From 3546cbd0da226060bb226f7bab57c77ec8fd0498 Mon Sep 17 00:00:00 2001 From: englebass Date: Thu, 24 Sep 2009 18:32:50 +0000 Subject: [PATCH] Convert nm to eina git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/e_dbus@42682 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/bin/nm.c | 128 +++++++++++++----------------- src/lib/dbus/e_dbus_private.h | 2 +- src/lib/nm/E_Nm.h | 32 ++++---- src/lib/nm/e_nm.c | 60 ++++++-------- src/lib/nm/e_nm_access_point.c | 107 +++++++++++-------------- src/lib/nm/e_nm_active_connection.c | 32 ++++---- src/lib/nm/e_nm_device.c | 153 +++++++++++++++++------------------- src/lib/nm/e_nm_ip4_config.c | 82 +++++++++---------- src/lib/nm/e_nm_manager.c | 39 +++++---- src/lib/nm/e_nm_private.h | 14 ++-- src/lib/nm/e_nm_util.c | 61 +++++++------- src/lib/nm/e_nm_variant.c | 13 ++- src/lib/nm/e_nms.c | 106 +++++++++++-------------- src/lib/nm/e_nms_connection.c | 46 +++++------ 14 files changed, 407 insertions(+), 468 deletions(-) diff --git a/src/bin/nm.c b/src/bin/nm.c index 0daf9e0..0267ad4 100644 --- a/src/bin/nm.c +++ b/src/bin/nm.c @@ -1,5 +1,4 @@ #include -#include #include #include @@ -25,10 +24,10 @@ dump_variant(E_NM_Variant *var) { case 'a': { E_NM_Variant *subvar; + Eina_List *l; printf("a:"); - ecore_list_first_goto(var->a); - while ((subvar = ecore_list_next(var->a))) + EINA_LIST_FOREACH(var->a, l, subvar) { dump_variant(subvar); printf(";"); @@ -63,6 +62,8 @@ dump_values(const Eina_Hash *hash, const void *key, void *value, void *data) printf(" - name: %s - ", (char *)key); dump_variant(value); printf("\n"); + + return 1; } static Eina_Bool @@ -72,10 +73,12 @@ dump_settings(const Eina_Hash *hash, const void *key, void *value, void *fdata) printf("values:\n"); eina_hash_foreach(value, dump_values, NULL); printf("\n"); + + return 1; } static int -cb_nms_connection_secrets(void *data, Ecore_Hash *secrets) +cb_nms_connection_secrets(void *data, Eina_Hash *secrets) { printf("Secrets:\n"); if (secrets) @@ -84,32 +87,29 @@ cb_nms_connection_secrets(void *data, Ecore_Hash *secrets) } static int -cb_nms_connection_settings(void *data, Ecore_Hash *settings) +cb_nms_connection_settings(void *data, Eina_Hash *settings) { printf("Settings:\n"); if (settings) { - if (ecore_hash_get(settings, "802-11-wireless-security")) + if (eina_hash_find(settings, "802-11-wireless-security")) e_nms_connection_secrets_get_secrets(data, "802-11-wireless-security", NULL, 0, cb_nms_connection_secrets, NULL); eina_hash_foreach(settings, dump_settings, NULL); + eina_hash_free(settings); } return 1; } static int -cb_nms_connections(void *data, Ecore_List *list) +cb_nms_connections(void *data, Eina_List *list) { E_NMS_Connection *conn; + Eina_List *l; - if (list) + EINA_LIST_FOREACH(list, l, conn) { - ecore_list_first_goto(list); - while ((conn = ecore_list_next(list))) - { - e_nms_connection_dump(conn); - e_nms_connection_get_settings(conn, cb_nms_connection_settings, conn); - } - //ecore_list_destroy(list); + e_nms_connection_dump(conn); + e_nms_connection_get_settings(conn, cb_nms_connection_settings, conn); } //ecore_main_loop_quit(); //e_nms_list_connections(nms, cb_nms_connections, nms); @@ -140,9 +140,10 @@ static int cb_active_connection(void *data, E_NM_Active_Connection *conn) { const char *device; + Eina_List *l; + e_nm_deactivate_connection(nm, conn); - ecore_list_first_goto(conn->devices); - while ((device = ecore_list_next(conn->devices))) + EINA_LIST_FOREACH(conn->devices, l, device) e_nm_device_get(nm, device, cb_activate_connection, conn); /* e_nm_active_connection_dump(conn); @@ -160,43 +161,36 @@ cb_ip4_config(void *data, E_NM_IP4_Config *config) } static int -cb_access_points(void *data, Ecore_List *list) +cb_access_points(void *data, Eina_List *list) { E_NM_Access_Point *ap; + Eina_List *l; - if (list) + EINA_LIST_FREE(list, ap) { - ecore_list_first_goto(list); - while ((ap = ecore_list_next(list))) - { - e_nm_access_point_dump(ap); - } - ecore_list_destroy(list); + e_nm_access_point_dump(ap); + e_nm_access_point_free(ap); } return 1; } static int -cb_get_devices(void *data, Ecore_List *list) +cb_get_devices(void *data, Eina_List *list) { E_NM_Device *device; + Eina_List *l; - if (list) + EINA_LIST_FOREACH(list, l, device) { - ecore_list_first_goto(list); - while ((device = ecore_list_next(list))) + e_nm_device_dump(device); + if (device->device_type == E_NM_DEVICE_TYPE_WIRELESS) { - e_nm_device_dump(device); - if (device->device_type == E_NM_DEVICE_TYPE_WIRELESS) - { - /* - e_nm_device_wireless_get_access_points(device, cb_access_points, NULL); - e_nm_access_point_get(nm, device->wireless.active_access_point, cb_access_point, NULL); - e_nm_ip4_config_get(nm, device->ip4_config, cb_ip4_config, NULL); - */ - } + /* + e_nm_device_wireless_get_access_points(device, cb_access_points, NULL); + e_nm_access_point_get(nm, device->wireless.active_access_point, cb_access_point, NULL); + e_nm_ip4_config_get(nm, device->ip4_config, cb_ip4_config, NULL); + */ } - //ecore_list_destroy(list); } //ecore_main_loop_quit(); return 1; @@ -205,80 +199,70 @@ cb_get_devices(void *data, Ecore_List *list) static int cb_nms(void *data, E_NMS *reply) { - Ecore_Hash *settings, *values; + Eina_Hash *settings, *values; E_NM_Variant variant; const char ssid[] = { }; const char *bssids[] = { }; - 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)); /* connection */ - values = ecore_hash_new(ecore_str_hash, ecore_str_compare); - ecore_hash_free_key_cb_set(values, free); - ecore_hash_free_value_cb_set(values, ECORE_FREE_CB(e_nm_variant_free)); - ecore_hash_set(settings, strdup("connection"), values); + values = eina_hash_string_small_new(EINA_FREE_CB(e_nm_variant_free)); + eina_hash_add(settings, strdup("connection"), values); memset(&variant, 0, sizeof(E_NM_Variant)); variant.type = 't'; variant.t = 1228201388; - ecore_hash_set(values, strdup("timestamp"), memdup(&variant, sizeof(E_NM_Variant))); + eina_hash_add(values, strdup("timestamp"), memdup(&variant, sizeof(E_NM_Variant))); memset(&variant, 0, sizeof(E_NM_Variant)); variant.type = 's'; variant.s = strdup(""); - ecore_hash_set(values, strdup("id"), memdup(&variant, sizeof(E_NM_Variant))); + eina_hash_add(values, strdup("id"), memdup(&variant, sizeof(E_NM_Variant))); memset(&variant, 0, sizeof(E_NM_Variant)); variant.type = 's'; variant.s = strdup(""); - ecore_hash_set(values, strdup("uuid"), memdup(&variant, sizeof(E_NM_Variant))); + eina_hash_add(values, strdup("uuid"), memdup(&variant, sizeof(E_NM_Variant))); memset(&variant, 0, sizeof(E_NM_Variant)); variant.type = 's'; variant.s = strdup("802-11-wireless"); - ecore_hash_set(values, strdup("type"), memdup(&variant, sizeof(E_NM_Variant))); + eina_hash_add(values, strdup("type"), memdup(&variant, sizeof(E_NM_Variant))); memset(&variant, 0, sizeof(E_NM_Variant)); variant.type = 'b'; variant.b = 0; - ecore_hash_set(values, strdup("autoconnect"), memdup(&variant, sizeof(E_NM_Variant))); + eina_hash_add(values, strdup("autoconnect"), memdup(&variant, sizeof(E_NM_Variant))); /* 802-11-wireless */ - values = ecore_hash_new(ecore_str_hash, ecore_str_compare); - ecore_hash_free_key_cb_set(values, free); - ecore_hash_free_value_cb_set(values, ECORE_FREE_CB(e_nm_variant_free)); - ecore_hash_set(settings, strdup("802-11-wireless"), values); + values = eina_hash_string_small_new(EINA_FREE_CB(e_nm_variant_free)); + eina_hash_add(settings, strdup("802-11-wireless"), values); memset(&variant, 0, sizeof(E_NM_Variant)); variant.type = 's'; variant.s = strdup("mode"); - ecore_hash_set(values, strdup("infrastructure"), memdup(&variant, sizeof(E_NM_Variant))); - ecore_hash_set(values, strdup("ssid"), e_nm_variant_array_new('y', ssid, sizeof(ssid) / sizeof(ssid[0]))); - ecore_hash_set(values, strdup("seen-bssids"), e_nm_variant_array_new('s', bssids, sizeof(bssids) / sizeof(bssids[0]))); + eina_hash_add(values, strdup("infrastructure"), memdup(&variant, sizeof(E_NM_Variant))); + eina_hash_add(values, strdup("ssid"), e_nm_variant_array_new('y', ssid, sizeof(ssid) / sizeof(ssid[0]))); + eina_hash_add(values, strdup("seen-bssids"), e_nm_variant_array_new('s', bssids, sizeof(bssids) / sizeof(bssids[0]))); memset(&variant, 0, sizeof(E_NM_Variant)); variant.type = 's'; variant.s = strdup("802-11-wireless-security"); - ecore_hash_set(values, strdup("security"), memdup(&variant, sizeof(E_NM_Variant))); + eina_hash_add(values, strdup("security"), memdup(&variant, sizeof(E_NM_Variant))); /* ipv4 */ - values = ecore_hash_new(ecore_str_hash, ecore_str_compare); - ecore_hash_free_key_cb_set(values, free); - ecore_hash_free_value_cb_set(values, ECORE_FREE_CB(e_nm_variant_free)); - ecore_hash_set(settings, strdup("ipv4"), values); + values = eina_hash_string_small_new(EINA_FREE_CB(e_nm_variant_free)); + eina_hash_add(settings, strdup("ipv4"), values); memset(&variant, 0, sizeof(E_NM_Variant)); variant.type = 's'; variant.s = strdup("auto"); - ecore_hash_set(values, strdup("method"), memdup(&variant, sizeof(E_NM_Variant))); + eina_hash_add(values, strdup("method"), memdup(&variant, sizeof(E_NM_Variant))); /* 802-11-wireless-security */ - values = ecore_hash_new(ecore_str_hash, ecore_str_compare); - ecore_hash_free_key_cb_set(values, free); - ecore_hash_free_value_cb_set(values, ECORE_FREE_CB(e_nm_variant_free)); - ecore_hash_set(settings, strdup("802-11-wireless-security"), values); + values = eina_hash_string_small_new(EINA_FREE_CB(e_nm_variant_free)); + eina_hash_add(settings, strdup("802-11-wireless-security"), values); memset(&variant, 0, sizeof(E_NM_Variant)); variant.type = 's'; variant.s = strdup("none"); - ecore_hash_set(values, strdup("key-mgmt"), memdup(&variant, sizeof(E_NM_Variant))); + eina_hash_add(values, strdup("key-mgmt"), memdup(&variant, sizeof(E_NM_Variant))); memset(&variant, 0, sizeof(E_NM_Variant)); variant.type = 's'; variant.s = strdup("open"); - ecore_hash_set(values, strdup("auth-alg"), memdup(&variant, sizeof(E_NM_Variant))); + eina_hash_add(values, strdup("auth-alg"), memdup(&variant, sizeof(E_NM_Variant))); memset(&variant, 0, sizeof(E_NM_Variant)); variant.type = 's'; variant.s = strdup(""); - ecore_hash_set(values, strdup("wep-key0"), memdup(&variant, sizeof(E_NM_Variant))); + eina_hash_add(values, strdup("wep-key0"), memdup(&variant, sizeof(E_NM_Variant))); nms = reply; e_nms_dump(nms); diff --git a/src/lib/dbus/e_dbus_private.h b/src/lib/dbus/e_dbus_private.h index 18fcae9..67b0e0a 100644 --- a/src/lib/dbus/e_dbus_private.h +++ b/src/lib/dbus/e_dbus_private.h @@ -8,7 +8,7 @@ #ifndef E_DBUS_COLOR_DEFAULT #define E_DBUS_COLOR_DEFAULT EINA_COLOR_CYAN #endif -extern int _e_dbus_log_dom; +EAPI extern int _e_dbus_log_dom; #define DBG(...) EINA_LOG_DOM_DBG(_e_dbus_log_dom, __VA_ARGS__) #define INFO(...) EINA_LOG_DOM_INFO(_e_dbus_log_dom, __VA_ARGS__) #define WARN(...) EINA_LOG_DOM_WARN(_e_dbus_log_dom, __VA_ARGS__) diff --git a/src/lib/nm/E_Nm.h b/src/lib/nm/E_Nm.h index 4cfaeda..82e862a 100644 --- a/src/lib/nm/E_Nm.h +++ b/src/lib/nm/E_Nm.h @@ -2,7 +2,7 @@ #define E_NM_H #include -#include +#include /* * TODO: @@ -170,7 +170,7 @@ struct E_NM { int wireless_enabled; /* writeable*/ int wireless_hardware_enabled; - Ecore_List *active_connections; + Eina_List *active_connections; E_NM_State state; }; @@ -181,7 +181,7 @@ struct E_NM_Access_Point E_NM_802_11_Ap_Flags flags; E_NM_802_11_Ap_Sec wpa_flags; E_NM_802_11_Ap_Sec rsn_flags; - Ecore_List *ssid; /* unsigned char */ + Eina_List *ssid; /* unsigned char */ unsigned int frequency; char *hw_address; E_NM_802_11_Mode mode; @@ -225,10 +225,10 @@ struct E_NM_Device typedef struct E_NM_IP4_Config E_NM_IP4_Config; struct E_NM_IP4_Config { - Ecore_List *addresses; /* list unsigned int */ - Ecore_List *nameservers;/* unsigned int */ - Ecore_List *domains; /* char* */ - Ecore_List *routes; /* list unsigned int */ + Eina_List *addresses; /* list unsigned int */ + Eina_List *nameservers;/* unsigned int */ + Eina_List *domains; /* char* */ + Eina_List *routes; /* list unsigned int */ }; /* TODO typedef struct E_NM_DHCP4_Config E_NM_DHCP4_Config; */ @@ -244,7 +244,7 @@ typedef struct E_NMS E_NMS; struct E_NMS { const char *service_name; - Ecore_List *unmanaged_devices; /* object_path */ + Eina_List *unmanaged_devices; /* object_path */ char *hostname; }; @@ -262,7 +262,7 @@ struct E_NM_Active_Connection char *service_name; char *connection; /* object_path */ char *specific_object; /* object_path */ - Ecore_List *devices; /* object_path */ + Eina_List *devices; /* object_path */ E_NM_Active_Connection_State state; int def; /* default */ }; @@ -280,7 +280,7 @@ struct E_NM_Variant char *s; unsigned long long t; int b; - Ecore_List *a; + Eina_List *a; }; char type; }; @@ -296,7 +296,7 @@ extern "C" { EAPI int e_nm_wireless_enabled_set(E_NM *nm, int enabled); - EAPI int e_nm_get_devices(E_NM *nm, int (*cb_func)(void *data, Ecore_List *list), void *data); + EAPI int e_nm_get_devices(E_NM *nm, int (*cb_func)(void *data, Eina_List *list), void *data); /* TODO: Add return value cb */ EAPI int e_nm_activate_connection(E_NM *nm, const char *service_name, const char *connection, E_NM_Device *device, const char *specific_object); EAPI int e_nm_deactivate_connection(E_NM *nm, E_NM_Active_Connection *connection); @@ -327,7 +327,7 @@ extern "C" { EAPI void e_nm_device_free(E_NM_Device *device); EAPI void e_nm_device_dump(E_NM_Device *device); - EAPI int e_nm_device_wireless_get_access_points(E_NM_Device *device, int (*cb_func)(void *data, Ecore_List *access_points), void *data); + EAPI int e_nm_device_wireless_get_access_points(E_NM_Device *device, int (*cb_func)(void *data, Eina_List *access_points), void *data); EAPI void e_nm_device_data_set(E_NM_Device *device, void *data); EAPI void *e_nm_device_data_get(E_NM_Device *device); @@ -350,14 +350,14 @@ extern "C" { EAPI void e_nms_free(E_NMS *nms); EAPI void e_nms_dump(E_NMS *nms); EAPI int e_nms_list_connections(E_NMS *nms, - int (*cb_func)(void *data, Ecore_List *list), + int (*cb_func)(void *data, Eina_List *list), void *data); EAPI void e_nms_callback_new_connection_set(E_NMS *nms, int (*cb_func)(E_NMS *nms, const char *service_name, const char *connection)); /* org.freedesktop.NetworkManagerSettings.System */ EAPI int e_nms_system_save_hostname(E_NMS *nms, const char *hostname); - EAPI int e_nms_system_add_connection(E_NMS *nms, Ecore_Hash *settings); + EAPI int e_nms_system_add_connection(E_NMS *nms, Eina_Hash *settings); EAPI void e_nms_system_callback_properties_changed_set(E_NMS *nms, int (*cb_func)(E_NMS *nms)); @@ -370,9 +370,9 @@ extern "C" { /* TODO: e_nms_connection_delete */ 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 int e_nms_connection_secrets_get_secrets(E_NMS_Connection *connection, const char *setting_name, Eina_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)); + EAPI void e_nms_connection_callback_updated_set(E_NMS_Connection *connection, int (*cb_func)(E_NMS_Connection *conn, Eina_Hash *settings)); /* TODO: e_nms_connection_callback_removed_set */ /* org.freedesktop.NetworkManager.Connection.Active api */ diff --git a/src/lib/nm/e_nm.c b/src/lib/nm/e_nm.c index 147e949..d999c4d 100644 --- a/src/lib/nm/e_nm.c +++ b/src/lib/nm/e_nm.c @@ -24,7 +24,7 @@ cb_state_changed(void *data, DBusMessage *msg) dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &state, DBUS_TYPE_INVALID); if (dbus_error_is_set(&err)) { - E_DBUS_LOG_ERR("%s - %s", err.name, err.message); + ERR("%s - %s", err.name, err.message); return; } @@ -59,7 +59,7 @@ cb_device_added(void *data, DBusMessage *msg) dbus_message_get_args(msg, &err, DBUS_TYPE_OBJECT_PATH, &device, DBUS_TYPE_INVALID); if (dbus_error_is_set(&err)) { - E_DBUS_LOG_ERR("%s - %s", err.name, err.message); + ERR("%s - %s", err.name, err.message); return; } @@ -80,7 +80,7 @@ cb_device_removed(void *data, DBusMessage *msg) dbus_message_get_args(msg, &err, DBUS_TYPE_OBJECT_PATH, &device, DBUS_TYPE_INVALID); if (dbus_error_is_set(&err)) { - E_DBUS_LOG_ERR("%s - %s", err.name, err.message); + ERR("%s - %s", err.name, err.message); return; } @@ -109,11 +109,11 @@ e_nm_get(int (*cb_func)(void *data, E_NM *nm), void *data) nmi->conn = e_dbus_bus_get(DBUS_BUS_SYSTEM); if (!nmi->conn) goto error; - nmi->handlers = ecore_list_new(); - ecore_list_append(nmi->handlers, e_nm_signal_handler_add(nmi->conn, "StateChanged", cb_state_changed, nmi)); - ecore_list_append(nmi->handlers, e_nm_signal_handler_add(nmi->conn, "PropertiesChanged", cb_properties_changed, nmi)); - ecore_list_append(nmi->handlers, e_nm_signal_handler_add(nmi->conn, "DeviceAdded", cb_device_added, nmi)); - ecore_list_append(nmi->handlers, e_nm_signal_handler_add(nmi->conn, "DeviceRemoved", cb_device_removed, nmi)); + nmi->handlers = NULL; + nmi->handlers = eina_list_append(nmi->handlers, e_nm_signal_handler_add(nmi->conn, "StateChanged", cb_state_changed, nmi)); + nmi->handlers = eina_list_append(nmi->handlers, e_nm_signal_handler_add(nmi->conn, "PropertiesChanged", cb_properties_changed, nmi)); + nmi->handlers = eina_list_append(nmi->handlers, e_nm_signal_handler_add(nmi->conn, "DeviceAdded", cb_device_added, nmi)); + nmi->handlers = eina_list_append(nmi->handlers, e_nm_signal_handler_add(nmi->conn, "DeviceRemoved", cb_device_removed, nmi)); return property_get(nmi->conn, d); @@ -127,18 +127,14 @@ EAPI void e_nm_free(E_NM *nm) { E_NM_Internal *nmi; + void *data; if (!nm) return; nmi = (E_NM_Internal *)nm; - if (nmi->nm.active_connections) ecore_list_destroy(nmi->nm.active_connections); - if (nmi->handlers) - { - E_DBus_Signal_Handler *sh; - - while ((sh = ecore_list_first_remove(nmi->handlers))) - e_dbus_signal_handler_del(nmi->conn, sh); - ecore_list_destroy(nmi->handlers); - } + EINA_LIST_FREE(nmi->nm.active_connections, data) + free(data); + EINA_LIST_FREE(nmi->handlers, data) + e_dbus_signal_handler_del(nmi->conn, data); e_dbus_connection_close(nmi->conn); free(nmi); } @@ -147,38 +143,34 @@ EAPI void e_nm_dump(E_NM *nm) { const char *conn; + Eina_List *l; if (!nm) return; - INFO("E_NM:"); - INFO("wireless_enabled : %d", nm->wireless_enabled); - INFO("wireless_hardware_enabled: %d", nm->wireless_hardware_enabled); - INFO("active_connections :"); - if (nm->active_connections) - { - ecore_list_first_goto(nm->active_connections); - while ((conn = ecore_list_next(nm->active_connections))) - INFO(" - %s", conn); - } - INFO("state : "); + printf("E_NM:\n"); + printf("wireless_enabled : %d\n", nm->wireless_enabled); + printf("wireless_hardware_enabled: %d\n", nm->wireless_hardware_enabled); + printf("active_connections :\n"); + EINA_LIST_FOREACH(nm->active_connections, l, conn) + printf(" - %s\n", conn); + printf("state : "); switch (nm->state) { case E_NM_STATE_UNKNOWN: - INFO("E_NM_STATE_UNKNOWN"); + printf("E_NM_STATE_UNKNOWN\n"); break; case E_NM_STATE_ASLEEP: - INFO("E_NM_STATE_ASLEEP"); + printf("E_NM_STATE_ASLEEP\n"); break; case E_NM_STATE_CONNECTING: - INFO("E_NM_STATE_CONNECTING"); + printf("E_NM_STATE_CONNECTING\n"); break; case E_NM_STATE_CONNECTED: - INFO("E_NM_STATE_CONNECTED"); + printf("E_NM_STATE_CONNECTED\n"); break; case E_NM_STATE_DISCONNECTED: - INFO("E_NM_STATE_DISCONNECTED"); + printf("E_NM_STATE_DISCONNECTED\n"); break; } - INFO(""); } EAPI void diff --git a/src/lib/nm/e_nm_access_point.c b/src/lib/nm/e_nm_access_point.c index 87e4b0c..035256c 100644 --- a/src/lib/nm/e_nm_access_point.c +++ b/src/lib/nm/e_nm_access_point.c @@ -54,8 +54,7 @@ e_nm_access_point_get(E_NM *nm, const char *access_point, d->object = strdup(access_point); d->interface = E_NM_INTERFACE_ACCESSPOINT; - ap->handlers = ecore_list_new(); - ecore_list_append(ap->handlers, e_nm_access_point_signal_handler_add(nmi->conn, access_point, "PropertiesChanged", cb_properties_changed, ap)); + ap->handlers = eina_list_append(ap->handlers, e_nm_access_point_signal_handler_add(nmi->conn, access_point, "PropertiesChanged", cb_properties_changed, ap)); return property_get(nmi->conn, d); } @@ -64,112 +63,100 @@ EAPI void e_nm_access_point_free(E_NM_Access_Point *access_point) { E_NM_Access_Point_Internal *ap; + void *data; if (!access_point) return; ap = (E_NM_Access_Point_Internal *)access_point; if (ap->ap.path) free(ap->ap.path); - if (ap->ap.ssid) ecore_list_destroy(ap->ap.ssid); + EINA_LIST_FREE(ap->ap.ssid, data) + free(data); if (ap->ap.hw_address) free(ap->ap.hw_address); - if (ap->handlers) - { - E_DBus_Signal_Handler *sh; - - while ((sh = ecore_list_first_remove(ap->handlers))) - e_dbus_signal_handler_del(ap->nmi->conn, sh); - ecore_list_destroy(ap->handlers); - } + EINA_LIST_FREE(ap->handlers, data) + e_dbus_signal_handler_del(ap->nmi->conn, data); free(ap); } EAPI void e_nm_access_point_dump(E_NM_Access_Point *ap) { + Eina_List *l; char buffer[1024]; - unsigned char *c; + char *c; if (!ap) return; - E_DBUS_LOG_INFO("E_NM_Access_Point:"); - E_DBUS_LOG_INFO("flags :"); + INFO("E_NM_Access_Point:"); + INFO("flags :"); if (ap->flags & E_NM_802_11_AP_FLAGS_PRIVACY) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_FLAGS_PRIVACY"); + INFO(" E_NM_802_11_AP_FLAGS_PRIVACY"); if (ap->flags == E_NM_802_11_AP_FLAGS_NONE) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_FLAGS_NONE"); - E_DBUS_LOG_INFO(""); - E_DBUS_LOG_INFO("wpa_flags :"); + INFO(" E_NM_802_11_AP_FLAGS_NONE"); + INFO("wpa_flags :"); if (ap->wpa_flags & E_NM_802_11_AP_SEC_PAIR_WEP40) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_PAIR_WEP40"); + INFO(" E_NM_802_11_AP_SEC_PAIR_WEP40"); if (ap->wpa_flags & E_NM_802_11_AP_SEC_PAIR_WEP104) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_PAIR_WEP104"); + INFO(" E_NM_802_11_AP_SEC_PAIR_WEP104"); if (ap->wpa_flags & E_NM_802_11_AP_SEC_PAIR_TKIP) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_PAIR_TKIP"); + INFO(" E_NM_802_11_AP_SEC_PAIR_TKIP"); if (ap->wpa_flags & E_NM_802_11_AP_SEC_PAIR_CCMP) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_PAIR_CCMP"); + INFO(" E_NM_802_11_AP_SEC_PAIR_CCMP"); if (ap->wpa_flags & E_NM_802_11_AP_SEC_GROUP_WEP40) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_GROUP_WEP40"); + INFO(" E_NM_802_11_AP_SEC_GROUP_WEP40"); if (ap->wpa_flags & E_NM_802_11_AP_SEC_GROUP_WEP104) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_GROUP_WEP104"); + INFO(" E_NM_802_11_AP_SEC_GROUP_WEP104"); if (ap->wpa_flags & E_NM_802_11_AP_SEC_GROUP_TKIP) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_GROUP_TKIP"); + INFO(" E_NM_802_11_AP_SEC_GROUP_TKIP"); if (ap->wpa_flags & E_NM_802_11_AP_SEC_GROUP_CCMP) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_GROUP_CCMP"); + INFO(" E_NM_802_11_AP_SEC_GROUP_CCMP"); if (ap->wpa_flags & E_NM_802_11_AP_SEC_KEY_MGMT_PSK) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_KEY_MGMT_PSK"); + INFO(" E_NM_802_11_AP_SEC_KEY_MGMT_PSK"); if (ap->wpa_flags & E_NM_802_11_AP_SEC_KEY_MGMT_802_1X) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_KEY_MGMT_802_1X"); + INFO(" E_NM_802_11_AP_SEC_KEY_MGMT_802_1X"); if (ap->wpa_flags == E_NM_802_11_AP_SEC_NONE) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_NONE"); - E_DBUS_LOG_INFO(""); - E_DBUS_LOG_INFO("rsn_flags :"); + INFO(" E_NM_802_11_AP_SEC_NONE"); + INFO("rsn_flags :"); if (ap->rsn_flags & E_NM_802_11_AP_SEC_PAIR_WEP40) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_PAIR_WEP40"); + INFO(" E_NM_802_11_AP_SEC_PAIR_WEP40"); if (ap->rsn_flags & E_NM_802_11_AP_SEC_PAIR_WEP104) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_PAIR_WEP104"); + INFO(" E_NM_802_11_AP_SEC_PAIR_WEP104"); if (ap->rsn_flags & E_NM_802_11_AP_SEC_PAIR_TKIP) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_PAIR_TKIP"); + INFO(" E_NM_802_11_AP_SEC_PAIR_TKIP"); if (ap->rsn_flags & E_NM_802_11_AP_SEC_PAIR_CCMP) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_PAIR_CCMP"); + INFO(" E_NM_802_11_AP_SEC_PAIR_CCMP"); if (ap->rsn_flags & E_NM_802_11_AP_SEC_GROUP_WEP40) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_GROUP_WEP40"); + INFO(" E_NM_802_11_AP_SEC_GROUP_WEP40"); if (ap->rsn_flags & E_NM_802_11_AP_SEC_GROUP_WEP104) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_GROUP_WEP104"); + INFO(" E_NM_802_11_AP_SEC_GROUP_WEP104"); if (ap->rsn_flags & E_NM_802_11_AP_SEC_GROUP_TKIP) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_GROUP_TKIP"); + INFO(" E_NM_802_11_AP_SEC_GROUP_TKIP"); if (ap->rsn_flags & E_NM_802_11_AP_SEC_GROUP_CCMP) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_GROUP_CCMP"); + INFO(" E_NM_802_11_AP_SEC_GROUP_CCMP"); if (ap->rsn_flags & E_NM_802_11_AP_SEC_KEY_MGMT_PSK) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_KEY_MGMT_PSK"); + INFO(" E_NM_802_11_AP_SEC_KEY_MGMT_PSK"); if (ap->rsn_flags & E_NM_802_11_AP_SEC_KEY_MGMT_802_1X) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_KEY_MGMT_802_1X"); + INFO(" E_NM_802_11_AP_SEC_KEY_MGMT_802_1X"); if (ap->rsn_flags == E_NM_802_11_AP_SEC_NONE) - E_DBUS_LOG_INFO(" E_NM_802_11_AP_SEC_NONE"); - E_DBUS_LOG_INFO(""); + INFO(" E_NM_802_11_AP_SEC_NONE"); strcpy(buffer, "ssid : "); - if (ap->ssid) - { - - ecore_list_first_goto(ap->ssid); - while ((c = ecore_list_next(ap->ssid))) - snprintf("%s%c", buffer, *c); - } - E_DBUS_LOG_INFO("%s", buffer); - E_DBUS_LOG_INFO("frequency : %u", ap->frequency); - E_DBUS_LOG_INFO("hw_address : %s", ap->hw_address); - E_DBUS_LOG_INFO("mode : "); + EINA_LIST_FOREACH(ap->ssid, l, c) + strcat(buffer, c); + INFO("%s", buffer); + INFO("frequency : %u", ap->frequency); + INFO("hw_address : %s", ap->hw_address); + INFO("mode : "); switch (ap->mode) { case E_NM_802_11_MODE_UNKNOWN: - E_DBUS_LOG_INFO("E_NM_802_11_MODE_UNKNOWN"); + INFO("E_NM_802_11_MODE_UNKNOWN"); break; case E_NM_802_11_MODE_ADHOC: - E_DBUS_LOG_INFO("E_NM_802_11_MODE_ADHOC"); + INFO("E_NM_802_11_MODE_ADHOC"); break; case E_NM_802_11_MODE_INFRA: - E_DBUS_LOG_INFO("E_NM_802_11_MODE_INFRA"); + INFO("E_NM_802_11_MODE_INFRA"); break; } - E_DBUS_LOG_INFO("max_bitrate: %u", ap->max_bitrate); - E_DBUS_LOG_INFO("strength : %u", ap->strength); - E_DBUS_LOG_INFO(""); + INFO("max_bitrate: %u", ap->max_bitrate); + INFO("strength : %u", ap->strength); } EAPI void diff --git a/src/lib/nm/e_nm_active_connection.c b/src/lib/nm/e_nm_active_connection.c index b84e413..481d340 100644 --- a/src/lib/nm/e_nm_active_connection.c +++ b/src/lib/nm/e_nm_active_connection.c @@ -43,43 +43,45 @@ e_nm_active_connection_get(E_NM *nm, const char *connection, EAPI void e_nm_active_connection_free(E_NM_Active_Connection *conn) { + void *data; + if (!conn) return; if (conn->path) free(conn->path); if (conn->service_name) free(conn->service_name); if (conn->connection) free(conn->connection); if (conn->specific_object) free(conn->specific_object); - if (conn->devices) ecore_list_destroy(conn->devices); + EINA_LIST_FREE(conn->devices, data) + free(data); free(conn); } EAPI void e_nm_active_connection_dump(E_NM_Active_Connection *conn) { + Eina_List *l; const char *device; if (!conn) return; - E_DBUS_LOG_INFO("E_NM_Active_Connection:"); - E_DBUS_LOG_INFO("service_name : %s", conn->service_name); - E_DBUS_LOG_INFO("connection : %s", conn->connection); - E_DBUS_LOG_INFO("specific_object: %s", conn->specific_object); - E_DBUS_LOG_INFO("devices :"); - ecore_list_first_goto(conn->devices); - while ((device = ecore_list_next(conn->devices))) - E_DBUS_LOG_INFO(" - %s", device); - E_DBUS_LOG_INFO("state : "); + printf("E_NM_Active_Connection:\n"); + printf("service_name : %s\n", conn->service_name); + printf("connection : %s\n", conn->connection); + printf("specific_object: %s\n", conn->specific_object); + printf("devices :\n"); + EINA_LIST_FOREACH(conn->devices, l, device) + printf(" - %s\n", device); + printf("state : "); switch (conn->state) { case E_NM_ACTIVE_CONNECTION_STATE_UNKNOWN: - E_DBUS_LOG_INFO("E_NM_ACTIVE_CONNECTION_STATE_UNKNOWN"); + printf("E_NM_ACTIVE_CONNECTION_STATE_UNKNOWN\n"); break; case E_NM_ACTIVE_CONNECTION_STATE_ACTIVATING: - E_DBUS_LOG_INFO("E_NM_ACTIVE_CONNECTION_STATE_ACTIVATING"); + printf("E_NM_ACTIVE_CONNECTION_STATE_ACTIVATING\n"); break; case E_NM_ACTIVE_CONNECTION_STATE_ACTIVATED: - E_DBUS_LOG_INFO("E_NM_ACTIVE_CONNECTION_STATE_ACTIVATED"); + printf("E_NM_ACTIVE_CONNECTION_STATE_ACTIVATED\n"); break; } - E_DBUS_LOG_INFO("default : %d", conn->def); - E_DBUS_LOG_INFO(""); + printf("default : %d\n", conn->def); } diff --git a/src/lib/nm/e_nm_device.c b/src/lib/nm/e_nm_device.c index e834c29..f84a939 100644 --- a/src/lib/nm/e_nm_device.c +++ b/src/lib/nm/e_nm_device.c @@ -57,7 +57,7 @@ cb_state_changed(void *data, DBusMessage *msg) DBUS_TYPE_INVALID); if (dbus_error_is_set(&err)) { - E_DBUS_LOG_ERR("%s - %s", err.name, err.message); + ERR("%s - %s", err.name, err.message); return; } @@ -107,7 +107,7 @@ cb_wireless_access_point_added(void *data, DBusMessage *msg) DBUS_TYPE_INVALID); if (dbus_error_is_set(&err)) { - E_DBUS_LOG_ERR("%s - %s", err.name, err.message); + ERR("%s - %s", err.name, err.message); return; } @@ -131,7 +131,7 @@ cb_wireless_access_point_removed(void *data, DBusMessage *msg) DBUS_TYPE_INVALID); if (dbus_error_is_set(&err)) { - E_DBUS_LOG_ERR("%s - %s", err.name, err.message); + ERR("%s - %s", err.name, err.message); return; } @@ -167,15 +167,15 @@ property_device_type(Property_Data *data, DBusMessageIter *iter) case E_NM_DEVICE_TYPE_WIRED: data->property = device_wired_properties; data->interface = E_NM_INTERFACE_DEVICE_WIRED; - ecore_list_append(dev->handlers, e_nm_device_wired_signal_handler_add(data->nmi->conn, dev->dev.udi, "PropertiesChanged", cb_wired_properties_changed, dev)); + dev->handlers = eina_list_append(dev->handlers, e_nm_device_wired_signal_handler_add(data->nmi->conn, dev->dev.udi, "PropertiesChanged", cb_wired_properties_changed, dev)); property_get(data->nmi->conn, data); break; case E_NM_DEVICE_TYPE_WIRELESS: data->property = device_wireless_properties; data->interface = E_NM_INTERFACE_DEVICE_WIRELESS; - ecore_list_append(dev->handlers, e_nm_device_wireless_signal_handler_add(data->nmi->conn, dev->dev.udi, "PropertiesChanged", cb_wireless_properties_changed, dev)); - ecore_list_append(dev->handlers, e_nm_device_wireless_signal_handler_add(data->nmi->conn, dev->dev.udi, "AccessPointAdded", cb_wireless_access_point_added, dev)); - ecore_list_append(dev->handlers, e_nm_device_wireless_signal_handler_add(data->nmi->conn, dev->dev.udi, "AccessPointRemoved", cb_wireless_access_point_removed, dev)); + dev->handlers = eina_list_append(dev->handlers, e_nm_device_wireless_signal_handler_add(data->nmi->conn, dev->dev.udi, "PropertiesChanged", cb_wireless_properties_changed, dev)); + dev->handlers = eina_list_append(dev->handlers, e_nm_device_wireless_signal_handler_add(data->nmi->conn, dev->dev.udi, "AccessPointAdded", cb_wireless_access_point_added, dev)); + dev->handlers = eina_list_append(dev->handlers, e_nm_device_wireless_signal_handler_add(data->nmi->conn, dev->dev.udi, "AccessPointRemoved", cb_wireless_access_point_removed, dev)); property_get(data->nmi->conn, data); break; default: @@ -192,16 +192,14 @@ error: } static void -check_done(Reply_Data *d, Ecore_List *list) +check_done(Reply_Data *d, Eina_List *list) { - ecore_list_first_goto(list); - if (ecore_list_empty_is(list)) + if (!list) { d->cb_func(d->data, NULL); - ecore_list_destroy(list); free(d); } - else if (ecore_list_current(list) != (void *)-1) + else if (eina_list_data_get(list) != (void *)-1) { d->cb_func(d->data, list); free(d); @@ -212,15 +210,16 @@ static int cb_access_point(void *data, E_NM_Access_Point *ap) { Reply_Data *d; - Ecore_List *list; + Eina_List *list; d = data; list = d->reply; if (ap) - ecore_list_append(list, ap); - ecore_list_first_remove(list); + list = eina_list_append(list, ap); + list = eina_list_remove_list(list, list); check_done(d, list); + d->reply = list; return 1; } @@ -229,27 +228,26 @@ cb_access_points(void *data, void *reply, DBusError *err) { Reply_Data *d; E_NM_Device_Internal *dev; - Ecore_List *access_points; - Ecore_List *list; + Eina_List *access_points; + Eina_List *list = NULL; + Eina_List *l; const char *ap; d = data; dev = d->object; if (dbus_error_is_set(err)) { - E_DBUS_LOG_ERR("%s - %s", err->name, err->message); + ERR("%s - %s", err->name, err->message); d->cb_func(d->data, NULL); free(d); return; } access_points = reply; - ecore_list_first_goto(access_points); - list = ecore_list_new(); - ecore_list_free_cb_set(list, ECORE_FREE_CB(e_nm_access_point_free)); - d->reply = list; - while ((ap = ecore_list_next(access_points))) + //TODO: ecore_list_free_cb_set(list, ECORE_FREE_CB(e_nm_access_point_free)); + EINA_LIST_FOREACH(access_points, l, ap) { - ecore_list_prepend(list, (void *)-1); + list = eina_list_prepend(list, (void *)-1); + d->reply = list; e_nm_access_point_get(&(dev->nmi->nm), ap, cb_access_point, d); } } @@ -276,9 +274,8 @@ e_nm_device_get(E_NM *nm, const char *device, d->object = strdup(device); d->interface = E_NM_INTERFACE_DEVICE; - dev->handlers = ecore_list_new(); - ecore_list_append(dev->handlers, e_nm_device_signal_handler_add(nmi->conn, device, "StateChanged", cb_state_changed, dev)); - ecore_list_append(dev->handlers, e_nm_device_signal_handler_add(nmi->conn, device, "PropertiesChanged", cb_properties_changed, dev)); + dev->handlers = eina_list_append(dev->handlers, e_nm_device_signal_handler_add(nmi->conn, device, "StateChanged", cb_state_changed, dev)); + dev->handlers = eina_list_append(dev->handlers, e_nm_device_signal_handler_add(nmi->conn, device, "PropertiesChanged", cb_properties_changed, dev)); return property_get(nmi->conn, d); } @@ -287,6 +284,7 @@ EAPI void e_nm_device_free(E_NM_Device *device) { E_NM_Device_Internal *dev; + void *data; if (!device) return; dev = (E_NM_Device_Internal *)device; @@ -305,14 +303,8 @@ e_nm_device_free(E_NM_Device *device) if (dev->dev.wireless.active_access_point) free(dev->dev.wireless.active_access_point); break; } - if (dev->handlers) - { - E_DBus_Signal_Handler *sh; - - while ((sh = ecore_list_first_remove(dev->handlers))) - e_dbus_signal_handler_del(dev->nmi->conn, sh); - ecore_list_destroy(dev->handlers); - } + EINA_LIST_FREE(dev->handlers, data) + e_dbus_signal_handler_del(dev->nmi->conn, data); free(dev); } @@ -320,104 +312,103 @@ EAPI void e_nm_device_dump(E_NM_Device *dev) { if (!dev) return; - E_DBUS_LOG_INFO("E_NM_Device:"); - E_DBUS_LOG_INFO("udi : %s", dev->udi); - E_DBUS_LOG_INFO("interface : %s", dev->interface); - E_DBUS_LOG_INFO("driver : %s", dev->driver); - E_DBUS_LOG_INFO("capabilities :"); + printf("E_NM_Device:\n"); + printf("udi : %s\n", dev->udi); + printf("interface : %s\n", dev->interface); + printf("driver : %s\n", dev->driver); + printf("capabilities : "); if (dev->capabilities & E_NM_DEVICE_CAP_NM_SUPPORTED) - E_DBUS_LOG_INFO(" E_NM_DEVICE_CAP_NM_SUPPORTED"); + printf(" E_NM_DEVICE_CAP_NM_SUPPORTED"); if (dev->capabilities & E_NM_DEVICE_CAP_CARRIER_DETECT) - E_DBUS_LOG_INFO(" E_NM_DEVICE_CAP_CARRIER_DETECT"); + printf(" E_NM_DEVICE_CAP_CARRIER_DETECT"); if (dev->capabilities == E_NM_DEVICE_CAP_NONE) - E_DBUS_LOG_INFO(" E_NM_DEVICE_CAP_NONE"); - E_DBUS_LOG_INFO(""); - E_DBUS_LOG_INFO("ip4_address : %s", ip4_address2str(dev->ip4_address)); - E_DBUS_LOG_INFO("state : "); + printf(" E_NM_DEVICE_CAP_NONE"); + printf("\n"); + printf("ip4_address : %s\n", ip4_address2str(dev->ip4_address)); + printf("state : "); switch (dev->state) { case E_NM_DEVICE_STATE_UNKNOWN: - E_DBUS_LOG_INFO("E_NM_DEVICE_STATE_UNKNOWN"); + printf("E_NM_DEVICE_STATE_UNKNOWN\n"); break; case E_NM_DEVICE_STATE_UNMANAGED: - E_DBUS_LOG_INFO("E_NM_DEVICE_STATE_UNMANAGED"); + printf("E_NM_DEVICE_STATE_UNMANAGED\n"); break; case E_NM_DEVICE_STATE_UNAVAILABLE: - E_DBUS_LOG_INFO("E_NM_DEVICE_STATE_UNAVAILABLE"); + printf("E_NM_DEVICE_STATE_UNAVAILABLE\n"); break; case E_NM_DEVICE_STATE_DISCONNECTED: - E_DBUS_LOG_INFO("E_NM_DEVICE_STATE_DISCONNECTED"); + printf("E_NM_DEVICE_STATE_DISCONNECTED\n"); break; case E_NM_DEVICE_STATE_PREPARE: - E_DBUS_LOG_INFO("E_NM_DEVICE_STATE_PREPARE"); + printf("E_NM_DEVICE_STATE_PREPARE\n"); break; case E_NM_DEVICE_STATE_CONFIG: - E_DBUS_LOG_INFO("E_NM_DEVICE_STATE_CONFIG"); + printf("E_NM_DEVICE_STATE_CONFIG\n"); break; case E_NM_DEVICE_STATE_NEED_AUTH: - E_DBUS_LOG_INFO("E_NM_DEVICE_STATE_NEED_AUTH"); + printf("E_NM_DEVICE_STATE_NEED_AUTH\n"); break; case E_NM_DEVICE_STATE_IP_CONFIG: - E_DBUS_LOG_INFO("E_NM_DEVICE_STATE_IP_CONFIG"); + printf("E_NM_DEVICE_STATE_IP_CONFIG\n"); break; case E_NM_DEVICE_STATE_ACTIVATED: - E_DBUS_LOG_INFO("E_NM_DEVICE_STATE_ACTIVATED"); + printf("E_NM_DEVICE_STATE_ACTIVATED\n"); break; case E_NM_DEVICE_STATE_FAILED: - E_DBUS_LOG_INFO("E_NM_DEVICE_STATE_FAILED"); + printf("E_NM_DEVICE_STATE_FAILED\n"); break; } - E_DBUS_LOG_INFO("ip4_config : %s", dev->ip4_config); - E_DBUS_LOG_INFO("dhcp4_config : %s", dev->dhcp4_config); - E_DBUS_LOG_INFO("managed : %d", dev->managed); - E_DBUS_LOG_INFO("device_type : %u", dev->device_type); + printf("ip4_config : %s\n", dev->ip4_config); + printf("dhcp4_config : %s\n", dev->dhcp4_config); + printf("managed : %d\n", dev->managed); + printf("device_type : %u\n", dev->device_type); switch (dev->device_type) { case E_NM_DEVICE_TYPE_WIRED: - E_DBUS_LOG_INFO("hw_address : %s", dev->wired.hw_address); - E_DBUS_LOG_INFO("speed : %u", dev->wired.speed); - E_DBUS_LOG_INFO("carrier : %d", dev->wired.carrier); + printf("hw_address : %s\n", dev->wired.hw_address); + printf("speed : %u\n", dev->wired.speed); + printf("carrier : %d\n", dev->wired.carrier); break; case E_NM_DEVICE_TYPE_WIRELESS: - E_DBUS_LOG_INFO("hw_address : %s", dev->wireless.hw_address); - E_DBUS_LOG_INFO("mode : "); + printf("hw_address : %s\n", dev->wireless.hw_address); + printf("mode : "); switch (dev->wireless.mode) { case E_NM_802_11_MODE_UNKNOWN: - E_DBUS_LOG_INFO("E_NM_802_11_MODE_UNKNOWN"); + printf("E_NM_802_11_MODE_UNKNOWN\n"); break; case E_NM_802_11_MODE_ADHOC: - E_DBUS_LOG_INFO("E_NM_802_11_MODE_ADHOC"); + printf("E_NM_802_11_MODE_ADHOC\n"); break; case E_NM_802_11_MODE_INFRA: - E_DBUS_LOG_INFO("E_NM_802_11_MODE_INFRA"); + printf("E_NM_802_11_MODE_INFRA\n"); break; } - E_DBUS_LOG_INFO("bitrate : %u", dev->wireless.bitrate); - E_DBUS_LOG_INFO("active_access_point : %s", dev->wireless.active_access_point); - E_DBUS_LOG_INFO("wireless_capabilities:"); + printf("bitrate : %u\n", dev->wireless.bitrate); + printf("active_access_point : %s\n", dev->wireless.active_access_point); + printf("wireless_capabilities: "); if (dev->wireless.wireless_capabilities & E_NM_802_11_DEVICE_CAP_CIPHER_WEP40) - E_DBUS_LOG_INFO(" E_NM_802_11_DEVICE_CAP_CIPHER_WEP40"); + printf(" E_NM_802_11_DEVICE_CAP_CIPHER_WEP40"); if (dev->wireless.wireless_capabilities & E_NM_802_11_DEVICE_CAP_CIPHER_WEP104) - E_DBUS_LOG_INFO(" E_NM_802_11_DEVICE_CAP_CIPHER_WEP104"); + printf(" E_NM_802_11_DEVICE_CAP_CIPHER_WEP104"); if (dev->wireless.wireless_capabilities & E_NM_802_11_DEVICE_CAP_CIPHER_TKIP) - E_DBUS_LOG_INFO(" E_NM_802_11_DEVICE_CAP_CIPHER_TKIP"); + printf(" E_NM_802_11_DEVICE_CAP_CIPHER_TKIP"); if (dev->wireless.wireless_capabilities & E_NM_802_11_DEVICE_CAP_CIPHER_CCMP) - E_DBUS_LOG_INFO(" E_NM_802_11_DEVICE_CAP_CIPHER_CCMP"); + printf(" E_NM_802_11_DEVICE_CAP_CIPHER_CCMP"); if (dev->wireless.wireless_capabilities & E_NM_802_11_DEVICE_CAP_WPA) - E_DBUS_LOG_INFO(" E_NM_802_11_DEVICE_CAP_WPA"); + printf(" E_NM_802_11_DEVICE_CAP_WPA"); if (dev->wireless.wireless_capabilities & E_NM_802_11_DEVICE_CAP_RSN) - E_DBUS_LOG_INFO(" E_NM_802_11_DEVICE_CAP_RSN"); + printf(" E_NM_802_11_DEVICE_CAP_RSN"); if (dev->wireless.wireless_capabilities == E_NM_802_11_DEVICE_CAP_NONE) - E_DBUS_LOG_INFO(" E_NM_802_11_DEVICE_CAP_NONE"); - E_DBUS_LOG_INFO(""); + printf(" E_NM_802_11_DEVICE_CAP_NONE"); + printf("\n"); break; } - E_DBUS_LOG_INFO(""); } EAPI int -e_nm_device_wireless_get_access_points(E_NM_Device *device, int (*cb_func)(void *data, Ecore_List *access_points), void *data) +e_nm_device_wireless_get_access_points(E_NM_Device *device, int (*cb_func)(void *data, Eina_List *access_points), void *data) { DBusMessage *msg; Reply_Data *d; diff --git a/src/lib/nm/e_nm_ip4_config.c b/src/lib/nm/e_nm_ip4_config.c index 3fa53c1..9e9c449 100644 --- a/src/lib/nm/e_nm_ip4_config.c +++ b/src/lib/nm/e_nm_ip4_config.c @@ -41,11 +41,20 @@ e_nm_ip4_config_get(E_NM *nm, const char *ip4_config, EAPI void e_nm_ip4_config_free(E_NM_IP4_Config *config) { + Eina_List *l; + void *data; + if (!config) return; - if (config->addresses) ecore_list_destroy(config->addresses); - if (config->nameservers) ecore_list_destroy(config->nameservers); - if (config->domains) ecore_list_destroy(config->domains); - if (config->routes) ecore_list_destroy(config->routes); + EINA_LIST_FREE(config->addresses, l) + EINA_LIST_FREE(l, data) + free(data); + EINA_LIST_FREE(config->nameservers, data) + free(data); + EINA_LIST_FREE(config->domains, data) + free(data); + EINA_LIST_FREE(config->routes, l) + EINA_LIST_FREE(l, data) + free(data); free(config); } @@ -54,60 +63,47 @@ e_nm_ip4_config_dump(E_NM_IP4_Config *config) { unsigned int *u; const char *domain; - Ecore_List *list; + Eina_List *list, *l; if (!config) return; - E_DBUS_LOG_INFO("E_NM_IP4_Config:"); - if (config->addresses) + printf("E_NM_IP4_Config:\n"); + printf("addresses :\n"); + EINA_LIST_FOREACH(config->addresses, l, list) { char buffer[1024]; + Eina_List *l2; - E_DBUS_LOG_INFO("addresses :"); - ecore_list_first_goto(config->addresses); - while ((list = ecore_list_next(config->addresses))) + strcpy(buffer, " -"); + EINA_LIST_FOREACH(list, l2, u) { - strcpy(buffer, " -"); - ecore_list_first_goto(list); - while ((u = ecore_list_next(list))) - { - strcat(buffer, " "); - strcat(buffer, ip4_address2str(*u)); - } - E_DBUS_LOG_INFO(buffer); + strcat(buffer, " "); + strcat(buffer, ip4_address2str(*u)); } + printf("%s\n", buffer); } - if (config->nameservers) + printf("nameservers:\n"); + EINA_LIST_FOREACH(config->nameservers, l, u) { - E_DBUS_LOG_INFO("nameservers:"); - ecore_list_first_goto(config->nameservers); - while ((u = ecore_list_next(config->nameservers))) - E_DBUS_LOG_INFO(" - %s", ip4_address2str(*u)); + printf(" - %s\n", ip4_address2str(*u)); } - if (config->domains) + printf("domains :\n"); + EINA_LIST_FOREACH(config->domains, l, domain) { - E_DBUS_LOG_INFO("domains :"); - ecore_list_first_goto(config->domains); - while ((domain = ecore_list_next(config->domains))) - E_DBUS_LOG_INFO(" - %s", domain); + printf(" - %s\n", domain); } - if (config->routes) + printf("routes :\n"); + EINA_LIST_FOREACH(config->routes, l, list) { - E_DBUS_LOG_INFO("routes :"); - ecore_list_first_goto(config->routes); - while ((list = ecore_list_next(config->routes))) - { - char buffer[1024]; + char buffer[1024]; + Eina_List *l2; - strcpy(buffer, " -"); - ecore_list_first_goto(list); - while ((u = ecore_list_next(list))) - { - strcat(buffer, " "); - strcat(buffer, ip4_address2str(*u)); - } - E_DBUS_LOG_INFO("%s", buffer); + strcpy(buffer, " -"); + EINA_LIST_FOREACH(list, l2, u) + { + strcat(buffer, " "); + strcat(buffer, ip4_address2str(*u)); } + printf("%s\n", buffer); } - E_DBUS_LOG_INFO(""); } diff --git a/src/lib/nm/e_nm_manager.c b/src/lib/nm/e_nm_manager.c index 5db6316..fceb4f8 100644 --- a/src/lib/nm/e_nm_manager.c +++ b/src/lib/nm/e_nm_manager.c @@ -1,17 +1,16 @@ #include "E_Nm.h" #include "e_nm_private.h" #include "e_dbus_private.h" + static void -check_done(Reply_Data *d, Ecore_List *list) +check_done(Reply_Data *d, Eina_List *list) { - ecore_list_first_goto(list); - if (ecore_list_empty_is(list)) + if (!list) { d->cb_func(d->data, NULL); - ecore_list_destroy(list); free(d); } - else if (ecore_list_current(list) != (void *)-1) + else if (eina_list_data_get(list) != (void *)-1) { d->cb_func(d->data, list); free(d); @@ -21,16 +20,17 @@ check_done(Reply_Data *d, Ecore_List *list) static int cb_nm_device(void *data, E_NM_Device *dev) { - Reply_Data *d; - Ecore_List *list; + Reply_Data *d; + Eina_List *list; d = data; list = d->reply; if (dev) - ecore_list_append(list, dev); - ecore_list_first_remove(list); + list = eina_list_append(list, dev); + list = eina_list_remove_list(list, list); check_done(d, list); + d->reply = list; return 1; } @@ -39,27 +39,26 @@ cb_nm_devices(void *data, void *reply, DBusError *err) { Reply_Data *d; E_NM *nm; - Ecore_List *devices; - Ecore_List *list; + Eina_List *devices; + Eina_List *list = NULL; + Eina_List *l; const char *dev; d = data; nm = d->object; if (dbus_error_is_set(err)) { - E_DBUS_LOG_ERR("%s - %s", err->name, err->message); + ERR("%s - %s", err->name, err->message); d->cb_func(d->data, NULL); free(d); return; } devices = reply; - ecore_list_first_goto(devices); - list = ecore_list_new(); - ecore_list_free_cb_set(list, ECORE_FREE_CB(e_nm_device_free)); - d->reply = list; - while ((dev = ecore_list_next(devices))) + //TODO: ecore_list_free_cb_set(list, ECORE_FREE_CB(e_nm_device_free)); + EINA_LIST_FOREACH(devices, l, dev) { - ecore_list_prepend(list, (void *)-1); + list = eina_list_prepend(list, (void *)-1); + d->reply = list; e_nm_device_get(nm, dev, cb_nm_device, d); } } @@ -67,7 +66,7 @@ cb_nm_devices(void *data, void *reply, DBusError *err) /** * Get all network devices. * - * Returns an Ecore_List of dbus object paths for network devices. This list is + * Returns an Eina_List of dbus object paths for network devices. This list is * of const char *, and is freed automatically after the callback returns. * * @param nm an e_nm context @@ -75,7 +74,7 @@ cb_nm_devices(void *data, void *reply, DBusError *err) * @param data user data to pass to the callback function **/ EAPI int -e_nm_get_devices(E_NM *nm, int (*cb_func)(void *data, Ecore_List *list), void *data) +e_nm_get_devices(E_NM *nm, int (*cb_func)(void *data, Eina_List *list), void *data) { DBusMessage *msg; Reply_Data *d; diff --git a/src/lib/nm/e_nm_private.h b/src/lib/nm/e_nm_private.h index 53224a0..dc083d9 100644 --- a/src/lib/nm/e_nm_private.h +++ b/src/lib/nm/e_nm_private.h @@ -48,7 +48,7 @@ struct E_NM_Internal int (*properties_changed)(E_NM *nm); int (*device_added)(E_NM *nm, const char *device); int (*device_removed)(E_NM *nm, const char *device); - Ecore_List *handlers; + Eina_List *handlers; void *data; }; @@ -65,7 +65,7 @@ struct E_NM_Device_Internal /* TODO: Save some bytes by having internal wired and wireless object */ int (*access_point_added)(E_NM_Device *device, const char *access_point); int (*access_point_removed)(E_NM_Device *device, const char *access_point); - Ecore_List *handlers; + Eina_List *handlers; void *data; }; @@ -78,7 +78,7 @@ struct E_NM_Access_Point_Internal E_NM_Internal *nmi; int (*properties_changed)(E_NM_Access_Point *device); - Ecore_List *handlers; + Eina_List *handlers; void *data; }; @@ -100,7 +100,7 @@ struct E_NMS_Internal int (*new_connection)(E_NMS *nms, const char *service_name, const char *connection); int (*properties_changed)(E_NMS *nms); - Ecore_List *handlers; + Eina_List *handlers; void *data; }; @@ -111,9 +111,9 @@ struct E_NMS_Connection_Internal E_NMS_Connection conn; E_NM_Internal *nmi; - int (*updated)(E_NMS_Connection *conn, Ecore_Hash *settings); + int (*updated)(E_NMS_Connection *conn, Eina_Hash *settings); /* TODO: int (*removed)(E_NMS_Connection *conn); */ - Ecore_List *handlers; + Eina_List *handlers; void *data; }; @@ -167,7 +167,7 @@ void parse_properties(void *data, const Property *properties, DBusMessage *msg) void *cb_nm_object_path_list(DBusMessage *msg, DBusError *err); void free_nm_object_path_list(void *data); -Ecore_Hash *parse_settings(DBusMessage *msg); +Eina_Hash *parse_settings(DBusMessage *msg); int check_arg_type(DBusMessageIter *iter, char type); diff --git a/src/lib/nm/e_nm_util.c b/src/lib/nm/e_nm_util.c index 1f2d123..9b343c8 100644 --- a/src/lib/nm/e_nm_util.c +++ b/src/lib/nm/e_nm_util.c @@ -3,12 +3,11 @@ #include "E_DBus.h" #include "e_dbus_private.h" #include -#include #define CHECK_SIGNATURE(msg, err, sig) \ if (dbus_error_is_set((err))) \ { \ - E_DBUS_LOG_ERR("%s - %s", (err)->name, (err)->message); \ + ERR("%s - %s", (err)->name, (err)->message); \ return NULL; \ } \ \ @@ -62,7 +61,7 @@ find_property_cb(const char *sig) if (!strcmp(t->sig, sig)) return t->func; } - E_DBUS_LOG_ERR("Missing property parser for sig: %s", sig); + ERR("Missing property parser for sig: %s", sig); return NULL; } @@ -89,7 +88,7 @@ property_string(DBusMessageIter *iter, const char *sig, void *value) if ((value) && (!sig)) { - E_DBUS_LOG_ERR("Can't have value and no sig"); + ERR("Can't have value and no sig"); return NULL; } dbus_message_iter_get_basic(iter, &str); @@ -116,7 +115,7 @@ property_basic(DBusMessageIter *iter, const char *sig, void *value) if ((value) && (!sig)) { - E_DBUS_LOG_ERR("Can't have value and no sig"); + ERR("Can't have value and no sig"); return NULL; } if (sig) @@ -160,32 +159,27 @@ static E_NM_Variant * property_array(DBusMessageIter *iter, const char *sig, void *value) { DBusMessageIter a_iter; - Ecore_List **list; + Eina_List **list; Property_Cb func; E_NM_Variant *var = NULL; const char *subsig = NULL; if ((value) && (!sig)) { - E_DBUS_LOG_ERR("Can't have value and no sig"); + ERR("Can't have value and no sig"); return NULL; } dbus_message_iter_recurse(iter, &a_iter); if (sig) { - if (!check_arg_type(iter, sig[0])) return NULL; subsig = (sig + 1); func = find_property_cb(subsig); if (!func) return NULL; if (!value) value = &var; - list = (Ecore_List **)value; - *list = ecore_list_new(); - if (subsig[0] == 'a') - ecore_list_free_cb_set(*list, ECORE_FREE_CB(ecore_list_destroy)); - else - ecore_list_free_cb_set(*list, free); + list = (Eina_List **)value; + *list = NULL; } else { @@ -194,9 +188,8 @@ property_array(DBusMessageIter *iter, const char *sig, void *value) if (!func) return NULL; var = malloc(sizeof(E_NM_Variant)); var->type = dbus_message_iter_get_arg_type(iter); - list = (Ecore_List **)&var->a; - *list = ecore_list_new(); - ecore_list_free_cb_set(*list, ECORE_FREE_CB(property_free)); + list = (Eina_List **)&var->a; + *list = NULL; } while (dbus_message_iter_get_arg_type(&a_iter) != DBUS_TYPE_INVALID) @@ -204,7 +197,7 @@ property_array(DBusMessageIter *iter, const char *sig, void *value) void *subvar; subvar = (*func)(&a_iter, subsig, NULL); - if (subvar) ecore_list_append(*list, subvar); + if (subvar) *list = eina_list_append(*list, subvar); dbus_message_iter_next(&a_iter); } @@ -218,7 +211,12 @@ property_free(E_NM_Variant *var) if ((var->type == 's') || (var->type == 'o')) free(var->s); else if (var->type == 'a') - ecore_list_destroy(var->a); + { + E_NM_Variant *v; + + EINA_LIST_FREE(var->a, v) + property_free(v); + } free(var); } @@ -240,7 +238,7 @@ property(void *data, DBusMessage *msg, DBusError *err) d = data; if (dbus_error_is_set(err)) { - E_DBUS_LOG_ERR("%s - %s", err->name, err->message); + ERR("%s - %s", err->name, err->message); goto error; } if (!dbus_message_has_signature(msg, "v")) goto error; @@ -420,40 +418,45 @@ cb_nm_object_path(DBusMessage *msg, DBusError *err) void * cb_nm_object_path_list(DBusMessage *msg, DBusError *err) { - Ecore_List *devices; + Eina_List *devices = NULL; + char *dev; + DBusMessageIter iter, sub; CHECK_SIGNATURE(msg, err, "ao"); dbus_message_iter_init(msg, &iter); - devices = ecore_list_new(); dbus_message_iter_recurse(&iter, &sub); while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) { - char *dev = NULL; - + dev = NULL; if (!check_arg_type(&sub, 'o')) goto error; dbus_message_iter_get_basic(&sub, &dev); - if (dev) ecore_list_append(devices, dev); + if (dev) devices = eina_list_append(devices, strdup(dev)); dbus_message_iter_next(&sub); } + printf("Hm: devices create = %p\n", devices); return devices; error: - ecore_list_destroy(devices); + EINA_LIST_FREE(devices, dev) + free(dev); return NULL; } void free_nm_object_path_list(void *data) { - Ecore_List *list = data; + Eina_List *list = data; + char *s; - if (list) ecore_list_destroy(list); + printf("Hm: devices delete = %p\n", list); + EINA_LIST_FREE(list, s) + free(s); } -Ecore_Hash * +Eina_Hash * parse_settings(DBusMessage *msg) { Eina_Hash *settings; diff --git a/src/lib/nm/e_nm_variant.c b/src/lib/nm/e_nm_variant.c index 0381f3d..ffcb074 100644 --- a/src/lib/nm/e_nm_variant.c +++ b/src/lib/nm/e_nm_variant.c @@ -47,17 +47,22 @@ e_nm_variant_array_new(int type, const void *value, int size) variant = malloc(sizeof(E_NM_Variant)); variant->type = 'a'; - variant->a = ecore_list_new(); - ecore_list_free_cb_set(variant->a, ECORE_FREE_CB(e_nm_variant_free)); + variant->a = NULL; for (i = 0; i < size; i++) - ecore_list_append(variant->a, e_nm_variant_new(type, &(value[i]))); + variant->a = eina_list_append(variant->a, e_nm_variant_new(type, &(value[i]))); return variant; } EAPI void e_nm_variant_free(E_NM_Variant *variant) { - if (variant->type == 'a') ecore_list_destroy(variant->a); + if (variant->type == 'a') + { + void *data; + + EINA_LIST_FREE(variant->a, data) + e_nm_variant_free(data); + } else if ((variant->type == 's') || (variant->type == 'o')) free(variant->s); free(variant); } diff --git a/src/lib/nm/e_nms.c b/src/lib/nm/e_nms.c index 268856e..d2c060b 100644 --- a/src/lib/nm/e_nms.c +++ b/src/lib/nm/e_nms.c @@ -14,25 +14,24 @@ cb_nms_connections(void *data, void *reply, DBusError *err) { Reply_Data *d; E_NMS_Internal *nmsi; - Ecore_List *connections; - Ecore_List *list; + Eina_List *connections; + Eina_List *list = NULL; + Eina_List *l; const char *path; d = data; nmsi = d->object; if (dbus_error_is_set(err)) { - E_DBUS_LOG_ERR("%s - %s", err->name, err->message); + ERR("%s - %s", err->name, err->message); d->cb_func(d->data, NULL); free(d); return; } - list = ecore_list_new(); - ecore_list_free_cb_set(list, ECORE_FREE_CB(e_nms_connection_free)); + //TODO: ecore_list_free_cb_set(list, ECORE_FREE_CB(e_nms_connection_free)); connections = reply; - ecore_list_first_goto(connections); - while ((path = ecore_list_next(connections))) - ecore_list_append(list, e_nms_connection_get(&(nmsi->nms), nmsi->nms.service_name, path)); + EINA_LIST_FOREACH(connections, l, path) + list = eina_list_append(list, e_nms_connection_get(&(nmsi->nms), nmsi->nms.service_name, path)); d->cb_func(d->data, list); free(d); } @@ -50,7 +49,7 @@ cb_new_connection(void *data, DBusMessage *msg) dbus_message_get_args(msg, &err, DBUS_TYPE_OBJECT_PATH, &conn, DBUS_TYPE_INVALID); if (dbus_error_is_set(&err)) { - E_DBUS_LOG_ERR("%s - %s", err.name, err.message); + ERR("%s - %s", err.name, err.message); return; } @@ -77,7 +76,7 @@ add_basic(DBusMessageIter *iter, E_NM_Variant *variant) switch (variant->type) { case 'a': - E_DBUS_LOG_ERR("No support for array of array"); + ERR("No support for array of array"); break; case 's': case 'o': @@ -109,17 +108,17 @@ add_variant(DBusMessageIter *iter, E_NM_Variant *variant) case 'a': { E_NM_Variant *subvar; DBusMessageIter a_iter; + Eina_List *l; - if (!ecore_list_empty_is(variant->a)) + if (variant->a) { - subvar = ecore_list_first(variant->a); + subvar = eina_list_data_get(variant->a); sig[0] = 'a'; sig[1] = subvar->type; sig[2] = 0; dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &v_iter); dbus_message_iter_open_container(&v_iter, DBUS_TYPE_ARRAY, sig, &a_iter); - ecore_list_first_goto(variant->a); - while ((subvar = ecore_list_next(variant->a))) + EINA_LIST_FOREACH(variant->a, l, subvar) add_basic(&a_iter, subvar); dbus_message_iter_close_container(&v_iter, &a_iter); dbus_message_iter_close_container(iter, &v_iter); @@ -137,37 +136,36 @@ add_variant(DBusMessageIter *iter, E_NM_Variant *variant) } } -static void -add_value(void *value, void *data) +static Eina_Bool +add_value(const Eina_Hash *hash, const void *key, void *data, void *fdata) { - Ecore_Hash_Node *node; - E_NM_Variant *variant; DBusMessageIter *iter, d_iter; - node = value; - iter = data; + iter = fdata; dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY, NULL, &d_iter); - dbus_message_iter_append_basic(&d_iter, DBUS_TYPE_STRING, &node->key); - add_variant(&d_iter, node->value); + dbus_message_iter_append_basic(&d_iter, DBUS_TYPE_STRING, &key); + add_variant(&d_iter, data); dbus_message_iter_close_container(iter, &d_iter); + + return 1; } -static void -add_array(void *value, void *data) +static Eina_Bool +add_array(const Eina_Hash *hash, const void *key, void *data, void *fdata) { - Ecore_Hash_Node *node; DBusMessageIter *iter, d_iter, a_iter; - node = value; - iter = data; + iter = fdata; dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY, NULL, &d_iter); - dbus_message_iter_append_basic(&d_iter, DBUS_TYPE_STRING, &node->key); + dbus_message_iter_append_basic(&d_iter, DBUS_TYPE_STRING, &key); dbus_message_iter_open_container(&d_iter, DBUS_TYPE_ARRAY, "{sv}", &a_iter); - ecore_hash_for_each_node(node->value, add_value, &a_iter); + eina_hash_foreach(data, add_value, &a_iter); dbus_message_iter_close_container(&d_iter, &a_iter); dbus_message_iter_close_container(iter, &d_iter); + + return 1; } EAPI int @@ -178,7 +176,6 @@ e_nms_get(E_NM *nm, E_NMS_Context context, int (*cb_func)(void *data, E_NMS *nms nmsi = calloc(1, sizeof(E_NMS_Internal)); nmsi->nmi = (E_NM_Internal *)nm; - nmsi->handlers = ecore_list_new(); d = calloc(1, sizeof(Property_Data)); d->nmi = nmsi->nmi; @@ -192,8 +189,8 @@ e_nms_get(E_NM *nm, E_NMS_Context context, int (*cb_func)(void *data, E_NMS *nms { case E_NMS_CONTEXT_SYSTEM: nmsi->nms.service_name = E_NMS_SERVICE_SYSTEM; - ecore_list_append(nmsi->handlers, e_nms_signal_handler_add(nmsi->nmi->conn, nmsi->nms.service_name, "NewConnection", cb_new_connection, nmsi)); - ecore_list_append(nmsi->handlers, e_nms_system_signal_handler_add(nmsi->nmi->conn, nmsi->nms.service_name, "PropertiesChanged", cb_properties_changed, nmsi)); + nmsi->handlers = eina_list_append(nmsi->handlers, e_nms_signal_handler_add(nmsi->nmi->conn, nmsi->nms.service_name, "NewConnection", cb_new_connection, nmsi)); + nmsi->handlers = eina_list_append(nmsi->handlers, e_nms_system_signal_handler_add(nmsi->nmi->conn, nmsi->nms.service_name, "PropertiesChanged", cb_properties_changed, nmsi)); d->service = nmsi->nms.service_name; //(*cb_func)(data, &(nmsi->nms)); return property_get(nmsi->nmi->conn, d); @@ -205,42 +202,35 @@ EAPI void e_nms_free(E_NMS *nms) { E_NMS_Internal *nmsi; + void *data; + if (!nms) return; nmsi = (E_NMS_Internal *)nms; - if (nms->unmanaged_devices) ecore_list_destroy(nms->unmanaged_devices); + EINA_LIST_FREE(nms->unmanaged_devices, data) + free(data); if (nms->hostname) free(nms->hostname); - if (nmsi->handlers) - { - E_DBus_Signal_Handler *sh; - - while ((sh = ecore_list_first_remove(nmsi->handlers))) - e_dbus_signal_handler_del(nmsi->nmi->conn, sh); - ecore_list_destroy(nmsi->handlers); - } + EINA_LIST_FREE(nmsi->handlers, data) + e_dbus_signal_handler_del(nmsi->nmi->conn, data); free(nmsi); } EAPI void e_nms_dump(E_NMS *nms) { - if (!nms) return; - E_DBUS_LOG_INFO("E_NMS:"); - E_DBUS_LOG_INFO("unmanaged_devices:"); - if (nms->unmanaged_devices) - { - const char *dev; + const char *dev; + Eina_List *l; - ecore_list_first_goto(nms->unmanaged_devices); - while ((dev = ecore_list_next(nms->unmanaged_devices))) - INFO(" - %s", dev); - } - INFO("hostname : %s", nms->hostname); - INFO(""); + if (!nms) return; + printf("E_NMS:\n"); + printf("unmanaged_devices:\n"); + EINA_LIST_FOREACH(nms->unmanaged_devices, l, dev) + printf(" - %s\n", dev); + printf("hostname : %s\n", nms->hostname); } EAPI int -e_nms_list_connections(E_NMS *nms, int (*cb_func)(void *data, Ecore_List *list), void *data) +e_nms_list_connections(E_NMS *nms, int (*cb_func)(void *data, Eina_List *list), void *data) { DBusMessage *msg; Reply_Data *d; @@ -281,16 +271,16 @@ cb(void *data, DBusMessage *msg, DBusError *err) { if (dbus_error_is_set(err)) { - E_DBUS_LOG_ERR("%s - %s", err->name, err->message); + ERR("%s - %s", err->name, err->message); } else { - E_DBUS_LOG_ERR("Yay!"); + ERR("Yay!"); } } EAPI int -e_nms_system_add_connection(E_NMS *nms, Ecore_Hash *settings) +e_nms_system_add_connection(E_NMS *nms, Eina_Hash *settings) { DBusMessage *msg; DBusMessageIter iter, a_iter; @@ -301,7 +291,7 @@ e_nms_system_add_connection(E_NMS *nms, Ecore_Hash *settings) msg = e_nms_system_call_new(nms->service_name, "AddConnection"); dbus_message_iter_init_append(msg, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sa{sv}}", &a_iter); - ecore_hash_for_each_node(settings, add_array, &a_iter); + eina_hash_foreach(settings, add_array, &a_iter); dbus_message_iter_close_container(&iter, &a_iter); ret = e_dbus_message_send(nmsi->nmi->conn, msg, cb, -1, NULL) ? 1 : 0; diff --git a/src/lib/nm/e_nms_connection.c b/src/lib/nm/e_nms_connection.c index 2e8bac3..25a0c5d 100644 --- a/src/lib/nm/e_nms_connection.c +++ b/src/lib/nm/e_nms_connection.c @@ -7,7 +7,7 @@ static void cb_updated(void *data, DBusMessage *msg) { E_NMS_Connection_Internal *conn; - Ecore_Hash *settings; + Eina_Hash *settings; if (!msg || !data) return; conn = data; @@ -21,12 +21,12 @@ static void cb_settings(void *data, DBusMessage *msg, DBusError *err) { Reply_Data *d; - Ecore_Hash *settings; + Eina_Hash *settings; d = data; if (dbus_error_is_set(err)) { - E_DBUS_LOG_ERR("%s - %s", err->name, err->message); + ERR("%s - %s", err->name, err->message); d->cb_func(d->data, NULL); free(d); return; @@ -41,12 +41,12 @@ static void cb_secrets(void *data, DBusMessage *msg, DBusError *err) { Reply_Data *d; - Ecore_Hash *secrets; + Eina_Hash *secrets; d = data; if (dbus_error_is_set(err)) { - E_DBUS_LOG_ERR("%s - %s", err->name, err->message); + ERR("%s - %s", err->name, err->message); d->cb_func(d->data, NULL); free(d); return; @@ -68,8 +68,7 @@ e_nms_connection_get(E_NMS *nms, const char *service_name, const char *connectio conn->nmi = nmsi->nmi; conn->conn.path = strdup(connection); conn->conn.service_name = strdup(service_name); - conn->handlers = ecore_list_new(); - ecore_list_append(conn->handlers, e_nms_connection_signal_handler_add(nmsi->nmi->conn, service_name, connection, "Updated", cb_updated, conn)); + conn->handlers = eina_list_append(conn->handlers, e_nms_connection_signal_handler_add(nmsi->nmi->conn, service_name, connection, "Updated", cb_updated, conn)); return &conn->conn; } @@ -78,20 +77,15 @@ EAPI void e_nms_connection_free(E_NMS_Connection *connection) { E_NMS_Connection_Internal *conn; + void *data; if (!connection) return; conn = (E_NMS_Connection_Internal *)connection; if (conn->conn.service_name) free(conn->conn.service_name); if (conn->conn.path) free(conn->conn.path); - if (conn->handlers) - { - E_DBus_Signal_Handler *sh; - - while ((sh = ecore_list_first_remove(conn->handlers))) - e_dbus_signal_handler_del(conn->nmi->conn, sh); - ecore_list_destroy(conn->handlers); - } + EINA_LIST_FREE(conn->handlers, data) + e_dbus_signal_handler_del(conn->nmi->conn, data); free(conn); } @@ -100,10 +94,9 @@ e_nms_connection_dump(E_NMS_Connection *conn) { if (!conn) return; - E_DBUS_LOG_INFO("E_NMS_Connection:"); - E_DBUS_LOG_INFO("service_name: %s", conn->service_name); - E_DBUS_LOG_INFO("path : %s", conn->path); - E_DBUS_LOG_INFO(""); + printf("E_NMS_Connection:\n"); + printf("service_name: %s\n", conn->service_name); + printf("path : %s\n", conn->path); } EAPI int @@ -128,13 +121,15 @@ 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, Eina_Hash *secrets), void *data) +e_nms_connection_secrets_get_secrets(E_NMS_Connection *connection, const char *setting_name, Eina_List *hints, int request_new, int (*cb_func)(void *data, Eina_Hash *secrets), void *data) { DBusMessage *msg; DBusMessageIter iter, a_iter; Reply_Data *d; E_NMS_Connection_Internal *conn; int ret; + const char *hint; + Eina_List *l; conn = (E_NMS_Connection_Internal *)connection; d = calloc(1, sizeof(Reply_Data)); @@ -146,13 +141,8 @@ e_nms_connection_secrets_get_secrets(E_NMS_Connection *connection, const char *s dbus_message_iter_init_append(msg, &iter); dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &setting_name); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &a_iter); - if (hints) - { - const char *hint; - ecore_list_first_goto(hints); - while ((hint = ecore_list_next(hints))) - dbus_message_iter_append_basic(&a_iter, DBUS_TYPE_STRING, &hint); - } + EINA_LIST_FOREACH(hints, l, hint) + dbus_message_iter_append_basic(&a_iter, DBUS_TYPE_STRING, &hint); dbus_message_iter_close_container(&iter, &a_iter); dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &request_new); @@ -162,7 +152,7 @@ e_nms_connection_secrets_get_secrets(E_NMS_Connection *connection, const char *s } EAPI void -e_nms_connection_callback_updated_set(E_NMS_Connection *connection, int (*cb_func)(E_NMS_Connection *conn, Ecore_Hash *settings)) +e_nms_connection_callback_updated_set(E_NMS_Connection *connection, int (*cb_func)(E_NMS_Connection *conn, Eina_Hash *settings)) { E_NMS_Connection_Internal *conn; -- 2.7.4