summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-08 00:24:58 (UTC)
committer ulf69 <ulf69>2004-10-08 00:24:58 (UTC)
commit309df8e8df3a17602f948025b7951b21ec5c3fed (patch) (unidiff)
treef1b504be724510bd8d49b106cd1b98e09187c547
parent91e43b55a0ddf6a6f39f4ed3ae828ddad6ec89a5 (diff)
downloadkdepimpi-309df8e8df3a17602f948025b7951b21ec5c3fed.zip
kdepimpi-309df8e8df3a17602f948025b7951b21ec5c3fed.tar.gz
kdepimpi-309df8e8df3a17602f948025b7951b21ec5c3fed.tar.bz2
*** empty log message ***
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp36
-rw-r--r--pwmanager/pwmanager/pwmdoc.h38
-rw-r--r--pwmanager/pwmanager/serializer.cpp2
3 files changed, 58 insertions, 18 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
@@ -2796,14 +2796,14 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
2796 int addedPasswordsRemote = 0; 2796 int addedPasswordsRemote = 0;
2797 int deletedPasswordsRemote = 0; 2797 int deletedPasswordsRemote = 0;
2798 int deletedPasswordsLocal = 0; 2798 int deletedPasswordsLocal = 0;
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();
2807 2807
2808 bool fullDateRange = false; 2808 bool fullDateRange = false;
2809 int take; 2809 int take;
@@ -2825,13 +2825,13 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
2825 qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); 2825 qDebug("PwMDoc::syncronize : newly created local sync data could not be found");
2826 return e_syncError; 2826 return e_syncError;
2827 } 2827 }
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);
2835 if (found == false) 2835 if (found == false)
2836 { 2836 {
2837 qDebug("FULLDATE 1"); 2837 qDebug("FULLDATE 1");
@@ -2849,24 +2849,24 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
2849 2849
2850 syncItemRemote = syncRemote->getSyncDataEntry(index); 2850 syncItemRemote = syncRemote->getSyncDataEntry(index);
2851 //and remove the found entry here. We will reenter it later again. 2851 //and remove the found entry here. We will reenter it later again.
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!
2870 if ( fullDateRange ) 2870 if ( fullDateRange )
2871 mLastSync = QDateTime::currentDateTime().addDays( -100*365); 2871 mLastSync = QDateTime::currentDateTime().addDays( -100*365);
2872 else 2872 else
@@ -2917,15 +2917,18 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
2917 ++changedLocal; 2917 ++changedLocal;
2918 } 2918 }
2919 } 2919 }
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 {
2929 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2932 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2930 syncRemote->delEntry(catRemote, indexRemote, true); 2933 syncRemote->delEntry(catRemote, indexRemote, true);
2931 //USsyncRemote->removeAddressee( inRemote ); 2934 //USsyncRemote->removeAddressee( inRemote );
@@ -2950,26 +2953,35 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
2950 if ( incCounter % modulo == 0 ) 2953 if ( incCounter % modulo == 0 )
2951 manager->showProgressBar(incCounter); 2954 manager->showProgressBar(incCounter);
2952 uid = el[ incCounter ]; 2955 uid = el[ incCounter ];
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);
2959 syncLocal->delEntry(catLocal, indexLocal, true); 2964 syncLocal->delEntry(catLocal, indexLocal, true);
2960 //USsyncLocal->removeAddressee( inLocal ); 2965 //USsyncLocal->removeAddressee( inLocal );
2961 ++deletedPasswordsLocal; 2966 ++deletedPasswordsLocal;
2962 } else { 2967 } else {
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 }
2973 2985
2974 } 2986 }
2975 ++incCounter; 2987 ++incCounter;
@@ -2982,14 +2994,14 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
2982 mLastSync = QDateTime::currentDateTime().addSecs( 1 ); 2994 mLastSync = QDateTime::currentDateTime().addSecs( 1 );
2983 // get rid of micro seconds 2995 // get rid of micro seconds
2984 QTime t = mLastSync.time(); 2996 QTime t = mLastSync.time();
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 );
2993 3005
2994 syncRemote->addSyncDataEntry( syncItemRemote, false ); 3006 syncRemote->addSyncDataEntry( syncItemRemote, false );
2995 syncLocal->addSyncDataEntry( syncItemLocal, false ); 3007 syncLocal->addSyncDataEntry( syncItemLocal, false );
@@ -3279,13 +3291,13 @@ QStringList PwMDoc::getIDEntryList()
3279 3291
3280 while (catcounter != catend) { 3292 while (catcounter != catend) {
3281 entrBegin = catcounter->d.begin(); 3293 entrBegin = catcounter->d.begin();
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;
3289 } 3301 }
3290 3302
3291 return results; 3303 return results;
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
@@ -113,25 +113,36 @@ struct PwMMetaData
113 /** update interval (in minutes). Time since the 113 /** update interval (in minutes). Time since the
114 * last update to remind the user to update the item. 114 * last update to remind the user to update the item.
115 * 0 disables. 115 * 0 disables.
116 */ 116 */
117 unsigned long updateInt; 117 unsigned long updateInt;
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()
125 { 125 {
126 create = QDateTime(); 126 create = QDateTime();
127 expire = QDateTime(); 127 expire = QDateTime();
128 update = QDateTime(); 128 update = QDateTime();
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())
135 return true; 146 return true;
136 return (valid < QDateTime::currentDateTime()); 147 return (valid < QDateTime::currentDateTime());
137 } 148 }
@@ -203,12 +214,29 @@ struct PwMDataItem
203 lockStat = true; 214 lockStat = true;
204 listViewPos = -1; 215 listViewPos = -1;
205 binary = false; 216 binary = false;
206 if (clearMeta) 217 if (clearMeta)
207 meta.clear(); 218 meta.clear();
208 } 219 }
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 }
209 237
210}; 238};
211 239
212struct PwMCategoryItem 240struct PwMCategoryItem
213{ 241{
214 /** all PwMDataItems (all passwords) within this category */ 242 /** all PwMDataItems (all passwords) within this category */
@@ -760,14 +788,14 @@ protected:
760 bool findSyncData(const QString &syncname, unsigned int *index); 788 bool findSyncData(const QString &syncname, unsigned int *index);
761 789
762 /** add new syncdataentry */ 790 /** add new syncdataentry */
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);
771 799
772 PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index); 800 PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index);
773 801
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
@@ -643,13 +643,13 @@ bool Serializer::writeMeta(QDomElement *e,
643 tag = domDoc->createElement(META_UPDATE_INT); 643 tag = domDoc->createElement(META_UPDATE_INT);
644 text = domDoc->createTextNode(tostr(dta.updateInt).c_str()); 644 text = domDoc->createTextNode(tostr(dta.updateInt).c_str());
645 tag.appendChild(text); 645 tag.appendChild(text);
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
653#undef new_text 653#undef new_text
654 return true; 654 return true;
655} 655}