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 /* Gets the profile by object path. 45 * Args: 46 * path - The object path of the desired profile. 47 * 48 * Returns: 49 * The profile of the requested object path, or NULL if it 50 * does not exist. 51 */ 52 struct cras_bt_profile *cras_bt_profile_get(const char *path); 53 54 /* Resets all added profiles. */ 55 void cras_bt_profile_reset(); 56 57 /* Notifies all profiles when a device is disconnected. */ 58 void cras_bt_profile_on_device_disconnected(struct cras_bt_device *device); 59 60 /* Registers all added profiles. 61 * Args: 62 * conn - The dbus connection. 63 * Returns: 64 * 0 on success, or negative error code on failure. 65 */ 66 int cras_bt_register_profiles(DBusConnection *conn); 67 68 #endif /* CRAS_BT_PROFILE_H_ */ 69