2003-01-21 12:42:33 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu" -*- */
|
2003-01-22 04:48:47 +00:00
|
|
|
/* driver.c Bus client (driver)
|
2003-01-21 12:42:33 +00:00
|
|
|
*
|
2003-04-10 05:12:19 +00:00
|
|
|
* Copyright (C) 2003 CodeFactory AB
|
2005-02-12 17:13:13 +00:00
|
|
|
* Copyright (C) 2003, 2004, 2005 Red Hat, Inc.
|
2003-01-21 12:42:33 +00:00
|
|
|
*
|
2004-08-10 03:07:01 +00:00
|
|
|
* Licensed under the Academic Free License version 2.1
|
2003-01-21 12:42:33 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2003-02-16 10:00:37 +00:00
|
|
|
#include "activation.h"
|
2003-01-21 12:42:33 +00:00
|
|
|
#include "connection.h"
|
|
|
|
|
#include "driver.h"
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
#include "dispatch.h"
|
2003-01-21 12:42:33 +00:00
|
|
|
#include "services.h"
|
2003-09-21 19:53:56 +00:00
|
|
|
#include "signals.h"
|
2003-02-13 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
Add utils.[ch]
* bus/connection.c: (bus_connection_foreach):
Fix a warning.
* bus/desktop-file.c: (grow_lines_in_section), (grow_sections),
(unescape_string), (new_section), (parse_section_start),
(parse_key_value), (report_error), (bus_desktop_file_load),
(bus_desktop_file_get_string):
* bus/desktop-file.h:
Use DBusError for error reporting.
* bus/dispatch.c: (send_one_message),
(bus_dispatch_message_handler):
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_send_service_lost),
(bus_driver_send_service_acquired), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services),
(bus_driver_handle_acquire_service),
(bus_driver_handle_service_exists):
* bus/loop.c: (bus_loop_run):
* bus/main.c:
Use BUS_HANDLE_OOM instead of _DBUS_HANDLE_OOM.
* bus/utils.c: (bus_wait_for_memory):
* bus/utils.h:
New files with general utility functions.
* dbus/dbus-internals.h:
Remove _DBUS_HANDLE_OOM.
2003-02-13 19:06:42 +00:00
|
|
|
#include "utils.h"
|
2003-01-21 12:42:33 +00:00
|
|
|
#include <dbus/dbus-string.h>
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
#include <dbus/dbus-internals.h>
|
2005-03-12 20:07:21 +00:00
|
|
|
#include <dbus/dbus-marshal-recursive.h>
|
2003-01-21 12:42:33 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
static dbus_bool_t bus_driver_send_welcome_message (DBusConnection *connection,
|
|
|
|
|
DBusMessage *hello_message,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusError *error);
|
|
|
|
|
|
|
|
|
|
dbus_bool_t
|
2004-09-24 10:43:36 +00:00
|
|
|
bus_driver_send_service_owner_changed (const char *service_name,
|
|
|
|
|
const char *old_owner,
|
|
|
|
|
const char *new_owner,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusError *error)
|
2003-01-24 23:51:59 +00:00
|
|
|
{
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
DBusMessage *message;
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_bool_t retval;
|
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
|
|
|
const char *null_service;
|
2003-03-26 03:58:11 +00:00
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
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
|
|
|
|
|
|
|
|
null_service = "";
|
2005-01-18 20:42:15 +00:00
|
|
|
_dbus_verbose ("sending name owner changed: %s [%s -> %s]\n",
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
service_name,
|
2004-09-24 10:43:36 +00:00
|
|
|
old_owner ? old_owner : null_service,
|
|
|
|
|
new_owner ? new_owner : null_service);
|
2003-03-16 22:25:18 +00:00
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
message = dbus_message_new_signal (DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameOwnerChanged");
|
2003-08-11 02:11:58 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
if (!dbus_message_set_sender (message, DBUS_SERVICE_DBUS))
|
2004-09-24 10:43:36 +00:00
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_append_args (message,
|
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, &service_name,
|
|
|
|
|
DBUS_TYPE_STRING, old_owner ? &old_owner : &null_service,
|
|
|
|
|
DBUS_TYPE_STRING, new_owner ? &new_owner : &null_service,
|
2003-05-14 02:40:41 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
2004-09-24 10:43:36 +00:00
|
|
|
goto oom;
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_assert (dbus_message_has_signature (message, "sss"));
|
|
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
retval = bus_dispatch_matches (transaction, NULL, NULL, message, error);
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
2003-01-24 23:51:59 +00:00
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
oom:
|
2003-01-24 23:51:59 +00:00
|
|
|
dbus_message_unref (message);
|
2004-09-24 10:43:36 +00:00
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
2003-01-24 23:51:59 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_bool_t
|
2003-01-27 11:20:55 +00:00
|
|
|
bus_driver_send_service_lost (DBusConnection *connection,
|
2003-03-13 00:56:43 +00:00
|
|
|
const char *service_name,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusError *error)
|
2003-01-27 11:20:55 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
|
2003-03-26 03:58:11 +00:00
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
|
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
message = dbus_message_new_signal (DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameLost");
|
2003-08-11 02:11:58 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-01-27 11:20:55 +00:00
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
if (!dbus_message_set_destination (message, bus_connection_get_name (connection)) ||
|
|
|
|
|
!dbus_message_append_args (message,
|
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, &service_name,
|
2003-05-14 02:40:41 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!bus_transaction_send_from_driver (transaction, connection, message))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-01-27 11:20:55 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_bool_t
|
2003-01-27 11:20:55 +00:00
|
|
|
bus_driver_send_service_acquired (DBusConnection *connection,
|
2003-03-13 00:56:43 +00:00
|
|
|
const char *service_name,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusError *error)
|
2003-01-27 11:20:55 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
|
2003-03-26 03:58:11 +00:00
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
|
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
message = dbus_message_new_signal (DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameAcquired");
|
2003-04-24 19:18:23 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-01-27 11:20:55 +00:00
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
if (!dbus_message_set_destination (message, bus_connection_get_name (connection)) ||
|
|
|
|
|
!dbus_message_append_args (message,
|
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, &service_name,
|
2003-05-14 02:40:41 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!bus_transaction_send_from_driver (transaction, connection, message))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-01-27 11:20:55 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-21 12:42:33 +00:00
|
|
|
static dbus_bool_t
|
2003-03-13 03:52:58 +00:00
|
|
|
create_unique_client_name (BusRegistry *registry,
|
|
|
|
|
DBusString *str)
|
2003-01-21 12:42:33 +00:00
|
|
|
{
|
2003-01-22 03:36:05 +00:00
|
|
|
/* We never want to use the same unique client name twice, because
|
|
|
|
|
* we want to guarantee that if you send a message to a given unique
|
|
|
|
|
* name, you always get the same application. So we use two numbers
|
|
|
|
|
* for INT_MAX * INT_MAX combinations, should be pretty safe against
|
|
|
|
|
* wraparound.
|
|
|
|
|
*/
|
2003-04-25 23:50:34 +00:00
|
|
|
/* FIXME these should be in BusRegistry rather than static vars */
|
2003-01-22 03:36:05 +00:00
|
|
|
static int next_major_number = 0;
|
|
|
|
|
static int next_minor_number = 0;
|
|
|
|
|
int len;
|
2003-04-25 23:50:34 +00:00
|
|
|
|
2003-01-21 12:42:33 +00:00
|
|
|
len = _dbus_string_get_length (str);
|
|
|
|
|
|
2003-01-22 03:36:05 +00:00
|
|
|
while (TRUE)
|
2003-01-21 12:42:33 +00:00
|
|
|
{
|
2003-01-22 03:36:05 +00:00
|
|
|
/* start out with 1-0, go to 1-1, 1-2, 1-3,
|
|
|
|
|
* up to 1-MAXINT, then 2-0, 2-1, etc.
|
|
|
|
|
*/
|
|
|
|
|
if (next_minor_number <= 0)
|
|
|
|
|
{
|
|
|
|
|
next_major_number += 1;
|
|
|
|
|
next_minor_number = 0;
|
|
|
|
|
if (next_major_number <= 0)
|
|
|
|
|
_dbus_assert_not_reached ("INT_MAX * INT_MAX clients were added");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_assert (next_major_number > 0);
|
|
|
|
|
_dbus_assert (next_minor_number >= 0);
|
|
|
|
|
|
|
|
|
|
/* appname:MAJOR-MINOR */
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_append (str, ":"))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_append_int (str, next_major_number))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2003-10-21 05:46:52 +00:00
|
|
|
if (!_dbus_string_append (str, "."))
|
2003-01-22 03:36:05 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_append_int (str, next_minor_number))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
next_minor_number += 1;
|
2003-01-21 12:42:33 +00:00
|
|
|
|
|
|
|
|
/* Check if a client with the name exists */
|
2003-03-13 03:52:58 +00:00
|
|
|
if (bus_registry_lookup (registry, str) == NULL)
|
2003-01-21 12:42:33 +00:00
|
|
|
break;
|
|
|
|
|
|
2003-01-22 03:36:05 +00:00
|
|
|
/* drop the number again, try the next one. */
|
2003-01-21 12:42:33 +00:00
|
|
|
_dbus_string_set_length (str, len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
static dbus_bool_t
|
2003-01-24 23:51:59 +00:00
|
|
|
bus_driver_handle_hello (DBusConnection *connection,
|
2003-03-13 00:56:43 +00:00
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
2003-01-21 12:42:33 +00:00
|
|
|
{
|
|
|
|
|
DBusString unique_name;
|
|
|
|
|
BusService *service;
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_bool_t retval;
|
2003-03-13 03:52:58 +00:00
|
|
|
BusRegistry *registry;
|
2003-04-19 16:16:24 +00:00
|
|
|
BusConnections *connections;
|
2003-03-26 03:58:11 +00:00
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
2003-04-19 16:16:24 +00:00
|
|
|
|
2004-09-17 09:14:49 +00:00
|
|
|
if (bus_connection_is_active (connection))
|
|
|
|
|
{
|
|
|
|
|
/* We already handled an Hello message for this connection. */
|
|
|
|
|
dbus_set_error (error, DBUS_ERROR_FAILED,
|
|
|
|
|
"Already handled an Hello message");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
/* Note that when these limits are exceeded we don't disconnect the
|
|
|
|
|
* connection; we just sort of leave it hanging there until it times
|
|
|
|
|
* out or disconnects itself or is dropped due to the max number of
|
|
|
|
|
* incomplete connections. It's even OK if the connection wants to
|
|
|
|
|
* retry the hello message, we support that.
|
|
|
|
|
*/
|
|
|
|
|
connections = bus_connection_get_connections (connection);
|
|
|
|
|
if (!bus_connections_check_limits (connections, connection,
|
|
|
|
|
error))
|
|
|
|
|
{
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
|
2003-03-31 20:56:29 +00:00
|
|
|
if (!_dbus_string_init (&unique_name))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-02-16 10:00:37 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
retval = FALSE;
|
2003-03-13 03:52:58 +00:00
|
|
|
|
|
|
|
|
registry = bus_connection_get_registry (connection);
|
2003-03-13 00:56:43 +00:00
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
if (!create_unique_client_name (registry, &unique_name))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
goto out_0;
|
|
|
|
|
}
|
2003-02-13 21:37:58 +00:00
|
|
|
|
2003-04-27 06:25:42 +00:00
|
|
|
if (!bus_connection_complete (connection, &unique_name, error))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
2003-04-27 06:25:42 +00:00
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
2003-03-13 00:56:43 +00:00
|
|
|
goto out_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_set_sender (message,
|
|
|
|
|
bus_connection_get_name (connection)))
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
goto out_0;
|
|
|
|
|
}
|
2003-01-26 01:34:22 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (!bus_driver_send_welcome_message (connection, message, transaction, error))
|
|
|
|
|
goto out_0;
|
2003-02-13 21:37:58 +00:00
|
|
|
|
2003-01-21 12:42:33 +00:00
|
|
|
/* Create the service */
|
2003-03-13 03:52:58 +00:00
|
|
|
service = bus_registry_ensure (registry,
|
|
|
|
|
&unique_name, connection, transaction, error);
|
2003-03-13 00:56:43 +00:00
|
|
|
if (service == NULL)
|
|
|
|
|
goto out_0;
|
2003-01-27 11:20:55 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
bus_service_set_prohibit_replacement (service, TRUE);
|
2003-01-21 12:42:33 +00:00
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
_dbus_assert (bus_connection_is_active (connection));
|
2003-03-13 00:56:43 +00:00
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out_0:
|
2003-01-21 12:42:33 +00:00
|
|
|
_dbus_string_free (&unique_name);
|
2003-03-13 00:56:43 +00:00
|
|
|
return retval;
|
2003-01-21 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
static dbus_bool_t
|
2003-01-21 12:42:33 +00:00
|
|
|
bus_driver_send_welcome_message (DBusConnection *connection,
|
2003-03-13 00:56:43 +00:00
|
|
|
DBusMessage *hello_message,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusError *error)
|
2003-01-21 12:42:33 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *welcome;
|
|
|
|
|
const char *name;
|
2003-03-26 03:58:11 +00:00
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
2003-01-21 12:42:33 +00:00
|
|
|
|
|
|
|
|
name = bus_connection_get_name (connection);
|
|
|
|
|
_dbus_assert (name != NULL);
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
welcome = dbus_message_new_method_return (hello_message);
|
2003-03-13 00:56:43 +00:00
|
|
|
if (welcome == NULL)
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (!dbus_message_append_args (welcome,
|
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, &name,
|
2003-05-14 02:40:41 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
dbus_message_unref (welcome);
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-12 17:13:13 +00:00
|
|
|
_dbus_assert (dbus_message_has_signature (welcome, DBUS_TYPE_STRING_AS_STRING));
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!bus_transaction_send_from_driver (transaction, connection, welcome))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
dbus_message_unref (welcome);
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (welcome);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-01-21 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
static dbus_bool_t
|
2003-01-24 23:51:59 +00:00
|
|
|
bus_driver_handle_list_services (DBusConnection *connection,
|
2003-03-13 00:56:43 +00:00
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
2003-01-24 23:51:59 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *reply;
|
2003-03-13 00:56:43 +00:00
|
|
|
int len;
|
2003-01-24 23:51:59 +00:00
|
|
|
char **services;
|
2003-03-13 03:52:58 +00:00
|
|
|
BusRegistry *registry;
|
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
|
|
|
int i;
|
|
|
|
|
DBusMessageIter iter;
|
|
|
|
|
DBusMessageIter sub;
|
2003-03-26 03:58:11 +00:00
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
2003-03-13 03:52:58 +00:00
|
|
|
|
|
|
|
|
registry = bus_connection_get_registry (connection);
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
reply = dbus_message_new_method_return (message);
|
2003-03-13 00:56:43 +00:00
|
|
|
if (reply == NULL)
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-01-24 23:51:59 +00:00
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
if (!bus_registry_list_services (registry, &services, &len))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
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
|
|
|
|
2005-01-16 15:51:55 +00:00
|
|
|
dbus_message_iter_init_append (reply, &iter);
|
2003-03-13 00:56:43 +00:00
|
|
|
|
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
|
|
|
if (!dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY,
|
|
|
|
|
DBUS_TYPE_STRING_AS_STRING,
|
|
|
|
|
&sub))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
dbus_free_string_array (services);
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
2005-02-12 20:27:45 +00:00
|
|
|
{
|
|
|
|
|
/* Include the bus driver in the list */
|
2005-02-17 21:19:49 +00:00
|
|
|
const char *v_STRING = DBUS_SERVICE_DBUS;
|
2005-02-12 20:27:45 +00:00
|
|
|
if (!dbus_message_iter_append_basic (&sub, DBUS_TYPE_STRING,
|
|
|
|
|
&v_STRING))
|
|
|
|
|
{
|
|
|
|
|
dbus_free_string_array (services);
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
i = 0;
|
|
|
|
|
while (i < len)
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_message_iter_append_basic (&sub, DBUS_TYPE_STRING,
|
|
|
|
|
&services[i]))
|
|
|
|
|
{
|
|
|
|
|
dbus_free_string_array (services);
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_iter_close_container (&iter, &sub))
|
|
|
|
|
{
|
|
|
|
|
dbus_free_string_array (services);
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_free_string_array (services);
|
|
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!bus_transaction_send_from_driver (transaction, connection, reply))
|
2003-01-25 01:26:49 +00:00
|
|
|
{
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
return TRUE;
|
2003-01-25 01:26:49 +00:00
|
|
|
}
|
2003-01-24 23:51:59 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
static dbus_bool_t
|
2003-02-13 15:29:18 +00:00
|
|
|
bus_driver_handle_acquire_service (DBusConnection *connection,
|
2003-03-13 00:56:43 +00:00
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
2003-01-21 12:42:33 +00:00
|
|
|
{
|
2003-01-27 11:20:55 +00:00
|
|
|
DBusMessage *reply;
|
2003-01-21 12:42:33 +00:00
|
|
|
DBusString service_name;
|
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
|
|
|
const char *name;
|
2003-01-27 11:20:55 +00:00
|
|
|
int service_reply;
|
2004-08-25 08:03:12 +00:00
|
|
|
dbus_uint32_t flags;
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_bool_t retval;
|
2003-03-13 03:52:58 +00:00
|
|
|
BusRegistry *registry;
|
2003-03-26 03:58:11 +00:00
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
2003-03-13 03:52:58 +00:00
|
|
|
|
|
|
|
|
registry = bus_connection_get_registry (connection);
|
2003-01-27 11:20:55 +00:00
|
|
|
|
2003-04-08 15:52:51 +00:00
|
|
|
if (!dbus_message_get_args (message, error,
|
2003-03-13 00:56:43 +00:00
|
|
|
DBUS_TYPE_STRING, &name,
|
|
|
|
|
DBUS_TYPE_UINT32, &flags,
|
2003-05-14 02:40:41 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
2003-03-13 00:56:43 +00:00
|
|
|
return FALSE;
|
2003-01-27 11:20:55 +00:00
|
|
|
|
2005-01-30 07:44:08 +00:00
|
|
|
_dbus_verbose ("Trying to own name %s with flags 0x%x\n", name, flags);
|
2003-04-08 20:16:03 +00:00
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
reply = NULL;
|
2003-01-21 12:42:33 +00:00
|
|
|
|
|
|
|
|
_dbus_string_init_const (&service_name, name);
|
2003-01-27 11:20:55 +00:00
|
|
|
|
2003-04-11 00:03:06 +00:00
|
|
|
if (!bus_registry_acquire_service (registry, connection,
|
|
|
|
|
&service_name, flags,
|
|
|
|
|
&service_reply, transaction,
|
|
|
|
|
error))
|
|
|
|
|
goto out;
|
2003-01-21 12:42:33 +00:00
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
reply = dbus_message_new_method_return (message);
|
2003-03-13 00:56:43 +00:00
|
|
|
if (reply == NULL)
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
goto out;
|
2003-01-27 11:20:55 +00:00
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
|
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
|
|
|
if (!dbus_message_append_args (reply, DBUS_TYPE_UINT32, &service_reply, DBUS_TYPE_INVALID))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-02-02 00:39:10 +00:00
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!bus_transaction_send_from_driver (transaction, connection, reply))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (reply)
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
2003-01-21 12:42:33 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
static dbus_bool_t
|
2003-01-27 11:20:55 +00:00
|
|
|
bus_driver_handle_service_exists (DBusConnection *connection,
|
2003-03-13 00:56:43 +00:00
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
2003-01-27 11:20:55 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *reply;
|
|
|
|
|
DBusString service_name;
|
|
|
|
|
BusService *service;
|
2005-01-17 19:49:52 +00:00
|
|
|
dbus_bool_t service_exists;
|
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
|
|
|
const char *name;
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_bool_t retval;
|
2003-03-13 03:52:58 +00:00
|
|
|
BusRegistry *registry;
|
2003-03-26 03:58:11 +00:00
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
2003-03-13 03:52:58 +00:00
|
|
|
|
|
|
|
|
registry = bus_connection_get_registry (connection);
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (!dbus_message_get_args (message, error,
|
|
|
|
|
DBUS_TYPE_STRING, &name,
|
2003-05-14 02:40:41 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
2003-03-13 00:56:43 +00:00
|
|
|
return FALSE;
|
2003-01-27 11:20:55 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
retval = FALSE;
|
2004-08-26 17:26:06 +00:00
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
if (strcmp (name, DBUS_SERVICE_DBUS) == 0)
|
2004-08-26 17:26:06 +00:00
|
|
|
{
|
|
|
|
|
service_exists = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_string_init_const (&service_name, name);
|
|
|
|
|
service = bus_registry_lookup (registry, &service_name);
|
|
|
|
|
service_exists = service != NULL;
|
|
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
reply = dbus_message_new_method_return (message);
|
2003-03-13 00:56:43 +00:00
|
|
|
if (reply == NULL)
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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_BOOLEAN, &service_exists,
|
2003-03-13 00:56:43 +00:00
|
|
|
0))
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!bus_transaction_send_from_driver (transaction, connection, reply))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (reply)
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
|
|
|
|
|
return retval;
|
2003-01-21 12:42:33 +00:00
|
|
|
}
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
static dbus_bool_t
|
2003-02-16 10:00:37 +00:00
|
|
|
bus_driver_handle_activate_service (DBusConnection *connection,
|
2003-03-13 00:56:43 +00:00
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
2003-02-16 10:00:37 +00:00
|
|
|
{
|
|
|
|
|
dbus_uint32_t flags;
|
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
|
|
|
const char *name;
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_bool_t retval;
|
2003-03-13 03:52:58 +00:00
|
|
|
BusActivation *activation;
|
|
|
|
|
|
2003-03-26 03:58:11 +00:00
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
|
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
activation = bus_connection_get_activation (connection);
|
2003-02-16 10:00:37 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (!dbus_message_get_args (message, error,
|
|
|
|
|
DBUS_TYPE_STRING, &name,
|
|
|
|
|
DBUS_TYPE_UINT32, &flags,
|
2003-05-14 02:40:41 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
2003-04-11 03:05:58 +00:00
|
|
|
{
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
2005-01-18 20:42:15 +00:00
|
|
|
_dbus_verbose ("No memory to get arguments to StartServiceByName\n");
|
2003-04-11 03:05:58 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-02-16 10:00:37 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
retval = FALSE;
|
2003-02-16 10:00:37 +00:00
|
|
|
|
2004-03-16 18:00:35 +00:00
|
|
|
if (!bus_activation_activate_service (activation, connection, transaction, FALSE,
|
2003-04-02 20:14:52 +00:00
|
|
|
message, name, error))
|
2003-04-11 03:05:58 +00:00
|
|
|
{
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
|
|
|
|
_dbus_verbose ("bus_activation_activate_service() failed\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
return retval;
|
2003-02-16 10:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
send_ack_reply (DBusConnection *connection,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *reply;
|
|
|
|
|
|
|
|
|
|
reply = dbus_message_new_method_return (message);
|
|
|
|
|
if (reply == NULL)
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bus_transaction_send_from_driver (transaction, connection, reply))
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
bus_driver_handle_add_match (DBusConnection *connection,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
|
|
|
|
{
|
|
|
|
|
BusMatchRule *rule;
|
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
|
|
|
const char *text;
|
2003-09-21 19:53:56 +00:00
|
|
|
DBusString str;
|
|
|
|
|
BusMatchmaker *matchmaker;
|
|
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
|
|
|
|
|
|
|
|
|
text = NULL;
|
|
|
|
|
rule = NULL;
|
|
|
|
|
|
|
|
|
|
if (bus_connection_get_n_match_rules (connection) >=
|
|
|
|
|
bus_context_get_max_match_rules_per_connection (bus_transaction_get_context (transaction)))
|
|
|
|
|
{
|
|
|
|
|
dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
|
|
|
|
|
"Connection \"%s\" is not allowed to add more match rules "
|
|
|
|
|
"(increase limits in configuration file if required)",
|
|
|
|
|
bus_connection_is_active (connection) ?
|
|
|
|
|
bus_connection_get_name (connection) :
|
|
|
|
|
"(inactive)");
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_get_args (message, error,
|
|
|
|
|
DBUS_TYPE_STRING, &text,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("No memory to get arguments to AddMatch\n");
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_string_init_const (&str, text);
|
|
|
|
|
|
|
|
|
|
rule = bus_match_rule_parse (connection, &str, error);
|
|
|
|
|
if (rule == NULL)
|
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
|
|
matchmaker = bus_connection_get_matchmaker (connection);
|
|
|
|
|
|
|
|
|
|
if (!bus_matchmaker_add_rule (matchmaker, rule))
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!send_ack_reply (connection, transaction,
|
|
|
|
|
message, error))
|
|
|
|
|
{
|
|
|
|
|
bus_matchmaker_remove_rule (matchmaker, rule);
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bus_match_rule_unref (rule);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
failed:
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
|
|
|
|
if (rule)
|
|
|
|
|
bus_match_rule_unref (rule);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
bus_driver_handle_remove_match (DBusConnection *connection,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
|
|
|
|
{
|
|
|
|
|
BusMatchRule *rule;
|
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
|
|
|
const char *text;
|
2003-09-21 19:53:56 +00:00
|
|
|
DBusString str;
|
|
|
|
|
BusMatchmaker *matchmaker;
|
|
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
|
|
|
|
|
|
|
|
|
text = NULL;
|
|
|
|
|
rule = NULL;
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_get_args (message, error,
|
|
|
|
|
DBUS_TYPE_STRING, &text,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("No memory to get arguments to RemoveMatch\n");
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_string_init_const (&str, text);
|
|
|
|
|
|
|
|
|
|
rule = bus_match_rule_parse (connection, &str, error);
|
|
|
|
|
if (rule == NULL)
|
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
|
|
/* Send the ack before we remove the rule, since the ack is undone
|
|
|
|
|
* on transaction cancel, but rule removal isn't.
|
|
|
|
|
*/
|
|
|
|
|
if (!send_ack_reply (connection, transaction,
|
|
|
|
|
message, error))
|
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
|
|
matchmaker = bus_connection_get_matchmaker (connection);
|
|
|
|
|
|
|
|
|
|
if (!bus_matchmaker_remove_rule_by_value (matchmaker, rule, error))
|
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
|
|
bus_match_rule_unref (rule);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
failed:
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
|
|
|
|
if (rule)
|
|
|
|
|
bus_match_rule_unref (rule);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-15 22:08:05 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
bus_driver_handle_get_service_owner (DBusConnection *connection,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
|
|
|
|
{
|
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
|
|
|
const char *text;
|
2004-04-15 22:08:05 +00:00
|
|
|
const char *base_name;
|
|
|
|
|
DBusString str;
|
|
|
|
|
BusRegistry *registry;
|
|
|
|
|
BusService *service;
|
|
|
|
|
DBusMessage *reply;
|
|
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
|
|
|
|
|
|
|
|
|
registry = bus_connection_get_registry (connection);
|
|
|
|
|
|
|
|
|
|
text = NULL;
|
|
|
|
|
reply = NULL;
|
|
|
|
|
|
|
|
|
|
if (! dbus_message_get_args (message, error,
|
|
|
|
|
DBUS_TYPE_STRING, &text,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
|
|
_dbus_string_init_const (&str, text);
|
|
|
|
|
service = bus_registry_lookup (registry, &str);
|
2005-01-30 05:18:44 +00:00
|
|
|
if (service == NULL &&
|
2005-02-17 21:19:49 +00:00
|
|
|
_dbus_string_equal_c_str (&str, DBUS_SERVICE_DBUS))
|
2005-01-30 05:18:44 +00:00
|
|
|
{
|
|
|
|
|
/* ORG_FREEDESKTOP_DBUS owns itself */
|
2005-02-17 21:19:49 +00:00
|
|
|
base_name = DBUS_SERVICE_DBUS;
|
2005-01-30 05:18:44 +00:00
|
|
|
}
|
|
|
|
|
else if (service == NULL)
|
2004-04-15 22:08:05 +00:00
|
|
|
{
|
|
|
|
|
dbus_set_error (error,
|
2005-01-30 05:18:44 +00:00
|
|
|
DBUS_ERROR_NAME_HAS_NO_OWNER,
|
|
|
|
|
"Could not get owner of name '%s': no such name", text);
|
2004-04-15 22:08:05 +00:00
|
|
|
goto failed;
|
|
|
|
|
}
|
2005-01-30 05:18:44 +00:00
|
|
|
else
|
2004-04-15 22:08:05 +00:00
|
|
|
{
|
2005-01-30 05:18:44 +00:00
|
|
|
base_name = bus_connection_get_name (bus_service_get_primary_owner (service));
|
|
|
|
|
if (base_name == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* FIXME - how is this error possible? */
|
|
|
|
|
dbus_set_error (error,
|
|
|
|
|
DBUS_ERROR_FAILED,
|
|
|
|
|
"Could not determine unique name for '%s'", text);
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
_dbus_assert (*base_name == ':');
|
2004-04-15 22:08:05 +00:00
|
|
|
}
|
2005-01-30 05:18:44 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (base_name != NULL);
|
2004-04-15 22:08:05 +00:00
|
|
|
|
|
|
|
|
reply = dbus_message_new_method_return (message);
|
|
|
|
|
if (reply == NULL)
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
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, &base_name,
|
2004-04-15 22:08:05 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
if (! bus_transaction_send_from_driver (transaction, connection, reply))
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
oom:
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
|
|
|
|
|
failed:
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
|
|
|
|
if (reply)
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-28 21:55:15 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
bus_driver_handle_get_connection_unix_user (DBusConnection *connection,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
|
|
|
|
{
|
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
|
|
|
const char *service;
|
2004-06-28 21:55:15 +00:00
|
|
|
DBusString str;
|
|
|
|
|
BusRegistry *registry;
|
|
|
|
|
BusService *serv;
|
|
|
|
|
DBusConnection *conn;
|
|
|
|
|
DBusMessage *reply;
|
|
|
|
|
unsigned long uid;
|
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_uint32_t uid32;
|
2004-06-28 21:55:15 +00:00
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
|
|
|
|
|
|
|
|
|
registry = bus_connection_get_registry (connection);
|
|
|
|
|
|
|
|
|
|
service = NULL;
|
|
|
|
|
reply = NULL;
|
|
|
|
|
|
|
|
|
|
if (! dbus_message_get_args (message, error,
|
|
|
|
|
DBUS_TYPE_STRING, &service,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("asked for UID of connection %s\n", service);
|
|
|
|
|
|
|
|
|
|
_dbus_string_init_const (&str, service);
|
|
|
|
|
serv = bus_registry_lookup (registry, &str);
|
|
|
|
|
if (serv == NULL)
|
|
|
|
|
{
|
|
|
|
|
dbus_set_error (error,
|
2005-01-18 20:42:15 +00:00
|
|
|
DBUS_ERROR_NAME_HAS_NO_OWNER,
|
|
|
|
|
"Could not get UID of name '%s': no such name", service);
|
2004-06-28 21:55:15 +00:00
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conn = bus_service_get_primary_owner (serv);
|
|
|
|
|
|
|
|
|
|
reply = dbus_message_new_method_return (message);
|
|
|
|
|
if (reply == NULL)
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_unix_user (conn, &uid))
|
|
|
|
|
{
|
|
|
|
|
dbus_set_error (error,
|
|
|
|
|
DBUS_ERROR_FAILED,
|
|
|
|
|
"Could not determine UID for '%s'", service);
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
uid32 = uid;
|
2004-06-28 21:55:15 +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_UINT32, &uid32,
|
2004-06-28 21:55:15 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
if (! bus_transaction_send_from_driver (transaction, connection, reply))
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
oom:
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
|
|
|
|
|
failed:
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
|
|
|
|
if (reply)
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-19 20:55:58 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
bus_driver_handle_get_connection_unix_process_id (DBusConnection *connection,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
|
|
|
|
{
|
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
|
|
|
const char *service;
|
2004-07-19 20:55:58 +00:00
|
|
|
DBusString str;
|
|
|
|
|
BusRegistry *registry;
|
|
|
|
|
BusService *serv;
|
|
|
|
|
DBusConnection *conn;
|
|
|
|
|
DBusMessage *reply;
|
|
|
|
|
unsigned long pid;
|
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_uint32_t pid32;
|
2004-07-19 20:55:58 +00:00
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
|
|
|
|
|
|
|
|
|
registry = bus_connection_get_registry (connection);
|
|
|
|
|
|
|
|
|
|
service = NULL;
|
|
|
|
|
reply = NULL;
|
|
|
|
|
|
|
|
|
|
if (! dbus_message_get_args (message, error,
|
|
|
|
|
DBUS_TYPE_STRING, &service,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("asked for PID of connection %s\n", service);
|
|
|
|
|
|
|
|
|
|
_dbus_string_init_const (&str, service);
|
|
|
|
|
serv = bus_registry_lookup (registry, &str);
|
|
|
|
|
if (serv == NULL)
|
|
|
|
|
{
|
|
|
|
|
dbus_set_error (error,
|
2005-01-18 20:42:15 +00:00
|
|
|
DBUS_ERROR_NAME_HAS_NO_OWNER,
|
|
|
|
|
"Could not get PID of name '%s': no such name", service);
|
2004-07-19 20:55:58 +00:00
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conn = bus_service_get_primary_owner (serv);
|
|
|
|
|
|
|
|
|
|
reply = dbus_message_new_method_return (message);
|
|
|
|
|
if (reply == NULL)
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_unix_process_id (conn, &pid))
|
|
|
|
|
{
|
|
|
|
|
dbus_set_error (error,
|
|
|
|
|
DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN,
|
|
|
|
|
"Could not determine PID for '%s'", service);
|
|
|
|
|
goto failed;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
pid32 = pid;
|
2004-07-19 20:55:58 +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_UINT32, &pid32,
|
2004-07-19 20:55:58 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
if (! bus_transaction_send_from_driver (transaction, connection, reply))
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
oom:
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
|
|
|
|
|
failed:
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
|
|
|
|
if (reply)
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-20 18:45:16 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
bus_driver_handle_reload_config (DBusConnection *connection,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
|
|
|
|
{
|
|
|
|
|
BusContext *context;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
context = bus_connection_get_context (connection);
|
|
|
|
|
if (!bus_context_reload_config (context, error))
|
|
|
|
|
{
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
/* For speed it might be useful to sort this in order of
|
|
|
|
|
* frequency of use (but doesn't matter with only a few items
|
|
|
|
|
* anyhow)
|
|
|
|
|
*/
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
2005-02-12 17:13:13 +00:00
|
|
|
const char *in_args;
|
|
|
|
|
const char *out_args;
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_bool_t (* handler) (DBusConnection *connection,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error);
|
|
|
|
|
} message_handlers[] = {
|
2005-02-12 17:13:13 +00:00
|
|
|
{ "RequestName",
|
|
|
|
|
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_UINT32_AS_STRING,
|
|
|
|
|
DBUS_TYPE_UINT32_AS_STRING,
|
|
|
|
|
bus_driver_handle_acquire_service },
|
|
|
|
|
{ "StartServiceByName",
|
|
|
|
|
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_UINT32_AS_STRING,
|
|
|
|
|
DBUS_TYPE_UINT32_AS_STRING,
|
|
|
|
|
bus_driver_handle_activate_service },
|
|
|
|
|
{ "Hello",
|
|
|
|
|
"",
|
|
|
|
|
DBUS_TYPE_STRING_AS_STRING,
|
|
|
|
|
bus_driver_handle_hello },
|
|
|
|
|
{ "NameHasOwner",
|
|
|
|
|
DBUS_TYPE_STRING_AS_STRING,
|
|
|
|
|
DBUS_TYPE_BOOLEAN_AS_STRING,
|
|
|
|
|
bus_driver_handle_service_exists },
|
|
|
|
|
{ "ListNames",
|
|
|
|
|
"",
|
|
|
|
|
DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING,
|
|
|
|
|
bus_driver_handle_list_services },
|
|
|
|
|
{ "AddMatch",
|
|
|
|
|
DBUS_TYPE_STRING_AS_STRING,
|
|
|
|
|
"",
|
|
|
|
|
bus_driver_handle_add_match },
|
|
|
|
|
{ "RemoveMatch",
|
|
|
|
|
DBUS_TYPE_STRING_AS_STRING,
|
|
|
|
|
"",
|
|
|
|
|
bus_driver_handle_remove_match },
|
|
|
|
|
{ "GetNameOwner",
|
|
|
|
|
DBUS_TYPE_STRING_AS_STRING,
|
|
|
|
|
DBUS_TYPE_STRING_AS_STRING,
|
|
|
|
|
bus_driver_handle_get_service_owner },
|
|
|
|
|
{ "GetConnectionUnixUser",
|
|
|
|
|
DBUS_TYPE_STRING_AS_STRING,
|
|
|
|
|
DBUS_TYPE_UINT32_AS_STRING,
|
|
|
|
|
bus_driver_handle_get_connection_unix_user },
|
|
|
|
|
{ "GetConnectionUnixProcessID",
|
|
|
|
|
DBUS_TYPE_STRING_AS_STRING,
|
|
|
|
|
DBUS_TYPE_UINT32_AS_STRING,
|
|
|
|
|
bus_driver_handle_get_connection_unix_process_id },
|
|
|
|
|
{ "ReloadConfig",
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
bus_driver_handle_reload_config }
|
2003-03-13 00:56:43 +00:00
|
|
|
};
|
|
|
|
|
|
2005-03-12 20:07:21 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
write_args_for_direction (DBusString *xml,
|
|
|
|
|
const char *signature,
|
|
|
|
|
dbus_bool_t in)
|
|
|
|
|
{
|
|
|
|
|
DBusTypeReader typereader;
|
|
|
|
|
DBusString sigstr;
|
|
|
|
|
int current_type;
|
|
|
|
|
|
|
|
|
|
_dbus_string_init_const (&sigstr, signature);
|
|
|
|
|
_dbus_type_reader_init_types_only (&typereader, &sigstr, 0);
|
|
|
|
|
|
|
|
|
|
while ((current_type = _dbus_type_reader_get_current_type (&typereader)) != DBUS_TYPE_INVALID)
|
|
|
|
|
{
|
|
|
|
|
const DBusString *subsig;
|
|
|
|
|
int start, len;
|
|
|
|
|
|
|
|
|
|
_dbus_type_reader_get_signature (&typereader, &subsig, &start, &len);
|
2005-03-17 17:11:59 +00:00
|
|
|
if (!_dbus_string_append_printf (xml, " <arg direction=\"%s\" type=\"",
|
|
|
|
|
in ? "in" : "out"))
|
|
|
|
|
goto oom;
|
|
|
|
|
if (!_dbus_string_append_len (xml,
|
|
|
|
|
_dbus_string_get_const_data (subsig) + start,
|
|
|
|
|
len))
|
|
|
|
|
goto oom;
|
|
|
|
|
if (!_dbus_string_append (xml, "\"/>\n"))
|
2005-03-12 20:07:21 +00:00
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
_dbus_type_reader_next (&typereader);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
oom:
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-30 05:18:44 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
bus_driver_handle_introspect (DBusConnection *connection,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
|
|
|
|
{
|
|
|
|
|
DBusString xml;
|
|
|
|
|
DBusMessage *reply;
|
|
|
|
|
const char *v_STRING;
|
2005-02-12 20:13:08 +00:00
|
|
|
int i;
|
2005-01-30 05:18:44 +00:00
|
|
|
|
|
|
|
|
_dbus_verbose ("Introspect() on bus driver\n");
|
|
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
|
|
|
|
|
|
|
|
|
reply = NULL;
|
|
|
|
|
|
|
|
|
|
if (! dbus_message_get_args (message, error,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_init (&xml))
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_append (&xml, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE))
|
|
|
|
|
goto oom;
|
|
|
|
|
if (!_dbus_string_append (&xml, "<node>\n"))
|
|
|
|
|
goto oom;
|
2005-02-17 21:19:49 +00:00
|
|
|
if (!_dbus_string_append_printf (&xml, " <interface name=\"%s\">\n", DBUS_INTERFACE_INTROSPECTABLE))
|
2005-01-30 05:18:44 +00:00
|
|
|
goto oom;
|
|
|
|
|
if (!_dbus_string_append (&xml, " <method name=\"Introspect\">\n"))
|
|
|
|
|
goto oom;
|
2005-03-12 16:33:01 +00:00
|
|
|
if (!_dbus_string_append_printf (&xml, " <arg name=\"data\" direction=\"out\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING))
|
2005-01-30 05:18:44 +00:00
|
|
|
goto oom;
|
|
|
|
|
if (!_dbus_string_append (&xml, " </method>\n"))
|
|
|
|
|
goto oom;
|
|
|
|
|
if (!_dbus_string_append (&xml, " </interface>\n"))
|
2005-02-12 20:13:08 +00:00
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_append_printf (&xml, " <interface name=\"%s\">\n",
|
2005-02-17 21:19:49 +00:00
|
|
|
DBUS_INTERFACE_DBUS))
|
2005-02-12 20:13:08 +00:00
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
while (i < _DBUS_N_ELEMENTS (message_handlers))
|
|
|
|
|
{
|
2005-03-12 20:07:21 +00:00
|
|
|
|
2005-02-12 20:13:08 +00:00
|
|
|
if (!_dbus_string_append_printf (&xml, " <method name=\"%s\">\n",
|
|
|
|
|
message_handlers[i].name))
|
|
|
|
|
goto oom;
|
|
|
|
|
|
2005-03-12 20:07:21 +00:00
|
|
|
if (!write_args_for_direction (&xml, message_handlers[i].in_args, TRUE))
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
if (!write_args_for_direction (&xml, message_handlers[i].out_args, FALSE))
|
|
|
|
|
goto oom;
|
2005-02-12 20:13:08 +00:00
|
|
|
|
|
|
|
|
if (!_dbus_string_append (&xml, " </method>\n"))
|
2005-03-12 20:07:21 +00:00
|
|
|
goto oom;
|
2005-02-12 20:13:08 +00:00
|
|
|
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_append (&xml, " </interface>\n"))
|
2005-01-30 05:18:44 +00:00
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_append (&xml, "</node>\n"))
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
reply = dbus_message_new_method_return (message);
|
|
|
|
|
if (reply == NULL)
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
v_STRING = _dbus_string_get_const_data (&xml);
|
|
|
|
|
if (! dbus_message_append_args (reply,
|
|
|
|
|
DBUS_TYPE_STRING, &v_STRING,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
if (! bus_transaction_send_from_driver (transaction, connection, reply))
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
_dbus_string_free (&xml);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
oom:
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
|
|
|
|
|
if (reply)
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
|
|
|
|
|
_dbus_string_free (&xml);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_bool_t
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
bus_driver_handle_message (DBusConnection *connection,
|
2003-03-13 00:56:43 +00:00
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
{
|
2005-01-30 05:18:44 +00:00
|
|
|
const char *name, *sender, *interface;
|
2003-03-13 00:56:43 +00:00
|
|
|
int i;
|
2003-03-26 03:58:11 +00:00
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
2003-08-18 22:43:30 +00:00
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_METHOD_CALL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Driver got a non-method-call message, ignoring\n");
|
|
|
|
|
return TRUE; /* we just ignore this */
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-30 05:18:44 +00:00
|
|
|
if (dbus_message_is_method_call (message,
|
2005-02-17 21:19:49 +00:00
|
|
|
DBUS_INTERFACE_INTROSPECTABLE,
|
2005-01-30 05:18:44 +00:00
|
|
|
"Introspect"))
|
|
|
|
|
return bus_driver_handle_introspect (connection, transaction, message, error);
|
|
|
|
|
|
|
|
|
|
interface = dbus_message_get_interface (message);
|
|
|
|
|
if (interface == NULL)
|
2005-02-17 21:19:49 +00:00
|
|
|
interface = DBUS_INTERFACE_DBUS;
|
2005-01-30 05:18:44 +00:00
|
|
|
|
2003-08-18 22:43:30 +00:00
|
|
|
_dbus_assert (dbus_message_get_member (message) != NULL);
|
2005-01-30 05:18:44 +00:00
|
|
|
|
2003-08-18 22:43:30 +00:00
|
|
|
name = dbus_message_get_member (message);
|
|
|
|
|
sender = dbus_message_get_sender (message);
|
2003-03-13 00:56:43 +00:00
|
|
|
|
2005-01-30 05:18:44 +00:00
|
|
|
if (strcmp (interface,
|
2005-02-17 21:19:49 +00:00
|
|
|
DBUS_INTERFACE_DBUS) != 0)
|
2003-08-18 22:43:30 +00:00
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Driver got message to unknown interface \"%s\"\n",
|
2005-01-30 05:18:44 +00:00
|
|
|
interface);
|
2003-08-18 22:43:30 +00:00
|
|
|
goto unknown;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Driver got a method call: %s\n",
|
|
|
|
|
dbus_message_get_member (message));
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
2003-04-27 06:25:42 +00:00
|
|
|
/* security checks should have kept this from getting here */
|
2003-08-18 22:43:30 +00:00
|
|
|
_dbus_assert (sender != NULL || strcmp (name, "Hello") == 0);
|
2003-04-14 02:29:21 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
i = 0;
|
|
|
|
|
while (i < _DBUS_N_ELEMENTS (message_handlers))
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (message_handlers[i].name, name) == 0)
|
|
|
|
|
{
|
2005-02-12 17:13:13 +00:00
|
|
|
_dbus_verbose ("Found driver handler for %s\n", name);
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_has_signature (message, message_handlers[i].in_args))
|
|
|
|
|
{
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
|
|
|
|
_dbus_verbose ("Call to %s has wrong args (%s, expected %s)\n",
|
|
|
|
|
name, dbus_message_get_signature (message),
|
|
|
|
|
message_handlers[i].in_args);
|
|
|
|
|
|
|
|
|
|
dbus_set_error (error, DBUS_ERROR_INVALID_ARGS,
|
|
|
|
|
"Call to %s has wrong args (%s, expected %s)\n",
|
|
|
|
|
name, dbus_message_get_signature (message),
|
|
|
|
|
message_handlers[i].in_args);
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if ((* message_handlers[i].handler) (connection, transaction, message, error))
|
2003-04-11 03:05:58 +00:00
|
|
|
{
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
|
|
|
|
_dbus_verbose ("Driver handler succeeded\n");
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
else
|
2003-04-11 03:05:58 +00:00
|
|
|
{
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
|
|
|
|
_dbus_verbose ("Driver handler returned failure\n");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-18 22:43:30 +00:00
|
|
|
unknown:
|
|
|
|
|
_dbus_verbose ("No driver handler for message \"%s\"\n",
|
|
|
|
|
name);
|
2003-04-11 03:05:58 +00:00
|
|
|
|
2003-08-12 04:15:49 +00:00
|
|
|
dbus_set_error (error, DBUS_ERROR_UNKNOWN_METHOD,
|
2003-03-13 00:56:43 +00:00
|
|
|
"%s does not understand message %s",
|
2005-02-17 21:19:49 +00:00
|
|
|
DBUS_SERVICE_DBUS, name);
|
2003-03-13 00:56:43 +00:00
|
|
|
|
|
|
|
|
return FALSE;
|
2003-01-27 11:20:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
bus_driver_remove_connection (DBusConnection *connection)
|
|
|
|
|
{
|
2003-03-13 00:56:43 +00:00
|
|
|
/* FIXME Does nothing for now, should unregister the connection
|
|
|
|
|
* with the bus driver.
|
|
|
|
|
*/
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
}
|