libnm-glib: pass NMClient as first callback argument to activation callbacks
Better matches glib style.
This commit is contained in:
@@ -144,7 +144,7 @@ static gboolean find_device_for_connection (NmCli *nmc, NMConnection *connection
|
||||
const char *nsp, NMDevice **device, const char **spec_object, GError **error);
|
||||
static const char *active_connection_state_to_string (NMActiveConnectionState state);
|
||||
static void active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpointer user_data);
|
||||
static void activate_connection_cb (gpointer user_data, const char *path, GError *error);
|
||||
static void activate_connection_cb (NMClient *client, const char *path, GError *error, gpointer user_data);
|
||||
static void get_connections_cb (NMRemoteSettings *settings, gpointer user_data);
|
||||
static NMCResultCode do_connections_list (NmCli *nmc, int argc, char **argv);
|
||||
static NMCResultCode do_connections_status (NmCli *nmc, int argc, char **argv);
|
||||
@@ -1267,11 +1267,11 @@ foo_active_connections_changed_cb (NMClient *client,
|
||||
/* Call again activate_connection_cb with dummy arguments;
|
||||
* the correct ones are taken from its first call.
|
||||
*/
|
||||
activate_connection_cb (NULL, NULL, NULL);
|
||||
activate_connection_cb (NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
activate_connection_cb (gpointer user_data, const char *path, GError *error)
|
||||
activate_connection_cb (NMClient *client, const char *path, GError *error, gpointer user_data)
|
||||
{
|
||||
NmCli *nmc = (NmCli *) user_data;
|
||||
NMActiveConnection *active;
|
||||
|
@@ -18,7 +18,7 @@
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2007 - 2008 Novell, Inc.
|
||||
* Copyright (C) 2007 - 2010 Red Hat, Inc.
|
||||
* Copyright (C) 2007 - 2011 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <dbus/dbus-glib.h>
|
||||
@@ -1080,6 +1080,7 @@ nm_client_get_device_by_path (NMClient *client, const char *object_path)
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
NMClient *client;
|
||||
NMClientActivateDeviceFn act_fn;
|
||||
NMClientAddActivateFn add_act_fn;
|
||||
gpointer user_data;
|
||||
@@ -1094,7 +1095,7 @@ activate_cb (DBusGProxy *proxy,
|
||||
ActivateDeviceInfo *info = (ActivateDeviceInfo *) user_data;
|
||||
|
||||
if (info->act_fn)
|
||||
info->act_fn (info->user_data, path, error);
|
||||
info->act_fn (info->client, path, error, info->user_data);
|
||||
else if (error)
|
||||
nm_warning ("Device activation failed: (%d) %s", error->code, error->message);
|
||||
|
||||
@@ -1122,26 +1123,20 @@ nm_client_activate_connection (NMClient *client,
|
||||
gpointer user_data)
|
||||
{
|
||||
ActivateDeviceInfo *info;
|
||||
char *internal_so = (char *) specific_object;
|
||||
|
||||
g_return_if_fail (NM_IS_CLIENT (client));
|
||||
g_return_if_fail (NM_IS_DEVICE (device));
|
||||
g_return_if_fail (connection_path != NULL);
|
||||
|
||||
/* NULL specific object must be translated into "/" because D-Bus does
|
||||
* not have any idea of NULL object paths.
|
||||
*/
|
||||
if (internal_so == NULL)
|
||||
internal_so = "/";
|
||||
|
||||
info = g_slice_new (ActivateDeviceInfo);
|
||||
info->act_fn = callback;
|
||||
info->user_data = user_data;
|
||||
info->client = client;
|
||||
|
||||
org_freedesktop_NetworkManager_activate_connection_async (NM_CLIENT_GET_PRIVATE (client)->client_proxy,
|
||||
connection_path,
|
||||
nm_object_get_path (NM_OBJECT (device)),
|
||||
internal_so,
|
||||
specific_object ? specific_object : "/",
|
||||
activate_cb,
|
||||
info);
|
||||
}
|
||||
@@ -1156,7 +1151,7 @@ add_activate_cb (DBusGProxy *proxy,
|
||||
ActivateDeviceInfo *info = (ActivateDeviceInfo *) user_data;
|
||||
|
||||
if (info->add_act_fn)
|
||||
info->add_act_fn (info->user_data, connection_path, active_path, error);
|
||||
info->add_act_fn (info->client, connection_path, active_path, error, info->user_data);
|
||||
else if (error)
|
||||
nm_warning ("Connection add and activate failed: (%d) %s", error->code, error->message);
|
||||
|
||||
@@ -1201,6 +1196,7 @@ nm_client_add_and_activate_connection (NMClient *client,
|
||||
info = g_slice_new (ActivateDeviceInfo);
|
||||
info->add_act_fn = callback;
|
||||
info->user_data = user_data;
|
||||
info->client = client;
|
||||
|
||||
if (partial)
|
||||
hash = nm_connection_to_hash (partial);
|
||||
|
@@ -18,7 +18,7 @@
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2007 - 2008 Novell, Inc.
|
||||
* Copyright (C) 2007 - 2010 Red Hat, Inc.
|
||||
* Copyright (C) 2007 - 2011 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_CLIENT_H
|
||||
@@ -107,9 +107,10 @@ NMClient *nm_client_new (void);
|
||||
const GPtrArray *nm_client_get_devices (NMClient *client);
|
||||
NMDevice *nm_client_get_device_by_path (NMClient *client, const char *object_path);
|
||||
|
||||
typedef void (*NMClientActivateDeviceFn) (gpointer user_data,
|
||||
typedef void (*NMClientActivateDeviceFn) (NMClient *client,
|
||||
const char *object_path,
|
||||
GError *error);
|
||||
GError *error,
|
||||
gpointer user_data);
|
||||
|
||||
void nm_client_activate_connection (NMClient *client,
|
||||
const char *connection_path,
|
||||
@@ -118,10 +119,11 @@ void nm_client_activate_connection (NMClient *client,
|
||||
NMClientActivateDeviceFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
typedef void (*NMClientAddActivateFn) (gpointer user_data,
|
||||
typedef void (*NMClientAddActivateFn) (NMClient *client,
|
||||
const char *connection_path,
|
||||
const char *active_path,
|
||||
GError *error);
|
||||
GError *error,
|
||||
gpointer user_data);
|
||||
|
||||
void nm_client_add_and_activate_connection (NMClient *client,
|
||||
NMConnection *partial,
|
||||
|
Reference in New Issue
Block a user