summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2005-01-30 07:44:08 +0000
committerHavoc Pennington <hp@redhat.com>2005-01-30 07:44:08 +0000
commit98ad8a8ec6626f7f5c78915b6bdf2be688b4839f (patch)
treefb2744289e2f187aa7239d11bf8473fd186fa1ce /tools
parent41f52c96d651003b3d0a266a582d401228a8368e (diff)
downloaddbus-98ad8a8ec6626f7f5c78915b6bdf2be688b4839f.tar.gz
2005-01-30 Havoc Pennington <hp@redhat.com>
* glib/dbus-gobject.c (introspect_properties): fix the XML generated * dbus/dbus-message.c (dbus_message_unref): add an in_cache flag which effectively detects the use of freed messages * glib/dbus-gobject.c (handle_introspect): modify and return the reply message instead of the incoming message * dbus/dbus-object-tree.c (handle_default_introspect_unlocked): gee, maybe it should SEND THE XML instead of just making a string and freeing it again ;-) * tools/dbus-print-message.c (print_message): improve printing of messages * configure.in: add debug-glib.service to the output
Diffstat (limited to 'tools')
-rw-r--r--tools/dbus-print-message.c52
-rw-r--r--tools/dbus-viewer.c79
2 files changed, 94 insertions, 37 deletions
diff --git a/tools/dbus-print-message.c b/tools/dbus-print-message.c
index 572a1d14..b3559256 100644
--- a/tools/dbus-print-message.c
+++ b/tools/dbus-print-message.c
@@ -44,43 +44,45 @@ print_message (DBusMessage *message)
{
DBusMessageIter iter;
const char *sender;
+ const char *destination;
int message_type;
+ int count;
message_type = dbus_message_get_type (message);
- sender = dbus_message_get_sender (message);
-
+ sender = dbus_message_get_sender (message);
+ destination = dbus_message_get_destination (message);
+
+ printf ("%s sender=%s -> dest=%s",
+ type_to_name (message_type),
+ sender ? sender : "(null sender)",
+ destination ? destination : "(null destination)");
+
switch (message_type)
{
case DBUS_MESSAGE_TYPE_METHOD_CALL:
case DBUS_MESSAGE_TYPE_SIGNAL:
- printf ("%s interface=%s; member=%s; sender=%s\n",
- type_to_name (message_type),
+ printf (" interface=%s; member=%s\n",
dbus_message_get_interface (message),
- dbus_message_get_member (message),
- sender ? sender : "(no sender)");
+ dbus_message_get_member (message));
break;
case DBUS_MESSAGE_TYPE_METHOD_RETURN:
- printf ("%s; sender=%s\n",
- type_to_name (message_type),
- sender ? sender : "(no sender)");
+ printf ("\n");
break;
case DBUS_MESSAGE_TYPE_ERROR:
- printf ("%s name=%s; sender=%s\n",
- type_to_name (message_type),
- dbus_message_get_error_name (message),
- sender ? sender : "(no sender)");
+ printf (" error_name=%s\n",
+ dbus_message_get_error_name (message));
break;
default:
- printf ("Message of unknown type %d received\n",
- message_type);
+ printf ("\n");
break;
}
-
- dbus_message_iter_init (message, &iter);
+ dbus_message_iter_init (message, &iter);
+ count = 0;
+
do
{
int type = dbus_message_iter_get_arg_type (&iter);
@@ -98,38 +100,40 @@ print_message (DBusMessage *message)
{
case DBUS_TYPE_STRING:
dbus_message_iter_get_basic (&iter, &str);
- printf ("string:%s\n", str);
+ printf (" %d string \"%s\"\n", count, str);
break;
case DBUS_TYPE_INT32:
dbus_message_iter_get_basic (&iter, &int32);
- printf ("int32:%d\n", int32);
+ printf (" %d int32 %d\n", count, int32);
break;
case DBUS_TYPE_UINT32:
dbus_message_iter_get_basic (&iter, &uint32);
- printf ("int32:%u\n", uint32);
+ printf (" %d uint32 %u\n", count, uint32);
break;
case DBUS_TYPE_DOUBLE:
dbus_message_iter_get_basic (&iter, &d);
- printf ("double:%f\n", d);
+ printf (" %d double %g\n", count, d);
break;
case DBUS_TYPE_BYTE:
dbus_message_iter_get_basic (&iter, &byte);
- printf ("byte:%d\n", byte);
+ printf (" %d byte %d\n", count, byte);
break;
case DBUS_TYPE_BOOLEAN:
dbus_message_iter_get_basic (&iter, &boolean);
- printf ("boolean:%s\n", boolean ? "true" : "false");
+ printf (" %d boolean %s\n", count, boolean ? "true" : "false");
break;
default:
- printf ("(unknown arg type %d)\n", type);
+ printf (" (dbus-monitor too dumb to decipher arg type '%c')\n", type);
break;
}
+
+ count += 1;
} while (dbus_message_iter_next (&iter));
}
diff --git a/tools/dbus-viewer.c b/tools/dbus-viewer.c
index c32e6fd9..abd299f6 100644
--- a/tools/dbus-viewer.c
+++ b/tools/dbus-viewer.c
@@ -192,6 +192,7 @@ show_error_dialog (GtkWindow *transient_parent,
static gboolean
load_child_nodes (const char *service_name,
NodeInfo *parent,
+ GString *path,
GError **error)
{
DBusGConnection *connection;
@@ -200,7 +201,7 @@ load_child_nodes (const char *service_name,
connection = dbus_g_bus_get (DBUS_BUS_SESSION, error);
if (connection == NULL)
return FALSE;
-
+
tmp = node_info_get_nodes (parent);
while (tmp != NULL)
{
@@ -209,17 +210,37 @@ load_child_nodes (const char *service_name,
const char *data;
NodeInfo *child;
NodeInfo *complete_child;
+ int save_len;
complete_child = NULL;
+ call = NULL;
child = tmp->data;
- g_assert (*service_name == ':'); /* so we don't need new_for_name_owner */
- proxy = dbus_g_proxy_new_for_name (connection,
- service_name,
- "/",
- DBUS_INTERFACE_ORG_FREEDESKTOP_INTROSPECTABLE);
- g_assert (proxy != NULL);
+ save_len = path->len;
+
+ if (save_len > 1)
+ g_string_append (path, "/");
+ g_string_append (path, base_info_get_name ((BaseInfo*)child));
+
+ if (*service_name == ':')
+ {
+ proxy = dbus_g_proxy_new_for_name (connection,
+ service_name,
+ path->str,
+ DBUS_INTERFACE_ORG_FREEDESKTOP_INTROSPECTABLE);
+ g_assert (proxy != NULL);
+ }
+ else
+ {
+ proxy = dbus_g_proxy_new_for_name_owner (connection,
+ service_name,
+ path->str,
+ DBUS_INTERFACE_ORG_FREEDESKTOP_INTROSPECTABLE,
+ error);
+ if (proxy == NULL)
+ goto done;
+ }
call = dbus_g_proxy_begin_call (proxy, "Introspect",
DBUS_TYPE_INVALID);
@@ -231,10 +252,14 @@ load_child_nodes (const char *service_name,
complete_child = description_load_from_string (data, -1, error);
if (complete_child == NULL)
- goto done;
+ {
+ g_printerr ("%s\n", data);
+ goto done;
+ }
done:
- dbus_g_pending_call_unref (call);
+ if (call)
+ dbus_g_pending_call_unref (call);
g_object_unref (proxy);
if (complete_child == NULL)
@@ -249,8 +274,11 @@ load_child_nodes (const char *service_name,
node_info_unref (complete_child); /* ref still held by parent */
/* Now recurse */
- if (!load_child_nodes (service_name, complete_child, error))
+ if (!load_child_nodes (service_name, complete_child, path, error))
return FALSE;
+
+ /* restore path */
+ g_string_set_size (path, save_len);
tmp = tmp->next;
}
@@ -267,21 +295,36 @@ load_from_service (const char *service_name,
DBusGPendingCall *call;
const char *data;
NodeInfo *node;
+ GString *path;
node = NULL;
call = NULL;
+ path = NULL;
connection = dbus_g_bus_get (DBUS_BUS_SESSION, error);
if (connection == NULL)
return NULL;
+#if 1
+ /* this will end up autolaunching the service when we introspect it */
+ root_proxy = dbus_g_proxy_new_for_name (connection,
+ service_name,
+ "/",
+ DBUS_INTERFACE_ORG_FREEDESKTOP_INTROSPECTABLE);
+ g_assert (root_proxy != NULL);
+#else
+ /* this will be an error if the service doesn't exist */
root_proxy = dbus_g_proxy_new_for_name_owner (connection,
service_name,
"/",
DBUS_INTERFACE_ORG_FREEDESKTOP_INTROSPECTABLE,
error);
if (root_proxy == NULL)
- return NULL;
+ {
+ g_printerr ("Failed to get owner of '%s'\n", service_name);
+ return NULL;
+ }
+#endif
call = dbus_g_proxy_begin_call (root_proxy, "Introspect",
DBUS_TYPE_INVALID);
@@ -289,7 +332,11 @@ load_from_service (const char *service_name,
data = NULL;
if (!dbus_g_proxy_end_call (root_proxy, call, error, DBUS_TYPE_STRING, &data,
DBUS_TYPE_INVALID))
- goto out;
+ {
+ g_printerr ("Failed to Introspect() %s\n",
+ dbus_g_proxy_get_bus_name (root_proxy));
+ goto out;
+ }
node = description_load_from_string (data, -1, error);
@@ -299,9 +346,11 @@ load_from_service (const char *service_name,
goto out;
base_info_set_name ((BaseInfo*)node, "/");
+
+ path = g_string_new ("/");
if (!load_child_nodes (dbus_g_proxy_get_bus_name (root_proxy),
- node, error))
+ node, path, error))
{
node_info_unref (node);
node = NULL;
@@ -313,6 +362,10 @@ load_from_service (const char *service_name,
dbus_g_pending_call_unref (call);
g_object_unref (root_proxy);
+
+ if (path)
+ g_string_free (path, TRUE);
+
return node;
}