Home | History | Annotate | Download | only in src
      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 (at) 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 #define DEVICE_INTERFACE	"org.bluez.Device"
     26 
     27 struct btd_device;
     28 
     29 typedef enum {
     30 	AUTH_TYPE_PINCODE,
     31 	AUTH_TYPE_PASSKEY,
     32 	AUTH_TYPE_CONFIRM,
     33 	AUTH_TYPE_NOTIFY,
     34 	AUTH_TYPE_OOB,
     35 	AUTH_TYPE_AUTO,
     36 	AUTH_TYPE_PAIRING_CONSENT,
     37 } auth_type_t;
     38 
     39 struct btd_device *device_create(DBusConnection *conn, struct btd_adapter *adapter,
     40 				const gchar *address);
     41 void device_set_name(struct btd_device *device, const char *name);
     42 void device_get_name(struct btd_device *device, char *name, size_t len);
     43 void device_remove(struct btd_device *device, gboolean remove_stored);
     44 gint device_address_cmp(struct btd_device *device, const gchar *address);
     45 int device_browse(struct btd_device *device, DBusConnection *conn,
     46 			DBusMessage *msg, uuid_t *search, gboolean reverse);
     47 void device_probe_drivers(struct btd_device *device, GSList *profiles);
     48 const sdp_record_t *btd_device_get_record(struct btd_device *device,
     49 						const char *uuid);
     50 void btd_device_add_uuid(struct btd_device *device, const char *uuid);
     51 struct btd_adapter *device_get_adapter(struct btd_device *device);
     52 void device_get_address(struct btd_device *adapter, bdaddr_t *bdaddr);
     53 const gchar *device_get_path(struct btd_device *device);
     54 struct agent *device_get_agent(struct btd_device *device);
     55 gboolean device_is_busy(struct btd_device *device);
     56 gboolean device_is_temporary(struct btd_device *device);
     57 gboolean device_is_paired(struct btd_device *device);
     58 gboolean device_is_trusted(struct btd_device *device);
     59 void device_set_paired(struct btd_device *device, gboolean paired);
     60 void device_set_temporary(struct btd_device *device, gboolean temporary);
     61 void device_set_cap(struct btd_device *device, uint8_t cap);
     62 uint8_t device_get_cap(struct btd_device *device);
     63 void device_set_auth(struct btd_device *device, uint8_t auth);
     64 uint8_t device_get_auth(struct btd_device *device);
     65 gboolean device_is_connected(struct btd_device *device);
     66 gboolean device_get_secmode3_conn(struct btd_device *device);
     67 void device_set_secmode3_conn(struct btd_device *device, gboolean enable);
     68 DBusMessage *device_create_bonding(struct btd_device *device,
     69 				DBusConnection *conn, DBusMessage *msg,
     70 				const char *agent_path, uint8_t capability,
     71 				gboolean oob);
     72 void device_remove_bonding(struct btd_device *device);
     73 void device_bonding_complete(struct btd_device *device, uint8_t status);
     74 void device_simple_pairing_complete(struct btd_device *device, uint8_t status);
     75 gboolean device_is_creating(struct btd_device *device, const char *sender);
     76 gboolean device_is_bonding(struct btd_device *device, const char *sender);
     77 void device_cancel_bonding(struct btd_device *device, uint8_t status);
     78 int device_request_authentication(struct btd_device *device, auth_type_t type,
     79 				uint32_t passkey, void *cb);
     80 int device_request_oob_availability(struct btd_device *device,
     81 				void *cb, void  *user_data);
     82 void device_cancel_authentication(struct btd_device *device, gboolean aborted);
     83 gboolean device_is_authenticating(struct btd_device *device);
     84 gboolean device_is_authorizing(struct btd_device *device);
     85 void device_set_authorizing(struct btd_device *device, gboolean auth);
     86 void device_set_renewed_key(struct btd_device *device, gboolean renewed);
     87 gboolean device_set_debug_key(struct btd_device *device, uint8_t *key);
     88 gboolean device_get_debug_key(struct btd_device *device, uint8_t *key);
     89 void device_add_connection(struct btd_device *device, DBusConnection *conn,
     90 				uint16_t handle);
     91 uint16_t device_get_handle(struct btd_device *device);
     92 void device_remove_connection(struct btd_device *device, DBusConnection *conn,
     93 				uint16_t handle);
     94 gboolean device_has_connection(struct btd_device *device, uint16_t handle);
     95 void device_request_disconnect(struct btd_device *device, DBusMessage *msg);
     96 
     97 typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal,
     98 					void *user_data);
     99 
    100 guint device_add_disconnect_watch(struct btd_device *device,
    101 				disconnect_watch watch, void *user_data,
    102 				GDestroyNotify destroy);
    103 void device_remove_disconnect_watch(struct btd_device *device, guint id);
    104 
    105 #define BTD_UUIDS(args...) ((const char *[]) { args, NULL } )
    106 
    107 struct btd_device_driver {
    108 	const char *name;
    109 	const char **uuids;
    110 	int (*probe) (struct btd_device *device, GSList *uuids);
    111 	void (*remove) (struct btd_device *device);
    112 };
    113 
    114 int btd_register_device_driver(struct btd_device_driver *driver);
    115 void btd_unregister_device_driver(struct btd_device_driver *driver);
    116 
    117 struct btd_device *btd_device_ref(struct btd_device *device);
    118 void btd_device_unref(struct btd_device *device);
    119