summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile613
-rw-r--r--microkde/kdeui/kmainwindow.cpp1
-rw-r--r--microkde/kdeui/kmainwindow.h5
-rw-r--r--pwmanager/pwmanager/getmasterpwwnd_emb.cpp2
-rw-r--r--pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp4
-rw-r--r--pwmanager/pwmanager/libgcryptif.cpp5
-rw-r--r--pwmanager/pwmanager/main.cpp1
-rw-r--r--pwmanager/pwmanager/pwm.cpp10
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp1
-rw-r--r--pwmanager/pwmanager/pwmdocui.cpp15
-rw-r--r--pwmanager/pwmanager/pwminit.cpp17
11 files changed, 296 insertions, 378 deletions
diff --git a/Makefile b/Makefile
index da5feba..19e1685 100644
--- a/Makefile
+++ b/Makefile
@@ -1,362 +1,253 @@
1export KDEPIMDIR = $(shell pwd) 1#############################################################################
2 2# Makefile for building: kdepim-desktop
3export 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: Mon Oct 25 11:25:22 2004
4 4# Project: kdepim-desktop.pro
5ifeq ($(PLATFORM) , zaurus) 5# Template: subdirs
6 BUILD_NO_LDAP_PLUGIN=1 6# Command: $(QMAKE) -o Makefile kdepim-desktop.pro
7endif 7#############################################################################
8 8
9ifneq ($(PLATFORM) , zaurus) 9 MAKEFILE =Makefile
10 BUILD_NO_SHARP_PLUGIN=1 10 QMAKE =qmake
11endif 11DEL_FILE = rm -f
12 12CHK_DIR_EXISTS= test -d
13SUBDIRS_MICROKDE = \ 13MKDIR = mkdir -p
14 libical/src/libical \ 14 SUBTARGETS = \
15 libical/src/libicalss \ 15 sub-gammu-emb-common \
16 qtcompat \ 16 sub-gammu-emb-gammu \
17 microkde \ 17 sub-libical \
18 libkcal \ 18 sub-libkcal \
19 libkdepim \ 19 sub-microkde \
20 kabc \ 20 sub-libkdepim \
21 kabc/formats/binary \ 21 sub-kabc \
22 kabc/plugins/file \ 22 sub-korganizer \
23 kabc/plugins/dir \ 23 sub-kaddressbook \
24 korganizer \ 24 sub-kabc-plugins-file \
25 kalarmd \ 25 sub-kabc-plugins-dir \
26 kaddressbook 26 sub-kabc-plugins-file \
27 27 sub-kabc-plugins-qtopia \
28SUBDIRS_QTOPIA_PLUGIN = \ 28 sub-pwmanager-libcrypt-cipher \
29 kabc/plugins/qtopia 29 sub-pwmanager-libcrypt-error \
30 30 sub-pwmanager-libcrypt-mpi \
31SUBDIRS_OPIE_PLUGIN = \ 31 sub-pwmanager-libcrypt-zlib \
32 kabc/plugins/opie 32 sub-pwmanager-pwmanager
33 33
34SUBDIRS_SHARP_PLUGIN = \ 34first: all
35 kabc/plugins/sharpdtm 35
36 36all: Makefile $(SUBTARGETS)
37SUBDIRS_LDAP_PLUGIN = \ 37
38 kabc/plugins/ldap 38gammu/emb/common/$(MAKEFILE):
39 39 @$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common"
40SUBDIRS_MICROMAIL = \ 40 cd gammu/emb/common && $(QMAKE) common.pro -o $(MAKEFILE)
41 kmicromail/libetpan \ 41sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE
42 kmicromail/libmailwrapper \ 42 cd gammu/emb/common && $(MAKE) -f $(MAKEFILE)
43 kmicromail 43
44 44gammu/emb/gammu/$(MAKEFILE):
45SUBDIRS_GAMMU = \ 45 @$(CHK_DIR_EXISTS) "gammu/emb/gammu" || $(MKDIR) "gammu/emb/gammu"
46 gammu/emb/common \ 46 cd gammu/emb/gammu && $(QMAKE) gammu.pro -o $(MAKEFILE)
47 gammu/emb/gammu 47sub-gammu-emb-gammu: gammu/emb/gammu/$(MAKEFILE) FORCE
48 48 cd gammu/emb/gammu && $(MAKE) -f $(MAKEFILE)
49SUBDIRS_PWMANAGER = \ 49
50 pwmanager/libcrypt/mpi \ 50libical/$(MAKEFILE):
51 pwmanager/libcrypt/error \ 51 @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical"
52 pwmanager/libcrypt/cipher \ 52 cd libical && $(QMAKE) libical.pro -o $(MAKEFILE)
53 pwmanager/libcrypt/zlib \ 53sub-libical: libical/$(MAKEFILE) FORCE
54 pwmanager/pwmanager 54 cd libical && $(MAKE) -f $(MAKEFILE)
55 55
56SUBDIRS = \ 56libkcal/$(MAKEFILE):
57 $(SUBDIRS_MICROKDE) \ 57 @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal"
58 $(SUBDIRS_QTOPIA_PLUGIN) \ 58 cd libkcal && $(QMAKE) libkcal.pro -o $(MAKEFILE)
59 $(SUBDIRS_OPIE_PLUGIN) \ 59sub-libkcal: libkcal/$(MAKEFILE) FORCE
60 $(SUBDIRS_SHARP_PLUGIN) \ 60 cd libkcal && $(MAKE) -f $(MAKEFILE)
61 $(SUBDIRS_LDAP_PLUGIN) \ 61
62 $(SUBDIRS_MICROMAIL) \ 62microkde/$(MAKEFILE):
63 $(SUBDIRS_GAMMU) \ 63 @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde"
64 $(SUBDIRS_PWMANAGER) 64 cd microkde && $(QMAKE) microkde.pro -o $(MAKEFILE)
65 65sub-microkde: microkde/$(MAKEFILE) FORCE
66 66 cd microkde && $(MAKE) -f $(MAKEFILE)
67all: build_microkde \ 67
68 build_qtopia_plugin \ 68libkdepim/$(MAKEFILE):
69 build_opie_plugin \ 69 @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim"
70 build_sharp_plugin \ 70 cd libkdepim && $(QMAKE) libkdepim.pro -o $(MAKEFILE)
71 build_ldap_plugin \ 71sub-libkdepim: libkdepim/$(MAKEFILE) FORCE
72 build_micromail \ 72 cd libkdepim && $(MAKE) -f $(MAKEFILE)
73 build_gammu \ 73
74 build_pwmanager 74kabc/$(MAKEFILE):
75 75 @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc"
76 76 cd kabc && $(QMAKE) kabc.pro -o $(MAKEFILE)
77build_microkde: variable_test tmake 77sub-kabc: kabc/$(MAKEFILE) FORCE
78 for i in $(SUBDIRS_MICROKDE); do pushd $$i; \ 78 cd kabc && $(MAKE) -f $(MAKEFILE)
79 make -f Makefile$(PLATFORM) || exit 1; popd; \ 79
80 done 80korganizer/$(MAKEFILE):
81 81 @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer"
82build_qtopia_plugin: build_microkde 82 cd korganizer && $(QMAKE) korganizer.pro -o $(MAKEFILE)
83 ifdef BUILD_NO_QTOPIA_PLUGIN 83sub-korganizer: korganizer/$(MAKEFILE) FORCE
84 @echo == qtopia plugin not build. 84 cd korganizer && $(MAKE) -f $(MAKEFILE)
85 else 85
86 for i in $(SUBDIRS_QTOPIA_PLUGIN); do pushd $$i; \ 86kaddressbook/$(MAKEFILE):
87 make -f Makefile$(PLATFORM) || exit 1; popd; \ 87 @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook"
88 done 88 cd kaddressbook && $(QMAKE) kaddressbook.pro -o $(MAKEFILE)
89 endif 89sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE
90 90 cd kaddressbook && $(MAKE) -f $(MAKEFILE)
91build_opie_plugin: build_microkde 91
92 ifdef BUILD_NO_OPIE_PLUGIN 92kabc/plugins/file/$(MAKEFILE):
93 @echo == opie plugin not build. 93 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file"
94 else 94 cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE)
95 for i in $(SUBDIRS_OPIE_PLUGIN); do pushd $$i; \ 95sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE
96 make -f Makefile$(PLATFORM) || exit 1; popd; \ 96 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE)
97 done 97
98 endif 98kabc/plugins/dir/$(MAKEFILE):
99 99 @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir"
100build_sharp_plugin: build_microkde 100 cd kabc/plugins/dir && $(QMAKE) dir.pro -o $(MAKEFILE)
101 ifdef BUILD_NO_SHARP_PLUGIN 101sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE
102 @echo == ldap plugin not build. 102 cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE)
103 else 103
104 for i in $(SUBDIRS_SHARP_PLUGIN); do pushd $$i; \ 104kabc/plugins/file/$(MAKEFILE):
105 make -f Makefile$(PLATFORM) || exit 1; popd; \ 105 @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file"
106 done 106 cd kabc/plugins/file && $(QMAKE) file.pro -o $(MAKEFILE)
107 endif 107sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE
108 108 cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE)
109build_ldap_plugin: build_microkde 109
110 ifdef BUILD_NO_LDAP_PLUGIN 110kabc/plugins/qtopia/$(MAKEFILE):
111 @echo == ldap plugin not build. 111 @$(CHK_DIR_EXISTS) "kabc/plugins/qtopia" || $(MKDIR) "kabc/plugins/qtopia"
112 else 112 cd kabc/plugins/qtopia && $(QMAKE) qtopia.pro -o $(MAKEFILE)
113 for i in $(SUBDIRS_LDAP_PLUGIN); do pushd $$i; \ 113sub-kabc-plugins-qtopia: kabc/plugins/qtopia/$(MAKEFILE) FORCE
114 make -f Makefile$(PLATFORM) || exit 1; popd; \ 114 cd kabc/plugins/qtopia && $(MAKE) -f $(MAKEFILE)
115 done 115
116 endif 116pwmanager/libcrypt/cipher/$(MAKEFILE):
117 117 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/cipher" || $(MKDIR) "pwmanager/libcrypt/cipher"
118 118 cd pwmanager/libcrypt/cipher && $(QMAKE) cipher.pro -o $(MAKEFILE)
119build_micromail: build_microkde 119sub-pwmanager-libcrypt-cipher: pwmanager/libcrypt/cipher/$(MAKEFILE) FORCE
120 ifdef BUILD_NO_MICROMAIL 120 cd pwmanager/libcrypt/cipher && $(MAKE) -f $(MAKEFILE)
121 @echo == kmicromail not build. 121
122 else 122pwmanager/libcrypt/error/$(MAKEFILE):
123 for i in $(SUBDIRS_MICROMAIL); do pushd $$i; \ 123 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/error" || $(MKDIR) "pwmanager/libcrypt/error"
124 make -f Makefile$(PLATFORM) || exit 1; popd; \ 124 cd pwmanager/libcrypt/error && $(QMAKE) error.pro -o $(MAKEFILE)
125 done 125sub-pwmanager-libcrypt-error: pwmanager/libcrypt/error/$(MAKEFILE) FORCE
126 endif 126 cd pwmanager/libcrypt/error && $(MAKE) -f $(MAKEFILE)
127 127
128build_gammu: variable_test tmake 128pwmanager/libcrypt/mpi/$(MAKEFILE):
129 ifdef BUILD_NO_GAMMU 129 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/mpi" || $(MKDIR) "pwmanager/libcrypt/mpi"
130 @echo == gammu not build. 130 cd pwmanager/libcrypt/mpi && $(QMAKE) mpi.pro -o $(MAKEFILE)
131 else 131sub-pwmanager-libcrypt-mpi: pwmanager/libcrypt/mpi/$(MAKEFILE) FORCE
132 for i in $(SUBDIRS_GAMMU); do pushd $$i; \ 132 cd pwmanager/libcrypt/mpi && $(MAKE) -f $(MAKEFILE)
133 make -f Makefile$(PLATFORM) || exit 1; popd; \ 133
134 done 134pwmanager/libcrypt/zlib/$(MAKEFILE):
135 endif 135 @$(CHK_DIR_EXISTS) "pwmanager/libcrypt/zlib" || $(MKDIR) "pwmanager/libcrypt/zlib"
136 136 cd pwmanager/libcrypt/zlib && $(QMAKE) zlib.pro -o $(MAKEFILE)
137build_pwmanager: build_microkde 137sub-pwmanager-libcrypt-zlib: pwmanager/libcrypt/zlib/$(MAKEFILE) FORCE
138 ifdef BUILD_NO_PWMANAGER 138 cd pwmanager/libcrypt/zlib && $(MAKE) -f $(MAKEFILE)
139 @echo == pwmanager not build. 139
140 else 140pwmanager/pwmanager/$(MAKEFILE):
141 for i in $(SUBDIRS_PWMANAGER); do pushd $$i; \ 141 @$(CHK_DIR_EXISTS) "pwmanager/pwmanager" || $(MKDIR) "pwmanager/pwmanager"
142 make -f Makefile$(PLATFORM) || exit 1; popd; \ 142 cd pwmanager/pwmanager && $(QMAKE) pwmanager.pro -o $(MAKEFILE)
143 done 143sub-pwmanager-pwmanager: pwmanager/pwmanager/$(MAKEFILE) FORCE
144 endif 144 cd pwmanager/pwmanager && $(MAKE) -f $(MAKEFILE)
145 145
146 146Makefile: kdepim-desktop.pro /usr/lib/qt3/mkspecs/default/qmake.conf
147variable_info: 147 $(QMAKE) -o Makefile kdepim-desktop.pro
148 @echo -------------------------------------- 148qmake: qmake_all
149 @echo KDEPIM buildsystem, variableinfo... 149 @$(QMAKE) -o Makefile kdepim-desktop.pro
150 @echo KDEPIMDIR=$(KDEPIMDIR) 150
151 @echo QTDIR=$(QTDIR) 151all: $(SUBTARGETS)
152 @echo QPEDIR=$(QPEDIR) 152qmake_all: gammu/emb/common/$(MAKEFILE) gammu/emb/gammu/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/qtopia/$(MAKEFILE) pwmanager/libcrypt/cipher/$(MAKEFILE) pwmanager/libcrypt/error/$(MAKEFILE) pwmanager/libcrypt/mpi/$(MAKEFILE) pwmanager/libcrypt/zlib/$(MAKEFILE) pwmanager/pwmanager/$(MAKEFILE)
153 @echo OPIEDIR=$(OPIEDIR) 153 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
154 @echo PLATFORM=$(PLATFORM) 154 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
155 @echo RELEASE_DEBUG=$(RELEASE_DEBUG) 155 ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
156 @echo BUILD_NO_MICROMAIL=$(BUILD_NO_MICROMAIL) 156 ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
157 @echo BUILD_NO_LDAP_PLUGIN=$(BUILD_NO_LDAP_PLUGIN) 157 ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
158 @echo BUILD_NO_OPIE_PLUGIN=$(BUILD_NO_OPIE_PLUGIN) 158 ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
159 @echo BUILD_NO_QTOPIA_PLUGIN=$(BUILD_NO_QTOPIA_PLUGIN) 159 ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
160 @echo BUILD_NO_SHARP_PLUGIN=$(BUILD_NO_SHARP_PLUGIN) 160 ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
161 ifndef BUILD_NO_SHARP_PLUGIN 161 ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
162 @echo SHARPDTMSDK=$(SHARPDTMSDK) 162 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
163 endif 163 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
164 @echo BUILD_NO_GAMMU=$(BUILD_NO_GAMMU) 164 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
165 @echo BUILD_NO_PWMANAGER=$(BUILD_NO_PWMANAGER) 165 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
166 @echo -------------------------------------- 166 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
167 167 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
168variable_test: variable_info 168 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
169 @echo KDEPIM buildsystem, variablecheck... 169 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
170 ifndef KDEPIMDIR 170 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
171 @echo KDEPIMDIR is not defined. 171clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE
172 $(error KDEPIMDIR is not defined) 172 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; ) || true
173 endif 173 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; ) || true
174 ifndef PLATFORM 174 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true
175 @echo PLATFORM is not defined. 175 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true
176 $(error PLATFORM is not defined) 176 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true
177 endif 177 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true
178 ifdef BUILD_NO_LDAP_PLUGIN 178 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true
179 @echo LDAP PLUGIN will not be build, because BUILD_NO_LDAP_PLUGIN is set to $(BUILD_NO_LDAP_PLUGIN) 179 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true
180 endif 180 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true
181 ifdef BUILD_NO_OPIE_PLUGIN 181 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true
182 @echo OPIE PLUGIN will not be build, because BUILD_NO_OPIE_PLUGIN is set to $(BUILD_NO_OPIE_PLUGIN) 182 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true
183 endif 183 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true
184 ifdef BUILD_NO_QTOPIA_PLUGIN 184 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) $@; ) || true
185 @echo QTOPIA PLUGIN will not be build, because BUILD_NO__QTOPIA_PLUGIN is set to $(BUILD_NO__QTOPIA_PLUGIN) 185 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) $@; ) || true
186 endif 186 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) $@; ) || true
187 ifdef BUILD_NO_MICROMAIL 187 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) $@; ) || true
188 @echo MICROMAIL will not be build, because BUILD_NO_MICROMAIL is set to $(BUILD_NO_MICROMAIL) 188 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) $@; ) || true
189 endif 189 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) $@; ) || true
190 ifdef BUILD_NO_SHARP_PLUGIN 190uninstall_subdirs: qmake_all FORCE
191 @echo SHARP PLUGIN will not be build, because BUILD_NO_SHARP_PLUGIN is set to $(BUILD_NO_SHARP_PLUGIN) 191 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
192 else 192 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
193 ifndef SHARPDTMSDK 193 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
194 @echo SHARP PLUGIN can not be build, because SHARPDTMSDK is set to $(SHARPDTMSDK) 194 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
195 $(error SHARPDTMSDK is not defined) 195 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
196 endif 196 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
197 endif 197 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
198 ifdef BUILD_NO_GAMMU 198 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
199 @echo GAMMU will not be build, because BUILD_NO_GAMMU is set to $(BUILD_NO_GAMMU) 199 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
200 endif 200 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
201 ifdef BUILD_NO_PWMANAGER 201 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
202 @echo PWMANAGER will not be build, because BUILD_NO_PWMANAGER is set to $(BUILD_NO_PWMANAGER) 202 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
203 endif 203 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
204 @echo -------------------------------------- 204 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
205 205 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
206 206 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
207objects: 207 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
208 for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done 208 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
209 for i in $(SUBDIRS); do mkdir -p $$i/moc/$(PLATFORM); done 209install_subdirs: qmake_all FORCE
210 mkdir -p libical/lib/$(PLATFORM) 210 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) install; ) || true
211 mkdir -p pwmanager/libcrypt/$(PLATFORM) 211 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) install; ) || true
212 212 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true
213clean: 213 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true
214 rm -rf libical/lib/$(PLATFORM)/*; 214 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true
215 rm -rf pwmanager/libcrypt/$(PLATFORM)/*; 215 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true
216 for i in $(SUBDIRS); do pushd $$i; make clean; rm -f *~;\ 216 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true
217 rm -f obj/$(PLATFORM)/*; rm -f moc/$(PLATFORM)/*; rm Makefile$(PLATFORM); popd; \ 217 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true
218 done 218 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true
219 219 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true
220install: 220 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true
221 221 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true
222 cd bin/kdepim; make install 222 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) install; ) || true
223 cp -r Pim $(QPEDIR)/apps 223 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) install; ) || true
224 cp db2file/db2file $(QPEDIR)/bin/db2file 224 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) install; ) || true
225 cp korganizer/korganizer.desktop $(QPEDIR)/apps/Pim/korganizer.desktop 225 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) install; ) || true
226 cp kaddressbook/kaddressbook.desktop $(QPEDIR)/apps/Pim/kaddressbook.desktop 226 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) install; ) || true
227 cp kmicromail/kmicromail.desktop $(QPEDIR)/apps/Pim/kopiemail.desktop 227 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) install; ) || true
228 cp pwmanager/pwmanager/pwmanager.desktop $(QPEDIR)/apps/Pim/pwmanager.desktop 228distclean: qmake_all FORCE
229 229 ( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
230dist: 230 ( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
231 @echo Dont forget to do "make install" before "make dist" 231 ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
232 rm -f *arm.ipk 232 ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
233 rm -f *~ 233 ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
234 cd ..; tar czf kdepimpi-$(KDEPIM_VERSION).tar.gz --exclude=obj --exclude=moc --exclude=CVS --exclude=Makefilezaurus --exclude=Makefileqtopia kdepim 234 ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
235 mkipks kmicrokdelibs.control 235 ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
236 mkipks korganizer.control 236 ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
237 mkipks kaddressbook.control 237 ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
238 ifndef BUILD_NO_MICROMAIL 238 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
239 mkipks kopiemail.control 239 ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
240 endif 240 ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
241 mkipks korganizer-alarm.control 241 ( [ -d kabc/plugins/qtopia ] && cd kabc/plugins/qtopia ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
242 ifndef BUILD_NO_GAMMU 242 ( [ -d pwmanager/libcrypt/cipher ] && cd pwmanager/libcrypt/cipher ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
243 mkipks phoneaccess.control 243 ( [ -d pwmanager/libcrypt/error ] && cd pwmanager/libcrypt/error ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
244 endif 244 ( [ -d pwmanager/libcrypt/mpi ] && cd pwmanager/libcrypt/mpi ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
245 ifndef BUILD_NO_PWMANAGER 245 ( [ -d pwmanager/libcrypt/zlib ] && cd pwmanager/libcrypt/zlib ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
246 mkipks pwmanager.control 246 ( [ -d pwmanager/pwmanager ] && cd pwmanager/pwmanager ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
247 endif 247
248 mkipks pim_TAB_icon.control 248install: install_subdirs
249 249
250tmake: objects \ 250uninstall: uninstall_subdirs
251 qtcompat/Makefile$(PLATFORM) \ 251
252 microkde/Makefile$(PLATFORM) \ 252FORCE:
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
279qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro
280 cd qtcompat; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" qtcompat.pro -o Makefile$(PLATFORM)
281
282microkde/Makefile$(PLATFORM): microkde/microkdeE.pro
283 cd microkde; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" microkdeE.pro -o Makefile$(PLATFORM)
284
285libkcal/Makefile$(PLATFORM): libkcal/libkcalE.pro
286 cd libkcal; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libkcalE.pro -o Makefile$(PLATFORM)
287
288
289libkdepim/Makefile$(PLATFORM): libkdepim/libkdepimE.pro
290 cd libkdepim; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libkdepimE.pro -o Makefile$(PLATFORM)
291
292kalarmd/Makefile$(PLATFORM): kalarmd/kalarmdE.pro
293 cd kalarmd; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kalarmdE.pro -o Makefile$(PLATFORM)
294
295korganizer/Makefile$(PLATFORM): korganizer/korganizerE.pro
296 cd korganizer; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" korganizerE.pro -o Makefile$(PLATFORM)
297
298libical/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
301libical/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
304kabc/Makefile$(PLATFORM): kabc/kabcE.pro
305 cd kabc; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kabcE.pro -o Makefile$(PLATFORM)
306
307kabc/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
310kabc/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
313kabc/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
316kabc/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
319kabc/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
322kabc/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
325kabc/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
328kaddressbook/Makefile$(PLATFORM): kaddressbook/kaddressbookE.pro
329 cd kaddressbook; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kaddressbookE.pro -o Makefile$(PLATFORM)
330
331kmicromail/Makefile$(PLATFORM): kmicromail/kmicromailE.pro
332 cd kmicromail; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" kmicromailE.pro -o Makefile$(PLATFORM)
333
334kmicromail/libetpan/Makefile$(PLATFORM): kmicromail/libetpan/libetpanE.pro
335 cd kmicromail/libetpan; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libetpanE.pro -o Makefile$(PLATFORM)
336
337kmicromail/libmailwrapper/Makefile$(PLATFORM): kmicromail/libmailwrapper/libmailwrapperE.pro
338 cd kmicromail/libmailwrapper; tmake "CONFIG+=$(RELEASE_DEBUG)" "VERSION=$(KDEPIM_VERSION)" libmailwrapperE.pro -o Makefile$(PLATFORM)
339
340gammu/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
343gammu/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
346pwmanager/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
350pwmanager/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
353pwmanager/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
356pwmanager/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
359pwmanager/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 253
diff --git a/microkde/kdeui/kmainwindow.cpp b/microkde/kdeui/kmainwindow.cpp
index bd5a2cc..3ae4c87 100644
--- a/microkde/kdeui/kmainwindow.cpp
+++ b/microkde/kdeui/kmainwindow.cpp
@@ -1,686 +1,687 @@
1 /* This file is part of the KDE libraries 1 /* This file is part of the KDE libraries
2 Copyright 2 Copyright
3 (C) 2000 Reginald Stadlbauer (reggie@kde.org) 3 (C) 2000 Reginald Stadlbauer (reggie@kde.org)
4 (C) 1997 Stephan Kulow (coolo@kde.org) 4 (C) 1997 Stephan Kulow (coolo@kde.org)
5 (C) 1997-2000 Sven Radej (radej@kde.org) 5 (C) 1997-2000 Sven Radej (radej@kde.org)
6 (C) 1997-2000 Matthias Ettrich (ettrich@kde.org) 6 (C) 1997-2000 Matthias Ettrich (ettrich@kde.org)
7 (C) 1999 Chris Schlaeger (cs@kde.org) 7 (C) 1999 Chris Schlaeger (cs@kde.org)
8 (C) 2002 Joseph Wenninger (jowenn@kde.org) 8 (C) 2002 Joseph Wenninger (jowenn@kde.org)
9 9
10 This library is free software; you can redistribute it and/or 10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public 11 modify it under the terms of the GNU Library General Public
12 License version 2 as published by the Free Software Foundation. 12 License version 2 as published by the Free Software Foundation.
13 13
14 This library is distributed in the hope that it will be useful, 14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details. 17 Library General Public License for more details.
18 18
19 You should have received a copy of the GNU Library General Public License 19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to 20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. 22 Boston, MA 02111-1307, USA.
23 */ 23 */
24#include <qobjectlist.h> 24#include <qobjectlist.h>
25#include <qstringlist.h> 25#include <qstringlist.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qmenubar.h> 27#include <qmenubar.h>
28#include <qstatusbar.h> 28#include <qstatusbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31 31
32#include "kdebug.h" 32#include "kdebug.h"
33#include "kmainwindow.h" 33#include "kmainwindow.h"
34#include "kglobalsettings.h" 34#include "kglobalsettings.h"
35#include "kactioncollection.h" 35#include "kactioncollection.h"
36 36
37class KMainWindowPrivate { 37class KMainWindowPrivate {
38public: 38public:
39//US bool showHelpMenu:1; 39//US bool showHelpMenu:1;
40 40
41 bool autoSaveSettings:1; 41 bool autoSaveSettings:1;
42 bool settingsDirty:1; 42 bool settingsDirty:1;
43 bool autoSaveWindowSize:1; 43 bool autoSaveWindowSize:1;
44 bool care_about_geometry:1; 44 bool care_about_geometry:1;
45 QString autoSaveGroup; 45 QString autoSaveGroup;
46//US KAccel * kaccel; 46//US KAccel * kaccel;
47//US KMainWindowInterface *m_interface; 47//US KMainWindowInterface *m_interface;
48 KDEPrivate::ToolBarHandler *toolBarHandler; 48 KDEPrivate::ToolBarHandler *toolBarHandler;
49 QTimer* settingsTimer; 49 QTimer* settingsTimer;
50 KToggleAction *showStatusBarAction; 50 KToggleAction *showStatusBarAction;
51 QRect defaultWindowSize; 51 QRect defaultWindowSize;
52}; 52};
53 53
54static bool no_query_exit = false; 54static bool no_query_exit = false;
55 55
56KMainWindow::KMainWindow( QWidget* parent, const char *name, WFlags f ) 56KMainWindow::KMainWindow( QWidget* parent, const char *name, WFlags f )
57 : QMainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/ 57 : QMainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/
58{ 58{
59 mQToolBar = 0; 59 mQToolBar = 0;
60 initKMainWindow(name); 60 initKMainWindow(name);
61} 61}
62 62
63void KMainWindow::parseGeometry(bool parsewidth) 63void KMainWindow::parseGeometry(bool parsewidth)
64{ 64{
65//US the following code is not getting used in the embedded version !! So disable it for now 65//US the following code is not getting used in the embedded version !! So disable it for now
66/*US 66/*US
67 67
68 assert ( !kapp->geometryArgument().isNull() ); 68 assert ( !kapp->geometryArgument().isNull() );
69 assert ( d->care_about_geometry ); 69 assert ( d->care_about_geometry );
70 70
71#ifndef Q_WS_QWS 71#ifndef Q_WS_QWS
72 // FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it) 72 // FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it)
73 int x, y; 73 int x, y;
74 int w, h; 74 int w, h;
75 int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h); 75 int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h);
76 if (parsewidth) { 76 if (parsewidth) {
77 QSize minSize = minimumSize(); 77 QSize minSize = minimumSize();
78 QSize maxSize = maximumSize(); 78 QSize maxSize = maximumSize();
79 if ( (m & WidthValue) == 0 ) 79 if ( (m & WidthValue) == 0 )
80 w = width(); 80 w = width();
81 if ( (m & HeightValue) == 0 ) 81 if ( (m & HeightValue) == 0 )
82 h = height(); 82 h = height();
83 w = QMIN(w,maxSize.width()); 83 w = QMIN(w,maxSize.width());
84 h = QMIN(h,maxSize.height()); 84 h = QMIN(h,maxSize.height());
85 w = QMAX(w,minSize.width()); 85 w = QMAX(w,minSize.width());
86 h = QMAX(h,minSize.height()); 86 h = QMAX(h,minSize.height());
87 resize(w, h); 87 resize(w, h);
88 } else { 88 } else {
89 if ( parsewidth && (m & XValue) == 0 ) 89 if ( parsewidth && (m & XValue) == 0 )
90 x = geometry().x(); 90 x = geometry().x();
91 if ( parsewidth && (m & YValue) == 0 ) 91 if ( parsewidth && (m & YValue) == 0 )
92 y = geometry().y(); 92 y = geometry().y();
93 if ( (m & XNegative) ) 93 if ( (m & XNegative) )
94 x = KApplication::desktop()->width() + x - w; 94 x = KApplication::desktop()->width() + x - w;
95 if ( (m & YNegative) ) 95 if ( (m & YNegative) )
96 y = KApplication::desktop()->height() + y - h; 96 y = KApplication::desktop()->height() + y - h;
97 move(x, y); 97 move(x, y);
98 } 98 }
99#endif 99#endif
100*/ 100*/
101} 101}
102 102
103KMainWindow::~KMainWindow() 103KMainWindow::~KMainWindow()
104{ 104{
105 delete d->settingsTimer; 105 delete d->settingsTimer;
106 QMenuBar* mb = internalMenuBar(); 106 QMenuBar* mb = internalMenuBar();
107 delete mb; 107 delete mb;
108//US delete d->m_interface; 108//US delete d->m_interface;
109 109
110 delete d; 110 delete d;
111//US memberList->remove( this ); 111//US memberList->remove( this );
112} 112}
113 113
114void KMainWindow::initKMainWindow(const char *name) 114void KMainWindow::initKMainWindow(const char *name)
115{ 115{
116 setDockMenuEnabled( FALSE ); 116 setDockMenuEnabled( FALSE );
117//US mHelpMenu = 0; 117//US mHelpMenu = 0;
118 118
119//US kapp->setTopWidget( this ); 119//US kapp->setTopWidget( this );
120 actionCollection()->setWidget( this ); 120 actionCollection()->setWidget( this );
121//US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); 121//US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
122//US if( !memberList ) 122//US if( !memberList )
123//US memberList = new QPtrList<KMainWindow>; 123//US memberList = new QPtrList<KMainWindow>;
124/*US 124/*US
125 125
126 if ( !ksm ) 126 if ( !ksm )
127 ksm = ksmd.setObject(new KMWSessionManaged()); 127 ksm = ksmd.setObject(new KMWSessionManaged());
128 // set a unique object name. Required by session management. 128 // set a unique object name. Required by session management.
129 QCString objname; 129 QCString objname;
130 QCString s; 130 QCString s;
131 int unusedNumber; 131 int unusedNumber;
132 if ( !name ) 132 if ( !name )
133 { // no name given 133 { // no name given
134 objname = kapp->instanceName() + "-mainwindow#"; 134 objname = kapp->instanceName() + "-mainwindow#";
135 s = objname + '1'; // start adding number immediately 135 s = objname + '1'; // start adding number immediately
136 unusedNumber = 1; 136 unusedNumber = 1;
137 } 137 }
138 else if( name[ strlen( name ) - 1 ] == '#' ) 138 else if( name[ strlen( name ) - 1 ] == '#' )
139 { // trailing # - always add a number 139 { // trailing # - always add a number
140 objname = name; 140 objname = name;
141 s = objname + '1'; // start adding number immediately 141 s = objname + '1'; // start adding number immediately
142 unusedNumber = 1; 142 unusedNumber = 1;
143 } 143 }
144 else 144 else
145 { 145 {
146 objname = name; 146 objname = name;
147 s = objname; 147 s = objname;
148 unusedNumber = 0; // add numbers only when needed 148 unusedNumber = 0; // add numbers only when needed
149 } 149 }
150 for(;;) { 150 for(;;) {
151 QWidgetList* list = kapp->topLevelWidgets(); 151 QWidgetList* list = kapp->topLevelWidgets();
152 QWidgetListIt it( *list ); 152 QWidgetListIt it( *list );
153 bool found = false; 153 bool found = false;
154 for( QWidget* w = it.current(); 154 for( QWidget* w = it.current();
155 w != NULL; 155 w != NULL;
156 ++it, w = it.current()) 156 ++it, w = it.current())
157 if( w != this && w->name() == s ) 157 if( w != this && w->name() == s )
158 { 158 {
159 found = true; 159 found = true;
160 break; 160 break;
161 } 161 }
162 delete list; 162 delete list;
163 if( !found ) 163 if( !found )
164 break; 164 break;
165 s.setNum( ++unusedNumber ); 165 s.setNum( ++unusedNumber );
166 s = objname + s; 166 s = objname + s;
167 } 167 }
168 setName( s ); 168 setName( s );
169 memberList->append( this ); 169 memberList->append( this );
170*/ 170*/
171 171
172 d = new KMainWindowPrivate; 172 d = new KMainWindowPrivate;
173//US d->showHelpMenu = true; 173//US d->showHelpMenu = true;
174 d->settingsDirty = false; 174 d->settingsDirty = false;
175 d->autoSaveSettings = false; 175 d->autoSaveSettings = false;
176 d->autoSaveWindowSize = true; // for compatibility 176 d->autoSaveWindowSize = true; // for compatibility
177//US d->kaccel = actionCollection()->kaccel(); 177//US d->kaccel = actionCollection()->kaccel();
178 d->toolBarHandler = 0; 178 d->toolBarHandler = 0;
179 d->settingsTimer = 0; 179 d->settingsTimer = 0;
180 d->showStatusBarAction = NULL; 180 d->showStatusBarAction = NULL;
181/*US 181/*US
182 if ((d->care_about_geometry == beeing_first)) { 182 if ((d->care_about_geometry == beeing_first)) {
183 beeing_first = false; 183 beeing_first = false;
184 if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater 184 if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater
185 d->care_about_geometry = false; 185 d->care_about_geometry = false;
186 else 186 else
187 parseGeometry(false); 187 parseGeometry(false);
188 } 188 }
189*/ 189*/
190 d->care_about_geometry = false; 190 d->care_about_geometry = false;
191 191
192//US setCaption( kapp->caption() ); 192//US setCaption( kapp->caption() );
193 // attach dcop interface 193 // attach dcop interface
194//US d->m_interface = new KMainWindowInterface(this); 194//US d->m_interface = new KMainWindowInterface(this);
195 195
196//US if (!kapp->authorize("movable_toolbars")) 196//US if (!kapp->authorize("movable_toolbars"))
197//US setDockWindowsMovable(false); 197//US setDockWindowsMovable(false);
198} 198}
199 199
200KAction *KMainWindow::toolBarMenuAction() 200KAction *KMainWindow::toolBarMenuAction()
201{ 201{
202 if ( !d->toolBarHandler ) 202 if ( !d->toolBarHandler )
203 return 0; 203 return 0;
204 204
205 return d->toolBarHandler->toolBarMenuAction(); 205 return d->toolBarHandler->toolBarMenuAction();
206} 206}
207 207
208bool KMainWindow::canBeRestored( int number ) 208bool KMainWindow::canBeRestored( int number )
209{ 209{
210/*US we do not have and want to save sessioninformation. Use info from the default 210/*US we do not have and want to save sessioninformation. Use info from the default
211application config. 211application config.
212*/ 212*/
213//US if ( !kapp->isRestored() ) 213//US if ( !kapp->isRestored() )
214//US return FALSE; 214//US return FALSE;
215//US KConfig *config = kapp->sessionConfig(); 215//US KConfig *config = kapp->sessionConfig();
216 KConfig *config = KGlobal::config(); 216 KConfig *config = KGlobal::config();
217 if ( !config ) 217 if ( !config )
218 return FALSE; 218 return FALSE;
219 config->setGroup( QString::fromLatin1("Number") ); 219 config->setGroup( QString::fromLatin1("Number") );
220 int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 ); 220 int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 );
221 return number >= 1 && number <= n; 221 return number >= 1 && number <= n;
222 222
223} 223}
224 224
225const QString KMainWindow::classNameOfToplevel( int number ) 225const QString KMainWindow::classNameOfToplevel( int number )
226{ 226{
227/*US we do not have and want to save sessioninformation. Use info from the default 227/*US we do not have and want to save sessioninformation. Use info from the default
228application config. 228application config.
229*/ 229*/
230//US if ( !kapp->isRestored() ) 230//US if ( !kapp->isRestored() )
231//US return QString::null; 231//US return QString::null;
232//US KConfig *config = kapp->sessionConfig(); 232//US KConfig *config = kapp->sessionConfig();
233 KConfig *config = KGlobal::config(); 233 KConfig *config = KGlobal::config();
234 if ( !config ) 234 if ( !config )
235 return QString::null; 235 return QString::null;
236 QString s; 236 QString s;
237 s.setNum( number ); 237 s.setNum( number );
238 s.prepend( QString::fromLatin1("WindowProperties") ); 238 s.prepend( QString::fromLatin1("WindowProperties") );
239 config->setGroup( s ); 239 config->setGroup( s );
240 if ( !config->hasKey( QString::fromLatin1("ClassName") ) ) 240 if ( !config->hasKey( QString::fromLatin1("ClassName") ) )
241 return QString::null; 241 return QString::null;
242 else 242 else
243 return config->readEntry( QString::fromLatin1("ClassName") ); 243 return config->readEntry( QString::fromLatin1("ClassName") );
244} 244}
245 245
246bool KMainWindow::restore( int number, bool show ) 246bool KMainWindow::restore( int number, bool show )
247{ 247{
248/*US we do not have and want to save sessioninformation. Use info from the default 248/*US we do not have and want to save sessioninformation. Use info from the default
249application config. 249application config.
250*/ 250*/
251 if ( !canBeRestored( number ) ) 251 if ( !canBeRestored( number ) )
252 return FALSE; 252 return FALSE;
253//US KConfig *config = kapp->sessionConfig(); 253//US KConfig *config = kapp->sessionConfig();
254 KConfig *config = KGlobal::config(); 254 KConfig *config = KGlobal::config();
255 255
256 if ( readPropertiesInternal( config, number ) ){ 256 if ( readPropertiesInternal( config, number ) ){
257 if ( show ) 257 if ( show )
258 KMainWindow::show(); 258 KMainWindow::show();
259 return FALSE; 259 return FALSE;
260 } 260 }
261 return FALSE; 261 return FALSE;
262 262
263} 263}
264 264
265void KMainWindow::setCaption( const QString &caption ) 265void KMainWindow::setCaption( const QString &caption )
266{ 266{
267//US setPlainCaption( kapp->makeStdCaption(caption) ); 267//US setPlainCaption( kapp->makeStdCaption(caption) );
268 setPlainCaption( caption ); 268 setPlainCaption( caption );
269} 269}
270 270
271void KMainWindow::setCaption( const QString &caption, bool modified ) 271void KMainWindow::setCaption( const QString &caption, bool modified )
272{ 272{
273//US setPlainCaption( kapp->makeStdCaption(caption, true, modified) ); 273//US setPlainCaption( kapp->makeStdCaption(caption, true, modified) );
274 setPlainCaption( caption + "modified:" ); 274 setPlainCaption( caption + "modified:" );
275} 275}
276 276
277void KMainWindow::setPlainCaption( const QString &caption ) 277void KMainWindow::setPlainCaption( const QString &caption )
278{ 278{
279 QMainWindow::setCaption( caption ); 279 QMainWindow::setCaption( caption );
280#ifndef Q_WS_QWS 280#ifndef Q_WS_QWS
281//US the following is disabled for the embedded version 281//US the following is disabled for the embedded version
282//US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 ); 282//US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 );
283//US info.setName( caption.utf8().data() ); 283//US info.setName( caption.utf8().data() );
284#endif 284#endif
285} 285}
286 286
287void KMainWindow::slotStateChanged(const QString &newstate) 287void KMainWindow::slotStateChanged(const QString &newstate)
288{ 288{
289 stateChanged(newstate, KXMLGUIClient::StateNoReverse); 289 stateChanged(newstate, KXMLGUIClient::StateNoReverse);
290} 290}
291 291
292/* 292/*
293 * Get rid of this for KDE 4.0 293 * Get rid of this for KDE 4.0
294 */ 294 */
295void KMainWindow::slotStateChanged(const QString &newstate, 295void KMainWindow::slotStateChanged(const QString &newstate,
296 KXMLGUIClient::ReverseStateChange reverse) 296 KXMLGUIClient::ReverseStateChange reverse)
297{ 297{
298 stateChanged(newstate, reverse); 298 stateChanged(newstate, reverse);
299} 299}
300 300
301void KMainWindow::closeEvent ( QCloseEvent *e ) 301void KMainWindow::closeEvent ( QCloseEvent *e )
302{ 302{
303 //qDebug("MainWindow::closeEvent ");
303 // Save settings if auto-save is enabled, and settings have changed 304 // Save settings if auto-save is enabled, and settings have changed
304 if (d->settingsDirty && d->autoSaveSettings) 305 if (d->settingsDirty && d->autoSaveSettings)
305 saveAutoSaveSettings(); 306 saveAutoSaveSettings();
306 307
307 if (queryClose()) { 308 if (queryClose()) {
308 e->accept(); 309 e->accept();
309 310
310 int not_withdrawn = 0; 311 int not_withdrawn = 0;
311/*US 312/*US
312 QPtrListIterator<KMainWindow> it(*KMainWindow::memberList); 313 QPtrListIterator<KMainWindow> it(*KMainWindow::memberList);
313 for (it.toFirst(); it.current(); ++it){ 314 for (it.toFirst(); it.current(); ++it){
314 if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this ) 315 if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this )
315 not_withdrawn++; 316 not_withdrawn++;
316 } 317 }
317*/ 318*/
318 if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted? 319 if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted?
319/*US 320/*US
320 if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app? 321 if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app?
321 // don't call queryExit() twice 322 // don't call queryExit() twice
322 disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); 323 disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
323 kapp->deref(); // ...and quit aplication. 324 kapp->deref(); // ...and quit aplication.
324 } else { 325 } else {
325 // cancel closing, it's stupid to end up with no windows at all.... 326 // cancel closing, it's stupid to end up with no windows at all....
326 e->ignore(); 327 e->ignore();
327 } 328 }
328*/ 329*/
329//US we have no sessionmanagement. Simply close app. 330//US we have no sessionmanagement. Simply close app.
330 if ( queryExit() ) { // Yes, Quit app? 331 if ( queryExit() ) { // Yes, Quit app?
331 qDebug("KMainWindow::closeEvent: Exit application ???"); 332 qDebug("KMainWindow::closeEvent: Exit application ???");
332 // don't call queryExit() twice 333 // don't call queryExit() twice
333//US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); 334//US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
334 } 335 }
335 336
336 } 337 }
337 } 338 }
338} 339}
339 340
340bool KMainWindow::queryExit() 341bool KMainWindow::queryExit()
341{ 342{
342 return TRUE; 343 return TRUE;
343} 344}
344 345
345bool KMainWindow::queryClose() 346bool KMainWindow::queryClose()
346{ 347{
347 return TRUE; 348 return TRUE;
348} 349}
349 350
350void KMainWindow::saveGlobalProperties( KConfig* ) 351void KMainWindow::saveGlobalProperties( KConfig* )
351{ 352{
352} 353}
353 354
354void KMainWindow::readGlobalProperties( KConfig* ) 355void KMainWindow::readGlobalProperties( KConfig* )
355{ 356{
356} 357}
357 358
358void KMainWindow::savePropertiesInternal( KConfig *config, int number ) 359void KMainWindow::savePropertiesInternal( KConfig *config, int number )
359{ 360{
360 bool oldASWS = d->autoSaveWindowSize; 361 bool oldASWS = d->autoSaveWindowSize;
361 d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size 362 d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size
362 363
363 QString s; 364 QString s;
364 s.setNum(number); 365 s.setNum(number);
365 s.prepend(QString::fromLatin1("WindowProperties")); 366 s.prepend(QString::fromLatin1("WindowProperties"));
366 config->setGroup(s); 367 config->setGroup(s);
367 368
368 // store objectName, className, Width and Height for later restoring 369 // store objectName, className, Width and Height for later restoring
369 // (Only useful for session management) 370 // (Only useful for session management)
370 config->writeEntry(QString::fromLatin1("ObjectName"), name()); 371 config->writeEntry(QString::fromLatin1("ObjectName"), name());
371 config->writeEntry(QString::fromLatin1("ClassName"), className()); 372 config->writeEntry(QString::fromLatin1("ClassName"), className());
372 373
373 saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings. 374 saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings.
374 375
375 s.setNum(number); 376 s.setNum(number);
376 config->setGroup(s); 377 config->setGroup(s);
377 saveProperties(config); 378 saveProperties(config);
378 379
379 d->autoSaveWindowSize = oldASWS; 380 d->autoSaveWindowSize = oldASWS;
380} 381}
381 382
382void KMainWindow::setStandardToolBarMenuEnabled( bool enable ) 383void KMainWindow::setStandardToolBarMenuEnabled( bool enable )
383{ 384{
384 if ( enable ) 385 if ( enable )
385 { 386 {
386 if ( d->toolBarHandler ) 387 if ( d->toolBarHandler )
387 return; 388 return;
388 389
389 d->toolBarHandler = new KDEPrivate::ToolBarHandler( this ); 390 d->toolBarHandler = new KDEPrivate::ToolBarHandler( this );
390 391
391/*US if ( factory() ) 392/*US if ( factory() )
392 factory()->addClient( d->toolBarHandler ); 393 factory()->addClient( d->toolBarHandler );
393*/ 394*/
394 } 395 }
395 else 396 else
396 { 397 {
397 if ( !d->toolBarHandler ) 398 if ( !d->toolBarHandler )
398 return; 399 return;
399/*US 400/*US
400 if ( factory() ) 401 if ( factory() )
401 factory()->removeClient( d->toolBarHandler ); 402 factory()->removeClient( d->toolBarHandler );
402*/ 403*/
403 delete d->toolBarHandler; 404 delete d->toolBarHandler;
404 d->toolBarHandler = 0; 405 d->toolBarHandler = 0;
405 } 406 }
406 407
407} 408}
408 409
409bool KMainWindow::isStandardToolBarMenuEnabled() const 410bool KMainWindow::isStandardToolBarMenuEnabled() const
410{ 411{
411 return ( d->toolBarHandler != 0 ); 412 return ( d->toolBarHandler != 0 );
412} 413}
413 414
414void KMainWindow::createStandardStatusBarAction(){ 415void KMainWindow::createStandardStatusBarAction(){
415 if(!d->showStatusBarAction){ 416 if(!d->showStatusBarAction){
416 d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection()); 417 d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection());
417 connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); 418 connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool)));
418 if(internalStatusBar()) 419 if(internalStatusBar())
419 d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); 420 d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden());
420 } 421 }
421} 422}
422 423
423QToolBar *KMainWindow::tBar( ) 424QToolBar *KMainWindow::tBar( )
424{ 425{
425 if ( ! mQToolBar ) 426 if ( ! mQToolBar )
426 mQToolBar = new QToolBar( this ); 427 mQToolBar = new QToolBar( this );
427 return mQToolBar; 428 return mQToolBar;
428} 429}
429 430
430KToolBar *KMainWindow::toolBar( const char * name ) 431KToolBar *KMainWindow::toolBar( const char * name )
431{ 432{
432 433
433 if (!name) 434 if (!name)
434 name = "mainToolBar"; 435 name = "mainToolBar";
435 KToolBar *tb = (KToolBar*)child( name, "KToolBar" ); 436 KToolBar *tb = (KToolBar*)child( name, "KToolBar" );
436 if ( tb ) 437 if ( tb )
437 return tb; 438 return tb;
438 bool honor_mode = (name == "mainToolBar"); 439 bool honor_mode = (name == "mainToolBar");
439 440
440/*US 441/*US
441 if ( builderClient() ) 442 if ( builderClient() )
442 return new KToolBar(this, name, honor_mode); // XMLGUI constructor 443 return new KToolBar(this, name, honor_mode); // XMLGUI constructor
443 else 444 else
444*/ 445*/
445 return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI 446 return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI
446} 447}
447 448
448QPtrListIterator<KToolBar> KMainWindow::toolBarIterator() 449QPtrListIterator<KToolBar> KMainWindow::toolBarIterator()
449{ 450{
450 toolbarList.clear(); 451 toolbarList.clear();
451 QPtrList<QToolBar> lst; 452 QPtrList<QToolBar> lst;
452 for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) { 453 for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) {
453 lst = toolBars( (ToolBarDock)i ); 454 lst = toolBars( (ToolBarDock)i );
454 for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) { 455 for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) {
455 if ( !tb->inherits( "KToolBar" ) ) 456 if ( !tb->inherits( "KToolBar" ) )
456 continue; 457 continue;
457 toolbarList.append( (KToolBar*)tb ); 458 toolbarList.append( (KToolBar*)tb );
458 } 459 }
459 } 460 }
460 return QPtrListIterator<KToolBar>( toolbarList ); 461 return QPtrListIterator<KToolBar>( toolbarList );
461} 462}
462 463
463void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) 464void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize )
464{ 465{
465 d->autoSaveSettings = true; 466 d->autoSaveSettings = true;
466 d->autoSaveGroup = groupName; 467 d->autoSaveGroup = groupName;
467 d->autoSaveWindowSize = saveWindowSize; 468 d->autoSaveWindowSize = saveWindowSize;
468 // Get notified when the user moves a toolbar around 469 // Get notified when the user moves a toolbar around
469//US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), 470//US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ),
470//US this, SLOT( setSettingsDirty() ) ); 471//US this, SLOT( setSettingsDirty() ) );
471 connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ), 472 connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ),
472 this, SLOT( setSettingsDirty() ) ); 473 this, SLOT( setSettingsDirty() ) );
473 474
474 475
475 // Get default values 476 // Get default values
476//US int scnum = QApplication::desktop()->screenNumber(parentWidget()); 477//US int scnum = QApplication::desktop()->screenNumber(parentWidget());
477//US QRect desk = QApplication::desktop()->screenGeometry(scnum); 478//US QRect desk = QApplication::desktop()->screenGeometry(scnum);
478 QRect desk = KGlobalSettings::desktopGeometry(0); 479 QRect desk = KGlobalSettings::desktopGeometry(0);
479 480
480 d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height()); 481 d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height());
481 // Now read the previously saved settings 482 // Now read the previously saved settings
482 applyMainWindowSettings( KGlobal::config(), groupName ); 483 applyMainWindowSettings( KGlobal::config(), groupName );
483} 484}
484 485
485 486
486void KMainWindow::resetAutoSaveSettings() 487void KMainWindow::resetAutoSaveSettings()
487{ 488{
488 d->autoSaveSettings = false; 489 d->autoSaveSettings = false;
489 if ( d->settingsTimer ) 490 if ( d->settingsTimer )
490 d->settingsTimer->stop(); 491 d->settingsTimer->stop();
491} 492}
492 493
493bool KMainWindow::autoSaveSettings() const 494bool KMainWindow::autoSaveSettings() const
494{ 495{
495 return d->autoSaveSettings; 496 return d->autoSaveSettings;
496} 497}
497 498
498QString KMainWindow::autoSaveGroup() const 499QString KMainWindow::autoSaveGroup() const
499{ 500{
500 return d->autoSaveGroup; 501 return d->autoSaveGroup;
501} 502}
502 503
503void KMainWindow::saveAutoSaveSettings() 504void KMainWindow::saveAutoSaveSettings()
504{ 505{
505 ASSERT( d->autoSaveSettings ); 506 ASSERT( d->autoSaveSettings );
506 //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; 507 //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl;
507 saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); 508 saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup );
508 KGlobal::config()->sync(); 509 KGlobal::config()->sync();
509 d->settingsDirty = false; 510 d->settingsDirty = false;
510 if ( d->settingsTimer ) 511 if ( d->settingsTimer )
511 d->settingsTimer->stop(); 512 d->settingsTimer->stop();
512} 513}
513 514
514void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory ) 515void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory )
515{ 516{
516 // disabling the updates prevents unnecessary redraws 517 // disabling the updates prevents unnecessary redraws
517 setUpdatesEnabled( false ); 518 setUpdatesEnabled( false );
518 519
519 // just in case we are rebuilding, let's remove our old client 520 // just in case we are rebuilding, let's remove our old client
520//US guiFactory()->removeClient( this ); 521//US guiFactory()->removeClient( this );
521 522
522 // make sure to have an empty GUI 523 // make sure to have an empty GUI
523 QMenuBar* mb = internalMenuBar(); 524 QMenuBar* mb = internalMenuBar();
524 if ( mb ) 525 if ( mb )
525 mb->clear(); 526 mb->clear();
526 527
527 (void)toolBarIterator(); // make sure toolbarList is most-up-to-date 528 (void)toolBarIterator(); // make sure toolbarList is most-up-to-date
528 toolbarList.setAutoDelete( true ); 529 toolbarList.setAutoDelete( true );
529 toolbarList.clear(); 530 toolbarList.clear();
530 toolbarList.setAutoDelete( false ); 531 toolbarList.setAutoDelete( false );
531/*US 532/*US
532 // don't build a help menu unless the user ask for it 533 // don't build a help menu unless the user ask for it
533 if (d->showHelpMenu) { 534 if (d->showHelpMenu) {
534 // we always want a help menu 535 // we always want a help menu
535 if (helpMenu2 == 0) 536 if (helpMenu2 == 0)
536 helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true, 537 helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true,
537 actionCollection()); 538 actionCollection());
538 } 539 }
539 540
540 // we always want to load in our global standards file 541 // we always want to load in our global standards file
541 setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) ); 542 setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) );
542 543
543 // now, merge in our local xml file. if this is null, then that 544 // now, merge in our local xml file. if this is null, then that
544 // means that we will be only using the global file 545 // means that we will be only using the global file
545 if ( !xmlfile.isNull() ) { 546 if ( !xmlfile.isNull() ) {
546 setXMLFile( xmlfile, true ); 547 setXMLFile( xmlfile, true );
547 } else { 548 } else {
548 QString auto_file(instance()->instanceName() + "ui.rc"); 549 QString auto_file(instance()->instanceName() + "ui.rc");
549 setXMLFile( auto_file, true ); 550 setXMLFile( auto_file, true );
550 } 551 }
551 552
552 // make sure we don't have any state saved already 553 // make sure we don't have any state saved already
553 setXMLGUIBuildDocument( QDomDocument() ); 554 setXMLGUIBuildDocument( QDomDocument() );
554 555
555 // do the actual GUI building 556 // do the actual GUI building
556 guiFactory()->addClient( this ); 557 guiFactory()->addClient( this );
557 558
558 // try and get back *some* of our memory 559 // try and get back *some* of our memory
559 if ( _conserveMemory ) 560 if ( _conserveMemory )
560 { 561 {
561 // before freeing the memory allocated by the DOM document we also 562 // before freeing the memory allocated by the DOM document we also
562 // free all memory allocated internally in the KXMLGUIFactory for 563 // free all memory allocated internally in the KXMLGUIFactory for
563 // the menubar and the toolbars . This however implies that we 564 // the menubar and the toolbars . This however implies that we
564 // have to take care of deleting those widgets ourselves. For 565 // have to take care of deleting those widgets ourselves. For
565 // destruction this is no problem, but when rebuilding we have 566 // destruction this is no problem, but when rebuilding we have
566 // to take care of that (and we want to rebuild the GUI when 567 // to take care of that (and we want to rebuild the GUI when
567 // using stuff like the toolbar editor ). 568 // using stuff like the toolbar editor ).
568 // In addition we have to take care of not removing containers 569 // In addition we have to take care of not removing containers
569 // like popupmenus, defined in the XML document. 570 // like popupmenus, defined in the XML document.
570 // this code should probably go into a separate method in KMainWindow. 571 // this code should probably go into a separate method in KMainWindow.
571 // there's just one problem: I'm bad in finding names ;-) , so 572 // there's just one problem: I'm bad in finding names ;-) , so
572 // I skipped this ;-) 573 // I skipped this ;-)
573 574
574 QDomDocument doc = domDocument(); 575 QDomDocument doc = domDocument();
575 576
576 QDomElement e = doc.documentElement().firstChild().toElement(); 577 QDomElement e = doc.documentElement().firstChild().toElement();
577 for (; !e.isNull(); e = e.nextSibling().toElement() ) { 578 for (; !e.isNull(); e = e.nextSibling().toElement() ) {
578 if ( e.tagName().lower() == "toolbar" ) 579 if ( e.tagName().lower() == "toolbar" )
579 factory_->resetContainer( e.attribute( "name" ) ); 580 factory_->resetContainer( e.attribute( "name" ) );
580 else if ( e.tagName().lower() == "menubar" ) 581 else if ( e.tagName().lower() == "menubar" )
581 factory_->resetContainer( e.tagName(), true ); 582 factory_->resetContainer( e.tagName(), true );
582 } 583 }
583 584
584 conserveMemory(); 585 conserveMemory();
585 } 586 }
586*/ 587*/
587 setUpdatesEnabled( true ); 588 setUpdatesEnabled( true );
588 updateGeometry(); 589 updateGeometry();
589} 590}
590 591
591void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configGroup) 592void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configGroup)
592{ 593{
593 kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl; 594 kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl;
594//US QStrList entryList; 595//US QStrList entryList;
595 QStringList entryList; 596 QStringList entryList;
596 QString oldGroup; 597 QString oldGroup;
597 598
598 if (!configGroup.isEmpty()) 599 if (!configGroup.isEmpty())
599 { 600 {
600 oldGroup = config->group(); 601 oldGroup = config->group();
601 config->setGroup(configGroup); 602 config->setGroup(configGroup);
602 } 603 }
603 604
604 // Called by session management - or if we want to save the window size anyway 605 // Called by session management - or if we want to save the window size anyway
605 if ( d->autoSaveWindowSize ) 606 if ( d->autoSaveWindowSize )
606 saveWindowSize( config ); 607 saveWindowSize( config );
607 608
608 QStatusBar* sb = internalStatusBar(); 609 QStatusBar* sb = internalStatusBar();
609 if (sb) { 610 if (sb) {
610 entryList.clear(); 611 entryList.clear();
611 if ( sb->isHidden() ) 612 if ( sb->isHidden() )
612 entryList.append("Disabled"); 613 entryList.append("Disabled");
613 else 614 else
614 entryList.append("Enabled"); 615 entryList.append("Enabled");
615 616
616 if(sb->isHidden()) 617 if(sb->isHidden())
617 //US config->writeEntry(QString::fromLatin1("StatusBar"), entryList, ';'); 618 //US config->writeEntry(QString::fromLatin1("StatusBar"), entryList, ';');
618 config->writeEntry(QString::fromLatin1("StatusBar"), entryList); 619 config->writeEntry(QString::fromLatin1("StatusBar"), entryList);
619 else 620 else
620 config->deleteEntry(QString::fromLatin1("StatusBar")); 621 config->deleteEntry(QString::fromLatin1("StatusBar"));
621 } 622 }
622 623
623 QMenuBar* mb = internalMenuBar(); 624 QMenuBar* mb = internalMenuBar();
624 if (mb) { 625 if (mb) {
625 entryList.clear(); 626 entryList.clear();
626 if ( mb->isHidden() ) 627 if ( mb->isHidden() )
627 entryList.append("Disabled"); 628 entryList.append("Disabled");
628 else 629 else
629 entryList.append("Enabled"); 630 entryList.append("Enabled");
630 631
631 // By default we don't hide. 632 // By default we don't hide.
632 if(mb->isHidden()) 633 if(mb->isHidden())
633 //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';'); 634 //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';');
634 config->writeEntry(QString::fromLatin1("MenuBar"), entryList); 635 config->writeEntry(QString::fromLatin1("MenuBar"), entryList);
635 else 636 else
636 config->deleteEntry(QString::fromLatin1("MenuBar")); 637 config->deleteEntry(QString::fromLatin1("MenuBar"));
637 } 638 }
638 639
639 int n = 1; // Toolbar counter. toolbars are counted from 1, 640 int n = 1; // Toolbar counter. toolbars are counted from 1,
640 KToolBar *toolbar = 0; 641 KToolBar *toolbar = 0;
641 QPtrListIterator<KToolBar> it( toolBarIterator() ); 642 QPtrListIterator<KToolBar> it( toolBarIterator() );
642 while ( ( toolbar = it.current() ) ) { 643 while ( ( toolbar = it.current() ) ) {
643 ++it; 644 ++it;
644 QString group; 645 QString group;
645 if (!configGroup.isEmpty()) 646 if (!configGroup.isEmpty())
646 { 647 {
647 // Give a number to the toolbar, but prefer a name if there is one, 648 // Give a number to the toolbar, but prefer a name if there is one,
648 // because there's no real guarantee on the ordering of toolbars 649 // because there's no real guarantee on the ordering of toolbars
649 group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); 650 group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name());
650 group.prepend(" Toolbar"); 651 group.prepend(" Toolbar");
651 group.prepend(configGroup); 652 group.prepend(configGroup);
652 } 653 }
653 toolbar->saveSettings(config, group); 654 toolbar->saveSettings(config, group);
654 n++; 655 n++;
655 } 656 }
656 if (!configGroup.isEmpty()) 657 if (!configGroup.isEmpty())
657 config->setGroup(oldGroup); 658 config->setGroup(oldGroup);
658} 659}
659 660
660bool KMainWindow::readPropertiesInternal( KConfig *config, int number ) 661bool KMainWindow::readPropertiesInternal( KConfig *config, int number )
661{ 662{
662 if ( number == 1 ) 663 if ( number == 1 )
663 readGlobalProperties( config ); 664 readGlobalProperties( config );
664 665
665 // in order they are in toolbar list 666 // in order they are in toolbar list
666 QString s; 667 QString s;
667 s.setNum(number); 668 s.setNum(number);
668 s.prepend(QString::fromLatin1("WindowProperties")); 669 s.prepend(QString::fromLatin1("WindowProperties"));
669 670
670 config->setGroup(s); 671 config->setGroup(s);
671 672
672 // restore the object name (window role) 673 // restore the object name (window role)
673 if ( config->hasKey(QString::fromLatin1("ObjectName" )) ) 674 if ( config->hasKey(QString::fromLatin1("ObjectName" )) )
674 setName( config->readEntry(QString::fromLatin1("ObjectName")).latin1()); // latin1 is right here 675 setName( config->readEntry(QString::fromLatin1("ObjectName")).latin1()); // latin1 is right here
675 676
676 applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings. 677 applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings.
677 678
678 s.setNum(number); 679 s.setNum(number);
679 config->setGroup(s); 680 config->setGroup(s);
680 readProperties(config); 681 readProperties(config);
681 return true; 682 return true;
682} 683}
683 684
684void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &configGroup) 685void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &configGroup)
685{ 686{
686 kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl; 687 kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl;
diff --git a/microkde/kdeui/kmainwindow.h b/microkde/kdeui/kmainwindow.h
index e76e732..2aafb9d 100644
--- a/microkde/kdeui/kmainwindow.h
+++ b/microkde/kdeui/kmainwindow.h
@@ -1,480 +1,481 @@
1/* 1/*
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation. 6 License version 2 as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17 17
18 $Id$ 18 $Id$
19 19
20*/ 20*/
21 21
22 22
23 23
24#ifndef KMAINWINDOW_H 24#ifndef KMAINWINDOW_H
25#define KMAINWINDOW_H 25#define KMAINWINDOW_H
26 26
27/*US 27/*US
28#include "kxmlguifactory.h" 28#include "kxmlguifactory.h"
29#include "kxmlguiclient.h" 29#include "kxmlguiclient.h"
30#include "kxmlguibuilder.h" 30#include "kxmlguibuilder.h"
31#include <qmetaobject.h> 31#include <qmetaobject.h>
32 32
33class KPopupMenu; 33class KPopupMenu;
34class KXMLGUIFactory; 34class KXMLGUIFactory;
35class KConfig; 35class KConfig;
36class KHelpMenu; 36class KHelpMenu;
37class KStatusBar; 37class KStatusBar;
38class QStatusBar; 38class QStatusBar;
39class KMenuBar; 39class KMenuBar;
40class KMWSessionManaged; 40class KMWSessionManaged;
41class KAccel; 41class KAccel;
42class KToolBarMenuAction; 42class KToolBarMenuAction;
43*/ 43*/
44 44
45class QMenuBar; 45class QMenuBar;
46class QStatusBar; 46class QStatusBar;
47class KMainWindowPrivate; 47class KMainWindowPrivate;
48class KAction; 48class KAction;
49 49
50#include <ktoolbar.h> 50#include <ktoolbar.h>
51#include <ktoolbarhandler.h> 51#include <ktoolbarhandler.h>
52#include <kxmlguiclient.h> 52#include <kxmlguiclient.h>
53#include <qmainwindow.h> 53#include <qmainwindow.h>
54#include <qptrlist.h> 54#include <qptrlist.h>
55 55
56class KActionCollection; 56class KActionCollection;
57 57
58class KMainWindow : public QMainWindow, virtual public KXMLGUIClient 58class KMainWindow : public QMainWindow, virtual public KXMLGUIClient
59{ 59{
60 Q_OBJECT 60 Q_OBJECT
61 61
62private: 62private:
63//US create private defaultconstructor 63//US create private defaultconstructor
64 KMainWindow() {;}; 64 KMainWindow() {;};
65 65
66public: 66
67public: 67public:
68 /** 68 /**
69 * Construct a main window. 69 * Construct a main window.
70 * 70 *
71 * @param parent The widget parent. This is usually 0 but it may also be the window 71 * @param parent The widget parent. This is usually 0 but it may also be the window
72 * group leader. In that case, the KMainWindow becomes sort of a 72 * group leader. In that case, the KMainWindow becomes sort of a
73 * secondary window. 73 * secondary window.
74 * 74 *
75 * @param name The object name. For session management and window management to work 75 * @param name The object name. For session management and window management to work
76 * properly, all main windows in the application should have a 76 * properly, all main windows in the application should have a
77 * different name. When passing 0 (the default), KMainWindow will create 77 * different name. When passing 0 (the default), KMainWindow will create
78 * a unique name, but it's recommended to explicitly pass a window name that will 78 * a unique name, but it's recommended to explicitly pass a window name that will
79 * also describe the type of the window. If there can be several windows of the same 79 * also describe the type of the window. If there can be several windows of the same
80 * type, append '#' (hash) to the name, and KMainWindow will append numbers to make 80 * type, append '#' (hash) to the name, and KMainWindow will append numbers to make
81 * the names unique. For example, for a mail client which has one main window showing 81 * the names unique. For example, for a mail client which has one main window showing
82 * the mails and folders, and which can also have one or more windows for composing 82 * the mails and folders, and which can also have one or more windows for composing
83 * mails, the name for the folders window should be e.g. "mainwindow" and 83 * mails, the name for the folders window should be e.g. "mainwindow" and
84 * for the composer windows "composer#". 84 * for the composer windows "composer#".
85 * 85 *
86 * @param f Specify the widget flags. The default is 86 * @param f Specify the widget flags. The default is
87 * WType_TopLevel and WDestructiveClose. TopLevel indicates that a 87 * WType_TopLevel and WDestructiveClose. TopLevel indicates that a
88 * main window is a toplevel window, regardless of whether it has a 88 * main window is a toplevel window, regardless of whether it has a
89 * parent or not. DestructiveClose indicates that a main window is 89 * parent or not. DestructiveClose indicates that a main window is
90 * automatically destroyed when its window is closed. Pass 0 if 90 * automatically destroyed when its window is closed. Pass 0 if
91 * you do not want this behavior. 91 * you do not want this behavior.
92 * 92 *
93 * KMainWindows must be created on the heap with 'new', like: 93 * KMainWindows must be created on the heap with 'new', like:
94 * <pre> KMainWindow *kmw = new KMainWindow (...</pre> 94 * <pre> KMainWindow *kmw = new KMainWindow (...</pre>
95 **/ 95 **/
96 KMainWindow( QWidget* parent = 0, const char *name = 0, WFlags f = WType_TopLevel | WDestructiveClose ); 96 //LR remove WDestructiveClose
97 KMainWindow( QWidget* parent = 0, const char *name = 0, WFlags f = WType_TopLevel /*| WDestructiveClose*/ );
97 98
98 99
99 /** 100 /**
100 * Destructor. 101 * Destructor.
101 * 102 *
102 * Will also destroy the toolbars, and menubar if 103 * Will also destroy the toolbars, and menubar if
103 * needed. 104 * needed.
104 */ 105 */
105 virtual ~KMainWindow(); 106 virtual ~KMainWindow();
106 107
107 /** 108 /**
108 * Retrieve the standard help menu. 109 * Retrieve the standard help menu.
109 * 110 *
110 * It contains entires for the 111 * It contains entires for the
111 * help system (activated by F1), an optional "What's This?" entry 112 * help system (activated by F1), an optional "What's This?" entry
112 * (activated by Shift F1), an application specific dialog box, 113 * (activated by Shift F1), an application specific dialog box,
113 * and an "About KDE" dialog box. 114 * and an "About KDE" dialog box.
114 * 115 *
115 * Example (adding a standard help menu to your application): 116 * Example (adding a standard help menu to your application):
116 * <pre> 117 * <pre>
117 * KPopupMenu *help = helpMenu( <myTextString> ); 118 * KPopupMenu *help = helpMenu( <myTextString> );
118 * menuBar()->insertItem( i18n("&Help"), help ); 119 * menuBar()->insertItem( i18n("&Help"), help );
119 * </pre> 120 * </pre>
120 * 121 *
121 * @param aboutAppText The string that is used in the application 122 * @param aboutAppText The string that is used in the application
122 * specific dialog box. If you leave this string empty the 123 * specific dialog box. If you leave this string empty the
123 * information in the global @ref KAboutData of the 124 * information in the global @ref KAboutData of the
124 * application will be used to make a standard dialog box. 125 * application will be used to make a standard dialog box.
125 * 126 *
126 * @param showWhatsThis Set this to false if you do not want to include 127 * @param showWhatsThis Set this to false if you do not want to include
127 * the "What's This" menu entry. 128 * the "What's This" menu entry.
128 * 129 *
129 * @return A standard help menu. 130 * @return A standard help menu.
130 */ 131 */
131//US KPopupMenu* helpMenu( const QString &aboutAppText = QString::null, 132//US KPopupMenu* helpMenu( const QString &aboutAppText = QString::null,
132//US bool showWhatsThis = TRUE ); 133//US bool showWhatsThis = TRUE );
133 134
134 /** 135 /**
135 * Returns the help menu. Creates a standard help menu if none exists yet. 136 * Returns the help menu. Creates a standard help menu if none exists yet.
136 * 137 *
137 * It contains entries for the 138 * It contains entries for the
138 * help system (activated by F1), an optional "What's This?" entry 139 * help system (activated by F1), an optional "What's This?" entry
139 * (activated by Shift F1), an application specific dialog box, 140 * (activated by Shift F1), an application specific dialog box,
140 * and an "About KDE" dialog box. You must create the application 141 * and an "About KDE" dialog box. You must create the application
141 * specific dialog box yourself. When the "About application" 142 * specific dialog box yourself. When the "About application"
142 * menu entry is activated, a signal will trigger the 143 * menu entry is activated, a signal will trigger the
143 * @ref showAboutApplication slot. See @ref showAboutApplication for more 144 * @ref showAboutApplication slot. See @ref showAboutApplication for more
144 * information. 145 * information.
145 * 146 *
146 * Example (adding a help menu to your application): 147 * Example (adding a help menu to your application):
147 * <pre> 148 * <pre>
148 * menuBar()->insertItem( i18n("&Help"), customHelpMenu() ); 149 * menuBar()->insertItem( i18n("&Help"), customHelpMenu() );
149 * </pre> 150 * </pre>
150 * 151 *
151 * @param showWhatsThis Set this to @p false if you do not want to include 152 * @param showWhatsThis Set this to @p false if you do not want to include
152 * the "What's This" menu entry. 153 * the "What's This" menu entry.
153 * 154 *
154 * @return A standard help menu. 155 * @return A standard help menu.
155 */ 156 */
156//US KPopupMenu* customHelpMenu( bool showWhatsThis = TRUE ); 157//US KPopupMenu* customHelpMenu( bool showWhatsThis = TRUE );
157 158
158 /** 159 /**
159 * @sect Session Management 160 * @sect Session Management
160 * 161 *
161 * Try to restore the toplevel widget as defined by the number (1..X). 162 * Try to restore the toplevel widget as defined by the number (1..X).
162 * 163 *
163 * If the session did not contain so high a number, the configuration 164 * If the session did not contain so high a number, the configuration
164 * is not changed and @p false returned. 165 * is not changed and @p false returned.
165 * 166 *
166 * That means clients could simply do the following: 167 * That means clients could simply do the following:
167 * <pre> 168 * <pre>
168 * if (kapp->isRestored()){ 169 * if (kapp->isRestored()){
169 * int n = 1; 170 * int n = 1;
170 * while (KMainWindow::canBeRestored(n)){ 171 * while (KMainWindow::canBeRestored(n)){
171 * (new childMW)->restore(n); 172 * (new childMW)->restore(n);
172 * n++; 173 * n++;
173 * } 174 * }
174 * } else { 175 * } else {
175 * // create default application as usual 176 * // create default application as usual
176 * } 177 * }
177 * </pre> 178 * </pre>
178 * Note that @ref QWidget::show() is called implicitly in restore. 179 * Note that @ref QWidget::show() is called implicitly in restore.
179 * 180 *
180 * With this you can easily restore all toplevel windows of your 181 * With this you can easily restore all toplevel windows of your
181 * application. 182 * application.
182 * 183 *
183 * If your application uses different kinds of toplevel 184 * If your application uses different kinds of toplevel
184 * windows, then you can use @ref KMainWindow::classNameOfToplevel(n) 185 * windows, then you can use @ref KMainWindow::classNameOfToplevel(n)
185 * to determine the exact type before calling the childMW 186 * to determine the exact type before calling the childMW
186 * constructor in the example from above. 187 * constructor in the example from above.
187 * 188 *
188 * If your client has only one kind of toplevel widgets (which 189 * If your client has only one kind of toplevel widgets (which
189 * should be pretty usual) then you should use the RESTORE-macro 190 * should be pretty usual) then you should use the RESTORE-macro
190 * for backwards compatibility with 3.1 and 3.0 branches: 191 * for backwards compatibility with 3.1 and 3.0 branches:
191 * 192 *
192 * <pre> 193 * <pre>
193 * if (kapp->isRestored()) 194 * if (kapp->isRestored())
194 * RESTORE(childMW) 195 * RESTORE(childMW)
195 * else { 196 * else {
196 * // create default application as usual 197 * // create default application as usual
197 * } 198 * }
198 * </pre> 199 * </pre>
199 * 200 *
200 * The macro expands to the term above but is easier to use and 201 * The macro expands to the term above but is easier to use and
201 * less code to write. 202 * less code to write.
202 * 203 *
203 * For new code or if you have more than one kind of toplevel 204 * For new code or if you have more than one kind of toplevel
204 * widget (each derived from @ref KMainWindow, of course), you can 205 * widget (each derived from @ref KMainWindow, of course), you can
205 * use the templated @ref kRestoreMainWindows global functions: 206 * use the templated @ref kRestoreMainWindows global functions:
206 * 207 *
207 * <pre> 208 * <pre>
208 * if (kapp->isRestored()) 209 * if (kapp->isRestored())
209 * kRestoreMainWindows< childMW1, childMW2, childMW3 >(); 210 * kRestoreMainWindows< childMW1, childMW2, childMW3 >();
210 * else { 211 * else {
211 * // create default application as usual 212 * // create default application as usual
212 * } 213 * }
213 * </pre> 214 * </pre>
214 * 215 *
215 * Currently, these functions are provided for up to three 216 * Currently, these functions are provided for up to three
216 * template arguments. If you need more, tell us. To help you in 217 * template arguments. If you need more, tell us. To help you in
217 * deciding whether or not you can use @ref kRestoreMainWindows, a 218 * deciding whether or not you can use @ref kRestoreMainWindows, a
218 * define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS is provided. 219 * define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS is provided.
219 * 220 *
220 * @see restore() 221 * @see restore()
221 * @see classNameOfToplevel() 222 * @see classNameOfToplevel()
222 * 223 *
223 **/ 224 **/
224 static bool canBeRestored( int number ); 225 static bool canBeRestored( int number );
225 226
226 /** 227 /**
227 * Returns the @ref className() of the @p number of the toplevel window which 228 * Returns the @ref className() of the @p number of the toplevel window which
228 * should be restored. 229 * should be restored.
229 * 230 *
230 * This is only useful if your application uses 231 * This is only useful if your application uses
231 * different kinds of toplevel windows. 232 * different kinds of toplevel windows.
232 */ 233 */
233 static const QString classNameOfToplevel( int number ); 234 static const QString classNameOfToplevel( int number );
234 235
235 /** 236 /**
236 * Restore the session specified by @p number. 237 * Restore the session specified by @p number.
237 * 238 *
238 * Returns @p false if this 239 * Returns @p false if this
239 * fails, otherwise returns @p true and shows the window. 240 * fails, otherwise returns @p true and shows the window.
240 * You should call @ref canBeRestored() first. 241 * You should call @ref canBeRestored() first.
241 * If @p show is true (default), this widget will be shown automatically. 242 * If @p show is true (default), this widget will be shown automatically.
242 */ 243 */
243 bool restore( int number, bool show = TRUE ); 244 bool restore( int number, bool show = TRUE );
244 245
245//US virtual KXMLGUIFactory *guiFactory(); 246//US virtual KXMLGUIFactory *guiFactory();
246 247
247 /** 248 /**
248 * Create a GUI given a local XML file. 249 * Create a GUI given a local XML file.
249 * 250 *
250 * If @p xmlfile is NULL, 251 * If @p xmlfile is NULL,
251 * then it will try to construct a local XML filename like 252 * then it will try to construct a local XML filename like
252 * appnameui.rc where 'appname' is your app's name. If that file 253 * appnameui.rc where 'appname' is your app's name. If that file
253 * does not exist, then the XML UI code will only use the global 254 * does not exist, then the XML UI code will only use the global
254 * (standard) XML file for the layout purposes. 255 * (standard) XML file for the layout purposes.
255 * 256 *
256 * Note that when passing true for the conserveMemory argument subsequent 257 * Note that when passing true for the conserveMemory argument subsequent
257 * calls to guiFactory()->addClient/removeClient may not work as expected. 258 * calls to guiFactory()->addClient/removeClient may not work as expected.
258 * Also retrieving references to containers like popup menus or toolbars using 259 * Also retrieving references to containers like popup menus or toolbars using
259 * the container method will not work. 260 * the container method will not work.
260 * 261 *
261 * @param xmlfile The local xmlfile (relative or absolute) 262 * @param xmlfile The local xmlfile (relative or absolute)
262 * @param _conserveMemory Specify whether createGUI() should call 263 * @param _conserveMemory Specify whether createGUI() should call
263 * @ref KXMLGuiClient::conserveMemory() to free all memory 264 * @ref KXMLGuiClient::conserveMemory() to free all memory
264 * allocated by the @ref QDomDocument and by the KXMLGUIFactory. 265 * allocated by the @ref QDomDocument and by the KXMLGUIFactory.
265 */ 266 */
266 void createGUI( const QString &xmlfile = QString::null, bool _conserveMemory = TRUE ); 267 void createGUI( const QString &xmlfile = QString::null, bool _conserveMemory = TRUE );
267 268
268 /** 269 /**
269 * Enables the build of a standard help menu when calling createGUI(). 270 * Enables the build of a standard help menu when calling createGUI().
270 * 271 *
271 * The default behavior is to build one, you must call this function 272 * The default behavior is to build one, you must call this function
272 * to disable it 273 * to disable it
273 */ 274 */
274 void setHelpMenuEnabled(bool showHelpMenu = true); 275 void setHelpMenuEnabled(bool showHelpMenu = true);
275 276
276 /** 277 /**
277 * Return @p true when the help menu is enabled 278 * Return @p true when the help menu is enabled
278 */ 279 */
279 bool isHelpMenuEnabled(); 280 bool isHelpMenuEnabled();
280 281
281 282
282 /** 283 /**
283 * Returns true, if there is a menubar 284 * Returns true, if there is a menubar
284 * @since 3.1 285 * @since 3.1
285 */ 286 */
286 bool hasMenuBar(); 287 bool hasMenuBar();
287 288
288 /** 289 /**
289 * Returns a pointer to the menu bar. 290 * Returns a pointer to the menu bar.
290 * 291 *
291 * If there is no menu bar yet one will be created. 292 * If there is no menu bar yet one will be created.
292 **/ 293 **/
293//US KMenuBar *menuBar(); 294//US KMenuBar *menuBar();
294 QMenuBar *menuBar(); 295 QMenuBar *menuBar();
295 296
296 /** 297 /**
297 * Returns a pointer to the status bar. 298 * Returns a pointer to the status bar.
298 * 299 *
299 * If there is no 300 * If there is no
300 * status bar yet one will be created. 301 * status bar yet one will be created.
301 */ 302 */
302//US KStatusBar *statusBar(); 303//US KStatusBar *statusBar();
303 QStatusBar *statusBar(); 304 QStatusBar *statusBar();
304 305
305 /** 306 /**
306 * List of members of KMainWindow class. 307 * List of members of KMainWindow class.
307 */ 308 */
308//US static QPtrList<KMainWindow>* memberList; 309//US static QPtrList<KMainWindow>* memberList;
309 310
310 /** 311 /**
311 * Returns a pointer to the toolbar with the specified name. 312 * Returns a pointer to the toolbar with the specified name.
312 * This refers to toolbars created dynamically from the XML UI 313 * This refers to toolbars created dynamically from the XML UI
313 * framework. If the toolbar does not exist one will be created. 314 * framework. If the toolbar does not exist one will be created.
314 * 315 *
315 * @param name The internal name of the toolbar. If no name is 316 * @param name The internal name of the toolbar. If no name is
316 * specified "mainToolBar" is assumed. 317 * specified "mainToolBar" is assumed.
317 * 318 *
318 * @return A pointer to the toolbar 319 * @return A pointer to the toolbar
319 **/ 320 **/
320 KToolBar *toolBar( const char *name=0 ); 321 KToolBar *toolBar( const char *name=0 );
321 // method for getting rid of KDE-Crap 322 // method for getting rid of KDE-Crap
322 QToolBar *tBar( ); 323 QToolBar *tBar( );
323 324
324 /** 325 /**
325 * @return An iterator over the list of all toolbars for this window. 326 * @return An iterator over the list of all toolbars for this window.
326 */ 327 */
327 QPtrListIterator<KToolBar> toolBarIterator(); 328 QPtrListIterator<KToolBar> toolBarIterator();
328 329
329 /** 330 /**
330 * @return A KAccel instance bound to this mainwindow. Used automatically 331 * @return A KAccel instance bound to this mainwindow. Used automatically
331 * by KAction to make keybindings work in all cases. 332 * by KAction to make keybindings work in all cases.
332 */ 333 */
333 KAccel *accel(); 334 KAccel *accel();
334 335
335 void setFrameBorderWidth( int ) {} 336 void setFrameBorderWidth( int ) {}
336 337
337 /** 338 /**
338 * Call this to enable "auto-save" of toolbar/menubar/statusbar settings 339 * Call this to enable "auto-save" of toolbar/menubar/statusbar settings
339 * (and optionally window size). 340 * (and optionally window size).
340 * If the *bars were moved around/shown/hidden when the window is closed, 341 * If the *bars were moved around/shown/hidden when the window is closed,
341 * saveMainWindowSettings( KGlobal::config(), groupName ) will be called. 342 * saveMainWindowSettings( KGlobal::config(), groupName ) will be called.
342 * 343 *
343 * @param groupName a name that identifies this "type of window". 344 * @param groupName a name that identifies this "type of window".
344 * You can have several types of window in the same application. 345 * You can have several types of window in the same application.
345 * 346 *
346 * @param saveWindowSize set it to true to include the window size 347 * @param saveWindowSize set it to true to include the window size
347 * when saving. 348 * when saving.
348 * 349 *
349 * Typically, you will call setAutoSaveSettings() in your 350 * Typically, you will call setAutoSaveSettings() in your
350 * KMainWindow-inherited class constructor, and it will take care 351 * KMainWindow-inherited class constructor, and it will take care
351 * of restoring and saving automatically. Make sure you call this 352 * of restoring and saving automatically. Make sure you call this
352 * _after all_ your *bars have been created. 353 * _after all_ your *bars have been created.
353 */ 354 */
354 void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"), 355 void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"),
355 bool saveWindowSize = true ); 356 bool saveWindowSize = true );
356 357
357 /** 358 /**
358 * Disable the auto-save-settings feature. 359 * Disable the auto-save-settings feature.
359 * You don't normally need to call this, ever. 360 * You don't normally need to call this, ever.
360 */ 361 */
361 void resetAutoSaveSettings(); 362 void resetAutoSaveSettings();
362 363
363 /** 364 /**
364 * @return the current autosave setting, i.e. true if setAutoSaveSettings() was called, 365 * @return the current autosave setting, i.e. true if setAutoSaveSettings() was called,
365 * false by default or if resetAutoSaveSettings() was called. 366 * false by default or if resetAutoSaveSettings() was called.
366 * @since 3.1 367 * @since 3.1
367 */ 368 */
368 bool autoSaveSettings() const; 369 bool autoSaveSettings() const;
369 370
370 /** 371 /**
371 * @return the group used for setting-autosaving. 372 * @return the group used for setting-autosaving.
372 * Only meaningful if setAutoSaveSettings() was called. 373 * Only meaningful if setAutoSaveSettings() was called.
373 * This can be useful for forcing a save or an apply, e.g. before and after 374 * This can be useful for forcing a save or an apply, e.g. before and after
374 * using KEditToolbar. 375 * using KEditToolbar.
375 * @since 3.1 376 * @since 3.1
376 */ 377 */
377 QString autoSaveGroup() const; 378 QString autoSaveGroup() const;
378 379
379 /** 380 /**
380 * Read settings for statusbar, menubar and toolbar from their respective 381 * Read settings for statusbar, menubar and toolbar from their respective
381 * groups in the config file and apply them. 382 * groups in the config file and apply them.
382 * 383 *
383 * @param config Config file to read the settings from. 384 * @param config Config file to read the settings from.
384 * @param groupName Group name to use. If not specified, the last used 385 * @param groupName Group name to use. If not specified, the last used
385 * group name is used. 386 * group name is used.
386 */ 387 */
387 void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null); 388 void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null);
388 389
389 /** 390 /**
390 * Save settings for statusbar, menubar and toolbar to their respective 391 * Save settings for statusbar, menubar and toolbar to their respective
391 * groups in the config file @p config. 392 * groups in the config file @p config.
392 * 393 *
393 * @param config Config file to save the settings to. 394 * @param config Config file to save the settings to.
394 * @param groupName Group name to use. If not specified, the last used 395 * @param groupName Group name to use. If not specified, the last used
395 * group name is used 396 * group name is used
396 */ 397 */
397 void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null); 398 void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null);
398 399
399 /** 400 /**
400 * Sets whether KMainWindow should provide a menu that allows showing/hiding 401 * Sets whether KMainWindow should provide a menu that allows showing/hiding
401 * the available toolbars ( using @ref KToggleToolBarAction ) . In case there 402 * the available toolbars ( using @ref KToggleToolBarAction ) . In case there
402 * is only one toolbar configured a simple 'Show <toolbar name here>' menu item 403 * is only one toolbar configured a simple 'Show <toolbar name here>' menu item
403 * is shown. 404 * is shown.
404 * 405 *
405 * The menu / menu item is implemented using xmlgui. It will be inserted in your 406 * The menu / menu item is implemented using xmlgui. It will be inserted in your
406 * menu structure in the 'Settings' menu. 407 * menu structure in the 'Settings' menu.
407 * 408 *
408 * If your application uses a non-standard xmlgui resource file then you can 409 * If your application uses a non-standard xmlgui resource file then you can
409 * specify the exact position of the menu / menu item by adding a 410 * specify the exact position of the menu / menu item by adding a
410 * &lt;Merge name="StandardToolBarMenuHandler" /&gt; 411 * &lt;Merge name="StandardToolBarMenuHandler" /&gt;
411 * line to the settings menu section of your resource file ( usually appname.rc ). 412 * line to the settings menu section of your resource file ( usually appname.rc ).
412 * 413 *
413 * Note that you should enable this feature before calling createGUI() ( or similar ) . 414 * Note that you should enable this feature before calling createGUI() ( or similar ) .
414 * You enable/disable it anytime if you pass false to the conserveMemory argument of createGUI. 415 * You enable/disable it anytime if you pass false to the conserveMemory argument of createGUI.
415 * @since 3.1 416 * @since 3.1
416 */ 417 */
417 void setStandardToolBarMenuEnabled( bool enable ); 418 void setStandardToolBarMenuEnabled( bool enable );
418 /// @since 3.1 419 /// @since 3.1
419 bool isStandardToolBarMenuEnabled() const; 420 bool isStandardToolBarMenuEnabled() const;
420 421
421 422
422 /** 423 /**
423 * Sets whether KMainWindow should provide a menu that allows showing/hiding 424 * Sets whether KMainWindow should provide a menu that allows showing/hiding
424 * of the statusbar ( using @ref KToggleStatusBarAction ). 425 * of the statusbar ( using @ref KToggleStatusBarAction ).
425 * 426 *
426 * The menu / menu item is implemented using xmlgui. It will be inserted 427 * The menu / menu item is implemented using xmlgui. It will be inserted
427 * in your menu structure in the 'Settings' menu. 428 * in your menu structure in the 'Settings' menu.
428 * 429 *
429 * Note that you should enable this feature before calling createGUI() 430 * Note that you should enable this feature before calling createGUI()
430 * ( or similar ). 431 * ( or similar ).
431 * 432 *
432 * If an application maintains the action on its own (i.e. never calls 433 * If an application maintains the action on its own (i.e. never calls
433 * this function) a connection needs to be made to let KMainWindow 434 * this function) a connection needs to be made to let KMainWindow
434 * know when that status (hidden/shown) of the statusbar has changed. 435 * know when that status (hidden/shown) of the statusbar has changed.
435 * For example: 436 * For example:
436 * connect(action, SIGNAL(activated()), 437 * connect(action, SIGNAL(activated()),
437 * kmainwindow, SLOT(setSettingsDirty())); 438 * kmainwindow, SLOT(setSettingsDirty()));
438 * Otherwise the status (hidden/show) of the statusbar might not be saved 439 * Otherwise the status (hidden/show) of the statusbar might not be saved
439 * by KMainWindow. 440 * by KMainWindow.
440 * @since 3.2 441 * @since 3.2
441 */ 442 */
442 void createStandardStatusBarAction(); 443 void createStandardStatusBarAction();
443 444
444 445
445 /** 446 /**
446 * Returns a pointer to the mainwindows action responsible for the toolbars menu 447 * Returns a pointer to the mainwindows action responsible for the toolbars menu
447 * @since 3.1 448 * @since 3.1
448 */ 449 */
449 KAction *toolBarMenuAction(); 450 KAction *toolBarMenuAction();
450 451
451 // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; 452 // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI;
452 /// @since 3.1 453 /// @since 3.1
453 virtual void finalizeGUI( KXMLGUIClient *client ); 454 virtual void finalizeGUI( KXMLGUIClient *client );
454 455
455 /** 456 /**
456 * @internal 457 * @internal
457 */ 458 */
458 void finalizeGUI( bool force ); 459 void finalizeGUI( bool force );
459 460
460 /** 461 /**
461 * @return true if a -geometry argument was given on the command line, 462 * @return true if a -geometry argument was given on the command line,
462 * and this is the first window created (the one on which this option applies) 463 * and this is the first window created (the one on which this option applies)
463 */ 464 */
464 bool initialGeometrySet() const; 465 bool initialGeometrySet() const;
465 466
466 /** 467 /**
467 * @internal 468 * @internal
468 * Used from Konqueror when reusing the main window. 469 * Used from Konqueror when reusing the main window.
469 */ 470 */
470 void ignoreInitialGeometry(); 471 void ignoreInitialGeometry();
471 472
472 /** 473 /**
473 * @return the size the mainwindow should have so that the central 474 * @return the size the mainwindow should have so that the central
474 * widget will be of @p size. 475 * widget will be of @p size.
475 */ 476 */
476 QSize sizeForCentralWidgetSize(QSize size); 477 QSize sizeForCentralWidgetSize(QSize size);
477 478
478public slots: 479public slots:
479 /** 480 /**
480 * Makes a KDE compliant caption. 481 * Makes a KDE compliant caption.
diff --git a/pwmanager/pwmanager/getmasterpwwnd_emb.cpp b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
index 8404c3e..678f05f 100644
--- a/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
+++ b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
@@ -1,208 +1,208 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#include "getmasterpwwnd_emb.h" 26#include "getmasterpwwnd_emb.h"
27 27
28#include "klocale.h" 28#include "klocale.h"
29 29
30/* 30/*
31#include <qvariant.h> 31#include <qvariant.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qlineedit.h> 34#include <qlineedit.h>
35#include <qlayout.h> 35#include <qlayout.h>
36#include <qtooltip.h> 36#include <qtooltip.h>
37#include <qwhatsthis.h> 37#include <qwhatsthis.h>
38*/ 38*/
39 39
40#include <qwidget.h> 40#include <qwidget.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qlineedit.h> 43#include <qlineedit.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qapplication.h> 45#include <qapplication.h>
46 46
47/* 47/*
48 * Constructs a getMasterPwWnd as a child of 'parent', with the 48 * Constructs a getMasterPwWnd as a child of 'parent', with the
49 * name 'name' 49 * name 'name'
50 */ 50 */
51getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name) 51getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name)
52 : KDialogBase( KDialogBase::Plain, i18n( "Master-password" ), 52 : KDialogBase( KDialogBase::Plain, i18n( "Master-password" ),
53 KDialogBase::Ok | KDialogBase::Cancel, 53 KDialogBase::Ok | KDialogBase::Cancel,
54 KDialogBase::Ok, parent, name, true ) 54 KDialogBase::Ok, parent, name, true )
55{ 55{
56 QWidget *page = plainPage(); 56 QWidget *page = plainPage();
57 QVBoxLayout *pageLayout = new QVBoxLayout( page ); 57 QVBoxLayout *pageLayout = new QVBoxLayout( page );
58 58
59 pwLineEdit = new QLineEdit( page, "pwLineEdit" ); 59 pwLineEdit = new QLineEdit( page, "pwLineEdit" );
60 pwLineEdit->setEchoMode( QLineEdit::Password ); 60 pwLineEdit->setEchoMode( QLineEdit::Password );
61 61
62 QLabel* textLabel1 = new QLabel( pwLineEdit, i18n("Please enter the master-password:"), page, "textLabel1" ); 62 QLabel* textLabel1 = new QLabel( pwLineEdit, i18n("Please enter the master-password:"), page, "textLabel1" );
63 textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) ); 63 textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
64 pageLayout->addWidget(textLabel1); 64 pageLayout->addWidget(textLabel1);
65 pageLayout->addWidget(pwLineEdit); 65 pageLayout->addWidget(pwLineEdit);
66 66
67 QWidget* numberBox = new QWidget( page ); 67 QWidget* numberBox = new QWidget( page );
68#ifndef DESKTOP_VERSION 68#ifndef DESKTOP_VERSION
69 if ( QApplication::desktop()->width() > 320 ) { 69 if ( QApplication::desktop()->width() > 320 ) {
70 numberBox->setFixedHeight(250); 70 numberBox->setFixedHeight(250);
71 numberBox->setFixedWidth(200); 71 numberBox->setFixedWidth(200);
72 } 72 }
73 else{ 73 else{
74 numberBox->setFixedHeight(150); 74 numberBox->setFixedHeight(150);
75 numberBox->setFixedWidth(150); 75 numberBox->setFixedWidth(150);
76 } 76 }
77#endif 77#endif
78 78
79 QGridLayout* numberLayout = new QGridLayout( numberBox, 4, 3 ); 79 QGridLayout* numberLayout = new QGridLayout( numberBox, 4, 3 );
80 numberLayout->setMargin( 0 ); 80 numberLayout->setMargin( 0 );
81 numberLayout->setSpacing( 0 ); 81 numberLayout->setSpacing( 0 );
82 82
83 QPushButton* p1 = new QPushButton( i18n("1"), numberBox ); 83 QPushButton* p1 = new QPushButton( i18n("1"), numberBox );
84 numberLayout->addWidget( p1, 0, 0 ); 84 numberLayout->addWidget( p1, 0, 0 );
85 QPushButton* p2 = new QPushButton( i18n("2"), numberBox ); 85 QPushButton* p2 = new QPushButton( i18n("2"), numberBox );
86 numberLayout->addWidget( p2, 0, 1 ); 86 numberLayout->addWidget( p2, 0, 1 );
87 QPushButton* p3 = new QPushButton( i18n("3"), numberBox ); 87 QPushButton* p3 = new QPushButton( i18n("3"), numberBox );
88 numberLayout->addWidget( p3, 0, 2 ); 88 numberLayout->addWidget( p3, 0, 2 );
89 QPushButton* p4 = new QPushButton( i18n("4"), numberBox ); 89 QPushButton* p4 = new QPushButton( i18n("4"), numberBox );
90 numberLayout->addWidget( p4, 1, 0 ); 90 numberLayout->addWidget( p4, 1, 0 );
91 QPushButton* p5 = new QPushButton( i18n("5"), numberBox ); 91 QPushButton* p5 = new QPushButton( i18n("5"), numberBox );
92 numberLayout->addWidget( p5, 1, 1 ); 92 numberLayout->addWidget( p5, 1, 1 );
93 QPushButton* p6 = new QPushButton( i18n("6"), numberBox ); 93 QPushButton* p6 = new QPushButton( i18n("6"), numberBox );
94 numberLayout->addWidget( p6, 1, 2 ); 94 numberLayout->addWidget( p6, 1, 2 );
95 QPushButton* p7 = new QPushButton( i18n("7"), numberBox ); 95 QPushButton* p7 = new QPushButton( i18n("7"), numberBox );
96 numberLayout->addWidget( p7, 2, 0 ); 96 numberLayout->addWidget( p7, 2, 0 );
97 QPushButton* p8 = new QPushButton( i18n("8"), numberBox ); 97 QPushButton* p8 = new QPushButton( i18n("8"), numberBox );
98 numberLayout->addWidget( p8, 2, 1 ); 98 numberLayout->addWidget( p8, 2, 1 );
99 QPushButton* p9 = new QPushButton( i18n("9"), numberBox ); 99 QPushButton* p9 = new QPushButton( i18n("9"), numberBox );
100 numberLayout->addWidget( p9, 2, 2 ); 100 numberLayout->addWidget( p9, 2, 2 );
101 QPushButton* clear = new QPushButton( i18n("x"), numberBox ); 101 QPushButton* clear = new QPushButton( i18n("x"), numberBox );
102 numberLayout->addWidget( clear, 3, 0 ); 102 numberLayout->addWidget( clear, 3, 0 );
103 QPushButton* p0 = new QPushButton( i18n("0"), numberBox ); 103 QPushButton* p0 = new QPushButton( i18n("0"), numberBox );
104 numberLayout->addWidget( p0, 3, 1 ); 104 numberLayout->addWidget( p0, 3, 1 );
105 QPushButton* backspace = new QPushButton( i18n("-"), numberBox ); 105 QPushButton* backspace = new QPushButton( i18n("-"), numberBox );
106 numberLayout->addWidget( backspace, 3, 2 ); 106 numberLayout->addWidget( backspace, 3, 2 );
107 107
108 108
109 pageLayout->addWidget(numberBox); 109 pageLayout->addWidget(numberBox);
110#ifdef DESKTOP_VERSION 110#ifdef DESKTOP_VERSION
111 resize( sizeHint() ); 111 resize( sizeHint() );
112#else 112#else
113 resize( 200,sizeHint().height() ); 113 resize( 200,sizeHint().height() );
114#endif 114#endif
115 115
116 connect( p0, SIGNAL( clicked() ), this, SLOT( add0() ) ); 116 connect( p0, SIGNAL( clicked() ), this, SLOT( add0() ) );
117 connect( p1, SIGNAL( clicked() ), this, SLOT( add1() ) ); 117 connect( p1, SIGNAL( clicked() ), this, SLOT( add1() ) );
118 connect( p2, SIGNAL( clicked() ), this, SLOT( add2() ) ); 118 connect( p2, SIGNAL( clicked() ), this, SLOT( add2() ) );
119 connect( p3, SIGNAL( clicked() ), this, SLOT( add3() ) ); 119 connect( p3, SIGNAL( clicked() ), this, SLOT( add3() ) );
120 connect( p4, SIGNAL( clicked() ), this, SLOT( add4() ) ); 120 connect( p4, SIGNAL( clicked() ), this, SLOT( add4() ) );
121 connect( p5, SIGNAL( clicked() ), this, SLOT( add5() ) ); 121 connect( p5, SIGNAL( clicked() ), this, SLOT( add5() ) );
122 connect( p6, SIGNAL( clicked() ), this, SLOT( add6() ) ); 122 connect( p6, SIGNAL( clicked() ), this, SLOT( add6() ) );
123 connect( p7, SIGNAL( clicked() ), this, SLOT( add7() ) ); 123 connect( p7, SIGNAL( clicked() ), this, SLOT( add7() ) );
124 connect( p8, SIGNAL( clicked() ), this, SLOT( add8() ) ); 124 connect( p8, SIGNAL( clicked() ), this, SLOT( add8() ) );
125 connect( p9, SIGNAL( clicked() ), this, SLOT( add9() ) ); 125 connect( p9, SIGNAL( clicked() ), this, SLOT( add9() ) );
126 connect( backspace, SIGNAL( clicked() ), this, SLOT( backspace() ) ); 126 connect( backspace, SIGNAL( clicked() ), this, SLOT( backspace() ) );
127 connect( clear, SIGNAL( clicked() ), this, SLOT( clear() ) ); 127 connect( clear, SIGNAL( clicked() ), this, SLOT( clear() ) );
128 128
129 129 pwLineEdit->setFocus();
130 130
131} 131}
132 132
133/* 133/*
134 * Destroys the object and frees any allocated resources 134 * Destroys the object and frees any allocated resources
135 */ 135 */
136getMasterPwWnd::~getMasterPwWnd() 136getMasterPwWnd::~getMasterPwWnd()
137{ 137{
138 // no need to delete child widgets, Qt does it all for us 138 // no need to delete child widgets, Qt does it all for us
139} 139}
140 140
141void getMasterPwWnd::okButton_slot() 141void getMasterPwWnd::okButton_slot()
142{ 142{
143 qWarning( "getMasterPwWnd::okButton_slot(): Not implemented yet" ); 143 qWarning( "getMasterPwWnd::okButton_slot(): Not implemented yet" );
144} 144}
145 145
146void getMasterPwWnd::cancelButton_slot() 146void getMasterPwWnd::cancelButton_slot()
147{ 147{
148 qWarning( "getMasterPwWnd::cancelButton_slot(): Not implemented yet" ); 148 qWarning( "getMasterPwWnd::cancelButton_slot(): Not implemented yet" );
149} 149}
150 150
151void getMasterPwWnd::add0() 151void getMasterPwWnd::add0()
152{ 152{
153 addCharacter("0"); 153 addCharacter("0");
154} 154}
155void getMasterPwWnd::add1() 155void getMasterPwWnd::add1()
156{ 156{
157 addCharacter("1"); 157 addCharacter("1");
158} 158}
159void getMasterPwWnd::add2() 159void getMasterPwWnd::add2()
160{ 160{
161 addCharacter("2"); 161 addCharacter("2");
162} 162}
163void getMasterPwWnd::add3() 163void getMasterPwWnd::add3()
164{ 164{
165 addCharacter("3"); 165 addCharacter("3");
166} 166}
167void getMasterPwWnd::add4() 167void getMasterPwWnd::add4()
168{ 168{
169 addCharacter("4"); 169 addCharacter("4");
170} 170}
171void getMasterPwWnd::add5() 171void getMasterPwWnd::add5()
172{ 172{
173 addCharacter("5"); 173 addCharacter("5");
174} 174}
175void getMasterPwWnd::add6() 175void getMasterPwWnd::add6()
176{ 176{
177 addCharacter("6"); 177 addCharacter("6");
178} 178}
179void getMasterPwWnd::add7() 179void getMasterPwWnd::add7()
180{ 180{
181 addCharacter("7"); 181 addCharacter("7");
182} 182}
183void getMasterPwWnd::add8() 183void getMasterPwWnd::add8()
184{ 184{
185 addCharacter("8"); 185 addCharacter("8");
186} 186}
187void getMasterPwWnd::add9() 187void getMasterPwWnd::add9()
188{ 188{
189 addCharacter("9"); 189 addCharacter("9");
190} 190}
191void getMasterPwWnd::backspace() 191void getMasterPwWnd::backspace()
192{ 192{
193 QString old = pwLineEdit->text(); 193 QString old = pwLineEdit->text();
194 old.truncate(old.length()-1); 194 old.truncate(old.length()-1);
195 pwLineEdit->setText(old); 195 pwLineEdit->setText(old);
196} 196}
197 197
198void getMasterPwWnd::clear() 198void getMasterPwWnd::clear()
199{ 199{
200 pwLineEdit->setText(""); 200 pwLineEdit->setText("");
201} 201}
202 202
203void getMasterPwWnd::addCharacter(const QString& s) 203void getMasterPwWnd::addCharacter(const QString& s)
204{ 204{
205 QString old = pwLineEdit->text(); 205 QString old = pwLineEdit->text();
206 pwLineEdit->setText(old + s); 206 pwLineEdit->setText(old + s);
207} 207}
208 208
diff --git a/pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp b/pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp
index 26b9708..a8696ea 100644
--- a/pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp
+++ b/pwmanager/pwmanager/kcmconfigs/pwmconfigwidget.cpp
@@ -1,351 +1,351 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qcombobox.h> 30#include <qcombobox.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qspinbox.h> 32#include <qspinbox.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qvbox.h> 35#include <qvbox.h>
36 36
37#include <kconfig.h> 37#include <kconfig.h>
38#include <kdebug.h> 38#include <kdebug.h>
39#include <kdialog.h> 39#include <kdialog.h>
40#include <klistview.h> 40#include <klistview.h>
41#include <klocale.h> 41#include <klocale.h>
42#include <kglobal.h> 42#include <kglobal.h>
43#include <kmessagebox.h> 43#include <kmessagebox.h>
44#include <kstandarddirs.h> 44#include <kstandarddirs.h>
45#include <kio/kfile/kurlrequester.h> 45#include <kio/kfile/kurlrequester.h>
46 46
47#include "pwmprefs.h" 47#include "pwmprefs.h"
48 48
49#include "pwmconfigwidget.h" 49#include "pwmconfigwidget.h"
50#include "pwmexception.h" 50#include "pwmexception.h"
51 51
52PWMConfigWidget::PWMConfigWidget(PWMPrefs *prefs, QWidget *parent, const char *name ) 52PWMConfigWidget::PWMConfigWidget(PWMPrefs *prefs, QWidget *parent, const char *name )
53 : KPrefsWidget(prefs, parent, name ) 53 : KPrefsWidget(prefs, parent, name )
54{ 54{
55 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 55 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
56 KDialog::spacingHint() ); 56 KDialog::spacingHint() );
57 57
58 QTabWidget *tabWidget = new QTabWidget( this ); 58 QTabWidget *tabWidget = new QTabWidget( this );
59 topLayout->addWidget( tabWidget ); 59 topLayout->addWidget( tabWidget );
60 60
61 // windowsStyle page 61 // windowsStyle page
62 ////////////////////////////////////////////////////// 62 //////////////////////////////////////////////////////
63 QWidget *windowStylePage = new QWidget( this ); 63 QWidget *windowStylePage = new QWidget( this );
64 QGridLayout *windowStyleLayout = new QGridLayout( windowStylePage, 3, 3); 64 QGridLayout *windowStyleLayout = new QGridLayout( windowStylePage, 3, 3);
65 65
66 int i = 0; 66 int i = 0;
67 KPrefsWidRadios * windowStyle = addWidRadios(i18n("Window-style:") ,&(prefs->mMainViewStyle), windowStylePage); 67 KPrefsWidRadios * windowStyle = addWidRadios(i18n("Window-style:") ,&(prefs->mMainViewStyle), windowStylePage);
68 windowStyle->addRadio(i18n("Category on top")); 68 windowStyle->addRadio(i18n("Category on top"));
69 windowStyle->addRadio(i18n("Category-list left/top")); 69 windowStyle->addRadio(i18n("Category-list left/top"));
70 windowStyleLayout->addMultiCellWidget( (QWidget*)windowStyle->groupBox(),i,i,0,2); 70 windowStyleLayout->addMultiCellWidget( (QWidget*)windowStyle->groupBox(),i,i,0,2);
71 ++i; 71 ++i;
72 72
73 QLabel* lab = new QLabel(i18n("<b>Font for Password entries:</b>"), windowStylePage); 73 QLabel* lab = new QLabel(i18n("<b>Font for Password entries:</b>"), windowStylePage);
74 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2); 74 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2);
75 75
76 76
77 ++i; 77 ++i;
78 78
79 KPrefsWidFont *selEntrFont = 79 KPrefsWidFont *selEntrFont =
80 addWidFont(i18n("Password"),i18n("Font:"), 80 addWidFont(i18n("Password"),i18n("Font:"),
81 &(prefs->mEntryFont),windowStylePage); 81 &(prefs->mEntryFont),windowStylePage);
82 windowStyleLayout->addWidget(selEntrFont->label(),i,0); 82 windowStyleLayout->addWidget(selEntrFont->label(),i,0);
83 windowStyleLayout->addWidget(selEntrFont->preview(),i,1); 83 windowStyleLayout->addWidget(selEntrFont->preview(),i,1);
84 windowStyleLayout->addWidget(selEntrFont->button(),i,2); 84 windowStyleLayout->addWidget(selEntrFont->button(),i,2);
85 ++i; 85 ++i;
86 lab = new QLabel(i18n(""), windowStylePage); 86 lab = new QLabel(i18n(""), windowStylePage);
87 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2); 87 windowStyleLayout->addMultiCellWidget( lab,i,i,0,2);
88 88
89 // File page 89 // File page
90 ////////////////////////////////////////////////////// 90 //////////////////////////////////////////////////////
91 QWidget *filePage = new QWidget( this ); 91 QWidget *filePage = new QWidget( this );
92 QGridLayout *fileLayout = new QGridLayout( filePage, 3, 2); 92 QGridLayout *fileLayout = new QGridLayout( filePage, 3, 2);
93 93
94 i = 0; 94 i = 0;
95 QLabel* kcfg_compression_label = new QLabel(i18n("Compression:"), filePage); 95 QLabel* kcfg_compression_label = new QLabel(i18n("Compression:"), filePage);
96 fileLayout->addWidget(kcfg_compression_label,i,0); 96 fileLayout->addWidget(kcfg_compression_label,i,0);
97 kcfg_compression = new QComboBox(filePage, "kcfg_compression"); 97 kcfg_compression = new QComboBox(filePage, "kcfg_compression");
98 kcfg_compression->insertItem(i18n("None")); 98 kcfg_compression->insertItem(i18n("None"));
99 kcfg_compression->insertItem(i18n("gzip")); 99 kcfg_compression->insertItem(i18n("gzip"));
100 //US not yet supported: kcfg_compression->insertItem(i18n("bzip2")); 100 //US not yet supported: kcfg_compression->insertItem(i18n("bzip2"));
101 fileLayout->addWidget( kcfg_compression,i,1); 101 fileLayout->addWidget( kcfg_compression,i,1);
102 ++i; 102 ++i;
103 103
104 QLabel* kcfg_crypt_label = new QLabel(i18n("Encryption:"), filePage); 104 QLabel* kcfg_crypt_label = new QLabel(i18n("Encryption:"), filePage);
105 fileLayout->addWidget(kcfg_crypt_label,i,0); 105 fileLayout->addWidget(kcfg_crypt_label,i,0);
106 kcfg_cryptAlgo = new QComboBox(filePage, "kcfg_cryptAlgo"); 106 kcfg_cryptAlgo = new QComboBox(filePage, "kcfg_cryptAlgo");
107 kcfg_cryptAlgo->insertItem(i18n("Blowfish (128 bit)")); 107 kcfg_cryptAlgo->insertItem(i18n("Blowfish (128 bit)"));
108#ifdef CONFIG_PWMANAGER_GCRY 108#ifdef CONFIG_PWMANAGER_GCRY
109 kcfg_cryptAlgo->insertItem(i18n("AES-128, Rijndael (128 bit)")); 109 kcfg_cryptAlgo->insertItem(i18n("AES-128, Rijndael (128 bit)"));
110 kcfg_cryptAlgo->insertItem(i18n("AES-192, Rijndael (192 bit)")); 110 kcfg_cryptAlgo->insertItem(i18n("AES-192, Rijndael (192 bit)"));
111 kcfg_cryptAlgo->insertItem(i18n("AES-256, Rijndael (256 bit)")); 111 kcfg_cryptAlgo->insertItem(i18n("AES-256, Rijndael (256 bit)"));
112 kcfg_cryptAlgo->insertItem(i18n("Triple-DES (168 bit)")); 112 kcfg_cryptAlgo->insertItem(i18n("Triple-DES (168 bit)"));
113 kcfg_cryptAlgo->insertItem(i18n("Twofish (256 bit)")); 113 kcfg_cryptAlgo->insertItem(i18n("Twofish (256 bit)"));
114 kcfg_cryptAlgo->insertItem(i18n("Twofish-128 (128 bit)")); 114 kcfg_cryptAlgo->insertItem(i18n("Twofish-128 (128 bit)"));
115#endif // CONFIG_PWMANAGER_GCRY 115#endif // CONFIG_PWMANAGER_GCRY
116 fileLayout->addWidget( kcfg_cryptAlgo,i,1); 116 fileLayout->addWidget( kcfg_cryptAlgo,i,1);
117 ++i; 117 ++i;
118 118
119 QLabel* kcfg_hash_label = new QLabel(i18n("Hashing:"), filePage); 119 QLabel* kcfg_hash_label = new QLabel(i18n("Hashing:"), filePage);
120 fileLayout->addWidget(kcfg_hash_label,i,0); 120 fileLayout->addWidget(kcfg_hash_label,i,0);
121 kcfg_hashAlgo = new QComboBox(filePage, "kcfg_hashAlgo"); 121 kcfg_hashAlgo = new QComboBox(filePage, "kcfg_hashAlgo");
122 kcfg_hashAlgo->insertItem(i18n("SHA-160, SHA1 (160 bit)")); 122 kcfg_hashAlgo->insertItem(i18n("SHA-160, SHA1 (160 bit)"));
123#ifdef CONFIG_PWMANAGER_GCRY 123#ifdef CONFIG_PWMANAGER_GCRY
124 kcfg_hashAlgo->insertItem(i18n("SHA-256 (256 bit)")); 124 kcfg_hashAlgo->insertItem(i18n("SHA-256 (256 bit)"));
125 kcfg_hashAlgo->insertItem(i18n("SHA-384 (384 bit)")); 125 kcfg_hashAlgo->insertItem(i18n("SHA-384 (384 bit)"));
126 kcfg_hashAlgo->insertItem(i18n("SHA-512 (512 bit)")); 126 kcfg_hashAlgo->insertItem(i18n("SHA-512 (512 bit)"));
127 kcfg_hashAlgo->insertItem(i18n("MD5 (128 bit)")); 127 kcfg_hashAlgo->insertItem(i18n("MD5 (128 bit)"));
128 kcfg_hashAlgo->insertItem(i18n("RIPE-MD-160 (160 bit)")); 128 kcfg_hashAlgo->insertItem(i18n("RIPE-MD-160 (160 bit)"));
129 kcfg_hashAlgo->insertItem(i18n("Tiger (192 bit)")); 129 kcfg_hashAlgo->insertItem(i18n("Tiger (192 bit)"));
130#endif // CONFIG_PWMANAGER_GCRY 130#endif // CONFIG_PWMANAGER_GCRY
131 fileLayout->addWidget( kcfg_hashAlgo,i,1); 131 fileLayout->addWidget( kcfg_hashAlgo,i,1);
132 ++i; 132 ++i;
133 133
134 permissionLineEdit = new QLineEdit(filePage); 134 permissionLineEdit = new QLineEdit(filePage);
135 QLabel* permissionLineLabel = new QLabel(permissionLineEdit, i18n("Permissions:"), filePage); 135 QLabel* permissionLineLabel = new QLabel(permissionLineEdit, i18n("Permissions:"), filePage);
136 fileLayout->addWidget(permissionLineLabel,i,0); 136 fileLayout->addWidget(permissionLineLabel,i,0);
137 fileLayout->addWidget(permissionLineEdit,i,1); 137 fileLayout->addWidget(permissionLineEdit,i,1);
138 ++i; 138 ++i;
139 139
140 KPrefsWidBool *sb = addWidBool(i18n("Make backup before saving"), 140 KPrefsWidBool *sb = addWidBool(i18n("Make backup before saving"),
141 &(prefs->mMakeFileBackup),filePage); 141 &(prefs->mMakeFileBackup),filePage);
142 fileLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 142 fileLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
143 ++i; 143 ++i;
144 144
145 // Timeout page 145 // Timeout page
146 ////////////////////////////////////////////////////// 146 //////////////////////////////////////////////////////
147 QWidget *timeoutPage = new QWidget( this ); 147 QWidget *timeoutPage = new QWidget( this );
148 QGridLayout *timeoutLayout = new QGridLayout( timeoutPage, 3, 2); 148 QGridLayout *timeoutLayout = new QGridLayout( timeoutPage, 3, 2);
149 149
150 i = 0; 150 i = 0;
151 pwTimeoutSpinBox = new QSpinBox( timeoutPage, "pwTimeoutSpinBox" ); 151 pwTimeoutSpinBox = new QSpinBox( 0,600,10,timeoutPage, "pwTimeoutSpinBox" );
152 QLabel* timeoutLabel = new QLabel(pwTimeoutSpinBox, i18n("Password timeout\n(timeout to hold password in\nmemory,so you don't have to\nre-enter it,if you\nalready have entered it)\n[set to 0 to disable]:"), timeoutPage); 152 QLabel* timeoutLabel = new QLabel(pwTimeoutSpinBox, i18n("Password timeout\n(timeout to hold password in\nmemory,so you don't have to\nre-enter it,if you\nalready have entered it)\n[set to 0 to disable]:"), timeoutPage);
153 timeoutLayout->addMultiCellWidget(timeoutLabel,i, i, 0 ,0); 153 timeoutLayout->addMultiCellWidget(timeoutLabel,i, i, 0 ,0);
154 timeoutLayout->addWidget(pwTimeoutSpinBox,i,1); 154 timeoutLayout->addWidget(pwTimeoutSpinBox,i,1);
155 ++i; 155 ++i;
156 156
157 lockTimeoutSpinBox = new QSpinBox( timeoutPage, "lockTimeoutSpinBox" ); 157 lockTimeoutSpinBox = new QSpinBox( 0,600,10,timeoutPage, "lockTimeoutSpinBox" );
158 QLabel* lockTimeoutLabel = new QLabel(lockTimeoutSpinBox, i18n("Auto-lock timeout\n(auto lock document after this\namount of seconds)\n[set to 0 to disable]:"), timeoutPage); 158 QLabel* lockTimeoutLabel = new QLabel(lockTimeoutSpinBox, i18n("Auto-lock timeout\n(auto lock document after this\namount of seconds)\n[set to 0 to disable]:"), timeoutPage);
159 timeoutLayout->addMultiCellWidget(lockTimeoutLabel,i, i, 0 ,0); 159 timeoutLayout->addMultiCellWidget(lockTimeoutLabel,i, i, 0 ,0);
160 timeoutLayout->addWidget(lockTimeoutSpinBox,i,1); 160 timeoutLayout->addWidget(lockTimeoutSpinBox,i,1);
161 ++i; 161 ++i;
162 162
163 sb = addWidBool(i18n("deep-lock on autolock"), 163 sb = addWidBool(i18n("deep-lock on autolock"),
164 &(prefs->mAutoDeeplock),timeoutPage); 164 &(prefs->mAutoDeeplock),timeoutPage);
165 timeoutLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 165 timeoutLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
166 ++i; 166 ++i;
167 167
168 168
169 // Autostart page 169 // Autostart page
170 ////////////////////////////////////////////////////// 170 //////////////////////////////////////////////////////
171 QWidget *autostartPage = new QWidget( this ); 171 QWidget *autostartPage = new QWidget( this );
172 QGridLayout *autostartLayout = new QGridLayout( autostartPage, 3, 2); 172 QGridLayout *autostartLayout = new QGridLayout( autostartPage, 3, 2);
173 173
174 i = 0; 174 i = 0;
175 175
176 autostartLineEdit = new KURLRequester(autostartPage, "autoStartLineEdit"); 176 autostartLineEdit = new KURLRequester(autostartPage, "autoStartLineEdit");
177 QLabel* autostartLineLabel = new QLabel(autostartLineEdit, "Open this file automatically on startup:",autostartPage); 177 QLabel* autostartLineLabel = new QLabel(autostartLineEdit, "Open this file automatically on startup:",autostartPage);
178 autostartLayout->addMultiCellWidget(autostartLineLabel,i,i,0,1); 178 autostartLayout->addMultiCellWidget(autostartLineLabel,i,i,0,1);
179 ++i; 179 ++i;
180 autostartLayout->addMultiCellWidget(autostartLineEdit,i,i,0,1); 180 autostartLayout->addMultiCellWidget(autostartLineEdit,i,i,0,1);
181 ++i; 181 ++i;
182 182
183 sb = addWidBool(i18n("open deeplocked"), 183 sb = addWidBool(i18n("open deeplocked"),
184 &(prefs->mAutostartDeeplocked),autostartPage); 184 &(prefs->mAutostartDeeplocked),autostartPage);
185 autostartLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 185 autostartLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
186 ++i; 186 ++i;
187 187
188 188
189 // external app page 189 // external app page
190 ////////////////////////////////////////////////////// 190 //////////////////////////////////////////////////////
191 QWidget *externalappPage = new QWidget( this ); 191 QWidget *externalappPage = new QWidget( this );
192 QGridLayout *externalappLayout = new QGridLayout( externalappPage, 3, 2); 192 QGridLayout *externalappLayout = new QGridLayout( externalappPage, 3, 2);
193 193
194 i = 0; 194 i = 0;
195 195
196 browserLineEdit = new QLineEdit(externalappPage); 196 browserLineEdit = new QLineEdit(externalappPage);
197 QLabel* browserLineLabel = new QLabel(browserLineEdit, i18n("Favourite browser:"), externalappPage); 197 QLabel* browserLineLabel = new QLabel(browserLineEdit, i18n("Favourite browser:"), externalappPage);
198 externalappLayout->addWidget(browserLineLabel,i,0); 198 externalappLayout->addWidget(browserLineLabel,i,0);
199 externalappLayout->addWidget(browserLineEdit,i,1); 199 externalappLayout->addWidget(browserLineEdit,i,1);
200 ++i; 200 ++i;
201 201
202 xtermLineEdit = new QLineEdit(externalappPage); 202 xtermLineEdit = new QLineEdit(externalappPage);
203 QLabel* xtermLineLabel = new QLabel(xtermLineEdit, i18n("Favourite x-terminal:"), externalappPage); 203 QLabel* xtermLineLabel = new QLabel(xtermLineEdit, i18n("Favourite x-terminal:"), externalappPage);
204 externalappLayout->addWidget(xtermLineLabel,i,0); 204 externalappLayout->addWidget(xtermLineLabel,i,0);
205 externalappLayout->addWidget(xtermLineEdit,i,1); 205 externalappLayout->addWidget(xtermLineEdit,i,1);
206 ++i; 206 ++i;
207 207
208 208
209 // miscelaneous page 209 // miscelaneous page
210 ////////////////////////////////////////////////////// 210 //////////////////////////////////////////////////////
211 QWidget *miscPage = new QWidget( this ); 211 QWidget *miscPage = new QWidget( this );
212 QGridLayout *miscLayout = new QGridLayout( miscPage, 3, 2); 212 QGridLayout *miscLayout = new QGridLayout( miscPage, 3, 2);
213 213
214 i = 0; 214 i = 0;
215 215
216 /*US ENH: PWM/Pi has no tray and con be minimized 216 /*US ENH: PWM/Pi has no tray and con be minimized
217 sb = addWidBool(i18n("Show icon in system-tray"),&(prefs->mTray),miscPage); 217 sb = addWidBool(i18n("Show icon in system-tray"),&(prefs->mTray),miscPage);
218 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 218 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
219 ++i; 219 ++i;
220 */ 220 */
221 221
222 sb = addWidBool(i18n("Open document with passwords unlocked"),&(prefs->mUnlockOnOpen),miscPage); 222 sb = addWidBool(i18n("Open document with passwords unlocked"),&(prefs->mUnlockOnOpen),miscPage);
223 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 223 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
224 ++i; 224 ++i;
225 225
226 /*US ENH: PWM/Pi has no tray and con be minimized 226 /*US ENH: PWM/Pi has no tray and con be minimized
227 sb = addWidBool(i18n("auto-minimize to tray on startup"),&(prefs->mAutoMinimizeOnStart),miscPage); 227 sb = addWidBool(i18n("auto-minimize to tray on startup"),&(prefs->mAutoMinimizeOnStart),miscPage);
228 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 228 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
229 ++i; 229 ++i;
230 230
231 KPrefsWidRadios * minimizeRadio = addWidRadios(i18n("auto-lock on minimize:") ,&(prefs->mMinimizeLock), miscPage); 231 KPrefsWidRadios * minimizeRadio = addWidRadios(i18n("auto-lock on minimize:") ,&(prefs->mMinimizeLock), miscPage);
232 minimizeRadio->addRadio(i18n("don't lock")); 232 minimizeRadio->addRadio(i18n("don't lock"));
233 minimizeRadio->addRadio(i18n("normal lock")); 233 minimizeRadio->addRadio(i18n("normal lock"));
234 minimizeRadio->addRadio(i18n("deep-lock")); 234 minimizeRadio->addRadio(i18n("deep-lock"));
235 miscLayout->addMultiCellWidget( (QWidget*)minimizeRadio->groupBox(),i,i,0,2); 235 miscLayout->addMultiCellWidget( (QWidget*)minimizeRadio->groupBox(),i,i,0,2);
236 ++i; 236 ++i;
237 237
238 sb = addWidBool(i18n("KWallet emulation"),&(prefs->mKWalletEmu),miscPage); 238 sb = addWidBool(i18n("KWallet emulation"),&(prefs->mKWalletEmu),miscPage);
239 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 239 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
240 ++i; 240 ++i;
241 241
242 sb = addWidBool(i18n("Close instead Minimize into tray"),&(prefs->mClose),miscPage); 242 sb = addWidBool(i18n("Close instead Minimize into tray"),&(prefs->mClose),miscPage);
243 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1); 243 miscLayout->addMultiCellWidget(sb->checkBox(), i,i,0,1);
244 ++i; 244 ++i;
245 */ 245 */
246 246
247 247
248 tabWidget->addTab( windowStylePage, i18n( "Look && feel" ) ); 248 tabWidget->addTab( windowStylePage, i18n( "Look && feel" ) );
249 tabWidget->addTab( filePage, i18n( "File" ) ); 249 tabWidget->addTab( filePage, i18n( "File" ) );
250 tabWidget->addTab( timeoutPage, i18n( "Timeout" ) ); 250 tabWidget->addTab( timeoutPage, i18n( "Timeout" ) );
251 tabWidget->addTab( autostartPage, i18n( "Autostart" ) ); 251 tabWidget->addTab( autostartPage, i18n( "Autostart" ) );
252 tabWidget->addTab( externalappPage, i18n( "External apps" ) ); 252 tabWidget->addTab( externalappPage, i18n( "External apps" ) );
253 tabWidget->addTab( miscPage, i18n( "Miscellaneous" ) ); 253 tabWidget->addTab( miscPage, i18n( "Miscellaneous" ) );
254 254
255 255
256 connect( permissionLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) ); 256 connect( permissionLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) );
257 connect( pwTimeoutSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( modified() ) ); 257 connect( pwTimeoutSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( modified() ) );
258 connect( lockTimeoutSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( modified() ) ); 258 connect( lockTimeoutSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( modified() ) );
259 connect( autostartLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) ); 259 connect( autostartLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) );
260 connect( browserLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) ); 260 connect( browserLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) );
261 connect( xtermLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) ); 261 connect( xtermLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( modified() ) );
262 262
263} 263}
264 264
265 265
266void PWMConfigWidget::usrReadConfig() 266void PWMConfigWidget::usrReadConfig()
267{ 267{
268 PWMPrefs* prefs = PWMPrefs::instance(); 268 PWMPrefs* prefs = PWMPrefs::instance();
269 269
270 270
271 setFilePermissions(prefs->mFilePermissions); 271 setFilePermissions(prefs->mFilePermissions);
272 272
273 pwTimeoutSpinBox->setValue(prefs->mPwTimeout); 273 pwTimeoutSpinBox->setValue(prefs->mPwTimeout);
274 lockTimeoutSpinBox->setValue(prefs->mLockTimeout); 274 lockTimeoutSpinBox->setValue(prefs->mLockTimeout);
275 autostartLineEdit->setURL(prefs->mAutoStart); 275 autostartLineEdit->setURL(prefs->mAutoStart);
276 browserLineEdit->setText(prefs->mBrowserCommand); 276 browserLineEdit->setText(prefs->mBrowserCommand);
277 xtermLineEdit->setText(prefs->mXTermCommand); 277 xtermLineEdit->setText(prefs->mXTermCommand);
278 278
279 kcfg_compression->setCurrentItem(prefs->mCompression); 279 kcfg_compression->setCurrentItem(prefs->mCompression);
280 kcfg_cryptAlgo->setCurrentItem(prefs->mCryptAlgo); 280 kcfg_cryptAlgo->setCurrentItem(prefs->mCryptAlgo);
281 kcfg_hashAlgo->setCurrentItem(prefs->mHashAlgo); 281 kcfg_hashAlgo->setCurrentItem(prefs->mHashAlgo);
282} 282}
283 283
284void PWMConfigWidget::usrWriteConfig() 284void PWMConfigWidget::usrWriteConfig()
285{ 285{
286 PWMPrefs* prefs = PWMPrefs::instance(); 286 PWMPrefs* prefs = PWMPrefs::instance();
287 287
288 prefs->mFilePermissions = getFilePermissions(); 288 prefs->mFilePermissions = getFilePermissions();
289 289
290 prefs->mPwTimeout = pwTimeoutSpinBox->value(); 290 prefs->mPwTimeout = pwTimeoutSpinBox->value();
291 prefs->mLockTimeout = lockTimeoutSpinBox->value(); 291 prefs->mLockTimeout = lockTimeoutSpinBox->value();
292 prefs->mAutoStart = autostartLineEdit->url(); 292 prefs->mAutoStart = autostartLineEdit->url();
293 293
294 prefs->mBrowserCommand = browserLineEdit->text(); 294 prefs->mBrowserCommand = browserLineEdit->text();
295 prefs->mXTermCommand = xtermLineEdit->text(); 295 prefs->mXTermCommand = xtermLineEdit->text();
296 296
297 prefs->mCompression = kcfg_compression->currentItem(); 297 prefs->mCompression = kcfg_compression->currentItem();
298 prefs->mCryptAlgo = kcfg_cryptAlgo->currentItem(); 298 prefs->mCryptAlgo = kcfg_cryptAlgo->currentItem();
299 prefs->mHashAlgo = kcfg_hashAlgo->currentItem(); 299 prefs->mHashAlgo = kcfg_hashAlgo->currentItem();
300 300
301} 301}
302 302
303int PWMConfigWidget::getFilePermissions() 303int PWMConfigWidget::getFilePermissions()
304{ 304{
305 char octalDigits[] = "01234567"; 305 char octalDigits[] = "01234567";
306 bool isOctal; 306 bool isOctal;
307 QString permString(permissionLineEdit->text()); 307 QString permString(permissionLineEdit->text());
308 int i, j, length = permString.length(); 308 int i, j, length = permString.length();
309 if (length != 3) { 309 if (length != 3) {
310 printWarn("Wrong permission string length! Please enter " 310 printWarn("Wrong permission string length! Please enter "
311 "the string like the following example: 600"); 311 "the string like the following example: 600");
312 return CONF_DEFAULT_FILEPERMISSIONS; 312 return CONF_DEFAULT_FILEPERMISSIONS;
313 } 313 }
314 for (i = 0; i < length; ++i) { 314 for (i = 0; i < length; ++i) {
315 isOctal = false; 315 isOctal = false;
316 for (j = 0; j < 8; ++j) { 316 for (j = 0; j < 8; ++j) {
317 if (permString.at(i) == octalDigits[j]) { 317 if (permString.at(i) == octalDigits[j]) {
318 isOctal = true; 318 isOctal = true;
319 break; 319 break;
320 } 320 }
321 } 321 }
322 if (!isOctal) { 322 if (!isOctal) {
323 printWarn("CONFIG: File-permissions: This is " 323 printWarn("CONFIG: File-permissions: This is "
324 "not an octal number "); 324 "not an octal number ");
325 return CONF_DEFAULT_FILEPERMISSIONS; 325 return CONF_DEFAULT_FILEPERMISSIONS;
326 } 326 }
327 } 327 }
328 328
329 int ret = strtol(permString.latin1(), 0, 8); 329 int ret = strtol(permString.latin1(), 0, 8);
330 if (ret == 0) { 330 if (ret == 0) {
331 /* either an error occured, or the user did really type 000 */ 331 /* either an error occured, or the user did really type 000 */
332 printWarn("CONFIG: File-permissions: Hm, either conversion error, " 332 printWarn("CONFIG: File-permissions: Hm, either conversion error, "
333 "or you really typed 000. 8-)"); 333 "or you really typed 000. 8-)");
334 return CONF_DEFAULT_FILEPERMISSIONS; 334 return CONF_DEFAULT_FILEPERMISSIONS;
335 } 335 }
336 return ret; 336 return ret;
337} 337}
338 338
339void PWMConfigWidget::setFilePermissions(int perm) 339void PWMConfigWidget::setFilePermissions(int perm)
340{ 340{
341 char tmpBuf[30]; 341 char tmpBuf[30];
342 sprintf(tmpBuf, "%o", perm); 342 sprintf(tmpBuf, "%o", perm);
343 permissionLineEdit->setText(tmpBuf); 343 permissionLineEdit->setText(tmpBuf);
344} 344}
345 345
346 346
347 347
348#ifndef PWM_EMBEDDED 348#ifndef PWM_EMBEDDED
349#include "pwmconfigwidget.moc" 349#include "pwmconfigwidget.moc"
350#endif //PWM_EMBEDDED 350#endif //PWM_EMBEDDED
351 351
diff --git a/pwmanager/pwmanager/libgcryptif.cpp b/pwmanager/pwmanager/libgcryptif.cpp
index eafd318..ff94bf6 100644
--- a/pwmanager/pwmanager/libgcryptif.cpp
+++ b/pwmanager/pwmanager/libgcryptif.cpp
@@ -58,392 +58,397 @@ PwMerror LibGCryptIf::encrypt(unsigned char **outBuf,
58 58
59 // test if algo is ready for encryption 59 // test if algo is ready for encryption
60 err = gcry_cipher_algo_info(algo, 60 err = gcry_cipher_algo_info(algo,
61 GCRYCTL_TEST_ALGO, 61 GCRYCTL_TEST_ALGO,
62 0, 0); 62 0, 0);
63 if (err != GPG_ERR_NO_ERROR) { 63 if (err != GPG_ERR_NO_ERROR) {
64 printDebug(string("LibGCryptIf::doEncrypt(): GCRYCTL_TEST_ALGO failed: ") 64 printDebug(string("LibGCryptIf::doEncrypt(): GCRYCTL_TEST_ALGO failed: ")
65 + gcry_strerror(err)); 65 + gcry_strerror(err));
66 ret = e_cryptNotImpl; 66 ret = e_cryptNotImpl;
67 goto out; 67 goto out;
68 } 68 }
69 // get the algo block length 69 // get the algo block length
70 err = gcry_cipher_algo_info(algo, 70 err = gcry_cipher_algo_info(algo,
71 GCRYCTL_GET_BLKLEN, 71 GCRYCTL_GET_BLKLEN,
72 0, 72 0,
73 &blklen); 73 &blklen);
74 if (err != GPG_ERR_NO_ERROR) { 74 if (err != GPG_ERR_NO_ERROR) {
75 printDebug(string("LibGCryptIf::doEncrypt(): GCRYCTL_GET_BLKLEN failed: ") 75 printDebug(string("LibGCryptIf::doEncrypt(): GCRYCTL_GET_BLKLEN failed: ")
76 + gcry_strerror(err)); 76 + gcry_strerror(err));
77 ret = e_cryptNotImpl; 77 ret = e_cryptNotImpl;
78 goto out; 78 goto out;
79 } 79 }
80 /* double check if we have enough space. 80 /* double check if we have enough space.
81 * We have only 1024 extra bytes for padding and salt. 81 * We have only 1024 extra bytes for padding and salt.
82 */ 82 */
83 BUG_ON(blklen > 1024 - STRING2KEY_SALTLEN); 83 BUG_ON(blklen > 1024 - STRING2KEY_SALTLEN);
84 // get the algo key length 84 // get the algo key length
85 err = gcry_cipher_algo_info(algo, 85 err = gcry_cipher_algo_info(algo,
86 GCRYCTL_GET_KEYLEN, 86 GCRYCTL_GET_KEYLEN,
87 0, 87 0,
88 &cipherKeylen); 88 &cipherKeylen);
89 if (err != GPG_ERR_NO_ERROR) { 89 if (err != GPG_ERR_NO_ERROR) {
90 printDebug(string("LibGCryptIf::doEncrypt(): GCRYCTL_GET_KEYLEN failed: ") 90 printDebug(string("LibGCryptIf::doEncrypt(): GCRYCTL_GET_KEYLEN failed: ")
91 + gcry_strerror(err)); 91 + gcry_strerror(err));
92 ret = e_cryptNotImpl; 92 ret = e_cryptNotImpl;
93 goto out; 93 goto out;
94 } 94 }
95 // now open the algo and get a handle 95 // now open the algo and get a handle
96 err = gcry_cipher_open(&handle, 96 err = gcry_cipher_open(&handle,
97 algo, 97 algo,
98 GCRY_CIPHER_MODE_CBC, 98 GCRY_CIPHER_MODE_CBC,
99 0); 99 0);
100 if (err != GPG_ERR_NO_ERROR) { 100 if (err != GPG_ERR_NO_ERROR) {
101 printDebug(string("LibGCryptIf::doEncrypt(): gcry_cipher_open() failed: ") 101 printDebug(string("LibGCryptIf::doEncrypt(): gcry_cipher_open() failed: ")
102 + gcry_strerror(err)); 102 + gcry_strerror(err));
103 ret = e_cryptNotImpl; 103 ret = e_cryptNotImpl;
104 goto out; 104 goto out;
105 } 105 }
106 // hash the "key" to a fixed size hash matching "cipherKeylen" 106 // hash the "key" to a fixed size hash matching "cipherKeylen"
107 hashedKey = new unsigned char[cipherKeylen]; 107 hashedKey = new unsigned char[cipherKeylen];
108 hashPassphrase(key, keylen, salt, hashedKey, cipherKeylen, true); 108 hashPassphrase(key, keylen, salt, hashedKey, cipherKeylen, true);
109 // so now set the hashed key 109 // so now set the hashed key
110 err = gcry_cipher_setkey(handle, hashedKey, cipherKeylen); 110 err = gcry_cipher_setkey(handle, hashedKey, cipherKeylen);
111 if (err != GPG_ERR_NO_ERROR) { 111 if (err != GPG_ERR_NO_ERROR) {
112 printDebug(string("LibGCryptIf::doEncrypt(): gcry_cipher_setkey() failed: ") 112 printDebug(string("LibGCryptIf::doEncrypt(): gcry_cipher_setkey() failed: ")
113 + gcry_strerror(err)); 113 + gcry_strerror(err));
114 ret = e_cryptNotImpl; 114 ret = e_cryptNotImpl;
115 delete [] hashedKey; 115 delete [] hashedKey;
116 goto out_close; 116 goto out_close;
117 } 117 }
118 delete [] hashedKey; 118 delete [] hashedKey;
119 /* allocate a buffer for the encrypted data. 119 /* allocate a buffer for the encrypted data.
120 * The size of the buffer is the inBuf length, but blklen 120 * The size of the buffer is the inBuf length, but blklen
121 * aligned and plus the length of the salt, that is appended. 121 * aligned and plus the length of the salt, that is appended.
122 */ 122 */
123 *outBufLen = getBufLen(unpaddedLen, blklen) + STRING2KEY_SALTLEN; 123 *outBufLen = getBufLen(unpaddedLen, blklen) + STRING2KEY_SALTLEN;
124 *outBuf = new unsigned char[*outBufLen]; 124 *outBuf = new unsigned char[*outBufLen];
125 padData(inBuf, unpaddedLen, blklen); 125 padData(inBuf, unpaddedLen, blklen);
126 // encrypt the padded data 126 // encrypt the padded data
127 err = gcry_cipher_encrypt(handle, 127 err = gcry_cipher_encrypt(handle,
128 *outBuf, 128 *outBuf,
129 *outBufLen - STRING2KEY_SALTLEN, 129 *outBufLen - STRING2KEY_SALTLEN,
130 inBuf, 130 inBuf,
131 *outBufLen - STRING2KEY_SALTLEN); 131 *outBufLen - STRING2KEY_SALTLEN);
132 if (err != GPG_ERR_NO_ERROR) { 132 if (err != GPG_ERR_NO_ERROR) {
133 printDebug(string("LibGCryptIf::doEncrypt(): gcry_cipher_encrypt() failed: ") 133 printDebug(string("LibGCryptIf::doEncrypt(): gcry_cipher_encrypt() failed: ")
134 + gcry_strerror(err)); 134 + gcry_strerror(err));
135 ret = e_cryptNotImpl; 135 ret = e_cryptNotImpl;
136 goto out_delete; 136 goto out_delete;
137 } 137 }
138 // append the salt to the encrypted data 138 // append the salt to the encrypted data
139 memcpy(*outBuf + *outBufLen - STRING2KEY_SALTLEN, salt, STRING2KEY_SALTLEN); 139 memcpy(*outBuf + *outBufLen - STRING2KEY_SALTLEN, salt, STRING2KEY_SALTLEN);
140 goto out_close; 140 goto out_close;
141out_delete: 141out_delete:
142 delete [] *outBuf; 142 delete [] *outBuf;
143out_close: 143out_close:
144 gcry_cipher_close(handle); 144 gcry_cipher_close(handle);
145out: 145out:
146 return ret; 146 return ret;
147} 147}
148 148
149PwMerror LibGCryptIf::decrypt(unsigned char **outBuf, 149PwMerror LibGCryptIf::decrypt(unsigned char **outBuf,
150 size_t *outBufLen, 150 size_t *outBufLen,
151 const unsigned char *inBuf, 151 const unsigned char *inBuf,
152 size_t inBufLen, 152 size_t inBufLen,
153 const unsigned char *key, 153 const unsigned char *key,
154 size_t keylen, 154 size_t keylen,
155 char _algo) 155 char _algo)
156{ 156{
157 PwMerror ret = e_success; 157 PwMerror ret = e_success;
158 gcry_error_t err; 158 gcry_error_t err;
159 gcry_cipher_hd_t handle; 159 gcry_cipher_hd_t handle;
160 size_t cipherKeylen; 160 size_t cipherKeylen;
161 unsigned char *hashedKey; 161 unsigned char *hashedKey;
162 unsigned char salt[STRING2KEY_SALTLEN]; 162 unsigned char salt[STRING2KEY_SALTLEN];
163 int algo = mapCipherId(_algo); 163 int algo = mapCipherId(_algo);
164 164
165 if (!inBufLen || !keylen) 165 if (!inBufLen || !keylen)
166 return e_invalidArg; 166 return e_invalidArg;
167 167
168 // test if algo is ready for encryption 168 // test if algo is ready for encryption
169 err = gcry_cipher_algo_info(algo, 169 err = gcry_cipher_algo_info(algo,
170 GCRYCTL_TEST_ALGO, 170 GCRYCTL_TEST_ALGO,
171 0, 0); 171 0, 0);
172 if (err != GPG_ERR_NO_ERROR) { 172 if (err != GPG_ERR_NO_ERROR) {
173 printDebug(string("LibGCryptIf::doDecrypt(): GCRYCTL_TEST_ALGO failed: ") 173 printDebug(string("LibGCryptIf::doDecrypt(): GCRYCTL_TEST_ALGO failed: ")
174 + gcry_strerror(err)); 174 + gcry_strerror(err));
175 ret = e_cryptNotImpl; 175 ret = e_cryptNotImpl;
176 goto out; 176 goto out;
177 } 177 }
178 // get algo key length 178 // get algo key length
179 err = gcry_cipher_algo_info(algo, 179 err = gcry_cipher_algo_info(algo,
180 GCRYCTL_GET_KEYLEN, 180 GCRYCTL_GET_KEYLEN,
181 0, 181 0,
182 &cipherKeylen); 182 &cipherKeylen);
183 if (err != GPG_ERR_NO_ERROR) { 183 if (err != GPG_ERR_NO_ERROR) {
184 printDebug(string("LibGCryptIf::doDecrypt(): GCRYCTL_GET_KEYLEN failed: ") 184 printDebug(string("LibGCryptIf::doDecrypt(): GCRYCTL_GET_KEYLEN failed: ")
185 + gcry_strerror(err)); 185 + gcry_strerror(err));
186 ret = e_cryptNotImpl; 186 ret = e_cryptNotImpl;
187 goto out; 187 goto out;
188 } 188 }
189 // extract the salt of the encrypted data buffer 189 // extract the salt of the encrypted data buffer
190 memcpy(salt, inBuf + inBufLen - STRING2KEY_SALTLEN, STRING2KEY_SALTLEN); 190 memcpy(salt, inBuf + inBufLen - STRING2KEY_SALTLEN, STRING2KEY_SALTLEN);
191 // open the algo and get a handle 191 // open the algo and get a handle
192 err = gcry_cipher_open(&handle, 192 err = gcry_cipher_open(&handle,
193 algo, 193 algo,
194 GCRY_CIPHER_MODE_CBC, 194 GCRY_CIPHER_MODE_CBC,
195 0); 195 0);
196 if (err != GPG_ERR_NO_ERROR) { 196 if (err != GPG_ERR_NO_ERROR) {
197 printDebug(string("LibGCryptIf::doDecrypt(): gcry_cipher_open() failed: ") 197 printDebug(string("LibGCryptIf::doDecrypt(): gcry_cipher_open() failed: ")
198 + gcry_strerror(err)); 198 + gcry_strerror(err));
199 ret = e_cryptNotImpl; 199 ret = e_cryptNotImpl;
200 goto out; 200 goto out;
201 } 201 }
202 // hash the "key" to a fixed size hash matching "cipherKeylen" 202 // hash the "key" to a fixed size hash matching "cipherKeylen"
203 hashedKey = new unsigned char[cipherKeylen]; 203 hashedKey = new unsigned char[cipherKeylen];
204 hashPassphrase(key, keylen, salt, hashedKey, cipherKeylen, false); 204 hashPassphrase(key, keylen, salt, hashedKey, cipherKeylen, false);
205 // so now set the hashed key 205 // so now set the hashed key
206 err = gcry_cipher_setkey(handle, hashedKey, cipherKeylen); 206 err = gcry_cipher_setkey(handle, hashedKey, cipherKeylen);
207 if (err != GPG_ERR_NO_ERROR) { 207 if (err != GPG_ERR_NO_ERROR) {
208 printDebug(string("LibGCryptIf::doDecrypt(): gcry_cipher_setkey() failed: ") 208 printDebug(string("LibGCryptIf::doDecrypt(): gcry_cipher_setkey() failed: ")
209 + gcry_strerror(err)); 209 + gcry_strerror(err));
210 ret = e_cryptNotImpl; 210 ret = e_cryptNotImpl;
211 delete [] hashedKey; 211 delete [] hashedKey;
212 goto out_close; 212 goto out_close;
213 } 213 }
214 delete [] hashedKey; 214 delete [] hashedKey;
215 *outBufLen = inBufLen - STRING2KEY_SALTLEN; 215 *outBufLen = inBufLen - STRING2KEY_SALTLEN;
216 *outBuf = new unsigned char[*outBufLen]; 216 *outBuf = new unsigned char[*outBufLen];
217 // decrypt the data 217 // decrypt the data
218 err = gcry_cipher_decrypt(handle, 218 err = gcry_cipher_decrypt(handle,
219 *outBuf, 219 *outBuf,
220 *outBufLen, 220 *outBufLen,
221 inBuf, 221 inBuf,
222 *outBufLen); 222 *outBufLen);
223 if (err != GPG_ERR_NO_ERROR) { 223 if (err != GPG_ERR_NO_ERROR) {
224 printDebug(string("LibGCryptIf::doEncrypt(): gcry_cipher_encrypt() failed: ") 224 printDebug(string("LibGCryptIf::doEncrypt(): gcry_cipher_encrypt() failed: ")
225 + gcry_strerror(err)); 225 + gcry_strerror(err));
226 ret = e_cryptNotImpl; 226 ret = e_cryptNotImpl;
227 goto out_delete; 227 goto out_delete;
228 } 228 }
229 // remove all random padding 229 // remove all random padding
230 unpadData(*outBuf, outBufLen); 230 unpadData(*outBuf, outBufLen);
231 goto out_close; 231 goto out_close;
232out_delete: 232out_delete:
233 delete [] *outBuf; 233 delete [] *outBuf;
234out_close: 234out_close:
235 gcry_cipher_close(handle); 235 gcry_cipher_close(handle);
236out: 236out:
237 return ret; 237 return ret;
238} 238}
239 239
240PwMerror LibGCryptIf::hash(unsigned char **outBuf, 240PwMerror LibGCryptIf::hash(unsigned char **outBuf,
241 size_t *outBufLen, 241 size_t *outBufLen,
242 const unsigned char *inBuf, 242 const unsigned char *inBuf,
243 size_t inBufLen, 243 size_t inBufLen,
244 char _algo) 244 char _algo)
245{ 245{
246 PwMerror ret = e_success; 246 PwMerror ret = e_success;
247 unsigned int hashLen; 247 unsigned int hashLen;
248 int algo = mapHashId(_algo); 248 int algo = mapHashId(_algo);
249 249
250 hashLen = gcry_md_get_algo_dlen(algo); 250 hashLen = gcry_md_get_algo_dlen(algo);
251 *outBufLen = hashLen; 251 *outBufLen = hashLen;
252 *outBuf = new unsigned char[*outBufLen]; 252 *outBuf = new unsigned char[*outBufLen];
253 gcry_md_hash_buffer(algo, 253 gcry_md_hash_buffer(algo,
254 *outBuf, 254 *outBuf,
255 inBuf, 255 inBuf,
256 inBufLen); 256 inBufLen);
257 return ret; 257 return ret;
258} 258}
259 259
260unsigned int LibGCryptIf::hashLength(char _algo) 260unsigned int LibGCryptIf::hashLength(char _algo)
261{ 261{
262 unsigned int ret; 262 unsigned int ret;
263 int algo = mapHashId(_algo); 263 int algo = mapHashId(_algo);
264 ret = gcry_md_get_algo_dlen(algo); 264 ret = gcry_md_get_algo_dlen(algo);
265 return ret; 265 return ret;
266} 266}
267 267
268int LibGCryptIf::mapCipherId(char algo) 268int LibGCryptIf::mapCipherId(char algo)
269{ 269{
270 switch (algo) { 270 switch (algo) {
271 case PWM_CRYPT_AES128: 271 case PWM_CRYPT_AES128:
272 return GCRY_CIPHER_AES; 272 return GCRY_CIPHER_AES;
273 case PWM_CRYPT_AES192: 273 case PWM_CRYPT_AES192:
274 return GCRY_CIPHER_AES192; 274 return GCRY_CIPHER_AES192;
275 case PWM_CRYPT_AES256: 275 case PWM_CRYPT_AES256:
276 return GCRY_CIPHER_AES256; 276 return GCRY_CIPHER_AES256;
277 case PWM_CRYPT_3DES: 277 case PWM_CRYPT_3DES:
278 return GCRY_CIPHER_3DES; 278 return GCRY_CIPHER_3DES;
279 case PWM_CRYPT_TWOFISH: 279 case PWM_CRYPT_TWOFISH:
280 return GCRY_CIPHER_TWOFISH; 280 return GCRY_CIPHER_TWOFISH;
281 case PWM_CRYPT_TWOFISH128: 281 case PWM_CRYPT_TWOFISH128:
282 return GCRY_CIPHER_TWOFISH128; 282 return GCRY_CIPHER_TWOFISH128;
283 default: 283 default:
284 BUG(); 284 BUG();
285 } 285 }
286 return GCRY_CIPHER_NONE; 286 return GCRY_CIPHER_NONE;
287} 287}
288 288
289int LibGCryptIf::mapHashId(char algo) 289int LibGCryptIf::mapHashId(char algo)
290{ 290{
291 switch (algo) { 291 switch (algo) {
292 case PWM_HASH_SHA1: 292 case PWM_HASH_SHA1:
293 return GCRY_MD_SHA1; 293 return GCRY_MD_SHA1;
294 case PWM_HASH_SHA256: 294 case PWM_HASH_SHA256:
295 return GCRY_MD_SHA256; 295 return GCRY_MD_SHA256;
296 case PWM_HASH_SHA384: 296 case PWM_HASH_SHA384:
297 return GCRY_MD_SHA384; 297 return GCRY_MD_SHA384;
298 case PWM_HASH_SHA512: 298 case PWM_HASH_SHA512:
299 return GCRY_MD_SHA512; 299 return GCRY_MD_SHA512;
300 case PWM_HASH_MD5: 300 case PWM_HASH_MD5:
301 return GCRY_MD_MD5; 301 return GCRY_MD_MD5;
302 case PWM_HASH_RMD160: 302 case PWM_HASH_RMD160:
303 return GCRY_MD_RMD160; 303 return GCRY_MD_RMD160;
304 case PWM_HASH_TIGER: 304 case PWM_HASH_TIGER:
305 return GCRY_MD_TIGER; 305 return GCRY_MD_TIGER;
306 default: 306 default:
307 BUG(); 307 BUG();
308 } 308 }
309 return GCRY_MD_NONE; 309 return GCRY_MD_NONE;
310} 310}
311 311
312bool LibGCryptIf::hashPassphrase(const unsigned char *pw, 312bool LibGCryptIf::hashPassphrase(const unsigned char *pw,
313 size_t pwlen, 313 size_t pwlen,
314 unsigned char *salt, 314 unsigned char *salt,
315 unsigned char *key, 315 unsigned char *key,
316 size_t keylen, 316 size_t keylen,
317 bool create) 317 bool create)
318{ 318{
319 DEK dek; 319 DEK dek;
320 STRING2KEY s2k; 320 STRING2KEY s2k;
321 bool ret; 321 bool ret;
322 322
323 dek.keylen = keylen; 323 dek.keylen = keylen;
324 s2k.mode = 1; 324 s2k.mode = 1;
325 s2k.hash_algo = mapHashId(conf()->confGlobHashAlgo()); 325 s2k.hash_algo = mapHashId(conf()->confGlobHashAlgo());
326 s2k.count = 0; 326 s2k.count = 0;
327 if (!create) 327 if (!create)
328 memcpy(s2k.salt, salt, STRING2KEY_SALTLEN); 328 memcpy(s2k.salt, salt, STRING2KEY_SALTLEN);
329 ret = doHashPassphrase(&dek, 329 ret = doHashPassphrase(&dek,
330 pw, 330 pw,
331 pwlen, 331 pwlen,
332 &s2k, 332 &s2k,
333 create); 333 create);
334 if (!ret) 334 if (!ret)
335 goto out; 335 goto out;
336 memcpy(key, dek.key, dek.keylen); 336 memcpy(key, dek.key, dek.keylen);
337 if (create) 337 if (create)
338 memcpy(salt, s2k.salt, STRING2KEY_SALTLEN); 338 memcpy(salt, s2k.salt, STRING2KEY_SALTLEN);
339out: 339out:
340 return ret; 340 return ret;
341} 341}
342 342
343 343
344bool LibGCryptIf::doHashPassphrase(DEK *dek, 344bool LibGCryptIf::doHashPassphrase(DEK *dek,
345 const unsigned char *pw, 345 const unsigned char *pw,
346 size_t pwlen, 346 size_t pwlen,
347 STRING2KEY *s2k, 347 STRING2KEY *s2k,
348 bool create) 348 bool create)
349{ 349{
350 // This function is derived from GnuPG-1.2.5-rc2 350 // This function is derived from GnuPG-1.2.5-rc2
351 gcry_md_hd_t md; 351 gcry_md_hd_t md;
352 gcry_error_t err; 352 gcry_error_t err;
353 bool ret = true; 353 bool ret = true;
354 size_t pass, i; 354 size_t pass, i;
355 size_t used = 0; 355 size_t used = 0;
356 356
357 PWM_ASSERT(s2k->hash_algo); 357 PWM_ASSERT(s2k->hash_algo);
358 BUG_ON(!(dek->keylen > 0 && dek->keylen <= array_size(dek->key))); 358 BUG_ON(!(dek->keylen > 0 && dek->keylen <= array_size(dek->key)));
359 359
360 err = gcry_md_open(&md, s2k->hash_algo, 0); 360 err = gcry_md_open(&md, s2k->hash_algo, 0);
361 if (err != GPG_ERR_NO_ERROR) { 361 if (err != GPG_ERR_NO_ERROR) {
362 ret = false; 362 ret = false;
363 goto out; 363 goto out;
364 } 364 }
365 for (pass = 0; used < dek->keylen; pass++) { 365 for (pass = 0; used < dek->keylen; pass++) {
366 if (pass) { 366 if (pass) {
367 gcry_md_reset(md); 367 gcry_md_reset(md);
368 for (i = 0; i < pass; i++) // preset the hash context 368 for (i = 0; i < pass; i++) // preset the hash context
369 gcry_md_putc(md, 0); 369 gcry_md_putc(md, 0);
370 } 370 }
371 if (s2k->mode == 1 || s2k->mode == 3) { 371 if (s2k->mode == 1 || s2k->mode == 3) {
372 size_t len2 = pwlen + 8; 372 size_t len2 = pwlen + 8;
373 size_t count = len2; 373 size_t count = len2;
374 374
375 if (create && !pass) { 375 if (create && !pass) {
376 Randomizer *rnd = Randomizer::obj(); 376 Randomizer *rnd = Randomizer::obj();
377 const unsigned int salt_len = 8; 377 const unsigned int salt_len = 8;
378 string rndBuf(rnd->genRndBuf(salt_len)); 378 string rndBuf(rnd->genRndBuf(salt_len));
379 memcpy(s2k->salt, rndBuf.c_str(), salt_len); 379 memcpy(s2k->salt, rndBuf.c_str(), salt_len);
380 if (s2k->mode == 3) 380 if (s2k->mode == 3)
381 s2k->count = 96; // 65536 iterations 381 s2k->count = 96; // 65536 iterations
382 } 382 }
383 if (s2k->mode == 3) { 383 if (s2k->mode == 3) {
384 count = (16ul + (s2k->count & 15)) << ((s2k->count >> 4) + 6); 384 count = (16ul + (s2k->count & 15)) << ((s2k->count >> 4) + 6);
385 if (count < len2) 385 if (count < len2)
386 count = len2; 386 count = len2;
387 } 387 }
388 // a little bit complicated because we need a ulong for count 388 // a little bit complicated because we need a ulong for count
389 while (count > len2) { // maybe iterated+salted 389 while (count > len2) { // maybe iterated+salted
390 gcry_md_write(md, s2k->salt, 8); 390 gcry_md_write(md, s2k->salt, 8);
391 gcry_md_write(md, pw, pwlen); 391 gcry_md_write(md, pw, pwlen);
392 count -= len2; 392 count -= len2;
393 } 393 }
394 if (count < 8) { 394 if (count < 8) {
395 gcry_md_write(md, s2k->salt, count); 395 gcry_md_write(md, s2k->salt, count);
396 } else { 396 } else {
397 gcry_md_write(md, s2k->salt, 8); 397 gcry_md_write(md, s2k->salt, 8);
398 count -= 8; 398 count -= 8;
399 gcry_md_write(md, pw, count); 399 gcry_md_write(md, pw, count);
400 } 400 }
401 } else 401 } else
402 gcry_md_write(md, pw, pwlen); 402 gcry_md_write(md, pw, pwlen);
403 gcry_md_final(md); 403 gcry_md_final(md);
404 i = gcry_md_get_algo_dlen(s2k->hash_algo); 404 i = gcry_md_get_algo_dlen(s2k->hash_algo);
405 if (i > dek->keylen - used) 405 if (i > dek->keylen - used)
406 i = dek->keylen - used; 406 i = dek->keylen - used;
407 memcpy(dek->key+used, gcry_md_read(md, s2k->hash_algo), i); 407 memcpy(dek->key+used, gcry_md_read(md, s2k->hash_algo), i);
408 used += i; 408 used += i;
409 } 409 }
410 gcry_md_close(md); 410 gcry_md_close(md);
411out: 411out:
412 return ret; 412 return ret;
413} 413}
414 414
415void LibGCryptIf::padData(unsigned char *buf, 415void LibGCryptIf::padData(unsigned char *buf,
416 size_t bufLen, 416 size_t bufLen,
417 size_t boundary) 417 size_t boundary)
418{ 418{
419 size_t numPadBytes = boundary - ((bufLen + 1) % boundary); 419 size_t numPadBytes = boundary - ((bufLen + 1) % boundary);
420 buf[bufLen] = static_cast<char>(0x01); 420 buf[bufLen] = static_cast<char>(0x01);
421 size_t i = 0; 421 size_t i = 0;
422 Randomizer *rnd = Randomizer::obj(); 422 Randomizer *rnd = Randomizer::obj();
423 char c; 423 char c;
424 unsigned char *b; 424 unsigned char *b;
425 while (i < numPadBytes) { 425 while (i < numPadBytes) {
426 c = rnd->genRndChar(); 426 c = rnd->genRndChar();
427 if (c == static_cast<char>(0x01)) 427 if (c == static_cast<char>(0x01))
428 continue; 428 continue;
429 b = buf + bufLen + 1 + i; 429 b = buf + bufLen + 1 + i;
430 *b = c; 430 *b = c;
431 ++i; 431 ++i;
432 } 432 }
433} 433}
434 434
435void LibGCryptIf::unpadData(const unsigned char *buf, 435void LibGCryptIf::unpadData(const unsigned char *buf,
436 size_t *bufLen) 436 size_t *bufLen)
437{ 437{
438 size_t pos; 438 size_t pos;
439 BUG_ON(*bufLen % 8); 439 BUG_ON(*bufLen % 8);
440 pos = *bufLen - 1; 440 pos = *bufLen - 1;
441 while (buf[pos] != static_cast<char>(0x01)) { 441 while (buf[pos] != static_cast<char>(0x01)) {
442 qDebug("pos %d %d %d", pos, buf[pos], static_cast<char>(0x01) );
442 BUG_ON(!pos); 443 BUG_ON(!pos);
444 //LR BUG we should terminte the loop if p == 0
445 if ( pos == 0 )
446 break;
443 --pos; 447 --pos;
444 } 448 }
445 *bufLen = pos; 449 *bufLen = pos;
450 qDebug("ente ");
446} 451}
447 452
448#endif // CONFIG_PWMANAGER_GCRY 453#endif // CONFIG_PWMANAGER_GCRY
449 454
diff --git a/pwmanager/pwmanager/main.cpp b/pwmanager/pwmanager/main.cpp
index 1ca7ba8..70df15d 100644
--- a/pwmanager/pwmanager/main.cpp
+++ b/pwmanager/pwmanager/main.cpp
@@ -1,219 +1,220 @@
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
36int PwMApplication::newInstance() 36int 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
52static const char *description = I18N_NOOP("PwManager\n" 52static 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
56static KCmdLineOptions options[] = 56static 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
68static void printDebugConfigureInfo() 68static 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#ifdef WORDS_BIGENDIAN 87#ifdef WORDS_BIGENDIAN
88 cout << "Endianess 2: big-endian" << endl; 88 cout << "Endianess 2: big-endian" << endl;
89#else 89#else
90 cout << "Endianess 2: little-endian" << endl; 90 cout << "Endianess 2: little-endian" << endl;
91#endif 91#endif
92 92
93 cout << "sizeof(long): " << sizeof(long) << endl; 93 cout << "sizeof(long): " << sizeof(long) << endl;
94 cout << "================================" << endl; 94 cout << "================================" << endl;
95} 95}
96#else // PWM_DEBUG 96#else // PWM_DEBUG
97static inline void printDebugConfigureInfo() { /* nothing */ } 97static inline void printDebugConfigureInfo() { /* nothing */ }
98#endif // PWM_DEBUG 98#endif // PWM_DEBUG
99 99
100#ifndef PWM_EMBEDDED 100#ifndef PWM_EMBEDDED
101static void addAuthors(KAboutData *aboutData) 101static void addAuthors(KAboutData *aboutData)
102{ 102{
103 aboutData->addAuthor("Michael Buesch", 103 aboutData->addAuthor("Michael Buesch",
104 I18N_NOOP( 104 I18N_NOOP(
105 "main programming and current maintainer"), 105 "main programming and current maintainer"),
106 "mbuesch@freenet.de"); 106 "mbuesch@freenet.de");
107 aboutData->addAuthor("Matt Scifo", 107 aboutData->addAuthor("Matt Scifo",
108 I18N_NOOP( 108 I18N_NOOP(
109 "original implementaion of \n" 109 "original implementaion of \n"
110 "\"categories\" and the password-tree \n" 110 "\"categories\" and the password-tree \n"
111 "in the system-tray. Original implementations of \n" 111 "in the system-tray. Original implementations of \n"
112 "numerous view-improvements."), 112 "numerous view-improvements."),
113 "mscifo@o1.com"); 113 "mscifo@o1.com");
114 aboutData->addCredit("Elias Probst", 114 aboutData->addCredit("Elias Probst",
115 I18N_NOOP( 115 I18N_NOOP(
116 "Gentoo ebuild maintainer."), 116 "Gentoo ebuild maintainer."),
117 "elias.probst@gmx.de"); 117 "elias.probst@gmx.de");
118 aboutData->addCredit("George Staikos", 118 aboutData->addCredit("George Staikos",
119 I18N_NOOP("KWallet"), 119 I18N_NOOP("KWallet"),
120 "staikos@kde.org"); 120 "staikos@kde.org");
121 aboutData->addCredit("Matthew Palmer", 121 aboutData->addCredit("Matthew Palmer",
122 I18N_NOOP("rc2 code"), 122 I18N_NOOP("rc2 code"),
123 "mjp16@uow.edu.au"); 123 "mjp16@uow.edu.au");
124 aboutData->addCredit("Olivier Sessink", 124 aboutData->addCredit("Olivier Sessink",
125 I18N_NOOP("gpasman"), 125 I18N_NOOP("gpasman"),
126 "gpasman@nl.linux.org"); 126 "gpasman@nl.linux.org");
127 aboutData->addCredit("The libgcrypt developers", 127 aboutData->addCredit("The libgcrypt developers",
128 I18N_NOOP("Blowfish and SHA1 algorithms"), 128 I18N_NOOP("Blowfish and SHA1 algorithms"),
129 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/"); 129 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/");
130 aboutData->addCredit("Troy Engel", 130 aboutData->addCredit("Troy Engel",
131 I18N_NOOP("kpasman"), 131 I18N_NOOP("kpasman"),
132 "tengel@sonic.net"); 132 "tengel@sonic.net");
133 aboutData->addCredit("Wickey", 133 aboutData->addCredit("Wickey",
134 I18N_NOOP("graphics-design in older versions."), 134 I18N_NOOP("graphics-design in older versions."),
135 "wickey@gmx.at"); 135 "wickey@gmx.at");
136 aboutData->addCredit("Ian MacGregor", 136 aboutData->addCredit("Ian MacGregor",
137 I18N_NOOP( 137 I18N_NOOP(
138 "original documentation author.")); 138 "original documentation author."));
139} 139}
140#endif 140#endif
141 141
142int main(int argc, char *argv[]) 142int main(int argc, char *argv[])
143{ 143{
144 printDebugConfigureInfo(); 144 printDebugConfigureInfo();
145#ifndef PWM_EMBEDDED 145#ifndef PWM_EMBEDDED
146 KAboutData aboutData(PACKAGE_NAME, PROG_NAME, 146 KAboutData aboutData(PACKAGE_NAME, PROG_NAME,
147 PACKAGE_VER, description, KAboutData::License_File, 147 PACKAGE_VER, description, KAboutData::License_File,
148 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0, 148 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0,
149 "http://passwordmanager.sourceforge.net/", 149 "http://passwordmanager.sourceforge.net/",
150 "mbuesch@freenet.de"); 150 "mbuesch@freenet.de");
151 addAuthors(&aboutData); 151 addAuthors(&aboutData);
152 152
153 KCmdLineArgs::init(argc, argv, &aboutData); 153 KCmdLineArgs::init(argc, argv, &aboutData);
154 KCmdLineArgs::addCmdLineOptions(options); 154 KCmdLineArgs::addCmdLineOptions(options);
155 155
156 KUniqueApplication::addCmdLineOptions(); 156 KUniqueApplication::addCmdLineOptions();
157 if (!KUniqueApplication::start()) { 157 if (!KUniqueApplication::start()) {
158 printInfo("already running."); 158 printInfo("already running.");
159 return EXIT_SUCCESS; 159 return EXIT_SUCCESS;
160 } 160 }
161 PwMApplication a; 161 PwMApplication a;
162 aboutData.setLicenseTextFile(LICENSE_FILE); 162 aboutData.setLicenseTextFile(LICENSE_FILE);
163 return a.exec(); 163 return a.exec();
164#else 164#else
165 165
166 bool exitHelp = false; 166 bool exitHelp = false;
167 if ( argc > 1 ) { 167 if ( argc > 1 ) {
168 QString command = argv[1]; 168 QString command = argv[1];
169 if ( command == "-help" ){ 169 if ( command == "-help" ){
170 printf("PWM/PI command line commands:\n"); 170 printf("PWM/PI command line commands:\n");
171 printf(" no command: Start PWM/PI in usual way\n"); 171 printf(" no command: Start PWM/PI in usual way\n");
172 printf(" -help: This output\n"); 172 printf(" -help: This output\n");
173 printf(" PWM/PI is exiting now. Bye!\n"); 173 printf(" PWM/PI is exiting now. Bye!\n");
174 exitHelp = true; 174 exitHelp = true;
175 } 175 }
176 } 176 }
177 if ( ! exitHelp ) { 177 if ( ! exitHelp ) {
178 178
179 PwMApplication a(argc, argv); 179 PwMApplication a(argc, argv);
180 180
181 KGlobal::setAppName( "pwmanager" ); 181 KGlobal::setAppName( "pwmanager" );
182#ifndef DESKTOP_VERSION 182#ifndef DESKTOP_VERSION
183 //qDebug("width %d ",QApplication::desktop()->width() ); 183 //qDebug("width %d ",QApplication::desktop()->width() );
184 if ( QApplication::desktop()->width() > 320 ) 184 if ( QApplication::desktop()->width() > 320 )
185 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/"); 185 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/");
186 else 186 else
187 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/"); 187 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/");
188#else 188#else
189 QString fileName ; 189 QString fileName ;
190 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/"; 190 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/";
191 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 191 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
192 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 192 QApplication::addLibraryPath ( qApp->applicationDirPath () );
193 193
194#endif 194#endif
195 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager"))); 195 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager")));
196 KPimGlobalPrefs::instance()->setGlobalConfig(); 196 KPimGlobalPrefs::instance()->setGlobalConfig();
197 197
198 a.newInstance(); 198 a.newInstance();
199 199
200 //US KAddressBookMain m ; 200 //US KAddressBookMain m ;
201 201
202 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 202 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
203 /*US 203 /*US
204#ifndef DESKTOP_VERSION 204#ifndef DESKTOP_VERSION
205 a.showMainWidget( &m ); 205 a.showMainWidget( &m );
206#else 206#else
207 a.setMainWidget( &m ); 207 a.setMainWidget( &m );
208 m.resize (640, 480 ); 208 m.resize (640, 480 );
209 m.show(); 209 m.show();
210#endif 210#endif
211 */ 211 */
212 QObject::connect( &a, SIGNAL( lastWindowClosed()), &a, SLOT (quit()));
212 a.exec(); 213 a.exec();
213 KPimGlobalPrefs::instance()->writeConfig(); 214 KPimGlobalPrefs::instance()->writeConfig();
214 } 215 }
215 qDebug("PWMPI: Bye! "); 216 qDebug("PWMPI: Bye! ");
216 217
217#endif 218#endif
218 219
219} 220}
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 1ab2b71..2b8f2fa 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1,1278 +1,1284 @@
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#include <klocale.h> 20#include <klocale.h>
21#include <klistview.h> 21#include <klistview.h>
22#include <ktoolbar.h> 22#include <ktoolbar.h>
23#include <kfiledialog.h> 23#include <kfiledialog.h>
24#include <kiconloader.h> 24#include <kiconloader.h>
25#include <kmessagebox.h> 25#include <kmessagebox.h>
26 26
27#include <qstatusbar.h> 27#include <qstatusbar.h>
28 28
29#ifndef PWM_EMBEDDED 29#ifndef PWM_EMBEDDED
30#include <kmenubar.h> 30#include <kmenubar.h>
31#include <kstatusbar.h> 31#include <kstatusbar.h>
32#include <dcopclient.h> 32#include <dcopclient.h>
33#include "configwndimpl.h" 33#include "configwndimpl.h"
34#include "configuration.h" 34#include "configuration.h"
35#else 35#else
36#include <qmenubar.h> 36#include <qmenubar.h>
37#include <qmessagebox.h> 37#include <qmessagebox.h>
38#include <pwmprefs.h> 38#include <pwmprefs.h>
39#include <kpimglobalprefs.h> 39#include <kpimglobalprefs.h>
40#include <kcmconfigs/kcmpwmconfig.h> 40#include <kcmconfigs/kcmpwmconfig.h>
41#include <kcmconfigs/kcmkdepimconfig.h> 41#include <kcmconfigs/kcmkdepimconfig.h>
42#include <kcmultidialog.h> 42#include <kcmultidialog.h>
43#endif 43#endif
44 44
45 45
46#ifndef DESKTOP_VERSION 46#ifndef DESKTOP_VERSION
47#include <qpe/global.h> 47#include <qpe/global.h>
48#endif 48#endif
49 49
50#include <qpixmap.h> 50#include <qpixmap.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52#include <qspinbox.h> 52#include <qspinbox.h>
53#include <qlineedit.h> 53#include <qlineedit.h>
54#include <qfileinfo.h> 54#include <qfileinfo.h>
55#include <qclipboard.h> 55#include <qclipboard.h>
56 56
57 57
58#include <stdio.h> 58#include <stdio.h>
59 59
60#include "pwm.h" 60#include "pwm.h"
61#include "pwminit.h" 61#include "pwminit.h"
62#include "pwmprint.h" 62#include "pwmprint.h"
63#include "addentrywndimpl.h" 63#include "addentrywndimpl.h"
64#include "globalstuff.h" 64#include "globalstuff.h"
65#include "findwndimpl.h" 65#include "findwndimpl.h"
66#include "csv.h" 66#include "csv.h"
67 67
68#ifdef CONFIG_KWALLETIF 68#ifdef CONFIG_KWALLETIF
69# include "kwalletif.h" 69# include "kwalletif.h"
70# include "kwalletemu.h" 70# include "kwalletemu.h"
71#endif 71#endif
72#ifdef CONFIG_KEYCARD 72#ifdef CONFIG_KEYCARD
73# include "pwmkeycard.h" 73# include "pwmkeycard.h"
74#endif 74#endif
75 75
76 76
77 #define DEFAULT_SIZE (QSize(700, 400)) 77 #define DEFAULT_SIZE (QSize(700, 400))
78 78
79// Button IDs for "file" popup menu 79// Button IDs for "file" popup menu
80enum { 80enum {
81 BUTTON_POPUP_FILE_NEW = 0, 81 BUTTON_POPUP_FILE_NEW = 0,
82 BUTTON_POPUP_FILE_OPEN, 82 BUTTON_POPUP_FILE_OPEN,
83 BUTTON_POPUP_FILE_CLOSE, 83 BUTTON_POPUP_FILE_CLOSE,
84 BUTTON_POPUP_FILE_SAVE, 84 BUTTON_POPUP_FILE_SAVE,
85 BUTTON_POPUP_FILE_SAVEAS, 85 BUTTON_POPUP_FILE_SAVEAS,
86 BUTTON_POPUP_FILE_EXPORT, 86 BUTTON_POPUP_FILE_EXPORT,
87 BUTTON_POPUP_FILE_IMPORT, 87 BUTTON_POPUP_FILE_IMPORT,
88 BUTTON_POPUP_FILE_PRINT, 88 BUTTON_POPUP_FILE_PRINT,
89 BUTTON_POPUP_FILE_QUIT 89 BUTTON_POPUP_FILE_QUIT
90}; 90};
91// Button IDs for "manage" popup menu 91// Button IDs for "manage" popup menu
92enum { 92enum {
93 BUTTON_POPUP_MANAGE_ADD = 0, 93 BUTTON_POPUP_MANAGE_ADD = 0,
94 BUTTON_POPUP_MANAGE_EDIT, 94 BUTTON_POPUP_MANAGE_EDIT,
95 BUTTON_POPUP_MANAGE_DEL, 95 BUTTON_POPUP_MANAGE_DEL,
96 BUTTON_POPUP_MANAGE_CHANGEMP 96 BUTTON_POPUP_MANAGE_CHANGEMP
97}; 97};
98// Button IDs for chipcard popup menu 98// Button IDs for chipcard popup menu
99enum { 99enum {
100#ifdef CONFIG_KEYCARD 100#ifdef CONFIG_KEYCARD
101 BUTTON_POPUP_CHIPCARD_GENNEW = 0, 101 BUTTON_POPUP_CHIPCARD_GENNEW = 0,
102 BUTTON_POPUP_CHIPCARD_DEL, 102 BUTTON_POPUP_CHIPCARD_DEL,
103 BUTTON_POPUP_CHIPCARD_READID, 103 BUTTON_POPUP_CHIPCARD_READID,
104 BUTTON_POPUP_CHIPCARD_SAVEBACKUP, 104 BUTTON_POPUP_CHIPCARD_SAVEBACKUP,
105 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP 105 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP
106#else // CONFIG_KEYCARD 106#else // CONFIG_KEYCARD
107 BUTTON_POPUP_CHIPCARD_NO = 0 107 BUTTON_POPUP_CHIPCARD_NO = 0
108#endif // CONFIG_KEYCARD 108#endif // CONFIG_KEYCARD
109}; 109};
110// Button IDs for "view" popup menu 110// Button IDs for "view" popup menu
111enum { 111enum {
112 BUTTON_POPUP_VIEW_FIND = 0, 112 BUTTON_POPUP_VIEW_FIND = 0,
113 BUTTON_POPUP_VIEW_LOCK, 113 BUTTON_POPUP_VIEW_LOCK,
114 BUTTON_POPUP_VIEW_DEEPLOCK, 114 BUTTON_POPUP_VIEW_DEEPLOCK,
115 BUTTON_POPUP_VIEW_UNLOCK 115 BUTTON_POPUP_VIEW_UNLOCK
116}; 116};
117// Button IDs for "options" popup menu 117// Button IDs for "options" popup menu
118enum { 118enum {
119 BUTTON_POPUP_OPTIONS_CONFIG = 0 119 BUTTON_POPUP_OPTIONS_CONFIG = 0
120}; 120};
121// Button IDs for "export" popup menu (in "file" popup menu) 121// Button IDs for "export" popup menu (in "file" popup menu)
122enum { 122enum {
123 BUTTON_POPUP_EXPORT_TEXT = 0, 123 BUTTON_POPUP_EXPORT_TEXT = 0,
124 BUTTON_POPUP_EXPORT_GPASMAN, 124 BUTTON_POPUP_EXPORT_GPASMAN,
125 BUTTON_POPUP_EXPORT_CSV 125 BUTTON_POPUP_EXPORT_CSV
126#ifdef CONFIG_KWALLETIF 126#ifdef CONFIG_KWALLETIF
127 ,BUTTON_POPUP_EXPORT_KWALLET 127 ,BUTTON_POPUP_EXPORT_KWALLET
128#endif 128#endif
129}; 129};
130// Button IDs for "import" popup menu (in "file" popup menu) 130// Button IDs for "import" popup menu (in "file" popup menu)
131enum { 131enum {
132 BUTTON_POPUP_IMPORT_TEXT = 0, 132 BUTTON_POPUP_IMPORT_TEXT = 0,
133 BUTTON_POPUP_IMPORT_GPASMAN, 133 BUTTON_POPUP_IMPORT_GPASMAN,
134 BUTTON_POPUP_IMPORT_CSV 134 BUTTON_POPUP_IMPORT_CSV
135#ifdef CONFIG_KWALLETIF 135#ifdef CONFIG_KWALLETIF
136 ,BUTTON_POPUP_IMPORT_KWALLET 136 ,BUTTON_POPUP_IMPORT_KWALLET
137#endif 137#endif
138}; 138};
139 139
140#ifdef PWM_EMBEDDED 140#ifdef PWM_EMBEDDED
141// Button IDs for "help" popup menu 141// Button IDs for "help" popup menu
142enum { 142enum {
143 BUTTON_POPUP_HELP_LICENSE = 0, 143 BUTTON_POPUP_HELP_LICENSE = 0,
144 BUTTON_POPUP_HELP_FAQ, 144 BUTTON_POPUP_HELP_FAQ,
145 BUTTON_POPUP_HELP_ABOUT, 145 BUTTON_POPUP_HELP_ABOUT,
146 BUTTON_POPUP_HELP_SYNC, 146 BUTTON_POPUP_HELP_SYNC,
147 BUTTON_POPUP_HELP_WHATSNEW 147 BUTTON_POPUP_HELP_WHATSNEW
148}; 148};
149#endif 149#endif
150 150
151// Button IDs for toolbar 151// Button IDs for toolbar
152enum { 152enum {
153 BUTTON_TOOL_NEW = 0, 153 BUTTON_TOOL_NEW = 0,
154 BUTTON_TOOL_OPEN, 154 BUTTON_TOOL_OPEN,
155 BUTTON_TOOL_SAVE, 155 BUTTON_TOOL_SAVE,
156 BUTTON_TOOL_SAVEAS, 156 BUTTON_TOOL_SAVEAS,
157 BUTTON_TOOL_PRINT, 157 BUTTON_TOOL_PRINT,
158 BUTTON_TOOL_ADD, 158 BUTTON_TOOL_ADD,
159 BUTTON_TOOL_EDIT, 159 BUTTON_TOOL_EDIT,
160 BUTTON_TOOL_DEL, 160 BUTTON_TOOL_DEL,
161 BUTTON_TOOL_FIND, 161 BUTTON_TOOL_FIND,
162 BUTTON_TOOL_LOCK, 162 BUTTON_TOOL_LOCK,
163 BUTTON_TOOL_DEEPLOCK, 163 BUTTON_TOOL_DEEPLOCK,
164 BUTTON_TOOL_UNLOCK 164 BUTTON_TOOL_UNLOCK
165}; 165};
166 166
167 167
168PwM::PwM(PwMInit *_init, PwMDoc *doc, 168PwM::PwM(PwMInit *_init, PwMDoc *doc,
169 bool virginity, 169 bool virginity,
170 QWidget *parent, const char *name) 170 QWidget *parent, const char *name)
171 : KMainWindow(parent, "HALLO") 171 : KMainWindow(parent, "HALLO")
172 , forceQuit (false) 172 , forceQuit (false)
173 , forceMinimizeToTray (false) 173 , forceMinimizeToTray (false)
174{ 174{
175 syncManager = 0; 175 syncManager = 0;
176 virgin = !virginity; 176 virgin = !virginity;
177 init = _init; 177 init = _init;
178 connect(doc, SIGNAL(docClosed(PwMDoc *)), 178 connect(doc, SIGNAL(docClosed(PwMDoc *)),
179 this, SLOT(docClosed(PwMDoc *))); 179 this, SLOT(docClosed(PwMDoc *)));
180 initMenubar(); 180 initMenubar();
181 initToolbar(); 181 initToolbar();
182 initMetrics(); 182 initMetrics();
183 setVirgin(virginity); 183 setVirgin(virginity);
184 setFocusPolicy(QWidget::WheelFocus); 184 setFocusPolicy(QWidget::WheelFocus);
185#ifndef PWM_EMBEDDED 185#ifndef PWM_EMBEDDED
186 statusBar()->show(); 186 statusBar()->show();
187#endif 187#endif
188 view = makeNewListView(doc); 188 view = makeNewListView(doc);
189 setCentralWidget(view); 189 setCentralWidget(view);
190 updateCaption(); 190 updateCaption();
191 showStatMsg(i18n("Ready.")); 191 showStatMsg(i18n("Ready."));
192} 192}
193 193
194PwM::~PwM() 194PwM::~PwM()
195{ 195{
196 //qDebug("PwM::~PwM()"); 196 qDebug("PwM::~PwM() %x", this);
197 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), 197 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)),
198 this, SLOT(docClosed(PwMDoc *))); 198 this, SLOT(docClosed(PwMDoc *)));
199 conf()->confWndMainWndSize(size()); 199 conf()->confWndMainWndSize(size());
200 emit closed(this); 200 //LR closing of windows changed
201 //needed for fastload option on PDA
202 //emit closed(this);
201 //qDebug("PwM::~PwM() emited closed(this)"); 203 //qDebug("PwM::~PwM() emited closed(this)");
202 delete view; 204 delete view;
203 delete syncManager; 205 delete syncManager;
204} 206}
205 207
206void PwM::initMenubar() 208void PwM::initMenubar()
207{ 209{
208 KIconLoader* picons; 210 KIconLoader* picons;
209#ifndef PWM_EMBEDDED 211#ifndef PWM_EMBEDDED
210 KIconLoader icons; 212 KIconLoader icons;
211 picons = &icons; 213 picons = &icons;
212#else 214#else
213 picons = KGlobal::iconLoader(); 215 picons = KGlobal::iconLoader();
214 216
215 217
216 syncPopup = new KPopupMenu(this); 218 syncPopup = new KPopupMenu(this);
217 219
218 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup); 220 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup);
219 syncManager->setBlockSave(false); 221 syncManager->setBlockSave(false);
220 222
221 connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 223 connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
222 syncManager->fillSyncMenu(); 224 syncManager->fillSyncMenu();
223 225
224#endif 226#endif
225 filePopup = new KPopupMenu(this); 227 filePopup = new KPopupMenu(this);
226 importPopup = new KPopupMenu(filePopup); 228 importPopup = new KPopupMenu(filePopup);
227 exportPopup = new KPopupMenu(filePopup); 229 exportPopup = new KPopupMenu(filePopup);
228 managePopup = new KPopupMenu(this); 230 managePopup = new KPopupMenu(this);
229#ifdef CONFIG_KEYCARD 231#ifdef CONFIG_KEYCARD
230 chipcardPopup = new KPopupMenu(this); 232 chipcardPopup = new KPopupMenu(this);
231#endif // CONFIG_KEYCARD 233#endif // CONFIG_KEYCARD
232 viewPopup = new KPopupMenu(this); 234 viewPopup = new KPopupMenu(this);
233 optionsPopup = new KPopupMenu(this); 235 optionsPopup = new KPopupMenu(this);
234 236
235// "file" popup menu 237// "file" popup menu
236 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 238 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
237 i18n("&New"), this, 239 i18n("&New"), this,
238 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); 240 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW);
239 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), 241 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)),
240 i18n("&Open"), this, 242 i18n("&Open"), this,
241 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); 243 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN);
242 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), 244 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)),
243 i18n("&Close"), this, 245 i18n("&Close"), this,
244 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); 246 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE);
245 filePopup->insertSeparator(); 247 filePopup->insertSeparator();
246 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), 248 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)),
247 i18n("&Save"), this, 249 i18n("&Save"), this,
248 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); 250 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE);
249 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), 251 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)),
250 i18n("Save &as..."), 252 i18n("Save &as..."),
251 this, SLOT(saveAs_slot()), 0, 253 this, SLOT(saveAs_slot()), 0,
252 BUTTON_POPUP_FILE_SAVEAS); 254 BUTTON_POPUP_FILE_SAVEAS);
253 filePopup->insertSeparator(); 255 filePopup->insertSeparator();
254 // "file/export" popup menu 256 // "file/export" popup menu
255 exportPopup->insertItem(i18n("&Text-file..."), this, 257 exportPopup->insertItem(i18n("&Text-file..."), this,
256 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); 258 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT);
257 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 259 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
258 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); 260 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN);
259 exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 261 exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
260 SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV); 262 SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV);
261#ifdef CONFIG_KWALLETIF 263#ifdef CONFIG_KWALLETIF
262 exportPopup->insertItem(i18n("&KWallet..."), this, 264 exportPopup->insertItem(i18n("&KWallet..."), this,
263 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); 265 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET);
264#endif 266#endif
265 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), 267 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)),
266 i18n("E&xport"), exportPopup, 268 i18n("E&xport"), exportPopup,
267 BUTTON_POPUP_FILE_EXPORT); 269 BUTTON_POPUP_FILE_EXPORT);
268 // "file/import" popup menu 270 // "file/import" popup menu
269 importPopup->insertItem(i18n("&Text-file..."), this, 271 importPopup->insertItem(i18n("&Text-file..."), this,
270 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); 272 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT);
271 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 273 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
272 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); 274 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN);
273 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 275 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
274 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); 276 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV);
275#ifdef CONFIG_KWALLETIF 277#ifdef CONFIG_KWALLETIF
276 importPopup->insertItem(i18n("&KWallet..."), this, 278 importPopup->insertItem(i18n("&KWallet..."), this,
277 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); 279 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET);
278#endif 280#endif
279 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), 281 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)),
280 i18n("I&mport"), importPopup, 282 i18n("I&mport"), importPopup,
281 BUTTON_POPUP_FILE_IMPORT); 283 BUTTON_POPUP_FILE_IMPORT);
282 filePopup->insertSeparator(); 284 filePopup->insertSeparator();
283 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), 285 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)),
284 i18n("&Print..."), this, 286 i18n("&Print..."), this,
285 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); 287 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT);
286 filePopup->insertSeparator(); 288 filePopup->insertSeparator();
287 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), 289 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)),
288 i18n("&Quit"), this, 290 i18n("&Quit"), this,
289 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); 291 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT);
290 menuBar()->insertItem(i18n("&File"), filePopup); 292 menuBar()->insertItem(i18n("&File"), filePopup);
291// "manage" popup menu 293// "manage" popup menu
292 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), 294 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)),
293 i18n("&Add password"), this, 295 i18n("&Add password"), this,
294 SLOT(addPwd_slot()), 0, 296 SLOT(addPwd_slot()), 0,
295 BUTTON_POPUP_MANAGE_ADD); 297 BUTTON_POPUP_MANAGE_ADD);
296 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), 298 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)),
297 i18n("&Edit"), this, SLOT(editPwd_slot()), 0, 299 i18n("&Edit"), this, SLOT(editPwd_slot()), 0,
298 BUTTON_POPUP_MANAGE_EDIT); 300 BUTTON_POPUP_MANAGE_EDIT);
299 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 301 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
300 i18n("&Delete"), this, SLOT(deletePwd_slot()), 302 i18n("&Delete"), this, SLOT(deletePwd_slot()),
301 0, BUTTON_POPUP_MANAGE_DEL); 303 0, BUTTON_POPUP_MANAGE_DEL);
302 managePopup->insertSeparator(); 304 managePopup->insertSeparator();
303 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), 305 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)),
304 i18n("Change &Master Password"), this, 306 i18n("Change &Master Password"), this,
305 SLOT(changeMasterPwd_slot()), 0, 307 SLOT(changeMasterPwd_slot()), 0,
306 BUTTON_POPUP_MANAGE_CHANGEMP); 308 BUTTON_POPUP_MANAGE_CHANGEMP);
307 menuBar()->insertItem(i18n("&Manage"), managePopup); 309 menuBar()->insertItem(i18n("&Manage"), managePopup);
308// "chipcard" popup menu 310// "chipcard" popup menu
309#ifdef CONFIG_KEYCARD 311#ifdef CONFIG_KEYCARD
310 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 312 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
311 i18n("&Generate new key-card"), this, 313 i18n("&Generate new key-card"), this,
312 SLOT(genNewCard_slot()), 0, 314 SLOT(genNewCard_slot()), 0,
313 BUTTON_POPUP_CHIPCARD_GENNEW); 315 BUTTON_POPUP_CHIPCARD_GENNEW);
314 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 316 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
315 i18n("&Erase key-card"), this, 317 i18n("&Erase key-card"), this,
316 SLOT(eraseCard_slot()), 0, 318 SLOT(eraseCard_slot()), 0,
317 BUTTON_POPUP_CHIPCARD_DEL); 319 BUTTON_POPUP_CHIPCARD_DEL);
318 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), 320 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)),
319 i18n("Read card-&ID"), this, 321 i18n("Read card-&ID"), this,
320 SLOT(readCardId_slot()), 0, 322 SLOT(readCardId_slot()), 0,
321 BUTTON_POPUP_CHIPCARD_READID); 323 BUTTON_POPUP_CHIPCARD_READID);
322 chipcardPopup->insertSeparator(); 324 chipcardPopup->insertSeparator();
323 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), 325 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)),
324 i18n("&Make card backup-image"), this, 326 i18n("&Make card backup-image"), this,
325 SLOT(makeCardBackup_slot()), 0, 327 SLOT(makeCardBackup_slot()), 0,
326 BUTTON_POPUP_CHIPCARD_SAVEBACKUP); 328 BUTTON_POPUP_CHIPCARD_SAVEBACKUP);
327 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), 329 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)),
328 i18n("&Replay card backup-image"), this, 330 i18n("&Replay card backup-image"), this,
329 SLOT(replayCardBackup_slot()), 0, 331 SLOT(replayCardBackup_slot()), 0,
330 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); 332 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP);
331 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); 333 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup);
332#endif // CONFIG_KEYCARD 334#endif // CONFIG_KEYCARD
333// "view" popup menu 335// "view" popup menu
334 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), 336 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)),
335 i18n("&Find"), this, 337 i18n("&Find"), this,
336 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); 338 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND);
337 viewPopup->insertSeparator(); 339 viewPopup->insertSeparator();
338 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), 340 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)),
339 i18n("&Lock all entries"), this, 341 i18n("&Lock all entries"), this,
340 SLOT(lockWnd_slot()), 0, 342 SLOT(lockWnd_slot()), 0,
341 BUTTON_POPUP_VIEW_LOCK); 343 BUTTON_POPUP_VIEW_LOCK);
342 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), 344 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)),
343 i18n("&Deep-lock all entries"), this, 345 i18n("&Deep-lock all entries"), this,
344 SLOT(deepLockWnd_slot()), 0, 346 SLOT(deepLockWnd_slot()), 0,
345 BUTTON_POPUP_VIEW_DEEPLOCK); 347 BUTTON_POPUP_VIEW_DEEPLOCK);
346 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), 348 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)),
347 i18n("&Unlock all entries"), this, 349 i18n("&Unlock all entries"), this,
348 SLOT(unlockWnd_slot()), 0, 350 SLOT(unlockWnd_slot()), 0,
349 BUTTON_POPUP_VIEW_UNLOCK); 351 BUTTON_POPUP_VIEW_UNLOCK);
350 menuBar()->insertItem(i18n("&View"), viewPopup); 352 menuBar()->insertItem(i18n("&View"), viewPopup);
351// "options" popup menu 353// "options" popup menu
352 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 354 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
353 i18n("&Configure..."), this, 355 i18n("&Configure..."), this,
354 SLOT(config_slot()), 356 SLOT(config_slot()),
355 BUTTON_POPUP_OPTIONS_CONFIG); 357 BUTTON_POPUP_OPTIONS_CONFIG);
356 menuBar()->insertItem(i18n("&Options"), optionsPopup); 358 menuBar()->insertItem(i18n("&Options"), optionsPopup);
357// "help" popup menu 359// "help" popup menu
358#ifndef PWM_EMBEDDED 360#ifndef PWM_EMBEDDED
359 helpPopup = helpMenu(QString::null, false); 361 helpPopup = helpMenu(QString::null, false);
360#else 362#else
361 menuBar()->insertItem(i18n("&Sync"), syncPopup); 363 menuBar()->insertItem(i18n("&Sync"), syncPopup);
362 364
363 365
364 366
365 367
366 368
367 helpPopup = new KPopupMenu(this); 369 helpPopup = new KPopupMenu(this);
368 370
369 371
370 helpPopup->insertItem(i18n("&License"), this, 372 helpPopup->insertItem(i18n("&License"), this,
371 SLOT(showLicense_slot()), 0, 373 SLOT(showLicense_slot()), 0,
372 BUTTON_POPUP_HELP_LICENSE); 374 BUTTON_POPUP_HELP_LICENSE);
373 375
374 helpPopup->insertItem(i18n("&Faq"), this, 376 helpPopup->insertItem(i18n("&Faq"), this,
375 SLOT(faq_slot()), 0, 377 SLOT(faq_slot()), 0,
376 BUTTON_POPUP_HELP_FAQ); 378 BUTTON_POPUP_HELP_FAQ);
377 379
378 helpPopup->insertItem(i18n("&About PwManager"), this, 380 helpPopup->insertItem(i18n("&About PwManager"), this,
379 SLOT(createAboutData_slot()), 0, 381 SLOT(createAboutData_slot()), 0,
380 BUTTON_POPUP_HELP_ABOUT); 382 BUTTON_POPUP_HELP_ABOUT);
381 383
382 helpPopup->insertItem(i18n("&Sync HowTo"), this, 384 helpPopup->insertItem(i18n("&Sync HowTo"), this,
383 SLOT(syncHowTo_slot()), 0, 385 SLOT(syncHowTo_slot()), 0,
384 BUTTON_POPUP_HELP_SYNC); 386 BUTTON_POPUP_HELP_SYNC);
385 387
386 helpPopup->insertItem(i18n("&What's New"), this, 388 helpPopup->insertItem(i18n("&What's New"), this,
387 SLOT(whatsnew_slot()), 0, 389 SLOT(whatsnew_slot()), 0,
388 BUTTON_POPUP_HELP_WHATSNEW); 390 BUTTON_POPUP_HELP_WHATSNEW);
389 391
390#endif 392#endif
391 menuBar()->insertItem(i18n("&Help"), helpPopup); 393 menuBar()->insertItem(i18n("&Help"), helpPopup);
392 394
393} 395}
394 396
395void PwM::initToolbar() 397void PwM::initToolbar()
396{ 398{
397 KIconLoader* picons; 399 KIconLoader* picons;
398#ifndef PWM_EMBEDDED 400#ifndef PWM_EMBEDDED
399 KIconLoader icons; 401 KIconLoader icons;
400 picons = &icons; 402 picons = &icons;
401#else 403#else
402 picons = KGlobal::iconLoader(); 404 picons = KGlobal::iconLoader();
403#endif 405#endif
404 406
405#ifdef PWM_EMBEDDED 407#ifdef PWM_EMBEDDED
406 if ( QApplication::desktop()->width() > 320 ) 408 if ( QApplication::desktop()->width() > 320 )
407#endif 409#endif
408 { 410 {
409 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), 411 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar),
410 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, 412 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this,
411 SLOT(new_slot()), true, i18n("New")); 413 SLOT(new_slot()), true, i18n("New"));
412 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), 414 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar),
413 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, 415 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this,
414 SLOT(open_slot()), true, i18n("Open")); 416 SLOT(open_slot()), true, i18n("Open"));
415 toolBar()->insertSeparator(); 417 toolBar()->insertSeparator();
416 } 418 }
417 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), 419 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar),
418 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, 420 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this,
419 SLOT(save_slot()), true, i18n("Save")); 421 SLOT(save_slot()), true, i18n("Save"));
420 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), 422 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar),
421 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, 423 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this,
422 SLOT(saveAs_slot()), true, i18n("Save as")); 424 SLOT(saveAs_slot()), true, i18n("Save as"));
423 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), 425 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar),
424 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, 426 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this,
425 SLOT(print_slot()), true, i18n("Print...")); 427 SLOT(print_slot()), true, i18n("Print..."));
426 toolBar()->insertSeparator(); 428 toolBar()->insertSeparator();
427 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), 429 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar),
428 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, 430 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this,
429 SLOT(addPwd_slot()), true, 431 SLOT(addPwd_slot()), true,
430 i18n("Add password")); 432 i18n("Add password"));
431 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), 433 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar),
432 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, 434 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this,
433 SLOT(editPwd_slot()), true, 435 SLOT(editPwd_slot()), true,
434 i18n("Edit password")); 436 i18n("Edit password"));
435 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), 437 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar),
436 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, 438 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this,
437 SLOT(deletePwd_slot()), true, 439 SLOT(deletePwd_slot()), true,
438 i18n("Delete password")); 440 i18n("Delete password"));
439 toolBar()->insertSeparator(); 441 toolBar()->insertSeparator();
440 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), 442 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar),
441 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, 443 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this,
442 SLOT(find_slot()), true, i18n("Find entry")); 444 SLOT(find_slot()), true, i18n("Find entry"));
443 toolBar()->insertSeparator(); 445 toolBar()->insertSeparator();
444 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), 446 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar),
445 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, 447 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this,
446 SLOT(lockWnd_slot()), true, 448 SLOT(lockWnd_slot()), true,
447 i18n("Lock all entries")); 449 i18n("Lock all entries"));
448 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), 450 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar),
449 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, 451 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this,
450 SLOT(deepLockWnd_slot()), true, 452 SLOT(deepLockWnd_slot()), true,
451 i18n("Deep-Lock all entries")); 453 i18n("Deep-Lock all entries"));
452 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), 454 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar),
453 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, 455 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this,
454 SLOT(unlockWnd_slot()), true, 456 SLOT(unlockWnd_slot()), true,
455 i18n("Unlock all entries")); 457 i18n("Unlock all entries"));
456} 458}
457 459
458void PwM::initMetrics() 460void PwM::initMetrics()
459{ 461{
460 QSize s = conf()->confWndMainWndSize(); 462 QSize s = conf()->confWndMainWndSize();
461 if (s.isValid()) 463 if (s.isValid())
462 resize(s); 464 resize(s);
463 else 465 else
464 resize(DEFAULT_SIZE); 466 resize(DEFAULT_SIZE);
465} 467}
466 468
467void PwM::updateCaption() 469void PwM::updateCaption()
468{ 470{
469 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); 471 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER);
470} 472}
471 473
472void PwM::hideEvent(QHideEvent *) 474void PwM::hideEvent(QHideEvent *)
473{ 475{
474 if (isMinimized()) { 476 if (isMinimized()) {
475 if (init->tray()) { 477 if (init->tray()) {
476 forceMinimizeToTray = true; 478 forceMinimizeToTray = true;
477 close(); 479 close();
478 } 480 }
479 int mmlock = conf()->confGlobMinimizeLock(); 481 int mmlock = conf()->confGlobMinimizeLock();
480 switch (mmlock) { 482 switch (mmlock) {
481 case 0: // don't lock anything 483 case 0: // don't lock anything
482 break; 484 break;
483 case 1: {// normal lock 485 case 1: {// normal lock
484 curDoc()->lockAll(true); 486 curDoc()->lockAll(true);
485 break; 487 break;
486 } case 2: {// deep-lock 488 } case 2: {// deep-lock
487 curDoc()->deepLock(); 489 curDoc()->deepLock();
488 break; 490 break;
489 } default: 491 } default:
490 WARN(); 492 WARN();
491 } 493 }
492 } 494 }
493} 495}
494 496
495void PwM::setVirgin(bool v) 497void PwM::setVirgin(bool v)
496{ 498{
497 if (virgin == v) 499 if (virgin == v)
498 return; 500 return;
499 virgin = v; 501 virgin = v;
500 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); 502 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v);
501 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); 503 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v);
502 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); 504 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v);
503 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); 505 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v);
504 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); 506 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v);
505 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); 507 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v);
506 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); 508 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v);
507 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); 509 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v);
508 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); 510 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v);
509 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); 511 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v);
510 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); 512 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v);
511 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); 513 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v);
512 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); 514 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v);
513 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); 515 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v);
514 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); 516 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v);
515 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); 517 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v);
516 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); 518 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v);
517 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); 519 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v);
518 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); 520 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v);
519 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); 521 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v);
520} 522}
521 523
522void PwM::new_slot() 524void PwM::new_slot()
523{ 525{
524 init->createMainWnd(); 526 init->createMainWnd();
525} 527}
526 528
527//US ENH 529//US ENH
528void PwM::open_slot() 530void PwM::open_slot()
529{ 531{
530 open_slot(""); 532 open_slot("");
531} 533}
532 534
533void PwM::open_slot(QString fn) 535void PwM::open_slot(QString fn)
534{ 536{
535 openDoc(fn); 537 openDoc(fn);
536} 538}
537 539
538PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) 540PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked)
539{ 541{
540 if (!isVirgin()) { 542 if (!isVirgin()) {
541 // open the document in a new window. 543 // open the document in a new window.
542 PwM *newInstance = init->createMainWnd(); 544 PwM *newInstance = init->createMainWnd();
543 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); 545 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked);
544 if (!newDoc) { 546 if (!newDoc) {
545 newInstance->setForceQuit(true); 547 newInstance->setForceQuit(true);
546 delete_and_null(newInstance); 548 delete_and_null(newInstance);
547 } 549 }
548 return newDoc; 550 return newDoc;
549 } 551 }
550 552
551 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) 553 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked))
552 return 0; 554 return 0;
553 showStatMsg(i18n("Successfully opened file.")); 555 showStatMsg(i18n("Successfully opened file."));
554 updateCaption(); 556 updateCaption();
555 setVirgin(false); 557 setVirgin(false);
556 return curDoc(); 558 return curDoc();
557} 559}
558 560
559PwMView * PwM::makeNewListView(PwMDoc *doc) 561PwMView * PwM::makeNewListView(PwMDoc *doc)
560{ 562{
561 PwMView *ret = new PwMView(this, this, doc); 563 PwMView *ret = new PwMView(this, this, doc);
562 ret->setFont(conf()->confGlobEntryFont()); 564 ret->setFont(conf()->confGlobEntryFont());
563 ret->show(); 565 ret->show();
564 return ret; 566 return ret;
565} 567}
566 568
567void PwM::close_slot() 569void PwM::close_slot()
568{ 570{
569 close(); 571 close();
570} 572}
571 573
572void PwM::quitButton_slot() 574void PwM::quitButton_slot()
573{ 575{
574 init->shutdownApp(0); 576 init->shutdownApp(0);
575} 577}
576 578
577void PwM::save_slot() 579void PwM::save_slot()
578{ 580{
579 save(); 581 save();
580} 582}
581 583
582bool PwM::save() 584bool PwM::save()
583{ 585{
584 if (!curDoc()->saveDocUi(curDoc())) 586 if (!curDoc()->saveDocUi(curDoc()))
585 return false; 587 return false;
586 showStatMsg(i18n("Successfully saved data.")); 588 showStatMsg(i18n("Successfully saved data."));
587 updateCaption(); 589 updateCaption();
588 return true; 590 return true;
589} 591}
590 592
591void PwM::saveAs_slot() 593void PwM::saveAs_slot()
592{ 594{
593 saveAs(); 595 saveAs();
594} 596}
595 597
596bool PwM::saveAs() 598bool PwM::saveAs()
597{ 599{
598 if (!curDoc()->saveAsDocUi(curDoc())) 600 if (!curDoc()->saveAsDocUi(curDoc()))
599 return false; 601 return false;
600 showStatMsg(i18n("Successfully saved data.")); 602 showStatMsg(i18n("Successfully saved data."));
601 updateCaption(); 603 updateCaption();
602 return true; 604 return true;
603} 605}
604 606
605//US ENH : changed code to run with older MOC 607//US ENH : changed code to run with older MOC
606void PwM::addPwd_slot() 608void PwM::addPwd_slot()
607{ 609{
608 addPwd_slot1(0, 0); 610 addPwd_slot1(0, 0);
609} 611}
610 612
611void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) 613void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc)
612{ 614{
613 PwMDoc *doc; 615 PwMDoc *doc;
614 if (_doc) { 616 if (_doc) {
615 doc = _doc; 617 doc = _doc;
616 } else { 618 } else {
617 doc = curDoc(); 619 doc = curDoc();
618 } 620 }
619 PWM_ASSERT(doc); 621 PWM_ASSERT(doc);
620 doc->timer()->getLock(DocTimer::id_autoLockTimer); 622 doc->timer()->getLock(DocTimer::id_autoLockTimer);
621#ifndef PWM_EMBEDDED 623#ifndef PWM_EMBEDDED
622 AddEntryWndImpl w; 624 AddEntryWndImpl w;
623#else 625#else
624 AddEntryWndImpl w(this, "addentrywndimpl"); 626 AddEntryWndImpl w(this, "addentrywndimpl");
625#endif 627#endif
626 628
627 vector<string> catList; 629 vector<string> catList;
628 doc->getCategoryList(&catList); 630 doc->getCategoryList(&catList);
629 unsigned i, size = catList.size(); 631 unsigned i, size = catList.size();
630 for (i = 0; i < size; ++i) { 632 for (i = 0; i < size; ++i) {
631 w.addCategory(catList[i].c_str()); 633 w.addCategory(catList[i].c_str());
632 } 634 }
633 w.setCurrCategory(view->getCurrentCategory()); 635 w.setCurrCategory(view->getCurrentCategory());
634 if (pw) 636 if (pw)
635 w.pwLineEdit->setText(*pw); 637 w.pwLineEdit->setText(*pw);
636 638
637 tryAgain: 639 tryAgain:
638 if (w.exec() == 1) 640 if (w.exec() == 1)
639 { 641 {
640 PwMDataItem d; 642 PwMDataItem d;
641 643
642 //US BUG: to initialize all values of curEntr with meaningfulldata, 644 //US BUG: to initialize all values of curEntr with meaningfulldata,
643 // we call clear on it. Reason: Metadata will be uninitialized otherwise. 645 // we call clear on it. Reason: Metadata will be uninitialized otherwise.
644 // another option would be to create a constructor for PwMDataItem 646 // another option would be to create a constructor for PwMDataItem
645 d.clear(true); 647 d.clear(true);
646 648
647 d.desc = w.getDescription().latin1(); 649 d.desc = w.getDescription().latin1();
648 d.name = w.getUsername().latin1(); 650 d.name = w.getUsername().latin1();
649 d.pw = w.getPassword().latin1(); 651 d.pw = w.getPassword().latin1();
650 d.comment = w.getComment().latin1(); 652 d.comment = w.getComment().latin1();
651 d.url = w.getUrl().latin1(); 653 d.url = w.getUrl().latin1();
652 d.launcher = w.getLauncher().latin1(); 654 d.launcher = w.getLauncher().latin1();
653 PwMerror ret = doc->addEntry(w.getCategory(), &d); 655 PwMerror ret = doc->addEntry(w.getCategory(), &d);
654 if (ret == e_entryExists) { 656 if (ret == e_entryExists) {
655 KMessageBox::error(this, 657 KMessageBox::error(this,
656 i18n 658 i18n
657 ("An entry with this \"Description\",\n" 659 ("An entry with this \"Description\",\n"
658 "does already exist.\n" 660 "does already exist.\n"
659 "Please select another description."), 661 "Please select another description."),
660 i18n("entry already exists.")); 662 i18n("entry already exists."));
661 goto tryAgain; 663 goto tryAgain;
662 } else if (ret == e_maxAllowedEntr) { 664 } else if (ret == e_maxAllowedEntr) {
663 KMessageBox::error(this, i18n("The maximum possible number of\nentries" 665 KMessageBox::error(this, i18n("The maximum possible number of\nentries"
664 "has been reached.\nYou can't add more entries."), 666 "has been reached.\nYou can't add more entries."),
665 i18n("maximum number of entries")); 667 i18n("maximum number of entries"));
666 doc->timer()->putLock(DocTimer::id_autoLockTimer); 668 doc->timer()->putLock(DocTimer::id_autoLockTimer);
667 return; 669 return;
668 } 670 }
669 } 671 }
670 setVirgin(false); 672 setVirgin(false);
671 doc->timer()->putLock(DocTimer::id_autoLockTimer); 673 doc->timer()->putLock(DocTimer::id_autoLockTimer);
672} 674}
673 675
674//US ENH : changed code to run with older MOC 676//US ENH : changed code to run with older MOC
675void PwM::editPwd_slot() 677void PwM::editPwd_slot()
676{ 678{
677 editPwd_slot3(0,0,0); 679 editPwd_slot3(0,0,0);
678} 680}
679 681
680void PwM::editPwd_slot1(const QString *category) 682void PwM::editPwd_slot1(const QString *category)
681{ 683{
682 editPwd_slot3(category, 0, 0); 684 editPwd_slot3(category, 0, 0);
683} 685}
684 686
685void PwM::editPwd_slot3(const QString *category, const int *index, 687void PwM::editPwd_slot3(const QString *category, const int *index,
686 PwMDoc *_doc) 688 PwMDoc *_doc)
687{ 689{
688 PwMDoc *doc; 690 PwMDoc *doc;
689 if (_doc) { 691 if (_doc) {
690 doc = _doc; 692 doc = _doc;
691 } else { 693 } else {
692 doc = curDoc(); 694 doc = curDoc();
693 } 695 }
694 PWM_ASSERT(doc); 696 PWM_ASSERT(doc);
695 if (doc->isDocEmpty()) 697 if (doc->isDocEmpty())
696 return; 698 return;
697 if (doc->isDeepLocked()) 699 if (doc->isDeepLocked())
698 return; 700 return;
699 doc->timer()->getLock(DocTimer::id_autoLockTimer); 701 doc->timer()->getLock(DocTimer::id_autoLockTimer);
700 unsigned int curEntryIndex; 702 unsigned int curEntryIndex;
701 if (index) { 703 if (index) {
702 curEntryIndex = *index; 704 curEntryIndex = *index;
703 } else { 705 } else {
704 if (!(view->getCurEntryIndex(&curEntryIndex))) { 706 if (!(view->getCurEntryIndex(&curEntryIndex))) {
705 printDebug("couldn't get index. Maybe we have a binary entry here."); 707 printDebug("couldn't get index. Maybe we have a binary entry here.");
706 doc->timer()->putLock(DocTimer::id_autoLockTimer); 708 doc->timer()->putLock(DocTimer::id_autoLockTimer);
707 return; 709 return;
708 } 710 }
709 } 711 }
710 QString curCategory; 712 QString curCategory;
711 if (category) { 713 if (category) {
712 curCategory = *category; 714 curCategory = *category;
713 } else { 715 } else {
714 curCategory = view->getCurrentCategory(); 716 curCategory = view->getCurrentCategory();
715 } 717 }
716 PwMDataItem currItem; 718 PwMDataItem currItem;
717 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { 719 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
718 doc->timer()->putLock(DocTimer::id_autoLockTimer); 720 doc->timer()->putLock(DocTimer::id_autoLockTimer);
719 return; 721 return;
720 } 722 }
721 BUG_ON(currItem.binary); 723 BUG_ON(currItem.binary);
722 724
723 AddEntryWndImpl w; 725 AddEntryWndImpl w;
724 vector<string> catList; 726 vector<string> catList;
725 doc->getCategoryList(&catList); 727 doc->getCategoryList(&catList);
726 unsigned i, size = catList.size(); 728 unsigned i, size = catList.size();
727 for (i = 0; i < size; ++i) { 729 for (i = 0; i < size; ++i) {
728 w.addCategory(catList[i].c_str()); 730 w.addCategory(catList[i].c_str());
729 } 731 }
730 w.setCurrCategory(curCategory); 732 w.setCurrCategory(curCategory);
731 w.setDescription(currItem.desc.c_str()); 733 w.setDescription(currItem.desc.c_str());
732 w.setUsername(currItem.name.c_str()); 734 w.setUsername(currItem.name.c_str());
733 w.setPassword(currItem.pw.c_str()); 735 w.setPassword(currItem.pw.c_str());
734 w.setUrl(currItem.url.c_str()); 736 w.setUrl(currItem.url.c_str());
735 w.setLauncher(currItem.launcher.c_str()); 737 w.setLauncher(currItem.launcher.c_str());
736 w.setComment(currItem.comment.c_str()); 738 w.setComment(currItem.comment.c_str());
737 if (w.exec() == 1) { 739 if (w.exec() == 1) {
738 currItem.desc = w.getDescription().latin1(); 740 currItem.desc = w.getDescription().latin1();
739 currItem.name = w.getUsername().latin1(); 741 currItem.name = w.getUsername().latin1();
740 currItem.pw = w.getPassword().latin1(); 742 currItem.pw = w.getPassword().latin1();
741 currItem.comment = w.getComment().latin1(); 743 currItem.comment = w.getComment().latin1();
742 currItem.url = w.getUrl().latin1(); 744 currItem.url = w.getUrl().latin1();
743 currItem.launcher = w.getLauncher().latin1(); 745 currItem.launcher = w.getLauncher().latin1();
744 if (!doc->editEntry(curCategory, w.getCategory(), 746 if (!doc->editEntry(curCategory, w.getCategory(),
745 curEntryIndex, &currItem)) { 747 curEntryIndex, &currItem)) {
746 KMessageBox::error(this, 748 KMessageBox::error(this,
747 i18n("Couldn't edit the entry.\n" 749 i18n("Couldn't edit the entry.\n"
748 "Maybe you changed the category and\n" 750 "Maybe you changed the category and\n"
749 "this entry is already present\nin the new " 751 "this entry is already present\nin the new "
750 "category?"), 752 "category?"),
751 i18n("couldn't edit entry.")); 753 i18n("couldn't edit entry."));
752 doc->timer()->putLock(DocTimer::id_autoLockTimer); 754 doc->timer()->putLock(DocTimer::id_autoLockTimer);
753 return; 755 return;
754 } 756 }
755 } 757 }
756 doc->timer()->putLock(DocTimer::id_autoLockTimer); 758 doc->timer()->putLock(DocTimer::id_autoLockTimer);
757} 759}
758 760
759void PwM::deletePwd_slot() 761void PwM::deletePwd_slot()
760{ 762{
761 PWM_ASSERT(curDoc()); 763 PWM_ASSERT(curDoc());
762 if (curDoc()->isDocEmpty()) 764 if (curDoc()->isDocEmpty())
763 return; 765 return;
764 if (curDoc()->isDeepLocked()) 766 if (curDoc()->isDeepLocked())
765 return; 767 return;
766 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 768 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
767 unsigned int curEntryIndex = 0; 769 unsigned int curEntryIndex = 0;
768 if (!(view->getCurEntryIndex(&curEntryIndex))) { 770 if (!(view->getCurEntryIndex(&curEntryIndex))) {
769 printDebug("couldn't get index"); 771 printDebug("couldn't get index");
770 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 772 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
771 return; 773 return;
772 } 774 }
773 775
774 PwMDataItem currItem; 776 PwMDataItem currItem;
775 QString curCategory = view->getCurrentCategory(); 777 QString curCategory = view->getCurrentCategory();
776 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { 778 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
777 printDebug("couldn't get entry"); 779 printDebug("couldn't get entry");
778 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 780 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
779 return; 781 return;
780 } 782 }
781 if (KMessageBox:: 783 if (KMessageBox::
782 questionYesNo(this, 784 questionYesNo(this,
783 i18n 785 i18n
784 ("Do you really want to delete\nthe selected entry") + 786 ("Do you really want to delete\nthe selected entry") +
785 " \n\"" + QString(currItem.desc.c_str()) 787 " \n\"" + QString(currItem.desc.c_str())
786 + "\" ?", i18n("delete?")) 788 + "\" ?", i18n("delete?"))
787 == KMessageBox::Yes) { 789 == KMessageBox::Yes) {
788 790
789 curDoc()->delEntry(curCategory, curEntryIndex); 791 curDoc()->delEntry(curCategory, curEntryIndex);
790 } 792 }
791 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 793 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
792} 794}
793 795
794void PwM::changeMasterPwd_slot() 796void PwM::changeMasterPwd_slot()
795{ 797{
796 PWM_ASSERT(curDoc()); 798 PWM_ASSERT(curDoc());
797 curDoc()->changeCurrentPw(); 799 curDoc()->changeCurrentPw();
798} 800}
799 801
800void PwM::lockWnd_slot() 802void PwM::lockWnd_slot()
801{ 803{
802 PWM_ASSERT(curDoc()); 804 PWM_ASSERT(curDoc());
803 curDoc()->lockAll(true); 805 curDoc()->lockAll(true);
804} 806}
805 807
806void PwM::deepLockWnd_slot() 808void PwM::deepLockWnd_slot()
807{ 809{
808 PWM_ASSERT(curDoc()); 810 PWM_ASSERT(curDoc());
809 curDoc()->deepLock(); 811 curDoc()->deepLock();
810} 812}
811 813
812void PwM::unlockWnd_slot() 814void PwM::unlockWnd_slot()
813{ 815{
814 PWM_ASSERT(curDoc()); 816 PWM_ASSERT(curDoc());
815 curDoc()->lockAll(false); 817 curDoc()->lockAll(false);
816} 818}
817 819
818void PwM::config_slot() 820void PwM::config_slot()
819{ 821{
820 int oldStyle = conf()->confWndMainViewStyle(); 822 int oldStyle = conf()->confWndMainViewStyle();
821#ifdef PWM_EMBEDDED 823#ifdef PWM_EMBEDDED
822 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); 824 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true );
823 825
824 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); 826 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" );
825 ConfigureDialog->addModule(pwmcfg ); 827 ConfigureDialog->addModule(pwmcfg );
826 828
827 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 829 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
828 ConfigureDialog->addModule(kdelibcfg ); 830 ConfigureDialog->addModule(kdelibcfg );
829 831
830#ifndef DESKTOP_VERSION 832#ifndef DESKTOP_VERSION
831 ConfigureDialog->showMaximized(); 833 ConfigureDialog->showMaximized();
832#endif 834#endif
833 if ( ConfigureDialog->exec() ) 835 if ( ConfigureDialog->exec() )
834 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 836 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
835 delete ConfigureDialog; 837 delete ConfigureDialog;
836 838
837#else //PWM_EMBEDDED 839#else //PWM_EMBEDDED
838 // display the configuration window (modal mode) 840 // display the configuration window (modal mode)
839 if (!conf()->showConfWnd(this)) 841 if (!conf()->showConfWnd(this))
840 return; 842 return;
841#endif 843#endif
842 844
843 int newStyle = conf()->confWndMainViewStyle(); 845 int newStyle = conf()->confWndMainViewStyle();
844 // reinitialize tray 846 // reinitialize tray
845 init->initTray(); 847 init->initTray();
846 // reinitialize KWallet emulation 848 // reinitialize KWallet emulation
847 init->initKWalletEmu(); 849 init->initKWalletEmu();
848 850
849 PwMDocList *_dl = PwMDoc::getOpenDocList(); 851 PwMDocList *_dl = PwMDoc::getOpenDocList();
850 const vector<PwMDocList::listItem> *dl = _dl->getList(); 852 const vector<PwMDocList::listItem> *dl = _dl->getList();
851 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 853 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
852 end = dl->end(); 854 end = dl->end();
853 PwMDoc *doc; 855 PwMDoc *doc;
854 while (i != end) { 856 while (i != end) {
855 doc = (*i).doc; 857 doc = (*i).doc;
856 // unlock-without-mpw timeout 858 // unlock-without-mpw timeout
857 doc->timer()->start(DocTimer::id_mpwTimer); 859 doc->timer()->start(DocTimer::id_mpwTimer);
858 // auto-lock timeout 860 // auto-lock timeout
859 doc->timer()->start(DocTimer::id_autoLockTimer); 861 doc->timer()->start(DocTimer::id_autoLockTimer);
860 ++i; 862 ++i;
861 } 863 }
862 864
863 const QValueList<PwM *> *ml = init->mainWndList(); 865 const QValueList<PwM *> *ml = init->mainWndList();
864#ifndef PWM_EMBEDDED 866#ifndef PWM_EMBEDDED
865 QValueList<PwM *>::const_iterator i2 = ml->begin(), 867 QValueList<PwM *>::const_iterator i2 = ml->begin(),
866 end2 = ml->end(); 868 end2 = ml->end();
867#else 869#else
868 QValueList<PwM *>::ConstIterator i2 = ml->begin(), 870 QValueList<PwM *>::ConstIterator i2 = ml->begin(),
869 end2 = ml->end(); 871 end2 = ml->end();
870#endif 872#endif
871 PwM *pwm; 873 PwM *pwm;
872 while (i2 != end2) { 874 while (i2 != end2) {
873 pwm = *i2; 875 pwm = *i2;
874 // reinitialize the window style. 876 // reinitialize the window style.
875 if (oldStyle != newStyle) 877 if (oldStyle != newStyle)
876 pwm->curView()->initStyle(newStyle); 878 pwm->curView()->initStyle(newStyle);
877 // set the new font 879 // set the new font
878 pwm->curView()->setFont(conf()->confGlobEntryFont()); 880 pwm->curView()->setFont(conf()->confGlobEntryFont());
879 ++i2; 881 ++i2;
880 } 882 }
881} 883}
882 884
883void PwM::activateMpButton(bool activate) 885void PwM::activateMpButton(bool activate)
884{ 886{
885 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); 887 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate);
886} 888}
887 889
888void PwM::closeEvent(QCloseEvent *e) 890void PwM::closeEvent(QCloseEvent *e)
889{ 891{
892 qDebug("PwM::closeEvent ");
893 emit closed( this );
894 return;
890 e->accept(); 895 e->accept();
891} 896}
892 897
893void PwM::docClosed(PwMDoc *doc) 898void PwM::docClosed(PwMDoc *doc)
894{ 899{
900 qDebug("PwM::docClosed ");
895 PARAM_UNUSED(doc); 901 PARAM_UNUSED(doc);
896 PWM_ASSERT(doc == curDoc()); 902 PWM_ASSERT(doc == curDoc());
897 close(); 903 close();
898} 904}
899 905
900void PwM::find_slot() 906void PwM::find_slot()
901{ 907{
902 PWM_ASSERT(curDoc()); 908 PWM_ASSERT(curDoc());
903 if (curDoc()->isDocEmpty()) 909 if (curDoc()->isDocEmpty())
904 return; 910 return;
905 if (curDoc()->isDeepLocked()) 911 if (curDoc()->isDeepLocked())
906 return; 912 return;
907 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 913 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
908 FindWndImpl findWnd(view); 914 FindWndImpl findWnd(view);
909 findWnd.exec(); 915 findWnd.exec();
910 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 916 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
911} 917}
912 918
913void PwM::exportToText() 919void PwM::exportToText()
914{ 920{
915 PWM_ASSERT(curDoc()); 921 PWM_ASSERT(curDoc());
916 if (curDoc()->isDocEmpty()) { 922 if (curDoc()->isDocEmpty()) {
917 KMessageBox::information(this, 923 KMessageBox::information(this,
918 i18n 924 i18n
919 ("Sorry, there's nothing to export.\n" 925 ("Sorry, there's nothing to export.\n"
920 "Please first add some passwords."), 926 "Please first add some passwords."),
921 i18n("nothing to do")); 927 i18n("nothing to do"));
922 return; 928 return;
923 } 929 }
924 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 930 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
925 QString fn(KFileDialog::getSaveFileName(QString::null, 931 QString fn(KFileDialog::getSaveFileName(QString::null,
926 i18n("*|plain-text file"), 932 i18n("*|plain-text file"),
927 this)); 933 this));
928 if (fn == "") { 934 if (fn == "") {
929 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 935 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
930 return; 936 return;
931 } 937 }
932 938
933 PwMerror ret = curDoc()->exportToText(&fn); 939 PwMerror ret = curDoc()->exportToText(&fn);
934 if (ret != e_success) { 940 if (ret != e_success) {
935 KMessageBox::error(this, 941 KMessageBox::error(this,
936 i18n("Error: Couldn't write to file.\n" 942 i18n("Error: Couldn't write to file.\n"
937 "Please check if you have permission to write\n" 943 "Please check if you have permission to write\n"
938 "to the file in that directory."), 944 "to the file in that directory."),
939 i18n("error while writing")); 945 i18n("error while writing"));
940 } else 946 } else
941 showStatMsg(i18n("Successfully exported data.")); 947 showStatMsg(i18n("Successfully exported data."));
942 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 948 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
943} 949}
944 950
945bool PwM::importFromText() 951bool PwM::importFromText()
946{ 952{
947 if (!isVirgin()) { 953 if (!isVirgin()) {
948 if (KMessageBox::questionYesNo(this, 954 if (KMessageBox::questionYesNo(this,
949 i18n("Do you want to import the data\n" 955 i18n("Do you want to import the data\n"
950 "into the current document? (If you\n" 956 "into the current document? (If you\n"
951 "select \"no\", a new document will be\n" 957 "select \"no\", a new document will be\n"
952 "opened.)"), 958 "opened.)"),
953 i18n("import into this document?")) 959 i18n("import into this document?"))
954 == KMessageBox::No) { 960 == KMessageBox::No) {
955 // import the data to a new window. 961 // import the data to a new window.
956 PwM *newInstance = init->createMainWnd(); 962 PwM *newInstance = init->createMainWnd();
957 bool ok = newInstance->importFromText(); 963 bool ok = newInstance->importFromText();
958 if (!ok) { 964 if (!ok) {
959 newInstance->setForceQuit(true); 965 newInstance->setForceQuit(true);
960 delete_and_null(newInstance); 966 delete_and_null(newInstance);
961 } 967 }
962 return ok; 968 return ok;
963 } 969 }
964 } 970 }
965 971
966 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 972 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
967 PwMerror ret; 973 PwMerror ret;
968 QString path(KFileDialog::getOpenFileName(QString::null, 974 QString path(KFileDialog::getOpenFileName(QString::null,
969 i18n("*|PWM-exported text file"), 975 i18n("*|PWM-exported text file"),
970 this)); 976 this));
971 if (path == "") 977 if (path == "")
972 goto cancelImport; 978 goto cancelImport;
973 979
974 ret = curDoc()->importFromText(&path, 0); 980 ret = curDoc()->importFromText(&path, 0);
975 if (ret == e_fileFormat) { 981 if (ret == e_fileFormat) {
976 KMessageBox::error(this, 982 KMessageBox::error(this,
977 i18n("Could not read file-format.\n" 983 i18n("Could not read file-format.\n"
978 "This seems to be _not_ a valid file\n" 984 "This seems to be _not_ a valid file\n"
979 "exported by PwM."), 985 "exported by PwM."),
980 i18n("invalid file-format")); 986 i18n("invalid file-format"));
981 goto cancelImport; 987 goto cancelImport;
982 } else if (ret == e_invalidArg) { 988 } else if (ret == e_invalidArg) {
983 BUG(); 989 BUG();
984 goto cancelImport; 990 goto cancelImport;
985 } else if (ret != e_success) { 991 } else if (ret != e_success) {
986 KMessageBox::error(this, 992 KMessageBox::error(this,
987 i18n("Could not import file!\n" 993 i18n("Could not import file!\n"
988 "Do you have permission to read this file?\n" 994 "Do you have permission to read this file?\n"
989 "Do you have enough free memory?"), 995 "Do you have enough free memory?"),
990 i18n("import failed")); 996 i18n("import failed"));
991 goto cancelImport; 997 goto cancelImport;
992 } 998 }
993 setVirgin(false); 999 setVirgin(false);
994 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1000 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
995 return true; 1001 return true;
996 1002
997cancelImport: 1003cancelImport:
998 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1004 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
999 return false; 1005 return false;
1000} 1006}
1001 1007
1002void PwM::exportToGpasman() 1008void PwM::exportToGpasman()
1003{ 1009{
1004 PWM_ASSERT(curDoc()); 1010 PWM_ASSERT(curDoc());
1005 if (curDoc()->isDocEmpty()) { 1011 if (curDoc()->isDocEmpty()) {
1006 KMessageBox::information(this, 1012 KMessageBox::information(this,
1007 i18n 1013 i18n
1008 ("Sorry, there's nothing to export.\n" 1014 ("Sorry, there's nothing to export.\n"
1009 "Please first add some passwords."), 1015 "Please first add some passwords."),
1010 i18n("nothing to do")); 1016 i18n("nothing to do"));
1011 return; 1017 return;
1012 } 1018 }
1013 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1019 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1014 QString fn(KFileDialog::getSaveFileName(QString::null, 1020 QString fn(KFileDialog::getSaveFileName(QString::null,
1015 i18n("*|Gpasman or Kpasman file"), 1021 i18n("*|Gpasman or Kpasman file"),
1016 this)); 1022 this));
1017 if (fn == "") { 1023 if (fn == "") {
1018 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1024 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1019 return; 1025 return;
1020 } 1026 }
1021 1027
1022 PwMerror ret = curDoc()->exportToGpasman(&fn); 1028 PwMerror ret = curDoc()->exportToGpasman(&fn);
1023 if (ret != e_success) { 1029 if (ret != e_success) {
1024 if (ret == e_noPw) { 1030 if (ret == e_noPw) {
1025 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1031 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1026 return; 1032 return;
1027 } 1033 }
1028 KMessageBox::error(this, 1034 KMessageBox::error(this,
1029 i18n("Error: Couldn't write to file.\n" 1035 i18n("Error: Couldn't write to file.\n"
1030 "Please check if you have permission to write " 1036 "Please check if you have permission to write "
1031 "to the file in that directory."), 1037 "to the file in that directory."),
1032 i18n("error while writing")); 1038 i18n("error while writing"));
1033 } else 1039 } else
1034 showStatMsg(i18n("Successfully exported data.")); 1040 showStatMsg(i18n("Successfully exported data."));
1035 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1041 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1036} 1042}
1037 1043
1038 1044
1039 1045
1040void PwM::exportToCsv() 1046void PwM::exportToCsv()
1041{ 1047{
1042 PWM_ASSERT(curDoc()); 1048 PWM_ASSERT(curDoc());
1043 if (curDoc()->isDocEmpty()) { 1049 if (curDoc()->isDocEmpty()) {
1044 KMessageBox::information(this, 1050 KMessageBox::information(this,
1045 i18n 1051 i18n
1046 ("Sorry, there is nothing to export;\n" 1052 ("Sorry, there is nothing to export;\n"
1047 "please add some passwords first."), 1053 "please add some passwords first."),
1048 i18n("Nothing to Do")); 1054 i18n("Nothing to Do"));
1049 return; 1055 return;
1050 } 1056 }
1051 1057
1052 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1058 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1053 QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); 1059 QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this));
1054 if (fn.isEmpty()) { 1060 if (fn.isEmpty()) {
1055 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1061 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1056 return; 1062 return;
1057 } 1063 }
1058 1064
1059 Csv csv(this); 1065 Csv csv(this);
1060 if (!csv.exportData(fn, curDoc())) { 1066 if (!csv.exportData(fn, curDoc())) {
1061 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1067 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1062 showStatMsg(i18n("CSV file export failed.")); 1068 showStatMsg(i18n("CSV file export failed."));
1063 return; 1069 return;
1064 } 1070 }
1065 showStatMsg(i18n("Successfully exported data.")); 1071 showStatMsg(i18n("Successfully exported data."));
1066 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1072 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1067} 1073}
1068 1074
1069bool PwM::importCsv() 1075bool PwM::importCsv()
1070{ 1076{
1071 Csv csv(this); 1077 Csv csv(this);
1072 if (!isVirgin()) { 1078 if (!isVirgin()) {
1073 if (KMessageBox::questionYesNo(this, 1079 if (KMessageBox::questionYesNo(this,
1074 i18n("Do you want to import the data\n" 1080 i18n("Do you want to import the data\n"
1075 "into the current document? (If you\n" 1081 "into the current document? (If you\n"
1076 "select \"no\", a new document will be\n" 1082 "select \"no\", a new document will be\n"
1077 "opened.)"), 1083 "opened.)"),
1078 i18n("Import into This Document?")) 1084 i18n("Import into This Document?"))
1079 == KMessageBox::No) { 1085 == KMessageBox::No) {
1080 // import the data to a new window. 1086 // import the data to a new window.
1081 PwM *newInstance = init->createMainWnd(); 1087 PwM *newInstance = init->createMainWnd();
1082 bool ok = newInstance->importCsv(); 1088 bool ok = newInstance->importCsv();
1083 if (!ok) { 1089 if (!ok) {
1084 newInstance->setForceQuit(true); 1090 newInstance->setForceQuit(true);
1085 delete_and_null(newInstance); 1091 delete_and_null(newInstance);
1086 } 1092 }
1087 return ok; 1093 return ok;
1088 } 1094 }
1089 } 1095 }
1090 1096
1091 QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); 1097 QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this);
1092 if (filename.isEmpty()) 1098 if (filename.isEmpty())
1093 return false; 1099 return false;
1094 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1100 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1095 if (!csv.importData(filename, curDoc())) { 1101 if (!csv.importData(filename, curDoc())) {
1096 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1102 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1097 showStatMsg(i18n("CSV file import failed.")); 1103 showStatMsg(i18n("CSV file import failed."));
1098 return false; 1104 return false;
1099 } 1105 }
1100 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1106 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1101 KMessageBox::information(this, 1107 KMessageBox::information(this,
1102 i18n("Successfully imported the CSV data\n" 1108 i18n("Successfully imported the CSV data\n"
1103 "into the current document."), i18n("Successfully Imported")); 1109 "into the current document."), i18n("Successfully Imported"));
1104 showStatMsg(i18n("Successfully imported")); 1110 showStatMsg(i18n("Successfully imported"));
1105 setVirgin(false); 1111 setVirgin(false);
1106 return true; 1112 return true;
1107} 1113}
1108 1114
1109 1115
1110void PwM::exportToKWallet() 1116void PwM::exportToKWallet()
1111{ 1117{
1112#ifdef CONFIG_KWALLETIF 1118#ifdef CONFIG_KWALLETIF
1113 if (!checkAndAskForKWalletEmu()) 1119 if (!checkAndAskForKWalletEmu())
1114 return; 1120 return;
1115 PWM_ASSERT(curDoc()); 1121 PWM_ASSERT(curDoc());
1116 if (curDoc()->isDocEmpty()) { 1122 if (curDoc()->isDocEmpty()) {
1117 KMessageBox::information(this, 1123 KMessageBox::information(this,
1118 i18n 1124 i18n
1119 ("Sorry, there's nothing to export.\n" 1125 ("Sorry, there's nothing to export.\n"
1120 "Please first add some passwords."), 1126 "Please first add some passwords."),
1121 i18n("nothing to do")); 1127 i18n("nothing to do"));
1122 init->initKWalletEmu(); 1128 init->initKWalletEmu();
1123 return; 1129 return;
1124 } 1130 }
1125 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1131 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1126 KWalletIf walletIf(this); 1132 KWalletIf walletIf(this);
1127 if (walletIf.kwalletExport(curDoc())) { 1133 if (walletIf.kwalletExport(curDoc())) {
1128 KMessageBox::information(this, 1134 KMessageBox::information(this,
1129 i18n("Successfully exported the data of the current " 1135 i18n("Successfully exported the data of the current "
1130 "document to KWallet."), 1136 "document to KWallet."),
1131 i18n("Successfully exported data.")); 1137 i18n("Successfully exported data."));
1132 showStatMsg(i18n("Successfully exported data.")); 1138 showStatMsg(i18n("Successfully exported data."));
1133 } 1139 }
1134 init->initKWalletEmu(); 1140 init->initKWalletEmu();
1135 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1141 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1136#endif // CONFIG_KWALLETIF 1142#endif // CONFIG_KWALLETIF
1137} 1143}
1138 1144
1139bool PwM::importFromGpasman() 1145bool PwM::importFromGpasman()
1140{ 1146{
1141 if (!isVirgin()) { 1147 if (!isVirgin()) {
1142 if (KMessageBox::questionYesNo(this, 1148 if (KMessageBox::questionYesNo(this,
1143 i18n("Do you want to import the data\n" 1149 i18n("Do you want to import the data\n"
1144 "into the current document? (If you\n" 1150 "into the current document? (If you\n"
1145 "select \"no\", a new document will be\n" 1151 "select \"no\", a new document will be\n"
1146 "opened.)"), 1152 "opened.)"),
1147 i18n("import into this document?")) 1153 i18n("import into this document?"))
1148 == KMessageBox::No) { 1154 == KMessageBox::No) {
1149 // import the data to a new window. 1155 // import the data to a new window.
1150 PwM *newInstance = init->createMainWnd(); 1156 PwM *newInstance = init->createMainWnd();
1151 bool ok = newInstance->importFromGpasman(); 1157 bool ok = newInstance->importFromGpasman();
1152 if (!ok) { 1158 if (!ok) {
1153 newInstance->setForceQuit(true); 1159 newInstance->setForceQuit(true);
1154 delete_and_null(newInstance); 1160 delete_and_null(newInstance);
1155 } 1161 }
1156 return ok; 1162 return ok;
1157 } 1163 }
1158 } 1164 }
1159 1165
1160 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1166 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1161 PwMerror ret; 1167 PwMerror ret;
1162 QString path(KFileDialog::getOpenFileName(QString::null, 1168 QString path(KFileDialog::getOpenFileName(QString::null,
1163 i18n("*|Gpasman or Kpasman file"), this)); 1169 i18n("*|Gpasman or Kpasman file"), this));
1164 if (path == "") 1170 if (path == "")
1165 goto cancelImport; 1171 goto cancelImport;
1166 ret = curDoc()->importFromGpasman(&path); 1172 ret = curDoc()->importFromGpasman(&path);
1167 if (ret == e_wrongPw) { 1173 if (ret == e_wrongPw) {
1168 if (KMessageBox::questionYesNo(this, 1174 if (KMessageBox::questionYesNo(this,
1169 i18n 1175 i18n
1170 ("This is probably the wrong master-password\n" 1176 ("This is probably the wrong master-password\n"
1171 "you have typed in.\n" 1177 "you have typed in.\n"
1172 "There is no real way to determine the\n" 1178 "There is no real way to determine the\n"
1173 "correctness of the password in the Gpasman\n" 1179 "correctness of the password in the Gpasman\n"
1174 "file-format. But I think this\n" 1180 "file-format. But I think this\n"
1175 "password ist wrong.\n" 1181 "password ist wrong.\n"
1176 "Do you want to continue nevertheless?"), 1182 "Do you want to continue nevertheless?"),
1177 i18n("password error")) 1183 i18n("password error"))
1178 == KMessageBox::No) { 1184 == KMessageBox::No) {
1179 goto cancelImport; 1185 goto cancelImport;
1180 } 1186 }
1181 } else if (ret != e_success) { 1187 } else if (ret != e_success) {
1182 KMessageBox::error(this, 1188 KMessageBox::error(this,
1183 i18n("Could not import file!\n" 1189 i18n("Could not import file!\n"
1184 "Do you have permission to read this file?"), 1190 "Do you have permission to read this file?"),
1185 i18n("import failed")); 1191 i18n("import failed"));
1186 goto cancelImport; 1192 goto cancelImport;
1187 } 1193 }
1188 setVirgin(false); 1194 setVirgin(false);
1189 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1195 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1190 return true; 1196 return true;
1191 1197
1192cancelImport: 1198cancelImport:
1193 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1199 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1194 return false; 1200 return false;
1195} 1201}
1196 1202
1197#ifdef CONFIG_KWALLETIF 1203#ifdef CONFIG_KWALLETIF
1198bool PwM::checkAndAskForKWalletEmu() 1204bool PwM::checkAndAskForKWalletEmu()
1199{ 1205{
1200 if (init->kwalletEmu()) { 1206 if (init->kwalletEmu()) {
1201 /* KWallet emulation is enabled. We can't import/export 1207 /* KWallet emulation is enabled. We can't import/export
1202 * data from/to it, while emulation is active. 1208 * data from/to it, while emulation is active.
1203 */ 1209 */
1204 if (KMessageBox::questionYesNo(this, 1210 if (KMessageBox::questionYesNo(this,
1205 i18n("KWallet emulation is enabled.\n" 1211 i18n("KWallet emulation is enabled.\n"
1206 "You can't import or export data from/to " 1212 "You can't import or export data from/to "
1207 "the original KWallet, while the emulation " 1213 "the original KWallet, while the emulation "
1208 "is active.\n" 1214 "is active.\n"
1209 "Do you want to tempoarly disable the KWallet emulation?"), 1215 "Do you want to tempoarly disable the KWallet emulation?"),
1210 i18n("Tempoarly disable KWallet emulation?")) 1216 i18n("Tempoarly disable KWallet emulation?"))
1211 == KMessageBox::Yes) { 1217 == KMessageBox::Yes) {
1212 init->initKWalletEmu(true); 1218 init->initKWalletEmu(true);
1213 PWM_ASSERT(!init->kwalletEmu()); 1219 PWM_ASSERT(!init->kwalletEmu());
1214 return true; 1220 return true;
1215 } 1221 }
1216 return false; 1222 return false;
1217 } 1223 }
1218 return true; 1224 return true;
1219} 1225}
1220#endif // CONFIG_KWALLETIF 1226#endif // CONFIG_KWALLETIF
1221 1227
1222bool PwM::importKWallet() 1228bool PwM::importKWallet()
1223{ 1229{
1224#ifdef CONFIG_KWALLETIF 1230#ifdef CONFIG_KWALLETIF
1225 if (!checkAndAskForKWalletEmu()) 1231 if (!checkAndAskForKWalletEmu())
1226 return false; 1232 return false;
1227 KWalletIf walletIf(this); 1233 KWalletIf walletIf(this);
1228 if (!isVirgin()) { 1234 if (!isVirgin()) {
1229 if (KMessageBox::questionYesNo(this, 1235 if (KMessageBox::questionYesNo(this,
1230 i18n("Do you want to import the data " 1236 i18n("Do you want to import the data "
1231 "into the current document? (If you " 1237 "into the current document? (If you "
1232 "select \"no\", a new document will be " 1238 "select \"no\", a new document will be "
1233 "opened.)"), 1239 "opened.)"),
1234 i18n("import into this document?")) 1240 i18n("import into this document?"))
1235 == KMessageBox::No) { 1241 == KMessageBox::No) {
1236 // import the data to a new window. 1242 // import the data to a new window.
1237 PwM *newInstance = init->createMainWnd(); 1243 PwM *newInstance = init->createMainWnd();
1238 bool ok = newInstance->importKWallet(); 1244 bool ok = newInstance->importKWallet();
1239 if (!ok) { 1245 if (!ok) {
1240 newInstance->setForceQuit(true); 1246 newInstance->setForceQuit(true);
1241 delete_and_null(newInstance); 1247 delete_and_null(newInstance);
1242 goto exit_fail; 1248 goto exit_fail;
1243 } else { 1249 } else {
1244 goto exit_ok; 1250 goto exit_ok;
1245 } 1251 }
1246 } 1252 }
1247 } 1253 }
1248 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1254 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1249 if (!walletIf.kwalletImport(curDoc())) { 1255 if (!walletIf.kwalletImport(curDoc())) {
1250 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1256 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1251 showStatMsg(i18n("KWallet import failed")); 1257 showStatMsg(i18n("KWallet import failed"));
1252 goto exit_fail; 1258 goto exit_fail;
1253 } 1259 }
1254 KMessageBox::information(this, 1260 KMessageBox::information(this,
1255 i18n("Successfully imported the KWallet data " 1261 i18n("Successfully imported the KWallet data "
1256 "into the current document."), 1262 "into the current document."),
1257 i18n("successfully imported")); 1263 i18n("successfully imported"));
1258 showStatMsg(i18n("successfully imported")); 1264 showStatMsg(i18n("successfully imported"));
1259 setVirgin(false); 1265 setVirgin(false);
1260 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1266 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1261 1267
1262exit_ok: 1268exit_ok:
1263 init->initKWalletEmu(); 1269 init->initKWalletEmu();
1264 return true; 1270 return true;
1265 1271
1266exit_fail: 1272exit_fail:
1267 init->initKWalletEmu(); 1273 init->initKWalletEmu();
1268#endif // CONFIG_KWALLETIF 1274#endif // CONFIG_KWALLETIF
1269 return false; 1275 return false;
1270} 1276}
1271 1277
1272void PwM::print_slot() 1278void PwM::print_slot()
1273{ 1279{
1274 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1280 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1275#ifndef PWM_EMBEDDED 1281#ifndef PWM_EMBEDDED
1276 PwMPrint p(curDoc(), this); 1282 PwMPrint p(curDoc(), this);
1277 p.printNow(); 1283 p.printNow();
1278#else 1284#else
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 129bf7b..cf8690f 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -2596,768 +2596,769 @@ PwMerror PwMDoc::importText_PwM(const QString *file)
2596 if (res == false) 2596 if (res == false)
2597 return e_openFile; 2597 return e_openFile;
2598 2598
2599 unsigned int ch_tmp_size = 1024; 2599 unsigned int ch_tmp_size = 1024;
2600 char *ch_tmp = (char*)malloc(ch_tmp_size); 2600 char *ch_tmp = (char*)malloc(ch_tmp_size);
2601 if (!ch_tmp) { 2601 if (!ch_tmp) {
2602 f.close(); 2602 f.close();
2603 return e_outOfMem; 2603 return e_outOfMem;
2604 } 2604 }
2605 2605
2606 // - check header 2606 // - check header
2607 if (f.readLine(ch_tmp, ch_tmp_size) == -1) // skip first line. 2607 if (f.readLine(ch_tmp, ch_tmp_size) == -1) // skip first line.
2608 goto formatError; 2608 goto formatError;
2609 2609
2610 //US read fileversion first, then check if ok. 2610 //US read fileversion first, then check if ok.
2611 if (f.readLine(ch_tmp, ch_tmp_size) == -1) 2611 if (f.readLine(ch_tmp, ch_tmp_size) == -1)
2612 goto formatError; 2612 goto formatError;
2613 2613
2614 // check version-string and return version in "ch_tmp". 2614 // check version-string and return version in "ch_tmp".
2615 //US if (fscanf(f, "PwM v%s", ch_tmp) != 1) { 2615 //US if (fscanf(f, "PwM v%s", ch_tmp) != 1) {
2616 //US // header not recognized as PwM generated header 2616 //US // header not recognized as PwM generated header
2617 //US goto formatError; 2617 //US goto formatError;
2618 //US} 2618 //US}
2619 //US set filepointer behind version-string-line previously checked 2619 //US set filepointer behind version-string-line previously checked
2620 //US if (f.readLine(ch_tmp, ch_tmp_size) == -1) 2620 //US if (f.readLine(ch_tmp, ch_tmp_size) == -1)
2621 //US goto formatError; 2621 //US goto formatError;
2622 // skip next line containing the build-date 2622 // skip next line containing the build-date
2623 if (f.readLine(ch_tmp, ch_tmp_size) == -1) 2623 if (f.readLine(ch_tmp, ch_tmp_size) == -1)
2624 goto formatError; 2624 goto formatError;
2625 // read header termination line 2625 // read header termination line
2626 if (f.readLine(ch_tmp, ch_tmp_size) == -1) 2626 if (f.readLine(ch_tmp, ch_tmp_size) == -1)
2627 goto formatError; 2627 goto formatError;
2628 if (strcmp(ch_tmp, "==============================\n")) 2628 if (strcmp(ch_tmp, "==============================\n"))
2629 goto formatError; 2629 goto formatError;
2630 2630
2631 // - read entries 2631 // - read entries
2632 do { 2632 do {
2633 // find beginning of next category 2633 // find beginning of next category
2634 do { 2634 do {
2635 tmp = f.getch(); 2635 tmp = f.getch();
2636 } while (tmp == '\n' && tmp != EOF); 2636 } while (tmp == '\n' && tmp != EOF);
2637 if (tmp == EOF) 2637 if (tmp == EOF)
2638 break; 2638 break;
2639 2639
2640 // decrement filepos by one 2640 // decrement filepos by one
2641 f.at(f.at()-1); 2641 f.at(f.at()-1);
2642 // read cat-name 2642 // read cat-name
2643 if (f.readLine(ch_tmp, ch_tmp_size) == -1) 2643 if (f.readLine(ch_tmp, ch_tmp_size) == -1)
2644 goto formatError; 2644 goto formatError;
2645 // check cat-name format 2645 // check cat-name format
2646 if (memcmp(ch_tmp, "== Category: ", 13) != 0) 2646 if (memcmp(ch_tmp, "== Category: ", 13) != 0)
2647 goto formatError; 2647 goto formatError;
2648 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) 2648 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0)
2649 goto formatError; 2649 goto formatError;
2650 // copy cat-name 2650 // copy cat-name
2651 curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); 2651 curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16);
2652 2652
2653 do { 2653 do {
2654 // find beginning of next entry 2654 // find beginning of next entry
2655 do { 2655 do {
2656 tmp = f.getch(); 2656 tmp = f.getch();
2657 } while (tmp == '\n' && tmp != EOF && tmp != '='); 2657 } while (tmp == '\n' && tmp != EOF && tmp != '=');
2658 if (tmp == EOF) 2658 if (tmp == EOF)
2659 break; 2659 break;
2660 if (tmp == '=') { 2660 if (tmp == '=') {
2661 f.at(f.at()-1); 2661 f.at(f.at()-1);
2662 break; 2662 break;
2663 } 2663 }
2664 // decrement filepos by one 2664 // decrement filepos by one
2665 f.at(f.at()-1); 2665 f.at(f.at()-1);
2666 // read desc-line 2666 // read desc-line
2667 if (f.readLine(ch_tmp, ch_tmp_size) == -1) 2667 if (f.readLine(ch_tmp, ch_tmp_size) == -1)
2668 goto formatError; 2668 goto formatError;
2669 // check desc-line format 2669 // check desc-line format
2670 if (memcmp(ch_tmp, "-- ", 3) != 0) 2670 if (memcmp(ch_tmp, "-- ", 3) != 0)
2671 goto formatError; 2671 goto formatError;
2672 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) 2672 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0)
2673 goto formatError; 2673 goto formatError;
2674 // add desc-line 2674 // add desc-line
2675 currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); 2675 currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6);
2676 2676
2677 // read username-line 2677 // read username-line
2678 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) 2678 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1)
2679 goto formatError; 2679 goto formatError;
2680 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) 2680 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name))
2681 goto formatError; 2681 goto formatError;
2682 2682
2683 // read pw-line 2683 // read pw-line
2684 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) 2684 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1)
2685 goto formatError; 2685 goto formatError;
2686 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) 2686 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw))
2687 goto formatError; 2687 goto formatError;
2688 2688
2689 // read comment-line 2689 // read comment-line
2690 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) 2690 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1)
2691 goto formatError; 2691 goto formatError;
2692 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) 2692 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment))
2693 goto formatError; 2693 goto formatError;
2694 2694
2695 // read URL-line 2695 // read URL-line
2696 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) 2696 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1)
2697 goto formatError; 2697 goto formatError;
2698 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) 2698 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url))
2699 goto formatError; 2699 goto formatError;
2700 2700
2701 // read launcher-line 2701 // read launcher-line
2702 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1) 2702 if ((ret = f.readLine(ch_tmp, ch_tmp_size)) == -1)
2703 goto formatError; 2703 goto formatError;
2704 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) 2704 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher))
2705 goto formatError; 2705 goto formatError;
2706 2706
2707 currItem.lockStat = true; 2707 currItem.lockStat = true;
2708 currItem.listViewPos = -1; 2708 currItem.listViewPos = -1;
2709 addEntry(curCat.c_str(), &currItem, true); 2709 addEntry(curCat.c_str(), &currItem, true);
2710 ++entriesRead; 2710 ++entriesRead;
2711 } while (1); 2711 } while (1);
2712 } while (1); 2712 } while (1);
2713 if (!entriesRead) 2713 if (!entriesRead)
2714 goto formatError; 2714 goto formatError;
2715 2715
2716 free(ch_tmp); 2716 free(ch_tmp);
2717 f.close(); 2717 f.close();
2718 flagDirty(); 2718 flagDirty();
2719 return e_success; 2719 return e_success;
2720 2720
2721 formatError: 2721 formatError:
2722 free(ch_tmp); 2722 free(ch_tmp);
2723 f.close(); 2723 f.close();
2724 return e_fileFormat; 2724 return e_fileFormat;
2725 2725
2726#endif 2726#endif
2727 2727
2728} 2728}
2729 2729
2730bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out) 2730bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out)
2731{ 2731{
2732 PWM_ASSERT(in && out); 2732 PWM_ASSERT(in && out);
2733 ssize_t i = 0, len = in_size - 1; 2733 ssize_t i = 0, len = in_size - 1;
2734 while (i < len) { 2734 while (i < len) {
2735 if (in[i] == ':') 2735 if (in[i] == ':')
2736 break; 2736 break;
2737 ++i; 2737 ++i;
2738 } 2738 }
2739 i += 2; 2739 i += 2;
2740 *out = ""; 2740 *out = "";
2741 out->append(in + i, in_size - i - 1); 2741 out->append(in + i, in_size - i - 1);
2742 return true; 2742 return true;
2743} 2743}
2744 2744
2745PwMerror PwMDoc::exportToGpasman(const QString *file) 2745PwMerror PwMDoc::exportToGpasman(const QString *file)
2746{ 2746{
2747 PWM_ASSERT(file); 2747 PWM_ASSERT(file);
2748 GpasmanFile gp; 2748 GpasmanFile gp;
2749 int ret; 2749 int ret;
2750 2750
2751 if (!unlockAll_tempoary()) 2751 if (!unlockAll_tempoary())
2752 return e_lock; 2752 return e_lock;
2753 2753
2754 QString gpmPassword; 2754 QString gpmPassword;
2755 while (1) { 2755 while (1) {
2756 gpmPassword = requestNewMpw(0); 2756 gpmPassword = requestNewMpw(0);
2757 if (gpmPassword == "") { 2757 if (gpmPassword == "") {
2758 unlockAll_tempoary(true); 2758 unlockAll_tempoary(true);
2759 return e_noPw; 2759 return e_noPw;
2760 } 2760 }
2761 if (gpmPassword.length() < 4) { 2761 if (gpmPassword.length() < 4) {
2762 gpmPwLenErrMsgBox(); 2762 gpmPwLenErrMsgBox();
2763 } else { 2763 } else {
2764 break; 2764 break;
2765 } 2765 }
2766 } 2766 }
2767 2767
2768 ret = gp.save_init(file->latin1(), gpmPassword.latin1()); 2768 ret = gp.save_init(file->latin1(), gpmPassword.latin1());
2769 if (ret != 1) { 2769 if (ret != 1) {
2770 unlockAll_tempoary(true); 2770 unlockAll_tempoary(true);
2771 return e_accessFile; 2771 return e_accessFile;
2772 } 2772 }
2773 2773
2774 char *entry[4]; 2774 char *entry[4];
2775 unsigned int numCat = numCategories(), i; 2775 unsigned int numCat = numCategories(), i;
2776 unsigned int numEntr, j; 2776 unsigned int numEntr, j;
2777 int descLen, nameLen, pwLen, commentLen; 2777 int descLen, nameLen, pwLen, commentLen;
2778 for (i = 0; i < numCat; ++i) { 2778 for (i = 0; i < numCat; ++i) {
2779 numEntr = numEntries(i); 2779 numEntr = numEntries(i);
2780 for (j = 0; j < numEntr; ++j) { 2780 for (j = 0; j < numEntr; ++j) {
2781 descLen = dti.dta[i].d[j].desc.length(); 2781 descLen = dti.dta[i].d[j].desc.length();
2782 nameLen = dti.dta[i].d[j].name.length(); 2782 nameLen = dti.dta[i].d[j].name.length();
2783 pwLen = dti.dta[i].d[j].pw.length(); 2783 pwLen = dti.dta[i].d[j].pw.length();
2784 commentLen = dti.dta[i].d[j].comment.length(); 2784 commentLen = dti.dta[i].d[j].comment.length();
2785 entry[0] = new char[descLen + 1]; 2785 entry[0] = new char[descLen + 1];
2786 entry[1] = new char[nameLen + 1]; 2786 entry[1] = new char[nameLen + 1];
2787 entry[2] = new char[pwLen + 1]; 2787 entry[2] = new char[pwLen + 1];
2788 entry[3] = new char[commentLen + 1]; 2788 entry[3] = new char[commentLen + 1];
2789 strcpy(entry[0], descLen == 0 ? " " : dti.dta[i].d[j].desc.c_str()); 2789 strcpy(entry[0], descLen == 0 ? " " : dti.dta[i].d[j].desc.c_str());
2790 strcpy(entry[1], nameLen == 0 ? " " : dti.dta[i].d[j].name.c_str()); 2790 strcpy(entry[1], nameLen == 0 ? " " : dti.dta[i].d[j].name.c_str());
2791 strcpy(entry[2], pwLen == 0 ? " " : dti.dta[i].d[j].pw.c_str()); 2791 strcpy(entry[2], pwLen == 0 ? " " : dti.dta[i].d[j].pw.c_str());
2792 strcpy(entry[3], commentLen == 0 ? " " : dti.dta[i].d[j].comment.c_str()); 2792 strcpy(entry[3], commentLen == 0 ? " " : dti.dta[i].d[j].comment.c_str());
2793 entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0'; 2793 entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0';
2794 entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0'; 2794 entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0';
2795 entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0'; 2795 entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0';
2796 entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0'; 2796 entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0';
2797 2797
2798 ret = gp.save_entry(entry); 2798 ret = gp.save_entry(entry);
2799 if (ret == -1){ 2799 if (ret == -1){
2800 delete [] entry[0]; 2800 delete [] entry[0];
2801 delete [] entry[1]; 2801 delete [] entry[1];
2802 delete [] entry[2]; 2802 delete [] entry[2];
2803 delete [] entry[3]; 2803 delete [] entry[3];
2804 gp.save_finalize(); 2804 gp.save_finalize();
2805 unlockAll_tempoary(true); 2805 unlockAll_tempoary(true);
2806 return e_writeFile; 2806 return e_writeFile;
2807 } 2807 }
2808 2808
2809 delete [] entry[0]; 2809 delete [] entry[0];
2810 delete [] entry[1]; 2810 delete [] entry[1];
2811 delete [] entry[2]; 2811 delete [] entry[2];
2812 delete [] entry[3]; 2812 delete [] entry[3];
2813 } 2813 }
2814 } 2814 }
2815 unlockAll_tempoary(true); 2815 unlockAll_tempoary(true);
2816 if (gp.save_finalize() == -1) 2816 if (gp.save_finalize() == -1)
2817 return e_writeFile; 2817 return e_writeFile;
2818 2818
2819 return e_success; 2819 return e_success;
2820} 2820}
2821 2821
2822PwMerror PwMDoc::importFromGpasman(const QString *file) 2822PwMerror PwMDoc::importFromGpasman(const QString *file)
2823{ 2823{
2824 PWM_ASSERT(file); 2824 PWM_ASSERT(file);
2825 QString pw = requestMpw(false); 2825 QString pw = requestMpw(false);
2826 if (pw == "") 2826 if (pw == "")
2827 return e_noPw; 2827 return e_noPw;
2828 GpasmanFile gp; 2828 GpasmanFile gp;
2829 int ret, i; 2829 int ret, i;
2830 PwMerror ret2; 2830 PwMerror ret2;
2831 char *entry[4]; 2831 char *entry[4];
2832 PwMDataItem tmpData; 2832 PwMDataItem tmpData;
2833 ret = gp.load_init(file->latin1(), pw.latin1()); 2833 ret = gp.load_init(file->latin1(), pw.latin1());
2834 if (ret != 1) 2834 if (ret != 1)
2835 return e_accessFile; 2835 return e_accessFile;
2836 2836
2837 do { 2837 do {
2838 ret = gp.load_entry(entry); 2838 ret = gp.load_entry(entry);
2839 if(ret != 1) 2839 if(ret != 1)
2840 break; 2840 break;
2841 tmpData.desc = entry[0]; 2841 tmpData.desc = entry[0];
2842 tmpData.name = entry[1]; 2842 tmpData.name = entry[1];
2843 tmpData.pw = entry[2]; 2843 tmpData.pw = entry[2];
2844 tmpData.comment = entry[3]; 2844 tmpData.comment = entry[3];
2845 tmpData.lockStat = true; 2845 tmpData.lockStat = true;
2846 tmpData.listViewPos = -1; 2846 tmpData.listViewPos = -1;
2847 ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true); 2847 ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true);
2848 for (i = 0; i < 4; ++i) 2848 for (i = 0; i < 4; ++i)
2849 free(entry[i]); 2849 free(entry[i]);
2850 if (ret2 == e_maxAllowedEntr) { 2850 if (ret2 == e_maxAllowedEntr) {
2851 gp.load_finalize(); 2851 gp.load_finalize();
2852 return e_maxAllowedEntr; 2852 return e_maxAllowedEntr;
2853 } 2853 }
2854 } while (1); 2854 } while (1);
2855 gp.load_finalize(); 2855 gp.load_finalize();
2856 if (isDocEmpty()) 2856 if (isDocEmpty())
2857 return e_wrongPw; // we assume this. 2857 return e_wrongPw; // we assume this.
2858 2858
2859 flagDirty(); 2859 flagDirty();
2860 return e_success; 2860 return e_success;
2861} 2861}
2862 2862
2863 2863
2864//US: we use the stl sort algorythm to sort all elements in the order 2864//US: we use the stl sort algorythm to sort all elements in the order
2865//of its listViewPos (in the order 1,2,3,5,...,x,-1, -1, -1 2865//of its listViewPos (in the order 1,2,3,5,...,x,-1, -1, -1
2866struct PwMDataItemListViewPosSort 2866struct PwMDataItemListViewPosSort
2867{ 2867{
2868 bool operator()(PwMDataItem* rpStart, PwMDataItem* rpEnd) 2868 bool operator()(PwMDataItem* rpStart, PwMDataItem* rpEnd)
2869 { 2869 {
2870 //qDebug("pwMDoc::PwMDataItemListViewPosSort()"); 2870 //qDebug("pwMDoc::PwMDataItemListViewPosSort()");
2871 if ((rpEnd)->listViewPos < 0) 2871 if ((rpEnd)->listViewPos < 0)
2872 return false; 2872 return false;
2873 else 2873 else
2874 return (rpStart)->listViewPos < (rpEnd)->listViewPos; 2874 return (rpStart)->listViewPos < (rpEnd)->listViewPos;
2875 } 2875 }
2876}; 2876};
2877 2877
2878void PwMDoc::ensureLvp() 2878void PwMDoc::ensureLvp()
2879{ 2879{
2880 if (isDocEmpty()) 2880 if (isDocEmpty())
2881 return; 2881 return;
2882 2882
2883 //US ENH BUG: when using syncronizing, this way of sorting 2883 //US ENH BUG: when using syncronizing, this way of sorting
2884 //is not sufficient, because there might be empty spaces 2884 //is not sufficient, because there might be empty spaces
2885 // at the beginning. But the old algorythm only can add elements 2885 // at the beginning. But the old algorythm only can add elements
2886 //to the end.The result are crashes because of list overflows 2886 //to the end.The result are crashes because of list overflows
2887 //we need something to fill all gaps. 2887 //we need something to fill all gaps.
2888 vector<PwMDataItem*> sorted; 2888 vector<PwMDataItem*> sorted;
2889 vector< PwMDataItem*>::iterator sortedBegin, 2889 vector< PwMDataItem*>::iterator sortedBegin,
2890 sortedEnd, 2890 sortedEnd,
2891 sortedI; 2891 sortedI;
2892 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), 2892 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(),
2893 catEnd = dti.dta.end(), 2893 catEnd = dti.dta.end(),
2894 catI = catBegin; 2894 catI = catBegin;
2895 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 2895 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
2896 int lvpTop, tmpLvp; 2896 int lvpTop, tmpLvp;
2897 2897
2898 //qDebug("collect:"); 2898 //qDebug("collect:");
2899 2899
2900 while (catI != catEnd) { 2900 while (catI != catEnd) {
2901 lvpTop = -1; 2901 lvpTop = -1;
2902 sorted.clear(); 2902 sorted.clear();
2903 2903
2904 entrBegin = catI->d.begin(); 2904 entrBegin = catI->d.begin();
2905 entrEnd = catI->d.end(); 2905 entrEnd = catI->d.end();
2906 entrI = entrBegin; 2906 entrI = entrBegin;
2907 2907
2908 //US: we use the stl sort algorythm to sort all elements in the order 2908 //US: we use the stl sort algorythm to sort all elements in the order
2909 //of its listViewPos (in the order 1,2,2,3,5,...,x,-1, -1, -1 2909 //of its listViewPos (in the order 1,2,2,3,5,...,x,-1, -1, -1
2910 while (entrI != entrEnd) { 2910 while (entrI != entrEnd) {
2911 //qDebug("found: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); 2911 //qDebug("found: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos);
2912 sorted.push_back((PwMDataItem*)&(*entrI)); 2912 sorted.push_back((PwMDataItem*)&(*entrI));
2913 ++entrI; 2913 ++entrI;
2914 } 2914 }
2915 2915
2916 sortedBegin = sorted.begin(); 2916 sortedBegin = sorted.begin();
2917 sortedEnd = sorted.end(); 2917 sortedEnd = sorted.end();
2918 2918
2919 sort(sortedBegin, sortedEnd, PwMDataItemListViewPosSort()); 2919 sort(sortedBegin, sortedEnd, PwMDataItemListViewPosSort());
2920 2920
2921 // qDebug("resort:"); 2921 // qDebug("resort:");
2922 //now we have all sorted in a collection 2922 //now we have all sorted in a collection
2923 //Now start with the sorted and reset listviewpos. 2923 //Now start with the sorted and reset listviewpos.
2924 sortedBegin = sorted.begin(); 2924 sortedBegin = sorted.begin();
2925 sortedEnd = sorted.end(); 2925 sortedEnd = sorted.end();
2926 sortedI = sortedBegin; 2926 sortedI = sortedBegin;
2927 2927
2928 while (sortedI != sortedEnd) { 2928 while (sortedI != sortedEnd) {
2929 // qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1); 2929 // qDebug("reset defined: %s, from pos=%i to pos=%i", (*sortedI)->desc.c_str(), (*sortedI)->listViewPos, lvpTop+1);
2930 (*sortedI)->listViewPos = ++lvpTop; 2930 (*sortedI)->listViewPos = ++lvpTop;
2931 ++sortedI; 2931 ++sortedI;
2932 } 2932 }
2933 2933
2934 /*/debug 2934 /*/debug
2935 entrBegin = catI->d.begin(); 2935 entrBegin = catI->d.begin();
2936 entrEnd = catI->d.end(); 2936 entrEnd = catI->d.end();
2937 entrI = entrBegin; 2937 entrI = entrBegin;
2938 2938
2939 while (entrI != entrEnd) { 2939 while (entrI != entrEnd) {
2940 qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); 2940 qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos);
2941 ++entrI; 2941 ++entrI;
2942 } 2942 }
2943 */ 2943 */
2944 2944
2945 ++catI; 2945 ++catI;
2946 } 2946 }
2947} 2947}
2948 2948
2949QString PwMDoc::getTitle() 2949QString PwMDoc::getTitle()
2950{ 2950{
2951 /* NOTE: We have to ensure, that the returned title 2951 /* NOTE: We have to ensure, that the returned title
2952 * is unique and not reused somewhere else while 2952 * is unique and not reused somewhere else while
2953 * this document is valid (open). 2953 * this document is valid (open).
2954 */ 2954 */
2955 QString title(getFilename()); 2955 QString title(getFilename());
2956 2956
2957 //US ENH: The whole filename on PDAs is too long. So use only the last characters 2957 //US ENH: The whole filename on PDAs is too long. So use only the last characters
2958 if (QApplication::desktop()->width() < 640) 2958 if (QApplication::desktop()->width() < 640)
2959 { 2959 {
2960 if (title.length() > 30) 2960 if (title.length() > 30)
2961 title = "..." + title.right(30); 2961 title = "..." + title.right(30);
2962 2962
2963 } 2963 }
2964 2964
2965 2965
2966 if (title.isEmpty()) { 2966 if (title.isEmpty()) {
2967 if (unnamedNum == 0) { 2967 if (unnamedNum == 0) {
2968 unnamedNum = PwMDocList::getNewUnnamedNumber(); 2968 unnamedNum = PwMDocList::getNewUnnamedNumber();
2969 PWM_ASSERT(unnamedNum != 0); 2969 PWM_ASSERT(unnamedNum != 0);
2970 } 2970 }
2971 title = DEFAULT_TITLE; 2971 title = DEFAULT_TITLE;
2972 title += " "; 2972 title += " ";
2973 title += tostr(unnamedNum).c_str(); 2973 title += tostr(unnamedNum).c_str();
2974 } 2974 }
2975 return title; 2975 return title;
2976} 2976}
2977 2977
2978bool PwMDoc::tryDelete() 2978bool PwMDoc::tryDelete()
2979{ 2979{
2980
2980 if (deleted) 2981 if (deleted)
2981 return true; 2982 return true;
2982 int ret; 2983 int ret;
2983 if (isDirty()) { 2984 if (isDirty()) {
2984 ret = dirtyAskSave(getTitle()); 2985 ret = dirtyAskSave(getTitle());
2985 if (ret == 0) { // save to disk 2986 if (ret == 0) { // save to disk
2986 if (!saveDocUi(this)) 2987 if (!saveDocUi(this))
2987 goto out_ignore; 2988 goto out_ignore;
2988 } else if (ret == 1) { // don't save and delete 2989 } else if (ret == 1) { // don't save and delete
2989 goto out_accept; 2990 goto out_accept;
2990 } else { // cancel operation 2991 } else { // cancel operation
2991 goto out_ignore; 2992 goto out_ignore;
2992 } 2993 }
2993 } 2994 }
2994out_accept: 2995out_accept:
2995 deleted = true; 2996 deleted = true;
2996 delete this; 2997 delete this;
2997 return true; 2998 return true;
2998out_ignore: 2999out_ignore:
2999 return false; 3000 return false;
3000} 3001}
3001 3002
3002 3003
3003 3004
3004#ifdef PWM_EMBEDDED 3005#ifdef PWM_EMBEDDED
3005//US ENH: this is the magic function that syncronizes the this doc with the remote doc 3006//US ENH: this is the magic function that syncronizes the this doc with the remote doc
3006//US it could have been defined as static, but I did not want to. 3007//US it could have been defined as static, but I did not want to.
3007PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) 3008PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode )
3008{ 3009{
3009 int addedPasswordsLocal = 0; 3010 int addedPasswordsLocal = 0;
3010 int addedPasswordsRemote = 0; 3011 int addedPasswordsRemote = 0;
3011 int deletedPasswordsRemote = 0; 3012 int deletedPasswordsRemote = 0;
3012 int deletedPasswordsLocal = 0; 3013 int deletedPasswordsLocal = 0;
3013 int changedLocal = 0; 3014 int changedLocal = 0;
3014 int changedRemote = 0; 3015 int changedRemote = 0;
3015 3016
3016 PwMSyncItem* syncItemLocal; 3017 PwMSyncItem* syncItemLocal;
3017 PwMSyncItem* syncItemRemote; 3018 PwMSyncItem* syncItemRemote;
3018 3019
3019 QString mCurrentSyncName = manager->getCurrentSyncName(); 3020 QString mCurrentSyncName = manager->getCurrentSyncName();
3020 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3021 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3021 3022
3022 bool fullDateRange = false; 3023 bool fullDateRange = false;
3023 int take; 3024 int take;
3024 // local->resetTempSyncStat(); 3025 // local->resetTempSyncStat();
3025 QDateTime mLastSync = QDateTime::currentDateTime(); 3026 QDateTime mLastSync = QDateTime::currentDateTime();
3026 QDateTime modifiedSync = mLastSync; 3027 QDateTime modifiedSync = mLastSync;
3027 3028
3028 unsigned int index; 3029 unsigned int index;
3029 //Step 1. Find syncinfo in Local file and create if not existent. 3030 //Step 1. Find syncinfo in Local file and create if not existent.
3030 bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); 3031 bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index);
3031 if (found == false) 3032 if (found == false)
3032 { 3033 {
3033 PwMSyncItem newSyncItemLocal; 3034 PwMSyncItem newSyncItemLocal;
3034 newSyncItemLocal.syncName = mCurrentSyncDevice.latin1(); 3035 newSyncItemLocal.syncName = mCurrentSyncDevice.latin1();
3035 newSyncItemLocal.lastSyncDate = mLastSync; 3036 newSyncItemLocal.lastSyncDate = mLastSync;
3036 syncLocal->addSyncDataEntry(&newSyncItemLocal, true); 3037 syncLocal->addSyncDataEntry(&newSyncItemLocal, true);
3037 found = syncLocal->findSyncData(mCurrentSyncDevice, &index); 3038 found = syncLocal->findSyncData(mCurrentSyncDevice, &index);
3038 if (found == false) { 3039 if (found == false) {
3039 qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); 3040 qDebug("PwMDoc::syncronize : newly created local sync data could not be found");
3040 return e_syncError; 3041 return e_syncError;
3041 } 3042 }
3042 } 3043 }
3043 3044
3044 syncItemLocal = syncLocal->getSyncDataEntry(index); 3045 syncItemLocal = syncLocal->getSyncDataEntry(index);
3045 qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1()); 3046 qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1());
3046 3047
3047 //Step 2. Find syncinfo in remote file and create if not existent. 3048 //Step 2. Find syncinfo in remote file and create if not existent.
3048 found = syncRemote->findSyncData(mCurrentSyncName, &index); 3049 found = syncRemote->findSyncData(mCurrentSyncName, &index);
3049 if (found == false) 3050 if (found == false)
3050 { 3051 {
3051 qDebug("FULLDATE 1"); 3052 qDebug("FULLDATE 1");
3052 fullDateRange = true; 3053 fullDateRange = true;
3053 PwMSyncItem newSyncItemRemote; 3054 PwMSyncItem newSyncItemRemote;
3054 newSyncItemRemote.syncName = mCurrentSyncName.latin1(); 3055 newSyncItemRemote.syncName = mCurrentSyncName.latin1();
3055 newSyncItemRemote.lastSyncDate = mLastSync; 3056 newSyncItemRemote.lastSyncDate = mLastSync;
3056 syncRemote->addSyncDataEntry(&newSyncItemRemote, true); 3057 syncRemote->addSyncDataEntry(&newSyncItemRemote, true);
3057 found = syncRemote->findSyncData(mCurrentSyncName, &index); 3058 found = syncRemote->findSyncData(mCurrentSyncName, &index);
3058 if (found == false) { 3059 if (found == false) {
3059 qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); 3060 qDebug("PwMDoc::syncronize : newly created remote sync data could not be found");
3060 return e_syncError; 3061 return e_syncError;
3061 } 3062 }
3062 } 3063 }
3063 3064
3064 syncItemRemote = syncRemote->getSyncDataEntry(index); 3065 syncItemRemote = syncRemote->getSyncDataEntry(index);
3065 qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1()); 3066 qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1());
3066 //and remove the found entry here. We will reenter it later again. 3067 //and remove the found entry here. We will reenter it later again.
3067 //US syncRemote->delSyncDataEntry(index, true); 3068 //US syncRemote->delSyncDataEntry(index, true);
3068 3069
3069 3070
3070 if ( syncItemLocal->lastSyncDate == mLastSync ) { 3071 if ( syncItemLocal->lastSyncDate == mLastSync ) {
3071 qDebug("FULLDATE 2"); 3072 qDebug("FULLDATE 2");
3072 fullDateRange = true; 3073 fullDateRange = true;
3073 } 3074 }
3074 3075
3075 if ( ! fullDateRange ) { 3076 if ( ! fullDateRange ) {
3076 if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { 3077 if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) {
3077 3078
3078 fullDateRange = true; 3079 fullDateRange = true;
3079 qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); 3080 qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() );
3080 } 3081 }
3081 } 3082 }
3082 // fullDateRange = true; // debug only! 3083 // fullDateRange = true; // debug only!
3083 if ( fullDateRange ) 3084 if ( fullDateRange )
3084 mLastSync = QDateTime::currentDateTime().addDays( -100*365); 3085 mLastSync = QDateTime::currentDateTime().addDays( -100*365);
3085 else 3086 else
3086 mLastSync = syncItemLocal->lastSyncDate; 3087 mLastSync = syncItemLocal->lastSyncDate;
3087 3088
3088 3089
3089 qDebug("*************************** "); 3090 qDebug("*************************** ");
3090 qDebug("mLastSync %s ",mLastSync.toString().latin1() ); 3091 qDebug("mLastSync %s ",mLastSync.toString().latin1() );
3091 QStringList er = syncRemote->getIDEntryList(); 3092 QStringList er = syncRemote->getIDEntryList();
3092 PwMDataItem* inRemote ;//= er.first(); 3093 PwMDataItem* inRemote ;//= er.first();
3093 PwMDataItem* inLocal; 3094 PwMDataItem* inLocal;
3094 unsigned int catLocal, indexLocal; 3095 unsigned int catLocal, indexLocal;
3095 unsigned int catRemote, indexRemote; 3096 unsigned int catRemote, indexRemote;
3096 3097
3097 QString uid; 3098 QString uid;
3098 manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3099 manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3099 3100
3100 int modulo = (er.count()/10)+1; 3101 int modulo = (er.count()/10)+1;
3101 unsigned int incCounter = 0; 3102 unsigned int incCounter = 0;
3102 while ( incCounter < er.count()) { 3103 while ( incCounter < er.count()) {
3103 if (manager->isProgressBarCanceled()) 3104 if (manager->isProgressBarCanceled())
3104 return e_syncError; 3105 return e_syncError;
3105 if ( incCounter % modulo == 0 ) 3106 if ( incCounter % modulo == 0 )
3106 manager->showProgressBar(incCounter); 3107 manager->showProgressBar(incCounter);
3107 3108
3108 uid = er[ incCounter ]; 3109 uid = er[ incCounter ];
3109 qDebug("sync uid %s from remote file", uid.latin1()); 3110 qDebug("sync uid %s from remote file", uid.latin1());
3110 3111
3111 qApp->processEvents(); 3112 qApp->processEvents();
3112 3113
3113 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); 3114 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
3114 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); 3115 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
3115 PWM_ASSERT(inRemote); 3116 PWM_ASSERT(inRemote);
3116 if ( inLocal != 0 ) { // maybe conflict - same uid in both files 3117 if ( inLocal != 0 ) { // maybe conflict - same uid in both files
3117 if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { 3118 if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) {
3118 qDebug("take %d %s ", take, inLocal->desc.c_str()); 3119 qDebug("take %d %s ", take, inLocal->desc.c_str());
3119 if ( take == 3 ) 3120 if ( take == 3 )
3120 return e_syncError; 3121 return e_syncError;
3121 if ( take == 1 ) {// take local 3122 if ( take == 1 ) {// take local
3122 int oldlistpos = inRemote->listViewPos; 3123 int oldlistpos = inRemote->listViewPos;
3123 (*inRemote) = (*inLocal); 3124 (*inRemote) = (*inLocal);
3124 inRemote->listViewPos = oldlistpos; 3125 inRemote->listViewPos = oldlistpos;
3125 ++changedRemote; 3126 ++changedRemote;
3126 } else { // take == 2 take remote 3127 } else { // take == 2 take remote
3127 int oldlistpos = inLocal->listViewPos; 3128 int oldlistpos = inLocal->listViewPos;
3128 (*inLocal) = (*inRemote); 3129 (*inLocal) = (*inRemote);
3129 inLocal->listViewPos = oldlistpos; 3130 inLocal->listViewPos = oldlistpos;
3130 ++changedLocal; 3131 ++changedLocal;
3131 } 3132 }
3132 } 3133 }
3133 } else { // no conflict 3134 } else { // no conflict
3134 if ( inRemote->meta.update > mLastSync || mode == 5 ) { 3135 if ( inRemote->meta.update > mLastSync || mode == 5 ) {
3135 inRemote->meta.update = modifiedSync; 3136 inRemote->meta.update = modifiedSync;
3136 3137
3137 //first check if we have a matching category in the local file 3138 //first check if we have a matching category in the local file
3138 const string* remotecat = syncRemote->getCategory(catRemote); 3139 const string* remotecat = syncRemote->getCategory(catRemote);
3139 syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); 3140 syncLocal->addEntry(remotecat->c_str(), inRemote, true, false);
3140 3141
3141 ++addedPasswordsLocal; 3142 ++addedPasswordsLocal;
3142 } else { 3143 } else {
3143 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3144 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3144 syncRemote->delEntry(catRemote, indexRemote, true); 3145 syncRemote->delEntry(catRemote, indexRemote, true);
3145 ++deletedPasswordsRemote; 3146 ++deletedPasswordsRemote;
3146 } 3147 }
3147 } 3148 }
3148 3149
3149 ++incCounter; 3150 ++incCounter;
3150 } 3151 }
3151 3152
3152 3153
3153 er.clear(); 3154 er.clear();
3154 QStringList el = syncLocal->getIDEntryList(); 3155 QStringList el = syncLocal->getIDEntryList();
3155 modulo = (el.count()/10)+1; 3156 modulo = (el.count()/10)+1;
3156 3157
3157 manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3158 manager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3158 incCounter = 0; 3159 incCounter = 0;
3159 while ( incCounter < el.count()) { 3160 while ( incCounter < el.count()) {
3160 qApp->processEvents(); 3161 qApp->processEvents();
3161 if (manager->isProgressBarCanceled()) 3162 if (manager->isProgressBarCanceled())
3162 return e_syncError; 3163 return e_syncError;
3163 if ( incCounter % modulo == 0 ) 3164 if ( incCounter % modulo == 0 )
3164 manager->showProgressBar(incCounter); 3165 manager->showProgressBar(incCounter);
3165 uid = el[ incCounter ]; 3166 uid = el[ incCounter ];
3166 qDebug("sync uid %s from local file", uid.latin1()); 3167 qDebug("sync uid %s from local file", uid.latin1());
3167 3168
3168 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); 3169 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
3169 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); 3170 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
3170 PWM_ASSERT(inLocal); 3171 PWM_ASSERT(inLocal);
3171 3172
3172 if ( inRemote == 0 ) { 3173 if ( inRemote == 0 ) {
3173 if ( inLocal->meta.update < mLastSync && mode != 4 ) { 3174 if ( inLocal->meta.update < mLastSync && mode != 4 ) {
3174 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3175 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3175 syncLocal->delEntry(catLocal, indexLocal, true); 3176 syncLocal->delEntry(catLocal, indexLocal, true);
3176 ++deletedPasswordsLocal; 3177 ++deletedPasswordsLocal;
3177 } else { 3178 } else {
3178 if ( ! manager->mWriteBackExistingOnly ) { 3179 if ( ! manager->mWriteBackExistingOnly ) {
3179 ++addedPasswordsRemote; 3180 ++addedPasswordsRemote;
3180 inLocal->meta.update = modifiedSync; 3181 inLocal->meta.update = modifiedSync;
3181 3182
3182 //first check if we have a matching category in the remote file 3183 //first check if we have a matching category in the remote file
3183 const string* localcat = syncLocal->getCategory(catLocal); 3184 const string* localcat = syncLocal->getCategory(catLocal);
3184 3185
3185 PwMDataItem newEntry; 3186 PwMDataItem newEntry;
3186 newEntry = *inLocal; 3187 newEntry = *inLocal;
3187 inRemote = &newEntry; 3188 inRemote = &newEntry;
3188 3189
3189 //USsyncRemote->insertAddressee( inRemote, false ); 3190 //USsyncRemote->insertAddressee( inRemote, false );
3190 syncRemote->addEntry(localcat->c_str(), inRemote, true, false); 3191 syncRemote->addEntry(localcat->c_str(), inRemote, true, false);
3191 3192
3192 } 3193 }
3193 } 3194 }
3194 3195
3195 } 3196 }
3196 ++incCounter; 3197 ++incCounter;
3197 } 3198 }
3198 el.clear(); 3199 el.clear();
3199 manager->hideProgressBar(); 3200 manager->hideProgressBar();
3200 3201
3201 // Now write the info back into the sync data space of the files 3202 // Now write the info back into the sync data space of the files
3202 3203
3203 mLastSync = QDateTime::currentDateTime().addSecs( 1 ); 3204 mLastSync = QDateTime::currentDateTime().addSecs( 1 );
3204 // get rid of micro seconds 3205 // get rid of micro seconds
3205 QTime t = mLastSync.time(); 3206 QTime t = mLastSync.time();
3206 mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3207 mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3207 3208
3208 3209
3209 syncItemLocal->lastSyncDate = mLastSync; 3210 syncItemLocal->lastSyncDate = mLastSync;
3210 syncItemRemote->lastSyncDate = mLastSync; 3211 syncItemRemote->lastSyncDate = mLastSync;
3211 3212
3212 QString mes; 3213 QString mes;
3213 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 ); 3214 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 );
3214 if ( manager->mShowSyncSummary ) { 3215 if ( manager->mShowSyncSummary ) {
3215 KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); 3216 KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") );
3216 } 3217 }
3217 qDebug( mes ); 3218 qDebug( mes );
3218 return e_success; 3219 return e_success;
3219} 3220}
3220 3221
3221 3222
3222int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) 3223int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full )
3223{ 3224{
3224 // 0 equal 3225 // 0 equal
3225 // 1 take local 3226 // 1 take local
3226 // 2 take remote 3227 // 2 take remote
3227 // 3 cancel 3228 // 3 cancel
3228 QDateTime localMod = local->meta.update; 3229 QDateTime localMod = local->meta.update;
3229 QDateTime remoteMod = remote->meta.update; 3230 QDateTime remoteMod = remote->meta.update;
3230 3231
3231 if ( localMod == remoteMod ) 3232 if ( localMod == remoteMod )
3232 return 0; 3233 return 0;
3233 3234
3234 qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); 3235 qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() );
3235 3236
3236 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 3237 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
3237 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 3238 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
3238 //full = true; //debug only 3239 //full = true; //debug only
3239 if ( full ) { 3240 if ( full ) {
3240 bool equ = ( (*local) == (*remote) ); 3241 bool equ = ( (*local) == (*remote) );
3241 if ( equ ) { 3242 if ( equ ) {
3242 //qDebug("equal "); 3243 //qDebug("equal ");
3243 if ( mode < SYNC_PREF_FORCE_LOCAL ) 3244 if ( mode < SYNC_PREF_FORCE_LOCAL )
3244 return 0; 3245 return 0;
3245 3246
3246 }//else //debug only 3247 }//else //debug only
3247 //qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str()); 3248 //qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str());
3248 } 3249 }
3249 3250
3250 int result; 3251 int result;
3251 bool localIsNew; 3252 bool localIsNew;
3252 //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() ); 3253 //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() );
3253 3254
3254 if ( full && mode < SYNC_PREF_NEWEST ) 3255 if ( full && mode < SYNC_PREF_NEWEST )
3255 mode = SYNC_PREF_ASK; 3256 mode = SYNC_PREF_ASK;
3256 3257
3257 switch( mode ) { 3258 switch( mode ) {
3258 case SYNC_PREF_LOCAL: 3259 case SYNC_PREF_LOCAL:
3259 if ( lastSync > remoteMod ) 3260 if ( lastSync > remoteMod )
3260 return 1; 3261 return 1;
3261 if ( lastSync > localMod ) 3262 if ( lastSync > localMod )
3262 return 2; 3263 return 2;
3263 return 1; 3264 return 1;
3264 break; 3265 break;
3265 case SYNC_PREF_REMOTE: 3266 case SYNC_PREF_REMOTE:
3266 if ( lastSync > remoteMod ) 3267 if ( lastSync > remoteMod )
3267 return 1; 3268 return 1;
3268 if ( lastSync > localMod ) 3269 if ( lastSync > localMod )
3269 return 2; 3270 return 2;
3270 return 2; 3271 return 2;
3271 break; 3272 break;
3272 case SYNC_PREF_NEWEST: 3273 case SYNC_PREF_NEWEST:
3273 if ( localMod > remoteMod ) 3274 if ( localMod > remoteMod )
3274 return 1; 3275 return 1;
3275 else 3276 else
3276 return 2; 3277 return 2;
3277 break; 3278 break;
3278 case SYNC_PREF_ASK: 3279 case SYNC_PREF_ASK:
3279 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 3280 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
3280 if ( lastSync > remoteMod ) 3281 if ( lastSync > remoteMod )
3281 return 1; 3282 return 1;
3282 if ( lastSync > localMod ) 3283 if ( lastSync > localMod )
3283 return 2; 3284 return 2;
3284 localIsNew = localMod >= remoteMod; 3285 localIsNew = localMod >= remoteMod;
3285 //qDebug("conflict! ************************************** "); 3286 //qDebug("conflict! ************************************** ");
3286 { 3287 {
3287 PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); 3288 PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ );
3288 result = acd.executeD(localIsNew); 3289 result = acd.executeD(localIsNew);
3289 return result; 3290 return result;
3290 } 3291 }
3291 break; 3292 break;
3292 case SYNC_PREF_FORCE_LOCAL: 3293 case SYNC_PREF_FORCE_LOCAL:
3293 return 1; 3294 return 1;
3294 break; 3295 break;
3295 case SYNC_PREF_FORCE_REMOTE: 3296 case SYNC_PREF_FORCE_REMOTE:
3296 return 2; 3297 return 2;
3297 break; 3298 break;
3298 3299
3299 default: 3300 default:
3300 // SYNC_PREF_TAKE_BOTH not implemented 3301 // SYNC_PREF_TAKE_BOTH not implemented
3301 break; 3302 break;
3302 } 3303 }
3303 return 0; 3304 return 0;
3304} 3305}
3305 3306
3306 3307
3307 3308
3308 3309
3309//this are the overwritten callbackmethods from the syncinterface 3310//this are the overwritten callbackmethods from the syncinterface
3310bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) 3311bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
3311{ 3312{
3312 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3313 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3313 3314
3314 //1) unlock local file first if necessary (ask for password) 3315 //1) unlock local file first if necessary (ask for password)
3315 if (this->isDeepLocked()) { 3316 if (this->isDeepLocked()) {
3316 PwMerror ret = this->deepLock(false); 3317 PwMerror ret = this->deepLock(false);
3317 if (ret != e_success) 3318 if (ret != e_success)
3318 return false; 3319 return false;
3319 } 3320 }
3320 3321
3321 //2) construct and open a new doc on the stack(automatic cleanup of remote file). 3322 //2) construct and open a new doc on the stack(automatic cleanup of remote file).
3322 PwMDoc syncTarget(this, "synctarget"); 3323 PwMDoc syncTarget(this, "synctarget");
3323 PwMDoc* pSyncTarget = &syncTarget; 3324 PwMDoc* pSyncTarget = &syncTarget;
3324 3325
3325 3326
3326 PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); 3327 PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/);
3327 3328
3328 if (err == e_alreadyOpen) { 3329 if (err == e_alreadyOpen) {
3329 PwMDocList::listItem li; 3330 PwMDocList::listItem li;
3330 if (getOpenDocList()->find(filename.latin1(), &li)) 3331 if (getOpenDocList()->find(filename.latin1(), &li))
3331 pSyncTarget = li.doc; 3332 pSyncTarget = li.doc;
3332 else { 3333 else {
3333 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); 3334 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1());
3334 return false; 3335 return false;
3335 } 3336 }
3336 } 3337 }
3337 else if (err != e_success) { 3338 else if (err != e_success) {
3338 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); 3339 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1());
3339 return false; 3340 return false;
3340 } 3341 }
3341 3342
3342 qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); 3343 qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode );
3343 3344
3344 3345
3345 //3) unlock remote file first if necessary (ask for password) 3346 //3) unlock remote file first if necessary (ask for password)
3346 if (pSyncTarget->isDeepLocked()) { 3347 if (pSyncTarget->isDeepLocked()) {
3347 PwMerror ret = pSyncTarget->deepLock(false); 3348 PwMerror ret = pSyncTarget->deepLock(false);
3348 if (ret != e_success) 3349 if (ret != e_success)
3349 return false; 3350 return false;
3350 } 3351 }
3351 3352
3352 3353
3353 err = syncronize(manager, this, pSyncTarget, mode ); 3354 err = syncronize(manager, this, pSyncTarget, mode );
3354 3355
3355 if (err == e_success) { 3356 if (err == e_success) {
3356 if ( manager->mWriteBackFile ){ 3357 if ( manager->mWriteBackFile ){
3357 qDebug("Saving remote PWManager file"); 3358 qDebug("Saving remote PWManager file");
3358 err = pSyncTarget->saveDoc(conf()->confGlobCompression()); 3359 err = pSyncTarget->saveDoc(conf()->confGlobCompression());
3359 if (err != e_success) { 3360 if (err != e_success) {
3360 qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); 3361 qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1());
3361 return false; 3362 return false;
3362 } 3363 }
3363 } 3364 }
diff --git a/pwmanager/pwmanager/pwmdocui.cpp b/pwmanager/pwmanager/pwmdocui.cpp
index 71b4a8d..a9916c2 100644
--- a/pwmanager/pwmanager/pwmdocui.cpp
+++ b/pwmanager/pwmanager/pwmdocui.cpp
@@ -1,467 +1,470 @@
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#include "pwmdocui.h" 20#include "pwmdocui.h"
21#include "setmasterpwwndimpl.h" 21#include "setmasterpwwndimpl.h"
22#include "getmasterpwwndimpl.h" 22#include "getmasterpwwndimpl.h"
23#include "pwmexception.h" 23#include "pwmexception.h"
24#include "getkeycardwnd.h" 24#include "getkeycardwnd.h"
25#include "pwm.h" 25#include "pwm.h"
26#include "globalstuff.h" 26#include "globalstuff.h"
27#include "spinforsignal.h" 27#include "spinforsignal.h"
28 28
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31 31
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33#include <kfiledialog.h> 33#include <kfiledialog.h>
34 34
35#ifndef PWM_EMBEDDED 35#ifndef PWM_EMBEDDED
36#include <kwin.h> 36#include <kwin.h>
37#else 37#else
38#include <qdir.h> 38#include <qdir.h>
39#include "pwmprefs.h" 39#include "pwmprefs.h"
40#endif 40#endif
41 41
42 42
43#ifdef CONFIG_KEYCARD 43#ifdef CONFIG_KEYCARD
44# include "pwmkeycard.h" 44# include "pwmkeycard.h"
45#endif 45#endif
46 46
47 47
48PwMDocUi::PwMDocUi(QObject *parent, const char *name) 48PwMDocUi::PwMDocUi(QObject *parent, const char *name)
49 : QObject(parent, name) 49 : QObject(parent, name)
50{ 50{
51 currentView = 0; 51 currentView = 0;
52 keyCard = 0; 52 keyCard = 0;
53} 53}
54 54
55PwMDocUi::~PwMDocUi() 55PwMDocUi::~PwMDocUi()
56{ 56{
57} 57}
58 58
59QString PwMDocUi::requestMpw(bool chipcard) 59QString PwMDocUi::requestMpw(bool chipcard)
60{ 60{
61 QString pw; 61 QString pw;
62 62
63 if (chipcard) { 63 if (chipcard) {
64#ifdef CONFIG_KEYCARD 64#ifdef CONFIG_KEYCARD
65 PWM_ASSERT(keyCard); 65 PWM_ASSERT(keyCard);
66 uint32_t id; 66 uint32_t id;
67 string ret; 67 string ret;
68 SpinForSignal *spinner = keyCard->getSpinner(); 68 SpinForSignal *spinner = keyCard->getSpinner();
69 connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), 69 connect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
70 spinner, SLOT(u32_str_slot(uint32_t, const string &))); 70 spinner, SLOT(u32_str_slot(uint32_t, const string &)));
71 keyCard->getKey(); 71 keyCard->getKey();
72 spinner->spin(&id, &ret); 72 spinner->spin(&id, &ret);
73 disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)), 73 disconnect(keyCard, SIGNAL(keyAvailable(uint32_t, const string &)),
74 spinner, SLOT(u32_str_slot(uint32_t, const string &))); 74 spinner, SLOT(u32_str_slot(uint32_t, const string &)));
75 if (ret == "") 75 if (ret == "")
76 return ""; 76 return "";
77 pw = ret.c_str(); 77 pw = ret.c_str();
78#else // CONFIG_KEYCARD 78#else // CONFIG_KEYCARD
79 no_keycard_support_msg_box(currentView); 79 no_keycard_support_msg_box(currentView);
80#endif // CONFIG_KEYCARD 80#endif // CONFIG_KEYCARD
81 } else { 81 } else {
82#ifndef PWM_EMBEDDED 82#ifndef PWM_EMBEDDED
83 GetMasterPwWndImpl pwWnd; 83 GetMasterPwWndImpl pwWnd;
84 KWin::setState(pwWnd.winId(), NET::StaysOnTop); 84 KWin::setState(pwWnd.winId(), NET::StaysOnTop);
85#else 85#else
86 GetMasterPwWndImpl pwWnd; 86 GetMasterPwWndImpl pwWnd;
87#endif 87#endif
88 if (pwWnd.exec() != 1) 88 if (pwWnd.exec() != 1)
89 return ""; 89 return "";
90 pw = pwWnd.pwLineEdit->text(); 90 pw = pwWnd.pwLineEdit->text();
91 } 91 }
92 92
93 return pw; 93 return pw;
94} 94}
95 95
96QString PwMDocUi::requestNewMpw(bool *chipcard) 96QString PwMDocUi::requestNewMpw(bool *chipcard)
97{ 97{
98 QString pw; 98 QString pw;
99 SetMasterPwWndImpl pwWnd(currentView); 99 SetMasterPwWndImpl pwWnd(currentView);
100 pwWnd.setPwMKeyCard(keyCard); 100 pwWnd.setPwMKeyCard(keyCard);
101 if (!chipcard) { 101 if (!chipcard) {
102#ifndef PWM_EMBEDDED 102#ifndef PWM_EMBEDDED
103 pwWnd.mainTab->removePage(pwWnd.mainTab->page(1)); 103 pwWnd.mainTab->removePage(pwWnd.mainTab->page(1));
104#else 104#else
105 pwWnd.mainTab->removePage(pwWnd.tab_2); 105 pwWnd.mainTab->removePage(pwWnd.tab_2);
106#endif 106#endif
107 } 107 }
108 108
109 if (pwWnd.exec() != 1) 109 if (pwWnd.exec() != 1)
110 return ""; 110 return "";
111 pw = pwWnd.getPw(chipcard).c_str(); 111 pw = pwWnd.getPw(chipcard).c_str();
112 112
113 return pw; 113 return pw;
114} 114}
115 115
116QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard) 116QString PwMDocUi::requestMpwChange(const QString *currentPw, bool *chipcard)
117{ 117{
118 QString pw(requestMpw(*chipcard)); 118 QString pw(requestMpw(*chipcard));
119 if (pw == "") 119 if (pw == "")
120 return ""; 120 return "";
121 if (pw != *currentPw) { 121 if (pw != *currentPw) {
122 wrongMpwMsgBox(*chipcard); 122 wrongMpwMsgBox(*chipcard);
123 return ""; 123 return "";
124 } 124 }
125 125
126 pw = requestNewMpw(chipcard); 126 pw = requestNewMpw(chipcard);
127 if (pw == "") 127 if (pw == "")
128 return ""; 128 return "";
129 return pw; 129 return pw;
130} 130}
131 131
132void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix) 132void PwMDocUi::wrongMpwMsgBox(bool chipcard, QString prefix, QString postfix)
133{ 133{
134 QString msg; 134 QString msg;
135 if (prefix != "") { 135 if (prefix != "") {
136 msg += prefix; 136 msg += prefix;
137 msg += "\n"; 137 msg += "\n";
138 } 138 }
139 139
140 if (chipcard) { 140 if (chipcard) {
141 msg += i18n("Wrong key-card!\n" 141 msg += i18n("Wrong key-card!\n"
142 "Please try again with the\n" 142 "Please try again with the\n"
143 "correct key-card."); 143 "correct key-card.");
144 } else { 144 } else {
145 msg += i18n("Wrong master-password!\n" 145 msg += i18n("Wrong master-password!\n"
146 "Please try again."); 146 "Please try again.");
147 } 147 }
148 148
149 if (postfix != "") { 149 if (postfix != "") {
150 msg += "\n"; 150 msg += "\n";
151 msg += postfix; 151 msg += postfix;
152 } 152 }
153 KMessageBox::error(currentView, msg, 153 KMessageBox::error(currentView, msg,
154 (chipcard) ? (i18n("wrong chipcard")) 154 (chipcard) ? (i18n("wrong chipcard"))
155 : (i18n("password error"))); 155 : (i18n("password error")));
156} 156}
157 157
158void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix) 158void PwMDocUi::noMpwMsgBox(bool chipcard, QString prefix, QString postfix)
159{ 159{
160 QString msg; 160 QString msg;
161 if (prefix != "") { 161 if (prefix != "") {
162 msg += prefix; 162 msg += prefix;
163 msg += "\n"; 163 msg += "\n";
164 } 164 }
165 165
166 if (chipcard) { 166 if (chipcard) {
167 msg += i18n("No key-card found!\n" 167 msg += i18n("No key-card found!\n"
168 "Please insert the\n" 168 "Please insert the\n"
169 "correct key-card."); 169 "correct key-card.");
170 } else { 170 } else {
171 msg += i18n("No master-password given!"); 171 msg += i18n("No master-password given!");
172 } 172 }
173 173
174 if (postfix != "") { 174 if (postfix != "") {
175 msg += "\n"; 175 msg += "\n";
176 msg += postfix; 176 msg += postfix;
177 } 177 }
178 KMessageBox::error(currentView, msg, 178 KMessageBox::error(currentView, msg,
179 (chipcard) ? (i18n("no chipcard")) 179 (chipcard) ? (i18n("no chipcard"))
180 : (i18n("password error"))); 180 : (i18n("password error")));
181} 181}
182 182
183void PwMDocUi::rootAlertMsgBox() 183void PwMDocUi::rootAlertMsgBox()
184{ 184{
185 KMessageBox::error(currentView, 185 KMessageBox::error(currentView,
186 i18n("This feature is not available,n" 186 i18n("This feature is not available,n"
187 "if you execute PwM with \"root\" \n" 187 "if you execute PwM with \"root\" \n"
188 "UID 0 privileges, for security reasons!"), 188 "UID 0 privileges, for security reasons!"),
189 i18n("not allowed as root!")); 189 i18n("not allowed as root!"));
190} 190}
191 191
192void PwMDocUi::cantDeeplock_notSavedMsgBox() 192void PwMDocUi::cantDeeplock_notSavedMsgBox()
193{ 193{
194 KMessageBox::error(currentView, 194 KMessageBox::error(currentView,
195 i18n("Can't deep-lock, because the document\n" 195 i18n("Can't deep-lock, because the document\n"
196 "hasn't been saved, yet. Please save\n" 196 "hasn't been saved, yet. Please save\n"
197 "to a file and try again."), 197 "to a file and try again."),
198 i18n("not saved, yet")); 198 i18n("not saved, yet"));
199} 199}
200 200
201void PwMDocUi::gpmPwLenErrMsgBox() 201void PwMDocUi::gpmPwLenErrMsgBox()
202{ 202{
203 KMessageBox::error(currentView, 203 KMessageBox::error(currentView,
204 i18n("GPasman does not support passwords\n" 204 i18n("GPasman does not support passwords\n"
205 "shorter than 4 characters! Please try\n" 205 "shorter than 4 characters! Please try\n"
206 "again with a longer password."), 206 "again with a longer password."),
207 i18n("password too short")); 207 i18n("Password too short"));
208} 208}
209 209
210int PwMDocUi::dirtyAskSave(const QString &docTitle) 210int PwMDocUi::dirtyAskSave(const QString &docTitle)
211{ 211{
212 int ret; 212 int ret;
213#ifndef PWM_EMBEDDED 213#ifndef PWM_EMBEDDED
214 ret = KMessageBox::questionYesNoCancel(currentView, 214 ret = KMessageBox::questionYesNoCancel(currentView,
215 i18n("The list \"") + 215 i18n("The list\n\"") +
216 docTitle + 216 docTitle +
217 i18n 217 i18n
218 ("\" has been modified.\n" 218 ("\" has been modified.\n"
219 "Do you want to save it?"), 219 "Do you want to save it?"),
220 i18n("save?")); 220 i18n("Save?"));
221 if (ret == KMessageBox::Yes) { 221 if (ret == KMessageBox::Yes) {
222 return 0; 222 return 0;
223 } else if (ret == KMessageBox::No) { 223 } else if (ret == KMessageBox::No) {
224 return 1; 224 return 1;
225 } 225 }
226#else 226#else
227 QString doc = docTitle;
228 if ( doc.length() > 33 )
229 doc = "..." + doc.right(30);
227 ret = KMessageBox::warningYesNoCancel(currentView, 230 ret = KMessageBox::warningYesNoCancel(currentView,
228 i18n("The list \"") + 231 i18n("The list\n \"") +
229 docTitle + 232 doc +
230 i18n 233 i18n
231 ("\"\nhas been modified.\n" 234 ("\"\nhas been modified.\n"
232 "Do you want to save it?"), 235 "Do you want to save it?"),
233 i18n("save?")); 236 i18n("Save?"));
234 if (ret == KMessageBox::Yes) { 237 if (ret == KMessageBox::Yes) {
235 return 0; 238 return 0;
236 } else if (ret == KMessageBox::No) { 239 } else if (ret == KMessageBox::No) {
237 return 1; 240 return 1;
238 } 241 }
239 242
240#endif 243#endif
241 244
242 // cancel 245 // cancel
243 return -1; 246 return -1;
244} 247}
245 248
246bool PwMDocUi::saveDocUi(PwMDoc *doc) 249bool PwMDocUi::saveDocUi(PwMDoc *doc)
247{ 250{
248 PWM_ASSERT(doc); 251 PWM_ASSERT(doc);
249 doc->timer()->getLock(DocTimer::id_autoLockTimer); 252 doc->timer()->getLock(DocTimer::id_autoLockTimer);
250 if (doc->isDocEmpty()) { 253 if (doc->isDocEmpty()) {
251 KMessageBox::information(currentView, 254 KMessageBox::information(currentView,
252 i18n 255 i18n
253 ("Sorry, there's nothing to save.\n" 256 ("Sorry, there's nothing to save.\n"
254 "Please first add some passwords."), 257 "Please first add some passwords."),
255 i18n("nothing to do")); 258 i18n("nothing to do"));
256 doc->timer()->putLock(DocTimer::id_autoLockTimer); 259 doc->timer()->putLock(DocTimer::id_autoLockTimer);
257 return true; 260 return true;
258 } 261 }
259 PwMerror ret = doc->saveDoc(conf()->confGlobCompression()); 262 PwMerror ret = doc->saveDoc(conf()->confGlobCompression());
260 if (ret == e_filename) { 263 if (ret == e_filename) {
261 doc->timer()->putLock(DocTimer::id_autoLockTimer); 264 doc->timer()->putLock(DocTimer::id_autoLockTimer);
262 return saveAsDocUi(doc); 265 return saveAsDocUi(doc);
263 } else if (ret == e_weakPw) { 266 } else if (ret == e_weakPw) {
264 KMessageBox::error(currentView, 267 KMessageBox::error(currentView,
265 i18n("Error: This is a weak password.\n" 268 i18n("Error: This is a weak password.\n"
266 "Please select another password."), 269 "Please select another password."),
267 i18n("weak password")); 270 i18n("weak password"));
268 doc->timer()->putLock(DocTimer::id_autoLockTimer); 271 doc->timer()->putLock(DocTimer::id_autoLockTimer);
269 return false; 272 return false;
270 } else if (ret == e_fileBackup) { 273 } else if (ret == e_fileBackup) {
271 KMessageBox::error(currentView, 274 KMessageBox::error(currentView,
272 i18n("Error: Couldn't make backup-file!"), 275 i18n("Error: Couldn't make backup-file!"),
273 i18n("backup failed")); 276 i18n("backup failed"));
274 doc->timer()->putLock(DocTimer::id_autoLockTimer); 277 doc->timer()->putLock(DocTimer::id_autoLockTimer);
275 return false; 278 return false;
276 } else if (ret == e_noPw || 279 } else if (ret == e_noPw ||
277 ret == e_wrongPw || 280 ret == e_wrongPw ||
278 ret == e_openFile) { 281 ret == e_openFile) {
279 doc->timer()->putLock(DocTimer::id_autoLockTimer); 282 doc->timer()->putLock(DocTimer::id_autoLockTimer);
280 return false; 283 return false;
281 } else if (ret != e_success) { 284 } else if (ret != e_success) {
282 KMessageBox::error(currentView, 285 KMessageBox::error(currentView,
283 i18n("Error: Couldn't write to file.\n" 286 i18n("Error: Couldn't write to file.\n"
284 "Please check if you have permission to\n" 287 "Please check if you have permission to\n"
285 "write to the file in that directory."), 288 "write to the file in that directory."),
286 i18n("error while writing")); 289 i18n("error while writing"));
287 doc->timer()->putLock(DocTimer::id_autoLockTimer); 290 doc->timer()->putLock(DocTimer::id_autoLockTimer);
288 return false; 291 return false;
289 } 292 }
290 doc->timer()->putLock(DocTimer::id_autoLockTimer); 293 doc->timer()->putLock(DocTimer::id_autoLockTimer);
291 return true; 294 return true;
292} 295}
293 296
294bool PwMDocUi::saveAsDocUi(PwMDoc *doc) 297bool PwMDocUi::saveAsDocUi(PwMDoc *doc)
295{ 298{
296 PWM_ASSERT(doc); 299 PWM_ASSERT(doc);
297 doc->timer()->getLock(DocTimer::id_autoLockTimer); 300 doc->timer()->getLock(DocTimer::id_autoLockTimer);
298 if (doc->isDocEmpty()) { 301 if (doc->isDocEmpty()) {
299 KMessageBox::information(currentView, 302 KMessageBox::information(currentView,
300 i18n 303 i18n
301 ("Sorry, there's nothing to save.\n" 304 ("Sorry, there's nothing to save.\n"
302 "Please first add some passwords."), 305 "Please first add some passwords."),
303 i18n("nothing to do")); 306 i18n("nothing to do"));
304 doc->timer()->putLock(DocTimer::id_autoLockTimer); 307 doc->timer()->putLock(DocTimer::id_autoLockTimer);
305 return true; 308 return true;
306 } 309 }
307#ifndef PWM_EMBEDDED 310#ifndef PWM_EMBEDDED
308 QString fn(KFileDialog::getSaveFileName(QString::null, 311 QString fn(KFileDialog::getSaveFileName(QString::null,
309 i18n("*.pwm|PwManager Password file"), 312 i18n("*.pwm|PwManager Password file"),
310 currentView)); 313 currentView));
311#else 314#else
312 QString fn = locateLocal( "data", KGlobal::getAppName() + "/*.pwm" ); 315 QString fn = locateLocal( "data", KGlobal::getAppName() + "/*.pwm" );
313 fn = KFileDialog::getSaveFileName(fn, 316 fn = KFileDialog::getSaveFileName(fn,
314 i18n("password filename(*.pwm)"), 317 i18n("password filename(*.pwm)"),
315 currentView); 318 currentView);
316 319
317#endif 320#endif
318 if (fn == "") { 321 if (fn == "") {
319 doc->timer()->putLock(DocTimer::id_autoLockTimer); 322 doc->timer()->putLock(DocTimer::id_autoLockTimer);
320 return false; 323 return false;
321 } 324 }
322 if (fn.right(4) != ".pwm") 325 if (fn.right(4) != ".pwm")
323 fn += ".pwm"; 326 fn += ".pwm";
324 327
325 PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn); 328 PwMerror ret = doc->saveDoc(conf()->confGlobCompression(), &fn);
326 if (ret == e_noPw || 329 if (ret == e_noPw ||
327 ret == e_wrongPw || 330 ret == e_wrongPw ||
328 ret == e_openFile) { 331 ret == e_openFile) {
329 doc->timer()->putLock(DocTimer::id_autoLockTimer); 332 doc->timer()->putLock(DocTimer::id_autoLockTimer);
330 return false; 333 return false;
331 } else if (ret != e_success) { 334 } else if (ret != e_success) {
332 KMessageBox::error(currentView, 335 KMessageBox::error(currentView,
333 i18n("Error: Couldn't write to file.\n" 336 i18n("Error: Couldn't write to file.\n"
334 "Please check if you have permission to\n" 337 "Please check if you have permission to\n"
335 "write to the file in that directory."), 338 "write to the file in that directory."),
336 i18n("error while writing")); 339 i18n("error while writing"));
337 doc->timer()->putLock(DocTimer::id_autoLockTimer); 340 doc->timer()->putLock(DocTimer::id_autoLockTimer);
338 return false; 341 return false;
339 } 342 }
340 doc->timer()->putLock(DocTimer::id_autoLockTimer); 343 doc->timer()->putLock(DocTimer::id_autoLockTimer);
341 return true; 344 return true;
342} 345}
343 346
344bool PwMDocUi::openDocUi(PwMDoc *doc, 347bool PwMDocUi::openDocUi(PwMDoc *doc,
345 QString filename, 348 QString filename,
346 bool openDeepLocked) 349 bool openDeepLocked)
347{ 350{
348 if (filename.isEmpty()) 351 if (filename.isEmpty())
349 { 352 {
350#ifndef PWM_EMBEDDED 353#ifndef PWM_EMBEDDED
351 filename = KFileDialog::getOpenFileName(QString::null, 354 filename = KFileDialog::getOpenFileName(QString::null,
352 i18n("*.pwm|PwManager Password file\n" 355 i18n("*.pwm|PwManager Password file\n"
353 "*|All files"), getCurrentView()); 356 "*|All files"), getCurrentView());
354#else 357#else
355 filename = locateLocal( "data", KGlobal::getAppName() + "/*.pwm"); 358 filename = locateLocal( "data", KGlobal::getAppName() + "/*.pwm");
356 filename = KFileDialog::getOpenFileName(filename, 359 filename = KFileDialog::getOpenFileName(filename,
357 i18n("password filename(*.pwm)"), getCurrentView()); 360 i18n("password filename(*.pwm)"), getCurrentView());
358#endif 361#endif
359 } 362 }
360 if (filename.isEmpty()) 363 if (filename.isEmpty())
361 goto cancelOpen; 364 goto cancelOpen;
362 PwMerror ret; 365 PwMerror ret;
363 while (true) { 366 while (true) {
364 int lockStat = -1; 367 int lockStat = -1;
365 if (openDeepLocked) { 368 if (openDeepLocked) {
366 lockStat = 2; 369 lockStat = 2;
367 } else { 370 } else {
368 if (conf()->confGlobUnlockOnOpen()) { 371 if (conf()->confGlobUnlockOnOpen()) {
369 lockStat = 0; 372 lockStat = 0;
370 } else { 373 } else {
371 lockStat = 1; 374 lockStat = 1;
372 } 375 }
373 } 376 }
374 ret = doc->openDoc(&filename, lockStat); 377 ret = doc->openDoc(&filename, lockStat);
375 //qDebug("pwmdocui::OpenDocui %i", ret); 378 //qDebug("pwmdocui::OpenDocui %i", ret);
376 if (ret != e_success) { 379 if (ret != e_success) {
377 if (ret == e_readFile || ret == e_openFile) { 380 if (ret == e_readFile || ret == e_openFile) {
378 KMessageBox::error(getCurrentView(), 381 KMessageBox::error(getCurrentView(),
379 i18n("Could not read file!") 382 i18n("Could not read file!")
380 + "\n" 383 + "\n"
381 + filename, 384 + filename,
382 i18n("File error")); 385 i18n("File error"));
383 goto cancelOpen; 386 goto cancelOpen;
384 } 387 }
385 if (ret == e_alreadyOpen) { 388 if (ret == e_alreadyOpen) {
386 KMessageBox::error(getCurrentView(), 389 KMessageBox::error(getCurrentView(),
387 i18n("This file is already open."), 390 i18n("This file is already open."),
388 i18n("Already open")); 391 i18n("Already open"));
389 goto cancelOpen; 392 goto cancelOpen;
390 } 393 }
391 if (ret == e_fileVer) { 394 if (ret == e_fileVer) {
392 KMessageBox::error(getCurrentView(), 395 KMessageBox::error(getCurrentView(),
393 i18n 396 i18n
394 ("File-version is not supported!\n" 397 ("File-version is not supported!\n"
395 "Did you create this file with an\nolder or newer version of PwM?"), 398 "Did you create this file with an\nolder or newer version of PwM?"),
396 i18n 399 i18n
397 ("Incompatible version")); 400 ("Incompatible version"));
398 goto cancelOpen; 401 goto cancelOpen;
399 } 402 }
400 if (ret == e_wrongPw) { 403 if (ret == e_wrongPw) {
401 continue; 404 continue;
402 } 405 }
403 if (ret == e_noPw) { 406 if (ret == e_noPw) {
404 goto cancelOpen; 407 goto cancelOpen;
405 } 408 }
406 if (ret == e_fileFormat) { 409 if (ret == e_fileFormat) {
407 KMessageBox::error(getCurrentView(), 410 KMessageBox::error(getCurrentView(),
408 i18n 411 i18n
409 ("Sorry, this file has not been recognized\n" 412 ("Sorry, this file has not been recognized\n"
410 "as a PwM Password file.\n" 413 "as a PwM Password file.\n"
411 "Probably you have selected the wrong file."), 414 "Probably you have selected the wrong file."),
412 i18n 415 i18n
413 ("No PwM password-file")); 416 ("No PwM password-file"));
414 goto cancelOpen; 417 goto cancelOpen;
415 } 418 }
416 if (ret == e_fileCorrupt) { 419 if (ret == e_fileCorrupt) {
417 KMessageBox::error(getCurrentView(), 420 KMessageBox::error(getCurrentView(),
418 i18n 421 i18n
419 ("File corrupt!\n" 422 ("File corrupt!\n"
420 "Maybe the media, you stored this file on,\n" 423 "Maybe the media, you stored this file on,\n"
421 "had bad sectors?"), 424 "had bad sectors?"),
422 i18n 425 i18n
423 ("Checksum error")); 426 ("Checksum error"));
424 goto cancelOpen; 427 goto cancelOpen;
425 } 428 }
426 } 429 }
427 break; 430 break;
428 } 431 }
429 return true; 432 return true;
430 433
431 cancelOpen: 434 cancelOpen:
432 return false; 435 return false;
433} 436}
434 437
435QString PwMDocUi::string_defaultCategory() 438QString PwMDocUi::string_defaultCategory()
436{ 439{
437 return i18n("Default"); 440 return i18n("Default");
438} 441}
439 442
440QString PwMDocUi::string_locked() 443QString PwMDocUi::string_locked()
441{ 444{
442 return i18n("<LOCKED>"); 445 return i18n("<LOCKED>");
443} 446}
444 447
445QString PwMDocUi::string_deepLockedShort() 448QString PwMDocUi::string_deepLockedShort()
446{ 449{
447 return i18n("DEEP-LOCKED"); 450 return i18n("DEEP-LOCKED");
448} 451}
449 452
450QString PwMDocUi::string_deepLockedLong() 453QString PwMDocUi::string_deepLockedLong()
451{ 454{
452 return i18n("This file is DEEP-LOCKED!\n" 455 return i18n("This file is DEEP-LOCKED!\n"
453 "That means all data has been encrypted\n" 456 "That means all data has been encrypted\n"
454 "and written out to the file. If you want\n" 457 "and written out to the file. If you want\n"
455 "to see the entries, please UNLOCK the file.\n" 458 "to see the entries, please UNLOCK the file.\n"
456 "While unlocking, you will be prompted for the\n" 459 "While unlocking, you will be prompted for the\n"
457 "master-password or the key-card."); 460 "master-password or the key-card.");
458} 461}
459 462
460QString PwMDocUi::string_defaultTitle() 463QString PwMDocUi::string_defaultTitle()
461{ 464{
462 return i18n("Untitled"); 465 return i18n("Untitled");
463} 466}
464 467
465#ifndef PWM_EMBEDDED 468#ifndef PWM_EMBEDDED
466#include "pwmdocui.moc" 469#include "pwmdocui.moc"
467#endif 470#endif
diff --git a/pwmanager/pwmanager/pwminit.cpp b/pwmanager/pwmanager/pwminit.cpp
index d775aa9..fbd17a7 100644
--- a/pwmanager/pwmanager/pwminit.cpp
+++ b/pwmanager/pwmanager/pwminit.cpp
@@ -1,641 +1,650 @@
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#include <qdir.h>
23 23
24#ifndef PWM_EMBEDDED 24#ifndef PWM_EMBEDDED
25#include "selftest.h" 25#include "selftest.h"
26#include "configuration.h" 26#include "configuration.h"
27#else 27#else
28#include "pwmprefs.h" 28#include "pwmprefs.h"
29#endif 29#endif
30 30
31#include "pwm.h" 31#include "pwm.h"
32#include "pwmexception.h" 32#include "pwmexception.h"
33#include "pwmtray.h" 33#include "pwmtray.h"
34#include "pwmdoc.h" 34#include "pwmdoc.h"
35 35
36#ifdef CONFIG_KWALLETIF 36#ifdef CONFIG_KWALLETIF
37# include "kwalletemu.h" 37# include "kwalletemu.h"
38#endif // CONFIG_KWALLETIF 38#endif // CONFIG_KWALLETIF
39#ifdef CONFIG_KEYCARD 39#ifdef CONFIG_KEYCARD
40# include "pwmkeycard.h" 40# include "pwmkeycard.h"
41#endif // CONFIG_KEYCARD 41#endif // CONFIG_KEYCARD
42 42
43#include <qmessagebox.h> 43#include <qmessagebox.h>
44 44
45#include <kmessagebox.h> 45#include <kmessagebox.h>
46#ifndef PWM_EMBEDDED 46#ifndef PWM_EMBEDDED
47#include <kcmdlineargs.h> 47#include <kcmdlineargs.h>
48#include <kwin.h> 48#include <kwin.h>
49#include <dcopclient.h> 49#include <dcopclient.h>
50#endif 50#endif
51 51
52#include <kapplication.h> 52#include <kapplication.h>
53#include <kiconloader.h> 53#include <kiconloader.h>
54 54
55#include <signal.h> 55#include <signal.h>
56 56
57static PwMInit *sig_init_pointer; 57static PwMInit *sig_init_pointer;
58#ifdef _WIN32_ 58#ifdef _WIN32_
59static void sig_handler(int signum) 59static void sig_handler(int signum)
60#else 60#else
61static NOREGPARM void sig_handler(int signum) 61static NOREGPARM void sig_handler(int signum)
62#endif 62#endif
63{ 63{
64 switch (signum) { 64 switch (signum) {
65 case SIGINT: 65 case SIGINT:
66 case SIGTERM: 66 case SIGTERM:
67 sig_init_pointer->shutdownApp(20 + signum); 67 sig_init_pointer->shutdownApp(20 + signum);
68 break; 68 break;
69 default: 69 default:
70 printDebug(string("unhandled signal ") 70 printDebug(string("unhandled signal ")
71 + tostr(signum)); 71 + tostr(signum));
72 } 72 }
73} 73}
74 74
75 75
76 76
77PwMInit::PwMInit(PwMApplication *_app) 77PwMInit::PwMInit(PwMApplication *_app)
78 : runStatus (unknown) 78 : runStatus (unknown)
79 , _curWidget (0) 79 , _curWidget (0)
80 , _dcopClient (0) 80 , _dcopClient (0)
81 , _kwalletEmu (0) 81 , _kwalletEmu (0)
82 , _keycard (0) 82 , _keycard (0)
83 , _tray (0) 83 , _tray (0)
84{ 84{
85 sig_init_pointer = this; 85 sig_init_pointer = this;
86 app = _app; 86 app = _app;
87} 87}
88 88
89PwMInit::~PwMInit() 89PwMInit::~PwMInit()
90{ 90{
91 qDebug("PwMInit::~PwMInit() ");
91#ifndef PWM_EMBEDDED 92#ifndef PWM_EMBEDDED
92 SelfTest::cancel(); 93 SelfTest::cancel();
93 // close all open mainwnds 94 // close all open mainwnds
94 QValueList<PwM *>::iterator i = _mainWndList.begin(), 95 QValueList<PwM *>::iterator i = _mainWndList.begin(),
95 end = _mainWndList.end(); 96 end = _mainWndList.end();
96 97
97#else 98#else
98 // close all open mainwnds 99 // close all open mainwnds
99 QValueList<PwM *>::Iterator i = _mainWndList.begin(), 100 QValueList<PwM *>::Iterator i = _mainWndList.begin(),
100 end = _mainWndList.end(); 101 end = _mainWndList.end();
101#endif 102#endif
102 while (i != end) { 103 while (i != end) {
103 disconnect(*i, SIGNAL(closed(PwM *)), 104 disconnect(*i, SIGNAL(closed(PwM *)),
104 this, SLOT(mainWndClosed(PwM *))); 105 this, SLOT(mainWndClosed(PwM *)));
105 delete *i; 106 delete *i;
106 ++i; 107 ++i;
107 } 108 }
108 _mainWndList.clear(); 109 _mainWndList.clear();
109 // close all remaining open documents 110 // close all remaining open documents
110 PwMDocList *_dl = PwMDoc::getOpenDocList(); 111 PwMDocList *_dl = PwMDoc::getOpenDocList();
111 vector<PwMDocList::listItem> dl = *(_dl->getList()); 112 vector<PwMDocList::listItem> dl = *(_dl->getList());
112 vector<PwMDocList::listItem>::iterator i2 = dl.begin(), 113 vector<PwMDocList::listItem>::iterator i2 = dl.begin(),
113 end2 = dl.end(); 114 end2 = dl.end();
114 while (i2 != end2) { 115 while (i2 != end2) {
115 delete (*i2).doc; 116 delete (*i2).doc;
116 ++i2; 117 ++i2;
117 } 118 }
118 119
119#ifdef CONFIG_KWALLETIF 120#ifdef CONFIG_KWALLETIF
120 delete_ifnot_null(_kwalletEmu); 121 delete_ifnot_null(_kwalletEmu);
121#endif // CONFIG_KWALLETIF 122#endif // CONFIG_KWALLETIF
122#ifdef CONFIG_KEYCARD 123#ifdef CONFIG_KEYCARD
123 delete_ifnot_null(_keycard); 124 delete_ifnot_null(_keycard);
124#endif // CONFIG_KEYCARD 125#endif // CONFIG_KEYCARD
125 delete_ifnot_null(_tray); 126 delete_ifnot_null(_tray);
126 127
127 Randomizer::cleanup(); 128 Randomizer::cleanup();
128#ifndef PWM_EMBEDDED 129#ifndef PWM_EMBEDDED
129 Configuration::cleanup(); 130 Configuration::cleanup();
130#endif 131#endif
131} 132}
132 133
133void PwMInit::initializeApp() 134void PwMInit::initializeApp()
134{ 135{
135 //qDebug("PwMInit::initializeApp() "); 136 //qDebug("PwMInit::initializeApp() ");
136 PWM_ASSERT(runStatus == unknown); 137 PWM_ASSERT(runStatus == unknown);
137 runStatus = init; 138 runStatus = init;
138 initPosixSignalHandler(); 139 initPosixSignalHandler();
139 Randomizer::init(); 140 Randomizer::init();
140#ifndef PWM_EMBEDDED 141#ifndef PWM_EMBEDDED
141 Configuration::init(); 142 Configuration::init();
142#endif 143#endif
143 initDCOP(); 144 initDCOP();
144 initKWalletEmu(); 145 initKWalletEmu();
145 initKeycard(); 146 initKeycard();
146 initTray(); 147 initTray();
147 handleCmdLineArgs(); 148 handleCmdLineArgs();
148 bool openDeeplocked = false; 149 bool openDeeplocked = false;
149 if (conf()->confGlobAutostartDeepLocked() || 150 if (conf()->confGlobAutostartDeepLocked() ||
150 savedCmd.open_deeplocked) 151 savedCmd.open_deeplocked)
151 openDeeplocked = true; 152 openDeeplocked = true;
152 if ( false ){ 153 if ( false ){
153 // LR is not working 154 // LR is not working
154 //if (conf()->confWndAutoMinimizeOnStart() || 155 //if (conf()->confWndAutoMinimizeOnStart() ||
155 // savedCmd.minToTray) { 156 // savedCmd.minToTray) {
156 PwMDoc *newDoc = createDoc(); 157 PwMDoc *newDoc = createDoc();
157 qDebug(" createDoc()"); 158 qDebug(" createDoc()");
158 if (!newDoc->openDocUi(newDoc, 159 if (!newDoc->openDocUi(newDoc,
159 conf()->confGlobAutoStart(), 160 conf()->confGlobAutoStart(),
160 openDeeplocked)) { 161 openDeeplocked)) {
161 delete newDoc; 162 delete newDoc;
162 } 163 }
163 164
164 //US ENH for embedded devices: in the case of failure, open a document the default way 165 //US ENH for embedded devices: in the case of failure, open a document the default way
165 createMainWnd(conf()->confGlobAutoStart(), 166 createMainWnd(conf()->confGlobAutoStart(),
166 openDeeplocked, 167 openDeeplocked,
167 true, 168 true,
168 0, 169 0,
169 savedCmd.minimized); 170 savedCmd.minimized);
170 171
171 172
172 173
173 174
174 //} 175 //}
175 } else { 176 } else {
176 createMainWnd(conf()->confGlobAutoStart(), 177 createMainWnd(conf()->confGlobAutoStart(),
177 openDeeplocked, 178 openDeeplocked,
178 true, 179 true,
179 0, 180 0,
180 savedCmd.minimized); 181 savedCmd.minimized);
181 } 182 }
182
183 runStatus = running; 183 runStatus = running;
184} 184}
185 185
186void PwMInit::shutdownApp(int exitStatus) 186void PwMInit::shutdownApp(int exitStatus)
187{ 187{
188 printDebug(string("PwMInit::shutdownApp(") 188 printDebug(string("PwMInit::shutdownApp(")
189 + tostr(exitStatus) + ") called."); 189 + tostr(exitStatus) + ") called.");
190 PWM_ASSERT((runStatus == running) || (runStatus == init)); 190 PWM_ASSERT((runStatus == running) || (runStatus == init));
191 runStatus = shutdown; 191 runStatus = shutdown;
192 QApplication::exit(exitStatus); 192 QApplication::exit(exitStatus);
193 /* The destructor of PwMInit is called when control 193 /* The destructor of PwMInit is called when control
194 * leaves main() 194 * leaves main()
195 */ 195 */
196} 196}
197 197
198void PwMInit::initPosixSignalHandler() 198void PwMInit::initPosixSignalHandler()
199{ 199{
200 signal(SIGINT, sig_handler); 200 signal(SIGINT, sig_handler);
201 signal(SIGTERM, sig_handler); 201 signal(SIGTERM, sig_handler);
202} 202}
203 203
204void PwMInit::initDCOP() 204void PwMInit::initDCOP()
205{ 205{
206#ifndef PWM_EMBEDDED 206#ifndef PWM_EMBEDDED
207 _dcopClient = app->dcopClient(); 207 _dcopClient = app->dcopClient();
208 _dcopClient->setNotifications(true); 208 _dcopClient->setNotifications(true);
209#endif 209#endif
210 210
211} 211}
212 212
213void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload) 213void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload)
214{ 214{
215#ifdef CONFIG_KWALLETIF 215#ifdef CONFIG_KWALLETIF
216 if (!conf()->confGlobKwalletEmu() || 216 if (!conf()->confGlobKwalletEmu() ||
217 forceDisable) { 217 forceDisable) {
218 delete_ifnot_null(_kwalletEmu); 218 delete_ifnot_null(_kwalletEmu);
219 return; 219 return;
220 } 220 }
221 try { 221 try {
222 if (_kwalletEmu && forceReload) 222 if (_kwalletEmu && forceReload)
223 delete_and_null(_kwalletEmu); 223 delete_and_null(_kwalletEmu);
224 if (!_kwalletEmu) 224 if (!_kwalletEmu)
225 _kwalletEmu = new KWalletEmu(this); 225 _kwalletEmu = new KWalletEmu(this);
226 } catch (PwMException e) { 226 } catch (PwMException e) {
227 string errMsg("initializing KWallet emulation failed. ID: "); 227 string errMsg("initializing KWallet emulation failed. ID: ");
228 errMsg += tostr(static_cast<int>(e.getId())); 228 errMsg += tostr(static_cast<int>(e.getId()));
229 errMsg += " err-message: "; 229 errMsg += " err-message: ";
230 errMsg += e.getMessage(); 230 errMsg += e.getMessage();
231 printWarn(errMsg); 231 printWarn(errMsg);
232 return; 232 return;
233 } 233 }
234#else // CONFIG_KWALLETIF 234#else // CONFIG_KWALLETIF
235 PARAM_UNUSED(forceDisable); 235 PARAM_UNUSED(forceDisable);
236 PARAM_UNUSED(forceReload); 236 PARAM_UNUSED(forceReload);
237#endif // CONFIG_KWALLETIF 237#endif // CONFIG_KWALLETIF
238} 238}
239 239
240void PwMInit::initKeycard() 240void PwMInit::initKeycard()
241{ 241{
242#ifdef CONFIG_KEYCARD 242#ifdef CONFIG_KEYCARD
243 PWM_ASSERT(!_keycard); 243 PWM_ASSERT(!_keycard);
244 _keycard = new PwMKeyCard(this); 244 _keycard = new PwMKeyCard(this);
245#endif // CONFIG_KEYCARD 245#endif // CONFIG_KEYCARD
246} 246}
247 247
248void PwMInit::initTray() 248void PwMInit::initTray()
249{ 249{
250#ifdef PWM_EMBEDDED 250#ifdef PWM_EMBEDDED
251 //US ENH : embedded version does not support a tray 251 //US ENH : embedded version does not support a tray
252 return; 252 return;
253#endif 253#endif
254 254
255 if (!conf()->confGlobTray()) { 255 if (!conf()->confGlobTray()) {
256 if (!_tray) 256 if (!_tray)
257 return; 257 return;
258 _tray->hide(); 258 _tray->hide();
259 delete_and_null(_tray); 259 delete_and_null(_tray);
260 return; 260 return;
261 } 261 }
262 if (_tray) 262 if (_tray)
263 return; 263 return;
264 _tray = new PwMTray(this); 264 _tray = new PwMTray(this);
265 connect(_tray, SIGNAL(quitSelected()), 265 connect(_tray, SIGNAL(quitSelected()),
266 this, SLOT(removeTrayAndQuit())); 266 this, SLOT(removeTrayAndQuit()));
267 connect(_tray, SIGNAL(closed(PwMTray *)), 267 connect(_tray, SIGNAL(closed(PwMTray *)),
268 this, SLOT(trayIconClosed(PwMTray *))); 268 this, SLOT(trayIconClosed(PwMTray *)));
269 KIconLoader icons; 269 KIconLoader icons;
270#ifndef PWM_EMBEDDED 270#ifndef PWM_EMBEDDED
271 _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small)); 271 _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small));
272#endif 272#endif
273 _tray->show(); 273 _tray->show();
274 // connect the signals of all open documents. 274 // connect the signals of all open documents.
275 const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList(); 275 const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList();
276 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 276 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
277 end = dl->end(); 277 end = dl->end();
278 while (i != end) { 278 while (i != end) {
279 _tray->connectDocToTray((*i).doc); 279 _tray->connectDocToTray((*i).doc);
280 ++i; 280 ++i;
281 } 281 }
282} 282}
283 283
284void PwMInit::removeTrayAndQuit() 284void PwMInit::removeTrayAndQuit()
285{ 285{
286 PWM_ASSERT(_tray); 286 PWM_ASSERT(_tray);
287 // _tray is deleted in ~PwMInit 287 // _tray is deleted in ~PwMInit
288 shutdownApp(0); 288 shutdownApp(0);
289} 289}
290 290
291PwM * PwMInit::createMainWnd(const QString &loadFile, 291PwM * PwMInit::createMainWnd(const QString &loadFile,
292 bool loadFileDeepLocked, 292 bool loadFileDeepLocked,
293 bool virginity, 293 bool virginity,
294 PwMDoc *doc, 294 PwMDoc *doc,
295 bool minimized) 295 bool minimized)
296{ 296{
297 PwM *newWnd; 297 PwM *newWnd;
298 if (!doc) 298 if (!doc)
299 doc = createDoc(); 299 doc = createDoc();
300 newWnd = new PwM(this, doc, virginity); 300 newWnd = new PwM(this, doc, virginity);
301#ifndef PWM_EMBEDDED 301#ifndef PWM_EMBEDDED
302 _mainWndList.push_back(newWnd); 302 _mainWndList.push_back(newWnd);
303#else 303#else
304 _mainWndList.append(newWnd); 304 _mainWndList.append(newWnd);
305#endif 305#endif
306 connect(newWnd, SIGNAL(closed(PwM *)), 306 connect(newWnd, SIGNAL(closed(PwM *)),
307 this, SLOT(mainWndClosed(PwM *))); 307 this, SLOT(mainWndClosed(PwM *)));
308 connect(newWnd, SIGNAL(gotFocus(PwM *)), 308 connect(newWnd, SIGNAL(gotFocus(PwM *)),
309 this, SLOT(setCurWidget(PwM *))); 309 this, SLOT(setCurWidget(PwM *)));
310 connect(newWnd, SIGNAL(lostFocus(PwM *)), 310 connect(newWnd, SIGNAL(lostFocus(PwM *)),
311 this, SLOT(resetCurWidget())); 311 this, SLOT(resetCurWidget()));
312 312
313 //US ENH 313 //US ENH
314#ifndef PWM_EMBEDDED 314#ifndef PWM_EMBEDDED
315 if (minimized) 315 if (minimized)
316 newWnd->showMinimized(); 316 newWnd->showMinimized();
317 else 317 else
318 newWnd->show(); 318 newWnd->show();
319 319
320#else //PWM_EMBEDDED 320#else //PWM_EMBEDDED
321 321
322#ifndef DESKTOP_VERSION 322#ifndef DESKTOP_VERSION
323 app->showMainWidget( newWnd ); 323 app->showMainWidget( newWnd );
324#else //DESKTOP_VERSION 324#else //DESKTOP_VERSION
325 app->setMainWidget( newWnd );
326 newWnd->resize (640, 480 ); 325 newWnd->resize (640, 480 );
327 newWnd->show(); 326 newWnd->show();
328 qDebug("show ");
329#endif //DESKTOP_VERSION 327#endif //DESKTOP_VERSION
330 328
331#endif //PWM_EMBEDDED 329#endif //PWM_EMBEDDED
332 330
333 if (loadFile != QString::null && 331 if (loadFile != QString::null &&
334 loadFile != "") { 332 loadFile != "") {
335 newWnd->openDoc(loadFile, loadFileDeepLocked); 333 newWnd->openDoc(loadFile, loadFileDeepLocked);
336 } 334 }
337 return newWnd; 335 return newWnd;
338} 336}
339 337
340PwMDoc * PwMInit::createDoc() 338PwMDoc * PwMInit::createDoc()
341{ 339{
342 PwMDoc *doc = new PwMDoc(this); 340 PwMDoc *doc = new PwMDoc(this);
343#ifdef CONFIG_KEYCARD 341#ifdef CONFIG_KEYCARD
344 doc->setPwMKeyCard(keycard()); 342 doc->setPwMKeyCard(keycard());
345#endif 343#endif
346#ifdef CONFIG_KWALLETIF 344#ifdef CONFIG_KWALLETIF
347 if (kwalletEmu()) 345 if (kwalletEmu())
348 kwalletEmu()->connectDocSignals(doc); 346 kwalletEmu()->connectDocSignals(doc);
349#endif 347#endif
350 348
351 if (_tray) 349 if (_tray)
352 _tray->connectDocToTray(doc); 350 _tray->connectDocToTray(doc);
353 351
354 return doc; 352 return doc;
355 353
356} 354}
357 355
358void PwMInit::mainWndClosed(PwM *wnd) 356void PwMInit::mainWndClosed(PwM *wnd)
359{ 357{
360 bool doMinimizeToTray = false; 358 bool doMinimizeToTray = false;
361 bool doDeleteDoc = false; 359 bool doDeleteDoc = false;
362#ifndef PWM_EMBEDDED 360#ifndef PWM_EMBEDDED
363 dcopClient()->suspend(); 361 dcopClient()->suspend();
364 dcopClient()->setAcceptCalls(false); 362 dcopClient()->setAcceptCalls(false);
365#endif 363#endif
366again: 364again:
367 365
368 if (wnd->isForceMinimizeToTray()) { 366 if (wnd->isForceMinimizeToTray()) {
369 if (unlikely(!_tray)) { 367 if (unlikely(!_tray)) {
370 /* This should not happen! If we set forceMinimizeToTray , 368 /* This should not happen! If we set forceMinimizeToTray ,
371 * we must be sure that _tray exists. 369 * we must be sure that _tray exists.
372 */ 370 */
373 BUG(); 371 BUG();
374 wnd->setForceMinimizeToTray(false); 372 wnd->setForceMinimizeToTray(false);
375 goto again; 373 goto again;
376 } 374 }
377 doMinimizeToTray = true; 375 doMinimizeToTray = true;
378 } else { 376 } else {
379 // Ask to minimize to tray. If not, delete doc. 377 // Ask to minimize to tray. If not, delete doc.
380 if (_tray && 378 if (_tray &&
381 runStatus != shutdown && 379 runStatus != shutdown &&
382 !wnd->isForceQuit() && 380 !wnd->isForceQuit() &&
383 !wnd->curDoc()->isDeleted()) { 381 !wnd->curDoc()->isDeleted()) {
384 if (conf()->confWndClose()) 382 if (conf()->confWndClose())
385 doDeleteDoc = true; 383 doDeleteDoc = true;
386 else 384 else
387 doMinimizeToTray = true; 385 doMinimizeToTray = true;
388 } else { 386 } else {
389 doDeleteDoc = true; 387 doDeleteDoc = true;
390 } 388 }
391 } 389 }
392 390
393 if (doMinimizeToTray) { 391 if (doMinimizeToTray) {
394 392 qDebug("doMinimizeToTray ");
395 PWM_ASSERT(_tray); 393 PWM_ASSERT(_tray);
396 int mmlock = conf()->confGlobMinimizeLock(); 394 int mmlock = conf()->confGlobMinimizeLock();
397 switch (mmlock) { 395 switch (mmlock) {
398 case 0: // don't lock anything 396 case 0: // don't lock anything
399 break; 397 break;
400 case 1: // normal lock 398 case 1: // normal lock
401 wnd->curDoc()->lockAll(true); 399 wnd->curDoc()->lockAll(true);
402 break; 400 break;
403 case 2: // deep-lock 401 case 2: // deep-lock
404 wnd->curDoc()->deepLock(); 402 wnd->curDoc()->deepLock();
405 break; 403 break;
406 default: 404 default:
407 WARN(); 405 WARN();
408 } 406 }
409 } else if (doDeleteDoc) { 407 } else if (doDeleteDoc) {
408 qDebug("doDeleteDoc ");
410 if (!wnd->curDoc()->tryDelete()) { 409 if (!wnd->curDoc()->tryDelete()) {
411 /* We failed deleting the doc, 410 /* We failed deleting the doc,
412 * so open a new window with it, again. 411 * so open a new window with it, again.
413 */ 412 */
414 createMainWnd(QString::null, false, 413 createMainWnd(QString::null, false,
415 false, wnd->curDoc()); 414 false, wnd->curDoc());
416 } 415 }
417 } 416 }
418#ifndef PWM_EMBEDDED 417#ifndef PWM_EMBEDDED
419 // find the closed window in the "mainWndList" and delete it. 418 // find the closed window in the "mainWndList" and delete it.
420 QValueList<PwM *>::iterator i = _mainWndList.begin(), 419 QValueList<PwM *>::iterator i = _mainWndList.begin(),
421 end = _mainWndList.end(); 420 end = _mainWndList.end();
422#else 421#else
423 // find the closed window in the "mainWndList" and delete it. 422 // find the closed window in the "mainWndList" and delete it.
424 QValueList<PwM *>::Iterator i = _mainWndList.begin(), 423 QValueList<PwM *>::Iterator i = _mainWndList.begin(),
425 end = _mainWndList.end(); 424 end = _mainWndList.end();
426#endif 425#endif
427 while (i != end) { 426 while (i != end) {
428 if (*i == wnd) { 427 if (*i == wnd) {
429#ifndef PWM_EMBEDDED 428#ifndef PWM_EMBEDDED
430 _mainWndList.erase(i); 429 _mainWndList.erase(i);
431#else 430#else
432 _mainWndList.remove(i); 431 _mainWndList.remove(i);
433#endif 432#endif
433
434 if ( app->mainWidget() == wnd ) {
435 if ( _mainWndList.count() ) {
436#ifndef DESKTOP_VERSION
437 app->showMainWidget(_mainWndList.first() );
438#endif //DESKTOP_VERSION
439
440 }
441 }
442 delete wnd;
434 goto out_success; 443 goto out_success;
435 } 444 }
436 ++i; 445 ++i;
437 } 446 }
438 BUG(); 447 BUG();
439out_success: 448out_success:
440#ifndef PWM_EMBEDDED 449#ifndef PWM_EMBEDDED
441 if (!_mainWndList.size()) 450 if (!_mainWndList.size())
442#else 451#else
443 if (!_mainWndList.count()) 452 if (!_mainWndList.count())
444#endif 453#endif
445 454
446 { 455 {
447 /* If there's no main window and no tray icon 456 /* If there's no main window and no tray icon
448 * left, we have no user interface, so we can 457 * left, we have no user interface, so we can
449 * shut down the application. 458 * shut down the application.
450 */ 459 */
451 if (!_tray) { 460 if (!_tray) {
452#ifndef PWM_EMBEDDED 461#ifndef PWM_EMBEDDED
453 dcopClient()->setAcceptCalls(true); 462 dcopClient()->setAcceptCalls(true);
454 dcopClient()->resume(); 463 dcopClient()->resume();
455#endif 464#endif
456 shutdownApp(0); 465 shutdownApp(0);
457 return; 466 return;
458 } 467 }
459 /* There is no widget left, so set 468 /* There is no widget left, so set
460 * _curWidget to 0 469 * _curWidget to 0
461 */ 470 */
462 resetCurWidget(); 471 resetCurWidget();
463 } 472 }
464#ifndef PWM_EMBEDDED 473#ifndef PWM_EMBEDDED
465 dcopClient()->setAcceptCalls(true); 474 dcopClient()->setAcceptCalls(true);
466 dcopClient()->resume(); 475 dcopClient()->resume();
467#endif 476#endif
468} 477}
469 478
470void PwMInit::trayIconClosed(PwMTray *tray) 479void PwMInit::trayIconClosed(PwMTray *tray)
471{ 480{
472 if (runStatus != running) 481 if (runStatus != running)
473 return; 482 return;
474 PARAM_UNUSED(tray); 483 PARAM_UNUSED(tray);
475 PWM_ASSERT(tray == _tray); 484 PWM_ASSERT(tray == _tray);
476 /* If there's no main wnd left we have to 485 /* If there's no main wnd left we have to
477 * shutdown the app (same as in mainWndClosed()) 486 * shutdown the app (same as in mainWndClosed())
478 */ 487 */
479#ifndef PWM_EMBEDDED 488#ifndef PWM_EMBEDDED
480 if (!_mainWndList.size()) 489 if (!_mainWndList.size())
481 shutdownApp(0); 490 shutdownApp(0);
482#else 491#else
483 if (!_mainWndList.count()) 492 if (!_mainWndList.count())
484 shutdownApp(0); 493 shutdownApp(0);
485#endif 494#endif
486} 495}
487 496
488void PwMInit::handleCmdLineArgs(bool initial) 497void PwMInit::handleCmdLineArgs(bool initial)
489{ 498{
490#ifndef PWM_EMBEDDED 499#ifndef PWM_EMBEDDED
491 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 500 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
492 PWM_ASSERT(args); 501 PWM_ASSERT(args);
493 int i, numArgs = args->count(); 502 int i, numArgs = args->count();
494 const char *curArg; 503 const char *curArg;
495 504
496 // read all cmdline options 505 // read all cmdline options
497 savedCmd.open_deeplocked = args->isSet("open-deeplocked"); 506 savedCmd.open_deeplocked = args->isSet("open-deeplocked");
498 savedCmd.minimized = args->isSet("minimized"); 507 savedCmd.minimized = args->isSet("minimized");
499 savedCmd.minToTray = args->isSet("mintray"); 508 savedCmd.minToTray = args->isSet("mintray");
500 savedCmd.skipSelfTest = args->isSet("skip-self-test"); 509 savedCmd.skipSelfTest = args->isSet("skip-self-test");
501 if (savedCmd.minimized && 510 if (savedCmd.minimized &&
502 savedCmd.minToTray) { 511 savedCmd.minToTray) {
503 printInfo(i18n("Commandline option \"--minimized\" and " 512 printInfo(i18n("Commandline option \"--minimized\" and "
504 "\"--mintray\" selected. These are incompatible. " 513 "\"--mintray\" selected. These are incompatible. "
505 "\"--mintray\" will be selected.").latin1()); 514 "\"--mintray\" will be selected.").latin1());
506 } 515 }
507 /* Iterate through all non-option arguments. 516 /* Iterate through all non-option arguments.
508 * Every non-option arg is a filename to open. 517 * Every non-option arg is a filename to open.
509 */ 518 */
510 for (i = 0; i < numArgs; ++i) { 519 for (i = 0; i < numArgs; ++i) {
511 curArg = args->arg(i); 520 curArg = args->arg(i);
512 PWM_ASSERT(curArg); 521 PWM_ASSERT(curArg);
513 if (savedCmd.minToTray) { 522 if (savedCmd.minToTray) {
514 PwMDoc *newDoc = createDoc(); 523 PwMDoc *newDoc = createDoc();
515 if (!newDoc->openDocUi(newDoc, 524 if (!newDoc->openDocUi(newDoc,
516 curArg, 525 curArg,
517 savedCmd.open_deeplocked)) { 526 savedCmd.open_deeplocked)) {
518 delete newDoc; 527 delete newDoc;
519 } 528 }
520 } else { 529 } else {
521 PwM *newInstance = createMainWnd(QString::null, 530 PwM *newInstance = createMainWnd(QString::null,
522 false, 531 false,
523 true, 532 true,
524 0, 533 0,
525 savedCmd.minimized); 534 savedCmd.minimized);
526 PwMDoc *newDoc = newInstance->openDoc(curArg, 535 PwMDoc *newDoc = newInstance->openDoc(curArg,
527 savedCmd.open_deeplocked); 536 savedCmd.open_deeplocked);
528 if (!newDoc) { 537 if (!newDoc) {
529 newInstance->setForceQuit(true); 538 newInstance->setForceQuit(true);
530 delete_and_null(newInstance); 539 delete_and_null(newInstance);
531 } 540 }
532 } 541 }
533 } 542 }
534 543
535 if (savedCmd.minToTray) { 544 if (savedCmd.minToTray) {
536 minimizeAllMainWnd(true); 545 minimizeAllMainWnd(true);
537 } else if (savedCmd.minimized) { 546 } else if (savedCmd.minimized) {
538 minimizeAllMainWnd(false); 547 minimizeAllMainWnd(false);
539 } 548 }
540 if (!savedCmd.skipSelfTest && initial) { 549 if (!savedCmd.skipSelfTest && initial) {
541 SelfTest::schedule(); 550 SelfTest::schedule();
542 } 551 }
543 args->clear(); 552 args->clear();
544#endif 553#endif
545} 554}
546 555
547void PwMInit::minimizeAllMainWnd(bool toTray) 556void PwMInit::minimizeAllMainWnd(bool toTray)
548{ 557{
549#ifndef PWM_EMBEDDED 558#ifndef PWM_EMBEDDED
550 if (!_mainWndList.size()) 559 if (!_mainWndList.size())
551 return; 560 return;
552#else 561#else
553 if (!_mainWndList.count()) 562 if (!_mainWndList.count())
554 return; 563 return;
555#endif 564#endif
556 const QValueList<PwM *> *ml = mainWndList(); 565 const QValueList<PwM *> *ml = mainWndList();
557#ifndef PWM_EMBEDDED 566#ifndef PWM_EMBEDDED
558 QValueList<PwM *>::const_iterator it = ml->begin(), 567 QValueList<PwM *>::const_iterator it = ml->begin(),
559 end = ml->end(); 568 end = ml->end();
560#else 569#else
561 QValueList<PwM *>::ConstIterator it = ml->begin(), 570 QValueList<PwM *>::ConstIterator it = ml->begin(),
562 end = ml->end(); 571 end = ml->end();
563#endif 572#endif
564 PwM *wnd; 573 PwM *wnd;
565 if (toTray && _tray) { 574 if (toTray && _tray) {
566 /* minimize to tray. 575 /* minimize to tray.
567 * close all mainWnd. 576 * close all mainWnd.
568 */ 577 */
569 while (it != end) { 578 while (it != end) {
570 wnd = *it; 579 wnd = *it;
571 wnd->setForceMinimizeToTray(true); 580 wnd->setForceMinimizeToTray(true);
572 wnd->close_slot(); 581 wnd->close_slot();
573 ++it; 582 ++it;
574 } 583 }
575 } else { 584 } else {
576 // normal minimize 585 // normal minimize
577 while (it != end) { 586 while (it != end) {
578 wnd = *it; 587 wnd = *it;
579 wnd->hide(); 588 wnd->hide();
580 wnd->showMinimized(); 589 wnd->showMinimized();
581 ++it; 590 ++it;
582 } 591 }
583 } 592 }
584} 593}
585 594
586#ifdef PWM_EMBEDDED 595#ifdef PWM_EMBEDDED
587 596
588#ifndef DESKTOP_VERSION 597#ifndef DESKTOP_VERSION
589 598
590PwMApplication::PwMApplication(int & argc, char ** argv) 599PwMApplication::PwMApplication(int & argc, char ** argv)
591 : QPEApplication( argc, argv ) 600 : QPEApplication( argc, argv )
592 , init (0) 601 , init (0)
593{ 602{
594 this->setKeepRunning (); 603 this->setKeepRunning ();
595} 604}
596 605
597PwMApplication::~PwMApplication() 606PwMApplication::~PwMApplication()
598{ 607{
599 delete_ifnot_null(init); 608 delete_ifnot_null(init);
600} 609}
601#else //DESKTOP_VERSION 610#else //DESKTOP_VERSION
602 611
603PwMApplication::PwMApplication(int & argc, char ** argv) 612PwMApplication::PwMApplication(int & argc, char ** argv)
604 : QApplication( argc, argv ) 613 : QApplication( argc, argv )
605 , init (0) 614 , init (0)
606{ 615{
607 setStyle( new QPlatinumStyle ()); 616 setStyle( new QPlatinumStyle ());
608 QString hdir = QDir::homeDirPath(); 617 QString hdir = QDir::homeDirPath();
609 // there is a bug when creating dirs for WIN 98 618 // there is a bug when creating dirs for WIN 98
610 // it is difficult to fix, because we have no WIN 98 runnung 619 // it is difficult to fix, because we have no WIN 98 runnung
611 // such that we try it to create the dirs at startup here 620 // such that we try it to create the dirs at startup here
612 if ( hdir == "C:\\" ) 621 if ( hdir == "C:\\" )
613 { 622 {
614 // win 98 or ME 623 // win 98 or ME
615 QDir app_dir; 624 QDir app_dir;
616 if ( !app_dir.exists("C:\\kdepim") ) 625 if ( !app_dir.exists("C:\\kdepim") )
617 app_dir.mkdir ("C:\\kdepim"); 626 app_dir.mkdir ("C:\\kdepim");
618 if ( !app_dir.exists("C:\\kdepim\\apps") ) 627 if ( !app_dir.exists("C:\\kdepim\\apps") )
619 app_dir.mkdir ("C:\\kdepim\\apps"); 628 app_dir.mkdir ("C:\\kdepim\\apps");
620 if ( !app_dir.exists("C:\\kdepim\\config") ) 629 if ( !app_dir.exists("C:\\kdepim\\config") )
621 app_dir.mkdir ("C:\\kdepim\\config"); 630 app_dir.mkdir ("C:\\kdepim\\config");
622 if ( !app_dir.exists("C:\\kdepim\\apps\\pwmanager") ) 631 if ( !app_dir.exists("C:\\kdepim\\apps\\pwmanager") )
623 app_dir.mkdir ("C:\\kdepim\\apps\\pwmanager"); 632 app_dir.mkdir ("C:\\kdepim\\apps\\pwmanager");
624 } 633 }
625} 634}
626 635
627PwMApplication::~PwMApplication() 636PwMApplication::~PwMApplication()
628{ 637{
629 delete_ifnot_null(init); 638 delete_ifnot_null(init);
630} 639}
631 640
632#endif //DESKTOP_VERSION 641#endif //DESKTOP_VERSION
633 642
634#endif //PWM_EMBEDDED 643#endif //PWM_EMBEDDED
635 644
636 645
637 646
638 647
639#ifndef PWM_EMBEDDED 648#ifndef PWM_EMBEDDED
640#include "pwminit.moc" 649#include "pwminit.moc"
641#endif 650#endif