summaryrefslogtreecommitdiffabout
path: root/pwmanager
Side-by-side diff
Diffstat (limited to 'pwmanager') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwm.cpp22
-rw-r--r--pwmanager/pwmanager/pwm.h1
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp92
-rw-r--r--pwmanager/pwmanager/pwmdoc.h25
4 files changed, 132 insertions, 8 deletions
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index ac2e66e..014e809 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1322,27 +1322,37 @@ void PwM::createAboutData_slot()
//this are the overwritten callbackmethods from the syncinterface
bool PwM::sync(KSyncManager* manager, QString filename, int mode)
{
- return true;
-}
+ PWM_ASSERT(curDoc());
-bool PwM::syncExternal(KSyncManager* manager, QString resource)
-{
- return true;
+ bool ret = curDoc()->sync(manager, filename, mode);
+
+ if (ret == true) {
+ //US BUG: what can we call here to update the view of the current doc?
+ //mViewManager->refreshView();
+ }
+
+ return ret;
}
-//called by the syncmanager to indicate that the work has to marked as dirty.
+//called by the syncmanager to indicate that the work has to be marked as dirty.
void PwM::sync_setModified()
{
+ PWM_ASSERT(curDoc());
+ curDoc()->sync_setModified();
}
//called by the syncmanager to ask if the dirty flag is set.
bool PwM::sync_isModified()
{
+ PWM_ASSERT(curDoc());
+ return curDoc()->sync_isModified();
}
//called by the syncmanager to indicate that the work has to be saved.
void PwM::sync_save()
{
+ PWM_ASSERT(curDoc());
+ return curDoc()->sync_save();
}
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index 2fe7352..7c6bf0d 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -271,7 +271,6 @@ protected:
#ifdef PWM_EMBEDDED
//this are the overwritten callbackmethods from the syncinterface
virtual bool sync(KSyncManager* manager, QString filename, int mode);
- virtual bool syncExternal(KSyncManager* manager, QString resource);
//called by the syncmanager to indicate that the work has to marked as dirty.
virtual void sync_setModified();
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 1b6d36f..82fc746 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -2781,6 +2781,98 @@ out_ignore:
return false;
}
+
+
+#ifdef PWM_EMBEDDED
+//US ENH: this is the magic function that syncronizes the this doc with the remote doc
+PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode )
+{
+ bool syncOK = true;
+ int addedPasswordsLocal = 0;
+ int addedPasswordsRemote = 0;
+ int deletedPasswordsRemote = 0;
+ int deletedPasswordsLocal = 0;
+ int changedLocal = 0;
+ int changedRemote = 0;
+
+ QString mCurrentSyncName = manager->getCurrentSyncName();
+ QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
+
+
+
+
+
+
+
+
+
+ return e_success;
+}
+
+
+
+//this are the overwritten callbackmethods from the syncinterface
+bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
+{
+ QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
+
+ // construct on the stack = automatic cleanup.
+ PwMDoc syncTarget(this, "synctarget");
+
+ PwMerror err = syncTarget.openDoc(&filename, 2 /*== deeplocked*/);
+
+ if (err != e_success)
+ return false;
+
+ qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode );
+
+
+ err = syncronize(manager, this, &syncTarget, mode );
+
+ if (err == e_success) {
+ if ( PWMPrefs::instance()->mWriteBackFile ) {
+ qDebug("Saving remote PWManager file");
+ err = syncTarget.saveDoc(conf()->confGlobCompression());
+ if (err != e_success)
+ return false;
+
+ }
+
+ flagDirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+//called by the syncmanager to indicate that the work has to marked as dirty.
+void PwMDoc::sync_setModified()
+{
+ flagDirty();
+}
+
+//called by the syncmanager to ask if the dirty flag is set.
+bool PwMDoc::sync_isModified()
+{
+ return isDirty();
+}
+
+//called by the syncmanager to indicate that the work has to be saved.
+void PwMDoc::sync_save()
+{
+ PwMerror ret = saveDoc(conf()->confGlobCompression());
+}
+
+#endif
+
+
+
+
+
+
+
+
#ifndef PWM_EMBEDDED
#include "pwmdoc.moc"
#endif
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index 193247e..ea4d687 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -59,6 +59,7 @@
#include "configuration.h"
#else
#include <kapplication.h>
+#include <ksyncmanager.h>
#endif
#include <string>
@@ -335,7 +336,10 @@ protected:
};
/** Document class for PwM */
-class PwMDoc : public PwMDocUi
+//US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required.
+// But PwMDoc is handling the sync by itself.
+class PwMDoc : public PwMDocUi, public KSyncInterface
+
{
Q_OBJECT
friend class DocTimer;
@@ -696,6 +700,25 @@ protected:
bool backupFile(const QString &filePath);
/** copy a file from src to dst */
bool copyFile(const QString &src, const QString &dst);
+
+
+ public:
+#ifdef PWM_EMBEDDED
+ //US ENH: this is the magic function that syncronizes the local doc with the remote doc.
+ PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode );
+
+
+ //the following methods are the overwritten callbackmethods from the syncinterface
+ virtual bool sync(KSyncManager* manager, QString filename, int mode);
+
+ //called by the syncmanager to indicate that the work has to be marked as dirty.
+ virtual void sync_setModified();
+ //called by the syncmanager to ask if the dirty flag is set.
+ virtual bool sync_isModified();
+ //called by the syncmanager to indicate that the work has to be saved.
+ virtual void sync_save();
+#endif
+
};
#endif