Commit graph

74 commits

Author SHA1 Message Date
Havoc Pennington
fa05de9230 2003-03-31 Havoc Pennington <hp@redhat.com>
Fix some annoying DBusString API and fix all affected code.

	* dbus/dbus-string.c (_dbus_string_init): get rid of annoying
	max_length argument
	(_dbus_string_get_data): change to return string instead of using
	an out param
	(_dbus_string_get_const_data): ditto
	(_dbus_string_get_data_len): ditto
	(_dbus_string_get_const_data_len): ditto
2003-03-31 20:56:29 +00:00
Havoc Pennington
90ed1d8458 2003-03-25 Havoc Pennington <hp@redhat.com>
* throughout - add more _DBUS_ASSERT_ERROR_IS_CLEAR

	* configure.in: add --with-xml option to specify XML library,
	right now only libxml is supported.

	* bus/config-loader-libxml.c, config-parser.c: sync some minor
	nonworking code between home and work, still just stubs
2003-03-26 03:58:11 +00:00
Anders Carlsson
3f4086f0fd 2003-03-16 Anders Carlsson <andersca@codefactory.se>
* bus/activation.c: (bus_pending_activation_entry_free),
	(bus_pending_activation_free), (bus_activation_new),
	(bus_activation_unref), (bus_activation_service_created),
	(bus_activation_activate_service):
	* bus/activation.h:
	* bus/bus.c: (bus_context_new):
	* bus/desktop-file.c: (new_section):
	* bus/driver.c: (bus_driver_send_service_deleted),
	(bus_driver_handle_activate_service):
	* bus/services.c: (bus_registry_new), (bus_registry_ensure):
	* bus/services.h:
	* dbus/dbus-connection.c:
	(dbus_connection_send_with_reply_and_block):
	* dbus/dbus-message.c: (dbus_message_append_args_valist):
	* dbus/dbus-protocol.h:
	Make activation work better. Now pending activations will be queued
	and the daemon won't try to activate services that are already registered.
2003-03-16 22:25:18 +00:00
Havoc Pennington
6ecc14ffab 2003-03-12 Havoc Pennington <hp@pobox.com>
Throughout: purge global variables, introduce BusActivation,
	BusConnections, BusRegistry, etc. objects instead.

	* bus/bus.h, bus/bus.c: introduce BusContext as a global
	message bus object

	* test/Makefile.am (TEST_BINARIES): disable bus-test for now,
	going to redo this a bit differently I think
2003-03-13 03:52:58 +00:00
Havoc Pennington
29560adcc7 2003-03-12 Havoc Pennington <hp@redhat.com>
Mega-patch that gets the message bus daemon initially handling
	out-of-memory. Work still needed. Also lots of random
	moving stuff to DBusError instead of ResultCode.

	* dbus/dbus-list.c (_dbus_list_length_is_one): new function

	* dbus/dbus-connection.c
	(dbus_connection_send_with_reply_and_block): use DBusError

	* dbus/dbus-bus.c: adapt to API changes, make it use DBusError not
	DBusResultCode

	* dbus/dbus-connection.c (dbus_connection_send): drop the result
	code here, as the only failure possible is OOM.

	* bus/connection.c (bus_connection_disconnect):
	rename bus_connection_disconnected as it's a notification only

	* bus/driver.c (bus_driver_handle_acquire_service): don't free
	"name" on get_args failure, should be done by get_args;
	don't disconnect client for bad args, just return an error.
	(bus_driver_handle_service_exists): ditto

	* bus/services.c (bus_services_list): NULL-terminate returned array

	* bus/driver.c (bus_driver_send_service_lost)
	(bus_driver_send_service_acquired): send messages from driver to a
	specific client to the client's unique name, not to the broadcast
	service.

	* dbus/dbus-message.c (decode_header_data): reject messages that
	contain no name field
	(_dbus_message_get_client_serial): rename to
	dbus_message_get_serial and make public
	(_dbus_message_set_serial): rename from set_client_serial
	(_dbus_message_set_reply_serial): make public
	(_dbus_message_get_reply_serial): make public

	* bus/connection.c (bus_connection_foreach): allow stopping
	iteration by returning FALSE from foreach function.

	* dbus/dbus-connection.c (dbus_connection_send_preallocated)
	(dbus_connection_free_preallocated_send)
	(dbus_connection_preallocate_send): new API for sending a message
	without possibility of malloc failure.
	(dbus_connection_send_message): rename to just
	dbus_connection_send (and same for whole function family)

	* dbus/dbus-errors.c (dbus_error_free): make this reinit the error

	* dbus/dbus-sysdeps.c (_dbus_exit): new function

	* bus/activation.c: handle/return errors

	* dbus/dbus-errors.h: add more DBUS_ERROR #define

	* dbus/dbus-sysdeps.c (_dbus_directory_open) (_dbus_file_get_contents)
	(_dbus_directory_get_next_file): use DBusError instead of DBusResultCode
	(_dbus_result_from_errno): move to this file
