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, int rfcomm_fd); 31 void (*request_disconnection)(struct cras_bt_profile *profile, 32 struct cras_bt_device *device); 33 void (*cancel)(struct cras_bt_profile *profile); 34 struct cras_bt_profile *prev, *next; 35 }; 36 37 /* Adds the profile to cras and registers it with bluez. 38 * Args: 39 * conn - The dbus connection. 40 * profile - Pointer to the profile structure to be add. 41 */ 42 int cras_bt_add_profile(DBusConnection *conn, struct cras_bt_profile *profile); 43 44 /* Removes |profile| from the list of profiles registered with bluez. 45 * Args: 46 * conn - The dbus connection. 47 * profile - Pointer to the profile structure to be removed. 48 */ 49 int cras_bt_rm_profile(DBusConnection *conn, struct cras_bt_profile *profile); 50 51 /* Gets the profile by object path. 52 * Args: 53 * path - The object path of the desired profile. 54 * 55 * Returns: 56 * The profile of the requested object path, or NULL if it 57 * does not exist. 58 */ 59 struct cras_bt_profile *cras_bt_profile_get(const char *path); 60 61 /* Resets all added profiles. */ 62 void cras_bt_profile_reset(); 63 64 /* Notifies all profiles when a device is disconnected. */ 65 void cras_bt_profile_on_device_disconnected(struct cras_bt_device *device); 66 67 /* Registeres |profile| with bluez. 68 * Args: 69 * conn - The dbus connection. 70 * profile - Pointer to the profile structure to be registered. 71 */ 72 int cras_bt_register_profile(DBusConnection *conn, 73 struct cras_bt_profile *profile); 74 75 /* Unregisteres |profile| with bluez. 76 * Args: 77 * conn - The dbus connection. 78 * profile - Pointer to the profile structure to be unregistered. 79 */ 80 int cras_bt_unregister_profile(DBusConnection *conn, 81 struct cras_bt_profile *profile); 82 83 /* Registers all added profiles. 84 * Args: 85 * conn - The dbus connection. 86 * Returns: 87 * 0 on success, or negative error code on failure. 88 */ 89 int cras_bt_register_profiles(DBusConnection *conn); 90 91 #endif /* CRAS_BT_PROFILE_H_ */ 92