create a setup mode for the kcm where the screensaver starts with plasma unlocked...
[kdebase.git] / workspace / krunner / lock / lockprocess.h
blobb1ec4f1955a7c24419857f602a7b81e51266d600
1 //===========================================================================
2 //
3 // This file is part of the KDE project
4 //
5 // Copyright 1999 Martin R. Jones <mjones@kde.org>
6 // Copyright 2003 Oswald Buddenhagen <ossi@kde.org>
7 // Copyright 2008 Chani Armitage <chanika@gmail.com>
8 //
10 #ifndef LOCKPROCESS_H
11 #define LOCKPROCESS_H
13 #include <KProcess>
15 #include <QWidget>
16 #include <QTimer>
17 #include <QStack>
18 #include <QList>
19 #include <QMessageBox>
20 #include <QPixmap>
22 #include <X11/Xlib.h>
23 #include <fixx11h.h>
25 class QDBusInterface;
26 class KLibrary;
28 struct KGreeterPluginInfo;
30 struct GreeterPluginHandle {
31 KLibrary *library;
32 KGreeterPluginInfo *info;
35 //===========================================================================
37 // Screen saver handling process. Handles screensaver window,
38 // starting screensaver hacks, and password entry.
40 class LockProcess
41 : public QWidget
43 Q_OBJECT
44 public:
45 explicit LockProcess(bool child_saver = false, bool useBlankOnly = false, bool plasmaSetupMode = false);
46 ~LockProcess();
48 bool lock();
50 bool defaultSave();
52 bool dontLock();
54 void setChildren(QList<int> children) { child_sockets = children; }
55 void setParent(int fd) { mParent = fd; }
57 void msgBox( QWidget *parent, QMessageBox::Icon type, const QString &txt );
58 int execDialog( QDialog* dlg );
60 public Q_SLOTS:
61 void quitSaver();
62 void preparePopup();
63 void cleanupPopup();
64 //dbus methods
65 /**
66 * bring up the password dialog with @param reason displayed instead of the usual "this session
67 * is locked" message.
68 * @return true if the password was entered correctly
69 * if this returns true, there is a grace period where the screensaver can be freely unlocked
70 * with the unlock method without re-entering the password.
72 Q_SCRIPTABLE bool checkPass(const QString &reason);
73 /**
74 * this will unlock and quit the screensaver, asking for a password first if necessary
76 Q_SCRIPTABLE void unlock();
77 /**
78 * immediately end the "free unlock" grace period; if the screen is locked, it will now require
79 * a password to unlock.
80 * this has no effect if the screen wasn't locked in the first place.
82 Q_SCRIPTABLE void endFreeUnlock();
84 protected:
85 virtual bool x11Event(XEvent *);
86 virtual void timerEvent(QTimerEvent *);
88 private Q_SLOTS:
89 void hackExited();
90 void signalPipeSignal();
91 bool startLock();
92 void suspend();
93 void checkDPMSActive();
94 void slotDeadTimePassed();
95 /**
96 * a new dbus service has come in
98 void newService(QString name);
99 /**
100 * set the winid of plasma's view
101 * so that we can control it
103 void setPlasmaView(uint id); //it's really a WId but qdbuscpp2xml is dumb
105 * tell plasma we're in idle mode
107 void deactivatePlasma();
108 void lockPlasma();
110 * immediately un-suppress the password dialog
111 * FIXME need a better name
113 void unSuppressUnlock();
115 private:
116 void configure();
117 void readSaver();
118 void createSaverWindow();
119 void hideSaverWindow();
120 void saveVRoot();
121 void setVRoot(Window win, Window rw);
122 void removeVRoot(Window win);
123 bool grabKeyboard();
124 bool grabMouse();
125 bool grabInput();
126 void ungrabInput();
127 void cantLock(const QString &reason);
128 bool startSaver();
129 void stopSaver();
130 bool startHack();
131 void stopHack();
132 bool startPlasma();
133 void stopPlasma();
134 void setupSignals();
136 * if the password dialog is not suppressed, this execs it
137 * if the dialog *is* suppressed we just restart the timer
138 * @return true iff the password was checked and is valid
140 bool checkPass();
141 void stayOnTop();
142 void lockXF86();
143 void unlockXF86();
144 void resume( bool force );
145 enum WindowType { IgnoreWindow = 0 /** regular window to be left below the saver */,
146 SimpleWindow = 1 /** simple popup that can't handle direct input */,
147 InputWindow = 2 /** annoying dialog that needs direct input */,
148 DefaultWindow = 6/** input window that's also the plasma view */
151 * @return the type of window, based on its X property
153 WindowType windowType(WId id);
155 static QVariant getConf(void *ctx, const char *key, const QVariant &dflt);
157 bool mLocked;
158 int mLockGrace;
159 int mPriority;
160 bool mBusy;
161 KProcess mHackProc;
162 KProcess mPlasmaProc;
163 QDBusInterface *mPlasmaDBus;
164 WId mPlasmaView;
165 bool mPlasmaEnabled;
166 bool mFreeUnlock;
167 QString mSaverExec;
168 QString mSaver;
169 bool mOpenGLVisual;
170 bool child_saver;
171 QList<int> child_sockets;
172 int mParent;
173 bool mUseBlankOnly;
174 bool mSuspended;
175 QTimer mSuspendTimer;
176 bool mVisibility;
177 bool mDPMSDepend;
178 QTimer mCheckDPMS;
179 QStack< QWidget* > mDialogs;
180 bool mRestoreXF86Lock;
181 bool mForbidden;
182 QStringList mPlugins, mPluginOptions;
183 QString mMethod;
184 GreeterPluginHandle greetPlugin;
185 QPixmap mSavedScreen;
186 int mAutoLogoutTimerId;
187 int mAutoLogoutTimeout;
188 bool mAutoLogout;
189 QTimer mSuppressUnlock;
190 int mSuppressUnlockTimeout;
191 QList<WId> mForeignWindows;
192 QList<WId> mForeignInputWindows;
195 #endif