summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/pwmdoc.cpp
Side-by-side diff
Diffstat (limited to 'pwmanager/pwmanager/pwmdoc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp36
1 files changed, 24 insertions, 12 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
int changedLocal = 0;
int changedRemote = 0;
- PwMSyncItem* syncItemLocal;
- PwMSyncItem* syncItemRemote;
+ PwMSyncItem syncItemLocal;
+ PwMSyncItem syncItemRemote;
QString mCurrentSyncName = manager->getCurrentSyncName();
QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
@@ -2828,7 +2828,7 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
}
syncItemLocal = syncLocal->getSyncDataEntry(index);
- qDebug("Last Sync %s ", syncItemLocal->lastSyncDate.toString().latin1());
+ qDebug("Last Sync %s ", syncItemLocal.lastSyncDate.toString().latin1());
//Step 2. Find syncinfo in remote file and create if not existent.
found = syncRemote->findSyncData(mCurrentSyncName, &index);
@@ -2852,18 +2852,18 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
syncRemote->delSyncDataEntry(index, true);
- if ( syncItemLocal->lastSyncDate == mLastSync ) {
+ if ( syncItemLocal.lastSyncDate == mLastSync ) {
qDebug("FULLDATE 2");
fullDateRange = true;
}
if ( ! fullDateRange ) {
- if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) {
+ if ( syncItemLocal.lastSyncDate != syncItemRemote->lastSyncDate ) {
// qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
//qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
fullDateRange = true;
- qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() );
+ qDebug("FULLDATE 3 %s %s", syncItemLocal.lastSyncDate.toString().latin1() , syncItemRemote.lastSyncDate.toString().latin1() );
}
}
// fullDateRange = true; // debug only!
@@ -2920,9 +2920,12 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
} else { // no conflict
if ( inRemote->meta.update > mLastSync || mode == 5 ) {
inRemote->meta.update = modifiedSync;
+
+ //first check if we have a matching category in the local file
+ const string* remotecat = syncRemote->getCategory(catRemote);
//US syncRemote->insertAddressee( inRemote, false );
//US syncLocal->insertAddressee( inRemote, false );
- syncLocal->addEntry("newcategory", inRemote, true, false);
+ syncLocal->addEntry(remotecat->c_str(), inRemote, true, false);
++addedPasswordsLocal;
} else {
@@ -2953,6 +2956,8 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
+ PWM_ASSERT(inLocal);
+
if ( inRemote == 0 ) {
if ( inLocal->meta.update < mLastSync && mode != 4 ) {
// pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
@@ -2963,10 +2968,17 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
if ( ! manager->mWriteBackExistingOnly ) {
++addedPasswordsRemote;
inLocal->meta.update = modifiedSync;
+
+ //first check if we have a matching category in the remote file
+ const string* localcat = syncLocal->getCategory(catLocal);
+
//USsyncLocal->insertAddressee( inLocal, false );
- (*inRemote) = (*inLocal);
+ PwMDataItem newEntry;
+ newEntry = *inLocal;
+ inRemote = &newEntry;
+
//USsyncRemote->insertAddressee( inRemote, false );
- syncRemote->addEntry("newcategory", inRemote, true, false);
+ syncRemote->addEntry(localcat->c_str(), inRemote, true, false);
}
}
@@ -2985,8 +2997,8 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
- syncItemLocal->lastSyncDate = mLastSync;
- syncItemRemote->lastSyncDate = mLastSync;
+ syncItemLocal.lastSyncDate = mLastSync;
+ syncItemRemote.lastSyncDate = mLastSync;
// addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
// addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
@@ -3282,7 +3294,7 @@ QStringList PwMDoc::getIDEntryList()
entrEnd = catcounter->d.end();
entrI = entrBegin;
while (entrI != entrEnd) {
- results.append( (*entrI).meta.uniqueid );
+ results.append( (*entrI).meta.uniqueid.c_str() );
++entrI;
}
++catcounter;