![]() |
This module is under hard development phase and could be change completly.
Modules | |
watcher | |
Functions | |
int | easydbus_object_handle_message (EasyDbus_conn *data, int event_fd) |
Handle message where it is handled an event. | |
int | easydbus_object_main_loop (EasyDbus_conn *data) |
Easydbus main loop function. | |
enum easydbus_ret_values | easydbus_watch_method_blocking (EasyDbus_conn *conn, EasyDbus_method *method_container, int timeout) |
Wait for a method with blocking mode. | |
enum easydbus_ret_values | easydbus_watch_signal_blocking (EasyDbus_conn *data, EasyDbus_signal *signal_container, int timeout) |
Wait for a signal with blocking mode. |
int easydbus_object_handle_message | ( | EasyDbus_conn * | data, | |
int | event_fd | |||
) |
Handle message where it is handled an event.
data | pointer to EasyDbus_conn object | |
event_fd | event file descriptor where manage message. |
0 ok
Definition at line 73 of file watch_events.c.
References EasyDbus_core::conn, easydbus_watcher_get_from_fd(), EASYDBUS_WATCHER_READABLE, EasyDbusDebug, EasyDbus_watcher::watch, and EasyDbus_core::watcher.
00075 { 00076 struct EasyDbus_core *core = (struct EasyDbus_core *) data; 00077 struct EasyDbus_watcher *watch = NULL; 00078 int ret_val; 00079 00080 if (data == NULL || event_fd < 0) 00081 return -1; 00082 00083 watch = easydbus_watcher_get_from_fd (core->watcher, event_fd, 00084 EASYDBUS_WATCHER_READABLE); 00085 if (watch == NULL) 00086 return -1; 00087 00088 do { 00089 if (!dbus_watch_get_enabled (watch->watch)) { 00090 EasyDbusDebug ("Watch not enabled"); 00091 return -1; 00092 } 00093 else 00094 dbus_watch_handle (watch->watch, DBUS_WATCH_READABLE); 00095 ret_val = dbus_connection_dispatch (core->conn); 00096 // this permit to call dbus_connection_dispatch 00097 // in the next step. See if it is needed a sleep. 00098 if (ret_val == DBUS_DISPATCH_NEED_MEMORY) 00099 return 0; 00100 } while (ret_val == DBUS_DISPATCH_DATA_REMAINS); 00101 00102 return 0; 00103 }
int easydbus_object_main_loop | ( | EasyDbus_conn * | data | ) |
Easydbus main loop function.
data | pointer to EasyDbus_conn object |
0 ok
Definition at line 112 of file watch_events.c.
References EasyDbus_core::conn, EasyDbus_object_box::core, EasyDbusDebug, EasyDbus_core::objects, and EasyDbus_core::user_data.
00113 { 00114 struct EasyDbus_core *core = (struct EasyDbus_core *) data; 00115 void *user_data; 00116 00117 if (core == NULL || core->objects == NULL) 00118 return -1; 00119 00120 if (!dbus_connection_get_object_path_data (core->conn, 00121 core->objects->core. 00122 path, &user_data)) { 00123 EasyDbusDebug ("Error on recover user data"); 00124 return -1; 00125 } 00126 00127 if (user_data != (void *) core) { 00128 EasyDbusDebug ("User data pointer wrong!"); 00129 } 00130 EasyDbusDebug ("User data pointer is correct!"); 00131 00132 while (1) 00133 dbus_connection_read_write_dispatch (core->conn, -1); 00134 00135 return 0; 00136 }
enum easydbus_ret_values easydbus_watch_method_blocking | ( | EasyDbus_conn * | conn, | |
EasyDbus_method * | method_container, | |||
int | timeout | |||
) |
Wait for a method with blocking mode.
method_container | method to handled. | |
conn | pointer to struct EasyDbus_conn object. | |
timeout | Timeout for wait call. -1 no timeout. |
EASYDBUS_ERROR on error
EASYDBUS_METHOD_MSG_NULL for a msg equal to null exception
EASYDBUS_METHOD_HANDLED when method is catched.
Definition at line 151 of file watch_events.c.
References EasyDbus_core::conn, easydbus_method_build_skeleton(), easydbus_method_free_skeleton(), EASYDBUS_METHOD_HANDLED, EASYDBUS_METHOD_MSG_NULL, EASYDBUS_METHOD_NOT_HANDLED, EasyDbusDebug, EasyDbus_method::interface, EasyDbus_method::name, and EasyDbus_conn::received_msg.
00154 { 00155 DBusMessage *msg; 00156 struct EasyDbus_core *core = (struct EasyDbus_core *) conn; 00157 int ret_val = EASYDBUS_METHOD_NOT_HANDLED; 00158 00159 // blocking read of the next available message 00160 dbus_connection_read_write_dispatch (core->conn, timeout); 00161 msg = dbus_connection_pop_message (core->conn); 00162 00163 // loop again if we haven't read a message 00164 if (!msg) { 00165 EasyDbusDebug ("Null Message"); 00166 return EASYDBUS_METHOD_MSG_NULL; 00167 } 00168 00169 EasyDbusDebug ("%s Message: member = %s\n" 00170 "interface = %s\n" 00171 "path = %s\n", 00172 dbus_message_type_to_string (dbus_message_get_type 00173 (msg)), 00174 dbus_message_get_member (msg), 00175 dbus_message_get_interface (msg), 00176 dbus_message_get_path (msg)); 00177 00178 // check if the message is a signal from the correct 00179 // interface and with the correct name 00180 if (dbus_message_is_method_call (msg, 00181 method_container->interface, 00182 method_container->name)) { 00183 conn->received_msg++; 00184 // data->received_methods++; 00185 struct EasyDbus_method *temp = 00186 easydbus_method_build_skeleton (msg); 00187 easydbus_method_free_skeleton (temp); 00188 ret_val = EASYDBUS_METHOD_HANDLED; 00189 } 00190 00191 if (msg) 00192 dbus_message_unref (msg); 00193 00194 return ret_val; 00195 }
enum easydbus_ret_values easydbus_watch_signal_blocking | ( | EasyDbus_conn * | data, | |
EasyDbus_signal * | signal_container, | |||
int | timeout | |||
) |
Wait for a signal with blocking mode.
signal_container | signal to handled. | |
data | pointer to struct EasyDbus_conn object. | |
timeout | Timeout for wait call. -1 no timeout. |
EASYDBUS_ERROR on error
EASYDBUS_SIGNAL_MSG_NULL for a msg equal to null exception
EASYDBUS_SIGNAL_HANDLED when signal is catched.
Definition at line 210 of file watch_events.c.
References EasyDbus_core::conn, easydbus_build_skeleton_data(), EASYDBUS_ET_SIGNAL, EASYDBUS_SIGNAL_HANDLED, EASYDBUS_SIGNAL_MSG_NULL, EASYDBUS_SIGNAL_NOT_HANDLED, EasyDbusDebug, EasyDbus_signal::interface, EasyDbus_signal::name, and EasyDbus_conn::received_signal.
00213 { 00214 DBusMessage *msg; 00215 struct EasyDbus_core *core = (struct EasyDbus_core *) data; 00216 int ret_val = EASYDBUS_SIGNAL_NOT_HANDLED; 00217 00218 do { 00219 // blocking read of the next available message 00220 dbus_connection_read_write_dispatch (core->conn, timeout); 00221 msg = dbus_connection_pop_message (core->conn); 00222 00223 // loop again if we haven't read a message 00224 // (a timeout is handled); 00225 if (!msg) { 00226 EasyDbusDebug ("Null Message"); 00227 return EASYDBUS_SIGNAL_MSG_NULL; 00228 } 00229 00230 EasyDbusDebug ("%s Message: member = %s\n" 00231 "interface = %s\n" 00232 "path = %s\n", 00233 dbus_message_type_to_string 00234 (dbus_message_get_type (msg)), 00235 dbus_message_get_member (msg), 00236 dbus_message_get_interface (msg), 00237 dbus_message_get_path (msg)); 00238 00239 // check if the message is a signal from the correct 00240 // interface and with the correct name 00241 if (dbus_message_is_signal (msg, 00242 signal_container->interface, 00243 signal_container->name)) { 00244 //data->received_msg++; 00245 data->received_signal++; 00246 // add arg of signal to signal container passed in input 00247 easydbus_build_skeleton_data (msg, EASYDBUS_ET_SIGNAL, 00248 signal_container); 00249 ret_val = EASYDBUS_SIGNAL_HANDLED; 00250 } 00251 00252 if (msg) 00253 dbus_message_unref (msg); 00254 00255 } while (ret_val == EASYDBUS_SIGNAL_NOT_HANDLED); 00256 00257 return ret_val; 00258 }