summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-29 17:31:58 (UTC)
committer ulf69 <ulf69>2004-10-29 17:31:58 (UTC)
commitb55890913f4c81bd2fc3719cf7c97e8ab1f47077 (patch) (unidiff)
tree95da19ca855001977e046ddd761d8b9f6cfd66c9
parenta507e84cbf0afb76570ca1d82bee24bc68faa513 (diff)
downloadkdepimpi-b55890913f4c81bd2fc3719cf7c97e8ab1f47077.zip
kdepimpi-b55890913f4c81bd2fc3719cf7c97e8ab1f47077.tar.gz
kdepimpi-b55890913f4c81bd2fc3719cf7c97e8ab1f47077.tar.bz2
implemented removeSyncProfile
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp22
-rw-r--r--pwmanager/pwmanager/pwmdoc.h4
2 files changed, 25 insertions, 1 deletions
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index ddbf4f2..17cb74a 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -3264,97 +3264,117 @@ int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime
3264 return 1; 3264 return 1;
3265 if ( lastSync > localMod ) 3265 if ( lastSync > localMod )
3266 return 2; 3266 return 2;
3267 return 1; 3267 return 1;
3268 break; 3268 break;
3269 case SYNC_PREF_REMOTE: 3269 case SYNC_PREF_REMOTE:
3270 if ( lastSync > remoteMod ) 3270 if ( lastSync > remoteMod )
3271 return 1; 3271 return 1;
3272 if ( lastSync > localMod ) 3272 if ( lastSync > localMod )
3273 return 2; 3273 return 2;
3274 return 2; 3274 return 2;
3275 break; 3275 break;
3276 case SYNC_PREF_NEWEST: 3276 case SYNC_PREF_NEWEST:
3277 if ( localMod > remoteMod ) 3277 if ( localMod > remoteMod )
3278 return 1; 3278 return 1;
3279 else 3279 else
3280 return 2; 3280 return 2;
3281 break; 3281 break;
3282 case SYNC_PREF_ASK: 3282 case SYNC_PREF_ASK:
3283 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 3283 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
3284 if ( lastSync > remoteMod ) 3284 if ( lastSync > remoteMod )
3285 return 1; 3285 return 1;
3286 if ( lastSync > localMod ) 3286 if ( lastSync > localMod )
3287 return 2; 3287 return 2;
3288 localIsNew = localMod >= remoteMod; 3288 localIsNew = localMod >= remoteMod;
3289 //qDebug("conflict! ************************************** "); 3289 //qDebug("conflict! ************************************** ");
3290 { 3290 {
3291 PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); 3291 PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ );
3292 result = acd.executeD(localIsNew); 3292 result = acd.executeD(localIsNew);
3293 return result; 3293 return result;
3294 } 3294 }
3295 break; 3295 break;
3296 case SYNC_PREF_FORCE_LOCAL: 3296 case SYNC_PREF_FORCE_LOCAL:
3297 return 1; 3297 return 1;
3298 break; 3298 break;
3299 case SYNC_PREF_FORCE_REMOTE: 3299 case SYNC_PREF_FORCE_REMOTE:
3300 return 2; 3300 return 2;
3301 break; 3301 break;
3302 3302
3303 default: 3303 default:
3304 // SYNC_PREF_TAKE_BOTH not implemented 3304 // SYNC_PREF_TAKE_BOTH not implemented
3305 break; 3305 break;
3306 } 3306 }
3307 return 0; 3307 return 0;
3308} 3308}
3309 3309
3310void PwMDoc::removeSyncInfo( QString syncProfile) 3310void PwMDoc::removeSyncInfo( QString syncProfile)
3311{ 3311{
3312 qDebug("PwMDoc::not implemented: removeSyncInfo for profile %s ", syncProfile.latin1()); 3312 bool res, found;
3313 unsigned int count, i;
3314 if ( syncProfile.isEmpty() ) {
3315 count = numSyncDataEntries();
3316 for (i = count; count > 0; count-- ) {
3317 res = delSyncDataEntry(i-1, false);
3318 if (res == false) {
3319 qDebug("PwMDoc::removeSyncInfo: could not remove syncprofile");
3320 }
3321 }
3322 } else {
3323 found = findSyncData(syncProfile, &count);
3324 if (found == true)
3325 {
3326 res = delSyncDataEntry(count, false);
3327 if (res == false) {
3328 qDebug("PwMDoc::removeSyncInfo: could not remove %s", syncProfile.latin1());
3329
3330 }
3331 }
3332 }
3313} 3333}
3314 3334
3315 3335
3316//this are the overwritten callbackmethods from the syncinterface 3336//this are the overwritten callbackmethods from the syncinterface
3317bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) 3337bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
3318{ 3338{
3319 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3339 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3320 3340
3321 //1) unlock local file first if necessary (ask for password) 3341 //1) unlock local file first if necessary (ask for password)
3322 if (this->isDeepLocked()) { 3342 if (this->isDeepLocked()) {
3323 PwMerror ret = this->deepLock(false); 3343 PwMerror ret = this->deepLock(false);
3324 if (ret != e_success) 3344 if (ret != e_success)
3325 return false; 3345 return false;
3326 } 3346 }
3327 3347
3328 //2) construct and open a new doc on the stack(automatic cleanup of remote file). 3348 //2) construct and open a new doc on the stack(automatic cleanup of remote file).
3329 PwMDoc syncTarget(this, "synctarget"); 3349 PwMDoc syncTarget(this, "synctarget");
3330 PwMDoc* pSyncTarget = &syncTarget; 3350 PwMDoc* pSyncTarget = &syncTarget;
3331 3351
3332 3352
3333 PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); 3353 PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/);
3334 3354
3335 if (err == e_alreadyOpen) { 3355 if (err == e_alreadyOpen) {
3336 PwMDocList::listItem li; 3356 PwMDocList::listItem li;
3337 if (getOpenDocList()->find(filename.latin1(), &li)) 3357 if (getOpenDocList()->find(filename.latin1(), &li))
3338 pSyncTarget = li.doc; 3358 pSyncTarget = li.doc;
3339 else { 3359 else {
3340 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); 3360 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1());
3341 return false; 3361 return false;
3342 } 3362 }
3343 } 3363 }
3344 else if (err != e_success) { 3364 else if (err != e_success) {
3345 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); 3365 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1());
3346 return false; 3366 return false;
3347 } 3367 }
3348 3368
3349 qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); 3369 qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode );
3350 3370
3351 3371
3352 //3) unlock remote file first if necessary (ask for password) 3372 //3) unlock remote file first if necessary (ask for password)
3353 if (pSyncTarget->isDeepLocked()) { 3373 if (pSyncTarget->isDeepLocked()) {
3354 PwMerror ret = pSyncTarget->deepLock(false); 3374 PwMerror ret = pSyncTarget->deepLock(false);
3355 if (ret != e_success) 3375 if (ret != e_success)
3356 return false; 3376 return false;
3357 } 3377 }
3358 3378
3359 3379
3360 err = syncronize(manager, this, pSyncTarget, mode ); 3380 err = syncronize(manager, this, pSyncTarget, mode );
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index ef81dfc..138dd3d 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -769,55 +769,59 @@ protected:
769 void setCurrentPw(const QString &pw) 769 void setCurrentPw(const QString &pw)
770 { 770 {
771 currentPw = pw; 771 currentPw = pw;
772 setDocStatFlag(DOC_STAT_DISK_DIRTY); 772 setDocStatFlag(DOC_STAT_DISK_DIRTY);
773 } 773 }
774 /** make a backup-copy of the given file */ 774 /** make a backup-copy of the given file */
775 bool backupFile(const QString &filePath); 775 bool backupFile(const QString &filePath);
776 /** copy a file from src to dst */ 776 /** copy a file from src to dst */
777 bool copyFile(const QString &src, const QString &dst); 777 bool copyFile(const QString &src, const QString &dst);
778 778
779 779
780 public: 780 public:
781#ifdef PWM_EMBEDDED 781#ifdef PWM_EMBEDDED
782 //US ENH: this is the magic function that syncronizes the local doc with the remote doc. 782 //US ENH: this is the magic function that syncronizes the local doc with the remote doc.
783 PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode ); 783 PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode );
784 784
785 //takePwMDataItem returns the following values 785 //takePwMDataItem returns the following values
786 // 0 equal 786 // 0 equal
787 // 1 take local 787 // 1 take local
788 // 2 take remote 788 // 2 take remote
789 // 3 cancel 789 // 3 cancel
790 int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ); 790 int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full );
791 791
792 //the following methods are the overwritten callbackmethods from the syncinterface 792 //the following methods are the overwritten callbackmethods from the syncinterface
793 virtual bool sync(KSyncManager* manager, QString filename, int mode); 793 virtual bool sync(KSyncManager* manager, QString filename, int mode);
794 virtual void removeSyncInfo( QString syncProfile); 794 virtual void removeSyncInfo( QString syncProfile);
795 795
796#endif 796#endif
797 //US ENH: helpermethods to return a whole category entry 797 //US ENH: helpermethods to return a whole category entry
798 /** returns a pointer to the categoryitem */ 798 /** returns a pointer to the categoryitem */
799 PwMCategoryItem* getCategoryEntry(unsigned int index) 799 PwMCategoryItem* getCategoryEntry(unsigned int index)
800 { return &(dti.dta[index]); } 800 { return &(dti.dta[index]); }
801 801
802 private: 802 private:
803 //US ENH: helpermethods to access the sync data for a certain syncname. 803 //US ENH: helpermethods to access the sync data for a certain syncname.
804 // It returns the syncdatas index 804 // It returns the syncdatas index
805 bool findSyncData(const QString &syncname, unsigned int *index); 805 bool findSyncData(const QString &syncname, unsigned int *index);
806 806
807 /** add new syncdataentry */ 807 /** add new syncdataentry */
808 PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false); 808 PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false);
809 809
810 /** returns a pointer to the syncdata */ 810 /** returns a pointer to the syncdata */
811 PwMSyncItem* getSyncDataEntry(unsigned int index) 811 PwMSyncItem* getSyncDataEntry(unsigned int index)
812 { return &(dti.syncDta[index]); } 812 { return &(dti.syncDta[index]); }
813 813
814 /** delete entry */ 814 /** delete entry */
815 bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false); 815 bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false);
816 816
817 /** returns number of categories */
818 unsigned int numSyncDataEntries()
819 { return dti.syncDta.size(); }
820
817 PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index); 821 PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index);
818 822
819 QStringList getIDEntryList(); 823 QStringList getIDEntryList();
820 824
821}; 825};
822 826
823#endif 827#endif