File indexing completed on 2024-05-12 05:17:15
0001 /* 0002 SPDX-FileCopyrightText: 2009 Kevin Ottens <ervin@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "kimap_export.h" 0010 0011 #include "job.h" 0012 0013 namespace KIMAP 0014 { 0015 class Session; 0016 struct Response; 0017 class ListJobPrivate; 0018 0019 struct KIMAP_EXPORT MailBoxDescriptor { 0020 QString name; 0021 QChar separator; 0022 0023 inline bool operator==(const MailBoxDescriptor &other) const 0024 { 0025 return other.name == name && other.separator == separator; 0026 } 0027 0028 inline bool operator<(const MailBoxDescriptor &other) const 0029 { 0030 return other.name < name || (other.name == name && other.separator < separator); 0031 } 0032 }; 0033 0034 class KIMAP_EXPORT ListJob : public Job 0035 { 0036 Q_OBJECT 0037 Q_DECLARE_PRIVATE(ListJob) 0038 0039 friend class SessionPrivate; 0040 0041 public: 0042 enum Option { 0043 NoOption = 0x0, /**< List only subscribed mailboxes. (Uses the LSUB IMAP command.) */ 0044 IncludeUnsubscribed, /**< List subscribed and unsubscribed mailboxes. (Uses the LIST IMAP command.) */ 0045 IncludeFolderRoleFlags /**< List subscribed and unsubscribed mailboxes with flags to identify standard mailboxes whose name may be localized. 0046 The server must support the XLIST extension. */ 0047 }; 0048 0049 explicit ListJob(Session *session); 0050 ~ListJob() override; 0051 0052 KIMAP_DEPRECATED void setIncludeUnsubscribed(bool include); 0053 KIMAP_DEPRECATED bool isIncludeUnsubscribed() const; 0054 0055 void setOption(Option option); 0056 [[nodiscard]] Option option() const; 0057 0058 void setQueriedNamespaces(const QList<MailBoxDescriptor> &namespaces); 0059 [[nodiscard]] QList<MailBoxDescriptor> queriedNamespaces() const; 0060 0061 KIMAP_DEPRECATED QList<MailBoxDescriptor> mailBoxes() const; 0062 KIMAP_DEPRECATED QMap<MailBoxDescriptor, QList<QByteArray>> flags() const; 0063 0064 Q_SIGNALS: 0065 void mailBoxesReceived(const QList<KIMAP::MailBoxDescriptor> &descriptors, const QList<QList<QByteArray>> &flags); 0066 0067 protected: 0068 void doStart() override; 0069 void handleResponse(const Response &response) override; 0070 0071 private: 0072 Q_PRIVATE_SLOT(d_func(), void emitPendings()) 0073 0074 /** 0075 * @brief Converts a mailbox descriptor's name to uppercase if it is the Inbox or an Inbox subfolder. 0076 * This is according to the RFC3501, 5.1. Mailbox Naming section. 0077 * 0078 * @param descriptor the descriptor to convert, conversion happens in place 0079 **/ 0080 void convertInboxName(KIMAP::MailBoxDescriptor &descriptor); 0081 }; 0082 0083 }