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