diff --git a/plugins/echo.c b/plugins/echo.c index 2c549089b..7a5ad8d82 100644 --- a/plugins/echo.c +++ b/plugins/echo.c @@ -37,7 +37,8 @@ #include #include "plugin.h" -#include "server.h" +#include "adapter.h" +#include "driver.h" #include "logging.h" static gboolean session_event(GIOChannel *chan, @@ -123,24 +124,28 @@ static GIOChannel *setup_rfcomm(uint8_t channel) static GIOChannel *chan = NULL; -static int echo_probe(const char *adapter) +static int echo_probe(struct adapter *adapter) { - debug("echo probe adapter %s", adapter); + const char *path = adapter_get_path(adapter); + + DBG("path %s", path); chan = setup_rfcomm(23); return 0; } -static void echo_remove(const char *adapter) +static void echo_remove(struct adapter *adapter) { - debug("echo remove adapter %s", adapter); + const char *path = adapter_get_path(adapter); + + DBG("path %s", path); g_io_channel_unref(chan); } -static struct bt_server echo_server = { - .uuid = "00001101-0000-1000-8000-00805F9B34FB", +static struct btd_adapter_driver echo_server = { + .name = "echo-server", .probe = echo_probe, .remove = echo_remove, }; @@ -149,14 +154,14 @@ static int echo_init(void) { debug("Setup echo plugin"); - return bt_register_server(&echo_server); + return btd_register_adapter_driver(&echo_server); } static void echo_exit(void) { debug("Cleanup echo plugin"); - bt_unregister_server(&echo_server); + btd_unregister_adapter_driver(&echo_server); } BLUETOOTH_PLUGIN_DEFINE("echo", echo_init, echo_exit) diff --git a/src/Makefile.am b/src/Makefile.am index 7f0e72e53..4b504add6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ sbin_PROGRAMS = bluetoothd bluetoothd_SOURCES = main.c hcid.h sdpd.h \ sdpd-server.c sdpd-request.c sdpd-service.c \ sdpd-database.c security.c storage.c \ - manager.h manager.c error.h error.c server.h server.c \ + manager.h manager.c error.h error.c \ adapter.h adapter.c device.h device.c plugin.h plugin.c \ dbus-common.c dbus-common.h dbus-hci.h dbus-hci.c \ dbus-database.c dbus-database.h dbus-service.c dbus-service.h \ diff --git a/src/dbus-service.c b/src/dbus-service.c index a85c3d8a8..6673575c8 100644 --- a/src/dbus-service.c +++ b/src/dbus-service.c @@ -46,7 +46,6 @@ #include #include "hcid.h" -#include "server.h" #include "dbus-common.h" #include "error.h" #include "manager.h" diff --git a/src/driver.h b/src/driver.h index 6ed56d536..a69ebab10 100644 --- a/src/driver.h +++ b/src/driver.h @@ -39,14 +39,12 @@ int btd_register_device_driver(struct btd_device_driver *driver); void btd_unregister_device_driver(struct btd_device_driver *driver); GSList *btd_get_device_drivers(void); -struct btd_adapter; +struct adapter; struct btd_adapter_driver { const char *name; - int (*probe) (struct btd_adapter_driver *driver, - struct btd_adapter *adapter); - void (*remove) (struct btd_adapter_driver *driver, - struct btd_adapter *adapter); + int (*probe) (struct adapter *adapter); + void (*remove) (struct adapter *adapter); }; int btd_register_adapter_driver(struct btd_adapter_driver *driver); diff --git a/src/manager.c b/src/manager.c index fc0c87382..51fb6011a 100644 --- a/src/manager.c +++ b/src/manager.c @@ -452,7 +452,7 @@ int manager_register_adapter(int id) struct btd_adapter_driver *driver = l->data; if (driver->probe) - driver->probe(driver, (struct btd_adapter *) adapter); + driver->probe(adapter); } manager_add_adapter(adapter); @@ -478,7 +478,7 @@ int manager_unregister_adapter(int id) struct btd_adapter_driver *driver = l->data; if (driver->remove) - driver->remove(driver, (struct btd_adapter *) adapter); + driver->remove(adapter); } adapter_stop(adapter); diff --git a/src/server.c b/src/server.c deleted file mode 100644 index da2401122..000000000 --- a/src/server.c +++ /dev/null @@ -1,68 +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 "server.h" - -static GSList *servers = NULL; - -int bt_register_server(struct bt_server *server) -{ - servers = g_slist_append(servers, server); - - return 0; -} - -void bt_unregister_server(struct bt_server *server) -{ - servers = g_slist_remove(servers, server); -} - -void __probe_servers(const char *adapter) -{ - GSList *list; - - for (list = servers; list; list = list->next) { - struct bt_server *server = list->data; - - if (server->probe) - server->probe(adapter); - } -} - -void __remove_servers(const char *adapter) -{ - GSList *list; - - for (list = servers; list; list = list->next) { - struct bt_server *server = list->data; - - if (server->remove) - server->remove(adapter); - } -} diff --git a/src/server.h b/src/server.h deleted file mode 100644 index f60ab88bd..000000000 --- a/src/server.h +++ /dev/null @@ -1,31 +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 - * - */ - -struct bt_server { - const char *uuid; - int (*probe) (const char *adapter); - void (*remove) (const char *adapter); -}; - -int bt_register_server(struct bt_server *server); -void bt_unregister_server(struct bt_server *server);