author | zautrix <zautrix> | 2004-09-19 20:14:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-19 20:14:28 (UTC) |
commit | afa28a62314117555d6b32291188eedd1a576284 (patch) (unidiff) | |
tree | ea97a247de30a7a34480bc395e1996ab99247361 | |
parent | e0d8e062c9d8092e47dcadd88b30614ebff43c0c (diff) | |
download | kdepimpi-afa28a62314117555d6b32291188eedd1a576284.zip kdepimpi-afa28a62314117555d6b32291188eedd1a576284.tar.gz kdepimpi-afa28a62314117555d6b32291188eedd1a576284.tar.bz2 |
more AB sync
-rw-r--r-- | kabc/addressee.cpp | 13 | ||||
-rw-r--r-- | kabc/addressee.h | 2 | ||||
-rw-r--r-- | kabc/plugins/qtopia/qtopiaE.pro | 2 | ||||
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.cpp | 7 | ||||
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.h | 1 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 78 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 87 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 6 | ||||
-rw-r--r-- | libkcal/syncdefines.h | 2 |
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 | |||
@@ -58,24 +58,25 @@ struct Addressee::AddresseeData : public KShared | |||
58 | QDateTime birthday; | 58 | QDateTime birthday; |
59 | QString mailer; | 59 | QString mailer; |
60 | TimeZone timeZone; | 60 | TimeZone timeZone; |
61 | Geo geo; | 61 | Geo geo; |
62 | QString title; | 62 | QString title; |
63 | QString role; | 63 | QString role; |
64 | QString organization; | 64 | QString organization; |
65 | QString note; | 65 | QString note; |
66 | QString productId; | 66 | QString productId; |
67 | QDateTime revision; | 67 | QDateTime revision; |
68 | QString sortString; | 68 | QString sortString; |
69 | QString externalUID; | 69 | QString externalUID; |
70 | QString originalExternalUID; | ||
70 | KURL url; | 71 | KURL url; |
71 | Secrecy secrecy; | 72 | Secrecy secrecy; |
72 | Picture logo; | 73 | Picture logo; |
73 | Picture photo; | 74 | Picture photo; |
74 | Sound sound; | 75 | Sound sound; |
75 | Agent agent; | 76 | Agent agent; |
76 | QString mExternalId; | 77 | QString mExternalId; |
77 | PhoneNumber::List phoneNumbers; | 78 | PhoneNumber::List phoneNumbers; |
78 | Address::List addresses; | 79 | Address::List addresses; |
79 | Key::List keys; | 80 | Key::List keys; |
80 | QStringList emails; | 81 | QStringList emails; |
81 | QStringList categories; | 82 | QStringList categories; |
@@ -364,24 +365,36 @@ QString Addressee::IDStr() const | |||
364 | void Addressee::setExternalUID( const QString &id ) | 365 | void Addressee::setExternalUID( const QString &id ) |
365 | { | 366 | { |
366 | if ( id == mData->externalUID ) return; | 367 | if ( id == mData->externalUID ) return; |
367 | detach(); | 368 | detach(); |
368 | mData->empty = false; | 369 | mData->empty = false; |
369 | mData->externalUID = id; | 370 | mData->externalUID = id; |
370 | } | 371 | } |
371 | 372 | ||
372 | QString Addressee::externalUID() const | 373 | QString Addressee::externalUID() const |
373 | { | 374 | { |
374 | return mData->externalUID; | 375 | return mData->externalUID; |
375 | } | 376 | } |
377 | void Addressee::setOriginalExternalUID( const QString &id ) | ||
378 | { | ||
379 | if ( id == mData->originalExternalUID ) return; | ||
380 | detach(); | ||
381 | mData->empty = false; | ||
382 | mData->originalExternalUID = id; | ||
383 | } | ||
384 | |||
385 | QString Addressee::originalExternalUID() const | ||
386 | { | ||
387 | return mData->originalExternalUID; | ||
388 | } | ||
376 | 389 | ||
377 | void Addressee::setUid( const QString &id ) | 390 | void Addressee::setUid( const QString &id ) |
378 | { | 391 | { |
379 | if ( id == mData->uid ) return; | 392 | if ( id == mData->uid ) return; |
380 | detach(); | 393 | detach(); |
381 | mData->empty = false; | 394 | mData->empty = false; |
382 | mData->uid = id; | 395 | mData->uid = id; |
383 | } | 396 | } |
384 | 397 | ||
385 | QString Addressee::uid() const | 398 | QString Addressee::uid() const |
386 | { | 399 | { |
387 | if ( mData->uid.isEmpty() ) | 400 | if ( mData->uid.isEmpty() ) |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 3ba7777..8baa888 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -105,24 +105,26 @@ class Addressee | |||
105 | QString getID( const QString & ); | 105 | QString getID( const QString & ); |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | QString getCsum( const QString & ); | 107 | QString getCsum( const QString & ); |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
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 ); |
118 | /** | 120 | /** |
119 | Set unique identifier. | 121 | Set unique identifier. |
120 | */ | 122 | */ |
121 | void setUid( const QString &uid ); | 123 | void setUid( const QString &uid ); |
122 | /** | 124 | /** |
123 | Return unique identifier. | 125 | Return unique identifier. |
124 | */ | 126 | */ |
125 | QString uid() const; | 127 | QString uid() const; |
126 | /** | 128 | /** |
127 | Return translated label for uid field. | 129 | Return translated label for uid field. |
128 | */ | 130 | */ |
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,18 +1,18 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | 3 | ||
4 | TARGET = microkabc_qtopia | 4 | TARGET = microkabc_qtopia |
5 | 5 | ||
6 | INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include | 6 | INCLUDEPATH += $(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 | ||
8 | OBJECTS_DIR = obj/$(PLATFORM) | 8 | OBJECTS_DIR = obj/$(PLATFORM) |
9 | MOC_DIR = moc/$(PLATFORM) | 9 | MOC_DIR = moc/$(PLATFORM) |
10 | DESTDIR = $(QPEDIR)/lib | 10 | DESTDIR = $(QPEDIR)/lib |
11 | LIBS += -lmicrokde | 11 | LIBS += -lmicrokde |
12 | LIBS += -lmicrokabc | 12 | LIBS += -lmicrokabc |
13 | LIBS += -L$(QPEDIR)/lib | 13 | LIBS += -L$(QPEDIR)/lib |
14 | LIBS += -lqpepim | 14 | LIBS += -lqpepim |
15 | LIBS += -lqpe | 15 | LIBS += -lqpe |
16 | 16 | ||
17 | INTERFACES = \ | 17 | INTERFACES = \ |
18 | 18 | ||
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 | |||
@@ -23,24 +23,25 @@ Enhanced Version of the file for platform independent KDE tools. | |||
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | //US | 28 | //US |
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 | ||
38 | using namespace KABC; | 39 | using namespace KABC; |
39 | 40 | ||
40 | QtopiaConverter::QtopiaConverter() : catDB(0) | 41 | QtopiaConverter::QtopiaConverter() : catDB(0) |
41 | { | 42 | { |
42 | } | 43 | } |
43 | 44 | ||
44 | QtopiaConverter::~QtopiaConverter() | 45 | QtopiaConverter::~QtopiaConverter() |
45 | { | 46 | { |
46 | deinit(); | 47 | deinit(); |
@@ -66,25 +67,28 @@ void QtopiaConverter::deinit() | |||
66 | } | 67 | } |
67 | } | 68 | } |
68 | 69 | ||
69 | bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) | 70 | bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) |
70 | { | 71 | { |
71 | // name | 72 | // name |
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 ); |
85 | //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() ); | 89 | //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() ); |
86 | 90 | ||
87 | 91 | ||
88 | QStringList emails = contact.emailList(); | 92 | QStringList emails = contact.emailList(); |
89 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 93 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
90 | addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); | 94 | addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); |
@@ -242,24 +246,27 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
242 | cat = catDB->label("contact", catArray[i]); | 246 | cat = catDB->label("contact", catArray[i]); |
243 | if ( cat.isEmpty() ) | 247 | if ( cat.isEmpty() ) |
244 | addr.insertCategory(QString::number(catArray[i])); | 248 | addr.insertCategory(QString::number(catArray[i])); |
245 | else | 249 | else |
246 | addr.insertCategory( cat ); | 250 | addr.insertCategory( cat ); |
247 | } | 251 | } |
248 | 252 | ||
249 | return true; | 253 | return true; |
250 | } | 254 | } |
251 | 255 | ||
252 | bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact ) | 256 | bool 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()); |
260 | contact.setFileAs(); | 267 | contact.setFileAs(); |
261 | 268 | ||
262 | 269 | ||
263 | 270 | ||
264 | QStringList emails = addr.emails(); | 271 | QStringList emails = addr.emails(); |
265 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 272 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
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 | |||
@@ -22,24 +22,25 @@ | |||
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | $Id$ | 24 | $Id$ |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef KABC_QTOPIACONVERTER_H | 27 | #ifndef KABC_QTOPIACONVERTER_H |
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 | ||
35 | class Categories; | 36 | class Categories; |
36 | 37 | ||
37 | namespace KABC { | 38 | namespace KABC { |
38 | 39 | ||
39 | class QtopiaConverter | 40 | class QtopiaConverter |
40 | { | 41 | { |
41 | public: | 42 | public: |
42 | 43 | ||
43 | /** | 44 | /** |
44 | * Constructor. | 45 | * Constructor. |
45 | */ | 46 | */ |
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 | |||
@@ -43,24 +43,26 @@ $Id$ | |||
43 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
44 | 44 | ||
45 | #include <qpe/pim/addressbookaccess.h> | 45 | #include <qpe/pim/addressbookaccess.h> |
46 | 46 | ||
47 | 47 | ||
48 | #include "resourceqtopiaconfig.h" | 48 | #include "resourceqtopiaconfig.h" |
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 | ||
56 | using namespace KABC; | 58 | using namespace KABC; |
57 | extern "C" | 59 | extern "C" |
58 | { | 60 | { |
59 | void *init_microkabc_qtopia() | 61 | void *init_microkabc_qtopia() |
60 | { | 62 | { |
61 | return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidgetContainer>(); | 63 | return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidgetContainer>(); |
62 | } | 64 | } |
63 | } | 65 | } |
64 | 66 | ||
65 | ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable ) | 67 | ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable ) |
66 | : Resource( config, syncable ), mConverter (0) | 68 | : Resource( config, syncable ), mConverter (0) |
@@ -180,56 +182,78 @@ bool ResourceQtopia::load() | |||
180 | if ( !addressee.isEmpty() && res ) | 182 | if ( !addressee.isEmpty() && res ) |
181 | { | 183 | { |
182 | addressee.setResource( this ); | 184 | addressee.setResource( this ); |
183 | addressBook()->insertAddressee( addressee ); | 185 | addressBook()->insertAddressee( addressee ); |
184 | } | 186 | } |
185 | } | 187 | } |
186 | 188 | ||
187 | return true; | 189 | return true; |
188 | } | 190 | } |
189 | 191 | ||
190 | bool ResourceQtopia::save( Ticket *ticket ) | 192 | 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 | } |
225 | 249 | ||
226 | bool ResourceQtopia::lock( const QString &lockfileName ) | 250 | bool ResourceQtopia::lock( const QString &lockfileName ) |
227 | { | 251 | { |
228 | qDebug("ResourceQtopia::lock: %s", fileName().latin1()); | 252 | qDebug("ResourceQtopia::lock: %s", fileName().latin1()); |
229 | 253 | ||
230 | kdDebug(5700) << "ResourceQtopia::lock()" << endl; | 254 | kdDebug(5700) << "ResourceQtopia::lock()" << endl; |
231 | 255 | ||
232 | QString fn = lockfileName; | 256 | QString fn = lockfileName; |
233 | 257 | ||
234 | KURL url(fn); | 258 | KURL url(fn); |
235 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 259 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d6482fb..b3d88de 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2743,52 +2743,58 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2743 | bar.show(); | 2743 | bar.show(); |
2744 | int modulo = (er.count()/10)+1; | 2744 | int modulo = (er.count()/10)+1; |
2745 | int incCounter = 0; | 2745 | int incCounter = 0; |
2746 | while ( incCounter < er.count()) { | 2746 | while ( incCounter < er.count()) { |
2747 | if ( ! bar.isVisible() ) | 2747 | if ( ! bar.isVisible() ) |
2748 | return false; | 2748 | return false; |
2749 | if ( incCounter % modulo == 0 ) | 2749 | if ( incCounter % modulo == 0 ) |
2750 | bar.setProgress( incCounter ); | 2750 | bar.setProgress( incCounter ); |
2751 | uid = er[ incCounter ]; | 2751 | uid = er[ incCounter ]; |
2752 | bool skipIncidence = false; | 2752 | bool skipIncidence = false; |
2753 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2753 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2754 | skipIncidence = true; | 2754 | skipIncidence = true; |
2755 | QString idS; | 2755 | QString idS,OidS; |
2756 | qApp->processEvents(); | 2756 | qApp->processEvents(); |
2757 | if ( !skipIncidence ) { | 2757 | if ( !skipIncidence ) { |
2758 | inL = local->findByUid( uid ); | 2758 | inL = local->findByUid( uid ); |
2759 | inR = remote->findByUid( uid ); | 2759 | inR = remote->findByUid( uid ); |
2760 | //inL.setResource( 0 ); | 2760 | //inL.setResource( 0 ); |
2761 | //inR.setResource( 0 ); | 2761 | //inR.setResource( 0 ); |
2762 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2762 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2763 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2763 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2764 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2764 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2765 | if ( take == 3 ) | 2765 | if ( take == 3 ) |
2766 | return false; | 2766 | return false; |
2767 | if ( take == 1 ) {// take local | 2767 | if ( take == 1 ) {// take local |
2768 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2768 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2769 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2769 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2770 | local->insertAddressee( inL, false ); | 2770 | local->insertAddressee( inL, false ); |
2771 | idS = inR.externalUID(); | ||
2772 | OidS = inR.originalExternalUID(); | ||
2771 | } | 2773 | } |
2772 | else | 2774 | else |
2773 | idS = inR.IDStr(); | 2775 | idS = inR.IDStr(); |
2774 | remote->removeAddressee( inR ); | 2776 | remote->removeAddressee( inR ); |
2775 | inR = inL; | 2777 | inR = inL; |
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 ); |
2780 | remote->insertAddressee( inR , false); | 2786 | remote->insertAddressee( inR , false); |
2781 | ++changedRemote; | 2787 | ++changedRemote; |
2782 | } else { | 2788 | } else { // take == 2 take remote |
2783 | idS = inL.IDStr(); | 2789 | idS = inL.IDStr(); |
2784 | local->removeAddressee( inL ); | 2790 | local->removeAddressee( inL ); |
2785 | inL = inR; | 2791 | inL = inR; |
2786 | inL.setIDStr( idS ); | 2792 | inL.setIDStr( idS ); |
2787 | inL.setResource( 0 ); | 2793 | inL.setResource( 0 ); |
2788 | local->insertAddressee( inL , false ); | 2794 | local->insertAddressee( inL , false ); |
2789 | ++changedLocal; | 2795 | ++changedLocal; |
2790 | } | 2796 | } |
2791 | } | 2797 | } |
2792 | } else { // no conflict | 2798 | } else { // no conflict |
2793 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2799 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2794 | QString des = addresseeLSync.note(); | 2800 | QString des = addresseeLSync.note(); |
@@ -2845,25 +2851,25 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2845 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2851 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2846 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2852 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2847 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2853 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2848 | local->removeAddressee( inL ); | 2854 | local->removeAddressee( inL ); |
2849 | ++deletedAddresseeL; | 2855 | ++deletedAddresseeL; |
2850 | } else { | 2856 | } else { |
2851 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2857 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2852 | inL.removeID(mCurrentSyncDevice ); | 2858 | inL.removeID(mCurrentSyncDevice ); |
2853 | ++addedAddresseeR; | 2859 | ++addedAddresseeR; |
2854 | inL.setRevision( modifiedCalendar ); | 2860 | inL.setRevision( modifiedCalendar ); |
2855 | local->insertAddressee( inL, false ); | 2861 | local->insertAddressee( inL, false ); |
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 ); |
2859 | remote->insertAddressee( inR, false ); | 2865 | remote->insertAddressee( inR, false ); |
2860 | } | 2866 | } |
2861 | } | 2867 | } |
2862 | } else { | 2868 | } else { |
2863 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2869 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2864 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2870 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2865 | local->removeAddressee( inL ); | 2871 | local->removeAddressee( inL ); |
2866 | ++deletedAddresseeL; | 2872 | ++deletedAddresseeL; |
2867 | } else { | 2873 | } else { |
2868 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2874 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2869 | ++addedAddresseeR; | 2875 | ++addedAddresseeR; |
@@ -2910,65 +2916,94 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2910 | 2916 | ||
2911 | bool KABCore::syncAB(QString filename, int mode) | 2917 | bool KABCore::syncAB(QString filename, int mode) |
2912 | { | 2918 | { |
2913 | 2919 | ||
2914 | //pending prepare addresseeview for output | 2920 | //pending prepare addresseeview for output |
2915 | //pending detect, if remote file has REV field. if not switch to external sync | 2921 | //pending detect, if remote file has REV field. if not switch to external sync |
2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2922 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2917 | AddressBook abLocal(filename,"syncContact"); | 2923 | AddressBook abLocal(filename,"syncContact"); |
2918 | bool syncOK = false; | 2924 | bool syncOK = false; |
2919 | if ( abLocal.load() ) { | 2925 | if ( abLocal.load() ) { |
2920 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2926 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), 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; |
2942 | AddressBook::Iterator it; | 2931 | AddressBook::Iterator it; |
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 | } |
2948 | //AddressBook::Iterator it; | 2966 | //AddressBook::Iterator it; |
2949 | //QStringList vcards; | 2967 | //QStringList vcards; |
2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2968 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2951 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2969 | // qDebug("Name %s ", (*it).familyName().latin1()); |
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 ); |
2956 | if ( syncOK ) { | 2972 | if ( syncOK ) { |
2957 | if ( KABPrefs::instance()->mWriteBackFile ) | 2973 | if ( KABPrefs::instance()->mWriteBackFile ) |
2958 | { | 2974 | { |
2959 | if ( external ) | 2975 | if ( external && filename.right(4) != ".xml") |
2960 | abLocal.removeDeletedAddressees(); | 2976 | abLocal.removeDeletedAddressees(); |
2961 | qDebug("Saving remote AB "); | 2977 | qDebug("Saving remote AB "); |
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 | } |
2964 | } | 2999 | } |
2965 | setModified(); | 3000 | setModified(); |
2966 | 3001 | ||
2967 | } | 3002 | } |
2968 | if ( syncOK ) | 3003 | if ( syncOK ) |
2969 | mViewManager->refreshView(); | 3004 | mViewManager->refreshView(); |
2970 | return syncOK; | 3005 | return syncOK; |
2971 | #if 0 | 3006 | #if 0 |
2972 | 3007 | ||
2973 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 3008 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2974 | getEventViewerDialog()->setSyncMode( true ); | 3009 | getEventViewerDialog()->setSyncMode( true ); |
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index e7fc670..d56eab6 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -537,27 +537,27 @@ bool SharpFormat::save( Calendar *calendar) | |||
537 | else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new | 537 | else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new |
538 | QString fileNameIn = "/tmp/kopitempin"; | 538 | QString fileNameIn = "/tmp/kopitempin"; |
539 | QFile fileIn( fileNameIn ); | 539 | QFile fileIn( fileNameIn ); |
540 | if (!fileIn.open( IO_WriteOnly ) ) { | 540 | if (!fileIn.open( IO_WriteOnly ) ) { |
541 | return false; | 541 | return false; |
542 | } | 542 | } |
543 | QTextStream tsIn( &fileIn ); | 543 | QTextStream tsIn( &fileIn ); |
544 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 544 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
545 | tsIn << ePrefix << eString ; | 545 | tsIn << ePrefix << eString ; |
546 | fileIn.close(); | 546 | fileIn.close(); |
547 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 547 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
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() ); |
553 | QFile file( fileName ); | 553 | QFile file( fileName ); |
554 | if (!file.open( IO_ReadOnly ) ) { | 554 | if (!file.open( IO_ReadOnly ) ) { |
555 | return false; | 555 | return false; |
556 | 556 | ||
557 | } | 557 | } |
558 | QTextStream ts( &file ); | 558 | QTextStream ts( &file ); |
559 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 559 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
560 | answer = ts.read(); | 560 | answer = ts.read(); |
561 | file.close(); | 561 | file.close(); |
562 | //qDebug("answer \n%s ", answer.latin1()); | 562 | //qDebug("answer \n%s ", answer.latin1()); |
563 | getNumFromRecord( answer, ev ) ; | 563 | getNumFromRecord( answer, ev ) ; |
diff --git a/libkcal/syncdefines.h b/libkcal/syncdefines.h index 57642ec..704a670 100644 --- a/libkcal/syncdefines.h +++ b/libkcal/syncdefines.h | |||
@@ -5,18 +5,20 @@ | |||
5 | #define SYNC_PREF_LOCAL 0 | 5 | #define SYNC_PREF_LOCAL 0 |
6 | #define SYNC_PREF_REMOTE 1 | 6 | #define SYNC_PREF_REMOTE 1 |
7 | #define SYNC_PREF_NEWEST 2 | 7 | #define SYNC_PREF_NEWEST 2 |
8 | #define SYNC_PREF_ASK 3 | 8 | #define SYNC_PREF_ASK 3 |
9 | #define SYNC_PREF_FORCE_LOCAL 4 | 9 | #define SYNC_PREF_FORCE_LOCAL 4 |
10 | #define SYNC_PREF_FORCE_REMOTE 5 | 10 | #define SYNC_PREF_FORCE_REMOTE 5 |
11 | #define SYNC_PREF_TAKE_BOTH 6 | 11 | #define SYNC_PREF_TAKE_BOTH 6 |
12 | 12 | ||
13 | #define SYNC_MODE_NORMAL 0 | 13 | #define SYNC_MODE_NORMAL 0 |
14 | #define SYNC_MODE_EXTERNAL 1 | 14 | #define SYNC_MODE_EXTERNAL 1 |
15 | 15 | ||
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 |
18 | #define SYNC_TEMPSTATE_DELETE -3 | 19 | #define SYNC_TEMPSTATE_DELETE -3 |
19 | #define SYNC_TEMPSTATE_NEW_ID -4 | 20 | #define SYNC_TEMPSTATE_NEW_ID -4 |
21 | #define SYNC_TEMPSTATE_NEW_CSUM -5 | ||
20 | 22 | ||
21 | 23 | ||
22 | #endif | 24 | #endif |