libnm: retire deprecated WiMAX NMObject types

WiMAX is deprecated since NetworkManager 1.2.0. Note that also
NetworkManager on server side no longer supports this type, hence
the server's D-Bus API will never expose devices of this type.

Note that NMDeviceWimax and NMWimaxNsp are NMObject types. That means,
they are instantiated by NMClient to represent information on the D-Bus
interface. As NetworkManager no longer exposes WiMAX devices, such
devices are never created. Note that it makes no sense that a user would
directly instantiate NMObject types, because they only work together with
NMClient.

Don't drop the related symbols and definitions from libnm, so that there
is no API/ABI change (as far as building and linking is concerned). But
make the types defunctional (which of course is a behavioral API change).
Calling the API now triggers a g_return_*() warning.

Also belatedly mark the WimaxNsp API as deprecated. It should have been
done in 1.2. Note that here we deprecate the API and retire it at the
same time. Optimally, we would have deprecated it a few releases ago,
before retiring it. However, marking something for deprecation is anyway
no excuse for anything. I mean, removing or retiring API is usually
painful, regardless whether it was marked for deprecation or not. In this
case, there is no possibility that a libnm user gets hold on a NMDeviceWimax
or NMWimaxNsp instance, because NMClient simply no longer instantiates
them. Hence, this change should not affect any user in practice.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/316
This commit is contained in:
Thomas Haller 2019-10-20 08:10:03 +02:00
parent e346bdc550
commit dab1d780fd
10 changed files with 51 additions and 759 deletions

3
NEWS
View file

@ -20,6 +20,9 @@ USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE!
* libnm: hide NMObject and NMClient typedefs from header files. This prevents
the user from subclassing these types and is an ABI change (in case somebody
was doing so).
* libnm: retire deprecated WiMAX API NMDeviceWimax and NMWimaxNsp.
WiMAX support was removed from NetworkManager in version 1.2 (2016) and no such
type instances would have been created by NMClient for a while now.
=============================================
NetworkManager-1.20

View file

@ -4,6 +4,7 @@
org.freedesktop.NetworkManager.Device.WiMax:
@short_description: WiMax Device
DEPRECATED: NetworkManager no longer supports WiMAX since version 1.2. This interface is no longer used.
-->
<interface name="org.freedesktop.NetworkManager.Device.WiMax">

View file

@ -4,6 +4,7 @@
org.freedesktop.NetworkManager.WiMax.Nsp:
@short_description: WiMax Network Service Provider
DEPRECATED: NetworkManager no longer supports WiMAX since version 1.2. This interface is no longer used.
-->
<interface name="org.freedesktop.NetworkManager.WiMax.Nsp">

View file

