D-Bus 1.14.10
Data Structures | Macros | Typedefs | Functions
A hierarchy of objects with container-contained relationship

DBusObjectTree is used by DBusConnection to track the object tree. More...

Data Structures

struct  DBusObjectTree
 Internals of DBusObjectTree. More...
 
struct  DBusObjectSubtree
 Struct representing a single registered subtree handler, or node that's a parent of a registered subtree handler. More...
 

Macros

#define VERBOSE_FIND   0
 Set to 1 to get a bunch of debug spew about finding the subtree nodes. More...
 
#define VERBOSE_DECOMPOSE   0
 Set to 1 to get a bunch of spew about disassembling the path string. More...
 

Typedefs

typedef struct DBusObjectSubtree DBusObjectSubtree
 Subnode of the object hierarchy. More...
 

Functions

DBusObjectTree_dbus_object_tree_new (DBusConnection *connection)
 Creates a new object tree, representing a mapping from paths to handler vtables. More...
 
DBusObjectTree_dbus_object_tree_ref (DBusObjectTree *tree)
 Increment the reference count. More...
 
void _dbus_object_tree_unref (DBusObjectTree *tree)
 Decrement the reference count. More...
 
dbus_bool_t _dbus_object_tree_register (DBusObjectTree *tree, dbus_bool_t fallback, const char **path, const DBusObjectPathVTable *vtable, void *user_data, DBusError *error)
 Registers a new subtree in the global object tree. More...
 
void _dbus_object_tree_unregister_and_unlock (DBusObjectTree *tree, const char **path)
 Unregisters an object subtree that was registered with the same path. More...
 
void _dbus_object_tree_free_all_unlocked (DBusObjectTree *tree)
 Free all the handlers in the tree. More...
 
DBusHandlerResult _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, DBusMessage *message, dbus_bool_t *found_object)
 Tries to dispatch a message by directing it to handler for the object path listed in the message header, if any. More...
 
void * _dbus_object_tree_get_user_data_unlocked (DBusObjectTree *tree, const char **path)
 Looks up the data passed to _dbus_object_tree_register() for a handler at the given path. More...
 
dbus_bool_t _dbus_object_tree_list_registered_and_unlock (DBusObjectTree *tree, const char **parent_path, char ***child_entries)
 Lists the registered fallback handlers and object path handlers at the given parent_path. More...
 
dbus_bool_t _dbus_decompose_path (const char *data, int len, char ***path, int *path_len)
 Decompose an object path. More...
 

Detailed Description

DBusObjectTree is used by DBusConnection to track the object tree.

Types and functions related to DBusObjectTree. These are all library-internal.

Macro Definition Documentation

◆ VERBOSE_DECOMPOSE

#define VERBOSE_DECOMPOSE   0

Set to 1 to get a bunch of spew about disassembling the path string.

Definition at line 1232 of file dbus-object-tree.c.

◆ VERBOSE_FIND

#define VERBOSE_FIND   0

Set to 1 to get a bunch of debug spew about finding the subtree nodes.

Definition at line 161 of file dbus-object-tree.c.

Typedef Documentation

◆ DBusObjectSubtree

Subnode of the object hierarchy.

Definition at line 47 of file dbus-object-tree.c.

Function Documentation

◆ _dbus_decompose_path()

dbus_bool_t _dbus_decompose_path ( const char *  data,
int  len,
char ***  path,
int *  path_len 
)

Decompose an object path.

A path of just "/" is represented as an empty vector of strings. The path need not be nul terminated.

Parameters
datathe path data
lenthe length of the path string
pathaddress to store new object path
path_lenlength of stored path

Definition at line 1245 of file dbus-object-tree.c.

References _dbus_assert, _dbus_memdup(), dbus_free_string_array(), dbus_new0, FALSE, NULL, and TRUE.

Referenced by dbus_connection_get_object_path_data(), dbus_connection_list_registered(), dbus_connection_unregister_object_path(), and dbus_message_get_path_decomposed().

◆ _dbus_object_tree_dispatch_and_unlock()

DBusHandlerResult _dbus_object_tree_dispatch_and_unlock ( DBusObjectTree tree,
DBusMessage message,
dbus_bool_t found_object 
)

Tries to dispatch a message by directing it to handler for the object path listed in the message header, if any.

