author | ulf69 <ulf69> | 2004-10-03 23:29:56 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-03 23:29:56 (UTC) |
commit | aaea91151fe9a747e9eddfb8ba7d5896744faf30 (patch) (unidiff) | |
tree | b2b064757d65bc83427e7a86692601364051b631 /pwmanager | |
parent | a5c204da5a2dba950fc5ad2c45861dbe56849c09 (diff) | |
download | kdepimpi-aaea91151fe9a747e9eddfb8ba7d5896744faf30.zip kdepimpi-aaea91151fe9a747e9eddfb8ba7d5896744faf30.tar.gz kdepimpi-aaea91151fe9a747e9eddfb8ba7d5896744faf30.tar.bz2 |
moved sync related progressbar management to ksyncmanager, and proceeded with
the sync implementation of pwmanager
-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 22 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.h | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 92 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.h | 25 |
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 | |||
@@ -1313,43 +1313,53 @@ void PwM::createAboutData_slot() | |||
1313 | "Olivier Sessink - gpasman@nl.linux.org\n" | 1313 | "Olivier Sessink - gpasman@nl.linux.org\n" |
1314 | "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" | 1314 | "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" |
1315 | "Troy Engel - tengel@sonic.net\n" | 1315 | "Troy Engel - tengel@sonic.net\n" |
1316 | "Wickey - wickey@gmx.at\n" | 1316 | "Wickey - wickey@gmx.at\n" |
1317 | "Ian MacGregor - original documentation author.\n" | 1317 | "Ian MacGregor - original documentation author.\n" |
1318 | ); | 1318 | ); |
1319 | } | 1319 | } |
1320 | 1320 | ||
1321 | 1321 | ||
1322 | //this are the overwritten callbackmethods from the syncinterface | 1322 | //this are the overwritten callbackmethods from the syncinterface |
1323 | bool PwM::sync(KSyncManager* manager, QString filename, int mode) | 1323 | bool PwM::sync(KSyncManager* manager, QString filename, int mode) |
1324 | { | 1324 | { |
1325 | return true; | 1325 | PWM_ASSERT(curDoc()); |
1326 | } | ||
1327 | 1326 | ||
1328 | bool 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. |
1334 | void PwM::sync_setModified() | 1338 | void 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. |
1339 | bool PwM::sync_isModified() | 1345 | bool 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. |
1344 | void PwM::sync_save() | 1352 | void PwM::sync_save() |
1345 | { | 1353 | { |
1354 | PWM_ASSERT(curDoc()); | ||
1355 | return curDoc()->sync_save(); | ||
1346 | } | 1356 | } |
1347 | 1357 | ||
1348 | 1358 | ||
1349 | 1359 | ||
1350 | #endif | 1360 | #endif |
1351 | 1361 | ||
1352 | 1362 | ||
1353 | #ifndef PWM_EMBEDDED | 1363 | #ifndef PWM_EMBEDDED |
1354 | #include "pwm.moc" | 1364 | #include "pwm.moc" |
1355 | #endif | 1365 | #endif |
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 | |||
@@ -262,25 +262,24 @@ protected: | |||
262 | /** force quit this window? */ | 262 | /** force quit this window? */ |
263 | bool forceQuit; | 263 | bool forceQuit; |
264 | /** force minimize this window to the tray */ | 264 | /** force minimize this window to the tray */ |
265 | bool forceMinimizeToTray; | 265 | bool forceMinimizeToTray; |
266 | 266 | ||
267 | 267 | ||
268 | 268 | ||
269 | 269 | ||
270 | private: | 270 | private: |
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(); |
278 | //called by the syncmanager to ask if the dirty flag is set. | 277 | //called by the syncmanager to ask if the dirty flag is set. |
279 | virtual bool sync_isModified(); | 278 | virtual bool sync_isModified(); |
280 | //called by the syncmanager to indicate that the work has to be saved. | 279 | //called by the syncmanager to indicate that the work has to be saved. |
281 | virtual void sync_save(); | 280 | virtual void sync_save(); |
282 | 281 | ||
283 | // LR ******************************* | 282 | // LR ******************************* |
284 | // sync stuff! | 283 | // sync stuff! |
285 | QPopupMenu *syncPopup; | 284 | QPopupMenu *syncPopup; |
286 | KSyncManager* syncManager; | 285 | KSyncManager* syncManager; |
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 | |||
@@ -2772,15 +2772,107 @@ bool PwMDoc::tryDelete() | |||
2772 | } else { // cancel operation | 2772 | } else { // cancel operation |
2773 | goto out_ignore; | 2773 | goto out_ignore; |
2774 | } | 2774 | } |
2775 | } | 2775 | } |
2776 | out_accept: | 2776 | out_accept: |
2777 | deleted = true; | 2777 | deleted = true; |
2778 | delete this; | 2778 | delete this; |
2779 | return true; | 2779 | return true; |
2780 | out_ignore: | 2780 | 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 | ||
2788 | PwMerror 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 | ||
2815 | bool 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. | ||
2850 | void PwMDoc::sync_setModified() | ||
2851 | { | ||
2852 | flagDirty(); | ||
2853 | } | ||
2854 | |||
2855 | //called by the syncmanager to ask if the dirty flag is set. | ||
2856 | bool PwMDoc::sync_isModified() | ||
2857 | { | ||
2858 | return isDirty(); | ||
2859 | } | ||
2860 | |||
2861 | //called by the syncmanager to indicate that the work has to be saved. | ||
2862 | void 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 | |||
@@ -50,24 +50,25 @@ | |||
50 | #include "pwmdocui.h" | 50 | #include "pwmdocui.h" |
51 | 51 | ||
52 | #include <qobject.h> | 52 | #include <qobject.h> |
53 | #include <qtimer.h> | 53 | #include <qtimer.h> |
54 | #include <qdatetime.h> | 54 | #include <qdatetime.h> |
55 | 55 | ||
56 | #include <kprocess.h> | 56 | #include <kprocess.h> |
57 | 57 | ||
58 | #ifndef PWM_EMBEDDED | 58 | #ifndef PWM_EMBEDDED |
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> |
65 | #include <vector> | 66 | #include <vector> |
66 | #include <utility> | 67 | #include <utility> |
67 | 68 | ||
68 | using std::vector; | 69 | using std::vector; |
69 | using std::string; | 70 | using std::string; |
70 | using std::pair; | 71 | using std::pair; |
71 | 72 | ||
72 | /* used in findEntry() function */ | 73 | /* used in findEntry() function */ |
73 | #define SEARCH_IN_DESC (1) | 74 | #define SEARCH_IN_DESC (1) |
@@ -326,25 +327,28 @@ protected: | |||
326 | QTimer *autoLockTimer; | 327 | QTimer *autoLockTimer; |
327 | /** timer object for the metaCheck timer */ | 328 | /** timer object for the metaCheck timer */ |
328 | QTimer *metaCheckTimer; | 329 | QTimer *metaCheckTimer; |
329 | /** lock counter for the mpw timer */ | 330 | /** lock counter for the mpw timer */ |
330 | unsigned int mpwLock; | 331 | unsigned int mpwLock; |
331 | /** lock counter for the autoLock timer */ | 332 | /** lock counter for the autoLock timer */ |
332 | unsigned int autoLockLock; | 333 | unsigned int autoLockLock; |
333 | /** lock counter for the metaCheck timer */ | 334 | /** lock counter for the metaCheck timer */ |
334 | unsigned int metaCheckLock; | 335 | unsigned int metaCheckLock; |
335 | }; | 336 | }; |
336 | 337 | ||
337 | /** Document class for PwM */ | 338 | /** Document class for PwM */ |
338 | class 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. | ||
341 | class PwMDoc : public PwMDocUi, public KSyncInterface | ||
342 | |||
339 | { | 343 | { |
340 | Q_OBJECT | 344 | Q_OBJECT |
341 | friend class DocTimer; | 345 | friend class DocTimer; |
342 | 346 | ||
343 | public: | 347 | public: |
344 | /** construtor */ | 348 | /** construtor */ |
345 | PwMDoc(QObject* parent = 0, const char *name = 0); | 349 | PwMDoc(QObject* parent = 0, const char *name = 0); |
346 | /** destructor */ | 350 | /** destructor */ |
347 | ~PwMDoc(); | 351 | ~PwMDoc(); |
348 | 352 | ||
349 | /** returns a pointer to a list of all open documents */ | 353 | /** returns a pointer to a list of all open documents */ |
350 | static PwMDocList* getOpenDocList() | 354 | static PwMDocList* getOpenDocList() |
@@ -687,15 +691,34 @@ protected: | |||
687 | bool getDocStatFlag(unsigned int statFlag) const | 691 | bool getDocStatFlag(unsigned int statFlag) const |
688 | { return (curDocStat & statFlag); } | 692 | { return (curDocStat & statFlag); } |
689 | /** set the "currentPassword" */ | 693 | /** set the "currentPassword" */ |
690 | void setCurrentPw(const QString &pw) | 694 | void setCurrentPw(const QString &pw) |
691 | { | 695 | { |
692 | currentPw = pw; | 696 | currentPw = pw; |
693 | setDocStatFlag(DOC_STAT_DISK_DIRTY); | 697 | setDocStatFlag(DOC_STAT_DISK_DIRTY); |
694 | } | 698 | } |
695 | /** make a backup-copy of the given file */ | 699 | /** make a backup-copy of the given file */ |
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 |