diff options
-rw-r--r-- | kdesktop/lock/Makefile.am | 4 | ||||
-rw-r--r-- | kdesktop/lock/infodlg.cc | 15 | ||||
-rw-r--r-- | kdesktop/lock/infodlg.h | 3 | ||||
-rw-r--r-- | kdesktop/lock/lockprocess.cc | 66 | ||||
-rw-r--r-- | kdesktop/lock/lockprocess.h | 4 |
5 files changed, 76 insertions, 16 deletions
diff --git a/kdesktop/lock/Makefile.am b/kdesktop/lock/Makefile.am index e9963ffab..42c1b770a 100644 --- a/kdesktop/lock/Makefile.am +++ b/kdesktop/lock/Makefile.am @@ -8,9 +8,9 @@ kdesktop_lock_LDADD = ../libkdesktopsettings.la ../../kdmlib/libdmctl.la $(LI bin_PROGRAMS = kdesktop_lock -kdesktop_lock_SOURCES = lockprocess.cc lockdlg.cc infodlg.cc autologout.cc main.cc +kdesktop_lock_SOURCES = lockprocess.cc lockdlg.cc infodlg.cc querydlg.cc autologout.cc main.cc -noinst_HEADERS = lockprocess.h lockdlg.h infodlg.h autologout.h main.h +noinst_HEADERS = lockprocess.h lockdlg.h infodlg.h querydlg.cc autologout.h main.h METASOURCES = AUTO diff --git a/kdesktop/lock/infodlg.cc b/kdesktop/lock/infodlg.cc index 86351dd7b..66b54c0bc 100644 --- a/kdesktop/lock/infodlg.cc +++ b/kdesktop/lock/infodlg.cc @@ -103,11 +103,26 @@ void InfoDlg::setUnlockIcon() mpixLabel->setPixmap(DesktopIcon("unlock")); } +void InfoDlg::setKDEIcon() +{ + mpixLabel->setPixmap(DesktopIcon("about_kde")); +} + +void InfoDlg::setInfoIcon() +{ + mpixLabel->setPixmap(DesktopIcon("messagebox_info")); +} + void InfoDlg::setWarningIcon() { mpixLabel->setPixmap(DesktopIcon("messagebox_warning")); } +void InfoDlg::setErrorIcon() +{ + mpixLabel->setPixmap(DesktopIcon("messagebox_critical")); +} + void InfoDlg::show() { QDialog::show(); diff --git a/kdesktop/lock/infodlg.h b/kdesktop/lock/infodlg.h index 2eedf6269..ffe8364c2 100644 --- a/kdesktop/lock/infodlg.h +++ b/kdesktop/lock/infodlg.h @@ -33,7 +33,10 @@ public: void updateLabel( QString &txt ); void setUnlockIcon(); + void setKDEIcon(); + void setInfoIcon(); void setWarningIcon(); + void setErrorIcon(); private: QFrame *frame; diff --git a/kdesktop/lock/lockprocess.cc b/kdesktop/lock/lockprocess.cc index f0f53ae1e..2664c1c24 100644 --- a/kdesktop/lock/lockprocess.cc +++ b/kdesktop/lock/lockprocess.cc @@ -20,6 +20,7 @@ #include "lockprocess.h" #include "lockdlg.h" #include "infodlg.h" +#include "querydlg.h" #include "autologout.h" #include "kdesktopsettings.h" @@ -121,6 +122,7 @@ LockProcess::LockProcess(bool child, bool useBlankOnly) mForbidden(false), mAutoLogout(false), mPipeOpen(false), + mPipeOpen_out(false), mInfoMessageDisplayed(false), mForceReject(false) { @@ -208,7 +210,7 @@ LockProcess::~LockProcess() } mPipeOpen = false; - //close(mPipe_fd); + mPipeOpen_out = false; } static int signal_pipe[2]; @@ -237,16 +239,24 @@ void LockProcess::timerEvent(QTimerEvent *ev) void LockProcess::setupPipe() { - /* Create the FIFO if it does not exist */ + /* Create the FIFOs if they do not exist */ umask(0); - unlink(FIFO_DIR); - mkdir(FIFO_DIR,0600); - mknod(FIFO_FILE, S_IFIFO|0600, 0); + mkdir(FIFO_DIR,0644); + mknod(FIFO_FILE, S_IFIFO|0644, 0); + chmod(FIFO_FILE, 0644); mPipe_fd = open(FIFO_FILE, O_RDONLY | O_NONBLOCK); if (mPipe_fd > -1) { mPipeOpen = true; - QTimer::singleShot( 100, this, SLOT(checkPipe()) ); + QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) ); + } + + mknod(FIFO_FILE_OUT, S_IFIFO|0600, 0); + chmod(FIFO_FILE_OUT, 0600); + + mPipe_fd_out = open(FIFO_FILE_OUT, O_RDWR | O_NONBLOCK); + if (mPipe_fd_out > -1) { + mPipeOpen_out = true; } } @@ -255,6 +265,7 @@ void LockProcess::checkPipe() char readbuf[128]; int numread; QString to_display; + const char * pin_entry; if (mPipeOpen == true) { readbuf[0]=' '; @@ -262,7 +273,6 @@ void LockProcess::checkPipe() readbuf[numread] = 0; if (numread > 0) { if (readbuf[0] == 'C') { - printf("Clearing info box!\n\r"); mInfoMessageDisplayed=false; if (currentDialog != NULL) { mForceReject = true; @@ -272,7 +282,6 @@ void LockProcess::checkPipe() if (readbuf[0] == 'T') { to_display = readbuf; to_display = to_display.remove(0,1); - printf("Will display info message: %s\n", to_display.ascii()); // Lock out password dialogs and close any active dialog mInfoMessageDisplayed=true; if (currentDialog != NULL) { @@ -280,7 +289,7 @@ void LockProcess::checkPipe() currentDialog->close(); } // Display info message dialog - QTimer::singleShot( 100, this, SLOT(checkPipe()) ); + QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) ); InfoDlg inDlg( this ); inDlg.updateLabel(to_display); inDlg.setUnlockIcon(); @@ -288,10 +297,9 @@ void LockProcess::checkPipe() mForceReject = false; return; } - if (readbuf[0] == 'E') { + if ((readbuf[0] == 'E') || (readbuf[0] == 'W') || (readbuf[0] == 'I') || (readbuf[0] == 'K')) { to_display = readbuf; to_display = to_display.remove(0,1); - printf("Will display error message: %s\n", to_display.ascii()); // Lock out password dialogs and close any active dialog mInfoMessageDisplayed=true; if (currentDialog != NULL) { @@ -299,16 +307,46 @@ void LockProcess::checkPipe() currentDialog->close(); } // Display info message dialog - QTimer::singleShot( 100, this, SLOT(checkPipe()) ); + QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) ); InfoDlg inDlg( this ); inDlg.updateLabel(to_display); - inDlg.setWarningIcon(); + if (readbuf[0] == 'K') inDlg.setKDEIcon(); + if (readbuf[0] == 'I') inDlg.setInfoIcon(); + if (readbuf[0] == 'W') inDlg.setWarningIcon(); + if (readbuf[0] == 'E') inDlg.setErrorIcon(); int ret = execDialog( &inDlg ); mForceReject = false; return; } + if (readbuf[0] == 'Q') { + to_display = readbuf; + to_display = to_display.remove(0,1); + // Lock out password dialogs and close any active dialog + mInfoMessageDisplayed=true; + if (currentDialog != NULL) { + mForceReject = true; + currentDialog->close(); + } + // Display query dialog + QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) ); + QueryDlg qryDlg( this ); + qryDlg.updateLabel(to_display); + qryDlg.setUnlockIcon(); + mForceReject = false; + int ret = execDialog( &qryDlg ); + if (mForceReject == false) { + pin_entry = qryDlg.getEntry(); + mInfoMessageDisplayed=false; + if (mPipeOpen_out == true) { + write(mPipe_fd_out, pin_entry, strlen(pin_entry)+1); + write(mPipe_fd_out, "\n\r", 3); + } + } + mForceReject = false; + return; + } } - QTimer::singleShot( 100, this, SLOT(checkPipe()) ); + QTimer::singleShot( PIPE_CHECK_INTERVAL, this, SLOT(checkPipe()) ); } } diff --git a/kdesktop/lock/lockprocess.h b/kdesktop/lock/lockprocess.h index 18a624d57..eed5f92b9 100644 --- a/kdesktop/lock/lockprocess.h +++ b/kdesktop/lock/lockprocess.h @@ -31,6 +31,8 @@ struct GreeterPluginHandle { #define FIFO_DIR "/tmp/ksocket-global" #define FIFO_FILE "/tmp/ksocket-global/kdesktoplockcontrol" +#define FIFO_FILE_OUT "/tmp/ksocket-global/kdesktoplockcontrol_out" +#define PIPE_CHECK_INTERVAL 50 //=========================================================================== // @@ -136,6 +138,8 @@ private: bool mPipeOpen; int mPipe_fd; + bool mPipeOpen_out; + int mPipe_fd_out; }; #endif |