Messages are dispatched first to the registered handler that matches the largest number of path elements; that is, message to /foo/bar/baz would go to the handler for /foo/bar before the one for /foo.

Parameters
treethe global object tree
messagethe message to dispatch
found_objectreturn location for the object
Returns
whether message was handled successfully

Definition at line 906 of file dbus-object-tree.c.

References _dbus_connection_unlock(), connection, DBUS_HANDLER_RESULT_NEED_MEMORY, DBUS_HANDLER_RESULT_NOT_YET_HANDLED, dbus_message_get_path_decomposed(), and NULL.

◆ _dbus_object_tree_free_all_unlocked()

void _dbus_object_tree_free_all_unlocked ( DBusObjectTree tree)

Free all the handlers in the tree.

Lock on tree's connection must not be held.

Parameters
treethe object tree

Definition at line 721 of file dbus-object-tree.c.

References root.

Referenced by _dbus_object_tree_unref().

◆ _dbus_object_tree_get_user_data_unlocked()

void * _dbus_object_tree_get_user_data_unlocked ( DBusObjectTree tree,
const char **  path 
)

Looks up the data passed to _dbus_object_tree_register() for a handler at the given path.

Parameters
treethe global object tree
pathNULL-terminated array of path elements giving path to subtree
Returns
the object's user_data or NULL if none found

Definition at line 1078 of file dbus-object-tree.c.

References _dbus_assert, and NULL.

Referenced by dbus_connection_get_object_path_data().

◆ _dbus_object_tree_list_registered_and_unlock()

dbus_bool_t _dbus_object_tree_list_registered_and_unlock ( DBusObjectTree tree,
const char **  parent_path,
char ***  child_entries 
)

Lists the registered fallback handlers and object path handlers at the given parent_path.

The returned array should be freed with dbus_free_string_array().

Parameters
treethe object tree
parent_paththe path to list the child handlers of
child_entriesreturns NULL-terminated array of children
Returns
FALSE if no memory to allocate the child entries

Definition at line 1209 of file dbus-object-tree.c.

Referenced by dbus_connection_list_registered().

◆ _dbus_object_tree_new()

DBusObjectTree * _dbus_object_tree_new ( DBusConnection connection)

Creates a new object tree, representing a mapping from paths to handler vtables.

Parameters
connectionthe connection this tree belongs to
Returns
the new tree or NULL if no memory

Definition at line 93 of file dbus-object-tree.c.

References connection, dbus_new0, NULL, refcount, and root.

◆ _dbus_object_tree_ref()

DBusObjectTree * _dbus_object_tree_ref ( DBusObjectTree tree)

Increment the reference count.

Parameters
treethe object tree
Returns
the object tree

Definition at line 130 of file dbus-object-tree.c.

References _dbus_assert, and refcount.

◆ _dbus_object_tree_register()

dbus_bool_t _dbus_object_tree_register ( DBusObjectTree tree,
dbus_bool_t  fallback,
const char **  path,
const DBusObjectPathVTable vtable,
void *  user_data,
DBusError error 
)

Registers a new subtree in the global object tree.

Parameters
treethe global object tree
fallbackTRUE to handle messages to children of this path
pathNULL-terminated array of path elements giving path to subtree
vtablethe vtable used to traverse this subtree
user_datauser data to pass to methods in the vtable
erroraddress where an error can be returned
Returns
FALSE if an error (DBUS_ERROR_NO_MEMORY or DBUS_ERROR_OBJECT_PATH_IN_USE) is reported

Definition at line 394 of file dbus-object-tree.c.

References _dbus_assert, DBusObjectPathVTable::message_function, and NULL.

◆ _dbus_object_tree_unref()

void _dbus_object_tree_unref ( DBusObjectTree tree)

Decrement the reference count.

Parameters
treethe object tree

Definition at line 144 of file dbus-object-tree.c.

References _dbus_assert, _dbus_object_tree_free_all_unlocked(), dbus_free(), and refcount.

◆ _dbus_object_tree_unregister_and_unlock()

void _dbus_object_tree_unregister_and_unlock ( DBusObjectTree tree,
const char **  path 
)

Unregisters an object subtree that was registered with the same path.

Parameters
treethe global object tree
pathpath to the subtree (same as the one passed to _dbus_object_tree_register())

Definition at line 626 of file dbus-object-tree.c.

References _dbus_assert, NULL, and TRUE.

Referenced by dbus_connection_unregister_object_path().