summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-18 13:13:58 (UTC)
committer zautrix <zautrix>2004-09-18 13:13:58 (UTC)
commitbb16660f29fc709791aa0ee4cb63a40710a994a8 (patch) (unidiff)
tree5d7387987848039bb3594a624b819d136a38b0cd
parent4ec7c78ebd2c5a79ff224e9b07d9a3164f7fe602 (diff)
downloadkdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.zip
kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.tar.gz
kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.tar.bz2
more AB syncing
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp27
-rw-r--r--kabc/addressbook.h5
-rw-r--r--kabc/addressee.cpp54
-rw-r--r--kabc/addressee.h12
-rw-r--r--kaddressbook/kabcore.cpp93
-rw-r--r--kaddressbook/kabcore.h2
6 files changed, 156 insertions, 37 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 70eda1b..9332e21 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -44,2 +44,3 @@ $Id$
44#include <kdebug.h> 44#include <kdebug.h>
45#include <libkcal/syncdefines.h>
45#include "addressbook.h" 46#include "addressbook.h"
@@ -514,2 +515,28 @@ Addressee AddressBook::findByUid( const QString &uid )
514} 515}
516Addressee::List AddressBook::getExternLastSyncAddressees()
517{
518 Addressee::List results;
519
520 Iterator it;
521 for ( it = begin(); it != end(); ++it ) {
522 if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) {
523 if ( (*it).familyName().left(3) == "E: " )
524 results.append( *it );
525 }
526 }
527
528 return results;
529}
530void AddressBook::resetTempSyncStat()
531{
532
533
534 Iterator it;
535 for ( it = begin(); it != end(); ++it ) {
536 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
537 }
538
539}
540
541
515 542
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index e43de31..05225f9 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -290,2 +290,7 @@ class AddressBook : public QObject
290 290
291 // sync stuff
292 Addressee::List getExternLastSyncAddressees();
293 void resetTempSyncStat();
294
295
291 signals: 296 signals:
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 4cdd5e5..fb32f6e 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -34,4 +34,6 @@ $Id$
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h>
35//US 36//US
36#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h>
37 39
@@ -72,3 +74,3 @@ struct Addressee::AddresseeData : public KShared
72 Agent agent; 74 Agent agent;
73 75 QString mExternalId;
74 PhoneNumber::List phoneNumbers; 76 PhoneNumber::List phoneNumbers;
@@ -92,2 +94,4 @@ Addressee::Addressee()
92 mData->resource = 0; 94 mData->resource = 0;
95 mData->mExternalId = ":";
96 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
93} 97}
@@ -101,2 +105,3 @@ Addressee::Addressee( const Addressee &a )
101 mData = a.mData; 105 mData = a.mData;
106 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
102} 107}
@@ -170,2 +175,49 @@ bool Addressee::isEmpty() const
170} 175}
176void Addressee::removeID(const QString &prof)
177{
178 detach();
179 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
180
181}
182void Addressee::setID( const QString & prof , const QString & id )
183{
184 detach();
185 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
186}
187void Addressee::setTempSyncStat( int id )
188{
189 mTempSyncStat = id;
190}
191int Addressee::tempSyncStat() const
192{
193 return mTempSyncStat;
194}
195
196QString Addressee::getID( const QString & prof)
197{
198 return KIdManager::getId ( mData->mExternalId, prof );
199}
200
201void Addressee::setCsum( const QString & prof , const QString & id )
202{
203 detach();
204 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
205}
206
207QString Addressee::getCsum( const QString & prof)
208{
209 return KIdManager::getCsum ( mData->mExternalId, prof );
210}
211
212void Addressee::setIDStr( const QString & s )
213{
214 detach();
215 mData->mExternalId = s;
216}
217
218QString Addressee::IDStr() const
219{
220 return mData->mExternalId;
221}
222
171 223
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 27782f9..f098371 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -98,3 +98,12 @@ class Addressee
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 99 // sync stuff
100 void setTempSyncStat(int id);
101 int tempSyncStat() const;
102 void setIDStr( const QString & );
103 QString IDStr() const;
104 void setID( const QString &, const QString & );
105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & );
108 void removeID(const QString &);
100 /** 109 /**
@@ -817,2 +826,3 @@ class Addressee
817 void detach(); 826 void detach();
827 int mTempSyncStat;
818 828
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 1196360..53c63ff 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2515,5 +2515,24 @@ QString KABCore::getPassword( )
2515} 2515}
2516#include <libkcal/syncdefines.h>
2517
2518KABC::Addressee KABCore::getLastSyncAddressee()
2519{
2520 Addressee lse;
2521 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2522 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2523 if (lse.isEmpty()) {
2524 lse.setUid( "last-syncEvent-"+mCurrentSyncDevice );
2525 QString sum = "";
2526 if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
2527 sum = "E: ";
2528 lse.setFamilyName(sum+mCurrentSyncDevice + i18n(" - sync event"));
2529 lse.setRevision( mLastAddressbookSync );
2530 lse.setCategories( i18n("SyncEvent") );
2531 mAddressBook->insertAddressee( lse );
2532 }
2533 return lse;
2534}
2535
2516bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2536bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2517{ 2537{
2518#if 0
2519 bool syncOK = true; 2538 bool syncOK = true;
@@ -2526,19 +2545,19 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2526 //QPtrList<Addressee> el = local->rawAddressees(); 2545 //QPtrList<Addressee> el = local->rawAddressees();
2527 Addressee* addresseeR; 2546 Addressee addresseeR;
2528 QString uid; 2547 QString uid;
2529 int take; 2548 int take;
2530 Addressee* addresseeL; 2549 Addressee addresseeL;
2531 Addressee* addresseeRSync; 2550 Addressee addresseeRSync;
2532 Addressee* addresseeLSync; 2551 Addressee addresseeLSync;
2533 QPtrList<Addressee> addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2552 KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2534 QPtrList<Addressee> addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2553 KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2535 bool fullDateRange = false; 2554 bool fullDateRange = false;
2536 local->resetTempSyncStat(); 2555 local->resetTempSyncStat();
2537 mLastCalendarSync = QDateTime::currentDateTime(); 2556 mLastAddressbookSync = QDateTime::currentDateTime();
2538 QDateTime modifiedCalendar = mLastCalendarSync;; 2557 QDateTime modifiedCalendar = mLastAddressbookSync;;
2539 addresseeLSync = getLastSyncAddressee(); 2558 addresseeLSync = getLastSyncAddressee();
2540 addresseeR = remote->addressee("last-syncAddressee-"+mCurrentSyncName ); 2559 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2541 if ( addresseeR ) { 2560 if ( !addresseeR.isEmpty() ) {
2542 addresseeRSync = (Addressee*) addresseeR->clone(); 2561 addresseeRSync = addresseeR;
2543 remote->deleteAddressee(addresseeR ); 2562 remote->removeAddressee(addresseeR );
2544 2563
@@ -2546,18 +2565,17 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2546 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2565 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2547 addresseeRSync = (Addressee*)addresseeLSync->clone(); 2566 addresseeRSync = addresseeLSync ;
2548 } else { 2567 } else {
2549 fullDateRange = true; 2568 fullDateRange = true;
2550 addresseeRSync = new Addressee(); 2569 Addressee newAdd;
2551 addresseeRSync->setSummary(mCurrentSyncName + i18n(" - sync addressee")); 2570 addresseeRSync = newAdd;
2552 addresseeRSync->setUid("last-syncAddressee-"+mCurrentSyncName ); 2571 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2553 addresseeRSync->setDtStart( mLastCalendarSync ); 2572 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2554 addresseeRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 2573 addresseeRSync.setRevision( mLastAddressbookSync );
2555 addresseeRSync->setCategories( i18n("SyncAddressee") ); 2574 addresseeRSync.setCategories( i18n("SyncAddressee") );
2556 } 2575 }
2557 } 2576 }
2558 if ( addresseeLSync->dtStart() == mLastCalendarSync ) 2577 if ( addresseeLSync.revision() == mLastAddressbookSync )
2559 fullDateRange = true; 2578 fullDateRange = true;
2560
2561 if ( ! fullDateRange ) { 2579 if ( ! fullDateRange ) {
2562 if ( addresseeLSync->dtStart() != addresseeRSync->dtStart() ) { 2580 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2563 2581
@@ -2569,12 +2587,17 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2569 if ( fullDateRange ) 2587 if ( fullDateRange )
2570 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 2588 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2571 else 2589 else
2572 mLastCalendarSync = addresseeLSync->dtStart(); 2590 mLastAddressbookSync = addresseeLSync.revision();
2573 // for resyncing if own file has changed 2591 // for resyncing if own file has changed
2592 // PENDING fixme later when implemented
2593#if 0
2574 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2594 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2575 mLastCalendarSync = loadedFileVersion; 2595 mLastAddressbookSync = loadedFileVersion;
2576 qDebug("setting mLastCalendarSync "); 2596 qDebug("setting mLastAddressbookSync ");
2577 } 2597 }
2598#endif
2599
2600 #if 0
2578 //qDebug("*************************** "); 2601 //qDebug("*************************** ");
2579 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 2602 qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2580 QPtrList<Incidence> er = remote->rawIncidences(); 2603 QPtrList<Incidence> er = remote->rawIncidences();
@@ -2659,3 +2682,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2659 } else { 2682 } else {
2660 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 2683 if ( inR->lastModified() > mLastAddressbookSync || mode == 5 ) {
2661 inR->setLastModified( modifiedCalendar ); 2684 inR->setLastModified( modifiedCalendar );
@@ -2715,3 +2738,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2715 } else { 2738 } else {
2716 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 2739 if ( inL->lastModified() < mLastAddressbookSync && mode != 4 ) {
2717 checkExternSyncAddressee(addresseeLSyncSharp, inL); 2740 checkExternSyncAddressee(addresseeLSyncSharp, inL);
@@ -2762,8 +2785,8 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2762 bar.hide(); 2785 bar.hide();
2763 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 2786 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2764 addresseeLSync->setReadOnly( false ); 2787 addresseeLSync->setReadOnly( false );
2765 addresseeLSync->setDtStart( mLastCalendarSync ); 2788 addresseeLSync->setDtStart( mLastAddressbookSync );
2766 addresseeRSync->setDtStart( mLastCalendarSync ); 2789 addresseeRSync->setDtStart( mLastAddressbookSync );
2767 addresseeLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 2790 addresseeLSync->setDtEnd( mLastAddressbookSync.addSecs( 3600 ) );
2768 addresseeRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 2791 addresseeRSync->setDtEnd( mLastAddressbookSync.addSecs( 3600 ) );
2769 addresseeRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 2792 addresseeRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 4487a8a..c67cee6 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -474,2 +474,4 @@ class KABCore : public QWidget
474 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 474 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
475 KABC::Addressee getLastSyncAddressee();
476 QDateTime mLastAddressbookSync;
475 public slots: 477 public slots: