lib/bluez/e_bluez_private.h
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include "config.h"
00003 #endif
00004 
00005 #ifdef HAVE_ALLOCA_H
00006 # include <alloca.h>
00007 #elif defined __GNUC__
00008 # define alloca __builtin_alloca
00009 #elif defined _AIX
00010 # define alloca __alloca
00011 #elif defined _MSC_VER
00012 # include <malloc.h>
00013 # define alloca _alloca
00014 #else
00015 # include <stddef.h>
00016 # ifdef  __cplusplus
00017 extern "C"
00018 # endif
00019 void *    alloca (size_t);
00020 #endif
00021 
00022 #include <stdio.h>
00023 
00024 #include <Eina.h>
00025 #include <eina_safety_checks.h>
00026 
00027 #include "E_Bluez.h"
00028 
00029 static const char manager_path[] = "/";
00030 
00031 extern const char *e_bluez_iface_manager;
00032 extern const char *e_bluez_iface_adapter;
00033 extern const char *e_bluez_iface_device;
00034 extern const char *e_bluez_prop_address;
00035 extern const char *e_bluez_prop_name;
00036 extern const char *e_bluez_prop_alias;
00037 extern const char *e_bluez_prop_class;
00038 extern const char *e_bluez_prop_icon;
00039 extern const char *e_bluez_prop_paired;
00040 extern const char *e_bluez_prop_trusted;
00041 extern const char *e_bluez_prop_connected;
00042 extern const char *e_bluez_prop_uuids;
00043 extern const char *e_bluez_prop_powered;
00044 extern const char *e_bluez_prop_discoverable;
00045 extern const char *e_bluez_prop_pairable;
00046 extern const char *e_bluez_prop_discoverabletimeout;
00047 extern const char *e_bluez_prop_pairabletimeout;
00048 extern const char *e_bluez_prop_discovering;
00049 extern const char *e_bluez_prop_devices;
00050 
00051 extern int _e_dbus_bluez_log_dom;
00052 
00053 typedef struct _E_Bluez_Element_Dict_Entry   E_Bluez_Element_Dict_Entry;
00054 
00055 struct _E_Bluez_Element_Dict_Entry
00056 {
00057    const char *name;
00058    int         type;
00059    union {
00060       Eina_Bool      boolean;
00061       const char    *str;
00062       short          i16;
00063       unsigned short u16;
00064       unsigned int   u32;
00065       unsigned char  byte;
00066       const char    *path;
00067    } value;
00068 };
00069 
00070 #ifndef EINA_LOG_DEFAULT_COLOR
00071 #define EINA_LOG_DEFAULT_COLOR EINA_COLOR_CYAN
00072 #endif
00073 
00074 #undef DBG
00075 #undef INF
00076 #undef WRN
00077 #undef ERR
00078 
00079 #define DBG(...) EINA_LOG_DOM_DBG(_e_dbus_bluez_log_dom, __VA_ARGS__)
00080 #define INF(...) EINA_LOG_DOM_INFO(_e_dbus_bluez_log_dom, __VA_ARGS__)
00081 #define WRN(...) EINA_LOG_DOM_WARN(_e_dbus_bluez_log_dom, __VA_ARGS__)
00082 #define ERR(...) EINA_LOG_DOM_ERR(_e_dbus_bluez_log_dom, __VA_ARGS__)
00083 
00084 static inline Eina_Bool
00085 _dbus_callback_check_and_init(DBusMessage *msg, DBusMessageIter *itr, DBusError *err)
00086 {
00087    if (!msg)
00088      {
00089         if (err)
00090            ERR("an error was reported by server: "
00091                "name=\"%s\", message=\"%s\"",
00092                err->name, err->message);
00093         else
00094            ERR("callback without message arguments!");
00095 
00096         return EINA_FALSE;
00097      }
00098 
00099    if (!dbus_message_iter_init(msg, itr))
00100      {
00101         ERR("could not init iterator.");
00102         return EINA_FALSE;
00103      }
00104 
00105    return EINA_TRUE;
00106 }
00107 
00108 static inline Eina_Bool
00109 __dbus_iter_type_check(int type, int expected, const char *expected_name)
00110 {
00111    if (type == expected)
00112       return EINA_TRUE;
00113 
00114    ERR("expected type %s (%c) but got %c instead!",
00115        expected_name, expected, type);
00116 
00117    return EINA_FALSE;
00118 }
00119 
00120 #define _dbus_iter_type_check(t, e) __dbus_iter_type_check(t, e, # e)
00121 
00122 extern E_DBus_Connection *e_bluez_conn;
00123 
00124 const char *                    e_bluez_system_bus_name_get(void);
00125 
00126 void                            e_bluez_manager_clear_elements(void);
00127 
00128 void                            e_bluez_elements_init(void);
00129 void                            e_bluez_elements_shutdown(void);
00130 
00131 E_Bluez_Element *               e_bluez_element_register(const char *path, const char *interface);
00132 void                            e_bluez_element_unregister(E_Bluez_Element *element);
00133 
00134 Eina_Bool                       e_bluez_element_message_send(E_Bluez_Element *element, const char *method_name, E_DBus_Method_Return_Cb cb, DBusMessage *msg, Eina_Inlist **pending, E_DBus_Method_Return_Cb user_cb, const void *user_data);
00135 E_Bluez_Array *                 e_bluez_element_iter_get_array(DBusMessageIter *itr, const char *key);
00136 void                            e_bluez_element_event_add(int event_type, E_Bluez_Element *element);
00137 E_Bluez_Element_Dict_Entry *    e_bluez_element_array_dict_find_stringshared(const E_Bluez_Array *array, const char *key);
00138 void                            e_bluez_element_array_free(E_Bluez_Array *array, E_Bluez_Array *new __UNUSED__);
00139 
00140 Eina_Bool                       e_bluez_element_call_full(E_Bluez_Element *element, const char *method_name, E_DBus_Method_Return_Cb cb, Eina_Inlist **pending, E_DBus_Method_Return_Cb user_cb, const void *user_data);
00141 Eina_Bool                       e_bluez_element_call_with_path(E_Bluez_Element *element, const char *method_name, const char *string, E_DBus_Method_Return_Cb cb, Eina_Inlist **pending, E_DBus_Method_Return_Cb user_cb, const void *user_data);
00142 Eina_Bool                       e_bluez_element_call_with_string(E_Bluez_Element *element, const char *method_name, const char *string, E_DBus_Method_Return_Cb cb, Eina_Inlist **pending, E_DBus_Method_Return_Cb user_cb, const void *user_data);
00143 Eina_Bool                       e_bluez_element_call_with_path_and_string(E_Bluez_Element *element, const char *method_name, const char *path, const char *string, E_DBus_Method_Return_Cb cb, Eina_Inlist **pending, E_DBus_Method_Return_Cb user_cb, const void *user_data);