Home | History | Annotate | Download | only in gdbus

Lines Matching refs:data

60 	struct service_data *data;
93 struct filter_data *data = current->data;
95 if (connection != data->connection)
98 if (name && data->name &&
99 g_str_equal(name, data->name) == FALSE)
102 if (owner && data->owner &&
103 g_str_equal(owner, data->owner) == FALSE)
106 if (path && data->path &&
107 g_str_equal(path, data->path) == FALSE)
110 if (interface && data->interface &&
111 g_str_equal(interface, data->interface) == FALSE)
114 if (member && data->member &&
115 g_str_equal(member, data->member) == FALSE)
118 if (argument && data->argument &&
119 g_str_equal(argument, data->argument) == FALSE)
122 return data;
128 static void format_rule(struct filter_data *data, char *rule, size_t size)
134 sender = data->name ? : data->owner;
139 if (data->path)
141 ",path='%s'", data->path);
142 if (data->interface)
144 ",interface='%s'", data->interface);
145 if (data->member)
147 ",member='%s'", data->member);
148 if (data->argument)
150 ",arg0='%s'", data->argument);
153 static gboolean add_match(struct filter_data *data,
159 format_rule(data, rule, sizeof(rule));
162 dbus_bus_add_match(data->connection, rule, &err);
170 data->handle_func = filter;
171 data->registered = TRUE;
176 static gboolean remove_match(struct filter_data *data)
181 format_rule(data, rule, sizeof(rule));
185 dbus_bus_remove_match(data->connection, rule, &err);
204 struct filter_data *data;
224 data = filter_data_find(connection, name, owner, path, interface,
226 if (data)
227 return data;
229 data = g_new0(struct filter_data, 1);
231 data->connection = dbus_connection_ref(connection);
232 data->name = name ? g_strdup(name) : NULL;
233 data->owner = owner ? g_strdup(owner) : NULL;
234 data->path = g_strdup(path);
235 data->interface = g_strdup(interface);
236 data->member = g_strdup(member);
237 data->argument = g_strdup(argument);
239 if (!add_match(data, filter)) {
240 g_free(data);
244 listeners = g_slist_append(listeners, data);
246 return data;
250 struct filter_data *data,
255 for (l = data->callbacks; l; l = l->next) {
256 struct filter_callback *cb = l->data;
260 for (l = data->processed; l; l = l->next) {
261 struct filter_callback *cb = l->data;
269 static void filter_data_free(struct filter_data *data)
273 for (l = data->callbacks; l != NULL; l = l->next)
274 g_free(l->data);
276 g_slist_free(data->callbacks);
277 g_dbus_remove_watch(data->connection, data->name_watch);
278 g_free(data->name);
279 g_free(data->owner);
280 g_free(data->path);
281 g_free(data->interface);
282 g_free(data->member);
283 g_free(data->argument);
284 dbus_connection_unref(data->connection);
285 g_free(data);
288 static void filter_data_call_and_free(struct filter_data *data)
292 for (l = data->callbacks; l != NULL; l = l->next) {
293 struct filter_callback *cb = l->data;
295 cb->disc_func(data->connection, cb->user_data);
301 filter_data_free(data);
305 struct filter_data *data,
323 if (data->lock)
324 data->processed = g_slist_append(data->processed, cb);
326 data->callbacks = g_slist_append(data->callbacks, cb);
331 static void service_data_free(struct service_data *data)
333 struct filter_callback *callback = data->callback;
335 dbus_connection_unref(data->conn);
337 if (data->call)
338 dbus_pending_call_unref(data->call);
340 if (data->id)
341 g_source_remove(data->id);
343 g_free(data->name);
344 g_free(data);
346 callback->data = NULL;
349 static gboolean filter_data_remove_callback(struct filter_data *data,
354 data->callbacks = g_slist_remove(data->callbacks, cb);
355 data->processed = g_slist_remove(data->processed, cb);
358 if (cb->data) {
359 if (cb->data->call)
360 dbus_pending_call_cancel(cb->data->call);
361 service_data_free(cb->data);
369 /* Don't remove the filter if other callbacks exist or data is lock
371 if (data->callbacks || data->lock)
374 if (data->registered && !remove_match(data))
377 connection = dbus_connection_ref(data->connection);
378 listeners = g_slist_remove(listeners, data);
379 filter_data_free(data);
382 data = filter_data_find(connection, NULL, NULL, NULL, NULL, NULL,
384 if (data == NULL)
396 struct filter_data *data = user_data;
399 while (data->callbacks) {
400 cb = data->callbacks->data;
404 filter_data_remove_callback(data, cb);
410 if (!g_slist_find(data->callbacks, cb))
413 data->callbacks = g_slist_remove(data->callbacks, cb);
414 data->processed = g_slist_append(data->processed, cb);
425 struct filter_data *data = l->data;
427 if (g_strcmp0(data->name, name) != 0)
430 g_free(data->owner);
431 data->owner = g_strdup(owner);
440 struct filter_data *data = l->data;
442 if (g_strcmp0(data->name, name) != 0)
445 return data->owner;
454 struct filter_data *data = user_data;
469 while (data->callbacks) {
470 cb = data->callbacks->data;
482 if (!g_slist_find(data->callbacks, cb))
486 if (data->argument[0] == ':' &&
488 filter_data_remove_callback(data, cb);
492 data->callbacks = g_slist_remove(data->callbacks, cb);
493 data->processed = g_slist_append(data->processed, cb);
503 struct filter_data *data;
517 data = filter_data_find(connection, NULL, sender, path, iface, member,
519 if (data == NULL) {
524 if (data->handle_func) {
525 data->lock = TRUE;
527 data->handle_func(connection, message, data);
529 data->callbacks = data->processed;
530 data->processed = NULL;
531 data->lock = FALSE;
534 if (data->callbacks)
537 remove_match(data);
539 listeners = g_slist_remove(listeners, data);
540 filter_data_free(data);
543 data = filter_data_find(connection, NULL, NULL, NULL, NULL, NULL,
545 if (data == NULL)
554 struct service_data *data = user_data;
555 struct filter_callback *cb = data->callback;
557 update_name_cache(data->name, data->owner);
559 cb->conn_func(data->conn, cb->user_data);
561 service_data_free(data);
568 struct service_data *data = user_data;
582 DBUS_TYPE_STRING, &data->owner,
586 update_service(data);
593 service_data_free(data);
603 struct service_data *data;
605 data = g_try_malloc0(sizeof(*data));
606 if (data == NULL) {
607 error("Can't allocate data structure");
611 data->conn = dbus_connection_ref(connection);
612 data->name = g_strdup(name);
613 data->callback = callback;
614 callback->data = data;
616 data->owner = check_name_cache(name);
617 if (data->owner != NULL) {
618 data->id = g_idle_add(update_service, data);
626 g_free(data);
634 &data->call, -1) == FALSE) {
636 g_free(data);
640 if (data->call == NULL) {
642 g_free(data);
646 dbus_pending_call_set_notify(data->call, service_reply, data, NULL);
657 struct filter_data *data;
663 data = filter_data_get(connection, service_filter, NULL, NULL,
666 if (data == NULL)
669 cb = filter_data_add_callback(data, connect, disconnect, NULL, NULL,
694 struct filter_data *data;
697 data = filter_data_get(connection, signal_filter, sender, path,
699 if (data == NULL)
702 cb = filter_data_add_callback(data
707 if (data->name != NULL && data->name_watch == 0)
708 data->name_watch = g_dbus_add_service_watch(connection,
709 data->name, NULL,
717 struct filter_data *data;
725 data = ldata->data;
727 cb = filter_data_find_callback(data, id);
729 filter_data_remove_callback(data, cb);
739 struct filter_data *data;
741 while ((data = filter_data_find(connection, NULL, NULL, NULL, NULL,
743 listeners = g_slist_remove(listeners, data);
744 filter_data_call_and_free(data);