author | ulf69 <ulf69> | 2004-10-29 01:27:31 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-29 01:27:31 (UTC) |
commit | f8dd437160acec2959c462dd43d87f2a0920c0b9 (patch) (unidiff) | |
tree | ddd271930f54adc1b7220d534f682f616efeb20a | |
parent | 1b8d173d880e8f681bca88220bdd806a95d3c2a0 (diff) | |
download | kdepimpi-f8dd437160acec2959c462dd43d87f2a0920c0b9.zip kdepimpi-f8dd437160acec2959c462dd43d87f2a0920c0b9.tar.gz kdepimpi-f8dd437160acec2959c462dd43d87f2a0920c0b9.tar.bz2 |
enabling/disabling syncing of launcher
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 10 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.h | 20 |
2 files changed, 24 insertions, 6 deletions
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index fd17ce5..9043acc 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -3007,32 +3007,34 @@ out_ignore: | |||
3007 | //US it could have been defined as static, but I did not want to. | 3007 | //US it could have been defined as static, but I did not want to. |
3008 | PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) | 3008 | PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) |
3009 | { | 3009 | { |
3010 | int addedPasswordsLocal = 0; | 3010 | int addedPasswordsLocal = 0; |
3011 | int addedPasswordsRemote = 0; | 3011 | int addedPasswordsRemote = 0; |
3012 | int deletedPasswordsRemote = 0; | 3012 | int deletedPasswordsRemote = 0; |
3013 | int deletedPasswordsLocal = 0; | 3013 | int deletedPasswordsLocal = 0; |
3014 | int changedLocal = 0; | 3014 | int changedLocal = 0; |
3015 | int changedRemote = 0; | 3015 | int changedRemote = 0; |
3016 | 3016 | ||
3017 | PwMSyncItem* syncItemLocal; | 3017 | PwMSyncItem* syncItemLocal; |
3018 | PwMSyncItem* syncItemRemote; | 3018 | PwMSyncItem* syncItemRemote; |
3019 | 3019 | ||
3020 | QString mCurrentSyncName = manager->getCurrentSyncName(); | 3020 | QString mCurrentSyncName = manager->getCurrentSyncName(); |
3021 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3021 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3022 | 3022 | ||
3023 | bool mSyncLauncher = true; | ||
3024 | |||
3023 | bool fullDateRange = false; | 3025 | bool fullDateRange = false; |
3024 | int take; | 3026 | int take; |
3025 | // local->resetTempSyncStat(); | 3027 | // local->resetTempSyncStat(); |
3026 | QDateTime mLastSync = QDateTime::currentDateTime(); | 3028 | QDateTime mLastSync = QDateTime::currentDateTime(); |
3027 | QDateTime modifiedSync = mLastSync; | 3029 | QDateTime modifiedSync = mLastSync; |
3028 | 3030 | ||
3029 | unsigned int index; | 3031 | unsigned int index; |
3030 | //Step 1. Find syncinfo in Local file and create if not existent. | 3032 | //Step 1. Find syncinfo in Local file and create if not existent. |
3031 | bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); | 3033 | bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); |
3032 | if (found == false) | 3034 | if (found == false) |
3033 | { | 3035 | { |
3034 | PwMSyncItem newSyncItemLocal; | 3036 | PwMSyncItem newSyncItemLocal; |
3035 | newSyncItemLocal.syncName = mCurrentSyncDevice.latin1(); | 3037 | newSyncItemLocal.syncName = mCurrentSyncDevice.latin1(); |
3036 | newSyncItemLocal.lastSyncDate = mLastSync; | 3038 | newSyncItemLocal.lastSyncDate = mLastSync; |
3037 | syncLocal->addSyncDataEntry(&newSyncItemLocal, true); | 3039 | syncLocal->addSyncDataEntry(&newSyncItemLocal, true); |
3038 | found = syncLocal->findSyncData(mCurrentSyncDevice, &index); | 3040 | found = syncLocal->findSyncData(mCurrentSyncDevice, &index); |
@@ -3107,40 +3109,36 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
3107 | manager->showProgressBar(incCounter); | 3109 | manager->showProgressBar(incCounter); |
3108 | 3110 | ||
3109 | uid = er[ incCounter ]; | 3111 | uid = er[ incCounter ]; |
3110 | qDebug("sync uid %s from remote file", uid.latin1()); | 3112 | qDebug("sync uid %s from remote file", uid.latin1()); |
3111 | 3113 | ||
3112 | qApp->processEvents(); | 3114 | qApp->processEvents(); |
3113 | 3115 | ||
3114 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); | 3116 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); |
3115 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); | 3117 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); |
3116 | PWM_ASSERT(inRemote); | 3118 | PWM_ASSERT(inRemote); |
3117 | if ( inLocal != 0 ) { // maybe conflict - same uid in both files | 3119 | if ( inLocal != 0 ) { // maybe conflict - same uid in both files |
3118 | if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { | 3120 | if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { |
3119 | qDebug("take %d %s ", take, inLocal->desc.c_str()); | 3121 | qDebug("take %d %s ", take, inLocal->desc.c_str()); |
3120 | if ( take == 3 ) | 3122 | if ( take == 3 ) |
3121 | return e_syncError; | 3123 | return e_syncError; |
3122 | if ( take == 1 ) {// take local | 3124 | if ( take == 1 ) {// take local |
3123 | int oldlistpos = inRemote->listViewPos; | 3125 | inRemote->syncItem(*inLocal, mSyncLauncher); |
3124 | (*inRemote) = (*inLocal); | ||
3125 | inRemote->listViewPos = oldlistpos; | ||
3126 | ++changedRemote; | 3126 | ++changedRemote; |
3127 | } else { // take == 2 take remote | 3127 | } else { // take == 2 take remote |
3128 | int oldlistpos = inLocal->listViewPos; | 3128 | inLocal->syncItem(*inRemote, mSyncLauncher); |
3129 | (*inLocal) = (*inRemote); | ||
3130 | inLocal->listViewPos = oldlistpos; | ||
3131 | ++changedLocal; | 3129 | ++changedLocal; |
3132 | } | 3130 | } |
3133 | } | 3131 | } |
3134 | } else { // no conflict | 3132 | } else { // no conflict |
3135 | if ( inRemote->meta.update > mLastSync || mode == 5 ) { | 3133 | if ( inRemote->meta.update > mLastSync || mode == 5 ) { |
3136 | inRemote->meta.update = modifiedSync; | 3134 | inRemote->meta.update = modifiedSync; |
3137 | 3135 | ||
3138 | //first check if we have a matching category in the local file | 3136 | //first check if we have a matching category in the local file |
3139 | const string* remotecat = syncRemote->getCategory(catRemote); | 3137 | const string* remotecat = syncRemote->getCategory(catRemote); |
3140 | syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); | 3138 | syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); |
3141 | 3139 | ||
3142 | ++addedPasswordsLocal; | 3140 | ++addedPasswordsLocal; |
3143 | } else { | 3141 | } else { |
3144 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 3142 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
3145 | syncRemote->delEntry(catRemote, indexRemote, true); | 3143 | syncRemote->delEntry(catRemote, indexRemote, true); |
3146 | ++deletedPasswordsRemote; | 3144 | ++deletedPasswordsRemote; |
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h index e419c24..09923ab 100644 --- a/pwmanager/pwmanager/pwmdoc.h +++ b/pwmanager/pwmanager/pwmdoc.h | |||
@@ -211,32 +211,52 @@ struct PwMDataItem | |||
211 | } | 211 | } |
212 | //US ENH: we need this operator to compare two items if we have no unique ids | 212 | //US ENH: we need this operator to compare two items if we have no unique ids |
213 | //available. Generaly this happens before the first sync | 213 | //available. Generaly this happens before the first sync |
214 | 214 | ||
215 | bool PwMDataItem::operator==( const PwMDataItem &a ) const | 215 | bool PwMDataItem::operator==( const PwMDataItem &a ) const |
216 | { | 216 | { |
217 | //qDebug("oper==%s", a.desc.c_str()); | 217 | //qDebug("oper==%s", a.desc.c_str()); |
218 | if ( desc != a.desc ) return false; | 218 | if ( desc != a.desc ) return false; |
219 | if ( name != a.name ) return false; | 219 | if ( name != a.name ) return false; |
220 | if ( pw != a.pw ) return false; | 220 | if ( pw != a.pw ) return false; |
221 | if ( comment != a.comment ) return false; | 221 | if ( comment != a.comment ) return false; |
222 | if ( url != a.url ) return false; | 222 | if ( url != a.url ) return false; |
223 | if ( launcher != a.launcher ) return false; | 223 | if ( launcher != a.launcher ) return false; |
224 | //all other field will not be checked. | 224 | //all other field will not be checked. |
225 | return true; | 225 | return true; |
226 | } | 226 | } |
227 | |||
228 | //US ENH: this sync method actually copies all values from the parameter like the =operator | ||
229 | //does with two exceptions: listViewPos will not be changed, and the launcher only if required. | ||
230 | bool PwMDataItem::syncItem(const PwMDataItem &a, bool syncLauncher=true ) | ||
231 | { | ||
232 | desc = a.desc; | ||
233 | name = a.name; | ||
234 | pw = a.pw; | ||
235 | comment = a.comment; | ||
236 | url = a.url; | ||
237 | if (syncLauncher == true) | ||
238 | launcher = a.launcher; | ||
239 | meta = a.meta; | ||
240 | binary = a.binary; | ||
241 | lockStat = a.lockStat; | ||
242 | rev = a.rev; | ||
243 | |||
244 | return true; | ||
245 | } | ||
246 | |||
227 | }; | 247 | }; |
228 | 248 | ||
229 | struct PwMCategoryItem | 249 | struct PwMCategoryItem |
230 | { | 250 | { |
231 | /** all PwMDataItems (all passwords) within this category */ | 251 | /** all PwMDataItems (all passwords) within this category */ |
232 | vector<PwMDataItem>d; | 252 | vector<PwMDataItem>d; |
233 | /** category name/description */ | 253 | /** category name/description */ |
234 | string name; | 254 | string name; |
235 | 255 | ||
236 | void clear() | 256 | void clear() |
237 | { | 257 | { |
238 | d.clear(); | 258 | d.clear(); |
239 | name = ""; | 259 | name = ""; |
240 | } | 260 | } |
241 | }; | 261 | }; |
242 | 262 | ||