aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2012-07-27 19:46:28 -0500
committerDan Williams <dcbw@redhat.com>2012-08-03 10:53:14 -0500
commit9dfe54399e9faa81cc6ce2002c9f13252d6c6685 (patch)
tree03e81882296f50736b23fa3b65e16796a9461c96
parent1125f232c7516349ab7e4b14abc43b1d53433d69 (diff)
api: move SupportedBands property to Gsm.Network interface
Gsm.Card is really for the SIM, not for anything to do with bands or the device or whatever. Which was a mistake long cleaned up in MM 0.7+, but not in earlier versions. Plus, the SupportedBands and SupportedModes properties were never implemented in any in-tree drivers. In the 0.5/0.6 API, SupportedBands belongs on the Network interface along with the Get/Set methods for bands. The old property on the Card interface is deprecated, but not removed, to preserve backwards compatibility. The SupportedModes property is also deprecated, but not replaced by a corresponding property on the Network interface, because it returned a confusing mix of values (conflating access technology and allowed mode preference), plus it also was never used by in-tree drivers. If we really do need a property that advertises the supported allowed modes of the device (ie 2G_PREFERRED, 2G_ONLY, 3G_ONLY, etc) then we can add one on the Network interface later.
-rw-r--r--introspection/org.freedesktop.ModemManager.Modem.Gsm.Card.xml17
-rw-r--r--introspection/org.freedesktop.ModemManager.Modem.Gsm.Network.xml7
-rw-r--r--introspection/org.freedesktop.ModemManager.Modem.Gsm.xml6
-rw-r--r--src/mm-generic-gsm.c38
-rw-r--r--src/mm-generic-gsm.h11
-rw-r--r--src/mm-modem-gsm-card.c12
-rw-r--r--src/mm-modem-gsm-network.c14
-rw-r--r--src/mm-modem-gsm-network.h2
-rwxr-xr-xtest/info.py71
9 files changed, 126 insertions, 52 deletions
diff --git a/introspection/org.freedesktop.ModemManager.Modem.Gsm.Card.xml b/introspection/org.freedesktop.ModemManager.Modem.Gsm.Card.xml
index 9159052b..aff6ef65 100644
--- a/introspection/org.freedesktop.ModemManager.Modem.Gsm.Card.xml
+++ b/introspection/org.freedesktop.ModemManager.Modem.Gsm.Card.xml
@@ -2,9 +2,13 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.ModemManager.Modem.Gsm.Card">
+ <tp:docstring>
+ This interface implements functionality pertaining to the SIM card.
+ </tp:docstring>
+
<method name="GetImei">
<tp:docstring>
- Get the IMEI of the card.
+ Get the IMEI of the modem.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_gsm_modem_get_imei"/>
@@ -132,15 +136,16 @@
<property name="SupportedBands" type="u" access="read" tp:type="MM_MODEM_GSM_BAND">
<tp:docstring>
- Bands supported by the card. (Note for plugin writers:
- returned value must not contain ANY)
+ DEPRECATED; should not be used in new applications. Use the
+ SupportedBands property of the Gsm.Network interface instead.
</tp:docstring>
</property>
- <property name="SupportedModes" type="u" access="read" tp:type="MM_MODEM_GSM_MODE">
+ <property name="SupportedModes" type="u" access="read" tp:type="MM_MODEM_GSM_DEPRECATED_MODE">
<tp:docstring>
- Network selection modes supported by the card. (Note for plugin writers:
- returned value must not contain ANY)
+ DEPRECATED; should not be used in new applications. Use the
+ AccessTechnology property, AllowedMode property, and the SetAllowedMode()
+ method of the Gsm.Network interface instead.
</tp:docstring>
</property>
diff --git a/introspection/org.freedesktop.ModemManager.Modem.Gsm.Network.xml b/introspection/org.freedesktop.ModemManager.Modem.Gsm.Network.xml
index 5ba6c592..630c237b 100644
--- a/introspection/org.freedesktop.ModemManager.Modem.Gsm.Network.xml
+++ b/introspection/org.freedesktop.ModemManager.Modem.Gsm.Network.xml
@@ -208,6 +208,13 @@
</tp:docstring>
</property>
+ <property name="SupportedBands" type="u" access="read" tp:type="MM_MODEM_GSM_BAND">
+ <tp:docstring>
+ Bands supported by the card. (Note for plugin writers: returned value
+ must not contain ANY)
+ </tp:docstring>
+ </property>
+
<signal name="SignalQuality">
<tp:docstring>
The signal quality changed.
diff --git a/introspection/org.freedesktop.ModemManager.Modem.Gsm.xml b/introspection/org.freedesktop.ModemManager.Modem.Gsm.xml
index ee5076af..f4c50612 100644
--- a/introspection/org.freedesktop.ModemManager.Modem.Gsm.xml
+++ b/introspection/org.freedesktop.ModemManager.Modem.Gsm.xml
@@ -2,11 +2,9 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.ModemManager.Modem.Gsm">
- <tp:flags name="MM_MODEM_GSM_MODE" value-prefix="MM_MODEM_GSM_MODE" type="u">
+ <tp:flags name="MM_MODEM_GSM_DEPRECATED_MODE" value-prefix="MM_MODEM_GSM_DEPRECATED_MODE" type="u">
<tp:docstring>
- A bitfield describing the specific access modes and technologies
- supported by a device and the access technology in-use when connected to
- a mobile network.
+ DEPRECATED; should not be used in new applications.
</tp:docstring>
<tp:flag suffix="UNKNOWN" value="0x0">
<tp:docstring>Unknown or invalid mode.</tp:docstring>
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index 18806414..9172cfaf 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -145,6 +145,9 @@ typedef struct {
/* Facility locks */
MMModemGsmFacility enabled_facilities;
+
+ /* Bands */
+ MMModemGsmBand supported_bands;
} MMGenericGsmPrivate;
static void get_registration_status (MMAtSerialPort *port, MMCallbackInfo *info);
@@ -1327,6 +1330,18 @@ get_allowed_mode_done (MMModem *modem,
}
static void
+get_supported_bands_done (MMModem *modem,
+ MMModemGsmBand bands,
+ GError *error,
+ gpointer user_data)
+{
+ if (modem && !error) {
+ MM_GENERIC_GSM_GET_PRIVATE (modem)->supported_bands = bands;
+ g_object_notify (G_OBJECT (modem), MM_MODEM_GSM_NETWORK_SUPPORTED_BANDS);
+ }
+}
+
+static void
ciev_received (MMAtSerialPort *port,
GMatchInfo *info,
gpointer user_data)
@@ -1935,6 +1950,10 @@ mm_generic_gsm_enable_complete (MMGenericGsm *self,
if (MM_GENERIC_GSM_GET_CLASS (self)->get_allowed_mode)
MM_GENERIC_GSM_GET_CLASS (self)->get_allowed_mode (self, get_allowed_mode_done, NULL);
+ /* Get supported bands */
+ if (MM_GENERIC_GSM_GET_CLASS (self)->get_supported_bands)
+ MM_GENERIC_GSM_GET_CLASS (self)->get_supported_bands (self, get_supported_bands_done, NULL);
+
/* Try again to get facility locks */
if (priv->enabled_facilities == 0)
initial_facility_lock_check (self);
@@ -6676,6 +6695,11 @@ mm_generic_gsm_init (MMGenericGsm *self)
priv->sms_parts = g_hash_table_new (g_direct_hash, g_direct_equal);
mm_properties_changed_signal_register_property (G_OBJECT (self),
+ MM_MODEM_GSM_NETWORK_SUPPORTED_BANDS,
+ "SupportedBands",
+ MM_MODEM_GSM_NETWORK_DBUS_INTERFACE);
+
+ mm_properties_changed_signal_register_property (G_OBJECT (self),
MM_MODEM_GSM_NETWORK_ALLOWED_MODE,
NULL,
MM_MODEM_GSM_NETWORK_DBUS_INTERFACE);
@@ -6743,7 +6767,8 @@ set_property (GObject *object, guint prop_id,
case MM_GENERIC_GSM_PROP_INIT_CMD:
case MM_GENERIC_GSM_PROP_INIT_CMD_OPTIONAL:
case MM_GENERIC_GSM_PROP_SUPPORTED_BANDS:
- case MM_GENERIC_GSM_PROP_SUPPORTED_MODES:
+ case MM_GENERIC_GSM_PROP_DEPRECATED_SUPPORTED_BANDS:
+ case MM_GENERIC_GSM_PROP_DEPRECATED_SUPPORTED_MODES:
case MM_GENERIC_GSM_PROP_ALLOWED_MODE:
case MM_GENERIC_GSM_PROP_ACCESS_TECHNOLOGY:
case MM_GENERIC_GSM_PROP_SIM_IDENTIFIER:
@@ -6822,9 +6847,12 @@ get_property (GObject *object, guint prop_id,
g_value_set_string (value, "X4 &C1");
break;
case MM_GENERIC_GSM_PROP_SUPPORTED_BANDS:
+ g_value_set_uint (value, priv->supported_bands);
+ break;
+ case MM_GENERIC_GSM_PROP_DEPRECATED_SUPPORTED_BANDS:
g_value_set_uint (value, 0);
break;
- case MM_GENERIC_GSM_PROP_SUPPORTED_MODES:
+ case MM_GENERIC_GSM_PROP_DEPRECATED_SUPPORTED_MODES:
g_value_set_uint (value, 0);
break;
case MM_GENERIC_GSM_PROP_ALLOWED_MODE:
@@ -6963,10 +6991,14 @@ mm_generic_gsm_class_init (MMGenericGsmClass *generic_class)
g_object_class_override_property (object_class,
MM_GENERIC_GSM_PROP_SUPPORTED_BANDS,
+ MM_MODEM_GSM_NETWORK_SUPPORTED_BANDS);
+
+ g_object_class_override_property (object_class,
+ MM_GENERIC_GSM_PROP_DEPRECATED_SUPPORTED_BANDS,
MM_MODEM_GSM_CARD_SUPPORTED_BANDS);
g_object_class_override_property (object_class,
- MM_GENERIC_GSM_PROP_SUPPORTED_MODES,
+ MM_GENERIC_GSM_PROP_DEPRECATED_SUPPORTED_MODES,
MM_MODEM_GSM_CARD_SUPPORTED_MODES);
g_object_class_override_property (object_class,
diff --git a/src/mm-generic-gsm.h b/src/mm-generic-gsm.h
index e0c3e6dd..a76d8b5f 100644
--- a/src/mm-generic-gsm.h
+++ b/src/mm-generic-gsm.h
@@ -50,7 +50,8 @@ typedef enum {
MM_GENERIC_GSM_PROP_POWER_DOWN_CMD,
MM_GENERIC_GSM_PROP_INIT_CMD,
MM_GENERIC_GSM_PROP_SUPPORTED_BANDS,
- MM_GENERIC_GSM_PROP_SUPPORTED_MODES,
+ MM_GENERIC_GSM_PROP_DEPRECATED_SUPPORTED_BANDS,
+ MM_GENERIC_GSM_PROP_DEPRECATED_SUPPORTED_MODES,
MM_GENERIC_GSM_PROP_INIT_CMD_OPTIONAL,
MM_GENERIC_GSM_PROP_ALLOWED_MODE,
MM_GENERIC_GSM_PROP_ACCESS_TECHNOLOGY,
@@ -167,6 +168,14 @@ typedef struct {
MMModemUIntFn callback,
gpointer user_data);
+ /* Called by the generic class to get frequency bands supported by the
+ * modem. Any bands returned must be able to be enabled/disabled via the
+ * Gsm.Network interface's SetBand() method.
+ */
+ void (*get_supported_bands) (MMGenericGsm *self,
+ MMModemUIntFn callback,
+ gpointer user_data);
+
/* Called by the generic class to retrieve the SIM's ICCID */
void (*get_sim_iccid) (MMGenericGsm *self,
MMModemStringFn callback,
diff --git a/src/mm-modem-gsm-card.c b/src/mm-modem-gsm-card.c
index abf642af..18341343 100644
--- a/src/mm-modem-gsm-card.c
+++ b/src/mm-modem-gsm-card.c
@@ -643,8 +643,8 @@ mm_modem_gsm_card_init (gpointer g_iface)
g_object_interface_install_property
(g_iface,
g_param_spec_uint (MM_MODEM_GSM_CARD_SUPPORTED_BANDS,
- "Supported Modes",
- "Supported frequency bands of the card",
+ "DEPRECATED: Supported Bands",
+ "DEPRECATED: Supported frequency bands of the card",
MM_MODEM_GSM_BAND_UNKNOWN,
G_MAXUINT32,
MM_MODEM_GSM_BAND_UNKNOWN,
@@ -653,11 +653,11 @@ mm_modem_gsm_card_init (gpointer g_iface)
g_object_interface_install_property
(g_iface,
g_param_spec_uint (MM_MODEM_GSM_CARD_SUPPORTED_MODES,
- "Supported Modes",
- "Supported modes of the card (ex 2G preferred, 3G preferred, 2G only, etc",
- MM_MODEM_GSM_MODE_UNKNOWN,
+ "DEPRECATED: Supported Modes",
+ "DEPRECATED: Supported modes of the card (ex 2G preferred, 3G preferred, 2G only, etc",
+ MM_MODEM_GSM_DEPRECATED_MODE_UNKNOWN,
G_MAXUINT32,
- MM_MODEM_GSM_MODE_UNKNOWN,
+ MM_MODEM_GSM_DEPRECATED_MODE_UNKNOWN,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_interface_install_property
diff --git a/src/mm-modem-gsm-network.c b/src/mm-modem-gsm-network.c
index 2863aafd..462744a8 100644
--- a/src/mm-modem-gsm-network.c
+++ b/src/mm-modem-gsm-network.c
@@ -583,6 +583,16 @@ mm_modem_gsm_network_init (gpointer g_iface)
MM_MODEM_GSM_ACCESS_TECH_UNKNOWN,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_interface_install_property
+ (g_iface,
+ g_param_spec_uint (MM_MODEM_GSM_NETWORK_SUPPORTED_BANDS,
+ "Supported Bands",
+ "Supported frequency bands of the card",
+ MM_MODEM_GSM_BAND_UNKNOWN,
+ G_MAXUINT32,
+ MM_MODEM_GSM_BAND_UNKNOWN,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
/* Signals */
signals[SIGNAL_QUALITY] =
g_signal_new ("signal-quality",
@@ -641,6 +651,10 @@ mm_modem_gsm_network_get_type (void)
g_type_interface_add_prerequisite (network_type, G_TYPE_OBJECT);
g_type_interface_add_prerequisite (network_type, MM_TYPE_MODEM);
dbus_g_object_type_install_info (network_type, &dbus_glib_mm_modem_gsm_network_object_info);
+
+ dbus_g_object_type_register_shadow_property (network_type,
+ "SupportedBands",
+ MM_MODEM_GSM_NETWORK_SUPPORTED_BANDS);
}
return network_type;
diff --git a/src/mm-modem-gsm-network.h b/src/mm-modem-gsm-network.h
index 5b565673..d4aa47eb 100644
--- a/src/mm-modem-gsm-network.h
+++ b/src/mm-modem-gsm-network.h
@@ -29,12 +29,14 @@
#define MM_MODEM_GSM_NETWORK_ALLOWED_MODE "allowed-mode"
#define MM_MODEM_GSM_NETWORK_ACCESS_TECHNOLOGY "access-technology"
+#define MM_MODEM_GSM_NETWORK_SUPPORTED_BANDS "dev-supported-bands"
typedef enum {
MM_MODEM_GSM_NETWORK_PROP_FIRST = 0x1200,
MM_MODEM_GSM_NETWORK_PROP_ALLOWED_MODE = MM_MODEM_GSM_NETWORK_PROP_FIRST,
MM_MODEM_GSM_NETWORK_PROP_ACCESS_TECHNOLOGY,
+ MM_MODEM_GSM_NETWORK_PROP_SUPPORTED_BANDS,
} MMModemGsmNetworkProp;
typedef struct _MMModemGsmNetwork MMModemGsmNetwork;
diff --git a/test/info.py b/test/info.py
index 878adb75..3cb828a8 100755
--- a/test/info.py
+++ b/test/info.py
@@ -106,38 +106,28 @@ def get_gsm_network_mode(modem):
print "Mode: %s" % mode
-def get_gsm_band(modem):
- band = modem.GetBand()
- if band == 0x0:
- band = "Unknown"
- elif band == 0x1:
- band = "Any"
- elif band == 0x2:
- band = "EGSM (900 MHz)"
- elif band == 0x4:
- band = "DCS (1800 MHz)"
- elif band == 0x8:
- band = "PCS (1900 MHz)"
- elif band == 0x10:
- band = "G850 (850 MHz)"
- elif band == 0x20:
- band = "U2100 (WCSMA 2100 MHZ, Class I)"
- elif band == 0x40:
- band = "U1700 (WCDMA 3GPP UMTS1800 MHz, Class III)"
- elif band == 0x80:
- band = "17IV (WCDMA 3GPP AWS 1700/2100 MHz, Class IV)"
- elif band == 0x100:
- band = "U800 (WCDMA 3GPP UMTS800 MHz, Class VI)"
- elif band == 0x200:
- band = "U850 (WCDMA 3GPP UMT850 MHz, Class V)"
- elif band == 0x400:
- band = "U900 (WCDMA 3GPP UMTS900 MHz, Class VIII)"
- elif band == 0x800:
- band = "U17IX (WCDMA 3GPP UMTS MHz, Class IX)"
- else:
- band = "(invalid)"
-
- print "Band: %s" % band
+blist = { 0x2: "EGSM (900 MHz)",
+ 0x4: "DCS (1800 MHz)",
+ 0x8: "PCS (1900 MHz)",
+ 0x10: "G850 (850 MHz)",
+ 0x20: "U2100 (WCSMA 2100 MHZ, Class I)",
+ 0x40: "U1700 (WCDMA 3GPP UMTS1800 MHz, Class III)",
+ 0x80: "17IV (WCDMA 3GPP AWS 1700/2100 MHz, Class IV)",
+ 0x100: "U800 (WCDMA 3GPP UMTS800 MHz, Class VI)",
+ 0x200: "U850 (WCDMA 3GPP UMT850 MHz, Class V)",
+ 0x400: "U900 (WCDMA 3GPP UMTS900 MHz, Class VIII)",
+ 0x800: "U17IX (WCDMA 3GPP UMTS MHz, Class IX)",
+ 0x1000: "U1900 (WCDMA 3GPP UMTS 1900 MHz, Class II)",
+ 0x2000: "U2600 (WCDMA 3GPP UMTS 2600 MHz, Class VII)"
+ }
+
+
+def bands_to_list(bands):
+ b = []
+ for i in sorted(blist.keys()):
+ if bands & i:
+ b.append(blist[i])
+ return b
mm_allowed = { 0: "any",
@@ -224,6 +214,23 @@ def gsm_inspect(proxy, props):
except dbus.exceptions.DBusException, e:
print "Error reading current access technology: %s" % e
+ try:
+ bands = props.Get(MM_DBUS_INTERFACE_MODEM_GSM_NETWORK, "SupportedBands")
+ print "Supported Bands:"
+ blist = bands_to_list (bands)
+ for b in blist:
+ print " %s" % b
+ except dbus.exceptions.DBusException, e:
+ pass
+
+ try:
+ bands = net.GetBand()
+ print "Enabled Bands:"
+ blist = bands_to_list (bands)
+ for b in blist:
+ print " %s" % b
+ except dbus.exceptions.DBusException, e:
+ print "Error reading current bands: %s" % e
bus = dbus.SystemBus()