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
This commit is contained in:
@@ -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 ();
|
||||
}
|
||||
|
@@ -320,7 +320,6 @@ mm_common_get_rm_protocol_from_string (const gchar *str,
|
||||
|
||||
enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_CDMA_RM_PROTOCOL));
|
||||
|
||||
|
||||
for (i = 0; enum_class->values[i].value_nick; i++) {
|
||||
if (!g_ascii_strcasecmp (str, enum_class->values[i].value_nick))
|
||||
return enum_class->values[i].value;
|
||||
@@ -356,6 +355,28 @@ mm_common_get_ip_type_from_string (const gchar *str,
|
||||
return MM_BEARER_IP_FAMILY_UNKNOWN;
|
||||
}
|
||||
|
||||
MMSmsStorage
|
||||
mm_common_get_sms_storage_from_string (const gchar *str,
|
||||
GError **error)
|
||||
{
|
||||
GEnumClass *enum_class;
|
||||
guint i;
|
||||
|
||||
enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_SMS_STORAGE));
|
||||
|
||||
for (i = 0; enum_class->values[i].value_nick; i++) {
|
||||
if (!g_ascii_strcasecmp (str, enum_class->values[i].value_nick))
|
||||
return enum_class->values[i].value;
|
||||
}
|
||||
|
||||
g_set_error (error,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_INVALID_ARGS,
|
||||
"Couldn't match '%s' with a valid MMSmsStorage value",
|
||||
str);
|
||||
return MM_SMS_STORAGE_UNKNOWN;
|
||||
}
|
||||
|
||||
GVariant *
|
||||
mm_common_build_bands_unknown (void)
|
||||
{
|
||||
|
@@ -38,6 +38,8 @@ MMModemCdmaRmProtocol mm_common_get_rm_protocol_from_string (const gchar *str,
|
||||
GError **error);
|
||||
MMBearerIpFamily mm_common_get_ip_type_from_string (const gchar *str,
|
||||
GError **error);
|
||||
MMSmsStorage mm_common_get_sms_storage_from_string (const gchar *str,
|
||||
GError **error);
|
||||
|
||||
GArray *mm_common_bands_variant_to_garray (GVariant *variant);
|
||||
MMModemBand *mm_common_bands_variant_to_array (GVariant *variant,
|
||||
|
Reference in New Issue
Block a user