[network-manager-applet] applet: update for consolidated mobile broadband device classes



commit 273b9b31338c450b8bd0e13b91dfad59fce74df5
Author: Dan Williams <dcbw redhat com>
Date:   Fri Feb 25 12:17:00 2011 -0600

    applet: update for consolidated mobile broadband device classes
    
    Use current capabilities rather than the device class to figure
    out how to treat the device.

 src/applet-device-cdma.c            |   12 +++---
 src/applet-device-gsm.c             |   12 +++---
 src/applet-dialogs.c                |   19 ++++++---
 src/applet.c                        |   70 +++++++++++++++++++---------------
 src/connection-editor/page-mobile.c |   20 ++++++---
 src/gnome-bluetooth/bt-widget.c     |    8 ++--
 src/utils/mobile-wizard.c           |   48 ++++++++++-------------
 src/utils/mobile-wizard.h           |    6 +-
 src/utils/utils.c                   |   19 ++++++---
 9 files changed, 116 insertions(+), 98 deletions(-)
---
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index a7256fb..0e3f81c 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -32,7 +32,7 @@
 #include <nm-setting-cdma.h>
 #include <nm-setting-serial.h>
 #include <nm-setting-ppp.h>
-#include <nm-cdma-device.h>
+#include <nm-device-modem.h>
 #include <nm-utils.h>
 #include <nm-secret-agent.h>
 
