summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 16c5880..29c1ae6 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -335,97 +335,97 @@ ulong PhoneFormat::getCsumEvent( Event* event )
335 list.append( "0" ); 335 list.append( "0" );
336 list.append( "20991231T000000" ); 336 list.append( "20991231T000000" );
337 } 337 }
338 338
339 } 339 }
340 attList << list.join(""); 340 attList << list.join("");
341 attList << event->categoriesStr(); 341 attList << event->categoriesStr();
342 //qDebug("csum cat %s", event->categoriesStr().latin1()); 342 //qDebug("csum cat %s", event->categoriesStr().latin1());
343 343
344 attList << event->secrecyStr(); 344 attList << event->secrecyStr();
345 return PhoneFormat::getCsum(attList ); 345 return PhoneFormat::getCsum(attList );
346} 346}
347ulong PhoneFormat::getCsum( const QStringList & attList) 347ulong PhoneFormat::getCsum( const QStringList & attList)
348{ 348{
349 int max = attList.count(); 349 int max = attList.count();
350 ulong cSum = 0; 350 ulong cSum = 0;
351 int j,k,i; 351 int j,k,i;
352 int add; 352 int add;
353 for ( i = 0; i < max ; ++i ) { 353 for ( i = 0; i < max ; ++i ) {
354 QString s = attList[i]; 354 QString s = attList[i];
355 if ( ! s.isEmpty() ){ 355 if ( ! s.isEmpty() ){
356 j = s.length(); 356 j = s.length();
357 for ( k = 0; k < j; ++k ) { 357 for ( k = 0; k < j; ++k ) {
358 int mul = k +1; 358 int mul = k +1;
359 add = s[k].unicode (); 359 add = s[k].unicode ();
360 if ( k < 16 ) 360 if ( k < 16 )
361 mul = mul * mul; 361 mul = mul * mul;
362 int ii = i+1; 362 int ii = i+1;
363 add = add * mul *ii*ii*ii; 363 add = add * mul *ii*ii*ii;
364 cSum += add; 364 cSum += add;
365 } 365 }
366 } 366 }
367 367
368 } 368 }
369 //QString dump = attList.join(","); 369 //QString dump = attList.join(",");
370 //qDebug("csum: %d %s", cSum,dump.latin1()); 370 //qDebug("csum: %d %s", cSum,dump.latin1());
371 371
372 return cSum; 372 return cSum;
373 373
374} 374}
375//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 375//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
376#include <stdlib.h> 376#include <stdlib.h>
377#define DEBUGMODE false 377#define DEBUGMODE false
378bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 378bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
379{ 379{
380 380
381 QString fileName; 381 QString fileName;
382#ifdef _WIN32_ 382#ifdef _WIN32_
383 fileName = locateLocal("tmp", "tempfile.vcs") 383 fileName = locateLocal("tmp", "tempfile.vcs");
384#else 384#else
385 fileName = "/tmp/kdepimtemp.vcs"; 385 fileName = "/tmp/kdepimtemp.vcs";
386#endif 386#endif
387#ifdef DESKTOP_VERSION 387#ifdef DESKTOP_VERSION
388 QString command ="./kammu --backup " + fileName + " -yes" ; 388 QString command ="./kammu --backup " + fileName + " -yes" ;
389#else 389#else
390 QString command ="kammu --backup " + fileName + " -yes" ; 390 QString command ="kammu --backup " + fileName + " -yes" ;
391#endif 391#endif
392 int ret = system ( command.latin1() ); 392 int ret = system ( command.latin1() );
393 if ( ret != 0 ) { 393 if ( ret != 0 ) {
394 qDebug("Error::command returned %d", ret); 394 qDebug("Error::command returned %d", ret);
395 return false; 395 return false;
396 } 396 }
397 VCalFormat vfload; 397 VCalFormat vfload;
398 vfload.setLocalTime ( true ); 398 vfload.setLocalTime ( true );
399 qDebug("loading file ..."); 399 qDebug("loading file ...");
400 400
401 if ( ! vfload.load( calendar, fileName ) ) 401 if ( ! vfload.load( calendar, fileName ) )
402 return false; 402 return false;
403 QPtrList<Event> er = calendar->rawEvents(); 403 QPtrList<Event> er = calendar->rawEvents();
404 Event* ev = er.first(); 404 Event* ev = er.first();
405 qDebug("reading events... "); 405 qDebug("reading events... ");
406 while ( ev ) { 406 while ( ev ) {
407 QStringList cat = ev->categories(); 407 QStringList cat = ev->categories();
408 if ( cat.contains( "MeetingDEF" )) { 408 if ( cat.contains( "MeetingDEF" )) {
409 ev->setCategories( QStringList() ); 409 ev->setCategories( QStringList() );
410 } 410 }
411 int id = ev->pilotId(); 411 int id = ev->pilotId();
412 Event *event; 412 Event *event;
413 event = existingCal->event( mProfileName ,QString::number( id ) ); 413 event = existingCal->event( mProfileName ,QString::number( id ) );
414 if ( event ) { 414 if ( event ) {
415 event = (Event*)event->clone(); 415 event = (Event*)event->clone();
416 copyEvent( event, ev ); 416 copyEvent( event, ev );
417 calendar->deleteEvent( ev ); 417 calendar->deleteEvent( ev );
418 calendar->addEvent( event); 418 calendar->addEvent( event);
419 } 419 }
420 else 420 else
421 event = ev; 421 event = ev;
422 uint cSum; 422 uint cSum;
423 cSum = PhoneFormat::getCsumEvent( event ); 423 cSum = PhoneFormat::getCsumEvent( event );
424 event->setCsum( mProfileName, QString::number( cSum )); 424 event->setCsum( mProfileName, QString::number( cSum ));
425 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 425 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
426 event->setID( mProfileName,QString::number( id ) ); 426 event->setID( mProfileName,QString::number( id ) );
427 ev = er.next(); 427 ev = er.next();
428 } 428 }
429 { 429 {
430 qDebug("reading todos... "); 430 qDebug("reading todos... ");
431 QPtrList<Todo> tr = calendar->rawTodos(); 431 QPtrList<Todo> tr = calendar->rawTodos();
@@ -539,97 +539,97 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
539 to->setCategories( cat ); 539 to->setCategories( cat );
540 if ( from->isCompleted() ) { 540 if ( from->isCompleted() ) {
541 to->setCompleted( true ); 541 to->setCompleted( true );
542 if( from->completed().isValid() ) 542 if( from->completed().isValid() )
543 to->setCompleted( from->completed() ); 543 to->setCompleted( from->completed() );
544 } else { 544 } else {
545 // set percentcomplete only, if to->isCompleted() 545 // set percentcomplete only, if to->isCompleted()
546 if ( to->isCompleted() ) 546 if ( to->isCompleted() )
547 to->setPercentComplete(from->percentComplete()); 547 to->setPercentComplete(from->percentComplete());
548 } 548 }
549 if( to->priority() == 2 && from->priority() == 1 ) 549 if( to->priority() == 2 && from->priority() == 1 )
550 ; //skip 550 ; //skip
551 else if (to->priority() == 4 && from->priority() == 5 ) 551 else if (to->priority() == 4 && from->priority() == 5 )
552 ; 552 ;
553 else 553 else
554 to->setPriority(from->priority()); 554 to->setPriority(from->priority());
555 555
556} 556}
557#include <qcstring.h> 557#include <qcstring.h>
558 558
559void PhoneFormat::afterSave( Incidence* inc) 559void PhoneFormat::afterSave( Incidence* inc)
560{ 560{
561 uint csum; 561 uint csum;
562 inc->removeID( mProfileName ); 562 inc->removeID( mProfileName );
563 if ( inc->type() == "Event") 563 if ( inc->type() == "Event")
564 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 564 csum = PhoneFormat::getCsumEvent( (Event*) inc );
565 else 565 else
566 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 566 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
567 inc->setCsum( mProfileName, QString::number( csum )); 567 inc->setCsum( mProfileName, QString::number( csum ));
568 568
569 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 569 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
570 570
571} 571}
572bool PhoneFormat::save( Calendar *calendar) 572bool PhoneFormat::save( Calendar *calendar)
573{ 573{
574 QLabel status ( i18n(" Opening device ..."), 0 ); 574 QLabel status ( i18n(" Opening device ..."), 0 );
575 int w = status.sizeHint().width()+20 ; 575 int w = status.sizeHint().width()+20 ;
576 if ( w < 200 ) w = 230; 576 if ( w < 200 ) w = 230;
577 int h = status.sizeHint().height()+20 ; 577 int h = status.sizeHint().height()+20 ;
578 int dw = QApplication::desktop()->width(); 578 int dw = QApplication::desktop()->width();
579 int dh = QApplication::desktop()->height(); 579 int dh = QApplication::desktop()->height();
580 status.setCaption(i18n("Writing to phone...") ); 580 status.setCaption(i18n("Writing to phone...") );
581 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 581 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
582 status.show(); 582 status.show();
583 status.raise(); 583 status.raise();
584 qApp->processEvents(); 584 qApp->processEvents();
585 QString message; 585 QString message;
586#ifdef _WIN32_ 586#ifdef _WIN32_
587 QString fileName = locateLocal("tmp", "tempfile.vcs") 587 QString fileName = locateLocal("tmp", "tempfile.vcs");
588#else 588#else
589 QString fileName = "/tmp/kdepimtemp.vcs"; 589 QString fileName = "/tmp/kdepimtemp.vcs";
590#endif 590#endif
591 591
592 // 1 remove events which should be deleted 592 // 1 remove events which should be deleted
593 QPtrList<Event> er = calendar->rawEvents(); 593 QPtrList<Event> er = calendar->rawEvents();
594 Event* ev = er.first(); 594 Event* ev = er.first();
595 while ( ev ) { 595 while ( ev ) {
596 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 596 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
597 calendar->deleteEvent( ev ); 597 calendar->deleteEvent( ev );
598 } else { 598 } else {
599 599
600 } 600 }
601 ev = er.next(); 601 ev = er.next();
602 } 602 }
603 // 2 remove todos which should be deleted 603 // 2 remove todos which should be deleted
604 QPtrList<Todo> tl = calendar->rawTodos(); 604 QPtrList<Todo> tl = calendar->rawTodos();
605 Todo* to = tl.first(); 605 Todo* to = tl.first();
606 while ( to ) { 606 while ( to ) {
607 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 607 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
608 calendar->deleteTodo( to ); 608 calendar->deleteTodo( to );
609 } else { 609 } else {
610 if ( to->isCompleted()) { 610 if ( to->isCompleted()) {
611 calendar->deleteTodo( to ); 611 calendar->deleteTodo( to );
612 } 612 }
613 } 613 }
614 to = tl.next(); 614 to = tl.next();
615 } 615 }
616 // 3 save file 616 // 3 save file
617 VCalFormat vfsave; 617 VCalFormat vfsave;
618 vfsave.setLocalTime ( true ); 618 vfsave.setLocalTime ( true );
619 if ( ! vfsave.save( calendar, fileName ) ) 619 if ( ! vfsave.save( calendar, fileName ) )
620 return false; 620 return false;
621 // 4 call kammu 621 // 4 call kammu
622#ifdef DESKTOP_VERSION 622#ifdef DESKTOP_VERSION
623 QString command ="./kammu --restore " + fileName ; 623 QString command ="./kammu --restore " + fileName ;
624#else 624#else
625 QString command ="kammu --restore " + fileName ; 625 QString command ="kammu --restore " + fileName ;
626#endif 626#endif
627 int ret; 627 int ret;
628 while ( (ret = system ( command.latin1())) != 0 ) { 628 while ( (ret = system ( command.latin1())) != 0 ) {
629 qDebug("Error S::command returned %d. asking users", ret); 629 qDebug("Error S::command returned %d. asking users", ret);
630 int retval = KMessageBox::warningContinueCancel(0, 630 int retval = KMessageBox::warningContinueCancel(0,
631 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); 631 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel"));
632 if ( retval != KMessageBox::Continue ) 632 if ( retval != KMessageBox::Continue )
633 return false; 633 return false;
634 } 634 }
635 635