author | zautrix <zautrix> | 2004-10-20 08:28:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-20 08:28:39 (UTC) |
commit | 268e69a533c5db110600758366644c9827957364 (patch) (unidiff) | |
tree | a2375a67c76beaf861ae8a67ca11ca0f5743c705 | |
parent | dd66c63b4e953f1e4bb89386bdaed06cbf84a7a5 (diff) | |
download | kdepimpi-268e69a533c5db110600758366644c9827957364.zip kdepimpi-268e69a533c5db110600758366644c9827957364.tar.gz kdepimpi-268e69a533c5db110600758366644c9827957364.tar.bz2 |
several fixes
-rw-r--r-- | pwmanager/pwmanager/compiler.h | 10 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.h | 3 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmanager.pro | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.h | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/randomizer.cpp | 8 | ||||
-rw-r--r-- | pwmanager/pwmanager/setmasterpwwndimpl.h | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/sha1.h | 9 |
7 files changed, 32 insertions, 10 deletions
diff --git a/pwmanager/pwmanager/compiler.h b/pwmanager/pwmanager/compiler.h index be08c6d..a942246 100644 --- a/pwmanager/pwmanager/compiler.h +++ b/pwmanager/pwmanager/compiler.h | |||
@@ -1,61 +1,69 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * Derived from the linux-2.6 tree * | 3 | * Derived from the linux-2.6 tree * |
4 | * * | 4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | * it under the terms of the GNU General Public License version 2 * | 6 | * it under the terms of the GNU General Public License version 2 * |
7 | * as published by the Free Software Foundation. * | 7 | * as published by the Free Software Foundation. * |
8 | * * | 8 | * * |
9 | ***************************************************************************/ | 9 | ***************************************************************************/ |
10 | 10 | ||
11 | #ifndef __PWMANAGER_COMPILER_H | 11 | #ifndef __PWMANAGER_COMPILER_H |
12 | #define __PWMANAGER_COMPILER_H | 12 | #define __PWMANAGER_COMPILER_H |
13 | 13 | ||
14 | #ifdef _WIN32_ | ||
15 | # define __builtin_expect(x, expected_value) (x) | ||
16 | #define NOREGPARM__attribute__((regparm(0))) | ||
17 | #define REGPARM __attribute__((regparm(3))) | ||
18 | #define likely(x)__builtin_expect(!!(x), 1) | ||
19 | #define unlikely(x)__builtin_expect(!!(x), 0) | ||
20 | |||
21 | #else | ||
14 | #ifdef __deprecated | 22 | #ifdef __deprecated |
15 | # undef __deprecated | 23 | # undef __deprecated |
16 | #endif | 24 | #endif |
17 | #if __GNUC__ >= 3 | 25 | #if __GNUC__ >= 3 |
18 | # if __GNUC_MINOR__ > 0 | 26 | # if __GNUC_MINOR__ > 0 |
19 | # define __deprecated__attribute__((deprecated)) | 27 | # define __deprecated__attribute__((deprecated)) |
20 | # endif | 28 | # endif |
21 | #elif __GNUC__ == 2 | 29 | #elif __GNUC__ == 2 |
22 | # if __GNUC_MINOR__ < 96 | 30 | # if __GNUC_MINOR__ < 96 |
23 | # ifdef __builtin_expect | 31 | # ifdef __builtin_expect |
24 | # undef __builtin_expect | 32 | # undef __builtin_expect |
25 | # endif | 33 | # endif |
26 | # define __builtin_expect(x, expected_value) (x) | 34 | # define __builtin_expect(x, expected_value) (x) |
27 | # endif | 35 | # endif |
28 | #else | 36 | #else |
29 | # error "Sorry, your compiler is too old/not supported." | 37 | # error "Sorry, your compiler is too old/not supported." |
30 | #endif | 38 | #endif |
31 | 39 | ||
32 | /* | 40 | /* |
33 | * Allow us to mark functions as 'deprecated' and have gcc emit a nice | 41 | * Allow us to mark functions as 'deprecated' and have gcc emit a nice |
34 | * warning for each use, in hopes of speeding the functions removal. | 42 | * warning for each use, in hopes of speeding the functions removal. |
35 | * Usage is: | 43 | * Usage is: |
36 | * int __deprecated foo(void) | 44 | * int __deprecated foo(void) |
37 | */ | 45 | */ |
38 | #ifndef __deprecated | 46 | #ifndef __deprecated |
39 | # define __deprecated /* unimplemented */ | 47 | # define __deprecated /* unimplemented */ |
40 | #endif | 48 | #endif |
41 | 49 | ||
42 | /* define likely() and unlikely() */ | 50 | /* define likely() and unlikely() */ |
43 | #ifdef likely | 51 | #ifdef likely |
44 | # undef likely | 52 | # undef likely |
45 | #endif | 53 | #endif |
46 | #ifdef unlikely | 54 | #ifdef unlikely |
47 | # undef unlikely | 55 | # undef unlikely |
48 | #endif | 56 | #endif |
49 | #define likely(x)__builtin_expect(!!(x), 1) | 57 | #define likely(x)__builtin_expect(!!(x), 1) |
50 | #define unlikely(x)__builtin_expect(!!(x), 0) | 58 | #define unlikely(x)__builtin_expect(!!(x), 0) |
51 | 59 | ||
52 | #ifdef NOREGPARM | 60 | #ifdef NOREGPARM |
53 | # undef NOREGPARM | 61 | # undef NOREGPARM |
54 | #endif | 62 | #endif |
55 | #define NOREGPARM__attribute__((regparm(0))) | 63 | #define NOREGPARM__attribute__((regparm(0))) |
56 | #ifdef REGPARM | 64 | #ifdef REGPARM |
57 | # undef REGPARM | 65 | # undef REGPARM |
58 | #endif | 66 | #endif |
59 | #define REGPARM __attribute__((regparm(3))) | 67 | #define REGPARM __attribute__((regparm(3))) |
60 | 68 | #endif | |
61 | #endif // __PWMANAGER_COMPILER_H | 69 | #endif // __PWMANAGER_COMPILER_H |
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h index 116bc66..6ab9d6b 100644 --- a/pwmanager/pwmanager/pwm.h +++ b/pwmanager/pwmanager/pwm.h | |||
@@ -1,294 +1,293 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003, 2004 by Michael Buesch * | 3 | * copyright (C) 2003, 2004 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License version 2 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * copyright (C) 2004 by Ulf Schenk | 13 | * copyright (C) 2004 by Ulf Schenk |
14 | * This file is originaly based on version 1.0.1 of pwmanager | 14 | * This file is originaly based on version 1.0.1 of pwmanager |
15 | * and was modified to run on embedded devices that run microkde | 15 | * and was modified to run on embedded devices that run microkde |
16 | * | 16 | * |
17 | * $Id$ | 17 | * $Id$ |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | 19 | ||
20 | #ifndef __PWM_H | 20 | #ifndef __PWM_H |
21 | #define __PWM_H | 21 | #define __PWM_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <kpopupmenu.h> | 24 | #include <kpopupmenu.h> |
25 | #include <klistview.h> | 25 | #include <klistview.h> |
26 | #include <kmainwindow.h> | 26 | #include <kmainwindow.h> |
27 | 27 | ||
28 | #ifndef PWM_EMBEDDED | 28 | #ifndef PWM_EMBEDDED |
29 | #include <kwin.h> | 29 | #include <kwin.h> |
30 | #include <kapp.h> | 30 | #include <kapp.h> |
31 | #include <kdeversion.h> | 31 | #include <kdeversion.h> |
32 | #else | 32 | #else |
33 | #include <ksyncmanager.h> | 33 | #include <ksyncmanager.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <kaction.h> | 36 | #include <kaction.h> |
37 | 37 | ||
38 | #include <qglobal.h> | 38 | #include <qglobal.h> |
39 | 39 | ||
40 | #include "pwmview.h" | 40 | #include "pwmview.h" |
41 | #include "pwmexception.h" | 41 | #include "pwmexception.h" |
42 | 42 | ||
43 | 43 | ||
44 | /** timeout for displaying a message on the status-bar (in seconds) */ | 44 | /** timeout for displaying a message on the status-bar (in seconds) */ |
45 | #define STATUSBAR_MSG_TIMEOUT5 | 45 | #define STATUSBAR_MSG_TIMEOUT5 |
46 | 46 | ||
47 | 47 | ||
48 | class PwMInit; | 48 | class PwMInit; |
49 | class KSyncManager; | 49 | class KSyncManager; |
50 | 50 | ||
51 | /** PwM is the base class of the project */ | 51 | /** PwM is the base class of the project */ |
52 | #ifndef PWM_EMBEDDED | 52 | #ifndef PWM_EMBEDDED |
53 | //MOC_SKIP_BEGIN | 53 | //MOC_SKIP_BEGIN |
54 | class PwM : public KMainWindow | 54 | class PwM : public KMainWindow |
55 | //MOC_SKIP_END | 55 | //MOC_SKIP_END |
56 | #else | 56 | #else |
57 | class PwM : public KMainWindow, public KSyncInterface | 57 | class PwM : public KMainWindow, public KSyncInterface |
58 | #endif | 58 | #endif |
59 | { | 59 | { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | public: | 61 | public: |
62 | friend class PwMView; | 62 | friend class PwMView; |
63 | /** construtor */ | 63 | /** construtor */ |
64 | PwM(PwMInit *_init, PwMDoc *doc, | 64 | PwM(PwMInit *_init, PwMDoc *doc, |
65 | bool virginity = true, | 65 | bool virginity = true, |
66 | QWidget* parent = 0, const char *name = 0); | 66 | QWidget* parent = 0, const char *name = 0); |
67 | /** destructor */ | 67 | /** destructor */ |
68 | ~PwM(); | 68 | ~PwM(); |
69 | 69 | ||
70 | /** copy some text to the global clipboard */ | 70 | /** copy some text to the global clipboard */ |
71 | static void copyToClipboard(const QString &s); | 71 | static void copyToClipboard(const QString &s); |
72 | 72 | ||
73 | /** returns pointer to the view */ | 73 | /** returns pointer to the view */ |
74 | PwMView * curView() | 74 | PwMView * curView() |
75 | { return view; } | 75 | { return view; } |
76 | /** returns pointer to the currently using document. */ | 76 | /** returns pointer to the currently using document. */ |
77 | PwMDoc * curDoc() | 77 | PwMDoc * curDoc() |
78 | { return curView()->document(); } | 78 | { return curView()->document(); } |
79 | /** open a new doc with the given filename */ | 79 | /** open a new doc with the given filename */ |
80 | PwMDoc * openDoc(QString filename, bool openDeepLocked = false); | 80 | PwMDoc * openDoc(QString filename, bool openDeepLocked = false); |
81 | /** show a message on the global status bar. | 81 | /** show a message on the global status bar. |
82 | * The message times out after some seconds. | 82 | * The message times out after some seconds. |
83 | */ | 83 | */ |
84 | void showStatMsg(const QString &msg); | 84 | void showStatMsg(const QString &msg); |
85 | /** ask the user where to save the doc (if it has not been saved, yet) | 85 | /** ask the user where to save the doc (if it has not been saved, yet) |
86 | * and write the data to disk. | 86 | * and write the data to disk. |
87 | */ | 87 | */ |
88 | bool save(); | 88 | bool save(); |
89 | /** ask the user where to save the doc | 89 | /** ask the user where to save the doc |
90 | * and write the data to disk. | 90 | * and write the data to disk. |
91 | */ | 91 | */ |
92 | bool saveAs(); | 92 | bool saveAs(); |
93 | /** force quit. Quit this window, always! Don't minimize it */ | 93 | /** force quit. Quit this window, always! Don't minimize it */ |
94 | bool isForceQuit() | 94 | bool isForceQuit() |
95 | { return forceQuit; } | 95 | { return forceQuit; } |
96 | /** set forceQuit */ | 96 | /** set forceQuit */ |
97 | void setForceQuit(bool force) | 97 | void setForceQuit(bool force) |
98 | { forceQuit = force; } | 98 | { forceQuit = force; } |
99 | /** force minimize this window */ | 99 | /** force minimize this window */ |
100 | bool isForceMinimizeToTray() | 100 | bool isForceMinimizeToTray() |
101 | { return forceMinimizeToTray; } | 101 | { return forceMinimizeToTray; } |
102 | /** set forceMinimizeToTray */ | 102 | /** set forceMinimizeToTray */ |
103 | void setForceMinimizeToTray(bool force) | 103 | void setForceMinimizeToTray(bool force) |
104 | { forceMinimizeToTray = force; } | 104 | { forceMinimizeToTray = force; } |
105 | 105 | ||
106 | public slots: | 106 | public slots: |
107 | /** file/new triggered */ | 107 | /** file/new triggered */ |
108 | void new_slot(); | 108 | void new_slot(); |
109 | /** file/open triggered */ | 109 | /** file/open triggered */ |
110 | //US ENH | 110 | //US ENH |
111 | void open_slot(); | 111 | void open_slot(); |
112 | void open_slot(QString fn); | 112 | void open_slot(QString fn); |
113 | /** file/close triggered */ | 113 | /** file/close triggered */ |
114 | void close_slot(); | 114 | void close_slot(); |
115 | /** file/quit triggered */ | 115 | /** file/quit triggered */ |
116 | void quitButton_slot(); | 116 | void quitButton_slot(); |
117 | /** file/save triggered */ | 117 | /** file/save triggered */ |
118 | void save_slot(); | 118 | void save_slot(); |
119 | /** file/saveAs triggered */ | 119 | /** file/saveAs triggered */ |
120 | void saveAs_slot(); | 120 | void saveAs_slot(); |
121 | /** file/export/text triggered */ | 121 | /** file/export/text triggered */ |
122 | void exportToText(); | 122 | void exportToText(); |
123 | /** file/export/gpasman triggered */ | 123 | /** file/export/gpasman triggered */ |
124 | void exportToGpasman(); | 124 | void exportToGpasman(); |
125 | /** file/export/kwallet triggered */ | 125 | /** file/export/kwallet triggered */ |
126 | void exportToKWallet(); | 126 | void exportToKWallet(); |
127 | /** file/import/text triggered */ | 127 | /** file/import/text triggered */ |
128 | bool importFromText(); | 128 | bool importFromText(); |
129 | /** file/import/gpasman triggered */ | 129 | /** file/import/gpasman triggered */ |
130 | bool importFromGpasman(); | 130 | bool importFromGpasman(); |
131 | /** file/import/kwallet triggered */ | 131 | /** file/import/kwallet triggered */ |
132 | bool importKWallet(); | 132 | bool importKWallet(); |
133 | /** file/print triggered */ | 133 | /** file/print triggered */ |
134 | void print_slot(); | 134 | void print_slot(); |
135 | /** manage/add triggered */ | 135 | /** manage/add triggered */ |
136 | //US ENH : changed code to run with older MOC | 136 | //US ENH : changed code to run with older MOC |
137 | 137 | ||
138 | void addPwd_slot(); | 138 | void addPwd_slot(); |
139 | void addPwd_slot1(QString *pw, PwMDoc *_doc); | 139 | void addPwd_slot1(QString *pw, PwMDoc *_doc); |
140 | /** manage/edit triggered */ | 140 | /** manage/edit triggered */ |
141 | //US ENH : changed code to run with older MOC | 141 | //US ENH : changed code to run with older MOC |
142 | void editPwd_slot(); | 142 | void editPwd_slot(); |
143 | void editPwd_slot1(const QString *category); | 143 | void editPwd_slot1(const QString *category); |
144 | void editPwd_slot3(const QString *category = 0, const int *index = 0, | 144 | void editPwd_slot3(const QString *category, const int *index ,PwMDoc *_doc ); |
145 | PwMDoc *_doc = 0); | ||
146 | 145 | ||
147 | /** manage/delete triggered */ | 146 | /** manage/delete triggered */ |
148 | void deletePwd_slot(); | 147 | void deletePwd_slot(); |
149 | /** execute the "Launcher" entry */ | 148 | /** execute the "Launcher" entry */ |
150 | void execLauncher_slot(); | 149 | void execLauncher_slot(); |
151 | /** open browser with URL entry */ | 150 | /** open browser with URL entry */ |
152 | void goToURL_slot(); | 151 | void goToURL_slot(); |
153 | /** manage/changeMasterPwd triggered */ | 152 | /** manage/changeMasterPwd triggered */ |
154 | void changeMasterPwd_slot(); | 153 | void changeMasterPwd_slot(); |
155 | /** lock current document */ | 154 | /** lock current document */ |
156 | void lockWnd_slot(); | 155 | void lockWnd_slot(); |
157 | /** deeplock current document */ | 156 | /** deeplock current document */ |
158 | void deepLockWnd_slot(); | 157 | void deepLockWnd_slot(); |
159 | /** window/unlock triggered */ | 158 | /** window/unlock triggered */ |
160 | void unlockWnd_slot(); | 159 | void unlockWnd_slot(); |
161 | /** find item */ | 160 | /** find item */ |
162 | void find_slot(); | 161 | void find_slot(); |
163 | /** configure clicked */ | 162 | /** configure clicked */ |
164 | void config_slot(); | 163 | void config_slot(); |
165 | /** (de)activate the "change master pw" button in the menu-bar */ | 164 | /** (de)activate the "change master pw" button in the menu-bar */ |
166 | void activateMpButton(bool activate = true); | 165 | void activateMpButton(bool activate = true); |
167 | /** generate a new chipcard */ | 166 | /** generate a new chipcard */ |
168 | void genNewCard_slot(); | 167 | void genNewCard_slot(); |
169 | /** completely erase the current card */ | 168 | /** completely erase the current card */ |
170 | void eraseCard_slot(); | 169 | void eraseCard_slot(); |
171 | /** returns the ID number of the current card */ | 170 | /** returns the ID number of the current card */ |
172 | void readCardId_slot(); | 171 | void readCardId_slot(); |
173 | /** make backup image of the current card */ | 172 | /** make backup image of the current card */ |
174 | void makeCardBackup_slot(); | 173 | void makeCardBackup_slot(); |
175 | /** write backup image to current card */ | 174 | /** write backup image to current card */ |
176 | void replayCardBackup_slot(); | 175 | void replayCardBackup_slot(); |
177 | 176 | ||
178 | #ifdef PWM_EMBEDDED | 177 | #ifdef PWM_EMBEDDED |
179 | void whatsnew_slot(); | 178 | void whatsnew_slot(); |
180 | void showLicense_slot(); | 179 | void showLicense_slot(); |
181 | void faq_slot(); | 180 | void faq_slot(); |
182 | void createAboutData_slot(); | 181 | void createAboutData_slot(); |
183 | void syncHowTo_slot(); | 182 | void syncHowTo_slot(); |
184 | #endif | 183 | #endif |
185 | 184 | ||
186 | protected: | 185 | protected: |
187 | /** is this window virgin? */ | 186 | /** is this window virgin? */ |
188 | bool isVirgin() | 187 | bool isVirgin() |
189 | { return virgin; } | 188 | { return virgin; } |
190 | /** add/remove virginity */ | 189 | /** add/remove virginity */ |
191 | void setVirgin(bool v); | 190 | void setVirgin(bool v); |
192 | /** initialize the menubar */ | 191 | /** initialize the menubar */ |
193 | void initMenubar(); | 192 | void initMenubar(); |
194 | /** initialize the toolbar */ | 193 | /** initialize the toolbar */ |
195 | void initToolbar(); | 194 | void initToolbar(); |
196 | /** initialize the window-metrics */ | 195 | /** initialize the window-metrics */ |
197 | void initMetrics(); | 196 | void initMetrics(); |
198 | /** close-event */ | 197 | /** close-event */ |
199 | void closeEvent(QCloseEvent *e); | 198 | void closeEvent(QCloseEvent *e); |
200 | /** creates a new PwM-ListView and returns it */ | 199 | /** creates a new PwM-ListView and returns it */ |
201 | PwMView * makeNewListView(PwMDoc *doc); | 200 | PwMView * makeNewListView(PwMDoc *doc); |
202 | /** Window hide-event */ | 201 | /** Window hide-event */ |
203 | void hideEvent(QHideEvent *); | 202 | void hideEvent(QHideEvent *); |
204 | /** is this window minimized? */ | 203 | /** is this window minimized? */ |
205 | bool isMinimized() | 204 | bool isMinimized() |
206 | { | 205 | { |
207 | #ifndef PWM_EMBEDDED | 206 | #ifndef PWM_EMBEDDED |
208 | #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) | 207 | #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) |
209 | return KWin::windowInfo(winId()).isMinimized(); | 208 | return KWin::windowInfo(winId()).isMinimized(); |
210 | #else // KDE_VERSION | 209 | #else // KDE_VERSION |
211 | return KWin::info(winId()).isIconified(); | 210 | return KWin::info(winId()).isIconified(); |
212 | #endif // KDE_VERSION | 211 | #endif // KDE_VERSION |
213 | #else | 212 | #else |
214 | return false; | 213 | return false; |
215 | #endif | 214 | #endif |
216 | } | 215 | } |
217 | /** window got the focus */ | 216 | /** window got the focus */ |
218 | void focusInEvent(QFocusEvent *e); | 217 | void focusInEvent(QFocusEvent *e); |
219 | /** update the caption string */ | 218 | /** update the caption string */ |
220 | void updateCaption(); | 219 | void updateCaption(); |
221 | #ifdef CONFIG_KWALLETIF | 220 | #ifdef CONFIG_KWALLETIF |
222 | /** check if kwalletemu is enabled and ask the user what to do */ | 221 | /** check if kwalletemu is enabled and ask the user what to do */ |
223 | bool checkAndAskForKWalletEmu(); | 222 | bool checkAndAskForKWalletEmu(); |
224 | #endif // CONFIG_KWALLETIF | 223 | #endif // CONFIG_KWALLETIF |
225 | 224 | ||
226 | protected slots: | 225 | protected slots: |
227 | /** doc got closed */ | 226 | /** doc got closed */ |
228 | void docClosed(PwMDoc *doc); | 227 | void docClosed(PwMDoc *doc); |
229 | 228 | ||
230 | signals: | 229 | signals: |
231 | /** window got closed (by user or someone else) */ | 230 | /** window got closed (by user or someone else) */ |
232 | void closed(PwM *wnd); | 231 | void closed(PwM *wnd); |
233 | /** window got the focus (was brought to foreground) */ | 232 | /** window got the focus (was brought to foreground) */ |
234 | void gotFocus(PwM *wnd); | 233 | void gotFocus(PwM *wnd); |
235 | /** window lost the focus */ | 234 | /** window lost the focus */ |
236 | void lostFocus(PwM *wnd); | 235 | void lostFocus(PwM *wnd); |
237 | 236 | ||
238 | protected: | 237 | protected: |
239 | /** pointer to the view active in this KMainWindow */ | 238 | /** pointer to the view active in this KMainWindow */ |
240 | PwMView *view; | 239 | PwMView *view; |
241 | /** pointer to the init class */ | 240 | /** pointer to the init class */ |
242 | PwMInit *init; | 241 | PwMInit *init; |
243 | /** has this window already lost its virginity? | 242 | /** has this window already lost its virginity? |
244 | * Means is there an open working document | 243 | * Means is there an open working document |
245 | */ | 244 | */ |
246 | bool virgin; | 245 | bool virgin; |
247 | /** "file" popup-menu */ | 246 | /** "file" popup-menu */ |
248 | KPopupMenu *filePopup; | 247 | KPopupMenu *filePopup; |
249 | 248 | ||
250 | /** "manage" popup-menu */ | 249 | /** "manage" popup-menu */ |
251 | KPopupMenu *managePopup; | 250 | KPopupMenu *managePopup; |
252 | #ifdef CONFIG_KEYCARD | 251 | #ifdef CONFIG_KEYCARD |
253 | /** "chipcard" popup-menu */ | 252 | /** "chipcard" popup-menu */ |
254 | KPopupMenu *chipcardPopup; | 253 | KPopupMenu *chipcardPopup; |
255 | #endif // CONFIG_KEYCARD | 254 | #endif // CONFIG_KEYCARD |
256 | /** "view" popup-menu */ | 255 | /** "view" popup-menu */ |
257 | KPopupMenu *viewPopup; | 256 | KPopupMenu *viewPopup; |
258 | /** "options" popup-menu */ | 257 | /** "options" popup-menu */ |
259 | KPopupMenu *optionsPopup; | 258 | KPopupMenu *optionsPopup; |
260 | /** "help" popup-menu */ | 259 | /** "help" popup-menu */ |
261 | KPopupMenu *helpPopup; | 260 | KPopupMenu *helpPopup; |
262 | /** "export" popup-menu */ | 261 | /** "export" popup-menu */ |
263 | KPopupMenu *exportPopup; | 262 | KPopupMenu *exportPopup; |
264 | /** "import" popup-menu */ | 263 | /** "import" popup-menu */ |
265 | KPopupMenu *importPopup; | 264 | KPopupMenu *importPopup; |
266 | /** force quit this window? */ | 265 | /** force quit this window? */ |
267 | bool forceQuit; | 266 | bool forceQuit; |
268 | /** force minimize this window to the tray */ | 267 | /** force minimize this window to the tray */ |
269 | bool forceMinimizeToTray; | 268 | bool forceMinimizeToTray; |
270 | 269 | ||
271 | 270 | ||
272 | 271 | ||
273 | 272 | ||
274 | private: | 273 | private: |
275 | #ifdef PWM_EMBEDDED | 274 | #ifdef PWM_EMBEDDED |
276 | //this are the overwritten callbackmethods from the syncinterface | 275 | //this are the overwritten callbackmethods from the syncinterface |
277 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 276 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
278 | 277 | ||
279 | // LR ******************************* | 278 | // LR ******************************* |
280 | // sync stuff! | 279 | // sync stuff! |
281 | QPopupMenu *syncPopup; | 280 | QPopupMenu *syncPopup; |
282 | KSyncManager* syncManager; | 281 | KSyncManager* syncManager; |
283 | #endif | 282 | #endif |
284 | 283 | ||
285 | 284 | ||
286 | 285 | ||
287 | 286 | ||
288 | 287 | ||
289 | 288 | ||
290 | 289 | ||
291 | 290 | ||
292 | }; | 291 | }; |
293 | 292 | ||
294 | #endif | 293 | #endif |
diff --git a/pwmanager/pwmanager/pwmanager.pro b/pwmanager/pwmanager/pwmanager.pro index 7f39c76..49c1f46 100644 --- a/pwmanager/pwmanager/pwmanager.pro +++ b/pwmanager/pwmanager/pwmanager.pro | |||
@@ -1,173 +1,173 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_off |
3 | DESTDIR= ../../bin | 3 | DESTDIR= ../../bin |
4 | TARGET = pwmpi | 4 | TARGET = pwmpi |
5 | include( ../../variables.pri ) | 5 | include( ../../variables.pri ) |
6 | 6 | ||
7 | INCLUDEPATH += . ../../ ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils | 7 | INCLUDEPATH += . ../../ ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils |
8 | DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION | 8 | DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION |
9 | 9 | ||
10 | #enable this setting if you want debugoutput for pwmanager | 10 | #enable this setting if you want debugoutput for pwmanager |
11 | #DEFINES += CONFIG_DEBUG | 11 | #DEFINES += CONFIG_DEBUG |
12 | LIBS += -L../libcrypt/ | 12 | LIBS += -L../libcrypt/ |
13 | LIBS += -L../../bin/ | 13 | LIBS += -L../../bin/ |
14 | LIBS += -lmicrokde | 14 | LIBS += -lmicrokde |
15 | LIBS += -lmicrokdepim | 15 | LIBS += -lmicrokdepim |
16 | LIBS += -lzlib | 16 | LIBS += -lzlib |
17 | LIBS += -lkpmicrocipher | 17 | LIBS += -lkpmicrocipher |
18 | LIBS += -lkpmicroerror | 18 | LIBS += -lkpmicroerror |
19 | LIBS += -lkpmicrompi | 19 | LIBS += -lkpmicrompi |
20 | LIBS += -lstdc++ | 20 | LIBS += -lstdc++ |
21 | 21 | ||
22 | unix:{ | 22 | unix:{ |
23 | OBJECTS_DIR = obj/unix | 23 | OBJECTS_DIR = obj/unix |
24 | MOC_DIR = moc/unix | 24 | MOC_DIR = moc/unix |
25 | 25 | ||
26 | } | 26 | } |
27 | win32:{ | 27 | win32:{ |
28 | 28 | ||
29 | DEFINES += _WIN32_ | 29 | DEFINES += _WIN32_ |
30 | OBJECTS_DIR = obj/win | 30 | OBJECTS_DIR = obj/win |
31 | MOC_DIR = moc/win | 31 | MOC_DIR = moc/win |
32 | QMAKE_LINK += /NODEFAULTLIB:LIBC | 32 | QMAKE_LINK += /NODEFAULTLIB:LIBC |
33 | 33 | QMAKE_CXXFLAGS += /TP /GX /GR /Ehsc | |
34 | } | 34 | } |
35 | 35 | ||
36 | #INTERFACES = \ | 36 | #INTERFACES = \ |
37 | #addentrywnd.ui \ | 37 | #addentrywnd.ui \ |
38 | #configwnd.ui \ | 38 | #configwnd.ui \ |
39 | #findwnd.ui \ | 39 | #findwnd.ui \ |
40 | #getmasterpwwnd.ui \ | 40 | #getmasterpwwnd.ui \ |
41 | #pwgenwnd.ui \ | 41 | #pwgenwnd.ui \ |
42 | #setmasterpwwnd.ui \ | 42 | #setmasterpwwnd.ui \ |
43 | #subtbledit.ui | 43 | #subtbledit.ui |
44 | 44 | ||
45 | #INTERFACES = \ | 45 | #INTERFACES = \ |
46 | #subtbledit.ui \ | 46 | #subtbledit.ui \ |
47 | 47 | ||
48 | 48 | ||
49 | 49 | ||
50 | #HEADERS = \ | 50 | #HEADERS = \ |
51 | #configuration_31compat.h \ | 51 | #configuration_31compat.h \ |
52 | #configuration.h \ | 52 | #configuration.h \ |
53 | #configwnd.h \ | 53 | #configwnd.h \ |
54 | #configwndimpl.h \ | 54 | #configwndimpl.h \ |
55 | #selftest.h | 55 | #selftest.h |
56 | #subtbledit.h \ | 56 | #subtbledit.h \ |
57 | #subtbleditimpl.h \ | 57 | #subtbleditimpl.h \ |
58 | #compressbzip2.h \ | 58 | #compressbzip2.h \ |
59 | 59 | ||
60 | HEADERS = \ | 60 | HEADERS = \ |
61 | addentrywnd_emb.h \ | 61 | addentrywnd_emb.h \ |
62 | addentrywndimpl.h \ | 62 | addentrywndimpl.h \ |
63 | base64.h \ | 63 | base64.h \ |
64 | binentrygen.h \ | 64 | binentrygen.h \ |
65 | blowfish.h \ | 65 | blowfish.h \ |
66 | commentbox.h \ | 66 | commentbox.h \ |
67 | compiler.h \ | 67 | compiler.h \ |
68 | compressgzip.h \ | 68 | compressgzip.h \ |
69 | findwnd_emb.h \ | 69 | findwnd_emb.h \ |
70 | findwndimpl.h \ | 70 | findwndimpl.h \ |
71 | genpasswd.h \ | 71 | genpasswd.h \ |
72 | getkeycardwnd.h \ | 72 | getkeycardwnd.h \ |
73 | getmasterpwwnd_emb.h \ | 73 | getmasterpwwnd_emb.h \ |
74 | getmasterpwwndimpl.h \ | 74 | getmasterpwwndimpl.h \ |
75 | globalstuff.h \ | 75 | globalstuff.h \ |
76 | gpasmanfile.h \ | 76 | gpasmanfile.h \ |
77 | htmlgen.h \ | 77 | htmlgen.h \ |
78 | htmlparse.h \ | 78 | htmlparse.h \ |
79 | ipc.h \ | 79 | ipc.h \ |
80 | libgcryptif.h \ | 80 | libgcryptif.h \ |
81 | listobjselectwnd.h \ | 81 | listobjselectwnd.h \ |
82 | listviewpwm.h \ | 82 | listviewpwm.h \ |
83 | printtext.h \ | 83 | printtext.h \ |
84 | pwgenwnd_emb.h \ | 84 | pwgenwnd_emb.h \ |
85 | pwgenwndimpl.h \ | 85 | pwgenwndimpl.h \ |
86 | pwmdoc.h \ | 86 | pwmdoc.h \ |
87 | pwmdocui.h \ | 87 | pwmdocui.h \ |
88 | pwmexception.h \ | 88 | pwmexception.h \ |
89 | pwm.h \ | 89 | pwm.h \ |
90 | pwminit.h \ | 90 | pwminit.h \ |
91 | pwmprefs.h \ | 91 | pwmprefs.h \ |
92 | pwmprint.h \ | 92 | pwmprint.h \ |
93 | pwmtray.h \ | 93 | pwmtray.h \ |
94 | pwmview.h \ | 94 | pwmview.h \ |
95 | pwmviewstyle_0.h \ | 95 | pwmviewstyle_0.h \ |
96 | pwmviewstyle_1.h \ | 96 | pwmviewstyle_1.h \ |
97 | pwmviewstyle.h \ | 97 | pwmviewstyle.h \ |
98 | randomizer.h \ | 98 | randomizer.h \ |
99 | rc2.h \ | 99 | rc2.h \ |
100 | rencatwnd.h \ | 100 | rencatwnd.h \ |
101 | serializer.h \ | 101 | serializer.h \ |
102 | setmasterpwwnd_emb.h \ | 102 | setmasterpwwnd_emb.h \ |
103 | setmasterpwwndimpl.h \ | 103 | setmasterpwwndimpl.h \ |
104 | sha1.h \ | 104 | sha1.h \ |
105 | waitwnd.h \ | 105 | waitwnd.h \ |
106 | kcmconfigs/kcmpwmconfig.h \ | 106 | kcmconfigs/kcmpwmconfig.h \ |
107 | kcmconfigs/pwmconfigwidget.h | 107 | kcmconfigs/pwmconfigwidget.h |
108 | 108 | ||
109 | #sources that need not be build | 109 | #sources that need not be build |
110 | #SOURCES = \ | 110 | #SOURCES = \ |
111 | #advcommeditimpl.cpp \ | 111 | #advcommeditimpl.cpp \ |
112 | #configuration.cpp \ | 112 | #configuration.cpp \ |
113 | #configwnd.cpp \ | 113 | #configwnd.cpp \ |
114 | #configwndimpl.cpp \ | 114 | #configwndimpl.cpp \ |
115 | #configuration_31compat.cpp \ | 115 | #configuration_31compat.cpp \ |
116 | #htmlparse.cpp \ | 116 | #htmlparse.cpp \ |
117 | #printtext.cpp \ | 117 | #printtext.cpp \ |
118 | #selftest.cpp \ | 118 | #selftest.cpp \ |
119 | #pwmprint.cpp \ | 119 | #pwmprint.cpp \ |
120 | #spinforsignal.cpp | 120 | #spinforsignal.cpp |
121 | #subtbledit.cpp \ | 121 | #subtbledit.cpp \ |
122 | #subtbleditimpl.cpp \ | 122 | #subtbleditimpl.cpp \ |
123 | #compressbzip2.cpp | 123 | #compressbzip2.cpp |
124 | 124 | ||
125 | 125 | ||
126 | SOURCES = \ | 126 | SOURCES = \ |
127 | addentrywnd_emb.cpp \ | 127 | addentrywnd_emb.cpp \ |
128 | addentrywndimpl.cpp \ | 128 | addentrywndimpl.cpp \ |
129 | base64.cpp \ | 129 | base64.cpp \ |
130 | binentrygen.cpp \ | 130 | binentrygen.cpp \ |
131 | blowfish.cpp \ | 131 | blowfish.cpp \ |
132 | commentbox.cpp \ | 132 | commentbox.cpp \ |
133 | compressgzip.cpp \ | 133 | compressgzip.cpp \ |
134 | findwnd_emb.cpp \ | 134 | findwnd_emb.cpp \ |
135 | findwndimpl.cpp \ | 135 | findwndimpl.cpp \ |
136 | genpasswd.cpp \ | 136 | genpasswd.cpp \ |
137 | getkeycardwnd.cpp \ | 137 | getkeycardwnd.cpp \ |
138 | getmasterpwwnd_emb.cpp \ | 138 | getmasterpwwnd_emb.cpp \ |
139 | getmasterpwwndimpl.cpp \ | 139 | getmasterpwwndimpl.cpp \ |
140 | globalstuff.cpp \ | 140 | globalstuff.cpp \ |
141 | gpasmanfile.cpp \ | 141 | gpasmanfile.cpp \ |
142 | htmlgen.cpp \ | 142 | htmlgen.cpp \ |
143 | ipc.cpp \ | 143 | ipc.cpp \ |
144 | libgcryptif.cpp \ | 144 | libgcryptif.cpp \ |
145 | listobjselectwnd.cpp \ | 145 | listobjselectwnd.cpp \ |
146 | listviewpwm.cpp \ | 146 | listviewpwm.cpp \ |
147 | main.cpp \ | 147 | main.cpp \ |
148 | pwgenwnd_emb.cpp \ | 148 | pwgenwnd_emb.cpp \ |
149 | pwgenwndimpl.cpp \ | 149 | pwgenwndimpl.cpp \ |
150 | pwm.cpp \ | 150 | pwm.cpp \ |
151 | pwmdoc.cpp \ | 151 | pwmdoc.cpp \ |
152 | pwmdocui.cpp \ | 152 | pwmdocui.cpp \ |
153 | pwmexception.cpp \ | 153 | pwmexception.cpp \ |
154 | pwminit.cpp \ | 154 | pwminit.cpp \ |
155 | pwmprefs.cpp \ | 155 | pwmprefs.cpp \ |
156 | pwmtray.cpp \ | 156 | pwmtray.cpp \ |
157 | pwmview.cpp \ | 157 | pwmview.cpp \ |
158 | pwmviewstyle_0.cpp \ | 158 | pwmviewstyle_0.cpp \ |
159 | pwmviewstyle_1.cpp \ | 159 | pwmviewstyle_1.cpp \ |
160 | pwmviewstyle.cpp \ | 160 | pwmviewstyle.cpp \ |
161 | randomizer.cpp \ | 161 | randomizer.cpp \ |
162 | rc2.cpp \ | 162 | rc2.cpp \ |
163 | rencatwnd.cpp \ | 163 | rencatwnd.cpp \ |
164 | serializer.cpp \ | 164 | serializer.cpp \ |
165 | setmasterpwwnd_emb.cpp \ | 165 | setmasterpwwnd_emb.cpp \ |
166 | setmasterpwwndimpl.cpp \ | 166 | setmasterpwwndimpl.cpp \ |
167 | sha1.cpp \ | 167 | sha1.cpp \ |
168 | waitwnd.cpp \ | 168 | waitwnd.cpp \ |
169 | kcmconfigs/kcmpwmconfig.cpp \ | 169 | kcmconfigs/kcmpwmconfig.cpp \ |
170 | kcmconfigs/pwmconfigwidget.cpp | 170 | kcmconfigs/pwmconfigwidget.cpp |
171 | 171 | ||
172 | 172 | ||
173 | 173 | ||
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h index 635361a..55e3231 100644 --- a/pwmanager/pwmanager/pwmdoc.h +++ b/pwmanager/pwmanager/pwmdoc.h | |||
@@ -1,786 +1,788 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003, 2004 by Michael Buesch * | 3 | * copyright (C) 2003, 2004 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License version 2 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * copyright (C) 2004 by Ulf Schenk | 13 | * copyright (C) 2004 by Ulf Schenk |
14 | * This file is originaly based on version 1.1 of pwmanager | 14 | * This file is originaly based on version 1.1 of pwmanager |
15 | * and was modified to run on embedded devices that run microkde | 15 | * and was modified to run on embedded devices that run microkde |
16 | * | 16 | * |
17 | * $Id$ | 17 | * $Id$ |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | 19 | ||
20 | #ifndef __PWMDOC_H | 20 | #ifndef __PWMDOC_H |
21 | #define __PWMDOC_H | 21 | #define __PWMDOC_H |
22 | 22 | #ifdef _WIN32_ | |
23 | #define ssize_t unsigned int | ||
24 | #endif | ||
23 | #define PWM_FILE_VER (static_cast<char>(0x05)) | 25 | #define PWM_FILE_VER (static_cast<char>(0x05)) |
24 | 26 | ||
25 | #define PWM_HASH_SHA1 (static_cast<char>(0x01)) | 27 | #define PWM_HASH_SHA1 (static_cast<char>(0x01)) |
26 | #define PWM_HASH_SHA256 (static_cast<char>(0x02)) | 28 | #define PWM_HASH_SHA256 (static_cast<char>(0x02)) |
27 | #define PWM_HASH_SHA384 (static_cast<char>(0x03)) | 29 | #define PWM_HASH_SHA384 (static_cast<char>(0x03)) |
28 | #define PWM_HASH_SHA512 (static_cast<char>(0x04)) | 30 | #define PWM_HASH_SHA512 (static_cast<char>(0x04)) |
29 | #define PWM_HASH_MD5 (static_cast<char>(0x05)) | 31 | #define PWM_HASH_MD5 (static_cast<char>(0x05)) |
30 | #define PWM_HASH_RMD160 (static_cast<char>(0x06)) | 32 | #define PWM_HASH_RMD160 (static_cast<char>(0x06)) |
31 | #define PWM_HASH_TIGER (static_cast<char>(0x07)) | 33 | #define PWM_HASH_TIGER (static_cast<char>(0x07)) |
32 | 34 | ||
33 | #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01)) | 35 | #define PWM_CRYPT_BLOWFISH(static_cast<char>(0x01)) |
34 | #define PWM_CRYPT_AES128(static_cast<char>(0x02)) | 36 | #define PWM_CRYPT_AES128(static_cast<char>(0x02)) |
35 | #define PWM_CRYPT_AES192(static_cast<char>(0x03)) | 37 | #define PWM_CRYPT_AES192(static_cast<char>(0x03)) |
36 | #define PWM_CRYPT_AES256(static_cast<char>(0x04)) | 38 | #define PWM_CRYPT_AES256(static_cast<char>(0x04)) |
37 | #define PWM_CRYPT_3DES (static_cast<char>(0x05)) | 39 | #define PWM_CRYPT_3DES (static_cast<char>(0x05)) |
38 | #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06)) | 40 | #define PWM_CRYPT_TWOFISH(static_cast<char>(0x06)) |
39 | #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07)) | 41 | #define PWM_CRYPT_TWOFISH128(static_cast<char>(0x07)) |
40 | 42 | ||
41 | #define PWM_COMPRESS_NONE(static_cast<char>(0x00)) | 43 | #define PWM_COMPRESS_NONE(static_cast<char>(0x00)) |
42 | #define PWM_COMPRESS_GZIP(static_cast<char>(0x01)) | 44 | #define PWM_COMPRESS_GZIP(static_cast<char>(0x01)) |
43 | #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02)) | 45 | #define PWM_COMPRESS_BZIP2(static_cast<char>(0x02)) |
44 | 46 | ||
45 | #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0))) | 47 | #define DEFAULT_MAX_ENTRIES(~(static_cast<unsigned int>(0))) |
46 | #define FILE_ID_HEADER "PWM_PASSWORD_FILE" | 48 | #define FILE_ID_HEADER "PWM_PASSWORD_FILE" |
47 | 49 | ||
48 | 50 | ||
49 | #include "pwmexception.h" | 51 | #include "pwmexception.h" |
50 | #include "pwmdocui.h" | 52 | #include "pwmdocui.h" |
51 | 53 | ||
52 | #include <qobject.h> | 54 | #include <qobject.h> |
53 | #include <qtimer.h> | 55 | #include <qtimer.h> |
54 | #include <qdatetime.h> | 56 | #include <qdatetime.h> |
55 | 57 | ||
56 | #include <kprocess.h> | 58 | #include <kprocess.h> |
57 | 59 | ||
58 | #ifndef PWM_EMBEDDED | 60 | #ifndef PWM_EMBEDDED |
59 | #include "configuration.h" | 61 | #include "configuration.h" |
60 | #else | 62 | #else |
61 | #include <kapplication.h> | 63 | #include <kapplication.h> |
62 | #include <ksyncmanager.h> | 64 | #include <ksyncmanager.h> |
63 | #endif | 65 | #endif |
64 | 66 | ||
65 | #include <string> | 67 | #include <string> |
66 | #include <vector> | 68 | #include <vector> |
67 | #include <utility> | 69 | #include <utility> |
68 | 70 | ||
69 | using std::vector; | 71 | using std::vector; |
70 | using std::string; | 72 | using std::string; |
71 | using std::pair; | 73 | using std::pair; |
72 | 74 | ||
73 | /* used in findEntry() function */ | 75 | /* used in findEntry() function */ |
74 | #define SEARCH_IN_DESC (1) | 76 | #define SEARCH_IN_DESC (1) |
75 | #define SEARCH_IN_NAME (1 << 1) | 77 | #define SEARCH_IN_NAME (1 << 1) |
76 | #define SEARCH_IN_PW (1 << 2) | 78 | #define SEARCH_IN_PW (1 << 2) |
77 | #define SEARCH_IN_COMMENT(1 << 3) | 79 | #define SEARCH_IN_COMMENT(1 << 3) |
78 | #define SEARCH_IN_URL (1 << 4) | 80 | #define SEARCH_IN_URL (1 << 4) |
79 | #define SEARCH_IN_LAUNCHER(1 << 5) | 81 | #define SEARCH_IN_LAUNCHER(1 << 5) |
80 | #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \ | 82 | #define SEARCH_IN_ALL (SEARCH_IN_DESC | SEARCH_IN_NAME| \ |
81 | SEARCH_IN_PW | SEARCH_IN_COMMENT| \ | 83 | SEARCH_IN_PW | SEARCH_IN_COMMENT| \ |
82 | SEARCH_IN_URL| SEARCH_IN_LAUNCHER) | 84 | SEARCH_IN_URL| SEARCH_IN_LAUNCHER) |
83 | 85 | ||
84 | /** document deeplocked. Data is out for lunch to disk */ | 86 | /** document deeplocked. Data is out for lunch to disk */ |
85 | #define DOC_STAT_DEEPLOCKED (1) | 87 | #define DOC_STAT_DEEPLOCKED (1) |
86 | /** encrypted document on disk is dirty. data has to go to disk. */ | 88 | /** encrypted document on disk is dirty. data has to go to disk. */ |
87 | #define DOC_STAT_DISK_DIRTY (1 << 1) | 89 | #define DOC_STAT_DISK_DIRTY (1 << 1) |
88 | /** we are using a chipcard to encrypt the data */ | 90 | /** we are using a chipcard to encrypt the data */ |
89 | #define DOC_STAT_USE_CHIPCARD (1 << 2) | 91 | #define DOC_STAT_USE_CHIPCARD (1 << 2) |
90 | /** use "currentPw" to unlock. (This flag is set/unset by a timer) */ | 92 | /** use "currentPw" to unlock. (This flag is set/unset by a timer) */ |
91 | #define DOC_STAT_UNLOCK_WITHOUT_PW(1 << 3) | 93 | #define DOC_STAT_UNLOCK_WITHOUT_PW(1 << 3) |
92 | 94 | ||
93 | class PwMDoc; | 95 | class PwMDoc; |
94 | class PwMView; | 96 | class PwMView; |
95 | class QFile; | 97 | class QFile; |
96 | 98 | ||
97 | /* meta data for a PwMDataItem */ | 99 | /* meta data for a PwMDataItem */ |
98 | struct PwMMetaData | 100 | struct PwMMetaData |
99 | { | 101 | { |
100 | PwMMetaData() | 102 | PwMMetaData() |
101 | : updateInt (0) | 103 | : updateInt (0) |
102 | { } | 104 | { } |
103 | /** creation date of the PwMDataItem to which | 105 | /** creation date of the PwMDataItem to which |
104 | * this meta data belongs. | 106 | * this meta data belongs. |
105 | */ | 107 | */ |
106 | QDateTimecreate; | 108 | QDateTimecreate; |
107 | /** becomes valid on this date */ | 109 | /** becomes valid on this date */ |
108 | QDateTimevalid; | 110 | QDateTimevalid; |
109 | /** expire date */ | 111 | /** expire date */ |
110 | QDateTimeexpire; | 112 | QDateTimeexpire; |
111 | /** update date (last updated at this date) */ | 113 | /** update date (last updated at this date) */ |
112 | QDateTimeupdate; | 114 | QDateTimeupdate; |
113 | /** update interval (in minutes). Time since the | 115 | /** update interval (in minutes). Time since the |
114 | * last update to remind the user to update the item. | 116 | * last update to remind the user to update the item. |
115 | * 0 disables. | 117 | * 0 disables. |
116 | */ | 118 | */ |
117 | unsigned long updateInt; | 119 | unsigned long updateInt; |
118 | 120 | ||
119 | //US ENH: enhancements of the filestructure | 121 | //US ENH: enhancements of the filestructure |
120 | /* each entry gets a unique id assigned */ | 122 | /* each entry gets a unique id assigned */ |
121 | string uniqueid; | 123 | string uniqueid; |
122 | 124 | ||
123 | 125 | ||
124 | void clear() | 126 | void clear() |
125 | { | 127 | { |
126 | create = QDateTime(); | 128 | create = QDateTime(); |
127 | expire = QDateTime(); | 129 | expire = QDateTime(); |
128 | update = QDateTime(); | 130 | update = QDateTime(); |
129 | updateInt = 0; | 131 | updateInt = 0; |
130 | uniqueid = KApplication::randomString(8).latin1(); | 132 | uniqueid = KApplication::randomString(8).latin1(); |
131 | } | 133 | } |
132 | 134 | ||
133 | inline bool isValid() const | 135 | inline bool isValid() const |
134 | { | 136 | { |
135 | if (valid.isNull()) | 137 | if (valid.isNull()) |
136 | return true; | 138 | return true; |
137 | return (valid < QDateTime::currentDateTime()); | 139 | return (valid < QDateTime::currentDateTime()); |
138 | } | 140 | } |
139 | inline bool isExpired() const | 141 | inline bool isExpired() const |
140 | { | 142 | { |
141 | if (expire.isNull()) | 143 | if (expire.isNull()) |
142 | return false; | 144 | return false; |
143 | return (expire < QDateTime::currentDateTime()); | 145 | return (expire < QDateTime::currentDateTime()); |
144 | } | 146 | } |
145 | inline bool isUpdateIntOver() const | 147 | inline bool isUpdateIntOver() const |
146 | { | 148 | { |
147 | if (updateInt == 0 || | 149 | if (updateInt == 0 || |
148 | update.isNull()) | 150 | update.isNull()) |
149 | return false; | 151 | return false; |
150 | QDateTime d(update); | 152 | QDateTime d(update); |
151 | return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime()); | 153 | return (d.addSecs(updateInt * 60) < QDateTime::currentDateTime()); |
152 | } | 154 | } |
153 | }; | 155 | }; |
154 | 156 | ||
155 | struct PwMDataItem | 157 | struct PwMDataItem |
156 | { | 158 | { |
157 | PwMDataItem() | 159 | PwMDataItem() |
158 | : lockStat (true) | 160 | : lockStat (true) |
159 | , listViewPos (-1) | 161 | , listViewPos (-1) |
160 | , binary (false) | 162 | , binary (false) |
161 | , rev (0) | 163 | , rev (0) |
162 | { } | 164 | { } |
163 | 165 | ||
164 | /** password description */ | 166 | /** password description */ |
165 | stringdesc; | 167 | stringdesc; |
166 | /** user-name */ | 168 | /** user-name */ |
167 | stringname; | 169 | stringname; |
168 | /** the password itself */ | 170 | /** the password itself */ |
169 | stringpw; | 171 | stringpw; |
170 | /** some comment */ | 172 | /** some comment */ |
171 | stringcomment; | 173 | stringcomment; |
172 | /** an URL string */ | 174 | /** an URL string */ |
173 | stringurl; | 175 | stringurl; |
174 | /** launcher. Can be executed as a system() command */ | 176 | /** launcher. Can be executed as a system() command */ |
175 | stringlauncher; | 177 | stringlauncher; |
176 | /** locking status. If locked (true), pw is not emitted through getEntry() */ | 178 | /** locking status. If locked (true), pw is not emitted through getEntry() */ |
177 | boollockStat; | 179 | boollockStat; |
178 | /** position of this item in main "list-view" | 180 | /** position of this item in main "list-view" |
179 | * If -1, the position is not yet specified and should be appended to the list | 181 | * If -1, the position is not yet specified and should be appended to the list |
180 | */ | 182 | */ |
181 | intlistViewPos; | 183 | intlistViewPos; |
182 | /** does this entry contain binary data? */ | 184 | /** does this entry contain binary data? */ |
183 | bool binary; | 185 | bool binary; |
184 | /** meta data for this data item. */ | 186 | /** meta data for this data item. */ |
185 | PwMMetaData meta; | 187 | PwMMetaData meta; |
186 | /** data revision counter. This counter can be used | 188 | /** data revision counter. This counter can be used |
187 | * to easily, efficiently determine if this data item | 189 | * to easily, efficiently determine if this data item |
188 | * has changed since some time. | 190 | * has changed since some time. |
189 | * This counter is incremented on every update. | 191 | * This counter is incremented on every update. |
190 | */ | 192 | */ |
191 | unsigned int rev; | 193 | unsigned int rev; |
192 | 194 | ||
193 | void clear(bool clearMeta = true) | 195 | void clear(bool clearMeta = true) |
194 | { | 196 | { |
195 | /* NOTE: Don't use .clear() here to be | 197 | /* NOTE: Don't use .clear() here to be |
196 | * backward compatible with gcc-2 (Debian Woody) | 198 | * backward compatible with gcc-2 (Debian Woody) |
197 | */ | 199 | */ |
198 | desc = ""; | 200 | desc = ""; |
199 | name = ""; | 201 | name = ""; |
200 | pw = ""; | 202 | pw = ""; |
201 | comment = ""; | 203 | comment = ""; |
202 | url = ""; | 204 | url = ""; |
203 | launcher = ""; | 205 | launcher = ""; |
204 | lockStat = true; | 206 | lockStat = true; |
205 | listViewPos = -1; | 207 | listViewPos = -1; |
206 | binary = false; | 208 | binary = false; |
207 | if (clearMeta) | 209 | if (clearMeta) |
208 | meta.clear(); | 210 | meta.clear(); |
209 | } | 211 | } |
210 | //US ENH: we need this operator to compare two items if we have no unique ids | 212 | //US ENH: we need this operator to compare two items if we have no unique ids |
211 | //available. Generaly this happens before the first sync | 213 | //available. Generaly this happens before the first sync |
212 | 214 | ||
213 | bool PwMDataItem::operator==( const PwMDataItem &a ) const | 215 | bool PwMDataItem::operator==( const PwMDataItem &a ) const |
214 | { | 216 | { |
215 | //qDebug("oper==%s", a.desc.c_str()); | 217 | //qDebug("oper==%s", a.desc.c_str()); |
216 | if ( desc != a.desc ) return false; | 218 | if ( desc != a.desc ) return false; |
217 | if ( name != a.name ) return false; | 219 | if ( name != a.name ) return false; |
218 | if ( pw != a.pw ) return false; | 220 | if ( pw != a.pw ) return false; |
219 | if ( comment != a.comment ) return false; | 221 | if ( comment != a.comment ) return false; |
220 | if ( url != a.url ) return false; | 222 | if ( url != a.url ) return false; |
221 | if ( launcher != a.launcher ) return false; | 223 | if ( launcher != a.launcher ) return false; |
222 | //all other field will not be checked. | 224 | //all other field will not be checked. |
223 | return true; | 225 | return true; |
224 | } | 226 | } |
225 | }; | 227 | }; |
226 | 228 | ||
227 | struct PwMCategoryItem | 229 | struct PwMCategoryItem |
228 | { | 230 | { |
229 | /** all PwMDataItems (all passwords) within this category */ | 231 | /** all PwMDataItems (all passwords) within this category */ |
230 | vector<PwMDataItem>d; | 232 | vector<PwMDataItem>d; |
231 | /** category name/description */ | 233 | /** category name/description */ |
232 | string name; | 234 | string name; |
233 | 235 | ||
234 | void clear() | 236 | void clear() |
235 | { | 237 | { |
236 | d.clear(); | 238 | d.clear(); |
237 | name = ""; | 239 | name = ""; |
238 | } | 240 | } |
239 | }; | 241 | }; |
240 | 242 | ||
241 | struct PwMSyncItem | 243 | struct PwMSyncItem |
242 | { | 244 | { |
243 | string syncName; | 245 | string syncName; |
244 | QDateTime lastSyncDate; | 246 | QDateTime lastSyncDate; |
245 | 247 | ||
246 | void clear() | 248 | void clear() |
247 | { | 249 | { |
248 | lastSyncDate = QDateTime(); | 250 | lastSyncDate = QDateTime(); |
249 | syncName = ""; | 251 | syncName = ""; |
250 | } | 252 | } |
251 | }; | 253 | }; |
252 | 254 | ||
253 | struct PwMItem | 255 | struct PwMItem |
254 | { | 256 | { |
255 | vector<PwMCategoryItem> dta; | 257 | vector<PwMCategoryItem> dta; |
256 | vector<PwMSyncItem> syncDta; | 258 | vector<PwMSyncItem> syncDta; |
257 | 259 | ||
258 | void clear() | 260 | void clear() |
259 | { | 261 | { |
260 | dta.clear(); | 262 | dta.clear(); |
261 | syncDta.clear(); | 263 | syncDta.clear(); |
262 | } | 264 | } |
263 | }; | 265 | }; |
264 | 266 | ||
265 | 267 | ||
266 | /** "Function Object" for sort()ing PwMDataItem::listViewPos */ | 268 | /** "Function Object" for sort()ing PwMDataItem::listViewPos */ |
267 | class dta_lvp_greater | 269 | class dta_lvp_greater |
268 | { | 270 | { |
269 | public: | 271 | public: |
270 | bool operator() (const pair<unsigned int, unsigned int> &d1, | 272 | bool operator() (const pair<unsigned int, unsigned int> &d1, |
271 | const pair<unsigned int, unsigned int> &d2) | 273 | const pair<unsigned int, unsigned int> &d2) |
272 | { | 274 | { |
273 | return d1.second > d2.second; | 275 | return d1.second > d2.second; |
274 | } | 276 | } |
275 | }; | 277 | }; |
276 | 278 | ||
277 | /** list of PwMDoc documents and it's IDs */ | 279 | /** list of PwMDoc documents and it's IDs */ |
278 | class PwMDocList | 280 | class PwMDocList |
279 | { | 281 | { |
280 | public: | 282 | public: |
281 | struct listItem | 283 | struct listItem |
282 | { | 284 | { |
283 | /** document filename (known as ID, here) */ | 285 | /** document filename (known as ID, here) */ |
284 | string docId; | 286 | string docId; |
285 | /** pointer to the document class */ | 287 | /** pointer to the document class */ |
286 | PwMDoc *doc; | 288 | PwMDoc *doc; |
287 | }; | 289 | }; |
288 | 290 | ||
289 | PwMDocList() {} | 291 | PwMDocList() {} |
290 | 292 | ||
291 | /** add a new item to the list */ | 293 | /** add a new item to the list */ |
292 | void add(PwMDoc *doc, const string &id); | 294 | void add(PwMDoc *doc, const string &id); |
293 | /** changes the contents of an existing item */ | 295 | /** changes the contents of an existing item */ |
294 | void edit(PwMDoc *doc, const string &newId); | 296 | void edit(PwMDoc *doc, const string &newId); |
295 | /** remove the given item */ | 297 | /** remove the given item */ |
296 | void del(PwMDoc *doc); | 298 | void del(PwMDoc *doc); |
297 | /** get the item at index */ | 299 | /** get the item at index */ |
298 | listItem getAt(int index) | 300 | listItem getAt(int index) |
299 | { return docList[index]; } | 301 | { return docList[index]; } |
300 | /** find an entry with this id */ | 302 | /** find an entry with this id */ |
301 | bool find(const string &id, listItem *ret = 0); | 303 | bool find(const string &id, listItem *ret = 0); |
302 | /** returns a copy of the list */ | 304 | /** returns a copy of the list */ |
303 | const vector<listItem>* getList() const | 305 | const vector<listItem>* getList() const |
304 | { return &docList; } | 306 | { return &docList; } |
305 | 307 | ||
306 | 308 | ||
307 | /** returns a new unique number to extend the name of | 309 | /** returns a new unique number to extend the name of |
308 | * an unnamed document. | 310 | * an unnamed document. |
309 | */ | 311 | */ |
310 | static unsigned int getNewUnnamedNumber() | 312 | static unsigned int getNewUnnamedNumber() |
311 | { return unnamedDocCnt++; } | 313 | { return unnamedDocCnt++; } |
312 | 314 | ||
313 | protected: | 315 | protected: |
314 | /* Hm, I think we shouldn't really use a "list" here, should we? | 316 | /* Hm, I think we shouldn't really use a "list" here, should we? |
315 | * So I decided to actually use a vector. | 317 | * So I decided to actually use a vector. |
316 | */ | 318 | */ |
317 | vector<listItem> docList; | 319 | vector<listItem> docList; |
318 | /** This value is used to get a new number for yet unnamed | 320 | /** This value is used to get a new number for yet unnamed |
319 | * documents. It is incremented on every request. So it's | 321 | * documents. It is incremented on every request. So it's |
320 | * theoretically possible to overflow it, but... :) | 322 | * theoretically possible to overflow it, but... :) |
321 | */ | 323 | */ |
322 | static unsigned int unnamedDocCnt; | 324 | static unsigned int unnamedDocCnt; |
323 | }; | 325 | }; |
324 | 326 | ||
325 | /** implements timers for the document */ | 327 | /** implements timers for the document */ |
326 | class DocTimer : public QObject | 328 | class DocTimer : public QObject |
327 | { | 329 | { |
328 | Q_OBJECT | 330 | Q_OBJECT |
329 | public: | 331 | public: |
330 | enum TimerIDs | 332 | enum TimerIDs |
331 | { | 333 | { |
332 | id_mpwTimer, | 334 | id_mpwTimer, |
333 | id_autoLockTimer, | 335 | id_autoLockTimer, |
334 | id_metaCheckTimer | 336 | id_metaCheckTimer |
335 | }; | 337 | }; |
336 | 338 | ||
337 | public: | 339 | public: |
338 | DocTimer(PwMDoc *_doc); | 340 | DocTimer(PwMDoc *_doc); |
339 | ~DocTimer(); | 341 | ~DocTimer(); |
340 | 342 | ||
341 | /** start the timer */ | 343 | /** start the timer */ |
342 | void start(TimerIDs timer); | 344 | void start(TimerIDs timer); |
343 | /** stop the timer */ | 345 | /** stop the timer */ |
344 | void stop(TimerIDs timer); | 346 | void stop(TimerIDs timer); |
345 | /** get the lock for a timer. | 347 | /** get the lock for a timer. |
346 | * This lock is a recursive lock. When a lock is | 348 | * This lock is a recursive lock. When a lock is |
347 | * held, the timer will be stopped and timeout is | 349 | * held, the timer will be stopped and timeout is |
348 | * guaranteed to not happen | 350 | * guaranteed to not happen |
349 | */ | 351 | */ |
350 | void getLock(TimerIDs timer); | 352 | void getLock(TimerIDs timer); |
351 | /** put a recursive timer lock */ | 353 | /** put a recursive timer lock */ |
352 | void putLock(TimerIDs timer); | 354 | void putLock(TimerIDs timer); |
353 | 355 | ||
354 | protected slots: | 356 | protected slots: |
355 | /** timeout slot for the mpw timer */ | 357 | /** timeout slot for the mpw timer */ |
356 | void mpwTimeout(); | 358 | void mpwTimeout(); |
357 | /** timeout slot for the autoLock timer */ | 359 | /** timeout slot for the autoLock timer */ |
358 | void autoLockTimeout(); | 360 | void autoLockTimeout(); |
359 | /** timeout slot for the metaCheck timer */ | 361 | /** timeout slot for the metaCheck timer */ |
360 | void metaCheckTimeout(); | 362 | void metaCheckTimeout(); |
361 | 363 | ||
362 | protected: | 364 | protected: |
363 | /** pointer to the document associated with this timer. */ | 365 | /** pointer to the document associated with this timer. */ |
364 | PwMDoc *doc; | 366 | PwMDoc *doc; |
365 | /** timer object for mpw timer */ | 367 | /** timer object for mpw timer */ |
366 | QTimer *mpwTimer; | 368 | QTimer *mpwTimer; |
367 | /** timer object for the autoLock timer */ | 369 | /** timer object for the autoLock timer */ |
368 | QTimer *autoLockTimer; | 370 | QTimer *autoLockTimer; |
369 | /** timer object for the metaCheck timer */ | 371 | /** timer object for the metaCheck timer */ |
370 | QTimer *metaCheckTimer; | 372 | QTimer *metaCheckTimer; |
371 | /** lock counter for the mpw timer */ | 373 | /** lock counter for the mpw timer */ |
372 | unsigned int mpwLock; | 374 | unsigned int mpwLock; |
373 | /** lock counter for the autoLock timer */ | 375 | /** lock counter for the autoLock timer */ |
374 | unsigned int autoLockLock; | 376 | unsigned int autoLockLock; |
375 | /** lock counter for the metaCheck timer */ | 377 | /** lock counter for the metaCheck timer */ |
376 | unsigned int metaCheckLock; | 378 | unsigned int metaCheckLock; |
377 | }; | 379 | }; |
378 | 380 | ||
379 | /** Document class for PwM */ | 381 | /** Document class for PwM */ |
380 | //US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required. | 382 | //US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required. |
381 | // But PwMDoc is handling the sync by itself. | 383 | // But PwMDoc is handling the sync by itself. |
382 | class PwMDoc : public PwMDocUi, public KSyncInterface | 384 | class PwMDoc : public PwMDocUi, public KSyncInterface |
383 | 385 | ||
384 | { | 386 | { |
385 | Q_OBJECT | 387 | Q_OBJECT |
386 | friend class DocTimer; | 388 | friend class DocTimer; |
387 | 389 | ||
388 | public: | 390 | public: |
389 | /** construtor */ | 391 | /** construtor */ |
390 | PwMDoc(QObject* parent = 0, const char *name = 0); | 392 | PwMDoc(QObject* parent = 0, const char *name = 0); |
391 | /** destructor */ | 393 | /** destructor */ |
392 | ~PwMDoc(); | 394 | ~PwMDoc(); |
393 | 395 | ||
394 | /** returns a pointer to a list of all open documents */ | 396 | /** returns a pointer to a list of all open documents */ |
395 | static PwMDocList* getOpenDocList() | 397 | static PwMDocList* getOpenDocList() |
396 | { return &openDocList; } | 398 | { return &openDocList; } |
397 | 399 | ||
398 | /** flag document dirty. dta changed */ | 400 | /** flag document dirty. dta changed */ |
399 | void flagDirty() | 401 | void flagDirty() |
400 | { | 402 | { |
401 | setDocStatFlag(DOC_STAT_DISK_DIRTY); | 403 | setDocStatFlag(DOC_STAT_DISK_DIRTY); |
402 | emitDataChanged(this); | 404 | emitDataChanged(this); |
403 | } | 405 | } |
404 | /** modified? */ | 406 | /** modified? */ |
405 | bool isDirty() | 407 | bool isDirty() |
406 | { return getDocStatFlag(DOC_STAT_DISK_DIRTY); } | 408 | { return getDocStatFlag(DOC_STAT_DISK_DIRTY); } |
407 | /** save document to disk */ | 409 | /** save document to disk */ |
408 | PwMerror saveDoc(char compress, const QString *file = 0); | 410 | PwMerror saveDoc(char compress, const QString *file = 0); |
409 | /** read document from file. | 411 | /** read document from file. |
410 | * "openLocked is must be set to either of these values: | 412 | * "openLocked is must be set to either of these values: |
411 | * 0 == open with all entries unlocked | 413 | * 0 == open with all entries unlocked |
412 | * 1 == open with all entries locked | 414 | * 1 == open with all entries locked |
413 | * 2 == open deep-locked | 415 | * 2 == open deep-locked |
414 | */ | 416 | */ |
415 | PwMerror openDoc(const QString *file, int openLocked); | 417 | PwMerror openDoc(const QString *file, int openLocked); |
416 | /** export document to ascii-textfile */ | 418 | /** export document to ascii-textfile */ |
417 | PwMerror exportToText(const QString *file); | 419 | PwMerror exportToText(const QString *file); |
418 | /** export document to gpasman / kpasman file */ | 420 | /** export document to gpasman / kpasman file */ |
419 | PwMerror exportToGpasman(const QString *file); | 421 | PwMerror exportToGpasman(const QString *file); |
420 | /** import document from ascii-textfile */ | 422 | /** import document from ascii-textfile */ |
421 | PwMerror importFromText(const QString *file, int format = -1); | 423 | PwMerror importFromText(const QString *file, int format = -1); |
422 | /** import document from gpasman / kpasman file */ | 424 | /** import document from gpasman / kpasman file */ |
423 | PwMerror importFromGpasman(const QString *file); | 425 | PwMerror importFromGpasman(const QString *file); |
424 | /** add new entry */ | 426 | /** add new entry */ |
425 | PwMerror addEntry(const QString &category, PwMDataItem *d, | 427 | PwMerror addEntry(const QString &category, PwMDataItem *d, |
426 | bool dontFlagDirty = false, bool updateMeta = true); | 428 | bool dontFlagDirty = false, bool updateMeta = true); |
427 | /** add new category. This function doesn't flag the document dirty! */ | 429 | /** add new category. This function doesn't flag the document dirty! */ |
428 | PwMerror addCategory(const QString &category, unsigned int *categoryIndex, | 430 | PwMerror addCategory(const QString &category, unsigned int *categoryIndex, |
429 | bool checkIfExist = true); | 431 | bool checkIfExist = true); |
430 | /** rename an existing category */ | 432 | /** rename an existing category */ |
431 | bool renameCategory(const QString &category, const QString &newName); | 433 | bool renameCategory(const QString &category, const QString &newName); |
432 | /** rename an existing category */ | 434 | /** rename an existing category */ |
433 | bool renameCategory(unsigned int category, const QString &newName, | 435 | bool renameCategory(unsigned int category, const QString &newName, |
434 | bool dontFlagDirty = false); | 436 | bool dontFlagDirty = false); |
435 | /** delete an existing category */ | 437 | /** delete an existing category */ |
436 | bool delCategory(const QString &category); | 438 | bool delCategory(const QString &category); |
437 | /** delete an existing category */ | 439 | /** delete an existing category */ |
438 | bool delCategory(unsigned int category, bool dontFlagDirty = false); | 440 | bool delCategory(unsigned int category, bool dontFlagDirty = false); |
439 | /** returns a list of all category-names */ | 441 | /** returns a list of all category-names */ |
440 | void getCategoryList(vector<string> *list); | 442 | void getCategoryList(vector<string> *list); |
441 | /** returns a list of all category-names */ | 443 | /** returns a list of all category-names */ |
442 | void getCategoryList(QStringList *list); | 444 | void getCategoryList(QStringList *list); |
443 | /** returns a list of all entry-descs in the given category */ | 445 | /** returns a list of all entry-descs in the given category */ |
444 | void getEntryList(const QString &category, QStringList *list); | 446 | void getEntryList(const QString &category, QStringList *list); |
445 | /** returns a list of all entry-descs in the given category */ | 447 | /** returns a list of all entry-descs in the given category */ |
446 | void getEntryList(const QString &category, vector<string> *list); | 448 | void getEntryList(const QString &category, vector<string> *list); |
447 | /** returns a list of all entry-descs in the given category */ | 449 | /** returns a list of all entry-descs in the given category */ |
448 | void getEntryList(unsigned int category, vector<string> *list); | 450 | void getEntryList(unsigned int category, vector<string> *list); |
449 | /** returns a list of all entry-descs in the given category */ | 451 | /** returns a list of all entry-descs in the given category */ |
450 | void getEntryList(unsigned int category, QStringList *list); | 452 | void getEntryList(unsigned int category, QStringList *list); |
451 | /** delete entry */ | 453 | /** delete entry */ |
452 | bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false); | 454 | bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false); |
453 | /** delete entry */ | 455 | /** delete entry */ |
454 | bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false); | 456 | bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false); |
455 | /** edit entry */ | 457 | /** edit entry */ |
456 | bool editEntry(const QString &oldCategory, const QString &newCategory, | 458 | bool editEntry(const QString &oldCategory, const QString &newCategory, |
457 | unsigned int index, PwMDataItem *d, bool updateMeta = true); | 459 | unsigned int index, PwMDataItem *d, bool updateMeta = true); |
458 | /** edit entry */ | 460 | /** edit entry */ |
459 | bool editEntry(unsigned int oldCategory, const QString &newCategory, | 461 | bool editEntry(unsigned int oldCategory, const QString &newCategory, |
460 | unsigned int index, PwMDataItem *d, bool updateMeta = true); | 462 | unsigned int index, PwMDataItem *d, bool updateMeta = true); |
461 | /** finds the category with the "name" and return it's index */ | 463 | /** finds the category with the "name" and return it's index */ |
462 | bool findCategory(const QString &name, unsigned int *index); | 464 | bool findCategory(const QString &name, unsigned int *index); |
463 | /** search for an entry "find" and check while searching only for | 465 | /** search for an entry "find" and check while searching only for |
464 | * the data-fields specified by "searchIn". To set the "searchIn" | 466 | * the data-fields specified by "searchIn". To set the "searchIn" |
465 | * value, we may use one or more of the SEARCH_IN_* defines at | 467 | * value, we may use one or more of the SEARCH_IN_* defines at |
466 | * the top of this header-file. It returns the positions of all | 468 | * the top of this header-file. It returns the positions of all |
467 | * matched entries in "foundPositions". If "breakAfterFound" is true, | 469 | * matched entries in "foundPositions". If "breakAfterFound" is true, |
468 | * the function terminates after the first occurence of the entry | 470 | * the function terminates after the first occurence of the entry |
469 | * and doesn't go on searching. So foundPositions->size() is never | 471 | * and doesn't go on searching. So foundPositions->size() is never |
470 | * > 1 if breakAfterFound is true. | 472 | * > 1 if breakAfterFound is true. |
471 | */ | 473 | */ |
472 | void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, | 474 | void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, |
473 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, | 475 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, |
474 | bool caseSensitive = true, bool exactWordMatch = true, | 476 | bool caseSensitive = true, bool exactWordMatch = true, |
475 | bool sortByLvp = false); | 477 | bool sortByLvp = false); |
476 | /** see the above funtion. This function allows to set the category by name. */ | 478 | /** see the above funtion. This function allows to set the category by name. */ |
477 | void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, | 479 | void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, |
478 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, | 480 | vector<unsigned int> *foundPositions, bool breakAfterFound = false, |
479 | bool caseSensitive = true, bool exactWordMatch = true, | 481 | bool caseSensitive = true, bool exactWordMatch = true, |
480 | bool sortByLvp = false); | 482 | bool sortByLvp = false); |
481 | /** returns number of entries */ | 483 | /** returns number of entries */ |
482 | unsigned int numEntries(const QString &category); | 484 | unsigned int numEntries(const QString &category); |
483 | unsigned int numEntries(unsigned int category) | 485 | unsigned int numEntries(unsigned int category) |
484 | { return dti.dta[category].d.size(); } | 486 | { return dti.dta[category].d.size(); } |
485 | /** returns number of categories */ | 487 | /** returns number of categories */ |
486 | unsigned int numCategories() | 488 | unsigned int numCategories() |
487 | { return dti.dta.size(); } | 489 | { return dti.dta.size(); } |
488 | /** returns the name of the category at "index" */ | 490 | /** returns the name of the category at "index" */ |
489 | const string* getCategory(unsigned int index) | 491 | const string* getCategory(unsigned int index) |
490 | { return (&(dti.dta[index].name)); } | 492 | { return (&(dti.dta[index].name)); } |
491 | 493 | ||
492 | /** returns the data of item at "index". | 494 | /** returns the data of item at "index". |
493 | * It unlocks the entry if it's locked and unlockIfLocked is true. | 495 | * It unlocks the entry if it's locked and unlockIfLocked is true. |
494 | * If the entry is locked, but unlockIfLocked is false, it'll not return | 496 | * If the entry is locked, but unlockIfLocked is false, it'll not return |
495 | * the pw. | 497 | * the pw. |
496 | */ | 498 | */ |
497 | bool getEntry(const QString &category, unsigned int index, | 499 | bool getEntry(const QString &category, unsigned int index, |
498 | PwMDataItem *d, bool unlockIfLocked = false); | 500 | PwMDataItem *d, bool unlockIfLocked = false); |
499 | bool getEntry(unsigned int category, unsigned int index, | 501 | bool getEntry(unsigned int category, unsigned int index, |
500 | PwMDataItem *d, bool unlockIfLocked = false); | 502 | PwMDataItem *d, bool unlockIfLocked = false); |
501 | /** returns the comment-string by looking at the category | 503 | /** returns the comment-string by looking at the category |
502 | * and the listViewPos | 504 | * and the listViewPos |
503 | */ | 505 | */ |
504 | PwMerror getCommentByLvp(const QString &category, int listViewPos, | 506 | PwMerror getCommentByLvp(const QString &category, int listViewPos, |
505 | string *foundComment); | 507 | string *foundComment); |
506 | /** checks if a password is already available. (currentPw) */ | 508 | /** checks if a password is already available. (currentPw) */ |
507 | bool isPwAvailable() | 509 | bool isPwAvailable() |
508 | { return (currentPw != ""); } | 510 | { return (currentPw != ""); } |
509 | /** un/lock entry at "index". If needed, ask for password. */ | 511 | /** un/lock entry at "index". If needed, ask for password. */ |
510 | bool lockAt(const QString &category, unsigned int index, | 512 | bool lockAt(const QString &category, unsigned int index, |
511 | bool lock = true); | 513 | bool lock = true); |
512 | bool lockAt(unsigned int category, unsigned int index, | 514 | bool lockAt(unsigned int category, unsigned int index, |
513 | bool lock = true); | 515 | bool lock = true); |
514 | /** returns the lock-status at "index" */ | 516 | /** returns the lock-status at "index" */ |
515 | bool isLocked(const QString &category, unsigned int index); | 517 | bool isLocked(const QString &category, unsigned int index); |
516 | bool isLocked(unsigned int category, unsigned int index) | 518 | bool isLocked(unsigned int category, unsigned int index) |
517 | { return dti.dta[category].d[index].lockStat; } | 519 | { return dti.dta[category].d[index].lockStat; } |
518 | /** returns the deeplock status */ | 520 | /** returns the deeplock status */ |
519 | bool isDeepLocked() | 521 | bool isDeepLocked() |
520 | { return getDocStatFlag(DOC_STAT_DEEPLOCKED); } | 522 | { return getDocStatFlag(DOC_STAT_DEEPLOCKED); } |
521 | /** (un)lock all entries */ | 523 | /** (un)lock all entries */ |
522 | bool lockAll(bool lock); | 524 | bool lockAll(bool lock); |
523 | /** unlocks all entries tempoarly. | 525 | /** unlocks all entries tempoarly. |
524 | * 1st NOTE: Be very careful with this function! :) | 526 | * 1st NOTE: Be very careful with this function! :) |
525 | * 2nd NOTE: After you have called unlockAll_Tempoary(); , | 527 | * 2nd NOTE: After you have called unlockAll_Tempoary(); , |
526 | * please DON'T forget to call unlockAll_Tempoary(true); | 528 | * please DON'T forget to call unlockAll_Tempoary(true); |
527 | * _before_ the user (or someone else) is able to change | 529 | * _before_ the user (or someone else) is able to change |
528 | * the document! | 530 | * the document! |
529 | * 3rd NOTE: Please DON'T change "dta" while the data is tempoary | 531 | * 3rd NOTE: Please DON'T change "dta" while the data is tempoary |
530 | * unlocked! This will cause corruption. | 532 | * unlocked! This will cause corruption. |
531 | */ | 533 | */ |
532 | bool unlockAll_tempoary(bool revert = false); | 534 | bool unlockAll_tempoary(bool revert = false); |
533 | /** deep-(un)locks the document. | 535 | /** deep-(un)locks the document. |
534 | * deep-locking writes all data to the file, deletes all data | 536 | * deep-locking writes all data to the file, deletes all data |
535 | * in memory, but doesn't close the document. | 537 | * in memory, but doesn't close the document. |
536 | * deep-locking is only available, if the user previously saved | 538 | * deep-locking is only available, if the user previously saved |
537 | * the doc to a file (with a password). | 539 | * the doc to a file (with a password). |
538 | * If "saveToFile" is false, it does NOT write the data to the file! | 540 | * If "saveToFile" is false, it does NOT write the data to the file! |
539 | */ | 541 | */ |
540 | PwMerror deepLock(bool lock = true, bool saveToFile = true); | 542 | PwMerror deepLock(bool lock = true, bool saveToFile = true); |
541 | /** is unlockable without pw? */ | 543 | /** is unlockable without pw? */ |
542 | bool unlockWoPw() | 544 | bool unlockWoPw() |
543 | { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); } | 545 | { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); } |
544 | /** get the "currentPassword" */ | 546 | /** get the "currentPassword" */ |
545 | const QString& getCurrentPw() | 547 | const QString& getCurrentPw() |
546 | { return currentPw; } | 548 | { return currentPw; } |
547 | /** open a window and request the user to change the mpw */ | 549 | /** open a window and request the user to change the mpw */ |
548 | void changeCurrentPw(); | 550 | void changeCurrentPw(); |
549 | /** set the "listViewPos" variable of "dta" */ | 551 | /** set the "listViewPos" variable of "dta" */ |
550 | void setListViewPos(const QString &category, unsigned int index, | 552 | void setListViewPos(const QString &category, unsigned int index, |
551 | int pos); | 553 | int pos); |
552 | /** set the "listViewPos" variable of "dta" */ | 554 | /** set the "listViewPos" variable of "dta" */ |
553 | void setListViewPos(unsigned int category, unsigned int index, | 555 | void setListViewPos(unsigned int category, unsigned int index, |
554 | int pos); | 556 | int pos); |
555 | /** get the "listViewPos" variable of "dta" */ | 557 | /** get the "listViewPos" variable of "dta" */ |
556 | int getListViewPos(const QString &category, unsigned int index); | 558 | int getListViewPos(const QString &category, unsigned int index); |
557 | /** set the maximum number of entries allowed */ | 559 | /** set the maximum number of entries allowed */ |
558 | void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES) | 560 | void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES) |
559 | { maxEntries = num; } | 561 | { maxEntries = num; } |
560 | /** get the maximum number of entries allowed */ | 562 | /** get the maximum number of entries allowed */ |
561 | unsigned int getMaxNumEntries() | 563 | unsigned int getMaxNumEntries() |
562 | { return maxEntries; } | 564 | { return maxEntries; } |
563 | /** ensure all listViewPos of all dta items are set. (are ! -1). | 565 | /** ensure all listViewPos of all dta items are set. (are ! -1). |
564 | * If there are some undefined entries, add them to the end of | 566 | * If there are some undefined entries, add them to the end of |
565 | * the listViewPos(itions). */ | 567 | * the listViewPos(itions). */ |
566 | void ensureLvp(); | 568 | void ensureLvp(); |
567 | /** execute the "launcher" of this entry */ | 569 | /** execute the "launcher" of this entry */ |
568 | bool execLauncher(const QString &category, unsigned int entryIndex); | 570 | bool execLauncher(const QString &category, unsigned int entryIndex); |
569 | /** see above */ | 571 | /** see above */ |
570 | bool execLauncher(unsigned int category, unsigned int entryIndex); | 572 | bool execLauncher(unsigned int category, unsigned int entryIndex); |
571 | /** open a browser with the URL-section of the given entry */ | 573 | /** open a browser with the URL-section of the given entry */ |
572 | bool goToURL(const QString &category, unsigned int entryIndex); | 574 | bool goToURL(const QString &category, unsigned int entryIndex); |
573 | /** see above */ | 575 | /** see above */ |
574 | bool goToURL(unsigned int category, unsigned int entryIndex); | 576 | bool goToURL(unsigned int category, unsigned int entryIndex); |
575 | /** returns true if there is no entry present in the document. | 577 | /** returns true if there is no entry present in the document. |
576 | * Note: The "default" Category is present everytime, so | 578 | * Note: The "default" Category is present everytime, so |
577 | * it's checked for it's entries. | 579 | * it's checked for it's entries. |
578 | */ | 580 | */ |
579 | bool isDocEmpty() | 581 | bool isDocEmpty() |
580 | { | 582 | { |
581 | if (numCategories() > 1) | 583 | if (numCategories() > 1) |
582 | return false; | 584 | return false; |
583 | if (numEntries(0)) | 585 | if (numEntries(0)) |
584 | return false; | 586 | return false; |
585 | return true; | 587 | return true; |
586 | } | 588 | } |
587 | /** returns the filename of this doc */ | 589 | /** returns the filename of this doc */ |
588 | const QString& getFilename() | 590 | const QString& getFilename() |
589 | { return filename; } | 591 | { return filename; } |
590 | /** returns the title of the doc */ | 592 | /** returns the title of the doc */ |
591 | QString getTitle(); | 593 | QString getTitle(); |
592 | /** sets the list-view-pointer hold in the doc */ | 594 | /** sets the list-view-pointer hold in the doc */ |
593 | void setListViewPointer(PwMView *_listView) | 595 | void setListViewPointer(PwMView *_listView) |
594 | { listView = _listView; } | 596 | { listView = _listView; } |
595 | /** returns the list-view-pointer */ | 597 | /** returns the list-view-pointer */ |
596 | PwMView * getListViewPointer() | 598 | PwMView * getListViewPointer() |
597 | { return listView; } | 599 | { return listView; } |
598 | /** try to delete the doc. The user may be asked to save | 600 | /** try to delete the doc. The user may be asked to save |
599 | * the data. The user may cancel the whole operation. | 601 | * the data. The user may cancel the whole operation. |
600 | * false is returned, then. | 602 | * false is returned, then. |
601 | */ | 603 | */ |
602 | bool tryDelete(); | 604 | bool tryDelete(); |
603 | /** is the doc deleted? (with tryDelete() ) */ | 605 | /** is the doc deleted? (with tryDelete() ) */ |
604 | bool isDeleted() | 606 | bool isDeleted() |
605 | { return deleted; } | 607 | { return deleted; } |
606 | /** returns the document timer object */ | 608 | /** returns the document timer object */ |
607 | DocTimer * timer() | 609 | DocTimer * timer() |
608 | { return _timer; } | 610 | { return _timer; } |
609 | /** get a lock on the dataChanged signal. | 611 | /** get a lock on the dataChanged signal. |
610 | * If someone is holding a lock, the signal is not emitted. | 612 | * If someone is holding a lock, the signal is not emitted. |
611 | */ | 613 | */ |
612 | void getDataChangedLock() | 614 | void getDataChangedLock() |
613 | { ++dataChangedLock; } | 615 | { ++dataChangedLock; } |
614 | /** put the dataChanged lock */ | 616 | /** put the dataChanged lock */ |
615 | void putDataChangedLock() | 617 | void putDataChangedLock() |
616 | { --dataChangedLock; } | 618 | { --dataChangedLock; } |
617 | /** returns the revision count of the item at cat/index */ | 619 | /** returns the revision count of the item at cat/index */ |
618 | unsigned int getEntryRevCnt(unsigned int category, unsigned int index) | 620 | unsigned int getEntryRevCnt(unsigned int category, unsigned int index) |
619 | { return dti.dta[category].d[index].rev; } | 621 | { return dti.dta[category].d[index].rev; } |
620 | /** returns a const pointer to the entries meta */ | 622 | /** returns a const pointer to the entries meta */ |
621 | const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index) | 623 | const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index) |
622 | { return &(dti.dta[category].d[index].meta); } | 624 | { return &(dti.dta[category].d[index].meta); } |
623 | /** is the entry at "category" "index" a binary entry? */ | 625 | /** is the entry at "category" "index" a binary entry? */ |
624 | bool isBinEntry(unsigned int category, unsigned int index) | 626 | bool isBinEntry(unsigned int category, unsigned int index) |
625 | { return dti.dta[category].d[index].binary; } | 627 | { return dti.dta[category].d[index].binary; } |
626 | 628 | ||
627 | public slots: | 629 | public slots: |
628 | /** wrapper for PwMTray */ | 630 | /** wrapper for PwMTray */ |
629 | void _deepUnlock(); | 631 | void _deepUnlock(); |
630 | 632 | ||
631 | signals: | 633 | signals: |
632 | /** the data of the document has changed and must be updated | 634 | /** the data of the document has changed and must be updated |
633 | * in all views. | 635 | * in all views. |
634 | * NOTE: use emitDataChanged(PwMDoc *document) to emit this signal! | 636 | * NOTE: use emitDataChanged(PwMDoc *document) to emit this signal! |
635 | */ | 637 | */ |
636 | void dataChanged(PwMDoc *document); | 638 | void dataChanged(PwMDoc *document); |
637 | /** the document class is going to close. This signal may be | 639 | /** the document class is going to close. This signal may be |
638 | * used to nofify all views, that the user closed the document, | 640 | * used to nofify all views, that the user closed the document, |
639 | * so the views can go down, too. | 641 | * so the views can go down, too. |
640 | */ | 642 | */ |
641 | void docClosed(PwMDoc *document); | 643 | void docClosed(PwMDoc *document); |
642 | /** somebody just opened the document */ | 644 | /** somebody just opened the document */ |
643 | void docOpened(PwMDoc *document); | 645 | void docOpened(PwMDoc *document); |
644 | /** this document object just got created */ | 646 | /** this document object just got created */ |
645 | void docCreated(PwMDoc *document); | 647 | void docCreated(PwMDoc *document); |
646 | 648 | ||
647 | public: | 649 | public: |
648 | /** emit the dataChanged signal after checking for a lock */ | 650 | /** emit the dataChanged signal after checking for a lock */ |
649 | void emitDataChanged(PwMDoc *document) | 651 | void emitDataChanged(PwMDoc *document) |
650 | { | 652 | { |
651 | if (!dataChangedLock) | 653 | if (!dataChangedLock) |
652 | emit dataChanged(document); | 654 | emit dataChanged(document); |
653 | } | 655 | } |
654 | 656 | ||
655 | protected: | 657 | protected: |
656 | /** current file for this doc */ | 658 | /** current file for this doc */ |
657 | QString filename; | 659 | QString filename; |
658 | //US ENH: we need a place where we keep the syncentries. So I invented | 660 | //US ENH: we need a place where we keep the syncentries. So I invented |
659 | // struct PwMItem, that has a vector of PwMCategoryItem and vector of PwMSyncItem | 661 | // struct PwMItem, that has a vector of PwMCategoryItem and vector of PwMSyncItem |
660 | /** holds all data */ | 662 | /** holds all data */ |
661 | PwMItem dti; | 663 | PwMItem dti; |
662 | /** maximum number of entries */ | 664 | /** maximum number of entries */ |
663 | unsigned int maxEntries; | 665 | unsigned int maxEntries; |
664 | /** currently used password to encrypt data */ | 666 | /** currently used password to encrypt data */ |
665 | QString currentPw; | 667 | QString currentPw; |
666 | /** current global document status flags */ | 668 | /** current global document status flags */ |
667 | unsigned int curDocStat; | 669 | unsigned int curDocStat; |
668 | /** browser process for goToURL() */ | 670 | /** browser process for goToURL() */ |
669 | KProcess browserProc; | 671 | KProcess browserProc; |
670 | /** pointer to the list-view, using this document. | 672 | /** pointer to the list-view, using this document. |
671 | * As there can only be one list-view per doc, we | 673 | * As there can only be one list-view per doc, we |
672 | * don't need a list here. | 674 | * don't need a list here. |
673 | */ | 675 | */ |
674 | PwMView *listView; | 676 | PwMView *listView; |
675 | /** unnamedNum is used to store the "unnamed counter" | 677 | /** unnamedNum is used to store the "unnamed counter" |
676 | * for this document, while it's unnamed. If it's 0, | 678 | * for this document, while it's unnamed. If it's 0, |
677 | * we have to get a new unique one. | 679 | * we have to get a new unique one. |
678 | */ | 680 | */ |
679 | unsigned int unnamedNum; | 681 | unsigned int unnamedNum; |
680 | /** is this doc going to be deleted (executing in destructor context) */ | 682 | /** is this doc going to be deleted (executing in destructor context) */ |
681 | bool deleted; | 683 | bool deleted; |
682 | /** document timer */ | 684 | /** document timer */ |
683 | DocTimer *_timer; | 685 | DocTimer *_timer; |
684 | /** lock counter for the "dataChanged" signal */ | 686 | /** lock counter for the "dataChanged" signal */ |
685 | unsigned int dataChangedLock; | 687 | unsigned int dataChangedLock; |
686 | 688 | ||
687 | /** list of all open documents */ | 689 | /** list of all open documents */ |
688 | static PwMDocList openDocList; | 690 | static PwMDocList openDocList; |
689 | 691 | ||
690 | protected: | 692 | protected: |
691 | /** serialize "dta" and return it in "d". */ | 693 | /** serialize "dta" and return it in "d". */ |
692 | bool serializeDta(string *d); | 694 | bool serializeDta(string *d); |
693 | /** de-serialize "d" and overwrite "dta" */ | 695 | /** de-serialize "d" and overwrite "dta" */ |
694 | bool deSerializeDta(const string *d, bool entriesLocked); | 696 | bool deSerializeDta(const string *d, bool entriesLocked); |
695 | /** write header to file */ | 697 | /** write header to file */ |
696 | PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress, | 698 | PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress, |
697 | QString *pw, QFile *f); | 699 | QString *pw, QFile *f); |
698 | /** write data-hash to file */ | 700 | /** write data-hash to file */ |
699 | PwMerror writeDataHash(char dataHash, string *d, QFile *f); | 701 | PwMerror writeDataHash(char dataHash, string *d, QFile *f); |
700 | /** check header. Read header info and verify key-hash and filever. | 702 | /** check header. Read header info and verify key-hash and filever. |
701 | * returns length of header in "headerLength" */ | 703 | * returns length of header in "headerLength" */ |
702 | PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress, | 704 | PwMerror checkHeader(char *cryptAlgo, QString *pw, char *compress, |
703 | unsigned int *headerLength, char *dataHashType, | 705 | unsigned int *headerLength, char *dataHashType, |
704 | string *dataHash, QFile *f); | 706 | string *dataHash, QFile *f); |
705 | /** check the data-hash */ | 707 | /** check the data-hash */ |
706 | PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream); | 708 | PwMerror checkDataHash(char dataHashType, const string *dataHash, const string *dataStream); |
707 | /** encrypt data "d" and write to "filename" */ | 709 | /** encrypt data "d" and write to "filename" */ |
708 | PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo); | 710 | PwMerror encrypt(string *d, const QString *pw, QFile *f, char algo); |
709 | /** read data from file beginning at "pos", decrypt and return it */ | 711 | /** read data from file beginning at "pos", decrypt and return it */ |
710 | PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, QFile *f); | 712 | PwMerror decrypt(string *d, unsigned int pos, const QString *pw, char algo, QFile *f); |
711 | /** compress the data */ | 713 | /** compress the data */ |
712 | bool compressDta(string *d, char algo); | 714 | bool compressDta(string *d, char algo); |
713 | /** uncompress the data */ | 715 | /** uncompress the data */ |
714 | bool decompressDta(string *d, char algo); | 716 | bool decompressDta(string *d, char algo); |
715 | /** internal import function for a text-file generated by PwM. | 717 | /** internal import function for a text-file generated by PwM. |
716 | * If this is not a valid PwM-exported file, it returns e_fileFormat */ | 718 | * If this is not a valid PwM-exported file, it returns e_fileFormat */ |
717 | PwMerror importText_PwM(const QString *file); | 719 | PwMerror importText_PwM(const QString *file); |
718 | /** PwM-text-import helper function to extract the name/pw/comment out | 720 | /** PwM-text-import helper function to extract the name/pw/comment out |
719 | * of one entry-line */ | 721 | * of one entry-line */ |
720 | bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out); | 722 | bool textExtractEntry_PwM(const char *in, ssize_t in_size, string *out); |
721 | /** compare two strings */ | 723 | /** compare two strings */ |
722 | bool compareString(const string &s1, const string &s2, bool caseSensitive, | 724 | bool compareString(const string &s1, const string &s2, bool caseSensitive, |
723 | bool exactWordMatch); | 725 | bool exactWordMatch); |
724 | /** clears all document-data */ | 726 | /** clears all document-data */ |
725 | void clearDoc(); | 727 | void clearDoc(); |
726 | /** delete all empty categories */ | 728 | /** delete all empty categories */ |
727 | void delAllEmptyCat(bool dontFlagDirty); | 729 | void delAllEmptyCat(bool dontFlagDirty); |
728 | /** set a document status flag */ | 730 | /** set a document status flag */ |
729 | void setDocStatFlag(unsigned int statFlag) | 731 | void setDocStatFlag(unsigned int statFlag) |
730 | { curDocStat |= statFlag; } | 732 | { curDocStat |= statFlag; } |
731 | /** unset a document status flag */ | 733 | /** unset a document status flag */ |
732 | void unsetDocStatFlag(unsigned int statFlag) | 734 | void unsetDocStatFlag(unsigned int statFlag) |
733 | { curDocStat &= ~statFlag; } | 735 | { curDocStat &= ~statFlag; } |
734 | /** get a document status flag */ | 736 | /** get a document status flag */ |
735 | bool getDocStatFlag(unsigned int statFlag) const | 737 | bool getDocStatFlag(unsigned int statFlag) const |
736 | { return (curDocStat & statFlag); } | 738 | { return (curDocStat & statFlag); } |
737 | /** set the "currentPassword" */ | 739 | /** set the "currentPassword" */ |
738 | void setCurrentPw(const QString &pw) | 740 | void setCurrentPw(const QString &pw) |
739 | { | 741 | { |
740 | currentPw = pw; | 742 | currentPw = pw; |
741 | setDocStatFlag(DOC_STAT_DISK_DIRTY); | 743 | setDocStatFlag(DOC_STAT_DISK_DIRTY); |
742 | } | 744 | } |
743 | /** make a backup-copy of the given file */ | 745 | /** make a backup-copy of the given file */ |
744 | bool backupFile(const QString &filePath); | 746 | bool backupFile(const QString &filePath); |
745 | /** copy a file from src to dst */ | 747 | /** copy a file from src to dst */ |
746 | bool copyFile(const QString &src, const QString &dst); | 748 | bool copyFile(const QString &src, const QString &dst); |
747 | 749 | ||
748 | 750 | ||
749 | public: | 751 | public: |
750 | #ifdef PWM_EMBEDDED | 752 | #ifdef PWM_EMBEDDED |
751 | //US ENH: this is the magic function that syncronizes the local doc with the remote doc. | 753 | //US ENH: this is the magic function that syncronizes the local doc with the remote doc. |
752 | PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode ); | 754 | PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode ); |
753 | 755 | ||
754 | //takePwMDataItem returns the following values | 756 | //takePwMDataItem returns the following values |
755 | // 0 equal | 757 | // 0 equal |
756 | // 1 take local | 758 | // 1 take local |
757 | // 2 take remote | 759 | // 2 take remote |
758 | // 3 cancel | 760 | // 3 cancel |
759 | int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ); | 761 | int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ); |
760 | 762 | ||
761 | //the following methods are the overwritten callbackmethods from the syncinterface | 763 | //the following methods are the overwritten callbackmethods from the syncinterface |
762 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 764 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
763 | 765 | ||
764 | #endif | 766 | #endif |
765 | private: | 767 | private: |
766 | //US ENH: helpermethods to access the sync data for a certain syncname. | 768 | //US ENH: helpermethods to access the sync data for a certain syncname. |
767 | // It returns the syncdatas index | 769 | // It returns the syncdatas index |
768 | bool findSyncData(const QString &syncname, unsigned int *index); | 770 | bool findSyncData(const QString &syncname, unsigned int *index); |
769 | 771 | ||
770 | /** add new syncdataentry */ | 772 | /** add new syncdataentry */ |
771 | PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false); | 773 | PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false); |
772 | 774 | ||
773 | /** returns a pointer to the syncdata */ | 775 | /** returns a pointer to the syncdata */ |
774 | PwMSyncItem* getSyncDataEntry(unsigned int index) | 776 | PwMSyncItem* getSyncDataEntry(unsigned int index) |
775 | { return &(dti.syncDta[index]); } | 777 | { return &(dti.syncDta[index]); } |
776 | 778 | ||
777 | /** delete entry */ | 779 | /** delete entry */ |
778 | bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false); | 780 | bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false); |
779 | 781 | ||
780 | PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index); | 782 | PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index); |
781 | 783 | ||
782 | QStringList getIDEntryList(); | 784 | QStringList getIDEntryList(); |
783 | 785 | ||
784 | }; | 786 | }; |
785 | 787 | ||
786 | #endif | 788 | #endif |
diff --git a/pwmanager/pwmanager/randomizer.cpp b/pwmanager/pwmanager/randomizer.cpp index e1085ff..da4df78 100644 --- a/pwmanager/pwmanager/randomizer.cpp +++ b/pwmanager/pwmanager/randomizer.cpp | |||
@@ -1,221 +1,225 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003, 2004 by Michael Buesch * | 3 | * copyright (C) 2003, 2004 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License version 2 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * copyright (C) 2004 by Ulf Schenk | 13 | * copyright (C) 2004 by Ulf Schenk |
14 | * This file is originaly based on version 1.1 of pwmanager | 14 | * This file is originaly based on version 1.1 of pwmanager |
15 | * and was modified to run on embedded devices that run microkde | 15 | * and was modified to run on embedded devices that run microkde |
16 | * | 16 | * |
17 | * $Id$ | 17 | * $Id$ |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | 19 | ||
20 | #include "randomizer.h" | 20 | #include "randomizer.h" |
21 | #include "pwmexception.h" | 21 | #include "pwmexception.h" |
22 | 22 | ||
23 | #include <qfile.h> | 23 | #include <qfile.h> |
24 | 24 | ||
25 | #include <kapplication.h> | 25 | #include <kapplication.h> |
26 | 26 | ||
27 | #include <stdlib.h> | 27 | #include <stdlib.h> |
28 | #include <time.h> | 28 | #include <time.h> |
29 | 29 | ||
30 | 30 | ||
31 | #ifdef PWM_EMBEDDED | 31 | #ifdef PWM_EMBEDDED |
32 | 32 | ||
33 | #ifndef Q_LONG | 33 | #ifndef Q_LONG |
34 | #define Q_LONG long | 34 | #define Q_LONG long |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #endif //PWM_EMBEDDED | 37 | #endif //PWM_EMBEDDED |
38 | 38 | #ifdef _WIN32_ | |
39 | 39 | int rand_r( uint * seed ) { | |
40 | srand(*seed); | ||
41 | return rand(); | ||
42 | } | ||
43 | #endif | ||
40 | Randomizer * Randomizer::rndObj (0); | 44 | Randomizer * Randomizer::rndObj (0); |
41 | 45 | ||
42 | Randomizer::Randomizer() | 46 | Randomizer::Randomizer() |
43 | { | 47 | { |
44 | rndDev = new QFile; | 48 | rndDev = new QFile; |
45 | seed = time(0); | 49 | seed = time(0); |
46 | 50 | ||
47 | #if 1 // set to 0 to test rand_r() fallback | 51 | #if 1 // set to 0 to test rand_r() fallback |
48 | 52 | ||
49 | // probe for /dev/urandom | 53 | // probe for /dev/urandom |
50 | rndDev->setName("/dev/urandom"); | 54 | rndDev->setName("/dev/urandom"); |
51 | if (rndDev->exists() && | 55 | if (rndDev->exists() && |
52 | rndDev->open(IO_ReadOnly)) { | 56 | rndDev->open(IO_ReadOnly)) { |
53 | printDebug("Randomizer: using /dev/urandom"); | 57 | printDebug("Randomizer: using /dev/urandom"); |
54 | return; | 58 | return; |
55 | } | 59 | } |
56 | 60 | ||
57 | // probe for /dev/random | 61 | // probe for /dev/random |
58 | rndDev->setName("/dev/random"); | 62 | rndDev->setName("/dev/random"); |
59 | if (rndDev->exists() && | 63 | if (rndDev->exists() && |
60 | rndDev->open(IO_ReadOnly)) { | 64 | rndDev->open(IO_ReadOnly)) { |
61 | printDebug("Randomizer: using /dev/random"); | 65 | printDebug("Randomizer: using /dev/random"); |
62 | return; | 66 | return; |
63 | } | 67 | } |
64 | 68 | ||
65 | // probe for EGD | 69 | // probe for EGD |
66 | char *fn = getenv("RANDFILE"); | 70 | char *fn = getenv("RANDFILE"); |
67 | if (fn) { | 71 | if (fn) { |
68 | rndDev->setName(fn); | 72 | rndDev->setName(fn); |
69 | if (rndDev->exists() && | 73 | if (rndDev->exists() && |
70 | rndDev->open(IO_ReadOnly)) { | 74 | rndDev->open(IO_ReadOnly)) { |
71 | printDebug(string("Randomizer: using $RANDFILE \"") | 75 | printDebug(string("Randomizer: using $RANDFILE \"") |
72 | + fn | 76 | + fn |
73 | + "\" (aka EGD)"); | 77 | + "\" (aka EGD)"); |
74 | return; | 78 | return; |
75 | } | 79 | } |
76 | } | 80 | } |
77 | #endif | 81 | #endif |
78 | 82 | ||
79 | /* no secure randomizer found. | 83 | /* no secure randomizer found. |
80 | * Fall back to stdlib randomizer. | 84 | * Fall back to stdlib randomizer. |
81 | */ | 85 | */ |
82 | delete_and_null(rndDev); | 86 | delete_and_null(rndDev); |
83 | printWarn("neither /dev/*random nor EGD found! " | 87 | printWarn("neither /dev/*random nor EGD found! " |
84 | "Falling back to insecure rand_r()!"); | 88 | "Falling back to insecure rand_r()!"); |
85 | } | 89 | } |
86 | 90 | ||
87 | Randomizer::~Randomizer() | 91 | Randomizer::~Randomizer() |
88 | { | 92 | { |
89 | #ifndef PWM_EMBEDDED | 93 | #ifndef PWM_EMBEDDED |
90 | while (mutex.locked()) { | 94 | while (mutex.locked()) { |
91 | /* wait for the mutex to unlock. | 95 | /* wait for the mutex to unlock. |
92 | * Don't block the GUI here, so processEvents() | 96 | * Don't block the GUI here, so processEvents() |
93 | */ | 97 | */ |
94 | kapp->processEvents(); | 98 | kapp->processEvents(); |
95 | } | 99 | } |
96 | #endif | 100 | #endif |
97 | if (rndDev) { | 101 | if (rndDev) { |
98 | rndDev->close(); | 102 | rndDev->close(); |
99 | delete rndDev; | 103 | delete rndDev; |
100 | } | 104 | } |
101 | } | 105 | } |
102 | 106 | ||
103 | char Randomizer::genRndChar() | 107 | char Randomizer::genRndChar() |
104 | { | 108 | { |
105 | char ret; | 109 | char ret; |
106 | #ifndef PWM_EMBEDDED | 110 | #ifndef PWM_EMBEDDED |
107 | mutex.lock(); | 111 | mutex.lock(); |
108 | #endif | 112 | #endif |
109 | if (rndDev) { | 113 | if (rndDev) { |
110 | /* we have a file which provides random data. | 114 | /* we have a file which provides random data. |
111 | * Simply read it. | 115 | * Simply read it. |
112 | */ | 116 | */ |
113 | ret = rndDev->getch(); | 117 | ret = rndDev->getch(); |
114 | } else { | 118 | } else { |
115 | /* fall back to rand_r() */ | 119 | /* fall back to rand_r() */ |
116 | ret = rand_r(&seed) % 0xFF; | 120 | ret = rand_r(&seed) % 0xFF; |
117 | } | 121 | } |
118 | #ifndef PWM_EMBEDDED | 122 | #ifndef PWM_EMBEDDED |
119 | mutex->unlock(); | 123 | mutex->unlock(); |
120 | #endif | 124 | #endif |
121 | return ret; | 125 | return ret; |
122 | } | 126 | } |
123 | 127 | ||
124 | int Randomizer::genRndInt() | 128 | int Randomizer::genRndInt() |
125 | { | 129 | { |
126 | int ret; | 130 | int ret; |
127 | #ifndef PWM_EMBEDDED | 131 | #ifndef PWM_EMBEDDED |
128 | mutex->lock(); | 132 | mutex->lock(); |
129 | #endif | 133 | #endif |
130 | if (rndDev) { | 134 | if (rndDev) { |
131 | if (sizeof(int) == 4) { | 135 | if (sizeof(int) == 4) { |
132 | (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); | 136 | (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); |
133 | (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); | 137 | (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); |
134 | (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); | 138 | (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); |
135 | (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); | 139 | (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); |
136 | } else if (sizeof(int) == 8) { | 140 | } else if (sizeof(int) == 8) { |
137 | (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); | 141 | (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); |
138 | (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); | 142 | (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); |
139 | (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); | 143 | (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); |
140 | (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); | 144 | (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); |
141 | (reinterpret_cast<char *>(&ret))[4] = rndDev->getch(); | 145 | (reinterpret_cast<char *>(&ret))[4] = rndDev->getch(); |
142 | (reinterpret_cast<char *>(&ret))[5] = rndDev->getch(); | 146 | (reinterpret_cast<char *>(&ret))[5] = rndDev->getch(); |
143 | (reinterpret_cast<char *>(&ret))[6] = rndDev->getch(); | 147 | (reinterpret_cast<char *>(&ret))[6] = rndDev->getch(); |
144 | (reinterpret_cast<char *>(&ret))[7] = rndDev->getch(); | 148 | (reinterpret_cast<char *>(&ret))[7] = rndDev->getch(); |
145 | } else { | 149 | } else { |
146 | printWarn(string(__FILE__) + ":" + tostr(__LINE__) | 150 | printWarn(string(__FILE__) + ":" + tostr(__LINE__) |
147 | + ": sizeof(int) != 4 && sizeof(int) != 8"); | 151 | + ": sizeof(int) != 4 && sizeof(int) != 8"); |
148 | ret = rand_r(&seed); | 152 | ret = rand_r(&seed); |
149 | } | 153 | } |
150 | } else { | 154 | } else { |
151 | ret = rand_r(&seed); | 155 | ret = rand_r(&seed); |
152 | } | 156 | } |
153 | #ifndef PWM_EMBEDDED | 157 | #ifndef PWM_EMBEDDED |
154 | mutex->unlock(); | 158 | mutex->unlock(); |
155 | #endif | 159 | #endif |
156 | return ret; | 160 | return ret; |
157 | } | 161 | } |
158 | 162 | ||
159 | unsigned int Randomizer::genRndUInt() | 163 | unsigned int Randomizer::genRndUInt() |
160 | { | 164 | { |
161 | unsigned int ret; | 165 | unsigned int ret; |
162 | #ifndef PWM_EMBEDDED | 166 | #ifndef PWM_EMBEDDED |
163 | mutex->lock(); | 167 | mutex->lock(); |
164 | #endif | 168 | #endif |
165 | if (rndDev) { | 169 | if (rndDev) { |
166 | if (sizeof(unsigned int) == 4) { | 170 | if (sizeof(unsigned int) == 4) { |
167 | (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); | 171 | (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); |
168 | (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); | 172 | (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); |
169 | (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); | 173 | (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); |
170 | (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); | 174 | (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); |
171 | } else if (sizeof(unsigned int) == 8) { | 175 | } else if (sizeof(unsigned int) == 8) { |
172 | (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); | 176 | (reinterpret_cast<char *>(&ret))[0] = rndDev->getch(); |
173 | (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); | 177 | (reinterpret_cast<char *>(&ret))[1] = rndDev->getch(); |
174 | (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); | 178 | (reinterpret_cast<char *>(&ret))[2] = rndDev->getch(); |
175 | (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); | 179 | (reinterpret_cast<char *>(&ret))[3] = rndDev->getch(); |
176 | (reinterpret_cast<char *>(&ret))[4] = rndDev->getch(); | 180 | (reinterpret_cast<char *>(&ret))[4] = rndDev->getch(); |
177 | (reinterpret_cast<char *>(&ret))[5] = rndDev->getch(); | 181 | (reinterpret_cast<char *>(&ret))[5] = rndDev->getch(); |
178 | (reinterpret_cast<char *>(&ret))[6] = rndDev->getch(); | 182 | (reinterpret_cast<char *>(&ret))[6] = rndDev->getch(); |
179 | (reinterpret_cast<char *>(&ret))[7] = rndDev->getch(); | 183 | (reinterpret_cast<char *>(&ret))[7] = rndDev->getch(); |
180 | } else { | 184 | } else { |
181 | printWarn(string(__FILE__) + ":" + tostr(__LINE__) | 185 | printWarn(string(__FILE__) + ":" + tostr(__LINE__) |
182 | + ": sizeof(unsigned int) != 4 && sizeof(unsigned int) != 8"); | 186 | + ": sizeof(unsigned int) != 4 && sizeof(unsigned int) != 8"); |
183 | ret = rand_r(&seed); | 187 | ret = rand_r(&seed); |
184 | } | 188 | } |
185 | } else { | 189 | } else { |
186 | ret = rand_r(&seed); | 190 | ret = rand_r(&seed); |
187 | } | 191 | } |
188 | #ifndef PWM_EMBEDDED | 192 | #ifndef PWM_EMBEDDED |
189 | mutex->unlock(); | 193 | mutex->unlock(); |
190 | #endif | 194 | #endif |
191 | return ret; | 195 | return ret; |
192 | } | 196 | } |
193 | 197 | ||
194 | void Randomizer::genRndBuf(unsigned char *buf, size_t len) | 198 | void Randomizer::genRndBuf(unsigned char *buf, size_t len) |
195 | { | 199 | { |
196 | #ifndef PWM_EMBEDDED | 200 | #ifndef PWM_EMBEDDED |
197 | mutex->lock(); | 201 | mutex->lock(); |
198 | #endif | 202 | #endif |
199 | if (rndDev) { | 203 | if (rndDev) { |
200 | Q_LONG n; | 204 | Q_LONG n; |
201 | n = rndDev->readBlock(reinterpret_cast<char *>(buf), len); | 205 | n = rndDev->readBlock(reinterpret_cast<char *>(buf), len); |
202 | WARN_ON(n != static_cast<Q_LONG>(len)); | 206 | WARN_ON(n != static_cast<Q_LONG>(len)); |
203 | } else { | 207 | } else { |
204 | size_t i; | 208 | size_t i; |
205 | for (i = 0; i < len; ++i) | 209 | for (i = 0; i < len; ++i) |
206 | buf[i] = rand_r(&seed) % 0xFF; | 210 | buf[i] = rand_r(&seed) % 0xFF; |
207 | } | 211 | } |
208 | #ifndef PWM_EMBEDDED | 212 | #ifndef PWM_EMBEDDED |
209 | mutex->unlock(); | 213 | mutex->unlock(); |
210 | #endif | 214 | #endif |
211 | } | 215 | } |
212 | 216 | ||
213 | string Randomizer::genRndBuf(size_t len) | 217 | string Randomizer::genRndBuf(size_t len) |
214 | { | 218 | { |
215 | string ret; | 219 | string ret; |
216 | unsigned char *buf; | 220 | unsigned char *buf; |
217 | buf = new unsigned char[len]; | 221 | buf = new unsigned char[len]; |
218 | genRndBuf(buf, len); | 222 | genRndBuf(buf, len); |
219 | ret.assign(reinterpret_cast<const char *>(buf), len); | 223 | ret.assign(reinterpret_cast<const char *>(buf), len); |
220 | return ret; | 224 | return ret; |
221 | } | 225 | } |
diff --git a/pwmanager/pwmanager/setmasterpwwndimpl.h b/pwmanager/pwmanager/setmasterpwwndimpl.h index 3203d4d..08f3654 100644 --- a/pwmanager/pwmanager/setmasterpwwndimpl.h +++ b/pwmanager/pwmanager/setmasterpwwndimpl.h | |||
@@ -1,80 +1,84 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003 by Michael Buesch * | 3 | * copyright (C) 2003 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License version 2 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | 12 | ||
13 | /*************************************************************************** | 13 | /*************************************************************************** |
14 | * copyright (C) 2004 by Ulf Schenk | 14 | * copyright (C) 2004 by Ulf Schenk |
15 | * This file is originaly based on version 1.0.1 of pwmanager | 15 | * This file is originaly based on version 1.0.1 of pwmanager |
16 | * and was modified to run on embedded devices that run microkde | 16 | * and was modified to run on embedded devices that run microkde |
17 | * | 17 | * |
18 | * $Id$ | 18 | * $Id$ |
19 | **************************************************************************/ | 19 | **************************************************************************/ |
20 | 20 | ||
21 | #ifndef SETMASTERPWWNDIMPL_H | 21 | #ifndef SETMASTERPWWNDIMPL_H |
22 | #define SETMASTERPWWNDIMPL_H | 22 | #define SETMASTERPWWNDIMPL_H |
23 | 23 | ||
24 | #ifndef PWM_EMBEDDED | 24 | #ifndef PWM_EMBEDDED |
25 | #include "setmasterpwwnd.h" | 25 | #include "setmasterpwwnd.h" |
26 | #else | 26 | #else |
27 | #include "setmasterpwwnd_emb.h" | 27 | #include "setmasterpwwnd_emb.h" |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | 31 | ||
32 | #ifdef _WIN32_ | ||
33 | #define uint32_t Q_UINT32 | ||
34 | #else | ||
32 | #include <stdint.h> | 35 | #include <stdint.h> |
36 | #endif | ||
33 | #include <string> | 37 | #include <string> |
34 | using std::string; | 38 | using std::string; |
35 | 39 | ||
36 | class PwMKeyCard; | 40 | class PwMKeyCard; |
37 | 41 | ||
38 | /** set master pw wnd */ | 42 | /** set master pw wnd */ |
39 | class SetMasterPwWndImpl : public setMasterPwWnd | 43 | class SetMasterPwWndImpl : public setMasterPwWnd |
40 | { | 44 | { |
41 | Q_OBJECT | 45 | Q_OBJECT |
42 | public: | 46 | public: |
43 | SetMasterPwWndImpl(QWidget* parent = 0, const char *name = 0); | 47 | SetMasterPwWndImpl(QWidget* parent = 0, const char *name = 0); |
44 | ~SetMasterPwWndImpl(); | 48 | ~SetMasterPwWndImpl(); |
45 | 49 | ||
46 | static QString string_cardNone() | 50 | static QString string_cardNone() |
47 | { return i18n("NONE"); } | 51 | { return i18n("NONE"); } |
48 | 52 | ||
49 | /** returns the selected pw (or the key on the card) */ | 53 | /** returns the selected pw (or the key on the card) */ |
50 | string getPw(bool *useCard); | 54 | string getPw(bool *useCard); |
51 | /** set pointer to the keycard-access object */ | 55 | /** set pointer to the keycard-access object */ |
52 | void setPwMKeyCard(PwMKeyCard *_keyCard) | 56 | void setPwMKeyCard(PwMKeyCard *_keyCard) |
53 | { keyCard = _keyCard; } | 57 | { keyCard = _keyCard; } |
54 | 58 | ||
55 | public slots: | 59 | public slots: |
56 | /** ok button pressed */ | 60 | /** ok button pressed */ |
57 | void okButton_slot(); | 61 | void okButton_slot(); |
58 | /** cancel button pressed */ | 62 | /** cancel button pressed */ |
59 | void cancelButton_slot(); | 63 | void cancelButton_slot(); |
60 | /** "generate a new card" button pressed */ | 64 | /** "generate a new card" button pressed */ |
61 | void genCardButton_slot(); | 65 | void genCardButton_slot(); |
62 | /** "select current card" button pressed */ | 66 | /** "select current card" button pressed */ |
63 | void selCardButton_slot(); | 67 | void selCardButton_slot(); |
64 | 68 | ||
65 | #ifdef PWM_EMBEDDED | 69 | #ifdef PWM_EMBEDDED |
66 | virtual void slotOk(); | 70 | virtual void slotOk(); |
67 | #endif | 71 | #endif |
68 | 72 | ||
69 | protected slots: | 73 | protected slots: |
70 | /** key from PwMKeyCard is available */ | 74 | /** key from PwMKeyCard is available */ |
71 | void keyAvailable_slot(uint32_t cardId, const string &key); | 75 | void keyAvailable_slot(uint32_t cardId, const string &key); |
72 | 76 | ||
73 | protected: | 77 | protected: |
74 | /** key of currently inserted card */ | 78 | /** key of currently inserted card */ |
75 | string curCardKey; | 79 | string curCardKey; |
76 | /** pointer to the keycard-access object */ | 80 | /** pointer to the keycard-access object */ |
77 | PwMKeyCard *keyCard; | 81 | PwMKeyCard *keyCard; |
78 | }; | 82 | }; |
79 | 83 | ||
80 | #endif | 84 | #endif |
diff --git a/pwmanager/pwmanager/sha1.h b/pwmanager/pwmanager/sha1.h index 29442a7..c649bae 100644 --- a/pwmanager/pwmanager/sha1.h +++ b/pwmanager/pwmanager/sha1.h | |||
@@ -1,75 +1,80 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003 by Michael Buesch * | 3 | * copyright (C) 2003 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License version 2 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * copyright (C) 2004 by Ulf Schenk | 13 | * copyright (C) 2004 by Ulf Schenk |
14 | * This file is originaly based on version 1.0.1 of pwmanager | 14 | * This file is originaly based on version 1.0.1 of pwmanager |
15 | * and was modified to run on embedded devices that run microkde | 15 | * and was modified to run on embedded devices that run microkde |
16 | * | 16 | * |
17 | * $Id$ | 17 | * $Id$ |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | 19 | ||
20 | #ifndef SHA1_H | 20 | #ifndef SHA1_H |
21 | #define SHA1_H | 21 | #define SHA1_H |
22 | 22 | #ifdef _WIN32_ | |
23 | #define uint32_t unsigned int | ||
24 | #define uint8_tunsigned char | ||
25 | #define byteunsigned char | ||
26 | #else | ||
23 | #include <stdint.h> | 27 | #include <stdint.h> |
28 | typedef uint8_t byte; | ||
29 | #endif | ||
24 | #include <string> | 30 | #include <string> |
25 | using std::string; | 31 | using std::string; |
26 | 32 | ||
27 | typedef uint8_t byte; | ||
28 | 33 | ||
29 | #define SHA1_HASH_LEN_BIT160 | 34 | #define SHA1_HASH_LEN_BIT160 |
30 | #define SHA1_HASH_LEN_BYTE(SHA1_HASH_LEN_BIT / 8) | 35 | #define SHA1_HASH_LEN_BYTE(SHA1_HASH_LEN_BIT / 8) |
31 | 36 | ||
32 | /** sha1 hash algorithm. | 37 | /** sha1 hash algorithm. |
33 | * Derived from libgcrypt-1.1.12 | 38 | * Derived from libgcrypt-1.1.12 |
34 | */ | 39 | */ |
35 | class Sha1 | 40 | class Sha1 |
36 | { | 41 | { |
37 | struct SHA1_CONTEXT | 42 | struct SHA1_CONTEXT |
38 | { | 43 | { |
39 | uint32_t h0,h1,h2,h3,h4; | 44 | uint32_t h0,h1,h2,h3,h4; |
40 | uint32_t nblocks; | 45 | uint32_t nblocks; |
41 | byte buf[64]; | 46 | byte buf[64]; |
42 | int count; | 47 | int count; |
43 | }; | 48 | }; |
44 | 49 | ||
45 | public: | 50 | public: |
46 | Sha1() { sha1_init(); } | 51 | Sha1() { sha1_init(); } |
47 | static bool selfTest(); | 52 | static bool selfTest(); |
48 | 53 | ||
49 | void sha1_write(const byte *inbuf, uint32_t inlen); | 54 | void sha1_write(const byte *inbuf, uint32_t inlen); |
50 | string sha1_read(); | 55 | string sha1_read(); |
51 | 56 | ||
52 | protected: | 57 | protected: |
53 | void sha1_init(); | 58 | void sha1_init(); |
54 | void sha1_final(); | 59 | void sha1_final(); |
55 | void burn_stack (int bytes); | 60 | void burn_stack (int bytes); |
56 | void transform(const byte *data); | 61 | void transform(const byte *data); |
57 | 62 | ||
58 | /** Rotate a 32 bit integer by n bytes */ | 63 | /** Rotate a 32 bit integer by n bytes */ |
59 | uint32_t rol(uint32_t x, int n) | 64 | uint32_t rol(uint32_t x, int n) |
60 | { | 65 | { |
61 | #if defined(__GNUC__) && defined(__i386__) | 66 | #if defined(__GNUC__) && defined(__i386__) |
62 | __asm__("roll %%cl,%0" | 67 | __asm__("roll %%cl,%0" |
63 | :"=r" (x) | 68 | :"=r" (x) |
64 | :"0" (x),"c" (n)); | 69 | :"0" (x),"c" (n)); |
65 | return x; | 70 | return x; |
66 | #else | 71 | #else |
67 | return ((x) << (n)) | ((x) >> (32-(n))); | 72 | return ((x) << (n)) | ((x) >> (32-(n))); |
68 | #endif | 73 | #endif |
69 | } | 74 | } |
70 | 75 | ||
71 | protected: | 76 | protected: |
72 | struct SHA1_CONTEXT ctx; | 77 | struct SHA1_CONTEXT ctx; |
73 | }; | 78 | }; |
74 | 79 | ||
75 | #endif | 80 | #endif |