summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandro Knauß <mail@sandroknauss.de>2014-05-12 19:54:39 (GMT)
committerSandro Knauß <mail@sandroknauss.de>2014-05-13 11:50:50 (GMT)
commit65cf8b1a574678a50bfc46abc66fce10b555a1bf (patch)
tree240f342a1910578fa49b16b1a2979cfcb79b68c1
parent62f1c49bc8b0c1ef314a910d16adf49f97278b88 (diff)
downloadlibcalendaring-65cf8b1a574678a50bfc46abc66fce10b555a1bf.tar.gz
KIMAP: Fixed METADATA support.
This is a comination of 5 commits made in kdepimlibs, but only the part that modifies kimap/getmetadatajob.cpp. with all commits between Tue Oct 29 09:54:21 2013 +0100 and Mon May 12 16:54:31 2014 +0200 excepting: commit 0140be4c1ffe5828ac409a5c0ffe7be91b8df264 Author: Christian Mollekopf <chrigi_1@fastmail.fm> Date: Fri Nov 8 22:56:44 2013 +0100 Use METADATA style annotations only. Applied patches: commit 61cfe3bcfd5541e071649469bb111aca71a7ebf7 Author: Sandro Knauß <mail@sandroknauss.de> Date: Mon May 12 16:54:31 2014 +0200 Added tests for ANNOTATEMORE mode. commit 2ed9d5f4074e30a8fc44776c5e2d7fd12064e5c5 Author: Sandro Knauß <mail@sandroknauss.de> Date: Mon May 12 16:39:50 2014 +0200 Make GETMETADATA RFC 5464 compatiple. commit 0a0cde867d115feff66871a0c248224541022510 Author: Christian Mollekopf <chrigi_1@fastmail.fm> Date: Sat Nov 16 10:32:24 2013 +0100 Skip NIL values as they simply indicate no value. commit 43d9d814c3dfc057c6e3514f24ef7823d2eebe2c Author: Christian Mollekopf <chrigi_1@fastmail.fm> Date: Tue Oct 29 09:54:21 2013 +0100 Fixed METADATA support for the GetMetaDataJob.
-rw-r--r--kimap/getmetadatajob.cpp66
1 files changed, 37 insertions, 29 deletions
diff --git a/kimap/getmetadatajob.cpp b/kimap/getmetadatajob.cpp
index 69be41d..4be0f69 100644
--- a/kimap/getmetadatajob.cpp
+++ b/kimap/getmetadatajob.cpp
@@ -65,50 +65,54 @@ void GetMetaDataJob::doStart()
if (d->serverCapability == Annotatemore) {
d->m_name = i18n("GetAnnotation");
command = "GETANNOTATION";
- if (d->entries.size() > 1)
+ if (d->entries.size() > 1) {
parameters += '(';
+ }
Q_FOREACH(const QByteArray &entry, d->entries) {
parameters += '\"' + entry + "\" ";
}
- if (d->entries.size() > 1)
+ if (d->entries.size() > 1) {
parameters[parameters.length() -1 ] = ')';
- else
- parameters.truncate(parameters.length() -1);
-
- parameters += ' ';
+ parameters += ' ';
+ }
- if (d->attributes.size() > 1)
+ if (d->attributes.size() > 1) {
parameters += '(';
+ }
Q_FOREACH(const QByteArray &attribute, d->attributes) {
parameters += '\"' + attribute + "\" ";
}
- if (d->attributes.size() > 1)
+ if (d->attributes.size() > 1) {
parameters[parameters.length() -1 ] = ')';
- else
+ } else {
parameters.truncate(parameters.length() -1);
-
+ }
} else {
- if (d->depth != "0") {
- parameters += "(DEPTH " + d->depth;
+
+ QByteArray options;
+ if ( d->depth != "0" ) {
+ options = "DEPTH " + d->depth;
}
- if (d->maxSize != -1) {
- parameters += "(MAXSIZE " + QByteArray::number(d->maxSize) + ')';
+ if ( d->maxSize != -1 ) {
+ if ( !options.isEmpty() ) {
+ options += ' ';
+ }
+ options += "MAXSIZE " + QByteArray::number( d->maxSize );
}
- if (d->depth != "0") {
- parameters += " )";
+
+ if ( !options.isEmpty() ) {
+ parameters = "(" + options + ") " + parameters;
}
- if (d->entries.size() > 1)
+ if ( d->entries.size() >= 1 ) {
parameters += '(';
- Q_FOREACH(const QByteArray &entry, d->entries) {
- parameters += '\"' + entry + "\" ";
+ Q_FOREACH ( const QByteArray &entry, d->entries ) {
+ parameters += entry + " ";
+ }
+ parameters[parameters.length() - 1 ] = ')';
+ } else {
+ parameters.truncate(parameters.length() -1);
}
- if (d->entries.size() > 1)
- parameters[parameters.length() -1 ] = ')';
- }
-
- if (d->entries.isEmpty()) {
- parameters += ')';
}
d->tags << d->sessionInternal()->sendCommand( command, parameters );
@@ -142,10 +146,14 @@ void GetMetaDataJob::handleResponse( const Message &response )
if (d->serverCapability == Metadata && response.content[1].toString() == "METADATA" ) {
QString mailBox = QString::fromUtf8( KIMAP::decodeImapFolderName( response.content[2].toString() ) );
- QList<QByteArray> entries = response.content[3].toList();
+ const QList<QByteArray> &entries = response.content[3].toList();
int i = 0;
- while ( i < entries.size() - 1) {
- d->metadata[mailBox][entries[i]][""] = entries[i + 1];
+ while ( i < entries.size() - 1 ) {
+ const QByteArray &value = entries[i + 1];
+ QByteArray &targetValue = d->metadata[mailBox][entries[i]][""];
+ if ( value != "NIL" ) { //This just indicates no value
+ targetValue = value;
+ }
i += 2;
}
}
@@ -209,4 +217,4 @@ QMap<QByteArray, QMap<QByteArray, QByteArray> > GetMetaDataJob::allMetaData(cons
return d->metadata[mailBox];
}
-#include "getmetadatajob.moc" \ No newline at end of file
+#include "getmetadatajob.moc"