2003-03-13 00:56:43 +00:00
Anders Carlsson
f116b1282f 2003-02-16 Anders Carlsson <andersca@codefactory.se>
* bus/activation.c: (load_directory), (bus_activation_init),
	(bus_activation_activate_service):
	* bus/activation.h:
	* bus/driver.c:
	(bus_driver_handle_activate_service), (bus_driver_handle_message):
	More work on the activation handling.

	* dbus/dbus-errors.h:
	Add some error messages

	* dbus/dbus-message.c: (dbus_message_new_error_reply):
	* dbus/dbus-message.h:
	New function that creates an error message.

	* dbus/dbus-protocol.h:
	Add ACTIVATE_SERVER message.

	* dbus/dbus-server-unix.c: (unix_handle_watch),
	(_dbus_server_new_for_domain_socket):
	Call _dbus_fd_set_close_on_exec.

	* dbus/dbus-sysdeps.c: (make_pipe), (do_exec),
	(_dbus_spawn_async), (_dbus_disable_sigpipe),
	(_dbus_fd_set_close_on_exec):
	* dbus/dbus-sysdeps.h:
	Add _dbus_fd_set_close_on exec function. Also add function that checks
	that all open fds are set to close-on-exec and warns otherwise.

	* dbus/dbus-transport-unix.c:
	(_dbus_transport_new_for_domain_socket):
	Call _dbus_fd_set_close_on_exec.
2003-02-16 10:00:37 +00:00
Anders Carlsson
97ee8d1899 2003-02-13 Anders Carlsson <andersca@codefactory.se>
* bus/driver.c: (bus_driver_handle_hello):
	* bus/driver.h:
	* bus/services.c: (bus_service_lookup):
	Reorder message sending so we get a more sane order.

	* test/bus-test.c: (message_handler):
	Fix tyop.
2003-02-13 21:37:58 +00:00
Anders Carlsson
aa4b4ef595 2003-02-13 Anders Carlsson <andersca@codefactory.se>
* 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):
	* dbus/dbus-bus.c: (dbus_bus_register_client),
	(dbus_bus_acquire_service), (dbus_bus_service_exists):
	* dbus/dbus-errors.c: (dbus_result_to_string):
	* dbus/dbus-errors.h:
	* dbus/dbus-message.c: (dbus_message_append_args),
	(dbus_message_append_args_valist), (dbus_message_get_args),
	(dbus_message_get_args_valist), (dbus_message_get_args_iter),
	(dbus_message_iter_get_arg_type), (dbus_message_iter_get_string),
	(dbus_message_iter_get_byte_array),
	(dbus_message_iter_get_string_array), (message_iter_test),
	(check_message_handling), (_dbus_message_test):
	* dbus/dbus-message.h:
	* test/bus-test.c: (main):
	Change fields to arguments in messages, so that they won't be
	confused with header fields.

	* glib/test-dbus-glib.c: (main):
	Remove append_fields from hello message.
2003-02-13 21:21:42 +00:00
Anders Carlsson
02dfd4fb34 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
Anders Carlsson
34e6c6ff31 2003-02-13 Anders Carlsson <andersca@codefactory.se>
* bus/driver.c: (bus_driver_send_welcome_message),
	(bus_driver_handle_list_services),
	(bus_driver_handle_acquire_service),
	(bus_driver_handle_service_exists), (bus_driver_handle_message):
	Update for API changes in libdbus.

	* dbus/dbus-message.c: (dbus_message_new_reply):
	* dbus/dbus-message.h:
	Remove the name argument. The spec states that replies shouldn't
	have a name.
2003-02-13 15:29:18 +00:00
Anders Carlsson
6d5d65dba6 2003-02-02 Anders Carlsson <set EMAIL_ADDRESS environment variable>
* bus/driver.c: (bus_driver_handle_service_exists):
	Simplify the code a bit.

	* dbus/dbus-bus.c: (dbus_bus_service_exists):
	Fix a silly.
2003-02-02 01:32:43 +00:00
James Willcox
ba60374e25 2003-02-01 James Willcox <jwillcox@gnome.org>
* bus/driver.c: (bus_driver_handle_own_service):
	Actually include the service reply code in the message.
2003-02-02 00:39:10 +00:00
Anders Carlsson
bfe3127d83 2003-02-02 Anders Carlsson <andersca@codefactory.se>
* bus/driver.c: (bus_driver_handle_service_exists):
	Don't unref the incoming message.
2003-02-02 00:29:56 +00:00
Anders Carlsson
dbc4c0ca13 2003-02-01 Anders Carlsson <andersca@codefactory.se>
* bus/driver.c: (create_unique_client_name),
	(bus_driver_handle_hello):
	Don't take a name, just use a numeric id to identify
	each client.

	* dbus/Makefile.am:
	* dbus/dbus-bus.c: (dbus_bus_register_client),
	(dbus_bus_acquire_service), (dbus_bus_service_exists):
	* dbus/dbus-bus.h:
	Add new convenience functions for communicating with the bus.

	* dbus/dbus-message.h:

	* dbus/dbus-protocol.h:
	Fix a typo.
2003-02-01 21:26:32 +00:00
Havoc Pennington
ca84a29217 2003-01-31 Havoc Pennington <hp@pobox.com>
* doc/dbus-specification.sgml: work on the specification

	* dbus/dbus-message.c (_dbus_message_loader_return_buffer): check
	the protocol version of the message.

	* dbus/dbus-protocol.h: drop special _REPLY names, the spec
	no longer specifies that.
	(DBUS_SERVICE_REPLY_SERVICE_EXISTS): fix flags (1/2/4/8 not
	1/2/3/4)

	* dbus/dbus-marshal.c (_dbus_marshal_get_arg_end_pos): add missing
	"break" for DBUS_TYPE_NIL, remove @todo
2003-02-01 00:08:32 +00:00
Anders Carlsson
ee1133de4d 2003-01-27 Anders Carlsson <andersca@codefactory.se>
* bus/dispatch.c: (bus_dispatch_message_handler):
	Dispatch messages sent to services.

	* bus/driver.c: (bus_driver_send_service_deleted),
	(bus_driver_send_service_created), (bus_driver_send_service_lost),
	(bus_driver_send_service_acquired):
	Add helper functions for sending service related messages.

	(bus_driver_send_welcome_message):
	Send HELLO_REPLY instead of WELCOME.

	(bus_driver_handle_list_services):
	Send LIST_SERVICES_REPLY instead of SERVICES.

	(bus_driver_handle_own_service),
	(bus_driver_handle_service_exists):
	New message handlers.

	(bus_driver_handle_message):
	Invoke new message handlers.

	(bus_driver_remove_connection):
	Don't remove any services here since that's done automatically
	by bus_service_remove_owner now.

	* bus/driver.h:
	New function signatures.

	* bus/services.c: (bus_service_add_owner):
	Send ServiceAcquired message if we're the only primary owner.

	(bus_service_remove_owner):
	Send ServiceAcquired/ServiceLost messages.

	(bus_service_set_prohibit_replacement),
	(bus_service_get_prohibit_replacement):
	Functions for setting prohibit replacement.

	(bus_service_has_owner):
	New function that checks if a connection is in the owner queue of
	a certain service.

	* bus/services.h:
	Add new function signatures.

	* dbus/dbus-list.c: (_dbus_list_test):
	Add tests for _dbus_list_remove_last and traversing the list backwards.

	* dbus/dbus-list.h:
	Fix a typo in _dbus_list_get_prev_link, if we're at the first element we can't
	go any further, so return NULL then.

	* dbus/dbus-protocol.h:
	Add new messages, service flags and service replies.
