summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2004-09-19 20:14:28 (UTC)
committer zautrix <zautrix>2004-09-19 20:14:28 (UTC)
commitafa28a62314117555d6b32291188eedd1a576284 (patch) (unidiff)
treeea97a247de30a7a34480bc395e1996ab99247361 /libkcal
parente0d8e062c9d8092e47dcadd88b30614ebff43c0c (diff)
downloadkdepimpi-afa28a62314117555d6b32291188eedd1a576284.zip
kdepimpi-afa28a62314117555d6b32291188eedd1a576284.tar.gz
kdepimpi-afa28a62314117555d6b32291188eedd1a576284.tar.bz2
more AB sync
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/sharpformat.cpp6
-rw-r--r--libkcal/syncdefines.h2
2 files changed, 5 insertions, 3 deletions
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index e7fc670..d56eab6 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -485,131 +485,131 @@ int SharpFormat::getNumFromRecord( QString answer, Incidence* inc )
485 qDebug("Error writing back %s ", inc->summary().latin1()); 485 qDebug("Error writing back %s ", inc->summary().latin1());
486 } 486 }
487 } 487 }
488 } 488 }
489 //qDebug("getNumFromRecord returning : %d ", retval); 489 //qDebug("getNumFromRecord returning : %d ", retval);
490 return retval; 490 return retval;
491} 491}
492bool SharpFormat::save( Calendar *calendar) 492bool SharpFormat::save( Calendar *calendar)
493{ 493{
494 494
495 QLabel status ( i18n("Processing/adding events ..."), 0 ); 495 QLabel status ( i18n("Processing/adding events ..."), 0 );
496 int w = status.sizeHint().width()+20 ; 496 int w = status.sizeHint().width()+20 ;
497 if ( w < 200 ) w = 200; 497 if ( w < 200 ) w = 200;
498 int h = status.sizeHint().height()+20 ; 498 int h = status.sizeHint().height()+20 ;
499 int dw = QApplication::desktop()->width(); 499 int dw = QApplication::desktop()->width();
500 int dh = QApplication::desktop()->height(); 500 int dh = QApplication::desktop()->height();
501 status.setCaption(i18n("Writing DTM Data") ); 501 status.setCaption(i18n("Writing DTM Data") );
502 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 502 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
503 status.show(); 503 status.show();
504 status.raise(); 504 status.raise();
505 qApp->processEvents(); 505 qApp->processEvents();
506 bool debug = DEBUGMODE; 506 bool debug = DEBUGMODE;
507 QString codec = "utf8"; 507 QString codec = "utf8";
508 QString answer; 508 QString answer;
509 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; 509 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n";
510 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; 510 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n";
511 QString command; 511 QString command;
512 QPtrList<Event> er = calendar->rawEvents(); 512 QPtrList<Event> er = calendar->rawEvents();
513 Event* ev = er.first(); 513 Event* ev = er.first();
514 QString fileName = "/tmp/kopitempout"; 514 QString fileName = "/tmp/kopitempout";
515 int i = 0; 515 int i = 0;
516 QString changeString = ePrefix; 516 QString changeString = ePrefix;
517 QString deleteString = ePrefix; 517 QString deleteString = ePrefix;
518 bool deleteEnt = false; 518 bool deleteEnt = false;
519 bool changeEnt = false; 519 bool changeEnt = false;
520 QString message = i18n("Processing event # "); 520 QString message = i18n("Processing event # ");
521 int procCount = 0; 521 int procCount = 0;
522 while ( ev ) { 522 while ( ev ) {
523 //qDebug("i %d ", ++i); 523 //qDebug("i %d ", ++i);
524 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 524 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
525 status.setText ( message + QString::number ( ++procCount ) ); 525 status.setText ( message + QString::number ( ++procCount ) );
526 qApp->processEvents(); 526 qApp->processEvents();
527 QString eString = getEventString( ev ); 527 QString eString = getEventString( ev );
528 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 528 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
529 // deleting empty strings does not work. 529 // deleting empty strings does not work.
530 // we write first and x and then delete the record with the x 530 // we write first and x and then delete the record with the x
531 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 531 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
532 changeString += eString + "\n"; 532 changeString += eString + "\n";
533 deleteString += eString + "\n"; 533 deleteString += eString + "\n";
534 deleteEnt = true; 534 deleteEnt = true;
535 changeEnt = true; 535 changeEnt = true;
536 } 536 }
537 else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new 537 else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new
538 QString fileNameIn = "/tmp/kopitempin"; 538 QString fileNameIn = "/tmp/kopitempin";
539 QFile fileIn( fileNameIn ); 539 QFile fileIn( fileNameIn );
540 if (!fileIn.open( IO_WriteOnly ) ) { 540 if (!fileIn.open( IO_WriteOnly ) ) {
541 return false; 541 return false;
542 } 542 }
543 QTextStream tsIn( &fileIn ); 543 QTextStream tsIn( &fileIn );
544 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 544 tsIn.setCodec( QTextCodec::codecForName("utf8") );
545 tsIn << ePrefix << eString ; 545 tsIn << ePrefix << eString ;
546 fileIn.close(); 546 fileIn.close();
547 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 547 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
548 command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName; 548 command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName;
549 qDebug("command ++++++++ "); 549 //qDebug("command ++++++++ ");
550 qDebug("%s ",command.latin1()); 550 //qDebug("%s ",command.latin1());
551 qDebug("command -------- "); 551 //qDebug("command -------- ");
552 system ( command.utf8() ); 552 system ( command.utf8() );
553 QFile file( fileName ); 553 QFile file( fileName );
554 if (!file.open( IO_ReadOnly ) ) { 554 if (!file.open( IO_ReadOnly ) ) {
555 return false; 555 return false;
556 556
557 } 557 }
558 QTextStream ts( &file ); 558 QTextStream ts( &file );
559 ts.setCodec( QTextCodec::codecForName("utf8") ); 559 ts.setCodec( QTextCodec::codecForName("utf8") );
560 answer = ts.read(); 560 answer = ts.read();
561 file.close(); 561 file.close();
562 //qDebug("answer \n%s ", answer.latin1()); 562 //qDebug("answer \n%s ", answer.latin1());
563 getNumFromRecord( answer, ev ) ; 563 getNumFromRecord( answer, ev ) ;
564 564
565 } 565 }
566 else { // change existing 566 else { // change existing
567 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); 567 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() );
568 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 568 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
569 changeString += eString + "\n"; 569 changeString += eString + "\n";
570 changeEnt = true; 570 changeEnt = true;
571 571
572 } 572 }
573 } 573 }
574 ev = er.next(); 574 ev = er.next();
575 } 575 }
576 status.setText ( i18n("Changing events ...") ); 576 status.setText ( i18n("Changing events ...") );
577 qApp->processEvents(); 577 qApp->processEvents();
578 //qDebug("changing... "); 578 //qDebug("changing... ");
579 if ( changeEnt ) { 579 if ( changeEnt ) {
580 QFile file( fileName ); 580 QFile file( fileName );
581 if (!file.open( IO_WriteOnly ) ) { 581 if (!file.open( IO_WriteOnly ) ) {
582 return false; 582 return false;
583 583
584 } 584 }
585 QTextStream ts( &file ); 585 QTextStream ts( &file );
586 ts.setCodec( QTextCodec::codecForName("utf8") ); 586 ts.setCodec( QTextCodec::codecForName("utf8") );
587 ts << changeString ; 587 ts << changeString ;
588 file.close(); 588 file.close();
589 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; 589 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName;
590 system ( command.latin1() ); 590 system ( command.latin1() );
591 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 591 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
592 592
593 } 593 }
594 status.setText ( i18n("Deleting events ...") ); 594 status.setText ( i18n("Deleting events ...") );
595 qApp->processEvents(); 595 qApp->processEvents();
596 //qDebug("deleting... "); 596 //qDebug("deleting... ");
597 if ( deleteEnt ) { 597 if ( deleteEnt ) {
598 QFile file( fileName ); 598 QFile file( fileName );
599 if (!file.open( IO_WriteOnly ) ) { 599 if (!file.open( IO_WriteOnly ) ) {
600 return false; 600 return false;
601 601
602 } 602 }
603 QTextStream ts( &file ); 603 QTextStream ts( &file );
604 ts.setCodec( QTextCodec::codecForName("utf8") ); 604 ts.setCodec( QTextCodec::codecForName("utf8") );
605 ts << deleteString; 605 ts << deleteString;
606 file.close(); 606 file.close();
607 command = "db2file datebook -d -c " + codec+ " < "+ fileName; 607 command = "db2file datebook -d -c " + codec+ " < "+ fileName;
608 system ( command.latin1() ); 608 system ( command.latin1() );
609 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 609 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
610 } 610 }
611 611
612 612
613 changeString = tPrefix; 613 changeString = tPrefix;
614 deleteString = tPrefix; 614 deleteString = tPrefix;
615 status.setText ( i18n("Processing todos ...") ); 615 status.setText ( i18n("Processing todos ...") );
diff --git a/libkcal/syncdefines.h b/libkcal/syncdefines.h
index 57642ec..704a670 100644
--- a/libkcal/syncdefines.h
+++ b/libkcal/syncdefines.h
@@ -1,22 +1,24 @@
1 1
2#ifndef _KSYNC_DEFINES_H_ 2#ifndef _KSYNC_DEFINES_H_
3#define _KSYNC_DEFINES_H_ 3#define _KSYNC_DEFINES_H_
4 4
5#define SYNC_PREF_LOCAL 0 5#define SYNC_PREF_LOCAL 0
6#define SYNC_PREF_REMOTE 1 6#define SYNC_PREF_REMOTE 1
7#define SYNC_PREF_NEWEST 2 7#define SYNC_PREF_NEWEST 2
8#define SYNC_PREF_ASK 3 8#define SYNC_PREF_ASK 3
9#define SYNC_PREF_FORCE_LOCAL 4 9#define SYNC_PREF_FORCE_LOCAL 4
10#define SYNC_PREF_FORCE_REMOTE 5 10#define SYNC_PREF_FORCE_REMOTE 5
11#define SYNC_PREF_TAKE_BOTH 6 11#define SYNC_PREF_TAKE_BOTH 6
12 12
13#define SYNC_MODE_NORMAL 0 13#define SYNC_MODE_NORMAL 0
14#define SYNC_MODE_EXTERNAL 1 14#define SYNC_MODE_EXTERNAL 1
15 15
16#define SYNC_TEMPSTATE_INITIAL 0 16#define SYNC_TEMPSTATE_INITIAL 0
17#define SYNC_TEMPSTATE_ADDED_EXTERNAL -1
17#define SYNC_TEMPSTATE_NEW_EXTERNAL -2 18#define SYNC_TEMPSTATE_NEW_EXTERNAL -2
18#define SYNC_TEMPSTATE_DELETE -3 19#define SYNC_TEMPSTATE_DELETE -3
19#define SYNC_TEMPSTATE_NEW_ID -4 20#define SYNC_TEMPSTATE_NEW_ID -4
21#define SYNC_TEMPSTATE_NEW_CSUM -5
20 22
21 23
22#endif 24#endif