diff options
| -rw-r--r-- | audio/avdtp.c | 9 | ||||
| -rw-r--r-- | audio/control.c | 8 | ||||
| -rw-r--r-- | audio/manager.c | 8 | ||||
| -rw-r--r-- | input/main.c | 1 | ||||
| -rw-r--r-- | input/manager.c | 1 | ||||
| -rw-r--r-- | input/server.c | 6 | ||||
| -rw-r--r-- | network/manager.c | 1 | ||||
| -rw-r--r-- | network/server.c | 7 | ||||
| -rw-r--r-- | plugins/echo.c | 1 | ||||
| -rw-r--r-- | serial/manager.c | 1 | ||||
| -rw-r--r-- | src/Makefile.am | 4 | ||||
| -rw-r--r-- | src/adapter.c | 119 | ||||
| -rw-r--r-- | src/adapter.h | 14 | ||||
| -rw-r--r-- | src/dbus-service.c | 156 | ||||
| -rw-r--r-- | src/dbus-service.h | 28 | ||||
| -rw-r--r-- | src/device.c | 19 | ||||
| -rw-r--r-- | src/device.h | 12 | ||||
| -rw-r--r-- | src/driver.c | 82 | ||||
| -rw-r--r-- | src/driver.h | 50 | 
19 files changed, 180 insertions, 347 deletions
| diff --git a/audio/avdtp.c b/audio/avdtp.c index bda21ac5..c215ca24 100644 --- a/audio/avdtp.c +++ b/audio/avdtp.c @@ -40,9 +40,9 @@  #include <glib.h>  #include <dbus/dbus.h> -#include "dbus-service.h"  #include "logging.h" +#include "adapter.h"  #include "device.h"  #include "manager.h"  #include "control.h" @@ -2684,7 +2684,7 @@ static void auth_cb(DBusError *derr, void *user_data)  		error("Access denied: %s", derr->message);  		if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY)) {  			debug("Canceling authorization request"); -			service_cancel_auth(&session->src, &session->dst); +			btd_cancel_authorization(&session->src, &session->dst);  		}  		connection_lost(session, -EACCES); @@ -2757,8 +2757,9 @@ static void avdtp_server_cb(GIOChannel *chan, int err, const bdaddr_t *src,  					(GIOFunc) session_cb, session);  	g_io_channel_unref(chan); -	if (service_req_auth(src, dst, ADVANCED_AUDIO_UUID, auth_cb, -			session) < 0) { +	err = btd_request_authorization(src, dst, ADVANCED_AUDIO_UUID, +				auth_cb, session); +	if (err < 0) {  		avdtp_unref(session);  		goto drop;  	} diff --git a/audio/control.c b/audio/control.c index 2a5e5e23..82646061 100644 --- a/audio/control.c +++ b/audio/control.c @@ -46,9 +46,9 @@  #include <dbus/dbus.h>  #include <gdbus.h> -#include "dbus-service.h"  #include "logging.h"  #include "uinput.h" +#include "adapter.h"  #include "device.h"  #include "manager.h"  #include "avdtp.h" @@ -629,7 +629,7 @@ static void auth_cb(DBusError *derr, void *user_data)  		error("Access denied: %s", derr->message);  		if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY)) {  			debug("Canceling authorization request"); -			service_cancel_auth(&session->src, &session->dst); +			btd_cancel_authorization(&session->src, &session->dst);  		}  		avctp_unref(session); @@ -687,7 +687,9 @@ static void avctp_server_cb(GIOChannel *chan, int err, const bdaddr_t *src,  	if (avdtp_is_connected(src, dst))  		goto proceed; -	if (service_req_auth(src, dst, AVRCP_TARGET_UUID, auth_cb, session) < 0) +	err = btd_request_authorization(src, dst, AVRCP_TARGET_UUID, +				auth_cb, session); +	if (err < 0)  		goto drop;  	return; diff --git a/audio/manager.c b/audio/manager.c index 6d17a5fd..5a363f9c 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -51,9 +51,7 @@  #include "glib-helper.h"  #include "../src/adapter.h"  #include "../src/device.h" -#include "../src/driver.h" -#include "dbus-service.h"  #include "logging.h"  #include "textfile.h"  #include "ipc.h" @@ -458,7 +456,7 @@ static void auth_cb(DBusError *derr, void *user_data)  		error("Access denied: %s", derr->message);  		if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY)) {  			debug("Canceling authorization request"); -			service_cancel_auth(&device->src, &device->dst); +			btd_cancel_authorization(&device->src, &device->dst);  		}  		headset_set_state(device, HEADSET_STATE_DISCONNECTED); @@ -512,8 +510,8 @@ static void ag_io_cb(GIOChannel *chan, int err, const bdaddr_t *src,  		goto drop;  	} -	err = service_req_auth(&device->src, &device->dst, uuid, auth_cb, -				device); +	err = btd_request_authorization(&device->src, &device->dst, uuid, +				auth_cb, device);  	if (err < 0) {  		debug("Authorization denied: %s", strerror(-err));  		headset_close_rfcomm(device); diff --git a/input/main.c b/input/main.c index d70bf2a0..d3d152e0 100644 --- a/input/main.c +++ b/input/main.c @@ -34,7 +34,6 @@  #include "plugin.h"  #include "logging.h" -#include "dbus-service.h"  #include "manager.h"  static GKeyFile *load_config_file(const char *file) diff --git a/input/manager.c b/input/manager.c index 4a461b4e..b8f8b2de 100644 --- a/input/manager.c +++ b/input/manager.c @@ -46,7 +46,6 @@  #include "textfile.h"  #include "../src/adapter.h"  #include "../src/device.h" -#include "../src/driver.h"  #include "device.h"  #include "server.h" diff --git a/input/server.c b/input/server.c index 9267e4aa..d8bd1925 100644 --- a/input/server.c +++ b/input/server.c @@ -44,10 +44,10 @@  #include "logging.h" +#include "adapter.h"  #include "device.h"  #include "server.h"  #include "storage.h" -#include "dbus-service.h"  #include "glib-helper.h"  static const char *HID_UUID = "00001124-0000-1000-8000-00805f9b34fb"; @@ -64,7 +64,7 @@ static void auth_callback(DBusError *derr, void *user_data)  	if (derr) {  		error("Access denied: %s", derr->message);  		if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY)) -			service_cancel_auth(&auth->src, &auth->dst); +			btd_cancel_authorization(&auth->src, &auth->dst);  		input_device_close_channels(&auth->src, &auth->dst);  	} else @@ -81,7 +81,7 @@ static int authorize_device(const bdaddr_t *src, const bdaddr_t *dst)  	bacpy(&auth->src, src);  	bacpy(&auth->dst, dst); -	return service_req_auth(src, dst, HID_UUID, +	return btd_request_authorization(src, dst, HID_UUID,  				auth_callback, auth);  } diff --git a/network/manager.c b/network/manager.c index c03b7943..7cbf8220 100644 --- a/network/manager.c +++ b/network/manager.c @@ -47,7 +47,6 @@  #include "adapter.h"  #include "device.h" -#include "driver.h"  #include "error.h"  #include "bridge.h"  #include "manager.h" diff --git a/network/server.c b/network/server.c index ec0c4900..aafdd4fc 100644 --- a/network/server.c +++ b/network/server.c @@ -47,11 +47,11 @@  #include <gdbus.h>  #include "../src/dbus-common.h" +#include "../src/adapter.h"  #include "logging.h"  #include "error.h"  #include "textfile.h" -#include "dbus-service.h"  #include "sdpd.h"  #include "glib-helper.h" @@ -359,7 +359,7 @@ static void req_auth_cb(DBusError *derr, void *user_data)  		if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY)) {  			bdaddr_t dst;  			str2ba(setup->address, &dst); -			service_cancel_auth(&na->src, &dst); +			btd_cancel_authorization(&na->src, &dst);  		}  		val = BNEP_CONN_NOT_ALLOWED;  		goto done; @@ -387,7 +387,8 @@ static int authorize_connection(struct network_server *ns, const char *address)  	uuid = bnep_uuid(ns->id);  	str2ba(address, &dst); -	ret_val = service_req_auth(&na->src, &dst, uuid, req_auth_cb, ns); +	ret_val = btd_request_authorization(&na->src, &dst, uuid, +				req_auth_cb, ns);  	return ret_val;  } diff --git a/plugins/echo.c b/plugins/echo.c index 7a5ad8d8..ead488e4 100644 --- a/plugins/echo.c +++ b/plugins/echo.c @@ -38,7 +38,6 @@  #include "plugin.h"  #include "adapter.h" -#include "driver.h"  #include "logging.h"  static gboolean session_event(GIOChannel *chan, diff --git a/serial/manager.c b/serial/manager.c index 05af27b4..6bcb3dd3 100644 --- a/serial/manager.c +++ b/serial/manager.c @@ -54,7 +54,6 @@  #include "../src/dbus-common.h"  #include "adapter.h"  #include "device.h" -#include "driver.h"  #include "logging.h"  #include "textfile.h" diff --git a/src/Makefile.am b/src/Makefile.am index 4b504add..e44ae579 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,8 +21,8 @@ bluetoothd_SOURCES = main.c hcid.h sdpd.h \  	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 \ -	telephony.h telephony.c agent.h agent.c driver.h driver.c +	dbus-database.c dbus-database.h \ +	telephony.h telephony.c agent.h agent.c  bluetoothd_LDADD = $(top_builddir)/common/libhelper.a \  	@GDBUS_LIBS@ @GMODULE_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@ diff --git a/src/adapter.c b/src/adapter.c index 70adab21..e8e27715 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -51,6 +51,7 @@  #include "hcid.h"  #include "sdpd.h" +#include "manager.h"  #include "adapter.h"  #include "device.h" @@ -63,7 +64,6 @@  #include "glib-helper.h"  #include "logging.h"  #include "agent.h" -#include "driver.h"  #define NUM_ELEMENTS(table) (sizeof(table)/sizeof(const char *)) @@ -74,6 +74,7 @@  #define IO_CAPABILITY_INVALID		0xFF  static DBusConnection *connection = NULL; +static GSList *adapter_drivers = NULL;  struct record_list {    sdp_list_t *recs; @@ -88,6 +89,11 @@ struct mode_req {  	guint		id;		/* Listener id */  }; +struct service_auth { +	service_auth_cb cb; +	void *user_data; +}; +  static inline DBusMessage *invalid_args(DBusMessage *msg)  {  	return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments", @@ -2220,7 +2226,7 @@ static void load_drivers(struct adapter *adapter)  {  	GSList *l; -	for (l = btd_get_adapter_drivers(); l; l = l->next) { +	for (l = adapter_drivers; l; l = l->next) {  		struct btd_adapter_driver *driver = l->data;  		if (driver->probe) @@ -2436,7 +2442,7 @@ static void unload_drivers(struct adapter *adapter)  {  	GSList *l; -	for (l = btd_get_adapter_drivers(); l; l = l->next) { +	for (l = adapter_drivers; l; l = l->next) {  		struct btd_adapter_driver *driver = l->data;  		if (driver->remove) @@ -2757,3 +2763,110 @@ int adapter_get_state(struct adapter *adapter)  {  	return adapter->state;  } + +int btd_register_adapter_driver(struct btd_adapter_driver *driver) +{ +	adapter_drivers = g_slist_append(adapter_drivers, driver); + +	return 0; +} + +void btd_unregister_adapter_driver(struct btd_adapter_driver *driver) +{ +	adapter_drivers = g_slist_remove(adapter_drivers, driver); +} + +static void agent_auth_cb(struct agent *agent, DBusError *derr, void *user_data) +{ +	struct service_auth *auth = user_data; + +	auth->cb(derr, auth->user_data); + +	g_free(auth); +} + +int btd_request_authorization(const bdaddr_t *src, const bdaddr_t *dst, +		const char *uuid, service_auth_cb cb, void *user_data) +{ +	struct service_auth *auth; +	struct adapter *adapter; +	struct btd_device *device; +	struct agent *agent; +	char address[18]; +	gboolean trusted; +	const gchar *dev_path; + +	if (src == NULL || dst == NULL) +		return -EINVAL; + +	adapter = manager_find_adapter(src); +	if (!adapter) +		return -EPERM; + +	/* Device connected? */ +	if (!g_slist_find_custom(adapter->active_conn, +				dst, active_conn_find_by_bdaddr)) +		return -ENOTCONN; + +	ba2str(dst, address); +	trusted = read_trust(src, address, GLOBAL_TRUST); + +	if (trusted) { +		cb(NULL, user_data); +		return 0; +	} + +	device = adapter_find_device(adapter, address); +	if (!device) +		return -EPERM; + +	agent = device_get_agent(device); + +	if (!agent) +		agent =  adapter->agent; + +	if (!agent) +		return -EPERM; + +	auth = g_try_new0(struct service_auth, 1); +	if (!auth) +		return -ENOMEM; + +	auth->cb = cb; +	auth->user_data = user_data; + +	dev_path = device_get_path(device); + +	return agent_authorize(agent, dev_path, uuid, agent_auth_cb, auth); +} + +int btd_cancel_authorization(const bdaddr_t *src, const bdaddr_t *dst) +{ +	struct adapter *adapter = manager_find_adapter(src); +	struct btd_device *device; +	struct agent *agent; +	char address[18]; + +	if (!adapter) +		return -EPERM; + +	ba2str(dst, address); +	device = adapter_find_device(adapter, address); +	if (!device) +		return -EPERM; + +	/* +	 * FIXME: Cancel fails if authorization is requested to adapter's +	 * agent and in the meanwhile CreatePairedDevice is called. +	 */ + +	agent = device_get_agent(device); + +	if (!agent) +		agent =  adapter->agent; + +	if (!agent) +		return -EPERM; + +	return agent_cancel(agent); +} diff --git a/src/adapter.h b/src/adapter.h index 7ea6fb23..729ef683 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -180,3 +180,17 @@ void adapter_set_mode(struct adapter *adapter, uint8_t mode);  uint8_t adapter_get_mode(struct adapter *adapter);  void adapter_set_state(struct adapter *adapter, int state);  int adapter_get_state(struct adapter *adapter); + +struct btd_adapter_driver { +	const char *name; +	int (*probe) (struct adapter *adapter); +	void (*remove) (struct adapter *adapter); +}; + +typedef void (*service_auth_cb) (DBusError *derr, void *user_data); + +int btd_register_adapter_driver(struct btd_adapter_driver *driver); +void btd_unregister_adapter_driver(struct btd_adapter_driver *driver); +int btd_request_authorization(const bdaddr_t *src, const bdaddr_t *dst, +		const char *uuid, service_auth_cb cb, void *user_data); +int btd_cancel_authorization(const bdaddr_t *src, const bdaddr_t *dst); diff --git a/src/dbus-service.c b/src/dbus-service.c deleted file mode 100644 index 6673575c..00000000 --- a/src/dbus-service.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - *  BlueZ - Bluetooth protocol stack for Linux - * - *  Copyright (C) 2006-2007  Nokia Corporation - *  Copyright (C) 2004-2008  Marcel Holtmann <marcel@holtmann.org> - * - * - *  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 <config.h> -#endif - -#include <stdio.h> -#include <errno.h> -#include <unistd.h> -#include <stdlib.h> -#include <dirent.h> -#include <signal.h> -#include <ctype.h> -#include <sys/types.h> -#include <sys/wait.h> - -#include <bluetooth/bluetooth.h> -#include <bluetooth/hci.h> -#include <bluetooth/hci_lib.h> -#include <bluetooth/sdp.h> - -#include <glib.h> -#include <dbus/dbus.h> -#include <gdbus.h> - -#include "hcid.h" -#include "dbus-common.h" -#include "error.h" -#include "manager.h" -#include "adapter.h" -#include "agent.h" -#include "device.h" -#include "dbus-service.h" -#include "dbus-hci.h" - -struct service_auth { -	service_auth_cb cb; -	void *user_data; -}; - -static void agent_auth_cb(struct agent *agent, DBusError *derr, void *user_data) -{ -	struct service_auth *auth = user_data; - -	auth->cb(derr, auth->user_data); - -	g_free(auth); -} - -int service_req_auth(const bdaddr_t *src, const bdaddr_t *dst, -		const char *uuid, service_auth_cb cb, void *user_data) -{ -	struct service_auth *auth; -	struct adapter *adapter; -	struct btd_device *device; -	struct agent *agent; -	char address[18]; -	gboolean trusted; -	const gchar *dev_path; - -	if (src == NULL || dst == NULL) -		return -EINVAL; - -	adapter = manager_find_adapter(src); -	if (!adapter) -		return -EPERM; - -	/* Device connected? */ -	if (!g_slist_find_custom(adapter->active_conn, -				dst, active_conn_find_by_bdaddr)) -		return -ENOTCONN; - -	ba2str(dst, address); -	trusted = read_trust(src, address, GLOBAL_TRUST); - -	if (trusted) { -		cb(NULL, user_data); -		return 0; -	} - -	device = adapter_find_device(adapter, address); -	if (!device) -		return -EPERM; - -	agent = device_get_agent(device); - -	if (!agent) -		agent =  adapter->agent; - -	if (!agent) -		return -EPERM; - -	auth = g_try_new0(struct service_auth, 1); -	if (!auth) -		return -ENOMEM; - -	auth->cb = cb; -	auth->user_data = user_data; - -	dev_path = device_get_path(device); - -	return agent_authorize(agent, dev_path, uuid, agent_auth_cb, auth); -} - -int service_cancel_auth(const bdaddr_t *src, const bdaddr_t *dst) -{ -	struct adapter *adapter = manager_find_adapter(src); -	struct btd_device *device; -	struct agent *agent; -	char address[18]; - -	if (!adapter) -		return -EPERM; - -	ba2str(dst, address); -	device = adapter_find_device(adapter, address); -	if (!device) -		return -EPERM; - -	/* -	 * FIXME: Cancel fails if authorization is requested to adapter's -	 * agent and in the meanwhile CreatePairedDevice is called. -	 */ - -	agent = device_get_agent(device); - -	if (!agent) -		agent =  adapter->agent; - -	if (!agent) -		return -EPERM; - -	return agent_cancel(agent); -} diff --git a/src/dbus-service.h b/src/dbus-service.h deleted file mode 100644 index 374f9008..00000000 --- a/src/dbus-service.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - *  BlueZ - Bluetooth protocol stack for Linux - * - *  Copyright (C) 2006-2007  Nokia Corporation - *  Copyright (C) 2004-2008  Marcel Holtmann <marcel@holtmann.org> - * - * - *  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 - * - */ - -typedef void (*service_auth_cb) (DBusError *derr, void *user_data); -int service_req_auth(const bdaddr_t *src, const bdaddr_t *dst, -		const char *uuid, service_auth_cb cb, void *user_data); -int service_cancel_auth(const bdaddr_t *src, const bdaddr_t *dst); diff --git a/src/device.c b/src/device.c index b22695e1..a8f40f8e 100644 --- a/src/device.c +++ b/src/device.c @@ -61,7 +61,6 @@  #include "glib-helper.h"  #include "agent.h"  #include "sdp-xml.h" -#include "driver.h"  #define DEFAULT_XML_BUF_SIZE	1024  #define DISCONNECT_TIMER	2 @@ -110,6 +109,8 @@ static uint16_t uuid_list[] = {  	0  }; +static GSList *device_drivers = NULL; +  static void device_free(gpointer user_data)  {  	struct btd_device *device = user_data; @@ -618,13 +619,13 @@ sdp_record_t *get_record(sdp_list_t *recs, const char *uuid)  void device_probe_drivers(struct btd_device *device, GSList *uuids, sdp_list_t *recs)  { -	GSList *list = btd_get_device_drivers(); +	GSList *list;  	const char **uuid;  	int err;  	debug("Probe drivers for %s", device->path); -	for (; list; list = list->next) { +	for (list = device_drivers; list; list = list->next) {  		struct btd_device_driver *driver = list->data;  		GSList *records = NULL; @@ -1083,3 +1084,15 @@ uint8_t device_get_auth(struct btd_device *device)  {  	return device->auth;  } + +int btd_register_device_driver(struct btd_device_driver *driver) +{ +	device_drivers = g_slist_append(device_drivers, driver); + +	return 0; +} + +void btd_unregister_device_driver(struct btd_device_driver *driver) +{ +	device_drivers = g_slist_remove(device_drivers, driver); +} diff --git a/src/device.h b/src/device.h index c29d670b..bbb0846f 100644 --- a/src/device.h +++ b/src/device.h @@ -42,3 +42,15 @@ void device_set_temporary(struct btd_device *device, gboolean temporary);  void device_set_cap(struct btd_device *device, uint8_t cap);  void device_set_auth(struct btd_device *device, uint8_t auth);  uint8_t device_get_auth(struct btd_device *device); + +#define BTD_UUIDS(args...) ((const char *[]) { args, NULL } ) + +struct btd_device_driver { +	const char *name; +	const char **uuids; +	int (*probe) (struct btd_device *device, GSList *records); +	void (*remove) (struct btd_device *device); +}; + +int btd_register_device_driver(struct btd_device_driver *driver); +void btd_unregister_device_driver(struct btd_device_driver *driver); diff --git a/src/driver.c b/src/driver.c deleted file mode 100644 index 5c47a250..00000000 --- a/src/driver.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - *  BlueZ - Bluetooth protocol stack for Linux - * - *  Copyright (C) 2006-2007  Nokia Corporation - *  Copyright (C) 2004-2008  Marcel Holtmann <marcel@holtmann.org> - * - * - *  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 <config.h> -#endif - -#include <bluetooth/bluetooth.h> - -#include <dbus/dbus.h> -#include <glib.h> - -#include "logging.h" - -#include "driver.h" -#include "dbus-service.h" - -static GSList *device_drivers = NULL; -static GSList *adapter_drivers = NULL; - -int btd_register_device_driver(struct btd_device_driver *driver) -{ -	const char **uuid; - -	/* FIXME: hack to make hci to resolve service_req_auth symbol*/ -	service_req_auth(NULL, NULL, NULL, NULL, NULL); -	device_drivers = g_slist_append(device_drivers, driver); - -	for (uuid = driver->uuids; *uuid; uuid++) { -		debug("name %s uuid %s", driver->name, *uuid); -	} - -	return 0; -} - -void btd_unregister_device_driver(struct btd_device_driver *driver) -{ -	device_drivers = g_slist_remove(device_drivers, driver); -} - -GSList *btd_get_device_drivers() -{ -	return device_drivers; -} - -int btd_register_adapter_driver(struct btd_adapter_driver *driver) -{ -	adapter_drivers = g_slist_append(adapter_drivers, driver); - -	return 0; -} - -void btd_unregister_adapter_driver(struct btd_adapter_driver *driver) -{ -	adapter_drivers = g_slist_remove(adapter_drivers, driver); -} - -GSList *btd_get_adapter_drivers() -{ -	return adapter_drivers; -} diff --git a/src/driver.h b/src/driver.h deleted file mode 100644 index e27c7de5..00000000 --- a/src/driver.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - *  BlueZ - Bluetooth protocol stack for Linux - * - *  Copyright (C) 2006-2007  Nokia Corporation - *  Copyright (C) 2004-2008  Marcel Holtmann <marcel@holtmann.org> - * - * - *  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 - * - */ - -#define BTD_UUIDS(args...) ((const char *[]) { args, NULL } ) - -struct btd_device; - -struct btd_device_driver { -	const char *name; -	const char **uuids; -	int (*probe) (struct btd_device *device, GSList *records); -	void (*remove) (struct btd_device *device); -}; - -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 adapter; - -struct btd_adapter_driver { -	const char *name; -	int (*probe) (struct adapter *adapter); -	void (*remove) (struct adapter *adapter); -}; - -int btd_register_adapter_driver(struct btd_adapter_driver *driver); -void btd_unregister_adapter_driver(struct btd_adapter_driver *driver); -GSList *btd_get_adapter_drivers(void); | 
