summaryrefslogtreecommitdiffabout
path: root/pwmanager
Unidiff
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()
1322//this are the overwritten callbackmethods from the syncinterface 1322//this are the overwritten callbackmethods from the syncinterface
1323bool PwM::sync(KSyncManager* manager, QString filename, int mode) 1323bool PwM::sync(KSyncManager* manager, QString filename, int mode)
1324{ 1324{
1325 return true; 1325 PWM_ASSERT(curDoc());
1326}
1327 1326
1328bool PwM::syncExternal(KSyncManager* manager, QString resource) 1327 bool ret = curDoc()->sync(manager, filename, mode);
1329{ 1328
1330 return true; 1329 if (ret == true) {
1330 //US BUG: what can we call here to update the view of the current doc?
1331 //mViewManager->refreshView();
1332 }
1333
1334 return ret;
1331} 1335}
1332 1336
1333//called by the syncmanager to indicate that the work has to marked as dirty. 1337//called by the syncmanager to indicate that the work has to be marked as dirty.
1334void PwM::sync_setModified() 1338void PwM::sync_setModified()
1335{ 1339{
1340 PWM_ASSERT(curDoc());
1341 curDoc()->sync_setModified();
1336} 1342}
1337 1343
1338//called by the syncmanager to ask if the dirty flag is set. 1344//called by the syncmanager to ask if the dirty flag is set.
1339bool PwM::sync_isModified() 1345bool PwM::sync_isModified()
1340{ 1346{
1347 PWM_ASSERT(curDoc());
1348 return curDoc()->sync_isModified();
1341} 1349}
1342 1350
1343//called by the syncmanager to indicate that the work has to be saved. 1351//called by the syncmanager to indicate that the work has to be saved.
1344void PwM::sync_save() 1352void PwM::sync_save()
1345{ 1353{
1354 PWM_ASSERT(curDoc());
1355 return curDoc()->sync_save();
1346} 1356}
1347 1357
1348 1358
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:
271#ifdef PWM_EMBEDDED 271#ifdef PWM_EMBEDDED
272 //this are the overwritten callbackmethods from the syncinterface 272 //this are the overwritten callbackmethods from the syncinterface
273 virtual bool sync(KSyncManager* manager, QString filename, int mode); 273 virtual bool sync(KSyncManager* manager, QString filename, int mode);
274 virtual bool syncExternal(KSyncManager* manager, QString resource);
275 274
276 //called by the syncmanager to indicate that the work has to marked as dirty. 275 //called by the syncmanager to indicate that the work has to marked as dirty.
277 virtual void sync_setModified(); 276 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:
2781 return false; 2781 return false;
2782} 2782}
2783 2783
2784
2785
2786#ifdef PWM_EMBEDDED
2787//US ENH: this is the magic function that syncronizes the this doc with the remote doc
2788PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode )
2789{
2790 bool syncOK = true;
2791 int addedPasswordsLocal = 0;
2792 int addedPasswordsRemote = 0;
2793 int deletedPasswordsRemote = 0;
2794 int deletedPasswordsLocal = 0;
2795 int changedLocal = 0;
2796 int changedRemote = 0;
2797
2798 QString mCurrentSyncName = manager->getCurrentSyncName();
2799 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809 return e_success;
2810}
2811
2812
2813
2814//this are the overwritten callbackmethods from the syncinterface
2815bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
2816{
2817 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2818
2819 // construct on the stack = automatic cleanup.
2820 PwMDoc syncTarget(this, "synctarget");
2821
2822 PwMerror err = syncTarget.openDoc(&filename, 2 /*== deeplocked*/);
2823
2824 if (err != e_success)
2825 return false;
2826
2827 qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode );
2828
2829
2830 err = syncronize(manager, this, &syncTarget, mode );
2831
2832 if (err == e_success) {
2833 if ( PWMPrefs::instance()->mWriteBackFile ){
2834 qDebug("Saving remote PWManager file");
2835 err = syncTarget.saveDoc(conf()->confGlobCompression());
2836 if (err != e_success)
2837 return false;
2838
2839 }
2840
2841 flagDirty();
2842 return true;
2843 }
2844 else {
2845 return false;
2846 }
2847}
2848
2849//called by the syncmanager to indicate that the work has to marked as dirty.
2850void PwMDoc::sync_setModified()
2851{
2852 flagDirty();
2853}
2854
2855//called by the syncmanager to ask if the dirty flag is set.
2856bool PwMDoc::sync_isModified()
2857{
2858 return isDirty();
2859}
2860
2861//called by the syncmanager to indicate that the work has to be saved.
2862void PwMDoc::sync_save()
2863{
2864 PwMerror ret = saveDoc(conf()->confGlobCompression());
2865}
2866
2867#endif
2868
2869
2870
2871
2872
2873
2874
2875
2784#ifndef PWM_EMBEDDED 2876#ifndef PWM_EMBEDDED
2785#include "pwmdoc.moc" 2877#include "pwmdoc.moc"
2786#endif 2878#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 @@
59#include "configuration.h" 59#include "configuration.h"
60#else 60#else
61#include <kapplication.h> 61#include <kapplication.h>
62#include <ksyncmanager.h>
62#endif 63#endif
63 64
64#include <string> 65#include <string>
@@ -335,7 +336,10 @@ protected:
335}; 336};
336 337
337/** Document class for PwM */ 338/** Document class for PwM */
338class PwMDoc : public PwMDocUi 339//US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required.
340// But PwMDoc is handling the sync by itself.
341class PwMDoc : public PwMDocUi, public KSyncInterface
342
339{ 343{
340 Q_OBJECT 344 Q_OBJECT
341 friend class DocTimer; 345 friend class DocTimer;
@@ -696,6 +700,25 @@ protected:
696 bool backupFile(const QString &filePath); 700 bool backupFile(const QString &filePath);
697 /** copy a file from src to dst */ 701 /** copy a file from src to dst */
698 bool copyFile(const QString &src, const QString &dst); 702 bool copyFile(const QString &src, const QString &dst);
703
704
705 public:
706#ifdef PWM_EMBEDDED
707 //US ENH: this is the magic function that syncronizes the local doc with the remote doc.
708 PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode );
709
710
711 //the following methods are the overwritten callbackmethods from the syncinterface
712 virtual bool sync(KSyncManager* manager, QString filename, int mode);
713
714 //called by the syncmanager to indicate that the work has to be marked as dirty.
715 virtual void sync_setModified();
716 //called by the syncmanager to ask if the dirty flag is set.
717 virtual bool sync_isModified();
718 //called by the syncmanager to indicate that the work has to be saved.
719 virtual void sync_save();
720#endif
721
699}; 722};
700 723
701#endif 724#endif