diff options
author | Mikel Astiz <mikel.astiz@bmw-carit.de> | 2013-04-26 11:46:25 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-04-26 14:48:32 +0300 |
commit | 10620c1c0fbb211455fde597a1d2e5e47806f25d (patch) | |
tree | 70807220fbbbd9a104887ccad265d87e43730409 /profiles/input | |
parent | 32a4ce9475d5804b854df0ec145c535b11b147a5 (diff) | |
download | bluez-10620c1c0fbb211455fde597a1d2e5e47806f25d.tar.gz |
profile: Use btd_service for connect/disconnect
Change the btd_profile connect/disconnect callbacks to receive a
btd_service pointer. This should make it possible to handle multiple
instances of the same profile in a specific device.
The patch strongly influences how the profiles should interact with the
core. The state transitions, previously reported using the device.h API
(device_profile_connected() and device_profile_disconnected()), have
now been replaced by the btd_service API.
The transitions will then be propagated to device.c by means of the
conventional state-changed callback mechanism.
Diffstat (limited to 'profiles/input')
-rw-r--r-- | profiles/input/device.c | 21 | ||||
-rw-r--r-- | profiles/input/device.h | 5 | ||||
-rw-r--r-- | profiles/input/manager.c | 11 | ||||
-rw-r--r-- | profiles/input/manager.h | 25 |
4 files changed, 10 insertions, 52 deletions
diff --git a/profiles/input/device.c b/profiles/input/device.c index 53f46beb8..498c22687 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -48,7 +48,6 @@ #include "../src/storage.h" #include "../src/dbus-common.h" -#include "manager.h" #include "device.h" #include "error.h" #include <btio/btio.h> @@ -559,7 +558,7 @@ static int input_device_connected(struct input_device *idev) idev->dc_id = device_add_disconnect_watch(idev->device, disconnect_cb, idev, NULL); - input_manager_device_connected(idev->device, 0); + btd_service_connecting_complete(idev->service, 0); return 0; } @@ -586,7 +585,7 @@ static void interrupt_connect_cb(GIOChannel *chan, GError *conn_err, return; failed: - input_manager_device_connected(idev->device, err); + btd_service_connecting_complete(idev->service, err); /* So we guarantee the interrupt channel is closed before the * control channel (if we only do unref GLib will close it only @@ -638,7 +637,7 @@ static void control_connect_cb(GIOChannel *chan, GError *conn_err, return; failed: - input_manager_device_connected(idev->device, -EIO); + btd_service_connecting_complete(idev->service, -EIO); g_io_channel_unref(idev->ctrl_io); idev->ctrl_io = NULL; } @@ -737,13 +736,11 @@ static void input_device_enter_reconnect_mode(struct input_device *idev) } -int input_device_connect(struct btd_device *dev, struct btd_profile *profile) +int input_device_connect(struct btd_service *service) { struct input_device *idev; - idev = find_device_by_path(devices, device_get_path(dev)); - if (!idev) - return -ENOENT; + idev = btd_service_get_user_data(service); if (idev->ctrl_io) return -EBUSY; @@ -754,20 +751,18 @@ int input_device_connect(struct btd_device *dev, struct btd_profile *profile) return dev_connect(idev); } -int input_device_disconnect(struct btd_device *dev, struct btd_profile *profile) +int input_device_disconnect(struct btd_service *service) { struct input_device *idev; int err; - idev = find_device_by_path(devices, device_get_path(dev)); - if (!idev) - return -ENOENT; + idev = btd_service_get_user_data(service); err = connection_disconnect(idev, 0); if (err < 0) return err; - device_profile_disconnected(dev, profile, 0); + btd_service_disconnecting_complete(service, 0); return 0; } diff --git a/profiles/input/device.h b/profiles/input/device.h index fd7f84790..39c642d7b 100644 --- a/profiles/input/device.h +++ b/profiles/input/device.h @@ -36,6 +36,5 @@ int input_device_set_channel(const bdaddr_t *src, const bdaddr_t *dst, int psm, GIOChannel *io); int input_device_close_channels(const bdaddr_t *src, const bdaddr_t *dst); -int input_device_connect(struct btd_device *dev, struct btd_profile *profile); -int input_device_disconnect(struct btd_device *dev, - struct btd_profile *profile); +int input_device_connect(struct btd_service *service); +int input_device_disconnect(struct btd_service *service); diff --git a/profiles/input/manager.c b/profiles/input/manager.c index dc771a69b..689ccddd6 100644 --- a/profiles/input/manager.c +++ b/profiles/input/manager.c @@ -43,7 +43,6 @@ #include "device.h" #include "server.h" -#include "manager.h" static int hid_server_probe(struct btd_profile *p, struct btd_adapter *adapter) { @@ -72,16 +71,6 @@ static struct btd_profile input_profile = { .adapter_remove = hid_server_remove, }; -void input_manager_device_connected(struct btd_device *dev, int err) -{ - device_profile_connected(dev, &input_profile, err); -} - -void input_manager_device_disconnected(struct btd_device *dev, int err) -{ - device_profile_disconnected(dev, &input_profile, err); -} - static GKeyFile *load_config_file(const char *file) { GKeyFile *keyfile; diff --git a/profiles/input/manager.h b/profiles/input/manager.h deleted file mode 100644 index 3a050944f..000000000 --- a/profiles/input/manager.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2004-2010 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 - * - */ - -void input_manager_device_connected(struct btd_device *dev, int err); -void input_manager_device_disconnected(struct btd_device *dev, int err); |