E_Bluez.h
Go to the documentation of this file.
1 #ifndef E_BLUEZ_H
2 #define E_BLUEZ_H
3 
4 #include <stdint.h>
5 #include <stdio.h>
6 
7 #include <Eina.h>
8 #include <Ecore.h>
9 #include <E_DBus.h>
10 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /* Ecore Events */
22 extern int E_BLUEZ_EVENT_MANAGER_IN;
23 extern int E_BLUEZ_EVENT_MANAGER_OUT;
24 extern int E_BLUEZ_EVENT_ELEMENT_ADD;
25 extern int E_BLUEZ_EVENT_ELEMENT_DEL;
28 // TODO: extern int E_BLUEZ_EVENT_DEVICE_DISAPPEARED;
29 
33 
35 {
36  const char *path;
37  const char *interface;
40  Eina_Inlist *props;
41 
42  /* private */
43  struct
44  {
45  Eina_Inlist *properties_get;
46  Eina_Inlist *property_set;
47  Eina_Inlist *agent_register;
48  Eina_Inlist *agent_unregister;
49  Eina_Inlist *start_discovery;
50  Eina_Inlist *stop_discovery;
51  Eina_Inlist *create_paired_device;
52  } _pending;
53  struct
54  {
55  Ecore_Idler *changed;
56  } _idler;
57  Eina_Inlist *_listeners;
59 };
60 
62 {
63  int type;
64  Eina_Array *array;
65 };
66 
68 {
70  const char *name;
72 };
73 
74 /* General Public API */
75 EAPI unsigned int e_bluez_system_init(E_DBus_Connection *edbus_conn) EINA_ARG_NONNULL(1);
76 EAPI unsigned int e_bluez_system_shutdown(void);
77 
78 /* Manager Methods */
80 EAPI Eina_Bool e_bluez_manager_default_adapter(E_DBus_Method_Return_Cb cb, void *data) EINA_WARN_UNUSED_RESULT;
81 
82 /* Adapter Methods */
83 EAPI E_Bluez_Element * e_bluez_adapter_get(const char *path) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
84 
85 EAPI Eina_Bool e_bluez_adapter_agent_register(E_Bluez_Element *element, const char *object_path, const char *capability, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
86 EAPI Eina_Bool e_bluez_adapter_agent_unregister(E_Bluez_Element *element, const char *object_path, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
87 EAPI Eina_Bool e_bluez_adapter_address_get(const E_Bluez_Element *element, const char **address) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
88 EAPI Eina_Bool e_bluez_adapter_name_get(const E_Bluez_Element *element, const char **name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
89 EAPI Eina_Bool e_bluez_adapter_name_set(E_Bluez_Element *element, const char *name, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1,2) EINA_WARN_UNUSED_RESULT;
90 EAPI Eina_Bool e_bluez_adapter_powered_get(const E_Bluez_Element *element, Eina_Bool *powered) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
91 EAPI Eina_Bool e_bluez_adapter_powered_set(E_Bluez_Element *profile, Eina_Bool powered, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
92 EAPI Eina_Bool e_bluez_adapter_discoverable_get(const E_Bluez_Element *element, Eina_Bool *discoverable) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
93 EAPI Eina_Bool e_bluez_adapter_discoverable_set(E_Bluez_Element *profile, Eina_Bool discoverable, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
94 EAPI Eina_Bool e_bluez_adapter_discoverable_timeout_get(const E_Bluez_Element *element, unsigned int *timeout) EINA_ARG_NONNULL(1,2) EINA_WARN_UNUSED_RESULT;
95 EAPI Eina_Bool e_bluez_adapter_discoverable_timeout_set(E_Bluez_Element *element, unsigned int timeout, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
96 EAPI Eina_Bool e_bluez_adapter_discovering_get(const E_Bluez_Element *element, Eina_Bool *discovering) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
97 EAPI Eina_Bool e_bluez_adapter_start_discovery(E_Bluez_Element *element, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
98 EAPI Eina_Bool e_bluez_adapter_stop_discovery(E_Bluez_Element *element, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
99 EAPI Eina_Bool e_bluez_adapter_create_paired_device(E_Bluez_Element *element, const char *object_path, const char *capability, const char *device, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 4) EINA_WARN_UNUSED_RESULT;
100 
101 /* Device Found Methods */
102 EAPI void e_bluez_devicefound_free(E_Bluez_Device_Found *device) EINA_ARG_NONNULL(1);
103 EAPI const char * e_bluez_devicefound_alias_get(const E_Bluez_Device_Found *device) EINA_ARG_NONNULL(1);
104 
105 /* Devices Methods */
106 EAPI E_Bluez_Element * e_bluez_device_get(const char *path) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
107 EAPI Eina_Bool e_bluez_device_name_get(const E_Bluez_Element *element, const char **name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
108 EAPI Eina_Bool e_bluez_device_alias_get(const E_Bluez_Element *element, const char **alias) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
109 EAPI Eina_Bool e_bluez_device_paired_get(const E_Bluez_Element *element, Eina_Bool *paired) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
110 
111 /* Low-Level API:
112  *
113  * Should just be used to work around problems until proper solution
114  * is made into e_bluez.
115  */
116 EAPI Eina_Bool e_bluez_manager_sync_elements(void);
117 
118 EAPI Eina_Bool e_bluez_elements_get_all(unsigned int *count, E_Bluez_Element ***p_elements) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
119 EAPI Eina_Bool e_bluez_elements_get_all_type(const char *type, unsigned int *count, E_Bluez_Element ***p_elements) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
120 EAPI E_Bluez_Element * e_bluez_element_get(const char *path);
121 
122 EAPI void e_bluez_element_listener_add(E_Bluez_Element *element, void (*cb)(void *data, const E_Bluez_Element *element), const void *data, void (*free_data)(void *data)) EINA_ARG_NONNULL(1, 2);
123 EAPI void e_bluez_element_listener_del(E_Bluez_Element *element, void (*cb)(void *data, const E_Bluez_Element *element), const void *data) EINA_ARG_NONNULL(1, 2);
124 
125 EAPI int e_bluez_element_ref(E_Bluez_Element *element) EINA_ARG_NONNULL(1);
126 EAPI int e_bluez_element_unref(E_Bluez_Element *element) EINA_ARG_NONNULL(1);
127 
128 EAPI void e_bluez_element_print(FILE *fp, const E_Bluez_Element *element) EINA_ARG_NONNULL(1, 2);
129 EAPI void e_bluez_element_array_print(FILE *fp, E_Bluez_Array *array);
130 
131 EAPI Eina_Bool e_bluez_element_properties_sync(E_Bluez_Element *element) EINA_ARG_NONNULL(1);
132 EAPI Eina_Bool e_bluez_element_properties_sync_full(E_Bluez_Element *element, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1);
133 
134 EAPI Eina_Bool e_bluez_element_property_set(E_Bluez_Element *element, const char *prop, int type, const void *value) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
135 EAPI Eina_Bool e_bluez_element_property_set_full(E_Bluez_Element *element, const char *prop, int type, const void *value, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
136 EAPI Eina_Bool e_bluez_element_property_dict_set_full(E_Bluez_Element *element, const char *prop, const char *key, int type, const void *value, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
137 
138 EAPI void e_bluez_element_properties_list(const E_Bluez_Element *element, Eina_Bool (*cb)(void *data, const E_Bluez_Element *element, const char *name, int type, const void *value), const void *data) EINA_ARG_NONNULL(1, 2);
139 
140 EAPI Eina_Bool e_bluez_element_property_type_get_stringshared(const E_Bluez_Element *element, const char *name, int *type) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
141 EAPI Eina_Bool e_bluez_element_property_type_get(const E_Bluez_Element *element, const char *name, int *type) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
142 EAPI Eina_Bool e_bluez_element_property_dict_get_stringshared(const E_Bluez_Element *element, const char *dict_name, const char *key_name, int *type, void *value) EINA_ARG_NONNULL(1, 2, 4) EINA_WARN_UNUSED_RESULT;
143 EAPI Eina_Bool e_bluez_element_property_get_stringshared(const E_Bluez_Element *element, const char *name, int *type, void *value) EINA_ARG_NONNULL(1, 2, 4) EINA_WARN_UNUSED_RESULT;
144 EAPI Eina_Bool e_bluez_element_property_get(const E_Bluez_Element *element, const char *name, int *type, void *value) EINA_ARG_NONNULL(1, 2, 4) EINA_WARN_UNUSED_RESULT;
145 
146 EAPI Eina_Bool e_bluez_element_is_adapter(const E_Bluez_Element *element) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
147 EAPI Eina_Bool e_bluez_element_is_device(const E_Bluez_Element *element) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
157 #endif /* E_BLUEZ_H */
EAPI void e_bluez_element_print(FILE *fp, const E_Bluez_Element *element) EINA_ARG_NONNULL(1
Eina_Bool e_bluez_manager_sync_elements(void)
Definition: e_bluez.c:71
Ecore_Idler * changed
Definition: E_Bluez.h:55
struct _E_Bluez_Element::@0 _pending
EAPI Eina_Bool e_bluez_element_properties_sync(E_Bluez_Element *element) EINA_ARG_NONNULL(1)
Definition: e_bluez_element.c:1443
unsigned int e_bluez_system_shutdown(void)
Definition: e_bluez.c:337
Definition: E_Bluez.h:34
EAPI Eina_Bool e_bluez_adapter_start_discovery(E_Bluez_Element *element, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
Definition: e_bluez_adapter.c:363
EAPI Eina_Bool e_bluez_adapter_discoverable_set(E_Bluez_Element *profile, Eina_Bool discoverable, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
Definition: e_bluez_adapter.c:272
EAPI void e_bluez_element_listener_add(E_Bluez_Element *element, void(*cb)(void *data, const E_Bluez_Element *element), const void *data, void(*free_data)(void *data)) EINA_ARG_NONNULL(1
E_Bluez_Element * adapter
Definition: E_Bluez.h:69
EAPI Eina_Bool e_bluez_element_property_set_full(E_Bluez_Element *element, const char *prop, int type, const void *value, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1
Definition: e_dbus_private.h:18
EAPI Eina_Bool e_bluez_device_alias_get(const E_Bluez_Element *element, const char **alias) EINA_ARG_NONNULL(1
Eina_Inlist * create_paired_device
Definition: E_Bluez.h:51
EAPI Eina_Bool e_bluez_adapter_agent_unregister(E_Bluez_Element *element, const char *object_path, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1
EAPI Eina_Bool e_bluez_adapter_discoverable_timeout_set(E_Bluez_Element *element, unsigned int timeout, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
Definition: e_bluez_adapter.c:320
void(* E_DBus_Method_Return_Cb)(void *data, DBusMessage *msg, DBusError *error)
Definition: E_DBus.h:124
Eina_Inlist * stop_discovery
Definition: E_Bluez.h:50
EAPI E_Bluez_Element * e_bluez_device_get(const char *path) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
Definition: e_bluez_device.c:4
EAPI Eina_Bool e_bluez_adapter_address_get(const E_Bluez_Element *element, const char **address) EINA_ARG_NONNULL(1
EAPI Eina_Bool e_bluez_element_property_type_get(const E_Bluez_Element *element, const char *name, int *type) EINA_ARG_NONNULL(1
EAPI E_Bluez_Element * e_bluez_element_get(const char *path)
Definition: e_bluez_element.c:2192
EAPI int E_BLUEZ_EVENT_DEVICE_FOUND
Definition: e_bluez.c:19
Eina_Inlist * start_discovery
Definition: E_Bluez.h:49
EAPI E_Bluez_Element * e_bluez_manager_get(void) EINA_WARN_UNUSED_RESULT
Definition: e_bluez_manager.c:9
EAPI void e_bluez_element_properties_list(const E_Bluez_Element *element, Eina_Bool(*cb)(void *data, const E_Bluez_Element *element, const char *name, int type, const void *value), const void *data) EINA_ARG_NONNULL(1
Eina_Inlist * _listeners
Definition: E_Bluez.h:57
EAPI Eina_Bool e_bluez_adapter_agent_register(E_Bluez_Element *element, const char *object_path, const char *capability, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1
EAPI void EAPI void e_bluez_element_array_print(FILE *fp, E_Bluez_Array *array)
Definition: e_bluez_element.c:899
Definition: E_Bluez.h:61
EAPI Eina_Bool e_bluez_device_paired_get(const E_Bluez_Element *element, Eina_Bool *paired) EINA_ARG_NONNULL(1
unsigned int e_bluez_system_init(E_DBus_Connection *edbus_conn)
Definition: e_bluez.c:212
EAPI int E_BLUEZ_EVENT_MANAGER_OUT
Definition: e_bluez.c:15
#define EAPI
Definition: E_DBus.h:44
E_DBus_Signal_Handler * signal_handler
Definition: E_Bluez.h:38
EAPI Eina_Bool e_bluez_adapter_name_set(E_Bluez_Element *element, const char *name, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1
EAPI Eina_Bool e_bluez_manager_default_adapter(E_DBus_Method_Return_Cb cb, void *data) EINA_WARN_UNUSED_RESULT
Definition: e_bluez_manager.c:25
int _references
Definition: E_Bluez.h:58
EAPI Eina_Bool e_bluez_element_is_device(const E_Bluez_Element *element) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
Definition: e_bluez_element.c:2405
EAPI Eina_Bool e_bluez_elements_get_all(unsigned int *count, E_Bluez_Element ***p_elements) EINA_ARG_NONNULL(1
EAPI Eina_Bool e_bluez_adapter_powered_get(const E_Bluez_Element *element, Eina_Bool *powered) EINA_ARG_NONNULL(1
EAPI Eina_Bool e_bluez_adapter_discovering_get(const E_Bluez_Element *element, Eina_Bool *discovering) EINA_ARG_NONNULL(1
EAPI Eina_Bool EINA_WARN_UNUSED_RESULT
Definition: E_Bluez.h:85
EAPI Eina_Bool e_bluez_element_property_get(const E_Bluez_Element *element, const char *name, int *type, void *value) EINA_ARG_NONNULL(1
EAPI int e_bluez_element_unref(E_Bluez_Element *element) EINA_ARG_NONNULL(1)
Definition: e_bluez_element.c:1129
EAPI int E_BLUEZ_EVENT_MANAGER_IN
Definition: e_bluez.c:14
EAPI void EAPI Eina_Bool e_bluez_element_property_type_get_stringshared(const E_Bluez_Element *element, const char *name, int *type) EINA_ARG_NONNULL(1
Definition: E_Bluez.h:67
EAPI const char * e_bluez_devicefound_alias_get(const E_Bluez_Device_Found *device) EINA_ARG_NONNULL(1)
Definition: e_bluez_devicefound.c:23
E_Bluez_Array * array
Definition: E_Bluez.h:71
EAPI void EAPI void e_bluez_element_listener_del(E_Bluez_Element *element, void(*cb)(void *data, const E_Bluez_Element *element), const void *data) EINA_ARG_NONNULL(1
EAPI Eina_Bool e_bluez_adapter_stop_discovery(E_Bluez_Element *element, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
Definition: e_bluez_adapter.c:391
EAPI int E_BLUEZ_EVENT_ELEMENT_DEL
Definition: e_bluez.c:17
EAPI Eina_Bool e_bluez_device_name_get(const E_Bluez_Element *element, const char **name) EINA_ARG_NONNULL(1
EAPI Eina_Bool e_bluez_element_property_get_stringshared(const E_Bluez_Element *element, const char *name, int *type, void *value) EINA_ARG_NONNULL(1
struct _E_Bluez_Element::@1 _idler
EAPI Eina_Bool e_bluez_adapter_name_get(const E_Bluez_Element *element, const char **name) EINA_ARG_NONNULL(1
Eina_Array * array
Definition: E_Bluez.h:64
E_DBus_Signal_Handler * device_found_handler
Definition: E_Bluez.h:39
EAPI Eina_Bool e_bluez_adapter_discoverable_get(const E_Bluez_Element *element, Eina_Bool *discoverable) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
Definition: e_bluez_adapter.c:252
EAPI int E_BLUEZ_EVENT_ELEMENT_ADD
Definition: e_bluez.c:16
EAPI Eina_Bool e_bluez_element_is_adapter(const E_Bluez_Element *element) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
Definition: e_bluez_element.c:2398
Eina_Inlist * props
Definition: E_Bluez.h:40
EAPI Eina_Bool e_bluez_adapter_discoverable_timeout_get(const E_Bluez_Element *element, unsigned int *timeout) EINA_ARG_NONNULL(1
Eina_Inlist * property_set
Definition: E_Bluez.h:46
const char * name
Definition: E_Bluez.h:70
Eina_Inlist * agent_register
Definition: E_Bluez.h:47
EAPI E_Bluez_Element * e_bluez_adapter_get(const char *path) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
Definition: e_bluez_adapter.c:4
EAPI Eina_Bool e_bluez_element_property_dict_set_full(E_Bluez_Element *element, const char *prop, const char *key, int type, const void *value, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1
EAPI int E_BLUEZ_EVENT_ELEMENT_UPDATED
Definition: e_bluez.c:18
EAPI void e_bluez_devicefound_free(E_Bluez_Device_Found *device) EINA_ARG_NONNULL(1)
Definition: e_bluez_devicefound.c:9
EAPI Eina_Bool e_bluez_adapter_powered_set(E_Bluez_Element *profile, Eina_Bool powered, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
Definition: e_bluez_adapter.c:230
EAPI Eina_Bool e_bluez_element_properties_sync_full(E_Bluez_Element *element, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1)
Definition: e_bluez_element.c:1421
Eina_Inlist * properties_get
Definition: E_Bluez.h:45
Eina_Inlist * agent_unregister
Definition: E_Bluez.h:48
EAPI void EAPI void EAPI int e_bluez_element_ref(E_Bluez_Element *element) EINA_ARG_NONNULL(1)
Definition: e_bluez_element.c:1117
EAPI Eina_Bool e_bluez_element_property_dict_get_stringshared(const E_Bluez_Element *element, const char *dict_name, const char *key_name, int *type, void *value) EINA_ARG_NONNULL(1
Definition: e_dbus_signal.c:19
int type
Definition: E_Bluez.h:63
const char * path
Definition: E_Bluez.h:36
EAPI Eina_Bool e_bluez_element_property_set(E_Bluez_Element *element, const char *prop, int type, const void *value) EINA_ARG_NONNULL(1
EAPI Eina_Bool e_bluez_elements_get_all_type(const char *type, unsigned int *count, E_Bluez_Element ***p_elements) EINA_ARG_NONNULL(1
const char * interface
Definition: E_Bluez.h:37
EAPI Eina_Bool e_bluez_adapter_create_paired_device(E_Bluez_Element *element, const char *object_path, const char *capability, const char *device, E_DBus_Method_Return_Cb cb, const void *data) EINA_ARG_NONNULL(1