diff options
Diffstat (limited to 'kdesktop')
74 files changed, 5049 insertions, 4482 deletions
diff --git a/kdesktop/CMakeLists.txt b/kdesktop/CMakeLists.txt index 5ee2746cc..c65986368 100644 --- a/kdesktop/CMakeLists.txt +++ b/kdesktop/CMakeLists.txt @@ -96,9 +96,9 @@ set( ${target}_SRCS tde_add_tdeinit_executable( ${target} AUTOMOC SOURCES ${${target}_SRCS} LINK - pthread kdesktopsettings-static bgnd-static dmctl-static - konq-shared tdeutils-shared tdesu-shared - ${XRENDER_LIBRARIES} ${XCURSOR_LIBRARIES} Xext ${DL_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} kdesktopsettings-static bgnd-static dmctl-static + konq-shared tdeutils-shared tdesu-shared ${TDEHW_LIBRARIES} + ${XRENDER_LIBRARIES} ${XCURSOR_LIBRARIES} Xext ${CMAKE_DL_LIBS} ${XSS_LIBRARIES} ${DBUS_1_TQT_LIBRARIES} ) diff --git a/kdesktop/DESIGN b/kdesktop/DESIGN index f69ee2198..170a86a75 100644 --- a/kdesktop/DESIGN +++ b/kdesktop/DESIGN @@ -7,6 +7,7 @@ Author : Last modified: 24 Oct 1999 + Overall design of KDesktop : ============================= @@ -14,6 +15,7 @@ KDesktop is the program that handles the desktop icons, the popup menus for the desktop, the mac menubar, and the screensaver system. + Files : ======= @@ -34,6 +36,7 @@ KDesktopIface* : DCOP interface for kdesktop, used by kfmclient lock* : screen saver/locker + Libs used by KDesktop ====================== @@ -41,6 +44,7 @@ tdecore, tdeui, tdefile - usual stuff :) libtdeio - I/O stuff, mimetypes, services, registry libkonq - properties dialog, templates ("new") menu, dir lister, settings + Screensaver =========== @@ -69,6 +73,7 @@ The new background code is in bgrender.cpp and bgmanager.cpp. Some features: * Support for xearth like programs. * Can export a pixmap of the desktop background for pseudo transparency. + Multiple monitors ================= Two monitors showing different things (not a mirror-setup) can be configured @@ -92,3 +97,43 @@ In case of 2 screen (multihead) | | | | desktopGeometry = 3200 x 1200 +----+ +-----+ screenGeometry = 1600 x 1200 (for each monitor) + +Interaction between kdesktop and kdesktop_lock +============================================== +kdesktop and kdesktop_lock interact using POSIX signals to coordinate their activities. +Each time the screensaver or lock is activated and then stopped/unlocked, the current +kdesktop_lock process is terminated and respawned, while kdesktop waits for the new process +to be ready. + +kdesktop to kdesktop_lock communication: + kdesktop uses four signals to request different types of locks. These signals do not activate + the lock/screensaver. Some of the signals can be combined together, for example to request a + lock with blank screen. + + - USR1 : request lock of the screen + - USR2 : request screensaver only, no lock + - WINCH: request lock of the screen using SAK (Secure Attention Key) + - TTIN : request blank screen for saver or lock + + The lock/screensaver is started using a fifth signal. + - TTOU : activate the scrensaver or lock + +kdesktop_lock to kdesktop communication: + kdesktop_lock uses three signals to inform kdesktop of status changes. + + - TTIN: the lock process is ready. This is sent after the process has been created/respawned + - USR2: the lock/screensaver has been activated + - USR1: the lock/screensaver has been unlocked/stopped + +Communication is handled by the screen saver engine defined in 'lockeng.{h,cpp}'. +The engine is split into two parts, the 'SaverEngine' running in the GUI thread and +the 'SaverEngineEventHandler' running in a separate thread and eventloop. +The 'SaverEngine' handles communication with X11, DCOP and DBUS while the +'SaverEngineEventHandler' handles communication with the actual lock process. +Several actions require cooperation of the two parts, so in various methods +there will be inter-thread calls (using timers or by emitting signals) to +trigger the other side remaining logic. +This complex design is necessary to avoid blocking the main GUI application event loop, +which has several tasks to manage and therefore can't affort to wait in a suspended state. +This was previously leading to deadlock when DCOP calls where executed on the secondary +thread/eventloop, for example when changing desktop while the lock process was restarting. diff --git a/kdesktop/KScreensaverIface.h b/kdesktop/KScreensaverIface.h index de5c19f2b..b6434738e 100644 --- a/kdesktop/KScreensaverIface.h +++ b/kdesktop/KScreensaverIface.h @@ -12,11 +12,10 @@ public: KScreensaverIface() : DCOPObject("KScreensaverIface") {} k_dcop: - /** Lock the screen now even if the screensaver does not lock by default. */ + /** Lock the screen now even if the screensaver does not lock by default */ virtual void lock() = 0; - /** Save the screen now. If the user has locking enabled, the screen is - * locked also. */ + /** Start the screensaver now. If the user has locking enabled, the screen is locked also */ virtual void save() = 0; /** Quit the screensaver if it is running */ @@ -29,22 +28,23 @@ k_dcop: * Enable/disable the screensaver * returns true if the action succeeded */ - virtual bool enable( bool e ) = 0; + virtual bool enable(bool e) = 0; /** Is the screen currently blanked? */ virtual bool isBlanked() = 0; - /** Reload the screensaver configuration. */ + /** Reload the screensaver configuration */ virtual void configure() = 0; - /** Only blank the screen (and possibly lock). Do not use a custom - * screen saver in the interest of saving battery. + /** + * Set the screensaver to blank (and possibly lock). + * This method does not actually start the screensaver. */ - virtual void setBlankOnly( bool blankOnly ) = 0; + virtual void setBlankOnly(bool blankOnly) = 0; /*** * @internal - */ + */ virtual void saverLockReady() = 0; }; diff --git a/kdesktop/Makefile.am b/kdesktop/Makefile.am index 393b3c760..b2d4c2b2c 100644 --- a/kdesktop/Makefile.am +++ b/kdesktop/Makefile.am @@ -35,7 +35,7 @@ noinst_HEADERS = desktop.h bgmanager.h krootwm.h \ kcheckrunning_SOURCES = kcheckrunning.cpp kcheckrunning_LDFLAGS = $(all_libraries) -kcheckrunning_LDADD = $(LIB_X11) $(LIB_QT) +kcheckrunning_LDADD = $(LIB_X11) $(LIB_TQT) METASOURCES = AUTO diff --git a/kdesktop/bgmanager.cpp b/kdesktop/bgmanager.cpp index 7e90e8fca..49cff2c16 100644 --- a/kdesktop/bgmanager.cpp +++ b/kdesktop/bgmanager.cpp @@ -78,7 +78,7 @@ KBackgroundManager::KBackgroundManager(TQWidget *desktop, KWinModule* twinModule m_pDesktop = desktop; if (desktop == 0L) - desktop = TQT_TQWIDGET(TDEApplication::desktop()->screen()); + desktop = TDEApplication::desktop()->screen(); m_Renderer.resize( 1 ); m_Cache.resize( 1 ); @@ -97,40 +97,40 @@ KBackgroundManager::KBackgroundManager(TQWidget *desktop, KWinModule* twinModule m_Cache[i]->hash = 0; m_Cache[i]->exp_from = -1; m_Renderer.insert (i, new KVirtualBGRenderer(i,m_pConfig)); - connect(m_Renderer[i], TQT_SIGNAL(imageDone(int)), TQT_SLOT(slotImageDone(int))); + connect(m_Renderer[i], TQ_SIGNAL(imageDone(int)), TQ_SLOT(slotImageDone(int))); m_Renderer[i]->enableTiling( true ); // optimize } #ifdef COMPOSITE - m_tPixmap = new KPixmap(kapp->desktop()->size()); + m_tPixmap = new KPixmap(tdeApp->desktop()->size()); m_tPixmap->fill(TQColor(0, 0x0)); - connect(myApp, TQT_SIGNAL(cmBackgroundChanged( bool )), - TQT_SLOT(slotCmBackgroundChanged( bool ))); + connect(myApp, TQ_SIGNAL(cmBackgroundChanged( bool )), + TQ_SLOT(slotCmBackgroundChanged( bool ))); #endif configure(); m_pTimer = new TQTimer(this); - connect(m_pTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotTimeout())); + connect(m_pTimer, TQ_SIGNAL(timeout()), TQ_SLOT(slotTimeout())); m_pTimer->start( 60000 ); /*CrossFade's config*/ m_crossTimer = new TQTimer(this); - connect(m_crossTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotCrossFadeTimeout())); + connect(m_crossTimer, TQ_SIGNAL(timeout()), TQ_SLOT(slotCrossFadeTimeout())); resizingDesktop = true; /*Ends here*/ - connect(m_pKwinmodule, TQT_SIGNAL(currentDesktopChanged(int)), - TQT_SLOT(slotChangeDesktop(int))); - connect(m_pKwinmodule, TQT_SIGNAL(numberOfDesktopsChanged(int)), - TQT_SLOT(slotChangeNumberOfDesktops(int))); - connect(m_pKwinmodule, TQT_SIGNAL(currentDesktopViewportChanged(int, const TQPoint&)), - TQT_SLOT(slotChangeViewport(int, const TQPoint&))); + connect(m_pKwinmodule, TQ_SIGNAL(currentDesktopChanged(int)), + TQ_SLOT(slotChangeDesktop(int))); + connect(m_pKwinmodule, TQ_SIGNAL(numberOfDesktopsChanged(int)), + TQ_SLOT(slotChangeNumberOfDesktops(int))); + connect(m_pKwinmodule, TQ_SIGNAL(currentDesktopViewportChanged(int, const TQPoint&)), + TQ_SLOT(slotChangeViewport(int, const TQPoint&))); #if (TQT_VERSION-0 >= 0x030200) - connect( kapp->desktop(), TQT_SIGNAL( resized( int )), TQT_SLOT( desktopResized())); // RANDR support + connect( tdeApp->desktop(), TQ_SIGNAL( resized( int )), TQ_SLOT( desktopResized())); // RANDR support #endif TQSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop())); @@ -338,7 +338,7 @@ void KBackgroundManager::slotChangeNumberOfDesktops(int num) m_Cache[i]->hash = 0; m_Cache[i]->exp_from = -1; m_Renderer.insert(i, new KVirtualBGRenderer(i,m_pConfig)); - connect(m_Renderer[i], TQT_SIGNAL(imageDone(int)), TQT_SLOT(slotImageDone(int))); + connect(m_Renderer[i], TQ_SIGNAL(imageDone(int)), TQ_SLOT(slotImageDone(int))); m_Renderer[i]->enableTiling( true ); // optimize } } @@ -542,16 +542,16 @@ void KBackgroundManager::setPixmap(KPixmap *pm, int hash, int desk) if( !root_cleared ) { // clear the root window pixmap set by tdm root_cleared = true; - TQTimer::singleShot( 0, this, TQT_SLOT( clearRoot())); + TQTimer::singleShot( 0, this, TQ_SLOT( clearRoot())); // but make the pixmap visible until m_pDesktop is visible - TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap(*ep); - TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); + TDEApplication::desktop()->screen()->setErasePixmap(*ep); + TDEApplication::desktop()->screen()->erase(); } } else { - TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap(*ep); - TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); + TDEApplication::desktop()->screen()->setErasePixmap(*ep); + TDEApplication::desktop()->screen()->erase(); } // and export it via Esetroot-style for gnome/GTK apps to share in the pretties @@ -571,8 +571,8 @@ void KBackgroundManager::setPixmap(KPixmap *pm, int hash, int desk) void KBackgroundManager::clearRoot() { - TQT_TQWIDGET(TDEApplication::desktop()->screen())->setErasePixmap( TQPixmap()); - TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); + TDEApplication::desktop()->screen()->setErasePixmap( TQPixmap()); + TDEApplication::desktop()->screen()->erase(); } /* @@ -681,7 +681,7 @@ void KBackgroundManager::slotImageDone(int desk) { m_bBgInitDone = true; emit initDone(); - TQTimer::singleShot( 30000, this, TQT_SLOT( saveImages())); + TQTimer::singleShot( 30000, this, TQ_SLOT( saveImages())); do_cleanup = false; } } @@ -1004,7 +1004,7 @@ void KBackgroundManager::repaintBackground() if (m_pDesktop) m_pDesktop->repaint(); else - TQT_TQWIDGET(TDEApplication::desktop()->screen())->erase(); + TDEApplication::desktop()->screen()->erase(); } void KBackgroundManager::desktopResized() @@ -1026,13 +1026,13 @@ void KBackgroundManager::desktopResized() #ifdef COMPOSITE if (m_tPixmap) delete m_tPixmap; - m_tPixmap = new KPixmap(kapp->desktop()->size()); + m_tPixmap = new KPixmap(tdeApp->desktop()->size()); m_tPixmap->fill(TQColor(0, 0x0)); #endif m_Hash = 0; if( m_pDesktop ) { - m_pDesktop->resize( kapp->desktop()->geometry().size()); + m_pDesktop->resize( tdeApp->desktop()->geometry().size()); if (m_Renderer[effectiveDesktop()]->renderer(0)->usingCrossXml()){ m_Renderer[effectiveDesktop()]->renderer(0)->changeWallpaper(); } diff --git a/kdesktop/bgmanager.h b/kdesktop/bgmanager.h index b852a4adb..d78ebebc3 100644 --- a/kdesktop/bgmanager.h +++ b/kdesktop/bgmanager.h @@ -16,7 +16,7 @@ #include <tqdatetime.h> #include <KBackgroundIface.h> -#if defined(Q_WS_X11) && defined(HAVE_XRENDER) && TQT_VERSION >= 0x030300 +#if defined(TQ_WS_X11) && defined(HAVE_XRENDER) && TQT_VERSION >= 0x030300 #define COMPOSITE #endif @@ -54,7 +54,7 @@ class KBackgroundManager : public TQObject, public KBackgroundIface { - Q_OBJECT + TQ_OBJECT public: diff --git a/kdesktop/desktop.cpp b/kdesktop/desktop.cpp index 2732bff08..3ef0e33e7 100644 --- a/kdesktop/desktop.cpp +++ b/kdesktop/desktop.cpp @@ -44,17 +44,17 @@ #include <dcopclient.h> #include <kcursor.h> #include <kdebug.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <kimageio.h> #include <kinputdialog.h> #include <kipc.h> #include <tdelocale.h> #include <tdeio/netaccess.h> -#include <kprocess.h> +#include <tdeprocess.h> #include <tdesycoca.h> #include <tdetempfile.h> #include <tdemessagebox.h> -#include <kglobalaccel.h> +#include <tdeglobalaccel.h> #include <twinmodule.h> #include <krun.h> #include <twin.h> @@ -71,21 +71,21 @@ extern TQCString kdesktop_name, kicker_name, twin_name; KRootWidget::KRootWidget() : TQObject() { - kapp->desktop()->installEventFilter(this); - kapp->desktop()->setAcceptDrops( true ); + tdeApp->desktop()->installEventFilter(this); + tdeApp->desktop()->setAcceptDrops( true ); } bool KRootWidget::eventFilter ( TQObject *, TQEvent * e ) { if (e->type() == TQEvent::MouseButtonPress) { - TQMouseEvent *me = TQT_TQMOUSEEVENT(e); + TQMouseEvent *me = static_cast<TQMouseEvent*>(e); KRootWm::self()->mousePressed( me->globalPos(), me->button() ); return true; } else if (e->type() == TQEvent::Wheel) { - TQWheelEvent *we = TQT_TQWHEELEVENT(e); + TQWheelEvent *we = static_cast<TQWheelEvent*>(e); emit wheelRolled(we->delta()); return true; } @@ -113,7 +113,7 @@ bool KRootWidget::eventFilter ( TQObject *, TQEvent * e ) else if ( e->type() == TQEvent::Drop ) { TQDropEvent* de = static_cast<TQDropEvent*>( e ); - if ( KColorDrag::canDecode( de ) ) + if ( KColorDrag::canDecode( de ) ) emit colorDropEvent( de ); else if ( TQImageDrag::canDecode( de ) ) emit imageDropEvent( de ); @@ -155,17 +155,17 @@ KDesktop::KDesktop( SaverEngine* saver, bool x_root_hack, bool wait_for_kded ) : setCaption( "KDE Desktop"); setAcceptDrops(true); // WStyle_Customize seems to disable that - m_pKwinmodule = new KWinModule( TQT_TQOBJECT(this) ); + m_pKwinmodule = new KWinModule( this ); - kapp->dcopClient()->setNotifications(true); - kapp->dcopClient()->connectDCOPSignal(kicker_name, kicker_name, "desktopIconsAreaChanged(TQRect, int)", + tdeApp->dcopClient()->setNotifications(true); + tdeApp->dcopClient()->connectDCOPSignal(kicker_name, kicker_name, "desktopIconsAreaChanged(TQRect, int)", "KDesktopIface", "desktopIconsAreaChanged(TQRect, int)", false); // Dont repaint on configuration changes during construction m_bInit = true; // It's the child widget that gets the focus, not us - setFocusPolicy( TQ_NoFocus ); + setFocusPolicy( TQWidget::NoFocus ); if ( x_root_hack ) { @@ -184,28 +184,28 @@ KDesktop::KDesktop( SaverEngine* saver, bool x_root_hack, bool wait_for_kded ) : setGeometry( TQApplication::desktop()->geometry() ); lower(); - connect( kapp, TQT_SIGNAL( shutDown() ), - this, TQT_SLOT( slotShutdown() ) ); + connect( tdeApp, TQ_SIGNAL( shutDown() ), + this, TQ_SLOT( slotShutdown() ) ); - connect(kapp, TQT_SIGNAL(settingsChanged(int)), - this, TQT_SLOT(slotSettingsChanged(int))); - kapp->addKipcEventMask(KIPC::SettingsChanged); + connect(tdeApp, TQ_SIGNAL(settingsChanged(int)), + this, TQ_SLOT(slotSettingsChanged(int))); + tdeApp->addKipcEventMask(KIPC::SettingsChanged); - kapp->addKipcEventMask(KIPC::IconChanged); - connect(kapp, TQT_SIGNAL(iconChanged(int)), this, TQT_SLOT(slotIconChanged(int))); + tdeApp->addKipcEventMask(KIPC::IconChanged); + connect(tdeApp, TQ_SIGNAL(iconChanged(int)), this, TQ_SLOT(slotIconChanged(int))); - connect(KSycoca::self(), TQT_SIGNAL(databaseChanged()), - this, TQT_SLOT(slotDatabaseChanged())); + connect(KSycoca::self(), TQ_SIGNAL(databaseChanged()), + this, TQ_SLOT(slotDatabaseChanged())); m_pIconView = 0; m_pRootWidget = 0; bgMgr = 0; initRoot(); - TQTimer::singleShot(0, this, TQT_SLOT( slotStart() )); + TQTimer::singleShot(0, this, TQ_SLOT( slotStart() )); #if (TQT_VERSION-0 >= 0x030200) // XRANDR support - connect( kapp->desktop(), TQT_SIGNAL( resized( int )), TQT_SLOT( desktopResized())); + connect( tdeApp->desktop(), TQ_SIGNAL( resized( int )), TQ_SLOT( desktopResized())); #endif } @@ -215,7 +215,7 @@ KDesktop::initRoot() Display *dpy = tqt_xdisplay(); Window root = RootWindow(dpy, kdesktop_screen_number); XDefineCursor(dpy, root, cursor().handle()); - + m_bDesktopEnabled = KDesktopSettings::desktopEnabled(); if ( !m_bDesktopEnabled && !m_pRootWidget ) { @@ -238,21 +238,21 @@ KDesktop::initRoot() XSelectInput(dpy, root, attrs.your_event_mask | ButtonPressMask); m_pRootWidget = new KRootWidget; - connect(m_pRootWidget, TQT_SIGNAL(wheelRolled(int)), this, TQT_SLOT(slotSwitchDesktops(int))); - connect(m_pRootWidget, TQT_SIGNAL(colorDropEvent(TQDropEvent*)), this, TQT_SLOT(handleColorDropEvent(TQDropEvent*)) ); - connect(m_pRootWidget, TQT_SIGNAL(imageDropEvent(TQDropEvent*)), this, TQT_SLOT(handleImageDropEvent(TQDropEvent*)) ); - connect(m_pRootWidget, TQT_SIGNAL(newWallpaper(const KURL&)), this, TQT_SLOT(slotNewWallpaper(const KURL&)) ); + connect(m_pRootWidget, TQ_SIGNAL(wheelRolled(int)), this, TQ_SLOT(slotSwitchDesktops(int))); + connect(m_pRootWidget, TQ_SIGNAL(colorDropEvent(TQDropEvent*)), this, TQ_SLOT(handleColorDropEvent(TQDropEvent*)) ); + connect(m_pRootWidget, TQ_SIGNAL(imageDropEvent(TQDropEvent*)), this, TQ_SLOT(handleImageDropEvent(TQDropEvent*)) ); + connect(m_pRootWidget, TQ_SIGNAL(newWallpaper(const KURL&)), this, TQ_SLOT(slotNewWallpaper(const KURL&)) ); // Geert Jansen: backgroundmanager belongs here // TODO tell KBackgroundManager if we change widget() bgMgr = new KBackgroundManager( m_pIconView, m_pKwinmodule ); bgMgr->setExport(1); - connect( bgMgr, TQT_SIGNAL( initDone()), TQT_SLOT( backgroundInitDone())); + connect( bgMgr, TQ_SIGNAL( initDone()), TQ_SLOT( backgroundInitDone())); if (!m_bInit) { delete KRootWm::self(); KRootWm* krootwm = new KRootWm( m_pSaver, this ); // handler for root menu (used by kdesktop on RMB click) - keys->setSlot("Lock Session", krootwm, TQT_SLOT(slotLock())); + keys->setSlot("Lock Session", krootwm, TQ_SLOT(slotLock())); keys->updateConnections(); } } @@ -263,24 +263,24 @@ KDesktop::initRoot() delete m_pRootWidget; m_pRootWidget = 0; m_pIconView = new KDIconView( this, 0 ); - connect( m_pIconView, TQT_SIGNAL( imageDropEvent( TQDropEvent * ) ), - this, TQT_SLOT( handleImageDropEvent( TQDropEvent * ) ) ); - connect( m_pIconView, TQT_SIGNAL( colorDropEvent( TQDropEvent * ) ), - this, TQT_SLOT( handleColorDropEvent( TQDropEvent * ) ) ); - connect( m_pIconView, TQT_SIGNAL( newWallpaper( const KURL & ) ), - this, TQT_SLOT( slotNewWallpaper( const KURL & ) ) ); - connect( m_pIconView, TQT_SIGNAL( wheelRolled( int ) ), - this, TQT_SLOT( slotSwitchDesktops( int ) ) ); - - // All the QScrollView/QWidget-specific stuff should go here, so that we can use + connect( m_pIconView, TQ_SIGNAL( imageDropEvent( TQDropEvent * ) ), + this, TQ_SLOT( handleImageDropEvent( TQDropEvent * ) ) ); + connect( m_pIconView, TQ_SIGNAL( colorDropEvent( TQDropEvent * ) ), + this, TQ_SLOT( handleColorDropEvent( TQDropEvent * ) ) ); + connect( m_pIconView, TQ_SIGNAL( newWallpaper( const KURL & ) ), + this, TQ_SLOT( slotNewWallpaper( const KURL & ) ) ); + connect( m_pIconView, TQ_SIGNAL( wheelRolled( int ) ), + this, TQ_SLOT( slotSwitchDesktops( int ) ) ); + + // All the QScrollView/TQWidget-specific stuff should go here, so that we can use // another qscrollview/widget instead of the iconview and use the same code m_pIconView->setVScrollBarMode( TQScrollView::AlwaysOff ); m_pIconView->setHScrollBarMode( TQScrollView::AlwaysOff ); m_pIconView->setDragAutoScroll( false ); m_pIconView->setFrameStyle( TQFrame::NoFrame ); m_pIconView->viewport()->setBackgroundMode( X11ParentRelative ); - m_pIconView->setFocusPolicy( TQ_StrongFocus ); - m_pIconView->viewport()->setFocusPolicy( TQ_StrongFocus ); + m_pIconView->setFocusPolicy( TQWidget::StrongFocus ); + m_pIconView->viewport()->setFocusPolicy( TQWidget::StrongFocus ); m_pIconView->setGeometry( geometry() ); m_pIconView->show(); @@ -288,7 +288,7 @@ KDesktop::initRoot() // TODO tell KBackgroundManager if we change widget() bgMgr = new KBackgroundManager( m_pIconView, m_pKwinmodule ); bgMgr->setExport(1); - connect( bgMgr, TQT_SIGNAL( initDone()), TQT_SLOT( backgroundInitDone())); + connect( bgMgr, TQ_SIGNAL( initDone()), TQ_SLOT( backgroundInitDone())); // make sure it is initialized before we first call updateWorkArea() m_pIconView->initConfig( m_bInit ); @@ -301,7 +301,7 @@ KDesktop::initRoot() TQCString replyType; TQRect area; - if ( kapp->dcopClient()->call(kicker_name, kicker_name, "desktopIconsArea(int)", + if ( tdeApp->dcopClient()->call(kicker_name, kicker_name, "desktopIconsArea(int)", data, replyType, result, false, 2000) ) { TQDataStream res(result, IO_ReadOnly); @@ -315,7 +315,7 @@ KDesktop::initRoot() // if we failed to get the information from kicker wait a little - probably // this is the KDE startup and kicker is simply not running yet m_waitForKicker = new TQTimer(this); - connect(m_waitForKicker, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotNoKicker())); + connect(m_waitForKicker, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotNoKicker())); m_waitForKicker->start(15000, true); } else // we are not called from the ctor, so kicker should already run @@ -330,7 +330,7 @@ KDesktop::initRoot() m_pIconView->start(); delete KRootWm::self(); KRootWm* krootwm = new KRootWm( m_pSaver, this ); // handler for root menu (used by kdesktop on RMB click) - keys->setSlot("Lock Session", krootwm, TQT_SLOT(slotLock())); + keys->setSlot("Lock Session", krootwm, TQ_SLOT(slotLock())); keys->updateConnections(); } } else { @@ -359,12 +359,12 @@ KDesktop::backgroundInitDone() // avoid flicker if (m_bDesktopEnabled) { - const TQPixmap *bg = TQT_TQWIDGET(TQApplication::desktop()->screen())->backgroundPixmap(); + const TQPixmap *bg = TQApplication::desktop()->screen()->backgroundPixmap(); if ( bg ) m_pIconView->setErasePixmap( *bg ); show(); - kapp->sendPostedEvents(); + tdeApp->sendPostedEvents(); } DCOPRef r( "ksmserver", "ksmserver" ); @@ -396,7 +396,7 @@ KDesktop::slotStart() m_pIconView->start(); // Global keys - keys = new TDEGlobalAccel( TQT_TQOBJECT(this) ); + keys = new TDEGlobalAccel( this ); (void) new KRootWm( m_pSaver, this ); #include "kdesktopbindings.cpp" @@ -404,9 +404,9 @@ KDesktop::slotStart() keys->readSettings(); keys->updateConnections(); - connect(kapp, TQT_SIGNAL(appearanceChanged()), TQT_SLOT(slotConfigure())); + connect(tdeApp, TQ_SIGNAL(appearanceChanged()), TQ_SLOT(slotConfigure())); - TQTimer::singleShot(300, this, TQT_SLOT( slotUpAndRunning() )); + TQTimer::singleShot(300, this, TQ_SLOT( slotUpAndRunning() )); } void @@ -504,7 +504,7 @@ void KDesktop::popupExecuteCommand(const TQString& command) if (m_bInit) return; - if (!kapp->authorize("run_command")) + if (!tdeApp->authorize("run_command")) return; // Created on demand @@ -648,21 +648,21 @@ void KDesktop::setShowDesktop( bool b ) } // on desktop changes or when a window is deiconified, we abort the show desktop mode - connect(twinModule(), TQT_SIGNAL(currentDesktopChanged(int)), - TQT_SLOT(slotCurrentDesktopChanged(int))); - connect(twinModule(), TQT_SIGNAL(windowChanged(WId,unsigned int)), - TQT_SLOT(slotWindowChanged(WId,unsigned int))); - connect(twinModule(), TQT_SIGNAL(windowAdded(WId)), - TQT_SLOT(slotWindowAdded(WId))); + connect(twinModule(), TQ_SIGNAL(currentDesktopChanged(int)), + TQ_SLOT(slotCurrentDesktopChanged(int))); + connect(twinModule(), TQ_SIGNAL(windowChanged(WId,unsigned int)), + TQ_SLOT(slotWindowChanged(WId,unsigned int))); + connect(twinModule(), TQ_SIGNAL(windowAdded(WId)), + TQ_SLOT(slotWindowAdded(WId))); } else { - disconnect(twinModule(), TQT_SIGNAL(currentDesktopChanged(int)), - this, TQT_SLOT(slotCurrentDesktopChanged(int))); - disconnect(twinModule(), TQT_SIGNAL(windowChanged(WId,unsigned int)), - this, TQT_SLOT(slotWindowChanged(WId,unsigned int))); - disconnect(twinModule(), TQT_SIGNAL(windowAdded(WId)), - this, TQT_SLOT(slotWindowAdded(WId))); + disconnect(twinModule(), TQ_SIGNAL(currentDesktopChanged(int)), + this, TQ_SLOT(slotCurrentDesktopChanged(int))); + disconnect(twinModule(), TQ_SIGNAL(windowChanged(WId,unsigned int)), + this, TQ_SLOT(slotWindowChanged(WId,unsigned int))); + disconnect(twinModule(), TQ_SIGNAL(windowAdded(WId)), + this, TQ_SLOT(slotWindowAdded(WId))); for (TQValueVector<WId>::ConstIterator it = m_iconifiedList.begin(); it != m_iconifiedList.end(); @@ -839,7 +839,7 @@ void KDesktop::refresh() m_bNeedRepaint |= 1; updateWorkArea(); #endif - kapp->dcopClient()->send( twin_name, "", "refresh()", TQString("")); + tdeApp->dcopClient()->send( twin_name, "", "refresh()", TQString("")); refreshIcons(); } @@ -851,7 +851,7 @@ void KDesktop::slotSetVRoot() return; if (KWin::windowInfo(winId()).mappingState() == NET::Withdrawn) { - TQTimer::singleShot(100, this, TQT_SLOT(slotSetVRoot())); + TQTimer::singleShot(100, this, TQ_SLOT(slotSetVRoot())); return; } @@ -907,7 +907,7 @@ void KDesktop::desktopIconsAreaChanged(const TQRect &area, int screen) if (screen <= -2) screen = kdesktop_screen_number; else if (screen == -1) - screen = kapp->desktop()->primaryScreen(); + screen = tdeApp->desktop()->primaryScreen(); // This is pretty broken, mixes Xinerama and non-Xinerama multihead // and generally doesn't seem to be required anyway => ignore screen. @@ -1032,7 +1032,7 @@ void KDesktop::logout() void KDesktop::logout( TDEApplication::ShutdownConfirm confirm, TDEApplication::ShutdownType sdtype ) { - if( !kapp->requestShutDown( confirm, sdtype ) ) + if( !tdeApp->requestShutDown( confirm, sdtype ) ) // this i18n string is also in kicker/applets/run/runapplet KMessageBox::error( this, i18n("Could not log out properly.\nThe session manager cannot " "be contacted. You can try to force a shutdown by pressing " @@ -1064,6 +1064,30 @@ void KDesktop::slotRebootNoCnf() TDEApplication::ShutdownTypeReboot ); } +void KDesktop::slotFreeze() +{ + DCOPRef r("ksmserver", "ksmserver"); + r.send("suspend", 1); +} + +void KDesktop::slotSuspend() +{ + DCOPRef r("ksmserver", "ksmserver"); + r.send("suspend", 3); +} + +void KDesktop::slotHibernate() +{ + DCOPRef r("ksmserver", "ksmserver"); + r.send("suspend", 4); +} + +void KDesktop::slotHybridSuspend() +{ + DCOPRef r("ksmserver", "ksmserver"); + r.send("suspend", 5); +} + void KDesktop::setVRoot( bool enable ) { if ( enable == set_vroot ) @@ -1100,7 +1124,7 @@ void KDesktop::setIconsEnabled( bool enable ) void KDesktop::desktopResized() { - resize(kapp->desktop()->size()); + resize(tdeApp->desktop()->size()); if ( m_pIconView ) { @@ -1108,7 +1132,7 @@ void KDesktop::desktopResized() // remove all icons, resize desktop, tell kdiconview new iconsArea size // tell kdiconview to reget all icons m_pIconView->slotClear(); - m_pIconView->resize(kapp->desktop()->size()); + m_pIconView->resize(tdeApp->desktop()->size()); // get new desktopIconsArea from kicker TQByteArray data, result; @@ -1117,7 +1141,7 @@ void KDesktop::desktopResized() TQCString replyType; TQRect area; - if ( kapp->dcopClient()->call(kicker_name, kicker_name, "desktopIconsArea(int)", + if ( tdeApp->dcopClient()->call(kicker_name, kicker_name, "desktopIconsArea(int)", data, replyType, result, false, 2000) ) { TQDataStream res(result, IO_ReadOnly); diff --git a/kdesktop/desktop.h b/kdesktop/desktop.h index c6a208f07..ca1eefc61 100644 --- a/kdesktop/desktop.h +++ b/kdesktop/desktop.h @@ -44,7 +44,7 @@ class SaverEngine; class KRootWidget : public TQObject { - Q_OBJECT + TQ_OBJECT public: KRootWidget(); bool eventFilter( TQObject *, TQEvent * e ); @@ -63,7 +63,7 @@ signals: class KDesktop : public TQWidget, public KDesktopIface { - Q_OBJECT + TQ_OBJECT public: @@ -135,6 +135,10 @@ private slots: void slotLogoutNoCnf(); void slotHaltNoCnf(); void slotRebootNoCnf(); + void slotFreeze(); + void slotSuspend(); + void slotHibernate(); + void slotHybridSuspend(); /** Connected to KSycoca */ void slotDatabaseChanged(); diff --git a/kdesktop/init.cpp b/kdesktop/init.cpp index 6bf87f333..25e3dd717 100644 --- a/kdesktop/init.cpp +++ b/kdesktop/init.cpp @@ -19,11 +19,11 @@ #include <tdeio/job.h> #include <tdeio/netaccess.h> -#include <kstandarddirs.h> -#include <kdesktopfile.h> +#include <tdestandarddirs.h> +#include <tdedesktopfile.h> #include <tdeglobalsettings.h> #include <tdeapplication.h> -#include <kprocess.h> +#include <tdeprocess.h> #include <tdemessagebox.h> #include <tdelocale.h> #include <kdebug.h> @@ -40,7 +40,7 @@ #include <dirent.h> #include <stdlib.h> #include <errno.h> -#include <ksimpleconfig.h> +#include <tdesimpleconfig.h> // for multihead extern int kdesktop_screen_number; @@ -134,7 +134,7 @@ static TQString realDesktopPath() */ static void copyDesktopLinks() { - TDEConfig *config = kapp->config(); + TDEConfig *config = tdeApp->config(); config->setGroup("General"); if (!config->readBoolEntry("CopyDesktopLinks", true)) return; @@ -145,7 +145,7 @@ static void copyDesktopLinks() TQString desktopPath = realDesktopPath(); for (TQStringList::ConstIterator it = list.begin(); it != list.end(); it++) { - KDesktopFile desk( *it ); + TDEDesktopFile desk( *it ); if (desk.readBoolEntry("Hidden")) continue; copyFile( *it, desktopPath ); @@ -213,13 +213,13 @@ void testLocalInstallation() if ( emptyDesktop || firstTimeWithNewTrash || installNewTrashi18n ) { TQString oldIcon, oldEmptyIcon; if ( trashDesktopExists ) { - KDesktopFile trashDesktop( trashDesktopPath, true ); + TDEDesktopFile trashDesktop( trashDesktopPath, true ); oldIcon = trashDesktop.readIcon(); oldEmptyIcon = trashDesktop.readEntry( "EmptyIcon" ); } copyFile( locate( "data", "kdesktop/directory.trash" ), trashDesktopPath ); if ( trashDesktopExists ) { - KDesktopFile trashDesktop( trashDesktopPath ); + TDEDesktopFile trashDesktop( trashDesktopPath ); trashDesktop.writeEntry( "Icon", oldIcon ); trashDesktop.writeEntry( "EmptyIcon", oldEmptyIcon ); trashDesktop.sync(); @@ -234,7 +234,7 @@ void testLocalInstallation() (void)TDEIO::NetAccess::synchronousRun( job, 0 ); // OK the only thing missing is to convert the icon position... - KSimpleConfig cfg( locateLocal("appdata", "IconPositions") ); + TDESimpleConfig cfg( locateLocal("appdata", "IconPositions") ); if ( cfg.hasGroup( "IconPosition::Trash" ) && !cfg.hasGroup( "IconPosition::trash.desktop" ) ) { const TQMap<TQString, TQString> entries = cfg.entryMap( "IconPosition::Trash" ); cfg.setGroup( "IconPosition::trash.desktop" ); diff --git a/kdesktop/init/Templates/CAMERA-Device.desktop b/kdesktop/init/Templates/CAMERA-Device.desktop index 524436e35..af68c39ce 100644 --- a/kdesktop/init/Templates/CAMERA-Device.desktop +++ b/kdesktop/init/Templates/CAMERA-Device.desktop @@ -3,5 +3,5 @@ MountPoint= Dev= ReadOnly=false Type=FSDevice -Icon=camera_mount -UnmountIcon=camera_unmount +Icon=camera-mounted +UnmountIcon=camera-unmounted diff --git a/kdesktop/init/Templates/CDROM-Device.desktop b/kdesktop/init/Templates/CDROM-Device.desktop index 4aa9adaf9..eb228c909 100644 --- a/kdesktop/init/Templates/CDROM-Device.desktop +++ b/kdesktop/init/Templates/CDROM-Device.desktop @@ -4,7 +4,7 @@ Dev= ReadOnly=false Type=FSDevice Icon=media-optical-cdrom-mounted -UnmountIcon=media-optical-cdrom +UnmountIcon=media-optical-cdrom-unmounted Actions=Eject; X-TDE-Priority=TopLevel diff --git a/kdesktop/init/Templates/CDWRITER-Device.desktop b/kdesktop/init/Templates/CDWRITER-Device.desktop index d3c61f03b..0b2b336ca 100644 --- a/kdesktop/init/Templates/CDWRITER-Device.desktop +++ b/kdesktop/init/Templates/CDWRITER-Device.desktop @@ -3,8 +3,8 @@ MountPoint= Dev= ReadOnly=0 Type=FSDevice -Icon=media-optical-cdwriter-mounted -UnmountIcon=media-optical-cdwriter +Icon=cd-rw-mounted +UnmountIcon=cd-rw-unmounted Actions=Eject; X-TDE-Priority=TopLevel diff --git a/kdesktop/init/Templates/DVDROM-Device.desktop b/kdesktop/init/Templates/DVDROM-Device.desktop index 6b34ef2cc..7ee55ac8d 100644 --- a/kdesktop/init/Templates/DVDROM-Device.desktop +++ b/kdesktop/init/Templates/DVDROM-Device.desktop @@ -4,7 +4,7 @@ Dev= ReadOnly=false Type=FSDevice Icon=media-optical-dvd-mounted -UnmountIcon=media-optical-dvd +UnmountIcon=media-optical-dvd-unmounted Actions=Eject; X-TDE-Priority=TopLevel diff --git a/kdesktop/init/Templates/Floppy.desktop b/kdesktop/init/Templates/Floppy.desktop index 38f515772..72c48de97 100644 --- a/kdesktop/init/Templates/Floppy.desktop +++ b/kdesktop/init/Templates/Floppy.desktop @@ -9,5 +9,5 @@ Dev= ReadOnly=false Type=FSDevice Icon=media-floppy-3_5-mounted -UnmountIcon=media-floppy-3_5 +UnmountIcon=media-floppy-3_5-unmounted X-TDE-Priority=TopLevel diff --git a/kdesktop/init/Templates/HD.desktop b/kdesktop/init/Templates/HD.desktop index 69646a095..497ea0377 100644 --- a/kdesktop/init/Templates/HD.desktop +++ b/kdesktop/init/Templates/HD.desktop @@ -4,4 +4,4 @@ Dev= ReadOnly=false Type=FSDevice Icon=drive-harddisk-mounted -UnmountIcon=drive-harddisk +UnmountIcon=drive-harddisk-unmounted diff --git a/kdesktop/init/Templates/MO-Device.desktop b/kdesktop/init/Templates/MO-Device.desktop index 7ad78fd18..fa4bb9897 100644 --- a/kdesktop/init/Templates/MO-Device.desktop +++ b/kdesktop/init/Templates/MO-Device.desktop @@ -3,5 +3,5 @@ MountPoint= Dev= ReadOnly=false Type=FSDevice -Icon=mo_mount -UnmountIcon=mo_unmount +Icon=mo-mounted +UnmountIcon=mo-unmounted diff --git a/kdesktop/init/Templates/NFS.desktop b/kdesktop/init/Templates/NFS.desktop index dcfc043d4..295abd01a 100644 --- a/kdesktop/init/Templates/NFS.desktop +++ b/kdesktop/init/Templates/NFS.desktop @@ -3,5 +3,5 @@ MountPoint= Dev= ReadOnly=false Type=FSDevice -Icon=nfs_mount -UnmountIcon=nfs_unmount +Icon=nfs-mounted +UnmountIcon=nfs-unmounted diff --git a/kdesktop/init/Templates/ZIP-Device.desktop b/kdesktop/init/Templates/ZIP-Device.desktop index d41ff2bbc..4067456c6 100644 --- a/kdesktop/init/Templates/ZIP-Device.desktop +++ b/kdesktop/init/Templates/ZIP-Device.desktop @@ -4,7 +4,7 @@ Dev= ReadOnly=false Type=FSDevice Icon=media-floppy-zip-mounted -UnmountIcon=media-floppy-zip +UnmountIcon=media-floppy-zip-unmounted Actions=Eject; X-TDE-Priority=TopLevel diff --git a/kdesktop/init/Templates/linkCAMERA.desktop b/kdesktop/init/Templates/linkCAMERA.desktop index 20a1f26b0..0f0d7a9b9 100644 --- a/kdesktop/init/Templates/linkCAMERA.desktop +++ b/kdesktop/init/Templates/linkCAMERA.desktop @@ -3,4 +3,4 @@ Name=Camera Device... Comment=New camera Type=Link URL=.source/CAMERA-Device.desktop -Icon=camera_unmount +Icon=camera-unmounted diff --git a/kdesktop/init/Templates/linkCDROM.desktop b/kdesktop/init/Templates/linkCDROM.desktop index 75bf366ed..1f73d4076 100644 --- a/kdesktop/init/Templates/linkCDROM.desktop +++ b/kdesktop/init/Templates/linkCDROM.desktop @@ -3,4 +3,4 @@ Name=CD-ROM Device... Comment=New CD-ROM Device Type=Link URL=.source/CDROM-Device.desktop -Icon=media-optical-cdrom +Icon=media-optical-cdrom-unmounted diff --git a/kdesktop/init/Templates/linkCDWRITER.desktop b/kdesktop/init/Templates/linkCDWRITER.desktop index faaad9795..ad2057139 100644 --- a/kdesktop/init/Templates/linkCDWRITER.desktop +++ b/kdesktop/init/Templates/linkCDWRITER.desktop @@ -3,4 +3,4 @@ Name=CDWRITER Device... Comment=New CDWRITER Device Type=Link URL=.source/CDWRITER-Device.desktop -Icon=cd-rw_unmount +Icon=cd-rw-unmounted diff --git a/kdesktop/init/Templates/linkDVDROM.desktop b/kdesktop/init/Templates/linkDVDROM.desktop index 687c14816..1e0427731 100644 --- a/kdesktop/init/Templates/linkDVDROM.desktop +++ b/kdesktop/init/Templates/linkDVDROM.desktop @@ -3,4 +3,4 @@ Name=DVD-ROM Device... Comment=New DVD-ROM Device Type=Link URL=.source/DVDROM-Device.desktop -Icon=media-optical-dvd +Icon=media-optical-dvd-unmounted diff --git a/kdesktop/init/Templates/linkFloppy.desktop b/kdesktop/init/Templates/linkFloppy.desktop index 15a9b4108..d61466a93 100644 --- a/kdesktop/init/Templates/linkFloppy.desktop +++ b/kdesktop/init/Templates/linkFloppy.desktop @@ -3,4 +3,4 @@ Name=Floppy Device... Comment=New Floppy Device Type=Link URL=.source/Floppy.desktop -Icon=media-floppy-3_5 +Icon=media-floppy-3_5-unmounted diff --git a/kdesktop/init/Templates/linkHD.desktop b/kdesktop/init/Templates/linkHD.desktop index 49d87e3f8..15c94ac4a 100644 --- a/kdesktop/init/Templates/linkHD.desktop +++ b/kdesktop/init/Templates/linkHD.desktop @@ -3,4 +3,4 @@ Name=Hard Disc Device... Comment=New Hard Disc Type=Link URL=.source/HD.desktop -Icon=drive-harddisk +Icon=drive-harddisk-unmounted diff --git a/kdesktop/init/Templates/linkMO.desktop b/kdesktop/init/Templates/linkMO.desktop index 994327b61..1a486e632 100644 --- a/kdesktop/init/Templates/linkMO.desktop +++ b/kdesktop/init/Templates/linkMO.desktop @@ -3,4 +3,4 @@ Name=MO Device... Comment=New MO Device Type=Link URL=.source/MO-Device.desktop -Icon=mo_unmount +Icon=mo-unmounted diff --git a/kdesktop/init/Templates/linkNFS.desktop b/kdesktop/init/Templates/linkNFS.desktop index fa2348c2d..bfa98b4d6 100644 --- a/kdesktop/init/Templates/linkNFS.desktop +++ b/kdesktop/init/Templates/linkNFS.desktop @@ -3,4 +3,4 @@ Name=NFS... Comment=New NFS Link Type=Link URL=.source/NFS.desktop -Icon=nfs_unmount +Icon=nfs-unmounted diff --git a/kdesktop/init/Templates/linkZIP.desktop b/kdesktop/init/Templates/linkZIP.desktop index 316a7d2ff..aaf2bc55e 100644 --- a/kdesktop/init/Templates/linkZIP.desktop +++ b/kdesktop/init/Templates/linkZIP.desktop @@ -3,4 +3,4 @@ Name=ZIP Device... Comment=New ZIP Device Type=Link URL=.source/ZIP-Device.desktop -Icon=media-floppy-zip +Icon=media-floppy-zip-unmounted diff --git a/kdesktop/kcustommenu.cpp b/kdesktop/kcustommenu.cpp index 2e825c0d9..f3d3cf817 100644 --- a/kdesktop/kcustommenu.cpp +++ b/kdesktop/kcustommenu.cpp @@ -57,7 +57,7 @@ KCustomMenu::KCustomMenu(const TQString &configfile, TQWidget *parent) insertMenuItem( menuItem, -1 ); } - connect(this, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotActivated(int))); + connect(this, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotActivated(int))); } KCustomMenu::~KCustomMenu() @@ -71,7 +71,7 @@ KCustomMenu::slotActivated(int id) KService::Ptr s = d->entryMap[id]; if (!s) return; - kapp->startServiceByDesktopPath(s->desktopEntryPath()); + tdeApp->startServiceByDesktopPath(s->desktopEntryPath()); } // The following is copied from kicker's PanelServiceMenu diff --git a/kdesktop/kcustommenu.h b/kdesktop/kcustommenu.h index 93b8d671f..a8f2cf5c4 100644 --- a/kdesktop/kcustommenu.h +++ b/kdesktop/kcustommenu.h @@ -29,7 +29,7 @@ */ class KCustomMenu : public TQPopupMenu { - Q_OBJECT + TQ_OBJECT public: /** * Create a custome menu described by @p configfile. diff --git a/kdesktop/kdesktop.kcfg b/kdesktop/kdesktop.kcfg index 71e008562..183fcc417 100644 --- a/kdesktop/kdesktop.kcfg +++ b/kdesktop/kdesktop.kcfg @@ -123,7 +123,7 @@ </group> <group name="FMSettings"> <entry key="NormalTextColor" type="Color"> <!--SHARED--> - <default>Qt::white</default> + <default>TQt::white</default> <label>Normal text color used for icon labels</label> <whatsthis></whatsthis> </entry> diff --git a/kdesktop/kdesktopapp.cpp b/kdesktop/kdesktopapp.cpp index ba05dc655..b19817bbd 100644 --- a/kdesktop/kdesktopapp.cpp +++ b/kdesktop/kdesktopapp.cpp @@ -20,15 +20,15 @@ #include <kdesktopapp.h> KDesktopApp::KDesktopApp(): -KUniqueApplication() +TDEUniqueApplication() { #ifdef COMPOSITE initCmBackground(); #endif } -KDesktopApp::KDesktopApp(Display * dpy, Qt::HANDLE visual, Qt::HANDLE colormap): -KUniqueApplication(dpy, visual, colormap) +KDesktopApp::KDesktopApp(Display * dpy, TQt::HANDLE visual, TQt::HANDLE colormap): +TDEUniqueApplication(dpy, visual, colormap) { #ifdef COMPOSITE initCmBackground(); @@ -87,7 +87,7 @@ bool KDesktopApp::x11EventFilter (XEvent * xevent) emit cmBackgroundChanged(supported); } } - return KUniqueApplication::x11EventFilter (xevent); + return TDEUniqueApplication::x11EventFilter (xevent); } #endif diff --git a/kdesktop/kdesktopapp.h b/kdesktop/kdesktopapp.h index 94cdd1d33..4ce52c3a2 100644 --- a/kdesktop/kdesktopapp.h +++ b/kdesktop/kdesktopapp.h @@ -21,9 +21,9 @@ #define __kdesktopapp_h__ #include <config.h> -#include <kuniqueapplication.h> +#include <tdeuniqueapplication.h> -#if defined(Q_WS_X11) && defined(HAVE_XRENDER) && TQT_VERSION >= 0x030300 +#if defined(TQ_WS_X11) && defined(HAVE_XRENDER) && TQT_VERSION >= 0x030300 #define COMPOSITE #endif @@ -33,13 +33,13 @@ # include <fixx11h.h> #endif -class KDesktopApp : public KUniqueApplication +class KDesktopApp : public TDEUniqueApplication { - Q_OBJECT + TQ_OBJECT public: KDesktopApp(); - KDesktopApp(Display * dpy, Qt::HANDLE visual = 0, - Qt::HANDLE colormap = 0); + KDesktopApp(Display * dpy, TQt::HANDLE visual = 0, + TQt::HANDLE colormap = 0); #ifdef COMPOSITE bool x11EventFilter (XEvent *); diff --git a/kdesktop/kdesktopbindings.cpp b/kdesktop/kdesktopbindings.cpp index 91bddb5b3..a4f46e717 100644 --- a/kdesktop/kdesktopbindings.cpp +++ b/kdesktop/kdesktopbindings.cpp @@ -1,6 +1,6 @@ #ifndef NOSLOTS # define DEF( name, key3, key4, fnSlot ) \ - keys->insert( name, i18n(name), TQString(), key3, key4, TQT_TQOBJECT(this), TQT_SLOT(fnSlot) ) + keys->insert( name, i18n(name), TQString(), key3, key4, this, TQ_SLOT(fnSlot) ) # define DEF2( name, key3, key4, receiver, slot ) \ keys->insert( name, i18n(name), TQString(), key3, key4, receiver, slot ); #else @@ -14,41 +14,62 @@ keys->insert( "Program:kdesktop", i18n("Desktop") ); #ifndef NOSLOTS - if (kapp->authorize("run_command")) + if (tdeApp->authorize("run_command")) { #endif - DEF( I18N_NOOP("Run Command"), ALT+Qt::Key_F2, WIN+Qt::Key_Return, slotExecuteCommand() ); + DEF( I18N_NOOP("Run Command"), ALT+TQt::Key_F2, WIN+TQt::Key_Return, slotExecuteCommand() ); #ifndef NOSLOTS } #endif - DEF( I18N_NOOP("Show Taskmanager"), CTRL+Qt::Key_Escape, WIN+CTRL+Qt::Key_Pause, slotShowTaskManager() ); - DEF( I18N_NOOP("Show Window List"), ALT+Qt::Key_F5, WIN+Qt::Key_0, slotShowWindowList() ); - DEF( I18N_NOOP("Switch User"), ALT+CTRL+Qt::Key_Insert, WIN+Qt::Key_Insert, slotSwitchUser() ); + DEF( I18N_NOOP("Show Taskmanager"), CTRL+TQt::Key_Escape, WIN+CTRL+TQt::Key_Pause, slotShowTaskManager() ); + DEF( I18N_NOOP("Show Window List"), ALT+TQt::Key_F5, WIN+TQt::Key_0, slotShowWindowList() ); + DEF( I18N_NOOP("Switch User"), ALT+CTRL+TQt::Key_Insert, WIN+TQt::Key_Insert, slotSwitchUser() ); #ifndef NOSLOTS - if (kapp->authorize("lock_screen")) + if (tdeApp->authorize("lock_screen")) { #endif - DEF2( I18N_NOOP("Lock Session"), ALT+CTRL+Qt::Key_L, WIN+Qt::Key_ScrollLock, KRootWm::self(), TQT_SLOT(slotLock()) ); - DEF2( I18N_NOOP("Lock Session (Hotkey)"), TDEShortcut(TQString("XF86ScreenSaver")), TDEShortcut(TQString("XF86ScreenSaver")), KRootWm::self(), TQT_SLOT(slotLock()) ); + DEF2( I18N_NOOP("Lock Session"), ALT+CTRL+TQt::Key_L, WIN+TQt::Key_ScrollLock, KRootWm::self(), TQ_SLOT(slotLock()) ); + DEF2( I18N_NOOP("Lock Session (Hotkey)"), TDEShortcut(TQString("XF86ScreenSaver")), TDEShortcut(TQString("XF86ScreenSaver")), KRootWm::self(), TQ_SLOT(slotLock()) ); #ifndef NOSLOTS } - if (kapp->authorize("start_screensaver")) + if (tdeApp->authorize("start_screensaver")) { #endif - DEF2( I18N_NOOP("Start Screen Saver"), ALT+CTRL+Qt::Key_S, WIN+Qt::Key_S, KRootWm::self(), TQT_SLOT(slotSave()) ); + DEF2( I18N_NOOP("Start Screen Saver"), ALT+CTRL+TQt::Key_S, WIN+TQt::Key_S, KRootWm::self(), TQ_SLOT(slotSave()) ); #ifndef NOSLOTS } - if (kapp->authorize("logout")) + if (tdeApp->authorize("logout")) { #endif - DEF( I18N_NOOP("Log Out"), ALT+CTRL+Qt::Key_Delete, WIN+Qt::Key_Escape, slotLogout() ); - DEF( I18N_NOOP("Log Out Without Confirmation"), ALT+CTRL+SHIFT+Qt::Key_Delete, WIN+SHIFT+Qt::Key_Escape, slotLogoutNoCnf() ); - DEF( I18N_NOOP("Halt without Confirmation"), ALT+CTRL+SHIFT+Qt::Key_PageDown, WIN+CTRL+SHIFT+Qt::Key_PageDown, slotHaltNoCnf() ); - DEF( I18N_NOOP("Reboot without Confirmation"), ALT+CTRL+SHIFT+Qt::Key_PageUp, WIN+CTRL+SHIFT+Qt::Key_PageUp, slotRebootNoCnf() ); + DEF( I18N_NOOP("Log Out"), ALT+CTRL+TQt::Key_Delete, WIN+TQt::Key_Escape, slotLogout() ); + DEF( I18N_NOOP("Log Out Without Confirmation"), ALT+CTRL+SHIFT+TQt::Key_Delete, WIN+SHIFT+TQt::Key_Escape, slotLogoutNoCnf() ); + DEF( I18N_NOOP("Halt without Confirmation"), ALT+CTRL+SHIFT+TQt::Key_PageDown, WIN+CTRL+SHIFT+TQt::Key_PageDown, slotHaltNoCnf() ); + DEF( I18N_NOOP("Reboot without Confirmation"), ALT+CTRL+SHIFT+TQt::Key_PageUp, WIN+CTRL+SHIFT+TQt::Key_PageUp, slotRebootNoCnf() ); #ifndef NOSLOTS } #endif + // Only add these options if supported by ksmserver + DCOPRef ksmref("ksmserver", "ksmserver"); + DCOPReply reply = ksmref.call("suspendOptions"); + + TQStringList suspendOptions; + if (reply.isValid()) { + reply.get(suspendOptions); + } + + if (suspendOptions.contains("freeze")) + DEF( I18N_NOOP("Freeze"), TDEShortcut(), TDEShortcut(), slotFreeze() ); + + if (suspendOptions.contains("suspend")) + DEF( I18N_NOOP("Suspend"), TDEShortcut(TQString("XF86Sleep")), TDEShortcut(TQString("XF86Sleep")), slotSuspend() ); + + if (suspendOptions.contains("hibernate")) + DEF( I18N_NOOP("Hibernate"), TDEShortcut(), TDEShortcut(), slotHibernate() ); + + if (suspendOptions.contains("hybridSuspend")) + DEF( I18N_NOOP("Hybrid Suspend"), TDEShortcut(), TDEShortcut(), slotHybridSuspend() ); + #undef DEF #undef DEF2 #undef WIN diff --git a/kdesktop/kdesktopshadowsettings.h b/kdesktop/kdesktopshadowsettings.h index c7e73db71..3c08cd574 100644 --- a/kdesktop/kdesktopshadowsettings.h +++ b/kdesktop/kdesktopshadowsettings.h @@ -24,7 +24,7 @@ #define __FX_DATA_DESKTOP #include <tqcolor.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <tdeconfig.h> #include <kshadowsettings.h> diff --git a/kdesktop/kdiconview.cpp b/kdesktop/kdiconview.cpp index 9e4f77931..70f1010b7 100644 --- a/kdesktop/kdiconview.cpp +++ b/kdesktop/kdiconview.cpp @@ -27,7 +27,7 @@ #include <tdeapplication.h> #include <kcolordrag.h> #include <kdebug.h> -#include <kdesktopfile.h> +#include <tdedesktopfile.h> #include <kdirlister.h> #include <tdeglobalsettings.h> #include <kpropertiesdialog.h> @@ -42,7 +42,7 @@ #include <kivfreespaceoverlay.h> #include <kprotocolinfo.h> #include <kstdaction.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <kurldrag.h> #include <twin.h> #include <twinmodule.h> @@ -74,7 +74,7 @@ TQRect KDIconView::desktopRect() // ----------------------------------------------------------------------------- -void KDIconView::saveIconPosition(KSimpleConfig *config, int x, int y) +void KDIconView::saveIconPosition(TDESimpleConfig *config, int x, int y) { // save the icon position in absolute coordinates config->writeEntry("Xabs", x); @@ -90,7 +90,7 @@ void KDIconView::saveIconPosition(KSimpleConfig *config, int x, int y) // ----------------------------------------------------------------------------- -void KDIconView::readIconPosition(KSimpleConfig *config, int &x, int &y) +void KDIconView::readIconPosition(TDESimpleConfig *config, int &x, int &y) { // check if we have the position for the current desktop size TQRect desk = desktopRect(); @@ -138,7 +138,7 @@ KDIconView::KDIconView( TQWidget *parent, const char* name ) m_bNeedSave( false ), m_autoAlign( false ), m_hasExistingPos( false ), - m_bEditableDesktopIcons( kapp->authorize("editable_desktop_icons") ), + m_bEditableDesktopIcons( tdeApp->authorize("editable_desktop_icons") ), m_bShowDot( false ), m_bVertAlign( true ), m_dirLister( 0L ), @@ -162,32 +162,32 @@ KDIconView::KDIconView( TQWidget *parent, const char* name ) // Initialize media handler mMediaListView = new TQListView(); - connect( TQApplication::clipboard(), TQT_SIGNAL(dataChanged()), this, TQT_SLOT(slotClipboardDataChanged()) ); + connect( TQApplication::clipboard(), TQ_SIGNAL(dataChanged()), this, TQ_SLOT(slotClipboardDataChanged()) ); setURL( desktopURL() ); // sets m_url m_desktopDirs = TDEGlobal::dirs()->findDirs( "appdata", "Desktop" ); initDotDirectories(); - connect( this, TQT_SIGNAL( executed( TQIconViewItem * ) ), - TQT_SLOT( slotExecuted( TQIconViewItem * ) ) ); - connect( this, TQT_SIGNAL( returnPressed( TQIconViewItem * ) ), - TQT_SLOT( slotReturnPressed( TQIconViewItem * ) ) ); - connect( this, TQT_SIGNAL( mouseButtonPressed(int, TQIconViewItem*, const TQPoint&)), - TQT_SLOT( slotMouseButtonPressed(int, TQIconViewItem*, const TQPoint&)) ); - connect( this, TQT_SIGNAL( mouseButtonClicked(int, TQIconViewItem*, const TQPoint&)), - TQT_SLOT( slotMouseButtonClickedKDesktop(int, TQIconViewItem*, const TQPoint&)) ); - connect( this, TQT_SIGNAL( contextMenuRequested(TQIconViewItem*, const TQPoint&)), - TQT_SLOT( slotContextMenuRequested(TQIconViewItem*, const TQPoint&)) ); + connect( this, TQ_SIGNAL( executed( TQIconViewItem * ) ), + TQ_SLOT( slotExecuted( TQIconViewItem * ) ) ); + connect( this, TQ_SIGNAL( returnPressed( TQIconViewItem * ) ), + TQ_SLOT( slotReturnPressed( TQIconViewItem * ) ) ); + connect( this, TQ_SIGNAL( mouseButtonPressed(int, TQIconViewItem*, const TQPoint&)), + TQ_SLOT( slotMouseButtonPressed(int, TQIconViewItem*, const TQPoint&)) ); + connect( this, TQ_SIGNAL( mouseButtonClicked(int, TQIconViewItem*, const TQPoint&)), + TQ_SLOT( slotMouseButtonClickedKDesktop(int, TQIconViewItem*, const TQPoint&)) ); + connect( this, TQ_SIGNAL( contextMenuRequested(TQIconViewItem*, const TQPoint&)), + TQ_SLOT( slotContextMenuRequested(TQIconViewItem*, const TQPoint&)) ); - connect( this, TQT_SIGNAL( enableAction( const char * , bool ) ), - TQT_SLOT( slotEnableAction( const char * , bool ) ) ); + connect( this, TQ_SIGNAL( enableAction( const char * , bool ) ), + TQ_SLOT( slotEnableAction( const char * , bool ) ) ); // Hack: KonqIconViewWidget::slotItemRenamed is not virtual :-( - disconnect( this, TQT_SIGNAL(itemRenamed(TQIconViewItem *, const TQString &)), - this, TQT_SLOT(slotItemRenamed(TQIconViewItem *, const TQString &)) ); - connect( this, TQT_SIGNAL(itemRenamed(TQIconViewItem *, const TQString &)), - this, TQT_SLOT(slotItemRenamed(TQIconViewItem *, const TQString &)) ); + disconnect( this, TQ_SIGNAL(itemRenamed(TQIconViewItem *, const TQString &)), + this, TQ_SLOT(slotItemRenamed(TQIconViewItem *, const TQString &)) ); + connect( this, TQ_SIGNAL(itemRenamed(TQIconViewItem *, const TQString &)), + this, TQ_SLOT(slotItemRenamed(TQIconViewItem *, const TQString &)) ); if (!m_bEditableDesktopIcons) { @@ -226,7 +226,7 @@ void KDIconView::initDotDirectories() delete m_dotDirectory; - m_dotDirectory = new KSimpleConfig( dotFileName ); + m_dotDirectory = new TDESimpleConfig( dotFileName ); // If we don't allow editable desktop icons, empty m_dotDirectory if (!m_bEditableDesktopIcons) { @@ -248,7 +248,7 @@ void KDIconView::initDotDirectories() if (TQFile::exists(localDotFileName)) { - KSimpleConfig dotDir(localDotFileName, true); // Read only + TDESimpleConfig dotDir(localDotFileName, true); // Read only TQStringList groups = dotDir.groupList(); TQStringList::ConstIterator gIt = groups.begin(); @@ -370,16 +370,16 @@ void KDIconView::start() m_bNeedSave = false; - connect( m_dirLister, TQT_SIGNAL( clear() ), this, TQT_SLOT( slotClear() ) ); - connect( m_dirLister, TQT_SIGNAL( started(const KURL&) ), this, TQT_SLOT( slotStarted(const KURL&) ) ); - connect( m_dirLister, TQT_SIGNAL( completed() ), this, TQT_SLOT( slotCompleted() ) ); - connect( m_dirLister, TQT_SIGNAL( newItems( const KFileItemList & ) ), this, TQT_SLOT( slotNewItems( const KFileItemList & ) ) ); - connect( m_dirLister, TQT_SIGNAL( deleteItem( KFileItem * ) ), this, TQT_SLOT( slotDeleteItem( KFileItem * ) ) ); - connect( m_dirLister, TQT_SIGNAL( refreshItems( const KFileItemList & ) ), this, TQT_SLOT( slotRefreshItems( const KFileItemList & ) ) ); + connect( m_dirLister, TQ_SIGNAL( clear() ), this, TQ_SLOT( slotClear() ) ); + connect( m_dirLister, TQ_SIGNAL( started(const KURL&) ), this, TQ_SLOT( slotStarted(const KURL&) ) ); + connect( m_dirLister, TQ_SIGNAL( completed() ), this, TQ_SLOT( slotCompleted() ) ); + connect( m_dirLister, TQ_SIGNAL( newItems( const KFileItemList & ) ), this, TQ_SLOT( slotNewItems( const KFileItemList & ) ) ); + connect( m_dirLister, TQ_SIGNAL( deleteItem( KFileItem * ) ), this, TQ_SLOT( slotDeleteItem( KFileItem * ) ) ); + connect( m_dirLister, TQ_SIGNAL( refreshItems( const KFileItemList & ) ), this, TQ_SLOT( slotRefreshItems( const KFileItemList & ) ) ); // Start the directory lister ! m_dirLister->setShowingDotFiles( m_bShowDot ); - kapp->allowURLAction("list", KURL(), url()); + tdeApp->allowURLAction("list", KURL(), url()); startDirLister(); createActions(); } @@ -420,35 +420,35 @@ void KDIconView::createActions() { if (m_bEditableDesktopIcons) { - TDEAction *undo = KStdAction::undo( KonqUndoManager::self(), TQT_SLOT( undo() ), &m_actionCollection, "undo" ); - connect( KonqUndoManager::self(), TQT_SIGNAL( undoAvailable( bool ) ), - undo, TQT_SLOT( setEnabled( bool ) ) ); - connect( KonqUndoManager::self(), TQT_SIGNAL( undoTextChanged( const TQString & ) ), - undo, TQT_SLOT( setText( const TQString & ) ) ); + TDEAction *undo = KStdAction::undo( KonqUndoManager::self(), TQ_SLOT( undo() ), &m_actionCollection, "undo" ); + connect( KonqUndoManager::self(), TQ_SIGNAL( undoAvailable( bool ) ), + undo, TQ_SLOT( setEnabled( bool ) ) ); + connect( KonqUndoManager::self(), TQ_SIGNAL( undoTextChanged( const TQString & ) ), + undo, TQ_SLOT( setText( const TQString & ) ) ); undo->setEnabled( KonqUndoManager::self()->undoAvailable() ); - TDEAction* paCut = KStdAction::cut( TQT_TQOBJECT(this), TQT_SLOT( slotCut() ), &m_actionCollection, "cut" ); + TDEAction* paCut = KStdAction::cut( this, TQ_SLOT( slotCut() ), &m_actionCollection, "cut" ); TDEShortcut cutShortCut = paCut->shortcut(); cutShortCut.remove( KKey( SHIFT + Key_Delete ) ); // used for deleting files paCut->setShortcut( cutShortCut ); - KStdAction::copy( TQT_TQOBJECT(this), TQT_SLOT( slotCopy() ), &m_actionCollection, "copy" ); - KStdAction::paste( TQT_TQOBJECT(this), TQT_SLOT( slotPaste() ), &m_actionCollection, "paste" ); - TDEAction *pasteTo = KStdAction::paste( TQT_TQOBJECT(this), TQT_SLOT( slotPopupPasteTo() ), &m_actionCollection, "pasteto" ); + KStdAction::copy( this, TQ_SLOT( slotCopy() ), &m_actionCollection, "copy" ); + KStdAction::paste( this, TQ_SLOT( slotPaste() ), &m_actionCollection, "paste" ); + TDEAction *pasteTo = KStdAction::paste( this, TQ_SLOT( slotPopupPasteTo() ), &m_actionCollection, "pasteto" ); pasteTo->setEnabled( false ); // only enabled during popupMenu() TDEShortcut reloadShortcut = TDEStdAccel::shortcut(TDEStdAccel::Reload); - new TDEAction( i18n( "&Reload" ), "reload", reloadShortcut, TQT_TQOBJECT(this), TQT_SLOT( refreshIcons() ), &m_actionCollection, "reload" ); + new TDEAction( i18n( "&Reload" ), "reload", reloadShortcut, this, TQ_SLOT( refreshIcons() ), &m_actionCollection, "reload" ); - (void) new TDEAction( i18n( "&Rename" ), /*"editrename",*/ Key_F2, TQT_TQOBJECT(this), TQT_SLOT( renameSelectedItem() ), &m_actionCollection, "rename" ); - (void) new TDEAction( i18n( "&Properties" ), ALT+Key_Return, TQT_TQOBJECT(this), TQT_SLOT( slotProperties() ), &m_actionCollection, "properties" ); + (void) new TDEAction( i18n( "&Rename" ), /*"editrename",*/ Key_F2, this, TQ_SLOT( renameSelectedItem() ), &m_actionCollection, "rename" ); + (void) new TDEAction( i18n( "&Properties" ), ALT+Key_Return, this, TQ_SLOT( slotProperties() ), &m_actionCollection, "properties" ); TDEAction* trash = new TDEAction( i18n( "&Move to Trash" ), "edittrash", Key_Delete, &m_actionCollection, "trash" ); - connect( trash, TQT_SIGNAL( activated( TDEAction::ActivationReason, TQt::ButtonState ) ), - this, TQT_SLOT( slotTrashActivated( TDEAction::ActivationReason, TQt::ButtonState ) ) ); + connect( trash, TQ_SIGNAL( activated( TDEAction::ActivationReason, TQt::ButtonState ) ), + this, TQ_SLOT( slotTrashActivated( TDEAction::ActivationReason, TQt::ButtonState ) ) ); TDEConfig config("kdeglobals", true, false); config.setGroup( "KDE" ); - (void) new TDEAction( i18n( "&Delete" ), "edit-delete", SHIFT+Key_Delete, TQT_TQOBJECT(this), TQT_SLOT( slotDelete() ), &m_actionCollection, "del" ); + (void) new TDEAction( i18n( "&Delete" ), "edit-delete", SHIFT+Key_Delete, this, TQ_SLOT( slotDelete() ), &m_actionCollection, "del" ); // Initial state of the actions (cut/copy/paste/...) slotSelectionChanged(); @@ -526,8 +526,8 @@ void KDIconView::setAutoAlign( bool b ) else { KRootWm::self()->startup = false; } - connect( this, TQT_SIGNAL( iconMoved() ), - this, TQT_SLOT( lineupIcons() ) ); + connect( this, TQ_SIGNAL( iconMoved() ), + this, TQ_SLOT( lineupIcons() ) ); } else { // change maxItemWidth, because when grid-align was active, it changed this for the grid @@ -535,8 +535,8 @@ void KDIconView::setAutoAlign( bool b ) setMaxItemWidth( TQMAX( TQMAX( sz, previewIconSize( iconSize() ) ), KonqFMSettings::settings()->iconTextWidth() ) ); setFont( font() ); // Force calcRect() - disconnect( this, TQT_SIGNAL( iconMoved() ), - this, TQT_SLOT( lineupIcons() ) ); + disconnect( this, TQ_SIGNAL( iconMoved() ), + this, TQ_SLOT( lineupIcons() ) ); } } @@ -566,7 +566,7 @@ void KDIconView::startDirLister() u.setPath( *it ); m_mergeDirs.append( u ); // And start listing this dir right now - kapp->allowURLAction("list", KURL(), u); + tdeApp->allowURLAction("list", KURL(), u); m_dirLister->openURL( u, true ); } configureMedia(); @@ -650,7 +650,7 @@ void KDIconView::contentsMousePressEvent( TQMouseEvent *e ) if (!m_dirLister) return; //kdDebug(1204) << "KDIconView::contentsMousePressEvent" << endl; // TQIconView, as of Qt 2.2, doesn't emit mouseButtonPressed for LMB on background - if ( e->button() == Qt::LeftButton && KRootWm::self()->hasLeftButtonMenu() ) + if ( e->button() == TQt::LeftButton && KRootWm::self()->hasLeftButtonMenu() ) { TQIconViewItem *item = findItem( e->pos() ); if ( !item ) @@ -676,7 +676,7 @@ void KDIconView::wheelEvent( TQWheelEvent* e ) TQIconViewItem *item = findItem( e->pos() ); if ( !item ) { - TQWheelEvent *we = TQT_TQWHEELEVENT(e); + TQWheelEvent *we = static_cast<TQWheelEvent*>(e); if ( we->state() == ControlButton ) { @@ -731,7 +731,7 @@ void KDIconView::slotMouseButtonClickedKDesktop(int _button, TQIconViewItem* _it { if (!m_dirLister) return; //kdDebug(1204) << "KDIconView::slotMouseButtonClickedKDesktop" << endl; - if ( _item && _button == Qt::MidButton ) { + if ( _item && _button == TQt::MidButton ) { slotExecuted(_item); } } @@ -749,7 +749,7 @@ void KDIconView::slotReturnPressed( TQIconViewItem *item ) void KDIconView::slotExecuted( TQIconViewItem *item ) { - kapp->propagateSessionManager(); + tdeApp->propagateSessionManager(); m_lastDeletedIconPos = TQPoint(); // user action -> not renaming an icon if (item) { visualActivate(item); @@ -839,7 +839,7 @@ void KDIconView::saveMediaListView() appname = "kdesktop"; else appname.sprintf("kdesktop-screen-%d", konq_screen_number); - kapp->dcopClient()->send( appname, "KDesktopIface", "configure()", data ); + tdeApp->dcopClient()->send( appname, "KDesktopIface", "configure()", data ); delete g_pConfig; } @@ -906,7 +906,7 @@ bool KDIconView::deleteGlobalDesktopFiles() // Web Browser kfmclient openBrowser %u Application TDE; if ( isDesktopFile(fItem) ) { - KSimpleConfig cfg( fItem->url().path(), true ); + TDESimpleConfig cfg( fItem->url().path(), true ); cfg.setDesktopGroup(); if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" ) { removeBuiltinIcon(cfg.readEntry( "Name" )); @@ -914,7 +914,7 @@ bool KDIconView::deleteGlobalDesktopFiles() } } - KDesktopFile df(desktopPath + fItem->url().fileName()); + TDEDesktopFile df(desktopPath + fItem->url().fileName()); df.writeEntry("Hidden", true); df.sync(); @@ -947,7 +947,7 @@ void KDIconView::slotDelete() // Not to be confused with the global popup-menu, KRootWm, when doing RMB on the desktop void KDIconView::popupMenu( const TQPoint &_global, const KFileItemList& _items ) { - if (!kapp->authorize("action/kdesktop_rmb")) return; + if (!tdeApp->authorize("action/kdesktop_rmb")) return; if (!m_dirLister) return; if ( _items.count() == 1 ) m_popupURL = _items.getFirst()->url(); @@ -1062,7 +1062,7 @@ bool KDIconView::makeFriendlyText( KFileIVI *fileIVI ) if ( !desktopFile.isEmpty() ) { - KSimpleConfig cfg( desktopFile, true ); + TDESimpleConfig cfg( desktopFile, true ); cfg.setDesktopGroup(); if (cfg.readBoolEntry("Hidden")) { return false; @@ -1145,7 +1145,7 @@ void KDIconView::slotNewItems( const KFileItemList & entries ) if (m_nextItemPos.isNull() && !m_dotDirectory) { // Not found, we'll need to save the new pos kdDebug(1214)<<"Neither a drop position stored nor m_dotDirectory set"<<endl; - m_dotDirectory = new KSimpleConfig( dotDirectoryPath(), true ); + m_dotDirectory = new TDESimpleConfig( dotDirectoryPath(), true ); // recursion slotNewItems( entries ); delete m_dotDirectory; @@ -1406,7 +1406,7 @@ void KDIconView::refreshTrashIcon() KFileIVI * fileIVI = static_cast<KFileIVI *>(it); KFileItem* item = fileIVI->item(); if ( isDesktopFile( item ) ) { - KSimpleConfig cfg( item->url().path(), true ); + TDESimpleConfig cfg( item->url().path(), true ); cfg.setDesktopGroup(); if ( cfg.readEntry( "Type" ) == "Link" && cfg.readEntry( "URL" ) == "trash:/" ) { @@ -1446,7 +1446,7 @@ void KDIconView::showFreeSpaceOverlay(KFileIVI* item) if (!m_paOutstandingFreeSpaceOverlaysTimer) { m_paOutstandingFreeSpaceOverlaysTimer = new TQTimer(this); - connect(m_paOutstandingFreeSpaceOverlaysTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotFreeSpaceOverlayStart())); + connect(m_paOutstandingFreeSpaceOverlaysTimer, TQ_SIGNAL(timeout()), TQ_SLOT(slotFreeSpaceOverlayStart())); } m_paOutstandingFreeSpaceOverlaysTimer->start(20, true); } @@ -1466,7 +1466,7 @@ void KDIconView::slotFreeSpaceOverlayStart() if (overlay) { - connect( overlay, TQT_SIGNAL( finished() ), this, TQT_SLOT( slotFreeSpaceOverlayFinished() ) ); + connect( overlay, TQ_SIGNAL( finished() ), this, TQ_SLOT( slotFreeSpaceOverlayFinished() ) ); overlay->start(); // Watch out, may emit finished() immediately!! return; // Let it run.... } @@ -1578,7 +1578,7 @@ void KDIconView::slotClipboardDataChanged() void KDIconView::renameDesktopFile(const TQString &path, const TQString &name) { - KDesktopFile cfg( path, false ); + TDEDesktopFile cfg( path, false ); // if we don't have the desktop entry group, then we assume that // it's not a config file (and we don't nuke it!) @@ -1667,7 +1667,7 @@ void KDIconView::slotAboutToCreate(const TQPoint &pos, const TQValueList<TDEIO:: saveIconPosition(m_dotDirectory, m_lastDropPos.x(), m_lastDropPos.y()); int dX = m_lastDropPos.x() - m_dropPos.x(); int dY = m_lastDropPos.y() - m_dropPos.y(); - if ((QABS(dX) > QABS(dY)) || (m_lastDropPos.x() + 2*gridX > width())) + if ((TQABS(dX) > TQABS(dY)) || (m_lastDropPos.x() + 2*gridX > width())) m_lastDropPos = TQPoint(m_dropPos.x(), m_lastDropPos.y() + gridY); else m_lastDropPos = TQPoint(m_lastDropPos.x() + gridX, m_lastDropPos.y()); @@ -1832,8 +1832,8 @@ void KDIconView::updateWorkArea( const TQRect &wr ) } } if ( needRepaint ) { - viewport()->repaint( FALSE ); - repaint( FALSE ); + viewport()->repaint( false ); + repaint( false ); saveIconPositions(); } @@ -1844,7 +1844,7 @@ void KDIconView::updateWorkArea( const TQRect &wr ) void KDIconView::setupSortKeys() { // can't use sorting in KFileIVI::setKey() - setProperty("sortDirectoriesFirst", TQVariant(false, 0)); + setProperty("sortDirectoriesFirst", TQVariant(false)); for (TQIconViewItem *it = firstItem(); it; it = it->nextItem()) { @@ -1905,7 +1905,7 @@ bool KDIconView::isFreePosition( const TQIconViewItem *item, const TQRect &curre if (area.isNull()) area = iconArea(); // If the proposed item rect is not contained by the desktop, by definition the item position is not free! - if (!area.contains(r, FALSE)) { + if (!area.contains(r, false)) { return false; } @@ -1929,7 +1929,7 @@ bool KDIconView::isFreePosition( const TQIconViewItem *item, const TQRect& rect, if (area.isNull()) area = iconArea(); // If the proposed item rect is not contained by the desktop, by definition the item position is not free! - if (!area.contains(rect, FALSE)) { + if (!area.contains(rect, false)) { return false; } diff --git a/kdesktop/kdiconview.h b/kdesktop/kdiconview.h index f3ebe6718..7ef8d4889 100644 --- a/kdesktop/kdiconview.h +++ b/kdesktop/kdiconview.h @@ -33,7 +33,7 @@ class KDirLister; class KonqSettings; -class KSimpleConfig; +class TDESimpleConfig; class TDEAccel; class KShadowEngine; class KDesktopShadowSettings; @@ -48,7 +48,7 @@ class KDesktopShadowSettings; */ class KDIconView : public KonqIconViewWidget, public KDirNotify { - Q_OBJECT + TQ_OBJECT public: KDIconView( TQWidget *parent, const char* name = 0L ); @@ -205,8 +205,8 @@ private: void refreshTrashIcon(); static TQRect desktopRect(); - static void saveIconPosition(KSimpleConfig *config, int x, int y); - static void readIconPosition(KSimpleConfig *config, int &x, int &y); + static void saveIconPosition(TDESimpleConfig *config, int x, int y); + static void readIconPosition(TDESimpleConfig *config, int &x, int &y); void showFreeSpaceOverlay(KFileIVI* item); @@ -243,7 +243,7 @@ private: TQStringList m_desktopDirs; /** The desktop's .directory, used for storing icon positions */ - KSimpleConfig *m_dotDirectory; + TDESimpleConfig *m_dotDirectory; /** Position of last deleted icon - used when renaming a file */ TQPoint m_lastDeletedIconPos; diff --git a/kdesktop/krootwm.cpp b/kdesktop/krootwm.cpp index 62ee673e0..9e751d573 100644 --- a/kdesktop/krootwm.cpp +++ b/kdesktop/krootwm.cpp @@ -32,8 +32,8 @@ #include <dirent.h> #include <errno.h> -#include <kprocess.h> -#include <kstandarddirs.h> +#include <tdeprocess.h> +#include <tdestandarddirs.h> #include <tdepopupmenu.h> #include <tdeapplication.h> #include <tdeconfig.h> @@ -52,7 +52,7 @@ #include <tdemessagebox.h> #include <kuser.h> #include <tqfile.h> -#include <ntqthread.h> +#include <tqthread.h> #include <tqeventloop.h> #include "krootwm.h" @@ -72,7 +72,7 @@ KRootWm * KRootWm::s_rootWm = 0; extern TQCString kdesktop_name, kicker_name, twin_name; -KRootWm::KRootWm(SaverEngine* _saver, KDesktop* _desktop) : TQObject(_desktop), startup(FALSE) +KRootWm::KRootWm(SaverEngine* _saver, KDesktop* _desktop) : TQObject(_desktop), startup(false) { s_rootWm = this; m_actionCollection = new TDEActionCollection(_desktop, this, "KRootWm::m_actionCollection"); @@ -86,16 +86,16 @@ KRootWm::KRootWm(SaverEngine* _saver, KDesktop* _desktop) : TQObject(_desktop), // Creates the new menu menuBar = 0; // no menubar yet menuNew = 0; - if (m_bDesktopEnabled && kapp->authorize("editable_desktop_icons")) + if (m_bDesktopEnabled && tdeApp->authorize("editable_desktop_icons")) { menuNew = new KNewMenu( m_actionCollection, "new_menu" ); - connect(menuNew->popupMenu(), TQT_SIGNAL( aboutToShow() ), - this, TQT_SLOT( slotFileNewAboutToShow() ) ); - connect( menuNew, TQT_SIGNAL( activated() ), - m_pDesktop->iconView(), TQT_SLOT( slotNewMenuActivated() ) ); + connect(menuNew->popupMenu(), TQ_SIGNAL( aboutToShow() ), + this, TQ_SLOT( slotFileNewAboutToShow() ) ); + connect( menuNew, TQ_SIGNAL( activated() ), + m_pDesktop->iconView(), TQ_SLOT( slotNewMenuActivated() ) ); } - if (kapp->authorizeTDEAction("bookmarks")) + if (tdeApp->authorizeTDEAction("bookmarks")) { bookmarks = new TDEActionMenu( i18n("Bookmarks"), "bookmark", m_actionCollection, "bookmarks" ); // The KBookmarkMenu is needed to fill the Bookmarks menu in the desktop menubar. @@ -114,8 +114,8 @@ KRootWm::KRootWm(SaverEngine* _saver, KDesktop* _desktop) : TQObject(_desktop), // so we create them here desktopMenu = new TQPopupMenu; windowListMenu = new KWindowListMenu; - connect( windowListMenu, TQT_SIGNAL( aboutToShow() ), - this, TQT_SLOT( slotWindowListAboutToShow() ) ); + connect( windowListMenu, TQ_SIGNAL( aboutToShow() ), + this, TQ_SLOT( slotWindowListAboutToShow() ) ); // Create the actions #if 0 @@ -132,82 +132,82 @@ KRootWm::KRootWm(SaverEngine* _saver, KDesktop* _desktop) : TQObject(_desktop), } #endif - if (kapp->authorize("run_command")) + if (tdeApp->authorize("run_command")) { - new TDEAction(i18n("Run Command..."), "system-run", 0, TQT_TQOBJECT(m_pDesktop), TQT_SLOT( slotExecuteCommand() ), m_actionCollection, "exec" ); - new TDEAction(i18n("Open Terminal Here..." ), "terminal", CTRL+Key_T, this, TQT_SLOT( slotOpenTerminal() ), + new TDEAction(i18n("Run Command..."), "system-run", 0, m_pDesktop, TQ_SLOT( slotExecuteCommand() ), m_actionCollection, "exec" ); + new TDEAction(i18n("Open Terminal Here..." ), "terminal", CTRL+Key_T, this, TQ_SLOT( slotOpenTerminal() ), m_actionCollection, "open_terminal" ); } if (!TDEGlobal::config()->isImmutable()) { - new TDEAction(i18n("Configure Desktop..."), "configure", 0, this, TQT_SLOT( slotConfigureDesktop() ), + new TDEAction(i18n("Configure Desktop..."), "configure", 0, this, TQ_SLOT( slotConfigureDesktop() ), m_actionCollection, "configdesktop" ); - new TDEAction(i18n("Disable Desktop Menu"), 0, this, TQT_SLOT( slotToggleDesktopMenu() ), + new TDEAction(i18n("Disable Desktop Menu"), 0, this, TQ_SLOT( slotToggleDesktopMenu() ), m_actionCollection, "togglemenubar" ); } - new TDEAction(i18n("Unclutter Windows"), 0, this, TQT_SLOT( slotUnclutterWindows() ), + new TDEAction(i18n("Unclutter Windows"), 0, this, TQ_SLOT( slotUnclutterWindows() ), m_actionCollection, "unclutter" ); - new TDEAction(i18n("Cascade Windows"), 0, this, TQT_SLOT( slotCascadeWindows() ), + new TDEAction(i18n("Cascade Windows"), 0, this, TQ_SLOT( slotCascadeWindows() ), m_actionCollection, "cascade" ); // arrange menu actions - if (m_bDesktopEnabled && kapp->authorize("editable_desktop_icons")) + if (m_bDesktopEnabled && tdeApp->authorize("editable_desktop_icons")) { - new TDEAction(i18n("By Name (Case Sensitive)"), 0, this, TQT_SLOT( slotArrangeByNameCS() ), + new TDEAction(i18n("By Name (Case Sensitive)"), 0, this, TQ_SLOT( slotArrangeByNameCS() ), m_actionCollection, "sort_ncs"); - new TDEAction(i18n("By Name (Case Insensitive)"), 0, this, TQT_SLOT( slotArrangeByNameCI() ), + new TDEAction(i18n("By Name (Case Insensitive)"), 0, this, TQ_SLOT( slotArrangeByNameCI() ), m_actionCollection, "sort_nci"); - new TDEAction(i18n("By Size"), 0, this, TQT_SLOT( slotArrangeBySize() ), + new TDEAction(i18n("By Size"), 0, this, TQ_SLOT( slotArrangeBySize() ), m_actionCollection, "sort_size"); - new TDEAction(i18n("By Type"), 0, this, TQT_SLOT( slotArrangeByType() ), + new TDEAction(i18n("By Type"), 0, this, TQ_SLOT( slotArrangeByType() ), m_actionCollection, "sort_type"); - new TDEAction(i18n("By Date"), 0, this, TQT_SLOT( slotArrangeByDate() ), + new TDEAction(i18n("By Date"), 0, this, TQ_SLOT( slotArrangeByDate() ), m_actionCollection, "sort_date"); TDEToggleAction *aSortDirsFirst = new TDEToggleAction( i18n("Directories First"), 0, m_actionCollection, "sort_directoriesfirst" ); - connect( aSortDirsFirst, TQT_SIGNAL( toggled( bool ) ), - this, TQT_SLOT( slotToggleDirFirst( bool ) ) ); + connect( aSortDirsFirst, TQ_SIGNAL( toggled( bool ) ), + this, TQ_SLOT( slotToggleDirFirst( bool ) ) ); new TDEAction(i18n("Line Up Horizontally"), 0, - this, TQT_SLOT( slotLineupIconsHoriz() ), + this, TQ_SLOT( slotLineupIconsHoriz() ), m_actionCollection, "lineupHoriz" ); new TDEAction(i18n("Line Up Vertically"), 0, - this, TQT_SLOT( slotLineupIconsVert() ), + this, TQ_SLOT( slotLineupIconsVert() ), m_actionCollection, "lineupVert" ); TDEToggleAction *aAutoAlign = new TDEToggleAction(i18n("Align to Grid"), 0, m_actionCollection, "realign" ); - connect( aAutoAlign, TQT_SIGNAL( toggled( bool ) ), - this, TQT_SLOT( slotToggleAutoAlign( bool ) ) ); + connect( aAutoAlign, TQ_SIGNAL( toggled( bool ) ), + this, TQ_SLOT( slotToggleAutoAlign( bool ) ) ); TDEToggleAction *aLockIcons = new TDEToggleAction(i18n("Lock in Place"), 0, m_actionCollection, "lock_icons"); - connect( aLockIcons, TQT_SIGNAL( toggled( bool ) ), - this, TQT_SLOT( slotToggleLockIcons( bool ) ) ); + connect( aLockIcons, TQ_SIGNAL( toggled( bool ) ), + this, TQ_SLOT( slotToggleLockIcons( bool ) ) ); } if (m_bDesktopEnabled) { - new TDEAction(i18n("Refresh Desktop"), "desktop", 0, this, TQT_SLOT( slotRefreshDesktop() ), + new TDEAction(i18n("Refresh Desktop"), "desktop", 0, this, TQ_SLOT( slotRefreshDesktop() ), m_actionCollection, "refresh" ); } // Icons in sync with kicker - if (kapp->authorize("lock_screen")) + if (tdeApp->authorize("lock_screen")) { - new TDEAction(i18n("Lock Session"), "system-lock-screen", 0, this, TQT_SLOT( slotLock() ), + new TDEAction(i18n("Lock Session"), "system-lock-screen", 0, this, TQ_SLOT( slotLock() ), m_actionCollection, "lock" ); } - if (kapp->authorize("logout")) + if (tdeApp->authorize("logout")) { new TDEAction(i18n("Log Out \"%1\"...").arg(KUser().loginName()), "system-log-out", 0, - this, TQT_SLOT( slotLogout() ), m_actionCollection, "logout" ); + this, TQ_SLOT( slotLogout() ), m_actionCollection, "logout" ); } - if (kapp->authorize("start_new_session") && DM().isSwitchable()) + if (tdeApp->authorize("start_new_session") && DM().isSwitchable()) { new TDEAction(i18n("Start New Session"), "fork", 0, this, - TQT_SLOT( slotNewSession() ), m_actionCollection, "newsession" ); - if (kapp->authorize("lock_screen")) + TQ_SLOT( slotNewSession() ), m_actionCollection, "newsession" ); + if (tdeApp->authorize("lock_screen")) { new TDEAction(i18n("Lock Current && Start New Session"), "system-lock-screen", 0, this, - TQT_SLOT( slotLockNNewSession() ), m_actionCollection, "lockNnewsession" ); + TQ_SLOT( slotLockNNewSession() ), m_actionCollection, "lockNnewsession" ); } } @@ -249,7 +249,7 @@ void KRootWm::initConfig() // Read configuration for icons alignment if ( m_bDesktopEnabled ) { m_pDesktop->iconView()->setAutoAlign( KDesktopSettings::autoLineUpIcons() ); - if ( kapp->authorize( "editable_desktop_icons" ) ) { + if ( tdeApp->authorize( "editable_desktop_icons" ) ) { m_pDesktop->iconView()->setIconsLocked( KDesktopSettings::lockIcons() ); TDEToggleAction *aLockIcons = static_cast<TDEToggleAction*>(m_actionCollection->action("lock_icons")); if (aLockIcons) @@ -314,8 +314,8 @@ void KRootWm::buildMenus() if (m_actionCollection->action("newsession")) { sessionsMenu = new TQPopupMenu; - connect( sessionsMenu, TQT_SIGNAL(aboutToShow()), TQT_SLOT(slotPopulateSessions()) ); - connect( sessionsMenu, TQT_SIGNAL(activated(int)), TQT_SLOT(slotSessionActivated(int)) ); + connect( sessionsMenu, TQ_SIGNAL(aboutToShow()), TQ_SLOT(slotPopulateSessions()) ); + connect( sessionsMenu, TQ_SIGNAL(activated(int)), TQ_SLOT(slotSessionActivated(int)) ); } if (menuBar) { @@ -464,7 +464,7 @@ void KRootWm::buildMenus() } int lastSep = desktopMenu->insertSeparator(); - if (sessionsMenu && kapp->authorize("switch_user")) + if (sessionsMenu && tdeApp->authorize("switch_user")) { desktopMenu->insertItem(SmallIconSet("switchuser" ), i18n("Switch User"), sessionsMenu); needSeparator = true; @@ -489,7 +489,7 @@ void KRootWm::buildMenus() desktopMenu->removeItem(lastSep); } - connect( desktopMenu, TQT_SIGNAL( aboutToShow() ), this, TQT_SLOT( slotFileNewAboutToShow() ) ); + connect( desktopMenu, TQ_SIGNAL( aboutToShow() ), this, TQ_SLOT( slotFileNewAboutToShow() ) ); if (menuBar) { menuBar->insertItem(i18n("File"), file); @@ -609,16 +609,16 @@ void KRootWm::mousePressed( const TQPoint& _global, int _button ) { if (!desktopMenu) return; // initialisation not yet done switch ( _button ) { - case Qt::LeftButton: + case TQt::LeftButton: if ( m_bShowMenuBar && menuBar ) menuBar->raise(); activateMenu( leftButtonChoice, _global ); break; - case Qt::MidButton: + case TQt::MidButton: activateMenu( middleButtonChoice, _global ); break; - case Qt::RightButton: - if (!kapp->authorize("action/kdesktop_rmb")) return; + case TQt::RightButton: + if (!tdeApp->authorize("action/kdesktop_rmb")) return; activateMenu( rightButtonChoice, _global ); break; default: @@ -637,13 +637,13 @@ void KRootWm::slotWindowList() { else r = desktop->screenGeometry( desktop->screenNumber(TQCursor::pos())); windowListMenu->init(); - disconnect( windowListMenu, TQT_SIGNAL( aboutToShow() ), - this, TQT_SLOT( slotWindowListAboutToShow() ) ); // avoid calling init() twice + disconnect( windowListMenu, TQ_SIGNAL( aboutToShow() ), + this, TQ_SLOT( slotWindowListAboutToShow() ) ); // avoid calling init() twice // windowListMenu->rect() is not valid before showing, use sizeHint() windowListMenu->popup(r.center() - TQRect( TQPoint( 0, 0 ), windowListMenu->sizeHint()).center()); windowListMenu->selectActiveWindow(); // make the popup more useful - connect( windowListMenu, TQT_SIGNAL( aboutToShow() ), - this, TQT_SLOT( slotWindowListAboutToShow() ) ); + connect( windowListMenu, TQ_SIGNAL( aboutToShow() ), + this, TQ_SLOT( slotWindowListAboutToShow() ) ); } void KRootWm::slotSwitchUser() { @@ -657,11 +657,11 @@ void KRootWm::slotSwitchUser() { else r = desktop->screenGeometry( desktop->screenNumber(TQCursor::pos())); slotPopulateSessions(); - disconnect( sessionsMenu, TQT_SIGNAL( aboutToShow() ), - this, TQT_SLOT( slotPopulateSessions() ) ); // avoid calling init() twice + disconnect( sessionsMenu, TQ_SIGNAL( aboutToShow() ), + this, TQ_SLOT( slotPopulateSessions() ) ); // avoid calling init() twice sessionsMenu->popup(r.center() - TQRect( TQPoint( 0, 0 ), sessionsMenu->sizeHint()).center()); - connect( sessionsMenu, TQT_SIGNAL( aboutToShow() ), - TQT_SLOT( slotPopulateSessions() ) ); + connect( sessionsMenu, TQ_SIGNAL( aboutToShow() ), + TQ_SLOT( slotPopulateSessions() ) ); } void KRootWm::slotArrangeByNameCS() @@ -786,12 +786,12 @@ void KRootWm::slotConfigureDesktop() { if (!m_configDialog) { m_configDialog = new KCMultiDialog( (TQWidget*)0, "configureDialog" ); - connect(m_configDialog, TQT_SIGNAL(finished()), this, TQT_SLOT(slotConfigClosed())); + connect(m_configDialog, TQ_SIGNAL(finished()), this, TQ_SLOT(slotConfigClosed())); TQStringList modules = configModules(); for (TQStringList::const_iterator it = modules.constBegin(); it != modules.constEnd(); ++it) { - if (kapp->authorizeControlModule(*it)) + if (tdeApp->authorizeControlModule(*it)) { m_configDialog->addModule(*it); } @@ -815,22 +815,22 @@ void KRootWm::slotToggleDesktopMenu() KDesktopSettings::writeConfig(); TQByteArray data; - kapp->dcopClient()->send( kdesktop_name, "KDesktopIface", "configure()", data); + tdeApp->dcopClient()->send( kdesktop_name, "KDesktopIface", "configure()", data); // for the standalone menubar setting - kapp->dcopClient()->send( "menuapplet*", "menuapplet", "configure()", data ); - kapp->dcopClient()->send( kicker_name, kicker_name, "configureMenubar()", data ); - kapp->dcopClient()->send( "twin*", "", "reconfigure()", data ); + tdeApp->dcopClient()->send( "menuapplet*", "menuapplet", "configure()", data ); + tdeApp->dcopClient()->send( kicker_name, kicker_name, "configureMenubar()", data ); + tdeApp->dcopClient()->send( "twin*", "", "reconfigure()", data ); } void KRootWm::slotUnclutterWindows() { - kapp->dcopClient()->send(twin_name, "KWinInterface", "unclutterDesktop()", TQString("")); + tdeApp->dcopClient()->send(twin_name, "KWinInterface", "unclutterDesktop()", TQString("")); } void KRootWm::slotCascadeWindows() { - kapp->dcopClient()->send(twin_name, "KWinInterface", "cascadeDesktop()", TQString("")); + tdeApp->dcopClient()->send(twin_name, "KWinInterface", "cascadeDesktop()", TQString("")); } @@ -840,7 +840,7 @@ void KRootWm::slotLock() { void KRootWm::slotSave() { - kapp->dcopClient()->send(kdesktop_name, "KScreensaverIface", "save()", TQString("")); + tdeApp->dcopClient()->send(kdesktop_name, "KScreensaverIface", "save()", TQString("")); } diff --git a/kdesktop/krootwm.h b/kdesktop/krootwm.h index 264f3eadb..efdd64c3e 100644 --- a/kdesktop/krootwm.h +++ b/kdesktop/krootwm.h @@ -64,7 +64,7 @@ class KRootWmThreadHelperObject; * This class is the handler for the menus (root popup menu and desktop menubar) */ class KRootWm: public TQObject { - Q_OBJECT + TQ_OBJECT public: KRootWm(SaverEngine*, KDesktop*); diff --git a/kdesktop/kwebdesktop/Makefile.am b/kdesktop/kwebdesktop/Makefile.am index 0d627675f..cd4458b1a 100644 --- a/kdesktop/kwebdesktop/Makefile.am +++ b/kdesktop/kwebdesktop/Makefile.am @@ -7,7 +7,7 @@ bin_PROGRAMS = kwebdesktop METASOURCES = AUTO kwebdesktop_SOURCES = kwebdesktop.cpp kwebdesktopsettings.kcfgc -kwebdesktop_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor +kwebdesktop_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_TQT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor kdesktop_kwebdesktop_data_DATA = kwebdesktop.desktop kdesktop_kwebdesktop_datadir = $(kde_datadir)/kdesktop/programs diff --git a/kdesktop/kwebdesktop/kwebdesktop.cpp b/kdesktop/kwebdesktop/kwebdesktop.cpp index 1e2499ea2..37358f758 100644 --- a/kdesktop/kwebdesktop/kwebdesktop.cpp +++ b/kdesktop/kwebdesktop/kwebdesktop.cpp @@ -52,10 +52,10 @@ KWebDesktopRun::KWebDesktopRun( KWebDesktop* webDesktop, const KURL & url ) { kdDebug() << "KWebDesktopRun::KWebDesktopRun starting get" << endl; TDEIO::Job * job = TDEIO::get(m_url, false, false); - connect( job, TQT_SIGNAL( result( TDEIO::Job *)), - this, TQT_SLOT( slotFinished(TDEIO::Job *))); - connect( job, TQT_SIGNAL( mimetype( TDEIO::Job *, const TQString &)), - this, TQT_SLOT( slotMimetype(TDEIO::Job *, const TQString &))); + connect( job, TQ_SIGNAL( result( TDEIO::Job *)), + this, TQ_SLOT( slotFinished(TDEIO::Job *))); + connect( job, TQ_SIGNAL( mimetype( TDEIO::Job *, const TQString &)), + this, TQ_SLOT( slotMimetype(TDEIO::Job *, const TQString &))); } void KWebDesktopRun::slotMimetype( TDEIO::Job *job, const TQString &_type ) @@ -79,7 +79,7 @@ void KWebDesktopRun::slotFinished( TDEIO::Job * job ) if (job->error()) { kdDebug() << job->errorString() << endl; - kapp->exit(1); + tdeApp->exit(1); } } @@ -141,7 +141,7 @@ void KWebDesktop::slotCompleted() TQPixmap snapshot = TQPixmap::grabWidget( m_part->widget() ); snapshot.save( m_imageFile, "PNG" ); // And terminate the app. - kapp->quit(); + tdeApp->quit(); } KParts::ReadOnlyPart* KWebDesktop::createPart( const TQString& mimeType ) @@ -166,7 +166,7 @@ KParts::ReadOnlyPart* KWebDesktop::createPart( const TQString& mimeType ) ((TQScrollView *)htmlPart->widget())->setHScrollBarMode( TQScrollView::AlwaysOff ); ((TQScrollView *)htmlPart->widget())->setVScrollBarMode( TQScrollView::AlwaysOff ); - connect( htmlPart, TQT_SIGNAL( completed() ), this, TQT_SLOT( slotCompleted() ) ); + connect( htmlPart, TQ_SIGNAL( completed() ), this, TQ_SLOT( slotCompleted() ) ); m_part = htmlPart; } else { // Try to find an appropriate viewer component @@ -176,13 +176,13 @@ KParts::ReadOnlyPart* KWebDesktop::createPart( const TQString& mimeType ) kdWarning() << "No handler found for " << mimeType << endl; else { kdDebug() << "Loaded " << m_part->className() << endl; - connect( m_part, TQT_SIGNAL( completed() ), - this, TQT_SLOT( slotCompleted() ) ); + connect( m_part, TQ_SIGNAL( completed() ), + this, TQ_SLOT( slotCompleted() ) ); } } if ( m_part ) { - connect( m_part, TQT_SIGNAL( canceled(const TQString &) ), - this, TQT_SLOT( slotCompleted() ) ); + connect( m_part, TQ_SIGNAL( canceled(const TQString &) ), + this, TQ_SLOT( slotCompleted() ) ); } return m_part; } diff --git a/kdesktop/kwebdesktop/kwebdesktop.h b/kdesktop/kwebdesktop/kwebdesktop.h index 2641378cf..686e40297 100644 --- a/kdesktop/kwebdesktop/kwebdesktop.h +++ b/kdesktop/kwebdesktop/kwebdesktop.h @@ -28,7 +28,7 @@ namespace TDEIO { class Job; } class KWebDesktop : public TQObject { - Q_OBJECT + TQ_OBJECT public: KWebDesktop( TQObject* parent, const TQCString & imageFile, int width, int height ) : TQObject( parent ), @@ -51,9 +51,9 @@ private: }; -class KWebDesktopRun : public QObject +class KWebDesktopRun : public TQObject { - Q_OBJECT + TQ_OBJECT public: KWebDesktopRun( KWebDesktop* webDesktop, const KURL & url ); ~KWebDesktopRun() {} diff --git a/kdesktop/lock/CMakeLists.txt b/kdesktop/lock/CMakeLists.txt index a394932e5..abeebb3d2 100644 --- a/kdesktop/lock/CMakeLists.txt +++ b/kdesktop/lock/CMakeLists.txt @@ -18,11 +18,14 @@ include_directories( ${CMAKE_SOURCE_DIR}/tdmlib ${CMAKE_SOURCE_DIR}/kcheckpass ${TDE_INCLUDE_DIR} + ${TDE_INCLUDE_DIR}/tde ${TQT_INCLUDE_DIRS} + ${KRB5_INCLUDE_DIRS} ) link_directories( ${TQT_LIBRARY_DIRS} + ${TDE_LIB_DIR} ) @@ -37,7 +40,8 @@ set( ${target}_SRCS tde_add_executable( ${target} AUTOMOC SOURCES ${${target}_SRCS} - LINK kdesktopsettings-static dmctl-static tdeio-shared Xext - pthread ${GL_LIBRARIES} "${LINKER_IMMEDIATE_BINDING_FLAGS}" + LINK kdesktopsettings-static dmctl-static tdeio-shared Xext ${TDEHW_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} ${GL_LIBRARIES} + "${LINKER_IMMEDIATE_BINDING_FLAGS}" DESTINATION ${BIN_INSTALL_DIR} ) diff --git a/kdesktop/lock/Makefile.am b/kdesktop/lock/Makefile.am index fd1bc1259..4c2fb22a8 100644 --- a/kdesktop/lock/Makefile.am +++ b/kdesktop/lock/Makefile.am @@ -1,7 +1,7 @@ ## Makefile.am of tdebase/kdesktop/lock INCLUDES = -I.. -I$(top_srcdir)/kcheckpass -I$(top_srcdir)/tdmlib $(GLINC) $(all_includes) -kdesktop_lock_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor +kdesktop_lock_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_TQT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor kdesktop_lock_LDADD = ../libkdesktopsettings.la ../../tdmlib/libdmctl.la $(LIB_TDEIO) $(LIB_XF86MISC) $(GLLIB) ####### Files diff --git a/kdesktop/lock/autologout.cpp b/kdesktop/lock/autologout.cpp index 7d6bf6ff1..ee1d8e1db 100644 --- a/kdesktop/lock/autologout.cpp +++ b/kdesktop/lock/autologout.cpp @@ -1,6 +1,6 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // // Copyright (c) 2004 Chris Howells <howells@kde.org> @@ -33,100 +33,100 @@ extern bool trinity_desktop_lock_use_system_modal_dialogs; AutoLogout::AutoLogout(LockProcess *parent) : TQDialog(parent, "password dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))) { - 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); - XChangeProperty(tqt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); - } - setCaption(i18n("Automatic Logout Notification")); - - 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); - - TQLabel *pixLabel = new TQLabel( frame, "pixlabel" ); - pixLabel->setPixmap(DesktopIcon("system-log-out")); - - TQLabel *greetLabel = new TQLabel(i18n("<nobr><qt><b>Automatic Log Out</b></qt><nobr>"), frame); - TQLabel *infoLabel = new TQLabel(i18n("<qt>To prevent being logged out, resume using this session by moving the mouse or pressing a key.</qt>"), frame); - - mStatusLabel = new TQLabel("<b> </b>", frame); - mStatusLabel->setAlignment(TQLabel::AlignCenter); - - TQLabel *mProgressLabel = new TQLabel("Time Remaining:", frame); - mProgressRemaining = new TQProgressBar(frame); - mProgressRemaining->setPercentageVisible(false); - - TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); - unlockDialogLayout->addWidget( frame ); - - frameLayout = new TQGridLayout(frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint()); - frameLayout->addMultiCellWidget(pixLabel, 0, 2, 0, 0, Qt::AlignCenter | Qt::AlignTop); - frameLayout->addWidget(greetLabel, 0, 1); - frameLayout->addWidget(mStatusLabel, 1, 1); - frameLayout->addWidget(infoLabel, 2, 1); - frameLayout->addWidget(mProgressLabel, 3, 1); - frameLayout->addWidget(mProgressRemaining, 4, 1); - - // get the time remaining in seconds for the status label - mRemaining = COUNTDOWN * 25; - - mProgressRemaining->setTotalSteps(COUNTDOWN * 25); - - updateInfo(mRemaining); - - mCountdownTimerId = startTimer(1000/25); - - connect(tqApp, TQT_SIGNAL(activity()), TQT_SLOT(slotActivity())); - - setFixedSize( sizeHint() ); + 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); + XChangeProperty(tqt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); + } + setCaption(i18n("Automatic Logout Notification")); + + 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); + + TQLabel *pixLabel = new TQLabel( frame, "pixlabel" ); + pixLabel->setPixmap(DesktopIcon("system-log-out")); + + TQLabel *greetLabel = new TQLabel(i18n("<nobr><qt><b>Automatic Log Out</b></qt><nobr>"), frame); + TQLabel *infoLabel = new TQLabel(i18n("<qt>To prevent being logged out, resume using this session by moving the mouse or pressing a key.</qt>"), frame); + + mStatusLabel = new TQLabel("<b> </b>", frame); + mStatusLabel->setAlignment(TQLabel::AlignCenter); + + TQLabel *mProgressLabel = new TQLabel("Time Remaining:", frame); + mProgressRemaining = new TQProgressBar(frame); + mProgressRemaining->setPercentageVisible(false); + + TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); + unlockDialogLayout->addWidget( frame ); + + frameLayout = new TQGridLayout(frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint()); + frameLayout->addMultiCellWidget(pixLabel, 0, 2, 0, 0, TQt::AlignCenter | TQt::AlignTop); + frameLayout->addWidget(greetLabel, 0, 1); + frameLayout->addWidget(mStatusLabel, 1, 1); + frameLayout->addWidget(infoLabel, 2, 1); + frameLayout->addWidget(mProgressLabel, 3, 1); + frameLayout->addWidget(mProgressRemaining, 4, 1); + + // get the time remaining in seconds for the status label + mRemaining = COUNTDOWN * 25; + + mProgressRemaining->setTotalSteps(COUNTDOWN * 25); + + updateInfo(mRemaining); + + mCountdownTimerId = startTimer(1000/25); + + connect(tqApp, TQ_SIGNAL(activity()), TQ_SLOT(slotActivity())); + + setFixedSize( sizeHint() ); } AutoLogout::~AutoLogout() { - hide(); + hide(); } void AutoLogout::updateInfo(int timeout) { - mStatusLabel->setText(i18n("<nobr><qt>You will be automatically logged out in 1 second</qt></nobr>", - "<nobr><qt>You will be automatically logged out in %n seconds</qt></nobr>", - timeout / 25) ); - mProgressRemaining->setProgress(timeout); + mStatusLabel->setText(i18n("<nobr><qt>You will be automatically logged out in 1 second</qt></nobr>", + "<nobr><qt>You will be automatically logged out in %n seconds</qt></nobr>", + timeout / 25) ); + mProgressRemaining->setProgress(timeout); } void AutoLogout::timerEvent(TQTimerEvent *ev) { - if (ev->timerId() == mCountdownTimerId) - { - updateInfo(mRemaining); - --mRemaining; - if (mRemaining < 0) - { - logout(); + if (ev->timerId() == mCountdownTimerId) { + updateInfo(mRemaining); + --mRemaining; + if (mRemaining < 0) { + logout(); + } } - } } void AutoLogout::slotActivity() { - accept(); + accept(); } void AutoLogout::logout() { - TQT_TQOBJECT(this)->killTimers(); + this->killTimers(); DCOPRef("ksmserver","ksmserver").send("logout", 0, 0, 0); } void AutoLogout::show() { - TQDialog::show(); - TQApplication::flushX(); + TQDialog::show(); + TQApplication::flushX(); } #include "autologout.moc" diff --git a/kdesktop/lock/autologout.h b/kdesktop/lock/autologout.h index c15a47f07..834f4fd0e 100644 --- a/kdesktop/lock/autologout.h +++ b/kdesktop/lock/autologout.h @@ -1,6 +1,6 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // // Copyright (c) 1999 Martin R. Jones <mjones@kde.org> // Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org> @@ -22,29 +22,29 @@ class TQProgressBar; class AutoLogout : public TQDialog { - Q_OBJECT - -public: - AutoLogout(LockProcess *parent); - ~AutoLogout(); - virtual void show(); - -protected: - virtual void timerEvent(TQTimerEvent *); - -private slots: - void slotActivity(); - -private: - void updateInfo(int); - TQFrame *frame; - TQGridLayout *frameLayout; - TQLabel *mStatusLabel; - int mCountdownTimerId; - int mRemaining; - TQTimer countDownTimer; - TQProgressBar *mProgressRemaining; - void logout(); + TQ_OBJECT + + public: + AutoLogout(LockProcess *parent); + ~AutoLogout(); + virtual void show(); + + protected: + virtual void timerEvent(TQTimerEvent *); + + private slots: + void slotActivity(); + + private: + void updateInfo(int); + TQFrame *frame; + TQGridLayout *frameLayout; + TQLabel *mStatusLabel; + int mCountdownTimerId; + int mRemaining; + TQTimer countDownTimer; + TQProgressBar *mProgressRemaining; + void logout(); }; #endif diff --git a/kdesktop/lock/infodlg.cpp b/kdesktop/lock/infodlg.cpp index d248d7bd0..a37c92b8e 100644 --- a/kdesktop/lock/infodlg.cpp +++ b/kdesktop/lock/infodlg.cpp @@ -1,8 +1,8 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // -// Copyright (c) 2010 Timothy Pearson <kb9vqf@pearsoncomputing.net> +// Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> #include <config.h> @@ -14,7 +14,7 @@ #include <tdelocale.h> #include <kpushbutton.h> #include <kseparator.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <tdeglobalsettings.h> #include <tdeconfig.h> #include <kiconloader.h> @@ -62,86 +62,88 @@ extern bool trinity_desktop_lock_use_system_modal_dialogs; // Simple dialog for displaying an unlock status or recurring error message // InfoDlg::InfoDlg(LockProcess *parent) - : TQDialog(parent, "information dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))), - mUnlockingFailed(false) + : 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); - XChangeProperty(tqt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); - } - setCaption(i18n("Information")); + 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); + XChangeProperty(tqt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); + } + setCaption(i18n("Information")); - 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 ); + 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")); + mpixLabel = new TQLabel( frame, "pixlabel" ); + mpixLabel->setPixmap(DesktopIcon("unlock")); - KUser user; + KUser user; - mStatusLabel = new TQLabel( "<b> </b>", frame ); - mStatusLabel->setAlignment( TQLabel::AlignCenter ); + mStatusLabel = new TQLabel( "<b> </b>", frame ); + mStatusLabel->setAlignment( TQLabel::AlignCenter ); - TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); - unlockDialogLayout->addWidget( frame ); + TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); + unlockDialogLayout->addWidget( frame ); - TQHBoxLayout *layStatus = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); - layStatus->addWidget( mStatusLabel ); + 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 ); + frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); + frameLayout->addMultiCellWidget( mpixLabel, 0, 2, 0, 0, TQt::AlignTop ); + frameLayout->addLayout( layStatus, 1, 1 ); - installEventFilter(this); - setFixedSize( sizeHint() ); -} + installEventFilter(this); + setFixedSize( sizeHint() ); + } InfoDlg::~InfoDlg() { - hide(); + hide(); } void InfoDlg::updateLabel(TQString &txt) { - mStatusLabel->setPaletteForegroundColor(Qt::black); - mStatusLabel->setText("<b>" + txt + "</b>"); + mStatusLabel->setPaletteForegroundColor(TQt::black); + mStatusLabel->setText("<b>" + txt + "</b>"); } void InfoDlg::setUnlockIcon() { - mpixLabel->setPixmap(DesktopIcon("unlock")); + mpixLabel->setPixmap(DesktopIcon("unlock")); } void InfoDlg::setKDEIcon() { - mpixLabel->setPixmap(DesktopIcon("about_kde")); + mpixLabel->setPixmap(DesktopIcon("about_kde")); } void InfoDlg::setInfoIcon() { - mpixLabel->setPixmap(DesktopIcon("messagebox_info")); + mpixLabel->setPixmap(DesktopIcon("messagebox_info")); } void InfoDlg::setWarningIcon() { - mpixLabel->setPixmap(DesktopIcon("messagebox_warning")); + mpixLabel->setPixmap(DesktopIcon("messagebox_warning")); } void InfoDlg::setErrorIcon() { - mpixLabel->setPixmap(DesktopIcon("messagebox_critical")); + mpixLabel->setPixmap(DesktopIcon("messagebox_critical")); } void InfoDlg::show() { - TQDialog::show(); - TQApplication::flushX(); + TQDialog::show(); + TQApplication::flushX(); } #include "infodlg.moc" diff --git a/kdesktop/lock/infodlg.h b/kdesktop/lock/infodlg.h index bb974282f..ec5569748 100644 --- a/kdesktop/lock/infodlg.h +++ b/kdesktop/lock/infodlg.h @@ -1,8 +1,8 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // -// Copyright (c) 2010 Timothy Pearson <kb9vqf@pearsoncomputing.net> +// Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> // #ifndef __INFODLG_H__ @@ -26,30 +26,30 @@ class TQListView; // class InfoDlg : public TQDialog { - Q_OBJECT - -public: - InfoDlg(LockProcess *parent); - ~InfoDlg(); - virtual void show(); - - void updateLabel( TQString &txt ); - void setUnlockIcon(); - void setKDEIcon(); - void setInfoIcon(); - void setWarningIcon(); - void setErrorIcon(); - -private: - TQFrame *frame; - TQGridLayout *frameLayout; - TQLabel *mStatusLabel; - TQLabel *mpixLabel; - int mCapsLocked; - bool mUnlockingFailed; - TQStringList layoutsList; - TQStringList::iterator currLayout; - int sPid, sFd; + TQ_OBJECT + + public: + InfoDlg(LockProcess *parent); + ~InfoDlg(); + virtual void show(); + + void updateLabel( TQString &txt ); + void setUnlockIcon(); + void setKDEIcon(); + void setInfoIcon(); + void setWarningIcon(); + void setErrorIcon(); + + private: + TQFrame *frame; + TQGridLayout *frameLayout; + TQLabel *mStatusLabel; + TQLabel *mpixLabel; + int mCapsLocked; + bool mUnlockingFailed; + TQStringList layoutsList; + TQStringList::iterator currLayout; + int sPid, sFd; }; #endif diff --git a/kdesktop/lock/lockdlg.cpp b/kdesktop/lock/lockdlg.cpp index 763d7bf95..c5d3d1aea 100644 --- a/kdesktop/lock/lockdlg.cpp +++ b/kdesktop/lock/lockdlg.cpp @@ -1,10 +1,11 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // // Copyright (c) 1999 Martin R. Jones <mjones@kde.org> // Copyright (c) 2003 Chris Howells <howells@kde.org> // Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org> +// Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> #include <config.h> @@ -19,7 +20,8 @@ #include <tdelocale.h> #include <kpushbutton.h> #include <kseparator.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> +#include <tdesimpleconfig.h> #include <tdeglobalsettings.h> #include <tdeconfig.h> #include <kiconloader.h> @@ -42,6 +44,10 @@ #include <tqlistview.h> #include <tqheader.h> #include <tqcheckbox.h> +#ifdef WITH_TDEHWLIB +#include <tqfile.h> +#include <tdecryptographiccarddevice.h> +#endif #include <ctype.h> #include <unistd.h> @@ -56,6 +62,7 @@ #include <X11/Xatom.h> #include <fixx11h.h> + #ifndef AF_LOCAL # define AF_LOCAL AF_UNIX #endif @@ -75,12 +82,15 @@ int dialogHideTimeout = 10*1000; // Simple dialog for entering a password. // PasswordDlg::PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin) - : TQDialog(parent, "password dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))), - mPlugin( plugin ), - mCapsLocked(-1), - mUnlockingFailed(false) + : TQDialog(parent, "password dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))), + mPlugin( plugin ), + mCapsLocked(-1), + mUnlockingFailed(false), + validUserCardInserted(false), + showInfoMessages(true), + mCardLoginInProgress(false) { - init(plugin); + init(plugin); } // @@ -88,239 +98,250 @@ PasswordDlg::PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin) // This version includes support for displaying the date and time the lock process was started // PasswordDlg::PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin, TQDateTime lockStartDateTime) - : TQDialog(parent, "password dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))), - mPlugin( plugin ), - mCapsLocked(-1), - mUnlockingFailed(false) + : TQDialog(parent, "password dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))), + mPlugin( plugin ), + mCapsLocked(-1), + mUnlockingFailed(false), + validUserCardInserted(false), + showInfoMessages(true), + mCardLoginInProgress(false) { - m_lockStartDT = lockStartDateTime; - init(plugin); + m_lockStartDT = lockStartDateTime; + init(plugin); } void PasswordDlg::init(GreeterPluginHandle *plugin) { - dialogHideTimeout = trinity_desktop_lock_delay_screensaver_start?KDesktopSettings::timeout()*1000:10*1000; - - 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); - XChangeProperty(tqt_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 ); - - TQLabel *pixLabel = NULL; - if (!trinity_desktop_lock_use_system_modal_dialogs) { - pixLabel = new TQLabel( frame, "pixlabel" ); - pixLabel->setPixmap(DesktopIcon("system-lock-screen")); - } - - KUser user; - TQLabel *greetLabel; - if (trinity_desktop_lock_use_system_modal_dialogs) { - greetLabel = new TQLabel( user.fullName().isEmpty() ? - "<b>" + i18n("This computer is in use and has been locked.") + "</b>" : - "<b>" + i18n("This computer is in use and has been locked.") + "</b><br><nobr>" + i18n("Only '%1' may unlock this session.").arg( user.fullName() ), frame ); - } - else { - greetLabel = new TQLabel( user.fullName().isEmpty() ? - i18n("<nobr><b>The session is locked</b><br>") : - i18n("<nobr><b>The session was locked by %1</b><br>").arg( user.fullName() ), frame ); - } - - TQLabel *lockDTLabel = NULL; - if ((trinity_desktop_lock_use_system_modal_dialogs) && (!m_lockStartDT.isNull())) { - lockDTLabel = new TQLabel(i18n("This session has been locked since %1").arg(m_lockStartDT.toString()), frame); - } - - mStatusLabel = new TQLabel( "<b> </b>", frame ); - mStatusLabel->setAlignment( TQLabel::AlignCenter ); - - mLayoutButton = new TQPushButton( frame ); - mLayoutButton->setFlat( true ); - - KSeparator *sep = new KSeparator( KSeparator::HLine, frame ); - - mNewSessButton = new KPushButton( KGuiItem(i18n("Sw&itch User..."), "fork"), frame ); - ok = new KPushButton( i18n("Unl&ock"), frame ); - ok->setDefault(true); - - bool show_cancel_button = !trinity_desktop_lock_hide_cancel_button || - trinity_desktop_lock_use_sak || - !trinity_desktop_lock_use_system_modal_dialogs; - if (show_cancel_button) - cancel = new KPushButton( KStdGuiItem::cancel(), frame ); - else - cancel = NULL; - - greet = plugin->info->create( this, 0, this, mLayoutButton, TQString::null, - KGreeterPlugin::Authenticate, KGreeterPlugin::ExUnlock ); - - TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); - unlockDialogLayout->addWidget( frame ); - - TQHBoxLayout *layStatus = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); - layStatus->addWidget( mStatusLabel ); - layStatus->addWidget( mLayoutButton ); - - TQHBoxLayout *layButtons = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); - layButtons->addWidget( mNewSessButton ); - layButtons->addStretch(); - layButtons->addWidget(ok); - if (show_cancel_button) - layButtons->addWidget(cancel); - - if (trinity_desktop_lock_use_system_modal_dialogs) { - KSMModalDialogHeader* theader = new KSMModalDialogHeader( frame ); - - if (!m_lockStartDT.isNull()) { - frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); - frameLayout->addMultiCellWidget( theader, 0, 0, 0, 2, Qt::AlignTop ); - frameLayout->addWidget( greetLabel, 1, 1 ); - frameLayout->addWidget( lockDTLabel, 2, 1 ); - frameLayout->addItem( greet->getLayoutItem(), 3, 1 ); - frameLayout->addLayout( layStatus, 4, 1 ); - frameLayout->addMultiCellWidget( sep, 5, 5, 0, 1 ); - frameLayout->addMultiCellLayout( layButtons, 6, 6, 0, 1 ); - } - else { - frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); - frameLayout->addMultiCellWidget( theader, 0, 0, 0, 2, Qt::AlignTop ); - frameLayout->addWidget( greetLabel, 1, 1 ); - frameLayout->addItem( greet->getLayoutItem(), 2, 1 ); - frameLayout->addLayout( layStatus, 3, 1 ); - frameLayout->addMultiCellWidget( sep, 4, 4, 0, 1 ); - frameLayout->addMultiCellLayout( layButtons, 5, 5, 0, 1 ); - } - } - else { - frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); - frameLayout->addMultiCellWidget( pixLabel, 0, 2, 0, 0, Qt::AlignTop ); - frameLayout->addWidget( greetLabel, 0, 1 ); - frameLayout->addItem( greet->getLayoutItem(), 1, 1 ); - frameLayout->addLayout( layStatus, 2, 1 ); - frameLayout->addMultiCellWidget( sep, 3, 3, 0, 1 ); - frameLayout->addMultiCellLayout( layButtons, 4, 4, 0, 1 ); - } - - if (show_cancel_button) - { - setTabOrder( ok, cancel ); - setTabOrder( cancel, mNewSessButton ); - } - else - { - setTabOrder( ok, mNewSessButton ); - } - setTabOrder( mNewSessButton, mLayoutButton ); - - connect(mLayoutButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(layoutClicked())); - if (show_cancel_button) - { - connect(cancel, TQT_SIGNAL(clicked()), TQT_SLOT(reject())); - } - connect(ok, TQT_SIGNAL(clicked()), TQT_SLOT(slotOK())); - connect(mNewSessButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotSwitchUser())); - - if (!DM().isSwitchable() || !kapp->authorize("switch_user")) - mNewSessButton->hide(); - - installEventFilter(this); - setFixedSize( sizeHint() ); - - mFailedTimerId = 0; - mTimeoutTimerId = startTimer(PASSDLG_HIDE_TIMEOUT); - connect(tqApp, TQT_SIGNAL(activity()), TQT_SLOT(slotActivity()) ); - - greet->start(); - - DCOPRef kxkb("kxkb", "kxkb"); - if( !kxkb.isNull() ) { - DCOPReply reply = kxkb.call("getLayoutsList"); - if (reply.isValid()) { - layoutsList = reply; - } - reply = kxkb.call("getCurrentLayout"); - TQString currentLayout; - if (reply.isValid()) { - reply.get(currentLayout); - } - if( !currentLayout.isEmpty() && layoutsList.count() > 1 ) { - currLayout = layoutsList.find(currentLayout); - if (currLayout == layoutsList.end()) - setLayoutText("err"); - else - setLayoutText(*currLayout); - } else - mLayoutButton->hide(); - } else { - mLayoutButton->hide(); // no kxkb running - } - capsLocked(); + dialogHideTimeout = trinity_desktop_lock_delay_screensaver_start?KDesktopSettings::timeout()*1000:10*1000; + + 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); + XChangeProperty(tqt_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 ); + + TQLabel *pixLabel = NULL; + if (!trinity_desktop_lock_use_system_modal_dialogs) { + pixLabel = new TQLabel( frame, "pixlabel" ); + pixLabel->setPixmap(DesktopIcon("system-lock-screen")); + } + + KUser user; + TQLabel *greetLabel; + if (trinity_desktop_lock_use_system_modal_dialogs) { + greetLabel = new TQLabel( user.fullName().isEmpty() ? + "<b>" + i18n("This computer is in use and has been locked.") + "</b>" : + "<b>" + i18n("This computer is in use and has been locked.") + "</b><br><nobr>" + i18n("Only '%1' may unlock this session.").arg( user.fullName() ), frame ); + } + else { + greetLabel = new TQLabel( user.fullName().isEmpty() ? + i18n("<nobr><b>The session is locked</b><br>") : + i18n("<nobr><b>The session was locked by %1</b><br>").arg( user.fullName() ), frame ); + } + + TQLabel *lockDTLabel = NULL; + if ((trinity_desktop_lock_use_system_modal_dialogs) && (!m_lockStartDT.isNull())) { + lockDTLabel = new TQLabel(i18n("This session has been locked since %1").arg(m_lockStartDT.toString()), frame); + } + + mStatusLabel = new TQLabel( "<b> </b>", frame ); + mStatusLabel->setAlignment( TQLabel::AlignCenter ); + + mLayoutButton = new TQPushButton( frame ); + mLayoutButton->setFlat( true ); + + KSeparator *sep = new KSeparator( KSeparator::HLine, frame ); + + mNewSessButton = new KPushButton( KGuiItem(i18n("Sw&itch User..."), "fork"), frame ); + ok = new KPushButton( i18n("Unl&ock"), frame ); + ok->setDefault(true); + + bool show_cancel_button = !trinity_desktop_lock_hide_cancel_button + || trinity_desktop_lock_use_sak + || !trinity_desktop_lock_use_system_modal_dialogs; + if (show_cancel_button) { + cancel = new KPushButton( KStdGuiItem::cancel(), frame ); + } + else { + cancel = NULL; + } + + greet = plugin->info->create( this, 0, this, mLayoutButton, TQString::null, + KGreeterPlugin::Authenticate, KGreeterPlugin::ExUnlock ); + + TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); + unlockDialogLayout->addWidget( frame ); + + TQHBoxLayout *layStatus = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); + layStatus->addWidget( mStatusLabel ); + layStatus->addWidget( mLayoutButton ); + + TQHBoxLayout *layButtons = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); + layButtons->addWidget( mNewSessButton ); + layButtons->addStretch(); + layButtons->addWidget(ok); + if (show_cancel_button) { + layButtons->addWidget(cancel); + } + + if (trinity_desktop_lock_use_system_modal_dialogs) { + KSMModalDialogHeader* theader = new KSMModalDialogHeader( frame ); + + if (!m_lockStartDT.isNull()) { + frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); + frameLayout->addMultiCellWidget( theader, 0, 0, 0, 2, TQt::AlignTop ); + frameLayout->addWidget( greetLabel, 1, 1 ); + frameLayout->addWidget( lockDTLabel, 2, 1 ); + frameLayout->addItem( greet->getLayoutItem(), 3, 1 ); + frameLayout->addLayout( layStatus, 4, 1 ); + frameLayout->addMultiCellWidget( sep, 5, 5, 0, 1 ); + frameLayout->addMultiCellLayout( layButtons, 6, 6, 0, 1 ); + } + else { + frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); + frameLayout->addMultiCellWidget( theader, 0, 0, 0, 2, TQt::AlignTop ); + frameLayout->addWidget( greetLabel, 1, 1 ); + frameLayout->addItem( greet->getLayoutItem(), 2, 1 ); + frameLayout->addLayout( layStatus, 3, 1 ); + frameLayout->addMultiCellWidget( sep, 4, 4, 0, 1 ); + frameLayout->addMultiCellLayout( layButtons, 5, 5, 0, 1 ); + } + } + else { + frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); + frameLayout->addMultiCellWidget( pixLabel, 0, 2, 0, 0, TQt::AlignTop ); + frameLayout->addWidget( greetLabel, 0, 1 ); + frameLayout->addItem( greet->getLayoutItem(), 1, 1 ); + frameLayout->addLayout( layStatus, 2, 1 ); + frameLayout->addMultiCellWidget( sep, 3, 3, 0, 1 ); + frameLayout->addMultiCellLayout( layButtons, 4, 4, 0, 1 ); + } + + if (show_cancel_button) { + setTabOrder( ok, cancel ); + setTabOrder( cancel, mNewSessButton ); + } + else { + setTabOrder( ok, mNewSessButton ); + } + setTabOrder( mNewSessButton, mLayoutButton ); + + connect(mLayoutButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(layoutClicked())); + if (show_cancel_button) { + connect(cancel, TQ_SIGNAL(clicked()), TQ_SLOT(reject())); + } + connect(ok, TQ_SIGNAL(clicked()), TQ_SLOT(slotOK())); + connect(mNewSessButton, TQ_SIGNAL(clicked()), TQ_SLOT(slotSwitchUser())); + + if (!DM().isSwitchable() || !tdeApp->authorize("switch_user")) { + mNewSessButton->hide(); + } + + installEventFilter(this); + setFixedSize( sizeHint() ); + + mFailedTimerId = 0; + mTimeoutTimerId = startTimer(PASSDLG_HIDE_TIMEOUT); + connect(tqApp, TQ_SIGNAL(activity()), TQ_SLOT(slotActivity()) ); + + greet->setInfoMessageDisplay(showInfoMessages); + greet->start(); + + DCOPRef kxkb("kxkb", "kxkb"); + if( !kxkb.isNull() ) { + DCOPReply reply = kxkb.call("getLayoutsList"); + if (reply.isValid()) { + layoutsList = reply; + } + reply = kxkb.call("getCurrentLayout"); + TQString currentLayout; + if (reply.isValid()) { + reply.get(currentLayout); + } + if( !currentLayout.isEmpty() && layoutsList.count() > 1 ) { + currLayout = layoutsList.find(currentLayout); + if (currLayout == layoutsList.end()) + setLayoutText("err"); + else + setLayoutText(*currLayout); + } + else { + mLayoutButton->hide(); + } + } + else { + mLayoutButton->hide(); // no kxkb running + } + capsLocked(); + + if (static_cast< LockProcess* >(parent())->cryptographicCardDevice()) { + attemptCardLogin(); + } } PasswordDlg::~PasswordDlg() { - hide(); - frameLayout->removeItem( greet->getLayoutItem() ); - delete greet; + hide(); + frameLayout->removeItem( greet->getLayoutItem() ); + delete greet; } void PasswordDlg::reject() { - if (!trinity_desktop_lock_hide_cancel_button || trinity_desktop_lock_use_sak || - !trinity_desktop_lock_use_system_modal_dialogs || trinity_desktop_lock_autohide_lockdlg) - { - TQDialog::reject(); - } + if (!trinity_desktop_lock_hide_cancel_button + || trinity_desktop_lock_use_sak + || !trinity_desktop_lock_use_system_modal_dialogs + || trinity_desktop_lock_autohide_lockdlg) { + TQDialog::reject(); + } } void PasswordDlg::layoutClicked() { + if( ++currLayout == layoutsList.end() ) { + currLayout = layoutsList.begin(); + } - if( ++currLayout == layoutsList.end() ) - currLayout = layoutsList.begin(); - - DCOPRef kxkb("kxkb", "kxkb"); - setLayoutText( kxkb.call("setLayout", *currLayout) ? *currLayout : "err" ); + DCOPRef kxkb("kxkb", "kxkb"); + setLayoutText( kxkb.call("setLayout", *currLayout) ? *currLayout : "err" ); } void PasswordDlg::setLayoutText( const TQString &txt ) { - mLayoutButton->setText( txt ); - TQSize sz = mLayoutButton->fontMetrics().size( 0, txt ); - int mrg = mLayoutButton->style().pixelMetric( TQStyle::PM_ButtonMargin ) * 2; - mLayoutButton->setFixedSize( sz.width() + mrg, sz.height() + mrg ); + mLayoutButton->setText( txt ); + TQSize sz = mLayoutButton->fontMetrics().size( 0, txt ); + int mrg = mLayoutButton->style().pixelMetric( TQStyle::PM_ButtonMargin ) * 2; + mLayoutButton->setFixedSize( sz.width() + mrg, sz.height() + mrg ); } void PasswordDlg::updateLabel() { - if (mUnlockingFailed) - { - mStatusLabel->setPaletteForegroundColor(Qt::black); - mStatusLabel->setText(i18n("<b>Unlocking failed</b>")); -// mStatusLabel->show(); - } - else - if (mCapsLocked) - { - mStatusLabel->setPaletteForegroundColor(Qt::red); - mStatusLabel->setText(i18n("<b>Warning: Caps Lock on</b>")); -// mStatusLabel->show(); - } - else - { - mStatusLabel->setText("<b> </b>"); -// mStatusLabel->hide(); - } + if (mUnlockingFailed) { + mStatusLabel->setPaletteForegroundColor(TQt::black); + mStatusLabel->setText(i18n("<b>Unlocking failed</b>")); +// mStatusLabel->show(); + } + else if (mCapsLocked) { + mStatusLabel->setPaletteForegroundColor(TQt::red); + mStatusLabel->setText(i18n("<b>Warning: Caps Lock on</b>")); +// mStatusLabel->show(); + } + else { + mStatusLabel->setText("<b> </b>"); +// mStatusLabel->hide(); + } } //--------------------------------------------------------------------------- @@ -329,240 +350,298 @@ void PasswordDlg::updateLabel() // void PasswordDlg::timerEvent(TQTimerEvent *ev) { - if (ev->timerId() == mTimeoutTimerId) - { - if (trinity_desktop_lock_autohide_lockdlg) - { - // Force dialog rejection regardless of the value of trinity_desktop_lock_hide_cancel_button - TQDialog::reject(); - } - else - { - slotActivity(); - } - } - else if (ev->timerId() == mFailedTimerId) - { - killTimer(mFailedTimerId); - mFailedTimerId = 0; - // Show the normal password prompt. - mUnlockingFailed = false; - updateLabel(); - ok->setEnabled(true); - if (cancel) cancel->setEnabled(true); - mNewSessButton->setEnabled( true ); - greet->revive(); - greet->start(); - } + if (ev->timerId() == mTimeoutTimerId) { + if (trinity_desktop_lock_autohide_lockdlg) { + // Force dialog rejection regardless of the value of trinity_desktop_lock_hide_cancel_button + TQDialog::reject(); + } + else { + slotActivity(); + } + } + else if (ev->timerId() == mFailedTimerId) { + killTimer(mFailedTimerId); + mFailedTimerId = 0; + // Show the normal password prompt. + mUnlockingFailed = false; + updateLabel(); + ok->setEnabled(true); + if (cancel) { + cancel->setEnabled(true); + } + mNewSessButton->setEnabled( true ); + greet->revive(); + greet->start(); + } } bool PasswordDlg::eventFilter(TQObject *, TQEvent *ev) { - if (ev->type() == TQEvent::KeyPress || ev->type() == TQEvent::KeyRelease) - capsLocked(); - return false; + if (ev->type() == TQEvent::KeyPress || ev->type() == TQEvent::KeyRelease) { + capsLocked(); + } + return false; } void PasswordDlg::slotActivity() { - if (mTimeoutTimerId) { - killTimer(mTimeoutTimerId); - mTimeoutTimerId = startTimer(PASSDLG_HIDE_TIMEOUT); - } + if (mTimeoutTimerId) { + killTimer(mTimeoutTimerId); + mTimeoutTimerId = startTimer(PASSDLG_HIDE_TIMEOUT); + } } ////// kckeckpass interface code int PasswordDlg::Reader (void *buf, int count) { - int ret, rlen; - - for (rlen = 0; rlen < count; ) { - dord: - ret = ::read (sFd, (void *)((char *)buf + rlen), count - rlen); - if (ret < 0) { - if (errno == EINTR) - goto dord; - if (errno == EAGAIN) - break; - return -1; - } - if (!ret) - break; - rlen += ret; - } - return rlen; + int ret, rlen; + + for (rlen = 0; rlen < count; ) { +dord: + ret = ::read (sFd, (void *)((char *)buf + rlen), count - rlen); + if (ret < 0) { + if (errno == EINTR) { + goto dord; + } + if (errno == EAGAIN) { + break; + } + return -1; + } + if (!ret) { + break; + } + rlen += ret; + } + return rlen; } bool PasswordDlg::GRead (void *buf, int count) { - return Reader (buf, count) == count; + return Reader (buf, count) == count; } bool PasswordDlg::GWrite (const void *buf, int count) { - return ::write (sFd, buf, count) == count; + return ::write (sFd, buf, count) == count; } bool PasswordDlg::GSendInt (int val) { - return GWrite (&val, sizeof(val)); + return GWrite (&val, sizeof(val)); } bool PasswordDlg::GSendStr (const char *buf) { - int len = buf ? ::strlen (buf) + 1 : 0; - return GWrite (&len, sizeof(len)) && GWrite (buf, len); + int len = buf ? ::strlen (buf) + 1 : 0; + return GWrite (&len, sizeof(len)) && GWrite (buf, len); } bool PasswordDlg::GSendArr (int len, const char *buf) { - return GWrite (&len, sizeof(len)) && GWrite (buf, len); + return GWrite (&len, sizeof(len)) && GWrite (buf, len); } bool PasswordDlg::GRecvInt (int *val) { - return GRead (val, sizeof(*val)); + return GRead (val, sizeof(*val)); } bool PasswordDlg::GRecvArr (char **ret) { - int len; - char *buf; - - if (!GRecvInt(&len)) - return false; - if (!len) { - *ret = 0; - return true; - } - if (!(buf = (char *)::malloc (len))) - return false; - *ret = buf; - return GRead (buf, len); + int len; + char *buf; + + if (!GRecvInt(&len)) { + return false; + } + if (!len) { + *ret = 0; + return true; + } + if (!(buf = (char *)::malloc (len))) { + return false; + } + *ret = buf; + return GRead (buf, len); } void PasswordDlg::reapVerify() { - ::close( sFd ); - int status; - pid_t retpid = ::waitpid( sPid, &status, 0 ); - if (retpid < 0) { - // FIXME - // ERROR - } - else { - if (WIFEXITED(status)) { - switch (WEXITSTATUS(status)) { - case AuthOk: - greet->succeeded(); - accept(); - return; - case AuthBad: - greet->failed(); - mUnlockingFailed = true; - updateLabel(); - mFailedTimerId = startTimer(1500); - ok->setEnabled(false); - if (cancel) cancel->setEnabled(false); - mNewSessButton->setEnabled( false ); - return; - case AuthAbort: - return; - } - } - else if (WIFSIGNALED(status)) { - // FIXME - // ERROR - } - } - cantCheck(); + ::close( sFd ); + int status; + pid_t retpid = ::waitpid( sPid, &status, 0 ); + if (retpid < 0) { + // FIXME + // ERROR + } + else { + if (WIFEXITED(status)) { + switch (WEXITSTATUS(status)) { + case AuthOk: + { +#ifdef WITH_TDEHWLIB + KUser userinfo; + TQString fileName = userinfo.homeDir() + "/.tde_card_login_state"; + TQFile flagFile(fileName); + if (validUserCardInserted) { + // Card was likely used to log in + if (flagFile.open(IO_WriteOnly)) { + flagFile.writeBlock("1\n", 2); + flagFile.close(); + } + } + else { + // Card was not used to log in + flagFile.remove(); + } +#endif + + // Signal success + greet->succeeded(); + accept(); + return; + } + case AuthBad: + greet->failed(); + mUnlockingFailed = true; + updateLabel(); + mFailedTimerId = startTimer(1500); + ok->setEnabled(false); + if (cancel) { + cancel->setEnabled(false); + } + mNewSessButton->setEnabled( false ); + return; + case AuthAbort: + return; + } + } + else if (WIFSIGNALED(status)) { + // FIXME + // ERROR + } + } + cantCheck(); } void PasswordDlg::handleVerify() { - int ret; - char *arr; - - while (GRecvInt( &ret )) { - switch (ret) { - case ConvGetBinary: - if (!GRecvArr( &arr )) - break; - greet->binaryPrompt( arr, false ); - if (arr) - ::free( arr ); - return; - case ConvGetNormal: - if (!GRecvArr( &arr )) - break; - greet->textPrompt( arr, true, false ); - if (arr) - ::free( arr ); - return; - case ConvGetHidden: - if (!GRecvArr( &arr )) - break; - greet->textPrompt( arr, false, false ); - if (arr) - ::free( arr ); - return; - case ConvPutInfo: - if (!GRecvArr( &arr )) - break; - if (!greet->textMessage( arr, false )) - static_cast< LockProcess* >(parent())->msgBox( TQMessageBox::Information, TQString::fromLocal8Bit( arr ) ); - ::free( arr ); - continue; - case ConvPutError: - if (!GRecvArr( &arr )) - break; - if (!greet->textMessage( arr, true )) - static_cast< LockProcess* >(parent())->msgBox( TQMessageBox::Warning, TQString::fromLocal8Bit( arr ) ); - ::free( arr ); - continue; - } - break; - } - reapVerify(); + int ret; + char *arr; + + while (GRecvInt( &ret )) { + switch (ret) { + case ConvGetBinary: + if (!GRecvArr( &arr )) + break; + greet->binaryPrompt( arr, false ); + if (arr) + ::free( arr ); + return; + case ConvGetNormal: + if (!GRecvArr( &arr )) + break; + greet->textPrompt( arr, true, false ); + if (arr) + ::free( arr ); + return; + case ConvGetHidden: + if (!GRecvArr( &arr )) + break; + if (arr && (arr[0] != 0)) { + // Reset password entry and change text + greet->start(); + greet->textPrompt( arr, false, false ); + + // Force relayout + setFixedSize( sizeHint().width(), sizeHint().height() + 1 ); + setFixedSize( sizeHint() ); + +#ifdef WITH_TDEHWLIB + // Check if cryptographic card login is being used + if (mCardLoginInProgress) { + // Attempt authentication if configured + TDECryptographicCardDevice* cdevice = static_cast<LockProcess*>(parent())->cryptographicCardDevice(); + if (cdevice) { + TQString autoPIN = cdevice->autoPIN(); + if (autoPIN != TQString::null) { + greet->setPassword(autoPIN); + TQTimer::singleShot(0, this, TQ_SLOT(slotOK())); + } + } + mCardLoginInProgress = false; + } +#endif + } + else { + greet->textPrompt( arr, false, false ); + } + if (arr) + ::free( arr ); + return; + case ConvPutInfo: + if (!GRecvArr( &arr )) + break; + if (!greet->textMessage( arr, false )) + static_cast< LockProcess* >(parent())->msgBox( TQMessageBox::Information, TQString::fromLocal8Bit( arr ) ); + ::free( arr ); + continue; + case ConvPutError: + if (!GRecvArr( &arr )) + break; + if (!greet->textMessage( arr, true )) + static_cast< LockProcess* >(parent())->msgBox( TQMessageBox::Warning, TQString::fromLocal8Bit( arr ) ); + ::free( arr ); + continue; + } + break; + } + reapVerify(); } ////// greeter plugin callbacks void PasswordDlg::gplugReturnText( const char *text, int tag ) { - GSendStr( text ); - if (text) - GSendInt( tag ); - handleVerify(); + GSendStr( text ); + if (text) { + GSendInt( tag ); + } + handleVerify(); } void PasswordDlg::gplugReturnBinary( const char *data ) { - if (data) { - unsigned const char *up = (unsigned const char *)data; - int len = up[3] | (up[2] << 8) | (up[1] << 16) | (up[0] << 24); - if (!len) - GSendArr( 4, data ); - else - GSendArr( len, data ); - } else - GSendArr( 0, 0 ); - handleVerify(); + if (data) { + unsigned const char *up = (unsigned const char *)data; + int len = up[3] | (up[2] << 8) | (up[1] << 16) | (up[0] << 24); + if (!len) { + GSendArr( 4, data ); + } + else { + GSendArr( len, data ); + } + } + else { + GSendArr( 0, 0 ); + } + handleVerify(); } void PasswordDlg::gplugSetUser( const TQString & ) { - // ignore ... + // ignore ... } void PasswordDlg::cantCheck() { - greet->failed(); - static_cast< LockProcess* >(parent())->msgBox( TQMessageBox::Critical, - i18n("Cannot unlock the session because the authentication system failed to work;\n" - "you must kill kdesktop_lock (pid %1) manually.").arg(getpid()) ); - greet->revive(); + greet->failed(); + static_cast< LockProcess* >(parent())->msgBox( TQMessageBox::Critical, + i18n("Cannot unlock the session because the authentication system failed to work;\n" + "you must kill kdesktop_lock (pid %1) manually.").arg(getpid()) ); + greet->revive(); } //--------------------------------------------------------------------------- @@ -571,330 +650,393 @@ void PasswordDlg::cantCheck() // void PasswordDlg::gplugStart() { - int sfd[2]; - char fdbuf[16]; - - if (::socketpair(AF_LOCAL, SOCK_STREAM, 0, sfd)) { - cantCheck(); - return; - } - if ((sPid = ::fork()) < 0) { - ::close(sfd[0]); - ::close(sfd[1]); - cantCheck(); - return; - } - if (!sPid) { - ::close(sfd[0]); - sprintf(fdbuf, "%d", sfd[1]); - execlp("kcheckpass", "kcheckpass", + int sfd[2]; + char fdbuf[16]; + + if (::socketpair(AF_LOCAL, SOCK_STREAM, 0, sfd)) { + cantCheck(); + return; + } + if ((sPid = ::fork()) < 0) { + ::close(sfd[0]); + ::close(sfd[1]); + cantCheck(); + return; + } + if (!sPid) { + ::close(sfd[0]); + sprintf(fdbuf, "%d", sfd[1]); + execlp("kcheckpass", "kcheckpass", #ifdef HAVE_PAM - "-c", TDESCREENSAVER_PAM_SERVICE, + "-c", TDESCREENSAVER_PAM_SERVICE, #endif - "-m", mPlugin->info->method, - "-S", fdbuf, - (char *)0); - exit(20); - } - ::close(sfd[1]); - sFd = sfd[0]; - handleVerify(); + "-m", mPlugin->info->method, + "-S", fdbuf, + (char *)0); + exit(20); + } + ::close(sfd[1]); + sFd = sfd[0]; + handleVerify(); } void PasswordDlg::gplugActivity() { - slotActivity(); + slotActivity(); } void PasswordDlg::gplugMsgBox( TQMessageBox::Icon type, const TQString &text ) { - TQDialog dialog( this, 0, true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM)) ); - 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); - XChangeProperty(tqt_xdisplay(), dialog.winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); - } - dialog.setCaption(i18n("Authentication Subsystem Notice")); - TQFrame *winFrame = new TQFrame( &dialog ); - if (trinity_desktop_lock_use_system_modal_dialogs) - winFrame->setFrameStyle( TQFrame::NoFrame ); - else - winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised ); - winFrame->setLineWidth( 2 ); - TQVBoxLayout *vbox = new TQVBoxLayout( &dialog ); - vbox->addWidget( winFrame ); - - TQLabel *label1 = new TQLabel( winFrame ); - label1->setPixmap( TQMessageBox::standardIcon( type ) ); - TQLabel *label2 = new TQLabel( text, winFrame ); - KPushButton *button = new KPushButton( KStdGuiItem::ok(), winFrame ); - button->setDefault( true ); - button->setSizePolicy( TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Preferred ) ); - connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( accept() ) ); - - TQGridLayout *grid = new TQGridLayout( winFrame, 2, 2, 10 ); - grid->addWidget( label1, 0, 0, Qt::AlignCenter ); - grid->addWidget( label2, 0, 1, Qt::AlignCenter ); - grid->addMultiCellWidget( button, 1,1, 0,1, Qt::AlignCenter ); - - static_cast< LockProcess* >(parent())->execDialog( &dialog ); + TQDialog dialog( this, 0, true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM)) ); + 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); + XChangeProperty(tqt_xdisplay(), dialog.winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); + } + dialog.setCaption(i18n("Authentication Subsystem Notice")); + TQFrame *winFrame = new TQFrame( &dialog ); + if (trinity_desktop_lock_use_system_modal_dialogs) { + winFrame->setFrameStyle( TQFrame::NoFrame ); + } + else { + winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised ); + } + winFrame->setLineWidth( 2 ); + TQVBoxLayout *vbox = new TQVBoxLayout( &dialog ); + vbox->addWidget( winFrame ); + + TQLabel *label1 = new TQLabel( winFrame ); + label1->setPixmap( TQMessageBox::standardIcon( type ) ); + TQLabel *label2 = new TQLabel( text, winFrame ); + KPushButton *button = new KPushButton( KStdGuiItem::ok(), winFrame ); + button->setDefault( true ); + button->setSizePolicy( TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Preferred ) ); + connect( button, TQ_SIGNAL( clicked() ), TQ_SLOT( accept() ) ); + + TQGridLayout *grid = new TQGridLayout( winFrame, 2, 2, 10 ); + grid->addWidget( label1, 0, 0, TQt::AlignCenter ); + grid->addWidget( label2, 0, 1, TQt::AlignCenter ); + grid->addMultiCellWidget( button, 1,1, 0,1, TQt::AlignCenter ); + + static_cast< LockProcess* >(parent())->execDialog( &dialog ); } void PasswordDlg::slotOK() { - greet->next(); + greet->next(); } void PasswordDlg::show() { - TQDialog::show(); - TQApplication::flushX(); - setFixedSize( sizeHint() ); + TQDialog::show(); + TQApplication::flushX(); + setFixedSize( sizeHint() ); } void PasswordDlg::slotStartNewSession() { - if (!KMessageBox::shouldBeShownContinue( ":confirmNewSession" )) { - DM().startReserve(); - return; - } - - killTimer(mTimeoutTimerId); - mTimeoutTimerId = 0; - - TQDialog *dialog = new TQDialog( this, "warnbox", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))); - - 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); - XChangeProperty(tqt_xdisplay(), dialog->winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); - } - dialog->setCaption(i18n("New Session")); - - TQFrame *winFrame = new TQFrame( dialog ); - if (trinity_desktop_lock_use_system_modal_dialogs) - winFrame->setFrameStyle( TQFrame::NoFrame ); - else - winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised ); - winFrame->setLineWidth( 2 ); - TQVBoxLayout *vbox = new TQVBoxLayout( dialog ); - vbox->addWidget( winFrame ); - - TQLabel *label1 = new TQLabel( winFrame ); - label1->setPixmap( TQMessageBox::standardIcon( TQMessageBox::Warning ) ); - TQString qt_text = - i18n("You have chosen to open another desktop session " - "instead of resuming the current one.<br>" - "The current session will be hidden " - "and a new login screen will be displayed.<br>" - "An F-key is assigned to each session; " - "F%1 is usually assigned to the first session, " - "F%2 to the second session and so on. " - "You can switch between sessions by pressing " - "Ctrl, Alt and the appropriate F-key at the same time. " - "Additionally, the TDE Panel and Desktop menus have " - "actions for switching between sessions.") - .arg(7).arg(8); - TQLabel *label2 = new TQLabel( qt_text, winFrame ); - KPushButton *okbutton = new KPushButton( KGuiItem(i18n("&Start New Session"), "fork"), winFrame ); - okbutton->setDefault( true ); - connect( okbutton, TQT_SIGNAL( clicked() ), dialog, TQT_SLOT( accept() ) ); - KPushButton *cbutton = new KPushButton( KStdGuiItem::cancel(), winFrame ); - connect( cbutton, TQT_SIGNAL( clicked() ), dialog, TQT_SLOT( reject() ) ); - - TQBoxLayout *mbox = new TQVBoxLayout( winFrame, KDialog::marginHint(), KDialog::spacingHint() ); - - TQGridLayout *grid = new TQGridLayout( mbox, 2, 2, 2 * KDialog::spacingHint() ); - grid->setMargin( KDialog::marginHint() ); - grid->addWidget( label1, 0, 0, Qt::AlignCenter ); - grid->addWidget( label2, 0, 1, Qt::AlignCenter ); - TQCheckBox *cb = new TQCheckBox( i18n("&Do not ask again"), winFrame ); - grid->addMultiCellWidget( cb, 1,1, 0,1 ); - - TQBoxLayout *hbox = new TQHBoxLayout( mbox, KDialog::spacingHint() ); - hbox->addStretch( 1 ); - hbox->addWidget( okbutton ); - hbox->addStretch( 1 ); - hbox->addWidget( cbutton ); - hbox->addStretch( 1 ); - - // stolen from kmessagebox - int pref_width = 0; - int pref_height = 0; - // Calculate a proper size for the text. - { - TQSimpleRichText rt(qt_text, dialog->font()); - TQRect rect = TDEGlobalSettings::desktopGeometry(dialog); - - pref_width = rect.width() / 3; - rt.setWidth(pref_width); - int used_width = rt.widthUsed(); - pref_height = rt.height(); - if (used_width <= pref_width) - { - while(true) - { - int new_width = (used_width * 9) / 10; - rt.setWidth(new_width); - int new_height = rt.height(); - if (new_height > pref_height) - break; - used_width = rt.widthUsed(); - if (used_width > new_width) - break; - } - pref_width = used_width; - } - else - { - if (used_width > (pref_width *2)) - pref_width = pref_width *2; - else - pref_width = used_width; - } - } - label2->setFixedSize(TQSize(pref_width+10, pref_height)); - - int ret = static_cast< LockProcess* >( parent())->execDialog( dialog ); - - delete dialog; - - if (ret == TQDialog::Accepted) { - if (cb->isChecked()) - KMessageBox::saveDontShowAgainContinue( ":confirmNewSession" ); - DM().startReserve(); - } - - mTimeoutTimerId = startTimer(PASSDLG_HIDE_TIMEOUT); + if (!KMessageBox::shouldBeShownContinue( ":confirmNewSession" )) { + DM().startReserve(); + return; + } + + killTimer(mTimeoutTimerId); + mTimeoutTimerId = 0; + + TQDialog *dialog = new TQDialog( this, "warnbox", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))); + + 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); + XChangeProperty(tqt_xdisplay(), dialog->winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); + } + dialog->setCaption(i18n("New Session")); + + TQFrame *winFrame = new TQFrame( dialog ); + if (trinity_desktop_lock_use_system_modal_dialogs) { + winFrame->setFrameStyle( TQFrame::NoFrame ); + } + else { + winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised ); + } + winFrame->setLineWidth( 2 ); + TQVBoxLayout *vbox = new TQVBoxLayout( dialog ); + vbox->addWidget( winFrame ); + + TQLabel *label1 = new TQLabel( winFrame ); + label1->setPixmap( TQMessageBox::standardIcon( TQMessageBox::Warning ) ); + TQString qt_text = i18n("You have chosen to open another desktop session " + "instead of resuming the current one.<br>" + "The current session will be hidden " + "and a new login screen will be displayed.<br>" + "An F-key is assigned to each session; " + "F%1 is usually assigned to the first session, " + "F%2 to the second session and so on. " + "You can switch between sessions by pressing " + "Ctrl, Alt and the appropriate F-key at the same time. " + "Additionally, the TDE Panel and Desktop menus have " + "actions for switching between sessions.") + .arg(7).arg(8); + TQLabel *label2 = new TQLabel( qt_text, winFrame ); + KPushButton *okbutton = new KPushButton( KGuiItem(i18n("&Start New Session"), "fork"), winFrame ); + okbutton->setDefault( true ); + connect( okbutton, TQ_SIGNAL( clicked() ), dialog, TQ_SLOT( accept() ) ); + KPushButton *cbutton = new KPushButton( KStdGuiItem::cancel(), winFrame ); + connect( cbutton, TQ_SIGNAL( clicked() ), dialog, TQ_SLOT( reject() ) ); + + TQBoxLayout *mbox = new TQVBoxLayout( winFrame, KDialog::marginHint(), KDialog::spacingHint() ); + + TQGridLayout *grid = new TQGridLayout( mbox, 2, 2, 2 * KDialog::spacingHint() ); + grid->setMargin( KDialog::marginHint() ); + grid->addWidget( label1, 0, 0, TQt::AlignCenter ); + grid->addWidget( label2, 0, 1, TQt::AlignCenter ); + TQCheckBox *cb = new TQCheckBox( i18n("&Do not ask again"), winFrame ); + grid->addMultiCellWidget( cb, 1,1, 0,1 ); + + TQBoxLayout *hbox = new TQHBoxLayout( mbox, KDialog::spacingHint() ); + hbox->addStretch( 1 ); + hbox->addWidget( okbutton ); + hbox->addStretch( 1 ); + hbox->addWidget( cbutton ); + hbox->addStretch( 1 ); + + // stolen from kmessagebox + int pref_width = 0; + int pref_height = 0; + // Calculate a proper size for the text. + { + TQSimpleRichText rt(qt_text, dialog->font()); + TQRect rect = TDEGlobalSettings::desktopGeometry(dialog); + + pref_width = rect.width() / 3; + rt.setWidth(pref_width); + int used_width = rt.widthUsed(); + pref_height = rt.height(); + if (used_width <= pref_width) { + while(true) { + int new_width = (used_width * 9) / 10; + rt.setWidth(new_width); + int new_height = rt.height(); + if (new_height > pref_height) { + break; + } + used_width = rt.widthUsed(); + if (used_width > new_width) { + break; + } + } + pref_width = used_width; + } + else { + if (used_width > (pref_width *2)) + pref_width = pref_width *2; + else + pref_width = used_width; + } + } + label2->setFixedSize(TQSize(pref_width+10, pref_height)); + + int ret = static_cast< LockProcess* >( parent())->execDialog( dialog ); + + delete dialog; + + if (ret == TQDialog::Accepted) { + if (cb->isChecked()) { + KMessageBox::saveDontShowAgainContinue( ":confirmNewSession" ); + } + DM().startReserve(); + } + + mTimeoutTimerId = startTimer(PASSDLG_HIDE_TIMEOUT); } class LockListViewItem : public TQListViewItem { -public: - LockListViewItem( TQListView *parent, - const TQString &sess, const TQString &loc, int _vt ) - : TQListViewItem( parent ) - , vt( _vt ) - { - setText( 0, sess ); - setText( 1, loc ); - } - - int vt; + public: + LockListViewItem( TQListView *parent, const TQString &sess, const TQString &loc, int _vt ) : TQListViewItem( parent ) + , vt( _vt ) + { + setText( 0, sess ); + setText( 1, loc ); + } + + int vt; }; void PasswordDlg::slotSwitchUser() { - int p = 0; - DM dm; - - TQDialog dialog( this, "sessbox", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM)) ); - - 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); - XChangeProperty(tqt_xdisplay(), dialog.winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); - } - dialog.setCaption(i18n("Switch User")); - - TQFrame *winFrame = new TQFrame( &dialog ); - if (trinity_desktop_lock_use_system_modal_dialogs) - winFrame->setFrameStyle( TQFrame::NoFrame ); - else - winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised ); - winFrame->setLineWidth( 2 ); - TQBoxLayout *vbox = new TQVBoxLayout( &dialog ); - vbox->addWidget( winFrame ); - - TQBoxLayout *hbox = new TQHBoxLayout( winFrame, KDialog::marginHint(), KDialog::spacingHint() ); - - TQBoxLayout *vbox1 = new TQVBoxLayout( hbox, KDialog::spacingHint() ); - TQBoxLayout *vbox2 = new TQVBoxLayout( hbox, KDialog::spacingHint() ); - - KPushButton *btn; - - SessList sess; - if (dm.localSessions( sess )) { - - lv = new TQListView( winFrame ); - connect( lv, TQT_SIGNAL(doubleClicked(TQListViewItem *, const TQPoint&, int)), TQT_SLOT(slotSessionActivated()) ); - connect( lv, TQT_SIGNAL(doubleClicked(TQListViewItem *, const TQPoint&, int)), &dialog, TQT_SLOT(accept()) ); - lv->setAllColumnsShowFocus( true ); - lv->addColumn( i18n("Session") ); - lv->addColumn( i18n("Location") ); - lv->setColumnWidthMode( 0, TQListView::Maximum ); - lv->setColumnWidthMode( 1, TQListView::Maximum ); - TQListViewItem *itm = 0; - TQString user, loc; - int ns = 0; - for (SessList::ConstIterator it = sess.begin(); it != sess.end(); ++it) { - DM::sess2Str2( *it, user, loc ); - itm = new LockListViewItem( lv, user, loc, (*it).vt ); - if (!(*it).vt) - itm->setEnabled( false ); - if ((*it).self) { - lv->setCurrentItem( itm ); - itm->setSelected( true ); - } - ns++; - } - int fw = lv->frameWidth() * 2; - TQSize hds( lv->header()->sizeHint() ); - lv->setMinimumWidth( fw + hds.width() + - (ns > 10 ? style().pixelMetric(TQStyle::PM_ScrollBarExtent) : 0 ) ); - lv->setFixedHeight( fw + hds.height() + - itm->height() * (ns < 6 ? 6 : ns > 10 ? 10 : ns) ); - lv->header()->adjustHeaderSize(); - vbox1->addWidget( lv ); - - btn = new KPushButton( KGuiItem(i18n("session", "&Activate"), "fork"), winFrame ); - connect( btn, TQT_SIGNAL(clicked()), TQT_SLOT(slotSessionActivated()) ); - connect( btn, TQT_SIGNAL(clicked()), &dialog, TQT_SLOT(accept()) ); - vbox2->addWidget( btn ); - vbox2->addStretch( 2 ); - } - - if (kapp->authorize("start_new_session") && (p = dm.numReserve()) >= 0) - { - btn = new KPushButton( KGuiItem(i18n("Start &New Session"), "fork"), winFrame ); - connect( btn, TQT_SIGNAL(clicked()), TQT_SLOT(slotStartNewSession()) ); - connect( btn, TQT_SIGNAL(clicked()), &dialog, TQT_SLOT(accept()) ); - if (!p) - btn->setEnabled( false ); - vbox2->addWidget( btn ); - vbox2->addStretch( 1 ); - } - - btn = new KPushButton( KStdGuiItem::cancel(), winFrame ); - connect( btn, TQT_SIGNAL(clicked()), &dialog, TQT_SLOT(reject()) ); - vbox2->addWidget( btn ); - - dialog.setFixedSize( dialog.sizeHint() ); - - int ret = static_cast< LockProcess* >(parent())->execDialog( &dialog ); - if (ret != TQDialog::Rejected) { - TQDialog::reject(); - } + int p = 0; + DM dm; + + TQDialog dialog( this, "sessbox", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM)) ); + + 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); + XChangeProperty(tqt_xdisplay(), dialog.winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); + } + dialog.setCaption(i18n("Switch User")); + + TQFrame *winFrame = new TQFrame( &dialog ); + if (trinity_desktop_lock_use_system_modal_dialogs) { + winFrame->setFrameStyle( TQFrame::NoFrame ); + } + else { + winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised ); + } + winFrame->setLineWidth( 2 ); + TQBoxLayout *vbox = new TQVBoxLayout( &dialog ); + vbox->addWidget( winFrame ); + + TQBoxLayout *hbox = new TQHBoxLayout( winFrame, KDialog::marginHint(), KDialog::spacingHint() ); + + TQBoxLayout *vbox1 = new TQVBoxLayout( hbox, KDialog::spacingHint() ); + TQBoxLayout *vbox2 = new TQVBoxLayout( hbox, KDialog::spacingHint() ); + + KPushButton *btn; + + SessList sess; + if (dm.localSessions( sess )) { + lv = new TQListView( winFrame ); + connect( lv, TQ_SIGNAL(doubleClicked(TQListViewItem *, const TQPoint&, int)), TQ_SLOT(slotSessionActivated()) ); + connect( lv, TQ_SIGNAL(doubleClicked(TQListViewItem *, const TQPoint&, int)), &dialog, TQ_SLOT(accept()) ); + lv->setAllColumnsShowFocus( true ); + lv->addColumn( i18n("Session") ); + lv->addColumn( i18n("Location") ); + lv->setColumnWidthMode( 0, TQListView::Maximum ); + lv->setColumnWidthMode( 1, TQListView::Maximum ); + TQListViewItem *itm = 0; + TQString user, loc; + int ns = 0; + for (SessList::ConstIterator it = sess.begin(); it != sess.end(); ++it) { + DM::sess2Str2( *it, user, loc ); + itm = new LockListViewItem( lv, user, loc, (*it).vt ); + if (!(*it).vt) { + itm->setEnabled( false ); + } + if ((*it).self) { + lv->setCurrentItem( itm ); + itm->setSelected( true ); + } + ns++; + } + int fw = lv->frameWidth() * 2; + TQSize hds( lv->header()->sizeHint() ); + lv->setMinimumWidth( fw + hds.width() + + (ns > 10 ? style().pixelMetric(TQStyle::PM_ScrollBarExtent) : 0 ) ); + lv->setFixedHeight( fw + hds.height() + + itm->height() * (ns < 6 ? 6 : ns > 10 ? 10 : ns) ); + lv->header()->adjustHeaderSize(); + vbox1->addWidget( lv ); + + btn = new KPushButton( KGuiItem(i18n("session", "&Activate"), "fork"), winFrame ); + connect( btn, TQ_SIGNAL(clicked()), TQ_SLOT(slotSessionActivated()) ); + connect( btn, TQ_SIGNAL(clicked()), &dialog, TQ_SLOT(accept()) ); + vbox2->addWidget( btn ); + vbox2->addStretch( 2 ); + } + + if (tdeApp->authorize("start_new_session") && (p = dm.numReserve()) >= 0) { + btn = new KPushButton( KGuiItem(i18n("Start &New Session"), "fork"), winFrame ); + connect( btn, TQ_SIGNAL(clicked()), TQ_SLOT(slotStartNewSession()) ); + connect( btn, TQ_SIGNAL(clicked()), &dialog, TQ_SLOT(accept()) ); + if (!p) + btn->setEnabled( false ); + vbox2->addWidget( btn ); + vbox2->addStretch( 1 ); + } + + btn = new KPushButton( KStdGuiItem::cancel(), winFrame ); + connect( btn, TQ_SIGNAL(clicked()), &dialog, TQ_SLOT(reject()) ); + vbox2->addWidget( btn ); + + dialog.setFixedSize( dialog.sizeHint() ); + + int ret = static_cast< LockProcess* >(parent())->execDialog( &dialog ); + if (ret != TQDialog::Rejected) { + TQDialog::reject(); + } } void PasswordDlg::slotSessionActivated() { - LockListViewItem *itm = (LockListViewItem *)lv->currentItem(); - if (itm && itm->vt > 0) - DM().switchVT( itm->vt ); + LockListViewItem *itm = (LockListViewItem *)lv->currentItem(); + if (itm && itm->vt > 0) { + DM().switchVT( itm->vt ); + } } void PasswordDlg::capsLocked() { - unsigned int lmask; - Window dummy1, dummy2; - int dummy3, dummy4, dummy5, dummy6; - XQueryPointer(tqt_xdisplay(), DefaultRootWindow( tqt_xdisplay() ), &dummy1, &dummy2, &dummy3, &dummy4, &dummy5, &dummy6, &lmask); - mCapsLocked = lmask & LockMask; - updateLabel(); + unsigned int lmask; + Window dummy1, dummy2; + int dummy3, dummy4, dummy5, dummy6; + XQueryPointer(tqt_xdisplay(), DefaultRootWindow( tqt_xdisplay() ), &dummy1, &dummy2, &dummy3, &dummy4, &dummy5, &dummy6, &lmask); + mCapsLocked = lmask & LockMask; + updateLabel(); +} + +void PasswordDlg::attemptCardLogin() { +#ifdef WITH_TDEHWLIB +#ifndef HAVE_KRB5 + // Don't enable card-based logins if Kerberos integration was disabled + return; +#endif + + // Make sure card logins are enabled before attempting one + TDESimpleConfig *systemconfig = new TDESimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/ldap/ldapconfigrc" )); + systemconfig->setGroup(NULL); + bool enabled = systemconfig->readBoolEntry("EnablePKCS11Login", false); + delete systemconfig; + if (!enabled) + { + return; + } + + if (mCardLoginInProgress) { + return; + } + mCardLoginInProgress = true; + + // FIXME + // pam_pkcs11 is extremely chatty with no apparent way to disable the unwanted messages + greet->setInfoMessageDisplay(false); + + validUserCardInserted = true; + greet->setPasswordPrompt(i18n("PIN:")); + + // Force relayout + setFixedSize(sizeHint().width(), sizeHint().height() + 1); + setFixedSize(sizeHint()); + + // Bypass initial password prompt + greet->start(); + greet->setPassword(""); + TQTimer::singleShot(0, this, TQ_SLOT(slotOK())); +#endif +} + +void PasswordDlg::resetCardLogin() { +#ifdef WITH_TDEHWLIB + validUserCardInserted = false; + greet->abort(); + greet->clear(); + greet->revive(); + greet->start(); + greet->setPasswordPrompt(TQString::null); + + // Force relayout + setFixedSize(sizeHint().width(), sizeHint().height() + 1); + setFixedSize(sizeHint()); + + // Restore information message display settings + greet->setInfoMessageDisplay(showInfoMessages); + + mCardLoginInProgress = false; +#endif } #include "lockdlg.moc" diff --git a/kdesktop/lock/lockdlg.h b/kdesktop/lock/lockdlg.h index 2ede5a4fa..3f8500a42 100644 --- a/kdesktop/lock/lockdlg.h +++ b/kdesktop/lock/lockdlg.h @@ -1,9 +1,10 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // // Copyright (c) 1999 Martin R. Jones <mjones@kde.org> // Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org> +// Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> // #ifndef __LOCKDLG_H__ @@ -32,69 +33,75 @@ class TQListView; // class PasswordDlg : public TQDialog, public KGreeterPluginHandler { - Q_OBJECT + TQ_OBJECT -public: - PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin); - PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin, TQDateTime lockStartDateTime); - ~PasswordDlg(); - void init(GreeterPluginHandle *plugin); - virtual void show(); + public: + PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin); + PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin, TQDateTime lockStartDateTime); + ~PasswordDlg(); + void init(GreeterPluginHandle *plugin); + virtual void show(); + + // from KGreetPluginHandler + virtual void gplugReturnText( const char *text, int tag ); + virtual void gplugReturnBinary( const char *data ); + virtual void gplugSetUser( const TQString & ); + virtual void gplugStart(); + virtual void gplugActivity(); + virtual void gplugMsgBox( TQMessageBox::Icon type, const TQString &text ); - // from KGreetPluginHandler - virtual void gplugReturnText( const char *text, int tag ); - virtual void gplugReturnBinary( const char *data ); - virtual void gplugSetUser( const TQString & ); - virtual void gplugStart(); - virtual void gplugActivity(); - virtual void gplugMsgBox( TQMessageBox::Icon type, const TQString &text ); - -protected: - virtual void timerEvent(TQTimerEvent *); - virtual bool eventFilter(TQObject *, TQEvent *); - -private slots: - void slotSwitchUser(); - void slotSessionActivated(); - void slotStartNewSession(); - void slotOK(); - void layoutClicked(); - void slotActivity(); - -protected slots: - virtual void reject(); - -private: - void setLayoutText( const TQString &txt ); - void capsLocked(); - void updateLabel(); - int Reader (void *buf, int count); - bool GRead (void *buf, int count); - bool GWrite (const void *buf, int count); - bool GSendInt (int val); - bool GSendStr (const char *buf); - bool GSendArr (int len, const char *buf); - bool GRecvInt (int *val); - bool GRecvArr (char **buf); - void handleVerify(); - void reapVerify(); - void cantCheck(); - GreeterPluginHandle *mPlugin; - KGreeterPlugin *greet; - TQFrame *frame; - TQGridLayout *frameLayout; - TQLabel *mStatusLabel; - KPushButton *mNewSessButton, *ok, *cancel; - TQPushButton *mLayoutButton; - int mFailedTimerId; - int mTimeoutTimerId; - int mCapsLocked; - bool mUnlockingFailed; - TQStringList layoutsList; - TQStringList::iterator currLayout; - int sPid, sFd; - TQListView *lv; - TQDateTime m_lockStartDT; + virtual void attemptCardLogin(); + virtual void resetCardLogin(); + + protected: + virtual void timerEvent(TQTimerEvent *); + virtual bool eventFilter(TQObject *, TQEvent *); + + private slots: + void slotSwitchUser(); + void slotSessionActivated(); + void slotStartNewSession(); + void slotOK(); + void layoutClicked(); + void slotActivity(); + + protected slots: + virtual void reject(); + + private: + void setLayoutText( const TQString &txt ); + void capsLocked(); + void updateLabel(); + int Reader (void *buf, int count); + bool GRead (void *buf, int count); + bool GWrite (const void *buf, int count); + bool GSendInt (int val); + bool GSendStr (const char *buf); + bool GSendArr (int len, const char *buf); + bool GRecvInt (int *val); + bool GRecvArr (char **buf); + void handleVerify(); + void reapVerify(); + void cantCheck(); + GreeterPluginHandle *mPlugin; + KGreeterPlugin *greet; + TQFrame *frame; + TQGridLayout *frameLayout; + TQLabel *mStatusLabel; + KPushButton *mNewSessButton, *ok, *cancel; + TQPushButton *mLayoutButton; + int mFailedTimerId; + int mTimeoutTimerId; + int mCapsLocked; + bool mUnlockingFailed; + bool validUserCardInserted; + bool showInfoMessages; + TQStringList layoutsList; + TQStringList::iterator currLayout; + int sPid, sFd; + TQListView *lv; + bool mCardLoginInProgress; + TQDateTime m_lockStartDT; }; #endif diff --git a/kdesktop/lock/lockprocess.cpp b/kdesktop/lock/lockprocess.cpp index 67492ea3c..2ad89f5ab 100644 --- a/kdesktop/lock/lockprocess.cpp +++ b/kdesktop/lock/lockprocess.cpp @@ -1,10 +1,10 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // // Copyright (c) 1999 Martin R. Jones <mjones@kde.org> // Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org> -// Copyright (c) 2010-2013 Timothy Pearson <kb9vqf@pearsoncomputing.net> +// Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> // //kdesktop keeps running and checks user inactivity @@ -17,6 +17,14 @@ //some image will be corrupted). #include <config.h> +#include <tdeglobal.h> + +#ifdef WITH_TDEHWLIB +#include <ksslcertificate.h> +#include <kuser.h> +#include <tdehardwaredevices.h> +#include <tdecryptographiccarddevice.h> +#endif #include "lockprocess.h" #include "lockdlg.h" @@ -30,7 +38,7 @@ #include <dmctl.h> #include <dcopref.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <tdeapplication.h> #include <kservicegroup.h> #include <kdebug.h> @@ -77,7 +85,7 @@ #include <sys/types.h> #include <fcntl.h> -#include <kcrash.h> +#include <tdecrash.h> #include <pthread.h> @@ -109,6 +117,8 @@ Status DPMSInfo ( Display *, CARD16 *, BOOL * ); #include <GL/glx.h> #endif +#define KDESKTOP_DEBUG_ID 1204 + #define LOCK_GRACE_DEFAULT 5000 #define AUTOLOGOUT_DEFAULT 600 @@ -141,14 +151,6 @@ Atom kde_wm_system_modal_notification = 0; Atom kde_wm_transparent_to_desktop = 0; Atom kde_wm_transparent_to_black = 0; -static void segv_handler(int) -{ - kdError(1204) << "A fatal exception was encountered." - << " Trapping and ignoring it so as not to compromise desktop security..." - << kdBacktrace() << endl; - sleep(1); -} - extern Atom tqt_wm_state; extern bool trinity_desktop_lock_use_system_modal_dialogs; extern bool trinity_desktop_lock_delay_screensaver_start; @@ -156,24 +158,32 @@ extern bool trinity_desktop_lock_use_sak; extern bool trinity_desktop_lock_hide_active_windows; extern bool trinity_desktop_lock_hide_cancel_button; extern bool trinity_desktop_lock_forced; - -extern LockProcess* trinity_desktop_lock_process; +extern bool trinity_desktop_lock_failed_grab; extern bool argb_visual; extern pid_t kdesktop_pid; extern TQXLibWindowList trinity_desktop_lock_hidden_window_list; -bool trinity_desktop_lock_autohide_lockdlg = TRUE; +bool trinity_desktop_lock_autohide_lockdlg = true; + +static void segv_handler(int) +{ + kdError(KDESKTOP_DEBUG_ID) << "A fatal exception was encountered." + << " Trapping and ignoring it so as not to compromise desktop security..." + << kdBacktrace() << endl; + + sleep(1); +} #define ENABLE_CONTINUOUS_LOCKDLG_DISPLAY \ -if (!mForceContinualLockDisplayTimer->isActive()) mForceContinualLockDisplayTimer->start(100, FALSE); \ -trinity_desktop_lock_autohide_lockdlg = FALSE; \ +if (!mForceContinualLockDisplayTimer->isActive()) mForceContinualLockDisplayTimer->start(100, false); \ +trinity_desktop_lock_autohide_lockdlg = false; \ mHackDelayStartupTimer->stop(); #define DISABLE_CONTINUOUS_LOCKDLG_DISPLAY \ mForceContinualLockDisplayTimer->stop(); \ -trinity_desktop_lock_autohide_lockdlg = TRUE; \ +trinity_desktop_lock_autohide_lockdlg = true; \ mHackDelayStartupTimer->stop(); //=========================================================================== @@ -182,118 +192,136 @@ mHackDelayStartupTimer->stop(); // starting screensaver hacks, and password entry. // LockProcess::LockProcess() - : TQWidget(0L, "saver window", ((WFlags)(WStyle_StaysOnTop|WStyle_Customize|WStyle_NoBorder))), - mOpenGLVisual(0), - mParent(0), - mShowLockDateTime(false), - mSuspended(false), - mVisibility(false), - mRestoreXF86Lock(false), - mForbidden(false), - mAutoLogout(false), - resizeTimer(NULL), - hackResumeTimer(NULL), - mVkbdProcess(NULL), - mKWinModule(NULL), - mPipeOpen(false), - mPipeOpen_out(false), - mInfoMessageDisplayed(false), - mDialogControlLock(false), - mForceReject(false), - currentDialog(NULL), - mEnsureScreenHiddenTimer(NULL), - mForceContinualLockDisplayTimer(NULL), - mEnsureVRootWindowSecurityTimer(NULL), - mHackDelayStartupTimer(NULL), - mHackDelayStartupTimeout(0), - mHackStartupEnabled(true), - mOverrideHackStartupEnabled(false), - mResizingDesktopLock(false), - mFullyOnlineSent(false), - mClosingWindows(false), - mInSecureDialog(false), - mHackActive(false), - m_rootPixmap(NULL), - mBackingStartupDelayTimer(0), - m_startupStatusDialog(NULL), - m_mouseDown(0), - m_mousePrevX(0), - m_mousePrevY(0), - m_dialogPrevX(0), - m_dialogPrevY(0), - m_notifyReadyRequested(false), - m_maskWidget(NULL), - m_saverRootWindow(0) + : TQWidget(0L, "saver window", ((WFlags)(WStyle_StaysOnTop|WStyle_Customize|WStyle_NoBorder))), + mOpenGLVisual(0), + mParent(0), + mShowLockDateTime(false), + mSuspended(false), + mVisibility(false), + mRestoreXF86Lock(false), + mForbidden(false), + mAutoLogout(false), + resizeTimer(NULL), + hackResumeTimer(NULL), + mVkbdProcess(NULL), + mKWinModule(NULL), + mPipeOpen(false), + mPipeOpen_out(false), + mInfoMessageDisplayed(false), + mDialogControlLock(false), + mForceReject(false), + currentDialog(NULL), + mEnsureScreenHiddenTimer(NULL), + mForceContinualLockDisplayTimer(NULL), + mEnsureVRootWindowSecurityTimer(NULL), + mHackDelayStartupTimer(NULL), + mHackDelayStartupTimeout(0), + mHackStartupEnabled(true), + mOverrideHackStartupEnabled(false), + mResizingDesktopLock(false), + mFullyOnlineSent(false), + mClosingWindows(false), + mInSecureDialog(false), + mHackActive(false), + m_rootPixmap(NULL), + mBackingStartupDelayTimer(0), + m_startupStatusDialog(NULL), + m_mouseDown(0), + m_mousePrevX(0), + m_mousePrevY(0), + m_dialogPrevX(0), + m_dialogPrevY(0), + m_notifyReadyRequested(false), + m_loginCardDevice(NULL), + m_maskWidget(NULL), + m_saverRootWindow(0), + mControlPipeHandler(nullptr), + mControlPipeHandlerThread(nullptr) { #ifdef KEEP_MOUSE_UNGRABBED - setNFlags(WX11DisableMove|WX11DisableClose|WX11DisableShade|WX11DisableMinimize|WX11DisableMaximize); + setNFlags(WX11DisableMove|WX11DisableClose|WX11DisableShade|WX11DisableMinimize|WX11DisableMaximize); #endif - setupSignals(); - - // Set up atoms - kde_wm_system_modal_notification = XInternAtom(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); - kde_wm_transparent_to_desktop = XInternAtom(tqt_xdisplay(), "_TDE_TRANSPARENT_TO_DESKTOP", False); - kde_wm_transparent_to_black = XInternAtom(tqt_xdisplay(), "_TDE_TRANSPARENT_TO_BLACK", False); - - kapp->installX11EventFilter(this); - - mForceContinualLockDisplayTimer = new TQTimer( this ); - mHackDelayStartupTimer = new TQTimer( this ); - mEnsureVRootWindowSecurityTimer = new TQTimer( this ); - - if (!argb_visual) { - // Try to get the root pixmap - if (!m_rootPixmap) m_rootPixmap = new KRootPixmap(this); - connect(m_rootPixmap, TQT_SIGNAL(backgroundUpdated(const TQPixmap &)), this, TQT_SLOT(slotPaintBackground(const TQPixmap &))); - m_rootPixmap->setCustomPainting(true); - m_rootPixmap->start(); - } - - // Get root window attributes - XWindowAttributes rootAttr; - XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(), tqt_xscreen()), &rootAttr); - { // trigger creation of QToolTipManager, it does XSelectInput() on the root window - TQWidget w; - TQToolTip::add( &w, "foo" ); - } - XSelectInput( tqt_xdisplay(), tqt_xrootwin(), SubstructureNotifyMask | rootAttr.your_event_mask ); - - // Add non-TDE path - TDEGlobal::dirs()->addResourceType("scrsav", - TDEGlobal::dirs()->kde_default("apps") + - "System/ScreenSavers/"); - - // Add KDE specific screensaver path - TQString relPath="System/ScreenSavers/"; - KServiceGroup::Ptr servGroup = KServiceGroup::baseGroup( "screensavers"); - if (servGroup) - { - relPath=servGroup->relPath(); - kdDebug(1204) << "relPath=" << relPath << endl; - } - TDEGlobal::dirs()->addResourceType("scrsav", - TDEGlobal::dirs()->kde_default("apps") + - relPath); - - // virtual root property - gXA_VROOT = XInternAtom (tqt_xdisplay(), "__SWM_VROOT", False); - gXA_SCREENSAVER_VERSION = XInternAtom (tqt_xdisplay(), "_SCREENSAVER_VERSION", False); - - TQStringList dmopt = - TQStringList::split(TQChar(','), - TQString::fromLatin1( ::getenv( "XDM_MANAGED" ))); - for (TQStringList::ConstIterator it = dmopt.begin(); it != dmopt.end(); ++it) - if ((*it).startsWith("method=")) - mMethod = (*it).mid(7); + setupSignals(); + + // Set up atoms + kde_wm_system_modal_notification = XInternAtom(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); + kde_wm_transparent_to_desktop = XInternAtom(tqt_xdisplay(), "_TDE_TRANSPARENT_TO_DESKTOP", False); + kde_wm_transparent_to_black = XInternAtom(tqt_xdisplay(), "_TDE_TRANSPARENT_TO_BLACK", False); + + tdeApp->installX11EventFilter(this); + + mForceContinualLockDisplayTimer = new TQTimer( this ); + mHackDelayStartupTimer = new TQTimer( this ); + mEnsureVRootWindowSecurityTimer = new TQTimer( this ); + + if (!argb_visual) { + // Try to get the root pixmap + if (!m_rootPixmap) m_rootPixmap = new KRootPixmap(this); + connect(m_rootPixmap, TQ_SIGNAL(backgroundUpdated(const TQPixmap &)), this, TQ_SLOT(slotPaintBackground(const TQPixmap &))); + m_rootPixmap->setCustomPainting(true); + m_rootPixmap->start(); + } + + // Get root window attributes + XWindowAttributes rootAttr; + XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(), tqt_xscreen()), &rootAttr); + { // trigger creation of QToolTipManager, it does XSelectInput() on the root window + TQWidget w; + TQToolTip::add( &w, "foo" ); + } + XSelectInput( tqt_xdisplay(), tqt_xrootwin(), SubstructureNotifyMask | rootAttr.your_event_mask ); + + // Add non-TDE path + TDEGlobal::dirs()->addResourceType("scrsav", + TDEGlobal::dirs()->kde_default("apps") + + "System/ScreenSavers/"); + + // Add KDE specific screensaver path + TQString relPath="System/ScreenSavers/"; + KServiceGroup::Ptr servGroup = KServiceGroup::baseGroup( "screensavers"); + if (servGroup) { + relPath=servGroup->relPath(); + kdDebug(KDESKTOP_DEBUG_ID) << "relPath=" << relPath << endl; + } + TDEGlobal::dirs()->addResourceType("scrsav", + TDEGlobal::dirs()->kde_default("apps") + + relPath); + + // virtual root property + gXA_VROOT = XInternAtom (tqt_xdisplay(), "__SWM_VROOT", False); + gXA_SCREENSAVER_VERSION = XInternAtom (tqt_xdisplay(), "_SCREENSAVER_VERSION", False); + + TQStringList dmopt = TQStringList::split(TQChar(','), + TQString::fromLatin1( ::getenv( "XDM_MANAGED" ))); + for (TQStringList::ConstIterator it = dmopt.begin(); it != dmopt.end(); ++it) { + if ((*it).startsWith("method=")) { + mMethod = (*it).mid(7); + } + } + +#ifdef WITH_TDEHWLIB + // Initialize SmartCard readers + TDEGenericDevice *hwdevice; + TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); + TDEGenericHardwareList cardReaderList = hwdevices->listByDeviceClass(TDEGenericDeviceType::CryptographicCard); + for (hwdevice = cardReaderList.first(); hwdevice; hwdevice = cardReaderList.next()) { + TDECryptographicCardDevice* cdevice = static_cast<TDECryptographicCardDevice*>(hwdevice); + // connect(cdevice, TQ_SIGNAL(pinRequested(TQString,TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardPinRequested(TQString,TDECryptographicCardDevice*))); + connect(cdevice, TQ_SIGNAL(certificateListAvailable(TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardInserted(TDECryptographicCardDevice*))); + connect(cdevice, TQ_SIGNAL(cardRemoved(TDECryptographicCardDevice*)), this, TQ_SLOT(cryptographicCardRemoved(TDECryptographicCardDevice*))); + cdevice->enableCardMonitoring(true); + // cdevice->enablePINEntryCallbacks(true); + } +#endif #ifdef KEEP_MOUSE_UNGRABBED - setEnabled(false); + setEnabled(false); #endif - greetPlugin.library = 0; + greetPlugin.library = 0; - TDECrash::setCrashHandler(segv_handler); + TDECrash::setCrashHandler(segv_handler); } //--------------------------------------------------------------------------- @@ -302,49 +330,47 @@ LockProcess::LockProcess() // LockProcess::~LockProcess() { - mControlPipeHandler->terminateThread(); - mControlPipeHandlerThread->wait(); - delete mControlPipeHandler; -// delete mControlPipeHandlerThread; - - if (resizeTimer != NULL) { - resizeTimer->stop(); - delete resizeTimer; - } - if (hackResumeTimer != NULL) { - hackResumeTimer->stop(); - delete hackResumeTimer; - } - if (mEnsureScreenHiddenTimer != NULL) { - mEnsureScreenHiddenTimer->stop(); - delete mEnsureScreenHiddenTimer; - } - if (mForceContinualLockDisplayTimer != NULL) { - mForceContinualLockDisplayTimer->stop(); - delete mForceContinualLockDisplayTimer; - } - if (mHackDelayStartupTimer != NULL) { - mHackDelayStartupTimer->stop(); - delete mHackDelayStartupTimer; - } - if (mEnsureVRootWindowSecurityTimer != NULL) { - mEnsureVRootWindowSecurityTimer->stop(); - delete mEnsureVRootWindowSecurityTimer; - } - - if (greetPlugin.library) { - if (greetPlugin.info->done) - greetPlugin.info->done(); - greetPlugin.library->unload(); - } - - if (m_rootPixmap) { - m_rootPixmap->stop(); - delete m_rootPixmap; - } - - mPipeOpen = false; - mPipeOpen_out = false; + mControlPipeHandler->terminateThread(); + mControlPipeHandlerThread->wait(); + delete mControlPipeHandler; + if (resizeTimer != NULL) { + resizeTimer->stop(); + delete resizeTimer; + } + if (hackResumeTimer != NULL) { + hackResumeTimer->stop(); + delete hackResumeTimer; + } + if (mEnsureScreenHiddenTimer != NULL) { + mEnsureScreenHiddenTimer->stop(); + delete mEnsureScreenHiddenTimer; + } + if (mForceContinualLockDisplayTimer != NULL) { + mForceContinualLockDisplayTimer->stop(); + delete mForceContinualLockDisplayTimer; + } + if (mHackDelayStartupTimer != NULL) { + mHackDelayStartupTimer->stop(); + delete mHackDelayStartupTimer; + } + if (mEnsureVRootWindowSecurityTimer != NULL) { + mEnsureVRootWindowSecurityTimer->stop(); + delete mEnsureVRootWindowSecurityTimer; + } + + if (greetPlugin.library) { + if (greetPlugin.info->done) + greetPlugin.info->done(); + greetPlugin.library->unload(); + } + + if (m_rootPixmap) { + m_rootPixmap->stop(); + delete m_rootPixmap; + } + + mPipeOpen = false; + mPipeOpen_out = false; } //--------------------------------------------------------------------------- @@ -354,118 +380,119 @@ LockProcess::~LockProcess() // void LockProcess::init(bool child, bool useBlankOnly) { - // Get root window size - XWindowAttributes rootAttr; - XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(), tqt_xscreen()), &rootAttr); - mRootWidth = rootAttr.width; - mRootHeight = rootAttr.height; - generateBackingImages(); - - // Connect all signals - connect( mForceContinualLockDisplayTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(displayLockDialogIfNeeded()) ); - connect( mHackDelayStartupTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(closeDialogAndStartHack()) ); - connect( mEnsureVRootWindowSecurityTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(repaintRootWindowIfNeeded()) ); - connect(tqApp, TQT_SIGNAL(mouseInteraction(XEvent *)), TQT_SLOT(slotMouseActivity(XEvent *))); - connect(&mHackProc, TQT_SIGNAL(processExited(TDEProcess *)), TQT_SLOT(hackExited(TDEProcess *))); - connect(&mSuspendTimer, TQT_SIGNAL(timeout()), TQT_SLOT(suspend())); + // Get root window size + XWindowAttributes rootAttr; + XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(), tqt_xscreen()), &rootAttr); + mRootWidth = rootAttr.width; + mRootHeight = rootAttr.height; + generateBackingImages(); + + // Connect all signals + connect( mForceContinualLockDisplayTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(displayLockDialogIfNeeded()) ); + connect( mHackDelayStartupTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(closeDialogAndStartHack()) ); + connect( mEnsureVRootWindowSecurityTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(repaintRootWindowIfNeeded()) ); + connect(tqApp, TQ_SIGNAL(mouseInteraction(XEvent *)), TQ_SLOT(slotMouseActivity(XEvent *))); + connect(&mHackProc, TQ_SIGNAL(processExited(TDEProcess *)), TQ_SLOT(hackExited(TDEProcess *))); + connect(&mSuspendTimer, TQ_SIGNAL(timeout()), TQ_SLOT(suspend())); #ifdef HAVE_DPMS - //if the user decided that the screensaver should run independent from - //dpms, we shouldn't check for it, aleXXX - if (KDesktopSettings::dpmsDependent()) { - BOOL on; - CARD16 state; - if (DPMSInfo(tqt_xdisplay(), &state, &on)) { - if (on) { - connect(&mCheckDPMS, TQT_SIGNAL(timeout()), TQT_SLOT(checkDPMSActive())); - // we can save CPU if we stop it as quickly as possible - // but we waste CPU if we check too often -> so take 10s - mCheckDPMS.start(10000); - } - } - } + //if the user decided that the screensaver should run independent from + //dpms, we shouldn't check for it, aleXXX + if (KDesktopSettings::dpmsDependent()) { + BOOL on; + CARD16 state; + if (DPMSInfo(tqt_xdisplay(), &state, &on)) { + if (on) { + connect(&mCheckDPMS, TQ_SIGNAL(timeout()), TQ_SLOT(checkDPMSActive())); + // we can save CPU if we stop it as quickly as possible + // but we waste CPU if we check too often -> so take 10s + mCheckDPMS.start(10000); + } + } + } #endif -#if (TQT_VERSION-0 >= 0x030200) // XRANDR support - connect( kapp->desktop(), TQT_SIGNAL( resized( int )), TQT_SLOT( desktopResized())); -#endif + connect( tdeApp->desktop(), TQ_SIGNAL( resized( int )), TQ_SLOT( desktopResized())); - if (!trinity_desktop_lock_use_system_modal_dialogs) { - setWFlags((WFlags)WX11BypassWM); - } + if (!trinity_desktop_lock_use_system_modal_dialogs) { + setWFlags((WFlags)WX11BypassWM); + } - child_saver = child; - mUseBlankOnly = useBlankOnly; + child_saver = child; + mUseBlankOnly = useBlankOnly; - mShowLockDateTime = KDesktopSettings::showLockDateTime(); - mlockDateTime = TQDateTime::currentDateTime(); + mShowLockDateTime = KDesktopSettings::showLockDateTime(); + mlockDateTime = TQDateTime::currentDateTime(); - mHackDelayStartupTimeout = trinity_desktop_lock_delay_screensaver_start?KDesktopSettings::timeout()*1000:10*1000; - mHackStartupEnabled = trinity_desktop_lock_use_system_modal_dialogs?KDesktopSettings::screenSaverEnabled():true; + mHackDelayStartupTimeout = trinity_desktop_lock_delay_screensaver_start?KDesktopSettings::timeout()*1000:10*1000; + mHackStartupEnabled = trinity_desktop_lock_use_system_modal_dialogs?KDesktopSettings::screenSaverEnabled():true; - configure(); + configure(); - mControlPipeHandlerThread = new TQEventLoopThread(); - mControlPipeHandler = new ControlPipeHandlerObject(); - mControlPipeHandler->mParent = this; - mControlPipeHandler->moveToThread(mControlPipeHandlerThread); - TQObject::connect(mControlPipeHandler, SIGNAL(processCommand(TQString)), this, SLOT(processInputPipeCommand(TQString))); - TQTimer::singleShot(0, mControlPipeHandler, SLOT(run())); - mControlPipeHandlerThread->start(); + mControlPipeHandlerThread = new TQEventLoopThread(); + mControlPipeHandler = new ControlPipeHandlerObject(); + mControlPipeHandler->mParent = this; + mControlPipeHandler->moveToThread(mControlPipeHandlerThread); + TQObject::connect(mControlPipeHandler, TQ_SIGNAL(processCommand(TQString)), this, TQ_SLOT(processInputPipeCommand(TQString))); + TQTimer::singleShot(0, mControlPipeHandler, TQ_SLOT(run())); + mControlPipeHandlerThread->start(); + // If the lock process terminates before 'mControlPipeHandler::run()' has been called, the + // 'mControlPipeHandlerThread' thread would not terminate and the lock process would have a + // dirty exit, potentially leaving 'kdesktop' in a dirty state that prevents the lock from + // working correctly till 'kdesktop' is killed and restarted. By forcing a call to 'processEvents()' + // we make sure to handle pending timer events and execute the required call + tdeApp->processEvents(); } static int signal_pipe[2]; static void sigterm_handler(int) { - if ((!trinity_desktop_lock_process) || (!trinity_desktop_lock_process->inSecureDialog())) { - // Exit uncleanly - char tmp = 'U'; - if (::write( signal_pipe[1], &tmp, 1) == -1) { - // Error handler to shut up gcc warnings - } - } + // Exit uncleanly + char tmp = 'U'; + if (::write( signal_pipe[1], &tmp, 1) == -1) { + // Error handler to shut up gcc warnings + } } static void sighup_handler(int) { - char tmp = 'H'; - if (::write( signal_pipe[1], &tmp, 1) == -1) { - // Error handler to shut up gcc warnings - } + char tmp = 'H'; + if (::write( signal_pipe[1], &tmp, 1) == -1) { + // Error handler to shut up gcc warnings + } } bool LockProcess::closeCurrentWindow() { - mClosingWindows = TRUE; - if (currentDialog != NULL) { - mForceReject = true; - if (dynamic_cast<SAKDlg*>(currentDialog)) { - dynamic_cast<SAKDlg*>(currentDialog)->closeDialogForced(); - } - else if (dynamic_cast<SecureDlg*>(currentDialog)) { - dynamic_cast<SecureDlg*>(currentDialog)->closeDialogForced(); - } - else { - currentDialog->close(); - } - } - - if( mDialogs.isEmpty() ) { - mClosingWindows = FALSE; - mForceReject = false; - return false; - } - else { - mClosingWindows = TRUE; - return true; - } + mClosingWindows = true; + if (currentDialog != NULL) { + mForceReject = true; + if (dynamic_cast<SAKDlg*>(currentDialog)) { + dynamic_cast<SAKDlg*>(currentDialog)->closeDialogForced(); + } + else if (dynamic_cast<SecureDlg*>(currentDialog)) { + dynamic_cast<SecureDlg*>(currentDialog)->closeDialogForced(); + } + else { + currentDialog->close(); + } + } + + if( mDialogs.isEmpty() ) { + mClosingWindows = false; + mForceReject = false; + return false; + } + else { + mClosingWindows = true; + return true; + } } void LockProcess::timerEvent(TQTimerEvent *ev) { - if (mAutoLogout && ev->timerId() == mAutoLogoutTimerId) - { + if (mAutoLogout && ev->timerId() == mAutoLogoutTimerId) { killTimer(mAutoLogoutTimerId); AutoLogout autologout(this); execDialog(&autologout); @@ -479,58 +506,60 @@ void LockProcess::resizeEvent(TQResizeEvent *) void LockProcess::setupSignals() { - struct sigaction act; - // ignore SIGINT - act.sa_handler=SIG_IGN; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGINT); - act.sa_flags = 0; - sigaction(SIGINT, &act, 0L); - // ignore SIGQUIT - act.sa_handler=SIG_IGN; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGQUIT); - act.sa_flags = 0; - sigaction(SIGQUIT, &act, 0L); - // exit uncleanly on SIGTERM - act.sa_handler= sigterm_handler; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGTERM); - act.sa_flags = 0; - sigaction(SIGTERM, &act, 0L); - // SIGHUP forces lock - act.sa_handler= sighup_handler; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGHUP); - act.sa_flags = 0; - sigaction(SIGHUP, &act, 0L); - - if (pipe(signal_pipe) == -1) { - // Error handler to shut up gcc warnings - } - TQSocketNotifier* notif = new TQSocketNotifier(signal_pipe[0], TQSocketNotifier::Read, TQT_TQOBJECT(this) ); - connect( notif, TQT_SIGNAL(activated(int)), TQT_SLOT(signalPipeSignal())); + struct sigaction act; + // ignore SIGINT + act.sa_handler=SIG_IGN; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGINT); + act.sa_flags = 0; + sigaction(SIGINT, &act, 0L); + // ignore SIGQUIT + act.sa_handler=SIG_IGN; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGQUIT); + act.sa_flags = 0; + sigaction(SIGQUIT, &act, 0L); + // exit uncleanly on SIGTERM + act.sa_handler= sigterm_handler; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGTERM); + act.sa_flags = 0; + sigaction(SIGTERM, &act, 0L); + // SIGHUP forces lock + act.sa_handler= sighup_handler; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGHUP); + act.sa_flags = 0; + sigaction(SIGHUP, &act, 0L); + + if (pipe(signal_pipe) == -1) { + // Error handler to shut up gcc warnings + } + TQSocketNotifier* notif = new TQSocketNotifier(signal_pipe[0], TQSocketNotifier::Read, this ); + connect( notif, TQ_SIGNAL(activated(int)), TQ_SLOT(signalPipeSignal())); } void LockProcess::signalPipeSignal() { - char tmp; - if (::read( signal_pipe[0], &tmp, 1) == -1) { - // Error handler to shut up gcc warnings - } - if( tmp == 'T' ) { - quitSaver(); - } - else if( tmp == 'H' ) { - if( !mLocked ) - startLock(); - } - else if( tmp == 'U' ) { - // Exit uncleanly - quitSaver(); - exit(1); - } + char tmp; + if (::read( signal_pipe[0], &tmp, 1) == -1) { + // Error handler to shut up gcc warnings + } + if( tmp == 'T' ) { + quitSaver(); + } + else if( tmp == 'H' ) { + if( !mLocked ) + startLock(); + } + else if( tmp == 'U' ) { + if (!inSecureDialog()) { + // Exit uncleanly + quitSaver(); + exit(1); + } + } } //--------------------------------------------------------------------------- @@ -541,7 +570,7 @@ bool LockProcess::lock() m_startupStatusDialog->setStatusMessage(i18n("Securing desktop session").append("...")); m_startupStatusDialog->show(); m_startupStatusDialog->setActiveWindow(); - tqApp->processEvents(); + tdeApp->processEvents(); #endif if (startSaver(true)) { @@ -551,9 +580,8 @@ bool LockProcess::lock() // the screensaver kicks in because the user moved the mouse after // selecting "lock screen", that looks really untidy. mBusy = true; - if (startLock()) - { - TQTimer::singleShot(1000, this, TQT_SLOT(slotDeadTimePassed())); + if (startLock()) { + TQTimer::singleShot(1000, this, TQ_SLOT(slotDeadTimePassed())); return true; } stopSaver(); @@ -564,47 +592,48 @@ bool LockProcess::lock() //--------------------------------------------------------------------------- void LockProcess::slotDeadTimePassed() { - mBusy = false; + mBusy = false; } //--------------------------------------------------------------------------- bool LockProcess::defaultSave() { - mLocked = false; - mOverrideHackStartupEnabled = true; - if (startSaver()) { - if (mLockGrace >= 0) - TQTimer::singleShot(mLockGrace, this, TQT_SLOT(startLock())); - return true; - } - mOverrideHackStartupEnabled = false; - return false; + mLocked = false; + mOverrideHackStartupEnabled = true; + if (startSaver()) { + if (mLockGrace >= 0) { + TQTimer::singleShot(mLockGrace, this, TQ_SLOT(startLock())); + } + return true; + } + mOverrideHackStartupEnabled = false; + return false; } //--------------------------------------------------------------------------- bool LockProcess::dontLock() { - mLocked = false; - return startSaver(); + mLocked = false; + return startSaver(); } //--------------------------------------------------------------------------- void LockProcess::quitSaver() { - DISABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (closeCurrentWindow()) { - TQTimer::singleShot( 0, this, SLOT(quitSaver()) ); - return; - } - stopSaver(); - kapp->quit(); + DISABLE_CONTINUOUS_LOCKDLG_DISPLAY + if (closeCurrentWindow()) { + TQTimer::singleShot( 0, this, TQ_SLOT(quitSaver()) ); + return; + } + stopSaver(); + tdeApp->quit(); } //--------------------------------------------------------------------------- void LockProcess::startSecureDialog() { if ((backingPixmap.isNull()) && (mBackingStartupDelayTimer < 100)) { - TQTimer::singleShot(10, this, TQT_SLOT(startSecureDialog())); + TQTimer::singleShot(10, this, TQ_SLOT(startSecureDialog())); mBackingStartupDelayTimer++; return; } @@ -625,7 +654,7 @@ void LockProcess::startSecureDialog() mInSecureDialog = false; if (ret == 0) { mClosingWindows = 1; - kapp->quit(); + tdeApp->quit(); } if (ret == 1) { // In case of a forced lock we don't react to events during @@ -636,18 +665,18 @@ void LockProcess::startSecureDialog() mBusy = true; trinity_desktop_lock_forced = true; // Make sure the cursor is not showing busy status - setCursor( tqarrowCursor ); + setCursor( TQt::arrowCursor ); if (startLock()) { if (trinity_desktop_lock_delay_screensaver_start) { mBusy = false; } else { - TQTimer::singleShot(1000, this, TQT_SLOT(slotDeadTimePassed())); + TQTimer::singleShot(1000, this, TQ_SLOT(slotDeadTimePassed())); } if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced && trinity_desktop_lock_use_system_modal_dialogs) { ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); + if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); } else { if (mHackStartupEnabled == true) { @@ -656,7 +685,7 @@ void LockProcess::startSecureDialog() else { if (trinity_desktop_lock_use_system_modal_dialogs == true) { ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); + if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); } else { startHack(); @@ -674,18 +703,18 @@ void LockProcess::startSecureDialog() if (system("ksysguard &") == -1) { // Error handler to shut up gcc warnings } - kapp->quit(); + tdeApp->quit(); } if (ret == 3) { mClosingWindows = 1; DCOPRef("ksmserver","ksmserver").send("logout", (int)TDEApplication::ShutdownConfirmYes, (int)TDEApplication::ShutdownTypeNone, (int)TDEApplication::ShutdownModeInteractive); - kapp->quit(); + tdeApp->quit(); } // FIXME // Handle remaining case (switch user) if (forcecontdisp) { ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); + if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); } stopSaver(); } @@ -697,13 +726,13 @@ bool LockProcess::runSecureDialog() m_startupStatusDialog->setStatusMessage(i18n("Securing desktop session").append("...")); m_startupStatusDialog->show(); m_startupStatusDialog->setActiveWindow(); - tqApp->processEvents(); + tdeApp->processEvents(); #endif mInSecureDialog = true; if (startSaver()) { mBackingStartupDelayTimer = 0; - TQTimer::singleShot(0, this, TQT_SLOT(startSecureDialog())); + TQTimer::singleShot(0, this, TQ_SLOT(startSecureDialog())); return true; } else { @@ -723,47 +752,45 @@ bool LockProcess::inSecureDialog() // void LockProcess::configure() { - // the configuration is stored in kdesktop's config file - if( KDesktopSettings::lock() ) - { - mLockGrace = KDesktopSettings::lockGrace(); - if (mLockGrace < 0) - mLockGrace = 0; - else if (mLockGrace > 300000) - mLockGrace = 300000; // 5 minutes, keep the value sane - } - else - mLockGrace = -1; - - if ( KDesktopSettings::autoLogout() ) - { - mAutoLogout = true; - mAutoLogoutTimeout = KDesktopSettings::autoLogoutTimeout(); - mAutoLogoutTimerId = startTimer(mAutoLogoutTimeout * 1000); // in milliseconds - } - - mPriority = KDesktopSettings::priority(); - if (mPriority < 0) mPriority = 0; - if (mPriority > 19) mPriority = 19; - - mSaver = KDesktopSettings::saver(); - if (mSaver.isEmpty() || mUseBlankOnly) { - mSaver = "KBlankscreen.desktop"; - } - if (!trinity_desktop_lock_use_system_modal_dialogs) { - if (KDesktopSettings::screenSaverEnabled() == false) { - mSaver = ""; - mSaverExec = ""; - } - } - - readSaver(); - - mPlugins = KDesktopSettings::pluginsUnlock(); - if (mPlugins.isEmpty()) { - mPlugins = TQStringList("classic"); - } - mPluginOptions = KDesktopSettings::pluginOptions(); + // the configuration is stored in kdesktop's config file + if( KDesktopSettings::lock() ) { + mLockGrace = KDesktopSettings::lockGrace(); + if (mLockGrace < 0) + mLockGrace = 0; + else if (mLockGrace > 300000) + mLockGrace = 300000; // 5 minutes, keep the value sane + } + else + mLockGrace = -1; + + if ( KDesktopSettings::autoLogout() ) { + mAutoLogout = true; + mAutoLogoutTimeout = KDesktopSettings::autoLogoutTimeout(); + mAutoLogoutTimerId = startTimer(mAutoLogoutTimeout * 1000); // in milliseconds + } + + mPriority = KDesktopSettings::priority(); + if (mPriority < 0) mPriority = 0; + if (mPriority > 19) mPriority = 19; + + mSaver = KDesktopSettings::saver(); + if (mSaver.isEmpty() || mUseBlankOnly) { + mSaver = "KBlankscreen.desktop"; + } + if (!trinity_desktop_lock_use_system_modal_dialogs) { + if (KDesktopSettings::screenSaverEnabled() == false) { + mSaver = ""; + mSaverExec = ""; + } + } + + readSaver(); + + mPlugins = KDesktopSettings::pluginsUnlock(); + if (mPlugins.isEmpty()) { + mPlugins = TQStringList("classic"); + } + mPluginOptions = KDesktopSettings::pluginOptions(); } //--------------------------------------------------------------------------- @@ -772,53 +799,45 @@ void LockProcess::configure() // void LockProcess::readSaver() { - if (!mSaver.isEmpty()) - { - TQString file = locate("scrsav", mSaver); - - bool opengl = kapp->authorize("opengl_screensavers"); - bool manipulatescreen = kapp->authorize("manipulatescreen_screensavers"); - KDesktopFile config(file, true); - if (config.readEntry("X-TDE-Type").utf8() != 0) - { - TQString saverType = config.readEntry("X-TDE-Type").utf8(); - TQStringList saverTypes = TQStringList::split(";", saverType); - for (uint i = 0; i < saverTypes.count(); i++) - { - if ((saverTypes[i] == "ManipulateScreen") && !manipulatescreen) - { - kdDebug(1204) << "Screensaver is type ManipulateScreen and ManipulateScreen is forbidden" << endl; - mForbidden = true; + if (!mSaver.isEmpty()) { + TQString file = locate("scrsav", mSaver); + + bool opengl = tdeApp->authorize("opengl_screensavers"); + bool manipulatescreen = tdeApp->authorize("manipulatescreen_screensavers"); + TDEDesktopFile config(file, true); + if (config.readEntry("X-TDE-Type").utf8() != 0) { + TQString saverType = config.readEntry("X-TDE-Type").utf8(); + TQStringList saverTypes = TQStringList::split(";", saverType); + for (uint i = 0; i < saverTypes.count(); i++) { + if ((saverTypes[i] == "ManipulateScreen") && !manipulatescreen) { + kdDebug(KDESKTOP_DEBUG_ID) << "Screensaver is type ManipulateScreen and ManipulateScreen is forbidden" << endl; + mForbidden = true; + } + if ((saverTypes[i] == "OpenGL") && !opengl) { + kdDebug(KDESKTOP_DEBUG_ID) << "Screensaver is type OpenGL and OpenGL is forbidden" << endl; + mForbidden = true; + } + if (saverTypes[i] == "OpenGL") { + mOpenGLVisual = true; + } } - if ((saverTypes[i] == "OpenGL") && !opengl) - { - kdDebug(1204) << "Screensaver is type OpenGL and OpenGL is forbidden" << endl; - mForbidden = true; + } + + kdDebug(KDESKTOP_DEBUG_ID) << "mForbidden: " << (mForbidden ? "true" : "false") << endl; + + if (trinity_desktop_lock_use_system_modal_dialogs) { + if (config.hasActionGroup("InWindow")) { + config.setActionGroup("InWindow"); + mSaverExec = config.readPathEntry("Exec"); } - if (saverTypes[i] == "OpenGL") - { - mOpenGLVisual = true; + } + else { + if (config.hasActionGroup("Root")) { + config.setActionGroup("Root"); + mSaverExec = config.readPathEntry("Exec"); } } } - - kdDebug(1204) << "mForbidden: " << (mForbidden ? "true" : "false") << endl; - - if (trinity_desktop_lock_use_system_modal_dialogs) { - if (config.hasActionGroup("InWindow")) - { - config.setActionGroup("InWindow"); - mSaverExec = config.readPathEntry("Exec"); - } - } - else { - if (config.hasActionGroup("Root")) - { - config.setActionGroup("Root"); - mSaverExec = config.readPathEntry("Exec"); - } - } - } } //--------------------------------------------------------------------------- @@ -827,233 +846,230 @@ void LockProcess::readSaver() // void LockProcess::createSaverWindow() { - Visual* visual = CopyFromParent; - XSetWindowAttributes attrs; - XVisualInfo* info = NULL; - int flags = trinity_desktop_lock_use_system_modal_dialogs?0:CWOverrideRedirect; + Visual* visual = CopyFromParent; + XSetWindowAttributes attrs; + XVisualInfo* info = NULL; + int flags = trinity_desktop_lock_use_system_modal_dialogs?0:CWOverrideRedirect; #ifdef HAVE_GLXCHOOSEVISUAL - if( mOpenGLVisual ) - { - static int attribs[][ 15 ] = - { - #define R GLX_RED_SIZE - #define G GLX_GREEN_SIZE - #define B GLX_BLUE_SIZE - { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None }, - { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None }, - { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, None }, - { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_DOUBLEBUFFER, None }, - { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_STENCIL_SIZE, 1, None }, - { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_STENCIL_SIZE, 1, None }, - { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, None }, - { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, None }, - { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None }, - { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, None }, - { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_STENCIL_SIZE, 1, None }, - { GLX_RGBA, GLX_DEPTH_SIZE, 8, None } - #undef R - #undef G - #undef B - }; - for( unsigned int i = 0; i < sizeof( attribs ) / sizeof( attribs[ 0 ] ); ++i ) { - int n_glxfb_configs; - GLXFBConfig *fbc = glXChooseFBConfig( x11Display(), x11Screen(), attribs[ i ], &n_glxfb_configs); - if (!fbc) { - n_glxfb_configs = 0; - } - for( int j = 0; j < n_glxfb_configs; j++ ) { - info = glXGetVisualFromFBConfig(x11Display(), fbc[j]); - if( info ) { - if (argb_visual) { - // Xorg can only use GPU compositing for ARGB32 8:8:8:8 visuals - // Ensure the selected visual is 8 bits per RGB - // Selecting a non-8-bit visual will result in stuttering and high - // CPU load, while Xorg tries to composite each frame on the CPU! - if ((info->depth < 32) || (info->bits_per_rgb != 8)) { - XFree( info ); - info = NULL; - continue; - } - } - visual = info->visual; - static Colormap colormap = 0; - if( colormap != 0 ) { - XFreeColormap( x11Display(), colormap ); - } - colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone ); - attrs.colormap = colormap; - flags |= CWColormap; - break; - } - } - if (flags & CWColormap) { - break; - } - } - if ( !info ) - { - printf("[WARNING] Unable to locate matching X11 GLX Visual; this OpenGL application may not function correctly!\n"); - } - } + if( mOpenGLVisual ) { + static int attribs[][ 15 ] = { + #define R GLX_RED_SIZE + #define G GLX_GREEN_SIZE + #define B GLX_BLUE_SIZE + { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None }, + { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None }, + { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, None }, + { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_DOUBLEBUFFER, None }, + { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_STENCIL_SIZE, 1, None }, + { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_STENCIL_SIZE, 1, None }, + { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, None }, + { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, None }, + { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None }, + { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, None }, + { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_STENCIL_SIZE, 1, None }, + { GLX_RGBA, GLX_DEPTH_SIZE, 8, None } + #undef R + #undef G + #undef B + }; + for( unsigned int i = 0; i < sizeof( attribs ) / sizeof( attribs[ 0 ] ); ++i ) { + int n_glxfb_configs; + GLXFBConfig *fbc = glXChooseFBConfig( x11Display(), x11Screen(), attribs[ i ], &n_glxfb_configs); + if (!fbc) { + n_glxfb_configs = 0; + } + for( int j = 0; j < n_glxfb_configs; j++ ) { + info = glXGetVisualFromFBConfig(x11Display(), fbc[j]); + if( info ) { + if (argb_visual) { + // Xorg can only use GPU compositing for ARGB32 8:8:8:8 visuals + // Ensure the selected visual is 8 bits per RGB + // Selecting a non-8-bit visual will result in stuttering and high + // CPU load, while Xorg tries to composite each frame on the CPU! + if ((info->depth < 32) || (info->bits_per_rgb != 8)) { + XFree( info ); + info = NULL; + continue; + } + } + visual = info->visual; + static Colormap colormap = 0; + if( colormap != 0 ) { + XFreeColormap( x11Display(), colormap ); + } + colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone ); + attrs.colormap = colormap; + flags |= CWColormap; + break; + } + } + if (flags & CWColormap) { + break; + } + } + if ( !info ) { + printf("[WARNING] Unable to locate matching X11 GLX Visual; this OpenGL application may not function correctly!\n"); + } + } #endif - attrs.override_redirect = 1; - hide(); - - if (argb_visual) { - // The GL visual selection can return a visual with invalid depth - // Check for this and use a fallback visual if needed - if (info && (info->depth < 32)) { - printf("[WARNING] Unable to locate matching X11 GLX Visual; this OpenGL application may not function correctly!\n"); - XFree( info ); - info = NULL; - flags &= ~CWColormap; - } - - attrs.background_pixel = 0; - attrs.border_pixel = 0; - flags |= CWBackPixel; - flags |= CWBorderPixel; - if (!(flags & CWColormap)) { - if (!info) { - info = new XVisualInfo; - if (!XMatchVisualInfo( x11Display(), x11Screen(), 32, TrueColor, info )) { - printf("[ERROR] Unable to locate matching X11 Visual; this application will not function correctly!\n"); - free(info); - info = NULL; - } - } - if (info) { - visual = info->visual; - attrs.colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone ); - flags |= CWColormap; - } - } - } - if (info) { - XFree( info ); - } - - m_saverRootWindow = XCreateWindow( x11Display(), RootWindow( x11Display(), x11Screen()), x(), y(), width(), height(), 0, x11Depth(), InputOutput, visual, flags, &attrs ); - create( m_saverRootWindow ); - - // Some xscreensaver hacks check for this property - const char *version = "KDE 2.0"; - XChangeProperty (tqt_xdisplay(), winId(), - gXA_SCREENSAVER_VERSION, XA_STRING, 8, PropModeReplace, - (unsigned char *) version, strlen(version)); - - XSetWindowAttributes attr; - attr.event_mask = KeyPressMask | ButtonPressMask | PointerMotionMask | VisibilityChangeMask | ExposureMask; - XChangeWindowAttributes(tqt_xdisplay(), winId(), CWEventMask, &attr); - - // Signal that we want to be transparent to the desktop, not to windows behind us... - XChangeProperty(tqt_xdisplay(), m_saverRootWindow, kde_wm_transparent_to_desktop, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); - - // erase(); - - // set NoBackground so that the saver can capture the current - // screen state if necessary - // this is a security risk and has been deactivated--welcome to the 21st century folks! - // setBackgroundMode(TQWidget::NoBackground); - - setGeometry(0, 0, mRootWidth, mRootHeight); - saverReadyIfNeeded(); - - // HACK - // Hide all tooltips and notification windows - { - Window rootWindow = RootWindow(x11Display(), x11Screen()); - Window parent; - Window* children = NULL; - unsigned int noOfChildren = 0; - XWindowAttributes childAttr; - Window childTransient; - - if (XQueryTree(x11Display(), rootWindow, &rootWindow, &parent, &children, &noOfChildren) && noOfChildren>0 ) { - for (unsigned int i=0; i<noOfChildren; i++) { - if (XGetWindowAttributes(x11Display(), children[i], &childAttr) && XGetTransientForHint(x11Display(), children[i], &childTransient)) { - if ((childAttr.map_state == IsViewable) && (childAttr.override_redirect) && (childTransient)) { - if (!trinity_desktop_lock_hidden_window_list.contains(children[i])) { - trinity_desktop_lock_hidden_window_list.append(children[i]); - } - XLowerWindow(x11Display(), children[i]); - XFlush(x11Display()); - } - } - } - } - } + attrs.override_redirect = 1; + hide(); - kdDebug(1204) << "Saver window Id: " << winId() << endl; + if (argb_visual) { + // The GL visual selection can return a visual with invalid depth + // Check for this and use a fallback visual if needed + if (info && (info->depth < 32)) { + printf("[WARNING] Unable to locate matching X11 GLX Visual; this OpenGL application may not function correctly!\n"); + XFree( info ); + info = NULL; + flags &= ~CWColormap; + } + + attrs.background_pixel = 0; + attrs.border_pixel = 0; + flags |= CWBackPixel; + flags |= CWBorderPixel; + if (!(flags & CWColormap)) { + if (!info) { + info = new XVisualInfo; + if (!XMatchVisualInfo( x11Display(), x11Screen(), 32, TrueColor, info )) { + printf("[ERROR] Unable to locate matching X11 Visual; this application will not function correctly!\n"); + free(info); + info = NULL; + } + } + if (info) { + visual = info->visual; + attrs.colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone ); + flags |= CWColormap; + } + } + } + if (info) { + XFree( info ); + } + + m_saverRootWindow = XCreateWindow( x11Display(), RootWindow( x11Display(), x11Screen()), x(), y(), width(), height(), 0, x11Depth(), InputOutput, visual, flags, &attrs ); + create( m_saverRootWindow ); + + // Some xscreensaver hacks check for this property + const char *version = "KDE 2.0"; + XChangeProperty (tqt_xdisplay(), winId(), + gXA_SCREENSAVER_VERSION, XA_STRING, 8, PropModeReplace, + (unsigned char *) version, strlen(version)); + + XSetWindowAttributes attr; + attr.event_mask = KeyPressMask | ButtonPressMask | PointerMotionMask | VisibilityChangeMask | ExposureMask; + XChangeWindowAttributes(tqt_xdisplay(), winId(), CWEventMask, &attr); + + // Signal that we want to be transparent to the desktop, not to windows behind us... + XChangeProperty(tqt_xdisplay(), m_saverRootWindow, kde_wm_transparent_to_desktop, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); + + // erase(); + + // set NoBackground so that the saver can capture the current + // screen state if necessary + // this is a security risk and has been deactivated--welcome to the 21st century folks! + // setBackgroundMode(TQWidget::NoBackground); + + setGeometry(0, 0, mRootWidth, mRootHeight); + saverReadyIfNeeded(); + + // HACK + // Hide all tooltips and notification windows + { + Window rootWindow = RootWindow(x11Display(), x11Screen()); + Window parent; + Window* children = NULL; + unsigned int noOfChildren = 0; + XWindowAttributes childAttr; + Window childTransient; + + if (XQueryTree(x11Display(), rootWindow, &rootWindow, &parent, &children, &noOfChildren) && noOfChildren>0 ) { + for (unsigned int i=0; i<noOfChildren; i++) { + if (XGetWindowAttributes(x11Display(), children[i], &childAttr) && XGetTransientForHint(x11Display(), children[i], &childTransient)) { + if ((childAttr.map_state == IsViewable) && (childAttr.override_redirect) && (childTransient)) { + if (!trinity_desktop_lock_hidden_window_list.contains(children[i])) { + trinity_desktop_lock_hidden_window_list.append(children[i]); + } + XLowerWindow(x11Display(), children[i]); + XFlush(x11Display()); + } + } + } + } + } + + kdDebug(KDESKTOP_DEBUG_ID) << "Saver window Id: " << winId() << endl; } void LockProcess::desktopResized() { - // Get root window size - XWindowAttributes rootAttr; - XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(), tqt_xscreen()), &rootAttr); - if ((rootAttr.width == mRootWidth) && (rootAttr.height == mRootHeight)) { - return; - } - mRootWidth = rootAttr.width; - mRootHeight = rootAttr.height; - generateBackingImages(); - - mBusy = true; - mHackDelayStartupTimer->stop(); - stopHack(); - DISABLE_CONTINUOUS_LOCKDLG_DISPLAY - mResizingDesktopLock = true; - - backingPixmap = TQPixmap(); - - if (trinity_desktop_lock_use_system_modal_dialogs) { - // Temporarily hide the entire screen with a new override redirect window - if (m_maskWidget) { - m_maskWidget->setGeometry(0, 0, mRootWidth, mRootHeight); - } - else { - m_maskWidget = new TQWidget(0, 0, TQt::WStyle_StaysOnTop | TQt::WX11BypassWM); - m_maskWidget->setGeometry(0, 0, mRootWidth, mRootHeight); - m_maskWidget->setBackgroundColor(TQt::black); - m_maskWidget->erase(); - m_maskWidget->show(); - } + // Get root window size + XWindowAttributes rootAttr; + XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(), tqt_xscreen()), &rootAttr); + if ((rootAttr.width == mRootWidth) && (rootAttr.height == mRootHeight)) { + return; + } + mRootWidth = rootAttr.width; + mRootHeight = rootAttr.height; + generateBackingImages(); + + mBusy = true; + mHackDelayStartupTimer->stop(); + stopHack(); + DISABLE_CONTINUOUS_LOCKDLG_DISPLAY + mResizingDesktopLock = true; + + backingPixmap = TQPixmap(); + + if (trinity_desktop_lock_use_system_modal_dialogs) { + // Temporarily hide the entire screen with a new override redirect window + if (m_maskWidget) { + m_maskWidget->setGeometry(0, 0, mRootWidth, mRootHeight); + } + else { + m_maskWidget = new TQWidget(0, 0, TQt::WStyle_StaysOnTop | TQt::WX11BypassWM); + m_maskWidget->setGeometry(0, 0, mRootWidth, mRootHeight); + m_maskWidget->setBackgroundColor(TQt::black); + m_maskWidget->erase(); + m_maskWidget->show(); + } + XSync(tqt_xdisplay(), False); + saverReadyIfNeeded(); + + if (mEnsureScreenHiddenTimer) { + mEnsureScreenHiddenTimer->stop(); + } + else { + mEnsureScreenHiddenTimer = new TQTimer( this ); + connect( mEnsureScreenHiddenTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotForcePaintBackground()) ); + } + mEnsureScreenHiddenTimer->start(DESKTOP_WALLPAPER_OBTAIN_TIMEOUT_MS, true); + } + + // Resize the background widget + setGeometry(0, 0, mRootWidth, mRootHeight); XSync(tqt_xdisplay(), False); saverReadyIfNeeded(); - if (mEnsureScreenHiddenTimer) { - mEnsureScreenHiddenTimer->stop(); + // Black out the background widget to hide ugly resize tiling artifacts + if (argb_visual) { + setTransparentBackgroundARGB(); } else { - mEnsureScreenHiddenTimer = new TQTimer( this ); - connect( mEnsureScreenHiddenTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotForcePaintBackground()) ); - } - mEnsureScreenHiddenTimer->start(DESKTOP_WALLPAPER_OBTAIN_TIMEOUT_MS, true); - } - - // Resize the background widget - setGeometry(0, 0, mRootWidth, mRootHeight); - XSync(tqt_xdisplay(), False); - saverReadyIfNeeded(); - - // Black out the background widget to hide ugly resize tiling artifacts - if (argb_visual) { - setTransparentBackgroundARGB(); - } - else { - setBackgroundColor(black); - } - erase(); - - // This slot needs to be able to execute very rapidly so as to prevent the user's desktop from ever - // being displayed, so we finish the hack restarting/display prettying operations in a separate timed slot - if (resizeTimer == NULL) { - resizeTimer = new TQTimer( this ); - connect( resizeTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(doDesktopResizeFinish()) ); - } - resizeTimer->start( 100, TRUE ); // 100 millisecond single shot timer; should allow display switching operations to finish before hack is started + setBackgroundColor(black); + } + erase(); + + // This slot needs to be able to execute very rapidly so as to prevent the user's desktop from ever + // being displayed, so we finish the hack restarting/display prettying operations in a separate timed slot + if (resizeTimer == NULL) { + resizeTimer = new TQTimer( this ); + connect( resizeTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(doDesktopResizeFinish()) ); + } + resizeTimer->start( 100, true ); // 100 millisecond single shot timer; should allow display switching operations to finish before hack is started } void LockProcess::doDesktopResizeFinish() @@ -1063,7 +1079,7 @@ void LockProcess::doDesktopResizeFinish() } mDialogControlLock = true; if (closeCurrentWindow()) { - TQTimer::singleShot( 0, this, SLOT(doDesktopResizeFinish()) ); + TQTimer::singleShot( 0, this, TQ_SLOT(doDesktopResizeFinish()) ); mDialogControlLock = false; return; } @@ -1072,7 +1088,7 @@ void LockProcess::doDesktopResizeFinish() // Restart the hack as the window size is now different if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_use_system_modal_dialogs) { ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); + if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); } else { if (mHackStartupEnabled == true) { @@ -1081,7 +1097,7 @@ void LockProcess::doDesktopResizeFinish() else { if (trinity_desktop_lock_use_system_modal_dialogs == true) { ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); + if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); } else { startHack(); @@ -1099,23 +1115,23 @@ void LockProcess::doDesktopResizeFinish() // void LockProcess::hideSaverWindow() { - hide(); - lower(); - removeVRoot(winId()); - XDeleteProperty(tqt_xdisplay(), winId(), gXA_SCREENSAVER_VERSION); - if ( gVRoot ) { - unsigned long vroot_data[1] = { gVRootData }; - XChangeProperty(tqt_xdisplay(), gVRoot, gXA_VROOT, XA_WINDOW, 32, - PropModeReplace, (unsigned char *)vroot_data, 1); - gVRoot = 0; - } - XSync(tqt_xdisplay(), False); + hide(); + lower(); + removeVRoot(winId()); + XDeleteProperty(tqt_xdisplay(), winId(), gXA_SCREENSAVER_VERSION); + if ( gVRoot ) { + unsigned long vroot_data[1] = { gVRootData }; + XChangeProperty(tqt_xdisplay(), gVRoot, gXA_VROOT, XA_WINDOW, 32, + PropModeReplace, (unsigned char *)vroot_data, 1); + gVRoot = 0; + } + XSync(tqt_xdisplay(), False); } //--------------------------------------------------------------------------- static int ignoreXError(Display *, XErrorEvent *) { - return 0; + return 0; } //--------------------------------------------------------------------------- @@ -1124,44 +1140,39 @@ static int ignoreXError(Display *, XErrorEvent *) // void LockProcess::saveVRoot() { - Window rootReturn, parentReturn, *children; - unsigned int numChildren; - Window root = RootWindowOfScreen(ScreenOfDisplay(tqt_xdisplay(), tqt_xscreen())); - - gVRoot = 0; - gVRootData = 0; - - int (*oldHandler)(Display *, XErrorEvent *); - oldHandler = XSetErrorHandler(ignoreXError); - - if (XQueryTree(tqt_xdisplay(), root, &rootReturn, &parentReturn, - &children, &numChildren)) - { - for (unsigned int i = 0; i < numChildren; i++) - { - Atom actual_type; - int actual_format; - unsigned long nitems, bytesafter; - unsigned char *newRoot = 0; - - if ((XGetWindowProperty(tqt_xdisplay(), children[i], gXA_VROOT, 0, 1, - False, XA_WINDOW, &actual_type, &actual_format, &nitems, &bytesafter, - &newRoot) == Success) && newRoot) - { - gVRoot = children[i]; - Window *dummy = (Window*)newRoot; - gVRootData = *dummy; - XFree ((char*) newRoot); - break; - } - } - if (children) - { - XFree((char *)children); - } - } - - XSetErrorHandler(oldHandler); + Window rootReturn, parentReturn, *children; + unsigned int numChildren; + Window root = RootWindowOfScreen(ScreenOfDisplay(tqt_xdisplay(), tqt_xscreen())); + + gVRoot = 0; + gVRootData = 0; + + int (*oldHandler)(Display *, XErrorEvent *); + oldHandler = XSetErrorHandler(ignoreXError); + + if (XQueryTree(tqt_xdisplay(), root, &rootReturn, &parentReturn, &children, &numChildren)) { + for (unsigned int i = 0; i < numChildren; i++) { + Atom actual_type; + int actual_format; + unsigned long nitems, bytesafter; + unsigned char *newRoot = 0; + + if ((XGetWindowProperty(tqt_xdisplay(), children[i], gXA_VROOT, 0, 1, + False, XA_WINDOW, &actual_type, &actual_format, &nitems, &bytesafter, + &newRoot) == Success) && newRoot) { + gVRoot = children[i]; + Window *dummy = (Window*)newRoot; + gVRootData = *dummy; + XFree ((char*) newRoot); + break; + } + } + if (children) { + XFree((char *)children); + } + } + + XSetErrorHandler(oldHandler); } //--------------------------------------------------------------------------- @@ -1170,35 +1181,35 @@ void LockProcess::saveVRoot() // void LockProcess::setVRoot(Window win, Window vr) { - if (gVRoot) { - removeVRoot(gVRoot); - } - - unsigned long rw = RootWindowOfScreen(ScreenOfDisplay(tqt_xdisplay(), tqt_xscreen())); - unsigned long vroot_data[1] = { vr }; - - Window rootReturn; - Window parentReturn; - Window *children = NULL; - unsigned int numChildren; - Window top = win; - while (1) { - if (XQueryTree(tqt_xdisplay(), top, &rootReturn, &parentReturn, &children, &numChildren) == 0) { - printf("[WARNING] XQueryTree() failed!\n"); fflush(stdout); - break; - } - if (children) { - XFree((char *)children); - } - if (parentReturn == rw) { - break; - } - else { - top = parentReturn; - } - } - - XChangeProperty(tqt_xdisplay(), top, gXA_VROOT, XA_WINDOW, 32, PropModeReplace, (unsigned char *)vroot_data, 1); + if (gVRoot) { + removeVRoot(gVRoot); + } + + unsigned long rw = RootWindowOfScreen(ScreenOfDisplay(tqt_xdisplay(), tqt_xscreen())); + unsigned long vroot_data[1] = { vr }; + + Window rootReturn; + Window parentReturn; + Window *children = NULL; + unsigned int numChildren; + Window top = win; + while (1) { + if (XQueryTree(tqt_xdisplay(), top, &rootReturn, &parentReturn, &children, &numChildren) == 0) { + printf("[WARNING] XQueryTree() failed!\n"); fflush(stdout); + break; + } + if (children) { + XFree((char *)children); + } + if (parentReturn == rw) { + break; + } + else { + top = parentReturn; + } + } + + XChangeProperty(tqt_xdisplay(), top, gXA_VROOT, XA_WINDOW, 32, PropModeReplace, (unsigned char *)vroot_data, 1); } //--------------------------------------------------------------------------- @@ -1207,7 +1218,7 @@ void LockProcess::setVRoot(Window win, Window vr) // void LockProcess::removeVRoot(Window win) { - XDeleteProperty (tqt_xdisplay(), win, gXA_VROOT); + XDeleteProperty (tqt_xdisplay(), win, gXA_VROOT); } //--------------------------------------------------------------------------- @@ -1216,13 +1227,13 @@ void LockProcess::removeVRoot(Window win) // bool LockProcess::grabKeyboard() { - int rv = XGrabKeyboard( tqt_xdisplay(), TQApplication::desktop()->winId(), - True, GrabModeAsync, GrabModeAsync, CurrentTime ); + int rv = XGrabKeyboard( tqt_xdisplay(), TQApplication::desktop()->winId(), + True, GrabModeAsync, GrabModeAsync, CurrentTime ); - if (rv != GrabSuccess) { - kdWarning(1204) << "LockProcess::grabKeyboard() failed: " << rv << endl; - } - return (rv == GrabSuccess); + if (rv != GrabSuccess) { + kdWarning(1204) << "LockProcess::grabKeyboard() failed: " << rv << endl; + } + return (rv == GrabSuccess); } #define GRABEVENTS ButtonPressMask | ButtonReleaseMask | PointerMotionMask | \ @@ -1234,21 +1245,21 @@ bool LockProcess::grabKeyboard() // bool LockProcess::grabMouse() { - HANDLE cursorHandle; - if (mHackActive) { - cursorHandle = TQCursor(tqblankCursor).handle(); - } - else { - cursorHandle = TQCursor(tqbusyCursor).handle(); - } - int rv = XGrabPointer( tqt_xdisplay(), TQApplication::desktop()->winId(), - True, GRABEVENTS, GrabModeAsync, GrabModeAsync, None, - cursorHandle, CurrentTime ); + HANDLE cursorHandle; + if (mHackActive) { + cursorHandle = TQCursor(TQt::blankCursor).handle(); + } + else { + cursorHandle = TQCursor(TQt::busyCursor).handle(); + } + int rv = XGrabPointer( tqt_xdisplay(), TQApplication::desktop()->winId(), + True, GRABEVENTS, GrabModeAsync, GrabModeAsync, None, + cursorHandle, CurrentTime ); - if (rv != GrabSuccess) { - kdWarning(1204) << "LockProcess::grabMouse() failed: " << rv << endl; - } - return (rv == GrabSuccess); + if (rv != GrabSuccess) { + kdWarning(1204) << "LockProcess::grabMouse() failed: " << rv << endl; + } + return (rv == GrabSuccess); } //--------------------------------------------------------------------------- @@ -1257,32 +1268,28 @@ bool LockProcess::grabMouse() // bool LockProcess::grabInput() { - XSync(tqt_xdisplay(), False); + XSync(tqt_xdisplay(), False); - if (!grabKeyboard()) - { - usleep(100000); - if (!grabKeyboard()) - { - return false; - } - } + if (!grabKeyboard()) { + usleep(100000); + if (!grabKeyboard()) { + return false; + } + } #ifndef KEEP_MOUSE_UNGRABBED - if (!grabMouse()) - { - usleep(100000); - if (!grabMouse()) - { - XUngrabKeyboard(tqt_xdisplay(), CurrentTime); - return false; - } - } + if (!grabMouse()) { + usleep(100000); + if (!grabMouse()) { + XUngrabKeyboard(tqt_xdisplay(), CurrentTime); + return false; + } + } #endif - lockXF86(); + lockXF86(); - return true; + return true; } //--------------------------------------------------------------------------- @@ -1291,9 +1298,9 @@ bool LockProcess::grabInput() // void LockProcess::ungrabInput() { - XUngrabKeyboard(tqt_xdisplay(), CurrentTime); - XUngrabPointer(tqt_xdisplay(), CurrentTime); - unlockXF86(); + XUngrabKeyboard(tqt_xdisplay(), CurrentTime); + XUngrabPointer(tqt_xdisplay(), CurrentTime); + unlockXF86(); } //--------------------------------------------------------------------------- @@ -1339,7 +1346,8 @@ bool LockProcess::startSaver(bool notify_ready) { if (!child_saver && !grabInput()) { - kdWarning(1204) << "LockProcess::startSaver() grabInput() failed!!!!" << endl; + kdWarning(KDESKTOP_DEBUG_ID) << "LockProcess::startSaver() grabInput() failed!!!!" << endl; + trinity_desktop_lock_failed_grab = true; return false; } mBusy = false; @@ -1350,8 +1358,8 @@ bool LockProcess::startSaver(bool notify_ready) saveVRoot(); if (mParent) { - TQSocketNotifier *notifier = new TQSocketNotifier(mParent, TQSocketNotifier::Read, TQT_TQOBJECT(this), "notifier"); - connect(notifier, TQT_SIGNAL( activated (int)), TQT_SLOT( quitSaver())); + TQSocketNotifier *notifier = new TQSocketNotifier(mParent, TQSocketNotifier::Read, this, "notifier"); + connect(notifier, TQ_SIGNAL( activated (int)), TQ_SLOT( quitSaver())); } createSaverWindow(); move(0, 0); @@ -1367,7 +1375,8 @@ bool LockProcess::startSaver(bool notify_ready) slotPaintBackground(rootWinSnapShot); } - if (((!(trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced)) && (!mInSecureDialog)) && (mHackStartupEnabled || mOverrideHackStartupEnabled)) { + if (!(trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced) && !mInSecureDialog && + (mHackStartupEnabled || mOverrideHackStartupEnabled)) { if (argb_visual) { setTransparentBackgroundARGB(); } @@ -1394,10 +1403,10 @@ bool LockProcess::startSaver(bool notify_ready) } } - if (mInSecureDialog == FALSE) { + if (!mInSecureDialog) { if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced && trinity_desktop_lock_use_system_modal_dialogs) { ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); + if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); } else { if (mHackStartupEnabled || mOverrideHackStartupEnabled) { @@ -1407,7 +1416,7 @@ bool LockProcess::startSaver(bool notify_ready) else { if (trinity_desktop_lock_use_system_modal_dialogs == true) { ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); + if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); } else { startHack(); @@ -1425,39 +1434,42 @@ bool LockProcess::startSaver(bool notify_ready) // void LockProcess::stopSaver() { - kdDebug(1204) << "LockProcess: stopping saver" << endl; - mHackProc.kill(SIGCONT); - stopHack(); - mSuspended = false; - hideSaverWindow(); - mVisibility = false; - if (!child_saver) { - if (mLocked) - DM().setLock( false ); - ungrabInput(); - const char *out = "GOAWAY!"; - for (TQValueList<int>::ConstIterator it = child_sockets.begin(); it != child_sockets.end(); ++it) - if (write(*it, out, sizeof(out)) == -1) { - // Error handler to shut up gcc warnings - } - } + kdDebug(KDESKTOP_DEBUG_ID) << "LockProcess: stopping saver" << endl; + mHackProc.kill(SIGCONT); + stopHack(); + mSuspended = false; + hideSaverWindow(); + mVisibility = false; + if (!child_saver) { + if (mLocked) { + DM().setLock( false ); + } + ungrabInput(); + const char *out = "GOAWAY!"; + for (TQValueList<int>::ConstIterator it = child_sockets.begin(); it != child_sockets.end(); ++it) { + if (write(*it, out, sizeof(out)) == -1) { + // Error handler to shut up gcc warnings + } + } + } } // private static TQVariant LockProcess::getConf(void *ctx, const char *key, const TQVariant &dflt) { - LockProcess *that = (LockProcess *)ctx; - TQString fkey = TQString::fromLatin1( key ) + '='; - for (TQStringList::ConstIterator it = that->mPluginOptions.begin(); - it != that->mPluginOptions.end(); ++it) - if ((*it).startsWith( fkey )) - return (*it).mid( fkey.length() ); - return dflt; + LockProcess *that = (LockProcess *)ctx; + TQString fkey = TQString::fromLatin1( key ) + '='; + for (TQStringList::ConstIterator it = that->mPluginOptions.begin(); it != that->mPluginOptions.end(); ++it) { + if ((*it).startsWith( fkey )) { + return (*it).mid( fkey.length() ); + } + } + return dflt; } void LockProcess::cantLock( const TQString &txt) { - msgBox( TQMessageBox::Critical, i18n("Will not lock the session, as unlocking would be impossible:\n") + txt ); + msgBox( TQMessageBox::Critical, i18n("Will not lock the session, as unlocking would be impossible:\n") + txt ); } #if 0 // placeholders for later @@ -1471,42 +1483,41 @@ i18n("<i>kcheckpass</i> is unable to operate. Possibly it is not SetUID root."); // bool LockProcess::startLock() { - for (TQStringList::ConstIterator it = mPlugins.begin(); it != mPlugins.end(); ++it) { - GreeterPluginHandle plugin; - TQString path = KLibLoader::self()->findLibrary( - ((*it)[0] == '/' ? *it : "kgreet_" + *it ).latin1() ); - if (path.isEmpty()) { - kdWarning(1204) << "GreeterPlugin " << *it << " does not exist" << endl; - continue; - } - if (!(plugin.library = KLibLoader::self()->library( path.latin1() ))) { - kdWarning(1204) << "Cannot load GreeterPlugin " << *it << " (" << path << ")" << endl; - continue; - } - if (!plugin.library->hasSymbol( "kgreeterplugin_info" )) { - kdWarning(1204) << "GreeterPlugin " << *it << " (" << path << ") is no valid greet widget plugin" << endl; - plugin.library->unload(); - continue; - } - plugin.info = (kgreeterplugin_info*)plugin.library->symbol( "kgreeterplugin_info" ); - if (plugin.info->method && !mMethod.isEmpty() && mMethod != plugin.info->method) { - kdDebug(1204) << "GreeterPlugin " << *it << " (" << path << ") serves " << plugin.info->method << ", not " << mMethod << endl; - plugin.library->unload(); - continue; - } - if (!plugin.info->init( mMethod, getConf, this )) { - kdDebug(1204) << "GreeterPlugin " << *it << " (" << path << ") refuses to serve " << mMethod << endl; - plugin.library->unload(); - continue; - } - kdDebug(1204) << "GreeterPlugin " << *it << " (" << plugin.info->method << ", " << plugin.info->name << ") loaded" << endl; - greetPlugin = plugin; - mLocked = true; - DM().setLock( true ); - return true; - } - cantLock( i18n("No appropriate greeter plugin configured.") ); - return false; + for (TQStringList::ConstIterator it = mPlugins.begin(); it != mPlugins.end(); ++it) { + GreeterPluginHandle plugin; + TQString path = KLibLoader::self()->findLibrary( ((*it)[0] == '/' ? *it : "kgreet_" + *it ).latin1() ); + if (path.isEmpty()) { + kdWarning(KDESKTOP_DEBUG_ID) << "GreeterPlugin " << *it << " does not exist" << endl; + continue; + } + if (!(plugin.library = KLibLoader::self()->library( path.latin1() ))) { + kdWarning(KDESKTOP_DEBUG_ID) << "Cannot load GreeterPlugin " << *it << " (" << path << ")" << endl; + continue; + } + if (!plugin.library->hasSymbol( "kgreeterplugin_info" )) { + kdWarning(KDESKTOP_DEBUG_ID) << "GreeterPlugin " << *it << " (" << path << ") is no valid greet widget plugin" << endl; + plugin.library->unload(); + continue; + } + plugin.info = (kgreeterplugin_info*)plugin.library->symbol( "kgreeterplugin_info" ); + if (plugin.info->method && !mMethod.isEmpty() && mMethod != plugin.info->method) { + kdDebug(KDESKTOP_DEBUG_ID) << "GreeterPlugin " << *it << " (" << path << ") serves " << plugin.info->method << ", not " << mMethod << endl; + plugin.library->unload(); + continue; + } + if (!plugin.info->init( mMethod, getConf, this )) { + kdDebug(KDESKTOP_DEBUG_ID) << "GreeterPlugin " << *it << " (" << path << ") refuses to serve " << mMethod << endl; + plugin.library->unload(); + continue; + } + kdDebug(KDESKTOP_DEBUG_ID) << "GreeterPlugin " << *it << " (" << plugin.info->method << ", " << plugin.info->name << ") loaded" << endl; + greetPlugin = plugin; + mLocked = true; + DM().setLock( true ); + return true; + } + cantLock( i18n("No appropriate greeter plugin configured.") ); + return false; } //--------------------------------------------------------------------------- @@ -1524,7 +1535,7 @@ void LockProcess::closeDialogAndStartHack() // Make sure saver will attempt to start again after DPMS wakeup // This is related to Bug 1475 ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); + if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); // Should not start saver here, because the DPMS check method below would turn it right back off! // This is related to Bug 1475 return; @@ -1537,7 +1548,7 @@ void LockProcess::closeDialogAndStartHack() DISABLE_CONTINUOUS_LOCKDLG_DISPLAY mSuspended = true; if (closeCurrentWindow()) { - TQTimer::singleShot( 0, this, SLOT(closeDialogAndStartHack()) ); + TQTimer::singleShot( 0, this, TQ_SLOT(closeDialogAndStartHack()) ); } else { resume(true); @@ -1572,168 +1583,165 @@ void LockProcess::repaintRootWindowIfNeeded() bool LockProcess::startHack() { - mHackActive = TRUE; - - if ((mEnsureVRootWindowSecurityTimer) && (!mEnsureVRootWindowSecurityTimer->isActive())) mEnsureVRootWindowSecurityTimer->start(250, FALSE); + mHackActive = true; - if (currentDialog || (!mDialogs.isEmpty())) - { - // no resuming with dialog visible or when not visible - if (argb_visual) { - setTransparentBackgroundARGB(); + if ((mEnsureVRootWindowSecurityTimer) && (!mEnsureVRootWindowSecurityTimer->isActive())) { + mEnsureVRootWindowSecurityTimer->start(250, false); } - else { - if (backingPixmap.isNull()) { - setBackgroundColor(black); + + if (currentDialog || (!mDialogs.isEmpty())) { + // no resuming with dialog visible or when not visible + if (argb_visual) { + setTransparentBackgroundARGB(); } else { - setBackgroundPixmap(backingPixmap); + if (backingPixmap.isNull()) { + setBackgroundColor(black); + } + else { + setBackgroundPixmap(backingPixmap); + } } + setGeometry(0, 0, mRootWidth, mRootHeight); + erase(); + saverReadyIfNeeded(); + return false; } - setGeometry(0, 0, mRootWidth, mRootHeight); - erase(); - saverReadyIfNeeded(); - return false; - } - - setCursor( tqblankCursor ); - XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(tqblankCursor).handle(), CurrentTime); - - if (mSaverExec.isEmpty()) - { - return false; - } - - if (mHackProc.isRunning()) - { - stopHack(); - } - - mHackProc.clearArguments(); - - TQTextStream ts(&mSaverExec, IO_ReadOnly); - TQString word; - ts >> word; - TQString path = TDEStandardDirs::findExe(word); - - if (!path.isEmpty()) - { - mHackProc << path; - - kdDebug(1204) << "Starting hack: " << path << endl; - - while (!ts.atEnd()) - { - ts >> word; - if (word == "%w") - { - word = word.setNum(winId()); - } - mHackProc << word; - } - - if (!mForbidden) - { - if (trinity_desktop_lock_use_system_modal_dialogs) { - // Make sure we have a nice clean display to start with! - if (argb_visual) { - // Signal that we want to be transparent to a black background... - if (m_saverRootWindow) { - XChangeProperty(tqt_xdisplay(), m_saverRootWindow, kde_wm_transparent_to_black, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); - XClearArea(tqt_xdisplay(), m_saverRootWindow, 0, 0, 0, 0, True); - } - setTransparentBackgroundARGB(); + + setCursor( TQt::blankCursor ); + XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(TQt::blankCursor).handle(), CurrentTime); + + if (mSaverExec.isEmpty()) { + return false; + } + + if (mHackProc.isRunning()) { + stopHack(); + } + + mHackProc.clearArguments(); + + TQTextStream ts(&mSaverExec, IO_ReadOnly); + TQString word; + ts >> word; + TQString path = TDEStandardDirs::findExe(word); + + if (!path.isEmpty()) { + mHackProc << path; + + kdDebug(KDESKTOP_DEBUG_ID) << "Starting hack: " << path << endl; + + while (!ts.atEnd()) { + ts >> word; + if (word == "%w") + { + word = word.setNum(winId()); } - else { - if (backingPixmap.isNull()) { - setBackgroundColor(black); + mHackProc << word; + } + + if (!mForbidden) { + if (trinity_desktop_lock_use_system_modal_dialogs) { + // Make sure we have a nice clean display to start with! + if (argb_visual) { + // Signal that we want to be transparent to a black background... + if (m_saverRootWindow) { + XChangeProperty(tqt_xdisplay(), m_saverRootWindow, kde_wm_transparent_to_black, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); + XClearArea(tqt_xdisplay(), m_saverRootWindow, 0, 0, 0, 0, True); + } + setTransparentBackgroundARGB(); } else { - setBackgroundPixmap(backingPixmap); + if (backingPixmap.isNull()) { + setBackgroundColor(black); + } + else { + setBackgroundPixmap(backingPixmap); + } } + setGeometry(0, 0, mRootWidth, mRootHeight); + erase(); + saverReadyIfNeeded(); + mSuspended = false; } - setGeometry(0, 0, mRootWidth, mRootHeight); - erase(); - saverReadyIfNeeded(); - mSuspended = false; - } - XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(tqblankCursor).handle(), CurrentTime); - if (mHackProc.start() == true) - { + XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(TQt::blankCursor).handle(), CurrentTime); + if (mHackProc.start() == true) { #ifdef HAVE_SETPRIORITY - setpriority(PRIO_PROCESS, mHackProc.pid(), mPriority); + setpriority(PRIO_PROCESS, mHackProc.pid(), mPriority); #endif - //bitBlt(this, 0, 0, &mOriginal); - DISABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced) { - // Close any active dialogs - if (closeCurrentWindow()) { - TQTimer::singleShot( 0, this, SLOT(closeCurrentWindow()) ); + //bitBlt(this, 0, 0, &mOriginal); + DISABLE_CONTINUOUS_LOCKDLG_DISPLAY + if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced) { + // Close any active dialogs + if (closeCurrentWindow()) { + TQTimer::singleShot( 0, this, TQ_SLOT(closeCurrentWindow()) ); + } } + if (m_startupStatusDialog) { m_startupStatusDialog->closeSMDialog(); m_startupStatusDialog=NULL; } + return true; } - if (m_startupStatusDialog) { m_startupStatusDialog->closeSMDialog(); m_startupStatusDialog=NULL; } - return true; } - } - else - // we aren't allowed to start the specified screensaver either because it didn't run for some reason - // according to the kiosk restrictions forbid it - { - usleep(100); - TQApplication::syncX(); - if (!trinity_desktop_lock_use_system_modal_dialogs) { + else { + // we aren't allowed to start the specified screensaver either because it didn't run for some reason + // according to the kiosk restrictions forbid it + usleep(100); + TQApplication::syncX(); + if (!trinity_desktop_lock_use_system_modal_dialogs) { + if (argb_visual) { + setTransparentBackgroundARGB(); + } + else { + if (backingPixmap.isNull()) { + setBackgroundColor(black); + } + else { + setBackgroundPixmap(backingPixmap); + } + } + } if (argb_visual) { setTransparentBackgroundARGB(); + erase(); } else { if (backingPixmap.isNull()) { - setBackgroundColor(black); + setGeometry(0, 0, mRootWidth, mRootHeight); + erase(); } else { - setBackgroundPixmap(backingPixmap); + bitBlt(this, 0, 0, &backingPixmap); } } - } - if (argb_visual) { - setTransparentBackgroundARGB(); - erase(); - } - else { - if (backingPixmap.isNull()) { - setGeometry(0, 0, mRootWidth, mRootHeight); - erase(); - } - else { - bitBlt(this, 0, 0, &backingPixmap); + if (trinity_desktop_lock_use_system_modal_dialogs) { + ENABLE_CONTINUOUS_LOCKDLG_DISPLAY + if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); } + saverReadyIfNeeded(); } - if (trinity_desktop_lock_use_system_modal_dialogs) { - ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); - } - saverReadyIfNeeded(); } - } - if (m_startupStatusDialog) { m_startupStatusDialog->closeSMDialog(); m_startupStatusDialog=NULL; } - return false; + + if (m_startupStatusDialog) { + m_startupStatusDialog->closeSMDialog(); + m_startupStatusDialog=NULL; + } + + return false; } //--------------------------------------------------------------------------- // void LockProcess::stopHack() { - if (mHackProc.isRunning()) - { - mHackProc.kill(); - if (!mHackProc.wait(10)) - { - mHackProc.kill(SIGKILL); - } - } - setCursor( tqarrowCursor ); + if (mHackProc.isRunning()) { + mHackProc.kill(); + if (!mHackProc.wait(10)) { + mHackProc.kill(SIGKILL); + } + } + setCursor( TQt::arrowCursor ); - mHackActive = FALSE; + mHackActive = false; } //--------------------------------------------------------------------------- @@ -1742,7 +1750,7 @@ void LockProcess::hackExited(TDEProcess *) { // Hack exited while we're supposed to be saving the screen. // Make sure the saver window is black. - mHackActive = FALSE; + mHackActive = false; usleep(100); TQApplication::syncX(); if (!trinity_desktop_lock_use_system_modal_dialogs) { @@ -1777,7 +1785,7 @@ void LockProcess::hackExited(TDEProcess *) if (!mSuspended) { if (trinity_desktop_lock_use_system_modal_dialogs) { ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); + if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); } } saverReadyIfNeeded(); @@ -1789,100 +1797,98 @@ void LockProcess::displayLockDialogIfNeeded() m_startupStatusDialog->closeSMDialog(); m_startupStatusDialog = NULL; } - if (!mInSecureDialog) { - if (trinity_desktop_lock_use_system_modal_dialogs) { - if (!mBusy) { - mBusy = true; - if (mLocked) { - if (checkPass()) { - mClosingWindows = true; - stopSaver(); - kapp->quit(); - } + if (!mInSecureDialog && trinity_desktop_lock_use_system_modal_dialogs) { + if (!mBusy) { + mBusy = true; + if (mLocked) { + if (checkPass()) { + mClosingWindows = true; + stopSaver(); + tdeApp->quit(); } - mBusy = false; } + mBusy = false; } } } void LockProcess::suspend() { - if(!mSuspended) - { - if (trinity_desktop_lock_use_system_modal_dialogs) { - mSuspended = true; - stopHack(); - ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); - } - else { - TQString hackStatus; - mHackProc.kill(SIGSTOP); - mSuspended = true; + if (!mSuspended) { + if (trinity_desktop_lock_use_system_modal_dialogs) { + mSuspended = true; + stopHack(); + ENABLE_CONTINUOUS_LOCKDLG_DISPLAY + if (mHackStartupEnabled) { + mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); + } + } + else { + TQString hackStatus; + mHackProc.kill(SIGSTOP); + mSuspended = true; #if 0 - // wait for the stop signal to take effect - while (hackStatus != "T") { - char hackstat[8192]; - FILE *fp = fopen(TQString("/proc/%1/stat").arg(mHackProc.pid()).ascii(),"r"); - if (fp != NULL) { - fgets (hackstat, 8192, fp); - fclose (fp); - } - hackstat[8191] = 0; - hackStatus = hackstat; - hackStatus = hackStatus.remove(TQRegExp("(*) ", TRUE, TRUE)); - TQStringList hackStatusList = TQStringList::split(" ", hackStatus); - hackStatus = (*(hackStatusList.at(1))); - } + // wait for the stop signal to take effect + while (hackStatus != "T") { + char hackstat[8192]; + FILE *fp = fopen(TQString("/proc/%1/stat").arg(mHackProc.pid()).ascii(),"r"); + if (fp != NULL) { + fgets (hackstat, 8192, fp); + fclose (fp); + } + hackstat[8191] = 0; + hackStatus = hackstat; + hackStatus = hackStatus.remove(TQRegExp("(*) ", true, true)); + TQStringList hackStatusList = TQStringList::split(" ", hackStatus); + hackStatus = (*(hackStatusList.at(1))); + } #endif - TQApplication::syncX(); - usleep(100000); // Allow certain bad graphics drivers (*cough* fglrx *cough*) time to actually sync up the display - } - TQApplication::syncX(); - mSavedScreen = TQPixmap::grabWindow( winId()); - } + TQApplication::syncX(); + usleep(100000); // Allow certain bad graphics drivers (*cough* fglrx *cough*) time to actually sync up the display + } + TQApplication::syncX(); + mSavedScreen = TQPixmap::grabWindow( winId()); + } } void LockProcess::resume( bool force ) { - if (trinity_desktop_lock_use_sak && (mHackDelayStartupTimer->isActive() || !mHackStartupEnabled)) { - return; - } - if( !force && (!mDialogs.isEmpty() || !mVisibility )) { - // no resuming with dialog visible or when not visible - if (trinity_desktop_lock_use_system_modal_dialogs) { - if (argb_visual) { - setTransparentBackgroundARGB(); - } - else { - if (backingPixmap.isNull()) { - setBackgroundColor(black); + if (trinity_desktop_lock_use_sak && (mHackDelayStartupTimer->isActive() || !mHackStartupEnabled)) { + return; + } + if( !force && (!mDialogs.isEmpty() || !mVisibility )) { + // no resuming with dialog visible or when not visible + if (trinity_desktop_lock_use_system_modal_dialogs) { + if (argb_visual) { + setTransparentBackgroundARGB(); } else { - setBackgroundPixmap(backingPixmap); + if (backingPixmap.isNull()) { + setBackgroundColor(black); + } + else { + setBackgroundPixmap(backingPixmap); + } } + setGeometry(0, 0, mRootWidth, mRootHeight); + erase(); } - setGeometry(0, 0, mRootWidth, mRootHeight); - erase(); + else { + setGeometry(0, 0, mRootWidth, mRootHeight); + } + saverReadyIfNeeded(); + return; } - else { - setGeometry(0, 0, mRootWidth, mRootHeight); + if ((mSuspended) && (mHackProc.isRunning())) { + XForceScreenSaver(tqt_xdisplay(), ScreenSaverReset ); + bitBlt( this, 0, 0, &mSavedScreen ); + TQApplication::syncX(); + mHackProc.kill(SIGCONT); + mSuspended = false; + } + else if (mSuspended && trinity_desktop_lock_use_system_modal_dialogs) { + startHack(); } - saverReadyIfNeeded(); - return; - } - if ((mSuspended) && (mHackProc.isRunning())) - { - XForceScreenSaver(tqt_xdisplay(), ScreenSaverReset ); - bitBlt( this, 0, 0, &mSavedScreen ); - TQApplication::syncX(); - mHackProc.kill(SIGCONT); - mSuspended = false; - } - else if (mSuspended && trinity_desktop_lock_use_system_modal_dialogs) { - startHack(); - } } //--------------------------------------------------------------------------- @@ -1892,158 +1898,159 @@ void LockProcess::resume( bool force ) // bool LockProcess::checkPass() { - if (!mDialogs.isEmpty()) { - // Another dialog is already shown - // Abort! - return 0; - } - if (mInfoMessageDisplayed == false) { - if (mAutoLogout) { - killTimer(mAutoLogoutTimerId); - } - - // Make sure we never launch the SAK or login dialog if windows are being closed down - // Otherwise we can get stuck in an irrecoverable state where any attempt to show the login screen is instantly aborted - if (mClosingWindows) { - return 0; - } - - if (trinity_desktop_lock_use_sak) { - // Verify SAK operational status - TDEProcess* checkSAKProcess = new TDEProcess; - *checkSAKProcess << "tdmtsak" << "check"; - checkSAKProcess->start(TDEProcess::Block, TDEProcess::NoCommunication); - int retcode = checkSAKProcess->exitStatus(); - delete checkSAKProcess; - if (retcode != 0) { - trinity_desktop_lock_use_sak = false; - } - } - - if (trinity_desktop_lock_use_sak) { - // Wait for SAK press before continuing... - SAKDlg inDlg( this ); - execDialog( &inDlg ); - if (mClosingWindows) { - return 0; - } - } - - showVkbd(); - PasswordDlg passDlg( this, &greetPlugin, (mShowLockDateTime)?mlockDateTime:TQDateTime()); - int ret = execDialog( &passDlg ); - hideVkbd(); - - if (mForceReject == true) { - ret = TQDialog::Rejected; - } - mForceReject = false; - - XWindowAttributes rootAttr; - XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(), - tqt_xscreen()), &rootAttr); - if(( rootAttr.your_event_mask & SubstructureNotifyMask ) == 0 ) - { - kdWarning() << "ERROR: Something removed SubstructureNotifyMask from the root window!!!" << endl; - XSelectInput( tqt_xdisplay(), tqt_xrootwin(), - SubstructureNotifyMask | rootAttr.your_event_mask ); - } - - return ret == TQDialog::Accepted; - } - else { - return 0; - } + if (!mDialogs.isEmpty()) { + // Another dialog is already shown + // Abort! + return 0; + } + if (mInfoMessageDisplayed == false) { + if (mAutoLogout) { + killTimer(mAutoLogoutTimerId); + } + + // Make sure we never launch the SAK or login dialog if windows are being closed down + // Otherwise we can get stuck in an irrecoverable state where any attempt to show the login screen is instantly aborted + if (mClosingWindows) { + return 0; + } + + if (trinity_desktop_lock_use_sak) { + // Verify SAK operational status + TDEProcess* checkSAKProcess = new TDEProcess; + *checkSAKProcess << "tdmtsak" << "check"; + checkSAKProcess->start(TDEProcess::Block, TDEProcess::NoCommunication); + int retcode = checkSAKProcess->exitStatus(); + delete checkSAKProcess; + if (retcode != 0) { + trinity_desktop_lock_use_sak = false; + } + } + + if (trinity_desktop_lock_use_sak) { + // Wait for SAK press before continuing... + SAKDlg inDlg( this ); + execDialog( &inDlg ); + if (mClosingWindows) { + return 0; + } + } + + showVkbd(); + PasswordDlg passDlg( this, &greetPlugin, (mShowLockDateTime)?mlockDateTime:TQDateTime()); + int ret = execDialog( &passDlg ); + hideVkbd(); + + if (mForceReject == true) { + ret = TQDialog::Rejected; + } + mForceReject = false; + + XWindowAttributes rootAttr; + XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(), + tqt_xscreen()), &rootAttr); + if(( rootAttr.your_event_mask & SubstructureNotifyMask ) == 0 ) { + kdWarning() << "ERROR: Something removed SubstructureNotifyMask from the root window!!!" << endl; + XSelectInput( tqt_xdisplay(), tqt_xrootwin(), + SubstructureNotifyMask | rootAttr.your_event_mask ); + } + + return ret == TQDialog::Accepted; + } + else { + return 0; + } } static void fakeFocusIn( WId window ) { - // We have keyboard grab, so this application will - // get keyboard events even without having focus. - // Fake FocusIn to make Qt realize it has the active - // window, so that it will correctly show cursor in the dialog. - XEvent ev; - memset(&ev, 0, sizeof(ev)); - ev.xfocus.display = tqt_xdisplay(); - ev.xfocus.type = FocusIn; - ev.xfocus.window = window; - ev.xfocus.mode = NotifyNormal; - ev.xfocus.detail = NotifyAncestor; - XSendEvent( tqt_xdisplay(), window, False, NoEventMask, &ev ); + // We have keyboard grab, so this application will + // get keyboard events even without having focus. + // Fake FocusIn to make Qt realize it has the active + // window, so that it will correctly show cursor in the dialog. + XEvent ev; + memset(&ev, 0, sizeof(ev)); + ev.xfocus.display = tqt_xdisplay(); + ev.xfocus.type = FocusIn; + ev.xfocus.window = window; + ev.xfocus.mode = NotifyNormal; + ev.xfocus.detail = NotifyAncestor; + XSendEvent( tqt_xdisplay(), window, False, NoEventMask, &ev ); } void LockProcess::resumeUnforced() { - resume( false ); + resume( false ); } int LockProcess::execDialog( TQDialog *dlg ) { - currentDialog=dlg; - dlg->adjustSize(); - - TQRect rect = dlg->geometry(); - rect.moveCenter(TDEGlobalSettings::desktopGeometry(TQCursor::pos()).center()); - dlg->move( rect.topLeft() ); - - if (mDialogs.isEmpty()) - { - suspend(); - XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(tqarrowCursor).handle(), CurrentTime); - } - mDialogs.prepend( dlg ); - fakeFocusIn( dlg->winId()); - if (trinity_desktop_lock_use_system_modal_dialogs) { - if (backingPixmap.isNull()) { - setGeometry(0, 0, mRootWidth, mRootHeight); - erase(); - } - else { - bitBlt(this, 0, 0, &backingPixmap); - } - saverReadyIfNeeded(); - } - // dlg->exec may generate BadMatch errors, so make sure they are silently ignored - int (*oldHandler)(Display *, XErrorEvent *); - oldHandler = XSetErrorHandler(ignoreXError); - int rt = dlg->exec(); - XSetErrorHandler(oldHandler); - while (mDialogControlLock == true) usleep(100000); - currentDialog = NULL; - mDialogs.remove( dlg ); - if( mDialogs.isEmpty() ) { - HANDLE cursorHandle; - if (mHackActive) { - cursorHandle = TQCursor(tqblankCursor).handle(); - } - else { - cursorHandle = TQCursor(tqbusyCursor).handle(); - } - XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, cursorHandle, CurrentTime); - if (trinity_desktop_lock_use_system_modal_dialogs) { - // Slight delay before screensaver resume to allow the dialog window to fully disappear - if (hackResumeTimer == NULL) { - hackResumeTimer = new TQTimer( this ); - connect( hackResumeTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(resumeUnforced()) ); - } - if (mResizingDesktopLock == false) { - hackResumeTimer->start( 10, TRUE ); - } - } - else { - resume( false ); - } - } else { - fakeFocusIn( mDialogs.first()->winId()); - currentDialog = dynamic_cast<TQDialog*>(mDialogs.first()); - } - return rt; + currentDialog=dlg; + dlg->adjustSize(); + + TQRect rect = dlg->geometry(); + rect.moveCenter(TDEGlobalSettings::desktopGeometry(TQCursor::pos()).center()); + dlg->move( rect.topLeft() ); + + if (mDialogs.isEmpty()) { + suspend(); + XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(TQt::arrowCursor).handle(), CurrentTime); + } + mDialogs.prepend( dlg ); + fakeFocusIn( dlg->winId()); + if (trinity_desktop_lock_use_system_modal_dialogs) { + if (backingPixmap.isNull()) { + setGeometry(0, 0, mRootWidth, mRootHeight); + erase(); + } + else { + bitBlt(this, 0, 0, &backingPixmap); + } + saverReadyIfNeeded(); + } + // dlg->exec may generate BadMatch errors, so make sure they are silently ignored + int (*oldHandler)(Display *, XErrorEvent *); + oldHandler = XSetErrorHandler(ignoreXError); + int rt = dlg->exec(); + XSetErrorHandler(oldHandler); + while (mDialogControlLock == true) { + usleep(100000); + } + currentDialog = NULL; + mDialogs.remove( dlg ); + if( mDialogs.isEmpty() ) { + HANDLE cursorHandle; + if (mHackActive) { + cursorHandle = TQCursor(TQt::blankCursor).handle(); + } + else { + cursorHandle = TQCursor(TQt::busyCursor).handle(); + } + XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, cursorHandle, CurrentTime); + if (trinity_desktop_lock_use_system_modal_dialogs) { + // Slight delay before screensaver resume to allow the dialog window to fully disappear + if (hackResumeTimer == NULL) { + hackResumeTimer = new TQTimer( this ); + connect( hackResumeTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(resumeUnforced()) ); + } + if (mResizingDesktopLock == false) { + hackResumeTimer->start( 10, true ); + } + } + else { + resume( false ); + } + } + else { + fakeFocusIn( mDialogs.first()->winId()); + currentDialog = dynamic_cast<TQDialog*>(mDialogs.first()); + } + return rt; } void LockProcess::slotForcePaintBackground() { TQPixmap blankPixmap(mRootWidth, mRootHeight); - blankPixmap.fill(Qt::black); + blankPixmap.fill(TQt::black); slotPaintBackground(blankPixmap); printf("[WARNING] Unable to obtain desktop wallpaper in a timely manner. High system load or possibly a TDE bug!\n"); fflush(stdout); } @@ -2062,7 +2069,7 @@ void LockProcess::slotPaintBackground(const TQPixmap &rpm) } else { mEnsureScreenHiddenTimer = new TQTimer( this ); - connect( mEnsureScreenHiddenTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotForcePaintBackground()) ); + connect( mEnsureScreenHiddenTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotForcePaintBackground()) ); } // Only remove the mask widget once the resize is 100% complete! @@ -2105,36 +2112,38 @@ void LockProcess::slotPaintBackground(const TQPixmap &rpm) void LockProcess::preparePopup() { - TQWidget *dlg = (TQWidget *)sender(); - mDialogs.prepend( dlg ); - fakeFocusIn( dlg->winId() ); + TQWidget *dlg = (TQWidget *)sender(); + mDialogs.prepend( dlg ); + fakeFocusIn( dlg->winId() ); } void LockProcess::cleanupPopup() { - TQWidget *dlg = (TQWidget *)sender(); - mDialogs.remove( dlg ); - if ( mDialogs.isEmpty() ) { - fakeFocusIn( mDialogs.first()->winId() ); - } + TQWidget *dlg = (TQWidget *)sender(); + mDialogs.remove( dlg ); + if ( mDialogs.isEmpty() ) { + fakeFocusIn( mDialogs.first()->winId() ); + } } void LockProcess::doFunctionKeyBroadcast() { - // Provide a clean, pretty display switch by hiding the password dialog here - // This does NOT work with the SAK or system modal dialogs! - if ((!trinity_desktop_lock_use_system_modal_dialogs) && (!trinity_desktop_lock_use_sak)) { - mBusy=true; - TQTimer::singleShot(1000, this, TQT_SLOT(slotDeadTimePassed())); - if (mkeyCode == XKeysymToKeycode(tqt_xdisplay(), XF86XK_Display)) { - while (mDialogControlLock == true) usleep(100000); - mDialogControlLock = true; - currentDialog->close(); // DO NOT use closeCurrentWindow() here! - mDialogControlLock = false; - } - } - - DCOPRef ref( "*", "MainApplication-Interface"); - ref.send("sendFakeKey", DCOPArg(mkeyCode , "unsigned int")); + // Provide a clean, pretty display switch by hiding the password dialog here + // This does NOT work with the SAK or system modal dialogs! + if ((!trinity_desktop_lock_use_system_modal_dialogs) && (!trinity_desktop_lock_use_sak)) { + mBusy=true; + TQTimer::singleShot(1000, this, TQ_SLOT(slotDeadTimePassed())); + if (mkeyCode == XKeysymToKeycode(tqt_xdisplay(), XF86XK_Display)) { + while (mDialogControlLock == true) { + usleep(100000); + } + mDialogControlLock = true; + currentDialog->close(); // DO NOT use closeCurrentWindow() here! + mDialogControlLock = false; + } + } + + DCOPRef ref( "*", "MainApplication-Interface"); + ref.send("sendFakeKey", DCOPArg(mkeyCode , "unsigned int")); } //--------------------------------------------------------------------------- @@ -2143,203 +2152,203 @@ void LockProcess::doFunctionKeyBroadcast() { // bool LockProcess::x11Event(XEvent *event) { - // Allow certain very specific keypresses through - // Key: Reason: - // XF86Display You need to be able to see the screen when unlocking your computer - // XF86AudioMute Would be nice to be able to shut your computer up in an emergency while it is locked - // XF86AudioRaiseVolume Ditto - // XF86AudioLowerVolume Ditto - // XF86XK_PowerOff If someone has access to the power button, they can hard power off the machine anyway - // XF86XK_Sleep Ditto - // XF86XK_Suspend Ditto - // XF86XK_Hibernate Ditto - - //if ((event->type == KeyPress) || (event->type == KeyRelease)) { - if (event->type == KeyPress) { - // Multimedia keys - if ((event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_Display)) || \ - (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_AudioMute)) || \ - (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_AudioRaiseVolume)) || \ - (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_AudioLowerVolume))) { - mkeyCode = event->xkey.keycode; - TQTimer::singleShot( 100, this, TQT_SLOT(doFunctionKeyBroadcast()) ); - return true; - } - // ACPI power keys - if ((event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_PowerOff)) || \ - (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_Sleep)) || \ - (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_Suspend)) || \ - (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_Hibernate))) { - mkeyCode = event->xkey.keycode; - TQTimer::singleShot( 100, this, TQT_SLOT(doFunctionKeyBroadcast()) ); - return true; - } - } - - switch (event->type) - { - case ButtonPress: - case MotionNotify: - case ButtonRelease: - if( forwardVkbdEvent( event )) - return true; // filter out - // fall through - case KeyPress: - if ((mHackDelayStartupTimer) && (mHackDelayStartupTimer->isActive())) { - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); - } - if (mBusy || !mDialogs.isEmpty()) - break; - mBusy = true; - if (trinity_desktop_lock_delay_screensaver_start) { - if (mLocked) { - ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); - } - if ((!mLocked) && (!mInSecureDialog)) - { - stopSaver(); - kapp->quit(); - } - if (mAutoLogout) // we need to restart the auto logout countdown - { - killTimer(mAutoLogoutTimerId); - mAutoLogoutTimerId = startTimer(mAutoLogoutTimeout); - } - } - else { - if (!mLocked || checkPass()) - { - mClosingWindows = true; - stopSaver(); - kapp->quit(); - } - else if (mAutoLogout) // we need to restart the auto logout countdown - { - killTimer(mAutoLogoutTimerId); - mAutoLogoutTimerId = startTimer(mAutoLogoutTimeout); - } - } - mBusy = false; - return true; - - case VisibilityNotify: - if( event->xvisibility.window == winId()) - { // mVisibility == false means the screensaver is not visible at all - // e.g. when switched to text console - mVisibility = !(event->xvisibility.state == VisibilityFullyObscured); - if(!mVisibility) { - mSuspendTimer.start(2000, true); - } - else - { - mSuspendTimer.stop(); - if (mResizingDesktopLock == false) { - if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced && trinity_desktop_lock_use_system_modal_dialogs) { - // Do nothing + // Allow certain very specific keypresses through + // Key: Reason: + // XF86Display You need to be able to see the screen when unlocking your computer + // XF86AudioMute Would be nice to be able to shut your computer up in an emergency while it is locked + // XF86AudioRaiseVolume Ditto + // XF86AudioLowerVolume Ditto + // XF86XK_PowerOff If someone has access to the power button, they can hard power off the machine anyway + // XF86XK_Sleep Ditto + // XF86XK_Suspend Ditto + // XF86XK_Hibernate Ditto + + //if ((event->type == KeyPress) || (event->type == KeyRelease)) { + if (event->type == KeyPress) { + // Multimedia keys + if ((event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_Display)) || \ + (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_AudioMute)) || \ + (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_AudioRaiseVolume)) || \ + (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_AudioLowerVolume))) { + mkeyCode = event->xkey.keycode; + TQTimer::singleShot( 100, this, TQ_SLOT(doFunctionKeyBroadcast()) ); + return true; + } + // ACPI power keys + if ((event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_PowerOff)) || \ + (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_Sleep)) || \ + (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_Suspend)) || \ + (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_Hibernate))) { + mkeyCode = event->xkey.keycode; + TQTimer::singleShot( 100, this, TQ_SLOT(doFunctionKeyBroadcast()) ); + return true; + } + } + + switch (event->type) + { + case ButtonPress: + case MotionNotify: + case ButtonRelease: + if( forwardVkbdEvent( event )) { + return true; // filter out + } + // fall through + case KeyPress: + if ((mHackDelayStartupTimer) && (mHackDelayStartupTimer->isActive())) { + if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); + } + if (mBusy || !mDialogs.isEmpty()) { + break; + } + mBusy = true; + if (trinity_desktop_lock_delay_screensaver_start) { + if (mLocked) { + ENABLE_CONTINUOUS_LOCKDLG_DISPLAY + if (mHackStartupEnabled) { + mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); + } + } + if (!mLocked && !mInSecureDialog) { + stopSaver(); + tdeApp->quit(); + } + if (mAutoLogout) { + // we need to restart the auto logout countdown + killTimer(mAutoLogoutTimerId); + mAutoLogoutTimerId = startTimer(mAutoLogoutTimeout); + } } else { - if (mHackStartupEnabled == true) { - resume( false ); + if (!mLocked || checkPass()) { + mClosingWindows = true; + stopSaver(); + tdeApp->quit(); + } + else if (mAutoLogout) { + // we need to restart the auto logout countdown + killTimer(mAutoLogoutTimerId); + mAutoLogoutTimerId = startTimer(mAutoLogoutTimeout); + } + } + mBusy = false; + return true; + + case VisibilityNotify: + if( event->xvisibility.window == winId()) { + // mVisibility == false means the screensaver is not visible at all + // e.g. when switched to text console + mVisibility = !(event->xvisibility.state == VisibilityFullyObscured); + if(!mVisibility) { + mSuspendTimer.start(2000, true); } else { - if (trinity_desktop_lock_use_system_modal_dialogs == true) { - ENABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); - } - else { - resume( false ); + mSuspendTimer.stop(); + if (mResizingDesktopLock == false) { + if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced && trinity_desktop_lock_use_system_modal_dialogs) { + // Do nothing + } + else { + if (mHackStartupEnabled == true) { + resume( false ); + } + else { + if (trinity_desktop_lock_use_system_modal_dialogs == true) { + ENABLE_CONTINUOUS_LOCKDLG_DISPLAY + if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, true); + } + else { + resume( false ); + } + } + } } } + if (event->xvisibility.state != VisibilityUnobscured) { + stayOnTop(); + } } - } - } - if (event->xvisibility.state != VisibilityUnobscured) { - stayOnTop(); - } - } - break; - - case ConfigureNotify: // from SubstructureNotifyMask on the root window - if(event->xconfigure.event == tqt_xrootwin()) { - stayOnTop(); - } - for( TQValueList< VkbdWindow >::Iterator it = mVkbdWindows.begin(); - it != mVkbdWindows.end(); - ++it ) { - if( (*it).id == event->xconfigure.window ) { - (*it).rect = TQRect( event->xconfigure.x, event->xconfigure.y, - event->xconfigure.width, event->xconfigure.height ); - break; - } - } - break; - case MapNotify: // from SubstructureNotifyMask on the root window - windowAdded( event->xmap.window, false ); - if( event->xmap.event == tqt_xrootwin()) - stayOnTop(); - break; - case DestroyNotify: - for( TQValueList< VkbdWindow >::Iterator it = mVkbdWindows.begin(); - it != mVkbdWindows.end(); - ++it ) - if( (*it).id == event->xdestroywindow.window ) { - mVkbdWindows.remove( it ); - break; - } - break; - } - - // We have grab with the grab window being the root window. - // This results in key events being sent to the root window, - // but they should be sent to the dialog if it's visible. - // It could be solved by setFocus() call, but that would mess - // the focus after this process exits. - // Qt seems to be quite hard to persuade to redirect the event, - // so let's simply dupe it with correct destination window, - // and ignore the original one. - if(!mDialogs.isEmpty() && ( event->type == KeyPress || event->type == KeyRelease) - && event->xkey.window != mDialogs.first()->winId()) - { - XEvent ev2 = *event; - ev2.xkey.window = ev2.xkey.subwindow = mDialogs.first()->winId(); - tqApp->x11ProcessEvent( &ev2 ); - return true; - } - - return false; + break; + + case ConfigureNotify: // from SubstructureNotifyMask on the root window + if(event->xconfigure.event == tqt_xrootwin()) { + stayOnTop(); + } + for( TQValueList< VkbdWindow >::Iterator it = mVkbdWindows.begin(); + it != mVkbdWindows.end(); + ++it ) { + if( (*it).id == event->xconfigure.window ) { + (*it).rect = TQRect( event->xconfigure.x, event->xconfigure.y, + event->xconfigure.width, event->xconfigure.height ); + break; + } + } + break; + case MapNotify: // from SubstructureNotifyMask on the root window + windowAdded( event->xmap.window, false ); + if( event->xmap.event == tqt_xrootwin()) { + stayOnTop(); + } + break; + case DestroyNotify: + for( TQValueList< VkbdWindow >::Iterator it = mVkbdWindows.begin(); it != mVkbdWindows.end(); ++it ) { + if( (*it).id == event->xdestroywindow.window ) { + mVkbdWindows.remove( it ); + break; + } + } + break; + } + + // We have grab with the grab window being the root window. + // This results in key events being sent to the root window, + // but they should be sent to the dialog if it's visible. + // It could be solved by setFocus() call, but that would mess + // the focus after this process exits. + // Qt seems to be quite hard to persuade to redirect the event, + // so let's simply dupe it with correct destination window, + // and ignore the original one. + if(!mDialogs.isEmpty() && ( event->type == KeyPress || event->type == KeyRelease) + && event->xkey.window != mDialogs.first()->winId()) { + XEvent ev2 = *event; + ev2.xkey.window = ev2.xkey.subwindow = mDialogs.first()->winId(); + tdeApp->x11ProcessEvent( &ev2 ); + return true; + } + + return false; } void LockProcess::stayOnTop() { - if(!mDialogs.isEmpty() || !mVkbdWindows.isEmpty()) - { - // this restacking is written in a way so that - // if the stacking positions actually don't change, - // all restacking operations will be no-op, - // and no ConfigureNotify will be generated, - // thus avoiding possible infinite loops - if( !mVkbdWindows.isEmpty()) - XRaiseWindow( tqt_xdisplay(), mVkbdWindows.first().id ); - else - XRaiseWindow( tqt_xdisplay(), mDialogs.first()->winId()); // raise topmost - // and stack others below it - Window* stack = new Window[ mDialogs.count() + mVkbdWindows.count() + 1 ]; - int count = 0; - for( TQValueList< VkbdWindow >::ConstIterator it = mVkbdWindows.begin(); - it != mVkbdWindows.end(); - ++it ) - stack[ count++ ] = (*it).id; - for( TQValueList< TQWidget* >::ConstIterator it = mDialogs.begin(); - it != mDialogs.end(); - ++it ) - stack[ count++ ] = (*it)->winId(); - stack[ count++ ] = winId(); - XRestackWindows( x11Display(), stack, count ); - delete[] stack; - } - else - XRaiseWindow(tqt_xdisplay(), winId()); + if(!mDialogs.isEmpty() || !mVkbdWindows.isEmpty()) { + // this restacking is written in a way so that + // if the stacking positions actually don't change, + // all restacking operations will be no-op, + // and no ConfigureNotify will be generated, + // thus avoiding possible infinite loops + if( !mVkbdWindows.isEmpty()) { + XRaiseWindow( tqt_xdisplay(), mVkbdWindows.first().id ); + } + else { + XRaiseWindow( tqt_xdisplay(), mDialogs.first()->winId()); // raise topmost + } + // and stack others below it + Window* stack = new Window[ mDialogs.count() + mVkbdWindows.count() + 1 ]; + int count = 0; + for( TQValueList< VkbdWindow >::ConstIterator it = mVkbdWindows.begin(); it != mVkbdWindows.end(); ++it ) { + stack[ count++ ] = (*it).id; + } + for( TQValueList< TQWidget* >::ConstIterator it = mDialogs.begin(); it != mDialogs.end(); ++it ) { + stack[ count++ ] = (*it)->winId(); + } + stack[ count++ ] = winId(); + XRestackWindows( x11Display(), stack, count ); + delete[] stack; + } + else { + XRaiseWindow(tqt_xdisplay(), winId()); + } } void LockProcess::checkDPMSActive() @@ -2370,233 +2379,239 @@ void LockProcess::checkDPMSActive() static enum { Unknown, Yes, No } can_do_xf86_lock = Unknown; void LockProcess::lockXF86() { - if( can_do_xf86_lock == Unknown ) - { - int major, minor; - if( XF86MiscQueryVersion( tqt_xdisplay(), &major, &minor ) - && major >= 0 && minor >= 5 ) - can_do_xf86_lock = Yes; - else - can_do_xf86_lock = No; - } - if( can_do_xf86_lock != Yes ) - return; - if( mRestoreXF86Lock ) - return; - if( XF86MiscSetGrabKeysState( tqt_xdisplay(), False ) != MiscExtGrabStateSuccess ) - return; - // success - mRestoreXF86Lock = true; + if( can_do_xf86_lock == Unknown ) { + int major, minor; + if( XF86MiscQueryVersion( tqt_xdisplay(), &major, &minor ) && major >= 0 && minor >= 5 ) { + can_do_xf86_lock = Yes; + } + else { + can_do_xf86_lock = No; + } + } + if( can_do_xf86_lock != Yes ) { + return; + } + if( mRestoreXF86Lock ) { + return; + } + if( XF86MiscSetGrabKeysState( tqt_xdisplay(), False ) != MiscExtGrabStateSuccess ) { + return; + } + // success + mRestoreXF86Lock = true; } void LockProcess::unlockXF86() { - if( can_do_xf86_lock != Yes ) - return; - if( !mRestoreXF86Lock ) - return; - XF86MiscSetGrabKeysState( tqt_xdisplay(), True ); - mRestoreXF86Lock = false; + if( can_do_xf86_lock != Yes ) { + return; + } + if( !mRestoreXF86Lock ) { + return; + } + XF86MiscSetGrabKeysState( tqt_xdisplay(), True ); + mRestoreXF86Lock = false; } #else void LockProcess::lockXF86() { + // } void LockProcess::unlockXF86() { + // } #endif void LockProcess::msgBox( TQMessageBox::Icon type, const TQString &txt ) { - TQDialog box( 0, "messagebox", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM)) ); - if (trinity_desktop_lock_use_system_modal_dialogs) { - // Signal that we do not want any window controls to be shown at all - XChangeProperty(tqt_xdisplay(), box.winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); - } - box.setCaption(i18n("Authentication Subsystem Notice")); - TQFrame *winFrame = new TQFrame( &box ); - if (trinity_desktop_lock_use_system_modal_dialogs) - winFrame->setFrameStyle( TQFrame::NoFrame ); - else - winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised ); - winFrame->setLineWidth( 2 ); - TQLabel *label1 = new TQLabel( winFrame ); - label1->setPixmap( TQMessageBox::standardIcon( type ) ); - TQLabel *label2 = new TQLabel( txt, winFrame ); - KPushButton *button = new KPushButton( KStdGuiItem::ok(), winFrame ); - button->setDefault( true ); - button->setSizePolicy( TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Preferred ) ); - connect( button, TQT_SIGNAL( clicked() ), &box, TQT_SLOT( accept() ) ); - - TQVBoxLayout *vbox = new TQVBoxLayout( &box ); - vbox->addWidget( winFrame ); - TQGridLayout *grid = new TQGridLayout( winFrame, 2, 2, 10 ); - grid->addWidget( label1, 0, 0, Qt::AlignCenter ); - grid->addWidget( label2, 0, 1, Qt::AlignCenter ); - grid->addMultiCellWidget( button, 1,1, 0,1, Qt::AlignCenter ); - - execDialog( &box ); + TQDialog box( 0, "messagebox", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM)) ); + if (trinity_desktop_lock_use_system_modal_dialogs) { + // Signal that we do not want any window controls to be shown at all + XChangeProperty(tqt_xdisplay(), box.winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); + } + box.setCaption(i18n("Authentication Subsystem Notice")); + TQFrame *winFrame = new TQFrame( &box ); + if (trinity_desktop_lock_use_system_modal_dialogs) { + winFrame->setFrameStyle( TQFrame::NoFrame ); + } + else { + winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised ); + } + winFrame->setLineWidth( 2 ); + TQLabel *label1 = new TQLabel( winFrame ); + label1->setPixmap( TQMessageBox::standardIcon( type ) ); + TQLabel *label2 = new TQLabel( txt, winFrame ); + KPushButton *button = new KPushButton( KStdGuiItem::ok(), winFrame ); + button->setDefault( true ); + button->setSizePolicy( TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Preferred ) ); + connect( button, TQ_SIGNAL( clicked() ), &box, TQ_SLOT( accept() ) ); + + TQVBoxLayout *vbox = new TQVBoxLayout( &box ); + vbox->addWidget( winFrame ); + TQGridLayout *grid = new TQGridLayout( winFrame, 2, 2, 10 ); + grid->addWidget( label1, 0, 0, TQt::AlignCenter ); + grid->addWidget( label2, 0, 1, TQt::AlignCenter ); + grid->addMultiCellWidget( button, 1,1, 0,1, TQt::AlignCenter ); + + execDialog( &box ); } static int run_vkbd = -1; void LockProcess::showVkbd() { - if( run_vkbd == - 1 ) { -#ifdef WITH_HAL - int status = system( "hal-find-by-property --key system.formfactor.subtype --string tabletpc" ); -// status = 0; // enable for testing - run_vkbd = ( WIFEXITED( status ) && WEXITSTATUS( status ) == 0 - && !TDEStandardDirs::findExe( "xvkbd" ).isEmpty()) ? 1 : 0; -#else // WITH_HAL - run_vkbd = (!TDEStandardDirs::findExe( "xvkbd" ).isEmpty()); -#endif // WITH_HAL - } - if( run_vkbd ) { - mVkbdWindows.clear(); - mVkbdLastEventWindow = None; - mKWinModule = new KWinModule( NULL, KWinModule::INFO_WINDOWS ); - connect( mKWinModule, TQT_SIGNAL( windowAdded( WId )), TQT_SLOT( windowAdded( WId ))); - mVkbdProcess = new TDEProcess; - *mVkbdProcess << "xvkbd" << "-compact" << "-geometry" << "-0-0" << "-xdm"; - mVkbdProcess->start(); - } + if( run_vkbd == - 1 ) { + run_vkbd = (!TDEStandardDirs::findExe( "xvkbd" ).isEmpty()); + } + if( run_vkbd ) { + mVkbdWindows.clear(); + mVkbdLastEventWindow = None; + mKWinModule = new KWinModule( NULL, KWinModule::INFO_WINDOWS ); + connect( mKWinModule, TQ_SIGNAL( windowAdded( WId )), TQ_SLOT( windowAdded( WId ))); + mVkbdProcess = new TDEProcess; + *mVkbdProcess << "xvkbd" << "-compact" << "-geometry" << "-0-0" << "-xdm"; + mVkbdProcess->start(); + } } void LockProcess::hideVkbd() { - if( mVkbdProcess != NULL ) { - mVkbdProcess->kill(); - delete mVkbdProcess; - mVkbdProcess = NULL; - delete mKWinModule; - mKWinModule = NULL; - mVkbdWindows.clear(); - } + if( mVkbdProcess != NULL ) { + mVkbdProcess->kill(); + delete mVkbdProcess; + mVkbdProcess = NULL; + delete mKWinModule; + mKWinModule = NULL; + mVkbdWindows.clear(); + } } void LockProcess::windowAdded( WId w ) { - windowAdded( w, true ); + windowAdded( w, true ); } void LockProcess::windowAdded( WId w, bool managed ) { - // KWin::windowInfo may generate BadWindow errors, so make sure they are silently ignored - int (*oldHandler)(Display *, XErrorEvent *); - oldHandler = XSetErrorHandler(ignoreXError); - KWin::WindowInfo info = KWin::windowInfo( w, 0, NET::WM2WindowClass ); - XSetErrorHandler(oldHandler); - - if( info.windowClassClass().lower() != "xvkbd" ) - return; - // Unmanaged windows (i.e. popups) don't currently work anyway, since they - // don't have WM_CLASS set anyway. I could perhaps try tricks with X id - // ranges if really needed. - if( managed ) { - // withdraw the window, wait for it to be withdrawn, reparent it directly - // to root at the right position - XWithdrawWindow( tqt_xdisplay(), w, tqt_xscreen()); - for(;;) { - Atom type; - int format; - unsigned long length, after; - unsigned char *data; - int r = XGetWindowProperty( tqt_xdisplay(), w, tqt_wm_state, 0, 2, - false, AnyPropertyType, &type, &format, - &length, &after, &data ); - bool withdrawn = true; - if ( r == Success && data && format == 32 ) { - TQ_UINT32 *wstate = (TQ_UINT32*)data; - withdrawn = (*wstate == WithdrawnState ); - XFree( (char *)data ); - } - if( withdrawn ) - break; - } - } - XSelectInput( tqt_xdisplay(), w, StructureNotifyMask ); - XWindowAttributes attr_geom; - if( !XGetWindowAttributes( tqt_xdisplay(), w, &attr_geom )) - return; - int x = XDisplayWidth( tqt_xdisplay(), tqt_xscreen()) - attr_geom.width; - int y = XDisplayHeight( tqt_xdisplay(), tqt_xscreen()) - attr_geom.height; - if( managed ) { - XSetWindowAttributes attr; - if (!trinity_desktop_lock_use_system_modal_dialogs) { - attr.override_redirect = True; - XChangeWindowAttributes( tqt_xdisplay(), w, CWOverrideRedirect, &attr ); - } - XReparentWindow( tqt_xdisplay(), w, tqt_xrootwin(), x, y ); - XMapWindow( tqt_xdisplay(), w ); - } - VkbdWindow data; - data.id = w; - data.rect = TQRect( x, y, attr_geom.width, attr_geom.height ); - mVkbdWindows.prepend( data ); + // KWin::windowInfo may generate BadWindow errors, so make sure they are silently ignored + int (*oldHandler)(Display *, XErrorEvent *); + oldHandler = XSetErrorHandler(ignoreXError); + KWin::WindowInfo info = KWin::windowInfo( w, 0, NET::WM2WindowClass ); + XSetErrorHandler(oldHandler); + + if( info.windowClassClass().lower() != "xvkbd" ) { + return; + } + // Unmanaged windows (i.e. popups) don't currently work anyway, since they + // don't have WM_CLASS set anyway. I could perhaps try tricks with X id + // ranges if really needed. + if( managed ) { + // withdraw the window, wait for it to be withdrawn, reparent it directly + // to root at the right position + XWithdrawWindow( tqt_xdisplay(), w, tqt_xscreen()); + for(;;) { + Atom type; + int format; + unsigned long length, after; + unsigned char *data; + int r = XGetWindowProperty( tqt_xdisplay(), w, tqt_wm_state, 0, 2, + false, AnyPropertyType, &type, &format, + &length, &after, &data ); + bool withdrawn = true; + if ( r == Success && data && format == 32 ) { + TQ_UINT32 *wstate = (TQ_UINT32*)data; + withdrawn = (*wstate == WithdrawnState ); + XFree( (char *)data ); + } + if( withdrawn ) { + break; + } + } + } + XSelectInput( tqt_xdisplay(), w, StructureNotifyMask ); + XWindowAttributes attr_geom; + if( !XGetWindowAttributes( tqt_xdisplay(), w, &attr_geom )) { + return; + } + int x = XDisplayWidth( tqt_xdisplay(), tqt_xscreen()) - attr_geom.width; + int y = XDisplayHeight( tqt_xdisplay(), tqt_xscreen()) - attr_geom.height; + if( managed ) { + XSetWindowAttributes attr; + if (!trinity_desktop_lock_use_system_modal_dialogs) { + attr.override_redirect = True; + XChangeWindowAttributes( tqt_xdisplay(), w, CWOverrideRedirect, &attr ); + } + XReparentWindow( tqt_xdisplay(), w, tqt_xrootwin(), x, y ); + XMapWindow( tqt_xdisplay(), w ); + } + VkbdWindow data; + data.id = w; + data.rect = TQRect( x, y, attr_geom.width, attr_geom.height ); + mVkbdWindows.prepend( data ); } bool LockProcess::forwardVkbdEvent( XEvent* event ) { - if( mVkbdProcess == NULL ) - return false; - TQPoint pos; - Time time; - switch( event->type ) - { - case ButtonPress: - case ButtonRelease: - pos = TQPoint( event->xbutton.x, event->xbutton.y ); - time = event->xbutton.time; - break; - case MotionNotify: - pos = TQPoint( event->xmotion.x, event->xmotion.y ); - time = event->xmotion.time; - break; - default: - return false; - } - // vkbd windows are kept topmost, so just find the first one in the position - for( TQValueList< VkbdWindow >::ConstIterator it = mVkbdWindows.begin(); - it != mVkbdWindows.end(); - ++it ) { - if( TQT_TQRECT_OBJECT((*it).rect).contains( pos )) { - // Find the subwindow where the event should actually go. - // Not exactly cheap in the number of X roundtrips but oh well. - Window window = (*it).id; - Window root, child; - int root_x, root_y, x, y; - unsigned int mask; - for(;;) { - if( !XQueryPointer( tqt_xdisplay(), window, &root, &child, &root_x, &root_y, &x, &y, &mask )) - return false; - if( child == None ) - break; - window = child; - } - switch( event->type ) - { - case ButtonPress: - case ButtonRelease: - event->xbutton.x = x; - event->xbutton.y = y; - event->xbutton.subwindow = None; - break; - case MotionNotify: - event->xmotion.x = x; - event->xmotion.y = y; - event->xmotion.subwindow = None; - break; - } - event->xany.window = window; - sendVkbdFocusInOut( window, time ); - XSendEvent( tqt_xdisplay(), window, False, 0, event ); - return true; - } - } - sendVkbdFocusInOut( None, time ); - return false; + if( mVkbdProcess == NULL ) { + return false; + } + TQPoint pos; + Time time; + switch( event->type ) + { + case ButtonPress: + case ButtonRelease: + pos = TQPoint( event->xbutton.x, event->xbutton.y ); + time = event->xbutton.time; + break; + case MotionNotify: + pos = TQPoint( event->xmotion.x, event->xmotion.y ); + time = event->xmotion.time; + break; + default: + return false; + } + // vkbd windows are kept topmost, so just find the first one in the position + for( TQValueList< VkbdWindow >::ConstIterator it = mVkbdWindows.begin(); it != mVkbdWindows.end(); ++it ) { + if( (*it).rect.contains( pos )) { + // Find the subwindow where the event should actually go. + // Not exactly cheap in the number of X roundtrips but oh well. + Window window = (*it).id; + Window root, child; + int root_x, root_y, x, y; + unsigned int mask; + for(;;) { + if( !XQueryPointer( tqt_xdisplay(), window, &root, &child, &root_x, &root_y, &x, &y, &mask )) { + return false; + } + if( child == None ) { + break; + } + window = child; + } + switch( event->type ) + { + case ButtonPress: + case ButtonRelease: + event->xbutton.x = x; + event->xbutton.y = y; + event->xbutton.subwindow = None; + break; + case MotionNotify: + event->xmotion.x = x; + event->xmotion.y = y; + event->xmotion.subwindow = None; + break; + } + event->xany.window = window; + sendVkbdFocusInOut( window, time ); + XSendEvent( tqt_xdisplay(), window, False, 0, event ); + return true; + } + } + sendVkbdFocusInOut( None, time ); + return false; } // Fake EnterNotify/LeaveNotify events as the mouse moves. They're not sent by X @@ -2604,47 +2619,48 @@ bool LockProcess::forwardVkbdEvent( XEvent* event ) // not needed otherwise it seems). void LockProcess::sendVkbdFocusInOut( WId window, Time t ) { - if( mVkbdLastEventWindow == window ) - return; - if( mVkbdLastEventWindow != None ) { - XEvent e; - e.xcrossing.type = LeaveNotify; - e.xcrossing.display = tqt_xdisplay(); - e.xcrossing.window = mVkbdLastEventWindow; - e.xcrossing.root = tqt_xrootwin(); - e.xcrossing.subwindow = None; - e.xcrossing.time = t; - e.xcrossing.x = 0; - e.xcrossing.y = 0; - e.xcrossing.x_root = -1; - e.xcrossing.y_root = -1; - e.xcrossing.mode = NotifyNormal; - e.xcrossing.detail = NotifyAncestor; - e.xcrossing.same_screen = True; - e.xcrossing.focus = False; - e.xcrossing.state = 0; - XSendEvent( tqt_xdisplay(), mVkbdLastEventWindow, False, 0, &e ); - } - mVkbdLastEventWindow = window; - if( mVkbdLastEventWindow != None ) { - XEvent e; - e.xcrossing.type = EnterNotify; - e.xcrossing.display = tqt_xdisplay(); - e.xcrossing.window = mVkbdLastEventWindow; - e.xcrossing.root = tqt_xrootwin(); - e.xcrossing.subwindow = None; - e.xcrossing.time = t; - e.xcrossing.x = 0; - e.xcrossing.y = 0; - e.xcrossing.x_root = 0; - e.xcrossing.y_root = 0; - e.xcrossing.mode = NotifyNormal; - e.xcrossing.detail = NotifyAncestor; - e.xcrossing.same_screen = True; - e.xcrossing.focus = False; - e.xcrossing.state = 0; - XSendEvent( tqt_xdisplay(), mVkbdLastEventWindow, False, 0, &e ); - } + if( mVkbdLastEventWindow == window ) { + return; + } + if( mVkbdLastEventWindow != None ) { + XEvent e; + e.xcrossing.type = LeaveNotify; + e.xcrossing.display = tqt_xdisplay(); + e.xcrossing.window = mVkbdLastEventWindow; + e.xcrossing.root = tqt_xrootwin(); + e.xcrossing.subwindow = None; + e.xcrossing.time = t; + e.xcrossing.x = 0; + e.xcrossing.y = 0; + e.xcrossing.x_root = -1; + e.xcrossing.y_root = -1; + e.xcrossing.mode = NotifyNormal; + e.xcrossing.detail = NotifyAncestor; + e.xcrossing.same_screen = True; + e.xcrossing.focus = False; + e.xcrossing.state = 0; + XSendEvent( tqt_xdisplay(), mVkbdLastEventWindow, False, 0, &e ); + } + mVkbdLastEventWindow = window; + if( mVkbdLastEventWindow != None ) { + XEvent e; + e.xcrossing.type = EnterNotify; + e.xcrossing.display = tqt_xdisplay(); + e.xcrossing.window = mVkbdLastEventWindow; + e.xcrossing.root = tqt_xrootwin(); + e.xcrossing.subwindow = None; + e.xcrossing.time = t; + e.xcrossing.x = 0; + e.xcrossing.y = 0; + e.xcrossing.x_root = 0; + e.xcrossing.y_root = 0; + e.xcrossing.mode = NotifyNormal; + e.xcrossing.detail = NotifyAncestor; + e.xcrossing.same_screen = True; + e.xcrossing.focus = False; + e.xcrossing.state = 0; + XSendEvent( tqt_xdisplay(), mVkbdLastEventWindow, False, 0, &e ); + } } void LockProcess::slotMouseActivity(XEvent *event) @@ -2666,7 +2682,7 @@ void LockProcess::slotMouseActivity(XEvent *event) } // Clicked inside dialog; set focus - if (inFrame == TRUE) { + if (inFrame) { WId window = mDialogs.first()->winId(); XSetInputFocus(tqt_xdisplay(), window, RevertToParent, CurrentTime); fakeFocusIn(window); @@ -2676,20 +2692,20 @@ void LockProcess::slotMouseActivity(XEvent *event) } // Clicked inside window handle (or border); drag window - if ((inFrame == TRUE) && (inDialog == FALSE)) { + if (inFrame && !inDialog) { TQPoint oldPoint = mDialogs.first()->pos(); m_mouseDown = 1; m_dialogPrevX = oldPoint.x(); m_dialogPrevY = oldPoint.y(); m_mousePrevX = be->x_root; m_mousePrevY = be->y_root; - XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(tqsizeAllCursor).handle(), CurrentTime); + XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(TQt::sizeAllCursor).handle(), CurrentTime); } } // Drag the window... if (event->type == MotionNotify) { - if (m_mouseDown == TRUE) { + if (m_mouseDown) { int deltaX = me->x_root - m_mousePrevX; int deltaY = me->y_root - m_mousePrevY; m_dialogPrevX = m_dialogPrevX + deltaX; @@ -2703,14 +2719,14 @@ void LockProcess::slotMouseActivity(XEvent *event) if (event->type == ButtonRelease) { m_mouseDown = 0; - XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(tqarrowCursor).handle(), CurrentTime); + XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(TQt::arrowCursor).handle(), CurrentTime); } } void LockProcess::processInputPipeCommand(TQString inputcommand) { TQCString command(inputcommand.ascii()); TQString to_display; - const char * pin_entry; + TQString pin_entry; if (command[0] == 'C') { while (mDialogControlLock == true) usleep(100000); @@ -2798,7 +2814,8 @@ void LockProcess::processInputPipeCommand(TQString inputcommand) { pin_entry = qryDlg.getEntry(); mInfoMessageDisplayed=false; if (mPipeOpen_out == true) { - if (write(mPipe_fd_out, pin_entry, strlen(pin_entry)+1) == -1) { + TQCString pin_entry_local8 = pin_entry.local8Bit(); // local 8 bit length may differ from TQString length + if (write(mPipe_fd_out, pin_entry_local8.data(), pin_entry_local8.length()+1) == -1) { // Error handler to shut up gcc warnings } if (write(mPipe_fd_out, "\n\r", 3) == -1) { @@ -2812,6 +2829,119 @@ void LockProcess::processInputPipeCommand(TQString inputcommand) { } } +void LockProcess::cryptographicCardInserted(TDECryptographicCardDevice* cdevice) { +#ifdef WITH_TDEHWLIB + TQString login_name = TQString::null; + X509CertificatePtrList certList = cdevice->cardX509Certificates(); + if (certList.count() > 0) { + KSSLCertificate* card_cert = NULL; + card_cert = KSSLCertificate::fromX509(certList[0]); + TQStringList cert_subject_parts = TQStringList::split("/", card_cert->getSubject(), false); + for (TQStringList::Iterator it = cert_subject_parts.begin(); it != cert_subject_parts.end(); ++it ) { + TQString lcpart = (*it).lower(); + if (lcpart.startsWith("cn=")) { + login_name = lcpart.right(lcpart.length() - strlen("cn=")); + } + } + delete card_cert; + } + + if (login_name != "") { + KUser user; + if (login_name == user.loginName()) { + // Pass login to the PAM stack... + m_loginCardDevice = cdevice; + if (dynamic_cast<SAKDlg*>(currentDialog)) { + dynamic_cast<SAKDlg*>(currentDialog)->closeDialogForced(); + TQTimer::singleShot(0, this, TQ_SLOT(signalPassDlgToAttemptCardLogin())); + } + else if (dynamic_cast<SecureDlg*>(currentDialog)) { + dynamic_cast<SecureDlg*>(currentDialog)->closeDialogForced(); + TQTimer::singleShot(0, this, TQ_SLOT(signalPassDlgToAttemptCardLogin())); + } + else if (dynamic_cast<PasswordDlg*>(currentDialog)) { + signalPassDlgToAttemptCardLogin(); + } + } + } +#endif +} + +void LockProcess::cryptographicCardRemoved(TDECryptographicCardDevice* cdevice) { +#ifdef WITH_TDEHWLIB + PasswordDlg* passDlg = dynamic_cast<PasswordDlg*>(currentDialog); + if (passDlg) { + passDlg->resetCardLogin(); + } + else { + m_loginCardDevice = NULL; + TQTimer::singleShot(0, this, TQ_SLOT(signalPassDlgToAttemptCardAbort())); + } +#endif +} + +void LockProcess::signalPassDlgToAttemptCardLogin() +{ +#ifdef WITH_TDEHWLIB + PasswordDlg* passDlg = dynamic_cast<PasswordDlg*>(currentDialog); + if (passDlg && m_loginCardDevice) { + passDlg->attemptCardLogin(); + } + else { + if (currentDialog && m_loginCardDevice) { + // Try again later + TQTimer::singleShot(0, this, TQ_SLOT(signalPassDlgToAttemptCardLogin())); + } + } +#endif +} + +void LockProcess::signalPassDlgToAttemptCardAbort() +{ +#ifdef WITH_TDEHWLIB + PasswordDlg* passDlg = dynamic_cast<PasswordDlg*>(currentDialog); + if (passDlg) { + passDlg->resetCardLogin(); + } + else { + if (currentDialog) { + // Try again later + TQTimer::singleShot(0, this, TQ_SLOT(signalPassDlgToAttemptCardAbort())); + } + } +#endif +} + +void LockProcess::cryptographicCardPinRequested(TQString prompt, TDECryptographicCardDevice* cdevice) +{ +#ifdef WITH_TDEHWLIB + TQCString password; + TQString pin_entry; + + QueryDlg qryDlg(this); + qryDlg.updateLabel(prompt); + qryDlg.setUnlockIcon(); + mForceReject = false; + execDialog(&qryDlg); + if (mForceReject == false) { + pin_entry = qryDlg.getEntry(); + cdevice->setProvidedPin(pin_entry); + } + else { + cdevice->setProvidedPin(TQString::null); + } +#endif +} + +TDECryptographicCardDevice* LockProcess::cryptographicCardDevice() +{ +#ifdef WITH_TDEHWLIB + return m_loginCardDevice; +#else + return NULL; +#endif +} + void LockProcess::fullyOnline() { if (!mFullyOnlineSent) { if (kdesktop_pid > 0) { @@ -2837,7 +2967,7 @@ void LockProcess::saverReady() { // Control pipe handler // ControlPipeHandlerObject::ControlPipeHandlerObject() : TQObject() { - mParent = NULL; + mParent = nullptr; mRunning = false; mTerminate = false; mThreadID = 0L; @@ -2861,7 +2991,7 @@ void ControlPipeHandlerObject::run(void) { int display_number = atoi(TQString(XDisplayString(tqt_xdisplay())).replace(":","").ascii()); if (display_number < 0) { - printf("[kdesktop_lock] Warning: unable to create control socket. Interactive logon modules may not function properly.\n"); + printf("[kdesktop_lock] Warning: unable to create control socket. Interactive logon modules may not function properly.\n"); mRunning = false; TQApplication::eventLoop()->exit(-1); return; @@ -2877,22 +3007,22 @@ void ControlPipeHandlerObject::run(void) { mkdir(FIFO_DIR,0644); mknod(fifo_file, S_IFIFO|0644, 0); chmod(fifo_file, 0644); - + mParent->mPipe_fd = open(fifo_file, O_RDONLY | O_NONBLOCK); if (mParent->mPipe_fd > -1) { mParent->mPipeOpen = true; } - + mknod(fifo_file_out, S_IFIFO|0600, 0); chmod(fifo_file_out, 0600); - + mParent->mPipe_fd_out = open(fifo_file_out, O_RDWR | O_NONBLOCK); if (mParent->mPipe_fd_out > -1) { mParent->mPipeOpen_out = true; } if (!mParent->mPipeOpen) { - printf("[kdesktop_lock] Warning: unable to create control socket '%s'. Interactive logon modules may not function properly.\n", fifo_file); + printf("[kdesktop_lock] Warning: unable to create control socket '%s'. Interactive logon modules may not function properly.\n", fifo_file); mRunning = false; TQApplication::eventLoop()->exit(-1); return; diff --git a/kdesktop/lock/lockprocess.h b/kdesktop/lock/lockprocess.h index 34e3da8e0..1afc9bb46 100644 --- a/kdesktop/lock/lockprocess.h +++ b/kdesktop/lock/lockprocess.h @@ -1,18 +1,17 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // // Copyright (c) 1999 Martin R. Jones <mjones@kde.org> // Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org> -// Copyright (c) 2010-2013 Timothy Pearson <kb9vqf@pearsoncomputing.net> +// Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> // #ifndef __LOCKENG_H__ #define __LOCKENG_H__ #include <kgreeterplugin.h> - -#include <kprocess.h> +#include <tdeprocess.h> #include <kpixmap.h> #include <krootpixmap.h> @@ -30,10 +29,15 @@ class KLibrary; class KWinModule; class KSMModalDialog; class LockProcess; +#ifdef WITH_TDEHWLIB +class TDECryptographicCardDevice; +#else +#define TDECryptographicCardDevice void +#endif struct GreeterPluginHandle { - KLibrary *library; - kgreeterplugin_info *info; + KLibrary *library; + kgreeterplugin_info *info; }; #define FIFO_DIR "/tmp/tdesocket-global" @@ -48,7 +52,7 @@ typedef TQValueList<Window> TQXLibWindowList; // class ControlPipeHandlerObject : public TQObject { - Q_OBJECT + TQ_OBJECT public: ControlPipeHandlerObject(); @@ -57,7 +61,7 @@ class ControlPipeHandlerObject : public TQObject public slots: void run(); void terminateThread(); - + signals: void processCommand(TQString); @@ -75,195 +79,199 @@ class ControlPipeHandlerObject : public TQObject // Screen saver handling process. Handles screensaver window, // starting screensaver hacks, and password entry. // -class LockProcess - : public TQWidget +class LockProcess : public TQWidget { - Q_OBJECT -public: - LockProcess(); - ~LockProcess(); - - void init(bool child_saver = false, bool useBlankOnly = false); - - bool lock(); - - bool defaultSave(); - - bool dontLock(); - - bool runSecureDialog(); - bool inSecureDialog(); - - void setChildren(TQValueList<int> children) { child_sockets = children; } - void setParent(int fd) { mParent = fd; } - - void msgBox( TQMessageBox::Icon type, const TQString &txt ); - int execDialog( TQDialog* dlg ); - -signals: - void terminateHelperThread(); - -public slots: - void quitSaver(); - void preparePopup(); - void cleanupPopup(); - void desktopResized(); - void doDesktopResizeFinish(); - void doFunctionKeyBroadcast(); - void slotPaintBackground(const TQPixmap &pm); - void slotForcePaintBackground(); - -protected: - virtual bool x11Event(XEvent *); - virtual void timerEvent(TQTimerEvent *); - virtual void resizeEvent(TQResizeEvent *); - -private slots: - void hackExited(TDEProcess *); - void signalPipeSignal(); - bool startLock(); - void suspend(); - void checkDPMSActive(); - void slotDeadTimePassed(); - void windowAdded( WId ); - void resumeUnforced(); - void displayLockDialogIfNeeded(); - void closeDialogAndStartHack(); - bool closeCurrentWindow(); - void repaintRootWindowIfNeeded(); - void startSecureDialog(); - void slotMouseActivity(XEvent *event); - void processInputPipeCommand(TQString command); - -private: - void configure(); - void readSaver(); - void createSaverWindow(); - void hideSaverWindow(); - void saveVRoot(); - void setVRoot(Window win, Window rw); - void removeVRoot(Window win); - void setTransparentBackgroundARGB(); - bool grabKeyboard(); - bool grabMouse(); - bool grabInput(); - void ungrabInput(); - void cantLock(const TQString &reason); - bool startSaver(bool notify_ready = false); - void stopSaver(); - bool startHack(); - void stopHack(); - void setupSignals(); - bool checkPass(); - void stayOnTop(); - void lockXF86(); - void unlockXF86(); - void showVkbd(); - void hideVkbd(); - void saverReady(); - void saverReadyIfNeeded(); - bool forwardVkbdEvent( XEvent* event ); - void sendVkbdFocusInOut( WId window, Time t ); - void windowAdded( WId window, bool managed ); - void resume( bool force ); - static TQVariant getConf(void *ctx, const char *key, const TQVariant &dflt); - void generateBackingImages(); - void fullyOnline(); - - bool mLocked; - int mLockGrace; - int mPriority; - bool mBusy; - TDEProcess mHackProc; - int mRootWidth; - int mRootHeight; - TQString mSaverExec; - TQString mSaver; - bool mOpenGLVisual; - bool child_saver; - TQValueList<int> child_sockets; - int mParent; - bool mUseBlankOnly; - bool mShowLockDateTime; - bool mSuspended; - TQTimer mSuspendTimer; - bool mVisibility; - TQTimer mCheckDPMS; - TQValueStack< TQWidget* > mDialogs; - bool mRestoreXF86Lock; - bool mForbidden; - TQStringList mPlugins, mPluginOptions; - TQString mMethod; - GreeterPluginHandle greetPlugin; - TQPixmap mSavedScreen; - int mAutoLogoutTimerId; - int mAutoLogoutTimeout; - bool mAutoLogout; - - TQTimer *resizeTimer; - unsigned int mkeyCode; - - TQTimer *hackResumeTimer; - - TDEProcess* mVkbdProcess; - KWinModule* mKWinModule; - struct VkbdWindow - { - WId id; - TQRect rect; - }; - TQValueList< VkbdWindow > mVkbdWindows; - WId mVkbdLastEventWindow; - - bool mPipeOpen; - int mPipe_fd; - bool mPipeOpen_out; - int mPipe_fd_out; - - bool mInfoMessageDisplayed; - bool mDialogControlLock; - bool mForceReject; - TQDialog *currentDialog; - - TQTimer* mEnsureScreenHiddenTimer; - TQTimer* mForceContinualLockDisplayTimer; - TQTimer* mEnsureVRootWindowSecurityTimer; - TQTimer* mHackDelayStartupTimer; - - int mHackDelayStartupTimeout; - bool mHackStartupEnabled; - bool mOverrideHackStartupEnabled; - bool mResizingDesktopLock; - bool mFullyOnlineSent; - - bool mClosingWindows; - bool mInSecureDialog; - bool mHackActive; - - TQPixmap backingPixmap; - KRootPixmap *m_rootPixmap; - int mBackingStartupDelayTimer; - TQPixmap mArgbTransparentBackgroundPixmap; - - KSMModalDialog* m_startupStatusDialog; - - TQDateTime mlockDateTime; - - bool m_mouseDown; - int m_mousePrevX; - int m_mousePrevY; - int m_dialogPrevX; - int m_dialogPrevY; - - bool m_notifyReadyRequested; - - TQWidget* m_maskWidget; - Window m_saverRootWindow; - - ControlPipeHandlerObject* mControlPipeHandler; - TQEventLoopThread* mControlPipeHandlerThread; - - friend class ControlPipeHandlerObject; + TQ_OBJECT + + public: + LockProcess(); + ~LockProcess(); + + void init(bool child_saver = false, bool useBlankOnly = false); + + bool lock(); + + bool defaultSave(); + + bool dontLock(); + + bool runSecureDialog(); + bool inSecureDialog(); + + void setChildren(TQValueList<int> children) { child_sockets = children; } + void setParent(int fd) { mParent = fd; } + + void msgBox( TQMessageBox::Icon type, const TQString &txt ); + int execDialog( TQDialog* dlg ); + + TDECryptographicCardDevice* cryptographicCardDevice(); + + public slots: + void quitSaver(); + void preparePopup(); + void cleanupPopup(); + void desktopResized(); + void doDesktopResizeFinish(); + void doFunctionKeyBroadcast(); + void slotPaintBackground(const TQPixmap &pm); + void slotForcePaintBackground(); + + protected: + virtual bool x11Event(XEvent *); + virtual void timerEvent(TQTimerEvent *); + virtual void resizeEvent(TQResizeEvent *); + + private slots: + void hackExited(TDEProcess *); + void signalPipeSignal(); + bool startLock(); + void suspend(); + void checkDPMSActive(); + void slotDeadTimePassed(); + void windowAdded( WId ); + void resumeUnforced(); + void displayLockDialogIfNeeded(); + void closeDialogAndStartHack(); + bool closeCurrentWindow(); + void repaintRootWindowIfNeeded(); + void startSecureDialog(); + void slotMouseActivity(XEvent *event); + void processInputPipeCommand(TQString command); + void cryptographicCardInserted(TDECryptographicCardDevice*); + void cryptographicCardRemoved(TDECryptographicCardDevice*); + void cryptographicCardPinRequested(TQString prompt, TDECryptographicCardDevice* cdevice); + void signalPassDlgToAttemptCardLogin(); + void signalPassDlgToAttemptCardAbort(); + + private: + void configure(); + void readSaver(); + void createSaverWindow(); + void hideSaverWindow(); + void saveVRoot(); + void setVRoot(Window win, Window rw); + void removeVRoot(Window win); + void setTransparentBackgroundARGB(); + bool grabKeyboard(); + bool grabMouse(); + bool grabInput(); + void ungrabInput(); + void cantLock(const TQString &reason); + bool startSaver(bool notify_ready = false); + void stopSaver(); + bool startHack(); + void stopHack(); + void setupSignals(); + bool checkPass(); + void stayOnTop(); + void lockXF86(); + void unlockXF86(); + void showVkbd(); + void hideVkbd(); + void saverReady(); + void saverReadyIfNeeded(); + bool forwardVkbdEvent( XEvent* event ); + void sendVkbdFocusInOut( WId window, Time t ); + void windowAdded( WId window, bool managed ); + void resume( bool force ); + static TQVariant getConf(void *ctx, const char *key, const TQVariant &dflt); + void generateBackingImages(); + void fullyOnline(); + + bool mLocked; + int mLockGrace; + int mPriority; + bool mBusy; + TDEProcess mHackProc; + int mRootWidth; + int mRootHeight; + TQString mSaverExec; + TQString mSaver; + bool mOpenGLVisual; + bool child_saver; + TQValueList<int> child_sockets; + int mParent; + bool mUseBlankOnly; + bool mShowLockDateTime; + bool mSuspended; + TQTimer mSuspendTimer; + bool mVisibility; + TQTimer mCheckDPMS; + TQValueStack< TQWidget* > mDialogs; + bool mRestoreXF86Lock; + bool mForbidden; + TQStringList mPlugins, mPluginOptions; + TQString mMethod; + GreeterPluginHandle greetPlugin; + TQPixmap mSavedScreen; + int mAutoLogoutTimerId; + int mAutoLogoutTimeout; + bool mAutoLogout; + + TQTimer *resizeTimer; + unsigned int mkeyCode; + + TQTimer *hackResumeTimer; + + TDEProcess* mVkbdProcess; + KWinModule* mKWinModule; + struct VkbdWindow { + WId id; + TQRect rect; + }; + TQValueList< VkbdWindow > mVkbdWindows; + WId mVkbdLastEventWindow; + + bool mPipeOpen; + int mPipe_fd; + bool mPipeOpen_out; + int mPipe_fd_out; + + bool mInfoMessageDisplayed; + bool mDialogControlLock; + bool mForceReject; + TQDialog *currentDialog; + + TQTimer* mEnsureScreenHiddenTimer; + TQTimer* mForceContinualLockDisplayTimer; + TQTimer* mEnsureVRootWindowSecurityTimer; + TQTimer* mHackDelayStartupTimer; + + int mHackDelayStartupTimeout; + bool mHackStartupEnabled; + bool mOverrideHackStartupEnabled; + bool mResizingDesktopLock; + bool mFullyOnlineSent; + + bool mClosingWindows; + bool mInSecureDialog; + bool mHackActive; + + TQPixmap backingPixmap; + KRootPixmap *m_rootPixmap; + int mBackingStartupDelayTimer; + TQPixmap mArgbTransparentBackgroundPixmap; + + KSMModalDialog* m_startupStatusDialog; + + TQDateTime mlockDateTime; + + bool m_mouseDown; + int m_mousePrevX; + int m_mousePrevY; + int m_dialogPrevX; + int m_dialogPrevY; + + bool m_notifyReadyRequested; + TDECryptographicCardDevice* m_loginCardDevice; + + TQWidget* m_maskWidget; + Window m_saverRootWindow; + + ControlPipeHandlerObject* mControlPipeHandler; + TQEventLoopThread* mControlPipeHandlerThread; + + friend class ControlPipeHandlerObject; }; #endif diff --git a/kdesktop/lock/main.cpp b/kdesktop/lock/main.cpp index c5993f4ac..9f707c35d 100644 --- a/kdesktop/lock/main.cpp +++ b/kdesktop/lock/main.cpp @@ -1,7 +1,7 @@ -/* This file is part of the KDE project +/* This file is part of the TDE project Copyright (C) 1999 David Faure Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org> - Copyright (c) 2010-2012 Timothy Pearson <kb9vqf@pearsoncomputing.net> + Copyright (c) 2010-2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -33,14 +33,14 @@ #include <kdebug.h> #include <tdeglobalsettings.h> #include <dcopref.h> -#include <ksimpleconfig.h> -#include <kstandarddirs.h> +#include <tdesimpleconfig.h> +#include <tdestandarddirs.h> #include <tdmtsak.h> #include <stdlib.h> -#if defined(Q_WS_X11) && defined(HAVE_XRENDER) && TQT_VERSION >= 0x030300 +#if defined(TQ_WS_X11) && defined(HAVE_XRENDER) && TQT_VERSION >= 0x030300 #define COMPOSITE #endif @@ -58,496 +58,512 @@ TQXLibWindowList trinity_desktop_lock_hidden_window_list; // [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_hide_active_windows = FALSE; -bool trinity_desktop_lock_hide_cancel_button = FALSE; -bool trinity_desktop_lock_forced = FALSE; - -LockProcess* trinity_desktop_lock_process = NULL; +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_hide_active_windows = false; +bool trinity_desktop_lock_hide_cancel_button = false; +bool trinity_desktop_lock_forced = false; +// This is a temporary variable used till a fix for the grab issue is prepared +bool trinity_desktop_lock_failed_grab = false; bool signalled_forcelock; bool signalled_dontlock; bool signalled_securedialog; bool signalled_blank; bool signalled_run; -bool in_internal_mode = FALSE; +bool in_internal_mode = false; -bool argb_visual = FALSE; +bool argb_visual = false; pid_t kdesktop_pid = -1; -bool trinity_desktop_lock_settings_initialized = FALSE; +bool trinity_desktop_lock_settings_initialized = false; static void sigusr1_handler(int) { - signalled_forcelock = TRUE; + signalled_forcelock = true; } static void sigusr2_handler(int) { - signalled_dontlock = TRUE; + signalled_dontlock = true; } -static void sigusr3_handler(int) +static void sigwinch_handler(int) { - signalled_securedialog = TRUE; + signalled_securedialog = true; } -static void sigusr4_handler(int) +static void sigttin_handler(int) { - signalled_blank = TRUE; + signalled_blank = true; } -static void sigusr5_handler(int) +static void sigttou_handler(int) { - signalled_run = TRUE; + signalled_run = true; } static int trapXErrors(Display *, XErrorEvent *) { - return 0; + return 0; } bool MyApp::x11EventFilter( XEvent *ev ) { - if (ev->type == ButtonPress || ev->type == ButtonRelease || ev->type == MotionNotify) { - emit mouseInteraction(ev); - } - if (ev->type == XKeyPress || ev->type == ButtonPress) { - emit activity(); - } - else if (ev->type == MotionNotify) { - time_t tick = time( 0 ); - if (tick != lastTick) { - lastTick = tick; - emit activity(); - } - } - else if (ev->type == MapNotify) { - // HACK - // Hide all tooltips and notification windows - XMapEvent map_event = ev->xmap; - XWindowAttributes childAttr; - Window childTransient; - if (XGetWindowAttributes(map_event.display, map_event.window, &childAttr) && XGetTransientForHint(map_event.display, map_event.window, &childTransient)) { - if((childAttr.map_state == IsViewable) && (childAttr.override_redirect) && (childTransient)) { - if (!trinity_desktop_lock_hidden_window_list.contains(map_event.window)) { - trinity_desktop_lock_hidden_window_list.append(map_event.window); - } - XLowerWindow(map_event.display, map_event.window); - XFlush(map_event.display); - } - } - } - else if (ev->type == VisibilityNotify) { - // HACK - // Hide all tooltips and notification windows - XVisibilityEvent visibility_event = ev->xvisibility; - XWindowAttributes childAttr; - Window childTransient; - if ((visibility_event.state == VisibilityUnobscured) || (visibility_event.state == VisibilityPartiallyObscured)) { - if (XGetWindowAttributes(visibility_event.display, visibility_event.window, &childAttr) && XGetTransientForHint(visibility_event.display, visibility_event.window, &childTransient)) { - if((childAttr.map_state == IsViewable) && (childAttr.override_redirect) && (childTransient)) { - if (!trinity_desktop_lock_hidden_window_list.contains(visibility_event.window)) { - trinity_desktop_lock_hidden_window_list.append(visibility_event.window); - } - XLowerWindow(visibility_event.display, visibility_event.window); - XFlush(visibility_event.display); - } - } - } - } - else if (ev->type == CreateNotify) { - // HACK - // Close all tooltips and notification windows - XCreateWindowEvent create_event = ev->xcreatewindow; - XWindowAttributes childAttr; - Window childTransient; - - // XGetWindowAttributes may generate BadWindow errors, so make sure they are silently ignored - int (*oldHandler)(Display *, XErrorEvent *); - oldHandler = XSetErrorHandler(trapXErrors); - if (XGetWindowAttributes(create_event.display, create_event.window, &childAttr) && XGetTransientForHint(create_event.display, create_event.window, &childTransient)) { - if ((childAttr.override_redirect) && (childTransient)) { - if (!trinity_desktop_lock_hidden_window_list.contains(create_event.window)) { - trinity_desktop_lock_hidden_window_list.append(create_event.window); - } - XLowerWindow(create_event.display, create_event.window); - XFlush(create_event.display); - } - } - XSetErrorHandler(oldHandler); - } - else if (ev->type == DestroyNotify) { - XDestroyWindowEvent destroy_event = ev->xdestroywindow; - if (trinity_desktop_lock_hidden_window_list.contains(destroy_event.window)) { - trinity_desktop_lock_hidden_window_list.remove(destroy_event.window); - } - } + if (ev->type == ButtonPress || ev->type == ButtonRelease || ev->type == MotionNotify) { + emit mouseInteraction(ev); + } + if (ev->type == XKeyPress || ev->type == ButtonPress) { + emit activity(); + } + else if (ev->type == MotionNotify) { + time_t tick = time( 0 ); + if (tick != lastTick) { + lastTick = tick; + emit activity(); + } + } + else if (ev->type == MapNotify) { + // HACK + // Hide all tooltips and notification windows + XMapEvent map_event = ev->xmap; + XWindowAttributes childAttr; + Window childTransient; + if (XGetWindowAttributes(map_event.display, map_event.window, &childAttr) && XGetTransientForHint(map_event.display, map_event.window, &childTransient)) { + if((childAttr.map_state == IsViewable) && (childAttr.override_redirect) && (childTransient)) { + if (!trinity_desktop_lock_hidden_window_list.contains(map_event.window)) { + trinity_desktop_lock_hidden_window_list.append(map_event.window); + } + XLowerWindow(map_event.display, map_event.window); + XFlush(map_event.display); + } + } + } + else if (ev->type == VisibilityNotify) { + // HACK + // Hide all tooltips and notification windows + XVisibilityEvent visibility_event = ev->xvisibility; + XWindowAttributes childAttr; + Window childTransient; + if ((visibility_event.state == VisibilityUnobscured) || (visibility_event.state == VisibilityPartiallyObscured)) { + if (XGetWindowAttributes(visibility_event.display, visibility_event.window, &childAttr) && XGetTransientForHint(visibility_event.display, visibility_event.window, &childTransient)) { + if((childAttr.map_state == IsViewable) && (childAttr.override_redirect) && (childTransient)) { + if (!trinity_desktop_lock_hidden_window_list.contains(visibility_event.window)) { + trinity_desktop_lock_hidden_window_list.append(visibility_event.window); + } + XLowerWindow(visibility_event.display, visibility_event.window); + XFlush(visibility_event.display); + } + } + } + } + else if (ev->type == CreateNotify) { + // HACK + // Close all tooltips and notification windows + XCreateWindowEvent create_event = ev->xcreatewindow; + XWindowAttributes childAttr; + Window childTransient; + + // XGetWindowAttributes may generate BadWindow errors, so make sure they are silently ignored + int (*oldHandler)(Display *, XErrorEvent *); + oldHandler = XSetErrorHandler(trapXErrors); + if (XGetWindowAttributes(create_event.display, create_event.window, &childAttr) && XGetTransientForHint(create_event.display, create_event.window, &childTransient)) { + if ((childAttr.override_redirect) && (childTransient)) { + if (!trinity_desktop_lock_hidden_window_list.contains(create_event.window)) { + trinity_desktop_lock_hidden_window_list.append(create_event.window); + } + XLowerWindow(create_event.display, create_event.window); + XFlush(create_event.display); + } + } + XSetErrorHandler(oldHandler); + } + else if (ev->type == DestroyNotify) { + XDestroyWindowEvent destroy_event = ev->xdestroywindow; + if (trinity_desktop_lock_hidden_window_list.contains(destroy_event.window)) { + trinity_desktop_lock_hidden_window_list.remove(destroy_event.window); + } + } #if 0 - else if (ev->type == CreateNotify) { - // HACK - // Close all tooltips and notification windows - XCreateWindowEvent create_event = ev->xcreatewindow; - XWindowAttributes childAttr; - Window childTransient; - if (XGetWindowAttributes(create_event.display, create_event.window, &childAttr) && XGetTransientForHint(create_event.display, create_event.window, &childTransient)) { - if ((childAttr.override_redirect) && (childTransient)) { - XDestroyWindow(create_event.display, create_event.window); - } - } - } + else if (ev->type == CreateNotify) { + // HACK + // Close all tooltips and notification windows + XCreateWindowEvent create_event = ev->xcreatewindow; + XWindowAttributes childAttr; + Window childTransient; + if (XGetWindowAttributes(create_event.display, create_event.window, &childAttr) && XGetTransientForHint(create_event.display, create_event.window, &childTransient)) { + if ((childAttr.override_redirect) && (childTransient)) { + XDestroyWindow(create_event.display, create_event.window); + } + } + } #endif - return TDEApplication::x11EventFilter( ev ); + return TDEApplication::x11EventFilter( ev ); } static TDECmdLineOptions options[] = { - { "forcelock", I18N_NOOP("Force session locking"), 0 }, - { "dontlock", I18N_NOOP("Only start screensaver"), 0 }, - { "securedialog", I18N_NOOP("Launch the secure dialog"), 0 }, - { "blank", I18N_NOOP("Only use the blank screensaver"), 0 }, - { "internal <pid>", I18N_NOOP("TDE internal command for background process loading"), 0 }, - TDECmdLineLastOption + { "forcelock", I18N_NOOP("Force session locking"), 0 }, + { "dontlock", I18N_NOOP("Only start screensaver"), 0 }, + { "securedialog", I18N_NOOP("Launch the secure dialog"), 0 }, + { "blank", I18N_NOOP("Only use the blank screensaver"), 0 }, + { "internal <pid>", I18N_NOOP("TDE internal command for background process loading"), 0 }, + TDECmdLineLastOption }; void restore_hidden_override_redirect_windows() { - TQXLibWindowList::iterator it; - for (it = trinity_desktop_lock_hidden_window_list.begin(); it != trinity_desktop_lock_hidden_window_list.end(); ++it) { - Window win = *it; - XRaiseWindow(tqt_xdisplay(), win); - } + TQXLibWindowList::iterator it; + for (it = trinity_desktop_lock_hidden_window_list.begin(); it != trinity_desktop_lock_hidden_window_list.end(); ++it) { + Window win = *it; + XRaiseWindow(tqt_xdisplay(), win); + } } // ----------------------------------------------------------------------------- int main( int argc, char **argv ) { - TDELocale::setMainCatalogue("kdesktop"); - - TDECmdLineArgs::init( argc, argv, "kdesktop_lock", I18N_NOOP("KDesktop Locker"), I18N_NOOP("Session Locker for KDesktop"), "2.1" ); - TDECmdLineArgs::addCmdLineOptions( options ); - TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); - - putenv(strdup("SESSION_MANAGER=")); - - TDEApplication::disableAutoDcopRegistration(); // not needed - - XSetErrorHandler(trapXErrors); - - MyApp* app = NULL; - - while (1 == 1) { - signalled_forcelock = FALSE; - signalled_dontlock = FALSE; - signalled_securedialog = FALSE; - signalled_blank = FALSE; - signalled_run = FALSE; - - int kdesktop_screen_number = 0; - int starting_screen = 0; - - bool child = false; - int parent_connection = 0; // socket to the parent saver - TQValueList<int> child_sockets; - - if (TDEGlobalSettings::isMultiHead()) - { - Display *dpy = XOpenDisplay(NULL); - if (! dpy) { - fprintf(stderr, - "%s: FATAL ERROR: couldn't open display '%s'\n", - argv[0], XDisplayName(NULL)); - exit(1); - } - - int number_of_screens = ScreenCount(dpy); - starting_screen = kdesktop_screen_number = DefaultScreen(dpy); - int pos; - TQCString display_name = XDisplayString(dpy); - XCloseDisplay(dpy); - kdDebug() << "screen " << number_of_screens << " " << kdesktop_screen_number << " " << display_name << " " << starting_screen << endl; - dpy = 0; - - if ((pos = display_name.findRev('.')) != -1) - display_name.remove(pos, 10); - - TQCString env; - if (number_of_screens != 1) { - for (int i = 0; i < number_of_screens; i++) { - if (i != starting_screen) { - int fd[2]; - if (pipe(fd)) { - perror("pipe"); - break; - } - if (fork() == 0) { - child = true; - kdesktop_screen_number = i; - parent_connection = fd[0]; - // break here because we are the child process, we don't - // want to fork() anymore - break; - } else { - child_sockets.append(fd[1]); - } - } - } - - env.sprintf("DISPLAY=%s.%d", display_name.data(), - kdesktop_screen_number); - kdDebug() << "env " << env << endl; - - if (putenv(strdup(env.data()))) { - fprintf(stderr, - "%s: WARNING: unable to set DISPLAY environment variable\n", - argv[0]); - perror("putenv()"); - } - } - } - - if (!app) { + TDELocale::setMainCatalogue("kdesktop"); + + TDECmdLineArgs::init( argc, argv, "kdesktop_lock", I18N_NOOP("KDesktop Locker"), I18N_NOOP("Session Locker for KDesktop"), "2.1" ); + TDECmdLineArgs::addCmdLineOptions( options ); + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + + putenv(strdup("SESSION_MANAGER=")); + + TDEApplication::disableAutoDcopRegistration(); // not needed + + XSetErrorHandler(trapXErrors); + + MyApp *app = nullptr; + + while (true) { + sigset_t new_mask; + sigset_t orig_mask; + + // Block reception of all signals in this thread + sigfillset(&new_mask); + sigprocmask(SIG_BLOCK, &new_mask, NULL); + + signalled_forcelock = false; + signalled_dontlock = false; + signalled_securedialog = false; + signalled_blank = false; + signalled_run = false; + + int kdesktop_screen_number = 0; + int starting_screen = 0; + + bool child = false; + int parent_connection = 0; // socket to the parent saver + TQValueList<int> child_sockets; + + if (TDEGlobalSettings::isMultiHead()) { + Display *dpy = XOpenDisplay(NULL); + if (!dpy) { + fprintf(stderr, + "%s: FATAL ERROR: couldn't open display '%s'\n", + argv[0], XDisplayName(NULL)); + exit(1); + } + + int number_of_screens = ScreenCount(dpy); + starting_screen = kdesktop_screen_number = DefaultScreen(dpy); + int pos; + TQCString display_name = XDisplayString(dpy); + XCloseDisplay(dpy); + kdDebug() << "screen " << number_of_screens << " " << kdesktop_screen_number << " " << display_name << " " << starting_screen << endl; + dpy = 0; + + if ((pos = display_name.findRev('.')) != -1) { + display_name.remove(pos, 10); + } + + TQCString env; + if (number_of_screens != 1) { + for (int i = 0; i < number_of_screens; i++) { + if (i != starting_screen) { + int fd[2]; + if (pipe(fd)) { + perror("pipe"); + break; + } + if (fork() == 0) { + child = true; + kdesktop_screen_number = i; + parent_connection = fd[0]; + // break here because we are the child process, we don't + // want to fork() anymore + break; + } + else { + child_sockets.append(fd[1]); + } + } + } + + env.sprintf("DISPLAY=%s.%d", display_name.data(), kdesktop_screen_number); + kdDebug() << "env " << env << endl; + + if (putenv(strdup(env.data()))) { + fprintf(stderr, "%s: WARNING: unable to set DISPLAY environment variable\n", argv[0]); + perror("putenv()"); + } + } + } + + if (!app) { #ifdef COMPOSITE - app = new MyApp(TDEApplication::openX11RGBADisplay()); - argb_visual = app->isX11CompositionAvailable(); + app = new MyApp(TDEApplication::openX11RGBADisplay()); + argb_visual = app->isX11CompositionAvailable(); #else - app = new MyApp; + app = new MyApp; #endif - } - - TDELockFile lock(locateLocal("tmp", TQString("kdesktop_lock_lockfile.%1").arg(getenv("DISPLAY")))); - lock.setStaleTime(0); - TDELockFile::LockResult lockRet = lock.lock(); - if (lockRet != TDELockFile::LockOK) { - // Terminate existing (stale) process if needed - int pid; - TQString hostName; - TQString appName; - if (lock.getLockInfo(pid, hostName, appName)) { - // Verify that the pid in question is an instance of kdesktop_lock - int len; - char procpath[PATH_MAX]; - char fullpath[PATH_MAX]; + } + + TDELockFile lock(locateLocal("tmp", TQString("kdesktop_lock_lockfile.%1").arg(getenv("DISPLAY")))); + lock.setStaleTime(0); + TDELockFile::LockResult lockRet = lock.lock(); + if (lockRet != TDELockFile::LockOK) { + // Terminate existing (stale) process if needed + int pid; + TQString hostName; + TQString appName; + if (lock.getLockInfo(pid, hostName, appName)) { + // Verify that the pid in question is an instance of kdesktop_lock + int len; + char procpath[PATH_MAX]; + char fullpath[PATH_MAX]; #if defined(__dilos__) - snprintf(procpath, sizeof(procpath), "/proc/%d/path/a.out", pid); + snprintf(procpath, sizeof(procpath), "/proc/%d/path/a.out", pid); #elif defined(__FreeBSD__) || defined (__DragonFly__) - snprintf(procpath, sizeof(procpath), "/compat/linux/proc/%d/exe", pid); + snprintf(procpath, sizeof(procpath), "/compat/linux/proc/%d/exe", pid); #else /* Linux way as default */ - snprintf(procpath, sizeof(procpath), "/proc/%d/exe", pid); + snprintf(procpath, sizeof(procpath), "/proc/%d/exe", pid); #endif - len = readlink( procpath, fullpath, sizeof(fullpath) ); - if (len >= 0) { - fullpath[len] = 0; - TQFileInfo fileInfo(fullpath); - if (fileInfo.baseName() == "kdesktop_lock") { - // Verify that pid in question is owned by current user before killing it - uid_t current_uid = geteuid(); - - struct stat info; - if (lstat(procpath, &info) == 0) { - if (info.st_uid == current_uid) { - kill(pid, SIGKILL); - } - } - } - } - } - } - - // Force a relock as a stale lockfile or process may have been dealt with above - if (!lock.isLocked()) { - lockRet = lock.lock(TDELockFile::LockNoBlock | TDELockFile::LockForce); - } - - kdDebug() << "app " << kdesktop_screen_number << " " << starting_screen << " " << child << " " << child_sockets.count() << " " << parent_connection << endl; - app->disableSessionManagement(); - TDEGlobal::locale()->insertCatalogue("libdmctl"); - - struct stat st; - KSimpleConfig* tdmconfig; - if( stat( KDE_CONFDIR "/tdm/tdmdistrc" , &st ) == 0) { - tdmconfig = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdm/tdmdistrc" )); - } - else { - tdmconfig = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdm/tdmrc" )); + len = readlink( procpath, fullpath, sizeof(fullpath) ); + if (len >= 0) { + fullpath[len] = 0; + TQFileInfo fileInfo(fullpath); + if (fileInfo.baseName() == "kdesktop_lock") { + // Verify that pid in question is owned by current user before killing it + uid_t current_uid = geteuid(); + + struct stat info; + if (lstat(procpath, &info) == 0) { + if (info.st_uid == current_uid) { + kill(pid, SIGKILL); + } + } + } } - tdmconfig->setGroup("X-:*-Greeter"); - - trinity_desktop_lock_process = new LockProcess; - - // Start loading core functions, such as the desktop wallpaper interface - app->processEvents(); - - if (args->isSet( "internal" )) { - kdesktop_pid = atoi(args->getOption( "internal" )); - sigset_t new_mask; - sigset_t orig_mask; - struct sigaction act; - - in_internal_mode = TRUE; - - // handle SIGUSR1 - act.sa_handler= sigusr1_handler; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGUSR1); - act.sa_flags = 0; - sigaction(SIGUSR1, &act, 0L); - // handle SIGUSR2 - act.sa_handler= sigusr2_handler; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGUSR2); - act.sa_flags = 0; - sigaction(SIGUSR2, &act, 0L); - // handle SIGWINCH (an ersatz SIGUSR3) - act.sa_handler= sigusr3_handler; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGWINCH); - act.sa_flags = 0; - sigaction(SIGWINCH, &act, 0L); - // handle SIGTTIN (an ersatz SIGUSR4) - act.sa_handler= sigusr4_handler; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGTTIN); - act.sa_flags = 0; - sigaction(SIGTTIN, &act, 0L); - // handle SIGTTOU (an ersatz SIGUSR5) - act.sa_handler= sigusr5_handler; - sigemptyset(&(act.sa_mask)); - sigaddset(&(act.sa_mask), SIGTTOU); - act.sa_flags = 0; - sigaction(SIGTTOU, &act, 0L); - - // initialize the signal masks - sigemptyset(&new_mask); - sigaddset(&new_mask,SIGUSR1); - sigaddset(&new_mask,SIGUSR2); - sigaddset(&new_mask,SIGWINCH); - sigaddset(&new_mask,SIGTTIN); - sigaddset(&new_mask,SIGTTOU); - - while (signalled_run == FALSE) { - // let kdesktop know the saver process is ready - if (kill(kdesktop_pid, SIGTTIN) < 0) { - // The controlling kdesktop process probably died. Commit suicide... - return 12; - } - - // Get root window attributes - XWindowAttributes rootAttr; - XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(), tqt_xscreen()), &rootAttr); - - // Disable reception of all X11 events on the root window - XSelectInput( tqt_xdisplay(), tqt_xrootwin(), 0 ); - app->processEvents(); + } + } - // wait for SIGUSR1, SIGUSR2, SIGWINCH, SIGTTIN, or SIGTTOU - sigprocmask(SIG_BLOCK, &new_mask, &orig_mask); - if (signalled_run != TRUE) { - sigsuspend(&orig_mask); + // Force a relock as a stale lockfile or process may have been dealt with above + if (!lock.isLocked()) { + lockRet = lock.lock(TDELockFile::LockNoBlock | TDELockFile::LockForce); } + + kdDebug() << "app " << kdesktop_screen_number << " " << starting_screen << " " << child << " " << child_sockets.count() << " " << parent_connection << endl; + app->disableSessionManagement(); + TDEGlobal::locale()->insertCatalogue("libdmctl"); + + struct stat st; + TDESimpleConfig* tdmconfig; + if( stat( KDE_CONFDIR "/tdm/tdmdistrc" , &st ) == 0) { + tdmconfig = new TDESimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdm/tdmdistrc" )); + } + else { + tdmconfig = new TDESimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdm/tdmrc" )); + } + tdmconfig->setGroup("X-:*-Greeter"); + + // Create new LockProcess, which also spawns threads inheriting the blocked signal mask + LockProcess lock_process; + + // Unblock reception of all signals in this thread sigprocmask(SIG_UNBLOCK, &new_mask, NULL); - // Reenable reception of X11 events on the root window - XSelectInput( tqt_xdisplay(), tqt_xrootwin(), rootAttr.your_event_mask ); - } - - // Block reception of all signals in this thread - sigprocmask(SIG_BLOCK, &new_mask, NULL); - } - - // (re)load settings here so that they actually reflect reality - // we need to read from the right rc file - possibly taking screen number in account - if (!trinity_desktop_lock_settings_initialized) { - KDesktopSettings::instance("kdesktoprc"); - trinity_desktop_lock_settings_initialized = true; - } - else { - KDesktopSettings::self()->readConfig(); - } - trinity_desktop_lock_use_system_modal_dialogs = !KDesktopSettings::useUnmanagedLockWindows(); - trinity_desktop_lock_delay_screensaver_start = KDesktopSettings::delaySaverStart(); - if (trinity_desktop_lock_use_system_modal_dialogs) { + // Start loading core functions, such as the desktop wallpaper interface + app->processEvents(); + + if (args->isSet( "internal" )) { + kdesktop_pid = atoi(args->getOption( "internal" )); + struct sigaction act; + + in_internal_mode = true; + + // handle SIGUSR1 + act.sa_handler= sigusr1_handler; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGUSR1); + act.sa_flags = 0; + sigaction(SIGUSR1, &act, 0L); + // handle SIGUSR2 + act.sa_handler= sigusr2_handler; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGUSR2); + act.sa_flags = 0; + sigaction(SIGUSR2, &act, 0L); + // handle SIGWINCH (as custom user signal rather than its inherent meaning) + act.sa_handler= sigwinch_handler; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGWINCH); + act.sa_flags = 0; + sigaction(SIGWINCH, &act, 0L); + // handle SIGTTIN (as custom user signal rather than its inherent meaning) + act.sa_handler= sigttin_handler; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGTTIN); + act.sa_flags = 0; + sigaction(SIGTTIN, &act, 0L); + // handle SIGTTOU (as custom user signal rather than its inherent meaning) + act.sa_handler= sigttou_handler; + sigemptyset(&(act.sa_mask)); + sigaddset(&(act.sa_mask), SIGTTOU); + act.sa_flags = 0; + sigaction(SIGTTOU, &act, 0L); + + // initialize the signal masks + sigemptyset(&new_mask); + sigaddset(&new_mask,SIGUSR1); + sigaddset(&new_mask,SIGUSR2); + sigaddset(&new_mask,SIGWINCH); + sigaddset(&new_mask,SIGTTIN); + sigaddset(&new_mask,SIGTTOU); + + while (!signalled_run) { + // let kdesktop know the saver process is ready + if (kill(kdesktop_pid, SIGTTIN) < 0) { + // The controlling kdesktop process probably died. Commit suicide... + return 12; + } + + // Get root window attributes + XWindowAttributes rootAttr; + XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(), tqt_xscreen()), &rootAttr); + + // Disable reception of all X11 events on the root window + XSelectInput( tqt_xdisplay(), tqt_xrootwin(), 0 ); + app->processEvents(); + + // wait for SIGUSR1, SIGUSR2, SIGWINCH, SIGTTIN, or SIGTTOU + sigprocmask(SIG_BLOCK, &new_mask, &orig_mask); + if (!signalled_run) { + sigsuspend(&orig_mask); + } + sigprocmask(SIG_UNBLOCK, &new_mask, NULL); + + // Reenable reception of X11 events on the root window + XSelectInput( tqt_xdisplay(), tqt_xrootwin(), rootAttr.your_event_mask ); + } + + // Block reception of all signals in this thread + sigprocmask(SIG_BLOCK, &new_mask, NULL); + } + + // (re)load settings here so that they actually reflect reality + // we need to read from the right rc file - possibly taking screen number in account + if (!trinity_desktop_lock_settings_initialized) { + KDesktopSettings::instance("kdesktoprc"); + trinity_desktop_lock_settings_initialized = true; + } + else { + KDesktopSettings::self()->readConfig(); + } + trinity_desktop_lock_use_system_modal_dialogs = !KDesktopSettings::useUnmanagedLockWindows(); + trinity_desktop_lock_delay_screensaver_start = KDesktopSettings::delaySaverStart(); + if (trinity_desktop_lock_use_system_modal_dialogs) { #ifdef BUILD_TSAK - trinity_desktop_lock_use_sak = tdmconfig->readBoolEntry("UseSAK", false) && KDesktopSettings::useTDESAK(); + trinity_desktop_lock_use_sak = tdmconfig->readBoolEntry("UseSAK", false) && KDesktopSettings::useTDESAK(); #else - trinity_desktop_lock_use_sak = false; + trinity_desktop_lock_use_sak = false; #endif - } - else { - trinity_desktop_lock_use_sak = false; // If SAK is enabled with unmanaged windows, the SAK dialog will never close and will "burn in" the screen - trinity_desktop_lock_delay_screensaver_start = false; // If trinity_desktop_lock_delay_screensaver_start is true with unmanaged windows, the lock dialog may never appear - } - trinity_desktop_lock_hide_active_windows = KDesktopSettings::hideActiveWindowsFromSaver(); - trinity_desktop_lock_hide_cancel_button = KDesktopSettings::hideCancelButton(); - - delete tdmconfig; - - if (args->isSet( "forcelock" ) || (signalled_forcelock == TRUE)) { - trinity_desktop_lock_forced = TRUE; - } - - trinity_desktop_lock_process->init(child, (args->isSet( "blank" ) || (signalled_blank == TRUE))); - if (!child) { - trinity_desktop_lock_process->setChildren(child_sockets); - } - else { - trinity_desktop_lock_process->setParent(parent_connection); - } - - bool rt; - if( (((!child) && (args->isSet( "forcelock" ))) || (signalled_forcelock == TRUE))) { - rt = trinity_desktop_lock_process->lock(); - } - else if( child || (args->isSet( "dontlock" ) || (signalled_dontlock == TRUE))) { - rt = trinity_desktop_lock_process->dontLock(); - } - else if( child || (args->isSet( "securedialog" ) || (signalled_securedialog == TRUE))) { - int retcode = tde_sak_verify_calling_process(); - if (retcode == 0) { - rt = trinity_desktop_lock_process->runSecureDialog(); - } - else { - return 1; - } - } - else { - rt = trinity_desktop_lock_process->defaultSave(); - } - if (!rt) { - return 0; - } - - if (in_internal_mode == FALSE) { - trinity_desktop_lock_hidden_window_list.clear(); - int ret = app->exec(); - restore_hidden_override_redirect_windows(); - return ret; - } - else { - if (kill(kdesktop_pid, 0) < 0) { - // The controlling kdesktop process probably died. Commit suicide... - return 12; - } - trinity_desktop_lock_hidden_window_list.clear(); - app->exec(); - restore_hidden_override_redirect_windows(); - if (kill(kdesktop_pid, SIGUSR1) < 0) { - // The controlling kdesktop process probably died. Commit suicide... - return 12; - } - - delete trinity_desktop_lock_process; - trinity_desktop_lock_process = NULL; - - // FIXME - // We should not have to return (restart) at all, - // but it seems that some X11 connections are left active, - // preventing the lock process from restarting properly in the while() loop above. - return 0; - } - } + } + else { + trinity_desktop_lock_use_sak = false; // If SAK is enabled with unmanaged windows, the SAK dialog will never close and will "burn in" the screen + trinity_desktop_lock_delay_screensaver_start = false; // If trinity_desktop_lock_delay_screensaver_start is true with unmanaged windows, the lock dialog may never appear + } + trinity_desktop_lock_hide_active_windows = KDesktopSettings::hideActiveWindowsFromSaver(); + trinity_desktop_lock_hide_cancel_button = KDesktopSettings::hideCancelButton(); + + delete tdmconfig; + + if (args->isSet( "forcelock" ) || signalled_forcelock) { + trinity_desktop_lock_forced = true; + } + + lock_process.init(child, (args->isSet( "blank" ) || signalled_blank)); + if (!child) { + lock_process.setChildren(child_sockets); + } + else { + lock_process.setParent(parent_connection); + } + + trinity_desktop_lock_failed_grab = false; + bool rt; + if( (!child && args->isSet( "forcelock" )) || signalled_forcelock) { + rt = lock_process.lock(); + } + else if( child || (args->isSet( "dontlock" ) || signalled_dontlock)) { + rt = lock_process.dontLock(); + } + else if( child || (args->isSet( "securedialog" ) || signalled_securedialog)) { + int retcode = tde_sak_verify_calling_process(); + if (retcode == 0) { + rt = lock_process.runSecureDialog(); + } + else { + return 1; + } + } + else { + rt = lock_process.defaultSave(); + } + + // Make sure to handle all pending responses from the X server. + // If we don't do this, in case of failed activation of the saver/lock screen, + // we will end up in a dirty state and the screen lock will no longer hide the windows + // on the screen due to 'm_rootPixmap' failing to load the background image. + // This is caused by a 'XConvertSelection' request in 'TDESharedPixmap::loadFromShared' + // not being handled and causing the corresponding property to become unusuable in X for + // subsequent lock requests. + XSync(tqt_xdisplay(), False); + app->processEvents(); + + if (!rt) { + return (trinity_desktop_lock_failed_grab ? 0 : 12); + } + + if (!in_internal_mode) { + trinity_desktop_lock_hidden_window_list.clear(); + int ret = app->exec(); + restore_hidden_override_redirect_windows(); + return ret; + } + else { + if (kill(kdesktop_pid, 0) < 0) { + // The controlling kdesktop process probably died. Commit suicide... + return 12; + } + trinity_desktop_lock_hidden_window_list.clear(); + app->exec(); + restore_hidden_override_redirect_windows(); + if (kill(kdesktop_pid, SIGUSR1) < 0) { + // The controlling kdesktop process probably died. Commit suicide... + return 12; + } + + // FIXME + // We should not have to return (restart) at all, + // but it seems that some X11 connections are left active, + // preventing the lock process from restarting properly in the while() loop above. + return 0; + } + } } #include "main.moc" diff --git a/kdesktop/lock/main.h b/kdesktop/lock/main.h index da3accda2..162542555 100644 --- a/kdesktop/lock/main.h +++ b/kdesktop/lock/main.h @@ -1,4 +1,4 @@ -/* This file is part of the KDE project +/* This file is part of the TDE project Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org> This library is free software; you can redistribute it and/or @@ -25,17 +25,20 @@ #include <time.h> class MyApp : public TDEApplication { - Q_OBJECT -public: - MyApp() : TDEApplication(), lastTick( 0 ) {} - MyApp(Display *display, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0, bool allowStyles=true) : TDEApplication(display, visual, colormap, allowStyles), lastTick( 0 ) {} -protected: - bool x11EventFilter( XEvent * ); -signals: - void activity(); - void mouseInteraction(XEvent *event); -private: - time_t lastTick; + TQ_OBJECT + public: + MyApp() : TDEApplication(), lastTick( 0 ) {} + MyApp(Display *display, TQt::HANDLE visual = 0, TQt::HANDLE colormap = 0, bool allowStyles=true) : TDEApplication(display, visual, colormap, allowStyles), lastTick( 0 ) {} + + protected: + bool x11EventFilter( XEvent * ); + + signals: + void activity(); + void mouseInteraction(XEvent *event); + + private: + time_t lastTick; }; #endif diff --git a/kdesktop/lock/querydlg.cpp b/kdesktop/lock/querydlg.cpp index 7618a5062..5b1fea0f3 100644 --- a/kdesktop/lock/querydlg.cpp +++ b/kdesktop/lock/querydlg.cpp @@ -1,8 +1,8 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // -// Copyright (c) 2010 Timothy Pearson <kb9vqf@pearsoncomputing.net> +// Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> #include <config.h> @@ -14,7 +14,7 @@ #include <tdelocale.h> #include <kpushbutton.h> #include <kseparator.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <tdeglobalsettings.h> #include <tdeconfig.h> #include <kiconloader.h> @@ -62,100 +62,102 @@ extern bool trinity_desktop_lock_use_system_modal_dialogs; // Simple dialog for displaying a password/PIN entry dialog // QueryDlg::QueryDlg(LockProcess *parent) - : TQDialog(parent, "query dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))), - mUnlockingFailed(false) + : TQDialog(parent, "query 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); - XChangeProperty(tqt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); - } - setCaption(i18n("Information Needed")); - - 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->setAlignment( TQLabel::AlignCenter ); - mStatusLabel->setAlignment( TQLabel::AlignLeft ); - - KSeparator *sep = new KSeparator( KSeparator::HLine, frame ); - - ok = new KPushButton( i18n("Unl&ock"), frame ); - - TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); - unlockDialogLayout->addWidget( frame ); - - TQHBoxLayout *layStatus = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); - layStatus->addWidget( mStatusLabel ); - - TQHBoxLayout *layPin = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); - pin_box = new KPasswordEdit( this, "pin_box" ); - layPin->addWidget( pin_box ); - pin_box->setFocus(); - - TQHBoxLayout *layButtons = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); - layButtons->addStretch(); - layButtons->addWidget( ok ); - - frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); - frameLayout->addMultiCellWidget( mpixLabel, 0, 2, 0, 0, Qt::AlignTop ); - frameLayout->addLayout( layStatus, 0, 1 ); - frameLayout->addLayout( layPin, 2, 1 ); - frameLayout->addMultiCellWidget( sep, 3, 3, 0, 1 ); - frameLayout->addMultiCellLayout( layButtons, 4, 4, 0, 1 ); - - connect(ok, TQT_SIGNAL(clicked()), TQT_SLOT(slotOK())); - - installEventFilter(this); - setFixedSize( sizeHint() ); + 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); + XChangeProperty(tqt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); + } + setCaption(i18n("Information Needed")); + + 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->setAlignment( TQLabel::AlignCenter ); + mStatusLabel->setAlignment( TQLabel::AlignLeft ); + + KSeparator *sep = new KSeparator( KSeparator::HLine, frame ); + + ok = new KPushButton( i18n("Unl&ock"), frame ); + + TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); + unlockDialogLayout->addWidget( frame ); + + TQHBoxLayout *layStatus = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); + layStatus->addWidget( mStatusLabel ); + + TQHBoxLayout *layPin = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); + pin_box = new KPasswordEdit( this, "pin_box" ); + layPin->addWidget( pin_box ); + pin_box->setFocus(); + + TQHBoxLayout *layButtons = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); + layButtons->addStretch(); + layButtons->addWidget( ok ); + + frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); + frameLayout->addMultiCellWidget( mpixLabel, 0, 2, 0, 0, TQt::AlignTop ); + frameLayout->addLayout( layStatus, 0, 1 ); + frameLayout->addLayout( layPin, 2, 1 ); + frameLayout->addMultiCellWidget( sep, 3, 3, 0, 1 ); + frameLayout->addMultiCellLayout( layButtons, 4, 4, 0, 1 ); + + connect(ok, TQ_SIGNAL(clicked()), TQ_SLOT(slotOK())); + + installEventFilter(this); + setFixedSize( sizeHint() ); } QueryDlg::~QueryDlg() { - hide(); + hide(); } void QueryDlg::slotOK() { - close(); + close(); } -const char * QueryDlg::getEntry() +TQString QueryDlg::getEntry() { - return pin_box->password(); + return pin_box->password(); } void QueryDlg::updateLabel(TQString &txt) { - mStatusLabel->setPaletteForegroundColor(Qt::black); - mStatusLabel->setText("<b>" + txt + "</b>"); + mStatusLabel->setPaletteForegroundColor(TQt::black); + mStatusLabel->setText("<b>" + txt + "</b>"); } void QueryDlg::setUnlockIcon() { - mpixLabel->setPixmap(DesktopIcon("unlock")); + mpixLabel->setPixmap(DesktopIcon("unlock")); } void QueryDlg::setWarningIcon() { - mpixLabel->setPixmap(DesktopIcon("messagebox_warning")); + mpixLabel->setPixmap(DesktopIcon("messagebox_warning")); } void QueryDlg::show() { - TQDialog::show(); - TQApplication::flushX(); + TQDialog::show(); + TQApplication::flushX(); } #include "querydlg.moc" diff --git a/kdesktop/lock/querydlg.h b/kdesktop/lock/querydlg.h index 0da557caf..0b3e55aa8 100644 --- a/kdesktop/lock/querydlg.h +++ b/kdesktop/lock/querydlg.h @@ -1,8 +1,8 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // -// Copyright (c) 2010 Timothy Pearson <kb9vqf@pearsoncomputing.net> +// Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> // #ifndef __QUERYDLG_H__ @@ -28,33 +28,33 @@ class TQListView; // class QueryDlg : public TQDialog { - Q_OBJECT - -public: - QueryDlg(LockProcess *parent); - ~QueryDlg(); - virtual void show(); - - void updateLabel( TQString &txt ); - void setUnlockIcon(); - void setWarningIcon(); - const char * getEntry(); - -private slots: - void slotOK(); - -private: - TQFrame *frame; - TQGridLayout *frameLayout; - TQLabel *mStatusLabel; - TQLabel *mpixLabel; - int mCapsLocked; - bool mUnlockingFailed; - TQStringList layoutsList; - TQStringList::iterator currLayout; - int sPid, sFd; - KPushButton *ok; - KPasswordEdit *pin_box; + TQ_OBJECT + + public: + QueryDlg(LockProcess *parent); + ~QueryDlg(); + virtual void show(); + + void updateLabel( TQString &txt ); + void setUnlockIcon(); + void setWarningIcon(); + TQString getEntry(); + + private slots: + void slotOK(); + + private: + TQFrame *frame; + TQGridLayout *frameLayout; + TQLabel *mStatusLabel; + TQLabel *mpixLabel; + int mCapsLocked; + bool mUnlockingFailed; + TQStringList layoutsList; + TQStringList::iterator currLayout; + int sPid, sFd; + KPushButton *ok; + KPasswordEdit *pin_box; }; #endif diff --git a/kdesktop/lock/sakdlg.cpp b/kdesktop/lock/sakdlg.cpp index a062fb0fe..5b23a9c5a 100644 --- a/kdesktop/lock/sakdlg.cpp +++ b/kdesktop/lock/sakdlg.cpp @@ -1,8 +1,8 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // -// Copyright (c) 2010-2011 Timothy Pearson <kb9vqf@pearsoncomputing.net> +// Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> #include <config.h> @@ -14,7 +14,7 @@ #include <tdelocale.h> #include <kpushbutton.h> #include <kseparator.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <tdeglobalsettings.h> #include <tdeconfig.h> #include <kiconloader.h> @@ -64,57 +64,61 @@ 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) + : 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); - XChangeProperty(tqt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); - } - setCaption(i18n("Desktop Session Locked")); + 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); + XChangeProperty(tqt_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 ); + 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 ); - KSMModalDialogHeader* theader = new KSMModalDialogHeader( frame ); + KSMModalDialogHeader* theader = new KSMModalDialogHeader( frame ); - KUser user; + KUser user; - mStatusLabel = new TQLabel( "<b> </b>", frame ); - mStatusLabel->setAlignment( TQLabel::AlignVCenter ); + mStatusLabel = new TQLabel( "<b> </b>", frame ); + mStatusLabel->setAlignment( TQLabel::AlignVCenter ); - TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); - unlockDialogLayout->addWidget( frame ); + TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); + unlockDialogLayout->addWidget( frame ); - TQHBoxLayout *layStatus = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); - layStatus->addWidget( mStatusLabel ); + TQHBoxLayout *layStatus = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); + layStatus->addWidget( mStatusLabel ); - frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); - frameLayout->addMultiCellWidget( theader, 0, 0, 0, 1, AlignTop | AlignLeft ); - frameLayout->addMultiCellLayout( layStatus, 1, 1, 0, 1, AlignLeft | AlignVCenter); + frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); + frameLayout->addMultiCellWidget( theader, 0, 0, 0, 1, AlignTop | AlignLeft ); + frameLayout->addMultiCellLayout( layStatus, 1, 1, 0, 1, AlignLeft | AlignVCenter); - mStatusLabel->setText("<b>" + i18n("Press Ctrl+Alt+Del to begin.") + "</b><p>" + i18n("This process helps keep your password secure.") + "<br>" + i18n("It prevents unauthorized users from emulating the login screen.")); + mStatusLabel->setText("<b>" + i18n("Press Ctrl+Alt+Del to begin.") + "</b><p>" + i18n("This process helps keep your password secure.") + "<br>" + i18n("It prevents unauthorized users from emulating the login screen.")); - installEventFilter(this); - setFixedSize( sizeHint() ); + installEventFilter(this); + setFixedSize( sizeHint() ); - mSAKProcess = new TDEProcess; - *mSAKProcess << "tdmtsak"; - connect(mSAKProcess, TQT_SIGNAL(processExited(TDEProcess*)), this, TQT_SLOT(slotSAKProcessExited())); - mSAKProcess->start(); + mSAKProcess = new TDEProcess; + *mSAKProcess << "tdmtsak"; + connect(mSAKProcess, TQ_SIGNAL(processExited(TDEProcess*)), this, TQ_SLOT(slotSAKProcessExited())); + mSAKProcess->start(); } void SAKDlg::slotSAKProcessExited() { - int retcode = mSAKProcess->exitStatus(); - if (retcode != 0) trinity_desktop_lock_use_sak = false; - hide(); + int retcode = mSAKProcess->exitStatus(); + if (retcode != 0) { + trinity_desktop_lock_use_sak = false; + } + hide(); } SAKDlg::~SAKDlg() @@ -128,7 +132,7 @@ SAKDlg::~SAKDlg() void SAKDlg::closeDialogForced() { - TQDialog::reject(); + TQDialog::reject(); } void SAKDlg::reject() @@ -138,14 +142,14 @@ void SAKDlg::reject() void SAKDlg::updateLabel(TQString &txt) { - mStatusLabel->setPaletteForegroundColor(Qt::black); - mStatusLabel->setText("<b>" + txt + "</b>"); + mStatusLabel->setPaletteForegroundColor(TQt::black); + mStatusLabel->setText("<b>" + txt + "</b>"); } void SAKDlg::show() { - TQDialog::show(); - TQApplication::flushX(); + TQDialog::show(); + TQApplication::flushX(); } #include "sakdlg.moc" diff --git a/kdesktop/lock/sakdlg.h b/kdesktop/lock/sakdlg.h index 5810b8771..12d80b8cb 100644 --- a/kdesktop/lock/sakdlg.h +++ b/kdesktop/lock/sakdlg.h @@ -1,8 +1,8 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // -// Copyright (c) 2010 Timothy Pearson <kb9vqf@pearsoncomputing.net> +// Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> // #ifndef __SAKDLG_H__ @@ -26,32 +26,32 @@ class TQListView; // class SAKDlg : public TQDialog { - Q_OBJECT - -public: - SAKDlg(LockProcess *parent); - ~SAKDlg(); - virtual void show(); - - void updateLabel( TQString &txt ); - void closeDialogForced(); - -private slots: - void slotSAKProcessExited(); - -protected slots: - virtual void reject(); - -private: - TQFrame *frame; - TQGridLayout *frameLayout; - TQLabel *mStatusLabel; - int mCapsLocked; - bool mUnlockingFailed; - TQStringList layoutsList; - TQStringList::iterator currLayout; - int sPid, sFd; - TDEProcess* mSAKProcess; + TQ_OBJECT + + public: + SAKDlg(LockProcess *parent); + ~SAKDlg(); + virtual void show(); + + void updateLabel( TQString &txt ); + void closeDialogForced(); + + private slots: + void slotSAKProcessExited(); + + protected slots: + virtual void reject(); + + private: + TQFrame *frame; + TQGridLayout *frameLayout; + TQLabel *mStatusLabel; + int mCapsLocked; + bool mUnlockingFailed; + TQStringList layoutsList; + TQStringList::iterator currLayout; + int sPid, sFd; + TDEProcess* mSAKProcess; }; #endif diff --git a/kdesktop/lock/securedlg.cpp b/kdesktop/lock/securedlg.cpp index b38378f2e..ba2b08af0 100644 --- a/kdesktop/lock/securedlg.cpp +++ b/kdesktop/lock/securedlg.cpp @@ -1,8 +1,8 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // -// Copyright (c) 2010-2011 Timothy Pearson <kb9vqf@pearsoncomputing.net> +// Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> #include <config.h> @@ -14,7 +14,7 @@ #include <tdelocale.h> #include <kpushbutton.h> #include <kseparator.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <tdeglobalsettings.h> #include <tdeconfig.h> #include <kiconloader.h> @@ -64,152 +64,154 @@ extern bool trinity_desktop_lock_use_sak; // Simple dialog for displaying an unlock status or recurring error message // SecureDlg::SecureDlg(LockProcess *parent) - : TQDialog(parent, "information dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))), - mUnlockingFailed(false), retInt(NULL) + : TQDialog(parent, "information dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))), + mUnlockingFailed(false), retInt(NULL) { - 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); - XChangeProperty(tqt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); - } - setCaption(i18n("Secure Desktop Area")); - - 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 ); - - KSMModalDialogHeader* theader = new KSMModalDialogHeader( frame ); - - KUser user; - - mLogonStatus = new TQLabel( frame ); - TQString userString = user.fullName(); - if (userString == "") { - userString = user.loginName(); - } - if (userString != "") { - mLogonStatus->setText(i18n("'%1' is currently logged on").arg( user.fullName() )); - } - else { - mLogonStatus->setText(i18n("You are currently logged on")); // We should never get here, and this message is somewhat obtuse, but it is better than displaying two qotation marks with no text between them... - } - - KSeparator *sep = new KSeparator( KSeparator::HLine, frame ); - - mLockButton = new TQPushButton( frame ); - mLockButton->setText(i18n("Lock Session")); - - mTaskButton = new TQPushButton( frame ); - mTaskButton->setText(i18n("Task Manager")); - - mShutdownButton = new TQPushButton( frame ); - mShutdownButton->setText(i18n("Logoff Menu")); - - mCancelButton = new TQPushButton( frame ); - mCancelButton->setText(i18n("Cancel")); - - mSwitchButton = new TQPushButton( frame ); - mSwitchButton->setText(i18n("Switch User")); - mSwitchButton->setEnabled(false); // FIXME - - TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); - unlockDialogLayout->addWidget( frame ); - - TQHBoxLayout *layStatus = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); - layStatus->addWidget( mLogonStatus ); - - TQGridLayout *layPBGrid = new TQGridLayout( 0, 0, KDialog::spacingHint()); - layPBGrid->addWidget( mLockButton, 0, 0 ); - layPBGrid->addWidget( mTaskButton, 0, 1 ); - layPBGrid->addWidget( mShutdownButton, 0, 2 ); - layPBGrid->addWidget( mCancelButton, 0, 3 ); - layPBGrid->addWidget( mSwitchButton, 1, 0 ); - - frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); - frameLayout->addMultiCellWidget( theader, 0, 0, 0, 1, AlignTop | AlignLeft ); - frameLayout->addMultiCellLayout( layStatus, 1, 1, 0, 1, AlignLeft | AlignVCenter); - frameLayout->addMultiCellWidget( sep, 2, 2, 0, 1 ); - frameLayout->addMultiCellLayout( layPBGrid, 3, 3, 0, 1, AlignLeft | AlignVCenter); - - connect(mCancelButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotBtnCancel())); - connect(mLockButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotBtnLock())); - connect(mTaskButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotBtnTask())); - connect(mShutdownButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotBtnShutdown())); - connect(mSwitchButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotBtnSwitchUser())); - - TQSize dlgSz = sizeHint(); - int btnSize = dlgSz.width(); - btnSize = btnSize / 4; - btnSize = btnSize - (KDialog::spacingHint() / 2); - mLockButton->setFixedWidth(btnSize); - mTaskButton->setFixedWidth(btnSize); - mCancelButton->setFixedWidth(btnSize); - mShutdownButton->setFixedWidth(btnSize); - mSwitchButton->setFixedWidth(btnSize); - - installEventFilter(this); - setFixedSize( sizeHint() ); + 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(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); + XChangeProperty(tqt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); + } + setCaption(i18n("Secure Desktop Area")); + + 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 ); + + KSMModalDialogHeader* theader = new KSMModalDialogHeader( frame ); + + KUser user; + + mLogonStatus = new TQLabel( frame ); + TQString userString = user.fullName(); + if (userString == "") { + userString = user.loginName(); + } + if (userString != "") { + mLogonStatus->setText(i18n("'%1' is currently logged on").arg( user.fullName() )); + } + else { + mLogonStatus->setText(i18n("You are currently logged on")); // We should never get here, and this message is somewhat obtuse, but it is better than displaying two qotation marks with no text between them... + } + + KSeparator *sep = new KSeparator( KSeparator::HLine, frame ); + + mLockButton = new TQPushButton( frame ); + mLockButton->setText(i18n("Lock Session")); + + mTaskButton = new TQPushButton( frame ); + mTaskButton->setText(i18n("Task Manager")); + + mShutdownButton = new TQPushButton( frame ); + mShutdownButton->setText(i18n("Logoff Menu")); + + mCancelButton = new TQPushButton( frame ); + mCancelButton->setText(i18n("Cancel")); + + mSwitchButton = new TQPushButton( frame ); + mSwitchButton->setText(i18n("Switch User")); + mSwitchButton->setEnabled(false); // FIXME + + TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this ); + unlockDialogLayout->addWidget( frame ); + + TQHBoxLayout *layStatus = new TQHBoxLayout( 0, 0, KDialog::spacingHint()); + layStatus->addWidget( mLogonStatus ); + + TQGridLayout *layPBGrid = new TQGridLayout( 0, 0, KDialog::spacingHint()); + layPBGrid->addWidget( mLockButton, 0, 0 ); + layPBGrid->addWidget( mTaskButton, 0, 1 ); + layPBGrid->addWidget( mShutdownButton, 0, 2 ); + layPBGrid->addWidget( mCancelButton, 0, 3 ); + layPBGrid->addWidget( mSwitchButton, 1, 0 ); + + frameLayout = new TQGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); + frameLayout->addMultiCellWidget( theader, 0, 0, 0, 1, AlignTop | AlignLeft ); + frameLayout->addMultiCellLayout( layStatus, 1, 1, 0, 1, AlignLeft | AlignVCenter); + frameLayout->addMultiCellWidget( sep, 2, 2, 0, 1 ); + frameLayout->addMultiCellLayout( layPBGrid, 3, 3, 0, 1, AlignLeft | AlignVCenter); + + connect(mCancelButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotBtnCancel())); + connect(mLockButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotBtnLock())); + connect(mTaskButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotBtnTask())); + connect(mShutdownButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotBtnShutdown())); + connect(mSwitchButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotBtnSwitchUser())); + + TQSize dlgSz = sizeHint(); + int btnSize = dlgSz.width(); + btnSize = btnSize / 4; + btnSize = btnSize - (KDialog::spacingHint() / 2); + mLockButton->setFixedWidth(btnSize); + mTaskButton->setFixedWidth(btnSize); + mCancelButton->setFixedWidth(btnSize); + mShutdownButton->setFixedWidth(btnSize); + mSwitchButton->setFixedWidth(btnSize); + + installEventFilter(this); + setFixedSize( sizeHint() ); } SecureDlg::~SecureDlg() { - hide(); + hide(); } void SecureDlg::slotBtnCancel() { - if (retInt) *retInt = 0; - hide(); + if (retInt) *retInt = 0; + hide(); } void SecureDlg::slotBtnLock() { - if (retInt) *retInt = 1; - hide(); + if (retInt) *retInt = 1; + hide(); } void SecureDlg::slotBtnTask() { - if (retInt) *retInt = 2; - hide(); + if (retInt) *retInt = 2; + hide(); } void SecureDlg::slotBtnShutdown() { - if (retInt) *retInt = 3; - hide(); + if (retInt) *retInt = 3; + hide(); } void SecureDlg::slotBtnSwitchUser() { - if (retInt) *retInt = 4; - hide(); + if (retInt) *retInt = 4; + hide(); } void SecureDlg::setRetInt(int *i) { - retInt = i; + retInt = i; } void SecureDlg::closeDialogForced() { - if (retInt) *retInt = 0; - TQDialog::reject(); + if (retInt) *retInt = 0; + TQDialog::reject(); } void SecureDlg::reject() { - closeDialogForced(); + closeDialogForced(); } void SecureDlg::show() { - TQDialog::show(); - TQApplication::flushX(); + TQDialog::show(); + TQApplication::flushX(); } #include "securedlg.moc" diff --git a/kdesktop/lock/securedlg.h b/kdesktop/lock/securedlg.h index d616bf2e7..c6c9fa7fe 100644 --- a/kdesktop/lock/securedlg.h +++ b/kdesktop/lock/securedlg.h @@ -1,8 +1,8 @@ //=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // -// Copyright (c) 2010 Timothy Pearson <kb9vqf@pearsoncomputing.net> +// Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> // #ifndef __SECUREDLG_H__ @@ -27,41 +27,41 @@ class TQListView; // class SecureDlg : public TQDialog { - Q_OBJECT + TQ_OBJECT -public: - SecureDlg(LockProcess *parent); - ~SecureDlg(); - virtual void show(); + public: + SecureDlg(LockProcess *parent); + ~SecureDlg(); + virtual void show(); - void closeDialogForced(); - void setRetInt(int *); + void closeDialogForced(); + void setRetInt(int *); -private slots: - void slotBtnCancel(); - void slotBtnLock(); - void slotBtnTask(); - void slotBtnShutdown(); - void slotBtnSwitchUser(); + private slots: + void slotBtnCancel(); + void slotBtnLock(); + void slotBtnTask(); + void slotBtnShutdown(); + void slotBtnSwitchUser(); -protected slots: - virtual void reject(); + protected slots: + virtual void reject(); -private: - TQFrame *frame; - TQGridLayout *frameLayout; - TQLabel *mLogonStatus; - TQButton *mCancelButton; - TQButton *mLockButton; - TQButton *mTaskButton; - TQButton *mShutdownButton; - TQButton *mSwitchButton; - int mCapsLocked; - bool mUnlockingFailed; - TQStringList layoutsList; - TQStringList::iterator currLayout; - int sPid, sFd; - int* retInt; + private: + TQFrame *frame; + TQGridLayout *frameLayout; + TQLabel *mLogonStatus; + TQButton *mCancelButton; + TQButton *mLockButton; + TQButton *mTaskButton; + TQButton *mShutdownButton; + TQButton *mSwitchButton; + int mCapsLocked; + bool mUnlockingFailed; + TQStringList layoutsList; + TQStringList::iterator currLayout; + int sPid, sFd; + int* retInt; }; #endif diff --git a/kdesktop/lockeng.cpp b/kdesktop/lockeng.cpp index 52826bf24..fc3c9db6e 100644 --- a/kdesktop/lockeng.cpp +++ b/kdesktop/lockeng.cpp @@ -6,16 +6,23 @@ // Copyright (c) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net> // - #include <config.h> #include <stdlib.h> #include <sys/stat.h> +#include <tdeglobal.h> + +#ifdef WITH_TDEHWLIB +#include <ksslcertificate.h> +#include <kuser.h> +#include <tdehardwaredevices.h> +#include <tdecryptographiccarddevice.h> +#endif -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <tdeapplication.h> #include <kservicegroup.h> -#include <ksimpleconfig.h> +#include <tdesimpleconfig.h> #include <kdebug.h> #include <tdelocale.h> #include <tqfile.h> @@ -37,60 +44,57 @@ #include "lockeng.moc" #include "kdesktopsettings.h" -#define SYSTEMD_LOGIN1_SERVICE "org.freedesktop.login1" -#define SYSTEMD_LOGIN1_PATH "/org/freedesktop/login1" -#define SYSTEMD_LOGIN1_MANAGER_IFACE "org.freedesktop.login1.Manager" -#define SYSTEMD_LOGIN1_SESSION_IFACE "org.freedesktop.login1.Session" -#define SYSTEMD_LOGIN1_SEAT_IFACE "org.freedesktop.login1.Seat" +#include "xautolock_c.h" + +#define SYSTEMD_LOGIN1_SERVICE "org.freedesktop.login1" +#define SYSTEMD_LOGIN1_MANAGER_IFACE "org.freedesktop.login1.Manager" +#define SYSTEMD_LOGIN1_SESSION_IFACE "org.freedesktop.login1.Session" +#define SYSTEMD_LOGIN1_SEAT_IFACE "org.freedesktop.login1.Seat" +#define SYSTEMD_LOGIN1_PATH "/org/freedesktop/login1" #define DBUS_CONN_NAME "kdesktop_lock" -#include "xautolock_c.h" extern xautolock_corner_t xautolock_corners[ 4 ]; +bool trinity_lockeng_sak_available = true; -bool trinity_lockeng_sak_available = TRUE; +SaverEngineEventHandler *gbl_saverEngineEventHandler = nullptr; -SaverEngine* m_masterSaverEngine = NULL; static void sigusr1_handler(int) { - if (m_masterSaverEngine) { - m_masterSaverEngine->m_threadHelperObject->slotLockProcessWaiting(); + if (gbl_saverEngineEventHandler) + { + gbl_saverEngineEventHandler->lockCompleted(); } } + static void sigusr2_handler(int) { - if (m_masterSaverEngine) { - m_masterSaverEngine->m_threadHelperObject->slotLockProcessFullyActivated(); + if (gbl_saverEngineEventHandler) + { + gbl_saverEngineEventHandler->lockFullyActivated(); } } + static void sigttin_handler(int) { - if (m_masterSaverEngine) { - m_masterSaverEngine->slotLockProcessReady(); + if (gbl_saverEngineEventHandler) + { + gbl_saverEngineEventHandler->lockReady(); } } -//=========================================================================== -// -// Screen saver engine. Doesn't handle the actual screensaver window, -// starting screensaver hacks, or password entry. That's done by -// a newly started process. -// SaverEngine::SaverEngine() - : TQWidget(), + : TQObject(), KScreensaverIface(), mBlankOnly(false), - mSAKProcess(NULL), - mTerminationRequested(false), - mSaverProcessReady(false), mNewVTAfterLockEngage(false), + mValidCryptoCardInserted(false), mSwitchVTAfterLockEngage(-1), dBusLocal(0), dBusWatch(0), systemdSession(0) { // handle SIGUSR1 - m_masterSaverEngine = this; mSignalAction.sa_handler= sigusr1_handler; sigemptyset(&(mSignalAction.sa_mask)); sigaddset(&(mSignalAction.sa_mask), SIGUSR1); @@ -98,15 +102,13 @@ SaverEngine::SaverEngine() sigaction(SIGUSR1, &mSignalAction, 0L); // handle SIGUSR2 - m_masterSaverEngine = this; mSignalAction.sa_handler= sigusr2_handler; sigemptyset(&(mSignalAction.sa_mask)); sigaddset(&(mSignalAction.sa_mask), SIGUSR2); mSignalAction.sa_flags = 0; sigaction(SIGUSR2, &mSignalAction, 0L); - // handle SIGTTIN - m_masterSaverEngine = this; + // handle SIGTTIN (as custom user signal rather than its inherent meaning) mSignalAction.sa_handler= sigttin_handler; sigemptyset(&(mSignalAction.sa_mask)); sigaddset(&(mSignalAction.sa_mask), SIGTTIN); @@ -114,329 +116,305 @@ SaverEngine::SaverEngine() sigaction(SIGTTIN, &mSignalAction, 0L); // Save X screensaver parameters - XGetScreenSaver(tqt_xdisplay(), &mXTimeout, &mXInterval, - &mXBlanking, &mXExposures); - - mState = Waiting; - mXAutoLock = 0; + XGetScreenSaver(tqt_xdisplay(), &mXTimeout, &mXInterval, &mXBlanking, &mXExposures); + + // Create event handler thread, event loop and object + m_eventHandlerThread = new TQEventLoopThread; + m_eventHandlerThread->start(); + m_saverEngineEventHandler = new SaverEngineEventHandler(this); + gbl_saverEngineEventHandler = m_saverEngineEventHandler; + m_saverEngineEventHandler->moveToThread(m_eventHandlerThread); + connect(this, TQ_SIGNAL(terminateEventHandlerThread()), m_saverEngineEventHandler, TQ_SLOT(terminateThread())); + connect(this, TQ_SIGNAL(lockScreenSignal(bool)), m_saverEngineEventHandler, TQ_SLOT(lockScreen(bool))); + connect(this, TQ_SIGNAL(activateSaverOrLockSignal(LockType)), + m_saverEngineEventHandler, TQ_SLOT(activateSaverOrLock(LockType))); + + mXAutoLock = nullptr; mEnabled = false; - m_helperThread = new TQEventLoopThread; - m_helperThread->start(); - m_threadHelperObject = new SaverEngineThreadHelperObject; - m_threadHelperObject->moveToThread(m_helperThread); - connect(this, TQT_SIGNAL(terminateHelperThread()), m_threadHelperObject, TQT_SLOT(terminateThread())); - connect(m_threadHelperObject, TQT_SIGNAL(lockProcessWaiting()), this, TQT_SLOT(lockProcessWaiting())); - connect(m_threadHelperObject, TQT_SIGNAL(lockProcessFullyActivated()), this, TQT_SLOT(lockProcessFullyActivated())); - - connect(&mLockProcess, TQT_SIGNAL(processExited(TDEProcess *)), - TQT_SLOT(lockProcessExited())); - configure(); - // Create SAK process only if SAK is enabled - KSimpleConfig *config; - struct stat st; - if (stat( KDE_CONFDIR "/tdm/tdmdistrc" , &st) == 0) { - config = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdm/tdmdistrc" )); - } - else { - config = new KSimpleConfig( TQString::fromLatin1( KDE_CONFDIR "/tdm/tdmrc" )); - } - config->setGroup("X-:*-Greeter"); - bool useSAKProcess = false; -#ifdef BUILD_TSAK - useSAKProcess = config->readBoolEntry("UseSAK", false) && KDesktopSettings::useTDESAK(); -#endif - if (useSAKProcess) { - mSAKProcess = new TDEProcess; - *mSAKProcess << "tdmtsak"; - connect(mSAKProcess, TQT_SIGNAL(processExited(TDEProcess*)), this, TQT_SLOT(slotSAKProcessExited())); - TQTimer::singleShot( 0, this, TQT_SLOT(handleSecureDialog()) ); - } - - mLockProcess.clearArguments(); - TQString path = TDEStandardDirs::findExe( "kdesktop_lock" ); - if( path.isEmpty()) + // Prevent kdesktop_lock signals from being handled by the main GUI thread. + // Those signals will be handled by m_eventHandlerThread instead + // + // Make sure to keep this code after the constructor of `m_eventHandlerThread`, so that + // the new thread starts with the signals unblocked. + sigset_t sigBlockMask; + sigemptyset(&sigBlockMask); + sigaddset(&sigBlockMask, SIGUSR1); + sigaddset(&sigBlockMask, SIGUSR2); + sigaddset(&sigBlockMask, SIGTTIN); + sigaddset(&sigBlockMask, SIGCHLD); + pthread_sigmask(SIG_BLOCK, &sigBlockMask, NULL); + + // Start SAK and lock processes + TQTimer::singleShot(0, m_saverEngineEventHandler, TQ_SLOT(restartLockProcess())); + +#ifdef WITH_TDEHWLIB + // Initialize SmartCard readers + TDEGenericDevice *hwdevice; + TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); + TDEGenericHardwareList cardReaderList = hwdevices->listByDeviceClass(TDEGenericDeviceType::CryptographicCard); + for (hwdevice = cardReaderList.first(); hwdevice; hwdevice = cardReaderList.next()) { - kdDebug( 1204 ) << "Can't find kdesktop_lock!" << endl; - } - mLockProcess << path; - mLockProcess << TQString( "--internal" ) << TQString( "%1" ).arg(getpid()); - if (mLockProcess.start() == false ) + TDECryptographicCardDevice *cdevice = static_cast<TDECryptographicCardDevice*>(hwdevice); + connect(cdevice, TQ_SIGNAL(certificateListAvailable(TDECryptographicCardDevice*)), + this, TQ_SLOT(cryptographicCardInserted(TDECryptographicCardDevice*))); + connect(cdevice, TQ_SIGNAL(cardRemoved(TDECryptographicCardDevice*)), + this, TQ_SLOT(cryptographicCardRemoved(TDECryptographicCardDevice*))); + cdevice->enableCardMonitoring(true); + } + + // Check card login status + KUser userinfo; + TQString fileName = userinfo.homeDir() + "/.tde_card_login_state"; + TQFile flagFile(fileName); + if (flagFile.open(IO_ReadOnly)) { - kdDebug( 1204 ) << "Failed to start kdesktop_lock!" << endl; + TQTextStream stream(&flagFile); + if (stream.readLine().startsWith("1")) + { + // Card was likely used to log in + TQTimer::singleShot(5000, this, TQ_SLOT(cardStartupTimeout())); + } + flagFile.close(); } +#endif - // Prevent kdesktop_lock signals from being handled by the wrong (GUI) thread - sigemptyset(&mThreadBlockSet); - sigaddset(&mThreadBlockSet, SIGUSR1); - sigaddset(&mThreadBlockSet, SIGUSR2); - sigaddset(&mThreadBlockSet, SIGTTIN); - pthread_sigmask(SIG_BLOCK, &mThreadBlockSet, NULL); + dBusConnect(); +} - // Wait for the saver process to signal ready... - if (!waitForLockProcessStart()) { - kdDebug( 1204 ) << "Failed to initialize kdesktop_lock (unexpected termination)!" << endl; - } +SaverEngine::~SaverEngine() +{ + m_saverEngineEventHandler->terminateLockProcess(); + delete mXAutoLock; + dBusClose(); - // lock the desktop if required - config->setGroup("X-:0-Core"); - bool autoLoginEnable = config->readBoolEntry("AutoLoginEnable", false); - bool autoLoginLocked = config->readBoolEntry("AutoLoginLocked", false); - if (autoLoginEnable && autoLoginLocked) { - mLockProcess.kill(SIGTTOU); - mLockProcess.kill(SIGUSR1); - } - delete config; - config = NULL; + // Restore X screensaver parameters + XSetScreenSaver(tqt_xdisplay(), mXTimeout, mXInterval, mXBlanking, mXExposures); + emit terminateEventHandlerThread(); + m_eventHandlerThread->wait(); + delete m_saverEngineEventHandler; + delete m_eventHandlerThread; +} - dBusConnect(); +void SaverEngine::cardStartupTimeout() +{ + if (!mValidCryptoCardInserted) + { + configure(); // Restore saver timeout + lockScreen(); // Force lock + } } -//--------------------------------------------------------------------------- -// -// Destructor - usual cleanups. -// -SaverEngine::~SaverEngine() +void SaverEngine::cryptographicCardInserted(TDECryptographicCardDevice* cdevice) { - if (mState == Waiting) { - kill(mLockProcess.pid(), SIGKILL); +#ifdef WITH_TDEHWLIB + TQString login_name = TQString::null; + X509CertificatePtrList certList = cdevice->cardX509Certificates(); + if (certList.count() > 0) + { + KSSLCertificate* card_cert = NULL; + card_cert = KSSLCertificate::fromX509(certList[0]); + TQStringList cert_subject_parts = TQStringList::split("/", card_cert->getSubject(), false); + for (TQStringList::Iterator it = cert_subject_parts.begin(); it != cert_subject_parts.end(); ++it) + { + TQString lcpart = (*it).lower(); + if (lcpart.startsWith("cn=")) + { + login_name = lcpart.right(lcpart.length() - strlen("cn=")); + } + } + delete card_cert; } - mLockProcess.detach(); // don't kill it if we crash - delete mXAutoLock; + if (login_name != "") + { + KUser user; + if (login_name == user.loginName()) + { + mValidCryptoCardInserted = true; + } + } +#endif +} - dBusClose(); +void SaverEngine::cryptographicCardRemoved(TDECryptographicCardDevice* cdevice) +{ +#ifdef WITH_TDEHWLIB + if (mValidCryptoCardInserted) + { + mValidCryptoCardInserted = false; - // Restore X screensaver parameters - XSetScreenSaver(tqt_xdisplay(), mXTimeout, mXInterval, mXBlanking, - mXExposures); + // Restore saver timeout + configure(); - terminateHelperThread(); - m_helperThread->wait(); - delete m_threadHelperObject; - delete m_helperThread; + // Force lock + lockScreen(); + } +#endif } -//--------------------------------------------------------------------------- -// -// This should be called only using DCOP. -// +// DCOP interface method void SaverEngine::lock() { lockScreen(true); } -//--------------------------------------------------------------------------- -// -// Lock the screen -// -void SaverEngine::lockScreen(bool DCOP) +void SaverEngine::lockScreen(bool dcop) { - bool ok = true; - if (mState == Waiting) + if (mValidCryptoCardInserted) { - ok = startLockProcess( ForceLock ); - // It takes a while for kdesktop_lock to start and lock the screen. - // Therefore delay the DCOP call until it tells kdesktop that the locking is in effect. - // This is done only for --forcelock . - if( ok && mState != Saving ) - { - if (DCOP) { - DCOPClientTransaction* trans = kapp->dcopClient()->beginTransaction(); - if (trans) { - mLockTransactions.append( trans ); - } - } - } + kdDebug(1204) << "SaverEngine: crypto card inserted, ignore lock request" << endl; + return; } - else + emit lockScreenSignal(dcop); +} + +void SaverEngine::lockScreenGUI() +{ + DCOPClientTransaction *trans = tdeApp->dcopClient()->beginTransaction(); + if (trans) { - mLockProcess.kill( SIGHUP ); + mLockTransactions.append(trans); } } void SaverEngine::processLockTransactions() { - for( TQValueVector< DCOPClientTransaction* >::ConstIterator it = mLockTransactions.begin(); - it != mLockTransactions.end(); - ++it ) + TQValueVector<DCOPClientTransaction*>::ConstIterator it = mLockTransactions.begin(); + for (; it != mLockTransactions.end(); ++it) { TQCString replyType = "void"; TQByteArray arr; - kapp->dcopClient()->endTransaction( *it, replyType, arr ); + tdeApp->dcopClient()->endTransaction(*it, replyType, arr); } mLockTransactions.clear(); } void SaverEngine::saverLockReady() { - if( mState != Engaging ) + if (m_saverEngineEventHandler->getState() != SaverState::Engaging) { - kdDebug( 1204 ) << "Got unexpected saverReady()" << endl; + kdDebug(1204) << "Got unexpected saverLockReady()" << endl; } - kdDebug( 1204 ) << "Saver Lock Ready" << endl; + + kdDebug(1204) << "Saver Lock Ready" << endl; processLockTransactions(); } -//--------------------------------------------------------------------------- +// DCOP interface method void SaverEngine::save() { - if (mState == Waiting) + if (mValidCryptoCardInserted) { - startLockProcess( DefaultLock ); + kdDebug(1204) << "SaverEngine: crypto card inserted, ignore save request" << endl; + return; } + TQTimer::singleShot(0, m_saverEngineEventHandler, TQ_SLOT(saveScreen())); } -//--------------------------------------------------------------------------- +// DCOP interface method void SaverEngine::quit() { - if (mState == Saving || mState == Engaging) - { - stopLockProcess(); - } + TQTimer::singleShot(0, m_saverEngineEventHandler, TQ_SLOT(stopLockProcess())); } -//--------------------------------------------------------------------------- +// DCOP interface method bool SaverEngine::isEnabled() { return mEnabled; } -//--------------------------------------------------------------------------- -bool SaverEngine::enable( bool e ) +// DCOP interface method +bool SaverEngine::enable(bool e) { - if ( e == mEnabled ) - return true; + if (e == mEnabled) + return true; // If we aren't in a suitable state, we will not reconfigure. - if (mState != Waiting) + if (m_saverEngineEventHandler->getState() != SaverState::Waiting) return false; mEnabled = e; if (mEnabled) { - if ( !mXAutoLock ) { + if (!mXAutoLock) + { mXAutoLock = new XAutoLock(); - connect(mXAutoLock, TQT_SIGNAL(timeout()), TQT_SLOT(idleTimeout())); + connect(mXAutoLock, TQ_SIGNAL(timeout()), TQ_SLOT(idleTimeout())); } - mXAutoLock->setTimeout(mTimeout); - mXAutoLock->setDPMS(true); - //mXAutoLock->changeCornerLockStatus( mLockCornerTopLeft, mLockCornerTopRight, mLockCornerBottomLeft, mLockCornerBottomRight); + mXAutoLock->setTimeout(mTimeout); + mXAutoLock->setDPMS(true); - // We'll handle blanking - XSetScreenSaver(tqt_xdisplay(), mTimeout + 10, mXInterval, PreferBlanking, mXExposures); - kdDebug() << "XSetScreenSaver " << mTimeout + 10 << endl; - - mXAutoLock->start(); - - kdDebug(1204) << "Saver Engine started, timeout: " << mTimeout << endl; + // We'll handle blanking + XSetScreenSaver(tqt_xdisplay(), mTimeout + 10, mXInterval, PreferBlanking, mXExposures); + mXAutoLock->start(); + kdDebug(1204) << "Saver engine started, timeout: " << mTimeout << endl; } else { if (mXAutoLock) { delete mXAutoLock; - mXAutoLock = 0; + mXAutoLock = nullptr; } - XForceScreenSaver(tqt_xdisplay(), ScreenSaverReset ); + XForceScreenSaver(tqt_xdisplay(), ScreenSaverReset); XSetScreenSaver(tqt_xdisplay(), 0, mXInterval, PreferBlanking, DontAllowExposures); - kdDebug(1204) << "Saver Engine disabled" << endl; + kdDebug(1204) << "Saver engine disabled" << endl; } return true; } -//--------------------------------------------------------------------------- +// DCOP interface method bool SaverEngine::isBlanked() { - return (mState != Waiting); + return (m_saverEngineEventHandler->getState() != SaverState::Waiting); } void SaverEngine::enableExports() { -#ifdef Q_WS_X11 - kdDebug(270) << k_lineinfo << "activating background exports.\n"; - DCOPClient *client = kapp->dcopClient(); - if (!client->isAttached()) { +#ifdef TQ_WS_X11 + kdDebug(270) << k_lineinfo << "activating background exports" << endl; + DCOPClient *client = tdeApp->dcopClient(); + if (!client->isAttached()) + { client->attach(); } TQByteArray data; - TQDataStream args( data, IO_WriteOnly ); + TQDataStream args(data, IO_WriteOnly); args << 1; - TQCString appname( "kdesktop" ); + TQCString appname("kdesktop"); int screen_number = DefaultScreen(tqt_xdisplay()); - if ( screen_number ) { - appname.sprintf("kdesktop-screen-%d", screen_number ); + if (screen_number) + { + appname.sprintf("kdesktop-screen-%d", screen_number); } - client->send( appname, "KBackgroundIface", "setExport(int)", data ); + client->send(appname, "KBackgroundIface", "setExport(int)", data); #endif } -//--------------------------------------------------------------------------- -void SaverEngine::handleSecureDialog() -{ - // Wait for SAK press - if (mSAKProcess && !mSAKProcess->isRunning()) { - mSAKProcess->start(); - } -} - -void SaverEngine::slotSAKProcessExited() -{ - if (!mSAKProcess) { - printf("[kdesktop] SAK process does not exist. Something went wrong. Ignoring...\n"); fflush(stdout); - return; - } - int retcode = mSAKProcess->exitStatus(); - if ((retcode != 0) && (mSAKProcess->normalExit())) { - trinity_lockeng_sak_available = FALSE; - printf("[kdesktop] SAK driven secure dialog is not available for use (retcode %d). Check tdmtsak for proper functionality.\n", retcode); fflush(stdout); - } - - if (mState == Preparing) { - return; - } - - if ((mSAKProcess->normalExit()) && (trinity_lockeng_sak_available == TRUE)) { - bool ok = true; - if (mState == Waiting) - { - ok = startLockProcess( SecureDialog ); - if( ok && mState != Saving ) - { - } - } - else - { - mLockProcess.kill( SIGHUP ); - } - } -} - -//--------------------------------------------------------------------------- -// // Read and apply configuration. -// void SaverEngine::configure() { // If we aren't in a suitable state, we will not reconfigure. - if (mState != Waiting) { + if (m_saverEngineEventHandler->getState() != SaverState::Waiting) + { return; } // create a new config obj to ensure we read the latest options KDesktopSettings::self()->readConfig(); - bool e = KDesktopSettings::screenSaverEnabled(); mTimeout = KDesktopSettings::timeout(); - - mEnabled = !e; // force the enable() + bool e = KDesktopSettings::screenSaverEnabled(); + mEnabled = !e; // enable the screensaver by forcibly toggling it + enable(e); int action; action = KDesktopSettings::actionTopLeft(); @@ -447,407 +425,257 @@ void SaverEngine::configure() xautolock_corners[2] = applyManualSettings(action); action = KDesktopSettings::actionBottomRight(); xautolock_corners[3] = applyManualSettings(action); - - enable( e ); } -//--------------------------------------------------------------------------- -// -// Set a variable to indicate only using the blanker and not the saver. -// -void SaverEngine::setBlankOnly( bool blankOnly ) +// DCOP interface method +// Set a variable to indicate only to blank the screen and not use the saver +void SaverEngine::setBlankOnly(bool blankOnly) { mBlankOnly = blankOnly; - // FIXME: if running, stop and restart? What about security - // implications of this? -} - -bool SaverEngine::restartDesktopLockProcess() -{ - if (!mLockProcess.isRunning()) { - mSaverProcessReady = false; - mLockProcess.clearArguments(); - TQString path = TDEStandardDirs::findExe( "kdesktop_lock" ); - if (path.isEmpty()) { - kdDebug( 1204 ) << "Can't find kdesktop_lock!" << endl; - return false; - } - mLockProcess << path; - mLockProcess << TQString( "--internal" ) << TQString( "%1" ).arg(getpid()); - if (mLockProcess.start() == false) { - kdDebug( 1204 ) << "Failed to start kdesktop_lock!" << endl; - return false; - } - // Wait for the saver process to signal ready... - if (!waitForLockProcessStart()) { - kdDebug( 1204 ) << "Failed to initialize kdesktop_lock (unexpected termination)!" << endl; - return false; - } - } - return true; } -//--------------------------------------------------------------------------- -// -// Start the screen saver. -// -bool SaverEngine::startLockProcess( LockType lock_type ) +void SaverEngine::activateSaverOrLockGUI() { - int ret; - - if (mState == Saving) { - return true; - } - - mState = Preparing; - if (mSAKProcess) { - mSAKProcess->kill(SIGTERM); - } - - enableExports(); - - kdDebug(1204) << "SaverEngine: starting saver" << endl; - emitDCOPSignal("KDE_start_screensaver()", TQByteArray()); - - if (!restartDesktopLockProcess()) { - mState = Waiting; - return false; - } - - switch( lock_type ) - { - case ForceLock: - mLockProcess.kill(SIGUSR1); // Request forcelock - break; - case DontLock: - mLockProcess.kill(SIGUSR2); // Request dontlock - break; - case SecureDialog: - mLockProcess.kill(SIGWINCH); // Request secure dialog - break; - default: - break; - } - if (mBlankOnly) { - mLockProcess.kill(SIGTTIN); // Request blanking - } - - ret = mLockProcess.kill(SIGTTOU); // Start lock - if (!ret) { - mState = Waiting; - return false; - } XSetScreenSaver(tqt_xdisplay(), 0, mXInterval, PreferBlanking, mXExposures); - - mState = Engaging; - if (mXAutoLock) { + if (mXAutoLock) + { mXAutoLock->stop(); } - return true; + emitDCOPSignal("KDE_start_screensaver()", TQByteArray()); } -//--------------------------------------------------------------------------- -// -// Stop the screen saver. -// -void SaverEngine::stopLockProcess() +void SaverEngine::stopLockProcessGUI() { - if (mState == Waiting) { - kdWarning(1204) << "SaverEngine::stopSaver() saver not active" << endl; - return; - } - kdDebug(1204) << "SaverEngine: stopping lock" << endl; emitDCOPSignal("KDE_stop_screensaver()", TQByteArray()); - mTerminationRequested = true; - mLockProcess.kill(); - - if (mEnabled) { - if (mXAutoLock) { + if (mEnabled) + { + if (mXAutoLock) + { mXAutoLock->start(); } - XForceScreenSaver(tqt_xdisplay(), ScreenSaverReset ); + XForceScreenSaver(tqt_xdisplay(), ScreenSaverReset); XSetScreenSaver(tqt_xdisplay(), mTimeout + 10, mXInterval, PreferBlanking, mXExposures); } processLockTransactions(); - mState = Waiting; - if( systemdSession && systemdSession->canSend() ) { + if (systemdSession && systemdSession->canSend()) + { TQValueList<TQT_DBusData> params; params << TQT_DBusData::fromBool(false); TQT_DBusMessage reply = systemdSession->sendWithReply("SetIdleHint", params); } } -void SaverEngine::recoverFromHackingAttempt() -{ - // Try to relaunch saver with forcelock - if (!startLockProcess(ForceLock)) { - // Terminate the TDE session ASAP! - // Values are explained at http://lists.kde.org/?l=kde-linux&m=115770988603387 - TQByteArray data; - TQDataStream arg(data, IO_WriteOnly); - arg << (int)0 << (int)0 << (int)2; - if (!kapp->dcopClient()->send("ksmserver", "default", "logout(int,int,int)", data)) { - // Someone got to DCOP before we did - // Try an emergency system logout - system("logout"); - } - } -} - -void SaverEngine::lockProcessExited() +void SaverEngine::terminateTDESession() { - bool abnormalExit = false; - if (mLockProcess.normalExit() == false) { - abnormalExit = true; - } - else { - if (mLockProcess.exitStatus() != 0) { - abnormalExit = true; - } - } - if (mTerminationRequested == true) { - abnormalExit = false; - mTerminationRequested = false; - } - if (abnormalExit == true) { - // PROBABLE HACKING ATTEMPT DETECTED - restartDesktopLockProcess(); - mState = Waiting; - TQTimer::singleShot( 100, this, SLOT(recoverFromHackingAttempt()) ); - } - else { - // Restart the lock process - restartDesktopLockProcess(); + // Terminate the TDE session ASAP! + // Values are explained at http://lists.kde.org/?l=kde-linux&m=115770988603387 + TQByteArray data; + TQDataStream arg(data, IO_WriteOnly); + arg << (int)0 << (int)0 << (int)2; + if (!tdeApp->dcopClient()->send("ksmserver", "default", "logout(int,int,int)", data)) + { + // Someone got to DCOP before we did. Try an emergency system logout + system("logout"); } } -void SaverEngineThreadHelperObject::slotLockProcessWaiting() +void SaverEngine::lockProcessFullyActivatedGUI() { - // lockProcessWaiting cannot be called directly from a signal handler, as it will hang in certain obscure circumstances - // Instead we use a single-shot timer to immediately call lockProcessWaiting once control has returned to the Qt main loop - lockProcessWaiting(); -} - -void SaverEngineThreadHelperObject::slotLockProcessFullyActivated() -{ - lockProcessFullyActivated(); -} - -void SaverEngine::lockProcessFullyActivated() -{ - mState = Saving; - - if( systemdSession && systemdSession->canSend() ) { + if (systemdSession && systemdSession->canSend()) + { TQValueList<TQT_DBusData> params; params << TQT_DBusData::fromBool(true); TQT_DBusMessage reply = systemdSession->sendWithReply("SetIdleHint", params); } - if (mNewVTAfterLockEngage) { + if (mNewVTAfterLockEngage) + { DM().startReserve(); mNewVTAfterLockEngage = false; } - else if (mSwitchVTAfterLockEngage != -1) { + else if (mSwitchVTAfterLockEngage != -1) + { DM().switchVT(mSwitchVTAfterLockEngage); mSwitchVTAfterLockEngage = -1; } } -void SaverEngine::slotLockProcessReady() -{ - mSaverProcessReady = true; -} - -void SaverEngine::lockProcessWaiting() -{ - kdDebug(1204) << "SaverEngine: lock exited" << endl; - if (trinity_lockeng_sak_available == TRUE) { - handleSecureDialog(); - } - if( mState == Waiting ) { - return; - } - emitDCOPSignal("KDE_stop_screensaver()", TQByteArray()); - if (mEnabled) { - if (mXAutoLock) { - mXAutoLock->start(); - } - XForceScreenSaver(tqt_xdisplay(), ScreenSaverReset ); - XSetScreenSaver(tqt_xdisplay(), mTimeout + 10, mXInterval, PreferBlanking, mXExposures); - } - processLockTransactions(); - mState = Waiting; - - if( systemdSession && systemdSession->canSend() ) { - TQValueList<TQT_DBusData> params; - params << TQT_DBusData::fromBool(false); - TQT_DBusMessage reply = systemdSession->sendWithReply("SetIdleHint", params); - } -} - -//--------------------------------------------------------------------------- -// // XAutoLock has detected the required idle time. -// void SaverEngine::idleTimeout() { - // disable X screensaver - XForceScreenSaver(tqt_xdisplay(), ScreenSaverReset ); - XSetScreenSaver(tqt_xdisplay(), 0, mXInterval, PreferBlanking, DontAllowExposures); - startLockProcess( DefaultLock ); + if (!mValidCryptoCardInserted) + { + // disable X screensaver + XForceScreenSaver(tqt_xdisplay(), ScreenSaverReset); + XSetScreenSaver(tqt_xdisplay(), 0, mXInterval, PreferBlanking, DontAllowExposures); + emit activateSaverOrLockSignal(DefaultLock); + } } xautolock_corner_t SaverEngine::applyManualSettings(int action) { - if (action == 0) { + if (action == 0) + { kdDebug() << "no lock" << endl; return ca_nothing; } - else if (action == 1) { + else if (action == 1) + { kdDebug() << "lock screen" << endl; return ca_forceLock; } - else if (action == 2) { + else if (action == 2) + { kdDebug() << "prevent lock" << endl; return ca_dontLock; } - else{ + else + { kdDebug() << "no lock nothing" << endl; return ca_nothing; } } -/*! - * This function try a reconnect to D-Bus. +/* + * This function try to reconnect to D-Bus. * \return boolean with the result of the operation * \retval true if successful reconnected to D-Bus * \retval false if unsuccessful */ -bool SaverEngine::dBusReconnect() { - // close D-Bus connection - dBusClose(); - // init D-Bus conntection - return (dBusConnect()); -} +bool SaverEngine::dBusReconnect() +{ + dBusClose(); // close D-Bus connection + return (dBusConnect()); // init D-Bus conntection +} -/*! - * This function is used to close D-Bus connection. - */ -void SaverEngine::dBusClose() { - if( dBusConn.isConnected() ) { - if( dBusLocal ) { +// This function is used to close D-Bus connection. +void SaverEngine::dBusClose() +{ + if (dBusConn.isConnected()) + { + if (dBusLocal) + { delete dBusLocal; - dBusLocal = 0; + dBusLocal = nullptr; } - if( dBusWatch ) { + if (dBusWatch) + { delete dBusWatch; - dBusWatch = 0; + dBusWatch = nullptr; } - if( systemdSession ) { + if (systemdSession) + { delete systemdSession; - systemdSession = 0; + systemdSession = nullptr; } } dBusConn.closeConnection(DBUS_CONN_NAME); } -/*! - * This function is used to connect to D-Bus. - */ -bool SaverEngine::dBusConnect() { +// This function is used to connect to D-Bus. +bool SaverEngine::dBusConnect() +{ dBusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus, DBUS_CONN_NAME); - if( !dBusConn.isConnected() ) { + if (!dBusConn.isConnected()) + { kdError() << "Failed to open connection to system message bus: " << dBusConn.lastError().message() << endl; - TQTimer::singleShot(4000, this, TQT_SLOT(dBusReconnect())); + TQTimer::singleShot(4000, this, TQ_SLOT(dBusReconnect())); return false; } // watcher for Disconnect signal dBusLocal = new TQT_DBusProxy(DBUS_SERVICE_DBUS, DBUS_PATH_LOCAL, DBUS_INTERFACE_LOCAL, dBusConn); - TQObject::connect(dBusLocal, TQT_SIGNAL(dbusSignal(const TQT_DBusMessage&)), - this, TQT_SLOT(handleDBusSignal(const TQT_DBusMessage&))); + TQObject::connect(dBusLocal, TQ_SIGNAL(dbusSignal(const TQT_DBusMessage&)), + this, TQ_SLOT(handleDBusSignal(const TQT_DBusMessage&))); // watcher for NameOwnerChanged signals dBusWatch = new TQT_DBusProxy(DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, dBusConn); - TQObject::connect(dBusWatch, TQT_SIGNAL(dbusSignal(const TQT_DBusMessage&)), - this, TQT_SLOT(handleDBusSignal(const TQT_DBusMessage&))); + TQObject::connect(dBusWatch, TQ_SIGNAL(dbusSignal(const TQT_DBusMessage&)), + this, TQ_SLOT(handleDBusSignal(const TQT_DBusMessage&))); // find already running SystemD TQT_DBusProxy checkSystemD(DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, dBusConn); - if( checkSystemD.canSend() ) { + if (checkSystemD.canSend()) + { TQValueList<TQT_DBusData> params; params << TQT_DBusData::fromString(SYSTEMD_LOGIN1_SERVICE); TQT_DBusMessage reply = checkSystemD.sendWithReply("NameHasOwner", params); - if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1 && reply[0].toBool() ) { + if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1 && reply[0].toBool()) + { onDBusServiceRegistered(SYSTEMD_LOGIN1_SERVICE); } } return true; } -/*! - * This function handles D-Bus service registering - */ -void SaverEngine::onDBusServiceRegistered(const TQString& service) { - if( service == SYSTEMD_LOGIN1_SERVICE ) { +// This function handles D-Bus service registering +void SaverEngine::onDBusServiceRegistered(const TQString& service) +{ + if (service == SYSTEMD_LOGIN1_SERVICE) + { // get current systemd session TQT_DBusProxy managerIface(SYSTEMD_LOGIN1_SERVICE, SYSTEMD_LOGIN1_PATH, SYSTEMD_LOGIN1_MANAGER_IFACE, dBusConn); TQT_DBusObjectPath systemdSessionPath = TQT_DBusObjectPath(); - if( managerIface.canSend() ) { + if (managerIface.canSend()) + { TQValueList<TQT_DBusData> params; - params << TQT_DBusData::fromUInt32( getpid() ); + params << TQT_DBusData::fromUInt32(getpid()); TQT_DBusMessage reply = managerIface.sendWithReply("GetSessionByPID", params); - if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1 ) { + if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) + { systemdSessionPath = reply[0].toObjectPath(); } } // wather for systemd session signals - if( systemdSessionPath.isValid() ) { + if (systemdSessionPath.isValid()) + { systemdSession = new TQT_DBusProxy(SYSTEMD_LOGIN1_SERVICE, systemdSessionPath, SYSTEMD_LOGIN1_SESSION_IFACE, dBusConn); - TQObject::connect(systemdSession, TQT_SIGNAL(dbusSignal(const TQT_DBusMessage&)), - this, TQT_SLOT(handleDBusSignal(const TQT_DBusMessage&))); + TQObject::connect(systemdSession, TQ_SIGNAL(dbusSignal(const TQT_DBusMessage&)), + this, TQ_SLOT(handleDBusSignal(const TQT_DBusMessage&))); } return; } } -/*! - * This function handles D-Bus service unregistering - */ -void SaverEngine::onDBusServiceUnregistered(const TQString& service) { - if( service == SYSTEMD_LOGIN1_SERVICE ) { - if( systemdSession ) { +// This function handles D-Bus service unregistering +void SaverEngine::onDBusServiceUnregistered(const TQString& service) +{ + if (service == SYSTEMD_LOGIN1_SERVICE) + { + if (systemdSession) + { delete systemdSession; - systemdSession = 0; + systemdSession = nullptr; } return; } } -/*! - * This function handles signals from the D-Bus daemon. - */ -void SaverEngine::handleDBusSignal(const TQT_DBusMessage& msg) { +// This function handles signals from the D-Bus daemon. +void SaverEngine::handleDBusSignal(const TQT_DBusMessage& msg) +{ // dbus terminated - if( msg.path() == DBUS_PATH_LOCAL - && msg.interface() == DBUS_INTERFACE_LOCAL - && msg.member() == "Disconnected" ) { + if (msg.path() == DBUS_PATH_LOCAL && msg.interface() == DBUS_INTERFACE_LOCAL && + msg.member() == "Disconnected") + { dBusClose(); - TQTimer::singleShot(1000, this, TQT_SLOT(dBusReconnect())); + TQTimer::singleShot(1000, this, TQ_SLOT(dBusReconnect())); return; } // service registered / unregistered - if( msg.path() == DBUS_PATH_DBUS - && msg.interface() == DBUS_INTERFACE_DBUS - && msg.member() == "NameOwnerChanged" ) { - if( msg[1].toString().isEmpty() ) { + if (msg.path() == DBUS_PATH_DBUS && msg.interface() == DBUS_INTERFACE_DBUS && + msg.member() == "NameOwnerChanged") + { + if (msg[1].toString().isEmpty()) + { // old-owner is empty onDBusServiceRegistered(msg[0].toString()); } - if( msg[2].toString().isEmpty() ) { + if (msg[2].toString().isEmpty()) + { // new-owner is empty onDBusServiceUnregistered(msg[0].toString()); } @@ -855,69 +683,367 @@ void SaverEngine::handleDBusSignal(const TQT_DBusMessage& msg) { } // systemd signal Lock() - if( systemdSession && systemdSession->canSend() - && msg.path() == systemdSession->path() - && msg.interface() == SYSTEMD_LOGIN1_SESSION_IFACE - && msg.member() == "Lock") { + if (systemdSession && systemdSession->canSend() && msg.path() == systemdSession->path() && + msg.interface() == SYSTEMD_LOGIN1_SESSION_IFACE && msg.member() == "Lock") + { lockScreen(); return; } // systemd signal Unlock() - if( systemdSession && systemdSession->canSend() - && msg.path() == systemdSession->path() - && msg.interface() == SYSTEMD_LOGIN1_SESSION_IFACE - && msg.member() == "Unlock") { + if (systemdSession && systemdSession->canSend() && msg.path() == systemdSession->path() && + msg.interface() == SYSTEMD_LOGIN1_SESSION_IFACE && msg.member() == "Unlock") + { // unlock? return; } } -bool SaverEngine::waitForLockProcessStart() { - sigset_t new_mask; - sigset_t empty_mask; - sigemptyset(&empty_mask); +void SaverEngine::lockScreenAndDoNewSession() +{ + mNewVTAfterLockEngage = true; + lockScreen(); +} + +void SaverEngine::lockScreenAndSwitchSession(int vt) +{ + mSwitchVTAfterLockEngage = vt; + lockScreen(); +} + +SaverEngineEventHandler::SaverEngineEventHandler(SaverEngine *engine) : + m_state(Waiting), m_saverProcessReady(false), m_lockProcessRestarting(false), + m_terminationRequest(false), m_saverEngine(engine), m_SAKProcess(nullptr) +{ + connect(&m_lockProcess, TQ_SIGNAL(processExited(TDEProcess*)), + this, TQ_SLOT(slotLockProcessExited())); +} + +void SaverEngineEventHandler::terminateLockProcess() +{ + if (m_state == Waiting) + { + kill(m_lockProcess.pid(), SIGKILL); + } + m_lockProcess.detach(); // don't kill it if we crash +} + +void SaverEngineEventHandler::lockCompleted() +{ + kdDebug(1204) << "SaverEngineEventHandler: lock completed" << endl; - // ensure that SIGCHLD is not subject to a race condition - sigemptyset(&new_mask); - sigaddset(&new_mask, SIGCHLD); + if (m_state == Waiting) + { + return; + } - pthread_sigmask(SIG_BLOCK, &new_mask, NULL); - while ((mLockProcess.isRunning()) && (!mSaverProcessReady)) { - // wait for any signal(s) to arrive - sigsuspend(&empty_mask); + m_state = Waiting; + if (trinity_lockeng_sak_available) + { + startSAKProcess(); } - pthread_sigmask(SIG_UNBLOCK, &new_mask, NULL); + TQTimer::singleShot(0, m_saverEngine, TQ_SLOT(stopLockProcessGUI())); +} - return mLockProcess.isRunning(); +void SaverEngineEventHandler::lockFullyActivated() +{ + m_state = Saving; + TQTimer::singleShot(0, m_saverEngine, TQ_SLOT(lockProcessFullyActivatedGUI())); } -bool SaverEngine::waitForLockEngage() { - sigset_t empty_mask; - sigemptyset(&empty_mask); +void SaverEngineEventHandler::lockReady() +{ + m_saverProcessReady = true; +} - // wait for SIGUSR1, SIGUSR2, SIGTTIN - while ((mLockProcess.isRunning()) && (mState != Waiting) && (mState != Saving)) { - // wait for any signal(s) to arrive - sigsuspend(&empty_mask); +void SaverEngineEventHandler::lockScreen(bool dcop) +{ + if (m_lockProcessRestarting) + { + kdDebug(1204) << "SaverEngineEventHandler: lock process is restarting, can't handle lock request" << endl; + return; } - return mLockProcess.isRunning(); + bool ok = true; + if (m_state == Waiting) + { + ok = activateSaverOrLock(ForceLock); + // It takes a while for kdesktop_lock to start and lock the screen. + // Therefore delay the DCOP call until it tells kdesktop that the locking is in effect. + // This is done only for --forcelock . + if (ok && m_state != Saving) + { + if (dcop) + { + TQTimer::singleShot(0, m_saverEngine, TQ_SLOT(lockScreenGUI())); + } + } + } } -void SaverEngine::lockScreenAndDoNewSession() { - mNewVTAfterLockEngage = true; - lockScreen(); +void SaverEngineEventHandler::saveScreen() +{ + if (m_lockProcessRestarting) + { + kdDebug(1204) << "SaverEngineEventHandler: lock process is restarting, can't handle save request" << endl; + return; + } + + if (m_state == Waiting) + { + activateSaverOrLock(DefaultLock); + } } -void SaverEngine::lockScreenAndSwitchSession(int vt) { - mSwitchVTAfterLockEngage = vt; - lockScreen(); +void SaverEngineEventHandler::slotLockProcessExited() +{ + // Clean up status after the lock process has exited + lockCompleted(); + + m_lockProcessRestarting = true; + + bool abnormalExit = false; + if (!m_lockProcess.normalExit()) + { + abnormalExit = true; + } + else if (m_lockProcess.exitStatus() != 0) + { + abnormalExit = true; + } + if (m_terminationRequest) + { + abnormalExit = false; + m_terminationRequest = false; + } + + // Restart the lock process. This call blocks till + // the lock process has restarted. + restartLockProcess(); + + if (abnormalExit) + { + // Possible hacking attempt detected, try to relaunch the saver with force lock + m_state = Waiting; + if (!activateSaverOrLock(ForceLock)) + { + TQTimer::singleShot(0, m_saverEngine, TQ_SLOT(terminateTDESession())); + } + } + m_lockProcessRestarting = false; +} + +/* + * Start or restart the lock process. + * On the very first invocation, launch the SAK process if required and + * auto lock the screen if the option has been enabled in the configuration. + */ +bool SaverEngineEventHandler::restartLockProcess() +{ + static bool firstStart = true; + + bool autoLoginEnable = false; + bool autoLoginLocked = false; + if (firstStart) + { + firstStart = false; + + // Create SAK process only if SAK is enabled + struct stat st; + TDESimpleConfig *config; + if (stat(KDE_CONFDIR "/tdm/tdmdistrc" , &st) == 0) + { + config = new TDESimpleConfig(TQString::fromLatin1(KDE_CONFDIR "/tdm/tdmdistrc")); + } + else + { + config = new TDESimpleConfig(TQString::fromLatin1(KDE_CONFDIR "/tdm/tdmrc")); + } + config->setGroup("X-:*-Greeter"); + bool useSAKProcess = false; +#ifdef BUILD_TSAK + useSAKProcess = config->readBoolEntry("UseSAK", false) && KDesktopSettings::useTDESAK(); +#endif + if (useSAKProcess) + { + startSAKProcess(); + } + + // autolock the desktop if required + config->setGroup("X-:0-Core"); + autoLoginEnable = config->readBoolEntry("AutoLoginEnable", false); + autoLoginLocked = config->readBoolEntry("AutoLoginLocked", false); + delete config; + } + + // (Re)start the lock process + if (!m_lockProcess.isRunning()) + { + m_lockProcess.clearArguments(); + TQString path = TDEStandardDirs::findExe("kdesktop_lock"); + if (path.isEmpty()) + { + kdDebug(1204) << "Can't find kdesktop_lock!" << endl; + return false; + } + m_lockProcess << path; + m_lockProcess << TQString("--internal") << TQString("%1").arg(getpid()); + + m_saverProcessReady = false; + if (!m_lockProcess.start()) + { + kdDebug(1204) << "Failed to start kdesktop_lock!" << endl; + return false; + } + // Wait for the lock process to signal that it is ready + sigset_t empty_mask; + sigemptyset(&empty_mask); + while (!m_saverProcessReady) + { + sigsuspend(&empty_mask); + } + if (!m_lockProcess.isRunning()) + { + kdDebug(1204) << "Failed to initialize kdesktop_lock (unexpected termination)!" << endl; + return false; + } + } + + if (autoLoginEnable && autoLoginLocked) + { + m_lockProcess.kill(SIGTTOU); + m_lockProcess.kill(SIGUSR1); + } + return true; +} + +// Start the screen saver or lock screen +bool SaverEngineEventHandler::activateSaverOrLock(LockType lock_type) +{ + if (m_state == Saving) + { + return true; + } + + kdDebug(1204) << "SaverEngineEventHandler: starting saver" << endl; + m_state = Preparing; + if (m_SAKProcess) + { + m_SAKProcess->kill(SIGTERM); + } + + m_saverEngine->enableExports(); + if (!restartLockProcess()) + { + m_state = Waiting; + return false; + } + + switch (lock_type) + { + case ForceLock: + m_lockProcess.kill(SIGUSR1); // Request forcelock + break; + case DontLock: + m_lockProcess.kill(SIGUSR2); // Request dontlock + break; + case SecureDialog: + m_lockProcess.kill(SIGWINCH); // Request secure dialog + break; + default: + break; + } + + if (m_saverEngine->mBlankOnly) + { + m_lockProcess.kill(SIGTTIN); // Request blanking + } + + int ret = m_lockProcess.kill(SIGTTOU); // Start lock + if (!ret) + { + m_state = Waiting; + return false; + } + m_state = Engaging; + + // Ask to the GUI thread to activate X11 saver + TQTimer::singleShot(0, m_saverEngine, TQ_SLOT(activateSaverOrLockGUI())); + + return true; +} + +// Stop the screen saver. +void SaverEngineEventHandler::stopLockProcess() +{ + if (m_state == Waiting) + { + return; + } + + kdDebug(1204) << "SaverEngineEventHandler: stopping lock process" << endl; + + m_terminationRequest = true; + m_lockProcess.kill(); + m_state = Waiting; + + // Ask to the GUI thread to stop the X11 saver + TQTimer::singleShot(0, m_saverEngine, TQ_SLOT(stopLockProcessGUI())); } -void SaverEngineThreadHelperObject::terminateThread() { - TQEventLoop* eventLoop = TQApplication::eventLoop(); - if (eventLoop) { +void SaverEngineEventHandler::startSAKProcess() +{ + if (!m_SAKProcess) + { + m_SAKProcess = new TDEProcess; + *m_SAKProcess << "tdmtsak"; + connect(m_SAKProcess, TQ_SIGNAL(processExited(TDEProcess*)), this, TQ_SLOT(slotSAKProcessExited())); + } + if (!m_SAKProcess->isRunning()) + { + m_SAKProcess->start(); + } +} + +void SaverEngineEventHandler::slotSAKProcessExited() +{ + if (!m_SAKProcess) + { + tqWarning("[kdesktop] SAK process does not exist. Something went wrong. Ignoring."); + return; + } + + int retcode = m_SAKProcess->exitStatus(); + if (retcode && m_SAKProcess->normalExit()) + { + trinity_lockeng_sak_available = false; + tqWarning("[kdesktop] SAK driven secure dialog is not available for use (retcode %d). " + "Check tdmtsak for proper functionality.", retcode); + } + + if (m_state == Preparing) + { + return; + } + + if (m_SAKProcess->normalExit() && trinity_lockeng_sak_available) + { + if (m_state == Waiting) + { + activateSaverOrLock(SecureDialog); + } + else + { + m_lockProcess.kill(SIGHUP); + } + } +} + +void SaverEngineEventHandler::terminateThread() +{ + TQEventLoop *eventLoop = TQApplication::eventLoop(); + if (eventLoop) + { eventLoop->exit(0); } } diff --git a/kdesktop/lockeng.h b/kdesktop/lockeng.h index 166d6b40e..11806e73c 100644 --- a/kdesktop/lockeng.h +++ b/kdesktop/lockeng.h @@ -1,6 +1,5 @@ -//=========================================================================== // -// This file is part of the KDE project +// This file is part of the TDE project // // Copyright (c) 1999 Martin R. Jones <mjones@kde.org> // @@ -8,9 +7,8 @@ #ifndef __LOCKENG_H__ #define __LOCKENG_H__ -#include <tqwidget.h> #include <tqthread.h> -#include <kprocess.h> +#include <tdeprocess.h> #include <tqvaluevector.h> #include "KScreensaverIface.h" #include "xautolock.h" @@ -18,32 +16,54 @@ #include <tqdbusconnection.h> +#ifdef WITH_TDEHWLIB +class TDECryptographicCardDevice; +#else +#define TDECryptographicCardDevice void +#endif + +/** + * Screen saver engine. Handles communication with the lock process. + * The engine is split into two parts, the 'SaverEngine' running in the GUI thread and + * the 'SaverEngineEventHandler' running in a separate thread and eventloop. + * The 'SaverEngine' handles communication with X11, DCOP and DBUS while the + * 'SaverEngineEventHandler' handles communication with the actual lock process. + * Several actions require cooperation of the two parts, so in various methods + * there will be inter-thread calls (using timers or by emitting signals) to + * trigger the other side remaining logic. + * This complex design is necessary to avoid blocking the main GUI application event loop, + * which has several tasks to manage and therefore can't affort to wait in a suspended state. + * This was previously leading to deadlock when DCOP calls where executed on the secondary + * thread/eventloop, for example when changing desktop while the lock process was restarting. + */ + class DCOPClientTransaction; class TQT_DBusMessage; class TQT_DBusProxy; +class SaverEngineEventHandler; -class SaverEngineThreadHelperObject : public TQObject +// Type of lock screen +enum LockType : int { - Q_OBJECT - -public slots: - void terminateThread(); - void slotLockProcessWaiting(); - void slotLockProcessFullyActivated(); + DontLock = 0, + DefaultLock, + ForceLock, + SecureDialog +}; -signals: - void lockProcessWaiting(); - void lockProcessFullyActivated(); +enum SaverState +{ + Waiting, + Preparing, + Engaging, + Saving }; -//=========================================================================== -/** - * Screen saver engine. Handles screensaver window, starting screensaver - * hacks, and password entry. - */ -class SaverEngine : public TQWidget, public KScreensaverIface +class SaverEngine : public TQObject, public KScreensaverIface { - Q_OBJECT + friend class SaverEngineEventHandler; + + TQ_OBJECT public: SaverEngine(); ~SaverEngine(); @@ -95,76 +115,52 @@ public: */ virtual void saverLockReady(); - /** - * @internal - */ void lockScreen(bool DCOP = false); - /** - * Called by KDesktop to wait for saver engage - * @internal - */ - bool waitForLockEngage(); - - /** - * @internal - */ void lockScreenAndDoNewSession(); - - /** - * @internal - */ void lockScreenAndSwitchSession(int vt); + void enableExports(); // Enable wallpaper exports + signals: - void terminateHelperThread(); - void asyncLock(); + void activateSaverOrLockSignal(LockType lock_type); + void lockScreenSignal(bool); + void terminateEventHandlerThread(); public slots: - void slotLockProcessReady(); - void lockProcessWaiting(); - void lockProcessFullyActivated(); void handleDBusSignal(const TQT_DBusMessage&); + void terminateTDESession(); protected slots: void idleTimeout(); - void lockProcessExited(); private slots: - void handleSecureDialog(); - void slotSAKProcessExited(); - - /** - * Enable wallpaper exports - */ - void enableExports(); - void recoverFromHackingAttempt(); - + void cryptographicCardInserted(TDECryptographicCardDevice*); + void cryptographicCardRemoved(TDECryptographicCardDevice*); + void cardStartupTimeout(); bool dBusReconnect(); + // The following slots are invoked by corresponding methods named without the 'GUI' suffix + // in 'SaverEngineEventHandler' to complete the remaining X11 part of the actions + void activateSaverOrLockGUI(); + void lockProcessFullyActivatedGUI(); + void lockScreenGUI(); + void stopLockProcessGUI(); + private: - bool restartDesktopLockProcess(); void dBusClose(); bool dBusConnect(); void onDBusServiceRegistered(const TQString&); void onDBusServiceUnregistered(const TQString&); protected: - enum SaverState { Waiting, Preparing, Engaging, Saving }; - enum LockType { DontLock, DefaultLock, ForceLock, SecureDialog }; - bool startLockProcess( LockType lock_type ); - bool waitForLockProcessStart(); - void stopLockProcess(); - bool handleKeyPress(XKeyEvent *xke); void processLockTransactions(); xautolock_corner_t applyManualSettings(int); protected: bool mEnabled; - SaverState mState; XAutoLock *mXAutoLock; - TDEProcess mLockProcess; int mTimeout; // the original X screensaver parameters @@ -173,25 +169,60 @@ protected: int mXBlanking; int mXExposures; - bool mBlankOnly; // only use the blanker, not the defined saver TQValueVector< DCOPClientTransaction* > mLockTransactions; public: - SaverEngineThreadHelperObject* m_threadHelperObject; + bool mBlankOnly; // only use the blanker, not the defined saver // protected + SaverEngineEventHandler *m_saverEngineEventHandler; private: - TQEventLoopThread* m_helperThread; - sigset_t mThreadBlockSet; - TDEProcess* mSAKProcess; - bool mTerminationRequested; - bool mSaverProcessReady; + TQEventLoopThread* m_eventHandlerThread; bool mNewVTAfterLockEngage; + bool mValidCryptoCardInserted; int mSwitchVTAfterLockEngage; struct sigaction mSignalAction; TQT_DBusConnection dBusConn; - TQT_DBusProxy* dBusLocal; - TQT_DBusProxy* dBusWatch; - TQT_DBusProxy* systemdSession; + TQT_DBusProxy *dBusLocal; + TQT_DBusProxy *dBusWatch; + TQT_DBusProxy *systemdSession; +}; + +class SaverEngineEventHandler : public TQObject +{ + TQ_OBJECT + +public: + SaverEngineEventHandler(SaverEngine *engine); + + SaverState getState() const { return m_state; } + + void lockCompleted(); + void lockFullyActivated(); + void lockReady(); + void terminateLockProcess(); + +public slots: + bool activateSaverOrLock(LockType lock_type); + void lockScreen(bool DCOP = false); + bool restartLockProcess(); + void saveScreen(); + void stopLockProcess(); + void terminateThread(); + +protected slots: + void slotLockProcessExited(); + void slotSAKProcessExited(); + +protected: + void startSAKProcess(); + + bool m_saverProcessReady; + bool m_lockProcessRestarting; + bool m_terminationRequest; + SaverState m_state; + SaverEngine *m_saverEngine; + TDEProcess *m_SAKProcess; + TDEProcess m_lockProcess; }; #endif diff --git a/kdesktop/main.cpp b/kdesktop/main.cpp index b54c03cb7..0465068b6 100644 --- a/kdesktop/main.cpp +++ b/kdesktop/main.cpp @@ -18,13 +18,13 @@ */ #include <config.h> -#include <kuniqueapplication.h> +#include <tdeuniqueapplication.h> #include <tdelocale.h> #include <dcopclient.h> #include <tdeaboutdata.h> #include <tdecmdlineargs.h> #include <kopenwith.h> -#include <kcrash.h> +#include <tdecrash.h> #include <kdebug.h> #include <tdeglobalsettings.h> #include <tdeglobal.h> @@ -43,7 +43,7 @@ #include <fcntl.h> #include <stdlib.h> -#if defined(Q_WS_X11) && defined(HAVE_XRENDER) && TQT_VERSION >= 0x030300 +#if defined(TQ_WS_X11) && defined(HAVE_XRENDER) && TQT_VERSION >= 0x030300 #define COMPOSITE #endif @@ -71,7 +71,7 @@ static TDECmdLineOptions options[] = }; bool argb_visual = false; -KDesktopApp *myApp = NULL; +KDesktopApp *myApp = nullptr; // ----------------------------------------------------------------------------- @@ -94,8 +94,8 @@ static void signalHandler(int sigId) // try to cleanup all windows signal(SIGTERM, SIG_DFL); // next one kills signal(SIGHUP, SIG_DFL); // next one kills - if (kapp) - kapp->quit(); // turn catchable signals into clean shutdown + if (tdeApp) + tdeApp->quit(); // turn catchable signals into clean shutdown } void KDesktop::slotUpAndRunning() @@ -105,7 +105,7 @@ void KDesktop::slotUpAndRunning() TDECrash::setEmergencySaveFunction(crashHandler); // Try to restart on crash } -extern "C" KDE_EXPORT int kdemain( int argc, char **argv ) +extern "C" TDE_EXPORT int kdemain( int argc, char **argv ) { //setup signal handling signal(SIGTERM, signalHandler); @@ -184,7 +184,7 @@ extern "C" KDE_EXPORT int kdemain( int argc, char **argv ) TDECmdLineArgs::init( argc, argv, &aboutData ); TDECmdLineArgs::addCmdLineOptions( options ); - if (!KUniqueApplication::start()) { + if (!TDEUniqueApplication::start()) { fprintf(stderr, "kdesktop is already running!\n"); exit(0); } @@ -247,11 +247,11 @@ extern "C" KDE_EXPORT int kdemain( int argc, char **argv ) *qt_no_foreign_hack = true; // else argb_visual = false ... ? *shrug* if( argb_visual ) - myApp = new KDesktopApp( dpy, Qt::HANDLE( visual ), 0 ); + myApp = new KDesktopApp( dpy, TQt::HANDLE( visual ), 0 ); else XCloseDisplay( dpy ); } - if( myApp == NULL ) + if (!myApp) myApp = new KDesktopApp; #else myApp = new KDesktopApp; @@ -260,9 +260,6 @@ extern "C" KDE_EXPORT int kdemain( int argc, char **argv ) KDesktopSettings::instance(kdesktop_name + "rc"); - bool x_root_hack = args->isSet("x-root"); - bool wait_for_kded = args->isSet("waitforkded"); - // This MUST be created before any widgets are created SaverEngine saver; @@ -273,22 +270,21 @@ extern "C" KDE_EXPORT int kdemain( int argc, char **argv ) // Mark kdeskop as immutable if all of its config modules have been disabled if (!myApp->config()->isImmutable() && - kapp->authorizeControlModules(KRootWm::configModules()).isEmpty()) + tdeApp->authorizeControlModules(KRootWm::configModules()).isEmpty()) { myApp->config()->setReadOnly(true); myApp->config()->reparseConfiguration(); } - // for the KDE-already-running check in starttde - TDESelectionOwner kde_running( "_KDE_RUNNING", 0 ); - kde_running.claim( false ); + // for the TDE-already-running check in starttde + TDESelectionOwner tde_running( "_KDE_RUNNING", 0 ); + tde_running.claim( false ); + bool x_root_hack = args->isSet("x-root"); + bool wait_for_kded = args->isSet("waitforkded"); KDesktop desktop( &saver, x_root_hack, wait_for_kded ); args->clear(); - myApp->dcopClient()->setDefaultObject( "KDesktopIface" ); - - return myApp->exec(); } diff --git a/kdesktop/minicli.cpp b/kdesktop/minicli.cpp index 2029fda59..2ac8b3ecd 100644 --- a/kdesktop/minicli.cpp +++ b/kdesktop/minicli.cpp @@ -50,7 +50,7 @@ #include <dcopclient.h> #include <tdelocale.h> #include <tdemessagebox.h> -#include <kprocess.h> +#include <tdeprocess.h> #include <kcombobox.h> #include <klineedit.h> #include <tdeapplication.h> @@ -59,7 +59,7 @@ #include <krun.h> #include <twin.h> #include <tdesu/su.h> -#include <kstandarddirs.h> +#include <tdestandarddirs.h> #include <tdeconfig.h> #include <kiconloader.h> #include <kpushbutton.h> @@ -101,7 +101,7 @@ Minicli::Minicli( TQWidget *parent, const char *name) // Cancel button... m_dlg->pbCancel->setGuiItem ( KStdGuiItem::cancel() ); - if (!kapp->authorize("shell_access")) + if (!tdeApp->authorize("shell_access")) m_dlg->pbOptions->hide(); m_dlg->pbRun->setEnabled(!m_dlg->cbCommand->currentText().isEmpty()); @@ -131,34 +131,34 @@ Minicli::Minicli( TQWidget *parent, const char *name) m_pURLCompletion = new KURLCompletion(KURLCompletion::FileCompletion); m_pEXECompletion = new KURLCompletion(KURLCompletion::SystemExeCompletion); //m_pURLCompletion->setCompletionMode( TDEGlobalSettings::completionMode() ); - connect( m_pURLCompletion, TQT_SIGNAL( match(const TQString&) ), TQT_SLOT( slotMatch(const TQString&) )); - connect( m_pEXECompletion, TQT_SIGNAL( match(const TQString&) ), TQT_SLOT( slotEXEMatch(const TQString&) )); + connect( m_pURLCompletion, TQ_SIGNAL( match(const TQString&) ), TQ_SLOT( slotMatch(const TQString&) )); + connect( m_pEXECompletion, TQ_SIGNAL( match(const TQString&) ), TQ_SLOT( slotEXEMatch(const TQString&) )); // Main widget buttons... - connect( m_dlg->pbRun, TQT_SIGNAL(clicked()), this, TQT_SLOT(accept()) ); - connect( m_dlg->pbCancel, TQT_SIGNAL(clicked()), this, TQT_SLOT(reject()) ); - connect( m_dlg->pbOptions, TQT_SIGNAL(clicked()), TQT_SLOT(slotAdvanced()) ); - connect( m_parseTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotParseTimer()) ); + connect( m_dlg->pbRun, TQ_SIGNAL(clicked()), this, TQ_SLOT(accept()) ); + connect( m_dlg->pbCancel, TQ_SIGNAL(clicked()), this, TQ_SLOT(reject()) ); + connect( m_dlg->pbOptions, TQ_SIGNAL(clicked()), TQ_SLOT(slotAdvanced()) ); + connect( m_parseTimer, TQ_SIGNAL(timeout()), TQ_SLOT(slotParseTimer()) ); - connect( m_dlg->cbCommand, TQT_SIGNAL( textChanged( const TQString& ) ), - TQT_SLOT( slotCmdChanged(const TQString&) ) ); + connect( m_dlg->cbCommand, TQ_SIGNAL( textChanged( const TQString& ) ), + TQ_SLOT( slotCmdChanged(const TQString&) ) ); - connect( m_dlg->cbCommand, TQT_SIGNAL( returnPressed() ), - m_dlg->pbRun, TQT_SLOT( animateClick() ) ); + connect( m_dlg->cbCommand, TQ_SIGNAL( returnPressed() ), + m_dlg->pbRun, TQ_SLOT( animateClick() ) ); m_dlg->cbCommand->setHistoryEditorEnabled( true ); - connect( m_dlg->cbCommand, TQT_SIGNAL(removed( const TQString&) ), TQT_SLOT(saveConfig()) ); + connect( m_dlg->cbCommand, TQ_SIGNAL(removed( const TQString&) ), TQ_SLOT(saveConfig()) ); // Advanced group box... - connect(m_dlg->cbPriority, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotChangeScheduler(bool))); - connect(m_dlg->slPriority, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotPriority(int))); - connect(m_dlg->cbRealtime, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotRealtime(bool))); - connect(m_dlg->cbAppcomplete, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotAppcompleteToggled(bool))); - connect(m_dlg->cbAutocomplete, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotAutocompleteToggled(bool))); - connect(m_dlg->cbAutohistory, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotAutohistoryToggled(bool))); - connect(m_dlg->cbRunAsOther, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotChangeUid(bool))); - connect(m_dlg->leUsername, TQT_SIGNAL(lostFocus()), TQT_SLOT(updateAuthLabel())); - connect(m_dlg->cbRunInTerminal, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotTerminal(bool))); + connect(m_dlg->cbPriority, TQ_SIGNAL(toggled(bool)), TQ_SLOT(slotChangeScheduler(bool))); + connect(m_dlg->slPriority, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(slotPriority(int))); + connect(m_dlg->cbRealtime, TQ_SIGNAL(toggled(bool)), TQ_SLOT(slotRealtime(bool))); + connect(m_dlg->cbAppcomplete, TQ_SIGNAL(toggled(bool)), TQ_SLOT(slotAppcompleteToggled(bool))); + connect(m_dlg->cbAutocomplete, TQ_SIGNAL(toggled(bool)), TQ_SLOT(slotAutocompleteToggled(bool))); + connect(m_dlg->cbAutohistory, TQ_SIGNAL(toggled(bool)), TQ_SLOT(slotAutohistoryToggled(bool))); + connect(m_dlg->cbRunAsOther, TQ_SIGNAL(toggled(bool)), TQ_SLOT(slotChangeUid(bool))); + connect(m_dlg->leUsername, TQ_SIGNAL(lostFocus()), TQ_SLOT(updateAuthLabel())); + connect(m_dlg->cbRunInTerminal, TQ_SIGNAL(toggled(bool)), TQ_SLOT(slotTerminal(bool))); m_dlg->slPriority->setValue(50); @@ -317,8 +317,8 @@ void Minicli::accept() if ( logout ) { - kapp->propagateSessionManager(); - kapp->requestShutDown(); + tdeApp->propagateSessionManager(); + tdeApp->requestShutDown(); } if ( lock ) { @@ -326,7 +326,7 @@ void Minicli::accept() int kicker_screen_number = tqt_xscreen(); if ( kicker_screen_number ) appname.sprintf("kdesktop-screen-%d", kicker_screen_number); - kapp->dcopClient()->send(appname, "KScreensaverIface", "lock()", TQString("")); + tdeApp->dcopClient()->send(appname, "KScreensaverIface", "lock()", TQString("")); } } @@ -375,7 +375,7 @@ void Minicli::reset() void Minicli::keyPressEvent( TQKeyEvent* e ) { - if ( e->key() == Qt::Key_Escape ) + if ( e->key() == TQt::Key_Escape ) { e->accept(); m_dlg->pbCancel->animateClick(); @@ -437,7 +437,7 @@ int Minicli::runCommand() kdDebug (1207) << "Use terminal ? " << useTerminal << endl; - if (!kapp->authorize("shell_access")) + if (!tdeApp->authorize("shell_access")) useTerminal = false; if( needsTDEsu() ) @@ -483,7 +483,7 @@ int Minicli::runCommand() proc_checkpwd.setScheduler(m_iScheduler); } - if (proc_checkpwd.checkInstall(m_dlg->lePassword->password()) != 0) + if (proc_checkpwd.checkInstall(m_dlg->lePassword->password().local8Bit()) != 0) { KMessageBox::sorry(this, i18n("Incorrect password; please try again.")); return 1; @@ -534,7 +534,7 @@ int Minicli::runCommand() sigprocmask(SIG_BLOCK, &sset, 0L); proc.setTerminal(true); proc.setErase(true); - _exit(proc.exec(m_dlg->lePassword->password())); + _exit(proc.exec(m_dlg->lePassword->password().local8Bit())); return 0; } else @@ -585,7 +585,7 @@ int Minicli::runCommand() // fall-through to shell case case KURIFilterData::SHELL: { - if (kapp->authorize("shell_access")) + if (tdeApp->authorize("shell_access")) { exec = cmd; @@ -651,7 +651,7 @@ void Minicli::notifyServiceStarted(KService::Ptr service) TQDataStream stream(params, IO_WriteOnly); stream << "minicli" << service->storageId(); kdDebug() << "minicli appLauncher dcop signal: " << service->storageId() << endl; - TDEApplication::kApplication()->dcopClient()->emitDCOPSignal("appLauncher", + tdeApp->dcopClient()->emitDCOPSignal("appLauncher", "serviceStartedByStorageId(TQString,TQString)", params); } @@ -877,7 +877,7 @@ void Minicli::setIcon () { TQBitmap mask = *icon.mask(); bitBlt( &mask, x, y, - overlay.mask() ? TQT_TQPIXMAP(const_cast<TQBitmap *>(overlay.mask())) : &overlay, + overlay.mask() ? const_cast<TQBitmap *>(overlay.mask()) : &overlay, 0, 0, overlay.width(), overlay.height(), overlay.mask() ? OrROP : SetROP ); icon.setMask(mask); diff --git a/kdesktop/minicli.h b/kdesktop/minicli.h index 9d92825c7..c3974a13b 100644 --- a/kdesktop/minicli.h +++ b/kdesktop/minicli.h @@ -46,7 +46,7 @@ class KURIFilterData; class Minicli : public KDialog { - Q_OBJECT + TQ_OBJECT public: Minicli( TQWidget *parent=0, const char *name=0 ); diff --git a/kdesktop/pics/ksslogo.png b/kdesktop/pics/ksslogo.png Binary files differindex 466215dee..db984eedf 100644..100755 --- a/kdesktop/pics/ksslogo.png +++ b/kdesktop/pics/ksslogo.png diff --git a/kdesktop/pics/splash.png b/kdesktop/pics/splash.png Binary files differindex 1d5738697..52d76596f 100644..100755 --- a/kdesktop/pics/splash.png +++ b/kdesktop/pics/splash.png diff --git a/kdesktop/pixmapserver.cpp b/kdesktop/pixmapserver.cpp index 56224f37a..b60942277 100644 --- a/kdesktop/pixmapserver.cpp +++ b/kdesktop/pixmapserver.cpp @@ -39,7 +39,7 @@ KPixmapServer::KPixmapServer() : TQWidget(0L, "shpixmap comm window") { - kapp->installX11EventFilter(this); + tdeApp->installX11EventFilter(this); pixmap = XInternAtom(tqt_xdisplay(), "PIXMAP", false); } diff --git a/kdesktop/pixmapserver.h b/kdesktop/pixmapserver.h index a0eadcdd6..661d531ad 100644 --- a/kdesktop/pixmapserver.h +++ b/kdesktop/pixmapserver.h @@ -24,7 +24,7 @@ struct KPixmapInode { - Qt::HANDLE handle; + TQt::HANDLE handle; Atom selection; }; @@ -37,7 +37,7 @@ struct KPixmapData struct TDESelectionInode { - Qt::HANDLE handle; + TQt::HANDLE handle; TQString name; }; @@ -50,7 +50,7 @@ struct TDESelectionInode */ class KPixmapServer: public TQWidget { - Q_OBJECT + TQ_OBJECT public: KPixmapServer(); diff --git a/kdesktop/startupid.cpp b/kdesktop/startupid.cpp index 4027b7e9a..2aeac904a 100644 --- a/kdesktop/startupid.cpp +++ b/kdesktop/startupid.cpp @@ -54,18 +54,18 @@ StartupId::StartupId( TQWidget* parent, const char* name ) XWindowAttributes attrs; XGetWindowAttributes( tqt_xdisplay(), tqt_xrootwin(), &attrs); XSelectInput( tqt_xdisplay(), tqt_xrootwin(), attrs.your_event_mask | SubstructureNotifyMask); - kapp->installX11EventFilter( this ); + tdeApp->installX11EventFilter( this ); } - connect( &update_timer, TQT_SIGNAL( timeout()), TQT_SLOT( update_startupid())); + connect( &update_timer, TQ_SIGNAL( timeout()), TQ_SLOT( update_startupid())); connect( &startup_info, - TQT_SIGNAL( gotNewStartup( const TDEStartupInfoId&, const TDEStartupInfoData& )), - TQT_SLOT( gotNewStartup( const TDEStartupInfoId&, const TDEStartupInfoData& ))); + TQ_SIGNAL( gotNewStartup( const TDEStartupInfoId&, const TDEStartupInfoData& )), + TQ_SLOT( gotNewStartup( const TDEStartupInfoId&, const TDEStartupInfoData& ))); connect( &startup_info, - TQT_SIGNAL( gotStartupChange( const TDEStartupInfoId&, const TDEStartupInfoData& )), - TQT_SLOT( gotStartupChange( const TDEStartupInfoId&, const TDEStartupInfoData& ))); + TQ_SIGNAL( gotStartupChange( const TDEStartupInfoId&, const TDEStartupInfoData& )), + TQ_SLOT( gotStartupChange( const TDEStartupInfoId&, const TDEStartupInfoData& ))); connect( &startup_info, - TQT_SIGNAL( gotRemoveStartup( const TDEStartupInfoId&, const TDEStartupInfoData& )), - TQT_SLOT( gotRemoveStartup( const TDEStartupInfoId& ))); + TQ_SIGNAL( gotRemoveStartup( const TDEStartupInfoId&, const TDEStartupInfoData& )), + TQ_SLOT( gotRemoveStartup( const TDEStartupInfoId& ))); } StartupId::~StartupId() @@ -129,10 +129,10 @@ bool StartupId::x11Event( XEvent* e ) if( startups.count() == 0 ) start_startupid( KDE_STARTUP_ICON ); // 60(?) sec timeout - shouldn't be hopefully needed anyway, ksmserver should have it too - TQTimer::singleShot( 60000, this, TQT_SLOT( finishKDEStartup())); + TQTimer::singleShot( 60000, this, TQ_SLOT( finishKDEStartup())); } else if( strcmp( s, "session ready" ) == 0 && kde_startup_status < StartupDone ) - TQTimer::singleShot( 2000, this, TQT_SLOT( finishKDEStartup())); + TQTimer::singleShot( 2000, this, TQ_SLOT( finishKDEStartup())); } return false; } @@ -140,7 +140,7 @@ bool StartupId::x11Event( XEvent* e ) void StartupId::finishKDEStartup() { kde_startup_status = StartupDone; - kapp->removeX11EventFilter( this ); + tdeApp->removeX11EventFilter( this ); if( startups.count() == 0 ) stop_startupid(); } @@ -176,7 +176,7 @@ void StartupId::start_startupid( const TQString& icon_P ) { const TQColor startup_colors[ StartupId::NUM_BLINKING_PIXMAPS ] - = { Qt::black, Qt::darkGray, Qt::lightGray, Qt::white, Qt::white }; + = { TQt::black, TQt::darkGray, TQt::lightGray, TQt::white, TQt::white }; TQPixmap icon_pixmap = TDEGlobal::iconLoader()->loadIcon( icon_P, TDEIcon::Small, 0, diff --git a/kdesktop/startupid.h b/kdesktop/startupid.h index 893d0b8db..27345d598 100644 --- a/kdesktop/startupid.h +++ b/kdesktop/startupid.h @@ -34,7 +34,7 @@ class TQStyle; class StartupId : public TQWidget { - Q_OBJECT + TQ_OBJECT public: StartupId( TQWidget* parent = 0, const char* name = 0 ); virtual ~StartupId(); diff --git a/kdesktop/tdefileividesktop.cpp b/kdesktop/tdefileividesktop.cpp index bf9aa074c..464b5490d 100644 --- a/kdesktop/tdefileividesktop.cpp +++ b/kdesktop/tdefileividesktop.cpp @@ -144,10 +144,10 @@ void KFileIVIDesktop::drawShadowedText( TQPainter *p, const TQColorGroup &cg ) int textX; if (drawRoundedRect == true) - textX = textRect( FALSE ).x() + 4; + textX = textRect( false ).x() + 4; else - textX = textRect( FALSE ).x() + 2; - int textY = textRect( FALSE ).y(); + textX = textRect( false ).x() + 2; + int textY = textRect( false ).y(); int align = ((TDEIconView *) iconView())->itemTextPos() == TQIconView::Bottom ? AlignHCenter : AlignAuto; // FIXME @@ -222,11 +222,11 @@ TQImage *KFileIVIDesktop::buildShadow( TQPainter *p, const int align, TQPainter pixPainter; int spread = shadowThickness(); - TQPixmap textPixmap(textRect( FALSE ).width() + spread * 2 + 2, - textRect( FALSE ).height() + spread * 2 + 2); + TQPixmap textPixmap(textRect( false ).width() + spread * 2 + 2, + textRect( false ).height() + spread * 2 + 2); textPixmap.fill(TQColor(0,0,0)); - textPixmap.setMask( textPixmap.createHeuristicMask(TRUE) ); + textPixmap.setMask( textPixmap.createHeuristicMask(true) ); pixPainter.begin(&textPixmap); pixPainter.setPen(white); // get the pen from the root painter diff --git a/kdesktop/tdefileividesktop.h b/kdesktop/tdefileividesktop.h index 46f77f636..0434a706e 100644 --- a/kdesktop/tdefileividesktop.h +++ b/kdesktop/tdefileividesktop.h @@ -33,7 +33,7 @@ /* * The dither flags used to display the shadow image */ -#define DITHER_FLAGS (Qt::DiffuseAlphaDither | Qt::ColorOnly | Qt::AvoidDither) +#define DITHER_FLAGS (TQt::DiffuseAlphaDither | TQt::ColorOnly | TQt::AvoidDither) class TQFont; diff --git a/kdesktop/xautolock.cpp b/kdesktop/xautolock.cpp index 3c7e62670..95de8f3d6 100644 --- a/kdesktop/xautolock.cpp +++ b/kdesktop/xautolock.cpp @@ -71,7 +71,7 @@ XAutoLock::XAutoLock() #endif if( !xautolock_useXidle && !xautolock_useMit ) { - kapp->installX11EventFilter( this ); + tdeApp->installX11EventFilter( this ); int (*oldHandler)(Display *, XErrorEvent *); oldHandler = XSetErrorHandler(catchFalseAlarms); XSync(tqt_xdisplay(), False ); diff --git a/kdesktop/xautolock.h b/kdesktop/xautolock.h index 5684ce6ef..a30405339 100644 --- a/kdesktop/xautolock.h +++ b/kdesktop/xautolock.h @@ -19,7 +19,7 @@ // class XAutoLock : public TQWidget { - Q_OBJECT + TQ_OBJECT public: XAutoLock(); ~XAutoLock(); |