![]() |
TO COMPLETE
Data Structures | |
struct | EasyDbus_method |
EasyDbus_method object. More... | |
Functions | |
EasyDbus_method * | easydbus_method_create_skeleton (char *destination, char *path, char *interface, char *method) |
Create EasyDbus_method object skeleton. | |
void | easydbus_method_free_skeleton (EasyDbus_method *method) |
Free a EasyDbus_method object. | |
int | easydbus_method_get_args (EasyDbus_method *method) |
Get number of args on EasyDbus_method object. | |
const char * | easydbus_method_get_destination (EasyDbus_method *method) |
Get destination of method. | |
const EasyDbus_elem * | easydbus_method_get_element (EasyDbus_method *method, unsigned int n) |
Get N-element of EasyDbus_method object. | |
const char * | easydbus_method_get_interface (EasyDbus_method *method) |
Get interface of method. | |
const char * | easydbus_method_get_name (EasyDbus_method *method) |
Get name of method. | |
const char * | easydbus_method_get_path (EasyDbus_method *method) |
Get path of method. | |
const EasyDbus_reply * | easydbus_method_get_reply (EasyDbus_method *method) |
Get method reply message pointer from method. | |
int | easydbus_method_send_async (EasyDbus_conn *conn, EasyDbus_method *method, void *closure) |
Call method and blocking for a reply. | |
int | easydbus_method_send_async_with_notify (EasyDbus_conn *conn, EasyDbus_method *method, easydbus_method_async_reply_cb_f r_cb, void *closure, int timeout) |
Call method message async and notify a reply or a timeout. | |
enum easydbus_ret_values | easydbus_method_send_blocking (EasyDbus_conn *conn, EasyDbus_method *method, int timeout) |
Call method and blocking for a reply. | |
int | easydbus_method_set_reply (EasyDbus_method *method, EasyDbus_reply *reply) |
Set method reply message. |
EasyDbus_method* easydbus_method_create_skeleton | ( | char * | destination, | |
char * | path, | |||
char * | interface, | |||
char * | method | |||
) |
Create EasyDbus_method object skeleton.
destination | destination of method call | |
path | path of method | |
interface | interface of method | |
method | method name |
NULL error
Definition at line 134 of file method.c.
References EasyDbus_method::destination, EASYDBUS_MEMCOPY, EasyDbus_method::first, EasyDbus_method::interface, EasyDbus_method::name, EasyDbus_method::path, EasyDbus_method::reply, and EasyDbus_method::retry.
Referenced by easydbus_method_build_skeleton().
00137 { 00138 int len = 0; 00139 struct EasyDbus_method *m = NULL; 00140 00141 m = (struct EasyDbus_method *) 00142 malloc (sizeof (struct EasyDbus_method)); 00143 00144 if (m == NULL || path == NULL) 00145 return NULL; 00146 00147 memset (m, 0, sizeof (struct EasyDbus_method)); 00148 00149 m->name = m->path = m->destination = m->interface = NULL; 00150 m->first = NULL; 00151 m->reply = NULL; 00152 m->retry = 0; 00153 00154 len = strlen (method) + 1; 00155 m->name = (char *) malloc (len); 00156 if (!m->name) 00157 goto out_of_memory_error; 00158 EASYDBUS_MEMCOPY (m->name, method, len) 00159 00160 if (interface) { 00161 len = strlen (interface) + 1; 00162 m->interface = (char *) malloc (len); 00163 if (!m->interface) 00164 goto out_of_memory_error; 00165 EASYDBUS_MEMCOPY (m->interface, interface, len); 00166 } 00167 00168 len = strlen (path) + 1; 00169 m->path = (char *) malloc (len); 00170 if (!m->path) 00171 goto out_of_memory_error; 00172 EASYDBUS_MEMCOPY (m->path, path, len); 00173 00174 if (destination) { 00175 len = strlen (destination) + 1; 00176 m->destination = (char *) malloc (len); 00177 if (!m->destination) 00178 goto out_of_memory_error; 00179 EASYDBUS_MEMCOPY (m->destination, destination, len); 00180 } 00181 00182 return m; 00183 00184 out_of_memory_error: 00185 if (m->path) 00186 free (m->path); 00187 if (m->interface) 00188 free (m->interface); 00189 if (m->name) 00190 free (m->name); 00191 if (m) 00192 free (m); 00193 return NULL; 00194 }
void easydbus_method_free_skeleton | ( | EasyDbus_method * | method | ) | [inline] |
Free a EasyDbus_method object.
method | EasyDbus_method object pointer. |
Definition at line 57 of file method.c.
References EasyDbus_method::args, EasyDbus_method::destination, easydbus_elem_free(), easydbus_reply_free_skeleton(), EasyDbus_method::first, EasyDbus_method::interface, EasyDbus_method::name, EasyDbus_elem::next, EasyDbus_method::path, and EasyDbus_method::reply.
Referenced by easydbus_method_build_skeleton(), easydbus_pending_destroy(), easydbus_verify_match_and_prepare_reply(), and easydbus_watch_method_blocking().
00058 { 00059 struct EasyDbus_elem *el = NULL; 00060 00061 if (method == NULL) 00062 return; 00063 00064 if (method->name != NULL) 00065 free (method->name); 00066 if (method->path != NULL) 00067 free (method->path); 00068 if (method->destination != NULL) 00069 free (method->destination); 00070 if (method->interface != NULL) 00071 free (method->interface); 00072 00073 method->name = method->path = method->interface = NULL; 00074 00075 while (method->args) { 00076 if (method->first != NULL) { 00077 el = method->first; 00078 method->first = method->first->next; 00079 easydbus_elem_free (el); 00080 } 00081 method->args--; 00082 } 00083 00084 if (method->reply != NULL) 00085 easydbus_reply_free_skeleton (method->reply); 00086 00087 free (method); 00088 }
int easydbus_method_get_args | ( | EasyDbus_method * | method | ) |
Get number of args on EasyDbus_method object.
method | EasyDbus_method object pointer |
number of args on EasyDbus_method object.
Definition at line 303 of file method.c.
References EasyDbus_method::args.
00304 { 00305 return (method ? method->args : -1); 00306 }
const char* easydbus_method_get_destination | ( | EasyDbus_method * | method | ) |
Get destination of method.
method | EasyDbus_method object pointer |
NULL on error or no interface set.
Definition at line 289 of file method.c.
References EasyDbus_method::destination.
00290 { 00291 return (method ? (const char *) method->destination : NULL); 00292 }
const EasyDbus_elem* easydbus_method_get_element | ( | EasyDbus_method * | method, | |
unsigned int | n | |||
) |
Get N-element of EasyDbus_method object.
method | EasyDbus_method object pointer | |
n | element to recover. |
pointer to n-EasyDbus_elem of signal.
Definition at line 319 of file method.c.
References EasyDbus_method::args, easydbus_elem_get_element(), and EasyDbus_method::first.
00320 { 00321 return ((!method || n > method->args) ? NULL : 00322 easydbus_elem_get_element (method->first, n)); 00323 }
const char* easydbus_method_get_interface | ( | EasyDbus_method * | method | ) |
Get interface of method.
method | EasyDbus_method object pointer |
NULL on error or no interface set.
Definition at line 247 of file method.c.
References EasyDbus_method::interface.
00248 { 00249 return (method ? (const char *) method->interface : NULL); 00250 }
const char* easydbus_method_get_name | ( | EasyDbus_method * | method | ) |
Get name of method.
method | EasyDbus_method object pointer |
NULL on error or no interface set.
Definition at line 261 of file method.c.
References EasyDbus_method::name.
00262 { 00263 return (method ? (const char *) method->name : NULL); 00264 }
const char* easydbus_method_get_path | ( | EasyDbus_method * | method | ) |
Get path of method.
method | EasyDbus_method object pointer |
NULL on error or no interface set.
Definition at line 275 of file method.c.
References EasyDbus_method::path.
00276 { 00277 return (method ? (const char *) method->path : NULL); 00278 }
const EasyDbus_reply* easydbus_method_get_reply | ( | EasyDbus_method * | method | ) | [inline] |
Get method reply message pointer from method.
method | EasyDbus_method object pointer |
NULL on error or if there is a reply.
Definition at line 116 of file method.c.
References EasyDbus_method::reply.
00117 { 00118 if (method == NULL) 00119 return NULL; 00120 00121 return method->reply; 00122 }
int easydbus_method_send_async | ( | EasyDbus_conn * | conn, | |
EasyDbus_method * | method, | |||
void * | closure | |||
) |
Call method and blocking for a reply.
0 message in outgoing queue
conn | EasyDbus_conn object pointer | |
method | method to sent that is free from library. | |
closure | user closure passed to CALLBACK |
see if this is needed
Definition at line 423 of file method.c.
References create_method_msg(), easydbus_message_send(), easydbus_pending_create_skeleton(), easydbus_pending_destroy(), EasyDbusDebug, EasyDbus_Pending::message, EasyDbus_Pending::message_serial, EasyDbus_Pending::next, and EasyDbus_core::pending_msgs.
00426 { 00427 struct EasyDbus_core *core = 00428 (struct EasyDbus_core *) conn; 00429 struct EasyDbus_Pending *p = NULL; 00430 DBusMessage *msg = NULL; 00431 00432 if (!conn || !method) 00433 return -1; 00434 00435 p = easydbus_pending_create_skeleton (core, method, NULL, 00436 closure, 0); 00437 if (!p) goto error; 00438 00439 msg = create_method_msg (core, method); 00440 00441 if (!msg) { 00442 EasyDbusDebug ("Error on create method message"); 00443 goto error; 00444 } 00445 00446 if (easydbus_message_send(core, msg, 0, &p->message_serial)) { 00447 EasyDbusDebug ("Error on send message"); 00448 goto error; 00449 } 00450 00451 // add EasyDbus_Pending object to list 00452 if (core->pending_msgs) 00453 p->next = core->pending_msgs; 00454 core->pending_msgs = p; 00455 00456 dbus_message_unref (msg); 00457 00458 return 0; 00459 error: 00460 if (p) { 00462 p->message = NULL; 00463 easydbus_pending_destroy (p); 00464 } 00465 if (msg) 00466 dbus_message_unref(msg); 00467 00468 return -1; 00469 }
int easydbus_method_send_async_with_notify | ( | EasyDbus_conn * | conn, | |
EasyDbus_method * | method, | |||
easydbus_method_async_reply_cb_f | r_cb, | |||
void * | closure, | |||
int | timeout | |||
) |
Call method message async and notify a reply or a timeout.
conn | EasyDbus_conn object pointer | |
method | EasyDbus_method object pointer with method to call. | |
r_cb | user callback called on | |
closure | user closure passed to callback | |
timeout | timeout on wait reply. -1 is default value. |
0 message insert on outgoing queue.
see if this is needed
Definition at line 370 of file method.c.
References create_method_msg(), easydbus_message_send_async(), easydbus_pending_create_skeleton(), easydbus_pending_destroy(), EasyDbus_Pending::message, EasyDbus_Pending::next, and EasyDbus_core::pending_msgs.
00375 { 00376 DBusMessage *msg = NULL; 00377 struct EasyDbus_core *core = 00378 (struct EasyDbus_core *) conn; 00379 struct EasyDbus_Pending *p = NULL; 00380 00381 if (!conn || !method || !r_cb) 00382 return -1; 00383 00384 p = easydbus_pending_create_skeleton (core, method, r_cb, 00385 closure, timeout); 00386 if (!p) goto error; 00387 00388 msg = create_method_msg (core, method); 00389 if (!msg) goto error; 00390 00391 if (easydbus_message_send_async(core, p, msg)) 00392 goto error; 00393 00394 // add EasyDbus_Pending object to list 00395 if (core->pending_msgs) 00396 p->next = core->pending_msgs; 00397 core->pending_msgs = p; 00398 00399 dbus_message_unref (msg); 00400 return 0; 00401 00402 error: 00403 if (p) { 00405 p->message = NULL; 00406 easydbus_pending_destroy (p); 00407 } 00408 if (msg) 00409 dbus_message_unref(msg); 00410 return -1; 00411 }
enum easydbus_ret_values easydbus_method_send_blocking | ( | EasyDbus_conn * | conn, | |
EasyDbus_method * | method, | |||
int | timeout | |||
) |
Call method and blocking for a reply.
EASYDBUS_METHOD_NOT_SENT method not sent.
EASYDBUS_METHOD_SENT method sent
conn | EasyDbus_conn object pointer | |
method | method to sent | |
timeout | timeout value. -1 (wait until receive reply) |
Definition at line 482 of file method.c.
References create_method_msg(), EASYDBUS_ERROR, EASYDBUS_METHOD_NOT_SENT, EASYDBUS_METHOD_SENT, easydbus_send_method_withReply_Blocking(), and EasyDbusDebug.
00485 { 00486 struct EasyDbus_core *core = 00487 (struct EasyDbus_core *) conn; 00488 int ret_val = EASYDBUS_METHOD_NOT_SENT; 00489 00490 if (!conn || !method) 00491 return EASYDBUS_ERROR; 00492 00493 DBusMessage *msg = create_method_msg (core, method); 00494 00495 if (!msg) { 00496 EasyDbusDebug ("Error on create method message"); 00497 return EASYDBUS_ERROR; 00498 } 00499 00500 if (!easydbus_send_method_withReply_Blocking 00501 (core, msg, method, timeout)) 00502 ret_val = EASYDBUS_METHOD_SENT; 00503 00504 dbus_message_unref (msg); 00505 00506 return ret_val; 00507 }
int easydbus_method_set_reply | ( | EasyDbus_method * | method, | |
EasyDbus_reply * | reply | |||
) | [inline] |
Set method reply message.
method | pointer to EasyDbus_method object | |
reply | pointer to EasyDbus_reply object |
0 ok
Definition at line 98 of file method.c.
References EasyDbus_method::reply.
00100 { 00101 if (reply == NULL || method == NULL) 00102 return -1; 00103 00104 method->reply = reply; 00105 00106 return 0; 00107 }