Enlightenment CVS committal Author : raster Project : e17 Module : libs/e_dbus
Dir : e17/libs/e_dbus/src/bin Modified Files: nm.c Log Message: stefan's nm patches =================================================================== RCS file: /cvs/e/e17/libs/e_dbus/src/bin/nm.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- nm.c 2 Nov 2007 11:41:58 -0000 1.3 +++ nm.c 25 Mar 2008 18:22:01 -0000 1.4 @@ -1,5 +1,6 @@ #include <E_Nm.h> #include <Ecore_Data.h> +#include <dbus/dbus.h> #define E_NM_DEVICE_TYPE_WIRED 1 #define E_NM_DEVICE_TYPE_WIRELESS 2 @@ -11,162 +12,210 @@ Ecore_List *devices; }; -typedef struct NM_Device NM_Device; -struct NM_Device -{ - int type; - char *object_path; - char *device_name; -}; - void -cb_manager_get_name(void *data, void *reply, DBusError *err) +cb_manager_get_udi(void *data, void *reply, DBusError *err) { - if (dbus_error_is_set(err)) + DBusMessageIter iter, sub; + char *udi; + + if (dbus_error_is_set(err)) { - //XXX printf("Error: %s - %s\n" ,err->name, err->message); return; } - printf("Got name:\n"); - printf(" %s\n", (char *)reply); + + dbus_message_iter_init(reply, &iter); + dbus_message_iter_recurse(&iter, &sub); + dbus_message_iter_get_basic(&sub, &udi); + + printf("Got udi: %s\n", udi); } void -cb_manager_get_type(void *data, void *reply, DBusError *err) +cb_manager_get_interface(void *data, void *reply, DBusError *err) { - if (dbus_error_is_set(err)) + DBusMessageIter iter, sub; + char *interface; + + if (dbus_error_is_set(err)) { - //XXX printf("Error: %s - %s\n" ,err->name, err->message); return; } - printf("Got type:\n"); - printf(" %i (0 == unknown, 1 == ethernet, 2 == wireless)\n", (int)(*((dbus_int32_t *)reply))); + + dbus_message_iter_init(reply, &iter); + dbus_message_iter_recurse(&iter, &sub); + dbus_message_iter_get_basic(&sub, &interface); + + printf("Got interface: %s\n", interface); } void -cb_manager_get_hal_udi(void *data, void *reply, DBusError *err) +cb_manager_get_driver(void *data, void *reply, DBusError *err) { - if (dbus_error_is_set(err)) + DBusMessageIter iter, sub; + char *driver; + + if (dbus_error_is_set(err)) { - //XXX printf("Error: %s - %s\n" ,err->name, err->message); return; } - printf("Got hal udi:\n"); - printf(" %s\n", (char *)reply); + + dbus_message_iter_init(reply, &iter); + dbus_message_iter_recurse(&iter, &sub); + dbus_message_iter_get_basic(&sub, &driver); + + printf("Got driver: %s\n", driver); } void -cb_manager_get_ip4_address(void *data, void *reply, DBusError *err) +cb_manager_get_capabilities(void *data, void *reply, DBusError *err) { - if (dbus_error_is_set(err)) + DBusMessageIter iter, sub; + dbus_uint32_t caps; + + if (dbus_error_is_set(err)) { - //XXX printf("Error: %s - %s\n" ,err->name, err->message); return; } - printf("Got ip4_address:\n"); - printf(" %i.%i.%i.%i\n", - (int)(((*((dbus_int32_t *)reply)) ) & 0xff), - (int)(((*((dbus_int32_t *)reply)) >> 8 ) & 0xff), - (int)(((*((dbus_int32_t *)reply)) >> 16) & 0xff), - (int)(((*((dbus_int32_t *)reply)) >> 24) & 0xff) - ); + + dbus_message_iter_init(reply, &iter); + dbus_message_iter_recurse(&iter, &sub); + dbus_message_iter_get_basic(&sub, &caps); + + printf("Got capabilities: %i\n", caps); } void -cb_manager_get_link_active(void *data, void *reply, DBusError *err) +cb_manager_get_ip4address(void *data, void *reply, DBusError *err) { - if (dbus_error_is_set(err)) + DBusMessageIter iter, sub; + dbus_int32_t ip; + + if (dbus_error_is_set(err)) { - //XXX printf("Error: %s - %s\n" ,err->name, err->message); return; } - printf("Got active:\n"); - printf(" %i\n", (int)(*((dbus_bool_t *)reply))); + + dbus_message_iter_init(reply, &iter); + dbus_message_iter_recurse(&iter, &sub); + dbus_message_iter_get_basic(&sub, &ip); + + printf("Got IPv4 address: %i.%i.%i.%i\n", + (ip & 0xff), + ((ip >> 8 ) & 0xff), + ((ip >> 16) & 0xff), + ((ip >> 24) & 0xff) + ); } void -cb_manager_wireless_get_strength(void *data, void *reply, DBusError *err) +cb_manager_get_state(void *data, void *reply, DBusError *err) { - if (dbus_error_is_set(err)) + DBusMessageIter iter, sub; + dbus_uint32_t state; + + if (dbus_error_is_set(err)) { - //XXX printf("Error: %s - %s\n" ,err->name, err->message); return; } - printf("Got Wireless Strength:\n"); - printf(" %i\n", (int)(*((dbus_int32_t *)reply))); + + dbus_message_iter_init(reply, &iter); + dbus_message_iter_recurse(&iter, &sub); + dbus_message_iter_get_basic(&sub, &state); + + printf("Got state: %i\n", state); } void -cb_manager_wireless_get_active_network(void *data, void *reply, DBusError *err) +cb_manager_get_ip4config(void *data, void *reply, DBusError *err) { - if (dbus_error_is_set(err)) + DBusMessageIter iter, sub; + char *ip4config; + + if (dbus_error_is_set(err)) { - //XXX printf("Error: %s - %s\n" ,err->name, err->message); return; } - printf("Got Wireless Active Network:\n"); - printf(" %s\n", (char *)reply); + + dbus_message_iter_init(reply, &iter); + dbus_message_iter_recurse(&iter, &sub); + dbus_message_iter_get_basic(&sub, &ip4config); + + printf("Got IPv4 config path: %s\n", ip4config); } void -cb_manager_wireless_get_networks(void *data, void *reply, DBusError *err) +cb_manager_get_carrier(void *data, void *reply, DBusError *err) { - Ecore_List *networks; - const char *net; - + DBusMessageIter iter, sub; + dbus_uint32_t carrier; + if (dbus_error_is_set(err)) { - //XXX printf("Error: %s - %s\n" ,err->name, err->message); return; } - - networks = reply; - ecore_list_first_goto(networks); - printf("Got Wireless Networks:\n"); - while ((net = ecore_list_next(networks))) - { - printf(" %s\n", net); - } + + dbus_message_iter_init(reply, &iter); + dbus_message_iter_recurse(&iter, &sub); + dbus_message_iter_get_basic(&sub, &carrier); + + printf("Got carrier: %i\n", carrier); } +void +cb_manager_get_type(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + dbus_uint32_t type; + + if (dbus_error_is_set(err)) + { + printf("Error: %s - %s\n" ,err->name, err->message); + return; + } + + dbus_message_iter_init(reply, &iter); + dbus_message_iter_recurse(&iter, &sub); + dbus_message_iter_get_basic(&sub, &type); + printf("Got type: %i (1 = ethernet, 2 = wireless)\n", type); +} void cb_manager_get_devices(void *data, void *reply, DBusError *err) { NM_Manager *app = data; - Ecore_List *devices; const char *dev; - + if (dbus_error_is_set(err)) { - //XXX printf("Error: %s - %s\n" ,err->name, err->message); return; } - devices = reply; - ecore_list_first_goto(devices); + app->devices = reply; + ecore_list_first_goto(app->devices); printf("Got devices:\n"); - while ((dev = ecore_list_next(devices))) + while ((dev = ecore_list_next(app->devices))) { - printf(" %s\n", dev); - e_nm_device_get_name(app->ctx, dev, cb_manager_get_name, app); + printf("%s\n", dev); + e_nm_device_get_udi(app->ctx, dev, cb_manager_get_udi, app); + e_nm_device_get_interface(app->ctx, dev, cb_manager_get_interface, app); + e_nm_device_get_driver(app->ctx, dev, cb_manager_get_driver, app); + e_nm_device_get_capabilities(app->ctx, dev, cb_manager_get_capabilities, app); + e_nm_device_get_ip4address(app->ctx, dev, cb_manager_get_ip4address, app); + e_nm_device_get_state(app->ctx, dev, cb_manager_get_state, app); + /* FIXME: Getting the ip4config needs fixing */ + //e_nm_device_get_ip4config(app->ctx, dev, cb_manager_get_ip4config, app); + e_nm_device_get_carrier(app->ctx, dev, cb_manager_get_carrier, app); e_nm_device_get_type(app->ctx, dev, cb_manager_get_type, app); - e_nm_device_get_hal_udi(app->ctx, dev, cb_manager_get_hal_udi, app); - e_nm_device_get_ip4_address(app->ctx, dev, cb_manager_get_ip4_address, app); - e_nm_device_get_link_active(app->ctx, dev, cb_manager_get_link_active, app); - e_nm_device_wireless_get_strength(app->ctx, dev, cb_manager_wireless_get_strength, app); - e_nm_device_wireless_get_active_network(app->ctx, dev, cb_manager_wireless_get_active_network, app); - e_nm_device_wireless_get_networks(app->ctx, dev, cb_manager_wireless_get_networks, app); } } ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs