diff options
Diffstat (limited to 'src/lib/include/gnunet_dbus_lib_object.h')
-rw-r--r-- | src/lib/include/gnunet_dbus_lib_object.h | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/src/lib/include/gnunet_dbus_lib_object.h b/src/lib/include/gnunet_dbus_lib_object.h new file mode 100644 index 0000000..3264494 --- /dev/null +++ b/src/lib/include/gnunet_dbus_lib_object.h | |||
@@ -0,0 +1,125 @@ | |||
1 | #ifndef GNUNET_DBUS_LIB_OBJECT_H | ||
2 | #define GNUNET_DBUS_LIB_OBJECT_H | ||
3 | |||
4 | /** | ||
5 | * Represents a DBus object advertised on a DBus service. Objects are named and | ||
6 | * exist in a tree. For example, the object at the path | ||
7 | * /org/freedesktop/PolicyKit1/Authority is named Authority and sits in a | ||
8 | * heirarchy below four other objects including the service's root object. Each | ||
9 | * object has a set of interfaces and can be associated with an arbitrary piece | ||
10 | * of data. | ||
11 | */ | ||
12 | struct GNUNET_DBUS_Object; | ||
13 | |||
14 | #include "gnunet_dbus_lib_interface.h" | ||
15 | |||
16 | /** | ||
17 | * An iterable, doubly-linked-list of GNUNET_DBUS_Object. | ||
18 | */ | ||
19 | struct GNUNET_DBUS_ObjectIterator | ||
20 | { | ||
21 | /* linked list */ | ||
22 | struct GNUNET_DBUS_ObjectIterator *next; | ||
23 | struct GNUNET_DBUS_ObjectIterator *prev; | ||
24 | |||
25 | struct GNUNET_DBUS_Object *object; | ||
26 | }; | ||
27 | |||
28 | /** | ||
29 | * Create a new GNUNET_DBUS_Object with the given name and associated data. For | ||
30 | * example, the object that exists at the path | ||
31 | * /org/freedesktop/PolicyKit1/Authority has the name Authority and sits below | ||
32 | * four other objects including the service's root object. | ||
33 | */ | ||
34 | struct GNUNET_DBUS_Object * | ||
35 | GNUNET_DBUS_object_create ( | ||
36 | const char *name, | ||
37 | void *data); | ||
38 | |||
39 | /** | ||
40 | * Increase the reference count of this GNUNET_DBUS_Object by one. | ||
41 | */ | ||
42 | void | ||
43 | GNUNET_DBUS_object_ref ( | ||
44 | struct GNUNET_DBUS_Object *object); | ||
45 | |||
46 | /** | ||
47 | * Decrease the reference count of this GNUNET_DBUS_Object by one. Will free | ||
48 | * the GNUNET_DBUS_Object if the reference count reaches zero. | ||
49 | */ | ||
50 | void | ||
51 | GNUNET_DBUS_object_unref ( | ||
52 | struct GNUNET_DBUS_Object *object); | ||
53 | |||
54 | /** | ||
55 | * Get the name of this GNUNET_DBUS_Object. | ||
56 | */ | ||
57 | const char * | ||
58 | GNUNET_DBUS_object_get_name ( | ||
59 | const struct GNUNET_DBUS_Object *object); | ||
60 | |||
61 | /** | ||
62 | * Add an interface to this GNUNET_DBUS_Object. | ||
63 | */ | ||
64 | void | ||
65 | GNUNET_DBUS_object_add_interface ( | ||
66 | struct GNUNET_DBUS_Object *object, | ||
67 | struct GNUNET_DBUS_Interface *interface); | ||
68 | |||
69 | /** | ||
70 | * Iterate over the interfaces of this GNUNET_DBUS_Object. | ||
71 | */ | ||
72 | const struct GNUNET_DBUS_InterfaceIterator * | ||
73 | GNUNET_DBUS_object_iterate_interfaces ( | ||
74 | struct GNUNET_DBUS_Object *object); | ||
75 | |||
76 | /** | ||
77 | * Get the data associated with this GNUNET_DBUS_Object. | ||
78 | */ | ||
79 | void * | ||
80 | GNUNET_DBUS_object_get_data ( | ||
81 | struct GNUNET_DBUS_Object *object); | ||
82 | |||
83 | /** | ||
84 | * Create an object with a randomly generated name, associate data with it, and | ||
85 | * add it as a child to the given object. Returns the newly created object. | ||
86 | */ | ||
87 | struct GNUNET_DBUS_Object * | ||
88 | GNUNET_DBUS_object_create_uniquely_named_subobject ( | ||
89 | struct GNUNET_DBUS_Object *object, | ||
90 | void *data); | ||
91 | |||
92 | /** | ||
93 | * Add subobject as a child of object. | ||
94 | */ | ||
95 | void | ||
96 | GNUNET_DBUS_object_add_subobject ( | ||
97 | struct GNUNET_DBUS_Object *object, | ||
98 | struct GNUNET_DBUS_Object *subobject); | ||
99 | |||
100 | /** | ||
101 | * Remove the object pointed to by subobject_it as a child from object. | ||
102 | */ | ||
103 | void | ||
104 | GNUNET_DBUS_object_remove_subobject ( | ||
105 | struct GNUNET_DBUS_Object *object, | ||
106 | struct GNUNET_DBUS_ObjectIterator *subobject_it); | ||
107 | |||
108 | /** | ||
109 | * Iterate over an object's child objects. | ||
110 | */ | ||
111 | struct GNUNET_DBUS_ObjectIterator * | ||
112 | GNUNET_DBUS_object_iterate_subobjects ( | ||
113 | const struct GNUNET_DBUS_Object *object); | ||
114 | |||
115 | /** | ||
116 | * Search the given linked list of GNUNET_DBUS_Object for an object with the | ||
117 | * given name and return an iterator to it. | ||
118 | */ | ||
119 | const struct GNUNET_DBUS_ObjectIterator * | ||
120 | GNUNET_DBUS_object_find ( | ||
121 | const struct GNUNET_DBUS_ObjectIterator *object_it, | ||
122 | const char *name); | ||
123 | |||
124 | #endif | ||
125 | |||