-rw-r--r-- | libkcal/phoneformat.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 0bc9125..2ad1b5a 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -255,65 +255,66 @@ ulong PhoneFormat::getCsum( const QStringList & attList) | |||
255 | ulong cSum = 0; | 255 | ulong cSum = 0; |
256 | int j,k,i; | 256 | int j,k,i; |
257 | int add; | 257 | int add; |
258 | for ( i = 1; i < max ; ++i ) { | 258 | for ( i = 1; i < max ; ++i ) { |
259 | QString s = attList[i]; | 259 | QString s = attList[i]; |
260 | if ( ! s.isEmpty() ){ | 260 | if ( ! s.isEmpty() ){ |
261 | j = s.length(); | 261 | j = s.length(); |
262 | for ( k = 0; k < j; ++k ) { | 262 | for ( k = 0; k < j; ++k ) { |
263 | int mul = k +1; | 263 | int mul = k +1; |
264 | add = s[k].unicode (); | 264 | add = s[k].unicode (); |
265 | if ( k < 16 ) | 265 | if ( k < 16 ) |
266 | mul = mul * mul; | 266 | mul = mul * mul; |
267 | add = add * mul *i*i*i; | 267 | add = add * mul *i*i*i; |
268 | cSum += add; | 268 | cSum += add; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | } | 271 | } |
272 | return cSum; | 272 | return cSum; |
273 | 273 | ||
274 | } | 274 | } |
275 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 275 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
276 | #include <stdlib.h> | 276 | #include <stdlib.h> |
277 | #define DEBUGMODE false | 277 | #define DEBUGMODE false |
278 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 278 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
279 | { | 279 | { |
280 | 280 | ||
281 | QString fileName; | 281 | QString fileName; |
282 | #ifdef _WIN32_ | 282 | #ifdef _WIN32_ |
283 | fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; | 283 | fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; |
284 | #else | 284 | #else |
285 | fileName = "/tmp/kdepimtemp.vcs"; | 285 | fileName = "/tmp/kdepimtemp.vcs"; |
286 | #endif | 286 | #endif |
287 | QString command ="./kammu --backup " + fileName + " -yes"; | 287 | QString command ="./kammu --backup " + fileName + " -yes -C" + |
288 | mConnection +" -D" + mDevice +" -M" + mModel; | ||
288 | int ret = system ( command.latin1() ); | 289 | int ret = system ( command.latin1() ); |
289 | if ( ret != 0 ) | 290 | if ( ret != 0 ) |
290 | return false; | 291 | return false; |
291 | VCalFormat vfload; | 292 | VCalFormat vfload; |
292 | vfload.setLocalTime ( true ); | 293 | vfload.setLocalTime ( true ); |
293 | if ( ! vfload.load( calendar, fileName ) ) | 294 | if ( ! vfload.load( calendar, fileName ) ) |
294 | return false; | 295 | return false; |
295 | QPtrList<Event> er = calendar->rawEvents(); | 296 | QPtrList<Event> er = calendar->rawEvents(); |
296 | Event* ev = er.first(); | 297 | Event* ev = er.first(); |
297 | while ( ev ) { | 298 | while ( ev ) { |
298 | int id = ev->pilotId(); | 299 | int id = ev->pilotId(); |
299 | Event *event; | 300 | Event *event; |
300 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 301 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
301 | if ( event ) { | 302 | if ( event ) { |
302 | event = (Event*)event->clone(); | 303 | event = (Event*)event->clone(); |
303 | copyEvent( event, ev ); | 304 | copyEvent( event, ev ); |
304 | calendar->deleteEvent( ev ); | 305 | calendar->deleteEvent( ev ); |
305 | calendar->addEvent( event); | 306 | calendar->addEvent( event); |
306 | } | 307 | } |
307 | else | 308 | else |
308 | event = ev; | 309 | event = ev; |
309 | uint cSum; | 310 | uint cSum; |
310 | cSum = PhoneFormat::getCsumEvent( event ); | 311 | cSum = PhoneFormat::getCsumEvent( event ); |
311 | event->setCsum( mProfileName, QString::number( cSum )); | 312 | event->setCsum( mProfileName, QString::number( cSum )); |
312 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 313 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
313 | event->setID( mProfileName,QString::number( id ) ); | 314 | event->setID( mProfileName,QString::number( id ) ); |
314 | ev = er.next(); | 315 | ev = er.next(); |
315 | } | 316 | } |
316 | { | 317 | { |
317 | QPtrList<Todo> tr = calendar->rawTodos(); | 318 | QPtrList<Todo> tr = calendar->rawTodos(); |
318 | Todo* ev = tr.first(); | 319 | Todo* ev = tr.first(); |
319 | while ( ev ) { | 320 | while ( ev ) { |
@@ -459,65 +460,66 @@ bool PhoneFormat::save( Calendar *calendar) | |||
459 | #ifdef _WIN32_ | 460 | #ifdef _WIN32_ |
460 | QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; | 461 | QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; |
461 | #else | 462 | #else |
462 | QString fileName = "/tmp/kdepimtemp.vcs"; | 463 | QString fileName = "/tmp/kdepimtemp.vcs"; |
463 | #endif | 464 | #endif |
464 | 465 | ||
465 | // 1 remove events which should be deleted | 466 | // 1 remove events which should be deleted |
466 | QPtrList<Event> er = calendar->rawEvents(); | 467 | QPtrList<Event> er = calendar->rawEvents(); |
467 | Event* ev = er.first(); | 468 | Event* ev = er.first(); |
468 | while ( ev ) { | 469 | while ( ev ) { |
469 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 470 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
470 | calendar->deleteEvent( ev ); | 471 | calendar->deleteEvent( ev ); |
471 | } else { | 472 | } else { |
472 | 473 | ||
473 | } | 474 | } |
474 | ev = er.next(); | 475 | ev = er.next(); |
475 | } | 476 | } |
476 | // 2 remove todos which should be deleted | 477 | // 2 remove todos which should be deleted |
477 | QPtrList<Todo> tl = calendar->rawTodos(); | 478 | QPtrList<Todo> tl = calendar->rawTodos(); |
478 | Todo* to = tl.first(); | 479 | Todo* to = tl.first(); |
479 | while ( to ) { | 480 | while ( to ) { |
480 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 481 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
481 | calendar->deleteTodo( to ); | 482 | calendar->deleteTodo( to ); |
482 | } | 483 | } |
483 | to = tl.next(); | 484 | to = tl.next(); |
484 | } | 485 | } |
485 | // 3 save file | 486 | // 3 save file |
486 | VCalFormat vfsave; | 487 | VCalFormat vfsave; |
487 | vfsave.setLocalTime ( true ); | 488 | vfsave.setLocalTime ( true ); |
488 | if ( ! vfsave.save( calendar, fileName ) ) | 489 | if ( ! vfsave.save( calendar, fileName ) ) |
489 | return false; | 490 | return false; |
490 | // 4 call kammu | 491 | // 4 call kammu |
491 | QString command ="./kammu --restore " + fileName ; | 492 | QString command ="./kammu --restore " + fileName + " -C" + |
493 | mConnection +" -D" + mDevice +" -M" + mModel;; | ||
492 | int ret = system ( command.latin1() ); | 494 | int ret = system ( command.latin1() ); |
493 | if ( ret != 0 ) | 495 | if ( ret != 0 ) |
494 | return false; | 496 | return false; |
495 | // 5 reread data | 497 | // 5 reread data |
496 | message = i18n(" Rereading all data ... "); | 498 | message = i18n(" Rereading all data ... "); |
497 | status.setText ( message ); | 499 | status.setText ( message ); |
498 | qApp->processEvents(); | 500 | qApp->processEvents(); |
499 | CalendarLocal* calendarTemp = new CalendarLocal(); | 501 | CalendarLocal* calendarTemp = new CalendarLocal(); |
500 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | 502 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); |
501 | if ( ! load( calendarTemp,calendar) ){ | 503 | if ( ! load( calendarTemp,calendar) ){ |
502 | qDebug("error reloading calendar "); | 504 | qDebug("error reloading calendar "); |
503 | delete calendarTemp; | 505 | delete calendarTemp; |
504 | return false; | 506 | return false; |
505 | } | 507 | } |
506 | // 6 compare data | 508 | // 6 compare data |
507 | 509 | ||
508 | //algo 6 compare event | 510 | //algo 6 compare event |
509 | er = calendar->rawEvents(); | 511 | er = calendar->rawEvents(); |
510 | ev = er.first(); | 512 | ev = er.first(); |
511 | message = i18n(" Comparing event # "); | 513 | message = i18n(" Comparing event # "); |
512 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | 514 | QPtrList<Event> er1 = calendarTemp->rawEvents(); |
513 | Event* ev1; | 515 | Event* ev1; |
514 | int procCount = 0; | 516 | int procCount = 0; |
515 | while ( ev ) { | 517 | while ( ev ) { |
516 | qDebug("event new ID "); | 518 | qDebug("event new ID "); |
517 | status.setText ( message + QString::number ( ++procCount ) ); | 519 | status.setText ( message + QString::number ( ++procCount ) ); |
518 | qApp->processEvents(); | 520 | qApp->processEvents(); |
519 | QString cSum = ev->getCsum(mProfileName); | 521 | QString cSum = ev->getCsum(mProfileName); |
520 | ev1 = er1.first(); | 522 | ev1 = er1.first(); |
521 | while ( ev1 ) { | 523 | while ( ev1 ) { |
522 | if ( ev1->getCsum( mProfileName ) == cSum ) { | 524 | if ( ev1->getCsum( mProfileName ) == cSum ) { |
523 | er1.remove( ev1 ); | 525 | er1.remove( ev1 ); |