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