diff options
Diffstat (limited to 'kdesktop/lock')
-rw-r--r-- | kdesktop/lock/CMakeLists.txt | 2 | ||||
-rw-r--r-- | kdesktop/lock/lockdlg.cc | 7 | ||||
-rw-r--r-- | kdesktop/lock/lockprocess.cc | 12 | ||||
-rw-r--r-- | kdesktop/lock/main.cc | 4 | ||||
-rw-r--r-- | kdesktop/lock/sakdlg.cc | 171 | ||||
-rw-r--r-- | kdesktop/lock/sakdlg.h | 63 |
6 files changed, 254 insertions, 5 deletions
diff --git a/kdesktop/lock/CMakeLists.txt b/kdesktop/lock/CMakeLists.txt index c3e64b55a..216c9ae9f 100644 --- a/kdesktop/lock/CMakeLists.txt +++ b/kdesktop/lock/CMakeLists.txt @@ -29,7 +29,7 @@ link_directories( set( target kdesktop_lock ) set( ${target}_SRCS - lockprocess.cc lockdlg.cc infodlg.cc querydlg.cc + lockprocess.cc lockdlg.cc infodlg.cc querydlg.cc sakdlg.cc autologout.cc main.cc ) diff --git a/kdesktop/lock/lockdlg.cc b/kdesktop/lock/lockdlg.cc index 95d5ab00a..8059a28c7 100644 --- a/kdesktop/lock/lockdlg.cc +++ b/kdesktop/lock/lockdlg.cc @@ -65,6 +65,7 @@ extern bool trinity_desktop_lock_autohide_lockdlg; extern bool trinity_desktop_lock_delay_screensaver_start; extern bool trinity_desktop_lock_use_system_modal_dialogs; +extern bool trinity_desktop_lock_use_sak; int dialogHideTimeout = 10*1000; @@ -114,7 +115,7 @@ PasswordDlg::PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin) mNewSessButton = new KPushButton( KGuiItem(i18n("Sw&itch User..."), "fork"), frame ); ok = new KPushButton( i18n("Unl&ock"), frame ); cancel = new KPushButton( KStdGuiItem::cancel(), frame ); - if (!trinity_desktop_lock_autohide_lockdlg) cancel->setEnabled(false); + if (!trinity_desktop_lock_autohide_lockdlg && !trinity_desktop_lock_use_sak) cancel->setEnabled(false); greet = plugin->info->create( this, 0, this, mLayoutButton, TQString::null, KGreeterPlugin::Authenticate, KGreeterPlugin::ExUnlock ); @@ -188,7 +189,7 @@ PasswordDlg::~PasswordDlg() void PasswordDlg::reject() { - if (trinity_desktop_lock_autohide_lockdlg) + if (trinity_desktop_lock_autohide_lockdlg || trinity_desktop_lock_use_sak) TQDialog::reject(); } @@ -253,7 +254,7 @@ void PasswordDlg::timerEvent(TQTimerEvent *ev) mUnlockingFailed = false; updateLabel(); ok->setEnabled(true); - if (trinity_desktop_lock_autohide_lockdlg) cancel->setEnabled(true); + if (trinity_desktop_lock_autohide_lockdlg || trinity_desktop_lock_use_sak) cancel->setEnabled(true); mNewSessButton->setEnabled( true ); greet->revive(); greet->start(); diff --git a/kdesktop/lock/lockprocess.cc b/kdesktop/lock/lockprocess.cc index 47ff886f3..206dc9718 100644 --- a/kdesktop/lock/lockprocess.cc +++ b/kdesktop/lock/lockprocess.cc @@ -4,6 +4,7 @@ // // Copyright (c) 1999 Martin R. Jones <mjones@kde.org> // Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org> +// Copyright (c) 2010-2011 Timothy Pearson <kb9vqf@pearsoncomputing.net> // //kdesktop keeps running and checks user inactivity @@ -21,6 +22,7 @@ #include "lockdlg.h" #include "infodlg.h" #include "querydlg.h" +#include "sakdlg.h" #include "autologout.h" #include "kdesktopsettings.h" @@ -128,6 +130,7 @@ static void segv_handler(int) extern Atom qt_wm_state; extern bool trinity_desktop_lock_use_system_modal_dialogs; extern bool trinity_desktop_lock_delay_screensaver_start; +extern bool trinity_desktop_lock_use_sak; extern bool trinity_desktop_lock_forced; bool trinity_desktop_lock_autohide_lockdlg = TRUE; @@ -1359,6 +1362,9 @@ void LockProcess::suspend() void LockProcess::resume( bool force ) { + if (trinity_desktop_lock_use_sak && mHackDelayStartupTimer->isActive()) { + return; + } if( !force && (!mDialogs.isEmpty() || !mVisibility )) { // no resuming with dialog visible or when not visible if (backingPixmap.isNull()) @@ -1392,6 +1398,12 @@ bool LockProcess::checkPass() if (mAutoLogout) killTimer(mAutoLogoutTimerId); + if (trinity_desktop_lock_use_sak) { + // Wait for SAK press before continuing... + SAKDlg inDlg( this ); + int ret = execDialog( &inDlg ); + } + showVkbd(); PasswordDlg passDlg( this, &greetPlugin); int ret = execDialog( &passDlg ); diff --git a/kdesktop/lock/main.cc b/kdesktop/lock/main.cc index 90883f61e..587ad49db 100644 --- a/kdesktop/lock/main.cc +++ b/kdesktop/lock/main.cc @@ -34,9 +34,10 @@ #include <X11/Xlib.h> #include <fixx11h.h> -// [FIXME] Add GUI configuration checkboxes for these two settings (see kdesktoprc [ScreenSaver] UseUnmanagedLockWindows and DelaySaverStart) +// [FIXME] Add GUI configuration checkboxes for these three settings (see kdesktoprc [ScreenSaver] UseUnmanagedLockWindows, DelaySaverStart, and UseTDESAK) bool trinity_desktop_lock_use_system_modal_dialogs = FALSE; bool trinity_desktop_lock_delay_screensaver_start = FALSE; +bool trinity_desktop_lock_use_sak = FALSE; bool trinity_desktop_lock_forced = FALSE; @@ -153,6 +154,7 @@ int main( int argc, char **argv ) trinity_desktop_lock_use_system_modal_dialogs = !KDesktopSettings::useUnmanagedLockWindows(); trinity_desktop_lock_delay_screensaver_start = KDesktopSettings::delaySaverStart(); + trinity_desktop_lock_use_sak = KDesktopSettings::useTDESAK(); LockProcess process(child, args->isSet( "blank" )); if (!child) diff --git a/kdesktop/lock/sakdlg.cc b/kdesktop/lock/sakdlg.cc new file mode 100644 index 000000000..719f2122f --- /dev/null +++ b/kdesktop/lock/sakdlg.cc @@ -0,0 +1,171 @@ +//=========================================================================== +// +// This file is part of the KDE project +// +// Copyright (c) 2010-2011 Timothy Pearson <kb9vqf@pearsoncomputing.net> + +#include <config.h> + +#include "sakdlg.h" + +#include <dmctl.h> + +#include <kapplication.h> +#include <klocale.h> +#include <kpushbutton.h> +#include <kseparator.h> +#include <kstandarddirs.h> +#include <kglobalsettings.h> +#include <kconfig.h> +#include <kiconloader.h> +#include <kdesu/defaults.h> +#include <kpassdlg.h> +#include <kdebug.h> +#include <kuser.h> +#include <dcopref.h> +#include <kmessagebox.h> + +#include <tqlayout.h> +#include <tqpushbutton.h> +#include <tqmessagebox.h> +#include <tqsimplerichtext.h> +#include <tqlabel.h> +#include <tqstringlist.h> +#include <tqfontmetrics.h> +#include <tqstyle.h> +#include <tqapplication.h> +#include <tqlistview.h> +#include <tqheader.h> +#include <tqcheckbox.h> + +#include <ctype.h> +#include <unistd.h> +#include <stdlib.h> +#include <errno.h> +#include <pwd.h> +#include <sys/types.h> +#include <sys/socket.h> + +#include <X11/Xutil.h> +#include <X11/keysym.h> +#include <X11/Xatom.h> +#include <fixx11h.h> + +#ifndef AF_LOCAL +# define AF_LOCAL AF_UNIX +#endif + +extern bool trinity_desktop_lock_use_system_modal_dialogs; +extern bool trinity_desktop_lock_use_sak; + +//=========================================================================== +// +// Simple dialog for displaying an unlock status or recurring error message +// +SAKDlg::SAKDlg(LockProcess *parent) + : TQDialog(parent, "information dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))), + mUnlockingFailed(false) +{ + if (trinity_desktop_lock_use_system_modal_dialogs) { + // Signal that we do not want any window controls to be shown at all + Atom kde_wm_system_modal_notification; + kde_wm_system_modal_notification = XInternAtom(qt_xdisplay(), "_KDE_WM_MODAL_SYS_NOTIFICATION", False); + XChangeProperty(qt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); + } + setCaption(i18n("Desktop Session Locked")); + + frame = new TQFrame( this ); + if (trinity_desktop_lock_use_system_modal_dialogs) + frame->setFrameStyle( TQFrame::NoFrame ); + else + frame->setFrameStyle( TQFrame::Panel | TQFrame::Raised ); + frame->setLineWidth( 2 ); + + mpixLabel = new TQLabel( frame, "pixlabel" ); + mpixLabel->setPixmap(DesktopIcon("unlock")); + + KUser user; + + mStatusLabel = new TQLabel( "<b> </b>", frame ); + mStatusLabel->tqsetAlignment( TQLabel::AlignCenter ); + + TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); + unlockDialogLayout->addWidget( frame ); + + TQHBoxLayout *layStatus = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); + layStatus->addWidget( mStatusLabel ); + + frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); + frameLayout->addMultiCellWidget( mpixLabel, 0, 2, 0, 0, Qt::AlignTop ); + frameLayout->addLayout( layStatus, 1, 1 ); + + setKDEIcon(); + mStatusLabel->setText("<b>" + i18n("Press Ctrl+Alt+Del to begin.") + "</b>"); + + installEventFilter(this); + + mSAKProcess = new KProcess; + *mSAKProcess << "kdmtsak"; + connect(mSAKProcess, TQT_SIGNAL(processExited(KProcess*)), this, TQT_SLOT(slotSAKProcessExited())); + mSAKProcess->start(); +} + +void SAKDlg::slotSAKProcessExited() +{ + int retcode = mSAKProcess->exitStatus(); + if (retcode != 0) trinity_desktop_lock_use_sak = false; + hide(); +} + +SAKDlg::~SAKDlg() +{ + if ((mSAKProcess) && (mSAKProcess->isRunning())) { + mSAKProcess->kill(SIGTERM); + delete mSAKProcess; + } + hide(); +} + +void SAKDlg::reject() +{ + +} + +void SAKDlg::updateLabel(TQString &txt) +{ + mStatusLabel->setPaletteForegroundColor(Qt::black); + mStatusLabel->setText("<b>" + txt + "</b>"); +} + +void SAKDlg::setUnlockIcon() +{ + mpixLabel->setPixmap(DesktopIcon("unlock")); +} + +void SAKDlg::setKDEIcon() +{ + mpixLabel->setPixmap(DesktopIcon("about_kde")); +} + +void SAKDlg::setInfoIcon() +{ + mpixLabel->setPixmap(DesktopIcon("messagebox_info")); +} + +void SAKDlg::setWarningIcon() +{ + mpixLabel->setPixmap(DesktopIcon("messagebox_warning")); +} + +void SAKDlg::setErrorIcon() +{ + mpixLabel->setPixmap(DesktopIcon("messagebox_critical")); +} + +void SAKDlg::show() +{ + TQDialog::show(); + TQApplication::flushX(); +} + +#include "sakdlg.moc" diff --git a/kdesktop/lock/sakdlg.h b/kdesktop/lock/sakdlg.h new file mode 100644 index 000000000..a9a3c31a0 --- /dev/null +++ b/kdesktop/lock/sakdlg.h @@ -0,0 +1,63 @@ +//=========================================================================== +// +// This file is part of the KDE project +// +// Copyright (c) 2010 Timothy Pearson <kb9vqf@pearsoncomputing.net> +// + +#ifndef __SAKDLG_H__ +#define __SAKDLG_H__ + +#include <tqdialog.h> +#include <tqstringlist.h> + +#include "lockprocess.h" + +class TQFrame; +class TQGridLayout; +class TQLabel; +class KPushButton; +class TQListView; + +//=========================================================================== +// +// Simple dialog for displaying an info message. +// It does not handle password validation. +// +class SAKDlg : public TQDialog +{ + Q_OBJECT + +public: + SAKDlg(LockProcess *parent); + ~SAKDlg(); + virtual void show(); + + void updateLabel( TQString &txt ); + void setUnlockIcon(); + void setKDEIcon(); + void setInfoIcon(); + void setWarningIcon(); + void setErrorIcon(); + +private slots: + void slotSAKProcessExited(); + +protected slots: + virtual void reject(); + +private: + TQFrame *frame; + TQGridLayout *frameLayout; + TQLabel *mStatusLabel; + TQLabel *mpixLabel; + int mCapsLocked; + bool mUnlockingFailed; + TQStringList layoutsList; + TQStringList::iterator currLayout; + int sPid, sFd; + KProcess* mSAKProcess; +}; + +#endif + |