core: use hardware IDs as part of DeviceIdentifier

Pass the device's hardware IDs through modem creation and use them
when calculating the device's identifier.  Add a bunch of testcases
for real hardware to ensure we don't break the device ID in the
future unless we really want to.
This commit is contained in:
Dan Williams
2010-10-22 11:06:48 -05:00
parent 328d2369a9
commit 7ae8ffe21b
60 changed files with 716 additions and 94 deletions

View File

@@ -39,7 +39,9 @@ mm_modem_anydata_cdma_new (const char *device,
const char *driver,
const char *plugin,
gboolean evdo_rev0,
gboolean evdo_revA)
gboolean evdo_revA,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -52,6 +54,8 @@ mm_modem_anydata_cdma_new (const char *device,
MM_GENERIC_CDMA_EVDO_REV0, evdo_rev0,
MM_GENERIC_CDMA_EVDO_REVA, evdo_revA,
MM_GENERIC_CDMA_REGISTRATION_TRY_CSS, FALSE,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -40,6 +40,8 @@ MMModem *mm_modem_anydata_cdma_new (const char *device,
const char *driver,
const char *plugin,
gboolean evdo_rev0,
gboolean evdo_revA);
gboolean evdo_revA,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_ANYDATA_CDMA_H */

View File

@@ -36,7 +36,9 @@ G_DEFINE_TYPE_EXTENDED (MMModemGobiGsm, mm_modem_gobi_gsm, MM_TYPE_GENERIC_GSM,
MMModem *
mm_modem_gobi_gsm_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -46,6 +48,8 @@ mm_modem_gobi_gsm_new (const char *device,
MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -38,6 +38,8 @@ GType mm_modem_gobi_gsm_get_type (void);
MMModem *mm_modem_gobi_gsm_new (const char *device,
const char *driver,
const char *plugin_name);
const char *plugin_name,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_GOBI_GSM_H */

View File

@@ -74,7 +74,9 @@ typedef struct {
MMModem *
mm_modem_hso_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -85,6 +87,8 @@ mm_modem_hso_new (const char *device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_IP_METHOD, MM_MODEM_IP_METHOD_STATIC,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -38,7 +38,9 @@ GType mm_modem_hso_get_type (void);
MMModem *mm_modem_hso_new (const char *device,
const char *driver,
const char *plugin);
const char *plugin,
guint32 vendor,
guint32 product);
void mm_hso_modem_authenticate (MMModemHso *self,
const char *username,

View File

@@ -39,7 +39,9 @@ mm_modem_huawei_cdma_new (const char *device,
const char *driver,
const char *plugin,
gboolean evdo_rev0,
gboolean evdo_revA)
gboolean evdo_revA,
guint32 vendor,
guint32 product)
{
gboolean try_css = TRUE;
@@ -61,6 +63,8 @@ mm_modem_huawei_cdma_new (const char *device,
MM_GENERIC_CDMA_EVDO_REV0, evdo_rev0,
MM_GENERIC_CDMA_EVDO_REVA, evdo_revA,
MM_GENERIC_CDMA_REGISTRATION_TRY_CSS, try_css,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -40,6 +40,8 @@ MMModem *mm_modem_huawei_cdma_new (const char *device,
const char *driver,
const char *plugin,
gboolean evdo_rev0,
gboolean evdo_revA);
gboolean evdo_revA,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_HUAWEI_CDMA_H */

View File

@@ -50,7 +50,9 @@ typedef struct {
MMModem *
mm_modem_huawei_gsm_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -60,6 +62,8 @@ mm_modem_huawei_gsm_new (const char *device,
MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -38,6 +38,8 @@ GType mm_modem_huawei_gsm_get_type (void);
MMModem *mm_modem_huawei_gsm_new (const char *device,
const char *driver,
const char *plugin);
const char *plugin,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_HUAWEI_GSM_H */

View File

@@ -30,7 +30,9 @@ G_DEFINE_TYPE (MMModemLongcheerGsm, mm_modem_longcheer_gsm, MM_TYPE_GENERIC_GSM)
MMModem *
mm_modem_longcheer_gsm_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -40,6 +42,8 @@ mm_modem_longcheer_gsm_new (const char *device,
MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -38,6 +38,8 @@ GType mm_modem_longcheer_gsm_get_type (void);
MMModem *mm_modem_longcheer_gsm_new (const char *device,
const char *driver,
const char *plugin);
const char *plugin,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_LONGCHEER_H */

View File

@@ -82,7 +82,9 @@ mbm_modem_authenticate (MMModemMbm *self,
MMModem *
mm_modem_mbm_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -93,6 +95,8 @@ mm_modem_mbm_new (const char *device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_IP_METHOD, MM_MODEM_IP_METHOD_DHCP,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -43,6 +43,8 @@ GType mm_modem_mbm_get_type (void);
MMModem *mm_modem_mbm_new (const char *device,
const char *driver,
const char *plugin_name);
const char *plugin_name,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_MBM_H */

View File

@@ -35,7 +35,9 @@ G_DEFINE_TYPE_EXTENDED (MMModemMotoCGsm, mm_modem_moto_c_gsm, MM_TYPE_GENERIC_GS
MMModem *
mm_modem_moto_c_gsm_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -45,6 +47,8 @@ mm_modem_moto_c_gsm_new (const char *device,
MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -38,6 +38,8 @@ GType mm_modem_moto_c_gsm_get_type (void);
MMModem *mm_modem_moto_c_gsm_new (const char *device,
const char *driver,
const char *plugin_name);
const char *plugin_name,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_MOTO_C_GSM_H */

View File

@@ -30,7 +30,9 @@ G_DEFINE_TYPE_EXTENDED (MMModemNokia, mm_modem_nokia, MM_TYPE_GENERIC_GSM, 0,
MMModem *
mm_modem_nokia_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -40,6 +42,8 @@ mm_modem_nokia_new (const char *device,
MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -38,6 +38,8 @@ GType mm_modem_nokia_get_type (void);
MMModem *mm_modem_nokia_new (const char *data,
const char *driver,
const char *plugin);
const char *plugin,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_NOKIA_H */

View File

@@ -37,7 +37,9 @@ mm_modem_novatel_cdma_new (const char *device,
const char *driver,
const char *plugin,
gboolean evdo_rev0,
gboolean evdo_revA)
gboolean evdo_revA,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);

View File

@@ -40,6 +40,8 @@ MMModem *mm_modem_novatel_cdma_new (const char *device,
const char *driver,
const char *plugin,
gboolean evdo_rev0,
gboolean evdo_revA);
gboolean evdo_revA,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_NOVATEL_CDMA_H */

View File

@@ -33,7 +33,9 @@ G_DEFINE_TYPE_EXTENDED (MMModemNovatelGsm, mm_modem_novatel_gsm, MM_TYPE_GENERIC
MMModem *
mm_modem_novatel_gsm_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -43,6 +45,8 @@ mm_modem_novatel_gsm_new (const char *device,
MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -38,6 +38,8 @@ GType mm_modem_novatel_gsm_get_type (void);
MMModem *mm_modem_novatel_gsm_new (const char *device,
const char *driver,
const char *plugin_name);
const char *plugin_name,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_NOVATEL_GSM_H */

View File

@@ -36,7 +36,9 @@ typedef struct {
MMModem *
mm_modem_option_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -46,6 +48,8 @@ mm_modem_option_new (const char *device,
MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -38,6 +38,8 @@ GType mm_modem_option_get_type (void);
MMModem *mm_modem_option_new (const char *device,
const char *driver,
const char *plugin_name);
const char *plugin_name,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_OPTION_H */

View File

@@ -51,7 +51,9 @@ mm_modem_sierra_cdma_new (const char *device,
const char *driver,
const char *plugin,
gboolean evdo_rev0,
gboolean evdo_revA)
gboolean evdo_revA,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -63,6 +65,8 @@ mm_modem_sierra_cdma_new (const char *device,
MM_MODEM_PLUGIN, plugin,
MM_GENERIC_CDMA_EVDO_REV0, evdo_rev0,
MM_GENERIC_CDMA_EVDO_REVA, evdo_revA,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -40,6 +40,8 @@ MMModem *mm_modem_sierra_cdma_new (const char *device,
const char *driver,
const char *plugin,
gboolean evdo_rev0,
gboolean evdo_revA);
gboolean evdo_revA,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_SIERRA_CDMA_H */

View File

@@ -38,7 +38,9 @@ typedef struct {
MMModem *
mm_modem_sierra_gsm_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -48,6 +50,8 @@ mm_modem_sierra_gsm_new (const char *device,
MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -38,6 +38,8 @@ GType mm_modem_sierra_gsm_get_type (void);
MMModem *mm_modem_sierra_gsm_new (const char *device,
const char *driver,
const char *plugin_name);
const char *plugin_name,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_SIERRA_GSM_H */

View File

@@ -34,7 +34,9 @@ G_DEFINE_TYPE_EXTENDED (MMModemSimtechGsm, mm_modem_simtech_gsm, MM_TYPE_GENERIC
MMModem *
mm_modem_simtech_gsm_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -44,6 +46,8 @@ mm_modem_simtech_gsm_new (const char *device,
MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -38,6 +38,8 @@ GType mm_modem_simtech_gsm_get_type (void);
MMModem *mm_modem_simtech_gsm_new (const char *device,
const char *driver,
const char *plugin);
const char *plugin,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_SIMTECH_H */

View File

@@ -31,7 +31,9 @@ G_DEFINE_TYPE (MMModemX22xGsm, mm_modem_x22x_gsm, MM_TYPE_GENERIC_GSM)
MMModem *
mm_modem_x22x_gsm_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -41,6 +43,8 @@ mm_modem_x22x_gsm_new (const char *device,
MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -38,6 +38,8 @@ GType mm_modem_x22x_gsm_get_type (void);
MMModem *mm_modem_x22x_gsm_new (const char *device,
const char *driver,
const char *plugin);
const char *plugin,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_X22X_H */

View File

@@ -41,7 +41,9 @@ typedef struct {
MMModem *
mm_modem_zte_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint32 vendor,
guint32 product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -51,6 +53,8 @@ mm_modem_zte_new (const char *device,
MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -38,6 +38,8 @@ GType mm_modem_zte_get_type (void);
MMModem *mm_modem_zte_new (const char *device,
const char *driver,
const char *plugin);
const char *plugin,
guint32 vendor,
guint32 product);
#endif /* MM_MODEM_ZTE_H */

View File

@@ -110,6 +110,7 @@ grab_port (MMPluginBase *base,
MMModem *modem = NULL;
const char *name, *subsys, *devfile, *sysfs_path;
guint32 caps;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -129,6 +130,11 @@ grab_port (MMPluginBase *base,
return NULL;
}
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
if (caps & CAP_CDMA) {
@@ -136,7 +142,9 @@ grab_port (MMPluginBase *base,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A));
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A),
vendor,
product);
}
if (modem) {

View File

@@ -112,6 +112,7 @@ grab_port (MMPluginBase *base,
MMModem *modem = NULL;
const char *name, *subsys, *devfile, *sysfs_path, *driver;
guint32 caps;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -133,6 +134,11 @@ grab_port (MMPluginBase *base,
}
}
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
@@ -141,11 +147,15 @@ grab_port (MMPluginBase *base,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A));
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A),
vendor,
product);
} else if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
modem = mm_generic_gsm_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
}
if (modem) {

View File

@@ -106,6 +106,7 @@ grab_port (MMPluginBase *base,
MMModem *modem = NULL;
const char *name, *subsys, *sysfs_path;
guint32 caps;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -113,19 +114,28 @@ grab_port (MMPluginBase *base,
subsys = g_udev_device_get_subsystem (port);
name = g_udev_device_get_name (port);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
modem = mm_modem_gobi_gsm_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
} else if (caps & CAP_CDMA) {
modem = mm_generic_cdma_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A));
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A),
vendor,
product);
}
if (modem) {

View File

@@ -105,6 +105,7 @@ grab_port (MMPluginBase *base,
const char *name, *subsys, *sysfs_path;
char *devfile;
guint32 caps;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -112,6 +113,11 @@ grab_port (MMPluginBase *base,
subsys = g_udev_device_get_subsystem (port);
name = g_udev_device_get_name (port);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
devfile = g_strdup (g_udev_device_get_device_file (port));
if (!devfile) {
if (!strcmp (subsys, "net")) {
@@ -139,7 +145,9 @@ grab_port (MMPluginBase *base,
if (!existing) {
modem = mm_modem_hso_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {
g_object_unref (modem);

View File

@@ -268,7 +268,7 @@ grab_port (MMPluginBase *base,
MMModem *modem = NULL;
const char *name, *subsys, *devfile, *sysfs_path;
guint32 caps;
guint16 product = 0;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -282,7 +282,7 @@ grab_port (MMPluginBase *base,
subsys = g_udev_device_get_subsystem (port);
name = g_udev_device_get_name (port);
if (!mm_plugin_base_get_device_ids (base, subsys, name, NULL, &product)) {
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
@@ -293,13 +293,17 @@ grab_port (MMPluginBase *base,
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
modem = mm_modem_huawei_gsm_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
} else if (caps & CAP_CDMA) {
modem = mm_modem_huawei_cdma_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A));
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A),
vendor,
product);
}
if (modem) {

View File

@@ -114,6 +114,7 @@ grab_port (MMPluginBase *base,
const char *name, *subsys, *sysfs_path;
guint32 caps;
MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -138,19 +139,28 @@ grab_port (MMPluginBase *base,
subsys = g_udev_device_get_subsystem (port);
name = g_udev_device_get_name (port);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
modem = mm_modem_longcheer_gsm_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
} else if (caps & CAP_CDMA) {
modem = mm_generic_cdma_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A));
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A),
vendor,
product);
}
if (modem) {

View File

@@ -132,6 +132,7 @@ grab_port (MMPluginBase *base,
MMModem *modem = NULL;
const char *name, *subsys, *sysfs_path;
guint32 caps;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -143,11 +144,18 @@ grab_port (MMPluginBase *base,
if (!(caps & MM_PLUGIN_BASE_PORT_CAP_GSM) && strcmp (subsys, "net"))
return NULL;
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
modem = mm_modem_mbm_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {
g_object_unref (modem);

View File

@@ -105,6 +105,7 @@ grab_port (MMPluginBase *base,
GUdevDevice *port = NULL;
MMModem *modem = NULL;
const char *name, *subsys, *devfile, *sysfs_path;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -118,11 +119,18 @@ grab_port (MMPluginBase *base,
subsys = g_udev_device_get_subsystem (port);
name = g_udev_device_get_name (port);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
modem = mm_modem_moto_c_gsm_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
if (modem) {
if (!mm_modem_grab_port (modem, subsys, name, MM_PORT_TYPE_UNKNOWN, NULL, error)) {

View File

@@ -109,6 +109,7 @@ grab_port (MMPluginBase *base,
MMModem *modem = NULL;
const char *name, *subsys, *devfile, *sysfs_path;
guint32 caps;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -122,19 +123,28 @@ grab_port (MMPluginBase *base,
subsys = g_udev_device_get_subsystem (port);
name = g_udev_device_get_name (port);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
modem = mm_modem_nokia_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
} else if (caps & CAP_CDMA) {
modem = mm_generic_cdma_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A));
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A),
vendor,
product);
}
if (modem) {

View File

@@ -115,6 +115,7 @@ grab_port (MMPluginBase *base,
MMModem *modem = NULL;
const char *name, *subsys, *devfile, *sysfs_path;
guint32 caps;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -128,19 +129,28 @@ grab_port (MMPluginBase *base,
subsys = g_udev_device_get_subsystem (port);
name = g_udev_device_get_name (port);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
modem = mm_modem_novatel_gsm_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
} else if (caps & CAP_CDMA) {
modem = mm_modem_novatel_cdma_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A));
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A),
vendor,
product);
}
if (modem) {

View File

@@ -107,6 +107,7 @@ grab_port (MMPluginBase *base,
guint32 caps;
int usbif;
MMPortType ptype = MM_PORT_TYPE_SECONDARY;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -129,13 +130,20 @@ grab_port (MMPluginBase *base,
if (usbif == 0)
ptype = MM_PORT_TYPE_PRIMARY;
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
modem = mm_modem_option_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
}
if (modem) {

View File

@@ -128,6 +128,7 @@ grab_port (MMPluginBase *base,
const char *name, *subsys, *devfile, *sysfs_path;
guint32 caps;
MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -145,19 +146,28 @@ grab_port (MMPluginBase *base,
if (g_object_get_data (G_OBJECT (task), TAG_SIERRA_SECONDARY_PORT))
ptype = MM_PORT_TYPE_SECONDARY;
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
if ((caps & MM_PLUGIN_BASE_PORT_CAP_GSM) || (ptype != MM_PORT_TYPE_UNKNOWN)) {
modem = mm_modem_sierra_gsm_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
} else if (caps & CAP_CDMA) {
modem = mm_modem_sierra_cdma_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A));
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A),
vendor,
product);
}
if (modem) {

View File

@@ -114,6 +114,7 @@ grab_port (MMPluginBase *base,
const char *name, *subsys, *sysfs_path;
guint32 caps;
MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -138,19 +139,28 @@ grab_port (MMPluginBase *base,
subsys = g_udev_device_get_subsystem (port);
name = g_udev_device_get_name (port);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
modem = mm_modem_simtech_gsm_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
} else if (caps & CAP_CDMA) {
modem = mm_generic_cdma_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A));
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A),
vendor,
product);
}
if (modem) {

View File

@@ -115,6 +115,7 @@ grab_port (MMPluginBase *base,
const char *name, *subsys, *sysfs_path;
guint32 caps;
MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -139,13 +140,20 @@ grab_port (MMPluginBase *base,
subsys = g_udev_device_get_subsystem (port);
name = g_udev_device_get_name (port);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
modem = mm_modem_x22x_gsm_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
}
if (modem) {

View File

@@ -121,6 +121,7 @@ grab_port (MMPluginBase *base,
const char *name, *subsys, *sysfs_path;
guint32 caps;
MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -134,19 +135,28 @@ grab_port (MMPluginBase *base,
subsys = g_udev_device_get_subsystem (port);
name = g_udev_device_get_name (port);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
}
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
modem = mm_modem_zte_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_get_name (MM_PLUGIN (base)),
vendor,
product);
} else if (caps & CAP_CDMA) {
modem = mm_generic_cdma_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856),
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A));
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A),
vendor,
product);
}
if (modem) {

View File

@@ -95,7 +95,9 @@ mm_generic_cdma_new (const char *device,
const char *driver,
const char *plugin,
gboolean evdo_rev0,
gboolean evdo_revA)
gboolean evdo_revA,
guint vendor,
guint product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -107,6 +109,8 @@ mm_generic_cdma_new (const char *device,
MM_MODEM_PLUGIN, plugin,
MM_GENERIC_CDMA_EVDO_REV0, evdo_rev0,
MM_GENERIC_CDMA_EVDO_REVA, evdo_revA,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -88,7 +88,9 @@ MMModem *mm_generic_cdma_new (const char *device,
const char *driver,
const char *plugin,
gboolean evdo_rev0,
gboolean evdo_revA);
gboolean evdo_revA,
guint vendor,
guint product);
/* Private, for subclasses */

View File

@@ -158,7 +158,9 @@ static void update_lac_ci (MMGenericGsm *self, gulong lac, gulong ci, guint idx)
MMModem *
mm_generic_gsm_new (const char *device,
const char *driver,
const char *plugin)
const char *plugin,
guint vendor,
guint product)
{
g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
@@ -168,6 +170,8 @@ mm_generic_gsm_new (const char *device,
MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
MM_MODEM_PLUGIN, plugin,
MM_MODEM_HW_VID, vendor,
MM_MODEM_HW_PID, product,
NULL));
}

View File

@@ -134,7 +134,9 @@ GType mm_generic_gsm_get_type (void);
MMModem *mm_generic_gsm_new (const char *device,
const char *driver,
const char *plugin);
const char *plugin,
guint vendor,
guint product);
/* Private, for subclasses */

View File

@@ -51,6 +51,8 @@ typedef struct {
gboolean valid;
MMModemState state;
guint vid;
guint pid;
char *manf;
char *model;
char *revision;
@@ -435,8 +437,8 @@ card_info_cache_invoke (MMCallbackInfo *info)
/* Build up the device identifier */
g_free (priv->device_ident);
priv->device_ident = mm_create_device_identifier (NULL,
NULL,
priv->device_ident = mm_create_device_identifier (priv->vid,
priv->pid,
priv->ati,
priv->ati1,
priv->gsn,
@@ -454,41 +456,44 @@ info_item_done (MMCallbackInfo *info,
GString *response,
GError *error,
const char *tag,
const char *tag2,
const char *desc)
{
const char *p = response->str;
if (!error) {
if (tag)
p = mm_strip_tag (response->str, tag);
p = mm_strip_tag (p, tag);
if (tag2)
p = mm_strip_tag (p, tag2);
mm_callback_info_set_data (info, desc, strlen (p) ? g_strdup (p) : NULL, g_free);
}
mm_callback_info_chain_complete_one (info);
}
#define GET_INFO_RESP_FN(func_name, tag, desc) \
#define GET_INFO_RESP_FN(func_name, tag, tag2, desc) \
static void \
func_name (MMAtSerialPort *port, \
GString *response, \
GError *error, \
gpointer user_data) \
{ \
info_item_done ((MMCallbackInfo *) user_data, response, error, tag , desc ); \
info_item_done ((MMCallbackInfo *) user_data, response, error, tag, tag2, desc ); \
}
GET_INFO_RESP_FN(get_revision_done, "+GMR:", "card-info-revision")
GET_INFO_RESP_FN(get_model_done, "+GMM:", "card-info-model")
GET_INFO_RESP_FN(get_manf_done, "+GMI:", "card-info-manf")
GET_INFO_RESP_FN(get_revision_done, "+GMR:", "AT+GMR", "card-info-revision")
GET_INFO_RESP_FN(get_model_done, "+GMM:", "AT+GMM", "card-info-model")
GET_INFO_RESP_FN(get_manf_done, "+GMI:", "AT+GMI", "card-info-manf")
GET_INFO_RESP_FN(get_c_revision_done, "+CGMR:", "card-info-c-revision")
GET_INFO_RESP_FN(get_c_model_done, "+CGMM:", "card-info-c-model")
GET_INFO_RESP_FN(get_c_manf_done, "+CGMI:", "card-info-c-manf")
GET_INFO_RESP_FN(get_c_revision_done, "+CGMR:", "AT+CGMR", "card-info-c-revision")
GET_INFO_RESP_FN(get_c_model_done, "+CGMM:", "AT+CGMM", "card-info-c-model")
GET_INFO_RESP_FN(get_c_manf_done, "+CGMI:", "AT+CGMI", "card-info-c-manf")
GET_INFO_RESP_FN(get_ati_done, NULL, "card-info-ati")
GET_INFO_RESP_FN(get_ati1_done, NULL, "card-info-ati1")
GET_INFO_RESP_FN(get_gsn_done, "+GSN:", "card-info-gsn")
GET_INFO_RESP_FN(get_cgsn_done, "+CGSN:", "card-info-c-gsn")
GET_INFO_RESP_FN(get_ati_done, NULL, "ATI", "card-info-ati")
GET_INFO_RESP_FN(get_ati1_done, NULL, "ATI1", "card-info-ati1")
GET_INFO_RESP_FN(get_gsn_done, "+GSN:", "AT+GSN", "card-info-gsn")
GET_INFO_RESP_FN(get_cgsn_done, "+CGSN:", "AT+CGSN", "card-info-c-gsn")
void
mm_modem_base_get_card_info (MMModemBase *self,
@@ -672,6 +677,14 @@ set_property (GObject *object, guint prop_id,
case MM_MODEM_PROP_UNLOCK_REQUIRED:
case MM_MODEM_PROP_UNLOCK_RETRIES:
break;
case MM_MODEM_PROP_HW_VID:
/* Construct only */
priv->vid = g_value_get_uint (value);
break;
case MM_MODEM_PROP_HW_PID:
/* Construct only */
priv->pid = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -724,6 +737,12 @@ get_property (GObject *object, guint prop_id,
case MM_MODEM_PROP_UNLOCK_RETRIES:
g_value_set_uint (value, priv->unlock_retries);
break;
case MM_MODEM_PROP_HW_VID:
g_value_set_uint (value, priv->vid);
break;
case MM_MODEM_PROP_HW_PID:
g_value_set_uint (value, priv->pid);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -819,6 +838,14 @@ mm_modem_base_class_init (MMModemBaseClass *klass)
MM_MODEM_PROP_UNLOCK_RETRIES,
MM_MODEM_UNLOCK_RETRIES);
g_object_class_override_property (object_class,
MM_MODEM_PROP_HW_VID,
MM_MODEM_HW_VID);
g_object_class_override_property (object_class,
MM_MODEM_PROP_HW_PID,
MM_MODEM_HW_PID);
mm_properties_changed_signal_new (object_class);
}

View File

@@ -15,6 +15,7 @@
*/
#include <config.h>
#include <stdio.h>
#include <ctype.h>
#include <glib.h>
#include <string.h>
@@ -807,8 +808,8 @@ mm_gsm_string_to_access_tech (const char *string)
/*************************************************************************/
char *
mm_create_device_identifier (const char *vid,
const char *pid,
mm_create_device_identifier (guint vid,
guint pid,
const char *ati,
const char *ati1,
const char *gsn,
@@ -817,9 +818,10 @@ mm_create_device_identifier (const char *vid,
const char *manf,
gboolean debug)
{
GString *devid;
GString *devid, *dbg = NULL;
GChecksum *sum;
char *p, *ret = NULL, *j = NULL, *dbg = NULL;
char *p, *ret = NULL;
char str_vid[10], str_pid[10];
/* Build up the device identifier */
devid = g_string_sized_new (50);
@@ -844,15 +846,29 @@ mm_create_device_identifier (const char *vid,
p = devid->str;
if (debug)
j = dbg = g_malloc0 (strlen (devid->str) + 1);
dbg = g_string_sized_new (strlen (devid->str) + 17);
sum = g_checksum_new (G_CHECKSUM_SHA1);
if (vid) {
snprintf (str_vid, sizeof (str_vid) - 1, "%08x", vid);
g_checksum_update (sum, (const guchar *) &str_vid[0], strlen (str_vid));
if (dbg)
g_string_append_printf (dbg, "%08x", vid);
}
if (vid) {
snprintf (str_pid, sizeof (str_pid) - 1, "%08x", pid);
g_checksum_update (sum, (const guchar *) &str_pid[0], strlen (str_pid));
if (dbg)
g_string_append_printf (dbg, "%08x", pid);
}
while (*p) {
/* Strip spaces and linebreaks */
if (!isblank (*p) && !isspace (*p) && isascii (*p)) {
g_checksum_update (sum, (const guchar *) p, 1);
if (dbg)
*j++ = *p;
g_string_append_c (dbg, *p);
}
p++;
}
@@ -860,9 +876,9 @@ mm_create_device_identifier (const char *vid,
g_checksum_free (sum);
if (dbg) {
g_debug ("Device ID source '%s'", dbg);
g_debug ("Device ID source '%s'", dbg->str);
g_debug ("Device ID '%s'", ret);
g_free (dbg);
g_string_free (dbg, TRUE);
}
return ret;

View File

@@ -59,8 +59,8 @@ gboolean mm_gsm_parse_cscs_support_response (const char *reply,
MMModemGsmAccessTech mm_gsm_string_to_access_tech (const char *string);
char *mm_create_device_identifier (const char *vid,
const char *pid,
char *mm_create_device_identifier (guint vid,
guint pid,
const char *ati,
const char *ati1,
const char *gsn,

View File

@@ -893,6 +893,22 @@ mm_modem_init (gpointer g_iface)
0, G_MAXUINT32, 0,
G_PARAM_READABLE));
g_object_interface_install_property
(g_iface,
g_param_spec_uint (MM_MODEM_HW_VID,
"Hardware vendor ID",
"Hardware vendor ID",
0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_interface_install_property
(g_iface,
g_param_spec_uint (MM_MODEM_HW_PID,
"Hardware product ID",
"Hardware product ID",
0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/* Signals */
g_signal_new ("state-changed",
iface_type,

View File

@@ -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_MODEM_H
@@ -65,6 +65,8 @@ typedef enum {
#define MM_MODEM_VALID "valid" /* not exported */
#define MM_MODEM_PLUGIN "plugin" /* not exported */
#define MM_MODEM_STATE "state" /* not exported */
#define MM_MODEM_HW_VID "hw-vid" /* not exported */
#define MM_MODEM_HW_PID "hw-pid" /* not exported */
#define MM_MODEM_TYPE_UNKNOWN 0
#define MM_MODEM_TYPE_GSM 1
@@ -89,7 +91,9 @@ typedef enum {
MM_MODEM_PROP_EQUIPMENT_IDENTIFIER,
MM_MODEM_PROP_UNLOCK_REQUIRED,
MM_MODEM_PROP_UNLOCK_RETRIES,
MM_MODEM_PROP_DEVICE_IDENTIFIER
MM_MODEM_PROP_DEVICE_IDENTIFIER,
MM_MODEM_PROP_HW_VID, /* Not exported */
MM_MODEM_PROP_HW_PID /* Not exported */
} MMModemProp;
typedef struct _MMModem MMModem;

View File

@@ -890,8 +890,8 @@ mm_plugin_base_get_device_ids (MMPluginBase *self,
guint16 *product)
{
MMPluginBasePrivate *priv;
GUdevDevice *device = NULL;
const char *vid, *pid;
GUdevDevice *device = NULL, *parent = NULL;
const char *vid, *pid, *parent_subsys;
gboolean success = FALSE;
g_return_val_if_fail (self != NULL, FALSE);
@@ -909,6 +909,18 @@ mm_plugin_base_get_device_ids (MMPluginBase *self,
if (!device)
goto out;
/* Bluetooth devices report the VID/PID of the BT adapter here, which
* isn't really what we want. Just return null IDs instead.
*/
parent = g_udev_device_get_parent (device);
if (parent) {
parent_subsys = g_udev_device_get_subsystem (parent);
if (parent_subsys && !strcmp (parent_subsys, "bluetooth")) {
success = TRUE;
goto out;
}
}
vid = g_udev_device_get_property (device, "ID_VENDOR_ID");
if (!vid || (strlen (vid) != 4))
goto out;
@@ -934,6 +946,8 @@ mm_plugin_base_get_device_ids (MMPluginBase *self,
out:
if (device)
g_object_unref (device);
if (parent)
g_object_unref (parent);
return success;
}

View File

@@ -782,6 +782,301 @@ test_cscs_blackberry_support_response (void *f, gpointer d)
g_assert (charsets == MM_MODEM_CHARSET_IRA);
}
typedef struct {
char *devid;
char *desc;
guint vid;
guint pid;
const char *ati;
const char *ati1;
const char *gsn;
const char *revision;
const char *model;
const char *manf;
} DevidItem;
static DevidItem devids[] = {
{ "36e7a8e78637fd380b2664507ea5de8fc317d05b",
"Huawei E1550",
0x12d1, 0x1001,
"\nManufacturer: huawei\n"
"Model: E1550\n"
"Revision: 11.608.09.01.21\n"
"IMEI: 235012412595195\n"
"+GCAP: +CGSM,+FCLASS,+DS\n",
NULL,
"\n235012412595195\n",
"\n11.608.09.01.21\n",
"\nE1550\n",
"\nhuawei\n"
},
{ "33b0fc4a06af5448df656ce12925979acf1cb600",
"Huawei EC121",
0x12d1, 0x1411,
"\nManufacturer: HUAWEI INCORPORATED\n"
"Model: EC121\n"
"Revision: 11.100.17.00.114\n"
"ESN: +GSN:12de4fa6\n"
"+CIS707-A, +MS, +ES, +DS, +FCLASS\n",
NULL,
"\n12de4fa6\n",
"\n11.100.17.00.114\n",
"\nEC121\n",
"\nHUAWEI INCORPORATED\n"
},
{ "d17f016a402354eaa1e24855f4308fafca9cadb1",
"Sierra USBConnect Mercury",
0x1199, 0x6880,
"\nManufacturer: Sierra Wireless, Inc.\n"
"Model: C885\n"
"Revision: J1_0_1_26AP C:/WS/FW/J1_0_1_26AP/MSM7200A/SRC/AMSS 2009/01/30 07:58:06\n"
"IMEI: 987866969112306\n"
"IMEI SV: 6\n"
"FSN: D603478104511\n"
"3GPP Release 6\n"
"+GCAP: +CGSM,+DS,+ES\n",
NULL,
"\n987866969112306\n",
"\nJ1_0_1_26AP C:/WS/FW/J1_0_1_26AP/MSM7200A/SRC/AMSS 2009/01/30 07:58:06\n",
"\nC885\n",
"\nSierra Wireless, Inc.\n"
},
{ "345e9eaad7624393aca85cde9bd859edf462414c",
"ZTE MF627",
0x19d2, 0x0031,
"\nManufacturer: ZTE INCORPORATED\n"
"Model: MF627\n"
"Revision: BD_3GHAP673A4V1.0.0B02\n"
"IMEI: 023589923858188\n"
"+GCAP: +CGSM,+FCLASS,+DS\n",
NULL,
"\n023589923858188\n",
"\nBD_3GHAP673A4V1.0.0B02\n",
"\nMF627\n",
"\nZTE INCORPORATED\n"
},
{ "69fa133a668b6f4dbf39b73500fd153ec240c73f",
"Sony-Ericsson MD300",
0x0fce, 0xd0cf,
"\nMD300\n",
"\nR3A018\n",
"\n349583712939483\n",
"\nR3A018\n",
"\nMD300\n",
"\nSony Ericsson\n"
},
{ "3dad89ed7d774938c38188cf29cf1c211e9d360b",
"Option iCON 7.2",
0x0af0, 0x6901,
"\nManufacturer: Option N.V.\n"
"Model: GTM378\n"
"Revision: 2.5.21Hd (Date: Jun 17 2008, Time: 12:30:47)\n",
NULL,
"\n129512359199159,SE393939TS\n",
"\n2.5.21Hd (Date: Jun 17 2008, Time: 12:30:47)\n",
"\nGTM378\n",
"\nOption N.V.\n"
},
{ "b0acccb956c9eaf2076e03697e74bf998dc44179",
"ZTE MF622",
0x19d2, 0x0001,
NULL,
NULL,
"\n235251122555115\n",
"\n3UKP671M3V1.0.0B08 3UKP671M3V1.0.0B08 1 [Jan 07 2008 16:00:00]\n",
"\nMF622\n",
"\nZTE INCORPORATED\n"
},
{ "29a5b258f1dc6f50c66a1a9a1ecdde97560799ab",
"Option 452",
0x0af0, 0x7901,
"\nManufacturer: Option N.V.\n"
"Model: GlobeTrotter HSUPA Modem\n"
"Revision: 2.12.0.0Hd (Date: Oct 29 2009, Time: 09:56:48)\n",
"\nManufacturer: Option N.V.\n"
"Model: GlobeTrotter HSUPA Modem\n"
"Revision: 2.12.0.0Hd (Date: Oct 29 2009, Time: 09:56:48)\n",
"\n000125491259519,PH2155R3TR\n",
"\n2.12.0.0Hd (Date: Oct 29 2009, Time: 09:56:48)\n",
"\nGlobeTrotter HSUPA Modem\n",
"\nOption N.V.\n"
},
{ "c756c67e960e693d5d221e381ea170b60bb9288f",
"Novatel XU870",
0x413c, 0x8118,
"\nManufacturer: Novatel Wireless Incorporated\n"
"Model: DELL XU870 ExpressCard\n"
"Revision: 9.5.05.01-02 [2006-10-20 17:19:09]\n"
"IMEI: 012051505051501\n"
"+GCAP: +CGSM,+DS\n",
"\nManufacturer: Novatel Wireless Incorporated\n"
"Model: DELL XU870 ExpressCard\n"
"Revision: 9.5.05.01-02 [2006-10-20 17:19:09]\n"
"IMEI: 012051505051501\n"
"+GCAP: +CGSM,+DS\n",
"\n012051505051501\n",
"\n9.5.05.01-02 [2006-10-20 17:19:09]\n",
"\nDELL XU870 ExpressCard\n",
"\nNovatel Wireless Incorporated\n"
},
{ "4162ba918ab54b7776bccc3830e6c6b7a6738244",
"Zoom 4596",
0x1c9e, 0x9603,
"\nManufacturer: Manufacturer\n"
"Model: HSPA USB MODEM\n"
"Revision: LQA0021.1.1_M573A\n"
"IMEI: 239664699635121\n"
"+GCAP: +CGSM,+FCLASS,+DS\n",
"\nManufacturer: Manufacturer\n"
"Model: HSPA USB MODEM\n"
"Revision: LQA0021.1.1_M573A\n"
"IMEI: 239664699635121\n"
"+GCAP: +CGSM,+FCLASS,+DS\n",
"\n239664699635121\n",
"\nLQA0021.1.1_M573A\n",
"\nHSPA USB MODEM\n",
"\nManufacturer\n"
},
{ "6d3a2fccd3588943a8962fd1e0d3ba752c706660",
"C-MOTECH CDX-650",
0x16d8, 0x6512,
"\nManufacturer: C-MOTECH Co., Ltd.\r\r\n"
"Model: CDX-650 \r\r\n"
"Revision: CDX65UAC03\r\r\n"
"Esn: 3B0C4B98\r\r\n"
"+GCAP: +CIS707A, +MS, +ES, +DS, +FCLASS\r\n",
"\nManufacturer: C-MOTECH Co., Ltd.\r\r\n"
"Model: CDX-650 \r\r\n"
"Revision: CDX65UAC03\r\r\n"
"Esn: 3B0C4B98\r\r\n"
"+GCAP: +CIS707A, +MS, +ES, +DS, +FCLASS\r\n",
"\n0x3B0C4B98\n",
"\nCDX65UAC03 1 [Oct 17 2007 13:30:00]\n",
"\nModel CDX-650 \n",
"\nC-MOTECH Co., Ltd.\n"
},
{ "cf50da63e6d48beb1d1c3b41d70ef6fa534c3e13",
"BUSlink SCWi275u",
0x22b8, 0x3802,
"\n144\n",
"\n000\n",
NULL,
"\n\"ADE_05_00_06032300I\"\n",
"\n\"GSM900\",\"GSM1800\",\"GSM1900\",\"GSM850\",\"MODEL=I250-000\"\n",
"\n\"Motorola CE, Copyright 2000\"\n"
},
{ "2aff568f2b60f3d6f3f6cac708ed5dce77b12b96",
"Motorola ROKR E2",
0x22b8, 0x3802,
NULL,
NULL,
"\n\"626936926396996\"\n",
"\n\"R564_G_12.00.47P\"\n",
"\n\"E2\"\n",
"\n\"Motorola\"\n"
},
{ "a7136c6067a43f055ca093cee75cb98ce6c9658e",
"Sony-Ericsson W580i",
0x0fce, 0xd089,
"\nSony Ericsson W580\n",
"\nCXC1123481\n",
"\n012505051512505\n",
"\nR8BE001 080115 1451 CXC1123481_NAM_1_LA\n",
"\nAAC-1052042-BV\n",
"\nSony Ericsson\n"
},
{ "b80ee70214bdf9672f2a268ce165ecfd9def5721",
"Huawei E226",
0x12d1, 0x1003,
"\nManufacturer: huawei\n"
"Model: E226\n"
"Revision: 11.310.15.00.150\n"
"IMEI: 232363662362362\n"
"+GCAP: +CGSM,+FCLASS,+DS\n",
"\nManufacturer: huawei\n"
"Model: E226\n"
"Revision: 11.310.15.00.150\n"
"IMEI: 232363662362362\n"
"+GCAP: +CGSM,+FCLASS,+DS\n",
"\n232363662362362\n",
"\n11.310.15.00.150\n",
"\nE226\n",
"\nhuawei\n"
},
{ "d902e1f234863aa107bfc2d0faefbee5ed6901f1",
"LG LX265",
0x1004, 0x6000,
"\nManufacturer: +GMI: LG Electronics Inc.\n"
"Model: +GMI: LG Electronics Inc.+GMM: Model:LG-LX265\n"
"Revision: +GMR: LX265V05, 50571\n"
"ESN: +GSN: 0x9235EB52\n"
"+GCAP: +CIS707-A, +MS, +ES, +DS, +FCLASS\n",
"\nManufacturer: +GMI: LG Electronics Inc.\n"
"Model: +GMI: LG Electronics Inc.+GMM: Model:LG-LX265\n"
"Revision: +GMR: LX265V05, 50571\n"
"ESN: +GSN: 0x9235EB52\n"
"+GCAP: +CIS707-A, +MS, +ES, +DS, +FCLASS\n",
"\n0x9235EB52\n",
"\nLX265V05, 50571\n",
"\nModel:LG-LX265\n",
"\nLG Electronics Inc.\n"
},
{ "543c2920e450e20a46368861fdec3a3b97ba8663",
"Nokia 2720a BT",
0x0000, 0x0000,
"\nNokia\n",
"\n012350150101501\n",
"\n012350150101501\n",
"\nV 08.62\n"
"24-07-09\n"
"RM-520\n"
"(c) Nokia \n",
"\nNokia 2720a-2b\n",
"\nNokia\n"
},
{ "6386ffa7a39ced3c9bfd1d693b90975661e54a86",
"Gobi 1000",
0x03f0, 0x1f1d,
"\nManufacturer: QUALCOMM INCORPORATED\n"
"Model: 88\n"
"Revision: D1020-SUUAASFA-4352 1 [Apr 14 2008 18:00:00]\n"
"IMEI: 239639269236269\n"
"+GCAP: +CGSM,+DS\n",
"\nManufacturer: QUALCOMM INCORPORATED\n"
"Model: 88\n"
"Revision: D1020-SUUAASFA-4352 1 [Apr 14 2008 18:00:00]\n"
"IMEI: 239639269236269\n"
"+GCAP: +CGSM,+DS\n",
"\n239639269236269\n",
"\nD1020-SUUAASFA-4352 1 [Apr 14 2008 18:00:00]\n",
"\n88\n",
"\nQUALCOMM INCORPORATED\n"
},
{ NULL }
};
static void
test_devid_item (void *f, gpointer d)
{
DevidItem *item = (DevidItem *) d;
char *devid;
g_print ("%s... ", item->desc);
devid = mm_create_device_identifier (item->vid,
item->pid,
item->ati,
item->ati1,
item->gsn,
item->revision,
item->model,
item->manf,
FALSE);
g_assert (devid);
if (strcmp (devid, item->devid))
g_message (devid);
g_assert (!strcmp (devid, item->devid));
}
static TestData *
test_data_new (void)
{
@@ -815,6 +1110,7 @@ int main (int argc, char **argv)
GTestSuite *suite;
TestData *data;
gint result;
DevidItem *item = &devids[0];
g_test_init (&argc, &argv, NULL);
@@ -879,6 +1175,11 @@ int main (int argc, char **argv)
g_test_suite_add (suite, TESTCASE (test_cscs_buslink_support_response, data));
g_test_suite_add (suite, TESTCASE (test_cscs_blackberry_support_response, data));
while (item->devid) {
g_test_suite_add (suite, TESTCASE (test_devid_item, (gconstpointer) item));
item++;
}
result = g_test_run ();
test_data_free (data);