summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.build.yml4
-rw-r--r--applets/brightness/Makefile.am3
-rw-r--r--applets/brightness/brightness-applet.c78
-rw-r--r--applets/brightness/meson.build4
-rw-r--r--applets/inhibit/Makefile.am3
-rw-r--r--applets/inhibit/inhibit-applet.c64
-rw-r--r--applets/inhibit/meson.build4
-rw-r--r--applets/power-profiles/Makefile.am3
-rw-r--r--applets/power-profiles/meson.build4
-rw-r--r--applets/power-profiles/power-profiles-applet.c1
-rw-r--r--configure.ac7
-rw-r--r--meson.build2
-rw-r--r--src/Makefile.am29
-rw-r--r--src/egg-console-kit.c266
-rw-r--r--src/egg-console-kit.h8
-rw-r--r--src/gpm-backlight.c150
-rw-r--r--src/gpm-backlight.h4
-rw-r--r--src/gpm-kbd-backlight.c126
-rw-r--r--src/gpm-main.c137
-rw-r--r--src/gpm-manager.c71
-rw-r--r--src/gpm-manager.h5
-rw-r--r--src/gpm-networkmanager.c74
-rw-r--r--src/gpm-phone.c84
-rw-r--r--src/gpm-screensaver.c124
-rw-r--r--src/gpm-session.c261
-rw-r--r--src/gpm-statistics.c3
-rw-r--r--src/meson.build24
27 files changed, 1093 insertions, 450 deletions
diff --git a/.build.yml b/.build.yml
index 64e4f3d..21f7288 100644
--- a/.build.yml
+++ b/.build.yml
@@ -6,7 +6,6 @@ requires:
# Useful URL: https://git.archlinux.org/svntogit/community.git/tree/mate-power-manager
- autoconf-archive
- clang
- - dbus-glib
- file
- gcc
- git
@@ -38,7 +37,6 @@ requires:
- gcc
- git
- libcanberra-gtk3-dev
- - libdbus-glib-1-dev
- libgcrypt20-dev
- libglib2.0-dev
- libgtk-3-dev
@@ -71,7 +69,6 @@ requires:
- clang
- clang-analyzer
- cppcheck-htmlreport
- - dbus-glib-devel
- desktop-file-utils
- gcc
- git
@@ -102,7 +99,6 @@ requires:
- gcc
- git
- libcanberra-gtk3-dev
- - libdbus-glib-1-dev
- libgcrypt20-dev
- libglib2.0-dev
- libgtk-3-dev
diff --git a/applets/brightness/Makefile.am b/applets/brightness/Makefile.am
index 049a6c4..676de5d 100644
--- a/applets/brightness/Makefile.am
+++ b/applets/brightness/Makefile.am
@@ -3,7 +3,6 @@ NULL =
AM_CPPFLAGS = \
-I. -I$(srcdir) \
$(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
$(CAIRO_CFLAGS) \
$(PANEL_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
@@ -36,7 +35,6 @@ libmate_brightness_applet_la_SOURCES = \
libmate_brightness_applet_la_CFLAGS = $(AM_CFLAGS)
libmate_brightness_applet_la_LDFLAGS = -module -avoid-version
libmate_brightness_applet_la_LIBADD = \
- $(DBUS_LIBS) \
$(CAIRO_LIBS) \
$(PANEL_LIBS)
else
@@ -50,7 +48,6 @@ mate_brightness_applet_SOURCES = \
gpm-common.h
mate_brightness_applet_CFLAGS = $(AM_CFLAGS)
mate_brightness_applet_LDADD = \
- $(DBUS_LIBS) \
$(CAIRO_LIBS) \
$(PANEL_LIBS)
endif
diff --git a/applets/brightness/brightness-applet.c b/applets/brightness/brightness-applet.c
index 73242bc..b2ead95 100644
--- a/applets/brightness/brightness-applet.c
+++ b/applets/brightness/brightness-applet.c
@@ -34,7 +34,6 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include <glib-object.h>
-#include <dbus/dbus-glib.h>
#include "gpm-common.h"
@@ -56,8 +55,8 @@ typedef struct{
GdkPixbuf *icon;
gint icon_width, icon_height;
/* connection to g-p-m */
- DBusGProxy *proxy;
- DBusGConnection *connection;
+ GDBusProxy *proxy;
+ GDBusConnection *connection;
guint bus_watch_id;
guint level;
/* a cache for panel size */
@@ -123,7 +122,7 @@ static gboolean
gpm_applet_get_brightness (GpmBrightnessApplet *applet)
{
GError *error = NULL;
- gboolean ret;
+ GVariant *result;
guint policy_brightness;
if (applet->proxy == NULL) {
@@ -131,22 +130,28 @@ gpm_applet_get_brightness (GpmBrightnessApplet *applet)
return FALSE;
}
- ret = dbus_g_proxy_call (applet->proxy, "GetBrightness", &error,
- G_TYPE_INVALID,
- G_TYPE_UINT, &policy_brightness,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (applet->proxy,
+ "GetBrightness",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
if (error) {
g_debug ("ERROR: %s\n", error->message);
g_error_free (error);
}
- if (ret) {
+ if (result != NULL) {
+ g_variant_get (result, "(u)", &policy_brightness);
+ g_variant_unref (result);
applet->level = policy_brightness;
+ return TRUE;
} else {
/* abort as the DBUS method failed */
g_warning ("GetBrightness failed!\n");
}
- return ret;
+ return FALSE;
}
/**
@@ -157,6 +162,7 @@ static gboolean
gpm_applet_set_brightness (GpmBrightnessApplet *applet)
{
GError *error = NULL;
+ GVariant *result;
gboolean ret;
if (applet->proxy == NULL) {
@@ -164,10 +170,16 @@ gpm_applet_set_brightness (GpmBrightnessApplet *applet)
return FALSE;
}
- ret = dbus_g_proxy_call (applet->proxy, "SetBrightness", &error,
- G_TYPE_UINT, applet->level,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (applet->proxy,
+ "SetBrightness",
+ g_variant_new ("(u)", applet->level),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ ret = (result != NULL);
+ if (result != NULL)
+ g_variant_unref (result);
if (error) {
g_debug ("ERROR: %s", error->message);
g_error_free (error);
@@ -878,6 +890,10 @@ gpm_applet_destroy_cb (GtkWidget *widget)
}
g_bus_unwatch_name (applet->bus_watch_id);
+ if (applet->proxy != NULL)
+ g_object_unref (applet->proxy);
+ if (applet->connection != NULL)
+ g_object_unref (applet->connection);
if (applet->icon != NULL)
g_object_unref (applet->icon);
}
@@ -893,10 +909,18 @@ gpm_brightness_applet_class_init (GpmBrightnessAppletClass *class)
}
static void
-brightness_changed_cb (DBusGProxy *proxy,
- guint brightness,
+brightness_changed_cb (GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
GpmBrightnessApplet *applet)
{
+ guint brightness;
+
+ if (g_strcmp0 (signal_name, "BrightnessChanged") != 0)
+ return;
+
+ g_variant_get (parameters, "(u)", &brightness);
g_debug ("BrightnessChanged detected: %u\n", brightness);
applet->level = brightness;
}
@@ -912,7 +936,7 @@ gpm_brightness_applet_dbus_connect (GpmBrightnessApplet *applet)
if (applet->connection == NULL) {
g_debug ("get connection\n");
g_clear_error (&error);
- applet->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ applet->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
if (error != NULL) {
g_warning ("Could not connect to DBUS daemon: %s", error->message);
g_error_free (error);
@@ -923,22 +947,22 @@ gpm_brightness_applet_dbus_connect (GpmBrightnessApplet *applet)
if (applet->proxy == NULL) {
g_debug ("get proxy\n");
g_clear_error (&error);
- applet->proxy = dbus_g_proxy_new_for_name_owner (applet->connection,
- GPM_DBUS_SERVICE,
- GPM_DBUS_PATH_BACKLIGHT,
- GPM_DBUS_INTERFACE_BACKLIGHT,
- &error);
+ applet->proxy = g_dbus_proxy_new_sync (applet->connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ GPM_DBUS_SERVICE,
+ GPM_DBUS_PATH_BACKLIGHT,
+ GPM_DBUS_INTERFACE_BACKLIGHT,
+ NULL,
+ &error);
if (error != NULL) {
g_warning ("Cannot connect, maybe the daemon is not running: %s\n", error->message);
g_error_free (error);
applet->proxy = NULL;
return FALSE;
}
- dbus_g_proxy_add_signal (applet->proxy, "BrightnessChanged",
- G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (applet->proxy, "BrightnessChanged",
- G_CALLBACK (brightness_changed_cb),
- applet, NULL);
+ g_signal_connect (applet->proxy, "g-signal",
+ G_CALLBACK (brightness_changed_cb), applet);
/* reset, we might be starting race */
applet->call_worked = gpm_applet_get_brightness (applet);
}
diff --git a/applets/brightness/meson.build b/applets/brightness/meson.build
index 896eef2..8852a05 100644
--- a/applets/brightness/meson.build
+++ b/applets/brightness/meson.build
@@ -23,8 +23,6 @@ if enable_applets_inprocess
glib,
cairo,
notify,
- dbus,
- dbusglib,
matepanel
],
include_directories : config_inc,
@@ -40,8 +38,6 @@ else
glib,
cairo,
notify,
- dbus,
- dbusglib,
matepanel
],
include_directories : config_inc,
diff --git a/applets/inhibit/Makefile.am b/applets/inhibit/Makefile.am
index b6eca59..6d62fef 100644
--- a/applets/inhibit/Makefile.am
+++ b/applets/inhibit/Makefile.am
@@ -3,7 +3,6 @@ NULL =
AM_CPPFLAGS = \
-I. -I$(srcdir) \
$(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
$(CAIRO_CFLAGS) \
$(PANEL_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
@@ -36,7 +35,6 @@ libmate_inhibit_applet_la_SOURCES = \
libmate_inhibit_applet_la_CFLAGS = $(AM_CFLAGS)
libmate_inhibit_applet_la_LDFLAGS = -module -avoid-version
libmate_inhibit_applet_la_LIBADD = \
- $(DBUS_LIBS) \
$(CAIRO_LIBS) \
$(PANEL_LIBS)
else
@@ -50,7 +48,6 @@ mate_inhibit_applet_SOURCES = \
gpm-common.h
mate_inhibit_applet_CFLAGS = $(AM_CFLAGS)
mate_inhibit_applet_LDADD = \
- $(DBUS_LIBS) \
$(CAIRO_LIBS) \
$(PANEL_LIBS)
endif
diff --git a/applets/inhibit/inhibit-applet.c b/applets/inhibit/inhibit-applet.c
index 74ddd6e..7a2bea3 100644
--- a/applets/inhibit/inhibit-applet.c
+++ b/applets/inhibit/inhibit-applet.c
@@ -33,7 +33,6 @@
#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib/gi18n.h>
-#include <dbus/dbus-glib.h>
#include "gpm-common.h"
@@ -51,8 +50,8 @@ typedef struct{
/* the icon */
GtkWidget *image;
/* connection to g-p-m */
- DBusGProxy *proxy;
- DBusGConnection *connection;
+ GDBusProxy *proxy;
+ GDBusConnection *connection;
guint bus_watch_id;
guint level;
/* a cache for panel size */
@@ -97,6 +96,7 @@ gpm_applet_inhibit (GpmInhibitApplet *applet,
guint *cookie)
{
GError *error = NULL;
+ GVariant *result;
gboolean ret;
g_return_val_if_fail (cookie != NULL, FALSE);
@@ -106,14 +106,22 @@ gpm_applet_inhibit (GpmInhibitApplet *applet,
return FALSE;
}
- ret = dbus_g_proxy_call (applet->proxy, "Inhibit", &error,
- G_TYPE_STRING, appname,
- G_TYPE_UINT, 0, /* xid */
- G_TYPE_STRING, reason,
- G_TYPE_UINT, 1+2+4+8, /* logoff, switch, suspend, and idle */
- G_TYPE_INVALID,
- G_TYPE_UINT, cookie,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (applet->proxy,
+ "Inhibit",
+ g_variant_new ("(susu)",
+ appname,
+ 0,
+ reason,
+ 1+2+4+8),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ ret = (result != NULL);
+ if (result != NULL) {
+ g_variant_get (result, "(u)", cookie);
+ g_variant_unref (result);
+ }
if (error) {
g_debug ("ERROR: %s", error->message);
g_error_free (error);
@@ -132,6 +140,7 @@ gpm_applet_uninhibit (GpmInhibitApplet *applet,
guint cookie)
{
GError *error = NULL;
+ GVariant *result;
gboolean ret;
if (applet->proxy == NULL) {
@@ -139,10 +148,16 @@ gpm_applet_uninhibit (GpmInhibitApplet *applet,
return FALSE;
}
- ret = dbus_g_proxy_call (applet->proxy, "Uninhibit", &error,
- G_TYPE_UINT, cookie,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (applet->proxy,
+ "Uninhibit",
+ g_variant_new ("(u)", cookie),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ ret = (result != NULL);
+ if (result != NULL)
+ g_variant_unref (result);
if (error) {
g_debug ("ERROR: %s", error->message);
g_error_free (error);
@@ -345,6 +360,10 @@ gpm_applet_destroy_cb (GtkWidget *widget)
GpmInhibitApplet *applet = GPM_INHIBIT_APPLET(widget);
g_bus_unwatch_name (applet->bus_watch_id);
+ if (applet->proxy != NULL)
+ g_object_unref (applet->proxy);
+ if (applet->connection != NULL)
+ g_object_unref (applet->connection);
}
/**
@@ -368,7 +387,7 @@ gpm_inhibit_applet_dbus_connect (GpmInhibitApplet *applet)
if (applet->connection == NULL) {
g_debug ("get connection\n");
g_clear_error (&error);
- applet->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ applet->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
if (error != NULL) {
g_warning ("Could not connect to DBUS daemon: %s", error->message);
g_error_free (error);
@@ -379,11 +398,14 @@ gpm_inhibit_applet_dbus_connect (GpmInhibitApplet *applet)
if (applet->proxy == NULL) {
g_debug ("get proxy\n");
g_clear_error (&error);
- applet->proxy = dbus_g_proxy_new_for_name_owner (applet->connection,
- GS_DBUS_SERVICE,
- GS_DBUS_PATH,
- GS_DBUS_INTERFACE,
- &error);
+ applet->proxy = g_dbus_proxy_new_sync (applet->connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ GS_DBUS_SERVICE,
+ GS_DBUS_PATH,
+ GS_DBUS_INTERFACE,
+ NULL,
+ &error);
if (error != NULL) {
g_warning ("Cannot connect, maybe the daemon is not running: %s\n", error->message);
g_error_free (error);
diff --git a/applets/inhibit/meson.build b/applets/inhibit/meson.build
index 98dfbc1..2d93252 100644
--- a/applets/inhibit/meson.build
+++ b/applets/inhibit/meson.build
@@ -23,8 +23,6 @@ if enable_applets_inprocess
glib,
cairo,
notify,
- dbus,
- dbusglib,
matepanel
],
include_directories : config_inc,
@@ -40,8 +38,6 @@ else
glib,
cairo,
notify,
- dbus,
- dbusglib,
matepanel
],
include_directories : config_inc,
diff --git a/applets/power-profiles/Makefile.am b/applets/power-profiles/Makefile.am
index 041afc9..58acc6f 100644
--- a/applets/power-profiles/Makefile.am
+++ b/applets/power-profiles/Makefile.am
@@ -3,7 +3,6 @@ NULL =
AM_CPPFLAGS = \
-I. -I$(srcdir) \
$(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
$(CAIRO_CFLAGS) \
$(PANEL_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
@@ -36,7 +35,6 @@ libmate_power_profiles_applet_la_SOURCES = \
libmate_power_profiles_applet_la_CFLAGS = $(AM_CFLAGS)
libmate_power_profiles_applet_la_LDFLAGS = -module -avoid-version
libmate_power_profiles_applet_la_LIBADD = \
- $(DBUS_LIBS) \
$(CAIRO_LIBS) \
$(PANEL_LIBS)
else
@@ -50,7 +48,6 @@ mate_power_profiles_applet_SOURCES = \
gpm-common.h
mate_power_profiles_applet_CFLAGS = $(AM_CFLAGS)
mate_power_profiles_applet_LDADD = \
- $(DBUS_LIBS) \
$(CAIRO_LIBS) \
$(PANEL_LIBS)
endif
diff --git a/applets/power-profiles/meson.build b/applets/power-profiles/meson.build
index 1d16402..753a3cb 100644
--- a/applets/power-profiles/meson.build
+++ b/applets/power-profiles/meson.build
@@ -23,8 +23,6 @@ if enable_applets_inprocess
glib,
cairo,
notify,
- dbus,
- dbusglib,
matepanel
],
include_directories : config_inc,
@@ -40,8 +38,6 @@ else
glib,
cairo,
notify,
- dbus,
- dbusglib,
matepanel
],
include_directories : config_inc,
diff --git a/applets/power-profiles/power-profiles-applet.c b/applets/power-profiles/power-profiles-applet.c
index e3bb810..b26fec1 100644
--- a/applets/power-profiles/power-profiles-applet.c
+++ b/applets/power-profiles/power-profiles-applet.c
@@ -31,7 +31,6 @@
#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib/gi18n.h>
-#include <dbus/dbus-glib.h>
#include "gpm-common.h"
diff --git a/configure.ac b/configure.ac
index e659caf..8836a00 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,8 +71,6 @@ GDK_REQUIRED=3.22.0
GTK_REQUIRED=3.22.0
LIBSECRET_REQUIRED=0.11
GNOME_KEYRING_REQUIRED=3.0.0
-DBUS_REQUIRED=1.0
-DBUS_GLIB_REQUIRED=0.70
LIBNOTIFY_REQUIRED=0.7.0
CAIRO_REQUIRED=1.0.0
MATE_DESKTOP_REQUIRED=1.27.1
@@ -89,11 +87,6 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 gio-2.0 >= $GIO_R
PKG_CHECK_MODULES(CANBERRA, libcanberra-gtk3 >= $CANBERRA_REQUIRED)
-PKG_CHECK_MODULES(DBUS,[
- dbus-glib-1 >= $DBUS_GLIB_REQUIRED
- dbus-1 >= $DBUS_REQUIRED
- gthread-2.0])
-
PKG_CHECK_MODULES(CAIRO, [
gtk+-3.0 >= $GTK_REQUIRED
cairo >= $CAIRO_REQUIRED])
diff --git a/meson.build b/meson.build
index 4b2b940..6158d42 100644
--- a/meson.build
+++ b/meson.build
@@ -100,8 +100,6 @@ xrandr = dependency('xrandr', version : '>= 1.3.0')
xproto = dependency('xproto', version : '>= 7.0.15')
x11 = dependency('x11', version : '>= 1.3.0')
xext = dependency('xext', version : '>= 1.3.0')
-dbus = dependency('dbus-1', version : '>= 1.0')
-dbusglib = dependency('dbus-glib-1', version : '>= 0.70')
notify = dependency('libnotify', version : '>= 0.7.0')
canberra = dependency('libcanberra-gtk3', version : '>= 0.10')
matepanel = dependency('libmatepanelapplet-4.0', version : '>= 1.17.0',required: enable_applet)
diff --git a/src/Makefile.am b/src/Makefile.am
index da49dab..9a4f601 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,7 +12,6 @@ EXTRA_DIST = \
AM_CPPFLAGS = \
$(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
$(CAIRO_CFLAGS) \
$(LIBSECRET_CFLAGS) \
$(MATE_DESKTOP_CFLAGS) \
@@ -113,7 +112,6 @@ mate_power_statistics_LDADD = \
$(X11_LIBS) \
$(UPOWER_LIBS) \
$(CAIRO_LIBS) \
- $(DBUS_LIBS) \
-lm
mate_power_statistics_CFLAGS = \
@@ -139,7 +137,6 @@ mate_power_preferences_LDADD = \
$(GLIB_LIBS) \
$(X11_LIBS) \
$(CAIRO_LIBS) \
- $(DBUS_LIBS) \
$(GPM_EXTRA_LIBS) \
$(UPOWER_LIBS) \
-lm
@@ -202,7 +199,6 @@ mate_power_manager_LDADD = \
$(MATE_DESKTOP_LIBS) \
$(LIBSECRET_LIBS) \
$(KEYRING_LIBS) \
- $(DBUS_LIBS) \
$(X11_LIBS) \
$(CANBERRA_LIBS) \
$(LIBNOTIFY_LIBS) \
@@ -268,7 +264,6 @@ mate_power_self_test_LDADD = \
$(KEYRING_LIBS) \
$(GSTREAMER_LIBS) \
$(UPOWER_LIBS) \
- $(DBUS_LIBS) \
$(X11_LIBS) \
$(LIBNOTIFY_LIBS) \
$(GPM_EXTRA_LIBS) \
@@ -282,9 +277,6 @@ mate_power_self_test_CFLAGS = \
endif
BUILT_SOURCES = \
- org.mate.PowerManager.h \
- org.mate.PowerManager.Backlight.h \
- org.mate.PowerManager.KbdBacklight.h \
gpm-marshal.c \
gpm-marshal.h \
$(NULL)
@@ -296,27 +288,6 @@ gpm-marshal.c: gpm-marshal.list
gpm-marshal.h: gpm-marshal.list
@GLIB_GENMARSHAL@ $< --prefix=gpm_marshal --header > $@
-org.mate.PowerManager.h: org.mate.PowerManager.xml
- $(LIBTOOL) --mode=execute dbus-binding-tool \
- --prefix=gpm_manager \
- --mode=glib-server \
- --output=org.mate.PowerManager.h \
- $(srcdir)/org.mate.PowerManager.xml
-
-org.mate.PowerManager.Backlight.h: org.mate.PowerManager.Backlight.xml
- $(LIBTOOL) --mode=execute dbus-binding-tool \
- --prefix=gpm_backlight \
- --mode=glib-server \
- --output=org.mate.PowerManager.Backlight.h \
- $(srcdir)/org.mate.PowerManager.Backlight.xml
-
-org.mate.PowerManager.KbdBacklight.h: org.mate.PowerManager.KbdBacklight.xml
- $(LIBTOOL) --mode=execute dbus-binding-tool \
- --prefix=gpm_kbd_backlight \
- --mode=glib-server \
- --output=org.mate.PowerManager.KbdBacklight.h \
- $(srcdir)/org.mate.PowerManager.KbdBacklight.xml
-
clean-local:
rm -f *~
rm -f gpm-marshal.c gpm-marshal.h
diff --git a/src/egg-console-kit.c b/src/egg-console-kit.c
index 5c1780e..c430ed8 100644
--- a/src/egg-console-kit.c
+++ b/src/egg-console-kit.c
@@ -26,8 +26,7 @@
#include <unistd.h>
#include <stdio.h>
#include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
+#include <gio/gio.h>
#include "egg-console-kit.h"
@@ -44,9 +43,9 @@ static void egg_console_kit_finalize (GObject *object);
struct EggConsoleKitPrivate
{
- DBusGConnection *connection;
- DBusGProxy *proxy_manager;
- DBusGProxy *proxy_session;
+ GDBusConnection *connection;
+ GDBusProxy *proxy_manager;
+ GDBusProxy *proxy_session;
gchar *session_id;
};
@@ -66,14 +65,23 @@ G_DEFINE_TYPE_WITH_PRIVATE (EggConsoleKit, egg_console_kit, G_TYPE_OBJECT)
gboolean
egg_console_kit_restart (EggConsoleKit *console, GError **error)
{
+ GVariant *result;
gboolean ret;
GError *error_local = NULL;
g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
- ret = dbus_g_proxy_call (console->priv->proxy_manager, "Restart", &error_local,
- G_TYPE_INVALID, G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (console->priv->proxy_manager,
+ "Restart",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error_local);
+ ret = (result != NULL);
+ if (result != NULL)
+ g_variant_unref (result);
if (!ret) {
g_warning ("Couldn't restart: %s", error_local->message);
if (error != NULL)
@@ -89,14 +97,23 @@ egg_console_kit_restart (EggConsoleKit *console, GError **error)
gboolean
egg_console_kit_stop (EggConsoleKit *console, GError **error)
{
+ GVariant *result;
gboolean ret;
GError *error_local = NULL;
g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
- ret = dbus_g_proxy_call (console->priv->proxy_manager, "Stop", &error_local,
- G_TYPE_INVALID, G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (console->priv->proxy_manager,
+ "Stop",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error_local);
+ ret = (result != NULL);
+ if (result != NULL)
+ g_variant_unref (result);
if (!ret) {
g_warning ("Couldn't stop: %s", error_local->message);
if (error != NULL)
@@ -112,15 +129,23 @@ egg_console_kit_stop (EggConsoleKit *console, GError **error)
gboolean
egg_console_kit_suspend (EggConsoleKit *console, GError **error)
{
+ GVariant *result;
gboolean ret;
GError *error_local = NULL;
g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
- ret = dbus_g_proxy_call (console->priv->proxy_manager, "Suspend", &error_local,
- G_TYPE_BOOLEAN, TRUE,
- G_TYPE_INVALID, G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (console->priv->proxy_manager,
+ "Suspend",
+ g_variant_new ("(b)", TRUE),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error_local);
+ ret = (result != NULL);
+ if (result != NULL)
+ g_variant_unref (result);
if (!ret) {
g_warning ("Couldn't suspend: %s", error_local->message);
if (error != NULL)
@@ -136,15 +161,23 @@ egg_console_kit_suspend (EggConsoleKit *console, GError **error)
gboolean
egg_console_kit_hibernate (EggConsoleKit *console, GError **error)
{
+ GVariant *result;
gboolean ret;
GError *error_local = NULL;
g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
- ret = dbus_g_proxy_call (console->priv->proxy_manager, "Hibernate", &error_local,
- G_TYPE_BOOLEAN, TRUE,
- G_TYPE_INVALID, G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (console->priv->proxy_manager,
+ "Hibernate",
+ g_variant_new ("(b)", TRUE),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error_local);
+ ret = (result != NULL);
+ if (result != NULL)
+ g_variant_unref (result);
if (!ret) {
g_warning ("Couldn't hibernate: %s", error_local->message);
if (error != NULL)
@@ -160,15 +193,25 @@ egg_console_kit_hibernate (EggConsoleKit *console, GError **error)
gboolean
egg_console_kit_can_stop (EggConsoleKit *console, gboolean *can_stop, GError **error)
{
+ GVariant *result;
gboolean ret;
GError *error_local = NULL;
g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
- ret = dbus_g_proxy_call (console->priv->proxy_manager, "CanStop", &error_local,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, can_stop, G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (console->priv->proxy_manager,
+ "CanStop",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error_local);
+ ret = (result != NULL);
+ if (result != NULL) {
+ g_variant_get (result, "(b)", can_stop);
+ g_variant_unref (result);
+ }
if (!ret) {
g_warning ("Couldn't do CanStop: %s", error_local->message);
if (error != NULL)
@@ -187,15 +230,25 @@ egg_console_kit_can_stop (EggConsoleKit *console, gboolean *can_stop, GError **e
gboolean
egg_console_kit_can_restart (EggConsoleKit *console, gboolean *can_restart, GError **error)
{
+ GVariant *result;
gboolean ret;
GError *error_local = NULL;
g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
- ret = dbus_g_proxy_call (console->priv->proxy_manager, "CanRestart", &error_local,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, can_restart, G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (console->priv->proxy_manager,
+ "CanRestart",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error_local);
+ ret = (result != NULL);
+ if (result != NULL) {
+ g_variant_get (result, "(b)", can_restart);
+ g_variant_unref (result);
+ }
if (!ret) {
g_warning ("Couldn't do CanRestart: %s", error_local->message);
if (error != NULL)
@@ -215,26 +268,35 @@ gboolean
egg_console_kit_can_suspend (EggConsoleKit *console, gboolean *can_suspend, GError **error)
{
GError *error_local = NULL;
+ GVariant *result;
gboolean ret;
- gchar *retval;
+ const gchar *retval;
g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
- ret = dbus_g_proxy_call (console->priv->proxy_manager, "CanSuspend", &error_local,
- G_TYPE_INVALID,
- G_TYPE_STRING, &retval, G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (console->priv->proxy_manager,
+ "CanSuspend",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error_local);
+ ret = (result != NULL);
+ if (result != NULL)
+ g_variant_get (result, "(&s)", &retval);
if (!ret) {
g_warning ("Couldn't do CanSuspend: %s", error_local->message);
if (error != NULL)
*error = g_error_new (1, 0, "%s", error_local->message);
g_error_free (error_local);
+ retval = "";
}
*can_suspend = g_strcmp0 (retval, "yes") == 0 ||
g_strcmp0 (retval, "challenge") == 0;
-
- g_free (retval);
+ if (result != NULL)
+ g_variant_unref (result);
return ret;
}
@@ -246,24 +308,35 @@ gboolean
egg_console_kit_can_hibernate (EggConsoleKit *console, gboolean *can_hibernate, GError **error)
{
GError *error_local = NULL;
+ GVariant *result;
gboolean ret;
- gchar *retval;
+ const gchar *retval;
g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
- ret = dbus_g_proxy_call (console->priv->proxy_manager, "CanHibernate", &error_local,
- G_TYPE_INVALID,
- G_TYPE_STRING, &retval, G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (console->priv->proxy_manager,
+ "CanHibernate",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error_local);
+ ret = (result != NULL);
+ if (result != NULL)
+ g_variant_get (result, "(&s)", &retval);
if (!ret) {
g_warning ("Couldn't do CanHibernate: %s", error_local->message);
if (error != NULL)
*error = g_error_new (1, 0, "%s", error_local->message);
g_error_free (error_local);
+ retval = "";
}
*can_hibernate = g_strcmp0 (retval, "yes") == 0 ||
g_strcmp0 (retval, "challenge") == 0;
+ if (result != NULL)
+ g_variant_unref (result);
return ret;
}
@@ -273,13 +346,15 @@ egg_console_kit_can_hibernate (EggConsoleKit *console, gboolean *can_hibernate,
* Return value: Returns whether the session is local
**/
gboolean
-egg_console_kit_is_local (EggConsoleKit *console)
+egg_console_kit_is_local (EggConsoleKit *console, gboolean *is_local, GError **error)
{
+ GVariant *result = NULL;
gboolean ret = FALSE;
- gboolean value = FALSE;
- GError *error = NULL;
+ GError *error_local = NULL;
g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
+ g_return_val_if_fail (is_local != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* maybe console kit does not know about our session */
if (console->priv->proxy_session == NULL) {
@@ -288,17 +363,26 @@ egg_console_kit_is_local (EggConsoleKit *console)
}
/* is our session local */
- ret = dbus_g_proxy_call (console->priv->proxy_session, "IsLocal", &error, G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &value, G_TYPE_INVALID);
- if (!ret) {
- g_warning ("IsLocal failed: %s", error->message);
- g_error_free (error);
+ result = g_dbus_proxy_call_sync (console->priv->proxy_session,
+ "IsLocal",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error_local);
+ if (result == NULL) {
+ if (error != NULL)
+ *error = g_error_new (1, 0, "IsLocal failed: %s", error_local->message);
+ g_error_free (error_local);
goto out;
}
+ g_variant_get (result, "(b)", is_local);
- /* return value only if we successed */
- ret = value;
+ /* success */
+ ret = TRUE;
out:
+ if (result != NULL)
+ g_variant_unref (result);
return ret;
}
@@ -308,13 +392,15 @@ out:
* Return value: Returns whether the session is active on the Seat that it is attached to.
**/
gboolean
-egg_console_kit_is_active (EggConsoleKit *console)
+egg_console_kit_is_active (EggConsoleKit *console, gboolean *is_active, GError **error)
{
+ GVariant *result = NULL;
gboolean ret = FALSE;
- gboolean value = FALSE;
- GError *error = NULL;
+ GError *error_local = NULL;
g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
+ g_return_val_if_fail (is_active != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* maybe console kit does not know about our session */
if (console->priv->proxy_session == NULL) {
@@ -323,17 +409,26 @@ egg_console_kit_is_active (EggConsoleKit *console)
}
/* is our session active */
- ret = dbus_g_proxy_call (console->priv->proxy_session, "IsActive", &error, G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &value, G_TYPE_INVALID);
- if (!ret) {
- g_warning ("IsActive failed: %s", error->message);
- g_error_free (error);
+ result = g_dbus_proxy_call_sync (console->priv->proxy_session,
+ "IsActive",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error_local);
+ if (result == NULL) {
+ if (error != NULL)
+ *error = g_error_new (1, 0, "IsActive failed: %s", error_local->message);
+ g_error_free (error_local);
goto out;
}
+ g_variant_get (result, "(b)", is_active);
- /* return value only if we successed */
- ret = value;
+ /* success */
+ ret = TRUE;
out:
+ if (result != NULL)
+ g_variant_unref (result);
return ret;
}
@@ -341,8 +436,18 @@ out:
* egg_console_kit_active_changed_cb:
**/
static void
-egg_console_kit_active_changed_cb (DBusGProxy *proxy, gboolean active, EggConsoleKit *console)
+egg_console_kit_active_changed_cb (GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ EggConsoleKit *console)
{
+ gboolean active;
+
+ if (g_strcmp0 (signal_name, "ActiveChanged") != 0)
+ return;
+
+ g_variant_get (parameters, "(b)", &active);
g_debug ("emitting active: %i", active);
g_signal_emit (console, signals [EGG_CONSOLE_KIT_ACTIVE_CHANGED], 0, active);
}
@@ -371,16 +476,20 @@ egg_console_kit_class_init (EggConsoleKitClass *klass)
static void
egg_console_kit_init (EggConsoleKit *console)
{
+ GVariant *result;
gboolean ret;
GError *error = NULL;
guint32 pid;
+ const gchar *session_id;
console->priv = egg_console_kit_get_instance_private (console);
+ console->priv->connection = NULL;
console->priv->proxy_manager = NULL;
+ console->priv->proxy_session = NULL;
console->priv->session_id = NULL;
/* connect to D-Bus */
- console->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ console->priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (console->priv->connection == NULL) {
g_warning ("Failed to connect to the D-Bus daemon: %s", error->message);
g_error_free (error);
@@ -388,39 +497,56 @@ egg_console_kit_init (EggConsoleKit *console)
}
/* connect to ConsoleKit */
- console->priv->proxy_manager =
- dbus_g_proxy_new_for_name (console->priv->connection, CONSOLEKIT_NAME,
- CONSOLEKIT_MANAGER_PATH, CONSOLEKIT_MANAGER_INTERFACE);
+ console->priv->proxy_manager = g_dbus_proxy_new_sync (console->priv->connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ CONSOLEKIT_NAME,
+ CONSOLEKIT_MANAGER_PATH,
+ CONSOLEKIT_MANAGER_INTERFACE,
+ NULL,
+ &error);
if (console->priv->proxy_manager == NULL) {
- g_warning ("cannot connect to ConsoleKit");
+ g_warning ("cannot connect to ConsoleKit: %s", error->message);
+ g_error_free (error);
goto out;
}
/* get the session we are running in */
pid = getpid ();
- ret = dbus_g_proxy_call (console->priv->proxy_manager, "GetSessionForUnixProcess", &error,
- G_TYPE_UINT, pid,
- G_TYPE_INVALID,
- DBUS_TYPE_G_OBJECT_PATH, &console->priv->session_id,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (console->priv->proxy_manager,
+ "GetSessionForUnixProcess",
+ g_variant_new ("(u)", pid),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ ret = (result != NULL);
if (!ret) {
g_warning ("Failed to get session for pid %u: %s", pid, error->message);
g_error_free (error);
goto out;
}
+ g_variant_get (result, "(&o)", &session_id);
+ console->priv->session_id = g_strdup (session_id);
+ g_variant_unref (result);
g_debug ("ConsoleKit session ID: %s", console->priv->session_id);
/* connect to session */
- console->priv->proxy_session =
- dbus_g_proxy_new_for_name (console->priv->connection, CONSOLEKIT_NAME,
- console->priv->session_id, CONSOLEKIT_SESSION_INTERFACE);
+ console->priv->proxy_session = g_dbus_proxy_new_sync (console->priv->connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ CONSOLEKIT_NAME,
+ console->priv->session_id,
+ CONSOLEKIT_SESSION_INTERFACE,
+ NULL,
+ &error);
if (console->priv->proxy_session == NULL) {
- g_warning ("cannot connect to: %s", console->priv->session_id);
+ g_warning ("cannot connect to: %s: %s", console->priv->session_id, error->message);
+ g_error_free (error);
goto out;
}
- dbus_g_proxy_add_signal (console->priv->proxy_session, "ActiveChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (console->priv->proxy_session, "ActiveChanged",
- G_CALLBACK (egg_console_kit_active_changed_cb), console, NULL);
+ g_signal_connect (console->priv->proxy_session, "g-signal",
+ G_CALLBACK (egg_console_kit_active_changed_cb), console);
out:
return;
@@ -444,6 +570,8 @@ egg_console_kit_finalize (GObject *object)
g_object_unref (console->priv->proxy_manager);
if (console->priv->proxy_session != NULL)
g_object_unref (console->priv->proxy_session);
+ if (console->priv->connection != NULL)
+ g_object_unref (console->priv->connection);
g_free (console->priv->session_id);
G_OBJECT_CLASS (egg_console_kit_parent_class)->finalize (object);
diff --git a/src/egg-console-kit.h b/src/egg-console-kit.h
index 0074d0c..b241517 100644
--- a/src/egg-console-kit.h
+++ b/src/egg-console-kit.h
@@ -53,8 +53,12 @@ typedef struct
GType egg_console_kit_get_type (void);
EggConsoleKit *egg_console_kit_new (void);
-gboolean egg_console_kit_is_local (EggConsoleKit *console);
-gboolean egg_console_kit_is_active (EggConsoleKit *console);
+gboolean egg_console_kit_is_local (EggConsoleKit *console,
+ gboolean *is_local,
+ GError **error);
+gboolean egg_console_kit_is_active (EggConsoleKit *console,
+ gboolean *is_active,
+ GError **error);
gboolean egg_console_kit_stop (EggConsoleKit *console,
GError **error);
gboolean egg_console_kit_restart (EggConsoleKit *console,
diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c
index 6f4ea7c..c0a6637 100644
--- a/src/gpm-backlight.c
+++ b/src/gpm-backlight.c
@@ -38,6 +38,7 @@
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
+#include <gio/gio.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libupower-glib/upower.h>
@@ -50,7 +51,6 @@
#include "gsd-media-keys-window.h"
#include "gpm-dpms.h"
#include "gpm-idle.h"
-#include "gpm-marshal.h"
#include "gpm-icon-names.h"
#include "egg-console-kit.h"
@@ -65,6 +65,8 @@ struct GpmBacklightPrivate
GpmDpms *dpms;
GpmIdle *idle;
EggConsoleKit *console;
+ GDBusConnection *bus_connection;
+ guint bus_object_id;
gboolean can_dim;
gboolean system_is_idle;
GTimer *idle_timer;
@@ -79,8 +81,130 @@ enum {
static guint signals [LAST_SIGNAL] = { 0 };
+static const gchar gpm_backlight_introspection_xml[] =
+ "<node>"
+ " <interface name='org.mate.PowerManager.Backlight'>"
+ " <method name='GetBrightness'>"
+ " <arg type='u' name='percentage_brightness' direction='out'/>"
+ " </method>"
+ " <method name='SetBrightness'>"
+ " <arg type='u' name='percentage_brightness' direction='in'/>"
+ " </method>"
+ " <signal name='BrightnessChanged'>"
+ " <arg type='u' name='percentage_brightness' direction='out'/>"
+ " </signal>"
+ " </interface>"
+ "</node>";
+
G_DEFINE_TYPE_WITH_PRIVATE (GpmBacklight, gpm_backlight, G_TYPE_OBJECT)
+static void
+gpm_backlight_dbus_emit_brightness_changed (GpmBacklight *backlight,
+ guint brightness,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ if (backlight->priv->bus_connection == NULL)
+ return;
+
+ g_dbus_connection_emit_signal (backlight->priv->bus_connection,
+ NULL,
+ GPM_DBUS_PATH_BACKLIGHT,
+ GPM_DBUS_INTERFACE_BACKLIGHT,
+ "BrightnessChanged",
+ g_variant_new ("(u)", brightness),
+ &error);
+ if (error != NULL) {
+ g_warning ("Failed to emit backlight D-Bus signal: %s", error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+gpm_backlight_dbus_method_call (GDBusConnection *connection,
+ G_GNUC_UNUSED const gchar *sender,
+ G_GNUC_UNUSED const gchar *object_path,
+ G_GNUC_UNUSED const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ GpmBacklight *backlight = GPM_BACKLIGHT (user_data);
+ GError *error = NULL;
+ guint brightness;
+
+ if (g_strcmp0 (method_name, "GetBrightness") == 0) {
+ if (gpm_backlight_get_brightness (backlight, &brightness, &error)) {
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(u)", brightness));
+ } else {
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ g_error_free (error);
+ }
+ return;
+ }
+
+ if (g_strcmp0 (method_name, "SetBrightness") == 0) {
+ g_variant_get (parameters, "(u)", &brightness);
+ if (gpm_backlight_set_brightness (backlight, brightness, &error)) {
+ g_dbus_method_invocation_return_value (invocation, NULL);
+ } else {
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ g_error_free (error);
+ }
+ return;
+ }
+
+ g_dbus_method_invocation_return_error (invocation,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ "Method %s is not supported",
+ method_name);
+}
+
+static const GDBusInterfaceVTable gpm_backlight_interface_vtable = {
+ gpm_backlight_dbus_method_call,
+ NULL,
+ NULL,
+ { 0 }
+};
+
+gboolean
+gpm_backlight_register_dbus (GpmBacklight *backlight,
+ GDBusConnection *connection,
+ GError **error)
+{
+ GDBusNodeInfo *node_info;
+
+ g_return_val_if_fail (GPM_IS_BACKLIGHT (backlight), FALSE);
+ g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), FALSE);
+
+ if (backlight->priv->bus_connection != NULL)
+ return TRUE;
+
+ node_info = g_dbus_node_info_new_for_xml (gpm_backlight_introspection_xml, error);
+ if (node_info == NULL)
+ return FALSE;
+
+ backlight->priv->bus_object_id =
+ g_dbus_connection_register_object (connection,
+ GPM_DBUS_PATH_BACKLIGHT,
+ node_info->interfaces[0],
+ &gpm_backlight_interface_vtable,
+ backlight,
+ NULL,
+ error);
+ g_dbus_node_info_unref (node_info);
+
+ if (backlight->priv->bus_object_id == 0)
+ return FALSE;
+
+ backlight->priv->bus_connection = g_object_ref (connection);
+ return TRUE;
+}
+
/**
* gpm_backlight_error_quark:
* Return value: Our personal error quark.
@@ -581,6 +705,7 @@ static void
idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight)
{
gboolean ret;
+ gboolean is_active = TRUE;
GError *error = NULL;
gboolean on_battery;
GpmDpmsMode dpms_mode;
@@ -590,9 +715,17 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight)
return;
/* don't dim or undim the screen unless ConsoleKit/systemd say we are on the active console */
- if (!LOGIND_RUNNING() && !egg_console_kit_is_active (backlight->priv->console)) {
- g_debug ("ignoring as not on active console");
- return;
+ if (!LOGIND_RUNNING ()) {
+ ret = egg_console_kit_is_active (backlight->priv->console, &is_active, &error);
+ if (!ret) {
+ g_warning ("failed to get console active status: %s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+ if (!is_active) {
+ g_debug ("ignoring as not on active console");
+ return;
+ }
}
if (mode == GPM_IDLE_MODE_NORMAL) {
@@ -701,6 +834,11 @@ gpm_backlight_finalize (GObject *object)
g_return_if_fail (object != NULL);
g_return_if_fail (GPM_IS_BACKLIGHT (object));
backlight = GPM_BACKLIGHT (object);
+ if (backlight->priv->bus_connection != NULL) {
+ g_dbus_connection_unregister_object (backlight->priv->bus_connection,
+ backlight->priv->bus_object_id);
+ g_object_unref (backlight->priv->bus_connection);
+ }
g_timer_destroy (backlight->priv->idle_timer);
gtk_widget_destroy (backlight->priv->popup);
@@ -749,9 +887,13 @@ static void
gpm_backlight_init (GpmBacklight *backlight)
{
backlight->priv = gpm_backlight_get_instance_private (backlight);
+ backlight->priv->bus_connection = NULL;
+ backlight->priv->bus_object_id = 0;
/* record our idle time */
backlight->priv->idle_timer = g_timer_new ();
+ g_signal_connect (backlight, "brightness-changed",
+ G_CALLBACK (gpm_backlight_dbus_emit_brightness_changed), NULL);
/* watch for manual brightness changes (for the popup widget) */
backlight->priv->brightness = gpm_brightness_new ();
diff --git a/src/gpm-backlight.h b/src/gpm-backlight.h
index 17cb192..18b0df2 100644
--- a/src/gpm-backlight.h
+++ b/src/gpm-backlight.h
@@ -24,6 +24,7 @@
#ifndef __GPM_BACKLIGHT_H
#define __GPM_BACKLIGHT_H
+#include <gio/gio.h>
#include <glib-object.h>
G_BEGIN_DECLS
@@ -60,6 +61,9 @@ typedef enum
GType gpm_backlight_get_type (void);
GQuark gpm_backlight_error_quark (void);
GpmBacklight *gpm_backlight_new (void);
+gboolean gpm_backlight_register_dbus (GpmBacklight *backlight,
+ GDBusConnection *connection,
+ GError **error);
gboolean gpm_backlight_get_brightness (GpmBacklight *backlight,
guint *brightness,
diff --git a/src/gpm-kbd-backlight.c b/src/gpm-kbd-backlight.c
index bb7e9c0..e192bac 100644
--- a/src/gpm-kbd-backlight.c
+++ b/src/gpm-kbd-backlight.c
@@ -59,8 +59,129 @@ enum {
static guint signals [LAST_SIGNAL] = { 0 };
+static const gchar gpm_kbd_backlight_introspection_xml[] =
+ "<node>"
+ " <interface name='org.mate.PowerManager.KbdBacklight'>"
+ " <method name='GetBrightness'>"
+ " <arg type='u' name='percentage_brightness' direction='out'/>"
+ " </method>"
+ " <method name='SetBrightness'>"
+ " <arg type='u' name='percentage_brightness' direction='in'/>"
+ " </method>"
+ " <signal name='BrightnessChanged'>"
+ " <arg type='u' name='percentage_brightness' direction='out'/>"
+ " </signal>"
+ " </interface>"
+ "</node>";
+
G_DEFINE_TYPE_WITH_PRIVATE (GpmKbdBacklight, gpm_kbd_backlight, G_TYPE_OBJECT)
+static void
+gpm_kbd_backlight_dbus_emit_brightness_changed (GpmKbdBacklight *backlight,
+ guint value,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ if (backlight->priv->bus_connection == NULL)
+ return;
+
+ g_dbus_connection_emit_signal (backlight->priv->bus_connection,
+ NULL,
+ GPM_DBUS_PATH_KBD_BACKLIGHT,
+ GPM_DBUS_INTERFACE_KBD_BACKLIGHT,
+ "BrightnessChanged",
+ g_variant_new ("(u)", value),
+ &error);
+ if (error != NULL) {
+ g_warning ("Failed to emit keyboard backlight D-Bus signal: %s", error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+gpm_kbd_backlight_dbus_method_call (GDBusConnection *connection,
+ G_GNUC_UNUSED const gchar *sender,
+ G_GNUC_UNUSED const gchar *object_path,
+ G_GNUC_UNUSED const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ GpmKbdBacklight *backlight = GPM_KBD_BACKLIGHT (user_data);
+ GError *error = NULL;
+ guint brightness;
+
+ if (g_strcmp0 (method_name, "GetBrightness") == 0) {
+ if (gpm_kbd_backlight_get_brightness (backlight, &brightness, &error)) {
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(u)", brightness));
+ } else {
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ g_error_free (error);
+ }
+ return;
+ }
+
+ if (g_strcmp0 (method_name, "SetBrightness") == 0) {
+ g_variant_get (parameters, "(u)", &brightness);
+ if (gpm_kbd_backlight_set_brightness (backlight, brightness, &error)) {
+ g_dbus_method_invocation_return_value (invocation, NULL);
+ } else {
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ g_error_free (error);
+ }
+ return;
+ }
+
+ g_dbus_method_invocation_return_error (invocation,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ "Method %s is not supported",
+ method_name);
+}
+
+static const GDBusInterfaceVTable gpm_kbd_backlight_interface_vtable = {
+ gpm_kbd_backlight_dbus_method_call,
+ NULL,
+ NULL,
+ { 0 }
+};
+
+void
+gpm_kbd_backlight_register_dbus (GpmKbdBacklight *backlight,
+ GDBusConnection *connection,
+ GError **error)
+{
+ GDBusNodeInfo *node_info;
+
+ g_return_if_fail (GPM_IS_KBD_BACKLIGHT (backlight));
+ g_return_if_fail (G_IS_DBUS_CONNECTION (connection));
+
+ if (backlight->priv->bus_connection != NULL)
+ return;
+
+ node_info = g_dbus_node_info_new_for_xml (gpm_kbd_backlight_introspection_xml, error);
+ if (node_info == NULL)
+ return;
+
+ backlight->priv->bus_object_id =
+ g_dbus_connection_register_object (connection,
+ GPM_DBUS_PATH_KBD_BACKLIGHT,
+ node_info->interfaces[0],
+ &gpm_kbd_backlight_interface_vtable,
+ backlight,
+ NULL,
+ error);
+ g_dbus_node_info_unref (node_info);
+
+ if (backlight->priv->bus_object_id == 0)
+ return;
+
+ backlight->priv->bus_connection = g_object_ref (connection);
+}
+
/**
* gpm_kbd_backlight_error_quark:
* Return value: Our personal error quark.
@@ -602,6 +723,11 @@ gpm_kbd_backlight_init (GpmKbdBacklight *backlight)
GError *error = NULL;
backlight->priv = gpm_kbd_backlight_get_instance_private (backlight);
+ backlight->priv->bus_connection = NULL;
+ backlight->priv->bus_object_id = 0;
+
+ g_signal_connect (backlight, "brightness-changed",
+ G_CALLBACK (gpm_kbd_backlight_dbus_emit_brightness_changed), NULL);
backlight->priv->upower_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
diff --git a/src/gpm-main.c b/src/gpm-main.c
index 1dbf59a..c59bda8 100644
--- a/src/gpm-main.c
+++ b/src/gpm-main.c
@@ -31,18 +31,30 @@
#include <stdlib.h>
#include <errno.h>
#include <locale.h>
+#include <gio/gio.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include "gpm-icon-names.h"
#include "gpm-common.h"
#include "gpm-manager.h"
#include "gpm-session.h"
-#include "org.mate.PowerManager.h"
+#define GPM_DBUS_DAEMON_SERVICE "org.freedesktop.DBus"
+#define GPM_DBUS_DAEMON_PATH "/org/freedesktop/DBus"
+
+enum {
+ GPM_DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER = 1,
+ GPM_DBUS_REQUEST_NAME_REPLY_IN_QUEUE = 2
+};
+
+static const gchar gpm_manager_introspection_xml[] =
+ "<node>"
+ " <interface name='org.mate.PowerManager'/>"
+ "</node>";
+
+static GDBusNodeInfo *gpm_manager_node_info = NULL;
/**
* gpm_object_register:
@@ -55,46 +67,67 @@
* Return value: success
**/
static gboolean
-gpm_object_register (DBusGConnection *connection,
- GObject *object)
+gpm_object_register (GDBusConnection *connection,
+ GObject *object)
{
- DBusGProxy *bus_proxy = NULL;
GError *error = NULL;
+ GVariant *result = NULL;
guint request_name_result;
- gboolean ret;
-
- bus_proxy = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
-
- ret = dbus_g_proxy_call (bus_proxy, "RequestName", &error,
- G_TYPE_STRING, GPM_DBUS_SERVICE,
- G_TYPE_UINT, 0,
- G_TYPE_INVALID,
- G_TYPE_UINT, &request_name_result,
- G_TYPE_INVALID);
- if (error) {
+ guint registration_id;
+ static const GDBusInterfaceVTable interface_vtable = {
+ NULL,
+ NULL,
+ NULL,
+ { 0 }
+ };
+
+ result = g_dbus_connection_call_sync (connection,
+ GPM_DBUS_DAEMON_SERVICE,
+ GPM_DBUS_DAEMON_PATH,
+ GPM_DBUS_DAEMON_SERVICE,
+ "RequestName",
+ g_variant_new ("(su)", GPM_DBUS_SERVICE, (guint) G_BUS_NAME_OWNER_FLAGS_NONE),
+ G_VARIANT_TYPE ("(u)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (result == NULL) {
g_debug ("ERROR: %s", error->message);
g_error_free (error);
- }
- if (!ret) {
/* abort as the DBUS method failed */
g_warning ("RequestName failed!");
return FALSE;
}
-
- /* free the bus_proxy */
- g_object_unref (G_OBJECT (bus_proxy));
+ g_variant_get (result, "(u)", &request_name_result);
+ g_variant_unref (result);
/* already running */
- if (request_name_result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ if (request_name_result != GPM_DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
return FALSE;
}
- dbus_g_object_type_install_info (GPM_TYPE_MANAGER, &dbus_glib_gpm_manager_object_info);
- dbus_g_error_domain_register (GPM_MANAGER_ERROR, NULL, GPM_MANAGER_TYPE_ERROR);
- dbus_g_connection_register_g_object (connection, GPM_DBUS_PATH, object);
+ if (gpm_manager_node_info == NULL) {
+ gpm_manager_node_info = g_dbus_node_info_new_for_xml (gpm_manager_introspection_xml, &error);
+ if (gpm_manager_node_info == NULL) {
+ g_warning ("Failed to create manager introspection data: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+ }
+
+ registration_id = g_dbus_connection_register_object (connection,
+ GPM_DBUS_PATH,
+ gpm_manager_node_info->interfaces[0],
+ &interface_vtable,
+ object,
+ NULL,
+ &error);
+ if (registration_id == 0) {
+ g_warning ("Failed to register %s: %s", GPM_DBUS_PATH, error->message);
+ g_error_free (error);
+ return FALSE;
+ }
return TRUE;
}
@@ -153,14 +186,15 @@ int
main (int argc, char *argv[])
{
GMainLoop *loop;
- DBusGConnection *system_connection;
- DBusGConnection *session_connection;
+ GDBusConnection *system_connection;
+ GDBusConnection *session_connection;
gboolean version = FALSE;
gboolean timed_exit = FALSE;
gboolean immediate_exit = FALSE;
GpmSession *session = NULL;
GpmManager *manager = NULL;
GError *error = NULL;
+ GVariant *result = NULL;
GOptionContext *context;
gint ret;
guint timer_id;
@@ -180,8 +214,6 @@ main (int argc, char *argv[])
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- dbus_g_thread_init ();
-
context = g_option_context_new (N_("MATE Power Manager"));
/* TRANSLATORS: program name, a simple app to view pending updates */
g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
@@ -194,14 +226,12 @@ main (int argc, char *argv[])
goto unref_program;
}
- dbus_g_thread_init ();
-
gtk_init (&argc, &argv);
g_debug ("MATE %s %s", GPM_NAME, VERSION);
/* check dbus connections, exit if not valid */
- system_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ system_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (error) {
g_warning ("%s", error->message);
g_error_free (error);
@@ -211,7 +241,8 @@ main (int argc, char *argv[])
"your computer after starting this service.");
}
- session_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ error = NULL;
+ session_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
if (error) {
g_warning ("%s", error->message);
g_error_free (error);
@@ -242,15 +273,37 @@ main (int argc, char *argv[])
goto unref_program;
}
+ error = NULL;
+ if (!gpm_manager_register_dbus (manager, session_connection, &error)) {
+ g_error ("Failed to export D-Bus objects: %s", error->message);
+ g_error_free (error);
+ goto unref_program;
+ }
+
/* register to be a policy agent, just like kpackagekit does */
- ret = dbus_bus_request_name(dbus_g_connection_get_connection(system_connection),
- "org.freedesktop.Policy.Power",
- DBUS_NAME_FLAG_REPLACE_EXISTING, NULL);
+ result = g_dbus_connection_call_sync (system_connection,
+ GPM_DBUS_DAEMON_SERVICE,
+ GPM_DBUS_DAEMON_PATH,
+ GPM_DBUS_DAEMON_SERVICE,
+ "RequestName",
+ g_variant_new ("(su)",
+ "org.freedesktop.Policy.Power",
+ (guint) G_BUS_NAME_OWNER_FLAGS_REPLACE),
+ G_VARIANT_TYPE ("(u)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ NULL);
+ ret = 0;
+ if (result != NULL) {
+ g_variant_get (result, "(u)", &ret);
+ g_variant_unref (result);
+ }
switch (ret) {
- case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
+ case GPM_DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
g_debug ("Successfully acquired interface org.freedesktop.Policy.Power.");
break;
- case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
+ case GPM_DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
g_debug ("Queued for interface org.freedesktop.Policy.Power.");
break;
default:
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index 6a8cc1e..4e533da 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -38,8 +38,6 @@
#include <glib/gi18n.h>
#include <gio/gunixfdlist.h>
#include <gtk/gtk.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include <canberra-gtk.h>
#include <libupower-glib/upower.h>
#include <libnotify/notify.h>
@@ -61,9 +59,6 @@
#include "gpm-engine.h"
#include "gpm-upower.h"
-#include "org.mate.PowerManager.Backlight.h"
-#include "org.mate.PowerManager.KbdBacklight.h"
-
static void gpm_manager_finalize (GObject *object);
#define GPM_MANAGER_NOTIFY_TIMEOUT_NEVER 0 /* ms */
@@ -118,6 +113,27 @@ typedef enum {
G_DEFINE_TYPE_WITH_PRIVATE (GpmManager, gpm_manager, G_TYPE_OBJECT)
+gboolean
+gpm_manager_register_dbus (GpmManager *manager,
+ GDBusConnection *connection,
+ GError **error)
+{
+ g_return_val_if_fail (GPM_IS_MANAGER (manager), FALSE);
+ g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), FALSE);
+
+ if (manager->priv->backlight != NULL &&
+ !gpm_backlight_register_dbus (manager->priv->backlight, connection, error))
+ return FALSE;
+
+ if (manager->priv->kbd_backlight != NULL) {
+ gpm_kbd_backlight_register_dbus (manager->priv->kbd_backlight, connection, error);
+ if (error != NULL && *error != NULL)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/**
* gpm_manager_error_quark:
* Return value: Our personal error quark.
@@ -758,6 +774,28 @@ gpm_manager_idle_do_sleep (GpmManager *manager)
}
/**
+ * gpm_manager_is_active:
+ **/
+static gboolean
+gpm_manager_is_active (GpmManager *manager)
+{
+ gboolean ret;
+ gboolean is_active = TRUE;
+ GError *error = NULL;
+
+ if (LOGIND_RUNNING ())
+ return TRUE;
+
+ /* if we fail, assume we are on active console */
+ ret = egg_console_kit_is_active (manager->priv->console, &is_active, &error);
+ if (!ret) {
+ g_warning ("failed to get active status: %s", error->message);
+ g_error_free (error);
+ }
+ return is_active;
+}
+
+/**
* gpm_manager_idle_changed_cb:
* @idle: The idle class instance
* @mode: The idle mode, e.g. GPM_IDLE_MODE_BLANK
@@ -772,7 +810,7 @@ static void
gpm_manager_idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmManager *manager)
{
/* ConsoleKit/systemd say we are not on active console */
- if (!LOGIND_RUNNING() && !egg_console_kit_is_active (manager->priv->console)) {
+ if (!gpm_manager_is_active (manager)) {
g_debug ("ignoring as not on active console");
return;
}
@@ -901,7 +939,7 @@ gpm_manager_button_pressed_cb (GpmButton *button, const gchar *type, GpmManager
g_debug ("Button press event type=%s", type);
/* ConsoleKit/systemd say we are not on active console */
- if (!LOGIND_RUNNING() && !egg_console_kit_is_active (manager->priv->console)) {
+ if (!gpm_manager_is_active (manager)) {
g_debug ("ignoring as not on active console");
return;
}
@@ -978,7 +1016,7 @@ gpm_manager_client_changed_cb (UpClient *client, GParamSpec *pspec, GpmManager *
manager->priv->on_battery = on_battery;
/* ConsoleKit/systemd say we are not on active console */
- if (!LOGIND_RUNNING() && !egg_console_kit_is_active (manager->priv->console)) {
+ if (!gpm_manager_is_active (manager)) {
g_debug ("ignoring as not on active console");
return;
}
@@ -1816,11 +1854,8 @@ static void
gpm_manager_init (GpmManager *manager)
{
gboolean check_type_cpu;
- DBusGConnection *connection;
- GError *error = NULL;
manager->priv = gpm_manager_get_instance_private (manager);
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
/* We want to inhibit the systemd suspend options, and take care of them ourselves */
if (LOGIND_RUNNING()) {
@@ -1871,22 +1906,8 @@ gpm_manager_init (GpmManager *manager)
/* try an start an interactive service */
manager->priv->backlight = gpm_backlight_new ();
- if (manager->priv->backlight != NULL) {
- /* add the new brightness lcd DBUS interface */
- dbus_g_object_type_install_info (GPM_TYPE_BACKLIGHT,
- &dbus_glib_gpm_backlight_object_info);
- dbus_g_connection_register_g_object (connection, GPM_DBUS_PATH_BACKLIGHT,
- G_OBJECT (manager->priv->backlight));
- }
manager->priv->kbd_backlight = gpm_kbd_backlight_new ();
- if (manager->priv->kbd_backlight != NULL) {
- dbus_g_object_type_install_info (GPM_TYPE_KBD_BACKLIGHT,
- &dbus_glib_gpm_kbd_backlight_object_info);
- dbus_g_connection_register_g_object (connection, GPM_DBUS_PATH_KBD_BACKLIGHT,
- G_OBJECT (manager->priv->kbd_backlight));
-
- }
manager->priv->idle = gpm_idle_new ();
g_signal_connect (manager->priv->idle, "idle-changed",
diff --git a/src/gpm-manager.h b/src/gpm-manager.h
index 12b1f8c..2c487c2 100644
--- a/src/gpm-manager.h
+++ b/src/gpm-manager.h
@@ -24,8 +24,8 @@
#ifndef __GPM_MANAGER_H
#define __GPM_MANAGER_H
+#include <gio/gio.h>
#include <glib-object.h>
-#include <dbus/dbus-glib.h>
G_BEGIN_DECLS
@@ -62,6 +62,9 @@ GQuark gpm_manager_error_quark (void);
GType gpm_manager_error_get_type (void);
GType gpm_manager_get_type (void);
GpmManager *gpm_manager_new (void);
+gboolean gpm_manager_register_dbus (GpmManager *manager,
+ GDBusConnection *connection,
+ GError **error);
gboolean gpm_manager_suspend (GpmManager *manager,
GError **error);
diff --git a/src/gpm-networkmanager.c b/src/gpm-networkmanager.c
index 97c3210..4fd5c3d 100644
--- a/src/gpm-networkmanager.c
+++ b/src/gpm-networkmanager.c
@@ -25,7 +25,7 @@
#endif
#include <glib.h>
-#include <dbus/dbus-glib.h>
+#include <gio/gio.h>
#include "gpm-networkmanager.h"
@@ -43,26 +43,44 @@
gboolean
gpm_networkmanager_sleep (void)
{
- DBusGConnection *connection = NULL;
- DBusGProxy *nm_proxy = NULL;
+ GDBusProxy *nm_proxy = NULL;
+ GVariant *result = NULL;
GError *error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ nm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ NM_LISTENER_SERVICE,
+ NM_LISTENER_PATH,
+ NM_LISTENER_INTERFACE,
+ NULL,
+ &error);
if (error) {
g_warning ("%s", error->message);
g_error_free (error);
return FALSE;
}
-
- nm_proxy = dbus_g_proxy_new_for_name (connection,
- NM_LISTENER_SERVICE,
- NM_LISTENER_PATH,
- NM_LISTENER_INTERFACE);
if (!nm_proxy) {
g_warning ("Failed to get name owner");
return FALSE;
}
- dbus_g_proxy_call_no_reply (nm_proxy, "sleep", G_TYPE_INVALID);
+
+ result = g_dbus_proxy_call_sync (nm_proxy,
+ "sleep",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ g_object_unref (G_OBJECT (nm_proxy));
+ return FALSE;
+ }
+ if (result != NULL)
+ g_variant_unref (result);
+
g_object_unref (G_OBJECT (nm_proxy));
return TRUE;
}
@@ -77,26 +95,44 @@ gpm_networkmanager_sleep (void)
gboolean
gpm_networkmanager_wake (void)
{
- DBusGConnection *connection = NULL;
- DBusGProxy *nm_proxy = NULL;
+ GDBusProxy *nm_proxy = NULL;
+ GVariant *result = NULL;
GError *error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ nm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ NM_LISTENER_SERVICE,
+ NM_LISTENER_PATH,
+ NM_LISTENER_INTERFACE,
+ NULL,
+ &error);
if (error) {
g_warning ("%s", error->message);
g_error_free (error);
return FALSE;
}
-
- nm_proxy = dbus_g_proxy_new_for_name (connection,
- NM_LISTENER_SERVICE,
- NM_LISTENER_PATH,
- NM_LISTENER_INTERFACE);
if (!nm_proxy) {
g_warning ("Failed to get name owner");
return FALSE;
}
- dbus_g_proxy_call_no_reply (nm_proxy, "wake", G_TYPE_INVALID);
+
+ result = g_dbus_proxy_call_sync (nm_proxy,
+ "wake",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ g_object_unref (G_OBJECT (nm_proxy));
+ return FALSE;
+ }
+ if (result != NULL)
+ g_variant_unref (result);
+
g_object_unref (G_OBJECT (nm_proxy));
return TRUE;
}
diff --git a/src/gpm-phone.c b/src/gpm-phone.c
index c5634ab..76cb43c 100644
--- a/src/gpm-phone.c
+++ b/src/gpm-phone.c
@@ -26,17 +26,15 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
-#include <dbus/dbus-glib.h>
#include "gpm-phone.h"
-#include "gpm-marshal.h"
static void gpm_phone_finalize (GObject *object);
struct GpmPhonePrivate
{
- DBusGProxy *proxy;
- DBusGConnection *connection;
+ GDBusProxy *proxy;
+ GDBusConnection *connection;
guint watch_id;
gboolean present;
guint percentage;
@@ -63,6 +61,7 @@ gboolean
gpm_phone_coldplug (GpmPhone *phone)
{
GError *error = NULL;
+ GVariant *result;
gboolean ret;
g_return_val_if_fail (phone != NULL, FALSE);
@@ -73,8 +72,16 @@ gpm_phone_coldplug (GpmPhone *phone)
return FALSE;
}
- ret = dbus_g_proxy_call (phone->priv->proxy, "Coldplug", &error,
- G_TYPE_INVALID, G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (phone->priv->proxy,
+ "Coldplug",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ ret = (result != NULL);
+ if (result != NULL)
+ g_variant_unref (result);
if (error != NULL) {
g_warning ("DEBUG: ERROR: %s", error->message);
g_error_free (error);
@@ -137,7 +144,7 @@ gpm_phone_get_num_batteries (GpmPhone *phone)
/** Invoked when we get the BatteryStateChanged
*/
static void
-gpm_phone_battery_state_changed (DBusGProxy *proxy, guint idx, guint percentage, gboolean on_ac, GpmPhone *phone)
+gpm_phone_battery_state_changed (GpmPhone *phone, guint idx, guint percentage, gboolean on_ac)
{
g_return_if_fail (GPM_IS_PHONE (phone));
@@ -152,7 +159,7 @@ gpm_phone_battery_state_changed (DBusGProxy *proxy, guint idx, guint percentage,
/** Invoked when we get NumberBatteriesChanged
*/
static void
-gpm_phone_num_batteries_changed (DBusGProxy *proxy, guint number, GpmPhone *phone)
+gpm_phone_num_batteries_changed (GpmPhone *phone, guint number)
{
g_return_if_fail (GPM_IS_PHONE (phone));
@@ -185,6 +192,30 @@ gpm_phone_num_batteries_changed (DBusGProxy *proxy, guint number, GpmPhone *phon
g_signal_emit (phone, signals [DEVICE_ADDED], 0, 0);
}
+static void
+gpm_phone_dbus_signal_cb (GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ GpmPhone *phone)
+{
+ guint idx;
+ guint percentage;
+ gboolean on_ac;
+ guint number;
+
+ if (g_strcmp0 (signal_name, "BatteryStateChanged") == 0) {
+ g_variant_get (parameters, "(uub)", &idx, &percentage, &on_ac);
+ gpm_phone_battery_state_changed (phone, idx, percentage, on_ac);
+ return;
+ }
+
+ if (g_strcmp0 (signal_name, "NumberBatteriesChanged") == 0) {
+ g_variant_get (parameters, "(u)", &number);
+ gpm_phone_num_batteries_changed (phone, number);
+ }
+}
+
/**
* gpm_phone_class_init:
* @klass: This class instance
@@ -235,7 +266,7 @@ gpm_phone_service_appeared_cb (GDBusConnection *connection,
if (phone->priv->connection == NULL) {
g_debug ("get connection");
g_clear_error (&error);
- phone->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ phone->priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
if (error != NULL) {
g_warning ("Could not connect to DBUS daemon: %s", error->message);
g_error_free (error);
@@ -246,11 +277,14 @@ gpm_phone_service_appeared_cb (GDBusConnection *connection,
if (phone->priv->proxy == NULL) {
g_debug ("get proxy");
g_clear_error (&error);
- phone->priv->proxy = dbus_g_proxy_new_for_name_owner (phone->priv->connection,
- MATE_PHONE_MANAGER_DBUS_SERVICE,
- MATE_PHONE_MANAGER_DBUS_PATH,
- MATE_PHONE_MANAGER_DBUS_INTERFACE,
- &error);
+ phone->priv->proxy = g_dbus_proxy_new_sync (phone->priv->connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ MATE_PHONE_MANAGER_DBUS_SERVICE,
+ MATE_PHONE_MANAGER_DBUS_PATH,
+ MATE_PHONE_MANAGER_DBUS_INTERFACE,
+ NULL,
+ &error);
if (error != NULL) {
g_warning ("Cannot connect, maybe the daemon is not running: %s", error->message);
g_error_free (error);
@@ -258,24 +292,8 @@ gpm_phone_service_appeared_cb (GDBusConnection *connection,
return;
}
- /* complicated type. ick */
- dbus_g_object_register_marshaller(gpm_marshal_VOID__UINT_UINT_BOOLEAN,
- G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT,
- G_TYPE_BOOLEAN, G_TYPE_INVALID);
-
- /* get BatteryStateChanged */
- dbus_g_proxy_add_signal (phone->priv->proxy, "BatteryStateChanged",
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_BOOLEAN, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (phone->priv->proxy, "BatteryStateChanged",
- G_CALLBACK (gpm_phone_battery_state_changed),
- phone, NULL);
-
- /* get NumberBatteriesChanged */
- dbus_g_proxy_add_signal (phone->priv->proxy, "NumberBatteriesChanged",
- G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (phone->priv->proxy, "NumberBatteriesChanged",
- G_CALLBACK (gpm_phone_num_batteries_changed),
- phone, NULL);
+ g_signal_connect (phone->priv->proxy, "g-signal",
+ G_CALLBACK (gpm_phone_dbus_signal_cb), phone);
}
}
@@ -342,6 +360,8 @@ gpm_phone_finalize (GObject *object)
if (phone->priv->proxy != NULL)
g_object_unref (phone->priv->proxy);
+ if (phone->priv->connection != NULL)
+ g_object_unref (phone->priv->connection);
g_bus_unwatch_name (phone->priv->watch_id);
G_OBJECT_CLASS (gpm_phone_parent_class)->finalize (object);
diff --git a/src/gpm-screensaver.c b/src/gpm-screensaver.c
index b89f93e..88460eb 100644
--- a/src/gpm-screensaver.c
+++ b/src/gpm-screensaver.c
@@ -24,8 +24,8 @@
#include <string.h>
#include <glib.h>
+#include <gio/gio.h>
#include <glib/gi18n.h>
-#include <dbus/dbus-glib.h>
#include "gpm-screensaver.h"
#include "gpm-common.h"
@@ -38,7 +38,7 @@ static void gpm_screensaver_finalize (GObject *object);
struct GpmScreensaverPrivate
{
- DBusGProxy *proxy;
+ GDBusProxy *proxy;
};
static gpointer gpm_screensaver_object = NULL;
@@ -53,6 +53,8 @@ G_DEFINE_TYPE_WITH_PRIVATE (GpmScreensaver, gpm_screensaver, G_TYPE_OBJECT)
gboolean
gpm_screensaver_lock (GpmScreensaver *screensaver)
{
+ GError *error = NULL;
+ GVariant *result;
guint sleepcount = 0;
g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
@@ -63,8 +65,20 @@ gpm_screensaver_lock (GpmScreensaver *screensaver)
}
g_debug ("doing mate-screensaver lock");
- dbus_g_proxy_call_no_reply (screensaver->priv->proxy,
- "Lock", G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (screensaver->priv->proxy,
+ "Lock",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (error != NULL) {
+ g_warning ("Lock failed: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+ if (result != NULL)
+ g_variant_unref (result);
/* When we send the Lock signal to g-ss it takes maybe a second
or so to fade the screen and lock. If we suspend mid fade then on
@@ -97,6 +111,7 @@ gpm_screensaver_add_throttle (GpmScreensaver *screensaver,
const char *reason)
{
GError *error = NULL;
+ GVariant *result;
gboolean ret;
guint32 cookie;
@@ -108,13 +123,18 @@ gpm_screensaver_add_throttle (GpmScreensaver *screensaver,
return 0;
}
- ret = dbus_g_proxy_call (screensaver->priv->proxy,
- "Throttle", &error,
- G_TYPE_STRING, "Power screensaver",
- G_TYPE_STRING, reason,
- G_TYPE_INVALID,
- G_TYPE_UINT, &cookie,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (screensaver->priv->proxy,
+ "Throttle",
+ g_variant_new ("(ss)", "Power screensaver", reason),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ ret = (result != NULL);
+ if (result != NULL) {
+ g_variant_get (result, "(u)", &cookie);
+ g_variant_unref (result);
+ }
if (error) {
g_debug ("ERROR: %s", error->message);
g_error_free (error);
@@ -137,6 +157,7 @@ gpm_screensaver_remove_throttle (GpmScreensaver *screensaver, guint cookie)
{
gboolean ret;
GError *error = NULL;
+ GVariant *result;
g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
@@ -146,11 +167,16 @@ gpm_screensaver_remove_throttle (GpmScreensaver *screensaver, guint cookie)
}
g_debug ("removing throttle: id %u", cookie);
- ret = dbus_g_proxy_call (screensaver->priv->proxy,
- "UnThrottle", &error,
- G_TYPE_UINT, cookie,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (screensaver->priv->proxy,
+ "UnThrottle",
+ g_variant_new ("(u)", cookie),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ ret = (result != NULL);
+ if (result != NULL)
+ g_variant_unref (result);
if (error) {
g_debug ("ERROR: %s", error->message);
g_error_free (error);
@@ -172,9 +198,9 @@ gpm_screensaver_remove_throttle (GpmScreensaver *screensaver, guint cookie)
gboolean
gpm_screensaver_check_running (GpmScreensaver *screensaver)
{
- gboolean ret;
- gboolean temp = TRUE;
+ gboolean temp = FALSE;
GError *error = NULL;
+ GVariant *result;
g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
@@ -183,17 +209,23 @@ gpm_screensaver_check_running (GpmScreensaver *screensaver)
return FALSE;
}
- ret = dbus_g_proxy_call (screensaver->priv->proxy,
- "GetActive", &error,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &temp,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (screensaver->priv->proxy,
+ "GetActive",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (result != NULL) {
+ g_variant_get (result, "(b)", &temp);
+ g_variant_unref (result);
+ }
if (error) {
g_debug ("ERROR: %s", error->message);
g_error_free (error);
}
- return ret;
+ return temp;
}
/**
@@ -207,6 +239,9 @@ gpm_screensaver_check_running (GpmScreensaver *screensaver)
gboolean
gpm_screensaver_poke (GpmScreensaver *screensaver)
{
+ GError *error = NULL;
+ GVariant *result;
+
g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
if (screensaver->priv->proxy == NULL) {
@@ -215,9 +250,21 @@ gpm_screensaver_poke (GpmScreensaver *screensaver)
}
g_debug ("poke");
- dbus_g_proxy_call_no_reply (screensaver->priv->proxy,
- "SimulateUserActivity",
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (screensaver->priv->proxy,
+ "SimulateUserActivity",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (error != NULL) {
+ g_warning ("SimulateUserActivity failed: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+ if (result != NULL)
+ g_variant_unref (result);
+
return TRUE;
}
@@ -239,15 +286,23 @@ gpm_screensaver_class_init (GpmScreensaverClass *klass)
static void
gpm_screensaver_init (GpmScreensaver *screensaver)
{
- DBusGConnection *connection;
+ GError *error = NULL;
screensaver->priv = gpm_screensaver_get_instance_private (screensaver);
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
- screensaver->priv->proxy = dbus_g_proxy_new_for_name (connection,
- GS_LISTENER_SERVICE,
- GS_LISTENER_PATH,
- GS_LISTENER_INTERFACE);
+ screensaver->priv->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ GS_LISTENER_SERVICE,
+ GS_LISTENER_PATH,
+ GS_LISTENER_INTERFACE,
+ NULL,
+ &error);
+ if (error != NULL) {
+ g_warning ("Could not create screensaver proxy: %s", error->message);
+ g_error_free (error);
+ screensaver->priv->proxy = NULL;
+ }
}
/**
@@ -264,7 +319,8 @@ gpm_screensaver_finalize (GObject *object)
screensaver = GPM_SCREENSAVER (object);
screensaver->priv = gpm_screensaver_get_instance_private (screensaver);
- g_object_unref (screensaver->priv->proxy);
+ if (screensaver->priv->proxy != NULL)
+ g_object_unref (screensaver->priv->proxy);
G_OBJECT_CLASS (gpm_screensaver_parent_class)->finalize (object);
}
diff --git a/src/gpm-session.c b/src/gpm-session.c
index 2960501..a3c86a5 100644
--- a/src/gpm-session.c
+++ b/src/gpm-session.c
@@ -24,8 +24,8 @@
#include <string.h>
#include <glib.h>
+#include <gio/gio.h>
#include <glib/gi18n.h>
-#include <dbus/dbus-glib.h>
#include "gpm-session.h"
#include "gpm-common.h"
@@ -58,10 +58,10 @@ typedef enum {
struct GpmSessionPrivate
{
- DBusGProxy *proxy;
- DBusGProxy *proxy_presence;
- DBusGProxy *proxy_client_private;
- DBusGProxy *proxy_prop;
+ GDBusProxy *proxy;
+ GDBusProxy *proxy_presence;
+ GDBusProxy *proxy_client_private;
+ GDBusProxy *proxy_prop;
gboolean is_idle_old;
gboolean is_idle_inhibited_old;
gboolean is_suspend_inhibited_old;
@@ -97,7 +97,14 @@ gpm_session_logout (GpmSession *session)
}
/* we have to use no reply, as the SM calls into g-p-m to get the can_suspend property */
- dbus_g_proxy_call_no_reply (session->priv->proxy, "Shutdown", G_TYPE_INVALID);
+ g_dbus_proxy_call (session->priv->proxy,
+ "Shutdown",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ NULL,
+ NULL);
return TRUE;
}
@@ -135,9 +142,20 @@ gpm_session_get_suspend_inhibited (GpmSession *session)
* gpm_session_presence_status_changed_cb:
**/
static void
-gpm_session_presence_status_changed_cb (DBusGProxy *proxy, guint status, GpmSession *session)
+gpm_session_presence_status_changed_cb (GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ GpmSession *session)
{
+ guint status;
gboolean is_idle;
+
+ if (g_strcmp0 (signal_name, "StatusChanged") != 0)
+ return;
+
+ g_variant_get (parameters, "(u)", &status);
+
is_idle = (status == GPM_SESSION_STATUS_ENUM_IDLE);
if (is_idle != session->priv->is_idle_old) {
g_debug ("emitting idle-changed : (%i)", is_idle);
@@ -152,10 +170,12 @@ gpm_session_presence_status_changed_cb (DBusGProxy *proxy, guint status, GpmSess
static gboolean
gpm_session_is_idle (GpmSession *session)
{
+ GVariant *result;
+ GVariant *status_variant;
+ guint status;
gboolean ret;
gboolean is_idle = FALSE;
GError *error = NULL;
- GValue *value;
/* no mate-session */
if (session->priv->proxy_prop == NULL) {
@@ -163,23 +183,26 @@ gpm_session_is_idle (GpmSession *session)
goto out;
}
- value = g_new0(GValue, 1);
/* find out if this change altered the inhibited state */
- ret = dbus_g_proxy_call (session->priv->proxy_prop, "Get", &error,
- G_TYPE_STRING, GPM_SESSION_MANAGER_PRESENCE_INTERFACE,
- G_TYPE_STRING, "status",
- G_TYPE_INVALID,
- G_TYPE_VALUE, value,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (session->priv->proxy_prop,
+ "Get",
+ g_variant_new ("(ss)", GPM_SESSION_MANAGER_PRESENCE_INTERFACE, "status"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ ret = (result != NULL);
if (!ret) {
g_warning ("failed to get idle status: %s", error->message);
g_error_free (error);
- g_free (value);
is_idle = FALSE;
goto out;
}
- is_idle = (g_value_get_uint (value) == GPM_SESSION_STATUS_ENUM_IDLE);
- g_free (value);
+ g_variant_get (result, "(v)", &status_variant);
+ status = g_variant_get_uint32 (status_variant);
+ g_variant_unref (status_variant);
+ g_variant_unref (result);
+ is_idle = (status == GPM_SESSION_STATUS_ENUM_IDLE);
out:
return is_idle;
}
@@ -190,6 +213,7 @@ out:
static gboolean
gpm_session_is_idle_inhibited (GpmSession *session)
{
+ GVariant *result;
gboolean ret;
gboolean is_inhibited = FALSE;
GError *error = NULL;
@@ -201,11 +225,18 @@ gpm_session_is_idle_inhibited (GpmSession *session)
}
/* find out if this change altered the inhibited state */
- ret = dbus_g_proxy_call (session->priv->proxy, "IsInhibited", &error,
- G_TYPE_UINT, GPM_SESSION_INHIBIT_MASK_IDLE,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &is_inhibited,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (session->priv->proxy,
+ "IsInhibited",
+ g_variant_new ("(u)", GPM_SESSION_INHIBIT_MASK_IDLE),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ ret = (result != NULL);
+ if (result != NULL) {
+ g_variant_get (result, "(b)", &is_inhibited);
+ g_variant_unref (result);
+ }
if (!ret) {
g_warning ("failed to get inhibit status: %s", error->message);
g_error_free (error);
@@ -221,6 +252,7 @@ out:
static gboolean
gpm_session_is_suspend_inhibited (GpmSession *session)
{
+ GVariant *result;
gboolean ret;
gboolean is_inhibited = FALSE;
GError *error = NULL;
@@ -232,11 +264,18 @@ gpm_session_is_suspend_inhibited (GpmSession *session)
}
/* find out if this change altered the inhibited state */
- ret = dbus_g_proxy_call (session->priv->proxy, "IsInhibited", &error,
- G_TYPE_UINT, GPM_SESSION_INHIBIT_MASK_SUSPEND,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &is_inhibited,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (session->priv->proxy,
+ "IsInhibited",
+ g_variant_new ("(u)", GPM_SESSION_INHIBIT_MASK_SUSPEND),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ ret = (result != NULL);
+ if (result != NULL) {
+ g_variant_get (result, "(b)", &is_inhibited);
+ g_variant_unref (result);
+ }
if (!ret) {
g_warning ("failed to get inhibit status: %s", error->message);
g_error_free (error);
@@ -250,7 +289,7 @@ out:
* gpm_session_stop_cb:
**/
static void
-gpm_session_stop_cb (DBusGProxy *proxy, GpmSession *session)
+gpm_session_stop_cb (GpmSession *session)
{
g_debug ("emitting ::stop()");
g_signal_emit (session, signals [STOP], 0);
@@ -260,7 +299,7 @@ gpm_session_stop_cb (DBusGProxy *proxy, GpmSession *session)
* gpm_session_query_end_session_cb:
**/
static void
-gpm_session_query_end_session_cb (DBusGProxy *proxy, guint flags, GpmSession *session)
+gpm_session_query_end_session_cb (GpmSession *session, guint flags)
{
g_debug ("emitting ::query-end-session(%u)", flags);
g_signal_emit (session, signals [QUERY_END_SESSION], 0, flags);
@@ -270,18 +309,45 @@ gpm_session_query_end_session_cb (DBusGProxy *proxy, guint flags, GpmSession *se
* gpm_session_end_session_cb:
**/
static void
-gpm_session_end_session_cb (DBusGProxy *proxy, guint flags, GpmSession *session)
+gpm_session_end_session_cb (GpmSession *session, guint flags)
{
g_debug ("emitting ::end-session(%u)", flags);
g_signal_emit (session, signals [END_SESSION], 0, flags);
}
+static void
+gpm_session_client_private_signal_cb (GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ GpmSession *session)
+{
+ guint flags;
+
+ if (g_strcmp0 (signal_name, "Stop") == 0) {
+ gpm_session_stop_cb (session);
+ return;
+ }
+
+ if (g_strcmp0 (signal_name, "QueryEndSession") == 0) {
+ g_variant_get (parameters, "(u)", &flags);
+ gpm_session_query_end_session_cb (session, flags);
+ return;
+ }
+
+ if (g_strcmp0 (signal_name, "EndSession") == 0) {
+ g_variant_get (parameters, "(u)", &flags);
+ gpm_session_end_session_cb (session, flags);
+ }
+}
+
/**
* gpm_session_end_session_response:
**/
gboolean
gpm_session_end_session_response (GpmSession *session, gboolean is_okay, const gchar *reason)
{
+ GVariant *result;
gboolean ret = FALSE;
GError *error = NULL;
@@ -295,11 +361,16 @@ gpm_session_end_session_response (GpmSession *session, gboolean is_okay, const g
}
/* send response */
- ret = dbus_g_proxy_call (session->priv->proxy_client_private, "EndSessionResponse", &error,
- G_TYPE_BOOLEAN, is_okay,
- G_TYPE_STRING, reason,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (session->priv->proxy_client_private,
+ "EndSessionResponse",
+ g_variant_new ("(bs)", is_okay, reason),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ ret = (result != NULL);
+ if (result != NULL)
+ g_variant_unref (result);
if (!ret) {
g_warning ("failed to send session response: %s", error->message);
g_error_free (error);
@@ -315,10 +386,11 @@ out:
gboolean
gpm_session_register_client (GpmSession *session, const gchar *app_id, const gchar *client_startup_id)
{
+ GVariant *result;
+ const gchar *client_id_tmp;
gboolean ret = FALSE;
gchar *client_id = NULL;
GError *error = NULL;
- DBusGConnection *connection;
g_return_val_if_fail (GPM_IS_SESSION (session), FALSE);
@@ -329,39 +401,40 @@ gpm_session_register_client (GpmSession *session, const gchar *app_id, const gch
}
/* find out if this change altered the inhibited state */
- ret = dbus_g_proxy_call (session->priv->proxy, "RegisterClient", &error,
- G_TYPE_STRING, app_id,
- G_TYPE_STRING, client_startup_id,
- G_TYPE_INVALID,
- DBUS_TYPE_G_OBJECT_PATH, &client_id,
- G_TYPE_INVALID);
+ result = g_dbus_proxy_call_sync (session->priv->proxy,
+ "RegisterClient",
+ g_variant_new ("(ss)", app_id, client_startup_id),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ ret = (result != NULL);
if (!ret) {
g_warning ("failed to register client '%s': %s", client_startup_id, error->message);
g_error_free (error);
goto out;
}
+ g_variant_get (result, "(&o)", &client_id_tmp);
+ client_id = g_strdup (client_id_tmp);
+ g_variant_unref (result);
/* get org.gnome.SessionManager.ClientPrivate interface */
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
- session->priv->proxy_client_private = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
- client_id, GPM_SESSION_MANAGER_CLIENT_PRIVATE_INTERFACE, &error);
+ session->priv->proxy_client_private = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ GPM_SESSION_MANAGER_SERVICE,
+ client_id,
+ GPM_SESSION_MANAGER_CLIENT_PRIVATE_INTERFACE,
+ NULL,
+ &error);
if (session->priv->proxy_client_private == NULL) {
g_warning ("DBUS error: %s", error->message);
g_error_free (error);
goto out;
}
- /* get Stop */
- dbus_g_proxy_add_signal (session->priv->proxy_client_private, "Stop", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (session->priv->proxy_client_private, "Stop", G_CALLBACK (gpm_session_stop_cb), session, NULL);
-
- /* get QueryEndSession */
- dbus_g_proxy_add_signal (session->priv->proxy_client_private, "QueryEndSession", G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (session->priv->proxy_client_private, "QueryEndSession", G_CALLBACK (gpm_session_query_end_session_cb), session, NULL);
-
- /* get EndSession */
- dbus_g_proxy_add_signal (session->priv->proxy_client_private, "EndSession", G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (session->priv->proxy_client_private, "EndSession", G_CALLBACK (gpm_session_end_session_cb), session, NULL);
+ g_signal_connect (session->priv->proxy_client_private, "g-signal",
+ G_CALLBACK (gpm_session_client_private_signal_cb), session);
g_debug ("registered startup '%s' to client id '%s'", client_startup_id, client_id);
out:
@@ -373,11 +446,19 @@ out:
* gpm_session_inhibit_changed_cb:
**/
static void
-gpm_session_inhibit_changed_cb (DBusGProxy *proxy, const gchar *id, GpmSession *session)
+gpm_session_inhibit_changed_cb (GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ GpmSession *session)
{
gboolean is_idle_inhibited;
gboolean is_suspend_inhibited;
+ if (g_strcmp0 (signal_name, "InhibitorAdded") != 0 &&
+ g_strcmp0 (signal_name, "InhibitorRemoved") != 0)
+ return;
+
is_idle_inhibited = gpm_session_is_idle_inhibited (session);
is_suspend_inhibited = gpm_session_is_suspend_inhibited (session);
if (is_idle_inhibited != session->priv->is_idle_inhibited_old || is_suspend_inhibited != session->priv->is_suspend_inhibited_old) {
@@ -449,21 +530,26 @@ gpm_session_class_init (GpmSessionClass *klass)
static void
gpm_session_init (GpmSession *session)
{
- DBusGConnection *connection;
GError *error = NULL;
session->priv = gpm_session_get_instance_private (session);
session->priv->is_idle_old = FALSE;
session->priv->is_idle_inhibited_old = FALSE;
session->priv->is_suspend_inhibited_old = FALSE;
+ session->priv->proxy = NULL;
+ session->priv->proxy_presence = NULL;
session->priv->proxy_client_private = NULL;
-
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ session->priv->proxy_prop = NULL;
/* get org.gnome.SessionManager interface */
- session->priv->proxy = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
- GPM_SESSION_MANAGER_PATH,
- GPM_SESSION_MANAGER_INTERFACE, &error);
+ session->priv->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ GPM_SESSION_MANAGER_SERVICE,
+ GPM_SESSION_MANAGER_PATH,
+ GPM_SESSION_MANAGER_INTERFACE,
+ NULL,
+ &error);
if (session->priv->proxy == NULL) {
g_warning ("DBUS error: %s", error->message);
g_error_free (error);
@@ -471,9 +557,15 @@ gpm_session_init (GpmSession *session)
}
/* get org.gnome.SessionManager.Presence interface */
- session->priv->proxy_presence = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
- GPM_SESSION_MANAGER_PRESENCE_PATH,
- GPM_SESSION_MANAGER_PRESENCE_INTERFACE, &error);
+ g_clear_error (&error);
+ session->priv->proxy_presence = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ GPM_SESSION_MANAGER_SERVICE,
+ GPM_SESSION_MANAGER_PRESENCE_PATH,
+ GPM_SESSION_MANAGER_PRESENCE_INTERFACE,
+ NULL,
+ &error);
if (session->priv->proxy_presence == NULL) {
g_warning ("DBUS error: %s", error->message);
g_error_free (error);
@@ -481,26 +573,26 @@ gpm_session_init (GpmSession *session)
}
/* get properties interface */
- session->priv->proxy_prop = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
- GPM_SESSION_MANAGER_PRESENCE_PATH,
- GPM_DBUS_PROPERTIES_INTERFACE, &error);
+ g_clear_error (&error);
+ session->priv->proxy_prop = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ GPM_SESSION_MANAGER_SERVICE,
+ GPM_SESSION_MANAGER_PRESENCE_PATH,
+ GPM_DBUS_PROPERTIES_INTERFACE,
+ NULL,
+ &error);
if (session->priv->proxy_prop == NULL) {
g_warning ("DBUS error: %s", error->message);
g_error_free (error);
return;
}
- /* get StatusChanged */
- dbus_g_proxy_add_signal (session->priv->proxy_presence, "StatusChanged", G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (session->priv->proxy_presence, "StatusChanged", G_CALLBACK (gpm_session_presence_status_changed_cb), session, NULL);
-
- /* get InhibitorAdded */
- dbus_g_proxy_add_signal (session->priv->proxy, "InhibitorAdded", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (session->priv->proxy, "InhibitorAdded", G_CALLBACK (gpm_session_inhibit_changed_cb), session, NULL);
+ g_signal_connect (session->priv->proxy_presence, "g-signal",
+ G_CALLBACK (gpm_session_presence_status_changed_cb), session);
- /* get InhibitorRemoved */
- dbus_g_proxy_add_signal (session->priv->proxy, "InhibitorRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (session->priv->proxy, "InhibitorRemoved", G_CALLBACK (gpm_session_inhibit_changed_cb), session, NULL);
+ g_signal_connect (session->priv->proxy, "g-signal",
+ G_CALLBACK (gpm_session_inhibit_changed_cb), session);
/* coldplug */
session->priv->is_idle_inhibited_old = gpm_session_is_idle_inhibited (session);
@@ -523,11 +615,14 @@ gpm_session_finalize (GObject *object)
session = GPM_SESSION (object);
session->priv = gpm_session_get_instance_private (session);
- g_object_unref (session->priv->proxy);
- g_object_unref (session->priv->proxy_presence);
+ if (session->priv->proxy != NULL)
+ g_object_unref (session->priv->proxy);
+ if (session->priv->proxy_presence != NULL)
+ g_object_unref (session->priv->proxy_presence);
if (session->priv->proxy_client_private != NULL)
g_object_unref (session->priv->proxy_client_private);
- g_object_unref (session->priv->proxy_prop);
+ if (session->priv->proxy_prop != NULL)
+ g_object_unref (session->priv->proxy_prop);
G_OBJECT_CLASS (gpm_session_parent_class)->finalize (object);
}
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index aa25e8a..4c9d0d1 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -28,7 +28,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <dbus/dbus-glib.h>
#include <libupower-glib/upower.h>
#include "egg-color.h"
@@ -1266,8 +1265,6 @@ main (int argc, char *argv[])
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- dbus_g_thread_init ();
-
context = g_option_context_new (NULL);
/* TRANSLATORS: the program name */
g_option_context_set_summary (context, _("Power Statistics"));
diff --git a/src/meson.build b/src/meson.build
index 35a0b88..15e9b44 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -34,30 +34,9 @@ cflags = [
'-DEGG_CONSOLE="GPM_CONSOLE"'
]
marshal_files = gnome.genmarshal('gpm-marshal', prefix : 'gpm_marshal', sources : 'gpm-marshal.list')
-
-dbus_binding_tool = find_program('dbus-binding-tool')
-dbus_Backlight = custom_target('org.mate.PowerManager.Backlight',
- input: 'org.mate.PowerManager.Backlight.xml',
- output: 'org.mate.PowerManager.Backlight.h',
- command: [dbus_binding_tool, '--prefix=gpm_backlight', '--mode=glib-server',
- '--output=@OUTPUT@', '@INPUT@']
-)
-dbus_KbdBacklight = custom_target('org.mate.PowerManager.KbdBacklight',
- input: 'org.mate.PowerManager.KbdBacklight.xml',
- output: 'org.mate.PowerManager.KbdBacklight.h',
- command: [dbus_binding_tool, '--prefix=gpm_kbd_backlight', '--mode=glib-server',
- '--output=@OUTPUT@', '@INPUT@']
-)
-dbus_Manager = custom_target('org.mate.PowerManager',
- input: 'org.mate.PowerManager.xml',
- output: 'org.mate.PowerManager.h',
- command: [dbus_binding_tool, '--prefix=gpm_manager', '--mode=glib-server',
- '--output=@OUTPUT@', '@INPUT@']
-)
deps = [
glib,
gtk,
- dbusglib,
cairo,
upower,
keyring,
@@ -172,9 +151,6 @@ executable(
'gsd-media-keys-window.c',
'msd-osd-window.c',
'gpm-engine.c',
- dbus_Backlight,
- dbus_KbdBacklight,
- dbus_Manager,
],
include_directories : [
include_directories('..'),