api,libmm-glib: use a 'unique-id' as ID of the firmware image, not a 'name'
Also, make only the 'unique-id' mandatory.
This commit is contained in:
@@ -54,7 +54,7 @@ static GOptionEntry entries[] = {
|
|||||||
},
|
},
|
||||||
{ "firmware-select", 0, 0, G_OPTION_ARG_STRING, &select_str,
|
{ "firmware-select", 0, 0, G_OPTION_ARG_STRING, &select_str,
|
||||||
"Select a given firmware image",
|
"Select a given firmware image",
|
||||||
"[NAME]"
|
"[Unique ID]"
|
||||||
},
|
},
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
@@ -157,17 +157,15 @@ 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\t Type: '%s'\n",
|
||||||
"\t\tVersion: '%s'\n",
|
|
||||||
i,
|
i,
|
||||||
mm_firmware_properties_get_name (props),
|
mm_firmware_properties_get_unique_id (props),
|
||||||
((selected &&
|
((selected &&
|
||||||
g_str_equal (mm_firmware_properties_get_name (props),
|
g_str_equal (mm_firmware_properties_get_unique_id (props),
|
||||||
mm_firmware_properties_get_name (selected))) ?
|
mm_firmware_properties_get_unique_id (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)));
|
||||||
mm_firmware_properties_get_version (props));
|
|
||||||
g_object_unref (props);
|
g_object_unref (props);
|
||||||
}
|
}
|
||||||
g_list_free (result);
|
g_list_free (result);
|
||||||
|
@@ -532,8 +532,7 @@ mm_modem_firmware_get_type
|
|||||||
MMFirmwareProperties
|
MMFirmwareProperties
|
||||||
<SUBSECTION Getters>
|
<SUBSECTION Getters>
|
||||||
mm_firmware_properties_get_image_type
|
mm_firmware_properties_get_image_type
|
||||||
mm_firmware_properties_get_name
|
mm_firmware_properties_get_unique_id
|
||||||
mm_firmware_properties_get_version
|
|
||||||
<SUBSECTION Private>
|
<SUBSECTION Private>
|
||||||
mm_firmware_properties_new
|
mm_firmware_properties_new
|
||||||
mm_firmware_properties_new_from_dictionary
|
mm_firmware_properties_new_from_dictionary
|
||||||
|
@@ -34,15 +34,15 @@
|
|||||||
will only expose only the mandatory properties.
|
will only expose only the mandatory properties.
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry><term><literal>"name"</literal></term>
|
<varlistentry><term><literal>"unique-id"</literal></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
(Required) A user-readable name for the firmware image, given as a
|
(Required) A user-readable unique ID for the firmware image, given as a
|
||||||
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>"version"</literal></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
(Required) The version of the firmware, given as a string value
|
(Optional) The version of the firmware, given as a string value
|
||||||
(signature <literal>"s"</literal>). The format is
|
(signature <literal>"s"</literal>). The format is
|
||||||
unspecified; tools attempting to upgrade firmware automatically must
|
unspecified; tools attempting to upgrade firmware automatically must
|
||||||
understand the versioning scheme used by the modem driver they are
|
understand the versioning scheme used by the modem driver they are
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Select:
|
Select:
|
||||||
@name: The unique name of the firmware image to select.
|
@uniqueid: The unique ID of the firmware image to select.
|
||||||
|
|
||||||
Selects a different firmware image to use, and immediately resets the
|
Selects a different firmware image to use, and immediately resets the
|
||||||
modem so that it begins using the new firmware image.
|
modem so that it begins using the new firmware image.
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
or if the image could not be selected for some reason.
|
or if the image could not be selected for some reason.
|
||||||
-->
|
-->
|
||||||
<method name="Select">
|
<method name="Select">
|
||||||
<arg name="name" type="s" direction="in" />
|
<arg name="uniqueid" type="s" direction="in" />
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
@@ -33,15 +33,13 @@
|
|||||||
|
|
||||||
G_DEFINE_TYPE (MMFirmwareProperties, mm_firmware_properties, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (MMFirmwareProperties, mm_firmware_properties, G_TYPE_OBJECT);
|
||||||
|
|
||||||
#define PROPERTY_NAME "name"
|
#define PROPERTY_UNIQUE_ID "unique-id"
|
||||||
#define PROPERTY_VERSION "version"
|
|
||||||
#define PROPERTY_IMAGE_TYPE "image-type"
|
#define PROPERTY_IMAGE_TYPE "image-type"
|
||||||
|
|
||||||
struct _MMFirmwarePropertiesPrivate {
|
struct _MMFirmwarePropertiesPrivate {
|
||||||
/* Mandatory parameters */
|
/* Mandatory parameters */
|
||||||
MMFirmwareImageType image_type;
|
MMFirmwareImageType image_type;
|
||||||
gchar *name;
|
gchar *unique_id;
|
||||||
gchar *version;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static MMFirmwareProperties *firmware_properties_new_empty (void);
|
static MMFirmwareProperties *firmware_properties_new_empty (void);
|
||||||
@@ -49,37 +47,19 @@ static MMFirmwareProperties *firmware_properties_new_empty (void);
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mm_firmware_properties_get_name:
|
* mm_firmware_properties_get_unique_id:
|
||||||
* @self: A #MMFirmwareProperties.
|
* @self: A #MMFirmwareProperties.
|
||||||
*
|
*
|
||||||
* Gets the unique name of the firmare image.
|
* Gets the unique ID of the firmare image.
|
||||||
*
|
*
|
||||||
* Returns: (transfer none): The name of the image. Do not free the returned value, it is owned by @self.
|
* Returns: (transfer none): The ID of the image. Do not free the returned value, it is owned by @self.
|
||||||
*/
|
*/
|
||||||
const gchar *
|
const gchar *
|
||||||
mm_firmware_properties_get_name (MMFirmwareProperties *self)
|
mm_firmware_properties_get_unique_id (MMFirmwareProperties *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL);
|
g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL);
|
||||||
|
|
||||||
return self->priv->name;
|
return self->priv->unique_id;
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* mm_firmware_properties_get_version:
|
|
||||||
* @self: A #MMFirmwareProperties.
|
|
||||||
*
|
|
||||||
* Gets the version string of the firmare image.
|
|
||||||
*
|
|
||||||
* Returns: (transfer none): The version of the image. Do not free the returned value, it is owned by @self.
|
|
||||||
*/
|
|
||||||
const gchar *
|
|
||||||
mm_firmware_properties_get_version (MMFirmwareProperties *self)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (MM_IS_FIRMWARE_PROPERTIES (self), NULL);
|
|
||||||
|
|
||||||
return self->priv->version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -127,13 +107,8 @@ mm_firmware_properties_get_dictionary (MMFirmwareProperties *self)
|
|||||||
|
|
||||||
g_variant_builder_add (&builder,
|
g_variant_builder_add (&builder,
|
||||||
"{sv}",
|
"{sv}",
|
||||||
PROPERTY_NAME,
|
PROPERTY_UNIQUE_ID,
|
||||||
g_variant_new_string (self->priv->name));
|
g_variant_new_string (self->priv->unique_id));
|
||||||
|
|
||||||
g_variant_builder_add (&builder,
|
|
||||||
"{sv}",
|
|
||||||
PROPERTY_VERSION,
|
|
||||||
g_variant_new_string (self->priv->version));
|
|
||||||
|
|
||||||
g_variant_builder_add (&builder,
|
g_variant_builder_add (&builder,
|
||||||
"{sv}",
|
"{sv}",
|
||||||
@@ -151,12 +126,9 @@ consume_variant (MMFirmwareProperties *self,
|
|||||||
GVariant *value,
|
GVariant *value,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
if (g_str_equal (key, PROPERTY_NAME)) {
|
if (g_str_equal (key, PROPERTY_UNIQUE_ID)) {
|
||||||
g_free (self->priv->name);
|
g_free (self->priv->unique_id);
|
||||||
self->priv->name = g_variant_dup_string (value, NULL);
|
self->priv->unique_id = g_variant_dup_string (value, NULL);
|
||||||
} else if (g_str_equal (key, PROPERTY_VERSION)) {
|
|
||||||
g_free (self->priv->version);
|
|
||||||
self->priv->version = 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 {
|
else {
|
||||||
@@ -230,8 +202,7 @@ mm_firmware_properties_new_from_dictionary (GVariant *dictionary,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If mandatory properties missing, destroy the object */
|
/* If mandatory properties missing, destroy the object */
|
||||||
if (!self->priv->name ||
|
if (!self->priv->unique_id ||
|
||||||
!self->priv->version ||
|
|
||||||
self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_UNKNOWN) {
|
self->priv->image_type == MM_FIRMWARE_IMAGE_TYPE_UNKNOWN) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
@@ -250,8 +221,7 @@ mm_firmware_properties_new_from_dictionary (GVariant *dictionary,
|
|||||||
/**
|
/**
|
||||||
* mm_firmware_properties_new:
|
* mm_firmware_properties_new:
|
||||||
* @image_type: A #MMFirmwareImageType specifying the type of the image.
|
* @image_type: A #MMFirmwareImageType specifying the type of the image.
|
||||||
* @name: The unique name of the image.
|
* @unique_id: The unique ID of the image.
|
||||||
* @version: The version of the image.
|
|
||||||
*
|
*
|
||||||
* Creates a new #MMFirmwareProperties object with the properties specified.
|
* Creates a new #MMFirmwareProperties object with the properties specified.
|
||||||
*
|
*
|
||||||
@@ -259,19 +229,16 @@ mm_firmware_properties_new_from_dictionary (GVariant *dictionary,
|
|||||||
*/
|
*/
|
||||||
MMFirmwareProperties *
|
MMFirmwareProperties *
|
||||||
mm_firmware_properties_new (MMFirmwareImageType image_type,
|
mm_firmware_properties_new (MMFirmwareImageType image_type,
|
||||||
const gchar *name,
|
const gchar *unique_id)
|
||||||
const gchar *version)
|
|
||||||
{
|
{
|
||||||
MMFirmwareProperties *self;
|
MMFirmwareProperties *self;
|
||||||
|
|
||||||
g_return_val_if_fail (image_type != MM_FIRMWARE_IMAGE_TYPE_UNKNOWN, NULL);
|
g_return_val_if_fail (image_type != MM_FIRMWARE_IMAGE_TYPE_UNKNOWN, NULL);
|
||||||
g_return_val_if_fail (name != NULL, NULL);
|
g_return_val_if_fail (unique_id != NULL, NULL);
|
||||||
g_return_val_if_fail (version != NULL, NULL);
|
|
||||||
|
|
||||||
self = firmware_properties_new_empty ();
|
self = firmware_properties_new_empty ();
|
||||||
self->priv->image_type = image_type;
|
self->priv->image_type = image_type;
|
||||||
self->priv->name = g_strdup (name);
|
self->priv->unique_id = g_strdup (unique_id);
|
||||||
self->priv->version = g_strdup (version);
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -299,8 +266,7 @@ finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
MMFirmwareProperties *self = MM_FIRMWARE_PROPERTIES (object);
|
MMFirmwareProperties *self = MM_FIRMWARE_PROPERTIES (object);
|
||||||
|
|
||||||
g_free (self->priv->name);
|
g_free (self->priv->unique_id);
|
||||||
g_free (self->priv->version);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (mm_firmware_properties_parent_class)->finalize (object);
|
G_OBJECT_CLASS (mm_firmware_properties_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@@ -55,8 +55,7 @@ struct _MMFirmwarePropertiesClass {
|
|||||||
|
|
||||||
GType mm_firmware_properties_get_type (void);
|
GType mm_firmware_properties_get_type (void);
|
||||||
|
|
||||||
const gchar *mm_firmware_properties_get_name (MMFirmwareProperties *self);
|
const gchar *mm_firmware_properties_get_unique_id (MMFirmwareProperties *self);
|
||||||
const gchar *mm_firmware_properties_get_version (MMFirmwareProperties *self);
|
|
||||||
MMFirmwareImageType mm_firmware_properties_get_image_type (MMFirmwareProperties *self);
|
MMFirmwareImageType mm_firmware_properties_get_image_type (MMFirmwareProperties *self);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -67,8 +66,7 @@ MMFirmwareImageType mm_firmware_properties_get_image_type (MMFirmwareProperties
|
|||||||
defined (LIBMM_GLIB_COMPILATION)
|
defined (LIBMM_GLIB_COMPILATION)
|
||||||
|
|
||||||
MMFirmwareProperties *mm_firmware_properties_new (MMFirmwareImageType image_type,
|
MMFirmwareProperties *mm_firmware_properties_new (MMFirmwareImageType image_type,
|
||||||
const gchar *name,
|
const gchar *unique_id);
|
||||||
const gchar *version);
|
|
||||||
MMFirmwareProperties *mm_firmware_properties_new_from_dictionary (GVariant *dictionary,
|
MMFirmwareProperties *mm_firmware_properties_new_from_dictionary (GVariant *dictionary,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
@@ -105,7 +105,7 @@ mm_modem_firmware_select_finish (MMModemFirmware *self,
|
|||||||
/**
|
/**
|
||||||
* mm_modem_firmware_select:
|
* mm_modem_firmware_select:
|
||||||
* @self: A #MMModemFirmware.
|
* @self: A #MMModemFirmware.
|
||||||
* @name: Unique name of the firmware image to select.
|
* @unique_id: Unique ID of the firmware image to select.
|
||||||
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||||
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
|
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
|
||||||
* @user_data: User data to pass to @callback.
|
* @user_data: User data to pass to @callback.
|
||||||
@@ -122,21 +122,21 @@ mm_modem_firmware_select_finish (MMModemFirmware *self,
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mm_modem_firmware_select (MMModemFirmware *self,
|
mm_modem_firmware_select (MMModemFirmware *self,
|
||||||
const gchar *name,
|
const gchar *unique_id,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
g_return_if_fail (MM_IS_MODEM_FIRMWARE (self));
|
g_return_if_fail (MM_IS_MODEM_FIRMWARE (self));
|
||||||
g_return_if_fail (name != NULL || name[0] == '\0');
|
g_return_if_fail (unique_id != NULL || unique_id[0] == '\0');
|
||||||
|
|
||||||
mm_gdbus_modem_firmware_call_select (MM_GDBUS_MODEM_FIRMWARE (self), name, cancellable, callback, user_data);
|
mm_gdbus_modem_firmware_call_select (MM_GDBUS_MODEM_FIRMWARE (self), unique_id, cancellable, callback, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mm_modem_firmware_select_sync:
|
* mm_modem_firmware_select_sync:
|
||||||
* @self: A #MMModemFirmware.
|
* @self: A #MMModemFirmware.
|
||||||
* @name: Unique name of the firmware image to select.
|
* @unique_id: Unique ID of the firmware image to select.
|
||||||
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||||
* @error: Return location for error or %NULL.
|
* @error: Return location for error or %NULL.
|
||||||
*
|
*
|
||||||
@@ -152,14 +152,14 @@ mm_modem_firmware_select (MMModemFirmware *self,
|
|||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
mm_modem_firmware_select_sync (MMModemFirmware *self,
|
mm_modem_firmware_select_sync (MMModemFirmware *self,
|
||||||
const gchar *name,
|
const gchar *unique_id,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MM_IS_MODEM_FIRMWARE (self), FALSE);
|
g_return_val_if_fail (MM_IS_MODEM_FIRMWARE (self), FALSE);
|
||||||
g_return_val_if_fail (name != NULL || name[0] == '\0', FALSE);
|
g_return_val_if_fail (unique_id != NULL || unique_id[0] == '\0', FALSE);
|
||||||
|
|
||||||
return mm_gdbus_modem_firmware_call_select_sync (MM_GDBUS_MODEM_FIRMWARE (self), name, cancellable, error);
|
return mm_gdbus_modem_firmware_call_select_sync (MM_GDBUS_MODEM_FIRMWARE (self), unique_id, cancellable, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -218,7 +218,7 @@ build_results (const gchar *str_selected,
|
|||||||
*installed = g_list_append (*installed, firmware);
|
*installed = g_list_append (*installed, firmware);
|
||||||
|
|
||||||
if (str_selected &&
|
if (str_selected &&
|
||||||
g_str_equal (mm_firmware_properties_get_name (firmware), str_selected))
|
g_str_equal (mm_firmware_properties_get_unique_id (firmware), str_selected))
|
||||||
*selected = g_object_ref (firmware);
|
*selected = g_object_ref (firmware);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -82,7 +82,7 @@ gboolean mm_modem_firmware_list_sync (MMModemFirmware *self,
|
|||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
void mm_modem_firmware_select (MMModemFirmware *self,
|
void mm_modem_firmware_select (MMModemFirmware *self,
|
||||||
const gchar *name,
|
const gchar *unique_id,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@@ -90,7 +90,7 @@ gboolean mm_modem_firmware_select_finish (MMModemFirmware *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error);
|
GError **error);
|
||||||
gboolean mm_modem_firmware_select_sync (MMModemFirmware *self,
|
gboolean mm_modem_firmware_select_sync (MMModemFirmware *self,
|
||||||
const gchar *name,
|
const gchar *unique_id,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user