author | zautrix <zautrix> | 2004-10-19 23:38:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-19 23:38:16 (UTC) |
commit | f013ff3c0108100c6dbf037a05502ed493361fbf (patch) (unidiff) | |
tree | bf274ac58b55cea0e2f609db8ae5f27f4418a2df | |
parent | f605b2d40ff0f90b132ca880afa83ac751162a2e (diff) | |
download | kdepimpi-f013ff3c0108100c6dbf037a05502ed493361fbf.zip kdepimpi-f013ff3c0108100c6dbf037a05502ed493361fbf.tar.gz kdepimpi-f013ff3c0108100c6dbf037a05502ed493361fbf.tar.bz2 |
desktop fixes
-rw-r--r-- | Makefile | 589 | ||||
-rw-r--r-- | kdepim-desktop.pro | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/main.cpp | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 12 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.h | 8 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmanager.pro | 33 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 8 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwminit.cpp | 16 | ||||
-rw-r--r-- | pwmanager/pwmanager/serializer.cpp | 6 |
9 files changed, 281 insertions, 394 deletions
@@ -1,362 +1,229 @@ | |||
1 | export KDEPIMDIR = $(shell pwd) | 1 | ############################################################################# |
2 | 2 | # Makefile for building: kdepim-desktop | |
3 | export KDEPIM_VERSION=$(shell sed -e 's/.*\"\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/' < version) | 3 | # Generated by qmake (1.07a) (Qt 3.3.1) on: Wed Oct 20 01:01:01 2004 |
4 | 4 | # Project: kdepim-desktop.pro | |
5 | ifeq ($(PLATFORM) , zaurus) | 5 | # Template: subdirs |
6 | BUILD_NO_LDAP_PLUGIN=1 | 6 | # Command: $(QMAKE) -o Makefile kdepim-desktop.pro |
7 | endif | 7 | ############################################################################# |
8 | 8 | ||
9 | ifneq ($(PLATFORM) , zaurus) | 9 | MAKEFILE =Makefile |
10 | BUILD_NO_SHARP_PLUGIN=1 | 10 | QMAKE =qmake |
11 | endif | 11 | DEL_FILE = rm -f |
12 | 12 | CHK_DIR_EXISTS= test -d | |
13 | SUBDIRS_MICROKDE = \ | 13 | MKDIR = mkdir -p |
14 | libical/src/libical \ | 14 | SUBTARGETS = \ |
15 | libical/src/libicalss \ | 15 | sub-pwmanager-libcrypt-cipher \ |
16 | qtcompat \ | 16 | sub-pwmanager-libcrypt-error \ |
17 | microkde \ | 17 | sub-pwmanager-libcrypt-mpi \ |
18 | libkcal \ | 18 | sub-pwmanager-libcrypt-zlib \ |
19 | libkdepim \ | 19 | sub-gammu-emb-common \ |
20 | kabc \ | 20 | sub-gammu-emb-gammu \ |
21 | kabc/formats/binary \ | 21 | sub-libical \ |
22 | kabc/plugins/file \ | 22 | sub-libkcal \ |
23 | kabc/plugins/dir \ | 23 | sub-microkde \ |
24 | korganizer \ | 24 | sub-libkdepim \ |
25 | kalarmd \ | 25 | sub-kabc \ |
26 | kaddressbook | 26 | sub-pwmanager-pwmanager \ |
27 | 27 | sub-korganizer \ | |
28 | SUBDIRS_QTOPIA_PLUGIN = \ | 28 | sub-kaddressbook \ |
29 | kabc/plugins/qtopia | 29 | sub-kabc-plugins-file \ |
30 | 30 | sub-kabc-plugins-dir | |
31 | SUBDIRS_OPIE_PLUGIN = \ | 31 | |
32 | kabc/plugins/opie | 32 | first: all |
33 | 33 | ||
34 | SUBDIRS_SHARP_PLUGIN = \ | 34 | all: Makefile $(SUBTARGETS) |
35 | kabc/plugins/sharpdtm | 35 | |
36 | 36 | pwmanager/libcrypt/cipher/$(MAKEFILE): | |
37 | SUBDIRS_LDAP_PLUGIN = \ | 37 | @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/cipher" || $(MKDIR) "pwmanager/libcrypt/cipher" |
38 | kabc/plugins/ldap | 38 | cd pwmanager/libcrypt/cipher && $(QMAKE) cipher.pro -o $(MAKEFILE) |
39 | 39 | sub-pwmanager-libcrypt-cipher: pwmanager/libcrypt/cipher/$(MAKEFILE) FORCE | |
40 | SUBDIRS_MICROMAIL = \ | 40 | cd pwmanager/libcrypt/cipher && $(MAKE) -f $(MAKEFILE) |
41 | kmicromail/libetpan \ | 41 | |
42 | kmicromail/libmailwrapper \ | 42 | pwmanager/libcrypt/error/$(MAKEFILE): |
43 | kmicromail | 43 | @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/error" || $(MKDIR) "pwmanager/libcrypt/error" |
44 | 44 | cd pwmanager/libcrypt/error && $(QMAKE) error.pro -o $(MAKEFILE) | |
45 | SUBDIRS_GAMMU = \ | 45 | sub-pwmanager-libcrypt-error: pwmanager/libcrypt/error/$(MAKEFILE) FORCE |
46 | gammu/emb/common \ | 46 | cd pwmanager/libcrypt/error && $(MAKE) -f $(MAKEFILE) |
47 | gammu/emb/gammu | 47 | |
48 | 48 | pwmanager/libcrypt/mpi/$(MAKEFILE): | |
49 | SUBDIRS_PWMANAGER = \ | 49 | @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/mpi" || $(MKDIR) "pwmanager/libcrypt/mpi" |
50 | pwmanager/libcrypt/mpi \ | 50 | cd pwmanager/libcrypt/mpi && $(QMAKE) mpi.pro -o $(MAKEFILE) |
51 | pwmanager/libcrypt/error \ | 51 | sub-pwmanager-libcrypt-mpi: pwmanager/libcrypt/mpi/$(MAKEFILE) FORCE |
52 | pwmanager/libcrypt/cipher \ | 52 | cd pwmanager/libcrypt/mpi && $(MAKE) -f $(MAKEFILE) |
53 | pwmanager/libcrypt/zlib \ | 53 | |
54 | pwmanager/pwmanager | 54 | pwmanager/libcrypt/zlib/$(MAKEFILE): |
55 | 55 | @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/zlib" || $(MKDIR) "pwmanager/libcrypt/zlib" | |
56 | SUBDIRS = \ | 56 | cd pwmanager/libcrypt/zlib && $(QMAKE) zlib.pro -o $(MAKEFILE) |
57 | $(SUBDIRS_MICROKDE) \ | 57 | sub-pwmanager-libcrypt-zlib: pwmanager/libcrypt/zlib/$(MAKEFILE) FORCE |
58 | $(SUBDIRS_QTOPIA_PLUGIN) \ | 58 | cd pwmanager/libcrypt/zlib && $(MAKE) -f $(MAKEFILE) |
59 | $(SUBDIRS_OPIE_PLUGIN) \ | 59 | |
60 | $(SUBDIRS_SHARP_PLUGIN) \ | 60 | gammu/emb/common/$(MAKEFILE): |
61 | $(SUBDIRS_LDAP_PLUGIN) \ | 61 | @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common" |
62 | $(SUBDIRS_MICROMAIL) \ | 62 | cd gammu/emb/common && $(QMAKE) common.pro -o $(MAKEFILE) |
63 | $(SUBDIRS_GAMMU) \ | 63 | sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE |
64 | $(SUBDIRS_PWMANAGER) | 64 | cd gammu/emb/common && $(MAKE) -f $(MAKEFILE) |
65 | 65 | ||
66 | 66 | gammu/emb/gammu/$(MAKEFILE): | |
67 | all: build_microkde \ | 67 | @$(CHK_DIR_EXISTS) "gammu/emb/gammu" || $(MKDIR) "gammu/emb/gammu" |
68 | build_qtopia_plugin \ | 68 | cd gammu/emb/gammu && $(QMAKE) gammu.pro -o $(MAKEFILE) |
69 | build_opie_plugin \ | 69 | sub-gammu-emb-gammu: gammu/emb/gammu/$(MAKEFILE) FORCE |
70 | build_sharp_plugin \ | 70 | cd gammu/emb/gammu && $(MAKE) -f $(MAKEFILE) |
71 | build_ldap_plugin \ | 71 | |
72 | build_micromail \ | 72 | libical/$(MAKEFILE): |
73 | build_gammu \ | 73 | @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical" |
74 | build_pwmanager | 74 | cd libical && $(QMAKE) libical.pro -o $(MAKEFILE) |
75 | 75 | sub-libical: libical/$(MAKEFILE) FORCE | |
76 | 76 | cd libical && $(MAKE) -f $(MAKEFILE) | |
77 | build_microkde: variable_test tmake | 77 | |
78 | for i in $(SUBDIRS_MICROKDE); do pushd $$i; \ | 78 | libkcal/$(MAKEFILE): |
79 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | 79 | @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal" |
80 | done | 80 | cd libkcal && $(QMAKE) libkcal.pro -o $(MAKEFILE) |
81 | 81 | sub-libkcal: libkcal/$(MAKEFILE) FORCE | |
82 | build_qtopia_plugin: build_microkde | 82 | cd libkcal && $(MAKE) -f $(MAKEFILE) |
83 | ifdef BUILD_NO_QTOPIA_PLUGIN | 83 | |
84 | @echo == qtopia plugin not build. | 84 | microkde/$(MAKEFILE): |
85 | else | 85 | @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde" |
86 | for i in $(SUBDIRS_QTOPIA_PLUGIN); do pushd $$i; \ | 86 | cd microkde && $(QMAKE) microkde.pro -o $(MAKEFILE) |
87 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | 87 | sub-microkde: microkde/$(MAKEFILE) FORCE |
88 | done | 88 | cd microkde && $(MAKE) -f $(MAKEFILE) |
89 | endif | 89 | |
90 | 90 | libkdepim/$(MAKEFILE): | |
91 | build_opie_plugin: build_microkde | 91 | @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim" |
92 | ifdef BUILD_NO_OPIE_PLUGIN | 92 | cd libkdepim && $(QMAKE) libkdepim.pro -o $(MAKEFILE) |
93 | @echo == opie plugin not build. | 93 | sub-libkdepim: libkdepim/$(MAKEFILE) FORCE |
94 | else | 94 | cd libkdepim && $(MAKE) -f $(MAKEFILE) |
95 | for i in $(SUBDIRS_OPIE_PLUGIN); do pushd $$i; \ | 95 | |
96 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | 96 | kabc/$(MAKEFILE): |
97 | done | 97 | @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc" |
98 | endif | 98 | cd kabc && $(QMAKE) kabc.pro -o $(MAKEFILE) |
99 | 99 | sub-kabc: kabc/$(MAKEFILE) FORCE | |
100 | build_sharp_plugin: build_microkde | 100 | cd kabc && $(MAKE) -f $(MAKEFILE) |
101 | ifdef BUILD_NO_SHARP_PLUGIN | 101 | |
102 | @echo == ldap plugin not build. | 102 | pwmanager/pwmanager/$(MAKEFILE): |
103 | else | 103 | @$(CHK_DIR_EXISTS) "pwmanager/pwmanager" || $(MKDIR) "pwmanager/pwmanager" |
104 | for i in $(SUBDIRS_SHARP_PLUGIN); do pushd $$i; \ | 104 | cd pwmanager/pwmanager && $(QMAKE) pwmanager.pro -o $(MAKEFILE) |
105 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | 105 | sub-pwmanager-pwmanager: pwmanager/pwmanager/$(MAKEFILE) FORCE |
106 | done | 106 | cd pwmanager/pwmanager && $(MAKE) -f $(MAKEFILE) |
107 | endif | 107 | |
108 | 108 | korganizer/$(MAKEFILE): | |
109 | build_ldap_plugin: build_microkde | 109 | @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer" |
110 | ifdef BUILD_NO_LDAP_PLUGIN | 110 | cd korganizer && $(QMAKE) korganizer.pro -o $(MAKEFILE) |
111 | @echo == ldap plugin not build. | 111 | sub-korganizer: korganizer/$(MAKEFILE) FORCE |
112 | else | 112 | cd korganizer && $(MAKE) -f $(MAKEFILE) |
113 | for i in $(SUBDIRS_LDAP_PLUGIN); do pushd $$i; \ | 113 | |
114 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | 114 | kaddressbook/$(MAKEFILE): |
115 | done | 115 | @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook" |
116 | endif | 116 | cd kaddressbook && $(QMAKE) kaddressbook.pro -o $(MAKEFILE) |
117 | 117 | sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE | |
118 | 118 | cd kaddressbook && $(MAKE) -f $(MAKEFILE) | |
119 | build_micromail: build_microkde | 119 | |
120 | ifdef BUILD_NO_MICROMAIL | 120 | kabc/plugins/file/$(MAKEFILE): |
121 | @echo == kmicromail not build. | 121 | @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file" |
122 | else | 122 | cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE) |
123 | for i in $(SUBDIRS_MICROMAIL); do pushd $$i; \ | 123 | sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE |
124 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | 124 | cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE) |
125 | done | 125 | |
126 | endif | 126 | kabc/plugins/dir/$(MAKEFILE): |
127 | 127 | @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir" | |
128 | build_gammu: variable_test tmake | 128 | cd kabc/plugins/dir && $(QMAKE) dir.pro -o $(MAKEFILE) |
129 | ifdef BUILD_NO_GAMMU | 129 | sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE |
130 | @echo == gammu not build. | 130 | cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE) |
131 | else | 131 | |
132 | for i in $(SUBDIRS_GAMMU); do pushd $$i; \ | 132 | Makefile: kdepim-desktop.pro /usr/lib/qt3/mkspecs/default/qmake.conf |
133 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | 133 | $(QMAKE) -o Makefile kdepim-desktop.pro |
134 | done | 134 | qmake: qmake_all |
135 | endif | 135 | @$(QMAKE) -o Makefile kdepim-desktop.pro |
136 | 136 | ||
137 | build_pwmanager: build_microkde | 137 | all: $(SUBTARGETS) |
138 | ifdef BUILD_NO_PWMANAGER | 138 | qmake_all: pwmanager/libcrypt/cipher/$(MAKEFILE) pwmanager/libcrypt/error/$(MAKEFILE) pwmanager/libcrypt/mpi/$(MAKEFILE) pwmanager/libcrypt/zlib/$(MAKEFILE) gammu/emb/common/$(MAKEFILE) gammu/emb/gammu/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) pwmanager/pwmanager/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) |
139 | @echo == pwmanager not build. | 139 | ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
140 | else | 140 | ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
141 | for i in $(SUBDIRS_PWMANAGER); do pushd $$i; \ | 141 | ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
142 | make -f Makefile$(PLATFORM) || exit 1; popd; \ | 142 | ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
143 | done | 143 | ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
144 | endif | 144 | ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
145 | 145 | ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | |
146 | 146 | ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | |
147 | variable_info: | 147 | ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
148 | @echo -------------------------------------- | 148 | ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
149 | @echo KDEPIM buildsystem, variableinfo... | 149 | ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
150 | @echo KDEPIMDIR=$(KDEPIMDIR) | 150 | ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
151 | @echo QTDIR=$(QTDIR) | 151 | ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
152 | @echo QPEDIR=$(QPEDIR) | 152 | ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
153 | @echo OPIEDIR=$(OPIEDIR) | 153 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
154 | @echo PLATFORM=$(PLATFORM) | 154 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
155 | @echo RELEASE_DEBUG=$(RELEASE_DEBUG) | 155 | clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE |
156 | @echo BUILD_NO_MICROMAIL=$(BUILD_NO_MICROMAIL) | 156 | ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
157 | @echo BUILD_NO_LDAP_PLUGIN=$(BUILD_NO_LDAP_PLUGIN) | 157 | ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
158 | @echo BUILD_NO_OPIE_PLUGIN=$(BUILD_NO_OPIE_PLUGIN) | 158 | ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
159 | @echo BUILD_NO_QTOPIA_PLUGIN=$(BUILD_NO_QTOPIA_PLUGIN) | 159 | ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
160 | @echo BUILD_NO_SHARP_PLUGIN=$(BUILD_NO_SHARP_PLUGIN) | 160 | ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
161 | ifndef BUILD_NO_SHARP_PLUGIN | 161 | ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
162 | @echo SHARPDTMSDK=$(SHARPDTMSDK) | 162 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
163 | endif | 163 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
164 | @echo BUILD_NO_GAMMU=$(BUILD_NO_GAMMU) | 164 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
165 | @echo BUILD_NO_PWMANAGER=$(BUILD_NO_PWMANAGER) | 165 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
166 | @echo -------------------------------------- | 166 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
167 | 167 | ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) $@; ) || true | |
168 | variable_test: variable_info | 168 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
169 | @echo KDEPIM buildsystem, variablecheck... | 169 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
170 | ifndef KDEPIMDIR | 170 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
171 | @echo KDEPIMDIR is not defined. | 171 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
172 | $(error KDEPIMDIR is not defined) | 172 | uninstall_subdirs: qmake_all FORCE |
173 | endif | 173 | ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
174 | ifndef PLATFORM | 174 | ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
175 | @echo PLATFORM is not defined. | 175 | ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
176 | $(error PLATFORM is not defined) | 176 | ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
177 | endif | 177 | ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
178 | ifdef BUILD_NO_LDAP_PLUGIN | 178 | ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
179 | @echo LDAP PLUGIN will not be build, because BUILD_NO_LDAP_PLUGIN is set to $(BUILD_NO_LDAP_PLUGIN) | 179 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
180 | endif | 180 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
181 | ifdef BUILD_NO_OPIE_PLUGIN | 181 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
182 | @echo OPIE PLUGIN will not be build, because BUILD_NO_OPIE_PLUGIN is set to $(BUILD_NO_OPIE_PLUGIN) | 182 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
183 | endif | 183 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
184 | ifdef BUILD_NO_QTOPIA_PLUGIN | 184 | ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
185 | @echo QTOPIA PLUGIN will not be build, because BUILD_NO__QTOPIA_PLUGIN is set to $(BUILD_NO__QTOPIA_PLUGIN) | 185 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
186 | endif | 186 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
187 | ifdef BUILD_NO_MICROMAIL | 187 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
188 | @echo MICROMAIL will not be build, because BUILD_NO_MICROMAIL is set to $(BUILD_NO_MICROMAIL) | 188 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
189 | endif | 189 | install_subdirs: qmake_all FORCE |
190 | ifdef BUILD_NO_SHARP_PLUGIN | 190 | ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) install; ) || true |
191 | @echo SHARP PLUGIN will not be build, because BUILD_NO_SHARP_PLUGIN is set to $(BUILD_NO_SHARP_PLUGIN) | 191 | ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) install; ) || true |
192 | else | 192 | ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) install; ) || true |
193 | ifndef SHARPDTMSDK | 193 | ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) install; ) || true |
194 | @echo SHARP PLUGIN can not be build, because SHARPDTMSDK is set to $(SHARPDTMSDK) | 194 | ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) install; ) || true |
195 | $(error SHARPDTMSDK is not defined) | 195 | ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) install; ) || true |
196 | endif | 196 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true |
197 | endif | 197 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true |
198 | ifdef BUILD_NO_GAMMU | 198 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true |
199 | @echo GAMMU will not be build, because BUILD_NO_GAMMU is set to $(BUILD_NO_GAMMU) | 199 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true |
200 | endif | 200 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true |
201 | ifdef BUILD_NO_PWMANAGER | 201 | ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) install; ) || true |
202 | @echo PWMANAGER will not be build, because BUILD_NO_PWMANAGER is set to $(BUILD_NO_PWMANAGER) | 202 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true |
203 | endif | 203 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true |
204 | @echo -------------------------------------- | 204 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true |
205 | 205 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true | |
206 | 206 | distclean: qmake_all FORCE | |
207 | objects: | 207 | ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
208 | for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done | 208 | ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
209 | for i in $(SUBDIRS); do mkdir -p $$i/moc/$(PLATFORM); done | 209 | ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
210 | mkdir -p libical/lib/$(PLATFORM) | 210 | ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
211 | mkdir -p pwmanager/libcrypt/$(PLATFORM) | 211 | ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
212 | 212 | ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | |
213 | clean: | 213 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
214 | rm -rf libical/lib/$(PLATFORM)/*; | 214 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
215 | rm -rf pwmanager/libcrypt/$(PLATFORM)/*; | 215 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
216 | for i in $(SUBDIRS); do pushd $$i; make clean; rm -f *~;\ | 216 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
217 | rm -f obj/$(PLATFORM)/*; rm -f moc/$(PLATFORM)/*; rm Makefile$(PLATFORM); popd; \ | 217 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
218 | done | 218 | ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
219 | 219 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | |
220 | install: | 220 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
221 | 221 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | |
222 | cd bin/kdepim; make install | 222 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
223 | cp -r Pim $(QPEDIR)/apps | 223 | |
224 | cp db2file/db2file $(QPEDIR)/bin/db2file | 224 | install: install_subdirs |
225 | cp korganizer/korganizer.desktop $(QPEDIR)/apps/Pim/korganizer.desktop | 225 | |
226 | cp kaddressbook/kaddressbook.desktop $(QPEDIR)/apps/Pim/kaddressbook.desktop | 226 | uninstall: uninstall_subdirs |
227 | cp kmicromail/kmicromail.desktop $(QPEDIR)/apps/Pim/kopiemail.desktop | 227 | |
228 | cp pwmanager/pwmanager/pwmanager.desktop $(QPEDIR)/apps/Pim/pwmanager.desktop | 228 | FORCE: |
229 | |||
230 | dist: | ||
231 | @echo Dont forget to do "make install" before "make dist" | ||
232 | rm -f *arm.ipk | ||
233 | rm -f *~ | ||
234 | cd ..; tar czf kdepim.src.tar.gz --exclude=obj --exclude=moc --exclude=CVS --exclude=Makefilezaurus --exclude=Makefileqtopia kdepim | ||
235 | mkipks kmicrokdelibs.control | ||
236 | mkipks korganizer.control | ||
237 | mkipks kaddressbook.control | ||
238 | ifndef BUILD_NO_MICROMAIL | ||
239 | mkipks kopiemail.control | ||
240 | endif | ||
241 | mkipks korganizer-alarm.control | ||
242 | ifndef BUILD_NO_GAMMU | ||
243 | mkipks phoneaccess.control | ||
244 | endif | ||
245 | ifndef BUILD_NO_PWMANAGER | ||
246 | mkipks pwmanager.control | ||
247 | endif | ||
248 | mkipks pim_TAB_icon.control | ||
249 | |||
250 | tmake: objects \ | ||
251 | qtcompat/Makefile$(PLATFORM) \ | ||
252 | microkde/Makefile$(PLATFORM) \ | ||
253 | libkcal/Makefile$(PLATFORM) \ | ||
254 | libkdepim/Makefile$(PLATFORM) \ | ||
255 | korganizer/Makefile$(PLATFORM) \ | ||
256 | kalarmd/Makefile$(PLATFORM) \ | ||
257 | libical/src/libical/Makefile$(PLATFORM) \ | ||
258 | libical/src/libicalss/Makefile$(PLATFORM) \ | ||
259 | kabc/Makefile$(PLATFORM) \ | ||
260 | kabc/formats/binary/Makefile$(PLATFORM) \ | ||
261 | kabc/plugins/file/Makefile$(PLATFORM) \ | ||
262 | kabc/plugins/dir/Makefile$(PLATFORM) \ | ||
263 | kabc/plugins/ldap/Makefile$(PLATFORM) \ | ||
264 | kabc/plugins/opie/Makefile$(PLATFORM) \ | ||
265 | kabc/plugins/qtopia/Makefile$(PLATFORM) \ | ||
266 | kabc/plugins/sharpdtm/Makefile$(PLATFORM) \ | ||
267 | kaddressbook/Makefile$(PLATFORM) \ | ||
268 | kmicromail/Makefile$(PLATFORM) \ | ||
269 | kmicromail/libetpan/Makefile$(PLATFORM) \ | ||
270 | kmicromail/libmailwrapper/Makefile$(PLATFORM) \ | ||
271 | gammu/emb/common/Makefile$(PLATFORM) \ | ||
272 | gammu/emb/gammu/Makefile$(PLATFORM) \ | ||
273 | pwmanager/pwmanager/Makefile$(PLATFORM) \ | ||
274 | pwmanager/libcrypt/mpi/Makefile$(PLATFORM) \ | ||
275 | pwmanager/libcrypt/error/Makefile$(PLATFORM) \ | ||
276 | pwmanager/libcrypt/cipher/Makefile$(PLATFORM) \ | ||
277 | pwmanager/libcrypt/zlib/Makefile$(PLATFORM) | ||
278 | |||
279 | qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro | ||
280 | cd qtcompat; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" qtcompat.pro -o Makefile$(PLATFORM) | ||
281 | |||
282 | microkde/Makefile$(PLATFORM): microkde/microkdeE.pro | ||
283 | cd microkde; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" microkdeE.pro -o Makefile$(PLATFORM) | ||
284 | |||
285 | libkcal/Makefile$(PLATFORM): libkcal/libkcalE.pro | ||
286 | cd libkcal; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libkcalE.pro -o Makefile$(PLATFORM) | ||
287 | |||
288 | |||
289 | libkdepim/Makefile$(PLATFORM): libkdepim/libkdepimE.pro | ||
290 | cd libkdepim; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libkdepimE.pro -o Makefile$(PLATFORM) | ||
291 | |||
292 | kalarmd/Makefile$(PLATFORM): kalarmd/kalarmdE.pro | ||
293 | cd kalarmd; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kalarmdE.pro -o Makefile$(PLATFORM) | ||
294 | |||
295 | korganizer/Makefile$(PLATFORM): korganizer/korganizerE.pro | ||
296 | cd korganizer; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" korganizerE.pro -o Makefile$(PLATFORM) | ||
297 | |||
298 | libical/src/libical/Makefile$(PLATFORM): libical/src/libical/libicalE.pro | ||
299 | cd libical/src/libical; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libicalE.pro -o Makefile$(PLATFORM) | ||
300 | |||
301 | libical/src/libicalss/Makefile$(PLATFORM): libical/src/libicalss/libicalssE.pro | ||
302 | cd libical/src/libicalss; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libicalssE.pro -o Makefile$(PLATFORM) | ||
303 | |||
304 | kabc/Makefile$(PLATFORM): kabc/kabcE.pro | ||
305 | cd kabc; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kabcE.pro -o Makefile$(PLATFORM) | ||
306 | |||
307 | kabc/formats/binary/Makefile$(PLATFORM): kabc/formats/binary/kabcformat_binaryE.pro | ||
308 | cd kabc/formats/binary; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kabcformat_binaryE.pro -o Makefile$(PLATFORM) | ||
309 | |||
310 | kabc/plugins/file/Makefile$(PLATFORM): kabc/plugins/file/fileE.pro | ||
311 | cd kabc/plugins/file; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" fileE.pro -o Makefile$(PLATFORM) | ||
312 | |||
313 | kabc/plugins/dir/Makefile$(PLATFORM): kabc/plugins/dir/dirE.pro | ||
314 | cd kabc/plugins/dir; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" dirE.pro -o Makefile$(PLATFORM) | ||
315 | |||
316 | kabc/plugins/ldap/Makefile$(PLATFORM): kabc/plugins/ldap/ldapE.pro | ||
317 | cd kabc/plugins/ldap; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" ldapE.pro -o Makefile$(PLATFORM) | ||
318 | |||
319 | kabc/plugins/opie/Makefile$(PLATFORM): kabc/plugins/opie/opieE.pro | ||
320 | cd kabc/plugins/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" opieE.pro -o Makefile$(PLATFORM) | ||
321 | |||
322 | kabc/plugins/qtopia/Makefile$(PLATFORM): kabc/plugins/qtopia/qtopiaE.pro | ||
323 | cd kabc/plugins/qtopia; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" qtopiaE.pro -o Makefile$(PLATFORM) | ||
324 | |||
325 | kabc/plugins/sharpdtm/Makefile$(PLATFORM): kabc/plugins/sharpdtm/sharpdtmE.pro | ||
326 | cd kabc/plugins/sharpdtm; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" sharpdtmE.pro -o Makefile$(PLATFORM) | ||
327 | |||
328 | kaddressbook/Makefile$(PLATFORM): kaddressbook/kaddressbookE.pro | ||
329 | cd kaddressbook; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kaddressbookE.pro -o Makefile$(PLATFORM) | ||
330 | |||
331 | kmicromail/Makefile$(PLATFORM): kmicromail/kmicromailE.pro | ||
332 | cd kmicromail; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kmicromailE.pro -o Makefile$(PLATFORM) | ||
333 | |||
334 | kmicromail/libetpan/Makefile$(PLATFORM): kmicromail/libetpan/libetpanE.pro | ||
335 | cd kmicromail/libetpan; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libetpanE.pro -o Makefile$(PLATFORM) | ||
336 | |||
337 | kmicromail/libmailwrapper/Makefile$(PLATFORM): kmicromail/libmailwrapper/libmailwrapperE.pro | ||
338 | cd kmicromail/libmailwrapper; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libmailwrapperE.pro -o Makefile$(PLATFORM) | ||
339 | |||
340 | gammu/emb/common/Makefile$(PLATFORM): gammu/emb/common/commonE.pro | ||
341 | cd gammu/emb/common; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" commonE.pro -o Makefile$(PLATFORM) | ||
342 | |||
343 | gammu/emb/gammu/Makefile$(PLATFORM): gammu/emb/gammu/gammuE.pro | ||
344 | cd gammu/emb/gammu; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" gammuE.pro -o Makefile$(PLATFORM) | ||
345 | |||
346 | pwmanager/pwmanager/Makefile$(PLATFORM): pwmanager/pwmanager/pwmanagerE.pro | ||
347 | cd pwmanager/pwmanager; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" pwmanagerE.pro -o Makefile$(PLATFORM) | ||
348 | |||
349 | |||
350 | pwmanager/libcrypt/mpi/Makefile$(PLATFORM): pwmanager/libcrypt/mpi/mpi.pro | ||
351 | cd pwmanager/libcrypt/mpi;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" mpi.pro -o Makefile$(PLATFORM) | ||
352 | |||
353 | pwmanager/libcrypt/error/Makefile$(PLATFORM): pwmanager/libcrypt/error/error.pro | ||
354 | cd pwmanager/libcrypt/error;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" error.pro -o Makefile$(PLATFORM) | ||
355 | |||
356 | pwmanager/libcrypt/cipher/Makefile$(PLATFORM): pwmanager/libcrypt/cipher/cipher.pro | ||
357 | cd pwmanager/libcrypt/cipher;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" cipher.pro -o Makefile$(PLATFORM) | ||
358 | |||
359 | pwmanager/libcrypt/zlib/Makefile$(PLATFORM): pwmanager/libcrypt/zlib/zlib.pro | ||
360 | cd pwmanager/libcrypt/zlib;tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" zlib.pro -o Makefile$(PLATFORM) | ||
361 | |||
362 | 229 | ||
diff --git a/kdepim-desktop.pro b/kdepim-desktop.pro index 7a3a96e..cb4eee3 100644 --- a/kdepim-desktop.pro +++ b/kdepim-desktop.pro | |||
@@ -1,6 +1,6 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | TEMPLATE = subdirs | 3 | TEMPLATE = subdirs |
4 | SUBDIRS = gammu/emb/common gammu/emb/gammu libical libkcal microkde libkdepim kabc korganizer kaddressbook kabc/plugins/file kabc/plugins/dir | 4 | SUBDIRS = pwmanager/libcrypt/cipher pwmanager/libcrypt/error pwmanager/libcrypt/mpi pwmanager/libcrypt/zlib gammu/emb/common gammu/emb/gammu libical libkcal microkde libkdepim kabc pwmanager/pwmanager korganizer kaddressbook kabc/plugins/file kabc/plugins/dir |
5 | #kalarmd | 5 | #kalarmd |
6 | 6 | ||
diff --git a/pwmanager/pwmanager/main.cpp b/pwmanager/pwmanager/main.cpp index 3f2d055..9d1d863 100644 --- a/pwmanager/pwmanager/main.cpp +++ b/pwmanager/pwmanager/main.cpp | |||
@@ -1,213 +1,214 @@ | |||
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.0.1 of pwmanager | 14 | * This file is originaly based on version 1.0.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 PWM_EMBEDDED | 20 | #ifndef PWM_EMBEDDED |
21 | #include <kcmdlineargs.h> | 21 | #include <kcmdlineargs.h> |
22 | #include <kaboutdata.h> | 22 | #include <kaboutdata.h> |
23 | #else | 23 | #else |
24 | #include <qdir.h> | 24 | #include <qdir.h> |
25 | #include <kpimglobalprefs.h> | 25 | #include <kpimglobalprefs.h> |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | #include <klocale.h> | 28 | #include <klocale.h> |
29 | #include <kstandarddirs.h> | 29 | #include <kstandarddirs.h> |
30 | 30 | ||
31 | #include "pwmexception.h" | 31 | #include "pwmexception.h" |
32 | #include "pwminit.h" | 32 | #include "pwminit.h" |
33 | 33 | ||
34 | #define LICENSE_FILE(::locate("data", "pwmanager/pwmanager_license_text")) | 34 | #define LICENSE_FILE(::locate("data", "pwmanager/pwmanager_license_text")) |
35 | 35 | ||
36 | int PwMApplication::newInstance() | 36 | int PwMApplication::newInstance() |
37 | { | 37 | { |
38 | static bool initial = true; | 38 | static bool initial = true; |
39 | if (initial) { | 39 | if (initial) { |
40 | initial = false; | 40 | initial = false; |
41 | init = new PwMInit(this); | 41 | init = new PwMInit(this); |
42 | init->initializeApp(); | 42 | init->initializeApp(); |
43 | } else { | 43 | } else { |
44 | BUG_ON(!init); | 44 | BUG_ON(!init); |
45 | printInfo("passing parameters to old instance."); | 45 | printInfo("passing parameters to old instance."); |
46 | init->handleCmdLineArgs(false); | 46 | init->handleCmdLineArgs(false); |
47 | } | 47 | } |
48 | return EXIT_SUCCESS; | 48 | return EXIT_SUCCESS; |
49 | } | 49 | } |
50 | 50 | ||
51 | 51 | ||
52 | static const char *description = I18N_NOOP("PwManager\n" | 52 | static const char *description = I18N_NOOP("PwManager\n" |
53 | "The convenient way of managing passwords"); | 53 | "The convenient way of managing passwords"); |
54 | 54 | ||
55 | #ifndef PWM_EMBEDDED | 55 | #ifndef PWM_EMBEDDED |
56 | static KCmdLineOptions options[] = | 56 | static KCmdLineOptions options[] = |
57 | { | 57 | { |
58 | { "minimized", I18N_NOOP("Windows minimized"), 0 }, | 58 | { "minimized", I18N_NOOP("Windows minimized"), 0 }, |
59 | { "mintray", I18N_NOOP("Windows minimized to tray"),0 }, | 59 | { "mintray", I18N_NOOP("Windows minimized to tray"),0 }, |
60 | { "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"),0 }, | 60 | { "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"),0 }, |
61 | { "skip-self-test", I18N_NOOP("Don't run a self-test on startup"),0 }, | 61 | { "skip-self-test", I18N_NOOP("Don't run a self-test on startup"),0 }, |
62 | { "+[files...]", I18N_NOOP("Files to open on startup"), 0 }, | 62 | { "+[files...]", I18N_NOOP("Files to open on startup"), 0 }, |
63 | { 0, 0, 0 } | 63 | { 0, 0, 0 } |
64 | }; | 64 | }; |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #ifdef PWM_DEBUG | 67 | #ifdef PWM_DEBUG |
68 | static void printDebugConfigureInfo() | 68 | static void printDebugConfigureInfo() |
69 | { | 69 | { |
70 | cout << "================================" << endl; | 70 | cout << "================================" << endl; |
71 | cout << PROG_NAME " version " PACKAGE_VER << endl; | 71 | cout << PROG_NAME " version " PACKAGE_VER << endl; |
72 | #ifdef CONFIG_KEYCARD | 72 | #ifdef CONFIG_KEYCARD |
73 | cout << "CONFIG_KEYCARD: enabled" << endl; | 73 | cout << "CONFIG_KEYCARD: enabled" << endl; |
74 | #else | 74 | #else |
75 | cout << "CONFIG_KEYCARD: disabled" << endl; | 75 | cout << "CONFIG_KEYCARD: disabled" << endl; |
76 | #endif | 76 | #endif |
77 | #ifdef CONFIG_KWALLETIF | 77 | #ifdef CONFIG_KWALLETIF |
78 | cout << "CONFIG_KWALLETIF: enabled" << endl; | 78 | cout << "CONFIG_KWALLETIF: enabled" << endl; |
79 | #else | 79 | #else |
80 | cout << "CONFIG_KWALLETIF: disabled" << endl; | 80 | cout << "CONFIG_KWALLETIF: disabled" << endl; |
81 | #endif | 81 | #endif |
82 | #ifdef BIG_ENDIAN_HOST | 82 | #ifdef BIG_ENDIAN_HOST |
83 | cout << "Endianess: big-endian" << endl; | 83 | cout << "Endianess: big-endian" << endl; |
84 | #else | 84 | #else |
85 | cout << "Endianess: little-endian" << endl; | 85 | cout << "Endianess: little-endian" << endl; |
86 | #endif | 86 | #endif |
87 | cout << "sizeof(long): " << sizeof(long) << endl; | 87 | cout << "sizeof(long): " << sizeof(long) << endl; |
88 | cout << "================================" << endl; | 88 | cout << "================================" << endl; |
89 | } | 89 | } |
90 | #else // PWM_DEBUG | 90 | #else // PWM_DEBUG |
91 | static inline void printDebugConfigureInfo() { /* nothing */ } | 91 | static inline void printDebugConfigureInfo() { /* nothing */ } |
92 | #endif // PWM_DEBUG | 92 | #endif // PWM_DEBUG |
93 | 93 | ||
94 | #ifndef PWM_EMBEDDED | 94 | #ifndef PWM_EMBEDDED |
95 | static void addAuthors(KAboutData *aboutData) | 95 | static void addAuthors(KAboutData *aboutData) |
96 | { | 96 | { |
97 | aboutData->addAuthor("Michael Buesch", | 97 | aboutData->addAuthor("Michael Buesch", |
98 | I18N_NOOP( | 98 | I18N_NOOP( |
99 | "main programming and current maintainer"), | 99 | "main programming and current maintainer"), |
100 | "mbuesch@freenet.de"); | 100 | "mbuesch@freenet.de"); |
101 | aboutData->addAuthor("Matt Scifo", | 101 | aboutData->addAuthor("Matt Scifo", |
102 | I18N_NOOP( | 102 | I18N_NOOP( |
103 | "original implementaion of \n" | 103 | "original implementaion of \n" |
104 | "\"categories\" and the password-tree \n" | 104 | "\"categories\" and the password-tree \n" |
105 | "in the system-tray. Original implementations of \n" | 105 | "in the system-tray. Original implementations of \n" |
106 | "numerous view-improvements."), | 106 | "numerous view-improvements."), |
107 | "mscifo@o1.com"); | 107 | "mscifo@o1.com"); |
108 | aboutData->addCredit("Elias Probst", | 108 | aboutData->addCredit("Elias Probst", |
109 | I18N_NOOP( | 109 | I18N_NOOP( |
110 | "Gentoo ebuild maintainer."), | 110 | "Gentoo ebuild maintainer."), |
111 | "elias.probst@gmx.de"); | 111 | "elias.probst@gmx.de"); |
112 | aboutData->addCredit("George Staikos", | 112 | aboutData->addCredit("George Staikos", |
113 | I18N_NOOP("KWallet"), | 113 | I18N_NOOP("KWallet"), |
114 | "staikos@kde.org"); | 114 | "staikos@kde.org"); |
115 | aboutData->addCredit("Matthew Palmer", | 115 | aboutData->addCredit("Matthew Palmer", |
116 | I18N_NOOP("rc2 code"), | 116 | I18N_NOOP("rc2 code"), |
117 | "mjp16@uow.edu.au"); | 117 | "mjp16@uow.edu.au"); |
118 | aboutData->addCredit("Olivier Sessink", | 118 | aboutData->addCredit("Olivier Sessink", |
119 | I18N_NOOP("gpasman"), | 119 | I18N_NOOP("gpasman"), |
120 | "gpasman@nl.linux.org"); | 120 | "gpasman@nl.linux.org"); |
121 | aboutData->addCredit("The libgcrypt developers", | 121 | aboutData->addCredit("The libgcrypt developers", |
122 | I18N_NOOP("Blowfish and SHA1 algorithms"), | 122 | I18N_NOOP("Blowfish and SHA1 algorithms"), |
123 | 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/"); | 123 | 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/"); |
124 | aboutData->addCredit("Troy Engel", | 124 | aboutData->addCredit("Troy Engel", |
125 | I18N_NOOP("kpasman"), | 125 | I18N_NOOP("kpasman"), |
126 | "tengel@sonic.net"); | 126 | "tengel@sonic.net"); |
127 | aboutData->addCredit("Wickey", | 127 | aboutData->addCredit("Wickey", |
128 | I18N_NOOP("graphics-design in older versions."), | 128 | I18N_NOOP("graphics-design in older versions."), |
129 | "wickey@gmx.at"); | 129 | "wickey@gmx.at"); |
130 | aboutData->addCredit("Ian MacGregor", | 130 | aboutData->addCredit("Ian MacGregor", |
131 | I18N_NOOP( | 131 | I18N_NOOP( |
132 | "original documentation author.")); | 132 | "original documentation author.")); |
133 | } | 133 | } |
134 | #endif | 134 | #endif |
135 | 135 | ||
136 | int main(int argc, char *argv[]) | 136 | int main(int argc, char *argv[]) |
137 | { | 137 | { |
138 | printDebugConfigureInfo(); | 138 | printDebugConfigureInfo(); |
139 | #ifndef PWM_EMBEDDED | 139 | #ifndef PWM_EMBEDDED |
140 | KAboutData aboutData(PACKAGE_NAME, PROG_NAME, | 140 | KAboutData aboutData(PACKAGE_NAME, PROG_NAME, |
141 | PACKAGE_VER, description, KAboutData::License_File, | 141 | PACKAGE_VER, description, KAboutData::License_File, |
142 | "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0, | 142 | "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0, |
143 | "http://passwordmanager.sourceforge.net/", | 143 | "http://passwordmanager.sourceforge.net/", |
144 | "mbuesch@freenet.de"); | 144 | "mbuesch@freenet.de"); |
145 | addAuthors(&aboutData); | 145 | addAuthors(&aboutData); |
146 | 146 | ||
147 | KCmdLineArgs::init(argc, argv, &aboutData); | 147 | KCmdLineArgs::init(argc, argv, &aboutData); |
148 | KCmdLineArgs::addCmdLineOptions(options); | 148 | KCmdLineArgs::addCmdLineOptions(options); |
149 | 149 | ||
150 | KUniqueApplication::addCmdLineOptions(); | 150 | KUniqueApplication::addCmdLineOptions(); |
151 | if (!KUniqueApplication::start()) { | 151 | if (!KUniqueApplication::start()) { |
152 | printInfo("already running."); | 152 | printInfo("already running."); |
153 | return EXIT_SUCCESS; | 153 | return EXIT_SUCCESS; |
154 | } | 154 | } |
155 | PwMApplication a; | 155 | PwMApplication a; |
156 | aboutData.setLicenseTextFile(LICENSE_FILE); | 156 | aboutData.setLicenseTextFile(LICENSE_FILE); |
157 | return a.exec(); | 157 | return a.exec(); |
158 | #else | 158 | #else |
159 | 159 | ||
160 | bool exitHelp = false; | 160 | bool exitHelp = false; |
161 | if ( argc > 1 ) { | 161 | if ( argc > 1 ) { |
162 | QString command = argv[1]; | 162 | QString command = argv[1]; |
163 | if ( command == "-help" ){ | 163 | if ( command == "-help" ){ |
164 | printf("PWM/PI command line commands:\n"); | 164 | printf("PWM/PI command line commands:\n"); |
165 | printf(" no command: Start PWM/PI in usual way\n"); | 165 | printf(" no command: Start PWM/PI in usual way\n"); |
166 | printf(" -help: This output\n"); | 166 | printf(" -help: This output\n"); |
167 | printf(" PWM/PI is exiting now. Bye!\n"); | 167 | printf(" PWM/PI is exiting now. Bye!\n"); |
168 | exitHelp = true; | 168 | exitHelp = true; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | if ( ! exitHelp ) { | 171 | if ( ! exitHelp ) { |
172 | 172 | ||
173 | PwMApplication a(argc, argv); | 173 | PwMApplication a(argc, argv); |
174 | 174 | ||
175 | KGlobal::setAppName( "pwmanager" ); | 175 | KGlobal::setAppName( "pwmanager" ); |
176 | #ifndef DESKTOP_VERSION | 176 | #ifndef DESKTOP_VERSION |
177 | //qDebug("width %d ",QApplication::desktop()->width() ); | 177 | //qDebug("width %d ",QApplication::desktop()->width() ); |
178 | if ( QApplication::desktop()->width() > 320 ) | 178 | if ( QApplication::desktop()->width() > 320 ) |
179 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/"); | 179 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/"); |
180 | else | 180 | else |
181 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/"); | 181 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/"); |
182 | #else | 182 | #else |
183 | QString fileName ; | 183 | QString fileName ; |
184 | fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/"; | 184 | fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/"; |
185 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 185 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
186 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); | 186 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); |
187 | 187 | ||
188 | #endif | 188 | #endif |
189 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager"))); | 189 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager"))); |
190 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 190 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
191 | 191 | ||
192 | a.newInstance(); | 192 | a.newInstance(); |
193 | 193 | ||
194 | //US KAddressBookMain m ; | 194 | //US KAddressBookMain m ; |
195 | 195 | ||
196 | //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 196 | //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
197 | /*US | 197 | /*US |
198 | #ifndef DESKTOP_VERSION | 198 | #ifndef DESKTOP_VERSION |
199 | a.showMainWidget( &m ); | 199 | a.showMainWidget( &m ); |
200 | #else | 200 | #else |
201 | a.setMainWidget( &m ); | 201 | a.setMainWidget( &m ); |
202 | m.resize (640, 480 ); | 202 | m.resize (640, 480 ); |
203 | m.show(); | 203 | m.show(); |
204 | #endif | 204 | #endif |
205 | */ | 205 | */ |
206 | qDebug("exec "); | ||
206 | a.exec(); | 207 | a.exec(); |
207 | 208 | ||
208 | } | 209 | } |
209 | qDebug("PWMPI: Bye! "); | 210 | qDebug("PWMPI: Bye! "); |
210 | 211 | ||
211 | #endif | 212 | #endif |
212 | 213 | ||
213 | } | 214 | } |
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp index 26a44b1..c511661 100644 --- a/pwmanager/pwmanager/pwm.cpp +++ b/pwmanager/pwmanager/pwm.cpp | |||
@@ -205,846 +205,846 @@ void PwM::initMenubar() | |||
205 | 205 | ||
206 | connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 206 | connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
207 | syncManager->fillSyncMenu(); | 207 | syncManager->fillSyncMenu(); |
208 | 208 | ||
209 | #endif | 209 | #endif |
210 | filePopup = new KPopupMenu(this); | 210 | filePopup = new KPopupMenu(this); |
211 | importPopup = new KPopupMenu(filePopup); | 211 | importPopup = new KPopupMenu(filePopup); |
212 | exportPopup = new KPopupMenu(filePopup); | 212 | exportPopup = new KPopupMenu(filePopup); |
213 | managePopup = new KPopupMenu(this); | 213 | managePopup = new KPopupMenu(this); |
214 | #ifdef CONFIG_KEYCARD | 214 | #ifdef CONFIG_KEYCARD |
215 | chipcardPopup = new KPopupMenu(this); | 215 | chipcardPopup = new KPopupMenu(this); |
216 | #endif // CONFIG_KEYCARD | 216 | #endif // CONFIG_KEYCARD |
217 | viewPopup = new KPopupMenu(this); | 217 | viewPopup = new KPopupMenu(this); |
218 | optionsPopup = new KPopupMenu(this); | 218 | optionsPopup = new KPopupMenu(this); |
219 | 219 | ||
220 | // "file" popup menu | 220 | // "file" popup menu |
221 | filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), | 221 | filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), |
222 | i18n("&New"), this, | 222 | i18n("&New"), this, |
223 | SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); | 223 | SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); |
224 | filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), | 224 | filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), |
225 | i18n("&Open"), this, | 225 | i18n("&Open"), this, |
226 | SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); | 226 | SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); |
227 | filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), | 227 | filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), |
228 | i18n("&Close"), this, | 228 | i18n("&Close"), this, |
229 | SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); | 229 | SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); |
230 | filePopup->insertSeparator(); | 230 | filePopup->insertSeparator(); |
231 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), | 231 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), |
232 | i18n("&Save"), this, | 232 | i18n("&Save"), this, |
233 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); | 233 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); |
234 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), | 234 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), |
235 | i18n("Save &as..."), | 235 | i18n("Save &as..."), |
236 | this, SLOT(saveAs_slot()), 0, | 236 | this, SLOT(saveAs_slot()), 0, |
237 | BUTTON_POPUP_FILE_SAVEAS); | 237 | BUTTON_POPUP_FILE_SAVEAS); |
238 | filePopup->insertSeparator(); | 238 | filePopup->insertSeparator(); |
239 | // "file/export" popup menu | 239 | // "file/export" popup menu |
240 | exportPopup->insertItem(i18n("&Text-file..."), this, | 240 | exportPopup->insertItem(i18n("&Text-file..."), this, |
241 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); | 241 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); |
242 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 242 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
243 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); | 243 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); |
244 | #ifdef CONFIG_KWALLETIF | 244 | #ifdef CONFIG_KWALLETIF |
245 | exportPopup->insertItem(i18n("&KWallet..."), this, | 245 | exportPopup->insertItem(i18n("&KWallet..."), this, |
246 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); | 246 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); |
247 | #endif | 247 | #endif |
248 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), | 248 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), |
249 | i18n("E&xport"), exportPopup, | 249 | i18n("E&xport"), exportPopup, |
250 | BUTTON_POPUP_FILE_EXPORT); | 250 | BUTTON_POPUP_FILE_EXPORT); |
251 | // "file/import" popup menu | 251 | // "file/import" popup menu |
252 | importPopup->insertItem(i18n("&Text-file..."), this, | 252 | importPopup->insertItem(i18n("&Text-file..."), this, |
253 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); | 253 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); |
254 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 254 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
255 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); | 255 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); |
256 | #ifdef CONFIG_KWALLETIF | 256 | #ifdef CONFIG_KWALLETIF |
257 | importPopup->insertItem(i18n("&KWallet..."), this, | 257 | importPopup->insertItem(i18n("&KWallet..."), this, |
258 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); | 258 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); |
259 | #endif | 259 | #endif |
260 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), | 260 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), |
261 | i18n("I&mport"), importPopup, | 261 | i18n("I&mport"), importPopup, |
262 | BUTTON_POPUP_FILE_IMPORT); | 262 | BUTTON_POPUP_FILE_IMPORT); |
263 | filePopup->insertSeparator(); | 263 | filePopup->insertSeparator(); |
264 | filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), | 264 | filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), |
265 | i18n("&Print..."), this, | 265 | i18n("&Print..."), this, |
266 | SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); | 266 | SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); |
267 | filePopup->insertSeparator(); | 267 | filePopup->insertSeparator(); |
268 | filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), | 268 | filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), |
269 | i18n("&Quit"), this, | 269 | i18n("&Quit"), this, |
270 | SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); | 270 | SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); |
271 | menuBar()->insertItem(i18n("&File"), filePopup); | 271 | menuBar()->insertItem(i18n("&File"), filePopup); |
272 | // "manage" popup menu | 272 | // "manage" popup menu |
273 | managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), | 273 | managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), |
274 | i18n("&Add password"), this, | 274 | i18n("&Add password"), this, |
275 | SLOT(addPwd_slot()), 0, | 275 | SLOT(addPwd_slot()), 0, |
276 | BUTTON_POPUP_MANAGE_ADD); | 276 | BUTTON_POPUP_MANAGE_ADD); |
277 | managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), | 277 | managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), |
278 | i18n("&Edit"), this, SLOT(editPwd_slot()), 0, | 278 | i18n("&Edit"), this, SLOT(editPwd_slot()), 0, |
279 | BUTTON_POPUP_MANAGE_EDIT); | 279 | BUTTON_POPUP_MANAGE_EDIT); |
280 | managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), | 280 | managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), |
281 | i18n("&Delete"), this, SLOT(deletePwd_slot()), | 281 | i18n("&Delete"), this, SLOT(deletePwd_slot()), |
282 | 0, BUTTON_POPUP_MANAGE_DEL); | 282 | 0, BUTTON_POPUP_MANAGE_DEL); |
283 | managePopup->insertSeparator(); | 283 | managePopup->insertSeparator(); |
284 | managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), | 284 | managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), |
285 | i18n("Change &Master Password"), this, | 285 | i18n("Change &Master Password"), this, |
286 | SLOT(changeMasterPwd_slot()), 0, | 286 | SLOT(changeMasterPwd_slot()), 0, |
287 | BUTTON_POPUP_MANAGE_CHANGEMP); | 287 | BUTTON_POPUP_MANAGE_CHANGEMP); |
288 | menuBar()->insertItem(i18n("&Manage"), managePopup); | 288 | menuBar()->insertItem(i18n("&Manage"), managePopup); |
289 | // "chipcard" popup menu | 289 | // "chipcard" popup menu |
290 | #ifdef CONFIG_KEYCARD | 290 | #ifdef CONFIG_KEYCARD |
291 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), | 291 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), |
292 | i18n("&Generate new key-card"), this, | 292 | i18n("&Generate new key-card"), this, |
293 | SLOT(genNewCard_slot()), 0, | 293 | SLOT(genNewCard_slot()), 0, |
294 | BUTTON_POPUP_CHIPCARD_GENNEW); | 294 | BUTTON_POPUP_CHIPCARD_GENNEW); |
295 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), | 295 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), |
296 | i18n("&Erase key-card"), this, | 296 | i18n("&Erase key-card"), this, |
297 | SLOT(eraseCard_slot()), 0, | 297 | SLOT(eraseCard_slot()), 0, |
298 | BUTTON_POPUP_CHIPCARD_DEL); | 298 | BUTTON_POPUP_CHIPCARD_DEL); |
299 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), | 299 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), |
300 | i18n("Read card-&ID"), this, | 300 | i18n("Read card-&ID"), this, |
301 | SLOT(readCardId_slot()), 0, | 301 | SLOT(readCardId_slot()), 0, |
302 | BUTTON_POPUP_CHIPCARD_READID); | 302 | BUTTON_POPUP_CHIPCARD_READID); |
303 | chipcardPopup->insertSeparator(); | 303 | chipcardPopup->insertSeparator(); |
304 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), | 304 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), |
305 | i18n("&Make card backup-image"), this, | 305 | i18n("&Make card backup-image"), this, |
306 | SLOT(makeCardBackup_slot()), 0, | 306 | SLOT(makeCardBackup_slot()), 0, |
307 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP); | 307 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP); |
308 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), | 308 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), |
309 | i18n("&Replay card backup-image"), this, | 309 | i18n("&Replay card backup-image"), this, |
310 | SLOT(replayCardBackup_slot()), 0, | 310 | SLOT(replayCardBackup_slot()), 0, |
311 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); | 311 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); |
312 | menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); | 312 | menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); |
313 | #endif // CONFIG_KEYCARD | 313 | #endif // CONFIG_KEYCARD |
314 | // "view" popup menu | 314 | // "view" popup menu |
315 | viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), | 315 | viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), |
316 | i18n("&Find"), this, | 316 | i18n("&Find"), this, |
317 | SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); | 317 | SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); |
318 | viewPopup->insertSeparator(); | 318 | viewPopup->insertSeparator(); |
319 | viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), | 319 | viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), |
320 | i18n("&Lock all entries"), this, | 320 | i18n("&Lock all entries"), this, |
321 | SLOT(lockWnd_slot()), 0, | 321 | SLOT(lockWnd_slot()), 0, |
322 | BUTTON_POPUP_VIEW_LOCK); | 322 | BUTTON_POPUP_VIEW_LOCK); |
323 | viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), | 323 | viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), |
324 | i18n("&Deep-lock all entries"), this, | 324 | i18n("&Deep-lock all entries"), this, |
325 | SLOT(deepLockWnd_slot()), 0, | 325 | SLOT(deepLockWnd_slot()), 0, |
326 | BUTTON_POPUP_VIEW_DEEPLOCK); | 326 | BUTTON_POPUP_VIEW_DEEPLOCK); |
327 | viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), | 327 | viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), |
328 | i18n("&Unlock all entries"), this, | 328 | i18n("&Unlock all entries"), this, |
329 | SLOT(unlockWnd_slot()), 0, | 329 | SLOT(unlockWnd_slot()), 0, |
330 | BUTTON_POPUP_VIEW_UNLOCK); | 330 | BUTTON_POPUP_VIEW_UNLOCK); |
331 | menuBar()->insertItem(i18n("&View"), viewPopup); | 331 | menuBar()->insertItem(i18n("&View"), viewPopup); |
332 | // "options" popup menu | 332 | // "options" popup menu |
333 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), | 333 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), |
334 | i18n("&Configure..."), this, | 334 | i18n("&Configure..."), this, |
335 | SLOT(config_slot()), | 335 | SLOT(config_slot()), |
336 | BUTTON_POPUP_OPTIONS_CONFIG); | 336 | BUTTON_POPUP_OPTIONS_CONFIG); |
337 | menuBar()->insertItem(i18n("&Options"), optionsPopup); | 337 | menuBar()->insertItem(i18n("&Options"), optionsPopup); |
338 | // "help" popup menu | 338 | // "help" popup menu |
339 | #ifndef PWM_EMBEDDED | 339 | #ifndef PWM_EMBEDDED |
340 | helpPopup = helpMenu(QString::null, false); | 340 | helpPopup = helpMenu(QString::null, false); |
341 | #else | 341 | #else |
342 | menuBar()->insertItem(i18n("&Sync"), syncPopup); | 342 | menuBar()->insertItem(i18n("&Sync"), syncPopup); |
343 | 343 | ||
344 | 344 | ||
345 | 345 | ||
346 | 346 | ||
347 | 347 | ||
348 | helpPopup = new KPopupMenu(this); | 348 | helpPopup = new KPopupMenu(this); |
349 | 349 | ||
350 | 350 | ||
351 | helpPopup->insertItem(i18n("&License"), this, | 351 | helpPopup->insertItem(i18n("&License"), this, |
352 | SLOT(showLicense_slot()), 0, | 352 | SLOT(showLicense_slot()), 0, |
353 | BUTTON_POPUP_HELP_LICENSE); | 353 | BUTTON_POPUP_HELP_LICENSE); |
354 | 354 | ||
355 | helpPopup->insertItem(i18n("&Faq"), this, | 355 | helpPopup->insertItem(i18n("&Faq"), this, |
356 | SLOT(faq_slot()), 0, | 356 | SLOT(faq_slot()), 0, |
357 | BUTTON_POPUP_HELP_FAQ); | 357 | BUTTON_POPUP_HELP_FAQ); |
358 | 358 | ||
359 | helpPopup->insertItem(i18n("&About PwManager"), this, | 359 | helpPopup->insertItem(i18n("&About PwManager"), this, |
360 | SLOT(createAboutData_slot()), 0, | 360 | SLOT(createAboutData_slot()), 0, |
361 | BUTTON_POPUP_HELP_ABOUT); | 361 | BUTTON_POPUP_HELP_ABOUT); |
362 | 362 | ||
363 | helpPopup->insertItem(i18n("&Sync HowTo"), this, | 363 | helpPopup->insertItem(i18n("&Sync HowTo"), this, |
364 | SLOT(syncHowTo_slot()), 0, | 364 | SLOT(syncHowTo_slot()), 0, |
365 | BUTTON_POPUP_HELP_SYNC); | 365 | BUTTON_POPUP_HELP_SYNC); |
366 | 366 | ||
367 | helpPopup->insertItem(i18n("&What's New"), this, | 367 | helpPopup->insertItem(i18n("&What's New"), this, |
368 | SLOT(whatsnew_slot()), 0, | 368 | SLOT(whatsnew_slot()), 0, |
369 | BUTTON_POPUP_HELP_WHATSNEW); | 369 | BUTTON_POPUP_HELP_WHATSNEW); |
370 | 370 | ||
371 | #endif | 371 | #endif |
372 | menuBar()->insertItem(i18n("&Help"), helpPopup); | 372 | menuBar()->insertItem(i18n("&Help"), helpPopup); |
373 | 373 | ||
374 | } | 374 | } |
375 | 375 | ||
376 | void PwM::initToolbar() | 376 | void PwM::initToolbar() |
377 | { | 377 | { |
378 | KIconLoader* picons; | 378 | KIconLoader* picons; |
379 | #ifndef PWM_EMBEDDED | 379 | #ifndef PWM_EMBEDDED |
380 | KIconLoader icons; | 380 | KIconLoader icons; |
381 | picons = &icons; | 381 | picons = &icons; |
382 | #else | 382 | #else |
383 | picons = KGlobal::iconLoader(); | 383 | picons = KGlobal::iconLoader(); |
384 | #endif | 384 | #endif |
385 | 385 | ||
386 | #ifdef PWM_EMBEDDED | 386 | #ifdef PWM_EMBEDDED |
387 | if ( QApplication::desktop()->width() > 320 ) | 387 | if ( QApplication::desktop()->width() > 320 ) |
388 | #endif | 388 | #endif |
389 | { | 389 | { |
390 | toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), | 390 | toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), |
391 | BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, | 391 | BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, |
392 | SLOT(new_slot()), true, i18n("New")); | 392 | SLOT(new_slot()), true, i18n("New")); |
393 | toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), | 393 | toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), |
394 | BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, | 394 | BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, |
395 | SLOT(open_slot()), true, i18n("Open")); | 395 | SLOT(open_slot()), true, i18n("Open")); |
396 | toolBar()->insertSeparator(); | 396 | toolBar()->insertSeparator(); |
397 | } | 397 | } |
398 | toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), | 398 | toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), |
399 | BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, | 399 | BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, |
400 | SLOT(save_slot()), true, i18n("Save")); | 400 | SLOT(save_slot()), true, i18n("Save")); |
401 | toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), | 401 | toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), |
402 | BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, | 402 | BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, |
403 | SLOT(saveAs_slot()), true, i18n("Save as")); | 403 | SLOT(saveAs_slot()), true, i18n("Save as")); |
404 | toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), | 404 | toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), |
405 | BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, | 405 | BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, |
406 | SLOT(print_slot()), true, i18n("Print...")); | 406 | SLOT(print_slot()), true, i18n("Print...")); |
407 | toolBar()->insertSeparator(); | 407 | toolBar()->insertSeparator(); |
408 | toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), | 408 | toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), |
409 | BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, | 409 | BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, |
410 | SLOT(addPwd_slot()), true, | 410 | SLOT(addPwd_slot()), true, |
411 | i18n("Add password")); | 411 | i18n("Add password")); |
412 | toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), | 412 | toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), |
413 | BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, | 413 | BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, |
414 | SLOT(editPwd_slot()), true, | 414 | SLOT(editPwd_slot()), true, |
415 | i18n("Edit password")); | 415 | i18n("Edit password")); |
416 | toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), | 416 | toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), |
417 | BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, | 417 | BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, |
418 | SLOT(deletePwd_slot()), true, | 418 | SLOT(deletePwd_slot()), true, |
419 | i18n("Delete password")); | 419 | i18n("Delete password")); |
420 | toolBar()->insertSeparator(); | 420 | toolBar()->insertSeparator(); |
421 | toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), | 421 | toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), |
422 | BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, | 422 | BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, |
423 | SLOT(find_slot()), true, i18n("Find entry")); | 423 | SLOT(find_slot()), true, i18n("Find entry")); |
424 | toolBar()->insertSeparator(); | 424 | toolBar()->insertSeparator(); |
425 | toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), | 425 | toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), |
426 | BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, | 426 | BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, |
427 | SLOT(lockWnd_slot()), true, | 427 | SLOT(lockWnd_slot()), true, |
428 | i18n("Lock all entries")); | 428 | i18n("Lock all entries")); |
429 | toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), | 429 | toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), |
430 | BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, | 430 | BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, |
431 | SLOT(deepLockWnd_slot()), true, | 431 | SLOT(deepLockWnd_slot()), true, |
432 | i18n("Deep-Lock all entries")); | 432 | i18n("Deep-Lock all entries")); |
433 | toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), | 433 | toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), |
434 | BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, | 434 | BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, |
435 | SLOT(unlockWnd_slot()), true, | 435 | SLOT(unlockWnd_slot()), true, |
436 | i18n("Unlock all entries")); | 436 | i18n("Unlock all entries")); |
437 | } | 437 | } |
438 | 438 | ||
439 | void PwM::initMetrics() | 439 | void PwM::initMetrics() |
440 | { | 440 | { |
441 | QSize s = conf()->confWndMainWndSize(); | 441 | QSize s = conf()->confWndMainWndSize(); |
442 | if (s.isValid()) | 442 | if (s.isValid()) |
443 | resize(s); | 443 | resize(s); |
444 | else | 444 | else |
445 | resize(DEFAULT_SIZE); | 445 | resize(DEFAULT_SIZE); |
446 | } | 446 | } |
447 | 447 | ||
448 | void PwM::updateCaption() | 448 | void PwM::updateCaption() |
449 | { | 449 | { |
450 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); | 450 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); |
451 | } | 451 | } |
452 | 452 | ||
453 | void PwM::hideEvent(QHideEvent *) | 453 | void PwM::hideEvent(QHideEvent *) |
454 | { | 454 | { |
455 | if (isMinimized()) { | 455 | if (isMinimized()) { |
456 | if (init->tray()) { | 456 | if (init->tray()) { |
457 | forceMinimizeToTray = true; | 457 | forceMinimizeToTray = true; |
458 | close(); | 458 | close(); |
459 | } | 459 | } |
460 | int mmlock = conf()->confGlobMinimizeLock(); | 460 | int mmlock = conf()->confGlobMinimizeLock(); |
461 | switch (mmlock) { | 461 | switch (mmlock) { |
462 | case 0: // don't lock anything | 462 | case 0: // don't lock anything |
463 | break; | 463 | break; |
464 | case 1: {// normal lock | 464 | case 1: {// normal lock |
465 | curDoc()->lockAll(true); | 465 | curDoc()->lockAll(true); |
466 | break; | 466 | break; |
467 | } case 2: {// deep-lock | 467 | } case 2: {// deep-lock |
468 | curDoc()->deepLock(); | 468 | curDoc()->deepLock(); |
469 | break; | 469 | break; |
470 | } default: | 470 | } default: |
471 | WARN(); | 471 | WARN(); |
472 | } | 472 | } |
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
476 | void PwM::setVirgin(bool v) | 476 | void PwM::setVirgin(bool v) |
477 | { | 477 | { |
478 | if (virgin == v) | 478 | if (virgin == v) |
479 | return; | 479 | return; |
480 | virgin = v; | 480 | virgin = v; |
481 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); | 481 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); |
482 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); | 482 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); |
483 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); | 483 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); |
484 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); | 484 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); |
485 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); | 485 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); |
486 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); | 486 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); |
487 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); | 487 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); |
488 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); | 488 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); |
489 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); | 489 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); |
490 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); | 490 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); |
491 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); | 491 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); |
492 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); | 492 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); |
493 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); | 493 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); |
494 | toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); | 494 | toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); |
495 | toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); | 495 | toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); |
496 | toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); | 496 | toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); |
497 | toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); | 497 | toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); |
498 | toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); | 498 | toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); |
499 | toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); | 499 | toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); |
500 | toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); | 500 | toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); |
501 | } | 501 | } |
502 | 502 | ||
503 | void PwM::new_slot() | 503 | void PwM::new_slot() |
504 | { | 504 | { |
505 | init->createMainWnd(); | 505 | init->createMainWnd(); |
506 | } | 506 | } |
507 | 507 | ||
508 | //US ENH | 508 | //US ENH |
509 | void PwM::open_slot() | 509 | void PwM::open_slot() |
510 | { | 510 | { |
511 | open_slot(""); | 511 | open_slot(""); |
512 | } | 512 | } |
513 | 513 | ||
514 | void PwM::open_slot(QString fn) | 514 | void PwM::open_slot(QString fn) |
515 | { | 515 | { |
516 | openDoc(fn); | 516 | openDoc(fn); |
517 | } | 517 | } |
518 | 518 | ||
519 | PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) | 519 | PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) |
520 | { | 520 | { |
521 | if (!isVirgin()) { | 521 | if (!isVirgin()) { |
522 | // open the document in a new window. | 522 | // open the document in a new window. |
523 | PwM *newInstance = init->createMainWnd(); | 523 | PwM *newInstance = init->createMainWnd(); |
524 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); | 524 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); |
525 | if (!newDoc) { | 525 | if (!newDoc) { |
526 | newInstance->setForceQuit(true); | 526 | newInstance->setForceQuit(true); |
527 | delete_and_null(newInstance); | 527 | delete_and_null(newInstance); |
528 | } | 528 | } |
529 | return newDoc; | 529 | return newDoc; |
530 | } | 530 | } |
531 | 531 | ||
532 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) | 532 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) |
533 | return 0; | 533 | return 0; |
534 | showStatMsg(i18n("Successfully opened file.")); | 534 | showStatMsg(i18n("Successfully opened file.")); |
535 | updateCaption(); | 535 | updateCaption(); |
536 | setVirgin(false); | 536 | setVirgin(false); |
537 | return curDoc(); | 537 | return curDoc(); |
538 | } | 538 | } |
539 | 539 | ||
540 | PwMView * PwM::makeNewListView(PwMDoc *doc) | 540 | PwMView * PwM::makeNewListView(PwMDoc *doc) |
541 | { | 541 | { |
542 | PwMView *ret = new PwMView(this, this, doc); | 542 | PwMView *ret = new PwMView(this, this, doc); |
543 | ret->setFont(conf()->confGlobEntryFont()); | 543 | ret->setFont(conf()->confGlobEntryFont()); |
544 | ret->show(); | 544 | ret->show(); |
545 | return ret; | 545 | return ret; |
546 | } | 546 | } |
547 | 547 | ||
548 | void PwM::close_slot() | 548 | void PwM::close_slot() |
549 | { | 549 | { |
550 | close(); | 550 | close(); |
551 | } | 551 | } |
552 | 552 | ||
553 | void PwM::quitButton_slot() | 553 | void PwM::quitButton_slot() |
554 | { | 554 | { |
555 | init->shutdownApp(0); | 555 | init->shutdownApp(0); |
556 | } | 556 | } |
557 | 557 | ||
558 | void PwM::save_slot() | 558 | void PwM::save_slot() |
559 | { | 559 | { |
560 | save(); | 560 | save(); |
561 | } | 561 | } |
562 | 562 | ||
563 | bool PwM::save() | 563 | bool PwM::save() |
564 | { | 564 | { |
565 | if (!curDoc()->saveDocUi(curDoc())) | 565 | if (!curDoc()->saveDocUi(curDoc())) |
566 | return false; | 566 | return false; |
567 | showStatMsg(i18n("Successfully saved data.")); | 567 | showStatMsg(i18n("Successfully saved data.")); |
568 | updateCaption(); | 568 | updateCaption(); |
569 | return true; | 569 | return true; |
570 | } | 570 | } |
571 | 571 | ||
572 | void PwM::saveAs_slot() | 572 | void PwM::saveAs_slot() |
573 | { | 573 | { |
574 | saveAs(); | 574 | saveAs(); |
575 | } | 575 | } |
576 | 576 | ||
577 | bool PwM::saveAs() | 577 | bool PwM::saveAs() |
578 | { | 578 | { |
579 | if (!curDoc()->saveAsDocUi(curDoc())) | 579 | if (!curDoc()->saveAsDocUi(curDoc())) |
580 | return false; | 580 | return false; |
581 | showStatMsg(i18n("Successfully saved data.")); | 581 | showStatMsg(i18n("Successfully saved data.")); |
582 | updateCaption(); | 582 | updateCaption(); |
583 | return true; | 583 | return true; |
584 | } | 584 | } |
585 | 585 | ||
586 | //US ENH : changed code to run with older MOC | 586 | //US ENH : changed code to run with older MOC |
587 | void PwM::addPwd_slot() | 587 | void PwM::addPwd_slot() |
588 | { | 588 | { |
589 | addPwd_slot(0, 0); | 589 | addPwd_slot1(0, 0); |
590 | } | 590 | } |
591 | 591 | ||
592 | void PwM::addPwd_slot(QString *pw, PwMDoc *_doc) | 592 | void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) |
593 | { | 593 | { |
594 | PwMDoc *doc; | 594 | PwMDoc *doc; |
595 | if (_doc) { | 595 | if (_doc) { |
596 | doc = _doc; | 596 | doc = _doc; |
597 | } else { | 597 | } else { |
598 | doc = curDoc(); | 598 | doc = curDoc(); |
599 | } | 599 | } |
600 | PWM_ASSERT(doc); | 600 | PWM_ASSERT(doc); |
601 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 601 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
602 | #ifndef PWM_EMBEDDED | 602 | #ifndef PWM_EMBEDDED |
603 | AddEntryWndImpl w; | 603 | AddEntryWndImpl w; |
604 | #else | 604 | #else |
605 | AddEntryWndImpl w(this, "addentrywndimpl"); | 605 | AddEntryWndImpl w(this, "addentrywndimpl"); |
606 | #endif | 606 | #endif |
607 | 607 | ||
608 | vector<string> catList; | 608 | vector<string> catList; |
609 | doc->getCategoryList(&catList); | 609 | doc->getCategoryList(&catList); |
610 | unsigned i, size = catList.size(); | 610 | unsigned i, size = catList.size(); |
611 | for (i = 0; i < size; ++i) { | 611 | for (i = 0; i < size; ++i) { |
612 | w.addCategory(catList[i].c_str()); | 612 | w.addCategory(catList[i].c_str()); |
613 | } | 613 | } |
614 | w.setCurrCategory(view->getCurrentCategory()); | 614 | w.setCurrCategory(view->getCurrentCategory()); |
615 | if (pw) | 615 | if (pw) |
616 | w.pwLineEdit->setText(*pw); | 616 | w.pwLineEdit->setText(*pw); |
617 | 617 | ||
618 | tryAgain: | 618 | tryAgain: |
619 | if (w.exec() == 1) | 619 | if (w.exec() == 1) |
620 | { | 620 | { |
621 | PwMDataItem d; | 621 | PwMDataItem d; |
622 | 622 | ||
623 | //US BUG: to initialize all values of curEntr with meaningfulldata, | 623 | //US BUG: to initialize all values of curEntr with meaningfulldata, |
624 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. | 624 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. |
625 | // another option would be to create a constructor for PwMDataItem | 625 | // another option would be to create a constructor for PwMDataItem |
626 | d.clear(true); | 626 | d.clear(true); |
627 | 627 | ||
628 | d.desc = w.getDescription().latin1(); | 628 | d.desc = w.getDescription().latin1(); |
629 | d.name = w.getUsername().latin1(); | 629 | d.name = w.getUsername().latin1(); |
630 | d.pw = w.getPassword().latin1(); | 630 | d.pw = w.getPassword().latin1(); |
631 | d.comment = w.getComment().latin1(); | 631 | d.comment = w.getComment().latin1(); |
632 | d.url = w.getUrl().latin1(); | 632 | d.url = w.getUrl().latin1(); |
633 | d.launcher = w.getLauncher().latin1(); | 633 | d.launcher = w.getLauncher().latin1(); |
634 | PwMerror ret = doc->addEntry(w.getCategory(), &d); | 634 | PwMerror ret = doc->addEntry(w.getCategory(), &d); |
635 | if (ret == e_entryExists) { | 635 | if (ret == e_entryExists) { |
636 | KMessageBox::error(this, | 636 | KMessageBox::error(this, |
637 | i18n | 637 | i18n |
638 | ("An entry with this \"Description\",\n" | 638 | ("An entry with this \"Description\",\n" |
639 | "does already exist.\n" | 639 | "does already exist.\n" |
640 | "Please select another description."), | 640 | "Please select another description."), |
641 | i18n("entry already exists.")); | 641 | i18n("entry already exists.")); |
642 | goto tryAgain; | 642 | goto tryAgain; |
643 | } else if (ret == e_maxAllowedEntr) { | 643 | } else if (ret == e_maxAllowedEntr) { |
644 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" | 644 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" |
645 | "has been reached.\nYou can't add more entries."), | 645 | "has been reached.\nYou can't add more entries."), |
646 | i18n("maximum number of entries")); | 646 | i18n("maximum number of entries")); |
647 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 647 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
648 | return; | 648 | return; |
649 | } | 649 | } |
650 | } | 650 | } |
651 | setVirgin(false); | 651 | setVirgin(false); |
652 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 652 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
653 | } | 653 | } |
654 | 654 | ||
655 | //US ENH : changed code to run with older MOC | 655 | //US ENH : changed code to run with older MOC |
656 | void PwM::editPwd_slot() | 656 | void PwM::editPwd_slot() |
657 | { | 657 | { |
658 | editPwd_slot(0,0,0); | 658 | editPwd_slot3(0,0,0); |
659 | } | 659 | } |
660 | 660 | ||
661 | void PwM::editPwd_slot(const QString *category) | 661 | void PwM::editPwd_slot1(const QString *category) |
662 | { | 662 | { |
663 | editPwd_slot(category, 0, 0); | 663 | editPwd_slot3(category, 0, 0); |
664 | } | 664 | } |
665 | 665 | ||
666 | void PwM::editPwd_slot(const QString *category, const int *index, | 666 | void PwM::editPwd_slot3(const QString *category, const int *index, |
667 | PwMDoc *_doc) | 667 | PwMDoc *_doc) |
668 | { | 668 | { |
669 | PwMDoc *doc; | 669 | PwMDoc *doc; |
670 | if (_doc) { | 670 | if (_doc) { |
671 | doc = _doc; | 671 | doc = _doc; |
672 | } else { | 672 | } else { |
673 | doc = curDoc(); | 673 | doc = curDoc(); |
674 | } | 674 | } |
675 | PWM_ASSERT(doc); | 675 | PWM_ASSERT(doc); |
676 | if (doc->isDocEmpty()) | 676 | if (doc->isDocEmpty()) |
677 | return; | 677 | return; |
678 | if (doc->isDeepLocked()) | 678 | if (doc->isDeepLocked()) |
679 | return; | 679 | return; |
680 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 680 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
681 | unsigned int curEntryIndex; | 681 | unsigned int curEntryIndex; |
682 | if (index) { | 682 | if (index) { |
683 | curEntryIndex = *index; | 683 | curEntryIndex = *index; |
684 | } else { | 684 | } else { |
685 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 685 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
686 | printDebug("couldn't get index. Maybe we have a binary entry here."); | 686 | printDebug("couldn't get index. Maybe we have a binary entry here."); |
687 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 687 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
688 | return; | 688 | return; |
689 | } | 689 | } |
690 | } | 690 | } |
691 | QString curCategory; | 691 | QString curCategory; |
692 | if (category) { | 692 | if (category) { |
693 | curCategory = *category; | 693 | curCategory = *category; |
694 | } else { | 694 | } else { |
695 | curCategory = view->getCurrentCategory(); | 695 | curCategory = view->getCurrentCategory(); |
696 | } | 696 | } |
697 | PwMDataItem currItem; | 697 | PwMDataItem currItem; |
698 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { | 698 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { |
699 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 699 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
700 | return; | 700 | return; |
701 | } | 701 | } |
702 | BUG_ON(currItem.binary); | 702 | BUG_ON(currItem.binary); |
703 | 703 | ||
704 | AddEntryWndImpl w; | 704 | AddEntryWndImpl w; |
705 | vector<string> catList; | 705 | vector<string> catList; |
706 | doc->getCategoryList(&catList); | 706 | doc->getCategoryList(&catList); |
707 | unsigned i, size = catList.size(); | 707 | unsigned i, size = catList.size(); |
708 | for (i = 0; i < size; ++i) { | 708 | for (i = 0; i < size; ++i) { |
709 | w.addCategory(catList[i].c_str()); | 709 | w.addCategory(catList[i].c_str()); |
710 | } | 710 | } |
711 | w.setCurrCategory(curCategory); | 711 | w.setCurrCategory(curCategory); |
712 | w.setDescription(currItem.desc.c_str()); | 712 | w.setDescription(currItem.desc.c_str()); |
713 | w.setUsername(currItem.name.c_str()); | 713 | w.setUsername(currItem.name.c_str()); |
714 | w.setPassword(currItem.pw.c_str()); | 714 | w.setPassword(currItem.pw.c_str()); |
715 | w.setUrl(currItem.url.c_str()); | 715 | w.setUrl(currItem.url.c_str()); |
716 | w.setLauncher(currItem.launcher.c_str()); | 716 | w.setLauncher(currItem.launcher.c_str()); |
717 | w.setComment(currItem.comment.c_str()); | 717 | w.setComment(currItem.comment.c_str()); |
718 | if (w.exec() == 1) { | 718 | if (w.exec() == 1) { |
719 | currItem.desc = w.getDescription().latin1(); | 719 | currItem.desc = w.getDescription().latin1(); |
720 | currItem.name = w.getUsername().latin1(); | 720 | currItem.name = w.getUsername().latin1(); |
721 | currItem.pw = w.getPassword().latin1(); | 721 | currItem.pw = w.getPassword().latin1(); |
722 | currItem.comment = w.getComment().latin1(); | 722 | currItem.comment = w.getComment().latin1(); |
723 | currItem.url = w.getUrl().latin1(); | 723 | currItem.url = w.getUrl().latin1(); |
724 | currItem.launcher = w.getLauncher().latin1(); | 724 | currItem.launcher = w.getLauncher().latin1(); |
725 | if (!doc->editEntry(curCategory, w.getCategory(), | 725 | if (!doc->editEntry(curCategory, w.getCategory(), |
726 | curEntryIndex, &currItem)) { | 726 | curEntryIndex, &currItem)) { |
727 | KMessageBox::error(this, | 727 | KMessageBox::error(this, |
728 | i18n("Couldn't edit the entry.\n" | 728 | i18n("Couldn't edit the entry.\n" |
729 | "Maybe you changed the category and " | 729 | "Maybe you changed the category and " |
730 | "this entry is already present in the new " | 730 | "this entry is already present in the new " |
731 | "category?"), | 731 | "category?"), |
732 | i18n("couldn't edit entry.")); | 732 | i18n("couldn't edit entry.")); |
733 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 733 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
734 | return; | 734 | return; |
735 | } | 735 | } |
736 | } | 736 | } |
737 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 737 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
738 | } | 738 | } |
739 | 739 | ||
740 | void PwM::deletePwd_slot() | 740 | void PwM::deletePwd_slot() |
741 | { | 741 | { |
742 | PWM_ASSERT(curDoc()); | 742 | PWM_ASSERT(curDoc()); |
743 | if (curDoc()->isDocEmpty()) | 743 | if (curDoc()->isDocEmpty()) |
744 | return; | 744 | return; |
745 | if (curDoc()->isDeepLocked()) | 745 | if (curDoc()->isDeepLocked()) |
746 | return; | 746 | return; |
747 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 747 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
748 | unsigned int curEntryIndex = 0; | 748 | unsigned int curEntryIndex = 0; |
749 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 749 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
750 | printDebug("couldn't get index"); | 750 | printDebug("couldn't get index"); |
751 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 751 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
752 | return; | 752 | return; |
753 | } | 753 | } |
754 | 754 | ||
755 | PwMDataItem currItem; | 755 | PwMDataItem currItem; |
756 | QString curCategory = view->getCurrentCategory(); | 756 | QString curCategory = view->getCurrentCategory(); |
757 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { | 757 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { |
758 | printDebug("couldn't get entry"); | 758 | printDebug("couldn't get entry"); |
759 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 759 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
760 | return; | 760 | return; |
761 | } | 761 | } |
762 | if (KMessageBox:: | 762 | if (KMessageBox:: |
763 | questionYesNo(this, | 763 | questionYesNo(this, |
764 | i18n | 764 | i18n |
765 | ("Do you really want to delete\nthe selected entry") + | 765 | ("Do you really want to delete\nthe selected entry") + |
766 | " \n\"" + QString(currItem.desc.c_str()) | 766 | " \n\"" + QString(currItem.desc.c_str()) |
767 | + "\" ?", i18n("delete?")) | 767 | + "\" ?", i18n("delete?")) |
768 | == KMessageBox::Yes) { | 768 | == KMessageBox::Yes) { |
769 | 769 | ||
770 | curDoc()->delEntry(curCategory, curEntryIndex); | 770 | curDoc()->delEntry(curCategory, curEntryIndex); |
771 | } | 771 | } |
772 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 772 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
773 | } | 773 | } |
774 | 774 | ||
775 | void PwM::changeMasterPwd_slot() | 775 | void PwM::changeMasterPwd_slot() |
776 | { | 776 | { |
777 | PWM_ASSERT(curDoc()); | 777 | PWM_ASSERT(curDoc()); |
778 | curDoc()->changeCurrentPw(); | 778 | curDoc()->changeCurrentPw(); |
779 | } | 779 | } |
780 | 780 | ||
781 | void PwM::lockWnd_slot() | 781 | void PwM::lockWnd_slot() |
782 | { | 782 | { |
783 | PWM_ASSERT(curDoc()); | 783 | PWM_ASSERT(curDoc()); |
784 | curDoc()->lockAll(true); | 784 | curDoc()->lockAll(true); |
785 | } | 785 | } |
786 | 786 | ||
787 | void PwM::deepLockWnd_slot() | 787 | void PwM::deepLockWnd_slot() |
788 | { | 788 | { |
789 | PWM_ASSERT(curDoc()); | 789 | PWM_ASSERT(curDoc()); |
790 | curDoc()->deepLock(); | 790 | curDoc()->deepLock(); |
791 | } | 791 | } |
792 | 792 | ||
793 | void PwM::unlockWnd_slot() | 793 | void PwM::unlockWnd_slot() |
794 | { | 794 | { |
795 | PWM_ASSERT(curDoc()); | 795 | PWM_ASSERT(curDoc()); |
796 | curDoc()->lockAll(false); | 796 | curDoc()->lockAll(false); |
797 | } | 797 | } |
798 | 798 | ||
799 | void PwM::config_slot() | 799 | void PwM::config_slot() |
800 | { | 800 | { |
801 | int oldStyle = conf()->confWndMainViewStyle(); | 801 | int oldStyle = conf()->confWndMainViewStyle(); |
802 | #ifdef PWM_EMBEDDED | 802 | #ifdef PWM_EMBEDDED |
803 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); | 803 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); |
804 | 804 | ||
805 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); | 805 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); |
806 | ConfigureDialog->addModule(pwmcfg ); | 806 | ConfigureDialog->addModule(pwmcfg ); |
807 | 807 | ||
808 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 808 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
809 | ConfigureDialog->addModule(kdelibcfg ); | 809 | ConfigureDialog->addModule(kdelibcfg ); |
810 | 810 | ||
811 | #ifndef DESKTOP_VERSION | 811 | #ifndef DESKTOP_VERSION |
812 | ConfigureDialog->showMaximized(); | 812 | ConfigureDialog->showMaximized(); |
813 | #endif | 813 | #endif |
814 | if ( ConfigureDialog->exec() ) | 814 | if ( ConfigureDialog->exec() ) |
815 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 815 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
816 | delete ConfigureDialog; | 816 | delete ConfigureDialog; |
817 | 817 | ||
818 | #else //PWM_EMBEDDED | 818 | #else //PWM_EMBEDDED |
819 | // display the configuration window (modal mode) | 819 | // display the configuration window (modal mode) |
820 | if (!conf()->showConfWnd(this)) | 820 | if (!conf()->showConfWnd(this)) |
821 | return; | 821 | return; |
822 | #endif | 822 | #endif |
823 | 823 | ||
824 | int newStyle = conf()->confWndMainViewStyle(); | 824 | int newStyle = conf()->confWndMainViewStyle(); |
825 | // reinitialize tray | 825 | // reinitialize tray |
826 | init->initTray(); | 826 | init->initTray(); |
827 | // reinitialize KWallet emulation | 827 | // reinitialize KWallet emulation |
828 | init->initKWalletEmu(); | 828 | init->initKWalletEmu(); |
829 | 829 | ||
830 | PwMDocList *_dl = PwMDoc::getOpenDocList(); | 830 | PwMDocList *_dl = PwMDoc::getOpenDocList(); |
831 | const vector<PwMDocList::listItem> *dl = _dl->getList(); | 831 | const vector<PwMDocList::listItem> *dl = _dl->getList(); |
832 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), | 832 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), |
833 | end = dl->end(); | 833 | end = dl->end(); |
834 | PwMDoc *doc; | 834 | PwMDoc *doc; |
835 | while (i != end) { | 835 | while (i != end) { |
836 | doc = (*i).doc; | 836 | doc = (*i).doc; |
837 | // unlock-without-mpw timeout | 837 | // unlock-without-mpw timeout |
838 | doc->timer()->start(DocTimer::id_mpwTimer); | 838 | doc->timer()->start(DocTimer::id_mpwTimer); |
839 | // auto-lock timeout | 839 | // auto-lock timeout |
840 | doc->timer()->start(DocTimer::id_autoLockTimer); | 840 | doc->timer()->start(DocTimer::id_autoLockTimer); |
841 | ++i; | 841 | ++i; |
842 | } | 842 | } |
843 | 843 | ||
844 | const QValueList<PwM *> *ml = init->mainWndList(); | 844 | const QValueList<PwM *> *ml = init->mainWndList(); |
845 | #ifndef PWM_EMBEDDED | 845 | #ifndef PWM_EMBEDDED |
846 | QValueList<PwM *>::const_iterator i2 = ml->begin(), | 846 | QValueList<PwM *>::const_iterator i2 = ml->begin(), |
847 | end2 = ml->end(); | 847 | end2 = ml->end(); |
848 | #else | 848 | #else |
849 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), | 849 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), |
850 | end2 = ml->end(); | 850 | end2 = ml->end(); |
851 | #endif | 851 | #endif |
852 | PwM *pwm; | 852 | PwM *pwm; |
853 | while (i2 != end2) { | 853 | while (i2 != end2) { |
854 | pwm = *i2; | 854 | pwm = *i2; |
855 | // reinitialize the window style. | 855 | // reinitialize the window style. |
856 | if (oldStyle != newStyle) | 856 | if (oldStyle != newStyle) |
857 | pwm->curView()->initStyle(newStyle); | 857 | pwm->curView()->initStyle(newStyle); |
858 | // set the new font | 858 | // set the new font |
859 | pwm->curView()->setFont(conf()->confGlobEntryFont()); | 859 | pwm->curView()->setFont(conf()->confGlobEntryFont()); |
860 | ++i2; | 860 | ++i2; |
861 | } | 861 | } |
862 | } | 862 | } |
863 | 863 | ||
864 | void PwM::activateMpButton(bool activate) | 864 | void PwM::activateMpButton(bool activate) |
865 | { | 865 | { |
866 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); | 866 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); |
867 | } | 867 | } |
868 | 868 | ||
869 | void PwM::closeEvent(QCloseEvent *e) | 869 | void PwM::closeEvent(QCloseEvent *e) |
870 | { | 870 | { |
871 | e->accept(); | 871 | e->accept(); |
872 | } | 872 | } |
873 | 873 | ||
874 | void PwM::docClosed(PwMDoc *doc) | 874 | void PwM::docClosed(PwMDoc *doc) |
875 | { | 875 | { |
876 | PARAM_UNUSED(doc); | 876 | PARAM_UNUSED(doc); |
877 | PWM_ASSERT(doc == curDoc()); | 877 | PWM_ASSERT(doc == curDoc()); |
878 | close(); | 878 | close(); |
879 | } | 879 | } |
880 | 880 | ||
881 | void PwM::find_slot() | 881 | void PwM::find_slot() |
882 | { | 882 | { |
883 | PWM_ASSERT(curDoc()); | 883 | PWM_ASSERT(curDoc()); |
884 | if (curDoc()->isDocEmpty()) | 884 | if (curDoc()->isDocEmpty()) |
885 | return; | 885 | return; |
886 | if (curDoc()->isDeepLocked()) | 886 | if (curDoc()->isDeepLocked()) |
887 | return; | 887 | return; |
888 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 888 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
889 | FindWndImpl findWnd(view); | 889 | FindWndImpl findWnd(view); |
890 | findWnd.exec(); | 890 | findWnd.exec(); |
891 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 891 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
892 | } | 892 | } |
893 | 893 | ||
894 | void PwM::exportToText() | 894 | void PwM::exportToText() |
895 | { | 895 | { |
896 | PWM_ASSERT(curDoc()); | 896 | PWM_ASSERT(curDoc()); |
897 | if (curDoc()->isDocEmpty()) { | 897 | if (curDoc()->isDocEmpty()) { |
898 | KMessageBox::information(this, | 898 | KMessageBox::information(this, |
899 | i18n | 899 | i18n |
900 | ("Sorry, there's nothing to export.\n" | 900 | ("Sorry, there's nothing to export.\n" |
901 | "Please first add some passwords."), | 901 | "Please first add some passwords."), |
902 | i18n("nothing to do")); | 902 | i18n("nothing to do")); |
903 | return; | 903 | return; |
904 | } | 904 | } |
905 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 905 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
906 | QString fn(KFileDialog::getSaveFileName(QString::null, | 906 | QString fn(KFileDialog::getSaveFileName(QString::null, |
907 | i18n("*|plain-text file"), | 907 | i18n("*|plain-text file"), |
908 | this)); | 908 | this)); |
909 | if (fn == "") { | 909 | if (fn == "") { |
910 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 910 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
911 | return; | 911 | return; |
912 | } | 912 | } |
913 | 913 | ||
914 | PwMerror ret = curDoc()->exportToText(&fn); | 914 | PwMerror ret = curDoc()->exportToText(&fn); |
915 | if (ret != e_success) { | 915 | if (ret != e_success) { |
916 | KMessageBox::error(this, | 916 | KMessageBox::error(this, |
917 | i18n("Error: Couldn't write to file.\n" | 917 | i18n("Error: Couldn't write to file.\n" |
918 | "Please check if you have permission to write " | 918 | "Please check if you have permission to write " |
919 | "to the file in that directory."), | 919 | "to the file in that directory."), |
920 | i18n("error while writing")); | 920 | i18n("error while writing")); |
921 | } else | 921 | } else |
922 | showStatMsg(i18n("Successfully exported data.")); | 922 | showStatMsg(i18n("Successfully exported data.")); |
923 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 923 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
924 | } | 924 | } |
925 | 925 | ||
926 | bool PwM::importFromText() | 926 | bool PwM::importFromText() |
927 | { | 927 | { |
928 | if (!isVirgin()) { | 928 | if (!isVirgin()) { |
929 | if (KMessageBox::questionYesNo(this, | 929 | if (KMessageBox::questionYesNo(this, |
930 | i18n("Do you want to import the data " | 930 | i18n("Do you want to import the data " |
931 | "into the current document? (If you " | 931 | "into the current document? (If you " |
932 | "select \"no\", a new document will be " | 932 | "select \"no\", a new document will be " |
933 | "opened.)"), | 933 | "opened.)"), |
934 | i18n("import into this document?")) | 934 | i18n("import into this document?")) |
935 | == KMessageBox::No) { | 935 | == KMessageBox::No) { |
936 | // import the data to a new window. | 936 | // import the data to a new window. |
937 | PwM *newInstance = init->createMainWnd(); | 937 | PwM *newInstance = init->createMainWnd(); |
938 | bool ok = newInstance->importFromText(); | 938 | bool ok = newInstance->importFromText(); |
939 | if (!ok) { | 939 | if (!ok) { |
940 | newInstance->setForceQuit(true); | 940 | newInstance->setForceQuit(true); |
941 | delete_and_null(newInstance); | 941 | delete_and_null(newInstance); |
942 | } | 942 | } |
943 | return ok; | 943 | return ok; |
944 | } | 944 | } |
945 | } | 945 | } |
946 | 946 | ||
947 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 947 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
948 | PwMerror ret; | 948 | PwMerror ret; |
949 | QString path(KFileDialog::getOpenFileName(QString::null, | 949 | QString path(KFileDialog::getOpenFileName(QString::null, |
950 | i18n("*|PWM-exported text file"), | 950 | i18n("*|PWM-exported text file"), |
951 | this)); | 951 | this)); |
952 | if (path == "") | 952 | if (path == "") |
953 | goto cancelImport; | 953 | goto cancelImport; |
954 | 954 | ||
955 | ret = curDoc()->importFromText(&path, 0); | 955 | ret = curDoc()->importFromText(&path, 0); |
956 | if (ret == e_fileFormat) { | 956 | if (ret == e_fileFormat) { |
957 | KMessageBox::error(this, | 957 | KMessageBox::error(this, |
958 | i18n("Could not read file-format.\n" | 958 | i18n("Could not read file-format.\n" |
959 | "This seems to be _not_ a valid file " | 959 | "This seems to be _not_ a valid file " |
960 | "exported by PwM."), | 960 | "exported by PwM."), |
961 | i18n("invalid file-format")); | 961 | i18n("invalid file-format")); |
962 | goto cancelImport; | 962 | goto cancelImport; |
963 | } else if (ret == e_invalidArg) { | 963 | } else if (ret == e_invalidArg) { |
964 | BUG(); | 964 | BUG(); |
965 | goto cancelImport; | 965 | goto cancelImport; |
966 | } else if (ret != e_success) { | 966 | } else if (ret != e_success) { |
967 | KMessageBox::error(this, | 967 | KMessageBox::error(this, |
968 | i18n("Could not import file!\n" | 968 | i18n("Could not import file!\n" |
969 | "Do you have permission to read this file? " | 969 | "Do you have permission to read this file? " |
970 | "Do you have enough free memory?"), | 970 | "Do you have enough free memory?"), |
971 | i18n("import failed")); | 971 | i18n("import failed")); |
972 | goto cancelImport; | 972 | goto cancelImport; |
973 | } | 973 | } |
974 | setVirgin(false); | 974 | setVirgin(false); |
975 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 975 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
976 | return true; | 976 | return true; |
977 | 977 | ||
978 | cancelImport: | 978 | cancelImport: |
979 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 979 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
980 | return false; | 980 | return false; |
981 | } | 981 | } |
982 | 982 | ||
983 | void PwM::exportToGpasman() | 983 | void PwM::exportToGpasman() |
984 | { | 984 | { |
985 | PWM_ASSERT(curDoc()); | 985 | PWM_ASSERT(curDoc()); |
986 | if (curDoc()->isDocEmpty()) { | 986 | if (curDoc()->isDocEmpty()) { |
987 | KMessageBox::information(this, | 987 | KMessageBox::information(this, |
988 | i18n | 988 | i18n |
989 | ("Sorry, there's nothing to export.\n" | 989 | ("Sorry, there's nothing to export.\n" |
990 | "Please first add some passwords."), | 990 | "Please first add some passwords."), |
991 | i18n("nothing to do")); | 991 | i18n("nothing to do")); |
992 | return; | 992 | return; |
993 | } | 993 | } |
994 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 994 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
995 | QString fn(KFileDialog::getSaveFileName(QString::null, | 995 | QString fn(KFileDialog::getSaveFileName(QString::null, |
996 | i18n("*|Gpasman or Kpasman file"), | 996 | i18n("*|Gpasman or Kpasman file"), |
997 | this)); | 997 | this)); |
998 | if (fn == "") { | 998 | if (fn == "") { |
999 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 999 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1000 | return; | 1000 | return; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | PwMerror ret = curDoc()->exportToGpasman(&fn); | 1003 | PwMerror ret = curDoc()->exportToGpasman(&fn); |
1004 | if (ret != e_success) { | 1004 | if (ret != e_success) { |
1005 | if (ret == e_noPw) { | 1005 | if (ret == e_noPw) { |
1006 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1006 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1007 | return; | 1007 | return; |
1008 | } | 1008 | } |
1009 | KMessageBox::error(this, | 1009 | KMessageBox::error(this, |
1010 | i18n("Error: Couldn't write to file.\n" | 1010 | i18n("Error: Couldn't write to file.\n" |
1011 | "Please check if you have permission to write " | 1011 | "Please check if you have permission to write " |
1012 | "to the file in that directory."), | 1012 | "to the file in that directory."), |
1013 | i18n("error while writing")); | 1013 | i18n("error while writing")); |
1014 | } else | 1014 | } else |
1015 | showStatMsg(i18n("Successfully exported data.")); | 1015 | showStatMsg(i18n("Successfully exported data.")); |
1016 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1016 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | void PwM::exportToKWallet() | 1019 | void PwM::exportToKWallet() |
1020 | { | 1020 | { |
1021 | #ifdef CONFIG_KWALLETIF | 1021 | #ifdef CONFIG_KWALLETIF |
1022 | if (!checkAndAskForKWalletEmu()) | 1022 | if (!checkAndAskForKWalletEmu()) |
1023 | return; | 1023 | return; |
1024 | PWM_ASSERT(curDoc()); | 1024 | PWM_ASSERT(curDoc()); |
1025 | if (curDoc()->isDocEmpty()) { | 1025 | if (curDoc()->isDocEmpty()) { |
1026 | KMessageBox::information(this, | 1026 | KMessageBox::information(this, |
1027 | i18n | 1027 | i18n |
1028 | ("Sorry, there's nothing to export.\n" | 1028 | ("Sorry, there's nothing to export.\n" |
1029 | "Please first add some passwords."), | 1029 | "Please first add some passwords."), |
1030 | i18n("nothing to do")); | 1030 | i18n("nothing to do")); |
1031 | init->initKWalletEmu(); | 1031 | init->initKWalletEmu(); |
1032 | return; | 1032 | return; |
1033 | } | 1033 | } |
1034 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1034 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1035 | KWalletIf walletIf(this); | 1035 | KWalletIf walletIf(this); |
1036 | if (walletIf.kwalletExport(curDoc())) { | 1036 | if (walletIf.kwalletExport(curDoc())) { |
1037 | KMessageBox::information(this, | 1037 | KMessageBox::information(this, |
1038 | i18n("Successfully exported the data of the current " | 1038 | i18n("Successfully exported the data of the current " |
1039 | "document to KWallet."), | 1039 | "document to KWallet."), |
1040 | i18n("Successfully exported data.")); | 1040 | i18n("Successfully exported data.")); |
1041 | showStatMsg(i18n("Successfully exported data.")); | 1041 | showStatMsg(i18n("Successfully exported data.")); |
1042 | } | 1042 | } |
1043 | init->initKWalletEmu(); | 1043 | init->initKWalletEmu(); |
1044 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1044 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1045 | #endif // CONFIG_KWALLETIF | 1045 | #endif // CONFIG_KWALLETIF |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | bool PwM::importFromGpasman() | 1048 | bool PwM::importFromGpasman() |
1049 | { | 1049 | { |
1050 | if (!isVirgin()) { | 1050 | if (!isVirgin()) { |
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h index fe1f7a1..116bc66 100644 --- a/pwmanager/pwmanager/pwm.h +++ b/pwmanager/pwmanager/pwm.h | |||
@@ -1,292 +1,294 @@ | |||
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.0.1 of pwmanager | 14 | * This file is originaly based on version 1.0.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 __PWM_H | 20 | #ifndef __PWM_H |
21 | #define __PWM_H | 21 | #define __PWM_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <kpopupmenu.h> | 24 | #include <kpopupmenu.h> |
25 | #include <klistview.h> | 25 | #include <klistview.h> |
26 | #include <kmainwindow.h> | 26 | #include <kmainwindow.h> |
27 | 27 | ||
28 | #ifndef PWM_EMBEDDED | 28 | #ifndef PWM_EMBEDDED |
29 | #include <kwin.h> | 29 | #include <kwin.h> |
30 | #include <kapp.h> | 30 | #include <kapp.h> |
31 | #include <kdeversion.h> | 31 | #include <kdeversion.h> |
32 | #else | 32 | #else |
33 | #include <ksyncmanager.h> | 33 | #include <ksyncmanager.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <kaction.h> | 36 | #include <kaction.h> |
37 | 37 | ||
38 | #include <qglobal.h> | 38 | #include <qglobal.h> |
39 | 39 | ||
40 | #include "pwmview.h" | 40 | #include "pwmview.h" |
41 | #include "pwmexception.h" | 41 | #include "pwmexception.h" |
42 | 42 | ||
43 | 43 | ||
44 | /** timeout for displaying a message on the status-bar (in seconds) */ | 44 | /** timeout for displaying a message on the status-bar (in seconds) */ |
45 | #define STATUSBAR_MSG_TIMEOUT5 | 45 | #define STATUSBAR_MSG_TIMEOUT5 |
46 | 46 | ||
47 | 47 | ||
48 | class PwMInit; | 48 | class PwMInit; |
49 | class KSyncManager; | 49 | class KSyncManager; |
50 | 50 | ||
51 | /** PwM is the base class of the project */ | 51 | /** PwM is the base class of the project */ |
52 | #ifndef PWM_EMBEDDED | 52 | #ifndef PWM_EMBEDDED |
53 | //MOC_SKIP_BEGIN | 53 | //MOC_SKIP_BEGIN |
54 | class PwM : public KMainWindow | 54 | class PwM : public KMainWindow |
55 | //MOC_SKIP_END | 55 | //MOC_SKIP_END |
56 | #else | 56 | #else |
57 | class PwM : public KMainWindow, public KSyncInterface | 57 | class PwM : public KMainWindow, public KSyncInterface |
58 | #endif | 58 | #endif |
59 | { | 59 | { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | public: | 61 | public: |
62 | friend class PwMView; | 62 | friend class PwMView; |
63 | /** construtor */ | 63 | /** construtor */ |
64 | PwM(PwMInit *_init, PwMDoc *doc, | 64 | PwM(PwMInit *_init, PwMDoc *doc, |
65 | bool virginity = true, | 65 | bool virginity = true, |
66 | QWidget* parent = 0, const char *name = 0); | 66 | QWidget* parent = 0, const char *name = 0); |
67 | /** destructor */ | 67 | /** destructor */ |
68 | ~PwM(); | 68 | ~PwM(); |
69 | 69 | ||
70 | /** copy some text to the global clipboard */ | 70 | /** copy some text to the global clipboard */ |
71 | static void copyToClipboard(const QString &s); | 71 | static void copyToClipboard(const QString &s); |
72 | 72 | ||
73 | /** returns pointer to the view */ | 73 | /** returns pointer to the view */ |
74 | PwMView * curView() | 74 | PwMView * curView() |
75 | { return view; } | 75 | { return view; } |
76 | /** returns pointer to the currently using document. */ | 76 | /** returns pointer to the currently using document. */ |
77 | PwMDoc * curDoc() | 77 | PwMDoc * curDoc() |
78 | { return curView()->document(); } | 78 | { return curView()->document(); } |
79 | /** open a new doc with the given filename */ | 79 | /** open a new doc with the given filename */ |
80 | PwMDoc * openDoc(QString filename, bool openDeepLocked = false); | 80 | PwMDoc * openDoc(QString filename, bool openDeepLocked = false); |
81 | /** show a message on the global status bar. | 81 | /** show a message on the global status bar. |
82 | * The message times out after some seconds. | 82 | * The message times out after some seconds. |
83 | */ | 83 | */ |
84 | void showStatMsg(const QString &msg); | 84 | void showStatMsg(const QString &msg); |
85 | /** ask the user where to save the doc (if it has not been saved, yet) | 85 | /** ask the user where to save the doc (if it has not been saved, yet) |
86 | * and write the data to disk. | 86 | * and write the data to disk. |
87 | */ | 87 | */ |
88 | bool save(); | 88 | bool save(); |
89 | /** ask the user where to save the doc | 89 | /** ask the user where to save the doc |
90 | * and write the data to disk. | 90 | * and write the data to disk. |
91 | */ | 91 | */ |
92 | bool saveAs(); | 92 | bool saveAs(); |
93 | /** force quit. Quit this window, always! Don't minimize it */ | 93 | /** force quit. Quit this window, always! Don't minimize it */ |
94 | bool isForceQuit() | 94 | bool isForceQuit() |
95 | { return forceQuit; } | 95 | { return forceQuit; } |
96 | /** set forceQuit */ | 96 | /** set forceQuit */ |
97 | void setForceQuit(bool force) | 97 | void setForceQuit(bool force) |
98 | { forceQuit = force; } | 98 | { forceQuit = force; } |
99 | /** force minimize this window */ | 99 | /** force minimize this window */ |
100 | bool isForceMinimizeToTray() | 100 | bool isForceMinimizeToTray() |
101 | { return forceMinimizeToTray; } | 101 | { return forceMinimizeToTray; } |
102 | /** set forceMinimizeToTray */ | 102 | /** set forceMinimizeToTray */ |
103 | void setForceMinimizeToTray(bool force) | 103 | void setForceMinimizeToTray(bool force) |
104 | { forceMinimizeToTray = force; } | 104 | { forceMinimizeToTray = force; } |
105 | 105 | ||
106 | public slots: | 106 | public slots: |
107 | /** file/new triggered */ | 107 | /** file/new triggered */ |
108 | void new_slot(); | 108 | void new_slot(); |
109 | /** file/open triggered */ | 109 | /** file/open triggered */ |
110 | //US ENH | 110 | //US ENH |
111 | void open_slot(); | 111 | void open_slot(); |
112 | void open_slot(QString fn); | 112 | void open_slot(QString fn); |
113 | /** file/close triggered */ | 113 | /** file/close triggered */ |
114 | void close_slot(); | 114 | void close_slot(); |
115 | /** file/quit triggered */ | 115 | /** file/quit triggered */ |
116 | void quitButton_slot(); | 116 | void quitButton_slot(); |
117 | /** file/save triggered */ | 117 | /** file/save triggered */ |
118 | void save_slot(); | 118 | void save_slot(); |
119 | /** file/saveAs triggered */ | 119 | /** file/saveAs triggered */ |
120 | void saveAs_slot(); | 120 | void saveAs_slot(); |
121 | /** file/export/text triggered */ | 121 | /** file/export/text triggered */ |
122 | void exportToText(); | 122 | void exportToText(); |
123 | /** file/export/gpasman triggered */ | 123 | /** file/export/gpasman triggered */ |
124 | void exportToGpasman(); | 124 | void exportToGpasman(); |
125 | /** file/export/kwallet triggered */ | 125 | /** file/export/kwallet triggered */ |
126 | void exportToKWallet(); | 126 | void exportToKWallet(); |
127 | /** file/import/text triggered */ | 127 | /** file/import/text triggered */ |
128 | bool importFromText(); | 128 | bool importFromText(); |
129 | /** file/import/gpasman triggered */ | 129 | /** file/import/gpasman triggered */ |
130 | bool importFromGpasman(); | 130 | bool importFromGpasman(); |
131 | /** file/import/kwallet triggered */ | 131 | /** file/import/kwallet triggered */ |
132 | bool importKWallet(); | 132 | bool importKWallet(); |
133 | /** file/print triggered */ | 133 | /** file/print triggered */ |
134 | void print_slot(); | 134 | void print_slot(); |
135 | /** manage/add triggered */ | 135 | /** manage/add triggered */ |
136 | //US ENH : changed code to run with older MOC | 136 | //US ENH : changed code to run with older MOC |
137 | |||
137 | void addPwd_slot(); | 138 | void addPwd_slot(); |
138 | void addPwd_slot(QString *pw, PwMDoc *_doc); | 139 | void addPwd_slot1(QString *pw, PwMDoc *_doc); |
139 | /** manage/edit triggered */ | 140 | /** manage/edit triggered */ |
140 | //US ENH : changed code to run with older MOC | 141 | //US ENH : changed code to run with older MOC |
141 | void editPwd_slot(); | 142 | void editPwd_slot(); |
142 | void editPwd_slot(const QString *category); | 143 | void editPwd_slot1(const QString *category); |
143 | void editPwd_slot(const QString *category = 0, const int *index = 0, | 144 | void editPwd_slot3(const QString *category = 0, const int *index = 0, |
144 | PwMDoc *_doc = 0); | 145 | PwMDoc *_doc = 0); |
146 | |||
145 | /** manage/delete triggered */ | 147 | /** manage/delete triggered */ |
146 | void deletePwd_slot(); | 148 | void deletePwd_slot(); |
147 | /** execute the "Launcher" entry */ | 149 | /** execute the "Launcher" entry */ |
148 | void execLauncher_slot(); | 150 | void execLauncher_slot(); |
149 | /** open browser with URL entry */ | 151 | /** open browser with URL entry */ |
150 | void goToURL_slot(); | 152 | void goToURL_slot(); |
151 | /** manage/changeMasterPwd triggered */ | 153 | /** manage/changeMasterPwd triggered */ |
152 | void changeMasterPwd_slot(); | 154 | void changeMasterPwd_slot(); |
153 | /** lock current document */ | 155 | /** lock current document */ |
154 | void lockWnd_slot(); | 156 | void lockWnd_slot(); |
155 | /** deeplock current document */ | 157 | /** deeplock current document */ |
156 | void deepLockWnd_slot(); | 158 | void deepLockWnd_slot(); |
157 | /** window/unlock triggered */ | 159 | /** window/unlock triggered */ |
158 | void unlockWnd_slot(); | 160 | void unlockWnd_slot(); |
159 | /** find item */ | 161 | /** find item */ |
160 | void find_slot(); | 162 | void find_slot(); |
161 | /** configure clicked */ | 163 | /** configure clicked */ |
162 | void config_slot(); | 164 | void config_slot(); |
163 | /** (de)activate the "change master pw" button in the menu-bar */ | 165 | /** (de)activate the "change master pw" button in the menu-bar */ |
164 | void activateMpButton(bool activate = true); | 166 | void activateMpButton(bool activate = true); |
165 | /** generate a new chipcard */ | 167 | /** generate a new chipcard */ |
166 | void genNewCard_slot(); | 168 | void genNewCard_slot(); |
167 | /** completely erase the current card */ | 169 | /** completely erase the current card */ |
168 | void eraseCard_slot(); | 170 | void eraseCard_slot(); |
169 | /** returns the ID number of the current card */ | 171 | /** returns the ID number of the current card */ |
170 | void readCardId_slot(); | 172 | void readCardId_slot(); |
171 | /** make backup image of the current card */ | 173 | /** make backup image of the current card */ |
172 | void makeCardBackup_slot(); | 174 | void makeCardBackup_slot(); |
173 | /** write backup image to current card */ | 175 | /** write backup image to current card */ |
174 | void replayCardBackup_slot(); | 176 | void replayCardBackup_slot(); |
175 | 177 | ||
176 | #ifdef PWM_EMBEDDED | 178 | #ifdef PWM_EMBEDDED |
177 | void whatsnew_slot(); | 179 | void whatsnew_slot(); |
178 | void showLicense_slot(); | 180 | void showLicense_slot(); |
179 | void faq_slot(); | 181 | void faq_slot(); |
180 | void createAboutData_slot(); | 182 | void createAboutData_slot(); |
181 | void syncHowTo_slot(); | 183 | void syncHowTo_slot(); |
182 | #endif | 184 | #endif |
183 | 185 | ||
184 | protected: | 186 | protected: |
185 | /** is this window virgin? */ | 187 | /** is this window virgin? */ |
186 | bool isVirgin() | 188 | bool isVirgin() |
187 | { return virgin; } | 189 | { return virgin; } |
188 | /** add/remove virginity */ | 190 | /** add/remove virginity */ |
189 | void setVirgin(bool v); | 191 | void setVirgin(bool v); |
190 | /** initialize the menubar */ | 192 | /** initialize the menubar */ |
191 | void initMenubar(); | 193 | void initMenubar(); |
192 | /** initialize the toolbar */ | 194 | /** initialize the toolbar */ |
193 | void initToolbar(); | 195 | void initToolbar(); |
194 | /** initialize the window-metrics */ | 196 | /** initialize the window-metrics */ |
195 | void initMetrics(); | 197 | void initMetrics(); |
196 | /** close-event */ | 198 | /** close-event */ |
197 | void closeEvent(QCloseEvent *e); | 199 | void closeEvent(QCloseEvent *e); |
198 | /** creates a new PwM-ListView and returns it */ | 200 | /** creates a new PwM-ListView and returns it */ |
199 | PwMView * makeNewListView(PwMDoc *doc); | 201 | PwMView * makeNewListView(PwMDoc *doc); |
200 | /** Window hide-event */ | 202 | /** Window hide-event */ |
201 | void hideEvent(QHideEvent *); | 203 | void hideEvent(QHideEvent *); |
202 | /** is this window minimized? */ | 204 | /** is this window minimized? */ |
203 | bool isMinimized() | 205 | bool isMinimized() |
204 | { | 206 | { |
205 | #ifndef PWM_EMBEDDED | 207 | #ifndef PWM_EMBEDDED |
206 | #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) | 208 | #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) |
207 | return KWin::windowInfo(winId()).isMinimized(); | 209 | return KWin::windowInfo(winId()).isMinimized(); |
208 | #else // KDE_VERSION | 210 | #else // KDE_VERSION |
209 | return KWin::info(winId()).isIconified(); | 211 | return KWin::info(winId()).isIconified(); |
210 | #endif // KDE_VERSION | 212 | #endif // KDE_VERSION |
211 | #else | 213 | #else |
212 | return false; | 214 | return false; |
213 | #endif | 215 | #endif |
214 | } | 216 | } |
215 | /** window got the focus */ | 217 | /** window got the focus */ |
216 | void focusInEvent(QFocusEvent *e); | 218 | void focusInEvent(QFocusEvent *e); |
217 | /** update the caption string */ | 219 | /** update the caption string */ |
218 | void updateCaption(); | 220 | void updateCaption(); |
219 | #ifdef CONFIG_KWALLETIF | 221 | #ifdef CONFIG_KWALLETIF |
220 | /** check if kwalletemu is enabled and ask the user what to do */ | 222 | /** check if kwalletemu is enabled and ask the user what to do */ |
221 | bool checkAndAskForKWalletEmu(); | 223 | bool checkAndAskForKWalletEmu(); |
222 | #endif // CONFIG_KWALLETIF | 224 | #endif // CONFIG_KWALLETIF |
223 | 225 | ||
224 | protected slots: | 226 | protected slots: |
225 | /** doc got closed */ | 227 | /** doc got closed */ |
226 | void docClosed(PwMDoc *doc); | 228 | void docClosed(PwMDoc *doc); |
227 | 229 | ||
228 | signals: | 230 | signals: |
229 | /** window got closed (by user or someone else) */ | 231 | /** window got closed (by user or someone else) */ |
230 | void closed(PwM *wnd); | 232 | void closed(PwM *wnd); |
231 | /** window got the focus (was brought to foreground) */ | 233 | /** window got the focus (was brought to foreground) */ |
232 | void gotFocus(PwM *wnd); | 234 | void gotFocus(PwM *wnd); |
233 | /** window lost the focus */ | 235 | /** window lost the focus */ |
234 | void lostFocus(PwM *wnd); | 236 | void lostFocus(PwM *wnd); |
235 | 237 | ||
236 | protected: | 238 | protected: |
237 | /** pointer to the view active in this KMainWindow */ | 239 | /** pointer to the view active in this KMainWindow */ |
238 | PwMView *view; | 240 | PwMView *view; |
239 | /** pointer to the init class */ | 241 | /** pointer to the init class */ |
240 | PwMInit *init; | 242 | PwMInit *init; |
241 | /** has this window already lost its virginity? | 243 | /** has this window already lost its virginity? |
242 | * Means is there an open working document | 244 | * Means is there an open working document |
243 | */ | 245 | */ |
244 | bool virgin; | 246 | bool virgin; |
245 | /** "file" popup-menu */ | 247 | /** "file" popup-menu */ |
246 | KPopupMenu *filePopup; | 248 | KPopupMenu *filePopup; |
247 | 249 | ||
248 | /** "manage" popup-menu */ | 250 | /** "manage" popup-menu */ |
249 | KPopupMenu *managePopup; | 251 | KPopupMenu *managePopup; |
250 | #ifdef CONFIG_KEYCARD | 252 | #ifdef CONFIG_KEYCARD |
251 | /** "chipcard" popup-menu */ | 253 | /** "chipcard" popup-menu */ |
252 | KPopupMenu *chipcardPopup; | 254 | KPopupMenu *chipcardPopup; |
253 | #endif // CONFIG_KEYCARD | 255 | #endif // CONFIG_KEYCARD |
254 | /** "view" popup-menu */ | 256 | /** "view" popup-menu */ |
255 | KPopupMenu *viewPopup; | 257 | KPopupMenu *viewPopup; |
256 | /** "options" popup-menu */ | 258 | /** "options" popup-menu */ |
257 | KPopupMenu *optionsPopup; | 259 | KPopupMenu *optionsPopup; |
258 | /** "help" popup-menu */ | 260 | /** "help" popup-menu */ |
259 | KPopupMenu *helpPopup; | 261 | KPopupMenu *helpPopup; |
260 | /** "export" popup-menu */ | 262 | /** "export" popup-menu */ |
261 | KPopupMenu *exportPopup; | 263 | KPopupMenu *exportPopup; |
262 | /** "import" popup-menu */ | 264 | /** "import" popup-menu */ |
263 | KPopupMenu *importPopup; | 265 | KPopupMenu *importPopup; |
264 | /** force quit this window? */ | 266 | /** force quit this window? */ |
265 | bool forceQuit; | 267 | bool forceQuit; |
266 | /** force minimize this window to the tray */ | 268 | /** force minimize this window to the tray */ |
267 | bool forceMinimizeToTray; | 269 | bool forceMinimizeToTray; |
268 | 270 | ||
269 | 271 | ||
270 | 272 | ||
271 | 273 | ||
272 | private: | 274 | private: |
273 | #ifdef PWM_EMBEDDED | 275 | #ifdef PWM_EMBEDDED |
274 | //this are the overwritten callbackmethods from the syncinterface | 276 | //this are the overwritten callbackmethods from the syncinterface |
275 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 277 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
276 | 278 | ||
277 | // LR ******************************* | 279 | // LR ******************************* |
278 | // sync stuff! | 280 | // sync stuff! |
279 | QPopupMenu *syncPopup; | 281 | QPopupMenu *syncPopup; |
280 | KSyncManager* syncManager; | 282 | KSyncManager* syncManager; |
281 | #endif | 283 | #endif |
282 | 284 | ||
283 | 285 | ||
284 | 286 | ||
285 | 287 | ||
286 | 288 | ||
287 | 289 | ||
288 | 290 | ||
289 | 291 | ||
290 | }; | 292 | }; |
291 | 293 | ||
292 | #endif | 294 | #endif |
diff --git a/pwmanager/pwmanager/pwmanager.pro b/pwmanager/pwmanager/pwmanager.pro index 34f7403..7f39c76 100644 --- a/pwmanager/pwmanager/pwmanager.pro +++ b/pwmanager/pwmanager/pwmanager.pro | |||
@@ -1,168 +1,173 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | 3 | DESTDIR= ../../bin | |
4 | |||
5 | TARGET = pwmpi | 4 | TARGET = pwmpi |
6 | OBJECTS_DIR = obj/$(PLATFORM) | 5 | include( ../../variables.pri ) |
7 | MOC_DIR = moc/$(PLATFORM) | ||
8 | DESTDIR=$(QPEDIR)/bin | ||
9 | 6 | ||
10 | INCLUDEPATH += . ../../ ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils $(QPEDIR)/include | 7 | INCLUDEPATH += . ../../ ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils |
11 | DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION | 8 | DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION |
12 | 9 | ||
13 | #enable this setting if you want debugoutput for pwmanager | 10 | #enable this setting if you want debugoutput for pwmanager |
14 | #DEFINES += CONFIG_DEBUG | 11 | #DEFINES += CONFIG_DEBUG |
15 | LIBS += -L../libcrypt/$(PLATFORM) | 12 | LIBS += -L../libcrypt/ |
13 | LIBS += -L../../bin/ | ||
16 | LIBS += -lmicrokde | 14 | LIBS += -lmicrokde |
17 | LIBS += -lmicroqtcompat | ||
18 | LIBS += -lmicrokdepim | 15 | LIBS += -lmicrokdepim |
19 | LIBS += -L$(QPEDIR)/lib | ||
20 | LIBS += -lqpe | ||
21 | LIBS += -lzlib | 16 | LIBS += -lzlib |
22 | #LIBS += -lbz2 | ||
23 | #LIBS += -lkpmicrogcrypt | ||
24 | LIBS += -ljpeg | ||
25 | LIBS += $(QTOPIALIB) | ||
26 | LIBS += -lkpmicrocipher | 17 | LIBS += -lkpmicrocipher |
27 | LIBS += -lkpmicroerror | 18 | LIBS += -lkpmicroerror |
28 | LIBS += -lkpmicrompi | 19 | LIBS += -lkpmicrompi |
29 | LIBS += -lstdc++ | 20 | LIBS += -lstdc++ |
30 | 21 | ||
22 | unix:{ | ||
23 | OBJECTS_DIR = obj/unix | ||
24 | MOC_DIR = moc/unix | ||
25 | |||
26 | } | ||
27 | win32:{ | ||
28 | |||
29 | DEFINES += _WIN32_ | ||
30 | OBJECTS_DIR = obj/win | ||
31 | MOC_DIR = moc/win | ||
32 | QMAKE_LINK += /NODEFAULTLIB:LIBC | ||
33 | |||
34 | } | ||
35 | |||
31 | #INTERFACES = \ | 36 | #INTERFACES = \ |
32 | #addentrywnd.ui \ | 37 | #addentrywnd.ui \ |
33 | #configwnd.ui \ | 38 | #configwnd.ui \ |
34 | #findwnd.ui \ | 39 | #findwnd.ui \ |
35 | #getmasterpwwnd.ui \ | 40 | #getmasterpwwnd.ui \ |
36 | #pwgenwnd.ui \ | 41 | #pwgenwnd.ui \ |
37 | #setmasterpwwnd.ui \ | 42 | #setmasterpwwnd.ui \ |
38 | #subtbledit.ui | 43 | #subtbledit.ui |
39 | 44 | ||
40 | #INTERFACES = \ | 45 | #INTERFACES = \ |
41 | #subtbledit.ui \ | 46 | #subtbledit.ui \ |
42 | 47 | ||
43 | 48 | ||
44 | 49 | ||
45 | #HEADERS = \ | 50 | #HEADERS = \ |
46 | #configuration_31compat.h \ | 51 | #configuration_31compat.h \ |
47 | #configuration.h \ | 52 | #configuration.h \ |
48 | #configwnd.h \ | 53 | #configwnd.h \ |
49 | #configwndimpl.h \ | 54 | #configwndimpl.h \ |
50 | #selftest.h | 55 | #selftest.h |
51 | #subtbledit.h \ | 56 | #subtbledit.h \ |
52 | #subtbleditimpl.h \ | 57 | #subtbleditimpl.h \ |
53 | #compressbzip2.h \ | 58 | #compressbzip2.h \ |
54 | 59 | ||
55 | HEADERS = \ | 60 | HEADERS = \ |
56 | addentrywnd_emb.h \ | 61 | addentrywnd_emb.h \ |
57 | addentrywndimpl.h \ | 62 | addentrywndimpl.h \ |
58 | base64.h \ | 63 | base64.h \ |
59 | binentrygen.h \ | 64 | binentrygen.h \ |
60 | blowfish.h \ | 65 | blowfish.h \ |
61 | commentbox.h \ | 66 | commentbox.h \ |
62 | compiler.h \ | 67 | compiler.h \ |
63 | compressgzip.h \ | 68 | compressgzip.h \ |
64 | findwnd_emb.h \ | 69 | findwnd_emb.h \ |
65 | findwndimpl.h \ | 70 | findwndimpl.h \ |
66 | genpasswd.h \ | 71 | genpasswd.h \ |
67 | getkeycardwnd.h \ | 72 | getkeycardwnd.h \ |
68 | getmasterpwwnd_emb.h \ | 73 | getmasterpwwnd_emb.h \ |
69 | getmasterpwwndimpl.h \ | 74 | getmasterpwwndimpl.h \ |
70 | globalstuff.h \ | 75 | globalstuff.h \ |
71 | gpasmanfile.h \ | 76 | gpasmanfile.h \ |
72 | htmlgen.h \ | 77 | htmlgen.h \ |
73 | htmlparse.h \ | 78 | htmlparse.h \ |
74 | ipc.h \ | 79 | ipc.h \ |
75 | libgcryptif.h \ | 80 | libgcryptif.h \ |
76 | listobjselectwnd.h \ | 81 | listobjselectwnd.h \ |
77 | listviewpwm.h \ | 82 | listviewpwm.h \ |
78 | printtext.h \ | 83 | printtext.h \ |
79 | pwgenwnd_emb.h \ | 84 | pwgenwnd_emb.h \ |
80 | pwgenwndimpl.h \ | 85 | pwgenwndimpl.h \ |
81 | pwmdoc.h \ | 86 | pwmdoc.h \ |
82 | pwmdocui.h \ | 87 | pwmdocui.h \ |
83 | pwmexception.h \ | 88 | pwmexception.h \ |
84 | pwm.h \ | 89 | pwm.h \ |
85 | pwminit.h \ | 90 | pwminit.h \ |
86 | pwmprefs.h \ | 91 | pwmprefs.h \ |
87 | pwmprint.h \ | 92 | pwmprint.h \ |
88 | pwmtray.h \ | 93 | pwmtray.h \ |
89 | pwmview.h \ | 94 | pwmview.h \ |
90 | pwmviewstyle_0.h \ | 95 | pwmviewstyle_0.h \ |
91 | pwmviewstyle_1.h \ | 96 | pwmviewstyle_1.h \ |
92 | pwmviewstyle.h \ | 97 | pwmviewstyle.h \ |
93 | randomizer.h \ | 98 | randomizer.h \ |
94 | rc2.h \ | 99 | rc2.h \ |
95 | rencatwnd.h \ | 100 | rencatwnd.h \ |
96 | serializer.h \ | 101 | serializer.h \ |
97 | setmasterpwwnd_emb.h \ | 102 | setmasterpwwnd_emb.h \ |
98 | setmasterpwwndimpl.h \ | 103 | setmasterpwwndimpl.h \ |
99 | sha1.h \ | 104 | sha1.h \ |
100 | waitwnd.h \ | 105 | waitwnd.h \ |
101 | kcmconfigs/kcmpwmconfig.h \ | 106 | kcmconfigs/kcmpwmconfig.h \ |
102 | kcmconfigs/pwmconfigwidget.h | 107 | kcmconfigs/pwmconfigwidget.h |
103 | 108 | ||
104 | #sources that need not be build | 109 | #sources that need not be build |
105 | #SOURCES = \ | 110 | #SOURCES = \ |
106 | #advcommeditimpl.cpp \ | 111 | #advcommeditimpl.cpp \ |
107 | #configuration.cpp \ | 112 | #configuration.cpp \ |
108 | #configwnd.cpp \ | 113 | #configwnd.cpp \ |
109 | #configwndimpl.cpp \ | 114 | #configwndimpl.cpp \ |
110 | #configuration_31compat.cpp \ | 115 | #configuration_31compat.cpp \ |
111 | #htmlparse.cpp \ | 116 | #htmlparse.cpp \ |
112 | #printtext.cpp \ | 117 | #printtext.cpp \ |
113 | #selftest.cpp \ | 118 | #selftest.cpp \ |
114 | #pwmprint.cpp \ | 119 | #pwmprint.cpp \ |
115 | #spinforsignal.cpp | 120 | #spinforsignal.cpp |
116 | #subtbledit.cpp \ | 121 | #subtbledit.cpp \ |
117 | #subtbleditimpl.cpp \ | 122 | #subtbleditimpl.cpp \ |
118 | #compressbzip2.cpp | 123 | #compressbzip2.cpp |
119 | 124 | ||
120 | 125 | ||
121 | SOURCES = \ | 126 | SOURCES = \ |
122 | addentrywnd_emb.cpp \ | 127 | addentrywnd_emb.cpp \ |
123 | addentrywndimpl.cpp \ | 128 | addentrywndimpl.cpp \ |
124 | base64.cpp \ | 129 | base64.cpp \ |
125 | binentrygen.cpp \ | 130 | binentrygen.cpp \ |
126 | blowfish.cpp \ | 131 | blowfish.cpp \ |
127 | commentbox.cpp \ | 132 | commentbox.cpp \ |
128 | compressgzip.cpp \ | 133 | compressgzip.cpp \ |
129 | findwnd_emb.cpp \ | 134 | findwnd_emb.cpp \ |
130 | findwndimpl.cpp \ | 135 | findwndimpl.cpp \ |
131 | genpasswd.cpp \ | 136 | genpasswd.cpp \ |
132 | getkeycardwnd.cpp \ | 137 | getkeycardwnd.cpp \ |
133 | getmasterpwwnd_emb.cpp \ | 138 | getmasterpwwnd_emb.cpp \ |
134 | getmasterpwwndimpl.cpp \ | 139 | getmasterpwwndimpl.cpp \ |
135 | globalstuff.cpp \ | 140 | globalstuff.cpp \ |
136 | gpasmanfile.cpp \ | 141 | gpasmanfile.cpp \ |
137 | htmlgen.cpp \ | 142 | htmlgen.cpp \ |
138 | ipc.cpp \ | 143 | ipc.cpp \ |
139 | libgcryptif.cpp \ | 144 | libgcryptif.cpp \ |
140 | listobjselectwnd.cpp \ | 145 | listobjselectwnd.cpp \ |
141 | listviewpwm.cpp \ | 146 | listviewpwm.cpp \ |
142 | main.cpp \ | 147 | main.cpp \ |
143 | pwgenwnd_emb.cpp \ | 148 | pwgenwnd_emb.cpp \ |
144 | pwgenwndimpl.cpp \ | 149 | pwgenwndimpl.cpp \ |
145 | pwm.cpp \ | 150 | pwm.cpp \ |
146 | pwmdoc.cpp \ | 151 | pwmdoc.cpp \ |
147 | pwmdocui.cpp \ | 152 | pwmdocui.cpp \ |
148 | pwmexception.cpp \ | 153 | pwmexception.cpp \ |
149 | pwminit.cpp \ | 154 | pwminit.cpp \ |
150 | pwmprefs.cpp \ | 155 | pwmprefs.cpp \ |
151 | pwmtray.cpp \ | 156 | pwmtray.cpp \ |
152 | pwmview.cpp \ | 157 | pwmview.cpp \ |
153 | pwmviewstyle_0.cpp \ | 158 | pwmviewstyle_0.cpp \ |
154 | pwmviewstyle_1.cpp \ | 159 | pwmviewstyle_1.cpp \ |
155 | pwmviewstyle.cpp \ | 160 | pwmviewstyle.cpp \ |
156 | randomizer.cpp \ | 161 | randomizer.cpp \ |
157 | rc2.cpp \ | 162 | rc2.cpp \ |
158 | rencatwnd.cpp \ | 163 | rencatwnd.cpp \ |
159 | serializer.cpp \ | 164 | serializer.cpp \ |
160 | setmasterpwwnd_emb.cpp \ | 165 | setmasterpwwnd_emb.cpp \ |
161 | setmasterpwwndimpl.cpp \ | 166 | setmasterpwwndimpl.cpp \ |
162 | sha1.cpp \ | 167 | sha1.cpp \ |
163 | waitwnd.cpp \ | 168 | waitwnd.cpp \ |
164 | kcmconfigs/kcmpwmconfig.cpp \ | 169 | kcmconfigs/kcmpwmconfig.cpp \ |
165 | kcmconfigs/pwmconfigwidget.cpp | 170 | kcmconfigs/pwmconfigwidget.cpp |
166 | 171 | ||
167 | 172 | ||
168 | 173 | ||
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index e29e3d1..8869f3a 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -1948,1478 +1948,1478 @@ void PwMDoc::findEntry(unsigned int category, PwMDataItem find, unsigned int sea | |||
1948 | } | 1948 | } |
1949 | if (searchIn & SEARCH_IN_NAME) { | 1949 | if (searchIn & SEARCH_IN_NAME) { |
1950 | if (!compareString(find.name, dti.dta[category].d[i].name, | 1950 | if (!compareString(find.name, dti.dta[category].d[i].name, |
1951 | caseSensitive, exactWordMatch)) { | 1951 | caseSensitive, exactWordMatch)) { |
1952 | continue; | 1952 | continue; |
1953 | } | 1953 | } |
1954 | } | 1954 | } |
1955 | if (searchIn & SEARCH_IN_PW) { | 1955 | if (searchIn & SEARCH_IN_PW) { |
1956 | bool wasLocked = isLocked(category, i); | 1956 | bool wasLocked = isLocked(category, i); |
1957 | getDataChangedLock(); | 1957 | getDataChangedLock(); |
1958 | lockAt(category, i, false); | 1958 | lockAt(category, i, false); |
1959 | if (!compareString(find.pw, dti.dta[category].d[i].pw, | 1959 | if (!compareString(find.pw, dti.dta[category].d[i].pw, |
1960 | caseSensitive, exactWordMatch)) { | 1960 | caseSensitive, exactWordMatch)) { |
1961 | lockAt(category, i, wasLocked); | 1961 | lockAt(category, i, wasLocked); |
1962 | putDataChangedLock(); | 1962 | putDataChangedLock(); |
1963 | continue; | 1963 | continue; |
1964 | } | 1964 | } |
1965 | lockAt(category, i, wasLocked); | 1965 | lockAt(category, i, wasLocked); |
1966 | putDataChangedLock(); | 1966 | putDataChangedLock(); |
1967 | } | 1967 | } |
1968 | if (searchIn & SEARCH_IN_COMMENT) { | 1968 | if (searchIn & SEARCH_IN_COMMENT) { |
1969 | if (!compareString(find.comment, dti.dta[category].d[i].comment, | 1969 | if (!compareString(find.comment, dti.dta[category].d[i].comment, |
1970 | caseSensitive, exactWordMatch)) { | 1970 | caseSensitive, exactWordMatch)) { |
1971 | continue; | 1971 | continue; |
1972 | } | 1972 | } |
1973 | } | 1973 | } |
1974 | if (searchIn & SEARCH_IN_URL) { | 1974 | if (searchIn & SEARCH_IN_URL) { |
1975 | if (!compareString(find.url, dti.dta[category].d[i].url, | 1975 | if (!compareString(find.url, dti.dta[category].d[i].url, |
1976 | caseSensitive, exactWordMatch)) { | 1976 | caseSensitive, exactWordMatch)) { |
1977 | continue; | 1977 | continue; |
1978 | } | 1978 | } |
1979 | } | 1979 | } |
1980 | if (searchIn & SEARCH_IN_LAUNCHER) { | 1980 | if (searchIn & SEARCH_IN_LAUNCHER) { |
1981 | if (!compareString(find.launcher, dti.dta[category].d[i].launcher, | 1981 | if (!compareString(find.launcher, dti.dta[category].d[i].launcher, |
1982 | caseSensitive, exactWordMatch)) { | 1982 | caseSensitive, exactWordMatch)) { |
1983 | continue; | 1983 | continue; |
1984 | } | 1984 | } |
1985 | } | 1985 | } |
1986 | 1986 | ||
1987 | // all selected "searchIn" matched. | 1987 | // all selected "searchIn" matched. |
1988 | foundPositions->push_back(i); | 1988 | foundPositions->push_back(i); |
1989 | if (breakAfterFound) | 1989 | if (breakAfterFound) |
1990 | break; | 1990 | break; |
1991 | } | 1991 | } |
1992 | 1992 | ||
1993 | if (sortByLvp && foundPositions->size() > 1) { | 1993 | if (sortByLvp && foundPositions->size() > 1) { |
1994 | vector< pair<unsigned int /* foundPosition (real doc pos) */, | 1994 | vector< pair<unsigned int /* foundPosition (real doc pos) */, |
1995 | unsigned int /* lvp-pos */> > tmp_vec; | 1995 | unsigned int /* lvp-pos */> > tmp_vec; |
1996 | 1996 | ||
1997 | unsigned int i, items = foundPositions->size(); | 1997 | unsigned int i, items = foundPositions->size(); |
1998 | pair<unsigned int, unsigned int> tmp_pair; | 1998 | pair<unsigned int, unsigned int> tmp_pair; |
1999 | for (i = 0; i < items; ++i) { | 1999 | for (i = 0; i < items; ++i) { |
2000 | tmp_pair.first = (*foundPositions)[i]; | 2000 | tmp_pair.first = (*foundPositions)[i]; |
2001 | tmp_pair.second = dti.dta[category].d[(*foundPositions)[i]].listViewPos; | 2001 | tmp_pair.second = dti.dta[category].d[(*foundPositions)[i]].listViewPos; |
2002 | tmp_vec.push_back(tmp_pair); | 2002 | tmp_vec.push_back(tmp_pair); |
2003 | } | 2003 | } |
2004 | sort(tmp_vec.begin(), tmp_vec.end(), dta_lvp_greater()); | 2004 | sort(tmp_vec.begin(), tmp_vec.end(), dta_lvp_greater()); |
2005 | foundPositions->clear(); | 2005 | foundPositions->clear(); |
2006 | for (i = 0; i < items; ++i) { | 2006 | for (i = 0; i < items; ++i) { |
2007 | foundPositions->push_back(tmp_vec[i].first); | 2007 | foundPositions->push_back(tmp_vec[i].first); |
2008 | } | 2008 | } |
2009 | } | 2009 | } |
2010 | } | 2010 | } |
2011 | 2011 | ||
2012 | void PwMDoc::findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, | 2012 | void PwMDoc::findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, |
2013 | vector<unsigned int> *foundPositions, bool breakAfterFound, | 2013 | vector<unsigned int> *foundPositions, bool breakAfterFound, |
2014 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) | 2014 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) |
2015 | { | 2015 | { |
2016 | PWM_ASSERT(foundPositions); | 2016 | PWM_ASSERT(foundPositions); |
2017 | unsigned int cat = 0; | 2017 | unsigned int cat = 0; |
2018 | 2018 | ||
2019 | if (!findCategory(category, &cat)) { | 2019 | if (!findCategory(category, &cat)) { |
2020 | foundPositions->clear(); | 2020 | foundPositions->clear(); |
2021 | return; | 2021 | return; |
2022 | } | 2022 | } |
2023 | 2023 | ||
2024 | findEntry(cat, find, searchIn, foundPositions, breakAfterFound, | 2024 | findEntry(cat, find, searchIn, foundPositions, breakAfterFound, |
2025 | caseSensitive, exactWordMatch, sortByLvp); | 2025 | caseSensitive, exactWordMatch, sortByLvp); |
2026 | } | 2026 | } |
2027 | 2027 | ||
2028 | bool PwMDoc::compareString(const string &s1, const string &s2, bool caseSensitive, | 2028 | bool PwMDoc::compareString(const string &s1, const string &s2, bool caseSensitive, |
2029 | bool exactWordMatch) | 2029 | bool exactWordMatch) |
2030 | { | 2030 | { |
2031 | QString _s1(s1.c_str()); | 2031 | QString _s1(s1.c_str()); |
2032 | QString _s2(s2.c_str()); | 2032 | QString _s2(s2.c_str()); |
2033 | if (!caseSensitive) { | 2033 | if (!caseSensitive) { |
2034 | _s1 = _s1.lower(); | 2034 | _s1 = _s1.lower(); |
2035 | _s2 = _s2.lower(); | 2035 | _s2 = _s2.lower(); |
2036 | } | 2036 | } |
2037 | if (exactWordMatch ? (_s1 == _s2) : (_s2.find(_s1) != -1)) | 2037 | if (exactWordMatch ? (_s1 == _s2) : (_s2.find(_s1) != -1)) |
2038 | return true; | 2038 | return true; |
2039 | return false; | 2039 | return false; |
2040 | } | 2040 | } |
2041 | 2041 | ||
2042 | bool PwMDoc::findCategory(const QString &name, unsigned int *index) | 2042 | bool PwMDoc::findCategory(const QString &name, unsigned int *index) |
2043 | { | 2043 | { |
2044 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), | 2044 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), |
2045 | end = dti.dta.end(); | 2045 | end = dti.dta.end(); |
2046 | while (i != end) { | 2046 | while (i != end) { |
2047 | if ((*i).name == name.latin1()) { | 2047 | if ((*i).name == name.latin1()) { |
2048 | if (index) { | 2048 | if (index) { |
2049 | *index = i - dti.dta.begin(); | 2049 | *index = i - dti.dta.begin(); |
2050 | } | 2050 | } |
2051 | return true; | 2051 | return true; |
2052 | } | 2052 | } |
2053 | ++i; | 2053 | ++i; |
2054 | } | 2054 | } |
2055 | return false; | 2055 | return false; |
2056 | } | 2056 | } |
2057 | 2057 | ||
2058 | bool PwMDoc::renameCategory(const QString &category, const QString &newName) | 2058 | bool PwMDoc::renameCategory(const QString &category, const QString &newName) |
2059 | { | 2059 | { |
2060 | unsigned int cat = 0; | 2060 | unsigned int cat = 0; |
2061 | 2061 | ||
2062 | if (!findCategory(category, &cat)) | 2062 | if (!findCategory(category, &cat)) |
2063 | return false; | 2063 | return false; |
2064 | 2064 | ||
2065 | return renameCategory(cat, newName); | 2065 | return renameCategory(cat, newName); |
2066 | } | 2066 | } |
2067 | 2067 | ||
2068 | bool PwMDoc::renameCategory(unsigned int category, const QString &newName, | 2068 | bool PwMDoc::renameCategory(unsigned int category, const QString &newName, |
2069 | bool dontFlagDirty) | 2069 | bool dontFlagDirty) |
2070 | { | 2070 | { |
2071 | if (category > numCategories() - 1) | 2071 | if (category > numCategories() - 1) |
2072 | return false; | 2072 | return false; |
2073 | 2073 | ||
2074 | dti.dta[category].name = newName.latin1(); | 2074 | dti.dta[category].name = newName.latin1(); |
2075 | if (!dontFlagDirty) | 2075 | if (!dontFlagDirty) |
2076 | flagDirty(); | 2076 | flagDirty(); |
2077 | 2077 | ||
2078 | return true; | 2078 | return true; |
2079 | } | 2079 | } |
2080 | 2080 | ||
2081 | bool PwMDoc::delCategory(const QString &category) | 2081 | bool PwMDoc::delCategory(const QString &category) |
2082 | { | 2082 | { |
2083 | unsigned int cat = 0; | 2083 | unsigned int cat = 0; |
2084 | 2084 | ||
2085 | if (!findCategory(category, &cat)) | 2085 | if (!findCategory(category, &cat)) |
2086 | return false; | 2086 | return false; |
2087 | 2087 | ||
2088 | return delCategory(cat); | 2088 | return delCategory(cat); |
2089 | } | 2089 | } |
2090 | 2090 | ||
2091 | bool PwMDoc::delCategory(unsigned int category, bool dontFlagDirty) | 2091 | bool PwMDoc::delCategory(unsigned int category, bool dontFlagDirty) |
2092 | { | 2092 | { |
2093 | if (category > numCategories() - 1) | 2093 | if (category > numCategories() - 1) |
2094 | return false; | 2094 | return false; |
2095 | 2095 | ||
2096 | // We don't delete it, if it is the last existing | 2096 | // We don't delete it, if it is the last existing |
2097 | // category! Instead we rename it to "Default". | 2097 | // category! Instead we rename it to "Default". |
2098 | if (numCategories() > 1) { | 2098 | if (numCategories() > 1) { |
2099 | dti.dta.erase(dti.dta.begin() + category); | 2099 | dti.dta.erase(dti.dta.begin() + category); |
2100 | } else { | 2100 | } else { |
2101 | renameCategory(category, DEFAULT_CATEGORY, dontFlagDirty); | 2101 | renameCategory(category, DEFAULT_CATEGORY, dontFlagDirty); |
2102 | return true; | 2102 | return true; |
2103 | } | 2103 | } |
2104 | if (!dontFlagDirty) | 2104 | if (!dontFlagDirty) |
2105 | flagDirty(); | 2105 | flagDirty(); |
2106 | 2106 | ||
2107 | return true; | 2107 | return true; |
2108 | } | 2108 | } |
2109 | 2109 | ||
2110 | void PwMDoc::delAllEmptyCat(bool dontFlagDirty) | 2110 | void PwMDoc::delAllEmptyCat(bool dontFlagDirty) |
2111 | { | 2111 | { |
2112 | vector<PwMCategoryItem>::iterator begin = dti.dta.begin(), | 2112 | vector<PwMCategoryItem>::iterator begin = dti.dta.begin(), |
2113 | end = dti.dta.end(), | 2113 | end = dti.dta.end(), |
2114 | i = begin; | 2114 | i = begin; |
2115 | while (i != end) { | 2115 | while (i != end) { |
2116 | if (i->d.empty()) { | 2116 | if (i->d.empty()) { |
2117 | delCategory(begin - i, dontFlagDirty); | 2117 | delCategory(begin - i, dontFlagDirty); |
2118 | } | 2118 | } |
2119 | ++i; | 2119 | ++i; |
2120 | } | 2120 | } |
2121 | } | 2121 | } |
2122 | 2122 | ||
2123 | void PwMDoc::getCategoryList(vector<string> *list) | 2123 | void PwMDoc::getCategoryList(vector<string> *list) |
2124 | { | 2124 | { |
2125 | PWM_ASSERT(list); | 2125 | PWM_ASSERT(list); |
2126 | list->clear(); | 2126 | list->clear(); |
2127 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), | 2127 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), |
2128 | end = dti.dta.end(); | 2128 | end = dti.dta.end(); |
2129 | while (i != end) { | 2129 | while (i != end) { |
2130 | list->push_back(i->name); | 2130 | list->push_back(i->name); |
2131 | ++i; | 2131 | ++i; |
2132 | } | 2132 | } |
2133 | } | 2133 | } |
2134 | 2134 | ||
2135 | void PwMDoc::getCategoryList(QStringList *list) | 2135 | void PwMDoc::getCategoryList(QStringList *list) |
2136 | { | 2136 | { |
2137 | PWM_ASSERT(list); | 2137 | PWM_ASSERT(list); |
2138 | list->clear(); | 2138 | list->clear(); |
2139 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), | 2139 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), |
2140 | end = dti.dta.end(); | 2140 | end = dti.dta.end(); |
2141 | while (i != end) { | 2141 | while (i != end) { |
2142 | #ifndef PWM_EMBEDDED | 2142 | #ifndef PWM_EMBEDDED |
2143 | list->push_back(i->name.c_str()); | 2143 | list->push_back(i->name.c_str()); |
2144 | #else | 2144 | #else |
2145 | list->append(i->name.c_str()); | 2145 | list->append(i->name.c_str()); |
2146 | #endif | 2146 | #endif |
2147 | ++i; | 2147 | ++i; |
2148 | } | 2148 | } |
2149 | } | 2149 | } |
2150 | 2150 | ||
2151 | void PwMDoc::getEntryList(const QString &category, QStringList *list) | 2151 | void PwMDoc::getEntryList(const QString &category, QStringList *list) |
2152 | { | 2152 | { |
2153 | PWM_ASSERT(list); | 2153 | PWM_ASSERT(list); |
2154 | unsigned int cat = 0; | 2154 | unsigned int cat = 0; |
2155 | if (!findCategory(category, &cat)) { | 2155 | if (!findCategory(category, &cat)) { |
2156 | list->clear(); | 2156 | list->clear(); |
2157 | return; | 2157 | return; |
2158 | } | 2158 | } |
2159 | getEntryList(cat, list); | 2159 | getEntryList(cat, list); |
2160 | } | 2160 | } |
2161 | 2161 | ||
2162 | void PwMDoc::getEntryList(const QString &category, vector<string> *list) | 2162 | void PwMDoc::getEntryList(const QString &category, vector<string> *list) |
2163 | { | 2163 | { |
2164 | PWM_ASSERT(list); | 2164 | PWM_ASSERT(list); |
2165 | unsigned int cat = 0; | 2165 | unsigned int cat = 0; |
2166 | if (!findCategory(category, &cat)) { | 2166 | if (!findCategory(category, &cat)) { |
2167 | list->clear(); | 2167 | list->clear(); |
2168 | return; | 2168 | return; |
2169 | } | 2169 | } |
2170 | getEntryList(cat, list); | 2170 | getEntryList(cat, list); |
2171 | } | 2171 | } |
2172 | 2172 | ||
2173 | void PwMDoc::getEntryList(unsigned int category, vector<string> *list) | 2173 | void PwMDoc::getEntryList(unsigned int category, vector<string> *list) |
2174 | { | 2174 | { |
2175 | PWM_ASSERT(list); | 2175 | PWM_ASSERT(list); |
2176 | list->clear(); | 2176 | list->clear(); |
2177 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), | 2177 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), |
2178 | end = dti.dta[category].d.end(), | 2178 | end = dti.dta[category].d.end(), |
2179 | i = begin; | 2179 | i = begin; |
2180 | while (i != end) { | 2180 | while (i != end) { |
2181 | list->push_back(i->desc); | 2181 | list->push_back(i->desc); |
2182 | ++i; | 2182 | ++i; |
2183 | } | 2183 | } |
2184 | } | 2184 | } |
2185 | 2185 | ||
2186 | void PwMDoc::getEntryList(unsigned int category, QStringList *list) | 2186 | void PwMDoc::getEntryList(unsigned int category, QStringList *list) |
2187 | { | 2187 | { |
2188 | PWM_ASSERT(list); | 2188 | PWM_ASSERT(list); |
2189 | list->clear(); | 2189 | list->clear(); |
2190 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), | 2190 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), |
2191 | end = dti.dta[category].d.end(), | 2191 | end = dti.dta[category].d.end(), |
2192 | i = begin; | 2192 | i = begin; |
2193 | while (i != end) { | 2193 | while (i != end) { |
2194 | #ifndef PWM_EMBEDDED | 2194 | #ifndef PWM_EMBEDDED |
2195 | list->push_back(i->desc.c_str()); | 2195 | list->push_back(i->desc.c_str()); |
2196 | #else | 2196 | #else |
2197 | list->append(i->desc.c_str()); | 2197 | list->append(i->desc.c_str()); |
2198 | #endif | 2198 | #endif |
2199 | ++i; | 2199 | ++i; |
2200 | } | 2200 | } |
2201 | } | 2201 | } |
2202 | 2202 | ||
2203 | bool PwMDoc::execLauncher(const QString &category, unsigned int entryIndex) | 2203 | bool PwMDoc::execLauncher(const QString &category, unsigned int entryIndex) |
2204 | { | 2204 | { |
2205 | unsigned int cat = 0; | 2205 | unsigned int cat = 0; |
2206 | 2206 | ||
2207 | if (!findCategory(category, &cat)) | 2207 | if (!findCategory(category, &cat)) |
2208 | return false; | 2208 | return false; |
2209 | 2209 | ||
2210 | return execLauncher(cat, entryIndex); | 2210 | return execLauncher(cat, entryIndex); |
2211 | } | 2211 | } |
2212 | 2212 | ||
2213 | bool PwMDoc::execLauncher(unsigned int category, unsigned int entryIndex) | 2213 | bool PwMDoc::execLauncher(unsigned int category, unsigned int entryIndex) |
2214 | { | 2214 | { |
2215 | if (geteuid() == 0) { | 2215 | if (geteuid() == 0) { |
2216 | rootAlertMsgBox(); | 2216 | rootAlertMsgBox(); |
2217 | return false; | 2217 | return false; |
2218 | } | 2218 | } |
2219 | QString command(dti.dta[category].d[entryIndex].launcher.c_str()); | 2219 | QString command(dti.dta[category].d[entryIndex].launcher.c_str()); |
2220 | bool wasLocked = isLocked(category, entryIndex); | 2220 | bool wasLocked = isLocked(category, entryIndex); |
2221 | 2221 | ||
2222 | if (command.find("$p") != -1) { | 2222 | if (command.find("$p") != -1) { |
2223 | /* the user requested the password to be included | 2223 | /* the user requested the password to be included |
2224 | * into the command. We have to ask for the password, | 2224 | * into the command. We have to ask for the password, |
2225 | * if it's locked. We do that by unlocking the entry | 2225 | * if it's locked. We do that by unlocking the entry |
2226 | */ | 2226 | */ |
2227 | if (!lockAt(category, entryIndex, false)) | 2227 | if (!lockAt(category, entryIndex, false)) |
2228 | return false; | 2228 | return false; |
2229 | } | 2229 | } |
2230 | #ifndef PWM_EMBEDDED | 2230 | #ifndef PWM_EMBEDDED |
2231 | command.replace("$d", dti.dta[category].d[entryIndex].desc.c_str()); | 2231 | command.replace("$d", dti.dta[category].d[entryIndex].desc.c_str()); |
2232 | command.replace("$n", dti.dta[category].d[entryIndex].name.c_str()); | 2232 | command.replace("$n", dti.dta[category].d[entryIndex].name.c_str()); |
2233 | command.replace("$p", dti.dta[category].d[entryIndex].pw.c_str()); | 2233 | command.replace("$p", dti.dta[category].d[entryIndex].pw.c_str()); |
2234 | command.replace("$u", dti.dta[category].d[entryIndex].url.c_str()); | 2234 | command.replace("$u", dti.dta[category].d[entryIndex].url.c_str()); |
2235 | command.replace("$c", dti.dta[category].d[entryIndex].comment.c_str()); | 2235 | command.replace("$c", dti.dta[category].d[entryIndex].comment.c_str()); |
2236 | #else | 2236 | #else |
2237 | command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str()); | 2237 | command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str()); |
2238 | command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str()); | 2238 | command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str()); |
2239 | command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str()); | 2239 | command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str()); |
2240 | command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str()); | 2240 | command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str()); |
2241 | command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str()); | 2241 | command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str()); |
2242 | #endif | 2242 | #endif |
2243 | command.append(" &"); | 2243 | command.append(" &"); |
2244 | 2244 | ||
2245 | QString customXterm(conf()->confGlobXtermCommand()); | 2245 | QString customXterm(conf()->confGlobXtermCommand()); |
2246 | if (!customXterm.isEmpty()) | 2246 | if (!customXterm.isEmpty()) |
2247 | command = customXterm + " " + command; | 2247 | command = customXterm + " " + command; |
2248 | 2248 | ||
2249 | system(command.latin1()); | 2249 | system(command.latin1()); |
2250 | 2250 | ||
2251 | lockAt(category, entryIndex, wasLocked); | 2251 | lockAt(category, entryIndex, wasLocked); |
2252 | return true; | 2252 | return true; |
2253 | } | 2253 | } |
2254 | 2254 | ||
2255 | bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex) | 2255 | bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex) |
2256 | { | 2256 | { |
2257 | unsigned int cat = 0; | 2257 | unsigned int cat = 0; |
2258 | 2258 | ||
2259 | if (!findCategory(category, &cat)) | 2259 | if (!findCategory(category, &cat)) |
2260 | return false; | 2260 | return false; |
2261 | 2261 | ||
2262 | return goToURL(cat, entryIndex); | 2262 | return goToURL(cat, entryIndex); |
2263 | } | 2263 | } |
2264 | 2264 | ||
2265 | bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex) | 2265 | bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex) |
2266 | { | 2266 | { |
2267 | if (geteuid() == 0) { | 2267 | if (geteuid() == 0) { |
2268 | rootAlertMsgBox(); | 2268 | rootAlertMsgBox(); |
2269 | return false; | 2269 | return false; |
2270 | } | 2270 | } |
2271 | QString url(dti.dta[category].d[entryIndex].url.c_str()); | 2271 | QString url(dti.dta[category].d[entryIndex].url.c_str()); |
2272 | if (url.isEmpty()) | 2272 | if (url.isEmpty()) |
2273 | return false; | 2273 | return false; |
2274 | 2274 | ||
2275 | QString customBrowser(conf()->confGlobBrowserCommand()); | 2275 | QString customBrowser(conf()->confGlobBrowserCommand()); |
2276 | if (!customBrowser.isEmpty()) { | 2276 | if (!customBrowser.isEmpty()) { |
2277 | browserProc.clearArguments(); | 2277 | browserProc.clearArguments(); |
2278 | browserProc << customBrowser << url; | 2278 | browserProc << customBrowser << url; |
2279 | if (browserProc.start(KProcess::DontCare)) | 2279 | if (browserProc.start(KProcess::DontCare)) |
2280 | return true; | 2280 | return true; |
2281 | } | 2281 | } |
2282 | 2282 | ||
2283 | browserProc.clearArguments(); | 2283 | browserProc.clearArguments(); |
2284 | browserProc << "konqueror" << url; | 2284 | browserProc << "konqueror" << url; |
2285 | if (browserProc.start(KProcess::DontCare)) | 2285 | if (browserProc.start(KProcess::DontCare)) |
2286 | return true; | 2286 | return true; |
2287 | 2287 | ||
2288 | browserProc.clearArguments(); | 2288 | browserProc.clearArguments(); |
2289 | browserProc << "mozilla" << url; | 2289 | browserProc << "mozilla" << url; |
2290 | if (browserProc.start(KProcess::DontCare)) | 2290 | if (browserProc.start(KProcess::DontCare)) |
2291 | return true; | 2291 | return true; |
2292 | 2292 | ||
2293 | browserProc.clearArguments(); | 2293 | browserProc.clearArguments(); |
2294 | browserProc << "opera" << url; | 2294 | browserProc << "opera" << url; |
2295 | if (browserProc.start(KProcess::DontCare)) | 2295 | if (browserProc.start(KProcess::DontCare)) |
2296 | return true; | 2296 | return true; |
2297 | return false; | 2297 | return false; |
2298 | } | 2298 | } |
2299 | 2299 | ||
2300 | PwMerror PwMDoc::exportToText(const QString *file) | 2300 | PwMerror PwMDoc::exportToText(const QString *file) |
2301 | { | 2301 | { |
2302 | PWM_ASSERT(file); | 2302 | PWM_ASSERT(file); |
2303 | if (QFile::exists(*file)) { | 2303 | if (QFile::exists(*file)) { |
2304 | if (!QFile::remove(*file)) | 2304 | if (!QFile::remove(*file)) |
2305 | return e_accessFile; | 2305 | return e_accessFile; |
2306 | } | 2306 | } |
2307 | QFile f(*file); | 2307 | QFile f(*file); |
2308 | if (!f.open(IO_ReadWrite)) | 2308 | if (!f.open(IO_ReadWrite)) |
2309 | return e_openFile; | 2309 | return e_openFile; |
2310 | 2310 | ||
2311 | if (!unlockAll_tempoary()) { | 2311 | if (!unlockAll_tempoary()) { |
2312 | f.close(); | 2312 | f.close(); |
2313 | return e_lock; | 2313 | return e_lock; |
2314 | } | 2314 | } |
2315 | 2315 | ||
2316 | // write header | 2316 | // write header |
2317 | string header = i18n("Password table generated by\nPwM v").latin1(); | 2317 | string header = i18n("Password table generated by\nPwM v").latin1(); |
2318 | header += PACKAGE_VER; | 2318 | header += PACKAGE_VER; |
2319 | header += i18n("\non ").latin1(); | 2319 | header += i18n("\non ").latin1(); |
2320 | QDate currDate = QDate::currentDate(); | 2320 | QDate currDate = QDate::currentDate(); |
2321 | QTime currTime = QTime::currentTime(); | 2321 | QTime currTime = QTime::currentTime(); |
2322 | 2322 | ||
2323 | #ifndef PWM_EMBEDDED | 2323 | #ifndef PWM_EMBEDDED |
2324 | header += currDate.toString("ddd MMMM d ").latin1(); | 2324 | header += currDate.toString("ddd MMMM d ").latin1(); |
2325 | header += currTime.toString("hh:mm:ss ").latin1(); | 2325 | header += currTime.toString("hh:mm:ss ").latin1(); |
2326 | #else | 2326 | #else |
2327 | QString dfs = KGlobal::locale()->dateFormatShort(); | 2327 | QString dfs = KGlobal::locale()->dateFormatShort(); |
2328 | bool ampm = KGlobal::locale()->use12Clock(); | 2328 | bool ampm = KGlobal::locale()->use12Clock(); |
2329 | KGlobal::locale()->setDateFormatShort("%A %B %d"); | 2329 | KGlobal::locale()->setDateFormatShort("%A %B %d"); |
2330 | KGlobal::locale()->setHore24Format(true); | 2330 | KGlobal::locale()->setHore24Format(true); |
2331 | 2331 | ||
2332 | header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined); | 2332 | header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined).latin1(); |
2333 | header += KGlobal::locale()->formatTime(currTime, true); | 2333 | header += KGlobal::locale()->formatTime(currTime, true).latin1(); |
2334 | KGlobal::locale()->setDateFormatShort(dfs); | 2334 | KGlobal::locale()->setDateFormatShort(dfs); |
2335 | KGlobal::locale()->setHore24Format(!ampm); | 2335 | KGlobal::locale()->setHore24Format(!ampm); |
2336 | 2336 | ||
2337 | #endif | 2337 | #endif |
2338 | header += tostr(currDate.year()); | 2338 | header += tostr(currDate.year()); |
2339 | header += "\n==============================\n\n"; | 2339 | header += "\n==============================\n\n"; |
2340 | 2340 | ||
2341 | 2341 | ||
2342 | #ifndef PWM_EMBEDDED | 2342 | #ifndef PWM_EMBEDDED |
2343 | if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) { | 2343 | if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) { |
2344 | unlockAll_tempoary(true); | 2344 | unlockAll_tempoary(true); |
2345 | f.close(); | 2345 | f.close(); |
2346 | return e_writeFile; | 2346 | return e_writeFile; |
2347 | } | 2347 | } |
2348 | #else | 2348 | #else |
2349 | if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) { | 2349 | if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) { |
2350 | unlockAll_tempoary(true); | 2350 | unlockAll_tempoary(true); |
2351 | f.close(); | 2351 | f.close(); |
2352 | return e_writeFile; | 2352 | return e_writeFile; |
2353 | } | 2353 | } |
2354 | #endif | 2354 | #endif |
2355 | unsigned int i, numCat = numCategories(); | 2355 | unsigned int i, numCat = numCategories(); |
2356 | unsigned int j, numEnt; | 2356 | unsigned int j, numEnt; |
2357 | string exp; | 2357 | string exp; |
2358 | for (i = 0; i < numCat; ++i) { | 2358 | for (i = 0; i < numCat; ++i) { |
2359 | numEnt = numEntries(i); | 2359 | numEnt = numEntries(i); |
2360 | 2360 | ||
2361 | exp = "\n== Category: "; | 2361 | exp = "\n== Category: "; |
2362 | exp += dti.dta[i].name; | 2362 | exp += dti.dta[i].name; |
2363 | exp += " ==\n"; | 2363 | exp += " ==\n"; |
2364 | #ifndef PWM_EMBEDDED | 2364 | #ifndef PWM_EMBEDDED |
2365 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { | 2365 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { |
2366 | unlockAll_tempoary(true); | 2366 | unlockAll_tempoary(true); |
2367 | f.close(); | 2367 | f.close(); |
2368 | return e_writeFile; | 2368 | return e_writeFile; |
2369 | } | 2369 | } |
2370 | #else | 2370 | #else |
2371 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { | 2371 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { |
2372 | unlockAll_tempoary(true); | 2372 | unlockAll_tempoary(true); |
2373 | f.close(); | 2373 | f.close(); |
2374 | return e_writeFile; | 2374 | return e_writeFile; |
2375 | } | 2375 | } |
2376 | #endif | 2376 | #endif |
2377 | for (j = 0; j < numEnt; ++j) { | 2377 | for (j = 0; j < numEnt; ++j) { |
2378 | exp = "\n-- "; | 2378 | exp = "\n-- "; |
2379 | exp += dti.dta[i].d[j].desc; | 2379 | exp += dti.dta[i].d[j].desc; |
2380 | exp += " --\n"; | 2380 | exp += " --\n"; |
2381 | 2381 | ||
2382 | exp += i18n("Username: ").latin1(); | 2382 | exp += i18n("Username: ").latin1(); |
2383 | exp += dti.dta[i].d[j].name; | 2383 | exp += dti.dta[i].d[j].name; |
2384 | exp += "\n"; | 2384 | exp += "\n"; |
2385 | 2385 | ||
2386 | exp += i18n("Password: ").latin1(); | 2386 | exp += i18n("Password: ").latin1(); |
2387 | exp += dti.dta[i].d[j].pw; | 2387 | exp += dti.dta[i].d[j].pw; |
2388 | exp += "\n"; | 2388 | exp += "\n"; |
2389 | 2389 | ||
2390 | exp += i18n("Comment: ").latin1(); | 2390 | exp += i18n("Comment: ").latin1(); |
2391 | exp += dti.dta[i].d[j].comment; | 2391 | exp += dti.dta[i].d[j].comment; |
2392 | exp += "\n"; | 2392 | exp += "\n"; |
2393 | 2393 | ||
2394 | exp += i18n("URL: ").latin1(); | 2394 | exp += i18n("URL: ").latin1(); |
2395 | exp += dti.dta[i].d[j].url; | 2395 | exp += dti.dta[i].d[j].url; |
2396 | exp += "\n"; | 2396 | exp += "\n"; |
2397 | 2397 | ||
2398 | exp += i18n("Launcher: ").latin1(); | 2398 | exp += i18n("Launcher: ").latin1(); |
2399 | exp += dti.dta[i].d[j].launcher; | 2399 | exp += dti.dta[i].d[j].launcher; |
2400 | exp += "\n"; | 2400 | exp += "\n"; |
2401 | 2401 | ||
2402 | #ifndef PWM_EMBEDDED | 2402 | #ifndef PWM_EMBEDDED |
2403 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { | 2403 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { |
2404 | unlockAll_tempoary(true); | 2404 | unlockAll_tempoary(true); |
2405 | f.close(); | 2405 | f.close(); |
2406 | return e_writeFile; | 2406 | return e_writeFile; |
2407 | } | 2407 | } |
2408 | #else | 2408 | #else |
2409 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { | 2409 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { |
2410 | unlockAll_tempoary(true); | 2410 | unlockAll_tempoary(true); |
2411 | f.close(); | 2411 | f.close(); |
2412 | return e_writeFile; | 2412 | return e_writeFile; |
2413 | } | 2413 | } |
2414 | #endif | 2414 | #endif |
2415 | } | 2415 | } |
2416 | } | 2416 | } |
2417 | unlockAll_tempoary(true); | 2417 | unlockAll_tempoary(true); |
2418 | f.close(); | 2418 | f.close(); |
2419 | 2419 | ||
2420 | return e_success; | 2420 | return e_success; |
2421 | } | 2421 | } |
2422 | 2422 | ||
2423 | PwMerror PwMDoc::importFromText(const QString *file, int format) | 2423 | PwMerror PwMDoc::importFromText(const QString *file, int format) |
2424 | { | 2424 | { |
2425 | PWM_ASSERT(file); | 2425 | PWM_ASSERT(file); |
2426 | if (format == 0) | 2426 | if (format == 0) |
2427 | return importText_PwM(file); | 2427 | return importText_PwM(file); |
2428 | else if (format == -1) { | 2428 | else if (format == -1) { |
2429 | // probe for all formats | 2429 | // probe for all formats |
2430 | if (importText_PwM(file) == e_success) | 2430 | if (importText_PwM(file) == e_success) |
2431 | return e_success; | 2431 | return e_success; |
2432 | dti.clear(); | 2432 | dti.clear(); |
2433 | emitDataChanged(this); | 2433 | emitDataChanged(this); |
2434 | // add next format here... | 2434 | // add next format here... |
2435 | return e_fileFormat; | 2435 | return e_fileFormat; |
2436 | } | 2436 | } |
2437 | return e_invalidArg; | 2437 | return e_invalidArg; |
2438 | } | 2438 | } |
2439 | 2439 | ||
2440 | PwMerror PwMDoc::importText_PwM(const QString *file) | 2440 | PwMerror PwMDoc::importText_PwM(const QString *file) |
2441 | { | 2441 | { |
2442 | #ifndef PWM_EMBEDDED | 2442 | #ifndef PWM_EMBEDDED |
2443 | PWM_ASSERT(file); | 2443 | PWM_ASSERT(file); |
2444 | FILE *f; | 2444 | FILE *f; |
2445 | int tmp; | 2445 | int tmp; |
2446 | ssize_t ret; | 2446 | ssize_t ret; |
2447 | string curCat; | 2447 | string curCat; |
2448 | unsigned int entriesRead = 0; | 2448 | unsigned int entriesRead = 0; |
2449 | PwMDataItem currItem; | 2449 | PwMDataItem currItem; |
2450 | f = fopen(file->latin1(), "r"); | 2450 | f = fopen(file->latin1(), "r"); |
2451 | if (!f) | 2451 | if (!f) |
2452 | return e_openFile; | 2452 | return e_openFile; |
2453 | size_t ch_tmp_size = 1024; | 2453 | size_t ch_tmp_size = 1024; |
2454 | char *ch_tmp = (char*)malloc(ch_tmp_size); | 2454 | char *ch_tmp = (char*)malloc(ch_tmp_size); |
2455 | if (!ch_tmp) { | 2455 | if (!ch_tmp) { |
2456 | fclose(f); | 2456 | fclose(f); |
2457 | return e_outOfMem; | 2457 | return e_outOfMem; |
2458 | } | 2458 | } |
2459 | 2459 | ||
2460 | // - check header | 2460 | // - check header |
2461 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) // skip first line. | 2461 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) // skip first line. |
2462 | goto formatError; | 2462 | goto formatError; |
2463 | // check version-string and return version in "ch_tmp". | 2463 | // check version-string and return version in "ch_tmp". |
2464 | if (fscanf(f, "PwM v%s", ch_tmp) != 1) { | 2464 | if (fscanf(f, "PwM v%s", ch_tmp) != 1) { |
2465 | // header not recognized as PwM generated header | 2465 | // header not recognized as PwM generated header |
2466 | goto formatError; | 2466 | goto formatError; |
2467 | } | 2467 | } |
2468 | // set filepointer behind version-string-line previously checked | 2468 | // set filepointer behind version-string-line previously checked |
2469 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2469 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2470 | goto formatError; | 2470 | goto formatError; |
2471 | // skip next line containing the build-date | 2471 | // skip next line containing the build-date |
2472 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2472 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2473 | goto formatError; | 2473 | goto formatError; |
2474 | // read header termination line | 2474 | // read header termination line |
2475 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2475 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2476 | goto formatError; | 2476 | goto formatError; |
2477 | if (strcmp(ch_tmp, "==============================\n")) | 2477 | if (strcmp(ch_tmp, "==============================\n")) |
2478 | goto formatError; | 2478 | goto formatError; |
2479 | 2479 | ||
2480 | // - read entries | 2480 | // - read entries |
2481 | do { | 2481 | do { |
2482 | // find beginning of next category | 2482 | // find beginning of next category |
2483 | do { | 2483 | do { |
2484 | tmp = fgetc(f); | 2484 | tmp = fgetc(f); |
2485 | } while (tmp == '\n' && tmp != EOF); | 2485 | } while (tmp == '\n' && tmp != EOF); |
2486 | if (tmp == EOF) | 2486 | if (tmp == EOF) |
2487 | break; | 2487 | break; |
2488 | 2488 | ||
2489 | // decrement filepos by one | 2489 | // decrement filepos by one |
2490 | fseek(f, -1, SEEK_CUR); | 2490 | fseek(f, -1, SEEK_CUR); |
2491 | // read cat-name | 2491 | // read cat-name |
2492 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2492 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2493 | goto formatError; | 2493 | goto formatError; |
2494 | // check cat-name format | 2494 | // check cat-name format |
2495 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) | 2495 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) |
2496 | goto formatError; | 2496 | goto formatError; |
2497 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) | 2497 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) |
2498 | goto formatError; | 2498 | goto formatError; |
2499 | // copy cat-name | 2499 | // copy cat-name |
2500 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); | 2500 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); |
2501 | 2501 | ||
2502 | do { | 2502 | do { |
2503 | // find beginning of next entry | 2503 | // find beginning of next entry |
2504 | do { | 2504 | do { |
2505 | tmp = fgetc(f); | 2505 | tmp = fgetc(f); |
2506 | } while (tmp == '\n' && tmp != EOF && tmp != '='); | 2506 | } while (tmp == '\n' && tmp != EOF && tmp != '='); |
2507 | if (tmp == EOF) | 2507 | if (tmp == EOF) |
2508 | break; | 2508 | break; |
2509 | if (tmp == '=') { | 2509 | if (tmp == '=') { |
2510 | fseek(f, -1, SEEK_CUR); | 2510 | fseek(f, -1, SEEK_CUR); |
2511 | break; | 2511 | break; |
2512 | } | 2512 | } |
2513 | // decrement filepos by one | 2513 | // decrement filepos by one |
2514 | fseek(f, -1, SEEK_CUR); | 2514 | fseek(f, -1, SEEK_CUR); |
2515 | // read desc-line | 2515 | // read desc-line |
2516 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2516 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2517 | goto formatError; | 2517 | goto formatError; |
2518 | // check desc-line format | 2518 | // check desc-line format |
2519 | if (memcmp(ch_tmp, "-- ", 3) != 0) | 2519 | if (memcmp(ch_tmp, "-- ", 3) != 0) |
2520 | goto formatError; | 2520 | goto formatError; |
2521 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) | 2521 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) |
2522 | goto formatError; | 2522 | goto formatError; |
2523 | // add desc-line | 2523 | // add desc-line |
2524 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); | 2524 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); |
2525 | 2525 | ||
2526 | // read username-line | 2526 | // read username-line |
2527 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2527 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2528 | goto formatError; | 2528 | goto formatError; |
2529 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) | 2529 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) |
2530 | goto formatError; | 2530 | goto formatError; |
2531 | 2531 | ||
2532 | // read pw-line | 2532 | // read pw-line |
2533 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2533 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2534 | goto formatError; | 2534 | goto formatError; |
2535 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) | 2535 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) |
2536 | goto formatError; | 2536 | goto formatError; |
2537 | 2537 | ||
2538 | // read comment-line | 2538 | // read comment-line |
2539 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2539 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2540 | goto formatError; | 2540 | goto formatError; |
2541 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) | 2541 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) |
2542 | goto formatError; | 2542 | goto formatError; |
2543 | 2543 | ||
2544 | // read URL-line | 2544 | // read URL-line |
2545 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2545 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2546 | goto formatError; | 2546 | goto formatError; |
2547 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) | 2547 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) |
2548 | goto formatError; | 2548 | goto formatError; |
2549 | 2549 | ||
2550 | // read launcher-line | 2550 | // read launcher-line |
2551 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2551 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2552 | goto formatError; | 2552 | goto formatError; |
2553 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) | 2553 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) |
2554 | goto formatError; | 2554 | goto formatError; |
2555 | 2555 | ||
2556 | currItem.lockStat = true; | 2556 | currItem.lockStat = true; |
2557 | currItem.listViewPos = -1; | 2557 | currItem.listViewPos = -1; |
2558 | addEntry(curCat.c_str(), &currItem, true); | 2558 | addEntry(curCat.c_str(), &currItem, true); |
2559 | ++entriesRead; | 2559 | ++entriesRead; |
2560 | } while (1); | 2560 | } while (1); |
2561 | } while (1); | 2561 | } while (1); |
2562 | if (!entriesRead) | 2562 | if (!entriesRead) |
2563 | goto formatError; | 2563 | goto formatError; |
2564 | 2564 | ||
2565 | free(ch_tmp); | 2565 | free(ch_tmp); |
2566 | fclose(f); | 2566 | fclose(f); |
2567 | flagDirty(); | 2567 | flagDirty(); |
2568 | return e_success; | 2568 | return e_success; |
2569 | 2569 | ||
2570 | formatError: | 2570 | formatError: |
2571 | free(ch_tmp); | 2571 | free(ch_tmp); |
2572 | fclose(f); | 2572 | fclose(f); |
2573 | return e_fileFormat; | 2573 | return e_fileFormat; |
2574 | #else | 2574 | #else |
2575 | PWM_ASSERT(file); | 2575 | PWM_ASSERT(file); |
2576 | QFile f(file->latin1()); | 2576 | QFile f(file->latin1()); |
2577 | int tmp; | 2577 | int tmp; |
2578 | ssize_t ret; | 2578 | ssize_t ret; |
2579 | string curCat; | 2579 | string curCat; |
2580 | unsigned int entriesRead = 0; | 2580 | unsigned int entriesRead = 0; |
2581 | PwMDataItem currItem; | 2581 | PwMDataItem currItem; |
2582 | bool res = f.open(IO_ReadOnly); | 2582 | bool res = f.open(IO_ReadOnly); |
2583 | if (res == false) | 2583 | if (res == false) |
2584 | return e_openFile; | 2584 | return e_openFile; |
2585 | 2585 | ||
2586 | unsigned int ch_tmp_size = 1024; | 2586 | unsigned int ch_tmp_size = 1024; |
2587 | char *ch_tmp = (char*)malloc(ch_tmp_size); | 2587 | char *ch_tmp = (char*)malloc(ch_tmp_size); |
2588 | if (!ch_tmp) { | 2588 | if (!ch_tmp) { |
2589 | f.close(); | 2589 | f.close(); |
2590 | return e_outOfMem; | 2590 | return e_outOfMem; |
2591 | } | 2591 | } |
2592 | 2592 | ||
2593 | // - check header | 2593 | // - check header |
2594 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) // skip first line. | 2594 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) // skip first line. |
2595 | goto formatError; | 2595 | goto formatError; |
2596 | 2596 | ||
2597 | //US read fileversion first, then check if ok. | 2597 | //US read fileversion first, then check if ok. |
2598 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2598 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2599 | goto formatError; | 2599 | goto formatError; |
2600 | 2600 | ||
2601 | // check version-string and return version in "ch_tmp". | 2601 | // check version-string and return version in "ch_tmp". |
2602 | //US if (fscanf(f, "PwM v%s", ch_tmp) != 1) { | 2602 | //US if (fscanf(f, "PwM v%s", ch_tmp) != 1) { |
2603 | //US // header not recognized as PwM generated header | 2603 | //US // header not recognized as PwM generated header |
2604 | //US goto formatError; | 2604 | //US goto formatError; |
2605 | //US} | 2605 | //US} |
2606 | //US set filepointer behind version-string-line previously checked | 2606 | //US set filepointer behind version-string-line previously checked |
2607 | //US if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2607 | //US if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2608 | //US goto formatError; | 2608 | //US goto formatError; |
2609 | // skip next line containing the build-date | 2609 | // skip next line containing the build-date |
2610 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2610 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2611 | goto formatError; | 2611 | goto formatError; |
2612 | // read header termination line | 2612 | // read header termination line |
2613 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2613 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2614 | goto formatError; | 2614 | goto formatError; |
2615 | if (strcmp(ch_tmp, "==============================\n")) | 2615 | if (strcmp(ch_tmp, "==============================\n")) |
2616 | goto formatError; | 2616 | goto formatError; |
2617 | 2617 | ||
2618 | // - read entries | 2618 | // - read entries |
2619 | do { | 2619 | do { |
2620 | // find beginning of next category | 2620 | // find beginning of next category |
2621 | do { | 2621 | do { |
2622 | tmp = f.getch(); | 2622 | tmp = f.getch(); |
2623 | } while (tmp == '\n' && tmp != EOF); | 2623 | } while (tmp == '\n' && tmp != EOF); |
2624 | if (tmp == EOF) | 2624 | if (tmp == EOF) |
2625 | break; | 2625 | break; |
2626 | 2626 | ||
2627 | // decrement filepos by one | 2627 | // decrement filepos by one |
2628 | f.at(f.at()-1); | 2628 | f.at(f.at()-1); |
2629 | // read cat-name | 2629 | // read cat-name |
2630 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2630 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2631 | goto formatError; | 2631 | goto formatError; |
2632 | // check cat-name format | 2632 | // check cat-name format |
2633 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) | 2633 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) |
2634 | goto formatError; | 2634 | goto formatError; |
2635 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) | 2635 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) |
2636 | goto formatError; | 2636 | goto formatError; |
2637 | // copy cat-name | 2637 | // copy cat-name |
2638 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); | 2638 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); |
2639 | 2639 | ||
2640 | do { | 2640 | do { |
2641 | // find beginning of next entry | 2641 | // find beginning of next entry |
2642 | do { | 2642 | do { |
2643 | tmp = f.getch(); | 2643 | tmp = f.getch(); |
2644 | } while (tmp == '\n' && tmp != EOF && tmp != '='); | 2644 | } while (tmp == '\n' && tmp != EOF && tmp != '='); |
2645 | if (tmp == EOF) | 2645 | if (tmp == EOF) |
2646 | break; | 2646 | break; |
2647 | if (tmp == '=') { | 2647 | if (tmp == '=') { |
2648 | f.at(f.at()-1); | 2648 | f.at(f.at()-1); |
2649 | break; | 2649 | break; |
2650 | } | 2650 | } |
2651 | // decrement filepos by one | 2651 | // decrement filepos by one |
2652 | f.at(f.at()-1); | 2652 | f.at(f.at()-1); |
2653 | // read desc-line | 2653 | // read desc-line |
2654 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) | 2654 | if (f.readLine(ch_tmp, ch_tmp_size) == -1) |
2655 | goto formatError; | 2655 | goto formatError; |
2656 | // check desc-line format | 2656 | // check desc-line format |
2657 | if (memcmp(ch_tmp, "-- ", 3) != 0) | 2657 | if (memcmp(ch_tmp, "-- ", 3) != 0) |
2658 | goto formatError; | 2658 | goto formatError; |
2659 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) | 2659 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) |
2660 | goto formatError; | 2660 | goto formatError; |
2661 | // add desc-line | 2661 | // add desc-line |
2662 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); | 2662 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); |
2663 | 2663 | ||
2664 | // read username-line | 2664 | // read username-line |
2665 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2665 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2666 | goto formatError; | 2666 | goto formatError; |
2667 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) | 2667 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) |
2668 | goto formatError; | 2668 | goto formatError; |
2669 | 2669 | ||
2670 | // read pw-line | 2670 | // read pw-line |
2671 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2671 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2672 | goto formatError; | 2672 | goto formatError; |
2673 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) | 2673 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) |
2674 | goto formatError; | 2674 | goto formatError; |
2675 | 2675 | ||
2676 | // read comment-line | 2676 | // read comment-line |
2677 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2677 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2678 | goto formatError; | 2678 | goto formatError; |
2679 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) | 2679 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) |
2680 | goto formatError; | 2680 | goto formatError; |
2681 | 2681 | ||
2682 | // read URL-line | 2682 | // read URL-line |
2683 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2683 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2684 | goto formatError; | 2684 | goto formatError; |
2685 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) | 2685 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) |
2686 | goto formatError; | 2686 | goto formatError; |
2687 | 2687 | ||
2688 | // read launcher-line | 2688 | // read launcher-line |
2689 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) | 2689 | if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) |
2690 | goto formatError; | 2690 | goto formatError; |
2691 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) | 2691 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) |
2692 | goto formatError; | 2692 | goto formatError; |
2693 | 2693 | ||
2694 | currItem.lockStat = true; | 2694 | currItem.lockStat = true; |
2695 | currItem.listViewPos = -1; | 2695 | currItem.listViewPos = -1; |
2696 | addEntry(curCat.c_str(), &currItem, true); | 2696 | addEntry(curCat.c_str(), &currItem, true); |
2697 | ++entriesRead; | 2697 | ++entriesRead; |
2698 | } while (1); | 2698 | } while (1); |
2699 | } while (1); | 2699 | } while (1); |
2700 | if (!entriesRead) | 2700 | if (!entriesRead) |
2701 | goto formatError; | 2701 | goto formatError; |
2702 | 2702 | ||
2703 | free(ch_tmp); | 2703 | free(ch_tmp); |
2704 | f.close(); | 2704 | f.close(); |
2705 | flagDirty(); | 2705 | flagDirty(); |
2706 | return e_success; | 2706 | return e_success; |
2707 | 2707 | ||
2708 | formatError: | 2708 | formatError: |
2709 | free(ch_tmp); | 2709 | free(ch_tmp); |
2710 | f.close(); | 2710 | f.close(); |
2711 | return e_fileFormat; | 2711 | return e_fileFormat; |
2712 | 2712 | ||
2713 | #endif | 2713 | #endif |
2714 | 2714 | ||
2715 | } | 2715 | } |
2716 | 2716 | ||
2717 | bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out) | 2717 | bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out) |
2718 | { | 2718 | { |
2719 | PWM_ASSERT(in && out); | 2719 | PWM_ASSERT(in && out); |
2720 | ssize_t i = 0, len = in_size - 1; | 2720 | ssize_t i = 0, len = in_size - 1; |
2721 | while (i < len) { | 2721 | while (i < len) { |
2722 | if (in[i] == ':') | 2722 | if (in[i] == ':') |
2723 | break; | 2723 | break; |
2724 | ++i; | 2724 | ++i; |
2725 | } | 2725 | } |
2726 | i += 2; | 2726 | i += 2; |
2727 | *out = ""; | 2727 | *out = ""; |
2728 | out->append(in + i, in_size - i - 1); | 2728 | out->append(in + i, in_size - i - 1); |
2729 | return true; | 2729 | return true; |
2730 | } | 2730 | } |
2731 | 2731 | ||
2732 | PwMerror PwMDoc::exportToGpasman(const QString *file) | 2732 | PwMerror PwMDoc::exportToGpasman(const QString *file) |
2733 | { | 2733 | { |
2734 | PWM_ASSERT(file); | 2734 | PWM_ASSERT(file); |
2735 | GpasmanFile gp; | 2735 | GpasmanFile gp; |
2736 | int ret; | 2736 | int ret; |
2737 | 2737 | ||
2738 | if (!unlockAll_tempoary()) | 2738 | if (!unlockAll_tempoary()) |
2739 | return e_lock; | 2739 | return e_lock; |
2740 | 2740 | ||
2741 | QString gpmPassword; | 2741 | QString gpmPassword; |
2742 | while (1) { | 2742 | while (1) { |
2743 | gpmPassword = requestNewMpw(0); | 2743 | gpmPassword = requestNewMpw(0); |
2744 | if (gpmPassword == "") { | 2744 | if (gpmPassword == "") { |
2745 | unlockAll_tempoary(true); | 2745 | unlockAll_tempoary(true); |
2746 | return e_noPw; | 2746 | return e_noPw; |
2747 | } | 2747 | } |
2748 | if (gpmPassword.length() < 4) { | 2748 | if (gpmPassword.length() < 4) { |
2749 | gpmPwLenErrMsgBox(); | 2749 | gpmPwLenErrMsgBox(); |
2750 | } else { | 2750 | } else { |
2751 | break; | 2751 | break; |
2752 | } | 2752 | } |
2753 | } | 2753 | } |
2754 | 2754 | ||
2755 | ret = gp.save_init(file->latin1(), gpmPassword.latin1()); | 2755 | ret = gp.save_init(file->latin1(), gpmPassword.latin1()); |
2756 | if (ret != 1) { | 2756 | if (ret != 1) { |
2757 | unlockAll_tempoary(true); | 2757 | unlockAll_tempoary(true); |
2758 | return e_accessFile; | 2758 | return e_accessFile; |
2759 | } | 2759 | } |
2760 | 2760 | ||
2761 | char *entry[4]; | 2761 | char *entry[4]; |
2762 | unsigned int numCat = numCategories(), i; | 2762 | unsigned int numCat = numCategories(), i; |
2763 | unsigned int numEntr, j; | 2763 | unsigned int numEntr, j; |
2764 | int descLen, nameLen, pwLen, commentLen; | 2764 | int descLen, nameLen, pwLen, commentLen; |
2765 | for (i = 0; i < numCat; ++i) { | 2765 | for (i = 0; i < numCat; ++i) { |
2766 | numEntr = numEntries(i); | 2766 | numEntr = numEntries(i); |
2767 | for (j = 0; j < numEntr; ++j) { | 2767 | for (j = 0; j < numEntr; ++j) { |
2768 | descLen = dti.dta[i].d[j].desc.length(); | 2768 | descLen = dti.dta[i].d[j].desc.length(); |
2769 | nameLen = dti.dta[i].d[j].name.length(); | 2769 | nameLen = dti.dta[i].d[j].name.length(); |
2770 | pwLen = dti.dta[i].d[j].pw.length(); | 2770 | pwLen = dti.dta[i].d[j].pw.length(); |
2771 | commentLen = dti.dta[i].d[j].comment.length(); | 2771 | commentLen = dti.dta[i].d[j].comment.length(); |
2772 | entry[0] = new char[descLen + 1]; | 2772 | entry[0] = new char[descLen + 1]; |
2773 | entry[1] = new char[nameLen + 1]; | 2773 | entry[1] = new char[nameLen + 1]; |
2774 | entry[2] = new char[pwLen + 1]; | 2774 | entry[2] = new char[pwLen + 1]; |
2775 | entry[3] = new char[commentLen + 1]; | 2775 | entry[3] = new char[commentLen + 1]; |
2776 | strcpy(entry[0], descLen == 0 ? " " : dti.dta[i].d[j].desc.c_str()); | 2776 | strcpy(entry[0], descLen == 0 ? " " : dti.dta[i].d[j].desc.c_str()); |
2777 | strcpy(entry[1], nameLen == 0 ? " " : dti.dta[i].d[j].name.c_str()); | 2777 | strcpy(entry[1], nameLen == 0 ? " " : dti.dta[i].d[j].name.c_str()); |
2778 | strcpy(entry[2], pwLen == 0 ? " " : dti.dta[i].d[j].pw.c_str()); | 2778 | strcpy(entry[2], pwLen == 0 ? " " : dti.dta[i].d[j].pw.c_str()); |
2779 | strcpy(entry[3], commentLen == 0 ? " " : dti.dta[i].d[j].comment.c_str()); | 2779 | strcpy(entry[3], commentLen == 0 ? " " : dti.dta[i].d[j].comment.c_str()); |
2780 | entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0'; | 2780 | entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0'; |
2781 | entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0'; | 2781 | entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0'; |
2782 | entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0'; | 2782 | entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0'; |
2783 | entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0'; | 2783 | entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0'; |
2784 | 2784 | ||
2785 | ret = gp.save_entry(entry); | 2785 | ret = gp.save_entry(entry); |
2786 | if (ret == -1){ | 2786 | if (ret == -1){ |
2787 | delete [] entry[0]; | 2787 | delete [] entry[0]; |
2788 | delete [] entry[1]; | 2788 | delete [] entry[1]; |
2789 | delete [] entry[2]; | 2789 | delete [] entry[2]; |
2790 | delete [] entry[3]; | 2790 | delete [] entry[3]; |
2791 | gp.save_finalize(); | 2791 | gp.save_finalize(); |
2792 | unlockAll_tempoary(true); | 2792 | unlockAll_tempoary(true); |
2793 | return e_writeFile; | 2793 | return e_writeFile; |
2794 | } | 2794 | } |
2795 | 2795 | ||
2796 | delete [] entry[0]; | 2796 | delete [] entry[0]; |
2797 | delete [] entry[1]; | 2797 | delete [] entry[1]; |
2798 | delete [] entry[2]; | 2798 | delete [] entry[2]; |
2799 | delete [] entry[3]; | 2799 | delete [] entry[3]; |
2800 | } | 2800 | } |
2801 | } | 2801 | } |
2802 | unlockAll_tempoary(true); | 2802 | unlockAll_tempoary(true); |
2803 | if (gp.save_finalize() == -1) | 2803 | if (gp.save_finalize() == -1) |
2804 | return e_writeFile; | 2804 | return e_writeFile; |
2805 | 2805 | ||
2806 | return e_success; | 2806 | return e_success; |
2807 | } | 2807 | } |
2808 | 2808 | ||
2809 | PwMerror PwMDoc::importFromGpasman(const QString *file) | 2809 | PwMerror PwMDoc::importFromGpasman(const QString *file) |
2810 | { | 2810 | { |
2811 | PWM_ASSERT(file); | 2811 | PWM_ASSERT(file); |
2812 | QString pw = requestMpw(false); | 2812 | QString pw = requestMpw(false); |
2813 | if (pw == "") | 2813 | if (pw == "") |
2814 | return e_noPw; | 2814 | return e_noPw; |
2815 | GpasmanFile gp; | 2815 | GpasmanFile gp; |
2816 | int ret, i; | 2816 | int ret, i; |
2817 | PwMerror ret2; | 2817 | PwMerror ret2; |
2818 | char *entry[4]; | 2818 | char *entry[4]; |
2819 | PwMDataItem tmpData; | 2819 | PwMDataItem tmpData; |
2820 | ret = gp.load_init(file->latin1(), pw.latin1()); | 2820 | ret = gp.load_init(file->latin1(), pw.latin1()); |
2821 | if (ret != 1) | 2821 | if (ret != 1) |
2822 | return e_accessFile; | 2822 | return e_accessFile; |
2823 | 2823 | ||
2824 | do { | 2824 | do { |
2825 | ret = gp.load_entry(entry); | 2825 | ret = gp.load_entry(entry); |
2826 | if(ret != 1) | 2826 | if(ret != 1) |
2827 | break; | 2827 | break; |
2828 | tmpData.desc = entry[0]; | 2828 | tmpData.desc = entry[0]; |
2829 | tmpData.name = entry[1]; | 2829 | tmpData.name = entry[1]; |
2830 | tmpData.pw = entry[2]; | 2830 | tmpData.pw = entry[2]; |
2831 | tmpData.comment = entry[3]; | 2831 | tmpData.comment = entry[3]; |
2832 | tmpData.lockStat = true; | 2832 | tmpData.lockStat = true; |
2833 | tmpData.listViewPos = -1; | 2833 | tmpData.listViewPos = -1; |
2834 | ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true); | 2834 | ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true); |
2835 | for (i = 0; i < 4; ++i) | 2835 | for (i = 0; i < 4; ++i) |
2836 | free(entry[i]); | 2836 | free(entry[i]); |
2837 | if (ret2 == e_maxAllowedEntr) { | 2837 | if (ret2 == e_maxAllowedEntr) { |
2838 | gp.load_finalize(); | 2838 | gp.load_finalize(); |
2839 | return e_maxAllowedEntr; | 2839 | return e_maxAllowedEntr; |
2840 | } | 2840 | } |
2841 | } while (1); | 2841 | } while (1); |
2842 | gp.load_finalize(); | 2842 | gp.load_finalize(); |
2843 | if (isDocEmpty()) | 2843 | if (isDocEmpty()) |
2844 | return e_wrongPw; // we assume this. | 2844 | return e_wrongPw; // we assume this. |
2845 | 2845 | ||
2846 | flagDirty(); | 2846 | flagDirty(); |
2847 | return e_success; | 2847 | return e_success; |
2848 | } | 2848 | } |
2849 | 2849 | ||
2850 | 2850 | ||
2851 | //US: we use the stl sort algorythm to sort all elements in the order | 2851 | //US: we use the stl sort algorythm to sort all elements in the order |
2852 | //of its listViewPos (in the order 1,2,3,5,...,x,-1, -1, -1 | 2852 | //of its listViewPos (in the order 1,2,3,5,...,x,-1, -1, -1 |
2853 | struct PwMDataItemListViewPosSort | 2853 | struct PwMDataItemListViewPosSort |
2854 | { | 2854 | { |
2855 | bool operator()(PwMDataItem* rpStart, PwMDataItem* rpEnd) | 2855 | bool operator()(PwMDataItem* rpStart, PwMDataItem* rpEnd) |
2856 | { | 2856 | { |
2857 | //qDebug("pwMDoc::PwMDataItemListViewPosSort()"); | 2857 | //qDebug("pwMDoc::PwMDataItemListViewPosSort()"); |
2858 | if ((rpEnd)->listViewPos < 0) | 2858 | if ((rpEnd)->listViewPos < 0) |
2859 | return false; | 2859 | return false; |
2860 | else | 2860 | else |
2861 | return (rpStart)->listViewPos < (rpEnd)->listViewPos; | 2861 | return (rpStart)->listViewPos < (rpEnd)->listViewPos; |
2862 | } | 2862 | } |
2863 | }; | 2863 | }; |
2864 | 2864 | ||
2865 | void PwMDoc::ensureLvp() | 2865 | void PwMDoc::ensureLvp() |
2866 | { | 2866 | { |
2867 | if (isDocEmpty()) | 2867 | if (isDocEmpty()) |
2868 | return; | 2868 | return; |
2869 | 2869 | ||
2870 | //US ENH BUG: when using syncronizing, this way of sorting | 2870 | //US ENH BUG: when using syncronizing, this way of sorting |
2871 | //is not sufficient, because there might be empty spaces | 2871 | //is not sufficient, because there might be empty spaces |
2872 | // at the beginning. But the old algorythm only can add elements | 2872 | // at the beginning. But the old algorythm only can add elements |
2873 | //to the end.The result are crashes because of list overflows | 2873 | //to the end.The result are crashes because of list overflows |
2874 | //we need something to fill all gaps. | 2874 | //we need something to fill all gaps. |
2875 | vector<PwMDataItem*> sorted; | 2875 | vector<PwMDataItem*> sorted; |
2876 | vector< PwMDataItem*>::iterator sortedBegin, | 2876 | vector< PwMDataItem*>::iterator sortedBegin, |
2877 | sortedEnd, | 2877 | sortedEnd, |
2878 | sortedI; | 2878 | sortedI; |
2879 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 2879 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
2880 | catEnd = dti.dta.end(), | 2880 | catEnd = dti.dta.end(), |
2881 | catI = catBegin; | 2881 | catI = catBegin; |
2882 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 2882 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
2883 | int lvpTop, tmpLvp; | 2883 | int lvpTop, tmpLvp; |
2884 | 2884 | ||
2885 | //qDebug("collect:"); | 2885 | //qDebug("collect:"); |
2886 | 2886 | ||
2887 | while (catI != catEnd) { | 2887 | while (catI != catEnd) { |
2888 | lvpTop = -1; | 2888 | lvpTop = -1; |
2889 | sorted.clear(); | 2889 | sorted.clear(); |
2890 | 2890 | ||
2891 | entrBegin = catI->d.begin(); | 2891 | entrBegin = catI->d.begin(); |
2892 | entrEnd = catI->d.end(); | 2892 | entrEnd = catI->d.end(); |
2893 | entrI = entrBegin; | 2893 | entrI = entrBegin; |
2894 | 2894 | ||
2895 | //US: we use the stl sort algorythm to sort all elements in the order | 2895 | //US: we use the stl sort algorythm to sort all elements in the order |
2896 | //of its listViewPos (in the order 1,2,2,3,5,...,x,-1, -1, -1 | 2896 | //of its listViewPos (in the order 1,2,2,3,5,...,x,-1, -1, -1 |
2897 | while (entrI != entrEnd) { | 2897 | while (entrI != entrEnd) { |
2898 | //qDebug("found: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); | 2898 | //qDebug("found: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); |
2899 | sorted.push_back((PwMDataItem*)&(*entrI)); | 2899 | sorted.push_back((PwMDataItem*)&(*entrI)); |
2900 | ++entrI; | 2900 | ++entrI; |
2901 | } | 2901 | } |
2902 | 2902 | ||
2903 | sortedBegin = sorted.begin(); | 2903 | sortedBegin = sorted.begin(); |
2904 | sortedEnd = sorted.end(); | 2904 | sortedEnd = sorted.end(); |
2905 | 2905 | ||
2906 | sort(sortedBegin, sortedEnd, PwMDataItemListViewPosSort()); | 2906 | sort(sortedBegin, sortedEnd, PwMDataItemListViewPosSort()); |
2907 | 2907 | ||
2908 | // qDebug("resort:"); | 2908 | // qDebug("resort:"); |
2909 | //now we have all sorted in a collection | 2909 | //now we have all sorted in a collection |
2910 | //Now start with the sorted and reset listviewpos. | 2910 | //Now start with the sorted and reset listviewpos. |
2911 | sortedBegin = sorted.begin(); | 2911 | sortedBegin = sorted.begin(); |
2912 | sortedEnd = sorted.end(); | 2912 | sortedEnd = sorted.end(); |
2913 | sortedI = sortedBegin; | 2913 | sortedI = sortedBegin; |
2914 | 2914 | ||
2915 | while (sortedI != sortedEnd) { | 2915 | while (sortedI != sortedEnd) { |
2916 | // qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1); | 2916 | // qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1); |
2917 | (*sortedI)->listViewPos = ++lvpTop; | 2917 | (*sortedI)->listViewPos = ++lvpTop; |
2918 | ++sortedI; | 2918 | ++sortedI; |
2919 | } | 2919 | } |
2920 | 2920 | ||
2921 | /*/debug | 2921 | /*/debug |
2922 | entrBegin = catI->d.begin(); | 2922 | entrBegin = catI->d.begin(); |
2923 | entrEnd = catI->d.end(); | 2923 | entrEnd = catI->d.end(); |
2924 | entrI = entrBegin; | 2924 | entrI = entrBegin; |
2925 | 2925 | ||
2926 | while (entrI != entrEnd) { | 2926 | while (entrI != entrEnd) { |
2927 | qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); | 2927 | qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); |
2928 | ++entrI; | 2928 | ++entrI; |
2929 | } | 2929 | } |
2930 | */ | 2930 | */ |
2931 | 2931 | ||
2932 | ++catI; | 2932 | ++catI; |
2933 | } | 2933 | } |
2934 | } | 2934 | } |
2935 | 2935 | ||
2936 | QString PwMDoc::getTitle() | 2936 | QString PwMDoc::getTitle() |
2937 | { | 2937 | { |
2938 | /* NOTE: We have to ensure, that the returned title | 2938 | /* NOTE: We have to ensure, that the returned title |
2939 | * is unique and not reused somewhere else while | 2939 | * is unique and not reused somewhere else while |
2940 | * this document is valid (open). | 2940 | * this document is valid (open). |
2941 | */ | 2941 | */ |
2942 | QString title(getFilename()); | 2942 | QString title(getFilename()); |
2943 | 2943 | ||
2944 | //US ENH: The whole filename on PDAs is too long. So use only the last characters | 2944 | //US ENH: The whole filename on PDAs is too long. So use only the last characters |
2945 | if (QApplication::desktop()->width() < 640) | 2945 | if (QApplication::desktop()->width() < 640) |
2946 | { | 2946 | { |
2947 | if (title.length() > 30) | 2947 | if (title.length() > 30) |
2948 | title = "..." + title.right(30); | 2948 | title = "..." + title.right(30); |
2949 | 2949 | ||
2950 | } | 2950 | } |
2951 | 2951 | ||
2952 | 2952 | ||
2953 | if (title.isEmpty()) { | 2953 | if (title.isEmpty()) { |
2954 | if (unnamedNum == 0) { | 2954 | if (unnamedNum == 0) { |
2955 | unnamedNum = PwMDocList::getNewUnnamedNumber(); | 2955 | unnamedNum = PwMDocList::getNewUnnamedNumber(); |
2956 | PWM_ASSERT(unnamedNum != 0); | 2956 | PWM_ASSERT(unnamedNum != 0); |
2957 | } | 2957 | } |
2958 | title = DEFAULT_TITLE; | 2958 | title = DEFAULT_TITLE; |
2959 | title += " "; | 2959 | title += " "; |
2960 | title += tostr(unnamedNum).c_str(); | 2960 | title += tostr(unnamedNum).c_str(); |
2961 | } | 2961 | } |
2962 | return title; | 2962 | return title; |
2963 | } | 2963 | } |
2964 | 2964 | ||
2965 | bool PwMDoc::tryDelete() | 2965 | bool PwMDoc::tryDelete() |
2966 | { | 2966 | { |
2967 | if (deleted) | 2967 | if (deleted) |
2968 | return true; | 2968 | return true; |
2969 | int ret; | 2969 | int ret; |
2970 | if (isDirty()) { | 2970 | if (isDirty()) { |
2971 | ret = dirtyAskSave(getTitle()); | 2971 | ret = dirtyAskSave(getTitle()); |
2972 | if (ret == 0) { // save to disk | 2972 | if (ret == 0) { // save to disk |
2973 | if (!saveDocUi(this)) | 2973 | if (!saveDocUi(this)) |
2974 | goto out_ignore; | 2974 | goto out_ignore; |
2975 | } else if (ret == 1) { // don't save and delete | 2975 | } else if (ret == 1) { // don't save and delete |
2976 | goto out_accept; | 2976 | goto out_accept; |
2977 | } else { // cancel operation | 2977 | } else { // cancel operation |
2978 | goto out_ignore; | 2978 | goto out_ignore; |
2979 | } | 2979 | } |
2980 | } | 2980 | } |
2981 | out_accept: | 2981 | out_accept: |
2982 | deleted = true; | 2982 | deleted = true; |
2983 | delete this; | 2983 | delete this; |
2984 | return true; | 2984 | return true; |
2985 | out_ignore: | 2985 | out_ignore: |
2986 | return false; | 2986 | return false; |
2987 | } | 2987 | } |
2988 | 2988 | ||
2989 | 2989 | ||
2990 | 2990 | ||
2991 | #ifdef PWM_EMBEDDED | 2991 | #ifdef PWM_EMBEDDED |
2992 | //US ENH: this is the magic function that syncronizes the this doc with the remote doc | 2992 | //US ENH: this is the magic function that syncronizes the this doc with the remote doc |
2993 | //US it could have been defined as static, but I did not want to. | 2993 | //US it could have been defined as static, but I did not want to. |
2994 | PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) | 2994 | PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) |
2995 | { | 2995 | { |
2996 | int addedPasswordsLocal = 0; | 2996 | int addedPasswordsLocal = 0; |
2997 | int addedPasswordsRemote = 0; | 2997 | int addedPasswordsRemote = 0; |
2998 | int deletedPasswordsRemote = 0; | 2998 | int deletedPasswordsRemote = 0; |
2999 | int deletedPasswordsLocal = 0; | 2999 | int deletedPasswordsLocal = 0; |
3000 | int changedLocal = 0; | 3000 | int changedLocal = 0; |
3001 | int changedRemote = 0; | 3001 | int changedRemote = 0; |
3002 | 3002 | ||
3003 | PwMSyncItem* syncItemLocal; | 3003 | PwMSyncItem* syncItemLocal; |
3004 | PwMSyncItem* syncItemRemote; | 3004 | PwMSyncItem* syncItemRemote; |
3005 | 3005 | ||
3006 | QString mCurrentSyncName = manager->getCurrentSyncName(); | 3006 | QString mCurrentSyncName = manager->getCurrentSyncName(); |
3007 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3007 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3008 | 3008 | ||
3009 | bool fullDateRange = false; | 3009 | bool fullDateRange = false; |
3010 | int take; | 3010 | int take; |
3011 | // local->resetTempSyncStat(); | 3011 | // local->resetTempSyncStat(); |
3012 | QDateTime mLastSync = QDateTime::currentDateTime(); | 3012 | QDateTime mLastSync = QDateTime::currentDateTime(); |
3013 | QDateTime modifiedSync = mLastSync; | 3013 | QDateTime modifiedSync = mLastSync; |
3014 | 3014 | ||
3015 | unsigned int index; | 3015 | unsigned int index; |
3016 | //Step 1. Find syncinfo in Local file and create if not existent. | 3016 | //Step 1. Find syncinfo in Local file and create if not existent. |
3017 | bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); | 3017 | bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); |
3018 | if (found == false) | 3018 | if (found == false) |
3019 | { | 3019 | { |
3020 | PwMSyncItem newSyncItemLocal; | 3020 | PwMSyncItem newSyncItemLocal; |
3021 | newSyncItemLocal.syncName = mCurrentSyncDevice; | 3021 | newSyncItemLocal.syncName = mCurrentSyncDevice.latin1(); |
3022 | newSyncItemLocal.lastSyncDate = mLastSync; | 3022 | newSyncItemLocal.lastSyncDate = mLastSync; |
3023 | syncLocal->addSyncDataEntry(&newSyncItemLocal, true); | 3023 | syncLocal->addSyncDataEntry(&newSyncItemLocal, true); |
3024 | found = syncLocal->findSyncData(mCurrentSyncDevice, &index); | 3024 | found = syncLocal->findSyncData(mCurrentSyncDevice, &index); |
3025 | if (found == false) { | 3025 | if (found == false) { |
3026 | qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); | 3026 | qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); |
3027 | return e_syncError; | 3027 | return e_syncError; |
3028 | } | 3028 | } |
3029 | } | 3029 | } |
3030 | 3030 | ||
3031 | syncItemLocal = syncLocal->getSyncDataEntry(index); | 3031 | syncItemLocal = syncLocal->getSyncDataEntry(index); |
3032 | qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1()); | 3032 | qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1()); |
3033 | 3033 | ||
3034 | //Step 2. Find syncinfo in remote file and create if not existent. | 3034 | //Step 2. Find syncinfo in remote file and create if not existent. |
3035 | found = syncRemote->findSyncData(mCurrentSyncName, &index); | 3035 | found = syncRemote->findSyncData(mCurrentSyncName, &index); |
3036 | if (found == false) | 3036 | if (found == false) |
3037 | { | 3037 | { |
3038 | qDebug("FULLDATE 1"); | 3038 | qDebug("FULLDATE 1"); |
3039 | fullDateRange = true; | 3039 | fullDateRange = true; |
3040 | PwMSyncItem newSyncItemRemote; | 3040 | PwMSyncItem newSyncItemRemote; |
3041 | newSyncItemRemote.syncName = mCurrentSyncName; | 3041 | newSyncItemRemote.syncName = mCurrentSyncName.latin1(); |
3042 | newSyncItemRemote.lastSyncDate = mLastSync; | 3042 | newSyncItemRemote.lastSyncDate = mLastSync; |
3043 | syncRemote->addSyncDataEntry(&newSyncItemRemote, true); | 3043 | syncRemote->addSyncDataEntry(&newSyncItemRemote, true); |
3044 | found = syncRemote->findSyncData(mCurrentSyncName, &index); | 3044 | found = syncRemote->findSyncData(mCurrentSyncName, &index); |
3045 | if (found == false) { | 3045 | if (found == false) { |
3046 | qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); | 3046 | qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); |
3047 | return e_syncError; | 3047 | return e_syncError; |
3048 | } | 3048 | } |
3049 | } | 3049 | } |
3050 | 3050 | ||
3051 | syncItemRemote = syncRemote->getSyncDataEntry(index); | 3051 | syncItemRemote = syncRemote->getSyncDataEntry(index); |
3052 | qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1()); | 3052 | qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1()); |
3053 | //and remove the found entry here. We will reenter it later again. | 3053 | //and remove the found entry here. We will reenter it later again. |
3054 | //US syncRemote->delSyncDataEntry(index, true); | 3054 | //US syncRemote->delSyncDataEntry(index, true); |
3055 | 3055 | ||
3056 | 3056 | ||
3057 | if ( syncItemLocal->lastSyncDate == mLastSync ) { | 3057 | if ( syncItemLocal->lastSyncDate == mLastSync ) { |
3058 | qDebug("FULLDATE 2"); | 3058 | qDebug("FULLDATE 2"); |
3059 | fullDateRange = true; | 3059 | fullDateRange = true; |
3060 | } | 3060 | } |
3061 | 3061 | ||
3062 | if ( ! fullDateRange ) { | 3062 | if ( ! fullDateRange ) { |
3063 | if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { | 3063 | if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { |
3064 | 3064 | ||
3065 | fullDateRange = true; | 3065 | fullDateRange = true; |
3066 | qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); | 3066 | qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); |
3067 | } | 3067 | } |
3068 | } | 3068 | } |
3069 | // fullDateRange = true; // debug only! | 3069 | // fullDateRange = true; // debug only! |
3070 | if ( fullDateRange ) | 3070 | if ( fullDateRange ) |
3071 | mLastSync = QDateTime::currentDateTime().addDays( -100*365); | 3071 | mLastSync = QDateTime::currentDateTime().addDays( -100*365); |
3072 | else | 3072 | else |
3073 | mLastSync = syncItemLocal->lastSyncDate; | 3073 | mLastSync = syncItemLocal->lastSyncDate; |
3074 | 3074 | ||
3075 | 3075 | ||
3076 | qDebug("*************************** "); | 3076 | qDebug("*************************** "); |
3077 | qDebug("mLastSync %s ",mLastSync.toString().latin1() ); | 3077 | qDebug("mLastSync %s ",mLastSync.toString().latin1() ); |
3078 | QStringList er = syncRemote->getIDEntryList(); | 3078 | QStringList er = syncRemote->getIDEntryList(); |
3079 | PwMDataItem* inRemote ;//= er.first(); | 3079 | PwMDataItem* inRemote ;//= er.first(); |
3080 | PwMDataItem* inLocal; | 3080 | PwMDataItem* inLocal; |
3081 | unsigned int catLocal, indexLocal; | 3081 | unsigned int catLocal, indexLocal; |
3082 | unsigned int catRemote, indexRemote; | 3082 | unsigned int catRemote, indexRemote; |
3083 | 3083 | ||
3084 | QString uid; | 3084 | QString uid; |
3085 | manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 3085 | manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
3086 | 3086 | ||
3087 | int modulo = (er.count()/10)+1; | 3087 | int modulo = (er.count()/10)+1; |
3088 | unsigned int incCounter = 0; | 3088 | unsigned int incCounter = 0; |
3089 | while ( incCounter < er.count()) { | 3089 | while ( incCounter < er.count()) { |
3090 | if (manager->isProgressBarCanceled()) | 3090 | if (manager->isProgressBarCanceled()) |
3091 | return e_syncError; | 3091 | return e_syncError; |
3092 | if ( incCounter % modulo == 0 ) | 3092 | if ( incCounter % modulo == 0 ) |
3093 | manager->showProgressBar(incCounter); | 3093 | manager->showProgressBar(incCounter); |
3094 | 3094 | ||
3095 | uid = er[ incCounter ]; | 3095 | uid = er[ incCounter ]; |
3096 | qDebug("sync uid %s from remote file", uid.latin1()); | 3096 | qDebug("sync uid %s from remote file", uid.latin1()); |
3097 | 3097 | ||
3098 | qApp->processEvents(); | 3098 | qApp->processEvents(); |
3099 | 3099 | ||
3100 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); | 3100 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); |
3101 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); | 3101 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); |
3102 | PWM_ASSERT(inRemote); | 3102 | PWM_ASSERT(inRemote); |
3103 | if ( inLocal != 0 ) { // maybe conflict - same uid in both files | 3103 | if ( inLocal != 0 ) { // maybe conflict - same uid in both files |
3104 | if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { | 3104 | if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { |
3105 | qDebug("take %d %s ", take, inLocal->desc.c_str()); | 3105 | qDebug("take %d %s ", take, inLocal->desc.c_str()); |
3106 | if ( take == 3 ) | 3106 | if ( take == 3 ) |
3107 | return e_syncError; | 3107 | return e_syncError; |
3108 | if ( take == 1 ) {// take local | 3108 | if ( take == 1 ) {// take local |
3109 | int oldlistpos = inRemote->listViewPos; | 3109 | int oldlistpos = inRemote->listViewPos; |
3110 | (*inRemote) = (*inLocal); | 3110 | (*inRemote) = (*inLocal); |
3111 | inRemote->listViewPos = oldlistpos; | 3111 | inRemote->listViewPos = oldlistpos; |
3112 | ++changedRemote; | 3112 | ++changedRemote; |
3113 | } else { // take == 2 take remote | 3113 | } else { // take == 2 take remote |
3114 | int oldlistpos = inLocal->listViewPos; | 3114 | int oldlistpos = inLocal->listViewPos; |
3115 | (*inLocal) = (*inRemote); | 3115 | (*inLocal) = (*inRemote); |
3116 | inLocal->listViewPos = oldlistpos; | 3116 | inLocal->listViewPos = oldlistpos; |
3117 | ++changedLocal; | 3117 | ++changedLocal; |
3118 | } | 3118 | } |
3119 | } | 3119 | } |
3120 | } else { // no conflict | 3120 | } else { // no conflict |
3121 | if ( inRemote->meta.update > mLastSync || mode == 5 ) { | 3121 | if ( inRemote->meta.update > mLastSync || mode == 5 ) { |
3122 | inRemote->meta.update = modifiedSync; | 3122 | inRemote->meta.update = modifiedSync; |
3123 | 3123 | ||
3124 | //first check if we have a matching category in the local file | 3124 | //first check if we have a matching category in the local file |
3125 | const string* remotecat = syncRemote->getCategory(catRemote); | 3125 | const string* remotecat = syncRemote->getCategory(catRemote); |
3126 | //US syncRemote->insertAddressee( inRemote, false ); | 3126 | //US syncRemote->insertAddressee( inRemote, false ); |
3127 | //US syncLocal->insertAddressee( inRemote, false ); | 3127 | //US syncLocal->insertAddressee( inRemote, false ); |
3128 | syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); | 3128 | syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); |
3129 | 3129 | ||
3130 | ++addedPasswordsLocal; | 3130 | ++addedPasswordsLocal; |
3131 | } else { | 3131 | } else { |
3132 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 3132 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
3133 | syncRemote->delEntry(catRemote, indexRemote, true); | 3133 | syncRemote->delEntry(catRemote, indexRemote, true); |
3134 | //USsyncRemote->removeAddressee( inRemote ); | 3134 | //USsyncRemote->removeAddressee( inRemote ); |
3135 | ++deletedPasswordsRemote; | 3135 | ++deletedPasswordsRemote; |
3136 | } | 3136 | } |
3137 | } | 3137 | } |
3138 | 3138 | ||
3139 | ++incCounter; | 3139 | ++incCounter; |
3140 | } | 3140 | } |
3141 | 3141 | ||
3142 | 3142 | ||
3143 | er.clear(); | 3143 | er.clear(); |
3144 | QStringList el = syncLocal->getIDEntryList(); | 3144 | QStringList el = syncLocal->getIDEntryList(); |
3145 | modulo = (el.count()/10)+1; | 3145 | modulo = (el.count()/10)+1; |
3146 | 3146 | ||
3147 | manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3147 | manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3148 | incCounter = 0; | 3148 | incCounter = 0; |
3149 | while ( incCounter < el.count()) { | 3149 | while ( incCounter < el.count()) { |
3150 | qApp->processEvents(); | 3150 | qApp->processEvents(); |
3151 | if (manager->isProgressBarCanceled()) | 3151 | if (manager->isProgressBarCanceled()) |
3152 | return e_syncError; | 3152 | return e_syncError; |
3153 | if ( incCounter % modulo == 0 ) | 3153 | if ( incCounter % modulo == 0 ) |
3154 | manager->showProgressBar(incCounter); | 3154 | manager->showProgressBar(incCounter); |
3155 | uid = el[ incCounter ]; | 3155 | uid = el[ incCounter ]; |
3156 | qDebug("sync uid %s from local file", uid.latin1()); | 3156 | qDebug("sync uid %s from local file", uid.latin1()); |
3157 | 3157 | ||
3158 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); | 3158 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); |
3159 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); | 3159 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); |
3160 | PWM_ASSERT(inLocal); | 3160 | PWM_ASSERT(inLocal); |
3161 | 3161 | ||
3162 | if ( inRemote == 0 ) { | 3162 | if ( inRemote == 0 ) { |
3163 | if ( inLocal->meta.update < mLastSync && mode != 4 ) { | 3163 | if ( inLocal->meta.update < mLastSync && mode != 4 ) { |
3164 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3164 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3165 | syncLocal->delEntry(catLocal, indexLocal, true); | 3165 | syncLocal->delEntry(catLocal, indexLocal, true); |
3166 | //USsyncLocal->removeAddressee( inLocal ); | 3166 | //USsyncLocal->removeAddressee( inLocal ); |
3167 | ++deletedPasswordsLocal; | 3167 | ++deletedPasswordsLocal; |
3168 | } else { | 3168 | } else { |
3169 | if ( ! manager->mWriteBackExistingOnly ) { | 3169 | if ( ! manager->mWriteBackExistingOnly ) { |
3170 | ++addedPasswordsRemote; | 3170 | ++addedPasswordsRemote; |
3171 | inLocal->meta.update = modifiedSync; | 3171 | inLocal->meta.update = modifiedSync; |
3172 | 3172 | ||
3173 | //first check if we have a matching category in the remote file | 3173 | //first check if we have a matching category in the remote file |
3174 | const string* localcat = syncLocal->getCategory(catLocal); | 3174 | const string* localcat = syncLocal->getCategory(catLocal); |
3175 | 3175 | ||
3176 | //USsyncLocal->insertAddressee( inLocal, false ); | 3176 | //USsyncLocal->insertAddressee( inLocal, false ); |
3177 | PwMDataItem newEntry; | 3177 | PwMDataItem newEntry; |
3178 | newEntry = *inLocal; | 3178 | newEntry = *inLocal; |
3179 | inRemote = &newEntry; | 3179 | inRemote = &newEntry; |
3180 | 3180 | ||
3181 | //USsyncRemote->insertAddressee( inRemote, false ); | 3181 | //USsyncRemote->insertAddressee( inRemote, false ); |
3182 | syncRemote->addEntry(localcat->c_str(), inRemote, true, false); | 3182 | syncRemote->addEntry(localcat->c_str(), inRemote, true, false); |
3183 | 3183 | ||
3184 | } | 3184 | } |
3185 | } | 3185 | } |
3186 | 3186 | ||
3187 | } | 3187 | } |
3188 | ++incCounter; | 3188 | ++incCounter; |
3189 | } | 3189 | } |
3190 | el.clear(); | 3190 | el.clear(); |
3191 | manager->hideProgressBar(); | 3191 | manager->hideProgressBar(); |
3192 | 3192 | ||
3193 | // Now write the info back into the sync data space of the files | 3193 | // Now write the info back into the sync data space of the files |
3194 | 3194 | ||
3195 | mLastSync = QDateTime::currentDateTime().addSecs( 1 ); | 3195 | mLastSync = QDateTime::currentDateTime().addSecs( 1 ); |
3196 | // get rid of micro seconds | 3196 | // get rid of micro seconds |
3197 | QTime t = mLastSync.time(); | 3197 | QTime t = mLastSync.time(); |
3198 | mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3198 | mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3199 | 3199 | ||
3200 | 3200 | ||
3201 | syncItemLocal->lastSyncDate = mLastSync; | 3201 | syncItemLocal->lastSyncDate = mLastSync; |
3202 | syncItemRemote->lastSyncDate = mLastSync; | 3202 | syncItemRemote->lastSyncDate = mLastSync; |
3203 | 3203 | ||
3204 | QString mes; | 3204 | QString mes; |
3205 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote ); | 3205 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote ); |
3206 | if ( manager->mShowSyncSummary ) { | 3206 | if ( manager->mShowSyncSummary ) { |
3207 | KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); | 3207 | KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); |
3208 | } | 3208 | } |
3209 | qDebug( mes ); | 3209 | qDebug( mes ); |
3210 | return e_success; | 3210 | return e_success; |
3211 | } | 3211 | } |
3212 | 3212 | ||
3213 | 3213 | ||
3214 | int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) | 3214 | int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) |
3215 | { | 3215 | { |
3216 | // 0 equal | 3216 | // 0 equal |
3217 | // 1 take local | 3217 | // 1 take local |
3218 | // 2 take remote | 3218 | // 2 take remote |
3219 | // 3 cancel | 3219 | // 3 cancel |
3220 | QDateTime localMod = local->meta.update; | 3220 | QDateTime localMod = local->meta.update; |
3221 | QDateTime remoteMod = remote->meta.update; | 3221 | QDateTime remoteMod = remote->meta.update; |
3222 | 3222 | ||
3223 | //US QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3223 | //US QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3224 | 3224 | ||
3225 | if ( localMod == remoteMod ) | 3225 | if ( localMod == remoteMod ) |
3226 | return 0; | 3226 | return 0; |
3227 | 3227 | ||
3228 | qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); | 3228 | qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); |
3229 | 3229 | ||
3230 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 3230 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
3231 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 3231 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
3232 | //full = true; //debug only | 3232 | //full = true; //debug only |
3233 | if ( full ) { | 3233 | if ( full ) { |
3234 | bool equ = ( (*local) == (*remote) ); | 3234 | bool equ = ( (*local) == (*remote) ); |
3235 | if ( equ ) { | 3235 | if ( equ ) { |
3236 | //qDebug("equal "); | 3236 | //qDebug("equal "); |
3237 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 3237 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
3238 | return 0; | 3238 | return 0; |
3239 | 3239 | ||
3240 | }//else //debug only | 3240 | }//else //debug only |
3241 | //qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str()); | 3241 | //qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str()); |
3242 | } | 3242 | } |
3243 | 3243 | ||
3244 | int result; | 3244 | int result; |
3245 | bool localIsNew; | 3245 | bool localIsNew; |
3246 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 3246 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
3247 | 3247 | ||
3248 | if ( full && mode < SYNC_PREF_NEWEST ) | 3248 | if ( full && mode < SYNC_PREF_NEWEST ) |
3249 | mode = SYNC_PREF_ASK; | 3249 | mode = SYNC_PREF_ASK; |
3250 | 3250 | ||
3251 | switch( mode ) { | 3251 | switch( mode ) { |
3252 | case SYNC_PREF_LOCAL: | 3252 | case SYNC_PREF_LOCAL: |
3253 | if ( lastSync > remoteMod ) | 3253 | if ( lastSync > remoteMod ) |
3254 | return 1; | 3254 | return 1; |
3255 | if ( lastSync > localMod ) | 3255 | if ( lastSync > localMod ) |
3256 | return 2; | 3256 | return 2; |
3257 | return 1; | 3257 | return 1; |
3258 | break; | 3258 | break; |
3259 | case SYNC_PREF_REMOTE: | 3259 | case SYNC_PREF_REMOTE: |
3260 | if ( lastSync > remoteMod ) | 3260 | if ( lastSync > remoteMod ) |
3261 | return 1; | 3261 | return 1; |
3262 | if ( lastSync > localMod ) | 3262 | if ( lastSync > localMod ) |
3263 | return 2; | 3263 | return 2; |
3264 | return 2; | 3264 | return 2; |
3265 | break; | 3265 | break; |
3266 | case SYNC_PREF_NEWEST: | 3266 | case SYNC_PREF_NEWEST: |
3267 | if ( localMod > remoteMod ) | 3267 | if ( localMod > remoteMod ) |
3268 | return 1; | 3268 | return 1; |
3269 | else | 3269 | else |
3270 | return 2; | 3270 | return 2; |
3271 | break; | 3271 | break; |
3272 | case SYNC_PREF_ASK: | 3272 | case SYNC_PREF_ASK: |
3273 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 3273 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
3274 | if ( lastSync > remoteMod ) | 3274 | if ( lastSync > remoteMod ) |
3275 | return 1; | 3275 | return 1; |
3276 | if ( lastSync > localMod ) | 3276 | if ( lastSync > localMod ) |
3277 | return 2; | 3277 | return 2; |
3278 | localIsNew = localMod >= remoteMod; | 3278 | localIsNew = localMod >= remoteMod; |
3279 | //qDebug("conflict! ************************************** "); | 3279 | //qDebug("conflict! ************************************** "); |
3280 | { | 3280 | { |
3281 | PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); | 3281 | PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); |
3282 | result = acd.executeD(localIsNew); | 3282 | result = acd.executeD(localIsNew); |
3283 | return result; | 3283 | return result; |
3284 | } | 3284 | } |
3285 | break; | 3285 | break; |
3286 | case SYNC_PREF_FORCE_LOCAL: | 3286 | case SYNC_PREF_FORCE_LOCAL: |
3287 | return 1; | 3287 | return 1; |
3288 | break; | 3288 | break; |
3289 | case SYNC_PREF_FORCE_REMOTE: | 3289 | case SYNC_PREF_FORCE_REMOTE: |
3290 | return 2; | 3290 | return 2; |
3291 | break; | 3291 | break; |
3292 | 3292 | ||
3293 | default: | 3293 | default: |
3294 | // SYNC_PREF_TAKE_BOTH not implemented | 3294 | // SYNC_PREF_TAKE_BOTH not implemented |
3295 | break; | 3295 | break; |
3296 | } | 3296 | } |
3297 | return 0; | 3297 | return 0; |
3298 | } | 3298 | } |
3299 | 3299 | ||
3300 | 3300 | ||
3301 | 3301 | ||
3302 | 3302 | ||
3303 | //this are the overwritten callbackmethods from the syncinterface | 3303 | //this are the overwritten callbackmethods from the syncinterface |
3304 | bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) | 3304 | bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) |
3305 | { | 3305 | { |
3306 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3306 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3307 | 3307 | ||
3308 | //1) unlock local file first if necessary (ask for password) | 3308 | //1) unlock local file first if necessary (ask for password) |
3309 | if (this->isDeepLocked()) { | 3309 | if (this->isDeepLocked()) { |
3310 | PwMerror ret = this->deepLock(false); | 3310 | PwMerror ret = this->deepLock(false); |
3311 | if (ret != e_success) | 3311 | if (ret != e_success) |
3312 | return false; | 3312 | return false; |
3313 | } | 3313 | } |
3314 | 3314 | ||
3315 | //2) construct and open a new doc on the stack(automatic cleanup of remote file). | 3315 | //2) construct and open a new doc on the stack(automatic cleanup of remote file). |
3316 | PwMDoc syncTarget(this, "synctarget"); | 3316 | PwMDoc syncTarget(this, "synctarget"); |
3317 | PwMDoc* pSyncTarget = &syncTarget; | 3317 | PwMDoc* pSyncTarget = &syncTarget; |
3318 | 3318 | ||
3319 | 3319 | ||
3320 | PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); | 3320 | PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); |
3321 | 3321 | ||
3322 | if (err == e_alreadyOpen) { | 3322 | if (err == e_alreadyOpen) { |
3323 | PwMDocList::listItem li; | 3323 | PwMDocList::listItem li; |
3324 | if (getOpenDocList()->find(filename.latin1(), &li)) | 3324 | if (getOpenDocList()->find(filename.latin1(), &li)) |
3325 | pSyncTarget = li.doc; | 3325 | pSyncTarget = li.doc; |
3326 | else { | 3326 | else { |
3327 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); | 3327 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); |
3328 | return false; | 3328 | return false; |
3329 | } | 3329 | } |
3330 | } | 3330 | } |
3331 | else if (err != e_success) { | 3331 | else if (err != e_success) { |
3332 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); | 3332 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); |
3333 | return false; | 3333 | return false; |
3334 | } | 3334 | } |
3335 | 3335 | ||
3336 | qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); | 3336 | qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); |
3337 | 3337 | ||
3338 | 3338 | ||
3339 | //3) unlock remote file first if necessary (ask for password) | 3339 | //3) unlock remote file first if necessary (ask for password) |
3340 | if (pSyncTarget->isDeepLocked()) { | 3340 | if (pSyncTarget->isDeepLocked()) { |
3341 | PwMerror ret = pSyncTarget->deepLock(false); | 3341 | PwMerror ret = pSyncTarget->deepLock(false); |
3342 | if (ret != e_success) | 3342 | if (ret != e_success) |
3343 | return false; | 3343 | return false; |
3344 | } | 3344 | } |
3345 | 3345 | ||
3346 | 3346 | ||
3347 | err = syncronize(manager, this, pSyncTarget, mode ); | 3347 | err = syncronize(manager, this, pSyncTarget, mode ); |
3348 | 3348 | ||
3349 | if (err == e_success) { | 3349 | if (err == e_success) { |
3350 | if ( manager->mWriteBackFile ){ | 3350 | if ( manager->mWriteBackFile ){ |
3351 | qDebug("Saving remote PWManager file"); | 3351 | qDebug("Saving remote PWManager file"); |
3352 | err = pSyncTarget->saveDoc(conf()->confGlobCompression()); | 3352 | err = pSyncTarget->saveDoc(conf()->confGlobCompression()); |
3353 | if (err != e_success) { | 3353 | if (err != e_success) { |
3354 | qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); | 3354 | qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); |
3355 | return false; | 3355 | return false; |
3356 | } | 3356 | } |
3357 | } | 3357 | } |
3358 | 3358 | ||
3359 | flagDirty(); | 3359 | flagDirty(); |
3360 | return true; | 3360 | return true; |
3361 | } | 3361 | } |
3362 | else { | 3362 | else { |
3363 | return false; | 3363 | return false; |
3364 | } | 3364 | } |
3365 | } | 3365 | } |
3366 | 3366 | ||
3367 | #endif | 3367 | #endif |
3368 | 3368 | ||
3369 | 3369 | ||
3370 | bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index) | 3370 | bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index) |
3371 | { | 3371 | { |
3372 | vector<PwMSyncItem>::iterator i = dti.syncDta.begin(), | 3372 | vector<PwMSyncItem>::iterator i = dti.syncDta.begin(), |
3373 | end = dti.syncDta.end(); | 3373 | end = dti.syncDta.end(); |
3374 | 3374 | ||
3375 | while (i != end) { | 3375 | while (i != end) { |
3376 | if ((*i).syncName == syncname.latin1()) { | 3376 | if ((*i).syncName == syncname.latin1()) { |
3377 | if (index) { | 3377 | if (index) { |
3378 | *index = i - dti.syncDta.begin(); | 3378 | *index = i - dti.syncDta.begin(); |
3379 | } | 3379 | } |
3380 | return true; | 3380 | return true; |
3381 | } | 3381 | } |
3382 | ++i; | 3382 | ++i; |
3383 | } | 3383 | } |
3384 | return false; | 3384 | return false; |
3385 | }; | 3385 | }; |
3386 | 3386 | ||
3387 | /** add new syncdataentry */ | 3387 | /** add new syncdataentry */ |
3388 | PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty) | 3388 | PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty) |
3389 | { | 3389 | { |
3390 | PWM_ASSERT(d); | 3390 | PWM_ASSERT(d); |
3391 | 3391 | ||
3392 | if (isDeepLocked()) { | 3392 | if (isDeepLocked()) { |
3393 | PwMerror ret; | 3393 | PwMerror ret; |
3394 | ret = deepLock(false); | 3394 | ret = deepLock(false); |
3395 | if (ret != e_success) | 3395 | if (ret != e_success) |
3396 | return e_lock; | 3396 | return e_lock; |
3397 | } | 3397 | } |
3398 | unsigned int index; | 3398 | unsigned int index; |
3399 | 3399 | ||
3400 | const QString tmp = d->syncName.c_str(); | 3400 | const QString tmp = d->syncName.c_str(); |
3401 | bool exists = findSyncData(d->syncName.c_str(), &index); | 3401 | bool exists = findSyncData(d->syncName.c_str(), &index); |
3402 | 3402 | ||
3403 | if (exists == true) { | 3403 | if (exists == true) { |
3404 | // DOH! We found this entry. | 3404 | // DOH! We found this entry. |
3405 | return e_entryExists; | 3405 | return e_entryExists; |
3406 | } | 3406 | } |
3407 | 3407 | ||
3408 | dti.syncDta.push_back(*d); | 3408 | dti.syncDta.push_back(*d); |
3409 | 3409 | ||
3410 | if (!dontFlagDirty) | 3410 | if (!dontFlagDirty) |
3411 | flagDirty(); | 3411 | flagDirty(); |
3412 | return e_success; | 3412 | return e_success; |
3413 | } | 3413 | } |
3414 | 3414 | ||
3415 | 3415 | ||
3416 | 3416 | ||
3417 | /** delete syncdata entry */ | 3417 | /** delete syncdata entry */ |
3418 | bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty) | 3418 | bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty) |
3419 | { | 3419 | { |
3420 | if (isDeepLocked()) | 3420 | if (isDeepLocked()) |
3421 | return false; | 3421 | return false; |
3422 | if (index > dti.syncDta.size() - 1) | 3422 | if (index > dti.syncDta.size() - 1) |
3423 | return false; | 3423 | return false; |
3424 | 3424 | ||
3425 | // delete entry | 3425 | // delete entry |
diff --git a/pwmanager/pwmanager/pwminit.cpp b/pwmanager/pwmanager/pwminit.cpp index 8946443..ea9e330 100644 --- a/pwmanager/pwmanager/pwminit.cpp +++ b/pwmanager/pwmanager/pwminit.cpp | |||
@@ -1,632 +1,640 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2004 by Michael Buesch * | 3 | * copyright (C) 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.0.1 of pwmanager | 14 | * This file is originaly based on version 1.0.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 | #include "pwminit.h" | 20 | #include "pwminit.h" |
21 | #include "randomizer.h" | 21 | #include "randomizer.h" |
22 | #include <qdir.h> | ||
22 | 23 | ||
23 | #ifndef PWM_EMBEDDED | 24 | #ifndef PWM_EMBEDDED |
24 | #include "selftest.h" | 25 | #include "selftest.h" |
25 | #include "configuration.h" | 26 | #include "configuration.h" |
26 | #else | 27 | #else |
27 | #include "pwmprefs.h" | 28 | #include "pwmprefs.h" |
28 | #endif | 29 | #endif |
29 | 30 | ||
30 | #include "pwm.h" | 31 | #include "pwm.h" |
31 | #include "pwmexception.h" | 32 | #include "pwmexception.h" |
32 | #include "pwmtray.h" | 33 | #include "pwmtray.h" |
33 | #include "pwmdoc.h" | 34 | #include "pwmdoc.h" |
34 | 35 | ||
35 | #ifdef CONFIG_KWALLETIF | 36 | #ifdef CONFIG_KWALLETIF |
36 | # include "kwalletemu.h" | 37 | # include "kwalletemu.h" |
37 | #endif // CONFIG_KWALLETIF | 38 | #endif // CONFIG_KWALLETIF |
38 | #ifdef CONFIG_KEYCARD | 39 | #ifdef CONFIG_KEYCARD |
39 | # include "pwmkeycard.h" | 40 | # include "pwmkeycard.h" |
40 | #endif // CONFIG_KEYCARD | 41 | #endif // CONFIG_KEYCARD |
41 | 42 | ||
42 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
43 | 44 | ||
44 | #include <kmessagebox.h> | 45 | #include <kmessagebox.h> |
45 | #ifndef PWM_EMBEDDED | 46 | #ifndef PWM_EMBEDDED |
46 | #include <kcmdlineargs.h> | 47 | #include <kcmdlineargs.h> |
47 | #include <kwin.h> | 48 | #include <kwin.h> |
48 | #include <dcopclient.h> | 49 | #include <dcopclient.h> |
49 | #endif | 50 | #endif |
50 | 51 | ||
51 | #include <kapplication.h> | 52 | #include <kapplication.h> |
52 | #include <kiconloader.h> | 53 | #include <kiconloader.h> |
53 | 54 | ||
54 | #include <signal.h> | 55 | #include <signal.h> |
55 | 56 | ||
56 | static PwMInit *sig_init_pointer; | 57 | static PwMInit *sig_init_pointer; |
57 | static NOREGPARM void sig_handler(int signum) | 58 | static NOREGPARM void sig_handler(int signum) |
58 | { | 59 | { |
59 | switch (signum) { | 60 | switch (signum) { |
60 | case SIGINT: | 61 | case SIGINT: |
61 | case SIGTERM: | 62 | case SIGTERM: |
62 | sig_init_pointer->shutdownApp(20 + signum); | 63 | sig_init_pointer->shutdownApp(20 + signum); |
63 | break; | 64 | break; |
64 | default: | 65 | default: |
65 | printDebug(string("unhandled signal ") | 66 | printDebug(string("unhandled signal ") |
66 | + tostr(signum)); | 67 | + tostr(signum)); |
67 | } | 68 | } |
68 | } | 69 | } |
69 | 70 | ||
70 | 71 | ||
71 | 72 | ||
72 | 73 | ||
73 | PwMInit::PwMInit(PwMApplication *_app) | 74 | PwMInit::PwMInit(PwMApplication *_app) |
74 | : runStatus (unknown) | 75 | : runStatus (unknown) |
75 | , _curWidget (0) | 76 | , _curWidget (0) |
76 | , _dcopClient (0) | 77 | , _dcopClient (0) |
77 | , _kwalletEmu (0) | 78 | , _kwalletEmu (0) |
78 | , _keycard (0) | 79 | , _keycard (0) |
79 | , _tray (0) | 80 | , _tray (0) |
80 | { | 81 | { |
81 | sig_init_pointer = this; | 82 | sig_init_pointer = this; |
82 | app = _app; | 83 | app = _app; |
83 | } | 84 | } |
84 | 85 | ||
85 | PwMInit::~PwMInit() | 86 | PwMInit::~PwMInit() |
86 | { | 87 | { |
87 | #ifndef PWM_EMBEDDED | 88 | #ifndef PWM_EMBEDDED |
88 | SelfTest::cancel(); | 89 | SelfTest::cancel(); |
89 | // close all open mainwnds | 90 | // close all open mainwnds |
90 | QValueList<PwM *>::iterator i = _mainWndList.begin(), | 91 | QValueList<PwM *>::iterator i = _mainWndList.begin(), |
91 | end = _mainWndList.end(); | 92 | end = _mainWndList.end(); |
92 | 93 | ||
93 | #else | 94 | #else |
94 | // close all open mainwnds | 95 | // close all open mainwnds |
95 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), | 96 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), |
96 | end = _mainWndList.end(); | 97 | end = _mainWndList.end(); |
97 | #endif | 98 | #endif |
98 | while (i != end) { | 99 | while (i != end) { |
99 | disconnect(*i, SIGNAL(closed(PwM *)), | 100 | disconnect(*i, SIGNAL(closed(PwM *)), |
100 | this, SLOT(mainWndClosed(PwM *))); | 101 | this, SLOT(mainWndClosed(PwM *))); |
101 | delete *i; | 102 | delete *i; |
102 | ++i; | 103 | ++i; |
103 | } | 104 | } |
104 | _mainWndList.clear(); | 105 | _mainWndList.clear(); |
105 | // close all remaining open documents | 106 | // close all remaining open documents |
106 | PwMDocList *_dl = PwMDoc::getOpenDocList(); | 107 | PwMDocList *_dl = PwMDoc::getOpenDocList(); |
107 | vector<PwMDocList::listItem> dl = *(_dl->getList()); | 108 | vector<PwMDocList::listItem> dl = *(_dl->getList()); |
108 | vector<PwMDocList::listItem>::iterator i2 = dl.begin(), | 109 | vector<PwMDocList::listItem>::iterator i2 = dl.begin(), |
109 | end2 = dl.end(); | 110 | end2 = dl.end(); |
110 | while (i2 != end2) { | 111 | while (i2 != end2) { |
111 | delete (*i2).doc; | 112 | delete (*i2).doc; |
112 | ++i2; | 113 | ++i2; |
113 | } | 114 | } |
114 | 115 | ||
115 | #ifdef CONFIG_KWALLETIF | 116 | #ifdef CONFIG_KWALLETIF |
116 | delete_ifnot_null(_kwalletEmu); | 117 | delete_ifnot_null(_kwalletEmu); |
117 | #endif // CONFIG_KWALLETIF | 118 | #endif // CONFIG_KWALLETIF |
118 | #ifdef CONFIG_KEYCARD | 119 | #ifdef CONFIG_KEYCARD |
119 | delete_ifnot_null(_keycard); | 120 | delete_ifnot_null(_keycard); |
120 | #endif // CONFIG_KEYCARD | 121 | #endif // CONFIG_KEYCARD |
121 | delete_ifnot_null(_tray); | 122 | delete_ifnot_null(_tray); |
122 | 123 | ||
123 | Randomizer::cleanup(); | 124 | Randomizer::cleanup(); |
124 | #ifndef PWM_EMBEDDED | 125 | #ifndef PWM_EMBEDDED |
125 | Configuration::cleanup(); | 126 | Configuration::cleanup(); |
126 | #endif | 127 | #endif |
127 | } | 128 | } |
128 | 129 | ||
129 | void PwMInit::initializeApp() | 130 | void PwMInit::initializeApp() |
130 | { | 131 | { |
132 | qDebug("PwMInit::initializeApp() "); | ||
131 | PWM_ASSERT(runStatus == unknown); | 133 | PWM_ASSERT(runStatus == unknown); |
132 | runStatus = init; | 134 | runStatus = init; |
133 | initPosixSignalHandler(); | 135 | initPosixSignalHandler(); |
134 | Randomizer::init(); | 136 | Randomizer::init(); |
135 | #ifndef PWM_EMBEDDED | 137 | #ifndef PWM_EMBEDDED |
136 | Configuration::init(); | 138 | Configuration::init(); |
137 | #endif | 139 | #endif |
138 | initDCOP(); | 140 | initDCOP(); |
139 | initKWalletEmu(); | 141 | initKWalletEmu(); |
140 | initKeycard(); | 142 | initKeycard(); |
141 | initTray(); | 143 | initTray(); |
142 | handleCmdLineArgs(); | 144 | handleCmdLineArgs(); |
143 | 145 | qDebug("handle "); | |
144 | bool openDeeplocked = false; | 146 | bool openDeeplocked = false; |
145 | if (conf()->confGlobAutostartDeepLocked() || | 147 | if (conf()->confGlobAutostartDeepLocked() || |
146 | savedCmd.open_deeplocked) | 148 | savedCmd.open_deeplocked) |
147 | openDeeplocked = true; | 149 | openDeeplocked = true; |
148 | if (conf()->confWndAutoMinimizeOnStart() || | 150 | if ( false ){ |
149 | savedCmd.minToTray) { | 151 | // LR is not working |
152 | //if (conf()->confWndAutoMinimizeOnStart() || | ||
153 | // savedCmd.minToTray) { | ||
150 | PwMDoc *newDoc = createDoc(); | 154 | PwMDoc *newDoc = createDoc(); |
155 | qDebug(" createDoc()"); | ||
151 | if (!newDoc->openDocUi(newDoc, | 156 | if (!newDoc->openDocUi(newDoc, |
152 | conf()->confGlobAutoStart(), | 157 | conf()->confGlobAutoStart(), |
153 | openDeeplocked)) { | 158 | openDeeplocked)) { |
154 | delete newDoc; | 159 | delete newDoc; |
160 | } | ||
155 | 161 | ||
156 | //US ENH for embedded devices: in the case of failure, open a document the default way | 162 | //US ENH for embedded devices: in the case of failure, open a document the default way |
157 | createMainWnd(conf()->confGlobAutoStart(), | 163 | createMainWnd(conf()->confGlobAutoStart(), |
158 | openDeeplocked, | 164 | openDeeplocked, |
159 | true, | 165 | true, |
160 | 0, | 166 | 0, |
161 | savedCmd.minimized); | 167 | savedCmd.minimized); |
162 | 168 | ||
163 | 169 | ||
164 | 170 | ||
165 | 171 | ||
166 | } | 172 | //} |
167 | } else { | 173 | } else { |
168 | createMainWnd(conf()->confGlobAutoStart(), | 174 | createMainWnd(conf()->confGlobAutoStart(), |
169 | openDeeplocked, | 175 | openDeeplocked, |
170 | true, | 176 | true, |
171 | 0, | 177 | 0, |
172 | savedCmd.minimized); | 178 | savedCmd.minimized); |
173 | } | 179 | } |
174 | 180 | ||
175 | runStatus = running; | 181 | runStatus = running; |
176 | } | 182 | } |
177 | 183 | ||
178 | void PwMInit::shutdownApp(int exitStatus) | 184 | void PwMInit::shutdownApp(int exitStatus) |
179 | { | 185 | { |
180 | printDebug(string("PwMInit::shutdownApp(") | 186 | printDebug(string("PwMInit::shutdownApp(") |
181 | + tostr(exitStatus) + ") called."); | 187 | + tostr(exitStatus) + ") called."); |
182 | PWM_ASSERT((runStatus == running) || (runStatus == init)); | 188 | PWM_ASSERT((runStatus == running) || (runStatus == init)); |
183 | runStatus = shutdown; | 189 | runStatus = shutdown; |
184 | QApplication::exit(exitStatus); | 190 | QApplication::exit(exitStatus); |
185 | /* The destructor of PwMInit is called when control | 191 | /* The destructor of PwMInit is called when control |
186 | * leaves main() | 192 | * leaves main() |
187 | */ | 193 | */ |
188 | } | 194 | } |
189 | 195 | ||
190 | void PwMInit::initPosixSignalHandler() | 196 | void PwMInit::initPosixSignalHandler() |
191 | { | 197 | { |
192 | signal(SIGINT, sig_handler); | 198 | signal(SIGINT, sig_handler); |
193 | signal(SIGTERM, sig_handler); | 199 | signal(SIGTERM, sig_handler); |
194 | } | 200 | } |
195 | 201 | ||
196 | void PwMInit::initDCOP() | 202 | void PwMInit::initDCOP() |
197 | { | 203 | { |
198 | #ifndef PWM_EMBEDDED | 204 | #ifndef PWM_EMBEDDED |
199 | _dcopClient = app->dcopClient(); | 205 | _dcopClient = app->dcopClient(); |
200 | _dcopClient->setNotifications(true); | 206 | _dcopClient->setNotifications(true); |
201 | #endif | 207 | #endif |
202 | 208 | ||
203 | } | 209 | } |
204 | 210 | ||
205 | void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload) | 211 | void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload) |
206 | { | 212 | { |
207 | #ifdef CONFIG_KWALLETIF | 213 | #ifdef CONFIG_KWALLETIF |
208 | if (!conf()->confGlobKwalletEmu() || | 214 | if (!conf()->confGlobKwalletEmu() || |
209 | forceDisable) { | 215 | forceDisable) { |
210 | delete_ifnot_null(_kwalletEmu); | 216 | delete_ifnot_null(_kwalletEmu); |
211 | return; | 217 | return; |
212 | } | 218 | } |
213 | try { | 219 | try { |
214 | if (_kwalletEmu && forceReload) | 220 | if (_kwalletEmu && forceReload) |
215 | delete_and_null(_kwalletEmu); | 221 | delete_and_null(_kwalletEmu); |
216 | if (!_kwalletEmu) | 222 | if (!_kwalletEmu) |
217 | _kwalletEmu = new KWalletEmu(this); | 223 | _kwalletEmu = new KWalletEmu(this); |
218 | } catch (PwMException e) { | 224 | } catch (PwMException e) { |
219 | string errMsg("initializing KWallet emulation failed. ID: "); | 225 | string errMsg("initializing KWallet emulation failed. ID: "); |
220 | errMsg += tostr(static_cast<int>(e.getId())); | 226 | errMsg += tostr(static_cast<int>(e.getId())); |
221 | errMsg += " err-message: "; | 227 | errMsg += " err-message: "; |
222 | errMsg += e.getMessage(); | 228 | errMsg += e.getMessage(); |
223 | printWarn(errMsg); | 229 | printWarn(errMsg); |
224 | return; | 230 | return; |
225 | } | 231 | } |
226 | #else // CONFIG_KWALLETIF | 232 | #else // CONFIG_KWALLETIF |
227 | PARAM_UNUSED(forceDisable); | 233 | PARAM_UNUSED(forceDisable); |
228 | PARAM_UNUSED(forceReload); | 234 | PARAM_UNUSED(forceReload); |
229 | #endif // CONFIG_KWALLETIF | 235 | #endif // CONFIG_KWALLETIF |
230 | } | 236 | } |
231 | 237 | ||
232 | void PwMInit::initKeycard() | 238 | void PwMInit::initKeycard() |
233 | { | 239 | { |
234 | #ifdef CONFIG_KEYCARD | 240 | #ifdef CONFIG_KEYCARD |
235 | PWM_ASSERT(!_keycard); | 241 | PWM_ASSERT(!_keycard); |
236 | _keycard = new PwMKeyCard(this); | 242 | _keycard = new PwMKeyCard(this); |
237 | #endif // CONFIG_KEYCARD | 243 | #endif // CONFIG_KEYCARD |
238 | } | 244 | } |
239 | 245 | ||
240 | void PwMInit::initTray() | 246 | void PwMInit::initTray() |
241 | { | 247 | { |
242 | #ifdef PWM_EMBEDDED | 248 | #ifdef PWM_EMBEDDED |
243 | //US ENH : embedded version does not support a tray | 249 | //US ENH : embedded version does not support a tray |
244 | return; | 250 | return; |
245 | #endif | 251 | #endif |
246 | 252 | ||
247 | if (!conf()->confGlobTray()) { | 253 | if (!conf()->confGlobTray()) { |
248 | if (!_tray) | 254 | if (!_tray) |
249 | return; | 255 | return; |
250 | _tray->hide(); | 256 | _tray->hide(); |
251 | delete_and_null(_tray); | 257 | delete_and_null(_tray); |
252 | return; | 258 | return; |
253 | } | 259 | } |
254 | if (_tray) | 260 | if (_tray) |
255 | return; | 261 | return; |
256 | _tray = new PwMTray(this); | 262 | _tray = new PwMTray(this); |
257 | connect(_tray, SIGNAL(quitSelected()), | 263 | connect(_tray, SIGNAL(quitSelected()), |
258 | this, SLOT(removeTrayAndQuit())); | 264 | this, SLOT(removeTrayAndQuit())); |
259 | connect(_tray, SIGNAL(closed(PwMTray *)), | 265 | connect(_tray, SIGNAL(closed(PwMTray *)), |
260 | this, SLOT(trayIconClosed(PwMTray *))); | 266 | this, SLOT(trayIconClosed(PwMTray *))); |
261 | KIconLoader icons; | 267 | KIconLoader icons; |
262 | #ifndef PWM_EMBEDDED | 268 | #ifndef PWM_EMBEDDED |
263 | _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small)); | 269 | _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small)); |
264 | #endif | 270 | #endif |
265 | _tray->show(); | 271 | _tray->show(); |
266 | // connect the signals of all open documents. | 272 | // connect the signals of all open documents. |
267 | const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList(); | 273 | const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList(); |
268 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), | 274 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), |
269 | end = dl->end(); | 275 | end = dl->end(); |
270 | while (i != end) { | 276 | while (i != end) { |
271 | _tray->connectDocToTray((*i).doc); | 277 | _tray->connectDocToTray((*i).doc); |
272 | ++i; | 278 | ++i; |
273 | } | 279 | } |
274 | } | 280 | } |
275 | 281 | ||
276 | void PwMInit::removeTrayAndQuit() | 282 | void PwMInit::removeTrayAndQuit() |
277 | { | 283 | { |
278 | PWM_ASSERT(_tray); | 284 | PWM_ASSERT(_tray); |
279 | // _tray is deleted in ~PwMInit | 285 | // _tray is deleted in ~PwMInit |
280 | shutdownApp(0); | 286 | shutdownApp(0); |
281 | } | 287 | } |
282 | 288 | ||
283 | PwM * PwMInit::createMainWnd(const QString &loadFile, | 289 | PwM * PwMInit::createMainWnd(const QString &loadFile, |
284 | bool loadFileDeepLocked, | 290 | bool loadFileDeepLocked, |
285 | bool virginity, | 291 | bool virginity, |
286 | PwMDoc *doc, | 292 | PwMDoc *doc, |
287 | bool minimized) | 293 | bool minimized) |
288 | { | 294 | { |
295 | qDebug("PwMInit::createMainWnd "); | ||
289 | PwM *newWnd; | 296 | PwM *newWnd; |
290 | if (!doc) | 297 | if (!doc) |
291 | doc = createDoc(); | 298 | doc = createDoc(); |
292 | newWnd = new PwM(this, doc, virginity); | 299 | newWnd = new PwM(this, doc, virginity); |
293 | #ifndef PWM_EMBEDDED | 300 | #ifndef PWM_EMBEDDED |
294 | _mainWndList.push_back(newWnd); | 301 | _mainWndList.push_back(newWnd); |
295 | #else | 302 | #else |
296 | _mainWndList.append(newWnd); | 303 | _mainWndList.append(newWnd); |
297 | #endif | 304 | #endif |
298 | connect(newWnd, SIGNAL(closed(PwM *)), | 305 | connect(newWnd, SIGNAL(closed(PwM *)), |
299 | this, SLOT(mainWndClosed(PwM *))); | 306 | this, SLOT(mainWndClosed(PwM *))); |
300 | connect(newWnd, SIGNAL(gotFocus(PwM *)), | 307 | connect(newWnd, SIGNAL(gotFocus(PwM *)), |
301 | this, SLOT(setCurWidget(PwM *))); | 308 | this, SLOT(setCurWidget(PwM *))); |
302 | connect(newWnd, SIGNAL(lostFocus(PwM *)), | 309 | connect(newWnd, SIGNAL(lostFocus(PwM *)), |
303 | this, SLOT(resetCurWidget())); | 310 | this, SLOT(resetCurWidget())); |
304 | 311 | ||
305 | //US ENH | 312 | //US ENH |
306 | #ifndef PWM_EMBEDDED | 313 | #ifndef PWM_EMBEDDED |
307 | if (minimized) | 314 | if (minimized) |
308 | newWnd->showMinimized(); | 315 | newWnd->showMinimized(); |
309 | else | 316 | else |
310 | newWnd->show(); | 317 | newWnd->show(); |
311 | 318 | ||
312 | #else //PWM_EMBEDDED | 319 | #else //PWM_EMBEDDED |
313 | 320 | ||
314 | #ifndef DESKTOP_VERSION | 321 | #ifndef DESKTOP_VERSION |
315 | app->showMainWidget( newWnd ); | 322 | app->showMainWidget( newWnd ); |
316 | #else //DESKTOP_VERSION | 323 | #else //DESKTOP_VERSION |
317 | app->setMainWidget( newWnd ); | 324 | app->setMainWidget( newWnd ); |
318 | newWnd->resize (640, 480 ); | 325 | newWnd->resize (640, 480 ); |
319 | newWnd->show(); | 326 | newWnd->show(); |
327 | qDebug("show "); | ||
320 | #endif //DESKTOP_VERSION | 328 | #endif //DESKTOP_VERSION |
321 | 329 | ||
322 | #endif //PWM_EMBEDDED | 330 | #endif //PWM_EMBEDDED |
323 | 331 | ||
324 | if (loadFile != QString::null && | 332 | if (loadFile != QString::null && |
325 | loadFile != "") { | 333 | loadFile != "") { |
326 | newWnd->openDoc(loadFile, loadFileDeepLocked); | 334 | newWnd->openDoc(loadFile, loadFileDeepLocked); |
327 | } | 335 | } |
328 | return newWnd; | 336 | return newWnd; |
329 | } | 337 | } |
330 | 338 | ||
331 | PwMDoc * PwMInit::createDoc() | 339 | PwMDoc * PwMInit::createDoc() |
332 | { | 340 | { |
333 | PwMDoc *doc = new PwMDoc(this); | 341 | PwMDoc *doc = new PwMDoc(this); |
334 | #ifdef CONFIG_KEYCARD | 342 | #ifdef CONFIG_KEYCARD |
335 | doc->setPwMKeyCard(keycard()); | 343 | doc->setPwMKeyCard(keycard()); |
336 | #endif | 344 | #endif |
337 | #ifdef CONFIG_KWALLETIF | 345 | #ifdef CONFIG_KWALLETIF |
338 | if (kwalletEmu()) | 346 | if (kwalletEmu()) |
339 | kwalletEmu()->connectDocSignals(doc); | 347 | kwalletEmu()->connectDocSignals(doc); |
340 | #endif | 348 | #endif |
341 | 349 | ||
342 | if (_tray) | 350 | if (_tray) |
343 | _tray->connectDocToTray(doc); | 351 | _tray->connectDocToTray(doc); |
344 | 352 | ||
345 | return doc; | 353 | return doc; |
346 | 354 | ||
347 | } | 355 | } |
348 | 356 | ||
349 | void PwMInit::mainWndClosed(PwM *wnd) | 357 | void PwMInit::mainWndClosed(PwM *wnd) |
350 | { | 358 | { |
351 | bool doMinimizeToTray = false; | 359 | bool doMinimizeToTray = false; |
352 | bool doDeleteDoc = false; | 360 | bool doDeleteDoc = false; |
353 | #ifndef PWM_EMBEDDED | 361 | #ifndef PWM_EMBEDDED |
354 | dcopClient()->suspend(); | 362 | dcopClient()->suspend(); |
355 | dcopClient()->setAcceptCalls(false); | 363 | dcopClient()->setAcceptCalls(false); |
356 | #endif | 364 | #endif |
357 | again: | 365 | again: |
358 | 366 | ||
359 | if (wnd->isForceMinimizeToTray()) { | 367 | if (wnd->isForceMinimizeToTray()) { |
360 | if (unlikely(!_tray)) { | 368 | if (unlikely(!_tray)) { |
361 | /* This should not happen! If we set forceMinimizeToTray , | 369 | /* This should not happen! If we set forceMinimizeToTray , |
362 | * we must be sure that _tray exists. | 370 | * we must be sure that _tray exists. |
363 | */ | 371 | */ |
364 | BUG(); | 372 | BUG(); |
365 | wnd->setForceMinimizeToTray(false); | 373 | wnd->setForceMinimizeToTray(false); |
366 | goto again; | 374 | goto again; |
367 | } | 375 | } |
368 | doMinimizeToTray = true; | 376 | doMinimizeToTray = true; |
369 | } else { | 377 | } else { |
370 | // Ask to minimize to tray. If not, delete doc. | 378 | // Ask to minimize to tray. If not, delete doc. |
371 | if (_tray && | 379 | if (_tray && |
372 | runStatus != shutdown && | 380 | runStatus != shutdown && |
373 | !wnd->isForceQuit() && | 381 | !wnd->isForceQuit() && |
374 | !wnd->curDoc()->isDeleted()) { | 382 | !wnd->curDoc()->isDeleted()) { |
375 | if (conf()->confWndClose()) | 383 | if (conf()->confWndClose()) |
376 | doDeleteDoc = true; | 384 | doDeleteDoc = true; |
377 | else | 385 | else |
378 | doMinimizeToTray = true; | 386 | doMinimizeToTray = true; |
379 | } else { | 387 | } else { |
380 | doDeleteDoc = true; | 388 | doDeleteDoc = true; |
381 | } | 389 | } |
382 | } | 390 | } |
383 | 391 | ||
384 | if (doMinimizeToTray) { | 392 | if (doMinimizeToTray) { |
385 | 393 | ||
386 | PWM_ASSERT(_tray); | 394 | PWM_ASSERT(_tray); |
387 | int mmlock = conf()->confGlobMinimizeLock(); | 395 | int mmlock = conf()->confGlobMinimizeLock(); |
388 | switch (mmlock) { | 396 | switch (mmlock) { |
389 | case 0: // don't lock anything | 397 | case 0: // don't lock anything |
390 | break; | 398 | break; |
391 | case 1: // normal lock | 399 | case 1: // normal lock |
392 | wnd->curDoc()->lockAll(true); | 400 | wnd->curDoc()->lockAll(true); |
393 | break; | 401 | break; |
394 | case 2: // deep-lock | 402 | case 2: // deep-lock |
395 | wnd->curDoc()->deepLock(); | 403 | wnd->curDoc()->deepLock(); |
396 | break; | 404 | break; |
397 | default: | 405 | default: |
398 | WARN(); | 406 | WARN(); |
399 | } | 407 | } |
400 | } else if (doDeleteDoc) { | 408 | } else if (doDeleteDoc) { |
401 | if (!wnd->curDoc()->tryDelete()) { | 409 | if (!wnd->curDoc()->tryDelete()) { |
402 | /* We failed deleting the doc, | 410 | /* We failed deleting the doc, |
403 | * so open a new window with it, again. | 411 | * so open a new window with it, again. |
404 | */ | 412 | */ |
405 | createMainWnd(QString::null, false, | 413 | createMainWnd(QString::null, false, |
406 | false, wnd->curDoc()); | 414 | false, wnd->curDoc()); |
407 | } | 415 | } |
408 | } | 416 | } |
409 | #ifndef PWM_EMBEDDED | 417 | #ifndef PWM_EMBEDDED |
410 | // find the closed window in the "mainWndList" and delete it. | 418 | // find the closed window in the "mainWndList" and delete it. |
411 | QValueList<PwM *>::iterator i = _mainWndList.begin(), | 419 | QValueList<PwM *>::iterator i = _mainWndList.begin(), |
412 | end = _mainWndList.end(); | 420 | end = _mainWndList.end(); |
413 | #else | 421 | #else |
414 | // find the closed window in the "mainWndList" and delete it. | 422 | // find the closed window in the "mainWndList" and delete it. |
415 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), | 423 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), |
416 | end = _mainWndList.end(); | 424 | end = _mainWndList.end(); |
417 | #endif | 425 | #endif |
418 | while (i != end) { | 426 | while (i != end) { |
419 | if (*i == wnd) { | 427 | if (*i == wnd) { |
420 | #ifndef PWM_EMBEDDED | 428 | #ifndef PWM_EMBEDDED |
421 | _mainWndList.erase(i); | 429 | _mainWndList.erase(i); |
422 | #else | 430 | #else |
423 | _mainWndList.remove(i); | 431 | _mainWndList.remove(i); |
424 | #endif | 432 | #endif |
425 | goto out_success; | 433 | goto out_success; |
426 | } | 434 | } |
427 | ++i; | 435 | ++i; |
428 | } | 436 | } |
429 | BUG(); | 437 | BUG(); |
430 | out_success: | 438 | out_success: |
431 | #ifndef PWM_EMBEDDED | 439 | #ifndef PWM_EMBEDDED |
432 | if (!_mainWndList.size()) | 440 | if (!_mainWndList.size()) |
433 | #else | 441 | #else |
434 | if (!_mainWndList.count()) | 442 | if (!_mainWndList.count()) |
435 | #endif | 443 | #endif |
436 | 444 | ||
437 | { | 445 | { |
438 | /* If there's no main window and no tray icon | 446 | /* If there's no main window and no tray icon |
439 | * left, we have no user interface, so we can | 447 | * left, we have no user interface, so we can |
440 | * shut down the application. | 448 | * shut down the application. |
441 | */ | 449 | */ |
442 | if (!_tray) { | 450 | if (!_tray) { |
443 | #ifndef PWM_EMBEDDED | 451 | #ifndef PWM_EMBEDDED |
444 | dcopClient()->setAcceptCalls(true); | 452 | dcopClient()->setAcceptCalls(true); |
445 | dcopClient()->resume(); | 453 | dcopClient()->resume(); |
446 | #endif | 454 | #endif |
447 | shutdownApp(0); | 455 | shutdownApp(0); |
448 | return; | 456 | return; |
449 | } | 457 | } |
450 | /* There is no widget left, so set | 458 | /* There is no widget left, so set |
451 | * _curWidget to 0 | 459 | * _curWidget to 0 |
452 | */ | 460 | */ |
453 | resetCurWidget(); | 461 | resetCurWidget(); |
454 | } | 462 | } |
455 | #ifndef PWM_EMBEDDED | 463 | #ifndef PWM_EMBEDDED |
456 | dcopClient()->setAcceptCalls(true); | 464 | dcopClient()->setAcceptCalls(true); |
457 | dcopClient()->resume(); | 465 | dcopClient()->resume(); |
458 | #endif | 466 | #endif |
459 | } | 467 | } |
460 | 468 | ||
461 | void PwMInit::trayIconClosed(PwMTray *tray) | 469 | void PwMInit::trayIconClosed(PwMTray *tray) |
462 | { | 470 | { |
463 | if (runStatus != running) | 471 | if (runStatus != running) |
464 | return; | 472 | return; |
465 | PARAM_UNUSED(tray); | 473 | PARAM_UNUSED(tray); |
466 | PWM_ASSERT(tray == _tray); | 474 | PWM_ASSERT(tray == _tray); |
467 | /* If there's no main wnd left we have to | 475 | /* If there's no main wnd left we have to |
468 | * shutdown the app (same as in mainWndClosed()) | 476 | * shutdown the app (same as in mainWndClosed()) |
469 | */ | 477 | */ |
470 | #ifndef PWM_EMBEDDED | 478 | #ifndef PWM_EMBEDDED |
471 | if (!_mainWndList.size()) | 479 | if (!_mainWndList.size()) |
472 | shutdownApp(0); | 480 | shutdownApp(0); |
473 | #else | 481 | #else |
474 | if (!_mainWndList.count()) | 482 | if (!_mainWndList.count()) |
475 | shutdownApp(0); | 483 | shutdownApp(0); |
476 | #endif | 484 | #endif |
477 | } | 485 | } |
478 | 486 | ||
479 | void PwMInit::handleCmdLineArgs(bool initial) | 487 | void PwMInit::handleCmdLineArgs(bool initial) |
480 | { | 488 | { |
481 | #ifndef PWM_EMBEDDED | 489 | #ifndef PWM_EMBEDDED |
482 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 490 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
483 | PWM_ASSERT(args); | 491 | PWM_ASSERT(args); |
484 | int i, numArgs = args->count(); | 492 | int i, numArgs = args->count(); |
485 | const char *curArg; | 493 | const char *curArg; |
486 | 494 | ||
487 | // read all cmdline options | 495 | // read all cmdline options |
488 | savedCmd.open_deeplocked = args->isSet("open-deeplocked"); | 496 | savedCmd.open_deeplocked = args->isSet("open-deeplocked"); |
489 | savedCmd.minimized = args->isSet("minimized"); | 497 | savedCmd.minimized = args->isSet("minimized"); |
490 | savedCmd.minToTray = args->isSet("mintray"); | 498 | savedCmd.minToTray = args->isSet("mintray"); |
491 | savedCmd.skipSelfTest = args->isSet("skip-self-test"); | 499 | savedCmd.skipSelfTest = args->isSet("skip-self-test"); |
492 | if (savedCmd.minimized && | 500 | if (savedCmd.minimized && |
493 | savedCmd.minToTray) { | 501 | savedCmd.minToTray) { |
494 | printInfo(i18n("Commandline option \"--minimized\" and " | 502 | printInfo(i18n("Commandline option \"--minimized\" and " |
495 | "\"--mintray\" selected. These are incompatible. " | 503 | "\"--mintray\" selected. These are incompatible. " |
496 | "\"--mintray\" will be selected.").latin1()); | 504 | "\"--mintray\" will be selected.").latin1()); |
497 | } | 505 | } |
498 | /* Iterate through all non-option arguments. | 506 | /* Iterate through all non-option arguments. |
499 | * Every non-option arg is a filename to open. | 507 | * Every non-option arg is a filename to open. |
500 | */ | 508 | */ |
501 | for (i = 0; i < numArgs; ++i) { | 509 | for (i = 0; i < numArgs; ++i) { |
502 | curArg = args->arg(i); | 510 | curArg = args->arg(i); |
503 | PWM_ASSERT(curArg); | 511 | PWM_ASSERT(curArg); |
504 | if (savedCmd.minToTray) { | 512 | if (savedCmd.minToTray) { |
505 | PwMDoc *newDoc = createDoc(); | 513 | PwMDoc *newDoc = createDoc(); |
506 | if (!newDoc->openDocUi(newDoc, | 514 | if (!newDoc->openDocUi(newDoc, |
507 | curArg, | 515 | curArg, |
508 | savedCmd.open_deeplocked)) { | 516 | savedCmd.open_deeplocked)) { |
509 | delete newDoc; | 517 | delete newDoc; |
510 | } | 518 | } |
511 | } else { | 519 | } else { |
512 | PwM *newInstance = createMainWnd(QString::null, | 520 | PwM *newInstance = createMainWnd(QString::null, |
513 | false, | 521 | false, |
514 | true, | 522 | true, |
515 | 0, | 523 | 0, |
516 | savedCmd.minimized); | 524 | savedCmd.minimized); |
517 | PwMDoc *newDoc = newInstance->openDoc(curArg, | 525 | PwMDoc *newDoc = newInstance->openDoc(curArg, |
518 | savedCmd.open_deeplocked); | 526 | savedCmd.open_deeplocked); |
519 | if (!newDoc) { | 527 | if (!newDoc) { |
520 | newInstance->setForceQuit(true); | 528 | newInstance->setForceQuit(true); |
521 | delete_and_null(newInstance); | 529 | delete_and_null(newInstance); |
522 | } | 530 | } |
523 | } | 531 | } |
524 | } | 532 | } |
525 | 533 | ||
526 | if (savedCmd.minToTray) { | 534 | if (savedCmd.minToTray) { |
527 | minimizeAllMainWnd(true); | 535 | minimizeAllMainWnd(true); |
528 | } else if (savedCmd.minimized) { | 536 | } else if (savedCmd.minimized) { |
529 | minimizeAllMainWnd(false); | 537 | minimizeAllMainWnd(false); |
530 | } | 538 | } |
531 | if (!savedCmd.skipSelfTest && initial) { | 539 | if (!savedCmd.skipSelfTest && initial) { |
532 | SelfTest::schedule(); | 540 | SelfTest::schedule(); |
533 | } | 541 | } |
534 | args->clear(); | 542 | args->clear(); |
535 | #endif | 543 | #endif |
536 | } | 544 | } |
537 | 545 | ||
538 | void PwMInit::minimizeAllMainWnd(bool toTray) | 546 | void PwMInit::minimizeAllMainWnd(bool toTray) |
539 | { | 547 | { |
540 | #ifndef PWM_EMBEDDED | 548 | #ifndef PWM_EMBEDDED |
541 | if (!_mainWndList.size()) | 549 | if (!_mainWndList.size()) |
542 | return; | 550 | return; |
543 | #else | 551 | #else |
544 | if (!_mainWndList.count()) | 552 | if (!_mainWndList.count()) |
545 | return; | 553 | return; |
546 | #endif | 554 | #endif |
547 | const QValueList<PwM *> *ml = mainWndList(); | 555 | const QValueList<PwM *> *ml = mainWndList(); |
548 | #ifndef PWM_EMBEDDED | 556 | #ifndef PWM_EMBEDDED |
549 | QValueList<PwM *>::const_iterator it = ml->begin(), | 557 | QValueList<PwM *>::const_iterator it = ml->begin(), |
550 | end = ml->end(); | 558 | end = ml->end(); |
551 | #else | 559 | #else |
552 | QValueList<PwM *>::ConstIterator it = ml->begin(), | 560 | QValueList<PwM *>::ConstIterator it = ml->begin(), |
553 | end = ml->end(); | 561 | end = ml->end(); |
554 | #endif | 562 | #endif |
555 | PwM *wnd; | 563 | PwM *wnd; |
556 | if (toTray && _tray) { | 564 | if (toTray && _tray) { |
557 | /* minimize to tray. | 565 | /* minimize to tray. |
558 | * close all mainWnd. | 566 | * close all mainWnd. |
559 | */ | 567 | */ |
560 | while (it != end) { | 568 | while (it != end) { |
561 | wnd = *it; | 569 | wnd = *it; |
562 | wnd->setForceMinimizeToTray(true); | 570 | wnd->setForceMinimizeToTray(true); |
563 | wnd->close_slot(); | 571 | wnd->close_slot(); |
564 | ++it; | 572 | ++it; |
565 | } | 573 | } |
566 | } else { | 574 | } else { |
567 | // normal minimize | 575 | // normal minimize |
568 | while (it != end) { | 576 | while (it != end) { |
569 | wnd = *it; | 577 | wnd = *it; |
570 | wnd->hide(); | 578 | wnd->hide(); |
571 | wnd->showMinimized(); | 579 | wnd->showMinimized(); |
572 | ++it; | 580 | ++it; |
573 | } | 581 | } |
574 | } | 582 | } |
575 | } | 583 | } |
576 | 584 | ||
577 | #ifdef PWM_EMBEDDED | 585 | #ifdef PWM_EMBEDDED |
578 | 586 | ||
579 | #ifndef DESKTOP_VERSION | 587 | #ifndef DESKTOP_VERSION |
580 | 588 | ||
581 | PwMApplication::PwMApplication(int & argc, char ** argv) | 589 | PwMApplication::PwMApplication(int & argc, char ** argv) |
582 | : QPEApplication( argc, argv ) | 590 | : QPEApplication( argc, argv ) |
583 | , init (0) | 591 | , init (0) |
584 | { | 592 | { |
585 | this->setKeepRunning (); | 593 | this->setKeepRunning (); |
586 | } | 594 | } |
587 | 595 | ||
588 | PwMApplication::~PwMApplication() | 596 | PwMApplication::~PwMApplication() |
589 | { | 597 | { |
590 | delete_ifnot_null(init); | 598 | delete_ifnot_null(init); |
591 | } | 599 | } |
592 | #else //DESKTOP_VERSION | 600 | #else //DESKTOP_VERSION |
593 | 601 | ||
594 | PwMApplication::PwMApplication(int & argc, char ** argv) | 602 | PwMApplication::PwMApplication(int & argc, char ** argv) |
595 | : QApplication( argc, argv ) | 603 | : QApplication( argc, argv ) |
596 | , init (0) | 604 | , init (0) |
597 | { | 605 | { |
598 | setStyle( new QPlatinumStyle ()); | 606 | setStyle( new QPlatinumStyle ()); |
599 | QString hdir = QDir::homeDirPath(); | 607 | QString hdir = QDir::homeDirPath(); |
600 | // there is a bug when creating dirs for WIN 98 | 608 | // there is a bug when creating dirs for WIN 98 |
601 | // it is difficult to fix, because we have no WIN 98 runnung | 609 | // it is difficult to fix, because we have no WIN 98 runnung |
602 | // such that we try it to create the dirs at startup here | 610 | // such that we try it to create the dirs at startup here |
603 | if ( hdir == "C:\\" ) | 611 | if ( hdir == "C:\\" ) |
604 | { | 612 | { |
605 | // win 98 or ME | 613 | // win 98 or ME |
606 | QDir app_dir; | 614 | QDir app_dir; |
607 | if ( !app_dir.exists("C:\\kdepim") ) | 615 | if ( !app_dir.exists("C:\\kdepim") ) |
608 | app_dir.mkdir ("C:\\kdepim"); | 616 | app_dir.mkdir ("C:\\kdepim"); |
609 | if ( !app_dir.exists("C:\\kdepim\\apps") ) | 617 | if ( !app_dir.exists("C:\\kdepim\\apps") ) |
610 | app_dir.mkdir ("C:\\kdepim\\apps"); | 618 | app_dir.mkdir ("C:\\kdepim\\apps"); |
611 | if ( !app_dir.exists("C:\\kdepim\\config") ) | 619 | if ( !app_dir.exists("C:\\kdepim\\config") ) |
612 | app_dir.mkdir ("C:\\kdepim\\config"); | 620 | app_dir.mkdir ("C:\\kdepim\\config"); |
613 | if ( !app_dir.exists("C:\\kdepim\\apps\\pwmanager") ) | 621 | if ( !app_dir.exists("C:\\kdepim\\apps\\pwmanager") ) |
614 | app_dir.mkdir ("C:\\kdepim\\apps\\pwmanager"); | 622 | app_dir.mkdir ("C:\\kdepim\\apps\\pwmanager"); |
615 | } | 623 | } |
616 | } | 624 | } |
617 | 625 | ||
618 | PwMApplication::~PwMApplication() | 626 | PwMApplication::~PwMApplication() |
619 | { | 627 | { |
620 | delete_ifnot_null(init); | 628 | delete_ifnot_null(init); |
621 | } | 629 | } |
622 | 630 | ||
623 | #endif //DESKTOP_VERSION | 631 | #endif //DESKTOP_VERSION |
624 | 632 | ||
625 | #endif //PWM_EMBEDDED | 633 | #endif //PWM_EMBEDDED |
626 | 634 | ||
627 | 635 | ||
628 | 636 | ||
629 | 637 | ||
630 | #ifndef PWM_EMBEDDED | 638 | #ifndef PWM_EMBEDDED |
631 | #include "pwminit.moc" | 639 | #include "pwminit.moc" |
632 | #endif | 640 | #endif |
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp index 2d6498e..ed0f754 100644 --- a/pwmanager/pwmanager/serializer.cpp +++ b/pwmanager/pwmanager/serializer.cpp | |||
@@ -1,780 +1,784 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2004 by Michael Buesch * | 3 | * copyright (C) 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 | /*************************************************************************** | 13 | /*************************************************************************** |
14 | * copyright (C) 2004 by Ulf Schenk | 14 | * copyright (C) 2004 by Ulf Schenk |
15 | * This file is originaly based on version 1.1 of pwmanager | 15 | * This file is originaly based on version 1.1 of pwmanager |
16 | * and was modified to run on embedded devices that run microkde | 16 | * and was modified to run on embedded devices that run microkde |
17 | * | 17 | * |
18 | * $Id$ | 18 | * $Id$ |
19 | **************************************************************************/ | 19 | **************************************************************************/ |
20 | 20 | ||
21 | #include "serializer.h" | 21 | #include "serializer.h" |
22 | #include "pwmexception.h" | 22 | #include "pwmexception.h" |
23 | 23 | ||
24 | #ifdef PWM_EMBEDDED | 24 | #ifdef PWM_EMBEDDED |
25 | #include <kglobal.h> | 25 | #include <kglobal.h> |
26 | #include <klocale.h> | 26 | #include <klocale.h> |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | /* enable/disable serializer debugging (0/1) */ | 29 | /* enable/disable serializer debugging (0/1) */ |
30 | #define SERIALIZER_DEBUG0 | 30 | #define SERIALIZER_DEBUG0 |
31 | /* use the old xml tags for writing (0/1) */ | 31 | /* use the old xml tags for writing (0/1) */ |
32 | #define USE_OLD_TAGS 0 | 32 | #define USE_OLD_TAGS 0 |
33 | /* write a CDATA section (0/1) */ | 33 | /* write a CDATA section (0/1) */ |
34 | #define WRITE_CDATA_SEC 0 | 34 | #define WRITE_CDATA_SEC 0 |
35 | 35 | ||
36 | 36 | ||
37 | #define META_CREATE_DATE"c" | 37 | #define META_CREATE_DATE"c" |
38 | #define META_VALID_DATE "v" | 38 | #define META_VALID_DATE "v" |
39 | #define META_EXPIRE_DATE"e" | 39 | #define META_EXPIRE_DATE"e" |
40 | #define META_UPDATE_DATE"u" | 40 | #define META_UPDATE_DATE"u" |
41 | #define META_UPDATE_INT "i" | 41 | #define META_UPDATE_INT "i" |
42 | //US ENH : uniqueid | 42 | //US ENH : uniqueid |
43 | #define META_UNIQUEID "n" | 43 | #define META_UNIQUEID "n" |
44 | #define SYNC_ROOT "s" | 44 | #define SYNC_ROOT "s" |
45 | #define SYNC_TARGET_PREFIX "t" | 45 | #define SYNC_TARGET_PREFIX "t" |
46 | #define SYNC_TARGET_NAME "n" | 46 | #define SYNC_TARGET_NAME "n" |
47 | 47 | ||
48 | 48 | ||
49 | /* This is compatibility stuff. | 49 | /* This is compatibility stuff. |
50 | * The names of the entries have changed and here are the | 50 | * The names of the entries have changed and here are the |
51 | * new and old ones | 51 | * new and old ones |
52 | */ | 52 | */ |
53 | #define ROOT_MAGIC_OLD "PwM-xml-dat" | 53 | #define ROOT_MAGIC_OLD "PwM-xml-dat" |
54 | #define VER_STR_OLD "ver" | 54 | #define VER_STR_OLD "ver" |
55 | #define COMPAT_VER_OLD "0x02" | 55 | #define COMPAT_VER_OLD "0x02" |
56 | #define CAT_ROOT_OLD "categories" | 56 | #define CAT_ROOT_OLD "categories" |
57 | #define CAT_PREFIX_OLD "cat_" | 57 | #define CAT_PREFIX_OLD "cat_" |
58 | #define CAT_NAME_OLD "name" | 58 | #define CAT_NAME_OLD "name" |
59 | #define ENTRY_PREFIX_OLD"entry_" | 59 | #define ENTRY_PREFIX_OLD"entry_" |
60 | #define ENTRY_DESC_OLD "desc" | 60 | #define ENTRY_DESC_OLD "desc" |
61 | #define ENTRY_NAME_OLD "name" | 61 | #define ENTRY_NAME_OLD "name" |
62 | #define ENTRY_PW_OLD "pw" | 62 | #define ENTRY_PW_OLD "pw" |
63 | #define ENTRY_COMMENT_OLD"comment" | 63 | #define ENTRY_COMMENT_OLD"comment" |
64 | #define ENTRY_URL_OLD "url" | 64 | #define ENTRY_URL_OLD "url" |
65 | #define ENTRY_LAUNCHER_OLD"launcher" | 65 | #define ENTRY_LAUNCHER_OLD"launcher" |
66 | #define ENTRY_LVP_OLD "listViewPos" | 66 | #define ENTRY_LVP_OLD "listViewPos" |
67 | #define ENTRY_BIN_OLD "b" | 67 | #define ENTRY_BIN_OLD "b" |
68 | #define ENTRY_META_OLD "m" | 68 | #define ENTRY_META_OLD "m" |
69 | 69 | ||
70 | #define ROOT_MAGIC_NEW "P" | 70 | #define ROOT_MAGIC_NEW "P" |
71 | #define VER_STR_NEW "v" | 71 | #define VER_STR_NEW "v" |
72 | #define COMPAT_VER_NEW "2" | 72 | #define COMPAT_VER_NEW "2" |
73 | #define CAT_ROOT_NEW "c" | 73 | #define CAT_ROOT_NEW "c" |
74 | #define CAT_PREFIX_NEW "c" | 74 | #define CAT_PREFIX_NEW "c" |
75 | #define CAT_NAME_NEW "n" | 75 | #define CAT_NAME_NEW "n" |
76 | #define ENTRY_PREFIX_NEW"e" | 76 | #define ENTRY_PREFIX_NEW"e" |
77 | #define ENTRY_DESC_NEW "d" | 77 | #define ENTRY_DESC_NEW "d" |
78 | #define ENTRY_NAME_NEW "n" | 78 | #define ENTRY_NAME_NEW "n" |
79 | #define ENTRY_PW_NEW "p" | 79 | #define ENTRY_PW_NEW "p" |
80 | #define ENTRY_COMMENT_NEW"c" | 80 | #define ENTRY_COMMENT_NEW"c" |
81 | #define ENTRY_URL_NEW "u" | 81 | #define ENTRY_URL_NEW "u" |
82 | #define ENTRY_LAUNCHER_NEW"l" | 82 | #define ENTRY_LAUNCHER_NEW"l" |
83 | #define ENTRY_LVP_NEW "v" | 83 | #define ENTRY_LVP_NEW "v" |
84 | #define ENTRY_BIN_NEW ENTRY_BIN_OLD | 84 | #define ENTRY_BIN_NEW ENTRY_BIN_OLD |
85 | #define ENTRY_META_NEW ENTRY_META_OLD | 85 | #define ENTRY_META_NEW ENTRY_META_OLD |
86 | 86 | ||
87 | #if USE_OLD_TAGS != 0 | 87 | #if USE_OLD_TAGS != 0 |
88 | # define ROOT_MAGIC_WR ROOT_MAGIC_OLD | 88 | # define ROOT_MAGIC_WR ROOT_MAGIC_OLD |
89 | # define VER_STR_WR VER_STR_OLD | 89 | # define VER_STR_WR VER_STR_OLD |
90 | # define COMPAT_VER_WR COMPAT_VER_OLD | 90 | # define COMPAT_VER_WR COMPAT_VER_OLD |
91 | # define CAT_ROOT_WR CAT_ROOT_OLD | 91 | # define CAT_ROOT_WR CAT_ROOT_OLD |
92 | # define CAT_PREFIX_WR CAT_PREFIX_OLD | 92 | # define CAT_PREFIX_WR CAT_PREFIX_OLD |
93 | # define CAT_NAME_WR CAT_NAME_OLD | 93 | # define CAT_NAME_WR CAT_NAME_OLD |
94 | # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD | 94 | # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD |
95 | # define ENTRY_DESC_WR ENTRY_DESC_OLD | 95 | # define ENTRY_DESC_WR ENTRY_DESC_OLD |
96 | # define ENTRY_NAME_WR ENTRY_NAME_OLD | 96 | # define ENTRY_NAME_WR ENTRY_NAME_OLD |
97 | # define ENTRY_PW_WR ENTRY_PW_OLD | 97 | # define ENTRY_PW_WR ENTRY_PW_OLD |
98 | # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD | 98 | # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD |
99 | # define ENTRY_URL_WR ENTRY_URL_OLD | 99 | # define ENTRY_URL_WR ENTRY_URL_OLD |
100 | # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD | 100 | # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD |
101 | # define ENTRY_LVP_WR ENTRY_LVP_OLD | 101 | # define ENTRY_LVP_WR ENTRY_LVP_OLD |
102 | # define ENTRY_BIN_WR ENTRY_BIN_OLD | 102 | # define ENTRY_BIN_WR ENTRY_BIN_OLD |
103 | # define ENTRY_META_WR ENTRY_META_OLD | 103 | # define ENTRY_META_WR ENTRY_META_OLD |
104 | #else | 104 | #else |
105 | # define ROOT_MAGIC_WR ROOT_MAGIC_NEW | 105 | # define ROOT_MAGIC_WR ROOT_MAGIC_NEW |
106 | # define VER_STR_WR VER_STR_NEW | 106 | # define VER_STR_WR VER_STR_NEW |
107 | # define COMPAT_VER_WR COMPAT_VER_NEW | 107 | # define COMPAT_VER_WR COMPAT_VER_NEW |
108 | # define CAT_ROOT_WR CAT_ROOT_NEW | 108 | # define CAT_ROOT_WR CAT_ROOT_NEW |
109 | # define CAT_PREFIX_WR CAT_PREFIX_NEW | 109 | # define CAT_PREFIX_WR CAT_PREFIX_NEW |
110 | # define CAT_NAME_WR CAT_NAME_NEW | 110 | # define CAT_NAME_WR CAT_NAME_NEW |
111 | # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW | 111 | # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW |
112 | # define ENTRY_DESC_WR ENTRY_DESC_NEW | 112 | # define ENTRY_DESC_WR ENTRY_DESC_NEW |
113 | # define ENTRY_NAME_WR ENTRY_NAME_NEW | 113 | # define ENTRY_NAME_WR ENTRY_NAME_NEW |
114 | # define ENTRY_PW_WR ENTRY_PW_NEW | 114 | # define ENTRY_PW_WR ENTRY_PW_NEW |
115 | # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW | 115 | # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW |
116 | # define ENTRY_URL_WR ENTRY_URL_NEW | 116 | # define ENTRY_URL_WR ENTRY_URL_NEW |
117 | # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW | 117 | # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW |
118 | # define ENTRY_LVP_WR ENTRY_LVP_NEW | 118 | # define ENTRY_LVP_WR ENTRY_LVP_NEW |
119 | # define ENTRY_BIN_WR ENTRY_BIN_NEW | 119 | # define ENTRY_BIN_WR ENTRY_BIN_NEW |
120 | # define ENTRY_META_WR ENTRY_META_NEW | 120 | # define ENTRY_META_WR ENTRY_META_NEW |
121 | #endif | 121 | #endif |
122 | 122 | ||
123 | 123 | ||
124 | Serializer::Serializer() | 124 | Serializer::Serializer() |
125 | { | 125 | { |
126 | defaultLockStat = true; | 126 | defaultLockStat = true; |
127 | //US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing | 127 | //US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing |
128 | #ifndef PWM_EMBEDDED | 128 | #ifndef PWM_EMBEDDED |
129 | domDoc = new QDomDocument; | 129 | domDoc = new QDomDocument; |
130 | #else | 130 | #else |
131 | domDoc = new QDomDocument("mydoc"); | 131 | domDoc = new QDomDocument("mydoc"); |
132 | #endif | 132 | #endif |
133 | } | 133 | } |
134 | 134 | ||
135 | Serializer::Serializer(const QCString &buffer) | 135 | Serializer::Serializer(const QCString &buffer) |
136 | { | 136 | { |
137 | defaultLockStat = true; | 137 | defaultLockStat = true; |
138 | //US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing | 138 | //US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing |
139 | #ifndef PWM_EMBEDDED | 139 | #ifndef PWM_EMBEDDED |
140 | domDoc = new QDomDocument; | 140 | domDoc = new QDomDocument; |
141 | #else | 141 | #else |
142 | domDoc = new QDomDocument("mydoc"); | 142 | domDoc = new QDomDocument("mydoc"); |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | if (!parseXml(buffer)) { | 145 | if (!parseXml(buffer)) { |
146 | delete domDoc; | 146 | delete domDoc; |
147 | #ifndef PWM_EMBEDDED | 147 | #ifndef PWM_EMBEDDED |
148 | throw PwMException(PwMException::EX_PARSE); | 148 | throw PwMException(PwMException::EX_PARSE); |
149 | #else | 149 | #else |
150 | qDebug("Serializer::Serializer : Parse Exception "); | 150 | qDebug("Serializer::Serializer : Parse Exception "); |
151 | #endif | 151 | #endif |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | Serializer::~Serializer() | 155 | Serializer::~Serializer() |
156 | { | 156 | { |
157 | delete_ifnot_null(domDoc); | 157 | delete_ifnot_null(domDoc); |
158 | } | 158 | } |
159 | 159 | ||
160 | void Serializer::clear() | 160 | void Serializer::clear() |
161 | { | 161 | { |
162 | delete_ifnot_null(domDoc); | 162 | delete_ifnot_null(domDoc); |
163 | domDoc = new QDomDocument; | 163 | domDoc = new QDomDocument; |
164 | } | 164 | } |
165 | 165 | ||
166 | bool Serializer::parseXml(const QCString &buffer) | 166 | bool Serializer::parseXml(const QCString &buffer) |
167 | { | 167 | { |
168 | PWM_ASSERT(domDoc); | 168 | PWM_ASSERT(domDoc); |
169 | #ifndef PWM_EMBEDDED | 169 | #ifndef PWM_EMBEDDED |
170 | if (!domDoc->setContent(buffer, true)) | 170 | if (!domDoc->setContent(buffer, true)) |
171 | return false; | 171 | return false; |
172 | #else | 172 | #else |
173 | #ifdef DESKTOP_VERSION | ||
174 | if (!domDoc->setContent(buffer, true)) | ||
175 | #else | ||
173 | if (!domDoc->setContent(buffer)) | 176 | if (!domDoc->setContent(buffer)) |
177 | #endif | ||
174 | return false; | 178 | return false; |
175 | #endif | 179 | #endif |
176 | if (!checkValid()) | 180 | if (!checkValid()) |
177 | return false; | 181 | return false; |
178 | return true; | 182 | return true; |
179 | } | 183 | } |
180 | 184 | ||
181 | QCString Serializer::getXml() | 185 | QCString Serializer::getXml() |
182 | { | 186 | { |
183 | PWM_ASSERT(domDoc); | 187 | PWM_ASSERT(domDoc); |
184 | 188 | ||
185 | #ifndef PWM_EMBEDDED | 189 | #ifndef PWM_EMBEDDED |
186 | #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 | 190 | #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 |
187 | QCString tmp(domDoc->toCString(8)); | 191 | QCString tmp(domDoc->toCString(8)); |
188 | printDebug("<BEGIN Serializer::getXml() dump>\n"); | 192 | printDebug("<BEGIN Serializer::getXml() dump>\n"); |
189 | cout << tmp << endl; | 193 | cout << tmp << endl; |
190 | printDebug("<END Serializer::getXml() dump>"); | 194 | printDebug("<END Serializer::getXml() dump>"); |
191 | #endif // DEBUG | 195 | #endif // DEBUG |
192 | 196 | ||
193 | QCString ret(domDoc->toCString(0)); | 197 | QCString ret(domDoc->toCString(0)); |
194 | ret.replace('\n', ""); | 198 | ret.replace('\n', ""); |
195 | return ret; | 199 | return ret; |
196 | #else | 200 | #else |
197 | 201 | ||
198 | #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 | 202 | #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 |
199 | QCString tmp(" " + domDoc->toCString()); | 203 | QCString tmp(" " + domDoc->toCString()); |
200 | printDebug("<BEGIN Serializer::getXml() dump>\n"); | 204 | printDebug("<BEGIN Serializer::getXml() dump>\n"); |
201 | qDebug(tmp); | 205 | qDebug(tmp); |
202 | cout << tmp << endl; | 206 | cout << tmp << endl; |
203 | printDebug("<END Serializer::getXml() dump>"); | 207 | printDebug("<END Serializer::getXml() dump>"); |
204 | #endif // DEBUG | 208 | #endif // DEBUG |
205 | 209 | ||
206 | QCString ret(domDoc->toCString()); | 210 | QCString ret(domDoc->toCString()); |
207 | ret.replace(QRegExp("\n"), ""); | 211 | ret.replace(QRegExp("\n"), ""); |
208 | return ret; | 212 | return ret; |
209 | 213 | ||
210 | #endif | 214 | #endif |
211 | } | 215 | } |
212 | 216 | ||
213 | bool Serializer::serialize(PwMItem &dta) | 217 | bool Serializer::serialize(PwMItem &dta) |
214 | { | 218 | { |
215 | PWM_ASSERT(domDoc); | 219 | PWM_ASSERT(domDoc); |
216 | QDomElement root(genNewRoot()); | 220 | QDomElement root(genNewRoot()); |
217 | QDomElement catNode(domDoc->createElement(CAT_ROOT_WR)); | 221 | QDomElement catNode(domDoc->createElement(CAT_ROOT_WR)); |
218 | QDomElement syncNode(domDoc->createElement(SYNC_ROOT)); | 222 | QDomElement syncNode(domDoc->createElement(SYNC_ROOT)); |
219 | if (!addSyncData(&syncNode, dta.syncDta)) | 223 | if (!addSyncData(&syncNode, dta.syncDta)) |
220 | return false; | 224 | return false; |
221 | root.appendChild(syncNode); | 225 | root.appendChild(syncNode); |
222 | if (!addCategories(&catNode, dta.dta)) | 226 | if (!addCategories(&catNode, dta.dta)) |
223 | return false; | 227 | return false; |
224 | root.appendChild(catNode); | 228 | root.appendChild(catNode); |
225 | return true; | 229 | return true; |
226 | } | 230 | } |
227 | 231 | ||
228 | bool Serializer::deSerialize(PwMItem *dta) | 232 | bool Serializer::deSerialize(PwMItem *dta) |
229 | { | 233 | { |
230 | PWM_ASSERT(domDoc); | 234 | PWM_ASSERT(domDoc); |
231 | PWM_ASSERT(dta); | 235 | PWM_ASSERT(dta); |
232 | QDomElement root(domDoc->documentElement()); | 236 | QDomElement root(domDoc->documentElement()); |
233 | QDomNode n; | 237 | QDomNode n; |
234 | 238 | ||
235 | dta->clear(); | 239 | dta->clear(); |
236 | for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { | 240 | for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { |
237 | // find <categories> ... </categories> | 241 | // find <categories> ... </categories> |
238 | // <c> ... </c> | 242 | // <c> ... </c> |
239 | if (n.nodeName() == CAT_ROOT_NEW || | 243 | if (n.nodeName() == CAT_ROOT_NEW || |
240 | n.nodeName() == CAT_ROOT_OLD) { | 244 | n.nodeName() == CAT_ROOT_OLD) { |
241 | if (!readCategories(n, &(dta->dta))) { | 245 | if (!readCategories(n, &(dta->dta))) { |
242 | return false; | 246 | return false; |
243 | } | 247 | } |
244 | continue; | 248 | continue; |
245 | } | 249 | } |
246 | else if (n.nodeName() == SYNC_ROOT) { | 250 | else if (n.nodeName() == SYNC_ROOT) { |
247 | if (!readSyncData(n, &(dta->syncDta))) { | 251 | if (!readSyncData(n, &(dta->syncDta))) { |
248 | return false; | 252 | return false; |
249 | } | 253 | } |
250 | continue; | 254 | continue; |
251 | } | 255 | } |
252 | 256 | ||
253 | /* NOTE: We can stop processing here, as we | 257 | /* NOTE: We can stop processing here, as we |
254 | * don't have more nodes in root, yet. | 258 | * don't have more nodes in root, yet. |
255 | */ | 259 | */ |
256 | return false; | 260 | return false; |
257 | 261 | ||
258 | } | 262 | } |
259 | return true; | 263 | return true; |
260 | } | 264 | } |
261 | 265 | ||
262 | bool Serializer::readCategories(const QDomNode &n, | 266 | bool Serializer::readCategories(const QDomNode &n, |
263 | vector<PwMCategoryItem> *dta) | 267 | vector<PwMCategoryItem> *dta) |
264 | { | 268 | { |
265 | QDomNodeList nl(n.childNodes()); | 269 | QDomNodeList nl(n.childNodes()); |
266 | QDomNode cur; | 270 | QDomNode cur; |
267 | QString name; | 271 | QString name; |
268 | unsigned int numCat = nl.count(), i; | 272 | unsigned int numCat = nl.count(), i; |
269 | PwMCategoryItem curCat; | 273 | PwMCategoryItem curCat; |
270 | vector<PwMDataItem> curEntr; | 274 | vector<PwMDataItem> curEntr; |
271 | 275 | ||
272 | if (!numCat) { | 276 | if (!numCat) { |
273 | printDebug("Serializer::readCategories(): empty"); | 277 | printDebug("Serializer::readCategories(): empty"); |
274 | return false; | 278 | return false; |
275 | } | 279 | } |
276 | for (i = 0; i < numCat; ++i) { | 280 | for (i = 0; i < numCat; ++i) { |
277 | cur = nl.item(i); | 281 | cur = nl.item(i); |
278 | if (cur.nodeName().left(1) == CAT_PREFIX_NEW || | 282 | if (cur.nodeName().left(1) == CAT_PREFIX_NEW || |
279 | cur.nodeName().left(4) == CAT_PREFIX_OLD) { | 283 | cur.nodeName().left(4) == CAT_PREFIX_OLD) { |
280 | name = cur.toElement().attribute(CAT_NAME_NEW); | 284 | name = cur.toElement().attribute(CAT_NAME_NEW); |
281 | if (name == QString::null) | 285 | if (name == QString::null) |
282 | name = cur.toElement().attribute(CAT_NAME_OLD); | 286 | name = cur.toElement().attribute(CAT_NAME_OLD); |
283 | PWM_ASSERT(name != QString::null); | 287 | PWM_ASSERT(name != QString::null); |
284 | PWM_ASSERT(name != ""); | 288 | PWM_ASSERT(name != ""); |
285 | curCat.clear(); | 289 | curCat.clear(); |
286 | curCat.name = name.latin1(); | 290 | curCat.name = name.latin1(); |
287 | if (!readEntries(cur, &curEntr)) { | 291 | if (!readEntries(cur, &curEntr)) { |
288 | dta->clear(); | 292 | dta->clear(); |
289 | return false; | 293 | return false; |
290 | } | 294 | } |
291 | curCat.d = curEntr; | 295 | curCat.d = curEntr; |
292 | dta->push_back(curCat); | 296 | dta->push_back(curCat); |
293 | } else { | 297 | } else { |
294 | printDebug("Serializer::readCategories(): uh? not a category?"); | 298 | printDebug("Serializer::readCategories(): uh? not a category?"); |
295 | } | 299 | } |
296 | } | 300 | } |
297 | return true; | 301 | return true; |
298 | } | 302 | } |
299 | 303 | ||
300 | bool Serializer::readEntries(const QDomNode &n, | 304 | bool Serializer::readEntries(const QDomNode &n, |
301 | vector<PwMDataItem> *dta) | 305 | vector<PwMDataItem> *dta) |
302 | { | 306 | { |
303 | QDomNodeList nl(n.childNodes()); | 307 | QDomNodeList nl(n.childNodes()); |
304 | QDomNode cur; | 308 | QDomNode cur; |
305 | unsigned int numEntr = nl.count(), i; | 309 | unsigned int numEntr = nl.count(), i; |
306 | PwMDataItem curEntr; | 310 | PwMDataItem curEntr; |
307 | //US BUG: to initialize all values of curEntr with meaningfulldata, | 311 | //US BUG: to initialize all values of curEntr with meaningfulldata, |
308 | // we call clear on it. Reason: Information in the file we will read might be incomplete. | 312 | // we call clear on it. Reason: Information in the file we will read might be incomplete. |
309 | // e.g. the metadata is missing. | 313 | // e.g. the metadata is missing. |
310 | curEntr.clear(true); | 314 | curEntr.clear(true); |
311 | 315 | ||
312 | dta->clear(); | 316 | dta->clear(); |
313 | for (i = 0; i < numEntr; ++i) { | 317 | for (i = 0; i < numEntr; ++i) { |
314 | cur = nl.item(i); | 318 | cur = nl.item(i); |
315 | if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW || | 319 | if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW || |
316 | cur.nodeName().left(6) == ENTRY_PREFIX_OLD) { | 320 | cur.nodeName().left(6) == ENTRY_PREFIX_OLD) { |
317 | if (!extractEntry(cur, &curEntr)) { | 321 | if (!extractEntry(cur, &curEntr)) { |
318 | return false; | 322 | return false; |
319 | } | 323 | } |
320 | dta->push_back(curEntr); | 324 | dta->push_back(curEntr); |
321 | } else { | 325 | } else { |
322 | printDebug("Serializer::readEntries(): hm? not an entry?"); | 326 | printDebug("Serializer::readEntries(): hm? not an entry?"); |
323 | } | 327 | } |
324 | } | 328 | } |
325 | return true; | 329 | return true; |
326 | } | 330 | } |
327 | 331 | ||
328 | bool Serializer::extractEntry(const QDomNode &n, | 332 | bool Serializer::extractEntry(const QDomNode &n, |
329 | PwMDataItem *dta) | 333 | PwMDataItem *dta) |
330 | { | 334 | { |
331 | QDomNodeList nl(n.childNodes()); | 335 | QDomNodeList nl(n.childNodes()); |
332 | QDomNode cur, cdata; | 336 | QDomNode cur, cdata; |
333 | unsigned int cnt = nl.count(), i; | 337 | unsigned int cnt = nl.count(), i; |
334 | QString name, text; | 338 | QString name, text; |
335 | 339 | ||
336 | if (!cnt) { | 340 | if (!cnt) { |
337 | printDebug("Serializer::extractEntry(): empty"); | 341 | printDebug("Serializer::extractEntry(): empty"); |
338 | return false; | 342 | return false; |
339 | } | 343 | } |
340 | dta->clear(); | 344 | dta->clear(); |
341 | for (i = 0; i < cnt; ++i) { | 345 | for (i = 0; i < cnt; ++i) { |
342 | cur = nl.item(i); | 346 | cur = nl.item(i); |
343 | name = cur.nodeName(); | 347 | name = cur.nodeName(); |
344 | cdata = cur.firstChild(); | 348 | cdata = cur.firstChild(); |
345 | if (unlikely(cdata.isCDATASection())) { | 349 | if (unlikely(cdata.isCDATASection())) { |
346 | text = cdata.toCDATASection().data(); | 350 | text = cdata.toCDATASection().data(); |
347 | } else if (likely(cur.isElement())) { | 351 | } else if (likely(cur.isElement())) { |
348 | text = cur.toElement().text(); | 352 | text = cur.toElement().text(); |
349 | } else { | 353 | } else { |
350 | printDebug("Serializer::extractEntry(): neither CDATA nor element."); | 354 | printDebug("Serializer::extractEntry(): neither CDATA nor element."); |
351 | return false; | 355 | return false; |
352 | } | 356 | } |
353 | if (text == " ") | 357 | if (text == " ") |
354 | text = ""; // for backward compatibility. | 358 | text = ""; // for backward compatibility. |
355 | if (name == ENTRY_DESC_NEW || | 359 | if (name == ENTRY_DESC_NEW || |
356 | name == ENTRY_DESC_OLD) { | 360 | name == ENTRY_DESC_OLD) { |
357 | dta->desc = unescapeEntryData(text).latin1(); | 361 | dta->desc = unescapeEntryData(text).latin1(); |
358 | } else if (name == ENTRY_NAME_NEW || | 362 | } else if (name == ENTRY_NAME_NEW || |
359 | name == ENTRY_NAME_OLD) { | 363 | name == ENTRY_NAME_OLD) { |
360 | dta->name = unescapeEntryData(text).latin1(); | 364 | dta->name = unescapeEntryData(text).latin1(); |
361 | } else if (name == ENTRY_PW_NEW || | 365 | } else if (name == ENTRY_PW_NEW || |
362 | name == ENTRY_PW_OLD) { | 366 | name == ENTRY_PW_OLD) { |
363 | dta->pw = unescapeEntryData(text).latin1(); | 367 | dta->pw = unescapeEntryData(text).latin1(); |
364 | } else if (name == ENTRY_COMMENT_NEW || | 368 | } else if (name == ENTRY_COMMENT_NEW || |
365 | name == ENTRY_COMMENT_OLD) { | 369 | name == ENTRY_COMMENT_OLD) { |
366 | dta->comment = unescapeEntryData(text).latin1(); | 370 | dta->comment = unescapeEntryData(text).latin1(); |
367 | } else if (name == ENTRY_URL_NEW || | 371 | } else if (name == ENTRY_URL_NEW || |
368 | name == ENTRY_URL_OLD) { | 372 | name == ENTRY_URL_OLD) { |
369 | dta->url = unescapeEntryData(text).latin1(); | 373 | dta->url = unescapeEntryData(text).latin1(); |
370 | } else if (name == ENTRY_LAUNCHER_NEW || | 374 | } else if (name == ENTRY_LAUNCHER_NEW || |
371 | name == ENTRY_LAUNCHER_OLD) { | 375 | name == ENTRY_LAUNCHER_OLD) { |
372 | dta->launcher = unescapeEntryData(text).latin1(); | 376 | dta->launcher = unescapeEntryData(text).latin1(); |
373 | } else if (name == ENTRY_LVP_NEW || | 377 | } else if (name == ENTRY_LVP_NEW || |
374 | name == ENTRY_LVP_OLD) { | 378 | name == ENTRY_LVP_OLD) { |
375 | dta->listViewPos = strtol(text.latin1(), 0, 10); | 379 | dta->listViewPos = strtol(text.latin1(), 0, 10); |
376 | } else if (name == ENTRY_BIN_NEW) { | 380 | } else if (name == ENTRY_BIN_NEW) { |
377 | // ENTRY_BIN_NEW == ENTRY_BIN_OLD | 381 | // ENTRY_BIN_NEW == ENTRY_BIN_OLD |
378 | if (text == "0") { | 382 | if (text == "0") { |
379 | dta->binary = false; | 383 | dta->binary = false; |
380 | } else { | 384 | } else { |
381 | dta->binary = true; | 385 | dta->binary = true; |
382 | } | 386 | } |
383 | } else if (name == ENTRY_META_NEW) { | 387 | } else if (name == ENTRY_META_NEW) { |
384 | // ENTRY_META_NEW == ENTRY_META_OLD | 388 | // ENTRY_META_NEW == ENTRY_META_OLD |
385 | if (!extractMeta(cur, &dta->meta)) | 389 | if (!extractMeta(cur, &dta->meta)) |
386 | return false; | 390 | return false; |
387 | } else { | 391 | } else { |
388 | printDebug(string("Serializer::extractEntry(): invalid: ") | 392 | printDebug(string("Serializer::extractEntry(): invalid: ") |
389 | + name.latin1()); | 393 | + name.latin1()); |
390 | } | 394 | } |
391 | } | 395 | } |
392 | dta->lockStat = defaultLockStat; | 396 | dta->lockStat = defaultLockStat; |
393 | return true; | 397 | return true; |
394 | } | 398 | } |
395 | 399 | ||
396 | bool Serializer::extractMeta(const QDomNode &n, | 400 | bool Serializer::extractMeta(const QDomNode &n, |
397 | PwMMetaData *dta) | 401 | PwMMetaData *dta) |
398 | { | 402 | { |
399 | QDomNode cur(n.firstChild()); | 403 | QDomNode cur(n.firstChild()); |
400 | QString name, val; | 404 | QString name, val; |
401 | while (!cur.isNull()) { | 405 | while (!cur.isNull()) { |
402 | name = cur.nodeName(); | 406 | name = cur.nodeName(); |
403 | val = cur.toElement().text(); | 407 | val = cur.toElement().text(); |
404 | if (val == "") { | 408 | if (val == "") { |
405 | cur = cur.nextSibling(); | 409 | cur = cur.nextSibling(); |
406 | continue; | 410 | continue; |
407 | } | 411 | } |
408 | 412 | ||
409 | //US BUG: The transformation of an empty date into an ISO date and back is different on different systems/compilers. | 413 | //US BUG: The transformation of an empty date into an ISO date and back is different on different systems/compilers. |
410 | //because of that it is possible that here some values are not set, which means they are null. | 414 | //because of that it is possible that here some values are not set, which means they are null. |
411 | //US ENH: at the same moment we need backwardcompatibility. So older versions might have stored invalid dates. | 415 | //US ENH: at the same moment we need backwardcompatibility. So older versions might have stored invalid dates. |
412 | 416 | ||
413 | QDateTime dtval; //dtval should be invalid by definition. | 417 | QDateTime dtval; //dtval should be invalid by definition. |
414 | 418 | ||
415 | if ((name == META_CREATE_DATE) || | 419 | if ((name == META_CREATE_DATE) || |
416 | (name == META_VALID_DATE) || | 420 | (name == META_VALID_DATE) || |
417 | (name == META_EXPIRE_DATE) || | 421 | (name == META_EXPIRE_DATE) || |
418 | (name == META_UPDATE_DATE)) | 422 | (name == META_UPDATE_DATE)) |
419 | { | 423 | { |
420 | //qDebug("Serializer::extractMeta:: val:%s, empty:%i, length:%i",val.utf8(), val.isEmpty(), val.length()); | 424 | //qDebug("Serializer::extractMeta:: val:%s, empty:%i, length:%i",val.utf8(), val.isEmpty(), val.length()); |
421 | 425 | ||
422 | #ifndef PWM_EMBEDDED | 426 | #ifndef PWM_EMBEDDED |
423 | dtval = QDateTime::fromString(val, Qt::ISODate); | 427 | dtval = QDateTime::fromString(val, Qt::ISODate); |
424 | #else | 428 | #else |
425 | bool ok; | 429 | bool ok; |
426 | dtval = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); | 430 | dtval = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); |
427 | 431 | ||
428 | if (ok == false) | 432 | if (ok == false) |
429 | qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!"); | 433 | qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!"); |
430 | #endif | 434 | #endif |
431 | 435 | ||
432 | //if the parsed data is wrong, dtval should be invalid at this time. | 436 | //if the parsed data is wrong, dtval should be invalid at this time. |
433 | 437 | ||
434 | } | 438 | } |
435 | 439 | ||
436 | if (name == META_CREATE_DATE) { | 440 | if (name == META_CREATE_DATE) { |
437 | dta->create = dtval; | 441 | dta->create = dtval; |
438 | } else if (name == META_VALID_DATE) { | 442 | } else if (name == META_VALID_DATE) { |
439 | dta->valid = dtval; | 443 | dta->valid = dtval; |
440 | } else if (name == META_EXPIRE_DATE) { | 444 | } else if (name == META_EXPIRE_DATE) { |
441 | dta->expire = dtval; | 445 | dta->expire = dtval; |
442 | } else if (name == META_UPDATE_DATE) { | 446 | } else if (name == META_UPDATE_DATE) { |
443 | dta->update = dtval; | 447 | dta->update = dtval; |
444 | } else if (name == META_UPDATE_INT) { | 448 | } else if (name == META_UPDATE_INT) { |
445 | dta->updateInt = strtoul(val.latin1(), 0, 10); | 449 | dta->updateInt = strtoul(val.latin1(), 0, 10); |
446 | } else if (name == META_UNIQUEID) { | 450 | } else if (name == META_UNIQUEID) { |
447 | dta->uniqueid = unescapeEntryData(val).latin1(); | 451 | dta->uniqueid = unescapeEntryData(val).latin1(); |
448 | } else { | 452 | } else { |
449 | printDebug(string("extractMeta(): invalid: ") | 453 | printDebug(string("extractMeta(): invalid: ") |
450 | + name.latin1()); | 454 | + name.latin1()); |
451 | } | 455 | } |
452 | 456 | ||
453 | cur = cur.nextSibling(); | 457 | cur = cur.nextSibling(); |
454 | } | 458 | } |
455 | return true; | 459 | return true; |
456 | } | 460 | } |
457 | 461 | ||
458 | bool Serializer::checkValid() | 462 | bool Serializer::checkValid() |
459 | { | 463 | { |
460 | PWM_ASSERT(domDoc); | 464 | PWM_ASSERT(domDoc); |
461 | QDomElement root(domDoc->documentElement()); | 465 | QDomElement root(domDoc->documentElement()); |
462 | if (root.nodeName() != ROOT_MAGIC_NEW && | 466 | if (root.nodeName() != ROOT_MAGIC_NEW && |
463 | root.nodeName() != ROOT_MAGIC_OLD) { | 467 | root.nodeName() != ROOT_MAGIC_OLD) { |
464 | printDebug("Serializer: wrong magic"); | 468 | printDebug("Serializer: wrong magic"); |
465 | return false; | 469 | return false; |
466 | } | 470 | } |
467 | if (root.attribute(VER_STR_NEW) != COMPAT_VER_NEW && | 471 | if (root.attribute(VER_STR_NEW) != COMPAT_VER_NEW && |
468 | root.attribute(VER_STR_OLD) != COMPAT_VER_OLD) { | 472 | root.attribute(VER_STR_OLD) != COMPAT_VER_OLD) { |
469 | printDebug("Serializer: wrong version"); | 473 | printDebug("Serializer: wrong version"); |
470 | return false; | 474 | return false; |
471 | } | 475 | } |
472 | return true; | 476 | return true; |
473 | } | 477 | } |
474 | 478 | ||
475 | QDomElement Serializer::genNewRoot() | 479 | QDomElement Serializer::genNewRoot() |
476 | { | 480 | { |
477 | PWM_ASSERT(domDoc); | 481 | PWM_ASSERT(domDoc); |
478 | QDomElement root(domDoc->createElement(ROOT_MAGIC_WR)); | 482 | QDomElement root(domDoc->createElement(ROOT_MAGIC_WR)); |
479 | root.setAttribute(VER_STR_WR, COMPAT_VER_WR); | 483 | root.setAttribute(VER_STR_WR, COMPAT_VER_WR); |
480 | domDoc->appendChild(root); | 484 | domDoc->appendChild(root); |
481 | return root; | 485 | return root; |
482 | } | 486 | } |
483 | 487 | ||
484 | bool Serializer::addCategories(QDomElement *e, | 488 | bool Serializer::addCategories(QDomElement *e, |
485 | const vector<PwMCategoryItem> &dta) | 489 | const vector<PwMCategoryItem> &dta) |
486 | { | 490 | { |
487 | unsigned int numCat = dta.size(), i; | 491 | unsigned int numCat = dta.size(), i; |
488 | QString curId, curName; | 492 | QString curId, curName; |
489 | QDomElement curCat; | 493 | QDomElement curCat; |
490 | 494 | ||
491 | for (i = 0; i < numCat; ++i) { | 495 | for (i = 0; i < numCat; ++i) { |
492 | curId = CAT_PREFIX_WR; | 496 | curId = CAT_PREFIX_WR; |
493 | curId += tostr(i).c_str(); | 497 | curId += tostr(i).c_str(); |
494 | curName = dta[i].name.c_str(); | 498 | curName = dta[i].name.c_str(); |
495 | curCat = domDoc->createElement(curId); | 499 | curCat = domDoc->createElement(curId); |
496 | curCat.setAttribute(CAT_NAME_WR, curName); | 500 | curCat.setAttribute(CAT_NAME_WR, curName); |
497 | if (!addEntries(&curCat, dta[i].d)) { | 501 | if (!addEntries(&curCat, dta[i].d)) { |
498 | return false; | 502 | return false; |
499 | } | 503 | } |
500 | e->appendChild(curCat); | 504 | e->appendChild(curCat); |
501 | } | 505 | } |
502 | return true; | 506 | return true; |
503 | } | 507 | } |
504 | 508 | ||
505 | bool Serializer::addEntries(QDomElement *e, | 509 | bool Serializer::addEntries(QDomElement *e, |
506 | const vector<PwMDataItem> &dta) | 510 | const vector<PwMDataItem> &dta) |
507 | { | 511 | { |
508 | unsigned int numEntr = dta.size(), i; | 512 | unsigned int numEntr = dta.size(), i; |
509 | QString curId; | 513 | QString curId; |
510 | QDomElement curEntr; | 514 | QDomElement curEntr; |
511 | 515 | ||
512 | for (i = 0; i < numEntr; ++i) { | 516 | for (i = 0; i < numEntr; ++i) { |
513 | curId = ENTRY_PREFIX_WR; | 517 | curId = ENTRY_PREFIX_WR; |
514 | curId += tostr(i).c_str(); | 518 | curId += tostr(i).c_str(); |
515 | curEntr = domDoc->createElement(curId); | 519 | curEntr = domDoc->createElement(curId); |
516 | if (!writeEntry(&curEntr, dta[i])) { | 520 | if (!writeEntry(&curEntr, dta[i])) { |
517 | return false; | 521 | return false; |
518 | } | 522 | } |
519 | e->appendChild(curEntr); | 523 | e->appendChild(curEntr); |
520 | } | 524 | } |
521 | return true; | 525 | return true; |
522 | } | 526 | } |
523 | 527 | ||
524 | bool Serializer::writeEntry(QDomElement *e, | 528 | bool Serializer::writeEntry(QDomElement *e, |
525 | const PwMDataItem &_dta) | 529 | const PwMDataItem &_dta) |
526 | { | 530 | { |
527 | #if WRITE_CDATA_SEC != 0 | 531 | #if WRITE_CDATA_SEC != 0 |
528 | # define new_text(x)domDoc->createCDATASection(x) | 532 | # define new_text(x)domDoc->createCDATASection(x) |
529 | QDomCDATASection curText; | 533 | QDomCDATASection curText; |
530 | #else | 534 | #else |
531 | # define new_text(x)domDoc->createTextNode(x) | 535 | # define new_text(x)domDoc->createTextNode(x) |
532 | QDomText curText; | 536 | QDomText curText; |
533 | #endif | 537 | #endif |
534 | 538 | ||
535 | QDomText plainText; | 539 | QDomText plainText; |
536 | QDomElement tag; | 540 | QDomElement tag; |
537 | 541 | ||
538 | // begin -- This is for compatibility with the old serializer | 542 | // begin -- This is for compatibility with the old serializer |
539 | PwMDataItem dta = _dta; | 543 | PwMDataItem dta = _dta; |
540 | if (!dta.desc.size()) | 544 | if (!dta.desc.size()) |
541 | dta.desc = " "; | 545 | dta.desc = " "; |
542 | if (!dta.name.size()) | 546 | if (!dta.name.size()) |
543 | dta.name = " "; | 547 | dta.name = " "; |
544 | if (!dta.pw.size()) | 548 | if (!dta.pw.size()) |
545 | dta.pw = " "; | 549 | dta.pw = " "; |
546 | if (!dta.comment.size()) | 550 | if (!dta.comment.size()) |
547 | dta.comment = " "; | 551 | dta.comment = " "; |
548 | if (!dta.url.size()) | 552 | if (!dta.url.size()) |
549 | dta.url = " "; | 553 | dta.url = " "; |
550 | if (!dta.launcher.size()) | 554 | if (!dta.launcher.size()) |
551 | dta.launcher = " "; | 555 | dta.launcher = " "; |
552 | // end -- This is for compatibility with the old serializer | 556 | // end -- This is for compatibility with the old serializer |
553 | 557 | ||
554 | tag = domDoc->createElement(ENTRY_DESC_WR); | 558 | tag = domDoc->createElement(ENTRY_DESC_WR); |
555 | curText = new_text(escapeEntryData(dta.desc.c_str())); | 559 | curText = new_text(escapeEntryData(dta.desc.c_str())); |
556 | tag.appendChild(curText); | 560 | tag.appendChild(curText); |
557 | e->appendChild(tag); | 561 | e->appendChild(tag); |
558 | 562 | ||
559 | tag = domDoc->createElement(ENTRY_NAME_WR); | 563 | tag = domDoc->createElement(ENTRY_NAME_WR); |
560 | curText = new_text(escapeEntryData(dta.name.c_str())); | 564 | curText = new_text(escapeEntryData(dta.name.c_str())); |
561 | tag.appendChild(curText); | 565 | tag.appendChild(curText); |
562 | e->appendChild(tag); | 566 | e->appendChild(tag); |
563 | 567 | ||
564 | tag = domDoc->createElement(ENTRY_PW_WR); | 568 | tag = domDoc->createElement(ENTRY_PW_WR); |
565 | curText = new_text(escapeEntryData(dta.pw.c_str())); | 569 | curText = new_text(escapeEntryData(dta.pw.c_str())); |
566 | tag.appendChild(curText); | 570 | tag.appendChild(curText); |
567 | e->appendChild(tag); | 571 | e->appendChild(tag); |
568 | 572 | ||
569 | tag = domDoc->createElement(ENTRY_COMMENT_WR); | 573 | tag = domDoc->createElement(ENTRY_COMMENT_WR); |
570 | curText = new_text(escapeEntryData(dta.comment.c_str())); | 574 | curText = new_text(escapeEntryData(dta.comment.c_str())); |
571 | tag.appendChild(curText); | 575 | tag.appendChild(curText); |
572 | e->appendChild(tag); | 576 | e->appendChild(tag); |
573 | 577 | ||
574 | tag = domDoc->createElement(ENTRY_URL_WR); | 578 | tag = domDoc->createElement(ENTRY_URL_WR); |
575 | curText = new_text(escapeEntryData(dta.url.c_str())); | 579 | curText = new_text(escapeEntryData(dta.url.c_str())); |
576 | tag.appendChild(curText); | 580 | tag.appendChild(curText); |
577 | e->appendChild(tag); | 581 | e->appendChild(tag); |
578 | 582 | ||
579 | tag = domDoc->createElement(ENTRY_LAUNCHER_WR); | 583 | tag = domDoc->createElement(ENTRY_LAUNCHER_WR); |
580 | curText = new_text(escapeEntryData(dta.launcher.c_str())); | 584 | curText = new_text(escapeEntryData(dta.launcher.c_str())); |
581 | tag.appendChild(curText); | 585 | tag.appendChild(curText); |
582 | e->appendChild(tag); | 586 | e->appendChild(tag); |
583 | 587 | ||
584 | tag = domDoc->createElement(ENTRY_LVP_WR); | 588 | tag = domDoc->createElement(ENTRY_LVP_WR); |
585 | plainText = domDoc->createTextNode(tostr(dta.listViewPos).c_str()); | 589 | plainText = domDoc->createTextNode(tostr(dta.listViewPos).c_str()); |
586 | tag.appendChild(plainText); | 590 | tag.appendChild(plainText); |
587 | e->appendChild(tag); | 591 | e->appendChild(tag); |
588 | 592 | ||
589 | tag = domDoc->createElement(ENTRY_BIN_WR); | 593 | tag = domDoc->createElement(ENTRY_BIN_WR); |
590 | if (dta.binary) | 594 | if (dta.binary) |
591 | plainText = domDoc->createTextNode("1"); | 595 | plainText = domDoc->createTextNode("1"); |
592 | else | 596 | else |
593 | plainText = domDoc->createTextNode("0"); | 597 | plainText = domDoc->createTextNode("0"); |
594 | tag.appendChild(plainText); | 598 | tag.appendChild(plainText); |
595 | e->appendChild(tag); | 599 | e->appendChild(tag); |
596 | 600 | ||
597 | tag = domDoc->createElement(ENTRY_META_WR); | 601 | tag = domDoc->createElement(ENTRY_META_WR); |
598 | if (!writeMeta(&tag, dta.meta)) | 602 | if (!writeMeta(&tag, dta.meta)) |
599 | return false; | 603 | return false; |
600 | e->appendChild(tag); | 604 | e->appendChild(tag); |
601 | 605 | ||
602 | #undef new_text | 606 | #undef new_text |
603 | return true; | 607 | return true; |
604 | } | 608 | } |
605 | 609 | ||
606 | bool Serializer::writeMeta(QDomElement *e, | 610 | bool Serializer::writeMeta(QDomElement *e, |
607 | const PwMMetaData &dta) | 611 | const PwMMetaData &dta) |
608 | { | 612 | { |
609 | QDomText text; | 613 | QDomText text; |
610 | QDomElement tag; | 614 | QDomElement tag; |
611 | 615 | ||
612 | //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. | 616 | //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. |
613 | //So do not transform an empty value at all. | 617 | //So do not transform an empty value at all. |
614 | if (dta.create.isValid()) | 618 | if (dta.create.isValid()) |
615 | { | 619 | { |
616 | tag = domDoc->createElement(META_CREATE_DATE); | 620 | tag = domDoc->createElement(META_CREATE_DATE); |
617 | #ifndef PWM_EMBEDDED | 621 | #ifndef PWM_EMBEDDED |
618 | text = domDoc->createTextNode(dta.create.toString(Qt::ISODate)); | 622 | text = domDoc->createTextNode(dta.create.toString(Qt::ISODate)); |
619 | #else | 623 | #else |
620 | text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.create, KLocale::ISODate)); | 624 | text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.create, KLocale::ISODate)); |
621 | #endif | 625 | #endif |
622 | tag.appendChild(text); | 626 | tag.appendChild(text); |
623 | e->appendChild(tag); | 627 | e->appendChild(tag); |
624 | } | 628 | } |
625 | 629 | ||
626 | //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. | 630 | //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. |
627 | //So do not transform an empty value at all. | 631 | //So do not transform an empty value at all. |
628 | if (dta.valid.isValid()) | 632 | if (dta.valid.isValid()) |
629 | { | 633 | { |
630 | tag = domDoc->createElement(META_VALID_DATE); | 634 | tag = domDoc->createElement(META_VALID_DATE); |
631 | #ifndef PWM_EMBEDDED | 635 | #ifndef PWM_EMBEDDED |
632 | text = domDoc->createTextNode(dta.valid.toString(Qt::ISODate)); | 636 | text = domDoc->createTextNode(dta.valid.toString(Qt::ISODate)); |
633 | #else | 637 | #else |
634 | text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.valid, KLocale::ISODate)); | 638 | text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.valid, KLocale::ISODate)); |
635 | #endif | 639 | #endif |
636 | tag.appendChild(text); | 640 | tag.appendChild(text); |
637 | e->appendChild(tag); | 641 | e->appendChild(tag); |
638 | } | 642 | } |
639 | 643 | ||
640 | //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. | 644 | //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. |
641 | //So do not transform an empty value at all. | 645 | //So do not transform an empty value at all. |
642 | if (dta.expire.isValid()) | 646 | if (dta.expire.isValid()) |
643 | { | 647 | { |
644 | tag = domDoc->createElement(META_EXPIRE_DATE); | 648 | tag = domDoc->createElement(META_EXPIRE_DATE); |
645 | #ifndef PWM_EMBEDDED | 649 | #ifndef PWM_EMBEDDED |
646 | text = domDoc->createTextNode(dta.expire.toString(Qt::ISODate)); | 650 | text = domDoc->createTextNode(dta.expire.toString(Qt::ISODate)); |
647 | #else | 651 | #else |
648 | text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.expire, KLocale::ISODate)); | 652 | text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.expire, KLocale::ISODate)); |
649 | #endif | 653 | #endif |
650 | tag.appendChild(text); | 654 | tag.appendChild(text); |
651 | e->appendChild(tag); | 655 | e->appendChild(tag); |
652 | } | 656 | } |
653 | 657 | ||
654 | //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. | 658 | //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. |
655 | //So do not transform an empty value at all. | 659 | //So do not transform an empty value at all. |
656 | if (dta.update.isValid()) | 660 | if (dta.update.isValid()) |
657 | { | 661 | { |
658 | tag = domDoc->createElement(META_UPDATE_DATE); | 662 | tag = domDoc->createElement(META_UPDATE_DATE); |
659 | #ifndef PWM_EMBEDDED | 663 | #ifndef PWM_EMBEDDED |
660 | text = domDoc->createTextNode(dta.update.toString(Qt::ISODate)); | 664 | text = domDoc->createTextNode(dta.update.toString(Qt::ISODate)); |
661 | #else | 665 | #else |
662 | text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.update, KLocale::ISODate)); | 666 | text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.update, KLocale::ISODate)); |
663 | #endif | 667 | #endif |
664 | tag.appendChild(text); | 668 | tag.appendChild(text); |
665 | e->appendChild(tag); | 669 | e->appendChild(tag); |
666 | } | 670 | } |
667 | 671 | ||
668 | tag = domDoc->createElement(META_UPDATE_INT); | 672 | tag = domDoc->createElement(META_UPDATE_INT); |
669 | text = domDoc->createTextNode(tostr(dta.updateInt).c_str()); | 673 | text = domDoc->createTextNode(tostr(dta.updateInt).c_str()); |
670 | tag.appendChild(text); | 674 | tag.appendChild(text); |
671 | e->appendChild(tag); | 675 | e->appendChild(tag); |
672 | 676 | ||
673 | tag = domDoc->createElement(META_UNIQUEID); | 677 | tag = domDoc->createElement(META_UNIQUEID); |
674 | text = domDoc->createTextNode(escapeEntryData(dta.uniqueid.c_str())); | 678 | text = domDoc->createTextNode(escapeEntryData(dta.uniqueid.c_str())); |
675 | tag.appendChild(text); | 679 | tag.appendChild(text); |
676 | e->appendChild(tag); | 680 | e->appendChild(tag); |
677 | 681 | ||
678 | #undef new_text | 682 | #undef new_text |
679 | return true; | 683 | return true; |
680 | } | 684 | } |
681 | 685 | ||
682 | QString Serializer::escapeEntryData(QString dta) | 686 | QString Serializer::escapeEntryData(QString dta) |
683 | { | 687 | { |
684 | #ifndef PWM_EMBEDDED | 688 | #ifndef PWM_EMBEDDED |
685 | dta.replace('\n', "$>--endl--<$"); | 689 | dta.replace('\n', "$>--endl--<$"); |
686 | dta.replace("]]>", "||>"); | 690 | dta.replace("]]>", "||>"); |
687 | #else | 691 | #else |
688 | dta.replace(QRegExp("\n"), "$>--endl--<$"); | 692 | dta.replace(QRegExp("\n"), "$>--endl--<$"); |
689 | dta.replace(QRegExp("]]>"), "||>"); | 693 | dta.replace(QRegExp("]]>"), "||>"); |
690 | #endif | 694 | #endif |
691 | return dta; | 695 | return dta; |
692 | } | 696 | } |
693 | 697 | ||
694 | QString Serializer::unescapeEntryData(QString dta) | 698 | QString Serializer::unescapeEntryData(QString dta) |
695 | { | 699 | { |
696 | #ifndef PWM_EMBEDDED | 700 | #ifndef PWM_EMBEDDED |
697 | dta.replace("$>--endl--<$", "\n"); | 701 | dta.replace("$>--endl--<$", "\n"); |
698 | dta.replace("||>", "]]>"); | 702 | dta.replace("||>", "]]>"); |
699 | #else | 703 | #else |
700 | dta.replace(QRegExp("\\$>--endl--<\\$"), "\n"); | 704 | dta.replace(QRegExp("\\$>--endl--<\\$"), "\n"); |
701 | dta.replace(QRegExp("||>"), "]]>"); | 705 | dta.replace(QRegExp("||>"), "]]>"); |
702 | #endif | 706 | #endif |
703 | return dta; | 707 | return dta; |
704 | } | 708 | } |
705 | 709 | ||
706 | 710 | ||
707 | //US ENH: the following methods are getting used to write/read sync entries | 711 | //US ENH: the following methods are getting used to write/read sync entries |
708 | /** read the syncentries in the node "n" */ | 712 | /** read the syncentries in the node "n" */ |
709 | bool Serializer::readSyncData(const QDomNode &n, vector<PwMSyncItem> *dta) | 713 | bool Serializer::readSyncData(const QDomNode &n, vector<PwMSyncItem> *dta) |
710 | { | 714 | { |
711 | QDomNodeList nl(n.childNodes()); | 715 | QDomNodeList nl(n.childNodes()); |
712 | QDomNode cur; | 716 | QDomNode cur; |
713 | 717 | ||
714 | QString devicename, val; | 718 | QString devicename, val; |
715 | unsigned int numSync = nl.count(), i; | 719 | unsigned int numSync = nl.count(), i; |
716 | PwMSyncItem curSync; | 720 | PwMSyncItem curSync; |
717 | bool ok = true; | 721 | bool ok = true; |
718 | 722 | ||
719 | if (!numSync) { | 723 | if (!numSync) { |
720 | //no sync entries is a possible result | 724 | //no sync entries is a possible result |
721 | printDebug("Serializer::readSyncData(): empty"); | 725 | printDebug("Serializer::readSyncData(): empty"); |
722 | return true; | 726 | return true; |
723 | } | 727 | } |
724 | for (i = 0; i < numSync; ++i) { | 728 | for (i = 0; i < numSync; ++i) { |
725 | cur = nl.item(i); | 729 | cur = nl.item(i); |
726 | if (cur.nodeName().left(1) == SYNC_TARGET_PREFIX) { | 730 | if (cur.nodeName().left(1) == SYNC_TARGET_PREFIX) { |
727 | devicename = cur.toElement().attribute(SYNC_TARGET_NAME); | 731 | devicename = cur.toElement().attribute(SYNC_TARGET_NAME); |
728 | val = cur.toElement().text(); | 732 | val = cur.toElement().text(); |
729 | 733 | ||
730 | if ((val == "") || (devicename == QString::null)) { | 734 | if ((val == "") || (devicename == QString::null)) { |
731 | printDebug("Serializer::readSyncData(): empty synctarget name or syncdate"); | 735 | printDebug("Serializer::readSyncData(): empty synctarget name or syncdate"); |
732 | continue; | 736 | continue; |
733 | } | 737 | } |
734 | 738 | ||
735 | curSync.syncName = devicename; | 739 | curSync.syncName = devicename.latin1(); |
736 | #ifndef PWM_EMBEDDED | 740 | #ifndef PWM_EMBEDDED |
737 | curSync.lastSyncDate = QDateTime::fromString(val, Qt::ISODate); | 741 | curSync.lastSyncDate = QDateTime::fromString(val, Qt::ISODate); |
738 | #else | 742 | #else |
739 | curSync.lastSyncDate = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); | 743 | curSync.lastSyncDate = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); |
740 | if (ok == false) | 744 | if (ok == false) |
741 | qDebug("Serializer::readSyncData(): could not parse syncdate:%s",val.latin1()); | 745 | qDebug("Serializer::readSyncData(): could not parse syncdate:%s",val.latin1()); |
742 | 746 | ||
743 | #endif | 747 | #endif |
744 | dta->push_back(curSync); | 748 | dta->push_back(curSync); |
745 | } | 749 | } |
746 | } | 750 | } |
747 | return true; | 751 | return true; |
748 | 752 | ||
749 | } | 753 | } |
750 | 754 | ||
751 | 755 | ||
752 | 756 | ||
753 | bool Serializer::addSyncData(QDomElement *e, | 757 | bool Serializer::addSyncData(QDomElement *e, |
754 | const vector<PwMSyncItem> &dta) | 758 | const vector<PwMSyncItem> &dta) |
755 | { | 759 | { |
756 | unsigned int numSync = dta.size(), i; | 760 | unsigned int numSync = dta.size(), i; |
757 | QString curId, curDeviceName; | 761 | QString curId, curDeviceName; |
758 | QDomElement curSync; | 762 | QDomElement curSync; |
759 | QDomText text; | 763 | QDomText text; |
760 | 764 | ||
761 | for (i = 0; i < numSync; ++i) { | 765 | for (i = 0; i < numSync; ++i) { |
762 | curId = SYNC_TARGET_PREFIX; | 766 | curId = SYNC_TARGET_PREFIX; |
763 | curId += tostr(i).c_str(); | 767 | curId += tostr(i).c_str(); |
764 | curDeviceName = dta[i].syncName.c_str(); | 768 | curDeviceName = dta[i].syncName.c_str(); |
765 | curSync = domDoc->createElement(curId); | 769 | curSync = domDoc->createElement(curId); |
766 | curSync.setAttribute(SYNC_TARGET_NAME, curDeviceName); | 770 | curSync.setAttribute(SYNC_TARGET_NAME, curDeviceName); |
767 | 771 | ||
768 | #ifndef PWM_EMBEDDED | 772 | #ifndef PWM_EMBEDDED |
769 | text = domDoc->createTextNode(dta[i].lastSyncDate.toString(Qt::ISODate)); | 773 | text = domDoc->createTextNode(dta[i].lastSyncDate.toString(Qt::ISODate)); |
770 | #else | 774 | #else |
771 | text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta[i].lastSyncDate, KLocale::ISODate)); | 775 | text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta[i].lastSyncDate, KLocale::ISODate)); |
772 | #endif | 776 | #endif |
773 | curSync.appendChild(text); | 777 | curSync.appendChild(text); |
774 | 778 | ||
775 | e->appendChild(curSync); | 779 | e->appendChild(curSync); |
776 | 780 | ||
777 | } | 781 | } |
778 | return true; | 782 | return true; |
779 | } | 783 | } |
780 | 784 | ||