3 #include "devstate.hpp"
6 #include <mce/dbus-names.h>
7 #include <mce/mode-names.h>
9 #define MCE_AVAILABLE 1
11 #define MCE_AVAILABLE 0
14 static DeviceState *_instance = NULL;
17 // --------------------------------------------------
19 // --------------------------------------------------
20 DeviceState* DeviceState::instance ()
23 _instance = new DeviceState;
28 DeviceState::DeviceState ()
29 : _bus (QDBusConnection::systemBus ())
34 _itf = new QDBusInterface (MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, _bus);
35 _bus.connect (MCE_SERVICE, MCE_SIGNAL_PATH, MCE_SIGNAL_IF, MCE_TKLOCK_MODE_SIG,
36 this, SLOT (tkLockMessage (const QDBusMessage&)));
42 void DeviceState::requestState ()
45 tkLockMessage (_itf->call (MCE_TKLOCK_MODE_GET));
50 void DeviceState::tkLockMessage (const QDBusMessage &msg)
55 if (msg.arguments ().count () > 0) {
56 s = msg.arguments ().value (0).toString ();
57 printf ("Reply = %s\n", s.toUtf8 ().data ());
58 setLocked (s == QString (MCE_TK_LOCKED));
64 void DeviceState::setLocked (bool new_val)
66 if (_locked != new_val) {
68 lockChanged (_locked);