Replace ecore_hash by eina_hash.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 29 Dec 2008 09:03:24 +0000 (09:03 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 29 Dec 2008 09:03:24 +0000 (09:03 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/e_dbus@38340 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/nm.c
src/lib/hal/E_Hal.h
src/lib/hal/e_hal_device.c
src/lib/hal/e_hal_util.c
src/lib/nm/E_Nm.h
src/lib/nm/e_nm_util.c
src/lib/nm/e_nms_connection.c

index 65d9d29..0af4c11 100644 (file)
@@ -57,26 +57,20 @@ dump_variant(E_NM_Variant *var)
     }
 }
 
-static void
-dump_values(void *value, void *data)
+static Eina_Bool
+dump_values(const Eina_Hash *hash, const void *key, void *value, void *data)
 {
-    Ecore_Hash_Node *node;
-
-    node = value;
-    printf(" - name: %s - ", (char *)node->key);
-    dump_variant(node->value);
+    printf(" - name: %s - ", (char *)key);
+    dump_variant(value);
     printf("\n");
 }
  
-static void
-dump_settings(void *value, void *data)
+static Eina_Bool
+dump_settings(const Eina_Hash *hash, const void *key, void *value, void *fdata)
 {
-    Ecore_Hash_Node *node;
-
-    node = value;
-    printf("name: %s\n", (char *)node->key);
+    printf("name: %s\n", (char *)key);
     printf("values:\n");
-    ecore_hash_for_each_node(node->value, dump_values, NULL);
+    eina_hash_foreach(value, dump_values, NULL);
     printf("\n");
 }
 
@@ -85,7 +79,7 @@ cb_nms_connection_secrets(void *data, Ecore_Hash *secrets)
 {
     printf("Secrets:\n");
     if (secrets)
-        ecore_hash_for_each_node(secrets, dump_settings, NULL);
+        eina_hash_foreach(secrets, dump_settings, NULL);
     return 1;
 }
 
@@ -97,7 +91,7 @@ cb_nms_connection_settings(void *data, Ecore_Hash *settings)
     {
         if (ecore_hash_get(settings, "802-11-wireless-security"))
             e_nms_connection_secrets_get_secrets(data, "802-11-wireless-security", NULL, 0, cb_nms_connection_secrets, NULL);
-        ecore_hash_for_each_node(settings, dump_settings, NULL);
+        eina_hash_foreach(settings, dump_settings, NULL);
     }
     return 1;
 }
index 00dea4e..7fabb01 100644 (file)
@@ -83,7 +83,7 @@ struct E_Hal_Property
 
 struct E_Hal_Properties
 {
-  Ecore_Hash *properties;
+  Eina_Hash *properties;
 };
 
 typedef struct E_Hal_Properties E_Hal_Device_Get_All_Properties_Return;
index 480132b..b2447dc 100644 (file)
@@ -88,10 +88,7 @@ unmarshal_device_get_all_properties(DBusMessage *msg, DBusError *err)
     return NULL;
   }
 
-  ret->properties = ecore_hash_new(ecore_str_hash, ecore_str_compare);
-  ecore_hash_free_key_cb_set(ret->properties, ECORE_FREE_CB(eina_stringshare_del));
-  ecore_hash_free_value_cb_set(ret->properties, ECORE_FREE_CB(e_hal_property_free));
-
+  ret->properties = eina_hash_string_small_new(EINA_FREE_CB(e_hal_property_free));
 
   dbus_message_iter_init(msg, &iter);
   dbus_message_iter_recurse(&iter, &a_iter);
@@ -145,7 +142,7 @@ unmarshal_device_get_all_properties(DBusMessage *msg, DBusError *err)
         printf("Error: unexpected property type (%s): %c\n", name, dbus_message_iter_get_arg_type(&v_iter));
         break;
     }
-    ecore_hash_set(ret->properties, (void *)eina_stringshare_add(name), prop);
+    eina_hash_add(ret->properties, name, prop);
 
     dbus_message_iter_next(&a_iter);
   }
