gnome-power-manager r3025 - in trunk: . applets/brightness applets/inhibit docs libdbus-glib libhal-glib src test
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-power-manager r3025 - in trunk: . applets/brightness applets/inhibit docs libdbus-glib libhal-glib src test
- Date: Mon, 20 Oct 2008 17:31:37 +0000 (UTC)
Author: rhughes
Date: Mon Oct 20 17:31:36 2008
New Revision: 3025
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=3025&view=rev
Log:
2008-10-20 Richard Hughes <richard hughsie com>
* Makefile.am:
* applets/brightness/brightness-applet.c:
(gpm_brightness_applet_init):
* applets/inhibit/inhibit-applet.c: (gpm_applet_has_inhibit),
(gpm_inhibit_applet_init):
* configure.ac:
* docs/dbus-interface.html:
* libdbus-glib/Makefile.am:
* libdbus-glib/egg-dbus-monitor.c:
* libdbus-glib/egg-dbus-monitor.h:
* libdbus-glib/egg-debug.c:
* libdbus-glib/egg-debug.h:
* libdbus-glib/libdbus-proxy.c:
* libdbus-glib/libdbus-proxy.h:
* libhal-glib/Makefile.am:
* libhal-glib/egg-dbus-monitor.c:
* libhal-glib/egg-dbus-monitor.h:
* libhal-glib/egg-dbus-proxy.c:
* libhal-glib/egg-dbus-proxy.h:
* libhal-glib/egg-debug.c:
* libhal-glib/egg-debug.h:
* libhal-glib/libhal-gdevice.c: (hal_gdevice_set_udi),
(hal_gdevice_get_bool), (hal_gdevice_get_string),
(hal_gdevice_get_int), (hal_gdevice_query_capability),
(watch_device_properties_modified_cb),
(hal_gdevice_watch_property_modified),
(hal_gdevice_watch_condition), (hal_gdevice_remove_condition),
(hal_gdevice_remove_property_modified), (hal_gdevice_init):
* libhal-glib/libhal-gdevicestore.c:
* libhal-glib/libhal-gmanager.c: (hal_gmanager_proxy_connect_more),
(hal_gmanager_proxy_disconnect_more), (hal_gmanager_init),
(hal_gmanager_is_laptop):
* libhal-glib/libhal-gpower.c: (hal_gpower_init),
(hal_gpower_is_laptop), (hal_gpower_can_suspend),
(hal_gpower_can_hibernate), (hal_gpower_filter_error),
(hal_gpower_suspend), (hal_gpower_pm_method_void),
(hal_gpower_enable_power_save), (hal_gpower_clear_suspend_error),
(hal_gpower_clear_hibernate_error):
* src/Makefile.am:
* src/egg-dbus-monitor.c: (egg_dbus_monitor_assign),
(egg_dbus_monitor_init):
* src/egg-dbus-monitor.h:
* src/egg-dbus-proxy.c: (egg_dbus_proxy_connect),
(egg_dbus_proxy_disconnect), (dbus_monitor_connection_cb),
(egg_dbus_proxy_assign), (egg_dbus_proxy_get_proxy),
(egg_dbus_proxy_is_connected), (egg_dbus_proxy_class_init),
(egg_dbus_proxy_init), (egg_dbus_proxy_finalize),
(egg_dbus_proxy_new):
* src/egg-dbus-proxy.h:
* src/gpm-brightness-hal.c: (gpm_brightness_hal_get_hw),
(gpm_brightness_hal_set_hw), (gpm_brightness_hal_init):
* src/gpm-brightness-kbd.c: (gpm_brightness_kbd_get_hw),
(gpm_brightness_kbd_set_hw), (gpm_brightness_kbd_init):
* src/gpm-inhibit.c: (inhibit), (uninhibit), (has_inhibit),
(gpm_inhibit_test):
* src/gpm-light-sensor.c: (gpm_light_sensor_get_hw),
(gpm_light_sensor_init):
* src/gpm-phone.c: (gpm_phone_init):
* src/gpm-profile.c:
* src/gpm-screensaver.c: (gpm_screensaver_proxy_connect_more),
(gpm_screensaver_lock), (gpm_screensaver_add_throttle),
(gpm_screensaver_remove_throttle), (gpm_screensaver_check_running),
(gpm_screensaver_poke), (gpm_screensaver_get_idle),
(gpm_screensaver_init):
* src/gpm-statistics-core.c: (gpm_statistics_get_events),
(gpm_statistics_find_types), (gpm_statistics_get_data_dbus),
(gpm_statistics_get_parameters_dbus), (gpm_statistics_init):
* test/gpm-st-proxy.c: (egg_test_proxy):
Get rid of the ridiculous libdbus-glib DbusGProxy superclass.
Added:
trunk/libhal-glib/egg-dbus-monitor.c (contents, props changed)
trunk/libhal-glib/egg-dbus-monitor.h (contents, props changed)
trunk/libhal-glib/egg-dbus-proxy.c (contents, props changed)
trunk/libhal-glib/egg-dbus-proxy.h (contents, props changed)
trunk/libhal-glib/egg-debug.c (contents, props changed)
trunk/libhal-glib/egg-debug.h (contents, props changed)
trunk/src/egg-dbus-proxy.c
trunk/src/egg-dbus-proxy.h
Removed:
trunk/libdbus-glib/
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/applets/brightness/brightness-applet.c
trunk/applets/inhibit/inhibit-applet.c
trunk/configure.ac
trunk/docs/dbus-interface.html
trunk/libhal-glib/Makefile.am
trunk/libhal-glib/libhal-gdevice.c
trunk/libhal-glib/libhal-gdevicestore.c
trunk/libhal-glib/libhal-gmanager.c
trunk/libhal-glib/libhal-gpower.c
trunk/src/Makefile.am
trunk/src/egg-dbus-monitor.c
trunk/src/egg-dbus-monitor.h
trunk/src/gpm-brightness-hal.c
trunk/src/gpm-brightness-kbd.c
trunk/src/gpm-inhibit.c
trunk/src/gpm-light-sensor.c
trunk/src/gpm-phone.c
trunk/src/gpm-profile.c
trunk/src/gpm-screensaver.c
trunk/src/gpm-statistics-core.c
trunk/test/gpm-st-proxy.c
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Mon Oct 20 17:31:36 2008
@@ -2,7 +2,6 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = \
- libdbus-glib \
libhal-glib \
src \
po \
Modified: trunk/applets/brightness/brightness-applet.c
==============================================================================
--- trunk/applets/brightness/brightness-applet.c (original)
+++ trunk/applets/brightness/brightness-applet.c Mon Oct 20 17:31:36 2008
@@ -938,6 +938,8 @@
static void
gpm_brightness_applet_init (GpmBrightnessApplet *applet)
{
+ DBusGConnection *connection;
+
/* initialize fields */
applet->size = 0;
applet->call_worked = TRUE;
@@ -955,7 +957,8 @@
applet->monitor = egg_dbus_monitor_new ();
g_signal_connect (applet->monitor, "connection-changed",
G_CALLBACK (monitor_connection_cb), applet);
- egg_dbus_monitor_assign (applet->monitor, EGG_DBUS_MONITOR_SESSION, GPM_DBUS_SERVICE);
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ egg_dbus_monitor_assign (applet->monitor, connection, GPM_DBUS_SERVICE);
gpm_brightness_applet_dbus_connect (applet);
/* coldplug */
Modified: trunk/applets/inhibit/inhibit-applet.c
==============================================================================
--- trunk/applets/inhibit/inhibit-applet.c (original)
+++ trunk/applets/inhibit/inhibit-applet.c Mon Oct 20 17:31:36 2008
@@ -165,7 +165,7 @@
gboolean ret;
DBusGProxy *proxy;
- proxy = dbus_proxy_get_proxy (applet->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (applet->gproxy);
if (proxy == NULL) {
g_warning ("not connected");
return FALSE;
@@ -597,6 +597,8 @@
static void
gpm_inhibit_applet_init (GpmInhibitApplet *applet)
{
+ DBusGConnection *connection;
+
/* initialize fields */
applet->size = 0;
applet->icon = NULL;
@@ -611,7 +613,8 @@
applet->monitor = egg_dbus_monitor_new ();
g_signal_connect (applet->monitor, "connection-changed",
G_CALLBACK (monitor_connection_cb), applet);
- egg_dbus_monitor_assign (applet->monitor, EGG_DBUS_MONITOR_SESSION, GPM_DBUS_SERVICE);
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ egg_dbus_monitor_assign (applet->monitor, connection, GPM_DBUS_SERVICE);
gpm_inhibit_applet_dbus_connect (applet);
/* prepare */
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Mon Oct 20 17:31:36 2008
@@ -588,7 +588,6 @@
applets/brightness/Makefile
applets/inhibit/Makefile
libhal-glib/Makefile
-libdbus-glib/Makefile
docs/Makefile
man/Makefile
help/Makefile
Modified: trunk/docs/dbus-interface.html
==============================================================================
--- trunk/docs/dbus-interface.html (original)
+++ trunk/docs/dbus-interface.html Mon Oct 20 17:31:36 2008
@@ -1,4 +1,4 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>GNOME Power Management Specification (with additions)</title><link rel="stylesheet" href="docbook.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="index"></a>GNOME Power Management Specification (with additions)</h2></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Richard</span> <span class="surname">Hughes</span></h3><div class="affiliation"><div class="address"><p><br>
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>GNOME Power Management Specification (with additions)</title><link rel="stylesheet" href="docbook.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="index"></a>GNOME Power Management Specification (with additions)</h2></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Richard</span> <span class="surname">Hughes</span></h3><div class="affiliation"><div class="address"><p><br>
ÂÂÂÂÂÂÂÂÂÂÂÂ<code class="email"><<a class="email" href="mailto:richard hughsie com">richard hughsie com</a>></code><br>
ÂÂÂÂÂÂÂÂÂÂ</p></div></div></div></div></div><div><p class="releaseinfo">Version 2.19.x</p></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#overview">Overview</a></span></dt><dt><span class="sect1"><a href="#dbus">DBUS API</a></span></dt><dd><dl><dt><span class="sect2"><a href="#dbus-core">Compulsory Basic Interface</a></span></dt><dt><span class="sect2"><a href="#dbus-backlight">Optional Backlight Interface</a></span></dt><dt><span class="sect2"><a href="#dbus-widget">Optional Widget Interface</a></span></dt><dt><span class="sect2"><a href="#dbus-inhibit">Optional Inhibit Interface</a></span></dt><dt><span class="sect2"><a href="#dbus-statistics">Optional Statistics Interface</a></span></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="overview"></a>Overview</h2></div></div></div><p>
A Power Management specification has been in used informally used for
Modified: trunk/libhal-glib/Makefile.am
==============================================================================
--- trunk/libhal-glib/Makefile.am (original)
+++ trunk/libhal-glib/Makefile.am Mon Oct 20 17:31:36 2008
@@ -1,13 +1,10 @@
INCLUDES = \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
- -I$(top_srcdir)/libdbus-glib \
+ -DEGG_LOG_FILE=\""$(PK_LOG_DIR)/gnome-power-manager"\" \
-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
-LOCAL_LIBDBUS_LIBS = \
- $(top_builddir)/libdbus-glib/libdbus-proxy.la
-
noinst_LTLIBRARIES = \
libhal-gmanager.la \
libhal-gdevice.la \
@@ -15,6 +12,12 @@
libhal-gpower.la
libhal_gmanager_la_SOURCES = \
+ egg-dbus-proxy.h \
+ egg-dbus-proxy.c \
+ egg-dbus-monitor.h \
+ egg-dbus-monitor.c \
+ egg-debug.h \
+ egg-debug.c \
libhal-marshal.h \
libhal-marshal.c \
libhal-gdevice.c \
@@ -22,18 +25,22 @@
libhal-gmanager.c \
libhal-gmanager.h
libhal_gmanager_la_LIBADD = \
- $(LOCAL_LIBDBUS_LIBS) \
$(DBUS_LIBS) \
$(INTLLIBS) \
$(GLIB_LIBS)
libhal_gdevice_la_SOURCES = \
+ egg-dbus-proxy.h \
+ egg-dbus-proxy.c \
+ egg-dbus-monitor.h \
+ egg-dbus-monitor.c \
+ egg-debug.h \
+ egg-debug.c \
libhal-marshal.h \
libhal-marshal.c \
libhal-gdevice.c \
libhal-gdevice.h
libhal_gdevice_la_LIBADD = \
- $(LOCAL_LIBDBUS_LIBS) \
$(DBUS_LIBS) \
$(INTLLIBS) \
$(GLIB_LIBS)
@@ -46,18 +53,22 @@
libhal-gdevicestore.c \
libhal-gdevicestore.h
libhal_gdevicestore_la_LIBADD = \
- $(LOCAL_LIBDBUS_LIBS) \
$(DBUS_LIBS) \
$(INTLLIBS) \
$(GLIB_LIBS)
libhal_gpower_la_SOURCES = \
+ egg-dbus-proxy.h \
+ egg-dbus-proxy.c \
+ egg-dbus-monitor.h \
+ egg-dbus-monitor.c \
+ egg-debug.h \
+ egg-debug.c \
libhal-marshal.h \
libhal-marshal.c \
libhal-gpower.c \
libhal-gpower.h
libhal_gpower_la_LIBADD = \
- $(LOCAL_LIBDBUS_LIBS) \
$(DBUS_LIBS) \
$(INTLLIBS) \
$(GLIB_LIBS)
Added: trunk/libhal-glib/egg-dbus-monitor.c
==============================================================================
--- (empty file)
+++ trunk/libhal-glib/egg-dbus-monitor.c Mon Oct 20 17:31:36 2008
@@ -0,0 +1 @@
+link ../src/egg-dbus-monitor.c
\ No newline at end of file
Added: trunk/libhal-glib/egg-dbus-monitor.h
==============================================================================
--- (empty file)
+++ trunk/libhal-glib/egg-dbus-monitor.h Mon Oct 20 17:31:36 2008
@@ -0,0 +1 @@
+link ../src/egg-dbus-monitor.h
\ No newline at end of file
Added: trunk/libhal-glib/egg-dbus-proxy.c
==============================================================================
--- (empty file)
+++ trunk/libhal-glib/egg-dbus-proxy.c Mon Oct 20 17:31:36 2008
@@ -0,0 +1 @@
+link ../src/egg-dbus-proxy.c
\ No newline at end of file
Added: trunk/libhal-glib/egg-dbus-proxy.h
==============================================================================
--- (empty file)
+++ trunk/libhal-glib/egg-dbus-proxy.h Mon Oct 20 17:31:36 2008
@@ -0,0 +1 @@
+link ../src/egg-dbus-proxy.h
\ No newline at end of file
Added: trunk/libhal-glib/egg-debug.c
==============================================================================
--- (empty file)
+++ trunk/libhal-glib/egg-debug.c Mon Oct 20 17:31:36 2008
@@ -0,0 +1 @@
+link ../src/egg-debug.c
\ No newline at end of file
Added: trunk/libhal-glib/egg-debug.h
==============================================================================
--- (empty file)
+++ trunk/libhal-glib/egg-debug.h Mon Oct 20 17:31:36 2008
@@ -0,0 +1 @@
+link ../src/egg-debug.h
\ No newline at end of file
Modified: trunk/libhal-glib/libhal-gdevice.c
==============================================================================
--- trunk/libhal-glib/libhal-gdevice.c (original)
+++ trunk/libhal-glib/libhal-gdevice.c Mon Oct 20 17:31:36 2008
@@ -27,7 +27,9 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
-#include <libdbus-proxy.h>
+
+#include "egg-debug.h"
+#include "egg-dbus-proxy.h"
#include "libhal-marshal.h"
#include "libhal-gpower.h"
@@ -45,7 +47,7 @@
DBusGConnection *connection;
gboolean use_property_modified;
gboolean use_condition;
- DbusProxy *gproxy;
+ EggDbusProxy *gproxy;
gchar *udi;
};
@@ -73,13 +75,13 @@
/**
* hal_gdevice_set_udi:
*
-const gchar * * Return value: TRUE for success, FALSE for failure
+ * Return value: TRUE for success, FALSE for failure
**/
gboolean
-hal_gdevice_set_udi (HalGDevice *device,
- const gchar *udi)
+hal_gdevice_set_udi (HalGDevice *device, const gchar *udi)
{
DBusGProxy *proxy;
+ DBusGConnection *connection;
g_return_val_if_fail (LIBHAL_IS_GDEVICE (device), FALSE);
g_return_val_if_fail (udi != NULL, FALSE);
@@ -89,13 +91,11 @@
return FALSE;
}
- proxy = dbus_proxy_assign (device->priv->gproxy,
- DBUS_PROXY_SYSTEM,
- HAL_DBUS_SERVICE,
- udi,
- HAL_DBUS_INTERFACE_DEVICE);
+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+ proxy = egg_dbus_proxy_assign (device->priv->gproxy, connection,
+ HAL_DBUS_SERVICE, udi, HAL_DBUS_INTERFACE_DEVICE);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy failed");
+ egg_warning ("proxy failed");
return FALSE;
}
device->priv->udi = g_strdup (udi);
@@ -138,9 +138,9 @@
g_return_val_if_fail (value != NULL, FALSE);
g_return_val_if_fail (device->priv->udi != NULL, FALSE);
- proxy = dbus_proxy_get_proxy (device->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (device->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
ret = dbus_g_proxy_call (proxy, "GetPropertyBoolean", error,
@@ -178,9 +178,9 @@
g_return_val_if_fail (value != NULL, FALSE);
g_return_val_if_fail (device->priv->udi != NULL, FALSE);
- proxy = dbus_proxy_get_proxy (device->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (device->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
ret = dbus_g_proxy_call (proxy, "GetPropertyString", error,
@@ -216,9 +216,9 @@
g_return_val_if_fail (value != NULL, FALSE);
g_return_val_if_fail (device->priv->udi != NULL, FALSE);
- proxy = dbus_proxy_get_proxy (device->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (device->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
ret = dbus_g_proxy_call (proxy, "GetPropertyInteger", error,
@@ -274,9 +274,9 @@
g_return_val_if_fail (has_capability != NULL, FALSE);
g_return_val_if_fail (device->priv->udi != NULL, FALSE);
- proxy = dbus_proxy_get_proxy (device->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (device->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
ret = dbus_g_proxy_call (proxy, "QueryCapability", error,
@@ -341,7 +341,7 @@
for (i = 0; i < properties->len; i++) {
array = g_ptr_array_index (properties, i);
if (array->n_values != 3) {
- g_warning ("array->n_values invalid (!3)");
+ egg_warning ("array->n_values invalid (!3)");
return;
}
@@ -394,9 +394,9 @@
G_TYPE_NONE, G_TYPE_INT,
struct_array_type, G_TYPE_INVALID);
- proxy = dbus_proxy_get_proxy (device->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (device->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
dbus_g_proxy_add_signal (proxy, "PropertyModified",
@@ -449,9 +449,9 @@
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_INVALID);
- proxy = dbus_proxy_get_proxy (device->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (device->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
dbus_g_proxy_add_signal (proxy, "Condition",
@@ -480,9 +480,9 @@
device->priv->use_condition = FALSE;
- proxy = dbus_proxy_get_proxy (device->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (device->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
dbus_g_proxy_disconnect_signal (proxy, "Condition",
@@ -509,9 +509,9 @@
device->priv->use_property_modified = FALSE;
- proxy = dbus_proxy_get_proxy (device->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (device->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
dbus_g_proxy_disconnect_signal (proxy, "PropertyModified",
@@ -584,7 +584,7 @@
device->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (error != NULL) {
- g_warning ("%s", error->message);
+ egg_warning ("%s", error->message);
g_error_free (error);
}
@@ -592,7 +592,7 @@
device->priv->use_condition = FALSE;
/* get the manager connection */
- device->priv->gproxy = dbus_proxy_new ();
+ device->priv->gproxy = egg_dbus_proxy_new ();
g_signal_connect (device->priv->gproxy, "proxy-status",
G_CALLBACK (proxy_status_cb), device);
}
Modified: trunk/libhal-glib/libhal-gdevicestore.c
==============================================================================
--- trunk/libhal-glib/libhal-gdevicestore.c (original)
+++ trunk/libhal-glib/libhal-gdevicestore.c Mon Oct 20 17:31:36 2008
@@ -27,6 +27,8 @@
#include <glib.h>
#include <glib/gi18n.h>
+#include "egg-debug.h"
+
#include "libhal-marshal.h"
#include "libhal-gdevice.h"
#include "libhal-gdevicestore.h"
Modified: trunk/libhal-glib/libhal-gmanager.c
==============================================================================
--- trunk/libhal-glib/libhal-gmanager.c (original)
+++ trunk/libhal-glib/libhal-gmanager.c Mon Oct 20 17:31:36 2008
@@ -28,7 +28,9 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
-#include <libdbus-proxy.h>
+
+#include "egg-debug.h"
+#include "egg-dbus-proxy.h"
#include "libhal-marshal.h"
#include "libhal-gpower.h"
@@ -45,7 +47,7 @@
{
DBusGConnection *connection;
HalGDevice *computer;
- DbusProxy *gproxy;
+ EggDbusProxy *gproxy;
};
/* Signals emitted from HalGManager are:
@@ -410,9 +412,9 @@
g_return_val_if_fail (LIBHAL_IS_GMANAGER (manager), FALSE);
- proxy = dbus_proxy_get_proxy (manager->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (manager->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
@@ -452,9 +454,9 @@
g_return_val_if_fail (LIBHAL_IS_GMANAGER (manager), FALSE);
- proxy = dbus_proxy_get_proxy (manager->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (manager->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
@@ -497,25 +499,25 @@
{
GError *error = NULL;
DBusGProxy *proxy;
+ DBusGConnection *connection;
gboolean ret;
manager->priv = LIBHAL_GMANAGER_GET_PRIVATE (manager);
manager->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (error) {
- g_warning ("%s", error->message);
+ egg_warning ("%s", error->message);
g_error_free (error);
}
/* get the manager connection */
- manager->priv->gproxy = dbus_proxy_new ();
- proxy = dbus_proxy_assign (manager->priv->gproxy,
- DBUS_PROXY_SYSTEM,
- HAL_DBUS_SERVICE,
- HAL_DBUS_PATH_MANAGER,
- HAL_DBUS_INTERFACE_MANAGER);
+ manager->priv->gproxy = egg_dbus_proxy_new ();
+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+ proxy = egg_dbus_proxy_assign (manager->priv->gproxy, connection,
+ HAL_DBUS_SERVICE, HAL_DBUS_PATH_MANAGER,
+ HAL_DBUS_INTERFACE_MANAGER);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("Either HAL or DBUS are not working!");
+ egg_warning ("Either HAL or DBUS are not working!");
exit (0);
}
@@ -526,7 +528,7 @@
manager->priv->computer = hal_gdevice_new();
ret = hal_gdevice_set_udi (manager->priv->computer, HAL_ROOT_COMPUTER);
if (!ret) {
- g_warning ("failed to get Computer root object");
+ egg_warning ("failed to get Computer root object");
}
/* blindly try to connect, assuming HAL is alive */
@@ -556,7 +558,7 @@
return FALSE;
}
if (strcmp (formfactor, "laptop") != 0) {
- g_warning ("This machine is not identified as a laptop."
+ egg_warning ("This machine is not identified as a laptop."
"system.formfactor is %s.", formfactor);
ret = FALSE;
}
Modified: trunk/libhal-glib/libhal-gpower.c
==============================================================================
--- trunk/libhal-glib/libhal-gpower.c (original)
+++ trunk/libhal-glib/libhal-gpower.c Mon Oct 20 17:31:36 2008
@@ -27,9 +27,11 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
-#include <libdbus-proxy.h>
#include <time.h>
+#include "egg-debug.h"
+#include "egg-dbus-proxy.h"
+
#include "libhal-marshal.h"
#include "libhal-gpower.h"
#include "libhal-gdevice.h"
@@ -44,7 +46,7 @@
struct HalGPowerPrivate
{
HalGDevice *computer;
- DbusProxy *gproxy;
+ EggDbusProxy *gproxy;
};
static gpointer hal_gpower_object = NULL;
@@ -70,17 +72,16 @@
static void
hal_gpower_init (HalGPower *power)
{
+ DBusGConnection *connection;
power->priv = LIBHAL_GPOWER_GET_PRIVATE (power);
/* get the power connection */
- power->priv->gproxy = dbus_proxy_new ();
- dbus_proxy_assign (power->priv->gproxy,
- DBUS_PROXY_SYSTEM,
- HAL_DBUS_SERVICE,
- HAL_ROOT_COMPUTER,
- HAL_DBUS_INTERFACE_POWER);
+ power->priv->gproxy = egg_dbus_proxy_new ();
+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+ egg_dbus_proxy_assign (power->priv->gproxy, connection, HAL_DBUS_SERVICE,
+ HAL_ROOT_COMPUTER, HAL_DBUS_INTERFACE_POWER);
if (power->priv->gproxy == NULL)
- g_warning ("HAL does not support power management!");
+ egg_warning ("HAL does not support power management!");
power->priv->computer = hal_gdevice_new ();
hal_gdevice_set_udi (power->priv->computer, HAL_ROOT_COMPUTER);
@@ -109,7 +110,7 @@
return FALSE;
}
if (strcmp (formfactor, "laptop") != 0) {
- g_debug ("This machine is not identified as a laptop."
+ egg_debug ("This machine is not identified as a laptop."
"system.formfactor is %s.", formfactor);
ret = FALSE;
}
@@ -162,7 +163,7 @@
"power_management.can_suspend",
&can_suspend, NULL);
if (exists == FALSE) {
- g_warning ("Key can_suspend missing");
+ egg_warning ("Key can_suspend missing");
return FALSE;
}
return can_suspend;
@@ -189,7 +190,7 @@
"power_management.can_hibernate",
&can_hibernate, NULL);
if (exists == FALSE) {
- g_warning ("Key can_hibernate missing");
+ egg_warning ("Key can_hibernate missing");
return FALSE;
}
return can_hibernate;
@@ -210,12 +211,12 @@
/* DBUS might time out, which is okay. We can remove this code
when the dbus glib bindings are fixed. See #332888 */
if (g_error_matches (*error, DBUS_GERROR, DBUS_GERROR_NO_REPLY)) {
- g_warning ("DBUS timed out, but recovering");
+ egg_warning ("DBUS timed out, but recovering");
g_error_free (*error);
*error = NULL;
return TRUE;
}
- g_warning ("Method failed\n(%s)", (*error)->message);
+ egg_warning ("Method failed\n(%s)", (*error)->message);
return FALSE;
}
@@ -239,9 +240,9 @@
g_return_val_if_fail (LIBHAL_IS_GPOWER (power), FALSE);
- proxy = dbus_proxy_get_proxy (power->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (power->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
@@ -255,7 +256,7 @@
if (error != NULL && hal_gpower_filter_error (error))
return TRUE;
if (retval != 0)
- g_warning ("Suspend failed without error message");
+ egg_warning ("Suspend failed without error message");
/* compare the amount of time that has passed - if it's more than 6 hours
* then the dbus call timed out (dbus-pending-call.c) */
@@ -290,13 +291,13 @@
g_return_val_if_fail (LIBHAL_IS_GPOWER (power), FALSE);
g_return_val_if_fail (method != NULL, FALSE);
- proxy = dbus_proxy_get_proxy (power->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (power->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("not connected");
+ egg_warning ("not connected");
return FALSE;
}
@@ -309,7 +310,7 @@
if (error != NULL && hal_gpower_filter_error (error))
return TRUE;
if (retval != 0)
- g_warning ("%s failed in a horrible way!", method);
+ egg_warning ("%s failed in a horrible way!", method);
/* compare the amount of time that has passed - if it's more than 6 hours
* then the dbus call timed out (dbus-pending-call.c) */
@@ -386,15 +387,15 @@
g_return_val_if_fail (power != NULL, FALSE);
g_return_val_if_fail (LIBHAL_IS_GPOWER (power), FALSE);
- proxy = dbus_proxy_get_proxy (power->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (power->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
/* abort if we are not a "qualified" laptop */
if (hal_gpower_is_laptop (power) == FALSE) {
- g_debug ("We are not a laptop, so not even trying");
+ egg_debug ("We are not a laptop, so not even trying");
return FALSE;
}
@@ -404,7 +405,7 @@
G_TYPE_INT, &retval,
G_TYPE_INVALID);
if (retval != 0)
- g_warning ("SetPowerSave failed in a horrible way!");
+ egg_warning ("SetPowerSave failed in a horrible way!");
return ret;
}
@@ -463,9 +464,9 @@
g_return_val_if_fail (power != NULL, FALSE);
g_return_val_if_fail (LIBHAL_IS_GPOWER (power), FALSE);
- proxy = dbus_proxy_get_proxy (power->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (power->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
@@ -491,9 +492,9 @@
g_return_val_if_fail (power != NULL, FALSE);
g_return_val_if_fail (LIBHAL_IS_GPOWER (power), FALSE);
- proxy = dbus_proxy_get_proxy (power->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (power->priv->gproxy);
if (DBUS_IS_G_PROXY (proxy) == FALSE) {
- g_warning ("proxy NULL!!");
+ egg_warning ("proxy NULL!!");
return FALSE;
}
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Mon Oct 20 17:31:36 2008
@@ -33,7 +33,6 @@
-DEGG_LOG_FILE=\""$(PK_LOG_DIR)/gnome-power-manager"\" \
-I$(top_srcdir) \
-I$(top_srcdir)/libhal-glib \
- -I$(top_srcdir)/libdbus-glib \
$(NULL)
LOCAL_LIBHAL_LIBS = \
@@ -42,9 +41,6 @@
$(top_builddir)/libhal-glib/libhal-gmanager.la \
$(top_builddir)/libhal-glib/libhal-gpower.la
-LOCAL_LIBDBUS_LIBS = \
- $(top_builddir)/libdbus-glib/libdbus-proxy.la
-
bin_PROGRAMS = \
gnome-power-manager \
gnome-power-preferences \
@@ -65,6 +61,10 @@
egg-precision.c \
egg-discrete.h \
egg-discrete.c \
+ egg-dbus-proxy.h \
+ egg-dbus-proxy.c \
+ egg-dbus-monitor.h \
+ egg-dbus-monitor.c \
gpm-statistics.c \
gpm-statistics-core.h \
gpm-statistics-core.c \
@@ -86,7 +86,6 @@
$(GLIB_LIBS) \
$(GNOME_LIBS) \
$(DBUS_LIBS) \
- $(LOCAL_LIBDBUS_LIBS) \
$(NULL)
if HAVE_UNIQUE
@@ -99,6 +98,10 @@
egg-debug.c \
egg-unique.h \
egg-unique.c \
+ egg-dbus-proxy.h \
+ egg-dbus-proxy.c \
+ egg-dbus-monitor.h \
+ egg-dbus-monitor.c \
gpm-dpms.h \
gpm-dpms.c \
gpm-conf.h \
@@ -127,7 +130,6 @@
$(POLKIT_GNOME_LIBS) \
$(GPM_EXTRA_LIBS) \
$(LOCAL_LIBHAL_LIBS) \
- $(LOCAL_LIBDBUS_LIBS) \
$(NULL)
if HAVE_UNIQUE
@@ -142,6 +144,8 @@
egg-debug.c \
egg-dbus-monitor.h \
egg-dbus-monitor.c \
+ egg-dbus-proxy.h \
+ egg-dbus-proxy.c \
egg-precision.h \
egg-precision.c \
egg-discrete.h \
@@ -235,7 +239,6 @@
$(CANBERRA_LIBS) \
$(GPM_EXTRA_LIBS) \
$(LOCAL_LIBHAL_LIBS) \
- $(LOCAL_LIBDBUS_LIBS) \
$(NULL)
if HAVE_LIBNOTIFY
@@ -253,6 +256,8 @@
egg-debug.c \
egg-dbus-monitor.h \
egg-dbus-monitor.c \
+ egg-dbus-proxy.h \
+ egg-dbus-proxy.c \
egg-precision.h \
egg-precision.c \
egg-discrete.h \
@@ -317,7 +322,6 @@
$(POLKIT_GNOME_LIBS) \
$(DBUS_LIBS) \
$(LIBNOTIFY_LIBS) \
- $(LOCAL_LIBDBUS_LIBS) \
$(LOCAL_LIBHAL_LIBS) \
$(GPM_EXTRA_LIBS) \
$(NULL)
Modified: trunk/src/egg-dbus-monitor.c
==============================================================================
--- trunk/src/egg-dbus-monitor.c (original)
+++ trunk/src/egg-dbus-monitor.c Mon Oct 20 17:31:36 2008
@@ -40,7 +40,6 @@
struct EggDbusMonitorPrivate
{
- EggDbusMonitorType bus_type;
gchar *service;
DBusGProxy *proxy;
DBusGConnection *connection;
@@ -105,7 +104,7 @@
/**
* egg_dbus_monitor_assign:
* @monitor: This class instance
- * @bus_type: The bus type, either EGG_DBUS_MONITOR_SESSION or EGG_DBUS_MONITOR_SYSTEM
+ * @connection: The bus connection
* @service: The EGG_DBUS_MONITOR service name
* Return value: success
*
@@ -113,7 +112,7 @@
* have to connect up the callback before this function is called.
**/
gboolean
-egg_dbus_monitor_assign (EggDbusMonitor *monitor, EggDbusMonitorType bus_type, const gchar *service)
+egg_dbus_monitor_assign (EggDbusMonitor *monitor, DBusGConnection *connection, const gchar *service)
{
GError *error = NULL;
gboolean connected;
@@ -121,6 +120,7 @@
g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE);
g_return_val_if_fail (service != NULL, FALSE);
+ g_return_val_if_fail (connection != NULL, FALSE);
if (monitor->priv->proxy != NULL) {
egg_warning ("already assigned!");
@@ -128,18 +128,7 @@
}
monitor->priv->service = g_strdup (service);
- monitor->priv->bus_type = bus_type;
-
- /* connect to correct bus */
- if (bus_type == EGG_DBUS_MONITOR_SESSION)
- monitor->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- else
- monitor->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (error != NULL) {
- egg_warning ("Cannot connect to bus: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
+ monitor->priv->connection = connection;
monitor->priv->proxy = dbus_g_proxy_new_for_name_owner (monitor->priv->connection,
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
@@ -225,7 +214,7 @@
{
monitor->priv = EGG_DBUS_MONITOR_GET_PRIVATE (monitor);
monitor->priv->service = NULL;
- monitor->priv->bus_type = EGG_DBUS_MONITOR_SESSION;
+ monitor->priv->connection = NULL;
monitor->priv->proxy = NULL;
}
Modified: trunk/src/egg-dbus-monitor.h
==============================================================================
--- trunk/src/egg-dbus-monitor.h (original)
+++ trunk/src/egg-dbus-monitor.h Mon Oct 20 17:31:36 2008
@@ -23,6 +23,7 @@
#define __EGG_DBUS_MONITOR_H
#include <glib-object.h>
+#include <dbus/dbus-glib.h>
G_BEGIN_DECLS
@@ -51,15 +52,10 @@
void (* connection_replaced) (EggDbusMonitor *watch);
} EggDbusMonitorClass;
-typedef enum {
- EGG_DBUS_MONITOR_SESSION,
- EGG_DBUS_MONITOR_SYSTEM
-} EggDbusMonitorType;
-
GType egg_dbus_monitor_get_type (void) G_GNUC_CONST;
EggDbusMonitor *egg_dbus_monitor_new (void);
gboolean egg_dbus_monitor_assign (EggDbusMonitor *monitor,
- EggDbusMonitorType bus_type,
+ DBusGConnection *connection,
const gchar *service);
gboolean egg_dbus_monitor_is_connected (EggDbusMonitor *monitor);
Added: trunk/src/egg-dbus-proxy.c
==============================================================================
--- (empty file)
+++ trunk/src/egg-dbus-proxy.c Mon Oct 20 17:31:36 2008
@@ -0,0 +1,303 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2008 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <dbus/dbus-glib.h>
+
+#include "egg-debug.h"
+#include "egg-dbus-monitor.h"
+#include "egg-dbus-proxy.h"
+
+static void egg_dbus_proxy_class_init (EggDbusProxyClass *klass);
+static void egg_dbus_proxy_init (EggDbusProxy *proxy);
+static void egg_dbus_proxy_finalize (GObject *object);
+
+#define EGG_DBUS_PROXY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_TYPE_DBUS_PROXY, EggDbusProxyPrivate))
+
+/* this is a managed proxy, i.e. a proxy that handles messagebus and DBUS service restarts. */
+struct EggDbusProxyPrivate
+{
+ gchar *service;
+ gchar *interface;
+ gchar *path;
+ DBusGProxy *proxy;
+ EggDbusMonitor *monitor;
+ gboolean assigned;
+ DBusGConnection *connection;
+ gulong monitor_callback_id;
+};
+
+enum {
+ PROXY_STATUS,
+ LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (EggDbusProxy, egg_dbus_proxy, G_TYPE_OBJECT)
+
+/**
+ * egg_dbus_proxy_connect:
+ * @proxy: This class instance
+ * Return value: success
+ **/
+static gboolean
+egg_dbus_proxy_connect (EggDbusProxy *proxy)
+{
+ GError *error = NULL;
+
+ g_return_val_if_fail (EGG_IS_DBUS_PROXY (proxy), FALSE);
+
+ /* are already connected? */
+ if (proxy->priv->proxy != NULL) {
+ egg_debug ("already connected to %s", proxy->priv->service);
+ return FALSE;
+ }
+
+ proxy->priv->proxy = dbus_g_proxy_new_for_name_owner (proxy->priv->connection,
+ proxy->priv->service,
+ proxy->priv->path,
+ proxy->priv->interface,
+ &error);
+ /* check for any possible error */
+ if (error) {
+ egg_warning ("DBUS error: %s", error->message);
+ g_error_free (error);
+ proxy->priv->proxy = NULL;
+ }
+
+ /* shouldn't be, but make sure proxy valid */
+ if (proxy->priv->proxy == NULL) {
+ egg_debug ("proxy is NULL, maybe the daemon responsible "
+ "for %s is not running?", proxy->priv->service);
+ return FALSE;
+ }
+
+ g_signal_emit (proxy, signals [PROXY_STATUS], 0, TRUE);
+
+ return TRUE;
+}
+
+/**
+ * egg_dbus_proxy_disconnect:
+ * @proxy: This class instance
+ * Return value: success
+ **/
+static gboolean
+egg_dbus_proxy_disconnect (EggDbusProxy *proxy)
+{
+ g_return_val_if_fail (EGG_IS_DBUS_PROXY (proxy), FALSE);
+
+ /* are already disconnected? */
+ if (proxy->priv->proxy == NULL) {
+ if (proxy->priv->service)
+ egg_debug ("already disconnected from %s", proxy->priv->service);
+ else
+ egg_debug ("already disconnected.");
+ return FALSE;
+ }
+
+ g_signal_emit (proxy, signals [PROXY_STATUS], 0, FALSE);
+
+ g_object_unref (proxy->priv->proxy);
+ proxy->priv->proxy = NULL;
+
+ return TRUE;
+}
+
+/**
+ * dbus_monitor_connection_cb:
+ * @proxy: The dbus raw proxy
+ * @status: The status of the service, where TRUE is connected
+ * @screensaver: This class instance
+ **/
+static void
+dbus_monitor_connection_cb (EggDbusMonitor *monitor, gboolean status, EggDbusProxy *proxy)
+{
+ g_return_if_fail (EGG_IS_DBUS_PROXY (proxy));
+ if (proxy->priv->assigned == FALSE)
+ return;
+ if (status)
+ egg_dbus_proxy_connect (proxy);
+ else
+ egg_dbus_proxy_disconnect (proxy);
+}
+
+/**
+ * egg_dbus_proxy_assign:
+ * @proxy: This class instance
+ * @connections: The bus connection
+ * @service: The DBUS service name
+ * @interface: The DBUS interface
+ * @path: The DBUS path
+ * Return value: The DBUS proxy, or NULL if we haven't connected yet.
+ **/
+DBusGProxy *
+egg_dbus_proxy_assign (EggDbusProxy *proxy, DBusGConnection *connection,
+ const gchar *service, const gchar *path, const gchar *interface)
+{
+ g_return_val_if_fail (EGG_IS_DBUS_PROXY (proxy), NULL);
+ g_return_val_if_fail (connection != NULL, NULL);
+ g_return_val_if_fail (service != NULL, NULL);
+ g_return_val_if_fail (interface != NULL, NULL);
+ g_return_val_if_fail (path != NULL, NULL);
+
+ if (proxy->priv->assigned) {
+ egg_warning ("already assigned proxy!");
+ return NULL;
+ }
+
+ proxy->priv->service = g_strdup (service);
+ proxy->priv->interface = g_strdup (interface);
+ proxy->priv->path = g_strdup (path);
+ proxy->priv->connection = connection;
+ proxy->priv->assigned = TRUE;
+
+ /* We have to save the connection and remove the signal id later as
+ instances of this object are likely to be registering with a
+ singleton object many times */
+ egg_dbus_monitor_assign (proxy->priv->monitor, connection, service);
+
+ /* try to connect and return proxy (or NULL if invalid) */
+ egg_dbus_proxy_connect (proxy);
+
+ return proxy->priv->proxy;
+}
+
+/**
+ * egg_dbus_proxy_get_proxy:
+ * @proxy: This class instance
+ * Return value: The DBUS proxy, or NULL if we are not connected
+ **/
+DBusGProxy *
+egg_dbus_proxy_get_proxy (EggDbusProxy *proxy)
+{
+ g_return_val_if_fail (EGG_IS_DBUS_PROXY (proxy), NULL);
+ if (proxy->priv->assigned == FALSE)
+ return NULL;
+ return proxy->priv->proxy;
+}
+
+/**
+ * egg_dbus_proxy_is_connected:
+ * @proxy: This class instance
+ * Return value: if we are connected to a valid proxy
+ **/
+gboolean
+egg_dbus_proxy_is_connected (EggDbusProxy *proxy)
+{
+ g_return_val_if_fail (EGG_IS_DBUS_PROXY (proxy), FALSE);
+ if (proxy->priv->assigned == FALSE)
+ return FALSE;
+ if (proxy->priv->proxy == NULL)
+ return FALSE;
+ return TRUE;
+}
+
+/**
+ * egg_dbus_proxy_class_init:
+ * @proxy: This class instance
+ **/
+static void
+egg_dbus_proxy_class_init (EggDbusProxyClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = egg_dbus_proxy_finalize;
+ g_type_class_add_private (klass, sizeof (EggDbusProxyPrivate));
+
+ signals [PROXY_STATUS] =
+ g_signal_new ("proxy-status",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggDbusProxyClass, proxy_status),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+}
+
+/**
+ * egg_dbus_proxy_init:
+ * @egg_dbus_proxy: This class instance
+ **/
+static void
+egg_dbus_proxy_init (EggDbusProxy *proxy)
+{
+ proxy->priv = EGG_DBUS_PROXY_GET_PRIVATE (proxy);
+
+ proxy->priv->connection = NULL;
+ proxy->priv->proxy = NULL;
+ proxy->priv->service = NULL;
+ proxy->priv->interface = NULL;
+ proxy->priv->path = NULL;
+ proxy->priv->assigned = FALSE;
+ proxy->priv->monitor = egg_dbus_monitor_new ();
+ proxy->priv->monitor_callback_id =
+ g_signal_connect (proxy->priv->monitor, "connection-changed",
+ G_CALLBACK (dbus_monitor_connection_cb), proxy);
+ proxy->priv->monitor_callback_id = 0;
+}
+
+/**
+ * egg_dbus_proxy_finalize:
+ * @object: This class instance
+ **/
+static void
+egg_dbus_proxy_finalize (GObject *object)
+{
+ EggDbusProxy *proxy;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (EGG_IS_DBUS_PROXY (object));
+
+ proxy = EGG_DBUS_PROXY (object);
+ proxy->priv = EGG_DBUS_PROXY_GET_PRIVATE (proxy);
+
+ if (proxy->priv->monitor_callback_id != 0)
+ g_signal_handler_disconnect (proxy->priv->monitor,
+ proxy->priv->monitor_callback_id);
+
+ egg_dbus_proxy_disconnect (proxy);
+
+ if (proxy->priv->proxy != NULL)
+ g_object_unref (proxy->priv->proxy);
+ g_object_unref (proxy->priv->monitor);
+ g_free (proxy->priv->service);
+ g_free (proxy->priv->interface);
+ g_free (proxy->priv->path);
+
+ G_OBJECT_CLASS (egg_dbus_proxy_parent_class)->finalize (object);
+}
+
+/**
+ * egg_dbus_proxy_new:
+ * Return value: new class instance.
+ **/
+EggDbusProxy *
+egg_dbus_proxy_new (void)
+{
+ EggDbusProxy *proxy;
+ proxy = g_object_new (EGG_TYPE_DBUS_PROXY, NULL);
+ return EGG_DBUS_PROXY (proxy);
+}
+
Added: trunk/src/egg-dbus-proxy.h
==============================================================================
--- (empty file)
+++ trunk/src/egg-dbus-proxy.h Mon Oct 20 17:31:36 2008
@@ -0,0 +1,66 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2008 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __DBUSPROXY_H
+#define __DBUSPROXY_H
+
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+#define EGG_TYPE_DBUS_PROXY (egg_dbus_proxy_get_type ())
+#define EGG_DBUS_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_TYPE_DBUS_PROXY, EggDbusProxy))
+#define EGG_DBUS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EGG_TYPE_DBUS_PROXY, EggDbusProxyClass))
+#define EGG_IS_DBUS_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_TYPE_DBUS_PROXY))
+#define EGG_IS_DBUS_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGG_TYPE_DBUS_PROXY))
+#define EGG_DBUS_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGG_TYPE_DBUS_PROXY, EggDbusProxyClass))
+
+typedef struct EggDbusProxyPrivate EggDbusProxyPrivate;
+
+typedef struct
+{
+ GObject parent;
+ EggDbusProxyPrivate *priv;
+} EggDbusProxy;
+
+typedef struct
+{
+ GObjectClass parent_class;
+ void (* proxy_status) (EggDbusProxy *proxy,
+ gboolean status);
+} EggDbusProxyClass;
+
+GType egg_dbus_proxy_get_type (void);
+EggDbusProxy *egg_dbus_proxy_new (void);
+
+DBusGProxy *egg_dbus_proxy_assign (EggDbusProxy *dbus_proxy,
+ DBusGConnection *connection,
+ const gchar *service,
+ const gchar *path,
+ const gchar *interface);
+DBusGProxy *egg_dbus_proxy_get_proxy (EggDbusProxy *egg_dbus_proxy);
+gboolean egg_dbus_proxy_is_connected (EggDbusProxy *egg_dbus_proxy);
+
+G_END_DECLS
+
+#endif /* __DBUSPROXY_H */
+
Modified: trunk/src/gpm-brightness-hal.c
==============================================================================
--- trunk/src/gpm-brightness-hal.c (original)
+++ trunk/src/gpm-brightness-hal.c Mon Oct 20 17:31:36 2008
@@ -40,7 +40,7 @@
#include <libhal-gdevice.h>
#include <libhal-gmanager.h>
-#include <libdbus-proxy.h>
+#include "egg-dbus-proxy.h"
#include "egg-debug.h"
#include "egg-discrete.h"
@@ -59,7 +59,7 @@
guint levels;
gchar *udi;
gboolean hw_changed;
- DbusProxy *gproxy;
+ EggDbusProxy *gproxy;
/* true if hardware automatically sets brightness in response to
* key press events */
@@ -92,7 +92,7 @@
g_return_val_if_fail (GPM_IS_BRIGHTNESS_HAL (brightness), FALSE);
- proxy = dbus_proxy_get_proxy (brightness->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (brightness->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected to HAL");
return FALSE;
@@ -140,7 +140,7 @@
g_return_val_if_fail (GPM_IS_BRIGHTNESS_HAL (brightness), FALSE);
- proxy = dbus_proxy_get_proxy (brightness->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (brightness->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected to HAL");
return FALSE;
@@ -447,6 +447,7 @@
HalGManager *manager;
HalGDevice *device;
gboolean res;
+ DBusGConnection *connection;
brightness->priv = GPM_BRIGHTNESS_HAL_GET_PRIVATE (brightness);
brightness->priv->gproxy = NULL;
@@ -496,9 +497,10 @@
g_object_unref (device);
/* get a managed proxy */
- brightness->priv->gproxy = dbus_proxy_new ();
- dbus_proxy_assign (brightness->priv->gproxy, DBUS_PROXY_SYSTEM, HAL_DBUS_SERVICE,
- brightness->priv->udi, HAL_DBUS_INTERFACE_LAPTOP_PANEL);
+ brightness->priv->gproxy = egg_dbus_proxy_new ();
+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+ egg_dbus_proxy_assign (brightness->priv->gproxy, connection, HAL_DBUS_SERVICE,
+ brightness->priv->udi, HAL_DBUS_INTERFACE_LAPTOP_PANEL);
/* this changes under our feet */
gpm_brightness_hal_get_hw (brightness, &brightness->priv->last_set_hw);
Modified: trunk/src/gpm-brightness-kbd.c
==============================================================================
--- trunk/src/gpm-brightness-kbd.c (original)
+++ trunk/src/gpm-brightness-kbd.c Mon Oct 20 17:31:36 2008
@@ -41,7 +41,7 @@
#include <libhal-gdevice.h>
#include <libhal-gmanager.h>
-#include <libdbus-proxy.h>
+#include "egg-dbus-proxy.h"
#include "egg-debug.h"
#include "egg-discrete.h"
@@ -69,7 +69,7 @@
gchar *udi;
GpmConf *conf;
GpmLightSensor *sensor;
- DbusProxy *gproxy;
+ EggDbusProxy *gproxy;
};
enum {
@@ -100,7 +100,7 @@
g_return_val_if_fail (brightness != NULL, FALSE);
g_return_val_if_fail (GPM_IS_BRIGHTNESS_KBD (brightness), FALSE);
- proxy = dbus_proxy_get_proxy (brightness->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (brightness->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected to HAL");
return FALSE;
@@ -144,7 +144,7 @@
g_return_val_if_fail (brightness != NULL, FALSE);
g_return_val_if_fail (GPM_IS_BRIGHTNESS_KBD (brightness), FALSE);
- proxy = dbus_proxy_get_proxy (brightness->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (brightness->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected to HAL");
return FALSE;
@@ -677,6 +677,7 @@
gchar **names;
HalGManager *manager;
HalGDevice *device;
+ DBusGConnection *connection;
brightness->priv = GPM_BRIGHTNESS_KBD_GET_PRIVATE (brightness);
@@ -707,12 +708,10 @@
brightness->priv->is_disabled = FALSE;
/* get a managed proxy */
- brightness->priv->gproxy = dbus_proxy_new ();
- dbus_proxy_assign (brightness->priv->gproxy,
- DBUS_PROXY_SYSTEM,
- HAL_DBUS_SERVICE,
- brightness->priv->udi,
- HAL_DBUS_INTERFACE_KBD_BACKLIGHT);
+ brightness->priv->gproxy = egg_dbus_proxy_new ();
+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+ egg_dbus_proxy_assign (brightness->priv->gproxy, connection, HAL_DBUS_SERVICE,
+ brightness->priv->udi, HAL_DBUS_INTERFACE_KBD_BACKLIGHT);
/* get levels that the adapter supports -- this does not change ever */
device = hal_gdevice_new ();
Modified: trunk/src/gpm-inhibit.c
==============================================================================
--- trunk/src/gpm-inhibit.c (original)
+++ trunk/src/gpm-inhibit.c Mon Oct 20 17:31:36 2008
@@ -522,12 +522,12 @@
***************************************************************************/
#ifdef EGG_TEST
#include "egg-test.h"
-#include <libdbus-proxy.h>
+#include "egg-dbus-proxy.h"
#include "gpm-common.h"
/** cookie is returned as an unsigned integer */
static gboolean
-inhibit (DbusProxy *gproxy,
+inhibit (EggDbusProxy *gproxy,
const gchar *appname,
const gchar *reason,
guint *cookie)
@@ -538,7 +538,7 @@
g_return_val_if_fail (cookie != NULL, FALSE);
- proxy = dbus_proxy_get_proxy (gproxy);
+ proxy = egg_dbus_proxy_get_proxy (gproxy);
if (proxy == NULL) {
g_warning ("not connected");
return FALSE;
@@ -564,14 +564,14 @@
}
static gboolean
-uninhibit (DbusProxy *gproxy,
+uninhibit (EggDbusProxy *gproxy,
guint cookie)
{
GError *error = NULL;
gboolean ret;
DBusGProxy *proxy;
- proxy = dbus_proxy_get_proxy (gproxy);
+ proxy = egg_dbus_proxy_get_proxy (gproxy);
if (proxy == NULL) {
g_warning ("not connected");
return FALSE;
@@ -589,14 +589,14 @@
}
static gboolean
-has_inhibit (DbusProxy *gproxy,
+has_inhibit (EggDbusProxy *gproxy,
gboolean *has_inhibit)
{
GError *error = NULL;
gboolean ret;
DBusGProxy *proxy;
- proxy = dbus_proxy_get_proxy (gproxy);
+ proxy = egg_dbus_proxy_get_proxy (gproxy);
if (proxy == NULL) {
g_warning ("not connected");
return FALSE;
@@ -625,17 +625,17 @@
gboolean valid;
guint cookie1 = 0;
guint cookie2 = 0;
- DbusProxy *gproxy;
+ DBusGConnection *connection;
+ EggDbusProxy *gproxy;
if (egg_test_start (test, "GpmInhibit") == FALSE) {
return;
}
- gproxy = dbus_proxy_new ();
- dbus_proxy_assign (gproxy, DBUS_PROXY_SESSION,
- GPM_DBUS_SERVICE,
- GPM_DBUS_PATH_INHIBIT,
- GPM_DBUS_INTERFACE_INHIBIT);
+ gproxy = egg_dbus_proxy_new ();
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ egg_dbus_proxy_assign (gproxy, connection, GPM_DBUS_SERVICE,
+ GPM_DBUS_PATH_INHIBIT, GPM_DBUS_INTERFACE_INHIBIT);
if (gproxy == NULL) {
g_warning ("Unable to get connection to power manager");
Modified: trunk/src/gpm-light-sensor.c
==============================================================================
--- trunk/src/gpm-light-sensor.c (original)
+++ trunk/src/gpm-light-sensor.c Mon Oct 20 17:31:36 2008
@@ -40,7 +40,7 @@
#include <libhal-gdevice.h>
#include <libhal-gmanager.h>
-#include <libdbus-proxy.h>
+#include "egg-dbus-proxy.h"
#include "egg-debug.h"
#include "egg-discrete.h"
@@ -60,7 +60,7 @@
gfloat calibration_abs;
gchar *udi;
gboolean has_sensor;
- DbusProxy *gproxy;
+ EggDbusProxy *gproxy;
};
enum {
@@ -94,7 +94,7 @@
g_return_val_if_fail (sensor != NULL, FALSE);
g_return_val_if_fail (GPM_IS_LIGHT_SENSOR (sensor), FALSE);
- proxy = dbus_proxy_get_proxy (sensor->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (sensor->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected to HAL");
return FALSE;
@@ -332,6 +332,7 @@
HalGManager *manager;
HalGDevice *device;
guint timeout;
+ DBusGConnection *connection;
sensor->priv = GPM_LIGHT_SENSOR_GET_PRIVATE (sensor);
sensor->priv->udi = NULL;
@@ -360,12 +361,11 @@
if (sensor->priv->has_sensor) {
egg_debug ("Using proper brightness sensor");
/* get a managed proxy */
- sensor->priv->gproxy = dbus_proxy_new ();
- dbus_proxy_assign (sensor->priv->gproxy,
- DBUS_PROXY_SYSTEM,
- HAL_DBUS_SERVICE,
- sensor->priv->udi,
- HAL_DBUS_INTERFACE_LIGHT_SENSOR);
+ sensor->priv->gproxy = egg_dbus_proxy_new ();
+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
+ egg_dbus_proxy_assign (sensor->priv->gproxy,
+ connection, HAL_DBUS_SERVICE,
+ sensor->priv->udi, HAL_DBUS_INTERFACE_LIGHT_SENSOR);
/* get levels that the adapter supports -- this does not change ever */
device = hal_gdevice_new ();
Modified: trunk/src/gpm-phone.c
==============================================================================
--- trunk/src/gpm-phone.c (original)
+++ trunk/src/gpm-phone.c Mon Oct 20 17:31:36 2008
@@ -360,6 +360,7 @@
static void
gpm_phone_init (GpmPhone *phone)
{
+ DBusGConnection *connection;
phone->priv = GPM_PHONE_GET_PRIVATE (phone);
phone->priv->connection = NULL;
@@ -371,7 +372,8 @@
phone->priv->monitor = egg_dbus_monitor_new ();
g_signal_connect (phone->priv->monitor, "connection-changed",
G_CALLBACK (monitor_connection_cb), phone);
- egg_dbus_monitor_assign (phone->priv->monitor, EGG_DBUS_MONITOR_SESSION, GNOME_PHONE_MANAGER_DBUS_SERVICE);
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ egg_dbus_monitor_assign (phone->priv->monitor, connection, GNOME_PHONE_MANAGER_DBUS_SERVICE);
gpm_phone_dbus_connect (phone);
}
Modified: trunk/src/gpm-profile.c
==============================================================================
--- trunk/src/gpm-profile.c (original)
+++ trunk/src/gpm-profile.c Mon Oct 20 17:31:36 2008
@@ -35,7 +35,7 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <libdbus-proxy.h>
+#include "egg-dbus-proxy.h"
#include "egg-color.h"
#include "gpm-common.h"
Modified: trunk/src/gpm-screensaver.c
==============================================================================
--- trunk/src/gpm-screensaver.c (original)
+++ trunk/src/gpm-screensaver.c Mon Oct 20 17:31:36 2008
@@ -29,7 +29,7 @@
#include "gpm-conf.h"
#include "gpm-screensaver.h"
#include "egg-debug.h"
-#include <libdbus-proxy.h>
+#include "egg-dbus-proxy.h"
static void gpm_screensaver_class_init (GpmScreensaverClass *klass);
static void gpm_screensaver_init (GpmScreensaver *screensaver);
@@ -39,7 +39,7 @@
struct GpmScreensaverPrivate
{
- DbusProxy *gproxy;
+ EggDbusProxy *gproxy;
GpmConf *conf;
guint idle_delay; /* the setting in g-s-p, cached */
};
@@ -114,7 +114,7 @@
g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
- proxy = dbus_proxy_get_proxy (screensaver->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (screensaver->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected");
return FALSE;
@@ -241,7 +241,7 @@
g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
- proxy = dbus_proxy_get_proxy (screensaver->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (screensaver->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected");
return FALSE;
@@ -287,7 +287,7 @@
g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), 0);
g_return_val_if_fail (reason != NULL, 0);
- proxy = dbus_proxy_get_proxy (screensaver->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (screensaver->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected");
return 0;
@@ -329,7 +329,7 @@
g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
- proxy = dbus_proxy_get_proxy (screensaver->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (screensaver->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected");
return FALSE;
@@ -368,7 +368,7 @@
g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
- proxy = dbus_proxy_get_proxy (screensaver->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (screensaver->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected");
return FALSE;
@@ -401,7 +401,7 @@
g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
- proxy = dbus_proxy_get_proxy (screensaver->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (screensaver->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected");
return FALSE;
@@ -430,7 +430,7 @@
g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
g_return_val_if_fail (time != NULL, FALSE);
- proxy = dbus_proxy_get_proxy (screensaver->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (screensaver->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected");
return FALSE;
@@ -542,15 +542,14 @@
gpm_screensaver_init (GpmScreensaver *screensaver)
{
DBusGProxy *proxy;
+ DBusGConnection *connection;
screensaver->priv = GPM_SCREENSAVER_GET_PRIVATE (screensaver);
- screensaver->priv->gproxy = dbus_proxy_new ();
- proxy = dbus_proxy_assign (screensaver->priv->gproxy,
- DBUS_PROXY_SESSION,
- GS_LISTENER_SERVICE,
- GS_LISTENER_PATH,
- GS_LISTENER_INTERFACE);
+ screensaver->priv->gproxy = egg_dbus_proxy_new ();
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ proxy = egg_dbus_proxy_assign (screensaver->priv->gproxy, connection, GS_LISTENER_SERVICE,
+ GS_LISTENER_PATH, GS_LISTENER_INTERFACE);
g_signal_connect (screensaver->priv->gproxy, "proxy-status",
G_CALLBACK (proxy_status_cb),
Modified: trunk/src/gpm-statistics-core.c
==============================================================================
--- trunk/src/gpm-statistics-core.c (original)
+++ trunk/src/gpm-statistics-core.c Mon Oct 20 17:31:36 2008
@@ -39,7 +39,7 @@
#include "egg-debug.h"
#include "gpm-stock-icons.h"
#include "gpm-info.h"
-#include <libdbus-proxy.h>
+#include "egg-dbus-proxy.h"
static void gpm_statistics_class_init (GpmStatisticsClass *klass);
static void gpm_statistics_init (GpmStatistics *statistics);
@@ -73,7 +73,7 @@
GladeXML *glade_xml;
GtkWidget *graph_widget;
GpmConf *conf;
- DbusProxy *gproxy;
+ EggDbusProxy *gproxy;
GpmArray *events;
GpmArray *data;
const gchar *graph_type;
@@ -230,7 +230,7 @@
g_return_val_if_fail (statistics != NULL, FALSE);
g_return_val_if_fail (GPM_IS_STATISTICS (statistics), FALSE);
- proxy = dbus_proxy_get_proxy (statistics->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (statistics->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected");
return FALSE;
@@ -373,7 +373,7 @@
gchar **strlist;
DBusGProxy *proxy;
- proxy = dbus_proxy_get_proxy (statistics->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (statistics->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected");
return FALSE;
@@ -435,7 +435,7 @@
g_return_val_if_fail (GPM_IS_STATISTICS (statistics), FALSE);
g_return_val_if_fail (type != NULL, FALSE);
- proxy = dbus_proxy_get_proxy (statistics->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (statistics->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected");
return FALSE;
@@ -519,7 +519,7 @@
G_TYPE_STRING,
G_TYPE_INVALID));
- proxy = dbus_proxy_get_proxy (statistics->priv->gproxy);
+ proxy = egg_dbus_proxy_get_proxy (statistics->priv->gproxy);
if (proxy == NULL) {
egg_warning ("not connected");
return FALSE;
@@ -791,7 +791,8 @@
{
GtkWidget *main_window;
GtkWidget *widget;
- gboolean checked;
+ gboolean checked;
+ DBusGConnection *connection;
statistics->priv = GPM_STATISTICS_GET_PRIVATE (statistics);
@@ -801,15 +802,13 @@
glade_set_custom_handler (gpm_graph_widget_custom_handler, statistics);
- statistics->priv->gproxy = dbus_proxy_new ();
- dbus_proxy_assign (statistics->priv->gproxy,
- DBUS_PROXY_SESSION,
- GPM_DBUS_SERVICE,
- GPM_DBUS_PATH_STATS,
- GPM_DBUS_INTERFACE_STATS);
+ statistics->priv->gproxy = egg_dbus_proxy_new ();
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ egg_dbus_proxy_assign (statistics->priv->gproxy, connection, GPM_DBUS_SERVICE,
+ GPM_DBUS_PATH_STATS, GPM_DBUS_INTERFACE_STATS);
/* would happen if not using g-p-m or using an old version of g-p-m */
- if (dbus_proxy_is_connected (statistics->priv->gproxy) == FALSE) {
+ if (egg_dbus_proxy_is_connected (statistics->priv->gproxy) == FALSE) {
egg_error (_("Could not connect to GNOME Power Manager."));
}
Modified: trunk/test/gpm-st-proxy.c
==============================================================================
--- trunk/test/gpm-st-proxy.c (original)
+++ trunk/test/gpm-st-proxy.c Mon Oct 20 17:31:36 2008
@@ -21,23 +21,24 @@
#include <glib.h>
#include <dbus/dbus-glib.h>
-#include <libdbus-proxy.h>
+#include <egg-dbus-proxy.h>
#include "gpm-st-main.h"
#include "../src/gpm-common.h"
void
egg_test_proxy (GpmSelfTest *test)
{
- DbusProxy *gproxy = NULL;
+ EggDbusProxy *gproxy = NULL;
DBusGProxy *proxy = NULL;
+ DBusGConnection *connection;
- if (egg_test_start (test, "DbusProxy") == FALSE) {
+ if (egg_test_start (test, "EggDbusProxy") == FALSE) {
return;
}
/************************************************************/
egg_test_title (test, "make sure we can get a new gproxy");
- gproxy = dbus_proxy_new ();
+ gproxy = egg_dbus_proxy_new ();
if (gproxy != NULL) {
egg_test_success (test, "got gproxy");
} else {
@@ -46,7 +47,7 @@
/************************************************************/
egg_test_title (test, "make sure proxy if NULL when no assign");
- proxy = dbus_proxy_get_proxy (gproxy);
+ proxy = egg_dbus_proxy_get_proxy (gproxy);
if (proxy == NULL) {
egg_test_success (test, "got NULL proxy");
} else {
@@ -55,11 +56,9 @@
/************************************************************/
egg_test_title (test, "make sure we can assign and connect");
- proxy = dbus_proxy_assign (gproxy,
- DBUS_PROXY_SESSION,
- GPM_DBUS_SERVICE,
- GPM_DBUS_PATH_INHIBIT,
- GPM_DBUS_INTERFACE_INHIBIT);
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ proxy = egg_dbus_proxy_assign (gproxy, connection, GPM_DBUS_SERVICE,
+ GPM_DBUS_PATH_INHIBIT, GPM_DBUS_INTERFACE_INHIBIT);
if (proxy != NULL) {
egg_test_success (test, "got proxy (init)");
} else {
@@ -68,7 +67,7 @@
/************************************************************/
egg_test_title (test, "make sure proxy non NULL when assigned");
- proxy = dbus_proxy_get_proxy (gproxy);
+ proxy = egg_dbus_proxy_get_proxy (gproxy);
if (proxy != NULL) {
egg_test_success (test, "got valid proxy");
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]