Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbsessionmanager.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2013 Teo Mrnjavac <teo@kde.org> | - | ||||||||||||
4 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
5 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
6 | ** | - | ||||||||||||
7 | ** This file is part of the plugins of the Qt Toolkit. | - | ||||||||||||
8 | ** | - | ||||||||||||
9 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
10 | ** Commercial License Usage | - | ||||||||||||
11 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
12 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
13 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
14 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
15 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
16 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
17 | ** | - | ||||||||||||
18 | ** GNU Lesser General Public License Usage | - | ||||||||||||
19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
20 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
21 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
22 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
23 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
24 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
25 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
26 | ** | - | ||||||||||||
27 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
28 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
29 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
30 | ** | - | ||||||||||||
31 | ** $QT_END_LICENSE$ | - | ||||||||||||
32 | ** | - | ||||||||||||
33 | ****************************************************************************/ | - | ||||||||||||
34 | - | |||||||||||||
35 | #include "qxcbsessionmanager.h" | - | ||||||||||||
36 | - | |||||||||||||
37 | #include <qguiapplication.h> | - | ||||||||||||
38 | #include <qdatetime.h> | - | ||||||||||||
39 | #include <qfileinfo.h> | - | ||||||||||||
40 | #include <qplatformdefs.h> | - | ||||||||||||
41 | #include <qsocketnotifier.h> | - | ||||||||||||
42 | #include <X11/SM/SMlib.h> | - | ||||||||||||
43 | #include <errno.h> // ERANGE | - | ||||||||||||
44 | - | |||||||||||||
45 | #include <cerrno> // ERANGE | - | ||||||||||||
46 | - | |||||||||||||
47 | class QSmSocketReceiver : public QObject | - | ||||||||||||
48 | { | - | ||||||||||||
49 | Q_OBJECT | - | ||||||||||||
50 | public: | - | ||||||||||||
51 | QSmSocketReceiver(int socket) | - | ||||||||||||
52 | { | - | ||||||||||||
53 | QSocketNotifier* sn = new QSocketNotifier(socket, QSocketNotifier::Read, this); | - | ||||||||||||
54 | connect(sn, SIGNAL(activated(int)), this, SLOT(socketActivated(int))); | - | ||||||||||||
55 | } never executed: end of block | 0 | ||||||||||||
56 | - | |||||||||||||
57 | public Q_SLOTS: | - | ||||||||||||
58 | void socketActivated(int); | - | ||||||||||||
59 | }; | - | ||||||||||||
60 | - | |||||||||||||
61 | - | |||||||||||||
62 | static SmcConn smcConnection = 0; | - | ||||||||||||
63 | static bool sm_interactionActive; | - | ||||||||||||
64 | static bool sm_smActive; | - | ||||||||||||
65 | static int sm_interactStyle; | - | ||||||||||||
66 | static int sm_saveType; | - | ||||||||||||
67 | static bool sm_cancel; | - | ||||||||||||
68 | static bool sm_waitingForInteraction; | - | ||||||||||||
69 | static bool sm_isshutdown; | - | ||||||||||||
70 | static bool sm_phase2; | - | ||||||||||||
71 | static bool sm_in_phase2; | - | ||||||||||||
72 | bool qt_sm_blockUserInput = false; | - | ||||||||||||
73 | - | |||||||||||||
74 | static QSmSocketReceiver* sm_receiver = 0; | - | ||||||||||||
75 | - | |||||||||||||
76 | static void resetSmState(); | - | ||||||||||||
77 | static void sm_setProperty(const char *name, const char *type, | - | ||||||||||||
78 | int num_vals, SmPropValue *vals); | - | ||||||||||||
79 | static void sm_saveYourselfCallback(SmcConn smcConn, SmPointer clientData, | - | ||||||||||||
80 | int saveType, Bool shutdown , int interactStyle, Bool fast); | - | ||||||||||||
81 | static void sm_saveYourselfPhase2Callback(SmcConn smcConn, SmPointer clientData) ; | - | ||||||||||||
82 | static void sm_dieCallback(SmcConn smcConn, SmPointer clientData) ; | - | ||||||||||||
83 | static void sm_shutdownCancelledCallback(SmcConn smcConn, SmPointer clientData); | - | ||||||||||||
84 | static void sm_saveCompleteCallback(SmcConn smcConn, SmPointer clientData); | - | ||||||||||||
85 | static void sm_interactCallback(SmcConn smcConn, SmPointer clientData); | - | ||||||||||||
86 | static void sm_performSaveYourself(QXcbSessionManager*); | - | ||||||||||||
87 | - | |||||||||||||
88 | static void resetSmState() | - | ||||||||||||
89 | { | - | ||||||||||||
90 | sm_waitingForInteraction = false; | - | ||||||||||||
91 | sm_interactionActive = false; | - | ||||||||||||
92 | sm_interactStyle = SmInteractStyleNone; | - | ||||||||||||
93 | sm_smActive = false; | - | ||||||||||||
94 | qt_sm_blockUserInput = false; | - | ||||||||||||
95 | sm_isshutdown = false; | - | ||||||||||||
96 | sm_phase2 = false; | - | ||||||||||||
97 | sm_in_phase2 = false; | - | ||||||||||||
98 | } executed 129 times by 5 tests: end of block Executed by:
| 129 | ||||||||||||
99 | - | |||||||||||||
100 | - | |||||||||||||
101 | // theoretically it's possible to set several properties at once. For | - | ||||||||||||
102 | // simplicity, however, we do just one property at a time | - | ||||||||||||
103 | static void sm_setProperty(const char *name, const char *type, | - | ||||||||||||
104 | int num_vals, SmPropValue *vals) | - | ||||||||||||
105 | { | - | ||||||||||||
106 | if (num_vals) {
| 0 | ||||||||||||
107 | SmProp prop; | - | ||||||||||||
108 | prop.name = const_cast<char*>(name); | - | ||||||||||||
109 | prop.type = const_cast<char*>(type); | - | ||||||||||||
110 | prop.num_vals = num_vals; | - | ||||||||||||
111 | prop.vals = vals; | - | ||||||||||||
112 | - | |||||||||||||
113 | SmProp* props[1]; | - | ||||||||||||
114 | props[0] = ∝ | - | ||||||||||||
115 | SmcSetProperties(smcConnection, 1, props); | - | ||||||||||||
116 | } else { never executed: end of block | 0 | ||||||||||||
117 | char* names[1]; | - | ||||||||||||
118 | names[0] = const_cast<char*>(name); | - | ||||||||||||
119 | SmcDeleteProperties(smcConnection, 1, names); | - | ||||||||||||
120 | } never executed: end of block | 0 | ||||||||||||
121 | } | - | ||||||||||||
122 | - | |||||||||||||
123 | static void sm_setProperty(const QString &name, const QString &value) | - | ||||||||||||
124 | { | - | ||||||||||||
125 | QByteArray v = value.toUtf8(); | - | ||||||||||||
126 | SmPropValue prop; | - | ||||||||||||
127 | prop.length = v.length(); | - | ||||||||||||
128 | prop.value = (SmPointer) const_cast<char *>(v.constData()); | - | ||||||||||||
129 | sm_setProperty(name.toLatin1().data(), SmARRAY8, 1, &prop); | - | ||||||||||||
130 | } never executed: end of block | 0 | ||||||||||||
131 | - | |||||||||||||
132 | static void sm_setProperty(const QString &name, const QStringList &value) | - | ||||||||||||
133 | { | - | ||||||||||||
134 | SmPropValue *prop = new SmPropValue[value.count()]; | - | ||||||||||||
135 | int count = 0; | - | ||||||||||||
136 | QList<QByteArray> vl; | - | ||||||||||||
137 | vl.reserve(value.size()); | - | ||||||||||||
138 | for (QStringList::ConstIterator it = value.begin(); it != value.end(); ++it) {
| 0 | ||||||||||||
139 | prop[count].length = (*it).length(); | - | ||||||||||||
140 | vl.append((*it).toUtf8()); | - | ||||||||||||
141 | prop[count].value = (char*)vl.last().data(); | - | ||||||||||||
142 | ++count; | - | ||||||||||||
143 | } never executed: end of block | 0 | ||||||||||||
144 | sm_setProperty(name.toLatin1().data(), SmLISTofARRAY8, count, prop); | - | ||||||||||||
145 | delete [] prop; | - | ||||||||||||
146 | } never executed: end of block | 0 | ||||||||||||
147 | - | |||||||||||||
148 | - | |||||||||||||
149 | // workaround for broken libsm, see below | - | ||||||||||||
150 | struct QT_smcConn { | - | ||||||||||||
151 | unsigned int save_yourself_in_progress : 1; | - | ||||||||||||
152 | unsigned int shutdown_in_progress : 1; | - | ||||||||||||
153 | }; | - | ||||||||||||
154 | - | |||||||||||||
155 | static void sm_saveYourselfCallback(SmcConn smcConn, SmPointer clientData, | - | ||||||||||||
156 | int saveType, Bool shutdown , int interactStyle, Bool /*fast*/) | - | ||||||||||||
157 | { | - | ||||||||||||
158 | if (smcConn != smcConnection)
| 0 | ||||||||||||
159 | return; never executed: return; | 0 | ||||||||||||
160 | sm_cancel = false; | - | ||||||||||||
161 | sm_smActive = true; | - | ||||||||||||
162 | sm_isshutdown = shutdown; | - | ||||||||||||
163 | sm_saveType = saveType; | - | ||||||||||||
164 | sm_interactStyle = interactStyle; | - | ||||||||||||
165 | - | |||||||||||||
166 | // ugly workaround for broken libSM. libSM should do that _before_ | - | ||||||||||||
167 | // actually invoking the callback in sm_process.c | - | ||||||||||||
168 | ((QT_smcConn*)smcConn)->save_yourself_in_progress = true; | - | ||||||||||||
169 | if (sm_isshutdown)
| 0 | ||||||||||||
170 | ((QT_smcConn*)smcConn)->shutdown_in_progress = true; never executed: ((QT_smcConn*)smcConn)->shutdown_in_progress = true; | 0 | ||||||||||||
171 | - | |||||||||||||
172 | sm_performSaveYourself((QXcbSessionManager*) clientData); | - | ||||||||||||
173 | if (!sm_isshutdown) // we cannot expect a confirmation message in that case
| 0 | ||||||||||||
174 | resetSmState(); never executed: resetSmState(); | 0 | ||||||||||||
175 | } never executed: end of block | 0 | ||||||||||||
176 | - | |||||||||||||
177 | static void sm_performSaveYourself(QXcbSessionManager *sm) | - | ||||||||||||
178 | { | - | ||||||||||||
179 | if (sm_isshutdown)
| 0 | ||||||||||||
180 | qt_sm_blockUserInput = true; never executed: qt_sm_blockUserInput = true; | 0 | ||||||||||||
181 | - | |||||||||||||
182 | // generate a new session key | - | ||||||||||||
183 | timeval tv; | - | ||||||||||||
184 | gettimeofday(&tv, 0); | - | ||||||||||||
185 | sm->setSessionKey(QString::number(qulonglong(tv.tv_sec)) + | - | ||||||||||||
186 | QLatin1Char('_') + | - | ||||||||||||
187 | QString::number(qulonglong(tv.tv_usec))); | - | ||||||||||||
188 | - | |||||||||||||
189 | QStringList arguments = QCoreApplication::arguments(); | - | ||||||||||||
190 | QString argument0 = arguments.isEmpty() ? QCoreApplication::applicationFilePath()
| 0 | ||||||||||||
191 | : arguments.at(0); | - | ||||||||||||
192 | - | |||||||||||||
193 | // tell the session manager about our program in best POSIX style | - | ||||||||||||
194 | sm_setProperty(QString::fromLatin1(SmProgram), argument0); | - | ||||||||||||
195 | // tell the session manager about our user as well. | - | ||||||||||||
196 | struct passwd *entryPtr = 0; | - | ||||||||||||
197 | #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0) | - | ||||||||||||
198 | QVarLengthArray<char, 1024> buf(qMax<long>(sysconf(_SC_GETPW_R_SIZE_MAX), 1024L)); | - | ||||||||||||
199 | struct passwd entry; | - | ||||||||||||
200 | while (getpwuid_r(geteuid(), &entry, buf.data(), buf.size(), &entryPtr) == ERANGE) {
| 0 | ||||||||||||
201 | if (buf.size() >= 32768) {
| 0 | ||||||||||||
202 | // too big already, fail | - | ||||||||||||
203 | static char badusername[] = ""; | - | ||||||||||||
204 | entryPtr = &entry; | - | ||||||||||||
205 | entry.pw_name = badusername; | - | ||||||||||||
206 | break; never executed: break; | 0 | ||||||||||||
207 | } | - | ||||||||||||
208 | - | |||||||||||||
209 | // retry with a bigger buffer | - | ||||||||||||
210 | buf.resize(buf.size() * 2); | - | ||||||||||||
211 | } never executed: end of block | 0 | ||||||||||||
212 | #else | - | ||||||||||||
213 | entryPtr = getpwuid(geteuid()); | - | ||||||||||||
214 | #endif | - | ||||||||||||
215 | if (entryPtr)
| 0 | ||||||||||||
216 | sm_setProperty(QString::fromLatin1(SmUserID), QString::fromLocal8Bit(entryPtr->pw_name)); never executed: sm_setProperty(QString::fromLatin1("UserID"), QString::fromLocal8Bit(entryPtr->pw_name)); | 0 | ||||||||||||
217 | - | |||||||||||||
218 | // generate a restart and discard command that makes sense | - | ||||||||||||
219 | QStringList restart; | - | ||||||||||||
220 | restart << argument0 << QLatin1String("-session") | - | ||||||||||||
221 | << sm->sessionId() + QLatin1Char('_') + sm->sessionKey(); | - | ||||||||||||
222 | - | |||||||||||||
223 | QFileInfo fi = QCoreApplication::applicationFilePath(); | - | ||||||||||||
224 | if (qAppName().compare(fi.fileName(), Qt::CaseInsensitive) != 0)
| 0 | ||||||||||||
225 | restart << QLatin1String("-name") << qAppName(); never executed: restart << QLatin1String("-name") << qAppName(); | 0 | ||||||||||||
226 | sm->setRestartCommand(restart); | - | ||||||||||||
227 | QStringList discard; | - | ||||||||||||
228 | sm->setDiscardCommand(discard); | - | ||||||||||||
229 | - | |||||||||||||
230 | switch (sm_saveType) { | - | ||||||||||||
231 | case SmSaveBoth: never executed: case 2: | 0 | ||||||||||||
232 | sm->appCommitData(); | - | ||||||||||||
233 | if (sm_isshutdown && sm_cancel)
| 0 | ||||||||||||
234 | break; // we cancelled the shutdown, no need to save state never executed: break; | 0 | ||||||||||||
235 | // fall through | - | ||||||||||||
236 | case SmSaveLocal: code before this statement never executed: case 1: never executed: case 1: | 0 | ||||||||||||
237 | sm->appSaveState(); | - | ||||||||||||
238 | break; never executed: break; | 0 | ||||||||||||
239 | case SmSaveGlobal: never executed: case 0: | 0 | ||||||||||||
240 | sm->appCommitData(); | - | ||||||||||||
241 | break; never executed: break; | 0 | ||||||||||||
242 | default: never executed: default: | 0 | ||||||||||||
243 | break; never executed: break; | 0 | ||||||||||||
244 | } | - | ||||||||||||
245 | - | |||||||||||||
246 | if (sm_phase2 && !sm_in_phase2) {
| 0 | ||||||||||||
247 | SmcRequestSaveYourselfPhase2(smcConnection, sm_saveYourselfPhase2Callback, (SmPointer*) sm); | - | ||||||||||||
248 | qt_sm_blockUserInput = false; | - | ||||||||||||
249 | } else { never executed: end of block | 0 | ||||||||||||
250 | // close eventual interaction monitors and cancel the | - | ||||||||||||
251 | // shutdown, if required. Note that we can only cancel when | - | ||||||||||||
252 | // performing a shutdown, it does not work for checkpoints | - | ||||||||||||
253 | if (sm_interactionActive) {
| 0 | ||||||||||||
254 | SmcInteractDone(smcConnection, sm_isshutdown && sm_cancel); | - | ||||||||||||
255 | sm_interactionActive = false; | - | ||||||||||||
256 | } else if (sm_cancel && sm_isshutdown) { never executed: end of block
| 0 | ||||||||||||
257 | if (sm->allowsErrorInteraction()) {
| 0 | ||||||||||||
258 | SmcInteractDone(smcConnection, True); | - | ||||||||||||
259 | sm_interactionActive = false; | - | ||||||||||||
260 | } never executed: end of block | 0 | ||||||||||||
261 | } never executed: end of block | 0 | ||||||||||||
262 | - | |||||||||||||
263 | // set restart and discard command in session manager | - | ||||||||||||
264 | sm_setProperty(QString::fromLatin1(SmRestartCommand), sm->restartCommand()); | - | ||||||||||||
265 | sm_setProperty(QString::fromLatin1(SmDiscardCommand), sm->discardCommand()); | - | ||||||||||||
266 | - | |||||||||||||
267 | // set the restart hint | - | ||||||||||||
268 | SmPropValue prop; | - | ||||||||||||
269 | prop.length = sizeof(int); | - | ||||||||||||
270 | int value = sm->restartHint(); | - | ||||||||||||
271 | prop.value = (SmPointer) &value; | - | ||||||||||||
272 | sm_setProperty(SmRestartStyleHint, SmCARD8, 1, &prop); | - | ||||||||||||
273 | - | |||||||||||||
274 | // we are done | - | ||||||||||||
275 | SmcSaveYourselfDone(smcConnection, !sm_cancel); | - | ||||||||||||
276 | } never executed: end of block | 0 | ||||||||||||
277 | } | - | ||||||||||||
278 | - | |||||||||||||
279 | static void sm_dieCallback(SmcConn smcConn, SmPointer /* clientData */) | - | ||||||||||||
280 | { | - | ||||||||||||
281 | if (smcConn != smcConnection)
| 0 | ||||||||||||
282 | return; never executed: return; | 0 | ||||||||||||
283 | resetSmState(); | - | ||||||||||||
284 | QEvent quitEvent(QEvent::Quit); | - | ||||||||||||
285 | QGuiApplication::sendEvent(qApp, &quitEvent); | - | ||||||||||||
286 | } never executed: end of block | 0 | ||||||||||||
287 | - | |||||||||||||
288 | static void sm_shutdownCancelledCallback(SmcConn smcConn, SmPointer clientData) | - | ||||||||||||
289 | { | - | ||||||||||||
290 | if (smcConn != smcConnection)
| 0 | ||||||||||||
291 | return; never executed: return; | 0 | ||||||||||||
292 | if (sm_waitingForInteraction)
| 0 | ||||||||||||
293 | ((QXcbSessionManager *) clientData)->exitEventLoop(); never executed: ((QXcbSessionManager *) clientData)->exitEventLoop(); | 0 | ||||||||||||
294 | resetSmState(); | - | ||||||||||||
295 | } never executed: end of block | 0 | ||||||||||||
296 | - | |||||||||||||
297 | static void sm_saveCompleteCallback(SmcConn smcConn, SmPointer /*clientData */) | - | ||||||||||||
298 | { | - | ||||||||||||
299 | if (smcConn != smcConnection)
| 0 | ||||||||||||
300 | return; never executed: return; | 0 | ||||||||||||
301 | resetSmState(); | - | ||||||||||||
302 | } never executed: end of block | 0 | ||||||||||||
303 | - | |||||||||||||
304 | static void sm_interactCallback(SmcConn smcConn, SmPointer clientData) | - | ||||||||||||
305 | { | - | ||||||||||||
306 | if (smcConn != smcConnection)
| 0 | ||||||||||||
307 | return; never executed: return; | 0 | ||||||||||||
308 | if (sm_waitingForInteraction)
| 0 | ||||||||||||
309 | ((QXcbSessionManager *) clientData)->exitEventLoop(); never executed: ((QXcbSessionManager *) clientData)->exitEventLoop(); | 0 | ||||||||||||
310 | } never executed: end of block | 0 | ||||||||||||
311 | - | |||||||||||||
312 | static void sm_saveYourselfPhase2Callback(SmcConn smcConn, SmPointer clientData) | - | ||||||||||||
313 | { | - | ||||||||||||
314 | if (smcConn != smcConnection)
| 0 | ||||||||||||
315 | return; never executed: return; | 0 | ||||||||||||
316 | sm_in_phase2 = true; | - | ||||||||||||
317 | sm_performSaveYourself((QXcbSessionManager *) clientData); | - | ||||||||||||
318 | } never executed: end of block | 0 | ||||||||||||
319 | - | |||||||||||||
320 | - | |||||||||||||
321 | void QSmSocketReceiver::socketActivated(int) | - | ||||||||||||
322 | { | - | ||||||||||||
323 | IceProcessMessages(SmcGetIceConnection(smcConnection), 0, 0); | - | ||||||||||||
324 | } never executed: end of block | 0 | ||||||||||||
325 | - | |||||||||||||
326 | - | |||||||||||||
327 | // QXcbSessionManager starts here | - | ||||||||||||
328 | - | |||||||||||||
329 | QXcbSessionManager::QXcbSessionManager(const QString &id, const QString &key) | - | ||||||||||||
330 | : QPlatformSessionManager(id, key) | - | ||||||||||||
331 | , m_eventLoop(0) | - | ||||||||||||
332 | { | - | ||||||||||||
333 | resetSmState(); | - | ||||||||||||
334 | char cerror[256]; | - | ||||||||||||
335 | char* myId = 0; | - | ||||||||||||
336 | QByteArray b_id = id.toLatin1(); | - | ||||||||||||
337 | char* prevId = b_id.data(); | - | ||||||||||||
338 | - | |||||||||||||
339 | SmcCallbacks cb; | - | ||||||||||||
340 | cb.save_yourself.callback = sm_saveYourselfCallback; | - | ||||||||||||
341 | cb.save_yourself.client_data = (SmPointer) this; | - | ||||||||||||
342 | cb.die.callback = sm_dieCallback; | - | ||||||||||||
343 | cb.die.client_data = (SmPointer) this; | - | ||||||||||||
344 | cb.save_complete.callback = sm_saveCompleteCallback; | - | ||||||||||||
345 | cb.save_complete.client_data = (SmPointer) this; | - | ||||||||||||
346 | cb.shutdown_cancelled.callback = sm_shutdownCancelledCallback; | - | ||||||||||||
347 | cb.shutdown_cancelled.client_data = (SmPointer) this; | - | ||||||||||||
348 | - | |||||||||||||
349 | // avoid showing a warning message below | - | ||||||||||||
350 | if (!qEnvironmentVariableIsSet("SESSION_MANAGER"))
| 0-129 | ||||||||||||
351 | return; executed 129 times by 5 tests: return; Executed by:
| 129 | ||||||||||||
352 | - | |||||||||||||
353 | smcConnection = SmcOpenConnection(0, 0, 1, 0, | - | ||||||||||||
354 | SmcSaveYourselfProcMask | | - | ||||||||||||
355 | SmcDieProcMask | | - | ||||||||||||
356 | SmcSaveCompleteProcMask | | - | ||||||||||||
357 | SmcShutdownCancelledProcMask, | - | ||||||||||||
358 | &cb, | - | ||||||||||||
359 | prevId, | - | ||||||||||||
360 | &myId, | - | ||||||||||||
361 | 256, cerror); | - | ||||||||||||
362 | - | |||||||||||||
363 | setSessionId(QString::fromLatin1(myId)); | - | ||||||||||||
364 | ::free(myId); // it was allocated by C | - | ||||||||||||
365 | - | |||||||||||||
366 | QString error = QString::fromLocal8Bit(cerror); | - | ||||||||||||
367 | if (!smcConnection)
| 0 | ||||||||||||
368 | qWarning("Qt: Session management error: %s", qPrintable(error)); never executed: QMessageLogger(__FILE__, 368, __PRETTY_FUNCTION__).warning("Qt: Session management error: %s", QString(error).toLocal8Bit().constData()); | 0 | ||||||||||||
369 | else | - | ||||||||||||
370 | sm_receiver = new QSmSocketReceiver(IceConnectionNumber(SmcGetIceConnection(smcConnection))); never executed: sm_receiver = new QSmSocketReceiver(IceConnectionNumber(SmcGetIceConnection(smcConnection))); | 0 | ||||||||||||
371 | } | - | ||||||||||||
372 | - | |||||||||||||
373 | QXcbSessionManager::~QXcbSessionManager() | - | ||||||||||||
374 | { | - | ||||||||||||
375 | if (smcConnection)
| 0-341 | ||||||||||||
376 | SmcCloseConnection(smcConnection, 0, 0); never executed: SmcCloseConnection(smcConnection, 0, 0); | 0 | ||||||||||||
377 | smcConnection = 0; | - | ||||||||||||
378 | delete sm_receiver; | - | ||||||||||||
379 | } executed 341 times by 220 tests: end of block Executed by:
| 341 | ||||||||||||
380 | - | |||||||||||||
381 | - | |||||||||||||
382 | void* QXcbSessionManager::handle() const | - | ||||||||||||
383 | { | - | ||||||||||||
384 | return (void*) smcConnection; never executed: return (void*) smcConnection; | 0 | ||||||||||||
385 | } | - | ||||||||||||
386 | - | |||||||||||||
387 | bool QXcbSessionManager::allowsInteraction() | - | ||||||||||||
388 | { | - | ||||||||||||
389 | if (sm_interactionActive)
| 0 | ||||||||||||
390 | return true; never executed: return true; | 0 | ||||||||||||
391 | - | |||||||||||||
392 | if (sm_waitingForInteraction)
| 0 | ||||||||||||
393 | return false; never executed: return false; | 0 | ||||||||||||
394 | - | |||||||||||||
395 | if (sm_interactStyle == SmInteractStyleAny) {
| 0 | ||||||||||||
396 | sm_waitingForInteraction = SmcInteractRequest(smcConnection, | - | ||||||||||||
397 | SmDialogNormal, | - | ||||||||||||
398 | sm_interactCallback, | - | ||||||||||||
399 | (SmPointer*) this); | - | ||||||||||||
400 | } never executed: end of block | 0 | ||||||||||||
401 | if (sm_waitingForInteraction) {
| 0 | ||||||||||||
402 | QEventLoop eventLoop; | - | ||||||||||||
403 | m_eventLoop = &eventLoop; | - | ||||||||||||
404 | eventLoop.exec(); | - | ||||||||||||
405 | m_eventLoop = 0; | - | ||||||||||||
406 | - | |||||||||||||
407 | sm_waitingForInteraction = false; | - | ||||||||||||
408 | if (sm_smActive) { // not cancelled
| 0 | ||||||||||||
409 | sm_interactionActive = true; | - | ||||||||||||
410 | qt_sm_blockUserInput = false; | - | ||||||||||||
411 | return true; never executed: return true; | 0 | ||||||||||||
412 | } | - | ||||||||||||
413 | } never executed: end of block | 0 | ||||||||||||
414 | return false; never executed: return false; | 0 | ||||||||||||
415 | } | - | ||||||||||||
416 | - | |||||||||||||
417 | bool QXcbSessionManager::allowsErrorInteraction() | - | ||||||||||||
418 | { | - | ||||||||||||
419 | if (sm_interactionActive)
| 0 | ||||||||||||
420 | return true; never executed: return true; | 0 | ||||||||||||
421 | - | |||||||||||||
422 | if (sm_waitingForInteraction)
| 0 | ||||||||||||
423 | return false; never executed: return false; | 0 | ||||||||||||
424 | - | |||||||||||||
425 | if (sm_interactStyle == SmInteractStyleAny || sm_interactStyle == SmInteractStyleErrors) {
| 0 | ||||||||||||
426 | sm_waitingForInteraction = SmcInteractRequest(smcConnection, | - | ||||||||||||
427 | SmDialogError, | - | ||||||||||||
428 | sm_interactCallback, | - | ||||||||||||
429 | (SmPointer*) this); | - | ||||||||||||
430 | } never executed: end of block | 0 | ||||||||||||
431 | if (sm_waitingForInteraction) {
| 0 | ||||||||||||
432 | QEventLoop eventLoop; | - | ||||||||||||
433 | m_eventLoop = &eventLoop; | - | ||||||||||||
434 | eventLoop.exec(); | - | ||||||||||||
435 | m_eventLoop = 0; | - | ||||||||||||
436 | - | |||||||||||||
437 | sm_waitingForInteraction = false; | - | ||||||||||||
438 | if (sm_smActive) { // not cancelled
| 0 | ||||||||||||
439 | sm_interactionActive = true; | - | ||||||||||||
440 | qt_sm_blockUserInput = false; | - | ||||||||||||
441 | return true; never executed: return true; | 0 | ||||||||||||
442 | } | - | ||||||||||||
443 | } never executed: end of block | 0 | ||||||||||||
444 | return false; never executed: return false; | 0 | ||||||||||||
445 | } | - | ||||||||||||
446 | - | |||||||||||||
447 | void QXcbSessionManager::release() | - | ||||||||||||
448 | { | - | ||||||||||||
449 | if (sm_interactionActive) {
| 0 | ||||||||||||
450 | SmcInteractDone(smcConnection, False); | - | ||||||||||||
451 | sm_interactionActive = false; | - | ||||||||||||
452 | if (sm_smActive && sm_isshutdown)
| 0 | ||||||||||||
453 | qt_sm_blockUserInput = true; never executed: qt_sm_blockUserInput = true; | 0 | ||||||||||||
454 | } never executed: end of block | 0 | ||||||||||||
455 | } never executed: end of block | 0 | ||||||||||||
456 | - | |||||||||||||
457 | void QXcbSessionManager::cancel() | - | ||||||||||||
458 | { | - | ||||||||||||
459 | sm_cancel = true; | - | ||||||||||||
460 | } never executed: end of block | 0 | ||||||||||||
461 | - | |||||||||||||
462 | void QXcbSessionManager::setManagerProperty(const QString &name, const QString &value) | - | ||||||||||||
463 | { | - | ||||||||||||
464 | sm_setProperty(name, value); | - | ||||||||||||
465 | } never executed: end of block | 0 | ||||||||||||
466 | - | |||||||||||||
467 | void QXcbSessionManager::setManagerProperty(const QString &name, const QStringList &value) | - | ||||||||||||
468 | { | - | ||||||||||||
469 | sm_setProperty(name, value); | - | ||||||||||||
470 | } never executed: end of block | 0 | ||||||||||||
471 | - | |||||||||||||
472 | bool QXcbSessionManager::isPhase2() const | - | ||||||||||||
473 | { | - | ||||||||||||
474 | return sm_in_phase2; never executed: return sm_in_phase2; | 0 | ||||||||||||
475 | } | - | ||||||||||||
476 | - | |||||||||||||
477 | void QXcbSessionManager::requestPhase2() | - | ||||||||||||
478 | { | - | ||||||||||||
479 | sm_phase2 = true; | - | ||||||||||||
480 | } never executed: end of block | 0 | ||||||||||||
481 | - | |||||||||||||
482 | void QXcbSessionManager::exitEventLoop() | - | ||||||||||||
483 | { | - | ||||||||||||
484 | m_eventLoop->exit(); | - | ||||||||||||
485 | } never executed: end of block | 0 | ||||||||||||
486 | - | |||||||||||||
487 | #include "qxcbsessionmanager.moc" | - | ||||||||||||
Source code | Switch to Preprocessed file |