summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/pwminit.h
Unidiff
Diffstat (limited to 'pwmanager/pwmanager/pwminit.h') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwminit.h222
1 files changed, 222 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/pwminit.h b/pwmanager/pwmanager/pwminit.h
new file mode 100644
index 0000000..bf72093
--- a/dev/null
+++ b/pwmanager/pwmanager/pwminit.h
@@ -0,0 +1,222 @@
1/***************************************************************************
2 * *
3 * copyright (C) 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 __PWMINIT_H
21#define __PWMINIT_H
22
23#include <qvaluelist.h>
24#include <qobject.h>
25#ifndef PWM_EMBEDDED
26#include <kuniqueapplication.h>
27#else //PWM_EMBEDDED
28
29#ifndef DESKTOP_VERSION
30#include <qpe/qpeapplication.h>
31#else //DESKTOP_VERSION
32#include <qapplication.h>
33#include <qplatinumstyle.h>
34#endif //DESKTOP_VERSION
35
36#include <kapplication.h>
37#endif //PWM_EMBEDDED
38
39#include "globalstuff.h"
40
41class DCOPClient;
42class KWalletEmu;
43class PwMKeyCard;
44class KApplication;
45class QWidget;
46class PwM;
47class PwMTray;
48class PwMDoc;
49class PwMInit;
50
51/** main application class */
52#ifndef PWM_EMBEDDED
53//MOC_SKIP_BEGIN
54class PwMApplication : public KUniqueApplication
55{
56public:
57 PwMApplication(bool allowStyles=true,
58 bool GUIenabled=true,
59 bool configUnique=false)
60 : KUniqueApplication(allowStyles, GUIenabled, configUnique)
61 , init (0)
62 { }
63 ~PwMApplication()
64 { delete_ifnot_null(init); }
65
66 int newInstance();
67
68protected:
69 PwMInit *init;
70};
71//MOC_SKIP_END
72#else //PWM_EMBEDDED
73
74#ifndef DESKTOP_VERSION
75class PwMApplication : public QPEApplication
76{
77public:
78 PwMApplication(int & argc, char ** argv);
79 ~PwMApplication();
80
81 int newInstance();
82
83protected:
84 PwMInit *init;
85};
86#else //DESKTOP_VERSION
87
88class PwMApplication : public QApplication
89{
90public:
91 PwMApplication(int & argc, char ** argv);
92 ~PwMApplication();
93
94 int newInstance();
95
96protected:
97 PwMInit *init;
98};
99
100#endif
101#endif
102
103/** PwManager initialisation class.
104 * This class sets up a new instance of PwManager and finally
105 * starts the user interface.
106 */
107class PwMInit : public QObject
108{
109 Q_OBJECT
110 friend class PwMApplication;
111
112protected:
113 enum RunStatus
114 {
115 unknown,
116 init,
117 running,
118 shutdown,
119 };
120
121 /* saved command line options. */
122 class savedCmd_t
123 {
124 public:
125 bool open_deeplocked;
126 bool minimized;
127 bool minToTray;
128 bool skipSelfTest;
129 // initial open paths are not saved here.
130 };
131
132public:
133 PwMInit(PwMApplication *_app);
134 ~PwMInit();
135
136 /** Initialize the application. */
137 void initializeApp();
138 /** shutdown PwManager */
139 void shutdownApp(int exitStatus);
140
141 /** returns a pointer to the current widget */
142 QWidget * curWidget()
143 { return _curWidget; }
144 /** returns a pointer to the dcop client */
145 DCOPClient * dcopClient()
146 { return _dcopClient; }
147 /** returns a pointer to the KWallet emulation */
148 KWalletEmu * kwalletEmu()
149 { return _kwalletEmu; }
150 /** returns a pointer to the keycard interface */
151 PwMKeyCard * keycard()
152 { return _keycard; }
153 /** returns a pointer to the tray icon */
154 PwMTray * tray()
155 { return _tray; }
156 /** returns a list of all open main windows */
157 const QValueList<PwM *> * mainWndList()
158 { return &_mainWndList; }
159 /** create a new document */
160 PwMDoc * createDoc();
161 /** create a new PwM main window */
162 PwM * createMainWnd(const QString &loadFile = QString::null,
163 bool loadFileDeepLocked = false,
164 bool virginity = true,
165 PwMDoc *doc = 0,
166 bool minimized = false);
167
168 /** (re)initialize the KWallet emulation */
169 void initKWalletEmu(bool forceDisable = false, bool forceReload = false);
170 /** (re)initialize the tray icon */
171 void initTray();
172
173protected:
174 /** initialize the DCOP connection */
175 void initDCOP();
176 /** initialize the keycard interface */
177 void initKeycard();
178 /** initialize posix signal handling */
179 void initPosixSignalHandler();
180 /** handle the commandline args */
181 void handleCmdLineArgs(bool initial = true);
182 /** minimize all open mainWnds to tray (or if
183 * no tray is present, minimize them the normal way)
184 */
185 void minimizeAllMainWnd(bool toTray);
186
187protected slots:
188 /** a main window got closed */
189 void mainWndClosed(PwM *wnd);
190 /** the tray icon got closed */
191 void trayIconClosed(PwMTray *tray);
192 /** sets _curWidget on behalf of a PwM signal */
193 void setCurWidget(PwM *w)
194 { _curWidget = reinterpret_cast<QWidget *>(w); }
195 /** resets _curWidget to nothing */
196 void resetCurWidget()
197 { _curWidget = 0; }
198 /** remove the tray and quit the app */
199 void removeTrayAndQuit();
200
201protected:
202 /** run-status of the app */
203 RunStatus runStatus;
204 /** PwMApplication pointer */
205 PwMApplication *app;
206 /** pointer to the current widget the user is dealing with */
207 QWidget *_curWidget;
208 /** pointer to the dcop client */
209 DCOPClient *_dcopClient;
210 /** pointer to the KWallet emulation */
211 KWalletEmu *_kwalletEmu;
212 /** pointer to the keycard interface */
213 PwMKeyCard *_keycard;
214 /** pointer to the tray icon */
215 PwMTray *_tray;
216 /** list of all open main windows */
217 QValueList<PwM *> _mainWndList;
218 /** saved command line options. */
219 savedCmd_t savedCmd;
220};
221
222#endif // __PWMINIT_H