Merge remote branch 'origin/master' into qcdm
This commit is contained in:
@@ -22,9 +22,10 @@
|
||||
#include "mm-auth-request.h"
|
||||
|
||||
/* Authorizations */
|
||||
#define MM_AUTHORIZATION_DEVICE "org.freedesktop.ModemManager.Device"
|
||||
#define MM_AUTHORIZATION_CONTACTS "org.freedesktop.ModemManager.Contacts"
|
||||
#define MM_AUTHORIZATION_SMS "org.freedesktop.ModemManager.SMS"
|
||||
#define MM_AUTHORIZATION_DEVICE_INFO "org.freedesktop.ModemManager.Device.Info"
|
||||
#define MM_AUTHORIZATION_DEVICE_CONTROL "org.freedesktop.ModemManager.Device.Control"
|
||||
#define MM_AUTHORIZATION_CONTACTS "org.freedesktop.ModemManager.Contacts"
|
||||
#define MM_AUTHORIZATION_SMS "org.freedesktop.ModemManager.SMS"
|
||||
/******************/
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 - 2009 Novell, Inc.
|
||||
* Copyright (C) 2009 Red Hat, Inc.
|
||||
* Copyright (C) 2009 - 2010 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef MM_GENERIC_GSM_H
|
||||
@@ -43,7 +43,9 @@ typedef enum {
|
||||
MM_GENERIC_GSM_PROP_INIT_CMD,
|
||||
MM_GENERIC_GSM_PROP_SUPPORTED_BANDS,
|
||||
MM_GENERIC_GSM_PROP_SUPPORTED_MODES,
|
||||
MM_GENERIC_GSM_PROP_INIT_CMD_OPTIONAL
|
||||
MM_GENERIC_GSM_PROP_INIT_CMD_OPTIONAL,
|
||||
MM_GENERIC_GSM_PROP_ALLOWED_MODE,
|
||||
MM_GENERIC_GSM_PROP_ACCESS_TECHNOLOGY
|
||||
} MMGenericGsmProp;
|
||||
|
||||
|
||||
@@ -59,9 +61,41 @@ typedef struct {
|
||||
* that need to perform custom initialization sequences or other setup should
|
||||
* generally override this method instead of the MMModem interface's enable()
|
||||
* method, unless the customization must happen *after* the generic init
|
||||
* sequence has completed.
|
||||
* sequence has completed. When the subclass' enable attempt is complete
|
||||
* the subclass should call mm_generic_gsm_enable_complete() with any error
|
||||
* encountered during the process and the MMCallbackInfo created from the
|
||||
* callback and user_data passed in here.
|
||||
*/
|
||||
void (*do_enable) (MMGenericGsm *self, MMModemFn callback, gpointer user_data);
|
||||
|
||||
/* Called after the generic class has attempted to power up the modem.
|
||||
* Subclasses can handle errors here if they know the device supports their
|
||||
* power up command. Will only be called if the device does *not* override
|
||||
* the MMModem enable() command or allows the generic class' do_enable()
|
||||
* handler to execute.
|
||||
*/
|
||||
void (*do_enable_power_up_done) (MMGenericGsm *self,
|
||||
GString *response,
|
||||
GError *error,
|
||||
MMCallbackInfo *info);
|
||||
|
||||
/* Called by the generic class to set the allowed operating mode of the device */
|
||||
void (*set_allowed_mode) (MMGenericGsm *self,
|
||||
MMModemGsmAllowedMode mode,
|
||||
MMModemFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
/* Called by the generic class to get the allowed operating mode of the device */
|
||||
void (*get_allowed_mode) (MMGenericGsm *self,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
/* Called by the generic class to the current radio access technology the
|
||||
* device is using while communicating with the base station.
|
||||
*/
|
||||
void (*get_access_technology) (MMGenericGsm *self,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data);
|
||||
} MMGenericGsmClass;
|
||||
|
||||
GType mm_generic_gsm_get_type (void);
|
||||
@@ -74,10 +108,7 @@ MMModem *mm_generic_gsm_new (const char *device,
|
||||
|
||||
#define MM_GENERIC_GSM_PREV_STATE_TAG "prev-state"
|
||||
|
||||
void mm_generic_gsm_set_unsolicited_registration (MMGenericGsm *modem,
|
||||
gboolean enabled);
|
||||
|
||||
void mm_generic_gsm_pending_registration_stop (MMGenericGsm *modem);
|
||||
void mm_generic_gsm_pending_registration_stop (MMGenericGsm *modem);
|
||||
|
||||
void mm_generic_gsm_set_cid (MMGenericGsm *modem,
|
||||
guint32 cid);
|
||||
@@ -86,6 +117,22 @@ guint32 mm_generic_gsm_get_cid (MMGenericGsm *modem);
|
||||
void mm_generic_gsm_set_reg_status (MMGenericGsm *modem,
|
||||
MMModemGsmNetworkRegStatus status);
|
||||
|
||||
/* Called to asynchronously update the current allowed operating mode that the
|
||||
* device is allowed to use when connecting to a network. This isn't the
|
||||
* specific access technology the device is currently using (see
|
||||
* mm_generic_gsm_set_access_technology() for that) but the mode the device is
|
||||
* allowed to choose from when connecting.
|
||||
*/
|
||||
void mm_generic_gsm_update_allowed_mode (MMGenericGsm *modem,
|
||||
MMModemGsmAllowedMode mode);
|
||||
|
||||
/* Called to asynchronously update the current access technology of the device;
|
||||
* this is NOT the 2G/3G mode preference, but the current radio access
|
||||
* technology being used to communicate with the base station.
|
||||
*/
|
||||
void mm_generic_gsm_update_access_technology (MMGenericGsm *modem,
|
||||
MMModemGsmAccessTech act);
|
||||
|
||||
void mm_generic_gsm_check_pin (MMGenericGsm *modem,
|
||||
MMModemFn callback,
|
||||
gpointer user_data);
|
||||
|
@@ -265,6 +265,9 @@ mm_modem_base_init (MMModemBase *self)
|
||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||
MM_MODEM_ENABLED,
|
||||
MM_MODEM_DBUS_INTERFACE);
|
||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||
MM_MODEM_UNLOCK_REQUIRED,
|
||||
MM_MODEM_DBUS_INTERFACE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -212,7 +212,7 @@ impl_modem_cdma_get_esn (MMModemCdma *self, DBusGMethodInvocation *context)
|
||||
|
||||
/* Make sure the caller is authorized to get the ESN */
|
||||
if (!mm_modem_auth_request (MM_MODEM (self),
|
||||
MM_AUTHORIZATION_DEVICE,
|
||||
MM_AUTHORIZATION_DEVICE_INFO,
|
||||
context,
|
||||
esn_auth_cb,
|
||||
NULL,
|
||||
|
@@ -225,7 +225,7 @@ impl_gsm_modem_get_imei (MMModemGsmCard *modem, DBusGMethodInvocation *context)
|
||||
|
||||
/* Make sure the caller is authorized to get the IMEI */
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE,
|
||||
MM_AUTHORIZATION_DEVICE_INFO,
|
||||
context,
|
||||
imei_auth_cb,
|
||||
NULL,
|
||||
@@ -262,7 +262,7 @@ impl_gsm_modem_get_imsi (MMModemGsmCard *modem, DBusGMethodInvocation *context)
|
||||
|
||||
/* Make sure the caller is authorized to get the IMSI */
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE,
|
||||
MM_AUTHORIZATION_DEVICE_INFO,
|
||||
context,
|
||||
imsi_auth_cb,
|
||||
NULL,
|
||||
@@ -343,7 +343,7 @@ impl_gsm_modem_send_puk (MMModemGsmCard *modem,
|
||||
|
||||
/* Make sure the caller is authorized to send the PUK */
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE,
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
context,
|
||||
send_puk_auth_cb,
|
||||
info,
|
||||
@@ -386,7 +386,7 @@ impl_gsm_modem_send_pin (MMModemGsmCard *modem,
|
||||
|
||||
/* Make sure the caller is authorized to unlock the modem */
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE,
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
context,
|
||||
send_pin_auth_cb,
|
||||
info,
|
||||
@@ -430,7 +430,7 @@ impl_gsm_modem_enable_pin (MMModemGsmCard *modem,
|
||||
|
||||
/* Make sure the caller is authorized to enable a PIN */
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE,
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
context,
|
||||
enable_pin_auth_cb,
|
||||
info,
|
||||
@@ -474,7 +474,7 @@ impl_gsm_modem_change_pin (MMModemGsmCard *modem,
|
||||
|
||||
/* Make sure the caller is authorized to change the PIN */
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE,
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
context,
|
||||
change_pin_auth_cb,
|
||||
info,
|
||||
@@ -503,7 +503,7 @@ mm_modem_gsm_card_init (gpointer g_iface)
|
||||
"Supported Modes",
|
||||
"Supported frequency bands of the card",
|
||||
MM_MODEM_GSM_BAND_UNKNOWN,
|
||||
MM_MODEM_GSM_BAND_LAST,
|
||||
G_MAXUINT32,
|
||||
MM_MODEM_GSM_BAND_UNKNOWN,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
@@ -513,7 +513,7 @@ mm_modem_gsm_card_init (gpointer g_iface)
|
||||
"Supported Modes",
|
||||
"Supported modes of the card (ex 2G preferred, 3G preferred, 2G only, etc",
|
||||
MM_MODEM_GSM_MODE_UNKNOWN,
|
||||
MM_MODEM_GSM_MODE_LAST,
|
||||
G_MAXUINT32,
|
||||
MM_MODEM_GSM_MODE_UNKNOWN,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
* Copyright (C) 2010 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
@@ -42,8 +43,12 @@ static void impl_gsm_modem_set_band (MMModemGsmNetwork *modem,
|
||||
static void impl_gsm_modem_get_band (MMModemGsmNetwork *modem,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_gsm_modem_set_allowed_mode (MMModemGsmNetwork *modem,
|
||||
MMModemGsmAllowedMode mode,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_gsm_modem_set_network_mode (MMModemGsmNetwork *modem,
|
||||
MMModemGsmMode mode,
|
||||
MMModemDeprecatedMode old_mode,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static void impl_gsm_modem_get_network_mode (MMModemGsmNetwork *modem,
|
||||
@@ -68,6 +73,47 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MMModemGsmAllowedMode
|
||||
mm_modem_gsm_network_old_mode_to_allowed (MMModemDeprecatedMode old_mode)
|
||||
{
|
||||
/* Translate deprecated mode into new mode */
|
||||
switch (old_mode) {
|
||||
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_2G_PREFERRED:
|
||||
return MM_MODEM_GSM_ALLOWED_MODE_2G_PREFERRED;
|
||||
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_3G_PREFERRED:
|
||||
return MM_MODEM_GSM_ALLOWED_MODE_3G_PREFERRED;
|
||||
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_2G_ONLY:
|
||||
return MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY;
|
||||
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_3G_ONLY:
|
||||
return MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY;
|
||||
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_ANY:
|
||||
default:
|
||||
return MM_MODEM_GSM_ALLOWED_MODE_ANY;
|
||||
}
|
||||
}
|
||||
|
||||
MMModemDeprecatedMode
|
||||
mm_modem_gsm_network_act_to_old_mode (MMModemGsmAccessTech act)
|
||||
{
|
||||
/* Translate new mode into old deprecated mode */
|
||||
if (act & MM_MODEM_GSM_ACCESS_TECH_GPRS)
|
||||
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_GPRS;
|
||||
else if (act & MM_MODEM_GSM_ACCESS_TECH_EDGE)
|
||||
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_EDGE;
|
||||
else if (act & MM_MODEM_GSM_ACCESS_TECH_UMTS)
|
||||
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_UMTS;
|
||||
else if (act & MM_MODEM_GSM_ACCESS_TECH_HSDPA)
|
||||
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSDPA;
|
||||
else if (act & MM_MODEM_GSM_ACCESS_TECH_HSUPA)
|
||||
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSUPA;
|
||||
else if (act & MM_MODEM_GSM_ACCESS_TECH_HSPA)
|
||||
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSPA;
|
||||
|
||||
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_ANY;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
async_call_done (MMModem *modem, GError *error, gpointer user_data)
|
||||
{
|
||||
@@ -305,34 +351,20 @@ mm_modem_gsm_network_get_band (MMModemGsmNetwork *self,
|
||||
}
|
||||
|
||||
void
|
||||
mm_modem_gsm_network_set_mode (MMModemGsmNetwork *self,
|
||||
MMModemGsmMode mode,
|
||||
MMModemFn callback,
|
||||
gpointer user_data)
|
||||
mm_modem_gsm_network_set_allowed_mode (MMModemGsmNetwork *self,
|
||||
MMModemGsmAllowedMode mode,
|
||||
MMModemFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (MM_IS_MODEM_GSM_NETWORK (self));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
if (MM_MODEM_GSM_NETWORK_GET_INTERFACE (self)->set_network_mode)
|
||||
MM_MODEM_GSM_NETWORK_GET_INTERFACE (self)->set_network_mode (self, mode, callback, user_data);
|
||||
if (MM_MODEM_GSM_NETWORK_GET_INTERFACE (self)->set_allowed_mode)
|
||||
MM_MODEM_GSM_NETWORK_GET_INTERFACE (self)->set_allowed_mode (self, mode, callback, user_data);
|
||||
else
|
||||
async_call_not_supported (self, callback, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
mm_modem_gsm_network_get_mode (MMModemGsmNetwork *self,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (MM_IS_MODEM_GSM_NETWORK (self));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
if (MM_MODEM_GSM_NETWORK_GET_INTERFACE (self)->get_network_mode)
|
||||
MM_MODEM_GSM_NETWORK_GET_INTERFACE (self)->get_network_mode (self, callback, user_data);
|
||||
else
|
||||
uint_call_not_supported (self, callback, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
mm_modem_gsm_network_get_registration_info (MMModemGsmNetwork *self,
|
||||
MMModemGsmNetworkRegInfoFn callback,
|
||||
@@ -369,15 +401,6 @@ mm_modem_gsm_network_registration_info (MMModemGsmNetwork *self,
|
||||
oper_name ? oper_name : "");
|
||||
}
|
||||
|
||||
void
|
||||
mm_modem_gsm_network_mode (MMModemGsmNetwork *self,
|
||||
MMModemGsmMode mode)
|
||||
{
|
||||
g_return_if_fail (MM_IS_MODEM_GSM_NETWORK (self));
|
||||
|
||||
g_signal_emit (self, signals[NETWORK_MODE], 0, mode);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
@@ -422,7 +445,7 @@ impl_gsm_modem_scan (MMModemGsmNetwork *modem,
|
||||
|
||||
/* Make sure the caller is authorized to request a scan */
|
||||
if (!mm_modem_auth_request (MM_MODEM (modem),
|
||||
MM_AUTHORIZATION_DEVICE,
|
||||
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||
context,
|
||||
scan_auth_cb,
|
||||
NULL,
|
||||
@@ -493,7 +516,28 @@ impl_gsm_modem_get_band (MMModemGsmNetwork *modem,
|
||||
|
||||
static void
|
||||
impl_gsm_modem_set_network_mode (MMModemGsmNetwork *modem,
|
||||
MMModemGsmMode mode,
|
||||
MMModemDeprecatedMode old_mode,
|
||||
DBusGMethodInvocation *context)
|
||||
{
|
||||
if (!check_for_single_value (old_mode)) {
|
||||
GError *error;
|
||||
|
||||
error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_OPERATION_NOT_SUPPORTED,
|
||||
"Invalid arguments (more than one value given)");
|
||||
dbus_g_method_return_error (context, error);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_modem_gsm_network_set_allowed_mode (modem,
|
||||
mm_modem_gsm_network_old_mode_to_allowed (old_mode),
|
||||
async_call_done,
|
||||
context);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_gsm_modem_set_allowed_mode (MMModemGsmNetwork *modem,
|
||||
MMModemGsmAllowedMode mode,
|
||||
DBusGMethodInvocation *context)
|
||||
{
|
||||
if (!check_for_single_value (mode)) {
|
||||
@@ -506,14 +550,20 @@ impl_gsm_modem_set_network_mode (MMModemGsmNetwork *modem,
|
||||
return;
|
||||
}
|
||||
|
||||
mm_modem_gsm_network_set_mode (modem, mode, async_call_done, context);
|
||||
mm_modem_gsm_network_set_allowed_mode (modem, mode, async_call_done, context);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_gsm_modem_get_network_mode (MMModemGsmNetwork *modem,
|
||||
DBusGMethodInvocation *context)
|
||||
{
|
||||
mm_modem_gsm_network_get_mode (modem, uint_call_done, context);
|
||||
MMModemGsmAccessTech act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
|
||||
|
||||
/* DEPRECATED; it's now a property so it's quite easy to handle */
|
||||
g_object_get (G_OBJECT (modem),
|
||||
MM_MODEM_GSM_NETWORK_ACCESS_TECHNOLOGY, &act,
|
||||
NULL);
|
||||
dbus_g_method_return (context, mm_modem_gsm_network_act_to_old_mode (act));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -534,6 +584,28 @@ mm_modem_gsm_network_init (gpointer g_iface)
|
||||
if (initialized)
|
||||
return;
|
||||
|
||||
/* Properties */
|
||||
g_object_interface_install_property
|
||||
(g_iface,
|
||||
g_param_spec_uint (MM_MODEM_GSM_NETWORK_ALLOWED_MODE,
|
||||
"Allowed Mode",
|
||||
"Allowed network access mode",
|
||||
MM_MODEM_GSM_ALLOWED_MODE_ANY,
|
||||
MM_MODEM_GSM_ALLOWED_MODE_LAST,
|
||||
MM_MODEM_GSM_ALLOWED_MODE_ANY,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_interface_install_property
|
||||
(g_iface,
|
||||
g_param_spec_uint (MM_MODEM_GSM_NETWORK_ACCESS_TECHNOLOGY,
|
||||
"Access Technology",
|
||||
"Current access technology in use when connected to "
|
||||
"a mobile network.",
|
||||
MM_MODEM_GSM_ACCESS_TECH_UNKNOWN,
|
||||
MM_MODEM_GSM_ACCESS_TECH_LAST,
|
||||
MM_MODEM_GSM_ACCESS_TECH_UNKNOWN,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
/* Signals */
|
||||
signals[SIGNAL_QUALITY] =
|
||||
g_signal_new ("signal-quality",
|
||||
@@ -559,8 +631,7 @@ mm_modem_gsm_network_init (gpointer g_iface)
|
||||
g_signal_new ("network-mode",
|
||||
iface_type,
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (MMModemGsmNetwork, network_mode),
|
||||
NULL, NULL,
|
||||
0, NULL, NULL,
|
||||
g_cclosure_marshal_VOID__UINT,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_UINT);
|
||||
|
@@ -11,7 +11,7 @@
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
* Copyright (C) 2009 Red Hat, Inc.
|
||||
* Copyright (C) 2009 - 2010 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef MM_MODEM_GSM_NETWORK_H
|
||||
@@ -20,11 +20,23 @@
|
||||
#include <mm-modem.h>
|
||||
#include <mm-modem-gsm.h>
|
||||
|
||||
#define MM_MODEM_GSM_NETWORK_DBUS_INTERFACE "org.freedesktop.ModemManager.Modem.Gsm.Network"
|
||||
|
||||
#define MM_TYPE_MODEM_GSM_NETWORK (mm_modem_gsm_network_get_type ())
|
||||
#define MM_MODEM_GSM_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_GSM_NETWORK, MMModemGsmNetwork))
|
||||
#define MM_IS_MODEM_GSM_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_GSM_NETWORK))
|
||||
#define MM_MODEM_GSM_NETWORK_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_MODEM_GSM_NETWORK, MMModemGsmNetwork))
|
||||
|
||||
#define MM_MODEM_GSM_NETWORK_ALLOWED_MODE "allowed-mode"
|
||||
#define MM_MODEM_GSM_NETWORK_ACCESS_TECHNOLOGY "access-technology"
|
||||
|
||||
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,
|
||||
} MMModemGsmNetworkProp;
|
||||
|
||||
typedef enum {
|
||||
MM_MODEM_GSM_NETWORK_REG_STATUS_IDLE = 0,
|
||||
MM_MODEM_GSM_NETWORK_REG_STATUS_HOME = 1,
|
||||
@@ -80,15 +92,11 @@ struct _MMModemGsmNetwork {
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
void (*set_network_mode) (MMModemGsmNetwork *self,
|
||||
MMModemGsmMode mode,
|
||||
void (*set_allowed_mode) (MMModemGsmNetwork *self,
|
||||
MMModemGsmAllowedMode mode,
|
||||
MMModemFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
void (*get_network_mode) (MMModemGsmNetwork *self,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
void (*get_registration_info) (MMModemGsmNetwork *self,
|
||||
MMModemGsmNetworkRegInfoFn callback,
|
||||
gpointer user_data);
|
||||
@@ -101,9 +109,6 @@ struct _MMModemGsmNetwork {
|
||||
MMModemGsmNetworkRegStatus status,
|
||||
const char *open_code,
|
||||
const char *oper_name);
|
||||
|
||||
void (*network_mode) (MMModemGsmNetwork *self,
|
||||
MMModemGsmMode mode);
|
||||
};
|
||||
|
||||
GType mm_modem_gsm_network_get_type (void);
|
||||
@@ -135,15 +140,6 @@ void mm_modem_gsm_network_get_band (MMModemGsmNetwork *self,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
void mm_modem_gsm_network_set_mode (MMModemGsmNetwork *self,
|
||||
MMModemGsmMode mode,
|
||||
MMModemFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
void mm_modem_gsm_network_get_mode (MMModemGsmNetwork *self,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
void mm_modem_gsm_network_get_registration_info (MMModemGsmNetwork *self,
|
||||
MMModemGsmNetworkRegInfoFn callback,
|
||||
gpointer user_data);
|
||||
@@ -153,12 +149,19 @@ void mm_modem_gsm_network_get_registration_info (MMModemGsmNetwork *self,
|
||||
void mm_modem_gsm_network_signal_quality (MMModemGsmNetwork *self,
|
||||
guint32 quality);
|
||||
|
||||
void mm_modem_gsm_network_set_allowed_mode (MMModemGsmNetwork *self,
|
||||
MMModemGsmAllowedMode mode,
|
||||
MMModemFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
void mm_modem_gsm_network_registration_info (MMModemGsmNetwork *self,
|
||||
MMModemGsmNetworkRegStatus status,
|
||||
const char *oper_code,
|
||||
const char *oper_name);
|
||||
|
||||
void mm_modem_gsm_network_mode (MMModemGsmNetwork *self,
|
||||
MMModemGsmMode mode);
|
||||
/* Private */
|
||||
MMModemDeprecatedMode mm_modem_gsm_network_act_to_old_mode (MMModemGsmAccessTech act);
|
||||
|
||||
MMModemGsmAllowedMode mm_modem_gsm_network_old_mode_to_allowed (MMModemDeprecatedMode old_mode);
|
||||
|
||||
#endif /* MM_MODEM_GSM_NETWORK_H */
|
||||
|
@@ -30,10 +30,34 @@ typedef enum {
|
||||
MM_MODEM_GSM_MODE_3G_ONLY = 0x00000100,
|
||||
MM_MODEM_GSM_MODE_HSUPA = 0x00000200,
|
||||
MM_MODEM_GSM_MODE_HSPA = 0x00000400,
|
||||
|
||||
MM_MODEM_GSM_MODE_LAST = MM_MODEM_GSM_MODE_HSPA
|
||||
MM_MODEM_GSM_MODE_GSM = 0x00000800,
|
||||
MM_MODEM_GSM_MODE_GSM_COMPACT = 0x00001000,
|
||||
} MMModemGsmMode;
|
||||
|
||||
typedef enum {
|
||||
MM_MODEM_GSM_ALLOWED_MODE_ANY = 0,
|
||||
MM_MODEM_GSM_ALLOWED_MODE_2G_PREFERRED = 1,
|
||||
MM_MODEM_GSM_ALLOWED_MODE_3G_PREFERRED = 2,
|
||||
MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY = 3,
|
||||
MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY = 4,
|
||||
|
||||
MM_MODEM_GSM_ALLOWED_MODE_LAST = MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY
|
||||
} MMModemGsmAllowedMode;
|
||||
|
||||
typedef enum {
|
||||
MM_MODEM_GSM_ACCESS_TECH_UNKNOWN = 0,
|
||||
MM_MODEM_GSM_ACCESS_TECH_GSM = 1,
|
||||
MM_MODEM_GSM_ACCESS_TECH_GSM_COMPACT = 2,
|
||||
MM_MODEM_GSM_ACCESS_TECH_GPRS = 3,
|
||||
MM_MODEM_GSM_ACCESS_TECH_EDGE = 4, /* GSM w/EGPRS */
|
||||
MM_MODEM_GSM_ACCESS_TECH_UMTS = 5, /* UTRAN */
|
||||
MM_MODEM_GSM_ACCESS_TECH_HSDPA = 6, /* UTRAN w/HSDPA */
|
||||
MM_MODEM_GSM_ACCESS_TECH_HSUPA = 7, /* UTRAN w/HSUPA */
|
||||
MM_MODEM_GSM_ACCESS_TECH_HSPA = 8, /* UTRAN w/HSDPA and HSUPA */
|
||||
|
||||
MM_MODEM_GSM_ACCESS_TECH_LAST = MM_MODEM_GSM_ACCESS_TECH_HSPA
|
||||
} MMModemGsmAccessTech;
|
||||
|
||||
typedef enum {
|
||||
MM_MODEM_GSM_BAND_UNKNOWN = 0x00000000,
|
||||
MM_MODEM_GSM_BAND_ANY = 0x00000001,
|
||||
@@ -53,5 +77,18 @@ typedef enum {
|
||||
} MMModemGsmBand;
|
||||
|
||||
|
||||
#endif /* MM_MODEM_GSM_H */
|
||||
typedef enum {
|
||||
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_ANY = 0,
|
||||
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_GPRS,
|
||||
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_EDGE,
|
||||
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_UMTS,
|
||||
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSDPA,
|
||||
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_2G_PREFERRED,
|
||||
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_3G_PREFERRED,
|
||||
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_2G_ONLY,
|
||||
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_3G_ONLY,
|
||||
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSUPA,
|
||||
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSPA
|
||||
} MMModemDeprecatedMode;
|
||||
|
||||
#endif /* MM_MODEM_GSM_H */
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "mm-errors.h"
|
||||
#include "mm-modem-helpers.h"
|
||||
@@ -201,3 +202,230 @@ mm_gsm_destroy_scan_data (gpointer data)
|
||||
g_ptr_array_free (results, TRUE);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* +CREG: <stat> (GSM 07.07 CREG=1 unsolicited) */
|
||||
#define CREG1 "\\+CG?REG:\\s*(\\d{1})"
|
||||
|
||||
/* +CREG: <n>,<stat> (GSM 07.07 CREG=1 solicited) */
|
||||
#define CREG2 "\\+CG?REG:\\s*(\\d{1}),\\s*(\\d{1})"
|
||||
|
||||
/* +CREG: <stat>,<lac>,<ci> (GSM 07.07 CREG=2 unsolicited) */
|
||||
#define CREG3 "\\+CG?REG:\\s*(\\d{1}),\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)"
|
||||
|
||||
/* +CREG: <n>,<stat>,<lac>,<ci> (GSM 07.07 solicited and some CREG=2 unsolicited) */
|
||||
#define CREG4 "\\+CG?REG:\\s*(\\d{1}),\\s*(\\d{1})\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)"
|
||||
|
||||
/* +CREG: <stat>,<lac>,<ci>,<AcT> (ETSI 27.007 CREG=2 unsolicited) */
|
||||
#define CREG5 "\\+CG?REG:\\s*(\\d{1})\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*(\\d{1,2})"
|
||||
|
||||
/* +CREG: <n>,<stat>,<lac>,<ci>,<AcT> (ETSI 27.007 solicited and some CREG=2 unsolicited) */
|
||||
#define CREG6 "\\+CG?REG:\\s*(\\d{1}),\\s*(\\d{1})\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*(\\d{1,2})"
|
||||
|
||||
GPtrArray *
|
||||
mm_gsm_creg_regex_get (gboolean solicited)
|
||||
{
|
||||
GPtrArray *array = g_ptr_array_sized_new (6);
|
||||
GRegex *regex;
|
||||
|
||||
/* #1 */
|
||||
if (solicited)
|
||||
regex = g_regex_new (CREG1 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
else
|
||||
regex = g_regex_new ("\\r\\n" CREG1 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
g_assert (regex);
|
||||
g_ptr_array_add (array, regex);
|
||||
|
||||
/* #2 */
|
||||
if (solicited)
|
||||
regex = g_regex_new (CREG2 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
else
|
||||
regex = g_regex_new ("\\r\\n" CREG2 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
g_assert (regex);
|
||||
g_ptr_array_add (array, regex);
|
||||
|
||||
/* #3 */
|
||||
if (solicited)
|
||||
regex = g_regex_new (CREG3 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
else
|
||||
regex = g_regex_new ("\\r\\n" CREG3 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
g_assert (regex);
|
||||
g_ptr_array_add (array, regex);
|
||||
|
||||
/* #4 */
|
||||
if (solicited)
|
||||
regex = g_regex_new (CREG4 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
else
|
||||
regex = g_regex_new ("\\r\\n" CREG4 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
g_assert (regex);
|
||||
g_ptr_array_add (array, regex);
|
||||
|
||||
/* #5 */
|
||||
if (solicited)
|
||||
regex = g_regex_new (CREG5 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
else
|
||||
regex = g_regex_new ("\\r\\n" CREG5 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
g_assert (regex);
|
||||
g_ptr_array_add (array, regex);
|
||||
|
||||
/* #6 */
|
||||
if (solicited)
|
||||
regex = g_regex_new (CREG6 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
else
|
||||
regex = g_regex_new ("\\r\\n" CREG6 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
g_assert (regex);
|
||||
g_ptr_array_add (array, regex);
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
void
|
||||
mm_gsm_creg_regex_destroy (GPtrArray *array)
|
||||
{
|
||||
g_ptr_array_foreach (array, (GFunc) g_regex_unref, NULL);
|
||||
g_ptr_array_free (array, TRUE);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
static gulong
|
||||
parse_uint (char *str, int base, glong nmin, glong nmax, gboolean *valid)
|
||||
{
|
||||
gulong ret = 0;
|
||||
char *endquote;
|
||||
|
||||
*valid = FALSE;
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
/* Strip quotes */
|
||||
if (str[0] == '"')
|
||||
str++;
|
||||
endquote = strchr (str, '"');
|
||||
if (endquote)
|
||||
*endquote = '\0';
|
||||
|
||||
if (strlen (str)) {
|
||||
ret = strtol (str, NULL, base);
|
||||
if ((nmin == nmax) || (ret >= nmin && ret <= nmax))
|
||||
*valid = TRUE;
|
||||
}
|
||||
return *valid ? (guint) ret : 0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_gsm_parse_creg_response (GMatchInfo *info,
|
||||
guint32 *out_reg_state,
|
||||
gulong *out_lac,
|
||||
gulong *out_ci,
|
||||
gint *out_act,
|
||||
gboolean *out_greg,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = FALSE, foo;
|
||||
gint n_matches, act = -1;
|
||||
gulong stat = 0, lac = 0, ci = 0;
|
||||
guint istat = 0, ilac = 0, ici = 0, iact = 0;
|
||||
char *str;
|
||||
const char *orig_str;
|
||||
|
||||
g_return_val_if_fail (info != NULL, FALSE);
|
||||
g_return_val_if_fail (out_reg_state != NULL, FALSE);
|
||||
g_return_val_if_fail (out_lac != NULL, FALSE);
|
||||
g_return_val_if_fail (out_ci != NULL, FALSE);
|
||||
g_return_val_if_fail (out_act != NULL, FALSE);
|
||||
g_return_val_if_fail (out_greg != NULL, FALSE);
|
||||
|
||||
/* Normally the number of matches could be used to determine what each
|
||||
* item is, but we have overlap in one case.
|
||||
*/
|
||||
n_matches = g_match_info_get_match_count (info);
|
||||
if (n_matches == 2) {
|
||||
/* CREG=1: +CREG: <stat> */
|
||||
istat = 1;
|
||||
} else if (n_matches == 3) {
|
||||
/* Solicited response: +CREG: <n>,<stat> */
|
||||
istat = 2;
|
||||
} else if (n_matches == 4) {
|
||||
/* CREG=2 (GSM 07.07): +CREG: <stat>,<lac>,<ci> */
|
||||
istat = 1;
|
||||
ilac = 2;
|
||||
ici = 3;
|
||||
} else if (n_matches == 5) {
|
||||
/* CREG=2 (ETSI 27.007): +CREG: <stat>,<lac>,<ci>,<AcT>
|
||||
* CREG=2 (non-standard): +CREG: <n>,<stat>,<lac>,<ci>
|
||||
*/
|
||||
|
||||
/* To distinguish, check length of the second match item. If it's
|
||||
* more than one digit or has quotes in it, then we have the first format.
|
||||
*/
|
||||
str = g_match_info_fetch (info, 2);
|
||||
if (str && (strchr (str, '"') || strlen (str) > 1)) {
|
||||
g_free (str);
|
||||
istat = 1;
|
||||
ilac = 2;
|
||||
ici = 3;
|
||||
iact = 4;
|
||||
} else {
|
||||
istat = 2;
|
||||
ilac = 3;
|
||||
ici = 4;
|
||||
}
|
||||
} else if (n_matches == 6) {
|
||||
/* CREG=2 (non-standard): +CREG: <n>,<stat>,<lac>,<ci>,<AcT> */
|
||||
istat = 2;
|
||||
ilac = 3;
|
||||
ici = 4;
|
||||
iact = 5;
|
||||
}
|
||||
|
||||
/* Status */
|
||||
str = g_match_info_fetch (info, istat);
|
||||
stat = parse_uint (str, 10, 0, 5, &success);
|
||||
g_free (str);
|
||||
if (!success) {
|
||||
g_set_error_literal (error,
|
||||
MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
|
||||
"Could not parse the registration status response");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Location Area Code */
|
||||
if (ilac) {
|
||||
/* FIXME: some phones apparently swap the LAC bytes (LG, SonyEricsson,
|
||||
* Sagem). Need to handle that.
|
||||
*/
|
||||
str = g_match_info_fetch (info, ilac);
|
||||
lac = parse_uint (str, 16, 1, 0xFFFF, &foo);
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
/* Cell ID */
|
||||
if (ici) {
|
||||
str = g_match_info_fetch (info, ici);
|
||||
ci = parse_uint (str, 16, 1, 0x0FFFFFFE, &foo);
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
/* Access Technology */
|
||||
if (iact) {
|
||||
str = g_match_info_fetch (info, iact);
|
||||
act = (gint) parse_uint (str, 10, 0, 7, &foo);
|
||||
g_free (str);
|
||||
if (!foo)
|
||||
act = -1;
|
||||
}
|
||||
|
||||
orig_str = g_match_info_get_string (info);
|
||||
*out_greg = !!strstr (orig_str, "+CGREG");
|
||||
|
||||
*out_reg_state = (guint32) stat;
|
||||
if (stat != 4) {
|
||||
/* Don't fill in lac/ci/act if the device's state is unknown */
|
||||
*out_lac = lac;
|
||||
*out_ci = ci;
|
||||
*out_act = act;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -27,5 +27,17 @@ GPtrArray *mm_gsm_parse_scan_response (const char *reply, GError **error);
|
||||
|
||||
void mm_gsm_destroy_scan_data (gpointer data);
|
||||
|
||||
GPtrArray *mm_gsm_creg_regex_get (gboolean solicited);
|
||||
|
||||
void mm_gsm_creg_regex_destroy (GPtrArray *array);
|
||||
|
||||
gboolean mm_gsm_parse_creg_response (GMatchInfo *info,
|
||||
guint32 *out_reg_state,
|
||||
gulong *out_lac,
|
||||
gulong *out_ci,
|
||||
gint *out_act,
|
||||
gboolean *out_greg,
|
||||
GError **error);
|
||||
|
||||
#endif /* MM_MODEM_HELPERS_H */
|
||||
|
||||
|
@@ -18,6 +18,11 @@
|
||||
|
||||
#include "mm-modem-helpers.h"
|
||||
|
||||
typedef struct {
|
||||
GPtrArray *solicited_creg;
|
||||
GPtrArray *unsolicited_creg;
|
||||
} TestData;
|
||||
|
||||
#define MM_SCAN_TAG_STATUS "status"
|
||||
#define MM_SCAN_TAG_OPER_LONG "operator-long"
|
||||
#define MM_SCAN_TAG_OPER_SHORT "operator-short"
|
||||
@@ -35,10 +40,10 @@ typedef struct {
|
||||
#define ARRAY_LEN(i) (sizeof (i) / sizeof (i[0]))
|
||||
|
||||
static void
|
||||
test_results (const char *desc,
|
||||
const char *reply,
|
||||
OperEntry *expected_results,
|
||||
guint32 expected_results_len)
|
||||
test_cops_results (const char *desc,
|
||||
const char *reply,
|
||||
OperEntry *expected_results,
|
||||
guint32 expected_results_len)
|
||||
{
|
||||
guint i;
|
||||
GError *error = NULL;
|
||||
@@ -101,7 +106,7 @@ test_cops_response_tm506 (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" }
|
||||
};
|
||||
|
||||
test_results ("TM-506", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("TM-506", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -113,7 +118,7 @@ test_cops_response_gt3gplus (void *f, gpointer d)
|
||||
{ "1", "Cingular", "Cingular", "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("GlobeTrotter 3G+ (nozomi)", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("GlobeTrotter 3G+ (nozomi)", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -126,7 +131,7 @@ test_cops_response_ac881 (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("Sierra AirCard 881", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Sierra AirCard 881", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -139,7 +144,7 @@ test_cops_response_gtmax36 (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("Option GlobeTrotter MAX 3.6", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Option GlobeTrotter MAX 3.6", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -152,7 +157,7 @@ test_cops_response_ac860 (void *f, gpointer d)
|
||||
{ "1", "Cingular", "Cinglr", "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("Sierra AirCard 860", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Sierra AirCard 860", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -165,7 +170,7 @@ test_cops_response_gtm378 (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("Option GTM378", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Option GTM378", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -177,7 +182,7 @@ test_cops_response_motoc (void *f, gpointer d)
|
||||
{ "0", "Cingular Wireless", NULL, "310410", NULL },
|
||||
};
|
||||
|
||||
test_results ("BUSlink SCWi275u (Motorola C-series)", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("BUSlink SCWi275u (Motorola C-series)", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -189,7 +194,7 @@ test_cops_response_mf627a (void *f, gpointer d)
|
||||
{ "3", "Voicestream Wireless Corporation", "VSTREAM", "31026", "0" },
|
||||
};
|
||||
|
||||
test_results ("ZTE MF627 (A)", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("ZTE MF627 (A)", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -201,7 +206,7 @@ test_cops_response_mf627b (void *f, gpointer d)
|
||||
{ "3", NULL, NULL, "31026", "0" },
|
||||
};
|
||||
|
||||
test_results ("ZTE MF627 (B)", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("ZTE MF627 (B)", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -213,7 +218,7 @@ test_cops_response_e160g (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("Huawei E160G", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Huawei E160G", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -226,7 +231,7 @@ test_cops_response_mercury (void *f, gpointer d)
|
||||
{ "1", "T-Mobile", "TMO", "31026", "0" },
|
||||
};
|
||||
|
||||
test_results ("Sierra AT&T USBConnect Mercury", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Sierra AT&T USBConnect Mercury", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -239,7 +244,7 @@ test_cops_response_quicksilver (void *f, gpointer d)
|
||||
{ "1", "AT&T", NULL, "310260", "0" },
|
||||
};
|
||||
|
||||
test_results ("Option AT&T Quicksilver", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Option AT&T Quicksilver", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -251,7 +256,7 @@ test_cops_response_icon225 (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("Option iCON 225", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Option iCON 225", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -265,7 +270,7 @@ test_cops_response_icon452 (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" }
|
||||
};
|
||||
|
||||
test_results ("Option iCON 452", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Option iCON 452", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -278,7 +283,7 @@ test_cops_response_f3507g (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "2" }
|
||||
};
|
||||
|
||||
test_results ("Ericsson F3507g", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Ericsson F3507g", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -291,7 +296,7 @@ test_cops_response_f3607gw (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" }
|
||||
};
|
||||
|
||||
test_results ("Ericsson F3607gw", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Ericsson F3607gw", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -304,7 +309,7 @@ test_cops_response_mc8775 (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" }
|
||||
};
|
||||
|
||||
test_results ("Sierra MC8775", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Sierra MC8775", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -317,7 +322,7 @@ test_cops_response_n80 (void *f, gpointer d)
|
||||
{ "1", "Cingular", NULL, "31041", NULL },
|
||||
};
|
||||
|
||||
test_results ("Nokia N80", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Nokia N80", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -329,7 +334,7 @@ test_cops_response_e1550 (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("Huawei E1550", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Huawei E1550", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -341,7 +346,7 @@ test_cops_response_mf622 (void *f, gpointer d)
|
||||
{ "1", NULL, NULL, "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("ZTE MF622", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("ZTE MF622", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -354,7 +359,7 @@ test_cops_response_e226 (void *f, gpointer d)
|
||||
{ "1", NULL, NULL, "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("Huawei E226", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Huawei E226", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -367,7 +372,7 @@ test_cops_response_xu870 (void *f, gpointer d)
|
||||
{ "1", "T-Mobile", "TMO", "31026", "0" },
|
||||
};
|
||||
|
||||
test_results ("Novatel XU870", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Novatel XU870", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -380,7 +385,7 @@ test_cops_response_gtultraexpress (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("Option GlobeTrotter Ultra Express", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Option GlobeTrotter Ultra Express", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -392,7 +397,7 @@ test_cops_response_n2720 (void *f, gpointer d)
|
||||
{ "1", "AT&T", NULL, "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("Nokia 2720", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Nokia 2720", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -405,7 +410,7 @@ test_cops_response_gobi (void *f, gpointer d)
|
||||
{ "1", "AT&T", "AT&T", "310410", "0" },
|
||||
};
|
||||
|
||||
test_results ("Qualcomm Gobi", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Qualcomm Gobi", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -426,7 +431,7 @@ test_cops_response_sek600i (void *f, gpointer d)
|
||||
{ "3", NULL, NULL, "26207", NULL },
|
||||
};
|
||||
|
||||
test_results ("Sony-Ericsson K600i", reply, &expected[0], ARRAY_LEN (expected));
|
||||
test_cops_results ("Sony-Ericsson K600i", reply, &expected[0], ARRAY_LEN (expected));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -453,6 +458,238 @@ test_cops_response_umts_invalid (void *f, gpointer d)
|
||||
g_assert (error == NULL);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
guint32 state;
|
||||
gulong lac;
|
||||
gulong ci;
|
||||
gint act;
|
||||
|
||||
guint regex_num;
|
||||
gboolean cgreg;
|
||||
} CregResult;
|
||||
|
||||
static void
|
||||
test_creg_match (const char *test,
|
||||
gboolean solicited,
|
||||
const char *reply,
|
||||
TestData *data,
|
||||
const CregResult *result)
|
||||
{
|
||||
int i;
|
||||
GMatchInfo *info = NULL;
|
||||
guint32 state = 0;
|
||||
gulong lac = 0, ci = 0;
|
||||
gint access_tech = -1;
|
||||
GError *error = NULL;
|
||||
gboolean success, cgreg = FALSE;
|
||||
guint regex_num = 0;
|
||||
GPtrArray *array;
|
||||
|
||||
g_assert (reply);
|
||||
g_assert (test);
|
||||
g_assert (data);
|
||||
g_assert (result);
|
||||
|
||||
g_print ("\nTesting %s +CREG %s response...\n",
|
||||
test,
|
||||
solicited ? "solicited" : "unsolicited");
|
||||
|
||||
array = solicited ? data->solicited_creg : data->unsolicited_creg;
|
||||
for (i = 0; i < array->len; i++) {
|
||||
GRegex *r = g_ptr_array_index (array, i);
|
||||
|
||||
if (g_regex_match (r, reply, 0, &info)) {
|
||||
regex_num = i + 1;
|
||||
break;
|
||||
}
|
||||
g_match_info_free (info);
|
||||
info = NULL;
|
||||
}
|
||||
|
||||
g_assert (info != NULL);
|
||||
g_assert (regex_num == result->regex_num);
|
||||
|
||||
success = mm_gsm_parse_creg_response (info, &state, &lac, &ci, &access_tech, &cgreg, &error);
|
||||
g_assert (success);
|
||||
g_assert (error == NULL);
|
||||
g_assert (state == result->state);
|
||||
g_assert (lac == result->lac);
|
||||
g_assert (ci == result->ci);
|
||||
g_assert (access_tech == result->act);
|
||||
g_assert (cgreg == result->cgreg);
|
||||
}
|
||||
|
||||
static void
|
||||
test_creg1_solicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "+CREG: 1,3";
|
||||
const CregResult result = { 3, 0, 0, -1 , 2, FALSE};
|
||||
|
||||
test_creg_match ("CREG=1", TRUE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_creg1_unsolicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "\r\n+CREG: 3\r\n";
|
||||
const CregResult result = { 3, 0, 0, -1 , 1, FALSE};
|
||||
|
||||
test_creg_match ("CREG=1", FALSE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_creg2_mercury_solicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "+CREG: 0,1,84CD,00D30173";
|
||||
const CregResult result = { 1, 0x84cd, 0xd30173, -1 , 4, FALSE};
|
||||
|
||||
test_creg_match ("Sierra Mercury CREG=2", TRUE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_creg2_mercury_unsolicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "\r\n+CREG: 1,84CD,00D30156\r\n";
|
||||
const CregResult result = { 1, 0x84cd, 0xd30156, -1 , 3, FALSE};
|
||||
|
||||
test_creg_match ("Sierra Mercury CREG=2", FALSE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_creg2_sek850i_solicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "+CREG: 2,1,\"CE00\",\"01CEAD8F\"";
|
||||
const CregResult result = { 1, 0xce00, 0x01cead8f, -1 , 4, FALSE};
|
||||
|
||||
test_creg_match ("Sony Ericsson K850i CREG=2", TRUE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_creg2_sek850i_unsolicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "\r\n+CREG: 1,\"CE00\",\"00005449\"\r\n";
|
||||
const CregResult result = { 1, 0xce00, 0x5449, -1 , 3, FALSE};
|
||||
|
||||
test_creg_match ("Sony Ericsson K850i CREG=2", FALSE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_creg2_e160g_solicited_unregistered (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "+CREG: 2,0,00,0";
|
||||
const CregResult result = { 0, 0, 0, -1 , 4, FALSE};
|
||||
|
||||
test_creg_match ("Huawei E160G unregistered CREG=2", TRUE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_creg2_e160g_solicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "+CREG: 2,1,8BE3,2BAF";
|
||||
const CregResult result = { 1, 0x8be3, 0x2baf, -1 , 4, FALSE};
|
||||
|
||||
test_creg_match ("Huawei E160G CREG=2", TRUE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_creg2_e160g_unsolicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "\r\n+CREG: 2,8BE3,2BAF\r\n";
|
||||
const CregResult result = { 2, 0x8be3, 0x2baf, -1 , 3, FALSE};
|
||||
|
||||
test_creg_match ("Huawei E160G CREG=2", FALSE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_creg2_tm506_solicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "+CREG: 2,1,\"8BE3\",\"00002BAF\"";
|
||||
const CregResult result = { 1, 0x8BE3, 0x2BAF, -1 , 4, FALSE};
|
||||
|
||||
/* Test leading zeros in the CI */
|
||||
test_creg_match ("Sony Ericsson TM-506 CREG=2", TRUE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_creg2_xu870_unsolicited_unregistered (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "\r\n+CREG: 2,,\r\n";
|
||||
const CregResult result = { 2, 0, 0, -1 , 3, FALSE};
|
||||
|
||||
test_creg_match ("Novatel XU870 unregistered CREG=2", FALSE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_cgreg1_solicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "+CGREG: 1,3";
|
||||
const CregResult result = { 3, 0, 0, -1 , 2, TRUE};
|
||||
|
||||
test_creg_match ("CGREG=1", TRUE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_cgreg1_unsolicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "\r\n+CGREG: 3\r\n";
|
||||
const CregResult result = { 3, 0, 0, -1 , 1, TRUE};
|
||||
|
||||
test_creg_match ("CGREG=1", FALSE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_cgreg2_f3607gw_solicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "+CGREG: 2,1,\"8BE3\",\"00002B5D\",3";
|
||||
const CregResult result = { 1, 0x8BE3, 0x2B5D, 3 , 6, TRUE};
|
||||
|
||||
test_creg_match ("Ericsson F3607gw CGREG=2", TRUE, reply, data, &result);
|
||||
}
|
||||
|
||||
static void
|
||||
test_cgreg2_f3607gw_unsolicited (void *f, gpointer d)
|
||||
{
|
||||
TestData *data = (TestData *) d;
|
||||
const char *reply = "\r\n+CGREG: 1,\"8BE3\",\"00002B5D\",3\r\n";
|
||||
const CregResult result = { 1, 0x8BE3, 0x2B5D, 3 , 5, TRUE};
|
||||
|
||||
test_creg_match ("Ericsson F3607gw CGREG=2", FALSE, reply, data, &result);
|
||||
}
|
||||
|
||||
|
||||
static TestData *
|
||||
test_data_new (void)
|
||||
{
|
||||
TestData *data;
|
||||
|
||||
data = g_malloc0 (sizeof (TestData));
|
||||
data->solicited_creg = mm_gsm_creg_regex_get (TRUE);
|
||||
data->unsolicited_creg = mm_gsm_creg_regex_get (FALSE);
|
||||
return data;
|
||||
}
|
||||
|
||||
static void
|
||||
test_data_free (TestData *data)
|
||||
{
|
||||
mm_gsm_creg_regex_destroy (data->solicited_creg);
|
||||
mm_gsm_creg_regex_destroy (data->unsolicited_creg);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
|
||||
typedef void (*TCFunc)(void);
|
||||
|
||||
@@ -461,10 +698,13 @@ typedef void (*TCFunc)(void);
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
GTestSuite *suite;
|
||||
TestData *data;
|
||||
gint result;
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
suite = g_test_get_root ();
|
||||
data = test_data_new ();
|
||||
|
||||
g_test_suite_add (suite, TESTCASE (test_cops_response_tm506, NULL));
|
||||
g_test_suite_add (suite, TESTCASE (test_cops_response_gt3gplus, NULL));
|
||||
@@ -496,6 +736,27 @@ int main (int argc, char **argv)
|
||||
g_test_suite_add (suite, TESTCASE (test_cops_response_gsm_invalid, NULL));
|
||||
g_test_suite_add (suite, TESTCASE (test_cops_response_umts_invalid, NULL));
|
||||
|
||||
return g_test_run ();
|
||||
g_test_suite_add (suite, TESTCASE (test_creg1_solicited, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_creg1_unsolicited, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_creg2_mercury_solicited, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_creg2_mercury_unsolicited, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_creg2_sek850i_solicited, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_creg2_sek850i_unsolicited, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_creg2_e160g_solicited_unregistered, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_creg2_e160g_solicited, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_creg2_e160g_unsolicited, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_creg2_tm506_solicited, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_creg2_xu870_unsolicited_unregistered, data));
|
||||
|
||||
g_test_suite_add (suite, TESTCASE (test_cgreg1_solicited, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_cgreg1_unsolicited, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_cgreg2_f3607gw_solicited, data));
|
||||
g_test_suite_add (suite, TESTCASE (test_cgreg2_f3607gw_unsolicited, data));
|
||||
|
||||
result = g_test_run ();
|
||||
|
||||
test_data_free (data);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user