summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-05-30 13:03:20 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-07-03 16:08:56 +0200
commitd27b80e302a0db7998c861edb622c1ae24155fd5 (patch)
treebb8cf5e4544f12ad527d9f3659fa67ff81b06733
parent9d8fa6f6583d82f73633bff3ad9b4de5f4b14128 (diff)
cli: new `--dms-get-manufacturer' action
-rw-r--r--cli/qmicli-dms.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/cli/qmicli-dms.c b/cli/qmicli-dms.c
index d4febe2..6df9172 100644
--- a/cli/qmicli-dms.c
+++ b/cli/qmicli-dms.c
@@ -43,6 +43,7 @@ static Context *ctx;
/* Options */
static gboolean get_ids_flag;
static gboolean get_capabilities_flag;
+static gboolean get_manufacturer_flag;
static gboolean noop_flag;
static GOptionEntry entries[] = {
@@ -54,6 +55,10 @@ static GOptionEntry entries[] = {
"Get capabilities",
NULL
},
+ { "dms-get-manufacturer", 0, 0, G_OPTION_ARG_NONE, &get_manufacturer_flag,
+ "Get manufacturer",
+ NULL
+ },
{ "dms-noop", 0, 0, G_OPTION_ARG_NONE, &noop_flag,
"Just allocate or release a DMS client. Use with `--client-no-release-cid' and/or `--client-cid'",
NULL
@@ -87,6 +92,7 @@ qmicli_dms_options_enabled (void)
n_actions = (get_ids_flag +
get_capabilities_flag +
+ get_manufacturer_flag +
noop_flag);
if (n_actions > 1) {
@@ -223,6 +229,44 @@ get_capabilities_ready (QmiClientDms *client,
qmi_message_dms_get_capabilities_output_unref (output);
shutdown (TRUE);
}
+
+static void
+get_manufacturer_ready (QmiClientDms *client,
+ GAsyncResult *res)
+{
+ const gchar *str = NULL;
+ QmiMessageDmsGetManufacturerOutput *output;
+ GError *error = NULL;
+
+ output = qmi_client_dms_get_manufacturer_finish (client, res, &error);
+ if (!output) {
+ g_printerr ("error: operation failed: %s\n", error->message);
+ g_error_free (error);
+ shutdown (FALSE);
+ return;
+ }
+
+ if (!qmi_message_dms_get_manufacturer_output_get_result (output, &error)) {
+ g_printerr ("error: couldn't get manufacturer: %s\n", error->message);
+ g_error_free (error);
+ qmi_message_dms_get_manufacturer_output_unref (output);
+ shutdown (FALSE);
+ return;
+ }
+
+#undef VALIDATE_UNKNOWN
+#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
+
+ qmi_message_dms_get_manufacturer_output_get_manufacturer (output, &str, NULL);
+
+ g_print ("[%s] Device manufacturer retrieved:\n"
+ "\tManufacturer: '%s'\n",
+ qmi_device_get_path_display (ctx->device),
+ VALIDATE_UNKNOWN (str));
+
+ qmi_message_dms_get_manufacturer_output_unref (output);
+ shutdown (TRUE);
+}
static gboolean
noop_cb (gpointer unused)
{
@@ -266,6 +310,18 @@ qmicli_dms_run (QmiDevice *device,
return;
}
+ /* Request to get manufacturer? */
+ if (get_manufacturer_flag) {
+ g_debug ("Asynchronously getting manufacturer...");
+ qmi_client_dms_get_manufacturer (ctx->client,
+ NULL,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback)get_manufacturer_ready,
+ NULL);
+ return;
+ }
+
/* Just client allocate/release? */
if (noop_flag) {
g_idle_add (noop_cb, NULL);