Initialize Tizen 2.3
[framework/connectivity/bluez.git] / wearable / src / device.h
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2006-2010  Nokia Corporation
6  *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
7  *
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  *
23  */
24
25 #ifdef __TIZEN_PATCH__
26 #include "gattrib.h"
27 #endif
28
29 #define DEVICE_INTERFACE        "org.bluez.Device"
30
31 struct btd_device;
32
33 typedef enum {
34         AUTH_TYPE_PINCODE,
35         AUTH_TYPE_PASSKEY,
36         AUTH_TYPE_CONFIRM,
37         AUTH_TYPE_NOTIFY_PASSKEY,
38         AUTH_TYPE_NOTIFY_PINCODE,
39 } auth_type_t;
40
41 struct btd_device *device_create(DBusConnection *conn,
42                                         struct btd_adapter *adapter,
43                                         const char *address, uint8_t bdaddr_type);
44 void device_set_name(struct btd_device *device, const char *name);
45 void device_get_name(struct btd_device *device, char *name, size_t len);
46 uint16_t btd_device_get_vendor(struct btd_device *device);
47 uint16_t btd_device_get_vendor_src(struct btd_device *device);
48 uint16_t btd_device_get_product(struct btd_device *device);
49 uint16_t btd_device_get_version(struct btd_device *device);
50 void device_remove(struct btd_device *device, gboolean remove_stored);
51 gint device_address_cmp(struct btd_device *device, const gchar *address);
52 int device_browse_primary(struct btd_device *device, DBusConnection *conn,
53                                 DBusMessage *msg, gboolean secure);
54 int device_browse_sdp(struct btd_device *device, DBusConnection *conn,
55                         DBusMessage *msg, uuid_t *search, gboolean reverse);
56 void device_probe_drivers(struct btd_device *device, GSList *profiles);
57 const sdp_record_t *btd_device_get_record(struct btd_device *device,
58                                                 const char *uuid);
59 GSList *btd_device_get_primaries(struct btd_device *device);
60 void device_register_services(DBusConnection *conn, struct btd_device *device,
61                                                 GSList *prim_list, int psm);
62 GSList *device_services_from_record(struct btd_device *device,
63                                                         GSList *profiles);
64 void btd_device_add_uuid(struct btd_device *device, const char *uuid);
65 struct btd_adapter *device_get_adapter(struct btd_device *device);
66 void device_get_address(struct btd_device *device, bdaddr_t *bdaddr,
67                                                         uint8_t *bdaddr_type);
68 void device_set_addr_type(struct btd_device *device, uint8_t bdaddr_type);
69 uint8_t device_get_addr_type(struct btd_device *device);
70 const gchar *device_get_path(struct btd_device *device);
71 struct agent *device_get_agent(struct btd_device *device);
72 gboolean device_is_bredr(struct btd_device *device);
73 gboolean device_is_le(struct btd_device *device);
74 gboolean device_is_busy(struct btd_device *device);
75 gboolean device_is_temporary(struct btd_device *device);
76 gboolean device_is_paired(struct btd_device *device);
77 gboolean device_is_bonded(struct btd_device *device);
78 gboolean device_is_trusted(struct btd_device *device);
79 void device_set_paired(struct btd_device *device, gboolean paired);
80 void device_set_temporary(struct btd_device *device, gboolean temporary);
81 void device_set_bonded(struct btd_device *device, gboolean bonded);
82 void device_set_auto_connect(struct btd_device *device, gboolean enable);
83 gboolean device_is_connected(struct btd_device *device);
84 DBusMessage *device_create_bonding(struct btd_device *device,
85                                 DBusConnection *conn, DBusMessage *msg,
86                                 const char *agent_path, uint8_t capability);
87 void device_bonding_complete(struct btd_device *device, uint8_t status);
88 void device_simple_pairing_complete(struct btd_device *device, uint8_t status);
89 gboolean device_is_creating(struct btd_device *device, const char *sender);
90 gboolean device_is_bonding(struct btd_device *device, const char *sender);
91 void device_cancel_bonding(struct btd_device *device, uint8_t status);
92 int device_request_authentication(struct btd_device *device, auth_type_t type,
93                                         void *data, gboolean secure, void *cb);
94 void device_cancel_authentication(struct btd_device *device, gboolean aborted);
95 gboolean device_is_authenticating(struct btd_device *device);
96 gboolean device_is_authorizing(struct btd_device *device);
97 void device_set_authorizing(struct btd_device *device, gboolean auth);
98 void device_add_connection(struct btd_device *device, DBusConnection *conn);
99 void device_remove_connection(struct btd_device *device, DBusConnection *conn);
100 void device_request_disconnect(struct btd_device *device, DBusMessage *msg);
101
102 typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal,
103                                         void *user_data);
104
105 guint device_add_disconnect_watch(struct btd_device *device,
106                                 disconnect_watch watch, void *user_data,
107                                 GDestroyNotify destroy);
108 void device_remove_disconnect_watch(struct btd_device *device, guint id);
109 void device_set_class(struct btd_device *device, uint32_t value);
110
111 #define BTD_UUIDS(args...) ((const char *[]) { args, NULL } )
112
113 struct btd_device_driver {
114         const char *name;
115         const char **uuids;
116         int (*probe) (struct btd_device *device, GSList *uuids);
117         void (*remove) (struct btd_device *device);
118 };
119
120 int btd_register_device_driver(struct btd_device_driver *driver);
121 void btd_unregister_device_driver(struct btd_device_driver *driver);
122
123 struct btd_device *btd_device_ref(struct btd_device *device);
124 void btd_device_unref(struct btd_device *device);
125
126 int device_block(DBusConnection *conn, struct btd_device *device,
127                                                 gboolean update_only);
128 int device_unblock(DBusConnection *conn, struct btd_device *device,
129                                         gboolean silent, gboolean update_only);
130 void device_set_pnpid(struct btd_device *device, uint8_t vendor_id_src,
131                         uint16_t vendor_id, uint16_t product_id,
132                         uint16_t product_ver);
133 #ifdef __TIZEN_PATCH__
134 void device_set_attrib(struct btd_device *device, guint attachid, GAttrib *attrib);
135 void device_set_gatt_connected(struct btd_device *device, gboolean connected);
136 void device_set_disconnect_reason(struct btd_device *device, uint8_t reason);
137 #endif