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