diff options
| author | Michael Biebl <biebl@debian.org> | 2017-01-17 20:25:09 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2017-01-17 20:25:09 +0100 |
| commit | 58f8be580039b0575b197b9573a1c92745d96d30 (patch) | |
| tree | 2c226233f623a0dcb529be0eb8cdf97e4a2ae0c0 /src/devices/wifi/nm-device-olpc-mesh.c | |
| parent | 45cb5bb3c0e6edb887cf69b417fcaf7053814a9b (diff) | |
New upstream version 1.5.90 upstream/1.5.90
Diffstat (limited to 'src/devices/wifi/nm-device-olpc-mesh.c')
| -rw-r--r-- | src/devices/wifi/nm-device-olpc-mesh.c | 165 |
1 files changed, 80 insertions, 85 deletions
diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index 6fbc63a1..e0258523 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -26,6 +26,8 @@ #include "nm-default.h" +#include "nm-device-olpc-mesh.h" + #include <netinet/in.h> #include <string.h> #include <sys/stat.h> @@ -35,46 +37,52 @@ #include <sys/ioctl.h> #include <errno.h> -#include "nm-device.h" +#include "devices/nm-device.h" #include "nm-device-wifi.h" -#include "nm-device-olpc-mesh.h" -#include "nm-device-private.h" +#include "devices/nm-device-private.h" #include "nm-utils.h" #include "NetworkManagerUtils.h" -#include "nm-activation-request.h" +#include "nm-act-request.h" #include "nm-setting-connection.h" #include "nm-setting-olpc-mesh.h" #include "nm-manager.h" -#include "nm-enum-types.h" -#include "nm-platform.h" +#include "platform/nm-platform.h" /* This is a bug; but we can't really change API now... */ #include "nm-vpn-dbus-interface.h" -#include "nmdbus-device-olpc-mesh.h" +#include "introspection/org.freedesktop.NetworkManager.Device.OlpcMesh.h" -#include "nm-device-logging.h" +#include "devices/nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceOlpcMesh); -G_DEFINE_TYPE (NMDeviceOlpcMesh, nm_device_olpc_mesh, NM_TYPE_DEVICE) - -#define NM_DEVICE_OLPC_MESH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_OLPC_MESH, NMDeviceOlpcMeshPrivate)) +/*****************************************************************************/ -enum { - PROP_0, +NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceOlpcMesh, PROP_COMPANION, PROP_ACTIVE_CHANNEL, +); - LAST_PROP -}; - -struct _NMDeviceOlpcMeshPrivate { +typedef struct { NMDevice *companion; NMManager *manager; gboolean stage1_waiting; +} NMDeviceOlpcMeshPrivate; + +struct _NMDeviceOlpcMesh { + NMDevice parent; + NMDeviceOlpcMeshPrivate _priv; }; -/*******************************************************************/ +struct _NMDeviceOlpcMeshClass { + NMDeviceClass parent; +}; + +G_DEFINE_TYPE (NMDeviceOlpcMesh, nm_device_olpc_mesh, NM_TYPE_DEVICE) + +#define NM_DEVICE_OLPC_MESH_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceOlpcMesh, NM_IS_DEVICE_OLPC_MESH) + +/*****************************************************************************/ static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) @@ -103,6 +111,8 @@ can_auto_connect (NMDevice *device, NMConnection *connection, char **specific_object) { + nm_assert (!specific_object || !*specific_object); + return FALSE; } @@ -150,13 +160,13 @@ complete_connection (NMDevice *device, return TRUE; } -/****************************************************************************/ +/*****************************************************************************/ static NMActStageReturn act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) { NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); - NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (device); + NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); NMActStageReturn ret; gboolean scanning; @@ -178,7 +188,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) /* wait with continuing configuration untill the companion device is done scanning */ - g_object_get (priv->companion, "scanning", &scanning, NULL); + g_object_get (priv->companion, NM_DEVICE_WIFI_SCANNING, &scanning, NULL); if (scanning) { priv->stage1_waiting = TRUE; return NM_ACT_STAGE_RETURN_POSTPONE; @@ -194,7 +204,7 @@ _mesh_set_channel (NMDeviceOlpcMesh *self, guint32 channel) if (nm_platform_mesh_get_channel (NM_PLATFORM_GET, ifindex) != channel) { if (nm_platform_mesh_set_channel (NM_PLATFORM_GET, ifindex, channel)) - g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL); + _notify (self, PROP_ACTIVE_CHANNEL); } } @@ -243,7 +253,7 @@ is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags) return TRUE; } -/*******************************************************************/ +/*****************************************************************************/ static void companion_cleanup (NMDeviceOlpcMesh *self) @@ -254,7 +264,7 @@ companion_cleanup (NMDeviceOlpcMesh *self) g_signal_handlers_disconnect_by_data (priv->companion, self); g_clear_object (&priv->companion); } - g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_COMPANION); + _notify (self, PROP_COMPANION); } static void @@ -267,7 +277,7 @@ companion_notify_cb (NMDeviceWifi *companion, GParamSpec *pspec, gpointer user_d if (!priv->stage1_waiting) return; - g_object_get (companion, "scanning", &scanning, NULL); + g_object_get (companion, NM_DEVICE_WIFI_SCANNING, &scanning, NULL); if (!scanning) { priv->stage1_waiting = FALSE; @@ -343,16 +353,16 @@ check_companion (NMDeviceOlpcMesh *self, NMDevice *other) g_signal_connect (G_OBJECT (other), NM_DEVICE_STATE_CHANGED, G_CALLBACK (companion_state_changed_cb), self); - g_signal_connect (G_OBJECT (other), "notify::scanning", + g_signal_connect (G_OBJECT (other), "notify::" NM_DEVICE_WIFI_SCANNING, G_CALLBACK (companion_notify_cb), self); - g_signal_connect (G_OBJECT (other), "scanning-allowed", + g_signal_connect (G_OBJECT (other), NM_DEVICE_WIFI_SCANNING_ALLOWED, G_CALLBACK (companion_scan_allowed_cb), self); - g_signal_connect (G_OBJECT (other), "autoconnect-allowed", + g_signal_connect (G_OBJECT (other), NM_DEVICE_AUTOCONNECT_ALLOWED, G_CALLBACK (companion_autoconnect_allowed_cb), self); - g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_COMPANION); + _notify (self, PROP_COMPANION); return TRUE; } @@ -413,19 +423,30 @@ state_changed (NMDevice *device, find_companion (NM_DEVICE_OLPC_MESH (device)); } -/*******************************************************************/ +/*****************************************************************************/ -NMDevice * -nm_device_olpc_mesh_new (const char *iface) +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) { - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_OLPC_MESH, - NM_DEVICE_IFACE, iface, - NM_DEVICE_TYPE_DESC, "802.11 OLPC Mesh", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_OLPC_MESH, - NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_OLPC_MESH, - NULL); + NMDeviceOlpcMesh *device = NM_DEVICE_OLPC_MESH (object); + NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (device); + + switch (prop_id) { + case PROP_COMPANION: + nm_utils_g_value_set_object_path (value, priv->companion); + break; + case PROP_ACTIVE_CHANNEL: + g_value_set_uint (value, nm_platform_mesh_get_channel (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (device)))); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } +/*****************************************************************************/ + static void nm_device_olpc_mesh_init (NMDeviceOlpcMesh * self) { @@ -448,35 +469,15 @@ constructed (GObject *object) nm_device_set_dhcp_timeout (NM_DEVICE (self), 20); } -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - NMDeviceOlpcMesh *device = NM_DEVICE_OLPC_MESH (object); - NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (device); - - switch (prop_id) { - case PROP_COMPANION: - nm_utils_g_value_set_object_path (value, priv->companion); - break; - case PROP_ACTIVE_CHANNEL: - g_value_set_uint (value, nm_platform_mesh_get_channel (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (device)))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +NMDevice * +nm_device_olpc_mesh_new (const char *iface) { - switch (prop_id) { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_OLPC_MESH, + NM_DEVICE_IFACE, iface, + NM_DEVICE_TYPE_DESC, "802.11 OLPC Mesh", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_OLPC_MESH, + NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_OLPC_MESH, + NULL); } static void @@ -502,39 +503,33 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMDeviceOlpcMeshPrivate)); - NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_OLPC_MESH_SETTING_NAME, NM_LINK_TYPE_OLPC_MESH) object_class->constructed = constructed; object_class->get_property = get_property; - object_class->set_property = set_property; object_class->dispose = dispose; parent_class->check_connection_compatible = check_connection_compatible; parent_class->can_auto_connect = can_auto_connect; parent_class->complete_connection = complete_connection; - parent_class->is_available = is_available; parent_class->act_stage1_prepare = act_stage1_prepare; parent_class->act_stage2_config = act_stage2_config; - parent_class->state_changed = state_changed; - /* Properties */ - g_object_class_install_property - (object_class, PROP_COMPANION, - g_param_spec_string (NM_DEVICE_OLPC_MESH_COMPANION, "", "", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property - (object_class, PROP_ACTIVE_CHANNEL, - g_param_spec_uint (NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL, "", "", - 0, G_MAXUINT32, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + obj_properties[PROP_COMPANION] = + g_param_spec_string (NM_DEVICE_OLPC_MESH_COMPANION, "", "", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + obj_properties[PROP_ACTIVE_CHANNEL] = + g_param_spec_uint (NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL, "", "", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), NMDBUS_TYPE_DEVICE_OLPC_MESH_SKELETON, |