summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/qtopia
Unidiff
Diffstat (limited to 'kabc/plugins/qtopia') (more/less context) (show whitespace changes)
-rw-r--r--kabc/plugins/qtopia/qtopiaE.pro2
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp7
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.h1
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp42
4 files changed, 42 insertions, 10 deletions
diff --git a/kabc/plugins/qtopia/qtopiaE.pro b/kabc/plugins/qtopia/qtopiaE.pro
index 148da2a..c0aa960 100644
--- a/kabc/plugins/qtopia/qtopiaE.pro
+++ b/kabc/plugins/qtopia/qtopiaE.pro
@@ -1,12 +1,12 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3 3
4TARGET = microkabc_qtopia 4TARGET = microkabc_qtopia
5 5
6INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include 6INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include
7 7
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
10DESTDIR = $(QPEDIR)/lib 10DESTDIR = $(QPEDIR)/lib
11LIBS += -lmicrokde 11LIBS += -lmicrokde
12LIBS += -lmicrokabc 12LIBS += -lmicrokabc
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index 7d00a3f..de45e63 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -29,12 +29,13 @@ $Id$
29#include "kglobal.h" 29#include "kglobal.h"
30 30
31 31
32#include "qtopiaconverter.h" 32#include "qtopiaconverter.h"
33 33
34#include <qpe/categories.h> 34#include <qpe/categories.h>
35#include <libkdepim/ksyncprofile.h>
35//US #include <qpe/categoryselect.h> 36//US #include <qpe/categoryselect.h>
36 37
37 38
38using namespace KABC; 39using namespace KABC;
39 40
40QtopiaConverter::QtopiaConverter() : catDB(0) 41QtopiaConverter::QtopiaConverter() : catDB(0)
@@ -72,13 +73,16 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a
72 addr.setFormattedName(contact.fileAs()); 73 addr.setFormattedName(contact.fileAs());
73 addr.setFamilyName( contact.lastName() ); 74 addr.setFamilyName( contact.lastName() );
74 addr.setGivenName( contact.firstName() ); 75 addr.setGivenName( contact.firstName() );
75 addr.setAdditionalName( contact.middleName() ); 76 addr.setAdditionalName( contact.middleName() );
76 addr.setPrefix( contact.nameTitle() ); 77 addr.setPrefix( contact.nameTitle() );
77 addr.setSuffix( contact.suffix() ); 78 addr.setSuffix( contact.suffix() );
79
80 addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
78 QString exuid = contact.uid().toString(); 81 QString exuid = contact.uid().toString();
82 addr.setOriginalExternalUID( exuid );
79 int ente = exuid.find( "-0000"); 83 int ente = exuid.find( "-0000");
80 if ( exuid.left(1) == "{" ) 84 if ( exuid.left(1) == "{" )
81 exuid = exuid.mid(1); 85 exuid = exuid.mid(1);
82 if ( ente > -1 ) 86 if ( ente > -1 )
83 exuid = exuid.left( ente-1 ); 87 exuid = exuid.left( ente-1 );
84 addr.setExternalUID( exuid ); 88 addr.setExternalUID( exuid );
@@ -248,12 +252,15 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a
248 252
249 return true; 253 return true;
250} 254}
251 255
252bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact ) 256bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact )
253{ 257{
258
259
260
254 // name 261 // name
255 contact.setLastName(addr.familyName()); 262 contact.setLastName(addr.familyName());
256 contact.setFirstName(addr.givenName()); 263 contact.setFirstName(addr.givenName());
257 contact.setMiddleName(addr.additionalName()); 264 contact.setMiddleName(addr.additionalName());
258 contact.setNameTitle(addr.prefix()); 265 contact.setNameTitle(addr.prefix());
259 contact.setSuffix(addr.suffix()); 266 contact.setSuffix(addr.suffix());
diff --git a/kabc/plugins/qtopia/qtopiaconverter.h b/kabc/plugins/qtopia/qtopiaconverter.h
index 8f4c698..012a6e2 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.h
+++ b/kabc/plugins/qtopia/qtopiaconverter.h
@@ -28,12 +28,13 @@ $Id$
28#define KABC_QTOPIACONVERTER_H 28#define KABC_QTOPIACONVERTER_H
29 29
30#include <qstring.h> 30#include <qstring.h>
31 31
32#include "addressee.h" 32#include "addressee.h"
33#include <qpe/pim/contact.h> 33#include <qpe/pim/contact.h>
34#include <qpe/quuid.h>
34 35
35class Categories; 36class Categories;
36 37
37namespace KABC { 38namespace KABC {
38 39
39class QtopiaConverter 40class QtopiaConverter
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 48a9f22..935a1cf 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -49,12 +49,14 @@ $Id$
49#include "stdaddressbook.h" 49#include "stdaddressbook.h"
50 50
51#include "qtopiaconverter.h" 51#include "qtopiaconverter.h"
52#include "syncprefwidget.h" 52#include "syncprefwidget.h"
53 53
54#include "resourceqtopia.h" 54#include "resourceqtopia.h"
55#include <libkdepim/ksyncprofile.h>
56#include <qpe/quuid.h>
55 57
56using namespace KABC; 58using namespace KABC;
57extern "C" 59extern "C"
58{ 60{
59 void *init_microkabc_qtopia() 61 void *init_microkabc_qtopia()
60 { 62 {
@@ -194,25 +196,47 @@ bool ResourceQtopia::save( Ticket *ticket )
194 mDirWatch.stopScan(); 196 mDirWatch.stopScan();
195 197
196 KABC::AddressBook::Iterator it; 198 KABC::AddressBook::Iterator it;
197 bool res; 199 bool res;
198 200
199 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 201 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
200 PimContact c; 202 //KABC::Addressee addressee = (*it);
201 KABC::Addressee addressee = (*it); 203 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
202 204 QUuid uid( (*it).originalExternalUID() );
205 bool ok;
206 PimContact c = mAccess->contactForId( uid, &ok );
203 res = mConverter->addresseeToQtopia( *it, c ); 207 res = mConverter->addresseeToQtopia( *it, c );
204 if (res == true) 208 if (res == true) {
205 { 209 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
206 mAccess->addContact(c); 210 mAccess->addContact(c);
207// if (res == false) 211 KABC::Addressee addressee;
208// qDebug("Unable to append Contact %s", c.fullName().latin1()); 212 mConverter->qtopiaToAddressee( c, addressee );
213 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
214 addressBook()->insertAddressee( addressee );
215
216 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
217 if ( ok )
218 mAccess->removeContact(c);
219 else
220 qDebug("Error revoe contact from qtopia ");
221 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
222 if ( ok ) {
223 mAccess->updateContact(c);
224 KABC::Addressee addressee;
225 mConverter->qtopiaToAddressee( c, addressee );
226 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
227 addressBook()->insertAddressee( addressee );
209 } 228 }
210 else 229 else
211 { 230 qDebug("Error update contact from qtopia ");
212 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); 231
232 }
233
234 } else {
235 qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1());
236 }
213 } 237 }
214 } 238 }
215 239
216// mAccess->addressBookUpdated(); 240// mAccess->addressBookUpdated();
217 241
218 mDirWatch.startScan(); 242 mDirWatch.startScan();