not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kdm / kfrontend / kgverify.h
blob4c4c1b078d0f86e0e18d5f17cd77c7d0992451e6
1 /*
3 Shell for kdm conversation plugins
5 Copyright (C) 1997, 1998 Steffen Hansen <hansen@kde.org>
6 Copyright (C) 2000-2004 Oswald Buddenhagen <ossi@kde.org>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #ifndef KGVERIFY_H
27 #define KGVERIFY_H
29 #include "kgreeterplugin.h"
30 #include "kfdialog.h"
32 #include <QGridLayout>
33 #include <QSet>
34 #include <QTimer>
36 #include <sys/time.h>
37 #include <time.h>
39 class KdmThemer;
41 class KLibrary;
42 class KPushButton;
43 class QMenu;
45 // helper class, nuke when qt supports suspend()/resume()
46 class QXTimer : public QObject {
47 Q_OBJECT
48 typedef QObject inherited;
50 public:
51 QXTimer();
52 void start( int msec );
53 void stop();
54 void suspend();
55 void resume();
57 Q_SIGNALS:
58 void timeout();
60 private Q_SLOTS:
61 void slotTimeout();
63 private:
64 QTimer timer;
65 struct timeval stv;
66 long left;
69 class KGVerifyHandler {
70 public:
71 virtual ~KGVerifyHandler(){}
72 virtual void verifyPluginChanged( int id ) = 0;
73 virtual void verifyClear();
74 virtual void verifyOk() = 0;
75 virtual void verifyFailed() = 0;
76 virtual void verifyRetry() = 0;
77 virtual void verifySetUser( const QString &user ) = 0;
78 virtual void updateStatus( bool fail, bool caps, int left ); // for themed only
81 struct GreeterPluginHandle {
82 KLibrary *library;
83 KGreeterPluginInfo *info;
84 QAction *action;
87 typedef QVector<int> PluginList;
89 class KGVerify : public QObject, public KGreeterPluginHandler {
90 Q_OBJECT
91 typedef QObject inherited;
93 public:
94 KGVerify( KGVerifyHandler *handler,
95 QWidget *parent, QWidget *predecessor,
96 const QString &fixedEntity, const PluginList &pluginList,
97 KGreeterPlugin::Function func, KGreeterPlugin::Context ctx );
98 virtual ~KGVerify();
99 QMenu *getPlugMenu();
100 void loadUsers( const QStringList &users );
101 void presetEntity( const QString &entity, int field );
102 QString getEntity() const;
103 void setUser( const QString &user );
104 virtual void selectPlugin( int id );
105 bool entitiesLocal() const;
106 bool entitiesFielded() const;
107 bool entityPresettable() const;
108 bool isClassic() const;
109 QString pluginName() const;
110 void setEnabled( bool on );
111 void abort();
112 void suspend();
113 void resume();
114 void accept();
115 void reject();
117 int coreLock;
119 static bool handleFailVerify( QWidget *parent, bool showUser );
120 static PluginList init( const QStringList &plugins );
121 static void done();
123 public Q_SLOTS:
124 void start();
126 protected:
127 bool eventFilter( QObject *, QEvent * );
128 void msgBox( QMessageBox::Icon typ, const QString &msg );
129 void setTimer();
130 void updateLockStatus();
131 virtual void updateStatus() = 0;
132 void handleVerify();
134 QXTimer timer;
135 QString fixedEntity, presEnt, curUser;
136 PluginList pluginList;
137 KGVerifyHandler *handler;
138 QWidget *parent, *predecessor;
139 KGreeterPlugin *greet;
140 QMenu *plugMenu;
141 int curPlugin, presFld, timedLeft, deadTicks;
142 QByteArray pName;
143 KGreeterPlugin::Function func;
144 KGreeterPlugin::Context ctx;
145 bool capsLocked;
146 bool enabled, running, suspended, failed, delayed, cont;
147 bool authTok, isClear, timeable;
149 static void vrfMsgBox( QWidget *parent, const QString &user, QMessageBox::Icon type, const QString &mesg );
150 static void vrfErrBox( QWidget *parent, const QString &user, const char *msg );
151 static void vrfInfoBox( QWidget *parent, const QString &user, const char *msg );
153 static QVector<GreeterPluginHandle> greetPlugins;
155 private:
156 bool applyPreset();
157 void performAutoLogin();
158 bool scheduleAutoLogin( bool initial );
159 void doReject( bool initial );
161 private Q_SLOTS:
162 void slotPluginSelected( QAction * );
163 void slotTimeout();
164 void slotActivity();
166 public: // from KGreetPluginHandler
167 virtual void gplugReturnText( const char *text, int tag );
168 virtual void gplugReturnBinary( const char *data );
169 virtual void gplugSetUser( const QString &user );
170 virtual void gplugStart();
171 virtual void gplugChanged();
172 virtual void gplugActivity();
173 virtual void gplugMsgBox( QMessageBox::Icon type, const QString &text );
175 static QVariant getConf( void *ctx, const char *key, const QVariant &dflt );
178 class KGStdVerify : public KGVerify {
179 Q_OBJECT
180 typedef KGVerify inherited;
182 public:
183 KGStdVerify( KGVerifyHandler *handler, QWidget *parent,
184 QWidget *predecessor, const QString &fixedEntity,
185 const PluginList &pluginList,
186 KGreeterPlugin::Function func, KGreeterPlugin::Context ctx );
187 virtual ~KGStdVerify();
188 QLayout *getLayout() const { return grid; }
189 void selectPlugin( int id );
191 protected:
192 void updateStatus();
194 private:
195 QGridLayout *grid;
196 QLabel *failedLabel;
197 int failedLabelState;
199 public: // from KGreetPluginHandler
200 virtual bool gplugHasNode( const QString &id );
203 class KGThemedVerify : public KGVerify {
204 Q_OBJECT
205 typedef KGVerify inherited;
207 public:
208 KGThemedVerify( KGVerifyHandler *handler, KdmThemer *themer,
209 QWidget *parent, QWidget *predecessor,
210 const QString &fixedEntity,
211 const PluginList &pluginList,
212 KGreeterPlugin::Function func,
213 KGreeterPlugin::Context ctx );
214 virtual ~KGThemedVerify();
215 void selectPlugin( int id );
217 protected:
218 void updateStatus();
220 private:
221 KdmThemer *themer;
222 QSet<QString> showTypes;
224 public: // from KGreetPluginHandler
225 virtual bool gplugHasNode( const QString &id );
228 class KGChTok : public FDialog, public KGVerifyHandler {
229 Q_OBJECT
230 typedef FDialog inherited;
232 public:
233 KGChTok( QWidget *parent, const QString &user,
234 const PluginList &pluginList, int curPlugin,
235 KGreeterPlugin::Function func, KGreeterPlugin::Context ctx );
236 ~KGChTok();
238 public Q_SLOTS:
239 void accept();
241 private:
242 KPushButton *okButton, *cancelButton;
243 KGStdVerify *verify;
245 public: // from KGVerifyHandler
246 virtual void verifyPluginChanged( int id );
247 virtual void verifyOk();
248 virtual void verifyFailed();
249 virtual void verifyRetry();
250 virtual void verifySetUser( const QString &user );
253 #endif /* KGVERIFY_H */