api,libmm-glib,cli: handle firmware images of type `MM_FIRMWARE_IMAGE_TYPE_GOBI'

This commit is contained in:
Aleksander Morgado
2012-10-04 17:09:27 +02:00
parent 1b83af9482
commit 1ccf89dbb8
6 changed files with 294 additions and 11 deletions

View File

@@ -134,6 +134,9 @@ list_process_reply (MMFirmwareProperties *selected,
GList *result, GList *result,
const GError *error) const GError *error)
{ {
#undef VALIDATE_UNKNOWN
#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
if (error) { if (error) {
g_printerr ("error: couldn't list firmware images: '%s'\n", g_printerr ("error: couldn't list firmware images: '%s'\n",
error->message); error->message);
@@ -152,7 +155,7 @@ list_process_reply (MMFirmwareProperties *selected,
MMFirmwareProperties *props = MM_FIRMWARE_PROPERTIES (l->data); MMFirmwareProperties *props = MM_FIRMWARE_PROPERTIES (l->data);
g_print ("\t[%u] %s%s\n" g_print ("\t[%u] %s%s\n"
"\t\t Type: '%s'\n", "\t\tType: '%s'\n",
i, i,
mm_firmware_properties_get_unique_id (props), mm_firmware_properties_get_unique_id (props),
((selected && ((selected &&
@@ -161,6 +164,20 @@ list_process_reply (MMFirmwareProperties *selected,
" (CURRENT)" : ""), " (CURRENT)" : ""),
mm_firmware_image_type_get_string ( mm_firmware_image_type_get_string (
mm_firmware_properties_get_image_type (props))); mm_firmware_properties_get_image_type (props)));
if (mm_firmware_properties_get_image_type (props) == MM_FIRMWARE_IMAGE_TYPE_GOBI) {
g_print ("\t\t[Gobi] PRI version: '%s'\n"
"\t\t[Gobi] PRI info: '%s'\n"
"\t\t[Gobi] Boot version: '%s'\n"
"\t\t[Gobi] PRI Unique ID: '%s'\n"
"\t\t[Gobi] Modem Unique ID: '%s'\n",
VALIDATE_UNKNOWN (mm_firmware_properties_get_gobi_pri_version (props)),
VALIDATE_UNKNOWN (mm_firmware_properties_get_gobi_pri_info (props)),
VALIDATE_UNKNOWN (mm_firmware_properties_get_gobi_boot_version (props)),
VALIDATE_UNKNOWN (mm_firmware_properties_get_gobi_pri_unique_id (props)),
VALIDATE_UNKNOWN (mm_firmware_properties_get_gobi_modem_unique_id (props)));
}
g_object_unref (props); g_object_unref (props);
} }
g_list_free (result); g_list_free (result);

View File

@@ -533,10 +533,20 @@ MMFirmwareProperties
<SUBSECTION Getters> <SUBSECTION Getters>
mm_firmware_properties_get_image_type mm_firmware_properties_get_image_type
mm_firmware_properties_get_unique_id mm_firmware_properties_get_unique_id
mm_firmware_properties_get_gobi_pri_version
mm_firmware_properties_get_gobi_pri_info
mm_firmware_properties_get_gobi_boot_version
mm_firmware_properties_get_gobi_pri_unique_id
mm_firmware_properties_get_gobi_modem_unique_id
<SUBSECTION Private> <SUBSECTION Private>
mm_firmware_properties_new mm_firmware_properties_new
mm_firmware_properties_new_from_dictionary mm_firmware_properties_new_from_dictionary
mm_firmware_properties_get_dictionary mm_firmware_properties_get_dictionary
mm_firmware_properties_set_gobi_pri_version
mm_firmware_properties_set_gobi_pri_info
mm_firmware_properties_set_gobi_boot_version
mm_firmware_properties_set_gobi_pri_unique_id
mm_firmware_properties_set_gobi_modem_unique_id
<SUBSECTION Standard> <SUBSECTION Standard>
MMFirmwarePropertiesClass MMFirmwarePropertiesClass
MMFirmwarePropertiesPrivate MMFirmwarePropertiesPrivate

View File

@@ -688,12 +688,14 @@ typedef enum { /*< underscore_name=mm_modem_3gpp_ussd_session_state >*/
* MMFirmwareImageType: * MMFirmwareImageType:
* @MM_FIRMWARE_IMAGE_TYPE_UNKNOWN: Unknown firmware type. * @MM_FIRMWARE_IMAGE_TYPE_UNKNOWN: Unknown firmware type.
* @MM_FIRMWARE_IMAGE_TYPE_GENERIC: Generic firmware image. * @MM_FIRMWARE_IMAGE_TYPE_GENERIC: Generic firmware image.
* @MM_FIRMWARE_IMAGE_TYPE_GOBI: Firmware image of Gobi devices.
* *
* Type of firmware image. * Type of firmware image.
*/ */
typedef enum { /*< underscore_name=mm_firmware_image_type >*/ typedef enum { /*< underscore_name=mm_firmware_image_type >*/
MM_FIRMWARE_IMAGE_TYPE_UNKNOWN = 0, MM_FIRMWARE_IMAGE_TYPE_UNKNOWN = 0,
MM_FIRMWARE_IMAGE_TYPE_GENERIC = 1 MM_FIRMWARE_IMAGE_TYPE_GENERIC = 1,
MM_FIRMWARE_IMAGE_TYPE_GOBI = 2,
} MMFirmwareImageType; } MMFirmwareImageType;
#endif /* _MODEMMANAGER_ENUMS_H_ */ #endif /* _MODEMMANAGER_ENUMS_H_ */

View File

@@ -40,13 +40,39 @@
string value (signature <literal>"s"</literal>). string value (signature <literal>"s"</literal>).
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry><term><literal>"version"</literal></term> <varlistentry><term><literal>"gobi-pri-version"</literal></term>
<listitem> <listitem>
(Optional) The version of the firmware, given as a string value (Optional) The version of the PRI firmware image, in images of type
(signature <literal>"s"</literal>). The format is <link linkend="MM-FIRMWARE-IMAGE-TYPE-GOBI:CAPS">MM_FIRMWARE_IMAGE_TYPE_GOBI</link>,
unspecified; tools attempting to upgrade firmware automatically must given as a string value (signature <literal>"s"</literal>).
understand the versioning scheme used by the modem driver they are </listitem>
interacting with. </varlistentry>
<varlistentry><term><literal>"gobi-pri-info"</literal></term>
<listitem>
(Optional) Additional information of the PRI image, in images of type
<link linkend="MM-FIRMWARE-IMAGE-TYPE-GOBI:CAPS">MM_FIRMWARE_IMAGE_TYPE_GOBI</link>,
given as a string value (signature <literal>"s"</literal>).
</listitem>
</varlistentry>
<varlistentry><term><literal>"gobi-boot-version"</literal></term>
<listitem>
(Optional) The boot version of the PRI firmware image, in images of type
<link linkend="MM-FIRMWARE-IMAGE-TYPE-GOBI:CAPS">MM_FIRMWARE_IMAGE_TYPE_GOBI</link>,
given as a string value (signature <literal>"s"</literal>).
</listitem>
</varlistentry>
<varlistentry><term><literal>"gobi-pri-unique-id"</literal></term>
<listitem>
(Optional) The unique ID of the PRI firmware image, in images of type
<link linkend="MM-FIRMWARE-IMAGE-TYPE-GOBI:CAPS">MM_FIRMWARE_IMAGE_TYPE_GOBI</link>,
given as a string value (signature <literal>"s"</literal>).
</listitem>
</varlistentry>
<varlistentry><term><literal>"gobi-modem-unique-id"</literal></term>
<listitem>
(Optional) The unique ID of the Modem firmware image, in images of type
<link linkend="MM-FIRMWARE-IMAGE-TYPE-GOBI:CAPS">MM_FIRMWARE_IMAGE_TYPE_GOBI</link>,
given as a string value (signature <literal>"s"</literal>).
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>

View File

@@ -33,13 +33,25 @@
G_DEFINE_TYPE (MMFirmwareProperties, mm_firmware_properties, G_TYPE_OBJECT); G_DEFINE_TYPE (MMFirmwareProperties, mm_firmware_properties, G_TYPE_OBJECT);
#define PROPERTY_UNIQUE_ID "unique-id" #define PROPERTY_UNIQUE_ID "unique-id"
#define PROPERTY_IMAGE_TYPE "image-type" #define PROPERTY_IMAGE_TYPE "image-type"
#define PROPERTY_GOBI_PRI_VERSION "gobi-pri-version"
#define PROPERTY_GOBI_PRI_INFO "gobi-pri-info"
#define PROPERTY_GOBI_BOOT_VERSION "gobi-boot-version"
#define PROPERTY_GOBI_PRI_UNIQUE_ID "gobi-pri-unique-id"
#define PROPERTY_GOBI_MODEM_UNIQUE_ID "gobi-modem-unique-id"
struct _MMFirmwarePropertiesPrivate { struct _MMFirmwarePropertiesPrivate {
/* Mandatory parameters */ /* Mandatory parameters */
MMFirmwareImageType image_type; MMFirmwareImageType image_type;
gchar *unique_id; gchar *unique_id;
/* Gobi specific */
gchar *gobi_pri_version;
gchar *gobi_pri_info;
gchar *gobi_boot_version;
gchar *gobi_pri_unique_id;
gchar *gobi_modem_unique_id;
}; };
static MMFirmwareProperties *firmware_properties_new_empty (void); static MMFirmwareProperties *firmware_properties_new_empty (void);
@@ -82,6 +94,154 @@ mm_firmware_properties_get_image_type (MMFirmwareProperties *self)
/*****************************************************************************/ /*****************************************************************************/
/**
* mm_firmware_properties_get_gobi_pri_version:
* @self: a #MMFirmwareProperties.
*
* Gets the PRI version of a firmware image of type %MM_FIRMWARE_IMAGE_TYPE_GOBI.
*
* Returns: The PRI version, or %NULL if unknown. Do not free the returned value, it is owned by @self.
*/
const gchar *
mm_firmware_properties_get_gobi_pri_version (MMFirmwareProperties *self)
{
g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL);
g_return_val_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI, NULL);
return self->priv->gobi_pri_version;
}
void
mm_firmware_properties_set_gobi_pri_version (MMFirmwareProperties *self,
const gchar *version)
{
g_return_if_fail (MM_IS_FIRMWARE_PROPERTIES (self));
g_return_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI);
g_free (self->priv->gobi_pri_version);
self->priv->gobi_pri_version = g_strdup (version);
}
/*****************************************************************************/
/**
* mm_firmware_properties_get_gobi_pri_info:
* @self: a #MMFirmwareProperties.
*
* Gets the PRI info of a firmware image of type %MM_FIRMWARE_IMAGE_TYPE_GOBI.
*
* Returns: The PRI info, or %NULL if unknown. Do not free the returned value, it is owned by @self.
*/
const gchar *
mm_firmware_properties_get_gobi_pri_info (MMFirmwareProperties *self)
{
g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL);
g_return_val_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI, NULL);
return self->priv->gobi_pri_info;
}
void
mm_firmware_properties_set_gobi_pri_info (MMFirmwareProperties *self,
const gchar *info)
{
g_return_if_fail (MM_IS_FIRMWARE_PROPERTIES (self));
g_return_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI);
g_free (self->priv->gobi_pri_info);
self->priv->gobi_pri_info = g_strdup (info);
}
/**
* mm_firmware_properties_get_gobi_boot_version:
* @self: a #MMFirmwareProperties.
*
* Gets the boot version of a firmware image of type %MM_FIRMWARE_IMAGE_TYPE_GOBI.
*
* Returns: The boot version, or %NULL if unknown. Do not free the returned value, it is owned by @self.
*/
const gchar *
mm_firmware_properties_get_gobi_boot_version (MMFirmwareProperties *self)
{
g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL);
g_return_val_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI, NULL);
return self->priv->gobi_boot_version;
}
void
mm_firmware_properties_set_gobi_boot_version (MMFirmwareProperties *self,
const gchar *version)
{
g_return_if_fail (MM_IS_FIRMWARE_PROPERTIES (self));
g_return_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI);
g_free (self->priv->gobi_boot_version);
self->priv->gobi_boot_version = g_strdup (version);
}
/*****************************************************************************/
/**
* mm_firmware_properties_get_gobi_pri_unique_id:
* @self: a #MMFirmwareProperties.
*
* Gets the PRI unique ID of a firmware image of type %MM_FIRMWARE_IMAGE_TYPE_GOBI.
*
* Returns: The PRI unique ID, or %NULL if unknown. Do not free the returned value, it is owned by @self.
*/
const gchar *
mm_firmware_properties_get_gobi_pri_unique_id (MMFirmwareProperties *self)
{
g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL);
g_return_val_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI, NULL);
return self->priv->gobi_pri_unique_id;
}
void
mm_firmware_properties_set_gobi_pri_unique_id (MMFirmwareProperties *self,
const gchar *unique_id)
{
g_return_if_fail (MM_IS_FIRMWARE_PROPERTIES (self));
g_return_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI);
g_free (self->priv->gobi_pri_unique_id);
self->priv->gobi_pri_unique_id = g_strdup (unique_id);
}
/*****************************************************************************/
/**
* mm_firmware_properties_get_gobi_modem_unique_id:
* @self: a #MMFirmwareProperties.
*
* Gets the MODEM unique ID of a firmware image of type %MM_FIRMWARE_IMAGE_TYPE_GOBI.
*
* Returns: The PRI unique ID, or %NULL if unknown. Do not free the returned value, it is owned by @self.
*/
const gchar *
mm_firmware_properties_get_gobi_modem_unique_id (MMFirmwareProperties *self)
{
g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL);
g_return_val_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI, NULL);
return self->priv->gobi_modem_unique_id;
}
void
mm_firmware_properties_set_gobi_modem_unique_id (MMFirmwareProperties *self,
const gchar *unique_id)
{
g_return_if_fail (MM_IS_FIRMWARE_PROPERTIES (self));
g_return_if_fail (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI);
g_free (self->priv->gobi_modem_unique_id);
self->priv->gobi_modem_unique_id = g_strdup (unique_id);
}
/*****************************************************************************/
/** /**
* mm_firmware_properties_get_dictionary: * mm_firmware_properties_get_dictionary:
* @self: A #MMFirmwareProperties. * @self: A #MMFirmwareProperties.
@@ -115,6 +275,34 @@ mm_firmware_properties_get_dictionary (MMFirmwareProperties *self)
PROPERTY_IMAGE_TYPE, PROPERTY_IMAGE_TYPE,
g_variant_new_uint32 (self->priv->image_type)); g_variant_new_uint32 (self->priv->image_type));
if (self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_GOBI) {
if (self->priv->gobi_pri_version)
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_GOBI_PRI_VERSION,
g_variant_new_string (self->priv->gobi_pri_version));
if (self->priv->gobi_pri_info)
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_GOBI_PRI_INFO,
g_variant_new_string (self->priv->gobi_pri_info));
if (self->priv->gobi_boot_version)
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_GOBI_BOOT_VERSION,
g_variant_new_string (self->priv->gobi_boot_version));
if (self->priv->gobi_pri_unique_id)
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_GOBI_PRI_UNIQUE_ID,
g_variant_new_string (self->priv->gobi_pri_unique_id));
if (self->priv->gobi_modem_unique_id)
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_GOBI_MODEM_UNIQUE_ID,
g_variant_new_string (self->priv->gobi_modem_unique_id));
}
return g_variant_ref_sink (g_variant_builder_end (&builder)); return g_variant_ref_sink (g_variant_builder_end (&builder));
} }
@@ -129,8 +317,24 @@ consume_variant (MMFirmwareProperties *self,
if (g_str_equal (key, PROPERTY_UNIQUE_ID)) { if (g_str_equal (key, PROPERTY_UNIQUE_ID)) {
g_free (self->priv->unique_id); g_free (self->priv->unique_id);
self->priv->unique_id = g_variant_dup_string (value, NULL); self->priv->unique_id = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, PROPERTY_IMAGE_TYPE)) } else if (g_str_equal (key, PROPERTY_IMAGE_TYPE)) {
self->priv->image_type = g_variant_get_uint32 (value); self->priv->image_type = g_variant_get_uint32 (value);
} else if (g_str_equal (key, PROPERTY_GOBI_PRI_VERSION)) {
g_free (self->priv->gobi_pri_version);
self->priv->gobi_pri_version = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, PROPERTY_GOBI_PRI_INFO)) {
g_free (self->priv->gobi_pri_info);
self->priv->gobi_pri_info = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, PROPERTY_GOBI_BOOT_VERSION)) {
g_free (self->priv->gobi_boot_version);
self->priv->gobi_boot_version = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, PROPERTY_GOBI_PRI_UNIQUE_ID)) {
g_free (self->priv->gobi_pri_unique_id);
self->priv->gobi_pri_unique_id = g_variant_dup_string (value, NULL);
} else if (g_str_equal (key, PROPERTY_GOBI_MODEM_UNIQUE_ID)) {
g_free (self->priv->gobi_modem_unique_id);
self->priv->gobi_modem_unique_id = g_variant_dup_string (value, NULL);
}
else { else {
/* Set error */ /* Set error */
g_set_error (error, g_set_error (error,
@@ -267,6 +471,11 @@ finalize (GObject *object)
MMFirmwareProperties *self = MM_FIRMWARE_PROPERTIES (object); MMFirmwareProperties *self = MM_FIRMWARE_PROPERTIES (object);
g_free (self->priv->unique_id); g_free (self->priv->unique_id);
g_free (self->priv->gobi_pri_version);
g_free (self->priv->gobi_pri_info);
g_free (self->priv->gobi_boot_version);
g_free (self->priv->gobi_pri_unique_id);
g_free (self->priv->gobi_modem_unique_id);
G_OBJECT_CLASS (mm_firmware_properties_parent_class)->finalize (object); G_OBJECT_CLASS (mm_firmware_properties_parent_class)->finalize (object);
} }

View File

@@ -58,6 +58,13 @@ GType mm_firmware_properties_get_type (void);
const gchar *mm_firmware_properties_get_unique_id (MMFirmwareProperties *self); const gchar *mm_firmware_properties_get_unique_id (MMFirmwareProperties *self);
MMFirmwareImageType mm_firmware_properties_get_image_type (MMFirmwareProperties *self); MMFirmwareImageType mm_firmware_properties_get_image_type (MMFirmwareProperties *self);
/* Gobi specific */
const gchar *mm_firmware_properties_get_gobi_pri_version (MMFirmwareProperties *self);
const gchar *mm_firmware_properties_get_gobi_pri_info (MMFirmwareProperties *self);
const gchar *mm_firmware_properties_get_gobi_boot_version (MMFirmwareProperties *self);
const gchar *mm_firmware_properties_get_gobi_pri_unique_id (MMFirmwareProperties *self);
const gchar *mm_firmware_properties_get_gobi_modem_unique_id (MMFirmwareProperties *self);
/*****************************************************************************/ /*****************************************************************************/
/* ModemManager/libmm-glib/mmcli specific methods */ /* ModemManager/libmm-glib/mmcli specific methods */
@@ -70,6 +77,18 @@ MMFirmwareProperties *mm_firmware_properties_new (MMFirmwareImageType image_type
MMFirmwareProperties *mm_firmware_properties_new_from_dictionary (GVariant *dictionary, MMFirmwareProperties *mm_firmware_properties_new_from_dictionary (GVariant *dictionary,
GError **error); GError **error);
/* Gobi specific */
void mm_firmware_properties_set_gobi_pri_version (MMFirmwareProperties *self,
const gchar *version);
void mm_firmware_properties_set_gobi_pri_info (MMFirmwareProperties *self,
const gchar *info);
void mm_firmware_properties_set_gobi_boot_version (MMFirmwareProperties *self,
const gchar *version);
void mm_firmware_properties_set_gobi_pri_unique_id (MMFirmwareProperties *self,
const gchar *id);
void mm_firmware_properties_set_gobi_modem_unique_id (MMFirmwareProperties *self,
const gchar *id);
GVariant *mm_firmware_properties_get_dictionary (MMFirmwareProperties *self); GVariant *mm_firmware_properties_get_dictionary (MMFirmwareProperties *self);
#endif #endif