mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-01-07 19:20:20 +01:00
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
This commit is contained in:
parent
24f411a6a1
commit
8d38a2e2c5
24 changed files with 172 additions and 2672 deletions
17
ChangeLog
17
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
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "dbus-bus.h"
|
||||
#include "dbus-protocol.h"
|
||||
#include "dbus-internals.h"
|
||||
#include "dbus-message.h"
|
||||
#include <string.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);
|
||||
|
|
|
|||
|
|
@ -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_return_val_if_fail (connection != 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);
|
||||
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);
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -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 */
|
||||
|
|
@ -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;
|
||||
|
|
@ -381,10 +381,27 @@ _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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
@ -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 */
|
||||
|
|
@ -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 */
|
||||
|
|
@ -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 */
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue