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.
29 #include "kgreeterplugin.h"
32 #include <QGridLayout>
45 // helper class, nuke when qt supports suspend()/resume()
46 class QXTimer
: public QObject
{
48 typedef QObject inherited
;
52 void start( int msec
);
69 class KGVerifyHandler
{
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
{
83 KGreeterPluginInfo
*info
;
87 typedef QVector
<int> PluginList
;
89 class KGVerify
: public QObject
, public KGreeterPluginHandler
{
91 typedef QObject inherited
;
94 KGVerify( KGVerifyHandler
*handler
,
95 QWidget
*parent
, QWidget
*predecessor
,
96 const QString
&fixedEntity
, const PluginList
&pluginList
,
97 KGreeterPlugin::Function func
, KGreeterPlugin::Context ctx
);
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
);
119 static bool handleFailVerify( QWidget
*parent
, bool showUser
);
120 static PluginList
init( const QStringList
&plugins
);
127 bool eventFilter( QObject
*, QEvent
* );
128 void msgBox( QMessageBox::Icon typ
, const QString
&msg
);
130 void updateLockStatus();
131 virtual void updateStatus() = 0;
135 QString fixedEntity
, presEnt
, curUser
;
136 PluginList pluginList
;
137 KGVerifyHandler
*handler
;
138 QWidget
*parent
, *predecessor
;
139 KGreeterPlugin
*greet
;
141 int curPlugin
, presFld
, timedLeft
, deadTicks
;
143 KGreeterPlugin::Function func
;
144 KGreeterPlugin::Context ctx
;
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
;
157 void performAutoLogin();
158 bool scheduleAutoLogin( bool initial
);
159 void doReject( bool initial
);
162 void slotPluginSelected( QAction
* );
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
{
180 typedef KGVerify inherited
;
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
);
197 int failedLabelState
;
199 public: // from KGreetPluginHandler
200 virtual bool gplugHasNode( const QString
&id
);
203 class KGThemedVerify
: public KGVerify
{
205 typedef KGVerify inherited
;
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
);
222 QSet
<QString
> showTypes
;
224 public: // from KGreetPluginHandler
225 virtual bool gplugHasNode( const QString
&id
);
228 class KGChTok
: public FDialog
, public KGVerifyHandler
{
230 typedef FDialog inherited
;
233 KGChTok( QWidget
*parent
, const QString
&user
,
234 const PluginList
&pluginList
, int curPlugin
,
235 KGreeterPlugin::Function func
, KGreeterPlugin::Context ctx
);
242 KPushButton
*okButton
, *cancelButton
;
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 */