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_AUTO,
     35 	AUTH_TYPE_PAIRING_CONSENT,
     36 } auth_type_t;
     37 
     38 typedef enum {
     39 	DEVICE_TYPE_UNKNOWN,
     40 	DEVICE_TYPE_BREDR,
     41 	DEVICE_TYPE_LE,
     42 	DEVICE_TYPE_DUALMODE
     43 } device_type_t;
     44 
     45 struct btd_device *device_create(DBusConnection *conn,
     46 				struct btd_adapter *adapter,
     47 				const gchar *address, device_type_t type);
     48 void device_set_name(struct btd_device *device, const char *name);
     49 void device_get_name(struct btd_device *device, char *name, size_t len);
     50 device_type_t device_get_type(struct btd_device *device);
     51 void device_remove(struct btd_device *device, gboolean remove_stored);
     52 gint device_address_cmp(struct btd_device *device, const gchar *address);
     53 int device_browse_primary(struct btd_device *device, DBusConnection *conn,
     54 				DBusMessage *msg, gboolean secure);
     55 int device_browse_sdp(struct btd_device *device, DBusConnection *conn,
     56 			DBusMessage *msg, uuid_t *search, gboolean reverse);
     57 void device_probe_drivers(struct btd_device *device, GSList *profiles);
     58 const sdp_record_t *btd_device_get_record(struct btd_device *device,
     59 						const char *uuid);
     60 GSList *btd_device_get_primaries(struct btd_device *device);
     61 void device_register_services(DBusConnection *conn, struct btd_device *device,
     62 						GSList *prim_list, int psm);
     63 GSList *device_services_from_record(struct btd_device *device,
     64 							GSList *profiles);
     65 void btd_device_add_uuid(struct btd_device *device, const char *uuid);
     66 struct btd_adapter *device_get_adapter(struct btd_device *device);
     67 void device_get_address(struct btd_device *device, bdaddr_t *bdaddr);
     68 const gchar *device_get_path(struct btd_device *device);
     69 struct agent *device_get_agent(struct btd_device *device);
     70 gboolean device_is_busy(struct btd_device *device);
     71 gboolean device_is_temporary(struct btd_device *device);
     72 gboolean device_is_paired(struct btd_device *device);
     73 gboolean device_is_trusted(struct btd_device *device);
     74 void device_set_paired(struct btd_device *device, gboolean paired);
     75 void device_set_temporary(struct btd_device *device, gboolean temporary);
     76 void device_set_type(struct btd_device *device, device_type_t type);
     77 void device_set_bonded(struct btd_device *device, gboolean bonded);
     78 gboolean device_is_connected(struct btd_device *device);
     79 DBusMessage *device_create_bonding(struct btd_device *device,
     80 				DBusConnection *conn, DBusMessage *msg,
     81 				const char *agent_path, uint8_t capability);
     82 void device_remove_bonding(struct btd_device *device);
     83 void device_bonding_complete(struct btd_device *device, uint8_t status);
     84 void device_simple_pairing_complete(struct btd_device *device, uint8_t status);
     85 gboolean device_is_creating(struct btd_device *device, const char *sender);
     86 gboolean device_is_bonding(struct btd_device *device, const char *sender);
     87 void device_cancel_bonding(struct btd_device *device, uint8_t status);
     88 int device_request_authentication(struct btd_device *device, auth_type_t type,
     89 				uint32_t passkey, void *cb);
     90 void device_cancel_authentication(struct btd_device *device, gboolean aborted);
     91 gboolean device_is_authenticating(struct btd_device *device);
     92 gboolean device_is_authorizing(struct btd_device *device);
     93 void device_set_authorizing(struct btd_device *device, gboolean auth);
     94 void device_add_connection(struct btd_device *device, DBusConnection *conn);
     95 void device_remove_connection(struct btd_device *device, DBusConnection *conn);
     96 void device_request_disconnect(struct btd_device *device, DBusMessage *msg);
     97 
     98 typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal,
     99 					void *user_data);
    100 
    101 guint device_add_disconnect_watch(struct btd_device *device,
    102 				disconnect_watch watch, void *user_data,
    103 				GDestroyNotify destroy);
    104 void device_remove_disconnect_watch(struct btd_device *device, guint id);
    105 void device_set_class(struct btd_device *device, uint32_t value);
    106 
    107 #define BTD_UUIDS(args...) ((const char *[]) { args, NULL } )
    108 
    109 struct btd_device_driver {
    110 	const char *name;
    111 	const char **uuids;
    112 	int (*probe) (struct btd_device *device, GSList *uuids);
    113 	void (*remove) (struct btd_device *device);
    114 };
    115 
    116 int btd_register_device_driver(struct btd_device_driver *driver);
    117 void btd_unregister_device_driver(struct btd_device_driver *driver);
    118 
    119 struct btd_device *btd_device_ref(struct btd_device *device);
    120 void btd_device_unref(struct btd_device *device);
    121