From b29ea9115ea3277354b7ccbe442026279220f4ac Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 11 Aug 2003 02:11:58 +0000 Subject: 2003-08-10 Havoc Pennington * tools/dbus-send.c (main): add --type argument, for now supporting only method_call and signal types. * tools/dbus-print-message.c: print message type * dbus/dbus-connection.c (_dbus_connection_new_for_transport): init connection->objects * doc/dbus-specification.sgml: fix sgml * bus/*.c: port over to object-instance API changes * test/test-service.c: ditto * dbus/dbus-message.c (dbus_message_create_header): allow #NULL name, we will have to fix up the rest of the code to also handle this (dbus_message_new): generic message-creation call (set_string_field): allow appending name field --- tools/dbus-send.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'tools/dbus-send.c') diff --git a/tools/dbus-send.c b/tools/dbus-send.c index 12ad5c8c..fb876b52 100644 --- a/tools/dbus-send.c +++ b/tools/dbus-send.c @@ -30,7 +30,7 @@ static void usage (char *name, int ecode) { - fprintf (stderr, "Usage: %s [--help] [--system | --session] [--dest=SERVICE] [--print-reply] [contents ...]\n", name); + fprintf (stderr, "Usage: %s [--help] [--system | --session] [--dest=SERVICE] [--type=TYPE] [--print-reply] [contents ...]\n", name); exit (ecode); } @@ -44,9 +44,11 @@ main (int argc, char *argv[]) DBusMessageIter iter; int i; DBusBusType type = DBUS_BUS_SESSION; - char *dest = DBUS_SERVICE_BROADCAST; + const char *dest = DBUS_SERVICE_BROADCAST; char *name = NULL; - + int message_type = DBUS_MESSAGE_TYPE_SIGNAL; + const char *type_str = NULL; + if (argc < 2) usage (argv[0], 1); @@ -64,6 +66,8 @@ main (int argc, char *argv[]) print_reply = TRUE; else if (strstr (arg, "--dest=") == arg) dest = strchr (arg, '=') + 1; + else if (strstr (arg, "--type=") == arg) + type_str = strchr (arg, '=') + 1; else if (!strcmp(arg, "--help")) usage (argv[0], 0); else if (arg[0] == '-') @@ -75,6 +79,20 @@ main (int argc, char *argv[]) if (name == NULL) usage (argv[0], 1); + if (type_str != NULL) + { + if (strcmp (type_str, "method_call") == 0) + message_type = DBUS_MESSAGE_TYPE_METHOD_CALL; + else if (strcmp (type_str, "signal") == 0) + message_type = DBUS_MESSAGE_TYPE_SIGNAL; + else + { + fprintf (stderr, "Message type \"%s\" is not supported\n", + type_str); + exit (1); + } + } + dbus_error_init (&error); connection = dbus_bus_get (type, &error); if (connection == NULL) @@ -86,13 +104,32 @@ main (int argc, char *argv[]) exit (1); } - message = dbus_message_new (name, dest); + if (message_type == DBUS_MESSAGE_TYPE_METHOD_CALL) + { + message = dbus_message_new_method_call (name, NULL); + } + else if (message_type == DBUS_MESSAGE_TYPE_SIGNAL) + { + message = dbus_message_new_signal (name); + } + else + { + fprintf (stderr, "Internal error, unknown message type\n"); + exit (1); + } + if (message == NULL) { fprintf (stderr, "Couldn't allocate D-BUS message\n"); exit (1); } + if (dest && !dbus_message_set_destination (message, dest)) + { + fprintf (stderr, "Not enough memory\n"); + exit (1); + } + dbus_message_append_iter_init (message, &iter); while (i < argc) @@ -135,6 +172,7 @@ main (int argc, char *argv[]) exit (1); } + /* FIXME - we are ignoring OOM returns on all these functions */ switch (type) { case DBUS_TYPE_BYTE: -- cgit From 68a3c593b9e77b33614726363c7b6fd85d113021 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 18 Aug 2003 22:43:30 +0000 Subject: 2003-08-18 Havoc Pennington * 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" --- tools/dbus-send.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'tools/dbus-send.c') 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 { -- cgit From 5fd1e389e1c1c12ad4a55c2af6abdc8e7a2f6d41 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 31 Aug 2003 01:51:44 +0000 Subject: 2003-08-30 Havoc Pennington * test/data/valid-config-files/system.d/test.conf: change to root for the user so warnings don't get printed * dbus/dbus-message.c: add dbus_message_get_path, dbus_message_set_path * dbus/dbus-object-tree.c (do_test_dispatch): add test of dispatching to a path * dbus/dbus-string.c (_dbus_string_validate_path): add * dbus/dbus-marshal.c (_dbus_demarshal_object_path): implement (_dbus_marshal_object_path): implement * dbus/dbus-protocol.h (DBUS_HEADER_FIELD_PATH): new header field to contain the path to the target object (DBUS_HEADER_FIELD_SENDER_SERVICE): rename DBUS_HEADER_FIELD_SENDER to explicitly say it's the sender service --- tools/dbus-send.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'tools/dbus-send.c') diff --git a/tools/dbus-send.c b/tools/dbus-send.c index 7ea49aac..67abe066 100644 --- a/tools/dbus-send.c +++ b/tools/dbus-send.c @@ -30,7 +30,7 @@ static void usage (char *name, int ecode) { - fprintf (stderr, "Usage: %s [--help] [--system | --session] [--dest=SERVICE] [--type=TYPE] [--print-reply] [contents ...]\n", name); + fprintf (stderr, "Usage: %s [--help] [--system | --session] [--dest=SERVICE] [--type=TYPE] [--print-reply] [contents ...]\n", name); exit (ecode); } @@ -45,11 +45,12 @@ main (int argc, char *argv[]) int i; DBusBusType type = DBUS_BUS_SESSION; const char *dest = DBUS_SERVICE_ORG_FREEDESKTOP_BROADCAST; - char *name = NULL; + const char *name = NULL; + const char *path = NULL; int message_type = DBUS_MESSAGE_TYPE_SIGNAL; const char *type_str = NULL; - if (argc < 2) + if (argc < 3) usage (argv[0], 1); print_reply = FALSE; @@ -72,8 +73,12 @@ main (int argc, char *argv[]) usage (argv[0], 0); else if (arg[0] == '-') usage (argv[0], 1); + else if (path == NULL) + path = arg; + else if (name == NULL) + name = arg; else - name = arg; + usage (argv[0], 1); } if (name == NULL) @@ -117,9 +122,10 @@ main (int argc, char *argv[]) } *last_dot = '\0'; - message = dbus_message_new_method_call (name, - last_dot + 1, - NULL); + message = dbus_message_new_method_call (NULL, + path, + name, + last_dot + 1); } else if (message_type == DBUS_MESSAGE_TYPE_SIGNAL) { @@ -134,7 +140,7 @@ main (int argc, char *argv[]) } *last_dot = '\0'; - message = dbus_message_new_signal (name, last_dot + 1); + message = dbus_message_new_signal (path, name, last_dot + 1); } else { -- cgit From a683a80c409cc4f2e57ba6a3e60d52f91b8657d0 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 21 Sep 2003 19:53:56 +0000 Subject: 2003-09-21 Havoc Pennington Get matching rules mostly working in the bus; only actually parsing the rule text remains. However, the client side of "signal connections" hasn't been started, this patch is only the bus side. * dbus/dispatch.c: fix for the matching rules changes * bus/driver.c (bus_driver_handle_remove_match) (bus_driver_handle_add_match): send an ack reply from these method calls * glib/dbus-gproxy.c (dbus_gproxy_begin_call): fix order of arguments, reported by Seth Nickell * bus/config-parser.c (append_rule_from_element): support eavesdrop=true|false attribute on policies so match rules can be prevented from snooping on the system bus. * bus/dbus-daemon-1.1.in: consistently use terminology "sender" and "destination" in attribute names; fix some docs bugs; add eavesdrop=true|false attribute * bus/driver.c (bus_driver_handle_add_match) (bus_driver_handle_remove_match): handle AddMatch, RemoveMatch messages * dbus/dbus-protocol.h (DBUS_SERVICE_ORG_FREEDESKTOP_BROADCAST): get rid of broadcast service concept, signals are just always broadcast * bus/signals.c, bus/dispatch.c, bus/connection.c, bus/bus.c: mostly implement matching rules stuff (currently only exposed as signal connections) --- tools/dbus-send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/dbus-send.c') diff --git a/tools/dbus-send.c b/tools/dbus-send.c index 67abe066..06a87adb 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_ORG_FREEDESKTOP_BROADCAST; + const char *dest = NULL; const char *name = NULL; const char *path = NULL; int message_type = DBUS_MESSAGE_TYPE_SIGNAL; -- cgit