3
Shell for kdm conversation plugins
5
Copyright (C) 1997, 1998, 2000 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.
25
#include <config-workspace.h>
28
#include "kdmconfig.h"
29
#include "kdm_greet.h"
31
#include "themer/kdmthemer.h"
32
#include "themer/kdmitem.h"
34
#include <KColorScheme>
38
#include <kpushbutton.h>
40
#include <kseparator.h>
41
#include <KStandardGuiItem>
44
#include <QApplication>
49
#include <QSocketNotifier>
52
#include <X11/Xlib.h> // for updateLockStatus()
53
#include <fixx11h.h> // ... and make eventFilter() work again
55
#define FULL_GREET_TO 40 // normal inactivity timeout
56
#define TIMED_GREET_TO 20 // inactivity timeout when persisting timed login
57
#define MIN_TIMED_TO 5 // minimal timed login delay
58
#define DEAD_TIMED_TO 2 // <enter> dead time after re-activating timed login
59
#define SECONDS 1000 // reduce to 100 to speed up testing
61
void KGVerifyHandler::verifyClear()
65
void KGVerifyHandler::updateStatus(bool, bool, int)
69
KGVerify::KGVerify(KGVerifyHandler *_handler,
70
QWidget *_parent, QWidget *_predecessor,
71
const QString &_fixedUser,
72
const PluginList &_pluginList,
73
KGreeterPlugin::Function _func,
74
KGreeterPlugin::Context _ctx)
77
, fixedEntity(_fixedUser)
78
, pluginList(_pluginList)
81
, predecessor(_predecessor)
93
sockNot = new QSocketNotifier(rfd, QSocketNotifier::Read, this);
94
sockNot->setEnabled(false);
95
connect(sockNot, SIGNAL(activated(int)), SLOT(handleVerify()));
97
connect(&timer, SIGNAL(timeout()), SLOT(slotTimeout()));
98
connect(qApp, SIGNAL(activity()), SLOT(slotActivity()));
100
_parent->installEventFilter(this);
103
KGVerify::~KGVerify()
105
debug("delete %s\n", pName.data());
110
KGVerify::getPlugMenu()
112
// assert(coreState != CoreBusy);
114
uint np = pluginList.count();
116
plugMenu = new QMenu(parent);
117
QActionGroup *plugGroup = new QActionGroup(parent);
118
connect(plugMenu, SIGNAL(triggered(QAction *)),
119
SLOT(slotPluginSelected(QAction *)));
120
for (uint i = 0; i < np; i++) {
121
int pid = pluginList[i];
122
greetPlugins[pid].action = plugGroup->addAction(
123
i18nc("@item:inmenu authentication method",
124
greetPlugins[pid].info->name));
125
greetPlugins[pid].action->setData(i);
126
greetPlugins[pid].action->setCheckable(true);
128
plugMenu->addActions(plugGroup->actions());
135
KGVerify::entitiesLocal() const
137
return greetPlugins[pluginList[curPlugin]].info->flags & KGreeterPluginInfo::Local;
141
KGVerify::entitiesFielded() const
143
return greetPlugins[pluginList[curPlugin]].info->flags & KGreeterPluginInfo::Fielded;
147
KGVerify::entityPresettable() const
149
return greetPlugins[pluginList[curPlugin]].info->flags & KGreeterPluginInfo::Presettable;
153
KGVerify::isClassic() const
155
return !strcmp(greetPlugins[pluginList[curPlugin]].info->method, "classic");
159
KGVerify::pluginName() const
161
QString name(greetPlugins[pluginList[curPlugin]].library->fileName());
162
uint st = name.lastIndexOf('/') + 1;
163
uint en = name.indexOf('.', st);
164
if (en - st > 7 && QString::fromRawData(name.unicode() + st, 7) == QLatin1String("kgreet_"))
166
return name.mid(st, en - st);
170
setTabOrder(QWidget *&pred, const QObjectList &list)
172
foreach (QObject *o, list)
173
if (QWidget *w = qobject_cast<QWidget *>(o)) {
174
if (w->focusPolicy() & Qt::TabFocus) {
175
QWidget::setTabOrder(pred, w);
178
setTabOrder(pred, o->children());
184
KGVerify::selectPlugin(int id)
186
if (pluginList.isEmpty()) {
187
msgBox(errorbox, i18n("No greeter widget plugin loaded. Check the configuration."));
188
::exit(EX_UNMANAGE_DPY);
192
greetPlugins[pluginList[id]].action->setChecked(true);
193
pName = ("greet_" + pluginName()).toLatin1();
194
debug("new %s\n", pName.data());
195
greet = greetPlugins[pluginList[id]].info->create(this, parent, fixedEntity, func, ctx);
196
if (QWidget *pred = predecessor)
197
setTabOrder(pred, *(const QObjectList *)&greet->getWidgets());
198
timeable = _autoLoginDelay && entityPresettable() && isClassic();
202
KGVerify::slotPluginSelected(QAction *action)
206
int id = action->data().toInt();
207
if (id != curPlugin) {
208
parent->setUpdatesEnabled(false);
209
debug("delete %s\n", pName.data());
212
handler->verifyPluginChanged(id);
215
parent->setUpdatesEnabled(true);
220
KGVerify::loadUsers(const QStringList &users)
222
debug("%s->loadUsers(...)\n", pName.data());
223
greet->loadUsers(users);
227
KGVerify::presetEntity(const QString &entity, int field)
234
KGVerify::applyPreset()
236
if (!presEnt.isEmpty()) {
237
debug("%s->presetEntity(%\"s, %d)\n", pName.data(),
238
qPrintable(presEnt), presFld);
239
greet->presetEntity(presEnt, presFld);
240
if (entitiesLocal()) {
243
handler->verifySetUser(presEnt);
251
KGVerify::scheduleAutoLogin(bool initial)
254
debug("%s->presetEntity(%\"s, -1)\n", pName.data(),
255
qPrintable(_autoLoginUser), -1);
256
greet->presetEntity(_autoLoginUser, -1);
257
curUser = _autoLoginUser;
258
handler->verifySetUser(_autoLoginUser);
261
timedLeft = _autoLoginDelay;
264
timedLeft = qMax(_autoLoginDelay - TIMED_GREET_TO, MIN_TIMED_TO);
265
deadTicks = DEAD_TIMED_TO;
268
sockNot->setEnabled(false);
277
KGVerify::performAutoLogin()
280
gSendInt(G_AutoLogin);
281
coreState = CoreBusy;
282
sockNot->setEnabled(true);
286
KGVerify::getEntity() const
288
debug("%s->getEntity()\n", pName.data());
289
QString ent = greet->getEntity();
290
debug(" entity: %s\n", qPrintable(ent));
295
KGVerify::setUser(const QString &user)
297
// assert(fixedEntity.isEmpty());
299
debug("%s->setUser(%\"s)\n", pName.data(), qPrintable(user));
300
greet->setUser(user);
307
authTok = (func == KGreeterPlugin::ChAuthTok);
308
if (func == KGreeterPlugin::Authenticate && ctx == KGreeterPlugin::Login) {
309
if (scheduleAutoLogin(true)) {
310
if (!_autoLoginAgain)
311
_autoLoginDelay = 0, timeable = false;
317
timer.start(FULL_GREET_TO * SECONDS);
319
sockNot->setEnabled(true);
321
if (!(func == KGreeterPlugin::Authenticate ||
322
ctx == KGreeterPlugin::ChangeTok ||
323
ctx == KGreeterPlugin::ExChangeTok))
325
coreState = CoreBusy;
327
debug("%s->start()\n", pName.data());
334
debug("%s->abort()\n", pName.data());
336
sockNot->setEnabled(false);
343
// assert(coreState != CoreBusy);
345
debug("%s->abort()\n", pName.data());
351
sockNot->setEnabled(false);
357
sockNot->setEnabled(true);
362
debug("%s->start()\n", pName.data());
364
} else if (delayed) {
367
sockNot->setEnabled(true);
368
debug("%s->start()\n", pName.data());
373
void // not a slot - called manually by greeter
376
debug("%s->next()\n", pName.data());
381
KGVerify::doReject(bool initial)
383
// assert(coreState != CoreBusy);
385
debug("%s->abort()\n", pName.data());
388
handler->verifyClear();
389
debug("%s->clear()\n", pName.data());
393
if (!scheduleAutoLogin(initial)) {
394
isClear = !(isClear && applyPreset());
396
debug("%s->start()\n", pName.data());
404
void // not a slot - called manually by greeter
411
KGVerify::setEnabled(bool on)
413
debug("%s->setEnabled(%s)\n", pName.data(), on ? "true" : "false");
414
greet->setEnabled(on);
420
KGVerify::slotTimeout()
425
debug("%s->revive()\n", pName.data());
427
handler->verifyRetry();
432
sockNot->setEnabled(true);
433
debug("%s->start()\n", pName.data());
438
} else if (timedLeft) {
445
} else if (_isReserve) {
446
// assert(ctx == Login && running);
450
// assert(ctx == Login);
457
KGVerify::slotActivity()
460
// timed login countdown running. cancel and reschedule it.
461
debug("%s->revive()\n", pName.data());
463
debug("%s->start()\n", pName.data());
465
sockNot->setEnabled(true);
469
timer.start(TIMED_GREET_TO * SECONDS);
470
} else if (timeable) {
471
// timed login is possible and thus scheduled. reschedule it.
472
timer.start(TIMED_GREET_TO * SECONDS);
473
} else if (_isReserve) {
474
timer.start(FULL_GREET_TO * SECONDS);
479
KGVerify::talkerEdits()
481
if (func == KGreeterPlugin::Authenticate &&
482
ctx == KGreeterPlugin::Login)
486
timer.start(FULL_GREET_TO * SECONDS);
491
void // private static
492
KGVerify::vrfMsgBox(QWidget *parent, const QString &user,
493
QMessageBox::Icon type, const QString &mesg)
495
KFMsgBox::box(parent, type, user.isEmpty() ?
496
mesg : i18n("Logging in %1...\n\n", user) + mesg);
499
static const char * const msgs[] = {
500
I18N_NOOP("You are required to change your password immediately (password aged)."),
501
I18N_NOOP("You are required to change your password immediately (root enforced)."),
502
I18N_NOOP("You are not allowed to login at the moment."),
503
I18N_NOOP("Home folder not available."),
504
I18N_NOOP("Logins are not allowed at the moment.\nTry again later."),
505
I18N_NOOP("Your login shell is not listed in /etc/shells."),
506
I18N_NOOP("Root logins are not allowed."),
507
I18N_NOOP("Your account has expired; please contact your system administrator.")
510
void // private static
511
KGVerify::vrfErrBox(QWidget *parent, const QString &user, const char *msg)
513
QMessageBox::Icon icon;
517
mesg = i18n("A critical error occurred.\n"
518
"Please look at KDM's logfile(s) for more information\n"
519
"or contact your system administrator.");
522
mesg = QString::fromLocal8Bit(msg);
523
QString mesg1 = mesg + '.';
524
for (uint i = 0; i < as(msgs); i++)
525
if (mesg1 == msgs[i]) {
526
mesg = i18n(msgs[i]);
531
vrfMsgBox(parent, user, icon, mesg);
534
void // private static
535
KGVerify::vrfInfoBox(QWidget *parent, const QString &user, const char *msg)
537
QString mesg = QString::fromLocal8Bit(msg);
538
QRegExp rx("^Warning: your account will expire in (\\d+) day");
539
if (rx.indexIn(mesg) >= 0) {
540
int expire = rx.cap(1).toInt();
542
i18np("Your account expires tomorrow.",
543
"Your account expires in %1 days.", expire) :
544
i18n("Your account expires today.");
546
rx.setPattern("^Warning: your password will expire in (\\d+) day");
547
if (rx.indexIn(mesg) >= 0) {
548
int expire = rx.cap(1).toInt();
550
i18np("Your password expires tomorrow.",
551
"Your password expires in %1 days.", expire) :
552
i18n("Your password expires today.");
555
vrfMsgBox(parent, user, infobox, mesg);
558
bool // public static
559
KGVerify::handleFailVerify(QWidget *parent, bool showUser)
564
debug("handleFailVerify ...\n");
568
user = QString::fromLocal8Bit(msg);
573
int ret = gRecvInt();
575
// non-terminal status
577
/* case V_PUT_USER: cannot happen - we are in "classic" mode */
578
/* case V_PRE_OK: cannot happen - not in ChTok dialog */
579
/* case V_CHTOK: cannot happen - called by non-interactive verify */
581
debug(" V_CHTOK_AUTH\n");
583
QStringList pgs(_pluginsLogin);
584
pgs += _pluginsShutdown;
585
foreach (const QString& pg, pgs)
586
if (pg == "classic" || pg == "modern") {
587
pgs = QStringList(pg);
589
} else if (pg == "generic") {
590
pgs = QStringList("modern");
593
pgs = QStringList("classic");
595
KGChTok chtok(parent, user, init(pgs), 0,
596
KGreeterPlugin::AuthChAuthTok,
597
KGreeterPlugin::Login);
601
debug(" V_MSG_ERR\n");
603
debug(" message %\"s\n", msg);
604
vrfErrBox(parent, user, msg);
608
case V_MSG_INFO_AUTH: // should not happen
610
debug(" V_MSG_INFO\n");
612
debug(" message %\"s\n", msg);
613
vrfInfoBox(parent, user, msg);
626
vrfMsgBox(parent, user, sorrybox, i18n("Authentication failed"));
632
logPanic("Unknown V_xxx code %d from core\n", ret);
638
KGVerify::handleVerify()
640
debug("handleVerify ...\n");
643
int ret, echo, ndelay;
644
KGreeterPlugin::Function nfunc;
649
coreState = CorePrompting;
652
debug(" V_GET_TEXT\n");
654
debug(" prompt %\"s\n", msg);
656
debug(" echo = %d\n", echo);
658
debug(" ndelay = %d\n%s->textPrompt(...)\n", ndelay, pName.data());
659
greet->textPrompt(msg, echo, ndelay);
663
debug(" V_GET_BINARY\n");
664
msg = gRecvArr(&ret);
665
debug(" %d bytes prompt\n", ret);
667
debug(" ndelay = %d\n%s->binaryPrompt(...)\n", ndelay, pName.data());
668
greet->binaryPrompt(msg, ndelay);
673
// non-terminal status
674
coreState = CoreBusy;
677
debug(" V_PUT_USER\n");
679
curUser = pamUser = QString::fromLocal8Bit(msg);
680
// greet needs this to be able to return something useful from
681
// getEntity(). but the backend is still unable to tell a domain ...
682
debug(" %s->setUser(%\"s)\n", pName.data(), qPrintable(user));
683
greet->setUser(curUser);
684
handler->verifySetUser(curUser);
687
case V_PRE_OK: // this is only for func == AuthChAuthTok
688
debug(" V_PRE_OK\n");
689
// With the "classic" method, the wrong user simply cannot be
690
// authenticated, even with the generic plugin. Other methods
691
// could do so, but this applies only to ctx == ChangeTok, which
692
// is not implemented yet.
694
debug("%s->succeeded()\n", pName.data());
698
debug(" V_MSG_ERR\n");
701
debug(" %s->textMessage(%\"s, true)\n", pName.data(), msg);
702
if (!greet->textMessage(msg, true)) { // XXX little point in filtering
703
debug(" message passed\n");
704
vrfErrBox(parent, pamUser, msg);
706
debug(" message swallowed\n");
712
case V_MSG_INFO_AUTH:
713
debug(" V_MSG_INFO_AUTH\n");
716
debug(" %s->textMessage(%\"s, false)\n", pName.data(), msg);
717
if (!greet->textMessage(msg, false)) {
718
debug(" message passed\n");
719
vrfInfoBox(parent, pamUser, msg);
721
debug(" message swallowed\n");
728
debug(" V_MSG_INFO\n");
731
debug(" display %\"s\n", msg);
732
vrfInfoBox(parent, pamUser, msg);
740
coreState = CoreIdle;
742
sockNot->setEnabled(false);
745
// These codes are not really terminal as far as the core is concerned,
746
// but the branches as a whole are.
747
if (ret == V_CHTOK_AUTH) {
748
debug(" V_CHTOK_AUTH\n");
749
nfunc = KGreeterPlugin::AuthChAuthTok;
752
} else if (ret == V_CHTOK) {
754
nfunc = KGreeterPlugin::ChAuthTok;
757
debug("%s->succeeded()\n", pName.data());
759
KGChTok chtok(parent, user, pluginList, curPlugin, nfunc, KGreeterPlugin::Login);
768
if (!fixedEntity.isEmpty()) {
769
debug(" %s->getEntity()\n", pName.data());
770
QString ent = greet->getEntity();
771
debug(" entity %\"s\n", qPrintable(ent));
772
if (ent != fixedEntity) {
773
debug("%s->failed()\n", pName.data());
776
i18n("Authenticated user (%1) does not match requested user (%2).\n",
781
debug("%s->succeeded()\n", pName.data());
787
debug("%s->failed()\n", pName.data());
794
handler->verifyFailed();
795
timer.start(1500 + KRandom::random() / (RAND_MAX / 1000));
799
logPanic("Unknown V_xxx code %d from core\n", ret);
802
debug("%s->revive()\n", pName.data());
804
sockNot->setEnabled(true);
806
debug("%s->start()\n", pName.data());
813
KGVerify::gplugReturnText(const char *text, int tag)
815
debug("%s: gplugReturnText(%\"s, %d)\n", pName.data(),
816
tag & V_IS_SECRET ? "<masked>" : text, tag);
820
coreState = CoreBusy;
822
coreState = CoreIdle;
827
KGVerify::gplugReturnBinary(const char *data)
830
unsigned const char *up = (unsigned const char *)data;
831
int len = up[3] | (up[2] << 8) | (up[1] << 16) | (up[0] << 24);
832
debug("%s: gplugReturnBinary(%d bytes)\n", pName.data(), len);
834
coreState = CoreBusy;
836
debug("%s: gplugReturnBinary(NULL)\n", pName.data());
838
coreState = CoreIdle;
843
KGVerify::gplugSetUser(const QString &user)
845
debug("%s: gplugSetUser(%\"s)\n", pName.data(), qPrintable(user));
847
handler->verifySetUser(user);
851
KGVerify::gplugStart()
853
// XXX handle func != Authenticate
854
if (coreState != CoreIdle)
856
debug("%s: gplugStart()\n", pName.data());
857
gSendInt(ctx == KGreeterPlugin::Shutdown ? G_VerifyRootOK : G_Verify);
858
gSendStr(greetPlugins[pluginList[curPlugin]].info->method);
859
coreState = CoreBusy;
863
KGVerify::gplugChanged()
865
debug("%s: gplugChanged()\n", pName.data());
866
if (parent->isActiveWindow())
871
KGVerify::gplugActivity()
873
debug("%s: gplugActivity()\n", pName.data());
878
KGVerify::gplugMsgBox(QMessageBox::Icon type, const QString &text)
880
debug("%s: gplugMsgBox(%d, %\"s)\n", pName.data(), type, qPrintable(text));
885
KGVerify::eventFilter(QObject *o, QEvent *e)
888
case QEvent::KeyPress:
890
QKeyEvent *ke = (QKeyEvent *)e;
891
if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) {
892
if (deadTicks <= 0) {
900
case QEvent::KeyRelease:
906
return inherited::eventFilter(o, e);
910
KGVerify::updateLockStatus()
913
Window dummy1, dummy2;
914
int dummy3, dummy4, dummy5, dummy6;
915
XQueryPointer(QX11Info::display(), DefaultRootWindow(QX11Info::display()),
916
&dummy1, &dummy2, &dummy3, &dummy4, &dummy5, &dummy6,
918
capsLocked = lmask & LockMask;
923
KGVerify::msgBox(QMessageBox::Icon typ, const QString &msg)
926
KFMsgBox::box(parent, typ, msg);
931
QVariant // public static
932
KGVerify::getConf(void *, const char *key, const QVariant &dflt)
934
if (!qstrcmp(key, "EchoPasswd")) {
935
return QVariant(_echoPasswd);
937
QString fkey = QString::fromLatin1(key) + '=';
938
foreach (const QString& pgo, _pluginOptions)
939
if (pgo.startsWith(fkey))
940
return pgo.mid(fkey.length());
945
QVector<GreeterPluginHandle> KGVerify::greetPlugins;
948
KGVerify::init(const QStringList &plugins)
950
PluginList pluginList;
952
foreach (const QString& pg, plugins) {
953
GreeterPluginHandle plugin;
954
KLibrary *lib = new KLibrary(pg[0] == '/' ? pg : "kgreet_" + pg);
955
if (lib->fileName().isEmpty()) {
956
logError("GreeterPlugin %s does not exist\n", qPrintable(pg));
960
uint i, np = greetPlugins.count();
961
for (i = 0; i < np; i++)
962
if (greetPlugins[i].library->fileName() == lib->fileName()) {
967
logError("Cannot load GreeterPlugin %s (%s)\n",
968
qPrintable(pg), qPrintable(lib->fileName()));
972
plugin.library = lib;
973
plugin.info = (KGreeterPluginInfo *)lib->resolveSymbol("kgreeterplugin_info");
975
logError("GreeterPlugin %s (%s) is no valid greet widget plugin\n",
976
qPrintable(pg), qPrintable(lib->fileName()));
982
if (!plugin.info->init(QString(), getConf, 0)) {
983
logError("GreeterPlugin %s (%s) refuses to serve\n",
984
qPrintable(pg), qPrintable(lib->fileName()));
989
debug("GreeterPlugin %s (%s) loaded\n", qPrintable(pg), plugin.info->name);
991
greetPlugins.append(plugin);
993
pluginList.append(i);
1001
for (int i = 0; i < greetPlugins.count(); i++) {
1002
if (greetPlugins[i].info->done)
1003
greetPlugins[i].info->done();
1004
greetPlugins[i].library->unload();
1009
KGStdVerify::KGStdVerify(KGVerifyHandler *_handler, QWidget *_parent,
1010
QWidget *_predecessor, const QString &_fixedUser,
1011
const PluginList &_pluginList,
1012
KGreeterPlugin::Function _func,
1013
KGreeterPlugin::Context _ctx)
1014
: inherited(_handler, _parent, _predecessor, _fixedUser,
1015
_pluginList, _func, _ctx)
1016
, failedLabelState(0)
1018
grid = new QGridLayout;
1019
grid->setAlignment(Qt::AlignCenter);
1021
failedLabel = new QLabel(parent);
1022
failedLabel->setFont(*_failFont);
1023
grid->addWidget(failedLabel, 1, 0, Qt::AlignCenter);
1028
KGStdVerify::~KGStdVerify()
1033
KGStdVerify::gplugHasNode(const QString &)
1039
KGStdVerify::selectPlugin(int id)
1041
inherited::selectPlugin(id);
1042
QWidget *w = greet->getWidgets().first();
1043
grid->addWidget(w, 0, 0);
1048
KGStdVerify::updateStatus()
1058
else if (!suspended && capsLocked)
1063
if (failedLabelState != nfls) {
1064
failedLabelState = nfls;
1067
failedLabel->setText(i18np("Automatic login in 1 second...",
1068
"Automatic login in %1 seconds...",
1073
failedLabel->clear();
1076
p.setBrush(QPalette::WindowText,
1077
KColorScheme(QPalette::Active, KColorScheme::Window)
1078
.foreground(KColorScheme::NegativeText));
1079
failedLabel->setText(i18n("Warning: Caps Lock is on"));
1082
failedLabel->setText(authTok ?
1083
i18n("Change failed") :
1084
fixedEntity.isEmpty() ?
1085
i18n("Login failed") :
1086
i18n("Authentication failed"));
1090
failedLabel->setPalette(p);
1094
KGThemedVerify::KGThemedVerify(KGVerifyHandler *_handler,
1096
QWidget *_parent, QWidget *_predecessor,
1097
const QString &_fixedUser,
1098
const PluginList &_pluginList,
1099
KGreeterPlugin::Function _func,
1100
KGreeterPlugin::Context _ctx)
1101
: inherited(_handler, _parent, _predecessor, _fixedUser,
1102
_pluginList, _func, _ctx)
1108
KGThemedVerify::~KGThemedVerify()
1113
KGThemedVerify::gplugHasNode(const QString &id)
1115
return themer->findNode(id) != 0;
1119
KGThemedVerify::selectPlugin(int id)
1121
if (curPlugin != -1)
1122
themer->setTypeVisible(QString("plugin-specific-").append(pluginName()), false);
1123
inherited::selectPlugin(id);
1124
themer->setTypeVisible(QString("plugin-specific-").append(pluginName()), true);
1125
QSet<QString> oldTypes = showTypes;
1127
foreach (QWidget *w, greet->getWidgets())
1128
if (KdmItem *n = themer->findNode(w->objectName())) {
1129
QString tn(QString("plugin-").append(w->objectName()));
1130
themer->setTypeVisible(tn, true);
1131
showTypes.insert(tn);
1132
oldTypes.remove(tn);
1136
i18n("Theme not usable with authentication method '%1'.",
1137
i18n(greetPlugins[pluginList[id]].info->name)));
1140
foreach (const QString &t, oldTypes)
1141
themer->setTypeVisible(t, false);
1145
KGThemedVerify::updateStatus()
1147
handler->updateStatus(enabled && failed,
1148
enabled && !suspended && capsLocked,
1153
KGChTok::KGChTok(QWidget *_parent, const QString &user,
1154
const PluginList &pluginList, int curPlugin,
1155
KGreeterPlugin::Function func,
1156
KGreeterPlugin::Context ctx)
1157
: inherited(_parent)
1160
QSizePolicy fp(QSizePolicy::Fixed, QSizePolicy::Fixed);
1161
okButton = new KPushButton(KStandardGuiItem::ok(), this);
1162
okButton->setSizePolicy(fp);
1163
okButton->setDefault(true);
1164
cancelButton = new KPushButton(KStandardGuiItem::cancel(), this);
1165
cancelButton->setSizePolicy(fp);
1167
verify = new KGStdVerify(this, this, cancelButton, user, pluginList, func, ctx);
1168
verify->selectPlugin(curPlugin);
1170
QVBoxLayout *box = new QVBoxLayout(this);
1172
box->addWidget(new QLabel(i18nc("@title:window",
1173
"<qt><b>Changing authentication token</b></qt>"),
1174
this), 0, Qt::AlignHCenter | Qt::AlignTop);
1176
box->addLayout(verify->getLayout());
1178
box->addWidget(new KSeparator(Qt::Horizontal, this));
1180
QHBoxLayout *hlay = new QHBoxLayout();
1181
box->addLayout(hlay);
1182
hlay->addStretch(1);
1183
hlay->addWidget(okButton);
1184
hlay->addStretch(1);
1185
hlay->addWidget(cancelButton);
1186
hlay->addStretch(1);
1188
connect(okButton, SIGNAL(clicked()), SLOT(accept()));
1189
connect(cancelButton, SIGNAL(clicked()), SLOT(reject()));
1191
QTimer::singleShot(0, verify, SLOT(start()));
1207
KGChTok::verifyPluginChanged(int)
1215
inherited::accept();
1219
KGChTok::verifyFailed()
1221
okButton->setEnabled(false);
1222
cancelButton->setEnabled(false);
1226
KGChTok::verifyRetry()
1228
okButton->setEnabled(true);
1229
cancelButton->setEnabled(true);
1233
KGChTok::verifySetUser(const QString &)
1239
////// helper class, nuke when qtimer supports suspend()/resume()
1245
connect(&timer, SIGNAL(timeout()), SLOT(slotTimeout()));
1249
QXTimer::start(int msec)
1252
timer.setSingleShot(true);
1254
gettimeofday(&stv, 0);
1267
if (timer.isActive()) {
1270
gettimeofday(&tv, 0);
1271
left -= (tv.tv_sec - stv.tv_sec) * 1000 + (tv.tv_usec - stv.tv_usec) / 1000;
1280
if (left >= 0 && !timer.isActive()) {
1281
timer.setSingleShot(true);
1283
gettimeofday(&stv, 0);
1288
QXTimer::slotTimeout()
1295
#include "kgverify.moc"