summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"