summaryrefslogtreecommitdiffstats
path: root/src/dbusInterface.h
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2014-02-08 18:21:28 +0100
committerSlávek Banko <slavek.banko@axis.cz>2014-02-08 18:21:28 +0100
commitc68a1bac04c5cfdb0cdcbd91dc54995bfa05e292 (patch)
tree5a6bc1d0a5eba85862a2008df71bc6d273a13397 /src/dbusInterface.h
parent5c45c1a222eb91ea429f8c5245e32e43e7505582 (diff)
downloadtdepowersave-c68a1bac04c5cfdb0cdcbd91dc54995bfa05e292.tar.gz
tdepowersave-c68a1bac04c5cfdb0cdcbd91dc54995bfa05e292.zip
Switch from dbus-tqt do dbus-1-tqt
Add systemd session and inhibit support Cleanup unused methods This partially resolves Bug 1597
Diffstat (limited to 'src/dbusInterface.h')
-rw-r--r--src/dbusInterface.h118
1 files changed, 43 insertions, 75 deletions
diff --git a/src/dbusInterface.h b/src/dbusInterface.h
index f5afbd3..3fa8071 100644
--- a/src/dbusInterface.h
+++ b/src/dbusInterface.h
@@ -23,13 +23,13 @@
*/
/*!
* \class dbusInterface
-* \brief class for connection to HAL via D-Bus
+* \brief class for connection to D-Bus
* \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de>
* \date 2006-2007
*/
-#ifndef _DBUSHAL_H_
-#define _DBUSHAL_H_
+#ifndef _DBUS_INTERFACE_H_
+#define _DBUS_INTERFACE_H_
#ifndef DBUS_API_SUBJECT_TO_CHANGE
#define DBUS_API_SUBJECT_TO_CHANGE
@@ -41,12 +41,14 @@
#endif
// QT - Header
+#include <tqobject.h>
#include <tqstring.h>
// D-Bus Header
-#include <dbus/dbus.h> // needed for dbus_bool_t
-#include <dbus/message.h>
-#include <dbus/connection.h>
+#include <tqdbusconnection.h>
+#include <tqdbusobjectpath.h>
+#include <tqdbusproxy.h>
+#include <tqdbusunixfd.h>
// tdepowersave - Header
#include "tdepowersave_debug.h"
@@ -55,16 +57,13 @@
#define CK_MANAGER_IFACE "org.freedesktop.ConsoleKit.Manager"
#define CK_MANAGER_OBJECT "/org/freedesktop/ConsoleKit/Manager"
#define CK_SESSION_IFACE "org.freedesktop.ConsoleKit.Session"
+#define CK_SEAT_IFACE "org.freedesktop.ConsoleKit.Seat"
-enum msg_type {
- ACPI_EVENT,
- DBUS_EVENT,
- HAL_DEVICE,
- HAL_PROPERTY_CHANGED,
- HAL_CONDITION,
- CONSOLEKIT_SESSION_ACTIVE,
- POLICY_POWER_OWNER_CHANGED
-};
+#define SYSTEMD_LOGIN1_SERVICE "org.freedesktop.login1"
+#define SYSTEMD_LOGIN1_PATH "/org/freedesktop/login1"
+#define SYSTEMD_LOGIN1_MANAGER_IFACE "org.freedesktop.login1.Manager"
+#define SYSTEMD_LOGIN1_SESSION_IFACE "org.freedesktop.login1.Session"
+#define SYSTEMD_LOGIN1_SEAT_IFACE "org.freedesktop.login1.Seat"
class dbusInterface : public TQObject{
Q_OBJECT
@@ -72,35 +71,32 @@ class dbusInterface : public TQObject{
private:
- //! QT connection to D-Bus
- DBusQt::Connection* m_dBusQtConnection;
- //! real connection to D-Bus
- DBusConnection *dbus_connection;
-
- //! to store information if TDEPowersave is connected to D-Bus
- /*!
- * This boolean represent information about the state of the connection to D-Bus
- * \li true: if connected
- * \li false: if disconnected
- */
- bool dbus_is_connected;
-
- //! if we could claim the org.freedesktop.Policy.Power interface
- /*!
- * This boolean represent information if TDEPowersave could claim the
- * org.freedesktop.Policy.Power interface from the D-Bus
- * \li true: if acquired
- * \li false: if not
- */
- bool acquiredPolicyPower;
+ //! TQt connection to D-Bus
+ TQT_DBusConnection dBusConn;
+
+ //! TQt D-Bus proxy for watching signals
+ TQT_DBusProxy* dBusWatch;
+ TQT_DBusProxy* dBusLocal;
+
+ TQT_DBusObjectPath systemdSession;
+ TQT_DBusProxy* systemdSeat;
+ TQT_DBusUnixFd systemdInhibit;
+
+ TQT_DBusObjectPath consolekitSession;
+ TQT_DBusProxy* consolekitSeat;
/* D-Bus helper functions */
//! to initialise the connection to D-Bus
bool initDBUS();
- //! to call a methode on a dbus interface with reply
- bool dbusMethodCall( TQString interface, TQString path, TQString object, TQString method,
- DBusBusType dbus_type, void *retvalue, int retval_type,
- int first_arg_type, va_list var_args);
+
+ //! handles signal service registred/unregistered
+ void onServiceRegistered(const TQString&);
+ void onServiceUnregistered(const TQString&);
+
+private slots:
+
+ //! to reconnect to D-Bus
+ bool reconnect();
public:
@@ -109,52 +105,24 @@ public:
//! default destructor
~dbusInterface();
- //! to reconnect to D-Bus and HAL
- bool reconnect();
- //! to close the connection to D-Bus and HAL
+ //! to close the connection to D-Bus
bool close();
- //! to acquire the org.freedesktop.Policy.Power interface
- bool acquirePolicyPowerIface();
- //! to release the org.freedesktop.Policy.Power interface
- bool releasePolicyPowerIface();
- //! to check if the org.freedesktop.Policy.Power interface has an owner
- bool isPolicyPowerIfaceOwned();
-
// --- helper to get private members of the class --- //
//! to get information if TDEPowersave is connected to D-Bus
bool isConnectedToDBUS();
- //! to get info about claim org.freedesktop.Policy.Power interface
- bool acquiredPolicyPowerInterface();
- //! return the current DBus connection
- DBusConnection *get_DBUS_connection();
+ //! to check active session state
+ bool checkActiveSession();
- /* D-Bus helper functions */
+public slots:
- /* functions to call methodes */
- //! to call a methode on a dbus system bus method without reply
- bool dbusSystemMethodCall( TQString interface, TQString path, TQString object, TQString method,
- int first_arg_type, ... );
- //! to call a methode on a dbus system bus method with reply
- bool dbusSystemMethodCall( TQString interface, TQString path, TQString object, TQString method,
- void *retvalue, int retval_type, int first_arg_type, ... );
+ void handleDBusSignal(const TQT_DBusMessage&);
- /* PolicyKit call helper */
- //! check if the user has a requested privilege
- int isUserPrivileged( TQString privilege, TQString udi, TQString ressource = "", TQString user = TQString());
+signals:
- //! wrapper to emit a signal with a event from HAL
- void emitMsgReceived( msg_type type, TQString message, TQString string );
+ void activeSessionChanged(bool);
-signals:
- //! signal with message to forward from D-Bus to HAL
- void msgReceived_withStringString( msg_type, TQString, TQString );
- //! signal if we resumed!
- void backFromSuspend( int result );
};
-//! filter function to filter out needed information from D-Bus messages
-DBusHandlerResult filterFunction (DBusConnection *connection, DBusMessage *message, void *data);
-
#endif