![]() |
TO COMPLETE
Modules | |
obj_method | |
obj_signal | |
obj_interface | |
Data Structures | |
struct | EasyDbus_object |
EasyDbus_object object. More... | |
struct | EasyDbus_object_box |
EasyDbus_object_box object Box of visible EasyDbus_object. This struct is created when it is called easydbus_object_create_skeleton function and it is returned first field of this struct. More... | |
Functions | |
struct EasyDbus_object_box * | easydbus_get_obj (struct EasyDbus_object_box *objects, const char *object_path) |
Recover EasyDbus_object_box with object path passed in input from a list of objects. | |
int | easydbus_object_add_interface (EasyDbus_obj_interface *interface, EasyDbus_object *object) |
Add interface to EasyDbus_object object. | |
EasyDbus_object * | easydbus_object_create_skeleton (char *path, void *user_data) |
Create object skeleton for publish an object through DBUS. | |
void | easydbus_object_free_skeleton (EasyDbus_object *object) |
Free EasyDbus_object object and interfaces connect to it. | |
void * | easydbus_object_get_closure (EasyDbus_object *object) |
Get closure of EasyDbus_object object. | |
EasyDbus_obj_interface * | easydbus_object_get_interface (EasyDbus_object *object, unsigned int n) |
Get n-EasyDbus_obj_interface of object. | |
int | easydbus_object_get_n_interfaces (EasyDbus_object *object) |
Get path of an EasyDbus_object object. | |
const char * | easydbus_object_get_path (EasyDbus_object *object) |
Get path of an EasyDbus_object object. | |
int | easydbus_object_register (EasyDbus_conn *data, EasyDbus_object *object) |
Register object on DBus. | |
void | easydbus_object_set_closure (EasyDbus_object *object, void *user_data) |
Set closure of EasyDbus_object object. | |
int | easydbus_object_unregister (EasyDbus_conn *data, EasyDbus_object *object) |
Unregister EasyDbus_object object from DBus. | |
EasyDbus_reply * | easydbus_verify_match_and_prepare_reply (struct EasyDbus_obj_interface *interface, DBusMessage *msg, const char *msg_interface, const char *member_name, int *return_value) |
Found. |
struct EasyDbus_object_box* easydbus_get_obj | ( | struct EasyDbus_object_box * | objects, | |
const char * | object_path | |||
) | [read] |
Recover EasyDbus_object_box with object path passed in input from a list of objects.
For internal use only.
objects | list of objects | |
object_path | object path string of the object to found. |
NULL no object founded.
Definition at line 1077 of file utils.c.
References EasyDbus_object_box::core, EasyDbus_object_box::next, and EasyDbus_object::path.
Referenced by easydbus_obj_path_msg_function().
01079 { 01080 01081 while (objects != NULL) { 01082 if (!strcmp (object_path, objects->core.path)) 01083 return objects; 01084 objects = objects->next; 01085 } 01086 return NULL; 01087 }
int easydbus_object_add_interface | ( | EasyDbus_obj_interface * | interface, | |
EasyDbus_object * | object | |||
) |
Add interface to EasyDbus_object object.
interface | EasyDbus_obj_interface object pointer | |
object | EasyDbus_object object pointer |
0 ok
Definition at line 107 of file register_obj.c.
References EasyDbusDebug, EasyDbus_object::handled_interfaces, EasyDbus_obj_interface::name, EasyDbus_obj_interface::next, and EasyDbus_object::path.
00109 { 00110 struct EasyDbus_obj_interface *temp; 00111 00112 if (!interface || !object) 00113 return -1; 00114 00115 if (!object->handled_interfaces) 00116 object->handled_interfaces = interface; 00117 else { 00118 temp = object->handled_interfaces; 00119 while (temp->next) 00120 temp = temp->next; 00121 temp->next = interface; 00122 } 00123 00124 object->n_interfaces++; 00125 00126 EasyDbusDebug ("Added interface %s to object %s", 00127 interface->name, object->path); 00128 00129 return 0; 00130 }
EasyDbus_object* easydbus_object_create_skeleton | ( | char * | path, | |
void * | user_data | |||
) |
Create object skeleton for publish an object through DBUS.
path | path of object | |
user_data | pointer to user_data used on functions. |
pointer EasyDbus_object object.
Definition at line 59 of file register_obj.c.
References EasyDbus_object_box::core, EASYDBUS_MEMCOPY, EasyDbusDebug, and EasyDbus_object::path.
00060 { 00061 struct EasyDbus_object_box *object; 00062 int path_length; 00063 00064 if (!path) 00065 return NULL; 00066 00067 object = (struct EasyDbus_object_box *) 00068 malloc (sizeof (struct EasyDbus_object_box)); 00069 00070 if (!object) 00071 return NULL; 00072 memset (object, 0, sizeof (struct EasyDbus_object_box)); 00073 00074 path_length = strlen (path) + 1; 00075 00076 object->core.path = (char *) malloc (path_length); 00077 if (!object->core.path) 00078 goto out_of_memory; 00079 00080 EASYDBUS_MEMCOPY (object->core.path, path, path_length); 00081 00082 object->core.handled_interfaces = NULL; 00083 00084 if (user_data) 00085 object->core.user_data = user_data; 00086 00087 object->next = NULL; 00088 00089 EasyDbusDebug ("Create object core with" " path %s", path); 00090 00091 return (EasyDbus_object *) object; 00092 00093 out_of_memory: 00094 if (object) 00095 free (object); 00096 return NULL; 00097 }
void easydbus_object_free_skeleton | ( | EasyDbus_object * | object | ) |
Free EasyDbus_object object and interfaces connect to it.
object | EasyDbus_object object pointer |
Definition at line 296 of file register_obj.c.
References easydbus_obj_interface_free_skeleton(), EasyDbusDebug, EasyDbus_object::handled_interfaces, EasyDbus_obj_interface::next, and EasyDbus_object::path.
Referenced by easydbus_conn_destroy().
00297 { 00298 struct EasyDbus_obj_interface *interface; 00299 struct EasyDbus_object_box *obj = 00300 (struct EasyDbus_object_box *) object; 00301 00302 if (!object) 00303 return; 00304 00305 EasyDbusDebug ("Free of object skeleton %s", object->path); 00306 00307 if (object->path) 00308 free (object->path); 00309 00310 while (object->handled_interfaces) { 00311 interface = object->handled_interfaces; 00312 object->handled_interfaces = interface->next; 00313 easydbus_obj_interface_free_skeleton (interface); 00314 } 00315 00316 object->user_data = NULL; 00317 00318 free (obj); 00319 }
void* easydbus_object_get_closure | ( | EasyDbus_object * | object | ) | [inline] |
Get closure of EasyDbus_object object.
object | pointer to EasyDbus_object object. |
Definition at line 375 of file register_obj.c.
References EasyDbus_object::user_data.
00376 { 00377 return (object ? object->user_data : NULL); 00378 }
EasyDbus_obj_interface* easydbus_object_get_interface | ( | EasyDbus_object * | object, | |
unsigned int | n | |||
) |
Get n-EasyDbus_obj_interface of object.
object | pointer to EasyDbus_object object. | |
n | number of the interface to get. |
pointer to EasyDbus_obj_interface.
Definition at line 356 of file register_obj.c.
References EasyDbus_object::handled_interfaces, and EasyDbus_object_box::next.
00358 { 00359 unsigned int i; 00360 EasyDbus_obj_interface *ans = NULL; 00361 00362 if (object && ((int) n <= object->n_interfaces)) 00363 for (i = 0, ans = object->handled_interfaces; 00364 i < n; i++, ans = ans->next); 00365 00366 return ans; 00367 }
int easydbus_object_get_n_interfaces | ( | EasyDbus_object * | object | ) | [inline] |
Get path of an EasyDbus_object object.
object | EasyDbus_object object pointer. |
number of interfaces
Definition at line 340 of file register_obj.c.
References EasyDbus_object::n_interfaces.
00341 { 00342 return (object ? object->n_interfaces : -1); 00343 }
const char* easydbus_object_get_path | ( | EasyDbus_object * | object | ) | [inline] |
Get path of an EasyDbus_object object.
object | EasyDbus_object object pointer. |
object path string.
Definition at line 328 of file register_obj.c.
References EasyDbus_object::path.
00329 { 00330 return (object ? (const char *) object->path : NULL); 00331 }
int easydbus_object_register | ( | EasyDbus_conn * | data, | |
EasyDbus_object * | object | |||
) |
Register object on DBus.
data | EasyDbus_conn object pointer | |
object | EasyDbus_object object to register. |
-1 error
Definition at line 246 of file register_obj.c.
References EasyDbus_core::conn, EasyDbus_object_box::core, easydbus_obj_path_msg_function(), easydbus_obj_path_unregister_function(), EasyDbusDebug, EasyDbus_core::n_objs, EasyDbus_object_box::next, EasyDbus_core::objects, EasyDbus_object::path, and EasyDbus_object_box::vtable.
00248 { 00249 struct EasyDbus_core *core = (struct EasyDbus_core *) data; 00250 struct EasyDbus_object_box *obj = 00251 (struct EasyDbus_object_box *) object; 00252 struct EasyDbus_object_box *temp = NULL; 00253 00254 if (!object || !data) 00255 return -1; 00256 00257 memset (&obj->vtable, 0, sizeof (DBusObjectPathVTable)); 00258 00259 obj->vtable.message_function = easydbus_obj_path_msg_function; 00260 obj->vtable.unregister_function = 00261 easydbus_obj_path_unregister_function; 00262 obj->vtable.dbus_internal_pad1 = NULL; 00263 obj->vtable.dbus_internal_pad2 = NULL; 00264 00265 if (!dbus_connection_register_object_path (core->conn, 00266 (const char *) obj-> 00267 core.path, &obj->vtable, 00268 core)) { 00269 EasyDbusDebug ("Error on register object %s", obj->core.path); 00270 return -1; 00271 } 00272 temp = core->objects; 00273 00274 if (core->n_objs) { 00275 while (temp->next) 00276 temp = temp->next; 00277 temp->next = obj; 00278 } 00279 else 00280 core->objects = obj; 00281 core->n_objs++; 00282 00283 EasyDbusDebug ("Register object %s", obj->core.path); 00284 00285 return 0; 00286 }
void easydbus_object_set_closure | ( | EasyDbus_object * | object, | |
void * | user_data | |||
) | [inline] |
Set closure of EasyDbus_object object.
object | pointer to EasyDbus_object object. | |
user_data | user data closure pointer. |
Definition at line 386 of file register_obj.c.
int easydbus_object_unregister | ( | EasyDbus_conn * | data, | |
EasyDbus_object * | object | |||
) |
Unregister EasyDbus_object object from DBus.
data | EasyDbus_conn object pointer | |
object | EasyDbus_object object pointer. |
0 ok
Definition at line 140 of file register_obj.c.
References EasyDbus_core::conn, EasyDbus_object_box::core, and EasyDbus_object::path.
Referenced by easydbus_conn_destroy().
00142 { 00143 struct EasyDbus_core *core = (struct EasyDbus_core *) data; 00144 struct EasyDbus_object_box *obj = 00145 (struct EasyDbus_object_box *) object; 00146 00147 if (!object || !data) 00148 return -1; 00149 00150 if (dbus_connection_unregister_object_path 00151 (core->conn, (const char *) obj->core.path)) 00152 return -1; 00153 00154 return 0; 00155 }
EasyDbus_reply* easydbus_verify_match_and_prepare_reply | ( | struct EasyDbus_obj_interface * | interface, | |
DBusMessage * | msg, | |||
const char * | msg_interface, | |||
const char * | member_name, | |||
int * | return_value | |||
) |
Found.
interface | pointer to EasyDbus_obj_interface interface | |
msg | pointer to msg receive through DBUS. | |
msg_interface | interface name of msg. (can be equal to NULL) | |
member_name | string for member of msg | |
return_value | pointer to int where save result of function. |
NULL on error
Definition at line 179 of file register_obj_internal.c.
References EASYDBUS_ERROR, EASYDBUS_FAILURE_HANDLED, easydbus_method_build_skeleton(), easydbus_method_free_skeleton(), EASYDBUS_METHOD_HANDLED, EASYDBUS_METHOD_NOT_FOUND, easydbus_obj_interface_get_method(), EasyDbus_obj_method::method_callback, and EasyDbus_method::reply.
Referenced by easydbus_obj_path_msg_function().
00182 { 00183 int callback_retvalue; 00184 struct EasyDbus_obj_method *method = NULL; 00185 EasyDbus_method *method_skeleton = NULL; 00186 EasyDbus_reply *reply = NULL; 00187 00188 // manage method request 00189 method = easydbus_obj_interface_get_method (member_name, 00190 msg_interface, 00191 interface); 00192 if (!method) { 00193 *return_value = EASYDBUS_METHOD_NOT_FOUND; 00194 goto not_found; 00195 } 00196 00197 method_skeleton = easydbus_method_build_skeleton (msg); 00198 if (!method_skeleton) { 00199 *return_value = EASYDBUS_ERROR; 00200 goto not_found; 00201 } 00202 callback_retvalue = (int) 00203 method->method_callback (method_skeleton); 00204 // see if manage failure in this mannaer 00205 if (callback_retvalue == EASYDBUS_METHOD_HANDLED) { 00206 reply = method_skeleton->reply; 00207 *return_value = callback_retvalue; 00208 } 00209 else if (callback_retvalue == EASYDBUS_FAILURE_HANDLED) 00210 if (method_skeleton->reply) { 00211 reply = method_skeleton->reply; 00212 *return_value = callback_retvalue; 00213 } 00214 method_skeleton->reply = NULL; 00215 easydbus_method_free_skeleton (method_skeleton); 00216 00217 return reply; 00218 00219 not_found: 00220 00221 return NULL; 00222 }