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_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_active_connection_get(nm, conn, cb_active_connection, NULL);
}
*/
- e_nm_get_devices(nm, cb_get_devices, nm);
/*
+ e_nm_get_devices(nm, cb_get_devices, nm);
+ */
nms = e_nms_get(nm);
e_nms_dump(nms);
e_nms_list_connections(nms, cb_nms_connections, nms);
- */
return 1;
}
#include <string.h>
-static Property properties[] = {
+static const Property properties[] = {
{ .name = "WirelessEnabled", .sig = "b", .offset = offsetof(E_NM, wireless_enabled) },
{ .name = "WirelessHardwareEnabled", .sig = "b", .offset = offsetof(E_NM, wireless_hardware_enabled) },
{ .name = "ActiveConnections", .sig = "ao", .offset = offsetof(E_NM, active_connections) },
#include <string.h>
-static Property access_point_properties[] = {
+static const Property access_point_properties[] = {
{ .name = "Flags", .sig = "u", .offset = offsetof(E_NM_Access_Point, flags) },
{ .name = "WpaFlags", .sig = "u", .offset = offsetof(E_NM_Access_Point, wpa_flags) },
{ .name = "RsnFlags", .sig = "u", .offset = offsetof(E_NM_Access_Point, rsn_flags) },
#include <string.h>
-static Property active_connection_properties[] = {
+static const Property active_connection_properties[] = {
{ .name = "ServiceName", .sig = "s", .offset = offsetof(E_NM_Active_Connection, service_name) },
{ .name = "Connection", .sig = "o", .offset = offsetof(E_NM_Active_Connection, connection) },
{ .name = "SpecificObject", .sig = "o", .offset = offsetof(E_NM_Active_Connection, specific_object) },
static void property_device_type(Property_Data *data, DBusMessageIter *iter);
-static Property device_wired_properties[] = {
+static const Property device_wired_properties[] = {
{ .name = "HwAddress", .sig = "s", .offset = offsetof(E_NM_Device, wired.hw_address) },
{ .name = "Speed", .sig = "u", .offset = offsetof(E_NM_Device, wired.speed) },
{ .name = "Carrier", .sig = "b", .offset = offsetof(E_NM_Device, wired.carrier) },
{ .name = NULL }
};
-static Property device_wireless_properties[] = {
+static const Property device_wireless_properties[] = {
{ .name = "HwAddress", .sig = "s", .offset = offsetof(E_NM_Device, wireless.hw_address) },
{ .name = "Mode", .sig = "u", .offset = offsetof(E_NM_Device, wireless.mode) },
{ .name = "Bitrate", .sig = "u", .offset = offsetof(E_NM_Device, wireless.bitrate) },
{ .name = NULL }
};
-static Property device_properties[] = {
+static const Property device_properties[] = {
{ .name = "Udi", .sig = "s", .offset = offsetof(E_NM_Device, udi) },
{ .name = "Interface", .sig = "s", .offset = offsetof(E_NM_Device, interface) },
{ .name = "Driver", .sig = "s", .offset = offsetof(E_NM_Device, driver) },
while ((ap = ecore_list_next(access_points)))
{
ecore_list_prepend(list, (void *)-1);
- e_nm_access_point_get(dev->nmi, ap, cb_access_point, d);
+ e_nm_access_point_get(&(dev->nmi->nm), ap, cb_access_point, d);
}
ecore_list_first_remove(list);
check_done(d, list);
#include <string.h>
-static Property ip4_config_properties[] = {
+static const Property ip4_config_properties[] = {
{ .name = "Addresses", .sig = "aau", .offset = offsetof(E_NM_IP4_Config, addresses) },
{ .name = "Nameservers", .sig = "au", .offset = offsetof(E_NM_IP4_Config, nameservers) },
{ .name = "Domains", .sig = "as", .offset = offsetof(E_NM_IP4_Config, domains) },
#define e_nm_device_wireless_signal_handler_add(con, dev, sig, cb, data) e_dbus_signal_handler_add(con, _E_NM_SERVICE, dev, _E_NM_INTERFACE_DEVICE_WIRELESS, sig, cb, data)
#define e_nms_signal_handler_add(con, service, sig, cb, data) e_dbus_signal_handler_add(con, service, _E_NMS_PATH, _E_NMS_INTERFACE, sig, cb, data)
+#define e_nms_connection_signal_handler_add(con, service, dev, sig, cb, data) e_dbus_signal_handler_add(con, service, dev, _E_NMS_INTERFACE, sig, cb, data)
typedef struct E_NM_Internal E_NM_Internal;
struct E_NM_Internal
E_NMS_Connection conn;
E_NM_Internal *nmi;
+ int (*updated)(E_NMS_Connection *conn, Ecore_Hash *settings);
+/* TODO: int (*removed)(E_NMS_Connection *conn); */
+ Ecore_List *handlers;
+
void *data;
};
void *reply;
void *data;
- Property *property;
+ const Property *property;
};
typedef struct Reply_Data Reply_Data;
};
void property(void *data, DBusMessage *msg, DBusError *err);
-void parse_properties(void *data, Property *properties, DBusMessage *msg);
+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);
-void *cb_nm_settings(DBusMessage *msg, DBusError *err);
-void free_nm_settings(void *data);
+Ecore_Hash *parse_settings(DBusMessage *msg);
int check_arg_type(DBusMessageIter *iter, char type);
Property_Cb func;
};
-static Sig_Property sigs[] = {
+static const Sig_Property sigs[] = {
{ .sig = "s", property_string },
{ .sig = "o", property_string },
{ .sig = "u", property_basic },
{ .sig = NULL }
};
-static Property_Cb
+static const Property_Cb
find_property_cb(const char *sig)
{
- Sig_Property *t;
+ const Sig_Property *t;
if (!sig) return NULL;
return NULL;
}
-static Property *
-find_property(const char *name, Property *properties)
+static const Property *
+find_property(const char *name, const Property *properties)
{
- Property *p;
+ const Property *p;
if (!name) return NULL;
}
void
-parse_properties(void *data, Property *properties, DBusMessage *msg)
+parse_properties(void *data, const Property *properties, DBusMessage *msg)
{
DBusMessageIter iter, a_iter;
while (dbus_message_iter_get_arg_type(&a_iter) != DBUS_TYPE_INVALID)
{
DBusMessageIter d_iter, v_iter;
- Property *p;
+ const Property *p;
Property_Cb func;
const char *name;
void *value;
}
}
+#if 0
/**
* @internal
* @brief Generic callback for methods that return nothing
return str;
}
+#endif
/**
if (list) ecore_list_destroy(list);
}
-void *
-cb_nm_settings(DBusMessage *msg, DBusError *err)
+Ecore_Hash *
+parse_settings(DBusMessage *msg)
{
Ecore_Hash *settings;
DBusMessageIter iter, a_iter;
- CHECK_SIGNATURE(msg, err, "a{sa{sv}}");
+ if (!dbus_message_has_signature(msg, "a{sa{sv}}")) return NULL;
dbus_message_iter_init(msg, &iter);
return NULL;
}
-void
-free_nm_settings(void *data)
-{
- Ecore_Hash *hash = data;
-
- if (hash) ecore_hash_destroy(hash);
-}
-
int
check_arg_type(DBusMessageIter *iter, char type)
{
#include <string.h>
static void
+cb_updated(void *data, DBusMessage *msg)
+{
+ E_NMS_Connection_Internal *conn;
+ Ecore_Hash *settings;
+ if (!msg || !data) return;
+
+ conn = data;
+ settings = parse_settings(msg);
+
+ if (conn->updated)
+ conn->updated(&(conn->conn), settings);
+}
+
+static void *
+cb_unmarshal_settings(DBusMessage *msg, DBusError *err)
+{
+ if (dbus_error_is_set(err)) return NULL;
+ return parse_settings(msg);
+}
+
+static void
+cb_free_settings(void *data)
+{
+ ecore_hash_destroy(data);
+}
+
+static void
cb_nms_settings(void *data, void *reply, DBusError *err)
{
Reply_Data *d;
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));
+
return &conn->conn;
}
EAPI void
-e_nms_connection_free(E_NMS_Connection *conn)
+e_nms_connection_free(E_NMS_Connection *connection)
{
- if (!conn) return;
+ E_NMS_Connection_Internal *conn;
+
+ 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;
- if (conn->service_name) free(conn->service_name);
- if (conn->path) free(conn->path);
+ while ((sh = ecore_list_first_remove(conn->handlers)))
+ e_dbus_signal_handler_del(conn->nmi->conn, sh);
+ ecore_list_destroy(conn->handlers);
+ }
free(conn);
}
msg = e_nms_connection_call_new(conn->conn.service_name, conn->conn.path, "GetSettings");
- ret = e_dbus_method_call_send(conn->nmi->conn, msg, cb_nm_settings, cb_nms_settings, free_nm_settings, -1, d) ? 1 : 0;
+ ret = e_dbus_method_call_send(conn->nmi->conn, msg, cb_unmarshal_settings, cb_nms_settings, cb_free_settings, -1, d) ? 1 : 0;
dbus_message_unref(msg);
return ret;
}
+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_Internal *conn;
+
+ conn = (E_NMS_Connection_Internal*)connection;
+ conn->updated = cb_func;
+}
+