Warning, file /pim/trojita/src/Imap/Model/MailboxMetadata.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net> 0002 0003 This file is part of the Trojita Qt IMAP e-mail client, 0004 http://trojita.flaska.net/ 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public License as 0008 published by the Free Software Foundation; either version 2 of 0009 the License or (at your option) version 3 or any later version 0010 accepted by the membership of KDE e.V. (or its successor approved 0011 by the membership of KDE e.V.), which shall act as a proxy 0012 defined in Section 14 of version 3 of the license. 0013 0014 This program is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU General Public License for more details. 0018 0019 You should have received a copy of the GNU General Public License 0020 along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #ifndef IMAP_MODEL_MAILBOXMETADATA_H 0024 #define IMAP_MODEL_MAILBOXMETADATA_H 0025 0026 #include <QDebug> 0027 #include <QStringList> 0028 0029 namespace Imap 0030 { 0031 namespace Mailbox 0032 { 0033 0034 struct MailboxMetadata { 0035 QString mailbox; 0036 QString separator; 0037 QStringList flags; 0038 0039 MailboxMetadata(const QString &mailbox, const QString &separator, const QStringList &flags): 0040 mailbox(mailbox), separator(separator), flags(flags) {} 0041 MailboxMetadata() {} 0042 }; 0043 0044 inline bool operator==(const MailboxMetadata &a, const MailboxMetadata &b) 0045 { 0046 return a.mailbox == b.mailbox && a.separator == b.separator && a.flags == b.flags; 0047 } 0048 0049 inline bool operator!=(const MailboxMetadata &a, const MailboxMetadata &b) 0050 { 0051 return ! (a == b); 0052 } 0053 0054 /** @short Class for keeping track of information from the SELECT command */ 0055 class SyncState 0056 { 0057 uint m_exists, m_recent, m_unSeenCount, m_unSeenOffset, m_uidNext, m_uidValidity; 0058 quint64 m_highestModSeq; 0059 QStringList m_flags, m_permanentFlags; 0060 0061 bool m_hasExists, m_hasRecent, m_hasUnSeenCount, m_hasUnSeenOffset, m_hasUidNext, m_hasUidValidity, 0062 m_hasHighestModSeq, m_hasFlags, m_hasPermanentFlags; 0063 0064 friend QDebug operator<<(QDebug dbg, const Imap::Mailbox::SyncState &state); 0065 public: 0066 SyncState(); 0067 uint exists() const; 0068 uint recent() const; 0069 uint unSeenCount() const; 0070 uint unSeenOffset() const; 0071 uint uidNext() const; 0072 uint uidValidity() const; 0073 quint64 highestModSeq() const; 0074 QStringList flags() const; 0075 QStringList permanentFlags() const; 0076 0077 void setExists(const uint exists); 0078 void setRecent(const uint recent); 0079 void setUnSeenCount(const uint unSeenCount); 0080 void setUnSeenOffset(const uint unSeenOffset); 0081 void setUidNext(const uint uidNext); 0082 void setUidValidity(const uint uidValidity); 0083 void setHighestModSeq(const quint64 highestModSeq); 0084 void setFlags(const QStringList &flags); 0085 void setPermanentFlags(const QStringList &permanentFlags); 0086 0087 /** @short Return true if the record contains all items needed to display message numbers 0088 0089 Ie. check for EXISTS, RECENT and UNSEEN. 0090 */ 0091 bool isUsableForNumbers() const; 0092 /** @short Return true if all items really required for re-sync are available 0093 0094 These fields are just UIDNEXT, UIDVALIDITY and EXISTS. We don't care about 0095 crap like RECENT. 0096 */ 0097 bool isUsableForSyncing() const; 0098 bool isUsableForSyncingWithoutUidNext() const; 0099 0100 bool isUsableForCondstore() const; 0101 0102 /** @short Compare all members (including the hidden ones) with other */ 0103 bool completelyEqualTo(const SyncState &other) const; 0104 }; 0105 0106 QDebug operator<<(QDebug dbg, const Imap::Mailbox::SyncState &state); 0107 0108 } 0109 } 0110 0111 QDebug operator<<(QDebug dbg, const Imap::Mailbox::MailboxMetadata &metadata); 0112 0113 QDataStream &operator>>(QDataStream &stream, Imap::Mailbox::SyncState &ss); 0114 QDataStream &operator<<(QDataStream &stream, const Imap::Mailbox::SyncState &ss); 0115 QDataStream &operator>>(QDataStream &stream, Imap::Mailbox::MailboxMetadata &mm); 0116 QDataStream &operator<<(QDataStream &stream, const Imap::Mailbox::MailboxMetadata &mm); 0117 0118 #endif