tizen 2.3 release
[framework/connectivity/bluez.git] / src / service.h
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2012-2013  BMW Car IT GmbH. All rights reserved.
6  *
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  */
23
24 typedef enum {
25         BTD_SERVICE_STATE_UNAVAILABLE, /* Not probed */
26         BTD_SERVICE_STATE_DISCONNECTED,
27         BTD_SERVICE_STATE_CONNECTING,
28         BTD_SERVICE_STATE_CONNECTED,
29         BTD_SERVICE_STATE_DISCONNECTING,
30 } btd_service_state_t;
31
32 struct btd_service;
33 struct btd_device;
34 struct btd_profile;
35
36 typedef void (*btd_service_state_cb) (struct btd_service *service,
37                                                 btd_service_state_t old_state,
38                                                 btd_service_state_t new_state,
39                                                 void *user_data);
40
41 struct btd_service *btd_service_ref(struct btd_service *service);
42 void btd_service_unref(struct btd_service *service);
43
44 /* Service management functions used by the core */
45 struct btd_service *service_create(struct btd_device *device,
46                                                 struct btd_profile *profile);
47
48 int service_probe(struct btd_service *service);
49 void service_remove(struct btd_service *service);
50
51 /* Connection control API */
52 int btd_service_connect(struct btd_service *service);
53 int btd_service_disconnect(struct btd_service *service);
54
55 /* Public member access */
56 struct btd_device *btd_service_get_device(const struct btd_service *service);
57 struct btd_profile *btd_service_get_profile(const struct btd_service *service);
58 btd_service_state_t btd_service_get_state(const struct btd_service *service);
59 int btd_service_get_error(const struct btd_service *service);
60
61 unsigned int btd_service_add_state_cb(btd_service_state_cb cb,
62                                                         void *user_data);
63 bool btd_service_remove_state_cb(unsigned int id);
64
65 /* Functions used by profile implementation */
66 void btd_service_connecting_complete(struct btd_service *service, int err);
67 void btd_service_disconnecting_complete(struct btd_service *service, int err);
68 void btd_service_set_user_data(struct btd_service *service, void *user_data);
69 void *btd_service_get_user_data(const struct btd_service *service);