aboutsummaryrefslogtreecommitdiff
path: root/cli/mmcli-modem-messaging.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-09-10 16:23:58 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-09-14 07:05:23 +0200
commit47b459603a2605f574d8ea1a7b51d501754d67ac (patch)
tree5aa9ccf09409da0b4ba850df703cab7263f3a8cb /cli/mmcli-modem-messaging.c
parentc7e81d74708ca87d37d374cd8d2f67e9199a3c43 (diff)
cli: new `--messaging-status' action
Currently shows the list of supported SMS storages.
Diffstat (limited to 'cli/mmcli-modem-messaging.c')
-rw-r--r--cli/mmcli-modem-messaging.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/cli/mmcli-modem-messaging.c b/cli/mmcli-modem-messaging.c
index 60f03efb..3446f39f 100644
--- a/cli/mmcli-modem-messaging.c
+++ b/cli/mmcli-modem-messaging.c
@@ -43,11 +43,16 @@ typedef struct {
static Context *ctx;
/* Options */
+static gboolean status_flag;
static gboolean list_flag;
static gchar *create_str;
static gchar *delete_str;
static GOptionEntry entries[] = {
+ { "messaging-status", 0, 0, G_OPTION_ARG_NONE, &status_flag,
+ "Show status of messaging support.",
+ NULL
+ },
{ "list-sms", 0, 0, G_OPTION_ARG_NONE, &list_flag,
"List SMS messages available in a given modem",
NULL
@@ -87,7 +92,8 @@ mmcli_modem_messaging_options_enabled (void)
if (checked)
return !!n_actions;
- n_actions = (list_flag +
+ n_actions = (status_flag +
+ list_flag +
!!create_str +
!!delete_str);
@@ -96,6 +102,9 @@ mmcli_modem_messaging_options_enabled (void)
exit (EXIT_FAILURE);
}
+ if (status_flag)
+ mmcli_force_sync_operation ();
+
checked = TRUE;
return !!n_actions;
}
@@ -140,6 +149,31 @@ mmcli_modem_messaging_shutdown (void)
}
static void
+print_messaging_status (void)
+{
+ MMSmsStorage *supported = NULL;
+ guint supported_len = 0;
+ gchar *supported_str = NULL;
+
+ mm_modem_messaging_get_supported_storages (ctx->modem_messaging,
+ &supported,
+ &supported_len);
+ if (supported)
+ supported_str = mm_common_build_sms_storages_string (supported, supported_len);
+
+#undef VALIDATE_UNKNOWN
+#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
+
+ g_print ("\n"
+ "%s\n"
+ " ----------------------------\n"
+ " Messaging | supported storages: '%s'\n",
+ mm_modem_messaging_get_path (ctx->modem_messaging),
+ VALIDATE_UNKNOWN (supported_str));
+ g_free (supported_str);
+}
+
+static void
print_sms_short_info (MMSms *sms)
{
g_print ("\t%s (%s)\n",
@@ -258,6 +292,9 @@ get_modem_ready (GObject *source,
ensure_modem_messaging ();
+ if (status_flag)
+ g_assert_not_reached ();
+
/* Request to list SMS? */
if (list_flag) {
g_debug ("Asynchronously listing SMS in modem...");
@@ -337,6 +374,13 @@ mmcli_modem_messaging_run_synchronous (GDBusConnection *connection)
ensure_modem_messaging ();
+ /* Request to get location status? */
+ if (status_flag) {
+ g_debug ("Printing messaging status...");
+ print_messaging_status ();
+ return;
+ }
+
/* Request to list the SMS? */
if (list_flag) {
GList *result;