Commit a25d99f5 authored by Andrew Zaborowski's avatar Andrew Zaborowski Committed by Thomas Haller

devices/wifi: Track IWD devices, match to NMDeviceIwd objects

Add the NMIwdManager singleton to be responsible for matching
NMDeviceIwd objects created from platform devices, to IWD Device dbus
objects when they appear/disappear.
parent ec1db966
......@@ -2706,7 +2706,9 @@ src_devices_wifi_libnm_device_plugin_wifi_la_SOURCES = \
if WITH_IWD
src_devices_wifi_libnm_device_plugin_wifi_la_SOURCES += \
src/devices/wifi/nm-device-iwd.c \
src/devices/wifi/nm-device-iwd.h
src/devices/wifi/nm-device-iwd.h \
src/devices/wifi/nm-iwd-manager.c \
src/devices/wifi/nm-iwd-manager.h
endif
src_devices_wifi_libnm_device_plugin_wifi_la_CPPFLAGS = \
......
......@@ -1610,6 +1610,47 @@ properties_changed (GDBusProxy *proxy, GVariant *changed_properties,
g_variant_iter_free (iter);
}
void
nm_device_iwd_set_dbus_object (NMDeviceIwd *self, GDBusObject *object)
{
NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self);
GDBusInterface *interface;
if (!nm_g_object_ref_set ((GObject **) &priv->dbus_obj, (GObject *) object))
return;
if (priv->dbus_proxy) {
g_signal_handlers_disconnect_by_func (priv->dbus_proxy,
properties_changed, self);
g_clear_object (&priv->dbus_proxy);
}
if (priv->enabled)
nm_device_queue_recheck_available (NM_DEVICE (self),
NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE,
NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
if (!object) {
priv->can_scan = FALSE;
cleanup_association_attempt (self, FALSE);
return;
}
interface = g_dbus_object_get_interface (object, NM_IWD_DEVICE_INTERFACE);
priv->dbus_proxy = G_DBUS_PROXY (interface);
g_signal_connect (priv->dbus_proxy, "g-properties-changed",
G_CALLBACK (properties_changed), self);
/* Call Disconnect to make sure IWD's autoconnect is disabled. We've
* most likely just brought the device UP so it would be in
* autoconnect by default.
*/
send_disconnect (self);
}
/*****************************************************************************/
static void
......
......@@ -53,4 +53,6 @@ GType nm_device_iwd_get_type (void);
NMDevice *nm_device_iwd_new (const char *iface, NMDeviceWifiCapabilities capabilities);
void nm_device_iwd_set_dbus_object (NMDeviceIwd *device, GDBusObject *object);
#endif /* __NETWORKMANAGER_DEVICE_IWD_H__ */
This diff is collapsed.
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2017 Intel Corporation
*/
#ifndef __NETWORKMANAGER_IWD_MANAGER_H__
#define __NETWORKMANAGER_IWD_MANAGER_H__
#include "devices/nm-device.h"
#define NM_IWD_BUS_TYPE G_BUS_TYPE_SYSTEM
#define NM_IWD_SERVICE "net.connman.iwd"
#define NM_IWD_AGENT_MANAGER_INTERFACE "net.connman.iwd.AgentManager"
#define NM_IWD_WIPHY_INTERFACE "net.connman.iwd.Adapter"
#define NM_IWD_DEVICE_INTERFACE "net.connman.iwd.Device"
#define NM_IWD_NETWORK_INTERFACE "net.connman.iwd.Network"
#define NM_IWD_AGENT_INTERFACE "net.connman.iwd.Agent"
#define NM_IWD_WSC_INTERFACE \
"net.connman.iwd.WiFiSimpleConfiguration"
#define NM_IWD_KNOWN_NETWORKS_INTERFACE "net.connman.iwd.KnownNetworks"
#define NM_IWD_SIGNAL_AGENT_INTERFACE "net.connman.iwd.SignalLevelAgent"
#define NM_TYPE_IWD_MANAGER (nm_iwd_manager_get_type ())
#define NM_IWD_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IWD_MANAGER, NMIwdManager))
#define NM_IWD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IWD_MANAGER, NMIwdManagerClass))
#define NM_IS_IWD_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IWD_MANAGER))
#define NM_IS_IWD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IWD_MANAGER))
#define NM_IWD_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IWD_MANAGER, NMIwdManagerClass))
typedef struct _NMIwdManager NMIwdManager;
typedef struct _NMIwdManagerClass NMIwdManagerClass;
GType nm_iwd_manager_get_type (void);
NMIwdManager *nm_iwd_manager_get (void);
#endif /* __NETWORKMANAGER_IWD_MANAGER_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment