summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--dbus/Makefile.am6
-rw-r--r--dbus/dbus-bus.c1
-rw-r--r--dbus/dbus-connection-internal.h3
-rw-r--r--dbus/dbus-connection.c112
-rw-r--r--dbus/dbus-connection.h59
-rw-r--r--dbus/dbus-internals.h1
-rw-r--r--dbus/dbus-marshal.c105
-rw-r--r--dbus/dbus-marshal.h30
-rw-r--r--dbus/dbus-object-registry.c1399
-rw-r--r--dbus/dbus-object-registry.h57
-rw-r--r--dbus/dbus-object-tree.c27
-rw-r--r--dbus/dbus-object-tree.h3
-rw-r--r--dbus/dbus-object.c349
-rw-r--r--dbus/dbus-object.h90
-rw-r--r--dbus/dbus-objectid.c470
-rw-r--r--dbus/dbus-objectid.h75
-rw-r--r--dbus/dbus-protocol.h4
-rw-r--r--dbus/dbus-test.c18
-rw-r--r--dbus/dbus-test.h3
-rw-r--r--dbus/dbus-threads.c1
-rw-r--r--dbus/dbus.h4
-rw-r--r--glib/dbus-gproxy.c4
-rw-r--r--glib/dbus-gproxy.h4
24 files changed, 171 insertions, 2671 deletions
diff --git a/ChangeLog b/ChangeLog
index 30217379..6aa36760 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2003-08-28 Havoc Pennington <hp@pobox.com>
+
+ purge DBusObjectID
+
+ * dbus/dbus-connection.c: port to no ObjectID, create a
+ DBusObjectTree, rename ObjectTree to ObjectPath in public API
+
+ * dbus/dbus-connection.h (struct DBusObjectTreeVTable): delete
+ everything except UnregisterFunction and MessageFunction
+
+ * dbus/dbus-marshal.c: port away from DBusObjectID,
+ add DBUS_TYPE_OBJECT_PATH
+
+ * dbus/dbus-object-registry.[hc], dbus/dbus-object.[hc],
+ dbus/dbus-objectid.[hc]: remove these, we are moving to
+ path-based object IDs
+
2003-08-25 Havoc Pennington <hp@pobox.com>
Just noticed that dbus_message_test is hosed, I wonder when I
diff --git a/dbus/Makefile.am b/dbus/Makefile.am
index e59877e6..f8509cce 100644
--- a/dbus/Makefile.am
+++ b/dbus/Makefile.am
@@ -17,8 +17,6 @@ dbusinclude_HEADERS= \
dbus-memory.h \
dbus-message.h \
dbus-message-handler.h \
- dbus-object.h \
- dbus-objectid.h \
dbus-pending-call.h \
dbus-protocol.h \
dbus-server.h \
@@ -45,10 +43,6 @@ DBUS_LIB_SOURCES= \
dbus-message.c \
dbus-message-handler.c \
dbus-message-internal.h \
- dbus-object.c \
- dbus-objectid.c \
- dbus-object-registry.c \
- dbus-object-registry.h \
dbus-object-tree.c \
dbus-object-tree.h \
dbus-pending-call.c \
diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c
index 445606e2..89a2d12b 100644
--- a/dbus/dbus-bus.c
+++ b/dbus/dbus-bus.c
@@ -25,6 +25,7 @@
#include "dbus-bus.h"
#include "dbus-protocol.h"
#include "dbus-internals.h"
+#include "dbus-message.h"
#include <string.h>
/**
diff --git a/dbus/dbus-connection-internal.h b/dbus/dbus-connection-internal.h
index f26c92e6..93b1b4a3 100644
--- a/dbus/dbus-connection-internal.h
+++ b/dbus/dbus-connection-internal.h
@@ -86,8 +86,7 @@ void _dbus_message_handler_remove_connection (DBusMessageHandl
DBusHandlerResult _dbus_message_handler_handle_message (DBusMessageHandler *handler,
DBusConnection *connection,
DBusMessage *message);
-void _dbus_connection_init_id (DBusConnection *connection,
- DBusObjectID *id);
+
DBusPendingCall* _dbus_pending_call_new (DBusConnection *connection,
int timeout_milliseconds,
DBusTimeoutHandler timeout_handler);
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index 45bbb42d..0c384594 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -35,9 +35,9 @@
#include "dbus-threads.h"
#include "dbus-protocol.h"
#include "dbus-dataslot.h"
-#include "dbus-object-registry.h"
#include "dbus-string.h"
#include "dbus-pending-call.h"
+#include "dbus-object-tree.h"
#if 0
#define CONNECTION_LOCK(connection) do { \
@@ -179,7 +179,7 @@ struct DBusConnection
DBusList *link_cache; /**< A cache of linked list links to prevent contention
* for the global linked list mempool lock
*/
- DBusObjectRegistry *objects; /**< Objects registered with this connection */
+ DBusObjectTree *objects; /**< Object path handlers registered with this connection */
};
static void _dbus_connection_remove_timeout_locked (DBusConnection *connection,
@@ -775,7 +775,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport)
DBusList *disconnect_link;
DBusMessage *disconnect_message;
DBusCounter *outgoing_counter;
- DBusObjectRegistry *objects;
+ DBusObjectTree *objects;
watch_list = NULL;
connection = NULL;
@@ -839,7 +839,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport)
if (outgoing_counter == NULL)
goto error;
- objects = _dbus_object_registry_new (connection);
+ objects = _dbus_object_tree_new (connection);
if (objects == NULL)
goto error;
@@ -908,7 +908,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport)
_dbus_counter_unref (outgoing_counter);
if (objects)
- _dbus_object_registry_unref (objects);
+ _dbus_object_tree_unref (objects);
return NULL;
}
@@ -1048,25 +1048,6 @@ _dbus_connection_handle_watch (DBusWatch *watch,
return retval;
}
-/**
- * Get the server ID to be used in the object ID for an object
- * registered with this connection.
- *
- * @todo implement this function
- *
- * @param connection the connection.
- * @returns the portion of the object ID
- */
-void
-_dbus_connection_init_id (DBusConnection *connection,
- DBusObjectID *object_id)
-{
- /* FIXME */
- dbus_object_id_set_server_bits (object_id, 15);
- dbus_object_id_set_client_bits (object_id, 31);
- dbus_object_id_set_is_server_bit (object_id, FALSE);
-}
-
/** @} */
/**
@@ -1178,7 +1159,7 @@ _dbus_connection_last_unref (DBusConnection *connection)
_dbus_assert (!_dbus_transport_get_is_connected (connection->transport));
/* ---- We're going to call various application callbacks here, hope it doesn't break anything... */
- _dbus_object_registry_free_all_unlocked (connection->objects);
+ _dbus_object_tree_free_all_unlocked (connection->objects);
dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL);
dbus_connection_set_wakeup_main_function (connection, NULL, NULL, NULL);
@@ -1204,7 +1185,7 @@ _dbus_connection_last_unref (DBusConnection *connection)
link = next;
}
- _dbus_object_registry_unref (connection->objects);
+ _dbus_object_tree_unref (connection->objects);
_dbus_hash_table_unref (connection->pending_replies);
connection->pending_replies = NULL;
@@ -2547,8 +2528,8 @@ dbus_connection_dispatch (DBusConnection *connection)
dbus_message_get_interface (message) :
"no interface");
- result = _dbus_object_registry_handle_and_unlock (connection->objects,
- message);
+ result = _dbus_object_tree_dispatch_and_unlock (connection->objects,
+ message);
CONNECTION_LOCK (connection);
@@ -3026,67 +3007,58 @@ dbus_connection_remove_filter (DBusConnection *connection,
}
/**
- * Registers an object with the connection. This object is assigned an
- * object ID, and will be visible under this ID and with the provided
- * interfaces to the peer application on the other end of the
- * connection. The object instance should be passed in as object_impl;
- * the instance can be any datatype, as long as it fits in a void*.
+ * Registers a handler for a given subsection of the object hierarchy.
+ * The given vtable handles messages at or below the given path.
*
- * As a side effect of calling this function, the "registered"
- * callback in the #DBusObjectVTable will be invoked.
- *
- * If the object is deleted, be sure to unregister it with
- * dbus_connection_unregister_object() or it will continue to get
- * messages.
*
- * @param connection the connection to register the instance with
- * @param interfaces #NULL-terminated array of interface names the instance supports
- * @param vtable virtual table of functions for manipulating the instance
- * @param object_impl object instance
- * @param object_id if non-#NULL, object ID to initialize with the new object's ID
- * @returns #FALSE if not enough memory to register the object instance
+ * @param connection the connection
+ * @param path #NULL-terminated array of path elements
+ * @param vtable the virtual table
+ * @param user_data data to pass to functions in the vtable
+ * @returns #FALSE if not enough memory
*/
dbus_bool_t
-dbus_connection_register_object (DBusConnection *connection,
- const char **interfaces,
- const DBusObjectVTable *vtable,
- void *object_impl,
- DBusObjectID *object_id)
+dbus_connection_register_object_path (DBusConnection *connection,
+ const char **path,
+ const DBusObjectPathVTable *vtable,
+ void *user_data)
{
+ dbus_bool_t retval;
+
_dbus_return_val_if_fail (connection != NULL, FALSE);
+ _dbus_return_val_if_fail (path != NULL, FALSE);
+ _dbus_return_val_if_fail (path[0] != NULL, FALSE);
_dbus_return_val_if_fail (vtable != NULL, FALSE);
- _dbus_return_val_if_fail (vtable->dbus_internal_pad1 == NULL, FALSE);
- _dbus_return_val_if_fail (vtable->dbus_internal_pad2 == NULL, FALSE);
- _dbus_return_val_if_fail (vtable->dbus_internal_pad3 == NULL, FALSE);
-
+
CONNECTION_LOCK (connection);
- return _dbus_object_registry_add_and_unlock (connection->objects,
- interfaces,
- vtable,
- object_impl,
- object_id);
+ retval = _dbus_object_tree_register (connection->objects, path, vtable,
+ user_data);
+
+ CONNECTION_UNLOCK (connection);
+
+ return retval;
}
/**
- * Reverses the effects of dbus_connection_register_object(),
- * and invokes the "unregistered" callback in the #DBusObjectVTable
- * for the given object. The passed-in object ID must be a valid,
- * registered object ID or the results are undefined.
+ * Unregisters the handler registered with exactly the given path.
+ * It's a bug to call this function for a path that isn't registered.
*
- * @param connection the connection to unregister the object ID from
- * @param object_id the object ID to unregister
+ * @param connection the connection
+ * @param path the #NULL-terminated array of path elements
*/
void
-dbus_connection_unregister_object (DBusConnection *connection,
- const DBusObjectID *object_id)
+dbus_connection_unregister_object_path (DBusConnection *connection,
+ const char **path)
{
- _dbus_return_if_fail (connection != NULL);
+ _dbus_return_if_fail (connection != NULL);
+ _dbus_return_if_fail (path != NULL);
+ _dbus_return_if_fail (path[0] != NULL);
CONNECTION_LOCK (connection);
- return _dbus_object_registry_remove_and_unlock (connection->objects,
- object_id);
+ return _dbus_object_tree_unregister_and_unlock (connection->objects,
+ path);
}
static DBusDataSlotAllocator slot_allocator;
diff --git a/dbus/dbus-connection.h b/dbus/dbus-connection.h
index 7204c8ed..12ad0682 100644
--- a/dbus/dbus-connection.h
+++ b/dbus/dbus-connection.h
@@ -1,7 +1,7 @@
/* -*- mode: C; c-file-style: "gnu" -*- */
/* dbus-connection.h DBusConnection object
*
- * Copyright (C) 2002 Red Hat Inc.
+ * Copyright (C) 2002, 2003 Red Hat Inc.
*
* Licensed under the Academic Free License version 1.2
*
@@ -29,7 +29,7 @@
#include <dbus/dbus-errors.h>
#include <dbus/dbus-memory.h>
-#include <dbus/dbus-object.h>
+#include <dbus/dbus-message.h>
DBUS_BEGIN_DECLS;
@@ -38,6 +38,8 @@ typedef struct DBusTimeout DBusTimeout;
typedef struct DBusMessageHandler DBusMessageHandler;
typedef struct DBusPreallocatedSend DBusPreallocatedSend;
typedef struct DBusPendingCall DBusPendingCall;
+typedef struct DBusConnection DBusConnection;
+typedef struct DBusObjectPathVTable DBusObjectPathVTable;
typedef enum
{
@@ -57,6 +59,13 @@ typedef enum
DBUS_DISPATCH_NEED_MEMORY /**< More memory is needed to continue. */
} DBusDispatchStatus;
+typedef enum
+{
+ DBUS_HANDLER_RESULT_HANDLED, /**< Message has had its effect */
+ DBUS_HANDLER_RESULT_NOT_YET_HANDLED, /**< Message has not had any effect */
+ DBUS_HANDLER_RESULT_NEED_MEMORY /**< Need more memory to return another result */
+} DBusHandlerResult;
+
typedef dbus_bool_t (* DBusAddWatchFunction) (DBusWatch *watch,
void *data);
typedef void (* DBusWatchToggledFunction) (DBusWatch *watch,
@@ -159,16 +168,6 @@ dbus_bool_t dbus_connection_add_filter (DBusConnection *connection,
void dbus_connection_remove_filter (DBusConnection *connection,
DBusMessageHandler *handler);
-/* Objects */
-dbus_bool_t dbus_connection_register_object (DBusConnection *connection,
- const char **interfaces,
- const DBusObjectVTable *vtable,
- void *object_impl,
- DBusObjectID *object_id);
-void dbus_connection_unregister_object (DBusConnection *connection,
- const DBusObjectID *object_id);
-
-
/* Other */
dbus_bool_t dbus_connection_allocate_data_slot (dbus_int32_t *slot_p);
void dbus_connection_free_data_slot (dbus_int32_t *slot_p);
@@ -200,37 +199,17 @@ void dbus_connection_send_preallocated (DBusConnection
/* Object tree functionality */
-typedef struct DBusObjectTreeVTable DBusObjectTreeVTable;
-
-typedef void (* DBusObjectTreeUnregisterFunction) (DBusConnection *connection,
+typedef void (* DBusObjectPathUnregisterFunction) (DBusConnection *connection,
const char **path,
void *user_data);
-typedef DBusHandlerResult (* DBusObjectTreeMessageFunction) (DBusConnection *connection,
+typedef DBusHandlerResult (* DBusObjectPathMessageFunction) (DBusConnection *connection,
DBusMessage *message,
void *user_data);
-typedef dbus_bool_t (* DBusObjectTreeSubdirsFunction) (DBusConnection *connection,
- const char **path,
- char ***subdirs,
- int *n_subdirs,
- void *user_data);
-typedef dbus_bool_t (* DBusObjectTreeObjectsFunction) (DBusConnection *connection,
- const char **path,
- DBusObjectID **object_ids,
- int *n_object_ids,
- void *user_data);
-typedef dbus_bool_t (* DBusObjectTreeMethodsFunction) (DBusConnection *connection,
- const char **path,
- DBusObjectID **object_ids,
- int *n_object_ids,
- void *user_data);
-struct DBusObjectTreeVTable
+struct DBusObjectPathVTable
{
- DBusObjectTreeUnregisterFunction unregister_function;
- DBusObjectTreeMessageFunction message_function;
- DBusObjectTreeSubdirsFunction subdirs_function;
- DBusObjectTreeObjectsFunction objects_function;
- DBusObjectTreeMethodsFunction methods_function;
+ DBusObjectPathUnregisterFunction unregister_function;
+ DBusObjectPathMessageFunction message_function;
void (* dbus_internal_pad1) (void *);
void (* dbus_internal_pad2) (void *);
@@ -238,11 +217,11 @@ struct DBusObjectTreeVTable
void (* dbus_internal_pad4) (void *);
};
-dbus_bool_t dbus_connection_register_object_tree (DBusConnection *connection,
+dbus_bool_t dbus_connection_register_object_path (DBusConnection *connection,
const char **path,
- const DBusObjectTreeVTable *vtable,
+ const DBusObjectPathVTable *vtable,
void *user_data);
-void dbus_connection_unregister_object_tree (DBusConnection *connection,
+void dbus_connection_unregister_object_path (DBusConnection *connection,
const char **path);
diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h
index 6d120f1b..1c0f7314 100644
--- a/dbus/dbus-internals.h
+++ b/dbus/dbus-internals.h
@@ -234,7 +234,6 @@ _DBUS_DECLARE_GLOBAL_LOCK (server_slots);
_DBUS_DECLARE_GLOBAL_LOCK (message_slots);
_DBUS_DECLARE_GLOBAL_LOCK (atomic);
_DBUS_DECLARE_GLOBAL_LOCK (message_handler);
-_DBUS_DECLARE_GLOBAL_LOCK (callback_object);
_DBUS_DECLARE_GLOBAL_LOCK (bus);
_DBUS_DECLARE_GLOBAL_LOCK (shutdown_funcs);
_DBUS_DECLARE_GLOBAL_LOCK (system_users);
diff --git a/dbus/dbus-marshal.c b/dbus/dbus-marshal.c
index aaf97c7c..449dd33a 100644
--- a/dbus/dbus-marshal.c
+++ b/dbus/dbus-marshal.c
@@ -80,7 +80,6 @@ typedef union
dbus_uint64_t u;
#endif
double d;
- DBusObjectID object_id;
} DBusOctets8;
static DBusOctets8
@@ -426,26 +425,27 @@ _dbus_marshal_set_string (DBusString *str,
}
/**
- * Sets the existing marshaled object ID at the given offset to a new
- * value. The given offset must point to an existing object ID or this
+ * Sets the existing marshaled object path at the given offset to a new
+ * value. The given offset must point to an existing object path or this
* function doesn't make sense.
*
- * @param str the string to write the marshalled string to
- * @param offset the byte offset where string should be written
+ * @todo implement this function
+ *
+ * @param str the string to write the marshalled path to
+ * @param offset the byte offset where path should be written
* @param byte_order the byte order to use
- * @param value the new value
+ * @param path the new path
+ * @param path_len number of elements in the path
*/
void
-_dbus_marshal_set_object_id (DBusString *str,
- int byte_order,
- int offset,
- const DBusObjectID *value)
+_dbus_marshal_set_object_path (DBusString *str,
+ int byte_order,
+ int offset,
+ const char **path,
+ int path_len)
{
- DBusOctets8 r;
-
- r.object_id = *value;
-
- set_8_octets (str, byte_order, offset, r);
+
+ /* FIXME */
}
static dbus_bool_t
@@ -870,23 +870,23 @@ _dbus_marshal_string_array (DBusString *str,
}
/**
- * Marshals an object ID value.
+ * Marshals an object path value.
*
+ * @todo implement this function
+ *
* @param str the string to append the marshalled value to
* @param byte_order the byte order to use
- * @param value the value
+ * @param path the path
+ * @param path_len length of the path
* @returns #TRUE on success
*/
dbus_bool_t
-_dbus_marshal_object_id (DBusString *str,
- int byte_order,
- const DBusObjectID *value)
+_dbus_marshal_object_path (DBusString *str,
+ int byte_order,
+ const char **path,
+ int path_len)
{
- DBusOctets8 r;
-
- r.object_id = *value;
-
- return marshal_8_octets (str, byte_order, r);
+ return TRUE;
}
static dbus_uint32_t
@@ -1439,26 +1439,26 @@ _dbus_demarshal_string_array (const DBusString *str,
}
/**
- * Demarshals an object ID.
+ * Demarshals an object path.
*
+ * @todo implement this function
+ *
* @param str the string containing the data
* @param byte_order the byte order
* @param pos the position in the string
* @param new_pos the new position of the string
- * @param value address to store new object ID
+ * @param path address to store new object path
+ * @param path_len length of stored path
*/
-void
-_dbus_demarshal_object_id (const DBusString *str,
- int byte_order,
- int pos,
- int *new_pos,
- DBusObjectID *value)
+dbus_bool_t
+_dbus_demarshal_object_path (const DBusString *str,
+ int byte_order,
+ int pos,
+ int *new_pos,
+ char ***path,
+ int *path_len)
{
- DBusOctets8 r;
-
- r = demarshal_8_octets (str, byte_order, pos, new_pos);
-
- *value = r.object_id;
+
}
/**
@@ -1509,7 +1509,6 @@ _dbus_marshal_get_arg_end_pos (const DBusString *str,
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
- case DBUS_TYPE_OBJECT_ID:
case DBUS_TYPE_DOUBLE:
*end_pos = _DBUS_ALIGN_VALUE (pos, 8) + 8;
@@ -1541,7 +1540,8 @@ _dbus_marshal_get_arg_end_pos (const DBusString *str,
*end_pos = pos + len;
}
break;
-
+
+ case DBUS_TYPE_OBJECT_PATH:
case DBUS_TYPE_ARRAY:
{
int len;
@@ -1718,6 +1718,7 @@ validate_array_data (const DBusString *str,
case DBUS_TYPE_NIL:
break;
+ case DBUS_TYPE_OBJECT_PATH:
case DBUS_TYPE_STRING:
case DBUS_TYPE_NAMED:
case DBUS_TYPE_ARRAY:
@@ -1771,7 +1772,6 @@ validate_array_data (const DBusString *str,
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
case DBUS_TYPE_DOUBLE:
- case DBUS_TYPE_OBJECT_ID:
/* Call validate arg one time to check alignment padding
* at start of array
*/
@@ -1802,7 +1802,9 @@ validate_array_data (const DBusString *str,
*
* @todo For array types that can't be invalid, we should not
* walk the whole array validating it. e.g. just skip all the
- * int values in an int array.
+ * int values in an int array. (maybe this is already done now -hp)
+ *
+ * @todo support DBUS_TYPE_OBJECT_PATH
*
* @param str a string
* @param byte_order the byte order to use
@@ -1899,7 +1901,6 @@ _dbus_marshal_validate_arg (const DBusString *str,
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
case DBUS_TYPE_DOUBLE:
- case DBUS_TYPE_OBJECT_ID:
{
int align_8 = _DBUS_ALIGN_VALUE (pos, 8);
@@ -2219,7 +2220,6 @@ _dbus_marshal_test (void)
#endif
char *s;
DBusString t;
- DBusObjectID obj_id, obj_id2;
if (!_dbus_string_init (&str))
_dbus_assert_not_reached ("failed to init string");
@@ -2280,23 +2280,6 @@ _dbus_marshal_test (void)
if (!(_dbus_demarshal_uint64 (&str, DBUS_LITTLE_ENDIAN, pos, &pos) == DBUS_UINT64_CONSTANT (0x123456789abc7)))
_dbus_assert_not_reached ("demarshal failed");
#endif /* DBUS_HAVE_INT64 */
-
- /* Marshal object IDs */
- dbus_object_id_set_server_bits (&obj_id, 0xfffe);
- dbus_object_id_set_client_bits (&obj_id, 0xaacc);
- dbus_object_id_set_instance_bits (&obj_id, 0x70f00f0f);
-
- if (!_dbus_marshal_object_id (&str, DBUS_BIG_ENDIAN, &obj_id))
- _dbus_assert_not_reached ("could not marshal object ID value");
- _dbus_demarshal_object_id (&str, DBUS_BIG_ENDIAN, pos, &pos, &obj_id2);
- if (!dbus_object_id_equal (&obj_id, &obj_id2))
- _dbus_assert_not_reached ("demarshal failed");
-
- if (!_dbus_marshal_object_id (&str, DBUS_LITTLE_ENDIAN, &obj_id))
- _dbus_assert_not_reached ("could not marshal object ID value");
- _dbus_demarshal_object_id (&str, DBUS_LITTLE_ENDIAN, pos, &pos, &obj_id2);
- if (!dbus_object_id_equal (&obj_id, &obj_id2))
- _dbus_assert_not_reached ("demarshal failed");
/* Marshal strings */
tmp1 = "This is the dbus test string";
diff --git a/dbus/dbus-marshal.h b/dbus/dbus-marshal.h
index af18876a..27ded007 100644
--- a/dbus/dbus-marshal.h
+++ b/dbus/dbus-marshal.h
@@ -29,7 +29,6 @@
#include <dbus/dbus-types.h>
#include <dbus/dbus-arch-deps.h>
#include <dbus/dbus-string.h>
-#include <dbus/dbus-objectid.h>
#ifndef PACKAGE
#error "config.h not included here"
@@ -154,15 +153,16 @@ void _dbus_marshal_set_uint64 (DBusString *str,
dbus_uint64_t value);
#endif /* DBUS_HAVE_INT64 */
-dbus_bool_t _dbus_marshal_set_string (DBusString *str,
- int byte_order,
- int offset,
- const DBusString *value,
- int len);
-void _dbus_marshal_set_object_id (DBusString *str,
- int byte_order,
- int offset,
- const DBusObjectID *value);
+dbus_bool_t _dbus_marshal_set_string (DBusString *str,
+ int byte_order,
+ int offset,
+ const DBusString *value,
+ int len);
+void _dbus_marshal_set_object_path (DBusString *str,
+ int byte_order,
+ int offset,
+ const char **path,
+ int path_len);
dbus_bool_t _dbus_marshal_int32 (DBusString *str,
int byte_order,
@@ -214,9 +214,10 @@ dbus_bool_t _dbus_marshal_string_array (DBusString *str,
int byte_order,
const char **value,
int len);
-dbus_bool_t _dbus_marshal_object_id (DBusString *str,
+dbus_bool_t _dbus_marshal_object_path (DBusString *str,
int byte_order,
- const DBusObjectID *value);
+ const char **path,
+ int path_len);
double _dbus_demarshal_double (const DBusString *str,
int byte_order,
@@ -288,11 +289,12 @@ dbus_bool_t _dbus_demarshal_string_array (const DBusString *str,
int *new_pos,
char ***array,
int *array_len);
-void _dbus_demarshal_object_id (const DBusString *str,
+dbus_bool_t _dbus_demarshal_object_path (const DBusString *str,
int byte_order,
int pos,
int *new_pos,
- DBusObjectID *value);
+ char ***path,
+ int *path_len);
dbus_bool_t _dbus_marshal_get_arg_end_pos (const DBusString *str,
int byte_order,
diff --git a/dbus/dbus-object-registry.c b/dbus/dbus-object-registry.c
deleted file mode 100644
index e5a81315..00000000
--- a/dbus/dbus-object-registry.c
+++ /dev/null
@@ -1,1399 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-object-registry.c DBusObjectRegistry (internals of DBusConnection)
- *
- * Copyright (C) 2003 Red Hat Inc.
- *
- * Licensed under the Academic Free License version 1.2
- *
- * 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
- *
- */
-#include "dbus-object-registry.h"
-#include "dbus-connection-internal.h"
-#include "dbus-internals.h"
-#include "dbus-hash.h"
-#include "dbus-protocol.h"
-#include <string.h>
-
-/**
- * @defgroup DBusObjectRegistry Map object IDs to implementations
- * @ingroup DBusInternals
- * @brief DBusObjectRegistry is used by DBusConnection to track object IDs
- *
- * Types and functions related to DBusObjectRegistry. These
- * are all internal.
- *
- * @todo interface entries and signal connections are handled pretty
- * much identically, with lots of duplicate code. Once we're sure
- * they will always be the same, we could merge this code.
- *
- * @{
- */
-
-typedef struct DBusObjectEntry DBusObjectEntry;
-typedef struct DBusInterfaceEntry DBusInterfaceEntry;
-typedef struct DBusSignalEntry DBusSignalEntry;
-
-#define DBUS_MAX_OBJECTS_PER_INTERFACE 65535
-struct DBusInterfaceEntry
-{
- unsigned int n_objects : 16; /**< Number of objects with this interface */
- unsigned int n_allocated : 16; /**< Allocated size of objects array */
- dbus_uint16_t *objects; /**< Index of each object with the interface */
- char name[4]; /**< Name of interface (actually allocated larger) */
-};
-
-#define DBUS_MAX_CONNECTIONS_PER_SIGNAL 65535
-struct DBusSignalEntry
-{
- unsigned int n_connections : 16; /**< Number of connections to this signal */
- unsigned int n_allocated : 16; /**< Allocated size of objects array */
- dbus_uint16_t *connections; /**< Index of each object connected (can have dups for multiple
- * connections)
- */
- char name[4]; /**< Interface of signal, nul, then name of signal (actually allocated larger) */
-};
-
- /* 14 bits for object index, 32K objects */
-#define DBUS_OBJECT_INDEX_BITS (14)
-#define DBUS_OBJECT_INDEX_MASK (0x3fff)
-#define DBUS_MAX_OBJECTS_PER_CONNECTION DBUS_OBJECT_INDEX_MASK
-struct DBusObjectEntry
-{
- unsigned int id_index : 14; /**< Index of this entry in the entries array */
- unsigned int id_times_used : 18; /**< Count of times entry has been used; avoids recycling IDs too often */
-
- void *object_impl; /**< Pointer to application-supplied implementation */
- const DBusObjectVTable *vtable; /**< Virtual table for this object */
- DBusInterfaceEntry **interfaces; /**< NULL-terminated list of interfaces */
- DBusSignalEntry **signals; /**< Signal connections (contains dups, one each time we connect) */
-};
-
-struct DBusObjectRegistry
-{
- int refcount;
- DBusConnection *connection;
-
- DBusObjectEntry *entries;
- int n_entries_allocated;
- int n_entries_used;
-
- DBusHashTable *interface_table;
-
- DBusHashTable *signal_table;
-};
-
-static void
-free_interface_entry (void *entry)
-{
- DBusInterfaceEntry *iface = entry;
-
- if (iface == NULL) /* DBusHashTable stupidity */
- return;
-
- dbus_free (iface->objects);
- dbus_free (iface);
-}
-
-static void
-free_signal_entry (void *entry)
-{
- DBusSignalEntry *signal = entry;
-
- if (signal == NULL) /* DBusHashTable stupidity */
- return;
-
- dbus_free (signal->connections);
- dbus_free (signal);
-}
-
-DBusObjectRegistry*
-_dbus_object_registry_new (DBusConnection *connection)
-{
- DBusObjectRegistry *registry;
- DBusHashTable *interface_table;
- DBusHashTable *signal_table;
-
- /* the connection passed in here isn't fully constructed,
- * so don't do anything more than store a pointer to
- * it
- */
-
- registry = NULL;
- interface_table = NULL;
- signal_table = NULL;
-
- registry = dbus_new0 (DBusObjectRegistry, 1);
- if (registry == NULL)
- goto oom;
-
- interface_table = _dbus_hash_table_new (DBUS_HASH_STRING,
- NULL, free_interface_entry);
- if (interface_table == NULL)
- goto oom;
-
- signal_table = _dbus_hash_table_new (DBUS_HASH_TWO_STRINGS,
- NULL, free_signal_entry);
- if (signal_table == NULL)
- goto oom;
-
- registry->refcount = 1;
- registry->connection = connection;
- registry->interface_table = interface_table;
- registry->signal_table = signal_table;
-
- return registry;
-
- oom:
- if (registry)
- dbus_free (registry);
- if (interface_table)
- _dbus_hash_table_unref (interface_table);
- if (signal_table)
- _dbus_hash_table_unref (signal_table);
-
- return NULL;
-}
-
-void
-_dbus_object_registry_ref (DBusObjectRegistry *registry)
-{
- _dbus_assert (registry->refcount > 0);
-
- registry->refcount += 1;
-}
-
-void
-_dbus_object_registry_unref (DBusObjectRegistry *registry)
-{
- _dbus_assert (registry->refcount > 0);
-
- registry->refcount -= 1;
-
- if (registry->refcount == 0)
- {
- int i;
-
- _dbus_assert (registry->n_entries_used == 0);
- _dbus_assert (_dbus_hash_table_get_n_entries (registry->interface_table) == 0);
- _dbus_assert (_dbus_hash_table_get_n_entries (registry->signal_table) == 0);
-
- i = 0;
- while (i < registry->n_entries_allocated)
- {
- if (registry->entries[i].interfaces)
- dbus_free (registry->entries[i].interfaces);
- if (registry->entries[i].signals)
- dbus_free (registry->entries[i].signals);
- ++i;
- }
-
- _dbus_hash_table_unref (registry->interface_table);
- _dbus_hash_table_unref (registry->signal_table);
- dbus_free (registry->entries);
- dbus_free (registry);
- }
-}
-
-#define ENTRY_TO_ID(entry) \
- (((dbus_uint32_t) (entry)->id_index) | \
- (((dbus_uint32_t)(entry)->id_times_used) << DBUS_OBJECT_INDEX_BITS))
-
-#define ID_TO_INDEX(id) \
- (((dbus_uint32_t) (id)) & DBUS_OBJECT_INDEX_MASK)
-
-#define ID_TO_TIMES_USED(id) \
- (((dbus_uint32_t) (id)) >> DBUS_OBJECT_INDEX_BITS)
-
-static DBusObjectEntry*
-validate_id (DBusObjectRegistry *registry,
- const DBusObjectID *object_id)
-{
- int idx;
- int times_used;
- dbus_uint32_t instance_bits;
-
- instance_bits = dbus_object_id_get_instance_bits (object_id);
-
- /* Verify that connection ID bits are the same */
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- {
- DBusObjectID tmp_id;
-
- _dbus_connection_init_id (registry->connection,
- &tmp_id);
- dbus_object_id_set_instance_bits (&tmp_id, instance_bits);
-
- if (!dbus_object_id_equal (&tmp_id, object_id))
- return NULL;
- }
-
- idx = ID_TO_INDEX (instance_bits);
- times_used = ID_TO_TIMES_USED (instance_bits);
-
- if (idx >= registry->n_entries_allocated)
- return NULL;
- if (registry->entries[idx].vtable == NULL)
- return NULL;
- if (registry->entries[idx].id_times_used != times_used)
- return NULL;
- _dbus_assert (registry->entries[idx].id_index == idx);
- _dbus_assert (registry->n_entries_used > 0);
-
- return &registry->entries[idx];
-}
-
-static void
-id_from_entry (DBusObjectRegistry *registry,
- DBusObjectID *object_id,
- DBusObjectEntry *entry)
-{
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_init_id (registry->connection,
- object_id);
-#ifdef DBUS_BUILD_TESTS
- else
- {
- dbus_object_id_set_server_bits (object_id, 1);
- dbus_object_id_set_client_bits (object_id, 2);
- }
-#endif
-
- _dbus_assert (dbus_object_id_get_server_bits (object_id) != 0);
- _dbus_assert (dbus_object_id_get_client_bits (object_id) != 0);
-
- dbus_object_id_set_instance_bits (object_id,
- ENTRY_TO_ID (entry));
-
- _dbus_assert (dbus_object_id_get_instance_bits (object_id) != 0);
-}
-
-static void
-info_from_entry (DBusObjectRegistry *registry,
- DBusObjectInfo *info,
- DBusObjectEntry *entry)
-{
- info->connection = registry->connection;
- info->object_impl = entry->object_impl;
-
- id_from_entry (registry, &info->object_id, entry);
-}
-
-static DBusInterfaceEntry*
-lookup_interface (DBusObjectRegistry *registry,
- const char *name,
- dbus_bool_t create_if_not_found)
-{
- DBusInterfaceEntry *entry;
- int sz;
- int len;
-
- entry = _dbus_hash_table_lookup_string (registry->interface_table,
- name);
- if (entry != NULL || !create_if_not_found)
- return entry;
-
- _dbus_assert (create_if_not_found);
-
- len = strlen (name);
- sz = _DBUS_STRUCT_OFFSET (DBusInterfaceEntry, name) + len + 1;
- entry = dbus_malloc (sz);
- if (entry == NULL)
- return NULL;
- entry->n_objects = 0;
- entry->n_allocated = 0;
- entry->objects = NULL;
- memcpy (entry->name, name, len + 1);
-
- if (!_dbus_hash_table_insert_string (registry->interface_table,
- entry->name, entry))
- {
- dbus_free (entry);
- return NULL;
- }
-
- return entry;
-}
-
-static void
-delete_interface (DBusObjectRegistry *registry,
- DBusInterfaceEntry *entry)
-{
- _dbus_hash_table_remove_string (registry->interface_table,
- entry->name);
-}
-
-static dbus_bool_t
-interface_entry_add_object (DBusInterfaceEntry *entry,
- dbus_uint16_t object_index)
-{
- if (entry->n_objects == entry->n_allocated)
- {
- unsigned int new_alloc;
- dbus_uint16_t *new_objects;
-
- if (entry->n_allocated == 0)
- new_alloc = 2;
- else
- new_alloc = entry->n_allocated * 2;
-
- /* Right now MAX_OBJECTS_PER_INTERFACE can't possibly be reached
- * since the max number of objects _total_ is smaller, but the
- * code is here for future robustness.
- */
-
- if (new_alloc > DBUS_MAX_OBJECTS_PER_INTERFACE)
- new_alloc = DBUS_MAX_OBJECTS_PER_INTERFACE;
- if (new_alloc == entry->n_allocated)
- {
- _dbus_warn ("Attempting to register another instance with interface %s, but max count %d reached\n",
- entry->name, DBUS_MAX_OBJECTS_PER_INTERFACE);
- return FALSE;
- }
-
- new_objects = dbus_realloc (entry->objects, new_alloc * sizeof (dbus_uint16_t));
- if (new_objects == NULL)
- return FALSE;
- entry->objects = new_objects;
- entry->n_allocated = new_alloc;
- }
-
- _dbus_assert (entry->n_objects < entry->n_allocated);
-
- entry->objects[entry->n_objects] = object_index;
- entry->n_objects += 1;
-
- return TRUE;
-}
-
-static void
-interface_entry_remove_object (DBusInterfaceEntry *entry,
- dbus_uint16_t object_index)
-{
- unsigned int i;
-
- i = 0;
- while (i < entry->n_objects)
- {
- if (entry->objects[i] == object_index)
- break;
- ++i;
- }
-
- if (i == entry->n_objects)
- {
- _dbus_assert_not_reached ("Tried to remove object from an interface that didn't list that object\n");
- return;
- }
-
- memmove (&entry->objects[i],
- &entry->objects[i+1],
- (entry->n_objects - i - 1) * sizeof (entry->objects[0]));
- entry->n_objects -= 1;
-}
-
-static void
-object_remove_from_interfaces (DBusObjectRegistry *registry,
- DBusObjectEntry *entry)
-{
- if (entry->interfaces != NULL)
- {
- int i;
-
- i = 0;
- while (entry->interfaces[i] != NULL)
- {
- DBusInterfaceEntry *iface = entry->interfaces[i];
-
- interface_entry_remove_object (iface, entry->id_index);
- if (iface->n_objects == 0)
- delete_interface (registry, iface);
- ++i;
- }
- }
-}
-
-static DBusSignalEntry*
-lookup_signal (DBusObjectRegistry *registry,
- const char *signal_interface,
- const char *signal_name,
- dbus_bool_t create_if_not_found)
-{
- DBusSignalEntry *entry;
- int sz;
- size_t len_interface, len_name;
- char buf[2 * DBUS_MAXIMUM_NAME_LENGTH + 2];
-
- /* This is all a little scary and maybe we shouldn't jump
- * through these hoops just to save some bytes.
- */
-
- len_interface = strlen (signal_interface);
- len_name = strlen (signal_name);
-
- _dbus_assert (len_interface + len_name + 2 <= sizeof (buf));
-
- memcpy (buf, signal_interface, len_interface + 1);
- memcpy (buf + len_interface + 1, signal_name, len_name + 1);
-
- entry = _dbus_hash_table_lookup_two_strings (registry->signal_table,
- buf);
- if (entry != NULL || !create_if_not_found)
- return entry;
-
- _dbus_assert (create_if_not_found);
-
- sz = _DBUS_STRUCT_OFFSET (DBusSignalEntry, name) + len_interface + len_name + 2;
- entry = dbus_malloc (sz);
- if (entry == NULL)
- return NULL;
- entry->n_connections = 0;
- entry->n_allocated = 0;
- entry->connections = NULL;
- memcpy (entry->name, buf, len_interface + len_name + 2);
-
- if (!_dbus_hash_table_insert_two_strings (registry->signal_table,
- entry->name, entry))
- {
- dbus_free (entry);
- return NULL;
- }
-
- return entry;
-}
-
-static void
-delete_signal (DBusObjectRegistry *registry,
- DBusSignalEntry *entry)
-{
- _dbus_hash_table_remove_two_strings (registry->signal_table,
- entry->name);
-}
-
-static dbus_bool_t
-signal_entry_add_object (DBusSignalEntry *entry,
- dbus_uint16_t object_index)
-{
- if (entry->n_connections == entry->n_allocated)
- {
- unsigned int new_alloc;
- dbus_uint16_t *new_objects;
-
- if (entry->n_allocated == 0)
- new_alloc = 2;
- else
- new_alloc = entry->n_allocated * 2;
-
- /* Right now MAX_CONNECTIONS_PER_SIGNAL can't possibly be reached
- * since the max number of objects _total_ is smaller, but the
- * code is here for future robustness.
- */
-
- if (new_alloc > DBUS_MAX_CONNECTIONS_PER_SIGNAL)
- new_alloc = DBUS_MAX_CONNECTIONS_PER_SIGNAL;
- if (new_alloc == entry->n_allocated)
- {
- _dbus_warn ("Attempting to register another instance with signal %s, but max count %d reached\n",
- entry->name, DBUS_MAX_CONNECTIONS_PER_SIGNAL);
- return FALSE;
- }
-
- new_objects = dbus_realloc (entry->connections, new_alloc * sizeof (dbus_uint16_t));
- if (new_objects == NULL)
- return FALSE;
- entry->connections = new_objects;
- entry->n_allocated = new_alloc;
- }
-
- _dbus_assert (entry->n_connections < entry->n_allocated);
-
- entry->connections[entry->n_connections] = object_index;
- entry->n_connections += 1;
-
- return TRUE;
-}
-
-static void
-signal_entry_remove_object (DBusSignalEntry *entry,
- dbus_uint16_t object_index)
-{
- unsigned int i;
-
- i = 0;
- while (i < entry->n_connections)
- {
- if (entry->connections[i] == object_index)
- break;
- ++i;
- }
-
- if (i == entry->n_connections)
- {
- _dbus_assert_not_reached ("Tried to remove object from an signal that didn't list that object\n");
- return;
- }
-
- memmove (&entry->connections[i],
- &entry->connections[i+1],
- (entry->n_connections - i - 1) * sizeof (entry->connections[0]));
- entry->n_connections -= 1;
-}
-
-static void
-object_remove_from_signals (DBusObjectRegistry *registry,
- DBusObjectEntry *entry)
-{
- if (entry->signals != NULL)
- {
- int i;
-
- i = 0;
- while (entry->signals[i] != NULL)
- {
- DBusSignalEntry *signal = entry->signals[i];
-
- signal_entry_remove_object (signal, entry->id_index);
- if (signal->n_connections == 0)
- delete_signal (registry, signal);
- ++i;
- }
- }
-}
-
-/**
- * Connect this object to the given signal, such that if a
- * signal emission message is received with the given
- * signal name, the message will be routed to the
- * given object.
- *
- * Must be called with #DBusConnection lock held.
- *
- * @param registry the object registry
- * @param object_id object that would like to see the signal
- * @param signal_interface signal interface name
- * @param signal_name signal member name
- *
- * @returns #FALSE if no memory
- */
-dbus_bool_t
-_dbus_object_registry_connect_locked (DBusObjectRegistry *registry,
- const DBusObjectID *object_id,
- const char *signal_interface,
- const char *signal_name)
-{
- DBusSignalEntry **new_signals;
- DBusSignalEntry *signal;
- DBusObjectEntry *entry;
- int i;
-
- _dbus_assert (signal_interface != NULL);
- _dbus_assert (signal_name != NULL);
-
- entry = validate_id (registry, object_id);
- if (entry == NULL)
- {
- _dbus_warn ("Tried to connect a nonexistent D-BUS object ID to signal \"%s\"\n",
- signal_name);
-
- return FALSE;
- }
-
- /* O(n) in number of connections unfortunately, but in practice I
- * don't think it will matter. It's marginally a space-time
- * tradeoff (save an n_signals field) but the NULL termination is
- * just as large as an n_signals once we have even a single
- * connection.
- */
- i = 0;
- if (entry->signals != NULL)
- {
- while (entry->signals[i] != NULL)
- ++i;
- }
-
- new_signals = dbus_realloc (entry->signals,
- (i + 2) * sizeof (DBusSignalEntry*));
-
- if (new_signals == NULL)
- return FALSE;
-
- entry->signals = new_signals;
-
- signal = lookup_signal (registry, signal_interface, signal_name, TRUE);
- if (signal == NULL)
- goto oom;
-
- if (!signal_entry_add_object (signal, entry->id_index))
- goto oom;
-
- entry->signals[i] = signal;
- ++i;
- entry->signals[i] = NULL;
-
- return TRUE;
-
- oom:
- if (signal && signal->n_connections == 0)
- delete_signal (registry, signal);
-
- return FALSE;
-}
-
-/**
- * Reverses effects of _dbus_object_registry_disconnect_locked().
- *
- * @param registry the object registry
- * @param object_id object that would like to see the signal
- * @param signal_interface signal interface
- * @param signal_name signal name
- */
-void
-_dbus_object_registry_disconnect_locked (DBusObjectRegistry *registry,
- const DBusObjectID *object_id,
- const char *signal_interface,
- const char *signal_name)
-{
- DBusObjectEntry *entry;
- DBusSignalEntry *signal;
-
- _dbus_assert (signal_interface != NULL);
- _dbus_assert (signal_name != NULL);
-
- entry = validate_id (registry, object_id);
- if (entry == NULL)
- {
- _dbus_warn ("Tried to disconnect signal \"%s\"::\"%s\" from a nonexistent D-BUS object ID\n",
- signal_interface, signal_name);
-
- return;
- }
-
- signal = lookup_signal (registry, signal_interface, signal_name, FALSE);
- if (signal == NULL)
- {
- _dbus_warn ("Tried to disconnect signal \"%s\"::\"%s\" but no such signal is connected\n",
- signal_interface, signal_name);
- return;
- }
-
- signal_entry_remove_object (signal, entry->id_index);
-
- if (signal->n_connections == 0)
- delete_signal (registry, signal);
-}
-
-static DBusHandlerResult
-handle_method_call_and_unlock (DBusObjectRegistry *registry,
- DBusMessage *message)
-{
- DBusInterfaceEntry *iface_entry;
- DBusObjectEntry *object_entry;
- DBusObjectInfo info;
- const DBusObjectVTable *vtable;
-
- _dbus_assert (registry != NULL);
- _dbus_assert (message != NULL);
-
- /* FIXME handle calls to an object ID instead of just an
- * interface name
- */
-
- /* If the message isn't to a specific object ID, we send
- * it to the first object that supports the given interface.
- */
- iface_entry = lookup_interface (registry,
- dbus_message_get_interface (message),
- FALSE);
-
- if (iface_entry == NULL)
- {
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_unlock (registry->connection);
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
-
- _dbus_assert (iface_entry->n_objects > 0);
- _dbus_assert (iface_entry->objects != NULL);
-
- object_entry = &registry->entries[iface_entry->objects[0]];
-
-
- /* Once we have an object entry, pass message to the object */
-
- _dbus_assert (object_entry->vtable != NULL);
-
- info_from_entry (registry, &info, object_entry);
- vtable = object_entry->vtable;
-
- /* Drop lock and invoke application code */
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_unlock (registry->connection);
-
- (* vtable->message) (&info, message);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-typedef struct
-{
- DBusObjectID id;
-} ObjectEmitData;
-
-static DBusHandlerResult
-handle_signal_and_unlock (DBusObjectRegistry *registry,
- DBusMessage *message)
-{
- DBusSignalEntry *signal_entry;
- int i;
- ObjectEmitData *objects;
- int n_objects;
-
- _dbus_assert (registry != NULL);
- _dbus_assert (message != NULL);
-
- signal_entry = lookup_signal (registry,
- dbus_message_get_interface (message),
- dbus_message_get_member (message),
- FALSE);
-
- if (signal_entry == NULL)
- {
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_unlock (registry->connection);
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
-
- _dbus_assert (signal_entry->n_connections > 0);
- _dbus_assert (signal_entry->connections != NULL);
-
- /* make a copy for safety vs. reentrancy */
-
- /* FIXME (?) if you disconnect a signal during (vs. before)
- * emission, you still receive that signal. To fix this uses more
- * memory because we don't have a per-connection object at the
- * moment. You would have to introduce a connection object and
- * refcount it and have a "disconnected" flag. This is more like
- * GObject semantics but also maybe not important at this level (the
- * GObject/Qt wrappers can mop it up).
- */
-
- n_objects = signal_entry->n_connections;
- objects = dbus_new (ObjectEmitData, n_objects);
-
- if (objects == NULL)
- {
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_unlock (registry->connection);
-
- return DBUS_HANDLER_RESULT_NEED_MEMORY;
- }
-
- i = 0;
- while (i < signal_entry->n_connections)
- {
- DBusObjectEntry *object_entry;
- int idx;
-
- idx = signal_entry->connections[i];
-
- object_entry = &registry->entries[idx];
-
- _dbus_assert (object_entry->vtable != NULL);
-
- id_from_entry (registry,
- &objects[i].id,
- object_entry);
-
- ++i;
- }
-
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_ref_unlocked (registry->connection);
- _dbus_object_registry_ref (registry);
- dbus_message_ref (message);
-
- i = 0;
- while (i < n_objects)
- {
- DBusObjectEntry *object_entry;
-
- /* If an object ID no longer exists, don't send the
- * signal
- */
- object_entry = validate_id (registry, &objects[i].id);
- if (object_entry != NULL)
- {
- const DBusObjectVTable *vtable;
- DBusObjectInfo info;
-
- info_from_entry (registry, &info, object_entry);
- vtable = object_entry->vtable;
-
- /* Drop lock and invoke application code */
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_unlock (registry->connection);
-
- (* vtable->message) (&info, message);
-
- /* Reacquire lock */
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_lock (registry->connection);
- }
- ++i;
- }
-
- dbus_message_unref (message);
- _dbus_object_registry_unref (registry);
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_unref_unlocked (registry->connection);
-
- dbus_free (objects);
-
- /* Drop lock a final time */
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_unlock (registry->connection);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-/**
- * Handle a message, passing it to any objects in the registry that
- * should receive it.
- *
- * @todo handle messages to an object ID, not just those to
- * an interface name.
- *
- * @param registry the object registry
- * @param message the message to handle
- * @returns what to do with the message next
- */
-DBusHandlerResult
-_dbus_object_registry_handle_and_unlock (DBusObjectRegistry *registry,
- DBusMessage *message)
-{
- int type;
-
- _dbus_assert (registry != NULL);
- _dbus_assert (message != NULL);
-
- type = dbus_message_get_type (message);
-
- switch (type)
- {
- case DBUS_MESSAGE_TYPE_METHOD_CALL:
- return handle_method_call_and_unlock (registry, message);
- case DBUS_MESSAGE_TYPE_SIGNAL:
- return handle_signal_and_unlock (registry, message);
- default:
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_unlock (registry->connection);
-
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
-}
-
-dbus_bool_t
-_dbus_object_registry_add_and_unlock (DBusObjectRegistry *registry,
- const char **interfaces,
- const DBusObjectVTable *vtable,
- void *object_impl,
- DBusObjectID *object_id)
-{
- int idx;
- int i;
- DBusObjectInfo info;
-
- if (registry->n_entries_used == registry->n_entries_allocated)
- {
- DBusObjectEntry *new_entries;
- int new_alloc;
-
- if (registry->n_entries_allocated == 0)
- new_alloc = 16;
- else
- {
- if (registry->n_entries_allocated == DBUS_MAX_OBJECTS_PER_CONNECTION)
- {
- _dbus_warn ("Attempting to register a new D-BUS object, but maximum object count of %d reached\n",
- DBUS_MAX_OBJECTS_PER_CONNECTION);
- goto out_0;
- }
-
- new_alloc = registry->n_entries_allocated * 2;
- if (new_alloc > DBUS_MAX_OBJECTS_PER_CONNECTION)
- new_alloc = DBUS_MAX_OBJECTS_PER_CONNECTION;
- }
-
- new_entries = dbus_realloc (registry->entries,
- new_alloc * sizeof (DBusObjectEntry));
-
- if (new_entries == NULL)
- goto out_0;
-
- memset (&new_entries[registry->n_entries_allocated],
- '\0',
- sizeof (DBusObjectEntry) * (new_alloc - registry->n_entries_allocated));
-
- registry->entries = new_entries;
- registry->n_entries_allocated = new_alloc;
- }
- _dbus_assert (registry->n_entries_used < registry->n_entries_allocated);
-
- /* We linear search for an available entry. However, short-circuit
- * the hopefully-common situation where we don't have a sparse
- * array.
- */
- if (registry->entries[registry->n_entries_used].vtable == NULL)
- {
- idx = registry->n_entries_used;
- }
- else
- {
- /* If we do have a sparse array, we try to get rid of it rather
- * than using empty slots on the end, so we won't hit this case
- * next time.
- */
-
- /* If index n_entries_used is occupied, then
- * there is at least one entry outside of
- * the range [0, n_entries_used). Thus, there is
- * at least one blank entry inside that range.
- */
- idx = 0;
- while (idx < registry->n_entries_used)
- {
- if (registry->entries[idx].vtable == NULL)
- break;
- ++idx;
- }
-
- _dbus_assert (idx < registry->n_entries_used);
- }
-
- registry->entries[idx].id_index = idx;
- /* Overflow is OK here, but zero isn't as it's a null ID */
- registry->entries[idx].id_times_used += 1;
- if (registry->entries[idx].id_times_used == 0)
- registry->entries[idx].id_times_used += 1;
-
- registry->entries[idx].vtable = vtable;
- registry->entries[idx].object_impl = object_impl;
-
- registry->n_entries_used += 1;
-
- i = 0;
- if (interfaces != NULL)
- {
- while (interfaces[i] != NULL)
- ++i;
- }
-
- if (i > 0)
- {
- DBusInterfaceEntry **new_interfaces;
-
- new_interfaces =
- dbus_realloc (registry->entries[idx].interfaces,
- (i + 1) * sizeof (DBusInterfaceEntry*));
-
- if (new_interfaces == NULL)
- {
- /* maintain invariant that .interfaces array points to something
- * valid in oom handler (entering this function it pointed to
- * stale data but a valid malloc block)
- */
- dbus_free (registry->entries[idx].interfaces);
- registry->entries[idx].interfaces = NULL;
- goto out_1;
- }
-
- /* NULL-init so it's NULL-terminated and the OOM
- * case can see how far we got
- */
- while (i >= 0)
- {
- new_interfaces[i] = NULL;
- --i;
- }
-
- registry->entries[idx].interfaces = new_interfaces;
- }
- else
- {
- dbus_free (registry->entries[idx].interfaces);
- registry->entries[idx].interfaces = NULL;
- }
-
- /* Fill in interfaces */
- if (interfaces != NULL)
- {
- i = 0;
- while (interfaces[i] != NULL)
- {
- DBusInterfaceEntry *iface;
-
- iface = lookup_interface (registry, interfaces[i],
- TRUE);
- if (iface == NULL)
- goto out_1;
-
- if (!interface_entry_add_object (iface, idx))
- {
- if (iface->n_objects == 0)
- delete_interface (registry, iface);
- goto out_1;
- }
-
- registry->entries[idx].interfaces[i] = iface;
-
- ++i;
- }
- }
-
- info_from_entry (registry, &info, &registry->entries[idx]);
- if (object_id)
- *object_id = info.object_id;
-
- /* Drop lock and invoke application code */
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_unlock (registry->connection);
-
- (* vtable->registered) (&info);
-
- return TRUE;
-
- out_1:
- registry->entries[idx].vtable = NULL;
- registry->entries[idx].object_impl = NULL;
- registry->n_entries_used -= 1;
-
- object_remove_from_interfaces (registry,
- &registry->entries[idx]);
-
- out_0:
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_unlock (registry->connection);
- return FALSE;
-}
-
-void
-_dbus_object_registry_remove_and_unlock (DBusObjectRegistry *registry,
- const DBusObjectID *object_id)
-{
- DBusObjectInfo info;
- DBusObjectEntry *entry;
- const DBusObjectVTable *vtable;
-
- entry = validate_id (registry, object_id);
- if (entry == NULL)
- {
- _dbus_warn ("Tried to unregister a nonexistent D-BUS object ID\n");
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_unlock (registry->connection);
-
- return;
- }
-
- object_remove_from_signals (registry, entry);
- object_remove_from_interfaces (registry, entry);
-
- info_from_entry (registry, &info, entry);
- vtable = entry->vtable;
- entry->vtable = NULL;
- entry->object_impl = NULL;
- registry->n_entries_used -= 1;
-
- /* Drop lock and invoke application code */
-#ifdef DBUS_BUILD_TESTS
- if (registry->connection)
-#endif
- _dbus_connection_unlock (registry->connection);
-
- (* vtable->unregistered) (&info);
-}
-
-
-void
-_dbus_object_registry_free_all_unlocked (DBusObjectRegistry *registry)
-{
- int i;
-
- i = 0;
- while (registry->n_entries_used > 0)
- {
- _dbus_assert (i < registry->n_entries_allocated);
- if (registry->entries[i].vtable != NULL)
- {
- DBusObjectInfo info;
- const DBusObjectVTable *vtable;
-
- object_remove_from_interfaces (registry,
- &registry->entries[i]);
-
- info_from_entry (registry, &info, &registry->entries[i]);
- vtable = registry->entries[i].vtable;
- registry->entries[i].vtable = NULL;
- registry->entries[i].object_impl = NULL;
- registry->n_entries_used -= 1;
- _dbus_assert (registry->n_entries_used >= 0);
-
- (* vtable->unregistered) (&info);
- }
-
- ++i;
- }
-
- _dbus_assert (registry->n_entries_used == 0);
-}
-
-/** @} */
-
-#ifdef DBUS_BUILD_TESTS
-#include "dbus-test.h"
-#include <stdio.h>
-
-static void
-noop_message_function (DBusObjectInfo *info,
- DBusMessage *message)
-{
- /* nothing */
-}
-
-static void
-add_and_remove_objects (DBusObjectRegistry *registry)
-{
-#define N_OBJECTS 73
- DBusObjectID ids[N_OBJECTS];
- const char *zero_interfaces[] = { NULL };
- const char *one_interface[] = { "org.freedesktop.Test.Blah", NULL };
- const char *three_interfaces[] = { "org.freedesktop.Test.Blah",
- "org.freedesktop.Test.Baz",
- "org.freedesktop.Test.Foo",
- NULL };
- int i;
- DBusMessage *message;
-
- i = 0;
- while (i < N_OBJECTS)
- {
- DBusCallbackObject *callback;
- const char **interfaces;
-
- callback = dbus_callback_object_new (noop_message_function, NULL, NULL);
- if (callback == NULL)
- goto out;
-
- interfaces = NULL;
- switch (i % 3)
- {
- case 0:
- interfaces = zero_interfaces;
- break;
- case 1:
- interfaces = one_interface;
- break;
- case 2:
- interfaces = three_interfaces;
- break;
- }
- _dbus_assert (interfaces != NULL);
-
- if (!_dbus_object_registry_add_and_unlock (registry,
- interfaces,
- dbus_callback_object_vtable,
- callback,
- &ids[i]))
- {
- dbus_callback_object_unref (callback);
- goto out;
- }
-
- dbus_callback_object_unref (callback);
-
- ++i;
- }
-
- i = 0;
- while (i < N_OBJECTS)
- {
- if (i > (N_OBJECTS - 20) || (i % 3) == 0)
- {
- _dbus_object_registry_remove_and_unlock (registry,
- &ids[i]);
- dbus_object_id_set_null (&ids[i]);
- }
-
- ++i;
- }
-
- i = 0;
- while (i < N_OBJECTS)
- {
- if (dbus_object_id_is_null (&ids[i]))
- {
- DBusCallbackObject *callback;
- const char **interfaces;
-
- callback = dbus_callback_object_new (noop_message_function, NULL, NULL);
- if (callback == NULL)
- goto out;
-
- interfaces = NULL;
- switch (i % 4)
- {
- case 0:
- interfaces = NULL;
- break;
- case 1:
- interfaces = zero_interfaces;
- break;
- case 2:
- interfaces = one_interface;
- break;
- case 3:
- interfaces = three_interfaces;
- break;
- }
-
- if (!_dbus_object_registry_add_and_unlock (registry,
- interfaces,
- dbus_callback_object_vtable,
- callback,
- &ids[i]))
- {
- dbus_callback_object_unref (callback);
- goto out;
- }
-
- dbus_callback_object_unref (callback);
- }
-
- ++i;
- }
-
- message = dbus_message_new_method_call ("org.freedesktop.Test.Foo",
- "Bar", NULL);
- if (message != NULL)
- {
- if (_dbus_object_registry_handle_and_unlock (registry, message) !=
- DBUS_HANDLER_RESULT_HANDLED)
- _dbus_assert_not_reached ("message not handled\n");
- dbus_message_unref (message);
- }
-
- message = dbus_message_new_method_call ("org.freedesktop.Test.Blah",
- "Baz", NULL);
- if (message != NULL)
- {
- if (_dbus_object_registry_handle_and_unlock (registry, message) !=
- DBUS_HANDLER_RESULT_HANDLED)
- _dbus_assert_not_reached ("message not handled\n");
- dbus_message_unref (message);
- }
-
- message = dbus_message_new_method_call ("org.freedesktop.Test.NotRegisteredIface",
- "Boo", NULL);
- if (message != NULL)
- {
- if (_dbus_object_registry_handle_and_unlock (registry, message) !=
- DBUS_HANDLER_RESULT_NOT_YET_HANDLED)
- _dbus_assert_not_reached ("message handled but no handler was registered\n");
- dbus_message_unref (message);
- }
-
- i = 0;
- while (i < (N_OBJECTS - 30))
- {
- _dbus_assert (!dbus_object_id_is_null (&ids[i]));
-
- _dbus_object_registry_remove_and_unlock (registry,
- &ids[i]);
- ++i;
- }
-
- out:
- /* unregister the rest this way, to test this function */
- _dbus_object_registry_free_all_unlocked (registry);
-}
-
-static dbus_bool_t
-object_registry_test_iteration (void *data)
-{
- DBusObjectRegistry *registry;
-
- registry = _dbus_object_registry_new (NULL);
- if (registry == NULL)
- return TRUE;
-
- /* we do this twice since realloc behavior will differ each time,
- * and the IDs will get recycled leading to slightly different
- * codepaths
- */
- add_and_remove_objects (registry);
- add_and_remove_objects (registry);
-
- _dbus_object_registry_unref (registry);
-
- return TRUE;
-}
-
-/**
- * @ingroup DBusObjectRegistry
- * Unit test for DBusObjectRegistry
- * @returns #TRUE on success.
- */
-dbus_bool_t
-_dbus_object_registry_test (void)
-{
- _dbus_test_oom_handling ("object registry",
- object_registry_test_iteration,
- NULL);
-
- return TRUE;
-}
-
-#endif /* DBUS_BUILD_TESTS */
diff --git a/dbus/dbus-object-registry.h b/dbus/dbus-object-registry.h
deleted file mode 100644
index 29c92b9c..00000000
--- a/dbus/dbus-object-registry.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-object-registry.h DBusObjectRegistry (internals of DBusConnection)
- *
- * Copyright (C) 2003 Red Hat Inc.
- *
- * Licensed under the Academic Free License version 1.2
- *
- * 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
- *
- */
-#ifndef DBUS_OBJECT_REGISTRY_H
-#define DBUS_OBJECT_REGISTRY_H
-
-#include <dbus/dbus-object.h>
-
-DBUS_BEGIN_DECLS;
-
-typedef struct DBusObjectRegistry DBusObjectRegistry;
-
-DBusObjectRegistry* _dbus_object_registry_new (DBusConnection *connection);
-void _dbus_object_registry_ref (DBusObjectRegistry *registry);
-void _dbus_object_registry_unref (DBusObjectRegistry *registry);
-
-dbus_bool_t _dbus_object_registry_add_and_unlock (DBusObjectRegistry *registry,
- const char **interfaces,
- const DBusObjectVTable *vtable,
- void *object_impl,
- DBusObjectID *object_id);
-void _dbus_object_registry_remove_and_unlock (DBusObjectRegistry *registry,
- const DBusObjectID *object_id);
-DBusHandlerResult _dbus_object_registry_handle_and_unlock (DBusObjectRegistry *registry,
- DBusMessage *message);
-void _dbus_object_registry_free_all_unlocked (DBusObjectRegistry *registry);
-dbus_bool_t _dbus_object_registry_connect_locked (DBusObjectRegistry *registry,
- const DBusObjectID *object_id,
- const char *signal_interface,
- const char *signal_name);
-void _dbus_object_registry_disconnect_locked (DBusObjectRegistry *registry,
- const DBusObjectID *object_id,
- const char *signal_interface,
- const char *signal_name);
-
-DBUS_END_DECLS;
-
-#endif /* DBUS_OBJECT_REGISTRY_H */
diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c
index 7f7e6011..31724b7b 100644
--- a/dbus/dbus-object-tree.c
+++ b/dbus/dbus-object-tree.c
@@ -42,7 +42,7 @@
typedef struct DBusObjectSubtree DBusObjectSubtree;
DBusObjectSubtree* _dbus_object_subtree_new (const char **path,
- const DBusObjectTreeVTable *vtable,
+ const DBusObjectPathVTable *vtable,
void *user_data);
void _dbus_object_subtree_ref (DBusObjectSubtree *subtree);
void _dbus_object_subtree_unref (DBusObjectSubtree *subtree);
@@ -66,7 +66,7 @@ struct DBusObjectSubtree
int refcount;
char **path;
int n_path_elements;
- DBusObjectTreeVTable vtable;
+ DBusObjectPathVTable vtable;
void *user_data;
};
@@ -299,7 +299,7 @@ check_overlap (DBusObjectTree *tree,
dbus_bool_t
_dbus_object_tree_register (DBusObjectTree *tree,
const char **path,
- const DBusObjectTreeVTable *vtable,
+ const DBusObjectPathVTable *vtable,
void *user_data)
{
DBusObjectSubtree *subtree;
@@ -382,9 +382,26 @@ _dbus_object_tree_unregister_and_unlock (DBusObjectTree *tree,
}
/**
+ * Free all the handlers in the tree. Lock on tree's connection
+ * must not be held.
+ *
+ * @todo implement
+ *
+ * @param tree the object tree
+ */
+void
+_dbus_object_tree_free_all_unlocked (DBusObjectTree *tree)
+{
+
+
+}
+
+/**
* Tries to dispatch a message by directing it to the object tree
* node listed in the message header, if any.
*
+ * @todo implement
+ *
* @param tree the global object tree
* @param message the message to dispatch
* @returns whether message was handled successfully
@@ -399,7 +416,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree,
DBusObjectSubtree*
_dbus_object_subtree_new (const char **path,
- const DBusObjectTreeVTable *vtable,
+ const DBusObjectPathVTable *vtable,
void *user_data)
{
DBusObjectSubtree *subtree;
@@ -476,7 +493,7 @@ test_subtree_cmp (const char **path1,
DBusObjectSubtree *subtree1;
DBusObjectSubtree *subtree2;
dbus_bool_t retval;
- DBusObjectTreeVTable vtable;
+ DBusObjectPathVTable vtable;
_DBUS_ZERO (vtable);
diff --git a/dbus/dbus-object-tree.h b/dbus/dbus-object-tree.h
index 06033333..5d44bbe2 100644
--- a/dbus/dbus-object-tree.h
+++ b/dbus/dbus-object-tree.h
@@ -35,12 +35,13 @@ void _dbus_object_tree_unref (DBusObjectTree *tree);
dbus_bool_t _dbus_object_tree_register (DBusObjectTree *tree,
const char **path,
- const DBusObjectTreeVTable *vtable,
+ const DBusObjectPathVTable *vtable,
void *user_data);
void _dbus_object_tree_unregister_and_unlock (DBusObjectTree *tree,
const char **path);
DBusHandlerResult _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree,
DBusMessage *message);
+void _dbus_object_tree_free_all_unlocked (DBusObjectTree *tree);
DBUS_END_DECLS;
diff --git a/dbus/dbus-object.c b/dbus/dbus-object.c
deleted file mode 100644
index 5582f94a..00000000
--- a/dbus/dbus-object.c
+++ /dev/null
@@ -1,349 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-object.c Objects
- *
- * Copyright (C) 2003 Red Hat Inc.
- *
- * Licensed under the Academic Free License version 1.2
- *
- * 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
- *
- */
-
-#include <config.h>
-#include "dbus-internals.h"
-#include "dbus-object.h"
-
-/**
- * @defgroup DBusCallbackObjectInternals DBusCallbackObject implementation details
- * @ingroup DBusInternals
- * @brief DBusCallbackObject private implementation details.
- *
- * The guts of DBusCallbackObject and its methods.
- *
- * @{
- */
-
-_DBUS_DEFINE_GLOBAL_LOCK (callback_object);
-
-/**
- * @brief Internals of DBusCallbackObject
- *
- * Object that can send and receive messages.
- */
-struct DBusCallbackObject
-{
- DBusAtomic refcount; /**< reference count */
- DBusObjectMessageFunction function; /**< callback function */
- void *user_data; /**< user data for function */
- DBusFreeFunction free_user_data; /**< free the user data */
-};
-
-static void
-callback_object_registered (DBusObjectInfo *info)
-{
- DBusCallbackObject *callback = info->object_impl;
-
- dbus_callback_object_ref (callback);
-}
-
-static void
-callback_object_unregistered (DBusObjectInfo *info)
-{
- DBusCallbackObject *callback = info->object_impl;
-
- dbus_callback_object_unref (callback);
-}
-
-static void
-callback_object_message (DBusObjectInfo *info,
- DBusMessage *message)
-{
- DBusCallbackObject *callback = info->object_impl;
-
- if (callback->function)
- (* callback->function) (info, message);
-}
-
-/** @} */
-
-/**
- * @defgroup DBusObject DBusObjectInfo, DBusObjectVTable, DBusCallbackObject
- * @ingroup DBus
- * @brief support for object instances
- *
- * Behind each DBusConnection are object instances. An object instance
- * may be a GObject (using GLib), a QObject (using Qt), a built-in
- * object type called DBusCallbackObject, or any other representation
- * of an object; it's even permissible to have an object that's simply
- * an integer value or a pointer to a struct.
- *
- * Objects are registered with one or more DBusConnection. Registered
- * objects receive an object ID, represented by the DBusObjectID type.
- * Object IDs can be passed over a DBusConnection and used by the
- * remote application to refer to objects. Remote applications can
- * also refer to objects by dynamically locating objects that support
- * a particular interface.
- *
- * To define an object, you simply provide three callbacks: one to be
- * called when the object is registered with a new connection, one
- * to be called when the object is unregistered, and one to be called
- * when the object receives a message from the peer on the other end
- * of the DBusConnection. The three callbacks are specified in a
- * DBusObjectVTable struct.
- *
- * The DBusObjectInfo struct is used to pass the object pointer
- * (object_impl), connection, and object ID to each of the callbacks
- * in the virtual table. This struct should be treated as read-only.
- *
- * DBusCallbackObject is provided for convenience as a way to
- * implement an object quickly by writing only one callback function,
- * the callback that processes messages. To use DBusCallbackObject,
- * simply create one, then call dbus_connection_register_object()
- * passing in the provided DBusObjectVTable
- * dbus_callback_object_vtable. This is the simplest possible object;
- * it simply contains a function to be called whenever a message is
- * received.
- *
- * The DBusCallbackObject will be strong-referenced by the
- * DBusConnection, so may be unreferenced once it's registered, and
- * will go away either on unregistration or when the connection is
- * freed.
- *
- * One DBusCallbackObject may be registered with any number of
- * DBusConnection.
- *
- * @{
- */
-
-/**
- * @typedef DBusCallbackObject
- *
- * Opaque data type representing a callback object.
- */
-
-static const DBusObjectVTable callback_object_vtable = {
- callback_object_registered,
- callback_object_unregistered,
- callback_object_message,
- NULL, NULL, NULL
-};
-
-/**
- * Virtual table for a DBusCallbackObject, used to register the
- * callback object with dbus_connection_register_object().
- */
-const DBusObjectVTable* dbus_callback_object_vtable = &callback_object_vtable;
-
-/**
- * Creates a new callback object. The callback function
- * may be #NULL for a no-op callback or a callback to
- * be assigned a function later.
- *
- * Use dbus_connection_register_object() along with
- * dbus_callback_object_vtable to register the callback object with
- * one or more connections. Each connection will add a reference to
- * the callback object, so once it's registered it may be unreferenced
- * with dbus_callback_object_unref().
- *
- * @param function function to call to handle a message
- * @param user_data data to pass to the function
- * @param free_user_data function to call to free the user data
- * @returns a new DBusCallbackObject or #NULL if no memory.
- */
-DBusCallbackObject*
-dbus_callback_object_new (DBusObjectMessageFunction function,
- void *user_data,
- DBusFreeFunction free_user_data)
-{
- DBusCallbackObject *callback;
-
- callback = dbus_new0 (DBusCallbackObject, 1);
- if (callback == NULL)
- return NULL;
-
- callback->refcount.value = 1;
- callback->function = function;
- callback->user_data = user_data;
- callback->free_user_data = free_user_data;
-
- return callback;
-}
-
-/**
- * Increments the reference count on a callback object.
- *
- * @param callback the callback
- */
-void
-dbus_callback_object_ref (DBusCallbackObject *callback)
-{
- _dbus_return_if_fail (callback != NULL);
-
- _dbus_atomic_inc (&callback->refcount);
-}
-
-
-/**
- * Decrements the reference count on a callback object,
- * freeing the callback if the count reaches 0.
- *
- * @param callback the callback
- */
-void
-dbus_callback_object_unref (DBusCallbackObject *callback)
-{
- dbus_bool_t last_unref;
-
- _dbus_return_if_fail (callback != NULL);
-
- last_unref = (_dbus_atomic_dec (&callback->refcount) == 1);
-
- if (last_unref)
- {
- if (callback->free_user_data)
- (* callback->free_user_data) (callback->user_data);
-
- dbus_free (callback);
- }
-}
-
-/**
- * Gets the user data for the callback.
- *
- * @param callback the callback
- * @returns the user data
- */
-void*
-dbus_callback_object_get_data (DBusCallbackObject *callback)
-{
- void* user_data;
-
- _dbus_return_val_if_fail (callback != NULL, NULL);
-
- _DBUS_LOCK (callback_object);
- user_data = callback->user_data;
- _DBUS_UNLOCK (callback_object);
- return user_data;
-}
-
-
-/**
- * Sets the user data for the callback. Frees any previously-existing
- * user data with the previous free_user_data function.
- *
- * @param callback the callback
- * @param user_data the user data
- * @param free_user_data free function for the data
- */
-void
-dbus_callback_object_set_data (DBusCallbackObject *callback,
- void *user_data,
- DBusFreeFunction free_user_data)
-{
- DBusFreeFunction old_free_func;
- void *old_user_data;
-
- _dbus_return_if_fail (callback != NULL);
-
- _DBUS_LOCK (callback_object);
- old_free_func = callback->free_user_data;
- old_user_data = callback->user_data;
-
- callback->user_data = user_data;
- callback->free_user_data = free_user_data;
- _DBUS_UNLOCK (callback_object);
-
- if (old_free_func)
- (* old_free_func) (old_user_data);
-}
-
-/**
- * Sets the function to be used to handle messages to the
- * callback object.
- *
- * @todo the thread locking on DBusCallbackObject is hosed; in this
- * function in particular it's a joke since we don't take the same
- * lock when _calling_ the callback function.
- *
- * @param callback the callback
- * @param function the function
- */
-void
-dbus_callback_object_set_function (DBusCallbackObject *callback,
- DBusObjectMessageFunction function)
-{
- _dbus_return_if_fail (callback != NULL);
-
- _DBUS_LOCK (callback_object);
- callback->function = function;
- _DBUS_UNLOCK (callback_object);
-}
-
-/** @} */
-
-#ifdef DBUS_BUILD_TESTS
-#include "dbus-test.h"
-#include <stdio.h>
-
-static void
-test_message_function (DBusObjectInfo *info,
- DBusMessage *message)
-{
- /* nothing */
-}
-
-static void
-free_test_data (void *data)
-{
- /* does nothing */
-}
-
-/**
- * @ingroup DBusCallbackObjectInternals
- * Unit test for DBusCallbackObject.
- *
- * @returns #TRUE on success.
- */
-dbus_bool_t
-_dbus_object_test (void)
-{
- DBusCallbackObject *callback;
-
-#define TEST_DATA ((void*) 0xcafebabe)
-
- callback = dbus_callback_object_new (test_message_function,
- TEST_DATA,
- free_test_data);
-
- _dbus_assert (callback != NULL);
- _dbus_assert (callback->function == test_message_function);
-
- if (dbus_callback_object_get_data (callback) != TEST_DATA)
- _dbus_assert_not_reached ("got wrong data");
-
- dbus_callback_object_set_data (callback, NULL, NULL);
- if (dbus_callback_object_get_data (callback) != NULL)
- _dbus_assert_not_reached ("got wrong data after set");
-
- dbus_callback_object_set_function (callback, NULL);
- _dbus_assert (callback->function == NULL);
-
- dbus_callback_object_ref (callback);
- dbus_callback_object_unref (callback);
- dbus_callback_object_unref (callback);
-
- return TRUE;
-}
-#endif /* DBUS_BUILD_TESTS */
diff --git a/dbus/dbus-object.h b/dbus/dbus-object.h
deleted file mode 100644
index 23c12d15..00000000
--- a/dbus/dbus-object.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-object.h Objects
- *
- * Copyright (C) 2003 Red Hat Inc.
- *
- * Licensed under the Academic Free License version 1.2
- *
- * 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
- *
- */
-#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION)
-#error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef DBUS_OBJECT_H
-#define DBUS_OBJECT_H
-
-#include <dbus/dbus-arch-deps.h>
-#include <dbus/dbus-types.h>
-#include <dbus/dbus-message.h>
-#include <dbus/dbus-objectid.h>
-
-DBUS_BEGIN_DECLS;
-
-typedef struct DBusConnection DBusConnection;
-typedef struct DBusObjectVTable DBusObjectVTable;
-typedef struct DBusObjectInfo DBusObjectInfo;
-typedef struct DBusCallbackObject DBusCallbackObject;
-
-typedef enum
-{
- DBUS_HANDLER_RESULT_HANDLED, /**< Remove this message, no further processing. */
- DBUS_HANDLER_RESULT_NOT_YET_HANDLED, /**< Run any additional handlers that are interested in this message. */
- DBUS_HANDLER_RESULT_NEED_MEMORY /**< Need more memory to handle this message. */
-} DBusHandlerResult;
-
-struct DBusObjectInfo
-{
- void *object_impl; /**< Object implementation pointer provided by app */
- DBusObjectID object_id; /**< Object ID */
- DBusConnection *connection; /**< The connection object ID is for */
- void *dbus_internal_pad1; /**< Padding, do not use */
- void *dbus_internal_pad2; /**< Padding, do not use */
-};
-
-typedef void (* DBusObjectRegisteredFunction) (DBusObjectInfo *info);
-typedef void (* DBusObjectUnregisteredFunction) (DBusObjectInfo *info);
-typedef void (* DBusObjectMessageFunction) (DBusObjectInfo *info,
- DBusMessage *message);
-
-struct DBusObjectVTable
-{
- DBusObjectRegisteredFunction registered;
- DBusObjectUnregisteredFunction unregistered;
- DBusObjectMessageFunction message;
- void (* dbus_internal_pad1) (void *);
- void (* dbus_internal_pad2) (void *);
- void (* dbus_internal_pad3) (void *);
-};
-
-extern const DBusObjectVTable *dbus_callback_object_vtable;
-
-DBusCallbackObject* dbus_callback_object_new (DBusObjectMessageFunction function,
- void *user_data,
- DBusFreeFunction free_user_data);
-void dbus_callback_object_ref (DBusCallbackObject *callback);
-void dbus_callback_object_unref (DBusCallbackObject *callback);
-void* dbus_callback_object_get_data (DBusCallbackObject *callback);
-void dbus_callback_object_set_data (DBusCallbackObject *callback,
- void *data,
- DBusFreeFunction free_user_data);
-void dbus_callback_object_set_function (DBusCallbackObject *callback,
- DBusObjectMessageFunction function);
-
-
-DBUS_END_DECLS;
-
-#endif /* DBUS_OBJECT_H */
diff --git a/dbus/dbus-objectid.c b/dbus/dbus-objectid.c
deleted file mode 100644
index f2b27b61..00000000
--- a/dbus/dbus-objectid.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-objectid.c DBusObjectID type
- *
- * Copyright (C) 2003 Red Hat Inc.
- *
- * Licensed under the Academic Free License version 1.2
- *
- * 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
- *
- */
-
-#include "dbus-objectid.h"
-#include "dbus-internals.h"
-
-#ifdef DBUS_HAVE_INT64
-#define VALUE(objid) ((objid)->dbus_do_not_use_dummy1)
-#define SERVER_MASK DBUS_UINT64_CONSTANT (0xffff000000000000)
-#define CLIENT_MASK DBUS_UINT64_CONSTANT (0x0000ffff00000000)
-#define IS_SERVER_MASK DBUS_UINT64_CONSTANT (0x0000000080000000)
-#define INSTANCE_MASK DBUS_UINT64_CONSTANT (0x000000007fffffff)
-#define SERVER_BITS(objid) ((dbus_uint16_t) (VALUE (obj_id) >> 48))
-#define CLIENT_BITS(objid) ((dbus_uint16_t) ((VALUE (obj_id) & CLIENT_MASK) >> 32))
-#define IS_SERVER_BIT(objid) ((VALUE (obj_id) & IS_SERVER_MASK) != 0)
-#define INSTANCE_BITS(objid) ((dbus_uint32_t) (VALUE (obj_id) & INSTANCE_MASK))
-#else
-/* We care about the exact packing since in dbus-marshal.c we
- * just use the DBusObjectID struct as-is.
- */
-#ifdef WORDS_BIGENDIAN
-#define HIGH_VALUE(objid) ((objid)->dbus_do_not_use_dummy2)
-#define LOW_VALUE(objid) ((objid)->dbus_do_not_use_dummy3)
-#else
-#define HIGH_VALUE(objid) ((objid)->dbus_do_not_use_dummy3)
-#define LOW_VALUE(objid) ((objid)->dbus_do_not_use_dummy2)
-#endif
-#define SERVER_MASK (0xffff0000)
-#define CLIENT_MASK (0x0000ffff)
-#define IS_SERVER_MASK (0x80000000)
-#define INSTANCE_MASK (0x7fffffff)
-#define SERVER_BITS(objid) ((HIGH_VALUE (objid) & SERVER_MASK) >> 16)
-#define CLIENT_BITS(objid) (HIGH_VALUE (objid) & CLIENT_MASK)
-#define IS_SERVER_BIT(objid) ((LOW_VALUE (objid) & IS_SERVER_MASK) != 0)
-#define INSTANCE_BITS(objid) (LOW_VALUE (objid) & INSTANCE_MASK)
-#endif
-
-/**
- * @defgroup DBusObjectID object IDs
- * @ingroup DBusObjectID
- * @brief object ID datatype
- *
- * Value type representing an object ID, i.e. an object in the remote
- * application that can be communicated with.
- *
- * An object ID has three parts. 16 bits are provided by the server
- * side of a connection, and used for the high 16 bits of all object
- * IDs created by the client. 16 bits are provided by the client side
- * and used as the next 16 bits of all object IDs created by the
- * client. The next single bit is 1 if the object ID represents an
- * object on the server side of the connection and 0 otherwise. Then
- * 31 bits are provided by the side creating an object instance and
- * differ for each instance created (each app should make a best
- * effort to avoid recycling the instance values).
- *
- * 0 is an invalid value for the server bits, the client bits,
- * and the object instance bits. An object ID is the null ID
- * if all 64 bits are 0.
- *
- * @{
- */
-
-/**
- * Checks whether two object IDs have the same value.
- *
- * @param a the first object ID
- * @param b the second object ID
- * @returns #TRUE if they are equal
- */
-dbus_bool_t
-dbus_object_id_equal (const DBusObjectID *a,
- const DBusObjectID *b)
-{
-#ifdef DBUS_HAVE_INT64
- return VALUE (a) == VALUE (b);
-#else
- return LOW_VALUE (a) == LOW_VALUE (b) && HIGH_VALUE (a) == HIGH_VALUE (b);
-#endif
-}
-
-/**
- * Compares two object IDs, appropriate for
- * qsort(). Higher/lower IDs have no significance,
- * but the comparison can be used for data structures
- * that require ordering.
- *
- * @param a the first object ID
- * @param b the second object ID
- * @returns -1, 0, 1 as with strcmp()
- */
-int
-dbus_object_id_compare (const DBusObjectID *a,
- const DBusObjectID *b)
-{
-#ifdef DBUS_HAVE_INT64
- if (VALUE (a) > VALUE (b))
- return 1;
- else if (VALUE (a) < VALUE (b))
- return -1;
- else
- return 0;
-#else
- if (HIGH_VALUE (a) > HIGH_VALUE (b))
- return 1;
- else if (HIGH_VALUE (a) < HIGH_VALUE (b))
- return -1;
- else if (LOW_VALUE (a) > LOW_VALUE (b))
- return 1;
- else if (LOW_VALUE (a) < LOW_VALUE (b))
- return -1;
- else
- return 0;
-#endif
-}
-
-
-/**
- * An object ID contains 64 bits of data. This function
- * returns the 16 bits that were provided by the server
- * side of the connection.
- *
- * @param obj_id the object ID
- * @returns the server bits of the ID
- *
- */
-dbus_uint16_t
-dbus_object_id_get_server_bits (const DBusObjectID *obj_id)
-{
- return SERVER_BITS (obj_id);
-}
-
-/**
- * An object ID contains 64 bits of data. This function
- * returns the 16 bits that were provided by the client
- * side of the connection.
- *
- * @param obj_id the object ID
- * @returns the client bits of the ID
- *
- */
-dbus_uint16_t
-dbus_object_id_get_client_bits (const DBusObjectID *obj_id)
-{
- return CLIENT_BITS (obj_id);
-}
-
-/**
- * An object ID contains 64 bits of data. This function
- * returns the bit flagging whether the object ID comes
- * from the client or the server side of the connection.
- *
- * There is no secure guarantee that the bit is accurate;
- * object ID values are simply conventional, to make
- * collisions relatively unlikely.
- *
- * @param obj_id the object ID
- * @returns the server-side bit of the ID
- *
- */
-dbus_bool_t
-dbus_object_id_get_is_server_bit (const DBusObjectID *obj_id)
-{
- return IS_SERVER_BIT (obj_id);
-}
-
-/**
- * An object ID contains 64 bits of data. This function
- * returns the 31 bits that identify the object instance.
- *
- * @param obj_id the object ID
- * @returns the instance bits of the ID
- *
- */
-dbus_uint32_t
-dbus_object_id_get_instance_bits (const DBusObjectID *obj_id)
-{
- return INSTANCE_BITS (obj_id);
-}
-
-/**
- * An object ID contains 64 bits of data. This function sets the 16
- * bits provided by the server side of a connection.
- *
- * @param obj_id the object ID
- * @param value the new value of the server bits
- *
- */
-void
-dbus_object_id_set_server_bits (DBusObjectID *obj_id,
- dbus_uint16_t value)
-{
-#ifdef DBUS_HAVE_INT64
- VALUE (obj_id) &= ~ SERVER_MASK;
- VALUE (obj_id) |= ((dbus_uint64_t) value) << 48;
-#else
- HIGH_VALUE (obj_id) &= ~ SERVER_MASK;
- HIGH_VALUE (obj_id) |= ((dbus_uint32_t) value) << 16;
-#endif
-}
-
-/**
- * An object ID contains 64 bits of data. This function sets the 16
- * bits provided by the client side of a connection.
- *
- * @param obj_id the object ID
- * @param value the new value of the client bits
- *
- */
-void
-dbus_object_id_set_client_bits (DBusObjectID *obj_id,
- dbus_uint16_t value)
-{
-#ifdef DBUS_HAVE_INT64
- VALUE (obj_id) &= ~ CLIENT_MASK;
- VALUE (obj_id) |= ((dbus_uint64_t) value) << 32;
-#else
- HIGH_VALUE (obj_id) &= ~ CLIENT_MASK;
- HIGH_VALUE (obj_id) |= (dbus_uint32_t) value;
-#endif
-}
-
-/**
- * An object ID contains 64 bits of data. This function sets the
- * single bit that flags an instance as server-side or client-side.
- *
- * @param obj_id the object ID
- * @param value the new value of the server-side bit
- *
- */
-void
-dbus_object_id_set_is_server_bit (DBusObjectID *obj_id,
- dbus_bool_t value)
-{
-#ifdef DBUS_HAVE_INT64
- if (value)
- VALUE (obj_id) |= IS_SERVER_MASK;
- else
- VALUE (obj_id) &= ~ IS_SERVER_MASK;
-#else
- if (value)
- LOW_VALUE (obj_id) |= IS_SERVER_MASK;
- else
- LOW_VALUE (obj_id) &= ~ IS_SERVER_MASK;
-#endif
-}
-
-/**
- * An object ID contains 64 bits of data. This function sets the 31
- * bits identifying the object instance.
- *
- * @param obj_id the object ID
- * @param value the new value of the instance bits
- *
- */
-void
-dbus_object_id_set_instance_bits (DBusObjectID *obj_id,
- dbus_uint32_t value)
-{
-#ifdef DBUS_HAVE_INT64
- VALUE (obj_id) &= ~ INSTANCE_MASK;
- VALUE (obj_id) |= (dbus_uint64_t) value;
-#else
- LOW_VALUE (obj_id) &= ~ INSTANCE_MASK;
- LOW_VALUE (obj_id) |= (dbus_uint32_t) value;
-#endif
-}
-
-/**
- * Set the object ID to an invalid value that cannot
- * correspond to a valid object.
- *
- * @param obj_id the object ID
- */
-void
-dbus_object_id_set_null (DBusObjectID *obj_id)
-{
- memset (obj_id, '\0', sizeof (DBusObjectID));
-}
-
-/**
- * Check whether the object ID is set to a null value
- *
- * @param obj_id the object ID
- * @returns #TRUE if null
- */
-dbus_bool_t
-dbus_object_id_is_null (const DBusObjectID *obj_id)
-{
-#ifdef DBUS_HAVE_INT64
- return VALUE (obj_id) == 0;
-#else
- return HIGH_VALUE (obj_id) == 0 && LOW_VALUE (obj_id) == 0;
-#endif
-}
-
-#ifdef DBUS_HAVE_INT64
-/**
- * An object ID contains 64 bits of data. This function
- * returns all of them as a 64-bit integer.
- *
- * Use this function only if you are willing to limit portability to
- * compilers with a 64-bit type (this includes C99 compilers and
- * almost all other compilers).
- *
- * This function only exists if DBUS_HAVE_INT64 is defined.
- *
- * @param obj_id the object ID
- * @returns the object ID as a 64-bit integer.
- */
-dbus_uint64_t
-dbus_object_id_get_as_integer (const DBusObjectID *obj_id)
-{
- return VALUE (obj_id);
-}
-
-/**
- * An object ID contains 64 bits of data. This function sets all of
- * them as a 64-bit integer.
- *
- * Use this function only if you are willing to limit portability to
- * compilers with a 64-bit type (this includes C99 compilers and
- * almost all other compilers).
- *
- * This function only exists if #DBUS_HAVE_INT64 is defined.
- *
- * @param obj_id the object ID
- * @param value the new value of the object ID
- */
-void
-dbus_object_id_set_as_integer (DBusObjectID *obj_id,
- dbus_uint64_t value)
-{
- VALUE (obj_id) = value;
-}
-#endif /* DBUS_HAVE_INT64 */
-
-/** @} */
-
-#ifdef DBUS_BUILD_TESTS
-#include "dbus-test.h"
-#include <stdio.h>
-
-/**
- * Test for object ID routines.
- *
- * @returns #TRUE on success
- */
-dbus_bool_t
-_dbus_object_id_test (void)
-{
- DBusObjectID tmp;
- DBusObjectID tmp2;
-
- /* Check basic get/set */
-
- dbus_object_id_set_server_bits (&tmp, 340);
- _dbus_assert (dbus_object_id_get_server_bits (&tmp) == 340);
-
- dbus_object_id_set_client_bits (&tmp, 1492);
- _dbus_assert (dbus_object_id_get_client_bits (&tmp) == 1492);
- _dbus_assert (dbus_object_id_get_server_bits (&tmp) == 340);
-
- dbus_object_id_set_is_server_bit (&tmp, TRUE);
- _dbus_assert (dbus_object_id_get_client_bits (&tmp) == 1492);
- _dbus_assert (dbus_object_id_get_server_bits (&tmp) == 340);
- _dbus_assert (dbus_object_id_get_is_server_bit (&tmp) == TRUE);
-
- dbus_object_id_set_instance_bits (&tmp, 2001);
- _dbus_assert (dbus_object_id_get_client_bits (&tmp) == 1492);
- _dbus_assert (dbus_object_id_get_server_bits (&tmp) == 340);
- _dbus_assert (dbus_object_id_get_is_server_bit (&tmp) == TRUE);
- _dbus_assert (dbus_object_id_get_instance_bits (&tmp) == 2001);
-
- /* check equality check */
- tmp2 = tmp;
- _dbus_assert (dbus_object_id_equal (&tmp, &tmp2));
-
- /* check get/set as integer */
-#ifdef DBUS_HAVE_INT64
- _dbus_assert (dbus_object_id_get_as_integer (&tmp) ==
- ((DBUS_UINT64_CONSTANT (340) << 48) |
- (DBUS_UINT64_CONSTANT (1492) << 32) |
- (DBUS_UINT64_CONSTANT (1) << 31) |
- (DBUS_UINT64_CONSTANT (2001))));
-
- dbus_object_id_set_as_integer (&tmp, _DBUS_UINT64_MAX);
- _dbus_assert (dbus_object_id_get_as_integer (&tmp) ==
- _DBUS_UINT64_MAX);
- _dbus_assert (dbus_object_id_get_server_bits (&tmp) ==
- 0xffff);
- _dbus_assert (dbus_object_id_get_client_bits (&tmp) ==
- 0xffff);
- _dbus_assert (dbus_object_id_get_is_server_bit (&tmp) ==
- TRUE);
- _dbus_assert (dbus_object_id_get_instance_bits (&tmp) ==
- 0x7fffffff);
-
- dbus_object_id_set_as_integer (&tmp, 1);
- dbus_object_id_set_as_integer (&tmp2, 2);
- _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == -1);
- dbus_object_id_set_as_integer (&tmp2, 0);
- _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 1);
- dbus_object_id_set_as_integer (&tmp2, 1);
- _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 0);
-#endif
-
- /* Check comparison */
- tmp2 = tmp;
-
- dbus_object_id_set_server_bits (&tmp, 1);
- dbus_object_id_set_server_bits (&tmp2, 2);
- _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == -1);
- dbus_object_id_set_server_bits (&tmp2, 0);
- _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 1);
- dbus_object_id_set_server_bits (&tmp2, 1);
- _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 0);
-
- dbus_object_id_set_client_bits (&tmp, 1);
-
- dbus_object_id_set_client_bits (&tmp2, 2);
- _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == -1);
- dbus_object_id_set_client_bits (&tmp2, 0);
- _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 1);
- dbus_object_id_set_client_bits (&tmp2, 1);
- _dbus_assert (dbus_object_id_compare (&tmp, &tmp2) == 0);
-
- /* Check get/set again with high-limit numbers */
-
- dbus_object_id_set_server_bits (&tmp, 0xf0f0);
- _dbus_assert (dbus_object_id_get_server_bits (&tmp) == 0xf0f0);
-
- dbus_object_id_set_client_bits (&tmp, 0xf00f);
- _dbus_assert (dbus_object_id_get_client_bits (&tmp) == 0xf00f);
- _dbus_assert (dbus_object_id_get_server_bits (&tmp) == 0xf0f0);
-
- dbus_object_id_set_is_server_bit (&tmp, TRUE);
- _dbus_assert (dbus_object_id_get_client_bits (&tmp) == 0xf00f);
- _dbus_assert (dbus_object_id_get_server_bits (&tmp) == 0xf0f0);
- _dbus_assert (dbus_object_id_get_is_server_bit (&tmp) == TRUE);
-
- dbus_object_id_set_instance_bits (&tmp, 0x7fffffff);
- _dbus_assert (dbus_object_id_get_client_bits (&tmp) == 0xf00f);
- _dbus_assert (dbus_object_id_get_server_bits (&tmp) == 0xf0f0);
- _dbus_assert (dbus_object_id_get_is_server_bit (&tmp) == TRUE);
- _dbus_assert (dbus_object_id_get_instance_bits (&tmp) == 0x7fffffff);
-
- return TRUE;
-}
-
-#endif /* DBUS_BUILD_TESTS */
diff --git a/dbus/dbus-objectid.h b/dbus/dbus-objectid.h
deleted file mode 100644
index 9539f9be..00000000
--- a/dbus/dbus-objectid.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-objectid.h DBusObjectID type
- *
- * Copyright (C) 2003 Red Hat Inc.
- *
- * Licensed under the Academic Free License version 1.2
- *
- * 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
- *
- */
-#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION)
-#error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef DBUS_OBJECTID_H
-#define DBUS_OBJECTID_H
-
-#include <dbus/dbus-arch-deps.h>
-#include <dbus/dbus-types.h>
-
-DBUS_BEGIN_DECLS;
-
-typedef struct DBusObjectID DBusObjectID;
-
-struct DBusObjectID
-{
-#ifdef DBUS_HAVE_INT64
- dbus_uint64_t dbus_do_not_use_dummy1;
-#else
- dbus_uint32_t dbus_do_not_use_dummy2;
- dbus_uint32_t dbus_do_not_use_dummy3;
-#endif
-};
-
-dbus_bool_t dbus_object_id_equal (const DBusObjectID *a,
- const DBusObjectID *b);
-int dbus_object_id_compare (const DBusObjectID *a,
- const DBusObjectID *b);
-dbus_uint16_t dbus_object_id_get_server_bits (const DBusObjectID *obj_id);
-dbus_uint16_t dbus_object_id_get_client_bits (const DBusObjectID *obj_id);
-dbus_uint32_t dbus_object_id_get_connection_bits (const DBusObjectID *obj_id);
-dbus_bool_t dbus_object_id_get_is_server_bit (const DBusObjectID *obj_id);
-dbus_uint32_t dbus_object_id_get_instance_bits (const DBusObjectID *obj_id);
-void dbus_object_id_set_server_bits (DBusObjectID *obj_id,
- dbus_uint16_t value);
-void dbus_object_id_set_client_bits (DBusObjectID *obj_id,
- dbus_uint16_t value);
-void dbus_object_id_set_is_server_bit (DBusObjectID *obj_id,
- dbus_bool_t value);
-void dbus_object_id_set_instance_bits (DBusObjectID *obj_id,
- dbus_uint32_t value);
-void dbus_object_id_set_null (DBusObjectID *obj_id);
-dbus_bool_t dbus_object_id_is_null (const DBusObjectID *obj_id);
-
-#ifdef DBUS_HAVE_INT64
-dbus_uint64_t dbus_object_id_get_as_integer (const DBusObjectID *obj_id);
-void dbus_object_id_set_as_integer (DBusObjectID *obj_id,
- dbus_uint64_t value);
-#endif
-
-DBUS_END_DECLS;
-
-#endif /* DBUS_OBJECTID_H */
diff --git a/dbus/dbus-protocol.h b/dbus/dbus-protocol.h
index 21c06a76..a23d7466 100644
--- a/dbus/dbus-protocol.h
+++ b/dbus/dbus-protocol.h
@@ -53,9 +53,9 @@ extern "C" {
#define DBUS_TYPE_NAMED 10
#define DBUS_TYPE_ARRAY 11
#define DBUS_TYPE_DICT 12
-#define DBUS_TYPE_OBJECT_ID 13
+#define DBUS_TYPE_OBJECT_PATH 13
-#define DBUS_TYPE_LAST DBUS_TYPE_OBJECT_ID
+#define DBUS_TYPE_LAST DBUS_TYPE_OBJECT_PATH
/* Max length in bytes of a service or interface or member name */
#define DBUS_MAXIMUM_NAME_LENGTH 256
diff --git a/dbus/dbus-test.c b/dbus/dbus-test.c
index 2ab7fc27..259244ce 100644
--- a/dbus/dbus-test.c
+++ b/dbus/dbus-test.c
@@ -100,30 +100,12 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir)
check_memleaks ();
- printf ("%s: running object ID tests\n", "dbus-test");
- if (!_dbus_object_id_test ())
- die ("object ID");
-
- check_memleaks ();
-
- printf ("%s: running object registry tests\n", "dbus-test");
- if (!_dbus_object_registry_test ())
- die ("object registry");
-
- check_memleaks ();
-
printf ("%s: running object tree tests\n", "dbus-test");
if (!_dbus_object_tree_test ())
die ("object tree");
check_memleaks ();
- printf ("%s: running object tests\n", "dbus-test");
- if (!_dbus_object_test ())
- die ("object");
-
- check_memleaks ();
-
printf ("%s: running marshalling tests\n", "dbus-test");
if (!_dbus_marshal_test ())
die ("marshalling");
diff --git a/dbus/dbus-test.h b/dbus/dbus-test.h
index b6c02669..cbbc8638 100644
--- a/dbus/dbus-test.h
+++ b/dbus/dbus-test.h
@@ -53,9 +53,6 @@ dbus_bool_t _dbus_sysdeps_test (void);
dbus_bool_t _dbus_spawn_test (const char *test_data_dir);
dbus_bool_t _dbus_userdb_test (const char *test_data_dir);
dbus_bool_t _dbus_memory_test (void);
-dbus_bool_t _dbus_object_test (void);
-dbus_bool_t _dbus_object_id_test (void);
-dbus_bool_t _dbus_object_registry_test (void);
dbus_bool_t _dbus_object_tree_test (void);
dbus_bool_t _dbus_pending_call_test (const char *test_data_dir);
diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c
index 81c3fbfe..b604a397 100644
--- a/dbus/dbus-threads.c
+++ b/dbus/dbus-threads.c
@@ -227,7 +227,6 @@ init_global_locks (void)
LOCK_ADDR (message_slots),
LOCK_ADDR (atomic),
LOCK_ADDR (message_handler),
- LOCK_ADDR (callback_object),
LOCK_ADDR (bus),
LOCK_ADDR (shutdown_funcs),
LOCK_ADDR (system_users)
diff --git a/dbus/dbus.h b/dbus/dbus.h
index 12a087f5..051cb5fa 100644
--- a/dbus/dbus.h
+++ b/dbus/dbus.h
@@ -1,7 +1,7 @@
/* -*- mode: C; c-file-style: "gnu" -*- */
/* dbus.h Convenience header including all other headers
*
- * Copyright (C) 2002 Red Hat Inc.
+ * Copyright (C) 2002, 2003 Red Hat Inc.
*
* Licensed under the Academic Free License version 1.2
*
@@ -38,8 +38,6 @@
#include <dbus/dbus-macros.h>
#include <dbus/dbus-message.h>
#include <dbus/dbus-message-handler.h>
-#include <dbus/dbus-object.h>
-#include <dbus/dbus-objectid.h>
#include <dbus/dbus-pending-call.h>
#include <dbus/dbus-protocol.h>
#include <dbus/dbus-server.h>
diff --git a/glib/dbus-gproxy.c b/glib/dbus-gproxy.c
index 36f9724c..01a6b4b9 100644
--- a/glib/dbus-gproxy.c
+++ b/glib/dbus-gproxy.c
@@ -35,7 +35,7 @@ struct DBusGProxy
DBusConnection *connection;
char *service;
char *interface;
- DBusObjectID object_id;
+ char *path;
};
#define LOCK_PROXY(proxy) (g_static_mutex_lock (&(proxy)->lock))
@@ -248,7 +248,7 @@ dbus_gproxy_send (DBusGProxy *proxy,
{
/* FIXME */
}
- if (!dbus_object_id_is_null (&proxy->object_id))
+ if (proxy->path)
{
/* FIXME */
}
diff --git a/glib/dbus-gproxy.h b/glib/dbus-gproxy.h
index f40ce8a0..4e8f3f60 100644
--- a/glib/dbus-gproxy.h
+++ b/glib/dbus-gproxy.h
@@ -42,8 +42,8 @@ DBusGProxy* dbus_gproxy_new_for_service_owner (DBusConnection *connect
const char *service_name,
const char *interface_name,
GError **error);
-DBusGProxy* dbus_gproxy_new_for_object_id (DBusConnection *connection,
- const DBusObjectID *object_id,
+DBusGProxy* dbus_gproxy_new_for_object_path (DBusConnection *connection,
+ const char *path,
const char *interface_name);
DBusGProxy* dbus_gproxy_new_for_interface (DBusConnection *connection,
const char *interface_name);