mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-15 00:04:29 +08:00
core: Move profile code into profile.{c,h}
This commit is contained in:
parent
06a7852b69
commit
b1cde69a66
@ -294,6 +294,7 @@ src_bluetoothd_SOURCES = $(gdbus_sources) $(builtin_sources) \
|
||||
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 \
|
||||
src/dbus-common.c src/dbus-common.h \
|
||||
src/event.h src/event.c \
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "../src/adapter.h"
|
||||
#include "../src/manager.h"
|
||||
#include "../src/device.h"
|
||||
#include "../src/profile.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "device.h"
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "adapter.h"
|
||||
#include "device.h"
|
||||
#include "profile.h"
|
||||
#include "att.h"
|
||||
#include "gattrib.h"
|
||||
#include "gatt.h"
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "adapter.h"
|
||||
#include "device.h"
|
||||
#include "profile.h"
|
||||
#include "att.h"
|
||||
#include "gattrib.h"
|
||||
#include "gatt.h"
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <btio.h>
|
||||
#include <adapter.h>
|
||||
#include <device.h>
|
||||
#include <profile.h>
|
||||
#include <glib-helper.h>
|
||||
#include <log.h>
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "log.h"
|
||||
#include "../src/adapter.h"
|
||||
#include "../src/device.h"
|
||||
#include "../src/profile.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "hcid.h"
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "log.h"
|
||||
#include "../src/adapter.h"
|
||||
#include "../src/device.h"
|
||||
#include "../src/profile.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "hog_device.h"
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include "adapter.h"
|
||||
#include "device.h"
|
||||
#include "profile.h"
|
||||
#include "manager.h"
|
||||
#include "common.h"
|
||||
#include "connection.h"
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include "adapter.h"
|
||||
#include "device.h"
|
||||
#include "profile.h"
|
||||
#include "att.h"
|
||||
#include "gattrib.h"
|
||||
#include "gatt.h"
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "log.h"
|
||||
#include "adapter.h"
|
||||
#include "device.h"
|
||||
#include "profile.h"
|
||||
|
||||
#include "manager.h"
|
||||
#include "server.h"
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "adapter.h"
|
||||
#include "device.h"
|
||||
#include "profile.h"
|
||||
#include "att.h"
|
||||
#include "gattrib.h"
|
||||
#include "gatt.h"
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "manager.h"
|
||||
#include "adapter.h"
|
||||
#include "device.h"
|
||||
#include "profile.h"
|
||||
#include "server.h"
|
||||
|
||||
struct btd_profile time_profile = {
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "adapter.h"
|
||||
#include "manager.h"
|
||||
#include "device.h"
|
||||
#include "profile.h"
|
||||
#include "dbus-common.h"
|
||||
#include "error.h"
|
||||
#include "glib-helper.h"
|
||||
|
42
src/device.c
42
src/device.c
@ -53,6 +53,7 @@
|
||||
#include "gattrib.h"
|
||||
#include "attio.h"
|
||||
#include "device.h"
|
||||
#include "profile.h"
|
||||
#include "dbus-common.h"
|
||||
#include "error.h"
|
||||
#include "glib-helper.h"
|
||||
@ -171,8 +172,6 @@ struct btd_device {
|
||||
guint cleanup_id;
|
||||
};
|
||||
|
||||
static GSList *profiles = NULL;
|
||||
|
||||
static uint16_t uuid_list[] = {
|
||||
L2CAP_UUID,
|
||||
PNP_INFO_SVCLASS_ID,
|
||||
@ -1294,7 +1293,7 @@ void device_probe_profiles(struct btd_device *device, GSList *uuids)
|
||||
|
||||
DBG("Probing profiles for device %s", addr);
|
||||
|
||||
for (l = profiles; l != NULL; l = g_slist_next(l)) {
|
||||
for (l = btd_get_profiles(); l != NULL; l = g_slist_next(l)) {
|
||||
struct btd_profile *profile = l->data;
|
||||
GSList *probe_uuids;
|
||||
int err;
|
||||
@ -3226,40 +3225,3 @@ void device_set_pnpid(struct btd_device *device, uint8_t vendor_id_src,
|
||||
device_set_version(device, product_ver);
|
||||
}
|
||||
|
||||
void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),
|
||||
void *data)
|
||||
{
|
||||
GSList *l, *next;
|
||||
|
||||
for (l = profiles; l != NULL; l = next) {
|
||||
struct btd_profile *profile = l->data;
|
||||
|
||||
next = g_slist_next(l);
|
||||
|
||||
func(profile, data);
|
||||
}
|
||||
}
|
||||
|
||||
int btd_profile_register(struct btd_profile *profile)
|
||||
{
|
||||
profiles = g_slist_append(profiles, profile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void btd_profile_unregister(struct btd_profile *profile)
|
||||
{
|
||||
profiles = g_slist_remove(profiles, profile);
|
||||
}
|
||||
|
||||
void btd_profile_connected(struct btd_profile *profile,
|
||||
struct btd_device *device, int err)
|
||||
{
|
||||
if (err == 0)
|
||||
device->conns = g_slist_append(device->conns, profile);
|
||||
}
|
||||
|
||||
void btd_profile_disconnected(struct btd_profile *profile,
|
||||
struct btd_device *device)
|
||||
{
|
||||
device->conns = g_slist_remove(device->conns, profile);
|
||||
}
|
||||
|
31
src/device.h
31
src/device.h
@ -34,37 +34,6 @@ typedef enum {
|
||||
AUTH_TYPE_NOTIFY_PINCODE,
|
||||
} auth_type_t;
|
||||
|
||||
#define BTD_UUIDS(args...) ((const char *[]) { args, NULL } )
|
||||
|
||||
struct btd_profile {
|
||||
const char *name;
|
||||
|
||||
const char *local_uuid;
|
||||
const char **remote_uuids;
|
||||
|
||||
bool auto_connect;
|
||||
|
||||
int (*device_probe) (struct btd_device *device, GSList *uuids);
|
||||
void (*device_remove) (struct btd_device *device);
|
||||
|
||||
void (*connect) (struct btd_device *device);
|
||||
void (*disconnect) (struct btd_device *device);
|
||||
|
||||
int (*adapter_probe) (struct btd_adapter *adapter);
|
||||
void (*adapter_remove) (struct btd_adapter *adapter);
|
||||
};
|
||||
|
||||
void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),
|
||||
void *data);
|
||||
|
||||
int btd_profile_register(struct btd_profile *profile);
|
||||
void btd_profile_unregister(struct btd_profile *profile);
|
||||
|
||||
void btd_profile_connected(struct btd_profile *profile,
|
||||
struct btd_device *device, int err);
|
||||
void btd_profile_disconnected(struct btd_profile *profile,
|
||||
struct btd_device *device);
|
||||
|
||||
struct btd_device *device_create(DBusConnection *conn,
|
||||
struct btd_adapter *adapter,
|
||||
const char *address, uint8_t bdaddr_type);
|
||||
|
68
src/profile.c
Normal file
68
src/profile.c
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2012 Intel Corporation. All rights reserved.
|
||||
*
|
||||
*
|
||||
* 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include "adapter.h"
|
||||
#include "device.h"
|
||||
#include "profile.h"
|
||||
|
||||
static GSList *profiles = NULL;
|
||||
|
||||
void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),
|
||||
void *data)
|
||||
{
|
||||
GSList *l, *next;
|
||||
|
||||
for (l = profiles; l != NULL; l = next) {
|
||||
struct btd_profile *profile = l->data;
|
||||
|
||||
next = g_slist_next(l);
|
||||
|
||||
func(profile, data);
|
||||
}
|
||||
}
|
||||
|
||||
int btd_profile_register(struct btd_profile *profile)
|
||||
{
|
||||
profiles = g_slist_append(profiles, profile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void btd_profile_unregister(struct btd_profile *profile)
|
||||
{
|
||||
profiles = g_slist_remove(profiles, profile);
|
||||
}
|
||||
|
||||
GSList *btd_get_profiles(void)
|
||||
{
|
||||
return profiles;
|
||||
}
|
50
src/profile.h
Normal file
50
src/profile.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
*
|
||||
* BlueZ - Bluetooth protocol stack for Linux
|
||||
*
|
||||
* Copyright (C) 2012 Intel Corporation. All rights reserved.
|
||||
*
|
||||
*
|
||||
* 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_profile {
|
||||
const char *name;
|
||||
|
||||
const char *local_uuid;
|
||||
const char **remote_uuids;
|
||||
|
||||
bool auto_connect;
|
||||
|
||||
int (*device_probe) (struct btd_device *device, GSList *uuids);
|
||||
void (*device_remove) (struct btd_device *device);
|
||||
|
||||
void (*connect) (struct btd_device *device);
|
||||
void (*disconnect) (struct btd_device *device);
|
||||
|
||||
int (*adapter_probe) (struct btd_adapter *adapter);
|
||||
void (*adapter_remove) (struct btd_adapter *adapter);
|
||||
};
|
||||
|
||||
void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),
|
||||
void *data);
|
||||
|
||||
int btd_profile_register(struct btd_profile *profile);
|
||||
void btd_profile_unregister(struct btd_profile *profile);
|
||||
|
||||
GSList *btd_get_profiles(void);
|
Loading…
Reference in New Issue
Block a user