-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 691 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.h | 10 |
2 files changed, 72 insertions, 629 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index 1ae3b15..2b182f9 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -1,2157 +1,1826 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** | 2 | ** |
3 | ** Created: Sat Apr 6 17:57:45 2002 | 3 | ** Created: Sat Apr 6 17:57:45 2002 |
4 | ** | 4 | ** |
5 | ** Author: Carsten Schneider <CarstenSchneider@t-online.de> | 5 | ** Author: Carsten Schneider <CarstenSchneider@t-online.de> |
6 | ** | 6 | ** |
7 | ** $Id$ | 7 | ** $Id$ |
8 | ** | 8 | ** |
9 | ** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html | 9 | ** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html |
10 | ** | 10 | ** |
11 | ** Compile Flags: | ||
12 | ** Zaurus arm : -DNO_OPIE | ||
13 | ** Zaurus Opie arm: none | ||
14 | ** Linux Desktop : -DDESKTOP -DNO_OPIE | ||
15 | ** Windows Desktop: -DDESKTOP -DNO_OPIE | ||
16 | ** use qmake | ||
17 | ** for japanese version additional use: -DJPATCH_HDE | ||
18 | ** | 11 | ** |
19 | ****************************************************************************/ | 12 | ****************************************************************************/ |
20 | #include "zsafe.h" | 13 | #include "zsafe.h" |
21 | #include "newdialog.h" | 14 | #include "newdialog.h" |
22 | #include "searchdialog.h" | 15 | #include "searchdialog.h" |
23 | #include "categorydialog.h" | 16 | #include "categorydialog.h" |
24 | #include "passworddialog.h" | 17 | #include "passworddialog.h" |
25 | #include "infoform.h" | 18 | #include "infoform.h" |
26 | #include "zlistview.h" | 19 | #include "zlistview.h" |
27 | #include "shadedlistitem.h" | 20 | #include "shadedlistitem.h" |
28 | 21 | ||
29 | #ifndef DESKTOP | ||
30 | #ifndef NO_OPIE | ||
31 | #include <opie2/ofiledialog.h> | 22 | #include <opie2/ofiledialog.h> |
32 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
33 | using namespace Opie::Core; | 24 | using namespace Opie::Core; |
34 | using namespace Opie::Ui; | 25 | using namespace Opie::Ui; |
35 | #else | ||
36 | #include "scqtfileedit.h" | ||
37 | #endif | ||
38 | #endif | ||
39 | 26 | ||
40 | #include <qclipboard.h> | 27 | #include <qclipboard.h> |
41 | 28 | ||
42 | #include <sys/types.h> | 29 | #include <sys/types.h> |
43 | #include <sys/stat.h> | 30 | #include <sys/stat.h> |
44 | #include <fcntl.h> | 31 | #include <fcntl.h> |
45 | #include <stdlib.h> | 32 | #include <stdlib.h> |
46 | #ifndef Q_WS_WIN | ||
47 | #include <unistd.h> | 33 | #include <unistd.h> |
48 | #endif | ||
49 | #include <string.h> | 34 | #include <string.h> |
50 | #include <errno.h> | 35 | #include <errno.h> |
51 | 36 | ||
52 | #include <qmenubar.h> | 37 | #include <qmenubar.h> |
53 | #include <qpopupmenu.h> | 38 | #include <qpopupmenu.h> |
54 | 39 | ||
55 | #ifdef DESKTOP | ||
56 | #include <qfiledialog.h> | ||
57 | #include <qdragobject.h> | ||
58 | #ifndef Q_WS_WIN | ||
59 | #include <qsettings.h> | ||
60 | #else | ||
61 | #include "qsettings.h" | ||
62 | #endif | ||
63 | #include <qapplication.h> | ||
64 | #else | ||
65 | #include <qfile.h> | 40 | #include <qfile.h> |
66 | #include <qpe/fileselector.h> | 41 | #include <qpe/fileselector.h> |
67 | #include <qpe/global.h> | 42 | #include <qpe/global.h> |
68 | #include <qpe/qpeapplication.h> | 43 | #include <qpe/qpeapplication.h> |
69 | #include <qpe/resource.h> | 44 | #include <qpe/resource.h> |
70 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
71 | #endif | ||
72 | 46 | ||
73 | #include <qtimer.h> | 47 | #include <qtimer.h> |
74 | #include <qlayout.h> | 48 | #include <qlayout.h> |
75 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
76 | #include <qfile.h> | 50 | #include <qfile.h> |
77 | #include <qtextstream.h> | 51 | #include <qtextstream.h> |
78 | #include <qheader.h> | 52 | #include <qheader.h> |
79 | #include <qlistview.h> | 53 | #include <qlistview.h> |
80 | #include <qtoolbutton.h> | 54 | #include <qtoolbutton.h> |
81 | #include <qvariant.h> | 55 | #include <qvariant.h> |
82 | #include <qtooltip.h> | 56 | #include <qtooltip.h> |
83 | #include <qwhatsthis.h> | 57 | #include <qwhatsthis.h> |
84 | #include <qimage.h> | 58 | #include <qimage.h> |
85 | #include <qpixmap.h> | 59 | #include <qpixmap.h> |
86 | #include <qlineedit.h> | 60 | #include <qlineedit.h> |
87 | #include <qmultilineedit.h> | 61 | #include <qmultilineedit.h> |
88 | #include <qregexp.h> | 62 | #include <qregexp.h> |
89 | #include <qdir.h> | 63 | #include <qdir.h> |
90 | #include <qtextbrowser.h> | 64 | #include <qtextbrowser.h> |
91 | #include <qlabel.h> | 65 | #include <qlabel.h> |
92 | #include <qcombobox.h> | 66 | #include <qcombobox.h> |
93 | 67 | ||
94 | #include "krc2.h" | 68 | #include "krc2.h" |
95 | 69 | ||
96 | #include "wait.h" | 70 | #include "wait.h" |
97 | 71 | ||
98 | extern int DeskW, DeskH; | 72 | int DeskW, DeskH; |
99 | #ifdef DESKTOP | 73 | QApplication *appl; |
100 | extern QApplication *appl; | 74 | ZSafe *zs; |
101 | #else | ||
102 | extern QPEApplication *appl; | ||
103 | #endif | ||
104 | |||
105 | #ifdef JPATCH_HDE | ||
106 | #define tr(arg) arg | ||
107 | #endif | ||
108 | |||
109 | 75 | ||
110 | #ifdef DESKTOP | 76 | const QString APP_KEY = ""; |
111 | #ifndef Q_WS_WIN | ||
112 | const QString APP_KEY="/.zsafe/"; | ||
113 | #else | ||
114 | const QString APP_KEY=""; | ||
115 | #endif | ||
116 | #else | ||
117 | const QString APP_KEY=""; | ||
118 | #endif | ||
119 | 77 | ||
120 | // include xmp images | 78 | // include xmp images |
121 | #include "pics/zsafe/copy.xpm" | 79 | #include "pics/zsafe/copy.xpm" |
122 | #include "pics/zsafe/cut.xpm" | 80 | #include "pics/zsafe/cut.xpm" |
123 | #include "pics/zsafe/edit.xpm" | 81 | #include "pics/zsafe/edit.xpm" |
124 | #include "pics/zsafe/editdelete.xpm" | 82 | #include "pics/zsafe/editdelete.xpm" |
125 | #include "pics/zsafe/find.xpm" | 83 | #include "pics/zsafe/find.xpm" |
126 | #include "pics/zsafe/folder_open.xpm" | 84 | #include "pics/zsafe/folder_open.xpm" |
127 | #include "pics/zsafe/help_icon.xpm" | 85 | #include "pics/zsafe/help_icon.xpm" |
128 | #include "pics/zsafe/new.xpm" | 86 | #include "pics/zsafe/new.xpm" |
129 | #include "pics/zsafe/paste.xpm" | 87 | #include "pics/zsafe/paste.xpm" |
130 | #include "pics/zsafe/quit_icon.xpm" | 88 | #include "pics/zsafe/quit_icon.xpm" |
131 | #include "pics/zsafe/save.xpm" | 89 | #include "pics/zsafe/save.xpm" |
132 | #include "pics/zsafe/trash.xpm" | 90 | #include "pics/zsafe/trash.xpm" |
133 | #include "pics/zsafe/expand.xpm" | 91 | #include "pics/zsafe/expand.xpm" |
134 | #include "pics/zsafe/export.xpm" | 92 | #include "pics/zsafe/export.xpm" |
135 | #include "pics/zsafe/import.xpm" | 93 | #include "pics/zsafe/import.xpm" |
136 | #include "pics/zsafe/zsafe.xpm" | 94 | #include "pics/zsafe/zsafe.xpm" |
137 | 95 | ||
138 | static const char* const bank_cards_data[] = { | 96 | static const char* const bank_cards_data[] = { |
139 | "14 14 16 1", | 97 | "14 14 16 1", |
140 | ". c None", | 98 | ". c None", |
141 | "# c #000000", | 99 | "# c #000000", |
142 | "b c #0000de", | 100 | "b c #0000de", |
143 | "a c #0000e6", | 101 | "a c #0000e6", |
144 | "j c #41de83", | 102 | "j c #41de83", |
145 | "k c #4acecd", | 103 | "k c #4acecd", |
146 | "h c #4aced5", | 104 | "h c #4aced5", |
147 | "g c #5a40cd", | 105 | "g c #5a40cd", |
148 | "d c #5a44d5", | 106 | "d c #5a44d5", |
149 | "l c #9440d5", | 107 | "l c #9440d5", |
150 | "m c #b4ce4a", | 108 | "m c #b4ce4a", |
151 | "n c #cd4883", | 109 | "n c #cd4883", |
152 | "e c #d5ae10", | 110 | "e c #d5ae10", |
153 | "f c #de3ce6", | 111 | "f c #de3ce6", |
154 | "i c #e640e6", | 112 | "i c #e640e6", |
155 | "c c #ffffff", | 113 | "c c #ffffff", |
156 | "..............", | 114 | "..............", |
157 | ".###########..", | 115 | ".###########..", |
158 | ".#ababababa#..", | 116 | ".#ababababa#..", |
159 | ".#babbbabbb#..", | 117 | ".#babbbabbb#..", |
160 | ".#ccccccccc#..", | 118 | ".#ccccccccc#..", |
161 | ".#cdcefcghc#..", | 119 | ".#cdcefcghc#..", |
162 | ".#ccccccccc#..", | 120 | ".#ccccccccc#..", |
163 | ".#cicjkclic#..", | 121 | ".#cicjkclic#..", |
164 | ".#ccccccccc#..", | 122 | ".#ccccccccc#..", |
165 | ".#cmchlcnec#..", | 123 | ".#cmchlcnec#..", |
166 | ".#ccccccccc#..", | 124 | ".#ccccccccc#..", |
167 | ".###########..", | 125 | ".###########..", |
168 | "..............", | 126 | "..............", |
169 | ".............."}; | 127 | ".............."}; |
170 | 128 | ||
171 | 129 | ||
172 | static const char* const passwords_data[] = { | 130 | static const char* const passwords_data[] = { |
173 | "16 16 20 1", | 131 | "16 16 20 1", |
174 | ". c None", | 132 | ". c None", |
175 | "# c #000000", | 133 | "# c #000000", |
176 | "r c #000083", | 134 | "r c #000083", |
177 | "p c #0000c5", | 135 | "p c #0000c5", |
178 | "q c #0000ff", | 136 | "q c #0000ff", |
179 | "n c #008100", | 137 | "n c #008100", |
180 | "l c #00c200", | 138 | "l c #00c200", |
181 | "m c #00ff00", | 139 | "m c #00ff00", |
182 | "j c #838100", | 140 | "j c #838100", |
183 | "a c #c55900", | 141 | "a c #c55900", |
184 | "h c #c5c200", | 142 | "h c #c5c200", |
185 | "o c #c5c2ff", | 143 | "o c #c5c2ff", |
186 | "k c #c5ffc5", | 144 | "k c #c5ffc5", |
187 | "f c #ff0000", | 145 | "f c #ff0000", |
188 | "d c #ff8100", | 146 | "d c #ff8100", |
189 | "b c #ffaa5a", | 147 | "b c #ffaa5a", |
190 | "e c #ffc2c5", | 148 | "e c #ffc2c5", |
191 | "c c #ffdeac", | 149 | "c c #ffdeac", |
192 | "i c #ffff00", | 150 | "i c #ffff00", |
193 | "g c #ffffc5", | 151 | "g c #ffffc5", |
194 | "............###.", | 152 | "............###.", |
195 | "...........#abb#", | 153 | "...........#abb#", |
196 | "..........#cbab#", | 154 | "..........#cbab#", |
197 | ".........#cbdd#.", | 155 | ".........#cbdd#.", |
198 | "######..#cbdd#..", | 156 | "######..#cbdd#..", |
199 | "#eeff#..#add#...", | 157 | "#eeff#..#add#...", |
200 | "#eeff#######....", | 158 | "#eeff#######....", |
201 | "#ccdbdd#........", | 159 | "#ccdbdd#........", |
202 | "#dddbdd###......", | 160 | "#dddbdd###......", |
203 | "#gghihhjj#......", | 161 | "#gghihhjj#......", |
204 | "#hhhihhjj###....", | 162 | "#hhhihhjj###....", |
205 | "#kklmllnnnn#....", | 163 | "#kklmllnnnn#....", |
206 | "#lllmllnnnn#....", | 164 | "#lllmllnnnn#....", |
207 | "#oopqpprprr#....", | 165 | "#oopqpprprr#....", |
208 | "#oopqpprprr#....", | 166 | "#oopqpprprr#....", |
209 | "############...."}; | 167 | "############...."}; |
210 | 168 | ||
211 | static const char* const software_data[] = { | 169 | static const char* const software_data[] = { |
212 | "16 16 5 1", | 170 | "16 16 5 1", |
213 | ". c None", | 171 | ". c None", |
214 | "# c #000000", | 172 | "# c #000000", |
215 | "b c #838183", | 173 | "b c #838183", |
216 | "c c #c5ffff", | 174 | "c c #c5ffff", |
217 | "a c #ffffff", | 175 | "a c #ffffff", |
218 | "................", | 176 | "................", |
219 | ".##############.", | 177 | ".##############.", |
220 | "#aaaaaaaaaaaaaa#", | 178 | "#aaaaaaaaaaaaaa#", |
221 | "#abbbbbbbbbbbbb#", | 179 | "#abbbbbbbbbbbbb#", |
222 | "#ab##########ab#", | 180 | "#ab##########ab#", |
223 | "#ab#c########ab#", | 181 | "#ab#c########ab#", |
224 | "#ab#c#c######ab#", | 182 | "#ab#c#c######ab#", |
225 | "#ab##########ab#", | 183 | "#ab##########ab#", |
226 | "#ab##########ab#", | 184 | "#ab##########ab#", |
227 | "#ab##########ab#", | 185 | "#ab##########ab#", |
228 | "#ab##########ab#", | 186 | "#ab##########ab#", |
229 | "#ab##########ab#", | 187 | "#ab##########ab#", |
230 | "#aaaaaaaaaaaaab#", | 188 | "#aaaaaaaaaaaaab#", |
231 | "#bbbbbbbbbbbbbb#", | 189 | "#bbbbbbbbbbbbbb#", |
232 | ".##############.", | 190 | ".##############.", |
233 | "................"}; | 191 | "................"}; |
234 | 192 | ||
235 | static const char* const general_data[] = { | 193 | static const char* const general_data[] = { |
236 | "14 14 98 2", | 194 | "14 14 98 2", |
237 | "Qt c None", | 195 | "Qt c None", |
238 | ".k c #000000", | 196 | ".k c #000000", |
239 | "#x c #080808", | 197 | "#x c #080808", |
240 | "#F c #101008", | 198 | "#F c #101008", |
241 | "#q c #101010", | 199 | "#q c #101010", |
242 | "#i c #101410", | 200 | "#i c #101410", |
243 | "## c #101810", | 201 | "## c #101810", |
244 | ".m c #181818", | 202 | ".m c #181818", |
245 | ".3 c #181c18", | 203 | ".3 c #181c18", |
246 | ".I c #182018", | 204 | ".I c #182018", |
247 | ".T c #202420", | 205 | ".T c #202420", |
248 | "#D c #202820", | 206 | "#D c #202820", |
249 | "#y c #292c29", | 207 | "#y c #292c29", |
250 | ".c c #293029", | 208 | ".c c #293029", |
251 | ".d c #313031", | 209 | ".d c #313031", |
252 | "#E c #313429", | 210 | "#E c #313429", |
253 | "#r c #313831", | 211 | "#r c #313831", |
254 | ".j c #393c31", | 212 | ".j c #393c31", |
255 | "#j c #394039", | 213 | "#j c #394039", |
256 | "#C c #414841", | 214 | "#C c #414841", |
257 | ".w c #4a554a", | 215 | ".w c #4a554a", |
258 | ".a c #4a594a", | 216 | ".a c #4a594a", |
259 | ".# c #525052", | 217 | ".# c #525052", |
260 | ".l c #52594a", | 218 | ".l c #52594a", |
261 | "#f c #525952", | 219 | "#f c #525952", |
262 | "#v c #525d52", | 220 | "#v c #525d52", |
263 | ".O c #5a4c4a", | 221 | ".O c #5a4c4a", |
264 | ".9 c #5a595a", | 222 | ".9 c #5a595a", |
265 | ".A c #5a5d52", | 223 | ".A c #5a5d52", |
266 | ".B c #624c52", | 224 | ".B c #624c52", |
267 | ".0 c #625552", | 225 | ".0 c #625552", |
268 | "#o c #626562", | 226 | "#o c #626562", |
269 | ".R c #626962", | 227 | ".R c #626962", |
270 | "#. c #626d5a", | 228 | "#. c #626d5a", |
271 | "#p c #626d62", | 229 | "#p c #626d62", |
272 | ".2 c #627162", | 230 | ".2 c #627162", |
273 | "#h c #6a6d62", | 231 | "#h c #6a6d62", |
274 | "#z c #6a7562", | 232 | "#z c #6a7562", |
275 | "#w c #6a756a", | 233 | "#w c #6a756a", |
276 | ".C c #73656a", | 234 | ".C c #73656a", |
277 | ".P c #73696a", | 235 | ".P c #73696a", |
278 | "#a c #737d6a", | 236 | "#a c #737d6a", |
279 | ".U c #738573", | 237 | ".U c #738573", |
280 | ".E c #7b817b", | 238 | ".E c #7b817b", |
281 | "#B c #7b857b", | 239 | "#B c #7b857b", |
282 | "#s c #7b897b", | 240 | "#s c #7b897b", |
283 | "#n c #7b917b", | 241 | "#n c #7b917b", |
284 | ".b c #838d83", | 242 | ".b c #838d83", |
285 | ".7 c #839583", | 243 | ".7 c #839583", |
286 | ".n c #8b7d7b", | 244 | ".n c #8b7d7b", |
287 | "#g c #8b8583", | 245 | "#g c #8b8583", |
288 | ".g c #8b858b", | 246 | ".g c #8b858b", |
289 | ".r c #8b898b", | 247 | ".r c #8b898b", |
290 | ".s c #8b8d8b", | 248 | ".s c #8b8d8b", |
291 | ".i c #8b9183", | 249 | ".i c #8b9183", |
292 | ".8 c #8b918b", | 250 | ".8 c #8b918b", |
293 | "#A c #8b9d8b", | 251 | "#A c #8b9d8b", |
294 | ".S c #8ba183", | 252 | ".S c #8ba183", |
295 | ".Z c #94918b", | 253 | ".Z c #94918b", |
296 | ".N c #949994", | 254 | ".N c #949994", |
297 | ".F c #949d94", | 255 | ".F c #949d94", |
298 | ".x c #94a18b", | 256 | ".x c #94a18b", |
299 | ".v c #94a194", | 257 | ".v c #94a194", |
300 | ".Y c #94aa94", | 258 | ".Y c #94aa94", |
301 | ".h c #9c999c", | 259 | ".h c #9c999c", |
302 | ".Q c #9ca19c", | 260 | ".Q c #9ca19c", |
303 | "#u c #9ca59c", | 261 | "#u c #9ca59c", |
304 | ".H c #9caa9c", | 262 | ".H c #9caa9c", |
305 | "#e c #9cb29c", | 263 | "#e c #9cb29c", |
306 | "#m c #a4b29c", | 264 | "#m c #a4b29c", |
307 | "#t c #a4b2a4", | 265 | "#t c #a4b2a4", |
308 | ".M c #a4b69c", | 266 | ".M c #a4b69c", |
309 | "#l c #a4b6a4", | 267 | "#l c #a4b6a4", |
310 | ".z c #a4baa4", | 268 | ".z c #a4baa4", |
311 | ".f c #aca5ac", | 269 | ".f c #aca5ac", |
312 | ".q c #acaaac", | 270 | ".q c #acaaac", |
313 | "#d c #acbeac", | 271 | "#d c #acbeac", |
314 | ".6 c #acc2ac", | 272 | ".6 c #acc2ac", |
315 | ".o c #b4b2b4", | 273 | ".o c #b4b2b4", |
316 | ".t c #b4beb4", | 274 | ".t c #b4beb4", |
317 | "#k c #b4c2ac", | 275 | "#k c #b4c2ac", |
318 | ".5 c #b4cab4", | 276 | ".5 c #b4cab4", |
319 | ".D c #bdb6bd", | 277 | ".D c #bdb6bd", |
320 | ".G c #bdc6b4", | 278 | ".G c #bdc6b4", |
321 | "#c c #bdceb4", | 279 | "#c c #bdceb4", |
322 | ".X c #bdd2bd", | 280 | ".X c #bdd2bd", |
323 | ".4 c #bdd6bd", | 281 | ".4 c #bdd6bd", |
324 | ".1 c #c5bec5", | 282 | ".1 c #c5bec5", |
325 | ".e c #c5c2c5", | 283 | ".e c #c5c2c5", |
326 | ".u c #c5cac5", | 284 | ".u c #c5cac5", |
327 | "#b c #c5d6c5", | 285 | "#b c #c5d6c5", |
328 | ".J c #c5dec5", | 286 | ".J c #c5dec5", |
329 | ".p c #cdcacd", | 287 | ".p c #cdcacd", |
330 | ".W c #cddecd", | 288 | ".W c #cddecd", |
331 | ".L c #cde2cd", | 289 | ".L c #cde2cd", |
332 | ".K c #d5eacd", | 290 | ".K c #d5eacd", |
333 | ".V c #d5ead5", | 291 | ".V c #d5ead5", |
334 | ".y c #d5eed5", | 292 | ".y c #d5eed5", |
335 | "QtQtQtQtQtQtQtQtQtQtQtQtQtQt", | 293 | "QtQtQtQtQtQtQtQtQtQtQtQtQtQt", |
336 | "QtQtQt.#.a.b.cQtQtQtQtQtQtQt", | 294 | "QtQtQt.#.a.b.cQtQtQtQtQtQtQt", |
337 | "QtQt.d.e.f.g.h.i.c.j.dQt.kQt", | 295 | "QtQt.d.e.f.g.h.i.c.j.dQt.kQt", |
338 | ".a.l.m.n.o.p.q.r.s.t.u.v.wQt", | 296 | ".a.l.m.n.o.p.q.r.s.t.u.v.wQt", |
339 | ".x.y.z.A.B.C.D.p.q.E.F.G.H.I", | 297 | ".x.y.z.A.B.C.D.p.q.E.F.G.H.I", |
340 | ".I.J.K.L.M.N.O.P.o.p.Q.R.S.T", | 298 | ".I.J.K.L.M.N.O.P.o.p.Q.R.S.T", |
341 | "Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3", | 299 | "Qt.U.V.L.W.X.Y.Z.0.P.1.s.2.3", |
342 | "Qt.3.X.W.4.X.5.6.7.8.9.s#.##", | 300 | "Qt.3.X.W.4.X.5.6.7.8.9.s#.##", |
343 | "QtQt#a.X#b#c.5.6#d#e#f#g#h#i", | 301 | "QtQt#a.X#b#c.5.6#d#e#f#g#h#i", |
344 | "QtQtQt#j.7#k.6#d#l#m#n#o#p#q", | 302 | "QtQtQt#j.7#k.6#d#l#m#n#o#p#q", |
345 | "QtQtQtQt.k#r#s#m#t.H#u#v#w#x", | 303 | "QtQtQtQt.k#r#s#m#t.H#u#v#w#x", |
346 | "QtQtQtQtQtQt.k#y#z.v#A#B#C#x", | 304 | "QtQtQtQtQtQt.k#y#z.v#A#B#C#x", |
347 | "QtQtQtQtQtQtQtQt.k#D.w#s#E.k", | 305 | "QtQtQtQtQtQtQtQt.k#D.w#s#E.k", |
348 | "QtQtQtQtQtQtQtQtQtQtQt#x#FQt"}; | 306 | "QtQtQtQtQtQtQtQtQtQtQt#x#FQt"}; |
349 | 307 | ||
350 | // exit ZSafe and clear the clipboard for security reasons | 308 | // exit ZSafe and clear the clipboard for security reasons |
351 | void ZSafe::exitZs (int ec) | 309 | void ZSafe::exitZs (int ec) |
352 | { | 310 | { |
353 | QClipboard *cb = QApplication::clipboard(); | 311 | QClipboard *cb = QApplication::clipboard(); |
354 | cb->clear(); | 312 | cb->clear(); |
355 | 313 | ||
356 | exit (ec); | 314 | exit (ec); |
357 | } | 315 | } |
358 | 316 | ||
359 | 317 | ||
360 | // save the configuration into the file | 318 | // save the configuration into the file |
361 | void ZSafe::saveConf () | 319 | void ZSafe::saveConf () |
362 | { | 320 | { |
363 | if (conf) | 321 | if (conf) |
364 | { | 322 | { |
365 | delete conf; | 323 | delete conf; |
366 | 324 | ||
367 | #ifdef DESKTOP | 325 | conf = new Config ("zsafe"); |
368 | #ifndef Q_WS_WIN | 326 | conf->setGroup ("zsafe"); |
369 | conf = new QSettings(); | ||
370 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | ||
371 | #else | ||
372 | conf = new QSettings (cfgFile); | ||
373 | conf->insertSearchPath (QSettings::Unix, cfgFile); | ||
374 | #endif | ||
375 | #else | ||
376 | conf = new Config (cfgFile, Config::File); | ||
377 | conf->setGroup ("zsafePrefs"); | ||
378 | #endif | ||
379 | } | 327 | } |
380 | } | 328 | } |
381 | 329 | ||
382 | 330 | ||
383 | /* | 331 | /* |
384 | * Constructs a ZSafe which is a child of 'parent', with the | 332 | * Constructs a ZSafe which is a child of 'parent', with the |
385 | * name 'name' and widget flags set to 'f' | 333 | * name 'name' and widget flags set to 'f' |
386 | * | 334 | * |
387 | * The dialog will by default be modeless, unless you set 'modal' to | 335 | * The dialog will by default be modeless, unless you set 'modal' to |
388 | * TRUE to construct a modal dialog. | 336 | * TRUE to construct a modal dialog. |
389 | */ | 337 | */ |
390 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | 338 | ZSafe::ZSafe( QWidget* parent, const char* name, WFlags fl ) |
391 | : QDialog( parent, name, modal, fl ), | 339 | : QWidget( parent, name, fl), |
392 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) | 340 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) |
393 | { | 341 | { |
342 | zs = this; | ||
343 | appl = qApp; | ||
344 | DeskW = qApp->desktop()->width(); | ||
345 | DeskH = qApp->desktop()->height(); | ||
346 | |||
394 | IsCut = false; | 347 | IsCut = false; |
395 | IsCopy = false; | 348 | IsCopy = false; |
396 | modified = false; | 349 | modified = false; |
397 | showpwd = false; | 350 | showpwd = false; |
398 | 351 | ||
399 | // set the config file | 352 | // set the config file |
400 | cfgFile=QDir::homeDirPath(); | 353 | cfgFile=QDir::homeDirPath(); |
401 | cfgFile += "/.zsafe.cfg"; | 354 | cfgFile += "/.zsafe.cfg"; |
402 | // set the icon path | 355 | // set the icon path |
403 | #ifdef NO_OPIE | ||
404 | QString qpedir ((const char *)getenv("QPEDIR")); | ||
405 | #else | ||
406 | QString qpedir ((const char *)getenv("OPIEDIR")); | ||
407 | #endif | ||
408 | 356 | ||
409 | #ifdef DESKTOP | 357 | QString qpeDir = QPEApplication::qpeDir(); |
410 | iconPath = QDir::homeDirPath() + "/pics/"; | ||
411 | #else | ||
412 | if (qpedir.isEmpty()) | ||
413 | iconPath = "/home/QtPalmtop/pics/"; | ||
414 | else | ||
415 | iconPath = qpedir + "/pics/"; | ||
416 | #endif | ||
417 | 358 | ||
418 | // create a zsafe configuration object | 359 | conf = new Config ("zsafe"); |
419 | #ifdef DESKTOP | ||
420 | #ifndef Q_WS_WIN | ||
421 | conf = new QSettings (); | ||
422 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | ||
423 | #else | ||
424 | conf = new QSettings (cfgFile); | ||
425 | conf->insertSearchPath (QSettings::Unix, cfgFile); | ||
426 | #endif | ||
427 | #else | ||
428 | conf = new Config (cfgFile, Config::File); | ||
429 | conf->setGroup ("zsafePrefs"); | 360 | conf->setGroup ("zsafePrefs"); |
430 | #endif | 361 | |
431 | #ifdef DESKTOP | ||
432 | // #ifndef Q_WS_WIN | ||
433 | expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); | ||
434 | // #endif | ||
435 | #else | ||
436 | expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); | 362 | expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); |
437 | #endif | ||
438 | #ifndef DESKTOP | ||
439 | conf->setGroup ("zsafe"); | 363 | conf->setGroup ("zsafe"); |
440 | #endif | ||
441 | 364 | ||
442 | QPixmap copy_img((const char**) copy_xpm); | 365 | QPixmap copy_img((const char**) copy_xpm); |
443 | QPixmap cut_img((const char**) cut_xpm); | 366 | QPixmap cut_img((const char**) cut_xpm); |
444 | QPixmap edit_img((const char**) edit_xpm); | 367 | QPixmap edit_img((const char**) edit_xpm); |
445 | QPixmap editdelete_img((const char**) editdelete_xpm); | 368 | QPixmap editdelete_img((const char**) editdelete_xpm); |
446 | QPixmap find_img((const char**) find_xpm); | 369 | QPixmap find_img((const char**) find_xpm); |
447 | QPixmap folder_open_img((const char**) folder_open_xpm); | 370 | QPixmap folder_open_img((const char**) folder_open_xpm); |
448 | QPixmap help_icon_img((const char**) help_icon_xpm); | 371 | QPixmap help_icon_img((const char**) help_icon_xpm); |
449 | QPixmap new_img((const char**) new_xpm); | 372 | QPixmap new_img((const char**) new_xpm); |
450 | QPixmap paste_img((const char**) paste_xpm); | 373 | QPixmap paste_img((const char**) paste_xpm); |
451 | QPixmap quit_icon_img((const char**) quit_icon_xpm); | 374 | QPixmap quit_icon_img((const char**) quit_icon_xpm); |
452 | QPixmap save_img((const char**) save_xpm); | 375 | QPixmap save_img((const char**) save_xpm); |
453 | QPixmap trash_img((const char**) trash_xpm); | 376 | QPixmap trash_img((const char**) trash_xpm); |
454 | QPixmap expand_img((const char**) expand_xpm); | 377 | QPixmap expand_img((const char**) expand_xpm); |
455 | QPixmap export_img((const char**) export_xpm); | 378 | QPixmap export_img((const char**) export_xpm); |
456 | QPixmap import_img((const char**) import_xpm); | 379 | QPixmap import_img((const char**) import_xpm); |
457 | 380 | ||
458 | QPixmap bank_cards( ( const char** ) bank_cards_data ); | 381 | QPixmap bank_cards( ( const char** ) bank_cards_data ); |
459 | QPixmap passwords( ( const char** ) passwords_data ); | 382 | QPixmap passwords( ( const char** ) passwords_data ); |
460 | QPixmap software( ( const char** ) software_data ); | 383 | QPixmap software( ( const char** ) software_data ); |
461 | QPixmap general( ( const char** ) general_data ); | 384 | QPixmap general( ( const char** ) general_data ); |
462 | QPixmap image0( ( const char** ) zsafe_xpm ); | 385 | QPixmap image0( ( const char** ) zsafe_xpm ); |
463 | if ( !name ) | ||
464 | setName( "ZSafe" ); | ||
465 | |||
466 | #ifdef DESKTOP | ||
467 | #ifdef Q_WS_WIN | ||
468 | setGeometry(100, 150, DeskW, DeskH-30 ); | ||
469 | #else | ||
470 | resize( DeskW, DeskH-30 ); | ||
471 | #endif | ||
472 | |||
473 | #else | ||
474 | 386 | ||
475 | #ifdef JPATCH_HDE | 387 | if ( !name ) |
476 | int DeskS; | 388 | setName( "ZSafe" ); |
477 | if(DeskW > DeskH) | ||
478 | { | ||
479 | DeskS = DeskW; | ||
480 | } | ||
481 | else | ||
482 | { | ||
483 | DeskS = DeskH; | ||
484 | } | ||
485 | resize( DeskW, DeskH ); | ||
486 | setMinimumSize( QSize( DeskS, DeskS ) ); | ||
487 | setMaximumSize( QSize( DeskS, DeskS ) ); | ||
488 | #else | ||
489 | resize( DeskW, DeskH-30 ); | ||
490 | #endif | ||
491 | 389 | ||
492 | #endif | ||
493 | setCaption( tr( "ZSafe" ) ); | 390 | setCaption( tr( "ZSafe" ) ); |
494 | QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe"; | 391 | QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe"; |
392 | |||
495 | filename = conf->readEntry(APP_KEY+"document"); | 393 | filename = conf->readEntry(APP_KEY+"document"); |
496 | if ( !QFileInfo(filename).exists() || !QDir(zsafeAppDirPath).exists() ) | 394 | if ( !QFileInfo(filename).exists() || !QDir(zsafeAppDirPath).exists() ) |
497 | { | 395 | { |
498 | // check if the directory application exists, if not | 396 | // check if the directory application exists, if not |
499 | // create it | 397 | // create it |
500 | // #ifndef Q_WS_WIN | ||
501 | // QString d1("Documents/application"); | ||
502 | // #else | ||
503 | QString d1(QDir::homeDirPath() + "/Documents/application"); | 398 | QString d1(QDir::homeDirPath() + "/Documents/application"); |
504 | // #endif | ||
505 | QDir pd1(d1); | 399 | QDir pd1(d1); |
506 | if (!pd1.exists()) | 400 | if (!pd1.exists()) |
507 | { | 401 | { |
508 | QDir pd2(QDir::homeDirPath() + "/Documents"); | 402 | QDir pd2(QDir::homeDirPath() + "/Documents"); |
509 | if (!pd2.exists()) { | 403 | if (!pd2.exists()) { |
510 | QDir pd3(QDir::homeDirPath()); | 404 | QDir pd3(QDir::homeDirPath()); |
511 | if (!pd3.mkdir("Documents", FALSE)) { | 405 | if (!pd3.mkdir("Documents", FALSE)) { |
512 | } | 406 | } |
513 | } | 407 | } |
514 | 408 | ||
515 | if (!pd2.mkdir("application", FALSE)) | 409 | if (!pd2.mkdir("application", FALSE)) |
516 | { | 410 | { |
517 | QMessageBox::critical( 0, tr("ZSafe"), | 411 | QMessageBox::critical( 0, tr("ZSafe"), |
518 | #ifdef JPATCH_HDE | ||
519 | tr("<P>Can't create directory ..."+d1+"</P><P>ZSafe will now exit.</P>")); | ||
520 | #else | ||
521 | tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d1)); | 412 | tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d1)); |
522 | #endif | ||
523 | exitZs (1); | 413 | exitZs (1); |
524 | } | 414 | } |
525 | } | 415 | } |
526 | // #ifndef Q_WS_WIN | ||
527 | // QString d2("Documents/application/zsafe"); | ||
528 | // #else | ||
529 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); | 416 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); |
530 | // #endif | ||
531 | QDir pd2(d2); | 417 | QDir pd2(d2); |
532 | if (!pd2.exists()) | 418 | if (!pd2.exists()) |
533 | { | 419 | { |
534 | if (!pd1.mkdir("zsafe", FALSE)) | 420 | if (!pd1.mkdir("zsafe", FALSE)) |
535 | { | 421 | { |
536 | QMessageBox::critical( 0, tr("ZSafe"), | 422 | QMessageBox::critical( 0, tr("ZSafe"), |
537 | #ifdef JPATCH_HDE | ||
538 | tr("<P>Can't create directory ...//Documents/application/zsafe</P><P>ZSafe will now exit.</P")); | ||
539 | #else | ||
540 | tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d2)); | 423 | tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d2)); |
541 | #endif | ||
542 | exitZs (1); | 424 | exitZs (1); |
543 | } | 425 | } |
544 | } | 426 | } |
545 | 427 | ||
546 | filename = zsafeAppDirPath + "/passwords.zsf"; | 428 | filename = zsafeAppDirPath + "/passwords.zsf"; |
547 | 429 | ||
548 | // save the current filename to the config file | 430 | // save the current filename to the config file |
549 | conf->writeEntry(APP_KEY+"document", filename); | 431 | conf->writeEntry(APP_KEY+"document", filename); |
550 | saveConf(); | 432 | saveConf(); |
551 | } | 433 | } |
552 | //if (filename == "INVALIDPWD") | 434 | //if (filename == "INVALIDPWD") |
553 | //filename = ""; | 435 | //filename = ""; |
554 | 436 | ||
555 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 437 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
556 | #ifdef Q_WS_WIN | 438 | this->setCaption(tr("ZSafe: ") + ti); |
557 | this->setCaption("Qt ZSafe: " + ti); | ||
558 | #else | ||
559 | this->setCaption("ZSafe: " + ti); | ||
560 | #endif | ||
561 | 439 | ||
562 | selectedItem = NULL; | 440 | selectedItem = NULL; |
563 | lastSearchedCategory = NULL; | 441 | lastSearchedCategory = NULL; |
564 | lastSearchedItem = NULL; | 442 | lastSearchedItem = NULL; |
565 | lastSearchedName = ""; | 443 | lastSearchedName = ""; |
566 | lastSearchedUsername = ""; | 444 | lastSearchedUsername = ""; |
567 | lastSearchedComment = ""; | 445 | lastSearchedComment = ""; |
568 | 446 | ||
569 | infoForm = new InfoForm(this, "show_info", TRUE); | 447 | infoForm = new InfoForm(this, "show_info", TRUE); |
570 | categoryDialog = NULL; | 448 | categoryDialog = NULL; |
571 | infoForm->setIcon( image0); | 449 | infoForm->setIcon( image0); |
572 | 450 | ||
573 | // add a menu bar | 451 | // add a menu bar |
574 | QMenuBar *menu = new QMenuBar( this ); | 452 | QMenuBar *menu = new QMenuBar( this ); |
575 | 453 | ||
576 | // add file menu | 454 | // add file menu |
577 | // QPopupMenu *file = new QPopupMenu( this ); | 455 | // QPopupMenu *file = new QPopupMenu( this ); |
578 | file = new QPopupMenu( this ); | 456 | file = new QPopupMenu( this ); |
579 | 457 | ||
580 | // #ifdef DESKTOP | ||
581 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); | 458 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); |
582 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); | 459 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); |
583 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); | 460 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); |
584 | file->insertSeparator(); | 461 | file->insertSeparator(); |
585 | // #endif | ||
586 | 462 | ||
587 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); | 463 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); |
588 | file->insertItem( save_img, tr("S&ave document with new Password"), this, | 464 | file->insertItem( save_img, tr("S&ave document with new Password"), this, |
589 | SLOT(saveDocumentWithPwd()) ); | 465 | SLOT(saveDocumentWithPwd()) ); |
590 | file->insertSeparator(); | 466 | file->insertSeparator(); |
591 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); | 467 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); |
592 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); | 468 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); |
593 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); | 469 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); |
594 | file->insertSeparator(); | 470 | file->insertSeparator(); |
595 | file->insertItem( expand_img, tr("&Open entries expanded"), this, | 471 | file->insertItem( expand_img, tr("&Open entries expanded"), this, |
596 | SLOT(setExpandFlag()), 0, 'o'); | 472 | SLOT(setExpandFlag()), 0, 'o'); |
597 | file->setItemChecked('o', expandTree); | 473 | file->setItemChecked('o', expandTree); |
598 | file->insertSeparator(); | 474 | file->insertSeparator(); |
599 | file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); | 475 | file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); |
600 | menu->insertItem( tr("&File"), file ); | 476 | menu->insertItem( tr("&File"), file ); |
601 | 477 | ||
602 | QPopupMenu *cat = new QPopupMenu( this ); | 478 | QPopupMenu *cat = new QPopupMenu( this ); |
603 | cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); | 479 | cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); |
604 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); | 480 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); |
605 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); | 481 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); |
606 | menu->insertItem( tr("&Category"), cat ); | 482 | menu->insertItem( tr("&Category"), cat ); |
607 | 483 | ||
608 | QPopupMenu *it = new QPopupMenu( this ); | 484 | QPopupMenu *it = new QPopupMenu( this ); |
609 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); | 485 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); |
610 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); | 486 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); |
611 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); | 487 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); |
612 | it->insertSeparator(); | 488 | it->insertSeparator(); |
613 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); | 489 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); |
614 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); | 490 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); |
615 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); | 491 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); |
616 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); | 492 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); |
617 | menu->insertItem( tr("&Entry"), it ); | 493 | menu->insertItem( tr("&Entry"), it ); |
618 | 494 | ||
619 | QPopupMenu *help = new QPopupMenu( this ); | 495 | QPopupMenu *help = new QPopupMenu( this ); |
620 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); | 496 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); |
621 | menu->insertItem( tr("&Help"), help ); | 497 | menu->insertItem( tr("&Help"), help ); |
622 | 498 | ||
623 | // toolbar icons | 499 | // toolbar icons |
624 | 500 | ||
625 | New = new QToolButton( menu, "New" ); | 501 | New = new QToolButton( menu, "New" ); |
626 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); | 502 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); |
627 | New->setMouseTracking( TRUE ); | 503 | New->setMouseTracking( TRUE ); |
628 | New->setText( "" ); | 504 | New->setText( "" ); |
629 | New->setPixmap( new_img ); | 505 | New->setPixmap( new_img ); |
630 | QToolTip::add( New, tr( "New entry" ) ); | 506 | QToolTip::add( New, tr( "New entry" ) ); |
631 | 507 | ||
632 | Edit = new QToolButton( menu, "Edit" ); | 508 | Edit = new QToolButton( menu, "Edit" ); |
633 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); | 509 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); |
634 | Edit->setText( "" ); | 510 | Edit->setText( "" ); |
635 | Edit->setPixmap( edit_img ); | 511 | Edit->setPixmap( edit_img ); |
636 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); | 512 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); |
637 | 513 | ||
638 | Delete = new QToolButton( menu, "Delete" ); | 514 | Delete = new QToolButton( menu, "Delete" ); |
639 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 515 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); |
640 | Delete->setText( "" ); | 516 | Delete->setText( "" ); |
641 | Delete->setPixmap( trash_img ); | 517 | Delete->setPixmap( trash_img ); |
642 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); | 518 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); |
643 | 519 | ||
644 | Find = new QToolButton( menu, "Find" ); | 520 | Find = new QToolButton( menu, "Find" ); |
645 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); | 521 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); |
646 | Find->setText( "" ); | 522 | Find->setText( "" ); |
647 | Find->setPixmap( find_img ); | 523 | Find->setPixmap( find_img ); |
648 | QToolTip::add( Find, tr( "Find entry" ) ); | 524 | QToolTip::add( Find, tr( "Find entry" ) ); |
649 | 525 | ||
650 | /* | 526 | /* |
651 | QBoxLayout * h = new QHBoxLayout( this ); | 527 | QBoxLayout * h = new QHBoxLayout( this ); |
652 | h->addWidget (menu); | 528 | h->addWidget (menu); |
653 | h->addWidget (New); | 529 | h->addWidget (New); |
654 | h->addWidget (Edit); | 530 | h->addWidget (Edit); |
655 | h->addWidget (Delete); | 531 | h->addWidget (Delete); |
656 | h->addWidget (Find); | 532 | h->addWidget (Find); |
657 | */ | 533 | */ |
658 | 534 | ||
659 | ListView = new ZListView( this, "ListView" ); | 535 | ListView = new ZListView( this, "ListView" ); |
660 | ListView->addColumn( tr( "Name" ) ); | 536 | ListView->addColumn( tr( "Name" ) ); |
661 | ListView->addColumn( tr( "Field 2" ) ); | 537 | ListView->addColumn( tr( "Field 2" ) ); |
662 | ListView->addColumn( tr( "Field 3" ) ); | 538 | ListView->addColumn( tr( "Field 3" ) ); |
663 | ListView->addColumn( tr( "Comment" ) ); | 539 | ListView->addColumn( tr( "Comment" ) ); |
664 | ListView->addColumn( tr( "Field 4" ) ); | 540 | ListView->addColumn( tr( "Field 4" ) ); |
665 | ListView->addColumn( tr( "Field 5" ) ); | 541 | ListView->addColumn( tr( "Field 5" ) ); |
666 | ListView->setAllColumnsShowFocus(TRUE); | 542 | ListView->setAllColumnsShowFocus(TRUE); |
667 | 543 | ||
668 | #ifdef DESKTOP | ||
669 | // ListView->setResizePolicy(QScrollView::AutoOneFit); | ||
670 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); | ||
671 | #else | ||
672 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 544 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
673 | // ListView->setGeometry( QRect( 0, 22, | 545 | // ListView->setGeometry( QRect( 0, 22, |
674 | // this->width(), this->height() - 30 ) ); | 546 | // this->width(), this->height() - 30 ) ); |
675 | // ListView->setMaximumSize( QSize( 440, 290 ) ); | 547 | // ListView->setMaximumSize( QSize( 440, 290 ) ); |
676 | #endif | ||
677 | // ListView->setVScrollBarMode( QListView::Auto ); | 548 | // ListView->setVScrollBarMode( QListView::Auto ); |
678 | 549 | ||
679 | QBoxLayout * l = new QVBoxLayout( this ); | 550 | QBoxLayout * l = new QVBoxLayout( this ); |
680 | l->addWidget (menu); | 551 | l->addWidget (menu); |
681 | l->addWidget (ListView); | 552 | l->addWidget (ListView); |
682 | 553 | ||
683 | #ifndef DESKTOP | ||
684 | // start a timer (100 ms) to load the default document | 554 | // start a timer (100 ms) to load the default document |
685 | docuTimer.start( 100, true ); | 555 | docuTimer.start( 100, true ); |
686 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); | 556 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); |
687 | raiseFlag = true; | 557 | raiseFlag = true; |
688 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); | 558 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); |
689 | #else | ||
690 | // open the default document | ||
691 | openDocument(filename); | ||
692 | #endif | ||
693 | 559 | ||
694 | // signals and slots connections for QTollButton | 560 | // signals and slots connections for QTollButton |
695 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); | 561 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); |
696 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); | 562 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); |
697 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); | 563 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); |
698 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); | 564 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); |
699 | // signals and slots connections for QListView | 565 | // signals and slots connections for QListView |
700 | connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), | 566 | connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), |
701 | this, SLOT( listViewSelected(QListViewItem*) ) ); | 567 | this, SLOT( listViewSelected(QListViewItem*) ) ); |
702 | connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), | 568 | connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), |
703 | this, SLOT( showInfo(QListViewItem*) ) ); | 569 | this, SLOT( showInfo(QListViewItem*) ) ); |
704 | connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), | 570 | connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), |
705 | this, SLOT( showInfo(QListViewItem*) ) ); | 571 | this, SLOT( showInfo(QListViewItem*) ) ); |
706 | 572 | ||
707 | #ifndef DESKTOP | 573 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); |
708 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); | ||
709 | #endif | ||
710 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 574 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
711 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 575 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
712 | 576 | ||
713 | this->setIcon( image0); | 577 | this->setIcon( image0); |
714 | #ifdef Q_WS_WIN | ||
715 | ListView->setSelected( ListView->firstChild() , true); | ||
716 | ListView->setSelected( ListView->firstChild() , false); | ||
717 | #endif | ||
718 | } | 578 | } |
719 | 579 | ||
720 | const QColor *ZSafe::evenRowColor = &Qt::white; | 580 | const QColor *ZSafe::evenRowColor = &Qt::white; |
721 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; | 581 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; |
722 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); | 582 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); |
723 | 583 | ||
724 | /* | 584 | /* |
725 | * Destroys the object and frees any allocated resources | 585 | * Destroys the object and frees any allocated resources |
726 | */ | 586 | */ |
727 | ZSafe::~ZSafe() | 587 | ZSafe::~ZSafe() |
728 | { | 588 | { |
729 | // no need to delete child widgets, Qt does it all for us | 589 | // no need to delete child widgets, Qt does it all for us |
730 | quitMe(); | 590 | quitMe(); |
731 | } | 591 | } |
732 | 592 | ||
733 | // load the default document | 593 | // load the default document |
734 | void ZSafe::slotLoadDocu() | 594 | void ZSafe::slotLoadDocu() |
735 | { | 595 | { |
736 | openDocument (filename); | 596 | openDocument (filename); |
737 | } | 597 | } |
738 | 598 | ||
739 | void ZSafe::deletePwd() | 599 | void ZSafe::deletePwd() |
740 | { | 600 | { |
741 | 601 | ||
742 | if (!selectedItem) | 602 | if (!selectedItem) |
743 | return; | 603 | return; |
744 | if (!isCategory(selectedItem)) | 604 | if (!isCategory(selectedItem)) |
745 | { | 605 | { |
746 | switch( QMessageBox::information( this, tr("ZSafe"), | 606 | switch( QMessageBox::information( this, tr("ZSafe"), |
747 | tr("Do you want to delete?"), | 607 | tr("Do you want to delete?"), |
748 | tr("&Delete"), tr("D&on't Delete"), | 608 | tr("&Delete"), tr("D&on't Delete"), |
749 | 0 // Enter == button 0 | 609 | 0 // Enter == button 0 |
750 | ) ) { // Escape == button 2 | 610 | ) ) { // Escape == button 2 |
751 | case 0: // Delete clicked, Alt-S or Enter pressed. | 611 | case 0: // Delete clicked, Alt-S or Enter pressed. |
752 | // Delete | 612 | // Delete |
753 | modified = true; | 613 | modified = true; |
754 | selectedItem->parent()->takeItem(selectedItem); | 614 | selectedItem->parent()->takeItem(selectedItem); |
755 | selectedItem = NULL; | 615 | selectedItem = NULL; |
756 | break; | 616 | break; |
757 | case 1: // Don't delete | 617 | case 1: // Don't delete |
758 | break; | 618 | break; |
759 | } | 619 | } |
760 | } | 620 | } |
761 | else | 621 | else |
762 | { | 622 | { |
763 | delCategory(); | 623 | delCategory(); |
764 | } | 624 | } |
765 | } | 625 | } |
766 | 626 | ||
767 | void ZSafe::editPwd() | 627 | void ZSafe::editPwd() |
768 | { | 628 | { |
769 | if (!selectedItem) | 629 | if (!selectedItem) |
770 | return; | 630 | return; |
771 | if (!isCategory(selectedItem)) | 631 | if (!isCategory(selectedItem)) |
772 | { | 632 | { |
773 | // open the 'New Entry' dialog | 633 | // open the 'New Entry' dialog |
774 | NewDialog *dialog = new NewDialog(this, "edit_entry", TRUE); | 634 | NewDialog *dialog = new NewDialog(this, "edit_entry", TRUE); |
775 | #ifdef Q_WS_WIN | ||
776 | dialog->setCaption ("Qt " + tr("Edit Entry")); | ||
777 | dialog->setGeometry(200, 250, 220, 310 ); | ||
778 | #endif | ||
779 | 635 | ||
780 | // set the labels | 636 | // set the labels |
781 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 637 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
782 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 638 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
783 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 639 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
784 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 640 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
785 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 641 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
786 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 642 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
787 | 643 | ||
788 | // set the fields | 644 | // set the fields |
789 | dialog->NameField->setText(selectedItem->text (0)); | 645 | dialog->NameField->setText(selectedItem->text (0)); |
790 | dialog->UsernameField->setText(selectedItem->text (1)); | 646 | dialog->UsernameField->setText(selectedItem->text (1)); |
791 | dialog->PasswordField->setText(selectedItem->text (2)); | 647 | dialog->PasswordField->setText(selectedItem->text (2)); |
792 | QString comment = selectedItem->text (3); | 648 | QString comment = selectedItem->text (3); |
793 | comment.replace (QRegExp("<br>"), "\n"); | 649 | comment.replace (QRegExp("<br>"), "\n"); |
794 | dialog->Field5->setText(selectedItem->text (4)); | 650 | dialog->Field5->setText(selectedItem->text (4)); |
795 | dialog->Field6->setText(selectedItem->text (5)); | 651 | dialog->Field6->setText(selectedItem->text (5)); |
796 | dialog->CommentField->insertLine(comment); | 652 | dialog->CommentField->insertLine(comment); |
797 | dialog->CommentField->setCursorPosition(0,0); | 653 | dialog->CommentField->setCursorPosition(0,0); |
798 | 654 | ||
799 | #ifdef Q_WS_QWS | 655 | QDialog::DialogCode result = (QDialog::DialogCode) QPEApplication::execDialog( dialog ); |
800 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); | 656 | if (result == QDialog::Accepted) |
801 | #endif | ||
802 | |||
803 | #ifdef DESKTOP | ||
804 | #ifndef Q_QW_QWIN | ||
805 | dialog->show(); | ||
806 | #endif | ||
807 | #else | ||
808 | dialog->showMaximized(); | ||
809 | #endif | ||
810 | #ifdef DESKTOP | ||
811 | int result = dialog->exec(); | ||
812 | result = QDialog::Accepted; | ||
813 | #endif | ||
814 | if (result == Accepted) | ||
815 | { | 657 | { |
816 | modified = true; | 658 | modified = true; |
817 | // edit the selected item | 659 | // edit the selected item |
818 | QString name = dialog->NameField->text(); | 660 | QString name = dialog->NameField->text(); |
819 | selectedItem->setText (0, tr (name)); | 661 | selectedItem->setText (0, tr (name)); |
820 | QString user = dialog->UsernameField->text(); | 662 | QString user = dialog->UsernameField->text(); |
821 | selectedItem->setText (1, tr (user)); | 663 | selectedItem->setText (1, tr (user)); |
822 | QString pwd = dialog->PasswordField->text(); | 664 | QString pwd = dialog->PasswordField->text(); |
823 | selectedItem->setText (2, tr (pwd)); | 665 | selectedItem->setText (2, tr (pwd)); |
824 | QString comment = dialog->CommentField->text(); | 666 | QString comment = dialog->CommentField->text(); |
825 | comment.replace (QRegExp("\n"), "<br>"); | 667 | comment.replace (QRegExp("\n"), "<br>"); |
826 | selectedItem->setText (3, tr (comment)); | 668 | selectedItem->setText (3, tr (comment)); |
827 | QString f5 = dialog->Field5->text(); | 669 | QString f5 = dialog->Field5->text(); |
828 | selectedItem->setText (4, tr (f5)); | 670 | selectedItem->setText (4, tr (f5)); |
829 | QString f6 = dialog->Field6->text(); | 671 | QString f6 = dialog->Field6->text(); |
830 | selectedItem->setText (5, tr (f6)); | 672 | selectedItem->setText (5, tr (f6)); |
831 | } | 673 | } |
832 | 674 | ||
833 | delete dialog; | 675 | delete dialog; |
834 | } | 676 | } |
835 | else | 677 | else |
836 | { | 678 | { |
837 | editCategory(); | 679 | editCategory(); |
838 | } | 680 | } |
839 | } | 681 | } |
840 | 682 | ||
841 | void ZSafe::newPwd() | 683 | void ZSafe::newPwd() |
842 | { | 684 | { |
843 | if (!selectedItem) | 685 | if (!selectedItem) |
844 | return; | 686 | return; |
845 | qWarning("new item"); | 687 | qWarning("new item"); |
846 | if (!isCategory(selectedItem)) | 688 | if (!isCategory(selectedItem)) |
847 | selectedItem = selectedItem->parent(); | 689 | selectedItem = selectedItem->parent(); |
848 | 690 | ||
849 | if (isCategory(selectedItem)) | 691 | if (isCategory(selectedItem)) |
850 | { | 692 | { |
851 | QString cat = selectedItem->text(0); | 693 | QString cat = selectedItem->text(0); |
852 | qWarning(cat); | 694 | qWarning(cat); |
853 | // open the 'New Entry' dialog | 695 | // open the 'New Entry' dialog |
854 | NewDialog *dialog = new NewDialog(this, "new_entry", TRUE); | 696 | NewDialog *dialog = new NewDialog(this, "new_entry", TRUE); |
855 | #ifdef Q_WS_WIN | ||
856 | dialog->setCaption ("Qt " + tr("New Entry")); | ||
857 | dialog->setGeometry(200, 250, 220, 310 ); | ||
858 | #endif | ||
859 | // set the labels | 697 | // set the labels |
860 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 698 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
861 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 699 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
862 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 700 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
863 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 701 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
864 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 702 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
865 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 703 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
866 | retype: | 704 | retype: |
867 | 705 | ||
868 | #ifdef Q_WS_QWS | 706 | #ifdef Q_WS_QWS |
869 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); | 707 | QDialog::DialogCode result = (QDialog::DialogCode) QPEApplication::execDialog( dialog ); |
870 | #endif | ||
871 | |||
872 | #ifdef DESKTOP | ||
873 | #ifndef Q_QW_QWIN | ||
874 | dialog->show(); | ||
875 | #endif | ||
876 | #else | ||
877 | dialog->showMaximized(); | ||
878 | #endif | ||
879 | #ifdef DESKTOP | ||
880 | int result = dialog->exec(); | ||
881 | result = QDialog::Accepted; | ||
882 | #endif | 708 | #endif |
883 | 709 | if (result == QDialog::Accepted) | |
884 | if (result == Accepted) | ||
885 | { | 710 | { |
886 | 711 | ||
887 | QString name = dialog->NameField->text(); | 712 | QString name = dialog->NameField->text(); |
888 | if (cat == name) | 713 | if (cat == name) |
889 | { | 714 | { |
890 | QMessageBox::critical( 0, tr("ZSafe"), | 715 | QMessageBox::critical( 0, tr("ZSafe"), |
891 | tr("Entry name must be different\nfrom the category name.") ); | 716 | tr("Entry name must be different\nfrom the category name.") ); |
892 | goto retype; // it's not a good programming style :-) | 717 | goto retype; // it's not a good programming style :-) |
893 | } | 718 | } |
894 | 719 | ||
895 | modified = true; | 720 | modified = true; |
896 | // add the new item | 721 | // add the new item |
897 | QListViewItem *i = new ShadedListItem (0, selectedItem); | 722 | QListViewItem *i = new ShadedListItem (0, selectedItem); |
898 | i->setOpen (TRUE); | 723 | i->setOpen (TRUE); |
899 | 724 | ||
900 | i->setText (0, tr (name)); | 725 | i->setText (0, tr (name)); |
901 | QString user = dialog->UsernameField->text(); | 726 | QString user = dialog->UsernameField->text(); |
902 | i->setText (1, tr (user)); | 727 | i->setText (1, tr (user)); |
903 | QString pwd = dialog->PasswordField->text(); | 728 | QString pwd = dialog->PasswordField->text(); |
904 | i->setText (2, tr (pwd)); | 729 | i->setText (2, tr (pwd)); |
905 | QString comment = dialog->CommentField->text(); | 730 | QString comment = dialog->CommentField->text(); |
906 | comment.replace (QRegExp("\n"), "<br>"); | 731 | comment.replace (QRegExp("\n"), "<br>"); |
907 | i->setText (3, tr (comment)); | 732 | i->setText (3, tr (comment)); |
908 | QString f5 = dialog->Field5->text(); | 733 | QString f5 = dialog->Field5->text(); |
909 | i->setText (4, tr (f5)); | 734 | i->setText (4, tr (f5)); |
910 | QString f6 = dialog->Field6->text(); | 735 | QString f6 = dialog->Field6->text(); |
911 | i->setText (5, tr (f6)); | 736 | i->setText (5, tr (f6)); |
912 | } | 737 | } |
913 | 738 | ||
914 | delete dialog; | 739 | delete dialog; |
915 | } | 740 | } |
916 | } | 741 | } |
917 | 742 | ||
918 | void ZSafe::findPwd() | 743 | void ZSafe::findPwd() |
919 | { | 744 | { |
920 | 745 | ||
921 | // open the 'Search' dialog | 746 | // open the 'Search' dialog |
922 | SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); | 747 | SearchDialog *dialog = new SearchDialog(this, tr("Search"), TRUE); |
923 | #ifdef Q_WS_WIN | ||
924 | dialog->setCaption ("Qt " + tr("Search")); | ||
925 | #endif | ||
926 | 748 | ||
927 | #ifdef DESKTOP | ||
928 | #endif | ||
929 | if (lastSearchedName) | 749 | if (lastSearchedName) |
930 | dialog->NameField->setText(lastSearchedName); | 750 | dialog->NameField->setText(lastSearchedName); |
931 | else | 751 | else |
932 | dialog->NameField->setText(""); | 752 | dialog->NameField->setText(""); |
933 | if (lastSearchedUsername) | 753 | if (lastSearchedUsername) |
934 | dialog->UsernameField->setText(lastSearchedUsername); | 754 | dialog->UsernameField->setText(lastSearchedUsername); |
935 | else | 755 | else |
936 | dialog->UsernameField->setText(""); | 756 | dialog->UsernameField->setText(""); |
937 | if (lastSearchedComment) | 757 | if (lastSearchedComment) |
938 | dialog->CommentField->setText(lastSearchedComment); | 758 | dialog->CommentField->setText(lastSearchedComment); |
939 | else | 759 | else |
940 | dialog->CommentField->setText(""); | 760 | dialog->CommentField->setText(""); |
941 | DialogCode result = (DialogCode) dialog->exec(); | 761 | QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); |
942 | #ifdef DESKTOP | ||
943 | result = Accepted; | ||
944 | #endif | ||
945 | 762 | ||
946 | QString name; | 763 | QString name; |
947 | QString username; | 764 | QString username; |
948 | QString comment; | 765 | QString comment; |
949 | if (result == Accepted) | 766 | if (result == QDialog::Accepted) |
950 | { | 767 | { |
951 | name = dialog->NameField->text(); | 768 | name = dialog->NameField->text(); |
952 | username = dialog->UsernameField->text(); | 769 | username = dialog->UsernameField->text(); |
953 | comment = dialog->CommentField->text(); | 770 | comment = dialog->CommentField->text(); |
954 | #ifndef NO_OPIE | ||
955 | owarn << name << oendl; | ||
956 | #else | ||
957 | qWarning (name); | ||
958 | #endif | ||
959 | } | 771 | } |
960 | else | 772 | else |
961 | { | 773 | { |
962 | delete dialog; | 774 | delete dialog; |
963 | return; | 775 | return; |
964 | } | 776 | } |
965 | 777 | ||
966 | if (!name.isEmpty() && name != lastSearchedName || | 778 | if (!name.isEmpty() && name != lastSearchedName || |
967 | lastSearchedName.isEmpty() && !name.isEmpty()) | 779 | lastSearchedName.isEmpty() && !name.isEmpty()) |
968 | { | 780 | { |
969 | // set search at the beginning if a new name is given | 781 | // set search at the beginning if a new name is given |
970 | lastSearchedCategory = NULL; | 782 | lastSearchedCategory = NULL; |
971 | lastSearchedItem = NULL; | 783 | lastSearchedItem = NULL; |
972 | } | 784 | } |
973 | lastSearchedName = name; | 785 | lastSearchedName = name; |
974 | if (!username.isEmpty() && username != lastSearchedUsername || | 786 | if (!username.isEmpty() && username != lastSearchedUsername || |
975 | lastSearchedUsername.isEmpty() && !username.isEmpty()) | 787 | lastSearchedUsername.isEmpty() && !username.isEmpty()) |
976 | { | 788 | { |
977 | // set search at the beginning if a new name is given | 789 | // set search at the beginning if a new name is given |
978 | lastSearchedCategory = NULL; | 790 | lastSearchedCategory = NULL; |
979 | lastSearchedItem = NULL; | 791 | lastSearchedItem = NULL; |
980 | } | 792 | } |
981 | lastSearchedUsername = username; | 793 | lastSearchedUsername = username; |
982 | if (!comment.isEmpty() && comment != lastSearchedComment || | 794 | if (!comment.isEmpty() && comment != lastSearchedComment || |
983 | lastSearchedComment.isEmpty() && !comment.isEmpty()) | 795 | lastSearchedComment.isEmpty() && !comment.isEmpty()) |
984 | { | 796 | { |
985 | // set search at the beginning if a new name is given | 797 | // set search at the beginning if a new name is given |
986 | lastSearchedCategory = NULL; | 798 | lastSearchedCategory = NULL; |
987 | lastSearchedItem = NULL; | 799 | lastSearchedItem = NULL; |
988 | } | 800 | } |
989 | lastSearchedComment = comment; | 801 | lastSearchedComment = comment; |
990 | 802 | ||
991 | ListView->clearSelection(); | 803 | ListView->clearSelection(); |
992 | 804 | ||
993 | bool found=FALSE; | 805 | bool found=FALSE; |
994 | // step through all categories | 806 | // step through all categories |
995 | QListViewItem *i; | 807 | QListViewItem *i; |
996 | if (lastSearchedCategory) | 808 | if (lastSearchedCategory) |
997 | i = lastSearchedCategory; | 809 | i = lastSearchedCategory; |
998 | else | 810 | else |
999 | i = ListView->firstChild(); | 811 | i = ListView->firstChild(); |
1000 | for (; | 812 | for (; |
1001 | i != NULL; | 813 | i != NULL; |
1002 | i = i->nextSibling()) | 814 | i = i->nextSibling()) |
1003 | { | 815 | { |
1004 | #ifndef NO_OPIE | ||
1005 | owarn << i->text(0) << oendl; | ||
1006 | #endif | ||
1007 | i->setSelected(FALSE); | 816 | i->setSelected(FALSE); |
1008 | 817 | ||
1009 | // step through all subitems | 818 | // step through all subitems |
1010 | QListViewItem *si; | 819 | QListViewItem *si; |
1011 | if (lastSearchedItem) | 820 | if (lastSearchedItem) |
1012 | si = lastSearchedItem; | 821 | si = lastSearchedItem; |
1013 | else | 822 | else |
1014 | si = i->firstChild(); | 823 | si = i->firstChild(); |
1015 | // for (si = i->firstChild(); | 824 | // for (si = i->firstChild(); |
1016 | for (; | 825 | for (; |
1017 | si != NULL; | 826 | si != NULL; |
1018 | si = si->nextSibling()) | 827 | si = si->nextSibling()) |
1019 | { | 828 | { |
1020 | #ifndef NO_OPIE | ||
1021 | owarn << si->text(0) << oendl; | ||
1022 | #else | ||
1023 | qWarning (si->text(0)); | ||
1024 | #endif | ||
1025 | if (si->isSelected()) | 829 | if (si->isSelected()) |
1026 | si->setSelected(FALSE); | 830 | si->setSelected(FALSE); |
1027 | // ListView->repaintItem(si); | 831 | // ListView->repaintItem(si); |
1028 | 832 | ||
1029 | bool n=TRUE; | 833 | bool n=TRUE; |
1030 | bool u=TRUE; | 834 | bool u=TRUE; |
1031 | bool c=TRUE; | 835 | bool c=TRUE; |
1032 | if (!name.isEmpty()) | 836 | if (!name.isEmpty()) |
1033 | n = (si->text(0)).contains (name, FALSE); | 837 | n = (si->text(0)).contains (name, FALSE); |
1034 | if (!username.isEmpty()) | 838 | if (!username.isEmpty()) |
1035 | u = (si->text(1)).contains (username, FALSE); | 839 | u = (si->text(1)).contains (username, FALSE); |
1036 | if (!comment.isEmpty()) | 840 | if (!comment.isEmpty()) |
1037 | c = (si->text(3)).contains (comment, FALSE); | 841 | c = (si->text(3)).contains (comment, FALSE); |
1038 | 842 | ||
1039 | if ((n && u && c ) && !found) | 843 | if ((n && u && c ) && !found) |
1040 | { | 844 | { |
1041 | #ifndef NO_OPIE | ||
1042 | owarn << "Found" << oendl; | ||
1043 | #else | ||
1044 | qWarning ("Found"); | ||
1045 | #endif | ||
1046 | selectedItem = si; | 845 | selectedItem = si; |
1047 | si->setSelected(TRUE); | 846 | si->setSelected(TRUE); |
1048 | ListView->setCurrentItem(si); | 847 | ListView->setCurrentItem(si); |
1049 | ListView->ensureItemVisible(si); | 848 | ListView->ensureItemVisible(si); |
1050 | ListView->triggerUpdate(); | 849 | ListView->triggerUpdate(); |
1051 | 850 | ||
1052 | lastSearchedCategory = i; | 851 | lastSearchedCategory = i; |
1053 | // set to the next item | 852 | // set to the next item |
1054 | lastSearchedItem = si->nextSibling(); | 853 | lastSearchedItem = si->nextSibling(); |
1055 | if (!lastSearchedItem) | 854 | if (!lastSearchedItem) |
1056 | { | 855 | { |
1057 | // no next item within category -> set next category | 856 | // no next item within category -> set next category |
1058 | lastSearchedCategory = i->nextSibling(); | 857 | lastSearchedCategory = i->nextSibling(); |
1059 | if (!lastSearchedCategory) | 858 | if (!lastSearchedCategory) |
1060 | lastSearchedItem = NULL; // END | 859 | lastSearchedItem = NULL; // END |
1061 | } | 860 | } |
1062 | 861 | ||
1063 | found = TRUE; | 862 | found = TRUE; |
1064 | delete dialog; | 863 | delete dialog; |
1065 | update(); | 864 | update(); |
1066 | return; | 865 | return; |
1067 | } | 866 | } |
1068 | } | 867 | } |
1069 | lastSearchedCategory = i->nextSibling(); | 868 | lastSearchedCategory = i->nextSibling(); |
1070 | lastSearchedItem = NULL; | 869 | lastSearchedItem = NULL; |
1071 | } | 870 | } |
1072 | lastSearchedCategory = NULL; | 871 | lastSearchedCategory = NULL; |
1073 | lastSearchedItem = NULL; | 872 | lastSearchedItem = NULL; |
1074 | delete dialog; | 873 | delete dialog; |
1075 | update(); | 874 | update(); |
1076 | QMessageBox::information( this, tr("ZSafe"), | 875 | QMessageBox::information( this, tr("ZSafe"), |
1077 | tr("Entry not found"), tr("&OK"), 0); | 876 | tr("Entry not found"), tr("&OK"), 0); |
1078 | 877 | ||
1079 | } | 878 | } |
1080 | 879 | ||
1081 | QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) | 880 | QString ZSafe::getFieldLabel (QListViewItem *_item, QString field, QString def) |
1082 | { | 881 | { |
1083 | QString category; | 882 | QString category; |
1084 | if (_item) | 883 | if (_item) |
1085 | { | 884 | { |
1086 | if (isCategory(_item)) | 885 | if (isCategory(_item)) |
1087 | { | 886 | { |
1088 | category = _item->text(0); | 887 | category = _item->text(0); |
1089 | } | 888 | } |
1090 | else | 889 | else |
1091 | { | 890 | { |
1092 | QListViewItem *cat = _item->parent(); | 891 | QListViewItem *cat = _item->parent(); |
1093 | category = cat->text(0); | 892 | category = cat->text(0); |
1094 | } | 893 | } |
1095 | } | 894 | } |
1096 | else | 895 | else |
1097 | { | 896 | { |
1098 | return def; | 897 | return def; |
1099 | } | 898 | } |
1100 | 899 | ||
1101 | QString app_key = APP_KEY; | 900 | QString app_key = APP_KEY; |
1102 | #ifndef DESKTOP | ||
1103 | #ifndef Q_WS_WIN | ||
1104 | conf->setGroup ("fieldDefs"); | ||
1105 | #endif | ||
1106 | #else | ||
1107 | #ifndef Q_WS_WIN | ||
1108 | app_key += "/fieldDefs/"; | ||
1109 | #endif | ||
1110 | #endif | ||
1111 | // #ifndef Q_WS_WIN | ||
1112 | QString label = conf->readEntry(app_key+category+"-field"+field,def); | ||
1113 | // #else | ||
1114 | // QString label(def); | ||
1115 | // #endif | ||
1116 | 901 | ||
1117 | #ifndef DESKTOP | 902 | conf->setGroup( "fieldDefs" ); |
903 | QString label = conf->readEntry(app_key+category+"-field"+field,def); | ||
1118 | conf->setGroup ("zsafe"); | 904 | conf->setGroup ("zsafe"); |
1119 | #endif | ||
1120 | return label; | 905 | return label; |
1121 | } | 906 | } |
1122 | 907 | ||
1123 | QString ZSafe::getFieldLabel (QString category, QString field, QString def) | 908 | QString ZSafe::getFieldLabel (QString category, QString field, QString def) |
1124 | { | 909 | { |
1125 | QString app_key = APP_KEY; | 910 | QString app_key = APP_KEY; |
1126 | #ifndef DESKTOP | ||
1127 | conf->setGroup ("fieldDefs"); | ||
1128 | #else | ||
1129 | #ifndef Q_WS_WIN | ||
1130 | app_key += "/fieldDefs/"; | ||
1131 | #endif | ||
1132 | #endif | ||
1133 | // #ifndef Q_WS_WIN | 911 | // #ifndef Q_WS_WIN |
912 | conf->setGroup( "fieldDefs" ); | ||
1134 | QString label = conf->readEntry(app_key+category+"-field"+field, | 913 | QString label = conf->readEntry(app_key+category+"-field"+field, |
1135 | def); | 914 | def); |
1136 | // #else | 915 | // #else |
1137 | // QString label(def); | 916 | // QString label(def); |
1138 | // #endif | 917 | // #endif |
1139 | #ifndef DESKTOP | ||
1140 | conf->setGroup ("zsafe"); | 918 | conf->setGroup ("zsafe"); |
1141 | #endif | ||
1142 | return label; | 919 | return label; |
1143 | } | 920 | } |
1144 | 921 | ||
1145 | void ZSafe::showInfo( QListViewItem *_item) | 922 | void ZSafe::showInfo( QListViewItem *_item) |
1146 | { | 923 | { |
1147 | if (!_item) | 924 | if (!_item) |
1148 | return; | 925 | return; |
1149 | if (selectedItem != NULL) | 926 | if (selectedItem != NULL) |
1150 | selectedItem->setSelected(FALSE); | 927 | selectedItem->setSelected(FALSE); |
1151 | 928 | ||
1152 | selectedItem = _item; | 929 | selectedItem = _item; |
1153 | selectedItem->setSelected(TRUE); | 930 | selectedItem->setSelected(TRUE); |
1154 | 931 | ||
1155 | if (!isCategory(_item)) | 932 | if (!isCategory(_item)) |
1156 | { | 933 | { |
1157 | /* | 934 | /* |
1158 | QString label=selectedItem->text(0); | 935 | QString label=selectedItem->text(0); |
1159 | label+="\n"; | 936 | label+="\n"; |
1160 | label+=selectedItem->text(1); | 937 | label+=selectedItem->text(1); |
1161 | label+="\n"; | 938 | label+="\n"; |
1162 | label+=selectedItem->text(2); | 939 | label+=selectedItem->text(2); |
1163 | label+="\n"; | 940 | label+="\n"; |
1164 | label+=selectedItem->text(3); | 941 | label+=selectedItem->text(3); |
1165 | */ | 942 | */ |
1166 | 943 | ||
1167 | QString text; | 944 | QString text; |
1168 | QString entry; | 945 | QString entry; |
1169 | 946 | ||
1170 | text = "<html><body><div align=""center""><u><b>"; | 947 | text = "<html><body><div align=""center""><u><b>"; |
1171 | text += selectedItem->text(0); | 948 | text += selectedItem->text(0); |
1172 | text += "</b></u><br></div><br>"; | 949 | text += "</b></u><br></div><br>"; |
1173 | 950 | ||
1174 | entry = selectedItem->text(1); | 951 | entry = selectedItem->text(1); |
1175 | if (!entry.isEmpty() && entry.compare(" ")) | 952 | if (!entry.isEmpty() && entry.compare(" ")) |
1176 | { | 953 | { |
1177 | text += "<u><b>"; | 954 | text += "<u><b>"; |
1178 | text += getFieldLabel (selectedItem, "2", tr("Username")); | 955 | text += getFieldLabel (selectedItem, "2", tr("Username")); |
1179 | text += ":<br></b></u><blockquote>"; | 956 | text += ":<br></b></u><blockquote>"; |
1180 | text += entry; | 957 | text += entry; |
1181 | text += "</blockquote>"; | 958 | text += "</blockquote>"; |
1182 | // text += "<br>"; | 959 | // text += "<br>"; |
1183 | } | 960 | } |
1184 | 961 | ||
1185 | entry = selectedItem->text(2); | 962 | entry = selectedItem->text(2); |
1186 | if (!entry.isEmpty() && entry.compare(" ")) | 963 | if (!entry.isEmpty() && entry.compare(" ")) |
1187 | { | 964 | { |
1188 | text += "<u><b>"; | 965 | text += "<u><b>"; |
1189 | text += getFieldLabel (selectedItem, "3", tr("Password")); | 966 | text += getFieldLabel (selectedItem, "3", tr("Password")); |
1190 | text += ":<br> </b></u><blockquote>"; | 967 | text += ":<br> </b></u><blockquote>"; |
1191 | text += entry; | 968 | text += entry; |
1192 | text += "</blockquote>"; | 969 | text += "</blockquote>"; |
1193 | // text += "<br>"; | 970 | // text += "<br>"; |
1194 | } | 971 | } |
1195 | 972 | ||
1196 | entry = selectedItem->text(4); | 973 | entry = selectedItem->text(4); |
1197 | if (!entry.isEmpty() && entry.compare(" ")) | 974 | if (!entry.isEmpty() && entry.compare(" ")) |
1198 | { | 975 | { |
1199 | text += "<u><b>"; | 976 | text += "<u><b>"; |
1200 | text += getFieldLabel (selectedItem, "5", tr("Field 4")); | 977 | text += getFieldLabel (selectedItem, "5", tr("Field 4")); |
1201 | text += ":<br> </b></u><blockquote>"; | 978 | text += ":<br> </b></u><blockquote>"; |
1202 | text += entry; | 979 | text += entry; |
1203 | text += "</blockquote>"; | 980 | text += "</blockquote>"; |
1204 | // text += "<br>"; | 981 | // text += "<br>"; |
1205 | } | 982 | } |
1206 | 983 | ||
1207 | entry = selectedItem->text(5); | 984 | entry = selectedItem->text(5); |
1208 | if (!entry.isEmpty() && entry.compare(" ")) | 985 | if (!entry.isEmpty() && entry.compare(" ")) |
1209 | { | 986 | { |
1210 | text += "<u><b>"; | 987 | text += "<u><b>"; |
1211 | text += getFieldLabel (selectedItem, "6", tr("Field 5")); | 988 | text += getFieldLabel (selectedItem, "6", tr("Field 5")); |
1212 | text += ":<br> </b></u><blockquote>"; | 989 | text += ":<br> </b></u><blockquote>"; |
1213 | text += entry; | 990 | text += entry; |
1214 | text += "</blockquote>"; | 991 | text += "</blockquote>"; |
1215 | // text += "<br>"; | 992 | // text += "<br>"; |
1216 | } | 993 | } |
1217 | 994 | ||
1218 | entry = selectedItem->text(3); | 995 | entry = selectedItem->text(3); |
1219 | if (!entry.isEmpty() && entry.compare(" ")) | 996 | if (!entry.isEmpty() && entry.compare(" ")) |
1220 | { | 997 | { |
1221 | text += "<u><b>"; | 998 | text += "<u><b>"; |
1222 | text += getFieldLabel (selectedItem, "4", tr("Comment")); | 999 | text += getFieldLabel (selectedItem, "4", tr("Comment")); |
1223 | text += ":<br> </b></u>"; | 1000 | text += ":<br> </b></u>"; |
1224 | QString comment = selectedItem->text(3); | 1001 | QString comment = selectedItem->text(3); |
1225 | comment.replace (QRegExp("\n"), "<br>"); | 1002 | comment.replace (QRegExp("\n"), "<br>"); |
1226 | text += comment; | 1003 | text += comment; |
1227 | // text += "<br>"; | 1004 | // text += "<br>"; |
1228 | } | 1005 | } |
1229 | 1006 | ||
1230 | text += "</body></html>"; | 1007 | text += "</body></html>"; |
1231 | 1008 | ||
1232 | infoForm->InfoText->setText(text); | 1009 | infoForm->InfoText->setText(text); |
1233 | // infoForm->hide(); | 1010 | // infoForm->hide(); |
1234 | #ifdef Q_WS_QWS | 1011 | #ifdef Q_WS_QWS |
1235 | QPEApplication::showDialog( infoForm ); | 1012 | QPEApplication::showDialog( infoForm ); |
1236 | #endif | 1013 | #endif |
1237 | 1014 | ||
1238 | #ifdef DESKTOP | ||
1239 | infoForm->show(); | ||
1240 | #endif | ||
1241 | } | 1015 | } |
1242 | } | 1016 | } |
1243 | 1017 | ||
1244 | void ZSafe::listViewSelected( QListViewItem *_item) | 1018 | void ZSafe::listViewSelected( QListViewItem *_item) |
1245 | { | 1019 | { |
1246 | if (!_item) | 1020 | if (!_item) |
1247 | return; | 1021 | return; |
1248 | if (selectedItem != NULL) | 1022 | if (selectedItem != NULL) |
1249 | selectedItem->setSelected(FALSE); | 1023 | selectedItem->setSelected(FALSE); |
1250 | 1024 | ||
1251 | selectedItem = _item; | 1025 | selectedItem = _item; |
1252 | 1026 | ||
1253 | #ifndef DESKTOP | ||
1254 | // set the column text dependent on the selected item | ||
1255 | ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); | ||
1256 | ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); | ||
1257 | ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); | ||
1258 | ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); | ||
1259 | ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); | ||
1260 | ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); | ||
1261 | #endif | ||
1262 | #ifdef Q_WS_WIN | ||
1263 | // set the column text dependent on the selected item | 1027 | // set the column text dependent on the selected item |
1264 | ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); | 1028 | ListView->setColumnText(0, getFieldLabel (selectedItem, "1", tr("Name"))); |
1265 | ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); | 1029 | ListView->setColumnText(1, getFieldLabel (selectedItem, "2", tr("Field 2"))); |
1266 | ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); | 1030 | ListView->setColumnText(2, getFieldLabel (selectedItem, "3", tr("Field 3"))); |
1267 | ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); | 1031 | ListView->setColumnText(3, getFieldLabel (selectedItem, "4", tr("Comment"))); |
1268 | ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); | 1032 | ListView->setColumnText(4, getFieldLabel (selectedItem, "5", tr("Field 4"))); |
1269 | ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); | 1033 | ListView->setColumnText(5, getFieldLabel (selectedItem, "6", tr("Field 5"))); |
1270 | #endif | ||
1271 | |||
1272 | } | 1034 | } |
1273 | 1035 | ||
1274 | bool ZSafe::isCategory(QListViewItem *_item) | 1036 | bool ZSafe::isCategory(QListViewItem *_item) |
1275 | { | 1037 | { |
1276 | if (_item == NULL) | 1038 | if (_item == NULL) |
1277 | return FALSE; | 1039 | return FALSE; |
1278 | 1040 | ||
1279 | QString categoryName = _item->text (0); | 1041 | QString categoryName = _item->text (0); |
1280 | if (categories.find (categoryName)) | 1042 | if (categories.find (categoryName)) |
1281 | return TRUE; | 1043 | return TRUE; |
1282 | else | 1044 | else |
1283 | return FALSE; | 1045 | return FALSE; |
1284 | } | 1046 | } |
1285 | 1047 | ||
1286 | void ZSafe::removeAsciiFile() | 1048 | void ZSafe::removeAsciiFile() |
1287 | { | 1049 | { |
1288 | // QString fn = filename + ".txt"; | 1050 | // QString fn = filename + ".txt"; |
1289 | // open the file dialog | 1051 | // open the file dialog |
1290 | #ifndef DESKTOP | ||
1291 | #ifndef NO_OPIE | ||
1292 | QMap<QString, QStringList> mimeTypes; | 1052 | QMap<QString, QStringList> mimeTypes; |
1293 | mimeTypes.insert(tr("All"), QStringList() ); | 1053 | mimeTypes.insert(tr("All"), QStringList() ); |
1294 | mimeTypes.insert(tr("Text"), "text/*" ); | 1054 | mimeTypes.insert(tr("Text"), "text/*" ); |
1295 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 1055 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
1296 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1056 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1297 | QString::null, | 1057 | QString::null, |
1298 | mimeTypes, | 1058 | mimeTypes, |
1299 | this, | 1059 | this, |
1300 | tr ("Remove text file")); | 1060 | tr ("Remove text file")); |
1301 | #else | ||
1302 | QString fn = ScQtFileEdit::getOpenFileName(this, | ||
1303 | tr ("Remove text file"), | ||
1304 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
1305 | "*.txt"); | ||
1306 | #endif | ||
1307 | #else | ||
1308 | QString fn = QFileDialog::getOpenFileName( | ||
1309 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
1310 | "ZSafe (*.txt)", | ||
1311 | this, | ||
1312 | "ZSafe File Dialog" | ||
1313 | "Choose a text file" ); | ||
1314 | #endif | ||
1315 | 1061 | ||
1316 | if (fn && fn.length() > 0 ) | 1062 | if (fn && fn.length() > 0 ) |
1317 | { | 1063 | { |
1318 | QFile f( fn ); | 1064 | QFile f( fn ); |
1319 | if ( !f.remove() ) | 1065 | if ( !f.remove() ) |
1320 | { | 1066 | { |
1321 | #ifndef NO_OPIE | ||
1322 | owarn << "Could not remove file " << fn << oendl; | ||
1323 | #else | ||
1324 | qWarning( QString("Could not remove file %1").arg(fn),2000 ); | ||
1325 | #endif | ||
1326 | QMessageBox::critical( 0, tr("ZSafe"), | 1067 | QMessageBox::critical( 0, tr("ZSafe"), |
1327 | tr("Could not remove text file.") ); | 1068 | tr("Could not remove text file.") ); |
1328 | return; | 1069 | return; |
1329 | } | 1070 | } |
1330 | } | 1071 | } |
1331 | } | 1072 | } |
1332 | 1073 | ||
1333 | void ZSafe::writeAllEntries() | 1074 | void ZSafe::writeAllEntries() |
1334 | { | 1075 | { |
1335 | if (filename.isEmpty()) | 1076 | if (filename.isEmpty()) |
1336 | { | 1077 | { |
1337 | QMessageBox::critical( 0, tr("ZSafe"), | 1078 | QMessageBox::critical( 0, tr("ZSafe"), |
1338 | tr("No document defined.\nYou have to create a new document")); | 1079 | tr("No document defined.\nYou have to create a new document")); |
1339 | return; | 1080 | return; |
1340 | } | 1081 | } |
1341 | 1082 | ||
1342 | // open the file dialog | 1083 | // open the file dialog |
1343 | QString fn = zsaveDialog(); | 1084 | QString fn = zsaveDialog(); |
1344 | // open the new document | 1085 | // open the new document |
1345 | if (fn && fn.length() > 0 ) | 1086 | if (fn && fn.length() > 0 ) |
1346 | { | 1087 | { |
1347 | QFile f( fn ); | 1088 | QFile f( fn ); |
1348 | if ( !f.open( IO_WriteOnly ) ) { | 1089 | if ( !f.open( IO_WriteOnly ) ) { |
1349 | #ifndef NO_OPIE | ||
1350 | owarn << "Could not write to file " << fn << oendl; | ||
1351 | #else | ||
1352 | qWarning( QString("Could not write to file %1").arg(fn),2000 ); | ||
1353 | #endif | ||
1354 | QMessageBox::critical( 0, "ZSafe", | 1090 | QMessageBox::critical( 0, "ZSafe", |
1355 | QString("Could not export to text file.") ); | 1091 | QString("Could not export to text file.") ); |
1356 | return; | 1092 | return; |
1357 | } | 1093 | } |
1358 | QTextStream t( &f ); | 1094 | QTextStream t( &f ); |
1359 | 1095 | ||
1360 | QListViewItem *i; | 1096 | QListViewItem *i; |
1361 | // step through all categories | 1097 | // step through all categories |
1362 | for (i = ListView->firstChild(); | 1098 | for (i = ListView->firstChild(); |
1363 | i != NULL; | 1099 | i != NULL; |
1364 | i = i->nextSibling()) | 1100 | i = i->nextSibling()) |
1365 | { | 1101 | { |
1366 | // step through all subitems | 1102 | // step through all subitems |
1367 | QListViewItem *si; | 1103 | QListViewItem *si; |
1368 | for (si = i->firstChild(); | 1104 | for (si = i->firstChild(); |
1369 | si != NULL; | 1105 | si != NULL; |
1370 | si = si->nextSibling()) | 1106 | si = si->nextSibling()) |
1371 | { | 1107 | { |
1372 | QString oneEntry; | 1108 | QString oneEntry; |
1373 | oneEntry += "\""; | 1109 | oneEntry += "\""; |
1374 | oneEntry += i->text(0); | 1110 | oneEntry += i->text(0); |
1375 | oneEntry += "\";"; | 1111 | oneEntry += "\";"; |
1376 | oneEntry += "\""; | 1112 | oneEntry += "\""; |
1377 | oneEntry += si->text(0); | 1113 | oneEntry += si->text(0); |
1378 | oneEntry += "\";"; | 1114 | oneEntry += "\";"; |
1379 | oneEntry += "\""; | 1115 | oneEntry += "\""; |
1380 | oneEntry += si->text(1); | 1116 | oneEntry += si->text(1); |
1381 | oneEntry += "\";"; | 1117 | oneEntry += "\";"; |
1382 | oneEntry += "\""; | 1118 | oneEntry += "\""; |
1383 | oneEntry += si->text(2); | 1119 | oneEntry += si->text(2); |
1384 | oneEntry += "\";"; | 1120 | oneEntry += "\";"; |
1385 | oneEntry += "\""; | 1121 | oneEntry += "\""; |
1386 | QString comment = si->text(3); | 1122 | QString comment = si->text(3); |
1387 | comment.replace (QRegExp("\n"), "<br>"); | 1123 | comment.replace (QRegExp("\n"), "<br>"); |
1388 | oneEntry += comment; | 1124 | oneEntry += comment; |
1389 | oneEntry += "\";"; | 1125 | oneEntry += "\";"; |
1390 | oneEntry += "\""; | 1126 | oneEntry += "\""; |
1391 | oneEntry += si->text(4); | 1127 | oneEntry += si->text(4); |
1392 | oneEntry += "\";"; | 1128 | oneEntry += "\";"; |
1393 | oneEntry += "\""; | 1129 | oneEntry += "\""; |
1394 | oneEntry += si->text(5); | 1130 | oneEntry += si->text(5); |
1395 | oneEntry += "\""; | 1131 | oneEntry += "\""; |
1396 | // owarn << oneEntry << oendl; | 1132 | // owarn << oneEntry << oendl; |
1397 | t << oneEntry << endl; | 1133 | t << oneEntry << endl; |
1398 | 1134 | ||
1399 | // owarn << si->text(0) << oendl; | 1135 | // owarn << si->text(0) << oendl; |
1400 | } | 1136 | } |
1401 | } | 1137 | } |
1402 | f.close(); | 1138 | f.close(); |
1403 | } | 1139 | } |
1404 | } | 1140 | } |
1405 | 1141 | ||
1406 | void ZSafe::readAllEntries() | 1142 | void ZSafe::readAllEntries() |
1407 | { | 1143 | { |
1408 | if (filename.isEmpty()) | 1144 | if (filename.isEmpty()) |
1409 | { | 1145 | { |
1410 | QMessageBox::critical( 0, tr("ZSafe"), | 1146 | QMessageBox::critical( 0, tr("ZSafe"), |
1411 | tr("No document defined.\nYou have to create a new document")); | 1147 | tr("No document defined.\nYou have to create a new document")); |
1412 | return; | 1148 | return; |
1413 | } | 1149 | } |
1414 | 1150 | ||
1415 | // open the file dialog | 1151 | // open the file dialog |
1416 | #ifndef DESKTOP | ||
1417 | #ifndef NO_OPIE | ||
1418 | QMap<QString, QStringList> mimeTypes; | 1152 | QMap<QString, QStringList> mimeTypes; |
1419 | mimeTypes.insert(tr("All"), QStringList() ); | 1153 | mimeTypes.insert(tr("All"), QStringList() ); |
1420 | mimeTypes.insert(tr("Text"), "text/*" ); | 1154 | mimeTypes.insert(tr("Text"), "text/*" ); |
1421 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 1155 | QString fn = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
1422 | QDir::homeDirPath() + "/Documents/application/zsafe", | 1156 | QDir::homeDirPath() + "/Documents/application/zsafe", |
1423 | QString::null, | 1157 | QString::null, |
1424 | mimeTypes, | 1158 | mimeTypes, |
1425 | this, | 1159 | this, |
1426 | tr ("Import text file")); | 1160 | tr ("Import text file")); |
1427 | #else | ||
1428 | QString fn = ScQtFileEdit::getOpenFileName(this, | ||
1429 | tr ("Import text file"), | ||
1430 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
1431 | "*.txt"); | ||
1432 | #endif | ||
1433 | #else | ||
1434 | QString fn = QFileDialog::getOpenFileName( | ||
1435 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
1436 | "ZSafe (*.txt)", | ||
1437 | this, | ||
1438 | "ZSafe File Dialog" | ||
1439 | "Choose a text file" ); | ||
1440 | #endif | ||
1441 | 1161 | ||
1442 | if (fn && fn.length() > 0 ) | 1162 | if (fn && fn.length() > 0 ) |
1443 | { | 1163 | { |
1444 | QFile f( fn ); | 1164 | QFile f( fn ); |
1445 | if ( !f.open( IO_ReadOnly ) ) | 1165 | if ( !f.open( IO_ReadOnly ) ) |
1446 | { | 1166 | { |
1447 | #ifndef NO_OPIE | ||
1448 | owarn << "Could not read file " << fn << oendl; | ||
1449 | #else | ||
1450 | qWarning( QString("Could not read file %1").arg(fn), 2000 ); | ||
1451 | #endif | ||
1452 | QMessageBox::critical( 0, "ZSafe", | 1167 | QMessageBox::critical( 0, "ZSafe", |
1453 | QString("Could not import text file.") ); | 1168 | QString("Could not import text file.") ); |
1454 | return; | 1169 | return; |
1455 | } | 1170 | } |
1456 | 1171 | ||
1457 | modified = true; | 1172 | modified = true; |
1458 | 1173 | ||
1459 | // clear the password list | 1174 | // clear the password list |
1460 | selectedItem = NULL; | 1175 | selectedItem = NULL; |
1461 | QListViewItem *i; | 1176 | QListViewItem *i; |
1462 | // step through all categories | 1177 | // step through all categories |
1463 | for (i = ListView->firstChild(); | 1178 | for (i = ListView->firstChild(); |
1464 | i != NULL; | 1179 | i != NULL; |
1465 | i = i->nextSibling()) | 1180 | i = i->nextSibling()) |
1466 | { | 1181 | { |
1467 | // step through all subitems | 1182 | // step through all subitems |
1468 | QListViewItem *si; | 1183 | QListViewItem *si; |
1469 | for (si = i->firstChild(); | 1184 | for (si = i->firstChild(); |
1470 | si != NULL; ) | 1185 | si != NULL; ) |
1471 | // si = si->nextSibling()) | 1186 | // si = si->nextSibling()) |
1472 | { | 1187 | { |
1473 | QListViewItem *_si = si; | 1188 | QListViewItem *_si = si; |
1474 | si = si->nextSibling(); | 1189 | si = si->nextSibling(); |
1475 | i->takeItem(_si); // remove from view list | 1190 | i->takeItem(_si); // remove from view list |
1476 | if (_si) delete _si; | 1191 | if (_si) delete _si; |
1477 | } | 1192 | } |
1478 | } | 1193 | } |
1479 | 1194 | ||
1480 | #ifndef NO_OPIE | ||
1481 | owarn << "ReadAllEntries(): " << oendl; | ||
1482 | #else | ||
1483 | qWarning ("ReadAllEntries(): "); | ||
1484 | #endif | ||
1485 | |||
1486 | QTextStream t(&f); | 1195 | QTextStream t(&f); |
1487 | while ( !t.eof() ) | 1196 | while ( !t.eof() ) |
1488 | { | 1197 | { |
1489 | QString s = t.readLine(); | 1198 | QString s = t.readLine(); |
1490 | s.replace (QRegExp("\";\""), "\"|\""); | 1199 | s.replace (QRegExp("\";\""), "\"|\""); |
1491 | // char buffer[1024]; | 1200 | // char buffer[1024]; |
1492 | #ifndef Q_WS_WIN | ||
1493 | char buffer[s.length()+1]; | 1201 | char buffer[s.length()+1]; |
1494 | #else | ||
1495 | char buffer[4048]; | ||
1496 | #endif | ||
1497 | 1202 | ||
1498 | 1203 | ||
1499 | /* modify QString -> QCString::utf8 */ | 1204 | /* modify QString -> QCString::utf8 */ |
1500 | 1205 | ||
1501 | strcpy (buffer, s.utf8()); | 1206 | strcpy (buffer, s.utf8()); |
1502 | 1207 | ||
1503 | QString name; | 1208 | QString name; |
1504 | QString user; | 1209 | QString user; |
1505 | QString password; | 1210 | QString password; |
1506 | QString comment; | 1211 | QString comment; |
1507 | QString field5=""; | 1212 | QString field5=""; |
1508 | QString field6=""; | 1213 | QString field6=""; |
1509 | 1214 | ||
1510 | // separete the entries | 1215 | // separete the entries |
1511 | char *i = strtok (buffer, "|"); | 1216 | char *i = strtok (buffer, "|"); |
1512 | QString category(QString::fromUtf8(&i[1])); | 1217 | QString category(QString::fromUtf8(&i[1])); |
1513 | category.truncate(category.length() -1); | 1218 | category.truncate(category.length() -1); |
1514 | 1219 | ||
1515 | int idx=0; | 1220 | int idx=0; |
1516 | while ((i = strtok (NULL, "|")) != NULL) | 1221 | while ((i = strtok (NULL, "|")) != NULL) |
1517 | { | 1222 | { |
1518 | switch (idx) | 1223 | switch (idx) |
1519 | { | 1224 | { |
1520 | case 0: | 1225 | case 0: |
1521 | name = QString::fromUtf8(&i[1]); | 1226 | name = QString::fromUtf8(&i[1]); |
1522 | name.truncate(name.length() -1); | 1227 | name.truncate(name.length() -1); |
1523 | // name | 1228 | // name |
1524 | break; | 1229 | break; |
1525 | case 1: | 1230 | case 1: |
1526 | // user | 1231 | // user |
1527 | user = QString::fromUtf8(&i[1]); | 1232 | user = QString::fromUtf8(&i[1]); |
1528 | user.truncate(user.length() -1); | 1233 | user.truncate(user.length() -1); |
1529 | break; | 1234 | break; |
1530 | case 2: | 1235 | case 2: |
1531 | // password | 1236 | // password |
1532 | password = QString::fromUtf8(&i[1]); | 1237 | password = QString::fromUtf8(&i[1]); |
1533 | password.truncate(password.length() -1); | 1238 | password.truncate(password.length() -1); |
1534 | break; | 1239 | break; |
1535 | case 3: | 1240 | case 3: |
1536 | // comment | 1241 | // comment |
1537 | comment = QString::fromUtf8(&i[1]); | 1242 | comment = QString::fromUtf8(&i[1]); |
1538 | comment.truncate(comment.length() -1); | 1243 | comment.truncate(comment.length() -1); |
1539 | break; | 1244 | break; |
1540 | case 4: | 1245 | case 4: |
1541 | // field5 | 1246 | // field5 |
1542 | field5 = QString::fromUtf8(&i[1]); | 1247 | field5 = QString::fromUtf8(&i[1]); |
1543 | field5.truncate(field5.length() -1); | 1248 | field5.truncate(field5.length() -1); |
1544 | break; | 1249 | break; |
1545 | case 5: | 1250 | case 5: |
1546 | // field6 | 1251 | // field6 |
1547 | field6 = QString::fromUtf8(&i[1]); | 1252 | field6 = QString::fromUtf8(&i[1]); |
1548 | field6.truncate(field6.length() -1); | 1253 | field6.truncate(field6.length() -1); |
1549 | break; | 1254 | break; |
1550 | } | 1255 | } |
1551 | idx++; | 1256 | idx++; |
1552 | } | 1257 | } |
1553 | 1258 | ||
1554 | Category *cat= categories.find (category); | 1259 | Category *cat= categories.find (category); |
1555 | if (cat) | 1260 | if (cat) |
1556 | { | 1261 | { |
1557 | // use the existend item | 1262 | // use the existend item |
1558 | QListViewItem *catItem = cat->getListItem(); | 1263 | QListViewItem *catItem = cat->getListItem(); |
1559 | if (catItem) | 1264 | if (catItem) |
1560 | { | 1265 | { |
1561 | QListViewItem * item = new ShadedListItem( 0, catItem ); | 1266 | QListViewItem * item = new ShadedListItem( 0, catItem ); |
1562 | item->setText( 0, tr( name ) ); | 1267 | item->setText( 0, tr( name ) ); |
1563 | item->setText( 1, tr( user ) ); | 1268 | item->setText( 1, tr( user ) ); |
1564 | item->setText( 2, tr( password ) ); | 1269 | item->setText( 2, tr( password ) ); |
1565 | item->setText( 3, tr( comment ) ); | 1270 | item->setText( 3, tr( comment ) ); |
1566 | item->setText( 4, tr( field5 ) ); | 1271 | item->setText( 4, tr( field5 ) ); |
1567 | item->setText( 5, tr( field6 ) ); | 1272 | item->setText( 5, tr( field6 ) ); |
1568 | catItem->setOpen( TRUE ); | 1273 | catItem->setOpen( TRUE ); |
1569 | } | 1274 | } |
1570 | } | 1275 | } |
1571 | else | 1276 | else |
1572 | { | 1277 | { |
1573 | QListViewItem *catI = new ShadedListItem( 1, ListView ); | 1278 | QListViewItem *catI = new ShadedListItem( 1, ListView ); |
1574 | // create and insert a new item | 1279 | // create and insert a new item |
1575 | QListViewItem * item = new ShadedListItem( 0, catI ); | 1280 | QListViewItem * item = new ShadedListItem( 0, catI ); |
1576 | item->setText( 0, tr( name ) ); | 1281 | item->setText( 0, tr( name ) ); |
1577 | item->setText( 1, tr( user ) ); | 1282 | item->setText( 1, tr( user ) ); |
1578 | item->setText( 2, tr( password ) ); | 1283 | item->setText( 2, tr( password ) ); |
1579 | item->setText( 3, tr( comment ) ); | 1284 | item->setText( 3, tr( comment ) ); |
1580 | item->setText( 4, tr( field5 ) ); | 1285 | item->setText( 4, tr( field5 ) ); |
1581 | item->setText( 5, tr( field6 ) ); | 1286 | item->setText( 5, tr( field6 ) ); |
1582 | 1287 | ||
1583 | catI->setOpen( TRUE ); | 1288 | catI->setOpen( TRUE ); |
1584 | 1289 | ||
1585 | Category *c1 = new Category(); | 1290 | Category *c1 = new Category(); |
1586 | c1->setCategoryName(category); | 1291 | c1->setCategoryName(category); |
1587 | 1292 | ||
1588 | QString icon; | 1293 | QString icon; |
1589 | QString fullIconPath; | 1294 | QString fullIconPath; |
1590 | QPixmap *pix; | 1295 | QPixmap *pix; |
1591 | // #ifndef Q_WS_WIN | 1296 | // #ifndef Q_WS_WIN |
1592 | icon = conf->readEntry(APP_KEY+category); | 1297 | icon = conf->readEntry(APP_KEY+category); |
1593 | // #endif | 1298 | // #endif |
1594 | bool isIconAv = false; | 1299 | bool isIconAv = false; |
1595 | if (!icon.isEmpty() && !icon.isNull()) | 1300 | if (!icon.isEmpty() && !icon.isNull()) |
1596 | { | 1301 | { |
1597 | // build the full path | 1302 | // build the full path |
1598 | fullIconPath = iconPath + icon; | 1303 | fullIconPath = iconPath + icon; |
1599 | pix = new QPixmap (fullIconPath); | 1304 | pix = new QPixmap (fullIconPath); |
1600 | if (!pix->isNull()) | 1305 | if (!pix->isNull()) |
1601 | { | 1306 | { |
1602 | QImage img = pix->convertToImage(); | 1307 | QImage img = pix->convertToImage(); |
1603 | pix->convertFromImage(img.smoothScale(14,14)); | 1308 | pix->convertFromImage(img.smoothScale(14,14)); |
1604 | c1->setIconName (icon); | 1309 | c1->setIconName (icon); |
1605 | c1->setIcon (*pix); | 1310 | c1->setIcon (*pix); |
1606 | isIconAv = true; | 1311 | isIconAv = true; |
1607 | } | 1312 | } |
1608 | } | 1313 | } |
1609 | if (!isIconAv) | 1314 | if (!isIconAv) |
1610 | { | 1315 | { |
1611 | c1->setIcon (*getPredefinedIcon(category)); | 1316 | c1->setIcon (*getPredefinedIcon(category)); |
1612 | } | 1317 | } |
1613 | c1->setListItem (catI); | 1318 | c1->setListItem (catI); |
1614 | c1->initListItem(); | 1319 | c1->initListItem(); |
1615 | categories.insert (c1->getCategoryName(), c1); | 1320 | categories.insert (c1->getCategoryName(), c1); |
1616 | } | 1321 | } |
1617 | 1322 | ||
1618 | } | 1323 | } |
1619 | f.close(); | 1324 | f.close(); |
1620 | 1325 | ||
1621 | } | 1326 | } |
1622 | else | 1327 | else |
1623 | { | 1328 | { |
1624 | } | 1329 | } |
1625 | 1330 | ||
1626 | } | 1331 | } |
1627 | 1332 | ||
1628 | #ifdef UNUSED | 1333 | #ifdef UNUSED |
1629 | void ZSafe::writeAllEntries() | 1334 | void ZSafe::writeAllEntries() |
1630 | { | 1335 | { |
1631 | if (filename.isEmpty()) | 1336 | if (filename.isEmpty()) |
1632 | { | 1337 | { |
1633 | QMessageBox::critical( 0, tr("ZSafe"), | 1338 | QMessageBox::critical( 0, tr("ZSafe"), |
1634 | tr("<P>No document defined. You have to create a new document</P>")); | 1339 | tr("<P>No document defined. You have to create a new document</P>")); |
1635 | return; | 1340 | return; |
1636 | } | 1341 | } |
1637 | 1342 | ||
1638 | // open the file for writing | 1343 | // open the file for writing |
1639 | QString fn = filename + ".txt"; | 1344 | QString fn = filename + ".txt"; |
1640 | QFile f( fn ); | 1345 | QFile f( fn ); |
1641 | if ( !f.open( IO_WriteOnly ) ) { | 1346 | if ( !f.open( IO_WriteOnly ) ) { |
1642 | #ifndef NO_OPIE | ||
1643 | owarn << "Could not write to file " << fn << oendl; | ||
1644 | #else | ||
1645 | qWarning( QString("Could not write to file %1").arg(fn), 2000 ); | ||
1646 | #endif | ||
1647 | QMessageBox::critical( 0, tr("ZSafe"), | 1347 | QMessageBox::critical( 0, tr("ZSafe"), |
1648 | tr("Could not export to text file.") ); | 1348 | tr("Could not export to text file.") ); |
1649 | return; | 1349 | return; |
1650 | } | 1350 | } |
1651 | QTextStream t( &f ); | 1351 | QTextStream t( &f ); |
1652 | 1352 | ||
1653 | QListViewItem *i; | 1353 | QListViewItem *i; |
1654 | // step through all categories | 1354 | // step through all categories |
1655 | for (i = ListView->firstChild(); | 1355 | for (i = ListView->firstChild(); |
1656 | i != NULL; | 1356 | i != NULL; |
1657 | i = i->nextSibling()) | 1357 | i = i->nextSibling()) |
1658 | { | 1358 | { |
1659 | // step through all subitems | 1359 | // step through all subitems |
1660 | QListViewItem *si; | 1360 | QListViewItem *si; |
1661 | for (si = i->firstChild(); | 1361 | for (si = i->firstChild(); |
1662 | si != NULL; | 1362 | si != NULL; |
1663 | si = si->nextSibling()) | 1363 | si = si->nextSibling()) |
1664 | { | 1364 | { |
1665 | QString oneEntry; | 1365 | QString oneEntry; |
1666 | oneEntry += "\""; | 1366 | oneEntry += "\""; |
1667 | oneEntry += i->text(0); | 1367 | oneEntry += i->text(0); |
1668 | oneEntry += "\";"; | 1368 | oneEntry += "\";"; |
1669 | oneEntry += "\""; | 1369 | oneEntry += "\""; |
1670 | oneEntry += si->text(0); | 1370 | oneEntry += si->text(0); |
1671 | oneEntry += "\";"; | 1371 | oneEntry += "\";"; |
1672 | oneEntry += "\""; | 1372 | oneEntry += "\""; |
1673 | oneEntry += si->text(1); | 1373 | oneEntry += si->text(1); |
1674 | oneEntry += "\";"; | 1374 | oneEntry += "\";"; |
1675 | oneEntry += "\""; | 1375 | oneEntry += "\""; |
1676 | oneEntry += si->text(2); | 1376 | oneEntry += si->text(2); |
1677 | oneEntry += "\";"; | 1377 | oneEntry += "\";"; |
1678 | oneEntry += "\""; | 1378 | oneEntry += "\""; |
1679 | // oneEntry += si->text(3); | 1379 | // oneEntry += si->text(3); |
1680 | QString comment = si->text(3); | 1380 | QString comment = si->text(3); |
1681 | comment.replace (QRegExp("\n"), "<br>"); | 1381 | comment.replace (QRegExp("\n"), "<br>"); |
1682 | oneEntry += comment; | 1382 | oneEntry += comment; |
1683 | oneEntry += "\""; | 1383 | oneEntry += "\""; |
1684 | // owarn << oneEntry << oendl; | 1384 | // owarn << oneEntry << oendl; |
1685 | t << oneEntry << endl; | 1385 | t << oneEntry << endl; |
1686 | 1386 | ||
1687 | // owarn << si->text(0) << oendl; | 1387 | // owarn << si->text(0) << oendl; |
1688 | } | 1388 | } |
1689 | } | 1389 | } |
1690 | f.close(); | 1390 | f.close(); |
1691 | } | 1391 | } |
1692 | 1392 | ||
1693 | void ZSafe::readAllEntries() | 1393 | void ZSafe::readAllEntries() |
1694 | { | 1394 | { |
1695 | QString fn = filename + ".txt"; | 1395 | QString fn = filename + ".txt"; |
1696 | QFile f( fn ); | 1396 | QFile f( fn ); |
1697 | if ( !f.open( IO_ReadOnly ) ) | 1397 | if ( !f.open( IO_ReadOnly ) ) |
1698 | { | 1398 | { |
1699 | #ifndef NO_OPIE | ||
1700 | owarn << "Could not read file " << fn << oendl; | ||
1701 | #else | ||
1702 | qWarning( QString("Could not read file %1").arg(fn), 2000 ); | ||
1703 | #endif | ||
1704 | QMessageBox::critical( 0, tr("ZSafe"), | 1399 | QMessageBox::critical( 0, tr("ZSafe"), |
1705 | tr("Could not import text file.") ); | 1400 | tr("Could not import text file.") ); |
1706 | return; | 1401 | return; |
1707 | } | 1402 | } |
1708 | 1403 | ||
1709 | modified = true; | 1404 | modified = true; |
1710 | 1405 | ||
1711 | // clear the password list | 1406 | // clear the password list |
1712 | selectedItem = NULL; | 1407 | selectedItem = NULL; |
1713 | QListViewItem *i; | 1408 | QListViewItem *i; |
1714 | // step through all categories | 1409 | // step through all categories |
1715 | for (i = ListView->firstChild(); | 1410 | for (i = ListView->firstChild(); |
1716 | i != NULL; | 1411 | i != NULL; |
1717 | i = i->nextSibling()) | 1412 | i = i->nextSibling()) |
1718 | { | 1413 | { |
1719 | // step through all subitems | 1414 | // step through all subitems |
1720 | QListViewItem *si; | 1415 | QListViewItem *si; |
1721 | for (si = i->firstChild(); | 1416 | for (si = i->firstChild(); |
1722 | si != NULL; ) | 1417 | si != NULL; ) |
1723 | // si = si->nextSibling()) | 1418 | // si = si->nextSibling()) |
1724 | { | 1419 | { |
1725 | QListViewItem *_si = si; | 1420 | QListViewItem *_si = si; |
1726 | si = si->nextSibling(); | 1421 | si = si->nextSibling(); |
1727 | i->takeItem(_si); // remove from view list | 1422 | i->takeItem(_si); // remove from view list |
1728 | if (_si) delete _si; | 1423 | if (_si) delete _si; |
1729 | } | 1424 | } |
1730 | } | 1425 | } |
1731 | 1426 | ||
1732 | #ifndef NO_OPIE | ||
1733 | owarn << "ReadAllEntries(): " << oendl; | ||
1734 | #else | ||
1735 | qWarning ("ReadAllEntries(): "); | ||
1736 | #endif | ||
1737 | QTextStream t(&f); | 1427 | QTextStream t(&f); |
1738 | while ( !t.eof() ) | 1428 | while ( !t.eof() ) |
1739 | { | 1429 | { |
1740 | QString s = t.readLine(); | 1430 | QString s = t.readLine(); |
1741 | s.replace (QRegExp("\";\""), "\"|\""); | 1431 | s.replace (QRegExp("\";\""), "\"|\""); |
1742 | // char buffer[1024]; | 1432 | // char buffer[1024]; |
1743 | int len=s.length()+1; | 1433 | int len=s.length()+1; |
1744 | #ifdef Q_WS_WIN | ||
1745 | char buffer[512]; | ||
1746 | #else | ||
1747 | char buffer[len]; | 1434 | char buffer[len]; |
1748 | #endif | ||
1749 | strcpy (buffer, s); | 1435 | strcpy (buffer, s); |
1750 | 1436 | ||
1751 | QString name; | 1437 | QString name; |
1752 | QString user; | 1438 | QString user; |
1753 | QString password; | 1439 | QString password; |
1754 | QString comment; | 1440 | QString comment; |
1755 | 1441 | ||
1756 | // separete the entries | 1442 | // separete the entries |
1757 | char *i = strtok (buffer, "|"); | 1443 | char *i = strtok (buffer, "|"); |
1758 | QString category(&i[1]); | 1444 | QString category(&i[1]); |
1759 | category.truncate(category.length() -1); | 1445 | category.truncate(category.length() -1); |
1760 | 1446 | ||
1761 | int idx=0; | 1447 | int idx=0; |
1762 | while (i = strtok (NULL, "|")) | 1448 | while (i = strtok (NULL, "|")) |
1763 | { | 1449 | { |
1764 | switch (idx) | 1450 | switch (idx) |
1765 | { | 1451 | { |
1766 | case 0: | 1452 | case 0: |
1767 | name = &i[1]; | 1453 | name = &i[1]; |
1768 | name.truncate(name.length() -1); | 1454 | name.truncate(name.length() -1); |
1769 | // name | 1455 | // name |
1770 | break; | 1456 | break; |
1771 | case 1: | 1457 | case 1: |
1772 | // user | 1458 | // user |
1773 | user = &i[1]; | 1459 | user = &i[1]; |
1774 | user.truncate(user.length() -1); | 1460 | user.truncate(user.length() -1); |
1775 | break; | 1461 | break; |
1776 | case 2: | 1462 | case 2: |
1777 | // password | 1463 | // password |
1778 | password = &i[1]; | 1464 | password = &i[1]; |
1779 | password.truncate(password.length() -1); | 1465 | password.truncate(password.length() -1); |
1780 | break; | 1466 | break; |
1781 | case 3: | 1467 | case 3: |
1782 | // comment | 1468 | // comment |
1783 | comment = &i[1]; | 1469 | comment = &i[1]; |
1784 | comment.truncate(comment.length() -1); | 1470 | comment.truncate(comment.length() -1); |
1785 | break; | 1471 | break; |
1786 | } | 1472 | } |
1787 | idx++; | 1473 | idx++; |
1788 | } | 1474 | } |
1789 | 1475 | ||
1790 | Category *cat= categories.find (category); | 1476 | Category *cat= categories.find (category); |
1791 | if (cat) | 1477 | if (cat) |
1792 | { | 1478 | { |
1793 | // use the existend item | 1479 | // use the existend item |
1794 | QListViewItem *catItem = cat->getListItem(); | 1480 | QListViewItem *catItem = cat->getListItem(); |
1795 | if (catItem) | 1481 | if (catItem) |
1796 | { | 1482 | { |
1797 | QListViewItem * item = new ShadedListItem( 0, catItem ); | 1483 | QListViewItem * item = new ShadedListItem( 0, catItem ); |
1798 | item->setText( 0, tr( name ) ); | 1484 | item->setText( 0, tr( name ) ); |
1799 | item->setText( 1, tr( user ) ); | 1485 | item->setText( 1, tr( user ) ); |
1800 | item->setText( 2, tr( password ) ); | 1486 | item->setText( 2, tr( password ) ); |
1801 | item->setText( 3, tr( comment ) ); | 1487 | item->setText( 3, tr( comment ) ); |
1802 | 1488 | ||
1803 | catItem->setOpen( TRUE ); | 1489 | catItem->setOpen( TRUE ); |
1804 | } | 1490 | } |
1805 | } | 1491 | } |
1806 | else | 1492 | else |
1807 | { | 1493 | { |
1808 | QListViewItem *catI = new ShadedListItem( 1, ListView ); | 1494 | QListViewItem *catI = new ShadedListItem( 1, ListView ); |
1809 | // create and insert a new item | 1495 | // create and insert a new item |
1810 | QListViewItem * item = new ShadedListItem( 0, catI ); | 1496 | QListViewItem * item = new ShadedListItem( 0, catI ); |
1811 | item->setText( 0, tr( name ) ); | 1497 | item->setText( 0, tr( name ) ); |
1812 | item->setText( 1, tr( user ) ); | 1498 | item->setText( 1, tr( user ) ); |
1813 | item->setText( 2, tr( password ) ); | 1499 | item->setText( 2, tr( password ) ); |
1814 | item->setText( 3, tr( comment ) ); | 1500 | item->setText( 3, tr( comment ) ); |
1815 | 1501 | ||
1816 | catI->setOpen( TRUE ); | 1502 | catI->setOpen( TRUE ); |
1817 | 1503 | ||
1818 | Category *c1 = new Category(); | 1504 | Category *c1 = new Category(); |
1819 | c1->setCategoryName(category); | 1505 | c1->setCategoryName(category); |
1820 | 1506 | ||
1821 | QString icon; | 1507 | QString icon; |
1822 | QString fullIconPath; | 1508 | QString fullIconPath; |
1823 | QPixmap *pix; | 1509 | QPixmap *pix; |
1824 | // #ifndef Q_WS_WIN | 1510 | // #ifndef Q_WS_WIN |
1825 | icon = conf->readEntry(APP_KEY+category); | 1511 | icon = conf->readEntry(APP_KEY+category); |
1826 | // #endif | 1512 | // #endif |
1827 | bool isIconAv = false; | 1513 | bool isIconAv = false; |
1828 | if (!icon.isEmpty() && !icon.isNull()) | 1514 | if (!icon.isEmpty() && !icon.isNull()) |
1829 | { | 1515 | { |
1830 | // build the full path | 1516 | // build the full path |
1831 | fullIconPath = iconPath + icon; | 1517 | fullIconPath = iconPath + icon; |
1832 | pix = new QPixmap (fullIconPath); | 1518 | pix = new QPixmap (fullIconPath); |
1833 | if (!pix->isNull()) | 1519 | if (!pix->isNull()) |
1834 | { | 1520 | { |
1835 | QImage img = pix->convertToImage(); | 1521 | QImage img = pix->convertToImage(); |
1836 | pix->convertFromImage(img.smoothScale(14,14)); | 1522 | pix->convertFromImage(img.smoothScale(14,14)); |
1837 | c1->setIconName (icon); | 1523 | c1->setIconName (icon); |
1838 | c1->setIcon (*pix); | 1524 | c1->setIcon (*pix); |
1839 | isIconAv = true; | 1525 | isIconAv = true; |
1840 | } | 1526 | } |
1841 | } | 1527 | } |
1842 | if (!isIconAv) | 1528 | if (!isIconAv) |
1843 | { | 1529 | { |
1844 | c1->setIcon (*getPredefinedIcon(category)); | 1530 | c1->setIcon (*getPredefinedIcon(category)); |
1845 | } | 1531 | } |
1846 | c1->setListItem (catI); | 1532 | c1->setListItem (catI); |
1847 | c1->initListItem(); | 1533 | c1->initListItem(); |
1848 | categories.insert (c1->getCategoryName(), c1); | 1534 | categories.insert (c1->getCategoryName(), c1); |
1849 | } | 1535 | } |
1850 | 1536 | ||
1851 | } | 1537 | } |
1852 | f.close(); | 1538 | f.close(); |
1853 | 1539 | ||
1854 | } | 1540 | } |
1855 | #endif // UNUSED | 1541 | #endif // UNUSED |
1856 | 1542 | ||
1857 | void ZSafe::resume(int) | 1543 | void ZSafe::resume(int) |
1858 | { | 1544 | { |
1859 | #ifndef NO_OPIE | ||
1860 | owarn << "Resume" << oendl; | ||
1861 | #endif | ||
1862 | // hide the main window | 1545 | // hide the main window |
1863 | 1546 | ||
1864 | if ( !showpwd ) | 1547 | if ( !showpwd ) |
1865 | { | 1548 | { |
1866 | infoForm->hide(); | 1549 | infoForm->hide(); |
1867 | // open zsafe again | 1550 | // open zsafe again |
1868 | m_password = ""; | 1551 | m_password = ""; |
1869 | selectedItem = NULL; | 1552 | selectedItem = NULL; |
1870 | 1553 | ||
1871 | // clear the password list | 1554 | // clear the password list |
1872 | QListViewItem *i; | 1555 | QListViewItem *i; |
1873 | // step through all categories | 1556 | // step through all categories |
1874 | for (i = ListView->firstChild(); | 1557 | for (i = ListView->firstChild(); |
1875 | i != NULL; | 1558 | i != NULL; |
1876 | i = i->nextSibling()) | 1559 | i = i->nextSibling()) |
1877 | { | 1560 | { |
1878 | // step through all subitems | 1561 | // step through all subitems |
1879 | QListViewItem *si; | 1562 | QListViewItem *si; |
1880 | for (si = i->firstChild(); | 1563 | for (si = i->firstChild(); |
1881 | si != NULL; ) | 1564 | si != NULL; ) |
1882 | { | 1565 | { |
1883 | QListViewItem *_si = si; | 1566 | QListViewItem *_si = si; |
1884 | si = si->nextSibling(); | 1567 | si = si->nextSibling(); |
1885 | i->takeItem(_si); // remove from view list | 1568 | i->takeItem(_si); // remove from view list |
1886 | if (_si) delete _si; | 1569 | if (_si) delete _si; |
1887 | } | 1570 | } |
1888 | } | 1571 | } |
1889 | 1572 | ||
1890 | // ask for password and read again | 1573 | // ask for password and read again |
1891 | openDocument(filename); | 1574 | openDocument(filename); |
1892 | } | 1575 | } |
1893 | } | 1576 | } |
1894 | 1577 | ||
1895 | //--------------------------------------------- | 1578 | //--------------------------------------------- |
1896 | 1579 | ||
1897 | 1580 | ||
1898 | bool ZSafe::openDocument(const char* _filename, const char* ) | 1581 | bool ZSafe::openDocument(const char* _filename, const char* ) |
1899 | { | 1582 | { |
1900 | QString name= _filename; | 1583 | QString name= _filename; |
1901 | qWarning("openDocument "+name); | 1584 | qWarning("openDocument "+name); |
1902 | int retval; | 1585 | int retval; |
1903 | char* entry[FIELD_SIZE]; | 1586 | char* entry[FIELD_SIZE]; |
1904 | // #ifndef Q_WS_WIN | 1587 | // #ifndef Q_WS_WIN |
1905 | int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1); | 1588 | int validationFlag = conf->readNumEntry(APP_KEY+"valzsafe", 1); |
1906 | // #else | 1589 | // #else |
1907 | // int validationFlag = 1; | 1590 | // int validationFlag = 1; |
1908 | // #endif | 1591 | // #endif |
1909 | 1592 | ||
1910 | int pwdOk = 0; | 1593 | int pwdOk = 0; |
1911 | int numberOfTries = 3; | 1594 | int numberOfTries = 3; |
1912 | for (int i=0; i < numberOfTries; i++) | 1595 | for (int i=0; i < numberOfTries; i++) |
1913 | { | 1596 | { |
1914 | QFile f(_filename); | 1597 | QFile f(_filename); |
1915 | if (f.exists()) | 1598 | if (f.exists()) |
1916 | { | 1599 | { |
1917 | // ask with a dialog for the password | 1600 | // ask with a dialog for the password |
1918 | if (m_password.isEmpty()) | 1601 | if (m_password.isEmpty()) |
1919 | getDocPassword(tr("Enter Password")); | 1602 | getDocPassword(tr("Enter Password")); |
1920 | if (m_password.isEmpty() && validationFlag == 0) | 1603 | if (m_password.isEmpty() && validationFlag == 0) |
1921 | { | 1604 | { |
1922 | #ifndef NO_OPIE | ||
1923 | owarn << "Wrong password" << oendl; | ||
1924 | #else | ||
1925 | qWarning ("Wrong password"); | ||
1926 | #endif | ||
1927 | QMessageBox::critical( 0, tr("ZSafe"), | 1605 | QMessageBox::critical( 0, tr("ZSafe"), |
1928 | tr("Wrong password.\n\nZSafe will now exit.") ); | 1606 | tr("Wrong password.\n\nZSafe will now exit.") ); |
1929 | exitZs (1); | 1607 | exitZs (1); |
1930 | } | 1608 | } |
1931 | 1609 | ||
1932 | retval = loadInit(_filename, m_password); | 1610 | retval = loadInit(_filename, m_password); |
1933 | if (retval != PWERR_GOOD) | 1611 | if (retval != PWERR_GOOD) |
1934 | { | 1612 | { |
1935 | #ifndef NO_OPIE | ||
1936 | owarn << "Error loading Document" << oendl; | ||
1937 | #else | ||
1938 | qWarning ("Error loading Document"); | ||
1939 | #endif | ||
1940 | return false; | 1613 | return false; |
1941 | } | 1614 | } |
1942 | } | 1615 | } |
1943 | else | 1616 | else |
1944 | { | 1617 | { |
1945 | #ifdef Q_WS_WIN | 1618 | this->setCaption(tr("ZSafe")); |
1946 | this->setCaption("Qt ZSafe"); | ||
1947 | #else | ||
1948 | this->setCaption("ZSafe"); | ||
1949 | #endif | ||
1950 | filename = ""; | 1619 | filename = ""; |
1951 | switch( QMessageBox::warning( this, tr("ZSafe"), | 1620 | switch( QMessageBox::warning( this, tr("ZSafe"), |
1952 | tr("<P>You must create a new document first. Ok to create?</P>"), | 1621 | tr("<P>You must create a new document first. Ok to create?</P>"), |
1953 | tr("&Yes"), tr("&No."), | 1622 | tr("&Yes"), tr("&No."), |
1954 | 0 | 1623 | 0 |
1955 | ) ) | 1624 | ) ) |
1956 | { | 1625 | { |
1957 | case 1: // No | 1626 | case 1: // No |
1958 | return false; | 1627 | return false; |
1959 | break; | 1628 | break; |
1960 | case 0: // Yes | 1629 | case 0: // Yes |
1961 | newDocument(); | 1630 | newDocument(); |
1962 | return false; | 1631 | return false; |
1963 | break; | 1632 | break; |
1964 | } | 1633 | } |
1965 | 1634 | ||
1966 | } | 1635 | } |
1967 | 1636 | ||
1968 | 1637 | ||
1969 | // load the validation entry | 1638 | // load the validation entry |
1970 | if (validationFlag == 0) | 1639 | if (validationFlag == 0) |
1971 | { | 1640 | { |
1972 | pwdOk = 1; | 1641 | pwdOk = 1; |
1973 | break; | 1642 | break; |
1974 | } | 1643 | } |
1975 | 1644 | ||
1976 | retval = loadEntry(entry); | 1645 | retval = loadEntry(entry); |
1977 | if (retval == 1 && | 1646 | if (retval == 1 && |
1978 | !strcmp (entry[0], "ZSAFECATEGORY") && | 1647 | !strcmp (entry[0], "ZSAFECATEGORY") && |
1979 | !strcmp (entry[1], "name") && | 1648 | !strcmp (entry[1], "name") && |
1980 | !strcmp (entry[2], "username") && | 1649 | !strcmp (entry[2], "username") && |
1981 | !strcmp (entry[3], "password") && | 1650 | !strcmp (entry[3], "password") && |
1982 | !strcmp (entry[4], "comment") ) | 1651 | !strcmp (entry[4], "comment") ) |
1983 | { | 1652 | { |
1984 | for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); | 1653 | for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); |
1985 | pwdOk = 1; | 1654 | pwdOk = 1; |
1986 | break; | 1655 | break; |
1987 | } | 1656 | } |
1988 | else | 1657 | else |
1989 | // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); | 1658 | // for (int count = 0; count < FIELD_SIZE; count++) free(entry[count]); |
1990 | fclose (fd); | 1659 | fclose (fd); |
1991 | m_password = ""; | 1660 | m_password = ""; |
1992 | 1661 | ||
1993 | if (i < numberOfTries - 1) | 1662 | if (i < numberOfTries - 1) |
1994 | { | 1663 | { |
1995 | switch( QMessageBox::warning( this, tr("ZSafe"), | 1664 | switch( QMessageBox::warning( this, tr("ZSafe"), |
1996 | tr("Wrong password.\nEnter again?"), | 1665 | tr("Wrong password.\nEnter again?"), |
1997 | tr("&Yes"), tr("&No."), | 1666 | tr("&Yes"), tr("&No."), |
1998 | 0 | 1667 | 0 |
1999 | ) ) | 1668 | ) ) |
2000 | { | 1669 | { |
2001 | case 1: // No | 1670 | case 1: // No |
2002 | exitZs (1); | 1671 | exitZs (1); |
2003 | break; | 1672 | break; |
2004 | case 0: // Yes | 1673 | case 0: // Yes |
2005 | continue; | 1674 | continue; |
2006 | } | 1675 | } |
2007 | } | 1676 | } |
2008 | } | 1677 | } |
2009 | if (pwdOk == 0) | 1678 | if (pwdOk == 0) |
2010 | { | 1679 | { |
2011 | // unset the document entry | 1680 | // unset the document entry |
2012 | conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); | 1681 | conf->writeEntry(APP_KEY+"document", "INVALIDPWD"); |
2013 | if (conf) | 1682 | if (conf) |
2014 | delete conf; | 1683 | delete conf; |
2015 | 1684 | ||
2016 | exitZs (1); | 1685 | exitZs (1); |
2017 | } | 1686 | } |
2018 | 1687 | ||
2019 | 1688 | ||
2020 | retval = loadEntry(entry); | 1689 | retval = loadEntry(entry); |
2021 | 1690 | ||
2022 | int numberOfEntries=0; | 1691 | int numberOfEntries=0; |
2023 | while (retval == 1) { | 1692 | while (retval == 1) { |
2024 | 1693 | ||
2025 | QString category( QString::fromUtf8(entry[0]) ); | 1694 | QString category( QString::fromUtf8(entry[0]) ); |
2026 | QString name( QString::fromUtf8(entry[1]) ); | 1695 | QString name( QString::fromUtf8(entry[1]) ); |
2027 | QString user( QString::fromUtf8(entry[2]) ); | 1696 | QString user( QString::fromUtf8(entry[2]) ); |
2028 | QString password( QString::fromUtf8(entry[3]) ); | 1697 | QString password( QString::fromUtf8(entry[3]) ); |
2029 | QString comment( QString::fromUtf8(entry[4]) ); | 1698 | QString comment( QString::fromUtf8(entry[4]) ); |
2030 | QString field5( QString::fromUtf8(entry[5]) ); | 1699 | QString field5( QString::fromUtf8(entry[5]) ); |
2031 | QString field6( QString::fromUtf8(entry[6]) ); | 1700 | QString field6( QString::fromUtf8(entry[6]) ); |
2032 | // add the subitems to the categories | 1701 | // add the subitems to the categories |
2033 | 1702 | ||
2034 | Category *cat= categories.find (category); | 1703 | Category *cat= categories.find (category); |
2035 | if (cat) | 1704 | if (cat) |
2036 | { | 1705 | { |
2037 | // use the existend item | 1706 | // use the existend item |
2038 | QListViewItem *catItem = cat->getListItem(); | 1707 | QListViewItem *catItem = cat->getListItem(); |
2039 | if (catItem) | 1708 | if (catItem) |
2040 | { | 1709 | { |
2041 | QListViewItem * item = new ShadedListItem( 0, catItem ); | 1710 | QListViewItem * item = new ShadedListItem( 0, catItem ); |
2042 | item->setText( 0, tr( name ) ); | 1711 | item->setText( 0, tr( name ) ); |
2043 | item->setText( 1, tr( user ) ); | 1712 | item->setText( 1, tr( user ) ); |
2044 | item->setText( 2, tr( password ) ); | 1713 | item->setText( 2, tr( password ) ); |
2045 | item->setText( 3, tr( comment ) ); | 1714 | item->setText( 3, tr( comment ) ); |
2046 | item->setText( 4, tr( field5 ) ); | 1715 | item->setText( 4, tr( field5 ) ); |
2047 | item->setText( 5, tr( field6 ) ); | 1716 | item->setText( 5, tr( field6 ) ); |
2048 | 1717 | ||
2049 | if (expandTree) | 1718 | if (expandTree) |
2050 | catItem->setOpen( TRUE ); | 1719 | catItem->setOpen( TRUE ); |
2051 | numberOfEntries++; | 1720 | numberOfEntries++; |
2052 | } | 1721 | } |
2053 | } | 1722 | } |
2054 | else | 1723 | else |
2055 | { | 1724 | { |
2056 | QListViewItem *catI = new ShadedListItem( 1, ListView ); | 1725 | QListViewItem *catI = new ShadedListItem( 1, ListView ); |
2057 | // create and insert a new item | 1726 | // create and insert a new item |
2058 | QListViewItem * item = new ShadedListItem( 0, catI ); | 1727 | QListViewItem * item = new ShadedListItem( 0, catI ); |
2059 | 1728 | ||
2060 | item->setText( 0, tr( name ) ); | 1729 | item->setText( 0, tr( name ) ); |
2061 | item->setText( 1, tr( user ) ); | 1730 | item->setText( 1, tr( user ) ); |
2062 | item->setText( 2, tr( password ) ); | 1731 | item->setText( 2, tr( password ) ); |
2063 | item->setText( 3, tr( comment ) ); | 1732 | item->setText( 3, tr( comment ) ); |
2064 | item->setText( 4, tr( field5 ) ); | 1733 | item->setText( 4, tr( field5 ) ); |
2065 | item->setText( 5, tr( field6 ) ); | 1734 | item->setText( 5, tr( field6 ) ); |
2066 | 1735 | ||
2067 | if (expandTree) | 1736 | if (expandTree) |
2068 | catI->setOpen( TRUE ); | 1737 | catI->setOpen( TRUE ); |
2069 | 1738 | ||
2070 | Category *c1 = new Category(); | 1739 | Category *c1 = new Category(); |
2071 | c1->setCategoryName(category); | 1740 | c1->setCategoryName(category); |
2072 | 1741 | ||
2073 | QString icon; | 1742 | QString icon; |
2074 | QString fullIconPath; | 1743 | QString fullIconPath; |
2075 | QPixmap *pix; | 1744 | QPixmap *pix; |
2076 | // #ifndef Q_WS_WIN | 1745 | // #ifndef Q_WS_WIN |
2077 | icon = conf->readEntry(APP_KEY+category); | 1746 | icon = conf->readEntry(APP_KEY+category); |
2078 | // #endif | 1747 | // #endif |
2079 | bool isIconAv = false; | 1748 | bool isIconAv = false; |
2080 | if (!icon.isEmpty() && !icon.isNull()) | 1749 | if (!icon.isEmpty() && !icon.isNull()) |
2081 | { | 1750 | { |
2082 | // build the full path | 1751 | // build the full path |
2083 | fullIconPath = iconPath + icon; | 1752 | fullIconPath = iconPath + icon; |
2084 | pix = new QPixmap (fullIconPath); | 1753 | pix = new QPixmap (fullIconPath); |
2085 | if (!pix->isNull()) | 1754 | if (!pix->isNull()) |
2086 | { | 1755 | { |
2087 | QImage img = pix->convertToImage(); | 1756 | QImage img = pix->convertToImage(); |
2088 | pix->convertFromImage(img.smoothScale(14,14)); | 1757 | pix->convertFromImage(img.smoothScale(14,14)); |
2089 | c1->setIconName (icon); | 1758 | c1->setIconName (icon); |
2090 | c1->setIcon (*pix); | 1759 | c1->setIcon (*pix); |
2091 | isIconAv = true; | 1760 | isIconAv = true; |
2092 | } | 1761 | } |
2093 | } | 1762 | } |
2094 | if (!isIconAv) | 1763 | if (!isIconAv) |
2095 | { | 1764 | { |
2096 | c1->setIcon (*getPredefinedIcon(category)); | 1765 | c1->setIcon (*getPredefinedIcon(category)); |
2097 | } | 1766 | } |
2098 | 1767 | ||
2099 | c1->setListItem (catI); | 1768 | c1->setListItem (catI); |
2100 | c1->initListItem(); | 1769 | c1->initListItem(); |
2101 | categories.insert (c1->getCategoryName(), c1); | 1770 | categories.insert (c1->getCategoryName(), c1); |
2102 | numberOfEntries++; | 1771 | numberOfEntries++; |
2103 | } | 1772 | } |
2104 | 1773 | ||
2105 | for (int count = 0; count < FIELD_SIZE; count++) { | 1774 | for (int count = 0; count < FIELD_SIZE; count++) { |
2106 | free(entry[count]); | 1775 | free(entry[count]); |
2107 | } | 1776 | } |
2108 | retval = loadEntry(entry); | 1777 | retval = loadEntry(entry); |
2109 | if (retval == 2) { | 1778 | if (retval == 2) { |
2110 | // m_parent->slotStatusHelpMsg("Last entry loaded"); | 1779 | // m_parent->slotStatusHelpMsg("Last entry loaded"); |
2111 | } | 1780 | } |
2112 | } // end while | 1781 | } // end while |
2113 | 1782 | ||
2114 | if (numberOfEntries == 0) | 1783 | if (numberOfEntries == 0) |
2115 | { | 1784 | { |
2116 | 1785 | ||
2117 | switch( QMessageBox::warning( this, tr("ZSafe"), | 1786 | switch( QMessageBox::warning( this, tr("ZSafe"), |
2118 | tr("Empty document or\nwrong password.\nContinue?"), | 1787 | tr("Empty document or\nwrong password.\nContinue?"), |
2119 | tr("&No"), tr("&Yes."), | 1788 | tr("&No"), tr("&Yes."), |
2120 | 0 | 1789 | 0 |
2121 | ) ) { | 1790 | ) ) { |
2122 | case 0: // No | 1791 | case 0: // No |
2123 | retval = loadFinalize(); | 1792 | retval = loadFinalize(); |
2124 | exitZs (1); | 1793 | exitZs (1); |
2125 | break; | 1794 | break; |
2126 | case 1: // Yes | 1795 | case 1: // Yes |
2127 | break; | 1796 | break; |
2128 | } | 1797 | } |
2129 | } | 1798 | } |
2130 | 1799 | ||
2131 | retval = loadFinalize(); | 1800 | retval = loadFinalize(); |
2132 | 1801 | ||
2133 | return true; | 1802 | return true; |
2134 | } | 1803 | } |
2135 | 1804 | ||
2136 | int ZSafe::loadInit(const char* _filename, const char *password) | 1805 | int ZSafe::loadInit(const char* _filename, const char *password) |
2137 | { | 1806 | { |
2138 | unsigned int j = 0; | 1807 | unsigned int j = 0; |
2139 | unsigned int keylength=0; | 1808 | unsigned int keylength=0; |
2140 | int count=0, count2=0, count3=0; | 1809 | int count=0, count2=0, count3=0; |
2141 | unsigned char charbuf[8]; | 1810 | unsigned char charbuf[8]; |
2142 | unsigned short ciphertext[4]; | 1811 | unsigned short ciphertext[4]; |
2143 | char key[128]; | 1812 | char key[128]; |
2144 | Krc2* krc2 = new Krc2(); | 1813 | Krc2* krc2 = new Krc2(); |
2145 | 1814 | ||
2146 | fd = fopen (_filename, "rb"); | 1815 | fd = fopen (_filename, "rb"); |
2147 | 1816 | ||
2148 | QFileInfo f (_filename); | 1817 | QFileInfo f (_filename); |
2149 | load_buffer_length = f.size(); | 1818 | load_buffer_length = f.size(); |
2150 | load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; | 1819 | load_buffer_length = ((load_buffer_length / 1024)+1) * 1024 * 2; |
2151 | 1820 | ||
2152 | if (fd == NULL) | 1821 | if (fd == NULL) |
2153 | return PWERR_OPEN; | 1822 | return PWERR_OPEN; |
2154 | 1823 | ||
2155 | buffer = (char *)malloc(load_buffer_length); | 1824 | buffer = (char *)malloc(load_buffer_length); |
2156 | for (j = 0; password[j] != '\0'; j++) { | 1825 | for (j = 0; password[j] != '\0'; j++) { |
2157 | key[j] = password[j]; | 1826 | key[j] = password[j]; |
@@ -2247,1633 +1916,1401 @@ int ZSafe::loadFinalize(void) | |||
2247 | fclose (fd); | 1916 | fclose (fd); |
2248 | if (buffer) free(buffer); | 1917 | if (buffer) free(buffer); |
2249 | return PWERR_GOOD; | 1918 | return PWERR_GOOD; |
2250 | } | 1919 | } |
2251 | 1920 | ||
2252 | bool ZSafe::saveDocument(const char* _filename, | 1921 | bool ZSafe::saveDocument(const char* _filename, |
2253 | bool withPwd, | 1922 | bool withPwd, |
2254 | const char* ) | 1923 | const char* ) |
2255 | { | 1924 | { |
2256 | if (filename.isEmpty()) | 1925 | if (filename.isEmpty()) |
2257 | { | 1926 | { |
2258 | QMessageBox::critical( 0, tr("ZSafe"), | 1927 | QMessageBox::critical( 0, tr("ZSafe"), |
2259 | tr("No document defined.\nYou have to create a new document")); | 1928 | tr("No document defined.\nYou have to create a new document")); |
2260 | return false; | 1929 | return false; |
2261 | } | 1930 | } |
2262 | 1931 | ||
2263 | // if (m_password.isEmpty()) | 1932 | // if (m_password.isEmpty()) |
2264 | // withPwd = true; // the document must be saved with a valid password | 1933 | // withPwd = true; // the document must be saved with a valid password |
2265 | if (withPwd) | 1934 | if (withPwd) |
2266 | { | 1935 | { |
2267 | bool pwdOk = FALSE; | 1936 | bool pwdOk = FALSE; |
2268 | while (!pwdOk) | 1937 | while (!pwdOk) |
2269 | { | 1938 | { |
2270 | getDocPassword(tr("Enter Password")); | 1939 | getDocPassword(tr("Enter Password")); |
2271 | if (m_password.isEmpty()) | 1940 | if (m_password.isEmpty()) |
2272 | { | 1941 | { |
2273 | 1942 | ||
2274 | QMessageBox::critical( 0, tr("ZSafe"), | 1943 | QMessageBox::critical( 0, tr("ZSafe"), |
2275 | tr("Password is empty.\nPlease enter again.")); | 1944 | tr("Password is empty.\nPlease enter again.")); |
2276 | continue; | 1945 | continue; |
2277 | } | 1946 | } |
2278 | 1947 | ||
2279 | QString firstPasswd = m_password; | 1948 | QString firstPasswd = m_password; |
2280 | 1949 | ||
2281 | getDocPassword(tr("Reenter Password")); | 1950 | getDocPassword(tr("Reenter Password")); |
2282 | if (m_password.isEmpty()) | 1951 | if (m_password.isEmpty()) |
2283 | { | 1952 | { |
2284 | QMessageBox::critical( 0, tr("ZSafe"), | 1953 | QMessageBox::critical( 0, tr("ZSafe"), |
2285 | tr("Password is empty.\nPlease enter again.")); | 1954 | tr("Password is empty.\nPlease enter again.")); |
2286 | continue; | 1955 | continue; |
2287 | } | 1956 | } |
2288 | if (firstPasswd != m_password) | 1957 | if (firstPasswd != m_password) |
2289 | { | 1958 | { |
2290 | 1959 | ||
2291 | QMessageBox::critical( 0, tr("ZSafe"), | 1960 | QMessageBox::critical( 0, tr("ZSafe"), |
2292 | tr("Passwords must be identical.\nPlease enter again.")); | 1961 | tr("Passwords must be identical.\nPlease enter again.")); |
2293 | continue; | 1962 | continue; |
2294 | } | 1963 | } |
2295 | pwdOk = TRUE; | 1964 | pwdOk = TRUE; |
2296 | modified = false; | 1965 | modified = false; |
2297 | } | 1966 | } |
2298 | } | 1967 | } |
2299 | else if (modified) | 1968 | else if (modified) |
2300 | { | 1969 | { |
2301 | QString fns(_filename); | 1970 | QString fns(_filename); |
2302 | fns = fns.right (fns.length() - fns.findRev ('/') - 1); | 1971 | fns = fns.right (fns.length() - fns.findRev ('/') - 1); |
2303 | switch( QMessageBox::information( this, tr("ZSafe"), | 1972 | switch( QMessageBox::information( this, tr("ZSafe"), |
2304 | tr("Do you want to save ") + fns + tr("\nbefore continuing?"), | 1973 | tr("Do you want to save ") + fns + tr("\nbefore continuing?"), |
2305 | tr("&Save"), | 1974 | tr("&Save"), |
2306 | tr("&Don't Save"), | 1975 | tr("&Don't Save"), |
2307 | 0 // Enter == button 0 | 1976 | 0 // Enter == button 0 |
2308 | ) ) | 1977 | ) ) |
2309 | { // Escape == button 2 | 1978 | { // Escape == button 2 |
2310 | case 0: // Save clicked, Alt-S or Enter pressed. | 1979 | case 0: // Save clicked, Alt-S or Enter pressed. |
2311 | modified = false; | 1980 | modified = false; |
2312 | break; | 1981 | break; |
2313 | case 1: // Don't Save clicked or Alt-D pressed | 1982 | case 1: // Don't Save clicked or Alt-D pressed |
2314 | modified = false; | 1983 | modified = false; |
2315 | return true; | 1984 | return true; |
2316 | } | 1985 | } |
2317 | } | 1986 | } |
2318 | modified = false; | 1987 | modified = false; |
2319 | 1988 | ||
2320 | if (m_password.isEmpty()) | 1989 | if (m_password.isEmpty()) |
2321 | return false; | 1990 | return false; |
2322 | 1991 | ||
2323 | int retval = saveInit(_filename, m_password); | 1992 | int retval = saveInit(_filename, m_password); |
2324 | // int retval = saveInit(_filename, "test"); | 1993 | // int retval = saveInit(_filename, "test"); |
2325 | if (retval != PWERR_GOOD) { | 1994 | if (retval != PWERR_GOOD) { |
2326 | return false; | 1995 | return false; |
2327 | } | 1996 | } |
2328 | 1997 | ||
2329 | char* entry[FIELD_SIZE]; | 1998 | char* entry[FIELD_SIZE]; |
2330 | 1999 | ||
2331 | // save the validation entry | 2000 | // save the validation entry |
2332 | { | 2001 | { |
2333 | int i=0; | 2002 | int i=0; |
2334 | entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); | 2003 | entry[i] = (char*)malloc(strlen("ZSAFECATEGORY")+1); |
2335 | strcpy(entry[i++], "ZSAFECATEGORY"); | 2004 | strcpy(entry[i++], "ZSAFECATEGORY"); |
2336 | entry[i] = (char*)malloc(strlen("name")+1); | 2005 | entry[i] = (char*)malloc(strlen("name")+1); |
2337 | strcpy(entry[i++], "name"); | 2006 | strcpy(entry[i++], "name"); |
2338 | entry[i] = (char*)malloc(strlen("username")+1); | 2007 | entry[i] = (char*)malloc(strlen("username")+1); |
2339 | strcpy(entry[i++], "username"); | 2008 | strcpy(entry[i++], "username"); |
2340 | entry[i] = (char*)malloc(strlen("password")+1); | 2009 | entry[i] = (char*)malloc(strlen("password")+1); |
2341 | strcpy(entry[i++], "password"); | 2010 | strcpy(entry[i++], "password"); |
2342 | entry[i] = (char*)malloc(strlen("comment")+1); | 2011 | entry[i] = (char*)malloc(strlen("comment")+1); |
2343 | strcpy(entry[i++], "comment"); | 2012 | strcpy(entry[i++], "comment"); |
2344 | 2013 | ||
2345 | entry[i] = (char*)malloc(strlen("field5")+1); | 2014 | entry[i] = (char*)malloc(strlen("field5")+1); |
2346 | strcpy(entry[i++], "field5"); | 2015 | strcpy(entry[i++], "field5"); |
2347 | entry[i] = (char*)malloc(strlen("field6")+1); | 2016 | entry[i] = (char*)malloc(strlen("field6")+1); |
2348 | strcpy(entry[i++], "field6"); | 2017 | strcpy(entry[i++], "field6"); |
2349 | 2018 | ||
2350 | retval = saveEntry(entry); | 2019 | retval = saveEntry(entry); |
2351 | for (int z=0; z<i; z++) free(entry[z]); | 2020 | for (int z=0; z<i; z++) free(entry[z]); |
2352 | if (retval == PWERR_DATA) { | 2021 | if (retval == PWERR_DATA) { |
2353 | #ifndef NO_OPIE | 2022 | #ifndef NO_OPIE |
2354 | owarn << "1: Error writing file, contents not saved" << oendl; | 2023 | owarn << "1: Error writing file, contents not saved" << oendl; |
2355 | #else | 2024 | #else |
2356 | qWarning("1: Error writing file, contents not saved"); | 2025 | qWarning("1: Error writing file, contents not saved"); |
2357 | #endif | 2026 | #endif |
2358 | saveFinalize(); | 2027 | saveFinalize(); |
2359 | return false; | 2028 | return false; |
2360 | } | 2029 | } |
2361 | // #ifndef Q_WS_WIN | 2030 | // #ifndef Q_WS_WIN |
2362 | conf->writeEntry(APP_KEY+"valzsafe", 1); | 2031 | conf->writeEntry(APP_KEY+"valzsafe", 1); |
2363 | // #endif | 2032 | // #endif |
2364 | saveConf(); | 2033 | saveConf(); |
2365 | } | 2034 | } |
2366 | 2035 | ||
2367 | QListViewItem *i; | 2036 | QListViewItem *i; |
2368 | // step through all categories | 2037 | // step through all categories |
2369 | for (i = ListView->firstChild(); | 2038 | for (i = ListView->firstChild(); |
2370 | i != NULL; | 2039 | i != NULL; |
2371 | i = i->nextSibling()) | 2040 | i = i->nextSibling()) |
2372 | { | 2041 | { |
2373 | // step through all subitems | 2042 | // step through all subitems |
2374 | QListViewItem *si; | 2043 | QListViewItem *si; |
2375 | for (si = i->firstChild(); | 2044 | for (si = i->firstChild(); |
2376 | si != NULL; | 2045 | si != NULL; |
2377 | si = si->nextSibling()) | 2046 | si = si->nextSibling()) |
2378 | { | 2047 | { |
2379 | int j=0; | 2048 | int j=0; |
2380 | entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1); | 2049 | entry[j] = (char*)malloc(strlen(i->text(0).utf8())+1); |
2381 | strcpy(entry[j++], i->text(0).utf8()); | 2050 | strcpy(entry[j++], i->text(0).utf8()); |
2382 | entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1); | 2051 | entry[j] = (char*)malloc(strlen(si->text(0).utf8())+1); |
2383 | strcpy(entry[j++], si->text(0).utf8()); | 2052 | strcpy(entry[j++], si->text(0).utf8()); |
2384 | entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1); | 2053 | entry[j] = (char*)malloc(strlen(si->text(1).utf8())+1); |
2385 | strcpy(entry[j++], si->text(1).utf8()); | 2054 | strcpy(entry[j++], si->text(1).utf8()); |
2386 | entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1); | 2055 | entry[j] = (char*)malloc(strlen(si->text(2).utf8())+1); |
2387 | strcpy(entry[j++], si->text(2).utf8()); | 2056 | strcpy(entry[j++], si->text(2).utf8()); |
2388 | entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1); | 2057 | entry[j] = (char*)malloc(strlen(si->text(3).utf8())+1); |
2389 | strcpy(entry[j++], si->text(3).utf8()); | 2058 | strcpy(entry[j++], si->text(3).utf8()); |
2390 | entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1); | 2059 | entry[j] = (char*)malloc(strlen(si->text(4).utf8())+1); |
2391 | strcpy(entry[j++], si->text(4).utf8()); | 2060 | strcpy(entry[j++], si->text(4).utf8()); |
2392 | entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1); | 2061 | entry[j] = (char*)malloc(strlen(si->text(5).utf8())+1); |
2393 | strcpy(entry[j++], si->text(5).utf8()); | 2062 | strcpy(entry[j++], si->text(5).utf8()); |
2394 | 2063 | ||
2395 | retval = saveEntry(entry); | 2064 | retval = saveEntry(entry); |
2396 | for (int z=0; z<j; z++) | 2065 | for (int z=0; z<j; z++) |
2397 | { | 2066 | { |
2398 | free(entry[z]); | 2067 | free(entry[z]); |
2399 | } | 2068 | } |
2400 | if (retval == PWERR_DATA) { | 2069 | if (retval == PWERR_DATA) { |
2401 | #ifndef NO_OPIE | 2070 | #ifndef NO_OPIE |
2402 | owarn << "1: Error writing file, contents not saved" << oendl; | 2071 | owarn << "1: Error writing file, contents not saved" << oendl; |
2403 | #else | 2072 | #else |
2404 | qWarning("1: Error writing file, contents not saved"); | 2073 | qWarning("1: Error writing file, contents not saved"); |
2405 | #endif | 2074 | #endif |
2406 | saveFinalize(); | 2075 | saveFinalize(); |
2407 | return false; | 2076 | return false; |
2408 | } | 2077 | } |
2409 | 2078 | ||
2410 | } | 2079 | } |
2411 | } | 2080 | } |
2412 | 2081 | ||
2413 | if (saveFinalize() == PWERR_DATA) { | 2082 | if (saveFinalize() == PWERR_DATA) { |
2414 | #ifndef NO_OPIE | 2083 | #ifndef NO_OPIE |
2415 | owarn << "2: Error writing file, contents not saved" << oendl; | 2084 | owarn << "2: Error writing file, contents not saved" << oendl; |
2416 | #else | 2085 | #else |
2417 | qWarning("2: Error writing file, contents not saved"); | 2086 | qWarning("2: Error writing file, contents not saved"); |
2418 | #endif | 2087 | #endif |
2419 | return false; | 2088 | return false; |
2420 | } else { | 2089 | } else { |
2421 | #ifndef DESKTOP | 2090 | #ifndef DESKTOP |
2422 | Global::statusMessage (tr("Password file saved.")); | 2091 | Global::statusMessage (tr("Password file saved.")); |
2423 | #endif | 2092 | #endif |
2424 | modified = false; | 2093 | modified = false; |
2425 | return true; | 2094 | return true; |
2426 | } | 2095 | } |
2427 | } | 2096 | } |
2428 | 2097 | ||
2429 | PasswordForm *newPwdDialog; | 2098 | PasswordForm *newPwdDialog; |
2430 | bool newPwdDialogResult = false; | 2099 | bool newPwdDialogResult = false; |
2431 | void ZSafe::setPasswordDialogDone() | 2100 | void ZSafe::setPasswordDialogDone() |
2432 | { | 2101 | { |
2433 | newPwdDialogResult = true; | 2102 | newPwdDialogResult = true; |
2434 | newPwdDialog->close(); | 2103 | newPwdDialog->close(); |
2435 | } | 2104 | } |
2436 | 2105 | ||
2437 | void ZSafe::getDocPassword(QString title) | 2106 | void ZSafe::getDocPassword(QString title) |
2438 | { | 2107 | { |
2439 | #ifndef NO_OPIE | ||
2440 | owarn << "getDocPassword" << oendl; | ||
2441 | #endif | ||
2442 | // open the 'Password' dialog | 2108 | // open the 'Password' dialog |
2443 | PasswordForm *dialog = new PasswordForm(this, title, TRUE); | 2109 | PasswordForm *dialog = new PasswordForm(this, title, TRUE); |
2444 | newPwdDialog = dialog; | 2110 | newPwdDialog = dialog; |
2445 | newPwdDialogResult = false; | 2111 | newPwdDialogResult = false; |
2446 | 2112 | ||
2447 | QPixmap image0( ( const char** ) zsafe_xpm ); | 2113 | QPixmap image0( ( const char** ) zsafe_xpm ); |
2448 | dialog->setIcon( image0); | 2114 | dialog->setIcon( image0); |
2449 | 2115 | ||
2450 | connect( dialog->PasswordField, SIGNAL( returnPressed() ), | 2116 | connect( dialog->PasswordField, SIGNAL( returnPressed() ), |
2451 | this, SLOT( setPasswordDialogDone() ) ); | 2117 | this, SLOT( setPasswordDialogDone() ) ); |
2452 | 2118 | ||
2453 | // CS: !!! | 2119 | // CS: !!! |
2454 | // int pos = filename.findRev ('/'); | 2120 | // int pos = filename.findRev ('/'); |
2455 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 2121 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
2456 | #ifdef Q_WS_WIN | ||
2457 | dialog->setCaption("Qt " + ti); | ||
2458 | #else | ||
2459 | dialog->setCaption(ti); | 2122 | dialog->setCaption(ti); |
2460 | #endif | ||
2461 | // dialog->setCaption(title); | 2123 | // dialog->setCaption(title); |
2462 | 2124 | ||
2463 | dialog->PasswordField->setFocus(); | 2125 | dialog->PasswordField->setFocus(); |
2464 | DialogCode result = (DialogCode) dialog->exec(); | 2126 | QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); |
2465 | #ifdef DESKTOP | ||
2466 | result = Accepted; | ||
2467 | #endif | ||
2468 | 2127 | ||
2469 | QString password; | 2128 | QString password; |
2470 | if (result == Accepted || newPwdDialogResult) | 2129 | if (result == QDialog::Accepted || newPwdDialogResult) |
2471 | { | 2130 | { |
2472 | m_password = dialog->PasswordField->text(); | 2131 | m_password = dialog->PasswordField->text(); |
2473 | } | 2132 | } |
2474 | else | 2133 | else |
2475 | { | 2134 | { |
2476 | exitZs (1); | 2135 | exitZs (1); |
2477 | } | 2136 | } |
2478 | } | 2137 | } |
2479 | 2138 | ||
2480 | int ZSafe::saveInit(const char *_filename, const char *password) | 2139 | int ZSafe::saveInit(const char *_filename, const char *password) |
2481 | { | 2140 | { |
2482 | char key[128]; | 2141 | char key[128]; |
2483 | unsigned int j = 0; | 2142 | unsigned int j = 0; |
2484 | unsigned int keylength; | 2143 | unsigned int keylength; |
2485 | // int val; | 2144 | // int val; |
2486 | int count2; | 2145 | int count2; |
2487 | Krc2* krc2 = new Krc2(); | 2146 | Krc2* krc2 = new Krc2(); |
2488 | 2147 | ||
2489 | /* first we should check the permissions of the filename */ | 2148 | /* first we should check the permissions of the filename */ |
2490 | /* | 2149 | /* |
2491 | if (QFile::exists(_filename)) { | 2150 | if (QFile::exists(_filename)) { |
2492 | val = checkFile(_filename); | 2151 | val = checkFile(_filename); |
2493 | if (val != PWERR_GOOD) | 2152 | if (val != PWERR_GOOD) |
2494 | return val; | 2153 | return val; |
2495 | } else | 2154 | } else |
2496 | { | 2155 | { |
2497 | val = creat (_filename, (S_IRUSR | S_IWUSR)); | 2156 | val = creat (_filename, (S_IRUSR | S_IWUSR)); |
2498 | if (val == -1) | 2157 | if (val == -1) |
2499 | return PWERR_OPEN; | 2158 | return PWERR_OPEN; |
2500 | else | 2159 | else |
2501 | close(val); | 2160 | close(val); |
2502 | } | 2161 | } |
2503 | */ | 2162 | */ |
2504 | QFileInfo f (_filename); | 2163 | QFileInfo f (_filename); |
2505 | save_buffer_length = f.size(); | 2164 | save_buffer_length = f.size(); |
2506 | save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; | 2165 | save_buffer_length = ((save_buffer_length / 1024)+1) * 1024; |
2507 | 2166 | ||
2508 | fd = fopen (_filename, "wb"); | 2167 | fd = fopen (_filename, "wb"); |
2509 | if (fd == NULL) | 2168 | if (fd == NULL) |
2510 | return PWERR_OPEN; | 2169 | return PWERR_OPEN; |
2511 | 2170 | ||
2512 | buffer = (char*)malloc(save_buffer_length); | 2171 | buffer = (char*)malloc(save_buffer_length); |
2513 | 2172 | ||
2514 | /* make the key ready */ | 2173 | /* make the key ready */ |
2515 | for (j = 0; password[j] != '\0'; j++) { | 2174 | for (j = 0; password[j] != '\0'; j++) { |
2516 | key[j] = password[j]; | 2175 | key[j] = password[j]; |
2517 | } | 2176 | } |
2518 | keylength = j; | 2177 | keylength = j; |
2519 | krc2->rc2_expandkey (key, keylength, 128); | 2178 | krc2->rc2_expandkey (key, keylength, 128); |
2520 | 2179 | ||
2521 | /* First, we make the IV */ | 2180 | /* First, we make the IV */ |
2522 | for (count2 = 0; count2 < 4; count2++) { | 2181 | for (count2 = 0; count2 < 4; count2++) { |
2523 | iv[count2] = rand (); | 2182 | iv[count2] = rand (); |
2524 | putc ((unsigned char) (iv[count2] >> 8), fd); | 2183 | putc ((unsigned char) (iv[count2] >> 8), fd); |
2525 | putc ((unsigned char) (iv[count2] & 0xff), fd); | 2184 | putc ((unsigned char) (iv[count2] & 0xff), fd); |
2526 | } | 2185 | } |
2527 | 2186 | ||
2528 | bufferIndex = 0; | 2187 | bufferIndex = 0; |
2529 | return PWERR_GOOD; | 2188 | return PWERR_GOOD; |
2530 | } | 2189 | } |
2531 | 2190 | ||
2532 | 2191 | ||
2533 | int ZSafe::saveEntry(char *entry[FIELD_SIZE]) | 2192 | int ZSafe::saveEntry(char *entry[FIELD_SIZE]) |
2534 | { | 2193 | { |
2535 | char *text1; | 2194 | char *text1; |
2536 | int count2, count3; | 2195 | int count2, count3; |
2537 | unsigned short ciphertext[4]; | 2196 | unsigned short ciphertext[4]; |
2538 | Krc2* krc2 = new Krc2(); | 2197 | Krc2* krc2 = new Krc2(); |
2539 | 2198 | ||
2540 | buffer = (char*)memset(buffer, '\0', save_buffer_length); | 2199 | buffer = (char*)memset(buffer, '\0', save_buffer_length); |
2541 | 2200 | ||
2542 | for (count2 = 0; count2 < FIELD_SIZE; count2++) { | 2201 | for (count2 = 0; count2 < FIELD_SIZE; count2++) { |
2543 | text1 = entry[count2]; | 2202 | text1 = entry[count2]; |
2544 | if (strlen (text1) == 0) { | 2203 | if (strlen (text1) == 0) { |
2545 | strncat(buffer, " ", strlen(" ")); | 2204 | strncat(buffer, " ", strlen(" ")); |
2546 | } else { | 2205 | } else { |
2547 | strncat(buffer, text1, strlen(text1)); | 2206 | strncat(buffer, text1, strlen(text1)); |
2548 | } | 2207 | } |
2549 | /* Use 255 as the marker. \n is too tough to test for */ | 2208 | /* Use 255 as the marker. \n is too tough to test for */ |
2550 | buffer[strlen (buffer)] = 255; | 2209 | buffer[strlen (buffer)] = 255; |
2551 | } /*for (count2 = 0; count2 < 5; count2++)*/ | 2210 | } /*for (count2 = 0; count2 < 5; count2++)*/ |
2552 | count2 = 0; | 2211 | count2 = 0; |
2553 | /* I'm using CBC mode and encrypting the data straight from top down. | 2212 | /* I'm using CBC mode and encrypting the data straight from top down. |
2554 | * At the bottom, encrypted, I will append an MD5 hash of the file, eventually. | 2213 | * At the bottom, encrypted, I will append an MD5 hash of the file, eventually. |
2555 | * PKCS 5 padding (explained at the code section | 2214 | * PKCS 5 padding (explained at the code section |
2556 | */ | 2215 | */ |
2557 | while (count2 < (int)strlen (buffer)) { | 2216 | while (count2 < (int)strlen (buffer)) { |
2558 | #ifndef WORDS_BIGENDIAN | 2217 | #ifndef WORDS_BIGENDIAN |
2559 | plaintext[bufferIndex] = buffer[count2 + 1] << 8; | 2218 | plaintext[bufferIndex] = buffer[count2 + 1] << 8; |
2560 | plaintext[bufferIndex] += buffer[count2] & 0xff; | 2219 | plaintext[bufferIndex] += buffer[count2] & 0xff; |
2561 | #endif | 2220 | #endif |
2562 | #ifdef WORDS_BIGENDIAN | 2221 | #ifdef WORDS_BIGENDIAN |
2563 | plaintext[bufferIndex] = buffer[count2] << 8; | 2222 | plaintext[bufferIndex] = buffer[count2] << 8; |
2564 | plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; | 2223 | plaintext[bufferIndex] += buffer[count2 + 1] & 0xff; |
2565 | #endif | 2224 | #endif |
2566 | bufferIndex++; | 2225 | bufferIndex++; |
2567 | if (bufferIndex == 4) { | 2226 | if (bufferIndex == 4) { |
2568 | krc2->rc2_encrypt (plaintext); | 2227 | krc2->rc2_encrypt (plaintext); |
2569 | 2228 | ||
2570 | for (count3 = 0; count3 < 4; count3++) { | 2229 | for (count3 = 0; count3 < 4; count3++) { |
2571 | ciphertext[count3] = iv[count3] ^ plaintext[count3]; | 2230 | ciphertext[count3] = iv[count3] ^ plaintext[count3]; |
2572 | 2231 | ||
2573 | /* Now store the ciphertext as the iv */ | 2232 | /* Now store the ciphertext as the iv */ |
2574 | iv[count3] = plaintext[count3]; | 2233 | iv[count3] = plaintext[count3]; |
2575 | 2234 | ||
2576 | /* reset the buffer index */ | 2235 | /* reset the buffer index */ |
2577 | bufferIndex = 0; | 2236 | bufferIndex = 0; |
2578 | if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; | 2237 | if (putc ((unsigned char) (ciphertext[count3] >> 8), fd) == EOF) return PWERR_DATA; |
2579 | if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; | 2238 | if (putc ((unsigned char) (ciphertext[count3] & 0xff), fd) == EOF) return PWERR_DATA; |
2580 | } /*for (count3 = 0; count3 < 5; count3++)*/ | 2239 | } /*for (count3 = 0; count3 < 5; count3++)*/ |
2581 | } /*if (bufferIndex == 5)*/ | 2240 | } /*if (bufferIndex == 5)*/ |
2582 | /* increment a short, not a byte */ | 2241 | /* increment a short, not a byte */ |
2583 | count2 += 2; | 2242 | count2 += 2; |
2584 | } /*while (count2 < strlen (buffer))*/ | 2243 | } /*while (count2 < strlen (buffer))*/ |
2585 | int ret = PWERR_GOOD; | 2244 | int ret = PWERR_GOOD; |
2586 | return ret; | 2245 | return ret; |
2587 | } | 2246 | } |
2588 | 2247 | ||
2589 | int ZSafe::saveFinalize(void) | 2248 | int ZSafe::saveFinalize(void) |
2590 | { | 2249 | { |
2591 | int count1, retval = PWERR_GOOD; | 2250 | int count1, retval = PWERR_GOOD; |
2592 | unsigned short ciphertext[4]; | 2251 | unsigned short ciphertext[4]; |
2593 | Krc2* krc2 = new Krc2(); | 2252 | Krc2* krc2 = new Krc2(); |
2594 | 2253 | ||
2595 | /* Tack on the PKCS 5 padding | 2254 | /* Tack on the PKCS 5 padding |
2596 | * How it works is we fill up the last n bytes with the value n | 2255 | * How it works is we fill up the last n bytes with the value n |
2597 | * | 2256 | * |
2598 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left | 2257 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left |
2599 | * over, leaving us 3 short, so we fill it in with 3's. | 2258 | * over, leaving us 3 short, so we fill it in with 3's. |
2600 | * | 2259 | * |
2601 | * If we come out even, we fill it with 8 8s | 2260 | * If we come out even, we fill it with 8 8s |
2602 | * | 2261 | * |
2603 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. | 2262 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. |
2604 | * so, half everything | 2263 | * so, half everything |
2605 | */ | 2264 | */ |
2606 | for (count1 = bufferIndex; count1 < 4; count1++) { | 2265 | for (count1 = bufferIndex; count1 < 4; count1++) { |
2607 | plaintext[count1] = (4 - bufferIndex); | 2266 | plaintext[count1] = (4 - bufferIndex); |
2608 | } | 2267 | } |
2609 | krc2->rc2_encrypt (plaintext); | 2268 | krc2->rc2_encrypt (plaintext); |
2610 | for (count1 = 0; count1 < 4; count1++) { | 2269 | for (count1 = 0; count1 < 4; count1++) { |
2611 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; | 2270 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; |
2612 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; | 2271 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; |
2613 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; | 2272 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; |
2614 | } | 2273 | } |
2615 | 2274 | ||
2616 | fclose (fd); | 2275 | fclose (fd); |
2617 | free(buffer); | 2276 | free(buffer); |
2618 | return retval; | 2277 | return retval; |
2619 | } | 2278 | } |
2620 | 2279 | ||
2621 | void ZSafe::quitMe () | 2280 | void ZSafe::quitMe () |
2622 | { | 2281 | { |
2623 | #ifndef NO_OPIE | ||
2624 | owarn << "QUIT..." << oendl; | ||
2625 | #endif | ||
2626 | |||
2627 | if (modified) | 2282 | if (modified) |
2628 | { | 2283 | { |
2629 | switch( QMessageBox::information( this, tr("ZSafe"), | 2284 | switch( QMessageBox::information( this, tr("ZSafe"), |
2630 | tr("Do you want to save\nbefore exiting?"), | 2285 | tr("Do you want to save\nbefore exiting?"), |
2631 | tr("&Save"), | 2286 | tr("&Save"), |
2632 | tr("S&ave with\nnew\npassword"), | 2287 | tr("S&ave with\nnew\npassword"), |
2633 | tr("&Don't Save"), | 2288 | tr("&Don't Save"), |
2634 | 0 // Enter == button 0 | 2289 | 0 // Enter == button 0 |
2635 | ) ) | 2290 | ) ) |
2636 | { // Escape == button 2 | 2291 | { // Escape == button 2 |
2637 | case 0: // Save clicked, Alt-S or Enter pressed. | 2292 | case 0: // Save clicked, Alt-S or Enter pressed. |
2638 | // save | 2293 | // save |
2639 | modified = false; | 2294 | modified = false; |
2640 | saveDocument(filename, FALSE); | 2295 | saveDocument(filename, FALSE); |
2641 | exitZs (1); | 2296 | exitZs (1); |
2642 | break; | 2297 | break; |
2643 | case 1: // | 2298 | case 1: // |
2644 | // Save with new password | 2299 | // Save with new password |
2645 | modified = false; | 2300 | modified = false; |
2646 | saveDocument(filename, TRUE); | 2301 | saveDocument(filename, TRUE); |
2647 | exitZs (1); | 2302 | exitZs (1); |
2648 | break; | 2303 | break; |
2649 | case 2: // Don't Save clicked or Alt-D pressed | 2304 | case 2: // Don't Save clicked or Alt-D pressed |
2650 | // don't save but exitZs | 2305 | // don't save but exitZs |
2651 | exitZs (1); | 2306 | exitZs (1); |
2652 | break; | 2307 | break; |
2653 | } | 2308 | } |
2654 | } | 2309 | } |
2655 | exitZs (1); | 2310 | exitZs (1); |
2656 | 2311 | ||
2657 | } | 2312 | } |
2658 | 2313 | ||
2659 | void ZSafe::categoryFieldActivated( const QString& category) | 2314 | void ZSafe::categoryFieldActivated( const QString& category) |
2660 | { | 2315 | { |
2661 | if (categoryDialog) | 2316 | if (categoryDialog) |
2662 | setCategoryDialogFields(categoryDialog, category); | 2317 | setCategoryDialogFields(categoryDialog, category); |
2663 | } | 2318 | } |
2664 | 2319 | ||
2665 | void ZSafe::addCategory() | 2320 | void ZSafe::addCategory() |
2666 | { | 2321 | { |
2667 | if (filename.isEmpty()) | 2322 | if (filename.isEmpty()) |
2668 | { | 2323 | { |
2669 | QMessageBox::critical( 0, tr("ZSafe"), | 2324 | QMessageBox::critical( 0, tr("ZSafe"), |
2670 | tr("No document defined.\nYou have to create a new document")); | 2325 | tr("No document defined.\nYou have to create a new document")); |
2671 | return; | 2326 | return; |
2672 | } | 2327 | } |
2673 | else | 2328 | else |
2674 | { | 2329 | { |
2675 | // open the 'Category' dialog | 2330 | // open the 'Category' dialog |
2676 | bool initIcons = false; | 2331 | bool initIcons = false; |
2677 | // open the 'Category' dialog | 2332 | // open the 'Category' dialog |
2678 | CategoryDialog *dialog; | 2333 | CategoryDialog *dialog; |
2679 | if (categoryDialog) | 2334 | if (categoryDialog) |
2680 | { | 2335 | { |
2681 | dialog = categoryDialog; | 2336 | dialog = categoryDialog; |
2682 | } | 2337 | } |
2683 | else | 2338 | else |
2684 | { | 2339 | { |
2685 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2340 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
2686 | #ifdef Q_WS_WIN | ||
2687 | categoryDialog->setCaption ("Qt " + tr("Category")); | ||
2688 | #endif | ||
2689 | dialog = categoryDialog; | 2341 | dialog = categoryDialog; |
2690 | connect( dialog->CategoryField, | 2342 | connect( dialog->CategoryField, |
2691 | SIGNAL( activated(const QString&)), | 2343 | SIGNAL( activated(const QString&)), |
2692 | this, SLOT( categoryFieldActivated(const QString&) ) ); | 2344 | this, SLOT( categoryFieldActivated(const QString&) ) ); |
2693 | initIcons = true; | 2345 | initIcons = true; |
2694 | } | 2346 | } |
2695 | 2347 | ||
2696 | #ifdef DESKTOP | ||
2697 | #ifndef Q_WS_WIN | ||
2698 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | ||
2699 | #else | ||
2700 | // read all categories from the config file and store | 2348 | // read all categories from the config file and store |
2701 | // into a list | 2349 | // into a list |
2702 | QFile f (cfgFile); | 2350 | QFile f (cfgFile); |
2703 | QStringList list; | 2351 | QStringList list; |
2704 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2352 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
2705 | QTextStream t( &f ); // use a text stream | 2353 | QTextStream t( &f ); // use a text stream |
2706 | QString s; | 2354 | QString s; |
2707 | int n = 1; | ||
2708 | while ( !t.eof() ) { // until end of file... | 2355 | while ( !t.eof() ) { // until end of file... |
2709 | s = t.readLine(); // line of text excluding '\n' | 2356 | s = t.readLine(); // line of text excluding '\n' |
2710 | list.append(s); | 2357 | list.append(s); |
2711 | } | 2358 | } |
2712 | f.close(); | 2359 | f.close(); |
2713 | } | 2360 | } |
2714 | #endif | ||
2715 | #else | ||
2716 | // read all categories from the config file and store | ||
2717 | // into a list | ||
2718 | QFile f (cfgFile); | ||
2719 | QStringList list; | ||
2720 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | ||
2721 | QTextStream t( &f ); // use a text stream | ||
2722 | QString s; | ||
2723 | while ( !t.eof() ) { // until end of file... | ||
2724 | s = t.readLine(); // line of text excluding '\n' | ||
2725 | list.append(s); | ||
2726 | } | ||
2727 | f.close(); | ||
2728 | } | ||
2729 | #endif | ||
2730 | QStringList::Iterator it = list.begin(); | 2361 | QStringList::Iterator it = list.begin(); |
2731 | QString categ; | 2362 | QString categ; |
2732 | QString firstCategory; | 2363 | QString firstCategory; |
2733 | dialog->CategoryField->clear(); // remove all items | 2364 | dialog->CategoryField->clear(); // remove all items |
2734 | while( it != list.end() ) | 2365 | while( it != list.end() ) |
2735 | { | 2366 | { |
2736 | QString *cat = new QString (*it); | 2367 | QString *cat = new QString (*it); |
2737 | if (cat->contains("-field1", FALSE)) | 2368 | if (cat->contains("-field1", FALSE)) |
2738 | { | 2369 | { |
2739 | #ifdef DESKTOP | ||
2740 | #ifndef Q_WS_WIN | ||
2741 | categ = cat->section ("-field1", 0, 0); | ||
2742 | #else | ||
2743 | int pos = cat->find ("-field1"); | ||
2744 | categ = cat->left (pos); | ||
2745 | #endif | ||
2746 | #else | ||
2747 | int pos = cat->find ("-field1"); | 2370 | int pos = cat->find ("-field1"); |
2748 | cat->truncate(pos); | 2371 | cat->truncate(pos); |
2749 | categ = *cat; | 2372 | categ = *cat; |
2750 | #endif | ||
2751 | if (!categ.isEmpty()) | 2373 | if (!categ.isEmpty()) |
2752 | { | 2374 | { |
2753 | dialog->CategoryField->insertItem (categ, -1); | 2375 | dialog->CategoryField->insertItem (categ, -1); |
2754 | if (firstCategory.isEmpty()) | 2376 | if (firstCategory.isEmpty()) |
2755 | firstCategory = categ; | 2377 | firstCategory = categ; |
2756 | } | 2378 | } |
2757 | } | 2379 | } |
2758 | ++it; | 2380 | ++it; |
2759 | } | 2381 | } |
2760 | 2382 | ||
2761 | 2383 | ||
2762 | if (firstCategory.isEmpty()) | 2384 | if (firstCategory.isEmpty()) |
2763 | setCategoryDialogFields(dialog); | 2385 | setCategoryDialogFields(dialog); |
2764 | else | 2386 | else |
2765 | setCategoryDialogFields(dialog, firstCategory); | 2387 | setCategoryDialogFields(dialog, firstCategory); |
2766 | 2388 | ||
2767 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); | 2389 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); |
2768 | 2390 | ||
2769 | if (initIcons) | 2391 | if (initIcons) |
2770 | { | 2392 | { |
2771 | Wait waitDialog(this, tr("Wait dialog")); | 2393 | Wait waitDialog(this, tr("Wait dialog")); |
2772 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 2394 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
2773 | waitDialog.show(); | 2395 | waitDialog.show(); |
2774 | qApp->processEvents(); | 2396 | qApp->processEvents(); |
2775 | 2397 | ||
2776 | #ifdef DESKTOP | ||
2777 | QDir d(iconPath); | ||
2778 | #else | ||
2779 | QDir d(QPEApplication::qpeDir() + "pics/"); | 2398 | QDir d(QPEApplication::qpeDir() + "pics/"); |
2780 | #endif | ||
2781 | d.setFilter( QDir::Files); | 2399 | d.setFilter( QDir::Files); |
2782 | 2400 | ||
2783 | const QFileInfoList *list = d.entryInfoList(); | 2401 | const QFileInfoList *list = d.entryInfoList(); |
2784 | QFileInfoListIterator it( *list ); // create list iterator | 2402 | QFileInfoListIterator it( *list ); // create list iterator |
2785 | QFileInfo *fi; // pointer for traversing | 2403 | QFileInfo *fi; // pointer for traversing |
2786 | 2404 | ||
2787 | dialog->IconField->insertItem("predefined"); | 2405 | dialog->IconField->insertItem("predefined"); |
2788 | while ( (fi=it.current()) ) { // for each file... | 2406 | while ( (fi=it.current()) ) { // for each file... |
2789 | QString fileName = fi->fileName(); | 2407 | QString fileName = fi->fileName(); |
2790 | if(fileName.right(4) == ".png"){ | 2408 | if(fileName.right(4) == ".png"){ |
2791 | fileName = fileName.mid(0,fileName.length()-4); | 2409 | fileName = fileName.mid(0,fileName.length()-4); |
2792 | #ifdef DESKTOP | ||
2793 | QPixmap imageOfFile; | ||
2794 | imageOfFile.load(iconPath + fi->fileName()); | ||
2795 | #else | ||
2796 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 2410 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
2797 | #endif | ||
2798 | QImage foo = imageOfFile.convertToImage(); | 2411 | QImage foo = imageOfFile.convertToImage(); |
2799 | foo = foo.smoothScale(16,16); | 2412 | foo = foo.smoothScale(16,16); |
2800 | imageOfFile.convertFromImage(foo); | 2413 | imageOfFile.convertFromImage(foo); |
2801 | dialog->IconField->insertItem(imageOfFile,fileName); | 2414 | dialog->IconField->insertItem(imageOfFile,fileName); |
2802 | } | 2415 | } |
2803 | ++it; | 2416 | ++it; |
2804 | } | 2417 | } |
2805 | waitDialog.hide(); | 2418 | waitDialog.hide(); |
2806 | } | 2419 | } |
2807 | 2420 | ||
2808 | #ifndef Q_WS_WIN | 2421 | QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); |
2809 | dialog->show(); | ||
2810 | #endif | ||
2811 | #ifndef DESKTOP | ||
2812 | // dialog->move (20, 100); | ||
2813 | #endif | ||
2814 | DialogCode result = (DialogCode) dialog->exec(); | ||
2815 | #ifdef DESKTOP | ||
2816 | result = Accepted; | ||
2817 | #endif | ||
2818 | |||
2819 | QString category; | 2422 | QString category; |
2820 | QString icon; | 2423 | QString icon; |
2821 | QString fullIconPath; | 2424 | QString fullIconPath; |
2822 | QPixmap *pix; | 2425 | QPixmap *pix; |
2823 | if (result == Accepted) | 2426 | if (result == QDialog::Accepted) |
2824 | { | 2427 | { |
2825 | modified = true; | 2428 | modified = true; |
2826 | category = dialog->CategoryField->currentText(); | 2429 | category = dialog->CategoryField->currentText(); |
2827 | icon = dialog->IconField->currentText()+".png"; | 2430 | icon = dialog->IconField->currentText()+".png"; |
2828 | 2431 | ||
2829 | #ifndef NO_OPIE | ||
2830 | owarn << category << oendl; | ||
2831 | #endif | ||
2832 | |||
2833 | QListViewItem *li = new ShadedListItem( 1, ListView ); | 2432 | QListViewItem *li = new ShadedListItem( 1, ListView ); |
2834 | Category *c1 = new Category(); | 2433 | Category *c1 = new Category(); |
2835 | c1->setCategoryName(category); | 2434 | c1->setCategoryName(category); |
2836 | 2435 | ||
2837 | // if (!icon.isEmpty() && !icon.isNull()) | 2436 | // if (!icon.isEmpty() && !icon.isNull()) |
2838 | if (icon != "predefined.png") | 2437 | if (icon != "predefined.png") |
2839 | { | 2438 | { |
2840 | // build the full path | 2439 | // build the full path |
2841 | fullIconPath = iconPath + icon; | 2440 | fullIconPath = iconPath + icon; |
2842 | pix = new QPixmap (fullIconPath); | 2441 | pix = new QPixmap (fullIconPath); |
2843 | // pix->resize(14, 14); | 2442 | // pix->resize(14, 14); |
2844 | if (!pix->isNull()) | 2443 | if (!pix->isNull()) |
2845 | { | 2444 | { |
2846 | // save the full pixmap name into the config file | 2445 | // save the full pixmap name into the config file |
2847 | // #ifndef Q_WS_WIN | 2446 | // #ifndef Q_WS_WIN |
2848 | conf->writeEntry(APP_KEY+category, icon); | 2447 | conf->writeEntry(APP_KEY+category, icon); |
2849 | // #endif | 2448 | // #endif |
2850 | saveConf(); | 2449 | saveConf(); |
2851 | QImage img = pix->convertToImage(); | 2450 | QImage img = pix->convertToImage(); |
2852 | pix->convertFromImage(img.smoothScale(14,14)); | 2451 | pix->convertFromImage(img.smoothScale(14,14)); |
2853 | c1->setIcon (*pix); | 2452 | c1->setIcon (*pix); |
2854 | c1->setIconName(icon); | 2453 | c1->setIconName(icon); |
2855 | } | 2454 | } |
2856 | else | 2455 | else |
2857 | { | 2456 | { |
2858 | QPixmap folder( ( const char** ) general_data ); | 2457 | QPixmap folder( ( const char** ) general_data ); |
2859 | c1->setIcon (folder); | 2458 | c1->setIcon (folder); |
2860 | } | 2459 | } |
2861 | } | 2460 | } |
2862 | else | 2461 | else |
2863 | { | 2462 | { |
2864 | c1->setIcon (*getPredefinedIcon(category)); | 2463 | c1->setIcon (*getPredefinedIcon(category)); |
2865 | } | 2464 | } |
2866 | 2465 | ||
2867 | c1->setListItem (li); | 2466 | c1->setListItem (li); |
2868 | c1->initListItem(); | 2467 | c1->initListItem(); |
2869 | categories.insert (c1->getCategoryName(), c1); | 2468 | categories.insert (c1->getCategoryName(), c1); |
2870 | 2469 | ||
2871 | saveCategoryDialogFields(dialog); | 2470 | saveCategoryDialogFields(dialog); |
2872 | } | 2471 | } |
2873 | else | 2472 | else |
2874 | { | 2473 | { |
2875 | // delete dialog; | 2474 | // delete dialog; |
2876 | dialog->hide(); | 2475 | dialog->hide(); |
2877 | return; | 2476 | return; |
2878 | } | 2477 | } |
2879 | 2478 | ||
2880 | } | 2479 | } |
2881 | 2480 | ||
2882 | } | 2481 | } |
2883 | 2482 | ||
2884 | void ZSafe::delCategory() | 2483 | void ZSafe::delCategory() |
2885 | { | 2484 | { |
2886 | if (!selectedItem) | 2485 | if (!selectedItem) |
2887 | return; | 2486 | return; |
2888 | if (isCategory(selectedItem)) | 2487 | if (isCategory(selectedItem)) |
2889 | { | 2488 | { |
2890 | switch( QMessageBox::information( this, tr("ZSafe"), | 2489 | switch( QMessageBox::information( this, tr("ZSafe"), |
2891 | tr("Do you want to delete?"), | 2490 | tr("Do you want to delete?"), |
2892 | tr("&Delete"), tr("D&on't Delete"), | 2491 | tr("&Delete"), tr("D&on't Delete"), |
2893 | 0 // Enter == button 0 | 2492 | 0 // Enter == button 0 |
2894 | ) ) { // Escape == button 2 | 2493 | ) ) { // Escape == button 2 |
2895 | case 0: // Delete clicked, Alt-S or Enter pressed. | 2494 | case 0: // Delete clicked, Alt-S or Enter pressed. |
2896 | // Delete from the category list | 2495 | // Delete from the category list |
2897 | modified = true; | 2496 | modified = true; |
2898 | categories.remove (selectedItem->text(0)); | 2497 | categories.remove (selectedItem->text(0)); |
2899 | // #ifndef Q_WS_WIN | 2498 | // #ifndef Q_WS_WIN |
2900 | conf->removeEntry (selectedItem->text(0)); | 2499 | conf->removeEntry (selectedItem->text(0)); |
2901 | // #endif | 2500 | // #endif |
2902 | saveConf(); | 2501 | saveConf(); |
2903 | 2502 | ||
2904 | // Delete the selected item and all subitems | 2503 | // Delete the selected item and all subitems |
2905 | // step through all subitems | 2504 | // step through all subitems |
2906 | QListViewItem *si; | 2505 | QListViewItem *si; |
2907 | for (si = selectedItem->firstChild(); | 2506 | for (si = selectedItem->firstChild(); |
2908 | si != NULL; ) | 2507 | si != NULL; ) |
2909 | { | 2508 | { |
2910 | QListViewItem *_si = si; | 2509 | QListViewItem *_si = si; |
2911 | si = si->nextSibling(); | 2510 | si = si->nextSibling(); |
2912 | selectedItem->takeItem(_si); // remove from view list | 2511 | selectedItem->takeItem(_si); // remove from view list |
2913 | if (_si) delete _si; | 2512 | if (_si) delete _si; |
2914 | } | 2513 | } |
2915 | ListView->takeItem(selectedItem); | 2514 | ListView->takeItem(selectedItem); |
2916 | delete selectedItem; | 2515 | delete selectedItem; |
2917 | 2516 | ||
2918 | selectedItem = NULL; | 2517 | selectedItem = NULL; |
2919 | break; | 2518 | break; |
2920 | case 1: // Don't delete | 2519 | case 1: // Don't delete |
2921 | break; | 2520 | break; |
2922 | } | 2521 | } |
2923 | 2522 | ||
2924 | } | 2523 | } |
2925 | } | 2524 | } |
2926 | 2525 | ||
2927 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) | 2526 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) |
2928 | { | 2527 | { |
2929 | if (!dialog) | 2528 | if (!dialog) |
2930 | return; | 2529 | return; |
2931 | 2530 | ||
2932 | QString icon; | 2531 | QString icon; |
2933 | if (selectedItem) | 2532 | if (selectedItem) |
2934 | { | 2533 | { |
2935 | dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 2534 | dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
2936 | dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 2535 | dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
2937 | dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 2536 | dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
2938 | dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 2537 | dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
2939 | dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); | 2538 | dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); |
2940 | dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); | 2539 | dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); |
2941 | 2540 | ||
2942 | Category *cat= categories.find (selectedItem->text(0)); | 2541 | Category *cat= categories.find (selectedItem->text(0)); |
2943 | if (cat) | 2542 | if (cat) |
2944 | { | 2543 | { |
2945 | icon = cat->getIconName(); | 2544 | icon = cat->getIconName(); |
2946 | } | 2545 | } |
2947 | else | 2546 | else |
2948 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); | 2547 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); |
2949 | } | 2548 | } |
2950 | else | 2549 | else |
2951 | { | 2550 | { |
2952 | dialog->Field1->setText(tr("Name")); | 2551 | dialog->Field1->setText(tr("Name")); |
2953 | dialog->Field2->setText(tr("Username")); | 2552 | dialog->Field2->setText(tr("Username")); |
2954 | dialog->Field3->setText(tr("Password")); | 2553 | dialog->Field3->setText(tr("Password")); |
2955 | dialog->Field4->setText(tr("Comment")); | 2554 | dialog->Field4->setText(tr("Comment")); |
2956 | dialog->Field5->setText(tr("Field 4")); | 2555 | dialog->Field5->setText(tr("Field 4")); |
2957 | dialog->Field6->setText(tr("Field 5")); | 2556 | dialog->Field6->setText(tr("Field 5")); |
2958 | } | 2557 | } |
2959 | 2558 | ||
2960 | #ifdef DESKTOP | ||
2961 | QDir d(iconPath); | ||
2962 | #else | ||
2963 | QDir d(QPEApplication::qpeDir() + "pics/"); | 2559 | QDir d(QPEApplication::qpeDir() + "pics/"); |
2964 | #endif | ||
2965 | d.setFilter( QDir::Files); | 2560 | d.setFilter( QDir::Files); |
2966 | 2561 | ||
2967 | const QFileInfoList *list = d.entryInfoList(); | 2562 | const QFileInfoList *list = d.entryInfoList(); |
2968 | int i=0; | 2563 | int i=0; |
2969 | QFileInfoListIterator it( *list ); // create list iterator | 2564 | QFileInfoListIterator it( *list ); // create list iterator |
2970 | QFileInfo *fi; // pointer for traversing | 2565 | QFileInfo *fi; // pointer for traversing |
2971 | if (icon.isEmpty() || icon.isNull()) | 2566 | if (icon.isEmpty() || icon.isNull()) |
2972 | { | 2567 | { |
2973 | dialog->IconField->setCurrentItem(0); | 2568 | dialog->IconField->setCurrentItem(0); |
2974 | } | 2569 | } |
2975 | else | 2570 | else |
2976 | { | 2571 | { |
2977 | while ( (fi=it.current()) ) | 2572 | while ( (fi=it.current()) ) |
2978 | { // for each file... | 2573 | { // for each file... |
2979 | QString fileName = fi->fileName(); | 2574 | QString fileName = fi->fileName(); |
2980 | if(fileName.right(4) == ".png") | 2575 | if(fileName.right(4) == ".png") |
2981 | { | 2576 | { |
2982 | fileName = fileName.mid(0,fileName.length()-4); | 2577 | fileName = fileName.mid(0,fileName.length()-4); |
2983 | 2578 | ||
2984 | if(fileName+".png"==icon) | 2579 | if(fileName+".png"==icon) |
2985 | { | 2580 | { |
2986 | dialog->IconField->setCurrentItem(i+1); | 2581 | dialog->IconField->setCurrentItem(i+1); |
2987 | break; | 2582 | break; |
2988 | } | 2583 | } |
2989 | ++i; | 2584 | ++i; |
2990 | } | 2585 | } |
2991 | ++it; | 2586 | ++it; |
2992 | } | 2587 | } |
2993 | } | 2588 | } |
2994 | } | 2589 | } |
2995 | 2590 | ||
2996 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) | 2591 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) |
2997 | { | 2592 | { |
2998 | if (!dialog) | 2593 | if (!dialog) |
2999 | return; | 2594 | return; |
3000 | 2595 | ||
3001 | dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); | 2596 | dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); |
3002 | dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); | 2597 | dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); |
3003 | dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); | 2598 | dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); |
3004 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); | 2599 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); |
3005 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); | 2600 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); |
3006 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); | 2601 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); |
3007 | 2602 | ||
3008 | QString icon; | 2603 | QString icon; |
3009 | Category *cat= categories.find (category); | 2604 | Category *cat= categories.find (category); |
3010 | if (cat) | 2605 | if (cat) |
3011 | { | 2606 | { |
3012 | icon = cat->getIconName(); | 2607 | icon = cat->getIconName(); |
3013 | } | 2608 | } |
3014 | else | 2609 | else |
3015 | icon = conf->readEntry(APP_KEY+category); | 2610 | icon = conf->readEntry(APP_KEY+category); |
3016 | 2611 | ||
3017 | #ifdef DESKTOP | ||
3018 | QDir d(iconPath); | ||
3019 | #else | ||
3020 | QDir d(QPEApplication::qpeDir() + "pics/"); | 2612 | QDir d(QPEApplication::qpeDir() + "pics/"); |
3021 | #endif | ||
3022 | d.setFilter( QDir::Files); | 2613 | d.setFilter( QDir::Files); |
3023 | 2614 | ||
3024 | const QFileInfoList *list = d.entryInfoList(); | 2615 | const QFileInfoList *list = d.entryInfoList(); |
3025 | int i=0; | 2616 | int i=0; |
3026 | QFileInfoListIterator it( *list ); // create list iterator | 2617 | QFileInfoListIterator it( *list ); // create list iterator |
3027 | QFileInfo *fi; // pointer for traversing | 2618 | QFileInfo *fi; // pointer for traversing |
3028 | if (icon.isEmpty() || icon.isNull()) | 2619 | if (icon.isEmpty() || icon.isNull()) |
3029 | { | 2620 | { |
3030 | dialog->IconField->setCurrentItem(0); | 2621 | dialog->IconField->setCurrentItem(0); |
3031 | } | 2622 | } |
3032 | else | 2623 | else |
3033 | { | 2624 | { |
3034 | while ( (fi=it.current()) ) | 2625 | while ( (fi=it.current()) ) |
3035 | { // for each file... | 2626 | { // for each file... |
3036 | QString fileName = fi->fileName(); | 2627 | QString fileName = fi->fileName(); |
3037 | if(fileName.right(4) == ".png") | 2628 | if(fileName.right(4) == ".png") |
3038 | { | 2629 | { |
3039 | fileName = fileName.mid(0,fileName.length()-4); | 2630 | fileName = fileName.mid(0,fileName.length()-4); |
3040 | 2631 | ||
3041 | if(fileName+".png"==icon) | 2632 | if(fileName+".png"==icon) |
3042 | { | 2633 | { |
3043 | dialog->IconField->setCurrentItem(i+1); | 2634 | dialog->IconField->setCurrentItem(i+1); |
3044 | break; | 2635 | break; |
3045 | } | 2636 | } |
3046 | ++i; | 2637 | ++i; |
3047 | } | 2638 | } |
3048 | ++it; | 2639 | ++it; |
3049 | } | 2640 | } |
3050 | } | 2641 | } |
3051 | } | 2642 | } |
3052 | 2643 | ||
3053 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) | 2644 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) |
3054 | { | 2645 | { |
3055 | QString app_key = APP_KEY; | 2646 | QString app_key = APP_KEY; |
3056 | #ifndef DESKTOP | 2647 | conf->setGroup( "fieldDefs" ); |
3057 | conf->setGroup ("fieldDefs"); | ||
3058 | #else | ||
3059 | #ifndef Q_WS_WIN | ||
3060 | app_key += "/fieldDefs/"; | ||
3061 | #endif | ||
3062 | #endif | ||
3063 | QString category = dialog->CategoryField->currentText(); | 2648 | QString category = dialog->CategoryField->currentText(); |
3064 | // #ifndef Q_WS_WIN | 2649 | // #ifndef Q_WS_WIN |
3065 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); | 2650 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); |
3066 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); | 2651 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); |
3067 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); | 2652 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); |
3068 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); | 2653 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); |
3069 | conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); | 2654 | conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); |
3070 | conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); | 2655 | conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); |
3071 | // #endif | 2656 | // #endif |
3072 | saveConf(); | 2657 | saveConf(); |
3073 | #ifndef DESKTOP | ||
3074 | conf->setGroup ("zsafe"); | 2658 | conf->setGroup ("zsafe"); |
3075 | #endif | ||
3076 | } | 2659 | } |
3077 | 2660 | ||
3078 | void ZSafe::editCategory() | 2661 | void ZSafe::editCategory() |
3079 | { | 2662 | { |
3080 | if (!selectedItem) | 2663 | if (!selectedItem) |
3081 | return; | 2664 | return; |
3082 | if (isCategory(selectedItem)) | 2665 | if (isCategory(selectedItem)) |
3083 | { | 2666 | { |
3084 | QString category = selectedItem->text(0); | 2667 | QString category = selectedItem->text(0); |
3085 | bool initIcons = false; | 2668 | bool initIcons = false; |
3086 | // open the 'Category' dialog | 2669 | // open the 'Category' dialog |
3087 | CategoryDialog *dialog; | 2670 | CategoryDialog *dialog; |
3088 | if (categoryDialog) | 2671 | if (categoryDialog) |
3089 | { | 2672 | { |
3090 | dialog = categoryDialog; | 2673 | dialog = categoryDialog; |
3091 | } | 2674 | } |
3092 | else | 2675 | else |
3093 | { | 2676 | { |
3094 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2677 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
3095 | #ifdef Q_WS_WIN | ||
3096 | categoryDialog->setCaption ("Qt " + tr("Category")); | ||
3097 | #endif | ||
3098 | dialog = categoryDialog; | 2678 | dialog = categoryDialog; |
3099 | connect( dialog->CategoryField, | 2679 | connect( dialog->CategoryField, |
3100 | SIGNAL( activated(const QString&)), | 2680 | SIGNAL( activated(const QString&)), |
3101 | this, SLOT( categoryFieldActivated(const QString&) ) ); | 2681 | this, SLOT( categoryFieldActivated(const QString&) ) ); |
3102 | initIcons = true; | 2682 | initIcons = true; |
3103 | } | 2683 | } |
3104 | setCategoryDialogFields(dialog); | 2684 | setCategoryDialogFields(dialog); |
3105 | 2685 | ||
3106 | #ifdef DESKTOP | ||
3107 | #ifndef Q_WS_WIN | ||
3108 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | ||
3109 | #else | ||
3110 | // read all categories from the config file and store | ||
3111 | // into a list | ||
3112 | QFile f (cfgFile); | ||
3113 | QStringList list; | ||
3114 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | ||
3115 | QTextStream t( &f ); // use a text stream | ||
3116 | QString s; | ||
3117 | int n = 1; | ||
3118 | while ( !t.eof() ) { // until end of file... | ||
3119 | s = t.readLine(); // line of text excluding '\n' | ||
3120 | list.append(s); | ||
3121 | } | ||
3122 | f.close(); | ||
3123 | } | ||
3124 | #endif | ||
3125 | #else | ||
3126 | // read all categories from the config file and store | 2686 | // read all categories from the config file and store |
3127 | // into a list | 2687 | // into a list |
3128 | QFile f (cfgFile); | 2688 | QFile f (cfgFile); |
3129 | QStringList list; | 2689 | QStringList list; |
3130 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2690 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
3131 | QTextStream t( &f ); // use a text stream | 2691 | QTextStream t( &f ); // use a text stream |
3132 | QString s; | 2692 | QString s; |
3133 | while ( !t.eof() ) { // until end of file... | 2693 | while ( !t.eof() ) { // until end of file... |
3134 | s = t.readLine(); // line of text excluding '\n' | 2694 | s = t.readLine(); // line of text excluding '\n' |
3135 | list.append(s); | 2695 | list.append(s); |
3136 | } | 2696 | } |
3137 | f.close(); | 2697 | f.close(); |
3138 | } | 2698 | } |
3139 | #endif | ||
3140 | QStringList::Iterator it = list.begin(); | 2699 | QStringList::Iterator it = list.begin(); |
3141 | QString categ; | 2700 | QString categ; |
3142 | dialog->CategoryField->clear(); // remove all items | 2701 | dialog->CategoryField->clear(); // remove all items |
3143 | int i=0; | 2702 | int i=0; |
3144 | bool foundCategory = false; | 2703 | bool foundCategory = false; |
3145 | while( it != list.end() ) | 2704 | while( it != list.end() ) |
3146 | { | 2705 | { |
3147 | QString *cat = new QString (*it); | 2706 | QString *cat = new QString (*it); |
3148 | if (cat->contains("-field1", FALSE)) | 2707 | if (cat->contains("-field1", FALSE)) |
3149 | { | 2708 | { |
3150 | #ifdef DESKTOP | ||
3151 | #ifndef Q_WS_WIN | ||
3152 | categ = cat->section ("-field1", 0, 0); | ||
3153 | #else | ||
3154 | int pos = cat->find ("-field1"); | ||
3155 | categ = cat->left (pos); | ||
3156 | #endif | ||
3157 | #else | ||
3158 | int pos = cat->find ("-field1"); | 2709 | int pos = cat->find ("-field1"); |
3159 | cat->truncate(pos); | 2710 | cat->truncate(pos); |
3160 | categ = *cat; | 2711 | categ = *cat; |
3161 | #endif | ||
3162 | if (!categ.isEmpty()) | 2712 | if (!categ.isEmpty()) |
3163 | { | 2713 | { |
3164 | dialog->CategoryField->insertItem (categ, i); | 2714 | dialog->CategoryField->insertItem (categ, i); |
3165 | if (category.compare(categ) == 0) | 2715 | if (category.compare(categ) == 0) |
3166 | { | 2716 | { |
3167 | dialog->CategoryField->setCurrentItem(i); | 2717 | dialog->CategoryField->setCurrentItem(i); |
3168 | foundCategory = true; | 2718 | foundCategory = true; |
3169 | } | 2719 | } |
3170 | i++; | 2720 | i++; |
3171 | } | 2721 | } |
3172 | } | 2722 | } |
3173 | ++it; | 2723 | ++it; |
3174 | } | 2724 | } |
3175 | if (!foundCategory) | 2725 | if (!foundCategory) |
3176 | { | 2726 | { |
3177 | dialog->CategoryField->insertItem (category, i); | 2727 | dialog->CategoryField->insertItem (category, i); |
3178 | dialog->CategoryField->setCurrentItem(i); | 2728 | dialog->CategoryField->setCurrentItem(i); |
3179 | } | 2729 | } |
3180 | 2730 | ||
3181 | QString icon; | 2731 | QString icon; |
3182 | Category *cat= categories.find (selectedItem->text(0)); | 2732 | Category *cat= categories.find (selectedItem->text(0)); |
3183 | if (cat) | 2733 | if (cat) |
3184 | { | 2734 | { |
3185 | icon = cat->getIconName(); | 2735 | icon = cat->getIconName(); |
3186 | } | 2736 | } |
3187 | 2737 | ||
3188 | if (initIcons) | 2738 | if (initIcons) |
3189 | { | 2739 | { |
3190 | 2740 | ||
3191 | Wait waitDialog(this, tr("Wait dialog")); | 2741 | Wait waitDialog(this, tr("Wait dialog")); |
3192 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 2742 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
3193 | waitDialog.show(); | 2743 | waitDialog.show(); |
3194 | qApp->processEvents(); | 2744 | qApp->processEvents(); |
3195 | 2745 | ||
3196 | #ifdef DESKTOP | ||
3197 | QDir d(iconPath); | ||
3198 | #else | ||
3199 | QDir d(QPEApplication::qpeDir() + "pics/"); | 2746 | QDir d(QPEApplication::qpeDir() + "pics/"); |
3200 | #endif | ||
3201 | d.setFilter( QDir::Files); | 2747 | d.setFilter( QDir::Files); |
3202 | 2748 | ||
3203 | const QFileInfoList *list = d.entryInfoList(); | 2749 | const QFileInfoList *list = d.entryInfoList(); |
3204 | int i=0; | 2750 | int i=0; |
3205 | QFileInfoListIterator it( *list ); // create list iterator | 2751 | QFileInfoListIterator it( *list ); // create list iterator |
3206 | QFileInfo *fi; // pointer for traversing | 2752 | QFileInfo *fi; // pointer for traversing |
3207 | if (icon.isEmpty() || icon.isNull()) | 2753 | if (icon.isEmpty() || icon.isNull()) |
3208 | { | 2754 | { |
3209 | dialog->IconField->setCurrentItem(0); | 2755 | dialog->IconField->setCurrentItem(0); |
3210 | } | 2756 | } |
3211 | 2757 | ||
3212 | dialog->IconField->insertItem("predefined"); | 2758 | dialog->IconField->insertItem("predefined"); |
3213 | while ( (fi=it.current()) ) { // for each file... | 2759 | while ( (fi=it.current()) ) { // for each file... |
3214 | QString fileName = fi->fileName(); | 2760 | QString fileName = fi->fileName(); |
3215 | if(fileName.right(4) == ".png") | 2761 | if(fileName.right(4) == ".png") |
3216 | { | 2762 | { |
3217 | fileName = fileName.mid(0,fileName.length()-4); | 2763 | fileName = fileName.mid(0,fileName.length()-4); |
3218 | #ifdef DESKTOP | ||
3219 | QPixmap imageOfFile; | ||
3220 | imageOfFile.load(iconPath + fi->fileName()); | ||
3221 | #else | ||
3222 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 2764 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
3223 | #endif | ||
3224 | QImage foo = imageOfFile.convertToImage(); | 2765 | QImage foo = imageOfFile.convertToImage(); |
3225 | foo = foo.smoothScale(16,16); | 2766 | foo = foo.smoothScale(16,16); |
3226 | imageOfFile.convertFromImage(foo); | 2767 | imageOfFile.convertFromImage(foo); |
3227 | dialog->IconField->insertItem(imageOfFile,fileName); | 2768 | dialog->IconField->insertItem(imageOfFile,fileName); |
3228 | if(fileName+".png"==icon) | 2769 | if(fileName+".png"==icon) |
3229 | dialog->IconField->setCurrentItem(i+1); | 2770 | dialog->IconField->setCurrentItem(i+1); |
3230 | ++i; | 2771 | ++i; |
3231 | } | 2772 | } |
3232 | ++it; | 2773 | ++it; |
3233 | } | 2774 | } |
3234 | waitDialog.hide(); | 2775 | waitDialog.hide(); |
3235 | } | 2776 | } |
3236 | else | 2777 | else |
3237 | { | 2778 | { |
3238 | #ifdef DESKTOP | ||
3239 | // QDir d(QDir::homeDirPath() + "/pics/"); | ||
3240 | QDir d(iconPath); | ||
3241 | #else | ||
3242 | QDir d(QPEApplication::qpeDir() + "pics/"); | 2779 | QDir d(QPEApplication::qpeDir() + "pics/"); |
3243 | #endif | ||
3244 | d.setFilter( QDir::Files); | 2780 | d.setFilter( QDir::Files); |
3245 | 2781 | ||
3246 | const QFileInfoList *list = d.entryInfoList(); | 2782 | const QFileInfoList *list = d.entryInfoList(); |
3247 | int i=0; | 2783 | int i=0; |
3248 | QFileInfoListIterator it( *list ); // create list iterator | 2784 | QFileInfoListIterator it( *list ); // create list iterator |
3249 | QFileInfo *fi; // pointer for traversing | 2785 | QFileInfo *fi; // pointer for traversing |
3250 | if (icon.isEmpty() || icon.isNull()) | 2786 | if (icon.isEmpty() || icon.isNull()) |
3251 | { | 2787 | { |
3252 | dialog->IconField->setCurrentItem(0); | 2788 | dialog->IconField->setCurrentItem(0); |
3253 | } | 2789 | } |
3254 | else | 2790 | else |
3255 | { | 2791 | { |
3256 | 2792 | ||
3257 | while ( (fi=it.current()) ) | 2793 | while ( (fi=it.current()) ) |
3258 | { // for each file... | 2794 | { // for each file... |
3259 | QString fileName = fi->fileName(); | 2795 | QString fileName = fi->fileName(); |
3260 | if(fileName.right(4) == ".png") | 2796 | if(fileName.right(4) == ".png") |
3261 | { | 2797 | { |
3262 | fileName = fileName.mid(0,fileName.length()-4); | 2798 | fileName = fileName.mid(0,fileName.length()-4); |
3263 | 2799 | ||
3264 | 2800 | ||
3265 | if(fileName+".png"==icon) | 2801 | if(fileName+".png"==icon) |
3266 | { | 2802 | { |
3267 | dialog->IconField->setCurrentItem(i+1); | 2803 | dialog->IconField->setCurrentItem(i+1); |
3268 | break; | 2804 | break; |
3269 | } | 2805 | } |
3270 | ++i; | 2806 | ++i; |
3271 | } | 2807 | } |
3272 | ++it; | 2808 | ++it; |
3273 | } | 2809 | } |
3274 | } | 2810 | } |
3275 | } | 2811 | } |
3276 | 2812 | ||
3277 | // dialog->show(); | 2813 | // dialog->show(); |
3278 | #ifndef DESKTOP | 2814 | QDialog::DialogCode result = (QDialog::DialogCode) dialog->exec(); |
3279 | // dialog->move (20, 100); | ||
3280 | #endif | ||
3281 | DialogCode result = (DialogCode) dialog->exec(); | ||
3282 | #ifdef DESKTOP | ||
3283 | result = Accepted; | ||
3284 | #endif | ||
3285 | 2815 | ||
3286 | QString fullIconPath; | 2816 | QString fullIconPath; |
3287 | QPixmap *pix; | 2817 | QPixmap *pix; |
3288 | if (result == Accepted) | 2818 | if (result == QDialog::Accepted) |
3289 | { | 2819 | { |
3290 | modified = true; | 2820 | modified = true; |
3291 | if (category != dialog->CategoryField->currentText()) | 2821 | if (category != dialog->CategoryField->currentText()) |
3292 | { | 2822 | { |
3293 | categories.remove (category); | 2823 | categories.remove (category); |
3294 | // #ifndef Q_WS_WIN | 2824 | // #ifndef Q_WS_WIN |
3295 | conf->removeEntry(category); | 2825 | conf->removeEntry(category); |
3296 | // #endif | 2826 | // #endif |
3297 | saveConf(); | 2827 | saveConf(); |
3298 | } | 2828 | } |
3299 | 2829 | ||
3300 | category = dialog->CategoryField->currentText(); | 2830 | category = dialog->CategoryField->currentText(); |
3301 | icon = dialog->IconField->currentText()+".png"; | 2831 | icon = dialog->IconField->currentText()+".png"; |
3302 | 2832 | ||
3303 | if (cat) | 2833 | if (cat) |
3304 | { | 2834 | { |
3305 | #ifndef NO_OPIE | ||
3306 | owarn << "Category found" << oendl; | ||
3307 | #else | ||
3308 | qWarning("Category found"); | ||
3309 | #endif | ||
3310 | |||
3311 | // if (!icon.isEmpty() && !icon.isNull()) | 2835 | // if (!icon.isEmpty() && !icon.isNull()) |
3312 | if (icon != "predefined.png") | 2836 | if (icon != "predefined.png") |
3313 | { | 2837 | { |
3314 | // build the full path | 2838 | // build the full path |
3315 | fullIconPath = iconPath + icon; | 2839 | fullIconPath = iconPath + icon; |
3316 | pix = new QPixmap (fullIconPath); | 2840 | pix = new QPixmap (fullIconPath); |
3317 | if (!pix->isNull()) | 2841 | if (!pix->isNull()) |
3318 | { | 2842 | { |
3319 | // save the full pixmap name into the config file | 2843 | // save the full pixmap name into the config file |
3320 | // #ifndef Q_WS_WIN | 2844 | // #ifndef Q_WS_WIN |
3321 | conf->writeEntry(APP_KEY+category, icon); | 2845 | conf->writeEntry(APP_KEY+category, icon); |
3322 | // #endif | 2846 | // #endif |
3323 | saveConf(); | 2847 | saveConf(); |
3324 | QImage img = pix->convertToImage(); | 2848 | QImage img = pix->convertToImage(); |
3325 | pix->convertFromImage(img.smoothScale(14,14)); | 2849 | pix->convertFromImage(img.smoothScale(14,14)); |
3326 | cat->setIconName (icon); | 2850 | cat->setIconName (icon); |
3327 | cat->setIcon (*pix); | 2851 | cat->setIcon (*pix); |
3328 | } | 2852 | } |
3329 | } | 2853 | } |
3330 | else | 2854 | else |
3331 | { | 2855 | { |
3332 | // #ifndef Q_WS_WIN | 2856 | // #ifndef Q_WS_WIN |
3333 | conf->removeEntry (category); | 2857 | conf->removeEntry (category); |
3334 | // #endif | 2858 | // #endif |
3335 | saveConf(); | 2859 | saveConf(); |
3336 | cat->setIcon (*getPredefinedIcon(category)); | 2860 | cat->setIcon (*getPredefinedIcon(category)); |
3337 | } | 2861 | } |
3338 | 2862 | ||
3339 | // change the category name of the selected category | 2863 | // change the category name of the selected category |
3340 | QListViewItem *catItem = cat->getListItem(); | 2864 | QListViewItem *catItem = cat->getListItem(); |
3341 | if (catItem) | 2865 | if (catItem) |
3342 | { | 2866 | { |
3343 | #ifndef NO_OPIE | ||
3344 | owarn << category << oendl; | ||
3345 | #else | ||
3346 | qWarning (category); | ||
3347 | #endif | ||
3348 | catItem->setText( 0, tr( category ) ); | 2867 | catItem->setText( 0, tr( category ) ); |
3349 | cat->setCategoryName (tr(category)); | 2868 | cat->setCategoryName (tr(category)); |
3350 | 2869 | ||
3351 | cat->initListItem(); | 2870 | cat->initListItem(); |
3352 | categories.insert (category, cat); | 2871 | categories.insert (category, cat); |
3353 | } | 2872 | } |
3354 | } | 2873 | } |
3355 | saveCategoryDialogFields(dialog); | 2874 | saveCategoryDialogFields(dialog); |
3356 | } | 2875 | } |
3357 | else | 2876 | else |
3358 | { | 2877 | { |
3359 | // delete dialog; | 2878 | // delete dialog; |
3360 | dialog->hide(); | 2879 | dialog->hide(); |
3361 | return; | 2880 | return; |
3362 | } | 2881 | } |
3363 | 2882 | ||
3364 | } | 2883 | } |
3365 | } | 2884 | } |
3366 | 2885 | ||
3367 | void ZSafe::cutItem() | 2886 | void ZSafe::cutItem() |
3368 | { | 2887 | { |
3369 | if (!selectedItem) | 2888 | if (!selectedItem) |
3370 | return; | 2889 | return; |
3371 | if (!isCategory(selectedItem)) | 2890 | if (!isCategory(selectedItem)) |
3372 | { | 2891 | { |
3373 | IsCut = true; | 2892 | IsCut = true; |
3374 | copiedItem = selectedItem; | 2893 | copiedItem = selectedItem; |
3375 | } | 2894 | } |
3376 | } | 2895 | } |
3377 | 2896 | ||
3378 | void ZSafe::copyItem() | 2897 | void ZSafe::copyItem() |
3379 | { | 2898 | { |
3380 | if (!selectedItem) | 2899 | if (!selectedItem) |
3381 | return; | 2900 | return; |
3382 | if (!isCategory(selectedItem)) | 2901 | if (!isCategory(selectedItem)) |
3383 | { | 2902 | { |
3384 | IsCopy = true; | 2903 | IsCopy = true; |
3385 | copiedItem = selectedItem; | 2904 | copiedItem = selectedItem; |
3386 | } | 2905 | } |
3387 | } | 2906 | } |
3388 | 2907 | ||
3389 | // paste item into category | 2908 | // paste item into category |
3390 | void ZSafe::pasteItem() | 2909 | void ZSafe::pasteItem() |
3391 | { | 2910 | { |
3392 | if (!selectedItem) | 2911 | if (!selectedItem) |
3393 | return; | 2912 | return; |
3394 | if (isCategory(selectedItem)) | 2913 | if (isCategory(selectedItem)) |
3395 | { | 2914 | { |
3396 | modified = true; | 2915 | modified = true; |
3397 | if (IsCut) | 2916 | if (IsCut) |
3398 | { | 2917 | { |
3399 | if (copiedItem) | 2918 | if (copiedItem) |
3400 | { | 2919 | { |
3401 | // add the new item | 2920 | // add the new item |
3402 | QListViewItem *i = new ShadedListItem (0, selectedItem); | 2921 | QListViewItem *i = new ShadedListItem (0, selectedItem); |
3403 | // i->setOpen (TRUE); | 2922 | // i->setOpen (TRUE); |
3404 | i->setText (0, copiedItem->text(0)); | 2923 | i->setText (0, copiedItem->text(0)); |
3405 | i->setText (1, copiedItem->text(1)); | 2924 | i->setText (1, copiedItem->text(1)); |
3406 | i->setText (2, copiedItem->text(2)); | 2925 | i->setText (2, copiedItem->text(2)); |
3407 | i->setText (3, copiedItem->text(3)); | 2926 | i->setText (3, copiedItem->text(3)); |
3408 | i->setText (4, copiedItem->text(4)); | 2927 | i->setText (4, copiedItem->text(4)); |
3409 | i->setText (5, copiedItem->text(5)); | 2928 | i->setText (5, copiedItem->text(5)); |
3410 | selectedItem->setOpen( TRUE ); | 2929 | selectedItem->setOpen( TRUE ); |
3411 | 2930 | ||
3412 | // remove the cutted item | 2931 | // remove the cutted item |
3413 | copiedItem->parent()->takeItem(copiedItem); | 2932 | copiedItem->parent()->takeItem(copiedItem); |
3414 | selectedItem = NULL; | 2933 | selectedItem = NULL; |
3415 | } | 2934 | } |
3416 | } | 2935 | } |
3417 | else if (IsCopy) | 2936 | else if (IsCopy) |
3418 | { | 2937 | { |
3419 | if (copiedItem) | 2938 | if (copiedItem) |
3420 | { | 2939 | { |
3421 | // add the new item | 2940 | // add the new item |
3422 | QListViewItem *i = new ShadedListItem (0, selectedItem); | 2941 | QListViewItem *i = new ShadedListItem (0, selectedItem); |
3423 | // i->setOpen (TRUE); | 2942 | // i->setOpen (TRUE); |
3424 | i->setText (0, copiedItem->text(0)); | 2943 | i->setText (0, copiedItem->text(0)); |
3425 | i->setText (1, copiedItem->text(1)); | 2944 | i->setText (1, copiedItem->text(1)); |
3426 | i->setText (2, copiedItem->text(2)); | 2945 | i->setText (2, copiedItem->text(2)); |
3427 | i->setText (3, copiedItem->text(3)); | 2946 | i->setText (3, copiedItem->text(3)); |
3428 | i->setText (4, copiedItem->text(4)); | 2947 | i->setText (4, copiedItem->text(4)); |
3429 | i->setText (5, copiedItem->text(5)); | 2948 | i->setText (5, copiedItem->text(5)); |
3430 | selectedItem->setOpen( TRUE ); | 2949 | selectedItem->setOpen( TRUE ); |
3431 | } | 2950 | } |
3432 | } | 2951 | } |
3433 | } | 2952 | } |
3434 | IsCut = false; | 2953 | IsCut = false; |
3435 | IsCopy = false; | 2954 | IsCopy = false; |
3436 | } | 2955 | } |
3437 | 2956 | ||
3438 | void ZSafe::newDocument() | 2957 | void ZSafe::newDocument() |
3439 | { | 2958 | { |
3440 | 2959 | ||
3441 | // open the file dialog | 2960 | // open the file dialog |
3442 | QString newFile = zsaveDialog(); | 2961 | QString newFile = zsaveDialog(); |
3443 | 2962 | ||
3444 | // open the new document | 2963 | // open the new document |
3445 | if (newFile && newFile.length() > 0 ) | 2964 | if (newFile && newFile.length() > 0 ) |
3446 | { | 2965 | { |
3447 | // save the previous opened document | 2966 | // save the previous opened document |
3448 | if (!filename.isEmpty()) | 2967 | if (!filename.isEmpty()) |
3449 | saveDocument(filename, FALSE); | 2968 | saveDocument(filename, FALSE); |
3450 | 2969 | ||
3451 | modified = true; | 2970 | modified = true; |
3452 | 2971 | ||
3453 | // clear the password list | 2972 | // clear the password list |
3454 | QListViewItem *i; | 2973 | QListViewItem *i; |
3455 | QListViewItem *c = NULL; | 2974 | QListViewItem *c = NULL; |
3456 | // step through all categories | 2975 | // step through all categories |
3457 | for (i = ListView->firstChild(); | 2976 | for (i = ListView->firstChild(); |
3458 | i != NULL; | 2977 | i != NULL; |
3459 | i = i->nextSibling()) | 2978 | i = i->nextSibling()) |
3460 | { | 2979 | { |
3461 | if (c) delete c; // delete the previous category | 2980 | if (c) delete c; // delete the previous category |
3462 | 2981 | ||
3463 | c = i; | 2982 | c = i; |
3464 | // step through all subitems | 2983 | // step through all subitems |
3465 | QListViewItem *si; | 2984 | QListViewItem *si; |
3466 | for (si = i->firstChild(); | 2985 | for (si = i->firstChild(); |
3467 | si != NULL; ) | 2986 | si != NULL; ) |
3468 | { | 2987 | { |
3469 | QListViewItem *_si = si; | 2988 | QListViewItem *_si = si; |
3470 | si = si->nextSibling(); | 2989 | si = si->nextSibling(); |
3471 | i->takeItem(_si); // remove from view list | 2990 | i->takeItem(_si); // remove from view list |
3472 | if (_si) delete _si; | 2991 | if (_si) delete _si; |
3473 | } | 2992 | } |
3474 | } | 2993 | } |
3475 | if (c) delete c; // delete the previous category | 2994 | if (c) delete c; // delete the previous category |
3476 | categories.clear(); | 2995 | categories.clear(); |
3477 | 2996 | ||
3478 | // m_password = ""; | 2997 | // m_password = ""; |
3479 | selectedItem = NULL; | 2998 | selectedItem = NULL; |
3480 | 2999 | ||
3481 | filename = newFile; | 3000 | filename = newFile; |
3482 | 3001 | ||
3483 | // save the current filename to the config file | 3002 | // save the current filename to the config file |
3003 | conf->setGroup("zsafe"); | ||
3484 | conf->writeEntry(APP_KEY+"document", filename); | 3004 | conf->writeEntry(APP_KEY+"document", filename); |
3485 | saveConf(); | 3005 | saveConf(); |
3486 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3006 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3487 | #ifdef Q_WS_WIN | 3007 | this->setCaption(tr("ZSafe: ") + ti); |
3488 | this->setCaption("Qt ZSafe: " + ti); | ||
3489 | #else | ||
3490 | this->setCaption("ZSafe: " + ti); | ||
3491 | #endif | ||
3492 | 3008 | ||
3493 | // openDocument(filename); | 3009 | // openDocument(filename); |
3494 | 3010 | ||
3495 | QMessageBox::information( this, tr("ZSafe"), | 3011 | QMessageBox::information( this, tr("ZSafe"), |
3496 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); | 3012 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); |
3497 | 3013 | ||
3498 | saveDocumentWithPwd(); | 3014 | saveDocumentWithPwd(); |
3499 | } | 3015 | } |
3500 | } | 3016 | } |
3501 | 3017 | ||
3502 | void ZSafe::loadDocument() | 3018 | void ZSafe::loadDocument() |
3503 | { | 3019 | { |
3504 | 3020 | ||
3505 | // open the file dialog | 3021 | // open the file dialog |
3506 | #ifndef DESKTOP | ||
3507 | #ifndef NO_OPIE | ||
3508 | QMap<QString, QStringList> mimeTypes; | 3022 | QMap<QString, QStringList> mimeTypes; |
3509 | mimeTypes.insert(tr("All"), QStringList() ); | 3023 | mimeTypes.insert(tr("All"), QStringList() ); |
3510 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); | 3024 | mimeTypes.insert(tr("ZSafe"), "zsafe/*" ); |
3511 | QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 3025 | QString newFile = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
3512 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3026 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3513 | QString::null, | 3027 | QString::null, |
3514 | mimeTypes, | 3028 | mimeTypes, |
3515 | this, | 3029 | this, |
3516 | tr ("Open ZSafe document")); | 3030 | tr ("Open ZSafe document")); |
3517 | #else | ||
3518 | QString newFile = ScQtFileEdit::getOpenFileName(this, | ||
3519 | tr ("Open ZSafe document"), | ||
3520 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
3521 | "*.zsf"); | ||
3522 | #endif | ||
3523 | #else | ||
3524 | QString newFile = QFileDialog::getOpenFileName( | ||
3525 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
3526 | "ZSafe (*.zsf)", | ||
3527 | this, | ||
3528 | "ZSafe File Dialog" | ||
3529 | "Choose a ZSafe file" ); | ||
3530 | #endif | ||
3531 | 3031 | ||
3532 | // open the new document | 3032 | // open the new document |
3533 | if (newFile && newFile.length() > 0 ) | 3033 | if (newFile && newFile.length() > 0 ) |
3534 | { | 3034 | { |
3535 | // save the previous opened document | 3035 | // save the previous opened document |
3536 | if (!filename.isEmpty()) | 3036 | if (!filename.isEmpty()) |
3537 | saveDocument(filename, FALSE); | 3037 | saveDocument(filename, FALSE); |
3538 | 3038 | ||
3539 | // clear the password list | 3039 | // clear the password list |
3540 | QListViewItem *i; | 3040 | QListViewItem *i; |
3541 | QListViewItem *c = NULL; | 3041 | QListViewItem *c = NULL; |
3542 | // step through all categories | 3042 | // step through all categories |
3543 | for (i = ListView->firstChild(); | 3043 | for (i = ListView->firstChild(); |
3544 | i != NULL; | 3044 | i != NULL; |
3545 | i = i->nextSibling()) | 3045 | i = i->nextSibling()) |
3546 | { | 3046 | { |
3547 | if (c) delete c; // delete the previous category | 3047 | if (c) delete c; // delete the previous category |
3548 | 3048 | ||
3549 | c = i; | 3049 | c = i; |
3550 | // step through all subitems | 3050 | // step through all subitems |
3551 | QListViewItem *si; | 3051 | QListViewItem *si; |
3552 | for (si = i->firstChild(); | 3052 | for (si = i->firstChild(); |
3553 | si != NULL; ) | 3053 | si != NULL; ) |
3554 | { | 3054 | { |
3555 | QListViewItem *_si = si; | 3055 | QListViewItem *_si = si; |
3556 | si = si->nextSibling(); | 3056 | si = si->nextSibling(); |
3557 | i->takeItem(_si); // remove from view list | 3057 | i->takeItem(_si); // remove from view list |
3558 | if (_si) delete _si; | 3058 | if (_si) delete _si; |
3559 | } | 3059 | } |
3560 | } | 3060 | } |
3561 | if (c) delete c; // delete the previous category | 3061 | if (c) delete c; // delete the previous category |
3562 | categories.clear(); | 3062 | categories.clear(); |
3563 | m_password = ""; | 3063 | m_password = ""; |
3564 | selectedItem = NULL; | 3064 | selectedItem = NULL; |
3565 | filename = newFile; | 3065 | filename = newFile; |
3566 | 3066 | ||
3567 | // save the current filename to the config file | 3067 | // save the current filename to the config file |
3068 | conf->setGroup("zsafe"); | ||
3568 | conf->writeEntry(APP_KEY+"document", filename); | 3069 | conf->writeEntry(APP_KEY+"document", filename); |
3569 | saveConf(); | 3070 | saveConf(); |
3570 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3071 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3571 | #ifdef Q_WS_WIN | 3072 | this->setCaption(tr("ZSafe: ") + ti); |
3572 | this->setCaption("Qt ZSafe: " + ti); | ||
3573 | #else | ||
3574 | this->setCaption("ZSafe: " + ti); | ||
3575 | #endif | ||
3576 | 3073 | ||
3577 | openDocument(filename); | 3074 | openDocument(filename); |
3578 | } | 3075 | } |
3579 | } | 3076 | } |
3580 | 3077 | ||
3581 | void ZSafe::saveDocumentAs() | 3078 | void ZSafe::saveDocumentAs() |
3582 | { | 3079 | { |
3583 | 3080 | ||
3584 | QString newFile = zsaveDialog(); | 3081 | QString newFile = zsaveDialog(); |
3585 | // open the new document | 3082 | // open the new document |
3586 | if (newFile && newFile.length() > 0 ) | 3083 | if (newFile && newFile.length() > 0 ) |
3587 | { | 3084 | { |
3588 | // save the previous opened document | 3085 | // save the previous opened document |
3589 | if (!filename.isEmpty()) | 3086 | if (!filename.isEmpty()) |
3590 | saveDocument(filename, FALSE); | 3087 | saveDocument(filename, FALSE); |
3591 | 3088 | ||
3592 | selectedItem = NULL; | 3089 | selectedItem = NULL; |
3593 | filename = newFile; | 3090 | filename = newFile; |
3594 | 3091 | ||
3595 | // save the current filename to the config file | 3092 | // save the current filename to the config file |
3093 | conf->setGroup("zsafe"); | ||
3596 | conf->writeEntry(APP_KEY+"document", filename); | 3094 | conf->writeEntry(APP_KEY+"document", filename); |
3597 | saveConf(); | 3095 | saveConf(); |
3598 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3096 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3599 | #ifdef Q_WS_WIN | 3097 | this->setCaption(tr("ZSafe: ") + ti); |
3600 | this->setCaption("Qt ZSafe: " + ti); | ||
3601 | #else | ||
3602 | this->setCaption("ZSafe: " + ti); | ||
3603 | #endif | ||
3604 | 3098 | ||
3605 | QMessageBox::information( this, tr("ZSafe"), | 3099 | QMessageBox::information( this, tr("ZSafe"), |
3606 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); | 3100 | tr("Now you have to enter\na password twice for your\nnewly created document."), tr("&OK"), 0); |
3607 | 3101 | ||
3608 | saveDocumentWithPwd(); | 3102 | saveDocumentWithPwd(); |
3609 | } | 3103 | } |
3610 | } | 3104 | } |
3611 | 3105 | ||
3612 | void ZSafe::saveDocumentWithoutPwd() | 3106 | void ZSafe::saveDocumentWithoutPwd() |
3613 | { | 3107 | { |
3614 | saveDocument(filename, FALSE); | 3108 | saveDocument(filename, FALSE); |
3615 | } | 3109 | } |
3616 | 3110 | ||
3617 | void ZSafe::saveDocumentWithPwd() | 3111 | void ZSafe::saveDocumentWithPwd() |
3618 | { | 3112 | { |
3619 | saveDocument(filename, TRUE); | 3113 | saveDocument(filename, TRUE); |
3620 | } | 3114 | } |
3621 | 3115 | ||
3622 | void ZSafe::about() | 3116 | void ZSafe::about() |
3623 | { | 3117 | { |
3624 | QString info; | 3118 | QString info; |
3625 | #ifdef JPATCH_HDE | 3119 | info = tr("<html><body><div align=""center"">" |
3626 | info = "<html><body><div align=""center"">"; | 3120 | "<b>" |
3627 | info += "<b>"; | 3121 | "Zaurus Password Manager<br>" |
3628 | info += tr("Zaurus Password Manager<br>"); | 3122 | "ZSafe version 2.1.2<br>" |
3629 | info += tr("ZSafe version 2.1.2-jv01b<br>"); | 3123 | "</b>" |
3630 | info += "</b>"; | 3124 | "by Carsten Schneider<br>" |
3631 | info += tr("by Carsten Schneider<br>"); | 3125 | "zcarsten@gmx.net<br>" |
3632 | info += "zcarsten@gmx.net<br>"; | 3126 | "http://z-soft.z-portal.info/zsafe" |
3633 | info += "http://z-soft.z-portal.info/zsafe"; | 3127 | "<br>" |
3634 | info += "<br>"; | 3128 | "Translations by Robert Ernst<br>" |
3635 | info += tr("Translations by Robert Ernst<br>"); | 3129 | "robert.ernst@linux-solutions.at<br>" |
3636 | info += "robert.ernst@linux-solutions.at<br>"; | 3130 | "<br></div>" |
3637 | 3131 | "</body></html>"); | |
3638 | info += "<br><br>"; | ||
3639 | info += QString::fromUtf8("æ~W¥æ~\\¬èª~^/VGA Zaurus対å¿~\\ã~C~Qã~C~Cã~C~Aä½~\\æ ~H~P<br>"); | ||
3640 | info += "HADECO R&D<br>"; | ||
3641 | info += "r&d@hadeco.co.jp<br>"; | ||
3642 | info += "http://www.hadeco.co.jp/r&d/<br>"; | ||
3643 | info += "<br></div>"; | ||
3644 | info += "</body></html>"; | ||
3645 | #else | ||
3646 | info = "<html><body><div align=""center"">"; | ||
3647 | info += "<b>"; | ||
3648 | info += tr("Zaurus Password Manager<br>"); | ||
3649 | info += tr("ZSafe version 2.1.2<br>"); | ||
3650 | info += "</b>"; | ||
3651 | info += tr("by Carsten Schneider<br>"); | ||
3652 | info += "zcarsten@gmx.net<br>"; | ||
3653 | info += "http://z-soft.z-portal.info/zsafe"; | ||
3654 | info += "<br>"; | ||
3655 | info += tr("Translations by Robert Ernst<br>"); | ||
3656 | info += "robert.ernst@linux-solutions.at<br>"; | ||
3657 | info += "<br></div>"; | ||
3658 | info += "</body></html>"; | ||
3659 | #endif | ||
3660 | 3132 | ||
3661 | // QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0); | 3133 | // QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0); |
3662 | 3134 | ||
3663 | QMessageBox mb( this, tr("ZSafe")); | 3135 | QMessageBox mb( this, tr("ZSafe")); |
3664 | mb.setText (info); | 3136 | mb.setText (info); |
3665 | mb.setButtonText (QMessageBox::Ok, tr ("&OK")); | 3137 | mb.setButtonText (QMessageBox::Ok, tr ("&OK")); |
3666 | QPixmap zsafe_img((const char**) zsafe_xpm); | 3138 | QPixmap zsafe_img((const char**) zsafe_xpm); |
3667 | mb.setIconPixmap (zsafe_img); | 3139 | mb.setIconPixmap (zsafe_img); |
3668 | mb.exec(); | 3140 | mb.exec(); |
3669 | } | 3141 | } |
3670 | 3142 | ||
3671 | void ZSafe::setExpandFlag() | 3143 | void ZSafe::setExpandFlag() |
3672 | { | 3144 | { |
3673 | expandTree = !expandTree; | 3145 | expandTree = !expandTree; |
3674 | file->setItemChecked('o', expandTree); | 3146 | file->setItemChecked('o', expandTree); |
3675 | #ifndef DESKTOP | ||
3676 | conf->setGroup ("zsafePrefs"); | 3147 | conf->setGroup ("zsafePrefs"); |
3677 | #endif | ||
3678 | // #ifndef Q_WS_WIN | 3148 | // #ifndef Q_WS_WIN |
3679 | conf->writeEntry (APP_KEY+"expandTree", expandTree); | 3149 | conf->writeEntry (APP_KEY+"expandTree", expandTree); |
3680 | // #endif | 3150 | // #endif |
3681 | saveConf(); | 3151 | saveConf(); |
3682 | 3152 | ||
3683 | } | 3153 | } |
3684 | 3154 | ||
3685 | void ZSafe::paintEvent( QPaintEvent * ) | 3155 | void ZSafe::paintEvent( QPaintEvent * ) |
3686 | { | 3156 | { |
3687 | if (raiseFlag) | 3157 | if (raiseFlag) |
3688 | { | 3158 | { |
3689 | raiseFlag = false; | 3159 | raiseFlag = false; |
3690 | raiseTimer.start (1, true); | 3160 | raiseTimer.start (1, true); |
3691 | if (infoForm->isVisible()) | 3161 | if (infoForm->isVisible()) |
3692 | infoForm->raise(); | 3162 | infoForm->raise(); |
3693 | } | 3163 | } |
3694 | } | 3164 | } |
3695 | 3165 | ||
3696 | void ZSafe::resizeEvent ( QResizeEvent * ) | 3166 | void ZSafe::resizeEvent ( QResizeEvent * ) |
3697 | { | 3167 | { |
3698 | // owarn << "resizeEvent" << oendl; | 3168 | // owarn << "resizeEvent" << oendl; |
3699 | #ifndef DESKTOP | ||
3700 | DeskW = appl->desktop()->width(); | 3169 | DeskW = appl->desktop()->width(); |
3701 | DeskH = appl->desktop()->height(); | 3170 | DeskH = appl->desktop()->height(); |
3702 | #else | ||
3703 | DeskW = this->width(); | ||
3704 | DeskH = this->height(); | ||
3705 | #endif | ||
3706 | 3171 | ||
3707 | if (New) | 3172 | if (New) |
3708 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); | 3173 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); |
3709 | if (Edit) | 3174 | if (Edit) |
3710 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); | 3175 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); |
3711 | if (Delete) | 3176 | if (Delete) |
3712 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 3177 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); |
3713 | if (Find) | 3178 | if (Find) |
3714 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); | 3179 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); |
3715 | } | 3180 | } |
3716 | 3181 | ||
3717 | void ZSafe::slotRaiseTimer() | 3182 | void ZSafe::slotRaiseTimer() |
3718 | { | 3183 | { |
3719 | if (infoForm->isVisible()) | 3184 | if (infoForm->isVisible()) |
3720 | infoForm->raise(); | 3185 | infoForm->raise(); |
3721 | raiseFlag = true; | 3186 | raiseFlag = true; |
3722 | } | 3187 | } |
3723 | 3188 | ||
3724 | QPixmap * ZSafe::getPredefinedIcon(QString category) | 3189 | QPixmap * ZSafe::getPredefinedIcon(QString category) |
3725 | { | 3190 | { |
3726 | QPixmap *pm; | 3191 | QPixmap *pm; |
3727 | if (category == "Bank cards") | 3192 | if (category == "Bank cards") |
3728 | pm = new QPixmap((const char**)bank_cards_data); | 3193 | pm = new QPixmap((const char**)bank_cards_data); |
3729 | else if (category == "Passwords") | 3194 | else if (category == "Passwords") |
3730 | pm = new QPixmap((const char**)passwords_data); | 3195 | pm = new QPixmap((const char**)passwords_data); |
3731 | else if (category == "Software") | 3196 | else if (category == "Software") |
3732 | pm = new QPixmap((const char**)software_data); | 3197 | pm = new QPixmap((const char**)software_data); |
3733 | else if (category == "General") | 3198 | else if (category == "General") |
3734 | pm = new QPixmap((const char**)general_data); | 3199 | pm = new QPixmap((const char**)general_data); |
3735 | else | 3200 | else |
3736 | pm = new QPixmap((const char**)general_data); | 3201 | pm = new QPixmap((const char**)general_data); |
3737 | return pm; | 3202 | return pm; |
3738 | } | 3203 | } |
3739 | 3204 | ||
3740 | void ZSafe::setDocument(const QString& fileref) | 3205 | void ZSafe::setDocument(const QString& fileref) |
3741 | { | 3206 | { |
3742 | #ifndef DESKTOP | ||
3743 | // stop the timer to prevent loading of the default document | 3207 | // stop the timer to prevent loading of the default document |
3744 | docuTimer.stop(); | 3208 | docuTimer.stop(); |
3745 | 3209 | ||
3746 | DocLnk link(fileref); | 3210 | DocLnk link(fileref); |
3747 | if ( link.isValid() ) | 3211 | if ( link.isValid() ) |
3748 | { | 3212 | { |
3749 | // if (filename != link.file()) | 3213 | // if (filename != link.file()) |
3750 | // saveDocument(filename, FALSE); | 3214 | // saveDocument(filename, FALSE); |
3751 | filename = link.file(); | 3215 | filename = link.file(); |
3752 | } | 3216 | } |
3753 | else | 3217 | else |
3754 | { | 3218 | { |
3755 | // if (filename != fileref) | 3219 | // if (filename != fileref) |
3756 | // saveDocument(filename, FALSE); | 3220 | // saveDocument(filename, FALSE); |
3757 | filename = fileref; | 3221 | filename = fileref; |
3758 | } | 3222 | } |
3759 | // save the current filename to the config file | 3223 | // save the current filename to the config file |
3224 | conf->setGroup("zsafe"); | ||
3760 | conf->writeEntry(APP_KEY+"document", filename); | 3225 | conf->writeEntry(APP_KEY+"document", filename); |
3761 | saveConf(); | 3226 | saveConf(); |
3762 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 3227 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
3763 | #ifdef Q_WS_WIN | 3228 | this->setCaption(tr("ZSafe: ") + ti); |
3764 | this->setCaption("Qt ZSafe: " + ti); | ||
3765 | #else | ||
3766 | this->setCaption("ZSafe: " + ti); | ||
3767 | #endif | ||
3768 | 3229 | ||
3769 | // clear the password list | 3230 | // clear the password list |
3770 | QListViewItem *i; | 3231 | QListViewItem *i; |
3771 | QListViewItem *c = NULL; | 3232 | QListViewItem *c = NULL; |
3772 | // step through all categories | 3233 | // step through all categories |
3773 | for (i = ListView->firstChild(); | 3234 | for (i = ListView->firstChild(); |
3774 | i != NULL; | 3235 | i != NULL; |
3775 | i = i->nextSibling()) | 3236 | i = i->nextSibling()) |
3776 | { | 3237 | { |
3777 | if (c) delete c; // delete the previous category | 3238 | if (c) delete c; // delete the previous category |
3778 | 3239 | ||
3779 | c = i; | 3240 | c = i; |
3780 | // step through all subitems | 3241 | // step through all subitems |
3781 | QListViewItem *si; | 3242 | QListViewItem *si; |
3782 | for (si = i->firstChild(); | 3243 | for (si = i->firstChild(); |
3783 | si != NULL; ) | 3244 | si != NULL; ) |
3784 | { | 3245 | { |
3785 | QListViewItem *_si = si; | 3246 | QListViewItem *_si = si; |
3786 | si = si->nextSibling(); | 3247 | si = si->nextSibling(); |
3787 | i->takeItem(_si); // remove from view list | 3248 | i->takeItem(_si); // remove from view list |
3788 | if (_si) delete _si; | 3249 | if (_si) delete _si; |
3789 | } | 3250 | } |
3790 | } | 3251 | } |
3791 | if (c) delete c; // delete the previous category | 3252 | if (c) delete c; // delete the previous category |
3792 | categories.clear(); | 3253 | categories.clear(); |
3793 | 3254 | ||
3794 | m_password = ""; | 3255 | m_password = ""; |
3795 | selectedItem = NULL; | 3256 | selectedItem = NULL; |
3796 | 3257 | ||
3797 | openDocument(filename); | 3258 | openDocument(filename); |
3798 | #else | ||
3799 | Q_UNUSED(fileref); | ||
3800 | #endif | ||
3801 | } | 3259 | } |
3802 | 3260 | ||
3803 | 3261 | ||
3804 | void ZSafe::ListPressed(int mouse, QListViewItem *item, const QPoint&, int column) { | 3262 | void ZSafe::ListPressed(int mouse, QListViewItem *item, const QPoint&, int column) { |
3805 | if(item ==0) return; | 3263 | if(item ==0) return; |
3806 | switch (mouse) { | 3264 | switch (mouse) { |
3807 | case 1: | 3265 | case 1: |
3808 | { | ||
3809 | #ifdef DESKTOP | ||
3810 | QDragObject *d = new QTextDrag( item->text(column) , this ); | ||
3811 | d->dragCopy(); | ||
3812 | #endif | ||
3813 | } | ||
3814 | break; | 3266 | break; |
3815 | case 2: | 3267 | case 2: |
3816 | { | 3268 | { |
3817 | QClipboard *cb = QApplication::clipboard(); | 3269 | QClipboard *cb = QApplication::clipboard(); |
3818 | 3270 | ||
3819 | QIconSet copy_img((const char**) copy_xpm); | 3271 | QIconSet copy_img((const char**) copy_xpm); |
3820 | QIconSet edit_img((const char**) edit_xpm); | 3272 | QIconSet edit_img((const char**) edit_xpm); |
3821 | QPixmap folder_open_img((const char**) folder_open_xpm); | 3273 | QPixmap folder_open_img((const char**) folder_open_xpm); |
3822 | QPixmap editdelete_img((const char**) editdelete_xpm); | 3274 | QPixmap editdelete_img((const char**) editdelete_xpm); |
3823 | 3275 | ||
3824 | QPopupMenu *m = new QPopupMenu(this); | 3276 | QPopupMenu *m = new QPopupMenu(this); |
3825 | int copyItem = m->insertItem( copy_img, tr( "Copy to Clipboard" )); | 3277 | int copyItem = m->insertItem( copy_img, tr( "Copy to Clipboard" )); |
3826 | int editItem = m->insertItem(edit_img, tr( "Edit" )); | 3278 | int editItem = m->insertItem(edit_img, tr( "Edit" )); |
3827 | int showItem = m->insertItem(folder_open_img, tr( "Show Info" )); | 3279 | int showItem = m->insertItem(folder_open_img, tr( "Show Info" )); |
3828 | int cancelItem = m->insertItem( editdelete_img, tr( "Cancel" )); | 3280 | int cancelItem = m->insertItem( editdelete_img, tr( "Cancel" )); |
3829 | m->setFocus(); | 3281 | m->setFocus(); |
3830 | int me=m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y() ) ) ; | 3282 | int me=m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y() ) ) ; |
3831 | if(me == copyItem) { | 3283 | if(me == copyItem) { |
3832 | copyClip( item->text(column) ) ; | 3284 | copyClip( item->text(column) ) ; |
3833 | } else if (me == cancelItem) { | 3285 | } else if (me == cancelItem) { |
3834 | cb->clear(); | 3286 | cb->clear(); |
3835 | } else if (me == editItem) { | 3287 | } else if (me == editItem) { |
3836 | editPwd(); | 3288 | editPwd(); |
3837 | } else if (me == showItem) { | 3289 | } else if (me == showItem) { |
3838 | showInfo(item); | 3290 | showInfo(item); |
3839 | } | 3291 | } |
3840 | } | 3292 | } |
3841 | break; | 3293 | break; |
3842 | }; | 3294 | }; |
3843 | } | 3295 | } |
3844 | 3296 | ||
3845 | void ZSafe::copyClip( const QString &text) { | 3297 | void ZSafe::copyClip( const QString &text) { |
3846 | QClipboard *cb = QApplication::clipboard(); | 3298 | QClipboard *cb = QApplication::clipboard(); |
3847 | cb->setText( text); | 3299 | cb->setText( text); |
3848 | } | 3300 | } |
3849 | 3301 | ||
3850 | 3302 | ||
3851 | QString ZSafe::zsaveDialog() { | 3303 | QString ZSafe::zsaveDialog() { |
3852 | 3304 | ||
3853 | QString fn; | 3305 | QString fn; |
3854 | #ifndef DESKTOP | ||
3855 | #ifndef NO_OPIE | ||
3856 | QMap<QString, QStringList> mimeTypes; | 3306 | QMap<QString, QStringList> mimeTypes; |
3857 | mimeTypes.insert(tr("All"), QStringList() ); | 3307 | mimeTypes.insert(tr("All"), QStringList() ); |
3858 | mimeTypes.insert(tr("Text"), "text/*" ); | 3308 | mimeTypes.insert(tr("Text"), "text/*" ); |
3859 | fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, | 3309 | fn = OFileDialog::getSaveFileName( OFileSelector::EXTENDED_ALL, |
3860 | QDir::homeDirPath() + "/Documents/application/zsafe", | 3310 | QDir::homeDirPath() + "/Documents/application/zsafe", |
3861 | QString::null, | 3311 | QString::null, |
3862 | mimeTypes, | 3312 | mimeTypes, |
3863 | this, | 3313 | this, |
3864 | tr ("Export text file")); | 3314 | tr ("Export text file")); |
3865 | #else | 3315 | return fn; |
3866 | fn = ScQtFileEdit::getSaveAsFileName(this, | ||
3867 | tr ("Export text file"), | ||
3868 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
3869 | "*.txt"); | ||
3870 | #endif | ||
3871 | #else | ||
3872 | fn = QFileDialog::getSaveFileName( | ||
3873 | QDir::homeDirPath() + "/Documents/application/zsafe", | ||
3874 | "ZSafe (*.txt)", | ||
3875 | this, | ||
3876 | "ZSafe"); | ||
3877 | #endif | ||
3878 | return fn; | ||
3879 | } | 3316 | } |
diff --git a/noncore/apps/zsafe/zsafe.h b/noncore/apps/zsafe/zsafe.h index 7419797..3d812f8 100644 --- a/noncore/apps/zsafe/zsafe.h +++ b/noncore/apps/zsafe/zsafe.h | |||
@@ -1,198 +1,204 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form interface generated from reading ui file 'zsafe.ui' | 2 | ** Form interface generated from reading ui file 'zsafe.ui' |
3 | ** | 3 | ** |
4 | ** Created: Sat Apr 6 17:57:42 2002 | 4 | ** Created: Sat Apr 6 17:57:42 2002 |
5 | ** | 5 | ** |
6 | ** Author: Carsten Schneider <CarstenSchneider@t-online.de> | 6 | ** Author: Carsten Schneider <CarstenSchneider@t-online.de> |
7 | ** | 7 | ** |
8 | ** $Id$ | 8 | ** $Id$ |
9 | ** | 9 | ** |
10 | ** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html | 10 | ** Homepage: http://home.t-online.de/home/CarstenSchneider/zsafe/index.html |
11 | ** | 11 | ** |
12 | ** WARNING! All changes made in this file will be lost! | 12 | ** WARNING! All changes made in this file will be lost! |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #ifndef ZSAFE_H | 14 | #ifndef ZSAFE_H |
15 | #define ZSAFE_H | 15 | #define ZSAFE_H |
16 | 16 | ||
17 | #include <stdio.h> | 17 | #include <stdio.h> |
18 | 18 | ||
19 | #include "infoform.h" | 19 | #include "infoform.h" |
20 | #include "categorylist.h" | 20 | #include "categorylist.h" |
21 | #include "shadedlistitem.h" | 21 | #include "shadedlistitem.h" |
22 | 22 | ||
23 | #include <qvariant.h> | 23 | #include <qvariant.h> |
24 | #include <qdialog.h> | 24 | #include <qdialog.h> |
25 | #include <qwidgetstack.h> | 25 | #include <qwidgetstack.h> |
26 | #include <qtimer.h> | 26 | #include <qtimer.h> |
27 | 27 | ||
28 | class QVBoxLayout; | 28 | class QVBoxLayout; |
29 | class QHBoxLayout; | 29 | class QHBoxLayout; |
30 | class QGridLayout; | 30 | class QGridLayout; |
31 | class ZListView; | 31 | class ZListView; |
32 | class QListViewItem; | 32 | class QListViewItem; |
33 | class QToolButton; | 33 | class QToolButton; |
34 | class QTextBrowser; | 34 | class QTextBrowser; |
35 | class QPopupMenu; | 35 | class QPopupMenu; |
36 | #ifdef DESKTOP | 36 | #ifdef DESKTOP |
37 | // #ifndef WIN32 | 37 | // #ifndef WIN32 |
38 | class QSettings; | 38 | class QSettings; |
39 | // #endif | 39 | // #endif |
40 | #else | 40 | #else |
41 | class Config; | 41 | class Config; |
42 | #endif | 42 | #endif |
43 | class CategoryDialog; | 43 | class CategoryDialog; |
44 | class QPixmap; | 44 | class QPixmap; |
45 | 45 | ||
46 | // number of fields for one entry | 46 | // number of fields for one entry |
47 | #define FIELD_SIZE 7 | 47 | #define FIELD_SIZE 7 |
48 | 48 | ||
49 | class ZSafe : public QDialog | 49 | class ZSafe : public QWidget |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | 52 | ||
53 | protected: | 53 | protected: |
54 | void paintEvent( QPaintEvent * e ); | 54 | void paintEvent( QPaintEvent * e ); |
55 | void resizeEvent ( QResizeEvent * ); | 55 | void resizeEvent ( QResizeEvent * ); |
56 | 56 | ||
57 | bool raiseFlag; | 57 | bool raiseFlag; |
58 | QTimer raiseTimer; | 58 | QTimer raiseTimer; |
59 | 59 | ||
60 | public: | 60 | public: |
61 | ZSafe( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = WDestructiveClose ); | 61 | ZSafe( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
62 | ~ZSafe(); | 62 | ~ZSafe(); |
63 | static QString appName() { return QString::fromLatin1( QUICKAPP_NAME ); } | ||
63 | 64 | ||
64 | static const QColor *evenRowColor; | 65 | static const QColor *evenRowColor; |
65 | static const QColor *oddRowColor; | 66 | static const QColor *oddRowColor; |
66 | 67 | ||
67 | QToolButton* Edit; | 68 | QToolButton* Edit; |
68 | QToolButton* Delete; | 69 | QToolButton* Delete; |
69 | QToolButton* Find; | 70 | QToolButton* Find; |
70 | QToolButton* New; | 71 | QToolButton* New; |
71 | ZListView* ListView; | 72 | ZListView* ListView; |
72 | 73 | ||
73 | QString cfgFile; | 74 | QString cfgFile; |
74 | QString iconPath; | 75 | QString iconPath; |
75 | 76 | ||
76 | InfoForm *infoForm; | 77 | InfoForm *infoForm; |
77 | CategoryDialog *categoryDialog; | 78 | CategoryDialog *categoryDialog; |
78 | 79 | ||
79 | QListViewItem *selectedItem; // current selected item | 80 | QListViewItem *selectedItem; // current selected item |
80 | QListViewItem *copiedItem; // copied item | 81 | QListViewItem *copiedItem; // copied item |
81 | bool IsCopy; | 82 | bool IsCopy; |
82 | bool IsCut; | 83 | bool IsCut; |
83 | bool modified; // true if database is modified | 84 | bool modified; // true if database is modified |
84 | bool showpwd; // show PWD Dialog | 85 | bool showpwd; // show PWD Dialog |
85 | 86 | ||
86 | QListViewItem *lastSearchedCategory; | 87 | QListViewItem *lastSearchedCategory; |
87 | QListViewItem *lastSearchedItem; | 88 | QListViewItem *lastSearchedItem; |
88 | QString lastSearchedName; | 89 | QString lastSearchedName; |
89 | QString lastSearchedUsername; | 90 | QString lastSearchedUsername; |
90 | QString lastSearchedComment; | 91 | QString lastSearchedComment; |
91 | 92 | ||
92 | 93 | ||
93 | CategoryList categories; // list of categories | 94 | CategoryList categories; // list of categories |
94 | 95 | ||
95 | bool isCategory(QListViewItem *_item); | 96 | bool isCategory(QListViewItem *_item); |
96 | void getDocPassword(QString title); | 97 | void getDocPassword(QString title); |
97 | QString filename; | 98 | QString filename; |
98 | 99 | ||
99 | enum { | 100 | enum { |
100 | PWERR_GOOD, // success | 101 | PWERR_GOOD, // success |
101 | PWERR_OPEN, // can't open filedescriptor / can't create file | 102 | PWERR_OPEN, // can't open filedescriptor / can't create file |
102 | PWERR_PERM, // permissions are bad | 103 | PWERR_PERM, // permissions are bad |
103 | PWERR_SYML, // is a symlink | 104 | PWERR_SYML, // is a symlink |
104 | PWERR_STAT, // can't get file status | 105 | PWERR_STAT, // can't get file status |
105 | PWERR_DATA // can't read correct data | 106 | PWERR_DATA // can't read correct data |
106 | }; | 107 | }; |
107 | 108 | ||
108 | long load_buffer_length; | 109 | long load_buffer_length; |
109 | long save_buffer_length; | 110 | long save_buffer_length; |
110 | 111 | ||
111 | /** password for the file */ | 112 | /** password for the file */ |
112 | QString m_password; | 113 | QString m_password; |
113 | /** globals needed for file loading */ | 114 | /** globals needed for file loading */ |
114 | int lastcount, size; | 115 | int lastcount, size; |
115 | /** these three are needed in all save functions and initialized in save _init() */ | 116 | /** these three are needed in all save functions and initialized in save _init() */ |
116 | FILE *fd; | 117 | FILE *fd; |
117 | unsigned short iv[4]; | 118 | unsigned short iv[4]; |
118 | char *buffer; | 119 | char *buffer; |
119 | /** these two are global because save_entry() and save_finalize() both n eed them */ | 120 | /** these two are global because save_entry() and save_finalize() both n eed them */ |
120 | int bufferIndex; | 121 | int bufferIndex; |
121 | unsigned short plaintext[4]; | 122 | unsigned short plaintext[4]; |
122 | 123 | ||
123 | #ifdef DESKTOP | 124 | #ifdef DESKTOP |
124 | // #ifndef WIN32 | 125 | // #ifndef WIN32 |
125 | QSettings *conf; | 126 | QSettings *conf; |
126 | // #endif | 127 | // #endif |
127 | #else | 128 | #else |
128 | Config *conf; | 129 | Config *conf; |
129 | #endif | 130 | #endif |
130 | bool expandTree; | 131 | bool expandTree; |
131 | QPopupMenu *file; | 132 | QPopupMenu *file; |
132 | 133 | ||
133 | QTimer docuTimer; | 134 | QTimer docuTimer; |
134 | 135 | ||
135 | 136 | ||
136 | bool openDocument(const char* filename, const char* format=0); | 137 | bool openDocument(const char* filename, const char* format=0); |
137 | int loadInit(const char* filename, const char *password); | 138 | int loadInit(const char* filename, const char *password); |
138 | int loadEntry(char *entry[4]); | 139 | int loadEntry(char *entry[4]); |
139 | int loadFinalize(void); | 140 | int loadFinalize(void); |
140 | bool saveDocument(const char* filename, bool withPwd, const char* format=0); | 141 | bool saveDocument(const char* filename, bool withPwd, const char* format=0); |
141 | int saveInit(const char *filename, const char *password); | 142 | int saveInit(const char *filename, const char *password); |
142 | int saveEntry(char *entry[4]); | 143 | int saveEntry(char *entry[4]); |
143 | int saveFinalize(void); | 144 | int saveFinalize(void); |
144 | void saveConf(); | 145 | void saveConf(); |
145 | QPixmap * getPredefinedIcon(QString category); | 146 | QPixmap * getPredefinedIcon(QString category); |
146 | QString getFieldLabel (QListViewItem *_item, QString field, QString def); | 147 | QString getFieldLabel (QListViewItem *_item, QString field, QString def); |
147 | QString getFieldLabel (QString category, QString field, QString def); | 148 | QString getFieldLabel (QString category, QString field, QString def); |
148 | void setCategoryDialogFields(CategoryDialog *dialog); | 149 | void setCategoryDialogFields(CategoryDialog *dialog); |
149 | void setCategoryDialogFields(CategoryDialog *dialog, QString category); | 150 | void setCategoryDialogFields(CategoryDialog *dialog, QString category); |
150 | void saveCategoryDialogFields(CategoryDialog *dialog); | 151 | void saveCategoryDialogFields(CategoryDialog *dialog); |
151 | 152 | ||
152 | 153 | ||
153 | void resume(int signum); | 154 | void resume(int signum); |
154 | void exitZs (int ec); | 155 | void exitZs (int ec); |
155 | 156 | ||
156 | QString zsaveDialog(); | 157 | QString zsaveDialog(); |
157 | 158 | ||
158 | public slots: | 159 | public slots: |
159 | virtual void deletePwd(); | 160 | virtual void deletePwd(); |
160 | virtual void editPwd(); | 161 | virtual void editPwd(); |
161 | virtual void newPwd(); | 162 | virtual void newPwd(); |
162 | virtual void findPwd(); | 163 | virtual void findPwd(); |
163 | virtual void quitMe(); | 164 | virtual void quitMe(); |
164 | virtual void listViewSelected( QListViewItem *_item); | 165 | virtual void listViewSelected( QListViewItem *_item); |
165 | virtual void showInfo( QListViewItem *_item); | 166 | virtual void showInfo( QListViewItem *_item); |
166 | virtual void writeAllEntries(); | 167 | virtual void writeAllEntries(); |
167 | virtual void readAllEntries(); | 168 | virtual void readAllEntries(); |
168 | virtual void removeAsciiFile(); | 169 | virtual void removeAsciiFile(); |
169 | virtual void setPasswordDialogDone(); | 170 | virtual void setPasswordDialogDone(); |
170 | 171 | ||
171 | virtual void addCategory(); | 172 | virtual void addCategory(); |
172 | virtual void delCategory(); | 173 | virtual void delCategory(); |
173 | virtual void editCategory(); | 174 | virtual void editCategory(); |
174 | virtual void cutItem(); | 175 | virtual void cutItem(); |
175 | virtual void copyItem(); | 176 | virtual void copyItem(); |
176 | virtual void pasteItem(); | 177 | virtual void pasteItem(); |
177 | 178 | ||
178 | virtual void newDocument(); | 179 | virtual void newDocument(); |
179 | virtual void loadDocument(); | 180 | virtual void loadDocument(); |
180 | virtual void saveDocumentAs(); | 181 | virtual void saveDocumentAs(); |
181 | virtual void saveDocumentWithoutPwd(); | 182 | virtual void saveDocumentWithoutPwd(); |
182 | virtual void saveDocumentWithPwd(); | 183 | virtual void saveDocumentWithPwd(); |
183 | virtual void about(); | 184 | virtual void about(); |
184 | virtual void setExpandFlag(); | 185 | virtual void setExpandFlag(); |
185 | 186 | ||
186 | virtual void categoryFieldActivated( const QString& str); | 187 | virtual void categoryFieldActivated( const QString& str); |
187 | 188 | ||
188 | virtual void ListPressed(int, QListViewItem *, const QPoint&, int); | 189 | virtual void ListPressed(int, QListViewItem *, const QPoint&, int); |
189 | virtual void copyClip( const QString &text); | 190 | virtual void copyClip( const QString &text); |
190 | 191 | ||
191 | private slots: | 192 | private slots: |
192 | void setDocument(const QString& fileref); | 193 | void setDocument(const QString& fileref); |
193 | void slotLoadDocu(); | 194 | void slotLoadDocu(); |
194 | void slotRaiseTimer(); | 195 | void slotRaiseTimer(); |
195 | 196 | ||
196 | }; | 197 | }; |
197 | 198 | ||
199 | |||
200 | extern ZSafe *zs; | ||
201 | extern QApplication *appl; | ||
202 | extern int DeskW; | ||
203 | extern int DeskH; | ||
198 | #endif // ZSAFE_H | 204 | #endif // ZSAFE_H |