CConsoleUPowerSyscall::CConsoleUPowerSyscall() { CLog::Log(LOGINFO, "Selected UPower and ConsoleKit as PowerSyscall"); m_lowBattery = false; dbus_error_init (&m_error); // TODO: do not use dbus_connection_pop_message() that requires the use of a // private connection m_connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &m_error); if (m_connection) { dbus_connection_set_exit_on_disconnect(m_connection, false); dbus_bus_add_match(m_connection, "type='signal',interface='org.freedesktop.UPower'", &m_error); dbus_connection_flush(m_connection); } if (dbus_error_is_set(&m_error)) { CLog::Log(LOGERROR, "UPower: Failed to attach to signal %s", m_error.message); dbus_connection_close(m_connection); dbus_connection_unref(m_connection); m_connection = NULL; } m_CanPowerdown = ConsoleKitMethodCall("CanStop"); m_CanReboot = ConsoleKitMethodCall("CanRestart"); UpdateUPower(); EnumeratePowerSources(); }
CUPowerSyscall::CUPowerSyscall() { CLog::Log(LOGINFO, "Selected UPower as PowerSyscall"); m_lowBattery = false; //! @todo do not use dbus_connection_pop_message() that requires the use of a //! private connection if (m_connection.Connect(DBUS_BUS_SYSTEM, true)) { dbus_connection_set_exit_on_disconnect(m_connection, false); CDBusError error; dbus_bus_add_match(m_connection, "type='signal',interface='org.freedesktop.UPower'", error); dbus_connection_flush(m_connection); if (error) { error.Log("UPower: Failed to attach to signal"); m_connection.Destroy(); } } m_CanPowerdown = false; m_CanReboot = false; UpdateCapabilities(); EnumeratePowerSources(); }