summaryrefslogtreecommitdiff
path: root/cli/mmcli-sms.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-02-09 14:23:18 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-15 14:15:02 +0100
commit2622705744eb27f834abc72fdd8518289d486fda (patch)
tree2f3caad4b3d48a0b63dfe67dc275377035068666 /cli/mmcli-sms.c
parentcee94ef536fa759b5fbd6fcbd20860ba1a32f3ce (diff)
downloadModemManager-2622705744eb27f834abc72fdd8518289d486fda.tar.gz
cli: new `--store' action to store SMS messages
Diffstat (limited to 'cli/mmcli-sms.c')
-rw-r--r--cli/mmcli-sms.c55
1 files changed, 54 insertions, 1 deletions
diff --git a/cli/mmcli-sms.c b/cli/mmcli-sms.c
index eeba1b56a..7d6c30066 100644
--- a/cli/mmcli-sms.c
+++ b/cli/mmcli-sms.c
@@ -45,12 +45,17 @@ static Context *ctx;
/* Options */
static gboolean info_flag; /* set when no action found */
static gboolean send_flag;
+static gboolean store_flag;
static GOptionEntry entries[] = {
{ "send", 0, 0, G_OPTION_ARG_NONE, &send_flag,
"Send SMS.",
NULL,
},
+ { "store", 0, 0, G_OPTION_ARG_NONE, &store_flag,
+ "Store the SMS in the device.",
+ NULL,
+ },
{ NULL }
};
@@ -79,7 +84,8 @@ mmcli_sms_options_enabled (void)
if (checked)
return !!n_actions;
- n_actions = (send_flag);
+ n_actions = (send_flag +
+ store_flag);
if (n_actions == 0 && mmcli_get_common_sms_string ()) {
/* default to info */
@@ -178,6 +184,33 @@ send_ready (MMSms *sms,
}
static void
+store_process_reply (gboolean result,
+ const GError *error)
+{
+ if (!result) {
+ g_printerr ("error: couldn't store the SMS: '%s'\n",
+ error ? error->message : "unknown error");
+ exit (EXIT_FAILURE);
+ }
+
+ g_print ("successfully sent the SMS\n");
+}
+
+static void
+store_ready (MMSms *sms,
+ GAsyncResult *result,
+ gpointer nothing)
+{
+ gboolean operation_result;
+ GError *error = NULL;
+
+ operation_result = mm_sms_store_finish (sms, result, &error);
+ store_process_reply (operation_result, error);
+
+ mmcli_async_operation_done ();
+}
+
+static void
get_sms_ready (GObject *source,
GAsyncResult *result,
gpointer none)
@@ -198,6 +231,15 @@ get_sms_ready (GObject *source,
return;
}
+ /* Requesting to store the SMS? */
+ if (store_flag) {
+ mm_sms_store (ctx->sms,
+ ctx->cancellable,
+ (GAsyncReadyCallback)store_ready,
+ NULL);
+ return;
+ }
+
g_warn_if_reached ();
}
@@ -248,5 +290,16 @@ mmcli_sms_run_synchronous (GDBusConnection *connection)
return;
}
+ /* Requesting to store the SMS? */
+ if (store_flag) {
+ gboolean operation_result;
+
+ operation_result = mm_sms_store_sync (ctx->sms,
+ NULL,
+ &error);
+ store_process_reply (operation_result, error);
+ return;
+ }
+
g_warn_if_reached ();
}