2003-04-07 01:07:13 +00:00
|
|
|
|
|
|
|
|
#include "test-utils.h"
|
|
|
|
|
|
|
|
|
|
static DBusLoop *loop;
|
2003-04-10 05:12:19 +00:00
|
|
|
static dbus_bool_t already_quit = FALSE;
|
2003-04-07 23:28:16 +00:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
quit (void)
|
|
|
|
|
{
|
|
|
|
|
if (!already_quit)
|
|
|
|
|
{
|
|
|
|
|
_dbus_loop_quit (loop);
|
|
|
|
|
already_quit = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-03 05:22:49 +00:00
|
|
|
|
2003-04-03 21:56:22 +00:00
|
|
|
static void
|
|
|
|
|
die (const char *message)
|
|
|
|
|
{
|
2004-06-07 19:27:51 +00:00
|
|
|
fprintf (stderr, "*** test-service: %s", message);
|
2003-04-03 21:56:22 +00:00
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static DBusHandlerResult
|
2003-04-07 02:01:53 +00:00
|
|
|
handle_echo (DBusConnection *connection,
|
|
|
|
|
DBusMessage *message)
|
2003-04-03 21:56:22 +00:00
|
|
|
{
|
|
|
|
|
DBusError error;
|
|
|
|
|
DBusMessage *reply;
|
|
|
|
|
char *s;
|
2003-10-21 05:46:52 +00:00
|
|
|
|
|
|
|
|
_dbus_verbose ("sending reply to Echo method\n");
|
2003-04-03 21:56:22 +00:00
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_get_args (message,
|
|
|
|
|
&error,
|
|
|
|
|
DBUS_TYPE_STRING, &s,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
2003-08-11 02:11:58 +00:00
|
|
|
reply = dbus_message_new_error (message,
|
|
|
|
|
error.name,
|
|
|
|
|
error.message);
|
2003-04-03 21:56:22 +00:00
|
|
|
|
|
|
|
|
if (reply == NULL)
|
|
|
|
|
die ("No memory\n");
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_send (connection, reply, NULL))
|
|
|
|
|
die ("No memory\n");
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
|
2003-08-12 02:43:50 +00:00
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
2003-04-03 21:56:22 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
reply = dbus_message_new_method_return (message);
|
2003-04-03 21:56:22 +00:00
|
|
|
if (reply == NULL)
|
|
|
|
|
die ("No memory\n");
|
2003-04-08 15:52:51 +00:00
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
if (!dbus_message_append_args (reply,
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
DBUS_TYPE_STRING, &s,
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
2003-04-03 21:56:22 +00:00
|
|
|
die ("No memory");
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
|
2003-04-03 21:56:22 +00:00
|
|
|
if (!dbus_connection_send (connection, reply, NULL))
|
|
|
|
|
die ("No memory\n");
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
|
|
|
|
|
fprintf (stderr, "Echo service echoed string: \"%s\"\n", s);
|
2003-04-03 21:56:22 +00:00
|
|
|
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
2003-04-03 21:56:22 +00:00
|
|
|
}
|
|
|
|
|
|
2003-10-21 05:46:52 +00:00
|
|
|
static void
|
|
|
|
|
path_unregistered_func (DBusConnection *connection,
|
|
|
|
|
void *user_data)
|
|
|
|
|
{
|
|
|
|
|
/* connection was finalized */
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-07 02:01:53 +00:00
|
|
|
static DBusHandlerResult
|
2003-10-21 05:46:52 +00:00
|
|
|
path_message_func (DBusConnection *connection,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
void *user_data)
|
|
|
|
|
{
|
2003-08-18 22:43:30 +00:00
|
|
|
if (dbus_message_is_method_call (message,
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"Echo"))
|
2003-04-07 02:01:53 +00:00
|
|
|
return handle_echo (connection, message);
|
2003-08-18 22:43:30 +00:00
|
|
|
else if (dbus_message_is_method_call (message,
|
|
|
|
|
"org.freedesktop.TestSuite",
|
2003-10-21 05:46:52 +00:00
|
|
|
"Exit"))
|
|
|
|
|
{
|
|
|
|
|
dbus_connection_disconnect (connection);
|
|
|
|
|
quit ();
|
|
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
|
}
|
|
|
|
|
else if (dbus_message_is_method_call (message,
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"EmitFoo"))
|
|
|
|
|
{
|
|
|
|
|
/* Emit the Foo signal */
|
|
|
|
|
DBusMessage *signal;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
double v_DOUBLE;
|
2003-10-21 05:46:52 +00:00
|
|
|
|
|
|
|
|
_dbus_verbose ("emitting signal Foo\n");
|
|
|
|
|
|
|
|
|
|
signal = dbus_message_new_signal ("/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"Foo");
|
|
|
|
|
if (signal == NULL)
|
|
|
|
|
die ("No memory\n");
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
|
|
|
|
|
v_DOUBLE = 42.6;
|
2003-10-21 05:46:52 +00:00
|
|
|
if (!dbus_message_append_args (signal,
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
DBUS_TYPE_DOUBLE, &v_DOUBLE,
|
2003-10-21 05:46:52 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
die ("No memory");
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_send (connection, signal, NULL))
|
|
|
|
|
die ("No memory\n");
|
|
|
|
|
|
|
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static DBusObjectPathVTable
|
|
|
|
|
echo_vtable = {
|
|
|
|
|
path_unregistered_func,
|
|
|
|
|
path_message_func,
|
|
|
|
|
NULL,
|
|
|
|
|
};
|
|
|
|
|
|
2004-06-05 16:32:00 +00:00
|
|
|
|
|
|
|
|
static const char* echo_path = "/org/freedesktop/TestSuite" ;
|
2003-10-21 05:46:52 +00:00
|
|
|
|
|
|
|
|
static DBusHandlerResult
|
|
|
|
|
filter_func (DBusConnection *connection,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
void *user_data)
|
|
|
|
|
{
|
|
|
|
|
if (dbus_message_is_signal (message,
|
|
|
|
|
DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL,
|
|
|
|
|
"Disconnected"))
|
2003-04-07 02:01:53 +00:00
|
|
|
{
|
2003-04-07 23:28:16 +00:00
|
|
|
dbus_connection_disconnect (connection);
|
|
|
|
|
quit ();
|
2003-08-12 02:43:50 +00:00
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
2003-04-07 02:01:53 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-08-12 02:43:50 +00:00
|
|
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
2003-04-07 02:01:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-03 05:22:49 +00:00
|
|
|
int
|
|
|
|
|
main (int argc,
|
|
|
|
|
char **argv)
|
|
|
|
|
{
|
|
|
|
|
DBusConnection *connection;
|
|
|
|
|
DBusError error;
|
2003-04-03 21:56:22 +00:00
|
|
|
int result;
|
|
|
|
|
|
2003-04-03 05:22:49 +00:00
|
|
|
dbus_error_init (&error);
|
2005-01-18 20:42:15 +00:00
|
|
|
connection = dbus_bus_get (DBUS_BUS_STARTER, &error);
|
2003-04-03 05:22:49 +00:00
|
|
|
if (connection == NULL)
|
|
|
|
|
{
|
2003-10-21 05:46:52 +00:00
|
|
|
fprintf (stderr, "*** Failed to open connection to activating message bus: %s\n",
|
|
|
|
|
error.message);
|
2003-04-03 05:22:49 +00:00
|
|
|
dbus_error_free (&error);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-07 01:07:13 +00:00
|
|
|
loop = _dbus_loop_new ();
|
|
|
|
|
if (loop == NULL)
|
|
|
|
|
die ("No memory\n");
|
|
|
|
|
|
|
|
|
|
if (!test_connection_setup (loop, connection))
|
|
|
|
|
die ("No memory\n");
|
2003-04-03 21:56:22 +00:00
|
|
|
|
2003-08-31 03:25:24 +00:00
|
|
|
if (!dbus_connection_add_filter (connection,
|
|
|
|
|
filter_func, NULL, NULL))
|
2003-04-03 21:56:22 +00:00
|
|
|
die ("No memory");
|
|
|
|
|
|
2003-10-21 05:46:52 +00:00
|
|
|
if (!dbus_connection_register_object_path (connection,
|
|
|
|
|
echo_path,
|
|
|
|
|
&echo_vtable,
|
|
|
|
|
NULL))
|
|
|
|
|
die ("No memory");
|
2003-09-22 05:45:59 +00:00
|
|
|
|
2005-01-18 20:42:15 +00:00
|
|
|
result = dbus_bus_request_name (connection, "org.freedesktop.DBus.TestSuiteEchoService",
|
|
|
|
|
0, &error);
|
2003-04-03 21:56:22 +00:00
|
|
|
if (dbus_error_is_set (&error))
|
|
|
|
|
{
|
2004-06-05 16:32:00 +00:00
|
|
|
fprintf (stderr, "Error %s\n", error.message);
|
2003-04-11 04:52:29 +00:00
|
|
|
_dbus_verbose ("*** Failed to acquire service: %s\n",
|
|
|
|
|
error.message);
|
2003-04-03 21:56:22 +00:00
|
|
|
dbus_error_free (&error);
|
2003-04-07 23:28:16 +00:00
|
|
|
exit (1);
|
2003-04-03 21:56:22 +00:00
|
|
|
}
|
2003-04-10 05:12:19 +00:00
|
|
|
|
|
|
|
|
_dbus_verbose ("*** Test service entering main loop\n");
|
2003-04-07 01:07:13 +00:00
|
|
|
_dbus_loop_run (loop);
|
2003-04-03 05:22:49 +00:00
|
|
|
|
2003-04-07 23:28:16 +00:00
|
|
|
test_connection_shutdown (loop, connection);
|
2003-08-31 03:25:24 +00:00
|
|
|
|
|
|
|
|
dbus_connection_remove_filter (connection, filter_func, NULL);
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2003-04-03 05:22:49 +00:00
|
|
|
dbus_connection_unref (connection);
|
2003-04-07 01:07:13 +00:00
|
|
|
|
|
|
|
|
_dbus_loop_unref (loop);
|
|
|
|
|
loop = NULL;
|
2003-04-03 21:56:22 +00:00
|
|
|
|
|
|
|
|
dbus_shutdown ();
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2003-04-09 20:31:21 +00:00
|
|
|
_dbus_verbose ("*** Test service exiting\n");
|
2003-04-03 05:22:49 +00:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|