|
Lines 16-21
Link Here
|
| 16 |
#include <kdebug.h> |
16 |
#include <kdebug.h> |
| 17 |
#include <klocale.h> |
17 |
#include <klocale.h> |
| 18 |
#include <qfile.h> |
18 |
#include <qfile.h> |
|
|
19 |
#include <dcopclient.h> |
| 19 |
#include <assert.h> |
20 |
#include <assert.h> |
| 20 |
|
21 |
|
| 21 |
#include "lockeng.h" |
22 |
#include "lockeng.h" |
|
Lines 85-96
SaverEngine::~SaverEngine()
Link Here
|
| 85 |
} |
86 |
} |
| 86 |
|
87 |
|
| 87 |
//--------------------------------------------------------------------------- |
88 |
//--------------------------------------------------------------------------- |
|
|
89 |
|
| 90 |
// This should be called only using DCOP. |
| 88 |
void SaverEngine::lock() |
91 |
void SaverEngine::lock() |
| 89 |
{ |
92 |
{ |
|
|
93 |
bool ok = true; |
| 90 |
if (mState == Waiting) |
94 |
if (mState == Waiting) |
| 91 |
{ |
95 |
{ |
| 92 |
startLockProcess( ForceLock ); |
96 |
ok = startLockProcess( ForceLock ); |
|
|
97 |
} |
| 98 |
// It takes a while for kdesktop_lock to start and lock the screen. |
| 99 |
// Therefore delay the DCOP call until it tells kdesktop that the locking is in effect. |
| 100 |
// This is done only for --forcelock . |
| 101 |
if( ok && mState != Saving ) |
| 102 |
{ |
| 103 |
DCOPClientTransaction* trans = kapp->dcopClient()->beginTransaction(); |
| 104 |
mLockTransactions.append( trans ); |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
void SaverEngine::processLockTransactions() |
| 109 |
{ |
| 110 |
for( QValueVector< DCOPClientTransaction* >::ConstIterator it = mLockTransactions.begin(); |
| 111 |
it != mLockTransactions.end(); |
| 112 |
++it ) |
| 113 |
{ |
| 114 |
QCString replyType = "void"; |
| 115 |
QByteArray arr; |
| 116 |
kapp->dcopClient()->endTransaction( *it, replyType, arr ); |
| 93 |
} |
117 |
} |
|
|
118 |
mLockTransactions.clear(); |
| 119 |
} |
| 120 |
|
| 121 |
void SaverEngine::saverLockReady() |
| 122 |
{ |
| 123 |
if( mState != Preparing ) |
| 124 |
{ |
| 125 |
kdDebug( 1204 ) << "Got unexpected saverReady()" << endl; |
| 126 |
} |
| 127 |
kdDebug( 1204 ) << "Saver Lock Ready" << endl; |
| 128 |
processLockTransactions(); |
| 94 |
} |
129 |
} |
| 95 |
|
130 |
|
| 96 |
//--------------------------------------------------------------------------- |
131 |
//--------------------------------------------------------------------------- |
|
Lines 105-111
void SaverEngine::save()
Link Here
|
| 105 |
//--------------------------------------------------------------------------- |
140 |
//--------------------------------------------------------------------------- |
| 106 |
void SaverEngine::quit() |
141 |
void SaverEngine::quit() |
| 107 |
{ |
142 |
{ |
| 108 |
if (mState == Saving) |
143 |
if (mState == Saving || mState == Preparing) |
| 109 |
{ |
144 |
{ |
| 110 |
stopLockProcess(); |
145 |
stopLockProcess(); |
| 111 |
} |
146 |
} |
|
Lines 213-224
void SaverEngine::setBlankOnly( bool bla
Link Here
|
| 213 |
// |
248 |
// |
| 214 |
// Start the screen saver. |
249 |
// Start the screen saver. |
| 215 |
// |
250 |
// |
| 216 |
void SaverEngine::startLockProcess( LockType lock_type ) |
251 |
bool SaverEngine::startLockProcess( LockType lock_type ) |
| 217 |
{ |
252 |
{ |
| 218 |
if (mState != Waiting) |
253 |
if (mState != Waiting) |
| 219 |
{ |
254 |
{ |
| 220 |
kdWarning(1204) << "SaverEngine::startSaver() saver already active" << endl; |
255 |
kdWarning(1204) << "SaverEngine::startSaver() saver already active" << endl; |
| 221 |
return; |
256 |
return true; |
| 222 |
} |
257 |
} |
| 223 |
|
258 |
|
| 224 |
kdDebug(1204) << "SaverEngine: starting saver" << endl; |
259 |
kdDebug(1204) << "SaverEngine: starting saver" << endl; |
|
Lines 233-239
void SaverEngine::startLockProcess( Lock
Link Here
|
| 233 |
if( path.isEmpty()) |
268 |
if( path.isEmpty()) |
| 234 |
{ |
269 |
{ |
| 235 |
kdDebug( 1204 ) << "Can't find kdesktop_lock!" << endl; |
270 |
kdDebug( 1204 ) << "Can't find kdesktop_lock!" << endl; |
| 236 |
return; |
271 |
return false; |
| 237 |
} |
272 |
} |
| 238 |
mLockProcess << path; |
273 |
mLockProcess << path; |
| 239 |
switch( lock_type ) |
274 |
switch( lock_type ) |
|
Lines 253-266
void SaverEngine::startLockProcess( Lock
Link Here
|
| 253 |
if (mLockProcess.start() == false ) |
288 |
if (mLockProcess.start() == false ) |
| 254 |
{ |
289 |
{ |
| 255 |
kdDebug( 1204 ) << "Failed to start kdesktop_lock!" << endl; |
290 |
kdDebug( 1204 ) << "Failed to start kdesktop_lock!" << endl; |
| 256 |
return; |
291 |
return false; |
| 257 |
} |
292 |
} |
| 258 |
|
293 |
|
| 259 |
mState = Saving; |
294 |
mState = Preparing; |
| 260 |
if (mXAutoLock) |
295 |
if (mXAutoLock) |
| 261 |
{ |
296 |
{ |
| 262 |
mXAutoLock->stop(); |
297 |
mXAutoLock->stop(); |
| 263 |
} |
298 |
} |
|
|
299 |
return true; |
| 264 |
} |
300 |
} |
| 265 |
|
301 |
|
| 266 |
//--------------------------------------------------------------------------- |
302 |
//--------------------------------------------------------------------------- |
|
Lines 284-289
void SaverEngine::stopLockProcess()
Link Here
|
| 284 |
{ |
320 |
{ |
| 285 |
mXAutoLock->start(); |
321 |
mXAutoLock->start(); |
| 286 |
} |
322 |
} |
|
|
323 |
processLockTransactions(); |
| 287 |
mState = Waiting; |
324 |
mState = Waiting; |
| 288 |
} |
325 |
} |
| 289 |
|
326 |
|
|
Lines 297-302
void SaverEngine::lockProcessExited()
Link Here
|
| 297 |
{ |
334 |
{ |
| 298 |
mXAutoLock->start(); |
335 |
mXAutoLock->start(); |
| 299 |
} |
336 |
} |
|
|
337 |
processLockTransactions(); |
| 300 |
mState = Waiting; |
338 |
mState = Waiting; |
| 301 |
} |
339 |
} |
| 302 |
|
340 |
|