@@ -106,7 +106,7 @@ mobile_wizard_done (MobileWizard *wizard,
 		NMSetting *setting;
 		char *uuid, *id;
 
-		if (method->devtype != NM_DEVICE_TYPE_CDMA) {
+		if (method->devtype != NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) {
 			g_warning ("Unexpected device type (not CDMA).");
 			canceled = TRUE;
 			goto done;
@@ -173,7 +173,7 @@ cdma_new_auto_connection (NMDevice *device,
 	info->callback = callback;
 	info->callback_data = callback_data;
 
-	wizard = mobile_wizard_new (NULL, NULL, NM_DEVICE_TYPE_CDMA, FALSE,
+	wizard = mobile_wizard_new (NULL, NULL, NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO, FALSE,
 	                            mobile_wizard_done, info);
 	if (wizard) {
 		mobile_wizard_present (wizard);
@@ -182,7 +182,7 @@ cdma_new_auto_connection (NMDevice *device,
 
 	/* Fall back to something */
 	method = g_malloc0 (sizeof (MobileWizardAccessMethod));
-	method->devtype = NM_DEVICE_TYPE_CDMA;
+	method->devtype = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO;
 	method->provider_name = _("CDMA");
 	mobile_wizard_done (NULL, FALSE, method, info);
 	g_free (method);
@@ -826,7 +826,7 @@ modem_properties_changed (DBusGProxy *proxy,
 static void
 cdma_device_added (NMDevice *device, NMApplet *applet)
 {
-	NMCdmaDevice *cdma = NM_CDMA_DEVICE (device);
+	NMDeviceModem *modem = NM_DEVICE_MODEM (device);
 	CdmaDeviceInfo *info;
 	DBusGConnection *bus;
 	const char *udi;
@@ -871,7 +871,7 @@ cdma_device_added (NMDevice *device, NMApplet *applet)
 		return;
 	}
 
-	g_object_set_data_full (G_OBJECT (cdma), "devinfo", info, cdma_device_info_free);
+	g_object_set_data_full (G_OBJECT (modem), "devinfo", info, cdma_device_info_free);
 
 	/* Registration state change signal */
 	dbus_g_object_register_marshaller (nma_marshal_VOID__UINT_UINT,
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index 51a62a3..52926e4 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -34,7 +34,7 @@
 #include <nm-setting-gsm.h>
 #include <nm-setting-serial.h>
 #include <nm-setting-ppp.h>
-#include <nm-gsm-device.h>
+#include <nm-device-modem.h>
 #include <nm-utils.h>
 #include <nm-secret-agent.h>
 
@@ -131,7 +131,7 @@ mobile_wizard_done (MobileWizard *wizard,
 		NMSetting *setting;
 		char *uuid, *id;
 
-		if (method->devtype != NM_DEVICE_TYPE_GSM) {
+		if (method->devtype != NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) {
 			g_warning ("Unexpected device type (not GSM).");
 			canceled = TRUE;
 			goto done;
@@ -199,7 +199,7 @@ gsm_new_auto_connection (NMDevice *device,
 	info->callback = callback;
 	info->callback_data = callback_data;
 
-	wizard = mobile_wizard_new (NULL, NULL, NM_DEVICE_TYPE_GSM, FALSE,
+	wizard = mobile_wizard_new (NULL, NULL, NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS, FALSE,
 	                            mobile_wizard_done, info);
 	if (wizard) {
 		mobile_wizard_present (wizard);
@@ -208,7 +208,7 @@ gsm_new_auto_connection (NMDevice *device,
 
 	/* Fall back to something */
 	method = g_malloc0 (sizeof (MobileWizardAccessMethod));
-	method->devtype = NM_DEVICE_TYPE_GSM;
+	method->devtype = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS;
 	method->provider_name = _("GSM");
 	mobile_wizard_done (NULL, FALSE, method, info);
 	g_free (method);
@@ -1285,7 +1285,7 @@ modem_properties_changed (DBusGProxy *proxy,
 static void
 gsm_device_added (NMDevice *device, NMApplet *applet)
 {
-	NMGsmDevice *gsm = NM_GSM_DEVICE (device);
+	NMDeviceModem *modem = NM_DEVICE_MODEM (device);
 	GsmDeviceInfo *info;
 	const char *udi;
 	DBusGConnection *bus;
@@ -1337,7 +1337,7 @@ gsm_device_added (NMDevice *device, NMApplet *applet)
 		return;
 	}
 
-	g_object_set_data_full (G_OBJECT (gsm), "devinfo", info, gsm_device_info_free);
+	g_object_set_data_full (G_OBJECT (modem), "devinfo", info, gsm_device_info_free);
 
 	/* Registration info signal */
 	dbus_g_object_register_marshaller (nma_marshal_VOID__UINT_STRING_STRING,
diff --git a/src/applet-dialogs.c b/src/applet-dialogs.c
index ff54653..6d63f11 100644
--- a/src/applet-dialogs.c
+++ b/src/applet-dialogs.c
@@ -27,8 +27,7 @@
 
 #include <nm-device-ethernet.h>
 #include <nm-device-wifi.h>
-#include <nm-gsm-device.h>
-#include <nm-cdma-device.h>
+#include <nm-device-modem.h>
 #include <nm-device-wimax.h>
 
 #include <nm-setting-connection.h>
@@ -393,11 +392,17 @@ info_dialog_add_page (GtkNotebook *notebook,
 	} else if (NM_IS_DEVICE_WIFI (device)) {
 		str = g_strdup_printf (_("802.11 WiFi (%s)"), iface);
 		show_security = TRUE;
-	} else if (NM_IS_GSM_DEVICE (device))
-		str = g_strdup_printf (_("GSM (%s)"), iface);
-	else if (NM_IS_CDMA_DEVICE (device))
-		str = g_strdup_printf (_("CDMA (%s)"), iface);
-	else if (NM_IS_DEVICE_WIMAX (device))
+	} else if (NM_IS_DEVICE_MODEM (device)) {
+		NMDeviceModemCapabilities caps;
+
+		caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
+		if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
+			str = g_strdup_printf (_("GSM (%s)"), iface);
+		else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
+			str = g_strdup_printf (_("CDMA (%s)"), iface);
+		else
+			str = g_strdup_printf (_("Mobile Broadband (%s)"), iface);
+	} else if (NM_IS_DEVICE_WIMAX (device))
 		str = g_strdup_printf (_("WiMAX (%s)"), iface);
 	else
 		str = g_strdup (iface);
diff --git a/src/applet.c b/src/applet.c
index 8cdf4fa..ffda279 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -45,8 +45,7 @@
 #include <NetworkManagerVPN.h>
 #include <nm-device-ethernet.h>
 #include <nm-device-wifi.h>
-#include <nm-gsm-device.h>
-#include <nm-cdma-device.h>
+#include <nm-device-modem.h>
 #include <nm-device-bt.h>
 #include <nm-device-wimax.h>
 #include <nm-utils.h>
@@ -121,18 +120,27 @@ applet_get_best_activating_connection (NMApplet *applet, NMDevice **device)
 				best_dev = candidate_dev;
 				best = candidate;
 			}
-		} else if (NM_IS_CDMA_DEVICE (best_dev)) {
-			if (   NM_IS_DEVICE_ETHERNET (candidate_dev)
-			    || NM_IS_DEVICE_WIFI (candidate_dev)) {
-				best_dev = candidate_dev;
-				best = candidate;
-			}
-		} else if (NM_IS_GSM_DEVICE (best_dev)) {
-			if (   NM_IS_DEVICE_ETHERNET (candidate_dev)
-			    || NM_IS_DEVICE_WIFI (candidate_dev)
-			    || NM_IS_CDMA_DEVICE (candidate_dev)) {
-				best_dev = candidate_dev;
-				best = candidate;
+		} else if (NM_IS_DEVICE_MODEM (best_dev)) {
+			NMDeviceModemCapabilities best_caps;
+			NMDeviceModemCapabilities candidate_caps = NM_DEVICE_MODEM_CAPABILITY_NONE;
+
+			best_caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (best_dev));
+			if (NM_IS_DEVICE_MODEM (candidate_dev))
+				candidate_caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (candidate_dev));
+
+			if (best_caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) {
+				if (   NM_IS_DEVICE_ETHERNET (candidate_dev)
+				    || NM_IS_DEVICE_WIFI (candidate_dev)) {
+					best_dev = candidate_dev;
+					best = candidate;
+				}
+			} else if (best_caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) {
+				if (   NM_IS_DEVICE_ETHERNET (candidate_dev)
+					|| NM_IS_DEVICE_WIFI (candidate_dev)
+					|| (candidate_caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) {
+					best_dev = candidate_dev;
+					best = candidate;
+				}
 			}
 		}
 	}
@@ -273,11 +281,17 @@ get_device_class (NMDevice *device, NMApplet *applet)
 		return applet->wired_class;
 	else if (NM_IS_DEVICE_WIFI (device))
 		return applet->wifi_class;
-	else if (NM_IS_GSM_DEVICE (device))
-		return applet->gsm_class;
-	else if (NM_IS_CDMA_DEVICE (device))
-		return applet->cdma_class;
-	else if (NM_IS_DEVICE_BT (device))
+	else if (NM_IS_DEVICE_MODEM (device)) {
+		NMDeviceModemCapabilities caps;
+
+		caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
+		if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
+			return applet->gsm_class;
+		else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
+			return applet->cdma_class;
+		else
+			g_message ("%s: unhandled modem capabilities 0x%X", __func__, caps);
+	} else if (NM_IS_DEVICE_BT (device))
 		return applet->bt_class;
 	else if (NM_IS_DEVICE_WIMAX (device))
 		return applet->wimax_class;
@@ -1190,16 +1204,10 @@ sort_devices (gconstpointer a, gconstpointer b)
 	if (bb_type == NM_TYPE_DEVICE_ETHERNET)
 		return 1;
 
-	/* GSM next */
-	if (aa_type == NM_TYPE_GSM_DEVICE)
-		return -1;
-	if (bb_type == NM_TYPE_GSM_DEVICE)
-		return 1;
-
-	/* CDMA next */
-	if (aa_type == NM_TYPE_CDMA_DEVICE)
+	/* Modems next */
+	if (aa_type == NM_TYPE_DEVICE_MODEM)
 		return -1;
-	if (bb_type == NM_TYPE_CDMA_DEVICE)
+	if (bb_type == NM_TYPE_DEVICE_MODEM)
 		return 1;
 
 	/* Bluetooth next */
@@ -1402,7 +1410,7 @@ nma_menu_add_devices (GtkWidget *menu, NMApplet *applet)
 				n_usable_wifi_devices++;
 		} else if (NM_IS_DEVICE_ETHERNET (device))
 			n_wired_devices++;
-		else if (NM_IS_CDMA_DEVICE (device) || NM_IS_GSM_DEVICE (device))
+		else if (NM_IS_DEVICE_MODEM (device))
 			n_mb_devices++;
 		else if (NM_IS_DEVICE_BT (device))
 			n_bt_devices++;
@@ -1428,7 +1436,7 @@ nma_menu_add_devices (GtkWidget *menu, NMApplet *applet)
 			n_devices = n_wifi_devices;
 		else if (NM_IS_DEVICE_ETHERNET (device))
 			n_devices = n_wired_devices;
-		else if (NM_IS_CDMA_DEVICE (device) || NM_IS_GSM_DEVICE (device))
+		else if (NM_IS_DEVICE_MODEM (device))
 			n_devices = n_mb_devices;
 
 		active = applet_find_active_connection_for_device (device, applet, NULL);
@@ -1810,7 +1818,7 @@ nma_context_menu_update (NMApplet *applet)
 
 			if (NM_IS_DEVICE_WIFI (candidate))
 				have_wireless = TRUE;
-			else if (NM_IS_SERIAL_DEVICE (candidate))
+			else if (NM_IS_DEVICE_MODEM (candidate))
 				have_wwan = TRUE;
 			else if (NM_IS_DEVICE_WIMAX (candidate))
 				have_wimax = TRUE;
diff --git a/src/connection-editor/page-mobile.c b/src/connection-editor/page-mobile.c
index efebdb0..ed8b087 100644
--- a/src/connection-editor/page-mobile.c
+++ b/src/connection-editor/page-mobile.c
@@ -205,7 +205,7 @@ apn_button_mobile_wizard_done (MobileWizard *wizard,
 
 	if (!canceled && method) {
 		switch (method->devtype) {
-		case NM_DEVICE_TYPE_GSM:
+		case NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS:
 			gtk_entry_set_text (GTK_ENTRY (priv->username),
 			                    method->username ? method->username : "");
 			gtk_entry_set_text (GTK_ENTRY (priv->password),
@@ -213,6 +213,12 @@ apn_button_mobile_wizard_done (MobileWizard *wizard,
 			gtk_entry_set_text (GTK_ENTRY (priv->apn),
 			                    method->gsm_apn ? method->gsm_apn : "");
 			break;
+		case NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO:
+			gtk_entry_set_text (GTK_ENTRY (priv->username),
+			                    method->username ? method->username : "");
+			gtk_entry_set_text (GTK_ENTRY (priv->password),
+			                    method->password ? method->password : "");
+			break;
 		default:
 			g_assert_not_reached ();
 			break;
@@ -240,7 +246,7 @@ apn_button_clicked (GtkButton *button, gpointer user_data)
 
 	wizard = mobile_wizard_new (GTK_WINDOW (toplevel),
 	                            priv->window_group,
-	                            NM_DEVICE_TYPE_GSM,
+	                            NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS,
 	                            FALSE,
 	                            apn_button_mobile_wizard_done,
 	                            self);
@@ -544,7 +550,7 @@ new_connection_mobile_wizard_done (MobileWizard *wizard,
 		char *detail = NULL;
 
 		switch (method->devtype) {
-		case NM_DEVICE_TYPE_GSM:
+		case NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS:
 			ctype = NM_SETTING_GSM_SETTING_NAME;
 			type_setting = nm_setting_gsm_new ();
 			/* De-facto standard for GSM */
@@ -555,7 +561,7 @@ new_connection_mobile_wizard_done (MobileWizard *wizard,
 			              NM_SETTING_GSM_APN, method->gsm_apn,
 			              NULL);
 			break;
-		case NM_DEVICE_TYPE_CDMA:
+		case NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO:
 			ctype = NM_SETTING_CDMA_SETTING_NAME;
 			type_setting = nm_setting_cdma_new ();
 			/* De-facto standard for CDMA */
@@ -613,7 +619,7 @@ mobile_connection_new (GtkWindow *parent,
 	info->get_connections_func = get_connections_func;
 	info->user_data = user_data;
 
-	wizard = mobile_wizard_new (parent, NULL, NM_DEVICE_TYPE_UNKNOWN, FALSE,
+	wizard = mobile_wizard_new (parent, NULL, NM_DEVICE_MODEM_CAPABILITY_NONE, FALSE,
 	                            new_connection_mobile_wizard_done, info);
 	if (wizard) {
 		mobile_wizard_present (wizard);
@@ -669,10 +675,10 @@ mobile_connection_new (GtkWindow *parent,
 	response = gtk_dialog_run (GTK_DIALOG (dialog));
 	if (response == GTK_RESPONSE_OK) {
 		if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cdma_radio))) {
-			method.devtype = NM_DEVICE_TYPE_CDMA;
+			method.devtype = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO;
 			method.provider_name = _("CDMA");
 		} else {
-			method.devtype = NM_DEVICE_TYPE_GSM;
+			method.devtype = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS;
 			method.provider_name = _("GSM");
 		}
 	}
diff --git a/src/gnome-bluetooth/bt-widget.c b/src/gnome-bluetooth/bt-widget.c
index 5715a05..4c09c1c 100644
--- a/src/gnome-bluetooth/bt-widget.c
+++ b/src/gnome-bluetooth/bt-widget.c
@@ -510,9 +510,9 @@ wizard_done_cb (MobileWizard *self,
 		return;
 	}
 
-	if (method->devtype == NM_DEVICE_TYPE_CDMA)
+	if (method->devtype == NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
 		connection = dun_new_cdma (method);
-	else if (method->devtype == NM_DEVICE_TYPE_GSM)
+	else if (method->devtype == NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
 		connection = dun_new_gsm (method);
 	else {
 		dun_error (info, __func__, NULL, _("Unknown phone device type (not GSM or CDMA)"));
@@ -584,10 +584,10 @@ modem_get_all_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
 			if (value && G_VALUE_HOLDS_UINT (value)) {
 				switch (g_value_get_uint (value)) {
 				case 1:
-					devtype = NM_DEVICE_TYPE_GSM;
+					devtype = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS;
 					break;
 				case 2:
-					devtype = NM_DEVICE_TYPE_CDMA;
+					devtype = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO;
 					break;
 				default:
 					g_message ("%s: (%s) unknown modem type", __func__, path);
diff --git a/src/utils/mobile-wizard.c b/src/utils/mobile-wizard.c
index 8e96f57..381189a 100644
--- a/src/utils/mobile-wizard.c
+++ b/src/utils/mobile-wizard.c
@@ -31,8 +31,7 @@
 #include <nm-setting-gsm.h>
 #include <nm-setting-cdma.h>
 #include <nm-client.h>
-#include <nm-gsm-device.h>
-#include <nm-cdma-device.h>
+#include <nm-device-modem.h>
 
 #include "mobile-wizard.h"
 #include "nmn-mobile-providers.h"
@@ -150,10 +149,10 @@ assistant_closed (GtkButton *button, gpointer user_data)
 
 	switch (method_type) {
 	case NMN_MOBILE_ACCESS_METHOD_TYPE_GSM:
-		wiz_method->devtype = NM_DEVICE_TYPE_GSM;
+		wiz_method->devtype = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS;
 		break;
 	case NMN_MOBILE_ACCESS_METHOD_TYPE_CDMA:
-		wiz_method->devtype = NM_DEVICE_TYPE_CDMA;
+		wiz_method->devtype = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO;
 		break;
 	default:
 		g_assert_not_reached ();
@@ -1131,11 +1130,16 @@ __intro_device_added (MobileWizard *self, NMDevice *device, gboolean select_it)
 {
 	GtkTreeIter iter;
 	const char *desc = utils_get_device_description (device);
+	NMDeviceModemCapabilities caps;
 
-	if (NM_IS_GSM_DEVICE (device)) {
+	if (!NM_IS_DEVICE_MODEM (device))
+		return FALSE;
+
+	caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
+	if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) {
 		if (!desc)
 			desc = _("Installed GSM device");
-	} else if (NM_IS_CDMA_DEVICE (device)) {
+	} else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) {
 		if (!desc)
 			desc = _("Installed CDMA device");
 	} else
@@ -1271,6 +1275,7 @@ intro_combo_changed (MobileWizard *self)
 {
 	GtkTreeIter iter;
 	NMDevice *selected = NULL;
+	NMDeviceModemCapabilities caps;
 
 	g_free (self->dev_desc);
 	self->dev_desc = NULL;
@@ -1282,14 +1287,13 @@ intro_combo_changed (MobileWizard *self)
 	                    INTRO_COL_DEVICE, &selected, -1);
 	if (selected) {
 		self->dev_desc = g_strdup (utils_get_device_description (selected));
-		if (NM_IS_GSM_DEVICE (selected))
+		caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (selected));
+		if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
 			self->method_type = NMN_MOBILE_ACCESS_METHOD_TYPE_GSM;
-		else if (NM_IS_CDMA_DEVICE (selected))
+		else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
 			self->method_type = NMN_MOBILE_ACCESS_METHOD_TYPE_CDMA;
-		else {
-			g_warning ("%s: unknown device type '%s'", __func__,
-			           G_OBJECT_TYPE_NAME (selected));
-		}
+		else
+			g_warning ("%s: unknown modem capabilities 0x%X", __func__, caps);
 
 		g_object_unref (selected);
 	}
@@ -1517,7 +1521,7 @@ get_country_from_locale (void)
 MobileWizard *
 mobile_wizard_new (GtkWindow *parent,
                    GtkWindowGroup *window_group,
-                   NMDeviceType devtype,
+                   NMDeviceModemCapabilities modem_caps,
                    gboolean will_connect_after,
                    MobileWizardCallback cb,
                    gpointer user_data)
@@ -1542,22 +1546,12 @@ mobile_wizard_new (GtkWindow *parent,
 	self->will_connect_after = will_connect_after;
 	self->callback = cb;
 	self->user_data = user_data;
-	if (devtype != NM_DEVICE_TYPE_UNKNOWN)
-		self->initial_method_type = TRUE;
-	switch (devtype) {
-	case NM_DEVICE_TYPE_UNKNOWN:
-		break;
-	case NM_DEVICE_TYPE_GSM:
+	if (modem_caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
 		self->method_type = NMN_MOBILE_ACCESS_METHOD_TYPE_GSM;
-		break;
-	case NM_DEVICE_TYPE_CDMA:
+	else if (modem_caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
 		self->method_type = NMN_MOBILE_ACCESS_METHOD_TYPE_CDMA;
-		break;
-	default:
-		g_warning ("%s: invalid device type %d", __func__, devtype);
-		mobile_wizard_destroy (self);
-		return NULL;
-	}
+	else
+		self->initial_method_type = TRUE;
 
 	self->assistant = gtk_assistant_new ();
 	gtk_assistant_set_forward_page_func (GTK_ASSISTANT (self->assistant),
diff --git a/src/utils/mobile-wizard.h b/src/utils/mobile-wizard.h
index d205953..0fc3e6c 100644
--- a/src/utils/mobile-wizard.h
+++ b/src/utils/mobile-wizard.h
@@ -17,7 +17,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 2008 Red Hat, Inc.
+ * (C) Copyright 2008 - 2011 Red Hat, Inc.
  */
 
 #ifndef MOBILE_WIZARD_H
@@ -32,7 +32,7 @@ typedef struct MobileWizard MobileWizard;
 typedef struct {
 	char *provider_name;
 	char *plan_name;
-	NMDeviceType devtype;
+	NMDeviceModemCapabilities devtype;
 	char *username;
 	char *password;
 	char *gsm_apn;
@@ -45,7 +45,7 @@ typedef void (*MobileWizardCallback) (MobileWizard *self,
 
 MobileWizard *mobile_wizard_new (GtkWindow *parent,
                                  GtkWindowGroup *window_group,
-                                 NMDeviceType devtype,
+                                 NMDeviceModemCapabilities modem_caps,
                                  gboolean will_connect_after,
                                  MobileWizardCallback cb,
                                  gpointer user_data);
diff --git a/src/utils/utils.c b/src/utils/utils.c
index 32cb5fd..8b5cc46 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -28,8 +28,7 @@
 #include <nm-device-ethernet.h>
 #include <nm-device-wifi.h>
 #include <nm-device-bt.h>
-#include <nm-gsm-device.h>
-#include <nm-cdma-device.h>
+#include <nm-device-modem.h>
 #include <nm-device-wimax.h>
 #include <nm-access-point.h>
 
@@ -598,11 +597,17 @@ utils_connection_valid_for_device (NMConnection *connection,
 		return connection_valid_for_wired (connection, s_con, device, specific_object);
 	else if (NM_IS_DEVICE_WIFI (device))
 		return connection_valid_for_wireless (connection, s_con, device, specific_object);
-	else if (NM_IS_GSM_DEVICE (device))
-		return connection_valid_for_gsm (connection, s_con, device, specific_object);
-	else if (NM_IS_CDMA_DEVICE (device))
-		return connection_valid_for_cdma (connection, s_con, device, specific_object);
-	else if (NM_IS_DEVICE_BT (device))
+	else if (NM_IS_DEVICE_MODEM (device)) {
+		NMDeviceModemCapabilities caps;
+
+		caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
+		if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
+			return connection_valid_for_gsm (connection, s_con, device, specific_object);
+		else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
+			return connection_valid_for_cdma (connection, s_con, device, specific_object);
+		else
+			g_warning ("Unhandled modem capabilities 0x%X", caps);
+	} else if (NM_IS_DEVICE_BT (device))
 		return connection_valid_for_bt (connection, s_con, device, specific_object);
 	else if (NM_IS_DEVICE_WIMAX (device))
 		return connection_valid_for_wimax (connection, s_con, device, specific_object);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]