cli: add support for WWAN connections for 'nmcli con up' (bgo #640020)
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* (C) Copyright 2010 Red Hat, Inc.
|
||||
* (C) Copyright 2011 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
@@ -943,6 +943,60 @@ check_wimax_compatible (NMDeviceWimax *device, NMConnection *connection, GError
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_gsm_compatible (NMGsmDevice *device, NMConnection *connection, GError **error)
|
||||
{
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingGsm *s_gsm;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
|
||||
g_assert (s_con);
|
||||
|
||||
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_GSM_SETTING_NAME)) {
|
||||
g_set_error (error, 0, 0,
|
||||
"The connection was not a GSM connection.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s_gsm = NM_SETTING_GSM (nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM));
|
||||
if (!s_gsm) {
|
||||
g_set_error (error, 0, 0,
|
||||
"The connection was not a valid GSM connection.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_cdma_compatible (NMCdmaDevice *device, NMConnection *connection, GError **error)
|
||||
{
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingCdma *s_cdma;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
|
||||
g_assert (s_con);
|
||||
|
||||
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_CDMA_SETTING_NAME)) {
|
||||
g_set_error (error, 0, 0,
|
||||
"The connection was not a CDMA connection.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s_cdma = NM_SETTING_CDMA (nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA));
|
||||
if (!s_cdma) {
|
||||
g_set_error (error, 0, 0,
|
||||
"The connection was not a valid CDMA connection.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
|
||||
{
|
||||
@@ -959,6 +1013,10 @@ nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection,
|
||||
// return check_olpc_mesh_compatible (NM_DEVICE_OLPC_MESH (device), connection, error);
|
||||
else if (NM_IS_DEVICE_WIMAX (device))
|
||||
return check_wimax_compatible (NM_DEVICE_WIMAX (device), connection, error);
|
||||
else if (NM_IS_GSM_DEVICE (device))
|
||||
return check_gsm_compatible (NM_GSM_DEVICE (device), connection, error);
|
||||
else if (NM_IS_CDMA_DEVICE (device))
|
||||
return check_cdma_compatible (NM_CDMA_DEVICE (device), connection, error);
|
||||
|
||||
g_set_error (error, 0, 0, "unhandled device type '%s'", G_OBJECT_TYPE_NAME (device));
|
||||
return FALSE;
|
||||
|
Reference in New Issue
Block a user