summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-08-18 22:43:30 +0000
committerHavoc Pennington <hp@redhat.com>2003-08-18 22:43:30 +0000
commit68a3c593b9e77b33614726363c7b6fd85d113021 (patch)
treeec3035e33c20febc29d2b27e13139540dc739bbc /tools
parent95717a938b237d12211935f6a7467ef610288fe5 (diff)
2003-08-18 Havoc Pennington <hp@redhat.com>
* dbus/dbus-hash.c (_dbus_hash_table_insert_two_strings): fix * dbus/dbus-message.c (_dbus_message_loader_queue_messages): fix dumb bug created earlier (wrong order of args to decode_header_data()) * tools/dbus-send.c: port * tools/dbus-print-message.c (print_message): port * test/data/*messages: port all messages over * dbus/dbus-message-builder.c: support including message type * bus/driver.c: port over * bus/dispatch.c: port over to new stuff * dbus/dbus-connection.c (_dbus_connection_new_for_transport): rename disconnect signal to "Disconnected"
Diffstat (limited to 'tools')
-rw-r--r--tools/dbus-monitor.c4
-rw-r--r--tools/dbus-print-message.c37
-rw-r--r--tools/dbus-send.18
-rw-r--r--tools/dbus-send.c30
4 files changed, 67 insertions, 12 deletions
diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c
index a0f77407..c7293abb 100644
--- a/tools/dbus-monitor.c
+++ b/tools/dbus-monitor.c
@@ -37,7 +37,9 @@ handler_func (DBusMessageHandler *handler,
{
print_message (message);
- if (dbus_message_has_name (message, DBUS_MESSAGE_LOCAL_DISCONNECT))
+ if (dbus_message_is_signal (message,
+ DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL,
+ "Disconnected"))
exit (0);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
diff --git a/tools/dbus-print-message.c b/tools/dbus-print-message.c
index 7c5328da..43c41c73 100644
--- a/tools/dbus-print-message.c
+++ b/tools/dbus-print-message.c
@@ -48,12 +48,37 @@ print_message (DBusMessage *message)
message_type = dbus_message_get_type (message);
sender = dbus_message_get_sender (message);
-
- printf ("%s name=%s; sender=%s\n",
- type_to_name (message_type),
- dbus_message_get_name (message),
- sender ? sender : "(no sender)");
-
+
+ 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),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message),
+ sender ? sender : "(no sender)");
+ break;
+
+ case DBUS_MESSAGE_TYPE_METHOD_RETURN:
+ printf ("%s; sender=%s\n",
+ type_to_name (message_type),
+ sender ? sender : "(no sender)");
+ 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)");
+ break;
+
+ default:
+ printf ("Message of unknown type %d received\n",
+ message_type);
+ break;
+ }
+
dbus_message_iter_init (message, &iter);
do
diff --git a/tools/dbus-send.1 b/tools/dbus-send.1
index f71c4c6e..978ee2e7 100644
--- a/tools/dbus-send.1
+++ b/tools/dbus-send.1
@@ -42,12 +42,16 @@ byte, boolean. (D-BUS supports more types than these, but
Here is an example invocation:
.nf
- dbus-send \-\-dest='org.freedesktop.ExampleService' \\
- org.freedesktop.ExampleMessage \\
+ dbus-send \-\-dest='org.freedesktop.ExampleService' \\
+ org.freedesktop.ExampleInterface.ExampleMethod \\
int32:47 string:'hello world' double:65.32
.fi
+Note that the interface is separated from a method or signal
+name by a dot, though in the actual protocol the interface
+and the interface member are separate fields.
+
.SH OPTIONS
The following options are supported:
.TP
diff --git a/tools/dbus-send.c b/tools/dbus-send.c
index fb876b52..7ea49aac 100644
--- a/tools/dbus-send.c
+++ b/tools/dbus-send.c
@@ -44,7 +44,7 @@ main (int argc, char *argv[])
DBusMessageIter iter;
int i;
DBusBusType type = DBUS_BUS_SESSION;
- const char *dest = DBUS_SERVICE_BROADCAST;
+ const char *dest = DBUS_SERVICE_ORG_FREEDESKTOP_BROADCAST;
char *name = NULL;
int message_type = DBUS_MESSAGE_TYPE_SIGNAL;
const char *type_str = NULL;
@@ -106,11 +106,35 @@ main (int argc, char *argv[])
if (message_type == DBUS_MESSAGE_TYPE_METHOD_CALL)
{
- message = dbus_message_new_method_call (name, NULL);
+ char *last_dot;
+
+ last_dot = strrchr (name, '.');
+ if (last_dot == NULL)
+ {
+ fprintf (stderr, "Must use org.mydomain.Interface.Method notation, no dot in \"%s\"\n",
+ name);
+ exit (1);
+ }
+ *last_dot = '\0';
+
+ message = dbus_message_new_method_call (name,
+ last_dot + 1,
+ NULL);
}
else if (message_type == DBUS_MESSAGE_TYPE_SIGNAL)
{
- message = dbus_message_new_signal (name);
+ char *last_dot;
+
+ last_dot = strrchr (name, '.');
+ if (last_dot == NULL)
+ {
+ fprintf (stderr, "Must use org.mydomain.Interface.Signal notation, no dot in \"%s\"\n",
+ name);
+ exit (1);
+ }
+ *last_dot = '\0';
+
+ message = dbus_message_new_signal (name, last_dot + 1);
}
else
{