author | zautrix <zautrix> | 2004-09-12 13:11:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-12 13:11:10 (UTC) |
commit | b2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26 (patch) (unidiff) | |
tree | a25dbba0cac09b7a7892405b11eb08c7d02e6b6b /libkcal | |
parent | 3c954091cb8d90c185403c68a8bbbb2a961f67fe (diff) | |
download | kdepimpi-b2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26.zip kdepimpi-b2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26.tar.gz kdepimpi-b2dede5d5735e2b4ab5afd51cf6a2c46d9be9b26.tar.bz2 |
many phonesync fixes
-rw-r--r-- | libkcal/phoneformat.cpp | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 2ad1b5a..6df639f 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | #include <kmessagebox.h> | ||
38 | 39 | ||
39 | #include "calendar.h" | 40 | #include "calendar.h" |
40 | #include "alarm.h" | 41 | #include "alarm.h" |
@@ -246,6 +247,8 @@ ulong PhoneFormat::getCsumEvent( Event* event ) | |||
246 | } | 247 | } |
247 | attList << list.join(""); | 248 | attList << list.join(""); |
248 | attList << event->categoriesStr(); | 249 | attList << event->categoriesStr(); |
250 | //qDebug("csum cat %s", event->categoriesStr().latin1()); | ||
251 | |||
249 | attList << event->secrecyStr(); | 252 | attList << event->secrecyStr(); |
250 | return PhoneFormat::getCsum(attList ); | 253 | return PhoneFormat::getCsum(attList ); |
251 | } | 254 | } |
@@ -269,6 +272,9 @@ ulong PhoneFormat::getCsum( const QStringList & attList) | |||
269 | } | 272 | } |
270 | } | 273 | } |
271 | } | 274 | } |
275 | //QString dump = attList.join(","); | ||
276 | //qDebug("csum: %s", dump.latin1()); | ||
277 | |||
272 | return cSum; | 278 | return cSum; |
273 | 279 | ||
274 | } | 280 | } |
@@ -287,15 +293,25 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | |||
287 | QString command ="./kammu --backup " + fileName + " -yes -C" + | 293 | QString command ="./kammu --backup " + fileName + " -yes -C" + |
288 | mConnection +" -D" + mDevice +" -M" + mModel; | 294 | mConnection +" -D" + mDevice +" -M" + mModel; |
289 | int ret = system ( command.latin1() ); | 295 | int ret = system ( command.latin1() ); |
290 | if ( ret != 0 ) | 296 | if ( ret != 0 ) { |
297 | qDebug("Error::command returned %d", ret); | ||
291 | return false; | 298 | return false; |
299 | } | ||
300 | qDebug("Command returned %d", ret); | ||
292 | VCalFormat vfload; | 301 | VCalFormat vfload; |
293 | vfload.setLocalTime ( true ); | 302 | vfload.setLocalTime ( true ); |
303 | qDebug("loading file ..."); | ||
304 | |||
294 | if ( ! vfload.load( calendar, fileName ) ) | 305 | if ( ! vfload.load( calendar, fileName ) ) |
295 | return false; | 306 | return false; |
296 | QPtrList<Event> er = calendar->rawEvents(); | 307 | QPtrList<Event> er = calendar->rawEvents(); |
297 | Event* ev = er.first(); | 308 | Event* ev = er.first(); |
309 | qDebug("reading events... "); | ||
298 | while ( ev ) { | 310 | while ( ev ) { |
311 | QStringList cat = ev->categories(); | ||
312 | if ( cat.contains( "MeetingDEF" )) { | ||
313 | ev->setCategories( QStringList() ); | ||
314 | } | ||
299 | int id = ev->pilotId(); | 315 | int id = ev->pilotId(); |
300 | Event *event; | 316 | Event *event; |
301 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 317 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
@@ -315,6 +331,7 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | |||
315 | ev = er.next(); | 331 | ev = er.next(); |
316 | } | 332 | } |
317 | { | 333 | { |
334 | qDebug("reading todos... "); | ||
318 | QPtrList<Todo> tr = calendar->rawTodos(); | 335 | QPtrList<Todo> tr = calendar->rawTodos(); |
319 | Todo* ev = tr.first(); | 336 | Todo* ev = tr.first(); |
320 | while ( ev ) { | 337 | while ( ev ) { |
@@ -482,7 +499,7 @@ bool PhoneFormat::save( Calendar *calendar) | |||
482 | calendar->deleteTodo( to ); | 499 | calendar->deleteTodo( to ); |
483 | } | 500 | } |
484 | to = tl.next(); | 501 | to = tl.next(); |
485 | } | 502 | } |
486 | // 3 save file | 503 | // 3 save file |
487 | VCalFormat vfsave; | 504 | VCalFormat vfsave; |
488 | vfsave.setLocalTime ( true ); | 505 | vfsave.setLocalTime ( true ); |
@@ -490,10 +507,19 @@ bool PhoneFormat::save( Calendar *calendar) | |||
490 | return false; | 507 | return false; |
491 | // 4 call kammu | 508 | // 4 call kammu |
492 | QString command ="./kammu --restore " + fileName + " -C" + | 509 | QString command ="./kammu --restore " + fileName + " -C" + |
493 | mConnection +" -D" + mDevice +" -M" + mModel;; | 510 | mConnection +" -D" + mDevice +" -M" + mModel; |
494 | int ret = system ( command.latin1() ); | 511 | int ret; |
495 | if ( ret != 0 ) | 512 | while ( (ret = system ( command.latin1())) != 0 ) { |
513 | qDebug("Error S::command returned %d. asking users", ret); | ||
514 | int retval = KMessageBox::warningContinueCancel(0, | ||
515 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); | ||
516 | if ( retval != KMessageBox::Continue ) | ||
517 | return false; | ||
518 | } | ||
519 | if ( ret != 0 ) { | ||
520 | qDebug("Error S::command returned %d", ret); | ||
496 | return false; | 521 | return false; |
522 | } | ||
497 | // 5 reread data | 523 | // 5 reread data |
498 | message = i18n(" Rereading all data ... "); | 524 | message = i18n(" Rereading all data ... "); |
499 | status.setText ( message ); | 525 | status.setText ( message ); |
@@ -515,16 +541,22 @@ bool PhoneFormat::save( Calendar *calendar) | |||
515 | Event* ev1; | 541 | Event* ev1; |
516 | int procCount = 0; | 542 | int procCount = 0; |
517 | while ( ev ) { | 543 | while ( ev ) { |
518 | qDebug("event new ID "); | 544 | //qDebug("event new ID %s",ev->summary().latin1()); |
519 | status.setText ( message + QString::number ( ++procCount ) ); | 545 | status.setText ( message + QString::number ( ++procCount ) ); |
520 | qApp->processEvents(); | 546 | qApp->processEvents(); |
521 | QString cSum = ev->getCsum(mProfileName); | 547 | uint csum; |
548 | csum = PhoneFormat::getCsumEvent( ev ); | ||
549 | QString cSum = QString::number( csum ); | ||
550 | ev->setCsum( mProfileName, cSum ); | ||
551 | //qDebug("Event cSum %s ", cSum.latin1()); | ||
522 | ev1 = er1.first(); | 552 | ev1 = er1.first(); |
523 | while ( ev1 ) { | 553 | while ( ev1 ) { |
524 | if ( ev1->getCsum( mProfileName ) == cSum ) { | 554 | if ( ev1->getCsum( mProfileName ) == cSum ) { |
525 | er1.remove( ev1 ); | 555 | er1.remove( ev1 ); |
526 | afterSave( ev ); | 556 | afterSave( ev ); |
527 | ev->setID(mProfileName, ev1->getID(mProfileName) ); | 557 | ev->setID(mProfileName, ev1->getID(mProfileName) ); |
558 | //qDebug("Event found on phone for %s ", ev->summary().latin1()); | ||
559 | |||
528 | break; | 560 | break; |
529 | } | 561 | } |
530 | ev1 = er1.next(); | 562 | ev1 = er1.next(); |
@@ -538,6 +570,7 @@ bool PhoneFormat::save( Calendar *calendar) | |||
538 | ev = er.next(); | 570 | ev = er.next(); |
539 | } | 571 | } |
540 | //algo 6 compare todo | 572 | //algo 6 compare todo |
573 | tl = calendar->rawTodos(); | ||
541 | to = tl.first(); | 574 | to = tl.first(); |
542 | procCount = 0; | 575 | procCount = 0; |
543 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | 576 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); |
@@ -547,7 +580,11 @@ bool PhoneFormat::save( Calendar *calendar) | |||
547 | qDebug("todo2 %d ", procCount); | 580 | qDebug("todo2 %d ", procCount); |
548 | status.setText ( message + QString::number ( ++procCount ) ); | 581 | status.setText ( message + QString::number ( ++procCount ) ); |
549 | qApp->processEvents(); | 582 | qApp->processEvents(); |
550 | QString cSum = to->getCsum(mProfileName); | 583 | uint csum; |
584 | csum = PhoneFormat::getCsumTodo( to ); | ||
585 | QString cSum = QString::number( csum ); | ||
586 | to->setCsum( mProfileName, cSum ); | ||
587 | qDebug("Todo cSum %s ", cSum.latin1()); | ||
551 | Todo* to1 = tl1.first(); | 588 | Todo* to1 = tl1.first(); |
552 | while ( to1 ) { | 589 | while ( to1 ) { |
553 | if ( to1->getCsum( mProfileName ) == cSum ) { | 590 | if ( to1->getCsum( mProfileName ) == cSum ) { |