diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-09-10 14:31:16 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-09-14 07:05:23 +0200 |
commit | f0e873b26e036f3a6374ac3859987403cfc01d52 (patch) | |
tree | 0b20f7fb605de5867c52d9596d228575c0ba753f /cli/mmcli-sms.c | |
parent | 667026f0c829ba1be3d69726d7145b3ecd224dbd (diff) | |
download | ModemManager-f0e873b26e036f3a6374ac3859987403cfc01d52.tar.gz |
cli: new `--store-in-storage' action to be able to select where to store the SMS
Expects the storage as the enum nickname string, e.g:
"me" for MM_SMS_STORAGE_ME
or
"sm" for MM_SMS_STORAGE_SM
Diffstat (limited to 'cli/mmcli-sms.c')
-rw-r--r-- | cli/mmcli-sms.c | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/cli/mmcli-sms.c b/cli/mmcli-sms.c index bc45a4a4b..b3e2d66c5 100644 --- a/cli/mmcli-sms.c +++ b/cli/mmcli-sms.c @@ -46,6 +46,7 @@ static Context *ctx; static gboolean info_flag; /* set when no action found */ static gboolean send_flag; static gboolean store_flag; +static gchar *store_in_storage_str; static GOptionEntry entries[] = { { "send", 0, 0, G_OPTION_ARG_NONE, &send_flag, @@ -53,7 +54,11 @@ static GOptionEntry entries[] = { NULL, }, { "store", 0, 0, G_OPTION_ARG_NONE, &store_flag, - "Store the SMS in the device.", + "Store the SMS in the device, at the default storage", + NULL, + }, + { "store-in-storage", 0, 0, G_OPTION_ARG_STRING, &store_in_storage_str, + "Store the SMS in the device, at the specified storage", NULL, }, { NULL } @@ -85,7 +90,8 @@ mmcli_sms_options_enabled (void) return !!n_actions; n_actions = (send_flag + - store_flag); + store_flag + + !!store_in_storage_str); if (n_actions == 0 && mmcli_get_common_sms_string ()) { /* default to info */ @@ -245,6 +251,26 @@ get_sms_ready (GObject *source, return; } + /* Requesting to store the SMS in a specific storage? */ + if (store_in_storage_str) { + MMSmsStorage storage; + GError *error = NULL; + + storage = mm_common_get_sms_storage_from_string (store_in_storage_str, &error); + if (error) { + g_printerr ("error: couldn't store the SMS: '%s'\n", + error->message); + exit (EXIT_FAILURE); + } + + mm_sms_store (ctx->sms, + storage, + ctx->cancellable, + (GAsyncReadyCallback)store_ready, + NULL); + return; + } + g_warn_if_reached (); } @@ -310,5 +336,26 @@ mmcli_sms_run_synchronous (GDBusConnection *connection) return; } + /* Requesting to store the SMS in a specific storage? */ + if (store_in_storage_str) { + gboolean operation_result; + MMSmsStorage storage; + GError *error = NULL; + + storage = mm_common_get_sms_storage_from_string (store_in_storage_str, &error); + if (error) { + g_printerr ("error: couldn't store the SMS: '%s'\n", + error->message); + exit (EXIT_FAILURE); + } + + operation_result = mm_sms_store_sync (ctx->sms, + storage, + NULL, + &error); + store_process_reply (operation_result, error); + return; + } + g_warn_if_reached (); } |