core: simplify NMActRequest
The 'connection' and 'device' private variables aren't needed since they will always be available through the NMActiveConnection superclass.
This commit is contained in:
@@ -51,8 +51,6 @@ typedef struct {
|
|||||||
} ShareRule;
|
} ShareRule;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMConnection *connection;
|
|
||||||
NMDevice *device;
|
|
||||||
guint device_state_id;
|
guint device_state_id;
|
||||||
char *dbus_sender;
|
char *dbus_sender;
|
||||||
GSList *secrets_calls;
|
GSList *secrets_calls;
|
||||||
@@ -157,6 +155,7 @@ void
|
|||||||
nm_act_request_cancel_secrets (NMActRequest *self, guint32 call_id)
|
nm_act_request_cancel_secrets (NMActRequest *self, guint32 call_id)
|
||||||
{
|
{
|
||||||
NMActRequestPrivate *priv;
|
NMActRequestPrivate *priv;
|
||||||
|
NMConnection *connection;
|
||||||
GSList *iter;
|
GSList *iter;
|
||||||
|
|
||||||
g_return_if_fail (self);
|
g_return_if_fail (self);
|
||||||
@@ -165,6 +164,7 @@ nm_act_request_cancel_secrets (NMActRequest *self, guint32 call_id)
|
|||||||
|
|
||||||
priv = NM_ACT_REQUEST_GET_PRIVATE (self);
|
priv = NM_ACT_REQUEST_GET_PRIVATE (self);
|
||||||
|
|
||||||
|
connection = nm_active_connection_get_connection (NM_ACTIVE_CONNECTION (self));
|
||||||
for (iter = priv->secrets_calls; iter; iter = g_slist_next (iter)) {
|
for (iter = priv->secrets_calls; iter; iter = g_slist_next (iter)) {
|
||||||
GetSecretsInfo *info = iter->data;
|
GetSecretsInfo *info = iter->data;
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ nm_act_request_cancel_secrets (NMActRequest *self, guint32 call_id)
|
|||||||
priv->secrets_calls = g_slist_remove_link (priv->secrets_calls, iter);
|
priv->secrets_calls = g_slist_remove_link (priv->secrets_calls, iter);
|
||||||
g_slist_free (iter);
|
g_slist_free (iter);
|
||||||
|
|
||||||
nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (priv->connection), call_id);
|
nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (connection), call_id);
|
||||||
g_free (info);
|
g_free (info);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -300,6 +300,8 @@ device_state_changed (NMDevice *device, GParamSpec *pspec, NMActRequest *self)
|
|||||||
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self);
|
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self);
|
||||||
NMActiveConnectionState ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;
|
NMActiveConnectionState ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;
|
||||||
|
|
||||||
|
g_return_if_fail (device == nm_active_connection_get_device (NM_ACTIVE_CONNECTION (self)));
|
||||||
|
|
||||||
/* Set NMActiveConnection state based on the device's state */
|
/* Set NMActiveConnection state based on the device's state */
|
||||||
switch (nm_device_get_state (device)) {
|
switch (nm_device_get_state (device)) {
|
||||||
case NM_DEVICE_STATE_PREPARE:
|
case NM_DEVICE_STATE_PREPARE:
|
||||||
@@ -323,11 +325,10 @@ device_state_changed (NMDevice *device, GParamSpec *pspec, NMActRequest *self)
|
|||||||
ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATED;
|
ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATED;
|
||||||
|
|
||||||
/* No longer need to pay attention to device state */
|
/* No longer need to pay attention to device state */
|
||||||
if (priv->device && priv->device_state_id) {
|
if (device && priv->device_state_id) {
|
||||||
g_signal_handler_disconnect (priv->device, priv->device_state_id);
|
g_signal_handler_disconnect (device, priv->device_state_id);
|
||||||
priv->device_state_id = 0;
|
priv->device_state_id = 0;
|
||||||
}
|
}
|
||||||
g_clear_object (&priv->device);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -376,7 +377,7 @@ nm_act_request_new (NMConnection *connection,
|
|||||||
GObject *object;
|
GObject *object;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||||
g_return_val_if_fail (NM_DEVICE (device), NULL);
|
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
|
||||||
|
|
||||||
object = g_object_new (NM_TYPE_ACT_REQUEST,
|
object = g_object_new (NM_TYPE_ACT_REQUEST,
|
||||||
NM_ACTIVE_CONNECTION_INT_CONNECTION, connection,
|
NM_ACTIVE_CONNECTION_INT_CONNECTION, connection,
|
||||||
@@ -386,10 +387,8 @@ nm_act_request_new (NMConnection *connection,
|
|||||||
NM_ACTIVE_CONNECTION_INT_USER_UID, user_uid,
|
NM_ACTIVE_CONNECTION_INT_USER_UID, user_uid,
|
||||||
NM_ACTIVE_CONNECTION_INT_MASTER, master,
|
NM_ACTIVE_CONNECTION_INT_MASTER, master,
|
||||||
NULL);
|
NULL);
|
||||||
if (object) {
|
if (object)
|
||||||
nm_active_connection_export (NM_ACTIVE_CONNECTION (object));
|
|
||||||
NM_ACT_REQUEST_GET_PRIVATE (object)->dbus_sender = g_strdup (dbus_sender);
|
NM_ACT_REQUEST_GET_PRIVATE (object)->dbus_sender = g_strdup (dbus_sender);
|
||||||
}
|
|
||||||
|
|
||||||
return (NMActRequest *) object;
|
return (NMActRequest *) object;
|
||||||
}
|
}
|
||||||
@@ -403,32 +402,30 @@ static void
|
|||||||
constructed (GObject *object)
|
constructed (GObject *object)
|
||||||
{
|
{
|
||||||
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (object);
|
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (object);
|
||||||
NMConnection *connection;
|
|
||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_act_request_parent_class)->constructed (object);
|
G_OBJECT_CLASS (nm_act_request_parent_class)->constructed (object);
|
||||||
|
|
||||||
connection = nm_active_connection_get_connection (NM_ACTIVE_CONNECTION (object));
|
|
||||||
priv->connection = g_object_ref (connection);
|
|
||||||
|
|
||||||
device = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object));
|
device = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object));
|
||||||
if (device) {
|
g_assert (device);
|
||||||
priv->device = g_object_ref (device);
|
priv->device_state_id = g_signal_connect (device,
|
||||||
priv->device_state_id = g_signal_connect (priv->device,
|
"notify::" NM_DEVICE_STATE,
|
||||||
"notify::" NM_DEVICE_STATE,
|
G_CALLBACK (device_state_changed),
|
||||||
G_CALLBACK (device_state_changed),
|
NM_ACT_REQUEST (object));
|
||||||
NM_ACT_REQUEST (object));
|
nm_active_connection_export (NM_ACTIVE_CONNECTION (object));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dispose (GObject *object)
|
dispose (GObject *object)
|
||||||
{
|
{
|
||||||
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (object);
|
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (object);
|
||||||
|
NMConnection *connection;
|
||||||
|
NMDevice *device;
|
||||||
GSList *iter;
|
GSList *iter;
|
||||||
|
|
||||||
if (priv->device && priv->device_state_id) {
|
device = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object));
|
||||||
g_signal_handler_disconnect (priv->device, priv->device_state_id);
|
if (device && priv->device_state_id) {
|
||||||
|
g_signal_handler_disconnect (device, priv->device_state_id);
|
||||||
priv->device_state_id = 0;
|
priv->device_state_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,11 +436,11 @@ dispose (GObject *object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Kill any in-progress secrets requests */
|
/* Kill any in-progress secrets requests */
|
||||||
for (iter = priv->secrets_calls; iter; iter = g_slist_next (iter)) {
|
connection = nm_active_connection_get_connection (NM_ACTIVE_CONNECTION (object));
|
||||||
|
for (iter = priv->secrets_calls; connection && iter; iter = g_slist_next (iter)) {
|
||||||
GetSecretsInfo *info = iter->data;
|
GetSecretsInfo *info = iter->data;
|
||||||
|
|
||||||
g_assert (priv->connection);
|
nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (connection), info->call_id);
|
||||||
nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (priv->connection), info->call_id);
|
|
||||||
g_free (info);
|
g_free (info);
|
||||||
}
|
}
|
||||||
g_slist_free (priv->secrets_calls);
|
g_slist_free (priv->secrets_calls);
|
||||||
@@ -452,9 +449,6 @@ dispose (GObject *object)
|
|||||||
g_free (priv->dbus_sender);
|
g_free (priv->dbus_sender);
|
||||||
priv->dbus_sender = NULL;
|
priv->dbus_sender = NULL;
|
||||||
|
|
||||||
g_clear_object (&priv->device);
|
|
||||||
g_clear_object (&priv->connection);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_act_request_parent_class)->dispose (object);
|
G_OBJECT_CLASS (nm_act_request_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user