Debian Codegraph @

src/qmicli/qmicli-gas.c

raw
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * qmicli -- Command line interface to control QMI devices
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Copyright (C) 2019 Andreas Kling <[email protected]>
19 */
20
21 #include "config.h"
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <locale.h>
26 #include <string.h>
27
28 #include <glib.h>
29 #include <gio/gio.h>
30
31 #include <libqmi-glib.h>
32 #include <qmi-common.h>
33
34 #include "qmicli.h"
35 #include "qmicli-helpers.h"
36
37 #if defined HAVE_QMI_SERVICE_GAS
38
39 /* Context */
40 typedef struct {
41 QmiDevice *device;
42 QmiClientGas *client;
43 GCancellable *cancellable;
44 } Context;
45 static Context *ctx;
46
47 /* Options */
48 static gboolean get_firmware_list_flag;
49 static gboolean get_active_firmware_flag;
50 static gint set_active_firmware_int = -1;
51 static gint set_usb_composition_int = -1;
52 static gboolean get_usb_composition_flag;
53 static gboolean get_ethernet_mac_address_flag;
54 static gchar *set_firmware_auto_sim_str;
55 static gboolean get_firmware_auto_sim_flag;
56 static gboolean noop_flag;
57
58 static GOptionEntry entries[] = {
59 #if defined HAVE_QMI_MESSAGE_GAS_DMS_SET_USB_COMPOSITION
60 { "gas-dms-set-usb-composition", 0, 0, G_OPTION_ARG_INT, &set_usb_composition_int,
61 "Sets the USB composition",
62 "[pid]"
63 },
64 #endif
65 #if defined HAVE_QMI_MESSAGE_GAS_DMS_GET_USB_COMPOSITION
66 { "gas-dms-get-usb-composition", 0, 0, G_OPTION_ARG_NONE, &get_usb_composition_flag,
67 "Gets the current USB composition",
68 NULL
69 },
70 #endif
71 #if defined HAVE_QMI_MESSAGE_GAS_DMS_GET_FIRMWARE_LIST
72 { "gas-dms-get-firmware-list", 0, 0, G_OPTION_ARG_NONE, &get_firmware_list_flag,
73 "Gets the list of stored firmware",
74 NULL
75 },
76 { "gas-dms-get-active-firmware", 0, 0, G_OPTION_ARG_NONE, &get_active_firmware_flag,
77 "Gets the currently active firmware",
78 NULL
79 },
80 #endif
81 #if defined HAVE_QMI_MESSAGE_GAS_DMS_SET_ACTIVE_FIRMWARE
82 { "gas-dms-set-active-firmware", 0, 0, G_OPTION_ARG_INT, &set_active_firmware_int,
83 "Sets the active firmware index",
84 "[index]"
85 },
86 #endif
87 #if defined HAVE_QMI_MESSAGE_GAS_DMS_GET_ETHERNET_PDU_MAC_ADDRESS
88 { "gas-dms-get-ethernet-mac-address", 0, 0, G_OPTION_ARG_NONE, &get_ethernet_mac_address_flag,
89 "Gets the Ethernet PDU MAC address available in the modem",
90 NULL
91 },
92 #endif
93 #if defined HAVE_QMI_MESSAGE_GAS_DMS_SET_FIRMWARE_AUTO_SIM
94 { "gas-dms-set-firmware-auto-sim", 0, 0, G_OPTION_ARG_STRING, &set_firmware_auto_sim_str,
95 "Sets the automatic carrier switching mode according to the sim (allowed keys: mode (disable|enable|enable-one-shot), config-id",
96 "[\"key=value,...\"]"
97 },
98 #endif
99 #if defined HAVE_QMI_MESSAGE_GAS_DMS_GET_FIRMWARE_AUTO_SIM
100 { "gas-dms-get-firmware-auto-sim", 0, 0, G_OPTION_ARG_NONE, &get_firmware_auto_sim_flag,
101 "Gets the automatic carrier switching mode according to the sim",
102 NULL
103 },
104 #endif
105 { "gas-noop", 0, 0, G_OPTION_ARG_NONE, &noop_flag,
106 "Just allocate or release a GAS client. Use with `--client-no-release-cid' and/or `--client-cid'",
107 NULL
108 },
109 { NULL, 0, 0, 0, NULL, NULL, NULL }
110 };
111
112 GOptionGroup *
113 qmicli_gas_get_option_group (void)
114 {
115 GOptionGroup *group;
116
117 group = g_option_group_new ("gas",
118 "GAS options:",
119 "Show General Application Service options",
120 NULL,
121 NULL);
122 g_option_group_add_entries (group, entries);
123
124 return group;
125 }
126
127 gboolean
128 qmicli_gas_options_enabled (void)
129 {
130 static guint n_actions = 0;
131 static gboolean checked = FALSE;
132
133 if (checked)
134 return !!n_actions;
135
136 n_actions = ((set_usb_composition_int >= 0) +
137 get_usb_composition_flag +
138 get_firmware_list_flag +
139 get_active_firmware_flag +
140 (set_active_firmware_int >= 0) +
141 get_ethernet_mac_address_flag +
142 !!set_firmware_auto_sim_str +
143 get_firmware_auto_sim_flag +
144 noop_flag);
145
146 if (n_actions > 1) {
147 g_printerr ("error: too many GAS actions requested\n");
148 exit (EXIT_FAILURE);
149 }
150
151 checked = TRUE;
152 return !!n_actions;
153 }
154
155 static void
156 context_free (Context *context)
157 {
158 if (!context)
159 return;
160
161 if (context->cancellable)
162 g_object_unref (context->cancellable);
163 if (context->device)
164 g_object_unref (context->device);
165 if (context->client)
166 g_object_unref (context->client);
167 g_slice_free (Context, context);
168 }
169
170 static void
171 operation_shutdown (gboolean operation_status)
172 {
173 /* Cleanup context and finish async operation */
174 context_free (ctx);
175 qmicli_async_operation_done (operation_status, FALSE);
176 }
177
178 #if defined HAVE_QMI_MESSAGE_GAS_DMS_SET_USB_COMPOSITION
179
180 static void
181 set_usb_composition_ready (QmiClientGas *client,
182 GAsyncResult *res)
183 {
184 QmiMessageGasDmsSetUsbCompositionOutput *output;
185 GError *error = NULL;
186
187 output = qmi_client_gas_dms_set_usb_composition_finish (client, res, &error);
188 if (!output) {
189 g_printerr ("error: operation failed: %s\n", error->message);
190 g_error_free (error);
191 operation_shutdown (FALSE);
192 return;
193 }
194
195 if (!qmi_message_gas_dms_set_usb_composition_output_get_result (output, &error)) {
196 g_printerr ("error: unable to switch composition: %s\n", error->message);
197 g_error_free (error);
198 qmi_message_gas_dms_set_usb_composition_output_unref (output);
199 operation_shutdown (FALSE);
200 return;
201 }
202
203 g_print ("[%s] Successfully switched composition.\n",
204 qmi_device_get_path_display (ctx->device));
205
206 qmi_message_gas_dms_set_usb_composition_output_unref (output);
207 operation_shutdown (TRUE);
208 }
209
210 #endif /* HAVE_QMI_MESSAGE_GAS_DMS_SET_USB_COMPOSITION */
211
212 #if defined HAVE_QMI_MESSAGE_GAS_DMS_GET_USB_COMPOSITION
213
214 static void
215 get_usb_composition_ready (QmiClientGas *client,
216 GAsyncResult *res)
217 {
218 QmiMessageGasDmsGetUsbCompositionOutput *output;
219 GError *error = NULL;
220 guint32 composition;
221
222 output = qmi_client_gas_dms_get_usb_composition_finish (client, res, &error);
223 if (!output) {
224 g_printerr ("error: operation failed: %s\n", error->message);
225 g_error_free (error);
226 operation_shutdown (FALSE);
227 return;
228 }
229
230 if (!qmi_message_gas_dms_get_usb_composition_output_get_result (output, &error)) {
231 g_printerr ("error: unable to get current composition: %s\n", error->message);
232 g_error_free (error);
233 qmi_message_gas_dms_get_usb_composition_output_unref (output);
234 operation_shutdown (FALSE);
235 return;
236 }
237
238 qmi_message_gas_dms_get_usb_composition_output_get_usb_composition (output, &composition, NULL);
239 g_print ("[%s] Current composition is 0x%x\n",
240 qmi_device_get_path_display (ctx->device),
241 composition);
242
243 qmi_message_gas_dms_get_usb_composition_output_unref (output);
244 operation_shutdown (TRUE);
245 }
246
247 #endif /* HAVE_QMI_MESSAGE_GAS_DMS_GET_USB_COMPOSITION */
248
249 #if defined HAVE_QMI_MESSAGE_GAS_DMS_GET_FIRMWARE_LIST
250
251 static void
252 print_firmware_listing (guint8 idx,
253 const gchar *name,
254 const gchar *version,
255 const gchar *pri_revision)
256 {
257 g_print ("Firmware #%u:\n"
258 "\tIndex: %u\n"
259 "\tName: %s\n"
260 "\tVersion: %s\n"
261 "\tPRI revision: %s\n",
262 idx,
263 idx,
264 name,
265 version,
266 pri_revision);
267 }
268
269 static void
270 get_firmware_list_ready (QmiClientGas *client,
271 GAsyncResult *res)
272 {
273 QmiMessageGasDmsGetFirmwareListOutput *output;
274 GError *error = NULL;
275 guint8 idx;
276 const gchar *name;
277 const gchar *version;
278 const gchar *pri_revision;
279
280 output = qmi_client_gas_dms_get_firmware_list_finish (client, res, &error);
281 if (!output) {
282 g_printerr ("error: operation failed: %s\n", error->message);
283 g_error_free (error);
284 operation_shutdown (FALSE);
285 return;
286 }
287
288 if (!qmi_message_gas_dms_get_firmware_list_output_get_result (output, &error)) {
289 g_printerr ("error: couldn't get stored firmware list: %s\n", error->message);
290 g_error_free (error);
291 qmi_message_gas_dms_get_firmware_list_output_unref (output);
292 operation_shutdown (FALSE);
293 return;
294 }
295
296 if (qmi_message_gas_dms_get_firmware_list_output_get_stored_firmware_1 (output, &idx, &name, &version, &pri_revision, NULL))
297 print_firmware_listing (idx, name, version, pri_revision);
298
299 if (qmi_message_gas_dms_get_firmware_list_output_get_stored_firmware_2 (output, &idx, &name, &version, &pri_revision, NULL))
300 print_firmware_listing (idx, name, version, pri_revision);
301
302 if (qmi_message_gas_dms_get_firmware_list_output_get_stored_firmware_3 (output, &idx, &name, &version, &pri_revision, NULL))
303 print_firmware_listing (idx, name, version, pri_revision);
304
305 if (qmi_message_gas_dms_get_firmware_list_output_get_stored_firmware_4 (output, &idx, &name, &version, &pri_revision, NULL))
306 print_firmware_listing (idx, name, version, pri_revision);
307
308 qmi_message_gas_dms_get_firmware_list_output_unref (output);
309 operation_shutdown (TRUE);
310 }
311
312 #endif /* HAVE_QMI_MESSAGE_GAS_DMS_GET_FIRMWARE_LIST */
313
314 #if defined HAVE_QMI_MESSAGE_GAS_DMS_SET_ACTIVE_FIRMWARE
315
316 static void
317 set_active_firmware_ready (QmiClientGas *client,
318 GAsyncResult *res)
319 {
320 QmiMessageGasDmsSetActiveFirmwareOutput *output;
321 GError *error = NULL;
322
323 output = qmi_client_gas_dms_set_active_firmware_finish (client, res, &error);
324 if (!output) {
325 g_printerr ("error: operation failed: %s\n", error->message);
326 g_error_free (error);
327 operation_shutdown (FALSE);
328 return;
329 }
330
331 if (!qmi_message_gas_dms_set_active_firmware_output_get_result (output, &error)) {
332 g_printerr ("error: couldn't set active firmware list: %s\n", error->message);
333 g_error_free (error);
334 qmi_message_gas_dms_set_active_firmware_output_unref (output);
335 operation_shutdown (FALSE);
336 return;
337 }
338
339 g_print ("Successfully set the active firmware.\n");
340
341 qmi_message_gas_dms_set_active_firmware_output_unref (output);
342 operation_shutdown (TRUE);
343 }
344
345 #endif /* HAVE_QMI_MESSAGE_GAS_DMS_SET_ACTIVE_FIRMWARE */
346
347 #if defined HAVE_QMI_MESSAGE_GAS_DMS_GET_ETHERNET_PDU_MAC_ADDRESS
348
349 static void
350 print_mac_address (GArray *address)
351 {
352 g_autofree gchar *str = NULL;
353
354 str = qmi_common_str_hex (address->data, address->len, ':');
355 g_print ("%s\n", str);
356 }
357
358 static void
359 get_ethernet_pdu_mac_address_ready (QmiClientGas *client,
360 GAsyncResult *res)
361 {
362 g_autoptr(QmiMessageGasDmsGetEthernetPduMacAddressOutput) output;
363 g_autoptr(GError) error = NULL;
364 GArray *address;
365
366 output = qmi_client_gas_dms_get_ethernet_pdu_mac_address_finish (client, res, &error);
367 if (!output) {
368 g_printerr ("error: operation failed: %s\n", error->message);
369 operation_shutdown (FALSE);
370 return;
371 }
372
373 if (!qmi_message_gas_dms_get_ethernet_pdu_mac_address_output_get_result (output, &error)) {
374 g_printerr ("error: couldn't get Ethernet PDU MAC address: %s\n", error->message);
375 operation_shutdown (FALSE);
376 return;
377 }
378
379 if (qmi_message_gas_dms_get_ethernet_pdu_mac_address_output_get_mac_address_0 (output, &address, &error)) {
380 g_print ("Ethernet MAC address 0: ");
381 print_mac_address (address);
382 } else {
383 g_printerr ("error: couldn't get Ethernet PDU MAC address 0: %s\n", error->message);
384 operation_shutdown (FALSE);
385 return;
386 }
387
388 if (qmi_message_gas_dms_get_ethernet_pdu_mac_address_output_get_mac_address_1 (output, &address, NULL)) {
389 g_print ("Ethernet MAC address 1: ");
390 print_mac_address (address);
391 }
392
393 operation_shutdown (TRUE);
394 }
395
396 #endif /* HAVE_QMI_MESSAGE_GAS_DMS_GET_ETHERNET_PDU_MAC_ADDRESS */
397
398 #if defined HAVE_QMI_MESSAGE_GAS_DMS_SET_FIRMWARE_AUTO_SIM
399
400 typedef struct {
401 QmiGasFirmwareAutoSimMode auto_sim_mode;
402 guint8 config_id;
403 } FirmwareAutoSimProperties;
404
405 static gboolean
406 set_firmware_auto_sim_properties_handle (const gchar *key,
407 const gchar *value,
408 GError **error,
409 gpointer user_data)
410 {
411 FirmwareAutoSimProperties *props = user_data;
412
413 if (!value || !value[0]) {
414 g_set_error (error, QMI_CORE_ERROR, QMI_CORE_ERROR_FAILED,
415 "key '%s' requires a value", key);
416 return FALSE;
417 }
418
419 if (g_ascii_strcasecmp (key, "mode") == 0) {
420 if (!qmicli_read_gas_firmware_auto_sim_mode_from_string (value, &props->auto_sim_mode)) {
421 g_set_error (error, QMI_CORE_ERROR, QMI_CORE_ERROR_FAILED,
422 "failed reading key 'mode' unrecognized value: '%s'", value);
423 return FALSE;
424 }
425 return TRUE;
426 }
427
428 if (g_ascii_strcasecmp (key, "config-id") == 0) {
429 guint aux;
430
431 if (!qmicli_read_uint_from_string (value, &aux) || (aux >= G_MAXUINT8)) {
432 g_set_error (error, QMI_CORE_ERROR, QMI_CORE_ERROR_FAILED,
433 "failed reading key 'config-id' value in range [0,254]: '%s'", value);
434 return FALSE;
435 }
436 props->config_id = (guint8) aux;
437 return TRUE;
438 }
439
440 g_set_error (error, QMI_CORE_ERROR, QMI_CORE_ERROR_FAILED,
441 "unrecognized key: '%s'", key);
442 return FALSE;
443 }
444
445 static QmiMessageGasDmsSetFirmwareAutoSimInput *
446 set_firmware_auto_sim_input_create (const gchar *str)
447 {
448 g_autoptr(QmiMessageGasDmsSetFirmwareAutoSimInput) input = NULL;
449 g_autoptr(GError) error = NULL;
450 FirmwareAutoSimProperties props = {
451 .auto_sim_mode = 0xFF,
452 .config_id = 0xFF,
453 };
454
455 if (!str[0])
456 return NULL;
457
458 if (!qmicli_parse_key_value_string (str,
459 &error,
460 set_firmware_auto_sim_properties_handle,
461 &props)) {
462 g_printerr ("error: could not parse input string '%s'\n", error->message);
463 return NULL;
464 }
465
466 if (props.auto_sim_mode == 0xFF) {
467 g_printerr ("error: 'mode' is mandatory\n");
468 return NULL;
469 }
470
471 input = qmi_message_gas_dms_set_firmware_auto_sim_input_new ();
472 if (!qmi_message_gas_dms_set_firmware_auto_sim_input_set_auto_sim_mode (input, props.auto_sim_mode, &error)) {
473 g_printerr ("error: couldn't set auto sim mode: '%s'\n", error->message);
474 return NULL;
475 }
476 if (props.config_id != 0xFF) {
477 if (!qmi_message_gas_dms_set_firmware_auto_sim_input_set_config_id (input, props.config_id, &error)) {
478 g_printerr ("error: couldn't set config id: '%s'\n", error->message);
479 return NULL;
480 }
481 }
482
483 return g_steal_pointer (&input);
484 }
485
486 static void
487 set_firmware_auto_sim_ready (QmiClientGas *client,
488 GAsyncResult *res)
489 {
490 g_autoptr(QmiMessageGasDmsSetFirmwareAutoSimOutput) output = NULL;
491 g_autoptr(GError) error = NULL;
492
493 output = qmi_client_gas_dms_set_firmware_auto_sim_finish (client, res, &error);
494 if (!output) {
495 g_printerr ("error: operation failed: %s\n", error->message);
496 operation_shutdown (FALSE);
497 return;
498 }
499
500 if (!qmi_message_gas_dms_set_firmware_auto_sim_output_get_result (output, &error)) {
501 g_printerr ("error: couldn't set firmware auto sim: %s\n", error->message);
502 operation_shutdown (FALSE);
503 return;
504 }
505
506 g_print ("Firmware auto sim successfully updated\n");
507 operation_shutdown (TRUE);
508 }
509
510 #endif /* HAVE_QMI_MESSAGE_GAS_DMS_SET_FIRMWARE_AUTO_SIM */
511
512 #if defined HAVE_QMI_MESSAGE_GAS_DMS_GET_FIRMWARE_AUTO_SIM
513
514 static void
515 get_firmware_auto_sim_ready (QmiClientGas *client,
516 GAsyncResult *res)
517 {
518 g_autoptr(QmiMessageGasDmsGetFirmwareAutoSimOutput) output = NULL;
519 QmiGasFirmwareAutoSimMode auto_sim_mode;
520 guint8 config_id;
521 g_autoptr(GError) error = NULL;
522
523 output = qmi_client_gas_dms_get_firmware_auto_sim_finish (client, res, &error);
524 if (!output) {
525 g_printerr ("error: operation failed: %s\n", error->message);
526 operation_shutdown (FALSE);
527 return;
528 }
529
530 if (!qmi_message_gas_dms_get_firmware_auto_sim_output_get_result (output, &error)) {
531 g_printerr ("error: couldn't get firmware auto sim values: %s\n", error->message);
532 operation_shutdown (FALSE);
533 return;
534 }
535
536 if (!qmi_message_gas_dms_get_firmware_auto_sim_output_get_auto_sim_mode (output, &auto_sim_mode, &error)) {
537 g_printerr ("error: couldn't get firmware auto sim mode: %s\n", error->message);
538 operation_shutdown (FALSE);
539 return;
540 }
541 g_print ("Firmware auto sim mode: %s\n", qmi_gas_firmware_auto_sim_mode_get_string (auto_sim_mode));
542
543 if (qmi_message_gas_dms_get_firmware_auto_sim_output_get_config_id (output, &config_id, &error)) {
544 g_print ("Firmware auto sim config id: %u\n", config_id);
545 }
546
547 operation_shutdown (TRUE);
548 }
549
550 #endif /* HAVE_QMI_MESSAGE_GAS_DMS_GET_FIRMWARE_AUTO_SIM */
551
552 static gboolean
553 noop_cb (gpointer unused)
554 {
555 operation_shutdown (TRUE);
556 return FALSE;
557 }
558
559 void
560 qmicli_gas_run (QmiDevice *device,
561 QmiClientGas *client,
562 GCancellable *cancellable)
563 {
564 /* Initialize context */
565 ctx = g_slice_new (Context);
566 ctx->device = g_object_ref (device);
567 ctx->client = g_object_ref (client);
568 ctx->cancellable = g_object_ref (cancellable);
569
570 #if defined HAVE_QMI_MESSAGE_GAS_DMS_SET_USB_COMPOSITION
571 if (set_usb_composition_int >= 0) {
572 QmiMessageGasDmsSetUsbCompositionInput *input;
573
574 input = qmi_message_gas_dms_set_usb_composition_input_new ();
575 qmi_message_gas_dms_set_usb_composition_input_set_usb_composition (input, set_usb_composition_int, NULL);
576 qmi_message_gas_dms_set_usb_composition_input_set_endpoint_type (input, QMI_GAS_USB_COMPOSITION_ENDPOINT_TYPE_HSUSB, NULL);
577 qmi_message_gas_dms_set_usb_composition_input_set_composition_persistence (input, TRUE, NULL);
578 qmi_message_gas_dms_set_usb_composition_input_set_immediate_setting (input, FALSE, NULL);
579 qmi_message_gas_dms_set_usb_composition_input_set_reboot_after_setting (input, TRUE, NULL);
580 g_debug ("Asynchronously switching the USB composition...");
581 qmi_client_gas_dms_set_usb_composition (ctx->client,
582 input,
583 10,
584 ctx->cancellable,
585 (GAsyncReadyCallback)set_usb_composition_ready,
586 NULL);
587 qmi_message_gas_dms_set_usb_composition_input_unref (input);
588 return;
589 }
590 #endif
591
592 #if defined HAVE_QMI_MESSAGE_GAS_DMS_GET_USB_COMPOSITION
593 if (get_usb_composition_flag) {
594 g_debug ("Asynchronously getting the USB composition...");
595 qmi_client_gas_dms_get_usb_composition (ctx->client,
596 NULL,
597 10,
598 ctx->cancellable,
599 (GAsyncReadyCallback)get_usb_composition_ready,
600 NULL);
601 return;
602 }
603 #endif
604
605 #if defined HAVE_QMI_MESSAGE_GAS_DMS_GET_FIRMWARE_LIST
606 if (get_firmware_list_flag || get_active_firmware_flag) {
607 QmiMessageGasDmsGetFirmwareListInput *input;
608
609 input = qmi_message_gas_dms_get_firmware_list_input_new ();
610 if (get_firmware_list_flag) {
611 g_debug ("Asynchronously getting full firmware list...");
612 qmi_message_gas_dms_get_firmware_list_input_set_mode (input, QMI_GAS_FIRMWARE_LISTING_MODE_ALL_FIRMWARE, NULL);
613 } else if (get_active_firmware_flag) {
614 g_debug ("Asynchronously getting active firmware list...");
615 qmi_message_gas_dms_get_firmware_list_input_set_mode (input, QMI_GAS_FIRMWARE_LISTING_MODE_ACTIVE_FIRMWARE, NULL);
616 } else
617 g_assert_not_reached ();
618
619 qmi_client_gas_dms_get_firmware_list (ctx->client,
620 input,
621 10,
622 ctx->cancellable,
623 (GAsyncReadyCallback)get_firmware_list_ready,
624 NULL);
625 qmi_message_gas_dms_get_firmware_list_input_unref (input);
626 return;
627 }
628 #endif
629
630 #if defined HAVE_QMI_MESSAGE_GAS_DMS_SET_ACTIVE_FIRMWARE
631 if (set_active_firmware_int >= 0) {
632 QmiMessageGasDmsSetActiveFirmwareInput *input;
633
634 input = qmi_message_gas_dms_set_active_firmware_input_new ();
635 qmi_message_gas_dms_set_active_firmware_input_set_slot_index (input, set_active_firmware_int, NULL);
636 g_debug ("Asynchronously setting the active firmware index...");
637 qmi_client_gas_dms_set_active_firmware (ctx->client,
638 input,
639 10,
640 ctx->cancellable,
641 (GAsyncReadyCallback)set_active_firmware_ready,
642 NULL);
643 qmi_message_gas_dms_set_active_firmware_input_unref (input);
644 return;
645 }
646 #endif
647
648 #if defined HAVE_QMI_MESSAGE_GAS_DMS_GET_ETHERNET_PDU_MAC_ADDRESS
649 if (get_ethernet_mac_address_flag) {
650 g_debug ("Asynchronously getting ethernet mac adress...");
651 qmi_client_gas_dms_get_ethernet_pdu_mac_address (ctx->client,
652 NULL,
653 10,
654 ctx->cancellable,
655 (GAsyncReadyCallback)get_ethernet_pdu_mac_address_ready,
656 NULL);
657 return;
658 }
659 #endif
660
661 #if defined HAVE_QMI_MESSAGE_GAS_DMS_SET_FIRMWARE_AUTO_SIM
662 if (set_firmware_auto_sim_str) {
663 g_autoptr(QmiMessageGasDmsSetFirmwareAutoSimInput) input = NULL;
664
665 input = set_firmware_auto_sim_input_create (set_firmware_auto_sim_str);
666 if (input) {
667 g_debug ("Asynchronously setting firmware auto sim...");
668 qmi_client_gas_dms_set_firmware_auto_sim (client,
669 input,
670 10,
671 ctx->cancellable,
672 (GAsyncReadyCallback)set_firmware_auto_sim_ready,
673 NULL);
674 } else
675 operation_shutdown (FALSE);
676 return;
677 }
678 #endif
679
680 #if defined HAVE_QMI_MESSAGE_GAS_DMS_GET_FIRMWARE_AUTO_SIM
681 if (get_firmware_auto_sim_flag) {
682 g_debug ("Asynchronously getting firmware auto sim...");
683 qmi_client_gas_dms_get_firmware_auto_sim (ctx->client,
684 NULL,
685 10,
686 ctx->cancellable,
687 (GAsyncReadyCallback)get_firmware_auto_sim_ready,
688 NULL);
689 return;
690 }
691 #endif
692
693 /* Just client allocate/release? */
694 if (noop_flag) {
695 g_idle_add (noop_cb, NULL);
696 return;
697 }
698
699 g_warn_if_reached ();
700 }
701
702 #endif /* HAVE_QMI_SERVICE_GAS */