[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim-runtime/KDE/4.11] resources/imap: Translate annotations from METADATA to ANNOTATEMORE style.
From:       Christian Mollekopf <chrigi_1 () fastmail ! fm>
Date:       2013-11-06 14:32:26
Message-ID: E1Ve49i-000693-Ps () scm ! kde ! org
[Download RAW message or body]

Git commit 0f44d8dee614f616f070d816977c0368c4637c65 by Christian Mollekopf.
Committed on 28/10/2013 at 18:37.
Pushed by cmollekopf into branch 'KDE/4.11'.

Translate annotations from METADATA to ANNOTATEMORE style.

The IMAP proxy and the collectionannotationsattribute currently only
support shared annotations.
To match what kmail and the kolabproxy expect, we translate all METADATA
annotations (/shared/vendor/...) to ANNOTATEMORE (/vendor/....) and back
when writing.

BUG: 301154

M  +6    -6    resources/imap/addcollectiontask.cpp
M  +8    -8    resources/imap/changecollectiontask.cpp
M  +12   -1    resources/imap/retrievecollectionmetadatatask.cpp

http://commits.kde.org/kdepim-runtime/0f44d8dee614f616f070d816977c0368c4637c65

diff --git a/resources/imap/addcollectiontask.cpp \
b/resources/imap/addcollectiontask.cpp index 04b4691..dbca8de 100644
--- a/resources/imap/addcollectiontask.cpp
+++ b/resources/imap/addcollectiontask.cpp
@@ -123,16 +123,16 @@ void AddCollectionTask::onSubscribeDone( KJob *job )
     } else {
       job->setServerCapability( KIMAP::MetaDataJobBase::Annotatemore );
     }
+    job->setMailBox( mailBoxForCollection( m_collection ) );
 
-    QByteArray attribute = entry;
     if ( job->serverCapability() == KIMAP::MetaDataJobBase::Annotatemore ) {
-      attribute = "value.shared";
+      job->setEntry( entry );
+      job->addMetaData( "value.shared", annotations[entry] );
+    } else {
+      //We stripped the /shared prefix when getting the metadata, so we need to \
readd it now +      job->addMetaData( QByteArray("/shared") + entry, \
annotations[entry] );  }
 
-    job->setMailBox( mailBoxForCollection( m_collection ) );
-    job->setEntry( entry );
-    job->addMetaData( attribute, annotations[entry] );
-
     connect( job, SIGNAL(result(KJob*)),
              this, SLOT(onSetMetaDataDone(KJob*)) );
 
diff --git a/resources/imap/changecollectiontask.cpp \
b/resources/imap/changecollectiontask.cpp index a0acd84..8cad5db 100644
--- a/resources/imap/changecollectiontask.cpp
+++ b/resources/imap/changecollectiontask.cpp
@@ -135,17 +135,17 @@ void ChangeCollectionTask::doStart( KIMAP::Session *session )
         } else {
           job->setServerCapability( KIMAP::MetaDataJobBase::Annotatemore );
         }
+        job->setMailBox( mailBoxForCollection( collection() ) );
 
-        QByteArray attribute = entry;
-        if ( job->serverCapability()==KIMAP::MetaDataJobBase::Annotatemore ) {
-          attribute = "value.shared";
+        if ( job->serverCapability() == KIMAP::MetaDataJobBase::Annotatemore ) {
+          job->setEntry( entry );
+          job->addMetaData( "value.shared", annotations[entry] );
+        } else {
+          //We stripped the /shared prefix when getting the metadata, so we need to \
readd it now +          job->addMetaData( QByteArray("/shared") + entry, \
annotations[entry] );  }
 
-        job->setMailBox( mailBoxForCollection( collection() ) );
-        job->setEntry( entry );
-        job->addMetaData( attribute, annotations[entry] );
-
-        kDebug( 5327 ) << "Job got entry:" << entry << " attribute:" << attribute << \
"value:" << annotations[entry]; +        kDebug( 5327 ) << "Job got entry:" << entry \
<< "value:" << annotations[entry];  
         connect( job, SIGNAL(result(KJob*)),
                  this, SLOT(onSetMetaDataDone(KJob*)) );
diff --git a/resources/imap/retrievecollectionmetadatatask.cpp \
b/resources/imap/retrievecollectionmetadatatask.cpp index b79bed4..10a7c7d 100644
--- a/resources/imap/retrievecollectionmetadatatask.cpp
+++ b/resources/imap/retrievecollectionmetadatatask.cpp
@@ -165,7 +165,18 @@ void RetrieveCollectionMetadataTask::onGetMetaDataDone( KJob \
*job )  }
 
   foreach ( const QByteArray &entry, rawAnnotations.keys() ) { \
                //krazy:exclude=foreach
-    annotations[entry] = rawAnnotations[entry][attribute];
+    QByteArray annotation = entry;
+    if ( meta->serverCapability() == KIMAP::MetaDataJobBase::Metadata ) {
+      // Convert the annotations to the same style as used with ANNOTATEMORE, \
without the /shared prefix +      // We're currently only supporting shared \
annotations, so this keeps things working for now. +      if ( annotation.startsWith( \
"/shared/" ) ) { +        annotation.remove( 0, QByteArray( "/shared" ).size() );
+      } else {
+        //Since we're only fetching /shared annotations, only the empty "/shared" \
entry should match here +        continue;
+      }
+    }
+    annotations[annotation] = rawAnnotations[entry][attribute];
   }
 
   // filter out unused and annoying Cyrus annotation \
/vendor/cmu/cyrus-imapd/lastupdate


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic