Debian Codegraph @

src/qmicli/qmicli-wms.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) 2015-2017 Aleksander Morgado <[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
33 #include "qmicli.h"
34 #include "qmicli-helpers.h"
35
36 #if defined HAVE_QMI_SERVICE_WMS
37
38 #define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
39
40 /* Context */
41 typedef struct {
42 QmiDevice *device;
43 QmiClientWms *client;
44 GCancellable *cancellable;
45 } Context;
46 static Context *ctx;
47
48 /* Options */
49 static gboolean get_supported_messages_flag;
50 static gboolean get_routes_flag;
51 static gchar *set_routes_str;
52 static gboolean reset_flag;
53 static gboolean noop_flag;
54 static gchar *set_broadcast_config_str;
55 static gboolean get_broadcast_config_flag;
56
57 static GOptionEntry entries[] = {
58 #if defined HAVE_QMI_MESSAGE_WMS_GET_SUPPORTED_MESSAGES
59 { "wms-get-supported-messages", 0, 0, G_OPTION_ARG_NONE, &get_supported_messages_flag,
60 "Get supported messages",
61 NULL
62 },
63 #endif
64 #if defined HAVE_QMI_MESSAGE_WMS_GET_ROUTES
65 { "wms-get-routes", 0, 0, G_OPTION_ARG_NONE, &get_routes_flag,
66 "Get SMS route information",
67 NULL
68 },
69 #endif
70 #if defined HAVE_QMI_MESSAGE_WMS_SET_ROUTES
71 { "wms-set-routes", 0, 0, G_OPTION_ARG_STRING, &set_routes_str,
72 "Set SMS route information (keys: type, class, storage, receipt-action)",
73 "[\"key=value,...\"]"
74 },
75 #endif
76 #if defined HAVE_QMI_MESSAGE_WMS_SET_BROADCAST_CONFIG
77 { "wms-set-cbs-channels", 0, 0, G_OPTION_ARG_STRING, &set_broadcast_config_str,
78 "Set CBS channels (e.g. 4371-4372,4370,4373-4380",
79 "[start-end,start-end]",
80 },
81 #endif
82 #if defined HAVE_QMI_MESSAGE_WMS_GET_BROADCAST_CONFIG
83 { "wms-get-cbs-channels", 0, 0, G_OPTION_ARG_NONE, &get_broadcast_config_flag,
84 "Get CBS channels",
85 NULL,
86 },
87 #endif
88 #if defined HAVE_QMI_MESSAGE_WMS_RESET
89 { "wms-reset", 0, 0, G_OPTION_ARG_NONE, &reset_flag,
90 "Reset the service state",
91 NULL
92 },
93 #endif
94 { "wms-noop", 0, 0, G_OPTION_ARG_NONE, &noop_flag,
95 "Just allocate or release a WMS client. Use with `--client-no-release-cid' and/or `--client-cid'",
96 NULL
97 },
98 { NULL, 0, 0, 0, NULL, NULL, NULL }
99 };
100
101 GOptionGroup *
102 qmicli_wms_get_option_group (void)
103 {
104 GOptionGroup *group;
105
106 group = g_option_group_new ("wms",
107 "WMS options:",
108 "Show Wireless Messaging Service options",
109 NULL,
110 NULL);
111 g_option_group_add_entries (group, entries);
112
113 return group;
114 }
115
116 gboolean
117 qmicli_wms_options_enabled (void)
118 {
119 static guint n_actions = 0;
120 static gboolean checked = FALSE;
121
122 if (checked)
123 return !!n_actions;
124
125 n_actions = (get_supported_messages_flag +
126 get_routes_flag +
127 !!set_routes_str +
128 !!set_broadcast_config_str +
129 get_broadcast_config_flag +
130 reset_flag +
131 noop_flag);
132
133 if (n_actions > 1) {
134 g_printerr ("error: too many WMS actions requested\n");
135 exit (EXIT_FAILURE);
136 }
137
138 checked = TRUE;
139 return !!n_actions;
140 }
141
142 static void
143 context_free (Context *context)
144 {
145 if (!context)
146 return;
147
148 if (context->client)
149 g_object_unref (context->client);
150 g_object_unref (context->cancellable);
151 g_object_unref (context->device);
152 g_slice_free (Context, context);
153 }
154
155 static void
156 operation_shutdown (gboolean operation_status)
157 {
158 /* Cleanup context and finish async operation */
159 context_free (ctx);
160 qmicli_async_operation_done (operation_status, FALSE);
161 }
162
163 #if defined HAVE_QMI_MESSAGE_WMS_GET_SUPPORTED_MESSAGES
164
165 static void
166 get_supported_messages_ready (QmiClientWms *client,
167 GAsyncResult *res)
168 {
169 QmiMessageWmsGetSupportedMessagesOutput *output;
170 GError *error = NULL;
171 GArray *bytearray = NULL;
172 gchar *str;
173
174 output = qmi_client_wms_get_supported_messages_finish (client, res, &error);
175 if (!output) {
176 g_printerr ("error: operation failed: %s\n", error->message);
177 g_error_free (error);
178 operation_shutdown (FALSE);
179 return;
180 }
181
182 if (!qmi_message_wms_get_supported_messages_output_get_result (output, &error)) {
183 g_printerr ("error: couldn't get supported WMS messages: %s\n", error->message);
184 g_error_free (error);
185 qmi_message_wms_get_supported_messages_output_unref (output);
186 operation_shutdown (FALSE);
187 return;
188 }
189
190 g_print ("[%s] Successfully got supported WMS messages:\n",
191 qmi_device_get_path_display (ctx->device));
192
193 qmi_message_wms_get_supported_messages_output_get_list (output, &bytearray, NULL);
194 str = qmicli_get_supported_messages_list (bytearray ? (const guint8 *)bytearray->data : NULL,
195 bytearray ? bytearray->len : 0);
196 g_print ("%s", str);
197 g_free (str);
198
199 qmi_message_wms_get_supported_messages_output_unref (output);
200 operation_shutdown (TRUE);
201 }
202
203 #endif /* HAVE_QMI_MESSAGE_WMS_GET_SUPPORTED_MESSAGES */
204
205 #if defined HAVE_QMI_MESSAGE_WMS_GET_ROUTES
206
207 static void
208 get_routes_ready (QmiClientWms *client,
209 GAsyncResult *res)
210 {
211 g_autoptr(QmiMessageWmsGetRoutesOutput) output = NULL;
212 GError *error = NULL;
213 GArray *route_list;
214 guint i;
215
216 output = qmi_client_wms_get_routes_finish (client, res, &error);
217 if (!output) {
218 g_printerr ("error: operation failed: %s\n", error->message);
219 g_error_free (error);
220 operation_shutdown (FALSE);
221 return;
222 }
223
224 if (!qmi_message_wms_get_routes_output_get_result (output, &error)) {
225 g_printerr ("error: couldn't get SMS routes: %s\n", error->message);
226 g_error_free (error);
227 operation_shutdown (FALSE);
228 return;
229 }
230
231 if (!qmi_message_wms_get_routes_output_get_route_list (output, &route_list, &error)) {
232 g_printerr ("error: got invalid SMS routes: %s\n", error->message);
233 g_error_free (error);
234 operation_shutdown (FALSE);
235 return;
236 }
237
238 g_print ("[%s] Got %u SMS routes:\n", qmi_device_get_path_display (ctx->device),
239 route_list->len);
240
241 for (i = 0; i < route_list->len; i++) {
242 QmiMessageWmsGetRoutesOutputRouteListElement *route;
243
244 route = &g_array_index (route_list, QmiMessageWmsGetRoutesOutputRouteListElement, i);
245 g_print (" Route #%u:\n", i + 1);
246 g_print (" Message Type: %s\n", VALIDATE_UNKNOWN (qmi_wms_message_type_get_string (route->message_type)));
247 g_print (" Message Class: %s\n", VALIDATE_UNKNOWN (qmi_wms_message_class_get_string (route->message_class)));
248 g_print (" Storage Type: %s\n", VALIDATE_UNKNOWN (qmi_wms_storage_type_get_string (route->storage)));
249 g_print (" Receipt Action: %s\n", VALIDATE_UNKNOWN (qmi_wms_receipt_action_get_string (route->receipt_action)));
250 }
251
252 operation_shutdown (TRUE);
253 }
254
255 #endif /* HAVE_QMI_MESSAGE_WMS_GET_ROUTES */
256
257 #if defined HAVE_QMI_MESSAGE_WMS_SET_ROUTES
258
259 typedef struct {
260 GArray *route_list;
261
262 gboolean message_type_set;
263 gboolean message_class_set;
264 gboolean storage_set;
265 gboolean receipt_action_set;
266 } SetRoutesContext;
267
268 static void
269 set_routes_context_init (SetRoutesContext *routes_ctx)
270 {
271 memset (routes_ctx, 0, sizeof(SetRoutesContext));
272 routes_ctx->route_list = g_array_new (FALSE, TRUE, sizeof (QmiMessageWmsSetRoutesInputRouteListElement));
273 }
274
275 static void
276 set_routes_context_destroy (SetRoutesContext *routes_ctx)
277 {
278 g_array_unref (routes_ctx->route_list);
279 }
280
281 static gboolean
282 set_route_properties_handle (const gchar *key,
283 const gchar *value,
284 GError **error,
285 gpointer user_data)
286 {
287 SetRoutesContext *routes_ctx = user_data;
288 QmiMessageWmsSetRoutesInputRouteListElement *cur_route;
289 gboolean ret = FALSE;
290
291 if (!value || !value[0]) {
292 g_set_error (error,
293 QMI_CORE_ERROR,
294 QMI_CORE_ERROR_FAILED,
295 "key '%s' required a value",
296 key);
297 return FALSE;
298 }
299
300 if (!routes_ctx->message_type_set && !routes_ctx->message_class_set &&
301 !routes_ctx->storage_set && !routes_ctx->receipt_action_set) {
302 QmiMessageWmsSetRoutesInputRouteListElement new_elt;
303
304 memset (&new_elt, 0, sizeof (QmiMessageWmsSetRoutesInputRouteListElement));
305 g_array_append_val (routes_ctx->route_list, new_elt);
306 }
307 cur_route = &g_array_index (routes_ctx->route_list,
308 QmiMessageWmsSetRoutesInputRouteListElement,
309 routes_ctx->route_list->len - 1);
310
311 if (g_ascii_strcasecmp (key, "type") == 0 && !routes_ctx->message_type_set) {
312 if (!qmicli_read_wms_message_type_from_string (value, &cur_route->message_type)) {
313 g_set_error (error,
314 QMI_CORE_ERROR,
315 QMI_CORE_ERROR_FAILED,
316 "unknown message type '%s'",
317 value);
318 return FALSE;
319 }
320 routes_ctx->message_type_set = TRUE;
321 ret = TRUE;
322 } else if (g_ascii_strcasecmp (key, "class") == 0 && !routes_ctx->message_class_set) {
323 if (!qmicli_read_wms_message_class_from_string (value, &cur_route->message_class)) {
324 g_set_error (error,
325 QMI_CORE_ERROR,
326 QMI_CORE_ERROR_FAILED,
327 "unknown message class '%s'",
328 value);
329 return FALSE;
330 }
331 routes_ctx->message_class_set = TRUE;
332 ret = TRUE;
333 } else if (g_ascii_strcasecmp (key, "storage") == 0 && !routes_ctx->storage_set) {
334 if (!qmicli_read_wms_storage_type_from_string (value, &cur_route->storage)) {
335 g_set_error (error,
336 QMI_CORE_ERROR,
337 QMI_CORE_ERROR_FAILED,
338 "unknown storage type '%s'",
339 value);
340 return FALSE;
341 }
342 routes_ctx->storage_set = TRUE;
343 ret = TRUE;
344 } else if (g_ascii_strcasecmp (key, "receipt-action") == 0 && !routes_ctx->receipt_action_set) {
345 if (!qmicli_read_wms_receipt_action_from_string (value, &cur_route->receipt_action)) {
346 g_set_error (error,
347 QMI_CORE_ERROR,
348 QMI_CORE_ERROR_FAILED,
349 "unknown receipt action '%s'",
350 value);
351 return FALSE;
352 }
353 routes_ctx->receipt_action_set = TRUE;
354 ret = TRUE;
355 }
356
357 if (routes_ctx->message_type_set && routes_ctx->message_class_set &&
358 routes_ctx->storage_set && routes_ctx->receipt_action_set) {
359 /* We have a complete set of details for this route. Reset the context state. */
360 routes_ctx->message_type_set = FALSE;
361 routes_ctx->message_class_set = FALSE;
362 routes_ctx->storage_set = FALSE;
363 routes_ctx->receipt_action_set = FALSE;
364 }
365
366 if (!ret) {
367 g_set_error (error,
368 QMI_CORE_ERROR,
369 QMI_CORE_ERROR_FAILED,
370 "unrecognized or duplicate option '%s'",
371 key);
372 }
373 return ret;
374 }
375
376 static QmiMessageWmsSetRoutesInput *
377 set_routes_input_create (const gchar *str,
378 GError **error)
379 {
380 g_autoptr(QmiMessageWmsSetRoutesInput) input = NULL;
381 SetRoutesContext routes_ctx;
382 GError *inner_error = NULL;
383
384 set_routes_context_init (&routes_ctx);
385
386 if (!qmicli_parse_key_value_string (str,
387 &inner_error,
388 set_route_properties_handle,
389 &routes_ctx)) {
390 g_propagate_prefixed_error (error,
391 inner_error,
392 "couldn't parse input string: ");
393 set_routes_context_destroy (&routes_ctx);
394 return NULL;
395 }
396
397 if (routes_ctx.route_list->len == 0) {
398 g_set_error_literal (error,
399 QMI_CORE_ERROR,
400 QMI_CORE_ERROR_FAILED,
401 "route list was empty");
402 set_routes_context_destroy (&routes_ctx);
403 return NULL;
404 }
405
406 if (routes_ctx.message_type_set || routes_ctx.message_class_set ||
407 routes_ctx.storage_set || routes_ctx.receipt_action_set) {
408 g_set_error_literal (error,
409 QMI_CORE_ERROR,
410 QMI_CORE_ERROR_FAILED,
411 "final route was missing one or more options");
412 set_routes_context_destroy (&routes_ctx);
413 return NULL;
414 }
415
416 /* Create input */
417 input = qmi_message_wms_set_routes_input_new ();
418
419 if (!qmi_message_wms_set_routes_input_set_route_list (input, routes_ctx.route_list, &inner_error)) {
420 g_propagate_error (error, inner_error);
421 set_routes_context_destroy (&routes_ctx);
422 return NULL;
423 }
424
425 set_routes_context_destroy (&routes_ctx);
426 return g_steal_pointer (&input);
427 }
428
429 static void
430 set_routes_ready (QmiClientWms *client,
431 GAsyncResult *res)
432 {
433 g_autoptr(QmiMessageWmsSetRoutesOutput) output = NULL;
434 GError *error = NULL;
435
436 output = qmi_client_wms_set_routes_finish (client, res, &error);
437 if (!output) {
438 g_printerr ("error: operation failed: %s\n", error->message);
439 g_error_free (error);
440 operation_shutdown (FALSE);
441 return;
442 }
443
444 if (!qmi_message_wms_set_routes_output_get_result (output, &error)) {
445 g_printerr ("error: couldn't set SMS routes: %s\n", error->message);
446 g_error_free (error);
447 operation_shutdown (FALSE);
448 return;
449 }
450
451 g_print ("[%s] Successfully set SMS routes\n",
452 qmi_device_get_path_display (ctx->device));
453
454 operation_shutdown (TRUE);
455 }
456
457 #endif /* HAVE_QMI_MESSAGE_WMS_SET_ROUTES */
458
459 #if defined HAVE_QMI_MESSAGE_WMS_SET_BROADCAST_CONFIG
460
461 static QmiMessageWmsSetBroadcastConfigInput *
462 set_broadcast_config_input_create (const gchar *str,
463 GError **error)
464 {
465 g_autoptr(QmiMessageWmsSetBroadcastConfigInput) input = NULL;
466 g_autoptr (GArray) channels_list = NULL;
467 GError *inner_error = NULL;
468
469 if (!qmicli_read_cbs_channels_from_string (str, &channels_list)) {
470 return NULL;
471 }
472
473 if (channels_list->len == 0) {
474 g_set_error_literal (error,
475 QMI_CORE_ERROR,
476 QMI_CORE_ERROR_FAILED,
477 "cbs channels list was empty");
478 return NULL;
479 }
480
481 /* Create input */
482 input = qmi_message_wms_set_broadcast_config_input_new ();
483
484 if (!qmi_message_wms_set_broadcast_config_input_set_message_mode (input,
485 QMI_WMS_MESSAGE_MODE_GSM_WCDMA,
486 &inner_error)) {
487 g_propagate_error (error, inner_error);
488 return NULL;
489 }
490
491 if (!qmi_message_wms_set_broadcast_config_input_set_channels (input, channels_list, &inner_error)) {
492 g_propagate_error (error, inner_error);
493 return NULL;
494 }
495
496 return g_steal_pointer (&input);
497 }
498
499 static void
500 set_broadcast_config_ready (QmiClientWms *client,
501 GAsyncResult *res)
502 {
503 g_autoptr(QmiMessageWmsSetBroadcastConfigOutput) output = NULL;
504 g_autoptr(GError) error = NULL;
505
506 output = qmi_client_wms_set_broadcast_config_finish (client, res, &error);
507 if (!output) {
508 g_printerr ("error: operation failed: %s\n", error->message);
509 operation_shutdown (FALSE);
510 return;
511 }
512
513 if (!qmi_message_wms_set_broadcast_config_output_get_result (output, &error)) {
514 g_printerr ("error: couldn't set CBS channels: %s\n", error->message);
515 operation_shutdown (FALSE);
516 return;
517 }
518
519 g_print ("[%s] Successfully set cbs channels\n",
520 qmi_device_get_path_display (ctx->device));
521
522 operation_shutdown (TRUE);
523 }
524
525 #endif
526
527 #if defined HAVE_QMI_MESSAGE_WMS_GET_BROADCAST_CONFIG
528
529 static void
530 get_broadcast_config_ready (QmiClientWms *client,
531 GAsyncResult *res)
532 {
533 g_autoptr(QmiMessageWmsGetBroadcastConfigOutput) output = NULL;
534 g_autoptr(GError) error = NULL;
535 GArray *channels = NULL;
536 gboolean active;
537 guint i;
538
539 output = qmi_client_wms_get_broadcast_config_finish (client, res, &error);
540 if (!output) {
541 g_printerr ("error: operation failed: %s\n", error->message);
542 operation_shutdown (FALSE);
543 return;
544 }
545
546 if (!qmi_message_wms_get_broadcast_config_output_get_result (output, &error)) {
547 g_printerr ("error: couldn't get CBS channels: %s\n", error->message);
548 operation_shutdown (FALSE);
549 return;
550 }
551
552 if (!qmi_message_wms_get_broadcast_config_output_get_config (output, &active, &channels, &error)) {
553 g_printerr ("error: couldn't get CBS channels: %s\n", error->message);
554 operation_shutdown (FALSE);
555 return;
556 }
557
558 g_print ("[%s] Successfully get cbs channels: ", qmi_device_get_path_display (ctx->device));
559
560 for (i = 0; i < channels->len; i++) {
561 QmiMessageWmsGetBroadcastConfigOutputConfigChannelsElement ch;
562
563 ch = g_array_index (channels, QmiMessageWmsGetBroadcastConfigOutputConfigChannelsElement, i);
564 if (!ch.selected)
565 continue;
566
567 if (i > 0)
568 g_print (",");
569
570 if (ch.start == ch.end)
571 g_print ("%d", ch.start);
572 else
573 g_print ("%d-%d", ch.start, ch.end);
574 }
575 g_print ("\n");
576
577 operation_shutdown (TRUE);
578 }
579
580 #endif
581
582 #if defined HAVE_QMI_MESSAGE_WMS_RESET
583
584 static void
585 reset_ready (QmiClientWms *client,
586 GAsyncResult *res)
587 {
588 QmiMessageWmsResetOutput *output;
589 GError *error = NULL;
590
591 output = qmi_client_wms_reset_finish (client, res, &error);
592 if (!output) {
593 g_printerr ("error: operation failed: %s\n", error->message);
594 g_error_free (error);
595 operation_shutdown (FALSE);
596 return;
597 }
598
599 if (!qmi_message_wms_reset_output_get_result (output, &error)) {
600 g_printerr ("error: couldn't reset the WMS service: %s\n", error->message);
601 g_error_free (error);
602 qmi_message_wms_reset_output_unref (output);
603 operation_shutdown (FALSE);
604 return;
605 }
606
607 g_print ("[%s] Successfully performed WMS service reset\n",
608 qmi_device_get_path_display (ctx->device));
609
610 qmi_message_wms_reset_output_unref (output);
611 operation_shutdown (TRUE);
612 }
613
614 #endif
615
616 static gboolean
617 noop_cb (gpointer unused)
618 {
619 operation_shutdown (TRUE);
620 return FALSE;
621 }
622
623 void
624 qmicli_wms_run (QmiDevice *device,
625 QmiClientWms *client,
626 GCancellable *cancellable)
627 {
628 /* Initialize context */
629 ctx = g_slice_new (Context);
630 ctx->device = g_object_ref (device);
631 ctx->client = g_object_ref (client);
632 ctx->cancellable = g_object_ref (cancellable);
633
634 #if defined HAVE_QMI_MESSAGE_WMS_GET_SUPPORTED_MESSAGES
635 if (get_supported_messages_flag) {
636 g_debug ("Asynchronously getting supported WMS messages...");
637 qmi_client_wms_get_supported_messages (ctx->client,
638 NULL,
639 10,
640 ctx->cancellable,
641 (GAsyncReadyCallback)get_supported_messages_ready,
642 NULL);
643 return;
644 }
645 #endif
646
647 #if defined HAVE_QMI_MESSAGE_WMS_GET_ROUTES
648 if (get_routes_flag) {
649 g_debug ("Asynchronously getting SMS routes...");
650 qmi_client_wms_get_routes (ctx->client,
651 NULL,
652 10,
653 ctx->cancellable,
654 (GAsyncReadyCallback)get_routes_ready,
655 NULL);
656 return;
657 }
658 #endif
659
660 #if defined HAVE_QMI_MESSAGE_WMS_SET_ROUTES
661 if (set_routes_str) {
662 g_autoptr(QmiMessageWmsSetRoutesInput) input = NULL;
663 GError *error = NULL;
664
665 input = set_routes_input_create (set_routes_str, &error);
666 if (!input) {
667 g_printerr ("Failed to set route: %s\n", error->message);
668 g_error_free (error);
669 operation_shutdown (FALSE);
670 return;
671 }
672 g_debug ("Asynchronously setting SMS routes...");
673 qmi_client_wms_set_routes (ctx->client,
674 input,
675 10,
676 ctx->cancellable,
677 (GAsyncReadyCallback)set_routes_ready,
678 NULL);
679 return;
680 }
681 #endif
682
683 #if defined HAVE_QMI_MESSAGE_WMS_SET_BROADCAST_CONFIG
684 if (set_broadcast_config_str) {
685 g_autoptr(QmiMessageWmsSetBroadcastConfigInput) input = NULL;
686 g_autoptr(GError) error = NULL;
687
688 input = set_broadcast_config_input_create (set_broadcast_config_str, &error);
689 if (!input) {
690 g_printerr ("Failed to set cbs channels: %s\n", error->message);
691 operation_shutdown (FALSE);
692 return;
693 }
694 g_debug ("Asynchronously setting CBS channels...");
695 qmi_client_wms_set_broadcast_config (ctx->client,
696 input,
697 10,
698 ctx->cancellable,
699 (GAsyncReadyCallback)set_broadcast_config_ready,
700 NULL);
701 return;
702 }
703 #endif
704 #if defined HAVE_QMI_MESSAGE_WMS_GET_BROADCAST_CONFIG
705 if (get_broadcast_config_flag) {
706 g_autoptr(QmiMessageWmsGetBroadcastConfigInput) input = NULL;
707 g_autoptr(GError) error = NULL;
708
709 input = qmi_message_wms_get_broadcast_config_input_new ();
710 if (!qmi_message_wms_get_broadcast_config_input_set_message_mode (input,
711 QMI_WMS_MESSAGE_MODE_GSM_WCDMA,
712 &error)) {
713 g_printerr ("Failed to get cbs channels: %s\n", error->message);
714 return;
715 }
716
717 g_debug ("Asynchronously getting CBS channels...");
718 qmi_client_wms_get_broadcast_config (ctx->client,
719 input,
720 10,
721 ctx->cancellable,
722 (GAsyncReadyCallback)get_broadcast_config_ready,
723 NULL);
724 return;
725
726 }
727 #endif
728
729 #if defined HAVE_QMI_MESSAGE_WMS_RESET
730 if (reset_flag) {
731 g_debug ("Asynchronously resetting WMS service...");
732 qmi_client_wms_reset (ctx->client,
733 NULL,
734 10,
735 ctx->cancellable,
736 (GAsyncReadyCallback)reset_ready,
737 NULL);
738 return;
739 }
740 #endif
741
742 /* Just client allocate/release? */
743 if (noop_flag) {
744 g_idle_add (noop_cb, NULL);
745 return;
746 }
747
748 g_warn_if_reached ();
749 }
750
751 #endif /* HAVE_QMI_SERVICE_WMS */