summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-03-19 13:22:40 +0100
committerThomas Haller <thaller@redhat.com>2020-04-02 12:02:32 +0200
commit7d1d720e0a70c3fa79d7065cf5bab8ce0fd8be89 (patch)
tree0e8a31441e11e873e01cf4acfabefcbb747fbd8c
parentf1b4b9f9a50ff575ab98d1d2e881ecd3b8628eec (diff)
downloadNetworkManager-7d1d720e0a70c3fa79d7065cf5bab8ce0fd8be89.tar.gz
supplicant: cleanup notify signals for combined properties in supplicant (2)
-rw-r--r--src/supplicant/nm-supplicant-interface.c79
1 files changed, 37 insertions, 42 deletions
diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c
index b97a7e4b0f..ec1afa25ec 100644
--- a/src/supplicant/nm-supplicant-interface.c
+++ b/src/supplicant/nm-supplicant-interface.c
@@ -147,7 +147,10 @@ typedef struct _NMSupplicantInterfacePrivate {
bool p2p_capable_property:1;
bool p2p_capable_cached:1;
- bool p2p_group_is_owner:1;
+ bool p2p_group_owner_property:1;
+ bool p2p_group_owner_cached:1;
+
+ bool p2p_group_joined_cached:1;
bool is_ready_main:1;
bool is_ready_p2p_device:1;
@@ -468,6 +471,32 @@ _notify_maybe_p2p_available (NMSupplicantInterface *self)
_notify (self, PROP_P2P_AVAILABLE);
}
+static void
+_notify_maybe_p2p_group (NMSupplicantInterface *self)
+{
+ NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
+ gboolean value_joined;
+ gboolean value_owner;
+ gboolean joined_changed;
+ gboolean owner_changed;
+
+ value_joined = priv->p2p_group_path
+ && !priv->p2p_group_properties_cancellable;
+ value_owner = value_joined
+ && priv->p2p_group_owner_property;
+
+ if ((joined_changed = (priv->p2p_group_joined_cached != value_joined)))
+ priv->p2p_group_joined_cached = value_joined;
+
+ if ((owner_changed = (priv->p2p_group_owner_cached != value_owner)))
+ priv->p2p_group_owner_cached = value_owner;
+
+ if (joined_changed)
+ _notify (self, PROP_P2P_GROUP_JOINED);
+ if (owner_changed)
+ _notify (self, PROP_P2P_GROUP_OWNER);
+}
+
/*****************************************************************************/
static void
@@ -1284,37 +1313,19 @@ nm_supplicant_interface_get_auth_state (NMSupplicantInterface *self)
/*****************************************************************************/
-static gboolean
-_prop_p2p_group_joined_get (NMSupplicantInterfacePrivate *priv)
-{
- return priv->p2p_group_path
- && !priv->p2p_group_properties_cancellable;
-}
-
-static gboolean
-_prop_p2p_group_is_owner_get (NMSupplicantInterfacePrivate *priv)
-{
- return _prop_p2p_group_joined_get (priv)
- && priv->p2p_group_is_owner;
-}
-
static void
_p2p_group_properties_changed (NMSupplicantInterface *self,
GVariant *properties)
{
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
- gboolean old_val_p2p_group_is_owner;
const char *s;
- old_val_p2p_group_is_owner = _prop_p2p_group_is_owner_get (priv);
-
if (!properties)
- priv->p2p_group_is_owner = FALSE;
+ priv->p2p_group_owner_property = FALSE;
else if (g_variant_lookup (properties, "Role", "&s", &s))
- priv->p2p_group_is_owner = nm_streq (s, "GO");
+ priv->p2p_group_owner_property = nm_streq (s, "GO");
- if (old_val_p2p_group_is_owner != _prop_p2p_group_is_owner_get (priv))
- _notify (self, PROP_P2P_GROUP_OWNER);
+ _notify_maybe_p2p_group (self);
}
static void
@@ -1351,8 +1362,6 @@ _p2p_group_properties_get_all_cb (GVariant *result,
{
NMSupplicantInterface *self;
NMSupplicantInterfacePrivate *priv;
- gboolean old_val_p2p_group_joined;
- gboolean old_val_p2p_group_is_owner;
gs_unref_variant GVariant *properties = NULL;
if (nm_utils_error_is_cancelled (error))
@@ -1363,9 +1372,6 @@ _p2p_group_properties_get_all_cb (GVariant *result,
g_object_freeze_notify (G_OBJECT (self));
- old_val_p2p_group_joined = _prop_p2p_group_joined_get (priv);
- old_val_p2p_group_is_owner = _prop_p2p_group_is_owner_get (priv);
-
nm_clear_g_cancellable (&priv->p2p_group_properties_cancellable);
if (result)
@@ -1375,10 +1381,7 @@ _p2p_group_properties_get_all_cb (GVariant *result,
_starting_check_ready (self);
- if (old_val_p2p_group_joined != _prop_p2p_group_joined_get (priv))
- _notify (self, PROP_P2P_GROUP_JOINED);
- if (old_val_p2p_group_is_owner != _prop_p2p_group_is_owner_get (priv))
- _notify (self, PROP_P2P_GROUP_OWNER);
+ _notify_maybe_p2p_group (self);
g_object_thaw_notify (G_OBJECT (self));
}
@@ -1389,17 +1392,12 @@ _p2p_group_set_path (NMSupplicantInterface *self,
{
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
nm_auto_ref_string NMRefString *group_path = NULL;
- gboolean old_val_p2p_group_joined;
- gboolean old_val_p2p_group_is_owner;
group_path = nm_ref_string_new (nm_dbus_path_not_empty (path));
if (priv->p2p_group_path == group_path)
return;
- old_val_p2p_group_joined = _prop_p2p_group_joined_get (priv);
- old_val_p2p_group_is_owner = _prop_p2p_group_is_owner_get (priv);
-
nm_clear_g_dbus_connection_signal (priv->dbus_connection,
&priv->p2p_group_properties_changed_id);
nm_clear_g_cancellable (&priv->p2p_group_properties_cancellable);
@@ -1427,10 +1425,7 @@ _p2p_group_set_path (NMSupplicantInterface *self,
}
_notify (self, PROP_P2P_GROUP_PATH);
- if (old_val_p2p_group_joined != _prop_p2p_group_joined_get (priv))
- _notify (self, PROP_P2P_GROUP_JOINED);
- if (old_val_p2p_group_is_owner != _prop_p2p_group_is_owner_get (priv))
- _notify (self, PROP_P2P_GROUP_OWNER);
+ _notify_maybe_p2p_group (self);
nm_assert_starting_has_pending_count (priv->starting_pending_count);
}
@@ -2897,7 +2892,7 @@ nm_supplicant_interface_get_p2p_available (NMSupplicantInterface *self)
gboolean
nm_supplicant_interface_get_p2p_group_joined (NMSupplicantInterface *self)
{
- return _prop_p2p_group_joined_get (NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self));
+ return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->p2p_group_joined_cached;
}
const char*
@@ -2909,7 +2904,7 @@ nm_supplicant_interface_get_p2p_group_path (NMSupplicantInterface *self)
gboolean
nm_supplicant_interface_get_p2p_group_owner (NMSupplicantInterface *self)
{
- return _prop_p2p_group_is_owner_get (NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self));
+ return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->p2p_group_owner_cached;
}
/*****************************************************************************/