From 0a67ad2c8ea68d41c76ca2cae3cc2beca962adcf Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 3 Jan 2013 14:45:55 +0200 Subject: [PATCH] core: Remove manager.{c,h} --- Makefile.am | 1 - src/main.c | 1 - src/manager.c | 203 -------------------------------------------------- src/manager.h | 38 ---------- 4 files changed, 243 deletions(-) delete mode 100644 src/manager.c delete mode 100644 src/manager.h diff --git a/Makefile.am b/Makefile.am index 84e51a36e..bbaa4e043 100644 --- a/Makefile.am +++ b/Makefile.am @@ -138,7 +138,6 @@ src_bluetoothd_SOURCES = $(gdbus_sources) $(builtin_sources) \ src/storage.h src/storage.c \ src/agent.h src/agent.c \ src/error.h src/error.c \ - src/manager.h src/manager.c \ src/adapter.h src/adapter.c \ src/profile.h src/profile.c \ src/device.h src/device.c src/attio.h \ diff --git a/src/main.c b/src/main.c index cb989f979..8c3570f85 100644 --- a/src/main.c +++ b/src/main.c @@ -54,7 +54,6 @@ #include "dbus-common.h" #include "agent.h" #include "profile.h" -#include "manager.h" #include "mgmt.h" #include "systemd.h" diff --git a/src/manager.c b/src/manager.c deleted file mode 100644 index 9d115c13f..000000000 --- a/src/manager.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2006-2010 Nokia Corporation - * Copyright (C) 2004-2010 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 -#include -#include - -#include -#include -#include - -#include - -#include - -#include - -#include "glib-helper.h" -#include "hcid.h" -#include "dbus-common.h" -#include "log.h" -#include "adapter.h" -#include "device.h" -#include "error.h" -#include "manager.h" - -static int default_adapter_id = -1; -static GSList *adapters = NULL; - -static void manager_set_default_adapter(int id) -{ - default_adapter_id = id; -} - -struct btd_adapter *manager_get_default_adapter(void) -{ - return manager_find_adapter_by_id(default_adapter_id); -} - -static void manager_remove_adapter(struct btd_adapter *adapter) -{ - uint16_t dev_id = adapter_get_dev_id(adapter); - - adapters = g_slist_remove(adapters, adapter); - - if (default_adapter_id == dev_id || default_adapter_id < 0) { - int new_default = hci_get_route(NULL); - - manager_set_default_adapter(new_default); - } - - adapter_remove(adapter); - btd_adapter_unref(adapter); -} - -void manager_cleanup(void) -{ - while (adapters) { - struct btd_adapter *adapter = adapters->data; - - adapter_remove(adapter); - adapters = g_slist_remove(adapters, adapter); - btd_adapter_unref(adapter); - } -} - -static gint adapter_id_cmp(gconstpointer a, gconstpointer b) -{ - struct btd_adapter *adapter = (struct btd_adapter *) a; - uint16_t id = GPOINTER_TO_UINT(b); - uint16_t dev_id = adapter_get_dev_id(adapter); - - return dev_id == id ? 0 : -1; -} - -static gint adapter_cmp(gconstpointer a, gconstpointer b) -{ - struct btd_adapter *adapter = (struct btd_adapter *) a; - const bdaddr_t *bdaddr = b; - - return bacmp(adapter_get_address(adapter), bdaddr); -} - -struct btd_adapter *manager_find_adapter(const bdaddr_t *sba) -{ - GSList *match; - - match = g_slist_find_custom(adapters, sba, adapter_cmp); - if (!match) - return NULL; - - return match->data; -} - -struct btd_adapter *manager_find_adapter_by_id(int id) -{ - GSList *match; - - match = g_slist_find_custom(adapters, GINT_TO_POINTER(id), - adapter_id_cmp); - if (!match) - return NULL; - - return match->data; -} - -void manager_foreach_adapter(adapter_cb func, gpointer user_data) -{ - g_slist_foreach(adapters, (GFunc) func, user_data); -} - -GSList *manager_get_adapters(void) -{ - return adapters; -} - -struct btd_adapter *btd_manager_register_adapter(int id, gboolean powered, - bool connectable, - bool discoverable) -{ - struct btd_adapter *adapter; - const char *path; - - adapter = manager_find_adapter_by_id(id); - if (adapter) { - error("Unable to register adapter: hci%d already exist", id); - return NULL; - } - - adapter = adapter_create(id); - if (!adapter) - return NULL; - - adapters = g_slist_append(adapters, adapter); - - if (!adapter_setup(adapter, powered, connectable, discoverable)) { - adapters = g_slist_remove(adapters, adapter); - btd_adapter_unref(adapter); - return NULL; - } - - path = adapter_get_path(adapter); - - if (default_adapter_id < 0) - manager_set_default_adapter(id); - - if (main_opts.did_source) - btd_adapter_set_did(adapter, main_opts.did_vendor, - main_opts.did_product, - main_opts.did_version, - main_opts.did_source); - - DBG("Adapter %s registered", path); - - return btd_adapter_ref(adapter); -} - -int btd_manager_unregister_adapter(int id) -{ - struct btd_adapter *adapter; - const gchar *path; - - adapter = manager_find_adapter_by_id(id); - if (!adapter) - return -1; - - path = adapter_get_path(adapter); - - DBG("Unregister path: %s", path); - - manager_remove_adapter(adapter); - - return 0; -} diff --git a/src/manager.h b/src/manager.h deleted file mode 100644 index 37e8cb058..000000000 --- a/src/manager.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2006-2010 Nokia Corporation - * Copyright (C) 2004-2010 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 - -void manager_cleanup(void); - -struct btd_adapter *manager_find_adapter(const bdaddr_t *sba); -struct btd_adapter *manager_find_adapter_by_id(int id); -struct btd_adapter *manager_get_default_adapter(void); -void manager_foreach_adapter(adapter_cb func, gpointer user_data); -GSList *manager_get_adapters(void); -struct btd_adapter *btd_manager_register_adapter(int id, gboolean powered, - bool connectable, - bool discoverable); -int btd_manager_unregister_adapter(int id); -- 2.47.3