core: consolidate mobile broadband device types

These days more and more devices are showing up that support a
number of different access technology families in the same hardware,
like Qualcomm Gobi (CDMA and GSM), Pantech UM190 (CDMA and GSM),
Pantech UML290 (CDMA and LTE), LG VL600 (CDMA and LTE), Sierra
320U (GSM and LTE), etc.  The previous scheme of having device
classes based on access technology family simply cannot handle
this hardware and attempting to add LTE to both the CDMA and GSM
device classes would result in a bunch of code duplication that
we don't want.  There's a better way...

Instead, combine both CDMA and GSM device classes into a generic
"Modem" device class that provides capabilities indicating what
access technology families a modem supports, and what families
it supports immediately without a firmware reload.  (Gobi devices
for example require a firmware reload before they can switch
between GSM and CDMA).  This provides the necessary flexibility
to the client and allows us to keep the API stable when the
same consolidation change is made in ModemManager.

The current code doesn't yet allow multi-mode operation internally,
but the API is now what we want it to be and won't need to be
changed.
This commit is contained in:
Dan Williams
2011-02-25 10:16:17 -06:00
parent 3b61adec74
commit 2140dad5e0
33 changed files with 466 additions and 1052 deletions

View File

@@ -46,8 +46,7 @@
#if WITH_WIMAX
#include <nm-device-wimax.h>
#endif
#include <nm-gsm-device.h>
#include <nm-cdma-device.h>
#include <nm-device-modem.h>
#include <nm-device-bt.h>
//#include <nm-device-olpc-mesh.h>
#include <nm-remote-settings.h>
@@ -922,54 +921,46 @@ check_wimax_compatible (NMDeviceWimax *device, NMConnection *connection, GError
#endif
static gboolean
check_gsm_compatible (NMGsmDevice *device, NMConnection *connection, GError **error)
check_modem_compatible (NMDeviceModem *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;
NMDeviceModemCapabilities caps = NM_DEVICE_MODEM_CAPABILITY_NONE;
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;
}
/* Figure out what the modem supports */
caps = nm_device_modem_get_current_capabilities (device);
if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) {
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_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;
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;
}
} else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) {
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;
@@ -993,10 +984,8 @@ nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection,
else if (NM_IS_DEVICE_WIMAX (device))
return check_wimax_compatible (NM_DEVICE_WIMAX (device), connection, error);
#endif
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);
else if (NM_IS_DEVICE_MODEM (device))
return check_modem_compatible (NM_DEVICE_MODEM (device), connection, error);
g_set_error (error, 0, 0, "unhandled device type '%s'", G_OBJECT_TYPE_NAME (device));
return FALSE;