diff --git a/libnm-util/nm-setting-gsm.c b/libnm-util/nm-setting-gsm.c index 82ce4d1336..309c097933 100644 --- a/libnm-util/nm-setting-gsm.c +++ b/libnm-util/nm-setting-gsm.c @@ -76,8 +76,8 @@ typedef struct { char *apn; /* NULL for dynamic */ char *network_id; /* for manual registration or NULL for automatic */ - int network_type; /* One of the NM_GSM_NETWORK_* */ - int band; + int network_type; /* One of the NM_SETTING_GSM_NETWORK_TYPE_* */ + guint32 allowed_bands; /* A bitfield of NM_SETTING_GSM_BAND_* */ char *pin; } NMSettingGsmPrivate; @@ -93,6 +93,7 @@ enum { PROP_BAND, PROP_PIN, PROP_PUK, + PROP_ALLOWED_BANDS, LAST_PROP }; @@ -163,9 +164,16 @@ nm_setting_gsm_get_network_type (NMSettingGsm *setting) int nm_setting_gsm_get_band (NMSettingGsm *setting) { - g_return_val_if_fail (NM_IS_SETTING_GSM (setting), -1); + g_warning ("Tried to get deprecated property " NM_SETTING_GSM_SETTING_NAME "/" NM_SETTING_GSM_BAND); + return -1; +} - return NM_SETTING_GSM_GET_PRIVATE (setting)->band; +guint32 +nm_setting_gsm_get_allowed_bands (NMSettingGsm *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NM_SETTING_GSM_BAND_UNKNOWN); + + return NM_SETTING_GSM_GET_PRIVATE (setting)->allowed_bands; } const char * @@ -306,6 +314,7 @@ set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (object); + const char *str; switch (prop_id) { case PROP_NUMBER: @@ -332,14 +341,20 @@ set_property (GObject *object, guint prop_id, priv->network_type = g_value_get_int (value); break; case PROP_BAND: - priv->band = g_value_get_int (value); + if (g_value_get_int (value) != -1) + g_warning ("Tried to set deprecated property " NM_SETTING_GSM_SETTING_NAME "/" NM_SETTING_GSM_BAND); + break; + case PROP_ALLOWED_BANDS: + priv->allowed_bands = g_value_get_uint (value); break; case PROP_PIN: g_free (priv->pin); priv->pin = g_value_dup_string (value); break; case PROP_PUK: - g_warning ("Tried to set deprecated property " NM_SETTING_GSM_SETTING_NAME "/" NM_SETTING_GSM_PUK); + str = g_value_get_string (value); + if (str && strlen (str)) + g_warning ("Tried to set deprecated property " NM_SETTING_GSM_SETTING_NAME "/" NM_SETTING_GSM_PUK); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -372,13 +387,17 @@ get_property (GObject *object, guint prop_id, case PROP_NETWORK_TYPE: g_value_set_int (value, nm_setting_gsm_get_network_type (setting)); break; - case PROP_BAND: - g_value_set_int (value, nm_setting_gsm_get_band (setting)); + case PROP_ALLOWED_BANDS: + g_value_set_uint (value, nm_setting_gsm_get_allowed_bands (setting)); break; case PROP_PIN: g_value_set_string (value, nm_setting_gsm_get_pin (setting)); break; case PROP_PUK: + /* deprecated */ + break; + case PROP_BAND: + /* deprecated */ break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -447,18 +466,32 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class) g_param_spec_int (NM_SETTING_GSM_NETWORK_TYPE, "Network type", "Network type", - NM_GSM_NETWORK_ANY, - NM_GSM_NETWORK_PREFER_GPRS_EDGE, - NM_GSM_NETWORK_ANY, + NM_SETTING_GSM_NETWORK_TYPE_ANY, + NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE, + NM_SETTING_GSM_NETWORK_TYPE_ANY, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); g_object_class_install_property - (object_class, PROP_BAND, - g_param_spec_int (NM_SETTING_GSM_BAND, - "Band", - "Band", - -1, 5, -1, /* FIXME: Use an enum for it */ - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + (object_class, PROP_ALLOWED_BANDS, + g_param_spec_uint (NM_SETTING_GSM_ALLOWED_BANDS, + "Allowed Bands", + "Bitfield of allowed frequency bands", + NM_SETTING_GSM_BAND_UNKNOWN, + NM_SETTING_GSM_BAND_UNKNOWN + || NM_SETTING_GSM_BAND_ANY + || NM_SETTING_GSM_BAND_EGSM + || NM_SETTING_GSM_BAND_DCS + || NM_SETTING_GSM_BAND_PCS + || NM_SETTING_GSM_BAND_G850 + || NM_SETTING_GSM_BAND_U2100 + || NM_SETTING_GSM_BAND_U1800 + || NM_SETTING_GSM_BAND_U17IV + || NM_SETTING_GSM_BAND_U800 + || NM_SETTING_GSM_BAND_U850 + || NM_SETTING_GSM_BAND_U900 + || NM_SETTING_GSM_BAND_U17IX, + NM_SETTING_GSM_BAND_ANY, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); g_object_class_install_property (object_class, PROP_PIN, @@ -468,6 +501,7 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class) NULL, G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET)); + /* Deprecated properties */ g_object_class_install_property (object_class, PROP_PUK, g_param_spec_string (NM_SETTING_GSM_PUK, @@ -475,4 +509,12 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class) "PUK (DEPRECATED and UNUSED)", NULL, G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET)); + + g_object_class_install_property + (object_class, PROP_BAND, + g_param_spec_int (NM_SETTING_GSM_BAND, + "Band (DEPRECATED and UNUSED)", + "Band (DEPRECATED and UNUSED)", + -1, 5, -1, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); } diff --git a/libnm-util/nm-setting-gsm.h b/libnm-util/nm-setting-gsm.h index 531f54239a..5b6a056455 100644 --- a/libnm-util/nm-setting-gsm.h +++ b/libnm-util/nm-setting-gsm.h @@ -53,25 +53,49 @@ GType nm_setting_gsm_error_get_type (void); #define NM_SETTING_GSM_ERROR nm_setting_gsm_error_quark () GQuark nm_setting_gsm_error_quark (void); -#define NM_SETTING_GSM_NUMBER "number" -#define NM_SETTING_GSM_USERNAME "username" -#define NM_SETTING_GSM_PASSWORD "password" -#define NM_SETTING_GSM_APN "apn" -#define NM_SETTING_GSM_NETWORK_ID "network-id" -#define NM_SETTING_GSM_NETWORK_TYPE "network-type" -#define NM_SETTING_GSM_BAND "band" -#define NM_SETTING_GSM_PIN "pin" +#define NM_SETTING_GSM_NUMBER "number" +#define NM_SETTING_GSM_USERNAME "username" +#define NM_SETTING_GSM_PASSWORD "password" +#define NM_SETTING_GSM_APN "apn" +#define NM_SETTING_GSM_NETWORK_ID "network-id" +#define NM_SETTING_GSM_NETWORK_TYPE "network-type" +#define NM_SETTING_GSM_ALLOWED_BANDS "allowed-bands" +#define NM_SETTING_GSM_PIN "pin" /* DEPRECATED & UNUSED */ -#define NM_SETTING_GSM_PUK "puk" +#define NM_SETTING_GSM_PUK "puk" +#define NM_SETTING_GSM_BAND "band" -enum { - NM_GSM_NETWORK_ANY = -1, - NM_GSM_NETWORK_UMTS_HSPA = 0, - NM_GSM_NETWORK_GPRS_EDGE = 1, - NM_GSM_NETWORK_PREFER_UMTS_HSPA = 2, - NM_GSM_NETWORK_PREFER_GPRS_EDGE = 3 -}; +/* DEPRECATED, use NM_SETTING_NETWORK_TYPE_* instead */ +#define NM_GSM_NETWORK_ANY NM_SETTING_GSM_NETWORK_TYPE_ANY +#define NM_GSM_NETWORK_UMTS_HSPA NM_SETTING_GSM_NETWORK_TYPE_UMTS_HSPA +#define NM_GSM_NETWORK_GPRS_EDGE NM_SETTING_GSM_NETWORK_TYPE_GPRS_EDGE +#define NM_GSM_NETWORK_PREFER_UMTS_HSPA NM_SETTING_GSM_NETWORK_TYPE_PREFER_UMTS_HSPA +#define NM_GSM_NETWORK_PREFER_GPRS_EDGE NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE + +typedef enum { + NM_SETTING_GSM_NETWORK_TYPE_ANY = -1, + NM_SETTING_GSM_NETWORK_TYPE_UMTS_HSPA = 0, + NM_SETTING_GSM_NETWORK_TYPE_GPRS_EDGE = 1, + NM_SETTING_GSM_NETWORK_TYPE_PREFER_UMTS_HSPA = 2, + NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE = 3 +} NMSettingGsmNetworkType; + +typedef enum { + NM_SETTING_GSM_BAND_UNKNOWN = 0x00000000, + NM_SETTING_GSM_BAND_ANY = 0x00000001, + NM_SETTING_GSM_BAND_EGSM = 0x00000002, /* 900 MHz */ + NM_SETTING_GSM_BAND_DCS = 0x00000004, /* 1800 MHz */ + NM_SETTING_GSM_BAND_PCS = 0x00000008, /* 1900 MHz */ + NM_SETTING_GSM_BAND_G850 = 0x00000010, /* 850 MHz */ + NM_SETTING_GSM_BAND_U2100 = 0x00000020, /* WCDMA 3GPP UMTS 2100 MHz (Class I) */ + NM_SETTING_GSM_BAND_U1800 = 0x00000040, /* WCDMA 3GPP UMTS 1800 MHz (Class III) */ + NM_SETTING_GSM_BAND_U17IV = 0x00000080, /* WCDMA 3GPP AWS 1700/2100 MHz (Class IV) */ + NM_SETTING_GSM_BAND_U800 = 0x00000100, /* WCDMA 3GPP UMTS 800 MHz (Class VI) */ + NM_SETTING_GSM_BAND_U850 = 0x00000200, /* WCDMA 3GPP UMTS 850 MHz (Class V) */ + NM_SETTING_GSM_BAND_U900 = 0x00000400, /* WCDMA 3GPP UMTS 900 MHz (Class VIII) */ + NM_SETTING_GSM_BAND_U17IX = 0x00000800, /* WCDMA 3GPP UMTS 1700 MHz (Class IX) */ +} NMSettingGsmNetworkBand; typedef struct { NMSetting parent; @@ -89,16 +113,19 @@ typedef struct { GType nm_setting_gsm_get_type (void); -NMSetting *nm_setting_gsm_new (void); -const char *nm_setting_gsm_get_number (NMSettingGsm *setting); -const char *nm_setting_gsm_get_username (NMSettingGsm *setting); -const char *nm_setting_gsm_get_password (NMSettingGsm *setting); -const char *nm_setting_gsm_get_apn (NMSettingGsm *setting); -const char *nm_setting_gsm_get_network_id (NMSettingGsm *setting); -int nm_setting_gsm_get_network_type (NMSettingGsm *setting); -int nm_setting_gsm_get_band (NMSettingGsm *setting); -const char *nm_setting_gsm_get_pin (NMSettingGsm *setting); -const char *nm_setting_gsm_get_puk (NMSettingGsm *setting); +NMSetting *nm_setting_gsm_new (void); +const char *nm_setting_gsm_get_number (NMSettingGsm *setting); +const char *nm_setting_gsm_get_username (NMSettingGsm *setting); +const char *nm_setting_gsm_get_password (NMSettingGsm *setting); +const char *nm_setting_gsm_get_apn (NMSettingGsm *setting); +const char *nm_setting_gsm_get_network_id (NMSettingGsm *setting); +int nm_setting_gsm_get_network_type (NMSettingGsm *setting); +guint32 nm_setting_gsm_get_allowed_bands (NMSettingGsm *setting); +const char *nm_setting_gsm_get_pin (NMSettingGsm *setting); + +/* DEPRECATED & UNUSED */ +const char *nm_setting_gsm_get_puk (NMSettingGsm *setting); +int nm_setting_gsm_get_band (NMSettingGsm *setting); G_END_DECLS diff --git a/src/modem-manager/nm-modem-gsm.c b/src/modem-manager/nm-modem-gsm.c index 8f5b3b2db0..0493d7476d 100644 --- a/src/modem-manager/nm-modem-gsm.c +++ b/src/modem-manager/nm-modem-gsm.c @@ -226,16 +226,16 @@ create_connect_properties (NMConnection *connection) value_hash_add_str (properties, "password", str); switch (nm_setting_gsm_get_network_type (setting)) { - case NM_GSM_NETWORK_UMTS_HSPA: + case NM_SETTING_GSM_NETWORK_TYPE_UMTS_HSPA: value_hash_add_uint (properties, "network_mode", MM_MODEM_GSM_MODE_3G_ONLY); break; - case NM_GSM_NETWORK_GPRS_EDGE: + case NM_SETTING_GSM_NETWORK_TYPE_GPRS_EDGE: value_hash_add_uint (properties, "network_mode", MM_MODEM_GSM_MODE_2G_ONLY); break; - case NM_GSM_NETWORK_PREFER_UMTS_HSPA: + case NM_SETTING_GSM_NETWORK_TYPE_PREFER_UMTS_HSPA: value_hash_add_uint (properties, "network_mode", MM_MODEM_GSM_MODE_3G_PREFERRED); break; - case NM_GSM_NETWORK_PREFER_GPRS_EDGE: + case NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE: value_hash_add_uint (properties, "network_mode", MM_MODEM_GSM_MODE_2G_PREFERRED); break; default: