summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/getmasterpwwnd_emb.cpp11
-rw-r--r--pwmanager/pwmanager/main.cpp1
-rw-r--r--pwmanager/pwmanager/pwminit.cpp4
3 files changed, 9 insertions, 7 deletions
diff --git a/pwmanager/pwmanager/getmasterpwwnd_emb.cpp b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
index 7f4ccef..8b6dfbc 100644
--- a/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
+++ b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
@@ -1,196 +1,201 @@
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 45
46/* 46/*
47 * Constructs a getMasterPwWnd as a child of 'parent', with the 47 * Constructs a getMasterPwWnd as a child of 'parent', with the
48 * name 'name' 48 * name 'name'
49 */ 49 */
50getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name) 50getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name)
51 : KDialogBase( KDialogBase::Plain, i18n( "Master-password" ), 51 : KDialogBase( KDialogBase::Plain, i18n( "Master-password" ),
52 KDialogBase::Ok | KDialogBase::Cancel, 52 KDialogBase::Ok | KDialogBase::Cancel,
53 KDialogBase::Ok, parent, name, true ) 53 KDialogBase::Ok, parent, name, true )
54{ 54{
55 QWidget *page = plainPage(); 55 QWidget *page = plainPage();
56 QVBoxLayout *pageLayout = new QVBoxLayout( page ); 56 QVBoxLayout *pageLayout = new QVBoxLayout( page );
57 57
58 pwLineEdit = new QLineEdit( page, "pwLineEdit" ); 58 pwLineEdit = new QLineEdit( page, "pwLineEdit" );
59 pwLineEdit->setEchoMode( QLineEdit::Password ); 59 pwLineEdit->setEchoMode( QLineEdit::Password );
60 60
61 QLabel* textLabel1 = new QLabel( pwLineEdit, i18n("Please enter the master-password:"), page, "textLabel1" ); 61 QLabel* textLabel1 = new QLabel( pwLineEdit, i18n("Please enter the master-password:"), page, "textLabel1" );
62 textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) ); 62 textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
63 pageLayout->addWidget(textLabel1); 63 pageLayout->addWidget(textLabel1);
64 pageLayout->addWidget(pwLineEdit); 64 pageLayout->addWidget(pwLineEdit);
65 65
66 QWidget* numberBox = new QWidget( page ); 66 QWidget* numberBox = new QWidget( page );
67 numberBox->setFixedHeight(100); 67#ifndef DESKTOP_VERSION
68 numberBox->setFixedWidth(100); 68 numberBox->setFixedHeight(150);
69 numberBox->setFixedWidth(150);
70#endif
69 71
70 QGridLayout* numberLayout = new QGridLayout( numberBox, 4, 3 ); 72 QGridLayout* numberLayout = new QGridLayout( numberBox, 4, 3 );
71 numberLayout->setMargin( 0 ); 73 numberLayout->setMargin( 0 );
72 numberLayout->setSpacing( 0 ); 74 numberLayout->setSpacing( 0 );
73 75
74 QPushButton* p1 = new QPushButton( i18n("1"), numberBox ); 76 QPushButton* p1 = new QPushButton( i18n("1"), numberBox );
75 numberLayout->addWidget( p1, 0, 0 ); 77 numberLayout->addWidget( p1, 0, 0 );
76 QPushButton* p2 = new QPushButton( i18n("2"), numberBox ); 78 QPushButton* p2 = new QPushButton( i18n("2"), numberBox );
77 numberLayout->addWidget( p2, 0, 1 ); 79 numberLayout->addWidget( p2, 0, 1 );
78 QPushButton* p3 = new QPushButton( i18n("3"), numberBox ); 80 QPushButton* p3 = new QPushButton( i18n("3"), numberBox );
79 numberLayout->addWidget( p3, 0, 2 ); 81 numberLayout->addWidget( p3, 0, 2 );
80 QPushButton* p4 = new QPushButton( i18n("4"), numberBox ); 82 QPushButton* p4 = new QPushButton( i18n("4"), numberBox );
81 numberLayout->addWidget( p4, 1, 0 ); 83 numberLayout->addWidget( p4, 1, 0 );
82 QPushButton* p5 = new QPushButton( i18n("5"), numberBox ); 84 QPushButton* p5 = new QPushButton( i18n("5"), numberBox );
83 numberLayout->addWidget( p5, 1, 1 ); 85 numberLayout->addWidget( p5, 1, 1 );
84 QPushButton* p6 = new QPushButton( i18n("6"), numberBox ); 86 QPushButton* p6 = new QPushButton( i18n("6"), numberBox );
85 numberLayout->addWidget( p6, 1, 2 ); 87 numberLayout->addWidget( p6, 1, 2 );
86 QPushButton* p7 = new QPushButton( i18n("7"), numberBox ); 88 QPushButton* p7 = new QPushButton( i18n("7"), numberBox );
87 numberLayout->addWidget( p7, 2, 0 ); 89 numberLayout->addWidget( p7, 2, 0 );
88 QPushButton* p8 = new QPushButton( i18n("8"), numberBox ); 90 QPushButton* p8 = new QPushButton( i18n("8"), numberBox );
89 numberLayout->addWidget( p8, 2, 1 ); 91 numberLayout->addWidget( p8, 2, 1 );
90 QPushButton* p9 = new QPushButton( i18n("9"), numberBox ); 92 QPushButton* p9 = new QPushButton( i18n("9"), numberBox );
91 numberLayout->addWidget( p9, 2, 2 ); 93 numberLayout->addWidget( p9, 2, 2 );
92 QPushButton* clear = new QPushButton( i18n("x"), numberBox ); 94 QPushButton* clear = new QPushButton( i18n("x"), numberBox );
93 numberLayout->addWidget( clear, 3, 0 ); 95 numberLayout->addWidget( clear, 3, 0 );
94 QPushButton* p0 = new QPushButton( i18n("0"), numberBox ); 96 QPushButton* p0 = new QPushButton( i18n("0"), numberBox );
95 numberLayout->addWidget( p0, 3, 1 ); 97 numberLayout->addWidget( p0, 3, 1 );
96 QPushButton* backspace = new QPushButton( i18n("-"), numberBox ); 98 QPushButton* backspace = new QPushButton( i18n("-"), numberBox );
97 numberLayout->addWidget( backspace, 3, 2 ); 99 numberLayout->addWidget( backspace, 3, 2 );
98 100
99 101
100 pageLayout->addWidget(numberBox); 102 pageLayout->addWidget(numberBox);
101 103#ifdef DESKTOP_VERSION
104 resize( sizeHint() );
105#else
102 resize( 200,sizeHint().height() ); 106 resize( 200,sizeHint().height() );
107#endif
103 108
104 connect( p0, SIGNAL( clicked() ), this, SLOT( add0() ) ); 109 connect( p0, SIGNAL( clicked() ), this, SLOT( add0() ) );
105 connect( p1, SIGNAL( clicked() ), this, SLOT( add1() ) ); 110 connect( p1, SIGNAL( clicked() ), this, SLOT( add1() ) );
106 connect( p2, SIGNAL( clicked() ), this, SLOT( add2() ) ); 111 connect( p2, SIGNAL( clicked() ), this, SLOT( add2() ) );
107 connect( p3, SIGNAL( clicked() ), this, SLOT( add3() ) ); 112 connect( p3, SIGNAL( clicked() ), this, SLOT( add3() ) );
108 connect( p4, SIGNAL( clicked() ), this, SLOT( add4() ) ); 113 connect( p4, SIGNAL( clicked() ), this, SLOT( add4() ) );
109 connect( p5, SIGNAL( clicked() ), this, SLOT( add5() ) ); 114 connect( p5, SIGNAL( clicked() ), this, SLOT( add5() ) );
110 connect( p6, SIGNAL( clicked() ), this, SLOT( add6() ) ); 115 connect( p6, SIGNAL( clicked() ), this, SLOT( add6() ) );
111 connect( p7, SIGNAL( clicked() ), this, SLOT( add7() ) ); 116 connect( p7, SIGNAL( clicked() ), this, SLOT( add7() ) );
112 connect( p8, SIGNAL( clicked() ), this, SLOT( add8() ) ); 117 connect( p8, SIGNAL( clicked() ), this, SLOT( add8() ) );
113 connect( p9, SIGNAL( clicked() ), this, SLOT( add9() ) ); 118 connect( p9, SIGNAL( clicked() ), this, SLOT( add9() ) );
114 connect( backspace, SIGNAL( clicked() ), this, SLOT( backspace() ) ); 119 connect( backspace, SIGNAL( clicked() ), this, SLOT( backspace() ) );
115 connect( clear, SIGNAL( clicked() ), this, SLOT( clear() ) ); 120 connect( clear, SIGNAL( clicked() ), this, SLOT( clear() ) );
116 121
117 122
118 123
119} 124}
120 125
121/* 126/*
122 * Destroys the object and frees any allocated resources 127 * Destroys the object and frees any allocated resources
123 */ 128 */
124getMasterPwWnd::~getMasterPwWnd() 129getMasterPwWnd::~getMasterPwWnd()
125{ 130{
126 // no need to delete child widgets, Qt does it all for us 131 // no need to delete child widgets, Qt does it all for us
127} 132}
128 133
129void getMasterPwWnd::okButton_slot() 134void getMasterPwWnd::okButton_slot()
130{ 135{
131 qWarning( "getMasterPwWnd::okButton_slot(): Not implemented yet" ); 136 qWarning( "getMasterPwWnd::okButton_slot(): Not implemented yet" );
132} 137}
133 138
134void getMasterPwWnd::cancelButton_slot() 139void getMasterPwWnd::cancelButton_slot()
135{ 140{
136 qWarning( "getMasterPwWnd::cancelButton_slot(): Not implemented yet" ); 141 qWarning( "getMasterPwWnd::cancelButton_slot(): Not implemented yet" );
137} 142}
138 143
139void getMasterPwWnd::add0() 144void getMasterPwWnd::add0()
140{ 145{
141 addCharacter("0"); 146 addCharacter("0");
142} 147}
143void getMasterPwWnd::add1() 148void getMasterPwWnd::add1()
144{ 149{
145 addCharacter("1"); 150 addCharacter("1");
146} 151}
147void getMasterPwWnd::add2() 152void getMasterPwWnd::add2()
148{ 153{
149 addCharacter("2"); 154 addCharacter("2");
150} 155}
151void getMasterPwWnd::add3() 156void getMasterPwWnd::add3()
152{ 157{
153 addCharacter("3"); 158 addCharacter("3");
154} 159}
155void getMasterPwWnd::add4() 160void getMasterPwWnd::add4()
156{ 161{
157 addCharacter("4"); 162 addCharacter("4");
158} 163}
159void getMasterPwWnd::add5() 164void getMasterPwWnd::add5()
160{ 165{
161 addCharacter("5"); 166 addCharacter("5");
162} 167}
163void getMasterPwWnd::add6() 168void getMasterPwWnd::add6()
164{ 169{
165 addCharacter("6"); 170 addCharacter("6");
166} 171}
167void getMasterPwWnd::add7() 172void getMasterPwWnd::add7()
168{ 173{
169 addCharacter("7"); 174 addCharacter("7");
170} 175}
171void getMasterPwWnd::add8() 176void getMasterPwWnd::add8()
172{ 177{
173 addCharacter("8"); 178 addCharacter("8");
174} 179}
175void getMasterPwWnd::add9() 180void getMasterPwWnd::add9()
176{ 181{
177 addCharacter("9"); 182 addCharacter("9");
178} 183}
179void getMasterPwWnd::backspace() 184void getMasterPwWnd::backspace()
180{ 185{
181 QString old = pwLineEdit->text(); 186 QString old = pwLineEdit->text();
182 old.truncate(old.length()-1); 187 old.truncate(old.length()-1);
183 pwLineEdit->setText(old); 188 pwLineEdit->setText(old);
184} 189}
185 190
186void getMasterPwWnd::clear() 191void getMasterPwWnd::clear()
187{ 192{
188 pwLineEdit->setText(""); 193 pwLineEdit->setText("");
189} 194}
190 195
191void getMasterPwWnd::addCharacter(const QString& s) 196void getMasterPwWnd::addCharacter(const QString& s)
192{ 197{
193 QString old = pwLineEdit->text(); 198 QString old = pwLineEdit->text();
194 pwLineEdit->setText(old + s); 199 pwLineEdit->setText(old + s);
195} 200}
196 201
diff --git a/pwmanager/pwmanager/main.cpp b/pwmanager/pwmanager/main.cpp
index 9d1d863..3f2d055 100644
--- a/pwmanager/pwmanager/main.cpp
+++ b/pwmanager/pwmanager/main.cpp
@@ -1,214 +1,213 @@
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 cout << "sizeof(long): " << sizeof(long) << endl; 87 cout << "sizeof(long): " << sizeof(long) << endl;
88 cout << "================================" << endl; 88 cout << "================================" << endl;
89} 89}
90#else // PWM_DEBUG 90#else // PWM_DEBUG
91static inline void printDebugConfigureInfo() { /* nothing */ } 91static inline void printDebugConfigureInfo() { /* nothing */ }
92#endif // PWM_DEBUG 92#endif // PWM_DEBUG
93 93
94#ifndef PWM_EMBEDDED 94#ifndef PWM_EMBEDDED
95static void addAuthors(KAboutData *aboutData) 95static void addAuthors(KAboutData *aboutData)
96{ 96{
97 aboutData->addAuthor("Michael Buesch", 97 aboutData->addAuthor("Michael Buesch",
98 I18N_NOOP( 98 I18N_NOOP(
99 "main programming and current maintainer"), 99 "main programming and current maintainer"),
100 "mbuesch@freenet.de"); 100 "mbuesch@freenet.de");
101 aboutData->addAuthor("Matt Scifo", 101 aboutData->addAuthor("Matt Scifo",
102 I18N_NOOP( 102 I18N_NOOP(
103 "original implementaion of \n" 103 "original implementaion of \n"
104 "\"categories\" and the password-tree \n" 104 "\"categories\" and the password-tree \n"
105 "in the system-tray. Original implementations of \n" 105 "in the system-tray. Original implementations of \n"
106 "numerous view-improvements."), 106 "numerous view-improvements."),
107 "mscifo@o1.com"); 107 "mscifo@o1.com");
108 aboutData->addCredit("Elias Probst", 108 aboutData->addCredit("Elias Probst",
109 I18N_NOOP( 109 I18N_NOOP(
110 "Gentoo ebuild maintainer."), 110 "Gentoo ebuild maintainer."),
111 "elias.probst@gmx.de"); 111 "elias.probst@gmx.de");
112 aboutData->addCredit("George Staikos", 112 aboutData->addCredit("George Staikos",
113 I18N_NOOP("KWallet"), 113 I18N_NOOP("KWallet"),
114 "staikos@kde.org"); 114 "staikos@kde.org");
115 aboutData->addCredit("Matthew Palmer", 115 aboutData->addCredit("Matthew Palmer",
116 I18N_NOOP("rc2 code"), 116 I18N_NOOP("rc2 code"),
117 "mjp16@uow.edu.au"); 117 "mjp16@uow.edu.au");
118 aboutData->addCredit("Olivier Sessink", 118 aboutData->addCredit("Olivier Sessink",
119 I18N_NOOP("gpasman"), 119 I18N_NOOP("gpasman"),
120 "gpasman@nl.linux.org"); 120 "gpasman@nl.linux.org");
121 aboutData->addCredit("The libgcrypt developers", 121 aboutData->addCredit("The libgcrypt developers",
122 I18N_NOOP("Blowfish and SHA1 algorithms"), 122 I18N_NOOP("Blowfish and SHA1 algorithms"),
123 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/"); 123 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/");
124 aboutData->addCredit("Troy Engel", 124 aboutData->addCredit("Troy Engel",
125 I18N_NOOP("kpasman"), 125 I18N_NOOP("kpasman"),
126 "tengel@sonic.net"); 126 "tengel@sonic.net");
127 aboutData->addCredit("Wickey", 127 aboutData->addCredit("Wickey",
128 I18N_NOOP("graphics-design in older versions."), 128 I18N_NOOP("graphics-design in older versions."),
129 "wickey@gmx.at"); 129 "wickey@gmx.at");
130 aboutData->addCredit("Ian MacGregor", 130 aboutData->addCredit("Ian MacGregor",
131 I18N_NOOP( 131 I18N_NOOP(
132 "original documentation author.")); 132 "original documentation author."));
133} 133}
134#endif 134#endif
135 135
136int main(int argc, char *argv[]) 136int main(int argc, char *argv[])
137{ 137{
138 printDebugConfigureInfo(); 138 printDebugConfigureInfo();
139#ifndef PWM_EMBEDDED 139#ifndef PWM_EMBEDDED
140 KAboutData aboutData(PACKAGE_NAME, PROG_NAME, 140 KAboutData aboutData(PACKAGE_NAME, PROG_NAME,
141 PACKAGE_VER, description, KAboutData::License_File, 141 PACKAGE_VER, description, KAboutData::License_File,
142 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0, 142 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0,
143 "http://passwordmanager.sourceforge.net/", 143 "http://passwordmanager.sourceforge.net/",
144 "mbuesch@freenet.de"); 144 "mbuesch@freenet.de");
145 addAuthors(&aboutData); 145 addAuthors(&aboutData);
146 146
147 KCmdLineArgs::init(argc, argv, &aboutData); 147 KCmdLineArgs::init(argc, argv, &aboutData);
148 KCmdLineArgs::addCmdLineOptions(options); 148 KCmdLineArgs::addCmdLineOptions(options);
149 149
150 KUniqueApplication::addCmdLineOptions(); 150 KUniqueApplication::addCmdLineOptions();
151 if (!KUniqueApplication::start()) { 151 if (!KUniqueApplication::start()) {
152 printInfo("already running."); 152 printInfo("already running.");
153 return EXIT_SUCCESS; 153 return EXIT_SUCCESS;
154 } 154 }
155 PwMApplication a; 155 PwMApplication a;
156 aboutData.setLicenseTextFile(LICENSE_FILE); 156 aboutData.setLicenseTextFile(LICENSE_FILE);
157 return a.exec(); 157 return a.exec();
158#else 158#else
159 159
160 bool exitHelp = false; 160 bool exitHelp = false;
161 if ( argc > 1 ) { 161 if ( argc > 1 ) {
162 QString command = argv[1]; 162 QString command = argv[1];
163 if ( command == "-help" ){ 163 if ( command == "-help" ){
164 printf("PWM/PI command line commands:\n"); 164 printf("PWM/PI command line commands:\n");
165 printf(" no command: Start PWM/PI in usual way\n"); 165 printf(" no command: Start PWM/PI in usual way\n");
166 printf(" -help: This output\n"); 166 printf(" -help: This output\n");
167 printf(" PWM/PI is exiting now. Bye!\n"); 167 printf(" PWM/PI is exiting now. Bye!\n");
168 exitHelp = true; 168 exitHelp = true;
169 } 169 }
170 } 170 }
171 if ( ! exitHelp ) { 171 if ( ! exitHelp ) {
172 172
173 PwMApplication a(argc, argv); 173 PwMApplication a(argc, argv);
174 174
175 KGlobal::setAppName( "pwmanager" ); 175 KGlobal::setAppName( "pwmanager" );
176#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
177 //qDebug("width %d ",QApplication::desktop()->width() ); 177 //qDebug("width %d ",QApplication::desktop()->width() );
178 if ( QApplication::desktop()->width() > 320 ) 178 if ( QApplication::desktop()->width() > 320 )
179 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/"); 179 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/");
180 else 180 else
181 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/"); 181 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/");
182#else 182#else
183 QString fileName ; 183 QString fileName ;
184 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/"; 184 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/";
185 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 185 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
186 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 186 QApplication::addLibraryPath ( qApp->applicationDirPath () );
187 187
188#endif 188#endif
189 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager"))); 189 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager")));
190 KPimGlobalPrefs::instance()->setGlobalConfig(); 190 KPimGlobalPrefs::instance()->setGlobalConfig();
191 191
192 a.newInstance(); 192 a.newInstance();
193 193
194 //US KAddressBookMain m ; 194 //US KAddressBookMain m ;
195 195
196 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 196 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
197 /*US 197 /*US
198#ifndef DESKTOP_VERSION 198#ifndef DESKTOP_VERSION
199 a.showMainWidget( &m ); 199 a.showMainWidget( &m );
200#else 200#else
201 a.setMainWidget( &m ); 201 a.setMainWidget( &m );
202 m.resize (640, 480 ); 202 m.resize (640, 480 );
203 m.show(); 203 m.show();
204#endif 204#endif
205 */ 205 */
206 qDebug("exec ");
207 a.exec(); 206 a.exec();
208 207
209 } 208 }
210 qDebug("PWMPI: Bye! "); 209 qDebug("PWMPI: Bye! ");
211 210
212#endif 211#endif
213 212
214} 213}
diff --git a/pwmanager/pwmanager/pwminit.cpp b/pwmanager/pwmanager/pwminit.cpp
index ea9e330..9238c8c 100644
--- a/pwmanager/pwmanager/pwminit.cpp
+++ b/pwmanager/pwmanager/pwminit.cpp
@@ -1,640 +1,638 @@
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;
58static NOREGPARM void sig_handler(int signum) 58static NOREGPARM void sig_handler(int signum)
59{ 59{
60 switch (signum) { 60 switch (signum) {
61 case SIGINT: 61 case SIGINT:
62 case SIGTERM: 62 case SIGTERM:
63 sig_init_pointer->shutdownApp(20 + signum); 63 sig_init_pointer->shutdownApp(20 + signum);
64 break; 64 break;
65 default: 65 default:
66 printDebug(string("unhandled signal ") 66 printDebug(string("unhandled signal ")
67 + tostr(signum)); 67 + tostr(signum));
68 } 68 }
69} 69}
70 70
71 71
72 72
73 73
74PwMInit::PwMInit(PwMApplication *_app) 74PwMInit::PwMInit(PwMApplication *_app)
75 : runStatus (unknown) 75 : runStatus (unknown)
76 , _curWidget (0) 76 , _curWidget (0)
77 , _dcopClient (0) 77 , _dcopClient (0)
78 , _kwalletEmu (0) 78 , _kwalletEmu (0)
79 , _keycard (0) 79 , _keycard (0)
80 , _tray (0) 80 , _tray (0)
81{ 81{
82 sig_init_pointer = this; 82 sig_init_pointer = this;
83 app = _app; 83 app = _app;
84} 84}
85 85
86PwMInit::~PwMInit() 86PwMInit::~PwMInit()
87{ 87{
88#ifndef PWM_EMBEDDED 88#ifndef PWM_EMBEDDED
89 SelfTest::cancel(); 89 SelfTest::cancel();
90 // close all open mainwnds 90 // close all open mainwnds
91 QValueList<PwM *>::iterator i = _mainWndList.begin(), 91 QValueList<PwM *>::iterator i = _mainWndList.begin(),
92 end = _mainWndList.end(); 92 end = _mainWndList.end();
93 93
94#else 94#else
95 // close all open mainwnds 95 // close all open mainwnds
96 QValueList<PwM *>::Iterator i = _mainWndList.begin(), 96 QValueList<PwM *>::Iterator i = _mainWndList.begin(),
97 end = _mainWndList.end(); 97 end = _mainWndList.end();
98#endif 98#endif
99 while (i != end) { 99 while (i != end) {
100 disconnect(*i, SIGNAL(closed(PwM *)), 100 disconnect(*i, SIGNAL(closed(PwM *)),
101 this, SLOT(mainWndClosed(PwM *))); 101 this, SLOT(mainWndClosed(PwM *)));
102 delete *i; 102 delete *i;
103 ++i; 103 ++i;
104 } 104 }
105 _mainWndList.clear(); 105 _mainWndList.clear();
106 // close all remaining open documents 106 // close all remaining open documents
107 PwMDocList *_dl = PwMDoc::getOpenDocList(); 107 PwMDocList *_dl = PwMDoc::getOpenDocList();
108 vector<PwMDocList::listItem> dl = *(_dl->getList()); 108 vector<PwMDocList::listItem> dl = *(_dl->getList());
109 vector<PwMDocList::listItem>::iterator i2 = dl.begin(), 109 vector<PwMDocList::listItem>::iterator i2 = dl.begin(),
110 end2 = dl.end(); 110 end2 = dl.end();
111 while (i2 != end2) { 111 while (i2 != end2) {
112 delete (*i2).doc; 112 delete (*i2).doc;
113 ++i2; 113 ++i2;
114 } 114 }
115 115
116#ifdef CONFIG_KWALLETIF 116#ifdef CONFIG_KWALLETIF
117 delete_ifnot_null(_kwalletEmu); 117 delete_ifnot_null(_kwalletEmu);
118#endif // CONFIG_KWALLETIF 118#endif // CONFIG_KWALLETIF
119#ifdef CONFIG_KEYCARD 119#ifdef CONFIG_KEYCARD
120 delete_ifnot_null(_keycard); 120 delete_ifnot_null(_keycard);
121#endif // CONFIG_KEYCARD 121#endif // CONFIG_KEYCARD
122 delete_ifnot_null(_tray); 122 delete_ifnot_null(_tray);
123 123
124 Randomizer::cleanup(); 124 Randomizer::cleanup();
125#ifndef PWM_EMBEDDED 125#ifndef PWM_EMBEDDED
126 Configuration::cleanup(); 126 Configuration::cleanup();
127#endif 127#endif
128} 128}
129 129
130void PwMInit::initializeApp() 130void PwMInit::initializeApp()
131{ 131{
132 qDebug("PwMInit::initializeApp() "); 132 //qDebug("PwMInit::initializeApp() ");
133 PWM_ASSERT(runStatus == unknown); 133 PWM_ASSERT(runStatus == unknown);
134 runStatus = init; 134 runStatus = init;
135 initPosixSignalHandler(); 135 initPosixSignalHandler();
136 Randomizer::init(); 136 Randomizer::init();
137#ifndef PWM_EMBEDDED 137#ifndef PWM_EMBEDDED
138 Configuration::init(); 138 Configuration::init();
139#endif 139#endif
140 initDCOP(); 140 initDCOP();
141 initKWalletEmu(); 141 initKWalletEmu();
142 initKeycard(); 142 initKeycard();
143 initTray(); 143 initTray();
144 handleCmdLineArgs(); 144 handleCmdLineArgs();
145 qDebug("handle ");
146 bool openDeeplocked = false; 145 bool openDeeplocked = false;
147 if (conf()->confGlobAutostartDeepLocked() || 146 if (conf()->confGlobAutostartDeepLocked() ||
148 savedCmd.open_deeplocked) 147 savedCmd.open_deeplocked)
149 openDeeplocked = true; 148 openDeeplocked = true;
150 if ( false ){ 149 if ( false ){
151 // LR is not working 150 // LR is not working
152 //if (conf()->confWndAutoMinimizeOnStart() || 151 //if (conf()->confWndAutoMinimizeOnStart() ||
153 // savedCmd.minToTray) { 152 // savedCmd.minToTray) {
154 PwMDoc *newDoc = createDoc(); 153 PwMDoc *newDoc = createDoc();
155 qDebug(" createDoc()"); 154 qDebug(" createDoc()");
156 if (!newDoc->openDocUi(newDoc, 155 if (!newDoc->openDocUi(newDoc,
157 conf()->confGlobAutoStart(), 156 conf()->confGlobAutoStart(),
158 openDeeplocked)) { 157 openDeeplocked)) {
159 delete newDoc; 158 delete newDoc;
160 } 159 }
161 160
162 //US ENH for embedded devices: in the case of failure, open a document the default way 161 //US ENH for embedded devices: in the case of failure, open a document the default way
163 createMainWnd(conf()->confGlobAutoStart(), 162 createMainWnd(conf()->confGlobAutoStart(),
164 openDeeplocked, 163 openDeeplocked,
165 true, 164 true,
166 0, 165 0,
167 savedCmd.minimized); 166 savedCmd.minimized);
168 167
169 168
170 169
171 170
172 //} 171 //}
173 } else { 172 } else {
174 createMainWnd(conf()->confGlobAutoStart(), 173 createMainWnd(conf()->confGlobAutoStart(),
175 openDeeplocked, 174 openDeeplocked,
176 true, 175 true,
177 0, 176 0,
178 savedCmd.minimized); 177 savedCmd.minimized);
179 } 178 }
180 179
181 runStatus = running; 180 runStatus = running;
182} 181}
183 182
184void PwMInit::shutdownApp(int exitStatus) 183void PwMInit::shutdownApp(int exitStatus)
185{ 184{
186 printDebug(string("PwMInit::shutdownApp(") 185 printDebug(string("PwMInit::shutdownApp(")
187 + tostr(exitStatus) + ") called."); 186 + tostr(exitStatus) + ") called.");
188 PWM_ASSERT((runStatus == running) || (runStatus == init)); 187 PWM_ASSERT((runStatus == running) || (runStatus == init));
189 runStatus = shutdown; 188 runStatus = shutdown;
190 QApplication::exit(exitStatus); 189 QApplication::exit(exitStatus);
191 /* The destructor of PwMInit is called when control 190 /* The destructor of PwMInit is called when control
192 * leaves main() 191 * leaves main()
193 */ 192 */
194} 193}
195 194
196void PwMInit::initPosixSignalHandler() 195void PwMInit::initPosixSignalHandler()
197{ 196{
198 signal(SIGINT, sig_handler); 197 signal(SIGINT, sig_handler);
199 signal(SIGTERM, sig_handler); 198 signal(SIGTERM, sig_handler);
200} 199}
201 200
202void PwMInit::initDCOP() 201void PwMInit::initDCOP()
203{ 202{
204#ifndef PWM_EMBEDDED 203#ifndef PWM_EMBEDDED
205 _dcopClient = app->dcopClient(); 204 _dcopClient = app->dcopClient();
206 _dcopClient->setNotifications(true); 205 _dcopClient->setNotifications(true);
207#endif 206#endif
208 207
209} 208}
210 209
211void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload) 210void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload)
212{ 211{
213#ifdef CONFIG_KWALLETIF 212#ifdef CONFIG_KWALLETIF
214 if (!conf()->confGlobKwalletEmu() || 213 if (!conf()->confGlobKwalletEmu() ||
215 forceDisable) { 214 forceDisable) {
216 delete_ifnot_null(_kwalletEmu); 215 delete_ifnot_null(_kwalletEmu);
217 return; 216 return;
218 } 217 }
219 try { 218 try {
220 if (_kwalletEmu && forceReload) 219 if (_kwalletEmu && forceReload)
221 delete_and_null(_kwalletEmu); 220 delete_and_null(_kwalletEmu);
222 if (!_kwalletEmu) 221 if (!_kwalletEmu)
223 _kwalletEmu = new KWalletEmu(this); 222 _kwalletEmu = new KWalletEmu(this);
224 } catch (PwMException e) { 223 } catch (PwMException e) {
225 string errMsg("initializing KWallet emulation failed. ID: "); 224 string errMsg("initializing KWallet emulation failed. ID: ");
226 errMsg += tostr(static_cast<int>(e.getId())); 225 errMsg += tostr(static_cast<int>(e.getId()));
227 errMsg += " err-message: "; 226 errMsg += " err-message: ";
228 errMsg += e.getMessage(); 227 errMsg += e.getMessage();
229 printWarn(errMsg); 228 printWarn(errMsg);
230 return; 229 return;
231 } 230 }
232#else // CONFIG_KWALLETIF 231#else // CONFIG_KWALLETIF
233 PARAM_UNUSED(forceDisable); 232 PARAM_UNUSED(forceDisable);
234 PARAM_UNUSED(forceReload); 233 PARAM_UNUSED(forceReload);
235#endif // CONFIG_KWALLETIF 234#endif // CONFIG_KWALLETIF
236} 235}
237 236
238void PwMInit::initKeycard() 237void PwMInit::initKeycard()
239{ 238{
240#ifdef CONFIG_KEYCARD 239#ifdef CONFIG_KEYCARD
241 PWM_ASSERT(!_keycard); 240 PWM_ASSERT(!_keycard);
242 _keycard = new PwMKeyCard(this); 241 _keycard = new PwMKeyCard(this);
243#endif // CONFIG_KEYCARD 242#endif // CONFIG_KEYCARD
244} 243}
245 244
246void PwMInit::initTray() 245void PwMInit::initTray()
247{ 246{
248#ifdef PWM_EMBEDDED 247#ifdef PWM_EMBEDDED
249 //US ENH : embedded version does not support a tray 248 //US ENH : embedded version does not support a tray
250 return; 249 return;
251#endif 250#endif
252 251
253 if (!conf()->confGlobTray()) { 252 if (!conf()->confGlobTray()) {
254 if (!_tray) 253 if (!_tray)
255 return; 254 return;
256 _tray->hide(); 255 _tray->hide();
257 delete_and_null(_tray); 256 delete_and_null(_tray);
258 return; 257 return;
259 } 258 }
260 if (_tray) 259 if (_tray)
261 return; 260 return;
262 _tray = new PwMTray(this); 261 _tray = new PwMTray(this);
263 connect(_tray, SIGNAL(quitSelected()), 262 connect(_tray, SIGNAL(quitSelected()),
264 this, SLOT(removeTrayAndQuit())); 263 this, SLOT(removeTrayAndQuit()));
265 connect(_tray, SIGNAL(closed(PwMTray *)), 264 connect(_tray, SIGNAL(closed(PwMTray *)),
266 this, SLOT(trayIconClosed(PwMTray *))); 265 this, SLOT(trayIconClosed(PwMTray *)));
267 KIconLoader icons; 266 KIconLoader icons;
268#ifndef PWM_EMBEDDED 267#ifndef PWM_EMBEDDED
269 _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small)); 268 _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small));
270#endif 269#endif
271 _tray->show(); 270 _tray->show();
272 // connect the signals of all open documents. 271 // connect the signals of all open documents.
273 const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList(); 272 const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList();
274 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 273 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
275 end = dl->end(); 274 end = dl->end();
276 while (i != end) { 275 while (i != end) {
277 _tray->connectDocToTray((*i).doc); 276 _tray->connectDocToTray((*i).doc);
278 ++i; 277 ++i;
279 } 278 }
280} 279}
281 280
282void PwMInit::removeTrayAndQuit() 281void PwMInit::removeTrayAndQuit()
283{ 282{
284 PWM_ASSERT(_tray); 283 PWM_ASSERT(_tray);
285 // _tray is deleted in ~PwMInit 284 // _tray is deleted in ~PwMInit
286 shutdownApp(0); 285 shutdownApp(0);
287} 286}
288 287
289PwM * PwMInit::createMainWnd(const QString &loadFile, 288PwM * PwMInit::createMainWnd(const QString &loadFile,
290 bool loadFileDeepLocked, 289 bool loadFileDeepLocked,
291 bool virginity, 290 bool virginity,
292 PwMDoc *doc, 291 PwMDoc *doc,
293 bool minimized) 292 bool minimized)
294{ 293{
295 qDebug("PwMInit::createMainWnd ");
296 PwM *newWnd; 294 PwM *newWnd;
297 if (!doc) 295 if (!doc)
298 doc = createDoc(); 296 doc = createDoc();
299 newWnd = new PwM(this, doc, virginity); 297 newWnd = new PwM(this, doc, virginity);
300#ifndef PWM_EMBEDDED 298#ifndef PWM_EMBEDDED
301 _mainWndList.push_back(newWnd); 299 _mainWndList.push_back(newWnd);
302#else 300#else
303 _mainWndList.append(newWnd); 301 _mainWndList.append(newWnd);
304#endif 302#endif
305 connect(newWnd, SIGNAL(closed(PwM *)), 303 connect(newWnd, SIGNAL(closed(PwM *)),
306 this, SLOT(mainWndClosed(PwM *))); 304 this, SLOT(mainWndClosed(PwM *)));
307 connect(newWnd, SIGNAL(gotFocus(PwM *)), 305 connect(newWnd, SIGNAL(gotFocus(PwM *)),
308 this, SLOT(setCurWidget(PwM *))); 306 this, SLOT(setCurWidget(PwM *)));
309 connect(newWnd, SIGNAL(lostFocus(PwM *)), 307 connect(newWnd, SIGNAL(lostFocus(PwM *)),
310 this, SLOT(resetCurWidget())); 308 this, SLOT(resetCurWidget()));
311 309
312 //US ENH 310 //US ENH
313#ifndef PWM_EMBEDDED 311#ifndef PWM_EMBEDDED
314 if (minimized) 312 if (minimized)
315 newWnd->showMinimized(); 313 newWnd->showMinimized();
316 else 314 else
317 newWnd->show(); 315 newWnd->show();
318 316
319#else //PWM_EMBEDDED 317#else //PWM_EMBEDDED
320 318
321#ifndef DESKTOP_VERSION 319#ifndef DESKTOP_VERSION
322 app->showMainWidget( newWnd ); 320 app->showMainWidget( newWnd );
323#else //DESKTOP_VERSION 321#else //DESKTOP_VERSION
324 app->setMainWidget( newWnd ); 322 app->setMainWidget( newWnd );
325 newWnd->resize (640, 480 ); 323 newWnd->resize (640, 480 );
326 newWnd->show(); 324 newWnd->show();
327 qDebug("show "); 325 qDebug("show ");
328#endif //DESKTOP_VERSION 326#endif //DESKTOP_VERSION
329 327
330#endif //PWM_EMBEDDED 328#endif //PWM_EMBEDDED
331 329
332 if (loadFile != QString::null && 330 if (loadFile != QString::null &&
333 loadFile != "") { 331 loadFile != "") {
334 newWnd->openDoc(loadFile, loadFileDeepLocked); 332 newWnd->openDoc(loadFile, loadFileDeepLocked);
335 } 333 }
336 return newWnd; 334 return newWnd;
337} 335}
338 336
339PwMDoc * PwMInit::createDoc() 337PwMDoc * PwMInit::createDoc()
340{ 338{
341 PwMDoc *doc = new PwMDoc(this); 339 PwMDoc *doc = new PwMDoc(this);
342#ifdef CONFIG_KEYCARD 340#ifdef CONFIG_KEYCARD
343 doc->setPwMKeyCard(keycard()); 341 doc->setPwMKeyCard(keycard());
344#endif 342#endif
345#ifdef CONFIG_KWALLETIF 343#ifdef CONFIG_KWALLETIF
346 if (kwalletEmu()) 344 if (kwalletEmu())
347 kwalletEmu()->connectDocSignals(doc); 345 kwalletEmu()->connectDocSignals(doc);
348#endif 346#endif
349 347
350 if (_tray) 348 if (_tray)
351 _tray->connectDocToTray(doc); 349 _tray->connectDocToTray(doc);
352 350
353 return doc; 351 return doc;
354 352
355} 353}
356 354
357void PwMInit::mainWndClosed(PwM *wnd) 355void PwMInit::mainWndClosed(PwM *wnd)
358{ 356{
359 bool doMinimizeToTray = false; 357 bool doMinimizeToTray = false;
360 bool doDeleteDoc = false; 358 bool doDeleteDoc = false;
361#ifndef PWM_EMBEDDED 359#ifndef PWM_EMBEDDED
362 dcopClient()->suspend(); 360 dcopClient()->suspend();
363 dcopClient()->setAcceptCalls(false); 361 dcopClient()->setAcceptCalls(false);
364#endif 362#endif
365again: 363again:
366 364
367 if (wnd->isForceMinimizeToTray()) { 365 if (wnd->isForceMinimizeToTray()) {
368 if (unlikely(!_tray)) { 366 if (unlikely(!_tray)) {
369 /* This should not happen! If we set forceMinimizeToTray , 367 /* This should not happen! If we set forceMinimizeToTray ,
370 * we must be sure that _tray exists. 368 * we must be sure that _tray exists.
371 */ 369 */
372 BUG(); 370 BUG();
373 wnd->setForceMinimizeToTray(false); 371 wnd->setForceMinimizeToTray(false);
374 goto again; 372 goto again;
375 } 373 }
376 doMinimizeToTray = true; 374 doMinimizeToTray = true;
377 } else { 375 } else {
378 // Ask to minimize to tray. If not, delete doc. 376 // Ask to minimize to tray. If not, delete doc.
379 if (_tray && 377 if (_tray &&
380 runStatus != shutdown && 378 runStatus != shutdown &&
381 !wnd->isForceQuit() && 379 !wnd->isForceQuit() &&
382 !wnd->curDoc()->isDeleted()) { 380 !wnd->curDoc()->isDeleted()) {
383 if (conf()->confWndClose()) 381 if (conf()->confWndClose())
384 doDeleteDoc = true; 382 doDeleteDoc = true;
385 else 383 else
386 doMinimizeToTray = true; 384 doMinimizeToTray = true;
387 } else { 385 } else {
388 doDeleteDoc = true; 386 doDeleteDoc = true;
389 } 387 }
390 } 388 }
391 389
392 if (doMinimizeToTray) { 390 if (doMinimizeToTray) {
393 391
394 PWM_ASSERT(_tray); 392 PWM_ASSERT(_tray);
395 int mmlock = conf()->confGlobMinimizeLock(); 393 int mmlock = conf()->confGlobMinimizeLock();
396 switch (mmlock) { 394 switch (mmlock) {
397 case 0: // don't lock anything 395 case 0: // don't lock anything
398 break; 396 break;
399 case 1: // normal lock 397 case 1: // normal lock
400 wnd->curDoc()->lockAll(true); 398 wnd->curDoc()->lockAll(true);
401 break; 399 break;
402 case 2: // deep-lock 400 case 2: // deep-lock
403 wnd->curDoc()->deepLock(); 401 wnd->curDoc()->deepLock();
404 break; 402 break;
405 default: 403 default:
406 WARN(); 404 WARN();
407 } 405 }
408 } else if (doDeleteDoc) { 406 } else if (doDeleteDoc) {
409 if (!wnd->curDoc()->tryDelete()) { 407 if (!wnd->curDoc()->tryDelete()) {
410 /* We failed deleting the doc, 408 /* We failed deleting the doc,
411 * so open a new window with it, again. 409 * so open a new window with it, again.
412 */ 410 */
413 createMainWnd(QString::null, false, 411 createMainWnd(QString::null, false,
414 false, wnd->curDoc()); 412 false, wnd->curDoc());
415 } 413 }
416 } 414 }
417#ifndef PWM_EMBEDDED 415#ifndef PWM_EMBEDDED
418 // find the closed window in the "mainWndList" and delete it. 416 // find the closed window in the "mainWndList" and delete it.
419 QValueList<PwM *>::iterator i = _mainWndList.begin(), 417 QValueList<PwM *>::iterator i = _mainWndList.begin(),
420 end = _mainWndList.end(); 418 end = _mainWndList.end();
421#else 419#else
422 // find the closed window in the "mainWndList" and delete it. 420 // find the closed window in the "mainWndList" and delete it.
423 QValueList<PwM *>::Iterator i = _mainWndList.begin(), 421 QValueList<PwM *>::Iterator i = _mainWndList.begin(),
424 end = _mainWndList.end(); 422 end = _mainWndList.end();
425#endif 423#endif
426 while (i != end) { 424 while (i != end) {
427 if (*i == wnd) { 425 if (*i == wnd) {
428#ifndef PWM_EMBEDDED 426#ifndef PWM_EMBEDDED
429 _mainWndList.erase(i); 427 _mainWndList.erase(i);
430#else 428#else
431 _mainWndList.remove(i); 429 _mainWndList.remove(i);
432#endif 430#endif
433 goto out_success; 431 goto out_success;
434 } 432 }
435 ++i; 433 ++i;
436 } 434 }
437 BUG(); 435 BUG();
438out_success: 436out_success:
439#ifndef PWM_EMBEDDED 437#ifndef PWM_EMBEDDED
440 if (!_mainWndList.size()) 438 if (!_mainWndList.size())
441#else 439#else
442 if (!_mainWndList.count()) 440 if (!_mainWndList.count())
443#endif 441#endif
444 442
445 { 443 {
446 /* If there's no main window and no tray icon 444 /* If there's no main window and no tray icon
447 * left, we have no user interface, so we can 445 * left, we have no user interface, so we can
448 * shut down the application. 446 * shut down the application.
449 */ 447 */
450 if (!_tray) { 448 if (!_tray) {
451#ifndef PWM_EMBEDDED 449#ifndef PWM_EMBEDDED
452 dcopClient()->setAcceptCalls(true); 450 dcopClient()->setAcceptCalls(true);
453 dcopClient()->resume(); 451 dcopClient()->resume();
454#endif 452#endif
455 shutdownApp(0); 453 shutdownApp(0);
456 return; 454 return;
457 } 455 }
458 /* There is no widget left, so set 456 /* There is no widget left, so set
459 * _curWidget to 0 457 * _curWidget to 0
460 */ 458 */
461 resetCurWidget(); 459 resetCurWidget();
462 } 460 }
463#ifndef PWM_EMBEDDED 461#ifndef PWM_EMBEDDED
464 dcopClient()->setAcceptCalls(true); 462 dcopClient()->setAcceptCalls(true);
465 dcopClient()->resume(); 463 dcopClient()->resume();
466#endif 464#endif
467} 465}
468 466
469void PwMInit::trayIconClosed(PwMTray *tray) 467void PwMInit::trayIconClosed(PwMTray *tray)
470{ 468{
471 if (runStatus != running) 469 if (runStatus != running)
472 return; 470 return;
473 PARAM_UNUSED(tray); 471 PARAM_UNUSED(tray);
474 PWM_ASSERT(tray == _tray); 472 PWM_ASSERT(tray == _tray);
475 /* If there's no main wnd left we have to 473 /* If there's no main wnd left we have to
476 * shutdown the app (same as in mainWndClosed()) 474 * shutdown the app (same as in mainWndClosed())
477 */ 475 */
478#ifndef PWM_EMBEDDED 476#ifndef PWM_EMBEDDED
479 if (!_mainWndList.size()) 477 if (!_mainWndList.size())
480 shutdownApp(0); 478 shutdownApp(0);
481#else 479#else
482 if (!_mainWndList.count()) 480 if (!_mainWndList.count())
483 shutdownApp(0); 481 shutdownApp(0);
484#endif 482#endif
485} 483}
486 484
487void PwMInit::handleCmdLineArgs(bool initial) 485void PwMInit::handleCmdLineArgs(bool initial)
488{ 486{
489#ifndef PWM_EMBEDDED 487#ifndef PWM_EMBEDDED
490 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 488 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
491 PWM_ASSERT(args); 489 PWM_ASSERT(args);
492 int i, numArgs = args->count(); 490 int i, numArgs = args->count();
493 const char *curArg; 491 const char *curArg;
494 492
495 // read all cmdline options 493 // read all cmdline options
496 savedCmd.open_deeplocked = args->isSet("open-deeplocked"); 494 savedCmd.open_deeplocked = args->isSet("open-deeplocked");
497 savedCmd.minimized = args->isSet("minimized"); 495 savedCmd.minimized = args->isSet("minimized");
498 savedCmd.minToTray = args->isSet("mintray"); 496 savedCmd.minToTray = args->isSet("mintray");
499 savedCmd.skipSelfTest = args->isSet("skip-self-test"); 497 savedCmd.skipSelfTest = args->isSet("skip-self-test");
500 if (savedCmd.minimized && 498 if (savedCmd.minimized &&
501 savedCmd.minToTray) { 499 savedCmd.minToTray) {
502 printInfo(i18n("Commandline option \"--minimized\" and " 500 printInfo(i18n("Commandline option \"--minimized\" and "
503 "\"--mintray\" selected. These are incompatible. " 501 "\"--mintray\" selected. These are incompatible. "
504 "\"--mintray\" will be selected.").latin1()); 502 "\"--mintray\" will be selected.").latin1());
505 } 503 }
506 /* Iterate through all non-option arguments. 504 /* Iterate through all non-option arguments.
507 * Every non-option arg is a filename to open. 505 * Every non-option arg is a filename to open.
508 */ 506 */
509 for (i = 0; i < numArgs; ++i) { 507 for (i = 0; i < numArgs; ++i) {
510 curArg = args->arg(i); 508 curArg = args->arg(i);
511 PWM_ASSERT(curArg); 509 PWM_ASSERT(curArg);
512 if (savedCmd.minToTray) { 510 if (savedCmd.minToTray) {
513 PwMDoc *newDoc = createDoc(); 511 PwMDoc *newDoc = createDoc();
514 if (!newDoc->openDocUi(newDoc, 512 if (!newDoc->openDocUi(newDoc,
515 curArg, 513 curArg,
516 savedCmd.open_deeplocked)) { 514 savedCmd.open_deeplocked)) {
517 delete newDoc; 515 delete newDoc;
518 } 516 }
519 } else { 517 } else {
520 PwM *newInstance = createMainWnd(QString::null, 518 PwM *newInstance = createMainWnd(QString::null,
521 false, 519 false,
522 true, 520 true,
523 0, 521 0,
524 savedCmd.minimized); 522 savedCmd.minimized);
525 PwMDoc *newDoc = newInstance->openDoc(curArg, 523 PwMDoc *newDoc = newInstance->openDoc(curArg,
526 savedCmd.open_deeplocked); 524 savedCmd.open_deeplocked);
527 if (!newDoc) { 525 if (!newDoc) {
528 newInstance->setForceQuit(true); 526 newInstance->setForceQuit(true);
529 delete_and_null(newInstance); 527 delete_and_null(newInstance);
530 } 528 }
531 } 529 }
532 } 530 }
533 531
534 if (savedCmd.minToTray) { 532 if (savedCmd.minToTray) {
535 minimizeAllMainWnd(true); 533 minimizeAllMainWnd(true);
536 } else if (savedCmd.minimized) { 534 } else if (savedCmd.minimized) {
537 minimizeAllMainWnd(false); 535 minimizeAllMainWnd(false);
538 } 536 }
539 if (!savedCmd.skipSelfTest && initial) { 537 if (!savedCmd.skipSelfTest && initial) {
540 SelfTest::schedule(); 538 SelfTest::schedule();
541 } 539 }
542 args->clear(); 540 args->clear();
543#endif 541#endif
544} 542}
545 543
546void PwMInit::minimizeAllMainWnd(bool toTray) 544void PwMInit::minimizeAllMainWnd(bool toTray)
547{ 545{
548#ifndef PWM_EMBEDDED 546#ifndef PWM_EMBEDDED
549 if (!_mainWndList.size()) 547 if (!_mainWndList.size())
550 return; 548 return;
551#else 549#else
552 if (!_mainWndList.count()) 550 if (!_mainWndList.count())
553 return; 551 return;
554#endif 552#endif
555 const QValueList<PwM *> *ml = mainWndList(); 553 const QValueList<PwM *> *ml = mainWndList();
556#ifndef PWM_EMBEDDED 554#ifndef PWM_EMBEDDED
557 QValueList<PwM *>::const_iterator it = ml->begin(), 555 QValueList<PwM *>::const_iterator it = ml->begin(),
558 end = ml->end(); 556 end = ml->end();
559#else 557#else
560 QValueList<PwM *>::ConstIterator it = ml->begin(), 558 QValueList<PwM *>::ConstIterator it = ml->begin(),
561 end = ml->end(); 559 end = ml->end();
562#endif 560#endif
563 PwM *wnd; 561 PwM *wnd;
564 if (toTray && _tray) { 562 if (toTray && _tray) {
565 /* minimize to tray. 563 /* minimize to tray.
566 * close all mainWnd. 564 * close all mainWnd.
567 */ 565 */
568 while (it != end) { 566 while (it != end) {
569 wnd = *it; 567 wnd = *it;
570 wnd->setForceMinimizeToTray(true); 568 wnd->setForceMinimizeToTray(true);
571 wnd->close_slot(); 569 wnd->close_slot();
572 ++it; 570 ++it;
573 } 571 }
574 } else { 572 } else {
575 // normal minimize 573 // normal minimize
576 while (it != end) { 574 while (it != end) {
577 wnd = *it; 575 wnd = *it;
578 wnd->hide(); 576 wnd->hide();
579 wnd->showMinimized(); 577 wnd->showMinimized();
580 ++it; 578 ++it;
581 } 579 }
582 } 580 }
583} 581}
584 582
585#ifdef PWM_EMBEDDED 583#ifdef PWM_EMBEDDED
586 584
587#ifndef DESKTOP_VERSION 585#ifndef DESKTOP_VERSION
588 586
589PwMApplication::PwMApplication(int & argc, char ** argv) 587PwMApplication::PwMApplication(int & argc, char ** argv)
590 : QPEApplication( argc, argv ) 588 : QPEApplication( argc, argv )
591 , init (0) 589 , init (0)
592{ 590{
593 this->setKeepRunning (); 591 this->setKeepRunning ();
594} 592}
595 593
596PwMApplication::~PwMApplication() 594PwMApplication::~PwMApplication()
597{ 595{
598 delete_ifnot_null(init); 596 delete_ifnot_null(init);
599} 597}
600#else //DESKTOP_VERSION 598#else //DESKTOP_VERSION
601 599
602PwMApplication::PwMApplication(int & argc, char ** argv) 600PwMApplication::PwMApplication(int & argc, char ** argv)
603 : QApplication( argc, argv ) 601 : QApplication( argc, argv )
604 , init (0) 602 , init (0)
605{ 603{
606 setStyle( new QPlatinumStyle ()); 604 setStyle( new QPlatinumStyle ());
607 QString hdir = QDir::homeDirPath(); 605 QString hdir = QDir::homeDirPath();
608 // there is a bug when creating dirs for WIN 98 606 // there is a bug when creating dirs for WIN 98
609 // it is difficult to fix, because we have no WIN 98 runnung 607 // it is difficult to fix, because we have no WIN 98 runnung
610 // such that we try it to create the dirs at startup here 608 // such that we try it to create the dirs at startup here
611 if ( hdir == "C:\\" ) 609 if ( hdir == "C:\\" )
612 { 610 {
613 // win 98 or ME 611 // win 98 or ME
614 QDir app_dir; 612 QDir app_dir;
615 if ( !app_dir.exists("C:\\kdepim") ) 613 if ( !app_dir.exists("C:\\kdepim") )
616 app_dir.mkdir ("C:\\kdepim"); 614 app_dir.mkdir ("C:\\kdepim");
617 if ( !app_dir.exists("C:\\kdepim\\apps") ) 615 if ( !app_dir.exists("C:\\kdepim\\apps") )
618 app_dir.mkdir ("C:\\kdepim\\apps"); 616 app_dir.mkdir ("C:\\kdepim\\apps");
619 if ( !app_dir.exists("C:\\kdepim\\config") ) 617 if ( !app_dir.exists("C:\\kdepim\\config") )
620 app_dir.mkdir ("C:\\kdepim\\config"); 618 app_dir.mkdir ("C:\\kdepim\\config");
621 if ( !app_dir.exists("C:\\kdepim\\apps\\pwmanager") ) 619 if ( !app_dir.exists("C:\\kdepim\\apps\\pwmanager") )
622 app_dir.mkdir ("C:\\kdepim\\apps\\pwmanager"); 620 app_dir.mkdir ("C:\\kdepim\\apps\\pwmanager");
623 } 621 }
624} 622}
625 623
626PwMApplication::~PwMApplication() 624PwMApplication::~PwMApplication()
627{ 625{
628 delete_ifnot_null(init); 626 delete_ifnot_null(init);
629} 627}
630 628
631#endif //DESKTOP_VERSION 629#endif //DESKTOP_VERSION
632 630
633#endif //PWM_EMBEDDED 631#endif //PWM_EMBEDDED
634 632
635 633
636 634
637 635
638#ifndef PWM_EMBEDDED 636#ifndef PWM_EMBEDDED
639#include "pwminit.moc" 637#include "pwminit.moc"
640#endif 638#endif