@@ -159,7 +156,7 @@ free_device_get_all_properties(void *data)
   E_Hal_Device_Get_All_Properties_Return *ret = data;
 
   if (!ret) return;
-  ecore_hash_destroy(ret->properties);
+  eina_hash_free(ret->properties);
   free(ret);
 }
 
index cf10126..8714292 100644 (file)
@@ -26,7 +26,7 @@ e_hal_property_string_get(E_Hal_Properties *properties, const char *key, int *er
   E_Hal_Property *prop;
   if (err) *err = 0;
   if (!properties->properties) return NULL;
-  prop = ecore_hash_get(properties->properties, key);
+  prop = eina_hash_find(properties->properties, key);
   if (prop) return strdup(prop->val.s);
 
   if (err) *err = 1;
@@ -39,7 +39,7 @@ e_hal_property_bool_get(E_Hal_Properties *properties, const char *key, int *err)
   E_Hal_Property *prop;
   if (err) *err = 0;
   if (!properties->properties) return 0;
-  prop = ecore_hash_get(properties->properties, key);
+  prop = eina_hash_find(properties->properties, key);
   if (prop) return prop->val.b;
   
   if (err) *err = 1;
@@ -52,7 +52,7 @@ e_hal_property_int_get(E_Hal_Properties *properties, const char *key, int *err)
   E_Hal_Property *prop;
   if (err) *err = 0;
   if (!properties->properties) return 0;
-  prop = ecore_hash_get(properties->properties, key);
+  prop = eina_hash_find(properties->properties, key);
   if (prop) return prop->val.i;
 
   if (err) *err = 1;
@@ -65,7 +65,7 @@ e_hal_property_uint64_get(E_Hal_Properties *properties, const char *key, int *er
   E_Hal_Property *prop;
   if (err) *err = 0;
   if (!properties->properties) return 0;
-  prop = ecore_hash_get(properties->properties, key);
+  prop = eina_hash_find(properties->properties, key);
   if (prop) return prop->val.u64;
 
   if (err) *err = 1;
@@ -78,7 +78,7 @@ e_hal_property_double_get(E_Hal_Properties *properties, const char *key, int *er
   E_Hal_Property *prop;
   if (err) *err = 0;
   if (!properties->properties) return 0;
-  prop = ecore_hash_get(properties->properties, key);
+  prop = eina_hash_find(properties->properties, key);
   if (prop) return prop->val.d;
 
   if (err) *err = 1;
@@ -91,7 +91,7 @@ e_hal_property_strlist_get(E_Hal_Properties *properties, const char *key, int *e
   E_Hal_Property *prop;
   if (err) *err = 0;
   if (!properties->properties) return NULL;
-  prop = ecore_hash_get(properties->properties, key);
+  prop = eina_hash_find(properties->properties, key);
   if (prop) return prop->val.strlist;
 
   if (err) *err = 1;
index 7f751dc..4cfaeda 100644 (file)
@@ -368,8 +368,9 @@ extern "C" {
 
    /* TODO: e_nms_connection_update */
    /* TODO: e_nms_connection_delete */
-   EAPI int  e_nms_connection_get_settings(E_NMS_Connection *conn, int (*cb_func)(void *data, Ecore_Hash *settings), void *data);
-   EAPI int  e_nms_connection_secrets_get_secrets(E_NMS_Connection *connection, const char *setting_name, Ecore_List *hints, int request_new, int (*cb_func)(void *data, Ecore_Hash *secrets), void *data);
+
+   EAPI int  e_nms_connection_get_settings(E_NMS_Connection *conn, int (*cb_func)(void *data, Eina_Hash *settings), void *data);
+   EAPI int  e_nms_connection_secrets_get_secrets(E_NMS_Connection *connection, const char *setting_name, Ecore_List *hints, int request_new, int (*cb_func)(void *data, Eina_Hash *secrets), void *data);
 
    EAPI void  e_nms_connection_callback_updated_set(E_NMS_Connection *connection, int (*cb_func)(E_NMS_Connection *conn, Ecore_Hash *settings));
    /* TODO: e_nms_connection_callback_removed_set */
index 569b8c3..401de34 100644 (file)
@@ -455,23 +455,21 @@ free_nm_object_path_list(void *data)
 Ecore_Hash *
 parse_settings(DBusMessage *msg)
 {
-  Ecore_Hash *settings;
+  Eina_Hash *settings;
   DBusMessageIter iter, a_iter;
 
   if (!dbus_message_has_signature(msg, "a{sa{sv}}")) return NULL;
 
   dbus_message_iter_init(msg, &iter);
 
-  settings = ecore_hash_new(ecore_str_hash, ecore_str_compare);
-  ecore_hash_free_key_cb_set(settings, free);
-  ecore_hash_free_value_cb_set(settings, ECORE_FREE_CB(ecore_hash_destroy));
+  settings = eina_hash_string_small_new(EINA_FREE_CB(eina_hash_free));
   dbus_message_iter_recurse(&iter, &a_iter);
   while (dbus_message_iter_get_arg_type(&a_iter) != DBUS_TYPE_INVALID)
   {
     DBusMessageIter  d_iter, a2_iter;
     E_NM_Variant   *prop;
     const char      *name;
-    Ecore_Hash      *value;
+    Eina_Hash      *value;
 
     dbus_message_iter_recurse(&a_iter, &d_iter);
     if (!check_arg_type(&d_iter, 's')) goto error;
@@ -481,10 +479,8 @@ parse_settings(DBusMessage *msg)
     if (!check_arg_type(&d_iter, 'a')) goto error;
     dbus_message_iter_recurse(&d_iter, &a2_iter);
 
-    value = ecore_hash_new(ecore_str_hash, ecore_str_compare);
-    ecore_hash_free_key_cb_set(value, free);
-    ecore_hash_free_value_cb_set(value, ECORE_FREE_CB(property_free));
-    ecore_hash_set(settings, strdup(name), value);
+    value = eina_hash_string_small_new(EINA_FREE_CB(property_free));
+    eina_hash_add(settings, name, value);
     while (dbus_message_iter_get_arg_type(&a2_iter) != DBUS_TYPE_INVALID)
     {
       dbus_message_iter_recurse(&a2_iter, &d_iter);
@@ -493,7 +489,7 @@ parse_settings(DBusMessage *msg)
       dbus_message_iter_next(&d_iter);
       if (!check_arg_type(&d_iter, 'v')) goto error;
       prop = property_variant(&d_iter, NULL, NULL);
-      if (prop) ecore_hash_set(value, strdup(name), prop);
+      if (prop) eina_hash_add(value, name, prop);
       dbus_message_iter_next(&a2_iter);
     }
 
@@ -502,7 +498,7 @@ parse_settings(DBusMessage *msg)
 
   return settings;
 error:
-  ecore_hash_destroy(settings);
+  eina_hash_free(settings);
   return NULL;
 }
 
index f25db2d..037afcd 100644 (file)
@@ -107,7 +107,7 @@ e_nms_connection_dump(E_NMS_Connection *conn)
 }
 
 EAPI int
-e_nms_connection_get_settings(E_NMS_Connection *connection, int (*cb_func)(void *data, Ecore_Hash *settings), void *data)
+e_nms_connection_get_settings(E_NMS_Connection *connection, int (*cb_func)(void *data, Eina_Hash *settings), void *data)
 {
   DBusMessage *msg;
   Reply_Data   *d;
@@ -128,7 +128,7 @@ e_nms_connection_get_settings(E_NMS_Connection *connection, int (*cb_func)(void
 }
 
 EAPI int
-e_nms_connection_secrets_get_secrets(E_NMS_Connection *connection, const char *setting_name, Ecore_List *hints, int request_new, int (*cb_func)(void *data, Ecore_Hash *secrets), void *data)
+e_nms_connection_secrets_get_secrets(E_NMS_Connection *connection, const char *setting_name, Ecore_List *hints, int request_new, int (*cb_func)(void *data, Eina_Hash *secrets), void *data)
 {
   DBusMessage      *msg;
   DBusMessageIter   iter, a_iter;