-rw-r--r-- | pwmanager/pwmanager/pwmanager.pro | 168 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.h | 2 |
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 | ||
6 | OBJECTS_DIR = obj/$(PLATFORM) | ||
7 | MOC_DIR = moc/$(PLATFORM) | ||
8 | DESTDIR=$(QPEDIR)/bin | ||
9 | |||
10 | INCLUDEPATH += . ../../ ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils $(QPEDIR)/include | ||
11 | DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION | ||
12 | |||
13 | #enable this setting if you want debugoutput for pwmanager | ||
14 | #DEFINES += CONFIG_DEBUG | ||
15 | LIBS += -L../libcrypt/$(PLATFORM) | ||
16 | LIBS += -lmicrokde | ||
17 | LIBS += -lmicroqtcompat | ||
18 | LIBS += -lmicrokdepim | ||
19 | LIBS += -L$(QPEDIR)/lib | ||
20 | LIBS += -lqpe | ||
21 | LIBS += -lzlib | ||
22 | #LIBS += -lbz2 | ||
23 | #LIBS += -lkpmicrogcrypt | ||
24 | LIBS += -ljpeg | ||
25 | LIBS += $(QTOPIALIB) | ||
26 | LIBS += -lkpmicrocipher | ||
27 | LIBS += -lkpmicroerror | ||
28 | LIBS += -lkpmicrompi | ||
29 | LIBS += -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 | |||
55 | HEADERS = \ | ||
56 | addentrywnd_emb.h \ | ||
57 | addentrywndimpl.h \ | ||
58 | base64.h \ | ||
59 | binentrygen.h \ | ||
60 | blowfish.h \ | ||
61 | commentbox.h \ | ||
62 | compiler.h \ | ||
63 | compressgzip.h \ | ||
64 | findwnd_emb.h \ | ||
65 | findwndimpl.h \ | ||
66 | genpasswd.h \ | ||
67 | getkeycardwnd.h \ | ||
68 | getmasterpwwnd_emb.h \ | ||
69 | getmasterpwwndimpl.h \ | ||
70 | globalstuff.h \ | ||
71 | gpasmanfile.h \ | ||
72 | htmlgen.h \ | ||
73 | htmlparse.h \ | ||
74 | ipc.h \ | ||
75 | libgcryptif.h \ | ||
76 | listobjselectwnd.h \ | ||
77 | listviewpwm.h \ | ||
78 | printtext.h \ | ||
79 | pwgenwnd_emb.h \ | ||
80 | pwgenwndimpl.h \ | ||
81 | pwmdoc.h \ | ||
82 | pwmdocui.h \ | ||
83 | pwmexception.h \ | ||
84 | pwm.h \ | ||
85 | pwminit.h \ | ||
86 | pwmprefs.h \ | ||
87 | pwmprint.h \ | ||
88 | pwmtray.h \ | ||
89 | pwmview.h \ | ||
90 | pwmviewstyle_0.h \ | ||
91 | pwmviewstyle_1.h \ | ||
92 | pwmviewstyle.h \ | ||
93 | randomizer.h \ | ||
94 | rc2.h \ | ||
95 | rencatwnd.h \ | ||
96 | serializer.h \ | ||
97 | setmasterpwwnd_emb.h \ | ||
98 | setmasterpwwndimpl.h \ | ||
99 | sha1.h \ | ||
100 | waitwnd.h \ | ||
101 | kcmconfigs/kcmpwmconfig.h \ | ||
102 | kcmconfigs/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 | |||
121 | SOURCES = \ | ||
122 | addentrywnd_emb.cpp \ | ||
123 | addentrywndimpl.cpp \ | ||
124 | base64.cpp \ | ||
125 | binentrygen.cpp \ | ||
126 | blowfish.cpp \ | ||
127 | commentbox.cpp \ | ||
128 | compressgzip.cpp \ | ||
129 | findwnd_emb.cpp \ | ||
130 | findwndimpl.cpp \ | ||
131 | genpasswd.cpp \ | ||
132 | getkeycardwnd.cpp \ | ||
133 | getmasterpwwnd_emb.cpp \ | ||
134 | getmasterpwwndimpl.cpp \ | ||
135 | globalstuff.cpp \ | ||
136 | gpasmanfile.cpp \ | ||
137 | htmlgen.cpp \ | ||
138 | ipc.cpp \ | ||
139 | libgcryptif.cpp \ | ||
140 | listobjselectwnd.cpp \ | ||
141 | listviewpwm.cpp \ | ||
142 | main.cpp \ | ||
143 | pwgenwnd_emb.cpp \ | ||
144 | pwgenwndimpl.cpp \ | ||
145 | pwm.cpp \ | ||
146 | pwmdoc.cpp \ | ||
147 | pwmdocui.cpp \ | ||
148 | pwmexception.cpp \ | ||
149 | pwminit.cpp \ | ||
150 | pwmprefs.cpp \ | ||
151 | pwmtray.cpp \ | ||
152 | pwmview.cpp \ | ||
153 | pwmviewstyle_0.cpp \ | ||
154 | pwmviewstyle_1.cpp \ | ||
155 | pwmviewstyle.cpp \ | ||
156 | randomizer.cpp \ | ||
157 | rc2.cpp \ | ||
158 | rencatwnd.cpp \ | ||
159 | serializer.cpp \ | ||
160 | setmasterpwwnd_emb.cpp \ | ||
161 | setmasterpwwndimpl.cpp \ | ||
162 | sha1.cpp \ | ||
163 | waitwnd.cpp \ | ||
164 | kcmconfigs/kcmpwmconfig.cpp \ | ||
165 | kcmconfigs/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,322 +1,322 @@ | |||
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 | ||
69 | using std::vector; | 69 | using std::vector; |
70 | using std::string; | 70 | using std::string; |
71 | using std::pair; | 71 | using 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 | ||
93 | class PwMDoc; | 93 | class PwMDoc; |
94 | class PwMView; | 94 | class PwMView; |
95 | class QFile; | 95 | class QFile; |
96 | 96 | ||
97 | /* meta data for a PwMDataItem */ | 97 | /* meta data for a PwMDataItem */ |
98 | struct PwMMetaData | 98 | struct 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 | ||
155 | struct PwMDataItem | 155 | struct 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 | ||
227 | struct PwMCategoryItem | 227 | struct 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 | ||
241 | struct PwMSyncItem | 241 | struct 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 | ||
253 | struct PwMItem | 253 | struct 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 */ |
267 | class dta_lvp_greater | 267 | class dta_lvp_greater |
268 | { | 268 | { |
269 | public: | 269 | public: |
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 */ |
278 | class PwMDocList | 278 | class PwMDocList |
279 | { | 279 | { |
280 | public: | 280 | public: |
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 | ||
313 | protected: | 313 | protected: |
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; |