dbus/glib dbus-gproxy.c,1.8,1.9
Olivier Andrieu
oandrieu at pdx.freedesktop.org
Fri Apr 16 08:08:06 EST 2004
Update of /cvs/dbus/dbus/glib
In directory pdx:/tmp/cvs-serv29915/glib
Modified Files:
dbus-gproxy.c
Log Message:
2004-04-15 Olivier Andrieu <oliv__a at users.sourceforge.net>
* bus/driver.c (bus_driver_handle_get_service_owner):
implement a GetServiceOwner method.
* doc/dbus-specification.xml: document it.
* dbus/dbus-errors.h: add a 'ServiceHasNoOwner' error.
* glib/dbus-gproxy.c (dbus_gproxy_new_for_service_owner):
implement, using the bus GetServiceOwner method.
* test/glib/test-dbus-glib.c:
use dbus_gproxy_new_for_service_owner so that we can receive the
signal.
Index: dbus-gproxy.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gproxy.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- a/dbus-gproxy.c 2 Dec 2003 10:44:21 -0000 1.8
+++ b/dbus-gproxy.c 15 Apr 2004 22:08:04 -0000 1.9
@@ -932,12 +932,67 @@
const char *interface_name,
GError **error)
{
+ DBusGProxy *proxy;
+
+ DBusMessage *request, *reply;
+ DBusError derror;
+ char *base_service_name;
+
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (service_name != NULL, NULL);
g_return_val_if_fail (path_name != NULL, NULL);
g_return_val_if_fail (interface_name != NULL, NULL);
+ dbus_error_init (&derror);
+
+ proxy = NULL;
+ base_service_name = NULL;
+ reply = NULL;
+
+ request = dbus_message_new_method_call (DBUS_SERVICE_ORG_FREEDESKTOP_DBUS,
+ DBUS_PATH_ORG_FREEDESKTOP_DBUS,
+ DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS,
+ "GetServiceOwner");
+ if (request == NULL)
+ g_error ("Out of memory");
+
+ if (! dbus_message_append_args (request,
+ DBUS_TYPE_STRING, service_name,
+ DBUS_TYPE_INVALID))
+ g_error ("Out of memory");
+
+ reply = dbus_connection_send_with_reply_and_block (connection, request,
+ 2000, &derror);
+ if (reply == NULL)
+ goto error;
+ if (dbus_set_error_from_message (&derror, reply))
+ goto error;
+
+ if (! dbus_message_get_args (reply, &derror,
+ DBUS_TYPE_STRING, &base_service_name,
+ DBUS_TYPE_INVALID))
+ goto error;
+
+
+ proxy = dbus_gproxy_new (connection, base_service_name,
+ path_name, interface_name);
+
+ goto out;
+
+ error:
+ g_assert (dbus_error_is_set (&derror));
+ dbus_set_g_error (error, &derror);
+ dbus_error_free (&derror);
+
+ out:
+ if (request)
+ dbus_message_unref (request);
+ if (reply)
+ dbus_message_unref (reply);
+ dbus_free (base_service_name);
+
+ return proxy;
}
/**
More information about the dbus-commit
mailing list