author | zautrix <zautrix> | 2004-10-26 22:19:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-26 22:19:18 (UTC) |
commit | 6385f303bef3cbcd19d097a7b05c30e144d5dd6e (patch) (unidiff) | |
tree | 770795d94ea6ec1dc8bcaa67cc174a9c0add564a | |
parent | 13e996beddabc5e88f4f2fe49b2ce6cb8408eb30 (diff) | |
download | kdepimpi-6385f303bef3cbcd19d097a7b05c30e144d5dd6e.zip kdepimpi-6385f303bef3cbcd19d097a7b05c30e144d5dd6e.tar.gz kdepimpi-6385f303bef3cbcd19d097a7b05c30e144d5dd6e.tar.bz2 |
implemented remove sync info for kopi and kapi
-rw-r--r-- | kabc/addressbook.cpp | 8 | ||||
-rw-r--r-- | kabc/addressbook.h | 1 | ||||
-rw-r--r-- | kabc/addressee.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 4 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 1 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 23 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 5 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 42 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 1 |
11 files changed, 85 insertions, 7 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 3641c0c..2785131 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -460,192 +460,200 @@ bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | |||
460 | datastream += vcard; | 460 | datastream += vcard; |
461 | 461 | ||
462 | } | 462 | } |
463 | 463 | ||
464 | QFile outFile(fileName); | 464 | QFile outFile(fileName); |
465 | if ( outFile.open(IO_WriteOnly) ) { | 465 | if ( outFile.open(IO_WriteOnly) ) { |
466 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 466 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
467 | QTextStream t( &outFile ); // use a text stream | 467 | QTextStream t( &outFile ); // use a text stream |
468 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 468 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
469 | t <<datastream; | 469 | t <<datastream; |
470 | t << "\r\n\r\n"; | 470 | t << "\r\n\r\n"; |
471 | outFile.close(); | 471 | outFile.close(); |
472 | 472 | ||
473 | } else { | 473 | } else { |
474 | qDebug("Error open temp file "); | 474 | qDebug("Error open temp file "); |
475 | return false; | 475 | return false; |
476 | } | 476 | } |
477 | return true; | 477 | return true; |
478 | 478 | ||
479 | } | 479 | } |
480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) | 480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) |
481 | { | 481 | { |
482 | 482 | ||
483 | if ( removeOld ) | 483 | if ( removeOld ) |
484 | setUntagged( true ); | 484 | setUntagged( true ); |
485 | KABC::Addressee::List list; | 485 | KABC::Addressee::List list; |
486 | QFile file( fileName ); | 486 | QFile file( fileName ); |
487 | file.open( IO_ReadOnly ); | 487 | file.open( IO_ReadOnly ); |
488 | QByteArray rawData = file.readAll(); | 488 | QByteArray rawData = file.readAll(); |
489 | file.close(); | 489 | file.close(); |
490 | QString data; | 490 | QString data; |
491 | if ( replaceLabel ) { | 491 | if ( replaceLabel ) { |
492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
493 | data.replace ( QRegExp("LABEL") , "ADR" ); | 493 | data.replace ( QRegExp("LABEL") , "ADR" ); |
494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
495 | } else | 495 | } else |
496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
497 | KABC::VCardTool tool; | 497 | KABC::VCardTool tool; |
498 | list = tool.parseVCards( data ); | 498 | list = tool.parseVCards( data ); |
499 | KABC::Addressee::List::Iterator it; | 499 | KABC::Addressee::List::Iterator it; |
500 | for ( it = list.begin(); it != list.end(); ++it ) { | 500 | for ( it = list.begin(); it != list.end(); ++it ) { |
501 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 501 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
502 | if ( !id.isEmpty() ) | 502 | if ( !id.isEmpty() ) |
503 | (*it).setIDStr(id ); | 503 | (*it).setIDStr(id ); |
504 | (*it).setResource( 0 ); | 504 | (*it).setResource( 0 ); |
505 | if ( replaceLabel ) | 505 | if ( replaceLabel ) |
506 | (*it).removeVoice(); | 506 | (*it).removeVoice(); |
507 | if ( removeOld ) | 507 | if ( removeOld ) |
508 | (*it).setTagged( true ); | 508 | (*it).setTagged( true ); |
509 | insertAddressee( (*it), false, true ); | 509 | insertAddressee( (*it), false, true ); |
510 | } | 510 | } |
511 | if ( removeOld ) | 511 | if ( removeOld ) |
512 | removeUntagged(); | 512 | removeUntagged(); |
513 | return list.count(); | 513 | return list.count(); |
514 | } | 514 | } |
515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) | 515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) |
516 | { | 516 | { |
517 | Iterator ait; | 517 | Iterator ait; |
518 | for ( ait = begin(); ait != end(); ++ait ) { | 518 | for ( ait = begin(); ait != end(); ++ait ) { |
519 | if ( setNonSyncTagged ) { | 519 | if ( setNonSyncTagged ) { |
520 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { | 520 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { |
521 | (*ait).setTagged( true ); | 521 | (*ait).setTagged( true ); |
522 | } else | 522 | } else |
523 | (*ait).setTagged( false ); | 523 | (*ait).setTagged( false ); |
524 | } else | 524 | } else |
525 | (*ait).setTagged( false ); | 525 | (*ait).setTagged( false ); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | void AddressBook::removeUntagged() | 528 | void AddressBook::removeUntagged() |
529 | { | 529 | { |
530 | Iterator ait; | 530 | Iterator ait; |
531 | bool todelete = false; | 531 | bool todelete = false; |
532 | Iterator todel; | 532 | Iterator todel; |
533 | for ( ait = begin(); ait != end(); ++ait ) { | 533 | for ( ait = begin(); ait != end(); ++ait ) { |
534 | if ( todelete ) | 534 | if ( todelete ) |
535 | removeAddressee( todel ); | 535 | removeAddressee( todel ); |
536 | if (!(*ait).tagged()) { | 536 | if (!(*ait).tagged()) { |
537 | todelete = true; | 537 | todelete = true; |
538 | todel = ait; | 538 | todel = ait; |
539 | } else | 539 | } else |
540 | todelete = false; | 540 | todelete = false; |
541 | } | 541 | } |
542 | if ( todelete ) | 542 | if ( todelete ) |
543 | removeAddressee( todel ); | 543 | removeAddressee( todel ); |
544 | deleteRemovedAddressees(); | 544 | deleteRemovedAddressees(); |
545 | } | 545 | } |
546 | void AddressBook::smplifyAddressees() | 546 | void AddressBook::smplifyAddressees() |
547 | { | 547 | { |
548 | Iterator ait; | 548 | Iterator ait; |
549 | for ( ait = begin(); ait != end(); ++ait ) { | 549 | for ( ait = begin(); ait != end(); ++ait ) { |
550 | (*ait).simplifyEmails(); | 550 | (*ait).simplifyEmails(); |
551 | (*ait).simplifyPhoneNumbers(); | 551 | (*ait).simplifyPhoneNumbers(); |
552 | (*ait).simplifyPhoneNumberTypes(); | 552 | (*ait).simplifyPhoneNumberTypes(); |
553 | (*ait).simplifyAddresses(); | 553 | (*ait).simplifyAddresses(); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | void AddressBook::removeSyncInfo( QString syncProfile) | ||
557 | { | ||
558 | Iterator ait; | ||
559 | for ( ait = begin(); ait != end(); ++ait ) { | ||
560 | (*ait).removeID( syncProfile ); | ||
561 | } | ||
562 | |||
563 | } | ||
556 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) | 564 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) |
557 | { | 565 | { |
558 | Iterator ait; | 566 | Iterator ait; |
559 | for ( ait = begin(); ait != end(); ++ait ) { | 567 | for ( ait = begin(); ait != end(); ++ait ) { |
560 | QString id = (*ait).IDStr(); | 568 | QString id = (*ait).IDStr(); |
561 | (*ait).setIDStr( ":"); | 569 | (*ait).setIDStr( ":"); |
562 | (*ait).setExternalUID( id ); | 570 | (*ait).setExternalUID( id ); |
563 | (*ait).setOriginalExternalUID( id ); | 571 | (*ait).setOriginalExternalUID( id ); |
564 | if ( isPreSync ) | 572 | if ( isPreSync ) |
565 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 573 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
566 | else { | 574 | else { |
567 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 575 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
568 | (*ait).setID( currentSyncDevice,id ); | 576 | (*ait).setID( currentSyncDevice,id ); |
569 | 577 | ||
570 | } | 578 | } |
571 | } | 579 | } |
572 | } | 580 | } |
573 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) | 581 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) |
574 | { | 582 | { |
575 | 583 | ||
576 | setUntagged(); | 584 | setUntagged(); |
577 | KABC::Addressee::List list; | 585 | KABC::Addressee::List list; |
578 | QFile file( fileName ); | 586 | QFile file( fileName ); |
579 | file.open( IO_ReadOnly ); | 587 | file.open( IO_ReadOnly ); |
580 | QByteArray rawData = file.readAll(); | 588 | QByteArray rawData = file.readAll(); |
581 | file.close(); | 589 | file.close(); |
582 | QString data; | 590 | QString data; |
583 | 591 | ||
584 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 592 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
585 | KABC::VCardTool tool; | 593 | KABC::VCardTool tool; |
586 | list = tool.parseVCards( data ); | 594 | list = tool.parseVCards( data ); |
587 | KABC::Addressee::List::Iterator it; | 595 | KABC::Addressee::List::Iterator it; |
588 | for ( it = list.begin(); it != list.end(); ++it ) { | 596 | for ( it = list.begin(); it != list.end(); ++it ) { |
589 | Iterator ait; | 597 | Iterator ait; |
590 | for ( ait = begin(); ait != end(); ++ait ) { | 598 | for ( ait = begin(); ait != end(); ++ait ) { |
591 | if ( !(*ait).tagged() ) { | 599 | if ( !(*ait).tagged() ) { |
592 | if ( (*ait).containsAdr(*it)) { | 600 | if ( (*ait).containsAdr(*it)) { |
593 | (*ait).setTagged(true); | 601 | (*ait).setTagged(true); |
594 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 602 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
595 | (*it).setIDStr( ":"); | 603 | (*it).setIDStr( ":"); |
596 | (*it).setID( currentSyncDevice,id ); | 604 | (*it).setID( currentSyncDevice,id ); |
597 | (*it).setExternalUID( id ); | 605 | (*it).setExternalUID( id ); |
598 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 606 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
599 | (*it).setUid( ( (*ait).uid() )); | 607 | (*it).setUid( ( (*ait).uid() )); |
600 | break; | 608 | break; |
601 | } | 609 | } |
602 | } | 610 | } |
603 | 611 | ||
604 | } | 612 | } |
605 | if ( ait == end() ) | 613 | if ( ait == end() ) |
606 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); | 614 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); |
607 | } | 615 | } |
608 | clear(); | 616 | clear(); |
609 | for ( it = list.begin(); it != list.end(); ++it ) { | 617 | for ( it = list.begin(); it != list.end(); ++it ) { |
610 | insertAddressee( (*it) ); | 618 | insertAddressee( (*it) ); |
611 | } | 619 | } |
612 | } | 620 | } |
613 | 621 | ||
614 | bool AddressBook::saveABphone( QString fileName ) | 622 | bool AddressBook::saveABphone( QString fileName ) |
615 | { | 623 | { |
616 | //smplifyAddressees(); | 624 | //smplifyAddressees(); |
617 | qDebug("saveABphone:: saving AB... "); | 625 | qDebug("saveABphone:: saving AB... "); |
618 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) | 626 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) |
619 | return false; | 627 | return false; |
620 | qDebug("saveABphone:: writing to phone... "); | 628 | qDebug("saveABphone:: writing to phone... "); |
621 | if ( !PhoneAccess::writeToPhone( fileName) ) { | 629 | if ( !PhoneAccess::writeToPhone( fileName) ) { |
622 | return false; | 630 | return false; |
623 | } | 631 | } |
624 | qDebug("saveABphone:: re-reading from phone... "); | 632 | qDebug("saveABphone:: re-reading from phone... "); |
625 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 633 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
626 | return false; | 634 | return false; |
627 | } | 635 | } |
628 | return true; | 636 | return true; |
629 | } | 637 | } |
630 | bool AddressBook::saveAB() | 638 | bool AddressBook::saveAB() |
631 | { | 639 | { |
632 | bool ok = true; | 640 | bool ok = true; |
633 | 641 | ||
634 | deleteRemovedAddressees(); | 642 | deleteRemovedAddressees(); |
635 | Iterator ait; | 643 | Iterator ait; |
636 | for ( ait = begin(); ait != end(); ++ait ) { | 644 | for ( ait = begin(); ait != end(); ++ait ) { |
637 | if ( !(*ait).IDStr().isEmpty() ) { | 645 | if ( !(*ait).IDStr().isEmpty() ) { |
638 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 646 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
639 | } | 647 | } |
640 | } | 648 | } |
641 | KRES::Manager<Resource>::ActiveIterator it; | 649 | KRES::Manager<Resource>::ActiveIterator it; |
642 | KRES::Manager<Resource> *manager = d->mManager; | 650 | KRES::Manager<Resource> *manager = d->mManager; |
643 | qDebug("SaveAB::saving..." ); | 651 | qDebug("SaveAB::saving..." ); |
644 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 652 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
645 | qDebug("SaveAB::checking resource..." ); | 653 | qDebug("SaveAB::checking resource..." ); |
646 | if ( (*it)->readOnly() ) | 654 | if ( (*it)->readOnly() ) |
647 | qDebug("resource is readonly." ); | 655 | qDebug("resource is readonly." ); |
648 | if ( (*it)->isOpen() ) | 656 | if ( (*it)->isOpen() ) |
649 | qDebug("resource is open" ); | 657 | qDebug("resource is open" ); |
650 | 658 | ||
651 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 659 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 5edca06..f124dc9 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -51,192 +51,193 @@ class AddressBook : public QObject | |||
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); | 54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); |
55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); | 55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); |
56 | friend class StdAddressBook; | 56 | friend class StdAddressBook; |
57 | 57 | ||
58 | public: | 58 | public: |
59 | /** | 59 | /** |
60 | @short Address Book Iterator | 60 | @short Address Book Iterator |
61 | 61 | ||
62 | This class provides an iterator for address book entries. | 62 | This class provides an iterator for address book entries. |
63 | */ | 63 | */ |
64 | class Iterator | 64 | class Iterator |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | Iterator(); | 67 | Iterator(); |
68 | Iterator( const Iterator & ); | 68 | Iterator( const Iterator & ); |
69 | ~Iterator(); | 69 | ~Iterator(); |
70 | 70 | ||
71 | Iterator &operator=( const Iterator & ); | 71 | Iterator &operator=( const Iterator & ); |
72 | const Addressee &operator*() const; | 72 | const Addressee &operator*() const; |
73 | Addressee &operator*(); | 73 | Addressee &operator*(); |
74 | Addressee* operator->(); | 74 | Addressee* operator->(); |
75 | Iterator &operator++(); | 75 | Iterator &operator++(); |
76 | Iterator &operator++(int); | 76 | Iterator &operator++(int); |
77 | Iterator &operator--(); | 77 | Iterator &operator--(); |
78 | Iterator &operator--(int); | 78 | Iterator &operator--(int); |
79 | bool operator==( const Iterator &it ); | 79 | bool operator==( const Iterator &it ); |
80 | bool operator!=( const Iterator &it ); | 80 | bool operator!=( const Iterator &it ); |
81 | 81 | ||
82 | struct IteratorData; | 82 | struct IteratorData; |
83 | IteratorData *d; | 83 | IteratorData *d; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | @short Address Book Const Iterator | 87 | @short Address Book Const Iterator |
88 | 88 | ||
89 | This class provides a const iterator for address book entries. | 89 | This class provides a const iterator for address book entries. |
90 | */ | 90 | */ |
91 | class ConstIterator | 91 | class ConstIterator |
92 | { | 92 | { |
93 | public: | 93 | public: |
94 | ConstIterator(); | 94 | ConstIterator(); |
95 | ConstIterator( const ConstIterator & ); | 95 | ConstIterator( const ConstIterator & ); |
96 | ~ConstIterator(); | 96 | ~ConstIterator(); |
97 | 97 | ||
98 | ConstIterator &operator=( const ConstIterator & ); | 98 | ConstIterator &operator=( const ConstIterator & ); |
99 | const Addressee &operator*() const; | 99 | const Addressee &operator*() const; |
100 | const Addressee* operator->() const; | 100 | const Addressee* operator->() const; |
101 | ConstIterator &operator++(); | 101 | ConstIterator &operator++(); |
102 | ConstIterator &operator++(int); | 102 | ConstIterator &operator++(int); |
103 | ConstIterator &operator--(); | 103 | ConstIterator &operator--(); |
104 | ConstIterator &operator--(int); | 104 | ConstIterator &operator--(int); |
105 | bool operator==( const ConstIterator &it ); | 105 | bool operator==( const ConstIterator &it ); |
106 | bool operator!=( const ConstIterator &it ); | 106 | bool operator!=( const ConstIterator &it ); |
107 | 107 | ||
108 | struct ConstIteratorData; | 108 | struct ConstIteratorData; |
109 | ConstIteratorData *d; | 109 | ConstIteratorData *d; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | Constructs a address book object. | 113 | Constructs a address book object. |
114 | 114 | ||
115 | @param format File format class. | 115 | @param format File format class. |
116 | */ | 116 | */ |
117 | AddressBook(); | 117 | AddressBook(); |
118 | AddressBook( const QString &config ); | 118 | AddressBook( const QString &config ); |
119 | AddressBook( const QString &config, const QString &family ); | 119 | AddressBook( const QString &config, const QString &family ); |
120 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
121 | 121 | ||
122 | /** | 122 | /** |
123 | Requests a ticket for saving the addressbook. Calling this function locks | 123 | Requests a ticket for saving the addressbook. Calling this function locks |
124 | the addressbook for all other processes. If the address book is already | 124 | the addressbook for all other processes. If the address book is already |
125 | locked the function returns 0. You need the returned @ref Ticket object | 125 | locked the function returns 0. You need the returned @ref Ticket object |
126 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
127 | 127 | ||
128 | @see save() | 128 | @see save() |
129 | */ | 129 | */ |
130 | Ticket *requestSaveTicket( Resource *resource=0 ); | 130 | Ticket *requestSaveTicket( Resource *resource=0 ); |
131 | 131 | ||
132 | /** | 132 | /** |
133 | Load address book from file. | 133 | Load address book from file. |
134 | */ | 134 | */ |
135 | bool load(); | 135 | bool load(); |
136 | 136 | ||
137 | /** | 137 | /** |
138 | Save address book. The address book is saved to the file, the Ticket | 138 | Save address book. The address book is saved to the file, the Ticket |
139 | object has been requested for by @ref requestSaveTicket(). | 139 | object has been requested for by @ref requestSaveTicket(). |
140 | 140 | ||
141 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
142 | */ | 142 | */ |
143 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
144 | bool saveAB( ); | 144 | bool saveAB( ); |
145 | bool saveABphone( QString fileName ); | 145 | bool saveABphone( QString fileName ); |
146 | void smplifyAddressees(); | 146 | void smplifyAddressees(); |
147 | void removeSyncInfo( QString syncProfile); | ||
147 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); | 148 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); |
148 | void export2File( QString fileName ); | 149 | void export2File( QString fileName ); |
149 | bool export2PhoneFormat( QStringList uids ,QString fileName ); | 150 | bool export2PhoneFormat( QStringList uids ,QString fileName ); |
150 | int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); | 151 | int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); |
151 | void setUntagged( bool setNonSyncTagged = false ); | 152 | void setUntagged( bool setNonSyncTagged = false ); |
152 | void removeUntagged(); | 153 | void removeUntagged(); |
153 | void findNewExtIds( QString fileName, QString currentSyncDevice ); | 154 | void findNewExtIds( QString fileName, QString currentSyncDevice ); |
154 | /** | 155 | /** |
155 | Returns a iterator for first entry of address book. | 156 | Returns a iterator for first entry of address book. |
156 | */ | 157 | */ |
157 | Iterator begin(); | 158 | Iterator begin(); |
158 | 159 | ||
159 | /** | 160 | /** |
160 | Returns a const iterator for first entry of address book. | 161 | Returns a const iterator for first entry of address book. |
161 | */ | 162 | */ |
162 | ConstIterator begin() const; | 163 | ConstIterator begin() const; |
163 | 164 | ||
164 | /** | 165 | /** |
165 | Returns a iterator for first entry of address book. | 166 | Returns a iterator for first entry of address book. |
166 | */ | 167 | */ |
167 | Iterator end(); | 168 | Iterator end(); |
168 | 169 | ||
169 | /** | 170 | /** |
170 | Returns a const iterator for first entry of address book. | 171 | Returns a const iterator for first entry of address book. |
171 | */ | 172 | */ |
172 | ConstIterator end() const; | 173 | ConstIterator end() const; |
173 | 174 | ||
174 | /** | 175 | /** |
175 | Removes all entries from address book. | 176 | Removes all entries from address book. |
176 | */ | 177 | */ |
177 | void clear(); | 178 | void clear(); |
178 | 179 | ||
179 | /** | 180 | /** |
180 | Insert an Addressee object into address book. If an object with the same | 181 | Insert an Addressee object into address book. If an object with the same |
181 | unique id already exists in the address book it it replaced by the new | 182 | unique id already exists in the address book it it replaced by the new |
182 | one. If not the new object is appended to the address book. | 183 | one. If not the new object is appended to the address book. |
183 | */ | 184 | */ |
184 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 185 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
185 | 186 | ||
186 | /** | 187 | /** |
187 | Removes entry from the address book. | 188 | Removes entry from the address book. |
188 | */ | 189 | */ |
189 | void removeAddressee( const Addressee & ); | 190 | void removeAddressee( const Addressee & ); |
190 | 191 | ||
191 | /** | 192 | /** |
192 | This is like @ref removeAddressee() just above, with the difference that | 193 | This is like @ref removeAddressee() just above, with the difference that |
193 | the first element is a iterator, returned by @ref begin(). | 194 | the first element is a iterator, returned by @ref begin(). |
194 | */ | 195 | */ |
195 | void removeAddressee( const Iterator & ); | 196 | void removeAddressee( const Iterator & ); |
196 | 197 | ||
197 | /** | 198 | /** |
198 | Find the specified entry in address book. Returns end(), if the entry | 199 | Find the specified entry in address book. Returns end(), if the entry |
199 | couldn't be found. | 200 | couldn't be found. |
200 | */ | 201 | */ |
201 | Iterator find( const Addressee & ); | 202 | Iterator find( const Addressee & ); |
202 | 203 | ||
203 | /** | 204 | /** |
204 | Find the entry specified by an unique id. Returns an empty Addressee | 205 | Find the entry specified by an unique id. Returns an empty Addressee |
205 | object, if the address book does not contain an entry with this id. | 206 | object, if the address book does not contain an entry with this id. |
206 | */ | 207 | */ |
207 | Addressee findByUid( const QString & ); | 208 | Addressee findByUid( const QString & ); |
208 | 209 | ||
209 | 210 | ||
210 | /** | 211 | /** |
211 | Returns a list of all addressees in the address book. This list can | 212 | Returns a list of all addressees in the address book. This list can |
212 | be sorted with @ref KABC::AddresseeList for example. | 213 | be sorted with @ref KABC::AddresseeList for example. |
213 | */ | 214 | */ |
214 | Addressee::List allAddressees(); | 215 | Addressee::List allAddressees(); |
215 | 216 | ||
216 | /** | 217 | /** |
217 | Find all entries with the specified name in the address book. Returns | 218 | Find all entries with the specified name in the address book. Returns |
218 | an empty list, if no entries could be found. | 219 | an empty list, if no entries could be found. |
219 | */ | 220 | */ |
220 | Addressee::List findByName( const QString & ); | 221 | Addressee::List findByName( const QString & ); |
221 | 222 | ||
222 | /** | 223 | /** |
223 | Find all entries with the specified email address in the address book. | 224 | Find all entries with the specified email address in the address book. |
224 | Returns an empty list, if no entries could be found. | 225 | Returns an empty list, if no entries could be found. |
225 | */ | 226 | */ |
226 | Addressee::List findByEmail( const QString & ); | 227 | Addressee::List findByEmail( const QString & ); |
227 | 228 | ||
228 | /** | 229 | /** |
229 | Find all entries wich have the specified category in the address book. | 230 | Find all entries wich have the specified category in the address book. |
230 | Returns an empty list, if no entries could be found. | 231 | Returns an empty list, if no entries could be found. |
231 | */ | 232 | */ |
232 | Addressee::List findByCategory( const QString & ); | 233 | Addressee::List findByCategory( const QString & ); |
233 | 234 | ||
234 | /** | 235 | /** |
235 | Return a string identifying this addressbook. | 236 | Return a string identifying this addressbook. |
236 | */ | 237 | */ |
237 | virtual QString identifier(); | 238 | virtual QString identifier(); |
238 | 239 | ||
239 | /** | 240 | /** |
240 | Used for debug output. | 241 | Used for debug output. |
241 | */ | 242 | */ |
242 | void dump() const; | 243 | void dump() const; |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 40877ef..a660a9d 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -460,193 +460,196 @@ void Addressee::simplifyAddresses() | |||
460 | if ( (*it) == (*it2) ) { | 460 | if ( (*it) == (*it2) ) { |
461 | list.append( *it ); | 461 | list.append( *it ); |
462 | break; | 462 | break; |
463 | } | 463 | } |
464 | } | 464 | } |
465 | } | 465 | } |
466 | for( it = list.begin(); it != list.end(); ++it ) { | 466 | for( it = list.begin(); it != list.end(); ++it ) { |
467 | removeAddress( (*it) ); | 467 | removeAddress( (*it) ); |
468 | } | 468 | } |
469 | 469 | ||
470 | list.clear(); | 470 | list.clear(); |
471 | int max = 2; | 471 | int max = 2; |
472 | if ( mData->url.isValid() ) | 472 | if ( mData->url.isValid() ) |
473 | max = 1; | 473 | max = 1; |
474 | if ( mData->addresses.count() <= max ) return ; | 474 | if ( mData->addresses.count() <= max ) return ; |
475 | int count = 0; | 475 | int count = 0; |
476 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 476 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
477 | if ( count >= max ) | 477 | if ( count >= max ) |
478 | list.append( *it ); | 478 | list.append( *it ); |
479 | ++count; | 479 | ++count; |
480 | } | 480 | } |
481 | for( it = list.begin(); it != list.end(); ++it ) { | 481 | for( it = list.begin(); it != list.end(); ++it ) { |
482 | removeAddress( (*it) ); | 482 | removeAddress( (*it) ); |
483 | } | 483 | } |
484 | } | 484 | } |
485 | 485 | ||
486 | // removes all emails but the first | 486 | // removes all emails but the first |
487 | // needed by phone sync | 487 | // needed by phone sync |
488 | void Addressee::simplifyEmails() | 488 | void Addressee::simplifyEmails() |
489 | { | 489 | { |
490 | if ( mData->emails.count() == 0 ) return ; | 490 | if ( mData->emails.count() == 0 ) return ; |
491 | QString email = mData->emails.first(); | 491 | QString email = mData->emails.first(); |
492 | detach(); | 492 | detach(); |
493 | mData->emails.clear(); | 493 | mData->emails.clear(); |
494 | mData->emails.append( email ); | 494 | mData->emails.append( email ); |
495 | } | 495 | } |
496 | 496 | ||
497 | void Addressee::simplifyPhoneNumbers() | 497 | void Addressee::simplifyPhoneNumbers() |
498 | { | 498 | { |
499 | int max = 4; | 499 | int max = 4; |
500 | int inList = mData->phoneNumbers.count(); | 500 | int inList = mData->phoneNumbers.count(); |
501 | KABC::PhoneNumber::List removeNumbers; | 501 | KABC::PhoneNumber::List removeNumbers; |
502 | KABC::PhoneNumber::List::Iterator phoneIter; | 502 | KABC::PhoneNumber::List::Iterator phoneIter; |
503 | if ( inList > max ) { | 503 | if ( inList > max ) { |
504 | // delete non-preferred numbers | 504 | // delete non-preferred numbers |
505 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 505 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
506 | ++phoneIter ) { | 506 | ++phoneIter ) { |
507 | if ( inList > max ) { | 507 | if ( inList > max ) { |
508 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 508 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
509 | removeNumbers.append( ( *phoneIter ) ); | 509 | removeNumbers.append( ( *phoneIter ) ); |
510 | --inList; | 510 | --inList; |
511 | } | 511 | } |
512 | } else | 512 | } else |
513 | break; | 513 | break; |
514 | } | 514 | } |
515 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 515 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
516 | ++phoneIter ) { | 516 | ++phoneIter ) { |
517 | removePhoneNumber(( *phoneIter )); | 517 | removePhoneNumber(( *phoneIter )); |
518 | } | 518 | } |
519 | // delete preferred numbers | 519 | // delete preferred numbers |
520 | if ( inList > max ) { | 520 | if ( inList > max ) { |
521 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 521 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
522 | ++phoneIter ) { | 522 | ++phoneIter ) { |
523 | if ( inList > max ) { | 523 | if ( inList > max ) { |
524 | removeNumbers.append( ( *phoneIter ) ); | 524 | removeNumbers.append( ( *phoneIter ) ); |
525 | --inList; | 525 | --inList; |
526 | } else | 526 | } else |
527 | break; | 527 | break; |
528 | } | 528 | } |
529 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 529 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
530 | ++phoneIter ) { | 530 | ++phoneIter ) { |
531 | removePhoneNumber(( *phoneIter )); | 531 | removePhoneNumber(( *phoneIter )); |
532 | } | 532 | } |
533 | } | 533 | } |
534 | } | 534 | } |
535 | // remove non-numeric characters | 535 | // remove non-numeric characters |
536 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 536 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
537 | ++phoneIter ) { | 537 | ++phoneIter ) { |
538 | if ( ! ( *phoneIter ).simplifyNumber() ) | 538 | if ( ! ( *phoneIter ).simplifyNumber() ) |
539 | removeNumbers.append( ( *phoneIter ) ); | 539 | removeNumbers.append( ( *phoneIter ) ); |
540 | } | 540 | } |
541 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 541 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
542 | ++phoneIter ) { | 542 | ++phoneIter ) { |
543 | removePhoneNumber(( *phoneIter )); | 543 | removePhoneNumber(( *phoneIter )); |
544 | } | 544 | } |
545 | } | 545 | } |
546 | void Addressee::simplifyPhoneNumberTypes() | 546 | void Addressee::simplifyPhoneNumberTypes() |
547 | { | 547 | { |
548 | KABC::PhoneNumber::List::Iterator phoneIter; | 548 | KABC::PhoneNumber::List::Iterator phoneIter; |
549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
550 | ++phoneIter ) | 550 | ++phoneIter ) |
551 | ( *phoneIter ).simplifyType(); | 551 | ( *phoneIter ).simplifyType(); |
552 | } | 552 | } |
553 | void Addressee::removeID(const QString &prof) | 553 | void Addressee::removeID(const QString &prof) |
554 | { | 554 | { |
555 | detach(); | 555 | detach(); |
556 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 556 | if ( prof.isEmpty() ) |
557 | mData->mExternalId = ":"; | ||
558 | else | ||
559 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | ||
557 | 560 | ||
558 | } | 561 | } |
559 | void Addressee::setID( const QString & prof , const QString & id ) | 562 | void Addressee::setID( const QString & prof , const QString & id ) |
560 | { | 563 | { |
561 | detach(); | 564 | detach(); |
562 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 565 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
563 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 566 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
564 | } | 567 | } |
565 | void Addressee::setTempSyncStat( int id ) | 568 | void Addressee::setTempSyncStat( int id ) |
566 | { | 569 | { |
567 | if ( mData->mTempSyncStat == id ) return; | 570 | if ( mData->mTempSyncStat == id ) return; |
568 | detach(); | 571 | detach(); |
569 | mData->mTempSyncStat = id; | 572 | mData->mTempSyncStat = id; |
570 | } | 573 | } |
571 | int Addressee::tempSyncStat() const | 574 | int Addressee::tempSyncStat() const |
572 | { | 575 | { |
573 | return mData->mTempSyncStat; | 576 | return mData->mTempSyncStat; |
574 | } | 577 | } |
575 | 578 | ||
576 | QString Addressee::getID( const QString & prof) | 579 | QString Addressee::getID( const QString & prof) |
577 | { | 580 | { |
578 | return KIdManager::getId ( mData->mExternalId, prof ); | 581 | return KIdManager::getId ( mData->mExternalId, prof ); |
579 | } | 582 | } |
580 | 583 | ||
581 | void Addressee::setCsum( const QString & prof , const QString & id ) | 584 | void Addressee::setCsum( const QString & prof , const QString & id ) |
582 | { | 585 | { |
583 | detach(); | 586 | detach(); |
584 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 587 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
585 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 588 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
586 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 589 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
587 | } | 590 | } |
588 | 591 | ||
589 | QString Addressee::getCsum( const QString & prof) | 592 | QString Addressee::getCsum( const QString & prof) |
590 | { | 593 | { |
591 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 594 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
592 | } | 595 | } |
593 | 596 | ||
594 | void Addressee::setIDStr( const QString & s ) | 597 | void Addressee::setIDStr( const QString & s ) |
595 | { | 598 | { |
596 | detach(); | 599 | detach(); |
597 | mData->mExternalId = s; | 600 | mData->mExternalId = s; |
598 | } | 601 | } |
599 | 602 | ||
600 | QString Addressee::IDStr() const | 603 | QString Addressee::IDStr() const |
601 | { | 604 | { |
602 | return mData->mExternalId; | 605 | return mData->mExternalId; |
603 | } | 606 | } |
604 | 607 | ||
605 | void Addressee::setExternalUID( const QString &id ) | 608 | void Addressee::setExternalUID( const QString &id ) |
606 | { | 609 | { |
607 | if ( id == mData->externalUID ) return; | 610 | if ( id == mData->externalUID ) return; |
608 | detach(); | 611 | detach(); |
609 | mData->empty = false; | 612 | mData->empty = false; |
610 | mData->externalUID = id; | 613 | mData->externalUID = id; |
611 | } | 614 | } |
612 | 615 | ||
613 | QString Addressee::externalUID() const | 616 | QString Addressee::externalUID() const |
614 | { | 617 | { |
615 | return mData->externalUID; | 618 | return mData->externalUID; |
616 | } | 619 | } |
617 | void Addressee::setOriginalExternalUID( const QString &id ) | 620 | void Addressee::setOriginalExternalUID( const QString &id ) |
618 | { | 621 | { |
619 | if ( id == mData->originalExternalUID ) return; | 622 | if ( id == mData->originalExternalUID ) return; |
620 | detach(); | 623 | detach(); |
621 | mData->empty = false; | 624 | mData->empty = false; |
622 | //qDebug("*******Set orig uid %s ", id.latin1()); | 625 | //qDebug("*******Set orig uid %s ", id.latin1()); |
623 | mData->originalExternalUID = id; | 626 | mData->originalExternalUID = id; |
624 | } | 627 | } |
625 | 628 | ||
626 | QString Addressee::originalExternalUID() const | 629 | QString Addressee::originalExternalUID() const |
627 | { | 630 | { |
628 | return mData->originalExternalUID; | 631 | return mData->originalExternalUID; |
629 | } | 632 | } |
630 | 633 | ||
631 | void Addressee::setUid( const QString &id ) | 634 | void Addressee::setUid( const QString &id ) |
632 | { | 635 | { |
633 | if ( id == mData->uid ) return; | 636 | if ( id == mData->uid ) return; |
634 | detach(); | 637 | detach(); |
635 | //qDebug("****setuid %s ", id.latin1()); | 638 | //qDebug("****setuid %s ", id.latin1()); |
636 | mData->empty = false; | 639 | mData->empty = false; |
637 | mData->uid = id; | 640 | mData->uid = id; |
638 | } | 641 | } |
639 | 642 | ||
640 | QString Addressee::uid() const | 643 | QString Addressee::uid() const |
641 | { | 644 | { |
642 | if ( mData->uid.isEmpty() ) | 645 | if ( mData->uid.isEmpty() ) |
643 | mData->uid = KApplication::randomString( 10 ); | 646 | mData->uid = KApplication::randomString( 10 ); |
644 | 647 | ||
645 | return mData->uid; | 648 | return mData->uid; |
646 | } | 649 | } |
647 | 650 | ||
648 | QString Addressee::uidLabel() | 651 | QString Addressee::uidLabel() |
649 | { | 652 | { |
650 | return i18n("Unique Identifier"); | 653 | return i18n("Unique Identifier"); |
651 | } | 654 | } |
652 | 655 | ||
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index efae874..e56e46a 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2719,194 +2719,194 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2719 | } | 2719 | } |
2720 | } | 2720 | } |
2721 | } | 2721 | } |
2722 | ++incCounter; | 2722 | ++incCounter; |
2723 | } | 2723 | } |
2724 | el.clear(); | 2724 | el.clear(); |
2725 | syncManager->hideProgressBar(); | 2725 | syncManager->hideProgressBar(); |
2726 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2726 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2727 | // get rid of micro seconds | 2727 | // get rid of micro seconds |
2728 | QTime t = mLastAddressbookSync.time(); | 2728 | QTime t = mLastAddressbookSync.time(); |
2729 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2729 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2730 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2730 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2731 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2731 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2732 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2732 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2733 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2733 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2734 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2734 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2735 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2735 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2736 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2736 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2737 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2737 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2738 | addresseeRSync.setNote( "" ) ; | 2738 | addresseeRSync.setNote( "" ) ; |
2739 | addresseeLSync.setNote( "" ); | 2739 | addresseeLSync.setNote( "" ); |
2740 | 2740 | ||
2741 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2741 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2742 | remote->insertAddressee( addresseeRSync, false ); | 2742 | remote->insertAddressee( addresseeRSync, false ); |
2743 | local->insertAddressee( addresseeLSync, false ); | 2743 | local->insertAddressee( addresseeLSync, false ); |
2744 | QString mes; | 2744 | QString mes; |
2745 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2745 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2746 | if ( syncManager->mShowSyncSummary ) { | 2746 | if ( syncManager->mShowSyncSummary ) { |
2747 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2747 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2748 | } | 2748 | } |
2749 | qDebug( mes ); | 2749 | qDebug( mes ); |
2750 | return syncOK; | 2750 | return syncOK; |
2751 | } | 2751 | } |
2752 | 2752 | ||
2753 | 2753 | ||
2754 | //this is a overwritten callbackmethods from the syncinterface | 2754 | //this is a overwritten callbackmethods from the syncinterface |
2755 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2755 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2756 | { | 2756 | { |
2757 | 2757 | ||
2758 | //pending prepare addresseeview for output | 2758 | //pending prepare addresseeview for output |
2759 | //pending detect, if remote file has REV field. if not switch to external sync | 2759 | //pending detect, if remote file has REV field. if not switch to external sync |
2760 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2760 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2761 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2761 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2762 | 2762 | ||
2763 | AddressBook abLocal(filename,"syncContact"); | 2763 | AddressBook abLocal(filename,"syncContact"); |
2764 | bool syncOK = false; | 2764 | bool syncOK = false; |
2765 | if ( abLocal.load() ) { | 2765 | if ( abLocal.load() ) { |
2766 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2766 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2767 | bool external = false; | 2767 | bool external = false; |
2768 | bool isXML = false; | 2768 | bool isXML = false; |
2769 | if ( filename.right(4) == ".xml") { | 2769 | if ( filename.right(4) == ".xml") { |
2770 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2770 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2771 | isXML = true; | 2771 | isXML = true; |
2772 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2772 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2773 | } else { | 2773 | } else { |
2774 | external = !manager->mIsKapiFile; | 2774 | external = !manager->mIsKapiFile; |
2775 | if ( external ) { | 2775 | if ( external ) { |
2776 | qDebug("Setting vcf mode to external "); | 2776 | qDebug("Setting vcf mode to external "); |
2777 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2777 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2778 | AddressBook::Iterator it; | 2778 | AddressBook::Iterator it; |
2779 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2779 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2780 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2780 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2781 | (*it).computeCsum( mCurrentSyncDevice ); | 2781 | (*it).computeCsum( mCurrentSyncDevice ); |
2782 | } | 2782 | } |
2783 | } | 2783 | } |
2784 | } | 2784 | } |
2785 | //AddressBook::Iterator it; | 2785 | //AddressBook::Iterator it; |
2786 | //QStringList vcards; | 2786 | //QStringList vcards; |
2787 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2787 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2788 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2788 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2789 | //} | 2789 | //} |
2790 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2790 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2791 | if ( syncOK ) { | 2791 | if ( syncOK ) { |
2792 | if ( syncManager->mWriteBackFile ) | 2792 | if ( syncManager->mWriteBackFile ) |
2793 | { | 2793 | { |
2794 | if ( external ) | 2794 | if ( external ) |
2795 | abLocal.removeSyncAddressees( !isXML); | 2795 | abLocal.removeSyncAddressees( !isXML); |
2796 | qDebug("Saving remote AB "); | 2796 | qDebug("Saving remote AB "); |
2797 | if ( ! abLocal.saveAB()) | 2797 | if ( ! abLocal.saveAB()) |
2798 | qDebug("Error writing back AB to file "); | 2798 | qDebug("Error writing back AB to file "); |
2799 | if ( isXML ) { | 2799 | if ( isXML ) { |
2800 | // afterwrite processing | 2800 | // afterwrite processing |
2801 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2801 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2802 | } | 2802 | } |
2803 | } | 2803 | } |
2804 | } | 2804 | } |
2805 | setModified(); | 2805 | setModified(); |
2806 | 2806 | ||
2807 | } | 2807 | } |
2808 | if ( syncOK ) | 2808 | if ( syncOK ) |
2809 | mViewManager->refreshView(); | 2809 | mViewManager->refreshView(); |
2810 | return syncOK; | 2810 | return syncOK; |
2811 | 2811 | ||
2812 | } | 2812 | } |
2813 | void KABCore::removeSyncInfo( QString syncProfile) | 2813 | void KABCore::removeSyncInfo( QString syncProfile) |
2814 | { | 2814 | { |
2815 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | 2815 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
2816 | 2816 | mAddressBook->removeSyncInfo( syncProfile ); | |
2817 | } | 2817 | } |
2818 | 2818 | ||
2819 | 2819 | ||
2820 | //this is a overwritten callbackmethods from the syncinterface | 2820 | //this is a overwritten callbackmethods from the syncinterface |
2821 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2821 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2822 | { | 2822 | { |
2823 | if ( resource == "phone" ) | 2823 | if ( resource == "phone" ) |
2824 | return syncPhone(); | 2824 | return syncPhone(); |
2825 | disableBR( true ); | 2825 | disableBR( true ); |
2826 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2826 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2827 | 2827 | ||
2828 | AddressBook abLocal( resource,"syncContact"); | 2828 | AddressBook abLocal( resource,"syncContact"); |
2829 | bool syncOK = false; | 2829 | bool syncOK = false; |
2830 | if ( abLocal.load() ) { | 2830 | if ( abLocal.load() ) { |
2831 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2831 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2832 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2832 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2833 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2833 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2834 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2834 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2835 | if ( syncOK ) { | 2835 | if ( syncOK ) { |
2836 | if ( syncManager->mWriteBackFile ) { | 2836 | if ( syncManager->mWriteBackFile ) { |
2837 | abLocal.removeSyncAddressees( false ); | 2837 | abLocal.removeSyncAddressees( false ); |
2838 | abLocal.saveAB(); | 2838 | abLocal.saveAB(); |
2839 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2839 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2840 | } | 2840 | } |
2841 | } | 2841 | } |
2842 | setModified(); | 2842 | setModified(); |
2843 | } | 2843 | } |
2844 | if ( syncOK ) | 2844 | if ( syncOK ) |
2845 | mViewManager->refreshView(); | 2845 | mViewManager->refreshView(); |
2846 | disableBR( false ); | 2846 | disableBR( false ); |
2847 | return syncOK; | 2847 | return syncOK; |
2848 | 2848 | ||
2849 | } | 2849 | } |
2850 | void KABCore::message( QString m ) | 2850 | void KABCore::message( QString m ) |
2851 | { | 2851 | { |
2852 | topLevelWidget()->setCaption( m ); | 2852 | topLevelWidget()->setCaption( m ); |
2853 | mMessageTimer->start( 15000, true ); | 2853 | mMessageTimer->start( 15000, true ); |
2854 | } | 2854 | } |
2855 | bool KABCore::syncPhone() | 2855 | bool KABCore::syncPhone() |
2856 | { | 2856 | { |
2857 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2857 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2858 | QString fileName = getPhoneFile(); | 2858 | QString fileName = getPhoneFile(); |
2859 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2859 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2860 | message(i18n("Phone access failed!")); | 2860 | message(i18n("Phone access failed!")); |
2861 | return false; | 2861 | return false; |
2862 | } | 2862 | } |
2863 | AddressBook abLocal( fileName,"syncContact"); | 2863 | AddressBook abLocal( fileName,"syncContact"); |
2864 | bool syncOK = false; | 2864 | bool syncOK = false; |
2865 | { | 2865 | { |
2866 | abLocal.importFromFile( fileName ); | 2866 | abLocal.importFromFile( fileName ); |
2867 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2867 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2868 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2868 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2869 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2869 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2870 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2870 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2871 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2871 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2872 | if ( syncOK ) { | 2872 | if ( syncOK ) { |
2873 | if ( syncManager->mWriteBackFile ) { | 2873 | if ( syncManager->mWriteBackFile ) { |
2874 | abLocal.removeSyncAddressees( true ); | 2874 | abLocal.removeSyncAddressees( true ); |
2875 | abLocal.saveABphone( fileName ); | 2875 | abLocal.saveABphone( fileName ); |
2876 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2876 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2877 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2877 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2878 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2878 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2879 | } | 2879 | } |
2880 | } | 2880 | } |
2881 | setModified(); | 2881 | setModified(); |
2882 | } | 2882 | } |
2883 | if ( syncOK ) | 2883 | if ( syncOK ) |
2884 | mViewManager->refreshView(); | 2884 | mViewManager->refreshView(); |
2885 | return syncOK; | 2885 | return syncOK; |
2886 | } | 2886 | } |
2887 | void KABCore::getFile( bool success ) | 2887 | void KABCore::getFile( bool success ) |
2888 | { | 2888 | { |
2889 | if ( ! success ) { | 2889 | if ( ! success ) { |
2890 | message( i18n("Error receiving file. Nothing changed!") ); | 2890 | message( i18n("Error receiving file. Nothing changed!") ); |
2891 | return; | 2891 | return; |
2892 | } | 2892 | } |
2893 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2893 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2894 | if ( count ) | 2894 | if ( count ) |
2895 | setModified( true ); | 2895 | setModified( true ); |
2896 | message( i18n("Pi-Sync successful!") ); | 2896 | message( i18n("Pi-Sync successful!") ); |
2897 | mViewManager->refreshView(); | 2897 | mViewManager->refreshView(); |
2898 | } | 2898 | } |
2899 | void KABCore::syncFileRequest() | 2899 | void KABCore::syncFileRequest() |
2900 | { | 2900 | { |
2901 | mAddressBook->export2File( sentSyncFile() ); | 2901 | mAddressBook->export2File( sentSyncFile() ); |
2902 | } | 2902 | } |
2903 | QString KABCore::sentSyncFile() | 2903 | QString KABCore::sentSyncFile() |
2904 | { | 2904 | { |
2905 | #ifdef DESKTOP_VERSION | 2905 | #ifdef DESKTOP_VERSION |
2906 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2906 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2907 | #else | 2907 | #else |
2908 | return QString( "/tmp/copysyncab.vcf" ); | 2908 | return QString( "/tmp/copysyncab.vcf" ); |
2909 | #endif | 2909 | #endif |
2910 | } | 2910 | } |
2911 | 2911 | ||
2912 | void KABCore::setCaptionBack() | 2912 | void KABCore::setCaptionBack() |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index af01625..a08f243 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -3675,98 +3675,99 @@ bool CalendarView::removeCompletedSubTodos( Todo* t ) | |||
3675 | subTodos = t->relations(); | 3675 | subTodos = t->relations(); |
3676 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3676 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3677 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3677 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3678 | deleteTodo = false; | 3678 | deleteTodo = false; |
3679 | } | 3679 | } |
3680 | if ( deleteTodo ) { | 3680 | if ( deleteTodo ) { |
3681 | if ( t->isCompleted() ) { | 3681 | if ( t->isCompleted() ) { |
3682 | checkExternalId( t ); | 3682 | checkExternalId( t ); |
3683 | mCalendar->deleteTodo( t ); | 3683 | mCalendar->deleteTodo( t ); |
3684 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3684 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3685 | } | 3685 | } |
3686 | else | 3686 | else |
3687 | deleteTodo = false; | 3687 | deleteTodo = false; |
3688 | } | 3688 | } |
3689 | return deleteTodo; | 3689 | return deleteTodo; |
3690 | 3690 | ||
3691 | } | 3691 | } |
3692 | void CalendarView::purgeCompleted() | 3692 | void CalendarView::purgeCompleted() |
3693 | { | 3693 | { |
3694 | int result = KMessageBox::warningContinueCancel(this, | 3694 | int result = KMessageBox::warningContinueCancel(this, |
3695 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3695 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3696 | 3696 | ||
3697 | if (result == KMessageBox::Continue) { | 3697 | if (result == KMessageBox::Continue) { |
3698 | 3698 | ||
3699 | QPtrList<Todo> todoCal; | 3699 | QPtrList<Todo> todoCal; |
3700 | QPtrList<Todo> rootTodos; | 3700 | QPtrList<Todo> rootTodos; |
3701 | //QPtrList<Incidence> rel; | 3701 | //QPtrList<Incidence> rel; |
3702 | Todo *aTodo;//, *rTodo; | 3702 | Todo *aTodo;//, *rTodo; |
3703 | Incidence *rIncidence; | 3703 | Incidence *rIncidence; |
3704 | bool childDelete = false; | 3704 | bool childDelete = false; |
3705 | bool deletedOne = true; | 3705 | bool deletedOne = true; |
3706 | todoCal = calendar()->todos(); | 3706 | todoCal = calendar()->todos(); |
3707 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3707 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3708 | if ( !aTodo->relatedTo() ) | 3708 | if ( !aTodo->relatedTo() ) |
3709 | rootTodos.append( aTodo ); | 3709 | rootTodos.append( aTodo ); |
3710 | } | 3710 | } |
3711 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3711 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3712 | removeCompletedSubTodos( aTodo ); | 3712 | removeCompletedSubTodos( aTodo ); |
3713 | } | 3713 | } |
3714 | 3714 | ||
3715 | updateView(); | 3715 | updateView(); |
3716 | } | 3716 | } |
3717 | } | 3717 | } |
3718 | 3718 | ||
3719 | void CalendarView::slotCalendarChanged() | 3719 | void CalendarView::slotCalendarChanged() |
3720 | { | 3720 | { |
3721 | ; | 3721 | ; |
3722 | } | 3722 | } |
3723 | 3723 | ||
3724 | NavigatorBar *CalendarView::navigatorBar() | 3724 | NavigatorBar *CalendarView::navigatorBar() |
3725 | { | 3725 | { |
3726 | return mNavigatorBar; | 3726 | return mNavigatorBar; |
3727 | } | 3727 | } |
3728 | 3728 | ||
3729 | 3729 | ||
3730 | 3730 | ||
3731 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3731 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3732 | { | 3732 | { |
3733 | //qDebug(" alendarView::keyPressEvent "); | 3733 | //qDebug(" alendarView::keyPressEvent "); |
3734 | e->ignore(); | 3734 | e->ignore(); |
3735 | } | 3735 | } |
3736 | 3736 | ||
3737 | 3737 | ||
3738 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3738 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3739 | { | 3739 | { |
3740 | // mSyncManager = manager; | 3740 | // mSyncManager = manager; |
3741 | mSyncKDE = false; | 3741 | mSyncKDE = false; |
3742 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3742 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3743 | qDebug("SyncKDE request detected!"); | 3743 | qDebug("SyncKDE request detected!"); |
3744 | mSyncKDE = true; | 3744 | mSyncKDE = true; |
3745 | } | 3745 | } |
3746 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3746 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3747 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3747 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3748 | return syncCalendar( filename, mode ); | 3748 | return syncCalendar( filename, mode ); |
3749 | } | 3749 | } |
3750 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3750 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3751 | { | 3751 | { |
3752 | mSyncKDE = false; | 3752 | mSyncKDE = false; |
3753 | //mSyncManager = manager; | 3753 | //mSyncManager = manager; |
3754 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3754 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3755 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3755 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3756 | if ( resource == "sharp" ) | 3756 | if ( resource == "sharp" ) |
3757 | syncExternal( 0 ); | 3757 | syncExternal( 0 ); |
3758 | if ( resource == "phone" ) | 3758 | if ( resource == "phone" ) |
3759 | syncExternal( 1 ); | 3759 | syncExternal( 1 ); |
3760 | // pending setmodified | 3760 | // pending setmodified |
3761 | return true; | 3761 | return true; |
3762 | } | 3762 | } |
3763 | void CalendarView::setSyncManager(KSyncManager* manager) | 3763 | void CalendarView::setSyncManager(KSyncManager* manager) |
3764 | { | 3764 | { |
3765 | mSyncManager = manager; | 3765 | mSyncManager = manager; |
3766 | } | 3766 | } |
3767 | 3767 | ||
3768 | void CalendarView::removeSyncInfo( QString syncProfile) | 3768 | void CalendarView::removeSyncInfo( QString syncProfile) |
3769 | { | 3769 | { |
3770 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | 3770 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); |
3771 | mCalendar->removeSyncInfo( syncProfile ); | ||
3771 | 3772 | ||
3772 | } | 3773 | } |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index b801186..b7d6a1f 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,176 +1,177 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef CALENDAR_H | 22 | #ifndef CALENDAR_H |
23 | #define CALENDAR_H | 23 | #define CALENDAR_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qptrlist.h> | 28 | #include <qptrlist.h> |
29 | #include <qdict.h> | 29 | #include <qdict.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "event.h" | 32 | #include "event.h" |
33 | #include "todo.h" | 33 | #include "todo.h" |
34 | #include "journal.h" | 34 | #include "journal.h" |
35 | #include "calfilter.h" | 35 | #include "calfilter.h" |
36 | 36 | ||
37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ | 37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ |
38 | 38 | ||
39 | class KConfig; | 39 | class KConfig; |
40 | 40 | ||
41 | namespace KCal { | 41 | namespace KCal { |
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | This is the main "calendar" object class for KOrganizer. It holds | 45 | This is the main "calendar" object class for KOrganizer. It holds |
46 | information like all appointments/events, user information, etc. etc. | 46 | information like all appointments/events, user information, etc. etc. |
47 | one calendar is associated with each CalendarView (@see calendarview.h). | 47 | one calendar is associated with each CalendarView (@see calendarview.h). |
48 | This is an abstract base class defining the interface to a calendar. It is | 48 | This is an abstract base class defining the interface to a calendar. It is |
49 | implemented by subclasses like @see CalendarLocal, which use different | 49 | implemented by subclasses like @see CalendarLocal, which use different |
50 | methods to store and access the data. | 50 | methods to store and access the data. |
51 | 51 | ||
52 | Ownership of events etc. is handled by the following policy: As soon as an | 52 | Ownership of events etc. is handled by the following policy: As soon as an |
53 | event (or any other subclass of IncidenceBase) object is added to the | 53 | event (or any other subclass of IncidenceBase) object is added to the |
54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes | 54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes |
55 | care of deleting it. All Events returned by the query functions are returned | 55 | care of deleting it. All Events returned by the query functions are returned |
56 | as pointers, that means all changes to the returned events are immediately | 56 | as pointers, that means all changes to the returned events are immediately |
57 | visible in the Calendar. You shouldn't delete any Event object you get from | 57 | visible in the Calendar. You shouldn't delete any Event object you get from |
58 | Calendar. | 58 | Calendar. |
59 | */ | 59 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | Calendar(); | 65 | Calendar(); |
66 | Calendar(const QString &timeZoneId); | 66 | Calendar(const QString &timeZoneId); |
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | void deleteIncidence(Incidence *in); | 68 | void deleteIncidence(Incidence *in); |
69 | void resetTempSyncStat(); | 69 | void resetTempSyncStat(); |
70 | void resetPilotStat(int id); | 70 | void resetPilotStat(int id); |
71 | /** | 71 | /** |
72 | Clears out the current calendar, freeing all used memory etc. | 72 | Clears out the current calendar, freeing all used memory etc. |
73 | */ | 73 | */ |
74 | virtual void close() = 0; | 74 | virtual void close() = 0; |
75 | 75 | ||
76 | /** | 76 | /** |
77 | Sync changes in memory to persistant storage. | 77 | Sync changes in memory to persistant storage. |
78 | */ | 78 | */ |
79 | virtual void save() = 0; | 79 | virtual void save() = 0; |
80 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 80 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
81 | virtual void removeSyncInfo( QString syncProfile) = 0; | ||
81 | virtual bool isSaving() { return false; } | 82 | virtual bool isSaving() { return false; } |
82 | 83 | ||
83 | /** | 84 | /** |
84 | Return the owner of the calendar's full name. | 85 | Return the owner of the calendar's full name. |
85 | */ | 86 | */ |
86 | const QString &getOwner() const; | 87 | const QString &getOwner() const; |
87 | /** | 88 | /** |
88 | Set the owner of the calendar. Should be owner's full name. | 89 | Set the owner of the calendar. Should be owner's full name. |
89 | */ | 90 | */ |
90 | void setOwner( const QString &os ); | 91 | void setOwner( const QString &os ); |
91 | /** | 92 | /** |
92 | Return the email address of the calendar owner. | 93 | Return the email address of the calendar owner. |
93 | */ | 94 | */ |
94 | const QString &getEmail(); | 95 | const QString &getEmail(); |
95 | /** | 96 | /** |
96 | Set the email address of the calendar owner. | 97 | Set the email address of the calendar owner. |
97 | */ | 98 | */ |
98 | void setEmail( const QString & ); | 99 | void setEmail( const QString & ); |
99 | 100 | ||
100 | /** | 101 | /** |
101 | Set time zone from a timezone string (e.g. -2:00) | 102 | Set time zone from a timezone string (e.g. -2:00) |
102 | */ | 103 | */ |
103 | void setTimeZone( const QString &tz ); | 104 | void setTimeZone( const QString &tz ); |
104 | /** | 105 | /** |
105 | Set time zone from a minutes value (e.g. -60) | 106 | Set time zone from a minutes value (e.g. -60) |
106 | */ | 107 | */ |
107 | void setTimeZone( int tz ); | 108 | void setTimeZone( int tz ); |
108 | /** | 109 | /** |
109 | Return time zone as offest in minutes. | 110 | Return time zone as offest in minutes. |
110 | */ | 111 | */ |
111 | int getTimeZone() const; | 112 | int getTimeZone() const; |
112 | /** | 113 | /** |
113 | Compute an ISO 8601 format string from the time zone. | 114 | Compute an ISO 8601 format string from the time zone. |
114 | */ | 115 | */ |
115 | QString getTimeZoneStr() const; | 116 | QString getTimeZoneStr() const; |
116 | /** | 117 | /** |
117 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 118 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
118 | values). | 119 | values). |
119 | */ | 120 | */ |
120 | void setTimeZoneId( const QString & ); | 121 | void setTimeZoneId( const QString & ); |
121 | /** | 122 | /** |
122 | Return time zone id. | 123 | Return time zone id. |
123 | */ | 124 | */ |
124 | QString timeZoneId() const; | 125 | QString timeZoneId() const; |
125 | /** | 126 | /** |
126 | Use local time, not UTC or a time zone. | 127 | Use local time, not UTC or a time zone. |
127 | */ | 128 | */ |
128 | void setLocalTime(); | 129 | void setLocalTime(); |
129 | /** | 130 | /** |
130 | Return whether local time is being used. | 131 | Return whether local time is being used. |
131 | */ | 132 | */ |
132 | bool isLocalTime() const; | 133 | bool isLocalTime() const; |
133 | 134 | ||
134 | /** | 135 | /** |
135 | Add an incidence to calendar. | 136 | Add an incidence to calendar. |
136 | 137 | ||
137 | @return true on success, false on error. | 138 | @return true on success, false on error. |
138 | */ | 139 | */ |
139 | virtual bool addIncidence( Incidence * ); | 140 | virtual bool addIncidence( Incidence * ); |
140 | /** | 141 | /** |
141 | Return filtered list of all incidences of this calendar. | 142 | Return filtered list of all incidences of this calendar. |
142 | */ | 143 | */ |
143 | virtual QPtrList<Incidence> incidences(); | 144 | virtual QPtrList<Incidence> incidences(); |
144 | 145 | ||
145 | /** | 146 | /** |
146 | Return unfiltered list of all incidences of this calendar. | 147 | Return unfiltered list of all incidences of this calendar. |
147 | */ | 148 | */ |
148 | virtual QPtrList<Incidence> rawIncidences(); | 149 | virtual QPtrList<Incidence> rawIncidences(); |
149 | 150 | ||
150 | /** | 151 | /** |
151 | Adds a Event to this calendar object. | 152 | Adds a Event to this calendar object. |
152 | @param anEvent a pointer to the event to add | 153 | @param anEvent a pointer to the event to add |
153 | 154 | ||
154 | @return true on success, false on error. | 155 | @return true on success, false on error. |
155 | */ | 156 | */ |
156 | virtual bool addEventNoDup( Event *event ) = 0; | 157 | virtual bool addEventNoDup( Event *event ) = 0; |
157 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 158 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
158 | virtual bool addEvent( Event *anEvent ) = 0; | 159 | virtual bool addEvent( Event *anEvent ) = 0; |
159 | /** | 160 | /** |
160 | Delete event from calendar. | 161 | Delete event from calendar. |
161 | */ | 162 | */ |
162 | virtual void deleteEvent( Event * ) = 0; | 163 | virtual void deleteEvent( Event * ) = 0; |
163 | /** | 164 | /** |
164 | Retrieves an event on the basis of the unique string ID. | 165 | Retrieves an event on the basis of the unique string ID. |
165 | */ | 166 | */ |
166 | virtual Event *event( const QString &UniqueStr ) = 0; | 167 | virtual Event *event( const QString &UniqueStr ) = 0; |
167 | virtual Event *event( QString, QString ) = 0; | 168 | virtual Event *event( QString, QString ) = 0; |
168 | /** | 169 | /** |
169 | Builds and then returns a list of all events that match for the | 170 | Builds and then returns a list of all events that match for the |
170 | date specified. useful for dayView, etc. etc. | 171 | date specified. useful for dayView, etc. etc. |
171 | The calendar filter is applied. | 172 | The calendar filter is applied. |
172 | */ | 173 | */ |
173 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 174 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
174 | /** | 175 | /** |
175 | Get events, which occur on the given date. | 176 | Get events, which occur on the given date. |
176 | The calendar filter is applied. | 177 | The calendar filter is applied. |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 21b4aaf..3f46d53 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -128,193 +128,214 @@ bool CalendarLocal::addAnniversaryNoDup( Event *event ) | |||
128 | 128 | ||
129 | } | 129 | } |
130 | bool CalendarLocal::addEventNoDup( Event *event ) | 130 | bool CalendarLocal::addEventNoDup( Event *event ) |
131 | { | 131 | { |
132 | Event * eve; | 132 | Event * eve; |
133 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 133 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
134 | if ( *eve == *event ) { | 134 | if ( *eve == *event ) { |
135 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 135 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
136 | return false; | 136 | return false; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | return addEvent( event ); | 139 | return addEvent( event ); |
140 | } | 140 | } |
141 | 141 | ||
142 | bool CalendarLocal::addEvent( Event *event ) | 142 | bool CalendarLocal::addEvent( Event *event ) |
143 | { | 143 | { |
144 | insertEvent( event ); | 144 | insertEvent( event ); |
145 | 145 | ||
146 | event->registerObserver( this ); | 146 | event->registerObserver( this ); |
147 | 147 | ||
148 | setModified( true ); | 148 | setModified( true ); |
149 | 149 | ||
150 | return true; | 150 | return true; |
151 | } | 151 | } |
152 | 152 | ||
153 | void CalendarLocal::deleteEvent( Event *event ) | 153 | void CalendarLocal::deleteEvent( Event *event ) |
154 | { | 154 | { |
155 | 155 | ||
156 | 156 | ||
157 | if ( mEventList.removeRef( event ) ) { | 157 | if ( mEventList.removeRef( event ) ) { |
158 | setModified( true ); | 158 | setModified( true ); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | Event *CalendarLocal::event( const QString &uid ) | 163 | Event *CalendarLocal::event( const QString &uid ) |
164 | { | 164 | { |
165 | 165 | ||
166 | Event *event; | 166 | Event *event; |
167 | 167 | ||
168 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 168 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
169 | if ( event->uid() == uid ) { | 169 | if ( event->uid() == uid ) { |
170 | return event; | 170 | return event; |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
176 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 176 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
177 | { | 177 | { |
178 | Todo * eve; | 178 | Todo * eve; |
179 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 179 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
180 | if ( *eve == *todo ) { | 180 | if ( *eve == *todo ) { |
181 | //qDebug("duplicate todo found! not inserted! "); | 181 | //qDebug("duplicate todo found! not inserted! "); |
182 | return false; | 182 | return false; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | return addTodo( todo ); | 185 | return addTodo( todo ); |
186 | } | 186 | } |
187 | bool CalendarLocal::addTodo( Todo *todo ) | 187 | bool CalendarLocal::addTodo( Todo *todo ) |
188 | { | 188 | { |
189 | mTodoList.append( todo ); | 189 | mTodoList.append( todo ); |
190 | 190 | ||
191 | todo->registerObserver( this ); | 191 | todo->registerObserver( this ); |
192 | 192 | ||
193 | // Set up subtask relations | 193 | // Set up subtask relations |
194 | setupRelations( todo ); | 194 | setupRelations( todo ); |
195 | 195 | ||
196 | setModified( true ); | 196 | setModified( true ); |
197 | 197 | ||
198 | return true; | 198 | return true; |
199 | } | 199 | } |
200 | 200 | ||
201 | void CalendarLocal::deleteTodo( Todo *todo ) | 201 | void CalendarLocal::deleteTodo( Todo *todo ) |
202 | { | 202 | { |
203 | // Handle orphaned children | 203 | // Handle orphaned children |
204 | removeRelations( todo ); | 204 | removeRelations( todo ); |
205 | 205 | ||
206 | if ( mTodoList.removeRef( todo ) ) { | 206 | if ( mTodoList.removeRef( todo ) ) { |
207 | setModified( true ); | 207 | setModified( true ); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | QPtrList<Todo> CalendarLocal::rawTodos() | 211 | QPtrList<Todo> CalendarLocal::rawTodos() |
212 | { | 212 | { |
213 | return mTodoList; | 213 | return mTodoList; |
214 | } | 214 | } |
215 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 215 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
216 | { | 216 | { |
217 | Todo *todo; | 217 | Todo *todo; |
218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
219 | if ( todo->getID( syncProf ) == id ) return todo; | 219 | if ( todo->getID( syncProf ) == id ) return todo; |
220 | } | 220 | } |
221 | 221 | ||
222 | return 0; | 222 | return 0; |
223 | } | 223 | } |
224 | 224 | void CalendarLocal::removeSyncInfo( QString syncProfile) | |
225 | { | ||
226 | QPtrList<Incidence> all = rawIncidences() ; | ||
227 | Incidence *inc; | ||
228 | for ( inc = all.first(); inc; inc = all.next() ) { | ||
229 | inc->removeID( syncProfile ); | ||
230 | } | ||
231 | if ( syncProfile.isEmpty() ) { | ||
232 | QPtrList<Event> el; | ||
233 | Event *todo; | ||
234 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | ||
235 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | ||
236 | el.append( todo ); | ||
237 | } | ||
238 | for ( todo = el.first(); todo; todo = el.next() ) { | ||
239 | deleteIncidence ( todo ); | ||
240 | } | ||
241 | } else { | ||
242 | Event *lse = event( "last-syncEvent-"+ syncProfile); | ||
243 | deleteIncidence ( lse ); | ||
244 | } | ||
245 | } | ||
225 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 246 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
226 | { | 247 | { |
227 | QPtrList<Event> el; | 248 | QPtrList<Event> el; |
228 | Event *todo; | 249 | Event *todo; |
229 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 250 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
230 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 251 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
231 | if ( todo->summary().left(3) == "E: " ) | 252 | if ( todo->summary().left(3) == "E: " ) |
232 | el.append( todo ); | 253 | el.append( todo ); |
233 | } | 254 | } |
234 | 255 | ||
235 | return el; | 256 | return el; |
236 | 257 | ||
237 | } | 258 | } |
238 | Event *CalendarLocal::event( QString syncProf, QString id ) | 259 | Event *CalendarLocal::event( QString syncProf, QString id ) |
239 | { | 260 | { |
240 | Event *todo; | 261 | Event *todo; |
241 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 262 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
242 | if ( todo->getID( syncProf ) == id ) return todo; | 263 | if ( todo->getID( syncProf ) == id ) return todo; |
243 | } | 264 | } |
244 | 265 | ||
245 | return 0; | 266 | return 0; |
246 | } | 267 | } |
247 | Todo *CalendarLocal::todo( const QString &uid ) | 268 | Todo *CalendarLocal::todo( const QString &uid ) |
248 | { | 269 | { |
249 | Todo *todo; | 270 | Todo *todo; |
250 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 271 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
251 | if ( todo->uid() == uid ) return todo; | 272 | if ( todo->uid() == uid ) return todo; |
252 | } | 273 | } |
253 | 274 | ||
254 | return 0; | 275 | return 0; |
255 | } | 276 | } |
256 | QString CalendarLocal::nextSummary() const | 277 | QString CalendarLocal::nextSummary() const |
257 | { | 278 | { |
258 | return mNextSummary; | 279 | return mNextSummary; |
259 | } | 280 | } |
260 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 281 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
261 | { | 282 | { |
262 | return mNextAlarmEventDateTime; | 283 | return mNextAlarmEventDateTime; |
263 | } | 284 | } |
264 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 285 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
265 | { | 286 | { |
266 | //mNextAlarmIncidence | 287 | //mNextAlarmIncidence |
267 | //mNextAlarmDateTime | 288 | //mNextAlarmDateTime |
268 | //return mNextSummary; | 289 | //return mNextSummary; |
269 | //return mNextAlarmEventDateTime; | 290 | //return mNextAlarmEventDateTime; |
270 | bool newNextAlarm = false; | 291 | bool newNextAlarm = false; |
271 | bool computeNextAlarm = false; | 292 | bool computeNextAlarm = false; |
272 | bool ok; | 293 | bool ok; |
273 | int offset; | 294 | int offset; |
274 | QDateTime nextA; | 295 | QDateTime nextA; |
275 | // QString nextSum; | 296 | // QString nextSum; |
276 | //QDateTime nextEvent; | 297 | //QDateTime nextEvent; |
277 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 298 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
278 | computeNextAlarm = true; | 299 | computeNextAlarm = true; |
279 | } else { | 300 | } else { |
280 | if ( ! deleted ) { | 301 | if ( ! deleted ) { |
281 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; | 302 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; |
282 | if ( ok ) { | 303 | if ( ok ) { |
283 | if ( nextA < mNextAlarmDateTime ) { | 304 | if ( nextA < mNextAlarmDateTime ) { |
284 | deRegisterAlarm(); | 305 | deRegisterAlarm(); |
285 | mNextAlarmDateTime = nextA; | 306 | mNextAlarmDateTime = nextA; |
286 | mNextSummary = incidence->summary(); | 307 | mNextSummary = incidence->summary(); |
287 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; | 308 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; |
288 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 309 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
289 | newNextAlarm = true; | 310 | newNextAlarm = true; |
290 | mNextAlarmIncidence = incidence; | 311 | mNextAlarmIncidence = incidence; |
291 | } else { | 312 | } else { |
292 | if ( incidence == mNextAlarmIncidence ) { | 313 | if ( incidence == mNextAlarmIncidence ) { |
293 | computeNextAlarm = true; | 314 | computeNextAlarm = true; |
294 | } | 315 | } |
295 | } | 316 | } |
296 | } else { | 317 | } else { |
297 | if ( mNextAlarmIncidence == incidence ) { | 318 | if ( mNextAlarmIncidence == incidence ) { |
298 | computeNextAlarm = true; | 319 | computeNextAlarm = true; |
299 | } | 320 | } |
300 | } | 321 | } |
301 | } else { // deleted | 322 | } else { // deleted |
302 | if ( incidence == mNextAlarmIncidence ) { | 323 | if ( incidence == mNextAlarmIncidence ) { |
303 | computeNextAlarm = true; | 324 | computeNextAlarm = true; |
304 | } | 325 | } |
305 | } | 326 | } |
306 | } | 327 | } |
307 | if ( computeNextAlarm ) { | 328 | if ( computeNextAlarm ) { |
308 | deRegisterAlarm(); | 329 | deRegisterAlarm(); |
309 | nextA = nextAlarm( 1000 ); | 330 | nextA = nextAlarm( 1000 ); |
310 | if (! mNextAlarmIncidence ) { | 331 | if (! mNextAlarmIncidence ) { |
311 | return; | 332 | return; |
312 | } | 333 | } |
313 | newNextAlarm = true; | 334 | newNextAlarm = true; |
314 | } | 335 | } |
315 | if ( newNextAlarm ) | 336 | if ( newNextAlarm ) |
316 | registerAlarm(); | 337 | registerAlarm(); |
317 | } | 338 | } |
318 | QString CalendarLocal:: getAlarmNotification() | 339 | QString CalendarLocal:: getAlarmNotification() |
319 | { | 340 | { |
320 | QString ret; | 341 | QString ret; |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 5b6c64c..98ec710 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -1,167 +1,168 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | #ifndef KCAL_CALENDARLOCAL_H | 22 | #ifndef KCAL_CALENDARLOCAL_H |
23 | #define KCAL_CALENDARLOCAL_H | 23 | #define KCAL_CALENDARLOCAL_H |
24 | 24 | ||
25 | #include "calendar.h" | 25 | #include "calendar.h" |
26 | 26 | ||
27 | namespace KCal { | 27 | namespace KCal { |
28 | 28 | ||
29 | class CalFormat; | 29 | class CalFormat; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | This class provides a calendar stored as a local file. | 32 | This class provides a calendar stored as a local file. |
33 | */ | 33 | */ |
34 | class CalendarLocal : public Calendar | 34 | class CalendarLocal : public Calendar |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | /** | 37 | /** |
38 | Constructs a new calendar, with variables initialized to sane values. | 38 | Constructs a new calendar, with variables initialized to sane values. |
39 | */ | 39 | */ |
40 | CalendarLocal(); | 40 | CalendarLocal(); |
41 | /** | 41 | /** |
42 | Constructs a new calendar, with variables initialized to sane values. | 42 | Constructs a new calendar, with variables initialized to sane values. |
43 | */ | 43 | */ |
44 | CalendarLocal( const QString &timeZoneId ); | 44 | CalendarLocal( const QString &timeZoneId ); |
45 | ~CalendarLocal(); | 45 | ~CalendarLocal(); |
46 | 46 | ||
47 | /** | 47 | /** |
48 | Loads a calendar on disk in vCalendar or iCalendar format into the current | 48 | Loads a calendar on disk in vCalendar or iCalendar format into the current |
49 | calendar. Any information already present is lost. | 49 | calendar. Any information already present is lost. |
50 | @return true, if successfull, false on error. | 50 | @return true, if successfull, false on error. |
51 | @param fileName the name of the calendar on disk. | 51 | @param fileName the name of the calendar on disk. |
52 | */ | 52 | */ |
53 | bool load( const QString &fileName ); | 53 | bool load( const QString &fileName ); |
54 | /** | 54 | /** |
55 | Writes out the calendar to disk in the specified \a format. | 55 | Writes out the calendar to disk in the specified \a format. |
56 | CalendarLocal takes ownership of the CalFormat object. | 56 | CalendarLocal takes ownership of the CalFormat object. |
57 | @return true, if successfull, false on error. | 57 | @return true, if successfull, false on error. |
58 | @param fileName the name of the file | 58 | @param fileName the name of the file |
59 | */ | 59 | */ |
60 | bool save( const QString &fileName, CalFormat *format = 0 ); | 60 | bool save( const QString &fileName, CalFormat *format = 0 ); |
61 | 61 | ||
62 | /** | 62 | /** |
63 | Clears out the current calendar, freeing all used memory etc. etc. | 63 | Clears out the current calendar, freeing all used memory etc. etc. |
64 | */ | 64 | */ |
65 | void close(); | 65 | void close(); |
66 | 66 | ||
67 | void save() {} | 67 | void save() {} |
68 | 68 | ||
69 | /** | 69 | /** |
70 | Add Event to calendar. | 70 | Add Event to calendar. |
71 | */ | 71 | */ |
72 | void removeSyncInfo( QString syncProfile); | ||
72 | bool addAnniversaryNoDup( Event *event ); | 73 | bool addAnniversaryNoDup( Event *event ); |
73 | bool addEventNoDup( Event *event ); | 74 | bool addEventNoDup( Event *event ); |
74 | bool addEvent( Event *event ); | 75 | bool addEvent( Event *event ); |
75 | /** | 76 | /** |
76 | Deletes an event from this calendar. | 77 | Deletes an event from this calendar. |
77 | */ | 78 | */ |
78 | void deleteEvent( Event *event ); | 79 | void deleteEvent( Event *event ); |
79 | 80 | ||
80 | /** | 81 | /** |
81 | Retrieves an event on the basis of the unique string ID. | 82 | Retrieves an event on the basis of the unique string ID. |
82 | */ | 83 | */ |
83 | Event *event( const QString &uid ); | 84 | Event *event( const QString &uid ); |
84 | /** | 85 | /** |
85 | Return unfiltered list of all events in calendar. | 86 | Return unfiltered list of all events in calendar. |
86 | */ | 87 | */ |
87 | QPtrList<Event> rawEvents(); | 88 | QPtrList<Event> rawEvents(); |
88 | QPtrList<Event> getExternLastSyncEvents(); | 89 | QPtrList<Event> getExternLastSyncEvents(); |
89 | /** | 90 | /** |
90 | Add a todo to the todolist. | 91 | Add a todo to the todolist. |
91 | */ | 92 | */ |
92 | bool addTodo( Todo *todo ); | 93 | bool addTodo( Todo *todo ); |
93 | bool addTodoNoDup( Todo *todo ); | 94 | bool addTodoNoDup( Todo *todo ); |
94 | /** | 95 | /** |
95 | Remove a todo from the todolist. | 96 | Remove a todo from the todolist. |
96 | */ | 97 | */ |
97 | void deleteTodo( Todo * ); | 98 | void deleteTodo( Todo * ); |
98 | /** | 99 | /** |
99 | Searches todolist for an event with this unique string identifier, | 100 | Searches todolist for an event with this unique string identifier, |
100 | returns a pointer or null. | 101 | returns a pointer or null. |
101 | */ | 102 | */ |
102 | Todo *todo( const QString &uid ); | 103 | Todo *todo( const QString &uid ); |
103 | /** | 104 | /** |
104 | Return list of all todos. | 105 | Return list of all todos. |
105 | */ | 106 | */ |
106 | QPtrList<Todo> rawTodos(); | 107 | QPtrList<Todo> rawTodos(); |
107 | /** | 108 | /** |
108 | Returns list of todos due on the specified date. | 109 | Returns list of todos due on the specified date. |
109 | */ | 110 | */ |
110 | QPtrList<Todo> todos( const QDate &date ); | 111 | QPtrList<Todo> todos( const QDate &date ); |
111 | /** | 112 | /** |
112 | Return list of all todos. | 113 | Return list of all todos. |
113 | 114 | ||
114 | Workaround because compiler does not recognize function of base class. | 115 | Workaround because compiler does not recognize function of base class. |
115 | */ | 116 | */ |
116 | QPtrList<Todo> todos() { return Calendar::todos(); } | 117 | QPtrList<Todo> todos() { return Calendar::todos(); } |
117 | 118 | ||
118 | /** | 119 | /** |
119 | Add a Journal entry to calendar. | 120 | Add a Journal entry to calendar. |
120 | */ | 121 | */ |
121 | bool addJournal( Journal * ); | 122 | bool addJournal( Journal * ); |
122 | /** | 123 | /** |
123 | Remove a Journal from the calendar. | 124 | Remove a Journal from the calendar. |
124 | */ | 125 | */ |
125 | void deleteJournal( Journal * ); | 126 | void deleteJournal( Journal * ); |
126 | /** | 127 | /** |
127 | Return Journal for given date. | 128 | Return Journal for given date. |
128 | */ | 129 | */ |
129 | Journal *journal( const QDate & ); | 130 | Journal *journal( const QDate & ); |
130 | /** | 131 | /** |
131 | Return Journal with given UID. | 132 | Return Journal with given UID. |
132 | */ | 133 | */ |
133 | Journal *journal( const QString &uid ); | 134 | Journal *journal( const QString &uid ); |
134 | /** | 135 | /** |
135 | Return list of all Journals stored in calendar. | 136 | Return list of all Journals stored in calendar. |
136 | */ | 137 | */ |
137 | QPtrList<Journal> journals(); | 138 | QPtrList<Journal> journals(); |
138 | 139 | ||
139 | /** | 140 | /** |
140 | Return all alarms, which ocur in the given time interval. | 141 | Return all alarms, which ocur in the given time interval. |
141 | */ | 142 | */ |
142 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); | 143 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); |
143 | 144 | ||
144 | /** | 145 | /** |
145 | Return all alarms, which ocur before given date. | 146 | Return all alarms, which ocur before given date. |
146 | */ | 147 | */ |
147 | Alarm::List alarmsTo( const QDateTime &to ); | 148 | Alarm::List alarmsTo( const QDateTime &to ); |
148 | 149 | ||
149 | QDateTime nextAlarm( int daysTo ) ; | 150 | QDateTime nextAlarm( int daysTo ) ; |
150 | QDateTime nextAlarmEventDateTime() const; | 151 | QDateTime nextAlarmEventDateTime() const; |
151 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; | 152 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; |
152 | void registerAlarm(); | 153 | void registerAlarm(); |
153 | void deRegisterAlarm(); | 154 | void deRegisterAlarm(); |
154 | QString getAlarmNotification(); | 155 | QString getAlarmNotification(); |
155 | QString nextSummary() const ; | 156 | QString nextSummary() const ; |
156 | /** | 157 | /** |
157 | This method should be called whenever a Event is modified directly | 158 | This method should be called whenever a Event is modified directly |
158 | via it's pointer. It makes sure that the calendar is internally | 159 | via it's pointer. It makes sure that the calendar is internally |
159 | consistent. | 160 | consistent. |
160 | */ | 161 | */ |
161 | void update( IncidenceBase *incidence ); | 162 | void update( IncidenceBase *incidence ); |
162 | 163 | ||
163 | /** | 164 | /** |
164 | Builds and then returns a list of all events that match for the | 165 | Builds and then returns a list of all events that match for the |
165 | date specified. useful for dayView, etc. etc. | 166 | date specified. useful for dayView, etc. etc. |
166 | */ | 167 | */ |
167 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); | 168 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index b36dc1a..9aa517c 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -260,148 +260,151 @@ Attendee *IncidenceBase::getAttendee(const char *n) const | |||
260 | if (qli.current()->getName() == n) | 260 | if (qli.current()->getName() == n) |
261 | return qli.current(); | 261 | return qli.current(); |
262 | ++qli; | 262 | ++qli; |
263 | } | 263 | } |
264 | return 0L; | 264 | return 0L; |
265 | } | 265 | } |
266 | #endif | 266 | #endif |
267 | 267 | ||
268 | Attendee *IncidenceBase::attendeeByMail(const QString &email) | 268 | Attendee *IncidenceBase::attendeeByMail(const QString &email) |
269 | { | 269 | { |
270 | QPtrListIterator<Attendee> qli(mAttendees); | 270 | QPtrListIterator<Attendee> qli(mAttendees); |
271 | 271 | ||
272 | qli.toFirst(); | 272 | qli.toFirst(); |
273 | while (qli) { | 273 | while (qli) { |
274 | if (qli.current()->email().lower() == email.lower()) | 274 | if (qli.current()->email().lower() == email.lower()) |
275 | return qli.current(); | 275 | return qli.current(); |
276 | ++qli; | 276 | ++qli; |
277 | } | 277 | } |
278 | return 0L; | 278 | return 0L; |
279 | } | 279 | } |
280 | 280 | ||
281 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) | 281 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) |
282 | { | 282 | { |
283 | QPtrListIterator<Attendee> qli(mAttendees); | 283 | QPtrListIterator<Attendee> qli(mAttendees); |
284 | 284 | ||
285 | QStringList mails = emails; | 285 | QStringList mails = emails; |
286 | if (!email.isEmpty()) { | 286 | if (!email.isEmpty()) { |
287 | mails.append(email); | 287 | mails.append(email); |
288 | } | 288 | } |
289 | qli.toFirst(); | 289 | qli.toFirst(); |
290 | while (qli) { | 290 | while (qli) { |
291 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { | 291 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { |
292 | if (qli.current()->email().lower() == (*it).lower()) | 292 | if (qli.current()->email().lower() == (*it).lower()) |
293 | return qli.current(); | 293 | return qli.current(); |
294 | } | 294 | } |
295 | 295 | ||
296 | ++qli; | 296 | ++qli; |
297 | } | 297 | } |
298 | return 0L; | 298 | return 0L; |
299 | } | 299 | } |
300 | 300 | ||
301 | void IncidenceBase::setDuration(int seconds) | 301 | void IncidenceBase::setDuration(int seconds) |
302 | { | 302 | { |
303 | mDuration = seconds; | 303 | mDuration = seconds; |
304 | setHasDuration(true); | 304 | setHasDuration(true); |
305 | } | 305 | } |
306 | 306 | ||
307 | int IncidenceBase::duration() const | 307 | int IncidenceBase::duration() const |
308 | { | 308 | { |
309 | return mDuration; | 309 | return mDuration; |
310 | } | 310 | } |
311 | 311 | ||
312 | void IncidenceBase::setHasDuration(bool b) | 312 | void IncidenceBase::setHasDuration(bool b) |
313 | { | 313 | { |
314 | mHasDuration = b; | 314 | mHasDuration = b; |
315 | } | 315 | } |
316 | 316 | ||
317 | bool IncidenceBase::hasDuration() const | 317 | bool IncidenceBase::hasDuration() const |
318 | { | 318 | { |
319 | return mHasDuration; | 319 | return mHasDuration; |
320 | } | 320 | } |
321 | 321 | ||
322 | void IncidenceBase::setSyncStatus(int stat) | 322 | void IncidenceBase::setSyncStatus(int stat) |
323 | { | 323 | { |
324 | if (mReadOnly) return; | 324 | if (mReadOnly) return; |
325 | mSyncStatus = stat; | 325 | mSyncStatus = stat; |
326 | } | 326 | } |
327 | 327 | ||
328 | int IncidenceBase::syncStatus() const | 328 | int IncidenceBase::syncStatus() const |
329 | { | 329 | { |
330 | return mSyncStatus; | 330 | return mSyncStatus; |
331 | } | 331 | } |
332 | 332 | ||
333 | void IncidenceBase::setPilotId( int id ) | 333 | void IncidenceBase::setPilotId( int id ) |
334 | { | 334 | { |
335 | if (mReadOnly) return; | 335 | if (mReadOnly) return; |
336 | mPilotId = id; | 336 | mPilotId = id; |
337 | } | 337 | } |
338 | 338 | ||
339 | int IncidenceBase::pilotId() const | 339 | int IncidenceBase::pilotId() const |
340 | { | 340 | { |
341 | return mPilotId; | 341 | return mPilotId; |
342 | } | 342 | } |
343 | 343 | ||
344 | int IncidenceBase::tempSyncStat() const | 344 | int IncidenceBase::tempSyncStat() const |
345 | { | 345 | { |
346 | return mTempSyncStat; | 346 | return mTempSyncStat; |
347 | } | 347 | } |
348 | void IncidenceBase::setTempSyncStat( int id ) | 348 | void IncidenceBase::setTempSyncStat( int id ) |
349 | { | 349 | { |
350 | if (mReadOnly) return; | 350 | if (mReadOnly) return; |
351 | mTempSyncStat = id; | 351 | mTempSyncStat = id; |
352 | } | 352 | } |
353 | 353 | ||
354 | void IncidenceBase::removeID(const QString &prof) | 354 | void IncidenceBase::removeID(const QString &prof) |
355 | { | 355 | { |
356 | mExternalId = KIdManager::removeId ( mExternalId, prof); | 356 | if ( prof.isEmpty() ) |
357 | mExternalId = ":"; | ||
358 | else | ||
359 | mExternalId = KIdManager::removeId ( mExternalId, prof); | ||
357 | 360 | ||
358 | } | 361 | } |
359 | void IncidenceBase::setID( const QString & prof , const QString & id ) | 362 | void IncidenceBase::setID( const QString & prof , const QString & id ) |
360 | { | 363 | { |
361 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); | 364 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); |
362 | } | 365 | } |
363 | QString IncidenceBase::getID( const QString & prof) | 366 | QString IncidenceBase::getID( const QString & prof) |
364 | { | 367 | { |
365 | return KIdManager::getId ( mExternalId, prof ); | 368 | return KIdManager::getId ( mExternalId, prof ); |
366 | } | 369 | } |
367 | 370 | ||
368 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: | 371 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: |
369 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 | 372 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 |
370 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) | 373 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) |
371 | { | 374 | { |
372 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); | 375 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); |
373 | } | 376 | } |
374 | QString IncidenceBase::getCsum( const QString & prof) | 377 | QString IncidenceBase::getCsum( const QString & prof) |
375 | { | 378 | { |
376 | return KIdManager::getCsum ( mExternalId, prof ); | 379 | return KIdManager::getCsum ( mExternalId, prof ); |
377 | } | 380 | } |
378 | 381 | ||
379 | void IncidenceBase::setIDStr( const QString & s ) | 382 | void IncidenceBase::setIDStr( const QString & s ) |
380 | { | 383 | { |
381 | if (mReadOnly) return; | 384 | if (mReadOnly) return; |
382 | mExternalId = s; | 385 | mExternalId = s; |
383 | } | 386 | } |
384 | 387 | ||
385 | QString IncidenceBase::IDStr() const | 388 | QString IncidenceBase::IDStr() const |
386 | { | 389 | { |
387 | return mExternalId ; | 390 | return mExternalId ; |
388 | } | 391 | } |
389 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) | 392 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) |
390 | { | 393 | { |
391 | if( !mObservers.contains(observer) ) mObservers.append( observer ); | 394 | if( !mObservers.contains(observer) ) mObservers.append( observer ); |
392 | } | 395 | } |
393 | 396 | ||
394 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) | 397 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) |
395 | { | 398 | { |
396 | mObservers.remove( observer ); | 399 | mObservers.remove( observer ); |
397 | } | 400 | } |
398 | 401 | ||
399 | void IncidenceBase::updated() | 402 | void IncidenceBase::updated() |
400 | { | 403 | { |
401 | QPtrListIterator<Observer> it(mObservers); | 404 | QPtrListIterator<Observer> it(mObservers); |
402 | while( it.current() ) { | 405 | while( it.current() ) { |
403 | Observer *o = it.current(); | 406 | Observer *o = it.current(); |
404 | ++it; | 407 | ++it; |
405 | o->incidenceUpdated( this ); | 408 | o->incidenceUpdated( this ); |
406 | } | 409 | } |
407 | } | 410 | } |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 4390a06..feb184b 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,250 +1,282 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | 52 | ||
53 | #include <klocale.h> | 53 | #include <klocale.h> |
54 | #include <kglobal.h> | 54 | #include <kglobal.h> |
55 | #include <kconfig.h> | 55 | #include <kconfig.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | 57 | ||
58 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 58 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
59 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) | 59 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) |
60 | { | 60 | { |
61 | mServerSocket = 0; | 61 | mServerSocket = 0; |
62 | bar = new QProgressBar ( 1, 0 ); | 62 | bar = new QProgressBar ( 1, 0 ); |
63 | bar->setCaption (""); | 63 | bar->setCaption (""); |
64 | 64 | ||
65 | int w = 300; | 65 | int w = 300; |
66 | if ( QApplication::desktop()->width() < 320 ) | 66 | if ( QApplication::desktop()->width() < 320 ) |
67 | w = 220; | 67 | w = 220; |
68 | int h = bar->sizeHint().height() ; | 68 | int h = bar->sizeHint().height() ; |
69 | int dw = QApplication::desktop()->width(); | 69 | int dw = QApplication::desktop()->width(); |
70 | int dh = QApplication::desktop()->height(); | 70 | int dh = QApplication::desktop()->height(); |
71 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 71 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
72 | if ( mPrefs->mPassiveSyncAutoStart ) | 72 | if ( mPrefs->mPassiveSyncAutoStart ) |
73 | enableQuick( false ); | 73 | enableQuick( false ); |
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | KSyncManager::~KSyncManager() | 77 | KSyncManager::~KSyncManager() |
78 | { | 78 | { |
79 | delete bar; | 79 | delete bar; |
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | void KSyncManager::fillSyncMenu() | 83 | void KSyncManager::fillSyncMenu() |
84 | { | 84 | { |
85 | if ( mSyncMenu->count() ) | 85 | if ( mSyncMenu->count() ) |
86 | mSyncMenu->clear(); | 86 | mSyncMenu->clear(); |
87 | 87 | ||
88 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 88 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
89 | mSyncMenu->insertSeparator(); | 89 | mSyncMenu->insertSeparator(); |
90 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | ||
91 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | ||
92 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | ||
93 | clearMenu->insertSeparator(); | ||
94 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | ||
95 | mSyncMenu->insertSeparator(); | ||
90 | if ( mServerSocket == 0 ) { | 96 | if ( mServerSocket == 0 ) { |
91 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 97 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
92 | } else { | 98 | } else { |
93 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 99 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
94 | } | 100 | } |
95 | mSyncMenu->insertSeparator(); | 101 | mSyncMenu->insertSeparator(); |
96 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 102 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
97 | mSyncMenu->insertSeparator(); | 103 | mSyncMenu->insertSeparator(); |
98 | |||
99 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 104 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
100 | config.setGroup("General"); | 105 | config.setGroup("General"); |
101 | QStringList prof = config.readListEntry("SyncProfileNames"); | 106 | QStringList prof = config.readListEntry("SyncProfileNames"); |
102 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 107 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
103 | if ( prof.count() < 2 ) { | 108 | if ( prof.count() < 2 ) { |
104 | prof.clear(); | 109 | prof.clear(); |
105 | QString externalName; | 110 | QString externalName; |
106 | #ifdef DESKTOP_VERSION | 111 | #ifdef DESKTOP_VERSION |
107 | #ifdef _WIN32_ | 112 | #ifdef _WIN32_ |
108 | externalName = "OutLook(not_implemented)"; | 113 | externalName = "OutLook(not_implemented)"; |
109 | #else | 114 | #else |
110 | externalName = "KDE_Desktop"; | 115 | externalName = "KDE_Desktop"; |
111 | #endif | 116 | #endif |
112 | #else | 117 | #else |
113 | externalName = "Sharp_DTM"; | 118 | externalName = "Sharp_DTM"; |
114 | #endif | 119 | #endif |
115 | prof << externalName; | 120 | prof << externalName; |
116 | prof << i18n("Local_file"); | 121 | prof << i18n("Local_file"); |
117 | prof << i18n("Last_file"); | 122 | prof << i18n("Last_file"); |
118 | KSyncProfile* temp = new KSyncProfile (); | 123 | KSyncProfile* temp = new KSyncProfile (); |
119 | temp->setName( prof[0] ); | 124 | temp->setName( prof[0] ); |
120 | temp->writeConfig(&config); | 125 | temp->writeConfig(&config); |
121 | temp->setName( prof[1] ); | 126 | temp->setName( prof[1] ); |
122 | temp->writeConfig(&config); | 127 | temp->writeConfig(&config); |
123 | temp->setName( prof[2] ); | 128 | temp->setName( prof[2] ); |
124 | temp->writeConfig(&config); | 129 | temp->writeConfig(&config); |
125 | config.setGroup("General"); | 130 | config.setGroup("General"); |
126 | config.writeEntry("SyncProfileNames",prof); | 131 | config.writeEntry("SyncProfileNames",prof); |
127 | config.writeEntry("ExternSyncProfiles",externalName); | 132 | config.writeEntry("ExternSyncProfiles",externalName); |
128 | config.sync(); | 133 | config.sync(); |
129 | delete temp; | 134 | delete temp; |
130 | } | 135 | } |
131 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 136 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
132 | mSyncProfileNames = prof; | 137 | mSyncProfileNames = prof; |
133 | unsigned int i; | 138 | unsigned int i; |
134 | for ( i = 0; i < prof.count(); ++i ) { | 139 | for ( i = 0; i < prof.count(); ++i ) { |
135 | mSyncMenu->insertItem( prof[i], 1000+i ); | 140 | mSyncMenu->insertItem( prof[i], 1000+i ); |
141 | clearMenu->insertItem( prof[i], 1000+i ); | ||
136 | if ( i == 2 ) | 142 | if ( i == 2 ) |
137 | mSyncMenu->insertSeparator(); | 143 | mSyncMenu->insertSeparator(); |
138 | } | 144 | } |
139 | QDir app_dir; | 145 | QDir app_dir; |
140 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 146 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
141 | if ( mTargetApp == PWMPI) { | 147 | if ( mTargetApp == PWMPI) { |
142 | mSyncMenu->removeItem( 1000 ); | 148 | mSyncMenu->removeItem( 1000 ); |
149 | clearMenu->removeItem( 1000 ); | ||
143 | } | 150 | } |
144 | #ifndef DESKTOP_VERSION | 151 | #ifndef DESKTOP_VERSION |
145 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 152 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
146 | mSyncMenu->removeItem( 1000 ); | 153 | mSyncMenu->removeItem( 1000 ); |
154 | clearMenu->removeItem( 1000 ); | ||
147 | } | 155 | } |
148 | #endif | 156 | #endif |
149 | mSyncMenu->removeItem( 1002 ); | 157 | mSyncMenu->removeItem( 1002 ); |
158 | clearMenu->removeItem( 1002 ); | ||
150 | } | 159 | } |
160 | void KSyncManager::slotClearMenu( int action ) | ||
161 | { | ||
162 | QString syncDevice; | ||
163 | if ( action > 999 ) { | ||
164 | syncDevice = mSyncProfileNames[action - 1000] ; | ||
165 | } | ||
151 | 166 | ||
167 | |||
168 | |||
169 | int result = 0; | ||
170 | QString sd; | ||
171 | if ( syncDevice.isEmpty() ) | ||
172 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | ||
173 | else | ||
174 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | ||
175 | |||
176 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | ||
177 | 0, 1 ); | ||
178 | if ( result ) | ||
179 | return; | ||
180 | mImplementation->removeSyncInfo( syncDevice ); | ||
181 | } | ||
152 | void KSyncManager::slotSyncMenu( int action ) | 182 | void KSyncManager::slotSyncMenu( int action ) |
153 | { | 183 | { |
154 | qDebug("syncaction %d ", action); | 184 | qDebug("syncaction %d ", action); |
185 | if ( action == 5000 ) | ||
186 | return; | ||
155 | if ( action == 0 ) { | 187 | if ( action == 0 ) { |
156 | 188 | ||
157 | // seems to be a Qt2 event handling bug | 189 | // seems to be a Qt2 event handling bug |
158 | // syncmenu.clear causes a segfault at first time | 190 | // syncmenu.clear causes a segfault at first time |
159 | // when we call it after the main event loop, it is ok | 191 | // when we call it after the main event loop, it is ok |
160 | // same behaviour when calling OM/Pi via QCOP for the first time | 192 | // same behaviour when calling OM/Pi via QCOP for the first time |
161 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 193 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
162 | //confSync(); | 194 | //confSync(); |
163 | 195 | ||
164 | return; | 196 | return; |
165 | } | 197 | } |
166 | if ( action == 1 ) { | 198 | if ( action == 1 ) { |
167 | multiSync( true ); | 199 | multiSync( true ); |
168 | return; | 200 | return; |
169 | } | 201 | } |
170 | if ( action == 2 ) { | 202 | if ( action == 2 ) { |
171 | enableQuick(); | 203 | enableQuick(); |
172 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 204 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
173 | return; | 205 | return; |
174 | } | 206 | } |
175 | if ( action == 3 ) { | 207 | if ( action == 3 ) { |
176 | delete mServerSocket; | 208 | delete mServerSocket; |
177 | mServerSocket = 0; | 209 | mServerSocket = 0; |
178 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 210 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
179 | return; | 211 | return; |
180 | } | 212 | } |
181 | 213 | ||
182 | if (blockSave()) | 214 | if (blockSave()) |
183 | return; | 215 | return; |
184 | 216 | ||
185 | setBlockSave(true); | 217 | setBlockSave(true); |
186 | bool silent = false; | 218 | bool silent = false; |
187 | if ( action == 999 ) { | 219 | if ( action == 999 ) { |
188 | //special mode for silent syncing | 220 | //special mode for silent syncing |
189 | action = 1000; | 221 | action = 1000; |
190 | silent = true; | 222 | silent = true; |
191 | } | 223 | } |
192 | 224 | ||
193 | mCurrentSyncProfile = action - 1000 ; | 225 | mCurrentSyncProfile = action - 1000 ; |
194 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 226 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
195 | mCurrentSyncName = mLocalMachineName ; | 227 | mCurrentSyncName = mLocalMachineName ; |
196 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 228 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
197 | KSyncProfile* temp = new KSyncProfile (); | 229 | KSyncProfile* temp = new KSyncProfile (); |
198 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 230 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
199 | temp->readConfig(&config); | 231 | temp->readConfig(&config); |
200 | if (silent) { | 232 | if (silent) { |
201 | mAskForPreferences = false; | 233 | mAskForPreferences = false; |
202 | mShowSyncSummary = false; | 234 | mShowSyncSummary = false; |
203 | mWriteBackFile = true; | 235 | mWriteBackFile = true; |
204 | mSyncAlgoPrefs = 2;// take newest | 236 | mSyncAlgoPrefs = 2;// take newest |
205 | } | 237 | } |
206 | else { | 238 | else { |
207 | mAskForPreferences = temp->getAskForPreferences(); | 239 | mAskForPreferences = temp->getAskForPreferences(); |
208 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 240 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
209 | mWriteBackFile = temp->getWriteBackFile(); | 241 | mWriteBackFile = temp->getWriteBackFile(); |
210 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 242 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
211 | } | 243 | } |
212 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 244 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
213 | mIsKapiFile = temp->getIsKapiFile(); | 245 | mIsKapiFile = temp->getIsKapiFile(); |
214 | mWriteBackInFuture = 0; | 246 | mWriteBackInFuture = 0; |
215 | if ( temp->getWriteBackFuture() ) | 247 | if ( temp->getWriteBackFuture() ) |
216 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 248 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
217 | 249 | ||
218 | if ( action == 1000 ) { | 250 | if ( action == 1000 ) { |
219 | #ifdef DESKTOP_VERSION | 251 | #ifdef DESKTOP_VERSION |
220 | syncKDE(); | 252 | syncKDE(); |
221 | #else | 253 | #else |
222 | syncSharp(); | 254 | syncSharp(); |
223 | #endif | 255 | #endif |
224 | 256 | ||
225 | } else if ( action == 1001 ) { | 257 | } else if ( action == 1001 ) { |
226 | syncLocalFile(); | 258 | syncLocalFile(); |
227 | 259 | ||
228 | } else if ( action == 1002 ) { | 260 | } else if ( action == 1002 ) { |
229 | mWriteBackFile = false; | 261 | mWriteBackFile = false; |
230 | mAskForPreferences = false; | 262 | mAskForPreferences = false; |
231 | mShowSyncSummary = false; | 263 | mShowSyncSummary = false; |
232 | mSyncAlgoPrefs = 3; | 264 | mSyncAlgoPrefs = 3; |
233 | quickSyncLocalFile(); | 265 | quickSyncLocalFile(); |
234 | 266 | ||
235 | } else if ( action >= 1003 ) { | 267 | } else if ( action >= 1003 ) { |
236 | if ( temp->getIsLocalFileSync() ) { | 268 | if ( temp->getIsLocalFileSync() ) { |
237 | switch(mTargetApp) | 269 | switch(mTargetApp) |
238 | { | 270 | { |
239 | case (KAPI): | 271 | case (KAPI): |
240 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 272 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
241 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 273 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
242 | break; | 274 | break; |
243 | case (KOPI): | 275 | case (KOPI): |
244 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 276 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
245 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 277 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
246 | break; | 278 | break; |
247 | case (PWMPI): | 279 | case (PWMPI): |
248 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 280 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
249 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 281 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
250 | break; | 282 | break; |
@@ -742,194 +774,200 @@ bool KSyncManager::edit_pisync_options() | |||
742 | mActiveSyncIP = le2.text(); | 774 | mActiveSyncIP = le2.text(); |
743 | return true; | 775 | return true; |
744 | } | 776 | } |
745 | return false; | 777 | return false; |
746 | } | 778 | } |
747 | bool KSyncManager::edit_sync_options() | 779 | bool KSyncManager::edit_sync_options() |
748 | { | 780 | { |
749 | 781 | ||
750 | QDialog dia( mParent, "dia", true ); | 782 | QDialog dia( mParent, "dia", true ); |
751 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 783 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
752 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 784 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
753 | QVBoxLayout lay ( &dia ); | 785 | QVBoxLayout lay ( &dia ); |
754 | lay.setSpacing( 2 ); | 786 | lay.setSpacing( 2 ); |
755 | lay.setMargin( 3 ); | 787 | lay.setMargin( 3 ); |
756 | lay.addWidget(&gr); | 788 | lay.addWidget(&gr); |
757 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 789 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
758 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 790 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
759 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 791 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
760 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 792 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
761 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 793 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
762 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 794 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
763 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 795 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
764 | QPushButton pb ( "OK", &dia); | 796 | QPushButton pb ( "OK", &dia); |
765 | lay.addWidget( &pb ); | 797 | lay.addWidget( &pb ); |
766 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 798 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
767 | switch ( mSyncAlgoPrefs ) { | 799 | switch ( mSyncAlgoPrefs ) { |
768 | case 0: | 800 | case 0: |
769 | loc.setChecked( true); | 801 | loc.setChecked( true); |
770 | break; | 802 | break; |
771 | case 1: | 803 | case 1: |
772 | rem.setChecked( true ); | 804 | rem.setChecked( true ); |
773 | break; | 805 | break; |
774 | case 2: | 806 | case 2: |
775 | newest.setChecked( true); | 807 | newest.setChecked( true); |
776 | break; | 808 | break; |
777 | case 3: | 809 | case 3: |
778 | ask.setChecked( true); | 810 | ask.setChecked( true); |
779 | break; | 811 | break; |
780 | case 4: | 812 | case 4: |
781 | f_loc.setChecked( true); | 813 | f_loc.setChecked( true); |
782 | break; | 814 | break; |
783 | case 5: | 815 | case 5: |
784 | f_rem.setChecked( true); | 816 | f_rem.setChecked( true); |
785 | break; | 817 | break; |
786 | case 6: | 818 | case 6: |
787 | // both.setChecked( true); | 819 | // both.setChecked( true); |
788 | break; | 820 | break; |
789 | default: | 821 | default: |
790 | break; | 822 | break; |
791 | } | 823 | } |
792 | if ( dia.exec() ) { | 824 | if ( dia.exec() ) { |
793 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 825 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
794 | return true; | 826 | return true; |
795 | } | 827 | } |
796 | return false; | 828 | return false; |
797 | } | 829 | } |
798 | 830 | ||
799 | QString KSyncManager::getPassword( ) | 831 | QString KSyncManager::getPassword( ) |
800 | { | 832 | { |
801 | QString retfile = ""; | 833 | QString retfile = ""; |
802 | QDialog dia ( mParent, "input-dialog", true ); | 834 | QDialog dia ( mParent, "input-dialog", true ); |
803 | QLineEdit lab ( &dia ); | 835 | QLineEdit lab ( &dia ); |
804 | lab.setEchoMode( QLineEdit::Password ); | 836 | lab.setEchoMode( QLineEdit::Password ); |
805 | QVBoxLayout lay( &dia ); | 837 | QVBoxLayout lay( &dia ); |
806 | lay.setMargin(7); | 838 | lay.setMargin(7); |
807 | lay.setSpacing(7); | 839 | lay.setSpacing(7); |
808 | lay.addWidget( &lab); | 840 | lay.addWidget( &lab); |
809 | dia.setFixedSize( 230,50 ); | 841 | dia.setFixedSize( 230,50 ); |
810 | dia.setCaption( i18n("Enter password") ); | 842 | dia.setCaption( i18n("Enter password") ); |
811 | QPushButton pb ( "OK", &dia); | 843 | QPushButton pb ( "OK", &dia); |
812 | lay.addWidget( &pb ); | 844 | lay.addWidget( &pb ); |
813 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 845 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
814 | dia.show(); | 846 | dia.show(); |
815 | int res = dia.exec(); | 847 | int res = dia.exec(); |
816 | if ( res ) | 848 | if ( res ) |
817 | retfile = lab.text(); | 849 | retfile = lab.text(); |
818 | dia.hide(); | 850 | dia.hide(); |
819 | qApp->processEvents(); | 851 | qApp->processEvents(); |
820 | return retfile; | 852 | return retfile; |
821 | 853 | ||
822 | } | 854 | } |
823 | 855 | ||
824 | 856 | ||
825 | void KSyncManager::confSync() | 857 | void KSyncManager::confSync() |
826 | { | 858 | { |
827 | static KSyncPrefsDialog* sp = 0; | 859 | static KSyncPrefsDialog* sp = 0; |
828 | if ( ! sp ) { | 860 | if ( ! sp ) { |
829 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 861 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
830 | } | 862 | } |
831 | sp->usrReadConfig(); | 863 | sp->usrReadConfig(); |
832 | #ifndef DESKTOP_VERSION | 864 | #ifndef DESKTOP_VERSION |
833 | sp->showMaximized(); | 865 | sp->showMaximized(); |
834 | #else | 866 | #else |
835 | sp->show(); | 867 | sp->show(); |
836 | #endif | 868 | #endif |
837 | sp->exec(); | 869 | sp->exec(); |
870 | QStringList oldSyncProfileNames = mSyncProfileNames; | ||
838 | mSyncProfileNames = sp->getSyncProfileNames(); | 871 | mSyncProfileNames = sp->getSyncProfileNames(); |
839 | mLocalMachineName = sp->getLocalMachineName (); | 872 | mLocalMachineName = sp->getLocalMachineName (); |
873 | int ii; | ||
874 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | ||
875 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | ||
876 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | ||
877 | } | ||
840 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 878 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
841 | } | 879 | } |
842 | void KSyncManager::syncKDE() | 880 | void KSyncManager::syncKDE() |
843 | { | 881 | { |
844 | emit save(); | 882 | emit save(); |
845 | switch(mTargetApp) | 883 | switch(mTargetApp) |
846 | { | 884 | { |
847 | case (KAPI): | 885 | case (KAPI): |
848 | 886 | ||
849 | break; | 887 | break; |
850 | case (KOPI): | 888 | case (KOPI): |
851 | { | 889 | { |
852 | #ifdef DESKTOP_VERSION | 890 | #ifdef DESKTOP_VERSION |
853 | QString command = qApp->applicationDirPath () + "/kdecaldump"; | 891 | QString command = qApp->applicationDirPath () + "/kdecaldump"; |
854 | #else | 892 | #else |
855 | QString command = "kdecaldump"; | 893 | QString command = "kdecaldump"; |
856 | #endif | 894 | #endif |
857 | if ( ! QFile::exists ( command ) ) | 895 | if ( ! QFile::exists ( command ) ) |
858 | command = "kdecaldump"; | 896 | command = "kdecaldump"; |
859 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 897 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
860 | system ( command.latin1()); | 898 | system ( command.latin1()); |
861 | if ( syncWithFile( fileName,true ) ) { | 899 | if ( syncWithFile( fileName,true ) ) { |
862 | if ( mWriteBackFile ) { | 900 | if ( mWriteBackFile ) { |
863 | command += " --read"; | 901 | command += " --read"; |
864 | system ( command.latin1()); | 902 | system ( command.latin1()); |
865 | } | 903 | } |
866 | } | 904 | } |
867 | 905 | ||
868 | } | 906 | } |
869 | break; | 907 | break; |
870 | case (PWMPI): | 908 | case (PWMPI): |
871 | 909 | ||
872 | break; | 910 | break; |
873 | default: | 911 | default: |
874 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 912 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
875 | break; | 913 | break; |
876 | 914 | ||
877 | } | 915 | } |
878 | } | 916 | } |
879 | 917 | ||
880 | void KSyncManager::syncSharp() | 918 | void KSyncManager::syncSharp() |
881 | { | 919 | { |
882 | 920 | ||
883 | if ( ! syncExternalApplication("sharp") ) | 921 | if ( ! syncExternalApplication("sharp") ) |
884 | qDebug("ERROR sync sharp "); | 922 | qDebug("ERROR sync sharp "); |
885 | } | 923 | } |
886 | 924 | ||
887 | bool KSyncManager::syncExternalApplication(QString resource) | 925 | bool KSyncManager::syncExternalApplication(QString resource) |
888 | { | 926 | { |
889 | 927 | ||
890 | emit save(); | 928 | emit save(); |
891 | 929 | ||
892 | if ( mAskForPreferences ) | 930 | if ( mAskForPreferences ) |
893 | if ( !edit_sync_options()) { | 931 | if ( !edit_sync_options()) { |
894 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 932 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
895 | return false; | 933 | return false; |
896 | } | 934 | } |
897 | 935 | ||
898 | qDebug("Sync extern %s", resource.latin1()); | 936 | qDebug("Sync extern %s", resource.latin1()); |
899 | 937 | ||
900 | bool syncOK = mImplementation->syncExternal(this, resource); | 938 | bool syncOK = mImplementation->syncExternal(this, resource); |
901 | 939 | ||
902 | return syncOK; | 940 | return syncOK; |
903 | 941 | ||
904 | } | 942 | } |
905 | 943 | ||
906 | void KSyncManager::syncPhone() | 944 | void KSyncManager::syncPhone() |
907 | { | 945 | { |
908 | 946 | ||
909 | syncExternalApplication("phone"); | 947 | syncExternalApplication("phone"); |
910 | 948 | ||
911 | } | 949 | } |
912 | 950 | ||
913 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 951 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
914 | { | 952 | { |
915 | if (!bar->isVisible()) | 953 | if (!bar->isVisible()) |
916 | { | 954 | { |
917 | bar->setCaption (caption); | 955 | bar->setCaption (caption); |
918 | bar->setTotalSteps ( total ) ; | 956 | bar->setTotalSteps ( total ) ; |
919 | 957 | ||
920 | bar->show(); | 958 | bar->show(); |
921 | } | 959 | } |
922 | 960 | ||
923 | bar->setProgress( percentage ); | 961 | bar->setProgress( percentage ); |
924 | } | 962 | } |
925 | 963 | ||
926 | void KSyncManager::hideProgressBar() | 964 | void KSyncManager::hideProgressBar() |
927 | { | 965 | { |
928 | bar->hide(); | 966 | bar->hide(); |
929 | } | 967 | } |
930 | 968 | ||
931 | bool KSyncManager::isProgressBarCanceled() | 969 | bool KSyncManager::isProgressBarCanceled() |
932 | { | 970 | { |
933 | return !bar->isVisible(); | 971 | return !bar->isVisible(); |
934 | } | 972 | } |
935 | 973 | ||
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index af4f1ab..aa32e28 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -61,152 +61,153 @@ class KServerSocket : public QServerSocket | |||
61 | bool blockRC; | 61 | bool blockRC; |
62 | void send_file(); | 62 | void send_file(); |
63 | void get_file(); | 63 | void get_file(); |
64 | void end_connect(); | 64 | void end_connect(); |
65 | QDialog* mSyncActionDialog; | 65 | QDialog* mSyncActionDialog; |
66 | QSocket* mSocket; | 66 | QSocket* mSocket; |
67 | QString mPassWord; | 67 | QString mPassWord; |
68 | QString mFileName; | 68 | QString mFileName; |
69 | QTime piTime; | 69 | QTime piTime; |
70 | QString piFileString; | 70 | QString piFileString; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | class KCommandSocket : public QObject | 73 | class KCommandSocket : public QObject |
74 | { | 74 | { |
75 | Q_OBJECT | 75 | Q_OBJECT |
76 | public: | 76 | public: |
77 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; | 77 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; |
78 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 78 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
79 | void readFile( QString ); | 79 | void readFile( QString ); |
80 | void writeFile( QString ); | 80 | void writeFile( QString ); |
81 | void sendStop(); | 81 | void sendStop(); |
82 | 82 | ||
83 | signals: | 83 | signals: |
84 | void commandFinished( KCommandSocket*, int ); | 84 | void commandFinished( KCommandSocket*, int ); |
85 | private slots: | 85 | private slots: |
86 | void startReadFileFromSocket(); | 86 | void startReadFileFromSocket(); |
87 | void readFileFromSocket(); | 87 | void readFileFromSocket(); |
88 | void deleteSocket(); | 88 | void deleteSocket(); |
89 | void writeFileToSocket(); | 89 | void writeFileToSocket(); |
90 | private : | 90 | private : |
91 | QSocket* mSocket; | 91 | QSocket* mSocket; |
92 | QString mPassWord; | 92 | QString mPassWord; |
93 | Q_UINT16 mPort; | 93 | Q_UINT16 mPort; |
94 | QString mHost; | 94 | QString mHost; |
95 | QString mFileName; | 95 | QString mFileName; |
96 | QTimer* mTimerSocket; | 96 | QTimer* mTimerSocket; |
97 | int mRetVal; | 97 | int mRetVal; |
98 | QTime mTime; | 98 | QTime mTime; |
99 | QString mFileString; | 99 | QString mFileString; |
100 | bool mFirst; | 100 | bool mFirst; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | 103 | ||
104 | class KSyncManager : public QObject | 104 | class KSyncManager : public QObject |
105 | { | 105 | { |
106 | Q_OBJECT | 106 | Q_OBJECT |
107 | 107 | ||
108 | public: | 108 | public: |
109 | enum TargetApp { | 109 | enum TargetApp { |
110 | KOPI = 0, | 110 | KOPI = 0, |
111 | KAPI = 1, | 111 | KAPI = 1, |
112 | PWMPI = 2 }; | 112 | PWMPI = 2 }; |
113 | 113 | ||
114 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 114 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
115 | ~KSyncManager() ; | 115 | ~KSyncManager() ; |
116 | 116 | ||
117 | void multiSync( bool askforPrefs ); | 117 | void multiSync( bool askforPrefs ); |
118 | bool blockSave() { return mBlockSaveFlag; } | 118 | bool blockSave() { return mBlockSaveFlag; } |
119 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 119 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
120 | void setDefaultFileName( QString s) { mDefFileName = s ;} | 120 | void setDefaultFileName( QString s) { mDefFileName = s ;} |
121 | QString defaultFileName() { return mDefFileName ;} | 121 | QString defaultFileName() { return mDefFileName ;} |
122 | QString syncFileName(); | 122 | QString syncFileName(); |
123 | void enableQuick( bool ask = true); | 123 | void enableQuick( bool ask = true); |
124 | 124 | ||
125 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 125 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
126 | QString getCurrentSyncName() { return mCurrentSyncName; } | 126 | QString getCurrentSyncName() { return mCurrentSyncName; } |
127 | 127 | ||
128 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 128 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
129 | void hideProgressBar(); | 129 | void hideProgressBar(); |
130 | bool isProgressBarCanceled(); | 130 | bool isProgressBarCanceled(); |
131 | 131 | ||
132 | // sync stuff | 132 | // sync stuff |
133 | QString mLocalMachineName; | 133 | QString mLocalMachineName; |
134 | QStringList mExternSyncProfiles; | 134 | QStringList mExternSyncProfiles; |
135 | QStringList mSyncProfileNames; | 135 | QStringList mSyncProfileNames; |
136 | bool mAskForPreferences; | 136 | bool mAskForPreferences; |
137 | bool mShowSyncSummary; | 137 | bool mShowSyncSummary; |
138 | bool mIsKapiFile; | 138 | bool mIsKapiFile; |
139 | bool mWriteBackExistingOnly; | 139 | bool mWriteBackExistingOnly; |
140 | int mSyncAlgoPrefs; | 140 | int mSyncAlgoPrefs; |
141 | bool mWriteBackFile; | 141 | bool mWriteBackFile; |
142 | int mWriteBackInFuture; | 142 | int mWriteBackInFuture; |
143 | QString mPhoneDevice; | 143 | QString mPhoneDevice; |
144 | QString mPhoneConnection; | 144 | QString mPhoneConnection; |
145 | QString mPhoneModel; | 145 | QString mPhoneModel; |
146 | QString mPassWordPiSync; | 146 | QString mPassWordPiSync; |
147 | QString mActiveSyncPort; | 147 | QString mActiveSyncPort; |
148 | QString mActiveSyncIP ; | 148 | QString mActiveSyncIP ; |
149 | 149 | ||
150 | signals: | 150 | signals: |
151 | void save(); | 151 | void save(); |
152 | void request_file(); | 152 | void request_file(); |
153 | void getFile( bool ); | 153 | void getFile( bool ); |
154 | 154 | ||
155 | public slots: | 155 | public slots: |
156 | void slotSyncMenu( int ); | 156 | void slotSyncMenu( int ); |
157 | void slotClearMenu( int action ); | ||
157 | void deleteCommandSocket(KCommandSocket*s, int state); | 158 | void deleteCommandSocket(KCommandSocket*s, int state); |
158 | void readFileFromSocket(); | 159 | void readFileFromSocket(); |
159 | void fillSyncMenu(); | 160 | void fillSyncMenu(); |
160 | 161 | ||
161 | private: | 162 | private: |
162 | void syncPi(); | 163 | void syncPi(); |
163 | KServerSocket * mServerSocket; | 164 | KServerSocket * mServerSocket; |
164 | KPimPrefs* mPrefs; | 165 | KPimPrefs* mPrefs; |
165 | QString mDefFileName; | 166 | QString mDefFileName; |
166 | QString mCurrentSyncDevice; | 167 | QString mCurrentSyncDevice; |
167 | QString mCurrentSyncName; | 168 | QString mCurrentSyncName; |
168 | void quickSyncLocalFile(); | 169 | void quickSyncLocalFile(); |
169 | bool syncWithFile( QString fn , bool quick ); | 170 | bool syncWithFile( QString fn , bool quick ); |
170 | void syncLocalFile(); | 171 | void syncLocalFile(); |
171 | void syncPhone(); | 172 | void syncPhone(); |
172 | void syncSharp(); | 173 | void syncSharp(); |
173 | void syncKDE(); | 174 | void syncKDE(); |
174 | bool syncExternalApplication(QString); | 175 | bool syncExternalApplication(QString); |
175 | int mCurrentSyncProfile ; | 176 | int mCurrentSyncProfile ; |
176 | void syncRemote( KSyncProfile* prof, bool ask = true); | 177 | void syncRemote( KSyncProfile* prof, bool ask = true); |
177 | bool edit_sync_options(); | 178 | bool edit_sync_options(); |
178 | bool edit_pisync_options(); | 179 | bool edit_pisync_options(); |
179 | int ringSync(); | 180 | int ringSync(); |
180 | QString getPassword( ); | 181 | QString getPassword( ); |
181 | bool mPisyncFinished; | 182 | bool mPisyncFinished; |
182 | bool mBlockSaveFlag; | 183 | bool mBlockSaveFlag; |
183 | QWidget* mParent; | 184 | QWidget* mParent; |
184 | KSyncInterface* mImplementation; | 185 | KSyncInterface* mImplementation; |
185 | TargetApp mTargetApp; | 186 | TargetApp mTargetApp; |
186 | QPopupMenu* mSyncMenu; | 187 | QPopupMenu* mSyncMenu; |
187 | QProgressBar* bar; | 188 | QProgressBar* bar; |
188 | 189 | ||
189 | private slots: | 190 | private slots: |
190 | void confSync(); | 191 | void confSync(); |
191 | 192 | ||
192 | 193 | ||
193 | }; | 194 | }; |
194 | 195 | ||
195 | 196 | ||
196 | class KSyncInterface | 197 | class KSyncInterface |
197 | { | 198 | { |
198 | public : | 199 | public : |
199 | virtual void removeSyncInfo( QString syncProfile) = 0; | 200 | virtual void removeSyncInfo( QString syncProfile) = 0; |
200 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 201 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
201 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 202 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
202 | { | 203 | { |
203 | // empty implementation, because some syncable applications do not | 204 | // empty implementation, because some syncable applications do not |
204 | // have an external(sharpdtm) syncmode, like pwmanager. | 205 | // have an external(sharpdtm) syncmode, like pwmanager. |
205 | return false; | 206 | return false; |
206 | } | 207 | } |
207 | 208 | ||
208 | 209 | ||
209 | }; | 210 | }; |
210 | 211 | ||
211 | 212 | ||
212 | #endif | 213 | #endif |