return 1;
}
nm = reply;
- e_nm_wireless_enabled_set(nm, 1);
/*
+ e_nm_wireless_enabled_set(nm, 1);
if (nm->active_connections)
{
const char *conn;
e_nm_active_connection_get(nm, conn, cb_active_connection, NULL);
}
e_nm_get_devices(nm, cb_get_devices, nm);
- e_nms_get(nm, cb_nms, nm);
*/
+ e_nms_get(nm, cb_nms, nm);
return 1;
}
typedef struct E_NM_Access_Point E_NM_Access_Point;
struct E_NM_Access_Point
{
+ char *path;
E_NM_802_11_Ap_Flags flags;
E_NM_802_11_Ap_Sec wpa_flags;
E_NM_802_11_Ap_Sec rsn_flags;
/* No properties */
typedef struct E_NMS_Connection E_NMS_Connection;
-/* No properties */
+struct E_NMS_Connection
+{
+ E_NMS_Context context;
+ char *path;
+};
typedef struct E_NM_Active_Connection E_NM_Active_Connection;
struct E_NM_Active_Connection
{
+ char *path;
char *service_name;
char *connection; /* object_path */
char *specific_object; /* object_path */
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);
- /* TODO: e_nm_activate_connection */
- /* TODO: e_nm_deactivate_connection */
+ EAPI int e_nm_activate_connection(E_NM *nm, E_NMS_Connection *connection, E_NM_Device *device, const char *specific_object);
+ EAPI int e_nm_deactivate_connection(E_NM *nm, E_NM_Active_Connection *connection);
EAPI int e_nm_sleep(E_NM *nm, int sleep);
EAPI void e_nm_data_set(E_NM *nm, void *data);
nmi = (E_NM_Internal *)nm;
ap = calloc(1, sizeof(E_NM_Access_Point_Internal));
ap->nmi = nmi;
+ ap->ap.path = strdup(access_point);
d = calloc(1, sizeof(Property_Data));
d->nmi = nmi;
d->cb_func = OBJECT_CB(cb_func);
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);
if (ap->ap.hw_address) free(ap->ap.hw_address);
if (ap->handlers)
nmi = (E_NM_Internal *)nm;
conn = calloc(1, sizeof(E_NM_Active_Connection_Internal));
conn->nmi = nmi;
+ conn->conn.path = strdup(connection);
d = calloc(1, sizeof(Property_Data));
d->nmi = nmi;
d->cb_func = OBJECT_CB(cb_func);
e_nm_active_connection_free(E_NM_Active_Connection *conn)
{
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);
}
EAPI int
+e_nm_activate_connection(E_NM *nm, E_NMS_Connection *conn, E_NM_Device *device, const char *specific_object)
+{
+ DBusMessage *msg;
+ E_NM_Internal *nmi;
+ int ret;
+ const char *service_name;
+
+ nmi = (E_NM_Internal *)nm;
+
+ msg = e_nm_call_new("ActivateConnection");
+ if (conn->context == E_NMS_CONTEXT_USER) service_name = _E_NMS_SERVICE_USER;
+ else if (conn->context == E_NMS_CONTEXT_SYSTEM) service_name = _E_NMS_SERVICE_SYSTEM;
+ dbus_message_append_args(msg,
+ DBUS_TYPE_STRING, &service_name,
+ DBUS_TYPE_OBJECT_PATH, &conn->path,
+ DBUS_TYPE_OBJECT_PATH, &device->udi,
+ DBUS_TYPE_OBJECT_PATH, &specific_object,
+ DBUS_TYPE_INVALID);
+
+ ret = e_dbus_message_send(nmi->conn, msg, NULL, -1, NULL) ? 1 : 0;
+ dbus_message_unref(msg);
+ return ret;
+}
+
+EAPI int
+e_nm_deactivate_connection(E_NM *nm, E_NM_Active_Connection *conn)
+{
+ DBusMessage *msg;
+ E_NM_Internal *nmi;
+ int ret;
+
+ nmi = (E_NM_Internal *)nm;
+
+ msg = e_nm_call_new("DeactivateConnection");
+ dbus_message_append_args(msg,
+ DBUS_TYPE_OBJECT_PATH, &conn->path,
+ DBUS_TYPE_INVALID);
+
+ ret = e_dbus_message_send(nmi->conn, msg, NULL, -1, NULL) ? 1 : 0;
+ dbus_message_unref(msg);
+ return ret;
+}
+
+EAPI int
e_nm_sleep(E_NM *nm, int sleep)
{
DBusMessage *msg;
typedef struct E_NMS_Connection_Internal E_NMS_Connection_Internal;
struct E_NMS_Connection_Internal
{
+ E_NMS_Connection conn;
E_NM_Internal *nmi;
- char *path;
- E_NMS_Context context;
void *data;
};
E_NM_Active_Connection conn;
E_NM_Internal *nmi;
+ char *path;
};
typedef int (*Object_Cb)(void *data, void *reply);
nmsi = (E_NMS_Internal *)nms;
conn = calloc(1, sizeof(E_NMS_Connection_Internal));
conn->nmi = nmsi->nmi;
- conn->path = strdup(connection);
- conn->context = context;
+ conn->conn.path = strdup(connection);
+ conn->conn.context = context;
(*cb_func)(data, (E_NMS_Connection *)conn);
return 1;
}
EAPI void
-e_nms_connection_free(E_NMS_Connection *connection)
+e_nms_connection_free(E_NMS_Connection *conn)
{
- E_NMS_Connection_Internal *conn;
- if (!connection) return;
- conn = (E_NMS_Connection_Internal *)connection;
+ if (!conn) return;
if (conn->path) free(conn->path);
free(conn);
}
EAPI void
-e_nms_connection_dump(E_NMS_Connection *connection)
+e_nms_connection_dump(E_NMS_Connection *conn)
{
- E_NMS_Connection_Internal *conn;
- if (!connection) return;
- conn = (E_NMS_Connection_Internal *)connection;
+ if (!conn) return;
printf("E_NMS_Connection:\n");
printf("context: ");
d->cb_func = OBJECT_CB(cb_func);
d->data = data;
- msg = e_nms_connection_call_new(conn->context, conn->path, "GetSettings");
+ msg = e_nms_connection_call_new(conn->conn.context, 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;
dbus_message_unref(msg);