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