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