@ -3080,8 +3080,6 @@ obj_nm_for_gdbus_object (NMClient *self, GDBusObject *object, GDBusObjectManager
type = NM_TYPE_DEVICE_VXLAN;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_WIRELESS) == 0)
type = NM_TYPE_DEVICE_WIFI;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_WIMAX) == 0)
type = NM_TYPE_DEVICE_WIMAX;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_WIREGUARD) == 0)
type = NM_TYPE_DEVICE_WIREGUARD;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DHCP4_CONFIG) == 0)
@ -3102,8 +3100,6 @@ obj_nm_for_gdbus_object (NMClient *self, GDBusObject *object, GDBusObjectManager
type = NM_TYPE_DNS_MANAGER;
else if (strcmp (ifname, NM_DBUS_INTERFACE_VPN_CONNECTION) == 0)
type = NM_TYPE_VPN_CONNECTION;
else if (strcmp (ifname, NM_DBUS_INTERFACE_WIMAX_NSP) == 0)
type = NM_TYPE_WIMAX_NSP;
else if (strcmp (ifname, NM_DBUS_INTERFACE_CHECKPOINT) == 0)
type = NM_TYPE_CHECKPOINT;

View file

@ -8,12 +8,7 @@
#include "nm-device-wimax.h"
#include "nm-setting-connection.h"
#include "nm-setting-wimax.h"
#include "nm-utils.h"
#include "nm-wimax-nsp.h"
#include "nm-object-private.h"
#include "nm-core-internal.h"
/*****************************************************************************/
@ -37,27 +32,12 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
typedef struct {
char *hw_address;
NMWimaxNsp *active_nsp;
GPtrArray *nsps;
guint center_freq;
int rssi;
int cinr;
int tx_power;
char *bsid;
} NMDeviceWimaxPrivate;
struct _NMDeviceWimax {
NMDevice parent;
NMDeviceWimaxPrivate _priv;
};
struct _NMDeviceWimaxClass {
NMDeviceClass parent;
void (*nsp_removed) (NMDeviceWimax *self, NMWimaxNsp *nsp);
};
G_DEFINE_TYPE (NMDeviceWimax, nm_device_wimax, NM_TYPE_DEVICE)
@ -66,11 +46,6 @@ G_DEFINE_TYPE (NMDeviceWimax, nm_device_wimax, NM_TYPE_DEVICE)
/*****************************************************************************/
void _nm_device_wimax_set_wireless_enabled (NMDeviceWimax *wimax, gboolean enabled);
static void state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data);
/*****************************************************************************/
/**
* nm_device_wimax_get_hw_address:
* @wimax: a #NMDeviceWimax
@ -85,9 +60,7 @@ static void state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user
const char *
nm_device_wimax_get_hw_address (NMDeviceWimax *wimax)
{
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
return nm_str_not_empty (NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->hw_address);
g_return_val_if_reached (NULL);
}
/**
@ -103,27 +76,7 @@ nm_device_wimax_get_hw_address (NMDeviceWimax *wimax)
NMWimaxNsp *
nm_device_wimax_get_active_nsp (NMDeviceWimax *wimax)
{
NMDeviceState state;
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
state = nm_device_get_state (NM_DEVICE (wimax));
switch (state) {
case NM_DEVICE_STATE_PREPARE:
case NM_DEVICE_STATE_CONFIG:
case NM_DEVICE_STATE_NEED_AUTH:
case NM_DEVICE_STATE_IP_CONFIG:
case NM_DEVICE_STATE_IP_CHECK:
case NM_DEVICE_STATE_SECONDARIES:
case NM_DEVICE_STATE_ACTIVATED:
case NM_DEVICE_STATE_DEACTIVATING:
break;
default:
return NULL;
break;
}
return NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->active_nsp;
g_return_val_if_reached (NULL);
}
/**
@ -141,9 +94,7 @@ nm_device_wimax_get_active_nsp (NMDeviceWimax *wimax)
const GPtrArray *
nm_device_wimax_get_nsps (NMDeviceWimax *wimax)
{
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
return NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->nsps;
g_return_val_if_reached (NULL);
}
/**
@ -161,43 +112,7 @@ NMWimaxNsp *
nm_device_wimax_get_nsp_by_path (NMDeviceWimax *wimax,
const char *path)
{
const GPtrArray *nsps;
int i;
NMWimaxNsp *nsp = NULL;
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL);
g_return_val_if_fail (path != NULL, NULL);
nsps = nm_device_wimax_get_nsps (wimax);
if (!nsps)
return NULL;
for (i = 0; i < nsps->len; i++) {
NMWimaxNsp *candidate = g_ptr_array_index (nsps, i);
if (!strcmp (nm_object_get_path (NM_OBJECT (candidate)), path)) {
nsp = candidate;
break;
}
}
return nsp;
}
static void
clean_up_nsps (NMDeviceWimax *self)
{
NMDeviceWimaxPrivate *priv;
g_return_if_fail (NM_IS_DEVICE_WIMAX (self));
priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
if (priv->active_nsp) {
g_object_unref (priv->active_nsp);
priv->active_nsp = NULL;
}
g_clear_pointer (&priv->nsps, g_ptr_array_unref);
g_return_val_if_reached (NULL);
}
/**
@ -215,9 +130,7 @@ clean_up_nsps (NMDeviceWimax *self)
guint
nm_device_wimax_get_center_frequency (NMDeviceWimax *self)
{
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->center_freq;
g_return_val_if_reached (0);
}
/**
@ -236,9 +149,7 @@ nm_device_wimax_get_center_frequency (NMDeviceWimax *self)
int
nm_device_wimax_get_rssi (NMDeviceWimax *self)
{
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->rssi;
g_return_val_if_reached (0);
}
/**
@ -256,9 +167,7 @@ nm_device_wimax_get_rssi (NMDeviceWimax *self)
int
nm_device_wimax_get_cinr (NMDeviceWimax *self)
{
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->cinr;
g_return_val_if_reached (0);
}
/**
@ -276,9 +185,7 @@ nm_device_wimax_get_cinr (NMDeviceWimax *self)
int
nm_device_wimax_get_tx_power (NMDeviceWimax *self)
{
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0);
return NM_DEVICE_WIMAX_GET_PRIVATE (self)->tx_power;
g_return_val_if_reached (0);
}
/**
@ -294,245 +201,32 @@ nm_device_wimax_get_tx_power (NMDeviceWimax *self)
const char *
nm_device_wimax_get_bsid (NMDeviceWimax *self)
{
g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), NULL);
return nm_str_not_empty (NM_DEVICE_WIMAX_GET_PRIVATE (self)->bsid);
}
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingWimax *s_wimax;
const char *hwaddr, *setting_hwaddr;
if (!NM_DEVICE_CLASS (nm_device_wimax_parent_class)->connection_compatible (device, connection, error))
return FALSE;
if (!nm_connection_is_type (connection, NM_SETTING_WIMAX_SETTING_NAME)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The connection was not a WiMAX connection."));
return FALSE;
}
/* Check MAC address */
hwaddr = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
if (hwaddr) {
if (!nm_utils_hwaddr_valid (hwaddr, ETH_ALEN)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
_("Invalid device MAC address."));
return FALSE;
}
s_wimax = nm_connection_get_setting_wimax (connection);
setting_hwaddr = nm_setting_wimax_get_mac_address (s_wimax);
if (setting_hwaddr && !nm_utils_hwaddr_matches (setting_hwaddr, -1, hwaddr, -1)) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
_("The MACs of the device and the connection didn't match."));
return FALSE;
}
}
return TRUE;
}
static GType
get_setting_type (NMDevice *device)
{
return NM_TYPE_SETTING_WIMAX;
}
static const char *
get_hw_address (NMDevice *device)
{
return nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
g_return_val_if_reached (0);
}
/*****************************************************************************/
static void
nm_device_wimax_init (NMDeviceWimax *device)
{
g_signal_connect (device,
"notify::" NM_DEVICE_STATE,
G_CALLBACK (state_changed_cb),
NULL);
}
static void
get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
NMDeviceWimax *self = NM_DEVICE_WIMAX (object);
switch (prop_id) {
case PROP_HW_ADDRESS:
g_value_set_string (value, nm_device_wimax_get_hw_address (self));
break;
case PROP_ACTIVE_NSP:
g_value_set_object (value, nm_device_wimax_get_active_nsp (self));
break;
case PROP_CENTER_FREQ:
g_value_set_uint (value, nm_device_wimax_get_center_frequency (self));
break;
case PROP_RSSI:
g_value_set_int (value, nm_device_wimax_get_rssi (self));
break;
case PROP_CINR:
g_value_set_int (value, nm_device_wimax_get_cinr (self));
break;
case PROP_TX_POWER:
g_value_set_int (value, nm_device_wimax_get_tx_power (self));
break;
case PROP_BSID:
g_value_set_string (value, nm_device_wimax_get_bsid (self));
break;
case PROP_NSPS:
g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_wimax_get_nsps (self)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
g_return_if_reached ();
}
static void
clear_link_status (NMDeviceWimax *self)
nm_device_wimax_init (NMDeviceWimax *device)
{
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
if (priv->center_freq) {
priv->center_freq = 0;
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_CENTER_FREQUENCY);
}
if (priv->rssi) {
priv->rssi = 0;
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_RSSI);
}
if (priv->cinr) {
priv->cinr = 0;
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_CINR);
}
if (priv->tx_power) {
priv->tx_power = 0;
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_TX_POWER);
}
if (priv->bsid) {
g_free (priv->bsid);
priv->bsid = NULL;
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_BSID);
}
}
static void
state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
{
NMDeviceWimax *self = NM_DEVICE_WIMAX (device);
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
NMDeviceState state;
state = nm_device_get_state (device);
switch (state) {
case NM_DEVICE_STATE_UNKNOWN:
case NM_DEVICE_STATE_UNMANAGED:
case NM_DEVICE_STATE_UNAVAILABLE:
case NM_DEVICE_STATE_DISCONNECTED:
case NM_DEVICE_STATE_FAILED:
if (priv->active_nsp) {
g_object_unref (priv->active_nsp);
priv->active_nsp = NULL;
}
_nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_WIMAX_ACTIVE_NSP);
clear_link_status (self);
break;
case NM_DEVICE_STATE_PREPARE:
case NM_DEVICE_STATE_CONFIG:
case NM_DEVICE_STATE_NEED_AUTH:
case NM_DEVICE_STATE_IP_CONFIG:
clear_link_status (self);
break;
default:
break;
}
}
static void
init_dbus (NMObject *object)
{
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object);
const NMPropertiesInfo property_info[] = {
{ NM_DEVICE_WIMAX_HW_ADDRESS, &priv->hw_address },
{ NM_DEVICE_WIMAX_ACTIVE_NSP, &priv->active_nsp, NULL, NM_TYPE_WIMAX_NSP },
{ NM_DEVICE_WIMAX_CENTER_FREQUENCY, &priv->center_freq },
{ NM_DEVICE_WIMAX_RSSI, &priv->rssi },
{ NM_DEVICE_WIMAX_CINR, &priv->cinr },
{ NM_DEVICE_WIMAX_TX_POWER, &priv->tx_power },
{ NM_DEVICE_WIMAX_BSID, &priv->bsid },
{ NM_DEVICE_WIMAX_NSPS, &priv->nsps, NULL, NM_TYPE_WIMAX_NSP, "nsp" },
{ NULL },
};
NM_OBJECT_CLASS (nm_device_wimax_parent_class)->init_dbus (object);
_nm_object_register_properties (object,
NM_DBUS_INTERFACE_DEVICE_WIMAX,
property_info);
}
static void
nsp_removed (NMDeviceWimax *self, NMWimaxNsp *nsp)
{
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
if (nsp == priv->active_nsp) {
g_object_unref (priv->active_nsp);
priv->active_nsp = NULL;
_nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_ACTIVE_NSP);
}
}
static void
dispose (GObject *object)
{
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (object);
if (priv->hw_address) {
g_free (priv->hw_address);
priv->hw_address = NULL;
}
if (priv->bsid) {
g_free (priv->bsid);
priv->bsid = NULL;
}
if (priv->nsps)
clean_up_nsps (NM_DEVICE_WIMAX (object));
G_OBJECT_CLASS (nm_device_wimax_parent_class)->dispose (object);
g_return_if_reached ();
}
static void
nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (wimax_class);
NMObjectClass *nm_object_class = NM_OBJECT_CLASS (wimax_class);
NMDeviceClass *device_class = NM_DEVICE_CLASS (wimax_class);
object_class->get_property = get_property;
object_class->dispose = dispose;
nm_object_class->init_dbus = init_dbus;
device_class->connection_compatible = connection_compatible;
device_class->get_setting_type = get_setting_type;
device_class->get_hw_address = get_hw_address;
wimax_class->nsp_removed = nsp_removed;
/**
* NMDeviceWimax:hw-address:
@ -679,8 +373,7 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *wimax_class)
g_signal_new ("nsp-removed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMDeviceWimaxClass, nsp_removed),
NULL, NULL,
0, NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);

View file

@ -33,6 +33,8 @@ G_BEGIN_DECLS
/**
* NMDeviceWimax:
*
* Deprecated: 1.22. WiMAX is no longer supported by NetworkManager since 1.2.0
*/
typedef struct _NMDeviceWimaxClass NMDeviceWimaxClass;

