summaryrefslogtreecommitdiffabout
path: root/pwmanager
authorzautrix <zautrix>2004-10-25 22:23:56 (UTC)
committer zautrix <zautrix>2004-10-25 22:23:56 (UTC)
commitdbfa4de9416c28c5424eeee0f36f50de4cfae0ec (patch) (unidiff)
tree31fa0522ff7821f5b7e98123e16f12455eeb01c9 /pwmanager
parent03ca6830a9e6742b8873aee04d77b3e094b65d30 (diff)
downloadkdepimpi-dbfa4de9416c28c5424eeee0f36f50de4cfae0ec.zip
kdepimpi-dbfa4de9416c28c5424eeee0f36f50de4cfae0ec.tar.gz
kdepimpi-dbfa4de9416c28c5424eeee0f36f50de4cfae0ec.tar.bz2
pwmpi windows management fixes
Diffstat (limited to 'pwmanager') (more/less context) (ignore whitespace changes)
-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
8 files changed, 40 insertions, 15 deletions
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
@@ -81,97 +81,97 @@ getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name)
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");
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
@@ -103,103 +103,103 @@ PWMConfigWidget::PWMConfigWidget(PWMPrefs *prefs, QWidget *parent, const char *n
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);
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
@@ -394,56 +394,61 @@ bool LibGCryptIf::doHashPassphrase(DEK *dek,
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
@@ -164,56 +164,57 @@ int main(int argc, char *argv[])
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
@@ -148,101 +148,103 @@ enum {
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);
@@ -842,101 +844,105 @@ void PwM::config_slot()
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);
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
@@ -2932,96 +2932,97 @@ void PwMDoc::ensureLvp()
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
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
@@ -159,123 +159,126 @@ void 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) {
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
@@ -43,188 +43,188 @@
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();
@@ -277,205 +277,214 @@ void PwMInit::initTray()
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);