From f6adf298fe89ca5b9e7a9d35e951b8e4543b33af Mon Sep 17 00:00:00 2001 From: englebass Date: Wed, 5 Nov 2008 20:35:12 +0000 Subject: [PATCH] ip4 config git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/e_dbus@37514 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/bin/nm.c | 11 +++++++++++ src/lib/nm/e_nm_ip4_config.c | 39 ++++++++++++++++++++++++++++++--------- src/lib/nm/e_nm_manager.c | 1 + src/lib/nm/e_nm_util.c | 10 +++++++--- src/lib/nm/e_nms.c | 4 ++-- 5 files changed, 51 insertions(+), 14 deletions(-) diff --git a/src/bin/nm.c b/src/bin/nm.c index 4f00c6c..cc44986 100644 --- a/src/bin/nm.c +++ b/src/bin/nm.c @@ -37,6 +37,14 @@ cb_active_connection(void *data, E_NM_Active_Connection *conn) } static int +cb_ip4_config(void *data, E_NM_IP4_Config *config) +{ + e_nm_ip4_config_dump(config); + e_nm_ip4_config_free(config); + return 1; +} + +static int cb_get_devices(void *data, Ecore_List *list) { E_NM_Device *device; @@ -48,7 +56,10 @@ cb_get_devices(void *data, Ecore_List *list) { e_nm_device_dump(device); if (device->device_type == E_NM_DEVICE_TYPE_WIRELESS) + { 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); } diff --git a/src/lib/nm/e_nm_ip4_config.c b/src/lib/nm/e_nm_ip4_config.c index b93f57f..dbca2c2 100644 --- a/src/lib/nm/e_nm_ip4_config.c +++ b/src/lib/nm/e_nm_ip4_config.c @@ -4,15 +4,10 @@ #include static Property ip4_config_properties[] = { - /* TODO */ -#if 0 { .name = "Addresses", .sig = "aau", .offset = offsetof(E_NM_IP4_Config, addresses) }, { .name = "Nameservers", .sig = "au", .offset = offsetof(E_NM_IP4_Config, nameservers) }, -#endif { .name = "Domains", .sig = "as", .offset = offsetof(E_NM_IP4_Config, domains) }, -#if 0 { .name = "Routes", .sig = "aau", .offset = offsetof(E_NM_IP4_Config, routes) }, -#endif { .name = NULL } }; @@ -36,7 +31,7 @@ e_nm_ip4_config_get(E_NM *nm, const char *ip4_config, d->property = ip4_config_properties; d->object = strdup(ip4_config); - return e_nm_ip4_config_properties_get(nmi->conn, d->object, d->property->name, d->property->func, d) ? 1 : 0; + return e_nm_ip4_config_properties_get(nmi->conn, d->object, d->property->name, property, d) ? 1 : 0; } EAPI void @@ -53,25 +48,51 @@ e_nm_ip4_config_free(E_NM_IP4_Config *config) EAPI void e_nm_ip4_config_dump(E_NM_IP4_Config *config) { + uint *u; + const char *domain; + Ecore_List *list; + if (!config) return; printf("E_NM_IP4_Config:\n"); if (config->addresses) { + printf("addresses :\n"); + ecore_list_first_goto(config->addresses); + while ((list = ecore_list_next(config->addresses))) + { + printf(" -"); + ecore_list_first_goto(list); + while ((u = ecore_list_next(list))) + printf(" %s", ip4_address2str(*u)); + printf("\n"); + } } if (config->nameservers) { + printf("nameservers:\n"); + ecore_list_first_goto(config->nameservers); + while ((u = ecore_list_next(config->nameservers))) + printf(" - %s\n", ip4_address2str(*u)); } if (config->domains) { - const char *domain; - - printf("domains:\n"); + printf("domains :\n"); ecore_list_first_goto(config->domains); while ((domain = ecore_list_next(config->domains))) printf(" - %s\n", domain); } if (config->routes) { + printf("routes :\n"); + ecore_list_first_goto(config->routes); + while ((list = ecore_list_next(config->routes))) + { + printf(" -"); + ecore_list_first_goto(list); + while ((u = ecore_list_next(list))) + printf(" %s", ip4_address2str(*u)); + printf("\n"); + } } printf("\n"); } diff --git a/src/lib/nm/e_nm_manager.c b/src/lib/nm/e_nm_manager.c index 6b9ae36..75e3e01 100644 --- a/src/lib/nm/e_nm_manager.c +++ b/src/lib/nm/e_nm_manager.c @@ -47,6 +47,7 @@ cb_nm_devices(void *data, void *reply, DBusError *err) nm = d->object; if (dbus_error_is_set(err)) { + printf("Error: %s - %s\n", err->name, err->message); d->cb_func(d->data, NULL); free(d); return; diff --git a/src/lib/nm/e_nm_util.c b/src/lib/nm/e_nm_util.c index 9e27b61..b6e2c75 100644 --- a/src/lib/nm/e_nm_util.c +++ b/src/lib/nm/e_nm_util.c @@ -241,13 +241,13 @@ property_uint_list_list(DBusMessageIter *iter, void *value) if (!check_arg_type(&a2_iter, 'u')) return; list2 = ecore_list_new(); ecore_list_free_cb_set(list2, free); - ecore_list_append(*list, list); + ecore_list_append(*list, list2); while (dbus_message_iter_get_arg_type(&a2_iter) != DBUS_TYPE_INVALID) { unsigned int *c; c = malloc(sizeof(unsigned int)); - dbus_message_iter_get_basic(&a_iter, c); + dbus_message_iter_get_basic(&a2_iter, c); if (c) ecore_list_append(list2, c); dbus_message_iter_next(&a2_iter); } @@ -264,7 +264,11 @@ property(void *data, DBusMessage *msg, DBusError *err) void (*func)(DBusMessageIter *iter, void *value) = NULL; d = data; - if (dbus_error_is_set(err)) goto error; + if (dbus_error_is_set(err)) + { + printf("Error: %s - %s\n", err->name, err->message); + goto error; + } if (!dbus_message_has_signature(msg, "v")) goto error; dbus_message_iter_init(msg, &iter); dbus_message_iter_recurse(&iter, &v_iter); diff --git a/src/lib/nm/e_nms.c b/src/lib/nm/e_nms.c index d25dbac..895a16b 100644 --- a/src/lib/nm/e_nms.c +++ b/src/lib/nm/e_nms.c @@ -50,7 +50,7 @@ cb_nms_user_connections(void *data, void *reply, DBusError *err) list = d->reply; if (dbus_error_is_set(err)) { - fprintf(stderr, "error: %s\n", err->message); + printf("Error: %s - %s\n", err->name, err->message); d->cb_func(d->data, NULL); ecore_list_destroy(list); free(d); @@ -94,7 +94,7 @@ cb_nms_system_connections(void *data, void *reply, DBusError *err) nmsi = d->object; if (dbus_error_is_set(err)) { - fprintf(stderr, "error: %s\n", err->message); + printf("Error: %s - %s\n", err->name, err->message); d->cb_func(d->data, NULL); free(d); return; -- 2.7.4