author | zautrix <zautrix> | 2004-09-12 17:18:27 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-12 17:18:27 (UTC) |
commit | bc4153a99e205f43d0144e2e910730dd1a14d402 (patch) (unidiff) | |
tree | 16aeb28cd765539bac6e85e714478f31a7b93bac /libkcal | |
parent | a222c2f7369eeefd19454c973c0cc48300f72bec (diff) | |
download | kdepimpi-bc4153a99e205f43d0144e2e910730dd1a14d402.zip kdepimpi-bc4153a99e205f43d0144e2e910730dd1a14d402.tar.gz kdepimpi-bc4153a99e205f43d0144e2e910730dd1a14d402.tar.bz2 |
added missing sync featute
-rw-r--r-- | libkcal/phoneformat.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index ef69bce..6d0da5c 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -266,26 +266,24 @@ ulong PhoneFormat::getCsum( const QStringList & attList) | |||
266 | if ( ! s.isEmpty() ){ | 266 | if ( ! s.isEmpty() ){ |
267 | j = s.length(); | 267 | j = s.length(); |
268 | for ( k = 0; k < j; ++k ) { | 268 | for ( k = 0; k < j; ++k ) { |
269 | int mul = k +1; | 269 | int mul = k +1; |
270 | add = s[k].unicode (); | 270 | add = s[k].unicode (); |
271 | if ( k < 16 ) | 271 | if ( k < 16 ) |
272 | mul = mul * mul; | 272 | mul = mul * mul; |
273 | int ii = i+1; | 273 | int ii = i+1; |
274 | add = add * mul *ii*ii*ii; | 274 | add = add * mul *ii*ii*ii; |
275 | cSum += add; | 275 | cSum += add; |
276 | } | 276 | } |
277 | } | 277 | } |
278 | if ( i == 0 ) | ||
279 | qDebug("csum: i == 0 %d ", cSum); | ||
280 | 278 | ||
281 | } | 279 | } |
282 | QString dump = attList.join(","); | 280 | QString dump = attList.join(","); |
283 | qDebug("csum: %d %s", cSum,dump.latin1()); | 281 | qDebug("csum: %d %s", cSum,dump.latin1()); |
284 | 282 | ||
285 | return cSum; | 283 | return cSum; |
286 | 284 | ||
287 | } | 285 | } |
288 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
289 | #include <stdlib.h> | 287 | #include <stdlib.h> |
290 | #define DEBUGMODE false | 288 | #define DEBUGMODE false |
291 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
@@ -458,31 +456,30 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from ) | |||
458 | else if (to->priority() == 4 && from->priority() == 5 ) | 456 | else if (to->priority() == 4 && from->priority() == 5 ) |
459 | ; | 457 | ; |
460 | else | 458 | else |
461 | to->setPriority(from->priority()); | 459 | to->setPriority(from->priority()); |
462 | 460 | ||
463 | } | 461 | } |
464 | #include <qcstring.h> | 462 | #include <qcstring.h> |
465 | 463 | ||
466 | void PhoneFormat::afterSave( Incidence* inc) | 464 | void PhoneFormat::afterSave( Incidence* inc) |
467 | { | 465 | { |
468 | uint csum; | 466 | uint csum; |
469 | inc->removeID( mProfileName ); | 467 | inc->removeID( mProfileName ); |
470 | #if 0 | ||
471 | if ( inc->type() == "Event") | 468 | if ( inc->type() == "Event") |
472 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); | 469 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); |
473 | else | 470 | else |
474 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); | 471 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); |
475 | inc->setCsum( mProfileName, QString::number( csum )); | 472 | inc->setCsum( mProfileName, QString::number( csum )); |
476 | #endif | 473 | |
477 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 474 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
478 | 475 | ||
479 | } | 476 | } |
480 | bool PhoneFormat::save( Calendar *calendar) | 477 | bool PhoneFormat::save( Calendar *calendar) |
481 | { | 478 | { |
482 | QLabel status ( i18n(" Opening device ..."), 0 ); | 479 | QLabel status ( i18n(" Opening device ..."), 0 ); |
483 | int w = status.sizeHint().width()+20 ; | 480 | int w = status.sizeHint().width()+20 ; |
484 | if ( w < 200 ) w = 230; | 481 | if ( w < 200 ) w = 230; |
485 | int h = status.sizeHint().height()+20 ; | 482 | int h = status.sizeHint().height()+20 ; |
486 | int dw = QApplication::desktop()->width(); | 483 | int dw = QApplication::desktop()->width(); |
487 | int dh = QApplication::desktop()->height(); | 484 | int dh = QApplication::desktop()->height(); |
488 | status.setCaption(i18n("Writing to phone...") ); | 485 | status.setCaption(i18n("Writing to phone...") ); |
@@ -505,25 +502,29 @@ bool PhoneFormat::save( Calendar *calendar) | |||
505 | calendar->deleteEvent( ev ); | 502 | calendar->deleteEvent( ev ); |
506 | } else { | 503 | } else { |
507 | 504 | ||
508 | } | 505 | } |
509 | ev = er.next(); | 506 | ev = er.next(); |
510 | } | 507 | } |
511 | // 2 remove todos which should be deleted | 508 | // 2 remove todos which should be deleted |
512 | QPtrList<Todo> tl = calendar->rawTodos(); | 509 | QPtrList<Todo> tl = calendar->rawTodos(); |
513 | Todo* to = tl.first(); | 510 | Todo* to = tl.first(); |
514 | while ( to ) { | 511 | while ( to ) { |
515 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 512 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
516 | calendar->deleteTodo( to ); | 513 | calendar->deleteTodo( to ); |
517 | } | 514 | } else { |
515 | if ( to->isCompleted()) { | ||
516 | calendar->deleteTodo( to ); | ||
517 | } | ||
518 | } | ||
518 | to = tl.next(); | 519 | to = tl.next(); |
519 | } | 520 | } |
520 | // 3 save file | 521 | // 3 save file |
521 | VCalFormat vfsave; | 522 | VCalFormat vfsave; |
522 | vfsave.setLocalTime ( true ); | 523 | vfsave.setLocalTime ( true ); |
523 | if ( ! vfsave.save( calendar, fileName ) ) | 524 | if ( ! vfsave.save( calendar, fileName ) ) |
524 | return false; | 525 | return false; |
525 | // 4 call kammu | 526 | // 4 call kammu |
526 | QString command ="./kammu --restore " + fileName ; | 527 | QString command ="./kammu --restore " + fileName ; |
527 | int ret; | 528 | int ret; |
528 | while ( (ret = system ( command.latin1())) != 0 ) { | 529 | while ( (ret = system ( command.latin1())) != 0 ) { |
529 | qDebug("Error S::command returned %d. asking users", ret); | 530 | qDebug("Error S::command returned %d. asking users", ret); |
@@ -554,25 +555,25 @@ bool PhoneFormat::save( Calendar *calendar) | |||
554 | ev = er.first(); | 555 | ev = er.first(); |
555 | message = i18n(" Comparing event # "); | 556 | message = i18n(" Comparing event # "); |
556 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | 557 | QPtrList<Event> er1 = calendarTemp->rawEvents(); |
557 | Event* ev1; | 558 | Event* ev1; |
558 | int procCount = 0; | 559 | int procCount = 0; |
559 | while ( ev ) { | 560 | while ( ev ) { |
560 | //qDebug("event new ID %s",ev->summary().latin1()); | 561 | //qDebug("event new ID %s",ev->summary().latin1()); |
561 | status.setText ( message + QString::number ( ++procCount ) ); | 562 | status.setText ( message + QString::number ( ++procCount ) ); |
562 | qApp->processEvents(); | 563 | qApp->processEvents(); |
563 | uint csum; | 564 | uint csum; |
564 | csum = PhoneFormat::getCsumEvent( ev ); | 565 | csum = PhoneFormat::getCsumEvent( ev ); |
565 | QString cSum = QString::number( csum ); | 566 | QString cSum = QString::number( csum ); |
566 | ev->setCsum( mProfileName, cSum ); | 567 | //ev->setCsum( mProfileName, cSum ); |
567 | //qDebug("Event cSum %s ", cSum.latin1()); | 568 | //qDebug("Event cSum %s ", cSum.latin1()); |
568 | ev1 = er1.first(); | 569 | ev1 = er1.first(); |
569 | while ( ev1 ) { | 570 | while ( ev1 ) { |
570 | if ( ev1->getCsum( mProfileName ) == cSum ) { | 571 | if ( ev1->getCsum( mProfileName ) == cSum ) { |
571 | er1.remove( ev1 ); | 572 | er1.remove( ev1 ); |
572 | afterSave( ev ); | 573 | afterSave( ev ); |
573 | ev->setID(mProfileName, ev1->getID(mProfileName) ); | 574 | ev->setID(mProfileName, ev1->getID(mProfileName) ); |
574 | //qDebug("Event found on phone for %s ", ev->summary().latin1()); | 575 | //qDebug("Event found on phone for %s ", ev->summary().latin1()); |
575 | 576 | ||
576 | break; | 577 | break; |
577 | } | 578 | } |
578 | ev1 = er1.next(); | 579 | ev1 = er1.next(); |
@@ -590,25 +591,25 @@ bool PhoneFormat::save( Calendar *calendar) | |||
590 | to = tl.first(); | 591 | to = tl.first(); |
591 | procCount = 0; | 592 | procCount = 0; |
592 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | 593 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); |
593 | Todo* to1 ; | 594 | Todo* to1 ; |
594 | message = i18n(" Comparing todo # "); | 595 | message = i18n(" Comparing todo # "); |
595 | while ( to ) { | 596 | while ( to ) { |
596 | qDebug("todo2 %d ", procCount); | 597 | qDebug("todo2 %d ", procCount); |
597 | status.setText ( message + QString::number ( ++procCount ) ); | 598 | status.setText ( message + QString::number ( ++procCount ) ); |
598 | qApp->processEvents(); | 599 | qApp->processEvents(); |
599 | uint csum; | 600 | uint csum; |
600 | csum = PhoneFormat::getCsumTodo( to ); | 601 | csum = PhoneFormat::getCsumTodo( to ); |
601 | QString cSum = QString::number( csum ); | 602 | QString cSum = QString::number( csum ); |
602 | to->setCsum( mProfileName, cSum ); | 603 | //to->setCsum( mProfileName, cSum ); |
603 | qDebug("Todo cSum %s ", cSum.latin1()); | 604 | qDebug("Todo cSum %s ", cSum.latin1()); |
604 | Todo* to1 = tl1.first(); | 605 | Todo* to1 = tl1.first(); |
605 | while ( to1 ) { | 606 | while ( to1 ) { |
606 | if ( to1->getCsum( mProfileName ) == cSum ) { | 607 | if ( to1->getCsum( mProfileName ) == cSum ) { |
607 | tl1.remove( to1 ); | 608 | tl1.remove( to1 ); |
608 | afterSave( to ); | 609 | afterSave( to ); |
609 | to->setID(mProfileName, to1->getID(mProfileName) ); | 610 | to->setID(mProfileName, to1->getID(mProfileName) ); |
610 | break; | 611 | break; |
611 | } | 612 | } |
612 | to1 = tl1.next(); | 613 | to1 = tl1.next(); |
613 | } | 614 | } |
614 | if ( ! to1 ) { | 615 | if ( ! to1 ) { |