| 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) 2012-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_DMS |
| 37 |
|
| 38 |
#undef VALIDATE_UNKNOWN |
| 39 |
#define VALIDATE_UNKNOWN(str) (str ? str : "unknown") |
| 40 |
|
| 41 |
#undef VALIDATE_MASK_NONE |
| 42 |
#define VALIDATE_MASK_NONE(str) (str ? str : "none") |
| 43 |
|
| 44 |
/* Context */ |
| 45 |
typedef struct { |
| 46 |
QmiDevice *device; |
| 47 |
QmiClientDms *client; |
| 48 |
GCancellable *cancellable; |
| 49 |
} Context; |
| 50 |
static Context *ctx; |
| 51 |
|
| 52 |
/* Options */ |
| 53 |
static gboolean get_ids_flag; |
| 54 |
static gboolean get_capabilities_flag; |
| 55 |
static gboolean get_manufacturer_flag; |
| 56 |
static gboolean get_model_flag; |
| 57 |
static gboolean get_revision_flag; |
| 58 |
static gboolean get_msisdn_flag; |
| 59 |
static gboolean get_power_state_flag; |
| 60 |
static gchar *uim_set_pin_protection_str; |
| 61 |
static gchar *uim_verify_pin_str; |
| 62 |
static gchar *uim_unblock_pin_str; |
| 63 |
static gchar *uim_change_pin_str; |
| 64 |
static gboolean uim_get_pin_status_flag; |
| 65 |
static gboolean uim_get_iccid_flag; |
| 66 |
static gboolean uim_get_imsi_flag; |
| 67 |
static gboolean uim_get_state_flag; |
| 68 |
static gchar *uim_get_ck_status_str; |
| 69 |
static gchar *uim_set_ck_protection_str; |
| 70 |
static gchar *uim_unblock_ck_str; |
| 71 |
static gboolean get_hardware_revision_flag; |
| 72 |
static gboolean get_operating_mode_flag; |
| 73 |
static gchar *set_operating_mode_str; |
| 74 |
static gboolean get_time_flag; |
| 75 |
static gboolean get_prl_version_flag; |
| 76 |
static gboolean get_activation_state_flag; |
| 77 |
static gchar *activate_automatic_str; |
| 78 |
static gchar *activate_manual_str; |
| 79 |
static gboolean get_user_lock_state_flag; |
| 80 |
static gchar *set_user_lock_state_str; |
| 81 |
static gchar *set_user_lock_code_str; |
| 82 |
static gboolean read_user_data_flag; |
| 83 |
static gchar *write_user_data_str; |
| 84 |
static gboolean read_eri_file_flag; |
| 85 |
static gchar *restore_factory_defaults_str; |
| 86 |
static gchar *validate_service_programming_code_str; |
| 87 |
static gboolean set_firmware_id_flag; |
| 88 |
static gboolean get_band_capabilities_flag; |
| 89 |
static gboolean get_factory_sku_flag; |
| 90 |
static gboolean list_stored_images_flag; |
| 91 |
static gchar *select_stored_image_str; |
| 92 |
static gchar *delete_stored_image_str; |
| 93 |
static gboolean get_firmware_preference_flag; |
| 94 |
static gchar *set_firmware_preference_str; |
| 95 |
static gboolean get_boot_image_download_mode_flag; |
| 96 |
static gchar *set_boot_image_download_mode_str; |
| 97 |
static gboolean get_software_version_flag; |
| 98 |
static gboolean set_fcc_authentication_flag; |
| 99 |
static gboolean get_supported_messages_flag; |
| 100 |
static gchar *hp_change_device_mode_str; |
| 101 |
static gboolean swi_get_current_firmware_flag; |
| 102 |
static gboolean swi_get_usb_composition_flag; |
| 103 |
static gchar *swi_set_usb_composition_str; |
| 104 |
static gchar *dell_change_device_mode_str; /* deprecated */ |
| 105 |
static gchar *foxconn_change_device_mode_str; |
| 106 |
static gchar *dell_get_firmware_version_str; /* deprecated */ |
| 107 |
static gchar *foxconn_get_firmware_version_str; |
| 108 |
static gint foxconn_set_fcc_authentication_int = -1; |
| 109 |
static gchar *foxconn_set_fcc_authentication_v2_str; |
| 110 |
static gchar *get_mac_address_str; |
| 111 |
static gboolean reset_flag; |
| 112 |
static gboolean noop_flag; |
| 113 |
|
| 114 |
static GOptionEntry entries[] = { |
| 115 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_IDS |
| 116 |
{ "dms-get-ids", 0, 0, G_OPTION_ARG_NONE, &get_ids_flag, |
| 117 |
"Get IDs", |
| 118 |
NULL |
| 119 |
}, |
| 120 |
#endif |
| 121 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_CAPABILITIES |
| 122 |
{ "dms-get-capabilities", 0, 0, G_OPTION_ARG_NONE, &get_capabilities_flag, |
| 123 |
"Get capabilities", |
| 124 |
NULL |
| 125 |
}, |
| 126 |
#endif |
| 127 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_MANUFACTURER |
| 128 |
{ "dms-get-manufacturer", 0, 0, G_OPTION_ARG_NONE, &get_manufacturer_flag, |
| 129 |
"Get manufacturer", |
| 130 |
NULL |
| 131 |
}, |
| 132 |
#endif |
| 133 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_MODEL |
| 134 |
{ "dms-get-model", 0, 0, G_OPTION_ARG_NONE, &get_model_flag, |
| 135 |
"Get model", |
| 136 |
NULL |
| 137 |
}, |
| 138 |
#endif |
| 139 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_REVISION |
| 140 |
{ "dms-get-revision", 0, 0, G_OPTION_ARG_NONE, &get_revision_flag, |
| 141 |
"Get revision", |
| 142 |
NULL |
| 143 |
}, |
| 144 |
#endif |
| 145 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_MSISDN |
| 146 |
{ "dms-get-msisdn", 0, 0, G_OPTION_ARG_NONE, &get_msisdn_flag, |
| 147 |
"Get MSISDN", |
| 148 |
NULL |
| 149 |
}, |
| 150 |
#endif |
| 151 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_POWER_STATE |
| 152 |
{ "dms-get-power-state", 0, 0, G_OPTION_ARG_NONE, &get_power_state_flag, |
| 153 |
"Get power state", |
| 154 |
NULL |
| 155 |
}, |
| 156 |
#endif |
| 157 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_SET_PIN_PROTECTION |
| 158 |
{ "dms-uim-set-pin-protection", 0, 0, G_OPTION_ARG_STRING, &uim_set_pin_protection_str, |
| 159 |
"Set PIN protection in the UIM", |
| 160 |
"[(PIN|PIN2),(disable|enable),(current PIN)]", |
| 161 |
}, |
| 162 |
#endif |
| 163 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_VERIFY_PIN |
| 164 |
{ "dms-uim-verify-pin", 0, 0, G_OPTION_ARG_STRING, &uim_verify_pin_str, |
| 165 |
"Verify PIN", |
| 166 |
"[(PIN|PIN2),(current PIN)]", |
| 167 |
}, |
| 168 |
#endif |
| 169 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_UNBLOCK_PIN |
| 170 |
{ "dms-uim-unblock-pin", 0, 0, G_OPTION_ARG_STRING, &uim_unblock_pin_str, |
| 171 |
"Unblock PIN", |
| 172 |
"[(PIN|PIN2),(PUK),(new PIN)]", |
| 173 |
}, |
| 174 |
#endif |
| 175 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_CHANGE_PIN |
| 176 |
{ "dms-uim-change-pin", 0, 0, G_OPTION_ARG_STRING, &uim_change_pin_str, |
| 177 |
"Change PIN", |
| 178 |
"[(PIN|PIN2),(old PIN),(new PIN)]", |
| 179 |
}, |
| 180 |
#endif |
| 181 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_PIN_STATUS |
| 182 |
{ "dms-uim-get-pin-status", 0, 0, G_OPTION_ARG_NONE, &uim_get_pin_status_flag, |
| 183 |
"Get PIN status", |
| 184 |
NULL |
| 185 |
}, |
| 186 |
#endif |
| 187 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_ICCID |
| 188 |
{ "dms-uim-get-iccid", 0, 0, G_OPTION_ARG_NONE, &uim_get_iccid_flag, |
| 189 |
"Get ICCID", |
| 190 |
NULL |
| 191 |
}, |
| 192 |
#endif |
| 193 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_IMSI |
| 194 |
{ "dms-uim-get-imsi", 0, 0, G_OPTION_ARG_NONE, &uim_get_imsi_flag, |
| 195 |
"Get IMSI", |
| 196 |
NULL |
| 197 |
}, |
| 198 |
#endif |
| 199 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_STATE |
| 200 |
{ "dms-uim-get-state", 0, 0, G_OPTION_ARG_NONE, &uim_get_state_flag, |
| 201 |
"Get UIM State", |
| 202 |
NULL |
| 203 |
}, |
| 204 |
#endif |
| 205 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_CK_STATUS |
| 206 |
{ "dms-uim-get-ck-status", 0, 0, G_OPTION_ARG_STRING, &uim_get_ck_status_str, |
| 207 |
"Get CK Status", |
| 208 |
"[(pn|pu|pp|pc|pf)]" |
| 209 |
}, |
| 210 |
#endif |
| 211 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_SET_CK_PROTECTION |
| 212 |
{ "dms-uim-set-ck-protection", 0, 0, G_OPTION_ARG_STRING, &uim_set_ck_protection_str, |
| 213 |
"Disable CK protection", |
| 214 |
"[(pn|pu|pp|pc|pf),(disable),(key)]" |
| 215 |
}, |
| 216 |
#endif |
| 217 |
{ "dms-uim-unblock-ck", 0, 0, G_OPTION_ARG_STRING, &uim_unblock_ck_str, |
| 218 |
"Unblock CK", |
| 219 |
"[(pn|pu|pp|pc|pf),(key)]" |
| 220 |
}, |
| 221 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_HARDWARE_REVISION |
| 222 |
{ "dms-get-hardware-revision", 0, 0, G_OPTION_ARG_NONE, &get_hardware_revision_flag, |
| 223 |
"Get the HW revision", |
| 224 |
NULL |
| 225 |
}, |
| 226 |
#endif |
| 227 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_OPERATING_MODE |
| 228 |
{ "dms-get-operating-mode", 0, 0, G_OPTION_ARG_NONE, &get_operating_mode_flag, |
| 229 |
"Get the device operating mode", |
| 230 |
NULL |
| 231 |
}, |
| 232 |
#endif |
| 233 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_OPERATING_MODE |
| 234 |
{ "dms-set-operating-mode", 0, 0, G_OPTION_ARG_STRING, &set_operating_mode_str, |
| 235 |
"Set the device operating mode", |
| 236 |
"[(Operating mode)]" |
| 237 |
}, |
| 238 |
#endif |
| 239 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_TIME |
| 240 |
{ "dms-get-time", 0, 0, G_OPTION_ARG_NONE, &get_time_flag, |
| 241 |
"Get the device time", |
| 242 |
NULL, |
| 243 |
}, |
| 244 |
#endif |
| 245 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_PRL_VERSION |
| 246 |
{ "dms-get-prl-version", 0, 0, G_OPTION_ARG_NONE, &get_prl_version_flag, |
| 247 |
"Get the PRL version", |
| 248 |
NULL, |
| 249 |
}, |
| 250 |
#endif |
| 251 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_ACTIVATION_STATE |
| 252 |
{ "dms-get-activation-state", 0, 0, G_OPTION_ARG_NONE, &get_activation_state_flag, |
| 253 |
"Get the state of the service activation", |
| 254 |
NULL, |
| 255 |
}, |
| 256 |
#endif |
| 257 |
#if defined HAVE_QMI_MESSAGE_DMS_ACTIVATE_AUTOMATIC |
| 258 |
{ "dms-activate-automatic", 0, 0, G_OPTION_ARG_STRING, &activate_automatic_str, |
| 259 |
"Request automatic service activation", |
| 260 |
"[Activation Code]" |
| 261 |
}, |
| 262 |
#endif |
| 263 |
#if defined HAVE_QMI_MESSAGE_DMS_ACTIVATE_MANUAL |
| 264 |
{ "dms-activate-manual", 0, 0, G_OPTION_ARG_STRING, &activate_manual_str, |
| 265 |
"Request manual service activation", |
| 266 |
"[SPC,SID,MDN,MIN]" |
| 267 |
}, |
| 268 |
#endif |
| 269 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_USER_LOCK_STATE |
| 270 |
{ "dms-get-user-lock-state", 0, 0, G_OPTION_ARG_NONE, &get_user_lock_state_flag, |
| 271 |
"Get the state of the user lock", |
| 272 |
NULL, |
| 273 |
}, |
| 274 |
#endif |
| 275 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_USER_LOCK_STATE |
| 276 |
{ "dms-set-user-lock-state", 0, 0, G_OPTION_ARG_STRING, &set_user_lock_state_str, |
| 277 |
"Set the state of the user lock", |
| 278 |
"[(disable|enable),(current lock code)]", |
| 279 |
}, |
| 280 |
#endif |
| 281 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_USER_LOCK_CODE |
| 282 |
{ "dms-set-user-lock-code", 0, 0, G_OPTION_ARG_STRING, &set_user_lock_code_str, |
| 283 |
"Change the user lock code", |
| 284 |
"[(old lock code),(new lock code)]", |
| 285 |
}, |
| 286 |
#endif |
| 287 |
#if defined HAVE_QMI_MESSAGE_DMS_READ_USER_DATA |
| 288 |
{ "dms-read-user-data", 0, 0, G_OPTION_ARG_NONE, &read_user_data_flag, |
| 289 |
"Read user data", |
| 290 |
NULL, |
| 291 |
}, |
| 292 |
#endif |
| 293 |
#if defined HAVE_QMI_MESSAGE_DMS_WRITE_USER_DATA |
| 294 |
{ "dms-write-user-data", 0, 0, G_OPTION_ARG_STRING, &write_user_data_str, |
| 295 |
"Write user data", |
| 296 |
"[(User data)]", |
| 297 |
}, |
| 298 |
#endif |
| 299 |
#if defined HAVE_QMI_MESSAGE_DMS_READ_ERI_FILE |
| 300 |
{ "dms-read-eri-file", 0, 0, G_OPTION_ARG_NONE, &read_eri_file_flag, |
| 301 |
"Read ERI file", |
| 302 |
NULL, |
| 303 |
}, |
| 304 |
#endif |
| 305 |
#if defined HAVE_QMI_MESSAGE_DMS_RESTORE_FACTORY_DEFAULTS |
| 306 |
{ "dms-restore-factory-defaults", 0, 0, G_OPTION_ARG_STRING, &restore_factory_defaults_str, |
| 307 |
"Restore factory defaults", |
| 308 |
"[(Service Programming Code)]", |
| 309 |
}, |
| 310 |
#endif |
| 311 |
#if defined HAVE_QMI_MESSAGE_DMS_VALIDATE_SERVICE_PROGRAMMING_CODE |
| 312 |
{ "dms-validate-service-programming-code", 0, 0, G_OPTION_ARG_STRING, &validate_service_programming_code_str, |
| 313 |
"Validate the Service Programming Code", |
| 314 |
"[(Service Programming Code)]", |
| 315 |
}, |
| 316 |
#endif |
| 317 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_ID |
| 318 |
{ "dms-set-firmware-id", 0, 0, G_OPTION_ARG_NONE, &set_firmware_id_flag, |
| 319 |
"Set firmware id", |
| 320 |
NULL |
| 321 |
}, |
| 322 |
#endif |
| 323 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_BAND_CAPABILITIES |
| 324 |
{ "dms-get-band-capabilities", 0, 0, G_OPTION_ARG_NONE, &get_band_capabilities_flag, |
| 325 |
"Get band capabilities", |
| 326 |
NULL |
| 327 |
}, |
| 328 |
#endif |
| 329 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_FACTORY_SKU |
| 330 |
{ "dms-get-factory-sku", 0, 0, G_OPTION_ARG_NONE, &get_factory_sku_flag, |
| 331 |
"Get factory stock keeping unit", |
| 332 |
NULL |
| 333 |
}, |
| 334 |
#endif |
| 335 |
#if defined HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES && defined HAVE_QMI_MESSAGE_DMS_GET_STORED_IMAGE_INFO |
| 336 |
{ "dms-list-stored-images", 0, 0, G_OPTION_ARG_NONE, &list_stored_images_flag, |
| 337 |
"List stored images", |
| 338 |
NULL |
| 339 |
}, |
| 340 |
#endif |
| 341 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE && \ |
| 342 |
defined HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES |
| 343 |
{ "dms-select-stored-image", 0, 0, G_OPTION_ARG_STRING, &select_stored_image_str, |
| 344 |
"Select stored image", |
| 345 |
"[modem#,pri#] where # is the index" |
| 346 |
}, |
| 347 |
#endif |
| 348 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE && \ |
| 349 |
defined HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES && \ |
| 350 |
defined HAVE_QMI_MESSAGE_DMS_DELETE_STORED_IMAGE |
| 351 |
{ "dms-delete-stored-image", 0, 0, G_OPTION_ARG_STRING, &delete_stored_image_str, |
| 352 |
"Delete stored image", |
| 353 |
"[modem#|pri#] where # is the index" |
| 354 |
}, |
| 355 |
#endif |
| 356 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_FIRMWARE_PREFERENCE |
| 357 |
{ "dms-get-firmware-preference", 0, 0, G_OPTION_ARG_NONE, &get_firmware_preference_flag, |
| 358 |
"Get firmware preference", |
| 359 |
NULL |
| 360 |
}, |
| 361 |
#endif |
| 362 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE |
| 363 |
{ "dms-set-firmware-preference", 0, 0, G_OPTION_ARG_STRING, &set_firmware_preference_str, |
| 364 |
"Set firmware preference (required keys: firmware-version, config-version, carrier; optional keys: modem-storage-index, override-download=yes)", |
| 365 |
"[\"key=value,...\"]" |
| 366 |
}, |
| 367 |
#endif |
| 368 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_BOOT_IMAGE_DOWNLOAD_MODE |
| 369 |
{ "dms-get-boot-image-download-mode", 0, 0, G_OPTION_ARG_NONE, &get_boot_image_download_mode_flag, |
| 370 |
"Get boot image download mode", |
| 371 |
NULL |
| 372 |
}, |
| 373 |
#endif |
| 374 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_BOOT_IMAGE_DOWNLOAD_MODE |
| 375 |
{ "dms-set-boot-image-download-mode", 0, 0, G_OPTION_ARG_STRING, &set_boot_image_download_mode_str, |
| 376 |
"Set boot image download mode", |
| 377 |
"[normal|boot-and-recovery]" |
| 378 |
}, |
| 379 |
#endif |
| 380 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_SOFTWARE_VERSION |
| 381 |
{ "dms-get-software-version", 0, 0, G_OPTION_ARG_NONE, &get_software_version_flag, |
| 382 |
"Get software version", |
| 383 |
NULL |
| 384 |
}, |
| 385 |
#endif |
| 386 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FCC_AUTHENTICATION |
| 387 |
{ "dms-set-fcc-authentication", 0, 0, G_OPTION_ARG_NONE, &set_fcc_authentication_flag, |
| 388 |
"Set FCC authentication", |
| 389 |
NULL |
| 390 |
}, |
| 391 |
#endif |
| 392 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_SUPPORTED_MESSAGES |
| 393 |
{ "dms-get-supported-messages", 0, 0, G_OPTION_ARG_NONE, &get_supported_messages_flag, |
| 394 |
"Get supported messages", |
| 395 |
NULL |
| 396 |
}, |
| 397 |
#endif |
| 398 |
#if defined HAVE_QMI_MESSAGE_DMS_HP_CHANGE_DEVICE_MODE |
| 399 |
{ "dms-hp-change-device-mode", 0, 0, G_OPTION_ARG_STRING, &hp_change_device_mode_str, |
| 400 |
"Change device mode (HP specific)", |
| 401 |
"[fastboot]" |
| 402 |
}, |
| 403 |
#endif |
| 404 |
#if defined HAVE_QMI_MESSAGE_DMS_SWI_GET_CURRENT_FIRMWARE |
| 405 |
{ "dms-swi-get-current-firmware", 0, 0, G_OPTION_ARG_NONE, &swi_get_current_firmware_flag, |
| 406 |
"Get Current Firmware (Sierra Wireless specific)", |
| 407 |
NULL |
| 408 |
}, |
| 409 |
#endif |
| 410 |
#if defined HAVE_QMI_MESSAGE_DMS_SWI_GET_USB_COMPOSITION |
| 411 |
{ "dms-swi-get-usb-composition", 0, 0, G_OPTION_ARG_NONE, &swi_get_usb_composition_flag, |
| 412 |
"Get current and supported USB compositions (Sierra Wireless specific)", |
| 413 |
NULL |
| 414 |
}, |
| 415 |
#endif |
| 416 |
#if defined HAVE_QMI_MESSAGE_DMS_SWI_SET_USB_COMPOSITION |
| 417 |
{ "dms-swi-set-usb-composition", 0, 0, G_OPTION_ARG_STRING, &swi_set_usb_composition_str, |
| 418 |
"Set USB composition (Sierra Wireless specific)", |
| 419 |
"[#]" |
| 420 |
}, |
| 421 |
#endif |
| 422 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_CHANGE_DEVICE_MODE |
| 423 |
{ "dms-foxconn-change-device-mode", 0, 0, G_OPTION_ARG_STRING, &foxconn_change_device_mode_str, |
| 424 |
"Change device mode (Foxconn specific)", |
| 425 |
"[fastboot-ota|fastboot-online]" |
| 426 |
}, |
| 427 |
#endif |
| 428 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_GET_FIRMWARE_VERSION |
| 429 |
{ "dms-foxconn-get-firmware-version", 0, 0, G_OPTION_ARG_STRING, &foxconn_get_firmware_version_str, |
| 430 |
"Get firmware version (Foxconn specific)", |
| 431 |
"[firmware-mcfg-apps|firmware-mcfg|apps]" |
| 432 |
}, |
| 433 |
#endif |
| 434 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION |
| 435 |
{ "dms-foxconn-set-fcc-authentication", 0, 0, G_OPTION_ARG_INT, &foxconn_set_fcc_authentication_int, |
| 436 |
"Set FCC authentication (Foxconn specific)", |
| 437 |
"[magic]" |
| 438 |
}, |
| 439 |
#endif |
| 440 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION_V2 |
| 441 |
{ "dms-foxconn-set-fcc-authentication-v2", 0, 0, G_OPTION_ARG_STRING, &foxconn_set_fcc_authentication_v2_str, |
| 442 |
"Set FCC authentication (Foxconn specific, v2)", |
| 443 |
"[magic-string,magic-number]" |
| 444 |
}, |
| 445 |
#endif |
| 446 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_MAC_ADDRESS |
| 447 |
{ "dms-get-mac-address", 0, 0, G_OPTION_ARG_STRING, &get_mac_address_str, |
| 448 |
"Get default MAC address", |
| 449 |
"[wlan|bt]" |
| 450 |
}, |
| 451 |
#endif |
| 452 |
#if defined HAVE_QMI_MESSAGE_DMS_RESET |
| 453 |
{ "dms-reset", 0, 0, G_OPTION_ARG_NONE, &reset_flag, |
| 454 |
"Reset the service state", |
| 455 |
NULL |
| 456 |
}, |
| 457 |
#endif |
| 458 |
{ "dms-noop", 0, 0, G_OPTION_ARG_NONE, &noop_flag, |
| 459 |
"Just allocate or release a DMS client. Use with `--client-no-release-cid' and/or `--client-cid'", |
| 460 |
NULL |
| 461 |
}, |
| 462 |
/* deprecated entries (hidden in --help) */ |
| 463 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_CHANGE_DEVICE_MODE |
| 464 |
{ "dms-dell-change-device-mode", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &dell_change_device_mode_str, |
| 465 |
"Change device mode (DELL specific)", |
| 466 |
"[fastboot-ota|fastboot-online]" |
| 467 |
}, |
| 468 |
#endif |
| 469 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_GET_FIRMWARE_VERSION |
| 470 |
{ "dms-dell-get-firmware-version", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &dell_get_firmware_version_str, |
| 471 |
"Get firmware version (DELL specific)", |
| 472 |
"[firmware-mcfg-apps|firmware-mcfg|apps]" |
| 473 |
}, |
| 474 |
#endif |
| 475 |
{ NULL, 0, 0, 0, NULL, NULL, NULL } |
| 476 |
}; |
| 477 |
|
| 478 |
GOptionGroup * |
| 479 |
qmicli_dms_get_option_group (void) |
| 480 |
{ |
| 481 |
GOptionGroup *group; |
| 482 |
|
| 483 |
group = g_option_group_new ("dms", |
| 484 |
"DMS options:", |
| 485 |
"Show Device Management Service options", |
| 486 |
NULL, |
| 487 |
NULL); |
| 488 |
g_option_group_add_entries (group, entries); |
| 489 |
|
| 490 |
return group; |
| 491 |
} |
| 492 |
|
| 493 |
gboolean |
| 494 |
qmicli_dms_options_enabled (void) |
| 495 |
{ |
| 496 |
static guint n_actions = 0; |
| 497 |
static gboolean checked = FALSE; |
| 498 |
|
| 499 |
if (checked) |
| 500 |
return !!n_actions; |
| 501 |
|
| 502 |
n_actions = (get_ids_flag + |
| 503 |
get_capabilities_flag + |
| 504 |
get_manufacturer_flag + |
| 505 |
get_model_flag + |
| 506 |
get_revision_flag + |
| 507 |
get_msisdn_flag + |
| 508 |
get_power_state_flag + |
| 509 |
!!uim_set_pin_protection_str + |
| 510 |
!!uim_verify_pin_str + |
| 511 |
!!uim_unblock_pin_str + |
| 512 |
!!uim_change_pin_str + |
| 513 |
uim_get_pin_status_flag + |
| 514 |
uim_get_iccid_flag + |
| 515 |
uim_get_imsi_flag + |
| 516 |
uim_get_state_flag + |
| 517 |
!!uim_get_ck_status_str + |
| 518 |
!!uim_set_ck_protection_str + |
| 519 |
!!uim_unblock_ck_str + |
| 520 |
get_hardware_revision_flag + |
| 521 |
get_operating_mode_flag + |
| 522 |
!!set_operating_mode_str + |
| 523 |
get_time_flag + |
| 524 |
get_prl_version_flag + |
| 525 |
get_activation_state_flag + |
| 526 |
!!activate_automatic_str + |
| 527 |
!!activate_manual_str + |
| 528 |
get_user_lock_state_flag + |
| 529 |
!!set_user_lock_state_str + |
| 530 |
!!set_user_lock_code_str + |
| 531 |
read_user_data_flag + |
| 532 |
!!write_user_data_str + |
| 533 |
read_eri_file_flag + |
| 534 |
!!restore_factory_defaults_str + |
| 535 |
!!validate_service_programming_code_str + |
| 536 |
set_firmware_id_flag + |
| 537 |
get_band_capabilities_flag + |
| 538 |
get_factory_sku_flag + |
| 539 |
list_stored_images_flag + |
| 540 |
!!select_stored_image_str + |
| 541 |
!!delete_stored_image_str + |
| 542 |
get_firmware_preference_flag + |
| 543 |
!!set_firmware_preference_str + |
| 544 |
get_boot_image_download_mode_flag + |
| 545 |
!!set_boot_image_download_mode_str + |
| 546 |
get_software_version_flag + |
| 547 |
set_fcc_authentication_flag + |
| 548 |
get_supported_messages_flag + |
| 549 |
!!hp_change_device_mode_str + |
| 550 |
swi_get_current_firmware_flag + |
| 551 |
swi_get_usb_composition_flag + |
| 552 |
!!swi_set_usb_composition_str + |
| 553 |
!!dell_change_device_mode_str + |
| 554 |
!!foxconn_change_device_mode_str + |
| 555 |
!!dell_get_firmware_version_str + |
| 556 |
!!foxconn_get_firmware_version_str + |
| 557 |
(foxconn_set_fcc_authentication_int >= 0) + |
| 558 |
!!foxconn_set_fcc_authentication_v2_str + |
| 559 |
!!get_mac_address_str + |
| 560 |
reset_flag + |
| 561 |
noop_flag); |
| 562 |
|
| 563 |
if (n_actions > 1) { |
| 564 |
g_printerr ("error: too many DMS actions requested\n"); |
| 565 |
exit (EXIT_FAILURE); |
| 566 |
} |
| 567 |
|
| 568 |
checked = TRUE; |
| 569 |
return !!n_actions; |
| 570 |
} |
| 571 |
|
| 572 |
static void |
| 573 |
context_free (Context *context) |
| 574 |
{ |
| 575 |
if (!context) |
| 576 |
return; |
| 577 |
|
| 578 |
if (context->cancellable) |
| 579 |
g_object_unref (context->cancellable); |
| 580 |
if (context->device) |
| 581 |
g_object_unref (context->device); |
| 582 |
if (context->client) |
| 583 |
g_object_unref (context->client); |
| 584 |
g_slice_free (Context, context); |
| 585 |
} |
| 586 |
|
| 587 |
static void |
| 588 |
operation_shutdown (gboolean operation_status) |
| 589 |
{ |
| 590 |
/* Cleanup context and finish async operation */ |
| 591 |
context_free (ctx); |
| 592 |
qmicli_async_operation_done (operation_status, FALSE); |
| 593 |
} |
| 594 |
|
| 595 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_CHANGE_DEVICE_MODE || \ |
| 596 |
defined HAVE_QMI_MESSAGE_DMS_FOXCONN_CHANGE_DEVICE_MODE |
| 597 |
|
| 598 |
static void |
| 599 |
operation_shutdown_skip_cid_release (gboolean operation_status) |
| 600 |
{ |
| 601 |
/* Cleanup context and finish async operation. Explicitly ask not to release |
| 602 |
* the client CID. This is so that the qmicli operation doesn't fail after |
| 603 |
* this step, e.g. if the device just reboots after the action. */ |
| 604 |
context_free (ctx); |
| 605 |
qmicli_async_operation_done (operation_status, TRUE); |
| 606 |
} |
| 607 |
|
| 608 |
#endif |
| 609 |
|
| 610 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_IDS |
| 611 |
|
| 612 |
static void |
| 613 |
get_ids_ready (QmiClientDms *client, |
| 614 |
GAsyncResult *res) |
| 615 |
{ |
| 616 |
const gchar *esn = NULL; |
| 617 |
const gchar *imei = NULL; |
| 618 |
const gchar *meid = NULL; |
| 619 |
const gchar *imei_software_version = NULL; |
| 620 |
QmiMessageDmsGetIdsOutput *output; |
| 621 |
GError *error = NULL; |
| 622 |
|
| 623 |
output = qmi_client_dms_get_ids_finish (client, res, &error); |
| 624 |
if (!output) { |
| 625 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 626 |
g_error_free (error); |
| 627 |
operation_shutdown (FALSE); |
| 628 |
return; |
| 629 |
} |
| 630 |
|
| 631 |
if (!qmi_message_dms_get_ids_output_get_result (output, &error)) { |
| 632 |
g_printerr ("error: couldn't get IDs: %s\n", error->message); |
| 633 |
g_error_free (error); |
| 634 |
qmi_message_dms_get_ids_output_unref (output); |
| 635 |
operation_shutdown (FALSE); |
| 636 |
return; |
| 637 |
} |
| 638 |
|
| 639 |
qmi_message_dms_get_ids_output_get_esn (output, &esn, NULL); |
| 640 |
qmi_message_dms_get_ids_output_get_imei (output, &imei, NULL); |
| 641 |
qmi_message_dms_get_ids_output_get_meid (output, &meid, NULL); |
| 642 |
|
| 643 |
g_print ("[%s] Device IDs retrieved:\n" |
| 644 |
"\t ESN: '%s'\n" |
| 645 |
"\t IMEI: '%s'\n" |
| 646 |
"\t MEID: '%s'\n", |
| 647 |
qmi_device_get_path_display (ctx->device), |
| 648 |
VALIDATE_UNKNOWN (esn), |
| 649 |
VALIDATE_UNKNOWN (imei), |
| 650 |
VALIDATE_UNKNOWN (meid)); |
| 651 |
|
| 652 |
if (qmi_message_dms_get_ids_output_get_imei_software_version (output, |
| 653 |
&imei_software_version, |
| 654 |
NULL)) { |
| 655 |
g_print("\tIMEI SV: '%s'\n", imei_software_version); |
| 656 |
} |
| 657 |
|
| 658 |
qmi_message_dms_get_ids_output_unref (output); |
| 659 |
operation_shutdown (TRUE); |
| 660 |
} |
| 661 |
|
| 662 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_IDS */ |
| 663 |
|
| 664 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_CAPABILITIES |
| 665 |
|
| 666 |
static void |
| 667 |
get_capabilities_ready (QmiClientDms *client, |
| 668 |
GAsyncResult *res) |
| 669 |
{ |
| 670 |
QmiMessageDmsGetCapabilitiesOutput *output; |
| 671 |
guint32 max_tx_channel_rate; |
| 672 |
guint32 max_rx_channel_rate; |
| 673 |
QmiDmsDataServiceCapability data_service_capability; |
| 674 |
QmiDmsSimCapability sim_capability; |
| 675 |
GArray *radio_interface_list; |
| 676 |
GError *error = NULL; |
| 677 |
GString *networks; |
| 678 |
guint i; |
| 679 |
|
| 680 |
output = qmi_client_dms_get_capabilities_finish (client, res, &error); |
| 681 |
if (!output) { |
| 682 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 683 |
g_error_free (error); |
| 684 |
operation_shutdown (FALSE); |
| 685 |
return; |
| 686 |
} |
| 687 |
|
| 688 |
if (!qmi_message_dms_get_capabilities_output_get_result (output, &error)) { |
| 689 |
g_printerr ("error: couldn't get capabilities: %s\n", error->message); |
| 690 |
g_error_free (error); |
| 691 |
qmi_message_dms_get_capabilities_output_unref (output); |
| 692 |
operation_shutdown (FALSE); |
| 693 |
return; |
| 694 |
} |
| 695 |
|
| 696 |
qmi_message_dms_get_capabilities_output_get_info (output, |
| 697 |
&max_tx_channel_rate, |
| 698 |
&max_rx_channel_rate, |
| 699 |
&data_service_capability, |
| 700 |
&sim_capability, |
| 701 |
&radio_interface_list, |
| 702 |
NULL); |
| 703 |
|
| 704 |
networks = g_string_new (""); |
| 705 |
for (i = 0; i < radio_interface_list->len; i++) { |
| 706 |
g_string_append (networks, |
| 707 |
qmi_dms_radio_interface_get_string ( |
| 708 |
g_array_index (radio_interface_list, |
| 709 |
QmiDmsRadioInterface, |
| 710 |
i))); |
| 711 |
if (i != radio_interface_list->len - 1) |
| 712 |
g_string_append (networks, ", "); |
| 713 |
} |
| 714 |
|
| 715 |
g_print ("[%s] Device capabilities retrieved:\n" |
| 716 |
"\tMax TX channel rate: '%u'\n" |
| 717 |
"\tMax RX channel rate: '%u'\n" |
| 718 |
"\t Data Service: '%s'\n" |
| 719 |
"\t SIM: '%s'\n" |
| 720 |
"\t Networks: '%s'\n", |
| 721 |
qmi_device_get_path_display (ctx->device), |
| 722 |
max_tx_channel_rate, |
| 723 |
max_rx_channel_rate, |
| 724 |
qmi_dms_data_service_capability_get_string (data_service_capability), |
| 725 |
qmi_dms_sim_capability_get_string (sim_capability), |
| 726 |
networks->str); |
| 727 |
|
| 728 |
g_string_free (networks, TRUE); |
| 729 |
qmi_message_dms_get_capabilities_output_unref (output); |
| 730 |
operation_shutdown (TRUE); |
| 731 |
} |
| 732 |
|
| 733 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_CAPABILITIES */ |
| 734 |
|
| 735 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_MANUFACTURER |
| 736 |
|
| 737 |
static void |
| 738 |
get_manufacturer_ready (QmiClientDms *client, |
| 739 |
GAsyncResult *res) |
| 740 |
{ |
| 741 |
const gchar *str = NULL; |
| 742 |
QmiMessageDmsGetManufacturerOutput *output; |
| 743 |
GError *error = NULL; |
| 744 |
|
| 745 |
output = qmi_client_dms_get_manufacturer_finish (client, res, &error); |
| 746 |
if (!output) { |
| 747 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 748 |
g_error_free (error); |
| 749 |
operation_shutdown (FALSE); |
| 750 |
return; |
| 751 |
} |
| 752 |
|
| 753 |
if (!qmi_message_dms_get_manufacturer_output_get_result (output, &error)) { |
| 754 |
g_printerr ("error: couldn't get manufacturer: %s\n", error->message); |
| 755 |
g_error_free (error); |
| 756 |
qmi_message_dms_get_manufacturer_output_unref (output); |
| 757 |
operation_shutdown (FALSE); |
| 758 |
return; |
| 759 |
} |
| 760 |
|
| 761 |
qmi_message_dms_get_manufacturer_output_get_manufacturer (output, &str, NULL); |
| 762 |
|
| 763 |
g_print ("[%s] Device manufacturer retrieved:\n" |
| 764 |
"\tManufacturer: '%s'\n", |
| 765 |
qmi_device_get_path_display (ctx->device), |
| 766 |
VALIDATE_UNKNOWN (str)); |
| 767 |
|
| 768 |
qmi_message_dms_get_manufacturer_output_unref (output); |
| 769 |
operation_shutdown (TRUE); |
| 770 |
} |
| 771 |
|
| 772 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_MANUFACTURER */ |
| 773 |
|
| 774 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_MODEL |
| 775 |
|
| 776 |
static void |
| 777 |
get_model_ready (QmiClientDms *client, |
| 778 |
GAsyncResult *res) |
| 779 |
{ |
| 780 |
const gchar *str = NULL; |
| 781 |
QmiMessageDmsGetModelOutput *output; |
| 782 |
GError *error = NULL; |
| 783 |
|
| 784 |
output = qmi_client_dms_get_model_finish (client, res, &error); |
| 785 |
if (!output) { |
| 786 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 787 |
g_error_free (error); |
| 788 |
operation_shutdown (FALSE); |
| 789 |
return; |
| 790 |
} |
| 791 |
|
| 792 |
if (!qmi_message_dms_get_model_output_get_result (output, &error)) { |
| 793 |
g_printerr ("error: couldn't get model: %s\n", error->message); |
| 794 |
g_error_free (error); |
| 795 |
qmi_message_dms_get_model_output_unref (output); |
| 796 |
operation_shutdown (FALSE); |
| 797 |
return; |
| 798 |
} |
| 799 |
|
| 800 |
qmi_message_dms_get_model_output_get_model (output, &str, NULL); |
| 801 |
|
| 802 |
g_print ("[%s] Device model retrieved:\n" |
| 803 |
"\tModel: '%s'\n", |
| 804 |
qmi_device_get_path_display (ctx->device), |
| 805 |
VALIDATE_UNKNOWN (str)); |
| 806 |
|
| 807 |
qmi_message_dms_get_model_output_unref (output); |
| 808 |
operation_shutdown (TRUE); |
| 809 |
} |
| 810 |
|
| 811 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_MODEL */ |
| 812 |
|
| 813 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_REVISION |
| 814 |
|
| 815 |
static void |
| 816 |
get_revision_ready (QmiClientDms *client, |
| 817 |
GAsyncResult *res) |
| 818 |
{ |
| 819 |
const gchar *str = NULL; |
| 820 |
QmiMessageDmsGetRevisionOutput *output; |
| 821 |
GError *error = NULL; |
| 822 |
|
| 823 |
output = qmi_client_dms_get_revision_finish (client, res, &error); |
| 824 |
if (!output) { |
| 825 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 826 |
g_error_free (error); |
| 827 |
operation_shutdown (FALSE); |
| 828 |
return; |
| 829 |
} |
| 830 |
|
| 831 |
if (!qmi_message_dms_get_revision_output_get_result (output, &error)) { |
| 832 |
g_printerr ("error: couldn't get revision: %s\n", error->message); |
| 833 |
g_error_free (error); |
| 834 |
qmi_message_dms_get_revision_output_unref (output); |
| 835 |
operation_shutdown (FALSE); |
| 836 |
return; |
| 837 |
} |
| 838 |
|
| 839 |
qmi_message_dms_get_revision_output_get_revision (output, &str, NULL); |
| 840 |
|
| 841 |
g_print ("[%s] Device revision retrieved:\n" |
| 842 |
"\tRevision: '%s'\n", |
| 843 |
qmi_device_get_path_display (ctx->device), |
| 844 |
VALIDATE_UNKNOWN (str)); |
| 845 |
|
| 846 |
qmi_message_dms_get_revision_output_unref (output); |
| 847 |
operation_shutdown (TRUE); |
| 848 |
} |
| 849 |
|
| 850 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_REVISION */ |
| 851 |
|
| 852 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_MSISDN |
| 853 |
|
| 854 |
static void |
| 855 |
get_msisdn_ready (QmiClientDms *client, |
| 856 |
GAsyncResult *res) |
| 857 |
{ |
| 858 |
const gchar *str = NULL; |
| 859 |
QmiMessageDmsGetMsisdnOutput *output; |
| 860 |
GError *error = NULL; |
| 861 |
|
| 862 |
output = qmi_client_dms_get_msisdn_finish (client, res, &error); |
| 863 |
if (!output) { |
| 864 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 865 |
g_error_free (error); |
| 866 |
operation_shutdown (FALSE); |
| 867 |
return; |
| 868 |
} |
| 869 |
|
| 870 |
if (!qmi_message_dms_get_msisdn_output_get_result (output, &error)) { |
| 871 |
g_printerr ("error: couldn't get MSISDN: %s\n", error->message); |
| 872 |
g_error_free (error); |
| 873 |
qmi_message_dms_get_msisdn_output_unref (output); |
| 874 |
operation_shutdown (FALSE); |
| 875 |
return; |
| 876 |
} |
| 877 |
|
| 878 |
qmi_message_dms_get_msisdn_output_get_msisdn (output, &str, NULL); |
| 879 |
|
| 880 |
g_print ("[%s] Device MSISDN retrieved:\n" |
| 881 |
"\tMSISDN: '%s'\n", |
| 882 |
qmi_device_get_path_display (ctx->device), |
| 883 |
VALIDATE_UNKNOWN (str)); |
| 884 |
|
| 885 |
qmi_message_dms_get_msisdn_output_unref (output); |
| 886 |
operation_shutdown (TRUE); |
| 887 |
} |
| 888 |
|
| 889 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_MSISDN */ |
| 890 |
|
| 891 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_POWER_STATE |
| 892 |
|
| 893 |
static void |
| 894 |
get_power_state_ready (QmiClientDms *client, |
| 895 |
GAsyncResult *res) |
| 896 |
{ |
| 897 |
g_autofree gchar *power_state_str = NULL; |
| 898 |
guint8 power_state_flags; |
| 899 |
guint8 battery_level; |
| 900 |
QmiMessageDmsGetPowerStateOutput *output; |
| 901 |
GError *error = NULL; |
| 902 |
|
| 903 |
output = qmi_client_dms_get_power_state_finish (client, res, &error); |
| 904 |
if (!output) { |
| 905 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 906 |
g_error_free (error); |
| 907 |
operation_shutdown (FALSE); |
| 908 |
return; |
| 909 |
} |
| 910 |
|
| 911 |
if (!qmi_message_dms_get_power_state_output_get_result (output, &error)) { |
| 912 |
g_printerr ("error: couldn't get power state: %s\n", error->message); |
| 913 |
g_error_free (error); |
| 914 |
qmi_message_dms_get_power_state_output_unref (output); |
| 915 |
operation_shutdown (FALSE); |
| 916 |
return; |
| 917 |
} |
| 918 |
|
| 919 |
qmi_message_dms_get_power_state_output_get_info (output, |
| 920 |
&power_state_flags, |
| 921 |
&battery_level, |
| 922 |
NULL); |
| 923 |
power_state_str = qmi_dms_power_state_build_string_from_mask ((QmiDmsPowerState)power_state_flags); |
| 924 |
|
| 925 |
g_print ("[%s] Device power state retrieved:\n" |
| 926 |
"\tPower state: '%s'\n" |
| 927 |
"\tBattery level: '%u %%'\n", |
| 928 |
qmi_device_get_path_display (ctx->device), |
| 929 |
VALIDATE_MASK_NONE (power_state_str), |
| 930 |
(guint)battery_level); |
| 931 |
|
| 932 |
qmi_message_dms_get_power_state_output_unref (output); |
| 933 |
operation_shutdown (TRUE); |
| 934 |
} |
| 935 |
|
| 936 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_POWER_STATE */ |
| 937 |
|
| 938 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_SET_PIN_PROTECTION |
| 939 |
|
| 940 |
static QmiMessageDmsUimSetPinProtectionInput * |
| 941 |
uim_set_pin_protection_input_create (const gchar *str) |
| 942 |
{ |
| 943 |
QmiMessageDmsUimSetPinProtectionInput *input = NULL; |
| 944 |
g_auto(GStrv) split = NULL; |
| 945 |
QmiDmsUimPinId pin_id; |
| 946 |
gboolean enable_disable; |
| 947 |
gchar *current_pin; |
| 948 |
|
| 949 |
/* Prepare inputs. |
| 950 |
* Format of the string is: |
| 951 |
* "[(PIN|PIN2),(disable|enable),(current PIN)]" |
| 952 |
*/ |
| 953 |
split = g_strsplit (str, ",", -1); |
| 954 |
if (qmicli_read_dms_uim_pin_id_from_string (split[0], &pin_id) && |
| 955 |
qmicli_read_enable_disable_from_string (split[1], &enable_disable) && |
| 956 |
qmicli_read_non_empty_string (split[2], "current PIN", ¤t_pin)) { |
| 957 |
GError *error = NULL; |
| 958 |
|
| 959 |
input = qmi_message_dms_uim_set_pin_protection_input_new (); |
| 960 |
if (!qmi_message_dms_uim_set_pin_protection_input_set_info ( |
| 961 |
input, |
| 962 |
pin_id, |
| 963 |
enable_disable, |
| 964 |
current_pin, |
| 965 |
&error)) { |
| 966 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 967 |
error->message); |
| 968 |
g_error_free (error); |
| 969 |
qmi_message_dms_uim_set_pin_protection_input_unref (input); |
| 970 |
input = NULL; |
| 971 |
} |
| 972 |
} |
| 973 |
|
| 974 |
return input; |
| 975 |
} |
| 976 |
|
| 977 |
static void |
| 978 |
uim_set_pin_protection_ready (QmiClientDms *client, |
| 979 |
GAsyncResult *res) |
| 980 |
{ |
| 981 |
QmiMessageDmsUimSetPinProtectionOutput *output; |
| 982 |
GError *error = NULL; |
| 983 |
|
| 984 |
output = qmi_client_dms_uim_set_pin_protection_finish (client, res, &error); |
| 985 |
if (!output) { |
| 986 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 987 |
g_error_free (error); |
| 988 |
operation_shutdown (FALSE); |
| 989 |
return; |
| 990 |
} |
| 991 |
|
| 992 |
if (!qmi_message_dms_uim_set_pin_protection_output_get_result (output, &error)) { |
| 993 |
guint8 verify_retries_left; |
| 994 |
guint8 unblock_retries_left; |
| 995 |
|
| 996 |
g_printerr ("error: couldn't set PIN protection: %s\n", error->message); |
| 997 |
g_error_free (error); |
| 998 |
|
| 999 |
if (qmi_message_dms_uim_set_pin_protection_output_get_pin_retries_status ( |
| 1000 |
output, |
| 1001 |
&verify_retries_left, |
| 1002 |
&unblock_retries_left, |
| 1003 |
NULL)) { |
| 1004 |
g_printerr ("[%s] Retries left:\n" |
| 1005 |
"\tVerify: %u\n" |
| 1006 |
"\tUnblock: %u\n", |
| 1007 |
qmi_device_get_path_display (ctx->device), |
| 1008 |
verify_retries_left, |
| 1009 |
unblock_retries_left); |
| 1010 |
} |
| 1011 |
|
| 1012 |
qmi_message_dms_uim_set_pin_protection_output_unref (output); |
| 1013 |
operation_shutdown (FALSE); |
| 1014 |
return; |
| 1015 |
} |
| 1016 |
|
| 1017 |
g_print ("[%s] PIN protection updated\n", |
| 1018 |
qmi_device_get_path_display (ctx->device)); |
| 1019 |
|
| 1020 |
qmi_message_dms_uim_set_pin_protection_output_unref (output); |
| 1021 |
operation_shutdown (TRUE); |
| 1022 |
} |
| 1023 |
|
| 1024 |
#endif /* HAVE_QMI_MESSAGE_DMS_UIM_SET_PIN_PROTECTION */ |
| 1025 |
|
| 1026 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_VERIFY_PIN |
| 1027 |
|
| 1028 |
static QmiMessageDmsUimVerifyPinInput * |
| 1029 |
uim_verify_pin_input_create (const gchar *str) |
| 1030 |
{ |
| 1031 |
QmiMessageDmsUimVerifyPinInput *input = NULL; |
| 1032 |
g_auto(GStrv) split = NULL; |
| 1033 |
QmiDmsUimPinId pin_id; |
| 1034 |
gchar *current_pin; |
| 1035 |
|
| 1036 |
/* Prepare inputs. |
| 1037 |
* Format of the string is: |
| 1038 |
* "[(PIN|PIN2),(current PIN)]" |
| 1039 |
*/ |
| 1040 |
split = g_strsplit (str, ",", -1); |
| 1041 |
if (qmicli_read_dms_uim_pin_id_from_string (split[0], &pin_id) && |
| 1042 |
qmicli_read_non_empty_string (split[1], "current PIN", ¤t_pin)) { |
| 1043 |
GError *error = NULL; |
| 1044 |
|
| 1045 |
input = qmi_message_dms_uim_verify_pin_input_new (); |
| 1046 |
if (!qmi_message_dms_uim_verify_pin_input_set_info ( |
| 1047 |
input, |
| 1048 |
pin_id, |
| 1049 |
current_pin, |
| 1050 |
&error)) { |
| 1051 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 1052 |
error->message); |
| 1053 |
g_error_free (error); |
| 1054 |
qmi_message_dms_uim_verify_pin_input_unref (input); |
| 1055 |
input = NULL; |
| 1056 |
} |
| 1057 |
} |
| 1058 |
|
| 1059 |
return input; |
| 1060 |
} |
| 1061 |
|
| 1062 |
static void |
| 1063 |
uim_verify_pin_ready (QmiClientDms *client, |
| 1064 |
GAsyncResult *res) |
| 1065 |
{ |
| 1066 |
QmiMessageDmsUimVerifyPinOutput *output; |
| 1067 |
GError *error = NULL; |
| 1068 |
|
| 1069 |
output = qmi_client_dms_uim_verify_pin_finish (client, res, &error); |
| 1070 |
if (!output) { |
| 1071 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1072 |
g_error_free (error); |
| 1073 |
operation_shutdown (FALSE); |
| 1074 |
return; |
| 1075 |
} |
| 1076 |
|
| 1077 |
if (!qmi_message_dms_uim_verify_pin_output_get_result (output, &error)) { |
| 1078 |
guint8 verify_retries_left; |
| 1079 |
guint8 unblock_retries_left; |
| 1080 |
|
| 1081 |
g_printerr ("error: couldn't verify PIN: %s\n", error->message); |
| 1082 |
g_error_free (error); |
| 1083 |
|
| 1084 |
if (qmi_message_dms_uim_verify_pin_output_get_pin_retries_status ( |
| 1085 |
output, |
| 1086 |
&verify_retries_left, |
| 1087 |
&unblock_retries_left, |
| 1088 |
NULL)) { |
| 1089 |
g_printerr ("[%s] Retries left:\n" |
| 1090 |
"\tVerify: %u\n" |
| 1091 |
"\tUnblock: %u\n", |
| 1092 |
qmi_device_get_path_display (ctx->device), |
| 1093 |
verify_retries_left, |
| 1094 |
unblock_retries_left); |
| 1095 |
} |
| 1096 |
|
| 1097 |
qmi_message_dms_uim_verify_pin_output_unref (output); |
| 1098 |
operation_shutdown (FALSE); |
| 1099 |
return; |
| 1100 |
} |
| 1101 |
|
| 1102 |
g_print ("[%s] PIN verified successfully\n", |
| 1103 |
qmi_device_get_path_display (ctx->device)); |
| 1104 |
|
| 1105 |
qmi_message_dms_uim_verify_pin_output_unref (output); |
| 1106 |
operation_shutdown (TRUE); |
| 1107 |
} |
| 1108 |
|
| 1109 |
#endif /* HAVE_QMI_MESSAGE_DMS_UIM_VERIFY_PIN */ |
| 1110 |
|
| 1111 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_UNBLOCK_PIN |
| 1112 |
|
| 1113 |
static QmiMessageDmsUimUnblockPinInput * |
| 1114 |
uim_unblock_pin_input_create (const gchar *str) |
| 1115 |
{ |
| 1116 |
QmiMessageDmsUimUnblockPinInput *input = NULL; |
| 1117 |
g_auto(GStrv) split = NULL; |
| 1118 |
QmiDmsUimPinId pin_id; |
| 1119 |
gchar *puk; |
| 1120 |
gchar *new_pin; |
| 1121 |
|
| 1122 |
/* Prepare inputs. |
| 1123 |
* Format of the string is: |
| 1124 |
* "[(PIN|PIN2),(PUK),(new PIN)]" |
| 1125 |
*/ |
| 1126 |
split = g_strsplit (str, ",", -1); |
| 1127 |
if (qmicli_read_dms_uim_pin_id_from_string (split[0], &pin_id) && |
| 1128 |
qmicli_read_non_empty_string (split[1], "PUK", &puk) && |
| 1129 |
qmicli_read_non_empty_string (split[2], "new PIN", &new_pin)) { |
| 1130 |
GError *error = NULL; |
| 1131 |
|
| 1132 |
input = qmi_message_dms_uim_unblock_pin_input_new (); |
| 1133 |
if (!qmi_message_dms_uim_unblock_pin_input_set_info ( |
| 1134 |
input, |
| 1135 |
pin_id, |
| 1136 |
puk, |
| 1137 |
new_pin, |
| 1138 |
&error)) { |
| 1139 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 1140 |
error->message); |
| 1141 |
g_error_free (error); |
| 1142 |
qmi_message_dms_uim_unblock_pin_input_unref (input); |
| 1143 |
input = NULL; |
| 1144 |
} |
| 1145 |
} |
| 1146 |
|
| 1147 |
return input; |
| 1148 |
} |
| 1149 |
|
| 1150 |
static void |
| 1151 |
uim_unblock_pin_ready (QmiClientDms *client, |
| 1152 |
GAsyncResult *res) |
| 1153 |
{ |
| 1154 |
QmiMessageDmsUimUnblockPinOutput *output; |
| 1155 |
GError *error = NULL; |
| 1156 |
|
| 1157 |
output = qmi_client_dms_uim_unblock_pin_finish (client, res, &error); |
| 1158 |
if (!output) { |
| 1159 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1160 |
g_error_free (error); |
| 1161 |
operation_shutdown (FALSE); |
| 1162 |
return; |
| 1163 |
} |
| 1164 |
|
| 1165 |
if (!qmi_message_dms_uim_unblock_pin_output_get_result (output, &error)) { |
| 1166 |
guint8 verify_retries_left; |
| 1167 |
guint8 unblock_retries_left; |
| 1168 |
|
| 1169 |
g_printerr ("error: couldn't unblock PIN: %s\n", error->message); |
| 1170 |
g_error_free (error); |
| 1171 |
|
| 1172 |
if (qmi_message_dms_uim_unblock_pin_output_get_pin_retries_status ( |
| 1173 |
output, |
| 1174 |
&verify_retries_left, |
| 1175 |
&unblock_retries_left, |
| 1176 |
NULL)) { |
| 1177 |
g_printerr ("[%s] Retries left:\n" |
| 1178 |
"\tVerify: %u\n" |
| 1179 |
"\tUnblock: %u\n", |
| 1180 |
qmi_device_get_path_display (ctx->device), |
| 1181 |
verify_retries_left, |
| 1182 |
unblock_retries_left); |
| 1183 |
} |
| 1184 |
|
| 1185 |
qmi_message_dms_uim_unblock_pin_output_unref (output); |
| 1186 |
operation_shutdown (FALSE); |
| 1187 |
return; |
| 1188 |
} |
| 1189 |
|
| 1190 |
g_print ("[%s] PIN unblocked successfully\n", |
| 1191 |
qmi_device_get_path_display (ctx->device)); |
| 1192 |
|
| 1193 |
qmi_message_dms_uim_unblock_pin_output_unref (output); |
| 1194 |
operation_shutdown (TRUE); |
| 1195 |
} |
| 1196 |
|
| 1197 |
#endif /* HAVE_QMI_MESSAGE_DMS_UIM_UNBLOCK_PIN */ |
| 1198 |
|
| 1199 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_CHANGE_PIN |
| 1200 |
|
| 1201 |
static QmiMessageDmsUimChangePinInput * |
| 1202 |
uim_change_pin_input_create (const gchar *str) |
| 1203 |
{ |
| 1204 |
QmiMessageDmsUimChangePinInput *input = NULL; |
| 1205 |
g_auto(GStrv) split = NULL; |
| 1206 |
QmiDmsUimPinId pin_id; |
| 1207 |
gchar *old_pin; |
| 1208 |
gchar *new_pin; |
| 1209 |
|
| 1210 |
/* Prepare inputs. |
| 1211 |
* Format of the string is: |
| 1212 |
* "[(PIN|PIN2),(old PIN),(new PIN)]" |
| 1213 |
*/ |
| 1214 |
split = g_strsplit (str, ",", -1); |
| 1215 |
if (qmicli_read_dms_uim_pin_id_from_string (split[0], &pin_id) && |
| 1216 |
qmicli_read_non_empty_string (split[1], "old PIN", &old_pin) && |
| 1217 |
qmicli_read_non_empty_string (split[2], "new PIN", &new_pin)) { |
| 1218 |
GError *error = NULL; |
| 1219 |
|
| 1220 |
input = qmi_message_dms_uim_change_pin_input_new (); |
| 1221 |
if (!qmi_message_dms_uim_change_pin_input_set_info ( |
| 1222 |
input, |
| 1223 |
pin_id, |
| 1224 |
old_pin, |
| 1225 |
new_pin, |
| 1226 |
&error)) { |
| 1227 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 1228 |
error->message); |
| 1229 |
g_error_free (error); |
| 1230 |
qmi_message_dms_uim_change_pin_input_unref (input); |
| 1231 |
input = NULL; |
| 1232 |
} |
| 1233 |
} |
| 1234 |
|
| 1235 |
return input; |
| 1236 |
} |
| 1237 |
|
| 1238 |
static void |
| 1239 |
uim_change_pin_ready (QmiClientDms *client, |
| 1240 |
GAsyncResult *res) |
| 1241 |
{ |
| 1242 |
QmiMessageDmsUimChangePinOutput *output; |
| 1243 |
GError *error = NULL; |
| 1244 |
|
| 1245 |
output = qmi_client_dms_uim_change_pin_finish (client, res, &error); |
| 1246 |
if (!output) { |
| 1247 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1248 |
g_error_free (error); |
| 1249 |
operation_shutdown (FALSE); |
| 1250 |
return; |
| 1251 |
} |
| 1252 |
|
| 1253 |
if (!qmi_message_dms_uim_change_pin_output_get_result (output, &error)) { |
| 1254 |
guint8 verify_retries_left; |
| 1255 |
guint8 unblock_retries_left; |
| 1256 |
|
| 1257 |
g_printerr ("error: couldn't change PIN: %s\n", error->message); |
| 1258 |
g_error_free (error); |
| 1259 |
|
| 1260 |
if (qmi_message_dms_uim_change_pin_output_get_pin_retries_status ( |
| 1261 |
output, |
| 1262 |
&verify_retries_left, |
| 1263 |
&unblock_retries_left, |
| 1264 |
NULL)) { |
| 1265 |
g_printerr ("[%s] Retries left:\n" |
| 1266 |
"\tVerify: %u\n" |
| 1267 |
"\tUnblock: %u\n", |
| 1268 |
qmi_device_get_path_display (ctx->device), |
| 1269 |
verify_retries_left, |
| 1270 |
unblock_retries_left); |
| 1271 |
} |
| 1272 |
|
| 1273 |
qmi_message_dms_uim_change_pin_output_unref (output); |
| 1274 |
operation_shutdown (FALSE); |
| 1275 |
return; |
| 1276 |
} |
| 1277 |
|
| 1278 |
g_print ("[%s] PIN changed successfully\n", |
| 1279 |
qmi_device_get_path_display (ctx->device)); |
| 1280 |
|
| 1281 |
qmi_message_dms_uim_change_pin_output_unref (output); |
| 1282 |
operation_shutdown (TRUE); |
| 1283 |
} |
| 1284 |
|
| 1285 |
#endif /* HAVE_QMI_MESSAGE_DMS_UIM_CHANGE_PIN */ |
| 1286 |
|
| 1287 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_PIN_STATUS |
| 1288 |
|
| 1289 |
static void |
| 1290 |
uim_get_pin_status_ready (QmiClientDms *client, |
| 1291 |
GAsyncResult *res) |
| 1292 |
{ |
| 1293 |
guint8 verify_retries_left; |
| 1294 |
guint8 unblock_retries_left; |
| 1295 |
QmiDmsUimPinStatus current_status; |
| 1296 |
QmiMessageDmsUimGetPinStatusOutput *output; |
| 1297 |
GError *error = NULL; |
| 1298 |
|
| 1299 |
output = qmi_client_dms_uim_get_pin_status_finish (client, res, &error); |
| 1300 |
if (!output) { |
| 1301 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1302 |
g_error_free (error); |
| 1303 |
operation_shutdown (FALSE); |
| 1304 |
return; |
| 1305 |
} |
| 1306 |
|
| 1307 |
if (!qmi_message_dms_uim_get_pin_status_output_get_result (output, &error)) { |
| 1308 |
g_printerr ("error: couldn't get PIN status: %s\n", error->message); |
| 1309 |
g_error_free (error); |
| 1310 |
qmi_message_dms_uim_get_pin_status_output_unref (output); |
| 1311 |
operation_shutdown (FALSE); |
| 1312 |
return; |
| 1313 |
} |
| 1314 |
|
| 1315 |
g_print ("[%s] PIN status retrieved successfully\n", |
| 1316 |
qmi_device_get_path_display (ctx->device)); |
| 1317 |
|
| 1318 |
if (qmi_message_dms_uim_get_pin_status_output_get_pin1_status ( |
| 1319 |
output, |
| 1320 |
¤t_status, |
| 1321 |
&verify_retries_left, |
| 1322 |
&unblock_retries_left, |
| 1323 |
NULL)) { |
| 1324 |
g_print ("[%s] PIN1:\n" |
| 1325 |
"\tStatus: %s\n" |
| 1326 |
"\tVerify: %u\n" |
| 1327 |
"\tUnblock: %u\n", |
| 1328 |
qmi_device_get_path_display (ctx->device), |
| 1329 |
qmi_dms_uim_pin_status_get_string (current_status), |
| 1330 |
verify_retries_left, |
| 1331 |
unblock_retries_left); |
| 1332 |
} |
| 1333 |
|
| 1334 |
if (qmi_message_dms_uim_get_pin_status_output_get_pin2_status ( |
| 1335 |
output, |
| 1336 |
¤t_status, |
| 1337 |
&verify_retries_left, |
| 1338 |
&unblock_retries_left, |
| 1339 |
NULL)) { |
| 1340 |
g_print ("[%s] PIN2:\n" |
| 1341 |
"\tStatus: %s\n" |
| 1342 |
"\tVerify: %u\n" |
| 1343 |
"\tUnblock: %u\n", |
| 1344 |
qmi_device_get_path_display (ctx->device), |
| 1345 |
qmi_dms_uim_pin_status_get_string (current_status), |
| 1346 |
verify_retries_left, |
| 1347 |
unblock_retries_left); |
| 1348 |
} |
| 1349 |
|
| 1350 |
qmi_message_dms_uim_get_pin_status_output_unref (output); |
| 1351 |
operation_shutdown (TRUE); |
| 1352 |
} |
| 1353 |
|
| 1354 |
#endif /* HAVE_QMI_MESSAGE_DMS_UIM_GET_PIN_STATUS */ |
| 1355 |
|
| 1356 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_ICCID |
| 1357 |
|
| 1358 |
static void |
| 1359 |
uim_get_iccid_ready (QmiClientDms *client, |
| 1360 |
GAsyncResult *res) |
| 1361 |
{ |
| 1362 |
const gchar *str = NULL; |
| 1363 |
QmiMessageDmsUimGetIccidOutput *output; |
| 1364 |
GError *error = NULL; |
| 1365 |
|
| 1366 |
output = qmi_client_dms_uim_get_iccid_finish (client, res, &error); |
| 1367 |
if (!output) { |
| 1368 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1369 |
g_error_free (error); |
| 1370 |
operation_shutdown (FALSE); |
| 1371 |
return; |
| 1372 |
} |
| 1373 |
|
| 1374 |
if (!qmi_message_dms_uim_get_iccid_output_get_result (output, &error)) { |
| 1375 |
g_printerr ("error: couldn't get ICCID: %s\n", error->message); |
| 1376 |
g_error_free (error); |
| 1377 |
qmi_message_dms_uim_get_iccid_output_unref (output); |
| 1378 |
operation_shutdown (FALSE); |
| 1379 |
return; |
| 1380 |
} |
| 1381 |
|
| 1382 |
qmi_message_dms_uim_get_iccid_output_get_iccid (output, &str, NULL); |
| 1383 |
|
| 1384 |
g_print ("[%s] UIM ICCID retrieved:\n" |
| 1385 |
"\tICCID: '%s'\n", |
| 1386 |
qmi_device_get_path_display (ctx->device), |
| 1387 |
VALIDATE_UNKNOWN (str)); |
| 1388 |
|
| 1389 |
qmi_message_dms_uim_get_iccid_output_unref (output); |
| 1390 |
operation_shutdown (TRUE); |
| 1391 |
} |
| 1392 |
|
| 1393 |
#endif /* HAVE_QMI_MESSAGE_DMS_UIM_GET_ICCID */ |
| 1394 |
|
| 1395 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_IMSI |
| 1396 |
|
| 1397 |
static void |
| 1398 |
uim_get_imsi_ready (QmiClientDms *client, |
| 1399 |
GAsyncResult *res) |
| 1400 |
{ |
| 1401 |
const gchar *str = NULL; |
| 1402 |
QmiMessageDmsUimGetImsiOutput *output; |
| 1403 |
GError *error = NULL; |
| 1404 |
|
| 1405 |
output = qmi_client_dms_uim_get_imsi_finish (client, res, &error); |
| 1406 |
if (!output) { |
| 1407 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1408 |
g_error_free (error); |
| 1409 |
operation_shutdown (FALSE); |
| 1410 |
return; |
| 1411 |
} |
| 1412 |
|
| 1413 |
if (!qmi_message_dms_uim_get_imsi_output_get_result (output, &error)) { |
| 1414 |
g_printerr ("error: couldn't get IMSI: %s\n", error->message); |
| 1415 |
g_error_free (error); |
| 1416 |
qmi_message_dms_uim_get_imsi_output_unref (output); |
| 1417 |
operation_shutdown (FALSE); |
| 1418 |
return; |
| 1419 |
} |
| 1420 |
|
| 1421 |
qmi_message_dms_uim_get_imsi_output_get_imsi (output, &str, NULL); |
| 1422 |
|
| 1423 |
g_print ("[%s] UIM IMSI retrieved:\n" |
| 1424 |
"\tIMSI: '%s'\n", |
| 1425 |
qmi_device_get_path_display (ctx->device), |
| 1426 |
VALIDATE_UNKNOWN (str)); |
| 1427 |
|
| 1428 |
qmi_message_dms_uim_get_imsi_output_unref (output); |
| 1429 |
operation_shutdown (TRUE); |
| 1430 |
} |
| 1431 |
|
| 1432 |
#endif /* HAVE_QMI_MESSAGE_DMS_UIM_GET_IMSI */ |
| 1433 |
|
| 1434 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_STATE |
| 1435 |
|
| 1436 |
static void |
| 1437 |
uim_get_state_ready (QmiClientDms *client, |
| 1438 |
GAsyncResult *res) |
| 1439 |
{ |
| 1440 |
QmiDmsUimState state; |
| 1441 |
QmiMessageDmsUimGetStateOutput *output; |
| 1442 |
GError *error = NULL; |
| 1443 |
|
| 1444 |
output = qmi_client_dms_uim_get_state_finish (client, res, &error); |
| 1445 |
if (!output) { |
| 1446 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1447 |
g_error_free (error); |
| 1448 |
operation_shutdown (FALSE); |
| 1449 |
return; |
| 1450 |
} |
| 1451 |
|
| 1452 |
if (!qmi_message_dms_uim_get_state_output_get_result (output, &error)) { |
| 1453 |
g_printerr ("error: couldn't get UIM state: %s\n", error->message); |
| 1454 |
g_error_free (error); |
| 1455 |
qmi_message_dms_uim_get_state_output_unref (output); |
| 1456 |
operation_shutdown (FALSE); |
| 1457 |
return; |
| 1458 |
} |
| 1459 |
|
| 1460 |
qmi_message_dms_uim_get_state_output_get_state (output, &state, NULL); |
| 1461 |
|
| 1462 |
g_print ("[%s] UIM state retrieved:\n" |
| 1463 |
"\tState: '%s'\n", |
| 1464 |
qmi_device_get_path_display (ctx->device), |
| 1465 |
qmi_dms_uim_state_get_string (state)); |
| 1466 |
|
| 1467 |
qmi_message_dms_uim_get_state_output_unref (output); |
| 1468 |
operation_shutdown (TRUE); |
| 1469 |
} |
| 1470 |
|
| 1471 |
#endif /* HAVE_QMI_MESSAGE_DMS_UIM_GET_STATE */ |
| 1472 |
|
| 1473 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_CK_STATUS |
| 1474 |
|
| 1475 |
static QmiMessageDmsUimGetCkStatusInput * |
| 1476 |
uim_get_ck_status_input_create (const gchar *str) |
| 1477 |
{ |
| 1478 |
QmiMessageDmsUimGetCkStatusInput *input = NULL; |
| 1479 |
QmiDmsUimFacility facility; |
| 1480 |
|
| 1481 |
if (qmicli_read_dms_uim_facility_from_string (str, &facility)) { |
| 1482 |
GError *error = NULL; |
| 1483 |
|
| 1484 |
input = qmi_message_dms_uim_get_ck_status_input_new (); |
| 1485 |
if (!qmi_message_dms_uim_get_ck_status_input_set_facility ( |
| 1486 |
input, |
| 1487 |
facility, |
| 1488 |
&error)) { |
| 1489 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 1490 |
error->message); |
| 1491 |
g_error_free (error); |
| 1492 |
qmi_message_dms_uim_get_ck_status_input_unref (input); |
| 1493 |
input = NULL; |
| 1494 |
} |
| 1495 |
} |
| 1496 |
|
| 1497 |
return input; |
| 1498 |
} |
| 1499 |
|
| 1500 |
static void |
| 1501 |
uim_get_ck_status_ready (QmiClientDms *client, |
| 1502 |
GAsyncResult *res) |
| 1503 |
{ |
| 1504 |
QmiMessageDmsUimGetCkStatusOutput *output; |
| 1505 |
GError *error = NULL; |
| 1506 |
QmiDmsUimFacilityState state; |
| 1507 |
guint8 verify_retries_left; |
| 1508 |
guint8 unblock_retries_left; |
| 1509 |
gboolean blocking; |
| 1510 |
|
| 1511 |
output = qmi_client_dms_uim_get_ck_status_finish (client, res, &error); |
| 1512 |
if (!output) { |
| 1513 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1514 |
g_error_free (error); |
| 1515 |
operation_shutdown (FALSE); |
| 1516 |
return; |
| 1517 |
} |
| 1518 |
|
| 1519 |
if (!qmi_message_dms_uim_get_ck_status_output_get_result (output, &error)) { |
| 1520 |
g_printerr ("error: couldn't get UIM CK status: %s\n", error->message); |
| 1521 |
g_error_free (error); |
| 1522 |
qmi_message_dms_uim_get_ck_status_output_unref (output); |
| 1523 |
operation_shutdown (FALSE); |
| 1524 |
return; |
| 1525 |
} |
| 1526 |
|
| 1527 |
qmi_message_dms_uim_get_ck_status_output_get_ck_status ( |
| 1528 |
output, |
| 1529 |
&state, |
| 1530 |
&verify_retries_left, |
| 1531 |
&unblock_retries_left, |
| 1532 |
NULL); |
| 1533 |
|
| 1534 |
g_print ("[%s] UIM facility state retrieved:\n" |
| 1535 |
"\tState: '%s'\n", |
| 1536 |
qmi_device_get_path_display (ctx->device), |
| 1537 |
qmi_dms_uim_facility_state_get_string (state)); |
| 1538 |
g_print ("[%s] Retries left:\n" |
| 1539 |
"\tVerify: %u\n" |
| 1540 |
"\tUnblock: %u\n", |
| 1541 |
qmi_device_get_path_display (ctx->device), |
| 1542 |
verify_retries_left, |
| 1543 |
unblock_retries_left); |
| 1544 |
|
| 1545 |
if (qmi_message_dms_uim_get_ck_status_output_get_operation_blocking_facility ( |
| 1546 |
output, |
| 1547 |
&blocking, |
| 1548 |
NULL) && |
| 1549 |
blocking) { |
| 1550 |
g_print ("[%s] Facility is blocking operation\n", |
| 1551 |
qmi_device_get_path_display (ctx->device)); |
| 1552 |
} |
| 1553 |
|
| 1554 |
qmi_message_dms_uim_get_ck_status_output_unref (output); |
| 1555 |
operation_shutdown (TRUE); |
| 1556 |
} |
| 1557 |
|
| 1558 |
#endif /* HAVE_QMI_MESSAGE_DMS_UIM_GET_CK_STATUS */ |
| 1559 |
|
| 1560 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_SET_CK_PROTECTION |
| 1561 |
|
| 1562 |
static QmiMessageDmsUimSetCkProtectionInput * |
| 1563 |
uim_set_ck_protection_input_create (const gchar *str) |
| 1564 |
{ |
| 1565 |
QmiMessageDmsUimSetCkProtectionInput *input = NULL; |
| 1566 |
g_auto(GStrv) split = NULL; |
| 1567 |
QmiDmsUimFacility facility; |
| 1568 |
gboolean enable_disable; |
| 1569 |
gchar *key; |
| 1570 |
|
| 1571 |
/* Prepare inputs. |
| 1572 |
* Format of the string is: |
| 1573 |
* "[(facility),disable,(key)]" |
| 1574 |
*/ |
| 1575 |
split = g_strsplit (str, ",", -1); |
| 1576 |
if (qmicli_read_dms_uim_facility_from_string (split[0], &facility) && |
| 1577 |
qmicli_read_enable_disable_from_string (split[1], &enable_disable) && |
| 1578 |
qmicli_read_non_empty_string (split[2], "control key", &key)) { |
| 1579 |
|
| 1580 |
/* We should only allow 'disable' here */ |
| 1581 |
if (enable_disable) { |
| 1582 |
g_printerr ("error: only 'disable' action is allowed\n"); |
| 1583 |
} else { |
| 1584 |
GError *error = NULL; |
| 1585 |
|
| 1586 |
input = qmi_message_dms_uim_set_ck_protection_input_new (); |
| 1587 |
if (!qmi_message_dms_uim_set_ck_protection_input_set_facility ( |
| 1588 |
input, |
| 1589 |
facility, |
| 1590 |
(QmiDmsUimFacilityState)enable_disable, /* 0 == DISABLE */ |
| 1591 |
key, |
| 1592 |
&error)) { |
| 1593 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 1594 |
error->message); |
| 1595 |
g_error_free (error); |
| 1596 |
qmi_message_dms_uim_set_ck_protection_input_unref (input); |
| 1597 |
input = NULL; |
| 1598 |
} |
| 1599 |
} |
| 1600 |
} |
| 1601 |
|
| 1602 |
return input; |
| 1603 |
} |
| 1604 |
|
| 1605 |
static void |
| 1606 |
uim_set_ck_protection_ready (QmiClientDms *client, |
| 1607 |
GAsyncResult *res) |
| 1608 |
{ |
| 1609 |
QmiMessageDmsUimSetCkProtectionOutput *output; |
| 1610 |
GError *error = NULL; |
| 1611 |
|
| 1612 |
output = qmi_client_dms_uim_set_ck_protection_finish (client, res, &error); |
| 1613 |
if (!output) { |
| 1614 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1615 |
g_error_free (error); |
| 1616 |
operation_shutdown (FALSE); |
| 1617 |
return; |
| 1618 |
} |
| 1619 |
|
| 1620 |
if (!qmi_message_dms_uim_set_ck_protection_output_get_result (output, &error)) { |
| 1621 |
guint8 verify_retries_left; |
| 1622 |
|
| 1623 |
g_printerr ("error: couldn't set UIM CK protection: %s\n", error->message); |
| 1624 |
g_error_free (error); |
| 1625 |
|
| 1626 |
if (qmi_message_dms_uim_set_ck_protection_output_get_verify_retries_left ( |
| 1627 |
output, |
| 1628 |
&verify_retries_left, |
| 1629 |
NULL)) { |
| 1630 |
g_printerr ("[%s] Retries left:\n" |
| 1631 |
"\tVerify: %u\n", |
| 1632 |
qmi_device_get_path_display (ctx->device), |
| 1633 |
verify_retries_left); |
| 1634 |
} |
| 1635 |
|
| 1636 |
qmi_message_dms_uim_set_ck_protection_output_unref (output); |
| 1637 |
operation_shutdown (FALSE); |
| 1638 |
return; |
| 1639 |
} |
| 1640 |
|
| 1641 |
g_print ("[%s] UIM CK protection set\n", |
| 1642 |
qmi_device_get_path_display (ctx->device)); |
| 1643 |
|
| 1644 |
qmi_message_dms_uim_set_ck_protection_output_unref (output); |
| 1645 |
operation_shutdown (TRUE); |
| 1646 |
} |
| 1647 |
|
| 1648 |
#endif /* HAVE_QMI_MESSAGE_DMS_UIM_SET_CK_PROTECTION */ |
| 1649 |
|
| 1650 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_UNBLOCK_CK |
| 1651 |
|
| 1652 |
static QmiMessageDmsUimUnblockCkInput * |
| 1653 |
uim_unblock_ck_input_create (const gchar *str) |
| 1654 |
{ |
| 1655 |
QmiMessageDmsUimUnblockCkInput *input = NULL; |
| 1656 |
g_auto(GStrv) split = NULL; |
| 1657 |
QmiDmsUimFacility facility; |
| 1658 |
gchar *key; |
| 1659 |
|
| 1660 |
/* Prepare inputs. |
| 1661 |
* Format of the string is: |
| 1662 |
* "[(facility),(key)]" |
| 1663 |
*/ |
| 1664 |
split = g_strsplit (str, ",", -1); |
| 1665 |
if (qmicli_read_dms_uim_facility_from_string (split[0], &facility) && |
| 1666 |
qmicli_read_non_empty_string (split[1], "control key", &key)) { |
| 1667 |
GError *error = NULL; |
| 1668 |
|
| 1669 |
input = qmi_message_dms_uim_unblock_ck_input_new (); |
| 1670 |
if (!qmi_message_dms_uim_unblock_ck_input_set_facility ( |
| 1671 |
input, |
| 1672 |
facility, |
| 1673 |
key, |
| 1674 |
&error)) { |
| 1675 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 1676 |
error->message); |
| 1677 |
g_error_free (error); |
| 1678 |
qmi_message_dms_uim_unblock_ck_input_unref (input); |
| 1679 |
input = NULL; |
| 1680 |
} |
| 1681 |
} |
| 1682 |
|
| 1683 |
return input; |
| 1684 |
} |
| 1685 |
|
| 1686 |
static void |
| 1687 |
uim_unblock_ck_ready (QmiClientDms *client, |
| 1688 |
GAsyncResult *res) |
| 1689 |
{ |
| 1690 |
QmiMessageDmsUimUnblockCkOutput *output; |
| 1691 |
GError *error = NULL; |
| 1692 |
|
| 1693 |
output = qmi_client_dms_uim_unblock_ck_finish (client, res, &error); |
| 1694 |
if (!output) { |
| 1695 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1696 |
g_error_free (error); |
| 1697 |
operation_shutdown (FALSE); |
| 1698 |
return; |
| 1699 |
} |
| 1700 |
|
| 1701 |
if (!qmi_message_dms_uim_unblock_ck_output_get_result (output, &error)) { |
| 1702 |
guint8 unblock_retries_left; |
| 1703 |
|
| 1704 |
g_printerr ("error: couldn't unblock CK: %s\n", error->message); |
| 1705 |
g_error_free (error); |
| 1706 |
|
| 1707 |
if (qmi_message_dms_uim_unblock_ck_output_get_unblock_retries_left ( |
| 1708 |
output, |
| 1709 |
&unblock_retries_left, |
| 1710 |
NULL)) { |
| 1711 |
g_printerr ("[%s] Retries left:\n" |
| 1712 |
"\tUnblock: %u\n", |
| 1713 |
qmi_device_get_path_display (ctx->device), |
| 1714 |
unblock_retries_left); |
| 1715 |
} |
| 1716 |
|
| 1717 |
qmi_message_dms_uim_unblock_ck_output_unref (output); |
| 1718 |
operation_shutdown (FALSE); |
| 1719 |
return; |
| 1720 |
} |
| 1721 |
|
| 1722 |
g_print ("[%s] UIM CK unblocked\n", |
| 1723 |
qmi_device_get_path_display (ctx->device)); |
| 1724 |
|
| 1725 |
qmi_message_dms_uim_unblock_ck_output_unref (output); |
| 1726 |
operation_shutdown (TRUE); |
| 1727 |
} |
| 1728 |
|
| 1729 |
#endif /* HAVE_QMI_MESSAGE_DMS_UIM_UNBLOCK_CK */ |
| 1730 |
|
| 1731 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_HARDWARE_REVISION |
| 1732 |
|
| 1733 |
static void |
| 1734 |
get_hardware_revision_ready (QmiClientDms *client, |
| 1735 |
GAsyncResult *res) |
| 1736 |
{ |
| 1737 |
const gchar *str = NULL; |
| 1738 |
QmiMessageDmsGetHardwareRevisionOutput *output; |
| 1739 |
GError *error = NULL; |
| 1740 |
|
| 1741 |
output = qmi_client_dms_get_hardware_revision_finish (client, res, &error); |
| 1742 |
if (!output) { |
| 1743 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1744 |
g_error_free (error); |
| 1745 |
operation_shutdown (FALSE); |
| 1746 |
return; |
| 1747 |
} |
| 1748 |
|
| 1749 |
if (!qmi_message_dms_get_hardware_revision_output_get_result (output, &error)) { |
| 1750 |
g_printerr ("error: couldn't get the HW revision: %s\n", error->message); |
| 1751 |
g_error_free (error); |
| 1752 |
qmi_message_dms_get_hardware_revision_output_unref (output); |
| 1753 |
operation_shutdown (FALSE); |
| 1754 |
return; |
| 1755 |
} |
| 1756 |
|
| 1757 |
qmi_message_dms_get_hardware_revision_output_get_revision (output, &str, NULL); |
| 1758 |
|
| 1759 |
g_print ("[%s] Hardware revision retrieved:\n" |
| 1760 |
"\tRevision: '%s'\n", |
| 1761 |
qmi_device_get_path_display (ctx->device), |
| 1762 |
VALIDATE_UNKNOWN (str)); |
| 1763 |
|
| 1764 |
qmi_message_dms_get_hardware_revision_output_unref (output); |
| 1765 |
operation_shutdown (TRUE); |
| 1766 |
} |
| 1767 |
|
| 1768 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_HARDWARE_REVISION */ |
| 1769 |
|
| 1770 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_OPERATING_MODE |
| 1771 |
|
| 1772 |
static void |
| 1773 |
get_operating_mode_ready (QmiClientDms *client, |
| 1774 |
GAsyncResult *res) |
| 1775 |
{ |
| 1776 |
QmiMessageDmsGetOperatingModeOutput *output; |
| 1777 |
QmiDmsOperatingMode mode; |
| 1778 |
gboolean hw_restricted = FALSE; |
| 1779 |
GError *error = NULL; |
| 1780 |
|
| 1781 |
output = qmi_client_dms_get_operating_mode_finish (client, res, &error); |
| 1782 |
if (!output) { |
| 1783 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1784 |
g_error_free (error); |
| 1785 |
operation_shutdown (FALSE); |
| 1786 |
return; |
| 1787 |
} |
| 1788 |
|
| 1789 |
if (!qmi_message_dms_get_operating_mode_output_get_result (output, &error)) { |
| 1790 |
g_printerr ("error: couldn't get the HW revision: %s\n", error->message); |
| 1791 |
g_error_free (error); |
| 1792 |
qmi_message_dms_get_operating_mode_output_unref (output); |
| 1793 |
operation_shutdown (FALSE); |
| 1794 |
return; |
| 1795 |
} |
| 1796 |
|
| 1797 |
qmi_message_dms_get_operating_mode_output_get_mode (output, &mode, NULL); |
| 1798 |
|
| 1799 |
g_print ("[%s] Operating mode retrieved:\n" |
| 1800 |
"\tMode: '%s'\n", |
| 1801 |
qmi_device_get_path_display (ctx->device), |
| 1802 |
qmi_dms_operating_mode_get_string (mode)); |
| 1803 |
|
| 1804 |
if (mode == QMI_DMS_OPERATING_MODE_OFFLINE || mode == QMI_DMS_OPERATING_MODE_LOW_POWER) { |
| 1805 |
QmiDmsOfflineReason reason; |
| 1806 |
|
| 1807 |
if (qmi_message_dms_get_operating_mode_output_get_offline_reason (output, &reason, NULL)) { |
| 1808 |
g_autofree gchar *reason_str = NULL; |
| 1809 |
|
| 1810 |
reason_str = qmi_dms_offline_reason_build_string_from_mask (reason); |
| 1811 |
g_print ("\tReason: '%s'\n", VALIDATE_MASK_NONE (reason_str)); |
| 1812 |
} |
| 1813 |
} |
| 1814 |
|
| 1815 |
qmi_message_dms_get_operating_mode_output_get_hardware_restricted_mode (output, &hw_restricted, NULL); |
| 1816 |
g_print ("\tHW restricted: '%s'\n", hw_restricted ? "yes" : "no"); |
| 1817 |
|
| 1818 |
qmi_message_dms_get_operating_mode_output_unref (output); |
| 1819 |
operation_shutdown (TRUE); |
| 1820 |
} |
| 1821 |
|
| 1822 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_OPERATING_MODE */ |
| 1823 |
|
| 1824 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_OPERATING_MODE |
| 1825 |
|
| 1826 |
static QmiMessageDmsSetOperatingModeInput * |
| 1827 |
set_operating_mode_input_create (const gchar *str) |
| 1828 |
{ |
| 1829 |
QmiMessageDmsSetOperatingModeInput *input = NULL; |
| 1830 |
QmiDmsOperatingMode mode; |
| 1831 |
|
| 1832 |
if (qmicli_read_dms_operating_mode_from_string (str, &mode)) { |
| 1833 |
GError *error = NULL; |
| 1834 |
|
| 1835 |
input = qmi_message_dms_set_operating_mode_input_new (); |
| 1836 |
if (!qmi_message_dms_set_operating_mode_input_set_mode ( |
| 1837 |
input, |
| 1838 |
mode, |
| 1839 |
&error)) { |
| 1840 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 1841 |
error->message); |
| 1842 |
g_error_free (error); |
| 1843 |
qmi_message_dms_set_operating_mode_input_unref (input); |
| 1844 |
input = NULL; |
| 1845 |
} |
| 1846 |
} |
| 1847 |
|
| 1848 |
return input; |
| 1849 |
} |
| 1850 |
|
| 1851 |
static void |
| 1852 |
set_operating_mode_ready (QmiClientDms *client, |
| 1853 |
GAsyncResult *res) |
| 1854 |
{ |
| 1855 |
QmiMessageDmsSetOperatingModeOutput *output; |
| 1856 |
GError *error = NULL; |
| 1857 |
|
| 1858 |
output = qmi_client_dms_set_operating_mode_finish (client, res, &error); |
| 1859 |
if (!output) { |
| 1860 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1861 |
g_error_free (error); |
| 1862 |
operation_shutdown (FALSE); |
| 1863 |
return; |
| 1864 |
} |
| 1865 |
|
| 1866 |
if (!qmi_message_dms_set_operating_mode_output_get_result (output, &error)) { |
| 1867 |
g_printerr ("error: couldn't set operating mode: %s\n", error->message); |
| 1868 |
g_error_free (error); |
| 1869 |
qmi_message_dms_set_operating_mode_output_unref (output); |
| 1870 |
operation_shutdown (FALSE); |
| 1871 |
return; |
| 1872 |
} |
| 1873 |
|
| 1874 |
g_print ("[%s] Operating mode set successfully\n", |
| 1875 |
qmi_device_get_path_display (ctx->device)); |
| 1876 |
|
| 1877 |
qmi_message_dms_set_operating_mode_output_unref (output); |
| 1878 |
operation_shutdown (TRUE); |
| 1879 |
} |
| 1880 |
|
| 1881 |
#endif /* HAVE_QMI_MESSAGE_DMS_SET_OPERATING_MODE */ |
| 1882 |
|
| 1883 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_TIME |
| 1884 |
|
| 1885 |
static void |
| 1886 |
get_time_ready (QmiClientDms *client, |
| 1887 |
GAsyncResult *res) |
| 1888 |
{ |
| 1889 |
QmiMessageDmsGetTimeOutput *output; |
| 1890 |
guint64 time_count; |
| 1891 |
QmiDmsTimeSource time_source; |
| 1892 |
GError *error = NULL; |
| 1893 |
gchar *str; |
| 1894 |
GTimeZone *time_zone; |
| 1895 |
GDateTime *gpstime_epoch; |
| 1896 |
GDateTime *computed_epoch; |
| 1897 |
|
| 1898 |
output = qmi_client_dms_get_time_finish (client, res, &error); |
| 1899 |
if (!output) { |
| 1900 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1901 |
g_error_free (error); |
| 1902 |
operation_shutdown (FALSE); |
| 1903 |
return; |
| 1904 |
} |
| 1905 |
|
| 1906 |
if (!qmi_message_dms_get_time_output_get_result (output, &error)) { |
| 1907 |
g_printerr ("error: couldn't get the device time: %s\n", error->message); |
| 1908 |
g_error_free (error); |
| 1909 |
qmi_message_dms_get_time_output_unref (output); |
| 1910 |
operation_shutdown (FALSE); |
| 1911 |
return; |
| 1912 |
} |
| 1913 |
|
| 1914 |
qmi_message_dms_get_time_output_get_device_time ( |
| 1915 |
output, |
| 1916 |
&time_count, |
| 1917 |
&time_source, |
| 1918 |
NULL); |
| 1919 |
|
| 1920 |
/* January 6th 1980 */ |
| 1921 |
time_zone = g_time_zone_new_utc (); |
| 1922 |
gpstime_epoch = g_date_time_new (time_zone, 1980, 1, 6, 0, 0, 0.0); |
| 1923 |
|
| 1924 |
computed_epoch = g_date_time_add_seconds (gpstime_epoch, ((gdouble) time_count / 1000.0)); |
| 1925 |
str = g_date_time_format (computed_epoch, "%F %T"); |
| 1926 |
g_print ("[%s] Time retrieved:\n" |
| 1927 |
"\tTime count: '%" G_GUINT64_FORMAT " (x 1.25ms): %s'\n" |
| 1928 |
"\tTime source: '%s'\n", |
| 1929 |
qmi_device_get_path_display (ctx->device), |
| 1930 |
time_count, str, |
| 1931 |
qmi_dms_time_source_get_string (time_source)); |
| 1932 |
g_free (str); |
| 1933 |
g_date_time_unref (computed_epoch); |
| 1934 |
|
| 1935 |
if (qmi_message_dms_get_time_output_get_system_time ( |
| 1936 |
output, |
| 1937 |
&time_count, |
| 1938 |
NULL)){ |
| 1939 |
computed_epoch = g_date_time_add_seconds (gpstime_epoch, ((gdouble) time_count / 1000.0)); |
| 1940 |
str = g_date_time_format (computed_epoch, "%F %T"); |
| 1941 |
g_print ("\tSystem time: '%" G_GUINT64_FORMAT " (ms): %s'\n", |
| 1942 |
time_count, str); |
| 1943 |
g_free (str); |
| 1944 |
g_date_time_unref (computed_epoch); |
| 1945 |
} |
| 1946 |
|
| 1947 |
if (qmi_message_dms_get_time_output_get_user_time ( |
| 1948 |
output, |
| 1949 |
&time_count, |
| 1950 |
NULL)){ |
| 1951 |
computed_epoch = g_date_time_add_seconds (gpstime_epoch, ((gdouble) time_count / 1000.0)); |
| 1952 |
str = g_date_time_format (computed_epoch, "%F %T"); |
| 1953 |
g_print ("\tUser time: '%" G_GUINT64_FORMAT " (ms): %s'\n", |
| 1954 |
time_count, str); |
| 1955 |
g_free (str); |
| 1956 |
g_date_time_unref (computed_epoch); |
| 1957 |
} |
| 1958 |
|
| 1959 |
g_date_time_unref (gpstime_epoch); |
| 1960 |
g_time_zone_unref (time_zone); |
| 1961 |
|
| 1962 |
qmi_message_dms_get_time_output_unref (output); |
| 1963 |
operation_shutdown (TRUE); |
| 1964 |
} |
| 1965 |
|
| 1966 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_TIME */ |
| 1967 |
|
| 1968 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_PRL_VERSION |
| 1969 |
|
| 1970 |
static void |
| 1971 |
get_prl_version_ready (QmiClientDms *client, |
| 1972 |
GAsyncResult *res) |
| 1973 |
{ |
| 1974 |
QmiMessageDmsGetPrlVersionOutput *output; |
| 1975 |
guint16 prl_version; |
| 1976 |
gboolean prl_only; |
| 1977 |
GError *error = NULL; |
| 1978 |
|
| 1979 |
output = qmi_client_dms_get_prl_version_finish (client, res, &error); |
| 1980 |
if (!output) { |
| 1981 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 1982 |
g_error_free (error); |
| 1983 |
operation_shutdown (FALSE); |
| 1984 |
return; |
| 1985 |
} |
| 1986 |
|
| 1987 |
if (!qmi_message_dms_get_prl_version_output_get_result (output, &error)) { |
| 1988 |
g_printerr ("error: couldn't get the PRL version: %s\n", error->message); |
| 1989 |
g_error_free (error); |
| 1990 |
qmi_message_dms_get_prl_version_output_unref (output); |
| 1991 |
operation_shutdown (FALSE); |
| 1992 |
return; |
| 1993 |
} |
| 1994 |
|
| 1995 |
qmi_message_dms_get_prl_version_output_get_version ( |
| 1996 |
output, |
| 1997 |
&prl_version, |
| 1998 |
NULL); |
| 1999 |
|
| 2000 |
g_print ("[%s] PRL version retrieved:\n" |
| 2001 |
"\tPRL version: '%" G_GUINT16_FORMAT "'\n", |
| 2002 |
qmi_device_get_path_display (ctx->device), |
| 2003 |
prl_version); |
| 2004 |
|
| 2005 |
if (qmi_message_dms_get_prl_version_output_get_prl_only_preference ( |
| 2006 |
output, |
| 2007 |
&prl_only, |
| 2008 |
NULL)){ |
| 2009 |
g_print ("\tPRL only preference: '%s'\n", |
| 2010 |
prl_only ? "yes" : "no"); |
| 2011 |
} |
| 2012 |
|
| 2013 |
qmi_message_dms_get_prl_version_output_unref (output); |
| 2014 |
operation_shutdown (TRUE); |
| 2015 |
} |
| 2016 |
|
| 2017 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_PRL_VERSION */ |
| 2018 |
|
| 2019 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_ACTIVATION_STATE |
| 2020 |
|
| 2021 |
static void |
| 2022 |
get_activation_state_ready (QmiClientDms *client, |
| 2023 |
GAsyncResult *res) |
| 2024 |
{ |
| 2025 |
QmiMessageDmsGetActivationStateOutput *output; |
| 2026 |
QmiDmsActivationState activation_state; |
| 2027 |
GError *error = NULL; |
| 2028 |
|
| 2029 |
output = qmi_client_dms_get_activation_state_finish (client, res, &error); |
| 2030 |
if (!output) { |
| 2031 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2032 |
g_error_free (error); |
| 2033 |
operation_shutdown (FALSE); |
| 2034 |
return; |
| 2035 |
} |
| 2036 |
|
| 2037 |
if (!qmi_message_dms_get_activation_state_output_get_result (output, &error)) { |
| 2038 |
g_printerr ("error: couldn't get the state of the service activation: %s\n", error->message); |
| 2039 |
g_error_free (error); |
| 2040 |
qmi_message_dms_get_activation_state_output_unref (output); |
| 2041 |
operation_shutdown (FALSE); |
| 2042 |
return; |
| 2043 |
} |
| 2044 |
|
| 2045 |
qmi_message_dms_get_activation_state_output_get_info ( |
| 2046 |
output, |
| 2047 |
&activation_state, |
| 2048 |
NULL); |
| 2049 |
|
| 2050 |
g_print ("[%s] Activation state retrieved:\n" |
| 2051 |
"\tState: '%s'\n", |
| 2052 |
qmi_device_get_path_display (ctx->device), |
| 2053 |
qmi_dms_activation_state_get_string (activation_state)); |
| 2054 |
|
| 2055 |
qmi_message_dms_get_activation_state_output_unref (output); |
| 2056 |
operation_shutdown (TRUE); |
| 2057 |
} |
| 2058 |
|
| 2059 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_ACTIVATION_STATE */ |
| 2060 |
|
| 2061 |
#if defined HAVE_QMI_MESSAGE_DMS_ACTIVATE_MANUAL |
| 2062 |
|
| 2063 |
static QmiMessageDmsActivateManualInput * |
| 2064 |
activate_manual_input_create (const gchar *str) |
| 2065 |
{ |
| 2066 |
QmiMessageDmsActivateManualInput *input; |
| 2067 |
g_auto(GStrv) split = NULL; |
| 2068 |
GError *error = NULL; |
| 2069 |
gulong split_1_int; |
| 2070 |
|
| 2071 |
split = g_strsplit (str, ",", -1); |
| 2072 |
if (g_strv_length (split) != 4) { |
| 2073 |
g_printerr ("error: incorrect number of arguments given\n"); |
| 2074 |
return NULL; |
| 2075 |
} |
| 2076 |
|
| 2077 |
split_1_int = strtoul (split[1], NULL, 10); |
| 2078 |
if (split_1_int > G_MAXUINT16) { |
| 2079 |
g_printerr ("error: invalid SID given '%s'\n", |
| 2080 |
split[1]); |
| 2081 |
return NULL; |
| 2082 |
} |
| 2083 |
|
| 2084 |
input = qmi_message_dms_activate_manual_input_new (); |
| 2085 |
if (!qmi_message_dms_activate_manual_input_set_info ( |
| 2086 |
input, |
| 2087 |
split[0], |
| 2088 |
(guint16)split_1_int, |
| 2089 |
split[2], |
| 2090 |
split[3], |
| 2091 |
&error)) { |
| 2092 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 2093 |
error->message); |
| 2094 |
g_error_free (error); |
| 2095 |
qmi_message_dms_activate_manual_input_unref (input); |
| 2096 |
input = NULL; |
| 2097 |
} |
| 2098 |
|
| 2099 |
return input; |
| 2100 |
} |
| 2101 |
|
| 2102 |
static void |
| 2103 |
activate_manual_ready (QmiClientDms *client, |
| 2104 |
GAsyncResult *res) |
| 2105 |
{ |
| 2106 |
QmiMessageDmsActivateManualOutput *output; |
| 2107 |
GError *error = NULL; |
| 2108 |
|
| 2109 |
output = qmi_client_dms_activate_manual_finish (client, res, &error); |
| 2110 |
if (!output) { |
| 2111 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2112 |
g_error_free (error); |
| 2113 |
operation_shutdown (FALSE); |
| 2114 |
return; |
| 2115 |
} |
| 2116 |
|
| 2117 |
if (!qmi_message_dms_activate_manual_output_get_result (output, &error)) { |
| 2118 |
g_printerr ("error: couldn't request manual service activation: %s\n", error->message); |
| 2119 |
g_error_free (error); |
| 2120 |
qmi_message_dms_activate_manual_output_unref (output); |
| 2121 |
operation_shutdown (FALSE); |
| 2122 |
return; |
| 2123 |
} |
| 2124 |
|
| 2125 |
qmi_message_dms_activate_manual_output_unref (output); |
| 2126 |
operation_shutdown (TRUE); |
| 2127 |
} |
| 2128 |
|
| 2129 |
#endif /* HAVE_QMI_MESSAGE_DMS_ACTIVATE_MANUAL */ |
| 2130 |
|
| 2131 |
#if defined HAVE_QMI_MESSAGE_DMS_ACTIVATE_AUTOMATIC |
| 2132 |
|
| 2133 |
static QmiMessageDmsActivateAutomaticInput * |
| 2134 |
activate_automatic_input_create (const gchar *str) |
| 2135 |
{ |
| 2136 |
QmiMessageDmsActivateAutomaticInput *input; |
| 2137 |
GError *error = NULL; |
| 2138 |
|
| 2139 |
input = qmi_message_dms_activate_automatic_input_new (); |
| 2140 |
if (!qmi_message_dms_activate_automatic_input_set_activation_code ( |
| 2141 |
input, |
| 2142 |
str, |
| 2143 |
&error)) { |
| 2144 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 2145 |
error->message); |
| 2146 |
g_error_free (error); |
| 2147 |
qmi_message_dms_activate_automatic_input_unref (input); |
| 2148 |
input = NULL; |
| 2149 |
} |
| 2150 |
|
| 2151 |
return input; |
| 2152 |
} |
| 2153 |
|
| 2154 |
static void |
| 2155 |
activate_automatic_ready (QmiClientDms *client, |
| 2156 |
GAsyncResult *res) |
| 2157 |
{ |
| 2158 |
QmiMessageDmsActivateAutomaticOutput *output; |
| 2159 |
GError *error = NULL; |
| 2160 |
|
| 2161 |
output = qmi_client_dms_activate_automatic_finish (client, res, &error); |
| 2162 |
if (!output) { |
| 2163 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2164 |
g_error_free (error); |
| 2165 |
operation_shutdown (FALSE); |
| 2166 |
return; |
| 2167 |
} |
| 2168 |
|
| 2169 |
if (!qmi_message_dms_activate_automatic_output_get_result (output, &error)) { |
| 2170 |
g_printerr ("error: couldn't request automatic service activation: %s\n", error->message); |
| 2171 |
g_error_free (error); |
| 2172 |
qmi_message_dms_activate_automatic_output_unref (output); |
| 2173 |
operation_shutdown (FALSE); |
| 2174 |
return; |
| 2175 |
} |
| 2176 |
|
| 2177 |
qmi_message_dms_activate_automatic_output_unref (output); |
| 2178 |
operation_shutdown (TRUE); |
| 2179 |
} |
| 2180 |
|
| 2181 |
#endif |
| 2182 |
|
| 2183 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_USER_LOCK_STATE |
| 2184 |
|
| 2185 |
static void |
| 2186 |
get_user_lock_state_ready (QmiClientDms *client, |
| 2187 |
GAsyncResult *res) |
| 2188 |
{ |
| 2189 |
QmiMessageDmsGetUserLockStateOutput *output; |
| 2190 |
gboolean enabled; |
| 2191 |
GError *error = NULL; |
| 2192 |
|
| 2193 |
output = qmi_client_dms_get_user_lock_state_finish (client, res, &error); |
| 2194 |
if (!output) { |
| 2195 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2196 |
g_error_free (error); |
| 2197 |
operation_shutdown (FALSE); |
| 2198 |
return; |
| 2199 |
} |
| 2200 |
|
| 2201 |
if (!qmi_message_dms_get_user_lock_state_output_get_result (output, &error)) { |
| 2202 |
g_printerr ("error: couldn't get the state of the user lock: %s\n", error->message); |
| 2203 |
g_error_free (error); |
| 2204 |
qmi_message_dms_get_user_lock_state_output_unref (output); |
| 2205 |
operation_shutdown (FALSE); |
| 2206 |
return; |
| 2207 |
} |
| 2208 |
|
| 2209 |
qmi_message_dms_get_user_lock_state_output_get_enabled ( |
| 2210 |
output, |
| 2211 |
&enabled, |
| 2212 |
NULL); |
| 2213 |
|
| 2214 |
g_print ("[%s] User lock state retrieved:\n" |
| 2215 |
"\tEnabled: '%s'\n", |
| 2216 |
qmi_device_get_path_display (ctx->device), |
| 2217 |
enabled ? "yes" : "no"); |
| 2218 |
|
| 2219 |
qmi_message_dms_get_user_lock_state_output_unref (output); |
| 2220 |
operation_shutdown (TRUE); |
| 2221 |
} |
| 2222 |
|
| 2223 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_USER_LOCK_STATE */ |
| 2224 |
|
| 2225 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_USER_LOCK_STATE |
| 2226 |
|
| 2227 |
static QmiMessageDmsSetUserLockStateInput * |
| 2228 |
set_user_lock_state_input_create (const gchar *str) |
| 2229 |
{ |
| 2230 |
QmiMessageDmsSetUserLockStateInput *input = NULL; |
| 2231 |
g_auto(GStrv) split = NULL; |
| 2232 |
gboolean enable_disable; |
| 2233 |
gchar *code; |
| 2234 |
|
| 2235 |
/* Prepare inputs. |
| 2236 |
* Format of the string is: |
| 2237 |
* "[(disable|enable),(current lock code)]" |
| 2238 |
*/ |
| 2239 |
split = g_strsplit (str, ",", -1); |
| 2240 |
|
| 2241 |
if (qmicli_read_enable_disable_from_string (split[0], &enable_disable) && |
| 2242 |
qmicli_read_non_empty_string (split[1], "current lock code", &code)) { |
| 2243 |
GError *error = NULL; |
| 2244 |
|
| 2245 |
input = qmi_message_dms_set_user_lock_state_input_new (); |
| 2246 |
if (!qmi_message_dms_set_user_lock_state_input_set_info ( |
| 2247 |
input, |
| 2248 |
enable_disable, |
| 2249 |
code, |
| 2250 |
&error)) { |
| 2251 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 2252 |
error->message); |
| 2253 |
g_error_free (error); |
| 2254 |
qmi_message_dms_set_user_lock_state_input_unref (input); |
| 2255 |
input = NULL; |
| 2256 |
} |
| 2257 |
} |
| 2258 |
|
| 2259 |
return input; |
| 2260 |
} |
| 2261 |
|
| 2262 |
static void |
| 2263 |
set_user_lock_state_ready (QmiClientDms *client, |
| 2264 |
GAsyncResult *res) |
| 2265 |
{ |
| 2266 |
QmiMessageDmsSetUserLockStateOutput *output; |
| 2267 |
GError *error = NULL; |
| 2268 |
|
| 2269 |
output = qmi_client_dms_set_user_lock_state_finish (client, res, &error); |
| 2270 |
if (!output) { |
| 2271 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2272 |
g_error_free (error); |
| 2273 |
operation_shutdown (FALSE); |
| 2274 |
return; |
| 2275 |
} |
| 2276 |
|
| 2277 |
if (!qmi_message_dms_set_user_lock_state_output_get_result (output, &error)) { |
| 2278 |
g_printerr ("error: couldn't set state of the user lock: %s\n", error->message); |
| 2279 |
g_error_free (error); |
| 2280 |
qmi_message_dms_set_user_lock_state_output_unref (output); |
| 2281 |
operation_shutdown (FALSE); |
| 2282 |
return; |
| 2283 |
} |
| 2284 |
|
| 2285 |
g_print ("[%s] User lock state updated\n", |
| 2286 |
qmi_device_get_path_display (ctx->device)); |
| 2287 |
|
| 2288 |
qmi_message_dms_set_user_lock_state_output_unref (output); |
| 2289 |
operation_shutdown (TRUE); |
| 2290 |
} |
| 2291 |
|
| 2292 |
#endif |
| 2293 |
|
| 2294 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_USER_LOCK_CODE |
| 2295 |
|
| 2296 |
static QmiMessageDmsSetUserLockCodeInput * |
| 2297 |
set_user_lock_code_input_create (const gchar *str) |
| 2298 |
{ |
| 2299 |
QmiMessageDmsSetUserLockCodeInput *input = NULL; |
| 2300 |
g_auto(GStrv) split = NULL; |
| 2301 |
gchar *old_code; |
| 2302 |
gchar *new_code; |
| 2303 |
|
| 2304 |
/* Prepare inputs. |
| 2305 |
* Format of the string is: |
| 2306 |
* "[(old lock code),(new lock code)]" |
| 2307 |
*/ |
| 2308 |
split = g_strsplit (str, ",", -1); |
| 2309 |
if (qmicli_read_non_empty_string (split[0], "old lock code", &old_code) && |
| 2310 |
qmicli_read_non_empty_string (split[1], "new lock code", &new_code)) { |
| 2311 |
GError *error = NULL; |
| 2312 |
|
| 2313 |
input = qmi_message_dms_set_user_lock_code_input_new (); |
| 2314 |
if (!qmi_message_dms_set_user_lock_code_input_set_info ( |
| 2315 |
input, |
| 2316 |
old_code, |
| 2317 |
new_code, |
| 2318 |
&error)) { |
| 2319 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 2320 |
error->message); |
| 2321 |
g_error_free (error); |
| 2322 |
qmi_message_dms_set_user_lock_code_input_unref (input); |
| 2323 |
input = NULL; |
| 2324 |
} |
| 2325 |
} |
| 2326 |
|
| 2327 |
return input; |
| 2328 |
} |
| 2329 |
|
| 2330 |
static void |
| 2331 |
set_user_lock_code_ready (QmiClientDms *client, |
| 2332 |
GAsyncResult *res) |
| 2333 |
{ |
| 2334 |
QmiMessageDmsSetUserLockCodeOutput *output; |
| 2335 |
GError *error = NULL; |
| 2336 |
|
| 2337 |
output = qmi_client_dms_set_user_lock_code_finish (client, res, &error); |
| 2338 |
if (!output) { |
| 2339 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2340 |
g_error_free (error); |
| 2341 |
operation_shutdown (FALSE); |
| 2342 |
return; |
| 2343 |
} |
| 2344 |
|
| 2345 |
if (!qmi_message_dms_set_user_lock_code_output_get_result (output, &error)) { |
| 2346 |
g_printerr ("error: couldn't change user lock code: %s\n", error->message); |
| 2347 |
g_error_free (error); |
| 2348 |
qmi_message_dms_set_user_lock_code_output_unref (output); |
| 2349 |
operation_shutdown (FALSE); |
| 2350 |
return; |
| 2351 |
} |
| 2352 |
|
| 2353 |
g_print ("[%s] User lock code changed\n", |
| 2354 |
qmi_device_get_path_display (ctx->device)); |
| 2355 |
|
| 2356 |
qmi_message_dms_set_user_lock_code_output_unref (output); |
| 2357 |
operation_shutdown (TRUE); |
| 2358 |
} |
| 2359 |
|
| 2360 |
#endif /* HAVE_QMI_MESSAGE_DMS_SET_USER_LOCK_CODE */ |
| 2361 |
|
| 2362 |
#if defined HAVE_QMI_MESSAGE_DMS_READ_USER_DATA |
| 2363 |
|
| 2364 |
static void |
| 2365 |
read_user_data_ready (QmiClientDms *client, |
| 2366 |
GAsyncResult *res) |
| 2367 |
{ |
| 2368 |
QmiMessageDmsReadUserDataOutput *output; |
| 2369 |
GArray *user_data = NULL; |
| 2370 |
gchar *user_data_printable; |
| 2371 |
GError *error = NULL; |
| 2372 |
|
| 2373 |
output = qmi_client_dms_read_user_data_finish (client, res, &error); |
| 2374 |
if (!output) { |
| 2375 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2376 |
g_error_free (error); |
| 2377 |
operation_shutdown (FALSE); |
| 2378 |
return; |
| 2379 |
} |
| 2380 |
|
| 2381 |
if (!qmi_message_dms_read_user_data_output_get_result (output, &error)) { |
| 2382 |
g_printerr ("error: couldn't read user data: %s\n", error->message); |
| 2383 |
g_error_free (error); |
| 2384 |
qmi_message_dms_read_user_data_output_unref (output); |
| 2385 |
operation_shutdown (FALSE); |
| 2386 |
return; |
| 2387 |
} |
| 2388 |
|
| 2389 |
qmi_message_dms_read_user_data_output_get_user_data ( |
| 2390 |
output, |
| 2391 |
&user_data, |
| 2392 |
NULL); |
| 2393 |
user_data_printable = qmicli_get_raw_data_printable (user_data, 80, "\t\t"); |
| 2394 |
|
| 2395 |
g_print ("[%s] User data read:\n" |
| 2396 |
"\tSize: '%u' bytes\n" |
| 2397 |
"\tContents:\n" |
| 2398 |
"%s", |
| 2399 |
qmi_device_get_path_display (ctx->device), |
| 2400 |
user_data->len, |
| 2401 |
user_data_printable); |
| 2402 |
g_free (user_data_printable); |
| 2403 |
|
| 2404 |
qmi_message_dms_read_user_data_output_unref (output); |
| 2405 |
operation_shutdown (TRUE); |
| 2406 |
} |
| 2407 |
|
| 2408 |
#endif /* HAVE_QMI_MESSAGE_DMS_READ_USER_DATA */ |
| 2409 |
|
| 2410 |
#if defined HAVE_QMI_MESSAGE_DMS_WRITE_USER_DATA |
| 2411 |
|
| 2412 |
static QmiMessageDmsWriteUserDataInput * |
| 2413 |
write_user_data_input_create (const gchar *str) |
| 2414 |
{ |
| 2415 |
QmiMessageDmsWriteUserDataInput *input; |
| 2416 |
GArray *array; |
| 2417 |
GError *error = NULL; |
| 2418 |
|
| 2419 |
/* Prepare inputs. Just assume we'll get some text string here, although |
| 2420 |
* nobody said this had to be text. Read User Data actually treats the |
| 2421 |
* contents of the user data as raw binary data. */ |
| 2422 |
array = g_array_sized_new (FALSE, FALSE, 1, strlen (str)); |
| 2423 |
g_array_insert_vals (array, 0, str, strlen (str)); |
| 2424 |
input = qmi_message_dms_write_user_data_input_new (); |
| 2425 |
if (!qmi_message_dms_write_user_data_input_set_user_data ( |
| 2426 |
input, |
| 2427 |
array, |
| 2428 |
&error)) { |
| 2429 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 2430 |
error->message); |
| 2431 |
g_error_free (error); |
| 2432 |
qmi_message_dms_write_user_data_input_unref (input); |
| 2433 |
input = NULL; |
| 2434 |
} |
| 2435 |
g_array_unref (array); |
| 2436 |
|
| 2437 |
return input; |
| 2438 |
} |
| 2439 |
|
| 2440 |
static void |
| 2441 |
write_user_data_ready (QmiClientDms *client, |
| 2442 |
GAsyncResult *res) |
| 2443 |
{ |
| 2444 |
QmiMessageDmsWriteUserDataOutput *output; |
| 2445 |
GError *error = NULL; |
| 2446 |
|
| 2447 |
output = qmi_client_dms_write_user_data_finish (client, res, &error); |
| 2448 |
if (!output) { |
| 2449 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2450 |
g_error_free (error); |
| 2451 |
operation_shutdown (FALSE); |
| 2452 |
return; |
| 2453 |
} |
| 2454 |
|
| 2455 |
if (!qmi_message_dms_write_user_data_output_get_result (output, &error)) { |
| 2456 |
g_printerr ("error: couldn't write user data: %s\n", error->message); |
| 2457 |
g_error_free (error); |
| 2458 |
qmi_message_dms_write_user_data_output_unref (output); |
| 2459 |
operation_shutdown (FALSE); |
| 2460 |
return; |
| 2461 |
} |
| 2462 |
|
| 2463 |
g_print ("[%s] User data written", |
| 2464 |
qmi_device_get_path_display (ctx->device)); |
| 2465 |
|
| 2466 |
qmi_message_dms_write_user_data_output_unref (output); |
| 2467 |
operation_shutdown (TRUE); |
| 2468 |
} |
| 2469 |
|
| 2470 |
#endif /* HAVE_QMI_MESSAGE_DMS_WRITE_USER_DATA */ |
| 2471 |
|
| 2472 |
#if defined HAVE_QMI_MESSAGE_DMS_READ_ERI_FILE |
| 2473 |
|
| 2474 |
static void |
| 2475 |
read_eri_file_ready (QmiClientDms *client, |
| 2476 |
GAsyncResult *res) |
| 2477 |
{ |
| 2478 |
QmiMessageDmsReadEriFileOutput *output; |
| 2479 |
GArray *eri_file = NULL; |
| 2480 |
gchar *eri_file_printable; |
| 2481 |
GError *error = NULL; |
| 2482 |
|
| 2483 |
output = qmi_client_dms_read_eri_file_finish (client, res, &error); |
| 2484 |
if (!output) { |
| 2485 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2486 |
g_error_free (error); |
| 2487 |
operation_shutdown (FALSE); |
| 2488 |
return; |
| 2489 |
} |
| 2490 |
|
| 2491 |
if (!qmi_message_dms_read_eri_file_output_get_result (output, &error)) { |
| 2492 |
g_printerr ("error: couldn't read eri file: %s\n", error->message); |
| 2493 |
g_error_free (error); |
| 2494 |
qmi_message_dms_read_eri_file_output_unref (output); |
| 2495 |
operation_shutdown (FALSE); |
| 2496 |
return; |
| 2497 |
} |
| 2498 |
|
| 2499 |
qmi_message_dms_read_eri_file_output_get_eri_file ( |
| 2500 |
output, |
| 2501 |
&eri_file, |
| 2502 |
NULL); |
| 2503 |
eri_file_printable = qmicli_get_raw_data_printable (eri_file, 80, "\t\t"); |
| 2504 |
|
| 2505 |
g_print ("[%s] ERI file read:\n" |
| 2506 |
"\tSize: '%u' bytes\n" |
| 2507 |
"\tContents:\n" |
| 2508 |
"%s", |
| 2509 |
qmi_device_get_path_display (ctx->device), |
| 2510 |
eri_file->len, |
| 2511 |
eri_file_printable); |
| 2512 |
g_free (eri_file_printable); |
| 2513 |
|
| 2514 |
qmi_message_dms_read_eri_file_output_unref (output); |
| 2515 |
operation_shutdown (TRUE); |
| 2516 |
} |
| 2517 |
|
| 2518 |
#endif /* HAVE_QMI_MESSAGE_DMS_READ_ERI_FILE */ |
| 2519 |
|
| 2520 |
#if defined HAVE_QMI_MESSAGE_DMS_RESTORE_FACTORY_DEFAULTS |
| 2521 |
|
| 2522 |
static QmiMessageDmsRestoreFactoryDefaultsInput * |
| 2523 |
restore_factory_defaults_input_create (const gchar *str) |
| 2524 |
{ |
| 2525 |
QmiMessageDmsRestoreFactoryDefaultsInput *input; |
| 2526 |
GError *error = NULL; |
| 2527 |
|
| 2528 |
input = qmi_message_dms_restore_factory_defaults_input_new (); |
| 2529 |
if (!qmi_message_dms_restore_factory_defaults_input_set_service_programming_code ( |
| 2530 |
input, |
| 2531 |
str, |
| 2532 |
&error)) { |
| 2533 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 2534 |
error->message); |
| 2535 |
g_error_free (error); |
| 2536 |
qmi_message_dms_restore_factory_defaults_input_unref (input); |
| 2537 |
input = NULL; |
| 2538 |
} |
| 2539 |
|
| 2540 |
return input; |
| 2541 |
} |
| 2542 |
|
| 2543 |
static void |
| 2544 |
restore_factory_defaults_ready (QmiClientDms *client, |
| 2545 |
GAsyncResult *res) |
| 2546 |
{ |
| 2547 |
QmiMessageDmsRestoreFactoryDefaultsOutput *output; |
| 2548 |
GError *error = NULL; |
| 2549 |
|
| 2550 |
output = qmi_client_dms_restore_factory_defaults_finish (client, res, &error); |
| 2551 |
if (!output) { |
| 2552 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2553 |
g_error_free (error); |
| 2554 |
operation_shutdown (FALSE); |
| 2555 |
return; |
| 2556 |
} |
| 2557 |
|
| 2558 |
if (!qmi_message_dms_restore_factory_defaults_output_get_result (output, &error)) { |
| 2559 |
g_printerr ("error: couldn't restores factory defaults: %s\n", error->message); |
| 2560 |
g_error_free (error); |
| 2561 |
qmi_message_dms_restore_factory_defaults_output_unref (output); |
| 2562 |
operation_shutdown (FALSE); |
| 2563 |
return; |
| 2564 |
} |
| 2565 |
|
| 2566 |
g_print ("[%s] Factory defaults restored\n" |
| 2567 |
"Device needs to get power-cycled for reset to take effect.\n", |
| 2568 |
qmi_device_get_path_display (ctx->device)); |
| 2569 |
|
| 2570 |
qmi_message_dms_restore_factory_defaults_output_unref (output); |
| 2571 |
operation_shutdown (TRUE); |
| 2572 |
} |
| 2573 |
|
| 2574 |
#endif /* HAVE_QMI_MESSAGE_DMS_RESTORE_FACTORY_DEFAULTS */ |
| 2575 |
|
| 2576 |
#if defined HAVE_QMI_MESSAGE_DMS_VALIDATE_SERVICE_PROGRAMMING_CODE |
| 2577 |
|
| 2578 |
static QmiMessageDmsValidateServiceProgrammingCodeInput * |
| 2579 |
validate_service_programming_code_input_create (const gchar *str) |
| 2580 |
{ |
| 2581 |
QmiMessageDmsValidateServiceProgrammingCodeInput *input; |
| 2582 |
GError *error = NULL; |
| 2583 |
|
| 2584 |
input = qmi_message_dms_validate_service_programming_code_input_new (); |
| 2585 |
if (!qmi_message_dms_validate_service_programming_code_input_set_service_programming_code ( |
| 2586 |
input, |
| 2587 |
str, |
| 2588 |
&error)) { |
| 2589 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 2590 |
error->message); |
| 2591 |
g_error_free (error); |
| 2592 |
qmi_message_dms_validate_service_programming_code_input_unref (input); |
| 2593 |
input = NULL; |
| 2594 |
} |
| 2595 |
|
| 2596 |
return input; |
| 2597 |
} |
| 2598 |
|
| 2599 |
static void |
| 2600 |
validate_service_programming_code_ready (QmiClientDms *client, |
| 2601 |
GAsyncResult *res) |
| 2602 |
{ |
| 2603 |
QmiMessageDmsValidateServiceProgrammingCodeOutput *output; |
| 2604 |
GError *error = NULL; |
| 2605 |
|
| 2606 |
output = qmi_client_dms_validate_service_programming_code_finish (client, res, &error); |
| 2607 |
if (!output) { |
| 2608 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2609 |
g_error_free (error); |
| 2610 |
operation_shutdown (FALSE); |
| 2611 |
return; |
| 2612 |
} |
| 2613 |
|
| 2614 |
if (!qmi_message_dms_validate_service_programming_code_output_get_result (output, &error)) { |
| 2615 |
g_printerr ("error: couldn't validate Service Programming Code: %s\n", error->message); |
| 2616 |
g_error_free (error); |
| 2617 |
qmi_message_dms_validate_service_programming_code_output_unref (output); |
| 2618 |
operation_shutdown (FALSE); |
| 2619 |
return; |
| 2620 |
} |
| 2621 |
|
| 2622 |
g_print ("[%s] Service Programming Code validated\n", |
| 2623 |
qmi_device_get_path_display (ctx->device)); |
| 2624 |
|
| 2625 |
qmi_message_dms_validate_service_programming_code_output_unref (output); |
| 2626 |
operation_shutdown (TRUE); |
| 2627 |
} |
| 2628 |
|
| 2629 |
#endif /* HAVE_QMI_MESSAGE_DMS_VALIDATE_SERVICE_PROGRAMMING_CODE */ |
| 2630 |
|
| 2631 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_ID |
| 2632 |
|
| 2633 |
static void |
| 2634 |
set_firmware_id_ready (QmiClientDms *client, |
| 2635 |
GAsyncResult *res) |
| 2636 |
{ |
| 2637 |
QmiMessageDmsSetFirmwareIdOutput *output; |
| 2638 |
GError *error = NULL; |
| 2639 |
|
| 2640 |
output = qmi_client_dms_set_firmware_id_finish (client, res, &error); |
| 2641 |
if (!output) { |
| 2642 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2643 |
g_error_free (error); |
| 2644 |
operation_shutdown (FALSE); |
| 2645 |
return; |
| 2646 |
} |
| 2647 |
|
| 2648 |
if (!qmi_message_dms_set_firmware_id_output_get_result (output, &error)) { |
| 2649 |
g_printerr ("error: couldn't set firmware id: %s\n", error->message); |
| 2650 |
g_error_free (error); |
| 2651 |
qmi_message_dms_set_firmware_id_output_unref (output); |
| 2652 |
operation_shutdown (FALSE); |
| 2653 |
return; |
| 2654 |
} |
| 2655 |
|
| 2656 |
g_print ("[%s] Firmware id set\n", |
| 2657 |
qmi_device_get_path_display (ctx->device)); |
| 2658 |
|
| 2659 |
qmi_message_dms_set_firmware_id_output_unref (output); |
| 2660 |
operation_shutdown (TRUE); |
| 2661 |
} |
| 2662 |
|
| 2663 |
#endif /* HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_ID */ |
| 2664 |
|
| 2665 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_BAND_CAPABILITIES |
| 2666 |
|
| 2667 |
static void |
| 2668 |
get_band_capabilities_ready (QmiClientDms *client, |
| 2669 |
GAsyncResult *res) |
| 2670 |
{ |
| 2671 |
QmiMessageDmsGetBandCapabilitiesOutput *output; |
| 2672 |
QmiDmsBandCapability band_capability; |
| 2673 |
QmiDmsLteBandCapability lte_band_capability; |
| 2674 |
GArray *extended_lte_band_capability; |
| 2675 |
GArray *nr5g_band_capability; |
| 2676 |
GError *error = NULL; |
| 2677 |
|
| 2678 |
output = qmi_client_dms_get_band_capabilities_finish (client, res, &error); |
| 2679 |
if (!output) { |
| 2680 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2681 |
g_error_free (error); |
| 2682 |
operation_shutdown (FALSE); |
| 2683 |
return; |
| 2684 |
} |
| 2685 |
|
| 2686 |
if (!qmi_message_dms_get_band_capabilities_output_get_result (output, &error)) { |
| 2687 |
g_printerr ("error: couldn't get band capabilities: %s\n", error->message); |
| 2688 |
g_error_free (error); |
| 2689 |
qmi_message_dms_get_band_capabilities_output_unref (output); |
| 2690 |
operation_shutdown (FALSE); |
| 2691 |
return; |
| 2692 |
} |
| 2693 |
|
| 2694 |
if (qmi_message_dms_get_band_capabilities_output_get_band_capability ( |
| 2695 |
output, |
| 2696 |
&band_capability, |
| 2697 |
NULL)) { |
| 2698 |
g_autofree gchar *str = NULL; |
| 2699 |
|
| 2700 |
str = qmi_dms_band_capability_build_string_from_mask (band_capability); |
| 2701 |
g_print ("[%s] Device band capabilities retrieved:\n" |
| 2702 |
"\tBands: '%s'\n", |
| 2703 |
qmi_device_get_path_display (ctx->device), |
| 2704 |
VALIDATE_MASK_NONE (str)); |
| 2705 |
} |
| 2706 |
|
| 2707 |
if (qmi_message_dms_get_band_capabilities_output_get_lte_band_capability ( |
| 2708 |
output, |
| 2709 |
<e_band_capability, |
| 2710 |
NULL)) { |
| 2711 |
g_autofree gchar *str = NULL; |
| 2712 |
|
| 2713 |
str = qmi_dms_lte_band_capability_build_string_from_mask (lte_band_capability); |
| 2714 |
g_print ("\tLTE bands: '%s'\n", VALIDATE_MASK_NONE (str)); |
| 2715 |
} |
| 2716 |
|
| 2717 |
if (qmi_message_dms_get_band_capabilities_output_get_extended_lte_band_capability ( |
| 2718 |
output, |
| 2719 |
&extended_lte_band_capability, |
| 2720 |
NULL)) { |
| 2721 |
guint i; |
| 2722 |
|
| 2723 |
g_print ("\tLTE bands (extended): '"); |
| 2724 |
for (i = 0; i < extended_lte_band_capability->len; i++) |
| 2725 |
g_print ("%s%" G_GUINT16_FORMAT, |
| 2726 |
i == 0 ? "" : ", ", |
| 2727 |
g_array_index (extended_lte_band_capability, guint16, i)); |
| 2728 |
g_print ("'\n"); |
| 2729 |
} |
| 2730 |
|
| 2731 |
if (qmi_message_dms_get_band_capabilities_output_get_nr5g_band_capability ( |
| 2732 |
output, |
| 2733 |
&nr5g_band_capability, |
| 2734 |
NULL)) { |
| 2735 |
guint i; |
| 2736 |
|
| 2737 |
g_print ("\tNR5G bands: '"); |
| 2738 |
for (i = 0; i < nr5g_band_capability->len; i++) |
| 2739 |
g_print ("%s%" G_GUINT16_FORMAT, |
| 2740 |
i == 0 ? "" : ", ", |
| 2741 |
g_array_index (nr5g_band_capability, guint16, i)); |
| 2742 |
g_print ("'\n"); |
| 2743 |
} |
| 2744 |
|
| 2745 |
qmi_message_dms_get_band_capabilities_output_unref (output); |
| 2746 |
operation_shutdown (TRUE); |
| 2747 |
} |
| 2748 |
|
| 2749 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_BAND_CAPABILITIES */ |
| 2750 |
|
| 2751 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_FACTORY_SKU |
| 2752 |
|
| 2753 |
static void |
| 2754 |
get_factory_sku_ready (QmiClientDms *client, |
| 2755 |
GAsyncResult *res) |
| 2756 |
{ |
| 2757 |
const gchar *str = NULL; |
| 2758 |
QmiMessageDmsGetFactorySkuOutput *output; |
| 2759 |
GError *error = NULL; |
| 2760 |
|
| 2761 |
output = qmi_client_dms_get_factory_sku_finish (client, res, &error); |
| 2762 |
if (!output) { |
| 2763 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2764 |
g_error_free (error); |
| 2765 |
operation_shutdown (FALSE); |
| 2766 |
return; |
| 2767 |
} |
| 2768 |
|
| 2769 |
if (!qmi_message_dms_get_factory_sku_output_get_result (output, &error)) { |
| 2770 |
g_printerr ("error: couldn't get factory SKU: %s\n", error->message); |
| 2771 |
g_error_free (error); |
| 2772 |
qmi_message_dms_get_factory_sku_output_unref (output); |
| 2773 |
operation_shutdown (FALSE); |
| 2774 |
return; |
| 2775 |
} |
| 2776 |
|
| 2777 |
qmi_message_dms_get_factory_sku_output_get_sku (output, &str, NULL); |
| 2778 |
|
| 2779 |
g_print ("[%s] Device factory SKU retrieved:\n" |
| 2780 |
"\tSKU: '%s'\n", |
| 2781 |
qmi_device_get_path_display (ctx->device), |
| 2782 |
VALIDATE_UNKNOWN (str)); |
| 2783 |
|
| 2784 |
qmi_message_dms_get_factory_sku_output_unref (output); |
| 2785 |
operation_shutdown (TRUE); |
| 2786 |
} |
| 2787 |
|
| 2788 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_FACTORY_SKU */ |
| 2789 |
|
| 2790 |
#if defined HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES && \ |
| 2791 |
defined HAVE_QMI_MESSAGE_DMS_GET_STORED_IMAGE_INFO |
| 2792 |
|
| 2793 |
typedef struct { |
| 2794 |
QmiMessageDmsListStoredImagesOutput *list_images_output; |
| 2795 |
guint i; |
| 2796 |
guint j; |
| 2797 |
} ListImagesContext; |
| 2798 |
|
| 2799 |
static void |
| 2800 |
list_images_context_free (ListImagesContext *operation_ctx) |
| 2801 |
{ |
| 2802 |
qmi_message_dms_list_stored_images_output_unref (operation_ctx->list_images_output); |
| 2803 |
g_slice_free (ListImagesContext, operation_ctx); |
| 2804 |
} |
| 2805 |
|
| 2806 |
static void get_image_info (ListImagesContext *operation_ctx); |
| 2807 |
|
| 2808 |
static void |
| 2809 |
print_image_info (ListImagesContext *operation_ctx, |
| 2810 |
QmiMessageDmsGetStoredImageInfoOutput *output) |
| 2811 |
{ |
| 2812 |
GArray *array; |
| 2813 |
QmiMessageDmsListStoredImagesOutputListImage *image; |
| 2814 |
QmiMessageDmsListStoredImagesOutputListImageSublistSublistElement *subimage; |
| 2815 |
g_autofree gchar *unique_id_str = NULL; |
| 2816 |
|
| 2817 |
qmi_message_dms_list_stored_images_output_get_list ( |
| 2818 |
operation_ctx->list_images_output, |
| 2819 |
&array, |
| 2820 |
NULL); |
| 2821 |
|
| 2822 |
image = &g_array_index (array, QmiMessageDmsListStoredImagesOutputListImage, operation_ctx->i); |
| 2823 |
subimage = &g_array_index (image->sublist, |
| 2824 |
QmiMessageDmsListStoredImagesOutputListImageSublistSublistElement, |
| 2825 |
operation_ctx->j); |
| 2826 |
|
| 2827 |
unique_id_str = qmicli_get_firmware_image_unique_id_printable (subimage->unique_id); |
| 2828 |
|
| 2829 |
g_print ("%s" |
| 2830 |
"\t\t[%s%u]\n" |
| 2831 |
"\t\tUnique ID: '%s'\n" |
| 2832 |
"\t\tBuild ID: '%s'\n", |
| 2833 |
operation_ctx->j == image->index_of_running_image ? "\t\t>>>>>>>>>> [CURRENT] <<<<<<<<<<\n" : "", |
| 2834 |
qmi_dms_firmware_image_type_get_string (image->type), |
| 2835 |
operation_ctx->j, |
| 2836 |
unique_id_str, |
| 2837 |
subimage->build_id); |
| 2838 |
|
| 2839 |
if (subimage->storage_index != 255) |
| 2840 |
g_print ("\t\tStorage index: '%u'\n", subimage->storage_index); |
| 2841 |
|
| 2842 |
if (subimage->failure_count != 255) |
| 2843 |
g_print ("\t\tFailure count: '%u'\n", subimage->failure_count); |
| 2844 |
|
| 2845 |
if (output) { |
| 2846 |
/* Boot version (optional) */ |
| 2847 |
{ |
| 2848 |
guint16 boot_major_version; |
| 2849 |
guint16 boot_minor_version; |
| 2850 |
|
| 2851 |
if (qmi_message_dms_get_stored_image_info_output_get_boot_version ( |
| 2852 |
output, |
| 2853 |
&boot_major_version, |
| 2854 |
&boot_minor_version, |
| 2855 |
NULL)) { |
| 2856 |
g_print ("\t\tBoot version: '%u.%u'\n", |
| 2857 |
boot_major_version, |
| 2858 |
boot_minor_version); |
| 2859 |
} |
| 2860 |
} |
| 2861 |
|
| 2862 |
/* PRI version (optional) */ |
| 2863 |
{ |
| 2864 |
guint32 pri_version; |
| 2865 |
const gchar *pri_info; |
| 2866 |
|
| 2867 |
if (qmi_message_dms_get_stored_image_info_output_get_pri_version ( |
| 2868 |
output, |
| 2869 |
&pri_version, |
| 2870 |
&pri_info, |
| 2871 |
NULL)) { |
| 2872 |
g_print ("\t\tPRI version: '%u'\n" |
| 2873 |
"\t\tPRI info: '%s'\n", |
| 2874 |
pri_version, |
| 2875 |
pri_info); |
| 2876 |
} |
| 2877 |
} |
| 2878 |
|
| 2879 |
/* OEM lock ID (optional) */ |
| 2880 |
{ |
| 2881 |
guint32 lock_id; |
| 2882 |
|
| 2883 |
if (qmi_message_dms_get_stored_image_info_output_get_oem_lock_id ( |
| 2884 |
output, |
| 2885 |
&lock_id, |
| 2886 |
NULL)) { |
| 2887 |
g_print ("\t\tOEM lock ID: '%u'\n", |
| 2888 |
lock_id); |
| 2889 |
} |
| 2890 |
} |
| 2891 |
} |
| 2892 |
g_print ("\n"); |
| 2893 |
} |
| 2894 |
|
| 2895 |
static void |
| 2896 |
get_stored_image_info_ready (QmiClientDms *client, |
| 2897 |
GAsyncResult *res, |
| 2898 |
ListImagesContext *operation_ctx) |
| 2899 |
{ |
| 2900 |
|
| 2901 |
g_autoptr(QmiMessageDmsGetStoredImageInfoOutput) output = NULL; |
| 2902 |
|
| 2903 |
output = qmi_client_dms_get_stored_image_info_finish (client, res, NULL); |
| 2904 |
if (output && !qmi_message_dms_get_stored_image_info_output_get_result (output, NULL)) |
| 2905 |
g_clear_pointer (&output, qmi_message_dms_get_stored_image_info_output_unref); |
| 2906 |
|
| 2907 |
print_image_info (operation_ctx, output); |
| 2908 |
|
| 2909 |
/* Go on to the next one */ |
| 2910 |
operation_ctx->j++; |
| 2911 |
get_image_info (operation_ctx); |
| 2912 |
} |
| 2913 |
|
| 2914 |
static void |
| 2915 |
get_image_info (ListImagesContext *operation_ctx) |
| 2916 |
{ |
| 2917 |
GArray *array; |
| 2918 |
QmiMessageDmsListStoredImagesOutputListImage *image; |
| 2919 |
QmiMessageDmsListStoredImagesOutputListImageSublistSublistElement *subimage; |
| 2920 |
g_autoptr(QmiMessageDmsGetStoredImageInfoInput) input = NULL; |
| 2921 |
|
| 2922 |
qmi_message_dms_list_stored_images_output_get_list ( |
| 2923 |
operation_ctx->list_images_output, |
| 2924 |
&array, |
| 2925 |
NULL); |
| 2926 |
|
| 2927 |
if (operation_ctx->i >= array->len) { |
| 2928 |
/* We're done */ |
| 2929 |
list_images_context_free (operation_ctx); |
| 2930 |
operation_shutdown (TRUE); |
| 2931 |
return; |
| 2932 |
} |
| 2933 |
|
| 2934 |
image = &g_array_index (array, |
| 2935 |
QmiMessageDmsListStoredImagesOutputListImage, |
| 2936 |
operation_ctx->i); |
| 2937 |
|
| 2938 |
if (operation_ctx->j >= image->sublist->len) { |
| 2939 |
/* No more images in the sublist, go to next image type */ |
| 2940 |
operation_ctx->j = 0; |
| 2941 |
operation_ctx->i++; |
| 2942 |
get_image_info (operation_ctx); |
| 2943 |
return; |
| 2944 |
} |
| 2945 |
|
| 2946 |
/* Print info of the image type */ |
| 2947 |
if (operation_ctx->j == 0) { |
| 2948 |
g_print ("\t[%u] Type: '%s'\n" |
| 2949 |
"\t Maximum: '%u'\n" |
| 2950 |
"\n", |
| 2951 |
operation_ctx->i, |
| 2952 |
qmi_dms_firmware_image_type_get_string (image->type), |
| 2953 |
image->maximum_images); |
| 2954 |
} |
| 2955 |
|
| 2956 |
subimage = &g_array_index (image->sublist, |
| 2957 |
QmiMessageDmsListStoredImagesOutputListImageSublistSublistElement, |
| 2958 |
operation_ctx->j); |
| 2959 |
|
| 2960 |
/* Query image info */ |
| 2961 |
input = qmi_message_dms_get_stored_image_info_input_new (); |
| 2962 |
qmi_message_dms_get_stored_image_info_input_set_image_details (input, |
| 2963 |
image->type, |
| 2964 |
subimage->unique_id, |
| 2965 |
subimage->build_id, |
| 2966 |
NULL); |
| 2967 |
qmi_client_dms_get_stored_image_info (ctx->client, |
| 2968 |
input, |
| 2969 |
10, |
| 2970 |
ctx->cancellable, |
| 2971 |
(GAsyncReadyCallback)get_stored_image_info_ready, |
| 2972 |
operation_ctx); |
| 2973 |
} |
| 2974 |
|
| 2975 |
static void |
| 2976 |
list_stored_images_ready (QmiClientDms *client, |
| 2977 |
GAsyncResult *res) |
| 2978 |
{ |
| 2979 |
QmiMessageDmsListStoredImagesOutput *output; |
| 2980 |
GError *error = NULL; |
| 2981 |
ListImagesContext *operation_ctx; |
| 2982 |
|
| 2983 |
output = qmi_client_dms_list_stored_images_finish (client, res, &error); |
| 2984 |
if (!output) { |
| 2985 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 2986 |
g_error_free (error); |
| 2987 |
operation_shutdown (FALSE); |
| 2988 |
return; |
| 2989 |
} |
| 2990 |
|
| 2991 |
if (!qmi_message_dms_list_stored_images_output_get_result (output, &error)) { |
| 2992 |
g_printerr ("error: couldn't list stored images: %s\n", error->message); |
| 2993 |
g_error_free (error); |
| 2994 |
qmi_message_dms_list_stored_images_output_unref (output); |
| 2995 |
operation_shutdown (FALSE); |
| 2996 |
return; |
| 2997 |
} |
| 2998 |
|
| 2999 |
g_print ("[%s] Device list of stored images retrieved:\n\n", |
| 3000 |
qmi_device_get_path_display (ctx->device)); |
| 3001 |
|
| 3002 |
operation_ctx = g_slice_new0 (ListImagesContext); |
| 3003 |
operation_ctx->list_images_output = output; |
| 3004 |
operation_ctx->i = 0; |
| 3005 |
operation_ctx->j = 0; |
| 3006 |
|
| 3007 |
get_image_info (operation_ctx); |
| 3008 |
} |
| 3009 |
|
| 3010 |
#endif /* HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES && HAVE_QMI_MESSAGE_DMS_GET_STORED_IMAGE_INFO */ |
| 3011 |
|
| 3012 |
#if defined HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES && \ |
| 3013 |
defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE |
| 3014 |
|
| 3015 |
typedef struct { |
| 3016 |
gint modem_index; |
| 3017 |
gint pri_index; |
| 3018 |
} GetStoredImageContext; |
| 3019 |
|
| 3020 |
typedef struct { |
| 3021 |
GArray *modem_unique_id; |
| 3022 |
gchar *modem_build_id; |
| 3023 |
GArray *pri_unique_id; |
| 3024 |
gchar *pri_build_id; |
| 3025 |
} GetStoredImageResult; |
| 3026 |
|
| 3027 |
static void |
| 3028 |
get_stored_image_context_free (GetStoredImageContext *operation_ctx) |
| 3029 |
{ |
| 3030 |
g_slice_free (GetStoredImageContext, operation_ctx); |
| 3031 |
} |
| 3032 |
|
| 3033 |
static void |
| 3034 |
get_stored_image_result_free (GetStoredImageResult *result) |
| 3035 |
{ |
| 3036 |
if (result) { |
| 3037 |
g_clear_pointer (&result->modem_unique_id, g_array_unref); |
| 3038 |
g_free (result->modem_build_id); |
| 3039 |
g_clear_pointer (&result->pri_unique_id, g_array_unref); |
| 3040 |
g_free (result->pri_build_id); |
| 3041 |
g_slice_free (GetStoredImageResult, result); |
| 3042 |
} |
| 3043 |
} |
| 3044 |
|
| 3045 |
static void |
| 3046 |
get_stored_image_finish (QmiClientDms *client, |
| 3047 |
GAsyncResult *res, |
| 3048 |
GArray **modem_unique_id, |
| 3049 |
gchar **modem_build_id, |
| 3050 |
GArray **pri_unique_id, |
| 3051 |
gchar **pri_build_id) |
| 3052 |
{ |
| 3053 |
GetStoredImageResult *result; |
| 3054 |
GError *error = NULL; |
| 3055 |
|
| 3056 |
result = g_task_propagate_pointer (G_TASK (res), &error); |
| 3057 |
|
| 3058 |
/* The operation always returns a result */ |
| 3059 |
g_assert (result); |
| 3060 |
g_assert_no_error (error); |
| 3061 |
|
| 3062 |
/* Simply pass ownership to caller */ |
| 3063 |
*modem_unique_id = result->modem_unique_id; |
| 3064 |
*modem_build_id = result->modem_build_id; |
| 3065 |
*pri_unique_id = result->pri_unique_id; |
| 3066 |
*pri_build_id = result->pri_build_id; |
| 3067 |
|
| 3068 |
g_slice_free (GetStoredImageResult, result); |
| 3069 |
} |
| 3070 |
|
| 3071 |
static void |
| 3072 |
get_stored_image_list_stored_images_ready (QmiClientDms *client, |
| 3073 |
GAsyncResult *res, |
| 3074 |
GTask *task) |
| 3075 |
{ |
| 3076 |
GetStoredImageContext *operation_ctx; |
| 3077 |
GetStoredImageResult *result; |
| 3078 |
GArray *array; |
| 3079 |
QmiMessageDmsListStoredImagesOutput *output; |
| 3080 |
GError *error = NULL; |
| 3081 |
guint i; |
| 3082 |
|
| 3083 |
output = qmi_client_dms_list_stored_images_finish (client, res, &error); |
| 3084 |
if (!output) { |
| 3085 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 3086 |
g_error_free (error); |
| 3087 |
g_object_unref (task); |
| 3088 |
operation_shutdown (FALSE); |
| 3089 |
return; |
| 3090 |
} |
| 3091 |
|
| 3092 |
if (!qmi_message_dms_list_stored_images_output_get_result (output, &error)) { |
| 3093 |
g_printerr ("error: couldn't list stored images: %s\n", error->message); |
| 3094 |
g_error_free (error); |
| 3095 |
qmi_message_dms_list_stored_images_output_unref (output); |
| 3096 |
g_object_unref (task); |
| 3097 |
operation_shutdown (FALSE); |
| 3098 |
return; |
| 3099 |
} |
| 3100 |
|
| 3101 |
qmi_message_dms_list_stored_images_output_get_list ( |
| 3102 |
output, |
| 3103 |
&array, |
| 3104 |
NULL); |
| 3105 |
|
| 3106 |
operation_ctx = g_task_get_task_data (task); |
| 3107 |
|
| 3108 |
/* A single result struct is used for all iterations */ |
| 3109 |
result = g_slice_new0 (GetStoredImageResult); |
| 3110 |
|
| 3111 |
for (i = 0; i < array->len; i++) { |
| 3112 |
QmiMessageDmsListStoredImagesOutputListImageSublistSublistElement *subimage; |
| 3113 |
QmiMessageDmsListStoredImagesOutputListImage *image; |
| 3114 |
gchar *unique_id_str; |
| 3115 |
gint image_index; |
| 3116 |
|
| 3117 |
image = &g_array_index (array, |
| 3118 |
QmiMessageDmsListStoredImagesOutputListImage, |
| 3119 |
i); |
| 3120 |
|
| 3121 |
if (image->type == QMI_DMS_FIRMWARE_IMAGE_TYPE_MODEM) |
| 3122 |
image_index = operation_ctx->modem_index; |
| 3123 |
else if (image->type == QMI_DMS_FIRMWARE_IMAGE_TYPE_PRI) |
| 3124 |
image_index = operation_ctx->pri_index; |
| 3125 |
else |
| 3126 |
g_assert_not_reached (); |
| 3127 |
|
| 3128 |
/* If not looking for the specific image type, go on */ |
| 3129 |
if (image_index < 0) |
| 3130 |
continue; |
| 3131 |
|
| 3132 |
if ((guint)image_index >= image->sublist->len) { |
| 3133 |
g_printerr ("error: couldn't find '%s' image at index '%d'\n", |
| 3134 |
qmi_dms_firmware_image_type_get_string (image->type), |
| 3135 |
image_index); |
| 3136 |
qmi_message_dms_list_stored_images_output_unref (output); |
| 3137 |
g_object_unref (task); |
| 3138 |
operation_shutdown (FALSE); |
| 3139 |
get_stored_image_result_free (result); |
| 3140 |
return; |
| 3141 |
} |
| 3142 |
|
| 3143 |
subimage = &g_array_index (image->sublist, |
| 3144 |
QmiMessageDmsListStoredImagesOutputListImageSublistSublistElement, |
| 3145 |
image_index); |
| 3146 |
|
| 3147 |
unique_id_str = qmicli_get_firmware_image_unique_id_printable (subimage->unique_id); |
| 3148 |
g_debug ("Found [%s%d]: Unique ID: '%s', Build ID: '%s'", |
| 3149 |
qmi_dms_firmware_image_type_get_string (image->type), |
| 3150 |
image_index, |
| 3151 |
unique_id_str, |
| 3152 |
subimage->build_id); |
| 3153 |
g_free (unique_id_str); |
| 3154 |
|
| 3155 |
if (image->type == QMI_DMS_FIRMWARE_IMAGE_TYPE_MODEM) { |
| 3156 |
result->modem_unique_id = g_array_ref (subimage->unique_id); |
| 3157 |
result->modem_build_id = g_strdup (subimage->build_id); |
| 3158 |
} else if (image->type == QMI_DMS_FIRMWARE_IMAGE_TYPE_PRI) { |
| 3159 |
result->pri_unique_id = g_array_ref (subimage->unique_id); |
| 3160 |
result->pri_build_id = g_strdup (subimage->build_id); |
| 3161 |
} else |
| 3162 |
g_assert_not_reached (); |
| 3163 |
} |
| 3164 |
|
| 3165 |
/* Complete */ |
| 3166 |
g_task_return_pointer (task, result, (GDestroyNotify)get_stored_image_result_free); |
| 3167 |
g_object_unref (task); |
| 3168 |
qmi_message_dms_list_stored_images_output_unref (output); |
| 3169 |
} |
| 3170 |
|
| 3171 |
static void |
| 3172 |
get_stored_image (QmiClientDms *client, |
| 3173 |
const gchar *str, |
| 3174 |
GAsyncReadyCallback callback, |
| 3175 |
gpointer user_data) |
| 3176 |
{ |
| 3177 |
GetStoredImageContext *operation_ctx; |
| 3178 |
g_auto(GStrv) split = NULL; |
| 3179 |
GTask *task; |
| 3180 |
guint i = 0; |
| 3181 |
gint modem_index = -1; |
| 3182 |
gint pri_index = -1; |
| 3183 |
|
| 3184 |
split = g_strsplit (str, ",", -1); |
| 3185 |
while (split[i]) { |
| 3186 |
QmiDmsFirmwareImageType type; |
| 3187 |
guint image_index; |
| 3188 |
|
| 3189 |
if (i >= 3) { |
| 3190 |
g_printerr ("A maximum of 2 images should be given: '%s'\n", str); |
| 3191 |
operation_shutdown (FALSE); |
| 3192 |
return; |
| 3193 |
} |
| 3194 |
|
| 3195 |
if (!qmicli_read_firmware_id_from_string (split[i], &type, &image_index)) { |
| 3196 |
g_printerr ("Couldn't parse input string as firmware index info: '%s'\n", str); |
| 3197 |
operation_shutdown (FALSE); |
| 3198 |
return; |
| 3199 |
} |
| 3200 |
|
| 3201 |
if (type == QMI_DMS_FIRMWARE_IMAGE_TYPE_MODEM) { |
| 3202 |
if (modem_index >= 0) { |
| 3203 |
g_printerr ("Cannot handle two 'modem' type firmware indices: '%s'\n", str); |
| 3204 |
operation_shutdown (FALSE); |
| 3205 |
return; |
| 3206 |
} |
| 3207 |
modem_index = (gint)image_index; |
| 3208 |
} else if (type == QMI_DMS_FIRMWARE_IMAGE_TYPE_PRI) { |
| 3209 |
if (pri_index >= 0) { |
| 3210 |
g_printerr ("Cannot handle two 'pri' type firmware indices: '%s'\n", str); |
| 3211 |
operation_shutdown (FALSE); |
| 3212 |
return; |
| 3213 |
} |
| 3214 |
pri_index = (gint)image_index; |
| 3215 |
} |
| 3216 |
|
| 3217 |
i++; |
| 3218 |
} |
| 3219 |
|
| 3220 |
operation_ctx = g_slice_new (GetStoredImageContext); |
| 3221 |
operation_ctx->modem_index = modem_index; |
| 3222 |
operation_ctx->pri_index = pri_index; |
| 3223 |
|
| 3224 |
task = g_task_new (client, NULL, callback, user_data); |
| 3225 |
g_task_set_task_data (task, operation_ctx, (GDestroyNotify)get_stored_image_context_free); |
| 3226 |
|
| 3227 |
qmi_client_dms_list_stored_images ( |
| 3228 |
ctx->client, |
| 3229 |
NULL, |
| 3230 |
10, |
| 3231 |
ctx->cancellable, |
| 3232 |
(GAsyncReadyCallback)get_stored_image_list_stored_images_ready, |
| 3233 |
task); |
| 3234 |
} |
| 3235 |
|
| 3236 |
#endif /* HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES |
| 3237 |
* HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE */ |
| 3238 |
|
| 3239 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE |
| 3240 |
|
| 3241 |
/* Note: |
| 3242 |
* used by both --dms-set-firmware-preference and --dms-select-stored-image |
| 3243 |
* But only one single symbol check, as the select operation already |
| 3244 |
* requires SET_FIRMWARE_PREFERENCE. |
| 3245 |
*/ |
| 3246 |
static void |
| 3247 |
dms_set_firmware_preference_ready (QmiClientDms *client, |
| 3248 |
GAsyncResult *res) |
| 3249 |
{ |
| 3250 |
QmiMessageDmsSetFirmwarePreferenceOutput *output; |
| 3251 |
GError *error = NULL; |
| 3252 |
GArray *array; |
| 3253 |
GString *pending_images = NULL; |
| 3254 |
|
| 3255 |
output = qmi_client_dms_set_firmware_preference_finish (client, res, &error); |
| 3256 |
if (!output) { |
| 3257 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 3258 |
g_error_free (error); |
| 3259 |
operation_shutdown (FALSE); |
| 3260 |
return; |
| 3261 |
} |
| 3262 |
|
| 3263 |
if (!qmi_message_dms_set_firmware_preference_output_get_result (output, &error)) { |
| 3264 |
g_printerr ("error: couldn't select stored image: %s\n", error->message); |
| 3265 |
g_error_free (error); |
| 3266 |
qmi_message_dms_set_firmware_preference_output_unref (output); |
| 3267 |
operation_shutdown (FALSE); |
| 3268 |
return; |
| 3269 |
} |
| 3270 |
|
| 3271 |
g_print ("[%s] Firmware preference successfully selected\n" |
| 3272 |
"\n" |
| 3273 |
"\tYou may want to power-cycle the modem now, or just set it offline and reset it:\n" |
| 3274 |
"\t\t$> sudo qmicli ... --dms-set-operating-mode=offline\n" |
| 3275 |
"\t\t$> sudo qmicli ... --dms-set-operating-mode=reset\n" |
| 3276 |
"\n", |
| 3277 |
qmi_device_get_path_display (ctx->device)); |
| 3278 |
|
| 3279 |
/* do we need to download a new modem and/or pri image? */ |
| 3280 |
if (qmi_message_dms_set_firmware_preference_output_get_image_download_list (output, &array, NULL) && array->len) { |
| 3281 |
guint i; |
| 3282 |
QmiDmsFirmwareImageType type; |
| 3283 |
|
| 3284 |
pending_images = g_string_new (""); |
| 3285 |
for (i = 0; i < array->len; i++) { |
| 3286 |
type = g_array_index (array, QmiDmsFirmwareImageType, i); |
| 3287 |
g_string_append (pending_images, qmi_dms_firmware_image_type_get_string (type)); |
| 3288 |
if (i < array->len -1) |
| 3289 |
g_string_append (pending_images, ", "); |
| 3290 |
} |
| 3291 |
} |
| 3292 |
|
| 3293 |
if (pending_images) { |
| 3294 |
g_print ("\tAfter reset, the modem will wait in QDL mode for new firmware.\n" |
| 3295 |
"\tImages to download: '%s'\n" |
| 3296 |
"\n", |
| 3297 |
pending_images->str); |
| 3298 |
g_string_free (pending_images, TRUE); |
| 3299 |
} else { |
| 3300 |
/* If we're selecting an already stored image, or if we don't need any |
| 3301 |
* more images to be downloaded, we're done. */ |
| 3302 |
g_print ("\tNo new images are required to be downloaded.\n" |
| 3303 |
"\n" |
| 3304 |
"\tYou should check that the modem|pri image pair is valid by checking the current operating mode:\n" |
| 3305 |
"\t\t$> sudo qmicli .... --dms-get-operating-mode\n" |
| 3306 |
"\tIf the Mode is reported as 'online', you're good to go.\n" |
| 3307 |
"\tIf the Mode is reported as 'offline' with a 'pri-version-incompatible' reason, you chose an incorrect pair\n" |
| 3308 |
"\n"); |
| 3309 |
} |
| 3310 |
|
| 3311 |
qmi_message_dms_set_firmware_preference_output_unref (output); |
| 3312 |
operation_shutdown (TRUE); |
| 3313 |
} |
| 3314 |
|
| 3315 |
#endif /* HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE */ |
| 3316 |
|
| 3317 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE && \ |
| 3318 |
defined HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES |
| 3319 |
|
| 3320 |
static void |
| 3321 |
get_stored_image_select_ready (QmiClientDms *client, |
| 3322 |
GAsyncResult *res) |
| 3323 |
{ |
| 3324 |
QmiMessageDmsSetFirmwarePreferenceInput *input; |
| 3325 |
GArray *array; |
| 3326 |
QmiMessageDmsSetFirmwarePreferenceInputListImage modem_image_id; |
| 3327 |
QmiMessageDmsSetFirmwarePreferenceInputListImage pri_image_id; |
| 3328 |
|
| 3329 |
modem_image_id.type = QMI_DMS_FIRMWARE_IMAGE_TYPE_MODEM; |
| 3330 |
pri_image_id.type = QMI_DMS_FIRMWARE_IMAGE_TYPE_PRI; |
| 3331 |
|
| 3332 |
get_stored_image_finish (client, |
| 3333 |
res, |
| 3334 |
&modem_image_id.unique_id, |
| 3335 |
&modem_image_id.build_id, |
| 3336 |
&pri_image_id.unique_id, |
| 3337 |
&pri_image_id.build_id); |
| 3338 |
|
| 3339 |
if (!modem_image_id.unique_id || !modem_image_id.build_id || |
| 3340 |
!pri_image_id.unique_id || !pri_image_id.build_id) { |
| 3341 |
g_printerr ("error: must specify a pair of 'modem' and 'pri' images to select\n"); |
| 3342 |
operation_shutdown (FALSE); |
| 3343 |
return; |
| 3344 |
} |
| 3345 |
|
| 3346 |
array = g_array_sized_new (FALSE, FALSE, sizeof (QmiMessageDmsSetFirmwarePreferenceInputListImage), 2); |
| 3347 |
g_array_append_val (array, modem_image_id); |
| 3348 |
g_array_append_val (array, pri_image_id); |
| 3349 |
|
| 3350 |
input = qmi_message_dms_set_firmware_preference_input_new (); |
| 3351 |
qmi_message_dms_set_firmware_preference_input_set_list (input, array, NULL); |
| 3352 |
|
| 3353 |
qmi_client_dms_set_firmware_preference ( |
| 3354 |
client, |
| 3355 |
input, |
| 3356 |
10, |
| 3357 |
NULL, |
| 3358 |
(GAsyncReadyCallback)dms_set_firmware_preference_ready, |
| 3359 |
NULL); |
| 3360 |
qmi_message_dms_set_firmware_preference_input_unref (input); |
| 3361 |
|
| 3362 |
g_free (modem_image_id.build_id); |
| 3363 |
g_array_unref (modem_image_id.unique_id); |
| 3364 |
g_free (pri_image_id.build_id); |
| 3365 |
g_array_unref (pri_image_id.unique_id); |
| 3366 |
} |
| 3367 |
|
| 3368 |
#endif /* HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE |
| 3369 |
* HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES */ |
| 3370 |
|
| 3371 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE && \ |
| 3372 |
defined HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES && \ |
| 3373 |
defined HAVE_QMI_MESSAGE_DMS_DELETE_STORED_IMAGE |
| 3374 |
|
| 3375 |
static void |
| 3376 |
delete_stored_image_ready (QmiClientDms *client, |
| 3377 |
GAsyncResult *res) |
| 3378 |
{ |
| 3379 |
QmiMessageDmsDeleteStoredImageOutput *output; |
| 3380 |
GError *error = NULL; |
| 3381 |
|
| 3382 |
output = qmi_client_dms_delete_stored_image_finish (client, res, &error); |
| 3383 |
if (!output) { |
| 3384 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 3385 |
g_error_free (error); |
| 3386 |
operation_shutdown (FALSE); |
| 3387 |
return; |
| 3388 |
} |
| 3389 |
|
| 3390 |
if (!qmi_message_dms_delete_stored_image_output_get_result (output, &error)) { |
| 3391 |
g_printerr ("error: couldn't delete stored image: %s\n", error->message); |
| 3392 |
g_error_free (error); |
| 3393 |
qmi_message_dms_delete_stored_image_output_unref (output); |
| 3394 |
operation_shutdown (FALSE); |
| 3395 |
return; |
| 3396 |
} |
| 3397 |
|
| 3398 |
g_print ("[%s] Stored image successfully deleted\n", |
| 3399 |
qmi_device_get_path_display (ctx->device)); |
| 3400 |
qmi_message_dms_delete_stored_image_output_unref (output); |
| 3401 |
operation_shutdown (TRUE); |
| 3402 |
} |
| 3403 |
|
| 3404 |
static void |
| 3405 |
get_stored_image_delete_ready (QmiClientDms *client, |
| 3406 |
GAsyncResult *res) |
| 3407 |
{ |
| 3408 |
g_autoptr(QmiMessageDmsDeleteStoredImageInput) input = NULL; |
| 3409 |
g_autoptr(GArray) modem_unique_id = NULL; |
| 3410 |
g_autofree gchar *modem_build_id = NULL; |
| 3411 |
g_autoptr(GArray) pri_unique_id = NULL; |
| 3412 |
g_autofree gchar *pri_build_id = NULL; |
| 3413 |
|
| 3414 |
get_stored_image_finish (client, |
| 3415 |
res, |
| 3416 |
&modem_unique_id, |
| 3417 |
&modem_build_id, |
| 3418 |
&pri_unique_id, |
| 3419 |
&pri_build_id); |
| 3420 |
|
| 3421 |
if (modem_unique_id && modem_build_id && |
| 3422 |
pri_unique_id && pri_build_id) { |
| 3423 |
g_printerr ("error: cannot specify multiple images to delete\n"); |
| 3424 |
operation_shutdown (FALSE); |
| 3425 |
return; |
| 3426 |
} |
| 3427 |
|
| 3428 |
input = qmi_message_dms_delete_stored_image_input_new (); |
| 3429 |
if (modem_unique_id && modem_build_id) |
| 3430 |
qmi_message_dms_delete_stored_image_input_set_image_details (input, |
| 3431 |
QMI_DMS_FIRMWARE_IMAGE_TYPE_MODEM, |
| 3432 |
modem_unique_id, |
| 3433 |
modem_build_id, |
| 3434 |
NULL); |
| 3435 |
else if (pri_unique_id && pri_build_id) |
| 3436 |
qmi_message_dms_delete_stored_image_input_set_image_details (input, |
| 3437 |
QMI_DMS_FIRMWARE_IMAGE_TYPE_PRI, |
| 3438 |
pri_unique_id, |
| 3439 |
pri_build_id, |
| 3440 |
NULL); |
| 3441 |
else { |
| 3442 |
g_printerr ("error: didn't specify correctly an image to delete\n"); |
| 3443 |
operation_shutdown (FALSE); |
| 3444 |
return; |
| 3445 |
} |
| 3446 |
|
| 3447 |
qmi_client_dms_delete_stored_image ( |
| 3448 |
client, |
| 3449 |
input, |
| 3450 |
10, |
| 3451 |
NULL, |
| 3452 |
(GAsyncReadyCallback)delete_stored_image_ready, |
| 3453 |
NULL); |
| 3454 |
} |
| 3455 |
|
| 3456 |
#endif /* HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE |
| 3457 |
* HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES |
| 3458 |
* HAVE_QMI_MESSAGE_DMS_DELETE_STORED_IMAGE */ |
| 3459 |
|
| 3460 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_FIRMWARE_PREFERENCE |
| 3461 |
|
| 3462 |
static void |
| 3463 |
dms_get_firmware_preference_ready (QmiClientDms *client, |
| 3464 |
GAsyncResult *res) |
| 3465 |
{ |
| 3466 |
GError *error = NULL; |
| 3467 |
QmiMessageDmsGetFirmwarePreferenceOutput *output; |
| 3468 |
GArray *array; |
| 3469 |
guint i; |
| 3470 |
|
| 3471 |
output = qmi_client_dms_get_firmware_preference_finish (client, res, &error); |
| 3472 |
if (!output) { |
| 3473 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 3474 |
g_error_free (error); |
| 3475 |
operation_shutdown (FALSE); |
| 3476 |
return; |
| 3477 |
} |
| 3478 |
|
| 3479 |
if (!qmi_message_dms_get_firmware_preference_output_get_result (output, &error)) { |
| 3480 |
g_printerr ("error: couldn't get firmware preference: %s\n", error->message); |
| 3481 |
g_error_free (error); |
| 3482 |
qmi_message_dms_get_firmware_preference_output_unref (output); |
| 3483 |
operation_shutdown (FALSE); |
| 3484 |
return; |
| 3485 |
} |
| 3486 |
|
| 3487 |
qmi_message_dms_get_firmware_preference_output_get_list (output, &array, NULL); |
| 3488 |
|
| 3489 |
g_print ("firmware preference successfully retrieved:\n"); |
| 3490 |
|
| 3491 |
if (array->len > 0) { |
| 3492 |
for (i = 0; i < array->len; i++) { |
| 3493 |
QmiMessageDmsGetFirmwarePreferenceOutputListImage *image; |
| 3494 |
gchar *unique_id_str; |
| 3495 |
|
| 3496 |
image = &g_array_index (array, QmiMessageDmsGetFirmwarePreferenceOutputListImage, i); |
| 3497 |
|
| 3498 |
unique_id_str = qmicli_get_firmware_image_unique_id_printable (image->unique_id); |
| 3499 |
|
| 3500 |
g_print ("[image %u]\n" |
| 3501 |
"\tImage type: '%s'\n" |
| 3502 |
"\tUnique ID: '%s'\n" |
| 3503 |
"\tBuild ID: '%s'\n", |
| 3504 |
i, |
| 3505 |
qmi_dms_firmware_image_type_get_string (image->type), |
| 3506 |
unique_id_str, |
| 3507 |
image->build_id); |
| 3508 |
|
| 3509 |
g_free (unique_id_str); |
| 3510 |
} |
| 3511 |
} else |
| 3512 |
g_print ("no images specified\n"); |
| 3513 |
|
| 3514 |
qmi_message_dms_get_firmware_preference_output_unref (output); |
| 3515 |
operation_shutdown (TRUE); |
| 3516 |
} |
| 3517 |
|
| 3518 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_FIRMWARE_PREFERENCE */ |
| 3519 |
|
| 3520 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE |
| 3521 |
|
| 3522 |
typedef struct { |
| 3523 |
QmiMessageDmsSetFirmwarePreferenceInputListImage modem_image_id; |
| 3524 |
QmiMessageDmsSetFirmwarePreferenceInputListImage pri_image_id; |
| 3525 |
} SetFirmwarePreferenceContext; |
| 3526 |
|
| 3527 |
static void |
| 3528 |
set_firmware_preference_context_clear (SetFirmwarePreferenceContext *firmware_preference_ctx) |
| 3529 |
{ |
| 3530 |
g_clear_pointer (&firmware_preference_ctx->modem_image_id.unique_id, g_array_unref); |
| 3531 |
g_free (firmware_preference_ctx->modem_image_id.build_id); |
| 3532 |
|
| 3533 |
g_clear_pointer (&firmware_preference_ctx->pri_image_id.unique_id, g_array_unref); |
| 3534 |
g_free (firmware_preference_ctx->pri_image_id.build_id); |
| 3535 |
} |
| 3536 |
|
| 3537 |
typedef struct { |
| 3538 |
gchar *firmware_version; |
| 3539 |
gchar *config_version; |
| 3540 |
gchar *carrier; |
| 3541 |
gint modem_storage_index; |
| 3542 |
gboolean override_download; |
| 3543 |
gboolean override_download_set; |
| 3544 |
} SetFirmwarePreferenceProperties; |
| 3545 |
|
| 3546 |
static void |
| 3547 |
set_firmware_preference_properties_clear (SetFirmwarePreferenceProperties *props) |
| 3548 |
{ |
| 3549 |
g_free (props->firmware_version); |
| 3550 |
g_free (props->config_version); |
| 3551 |
g_free (props->carrier); |
| 3552 |
} |
| 3553 |
|
| 3554 |
static gboolean |
| 3555 |
set_firmware_preference_properties_handle (const gchar *key, |
| 3556 |
const gchar *value, |
| 3557 |
GError **error, |
| 3558 |
gpointer user_data) |
| 3559 |
{ |
| 3560 |
SetFirmwarePreferenceProperties *props = user_data; |
| 3561 |
|
| 3562 |
if (!value || !value[0]) { |
| 3563 |
g_set_error (error, |
| 3564 |
QMI_CORE_ERROR, |
| 3565 |
QMI_CORE_ERROR_FAILED, |
| 3566 |
"key '%s' required a value", |
| 3567 |
key); |
| 3568 |
return FALSE; |
| 3569 |
} |
| 3570 |
|
| 3571 |
if (g_ascii_strcasecmp (key, "firmware-version") == 0 && !props->firmware_version) { |
| 3572 |
props->firmware_version = g_strdup (value); |
| 3573 |
return TRUE; |
| 3574 |
} |
| 3575 |
|
| 3576 |
if (g_ascii_strcasecmp (key, "config-version") == 0 && !props->config_version) { |
| 3577 |
props->config_version = g_strdup (value); |
| 3578 |
return TRUE; |
| 3579 |
} |
| 3580 |
|
| 3581 |
if (g_ascii_strcasecmp (key, "carrier") == 0 && !props->carrier) { |
| 3582 |
props->carrier = g_strdup (value); |
| 3583 |
return TRUE; |
| 3584 |
} |
| 3585 |
|
| 3586 |
if (g_ascii_strcasecmp (key, "override-download") == 0 && !props->override_download_set) { |
| 3587 |
if (!qmicli_read_yes_no_from_string (value, &(props->override_download))) { |
| 3588 |
g_set_error (error, |
| 3589 |
QMI_CORE_ERROR, |
| 3590 |
QMI_CORE_ERROR_FAILED, |
| 3591 |
"unknown override-download '%s'", |
| 3592 |
value); |
| 3593 |
return FALSE; |
| 3594 |
} |
| 3595 |
props->override_download_set = TRUE; |
| 3596 |
return TRUE; |
| 3597 |
} |
| 3598 |
|
| 3599 |
if (g_ascii_strcasecmp (key, "modem-storage-index") == 0 && props->modem_storage_index == -1) { |
| 3600 |
props->modem_storage_index = atoi (value); |
| 3601 |
if (props->modem_storage_index < 0 || props->modem_storage_index > G_MAXUINT8) { |
| 3602 |
g_set_error (error, |
| 3603 |
QMI_CORE_ERROR, |
| 3604 |
QMI_CORE_ERROR_FAILED, |
| 3605 |
"invalid modem-storage-index '%s'", |
| 3606 |
value); |
| 3607 |
return FALSE; |
| 3608 |
} |
| 3609 |
return TRUE; |
| 3610 |
} |
| 3611 |
|
| 3612 |
g_set_error (error, |
| 3613 |
QMI_CORE_ERROR, |
| 3614 |
QMI_CORE_ERROR_FAILED, |
| 3615 |
"unrecognized or duplicate option '%s'", |
| 3616 |
key); |
| 3617 |
return FALSE; |
| 3618 |
} |
| 3619 |
|
| 3620 |
static QmiMessageDmsSetFirmwarePreferenceInput * |
| 3621 |
set_firmware_preference_input_create (const gchar *str, |
| 3622 |
SetFirmwarePreferenceContext *firmware_preference_ctx, |
| 3623 |
GError **error) |
| 3624 |
{ |
| 3625 |
g_autoptr(QmiMessageDmsSetFirmwarePreferenceInput) input = NULL; |
| 3626 |
g_autoptr(GArray) array = NULL; |
| 3627 |
|
| 3628 |
SetFirmwarePreferenceProperties props = { |
| 3629 |
.firmware_version = NULL, |
| 3630 |
.config_version = NULL, |
| 3631 |
.carrier = NULL, |
| 3632 |
.modem_storage_index = -1, |
| 3633 |
.override_download = FALSE, |
| 3634 |
.override_download_set = FALSE, |
| 3635 |
}; |
| 3636 |
|
| 3637 |
/* New key=value format */ |
| 3638 |
if (strchr (str, '=')) { |
| 3639 |
g_autoptr(GError) parse_error = NULL; |
| 3640 |
|
| 3641 |
if (!qmicli_parse_key_value_string (str, |
| 3642 |
&parse_error, |
| 3643 |
set_firmware_preference_properties_handle, |
| 3644 |
&props)) { |
| 3645 |
g_set_error (error, QMI_CORE_ERROR, QMI_CORE_ERROR_FAILED, |
| 3646 |
"Couldn't parse input string: %s", parse_error->message); |
| 3647 |
set_firmware_preference_properties_clear (&props); |
| 3648 |
return NULL; |
| 3649 |
} |
| 3650 |
|
| 3651 |
if (!props.firmware_version || !props.config_version || !props.carrier) { |
| 3652 |
g_set_error (error, QMI_CORE_ERROR, QMI_CORE_ERROR_FAILED, |
| 3653 |
"Missing mandatory parameters: 'firmware-version', 'config-version' and 'carrier' are mandatory"); |
| 3654 |
set_firmware_preference_properties_clear (&props); |
| 3655 |
return NULL; |
| 3656 |
} |
| 3657 |
} |
| 3658 |
/* Old non key=value format, like this: |
| 3659 |
* "[(firmware_version),(config_version),(carrier)]" |
| 3660 |
*/ |
| 3661 |
else { |
| 3662 |
g_auto(GStrv) split = NULL; |
| 3663 |
|
| 3664 |
split = g_strsplit (str, ",", -1); |
| 3665 |
if (g_strv_length (split) != 3) { |
| 3666 |
g_set_error (error, QMI_CORE_ERROR, QMI_CORE_ERROR_FAILED, |
| 3667 |
"Invalid format string, expected 3 elements: 'firmware-version', 'config-version' and 'carrier'"); |
| 3668 |
return NULL; |
| 3669 |
} |
| 3670 |
|
| 3671 |
props.firmware_version = g_strdup (split[0]); |
| 3672 |
props.config_version = g_strdup (split[1]); |
| 3673 |
props.carrier = g_strdup (split[2]); |
| 3674 |
} |
| 3675 |
|
| 3676 |
/* modem unique id is the fixed wildcard string '?_?' matching any pri. |
| 3677 |
* modem build id format is "(firmware_version)_?", matching any carrier */ |
| 3678 |
firmware_preference_ctx->modem_image_id.type = QMI_DMS_FIRMWARE_IMAGE_TYPE_MODEM; |
| 3679 |
firmware_preference_ctx->modem_image_id.unique_id = g_array_sized_new (FALSE, TRUE, 1, 16); |
| 3680 |
g_array_insert_vals (firmware_preference_ctx->modem_image_id.unique_id, 0, "?_?", 3); |
| 3681 |
g_array_set_size (firmware_preference_ctx->modem_image_id.unique_id, 16); |
| 3682 |
firmware_preference_ctx->modem_image_id.build_id = g_strdup_printf ("%s_?", props.firmware_version); |
| 3683 |
|
| 3684 |
/* pri unique id is the "(config_version)" input */ |
| 3685 |
firmware_preference_ctx->pri_image_id.type = QMI_DMS_FIRMWARE_IMAGE_TYPE_PRI; |
| 3686 |
firmware_preference_ctx->pri_image_id.unique_id = g_array_sized_new (FALSE, TRUE, 1, 16); |
| 3687 |
g_array_insert_vals (firmware_preference_ctx->pri_image_id.unique_id, 0, props.config_version, strlen (props.config_version)); |
| 3688 |
g_array_set_size (firmware_preference_ctx->pri_image_id.unique_id, 16); |
| 3689 |
firmware_preference_ctx->pri_image_id.build_id = g_strdup_printf ("%s_%s", props.firmware_version, props.carrier); |
| 3690 |
|
| 3691 |
/* Create an array with both images, the contents of each image struct, |
| 3692 |
* though, aren't owned by the array (i.e. need to be disposed afterwards |
| 3693 |
* when no longer used). */ |
| 3694 |
array = g_array_sized_new (FALSE, FALSE, sizeof (QmiMessageDmsSetFirmwarePreferenceInputListImage), 2); |
| 3695 |
g_array_append_val (array, firmware_preference_ctx->modem_image_id); |
| 3696 |
g_array_append_val (array, firmware_preference_ctx->pri_image_id); |
| 3697 |
|
| 3698 |
/* The input bundle takes a reference to the array itself */ |
| 3699 |
input = qmi_message_dms_set_firmware_preference_input_new (); |
| 3700 |
qmi_message_dms_set_firmware_preference_input_set_list (input, array, NULL); |
| 3701 |
|
| 3702 |
/* Other optional settings */ |
| 3703 |
if (props.modem_storage_index >= 0) |
| 3704 |
qmi_message_dms_set_firmware_preference_input_set_modem_storage_index (input, (guint8)props.modem_storage_index, NULL); |
| 3705 |
if (props.override_download_set) |
| 3706 |
qmi_message_dms_set_firmware_preference_input_set_download_override (input, props.override_download, NULL); |
| 3707 |
|
| 3708 |
set_firmware_preference_properties_clear (&props); |
| 3709 |
return g_steal_pointer (&input); |
| 3710 |
} |
| 3711 |
|
| 3712 |
#endif /* HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE */ |
| 3713 |
|
| 3714 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_BOOT_IMAGE_DOWNLOAD_MODE |
| 3715 |
|
| 3716 |
static void |
| 3717 |
get_boot_image_download_mode_ready (QmiClientDms *client, |
| 3718 |
GAsyncResult *res) |
| 3719 |
{ |
| 3720 |
QmiMessageDmsGetBootImageDownloadModeOutput *output; |
| 3721 |
GError *error = NULL; |
| 3722 |
QmiDmsBootImageDownloadMode mode; |
| 3723 |
|
| 3724 |
output = qmi_client_dms_get_boot_image_download_mode_finish (client, res, &error); |
| 3725 |
if (!output) { |
| 3726 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 3727 |
g_error_free (error); |
| 3728 |
operation_shutdown (FALSE); |
| 3729 |
return; |
| 3730 |
} |
| 3731 |
|
| 3732 |
if (!qmi_message_dms_get_boot_image_download_mode_output_get_result (output, &error)) { |
| 3733 |
g_printerr ("error: couldn't get boot image download mode: %s\n", error->message); |
| 3734 |
g_error_free (error); |
| 3735 |
qmi_message_dms_get_boot_image_download_mode_output_unref (output); |
| 3736 |
operation_shutdown (FALSE); |
| 3737 |
return; |
| 3738 |
} |
| 3739 |
|
| 3740 |
qmi_message_dms_get_boot_image_download_mode_output_get_mode (output, &mode, NULL); |
| 3741 |
|
| 3742 |
g_print ("[%s] Boot image download mode: %s\n", |
| 3743 |
qmi_device_get_path_display (ctx->device), |
| 3744 |
qmi_dms_boot_image_download_mode_get_string (mode)); |
| 3745 |
|
| 3746 |
qmi_message_dms_get_boot_image_download_mode_output_unref (output); |
| 3747 |
operation_shutdown (TRUE); |
| 3748 |
} |
| 3749 |
|
| 3750 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_BOOT_IMAGE_DOWNLOAD_MODE */ |
| 3751 |
|
| 3752 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_BOOT_IMAGE_DOWNLOAD_MODE |
| 3753 |
|
| 3754 |
static QmiMessageDmsSetBootImageDownloadModeInput * |
| 3755 |
set_boot_image_download_mode_input_create (const gchar *str) |
| 3756 |
{ |
| 3757 |
QmiMessageDmsSetBootImageDownloadModeInput *input = NULL; |
| 3758 |
QmiDmsBootImageDownloadMode mode; |
| 3759 |
GError *error = NULL; |
| 3760 |
|
| 3761 |
/* Prepare inputs. |
| 3762 |
* Format of the string is: |
| 3763 |
* [normal|boot-and-recovery] |
| 3764 |
*/ |
| 3765 |
if (!qmicli_read_dms_boot_image_download_mode_from_string (str, &mode)) |
| 3766 |
return NULL; |
| 3767 |
|
| 3768 |
input = qmi_message_dms_set_boot_image_download_mode_input_new (); |
| 3769 |
if (!qmi_message_dms_set_boot_image_download_mode_input_set_mode (input, mode, &error)) { |
| 3770 |
g_printerr ("error: couldn't create input bundle: '%s'\n", error->message); |
| 3771 |
g_error_free (error); |
| 3772 |
qmi_message_dms_set_boot_image_download_mode_input_unref (input); |
| 3773 |
return NULL; |
| 3774 |
} |
| 3775 |
|
| 3776 |
return input; |
| 3777 |
} |
| 3778 |
|
| 3779 |
static void |
| 3780 |
set_boot_image_download_mode_ready (QmiClientDms *client, |
| 3781 |
GAsyncResult *res) |
| 3782 |
{ |
| 3783 |
QmiMessageDmsSetBootImageDownloadModeOutput *output; |
| 3784 |
GError *error = NULL; |
| 3785 |
|
| 3786 |
output = qmi_client_dms_set_boot_image_download_mode_finish (client, res, &error); |
| 3787 |
if (!output) { |
| 3788 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 3789 |
g_error_free (error); |
| 3790 |
operation_shutdown (FALSE); |
| 3791 |
return; |
| 3792 |
} |
| 3793 |
|
| 3794 |
if (!qmi_message_dms_set_boot_image_download_mode_output_get_result (output, &error)) { |
| 3795 |
g_printerr ("error: couldn't set boot image download mode: %s\n", error->message); |
| 3796 |
g_error_free (error); |
| 3797 |
qmi_message_dms_set_boot_image_download_mode_output_unref (output); |
| 3798 |
operation_shutdown (FALSE); |
| 3799 |
return; |
| 3800 |
} |
| 3801 |
|
| 3802 |
g_print ("[%s] Boot image download mode successfully set\n", |
| 3803 |
qmi_device_get_path_display (ctx->device)); |
| 3804 |
|
| 3805 |
qmi_message_dms_set_boot_image_download_mode_output_unref (output); |
| 3806 |
operation_shutdown (TRUE); |
| 3807 |
} |
| 3808 |
|
| 3809 |
#endif /* HAVE_QMI_MESSAGE_DMS_SET_BOOT_IMAGE_DOWNLOAD_MODE */ |
| 3810 |
|
| 3811 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_SOFTWARE_VERSION |
| 3812 |
|
| 3813 |
static void |
| 3814 |
get_software_version_ready (QmiClientDms *client, |
| 3815 |
GAsyncResult *res) |
| 3816 |
{ |
| 3817 |
QmiMessageDmsGetSoftwareVersionOutput *output; |
| 3818 |
GError *error = NULL; |
| 3819 |
const gchar *version; |
| 3820 |
|
| 3821 |
output = qmi_client_dms_get_software_version_finish (client, res, &error); |
| 3822 |
if (!output) { |
| 3823 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 3824 |
g_error_free (error); |
| 3825 |
operation_shutdown (FALSE); |
| 3826 |
return; |
| 3827 |
} |
| 3828 |
|
| 3829 |
if (!qmi_message_dms_get_software_version_output_get_result (output, &error)) { |
| 3830 |
g_printerr ("error: couldn't get boot image download mode: %s\n", error->message); |
| 3831 |
g_error_free (error); |
| 3832 |
qmi_message_dms_get_software_version_output_unref (output); |
| 3833 |
operation_shutdown (FALSE); |
| 3834 |
return; |
| 3835 |
} |
| 3836 |
|
| 3837 |
qmi_message_dms_get_software_version_output_get_version (output, &version, NULL); |
| 3838 |
|
| 3839 |
g_print ("[%s] Software version: %s\n", |
| 3840 |
qmi_device_get_path_display (ctx->device), |
| 3841 |
version); |
| 3842 |
|
| 3843 |
qmi_message_dms_get_software_version_output_unref (output); |
| 3844 |
operation_shutdown (TRUE); |
| 3845 |
} |
| 3846 |
|
| 3847 |
#endif |
| 3848 |
|
| 3849 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FCC_AUTHENTICATION |
| 3850 |
|
| 3851 |
static void |
| 3852 |
set_fcc_authentication_ready (QmiClientDms *client, |
| 3853 |
GAsyncResult *res) |
| 3854 |
{ |
| 3855 |
QmiMessageDmsSetFccAuthenticationOutput *output; |
| 3856 |
GError *error = NULL; |
| 3857 |
|
| 3858 |
output = qmi_client_dms_set_fcc_authentication_finish (client, res, &error); |
| 3859 |
if (!output) { |
| 3860 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 3861 |
g_error_free (error); |
| 3862 |
operation_shutdown (FALSE); |
| 3863 |
return; |
| 3864 |
} |
| 3865 |
|
| 3866 |
if (!qmi_message_dms_set_fcc_authentication_output_get_result (output, &error)) { |
| 3867 |
g_printerr ("error: couldn't set FCC authentication: %s\n", error->message); |
| 3868 |
g_error_free (error); |
| 3869 |
qmi_message_dms_set_fcc_authentication_output_unref (output); |
| 3870 |
operation_shutdown (FALSE); |
| 3871 |
return; |
| 3872 |
} |
| 3873 |
|
| 3874 |
g_print ("[%s] Successfully set FCC authentication\n", |
| 3875 |
qmi_device_get_path_display (ctx->device)); |
| 3876 |
|
| 3877 |
qmi_message_dms_set_fcc_authentication_output_unref (output); |
| 3878 |
operation_shutdown (TRUE); |
| 3879 |
} |
| 3880 |
|
| 3881 |
#endif /* HAVE_QMI_MESSAGE_DMS_SET_FCC_AUTHENTICATION */ |
| 3882 |
|
| 3883 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_SUPPORTED_MESSAGES |
| 3884 |
|
| 3885 |
static void |
| 3886 |
get_supported_messages_ready (QmiClientDms *client, |
| 3887 |
GAsyncResult *res) |
| 3888 |
{ |
| 3889 |
QmiMessageDmsGetSupportedMessagesOutput *output; |
| 3890 |
GError *error = NULL; |
| 3891 |
GArray *bytearray = NULL; |
| 3892 |
gchar *str; |
| 3893 |
|
| 3894 |
output = qmi_client_dms_get_supported_messages_finish (client, res, &error); |
| 3895 |
if (!output) { |
| 3896 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 3897 |
g_error_free (error); |
| 3898 |
operation_shutdown (FALSE); |
| 3899 |
return; |
| 3900 |
} |
| 3901 |
|
| 3902 |
if (!qmi_message_dms_get_supported_messages_output_get_result (output, &error)) { |
| 3903 |
g_printerr ("error: couldn't get supported DMS messages: %s\n", error->message); |
| 3904 |
g_error_free (error); |
| 3905 |
qmi_message_dms_get_supported_messages_output_unref (output); |
| 3906 |
operation_shutdown (FALSE); |
| 3907 |
return; |
| 3908 |
} |
| 3909 |
|
| 3910 |
g_print ("[%s] Successfully got supported DMS messages:\n", |
| 3911 |
qmi_device_get_path_display (ctx->device)); |
| 3912 |
|
| 3913 |
qmi_message_dms_get_supported_messages_output_get_list (output, &bytearray, NULL); |
| 3914 |
str = qmicli_get_supported_messages_list (bytearray ? (const guint8 *)bytearray->data : NULL, |
| 3915 |
bytearray ? bytearray->len : 0); |
| 3916 |
g_print ("%s", str); |
| 3917 |
g_free (str); |
| 3918 |
|
| 3919 |
qmi_message_dms_get_supported_messages_output_unref (output); |
| 3920 |
operation_shutdown (TRUE); |
| 3921 |
} |
| 3922 |
|
| 3923 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_SUPPORTED_MESSAGES */ |
| 3924 |
|
| 3925 |
#if defined HAVE_QMI_MESSAGE_DMS_HP_CHANGE_DEVICE_MODE |
| 3926 |
|
| 3927 |
static QmiMessageDmsHpChangeDeviceModeInput * |
| 3928 |
hp_change_device_mode_input_create (const gchar *str) |
| 3929 |
{ |
| 3930 |
QmiMessageDmsHpChangeDeviceModeInput *input = NULL; |
| 3931 |
QmiDmsHpDeviceMode mode; |
| 3932 |
GError *error = NULL; |
| 3933 |
|
| 3934 |
if (!qmicli_read_dms_hp_device_mode_from_string (str, &mode)) { |
| 3935 |
g_printerr ("error: couldn't parse input HP device mode : '%s'\n", str); |
| 3936 |
return NULL; |
| 3937 |
} |
| 3938 |
|
| 3939 |
input = qmi_message_dms_hp_change_device_mode_input_new (); |
| 3940 |
if (!qmi_message_dms_hp_change_device_mode_input_set_mode (input, mode, &error)) { |
| 3941 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 3942 |
error->message); |
| 3943 |
g_error_free (error); |
| 3944 |
qmi_message_dms_hp_change_device_mode_input_unref (input); |
| 3945 |
return NULL; |
| 3946 |
} |
| 3947 |
|
| 3948 |
return input; |
| 3949 |
} |
| 3950 |
|
| 3951 |
static void |
| 3952 |
hp_change_device_mode_ready (QmiClientDms *client, |
| 3953 |
GAsyncResult *res) |
| 3954 |
{ |
| 3955 |
QmiMessageDmsHpChangeDeviceModeOutput *output; |
| 3956 |
GError *error = NULL; |
| 3957 |
|
| 3958 |
output = qmi_client_dms_hp_change_device_mode_finish (client, res, &error); |
| 3959 |
if (!output) { |
| 3960 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 3961 |
g_error_free (error); |
| 3962 |
operation_shutdown (FALSE); |
| 3963 |
return; |
| 3964 |
} |
| 3965 |
|
| 3966 |
if (!qmi_message_dms_hp_change_device_mode_output_get_result (output, &error)) { |
| 3967 |
g_printerr ("error: couldn't change HP device mode: %s\n", error->message); |
| 3968 |
g_error_free (error); |
| 3969 |
qmi_message_dms_hp_change_device_mode_output_unref (output); |
| 3970 |
operation_shutdown (FALSE); |
| 3971 |
return; |
| 3972 |
} |
| 3973 |
|
| 3974 |
g_print ("[%s] Successfully changed HP device mode\n", |
| 3975 |
qmi_device_get_path_display (ctx->device)); |
| 3976 |
|
| 3977 |
qmi_message_dms_hp_change_device_mode_output_unref (output); |
| 3978 |
|
| 3979 |
/* Changing the mode will end up power cycling the device right away, so |
| 3980 |
* just ignore any error from now on and don't even try to release the |
| 3981 |
* client CID */ |
| 3982 |
operation_shutdown_skip_cid_release (TRUE); |
| 3983 |
} |
| 3984 |
|
| 3985 |
#endif /* HAVE_QMI_MESSAGE_DMS_HP_CHANGE_DEVICE_MODE */ |
| 3986 |
|
| 3987 |
#if defined HAVE_QMI_MESSAGE_DMS_SWI_GET_CURRENT_FIRMWARE |
| 3988 |
|
| 3989 |
static void |
| 3990 |
swi_get_current_firmware_ready (QmiClientDms *client, |
| 3991 |
GAsyncResult *res) |
| 3992 |
{ |
| 3993 |
QmiMessageDmsSwiGetCurrentFirmwareOutput *output; |
| 3994 |
GError *error = NULL; |
| 3995 |
const gchar *model = NULL; |
| 3996 |
const gchar *boot_version = NULL; |
| 3997 |
const gchar *amss_version = NULL; |
| 3998 |
const gchar *sku_id = NULL; |
| 3999 |
const gchar *package_id = NULL; |
| 4000 |
const gchar *carrier_id = NULL; |
| 4001 |
const gchar *pri_version = NULL; |
| 4002 |
const gchar *carrier = NULL; |
| 4003 |
const gchar *config_version = NULL; |
| 4004 |
|
| 4005 |
output = qmi_client_dms_swi_get_current_firmware_finish (client, res, &error); |
| 4006 |
if (!output) { |
| 4007 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 4008 |
g_error_free (error); |
| 4009 |
operation_shutdown (FALSE); |
| 4010 |
return; |
| 4011 |
} |
| 4012 |
|
| 4013 |
if (!qmi_message_dms_swi_get_current_firmware_output_get_result (output, &error)) { |
| 4014 |
g_printerr ("error: couldn't get current firmware: %s\n", error->message); |
| 4015 |
g_error_free (error); |
| 4016 |
qmi_message_dms_swi_get_current_firmware_output_unref (output); |
| 4017 |
operation_shutdown (FALSE); |
| 4018 |
return; |
| 4019 |
} |
| 4020 |
|
| 4021 |
qmi_message_dms_swi_get_current_firmware_output_get_model (output, &model, NULL); |
| 4022 |
qmi_message_dms_swi_get_current_firmware_output_get_boot_version (output, &boot_version, NULL); |
| 4023 |
qmi_message_dms_swi_get_current_firmware_output_get_amss_version (output, &amss_version, NULL); |
| 4024 |
qmi_message_dms_swi_get_current_firmware_output_get_sku_id (output, &sku_id, NULL); |
| 4025 |
qmi_message_dms_swi_get_current_firmware_output_get_package_id (output, &package_id, NULL); |
| 4026 |
qmi_message_dms_swi_get_current_firmware_output_get_carrier_id (output, &carrier_id, NULL); |
| 4027 |
qmi_message_dms_swi_get_current_firmware_output_get_pri_version (output, &pri_version, NULL); |
| 4028 |
qmi_message_dms_swi_get_current_firmware_output_get_carrier (output, &carrier, NULL); |
| 4029 |
qmi_message_dms_swi_get_current_firmware_output_get_config_version (output, &config_version, NULL); |
| 4030 |
|
| 4031 |
/* We'll consider it a success if we got at least one of the expected strings */ |
| 4032 |
if (!model && |
| 4033 |
!boot_version && |
| 4034 |
!amss_version && |
| 4035 |
!sku_id && |
| 4036 |
!package_id && |
| 4037 |
!carrier_id && |
| 4038 |
!pri_version && |
| 4039 |
!carrier && |
| 4040 |
!config_version) { |
| 4041 |
g_printerr ("error: couldn't get any of the current firmware fields\n"); |
| 4042 |
qmi_message_dms_swi_get_current_firmware_output_unref (output); |
| 4043 |
operation_shutdown (FALSE); |
| 4044 |
return; |
| 4045 |
} |
| 4046 |
|
| 4047 |
g_print ("[%s] Successfully retrieved current firmware:\n", |
| 4048 |
qmi_device_get_path_display (ctx->device)); |
| 4049 |
g_print ("\tModel: %s\n", VALIDATE_UNKNOWN (model)); |
| 4050 |
g_print ("\tBoot version: %s\n", VALIDATE_UNKNOWN (boot_version)); |
| 4051 |
g_print ("\tAMSS version: %s\n", VALIDATE_UNKNOWN (amss_version)); |
| 4052 |
g_print ("\tSKU ID: %s\n", VALIDATE_UNKNOWN (sku_id)); |
| 4053 |
g_print ("\tPackage ID: %s\n", VALIDATE_UNKNOWN (package_id)); |
| 4054 |
g_print ("\tCarrier ID: %s\n", VALIDATE_UNKNOWN (carrier_id)); |
| 4055 |
g_print ("\tConfig version: %s\n", VALIDATE_UNKNOWN (config_version)); |
| 4056 |
|
| 4057 |
qmi_message_dms_swi_get_current_firmware_output_unref (output); |
| 4058 |
operation_shutdown (TRUE); |
| 4059 |
} |
| 4060 |
|
| 4061 |
#endif /* HAVE_QMI_MESSAGE_DMS_SWI_GET_CURRENT_FIRMWARE */ |
| 4062 |
|
| 4063 |
#if defined HAVE_QMI_MESSAGE_DMS_SWI_GET_USB_COMPOSITION |
| 4064 |
|
| 4065 |
static void |
| 4066 |
swi_get_usb_composition_ready (QmiClientDms *client, |
| 4067 |
GAsyncResult *res) |
| 4068 |
{ |
| 4069 |
QmiMessageDmsSwiGetUsbCompositionOutput *output; |
| 4070 |
GError *error = NULL; |
| 4071 |
GArray *supported = NULL; |
| 4072 |
QmiDmsSwiUsbComposition current = QMI_DMS_SWI_USB_COMPOSITION_UNKNOWN; |
| 4073 |
guint i; |
| 4074 |
|
| 4075 |
output = qmi_client_dms_swi_get_usb_composition_finish (client, res, &error); |
| 4076 |
if (!output) { |
| 4077 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 4078 |
g_error_free (error); |
| 4079 |
operation_shutdown (FALSE); |
| 4080 |
return; |
| 4081 |
} |
| 4082 |
|
| 4083 |
if (!qmi_message_dms_swi_get_usb_composition_output_get_result (output, &error)) { |
| 4084 |
g_printerr ("error: couldn't get USB composite modes: %s\n", error->message); |
| 4085 |
g_error_free (error); |
| 4086 |
qmi_message_dms_swi_get_usb_composition_output_unref (output); |
| 4087 |
operation_shutdown (FALSE); |
| 4088 |
return; |
| 4089 |
} |
| 4090 |
|
| 4091 |
g_print ("[%s] Successfully retrieved USB compositions:\n", |
| 4092 |
qmi_device_get_path_display (ctx->device)); |
| 4093 |
|
| 4094 |
if (!qmi_message_dms_swi_get_usb_composition_output_get_current (output, ¤t, &error)) { |
| 4095 |
g_printerr ("error: couldn't get current USB composition: %s\n", error->message); |
| 4096 |
g_clear_error (&error); |
| 4097 |
} |
| 4098 |
|
| 4099 |
if (!qmi_message_dms_swi_get_usb_composition_output_get_supported (output, &supported, &error)) { |
| 4100 |
g_printerr ("error: couldn't get list of USB compositions: %s\n", error->message); |
| 4101 |
g_clear_error (&error); |
| 4102 |
} |
| 4103 |
|
| 4104 |
for (i = 0; i < supported->len; i++) { |
| 4105 |
QmiDmsSwiUsbComposition value; |
| 4106 |
|
| 4107 |
value = g_array_index (supported, QmiDmsSwiUsbComposition, i); |
| 4108 |
g_print ("\t%sUSB composition %s: %s\n", |
| 4109 |
(value == current ? "[*] " : " "), |
| 4110 |
qmi_dms_swi_usb_composition_get_string (value), |
| 4111 |
qmi_dms_swi_usb_composition_get_description (value)); |
| 4112 |
} |
| 4113 |
|
| 4114 |
qmi_message_dms_swi_get_usb_composition_output_unref (output); |
| 4115 |
operation_shutdown (TRUE); |
| 4116 |
} |
| 4117 |
|
| 4118 |
#endif /* HAVE_QMI_MESSAGE_DMS_SWI_GET_USB_COMPOSITION */ |
| 4119 |
|
| 4120 |
#if defined HAVE_QMI_MESSAGE_DMS_SWI_SET_USB_COMPOSITION |
| 4121 |
|
| 4122 |
static void |
| 4123 |
swi_set_usb_composition_ready (QmiClientDms *client, |
| 4124 |
GAsyncResult *res) |
| 4125 |
{ |
| 4126 |
QmiMessageDmsSwiSetUsbCompositionOutput *output; |
| 4127 |
GError *error = NULL; |
| 4128 |
|
| 4129 |
output = qmi_client_dms_swi_set_usb_composition_finish (client, res, &error); |
| 4130 |
if (!output) { |
| 4131 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 4132 |
g_error_free (error); |
| 4133 |
operation_shutdown (FALSE); |
| 4134 |
return; |
| 4135 |
} |
| 4136 |
|
| 4137 |
if (!qmi_message_dms_swi_set_usb_composition_output_get_result (output, &error)) { |
| 4138 |
g_printerr ("error: couldn't set USB composite modes: %s\n", error->message); |
| 4139 |
g_error_free (error); |
| 4140 |
qmi_message_dms_swi_set_usb_composition_output_unref (output); |
| 4141 |
operation_shutdown (FALSE); |
| 4142 |
return; |
| 4143 |
} |
| 4144 |
|
| 4145 |
g_print ("[%s] Successfully set USB composition\n" |
| 4146 |
"\n" |
| 4147 |
"\tYou may want to power-cycle the modem now, or just set it offline and reset it:\n" |
| 4148 |
"\t\t$> sudo qmicli ... --dms-set-operating-mode=offline\n" |
| 4149 |
"\t\t$> sudo qmicli ... --dms-set-operating-mode=reset\n" |
| 4150 |
"\n", |
| 4151 |
qmi_device_get_path_display (ctx->device)); |
| 4152 |
|
| 4153 |
qmi_message_dms_swi_set_usb_composition_output_unref (output); |
| 4154 |
operation_shutdown (TRUE); |
| 4155 |
} |
| 4156 |
|
| 4157 |
static QmiMessageDmsSwiSetUsbCompositionInput * |
| 4158 |
swi_set_usb_composition_input_create (const gchar *str) |
| 4159 |
{ |
| 4160 |
QmiMessageDmsSwiSetUsbCompositionInput *input = NULL; |
| 4161 |
QmiDmsSwiUsbComposition value; |
| 4162 |
GError *error = NULL; |
| 4163 |
|
| 4164 |
if (!qmicli_read_dms_swi_usb_composition_from_string (str, &value)) |
| 4165 |
return NULL; |
| 4166 |
|
| 4167 |
input = qmi_message_dms_swi_set_usb_composition_input_new (); |
| 4168 |
if (!qmi_message_dms_swi_set_usb_composition_input_set_current (input, value, &error)) { |
| 4169 |
g_printerr ("error: couldn't create input bundle: '%s'\n", error->message); |
| 4170 |
g_error_free (error); |
| 4171 |
qmi_message_dms_swi_set_usb_composition_input_unref (input); |
| 4172 |
return NULL; |
| 4173 |
} |
| 4174 |
|
| 4175 |
return input; |
| 4176 |
} |
| 4177 |
|
| 4178 |
#endif /* HAVE_QMI_MESSAGE_DMS_SWI_SET_USB_COMPOSITION */ |
| 4179 |
|
| 4180 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_CHANGE_DEVICE_MODE |
| 4181 |
|
| 4182 |
static QmiMessageDmsFoxconnChangeDeviceModeInput * |
| 4183 |
foxconn_change_device_mode_input_create (const gchar *str) |
| 4184 |
{ |
| 4185 |
QmiMessageDmsFoxconnChangeDeviceModeInput *input = NULL; |
| 4186 |
QmiDmsFoxconnDeviceMode mode; |
| 4187 |
GError *error = NULL; |
| 4188 |
|
| 4189 |
if (!qmicli_read_dms_foxconn_device_mode_from_string (str, &mode)) { |
| 4190 |
g_printerr ("error: couldn't parse input foxconn device mode : '%s'\n", str); |
| 4191 |
return NULL; |
| 4192 |
} |
| 4193 |
|
| 4194 |
input = qmi_message_dms_foxconn_change_device_mode_input_new (); |
| 4195 |
if (!qmi_message_dms_foxconn_change_device_mode_input_set_mode (input, mode, &error)) { |
| 4196 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 4197 |
error->message); |
| 4198 |
g_error_free (error); |
| 4199 |
qmi_message_dms_foxconn_change_device_mode_input_unref (input); |
| 4200 |
return NULL; |
| 4201 |
} |
| 4202 |
|
| 4203 |
return input; |
| 4204 |
} |
| 4205 |
|
| 4206 |
static void |
| 4207 |
foxconn_change_device_mode_ready (QmiClientDms *client, |
| 4208 |
GAsyncResult *res) |
| 4209 |
{ |
| 4210 |
QmiMessageDmsFoxconnChangeDeviceModeOutput *output; |
| 4211 |
GError *error = NULL; |
| 4212 |
|
| 4213 |
output = qmi_client_dms_foxconn_change_device_mode_finish (client, res, &error); |
| 4214 |
if (!output) { |
| 4215 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 4216 |
g_error_free (error); |
| 4217 |
operation_shutdown (FALSE); |
| 4218 |
return; |
| 4219 |
} |
| 4220 |
|
| 4221 |
if (!qmi_message_dms_foxconn_change_device_mode_output_get_result (output, &error)) { |
| 4222 |
g_printerr ("error: couldn't change foxconn device mode: %s\n", error->message); |
| 4223 |
g_error_free (error); |
| 4224 |
qmi_message_dms_foxconn_change_device_mode_output_unref (output); |
| 4225 |
operation_shutdown (FALSE); |
| 4226 |
return; |
| 4227 |
} |
| 4228 |
|
| 4229 |
g_print ("[%s] Successfully changed foxconn device mode\n", |
| 4230 |
qmi_device_get_path_display (ctx->device)); |
| 4231 |
|
| 4232 |
qmi_message_dms_foxconn_change_device_mode_output_unref (output); |
| 4233 |
|
| 4234 |
/* Changing the mode will end up power cycling the device right away, so |
| 4235 |
* just ignore any error from now on and don't even try to release the |
| 4236 |
* client CID */ |
| 4237 |
operation_shutdown_skip_cid_release (TRUE); |
| 4238 |
} |
| 4239 |
|
| 4240 |
#endif /* HAVE_QMI_MESSAGE_DMS_FOXCONN_CHANGE_DEVICE_MODE */ |
| 4241 |
|
| 4242 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_GET_FIRMWARE_VERSION |
| 4243 |
|
| 4244 |
static QmiMessageDmsFoxconnGetFirmwareVersionInput * |
| 4245 |
foxconn_get_firmware_version_input_create (const gchar *str) |
| 4246 |
{ |
| 4247 |
QmiMessageDmsFoxconnGetFirmwareVersionInput *input = NULL; |
| 4248 |
QmiDmsFoxconnFirmwareVersionType type; |
| 4249 |
GError *error = NULL; |
| 4250 |
|
| 4251 |
if (!qmicli_read_dms_foxconn_firmware_version_type_from_string (str, &type)) { |
| 4252 |
g_printerr ("error: couldn't parse input foxconn firmware version type : '%s'\n", str); |
| 4253 |
return NULL; |
| 4254 |
} |
| 4255 |
|
| 4256 |
input = qmi_message_dms_foxconn_get_firmware_version_input_new (); |
| 4257 |
if (!qmi_message_dms_foxconn_get_firmware_version_input_set_version_type (input, type, &error)) { |
| 4258 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 4259 |
error->message); |
| 4260 |
g_error_free (error); |
| 4261 |
qmi_message_dms_foxconn_get_firmware_version_input_unref (input); |
| 4262 |
return NULL; |
| 4263 |
} |
| 4264 |
|
| 4265 |
return input; |
| 4266 |
} |
| 4267 |
|
| 4268 |
static void |
| 4269 |
foxconn_get_firmware_version_ready (QmiClientDms *client, |
| 4270 |
GAsyncResult *res) |
| 4271 |
{ |
| 4272 |
const gchar *str = NULL; |
| 4273 |
QmiMessageDmsFoxconnGetFirmwareVersionOutput *output; |
| 4274 |
GError *error = NULL; |
| 4275 |
|
| 4276 |
output = qmi_client_dms_foxconn_get_firmware_version_finish (client, res, &error); |
| 4277 |
if (!output) { |
| 4278 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 4279 |
g_error_free (error); |
| 4280 |
operation_shutdown (FALSE); |
| 4281 |
return; |
| 4282 |
} |
| 4283 |
|
| 4284 |
if (!qmi_message_dms_foxconn_get_firmware_version_output_get_result (output, &error)) { |
| 4285 |
g_printerr ("error: couldn't get foxconn firmware version: %s\n", error->message); |
| 4286 |
g_error_free (error); |
| 4287 |
qmi_message_dms_foxconn_get_firmware_version_output_unref (output); |
| 4288 |
operation_shutdown (FALSE); |
| 4289 |
return; |
| 4290 |
} |
| 4291 |
|
| 4292 |
qmi_message_dms_foxconn_get_firmware_version_output_get_version (output, &str, NULL); |
| 4293 |
|
| 4294 |
g_print ("[%s] Firmware version retrieved:\n" |
| 4295 |
"\tVersion: '%s'\n", |
| 4296 |
qmi_device_get_path_display (ctx->device), |
| 4297 |
VALIDATE_UNKNOWN (str)); |
| 4298 |
|
| 4299 |
qmi_message_dms_foxconn_get_firmware_version_output_unref (output); |
| 4300 |
operation_shutdown (TRUE); |
| 4301 |
} |
| 4302 |
|
| 4303 |
#endif /* HAVE_QMI_MESSAGE_DMS_FOXCONN_GET_FIRMWARE_VERSION */ |
| 4304 |
|
| 4305 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION |
| 4306 |
|
| 4307 |
static void |
| 4308 |
foxconn_set_fcc_authentication_ready (QmiClientDms *client, |
| 4309 |
GAsyncResult *res) |
| 4310 |
{ |
| 4311 |
g_autoptr(QmiMessageDmsFoxconnSetFccAuthenticationOutput) output = NULL; |
| 4312 |
g_autoptr(GError) error = NULL; |
| 4313 |
|
| 4314 |
output = qmi_client_dms_foxconn_set_fcc_authentication_finish (client, res, &error); |
| 4315 |
if (!output) { |
| 4316 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 4317 |
operation_shutdown (FALSE); |
| 4318 |
return; |
| 4319 |
} |
| 4320 |
|
| 4321 |
if (!qmi_message_dms_foxconn_set_fcc_authentication_output_get_result (output, &error)) { |
| 4322 |
g_printerr ("error: couldn't run Foxconn FCC authentication: %s\n", error->message); |
| 4323 |
operation_shutdown (FALSE); |
| 4324 |
return; |
| 4325 |
} |
| 4326 |
|
| 4327 |
g_print ("[%s] Successfully run Foxconn FCC authentication\n", |
| 4328 |
qmi_device_get_path_display (ctx->device)); |
| 4329 |
operation_shutdown (TRUE); |
| 4330 |
} |
| 4331 |
|
| 4332 |
#endif /* HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION */ |
| 4333 |
|
| 4334 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION_V2 |
| 4335 |
|
| 4336 |
static void |
| 4337 |
foxconn_set_fcc_authentication_v2_ready (QmiClientDms *client, |
| 4338 |
GAsyncResult *res) |
| 4339 |
{ |
| 4340 |
g_autoptr(QmiMessageDmsFoxconnSetFccAuthenticationV2Output) output = NULL; |
| 4341 |
g_autoptr(GError) error = NULL; |
| 4342 |
|
| 4343 |
output = qmi_client_dms_foxconn_set_fcc_authentication_v2_finish (client, res, &error); |
| 4344 |
if (!output) { |
| 4345 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 4346 |
operation_shutdown (FALSE); |
| 4347 |
return; |
| 4348 |
} |
| 4349 |
|
| 4350 |
if (!qmi_message_dms_foxconn_set_fcc_authentication_v2_output_get_result (output, &error)) { |
| 4351 |
g_printerr ("error: couldn't run Foxconn FCC authentication: %s\n", error->message); |
| 4352 |
operation_shutdown (FALSE); |
| 4353 |
return; |
| 4354 |
} |
| 4355 |
|
| 4356 |
g_print ("[%s] Successfully run Foxconn FCC authentication v2\n", |
| 4357 |
qmi_device_get_path_display (ctx->device)); |
| 4358 |
operation_shutdown (TRUE); |
| 4359 |
} |
| 4360 |
|
| 4361 |
#endif /* HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION_V2 */ |
| 4362 |
|
| 4363 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_MAC_ADDRESS |
| 4364 |
|
| 4365 |
static QmiMessageDmsGetMacAddressInput * |
| 4366 |
get_mac_address_input_create (const gchar *str) |
| 4367 |
{ |
| 4368 |
QmiMessageDmsGetMacAddressInput *input = NULL; |
| 4369 |
QmiDmsMacType device; |
| 4370 |
|
| 4371 |
if (qmicli_read_dms_mac_type_from_string (str, &device)) { |
| 4372 |
GError *error = NULL; |
| 4373 |
|
| 4374 |
input = qmi_message_dms_get_mac_address_input_new (); |
| 4375 |
if (!qmi_message_dms_get_mac_address_input_set_device ( |
| 4376 |
input, |
| 4377 |
device, |
| 4378 |
&error)) { |
| 4379 |
g_printerr ("error: couldn't create input data bundle: '%s'\n", |
| 4380 |
error->message); |
| 4381 |
g_error_free (error); |
| 4382 |
qmi_message_dms_get_mac_address_input_unref (input); |
| 4383 |
input = NULL; |
| 4384 |
} |
| 4385 |
} |
| 4386 |
|
| 4387 |
return input; |
| 4388 |
} |
| 4389 |
|
| 4390 |
static void |
| 4391 |
get_mac_address_ready (QmiClientDms *client, |
| 4392 |
GAsyncResult *res) |
| 4393 |
{ |
| 4394 |
QmiMessageDmsGetMacAddressOutput *output; |
| 4395 |
GError *error = NULL; |
| 4396 |
gchar *mac_address_printable; |
| 4397 |
GArray *mac_address = NULL; |
| 4398 |
|
| 4399 |
output = qmi_client_dms_get_mac_address_finish (client, res, &error); |
| 4400 |
if (!output) { |
| 4401 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 4402 |
g_error_free (error); |
| 4403 |
operation_shutdown (FALSE); |
| 4404 |
return; |
| 4405 |
} |
| 4406 |
|
| 4407 |
if (!qmi_message_dms_get_mac_address_output_get_result (output, &error)) { |
| 4408 |
g_printerr ("error: couldn't get mac address: %s\n", error->message); |
| 4409 |
g_error_free (error); |
| 4410 |
qmi_message_dms_get_mac_address_output_unref (output); |
| 4411 |
operation_shutdown (FALSE); |
| 4412 |
return; |
| 4413 |
} |
| 4414 |
|
| 4415 |
qmi_message_dms_get_mac_address_output_get_mac_address (output, &mac_address, NULL); |
| 4416 |
mac_address_printable = qmicli_get_raw_data_printable (mac_address, 80, "\t\t"); |
| 4417 |
|
| 4418 |
g_print ("[%s] MAC address read:\n" |
| 4419 |
"\tSize: '%u' bytes\n" |
| 4420 |
"\tContents:\n" |
| 4421 |
"%s", |
| 4422 |
qmi_device_get_path_display (ctx->device), |
| 4423 |
mac_address->len, |
| 4424 |
mac_address_printable); |
| 4425 |
g_free (mac_address_printable); |
| 4426 |
|
| 4427 |
qmi_message_dms_get_mac_address_output_unref (output); |
| 4428 |
operation_shutdown (TRUE); |
| 4429 |
} |
| 4430 |
|
| 4431 |
#endif /* HAVE_QMI_MESSAGE_DMS_GET_MAC_ADDRESS */ |
| 4432 |
|
| 4433 |
#if defined HAVE_QMI_MESSAGE_DMS_RESET |
| 4434 |
|
| 4435 |
static void |
| 4436 |
reset_ready (QmiClientDms *client, |
| 4437 |
GAsyncResult *res) |
| 4438 |
{ |
| 4439 |
QmiMessageDmsResetOutput *output; |
| 4440 |
GError *error = NULL; |
| 4441 |
|
| 4442 |
output = qmi_client_dms_reset_finish (client, res, &error); |
| 4443 |
if (!output) { |
| 4444 |
g_printerr ("error: operation failed: %s\n", error->message); |
| 4445 |
g_error_free (error); |
| 4446 |
operation_shutdown (FALSE); |
| 4447 |
return; |
| 4448 |
} |
| 4449 |
|
| 4450 |
if (!qmi_message_dms_reset_output_get_result (output, &error)) { |
| 4451 |
g_printerr ("error: couldn't reset the DMS service: %s\n", error->message); |
| 4452 |
g_error_free (error); |
| 4453 |
qmi_message_dms_reset_output_unref (output); |
| 4454 |
operation_shutdown (FALSE); |
| 4455 |
return; |
| 4456 |
} |
| 4457 |
|
| 4458 |
g_print ("[%s] Successfully performed DMS service reset\n", |
| 4459 |
qmi_device_get_path_display (ctx->device)); |
| 4460 |
|
| 4461 |
qmi_message_dms_reset_output_unref (output); |
| 4462 |
operation_shutdown (TRUE); |
| 4463 |
} |
| 4464 |
|
| 4465 |
#endif /* HAVE_QMI_MESSAGE_DMS_RESET */ |
| 4466 |
|
| 4467 |
static gboolean |
| 4468 |
noop_cb (gpointer unused) |
| 4469 |
{ |
| 4470 |
operation_shutdown (TRUE); |
| 4471 |
return FALSE; |
| 4472 |
} |
| 4473 |
|
| 4474 |
void |
| 4475 |
qmicli_dms_run (QmiDevice *device, |
| 4476 |
QmiClientDms *client, |
| 4477 |
GCancellable *cancellable) |
| 4478 |
{ |
| 4479 |
/* Initialize context */ |
| 4480 |
ctx = g_slice_new (Context); |
| 4481 |
ctx->device = g_object_ref (device); |
| 4482 |
ctx->client = g_object_ref (client); |
| 4483 |
ctx->cancellable = g_object_ref (cancellable); |
| 4484 |
|
| 4485 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_IDS |
| 4486 |
if (get_ids_flag) { |
| 4487 |
g_debug ("Asynchronously getting IDs..."); |
| 4488 |
qmi_client_dms_get_ids (ctx->client, |
| 4489 |
NULL, |
| 4490 |
10, |
| 4491 |
ctx->cancellable, |
| 4492 |
(GAsyncReadyCallback)get_ids_ready, |
| 4493 |
NULL); |
| 4494 |
return; |
| 4495 |
} |
| 4496 |
#endif |
| 4497 |
|
| 4498 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_CAPABILITIES |
| 4499 |
if (get_capabilities_flag) { |
| 4500 |
g_debug ("Asynchronously getting capabilities..."); |
| 4501 |
qmi_client_dms_get_capabilities (ctx->client, |
| 4502 |
NULL, |
| 4503 |
10, |
| 4504 |
ctx->cancellable, |
| 4505 |
(GAsyncReadyCallback)get_capabilities_ready, |
| 4506 |
NULL); |
| 4507 |
return; |
| 4508 |
} |
| 4509 |
#endif |
| 4510 |
|
| 4511 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_MANUFACTURER |
| 4512 |
if (get_manufacturer_flag) { |
| 4513 |
g_debug ("Asynchronously getting manufacturer..."); |
| 4514 |
qmi_client_dms_get_manufacturer (ctx->client, |
| 4515 |
NULL, |
| 4516 |
10, |
| 4517 |
ctx->cancellable, |
| 4518 |
(GAsyncReadyCallback)get_manufacturer_ready, |
| 4519 |
NULL); |
| 4520 |
return; |
| 4521 |
} |
| 4522 |
#endif |
| 4523 |
|
| 4524 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_MODEL |
| 4525 |
if (get_model_flag) { |
| 4526 |
g_debug ("Asynchronously getting model..."); |
| 4527 |
qmi_client_dms_get_model (ctx->client, |
| 4528 |
NULL, |
| 4529 |
10, |
| 4530 |
ctx->cancellable, |
| 4531 |
(GAsyncReadyCallback)get_model_ready, |
| 4532 |
NULL); |
| 4533 |
return; |
| 4534 |
} |
| 4535 |
#endif |
| 4536 |
|
| 4537 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_REVISION |
| 4538 |
if (get_revision_flag) { |
| 4539 |
g_debug ("Asynchronously getting revision..."); |
| 4540 |
qmi_client_dms_get_revision (ctx->client, |
| 4541 |
NULL, |
| 4542 |
10, |
| 4543 |
ctx->cancellable, |
| 4544 |
(GAsyncReadyCallback)get_revision_ready, |
| 4545 |
NULL); |
| 4546 |
return; |
| 4547 |
} |
| 4548 |
#endif |
| 4549 |
|
| 4550 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_MSISDN |
| 4551 |
if (get_msisdn_flag) { |
| 4552 |
g_debug ("Asynchronously getting msisdn..."); |
| 4553 |
qmi_client_dms_get_msisdn (ctx->client, |
| 4554 |
NULL, |
| 4555 |
10, |
| 4556 |
ctx->cancellable, |
| 4557 |
(GAsyncReadyCallback)get_msisdn_ready, |
| 4558 |
NULL); |
| 4559 |
return; |
| 4560 |
} |
| 4561 |
#endif |
| 4562 |
|
| 4563 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_POWER_STATE |
| 4564 |
if (get_power_state_flag) { |
| 4565 |
g_debug ("Asynchronously getting power status..."); |
| 4566 |
qmi_client_dms_get_power_state (ctx->client, |
| 4567 |
NULL, |
| 4568 |
10, |
| 4569 |
ctx->cancellable, |
| 4570 |
(GAsyncReadyCallback)get_power_state_ready, |
| 4571 |
NULL); |
| 4572 |
return; |
| 4573 |
} |
| 4574 |
#endif |
| 4575 |
|
| 4576 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_SET_PIN_PROTECTION |
| 4577 |
if (uim_set_pin_protection_str) { |
| 4578 |
QmiMessageDmsUimSetPinProtectionInput *input; |
| 4579 |
|
| 4580 |
g_debug ("Asynchronously setting PIN protection..."); |
| 4581 |
input = uim_set_pin_protection_input_create (uim_set_pin_protection_str); |
| 4582 |
if (!input) { |
| 4583 |
operation_shutdown (FALSE); |
| 4584 |
return; |
| 4585 |
} |
| 4586 |
qmi_client_dms_uim_set_pin_protection (ctx->client, |
| 4587 |
input, |
| 4588 |
10, |
| 4589 |
ctx->cancellable, |
| 4590 |
(GAsyncReadyCallback)uim_set_pin_protection_ready, |
| 4591 |
NULL); |
| 4592 |
qmi_message_dms_uim_set_pin_protection_input_unref (input); |
| 4593 |
return; |
| 4594 |
} |
| 4595 |
#endif |
| 4596 |
|
| 4597 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_VERIFY_PIN |
| 4598 |
if (uim_verify_pin_str) { |
| 4599 |
QmiMessageDmsUimVerifyPinInput *input; |
| 4600 |
|
| 4601 |
g_debug ("Asynchronously verifying PIN..."); |
| 4602 |
input = uim_verify_pin_input_create (uim_verify_pin_str); |
| 4603 |
if (!input) { |
| 4604 |
operation_shutdown (FALSE); |
| 4605 |
return; |
| 4606 |
} |
| 4607 |
qmi_client_dms_uim_verify_pin (ctx->client, |
| 4608 |
input, |
| 4609 |
10, |
| 4610 |
ctx->cancellable, |
| 4611 |
(GAsyncReadyCallback)uim_verify_pin_ready, |
| 4612 |
NULL); |
| 4613 |
qmi_message_dms_uim_verify_pin_input_unref (input); |
| 4614 |
return; |
| 4615 |
} |
| 4616 |
#endif |
| 4617 |
|
| 4618 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_UNBLOCK_PIN |
| 4619 |
if (uim_unblock_pin_str) { |
| 4620 |
QmiMessageDmsUimUnblockPinInput *input; |
| 4621 |
|
| 4622 |
g_debug ("Asynchronously unblocking PIN..."); |
| 4623 |
input = uim_unblock_pin_input_create (uim_unblock_pin_str); |
| 4624 |
if (!input) { |
| 4625 |
operation_shutdown (FALSE); |
| 4626 |
return; |
| 4627 |
} |
| 4628 |
qmi_client_dms_uim_unblock_pin (ctx->client, |
| 4629 |
input, |
| 4630 |
10, |
| 4631 |
ctx->cancellable, |
| 4632 |
(GAsyncReadyCallback)uim_unblock_pin_ready, |
| 4633 |
NULL); |
| 4634 |
qmi_message_dms_uim_unblock_pin_input_unref (input); |
| 4635 |
return; |
| 4636 |
} |
| 4637 |
#endif |
| 4638 |
|
| 4639 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_CHANGE_PIN |
| 4640 |
if (uim_change_pin_str) { |
| 4641 |
QmiMessageDmsUimChangePinInput *input; |
| 4642 |
|
| 4643 |
g_debug ("Asynchronously changing PIN..."); |
| 4644 |
input = uim_change_pin_input_create (uim_change_pin_str); |
| 4645 |
if (!input) { |
| 4646 |
operation_shutdown (FALSE); |
| 4647 |
return; |
| 4648 |
} |
| 4649 |
qmi_client_dms_uim_change_pin (ctx->client, |
| 4650 |
input, |
| 4651 |
10, |
| 4652 |
ctx->cancellable, |
| 4653 |
(GAsyncReadyCallback)uim_change_pin_ready, |
| 4654 |
NULL); |
| 4655 |
qmi_message_dms_uim_change_pin_input_unref (input); |
| 4656 |
return; |
| 4657 |
} |
| 4658 |
#endif |
| 4659 |
|
| 4660 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_PIN_STATUS |
| 4661 |
if (uim_get_pin_status_flag) { |
| 4662 |
g_debug ("Asynchronously getting PIN status..."); |
| 4663 |
qmi_client_dms_uim_get_pin_status (ctx->client, |
| 4664 |
NULL, |
| 4665 |
10, |
| 4666 |
ctx->cancellable, |
| 4667 |
(GAsyncReadyCallback)uim_get_pin_status_ready, |
| 4668 |
NULL); |
| 4669 |
return; |
| 4670 |
} |
| 4671 |
#endif |
| 4672 |
|
| 4673 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_ICCID |
| 4674 |
if (uim_get_iccid_flag) { |
| 4675 |
g_debug ("Asynchronously getting UIM ICCID..."); |
| 4676 |
qmi_client_dms_uim_get_iccid (ctx->client, |
| 4677 |
NULL, |
| 4678 |
10, |
| 4679 |
ctx->cancellable, |
| 4680 |
(GAsyncReadyCallback)uim_get_iccid_ready, |
| 4681 |
NULL); |
| 4682 |
return; |
| 4683 |
} |
| 4684 |
#endif |
| 4685 |
|
| 4686 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_IMSI |
| 4687 |
if (uim_get_imsi_flag) { |
| 4688 |
g_debug ("Asynchronously getting UIM IMSI..."); |
| 4689 |
qmi_client_dms_uim_get_imsi (ctx->client, |
| 4690 |
NULL, |
| 4691 |
10, |
| 4692 |
ctx->cancellable, |
| 4693 |
(GAsyncReadyCallback)uim_get_imsi_ready, |
| 4694 |
NULL); |
| 4695 |
return; |
| 4696 |
} |
| 4697 |
#endif |
| 4698 |
|
| 4699 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_STATE |
| 4700 |
if (uim_get_state_flag) { |
| 4701 |
g_debug ("Asynchronously getting UIM state..."); |
| 4702 |
qmi_client_dms_uim_get_state (ctx->client, |
| 4703 |
NULL, |
| 4704 |
10, |
| 4705 |
ctx->cancellable, |
| 4706 |
(GAsyncReadyCallback)uim_get_state_ready, |
| 4707 |
NULL); |
| 4708 |
return; |
| 4709 |
} |
| 4710 |
#endif |
| 4711 |
|
| 4712 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_HARDWARE_REVISION |
| 4713 |
if (get_hardware_revision_flag) { |
| 4714 |
g_debug ("Asynchronously getting hardware revision..."); |
| 4715 |
qmi_client_dms_get_hardware_revision (ctx->client, |
| 4716 |
NULL, |
| 4717 |
10, |
| 4718 |
ctx->cancellable, |
| 4719 |
(GAsyncReadyCallback)get_hardware_revision_ready, |
| 4720 |
NULL); |
| 4721 |
return; |
| 4722 |
} |
| 4723 |
#endif |
| 4724 |
|
| 4725 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_OPERATING_MODE |
| 4726 |
if (get_operating_mode_flag) { |
| 4727 |
g_debug ("Asynchronously getting operating mode..."); |
| 4728 |
qmi_client_dms_get_operating_mode (ctx->client, |
| 4729 |
NULL, |
| 4730 |
10, |
| 4731 |
ctx->cancellable, |
| 4732 |
(GAsyncReadyCallback)get_operating_mode_ready, |
| 4733 |
NULL); |
| 4734 |
return; |
| 4735 |
} |
| 4736 |
#endif |
| 4737 |
|
| 4738 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_OPERATING_MODE |
| 4739 |
if (set_operating_mode_str) { |
| 4740 |
QmiMessageDmsSetOperatingModeInput *input; |
| 4741 |
|
| 4742 |
g_debug ("Asynchronously setting operating mode..."); |
| 4743 |
input = set_operating_mode_input_create (set_operating_mode_str); |
| 4744 |
if (!input) { |
| 4745 |
operation_shutdown (FALSE); |
| 4746 |
return; |
| 4747 |
} |
| 4748 |
qmi_client_dms_set_operating_mode (ctx->client, |
| 4749 |
input, |
| 4750 |
10, |
| 4751 |
ctx->cancellable, |
| 4752 |
(GAsyncReadyCallback)set_operating_mode_ready, |
| 4753 |
NULL); |
| 4754 |
qmi_message_dms_set_operating_mode_input_unref (input); |
| 4755 |
return; |
| 4756 |
} |
| 4757 |
#endif |
| 4758 |
|
| 4759 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_TIME |
| 4760 |
if (get_time_flag) { |
| 4761 |
g_debug ("Asynchronously getting time..."); |
| 4762 |
qmi_client_dms_get_time (ctx->client, |
| 4763 |
NULL, |
| 4764 |
10, |
| 4765 |
ctx->cancellable, |
| 4766 |
(GAsyncReadyCallback)get_time_ready, |
| 4767 |
NULL); |
| 4768 |
return; |
| 4769 |
} |
| 4770 |
#endif |
| 4771 |
|
| 4772 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_PRL_VERSION |
| 4773 |
if (get_prl_version_flag) { |
| 4774 |
g_debug ("Asynchronously getting PRL version..."); |
| 4775 |
qmi_client_dms_get_prl_version (ctx->client, |
| 4776 |
NULL, |
| 4777 |
10, |
| 4778 |
ctx->cancellable, |
| 4779 |
(GAsyncReadyCallback)get_prl_version_ready, |
| 4780 |
NULL); |
| 4781 |
return; |
| 4782 |
} |
| 4783 |
#endif |
| 4784 |
|
| 4785 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_ACTIVATION_STATE |
| 4786 |
if (get_activation_state_flag) { |
| 4787 |
g_debug ("Asynchronously getting activation state..."); |
| 4788 |
qmi_client_dms_get_activation_state (ctx->client, |
| 4789 |
NULL, |
| 4790 |
10, |
| 4791 |
ctx->cancellable, |
| 4792 |
(GAsyncReadyCallback)get_activation_state_ready, |
| 4793 |
NULL); |
| 4794 |
return; |
| 4795 |
} |
| 4796 |
#endif |
| 4797 |
|
| 4798 |
#if defined HAVE_QMI_MESSAGE_DMS_ACTIVATE_AUTOMATIC |
| 4799 |
if (activate_automatic_str) { |
| 4800 |
QmiMessageDmsActivateAutomaticInput *input; |
| 4801 |
|
| 4802 |
g_debug ("Asynchronously requesting automatic activation..."); |
| 4803 |
input = activate_automatic_input_create (activate_automatic_str); |
| 4804 |
if (!input) { |
| 4805 |
operation_shutdown (FALSE); |
| 4806 |
return; |
| 4807 |
} |
| 4808 |
qmi_client_dms_activate_automatic (ctx->client, |
| 4809 |
input, |
| 4810 |
10, |
| 4811 |
ctx->cancellable, |
| 4812 |
(GAsyncReadyCallback)activate_automatic_ready, |
| 4813 |
NULL); |
| 4814 |
qmi_message_dms_activate_automatic_input_unref (input); |
| 4815 |
return; |
| 4816 |
} |
| 4817 |
#endif |
| 4818 |
|
| 4819 |
#if defined HAVE_QMI_MESSAGE_DMS_ACTIVATE_MANUAL |
| 4820 |
if (activate_manual_str) { |
| 4821 |
QmiMessageDmsActivateManualInput *input; |
| 4822 |
|
| 4823 |
g_debug ("Asynchronously requesting manual activation..."); |
| 4824 |
input = activate_manual_input_create (activate_manual_str); |
| 4825 |
if (!input) { |
| 4826 |
operation_shutdown (FALSE); |
| 4827 |
return; |
| 4828 |
} |
| 4829 |
qmi_client_dms_activate_manual (ctx->client, |
| 4830 |
input, |
| 4831 |
10, |
| 4832 |
ctx->cancellable, |
| 4833 |
(GAsyncReadyCallback)activate_manual_ready, |
| 4834 |
NULL); |
| 4835 |
qmi_message_dms_activate_manual_input_unref (input); |
| 4836 |
return; |
| 4837 |
} |
| 4838 |
#endif |
| 4839 |
|
| 4840 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_USER_LOCK_STATE |
| 4841 |
if (get_user_lock_state_flag) { |
| 4842 |
g_debug ("Asynchronously getting user lock state..."); |
| 4843 |
qmi_client_dms_get_user_lock_state (ctx->client, |
| 4844 |
NULL, |
| 4845 |
10, |
| 4846 |
ctx->cancellable, |
| 4847 |
(GAsyncReadyCallback)get_user_lock_state_ready, |
| 4848 |
NULL); |
| 4849 |
return; |
| 4850 |
} |
| 4851 |
#endif |
| 4852 |
|
| 4853 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_USER_LOCK_STATE |
| 4854 |
if (set_user_lock_state_str) { |
| 4855 |
QmiMessageDmsSetUserLockStateInput *input; |
| 4856 |
|
| 4857 |
g_debug ("Asynchronously setting user lock state..."); |
| 4858 |
input = set_user_lock_state_input_create (set_user_lock_state_str); |
| 4859 |
if (!input) { |
| 4860 |
operation_shutdown (FALSE); |
| 4861 |
return; |
| 4862 |
} |
| 4863 |
qmi_client_dms_set_user_lock_state (ctx->client, |
| 4864 |
input, |
| 4865 |
10, |
| 4866 |
ctx->cancellable, |
| 4867 |
(GAsyncReadyCallback)set_user_lock_state_ready, |
| 4868 |
NULL); |
| 4869 |
qmi_message_dms_set_user_lock_state_input_unref (input); |
| 4870 |
return; |
| 4871 |
} |
| 4872 |
#endif |
| 4873 |
|
| 4874 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_USER_LOCK_CODE |
| 4875 |
if (set_user_lock_code_str) { |
| 4876 |
QmiMessageDmsSetUserLockCodeInput *input; |
| 4877 |
|
| 4878 |
g_debug ("Asynchronously changing user lock code..."); |
| 4879 |
input = set_user_lock_code_input_create (set_user_lock_code_str); |
| 4880 |
if (!input) { |
| 4881 |
operation_shutdown (FALSE); |
| 4882 |
return; |
| 4883 |
} |
| 4884 |
qmi_client_dms_set_user_lock_code (ctx->client, |
| 4885 |
input, |
| 4886 |
10, |
| 4887 |
ctx->cancellable, |
| 4888 |
(GAsyncReadyCallback)set_user_lock_code_ready, |
| 4889 |
NULL); |
| 4890 |
qmi_message_dms_set_user_lock_code_input_unref (input); |
| 4891 |
return; |
| 4892 |
} |
| 4893 |
#endif |
| 4894 |
|
| 4895 |
#if defined HAVE_QMI_MESSAGE_DMS_READ_USER_DATA |
| 4896 |
if (read_user_data_flag) { |
| 4897 |
g_debug ("Asynchronously reading user data..."); |
| 4898 |
qmi_client_dms_read_user_data (ctx->client, |
| 4899 |
NULL, |
| 4900 |
10, |
| 4901 |
ctx->cancellable, |
| 4902 |
(GAsyncReadyCallback)read_user_data_ready, |
| 4903 |
NULL); |
| 4904 |
return; |
| 4905 |
} |
| 4906 |
#endif |
| 4907 |
|
| 4908 |
#if defined HAVE_QMI_MESSAGE_DMS_WRITE_USER_DATA |
| 4909 |
if (write_user_data_str) { |
| 4910 |
QmiMessageDmsWriteUserDataInput *input; |
| 4911 |
|
| 4912 |
g_debug ("Asynchronously writing user data..."); |
| 4913 |
input = write_user_data_input_create (write_user_data_str); |
| 4914 |
if (!input) { |
| 4915 |
operation_shutdown (FALSE); |
| 4916 |
return; |
| 4917 |
} |
| 4918 |
qmi_client_dms_write_user_data (ctx->client, |
| 4919 |
input, |
| 4920 |
10, |
| 4921 |
ctx->cancellable, |
| 4922 |
(GAsyncReadyCallback)write_user_data_ready, |
| 4923 |
NULL); |
| 4924 |
qmi_message_dms_write_user_data_input_unref (input); |
| 4925 |
return; |
| 4926 |
} |
| 4927 |
#endif |
| 4928 |
|
| 4929 |
#if defined HAVE_QMI_MESSAGE_DMS_READ_ERI_FILE |
| 4930 |
if (read_eri_file_flag) { |
| 4931 |
g_debug ("Asynchronously reading ERI file..."); |
| 4932 |
qmi_client_dms_read_eri_file (ctx->client, |
| 4933 |
NULL, |
| 4934 |
10, |
| 4935 |
ctx->cancellable, |
| 4936 |
(GAsyncReadyCallback)read_eri_file_ready, |
| 4937 |
NULL); |
| 4938 |
return; |
| 4939 |
} |
| 4940 |
#endif |
| 4941 |
|
| 4942 |
#if defined HAVE_QMI_MESSAGE_DMS_RESTORE_FACTORY_DEFAULTS |
| 4943 |
if (restore_factory_defaults_str) { |
| 4944 |
QmiMessageDmsRestoreFactoryDefaultsInput *input; |
| 4945 |
|
| 4946 |
g_debug ("Asynchronously restoring factory defaults..."); |
| 4947 |
input = restore_factory_defaults_input_create (restore_factory_defaults_str); |
| 4948 |
if (!input) { |
| 4949 |
operation_shutdown (FALSE); |
| 4950 |
return; |
| 4951 |
} |
| 4952 |
qmi_client_dms_restore_factory_defaults (ctx->client, |
| 4953 |
input, |
| 4954 |
10, |
| 4955 |
ctx->cancellable, |
| 4956 |
(GAsyncReadyCallback)restore_factory_defaults_ready, |
| 4957 |
NULL); |
| 4958 |
qmi_message_dms_restore_factory_defaults_input_unref (input); |
| 4959 |
return; |
| 4960 |
} |
| 4961 |
#endif |
| 4962 |
|
| 4963 |
#if defined HAVE_QMI_MESSAGE_DMS_VALIDATE_SERVICE_PROGRAMMING_CODE |
| 4964 |
if (validate_service_programming_code_str) { |
| 4965 |
QmiMessageDmsValidateServiceProgrammingCodeInput *input; |
| 4966 |
|
| 4967 |
g_debug ("Asynchronously validating SPC..."); |
| 4968 |
input = validate_service_programming_code_input_create (validate_service_programming_code_str); |
| 4969 |
if (!input) { |
| 4970 |
operation_shutdown (FALSE); |
| 4971 |
return; |
| 4972 |
} |
| 4973 |
qmi_client_dms_validate_service_programming_code (ctx->client, |
| 4974 |
input, |
| 4975 |
10, |
| 4976 |
ctx->cancellable, |
| 4977 |
(GAsyncReadyCallback)validate_service_programming_code_ready, |
| 4978 |
NULL); |
| 4979 |
qmi_message_dms_validate_service_programming_code_input_unref (input); |
| 4980 |
return; |
| 4981 |
} |
| 4982 |
#endif |
| 4983 |
|
| 4984 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_ID |
| 4985 |
if (set_firmware_id_flag) { |
| 4986 |
g_debug ("Asynchronously setting firmware id..."); |
| 4987 |
qmi_client_dms_set_firmware_id (ctx->client, |
| 4988 |
NULL, |
| 4989 |
10, |
| 4990 |
ctx->cancellable, |
| 4991 |
(GAsyncReadyCallback)set_firmware_id_ready, |
| 4992 |
NULL); |
| 4993 |
return; |
| 4994 |
} |
| 4995 |
#endif |
| 4996 |
|
| 4997 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_GET_CK_STATUS |
| 4998 |
if (uim_get_ck_status_str) { |
| 4999 |
QmiMessageDmsUimGetCkStatusInput *input; |
| 5000 |
|
| 5001 |
g_debug ("Asynchronously getting CK status..."); |
| 5002 |
input = uim_get_ck_status_input_create (uim_get_ck_status_str); |
| 5003 |
if (!input) { |
| 5004 |
operation_shutdown (FALSE); |
| 5005 |
return; |
| 5006 |
} |
| 5007 |
qmi_client_dms_uim_get_ck_status (ctx->client, |
| 5008 |
input, |
| 5009 |
10, |
| 5010 |
ctx->cancellable, |
| 5011 |
(GAsyncReadyCallback)uim_get_ck_status_ready, |
| 5012 |
NULL); |
| 5013 |
qmi_message_dms_uim_get_ck_status_input_unref (input); |
| 5014 |
return; |
| 5015 |
} |
| 5016 |
#endif |
| 5017 |
|
| 5018 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_SET_CK_PROTECTION |
| 5019 |
if (uim_set_ck_protection_str) { |
| 5020 |
QmiMessageDmsUimSetCkProtectionInput *input; |
| 5021 |
|
| 5022 |
g_debug ("Asynchronously setting CK protection..."); |
| 5023 |
input = uim_set_ck_protection_input_create (uim_set_ck_protection_str); |
| 5024 |
if (!input) { |
| 5025 |
operation_shutdown (FALSE); |
| 5026 |
return; |
| 5027 |
} |
| 5028 |
qmi_client_dms_uim_set_ck_protection (ctx->client, |
| 5029 |
input, |
| 5030 |
10, |
| 5031 |
ctx->cancellable, |
| 5032 |
(GAsyncReadyCallback)uim_set_ck_protection_ready, |
| 5033 |
NULL); |
| 5034 |
qmi_message_dms_uim_set_ck_protection_input_unref (input); |
| 5035 |
return; |
| 5036 |
} |
| 5037 |
#endif |
| 5038 |
|
| 5039 |
#if defined HAVE_QMI_MESSAGE_DMS_UIM_UNBLOCK_CK |
| 5040 |
if (uim_unblock_ck_str) { |
| 5041 |
QmiMessageDmsUimUnblockCkInput *input; |
| 5042 |
|
| 5043 |
g_debug ("Asynchronously unblocking CK..."); |
| 5044 |
input = uim_unblock_ck_input_create (uim_unblock_ck_str); |
| 5045 |
if (!input) { |
| 5046 |
operation_shutdown (FALSE); |
| 5047 |
return; |
| 5048 |
} |
| 5049 |
qmi_client_dms_uim_unblock_ck (ctx->client, |
| 5050 |
input, |
| 5051 |
10, |
| 5052 |
ctx->cancellable, |
| 5053 |
(GAsyncReadyCallback)uim_unblock_ck_ready, |
| 5054 |
NULL); |
| 5055 |
qmi_message_dms_uim_unblock_ck_input_unref (input); |
| 5056 |
return; |
| 5057 |
} |
| 5058 |
#endif |
| 5059 |
|
| 5060 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_BAND_CAPABILITIES |
| 5061 |
if (get_band_capabilities_flag) { |
| 5062 |
g_debug ("Asynchronously getting band capabilities..."); |
| 5063 |
qmi_client_dms_get_band_capabilities (ctx->client, |
| 5064 |
NULL, |
| 5065 |
10, |
| 5066 |
ctx->cancellable, |
| 5067 |
(GAsyncReadyCallback)get_band_capabilities_ready, |
| 5068 |
NULL); |
| 5069 |
return; |
| 5070 |
} |
| 5071 |
#endif |
| 5072 |
|
| 5073 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_FACTORY_SKU |
| 5074 |
if (get_factory_sku_flag) { |
| 5075 |
g_debug ("Asynchronously getting factory SKU..."); |
| 5076 |
qmi_client_dms_get_factory_sku (ctx->client, |
| 5077 |
NULL, |
| 5078 |
10, |
| 5079 |
ctx->cancellable, |
| 5080 |
(GAsyncReadyCallback)get_factory_sku_ready, |
| 5081 |
NULL); |
| 5082 |
return; |
| 5083 |
} |
| 5084 |
#endif |
| 5085 |
|
| 5086 |
#if defined HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES && defined HAVE_QMI_MESSAGE_DMS_GET_STORED_IMAGE_INFO |
| 5087 |
if (list_stored_images_flag) { |
| 5088 |
g_debug ("Asynchronously listing stored images..."); |
| 5089 |
qmi_client_dms_list_stored_images (ctx->client, |
| 5090 |
NULL, |
| 5091 |
10, |
| 5092 |
ctx->cancellable, |
| 5093 |
(GAsyncReadyCallback)list_stored_images_ready, |
| 5094 |
NULL); |
| 5095 |
return; |
| 5096 |
} |
| 5097 |
#endif |
| 5098 |
|
| 5099 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE && \ |
| 5100 |
defined HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES |
| 5101 |
if (select_stored_image_str) { |
| 5102 |
g_debug ("Asynchronously selecting stored image..."); |
| 5103 |
get_stored_image (ctx->client, |
| 5104 |
select_stored_image_str, |
| 5105 |
(GAsyncReadyCallback)get_stored_image_select_ready, |
| 5106 |
NULL); |
| 5107 |
return; |
| 5108 |
} |
| 5109 |
#endif |
| 5110 |
|
| 5111 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE && \ |
| 5112 |
defined HAVE_QMI_MESSAGE_DMS_LIST_STORED_IMAGES && \ |
| 5113 |
defined HAVE_QMI_MESSAGE_DMS_DELETE_STORED_IMAGE |
| 5114 |
if (delete_stored_image_str) { |
| 5115 |
g_debug ("Asynchronously deleting stored image..."); |
| 5116 |
get_stored_image (ctx->client, |
| 5117 |
delete_stored_image_str, |
| 5118 |
(GAsyncReadyCallback)get_stored_image_delete_ready, |
| 5119 |
NULL); |
| 5120 |
return; |
| 5121 |
} |
| 5122 |
#endif |
| 5123 |
|
| 5124 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_FIRMWARE_PREFERENCE |
| 5125 |
if (get_firmware_preference_flag) { |
| 5126 |
qmi_client_dms_get_firmware_preference ( |
| 5127 |
client, |
| 5128 |
NULL, |
| 5129 |
10, |
| 5130 |
NULL, |
| 5131 |
(GAsyncReadyCallback)dms_get_firmware_preference_ready, |
| 5132 |
NULL); |
| 5133 |
return; |
| 5134 |
} |
| 5135 |
#endif |
| 5136 |
|
| 5137 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FIRMWARE_PREFERENCE |
| 5138 |
if (set_firmware_preference_str) { |
| 5139 |
g_autoptr(GError) error = NULL; |
| 5140 |
g_autoptr(QmiMessageDmsSetFirmwarePreferenceInput) input = NULL; |
| 5141 |
SetFirmwarePreferenceContext firmware_preference_ctx; |
| 5142 |
|
| 5143 |
memset (&firmware_preference_ctx, 0, sizeof (firmware_preference_ctx)); |
| 5144 |
|
| 5145 |
g_debug ("Asynchronously setting firmware preference..."); |
| 5146 |
input = set_firmware_preference_input_create (set_firmware_preference_str, &firmware_preference_ctx, &error); |
| 5147 |
if (!input) { |
| 5148 |
g_printerr ("error: %s\n", error->message); |
| 5149 |
operation_shutdown (FALSE); |
| 5150 |
return; |
| 5151 |
} |
| 5152 |
|
| 5153 |
qmi_client_dms_set_firmware_preference ( |
| 5154 |
client, |
| 5155 |
input, |
| 5156 |
10, |
| 5157 |
NULL, |
| 5158 |
(GAsyncReadyCallback)dms_set_firmware_preference_ready, |
| 5159 |
NULL); |
| 5160 |
set_firmware_preference_context_clear (&firmware_preference_ctx); |
| 5161 |
return; |
| 5162 |
} |
| 5163 |
#endif |
| 5164 |
|
| 5165 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_BOOT_IMAGE_DOWNLOAD_MODE |
| 5166 |
if (get_boot_image_download_mode_flag) { |
| 5167 |
g_debug ("Asynchronously getting boot image download mode..."); |
| 5168 |
qmi_client_dms_get_boot_image_download_mode (ctx->client, |
| 5169 |
NULL, |
| 5170 |
10, |
| 5171 |
ctx->cancellable, |
| 5172 |
(GAsyncReadyCallback)get_boot_image_download_mode_ready, |
| 5173 |
NULL); |
| 5174 |
return; |
| 5175 |
} |
| 5176 |
#endif |
| 5177 |
|
| 5178 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_BOOT_IMAGE_DOWNLOAD_MODE |
| 5179 |
if (set_boot_image_download_mode_str) { |
| 5180 |
QmiMessageDmsSetBootImageDownloadModeInput *input; |
| 5181 |
|
| 5182 |
g_debug ("Asynchronously setting boot image download mode..."); |
| 5183 |
input = set_boot_image_download_mode_input_create (set_boot_image_download_mode_str); |
| 5184 |
if (!input) { |
| 5185 |
operation_shutdown (FALSE); |
| 5186 |
return; |
| 5187 |
} |
| 5188 |
qmi_client_dms_set_boot_image_download_mode (ctx->client, |
| 5189 |
input, |
| 5190 |
10, |
| 5191 |
ctx->cancellable, |
| 5192 |
(GAsyncReadyCallback)set_boot_image_download_mode_ready, |
| 5193 |
NULL); |
| 5194 |
qmi_message_dms_set_boot_image_download_mode_input_unref (input); |
| 5195 |
return; |
| 5196 |
} |
| 5197 |
#endif |
| 5198 |
|
| 5199 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_SOFTWARE_VERSION |
| 5200 |
if (get_software_version_flag) { |
| 5201 |
g_debug ("Asynchronously getting software version..."); |
| 5202 |
qmi_client_dms_get_software_version (ctx->client, |
| 5203 |
NULL, |
| 5204 |
10, |
| 5205 |
ctx->cancellable, |
| 5206 |
(GAsyncReadyCallback)get_software_version_ready, |
| 5207 |
NULL); |
| 5208 |
return; |
| 5209 |
} |
| 5210 |
#endif |
| 5211 |
|
| 5212 |
#if defined HAVE_QMI_MESSAGE_DMS_SET_FCC_AUTHENTICATION |
| 5213 |
if (set_fcc_authentication_flag) { |
| 5214 |
g_debug ("Asynchronously setting FCC auth..."); |
| 5215 |
qmi_client_dms_set_fcc_authentication (ctx->client, |
| 5216 |
NULL, |
| 5217 |
10, |
| 5218 |
ctx->cancellable, |
| 5219 |
(GAsyncReadyCallback)set_fcc_authentication_ready, |
| 5220 |
NULL); |
| 5221 |
return; |
| 5222 |
} |
| 5223 |
#endif |
| 5224 |
|
| 5225 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_SUPPORTED_MESSAGES |
| 5226 |
if (get_supported_messages_flag) { |
| 5227 |
g_debug ("Asynchronously getting supported DMS messages..."); |
| 5228 |
qmi_client_dms_get_supported_messages (ctx->client, |
| 5229 |
NULL, |
| 5230 |
10, |
| 5231 |
ctx->cancellable, |
| 5232 |
(GAsyncReadyCallback)get_supported_messages_ready, |
| 5233 |
NULL); |
| 5234 |
return; |
| 5235 |
} |
| 5236 |
#endif |
| 5237 |
|
| 5238 |
#if defined HAVE_QMI_MESSAGE_DMS_HP_CHANGE_DEVICE_MODE |
| 5239 |
if (hp_change_device_mode_str) { |
| 5240 |
QmiMessageDmsHpChangeDeviceModeInput *input; |
| 5241 |
|
| 5242 |
g_debug ("Asynchronously changing device mode (HP specific)..."); |
| 5243 |
|
| 5244 |
input = hp_change_device_mode_input_create (hp_change_device_mode_str); |
| 5245 |
if (!input) { |
| 5246 |
operation_shutdown (FALSE); |
| 5247 |
return; |
| 5248 |
} |
| 5249 |
|
| 5250 |
qmi_client_dms_hp_change_device_mode (ctx->client, |
| 5251 |
input, |
| 5252 |
10, |
| 5253 |
ctx->cancellable, |
| 5254 |
(GAsyncReadyCallback)hp_change_device_mode_ready, |
| 5255 |
NULL); |
| 5256 |
qmi_message_dms_hp_change_device_mode_input_unref (input); |
| 5257 |
return; |
| 5258 |
} |
| 5259 |
#endif |
| 5260 |
|
| 5261 |
#if defined HAVE_QMI_MESSAGE_DMS_SWI_GET_CURRENT_FIRMWARE |
| 5262 |
if (swi_get_current_firmware_flag) { |
| 5263 |
g_debug ("Asynchronously getting current firmware (Sierra Wireless specific)..."); |
| 5264 |
qmi_client_dms_swi_get_current_firmware (ctx->client, |
| 5265 |
NULL, |
| 5266 |
10, |
| 5267 |
ctx->cancellable, |
| 5268 |
(GAsyncReadyCallback)swi_get_current_firmware_ready, |
| 5269 |
NULL); |
| 5270 |
return; |
| 5271 |
} |
| 5272 |
#endif |
| 5273 |
|
| 5274 |
#if defined HAVE_QMI_MESSAGE_DMS_SWI_GET_USB_COMPOSITION |
| 5275 |
if (swi_get_usb_composition_flag) { |
| 5276 |
g_debug ("Asynchronously getting USB compositionss (Sierra Wireless specific)..."); |
| 5277 |
qmi_client_dms_swi_get_usb_composition (ctx->client, |
| 5278 |
NULL, |
| 5279 |
10, |
| 5280 |
ctx->cancellable, |
| 5281 |
(GAsyncReadyCallback)swi_get_usb_composition_ready, |
| 5282 |
NULL); |
| 5283 |
return; |
| 5284 |
} |
| 5285 |
#endif |
| 5286 |
|
| 5287 |
#if defined HAVE_QMI_MESSAGE_DMS_SWI_SET_USB_COMPOSITION |
| 5288 |
if (swi_set_usb_composition_str) { |
| 5289 |
QmiMessageDmsSwiSetUsbCompositionInput *input; |
| 5290 |
|
| 5291 |
g_debug ("Asynchronously setting USB composition (Sierra Wireless specific)..."); |
| 5292 |
|
| 5293 |
input = swi_set_usb_composition_input_create (swi_set_usb_composition_str); |
| 5294 |
if (!input) { |
| 5295 |
operation_shutdown (FALSE); |
| 5296 |
return; |
| 5297 |
} |
| 5298 |
|
| 5299 |
qmi_client_dms_swi_set_usb_composition (ctx->client, |
| 5300 |
input, |
| 5301 |
10, |
| 5302 |
ctx->cancellable, |
| 5303 |
(GAsyncReadyCallback)swi_set_usb_composition_ready, |
| 5304 |
NULL); |
| 5305 |
qmi_message_dms_swi_set_usb_composition_input_unref (input); |
| 5306 |
return; |
| 5307 |
} |
| 5308 |
#endif |
| 5309 |
|
| 5310 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_CHANGE_DEVICE_MODE |
| 5311 |
if (foxconn_change_device_mode_str || dell_change_device_mode_str) { |
| 5312 |
QmiMessageDmsFoxconnChangeDeviceModeInput *input; |
| 5313 |
|
| 5314 |
g_debug ("Asynchronously changing device mode (Foxconn specific)..."); |
| 5315 |
|
| 5316 |
input = foxconn_change_device_mode_input_create (foxconn_change_device_mode_str ? foxconn_change_device_mode_str : dell_change_device_mode_str); |
| 5317 |
if (!input) { |
| 5318 |
operation_shutdown (FALSE); |
| 5319 |
return; |
| 5320 |
} |
| 5321 |
|
| 5322 |
qmi_client_dms_foxconn_change_device_mode (ctx->client, |
| 5323 |
input, |
| 5324 |
10, |
| 5325 |
ctx->cancellable, |
| 5326 |
(GAsyncReadyCallback)foxconn_change_device_mode_ready, |
| 5327 |
NULL); |
| 5328 |
qmi_message_dms_foxconn_change_device_mode_input_unref (input); |
| 5329 |
return; |
| 5330 |
} |
| 5331 |
#endif |
| 5332 |
|
| 5333 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_GET_FIRMWARE_VERSION |
| 5334 |
if (foxconn_get_firmware_version_str || dell_get_firmware_version_str) { |
| 5335 |
QmiMessageDmsFoxconnGetFirmwareVersionInput *input; |
| 5336 |
|
| 5337 |
g_debug ("Asynchronously getting firmware version (Foxconn specific)..."); |
| 5338 |
|
| 5339 |
input = foxconn_get_firmware_version_input_create (foxconn_get_firmware_version_str ? foxconn_get_firmware_version_str : dell_get_firmware_version_str); |
| 5340 |
if (!input) { |
| 5341 |
operation_shutdown (FALSE); |
| 5342 |
return; |
| 5343 |
} |
| 5344 |
|
| 5345 |
qmi_client_dms_foxconn_get_firmware_version (ctx->client, |
| 5346 |
input, |
| 5347 |
10, |
| 5348 |
ctx->cancellable, |
| 5349 |
(GAsyncReadyCallback)foxconn_get_firmware_version_ready, |
| 5350 |
NULL); |
| 5351 |
qmi_message_dms_foxconn_get_firmware_version_input_unref (input); |
| 5352 |
return; |
| 5353 |
} |
| 5354 |
#endif |
| 5355 |
|
| 5356 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION |
| 5357 |
if (foxconn_set_fcc_authentication_int >= 0) { |
| 5358 |
g_autoptr(QmiMessageDmsFoxconnSetFccAuthenticationInput) input = NULL; |
| 5359 |
|
| 5360 |
if (foxconn_set_fcc_authentication_int > 0xFF) { |
| 5361 |
g_printerr ("error: magic value out of [0,255] range\n"); |
| 5362 |
operation_shutdown (FALSE); |
| 5363 |
return; |
| 5364 |
} |
| 5365 |
|
| 5366 |
g_debug ("Asynchronously running Foxconn FCC authentication..."); |
| 5367 |
|
| 5368 |
input = qmi_message_dms_foxconn_set_fcc_authentication_input_new (); |
| 5369 |
qmi_message_dms_foxconn_set_fcc_authentication_input_set_value (input, (guint8)foxconn_set_fcc_authentication_int, NULL); |
| 5370 |
qmi_client_dms_foxconn_set_fcc_authentication (ctx->client, |
| 5371 |
input, |
| 5372 |
10, |
| 5373 |
ctx->cancellable, |
| 5374 |
(GAsyncReadyCallback)foxconn_set_fcc_authentication_ready, |
| 5375 |
NULL); |
| 5376 |
return; |
| 5377 |
} |
| 5378 |
#endif |
| 5379 |
|
| 5380 |
#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION_V2 |
| 5381 |
if (foxconn_set_fcc_authentication_v2_str) { |
| 5382 |
g_autoptr(QmiMessageDmsFoxconnSetFccAuthenticationV2Input) input = NULL; |
| 5383 |
g_auto(GStrv) split = NULL; |
| 5384 |
gulong magic_number; |
| 5385 |
|
| 5386 |
split = g_strsplit (foxconn_set_fcc_authentication_v2_str, ",", -1); |
| 5387 |
if (g_strv_length (split) < 2) { |
| 5388 |
g_printerr ("error: missing fields\n"); |
| 5389 |
operation_shutdown (FALSE); |
| 5390 |
return; |
| 5391 |
} |
| 5392 |
if (g_strv_length (split) > 2) { |
| 5393 |
g_printerr ("error: too many fields given\n"); |
| 5394 |
operation_shutdown (FALSE); |
| 5395 |
return; |
| 5396 |
} |
| 5397 |
|
| 5398 |
magic_number = strtoul (split[1], NULL, 10); |
| 5399 |
if (magic_number > 0xFF) { |
| 5400 |
g_printerr ("error: magic number value out of [0,255] range\n"); |
| 5401 |
operation_shutdown (FALSE); |
| 5402 |
return; |
| 5403 |
} |
| 5404 |
|
| 5405 |
g_debug ("Asynchronously running Foxconn FCC authentication v2..."); |
| 5406 |
|
| 5407 |
input = qmi_message_dms_foxconn_set_fcc_authentication_v2_input_new (); |
| 5408 |
qmi_message_dms_foxconn_set_fcc_authentication_v2_input_set_magic_string (input, split[0], NULL); |
| 5409 |
qmi_message_dms_foxconn_set_fcc_authentication_v2_input_set_magic_number (input, magic_number, NULL); |
| 5410 |
qmi_client_dms_foxconn_set_fcc_authentication_v2 (ctx->client, |
| 5411 |
input, |
| 5412 |
10, |
| 5413 |
ctx->cancellable, |
| 5414 |
(GAsyncReadyCallback)foxconn_set_fcc_authentication_v2_ready, |
| 5415 |
NULL); |
| 5416 |
return; |
| 5417 |
} |
| 5418 |
#endif |
| 5419 |
|
| 5420 |
#if defined HAVE_QMI_MESSAGE_DMS_GET_MAC_ADDRESS |
| 5421 |
if (get_mac_address_str) { |
| 5422 |
QmiMessageDmsGetMacAddressInput *input; |
| 5423 |
|
| 5424 |
g_debug ("Asynchronously getting MAC address..."); |
| 5425 |
|
| 5426 |
input = get_mac_address_input_create (get_mac_address_str); |
| 5427 |
if (!input) { |
| 5428 |
operation_shutdown (FALSE); |
| 5429 |
return; |
| 5430 |
} |
| 5431 |
|
| 5432 |
qmi_client_dms_get_mac_address (ctx->client, |
| 5433 |
input, |
| 5434 |
10, |
| 5435 |
ctx->cancellable, |
| 5436 |
(GAsyncReadyCallback)get_mac_address_ready, |
| 5437 |
NULL); |
| 5438 |
qmi_message_dms_get_mac_address_input_unref (input); |
| 5439 |
return; |
| 5440 |
} |
| 5441 |
#endif |
| 5442 |
|
| 5443 |
#if defined HAVE_QMI_MESSAGE_DMS_RESET |
| 5444 |
if (reset_flag) { |
| 5445 |
g_debug ("Asynchronously resetting DMS service..."); |
| 5446 |
qmi_client_dms_reset (ctx->client, |
| 5447 |
NULL, |
| 5448 |
10, |
| 5449 |
ctx->cancellable, |
| 5450 |
(GAsyncReadyCallback)reset_ready, |
| 5451 |
NULL); |
| 5452 |
return; |
| 5453 |
} |
| 5454 |
#endif |
| 5455 |
|
| 5456 |
/* Just client allocate/release? */ |
| 5457 |
if (noop_flag) { |
| 5458 |
g_idle_add (noop_cb, NULL); |
| 5459 |
return; |
| 5460 |
} |
| 5461 |
|
| 5462 |
g_warn_if_reached (); |
| 5463 |
} |
| 5464 |
|
| 5465 |
#endif /* HAVE_QMI_SERVICE_DMS */ |