Commit b29ea911 authored by Havoc Pennington's avatar Havoc Pennington

2003-08-10 Havoc Pennington <hp@pobox.com>

	* 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
parent cefb84ed
2003-08-10 Havoc Pennington <hp@pobox.com>
* 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
2003-08-06 Havoc Pennington <hp@pobox.com>
* dbus/dbus-object-registry.c: implement signal connection
......
......@@ -586,7 +586,7 @@ bus_activation_service_created (BusActivation *activation,
if (dbus_connection_get_is_connected (entry->connection))
{
message = dbus_message_new_reply (entry->activation_message);
message = dbus_message_new_method_return (entry->activation_message);
if (!message)
{
BUS_SET_OOM (error);
......@@ -866,7 +866,7 @@ bus_activation_activate_service (BusActivation *activation,
{
_dbus_verbose ("Service \"%s\" is already active\n", service_name);
message = dbus_message_new_reply (activation_message);
message = dbus_message_new_method_return (activation_message);
if (!message)
{
......
......@@ -963,18 +963,18 @@ bus_connection_preallocate_oom_error (DBusConnection *connection)
if (preallocated == NULL)
return FALSE;
/* d->name may be NULL, but that is OK */
message = dbus_message_new (DBUS_ERROR_NO_MEMORY,
d->name);
message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR);
if (message == NULL)
{
dbus_connection_free_preallocated_send (connection, preallocated);
return FALSE;
}
dbus_message_set_is_error (message, TRUE);
if (!dbus_message_set_sender (message,
/* d->name may be NULL, but that is OK */
if (!dbus_message_set_name (message, DBUS_ERROR_NO_MEMORY) ||
!dbus_message_set_destination (message, d->name) ||
!dbus_message_set_sender (message,
DBUS_SERVICE_DBUS))
{
dbus_connection_free_preallocated_send (connection, preallocated);
......@@ -1338,7 +1338,7 @@ bus_transaction_send (BusTransaction *transaction,
DBusList *link;
_dbus_verbose (" trying to add %s %s to transaction%s\n",
dbus_message_get_is_error (message) ? "error" :
dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR ? "error" :
dbus_message_get_reply_serial (message) != 0 ? "reply" :
"message",
dbus_message_get_name (message),
......@@ -1554,9 +1554,9 @@ bus_transaction_send_error_reply (BusTransaction *transaction,
_dbus_verbose ("Sending error reply %s \"%s\"\n",
error->name, error->message);
reply = dbus_message_new_error_reply (in_reply_to,
error->name,
error->message);
reply = dbus_message_new_error (in_reply_to,
error->name,
error->message);
if (reply == NULL)
return FALSE;
......
......@@ -674,8 +674,8 @@ check_hello_message (BusContext *context,
acquired = NULL;
message = NULL;
message = dbus_message_new (DBUS_MESSAGE_HELLO,
DBUS_SERVICE_DBUS);
message = dbus_message_new_method_call (DBUS_MESSAGE_HELLO,
DBUS_SERVICE_DBUS);
if (message == NULL)
return TRUE;
......@@ -725,7 +725,7 @@ check_hello_message (BusContext *context,
goto out;
}
if (dbus_message_get_is_error (message))
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
{
if (dbus_message_has_name (message,
DBUS_ERROR_NO_MEMORY))
......@@ -906,8 +906,8 @@ check_nonexistent_service_activation (BusContext *context,
dbus_error_init (&error);
message = dbus_message_new (DBUS_MESSAGE_ACTIVATE_SERVICE,
DBUS_SERVICE_DBUS);
message = dbus_message_new_method_call (DBUS_MESSAGE_ACTIVATE_SERVICE,
DBUS_SERVICE_DBUS);
if (message == NULL)
return TRUE;
......@@ -953,7 +953,7 @@ check_nonexistent_service_activation (BusContext *context,
_dbus_verbose ("Received %s on %p\n",
dbus_message_get_name (message), connection);
if (dbus_message_get_is_error (message))
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
{
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
{
......@@ -1287,8 +1287,8 @@ check_send_exit_to_service (BusContext *context,
retval = FALSE;
/* Kill off the test service by sending it a quit message */
message = dbus_message_new ("org.freedesktop.DBus.TestSuiteExit",
service_name);
message = dbus_message_new_method_call ("org.freedesktop.DBus.TestSuiteExit",
service_name);
if (message == NULL)
{
......@@ -1324,7 +1324,7 @@ check_send_exit_to_service (BusContext *context,
/* see if we got an error during message bus dispatching */
bus_test_run_clients_loop (FALSE);
message = dbus_connection_borrow_message (connection);
got_error = message != NULL && dbus_message_get_is_error (message);
got_error = message != NULL && dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR;
if (message)
{
dbus_connection_return_message (connection, message);
......@@ -1344,7 +1344,7 @@ check_send_exit_to_service (BusContext *context,
message = pop_message_waiting_for_memory (connection);
_dbus_assert (message != NULL);
if (!dbus_message_get_is_error (message))
if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_ERROR)
{
_dbus_warn ("expecting an error reply to asking test service to exit, got %s\n",
dbus_message_get_name (message));
......@@ -1402,7 +1402,7 @@ check_got_error (BusContext *context,
goto out;
}
if (!dbus_message_get_is_error (message))
if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_ERROR)
{
_dbus_warn ("Expected an error, got %s\n",
dbus_message_get_name (message));
......@@ -1460,8 +1460,8 @@ check_existent_service_activation (BusContext *context,
dbus_error_init (&error);
message = dbus_message_new (DBUS_MESSAGE_ACTIVATE_SERVICE,
DBUS_SERVICE_DBUS);
message = dbus_message_new_method_call (DBUS_MESSAGE_ACTIVATE_SERVICE,
DBUS_SERVICE_DBUS);
if (message == NULL)
return TRUE;
......@@ -1513,7 +1513,7 @@ check_existent_service_activation (BusContext *context,
dbus_message_get_name (message), connection,
DBUS_MESSAGE_ACTIVATE_SERVICE);
if (dbus_message_get_is_error (message))
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
{
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
{
......@@ -1563,7 +1563,7 @@ check_existent_service_activation (BusContext *context,
}
got_service_deleted = dbus_message_has_name (message, DBUS_MESSAGE_SERVICE_DELETED);
got_error = dbus_message_get_is_error (message);
got_error = dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR;
dbus_connection_return_message (connection, message);
message = NULL;
......@@ -1668,8 +1668,8 @@ check_segfault_service_activation (BusContext *context,
dbus_error_init (&error);
message = dbus_message_new (DBUS_MESSAGE_ACTIVATE_SERVICE,
DBUS_SERVICE_DBUS);
message = dbus_message_new_method_call (DBUS_MESSAGE_ACTIVATE_SERVICE,
DBUS_SERVICE_DBUS);
if (message == NULL)
return TRUE;
......@@ -1716,7 +1716,7 @@ check_segfault_service_activation (BusContext *context,
_dbus_verbose ("Received %s on %p\n",
dbus_message_get_name (message), connection);
if (dbus_message_get_is_error (message))
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
{
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
{
......
......@@ -49,8 +49,8 @@ bus_driver_send_service_deleted (const char *service_name,
_dbus_verbose ("sending service deleted: %s\n", service_name);
message = dbus_message_new (DBUS_MESSAGE_SERVICE_DELETED,
DBUS_SERVICE_BROADCAST);
message = dbus_message_new_signal (DBUS_MESSAGE_SERVICE_DELETED);
if (message == NULL)
{
BUS_SET_OOM (error);
......@@ -83,8 +83,8 @@ bus_driver_send_service_created (const char *service_name,
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
message = dbus_message_new (DBUS_MESSAGE_SERVICE_CREATED,
DBUS_SERVICE_BROADCAST);
message = dbus_message_new_signal (DBUS_MESSAGE_SERVICE_CREATED);
if (message == NULL)
{
BUS_SET_OOM (error);
......@@ -123,15 +123,16 @@ bus_driver_send_service_lost (DBusConnection *connection,
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
message = dbus_message_new (DBUS_MESSAGE_SERVICE_LOST,
bus_connection_get_name (connection));
message = dbus_message_new_signal (DBUS_MESSAGE_SERVICE_LOST);
if (message == NULL)
{
BUS_SET_OOM (error);
return FALSE;
}
if (!dbus_message_append_args (message,
if (!dbus_message_set_destination (message, bus_connection_get_name (connection)) ||
!dbus_message_append_args (message,
DBUS_TYPE_STRING, service_name,
DBUS_TYPE_INVALID))
{
......@@ -163,8 +164,7 @@ bus_driver_send_service_acquired (DBusConnection *connection,
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
message = dbus_message_new (DBUS_MESSAGE_SERVICE_ACQUIRED,
bus_connection_get_name (connection));
message = dbus_message_new_signal (DBUS_MESSAGE_SERVICE_ACQUIRED);
if (message == NULL)
{
......@@ -172,7 +172,8 @@ bus_driver_send_service_acquired (DBusConnection *connection,
return FALSE;
}
if (!dbus_message_append_args (message,
if (!dbus_message_set_destination (message, bus_connection_get_name (connection)) ||
!dbus_message_append_args (message,
DBUS_TYPE_STRING, service_name,
DBUS_TYPE_INVALID))
{
......@@ -343,7 +344,7 @@ bus_driver_send_welcome_message (DBusConnection *connection,
name = bus_connection_get_name (connection);
_dbus_assert (name != NULL);
welcome = dbus_message_new_reply (hello_message);
welcome = dbus_message_new_method_return (hello_message);
if (welcome == NULL)
{
BUS_SET_OOM (error);
......@@ -387,7 +388,7 @@ bus_driver_handle_list_services (DBusConnection *connection,
registry = bus_connection_get_registry (connection);
reply = dbus_message_new_reply (message);
reply = dbus_message_new_method_return (message);
if (reply == NULL)
{
BUS_SET_OOM (error);
......@@ -463,7 +464,7 @@ bus_driver_handle_acquire_service (DBusConnection *connection,
error))
goto out;
reply = dbus_message_new_reply (message);
reply = dbus_message_new_method_return (message);
if (reply == NULL)
{
BUS_SET_OOM (error);
......@@ -518,7 +519,7 @@ bus_driver_handle_service_exists (DBusConnection *connection,
_dbus_string_init_const (&service_name, name);
service = bus_registry_lookup (registry, &service_name);
reply = dbus_message_new_reply (message);
reply = dbus_message_new_method_return (message);
if (reply == NULL)
{
BUS_SET_OOM (error);
......
......@@ -107,6 +107,10 @@ client_disconnect_handler (DBusMessageHandler *handler,
DBusMessage *message,
void *user_data)
{
if (!dbus_message_has_name (message,
DBUS_MESSAGE_LOCAL_DISCONNECT))
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
_dbus_verbose ("Removing client %p in disconnect handler\n",
connection);
......@@ -138,7 +142,6 @@ dbus_bool_t
bus_setup_debug_client (DBusConnection *connection)
{
DBusMessageHandler *disconnect_handler;
const char *to_handle[] = { DBUS_MESSAGE_LOCAL_DISCONNECT };
dbus_bool_t retval;
disconnect_handler = dbus_message_handler_new (client_disconnect_handler,
......@@ -147,10 +150,8 @@ bus_setup_debug_client (DBusConnection *connection)
if (disconnect_handler == NULL)
return FALSE;
if (!dbus_connection_register_handler (connection,
disconnect_handler,
to_handle,
_DBUS_N_ELEMENTS (to_handle)))
if (!dbus_connection_add_filter (connection,
disconnect_handler))
{
dbus_message_handler_unref (disconnect_handler);
return FALSE;
......
......@@ -844,6 +844,7 @@ echo "
cflags: ${CFLAGS}
cppflags: ${CPPFLAGS}
cxxflags: ${CXXFLAGS}
64-bit int: ${DBUS_INT64_TYPE}
Doxygen: ${DOXYGEN}
db2html: ${DB2HTML}"
......
......@@ -753,6 +753,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport)
connection->outgoing_counter = outgoing_counter;
connection->filter_list = NULL;
connection->last_dispatch_status = DBUS_DISPATCH_COMPLETE; /* so we're notified first time there's data */
connection->objects = objects;
_dbus_data_slot_list_init (&connection->slot_list);
......
......@@ -593,6 +593,14 @@ set_string_field (DBusMessage *message,
return append_string_field (message, field,
DBUS_HEADER_FIELD_SENDER,
value);
case FIELD_NAME:
return append_string_field (message, field,
DBUS_HEADER_FIELD_NAME,
value);
case FIELD_SERVICE:
return append_string_field (message, field,
DBUS_HEADER_FIELD_SERVICE,
value);
default:
_dbus_assert_not_reached ("appending a string field we don't support appending");
return FALSE;
......@@ -849,12 +857,14 @@ dbus_message_create_header (DBusMessage *message,
return FALSE;
}
_dbus_assert (name != NULL);
if (!append_string_field (message,
FIELD_NAME,
DBUS_HEADER_FIELD_NAME,
name))
return FALSE;
if (name != NULL)
{
if (!append_string_field (message,
FIELD_NAME,
DBUS_HEADER_FIELD_NAME,
name))
return FALSE;
}
return TRUE;
}
......@@ -948,6 +958,35 @@ dbus_message_new_empty_header (void)
return message;
}
/**
* Constructs a new message of the given message type.
* Types include #DBUS_MESSAGE_TYPE_METHOD_CALL,
* #DBUS_MESSAGE_TYPE_SIGNAL, and so forth.
*
* @param message_type type of message
* @returns new message or #NULL If no memory
*/
DBusMessage*
dbus_message_new (int message_type)
{
DBusMessage *message;
_dbus_return_val_if_fail (message_type != DBUS_MESSAGE_TYPE_INVALID, NULL);
message = dbus_message_new_empty_header ();
if (message == NULL)
return NULL;
if (!dbus_message_create_header (message,
message_type,
NULL, NULL))
{
dbus_message_unref (message);
return NULL;
}
return message;
}
/**
* Constructs a new message to invoke a method on a remote
......@@ -1273,6 +1312,34 @@ dbus_message_get_type (DBusMessage *message)
return type;
}
/**
* Sets the message name.
*
* @param message the message
* @param name the name
* @returns #FALSE if not enough memory
*/
dbus_bool_t
dbus_message_set_name (DBusMessage *message,
const char *name)
{
_dbus_return_val_if_fail (message != NULL, FALSE);
_dbus_return_val_if_fail (!message->locked, FALSE);
if (name == NULL)
{
delete_string_field (message, FIELD_NAME);
return TRUE;
}
else
{
return set_string_field (message,
FIELD_NAME,
name);
}
}
/**
* Gets the name of a message.
*
......@@ -1287,6 +1354,33 @@ dbus_message_get_name (DBusMessage *message)
return get_string_field (message, FIELD_NAME, NULL);
}
/**
* Sets the message's destination service.
*
* @param message the message
* @param destination the destination service name
* @returns #FALSE if not enough memory
*/
dbus_bool_t
dbus_message_set_destination (DBusMessage *message,
const char *destination)
{
_dbus_return_val_if_fail (message != NULL, FALSE);
_dbus_return_val_if_fail (!message->locked, FALSE);
if (destination == NULL)
{
delete_string_field (message, FIELD_SERVICE);
return TRUE;
}
else
{
return set_string_field (message,
FIELD_SERVICE,
destination);
}
}
/**
* Gets the destination service of a message.
*
......
......@@ -57,6 +57,7 @@ struct DBusMessageIter
void *pad3;
};
DBusMessage* dbus_message_new (int message_type);
DBusMessage* dbus_message_new_method_call (const char *name,
const char *destination_service);
DBusMessage* dbus_message_new_method_return (DBusMessage *method_call);
......@@ -70,7 +71,11 @@ DBusMessage *dbus_message_copy (const DBusMessage *message);
void dbus_message_ref (DBusMessage *message);
void dbus_message_unref (DBusMessage *message);
int dbus_message_get_type (DBusMessage *message);
dbus_bool_t dbus_message_set_name (DBusMessage *message,
const char *name);
const char* dbus_message_get_name (DBusMessage *message);
dbus_bool_t dbus_message_set_destination (DBusMessage *message,
const char *destination);
const char* dbus_message_get_destination (DBusMessage *message);
dbus_bool_t dbus_message_set_sender (DBusMessage *message,
const char *sender);
......
......@@ -827,7 +827,7 @@ handle_signal_and_unlock (DBusObjectRegistry *registry,
object_entry = validate_id (registry, &objects[i].id);
if (object_entry != NULL)
{
DBusObjectVTable *vtable;
const DBusObjectVTable *vtable;
DBusObjectInfo info;
info_from_entry (registry, &info, object_entry);
......
......@@ -201,7 +201,6 @@
<entry>1</entry>
<entry>Method call.</entry>
</row>
</row>
<row>
<entry>2</entry>
<entry>Method reply with returned data.</entry>
......
......@@ -30,8 +30,8 @@ main (int argc, char **argv)
dbus_connection_setup_with_g_main (connection, NULL);
message = dbus_message_new (DBUS_MESSAGE_HELLO,
DBUS_SERVICE_DBUS);
message = dbus_message_new_method_call (DBUS_MESSAGE_HELLO,
DBUS_SERVICE_DBUS);
dbus_error_init (&error);
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
......
......@@ -38,7 +38,7 @@ send_echo_message (DBusConnection *connection)
{
DBusMessage *message;
message = dbus_message_new (ECHO_MESSAGE, NULL);
message = dbus_message_new_method_call (ECHO_MESSAGE, NULL);
dbus_message_append_args (message,
DBUS_TYPE_STRING, "Hello World!",
DBUS_TYPE_INT32, 123456,
......
......@@ -19,7 +19,7 @@ thread_func (gpointer data)
while (1)
{
message = dbus_message_new ("org.freedesktop.ThreadTest", NULL);
message = dbus_message_new_method_call ("org.freedesktop.ThreadTest", NULL);
dbus_message_append_iter_init (message, &iter);
......
......@@ -42,6 +42,9 @@ handle_test_message (DBusMessageHandler *handler,
char *str, *expected_str;
GString *counter_str;
int i;
if (!dbus_message_has_name (message, "org.freedesktop.ThreadTest"))
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
dbus_message_iter_init (message, &iter);
......@@ -124,7 +127,7 @@ handle_test_message (DBusMessageHandler *handler,
g_string_free (counter_str, TRUE);
out:
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
return DBUS_HANDLER_RESULT_REMOVE_MESSAGE;
}
static DBusHandlerResult
......@@ -132,7 +135,7 @@ handle_filter (DBusMessageHandler *handler,
DBusConnection *connection,
DBusMessage *message,
void *user_data)
{
{
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
......@@ -142,20 +145,20 @@ handle_disconnect (DBusMessageHandler *handler,
DBusMessage *message,
void *user_data)
{
if (!dbus_message_has_name (message, DBUS_MESSAGE_LOCAL_DISCONNECT))
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
g_print ("connection disconnected\n");
dbus_connection_unref (connection);
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
return DBUS_HANDLER_RESULT_REMOVE_MESSAGE;
}
static void
new_connection_callback (DBusServer *server,
DBusConnection *new_connection,
void *user_data)
{
const char *test_messages[] = { "org.freedesktop.ThreadTest" };
const char *disconnect_messages[] = { "org.freedesktop.Local.Disconnect" };
DBusMessageHandler *test_message_handler;
ThreadTestData * data;
......@@ -170,9 +173,8 @@ new_connection_callback (DBusServer *server,
dbus_message_handler_new (handle_test_message,
data, (DBusFreeFunction)thread_test_data_free);
if (!dbus_connection_register_handler (new_connection,
test_message_handler,
test_messages, 1))
if (!dbus_connection_add_filter (new_connection,
test_message_handler))
goto nomem;
if (!dbus_connection_set_data (new_connection,
......@@ -181,9 +183,8 @@ new_connection_callback (DBusServer *server,
(DBusFreeFunction)dbus_message_handler_unref))
goto nomem;
if (!dbus_connection_register_handler (new_connection,
disconnect_handler,
disconnect_messages, 1))
if (!dbus_connection_add_filter (new_connection,
disconnect_handler))
goto nomem;
if (!dbus_connection_add_filter (new_connection,
......
......@@ -38,6 +38,10 @@
#include <stdlib.h>
#include <string.h>
#ifndef DBUS_HAVE_INT64
#error "gcov support can't be built without 64-bit integer support"
#endif
static void
die (const char *message)
{
......
......@@ -37,9 +37,9 @@ handle_echo (DBusConnection *connection,
DBUS_TYPE_STRING, &s,
DBUS_TYPE_INVALID))
{
reply = dbus_message_new_error_reply (message,
error.name,
error.message);
reply = dbus_message_new_error (message,
error.name,
error.message);
if (reply == NULL)
die ("No memory\n");
......@@ -52,7 +52,7 @@ handle_echo (DBusConnection *connection,
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
reply = dbus_message_new_reply (message);
reply = dbus_message_new_method_return (message);
if (reply == NULL)
die ("No memory\n");
......@@ -99,11 +99,6 @@ main (int argc,
DBusConnection *connection;
DBusError error;
DBusMessageHandler *handler;
const char *to_handle[] = {
"org.freedesktop.DBus.TestSuiteEcho",
"org.freedesktop.DBus.TestSuiteExit",
DBUS_MESSAGE_LOCAL_DISCONNECT,
};
int result;
dbus_error_init (&error);
......@@ -127,8 +122,7 @@ main (int argc,
if (handler == NULL)
die ("No memory");
if (!dbus_connection_register_handler (connection, handler, to_handle,
_DBUS_N_ELEMENTS (to_handle)))
if (!dbus_connection_add_filter (connection, handler))
die ("No memory");
result = dbus_bus_acquire_service (connection, "org.freedesktop.DBus.TestSuiteEchoService",
......
......@@ -21,15 +21,36 @@
*/
#include "dbus-print-message.h"
static const char*
type_to_name (int message_type)
{
switch (message_type)
{
case DBUS_MESSAGE_TYPE_SIGNAL:
return "signal";
case DBUS_MESSAGE_TYPE_METHOD_CALL:
return "method call";
case DBUS_MESSAGE_TYPE_METHOD_RETURN:
return "method return";
case DBUS_MESSAGE_TYPE_ERROR:
return "error";
default:
return "(unknown message type)";
}
}
void
print_message (DBusMessage *message)
{
DBusMessageIter iter;
const char *sender;
int message_type;
message_type = dbus_message_get_type (message);
sender = dbus_message_get_sender (message);
printf ("message name=%s; sender=%s\n",
printf ("%s name=%s; sender=%s\n",
type_to_name (message_type),
dbus_message_get_name (message),
sender ? sender : "(no sender)");
......
......@@ -8,7 +8,7 @@ dbus-send \- Send a message to a message bus
.SH SYNOPSIS
.PP
.B dbus-send
[\-\-system | \-\-session] [\-\-dest=SERVICE] [\-\-print-reply] <message name> [contents ...]
[\-\-system | \-\-session] [\-\-dest=SERVICE] [\-\-print-reply] [\-\-type=TYPE] <message name> [contents ...]
.SH DESCRIPTION
......@@ -62,6 +62,9 @@ Send to the system message bus.
.TP
.I "--session"
Send to the session message bus. (This is the default.)
.TP
.I "--type=TYPE"
Specify "method_call" or "signal" (defaults to "signal").
.SH AUTHOR
dbus-send was written by Philip Blundell.
......
......@@ -30,7 +30,7 @@
static void