summaryrefslogtreecommitdiffstats
path: root/examples/imapresource/imapserverproxy.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-01-22 18:35:52 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-01-22 18:35:52 +0100
commitb05edd5644738e7608d13a8b5b679f43d70f4dd4 (patch)
tree9ac59a67057da63564d59ecc3f896b21bcacd322 /examples/imapresource/imapserverproxy.h
parente513ee41adb6061aa72de8bfe49d117f47c1545b (diff)
downloadsink-b05edd5644738e7608d13a8b5b679f43d70f4dd4.tar.gz
sink-b05edd5644738e7608d13a8b5b679f43d70f4dd4.zip
Don't treat the IMAP namespace as subfolder.
INBOX.INBOX means that the INBOX folder is in the INBOX. namespace.
Diffstat (limited to 'examples/imapresource/imapserverproxy.h')
-rw-r--r--examples/imapresource/imapserverproxy.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h
index 2175ca1..6785fc2 100644
--- a/examples/imapresource/imapserverproxy.h
+++ b/examples/imapresource/imapserverproxy.h
@@ -67,12 +67,12 @@ struct Message {
67 67
68struct Folder { 68struct Folder {
69 Folder() = default; 69 Folder() = default;
70 Folder(const QString &path, const QChar &separator, bool noselect_, bool subscribed_, const QByteArrayList &flags_) 70 Folder(const QString &path, const QString &ns, const QChar &separator, bool noselect_, bool subscribed_, const QByteArrayList &flags_)
71 : noselect(noselect_), 71 : noselect(noselect_),
72 subscribed(subscribed_), 72 subscribed(subscribed_),
73 flags(flags_), 73 flags(flags_),
74 mPath(path), 74 mPath(path),
75 pathParts(path.split(separator)), 75 mNamespace(ns),
76 mSeparator(separator) 76 mSeparator(separator)
77 { 77 {
78 } 78 }
@@ -91,13 +91,19 @@ struct Folder {
91 QString parentPath() const 91 QString parentPath() const
92 { 92 {
93 Q_ASSERT(!mSeparator.isNull()); 93 Q_ASSERT(!mSeparator.isNull());
94 auto parts = pathParts; 94 auto parts = mPath.split(mSeparator);
95 parts.removeLast(); 95 parts.removeLast();
96 return parts.join(mSeparator); 96 auto parentPath = parts.join(mSeparator);
97 //Don't return the namespace for root folders as parent folder
98 if (mNamespace.startsWith(parentPath)) {
99 return QString{};
100 }
101 return parentPath;
97 } 102 }
98 103
99 QString name() const 104 QString name() const
100 { 105 {
106 auto pathParts = mPath.split(mSeparator);
101 Q_ASSERT(!pathParts.isEmpty()); 107 Q_ASSERT(!pathParts.isEmpty());
102 return pathParts.last(); 108 return pathParts.last();
103 } 109 }
@@ -108,7 +114,7 @@ struct Folder {
108 114
109private: 115private:
110 QString mPath; 116 QString mPath;
111 QList<QString> pathParts; 117 QString mNamespace;
112 QChar mSeparator; 118 QChar mSeparator;
113}; 119};
114 120
@@ -178,6 +184,7 @@ public:
178 KAsync::Job<QVector<qint64>> fetchUids(const Folder &folder); 184 KAsync::Job<QVector<qint64>> fetchUids(const Folder &folder);
179 185
180private: 186private:
187 QString getNamespace(const QString &name);
181 QObject mGuard; 188 QObject mGuard;
182}; 189};
183 190