aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2016-09-06 15:49:30 +0200
committerAleksander Morgado <aleksander@aleksander.es>2016-10-26 14:59:43 +0200
commit041ee874d571dc7ebc996e49f1f8778ebbba3cc4 (patch)
treef0772a8046a2f576c9db2601d6ce6faa90cd480d
parent38c24b2bdfe4018d7864078226cbd70cd45d62d2 (diff)
qmicli,pdc: refactor coding style and fix invalid frees
Mostly coding style fixes, although the patch also fixes several allocation issues when freeing GSlices.
-rw-r--r--src/qmicli/qmicli-pdc.c938
1 files changed, 423 insertions, 515 deletions
diff --git a/src/qmicli/qmicli-pdc.c b/src/qmicli/qmicli-pdc.c
index caa2386..d0b8e6b 100644
--- a/src/qmicli/qmicli-pdc.c
+++ b/src/qmicli/qmicli-pdc.c
@@ -61,7 +61,7 @@ typedef struct {
/* local data */
GArray *config_list;
- gint configs_loaded;
+ guint configs_loaded;
GArray *active_config_id;
GArray *pending_config_id;
gboolean ids_loaded;
@@ -89,30 +89,41 @@ static gchar *load_config_str;
static gboolean noop_flag;
static GOptionEntry entries[] = {
- {"pdc-list-configs", 0, 0, G_OPTION_ARG_STRING, &list_configs_str,
- "List all configs",
- "[(platform|software)]"},
- {"pdc-delete-config", 0, 0, G_OPTION_ARG_STRING, &delete_config_str,
- "Delete config",
- "[(platform|software),ConfigId]"},
- {"pdc-activate-config", 0, 0, G_OPTION_ARG_STRING, &activate_config_str,
- "Activate config",
- "[(platform|software),ConfigId]"},
- {"pdc-deactivate-config", 0, 0, G_OPTION_ARG_STRING, &deactivate_config_str,
- "Deactivate config",
- "[(platform|software),ConfigId]"},
- {"pdc-load-config", 0, 0, G_OPTION_ARG_STRING, &load_config_str,
- "Load config to device",
- "[Path to config]"},
- {"pdc-noop", 0, 0, G_OPTION_ARG_NONE, &noop_flag,
- "Just allocate or release a PDC client. Use with `--client-no-release-cid' and/or `--client-cid'",
- NULL},
- {NULL}
+ {
+ "pdc-list-configs", 0, 0, G_OPTION_ARG_STRING, &list_configs_str,
+ "List all configs",
+ "[(platform|software)]"
+ },
+ {
+ "pdc-delete-config", 0, 0, G_OPTION_ARG_STRING, &delete_config_str,
+ "Delete config",
+ "[(platform|software),ConfigId]"
+ },
+ {
+ "pdc-activate-config", 0, 0, G_OPTION_ARG_STRING, &activate_config_str,
+ "Activate config",
+ "[(platform|software),ConfigId]"
+ },
+ {
+ "pdc-deactivate-config", 0, 0, G_OPTION_ARG_STRING, &deactivate_config_str,
+ "Deactivate config",
+ "[(platform|software),ConfigId]"
+ },
+ {
+ "pdc-load-config", 0, 0, G_OPTION_ARG_STRING, &load_config_str,
+ "Load config to device",
+ "[Path to config]"
+ },
+ {
+ "pdc-noop", 0, 0, G_OPTION_ARG_NONE, &noop_flag,
+ "Just allocate or release a PDC client. Use with `--client-no-release-cid' and/or `--client-cid'",
+ NULL
+ },
+ { NULL }
};
GOptionGroup *
-qmicli_pdc_get_option_group (
- void)
+qmicli_pdc_get_option_group (void)
{
GOptionGroup *group;
@@ -125,8 +136,7 @@ qmicli_pdc_get_option_group (
}
gboolean
-qmicli_pdc_options_enabled (
- void)
+qmicli_pdc_options_enabled (void)
{
static guint n_actions = 0;
static gboolean checked = FALSE;
@@ -134,9 +144,12 @@ qmicli_pdc_options_enabled (
if (checked)
return !!n_actions;
- n_actions = !!list_configs_str +
- !!delete_config_str +
- !!activate_config_str + !!deactivate_config_str + !!load_config_str + noop_flag;
+ n_actions = (!!list_configs_str +
+ !!delete_config_str +
+ !!activate_config_str +
+ !!deactivate_config_str +
+ !!load_config_str +
+ noop_flag);
if (n_actions > 1) {
g_printerr ("error: too many PDC actions requested\n");
@@ -148,53 +161,33 @@ qmicli_pdc_options_enabled (
}
static Context *
-context_new (
- QmiDevice * device,
- QmiClientPdc * client,
- GCancellable * cancellable)
+context_new (QmiDevice *device,
+ QmiClientPdc *client,
+ GCancellable *cancellable)
{
Context *context;
- context = g_slice_new (Context);
+ context = g_slice_new0 (Context);
context->device = g_object_ref (device);
context->client = g_object_ref (client);
context->cancellable = g_object_ref (cancellable);
-
- context->config_list = NULL;
- context->configs_loaded = 0;
- context->active_config_id = NULL;
- context->pending_config_id = NULL;
- context->ids_loaded = FALSE;
- context->list_configs_indication_id = 0;
- context->get_selected_config_indication_id = 0;
-
- context->load_config_file_data = NULL;
- context->load_config_indication_id = 0;
- context->get_config_info_indication_id = 0;
-
- context->set_selected_config_indication_id = 0;
- context->activate_config_indication_id = 0;
- context->deactivate_config_indication_id = 0;
-
- context->token = 0;
return context;
}
static void
-context_free (
- Context * context)
+context_free (Context *context)
{
int i;
- ConfigInfo *current_config;
if (!context)
return;
if (context->config_list) {
for (i = 0; i < context->config_list->len; i++) {
+ ConfigInfo *current_config;
+
current_config = &g_array_index (context->config_list, ConfigInfo, i);
- if (current_config->description)
- g_free (current_config->description);
+ g_free (current_config->description);
if (current_config->id)
g_array_unref (current_config->id);
}
@@ -203,32 +196,32 @@ context_free (
g_signal_handler_disconnect (context->client, context->get_config_info_indication_id);
g_signal_handler_disconnect (context->client, context->get_selected_config_indication_id);
}
+
if (context->load_config_file_data) {
g_array_unref (context->load_config_file_data->checksum);
g_mapped_file_unref (context->load_config_file_data->mapped_file);
g_slice_free (LoadConfigFileData, context->load_config_file_data);
g_signal_handler_disconnect (context->client, context->load_config_indication_id);
}
- if (context->client)
- g_object_unref (context->client);
- if (context->set_selected_config_indication_id) {
+
+ if (context->set_selected_config_indication_id)
g_signal_handler_disconnect (context->client, context->set_selected_config_indication_id);
- }
- if (context->activate_config_indication_id) {
+
+ if (context->activate_config_indication_id)
g_signal_handler_disconnect (context->client, context->activate_config_indication_id);
- }
- if (context->deactivate_config_indication_id) {
+
+ if (context->deactivate_config_indication_id)
g_signal_handler_disconnect (context->client, context->deactivate_config_indication_id);
- }
+
g_object_unref (context->cancellable);
+ g_object_unref (context->client);
g_object_unref (context->device);
g_slice_free (Context, context);
}
static void
-operation_shutdown (
- gboolean operation_status)
+operation_shutdown (gboolean operation_status)
{
/* Cleanup context and finish async operation */
context_free (ctx);
@@ -236,119 +229,67 @@ operation_shutdown (
qmicli_async_operation_done (operation_status);
}
-/****************************************************************************************
- * List configs
- ****************************************************************************************/
+/******************************************************************************/
+/* List configs */
+
static const char *
-printable_config_type (
- QmiPdcConfigurationType type)
+status_string (GArray *id)
{
- if (type == QMI_PDC_CONFIGURATION_TYPE_PLATFORM) {
- return "Platform";
- } else if (type == QMI_PDC_CONFIGURATION_TYPE_SOFTWARE) {
- return "Software";
- } else {
+ if (!id)
return "Unknown";
- }
-}
-
-static char *
-printable_id (
- GArray * id)
-{
- if (!id) {
- return g_strdup ("Id is NULL?");
- } else if (id->len == 0) {
- return g_strdup ("Id is empty");
- } else {
- GString *printable;
- int i;
-
- printable = g_string_new ("");
- for (i = 0; i < id->len; i++) {
- guint8 ch = g_array_index (id, guint8, i);
-
- g_string_append_printf (printable, "%02hhX", ch);
- }
- return g_string_free (printable, FALSE);
- }
-}
-
-static gboolean
-is_array_equals (
- GArray * a,
- GArray * b)
-{
- int i;
-
- if (a == NULL && b == NULL) {
- return TRUE;
- } else if (a == NULL || b == NULL) {
- return FALSE;
- } else if (a->len != b->len) {
- return FALSE;
- }
- for (i = 0; i < a->len; i++) {
- if (g_array_index (a, guint8, i) != g_array_index (b, guint8, i)) {
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static const
-char *status_string (
- GArray * id)
-{
- if (!id) {
- return "UNKNOWN";
- } else if (is_array_equals (id, ctx->active_config_id)) {
+ if (ctx->active_config_id &&
+ id->len == ctx->active_config_id->len &&
+ memcmp (id->data, ctx->active_config_id->data, id->len) == 0)
return "Active";
- } else if (is_array_equals (id, ctx->pending_config_id)) {
+ if (ctx->pending_config_id &&
+ id->len == ctx->pending_config_id->len &&
+ memcmp (id->data, ctx->pending_config_id->data, id->len) == 0)
return "Pending";
- }
return "Inactive";
}
static void
-print_configs (
- GArray * configs)
+print_configs (GArray *configs)
{
- ConfigInfo *current_config = NULL;
- int i;
+ guint i;
- g_printf ("CONFIGS: %d\n", ctx->config_list->len);
+ g_printf ("Total configurations: %u\n", ctx->config_list->len);
for (i = 0; i < ctx->config_list->len; i++) {
+ ConfigInfo *current_config;
char *id_str;
current_config = &g_array_index (ctx->config_list, ConfigInfo, i);
- g_printf ("START_CONFIG\n");
- g_printf ("Config Index : %i\n", i);
- g_printf ("Description : %s\n", current_config->description);
- g_printf ("Type : %s\n", printable_config_type (current_config->config_type));
- g_printf ("Size : %u\n", current_config->total_size);
- g_printf ("Status : %s\n", status_string (current_config->id));
- g_printf ("Version : 0x%x\n", current_config->version);
- id_str = printable_id (current_config->id);
- g_printf ("ID : %s\n", id_str);
+ g_printf ("Configuration %u:\n", i);
+ g_printf ("\tDescription: %s\n", current_config->description);
+ g_printf ("\tType: %s\n", qmi_pdc_configuration_type_get_string (current_config->config_type));
+ g_printf ("\tSize: %u\n", current_config->total_size);
+ g_printf ("\tStatus: %s\n", status_string (current_config->id));
+ g_printf ("\tVersion: 0x%X\n", current_config->version);
+ id_str = qmicli_get_raw_data_printable (current_config->id, 80, "");
+ g_printf ("\tID: %s\n", id_str ? id_str ? "none");
g_free (id_str);
- g_printf ("END_CONFIG\n\n");
+ }
+}
+static void
+check_list_config_completed (void)
+{
+ if (ctx->configs_loaded == ctx->config_list->len &&
+ ctx->ids_loaded) {
+ print_configs (ctx->config_list);
+ operation_shutdown (TRUE);
}
}
static void
-get_config_info_ready (
- QmiClientPdc * client,
- GAsyncResult * res)
+get_config_info_ready (QmiClientPdc *client,
+ GAsyncResult *res)
{
GError *error = NULL;
QmiMessagePdcGetConfigInfoOutput *output;
output = qmi_client_pdc_get_config_info_finish (client, res, &error);
-
if (!output) {
g_printerr ("error: operation failed: %s\n", error->message);
g_error_free (error);
@@ -368,24 +309,24 @@ get_config_info_ready (
}
static void
-get_config_info_ready_indication (
- QmiClientPdc * client,
- QmiIndicationPdcGetConfigInfoOutput * output)
+get_config_info_ready_indication (QmiClientPdc *client,
+ QmiIndicationPdcGetConfigInfoOutput *output)
{
GError *error = NULL;
ConfigInfo *current_config = NULL;
guint32 token;
const gchar *description;
int i;
- guint16 error_code;
+ guint16 error_code = 0;
- if (!qmi_indication_pdc_get_config_info_output_get_indication_result (output,
- &error_code, &error)) {
+ if (!qmi_indication_pdc_get_config_info_output_get_indication_result (output, &error_code, &error)) {
g_printerr ("error: couldn't get config info: %s\n", error->message);
g_error_free (error);
operation_shutdown (FALSE);
return;
- } else if (error_code != 0) {
+ }
+
+ if (error_code != 0) {
g_printerr ("error: couldn't get config info: %s\n",
qmi_protocol_error_get_string ((QmiProtocolError) error_code));
operation_shutdown (FALSE);
@@ -393,18 +334,20 @@ get_config_info_ready_indication (
}
if (!qmi_indication_pdc_get_config_info_output_get_token (output, &token, &error)) {
- g_printerr ("error: couldn't get config info: %s\n", error->message);
+ g_printerr ("error: couldn't get config info token: %s\n", error->message);
g_error_free (error);
operation_shutdown (FALSE);
return;
}
+ /* Look for the current config in the list */
for (i = 0; i < ctx->config_list->len; i++) {
current_config = &g_array_index (ctx->config_list, ConfigInfo, i);
if (current_config->token == token)
break;
}
+ /* Store total size, version and description of the current config */
if (!qmi_indication_pdc_get_config_info_output_get_total_size (output,
&current_config->total_size,
&error) ||
@@ -412,7 +355,7 @@ get_config_info_ready_indication (
&current_config->version,
&error) ||
!qmi_indication_pdc_get_config_info_output_get_description (output, &description, &error)) {
- g_printerr ("error: couldn't get config info: %s\n", error->message);
+ g_printerr ("error: couldn't get config info details: %s\n", error->message);
g_error_free (error);
operation_shutdown (FALSE);
return;
@@ -420,22 +363,18 @@ get_config_info_ready_indication (
current_config->description = g_strdup (description);
ctx->configs_loaded++;
- if (ctx->configs_loaded == ctx->config_list->len && ctx->ids_loaded) {
- print_configs (ctx->config_list);
- operation_shutdown (TRUE);
- }
+
+ check_list_config_completed ();
}
static void
-list_configs_ready (
- QmiClientPdc * client,
- GAsyncResult * res)
+list_configs_ready (QmiClientPdc *client,
+ GAsyncResult *res)
{
GError *error = NULL;
QmiMessagePdcListConfigsOutput *output;
output = qmi_client_pdc_list_configs_finish (client, res, &error);
-
if (!output) {
g_printerr ("error: operation failed: %s\n", error->message);
g_error_free (error);
@@ -455,21 +394,22 @@ list_configs_ready (
}
static void
-list_configs_ready_indication (
- QmiClientPdc * client,
- QmiIndicationPdcListConfigsOutput * output)
+list_configs_ready_indication (QmiClientPdc *client,
+ QmiIndicationPdcListConfigsOutput *output)
{
GError *error = NULL;
GArray *configs = NULL;
int i;
- guint16 error_code;
+ guint16 error_code = 0;
if (!qmi_indication_pdc_list_configs_output_get_indication_result (output, &error_code, &error)) {
g_printerr ("error: couldn't list configs: %s\n", error->message);
g_error_free (error);
operation_shutdown (FALSE);
return;
- } else if (error_code != 0) {
+ }
+
+ if (error_code != 0) {
g_printerr ("error: couldn't list config: %s\n",
qmi_protocol_error_get_string ((QmiProtocolError) error_code));
operation_shutdown (FALSE);
@@ -483,8 +423,10 @@ list_configs_ready_indication (
return;
}
+ /* Preallocate config list and request details for each */
ctx->config_list = g_array_sized_new (FALSE, TRUE, sizeof (ConfigInfo), configs->len);
g_array_set_size (ctx->config_list, configs->len);
+
for (i = 0; i < configs->len; i++) {
ConfigInfo *current_info;
QmiIndicationPdcListConfigsOutputConfigsElement *element;
@@ -495,20 +437,24 @@ list_configs_ready_indication (
element = &g_array_index (configs, QmiIndicationPdcListConfigsOutputConfigsElement, i);
current_info = &g_array_index (ctx->config_list, ConfigInfo, i);
-
- input = qmi_message_pdc_get_config_info_input_new ();
current_info->token = token;
current_info->id = g_array_ref (element->id);
current_info->config_type = element->config_type;
+
+ input = qmi_message_pdc_get_config_info_input_new ();
+ g_print ("Fetching config type: %s\n", qmi_pdc_configuration_type_get_string (current_info->config_type));
+
+ /* Add type with id */
type_with_id.config_type = element->config_type;
type_with_id.id = current_info->id;
- g_printerr ("Fetching config type: %d\n", current_info->config_type);
if (!qmi_message_pdc_get_config_info_input_set_type_with_id (input, &type_with_id, &error)) {
g_printerr ("error: couldn't set type with id: %s\n", error->message);
g_error_free (error);
operation_shutdown (FALSE);
return;
}
+
+ /* Add token */
if (!qmi_message_pdc_get_config_info_input_set_token (input, token, &error)) {
g_printerr ("error: couldn't set token: %s\n", error->message);
g_error_free (error);
@@ -521,26 +467,21 @@ list_configs_ready_indication (
10,
ctx->cancellable,
(GAsyncReadyCallback) get_config_info_ready, NULL);
-
+ qmi_message_pdc_get_config_info_input_unref (input);
}
- g_print ("Loaded configs: %d\n", ctx->config_list->len);
- if (ctx->configs_loaded == ctx->config_list->len && ctx->ids_loaded) {
- print_configs (ctx->config_list);
- operation_shutdown (TRUE);
- }
+ g_print ("Loaded configs: %u\n", ctx->config_list->len);
+ check_list_config_completed ();
}
static void
-get_selected_config_ready (
- QmiClientPdc * client,
- GAsyncResult * res)
+get_selected_config_ready (QmiClientPdc *client,
+ GAsyncResult *res)
{
GError *error = NULL;
QmiMessagePdcGetSelectedConfigOutput *output;
output = qmi_client_pdc_get_selected_config_finish (client, res, &error);
-
if (!qmi_message_pdc_get_selected_config_output_get_result (output, &error)) {
g_printerr ("error: couldn't get selected config: %s\n", error->message);
g_error_free (error);
@@ -553,134 +494,127 @@ get_selected_config_ready (
}
static void
-get_selected_config_ready_indication (
- QmiClientPdc * client,
- QmiIndicationPdcGetSelectedConfigOutput * output)
+get_selected_config_ready_indication (QmiClientPdc *client,
+ QmiIndicationPdcGetSelectedConfigOutput *output)
{
GArray *pending_id = NULL;
GArray *active_id = NULL;
GError *error = NULL;
- guint16 error_code;
+ guint16 error_code = 0;
- if (!qmi_indication_pdc_get_selected_config_output_get_indication_result (output,
- &error_code,
- &error)) {
+ if (!qmi_indication_pdc_get_selected_config_output_get_indication_result (output, &error_code, &error)) {
g_printerr ("error: couldn't get selected config: %s\n", error->message);
g_error_free (error);
operation_shutdown (FALSE);
return;
- } else if (error_code != 0) {
+ }
+
+ if (error_code != 0) {
g_printerr ("error: couldn't get selected config: %s\n",
qmi_protocol_error_get_string ((QmiProtocolError) error_code));
+ operation_shutdown (FALSE);
+ return;
}
qmi_indication_pdc_get_selected_config_output_get_pending_id (output, &pending_id, NULL);
qmi_indication_pdc_get_selected_config_output_get_active_id (output, &active_id, NULL);
- if (active_id) {
+ if (active_id)
ctx->active_config_id = g_array_ref (active_id);
- }
- if (pending_id) {
+ if (pending_id)
ctx->pending_config_id = g_array_ref (pending_id);
- }
ctx->ids_loaded = TRUE;
- if (ctx->configs_loaded == ctx->config_list->len && ctx->ids_loaded) {
- print_configs (ctx->config_list);
- operation_shutdown (TRUE);
- }
+
+ check_list_config_completed ();
}
static void
-activate_config_ready_indication (
- QmiClientPdc * client,
- QmiIndicationPdcActivateConfigOutput * output)
+activate_config_ready_indication (QmiClientPdc *client,
+ QmiIndicationPdcActivateConfigOutput *output)
{
GError *error = NULL;
- guint16 error_code;
+ guint16 error_code = 0;
- if (!qmi_indication_pdc_activate_config_output_get_indication_result (output,
- &error_code, &error)) {
+ if (!qmi_indication_pdc_activate_config_output_get_indication_result (output, &error_code, &error)) {
g_printerr ("error: couldn't activate config: %s\n", error->message);
g_error_free (error);
operation_shutdown (FALSE);
return;
- } else if (error_code != 0) {
+ }
+
+ if (error_code != 0) {
g_printerr ("error: couldn't activate config: %s\n",
qmi_protocol_error_get_string ((QmiProtocolError) error_code));
operation_shutdown (FALSE);
+ return;
}
operation_shutdown (TRUE);
}
static void
-deactivate_config_ready_indication (
- QmiClientPdc * client,
- QmiIndicationPdcDeactivateConfigOutput * output)
+deactivate_config_ready_indication (QmiClientPdc *client,
+ QmiIndicationPdcDeactivateConfigOutput *output)
{
GError *error = NULL;
- guint16 error_code;
+ guint16 error_code = 0;
- if (!qmi_indication_pdc_deactivate_config_output_get_indication_result (output,
- &error_code, &error)) {
+ if (!qmi_indication_pdc_deactivate_config_output_get_indication_result (output, &error_code, &error)) {
g_printerr ("error: couldn't deactivate config: %s\n", error->message);
g_error_free (error);
operation_shutdown (FALSE);
return;
- } else if (error_code != 0) {
+ }
+
+ if (error_code != 0) {
g_printerr ("error: couldn't deactivate config: %s\n",
qmi_protocol_error_get_string ((QmiProtocolError) error_code));
operation_shutdown (FALSE);
+ return;
}
operation_shutdown (TRUE);
}
static QmiMessagePdcListConfigsInput *
-list_configs_input_create (
- const gchar * str)
+list_configs_input_create (const gchar *str)
{
QmiMessagePdcListConfigsInput *input = NULL;
- QmiPdcConfigurationType configType;
-
- if (qmicli_read_pdc_configuration_type_from_string (str, &configType)) {
- GError *error = NULL;
+ QmiPdcConfigurationType config_type;
+ GError *error = NULL;
- input = qmi_message_pdc_list_configs_input_new ();
- if (!qmi_message_pdc_list_configs_input_set_config_type (input, configType, &error)) {
- g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
- g_error_free (error);
- qmi_message_pdc_list_configs_input_unref (input);
- input = NULL;
- }
- if (!qmi_message_pdc_list_configs_input_set_token (input, ctx->token++, &error)) {
- g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
- g_error_free (error);
- qmi_message_pdc_list_configs_input_unref (input);
- input = NULL;
- }
+ if (!qmicli_read_pdc_configuration_type_from_string (str, &config_type))
+ return NULL;
+ input = qmi_message_pdc_list_configs_input_new ();
+ if (!qmi_message_pdc_list_configs_input_set_config_type (input, config_type, &error) ||
+ !qmi_message_pdc_list_configs_input_set_token (input, ctx->token++, &error)) {
+ g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
+ g_error_free (error);
+ qmi_message_pdc_list_configs_input_unref (input);
+ return NULL;
}
return input;
}
-/****************************************************************************************
- * Activate and deactivate configs
- ****************************************************************************************/
+/******************************************************************************/
+/* Activate and deactivate configs */
+
static QmiConfigTypeAndId *
-parse_type_and_id (
- const gchar * str)
+parse_type_and_id (const gchar *str)
{
GArray *id = NULL;
- int num_parts;
- gchar **substrings = g_strsplit (str, ",", -1);
+ guint num_parts;
+ gchar **substrings;
QmiPdcConfigurationType config_type;
QmiConfigTypeAndId *result = NULL;
- for (num_parts = 0; substrings[num_parts]; num_parts++) ;
+ substrings = g_strsplit (str, ",", -1);
+ num_parts = g_strv_length (substrings);
+
if (num_parts != 2) {
- g_printerr ("Expected 2 parameters, but found: '%d'\n", num_parts);
+ g_printerr ("Expected 2 parameters, but found %u\n", num_parts);
g_strfreev (substrings);
return NULL;
}
@@ -698,89 +632,67 @@ parse_type_and_id (
}
result = g_slice_new0 (QmiConfigTypeAndId);
- if (!result) {
- g_printerr ("Error allocating QmiConfigTypeAndId\n");
- g_strfreev (substrings);
- g_array_unref (id);
- return NULL;
- }
result->config_type = config_type;
result->id = id;
-
return result;
}
static QmiMessagePdcGetSelectedConfigInput *
-get_selected_config_input_create (
- const gchar * str)
+get_selected_config_input_create (const gchar *str)
{
QmiMessagePdcGetSelectedConfigInput *input = NULL;
- QmiPdcConfigurationType configType;
-
- if (qmicli_read_pdc_configuration_type_from_string (str, &configType)) {
- GError *error = NULL;
+ QmiPdcConfigurationType config_type;
+ GError *error = NULL;
- input = qmi_message_pdc_get_selected_config_input_new ();
- if (!qmi_message_pdc_get_selected_config_input_set_config_type (input, configType, &error)) {
- g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
- g_error_free (error);
- qmi_message_pdc_get_selected_config_input_unref (input);
- input = NULL;
- }
- if (!qmi_message_pdc_get_selected_config_input_set_token (input, ctx->token++, &error)) {
- g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
- g_error_free (error);
- qmi_message_pdc_get_selected_config_input_unref (input);
- input = NULL;
- }
+ if (!qmicli_read_pdc_configuration_type_from_string (str, &config_type))
+ return NULL;
+ input = qmi_message_pdc_get_selected_config_input_new ();
+ if (!qmi_message_pdc_get_selected_config_input_set_config_type (input, config_type, &error) ||
+ !qmi_message_pdc_get_selected_config_input_set_token (input, ctx->token++, &error)) {
+ g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
+ g_error_free (error);
+ qmi_message_pdc_get_selected_config_input_unref (input);
+ return NULL;
}
return input;
}
static QmiMessagePdcDeleteConfigInput *
-delete_config_input_create (
- const gchar * str)
+delete_config_input_create (const gchar *str)
{
QmiMessagePdcDeleteConfigInput *input = NULL;
QmiConfigTypeAndId *type_and_id;
+ GError *error = NULL;
type_and_id = parse_type_and_id (str);
+ if (!type_and_id)
+ return NULL;
- if (type_and_id) {
- GError *error = NULL;
-
- input = qmi_message_pdc_delete_config_input_new ();
- if (!qmi_message_pdc_delete_config_input_set_config_type (input,
- type_and_id->config_type,
- &error) ||
- !qmi_message_pdc_delete_config_input_set_token (input,
- ctx->token++,
- &error) ||
- !qmi_message_pdc_delete_config_input_set_id (input, type_and_id->id, &error)) {
- g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
- g_error_free (error);
- g_free (type_and_id);
- qmi_message_pdc_delete_config_input_unref (input);
- input = NULL;
- }
- g_slice_free (QmiConfigTypeAndId, type_and_id);
+ input = qmi_message_pdc_delete_config_input_new ();
+ if (!qmi_message_pdc_delete_config_input_set_config_type (input, type_and_id->config_type, &error) ||
+ !qmi_message_pdc_delete_config_input_set_token (input, ctx->token++, &error) ||
+ !qmi_message_pdc_delete_config_input_set_id (input, type_and_id->id, &error)) {
+ g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
+ g_error_free (error);
+ qmi_message_pdc_delete_config_input_unref (input);
+ input = NULL;
}
+ g_array_unref (type_and_id->id);
+ g_slice_free (QmiConfigTypeAndId, type_and_id);
return input;
}
static void
-delete_config_ready (
- QmiClientPdc * client,
- GAsyncResult * res)
+delete_config_ready (QmiClientPdc *client,
+ GAsyncResult *res)
{
GError *error = NULL;
QmiMessagePdcDeleteConfigOutput *output;
output = qmi_client_pdc_delete_config_finish (client, res, &error);
-
if (!output) {
g_printerr ("error: operation failed: %s\n", error->message);
g_error_free (error);
@@ -796,54 +708,43 @@ delete_config_ready (
return;
}
- operation_shutdown (TRUE);
qmi_message_pdc_delete_config_output_unref (output);
+ operation_shutdown (TRUE);
}
static QmiMessagePdcActivateConfigInput *
-activate_config_input_create (
- const gchar * str)
+activate_config_input_create (const gchar *str)
{
QmiMessagePdcActivateConfigInput *input = NULL;
QmiConfigTypeAndId *type_and_id;
+ GError *error = NULL;
type_and_id = parse_type_and_id (str);
+ if (!type_and_id)
+ return NULL;
- if (type_and_id) {
- GError *error = NULL;
-
- input = qmi_message_pdc_activate_config_input_new ();
- if (!qmi_message_pdc_activate_config_input_set_config_type (input,
- type_and_id->config_type,
- &error)) {
- g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
- g_error_free (error);
- qmi_message_pdc_activate_config_input_unref (input);
- g_free (type_and_id);
- input = NULL;
- }
- if (!qmi_message_pdc_activate_config_input_set_token (input, ctx->token++, &error)) {
- g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
- g_error_free (error);
- qmi_message_pdc_activate_config_input_unref (input);
- g_free (type_and_id);
- input = NULL;
- }
+ input = qmi_message_pdc_activate_config_input_new ();
+ if (!qmi_message_pdc_activate_config_input_set_config_type (input, type_and_id->config_type, &error) ||
+ !qmi_message_pdc_activate_config_input_set_token (input, ctx->token++, &error)) {
+ g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
+ g_error_free (error);
+ qmi_message_pdc_activate_config_input_unref (input);
+ input = NULL;
}
+ g_array_unref (type_and_id->id);
+ g_slice_free (QmiConfigTypeAndId, type_and_id);
return input;
}
static void
-activate_config_ready (
- QmiClientPdc * client,
- GAsyncResult * res)
+activate_config_ready (QmiClientPdc *client,
+ GAsyncResult *res)
{
GError *error = NULL;
QmiMessagePdcActivateConfigOutput *output;
output = qmi_client_pdc_activate_config_finish (client, res, &error);
-
if (!output) {
g_printerr ("error: operation failed: %s\n", error->message);
g_error_free (error);
@@ -863,15 +764,13 @@ activate_config_ready (
}
static void
-deactivate_config_ready (
- QmiClientPdc * client,
- GAsyncResult * res)
+deactivate_config_ready (QmiClientPdc *client,
+ GAsyncResult *res)
{
GError *error = NULL;
QmiMessagePdcDeactivateConfigOutput *output;
output = qmi_client_pdc_deactivate_config_finish (client, res, &error);
-
if (!output) {
g_printerr ("error: operation failed: %s\n", error->message);
g_error_free (error);
@@ -880,7 +779,7 @@ deactivate_config_ready (
}
if (!qmi_message_pdc_deactivate_config_output_get_result (output, &error)) {
- g_printerr ("error: couldn't activate config: %s\n", error->message);
+ g_printerr ("error: couldn't deactivate config: %s\n", error->message);
g_error_free (error);
qmi_message_pdc_deactivate_config_output_unref (output);
operation_shutdown (FALSE);
@@ -891,22 +790,21 @@ deactivate_config_ready (
}
static void
-set_selected_config_ready_indication_activation (
- QmiClientPdc * client,
- QmiIndicationPdcSetSelectedConfigOutput * output)
+set_selected_config_ready_indication_activation (QmiClientPdc *client,
+ QmiIndicationPdcSetSelectedConfigOutput *output)
{
GError *error = NULL;
QmiMessagePdcActivateConfigInput *input;
- guint16 error_code;
+ guint16 error_code = 0;
- if (!qmi_indication_pdc_set_selected_config_output_get_indication_result (output,
- &error_code,
- &error)) {
+ if (!qmi_indication_pdc_set_selected_config_output_get_indication_result (output, &error_code, &error)) {
g_printerr ("error: couldn't set selected config: %s\n", error->message);
g_error_free (error);
operation_shutdown (FALSE);
return;
- } else if (error_code != 0) {
+ }
+
+ if (error_code != 0) {
g_printerr ("error: couldn't set selected config: %s\n",
qmi_protocol_error_get_string ((QmiProtocolError) error_code));
operation_shutdown (FALSE);
@@ -918,6 +816,7 @@ set_selected_config_ready_indication_activation (
operation_shutdown (FALSE);
return;
}
+
qmi_client_pdc_activate_config (ctx->client,
input,
10,
@@ -927,15 +826,13 @@ set_selected_config_ready_indication_activation (
}
static void
-set_selected_config_ready (
- QmiClientPdc * client,
- GAsyncResult * res)
+set_selected_config_ready (QmiClientPdc *client,
+ GAsyncResult *res)
{
GError *error = NULL;
QmiMessagePdcSetSelectedConfigOutput *output;
output = qmi_client_pdc_set_selected_config_finish (client, res, &error);
-
if (!output) {
g_printerr ("error: operation failed: %s\n", error->message);
g_error_free (error);
@@ -947,56 +844,46 @@ set_selected_config_ready (
}
static QmiMessagePdcDeactivateConfigInput *
-deactivate_config_input_create (
- const gchar * str)
+deactivate_config_input_create (const gchar *str)
{
QmiMessagePdcDeactivateConfigInput *input = NULL;
QmiConfigTypeAndId *type_and_id;
+ GError *error = NULL;
type_and_id = parse_type_and_id (str);
+ if (!type_and_id)
+ return NULL;
- if (type_and_id) {
- GError *error = NULL;
-
- input = qmi_message_pdc_deactivate_config_input_new ();
- if (!qmi_message_pdc_deactivate_config_input_set_config_type (input,
- type_and_id->config_type,
- &error)) {
- g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
- g_error_free (error);
- qmi_message_pdc_deactivate_config_input_unref (input);
- g_free (type_and_id);
- input = NULL;
- }
- if (!qmi_message_pdc_deactivate_config_input_set_token (input, ctx->token++, &error)) {
- g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
- g_error_free (error);
- qmi_message_pdc_deactivate_config_input_unref (input);
- g_free (type_and_id);
- input = NULL;
- }
+ input = qmi_message_pdc_deactivate_config_input_new ();
+ if (!qmi_message_pdc_deactivate_config_input_set_config_type (input, type_and_id->config_type, &error) ||
+ !qmi_message_pdc_deactivate_config_input_set_token (input, ctx->token++, &error)) {
+ g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
+ g_error_free (error);
+ qmi_message_pdc_deactivate_config_input_unref (input);
+ input = NULL;
}
+ g_array_unref (type_and_id->id);
+ g_slice_free (QmiConfigTypeAndId, type_and_id);
return input;
}
static void
-set_selected_config_ready_indication_deactivation (
- QmiClientPdc * client,
- QmiIndicationPdcSetSelectedConfigOutput * output)
+set_selected_config_ready_indication_deactivation (QmiClientPdc *client,
+ QmiIndicationPdcSetSelectedConfigOutput *output)
{
GError *error = NULL;
QmiMessagePdcDeactivateConfigInput *input;
- guint16 error_code;
+ guint16 error_code = 0;
- if (!qmi_indication_pdc_set_selected_config_output_get_indication_result (output,
- &error_code,
- &error)) {
+ if (!qmi_indication_pdc_set_selected_config_output_get_indication_result (output, &error_code, &error)) {
g_printerr ("error: couldn't set selected config: %s\n", error->message);
g_error_free (error);
operation_shutdown (FALSE);
return;
- } else if (error_code != 0) {
+ }
+
+ if (error_code != 0) {
g_printerr ("error: couldn't set selected config: %s\n",
qmi_protocol_error_get_string ((QmiProtocolError) error_code));
operation_shutdown (FALSE);
@@ -1008,6 +895,7 @@ set_selected_config_ready_indication_deactivation (
operation_shutdown (FALSE);
return;
}
+
qmi_client_pdc_deactivate_config (ctx->client,
input,
10,
@@ -1017,46 +905,35 @@ set_selected_config_ready_indication_deactivation (
}
static QmiMessagePdcSetSelectedConfigInput *
-set_selected_config_input_create (
- const gchar * str)
+set_selected_config_input_create (const gchar *str)
{
QmiMessagePdcSetSelectedConfigInput *input = NULL;
QmiConfigTypeAndId *type_and_id;
+ GError *error = NULL;
type_and_id = parse_type_and_id (str);
+ if (!type_and_id)
+ return NULL;
- if (type_and_id) {
- GError *error = NULL;
-
- input = qmi_message_pdc_set_selected_config_input_new ();
- if (!qmi_message_pdc_set_selected_config_input_set_type_with_id (input,
- type_and_id, &error)) {
- g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
- g_error_free (error);
- g_free (type_and_id);
- qmi_message_pdc_set_selected_config_input_unref (input);
- input = NULL;
- }
- if (!qmi_message_pdc_set_selected_config_input_set_token (input, ctx->token++, &error)) {
- g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
- g_error_free (error);
- g_free (type_and_id);
- qmi_message_pdc_set_selected_config_input_unref (input);
- input = NULL;
- }
-
+ input = qmi_message_pdc_set_selected_config_input_new ();
+ if (!qmi_message_pdc_set_selected_config_input_set_type_with_id (input, type_and_id, &error) ||
+ !qmi_message_pdc_set_selected_config_input_set_token (input, ctx->token++, &error)) {
+ g_printerr ("error: couldn't create input data bundle: '%s'\n", error->message);
+ g_error_free (error);
+ qmi_message_pdc_set_selected_config_input_unref (input);
+ input = NULL;
}
+ g_array_unref (type_and_id->id);
+ g_slice_free (QmiConfigTypeAndId, type_and_id);
return input;
}
-/****************************************************************************************
- * Load config
- ****************************************************************************************/
+/******************************************************************************/
+/* Load config */
static LoadConfigFileData *
-load_config_file_from_string (
- const gchar * str)
+load_config_file_from_string (const gchar *str)
{
GError *error = NULL;
GMappedFile *mapped_file;
@@ -1077,9 +954,10 @@ load_config_file_from_string (
g_mapped_file_unref (mapped_file);
return NULL;
}
+
+ /* Get checksum */
file_size = g_mapped_file_get_length (mapped_file);
hash_size = g_checksum_type_get_length (G_CHECKSUM_SHA1);
- g_info ("File opened: %lu, %lu", file_size, hash_size);
checksum = g_checksum_new (G_CHECKSUM_SHA1);
g_checksum_update (checksum, file_contents, file_size);
@@ -1089,83 +967,86 @@ load_config_file_from_string (
g_array_set_size (data->checksum, hash_size);
data->offset = 0;
g_checksum_get_digest (checksum, &g_array_index (data->checksum, guint8, 0), &hash_size);
- g_info ("Checksum: %lu, %lu", file_size, hash_size);
return data;
}
static QmiMessagePdcLoadConfigInput *
-load_config_input_create_chunk (
- LoadConfigFileData * config_file)
+load_config_input_create_chunk (LoadConfigFileData *config_file)
{
- QmiMessagePdcLoadConfigInput *input = NULL;
+ QmiMessagePdcLoadConfigInput *input;
+ GError *error = NULL;
+ GArray *chunk;
+ gsize full_size;
+ gsize chunk_size;
+ guint8 *file_content;
- if (config_file) {
- GError *error = NULL;
- GArray *chunk;
- gsize full_size;
- gsize chunk_size;
- guchar *file_content;
+ if (!config_file)
+ return NULL;
- input = qmi_message_pdc_load_config_input_new ();
- if (!qmi_message_pdc_load_config_input_set_token (input, ctx->token++, &error)) {
- g_printerr ("error: couldn't set token: '%s'\n", error->message);
- g_error_free (error);
- qmi_message_pdc_load_config_input_unref (input);
- input = NULL;
- }
+ input = qmi_message_pdc_load_config_input_new ();
+ if (!qmi_message_pdc_load_config_input_set_token (input, ctx->token++, &error)) {
+ g_printerr ("error: couldn't set token: '%s'\n", error->message);
+ g_error_free (error);
+ qmi_message_pdc_load_config_input_unref (input);
+ return NULL;
+ }
- chunk = g_array_new (FALSE, FALSE, 1);
- full_size = g_mapped_file_get_length (config_file->mapped_file);
- chunk_size = config_file->offset + LOAD_CONFIG_CHUNK_SIZE > full_size ?
- full_size - config_file->offset : LOAD_CONFIG_CHUNK_SIZE;
- file_content = (guchar *) g_mapped_file_get_contents (config_file->mapped_file);
- g_array_append_vals (chunk, file_content + config_file->offset, chunk_size);
- g_print ("Uploaded %lu of %lu\n", config_file->offset, full_size);
-
- if (!qmi_message_pdc_load_config_input_set_config_chunk (input,
- QMI_PDC_CONFIGURATION_TYPE_SOFTWARE,
- config_file->checksum,
- g_mapped_file_get_length
- (config_file->mapped_file), chunk,
- &error)) {
- g_printerr ("error: couldn't set chunk: '%s'\n", error->message);
- g_error_free (error);
- qmi_message_pdc_load_config_input_unref (input);
- input = NULL;
- } else {
- config_file->offset += chunk_size;
- }
+ chunk = g_array_new (FALSE, FALSE, sizeof (guint8));
+ full_size = g_mapped_file_get_length (config_file->mapped_file);
+ chunk_size = (((config_file->offset + LOAD_CONFIG_CHUNK_SIZE) > full_size) ?
+ (full_size - config_file->offset) :
+ LOAD_CONFIG_CHUNK_SIZE);
+
+ file_content = (guint8 *) g_mapped_file_get_contents (config_file->mapped_file);
+ g_array_append_vals (chunk, &file_content[config_file->offset], chunk_size);
+ g_print ("Uploaded %lu of %lu\n", config_file->offset, full_size);
+
+ if (!qmi_message_pdc_load_config_input_set_config_chunk (input,
+ QMI_PDC_CONFIGURATION_TYPE_SOFTWARE,
+ config_file->checksum,
+ full_size,
+ chunk,
+ &error)) {
+ g_printerr ("error: couldn't set chunk: '%s'\n", error->message);
+ g_error_free (error);
+ g_array_unref (chunk);
+ qmi_message_pdc_load_config_input_unref (input);
+ return NULL;
}
+
+ config_file->offset += chunk_size;
+
+ g_array_unref (chunk);
return input;
}
static QmiMessagePdcLoadConfigInput *
-load_config_input_create (
- const gchar * str)
+load_config_input_create (const gchar *str)
{
LoadConfigFileData *config_file;
QmiMessagePdcLoadConfigInput *input = NULL;
- if ((config_file = load_config_file_from_string (str))) {
- if ((input = load_config_input_create_chunk (config_file))) {
- ctx->load_config_file_data = config_file;
- }
- }
+ config_file = load_config_file_from_string (str);
+ if (!config_file)
+ return NULL;
+ input = load_config_input_create_chunk (config_file);
+ if (!input)
+ return NULL;
+
+ ctx->load_config_file_data = config_file;
return input;
}
static void
-load_config_ready (
- QmiClientPdc * client,
- GAsyncResult * res)
+load_config_ready (QmiClientPdc *client,
+ GAsyncResult *res)
{
GError *error = NULL;
QmiMessagePdcLoadConfigOutput *output;
output = qmi_client_pdc_load_config_finish (client, res, &error);
-
if (!output) {
g_printerr ("error: operation failed: %s\n", error->message);
g_error_free (error);
@@ -1185,37 +1066,33 @@ load_config_ready (
}
static void
-load_config_ready_indication (
- QmiClientPdc * client,
- QmiIndicationPdcLoadConfigOutput * output)
+load_config_ready_indication (QmiClientPdc *client,
+ QmiIndicationPdcLoadConfigOutput *output)
{
GError *error = NULL;
QmiMessagePdcLoadConfigInput *input;
gboolean frame_reset;
guint32 remaining_size;
- guint16 error_code;
+ guint16 error_code = 0;
if (!qmi_indication_pdc_load_config_output_get_indication_result (output, &error_code, &error)) {
g_printerr ("error: couldn't load config: %s\n", error->message);
g_error_free (error);
operation_shutdown (FALSE);
return;
- } else if (error_code != 0) {
+ }
+
+ if (error_code != 0) {
g_printerr ("error: couldn't load config: %s\n",
qmi_protocol_error_get_string ((QmiProtocolError) error_code));
operation_shutdown (FALSE);
return;
}
- if (qmi_indication_pdc_load_config_output_get_frame_reset (output, &frame_reset, &error)) {
- if (frame_reset) {
- g_printerr ("error: frame reset requested\n");
- operation_shutdown (FALSE);
- return;
- }
- } else {
- g_error_free (error);
- error = NULL;
+ if (qmi_indication_pdc_load_config_output_get_frame_reset (output, &frame_reset, NULL) && frame_reset) {
+ g_printerr ("error: frame reset requested\n");
+ operation_shutdown (FALSE);
+ return;
}
if (!qmi_indication_pdc_load_config_output_get_remaining_size (output, &remaining_size, &error)) {
@@ -1225,43 +1102,42 @@ load_config_ready_indication (
return;
}
- g_print ("Remaining %d\n", remaining_size);
- if (remaining_size > 0) {
- g_print ("Loading next\n");
- input = load_config_input_create_chunk (ctx->load_config_file_data);
- if (!input) {
- g_printerr ("Input is null\n");
- operation_shutdown (FALSE);
- return;
- }
- qmi_client_pdc_load_config (ctx->client,
- input,
- 10,
- ctx->cancellable,
- (GAsyncReadyCallback) load_config_ready, NULL);
- qmi_message_pdc_load_config_input_unref (input);
- } else {
+ if (remaining_size == 0) {
+ g_print ("Finished loading\n");
operation_shutdown (TRUE);
+ return;
}
+
+ g_print ("Loading next chunk (%u bytes remaining)\n", remaining_size);
+ input = load_config_input_create_chunk (ctx->load_config_file_data);
+ if (!input) {
+ g_printerr ("error: couldn't create next chunk\n");
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ qmi_client_pdc_load_config (ctx->client,
+ input,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback) load_config_ready, NULL);
+ qmi_message_pdc_load_config_input_unref (input);
}
-/****************************************************************************************
- * Common logic
- ****************************************************************************************/
+/******************************************************************************/
+/* Common */
static gboolean
-noop_cb (
- gpointer unused)
+noop_cb (gpointer unused)
{
operation_shutdown (TRUE);
return FALSE;
}
void
-qmicli_pdc_run (
- QmiDevice * device,
- QmiClientPdc * client,
- GCancellable * cancellable)
+qmicli_pdc_run (QmiDevice *device,
+ QmiClientPdc *client,
+ GCancellable *cancellable)
{
/* Initialize context */
ctx = context_new (device, client, cancellable);
@@ -1271,22 +1147,27 @@ qmicli_pdc_run (
QmiMessagePdcListConfigsInput *input;
QmiMessagePdcGetSelectedConfigInput *get_selected_config_input;
- g_debug ("Listing configs asynchroniously...");
- ctx->list_configs_indication_id = g_signal_connect (client,
- "list-configs",
- G_CALLBACK
- (list_configs_ready_indication), NULL);
+ g_debug ("Listing configs asynchronously...");
+
+ /* Results are reported via indications */
+ ctx->list_configs_indication_id =
+ g_signal_connect (client,
+ "list-configs",
+ G_CALLBACK
+ (list_configs_ready_indication), NULL);
ctx->get_selected_config_indication_id =
g_signal_connect (client, "get-selected-config",
G_CALLBACK (get_selected_config_ready_indication), NULL);
ctx->get_config_info_indication_id =
g_signal_connect (client, "get-config-info",
G_CALLBACK (get_config_info_ready_indication), NULL);
+
input = list_configs_input_create (list_configs_str);
if (!input) {
operation_shutdown (FALSE);
return;
}
+
get_selected_config_input = get_selected_config_input_create (list_configs_str);
if (!get_selected_config_input) {
operation_shutdown (FALSE);
@@ -1297,14 +1178,16 @@ qmicli_pdc_run (
input,
10,
ctx->cancellable,
- (GAsyncReadyCallback) list_configs_ready, NULL);
+ (GAsyncReadyCallback) list_configs_ready,
+ NULL);
qmi_message_pdc_list_configs_input_unref (input);
qmi_client_pdc_get_selected_config (ctx->client,
get_selected_config_input,
10,
ctx->cancellable,
- (GAsyncReadyCallback) get_selected_config_ready, NULL);
+ (GAsyncReadyCallback) get_selected_config_ready,
+ NULL);
qmi_message_pdc_get_selected_config_input_unref (get_selected_config_input);
return;
}
@@ -1313,12 +1196,13 @@ qmicli_pdc_run (
if (delete_config_str) {
QmiMessagePdcDeleteConfigInput *input;
- g_debug ("Deleting config asynchroniously...");
+ g_debug ("Deleting config asynchronously...");
input = delete_config_input_create (delete_config_str);
if (!input) {
operation_shutdown (FALSE);
return;
}
+
qmi_client_pdc_delete_config (ctx->client,
input,
10,
@@ -1332,23 +1216,31 @@ qmicli_pdc_run (
if (activate_config_str) {
QmiMessagePdcSetSelectedConfigInput *input;
- g_debug ("Activating config asynchroniously...");
+ g_debug ("Activating config asynchronously...");
input = set_selected_config_input_create (activate_config_str);
if (!input) {
operation_shutdown (FALSE);
return;
}
+
+ /* Results are reported via indications */
ctx->set_selected_config_indication_id =
g_signal_connect (client,
"set-selected-config",
G_CALLBACK (set_selected_config_ready_indication_activation), NULL);
- ctx->activate_config_indication_id = g_signal_connect (client,
- "activate-config",
- G_CALLBACK
- (activate_config_ready_indication),
- NULL);
- qmi_client_pdc_set_selected_config (ctx->client, input, 10, ctx->cancellable,
- (GAsyncReadyCallback) set_selected_config_ready, NULL);
+ ctx->activate_config_indication_id =
+ g_signal_connect (client,
+ "activate-config",
+ G_CALLBACK
+ (activate_config_ready_indication),
+ NULL);
+
+ qmi_client_pdc_set_selected_config (ctx->client,
+ input,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback) set_selected_config_ready,
+ NULL);
qmi_message_pdc_set_selected_config_input_unref (input);
return;
}
@@ -1357,23 +1249,31 @@ qmicli_pdc_run (
if (deactivate_config_str) {
QmiMessagePdcSetSelectedConfigInput *input;
- g_debug ("Deactivating config asynchroniously...");
+ g_debug ("Deactivating config asynchronously...");
input = set_selected_config_input_create (activate_config_str);
if (!input) {
operation_shutdown (FALSE);
return;
}
+
+ /* Results are reported via indications */
ctx->set_selected_config_indication_id =
g_signal_connect (client,
"set-selected-config",
G_CALLBACK (set_selected_config_ready_indication_deactivation), NULL);
- ctx->deactivate_config_indication_id = g_signal_connect (client,
- "deactivate-config",
- G_CALLBACK
- (deactivate_config_ready_indication),
- NULL);
- qmi_client_pdc_set_selected_config (ctx->client, input, 10, ctx->cancellable,
- (GAsyncReadyCallback) set_selected_config_ready, NULL);
+ ctx->deactivate_config_indication_id =
+ g_signal_connect (client,
+ "deactivate-config",
+ G_CALLBACK
+ (deactivate_config_ready_indication),
+ NULL);
+
+ qmi_client_pdc_set_selected_config (ctx->client,
+ input,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback) set_selected_config_ready,
+ NULL);
qmi_message_pdc_set_selected_config_input_unref (input);
return;
}
@@ -1381,18 +1281,26 @@ qmicli_pdc_run (
if (load_config_str) {
QmiMessagePdcLoadConfigInput *input;
- g_debug ("Loading config asynchroniously...");
+ g_debug ("Loading config asynchronously...");
input = load_config_input_create (load_config_str);
if (!input) {
operation_shutdown (FALSE);
return;
}
- ctx->load_config_indication_id = g_signal_connect (client,
- "load-config",
- G_CALLBACK
- (load_config_ready_indication), NULL);
- qmi_client_pdc_load_config (ctx->client, input, 10, ctx->cancellable,
- (GAsyncReadyCallback) load_config_ready, NULL);
+
+ /* Results are reported via indications */
+ ctx->load_config_indication_id =
+ g_signal_connect (client,
+ "load-config",
+ G_CALLBACK (load_config_ready_indication),
+ NULL);
+
+ qmi_client_pdc_load_config (ctx->client,
+ input,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback) load_config_ready,
+ NULL);
qmi_message_pdc_load_config_input_unref (input);
return;
}