mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-02 12:20:12 +01:00
wifi-p2p: drop constructor property NM_DEVICE_WIFI_P2P_MGMT_IFACE
We already have a setter function nm_device_wifi_p2p_set_mgmt_iface() as we may need to change the mgmt-iface later on. Use that to set the supplicant interface instead of a constructor property. That makes the object creation simpler, because nothing noteworthy happens, until the very last statement in constructed() to add the pending action.
This commit is contained in:
parent
5c7a9f65b0
commit
75741ef5c8
3 changed files with 20 additions and 47 deletions
|
|
@ -52,8 +52,6 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceWifiP2P,
|
|||
PROP_WFDIES, /* TODO: Make this a property of the setting and Find feature
|
||||
* making the device stateless.
|
||||
*/
|
||||
|
||||
PROP_MGMT_IFACE,
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -1192,9 +1190,6 @@ get_property (GObject *object, guint prop_id,
|
|||
const char **list;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_MGMT_IFACE:
|
||||
g_value_set_object (value, priv->mgmt_iface);
|
||||
break;
|
||||
case PROP_GROUP_OWNER:
|
||||
g_value_set_boolean (value, priv->group_owner);
|
||||
break;
|
||||
|
|
@ -1211,30 +1206,16 @@ get_property (GObject *object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_MGMT_IFACE:
|
||||
/* construct-only */
|
||||
nm_device_wifi_p2p_set_mgmt_iface (self, g_value_get_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_device_wifi_p2p_init (NMDeviceWifiP2P * self)
|
||||
{
|
||||
NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (self);
|
||||
|
||||
c_list_init (&priv->peers_lst_head);
|
||||
|
||||
priv->sup_mgr = g_object_ref (nm_supplicant_manager_get ());
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1245,13 +1226,11 @@ constructed (GObject *object)
|
|||
|
||||
G_OBJECT_CLASS (nm_device_wifi_p2p_parent_class)->constructed (object);
|
||||
|
||||
priv->sup_mgr = g_object_ref (nm_supplicant_manager_get ());
|
||||
|
||||
nm_device_add_pending_action (NM_DEVICE (self), NM_PENDING_ACTION_WAITING_FOR_SUPPLICANT, FALSE);
|
||||
}
|
||||
|
||||
NMDevice*
|
||||
nm_device_wifi_p2p_new (NMSupplicantInterface *mgmt_iface, const char *iface)
|
||||
NMDeviceWifiP2P *
|
||||
nm_device_wifi_p2p_new (const char *iface)
|
||||
{
|
||||
return g_object_new (NM_TYPE_DEVICE_WIFI_P2P,
|
||||
NM_DEVICE_IFACE, iface,
|
||||
|
|
@ -1259,7 +1238,6 @@ nm_device_wifi_p2p_new (NMSupplicantInterface *mgmt_iface, const char *iface)
|
|||
NM_DEVICE_DEVICE_TYPE, NM_TYPE_DEVICE_WIFI_P2P,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_WIFI,
|
||||
NM_DEVICE_RFKILL_TYPE, RFKILL_TYPE_WLAN,
|
||||
NM_DEVICE_WIFI_P2P_MGMT_IFACE, mgmt_iface,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
@ -1298,7 +1276,6 @@ nm_device_wifi_p2p_class_init (NMDeviceWifiP2PClass *klass)
|
|||
|
||||
object_class->constructed = constructed;
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
|
|
@ -1346,12 +1323,5 @@ nm_device_wifi_p2p_class_init (NMDeviceWifiP2PClass *klass)
|
|||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_MGMT_IFACE] =
|
||||
g_param_spec_object (NM_DEVICE_WIFI_P2P_MGMT_IFACE, "", "",
|
||||
NM_TYPE_SUPPLICANT_INTERFACE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,15 +36,12 @@
|
|||
#define NM_DEVICE_WIFI_P2P_GROUPS "groups"
|
||||
#define NM_DEVICE_WIFI_P2P_WFDIES "WFDIEs"
|
||||
|
||||
#define NM_DEVICE_WIFI_P2P_MGMT_IFACE "mgmt-iface"
|
||||
|
||||
typedef struct _NMDeviceWifiP2P NMDeviceWifiP2P;
|
||||
typedef struct _NMDeviceWifiP2PClass NMDeviceWifiP2PClass;
|
||||
|
||||
GType nm_device_wifi_p2p_get_type (void);
|
||||
|
||||
NMDevice* nm_device_wifi_p2p_new (NMSupplicantInterface *mgmt_iface,
|
||||
const char* iface);
|
||||
NMDeviceWifiP2P *nm_device_wifi_p2p_new (const char *iface);
|
||||
|
||||
NMSupplicantInterface * nm_device_wifi_p2p_get_mgmt_iface (NMDeviceWifiP2P *self);
|
||||
void nm_device_wifi_p2p_set_mgmt_iface (NMDeviceWifiP2P *self,
|
||||
|
|
|
|||
|
|
@ -2237,7 +2237,6 @@ static void
|
|||
recheck_p2p_availability (NMDeviceWifi *self)
|
||||
{
|
||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
NMDeviceWifiP2P *p2p_device;
|
||||
gboolean p2p_available;
|
||||
|
||||
g_object_get (priv->sup_iface,
|
||||
|
|
@ -2251,20 +2250,27 @@ recheck_p2p_availability (NMDeviceWifi *self)
|
|||
* wpa_supplicant internally.
|
||||
*/
|
||||
iface_name = g_strconcat ("p2p-dev-", nm_device_get_iface (NM_DEVICE (self)), NULL);
|
||||
p2p_device = NM_DEVICE_WIFI_P2P (nm_device_wifi_p2p_new (priv->sup_iface, iface_name));
|
||||
priv->p2p_device = p2p_device;
|
||||
|
||||
g_signal_emit (self, signals[P2P_DEVICE_CREATED], 0, priv->p2p_device);
|
||||
g_object_add_weak_pointer (G_OBJECT (p2p_device), (gpointer*) &priv->p2p_device);
|
||||
g_object_unref (p2p_device);
|
||||
priv->p2p_device = nm_device_wifi_p2p_new (iface_name);
|
||||
|
||||
} else if (p2p_available && priv->p2p_device) {
|
||||
nm_device_wifi_p2p_set_mgmt_iface (priv->p2p_device, priv->sup_iface);
|
||||
|
||||
} else if (!p2p_available && priv->p2p_device) {
|
||||
g_signal_emit (self, signals[P2P_DEVICE_CREATED], 0, priv->p2p_device);
|
||||
g_object_add_weak_pointer (G_OBJECT (priv->p2p_device), (gpointer*) &priv->p2p_device);
|
||||
g_object_unref (priv->p2p_device);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p2p_available && priv->p2p_device) {
|
||||
nm_device_wifi_p2p_set_mgmt_iface (priv->p2p_device, priv->sup_iface);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!p2p_available && priv->p2p_device) {
|
||||
/* Destroy the P2P device. */
|
||||
g_object_remove_weak_pointer (G_OBJECT (priv->p2p_device), (gpointer*) &priv->p2p_device);
|
||||
nm_device_wifi_p2p_remove (g_steal_pointer (&priv->p2p_device));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue