Changeset 89708 in vbox
- Timestamp:
- Jun 15, 2021 2:25:25 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/platform/x11
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxX11Helper.cpp
r89705 r89708 39 39 RT_C_DECLS_END 40 40 41 #include <VBox/log.h> 41 42 42 43 static int gX11ScreenSaverTimeout; … … 177 178 } 178 179 179 void X11InhibitScrenSaver(const QStringList &serviceNameList) 180 { 181 Q_UNUSED(serviceNameList); 182 } 180 void X11InhibitScrenSaver(const QStringList &serviceNameList, QMap<QString, uint> &outCookies) 181 { 182 outCookies.clear(); 183 QDBusConnection bus = QDBusConnection::sessionBus(); 184 185 foreach(QString service, serviceNameList) 186 { 187 QDBusInterface screenSaverInterface(service, "/ScreenSaver", 188 QString(), bus); 189 if (!screenSaverInterface.isValid()) 190 { 191 QDBusError error = screenSaverInterface.lastError(); 192 LogRel(("QDBus error for service %s: %s\n", 193 service.toUtf8().constData(), error.message().toUtf8().constData())); 194 continue; 195 } 196 QDBusReply<uint> reply = screenSaverInterface.call("Inhibit", "Oracle VirtualBox", ""); 197 if (reply.isValid()) 198 outCookies[service] = reply.value(); 199 else 200 { 201 QDBusError error = screenSaverInterface.lastError(); 202 LogRel(("QDBus inhibition call error for service %s: %s\n", 203 service.toUtf8().constData(), error.message().toUtf8().constData())); 204 } 205 } 206 } 207 208 void X11UninhibitScrenSaver(const QMap<QString, uint> &cookies) 209 { 210 211 QDBusConnection bus = QDBusConnection::sessionBus(); 212 213 for (QMap<QString, uint>::const_iterator iterator = cookies.begin(); iterator != cookies.end(); ++iterator) 214 { 215 216 QDBusInterface screenSaverInterface(iterator.key(), "/ScreenSaver", 217 QString(), bus); 218 if (!screenSaverInterface.isValid()) 219 { 220 QDBusError error = screenSaverInterface.lastError(); 221 LogRel(("QDBus error for service %s: %s\n", 222 iterator.key().toUtf8().constData(), error.message().toUtf8().constData())); 223 continue; 224 } 225 QDBusReply<uint> reply = screenSaverInterface.call("UnInhibit", iterator.value()); 226 if (!reply.isValid()) 227 { 228 QDBusError error = screenSaverInterface.lastError(); 229 LogRel(("QDBus uninhibition call error for service %s: %s\n", 230 iterator.key().toUtf8().constData(), error.message().toUtf8().constData())); 231 } 232 } 233 } 234 183 235 184 236 #ifdef VBOX_WS_X11 -
trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxX11Helper.h
r89704 r89708 58 58 59 59 /* Disables Screen Saver through QDBus. */ 60 SHARED_LIBRARY_STUFF void X11InhibitScrenSaver(const QStringList &serviceNameList); 60 SHARED_LIBRARY_STUFF void X11InhibitScrenSaver(const QStringList &serviceNameList, QMap<QString, uint> &outCookies); 61 62 /* Enables Screen Saver through QDBus. */ 63 SHARED_LIBRARY_STUFF void X11UninhibitScrenSaver(const QMap<QString, uint> &cookies); 61 64 62 65 #endif /* !FEQT_INCLUDED_SRC_platform_x11_VBoxX11Helper_h */
Note:
See TracChangeset
for help on using the changeset viewer.