summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/main.cpp
blob: acb00114bea8890b3e5dc3fd6be8ff4e08b4c328 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/***************************************************************************
 *                                                                         *
 *   copyright (C) 2003, 2004 by Michael Buesch                            *
 *   email: mbuesch@freenet.de                                             *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License version 2        *
 *   as published by the Free Software Foundation.                         *
 *                                                                         *
 ***************************************************************************/

/***************************************************************************
 * copyright (C) 2004 by Ulf Schenk
 * This file is originaly based on version 1.0.1 of pwmanager
 * and was modified to run on embedded devices that run microkde
 *
 * $Id$
 **************************************************************************/  

#ifndef PWM_EMBEDDED
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#else
#include <qdir.h>
#include <kpimglobalprefs.h>
#endif

#include <klocale.h>
#include <kstandarddirs.h>

#include "pwmexception.h"
#include "pwminit.h"
void dumpMissing();

#define LICENSE_FILE	(::locate("data", "pwmanager/pwmanager_license_text"))

int PwMApplication::newInstance()
{
	static bool initial = true;
	if (initial) {
		initial = false;
		init = new PwMInit(this);
		init->initializeApp();
	} else {
		BUG_ON(!init);
		printInfo("passing parameters to old instance.");
		init->handleCmdLineArgs(false);
	}
	return EXIT_SUCCESS;
}


static const char *description = I18N_NOOP("PwManager\n"
					   "The convenient way of managing passwords");

#ifndef PWM_EMBEDDED
static KCmdLineOptions options[] =
{
	{ "minimized",		I18N_NOOP("Windows minimized"),		0 },
	{ "mintray",		I18N_NOOP("Windows minimized to tray"),	0 },
	{ "open-deeplocked",	I18N_NOOP("Open all \"files\" deeplocked"),	0 },
	{ "skip-self-test",	I18N_NOOP("Don't run a self-test on startup"),	0 },
	{ "+[files...]",	I18N_NOOP("Files to open on startup"),		0 },
	{ 0, 0, 0 }
};
#endif

#ifdef PWM_DEBUG
static void printDebugConfigureInfo()
{
	cout << "================================" << endl;
	cout << PROG_NAME " version " PACKAGE_VER << endl;
#ifdef CONFIG_KEYCARD
	cout << "CONFIG_KEYCARD:    enabled" << endl;
#else
	cout << "CONFIG_KEYCARD:    disabled" << endl;
#endif
#ifdef CONFIG_KWALLETIF
	cout << "CONFIG_KWALLETIF:  enabled" << endl;
#else
	cout << "CONFIG_KWALLETIF:  disabled" << endl;
#endif
#ifdef BIG_ENDIAN_HOST
	cout << "Endianess:         big-endian" << endl;
#else
	cout << "Endianess:         little-endian" << endl;
#endif
#ifdef WORDS_BIGENDIAN
	cout << "Endianess 2:         big-endian" << endl;
#else
	cout << "Endianess 2:         little-endian" << endl;
#endif

	cout << "sizeof(long):      " << sizeof(long) << endl;
	cout << "================================" << endl;
}
#else // PWM_DEBUG
static inline void printDebugConfigureInfo() { /* nothing */ }
#endif // PWM_DEBUG

#ifndef PWM_EMBEDDED
static void addAuthors(KAboutData *aboutData)
{
	aboutData->addAuthor("Michael Buesch",
			     I18N_NOOP(
			     "main programming and current maintainer"),
			     "mbuesch@freenet.de");
	aboutData->addAuthor("Matt Scifo",
			     I18N_NOOP(
			     "original implementaion of \n"
			     "\"categories\" and the password-tree \n"
			     "in the system-tray. Original implementations of \n"
			     "numerous view-improvements."),
			     "mscifo@o1.com");
	aboutData->addCredit("Elias Probst",
			     I18N_NOOP(
			     "Gentoo ebuild maintainer."),
			     "elias.probst@gmx.de");
	aboutData->addCredit("George Staikos",
			     I18N_NOOP("KWallet"),
			     "staikos@kde.org");
	aboutData->addCredit("Matthew Palmer",
			     I18N_NOOP("rc2 code"),
			     "mjp16@uow.edu.au");
        aboutData->addCredit("Olivier Sessink",
			     I18N_NOOP("gpasman"),
			     "gpasman@nl.linux.org");
	aboutData->addCredit("The libgcrypt developers",
			     I18N_NOOP("Blowfish and SHA1 algorithms"),
			     0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/");
	aboutData->addCredit("Troy Engel",
			     I18N_NOOP("kpasman"),
			     "tengel@sonic.net");
	aboutData->addCredit("Wickey",
			     I18N_NOOP("graphics-design in older versions."),
			     "wickey@gmx.at");
	aboutData->addCredit("Ian MacGregor",
			     I18N_NOOP(
			     "original documentation author."));
}
#endif

int main(int argc, char *argv[])
{
    if(!getenv("QPEDIR")) putenv("QPEDIR=/usr/lib/kdepimpi");
	printDebugConfigureInfo();
#ifndef PWM_EMBEDDED
	KAboutData aboutData(PACKAGE_NAME, PROG_NAME,
			     PACKAGE_VER, description, KAboutData::License_File,
			     "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0,
			     "http://passwordmanager.sourceforge.net/",
			     "mbuesch@freenet.de");
	addAuthors(&aboutData);

	KCmdLineArgs::init(argc, argv, &aboutData);
	KCmdLineArgs::addCmdLineOptions(options);

	KUniqueApplication::addCmdLineOptions();
	if (!KUniqueApplication::start()) {
		printInfo("already running.");
		return EXIT_SUCCESS;
	}
	PwMApplication a;
	aboutData.setLicenseTextFile(LICENSE_FILE);
	return a.exec();
#else

  bool exitHelp = false;
  if ( argc > 1 ) {
      QString command = argv[1];
      if (  command == "-help" ){
          printf("PWM/PI command line commands:\n");
          printf("  no command: Start PWM/PI in usual way\n");
          printf("  -help: This output\n");
          printf(" PWM/PI is exiting now. Bye!\n");
          exitHelp = true;
      }
  }
  if ( ! exitHelp ) {

    PwMApplication a(argc, argv);

    KGlobal::setAppName( "pwmanager" );
#ifndef DESKTOP_VERSION
    //qDebug("width %d ",QApplication::desktop()->width() );
    if ( QApplication::desktop()->width() > 320 )
      KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/");
    else
        KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/");
#else
      QString fileName ;
      fileName  = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/";
      KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
      QApplication::addLibraryPath ( qApp->applicationDirPath () );

#endif
      KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager")));
      KPimGlobalPrefs::instance()->setGlobalConfig();
      QApplication::setFont( KPimGlobalPrefs::instance()->mApplicationFont );

      a.newInstance();

      //US       KAddressBookMain m ;

      //US      QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
      /*US
#ifndef DESKTOP_VERSION
       a.showMainWidget( &m );
#else
      a.setMainWidget( &m );
      m.resize (640, 480 );
      m.show();
#endif
      */
      QObject::connect( &a, SIGNAL( lastWindowClosed()), &a, SLOT (quit()));
      a.exec();
      dumpMissing();
      KPimGlobalPrefs::instance()->writeConfig();
  }
  qDebug("PWMPI: Bye! ");

#endif

}