core: Introduce initial hooks to new mgmt code for adapter.c

This commit is contained in:
Johan Hedberg 2013-01-03 16:57:28 +02:00
parent b58a6519b8
commit 4963a4c6ae
4 changed files with 39 additions and 12 deletions

View File

@ -142,7 +142,9 @@ src_bluetoothd_SOURCES = $(gdbus_sources) $(builtin_sources) \
src/profile.h src/profile.c \
src/device.h src/device.c src/attio.h \
src/dbus-common.c src/dbus-common.h \
src/eir.h src/eir.c src/mgmt.c src/mgmt.h
src/eir.h src/eir.c src/mgmt.c src/mgmt.h \
src/shared/util.h src/shared/util.c \
src/shared/mgmt.h src/shared/mgmt.c
src_bluetoothd_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@ @DBUS_LIBS@ \
-ldl -lrt
src_bluetoothd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic \

View File

@ -50,6 +50,8 @@
#include "log.h"
#include "textfile.h"
#include "src/shared/mgmt.h"
#include "hcid.h"
#include "sdpd.h"
#include "adapter.h"
@ -86,6 +88,8 @@
static GSList *adapters = NULL;
static int default_adapter_id = -1;
struct mgmt *mgmt = NULL;
static const char *base_path = "/org/bluez";
static GSList *adapter_drivers = NULL;
@ -165,6 +169,8 @@ struct btd_adapter {
GSList *profiles;
struct oob_handler *oob_handler;
struct mgmt *mgmt;
};
static gboolean process_auth_queue(gpointer user_data);
@ -3617,17 +3623,6 @@ void btd_adapter_for_each_device(struct btd_adapter *adapter,
g_slist_foreach(adapter->devices, (GFunc) cb, data);
}
void adapter_cleanup(void)
{
while (adapters) {
struct btd_adapter *adapter = adapters->data;
adapter_remove(adapter);
adapters = g_slist_remove(adapters, adapter);
btd_adapter_unref(adapter);
}
}
static int adapter_cmp(gconstpointer a, gconstpointer b)
{
struct btd_adapter *adapter = (struct btd_adapter *) a;
@ -3733,3 +3728,27 @@ int adapter_unregister(int id)
return 0;
}
int adapter_init(void)
{
mgmt = mgmt_new_default();
if (!mgmt)
return -EIO;
return 0;
}
void adapter_cleanup(void)
{
while (adapters) {
struct btd_adapter *adapter = adapters->data;
adapter_remove(adapter);
adapters = g_slist_remove(adapters, adapter);
btd_adapter_unref(adapter);
}
mgmt_unregister_all(mgmt);
mgmt_unref(mgmt);
mgmt = NULL;
}

View File

@ -74,6 +74,7 @@ struct smp_ltk_info {
};
void adapter_cleanup(void);
int adapter_init(void);
struct btd_adapter *adapter_find(const bdaddr_t *sba);
struct btd_adapter *adapter_find_by_id(int id);
struct btd_adapter *adapter_get_default(void);

View File

@ -517,6 +517,11 @@ int main(int argc, char *argv[])
exit(1);
}
if (adapter_init() < 0) {
error("adapter init failed");
exit(1);
}
btd_agent_init();
btd_profile_init();