summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@indt.org.br>2008-08-18 19:20:42 -0300
committerLuiz Augusto von Dentz <luiz.dentz@indt.org.br>2008-08-18 19:20:42 -0300
commitc560d02ccf1dd156f068b1da8a3e7d75d2319dfd (patch)
treef0925d7821b400fe061a97d9521f78daf0ff9f66 /src
parent0dda767d09a31eb13976371730e4cfe5e437869e (diff)
Remove driver.c driver.h and remove workaround for to force a symbol resolution.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/adapter.c119
-rw-r--r--src/adapter.h14
-rw-r--r--src/dbus-service.c156
-rw-r--r--src/dbus-service.h28
-rw-r--r--src/device.c19
-rw-r--r--src/device.h12
-rw-r--r--src/driver.c82
-rw-r--r--src/driver.h50
9 files changed, 160 insertions, 324 deletions
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);