View file

@ -7,13 +7,6 @@
#include "nm-wimax-nsp.h"
#include "nm-connection.h"
#include "nm-setting-connection.h"
#include "nm-setting-wimax.h"
#include "nm-dbus-interface.h"
#include "nm-object-private.h"
#include "nm-enum-types.h"
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
@ -22,15 +15,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_NETWORK_TYPE,
);
typedef struct {
char *name;
guint32 signal_quality;
NMWimaxNspNetworkType network_type;
} NMWimaxNspPrivate;
struct _NMWimaxNsp {
NMObject parent;
NMWimaxNspPrivate _priv;
};
struct _NMWimaxNspClass {
@ -50,13 +36,13 @@ G_DEFINE_TYPE (NMWimaxNsp, nm_wimax_nsp, NM_TYPE_OBJECT)
* Gets the name of the wimax NSP
*
* Returns: the name
*
* Deprecated: 1.22. WiMAX is no longer supported by NetworkManager since 1.2.0
**/
const char *
nm_wimax_nsp_get_name (NMWimaxNsp *nsp)
{
g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), NULL);
return NM_WIMAX_NSP_GET_PRIVATE (nsp)->name;
g_return_val_if_reached (NULL);
}
/**
@ -66,13 +52,13 @@ nm_wimax_nsp_get_name (NMWimaxNsp *nsp)
* Gets the WPA signal quality of the wimax NSP.
*
* Returns: the signal quality
*
* Deprecated: 1.22. WiMAX is no longer supported by NetworkManager since 1.2.0
**/
guint32
nm_wimax_nsp_get_signal_quality (NMWimaxNsp *nsp)
{
g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), 0);
return NM_WIMAX_NSP_GET_PRIVATE (nsp)->signal_quality;
g_return_val_if_reached (0);
}
/**
@ -82,13 +68,13 @@ nm_wimax_nsp_get_signal_quality (NMWimaxNsp *nsp)
* Gets the network type of the wimax NSP.
*
* Returns: the network type
*
* Deprecated: 1.22. WiMAX is no longer supported by NetworkManager since 1.2.0
**/
NMWimaxNspNetworkType
nm_wimax_nsp_get_network_type (NMWimaxNsp *nsp)
{
g_return_val_if_fail (NM_IS_WIMAX_NSP (nsp), NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN);
return NM_WIMAX_NSP_GET_PRIVATE (nsp)->network_type;
g_return_val_if_reached (NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN);
}
/**
@ -102,36 +88,13 @@ nm_wimax_nsp_get_network_type (NMWimaxNsp *nsp)
*
* Returns: %TRUE if the connection may be activated with this WiMAX NSP,
* %FALSE if it cannot be.
*
* Deprecated: 1.22. WiMAX is no longer supported by NetworkManager since 1.2.0
**/
gboolean
nm_wimax_nsp_connection_valid (NMWimaxNsp *nsp, NMConnection *connection)
{
NMSettingConnection *s_con;
NMSettingWimax *s_wimax;
const char *ctype;
const char *nsp_name;
const char *setting_name;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_WIMAX_SETTING_NAME) != 0)
return FALSE;
s_wimax = nm_connection_get_setting_wimax (connection);
if (!s_wimax)
return FALSE;
setting_name = nm_setting_wimax_get_network_name (s_wimax);
if (!setting_name)
return FALSE;
nsp_name = nm_wimax_nsp_get_name (nsp);
g_warn_if_fail (nsp_name != NULL);
if (g_strcmp0 (nsp_name, setting_name) != 0)
return FALSE;
return TRUE;
g_return_val_if_reached (FALSE);
}
/**
@ -147,98 +110,45 @@ nm_wimax_nsp_connection_valid (NMWimaxNsp *nsp, NMConnection *connection)
* Returns: (transfer full) (element-type NMConnection): an array of
* #NMConnections that could be activated with the given @nsp. The array should
* be freed with g_ptr_array_unref() when it is no longer required.
*
* Deprecated: 1.22. WiMAX is no longer supported by NetworkManager since 1.2.0
**/
GPtrArray *
nm_wimax_nsp_filter_connections (NMWimaxNsp *nsp, const GPtrArray *connections)
{
GPtrArray *filtered;
int i;
filtered = g_ptr_array_new_with_free_func (g_object_unref);
for (i = 0; i < connections->len; i++) {
NMConnection *candidate = connections->pdata[i];
if (nm_wimax_nsp_connection_valid (nsp, candidate))
g_ptr_array_add (filtered, g_object_ref (candidate));
}
return filtered;
g_return_val_if_reached (NULL);
}
/*****************************************************************************/
static void
nm_wimax_nsp_init (NMWimaxNsp *nsp)
{
}
static void
finalize (GObject *object)
{
NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (object);
g_free (priv->name);
G_OBJECT_CLASS (nm_wimax_nsp_parent_class)->finalize (object);
}
static void
get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
NMWimaxNsp *nsp = NM_WIMAX_NSP (object);
switch (prop_id) {
case PROP_NAME:
g_value_set_string (value, nm_wimax_nsp_get_name (nsp));
break;
case PROP_SIGNAL_QUALITY:
g_value_set_uint (value, nm_wimax_nsp_get_signal_quality (nsp));
break;
case PROP_NETWORK_TYPE:
g_value_set_enum (value, nm_wimax_nsp_get_network_type (nsp));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
g_return_if_reached ();
}
static void
init_dbus (NMObject *object)
nm_wimax_nsp_init (NMWimaxNsp *nsp)
{
NMWimaxNspPrivate *priv = NM_WIMAX_NSP_GET_PRIVATE (object);
const NMPropertiesInfo property_info[] = {
{ NM_WIMAX_NSP_NAME, &priv->name },
{ NM_WIMAX_NSP_SIGNAL_QUALITY, &priv->signal_quality },
{ NM_WIMAX_NSP_NETWORK_TYPE, &priv->network_type },
{ NULL },
};
NM_OBJECT_CLASS (nm_wimax_nsp_parent_class)->init_dbus (object);
_nm_object_register_properties (object,
NM_DBUS_INTERFACE_WIMAX_NSP,
property_info);
g_return_if_reached ();
}
static void
nm_wimax_nsp_class_init (NMWimaxNspClass *nsp_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (nsp_class);
NMObjectClass *nm_object_class = NM_OBJECT_CLASS (nsp_class);
object_class->get_property = get_property;
object_class->finalize = finalize;
nm_object_class->init_dbus = init_dbus;
/**
* NMWimaxNsp:name:
*
* The name of the WiMAX NSP.
*
* Deprecated: 1.22. WiMAX is no longer supported by NetworkManager since 1.2.0
**/
obj_properties[PROP_NAME] =
g_param_spec_string (NM_WIMAX_NSP_NAME, "", "",
@ -250,6 +160,8 @@ nm_wimax_nsp_class_init (NMWimaxNspClass *nsp_class)
* NMWimaxNsp:signal-quality:
*
* The signal quality of the WiMAX NSP.
*
* Deprecated: 1.22. WiMAX is no longer supported by NetworkManager since 1.2.0
**/
obj_properties[PROP_SIGNAL_QUALITY] =
g_param_spec_uint (NM_WIMAX_NSP_SIGNAL_QUALITY, "", "",
@ -261,6 +173,8 @@ nm_wimax_nsp_class_init (NMWimaxNspClass *nsp_class)
* NMWimaxNsp:network-type:
*
* The network type of the WiMAX NSP.
*
* Deprecated: 1.22. WiMAX is no longer supported by NetworkManager since 1.2.0
**/
obj_properties[PROP_NETWORK_TYPE] =
g_param_spec_enum (NM_WIMAX_NSP_NETWORK_TYPE, "", "",

View file

@ -28,18 +28,25 @@ G_BEGIN_DECLS
/**
* NMWimaxNsp:
*
* Deprecated: 1.22. WiMAX is no longer supported by NetworkManager since 1.2.0
*/
typedef struct _NMWimaxNspClass NMWimaxNspClass;
GType nm_wimax_nsp_get_type (void);
NM_DEPRECATED_IN_1_22
const char * nm_wimax_nsp_get_name (NMWimaxNsp *nsp);
NM_DEPRECATED_IN_1_22
guint32 nm_wimax_nsp_get_signal_quality (NMWimaxNsp *nsp);
NM_DEPRECATED_IN_1_22
NMWimaxNspNetworkType nm_wimax_nsp_get_network_type (NMWimaxNsp *nsp);
NM_DEPRECATED_IN_1_22
GPtrArray * nm_wimax_nsp_filter_connections (NMWimaxNsp *nsp,
const GPtrArray *connections);
NM_DEPRECATED_IN_1_22
gboolean nm_wimax_nsp_connection_valid (NMWimaxNsp *nsp,
NMConnection *connection);

View file

@ -462,208 +462,6 @@ test_wifi_ap_added_removed (void)
/*****************************************************************************/
static const char *expected_nsp_name = "Clear";
typedef struct {
GMainLoop *loop;
gboolean found;
char *nsp_path;
gboolean signaled;
gboolean notified;
guint quit_id;
guint quit_count;
} WimaxNspInfo;
static void
wimax_check_quit (WimaxNspInfo *info)
{
info->quit_count--;
if (info->quit_count == 0) {
g_source_remove (info->quit_id);
info->quit_id = 0;
g_main_loop_quit (info->loop);
}
}
static void
got_nsp_path (WimaxNspInfo *info, const char *path)
{
if (info->nsp_path)
g_assert_cmpstr (info->nsp_path, ==, path);
else
info->nsp_path = g_strdup (path);
}
static void
wimax_nsp_added_cb (NMDeviceWimax *w,
NMWimaxNsp *nsp,
WimaxNspInfo *info)
{
g_assert (nsp);
g_assert_cmpstr (nm_wimax_nsp_get_name (nsp), ==, expected_nsp_name);
got_nsp_path (info, nm_object_get_path (NM_OBJECT (nsp)));
info->signaled = TRUE;
wimax_check_quit (info);
}
static void
wimax_nsp_add_notify_cb (NMDeviceWimax *w,
GParamSpec *pspec,
WimaxNspInfo *info)
{
const GPtrArray *nsps;
NMWimaxNsp *nsp;
nsps = nm_device_wimax_get_nsps (w);
g_assert (nsps);
g_assert_cmpint (nsps->len, ==, 1);
nsp = g_ptr_array_index (nsps, 0);
g_assert (nsp);
g_assert_cmpstr (nm_wimax_nsp_get_name (nsp), ==, expected_nsp_name);
got_nsp_path (info, nm_object_get_path (NM_OBJECT (nsp)));
info->notified = TRUE;
wimax_check_quit (info);
}
static void
wimax_nsp_removed_cb (NMDeviceWimax *w,
NMWimaxNsp *nsp,
WimaxNspInfo *info)
{
g_assert (nsp);
g_assert_cmpstr (info->nsp_path, ==, nm_object_get_path (NM_OBJECT (nsp)));
info->signaled = TRUE;
wimax_check_quit (info);
}
static void
wimax_nsp_remove_notify_cb (NMDeviceWimax *w,
GParamSpec *pspec,
WimaxNspInfo *info)
{
const GPtrArray *nsps;
nsps = nm_device_wimax_get_nsps (w);
g_assert (nsps->len == 0);
info->notified = TRUE;
wimax_check_quit (info);
}
static void
test_wimax_nsp_added_removed (void)
{
NMClient *client;
NMDeviceWimax *wimax;
WimaxNspInfo info = { loop, FALSE, FALSE, 0, 0 };
GVariant *ret;
GError *error = NULL;
char *expected_path = NULL;
sinfo = nmtstc_service_init ();
if (!nmtstc_service_available (sinfo))
return;
client = nm_client_new (NULL, &error);
g_assert_no_error (error);
/*************************************/
/* Add the wimax device */
wimax = (NMDeviceWimax *) nmtstc_service_add_device (sinfo, client, "AddWimaxDevice", "wmx0");
g_assert (NM_IS_DEVICE_WIMAX (wimax));
/*************************************/
/* Add the wimax NSP */
info.signaled = FALSE;
info.notified = FALSE;
info.quit_id = 0;
ret = g_dbus_proxy_call_sync (sinfo->proxy,
"AddWimaxNsp",
g_variant_new ("(ss)", "wmx0", expected_nsp_name),
G_DBUS_CALL_FLAGS_NO_AUTO_START,
3000,
NULL,
&error);
g_assert_no_error (error);
g_assert (ret);
g_assert_cmpstr (g_variant_get_type_string (ret), ==, "(o)");
g_variant_get (ret, "(o)", &expected_path);
g_variant_unref (ret);
g_signal_connect (wimax,
"nsp-added",
(GCallback) wimax_nsp_added_cb,
&info);
info.quit_count = 1;
g_signal_connect (wimax,
"notify::nsps",
(GCallback) wimax_nsp_add_notify_cb,
&info);
info.quit_count++;
/* Wait for libnm to find the AP */
info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
g_main_loop_run (loop);
g_assert (info.signaled);
g_assert (info.notified);
g_assert (info.nsp_path);
g_assert_cmpstr (info.nsp_path, ==, expected_path);
g_signal_handlers_disconnect_by_func (wimax, wimax_nsp_added_cb, &info);
g_signal_handlers_disconnect_by_func (wimax, wimax_nsp_add_notify_cb, &info);
/*************************************/
/* Remove the wimax NSP */
info.signaled = FALSE;
info.notified = FALSE;
info.quit_id = 0;
ret = g_dbus_proxy_call_sync (sinfo->proxy,
"RemoveWimaxNsp",
g_variant_new ("(so)", "wmx0", expected_path),
G_DBUS_CALL_FLAGS_NO_AUTO_START,
3000,
NULL,
&error);
g_assert_no_error (error);
g_clear_pointer (&ret, g_variant_unref);
g_signal_connect (wimax,
"nsp-removed",
(GCallback) wimax_nsp_removed_cb,
&info);
info.quit_count = 1;
g_signal_connect (wimax,
"notify::nsps",
(GCallback) wimax_nsp_remove_notify_cb,
&info);
info.quit_count++;
/* Wait for libnm to find the AP */
info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
g_main_loop_run (loop);
g_assert (info.signaled);
g_assert (info.notified);
g_signal_handlers_disconnect_by_func (wimax, wimax_nsp_removed_cb, &info);
g_signal_handlers_disconnect_by_func (wimax, wimax_nsp_remove_notify_cb, &info);
g_free (info.nsp_path);
g_free (expected_path);
g_object_unref (client);
g_clear_pointer (&sinfo, nmtstc_service_cleanup);
}
/*****************************************************************************/
typedef struct {
GMainLoop *loop;
gboolean signaled;
@ -1655,7 +1453,6 @@ main (int argc, char **argv)
g_test_add_func ("/libnm/device-added", test_device_added);
g_test_add_func ("/libnm/device-added-signal-after-init", test_device_added_signal_after_init);
g_test_add_func ("/libnm/wifi-ap-added-removed", test_wifi_ap_added_removed);
g_test_add_func ("/libnm/wimax-nsp-added-removed", test_wimax_nsp_added_removed);
g_test_add_func ("/libnm/devices-array", test_devices_array);
g_test_add_func ("/libnm/client-nm-running", test_client_nm_running);
g_test_add_func ("/libnm/active-connections", test_active_connections);

View file

@ -330,7 +330,6 @@ IFACE_OBJECT_MANAGER = 'org.freedesktop.DBus.ObjectManager'
IFACE_CONNECTION = 'org.freedesktop.NetworkManager.Settings.Connection'
IFACE_DEVICE = 'org.freedesktop.NetworkManager.Device'
IFACE_WIFI = 'org.freedesktop.NetworkManager.Device.Wireless'
IFACE_WIMAX = 'org.freedesktop.NetworkManager.Device.WiMax'
IFACE_TEST = 'org.freedesktop.NetworkManager.LibnmGlibTest'
IFACE_NM = 'org.freedesktop.NetworkManager'
IFACE_SETTINGS = 'org.freedesktop.NetworkManager.Settings'
@ -339,7 +338,6 @@ IFACE_AGENT = 'org.freedesktop.NetworkManager.SecretAgent'
IFACE_WIRED = 'org.freedesktop.NetworkManager.Device.Wired'
IFACE_VLAN = 'org.freedesktop.NetworkManager.Device.Vlan'
IFACE_WIFI_AP = 'org.freedesktop.NetworkManager.AccessPoint'
IFACE_WIMAX_NSP = 'org.freedesktop.NetworkManager.WiMax.Nsp'
IFACE_ACTIVE_CONNECTION = 'org.freedesktop.NetworkManager.Connection.Active'
IFACE_VPN_CONNECTION = 'org.freedesktop.NetworkManager.VPN.Connection'
IFACE_DNS_MANAGER = 'org.freedesktop.NetworkManager.DnsManager'
@ -376,9 +374,6 @@ class BusErr:
class ApNotFoundException(dbus.DBusException):
_dbus_error_name = IFACE_WIFI + '.AccessPointNotFound'
class NspNotFoundException(dbus.DBusException):
_dbus_error_name = IFACE_WIMAX + '.NspNotFound'
class PermissionDeniedException(dbus.DBusException):
_dbus_error_name = IFACE_NM + '.PermissionDenied'
@ -1086,108 +1081,6 @@ class WifiDevice(Device):
###############################################################################
PRP_WIMAX_NSP_NAME = "Name"
PRP_WIMAX_NSP_SIGNAL_QUALITY = "SignalQuality"
PRP_WIMAX_NSP_NETWORK_TYPE = "NetworkType"
class WimaxNsp(ExportedObj):
path_counter_next = 1
path_prefix = "/org/freedesktop/NetworkManager/Nsp/"
def __init__(self, name):
ExportedObj.__init__(self, ExportedObj.create_path(WimaxNsp))
strength = Util.random_int(self.path, 100)
props = {
PRP_WIMAX_NSP_NAME: name,
PRP_WIMAX_NSP_SIGNAL_QUALITY: dbus.UInt32(strength),
PRP_WIMAX_NSP_NETWORK_TYPE: dbus.UInt32(NM.WimaxNspNetworkType.HOME),
}
self.dbus_interface_add(IFACE_WIMAX_NSP, props, WimaxNsp.PropertiesChanged)
@dbus.service.signal(IFACE_WIMAX_NSP, signature='a{sv}')
def PropertiesChanged(self, changed):
pass
###############################################################################
PRP_WIMAX_NSPS = "Nsps"
PRP_WIMAX_HW_ADDRESS = "HwAddress"
PRP_WIMAX_CENTER_FREQUENCY = "CenterFrequency"
PRP_WIMAX_RSSI = "Rssi"
PRP_WIMAX_CINR = "Cinr"
PRP_WIMAX_TX_POWER = "TxPower"
PRP_WIMAX_BSID = "Bsid"
PRP_WIMAX_ACTIVE_NSP = "ActiveNsp"
class WimaxDevice(Device):
def __init__(self, iface, ident = None):
Device.__init__(self, iface, NM.DeviceType.WIMAX, ident)
mac = Util.random_mac(self.ident)
bsid = Util.random_mac(self.ident + '.bsid')
self.nsps = []
props = {
PRP_WIMAX_HW_ADDRESS: mac,
PRP_WIMAX_CENTER_FREQUENCY: dbus.UInt32(2525),
PRP_WIMAX_RSSI: dbus.Int32(-48),
PRP_WIMAX_CINR: dbus.Int32(24),
PRP_WIMAX_TX_POWER: dbus.Int32(9),
PRP_WIMAX_BSID: bsid,
PRP_WIMAX_NSPS: ExportedObj.to_path_array(self.nsps),
PRP_WIMAX_ACTIVE_NSP: ExportedObj.to_path(None),
}
self.dbus_interface_add(IFACE_WIMAX, props, WimaxDevice.PropertiesChanged)
@dbus.service.method(dbus_interface=IFACE_WIMAX, in_signature='', out_signature='ao')
def GetNspList(self):
return ExportedObj.to_path_array(self.nsps)
@dbus.service.signal(IFACE_WIMAX, signature='o')
def NspAdded(self, nsp_path):
pass
def add_nsp(self, nsp):
nsp.export()
self.nsps.append(nsp)
self._dbus_property_set(IFACE_WIMAX, PRP_WIMAX_NSPS, ExportedObj.to_path_array(self.nsps))
self.NspAdded(ExportedObj.to_path(nsp))
def remove_nsp(self, nsp):
self.nsps.remove(nsp)
self._dbus_property_set(IFACE_WIMAX, PRP_WIMAX_NSPS, ExportedObj.to_path_array(self.nsps))
self.NspRemoved(ExportedObj.to_path(nsp))
nsp.unexport()
@dbus.service.signal(IFACE_WIMAX, signature='o')
def NspRemoved(self, nsp_path):
pass
@dbus.service.signal(IFACE_WIMAX, signature='a{sv}')
def PropertiesChanged(self, changed):
pass
def add_test_nsp(self, name):
nsp = WimaxNsp(name)
self.add_nsp(nsp)
return nsp
def remove_nsp_by_path(self, path):
for nsp in self.nsps:
if nsp.path == path:
self.remove_nsp(nsp)
return
raise BusErr.NspNotFoundException("NSP %s not found" % path)
###############################################################################
PRP_ACTIVE_CONNECTION_CONNECTION = "Connection"
PRP_ACTIVE_CONNECTION_SPECIFIC_OBJECT = "SpecificObject"
PRP_ACTIVE_CONNECTION_ID = "Id"
@ -1603,11 +1496,6 @@ class NetworkManager(ExportedObj):
dev = WifiDevice(ifname)
return ExportedObj.to_path(self.add_device(dev))
@dbus.service.method(IFACE_TEST, in_signature='s', out_signature='o')
def AddWimaxDevice(self, ifname):
dev = WimaxDevice(ifname)
return ExportedObj.to_path(self.add_device(dev))
@dbus.service.method(IFACE_TEST, in_signature='o', out_signature='')
def RemoveDevice(self, path):
d = self.find_device_first(path = path, require = TestError)
@ -1624,16 +1512,6 @@ class NetworkManager(ExportedObj):
d = self.find_device_first(ident = ident, require = TestError)
d.remove_ap_by_path(ap_path)
@dbus.service.method(IFACE_TEST, in_signature='ss', out_signature='o')
def AddWimaxNsp(self, ident, name):
d = self.find_device_first(ident = ident, require = TestError)
return ExportedObj.to_path(d.add_test_nsp(name))
@dbus.service.method(IFACE_TEST, in_signature='so', out_signature='')
def RemoveWimaxNsp(self, ident, nsp_path):
d = self.find_device_first(ident = ident, require = TestError)
d.remove_nsp_by_path(nsp_path)
@dbus.service.method(IFACE_TEST, in_signature='', out_signature='')
def AutoRemoveNextConnection(self):
gl.settings.auto_remove_next_connection()