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

List:       kde-commits
Subject:    KDE/kdepim/akonadi/plugins
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2008-09-12 16:42:01
Message-ID: 1221237721.957715.15828.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 860316 by tokoe:

Add support for parts, so one can request parts of contacts
instead of all data.


 M  +1 -1      CMakeLists.txt  
 M  +59 -9     akonadi_serializer_addressee.cpp  


--- trunk/KDE/kdepim/akonadi/plugins/CMakeLists.txt #860315:860316
@@ -9,7 +9,7 @@
 
 set(akonadi_serializer_addressee_PART_SRCS akonadi_serializer_addressee.cpp )
 kde4_add_plugin(akonadi_serializer_addressee \
                ${akonadi_serializer_addressee_PART_SRCS})
-target_link_libraries(akonadi_serializer_addressee ${KDE4_KDECORE_LIBS} \
${KDE4_KABC_LIBS} ${KDE4_AKONADI_LIBS}) \
+target_link_libraries(akonadi_serializer_addressee ${KDE4_KDECORE_LIBS} \
${KDE4_KABC_LIBS} ${KDE4_AKONADI_LIBS} ${KDE4_AKONADI_KABC_LIBS})  install(TARGETS \
akonadi_serializer_addressee DESTINATION ${PLUGIN_INSTALL_DIR})  
 set(akonadi_serializer_mail_PART_SRCS akonadi_serializer_mail.cpp )
--- trunk/KDE/kdepim/akonadi/plugins/akonadi_serializer_addressee.cpp #860315:860316
@@ -26,6 +26,7 @@
 #include <kdebug.h>
 
 #include <akonadi/item.h>
+#include <akonadi/kabc/contactparts.h>
 
 using namespace Akonadi;
 
@@ -33,15 +34,37 @@
 {
     Q_UNUSED( version );
 
-    if ( label != Item::FullPayload )
-      return false;
+    KABC::Addressee addr;
+    if ( label == Item::FullPayload ) {
+        addr = m_converter.parseVCard( data.readAll() );
+    } else if ( label == Akonadi::ContactPart::Standard ) {
+        addr = m_converter.parseVCard( data.readAll() );
 
-    KABC::Addressee a = m_converter.parseVCard( data.readAll() );
-    if ( !a.isEmpty() ) {
-        item.setPayload<KABC::Addressee>( a );
+        // remove pictures and sound
+        addr.setPhoto( KABC::Picture() );
+        addr.setLogo( KABC::Picture() );
+        addr.setSound( KABC::Sound() );
+    } else if ( label == Akonadi::ContactPart::Lookup ) {
+        const KABC::Addressee temp = m_converter.parseVCard( data.readAll() );
+
+        // copy only uid, name and email addresses
+        addr.setUid( temp.uid() );
+        addr.setPrefix( temp.prefix() );
+        addr.setGivenName( temp.givenName() );
+        addr.setAdditionalName( temp.additionalName() );
+        addr.setFamilyName( temp.familyName() );
+        addr.setSuffix( temp.suffix() );
+        addr.setEmails( temp.emails() );
     } else {
+        return false;
+    }
+
+    if ( !addr.isEmpty() ) {
+        item.setPayload<KABC::Addressee>( addr );
+    } else {
         kWarning( 5261 ) << "Empty addressee object!";
     }
+
     return true;
 }
 
@@ -49,10 +72,37 @@
 {
     Q_UNUSED( version );
 
-    if ( label != Item::FullPayload || !item.hasPayload<KABC::Addressee>() )
-      return;
-    const KABC::Addressee a = item.payload<KABC::Addressee>();
-    data.write( m_converter.createVCard( a ) );
+    if ( label != Item::FullPayload && label != Akonadi::ContactPart::Standard && \
label != Akonadi::ContactPart::Lookup ) +        return;
+
+    if ( !item.hasPayload<KABC::Addressee>() )
+        return;
+
+    KABC::Addressee addr, temp;
+
+    temp = item.payload<KABC::Addressee>();
+
+    if ( label == Item::FullPayload ) {
+        addr = temp;
+    } else if ( label == Akonadi::ContactPart::Standard ) {
+        addr = temp;
+
+        // remove pictures and sound
+        addr.setPhoto( KABC::Picture() );
+        addr.setLogo( KABC::Picture() );
+        addr.setSound( KABC::Sound() );
+    } else if ( label == Akonadi::ContactPart::Lookup ) {
+        // copy only uid, name and email addresses
+        addr.setUid( temp.uid() );
+        addr.setPrefix( temp.prefix() );
+        addr.setGivenName( temp.givenName() );
+        addr.setAdditionalName( temp.additionalName() );
+        addr.setFamilyName( temp.familyName() );
+        addr.setSuffix( temp.suffix() );
+        addr.setEmails( temp.emails() );
+    }
+
+    data.write( m_converter.createVCard( addr ) );
 }
 
 Q_EXPORT_PLUGIN2( akonadi_serializer_addressee, Akonadi::SerializerPluginAddressee )


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

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