summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/main.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/pwmanager/pwmanager/main.cpp b/pwmanager/pwmanager/main.cpp
index acb0011..a39d983 100644
--- a/pwmanager/pwmanager/main.cpp
+++ b/pwmanager/pwmanager/main.cpp
@@ -1,224 +1,229 @@
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"
33void dumpMissing(); 33void dumpMissing();
34 34
35 #define LICENSE_FILE(::locate("data", "pwmanager/pwmanager_license_text")) 35 #define LICENSE_FILE(::locate("data", "pwmanager/pwmanager_license_text"))
36 36
37int PwMApplication::newInstance() 37int PwMApplication::newInstance()
38{ 38{
39 static bool initial = true; 39 static bool initial = true;
40 if (initial) { 40 if (initial) {
41 initial = false; 41 initial = false;
42 init = new PwMInit(this); 42 init = new PwMInit(this);
43 init->initializeApp(); 43 init->initializeApp();
44 } else { 44 } else {
45 BUG_ON(!init); 45 BUG_ON(!init);
46 printInfo("passing parameters to old instance."); 46 printInfo("passing parameters to old instance.");
47 init->handleCmdLineArgs(false); 47 init->handleCmdLineArgs(false);
48 } 48 }
49 return EXIT_SUCCESS; 49 return EXIT_SUCCESS;
50} 50}
51 51
52 52
53static const char *description = I18N_NOOP("PwManager\n" 53static const char *description = I18N_NOOP("PwManager\n"
54 "The convenient way of managing passwords"); 54 "The convenient way of managing passwords");
55 55
56#ifndef PWM_EMBEDDED 56#ifndef PWM_EMBEDDED
57static KCmdLineOptions options[] = 57static KCmdLineOptions options[] =
58{ 58{
59 { "minimized", I18N_NOOP("Windows minimized"), 0 }, 59 { "minimized", I18N_NOOP("Windows minimized"), 0 },
60 { "mintray", I18N_NOOP("Windows minimized to tray"),0 }, 60 { "mintray", I18N_NOOP("Windows minimized to tray"),0 },
61 { "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"),0 }, 61 { "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"),0 },
62 { "skip-self-test", I18N_NOOP("Don't run a self-test on startup"),0 }, 62 { "skip-self-test", I18N_NOOP("Don't run a self-test on startup"),0 },
63 { "+[files...]", I18N_NOOP("Files to open on startup"), 0 }, 63 { "+[files...]", I18N_NOOP("Files to open on startup"), 0 },
64 { 0, 0, 0 } 64 { 0, 0, 0 }
65}; 65};
66#endif 66#endif
67 67
68#ifdef PWM_DEBUG 68#ifdef PWM_DEBUG
69static void printDebugConfigureInfo() 69static void printDebugConfigureInfo()
70{ 70{
71 cout << "================================" << endl; 71 cout << "================================" << endl;
72 cout << PROG_NAME " version " PACKAGE_VER << endl; 72 cout << PROG_NAME " version " PACKAGE_VER << endl;
73#ifdef CONFIG_KEYCARD 73#ifdef CONFIG_KEYCARD
74 cout << "CONFIG_KEYCARD: enabled" << endl; 74 cout << "CONFIG_KEYCARD: enabled" << endl;
75#else 75#else
76 cout << "CONFIG_KEYCARD: disabled" << endl; 76 cout << "CONFIG_KEYCARD: disabled" << endl;
77#endif 77#endif
78#ifdef CONFIG_KWALLETIF 78#ifdef CONFIG_KWALLETIF
79 cout << "CONFIG_KWALLETIF: enabled" << endl; 79 cout << "CONFIG_KWALLETIF: enabled" << endl;
80#else 80#else
81 cout << "CONFIG_KWALLETIF: disabled" << endl; 81 cout << "CONFIG_KWALLETIF: disabled" << endl;
82#endif 82#endif
83#ifdef BIG_ENDIAN_HOST 83#ifdef BIG_ENDIAN_HOST
84 cout << "Endianess: big-endian" << endl; 84 cout << "Endianess: big-endian" << endl;
85#else 85#else
86 cout << "Endianess: little-endian" << endl; 86 cout << "Endianess: little-endian" << endl;
87#endif 87#endif
88#ifdef WORDS_BIGENDIAN 88#ifdef WORDS_BIGENDIAN
89 cout << "Endianess 2: big-endian" << endl; 89 cout << "Endianess 2: big-endian" << endl;
90#else 90#else
91 cout << "Endianess 2: little-endian" << endl; 91 cout << "Endianess 2: little-endian" << endl;
92#endif 92#endif
93 93
94 cout << "sizeof(long): " << sizeof(long) << endl; 94 cout << "sizeof(long): " << sizeof(long) << endl;
95 cout << "================================" << endl; 95 cout << "================================" << endl;
96} 96}
97#else // PWM_DEBUG 97#else // PWM_DEBUG
98static inline void printDebugConfigureInfo() { /* nothing */ } 98static inline void printDebugConfigureInfo() { /* nothing */ }
99#endif // PWM_DEBUG 99#endif // PWM_DEBUG
100 100
101#ifndef PWM_EMBEDDED 101#ifndef PWM_EMBEDDED
102static void addAuthors(KAboutData *aboutData) 102static void addAuthors(KAboutData *aboutData)
103{ 103{
104 aboutData->addAuthor("Michael Buesch", 104 aboutData->addAuthor("Michael Buesch",
105 I18N_NOOP( 105 I18N_NOOP(
106 "main programming and current maintainer"), 106 "main programming and current maintainer"),
107 "mbuesch@freenet.de"); 107 "mbuesch@freenet.de");
108 aboutData->addAuthor("Matt Scifo", 108 aboutData->addAuthor("Matt Scifo",
109 I18N_NOOP( 109 I18N_NOOP(
110 "original implementaion of \n" 110 "original implementaion of \n"
111 "\"categories\" and the password-tree \n" 111 "\"categories\" and the password-tree \n"
112 "in the system-tray. Original implementations of \n" 112 "in the system-tray. Original implementations of \n"
113 "numerous view-improvements."), 113 "numerous view-improvements."),
114 "mscifo@o1.com"); 114 "mscifo@o1.com");
115 aboutData->addCredit("Elias Probst", 115 aboutData->addCredit("Elias Probst",
116 I18N_NOOP( 116 I18N_NOOP(
117 "Gentoo ebuild maintainer."), 117 "Gentoo ebuild maintainer."),
118 "elias.probst@gmx.de"); 118 "elias.probst@gmx.de");
119 aboutData->addCredit("George Staikos", 119 aboutData->addCredit("George Staikos",
120 I18N_NOOP("KWallet"), 120 I18N_NOOP("KWallet"),
121 "staikos@kde.org"); 121 "staikos@kde.org");
122 aboutData->addCredit("Matthew Palmer", 122 aboutData->addCredit("Matthew Palmer",
123 I18N_NOOP("rc2 code"), 123 I18N_NOOP("rc2 code"),
124 "mjp16@uow.edu.au"); 124 "mjp16@uow.edu.au");
125 aboutData->addCredit("Olivier Sessink", 125 aboutData->addCredit("Olivier Sessink",
126 I18N_NOOP("gpasman"), 126 I18N_NOOP("gpasman"),
127 "gpasman@nl.linux.org"); 127 "gpasman@nl.linux.org");
128 aboutData->addCredit("The libgcrypt developers", 128 aboutData->addCredit("The libgcrypt developers",
129 I18N_NOOP("Blowfish and SHA1 algorithms"), 129 I18N_NOOP("Blowfish and SHA1 algorithms"),
130 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/"); 130 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/");
131 aboutData->addCredit("Troy Engel", 131 aboutData->addCredit("Troy Engel",
132 I18N_NOOP("kpasman"), 132 I18N_NOOP("kpasman"),
133 "tengel@sonic.net"); 133 "tengel@sonic.net");
134 aboutData->addCredit("Wickey", 134 aboutData->addCredit("Wickey",
135 I18N_NOOP("graphics-design in older versions."), 135 I18N_NOOP("graphics-design in older versions."),
136 "wickey@gmx.at"); 136 "wickey@gmx.at");
137 aboutData->addCredit("Ian MacGregor", 137 aboutData->addCredit("Ian MacGregor",
138 I18N_NOOP( 138 I18N_NOOP(
139 "original documentation author.")); 139 "original documentation author."));
140} 140}
141#endif 141#endif
142 142
143int main(int argc, char *argv[]) 143int main(int argc, char *argv[])
144{ 144{
145 if(!getenv("KDEPIMPIDIR")) putenv("KDEPIMPIDIR=/usr/lib/kdepimpi");
145 if(!getenv("QPEDIR")) putenv("QPEDIR=/usr/lib/kdepimpi"); 146 if(!getenv("QPEDIR")) putenv("QPEDIR=/usr/lib/kdepimpi");
146 printDebugConfigureInfo(); 147 printDebugConfigureInfo();
147#ifndef PWM_EMBEDDED 148#ifndef PWM_EMBEDDED
148 KAboutData aboutData(PACKAGE_NAME, PROG_NAME, 149 KAboutData aboutData(PACKAGE_NAME, PROG_NAME,
149 PACKAGE_VER, description, KAboutData::License_File, 150 PACKAGE_VER, description, KAboutData::License_File,
150 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0, 151 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0,
151 "http://passwordmanager.sourceforge.net/", 152 "http://passwordmanager.sourceforge.net/",
152 "mbuesch@freenet.de"); 153 "mbuesch@freenet.de");
153 addAuthors(&aboutData); 154 addAuthors(&aboutData);
154 155
155 KCmdLineArgs::init(argc, argv, &aboutData); 156 KCmdLineArgs::init(argc, argv, &aboutData);
156 KCmdLineArgs::addCmdLineOptions(options); 157 KCmdLineArgs::addCmdLineOptions(options);
157 158
158 KUniqueApplication::addCmdLineOptions(); 159 KUniqueApplication::addCmdLineOptions();
159 if (!KUniqueApplication::start()) { 160 if (!KUniqueApplication::start()) {
160 printInfo("already running."); 161 printInfo("already running.");
161 return EXIT_SUCCESS; 162 return EXIT_SUCCESS;
162 } 163 }
163 PwMApplication a; 164 PwMApplication a;
164 aboutData.setLicenseTextFile(LICENSE_FILE); 165 aboutData.setLicenseTextFile(LICENSE_FILE);
165 return a.exec(); 166 return a.exec();
166#else 167#else
167 168
168 bool exitHelp = false; 169 bool exitHelp = false;
169 if ( argc > 1 ) { 170 if ( argc > 1 ) {
170 QString command = argv[1]; 171 QString command = argv[1];
171 if ( command == "-help" ){ 172 if ( command == "-help" ){
172 printf("PWM/PI command line commands:\n"); 173 printf("PWM/PI command line commands:\n");
173 printf(" no command: Start PWM/PI in usual way\n"); 174 printf(" no command: Start PWM/PI in usual way\n");
174 printf(" -help: This output\n"); 175 printf(" -help: This output\n");
175 printf(" PWM/PI is exiting now. Bye!\n"); 176 printf(" PWM/PI is exiting now. Bye!\n");
176 exitHelp = true; 177 exitHelp = true;
177 } 178 }
178 } 179 }
179 if ( ! exitHelp ) { 180 if ( ! exitHelp ) {
180 181
181 PwMApplication a(argc, argv); 182 PwMApplication a(argc, argv);
182 183
183 KGlobal::setAppName( "pwmanager" ); 184 KGlobal::setAppName( "pwmanager" );
184#ifndef DESKTOP_VERSION 185#ifndef DESKTOP_VERSION
185 //qDebug("width %d ",QApplication::desktop()->width() ); 186 //qDebug("width %d ",QApplication::desktop()->width() );
186 if ( QApplication::desktop()->width() > 320 ) 187 if ( QApplication::desktop()->width() > 320 )
187 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/"); 188 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/");
188 else 189 else
189 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/"); 190 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/");
190#else 191#else
191 QString fileName ; 192 QString fileName ;
192 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/"; 193 const char *kpd = ::getenv("KDEPIMPIDIR");
194 if(kpd)
195 fileName = QString(kpd) + "/pwmanager/icons22/";
196 else
197 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/";
193 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 198 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
194 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 199 QApplication::addLibraryPath ( qApp->applicationDirPath () );
195 200
196#endif 201#endif
197 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager"))); 202 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager")));
198 KPimGlobalPrefs::instance()->setGlobalConfig(); 203 KPimGlobalPrefs::instance()->setGlobalConfig();
199 QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont ); 204 QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont );
200 205
201 a.newInstance(); 206 a.newInstance();
202 207
203 //US KAddressBookMain m ; 208 //US KAddressBookMain m ;
204 209
205 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 210 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
206 /*US 211 /*US
207#ifndef DESKTOP_VERSION 212#ifndef DESKTOP_VERSION
208 a.showMainWidget( &m ); 213 a.showMainWidget( &m );
209#else 214#else
210 a.setMainWidget( &m ); 215 a.setMainWidget( &m );
211 m.resize (640, 480 ); 216 m.resize (640, 480 );
212 m.show(); 217 m.show();
213#endif 218#endif
214 */ 219 */
215 QObject::connect( &a, SIGNAL( lastWindowClosed()), &a, SLOT (quit())); 220 QObject::connect( &a, SIGNAL( lastWindowClosed()), &a, SLOT (quit()));
216 a.exec(); 221 a.exec();
217 dumpMissing(); 222 dumpMissing();
218 KPimGlobalPrefs::instance()->writeConfig(); 223 KPimGlobalPrefs::instance()->writeConfig();
219 } 224 }
220 qDebug("PWMPI: Bye! "); 225 qDebug("PWMPI: Bye! ");
221 226
222#endif 227#endif
223 228
224} 229}