author | ulf69 <ulf69> | 2004-10-06 06:18:43 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-06 06:18:43 (UTC) |
commit | 8e5089d2f2011e38d811ae0fc6b6d4edaeaf89b8 (patch) (side-by-side diff) | |
tree | 8d8ca7401ce699ee3aca98cace5561beb4104710 | |
parent | 904cbf4f2a418d3cadc74a6168a4565ae6ebc3c5 (diff) | |
download | kdepimpi-8e5089d2f2011e38d811ae0fc6b6d4edaeaf89b8.zip kdepimpi-8e5089d2f2011e38d811ae0fc6b6d4edaeaf89b8.tar.gz kdepimpi-8e5089d2f2011e38d811ae0fc6b6d4edaeaf89b8.tar.bz2 |
*** empty log message ***
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index 4e8a603..6c1a9c0 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp @@ -2895,2 +2895,4 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s uid = er[ incCounter ]; + qDebug("sync uid %s from remote file", uid.latin1()); + qApp->processEvents(); @@ -2899,2 +2901,3 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); + PWM_ASSERT(inRemote); if ( inLocal != 0 ) { // maybe conflict - same uid in both files @@ -3096,14 +3099,42 @@ bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) - // construct on the stack = automatic cleanup. + //1) unlock local file first if necessary (ask for password) + if (this->isDeepLocked()) { + PwMerror ret = this->deepLock(false); + if (ret != e_success) + return false; + } + + //2) construct and open a new doc on the stack(automatic cleanup) for remote file. PwMDoc syncTarget(this, "synctarget"); + PwMDoc* pSyncTarget = &syncTarget; + - PwMerror err = syncTarget.openDoc(&filename, 2 /*== deeplocked*/); + PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); - if (err != e_success) + if (err == e_alreadyOpen) { + PwMDocList::listItem li; + if (getOpenDocList()->find(filename.latin1(), &li)) + pSyncTarget = li.doc; + else { + qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); + return false; + } + } + else if (err != e_success) { + qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); return false; - + } + qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); + + //3) unlock remote file first if necessary (ask for password) + if (pSyncTarget->isDeepLocked()) { + PwMerror ret = pSyncTarget->deepLock(false); + if (ret != e_success) + return false; + } + - err = syncronize(manager, this, &syncTarget, mode ); + err = syncronize(manager, this, pSyncTarget, mode ); @@ -3112,6 +3143,7 @@ bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) qDebug("Saving remote PWManager file"); - err = syncTarget.saveDoc(conf()->confGlobCompression()); - if (err != e_success) + err = pSyncTarget->saveDoc(conf()->confGlobCompression()); + if (err != e_success) { + qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); return false; - + } } |