summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp13
-rw-r--r--kabc/addressee.h2
-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.cpp78
-rw-r--r--kaddressbook/kabcore.cpp87
-rw-r--r--libkcal/sharpformat.cpp6
-rw-r--r--libkcal/syncdefines.h2
9 files changed, 141 insertions, 57 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 3a2dc5f..fda62f1 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -69,2 +69,3 @@ struct Addressee::AddresseeData : public KShared
69 QString externalUID; 69 QString externalUID;
70 QString originalExternalUID;
70 KURL url; 71 KURL url;
@@ -375,2 +376,14 @@ QString Addressee::externalUID() const
375} 376}
377void Addressee::setOriginalExternalUID( const QString &id )
378{
379 if ( id == mData->originalExternalUID ) return;
380 detach();
381 mData->empty = false;
382 mData->originalExternalUID = id;
383}
384
385QString Addressee::originalExternalUID() const
386{
387 return mData->originalExternalUID;
388}
376 389
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 3ba7777..8baa888 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -116,2 +116,4 @@ class Addressee
116 QString externalUID() const; 116 QString externalUID() const;
117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const;
117 void mergeContact( const Addressee& ad ); 119 void mergeContact( const Addressee& ad );
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
@@ -5,3 +5,3 @@ TARGET = 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
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
@@ -34,2 +34,3 @@ $Id$
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>
@@ -77,3 +78,6 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a
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");
@@ -253,2 +257,5 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &cont
253{ 257{
258
259
260
254 // name 261 // name
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
@@ -33,2 +33,3 @@ $Id$
33#include <qpe/pim/contact.h> 33#include <qpe/pim/contact.h>
34#include <qpe/quuid.h>
34 35
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
@@ -54,2 +54,4 @@ $Id$
54#include "resourceqtopia.h" 54#include "resourceqtopia.h"
55#include <libkdepim/ksyncprofile.h>
56#include <qpe/quuid.h>
55 57
@@ -191,34 +193,56 @@ bool ResourceQtopia::save( Ticket *ticket )
191{ 193{
192 qDebug("ResourceQtopia::save: %s", fileName().latin1()); 194 qDebug("ResourceQtopia::save: %s", fileName().latin1());
193 195
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() );
203 res = mConverter->addresseeToQtopia( *it, c ); 205 bool ok;
204 if (res == true) 206 PimContact c = mAccess->contactForId( uid, &ok );
205 { 207 res = mConverter->addresseeToQtopia( *it, c );
206 mAccess->addContact(c); 208 if (res == true) {
207// if (res == false) 209 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
208// qDebug("Unable to append Contact %s", c.fullName().latin1()); 210 mAccess->addContact(c);
211 KABC::Addressee addressee;
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 );
228 }
229 else
230 qDebug("Error update contact from qtopia ");
231
232 }
233
234 } else {
235 qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1());
236 }
237 }
209 } 238 }
210 else
211 {
212 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
213 }
214 }
215 239
216// mAccess->addressBookUpdated(); 240 // mAccess->addressBookUpdated();
217 241
218 mDirWatch.startScan(); 242 mDirWatch.startScan();
219 243
220 delete ticket; 244 delete ticket;
221 unlock( fileName() ); 245 unlock( fileName() );
222 246
223 return true; 247 return true;
224} 248}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d6482fb..b3d88de 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2754,3 +2754,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2754 skipIncidence = true; 2754 skipIncidence = true;
2755 QString idS; 2755 QString idS,OidS;
2756 qApp->processEvents(); 2756 qApp->processEvents();
@@ -2770,2 +2770,4 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2770 local->insertAddressee( inL, false ); 2770 local->insertAddressee( inL, false );
2771 idS = inR.externalUID();
2772 OidS = inR.originalExternalUID();
2771 } 2773 }
@@ -2776,4 +2778,8 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2776 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2778 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2777 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 2779 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2780 inR.setOriginalExternalUID( OidS );
2781 inR.setExternalUID( idS );
2782 } else {
2778 inR.setIDStr( idS ); 2783 inR.setIDStr( idS );
2784 }
2779 inR.setResource( 0 ); 2785 inR.setResource( 0 );
@@ -2781,3 +2787,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2781 ++changedRemote; 2787 ++changedRemote;
2782 } else { 2788 } else { // take == 2 take remote
2783 idS = inL.IDStr(); 2789 idS = inL.IDStr();
@@ -2856,3 +2862,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2856 inR = inL; 2862 inR = inL;
2857 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2863 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2858 inR.setResource( 0 ); 2864 inR.setResource( 0 );
@@ -2921,21 +2927,4 @@ bool KABCore::syncAB(QString filename, int mode)
2921 bool external = false; 2927 bool external = false;
2922 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2923 if ( ! lse.isEmpty() ) {
2924 if ( lse.familyName().left(4) == "!E: " )
2925 external = true;
2926 } else {
2927 bool found = false;
2928 QDateTime dt( QDate( 2004,1,1));
2929 AddressBook::Iterator it;
2930 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2931 if ( (*it).revision() != dt ) {
2932 found = true;
2933 break;
2934 }
2935 }
2936 external = ! found;
2937 }
2938 2928
2939 if ( external ) { 2929 if ( filename.right(4) == ".xml") {
2940 qDebug("Setting vcf mode to external ");
2941 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2930 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
@@ -2943,5 +2932,34 @@ bool KABCore::syncAB(QString filename, int mode)
2943 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2932 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2944 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2933 (*it).setID( mCurrentSyncDevice, (*it).externalUID() );
2945 (*it).computeCsum( mCurrentSyncDevice ); 2934 (*it).computeCsum( mCurrentSyncDevice );
2946 } 2935 }
2936 abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice );
2937
2938 } else {
2939 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2940 if ( ! lse.isEmpty() ) {
2941 if ( lse.familyName().left(4) == "!E: " )
2942 external = true;
2943 } else {
2944 bool found = false;
2945 QDateTime dt( QDate( 2004,1,1));
2946 AddressBook::Iterator it;
2947 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2948 if ( (*it).revision() != dt ) {
2949 found = true;
2950 break;
2951 }
2952 }
2953 external = ! found;
2954 }
2955
2956 if ( external ) {
2957 qDebug("Setting vcf mode to external ");
2958 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2959 AddressBook::Iterator it;
2960 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2961 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2962 (*it).computeCsum( mCurrentSyncDevice );
2963 }
2964 }
2947 } 2965 }
@@ -2952,4 +2970,2 @@ bool KABCore::syncAB(QString filename, int mode)
2952 //} 2970 //}
2953 if ( filename.right(4) == ".xml")
2954 abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice );
2955 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2971 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
@@ -2958,3 +2974,3 @@ bool KABCore::syncAB(QString filename, int mode)
2958 { 2974 {
2959 if ( external ) 2975 if ( external && filename.right(4) != ".xml")
2960 abLocal.removeDeletedAddressees(); 2976 abLocal.removeDeletedAddressees();
@@ -2962,2 +2978,21 @@ bool KABCore::syncAB(QString filename, int mode)
2962 abLocal.saveAB(); 2978 abLocal.saveAB();
2979 if ( external && filename.right(4) == ".xml") {
2980 // afterwrite processing
2981 AddressBook::Iterator it;
2982 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2983 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
2984 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
2985 Addressee ad = mAddressBook->findByUid( ( (*it).uid() ));
2986 if ( ad.isEmpty() ) {
2987 qDebug("ERROR ad empty ");
2988 } else {
2989 (*it).computeCsum( mCurrentSyncDevice );
2990 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
2991 ad.setID( mCurrentSyncDevice, (*it).externalUID() );
2992 ad.setCsum( mCurrentSyncDevice, (*it).getCsum( mCurrentSyncDevice ) );
2993 mAddressBook->insertAddressee( ad );
2994 }
2995 }
2996 }
2997 }
2963 } 2998 }
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index e7fc670..d56eab6 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -548,5 +548,5 @@ bool SharpFormat::save( Calendar *calendar)
548 command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName; 548 command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName;
549 qDebug("command ++++++++ "); 549 //qDebug("command ++++++++ ");
550 qDebug("%s ",command.latin1()); 550 //qDebug("%s ",command.latin1());
551 qDebug("command -------- "); 551 //qDebug("command -------- ");
552 system ( command.utf8() ); 552 system ( command.utf8() );
diff --git a/libkcal/syncdefines.h b/libkcal/syncdefines.h
index 57642ec..704a670 100644
--- a/libkcal/syncdefines.h
+++ b/libkcal/syncdefines.h
@@ -16,2 +16,3 @@
16#define SYNC_TEMPSTATE_INITIAL 0 16#define SYNC_TEMPSTATE_INITIAL 0
17#define SYNC_TEMPSTATE_ADDED_EXTERNAL -1
17#define SYNC_TEMPSTATE_NEW_EXTERNAL -2 18#define SYNC_TEMPSTATE_NEW_EXTERNAL -2
@@ -19,2 +20,3 @@
19#define SYNC_TEMPSTATE_NEW_ID -4 20#define SYNC_TEMPSTATE_NEW_ID -4
21#define SYNC_TEMPSTATE_NEW_CSUM -5
20 22