[PATCH 15/16] e_dbus/bluez: Add get_alias() function for DeviceFound
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 27 Feb 2010 05:28:01 +0000 (05:28 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 27 Feb 2010 05:28:01 +0000 (05:28 +0000)
By: Gustavo F. Padovan <padovan@profusion.mobi>

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/e_dbus@46567 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/bluez/E_Bluez.h
src/lib/bluez/e_bluez_adapter.c
src/lib/bluez/e_bluez_element.c
src/lib/bluez/e_bluez_private.h

index d5a981e..7fe927e 100644 (file)
@@ -94,6 +94,7 @@ extern "C" {
 
   /* Adapter Methods */
   EAPI void e_bluez_adapter_device_found_free(E_Bluez_Device_Found *device) EINA_ARG_NONNULL(1);
+  EAPI const char *e_bluez_adapter_device_found_get_alias(E_Bluez_Device_Found *device) EINA_ARG_NONNULL(1);
   EAPI 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) EINA_WARN_UNUSED_RESULT;
   EAPI 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) EINA_WARN_UNUSED_RESULT;
   EAPI bool e_bluez_adapter_address_get(E_Bluez_Element *element, const char **address) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
index 264376e..1cfcc72 100644 (file)
@@ -63,6 +63,23 @@ e_bluez_adapter_device_found_free(E_Bluez_Device_Found *device)
    e_bluez_element_array_free(device->array, NULL);
 }
 
+const char *
+e_bluez_adapter_device_found_get_alias(E_Bluez_Device_Found *device)
+{
+   E_Bluez_Element_Dict_Entry *entry;
+   const char *alias = eina_stringshare_add("Alias");
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, NULL);
+
+   entry = e_bluez_element_array_dict_find_stringshared(device->array,
+                                                       alias);
+
+   if (entry->type == DBUS_TYPE_STRING)
+      return entry->value.str;
+
+   return NULL;
+}
+
 /**
  * Register new agent for handling user requests.
  *
index 87cc1ac..05c56ce 100644 (file)
@@ -8,7 +8,6 @@ typedef struct _E_Bluez_Element_Pending E_Bluez_Element_Pending;
 typedef struct _E_Bluez_Element_Call_Data E_Bluez_Element_Call_Data;
 typedef struct _E_Bluez_Element_Property E_Bluez_Element_Property;
 typedef struct _E_Bluez_Element_Listener E_Bluez_Element_Listener;
-typedef struct _E_Bluez_Element_Dict_Entry E_Bluez_Element_Dict_Entry;
 
 struct _E_Bluez_Element_Pending
 {
@@ -44,21 +43,6 @@ struct _E_Bluez_Element_Property
    } value;
 };
 
-struct _E_Bluez_Element_Dict_Entry
-{
-   const char *name;
-   int type;
-   union {
-      bool boolean;
-      const char *str;
-      short i16;
-      unsigned short u16;
-      unsigned int u32;
-      unsigned char byte;
-      const char *path;
-   } value;
-};
-
 struct _E_Bluez_Element_Listener
 {
    EINA_INLIST;
@@ -342,8 +326,8 @@ _e_bluez_element_dict_entry_new(DBusMessageIter *itr)
    return entry;
 }
 
-static E_Bluez_Element_Dict_Entry *
-_e_bluez_element_array_dict_find_stringshared(const E_Bluez_Array *array, const char *key)
+E_Bluez_Element_Dict_Entry *
+e_bluez_element_array_dict_find_stringshared(const E_Bluez_Array *array, const char *key)
 {
    E_Bluez_Element_Dict_Entry *entry;
    Eina_Array_Iterator iterator;
@@ -1742,7 +1726,7 @@ e_bluez_element_property_dict_get_stringshared(const E_Bluez_Element *element, c
                 element->path, element, dict_name, t, t);
             return 0;
          }
-       entry = _e_bluez_element_array_dict_find_stringshared(array, key);
+       entry = e_bluez_element_array_dict_find_stringshared(array, key);
        if (!entry)
          {
             WRN("element %s (%p) has no dict property with name \"%s\" with "
index 6364d06..358e025 100644 (file)
@@ -50,6 +50,23 @@ extern const char *e_bluez_prop_devices;
 
 extern int _e_dbus_bluez_log_dom;
 
+typedef struct _E_Bluez_Element_Dict_Entry E_Bluez_Element_Dict_Entry;
+
+struct _E_Bluez_Element_Dict_Entry
+{
+   const char *name;
+   int type;
+   union {
+      bool boolean;
+      const char *str;
+      short i16;
+      unsigned short u16;
+      unsigned int u32;
+      unsigned char byte;
+      const char *path;
+   } value;
+};
+
 #ifndef EINA_LOG_DEFAULT_COLOR
 #define EINA_LOG_DEFAULT_COLOR EINA_COLOR_CYAN
 #endif
@@ -127,6 +144,7 @@ void e_bluez_element_unregister(E_Bluez_Element *element);
 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);
 E_Bluez_Array *e_bluez_element_iter_get_array(DBusMessageIter *itr, const char *key);
 void e_bluez_element_event_add(int event_type, E_Bluez_Element *element);
+E_Bluez_Element_Dict_Entry * e_bluez_element_array_dict_find_stringshared(const E_Bluez_Array *array, const char *key);
 void e_bluez_element_array_free(E_Bluez_Array *array, E_Bluez_Array *new __UNUSED__);
 
 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);