author | zautrix <zautrix> | 2004-09-20 18:59:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-20 18:59:02 (UTC) |
commit | 138be6cfa921cd8a07fa0b18046d955e7d2dbd6e (patch) (unidiff) | |
tree | 67b8b69e26641f4f048ce19e05b361f5aea6db85 | |
parent | 6b6a28919908134ccbb3badcb24c2dcae0d426a5 (diff) | |
download | kdepimpi-138be6cfa921cd8a07fa0b18046d955e7d2dbd6e.zip kdepimpi-138be6cfa921cd8a07fa0b18046d955e7d2dbd6e.tar.gz kdepimpi-138be6cfa921cd8a07fa0b18046d955e7d2dbd6e.tar.bz2 |
more DTM sync
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 95 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmE.pro | 2 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.cpp | 6 |
3 files changed, 100 insertions, 3 deletions
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index 867bc07..bba5f9a 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -36,24 +36,25 @@ $Id$ | |||
36 | //US #include <qtimer.h> | 36 | //US #include <qtimer.h> |
37 | 37 | ||
38 | #include <kapplication.h> | 38 | #include <kapplication.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kdebug.h> | 40 | #include <kdebug.h> |
41 | #include <klocale.h> | 41 | #include <klocale.h> |
42 | //US #include <ksavefile.h> | 42 | //US #include <ksavefile.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
45 | 45 | ||
46 | #include <sl/slzdb.h> | 46 | #include <sl/slzdb.h> |
47 | 47 | ||
48 | #include <libkdepim/ksyncprofile.h> | ||
48 | 49 | ||
49 | #include "resourcesharpdtmconfig.h" | 50 | #include "resourcesharpdtmconfig.h" |
50 | #include "resourcesharpdtm.h" | 51 | #include "resourcesharpdtm.h" |
51 | 52 | ||
52 | #include "syncprefwidget.h" | 53 | #include "syncprefwidget.h" |
53 | 54 | ||
54 | #include "stdaddressbook.h" | 55 | #include "stdaddressbook.h" |
55 | 56 | ||
56 | #include "sharpdtmconverter.h" | 57 | #include "sharpdtmconverter.h" |
57 | //#define ALLOW_LOCKING | 58 | //#define ALLOW_LOCKING |
58 | using namespace KABC; | 59 | using namespace KABC; |
59 | extern "C" | 60 | extern "C" |
@@ -193,53 +194,143 @@ bool ResourceSharpDTM::load() | |||
193 | 194 | ||
194 | return true; | 195 | return true; |
195 | } | 196 | } |
196 | 197 | ||
197 | bool ResourceSharpDTM::save( Ticket *ticket ) | 198 | bool ResourceSharpDTM::save( Ticket *ticket ) |
198 | { | 199 | { |
199 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); | 200 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); |
200 | 201 | ||
201 | mDirWatch.stopScan(); | 202 | mDirWatch.stopScan(); |
202 | 203 | ||
203 | KABC::AddressBook::Iterator it; | 204 | KABC::AddressBook::Iterator it; |
204 | bool res; | 205 | bool res; |
206 | KABC::Addressee::List changedAddressees; | ||
205 | 207 | ||
206 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 208 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
209 | |||
210 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | ||
211 | QString uid = (*it).originalExternalUID(); | ||
212 | CardId id ; | ||
213 | bool res; | ||
214 | if ( uid.isEmpty() ) | ||
215 | id = 0; | ||
216 | else | ||
217 | id = uid.toUInt(); | ||
218 | KABC::Addressee addressee = (*it); | ||
219 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { | ||
220 | res = mAccess->startEditCard(id); | ||
221 | if (res == true) | ||
222 | { | ||
223 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); | ||
224 | if (res == true) | ||
225 | { | ||
226 | KABC::Addressee addressee; | ||
227 | qDebug("1NEW id is %d", id); | ||
228 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | ||
229 | addressee.setUid((*it).uid() ); | ||
230 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | ||
231 | changedAddressees.append( addressee ); | ||
232 | res = mAccess->finishEditCard(&id); | ||
233 | qDebug("2NEW id is %d", id); | ||
234 | |||
235 | if (res == false) | ||
236 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | ||
237 | else { | ||
238 | qDebug("added card success "); | ||
239 | } | ||
240 | } | ||
241 | else | ||
242 | { | ||
243 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | ||
244 | mAccess->cancelEditCard(); | ||
245 | } | ||
246 | } | ||
247 | |||
248 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | ||
249 | res = mAccess->deleteCard(&id); | ||
250 | if ( res ) | ||
251 | qDebug("delete success "); | ||
252 | else | ||
253 | qDebug("delete error "); | ||
254 | |||
255 | |||
256 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | ||
257 | //changed | ||
258 | res = mAccess->startEditCard(id); | ||
259 | if (res == true) | ||
260 | { | ||
261 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); | ||
262 | if (res == true) | ||
263 | { | ||
264 | KABC::Addressee addressee; | ||
265 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | ||
266 | addressee.setUid((*it).uid() ); | ||
267 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | ||
268 | changedAddressees.append( addressee ); | ||
269 | res = mAccess->finishEditCard(&id); | ||
270 | if (res == false) | ||
271 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | ||
272 | else { | ||
273 | qDebug("change card succes "); | ||
274 | } | ||
275 | } | ||
276 | else | ||
277 | { | ||
278 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | ||
279 | mAccess->cancelEditCard(); | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | |||
284 | |||
285 | |||
286 | |||
287 | |||
288 | |||
289 | |||
290 | |||
291 | } | ||
292 | |||
293 | #if 0 | ||
294 | // old code | ||
207 | CardId id = 0;// 0 means new card | 295 | CardId id = 0;// 0 means new card |
208 | KABC::Addressee addressee = (*it); | 296 | KABC::Addressee addressee = (*it); |
209 | 297 | ||
210 | res = mAccess->startEditCard(id); | 298 | res = mAccess->startEditCard(id); |
211 | if (res == true) | 299 | if (res == true) |
212 | { | 300 | { |
213 | res = mConverter->addresseeToSharp( *it, mAccess, id ); | 301 | res = mConverter->addresseeToSharp( *it, mAccess, id ); |
214 | if (res == true) | 302 | if (res == true) |
215 | { | 303 | { |
216 | res = mAccess->finishEditCard(&id); | 304 | res = mAccess->finishEditCard(&id); |
217 | if (res == false) | 305 | if (res == false) |
218 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 306 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
219 | } | 307 | } |
220 | else | 308 | else |
221 | { | 309 | { |
222 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | 310 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); |
223 | mAccess->cancelEditCard(); | 311 | mAccess->cancelEditCard(); |
224 | } | 312 | } |
225 | } | 313 | } |
226 | else | 314 | else |
227 | { | 315 | { |
228 | qDebug("Unable to add new card. Addressee: %s", addressee.formattedName().latin1()); | 316 | qDebug("Unable to add new card. Addressee: %s", addressee.formattedName().latin1()); |
229 | } | 317 | } |
318 | #endif | ||
230 | 319 | ||
231 | } | 320 | } |
232 | 321 | KABC::Addressee::List::Iterator it2; | |
233 | //US mAccess->save(); | 322 | for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) |
323 | addressBook()->insertAddressee((*it2)); | ||
324 | //US mAccess->save(); | ||
234 | 325 | ||
235 | mDirWatch.startScan(); | 326 | mDirWatch.startScan(); |
236 | delete ticket; | 327 | delete ticket; |
237 | unlock( fileName() ); | 328 | unlock( fileName() ); |
238 | 329 | ||
239 | return true; | 330 | return true; |
240 | } | 331 | } |
241 | 332 | ||
242 | bool ResourceSharpDTM::lock( const QString &lockfileName ) | 333 | bool ResourceSharpDTM::lock( const QString &lockfileName ) |
243 | { | 334 | { |
244 | #ifdef ALLOW_LOCKING | 335 | #ifdef ALLOW_LOCKING |
245 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); | 336 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); |
diff --git a/kabc/plugins/sharpdtm/sharpdtmE.pro b/kabc/plugins/sharpdtm/sharpdtmE.pro index f335729..b80a1da 100644 --- a/kabc/plugins/sharpdtm/sharpdtmE.pro +++ b/kabc/plugins/sharpdtm/sharpdtmE.pro | |||
@@ -1,17 +1,17 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = microkabc_sharpdtm | 3 | TARGET = microkabc_sharpdtm |
4 | 4 | ||
5 | INCLUDEPATH += $(KDEPIMDIR)/kabc $(SHARPDTMSDK)/include $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include | 5 | INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/kabc $(SHARPDTMSDK)/include $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include |
6 | 6 | ||
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 += -lmicrokdepim | 13 | LIBS += -lmicrokdepim |
14 | LIBS += -lmicroqtcompat | 14 | LIBS += -lmicroqtcompat |
15 | LIBS += -lmicrokcal | 15 | LIBS += -lmicrokcal |
16 | LIBS += -L$(QPEDIR)/lib | 16 | LIBS += -L$(QPEDIR)/lib |
17 | LIBS += -ljpeg | 17 | LIBS += -ljpeg |
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp index 8f8334e..b065bf3 100644 --- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp | |||
@@ -60,24 +60,30 @@ bool SharpDTMConverter::init() | |||
60 | void SharpDTMConverter::deinit() | 60 | void SharpDTMConverter::deinit() |
61 | { | 61 | { |
62 | if (catDB) | 62 | if (catDB) |
63 | { | 63 | { |
64 | delete catDB; | 64 | delete catDB; |
65 | catDB = 0; | 65 | catDB = 0; |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) | 69 | bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) |
70 | { | 70 | { |
71 | SlZDataBase* db = (SlZDataBase*)database; | 71 | SlZDataBase* db = (SlZDataBase*)database; |
72 | |||
73 | // for syncing: we need setting of the two fields | ||
74 | addr.setExternalUID( QString::number( contact ) ); | ||
75 | addr.setOriginalExternalUID( QString::number( contact ) ); | ||
76 | |||
77 | |||
72 | // name | 78 | // name |
73 | qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); | 79 | qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); |
74 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); | 80 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); |
75 | 81 | ||
76 | addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); | 82 | addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); |
77 | addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); | 83 | addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); |
78 | addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); | 84 | addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); |
79 | addr.setPrefix( db->readField(ZdbAdrs::Title) ); | 85 | addr.setPrefix( db->readField(ZdbAdrs::Title) ); |
80 | addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); | 86 | addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); |
81 | 87 | ||
82 | 88 | ||
83 | 89 | ||