author | zautrix <zautrix> | 2004-10-26 22:19:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-26 22:19:18 (UTC) |
commit | 6385f303bef3cbcd19d097a7b05c30e144d5dd6e (patch) (side-by-side diff) | |
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 | 3 | ||||
-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 | 3 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 40 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 1 |
11 files changed, 82 insertions, 4 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 3641c0c..2785131 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -540,32 +540,40 @@ void AddressBook::removeUntagged() todelete = false; } if ( todelete ) removeAddressee( todel ); deleteRemovedAddressees(); } void AddressBook::smplifyAddressees() { Iterator ait; for ( ait = begin(); ait != end(); ++ait ) { (*ait).simplifyEmails(); (*ait).simplifyPhoneNumbers(); (*ait).simplifyPhoneNumberTypes(); (*ait).simplifyAddresses(); } } +void AddressBook::removeSyncInfo( QString syncProfile) +{ + Iterator ait; + for ( ait = begin(); ait != end(); ++ait ) { + (*ait).removeID( syncProfile ); + } + +} void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) { Iterator ait; for ( ait = begin(); ait != end(); ++ait ) { QString id = (*ait).IDStr(); (*ait).setIDStr( ":"); (*ait).setExternalUID( id ); (*ait).setOriginalExternalUID( id ); if ( isPreSync ) (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); else { (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); (*ait).setID( currentSyncDevice,id ); } } diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 5edca06..f124dc9 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h @@ -131,32 +131,33 @@ class AddressBook : public QObject /** Load address book from file. */ bool load(); /** Save address book. The address book is saved to the file, the Ticket object has been requested for by @ref requestSaveTicket(). @param ticket a ticket object returned by @ref requestSaveTicket() */ bool save( Ticket *ticket ); bool saveAB( ); bool saveABphone( QString fileName ); void smplifyAddressees(); + void removeSyncInfo( QString syncProfile); void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); void export2File( QString fileName ); bool export2PhoneFormat( QStringList uids ,QString fileName ); int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); void setUntagged( bool setNonSyncTagged = false ); void removeUntagged(); void findNewExtIds( QString fileName, QString currentSyncDevice ); /** Returns a iterator for first entry of address book. */ Iterator begin(); /** Returns a const iterator for first entry of address book. */ ConstIterator begin() const; diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 40877ef..a660a9d 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -540,32 +540,35 @@ void Addressee::simplifyPhoneNumbers() } for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); ++phoneIter ) { removePhoneNumber(( *phoneIter )); } } void Addressee::simplifyPhoneNumberTypes() { KABC::PhoneNumber::List::Iterator phoneIter; for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) ( *phoneIter ).simplifyType(); } void Addressee::removeID(const QString &prof) { detach(); + if ( prof.isEmpty() ) + mData->mExternalId = ":"; + else mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); } void Addressee::setID( const QString & prof , const QString & id ) { detach(); mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); } void Addressee::setTempSyncStat( int id ) { if ( mData->mTempSyncStat == id ) return; detach(); mData->mTempSyncStat = id; } int Addressee::tempSyncStat() const diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index efae874..e56e46a 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -2799,34 +2799,34 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) if ( isXML ) { // afterwrite processing abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); } } } setModified(); } if ( syncOK ) mViewManager->refreshView(); return syncOK; } void KABCore::removeSyncInfo( QString syncProfile) { - qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); - + qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); + mAddressBook->removeSyncInfo( syncProfile ); } //this is a overwritten callbackmethods from the syncinterface bool KABCore::syncExternal(KSyncManager* manager, QString resource) { if ( resource == "phone" ) return syncPhone(); disableBR( true ); QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); AddressBook abLocal( resource,"syncContact"); bool syncOK = false; if ( abLocal.load() ) { qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); mGlobalSyncMode = SYNC_MODE_EXTERNAL; diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index af01625..a08f243 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -3755,18 +3755,19 @@ bool CalendarView::syncExternal(KSyncManager* manager, QString resource) mCurrentSyncName = mSyncManager->getCurrentSyncName(); if ( resource == "sharp" ) syncExternal( 0 ); if ( resource == "phone" ) syncExternal( 1 ); // pending setmodified return true; } void CalendarView::setSyncManager(KSyncManager* manager) { mSyncManager = manager; } void CalendarView::removeSyncInfo( QString syncProfile) { qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); + mCalendar->removeSyncInfo( syncProfile ); } diff --git a/libkcal/calendar.h b/libkcal/calendar.h index b801186..b7d6a1f 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -65,32 +65,33 @@ public: Calendar(); Calendar(const QString &timeZoneId); virtual ~Calendar(); void deleteIncidence(Incidence *in); void resetTempSyncStat(); void resetPilotStat(int id); /** Clears out the current calendar, freeing all used memory etc. */ virtual void close() = 0; /** Sync changes in memory to persistant storage. */ virtual void save() = 0; virtual QPtrList<Event> getExternLastSyncEvents() = 0; + virtual void removeSyncInfo( QString syncProfile) = 0; virtual bool isSaving() { return false; } /** Return the owner of the calendar's full name. */ const QString &getOwner() const; /** Set the owner of the calendar. Should be owner's full name. */ void setOwner( const QString &os ); /** Return the email address of the calendar owner. */ const QString &getEmail(); /** Set the email address of the calendar owner. diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 21b4aaf..3f46d53 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -208,33 +208,54 @@ void CalendarLocal::deleteTodo( Todo *todo ) } } QPtrList<Todo> CalendarLocal::rawTodos() { return mTodoList; } Todo *CalendarLocal::todo( QString syncProf, QString id ) { Todo *todo; for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { if ( todo->getID( syncProf ) == id ) return todo; } return 0; } - +void CalendarLocal::removeSyncInfo( QString syncProfile) +{ + QPtrList<Incidence> all = rawIncidences() ; + Incidence *inc; + for ( inc = all.first(); inc; inc = all.next() ) { + inc->removeID( syncProfile ); + } + if ( syncProfile.isEmpty() ) { + QPtrList<Event> el; + Event *todo; + for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { + if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) + el.append( todo ); + } + for ( todo = el.first(); todo; todo = el.next() ) { + deleteIncidence ( todo ); + } + } else { + Event *lse = event( "last-syncEvent-"+ syncProfile); + deleteIncidence ( lse ); + } +} QPtrList<Event> CalendarLocal::getExternLastSyncEvents() { QPtrList<Event> el; Event *todo; for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) if ( todo->summary().left(3) == "E: " ) el.append( todo ); } return el; } Event *CalendarLocal::event( QString syncProf, QString id ) { Event *todo; diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 5b6c64c..98ec710 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -56,32 +56,33 @@ class CalendarLocal : public Calendar CalendarLocal takes ownership of the CalFormat object. @return true, if successfull, false on error. @param fileName the name of the file */ bool save( const QString &fileName, CalFormat *format = 0 ); /** Clears out the current calendar, freeing all used memory etc. etc. */ void close(); void save() {} /** Add Event to calendar. */ + void removeSyncInfo( QString syncProfile); bool addAnniversaryNoDup( Event *event ); bool addEventNoDup( Event *event ); bool addEvent( Event *event ); /** Deletes an event from this calendar. */ void deleteEvent( Event *event ); /** Retrieves an event on the basis of the unique string ID. */ Event *event( const QString &uid ); /** Return unfiltered list of all events in calendar. */ QPtrList<Event> rawEvents(); diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index b36dc1a..9aa517c 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp @@ -340,32 +340,35 @@ int IncidenceBase::pilotId() const { return mPilotId; } int IncidenceBase::tempSyncStat() const { return mTempSyncStat; } void IncidenceBase::setTempSyncStat( int id ) { if (mReadOnly) return; mTempSyncStat = id; } void IncidenceBase::removeID(const QString &prof) { + if ( prof.isEmpty() ) + mExternalId = ":"; + else mExternalId = KIdManager::removeId ( mExternalId, prof); } void IncidenceBase::setID( const QString & prof , const QString & id ) { mExternalId = KIdManager::setId ( mExternalId, prof, id ); } QString IncidenceBase::getID( const QString & prof) { return KIdManager::getId ( mExternalId, prof ); } // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 void IncidenceBase::setCsum( const QString & prof , const QString & id ) { diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 4390a06..feb184b 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -74,41 +74,46 @@ KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, Targ } KSyncManager::~KSyncManager() { delete bar; } void KSyncManager::fillSyncMenu() { if ( mSyncMenu->count() ) mSyncMenu->clear(); mSyncMenu->insertItem( i18n("Configure..."), 0 ); mSyncMenu->insertSeparator(); + QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); + mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); + clearMenu->insertItem( i18n("For all profiles"), 1 ); + clearMenu->insertSeparator(); + connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); + mSyncMenu->insertSeparator(); if ( mServerSocket == 0 ) { mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); } else { mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); } mSyncMenu->insertSeparator(); mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); mSyncMenu->insertSeparator(); - KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); config.setGroup("General"); QStringList prof = config.readListEntry("SyncProfileNames"); mLocalMachineName = config.readEntry("LocalMachineName","undefined"); if ( prof.count() < 2 ) { prof.clear(); QString externalName; #ifdef DESKTOP_VERSION #ifdef _WIN32_ externalName = "OutLook(not_implemented)"; #else externalName = "KDE_Desktop"; #endif #else externalName = "Sharp_DTM"; #endif @@ -120,51 +125,78 @@ void KSyncManager::fillSyncMenu() temp->writeConfig(&config); temp->setName( prof[1] ); temp->writeConfig(&config); temp->setName( prof[2] ); temp->writeConfig(&config); config.setGroup("General"); config.writeEntry("SyncProfileNames",prof); config.writeEntry("ExternSyncProfiles",externalName); config.sync(); delete temp; } mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); mSyncProfileNames = prof; unsigned int i; for ( i = 0; i < prof.count(); ++i ) { mSyncMenu->insertItem( prof[i], 1000+i ); + clearMenu->insertItem( prof[i], 1000+i ); if ( i == 2 ) mSyncMenu->insertSeparator(); } QDir app_dir; //US do not display SharpDTM if app is pwmpi, or no sharpfiles available if ( mTargetApp == PWMPI) { mSyncMenu->removeItem( 1000 ); + clearMenu->removeItem( 1000 ); } #ifndef DESKTOP_VERSION else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { mSyncMenu->removeItem( 1000 ); + clearMenu->removeItem( 1000 ); } #endif mSyncMenu->removeItem( 1002 ); + clearMenu->removeItem( 1002 ); +} +void KSyncManager::slotClearMenu( int action ) +{ + QString syncDevice; + if ( action > 999 ) { + syncDevice = mSyncProfileNames[action - 1000] ; } + + + int result = 0; + QString sd; + if ( syncDevice.isEmpty() ) + sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); + else + sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); + + result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, + 0, 1 ); + if ( result ) + return; + mImplementation->removeSyncInfo( syncDevice ); +} void KSyncManager::slotSyncMenu( int action ) { qDebug("syncaction %d ", action); + if ( action == 5000 ) + return; if ( action == 0 ) { // seems to be a Qt2 event handling bug // syncmenu.clear causes a segfault at first time // when we call it after the main event loop, it is ok // same behaviour when calling OM/Pi via QCOP for the first time QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); //confSync(); return; } if ( action == 1 ) { multiSync( true ); return; } if ( action == 2 ) { @@ -822,34 +854,40 @@ QString KSyncManager::getPassword( ) } void KSyncManager::confSync() { static KSyncPrefsDialog* sp = 0; if ( ! sp ) { sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); } sp->usrReadConfig(); #ifndef DESKTOP_VERSION sp->showMaximized(); #else sp->show(); #endif sp->exec(); + QStringList oldSyncProfileNames = mSyncProfileNames; mSyncProfileNames = sp->getSyncProfileNames(); mLocalMachineName = sp->getLocalMachineName (); + int ii; + for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { + if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) + mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); + } QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); } void KSyncManager::syncKDE() { emit save(); switch(mTargetApp) { case (KAPI): break; case (KOPI): { #ifdef DESKTOP_VERSION QString command = qApp->applicationDirPath () + "/kdecaldump"; #else QString command = "kdecaldump"; diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index af4f1ab..aa32e28 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h @@ -141,32 +141,33 @@ class KSyncManager : public QObject bool mWriteBackFile; int mWriteBackInFuture; QString mPhoneDevice; QString mPhoneConnection; QString mPhoneModel; QString mPassWordPiSync; QString mActiveSyncPort; QString mActiveSyncIP ; signals: void save(); void request_file(); void getFile( bool ); public slots: void slotSyncMenu( int ); + void slotClearMenu( int action ); void deleteCommandSocket(KCommandSocket*s, int state); void readFileFromSocket(); void fillSyncMenu(); private: void syncPi(); KServerSocket * mServerSocket; KPimPrefs* mPrefs; QString mDefFileName; QString mCurrentSyncDevice; QString mCurrentSyncName; void quickSyncLocalFile(); bool syncWithFile( QString fn , bool quick ); void syncLocalFile(); void syncPhone(); void syncSharp(); |