summaryrefslogtreecommitdiffstats
path: root/glib
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2005-01-30 05:18:44 +0000
committerHavoc Pennington <hp@redhat.com>2005-01-30 05:18:44 +0000
commit41f52c96d651003b3d0a266a582d401228a8368e (patch)
tree3b217cef0c0b9db03aa580cb541b7d686732055a /glib
parent2922b0e88ba00b0067c23633075629108ad8a496 (diff)
2005-01-30 Havoc Pennington <hp@redhat.com>
dbus-viewer introspected and displayed the bus driver * dbus/dbus-object-tree.c (object_tree_test_iteration): add tests for a handler registered on "/" * dbus/dbus-object-tree.c (_dbus_decompose_path): fix to handle path "/" properly (run_decompose_tests): add tests for path decomposition * glib/dbus-gutils.c (_dbus_gutils_split_path): fix to handle "/" properly * glib/dbus-gobject.c (handle_introspect): fix quotes * test/glib/run-test.sh: support launching the bus, then running dbus-viewer * test/glib/test-service-glib.c (main): put in a trivial gobject subclass and register it on the connection * bus/driver.c (bus_driver_handle_introspect): implement introspection of the bus driver service * dbus/dbus-protocol.h: add #defines for the XML namespace, identifiers, doctype decl * bus/driver.c (bus_driver_handle_get_service_owner): handle attempts to get owner of DBUS_SERVICE_ORG_FREEDESKTOP_DBUS by returning the service unchanged. (bus_driver_handle_message): remove old check for reply_serial in method calls, now the message type deals with that (bus_driver_handle_message): handle NULL interface * glib/dbus-gproxy.c (dbus_g_proxy_get_bus_name): new function * glib/dbus-gloader-expat.c (description_load_from_string): allow -1 for len * tools/dbus-viewer.c: add support for introspecting a service on a bus * glib/dbus-gproxy.c (dbus_g_pending_call_ref): add (dbus_g_pending_call_unref): add
Diffstat (limited to 'glib')
-rw-r--r--glib/dbus-gidl.c14
-rw-r--r--glib/dbus-gidl.h3
-rw-r--r--glib/dbus-gloader-expat.c4
-rw-r--r--glib/dbus-gobject.c16
-rw-r--r--glib/dbus-gproxy.c62
-rw-r--r--glib/dbus-gutils.c20
6 files changed, 98 insertions, 21 deletions
diff --git a/glib/dbus-gidl.c b/glib/dbus-gidl.c
index cabc406b..8e0dc0da 100644
--- a/glib/dbus-gidl.c
+++ b/glib/dbus-gidl.c
@@ -303,6 +303,20 @@ node_info_add_node (NodeInfo *info,
info->nodes = g_slist_append (info->nodes, node);
}
+void
+node_info_replace_node (NodeInfo *info,
+ NodeInfo *old_child,
+ NodeInfo *new_child)
+{
+ GSList *link;
+
+ node_info_ref (new_child); /* before unref old_child in case they are the same */
+ link = g_slist_find (info->nodes, old_child);
+ g_assert (link != NULL);
+ node_info_unref (old_child);
+ link->data = new_child;
+}
+
InterfaceInfo*
interface_info_new (const char *name)
{
diff --git a/glib/dbus-gidl.h b/glib/dbus-gidl.h
index fffbddfc..88d5c6e7 100644
--- a/glib/dbus-gidl.h
+++ b/glib/dbus-gidl.h
@@ -83,6 +83,9 @@ void node_info_add_interface (NodeInfo *info,
InterfaceInfo *interface);
void node_info_add_node (NodeInfo *info,
NodeInfo *child);
+void node_info_replace_node (NodeInfo *info,
+ NodeInfo *old_child,
+ NodeInfo *new_child);
InterfaceInfo* interface_info_new (const char *name);
InterfaceInfo* interface_info_ref (InterfaceInfo *info);
void interface_info_unref (InterfaceInfo *info);
diff --git a/glib/dbus-gloader-expat.c b/glib/dbus-gloader-expat.c
index fa7e3692..609f3164 100644
--- a/glib/dbus-gloader-expat.c
+++ b/glib/dbus-gloader-expat.c
@@ -23,6 +23,7 @@
#include "dbus-gparser.h"
#include <expat.h>
+#include <string.h>
static void*
expat_g_malloc (size_t sz)
@@ -192,6 +193,9 @@ description_load_from_string (const char *str,
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+ if (len < 0)
+ len = strlen (str);
+
expat = NULL;
context.parser = NULL;
context.error = error;
diff --git a/glib/dbus-gobject.c b/glib/dbus-gobject.c
index f08bf39e..245ebf1e 100644
--- a/glib/dbus-gobject.c
+++ b/glib/dbus-gobject.c
@@ -289,26 +289,28 @@ handle_introspect (DBusConnection *connection,
xml = g_string_new (NULL);
+ g_string_append (xml, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE);
+
g_string_append (xml, "<node>\n");
/* We are introspectable, though I guess that was pretty obvious */
g_string_append (xml, " <interface name=\"org.freedesktop.Introspectable\">\n");
g_string_append (xml, " <method name=\"Introspect\">\n");
- g_string_append (xml, " <arg name=\"data\" direction=\"out\" type=\"string\"\"/>\n");
+ g_string_append (xml, " <arg name=\"data\" direction=\"out\" type=\"string\"/>\n");
g_string_append (xml, " </method>\n");
g_string_append (xml, " </interface>\n");
/* We support get/set properties */
g_string_append (xml, " <interface name=\"org.freedesktop.Properties\">\n");
g_string_append (xml, " <method name=\"Get\">\n");
- g_string_append (xml, " <arg name=\"interface\" direction=\"in\" type=\"string\"\"/>\n");
- g_string_append (xml, " <arg name=\"propname\" direction=\"in\" type=\"string\"\"/>\n");
- g_string_append (xml, " <arg name=\"value\" direction=\"out\" type=\"variant\"\"/>\n");
+ g_string_append (xml, " <arg name=\"interface\" direction=\"in\" type=\"string\"/>\n");
+ g_string_append (xml, " <arg name=\"propname\" direction=\"in\" type=\"string\"/>\n");
+ g_string_append (xml, " <arg name=\"value\" direction=\"out\" type=\"variant\"/>\n");
g_string_append (xml, " </method>\n");
g_string_append (xml, " <method name=\"Set\">\n");
- g_string_append (xml, " <arg name=\"interface\" direction=\"in\" type=\"string\"\"/>\n");
- g_string_append (xml, " <arg name=\"propname\" direction=\"in\" type=\"string\"\"/>\n");
- g_string_append (xml, " <arg name=\"value\" direction=\"in\" type=\"variant\"\"/>\n");
+ g_string_append (xml, " <arg name=\"interface\" direction=\"in\" type=\"string\"/>\n");
+ g_string_append (xml, " <arg name=\"propname\" direction=\"in\" type=\"string\"/>\n");
+ g_string_append (xml, " <arg name=\"value\" direction=\"in\" type=\"variant\"/>\n");
g_string_append (xml, " </method>\n");
g_string_append (xml, " </interface>\n");
diff --git a/glib/dbus-gproxy.c b/glib/dbus-gproxy.c
index 624a95ca..39f8ba86 100644
--- a/glib/dbus-gproxy.c
+++ b/glib/dbus-gproxy.c
@@ -1032,12 +1032,31 @@ dbus_g_proxy_new_for_peer (DBusGConnection *connection,
g_return_val_if_fail (interface_name != NULL, NULL);
proxy = dbus_g_proxy_new (connection, NULL,
- path_name, interface_name);
+ path_name, interface_name);
return proxy;
}
/**
+ * Gets the bus name a proxy is bound to (may be #NULL in some cases).
+ * If you created the proxy with dbus_g_proxy_new_for_name(), then
+ * the name you passed to that will be returned.
+ * If you created it with dbus_g_proxy_new_for_name_owner(), then the
+ * unique connection name will be returned. If you created it
+ * with dbus_g_proxy_new_for_peer() then #NULL will be returned.
+ *
+ * @param proxy the proxy
+ * @returns the bus name the proxy sends messages to
+ */
+const char*
+dbus_g_proxy_get_bus_name (DBusGProxy *proxy)
+{
+ g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
+
+ return proxy->name;
+}
+
+/**
* Invokes a method on a remote interface. This function does not
* block; instead it returns an opaque #DBusPendingCall object that
* tracks the pending call. The method call will not be sent over the
@@ -1113,23 +1132,28 @@ dbus_g_proxy_begin_call (DBusGProxy *proxy,
*
* Otherwise, the "out" parameters and return value of the
* method are stored in the provided varargs list.
- * The list should be terminated with DBUS_TYPE_INVALID.
+ * The list should be terminated with #DBUS_TYPE_INVALID.
*
* This function doesn't affect the reference count of the
* #DBusPendingCall, the caller of dbus_g_proxy_begin_call() still owns
* a reference.
*
+ * @todo this should be changed to make a g_malloc() copy of the
+ * data returned probably; right now the data vanishes
+ * when you free the PendingCall which is sort of strange.
+ *
* @param proxy a proxy for a remote interface
* @param pending the pending call from dbus_g_proxy_begin_call()
* @param error return location for an error
* @param first_arg_type type of first "out" argument
- * @returns #FALSE if an error is set */
+ * @returns #FALSE if an error is set
+ */
gboolean
dbus_g_proxy_end_call (DBusGProxy *proxy,
- DBusGPendingCall *pending,
- GError **error,
- int first_arg_type,
- ...)
+ DBusGPendingCall *pending,
+ GError **error,
+ int first_arg_type,
+ ...)
{
DBusMessage *message;
va_list args;
@@ -1223,6 +1247,30 @@ dbus_g_proxy_call_no_reply (DBusGProxy *proxy,
}
/**
+ * Increments refcount on a pending call.
+ *
+ * @param call the call
+ * @returns the same call
+ */
+DBusGPendingCall*
+dbus_g_pending_call_ref (DBusGPendingCall *call)
+{
+ dbus_pending_call_ref (DBUS_PENDING_CALL_FROM_G_PENDING_CALL (call));
+ return call;
+}
+
+/**
+ * Decrements refcount on a pending call.
+ *
+ * @param call the call
+ */
+void
+dbus_g_pending_call_unref (DBusGPendingCall *call)
+{
+ dbus_pending_call_unref (DBUS_PENDING_CALL_FROM_G_PENDING_CALL (call));
+}
+
+/**
* Sends a message to the interface we're proxying for. Does not
* block or wait for a reply. The message is only actually written out
* when you return to the main loop or block in
diff --git a/glib/dbus-gutils.c b/glib/dbus-gutils.c
index ff48e7f1..cf12245c 100644
--- a/glib/dbus-gutils.c
+++ b/glib/dbus-gutils.c
@@ -39,19 +39,25 @@ _dbus_gutils_split_path (const char *path)
len = strlen (path);
n_components = 0;
- i = 0;
- while (i < len)
+ if (path[1] != '\0') /* if not "/" */
{
- if (path[i] == '/')
- n_components += 1;
- ++i;
+ i = 0;
+ while (i < len)
+ {
+ if (path[i] == '/')
+ n_components += 1;
+ ++i;
+ }
}
split = g_new0 (char*, n_components + 1);
comp = 0;
- i = 0;
- while (i < len)
+ if (n_components == 0)
+ i = 1;
+ else
+ i = 0;
+ while (comp < n_components)
{
if (path[i] == '/')
++i;