From c68a1bac04c5cfdb0cdcbd91dc54995bfa05e292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sat, 8 Feb 2014 18:21:28 +0100 Subject: Switch from dbus-tqt do dbus-1-tqt Add systemd session and inhibit support Cleanup unused methods This partially resolves Bug 1597 --- src/dbusInterface.h | 118 +++++++++++++++++++--------------------------------- 1 file changed, 43 insertions(+), 75 deletions(-) (limited to 'src/dbusInterface.h') 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, , * \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 #include // D-Bus Header -#include // needed for dbus_bool_t -#include -#include +#include +#include +#include +#include // 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 -- cgit v1.2.1