From 15ea15b3a752f0487bc50d0ea04925f1b9d33dcb Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 8 May 2008 22:19:14 +0000 Subject: Move D-Bus object and interface helpers into libgdbus --- audio/control.c | 2 +- audio/device.c | 2 +- audio/headset.c | 2 +- audio/manager.c | 3 +- audio/sink.c | 2 +- common/Makefile.am | 3 +- common/dbus-helper.c | 659 -------------------------------------------------- common/dbus-helper.h | 107 --------- common/error.c | 3 +- daemon/adapter.c | 2 +- daemon/database.c | 3 - daemon/main.c | 4 - daemon/manager.c | 2 +- daemon/service.c | 3 +- gdbus/Makefile.am | 2 +- gdbus/gdbus.h | 82 +++++++ gdbus/object.c | 660 +++++++++++++++++++++++++++++++++++++++++++++++++++ hcid/adapter.c | 3 - hcid/agent.c | 3 - hcid/dbus-common.c | 3 - hcid/dbus-database.c | 3 - hcid/dbus-error.c | 6 +- hcid/dbus-hci.c | 3 - hcid/dbus-sdp.c | 3 - hcid/dbus-security.c | 3 - hcid/dbus-service.c | 3 +- hcid/dbus-test.c | 3 - hcid/device.c | 4 +- hcid/manager.c | 1 - input/device.c | 2 +- input/manager.c | 3 +- input/server.c | 2 +- network/connection.c | 2 +- network/manager.c | 2 +- network/server.c | 2 +- serial/manager.c | 2 - serial/port.c | 2 - 37 files changed, 765 insertions(+), 831 deletions(-) delete mode 100644 common/dbus-helper.c delete mode 100644 common/dbus-helper.h create mode 100644 gdbus/object.c diff --git a/audio/control.c b/audio/control.c index cffcf517..f79eee9c 100644 --- a/audio/control.c +++ b/audio/control.c @@ -44,8 +44,8 @@ #include #include +#include -#include "dbus-helper.h" #include "dbus-service.h" #include "logging.h" #include "uinput.h" diff --git a/audio/device.c b/audio/device.c index c385c7ca..b240bdae 100644 --- a/audio/device.c +++ b/audio/device.c @@ -40,8 +40,8 @@ #include #include +#include -#include "dbus-helper.h" #include "logging.h" #include "textfile.h" diff --git a/audio/headset.c b/audio/headset.c index 2d635110..247d02d4 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -48,8 +48,8 @@ #include #include +#include -#include "dbus-helper.h" #include "logging.h" #include "device.h" #include "manager.h" diff --git a/audio/manager.c b/audio/manager.c index bf612bb3..15136b71 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -45,10 +45,9 @@ #include #include - #include +#include -#include "dbus-helper.h" #include "glib-helper.h" #include "dbus-service.h" diff --git a/audio/sink.c b/audio/sink.c index b755759d..af51a9c7 100644 --- a/audio/sink.c +++ b/audio/sink.c @@ -33,8 +33,8 @@ #include #include +#include -#include "dbus-helper.h" #include "logging.h" #include "avdtp.h" diff --git a/common/Makefile.am b/common/Makefile.am index 5352d34f..6ae5ed7a 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -3,14 +3,13 @@ noinst_LIBRARIES = libhelper.a libhelper_a_SOURCES = oui.h oui.c textfile.h textfile.c \ logging.h logging.c error.h error.c \ - dbus-helper.h dbus-helper.c \ glib-helper.h glib-helper.c sdp-xml.h sdp-xml.c sdp-glib.c noinst_PROGRAMS = test_textfile test_textfile_LDADD = libhelper.a -AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ +AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ @GDBUS_CFLAGS@ EXTRA_DIST = ppoll.h uinput.h diff --git a/common/dbus-helper.c b/common/dbus-helper.c deleted file mode 100644 index a7604f65..00000000 --- a/common/dbus-helper.c +++ /dev/null @@ -1,659 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2004-2008 Marcel Holtmann - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include - -#include - -#include "logging.h" - -#include "dbus-helper.h" - -struct generic_data { - void *user_data; - DBusObjectPathUnregisterFunction unregister_function; - GSList *interfaces; - char *introspect; -}; - -struct interface_data { - char *name; - DBusMethodVTable *methods; - DBusSignalVTable *signals; - DBusPropertyVTable *properties; -}; - -DBusHandlerResult dbus_connection_send_and_unref(DBusConnection *connection, - DBusMessage *message) -{ - if (message) { - dbus_connection_send(connection, message, NULL); - dbus_message_unref(message); - } - - return DBUS_HANDLER_RESULT_HANDLED; -} - -static void print_arguments(GString *gstr, const char *sig, const char *direction) -{ - int i; - - for (i = 0; sig[i]; i++) { - char type[32]; - int len, struct_level, dict_level; - gboolean complete; - - complete = FALSE; - struct_level = dict_level = 0; - memset(type, 0, sizeof(type)); - - /* Gather enough data to have a single complete type */ - for (len = 0; len < (sizeof(type) - 1) && sig[i]; len++, i++) { - switch (sig[i]){ - case '(': - struct_level++; - break; - case ')': - struct_level--; - if (struct_level <= 0 && dict_level <= 0) - complete = TRUE; - break; - case '{': - dict_level++; - break; - case '}': - dict_level--; - if (struct_level <= 0 && dict_level <= 0) - complete = TRUE; - break; - case 'a': - break; - default: - if (struct_level <= 0 && dict_level <= 0) - complete = TRUE; - break; - } - - type[len] = sig[i]; - - if (complete) - break; - } - - - if (direction) - g_string_append_printf(gstr, - "\t\t\t\n", - type, direction); - else - g_string_append_printf(gstr, - "\t\t\t\n", - type); - } -} - -static void generate_introspection_xml(DBusConnection *conn, - struct generic_data *data, - const char *path) -{ - GSList *list; - GString *gstr; - char **children; - int i; - - g_free(data->introspect); - - gstr = g_string_new(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE); - - g_string_append_printf(gstr, "\n", path); - - for (list = data->interfaces; list; list = list->next) { - struct interface_data *iface = list->data; - DBusMethodVTable *method; - DBusSignalVTable *signal; - DBusPropertyVTable *property; - - g_string_append_printf(gstr, "\t\n", iface->name); - - for (method = iface->methods; method && method->name; method++) { - /* debug("%s: adding method %s.%s", - path, iface->name, method->name); */ - if (!strlen(method->signature) && !strlen(method->reply)) - g_string_append_printf(gstr, "\t\t\n", - method->name); - else { - g_string_append_printf(gstr, "\t\t\n", - method->name); - print_arguments(gstr, method->signature, "in"); - print_arguments(gstr, method->reply, "out"); - g_string_append_printf(gstr, "\t\t\n"); - } - } - - for (signal = iface->signals; signal && signal->name; signal++) { - /* debug("%s: adding signal %s.%s", - path, iface->name, signal->name); */ - if (!strlen(signal->signature)) - g_string_append_printf(gstr, "\t\t\n", - signal->name); - else { - g_string_append_printf(gstr, "\t\t\n", - signal->name); - print_arguments(gstr, signal->signature, NULL); - g_string_append_printf(gstr, "\t\t\n"); - } - } - - for (property = iface->properties; property && property->name; property++) { - debug("%s: adding property %s.%s", - path, iface->name, property->name); - } - - g_string_append_printf(gstr, "\t\n"); - } - - if (!dbus_connection_list_registered(conn, path, &children)) - goto done; - - for (i = 0; children[i]; i++) - g_string_append_printf(gstr, "\t\n", children[i]); - - dbus_free_string_array(children); - -done: - g_string_append_printf(gstr, "\n"); - - data->introspect = g_string_free(gstr, FALSE); -} - -static DBusHandlerResult introspect(DBusConnection *connection, - DBusMessage *message, struct generic_data *data) -{ - DBusMessage *reply; - - if (!dbus_message_has_signature(message, DBUS_TYPE_INVALID_AS_STRING)) { - error("Unexpected signature to introspect call"); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - - if (!data->introspect) - generate_introspection_xml(connection, data, - dbus_message_get_path(message)); - - reply = dbus_message_new_method_return(message); - if (!reply) - return DBUS_HANDLER_RESULT_NEED_MEMORY; - - dbus_message_append_args(reply, DBUS_TYPE_STRING, &data->introspect, - DBUS_TYPE_INVALID); - - return dbus_connection_send_and_unref(connection, reply); -} - -static void generic_unregister(DBusConnection *connection, void *user_data) -{ - struct generic_data *data = user_data; - - if (data->unregister_function) - data->unregister_function(connection, data->user_data); - - g_free(data->introspect); - g_free(data); -} - -static struct interface_data *find_interface(GSList *interfaces, - const char *name) -{ - GSList *list; - - for (list = interfaces; list; list = list->next) { - struct interface_data *iface = list->data; - if (!strcmp(name, iface->name)) - return iface; - } - - return NULL; -} - -static DBusHandlerResult generic_message(DBusConnection *connection, - DBusMessage *message, void *user_data) -{ - struct generic_data *data = user_data; - struct interface_data *iface; - DBusMethodVTable *current; - const char *interface; - - if (dbus_message_is_method_call(message, - DBUS_INTERFACE_INTROSPECTABLE, - "Introspect")) - return introspect(connection, message, data); - - interface = dbus_message_get_interface(message); - - iface = find_interface(data->interfaces, interface); - if (!iface) - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - - for (current = iface->methods; - current->name && current->message_function; current++) { - if (!dbus_message_is_method_call(message, iface->name, - current->name)) - continue; - - if (dbus_message_has_signature(message, current->signature)) { - debug("%s: %s.%s()", dbus_message_get_path(message), - iface->name, current->name); - return current->message_function(connection, - message, data->user_data); - } - } - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -static DBusObjectPathVTable generic_table = { - .unregister_function = generic_unregister, - .message_function = generic_message, -}; - -static void invalidate_parent_data(DBusConnection *conn, const char *child_path) -{ - struct generic_data *data = NULL; - char *parent_path, *slash; - - parent_path = g_strdup(child_path); - slash = strrchr(parent_path, '/'); - if (!slash) - goto done; - - *slash = '\0'; - if (!strlen(parent_path)) - goto done; - - if (!dbus_connection_get_object_path_data(conn, parent_path, - (void *) &data)) - goto done; - - if (!data) - goto done; - - g_free(data->introspect); - data->introspect = NULL; - -done: - g_free(parent_path); -} - -dbus_bool_t dbus_connection_create_object_path(DBusConnection *connection, - const char *path, void *user_data, - DBusObjectPathUnregisterFunction function) -{ - struct generic_data *data; - - data = g_new0(struct generic_data, 1); - - data->user_data = user_data; - data->unregister_function = function; - - data->introspect = g_strdup(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE ""); - - if (!dbus_connection_register_object_path(connection, path, - &generic_table, data)) { - g_free(data->introspect); - g_free(data); - return FALSE; - } - - invalidate_parent_data(connection, path); - - return TRUE; -} - -dbus_bool_t dbus_connection_destroy_object_path(DBusConnection *connection, - const char *path) -{ - invalidate_parent_data(connection, path); - - return dbus_connection_unregister_object_path(connection, path); -} - -dbus_bool_t dbus_connection_get_object_user_data(DBusConnection *connection, - const char *path, - void **data_p) -{ - struct generic_data *data = NULL; - - if (!dbus_connection_get_object_path_data(connection, path, - (void *) &data) || !data) - return FALSE; - - *data_p = data->user_data; - - return TRUE; -} - -dbus_bool_t dbus_connection_register_interface(DBusConnection *connection, - const char *path, const char *name, - DBusMethodVTable *methods, - DBusSignalVTable *signals, - DBusPropertyVTable *properties) -{ - struct generic_data *data = NULL; - struct interface_data *iface; - - if (!dbus_connection_get_object_path_data(connection, path, - (void *) &data) || !data) - return FALSE; - - if (find_interface(data->interfaces, name)) - return FALSE; - - iface = g_new0(struct interface_data, 1); - - iface->name = g_strdup(name); - iface->methods = methods; - iface->signals = signals; - iface->properties = properties; - - data->interfaces = g_slist_append(data->interfaces, iface); - - g_free(data->introspect); - data->introspect = NULL; - - return TRUE; -} - -dbus_bool_t dbus_connection_unregister_interface(DBusConnection *connection, - const char *path, const char *name) -{ - struct generic_data *data = NULL; - struct interface_data *iface; - - if (!dbus_connection_get_object_path_data(connection, path, - (void *) &data) || !data) - return FALSE; - - iface = find_interface(data->interfaces, name); - if (!iface) - return FALSE; - - data->interfaces = g_slist_remove(data->interfaces, iface); - - g_free(iface->name); - g_free(iface); - - g_free(data->introspect); - data->introspect = NULL; - - return TRUE; -} - -void dbus_message_iter_append_variant(DBusMessageIter *iter, int type, void *val) -{ - DBusMessageIter value; - DBusMessageIter array; - char *sig; - - switch (type) { - case DBUS_TYPE_STRING: - sig = DBUS_TYPE_STRING_AS_STRING; - break; - case DBUS_TYPE_BYTE: - sig = DBUS_TYPE_BYTE_AS_STRING; - break; - case DBUS_TYPE_INT16: - sig = DBUS_TYPE_INT16_AS_STRING; - break; - case DBUS_TYPE_UINT16: - sig = DBUS_TYPE_UINT16_AS_STRING; - break; - case DBUS_TYPE_INT32: - sig = DBUS_TYPE_INT32_AS_STRING; - break; - case DBUS_TYPE_UINT32: - sig = DBUS_TYPE_UINT32_AS_STRING; - break; - case DBUS_TYPE_BOOLEAN: - sig = DBUS_TYPE_BOOLEAN_AS_STRING; - break; - case DBUS_TYPE_ARRAY: - sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING; - break; - case DBUS_TYPE_OBJECT_PATH: - sig = DBUS_TYPE_OBJECT_PATH_AS_STRING; - break; - default: - error("Could not append variant with type %d", type); - return; - } - - dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &value); - - if (type == DBUS_TYPE_ARRAY) { - int i; - const char ***str_array = val; - - dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, - DBUS_TYPE_STRING_AS_STRING, &array); - - for (i = 0; (*str_array)[i]; i++) - dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, - &((*str_array)[i])); - - dbus_message_iter_close_container(&value, &array); - } else - dbus_message_iter_append_basic(&value, type, val); - - dbus_message_iter_close_container(iter, &value); -} - -void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, - const char *key, int type, void *val) -{ - DBusMessageIter entry; - - dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry); - - dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); - - dbus_message_iter_append_variant(&entry, type, val); - - dbus_message_iter_close_container(dict, &entry); -} - -void dbus_message_iter_append_dict_valist(DBusMessageIter *iter, - const char *first_key, - va_list var_args) -{ - DBusMessageIter dict; - const char *key; - int type; - void *val; - - dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, - DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING - DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING - DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); - - key = first_key; - while (key) { - type = va_arg(var_args, int); - val = va_arg(var_args, void *); - dbus_message_iter_append_dict_entry(&dict, key, type, val); - key = va_arg(var_args, char *); - } - - dbus_message_iter_close_container(iter, &dict); -} - -void dbus_message_iter_append_dict(DBusMessageIter *iter, - const char *first_key, ...) -{ - va_list var_args; - - va_start(var_args, first_key); - dbus_message_iter_append_dict_valist(iter, first_key, var_args); - va_end(var_args); -} - -static gboolean check_signal(DBusConnection *conn, const char *path, - const char *interface, const char *name, - const char **args) -{ - struct generic_data *data = NULL; - struct interface_data *iface; - DBusSignalVTable *sig_data; - - *args = NULL; - if (!dbus_connection_get_object_path_data(conn, path, - (void *) &data) || !data) { - error("dbus_connection_emit_signal: path %s isn't registered", - path); - return FALSE; - } - - iface = find_interface(data->interfaces, interface); - - if (!iface) { - error("dbus_connection_emit_signal: %s does not implement %s", - path, interface); - return FALSE; - } - - for (sig_data = iface->signals; sig_data && sig_data->name; sig_data++) { - if (!strcmp(sig_data->name, name)) { - *args = sig_data->signature; - break; - } - } - - if (!*args) { - error("No signal named %s on interface %s", name, interface); - return FALSE; - } - - return TRUE; -} - -dbus_bool_t dbus_connection_emit_signal_valist(DBusConnection *conn, - const char *path, - const char *interface, - const char *name, - int first, - va_list var_args) -{ - DBusMessage *signal; - dbus_bool_t ret; - const char *signature, *args; - - if (!check_signal(conn, path, interface, name, &args)) - return FALSE; - - signal = dbus_message_new_signal(path, interface, name); - if (!signal) { - error("Unable to allocate new %s.%s signal", interface, name); - return FALSE; - } - - ret = dbus_message_append_args_valist(signal, first, var_args); - if (!ret) - goto fail; - - signature = dbus_message_get_signature(signal); - if (strcmp(args, signature) != 0) { - error("%s.%s: expected signature'%s' but got '%s'", - interface, name, args, signature); - ret = FALSE; - goto fail; - } - - ret = dbus_connection_send(conn, signal, NULL); -fail: - dbus_message_unref(signal); - - return ret; -} - -dbus_bool_t dbus_connection_emit_signal(DBusConnection *conn, const char *path, - const char *interface, const char *name, - int first, ...) -{ - dbus_bool_t ret; - va_list var_args; - - va_start(var_args, first); - ret = dbus_connection_emit_signal_valist(conn, path, interface, name, - first, var_args); - va_end(var_args); - - return ret; -} - -dbus_bool_t dbus_connection_emit_property_changed(DBusConnection *conn, - const char *path, - const char *interface, - const char *name, - int type, void *value) -{ - DBusMessage *signal; - DBusMessageIter iter; - gboolean ret; - const char *signature, *args; - - if (!check_signal(conn, path, interface, "PropertyChanged", &args)) - return FALSE; - - signal = dbus_message_new_signal(path, interface, "PropertyChanged"); - - if (!signal) { - error("Unable to allocate new %s.PropertyChanged signal", - interface); - return FALSE; - } - - dbus_message_iter_init_append(signal, &iter); - - dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name); - dbus_message_iter_append_variant(&iter, type, value); - - signature = dbus_message_get_signature(signal); - if (strcmp(args, signature) != 0) { - error("%s.%s: expected signature'%s' but got '%s'", - interface, name, args, signature); - ret = FALSE; - goto fail; - } - - ret = dbus_connection_send(conn, signal, NULL); - -fail: - dbus_message_unref(signal); - return ret; -} diff --git a/common/dbus-helper.h b/common/dbus-helper.h deleted file mode 100644 index 6c3c3a89..00000000 --- a/common/dbus-helper.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2004-2008 Marcel Holtmann - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include -#include - -#define DBUS_TYPE_STRING_ARRAY_AS_STRING (DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING) -#define DBUS_TYPE_BYTE_ARRAY_AS_STRING (DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING) - -DBusHandlerResult dbus_connection_send_and_unref(DBusConnection *connection, - DBusMessage *message); - -dbus_bool_t dbus_connection_create_object_path(DBusConnection *connection, - const char *path, void *user_data, - DBusObjectPathUnregisterFunction function); - -dbus_bool_t dbus_connection_destroy_object_path(DBusConnection *connection, - const char *path); - -dbus_bool_t dbus_connection_get_object_user_data(DBusConnection *connection, - const char *path, - void **data_p); - -typedef struct DBusMethodVTable DBusMethodVTable; - -struct DBusMethodVTable { - const char *name; - DBusObjectPathMessageFunction message_function; - const char *signature; - const char *reply; -}; - -typedef struct DBusSignalVTable DBusSignalVTable; - -struct DBusSignalVTable { - const char *name; - const char *signature; -}; - -typedef struct DBusPropertyVTable DBusPropertyVTable; - -struct DBusPropertyVTable { - const char *name; -}; - -dbus_bool_t dbus_connection_register_interface(DBusConnection *connection, - const char *path, const char *name, - DBusMethodVTable *methods, - DBusSignalVTable *signals, - DBusPropertyVTable *properties); - -dbus_bool_t dbus_connection_unregister_interface(DBusConnection *connection, - const char *path, const char *name); -void dbus_message_iter_append_variant(DBusMessageIter *iter, int type, void *val); -void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, - const char *key, int type, void *val); -void dbus_message_iter_append_dict_valist(DBusMessageIter *iter, - const char *first_key, - va_list var_args); -void dbus_message_iter_append_dict(DBusMessageIter *iter, - const char *first_key, ...); -dbus_bool_t dbus_connection_emit_signal(DBusConnection *conn, const char *path, - const char *interface, const char *name, - int first, ...); - -dbus_bool_t dbus_connection_emit_signal_valist(DBusConnection *conn, - const char *path, - const char *interface, - const char *name, - int first, - va_list var_args); -dbus_bool_t dbus_connection_emit_property_changed(DBusConnection *conn, - const char *path, - const char *interface, - const char *name, - int type, void *value); - -static inline DBusHandlerResult send_message_and_unref(DBusConnection *conn, - DBusMessage *msg) -{ - if (msg) { - dbus_connection_send(conn, msg, NULL); - dbus_message_unref(msg); - } - - return DBUS_HANDLER_RESULT_HANDLED; -} diff --git a/common/error.c b/common/error.c index 58999393..656c7299 100644 --- a/common/error.c +++ b/common/error.c @@ -31,7 +31,8 @@ #include #include -#include "dbus-helper.h" +#include + #include "error.h" /** diff --git a/daemon/adapter.c b/daemon/adapter.c index d8e4c9d4..2c5e608e 100644 --- a/daemon/adapter.c +++ b/daemon/adapter.c @@ -26,8 +26,8 @@ #endif #include +#include -#include "dbus-helper.h" #include "logging.h" #include "system.h" diff --git a/daemon/database.c b/daemon/database.c index b7d5562d..f0c8b38d 100644 --- a/daemon/database.c +++ b/daemon/database.c @@ -33,12 +33,9 @@ #include #include - #include - #include -#include "dbus-helper.h" #include "sdp-xml.h" #include "logging.h" diff --git a/daemon/main.c b/daemon/main.c index 0c735c35..a1b58ada 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -34,13 +34,9 @@ #include #include - #include - #include -#include "dbus-helper.h" - #include "logging.h" #include "sdpd.h" diff --git a/daemon/manager.c b/daemon/manager.c index 3c30575c..92e34dd5 100644 --- a/daemon/manager.c +++ b/daemon/manager.c @@ -26,8 +26,8 @@ #endif #include +#include -#include "dbus-helper.h" #include "logging.h" #include "system.h" diff --git a/daemon/service.c b/daemon/service.c index 27ed2417..7668d653 100644 --- a/daemon/service.c +++ b/daemon/service.c @@ -30,10 +30,9 @@ #include #include - #include +#include -#include "dbus-helper.h" #include "logging.h" #include "system.h" diff --git a/gdbus/Makefile.am b/gdbus/Makefile.am index 937b1d7f..9447555f 100644 --- a/gdbus/Makefile.am +++ b/gdbus/Makefile.am @@ -1,7 +1,7 @@ noinst_LTLIBRARIES = libgdbus.la -libgdbus_la_SOURCES = gdbus.h mainloop.c watch.c +libgdbus_la_SOURCES = gdbus.h mainloop.c object.c watch.c AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h index d1902a52..d8382306 100644 --- a/gdbus/gdbus.h +++ b/gdbus/gdbus.h @@ -40,6 +40,88 @@ gboolean g_dbus_set_disconnect_function(DBusConnection *connection, GDBusDisconnectFunction function, void *user_data, DBusFreeFunction destroy); +#define DBUS_TYPE_STRING_ARRAY_AS_STRING (DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING) +#define DBUS_TYPE_BYTE_ARRAY_AS_STRING (DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING) + +DBusHandlerResult dbus_connection_send_and_unref(DBusConnection *connection, + DBusMessage *message); + +dbus_bool_t dbus_connection_create_object_path(DBusConnection *connection, + const char *path, void *user_data, + DBusObjectPathUnregisterFunction function); + +dbus_bool_t dbus_connection_destroy_object_path(DBusConnection *connection, + const char *path); + +dbus_bool_t dbus_connection_get_object_user_data(DBusConnection *connection, + const char *path, + void **data_p); + +typedef struct DBusMethodVTable DBusMethodVTable; + +struct DBusMethodVTable { + const char *name; + DBusObjectPathMessageFunction message_function; + const char *signature; + const char *reply; +}; + +typedef struct DBusSignalVTable DBusSignalVTable; + +struct DBusSignalVTable { + const char *name; + const char *signature; +}; + +typedef struct DBusPropertyVTable DBusPropertyVTable; + +struct DBusPropertyVTable { + const char *name; +}; + +dbus_bool_t dbus_connection_register_interface(DBusConnection *connection, + const char *path, const char *name, + DBusMethodVTable *methods, + DBusSignalVTable *signals, + DBusPropertyVTable *properties); + +dbus_bool_t dbus_connection_unregister_interface(DBusConnection *connection, + const char *path, const char *name); +void dbus_message_iter_append_variant(DBusMessageIter *iter, int type, void *val); +void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, + const char *key, int type, void *val); +void dbus_message_iter_append_dict_valist(DBusMessageIter *iter, + const char *first_key, + va_list var_args); +void dbus_message_iter_append_dict(DBusMessageIter *iter, + const char *first_key, ...); +dbus_bool_t dbus_connection_emit_signal(DBusConnection *conn, const char *path, + const char *interface, const char *name, + int first, ...); + +dbus_bool_t dbus_connection_emit_signal_valist(DBusConnection *conn, + const char *path, + const char *interface, + const char *name, + int first, + va_list var_args); +dbus_bool_t dbus_connection_emit_property_changed(DBusConnection *conn, + const char *path, + const char *interface, + const char *name, + int type, void *value); + +static inline DBusHandlerResult send_message_and_unref(DBusConnection *conn, + DBusMessage *msg) +{ + if (msg) { + dbus_connection_send(conn, msg, NULL); + dbus_message_unref(msg); + } + + return DBUS_HANDLER_RESULT_HANDLED; +} + typedef void (*name_cb_t)(const char *name, void *user_data); guint name_listener_add(DBusConnection *connection, const char *name, diff --git a/gdbus/object.c b/gdbus/object.c new file mode 100644 index 00000000..12ba66a9 --- /dev/null +++ b/gdbus/object.c @@ -0,0 +1,660 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2004-2008 Marcel Holtmann + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include +#include + +#include "gdbus.h" + +#define info(fmt...) +#define error(fmt...) +#define debug(fmt...) + +struct generic_data { + void *user_data; + DBusObjectPathUnregisterFunction unregister_function; + GSList *interfaces; + char *introspect; +}; + +struct interface_data { + char *name; + DBusMethodVTable *methods; + DBusSignalVTable *signals; + DBusPropertyVTable *properties; +}; + +DBusHandlerResult dbus_connection_send_and_unref(DBusConnection *connection, + DBusMessage *message) +{ + if (message) { + dbus_connection_send(connection, message, NULL); + dbus_message_unref(message); + } + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static void print_arguments(GString *gstr, const char *sig, const char *direction) +{ + int i; + + for (i = 0; sig[i]; i++) { + char type[32]; + int len, struct_level, dict_level; + gboolean complete; + + complete = FALSE; + struct_level = dict_level = 0; + memset(type, 0, sizeof(type)); + + /* Gather enough data to have a single complete type */ + for (len = 0; len < (sizeof(type) - 1) && sig[i]; len++, i++) { + switch (sig[i]){ + case '(': + struct_level++; + break; + case ')': + struct_level--; + if (struct_level <= 0 && dict_level <= 0) + complete = TRUE; + break; + case '{': + dict_level++; + break; + case '}': + dict_level--; + if (struct_level <= 0 && dict_level <= 0) + complete = TRUE; + break; + case 'a': + break; + default: + if (struct_level <= 0 && dict_level <= 0) + complete = TRUE; + break; + } + + type[len] = sig[i]; + + if (complete) + break; + } + + + if (direction) + g_string_append_printf(gstr, + "\t\t\t\n", + type, direction); + else + g_string_append_printf(gstr, + "\t\t\t\n", + type); + } +} + +static void generate_introspection_xml(DBusConnection *conn, + struct generic_data *data, + const char *path) +{ + GSList *list; + GString *gstr; + char **children; + int i; + + g_free(data->introspect); + + gstr = g_string_new(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE); + + g_string_append_printf(gstr, "\n", path); + + for (list = data->interfaces; list; list = list->next) { + struct interface_data *iface = list->data; + DBusMethodVTable *method; + DBusSignalVTable *signal; + DBusPropertyVTable *property; + + g_string_append_printf(gstr, "\t\n", iface->name); + + for (method = iface->methods; method && method->name; method++) { + /* debug("%s: adding method %s.%s", + path, iface->name, method->name); */ + if (!strlen(method->signature) && !strlen(method->reply)) + g_string_append_printf(gstr, "\t\t\n", + method->name); + else { + g_string_append_printf(gstr, "\t\t\n", + method->name); + print_arguments(gstr, method->signature, "in"); + print_arguments(gstr, method->reply, "out"); + g_string_append_printf(gstr, "\t\t\n"); + } + } + + for (signal = iface->signals; signal && signal->name; signal++) { + /* debug("%s: adding signal %s.%s", + path, iface->name, signal->name); */ + if (!strlen(signal->signature)) + g_string_append_printf(gstr, "\t\t\n", + signal->name); + else { + g_string_append_printf(gstr, "\t\t\n", + signal->name); + print_arguments(gstr, signal->signature, NULL); + g_string_append_printf(gstr, "\t\t\n"); + } + } + + for (property = iface->properties; property && property->name; property++) { + debug("%s: adding property %s.%s", + path, iface->name, property->name); + } + + g_string_append_printf(gstr, "\t\n"); + } + + if (!dbus_connection_list_registered(conn, path, &children)) + goto done; + + for (i = 0; children[i]; i++) + g_string_append_printf(gstr, "\t\n", children[i]); + + dbus_free_string_array(children); + +done: + g_string_append_printf(gstr, "\n"); + + data->introspect = g_string_free(gstr, FALSE); +} + +static DBusHandlerResult introspect(DBusConnection *connection, + DBusMessage *message, struct generic_data *data) +{ + DBusMessage *reply; + + if (!dbus_message_has_signature(message, DBUS_TYPE_INVALID_AS_STRING)) { + error("Unexpected signature to introspect call"); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + if (!data->introspect) + generate_introspection_xml(connection, data, + dbus_message_get_path(message)); + + reply = dbus_message_new_method_return(message); + if (!reply) + return DBUS_HANDLER_RESULT_NEED_MEMORY; + + dbus_message_append_args(reply, DBUS_TYPE_STRING, &data->introspect, + DBUS_TYPE_INVALID); + + return dbus_connection_send_and_unref(connection, reply); +} + +static void generic_unregister(DBusConnection *connection, void *user_data) +{ + struct generic_data *data = user_data; + + if (data->unregister_function) + data->unregister_function(connection, data->user_data); + + g_free(data->introspect); + g_free(data); +} + +static struct interface_data *find_interface(GSList *interfaces, + const char *name) +{ + GSList *list; + + for (list = interfaces; list; list = list->next) { + struct interface_data *iface = list->data; + if (!strcmp(name, iface->name)) + return iface; + } + + return NULL; +} + +static DBusHandlerResult generic_message(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + struct generic_data *data = user_data; + struct interface_data *iface; + DBusMethodVTable *current; + const char *interface; + + if (dbus_message_is_method_call(message, + DBUS_INTERFACE_INTROSPECTABLE, + "Introspect")) + return introspect(connection, message, data); + + interface = dbus_message_get_interface(message); + + iface = find_interface(data->interfaces, interface); + if (!iface) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + for (current = iface->methods; + current->name && current->message_function; current++) { + if (!dbus_message_is_method_call(message, iface->name, + current->name)) + continue; + + if (dbus_message_has_signature(message, current->signature)) { + debug("%s: %s.%s()", dbus_message_get_path(message), + iface->name, current->name); + return current->message_function(connection, + message, data->user_data); + } + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static DBusObjectPathVTable generic_table = { + .unregister_function = generic_unregister, + .message_function = generic_message, +}; + +static void invalidate_parent_data(DBusConnection *conn, const char *child_path) +{ + struct generic_data *data = NULL; + char *parent_path, *slash; + + parent_path = g_strdup(child_path); + slash = strrchr(parent_path, '/'); + if (!slash) + goto done; + + *slash = '\0'; + if (!strlen(parent_path)) + goto done; + + if (!dbus_connection_get_object_path_data(conn, parent_path, + (void *) &data)) + goto done; + + if (!data) + goto done; + + g_free(data->introspect); + data->introspect = NULL; + +done: + g_free(parent_path); +} + +dbus_bool_t dbus_connection_create_object_path(DBusConnection *connection, + const char *path, void *user_data, + DBusObjectPathUnregisterFunction function) +{ + struct generic_data *data; + + data = g_new0(struct generic_data, 1); + + data->user_data = user_data; + data->unregister_function = function; + + data->introspect = g_strdup(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE ""); + + if (!dbus_connection_register_object_path(connection, path, + &generic_table, data)) { + g_free(data->introspect); + g_free(data); + return FALSE; + } + + invalidate_parent_data(connection, path); + + return TRUE; +} + +dbus_bool_t dbus_connection_destroy_object_path(DBusConnection *connection, + const char *path) +{ + invalidate_parent_data(connection, path); + + return dbus_connection_unregister_object_path(connection, path); +} + +dbus_bool_t dbus_connection_get_object_user_data(DBusConnection *connection, + const char *path, + void **data_p) +{ + struct generic_data *data = NULL; + + if (!dbus_connection_get_object_path_data(connection, path, + (void *) &data) || !data) + return FALSE; + + *data_p = data->user_data; + + return TRUE; +} + +dbus_bool_t dbus_connection_register_interface(DBusConnection *connection, + const char *path, const char *name, + DBusMethodVTable *methods, + DBusSignalVTable *signals, + DBusPropertyVTable *properties) +{ + struct generic_data *data = NULL; + struct interface_data *iface; + + if (!dbus_connection_get_object_path_data(connection, path, + (void *) &data) || !data) + return FALSE; + + if (find_interface(data->interfaces, name)) + return FALSE; + + iface = g_new0(struct interface_data, 1); + + iface->name = g_strdup(name); + iface->methods = methods; + iface->signals = signals; + iface->properties = properties; + + data->interfaces = g_slist_append(data->interfaces, iface); + + g_free(data->introspect); + data->introspect = NULL; + + return TRUE; +} + +dbus_bool_t dbus_connection_unregister_interface(DBusConnection *connection, + const char *path, const char *name) +{ + struct generic_data *data = NULL; + struct interface_data *iface; + + if (!dbus_connection_get_object_path_data(connection, path, + (void *) &data) || !data) + return FALSE; + + iface = find_interface(data->interfaces, name); + if (!iface) + return FALSE; + + data->interfaces = g_slist_remove(data->interfaces, iface); + + g_free(iface->name); + g_free(iface); + + g_free(data->introspect); + data->introspect = NULL; + + return TRUE; +} + +void dbus_message_iter_append_variant(DBusMessageIter *iter, int type, void *val) +{ + DBusMessageIter value; + DBusMessageIter array; + char *sig; + + switch (type) { + case DBUS_TYPE_STRING: + sig = DBUS_TYPE_STRING_AS_STRING; + break; + case DBUS_TYPE_BYTE: + sig = DBUS_TYPE_BYTE_AS_STRING; + break; + case DBUS_TYPE_INT16: + sig = DBUS_TYPE_INT16_AS_STRING; + break; + case DBUS_TYPE_UINT16: + sig = DBUS_TYPE_UINT16_AS_STRING; + break; + case DBUS_TYPE_INT32: + sig = DBUS_TYPE_INT32_AS_STRING; + break; + case DBUS_TYPE_UINT32: + sig = DBUS_TYPE_UINT32_AS_STRING; + break; + case DBUS_TYPE_BOOLEAN: + sig = DBUS_TYPE_BOOLEAN_AS_STRING; + break; + case DBUS_TYPE_ARRAY: + sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING; + break; + case DBUS_TYPE_OBJECT_PATH: + sig = DBUS_TYPE_OBJECT_PATH_AS_STRING; + break; + default: + error("Could not append variant with type %d", type); + return; + } + + dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &value); + + if (type == DBUS_TYPE_ARRAY) { + int i; + const char ***str_array = val; + + dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, &array); + + for (i = 0; (*str_array)[i]; i++) + dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, + &((*str_array)[i])); + + dbus_message_iter_close_container(&value, &array); + } else + dbus_message_iter_append_basic(&value, type, val); + + dbus_message_iter_close_container(iter, &value); +} + +void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, + const char *key, int type, void *val) +{ + DBusMessageIter entry; + + dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry); + + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); + + dbus_message_iter_append_variant(&entry, type, val); + + dbus_message_iter_close_container(dict, &entry); +} + +void dbus_message_iter_append_dict_valist(DBusMessageIter *iter, + const char *first_key, + va_list var_args) +{ + DBusMessageIter dict; + const char *key; + int type; + void *val; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); + + key = first_key; + while (key) { + type = va_arg(var_args, int); + val = va_arg(var_args, void *); + dbus_message_iter_append_dict_entry(&dict, key, type, val); + key = va_arg(var_args, char *); + } + + dbus_message_iter_close_container(iter, &dict); +} + +void dbus_message_iter_append_dict(DBusMessageIter *iter, + const char *first_key, ...) +{ + va_list var_args; + + va_start(var_args, first_key); + dbus_message_iter_append_dict_valist(iter, first_key, var_args); + va_end(var_args); +} + +static gboolean check_signal(DBusConnection *conn, const char *path, + const char *interface, const char *name, + const char **args) +{ + struct generic_data *data = NULL; + struct interface_data *iface; + DBusSignalVTable *sig_data; + + *args = NULL; + if (!dbus_connection_get_object_path_data(conn, path, + (void *) &data) || !data) { + error("dbus_connection_emit_signal: path %s isn't registered", + path); + return FALSE; + } + + iface = find_interface(data->interfaces, interface); + + if (!iface) { + error("dbus_connection_emit_signal: %s does not implement %s", + path, interface); + return FALSE; + } + + for (sig_data = iface->signals; sig_data && sig_data->name; sig_data++) { + if (!strcmp(sig_data->name, name)) { + *args = sig_data->signature; + break; + } + } + + if (!*args) { + error("No signal named %s on interface %s", name, interface); + return FALSE; + } + + return TRUE; +} + +dbus_bool_t dbus_connection_emit_signal_valist(DBusConnection *conn, + const char *path, + const char *interface, + const char *name, + int first, + va_list var_args) +{ + DBusMessage *signal; + dbus_bool_t ret; + const char *signature, *args; + + if (!check_signal(conn, path, interface, name, &args)) + return FALSE; + + signal = dbus_message_new_signal(path, interface, name); + if (!signal) { + error("Unable to allocate new %s.%s signal", interface, name); + return FALSE; + } + + ret = dbus_message_append_args_valist(signal, first, var_args); + if (!ret) + goto fail; + + signature = dbus_message_get_signature(signal); + if (strcmp(args, signature) != 0) { + error("%s.%s: expected signature'%s' but got '%s'", + interface, name, args, signature); + ret = FALSE; + goto fail; + } + + ret = dbus_connection_send(conn, signal, NULL); +fail: + dbus_message_unref(signal); + + return ret; +} + +dbus_bool_t dbus_connection_emit_signal(DBusConnection *conn, const char *path, + const char *interface, const char *name, + int first, ...) +{ + dbus_bool_t ret; + va_list var_args; + + va_start(var_args, first); + ret = dbus_connection_emit_signal_valist(conn, path, interface, name, + first, var_args); + va_end(var_args); + + return ret; +} + +dbus_bool_t dbus_connection_emit_property_changed(DBusConnection *conn, + const char *path, + const char *interface, + const char *name, + int type, void *value) +{ + DBusMessage *signal; + DBusMessageIter iter; + gboolean ret; + const char *signature, *args; + + if (!check_signal(conn, path, interface, "PropertyChanged", &args)) + return FALSE; + + signal = dbus_message_new_signal(path, interface, "PropertyChanged"); + + if (!signal) { + error("Unable to allocate new %s.PropertyChanged signal", + interface); + return FALSE; + } + + dbus_message_iter_init_append(signal, &iter); + + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name); + dbus_message_iter_append_variant(&iter, type, value); + + signature = dbus_message_get_signature(signal); + if (strcmp(args, signature) != 0) { + error("%s.%s: expected signature'%s' but got '%s'", + interface, name, args, signature); + ret = FALSE; + goto fail; + } + + ret = dbus_connection_send(conn, signal, NULL); + +fail: + dbus_message_unref(signal); + return ret; +} diff --git a/hcid/adapter.c b/hcid/adapter.c index 4bc7245e..1383ed50 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -45,9 +45,7 @@ #include #include - #include - #include #include "hcid.h" @@ -58,7 +56,6 @@ #include "textfile.h" #include "oui.h" #include "dbus-common.h" -#include "dbus-helper.h" #include "dbus-hci.h" #include "dbus-sdp.h" #include "dbus-database.h" diff --git a/hcid/agent.c b/hcid/agent.c index e7bf7d96..330d00e4 100644 --- a/hcid/agent.c +++ b/hcid/agent.c @@ -38,12 +38,9 @@ #include #include - #include - #include -#include "dbus-helper.h" #include "hcid.h" #include "dbus-common.h" #include "dbus-service.h" diff --git a/hcid/dbus-common.c b/hcid/dbus-common.c index 7a28555d..5acec28d 100644 --- a/hcid/dbus-common.c +++ b/hcid/dbus-common.c @@ -46,13 +46,10 @@ #include #include - #include - #include #include "hcid.h" -#include "dbus-helper.h" #include "dbus-error.h" #include "manager.h" #include "adapter.h" diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c index 370b7658..acf5301c 100644 --- a/hcid/dbus-database.c +++ b/hcid/dbus-database.c @@ -37,12 +37,9 @@ #include #include - #include - #include -#include "dbus-helper.h" #include "hcid.h" #include "sdpd.h" #include "sdp-xml.h" diff --git a/hcid/dbus-error.c b/hcid/dbus-error.c index 876082a4..b08cf33b 100644 --- a/hcid/dbus-error.c +++ b/hcid/dbus-error.c @@ -29,12 +29,12 @@ #include #include -#include - #include +#include +#include + #include "hcid.h" -#include "dbus-helper.h" #include "dbus-common.h" #include "dbus-error.h" #include "error.h" diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c index ec4e0f50..319d7cbd 100644 --- a/hcid/dbus-hci.c +++ b/hcid/dbus-hci.c @@ -42,9 +42,7 @@ #include #include - #include - #include #include "hcid.h" @@ -53,7 +51,6 @@ #include "adapter.h" #include "device.h" #include "error.h" -#include "dbus-helper.h" #include "glib-helper.h" #include "dbus-common.h" #include "dbus-error.h" diff --git a/hcid/dbus-sdp.c b/hcid/dbus-sdp.c index 0b3bc85e..2a0aa583 100644 --- a/hcid/dbus-sdp.c +++ b/hcid/dbus-sdp.c @@ -46,12 +46,9 @@ #include #include - #include - #include -#include "dbus-helper.h" #include "hcid.h" #include "textfile.h" #include "adapter.h" diff --git a/hcid/dbus-security.c b/hcid/dbus-security.c index 2e4a8bfe..cecb39af 100644 --- a/hcid/dbus-security.c +++ b/hcid/dbus-security.c @@ -39,13 +39,10 @@ #include #include - #include - #include #include "adapter.h" -#include "dbus-helper.h" #include "hcid.h" #include "dbus-common.h" #include "dbus-service.h" diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c index 59228a9d..4e8ff33c 100644 --- a/hcid/dbus-service.c +++ b/hcid/dbus-service.c @@ -42,10 +42,9 @@ #include #include - #include +#include -#include "dbus-helper.h" #include "hcid.h" #include "server.h" #include "dbus-common.h" diff --git a/hcid/dbus-test.c b/hcid/dbus-test.c index d683a901..f63f9b45 100644 --- a/hcid/dbus-test.c +++ b/hcid/dbus-test.c @@ -35,12 +35,9 @@ #include #include - #include - #include -#include "dbus-helper.h" #include "hcid.h" #include "dbus-common.h" #include "adapter.h" diff --git a/hcid/device.c b/hcid/device.c index 56a70ec2..850ce1af 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -42,10 +42,8 @@ #include #include - #include - -#include "dbus-helper.h" +#include #include "hcid.h" #include "sdpd.h" diff --git a/hcid/manager.c b/hcid/manager.c index 0d438217..be92b1b3 100644 --- a/hcid/manager.c +++ b/hcid/manager.c @@ -48,7 +48,6 @@ #include "hcid.h" #include "sdpd.h" #include "adapter.h" -#include "dbus-helper.h" #include "dbus-common.h" #include "error.h" #include "dbus-error.h" diff --git a/input/device.c b/input/device.c index 151ce08c..1975be16 100644 --- a/input/device.c +++ b/input/device.c @@ -41,8 +41,8 @@ #include #include +#include -#include "dbus-helper.h" #include "logging.h" #include "textfile.h" #include "uinput.h" diff --git a/input/manager.c b/input/manager.c index 11e14514..618641f1 100644 --- a/input/manager.c +++ b/input/manager.c @@ -39,10 +39,9 @@ #include #include - #include +#include -#include "dbus-helper.h" #include "logging.h" #include "textfile.h" diff --git a/input/server.c b/input/server.c index 5e29e99f..ea7139ec 100644 --- a/input/server.c +++ b/input/server.c @@ -39,13 +39,13 @@ #include #include +#include #include "logging.h" #include "device.h" #include "server.h" #include "storage.h" -#include "dbus-helper.h" #include "dbus-service.h" static const char* HID_UUID = "00001124-0000-1000-8000-00805f9b34fb"; diff --git a/network/connection.c b/network/connection.c index 466dd203..e5ed6d9c 100644 --- a/network/connection.c +++ b/network/connection.c @@ -39,9 +39,9 @@ #include #include +#include #include "logging.h" -#include "dbus-helper.h" #include "textfile.h" #include "glib-helper.h" diff --git a/network/manager.c b/network/manager.c index 14bea175..39aaa6e0 100644 --- a/network/manager.c +++ b/network/manager.c @@ -39,8 +39,8 @@ #include #include +#include -#include "dbus-helper.h" #include "logging.h" #include "textfile.h" #include "glib-helper.h" diff --git a/network/server.c b/network/server.c index f4fb5176..71b45b22 100644 --- a/network/server.c +++ b/network/server.c @@ -43,11 +43,11 @@ #include #include +#include #include "logging.h" #include "error.h" #include "textfile.h" -#include "dbus-helper.h" #include "dbus-service.h" #include "sdpd.h" diff --git a/serial/manager.c b/serial/manager.c index a10e1631..aa05b8f3 100644 --- a/serial/manager.c +++ b/serial/manager.c @@ -48,10 +48,8 @@ #include #include - #include -#include "dbus-helper.h" #include "logging.h" #include "textfile.h" diff --git a/serial/port.c b/serial/port.c index 98b751be..215dc62b 100644 --- a/serial/port.c +++ b/serial/port.c @@ -40,10 +40,8 @@ #include #include - #include -#include "dbus-helper.h" #include "logging.h" #include "error.h" -- cgit