2003-01-27 11:20:55 +00:00
Havoc Pennington
50c25505f6 2003-01-26 Havoc Pennington <hp@pobox.com>
The unit tests pass, but otherwise untested.  If it breaks, the
	tests should have been better. ;-)

	* bus/driver.c (bus_driver_handle_hello): return if we disconnect
	the connection.

	* dbus/dbus-message.c: redo everything so we maintain
	message->header as the only copy of the various fields.
	This avoids the possibility of out-of-memory in some cases,
	for example dbus_message_lock() can't run out of memory anymore,
	and avoids extra copying. Figured I may as well go ahead and do
	this since it was busted for dbus_message_lock to not return
	failure on OOM, and dbus_message_write_header was totally
	unchecked for OOM. Also fixed some random other bugs.

	* dbus/dbus-marshal.c (_dbus_marshal_get_field_end_pos): verify
	that strings are nul-terminated. Also, end_pos can be equal
	to string length just not greater than, I think.
	(_dbus_marshal_set_int32): new function
	(_dbus_marshal_set_uint32): new function
	(_dbus_marshal_set_string): new function

	* dbus/dbus-connection.c (_dbus_connection_new_for_transport): fix
	a warning, init timeout_list to NULL
	(dbus_connection_send_message): don't use uninitialized variable
	"serial"

	* dbus/dbus-string.c (_dbus_string_replace_len): new function
2003-01-26 07:48:16 +00:00
Anders Carlsson
d5ad082fec 2003-01-26 Anders Carlsson <andersca@codefactory.se>
* bus/driver.c: (bus_driver_handle_hello),
	(bus_driver_send_welcome_message):
	Plug leaks
2003-01-26 01:34:22 +00:00
Anders Carlsson
39dd1fcee6 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
Havoc Pennington
a1a53c3242 2003-01-24 Havoc Pennington <hp@pobox.com>
* dbus/dbus-list.c (alloc_link): put a thread lock on the global
	list_pool

	* bus/driver.c (bus_driver_handle_list_services): fix a leak
	on OOM
2003-01-25 01:26:49 +00:00
Anders Carlsson
a16e83f45d 2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/connection.c: (bus_connection_foreach):
	* bus/connection.h:
	Add new bus_connection_foreach function.

	* bus/driver.c: (send_one_message), (bus_driver_broadcast_message):
	Add function that broadcasts a message to all clients.

	(bus_driver_send_service_created), (bus_driver_handle_hello),
	(bus_driver_send_welcome_message),
	(bus_driver_handle_list_services), (bus_driver_message_handler):
	Implement functions that take care of listing services, and notifying
	clients when new services are created.

	* bus/services.c: (bus_services_list):
	* bus/services.h:
	Add new function that returns an array of strings with the currently
	registered services.

	* glib/dbus-glib.h:
	* glib/dbus-gmain.c:
	Update copyright year.
2003-01-24 23:51:59 +00:00
Havoc Pennington
c414488fe6 2003-01-22 Havoc Pennington <hp@pobox.com>
* dbus/dbus-connection.c
	(dbus_connection_send_message_with_reply_and_block): add some @todo

	* bus/driver.c (bus_driver_add_connection): add a FIXME about memleak
2003-01-22 04:48:47 +00:00
Havoc Pennington
d6d50a2994 2003-01-21 Havoc Pennington <hp@pobox.com>
(patch untested because can't compile)

	* bus/driver.c (create_unique_client_name): make this function
	never recycle client names. Also, caller should initialize
	the DBusString.

	* dbus/dbus-sysdeps.c (_dbus_get_current_time): new function
2003-01-22 03:36:05 +00:00
Anders Carlsson
aff24a72c1 2003-01-21 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
	Add driver.[ch]

	* bus/connection.c: (connection_disconnect_handler):
	Remove the connection from the bus driver's list.

	(connection_watch_callback): Dispatch messages.

	(free_connection_data): Free connection name.

	(bus_connection_setup): Add connection to the bus driver's list.
	(bus_connection_remove_owned_service):
	(bus_connection_set_name), (bus_connection_get_name):
	Add functions for setting and getting the connection's name.

	* bus/connection.h:
	Add function headers.

	* bus/driver.c: (create_unique_client_name),
	(bus_driver_handle_hello_message),
	(bus_driver_send_welcome_message), (bus_driver_message_handler),
	(bus_driver_add_connection), (bus_driver_remove_connection):
	* bus/driver.h:
	* bus/main.c:
	* bus/services.c: (bus_service_free):
	* bus/services.h:
	New file that handles communication and registreation with the bus
	itself.
2003-01-21 12:42:33 +00:00