summaryrefslogtreecommitdiff
path: root/libnm-util/nm-setting-gsm.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2009-10-07 12:18:57 -0700
committerDan Williams <dcbw@redhat.com>2009-10-07 12:18:57 -0700
commit00f945e54efc112e60ed547c9c7796a7657e4117 (patch)
treecf1cdd145e95c6667842b224215ee98c707423e1 /libnm-util/nm-setting-gsm.c
parent59d89050f255f5a15c1bdcbb33dffa638cfaf695 (diff)
downloadNetworkManager-00f945e54efc112e60ed547c9c7796a7657e4117.tar.gz
gsm: correct GSM band implementation and settings
NM didn't pass it to MM anyway, so it was mainly unused, but the band settings were still wrong. Fix that (and still preserve ABI) by adding a new property for allowed bands that can actually hold all the bands instead of limiting to 16-bits. Clean up some of the deprecation stuff at the same time to make it clearer what's deprecated and what to do about it.
Diffstat (limited to 'libnm-util/nm-setting-gsm.c')
-rw-r--r--libnm-util/nm-setting-gsm.c76
1 files changed, 59 insertions, 17 deletions
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;
+}
+
+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)->band;
+ 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));
}