2007-03-10 06:32:47 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* BlueZ - Bluetooth protocol stack for Linux
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2007 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
|
|
|
|
|
2007-04-09 09:14:21 +08:00
|
|
|
#include <stdio.h>
|
2007-05-19 09:18:39 +08:00
|
|
|
#include <stdlib.h>
|
2007-05-31 17:23:17 +08:00
|
|
|
#include <stdarg.h>
|
2007-04-09 09:14:21 +08:00
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
2007-04-10 19:44:10 +08:00
|
|
|
#include <stdint.h>
|
2007-06-23 07:50:24 +08:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <ctype.h>
|
2007-04-09 09:14:21 +08:00
|
|
|
|
2007-04-10 19:44:10 +08:00
|
|
|
#include <bluetooth/bluetooth.h>
|
2007-06-23 07:50:24 +08:00
|
|
|
#include <bluetooth/hci.h>
|
|
|
|
#include <bluetooth/hci_lib.h>
|
2007-04-10 19:44:10 +08:00
|
|
|
#include <bluetooth/rfcomm.h>
|
2007-05-19 09:18:39 +08:00
|
|
|
#include <bluetooth/sdp.h>
|
|
|
|
#include <bluetooth/sdp_lib.h>
|
2007-04-10 19:44:10 +08:00
|
|
|
|
2007-04-09 09:14:21 +08:00
|
|
|
#include <glib.h>
|
|
|
|
|
2007-04-09 07:19:19 +08:00
|
|
|
#include <dbus/dbus.h>
|
|
|
|
|
2007-05-09 23:51:02 +08:00
|
|
|
#include "dbus-helper.h"
|
2007-04-09 09:14:21 +08:00
|
|
|
#include "logging.h"
|
2007-06-23 07:50:24 +08:00
|
|
|
#include "textfile.h"
|
2007-03-10 06:32:47 +08:00
|
|
|
#include "manager.h"
|
2007-06-23 04:58:12 +08:00
|
|
|
#include "error.h"
|
2007-03-10 06:32:47 +08:00
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
typedef enum {
|
|
|
|
HEADSET = 1 << 0,
|
|
|
|
GATEWAY = 1 << 1,
|
|
|
|
SINK = 1 << 2,
|
|
|
|
SOURCE = 1 << 3,
|
|
|
|
CONTROL = 1 << 4,
|
|
|
|
TARGET = 1 << 5,
|
|
|
|
INVALID = 1 << 6
|
|
|
|
} audio_service_type;
|
|
|
|
|
2007-05-19 09:18:39 +08:00
|
|
|
typedef enum {
|
|
|
|
GENERIC_AUDIO = 0,
|
|
|
|
ADVANCED_AUDIO,
|
|
|
|
AV_REMOTE,
|
|
|
|
GET_RECORDS
|
|
|
|
} audio_sdp_state_t;
|
|
|
|
|
|
|
|
struct audio_sdp_data {
|
2007-06-23 04:58:12 +08:00
|
|
|
struct device *device;
|
2007-05-19 09:18:39 +08:00
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
DBusMessage *msg; /* Method call or NULL */
|
2007-05-19 09:18:39 +08:00
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
GSList *handles; /* uint32_t * */
|
|
|
|
GSList *records; /* sdp_record_t * */
|
2007-05-19 09:18:39 +08:00
|
|
|
|
|
|
|
audio_sdp_state_t state;
|
|
|
|
};
|
|
|
|
|
2007-04-12 06:46:22 +08:00
|
|
|
static DBusConnection *connection = NULL;
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
static struct device *default_dev = NULL;
|
2007-04-10 19:44:10 +08:00
|
|
|
|
2007-05-15 20:45:35 +08:00
|
|
|
static GSList *devices = NULL;
|
2007-04-09 07:19:19 +08:00
|
|
|
|
2007-05-19 09:18:39 +08:00
|
|
|
static void get_next_record(struct audio_sdp_data *data);
|
|
|
|
static DBusHandlerResult get_handles(const char *uuid,
|
|
|
|
struct audio_sdp_data *data);
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
static struct device *find_device(bdaddr_t *bda)
|
2007-04-10 19:44:10 +08:00
|
|
|
{
|
2007-05-15 20:45:35 +08:00
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
for (l = devices; l != NULL; l = l->next) {
|
2007-06-23 04:58:12 +08:00
|
|
|
struct device *device = l->data;
|
2007-06-23 07:50:24 +08:00
|
|
|
if (bacmp(&device->dst, bda) == 0)
|
2007-05-15 20:45:35 +08:00
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
static struct device *create_device(bdaddr_t *bda)
|
2007-05-15 20:45:35 +08:00
|
|
|
{
|
|
|
|
static int device_id = 0;
|
2007-06-23 04:58:12 +08:00
|
|
|
char path[128];
|
2007-05-15 20:45:35 +08:00
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
snprintf(path, sizeof(path) - 1,
|
2007-05-15 20:45:35 +08:00
|
|
|
"%s/device%d", AUDIO_MANAGER_PATH, device_id++);
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
return device_register(connection, path, bda);
|
2007-05-19 09:18:39 +08:00
|
|
|
}
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
static void remove_device(struct device *device)
|
2007-05-19 09:18:39 +08:00
|
|
|
{
|
2007-06-24 03:29:13 +08:00
|
|
|
if (device == default_dev) {
|
|
|
|
debug("Removing default device");
|
|
|
|
default_dev = NULL;
|
|
|
|
}
|
|
|
|
|
2007-05-19 09:18:39 +08:00
|
|
|
devices = g_slist_remove(devices, device);
|
2007-06-24 03:29:13 +08:00
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
dbus_connection_destroy_object_path(connection, device->path);
|
2007-05-19 09:18:39 +08:00
|
|
|
}
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
static gboolean add_device(struct device *device)
|
2007-05-19 09:18:39 +08:00
|
|
|
{
|
2007-06-24 03:29:13 +08:00
|
|
|
if (default_dev == NULL && g_slist_length(devices) == 0) {
|
|
|
|
debug("Selecting default device");
|
2007-06-19 05:08:35 +08:00
|
|
|
default_dev = device;
|
2007-06-24 03:29:13 +08:00
|
|
|
}
|
2007-06-19 05:08:35 +08:00
|
|
|
|
2007-05-15 20:45:35 +08:00
|
|
|
devices = g_slist_append(devices, device);
|
|
|
|
|
2007-05-19 09:18:39 +08:00
|
|
|
return TRUE;
|
2007-05-15 20:45:35 +08:00
|
|
|
}
|
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
static uint16_t get_service_uuid(const sdp_record_t *record)
|
|
|
|
{
|
|
|
|
sdp_list_t *classes;
|
|
|
|
uuid_t uuid;
|
|
|
|
uint16_t uuid16 = 0;
|
|
|
|
|
|
|
|
if (sdp_get_service_classes(record, &classes) < 0) {
|
|
|
|
error("Unable to get service classes from record");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(&uuid, classes->data, sizeof(uuid));
|
2007-06-23 04:58:12 +08:00
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
if (!sdp_uuid128_to_uuid(&uuid)) {
|
|
|
|
error("Not a 16 bit UUID");
|
|
|
|
sdp_list_free(classes, free);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uuid.type == SDP_UUID32) {
|
2007-06-23 04:58:12 +08:00
|
|
|
if (uuid.value.uuid32 > 0xFFFF) {
|
2007-05-31 17:23:17 +08:00
|
|
|
error("Not a 16 bit UUID");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
uuid16 = (uint16_t) uuid.value.uuid32;
|
|
|
|
} else
|
|
|
|
uuid16 = uuid.value.uuid16;
|
|
|
|
|
|
|
|
done:
|
|
|
|
sdp_list_free(classes, free);
|
|
|
|
|
|
|
|
return uuid16;
|
|
|
|
}
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
static void handle_record(sdp_record_t *record, struct device *device)
|
2007-05-19 09:18:39 +08:00
|
|
|
{
|
2007-06-24 02:21:23 +08:00
|
|
|
gboolean is_default;
|
2007-05-19 09:18:39 +08:00
|
|
|
uint16_t uuid16;
|
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
uuid16 = get_service_uuid(record);
|
2007-05-19 09:18:39 +08:00
|
|
|
|
|
|
|
switch (uuid16) {
|
|
|
|
case HEADSET_SVCLASS_ID:
|
|
|
|
debug("Found Headset record");
|
|
|
|
if (device->headset)
|
2007-06-23 04:58:12 +08:00
|
|
|
headset_update(device, record, uuid16);
|
2007-05-19 09:18:39 +08:00
|
|
|
else
|
2007-06-23 04:58:12 +08:00
|
|
|
device->headset = headset_init(device,
|
2007-06-28 01:03:07 +08:00
|
|
|
record, uuid16, -1);
|
2007-05-19 09:18:39 +08:00
|
|
|
break;
|
|
|
|
case HEADSET_AGW_SVCLASS_ID:
|
|
|
|
debug("Found Headset AG record");
|
|
|
|
break;
|
|
|
|
case HANDSFREE_SVCLASS_ID:
|
|
|
|
debug("Found Hansfree record");
|
2007-06-19 05:08:35 +08:00
|
|
|
if (device->headset)
|
2007-06-23 04:58:12 +08:00
|
|
|
headset_update(device, record, uuid16);
|
2007-06-19 05:08:35 +08:00
|
|
|
else
|
2007-06-23 04:58:12 +08:00
|
|
|
device->headset = headset_init(device,
|
2007-06-28 01:03:07 +08:00
|
|
|
record, uuid16, -1);
|
2007-05-19 09:18:39 +08:00
|
|
|
break;
|
|
|
|
case HANDSFREE_AGW_SVCLASS_ID:
|
|
|
|
debug("Found Handsfree AG record");
|
|
|
|
break;
|
|
|
|
case AUDIO_SINK_SVCLASS_ID:
|
|
|
|
debug("Found Audio Sink");
|
|
|
|
break;
|
|
|
|
case AUDIO_SOURCE_SVCLASS_ID:
|
|
|
|
debug("Found Audio Source");
|
|
|
|
break;
|
|
|
|
case AV_REMOTE_SVCLASS_ID:
|
|
|
|
debug("Found AV Remote");
|
|
|
|
break;
|
|
|
|
case AV_REMOTE_TARGET_SVCLASS_ID:
|
|
|
|
debug("Found AV Target");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
debug("Unrecognized UUID: 0x%04X", uuid16);
|
|
|
|
break;
|
|
|
|
}
|
2007-06-24 02:21:23 +08:00
|
|
|
|
|
|
|
is_default = (default_dev == device) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
device_store(device, is_default);
|
2007-05-31 17:23:17 +08:00
|
|
|
}
|
2007-05-19 09:18:39 +08:00
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
static gint record_iface_cmp(gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
const sdp_record_t *record = a;
|
|
|
|
const char *interface = b;
|
|
|
|
|
|
|
|
switch (get_service_uuid(record)) {
|
|
|
|
case HEADSET_SVCLASS_ID:
|
|
|
|
case HANDSFREE_SVCLASS_ID:
|
|
|
|
return strcmp(interface, AUDIO_HEADSET_INTERFACE);
|
|
|
|
|
|
|
|
case HEADSET_AGW_SVCLASS_ID:
|
|
|
|
case HANDSFREE_AGW_SVCLASS_ID:
|
|
|
|
return strcmp(interface, AUDIO_GATEWAY_INTERFACE);
|
|
|
|
|
|
|
|
case AUDIO_SINK_SVCLASS_ID:
|
|
|
|
return strcmp(interface, AUDIO_SINK_INTERFACE);
|
|
|
|
|
|
|
|
case AUDIO_SOURCE_SVCLASS_ID:
|
|
|
|
return strcmp(interface, AUDIO_SOURCE_INTERFACE);
|
|
|
|
|
|
|
|
case AV_REMOTE_SVCLASS_ID:
|
|
|
|
return strcmp(interface, AUDIO_CONTROL_INTERFACE);
|
|
|
|
|
|
|
|
case AV_REMOTE_TARGET_SVCLASS_ID:
|
|
|
|
return strcmp(interface, AUDIO_TARGET_INTERFACE);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
2007-05-19 09:18:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void finish_sdp(struct audio_sdp_data *data, gboolean success)
|
|
|
|
{
|
2007-06-23 04:58:12 +08:00
|
|
|
const char *addr;
|
|
|
|
char **required = NULL;
|
2007-05-31 17:23:17 +08:00
|
|
|
int required_len, i;
|
|
|
|
DBusMessage *reply = NULL;
|
2007-06-19 05:08:35 +08:00
|
|
|
DBusError derr;
|
2007-05-19 09:18:39 +08:00
|
|
|
|
|
|
|
debug("Audio service discovery completed with %s",
|
|
|
|
success ? "success" : "failure");
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
device_finish_sdp_transaction(data->device);
|
2007-05-19 09:18:39 +08:00
|
|
|
|
|
|
|
if (!success)
|
|
|
|
goto done;
|
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
if (!data->msg)
|
|
|
|
goto update;
|
|
|
|
|
2007-06-19 05:08:35 +08:00
|
|
|
dbus_error_init(&derr);
|
|
|
|
if (dbus_message_is_method_call(data->msg, AUDIO_MANAGER_INTERFACE,
|
|
|
|
"CreateHeadset")) {
|
|
|
|
dbus_message_get_args(data->msg, &derr,
|
|
|
|
DBUS_TYPE_STRING, &addr,
|
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
required = dbus_new0(char *, 2);
|
|
|
|
if (required == NULL) {
|
|
|
|
success = FALSE;
|
|
|
|
err_failed(connection, data->msg, "Out of memory");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
required[0] = dbus_new0(char,
|
|
|
|
strlen(AUDIO_HEADSET_INTERFACE) + 1);
|
|
|
|
if (required[0] == NULL) {
|
|
|
|
success = FALSE;
|
|
|
|
err_failed(connection, data->msg, "Out of memory");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(required[0], AUDIO_HEADSET_INTERFACE,
|
|
|
|
strlen(AUDIO_HEADSET_INTERFACE) + 1);
|
|
|
|
required[1] = NULL;
|
|
|
|
required_len = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dbus_message_get_args(data->msg, &derr,
|
2007-05-31 17:23:17 +08:00
|
|
|
DBUS_TYPE_STRING, &addr,
|
|
|
|
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
|
|
|
|
&required, &required_len,
|
2007-06-19 05:08:35 +08:00
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
|
|
|
|
if (dbus_error_is_set(&derr)) {
|
2007-05-31 17:23:17 +08:00
|
|
|
error("Unable to get message args");
|
|
|
|
success = FALSE;
|
2007-06-19 05:08:35 +08:00
|
|
|
dbus_error_free(&derr);
|
2007-05-31 17:23:17 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-05-31 19:47:29 +08:00
|
|
|
/* Return error if no audio related service records were found */
|
|
|
|
if (!data->records) {
|
|
|
|
debug("No audio audio related service records were found");
|
|
|
|
success = FALSE;
|
|
|
|
err_not_supported(connection, data->msg);
|
2007-05-31 19:48:02 +08:00
|
|
|
goto done;
|
2007-05-31 19:47:29 +08:00
|
|
|
}
|
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
for (i = 0; i < required_len; i++) {
|
|
|
|
const char *iface = required[i];
|
|
|
|
|
|
|
|
if (g_slist_find_custom(data->records, iface, record_iface_cmp))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
debug("Required interface %s not supported", iface);
|
|
|
|
success = FALSE;
|
|
|
|
err_not_supported(connection, data->msg);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-05-19 09:18:39 +08:00
|
|
|
reply = dbus_message_new_method_return(data->msg);
|
|
|
|
if (!reply) {
|
|
|
|
success = FALSE;
|
2007-05-28 18:32:05 +08:00
|
|
|
err_failed(connection, data->msg, "Out of memory");
|
2007-05-19 09:18:39 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
add_device(data->device);
|
2007-05-31 17:23:17 +08:00
|
|
|
|
|
|
|
update:
|
2007-05-19 09:18:39 +08:00
|
|
|
g_slist_foreach(data->records, (GFunc) handle_record, data->device);
|
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
if (reply) {
|
|
|
|
dbus_connection_emit_signal(connection, AUDIO_MANAGER_PATH,
|
|
|
|
AUDIO_MANAGER_INTERFACE,
|
|
|
|
"DeviceCreated",
|
2007-06-23 04:58:12 +08:00
|
|
|
DBUS_TYPE_STRING,
|
|
|
|
&data->device->path,
|
2007-05-31 17:23:17 +08:00
|
|
|
DBUS_TYPE_INVALID);
|
2007-06-19 05:08:35 +08:00
|
|
|
if (data->device->headset)
|
2007-06-23 04:58:12 +08:00
|
|
|
dbus_connection_emit_signal(connection,
|
|
|
|
AUDIO_MANAGER_PATH,
|
2007-06-19 05:08:35 +08:00
|
|
|
AUDIO_MANAGER_INTERFACE,
|
|
|
|
"HeadsetCreated",
|
2007-06-23 04:58:12 +08:00
|
|
|
DBUS_TYPE_STRING,
|
|
|
|
&data->device->path,
|
2007-06-19 05:08:35 +08:00
|
|
|
DBUS_TYPE_INVALID);
|
2007-06-23 04:58:12 +08:00
|
|
|
dbus_message_append_args(reply, DBUS_TYPE_STRING,
|
|
|
|
&data->device->path,
|
|
|
|
DBUS_TYPE_INVALID);
|
2007-05-31 17:23:17 +08:00
|
|
|
send_message_and_unref(connection, reply);
|
|
|
|
}
|
2007-05-19 09:18:39 +08:00
|
|
|
|
|
|
|
done:
|
2007-06-23 04:58:12 +08:00
|
|
|
dbus_free_string_array(required);
|
2007-05-19 09:18:39 +08:00
|
|
|
if (!success)
|
2007-06-23 04:58:12 +08:00
|
|
|
remove_device(data->device);
|
2007-05-31 17:23:17 +08:00
|
|
|
if (data->msg)
|
|
|
|
dbus_message_unref(data->msg);
|
2007-05-19 19:02:55 +08:00
|
|
|
g_slist_foreach(data->handles, (GFunc) g_free, NULL);
|
2007-05-19 09:18:39 +08:00
|
|
|
g_slist_free(data->handles);
|
|
|
|
g_slist_foreach(data->records, (GFunc) sdp_record_free, NULL);
|
|
|
|
g_slist_free(data->records);
|
|
|
|
g_free(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void get_record_reply(DBusPendingCall *call,
|
|
|
|
struct audio_sdp_data *data)
|
|
|
|
{
|
|
|
|
DBusMessage *reply;
|
|
|
|
DBusError derr;
|
|
|
|
uint8_t *array;
|
|
|
|
int array_len, record_len;
|
|
|
|
sdp_record_t *record;
|
|
|
|
|
|
|
|
reply = dbus_pending_call_steal_reply(call);
|
|
|
|
|
|
|
|
dbus_error_init(&derr);
|
|
|
|
if (dbus_set_error_from_message(&derr, reply)) {
|
|
|
|
error("GetRemoteServiceRecord failed: %s", derr.message);
|
|
|
|
if (dbus_error_has_name(&derr,
|
|
|
|
"org.bluez.Error.ConnectionAttemptFailed"))
|
2007-06-23 04:58:12 +08:00
|
|
|
err_connect_failed(connection, data->msg,
|
|
|
|
strerror(EHOSTDOWN));
|
2007-05-19 09:18:39 +08:00
|
|
|
else
|
2007-05-28 18:32:05 +08:00
|
|
|
err_failed(connection, data->msg, derr.message);
|
2007-05-19 09:18:39 +08:00
|
|
|
dbus_error_free(&derr);
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dbus_message_get_args(reply, NULL,
|
|
|
|
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &array, &array_len,
|
|
|
|
DBUS_TYPE_INVALID)) {
|
2007-05-28 18:32:05 +08:00
|
|
|
err_failed(connection, data->msg,
|
2007-05-19 09:18:39 +08:00
|
|
|
"Unable to get args from GetRecordReply");
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
record = sdp_extract_pdu(array, &record_len);
|
|
|
|
if (!record) {
|
|
|
|
error("Unable to extract service record from reply");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (record_len != array_len)
|
|
|
|
debug("warning: array len (%d) != record len (%d)",
|
|
|
|
array_len, record_len);
|
|
|
|
|
|
|
|
data->records = g_slist_append(data->records, record);
|
|
|
|
|
|
|
|
done:
|
|
|
|
dbus_message_unref(reply);
|
|
|
|
|
|
|
|
if (data->handles)
|
|
|
|
get_next_record(data);
|
|
|
|
else
|
|
|
|
finish_sdp(data, TRUE);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
failed:
|
|
|
|
if (reply)
|
|
|
|
dbus_message_unref(reply);
|
|
|
|
finish_sdp(data, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void get_next_record(struct audio_sdp_data *data)
|
|
|
|
{
|
|
|
|
DBusMessage *msg;
|
|
|
|
DBusPendingCall *pending;
|
|
|
|
char address[18], *ptr = address;
|
2007-05-19 19:02:55 +08:00
|
|
|
dbus_uint32_t *handle;
|
2007-05-19 09:18:39 +08:00
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
msg = dbus_message_new_method_call("org.bluez",
|
|
|
|
data->device->adapter_path,
|
2007-05-19 09:18:39 +08:00
|
|
|
"org.bluez.Adapter",
|
|
|
|
"GetRemoteServiceRecord");
|
|
|
|
if (!msg) {
|
|
|
|
error("Unable to allocate new method call");
|
2007-06-23 04:58:12 +08:00
|
|
|
err_connect_failed(connection, data->msg, strerror(ENOMEM));
|
2007-05-19 09:18:39 +08:00
|
|
|
finish_sdp(data, FALSE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-19 19:02:55 +08:00
|
|
|
handle = data->handles->data;
|
2007-05-19 09:18:39 +08:00
|
|
|
|
|
|
|
data->handles = g_slist_remove(data->handles, data->handles->data);
|
|
|
|
|
2007-06-23 07:50:24 +08:00
|
|
|
ba2str(&data->device->dst, address);
|
2007-05-19 09:18:39 +08:00
|
|
|
|
|
|
|
dbus_message_append_args(msg, DBUS_TYPE_STRING, &ptr,
|
2007-05-19 19:02:55 +08:00
|
|
|
DBUS_TYPE_UINT32, handle,
|
2007-05-19 09:18:39 +08:00
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
|
2007-05-19 19:02:55 +08:00
|
|
|
g_free(handle);
|
|
|
|
|
2007-05-28 18:32:05 +08:00
|
|
|
if (!dbus_connection_send_with_reply(connection, msg, &pending, -1)) {
|
2007-05-19 09:18:39 +08:00
|
|
|
error("Sending GetRemoteServiceRecord failed");
|
2007-06-23 04:58:12 +08:00
|
|
|
err_connect_failed(connection, data->msg, strerror(EIO));
|
2007-05-19 09:18:39 +08:00
|
|
|
finish_sdp(data, FALSE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dbus_pending_call_set_notify(pending,
|
|
|
|
(DBusPendingCallNotifyFunction) get_record_reply,
|
|
|
|
data, NULL);
|
|
|
|
dbus_pending_call_unref(pending);
|
|
|
|
dbus_message_unref(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GSList *find_handle(GSList *handles, dbus_uint32_t handle)
|
|
|
|
{
|
|
|
|
while (handles) {
|
2007-05-19 19:02:55 +08:00
|
|
|
if (*(dbus_uint32_t *) handles->data == handle)
|
2007-05-19 09:18:39 +08:00
|
|
|
return handles;
|
|
|
|
handles = handles->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void get_handles_reply(DBusPendingCall *call,
|
|
|
|
struct audio_sdp_data *data)
|
|
|
|
{
|
|
|
|
DBusMessage *reply;
|
|
|
|
DBusError derr;
|
|
|
|
dbus_uint32_t *array = NULL;
|
|
|
|
int array_len, i;
|
|
|
|
|
|
|
|
reply = dbus_pending_call_steal_reply(call);
|
|
|
|
|
|
|
|
dbus_error_init(&derr);
|
|
|
|
if (dbus_set_error_from_message(&derr, reply)) {
|
|
|
|
error("GetRemoteServiceHandles failed: %s", derr.message);
|
|
|
|
if (dbus_error_has_name(&derr,
|
|
|
|
"org.bluez.Error.ConnectionAttemptFailed"))
|
2007-06-23 04:58:12 +08:00
|
|
|
err_connect_failed(connection, data->msg, strerror(EHOSTDOWN));
|
2007-05-19 09:18:39 +08:00
|
|
|
else
|
2007-05-28 18:32:05 +08:00
|
|
|
err_failed(connection, data->msg, derr.message);
|
2007-05-19 09:18:39 +08:00
|
|
|
dbus_error_free(&derr);
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dbus_message_get_args(reply, NULL,
|
2007-06-09 14:26:01 +08:00
|
|
|
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32,
|
|
|
|
&array, &array_len,
|
2007-05-19 09:18:39 +08:00
|
|
|
DBUS_TYPE_INVALID)) {
|
2007-05-28 18:32:05 +08:00
|
|
|
err_failed(connection, data->msg,
|
2007-05-19 09:18:39 +08:00
|
|
|
"Unable to get args from reply");
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < array_len; i++) {
|
2007-05-19 19:02:55 +08:00
|
|
|
if (!find_handle(data->handles, array[i])) {
|
|
|
|
dbus_uint32_t *handle = g_new(dbus_uint32_t, 1);
|
|
|
|
*handle = array[i];
|
|
|
|
data->handles = g_slist_append(data->handles, handle);
|
|
|
|
}
|
2007-05-19 09:18:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
data->state++;
|
|
|
|
|
|
|
|
switch (data->state) {
|
|
|
|
case ADVANCED_AUDIO:
|
|
|
|
get_handles(ADVANCED_AUDIO_UUID, data);
|
|
|
|
break;
|
|
|
|
case AV_REMOTE:
|
|
|
|
get_handles(AVRCP_REMOTE_UUID, data);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (data->handles)
|
|
|
|
get_next_record(data);
|
|
|
|
else
|
|
|
|
finish_sdp(data, TRUE);
|
2007-06-19 05:08:35 +08:00
|
|
|
}
|
2007-05-19 09:18:39 +08:00
|
|
|
|
|
|
|
dbus_message_unref(reply);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
failed:
|
|
|
|
dbus_message_unref(reply);
|
|
|
|
finish_sdp(data, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DBusHandlerResult get_handles(const char *uuid,
|
|
|
|
struct audio_sdp_data *data)
|
|
|
|
{
|
|
|
|
DBusPendingCall *pending;
|
|
|
|
char address[18];
|
|
|
|
const char *ptr = address;
|
|
|
|
DBusMessage *msg;
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
msg = dbus_message_new_method_call("org.bluez",
|
|
|
|
data->device->adapter_path,
|
2007-05-19 09:18:39 +08:00
|
|
|
"org.bluez.Adapter",
|
|
|
|
"GetRemoteServiceHandles");
|
|
|
|
if (!msg) {
|
2007-05-28 18:32:05 +08:00
|
|
|
err_failed(connection, data->msg,
|
2007-05-19 09:18:39 +08:00
|
|
|
"Could not create a new dbus message");
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
2007-06-23 07:50:24 +08:00
|
|
|
ba2str(&data->device->dst, address);
|
2007-05-19 09:18:39 +08:00
|
|
|
|
|
|
|
dbus_message_append_args(msg, DBUS_TYPE_STRING, &ptr,
|
|
|
|
DBUS_TYPE_STRING, &uuid,
|
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
|
|
|
|
if (!dbus_connection_send_with_reply(connection, msg, &pending, -1)) {
|
2007-05-28 18:32:05 +08:00
|
|
|
err_failed(connection, data->msg,
|
2007-05-19 09:18:39 +08:00
|
|
|
"Sending GetRemoteServiceHandles failed");
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
dbus_pending_call_set_notify(pending,
|
|
|
|
(DBusPendingCallNotifyFunction) get_handles_reply,
|
|
|
|
data, NULL);
|
|
|
|
dbus_pending_call_unref(pending);
|
|
|
|
dbus_message_unref(msg);
|
|
|
|
|
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
|
|
|
|
failed:
|
|
|
|
if (msg)
|
|
|
|
dbus_message_unref(msg);
|
|
|
|
finish_sdp(data, FALSE);
|
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
}
|
|
|
|
|
2007-05-28 18:32:05 +08:00
|
|
|
static DBusHandlerResult resolve_services(DBusMessage *msg,
|
2007-06-23 04:58:12 +08:00
|
|
|
struct device *device)
|
2007-05-19 09:18:39 +08:00
|
|
|
{
|
|
|
|
struct audio_sdp_data *sdp_data;
|
|
|
|
|
|
|
|
sdp_data = g_new0(struct audio_sdp_data, 1);
|
2007-05-28 18:32:05 +08:00
|
|
|
if (msg)
|
|
|
|
sdp_data->msg = dbus_message_ref(msg);
|
2007-05-19 09:18:39 +08:00
|
|
|
sdp_data->device = device;
|
|
|
|
|
|
|
|
return get_handles(GENERIC_AUDIO_UUID, sdp_data);
|
2007-05-15 20:45:35 +08:00
|
|
|
}
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
struct device *manager_device_connected(bdaddr_t *bda)
|
2007-05-15 20:45:35 +08:00
|
|
|
{
|
2007-06-23 04:58:12 +08:00
|
|
|
struct device *device;
|
2007-05-15 20:45:35 +08:00
|
|
|
const char *path;
|
2007-05-20 03:21:28 +08:00
|
|
|
gboolean created = FALSE;
|
2007-05-15 20:45:35 +08:00
|
|
|
|
|
|
|
device = find_device(bda);
|
|
|
|
if (device && device->headset)
|
|
|
|
return device;
|
|
|
|
|
2007-05-19 09:18:39 +08:00
|
|
|
if (!device) {
|
|
|
|
device = create_device(bda);
|
|
|
|
if (!add_device(device)) {
|
2007-06-23 04:58:12 +08:00
|
|
|
remove_device(device);
|
2007-05-19 09:18:39 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-05-20 03:21:28 +08:00
|
|
|
created = TRUE;
|
2007-05-19 09:18:39 +08:00
|
|
|
}
|
2007-05-15 20:45:35 +08:00
|
|
|
|
|
|
|
if (!device->headset)
|
2007-06-28 01:03:07 +08:00
|
|
|
device->headset = headset_init(device, NULL, 0, -1);
|
2007-05-15 20:45:35 +08:00
|
|
|
|
|
|
|
if (!device->headset)
|
|
|
|
return NULL;
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
path = device->path;
|
2007-04-11 16:56:50 +08:00
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
if (created) {
|
2007-05-20 03:21:28 +08:00
|
|
|
dbus_connection_emit_signal(connection, AUDIO_MANAGER_PATH,
|
|
|
|
AUDIO_MANAGER_INTERFACE,
|
|
|
|
"DeviceCreated",
|
|
|
|
DBUS_TYPE_STRING, &path,
|
|
|
|
DBUS_TYPE_INVALID);
|
2007-05-31 17:23:17 +08:00
|
|
|
resolve_services(NULL, device);
|
|
|
|
}
|
2007-05-20 03:21:28 +08:00
|
|
|
|
2007-05-10 06:12:20 +08:00
|
|
|
dbus_connection_emit_signal(connection, AUDIO_MANAGER_PATH,
|
|
|
|
AUDIO_MANAGER_INTERFACE,
|
|
|
|
"HeadsetCreated",
|
2007-05-15 20:45:35 +08:00
|
|
|
DBUS_TYPE_STRING, &path,
|
2007-05-10 06:12:20 +08:00
|
|
|
DBUS_TYPE_INVALID);
|
2007-04-11 19:19:58 +08:00
|
|
|
|
2007-06-19 05:08:35 +08:00
|
|
|
if (!default_dev) {
|
|
|
|
default_dev = device;
|
2007-05-10 06:12:20 +08:00
|
|
|
dbus_connection_emit_signal(connection, AUDIO_MANAGER_PATH,
|
|
|
|
AUDIO_MANAGER_INTERFACE,
|
|
|
|
"DefaultHeadsetChanged",
|
2007-05-15 20:45:35 +08:00
|
|
|
DBUS_TYPE_STRING, &path,
|
2007-05-10 06:12:20 +08:00
|
|
|
DBUS_TYPE_INVALID);
|
2007-04-11 19:19:58 +08:00
|
|
|
}
|
2007-04-10 19:44:10 +08:00
|
|
|
|
2007-05-15 20:45:35 +08:00
|
|
|
return device;
|
2007-04-13 19:51:00 +08:00
|
|
|
}
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
static gboolean device_supports_interface(struct device *device,
|
2007-05-31 17:23:17 +08:00
|
|
|
const char *iface)
|
|
|
|
{
|
2007-06-23 07:50:24 +08:00
|
|
|
if (strcmp(iface, AUDIO_HEADSET_INTERFACE) == 0)
|
|
|
|
return device->headset ? TRUE : FALSE;
|
2007-05-31 17:23:17 +08:00
|
|
|
|
2007-06-23 07:50:24 +08:00
|
|
|
if (strcmp(iface, AUDIO_GATEWAY_INTERFACE) == 0)
|
|
|
|
return device->gateway ? TRUE : FALSE;
|
2007-05-31 17:23:17 +08:00
|
|
|
|
2007-06-23 07:50:24 +08:00
|
|
|
if (strcmp(iface, AUDIO_SOURCE_INTERFACE) == 0)
|
|
|
|
return device->source ? TRUE : FALSE;
|
2007-05-31 17:23:17 +08:00
|
|
|
|
2007-06-23 07:50:24 +08:00
|
|
|
if (strcmp(iface, AUDIO_SINK_INTERFACE) == 0)
|
2007-05-31 17:23:17 +08:00
|
|
|
return device->sink ? TRUE : FALSE;
|
|
|
|
|
2007-06-23 07:50:24 +08:00
|
|
|
if (strcmp(iface, AUDIO_CONTROL_INTERFACE) == 0)
|
|
|
|
return device->control ? TRUE : FALSE;
|
2007-05-31 17:23:17 +08:00
|
|
|
|
2007-06-23 07:50:24 +08:00
|
|
|
if (strcmp(iface, AUDIO_TARGET_INTERFACE) == 0)
|
|
|
|
return device->target ? TRUE : FALSE;
|
2007-05-31 17:23:17 +08:00
|
|
|
|
2007-06-23 07:50:24 +08:00
|
|
|
debug("Unknown interface %s", iface);
|
2007-05-31 17:23:17 +08:00
|
|
|
|
2007-06-23 07:50:24 +08:00
|
|
|
return FALSE;
|
2007-05-31 17:23:17 +08:00
|
|
|
}
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
static gboolean device_matches(struct device *device, char **interfaces)
|
2007-05-31 17:23:17 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; interfaces[i]; i++) {
|
|
|
|
if (device_supports_interface(device, interfaces[i]))
|
|
|
|
continue;
|
|
|
|
debug("Device does not support interface %s", interfaces[i]);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-06-09 14:26:01 +08:00
|
|
|
static DBusHandlerResult am_create_device(DBusConnection *conn,
|
|
|
|
DBusMessage *msg,
|
2007-05-09 23:51:02 +08:00
|
|
|
void *data)
|
2007-04-10 19:44:10 +08:00
|
|
|
{
|
2007-05-31 17:23:17 +08:00
|
|
|
const char *address, *path;
|
|
|
|
char **required;
|
|
|
|
int required_len;
|
2007-04-10 19:44:10 +08:00
|
|
|
bdaddr_t bda;
|
2007-06-23 04:58:12 +08:00
|
|
|
struct device *device;
|
2007-05-31 17:23:17 +08:00
|
|
|
DBusMessage *reply;
|
2007-04-10 19:44:10 +08:00
|
|
|
DBusError derr;
|
|
|
|
|
|
|
|
dbus_error_init(&derr);
|
2007-06-19 05:08:35 +08:00
|
|
|
if (dbus_message_is_method_call(msg, AUDIO_MANAGER_INTERFACE,
|
|
|
|
"CreateHeadset")) {
|
|
|
|
dbus_message_get_args(msg, &derr,
|
|
|
|
DBUS_TYPE_STRING, &address,
|
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
required = dbus_new0(char *, 2);
|
|
|
|
if (required == NULL)
|
|
|
|
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
|
|
|
|
|
|
|
required[0] = dbus_new0(char,
|
|
|
|
strlen(AUDIO_HEADSET_INTERFACE) + 1);
|
|
|
|
if (required[0] == NULL) {
|
|
|
|
dbus_free(required);
|
|
|
|
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(required[0], AUDIO_HEADSET_INTERFACE,
|
|
|
|
strlen(AUDIO_HEADSET_INTERFACE) + 1);
|
|
|
|
required[1] = NULL;
|
|
|
|
required_len = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dbus_message_get_args(msg, &derr,
|
|
|
|
DBUS_TYPE_STRING, &address,
|
|
|
|
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
|
|
|
|
&required, &required_len,
|
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
|
2007-05-15 20:45:35 +08:00
|
|
|
if (dbus_error_is_set(&derr)) {
|
2007-04-12 06:46:22 +08:00
|
|
|
err_invalid_args(connection, msg, derr.message);
|
2007-05-15 20:45:35 +08:00
|
|
|
dbus_error_free(&derr);
|
2007-04-10 19:44:10 +08:00
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
}
|
2007-05-15 20:45:35 +08:00
|
|
|
|
|
|
|
str2ba(address, &bda);
|
|
|
|
|
|
|
|
device = find_device(&bda);
|
2007-05-31 17:23:17 +08:00
|
|
|
if (!device) {
|
|
|
|
device = create_device(&bda);
|
|
|
|
dbus_free_string_array(required);
|
|
|
|
return resolve_services(msg, device);
|
2007-05-15 20:45:35 +08:00
|
|
|
}
|
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
if (!device_matches(device, required)) {
|
|
|
|
dbus_free_string_array(required);
|
|
|
|
return err_not_supported(conn, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
dbus_free_string_array(required);
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
path = device->path;
|
2007-05-31 17:23:17 +08:00
|
|
|
|
|
|
|
reply = dbus_message_new_method_return(msg);
|
|
|
|
if (!reply)
|
|
|
|
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
2007-05-15 20:45:35 +08:00
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
dbus_message_append_args(reply, DBUS_TYPE_STRING, &path,
|
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
|
|
|
|
return send_message_and_unref(conn, reply);
|
2007-05-15 20:45:35 +08:00
|
|
|
}
|
|
|
|
|
2007-05-18 17:15:54 +08:00
|
|
|
static DBusHandlerResult am_list_devices(DBusConnection *conn,
|
|
|
|
DBusMessage *msg,
|
|
|
|
void *data)
|
|
|
|
{
|
2007-05-19 03:10:08 +08:00
|
|
|
DBusMessageIter iter, array_iter;
|
|
|
|
DBusMessage *reply;
|
2007-05-31 17:23:17 +08:00
|
|
|
DBusError derr;
|
2007-05-19 03:10:08 +08:00
|
|
|
GSList *l;
|
2007-05-31 17:23:17 +08:00
|
|
|
char **required;
|
|
|
|
int required_len;
|
|
|
|
|
|
|
|
dbus_error_init(&derr);
|
2007-06-19 05:08:35 +08:00
|
|
|
|
|
|
|
if (dbus_message_is_method_call(msg, AUDIO_MANAGER_INTERFACE,
|
|
|
|
"ListHeadsets")) {
|
|
|
|
required = dbus_new0(char *, 2);
|
|
|
|
if (required == NULL)
|
|
|
|
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
|
|
|
|
|
|
|
required[0] = dbus_new0(char,
|
|
|
|
strlen(AUDIO_HEADSET_INTERFACE) + 1);
|
|
|
|
if (required[0] == NULL) {
|
|
|
|
dbus_free(required);
|
|
|
|
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(required[0], AUDIO_HEADSET_INTERFACE,
|
|
|
|
strlen(AUDIO_HEADSET_INTERFACE) + 1);
|
|
|
|
required[1] = NULL;
|
|
|
|
required_len = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dbus_message_get_args(msg, &derr,
|
|
|
|
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
|
|
|
|
&required, &required_len,
|
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
if (dbus_error_is_set(&derr)) {
|
|
|
|
err_invalid_args(connection, msg, derr.message);
|
|
|
|
dbus_error_free(&derr);
|
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
}
|
2007-05-19 03:10:08 +08:00
|
|
|
|
|
|
|
reply = dbus_message_new_method_return(msg);
|
|
|
|
if (!reply)
|
|
|
|
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
|
|
|
|
|
|
|
dbus_message_iter_init_append(reply, &iter);
|
|
|
|
|
|
|
|
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
|
|
|
|
DBUS_TYPE_STRING_AS_STRING, &array_iter);
|
|
|
|
|
|
|
|
for (l = devices; l != NULL; l = l->next) {
|
2007-06-23 04:58:12 +08:00
|
|
|
struct device *device = l->data;
|
2007-05-19 03:10:08 +08:00
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
if (!device_matches(device, required))
|
|
|
|
continue;
|
|
|
|
|
2007-05-19 03:10:08 +08:00
|
|
|
dbus_message_iter_append_basic(&array_iter,
|
2007-06-23 04:58:12 +08:00
|
|
|
DBUS_TYPE_STRING, &device->path);
|
2007-05-19 03:10:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
dbus_message_iter_close_container(&iter, &array_iter);
|
|
|
|
|
2007-05-31 17:23:17 +08:00
|
|
|
dbus_free_string_array(required);
|
|
|
|
|
2007-05-19 03:10:08 +08:00
|
|
|
return send_message_and_unref(connection, reply);
|
2007-05-18 17:15:54 +08:00
|
|
|
}
|
|
|
|
|
2007-05-15 20:45:35 +08:00
|
|
|
static gint device_path_cmp(gconstpointer a, gconstpointer b)
|
|
|
|
{
|
2007-06-23 04:58:12 +08:00
|
|
|
const struct device *device = a;
|
2007-05-15 20:45:35 +08:00
|
|
|
const char *path = b;
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
return strcmp(device->path, path);
|
2007-05-15 20:45:35 +08:00
|
|
|
}
|
|
|
|
|
2007-05-19 03:10:08 +08:00
|
|
|
static DBusHandlerResult am_remove_device(DBusConnection *conn,
|
|
|
|
DBusMessage *msg,
|
2007-05-09 23:51:02 +08:00
|
|
|
void *data)
|
2007-04-10 19:44:10 +08:00
|
|
|
{
|
2007-04-11 16:56:50 +08:00
|
|
|
DBusError derr;
|
|
|
|
DBusMessage *reply;
|
|
|
|
GSList *match;
|
2007-05-15 20:45:35 +08:00
|
|
|
const char *path;
|
2007-06-23 04:58:12 +08:00
|
|
|
struct device *device;
|
2007-04-11 16:56:50 +08:00
|
|
|
|
|
|
|
dbus_error_init(&derr);
|
|
|
|
if (!dbus_message_get_args(msg, &derr,
|
|
|
|
DBUS_TYPE_STRING, &path,
|
|
|
|
DBUS_TYPE_INVALID)) {
|
2007-04-12 06:46:22 +08:00
|
|
|
err_invalid_args(connection, msg, derr.message);
|
2007-04-11 16:56:50 +08:00
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
}
|
|
|
|
if (dbus_error_is_set(&derr)) {
|
2007-04-12 06:46:22 +08:00
|
|
|
err_invalid_args(connection, msg, derr.message);
|
2007-04-11 16:56:50 +08:00
|
|
|
dbus_error_free(&derr);
|
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
}
|
|
|
|
|
2007-05-15 20:45:35 +08:00
|
|
|
match = g_slist_find_custom(devices, path, device_path_cmp);
|
2007-04-11 16:56:50 +08:00
|
|
|
if (!match)
|
2007-06-23 04:58:12 +08:00
|
|
|
return err_does_not_exist(connection, msg);
|
2007-04-11 16:56:50 +08:00
|
|
|
|
|
|
|
reply = dbus_message_new_method_return(msg);
|
|
|
|
if (!reply)
|
|
|
|
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
|
|
|
|
2007-05-15 20:45:35 +08:00
|
|
|
device = match->data;
|
2007-04-11 19:19:58 +08:00
|
|
|
|
2007-05-15 20:45:35 +08:00
|
|
|
remove_device(device);
|
2007-04-11 16:56:50 +08:00
|
|
|
|
2007-06-19 05:08:35 +08:00
|
|
|
if (default_dev == device) {
|
2007-05-10 06:12:20 +08:00
|
|
|
const char *param;
|
2007-05-15 20:45:35 +08:00
|
|
|
GSList *l;
|
|
|
|
|
2007-06-19 05:08:35 +08:00
|
|
|
default_dev = NULL;
|
2007-05-10 06:12:20 +08:00
|
|
|
|
2007-05-15 20:45:35 +08:00
|
|
|
for (l = devices; l != NULL; l = l->next) {
|
|
|
|
device = l->data;
|
2007-04-11 19:19:58 +08:00
|
|
|
|
2007-05-15 20:45:35 +08:00
|
|
|
if (device->headset)
|
2007-06-19 05:08:35 +08:00
|
|
|
default_dev = device;
|
2007-05-15 20:45:35 +08:00
|
|
|
}
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
param = default_dev ? default_dev->path : "";
|
2007-05-10 06:12:20 +08:00
|
|
|
|
|
|
|
dbus_connection_emit_signal(conn, AUDIO_MANAGER_PATH,
|
|
|
|
AUDIO_MANAGER_INTERFACE,
|
|
|
|
"DefaultHeadsetChanged",
|
|
|
|
DBUS_TYPE_STRING, ¶m,
|
|
|
|
DBUS_TYPE_INVALID);
|
2007-04-11 16:56:50 +08:00
|
|
|
}
|
|
|
|
|
2007-05-10 06:12:20 +08:00
|
|
|
dbus_connection_emit_signal(conn, AUDIO_MANAGER_PATH,
|
|
|
|
AUDIO_MANAGER_INTERFACE,
|
|
|
|
"HeadsetRemoved",
|
|
|
|
DBUS_TYPE_STRING, &path,
|
|
|
|
DBUS_TYPE_INVALID);
|
2007-04-11 19:19:58 +08:00
|
|
|
|
2007-05-19 03:13:13 +08:00
|
|
|
dbus_connection_emit_signal(conn, AUDIO_MANAGER_PATH,
|
|
|
|
AUDIO_MANAGER_INTERFACE,
|
|
|
|
"DeviceRemoved",
|
|
|
|
DBUS_TYPE_STRING, &path,
|
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
|
2007-04-12 06:46:22 +08:00
|
|
|
return send_message_and_unref(connection, reply);
|
2007-04-10 19:44:10 +08:00
|
|
|
}
|
|
|
|
|
2007-06-09 14:26:01 +08:00
|
|
|
static DBusHandlerResult am_find_by_addr(DBusConnection *conn,
|
|
|
|
DBusMessage *msg,
|
2007-06-04 18:30:45 +08:00
|
|
|
void *data)
|
|
|
|
{
|
2007-06-23 04:58:12 +08:00
|
|
|
const char *address;
|
2007-06-04 18:30:45 +08:00
|
|
|
DBusMessage *reply;
|
|
|
|
DBusError derr;
|
2007-06-23 04:58:12 +08:00
|
|
|
struct device *device;
|
2007-06-04 18:30:45 +08:00
|
|
|
bdaddr_t bda;
|
|
|
|
|
|
|
|
dbus_error_init(&derr);
|
|
|
|
dbus_message_get_args(msg, &derr,
|
|
|
|
DBUS_TYPE_STRING, &address,
|
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
if (dbus_error_is_set(&derr)) {
|
|
|
|
err_invalid_args(connection, msg, derr.message);
|
|
|
|
dbus_error_free(&derr);
|
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
str2ba(address, &bda);
|
|
|
|
|
|
|
|
device = find_device(&bda);
|
|
|
|
|
|
|
|
if (!device)
|
|
|
|
return err_does_not_exist(conn, msg);
|
|
|
|
|
|
|
|
reply = dbus_message_new_method_return(msg);
|
|
|
|
if (!reply)
|
|
|
|
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
dbus_message_append_args(reply, DBUS_TYPE_STRING, &device->path,
|
2007-06-04 18:30:45 +08:00
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
|
|
|
|
return send_message_and_unref(conn, reply);
|
|
|
|
}
|
|
|
|
|
2007-06-19 05:08:35 +08:00
|
|
|
static DBusHandlerResult am_default_device(DBusConnection *conn,
|
2007-06-09 14:26:01 +08:00
|
|
|
DBusMessage *msg,
|
2007-05-09 23:51:02 +08:00
|
|
|
void *data)
|
2007-04-10 19:44:10 +08:00
|
|
|
{
|
|
|
|
DBusMessage *reply;
|
2007-04-11 16:56:50 +08:00
|
|
|
|
2007-06-19 05:08:35 +08:00
|
|
|
if (!default_dev)
|
2007-06-23 04:58:12 +08:00
|
|
|
return err_does_not_exist(connection, msg);
|
2007-06-19 05:08:35 +08:00
|
|
|
|
|
|
|
if (default_dev->headset == NULL &&
|
|
|
|
dbus_message_is_method_call(msg, AUDIO_MANAGER_INTERFACE,
|
2007-06-24 03:29:13 +08:00
|
|
|
"DefaultHeadset"))
|
2007-06-23 04:58:12 +08:00
|
|
|
return err_does_not_exist(connection, msg);
|
2007-04-10 19:44:10 +08:00
|
|
|
|
|
|
|
reply = dbus_message_new_method_return(msg);
|
|
|
|
if (!reply)
|
|
|
|
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
|
|
|
|
2007-06-23 04:58:12 +08:00
|
|
|
dbus_message_append_args(reply, DBUS_TYPE_STRING, &default_dev->path,
|
2007-04-10 19:44:10 +08:00
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
|
2007-04-12 06:46:22 +08:00
|
|
|
return send_message_and_unref(connection, reply);
|
2007-04-10 19:44:10 +08:00
|
|
|
}
|
|
|
|
|
2007-06-19 05:08:35 +08:00
|
|
|
static DBusHandlerResult am_change_default_device(DBusConnection *conn,
|
2007-06-09 14:26:01 +08:00
|
|
|
DBusMessage *msg,
|
2007-05-09 23:51:02 +08:00
|
|
|
void *data)
|
2007-04-10 19:44:10 +08:00
|
|
|
{
|
2007-04-11 16:56:50 +08:00
|
|
|
DBusError derr;
|
|
|
|
DBusMessage *reply;
|
|
|
|
GSList *match;
|
|
|
|
const char *path;
|
2007-06-23 04:58:12 +08:00
|
|
|
struct device *device;
|
2007-04-11 16:56:50 +08:00
|
|
|
|
|
|
|
dbus_error_init(&derr);
|
|
|
|
if (!dbus_message_get_args(msg, &derr,
|
|
|
|
DBUS_TYPE_STRING, &path,
|
|
|
|
DBUS_TYPE_INVALID)) {
|
2007-04-12 06:46:22 +08:00
|
|
|
err_invalid_args(connection, msg, derr.message);
|
2007-04-11 16:56:50 +08:00
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
}
|
|
|
|
if (dbus_error_is_set(&derr)) {
|
2007-04-12 06:46:22 +08:00
|
|
|
err_invalid_args(connection, msg, derr.message);
|
2007-04-11 16:56:50 +08:00
|
|
|
dbus_error_free(&derr);
|
|
|
|
return DBUS_HANDLER_RESULT_HANDLED;
|
|
|
|
}
|
|
|
|
|
2007-05-15 20:45:35 +08:00
|
|
|
match = g_slist_find_custom(devices, path, device_path_cmp);
|
2007-04-11 16:56:50 +08:00
|
|
|
if (!match)
|
2007-06-23 04:58:12 +08:00
|
|
|
return err_does_not_exist(connection, msg);
|
2007-04-11 16:56:50 +08:00
|
|
|
|
|
|
|
reply = dbus_message_new_method_return(msg);
|
|
|
|
if (!reply)
|
|
|
|
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
|
|
|
|
2007-06-19 05:08:35 +08:00
|
|
|
device = match->data;
|
2007-04-11 16:56:50 +08:00
|
|
|
|
2007-06-19 05:08:35 +08:00
|
|
|
if (!dbus_message_is_method_call(msg, AUDIO_MANAGER_INTERFACE,
|
|
|
|
"ChangeDefaultHeadset"))
|
|
|
|
dbus_connection_emit_signal(conn, AUDIO_MANAGER_PATH,
|
|
|
|
AUDIO_MANAGER_INTERFACE,
|
|
|
|
"DefaultDeviceChanged",
|
2007-06-23 04:58:12 +08:00
|
|
|
DBUS_TYPE_STRING, &device->path,
|
2007-06-19 05:08:35 +08:00
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
else if (device->headset)
|
|
|
|
dbus_connection_emit_signal(conn, AUDIO_MANAGER_PATH,
|
|
|
|
AUDIO_MANAGER_INTERFACE,
|
|
|
|
"DefaultHeadsetChanged",
|
2007-06-23 04:58:12 +08:00
|
|
|
DBUS_TYPE_STRING, &device->path,
|
2007-06-19 05:08:35 +08:00
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
else
|
2007-06-23 04:58:12 +08:00
|
|
|
return err_does_not_exist(connection, msg);
|
2007-04-11 19:19:58 +08:00
|
|
|
|
2007-06-19 05:08:35 +08:00
|
|
|
default_dev = device;
|
2007-06-24 02:21:23 +08:00
|
|
|
device_store(device, TRUE);
|
2007-04-12 06:46:22 +08:00
|
|
|
return send_message_and_unref(connection, reply);
|
2007-04-10 19:44:10 +08:00
|
|
|
}
|
|
|
|
|
2007-05-09 23:51:02 +08:00
|
|
|
static DBusMethodVTable manager_methods[] = {
|
2007-05-15 20:45:35 +08:00
|
|
|
{ "CreateDevice", am_create_device,
|
2007-05-31 17:23:17 +08:00
|
|
|
"sas", "s" },
|
2007-05-18 17:15:54 +08:00
|
|
|
{ "RemoveDevice", am_remove_device,
|
|
|
|
"s", "" },
|
|
|
|
{ "ListDevices", am_list_devices,
|
2007-06-19 05:08:35 +08:00
|
|
|
"as", "as" },
|
|
|
|
{ "DefaultDevice", am_default_device,
|
|
|
|
"", "s" },
|
|
|
|
{ "ChangeDefaultDevice", am_change_default_device,
|
|
|
|
"s", "" },
|
|
|
|
{ "CreateHeadset", am_create_device,
|
2007-05-18 17:15:54 +08:00
|
|
|
"s", "s" },
|
2007-06-19 05:08:35 +08:00
|
|
|
{ "RemoveHeadset", am_remove_device,
|
2007-05-18 17:15:54 +08:00
|
|
|
"s", "" },
|
2007-06-19 05:08:35 +08:00
|
|
|
{ "ListHeadsets", am_list_devices,
|
2007-05-18 17:15:54 +08:00
|
|
|
"", "as" },
|
2007-06-04 18:30:45 +08:00
|
|
|
{ "FindDeviceByAddress", am_find_by_addr,
|
|
|
|
"s", "s" },
|
2007-06-19 05:08:35 +08:00
|
|
|
{ "DefaultHeadset", am_default_device,
|
2007-05-18 17:15:54 +08:00
|
|
|
"", "s" },
|
2007-06-19 05:08:35 +08:00
|
|
|
{ "ChangeDefaultHeadset", am_change_default_device,
|
|
|
|
"s", "" },
|
2007-05-09 23:51:02 +08:00
|
|
|
{ NULL, NULL, NULL, NULL },
|
|
|
|
};
|
2007-04-10 19:44:10 +08:00
|
|
|
|
2007-05-09 23:51:02 +08:00
|
|
|
static DBusSignalVTable manager_signals[] = {
|
2007-05-19 02:26:56 +08:00
|
|
|
{ "DeviceCreated", "s" },
|
2007-05-18 17:15:54 +08:00
|
|
|
{ "DeviceRemoved", "s" },
|
2007-05-09 23:51:02 +08:00
|
|
|
{ "HeadsetCreated", "s" },
|
|
|
|
{ "HeadsetRemoved", "s" },
|
2007-06-19 05:08:35 +08:00
|
|
|
{ "DefaultDeviceChanged", "s" },
|
2007-05-09 23:51:02 +08:00
|
|
|
{ "DefaultHeadsetChanged", "s" },
|
|
|
|
{ NULL, NULL }
|
2007-04-10 19:44:10 +08:00
|
|
|
};
|
|
|
|
|
2007-06-23 07:50:24 +08:00
|
|
|
static void parse_stored_devices(char *key, char *value, void *data)
|
|
|
|
{
|
|
|
|
struct device *device;
|
|
|
|
bdaddr_t dst;
|
|
|
|
|
2007-06-24 02:21:23 +08:00
|
|
|
if (!key || !value || strcmp(key, "default") == 0)
|
2007-06-23 07:50:24 +08:00
|
|
|
return;
|
|
|
|
|
2007-06-24 03:29:13 +08:00
|
|
|
info("Loading device %s (%s)", key, value);
|
|
|
|
str2ba(key, &dst);
|
2007-06-23 07:50:24 +08:00
|
|
|
|
2007-06-24 03:29:13 +08:00
|
|
|
device = create_device(&dst);
|
|
|
|
if (!device)
|
2007-06-23 07:50:24 +08:00
|
|
|
return;
|
|
|
|
|
2007-06-28 01:03:07 +08:00
|
|
|
if (strncmp(value, "headset", strlen("headset")) == 0) {
|
|
|
|
int channel = -1;
|
|
|
|
char *ptr;
|
|
|
|
|
|
|
|
if ((ptr = strchr(value, '#')))
|
|
|
|
channel = strtol(ptr+1, NULL, 10);
|
|
|
|
|
|
|
|
device->headset = headset_init(device, NULL, 0, channel);
|
|
|
|
}
|
2007-06-23 07:50:24 +08:00
|
|
|
|
|
|
|
add_device(device);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void register_devices_stored(const char *adapter)
|
|
|
|
{
|
|
|
|
char filename[PATH_MAX + 1];
|
2007-06-24 03:29:13 +08:00
|
|
|
struct stat st;
|
|
|
|
struct device *device;
|
2007-06-23 07:50:24 +08:00
|
|
|
bdaddr_t src;
|
|
|
|
bdaddr_t dst;
|
2007-06-23 08:17:30 +08:00
|
|
|
char *addr;
|
2007-06-23 07:50:24 +08:00
|
|
|
|
|
|
|
create_name(filename, PATH_MAX, STORAGEDIR, adapter, "audio");
|
|
|
|
|
|
|
|
str2ba(adapter, &src);
|
|
|
|
|
2007-06-24 03:29:13 +08:00
|
|
|
if (stat(filename, &st) < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(st.st_mode & __S_IFREG))
|
|
|
|
return;
|
|
|
|
|
|
|
|
textfile_foreach(filename, parse_stored_devices, &src);
|
2007-06-23 07:50:24 +08:00
|
|
|
|
2007-06-24 03:29:13 +08:00
|
|
|
addr = textfile_get(filename, "default");
|
|
|
|
if (!addr)
|
|
|
|
return;
|
2007-06-24 02:57:42 +08:00
|
|
|
|
2007-06-24 03:29:13 +08:00
|
|
|
str2ba(addr, &dst);
|
|
|
|
device = find_device(&dst);
|
2007-06-23 07:50:24 +08:00
|
|
|
|
2007-06-24 03:29:13 +08:00
|
|
|
if (device) {
|
|
|
|
info("Setting %s as default device", addr);
|
|
|
|
default_dev = device;
|
2007-06-23 07:50:24 +08:00
|
|
|
}
|
2007-06-24 03:29:13 +08:00
|
|
|
|
|
|
|
free(addr);
|
2007-06-23 07:50:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void register_stored(void)
|
|
|
|
{
|
|
|
|
char dirname[PATH_MAX + 1];
|
|
|
|
struct dirent *de;
|
|
|
|
DIR *dir;
|
|
|
|
|
|
|
|
snprintf(dirname, PATH_MAX, "%s", STORAGEDIR);
|
|
|
|
|
|
|
|
dir = opendir(dirname);
|
|
|
|
if (!dir)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while ((de = readdir(dir)) != NULL) {
|
|
|
|
if (!isdigit(de->d_name[0]))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Device objects */
|
|
|
|
register_devices_stored(de->d_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
closedir(dir);
|
|
|
|
}
|
|
|
|
|
2007-06-28 01:03:07 +08:00
|
|
|
static void manager_unregister(DBusConnection *conn, void *data)
|
|
|
|
{
|
|
|
|
info("Unregistered manager path");
|
|
|
|
|
|
|
|
if (devices) {
|
|
|
|
g_slist_foreach(devices, (GFunc)remove_device, NULL);
|
|
|
|
g_slist_free(devices);
|
|
|
|
devices = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-09 07:19:19 +08:00
|
|
|
int audio_init(DBusConnection *conn)
|
2007-03-10 06:32:47 +08:00
|
|
|
{
|
2007-05-09 23:51:02 +08:00
|
|
|
if (!dbus_connection_create_object_path(conn, AUDIO_MANAGER_PATH,
|
2007-06-28 01:03:07 +08:00
|
|
|
NULL, manager_unregister)) {
|
2007-04-12 06:46:22 +08:00
|
|
|
error("D-Bus failed to register %s path", AUDIO_MANAGER_PATH);
|
2007-04-10 19:44:10 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-05-09 23:51:02 +08:00
|
|
|
if (!dbus_connection_register_interface(conn, AUDIO_MANAGER_PATH,
|
|
|
|
AUDIO_MANAGER_INTERFACE,
|
|
|
|
manager_methods,
|
|
|
|
manager_signals, NULL)) {
|
|
|
|
error("Failed to register %s interface to %s",
|
|
|
|
AUDIO_MANAGER_INTERFACE, AUDIO_MANAGER_PATH);
|
|
|
|
dbus_connection_destroy_object_path(conn,
|
|
|
|
AUDIO_MANAGER_PATH);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-04-12 06:46:22 +08:00
|
|
|
connection = dbus_connection_ref(conn);
|
|
|
|
|
2007-06-23 07:50:24 +08:00
|
|
|
info("Registered manager path:%s", AUDIO_MANAGER_PATH);
|
|
|
|
|
|
|
|
register_stored();
|
|
|
|
|
2007-03-10 06:32:47 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void audio_exit(void)
|
|
|
|
{
|
2007-06-28 01:03:07 +08:00
|
|
|
dbus_connection_destroy_object_path(connection, AUDIO_MANAGER_PATH);
|
2007-04-12 06:46:22 +08:00
|
|
|
|
|
|
|
dbus_connection_unref(connection);
|
2007-04-09 07:19:19 +08:00
|
|
|
|
2007-04-12 06:46:22 +08:00
|
|
|
connection = NULL;
|
2007-03-10 06:32:47 +08:00
|
|
|
}
|
2007-06-07 01:58:19 +08:00
|
|
|
|
2007-06-23 08:17:30 +08:00
|
|
|
struct device *manager_default_device()
|
2007-06-07 01:58:19 +08:00
|
|
|
{
|
2007-06-23 04:58:12 +08:00
|
|
|
return default_dev;
|
2007-06-07 01:58:19 +08:00
|
|
|
}
|