• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 #ifndef CRAS_BT_PROFILE_H_
7 #define CRAS_BT_PROFILE_H_
8 
9 #include <dbus/dbus.h>
10 
11 #include "cras_bt_device.h"
12 
13 #define PROFILE_MANAGER_OBJ_PATH "/org/bluez"
14 
15 /* Structure in cras to represent an external profile of bluez. All members
16  * and functions are documented in bluez/doc/profile-api.txt, more options
17  * can be put into this structure when we need it.
18  */
19 struct cras_bt_profile {
20 	const char *name;
21 	const char *object_path;
22 	const char *uuid;
23 	const char *role;
24 	const char *record;
25 	int version;
26 	int features;
27 	void (*release)(struct cras_bt_profile *profile);
28 	int (*new_connection)(DBusConnection *conn,
29 			      struct cras_bt_profile *profile,
30 			      struct cras_bt_device *device,
31 			      int rfcomm_fd);
32 	void (*request_disconnection)(struct cras_bt_profile *profile,
33 				      struct cras_bt_device *device);
34 	void (*cancel)(struct cras_bt_profile *profile);
35 	struct cras_bt_profile *prev, *next;
36 };
37 
38 /* Adds the profile to cras and registers it with bluez.
39  * Args:
40  *    conn - The dbus connection.
41  *    profile - Pointer to the profile structure to be add.
42  */
43 int cras_bt_add_profile(DBusConnection *conn,
44 			struct cras_bt_profile *profile);
45 
46 /* Gets the profile by object path.
47  * Args:
48  *    path - The object path of the desired profile.
49  *
50  * Returns:
51  *    The profile of the requested object path, or NULL if it
52  *    does not exist.
53  */
54 struct cras_bt_profile *cras_bt_profile_get(const char *path);
55 
56 /* Resets all added profiles. */
57 void cras_bt_profile_reset();
58 
59 /* Notifies all profiles when a device is disconnected. */
60 void cras_bt_profile_on_device_disconnected(struct cras_bt_device *device);
61 
62 /* Registers all added profiles.
63  * Args:
64  *    conn - The dbus connection.
65  * Returns:
66  *    0 on success, or negative error code on failure.
67  */
68 int cras_bt_register_profiles(DBusConnection *conn);
69 
70 #endif /* CRAS_BT_PROFILE_H_ */
71