diff -urN e_dbus/enm.pc.in e_dbus-hacky/enm.pc.in --- e_dbus/enm.pc.in 2008-04-05 03:26:07.000000000 +0200 +++ e_dbus-hacky/enm.pc.in 2008-03-30 01:01:35.000000000 +0100 @@ -7,5 +7,5 @@ Description: Network Manager convenience library Requires: ecore edbus Version: @VERSION@ -Libs: -L${libdir} -lenotify +Libs: -L${libdir} -lenm Cflags: -I${includedir} diff -urN e_dbus/src/bin/nm.c e_dbus-hacky/src/bin/nm.c --- e_dbus/src/bin/nm.c 2008-04-05 03:26:07.000000000 +0200 +++ e_dbus-hacky/src/bin/nm.c 2008-03-30 00:22:03.000000000 +0100 @@ -5,241 +5,154 @@ #define E_NM_DEVICE_TYPE_WIRED 1 #define E_NM_DEVICE_TYPE_WIRELESS 2 -typedef struct NM_Manager NM_Manager; struct NM_Manager { E_NM_Context *ctx; Ecore_List *devices; -}; - -void -cb_manager_get_udi(void *data, void *reply, DBusError *err) -{ - DBusMessageIter iter, sub; - char *udi; - - 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, &udi); - - printf("Got udi: %s\n", udi); -} - -void -cb_manager_get_interface(void *data, void *reply, DBusError *err) -{ - DBusMessageIter iter, sub; - char *interface; - - if (dbus_error_is_set(err)) - { - printf("Error: %s - %s\n" ,err->name, err->message); - return; - } + Ecore_List *aps; - 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); -} + E_DBus_Callback_Func cb_devices; + E_DBus_Callback_Func cb_aps; +}; void -cb_manager_get_driver(void *data, void *reply, DBusError *err) +cb_manager_get_wireless(void *data, void *reply, DBusError *err) { DBusMessageIter iter, sub; - char *driver; + int wireless; - if (dbus_error_is_set(err)) + if (dbus_error_is_set(err)) { - printf("Error: %s - %s\n" ,err->name, err->message); - return; + 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, &driver); + dbus_message_iter_get_basic(&sub, &wireless); - printf("Got driver: %s\n", driver); + printf("Wireless enabled: %i\n", wireless); } void -cb_manager_get_capabilities(void *data, void *reply, DBusError *err) +cb_manager_get_hw_wireless(void *data, void *reply, DBusError *err) { DBusMessageIter iter, sub; - dbus_uint32_t caps; + int hw_wireless; - if (dbus_error_is_set(err)) + if (dbus_error_is_set(err)) { - printf("Error: %s - %s\n" ,err->name, err->message); - return; + 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, &caps); + dbus_message_iter_get_basic(&sub, &hw_wireless); - printf("Got capabilities: %i\n", caps); + printf("Wireless hardware enabled: %i\n", hw_wireless); } void -cb_manager_get_ip4address(void *data, void *reply, DBusError *err) +cb_manager_manager_get_state(void *data, void *reply, DBusError *err) { DBusMessageIter iter, sub; - dbus_int32_t ip; + uint state; - if (dbus_error_is_set(err)) + 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, &ip); - - printf("Got IPv4 address: %i.%i.%i.%i\n", - (ip & 0xff), - ((ip >> 8 ) & 0xff), - ((ip >> 16) & 0xff), - ((ip >> 24) & 0xff) - ); -} - -void -cb_manager_get_state(void *data, void *reply, DBusError *err) -{ - DBusMessageIter iter, sub; - dbus_uint32_t state; - - if (dbus_error_is_set(err)) - { - printf("Error: %s - %s\n" ,err->name, err->message); - return; + 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, &state); - printf("Got state: %i\n", state); + printf("State: %i\n", state); } -void -cb_manager_get_ip4config(void *data, void *reply, DBusError *err) -{ - DBusMessageIter iter, sub; - char *ip4config; - - 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, &ip4config); - - printf("Got IPv4 config path: %s\n", ip4config); -} void -cb_manager_get_carrier(void *data, void *reply, DBusError *err) +cb_manager_wifi_aps(void *data, void *reply, DBusError *err) { - DBusMessageIter iter, sub; - dbus_uint32_t carrier; + NM_Manager *app = data; + E_NM_Access_Point *ap; + const char *ap_path; if (dbus_error_is_set(err)) { printf("Error: %s - %s\n" ,err->name, err->message); return; } + //app->devices = ecore_list_new(); + //ecore_list_init(app->devices); - 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); + ecore_list_first_goto(reply); + printf("Got APs:\n"); + while ((ap_path = ecore_list_next(reply))) + { + printf("%s\n", ap_path); + } } void -cb_manager_get_type(void *data, void *reply, DBusError *err) +cb_manager_get_devices(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); + NM_Manager *app = data; } -void -cb_manager_get_devices(void *data, void *reply, DBusError *err) -{ - NM_Manager *app = data; - const char *dev; +#if 0 +int +dump2_device_info(void *data) +{ + E_NM_Device *dev = data; + + printf("-- Informations from %s --\n", dev->interface); + printf("Got udi: %s\n", dev->udi); + printf("Got interface: %s\n", dev->interface); + printf("Got driver: %s\n", dev->driver); + printf("Got capabilities: %i\n", dev->capabilities); + printf("Got IPv4 address: %i.%i.%i.%i\n", + (dev->ip4address & 0xff), + ((dev->ip4address >> 8 ) & 0xff), + ((dev->ip4address >> 16) & 0xff), + ((dev->ip4address >> 24) & 0xff) + ); + printf("Got state: %i\n", dev->state); + //printf("Got IPv4 config path: %s\n", dev->ip4config); + printf("Got carrier: %i\n", dev->carrier); + printf("Got type: %i (1 = ethernet, 2 = wireless)\n", dev->type); - if (dbus_error_is_set(err)) - { - printf("Error: %s - %s\n" ,err->name, err->message); - return; - } - - app->devices = reply; - ecore_list_first_goto(app->devices); - printf("Got devices:\n"); - while ((dev = ecore_list_next(app->devices))) - { - 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); - } } +#endif -int +int main(int argc, char **argv) { NM_Manager *app; + ecore_init(); ecore_string_init(); e_dbus_init(); - + app = calloc(1, sizeof(NM_Manager)); - + app->ctx = e_nm_new(); if (!app->ctx) { printf("Error connecting to system bus. Is it running?\n"); return 1; } - + + e_nm_manager_get_wireless_enabled(app->ctx, cb_manager_get_wireless, app); + e_nm_manager_get_wireless_hw_enabled(app->ctx, cb_manager_get_hw_wireless, app); + e_nm_manager_get_state(app->ctx, cb_manager_manager_get_state, app); + e_nm_get_devices(app->ctx, cb_manager_get_devices, app); - + ecore_main_loop_begin(); - + e_nm_free(app->ctx); free(app); e_dbus_shutdown(); diff -urN e_dbus/src/lib/nm/e_nm_access_point.c e_dbus-hacky/src/lib/nm/e_nm_access_point.c --- e_dbus/src/lib/nm/e_nm_access_point.c 1970-01-01 01:00:00.000000000 +0100 +++ e_dbus-hacky/src/lib/nm/e_nm_access_point.c 2008-03-30 22:44:28.000000000 +0200 @@ -0,0 +1,475 @@ +/* + * This file defines functions that query each of the functions provided by + * the org.freedesktop.NetworkManager.AccessPoint DBus interface. + */ + +#include "E_Nm.h" +#include "e_nm_private.h" +#include +#include + +#define AP_PROPS 9 + +int ap_prop_counter = 0; + +NM_Manager *app_priv; + +/** + * Get the flags of a NetworkManager access point + * + * @param ctx an e_nm context + * @param ap a NetworkManager access point to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_access_point_get_flags(E_NM_Context *ctx, const char *ap, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ap_properties_get(ctx->conn, ap, "Flags", cb_func, data); +} + + +/** + * Get the WPA flags of a NetworkManager access point + * + * @param ctx an e_nm context + * @param ap a NetworkManager access point to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_access_point_get_wpa_flags(E_NM_Context *ctx, const char *ap, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ap_properties_get(ctx->conn, ap, "WpaFlags", cb_func, data); +} + + +/** + * Get the RSN flags of a NetworkManager access point + * + * @param ctx an e_nm context + * @param ap a NetworkManager access point to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_access_point_get_rsn_flags(E_NM_Context *ctx, const char *ap, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ap_properties_get(ctx->conn, ap, "RsnFlags", cb_func, data); +} + + +/** + * Get the Ssid of a NetworkManager access point + * + * @param ctx an e_nm context + * @param ap a NetworkManager access point to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_access_point_get_ssid(E_NM_Context *ctx, const char *ap, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ap_properties_get(ctx->conn, ap, "Ssid", cb_func, data); +} + + +/** + * Get the Frequency of a NetworkManager access point + * + * @param ctx an e_nm context + * @param ap a NetworkManager access point to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_access_point_get_frequency(E_NM_Context *ctx, const char *ap, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ap_properties_get(ctx->conn, ap, "Frequency", cb_func, data); +} + + +/** + * Get the hw address of a NetworkManager access point + * + * @param ctx an e_nm context + * @param ap a NetworkManager access point to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_access_point_get_hw_address(E_NM_Context *ctx, const char *ap, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ap_properties_get(ctx->conn, ap, "HwAddress", cb_func, data); +} + + +/** + * Get the mode of a NetworkManager access point + * + * @param ctx an e_nm context + * @param ap a NetworkManager access point to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_access_point_get_mode(E_NM_Context *ctx, const char *ap, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ap_properties_get(ctx->conn, ap, "Mode", cb_func, data); +} + + +/** + * Get the rate of a NetworkManager access point + * + * @param ctx an e_nm context + * @param ap a NetworkManager access point to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_access_point_get_rate(E_NM_Context *ctx, const char *ap, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ap_properties_get(ctx->conn, ap, "Rate", cb_func, data); +} + + +/** + * Get the strength of a NetworkManager access point + * + * @param ctx an e_nm context + * @param ap a NetworkManager access point to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_access_point_get_strength(E_NM_Context *ctx, const char *ap, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ap_properties_get(ctx->conn, ap, "Strength", cb_func, data); +} + +void +cb_manager_get_flags(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Access_Point *ap = data; + dbus_uint32_t flags; + + 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, &flags); + + ap->flags = flags; + + ap_prop_counter++; + if (ap_prop_counter == AP_PROPS) + { + dump_ap_properties(data); + ap_prop_counter = 0; + } +} + +void +cb_manager_get_wpa_flags(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Access_Point *ap = data; + dbus_uint32_t wpaflags; + + 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, &wpaflags); + + ap->wpaflags = wpaflags; + + ap_prop_counter++; + if (ap_prop_counter == AP_PROPS) + { + dump_ap_properties(data); + ap_prop_counter = 0; + } +} + +void +cb_manager_get_rsn_flags(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Access_Point *ap = data; + dbus_uint32_t rsnflags; + + 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, &rsnflags); + + ap->rsnflags = rsnflags; + + ap_prop_counter++; + if (ap_prop_counter == AP_PROPS) + { + dump_ap_properties(data); + ap_prop_counter = 0; + } +} + +void +cb_manager_get_ssid(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub, subsub; + E_NM_Access_Point *ap = data; + char byte; + char ssid[200] = "0"; + int len, i; + + 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_recurse(&sub, &subsub); + len = dbus_message_iter_get_array_len(&subsub); + for (i = 0; i < len; i++) + { + dbus_message_iter_get_basic(&subsub, &byte); + //printf("Byte value: %c\n", byte); + ssid[i] = byte; + dbus_message_iter_next(&subsub); + } + + ap->ssid = strdup(ssid); + + ap_prop_counter++; + if (ap_prop_counter == AP_PROPS) + { + dump_ap_properties(data); + ap_prop_counter = 0; + } +} + +void +cb_manager_get_frequency(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Access_Point *ap = data; + dbus_uint32_t frequency; + + 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, &frequency); + + ap->frequency = frequency; + + ap_prop_counter++; + if (ap_prop_counter == AP_PROPS) + { + dump_ap_properties(data); + ap_prop_counter = 0; + } +} + +void +cb_manager_get_hw_address(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Access_Point *ap = data; + char *hwaddress; + + 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, &hwaddress); + + ap->hwaddress = hwaddress; + + ap_prop_counter++; + if (ap_prop_counter == AP_PROPS) + { + dump_ap_properties(data); + ap_prop_counter = 0; + } +} + +void +cb_manager_get_mode(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Access_Point *ap = data; + dbus_int32_t mode; + + 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, &mode); + + ap->mode = mode; + + ap_prop_counter++; + if (ap_prop_counter == AP_PROPS) + { + dump_ap_properties(data); + ap_prop_counter = 0; + } +} + +void +cb_manager_get_rate(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Access_Point *ap = data; + dbus_uint32_t rate; + + 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, &rate); + + ap->rate = rate; + + ap_prop_counter++; + if (ap_prop_counter == AP_PROPS) + { + dump_ap_properties(data); + ap_prop_counter = 0; + } +} + +void +cb_manager_get_strength(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Access_Point *ap = data; + char strength; + + 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, &strength); + + ap->strength = strength; + + ap_prop_counter++; + if (ap_prop_counter == AP_PROPS) + { + dump_ap_properties(data); + ap_prop_counter = 0; + } +} + +void +fill_ap_properties(void *data, void *reply, DBusError *err) +{ + /* FIXME Store app info in private as workaround */ + app_priv = data; + + E_NM_Access_Point *ap; + const char *ap_path; + + if (dbus_error_is_set(err)) + { + printf("Error: %s - %s\n" ,err->name, err->message); + return; + } + + app_priv->aps = ecore_list_new(); + ecore_list_init(app_priv->aps); + + ecore_list_first_goto(reply); + while ((ap_path = ecore_list_next(reply))) + { + ap = calloc(1, sizeof(E_NM_Access_Point)); + ecore_list_append(app_priv->aps, ap); + e_nm_access_point_get_flags(app_priv->ctx, ap_path, cb_manager_get_flags, ap); + e_nm_access_point_get_wpa_flags(app_priv->ctx, ap_path, cb_manager_get_wpa_flags, ap); + e_nm_access_point_get_rsn_flags(app_priv->ctx, ap_path, cb_manager_get_rsn_flags, ap); + e_nm_access_point_get_ssid(app_priv->ctx, ap_path, cb_manager_get_ssid, ap); + e_nm_access_point_get_frequency(app_priv->ctx, ap_path, cb_manager_get_frequency, ap); + e_nm_access_point_get_hw_address(app_priv->ctx, ap_path, cb_manager_get_hw_address, ap); + e_nm_access_point_get_mode(app_priv->ctx, ap_path, cb_manager_get_mode, ap); + e_nm_access_point_get_rate(app_priv->ctx, ap_path, cb_manager_get_rate, ap); + e_nm_access_point_get_strength(app_priv->ctx, ap_path, cb_manager_get_strength, ap); + } +} + +int +dump_ap_properties(void *data) +{ + E_NM_Access_Point *ap = data; + + printf("-- Informations from %s --\n", ap->ssid); + printf("Got flags: %i\n", ap->flags); + printf("Got WPA flags: %i\n", ap->wpaflags); + printf("Got RSN flags: %i\n", ap->rsnflags); + printf("Got SSID: %s\n", ap->ssid); + printf("Got frequency: %i\n", ap->frequency); + printf("Got hw address: %s\n", ap->hwaddress); + printf("Got mode: %i\n", ap->mode); + printf("Got rate: %i\n", ap->rate); + printf("Got strength: %i\n", ap->strength); + + app_priv->cb_aps(app_priv, ap, NULL); +} + diff -urN e_dbus/src/lib/nm/e_nm_device.c e_dbus-hacky/src/lib/nm/e_nm_device.c --- e_dbus/src/lib/nm/e_nm_device.c 2008-04-05 03:26:07.000000000 +0200 +++ e_dbus-hacky/src/lib/nm/e_nm_device.c 2008-03-29 14:53:59.000000000 +0100 @@ -7,6 +7,13 @@ #include "e_nm_private.h" #include +#define DEVICE_PROPS 8 +#define E_NM_DEVICE_TYPE_WIRED 1 +#define E_NM_DEVICE_TYPE_WIRELESS 2 + +int dev_prop_counter = 0; + +NM_Manager *app_priv; /** * Get the UDI of a NetworkManager device @@ -163,3 +170,342 @@ /* FIXME: Decide how to handle the return value for this functions */ e_nm_device_properties_get(ctx->conn, device, "DeviceType", cb_func, data); } + +void +cb_manager_get_udi(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + char *udi; + + 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, &udi); + + dev->udi = udi; + + dev_prop_counter++; + if (dev_prop_counter == DEVICE_PROPS) + { + dump_device_info(data); + dev_prop_counter = 0; + } +} + +void +cb_manager_get_interface(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + char *interface; + + 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, &interface); + + dev->interface = interface; + + dev_prop_counter++; + if (dev_prop_counter == DEVICE_PROPS) + { + fill_dev_special_properties(data); + dev_prop_counter = 0; + } +} + +void +cb_manager_get_driver(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + char *driver; + + 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, &driver); + + dev->driver = driver; + + dev_prop_counter++; + if (dev_prop_counter == DEVICE_PROPS) + { + fill_dev_special_properties(data); + dev_prop_counter = 0; + } +} + +void +cb_manager_get_capabilities(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + dbus_uint32_t caps; + + 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, &caps); + + dev->capabilities = caps; + + dev_prop_counter++; + if (dev_prop_counter == DEVICE_PROPS) + { + fill_dev_special_properties(data); + dev_prop_counter = 0; + } +} + +void +cb_manager_get_ip4address(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + dbus_int32_t ip; + + 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, &ip); + + dev->ip4address = ip; + + dev_prop_counter++; + if (dev_prop_counter == DEVICE_PROPS) + { + fill_dev_special_properties(data); + dev_prop_counter = 0; + } +} + +void +cb_manager_get_state(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + dbus_uint32_t state; + + 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, &state); + + dev->state = state; + + dev_prop_counter++; + if (dev_prop_counter == DEVICE_PROPS) + { + fill_dev_special_properties(data); + dev_prop_counter = 0; + } +} + +void +cb_manager_get_ip4config(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + char *ip4config; + + 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, &ip4config); + + dev->ip4config = ip4config; + + dev_prop_counter++; + if (dev_prop_counter == DEVICE_PROPS) + { + fill_dev_special_properties(data); + dev_prop_counter = 0; + } +} + +void +cb_manager_get_carrier(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + dbus_uint32_t carrier; + + 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, &carrier); + + dev->carrier = carrier; + + dev_prop_counter++; + if (dev_prop_counter == DEVICE_PROPS) + { + fill_dev_special_properties(data); + dev_prop_counter = 0; + } +} + +void +cb_manager_get_type(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + 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); + + dev->type = type; + + dev_prop_counter++; + if (dev_prop_counter == DEVICE_PROPS) + { + fill_dev_special_properties(data); + dev_prop_counter = 0; + } +} + +void +fill_dev_properties(void *data, void *reply, DBusError *err) +{ + NM_Manager *app = data; + + E_NM_Device *dev; + const char *dev_path; + + /* FIXME Store app info in private as workaround */ + app_priv = app; + + if (dbus_error_is_set(err)) + { + printf("Error: %s - %s\n" ,err->name, err->message); + return; + } + + app->devices = ecore_list_new(); + ecore_list_init(app->devices); + + ecore_list_first_goto(reply); + while ((dev_path = ecore_list_next(reply))) + { + dev = calloc(1, sizeof(E_NM_Device)); + ecore_list_append(app->devices, dev); + e_nm_device_get_udi(app->ctx, dev_path, cb_manager_get_udi, dev); + e_nm_device_get_interface(app->ctx, dev_path, cb_manager_get_interface, dev); + e_nm_device_get_driver(app->ctx, dev_path, cb_manager_get_driver, dev); + e_nm_device_get_capabilities(app->ctx, dev_path, cb_manager_get_capabilities, dev); + e_nm_device_get_ip4address(app->ctx, dev_path, cb_manager_get_ip4address, dev); + e_nm_device_get_state(app->ctx, dev_path, cb_manager_get_state, dev); + /* FIXME: We get no reply from NM for this. Broken in used version (3202)? */ + //e_nm_device_get_ip4config(app->ctx, dev_path, cb_manager_get_ip4config, dev); + e_nm_device_get_carrier(app->ctx, dev_path, cb_manager_get_carrier, dev); + e_nm_device_get_type(app->ctx, dev_path, cb_manager_get_type, dev); + } + + app->cb_devices(app, app->devices, err); +} + +void +fill_dev_special_properties(void *data) +{ + E_NM_Device *dev = data; + + if (dev->type == E_NM_DEVICE_TYPE_WIRELESS) + { + e_nm_device_wifi_get_hw_address(app_priv->ctx, dev->udi, cb_manager_wifi_get_hw_address, dev); + e_nm_device_wifi_get_mode(app_priv->ctx, dev->udi, cb_manager_wifi_get_mode, dev); + e_nm_device_wifi_get_bitrate(app_priv->ctx, dev->udi, cb_manager_wifi_get_bitrate, dev); + e_nm_device_wifi_get_active_ap(app_priv->ctx, dev->udi, cb_manager_wifi_get_active_ap, dev); + e_nm_device_wifi_get_wireless_caps(app_priv->ctx, dev->udi, cb_manager_wifi_get_wireless_caps, dev); + e_nm_device_wifi_get_access_points(app_priv->ctx, dev->udi, cb_manager_wifi_aps, app_priv); + } + +#if 0 + else if (dev->type == E_NM_DEVICE_TYPE_WIRED) + { + e_nm_device_wired_get_hw_address(app_priv->ctx, dev->udi, cb_manager_wired_get_hw_address, dev); + /* FIXME: Why does the second call crash? Function does not matter */ + //e_nm_device_wired_get_speed(app_priv->ctx, dev->udi, cb_manager_wired_get_speed, dev); + } +#endif +} + +int +dump_device_info(void *data) +{ + E_NM_Device *dev = data; + + printf("-- Informations from %s --\n", dev->interface); + printf("Got udi: %s\n", dev->udi); + printf("Got interface: %s\n", dev->interface); + printf("Got driver: %s\n", dev->driver); + printf("Got capabilities: %i\n", dev->capabilities); + printf("Got IPv4 address: %i.%i.%i.%i\n", + (dev->ip4address & 0xff), + ((dev->ip4address >> 8 ) & 0xff), + ((dev->ip4address >> 16) & 0xff), + ((dev->ip4address >> 24) & 0xff) + ); + printf("Got state: %i\n", dev->state); + //printf("Got IPv4 config path: %s\n", dev->ip4config); + printf("Got carrier: %i\n", dev->carrier); + printf("Got type: %i (1 = ethernet, 2 = wireless)\n", dev->type); + if (dev->type == E_NM_DEVICE_TYPE_WIRELESS) + { + } + else if (dev->type == E_NM_DEVICE_TYPE_WIRED) + { + printf("Got wired hw address %s\n", dev->sub_device.wired.hwaddress); + printf("Got wired speed %i\n", dev->sub_device.wired.speed); + } +} + diff -urN e_dbus/src/lib/nm/e_nm_device_wifi.c e_dbus-hacky/src/lib/nm/e_nm_device_wifi.c --- e_dbus/src/lib/nm/e_nm_device_wifi.c 1970-01-01 01:00:00.000000000 +0100 +++ e_dbus-hacky/src/lib/nm/e_nm_device_wifi.c 2008-03-29 14:38:01.000000000 +0100 @@ -0,0 +1,234 @@ +/* + * This file defines functions that query each of the functions provided by + * the org.freedesktop.NetworkManager.Device.Wireless DBus interface. + */ + +#include "E_Nm.h" +#include "e_nm_private.h" +#include + +#define DEVICE_WIFI_PROPS 6 + +int dev_wifi_prop_counter = 0; + +/** + * Get all access points seen on this devices. + * + * Returns an Ecore_List of dbus object paths for access points. This list is + * of const char *, and is freed automatically after the callback returns. + * + * @param ctx an e_nm context + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + **/ +EAPI int +e_nm_device_wifi_get_access_points(E_NM_Context *ctx, const char *device, + E_DBus_Callback_Func cb_func, void *data) +{ + DBusMessage *msg; + int ret; + NM_Manager *app = data; + + app->cb_aps = cb_func; + + msg = e_nm_device_wifi_call_new(device, "GetAccessPoints"); + + ret = e_dbus_method_call_send(ctx->conn, msg, cb_nm_string_list, fill_ap_properties, free_nm_string_list, -1, data) ? 1 : 0; + dbus_message_unref(msg); + return ret; +} + + +/** + * Get the hw address of a NetworkManager wireless device. + * + * @param ctx an e_nm context + * @param device a NetworkManagr device to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_device_wifi_get_hw_address(E_NM_Context *ctx, const char *device, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_device_wifi_properties_get(ctx->conn, device, "HwAddress", cb_func, data); +} + + +/** + * Get the mode of a NetworkManager wireless device. + * + * @param ctx an e_nm context + * @param device a NetworkManagr device to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_device_wifi_get_mode(E_NM_Context *ctx, const char *device, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_device_wifi_properties_get(ctx->conn, device, "Mode", cb_func, data); +} + + +/** + * Get the bitrate of a NetworkManager wireless device. + * + * @param ctx an e_nm context + * @param device a NetworkManagr device to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_device_wifi_get_bitrate(E_NM_Context *ctx, const char *device, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_device_wifi_properties_get(ctx->conn, device, "Bitrate", cb_func, data); +} + + +/** + * Get the active ap of a NetworkManager wireless device. + * + * @param ctx an e_nm context + * @param device a NetworkManagr device to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_device_wifi_get_active_ap(E_NM_Context *ctx, const char *device, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_device_wifi_properties_get(ctx->conn, device, "ActiveAccessPoint", cb_func, data); +} + + +/** + * Get the wireless capabilities of a NetworkManager wireless device. + * + * @param ctx an e_nm context + * @param device a NetworkManagr device to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_device_wifi_get_wireless_caps(E_NM_Context *ctx, const char *device, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_device_wifi_properties_get(ctx->conn, device, "WirelessCapabilities", cb_func, data); +} + +void +cb_manager_wifi_get_hw_address(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + char *hw_address; + + 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, &hw_address); + + printf("Wifi hw address: %s\n", hw_address); +#if 1 + dev->sub_device.wireless.hwaddress = hw_address; + + dev_wifi_prop_counter++; + if (dev_wifi_prop_counter == DEVICE_WIFI_PROPS) + { + fill_dev_special_properties(data); + dev_wifi_prop_counter = 0; + } +#endif +} + +void +cb_manager_wifi_get_mode(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + dbus_uint32_t mode; + + 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, &mode); + + printf("Wifi mode: %i\n", mode); +} + +void +cb_manager_wifi_get_bitrate(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + dbus_uint32_t bitrate; + + 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, &bitrate); + + printf("Wifi bitrate: %i\n", bitrate); +} + +void +cb_manager_wifi_get_active_ap(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + char *active_ap; + + 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, &active_ap); + + printf("Wifi active AP: %s\n", active_ap); +} + +void +cb_manager_wifi_get_wireless_caps(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + dbus_uint32_t wifi_caps; + + 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, &wifi_caps); + + printf("Wifi capabilities: %i\n", wifi_caps); +} diff -urN e_dbus/src/lib/nm/e_nm_device_wired.c e_dbus-hacky/src/lib/nm/e_nm_device_wired.c --- e_dbus/src/lib/nm/e_nm_device_wired.c 1970-01-01 01:00:00.000000000 +0100 +++ e_dbus-hacky/src/lib/nm/e_nm_device_wired.c 2008-03-28 01:28:01.000000000 +0100 @@ -0,0 +1,104 @@ +/* + * This file defines functions that query each of the functions provided by + * the org.freedesktop.NetworkManager.Device.Wired DBus interface. + */ + +#include "E_Nm.h" +#include "e_nm_private.h" +#include + +#define DEVICE_WIRED_PROPS 2 + +int dev_wired_prop_counter = 0; + +/** + * Get the hw address of a NetworkManager wired device. + * + * @param ctx an e_nm context + * @param device a NetworkManagr device to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_device_wired_get_hw_address(E_NM_Context *ctx, const char *device, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_device_wired_properties_get(ctx->conn, device, "HwAddress", cb_func, data); +} + + +/** + * Get the speed of a NetworkManager wired device. + * + * @param ctx an e_nm context + * @param device a NetworkManagr device to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_device_wired_get_speed(E_NM_Context *ctx, const char *device, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_device_wired_properties_get(ctx->conn, device, "Speed", cb_func, data); +} + +void +cb_manager_wired_get_hw_address(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + char *hw_address; + + 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, &hw_address); + + printf("Wired hw address: %s\n", hw_address); + + dev->sub_device.wired.hwaddress = hw_address; + + dev_wired_prop_counter++; + if (dev_wired_prop_counter == DEVICE_WIRED_PROPS) + { + dump_device_info(dev); + dev_wired_prop_counter = 0; + } + dump_device_info(dev); +} + +void +cb_manager_wired_get_speed(void *data, void *reply, DBusError *err) +{ + DBusMessageIter iter, sub; + E_NM_Device *dev = data; + dbus_int32_t speed; + + 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, &speed); + + printf("Wired speed: %i\n", speed); + + dev->sub_device.wired.speed = speed; + + dev_wired_prop_counter++; + if (dev_wired_prop_counter == DEVICE_WIRED_PROPS) + { + dump_device_info(dev); + dev_wired_prop_counter = 0; + } +} diff -urN e_dbus/src/lib/nm/E_Nm.h e_dbus-hacky/src/lib/nm/E_Nm.h --- e_dbus/src/lib/nm/E_Nm.h 2008-04-05 03:26:07.000000000 +0200 +++ e_dbus-hacky/src/lib/nm/E_Nm.h 2008-03-30 22:20:51.000000000 +0200 @@ -26,25 +26,12 @@ #endif typedef struct E_NM_Context E_NM_Context; +typedef struct NM_Manager NM_Manager; /** * Matching structs for the new "object" based DBus API * VPN is missing as this was still missing the redesign for the new 0.7 API */ -typedef struct E_NM_Device E_NM_Device; -struct E_NM_Device -{ - char *udi; /* object_path */ - char *interface; - char *driver; - uint capabilities; - int ip4address; - uint state; - char *ip4config; /* object_path */ - int carrier; - uint type; -}; - typedef struct E_NM_Device_Wireless E_NM_Device_Wireless; struct E_NM_Device_Wireless { @@ -62,6 +49,25 @@ uint speed; }; +typedef struct E_NM_Device E_NM_Device; +struct E_NM_Device +{ + char *udi; /* object_path */ + char *interface; + char *driver; + uint capabilities; + int ip4address; + uint state; + char *ip4config; /* object_path */ + int carrier; + uint type; + union + { + E_NM_Device_Wired wired; + E_NM_Device_Wireless wireless; + } sub_device; +}; + typedef struct E_NM_Access_Point E_NM_Access_Point; struct E_NM_Access_Point { diff -urN e_dbus/src/lib/nm/e_nm_ip4config.c e_dbus-hacky/src/lib/nm/e_nm_ip4config.c --- e_dbus/src/lib/nm/e_nm_ip4config.c 1970-01-01 01:00:00.000000000 +0100 +++ e_dbus-hacky/src/lib/nm/e_nm_ip4config.c 2008-03-28 01:28:15.000000000 +0100 @@ -0,0 +1,161 @@ +/* + * This file defines functions that query each of the functions provided by + * the org.freedesktop.NetworkManager.IP4Config DBus interface. + */ + +#include "E_Nm.h" +#include "e_nm_private.h" +#include + + +/** + * Get the address of a NetworkManager IP4Config + * + * @param ctx an e_nm context + * @param config a NetworkManager config to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_ip4config_get_address(E_NM_Context *ctx, const char *config, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ip4config_properties_get(ctx->conn, config, "Address", cb_func, data); +} + + +/** + * Get the gateway of a NetworkManager IP4Config + * + * @param ctx an e_nm context + * @param config a NetworkManager config to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_ip4config_get_gateway(E_NM_Context *ctx, const char *config, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ip4config_properties_get(ctx->conn, config, "Gateway", cb_func, data); +} + + +/** + * Get the netmask of a NetworkManager IP4Config + * + * @param ctx an e_nm context + * @param config a NetworkManager config to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_ip4config_get_netmask(E_NM_Context *ctx, const char *config, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ip4config_properties_get(ctx->conn, config, "Netmask", cb_func, data); +} + + +/** + * Get the broadcast of a NetworkManager IP4Config + * + * @param ctx an e_nm context + * @param config a NetworkManager config to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_ip4config_get_Broadcast(E_NM_Context *ctx, const char *config, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ip4config_properties_get(ctx->conn, config, "Broadcast", cb_func, data); +} + + +/** + * Get the hostname of a NetworkManager IP4Config + * + * @param ctx an e_nm context + * @param config a NetworkManager config to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_ip4config_get_hostname(E_NM_Context *ctx, const char *config, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ip4config_properties_get(ctx->conn, config, "Hostname", cb_func, data); +} + + +/** + * Get the nameservers of a NetworkManager IP4Config + * + * @param ctx an e_nm context + * @param config a NetworkManager config to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_ip4config_get_nameservers(E_NM_Context *ctx, const char *config, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ip4config_properties_get(ctx->conn, config, "Nameservers", cb_func, data); +} + + +/** + * Get the domains of a NetworkManager IP4Config + * + * @param ctx an e_nm context + * @param config a NetworkManager config to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_ip4config_get_domains(E_NM_Context *ctx, const char *config, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ip4config_properties_get(ctx->conn, config, "Domains", cb_func, data); +} + + +/** + * Get the NIS domain of a NetworkManager IP4Config + * + * @param ctx an e_nm context + * @param config a NetworkManager config to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_ip4config_get_nisdomains(E_NM_Context *ctx, const char *config, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ip4config_properties_get(ctx->conn, config, "NisDomain", cb_func, data); +} + + +/** + * Get the NIS servers of a NetworkManager IP4Config + * + * @param ctx an e_nm context + * @param config a NetworkManager config to communicate with + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_ip4config_get_nisservers(E_NM_Context *ctx, const char *config, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_ip4config_properties_get(ctx->conn, config, "NisServers", cb_func, data); +} diff -urN e_dbus/src/lib/nm/e_nm_manager.c e_dbus-hacky/src/lib/nm/e_nm_manager.c --- e_dbus/src/lib/nm/e_nm_manager.c 2008-04-05 03:26:07.000000000 +0200 +++ e_dbus-hacky/src/lib/nm/e_nm_manager.c 2008-03-29 14:35:41.000000000 +0100 @@ -17,60 +17,77 @@ { DBusMessage *msg; int ret; + NM_Manager *app = data; + + app->cb_devices = cb_func; msg = e_nm_manager_call_new("GetDevices"); - ret = e_dbus_method_call_send(ctx->conn, msg, cb_nm_string_list, cb_func, free_nm_string_list, -1, data) ? 1 : 0; + ret = e_dbus_method_call_send(ctx->conn, msg, cb_nm_string_list, fill_dev_properties, free_nm_string_list, -1, data) ? 1 : 0; dbus_message_unref(msg); return ret; } /** - * Find the active device that NM has chosen - * - * Returns a single string containing the dbus path to the active device + * Check if wireless is enabled in NetworkManager * * @param ctx an e_nm context * @param cb a callback, used when the method returns (or an error is received) * @param data user data to pass to the callback function - **/ + */ EAPI int -e_nm_get_active_device(E_NM_Context *ctx, E_DBus_Callback_Func cb_func, - void *data) +e_nm_manager_get_wireless_enabled(E_NM_Context *ctx, + E_DBus_Callback_Func cb_func, void *data) { - return e_nm_get_from_nm(ctx, cb_func, data, - "getActiveDevice", DBUS_TYPE_STRING); + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_manager_properties_get(ctx->conn, "WirelessEnabled", cb_func, data); } /** - * Query the current state of the network - * - * Returns a single string containing the status: - * - * "connecting": there is a pending network connection (waiting for a DHCP - * request to complete, waiting for an encryption - * key/passphrase, waiting for a wireless network, etc) - * - * "connected": there is an active network connection - * - * "scanning": there is no active network connection, but NetworkManager - * is looking for an access point to associate with - * - * "disconnected": there is no network connection - * + * Disable wireless in NetworkManager * + * @param ctx an e_nm context + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_manager_set_wireless_enabled(E_NM_Context *ctx, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + //e_nm_manager_properties_get(ctx->conn, "WirelessEnabled", cb_func, data); +} + + +/** + * Check if wireless is hardware enabled in NetworkManager * * @param ctx an e_nm context * @param cb a callback, used when the method returns (or an error is received) * @param data user data to pass to the callback function - **/ + */ EAPI int -e_nm_status(E_NM_Context *ctx, E_DBus_Callback_Func cb_func, - void *data) +e_nm_manager_get_wireless_hw_enabled(E_NM_Context *ctx, + E_DBus_Callback_Func cb_func, void *data) { + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_manager_properties_get(ctx->conn, "WirelessHardwareEnabled", cb_func, data); +} - return e_nm_get_from_nm(ctx, cb_func, data, - "status", DBUS_TYPE_STRING); + +/** + * State of NetworkManager + * + * @param ctx an e_nm context + * @param cb a callback, used when the method returns (or an error is received) + * @param data user data to pass to the callback function + */ +EAPI int +e_nm_manager_get_state(E_NM_Context *ctx, + E_DBus_Callback_Func cb_func, void *data) +{ + /* FIXME: Decide how to handle the return value for this functions */ + e_nm_manager_properties_get(ctx->conn, "State", cb_func, data); } diff -urN e_dbus/src/lib/nm/e_nm_private.h e_dbus-hacky/src/lib/nm/e_nm_private.h --- e_dbus/src/lib/nm/e_nm_private.h 2008-04-05 03:26:07.000000000 +0200 +++ e_dbus-hacky/src/lib/nm/e_nm_private.h 2008-03-30 22:43:51.000000000 +0200 @@ -14,10 +14,22 @@ #define e_nm_device_call_new(path, member) dbus_message_new_method_call(E_NM_SERVICE, path, E_NM_INTERFACE_DEVICE, member) +#define e_nm_device_wifi_call_new(path, member) dbus_message_new_method_call(E_NM_SERVICE, path, E_NM_INTERFACE_DEVICE_WIRELESS, member) + #define e_nm_network_call_new(member) dbus_message_new_method_call(E_NM_SERVICE, E_NM_PATH_NETWORK_MANAGER, E_NM_INTERFACE_NETWORK_MANAGER, member) #define e_nm_device_properties_get(con, dev, prop, cb, data) e_dbus_properties_get(con, E_NM_SERVICE, dev, E_NM_INTERFACE_DEVICE, prop, (E_DBus_Method_Return_Cb) cb, data) +#define e_nm_device_wifi_properties_get(con, dev, prop, cb, data) e_dbus_properties_get(con, E_NM_SERVICE, dev, E_NM_INTERFACE_DEVICE_WIRELESS, prop, (E_DBus_Method_Return_Cb) cb, data) + +#define e_nm_device_wired_properties_get(con, dev, prop, cb, data) e_dbus_properties_get(con, E_NM_SERVICE, dev, E_NM_INTERFACE_DEVICE_WIRED, prop, (E_DBus_Method_Return_Cb) cb, data) + +#define e_nm_manager_properties_get(con, prop, cb, data) e_dbus_properties_get(con, E_NM_SERVICE, E_NM_PATH_NETWORK_MANAGER, E_NM_INTERFACE_NETWORK_MANAGER, prop, (E_DBus_Method_Return_Cb) cb, data) + +#define e_nm_ip4config_properties_get(con, config, prop, cb, data) e_dbus_properties_get(con, E_NM_SERVICE, config, E_NM_INTERFACE_IP4CONFIG, prop, (E_DBus_Method_Return_Cb) cb, data) + +#define e_nm_ap_properties_get(con, ap, prop, cb, data) e_dbus_properties_get(con, E_NM_SERVICE, ap, E_NM_INTERFACE_ACCESSPOINT, prop, (E_DBus_Method_Return_Cb) cb, data) + struct E_NM_Context { E_DBus_Connection *conn; @@ -32,6 +44,16 @@ void *data_manager_device_removed; }; +struct NM_Manager +{ + E_NM_Context *ctx; + Ecore_List *devices; + Ecore_List *aps; + + E_DBus_Callback_Func cb_devices; + E_DBus_Callback_Func cb_aps; +}; + int e_nm_get_from_nm(E_NM_Context *ctx, E_DBus_Callback_Func cb_func, void *data, const char *method, int rettype); @@ -39,6 +61,8 @@ E_DBus_Callback_Func cb_func, void *data, const char *method, int rettype); +void fill_dev_properties(void *data, void *reply, DBusError *err); +void fill_ap_properties(void *data, void *reply, DBusError *err); void *cb_nm_generic(DBusMessage *msg, DBusError *err); void free_nm_generic(void *data); void *cb_nm_int32(DBusMessage *msg, DBusError *err); @@ -47,4 +71,13 @@ void *cb_nm_boolean(DBusMessage *msg, DBusError *err); void *cb_nm_string_list(DBusMessage *msg, DBusError *err); void free_nm_string_list(void *data); + +void cb_manager_wifi_get_hw_address(void *data, void *reply, DBusError *err); +void cb_manager_wifi_get_mode(void *data, void *reply, DBusError *err); +void cb_manager_wifi_get_bitrate(void *data, void *reply, DBusError *err); +void cb_manager_wifi_get_active_ap(void *data, void *reply, DBusError *err); +void cb_manager_wifi_get_wireless_caps(void *data, void *reply, DBusError *err); +void cb_manager_wifi_aps(void *data, void *reply, DBusError *err); +void cb_manager_wired_get_hw_address(void *data, void *reply, DBusError *err); +void cb_manager_wired_get_speed(void *data, void *reply, DBusError *err); #endif diff -urN e_dbus/src/lib/nm/Makefile.am e_dbus-hacky/src/lib/nm/Makefile.am --- e_dbus/src/lib/nm/Makefile.am 2008-04-05 03:26:07.000000000 +0200 +++ e_dbus-hacky/src/lib/nm/Makefile.am 2008-03-28 01:35:28.000000000 +0100 @@ -14,7 +14,10 @@ e_nm.c \ e_nm_manager.c \ e_nm_device.c \ -e_nm_network.c \ +e_nm_device_wifi.c \ +e_nm_device_wired.c \ +e_nm_ip4config.c \ +e_nm_access_point.c \ e_nm_util.c