author | ulf69 <ulf69> | 2004-10-08 00:24:58 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-08 00:24:58 (UTC) |
commit | 309df8e8df3a17602f948025b7951b21ec5c3fed (patch) (unidiff) | |
tree | f1b504be724510bd8d49b106cd1b98e09187c547 | |
parent | 91e43b55a0ddf6a6f39f4ed3ae828ddad6ec89a5 (diff) | |
download | kdepimpi-309df8e8df3a17602f948025b7951b21ec5c3fed.zip kdepimpi-309df8e8df3a17602f948025b7951b21ec5c3fed.tar.gz kdepimpi-309df8e8df3a17602f948025b7951b21ec5c3fed.tar.bz2 |
*** empty log message ***
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 36 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.h | 34 | ||||
-rw-r--r-- | pwmanager/pwmanager/serializer.cpp | 2 |
3 files changed, 56 insertions, 16 deletions
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index 76a45f4..ab3238a 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -2799,8 +2799,8 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
2799 | int changedLocal = 0; | 2799 | int changedLocal = 0; |
2800 | int changedRemote = 0; | 2800 | int changedRemote = 0; |
2801 | 2801 | ||
2802 | PwMSyncItem* syncItemLocal; | 2802 | PwMSyncItem syncItemLocal; |
2803 | PwMSyncItem* syncItemRemote; | 2803 | PwMSyncItem syncItemRemote; |
2804 | 2804 | ||
2805 | QString mCurrentSyncName = manager->getCurrentSyncName(); | 2805 | QString mCurrentSyncName = manager->getCurrentSyncName(); |
2806 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2806 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
@@ -2828,7 +2828,7 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
2828 | } | 2828 | } |
2829 | 2829 | ||
2830 | syncItemLocal = syncLocal->getSyncDataEntry(index); | 2830 | syncItemLocal = syncLocal->getSyncDataEntry(index); |
2831 | qDebug("Last Sync %s ", syncItemLocal->lastSyncDate.toString().latin1()); | 2831 | qDebug("Last Sync %s ", syncItemLocal.lastSyncDate.toString().latin1()); |
2832 | 2832 | ||
2833 | //Step 2. Find syncinfo in remote file and create if not existent. | 2833 | //Step 2. Find syncinfo in remote file and create if not existent. |
2834 | found = syncRemote->findSyncData(mCurrentSyncName, &index); | 2834 | found = syncRemote->findSyncData(mCurrentSyncName, &index); |
@@ -2852,18 +2852,18 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
2852 | syncRemote->delSyncDataEntry(index, true); | 2852 | syncRemote->delSyncDataEntry(index, true); |
2853 | 2853 | ||
2854 | 2854 | ||
2855 | if ( syncItemLocal->lastSyncDate == mLastSync ) { | 2855 | if ( syncItemLocal.lastSyncDate == mLastSync ) { |
2856 | qDebug("FULLDATE 2"); | 2856 | qDebug("FULLDATE 2"); |
2857 | fullDateRange = true; | 2857 | fullDateRange = true; |
2858 | } | 2858 | } |
2859 | 2859 | ||
2860 | if ( ! fullDateRange ) { | 2860 | if ( ! fullDateRange ) { |
2861 | if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { | 2861 | if ( syncItemLocal.lastSyncDate != syncItemRemote->lastSyncDate ) { |
2862 | 2862 | ||
2863 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2863 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2864 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2864 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2865 | fullDateRange = true; | 2865 | fullDateRange = true; |
2866 | qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); | 2866 | qDebug("FULLDATE 3 %s %s", syncItemLocal.lastSyncDate.toString().latin1() , syncItemRemote.lastSyncDate.toString().latin1() ); |
2867 | } | 2867 | } |
2868 | } | 2868 | } |
2869 | // fullDateRange = true; // debug only! | 2869 | // fullDateRange = true; // debug only! |
@@ -2920,9 +2920,12 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
2920 | } else { // no conflict | 2920 | } else { // no conflict |
2921 | if ( inRemote->meta.update > mLastSync || mode == 5 ) { | 2921 | if ( inRemote->meta.update > mLastSync || mode == 5 ) { |
2922 | inRemote->meta.update = modifiedSync; | 2922 | inRemote->meta.update = modifiedSync; |
2923 | |||
2924 | //first check if we have a matching category in the local file | ||
2925 | const string* remotecat = syncRemote->getCategory(catRemote); | ||
2923 | //US syncRemote->insertAddressee( inRemote, false ); | 2926 | //US syncRemote->insertAddressee( inRemote, false ); |
2924 | //US syncLocal->insertAddressee( inRemote, false ); | 2927 | //US syncLocal->insertAddressee( inRemote, false ); |
2925 | syncLocal->addEntry("newcategory", inRemote, true, false); | 2928 | syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); |
2926 | 2929 | ||
2927 | ++addedPasswordsLocal; | 2930 | ++addedPasswordsLocal; |
2928 | } else { | 2931 | } else { |
@@ -2953,6 +2956,8 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
2953 | 2956 | ||
2954 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); | 2957 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); |
2955 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); | 2958 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); |
2959 | PWM_ASSERT(inLocal); | ||
2960 | |||
2956 | if ( inRemote == 0 ) { | 2961 | if ( inRemote == 0 ) { |
2957 | if ( inLocal->meta.update < mLastSync && mode != 4 ) { | 2962 | if ( inLocal->meta.update < mLastSync && mode != 4 ) { |
2958 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2963 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
@@ -2963,10 +2968,17 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
2963 | if ( ! manager->mWriteBackExistingOnly ) { | 2968 | if ( ! manager->mWriteBackExistingOnly ) { |
2964 | ++addedPasswordsRemote; | 2969 | ++addedPasswordsRemote; |
2965 | inLocal->meta.update = modifiedSync; | 2970 | inLocal->meta.update = modifiedSync; |
2971 | |||
2972 | //first check if we have a matching category in the remote file | ||
2973 | const string* localcat = syncLocal->getCategory(catLocal); | ||
2974 | |||
2966 | //USsyncLocal->insertAddressee( inLocal, false ); | 2975 | //USsyncLocal->insertAddressee( inLocal, false ); |
2967 | (*inRemote) = (*inLocal); | 2976 | PwMDataItem newEntry; |
2977 | newEntry = *inLocal; | ||
2978 | inRemote = &newEntry; | ||
2979 | |||
2968 | //USsyncRemote->insertAddressee( inRemote, false ); | 2980 | //USsyncRemote->insertAddressee( inRemote, false ); |
2969 | syncRemote->addEntry("newcategory", inRemote, true, false); | 2981 | syncRemote->addEntry(localcat->c_str(), inRemote, true, false); |
2970 | 2982 | ||
2971 | } | 2983 | } |
2972 | } | 2984 | } |
@@ -2985,8 +2997,8 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
2985 | mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2997 | mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2986 | 2998 | ||
2987 | 2999 | ||
2988 | syncItemLocal->lastSyncDate = mLastSync; | 3000 | syncItemLocal.lastSyncDate = mLastSync; |
2989 | syncItemRemote->lastSyncDate = mLastSync; | 3001 | syncItemRemote.lastSyncDate = mLastSync; |
2990 | 3002 | ||
2991 | // addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3003 | // addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2992 | // addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3004 | // addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
@@ -3282,7 +3294,7 @@ QStringList PwMDoc::getIDEntryList() | |||
3282 | entrEnd = catcounter->d.end(); | 3294 | entrEnd = catcounter->d.end(); |
3283 | entrI = entrBegin; | 3295 | entrI = entrBegin; |
3284 | while (entrI != entrEnd) { | 3296 | while (entrI != entrEnd) { |
3285 | results.append( (*entrI).meta.uniqueid ); | 3297 | results.append( (*entrI).meta.uniqueid.c_str() ); |
3286 | ++entrI; | 3298 | ++entrI; |
3287 | } | 3299 | } |
3288 | ++catcounter; | 3300 | ++catcounter; |
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h index 91277f6..ddab7f3 100644 --- a/pwmanager/pwmanager/pwmdoc.h +++ b/pwmanager/pwmanager/pwmdoc.h | |||
@@ -118,7 +118,7 @@ struct PwMMetaData | |||
118 | 118 | ||
119 | //US ENH: enhancements of the filestructure | 119 | //US ENH: enhancements of the filestructure |
120 | /* each entry gets a unique id assigned */ | 120 | /* each entry gets a unique id assigned */ |
121 | QString uniqueid; | 121 | string uniqueid; |
122 | 122 | ||
123 | 123 | ||
124 | void clear() | 124 | void clear() |
@@ -129,6 +129,17 @@ struct PwMMetaData | |||
129 | updateInt = 0; | 129 | updateInt = 0; |
130 | uniqueid = KApplication::randomString(8); | 130 | uniqueid = KApplication::randomString(8); |
131 | } | 131 | } |
132 | |||
133 | PwMMetaData& operator = (const PwMMetaData& x) | ||
134 | { | ||
135 | create = x.create; | ||
136 | expire = x.expire; | ||
137 | update = x.update; | ||
138 | updateInt = x.updateInt; | ||
139 | uniqueid = x.uniqueid; | ||
140 | return *this; | ||
141 | } | ||
142 | |||
132 | inline bool isValid() const | 143 | inline bool isValid() const |
133 | { | 144 | { |
134 | if (valid.isNull()) | 145 | if (valid.isNull()) |
@@ -207,6 +218,23 @@ struct PwMDataItem | |||
207 | meta.clear(); | 218 | meta.clear(); |
208 | } | 219 | } |
209 | 220 | ||
221 | PwMDataItem& operator = (const PwMDataItem& x) | ||
222 | { | ||
223 | qDebug("oper=%s", x.desc.c_str()); | ||
224 | desc = x.desc; | ||
225 | name = x.name; | ||
226 | pw = x.pw; | ||
227 | comment = x.comment; | ||
228 | url = x.url; | ||
229 | launcher = x.launcher; | ||
230 | lockStat = x.lockStat; | ||
231 | listViewPos = x.listViewPos; | ||
232 | binary = x.binary; | ||
233 | meta = x.meta; | ||
234 | rev = x.rev; | ||
235 | return *this; | ||
236 | } | ||
237 | |||
210 | }; | 238 | }; |
211 | 239 | ||
212 | struct PwMCategoryItem | 240 | struct PwMCategoryItem |
@@ -763,8 +791,8 @@ protected: | |||
763 | PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false); | 791 | PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false); |
764 | 792 | ||
765 | /** returns a pointer to the syncdata */ | 793 | /** returns a pointer to the syncdata */ |
766 | PwMSyncItem* getSyncDataEntry(unsigned int index) | 794 | PwMSyncItem getSyncDataEntry(unsigned int index) |
767 | { return &(dti.syncDta[index]); } | 795 | { return *(dti.syncDta[index]); } |
768 | 796 | ||
769 | /** delete entry */ | 797 | /** delete entry */ |
770 | bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false); | 798 | bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false); |
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp index f615082..74b3354 100644 --- a/pwmanager/pwmanager/serializer.cpp +++ b/pwmanager/pwmanager/serializer.cpp | |||
@@ -646,7 +646,7 @@ bool Serializer::writeMeta(QDomElement *e, | |||
646 | e->appendChild(tag); | 646 | e->appendChild(tag); |
647 | 647 | ||
648 | tag = domDoc->createElement(META_UNIQUEID); | 648 | tag = domDoc->createElement(META_UNIQUEID); |
649 | text = domDoc->createTextNode(escapeEntryData(dta.uniqueid)); | 649 | text = domDoc->createTextNode(escapeEntryData(dta.uniqueid.c_str())); |
650 | tag.appendChild(text); | 650 | tag.appendChild(text); |
651 | e->appendChild(tag); | 651 | e->appendChild(tag); |
652 | 652 | ||