-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 39 |
2 files changed, 4 insertions, 37 deletions
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp index 430c7b3..5eab1be 100644 --- a/kabc/plugins/qtopia/qtopiaconverter.cpp +++ b/kabc/plugins/qtopia/qtopiaconverter.cpp | |||
@@ -65,49 +65,49 @@ void QtopiaConverter::deinit() | |||
65 | delete catDB; | 65 | delete catDB; |
66 | catDB = 0; | 66 | catDB = 0; |
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) | 70 | bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) |
71 | { | 71 | { |
72 | // name | 72 | // name |
73 | addr.setFormattedName(contact.fileAs()); | 73 | addr.setFormattedName(contact.fileAs()); |
74 | addr.setFamilyName( contact.lastName() ); | 74 | addr.setFamilyName( contact.lastName() ); |
75 | addr.setGivenName( contact.firstName() ); | 75 | addr.setGivenName( contact.firstName() ); |
76 | addr.setAdditionalName( contact.middleName() ); | 76 | addr.setAdditionalName( contact.middleName() ); |
77 | addr.setPrefix( contact.nameTitle() ); | 77 | addr.setPrefix( contact.nameTitle() ); |
78 | addr.setSuffix( contact.suffix() ); | 78 | addr.setSuffix( contact.suffix() ); |
79 | 79 | ||
80 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 80 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
81 | QString exuid = contact.uid().toString(); | 81 | QString exuid = contact.uid().toString(); |
82 | addr.setOriginalExternalUID( exuid ); | 82 | addr.setOriginalExternalUID( exuid ); |
83 | int ente = exuid.find( "-0000"); | 83 | int ente = exuid.find( "-0000"); |
84 | if ( exuid.left(1) == "{" ) | 84 | if ( exuid.left(1) == "{" ) |
85 | exuid = exuid.mid(1); | 85 | exuid = exuid.mid(1); |
86 | if ( ente > -1 ) | 86 | if ( ente > -1 ) |
87 | exuid = exuid.left( ente-1 ); | 87 | exuid = exuid.left( ente-1 ); |
88 | addr.setExternalUID( exuid ); | 88 | addr.setExternalUID( exuid ); |
89 | qDebug("QtopiaConverter:set %s uid %s ",addr.originalExternalUID().latin1(),addr.externalUID().latin1() ); | 89 | // qDebug("QtopiaConverter:set %s uid %s ",addr.originalExternalUID().latin1(),addr.externalUID().latin1() ); |
90 | 90 | ||
91 | 91 | ||
92 | QStringList emails = contact.emailList(); | 92 | QStringList emails = contact.emailList(); |
93 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 93 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
94 | addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); | 94 | addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); |
95 | } | 95 | } |
96 | 96 | ||
97 | if (!contact.defaultEmail().isEmpty()) | 97 | if (!contact.defaultEmail().isEmpty()) |
98 | addr.insertEmail(contact.defaultEmail(), true); | 98 | addr.insertEmail(contact.defaultEmail(), true); |
99 | 99 | ||
100 | // home | 100 | // home |
101 | if ((!contact.homeStreet().isEmpty()) || | 101 | if ((!contact.homeStreet().isEmpty()) || |
102 | (!contact.homeCity().isEmpty()) || | 102 | (!contact.homeCity().isEmpty()) || |
103 | (!contact.homeState().isEmpty()) || | 103 | (!contact.homeState().isEmpty()) || |
104 | (!contact.homeZip().isEmpty()) || | 104 | (!contact.homeZip().isEmpty()) || |
105 | (!contact.homeCountry().isEmpty())) | 105 | (!contact.homeCountry().isEmpty())) |
106 | { | 106 | { |
107 | Address homeaddress; | 107 | Address homeaddress; |
108 | homeaddress.setType(Address::Home); | 108 | homeaddress.setType(Address::Home); |
109 | //US homeaddress.setPostOfficeBox( "" ); | 109 | //US homeaddress.setPostOfficeBox( "" ); |
110 | //US homeaddress.setExtended( "" ); | 110 | //US homeaddress.setExtended( "" ); |
111 | homeaddress.setStreet( contact.homeStreet() ); | 111 | homeaddress.setStreet( contact.homeStreet() ); |
112 | homeaddress.setLocality( contact.homeCity() ); | 112 | homeaddress.setLocality( contact.homeCity() ); |
113 | homeaddress.setRegion( contact.homeState() ); | 113 | homeaddress.setRegion( contact.homeState() ); |
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index adc7256..c013f52 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -208,144 +208,111 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
208 | AddresseeMap map; | 208 | AddresseeMap map; |
209 | CardId id ; | 209 | CardId id ; |
210 | 210 | ||
211 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 211 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
212 | 212 | ||
213 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 213 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
214 | QString uid = (*it).originalExternalUID(); | 214 | QString uid = (*it).originalExternalUID(); |
215 | bool res; | 215 | bool res; |
216 | if ( uid.isEmpty() ) | 216 | if ( uid.isEmpty() ) |
217 | id = 0; | 217 | id = 0; |
218 | else | 218 | else |
219 | id = uid.toUInt(); | 219 | id = uid.toUInt(); |
220 | KABC::Addressee addressee = (*it); | 220 | KABC::Addressee addressee = (*it); |
221 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { | 221 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { |
222 | res = mAccess->startEditCard(id); | 222 | res = mAccess->startEditCard(id); |
223 | if (res == true) | 223 | if (res == true) |
224 | { | 224 | { |
225 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); | 225 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); |
226 | if (res == true) | 226 | if (res == true) |
227 | { | 227 | { |
228 | res = mAccess->finishEditCard(&id); | 228 | res = mAccess->finishEditCard(&id); |
229 | //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 229 | //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
230 | //(*it).setExternalUID( QString::number( id ) ); | 230 | //(*it).setExternalUID( QString::number( id ) ); |
231 | //(*it).setOriginalExternalUID( QString::number( id ) ); | 231 | //(*it).setOriginalExternalUID( QString::number( id ) ); |
232 | map.insert(id,(*it).uid()); | 232 | map.insert(id,(*it).uid()); |
233 | |||
234 | #if 0 | ||
235 | KABC::Addressee addressee; | ||
236 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | ||
237 | addressee.setUid((*it).uid() ); | ||
238 | (it*).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
239 | res = mAccess->finishEditCard(&id); | ||
240 | //qDebug("2NEW id is %d", id); | ||
241 | addressee.setExternalUID( QString::number( id ) ); | ||
242 | addressee.setOriginalExternalUID( QString::number( id ) ); | ||
243 | changedAddressees.append( addressee ); | ||
244 | #endif | ||
245 | |||
246 | if (res == false) | 233 | if (res == false) |
247 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 234 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
248 | 235 | ||
249 | } | 236 | } |
250 | else | 237 | else |
251 | { | 238 | { |
252 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | 239 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); |
253 | mAccess->cancelEditCard(); | 240 | mAccess->cancelEditCard(); |
254 | } | 241 | } |
255 | } | 242 | } |
256 | 243 | ||
257 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 244 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
258 | res = mAccess->deleteCard(&id); | 245 | res = mAccess->deleteCard(&id); |
259 | if ( res ) | 246 | if ( !res ) |
260 | qDebug("delete success "); | ||
261 | else | ||
262 | qDebug("delete error "); | 247 | qDebug("delete error "); |
263 | 248 | ||
264 | 249 | ||
265 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 250 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
266 | //changed | 251 | //changed |
267 | qDebug("changed ****"); | ||
268 | res = mAccess->startEditCard(id); | 252 | res = mAccess->startEditCard(id); |
269 | if (res == true) | 253 | if (res == true) |
270 | { | 254 | { |
271 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); | 255 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); |
272 | if (res == true) | 256 | if (res == true) |
273 | { | 257 | { |
274 | res = mAccess->finishEditCard(&id); | 258 | res = mAccess->finishEditCard(&id); |
275 | //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | 259 | //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); |
276 | map.insert(id,(*it).uid()); | 260 | map.insert(id,(*it).uid()); |
277 | |||
278 | #if 0 | ||
279 | KABC::Addressee addressee; | ||
280 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | ||
281 | addressee.setUid((*it).uid() ); | ||
282 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | ||
283 | changedAddressees.append( addressee ); | ||
284 | res = mAccess->finishEditCard(&id); | ||
285 | #endif | ||
286 | if (res == false) | 261 | if (res == false) |
287 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 262 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
288 | 263 | ||
289 | } | 264 | } |
290 | else | 265 | else |
291 | { | 266 | { |
292 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | 267 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); |
293 | mAccess->cancelEditCard(); | 268 | mAccess->cancelEditCard(); |
294 | } | 269 | } |
295 | } | 270 | } |
296 | } | 271 | } |
297 | } | 272 | } |
298 | 273 | ||
299 | } | 274 | } |
300 | AddresseeMap::Iterator itam; | 275 | AddresseeMap::Iterator itam; |
301 | for ( res=mAccess->first(); res == true; res=mAccess->next()) | 276 | for ( res=mAccess->first(); res == true; res=mAccess->next()) |
302 | { | 277 | { |
303 | id = mAccess->cardId(); | 278 | id = mAccess->cardId(); |
304 | int idint = id; | 279 | int idint = id; |
305 | itam = map.find( idint ); | 280 | itam = map.find( idint ); |
306 | if ( itam != map.end() ) { | 281 | if ( itam != map.end() ) { |
307 | KABC::Addressee addressee; | 282 | KABC::Addressee addressee; |
308 | qDebug("found change %d %s ", idint, itam.data().latin1()); | ||
309 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 283 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
310 | 284 | ||
311 | if ( !addressee.isEmpty() && res ) | 285 | if ( !addressee.isEmpty() && res ) |
312 | { | 286 | { |
313 | addressee.setResource( this ); | 287 | addressee.setResource( this ); |
314 | addressee.setUid( itam.data() ); | 288 | addressee.setUid( itam.data() ); |
315 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 289 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
316 | addressBook()->insertAddressee( addressee , false ); | 290 | addressBook()->insertAddressee( addressee , false ); |
317 | } | 291 | } |
318 | } | 292 | } |
319 | } | 293 | } |
320 | #if 0 | 294 | |
321 | KABC::Addressee::List::Iterator it2; | ||
322 | for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) { | ||
323 | (*it2).computeCsum( "Sharp_DTM" ); | ||
324 | qDebug("CSUM: %s ",(*it2).getCsum( "Sharp_DTM" ).latin1() ); | ||
325 | addressBook()->insertAddressee((*it2)); | ||
326 | } | ||
327 | #endif | ||
328 | //US mAccess->save(); | 295 | //US mAccess->save(); |
329 | 296 | ||
330 | mDirWatch.startScan(); | 297 | mDirWatch.startScan(); |
331 | delete ticket; | 298 | delete ticket; |
332 | unlock( fileName() ); | 299 | unlock( fileName() ); |
333 | 300 | ||
334 | return true; | 301 | return true; |
335 | } | 302 | } |
336 | 303 | ||
337 | bool ResourceSharpDTM::lock( const QString &lockfileName ) | 304 | bool ResourceSharpDTM::lock( const QString &lockfileName ) |
338 | { | 305 | { |
339 | #ifdef ALLOW_LOCKING | 306 | #ifdef ALLOW_LOCKING |
340 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); | 307 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); |
341 | 308 | ||
342 | kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; | 309 | kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; |
343 | 310 | ||
344 | QString fn = lockfileName; | 311 | QString fn = lockfileName; |
345 | 312 | ||
346 | KURL url(fn); | 313 | KURL url(fn); |
347 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 314 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
348 | 315 | ||
349 | kdDebug(5700) << "-- lock name: " << lockName << endl; | 316 | kdDebug(5700) << "-- lock name: " << lockName << endl; |
350 | 317 | ||
351 | if (QFile::exists( lockName )) | 318 | if (QFile::exists( lockName )) |