sms: specify storage where the SMS is kept
This commit is contained in:
+49
-34
@@ -3845,7 +3845,9 @@ sms_part_ready (MMBroadbandModem *self,
|
||||
mm_dbg ("Correctly parsed PDU (%d)", ctx->idx);
|
||||
mm_iface_modem_messaging_take_part (MM_IFACE_MODEM_MESSAGING (self),
|
||||
part,
|
||||
MM_SMS_STATE_RECEIVED);
|
||||
MM_SMS_STATE_RECEIVED,
|
||||
/* use default reception (mem3) storage */
|
||||
self->priv->modem_messaging_sms_mem3_storage);
|
||||
} else {
|
||||
/* Don't treat the error as critical */
|
||||
mm_dbg ("Error parsing PDU (%d): %s", ctx->idx, error->message);
|
||||
@@ -3958,6 +3960,21 @@ modem_messaging_cleanup_unsolicited_events (MMIfaceModemMessaging *self,
|
||||
/*****************************************************************************/
|
||||
/* Load initial list of SMS parts (Messaging interface) */
|
||||
|
||||
typedef struct {
|
||||
MMBroadbandModem *self;
|
||||
GSimpleAsyncResult *result;
|
||||
MMSmsStorage list_storage;
|
||||
} ListPartsContext;
|
||||
|
||||
static void
|
||||
list_parts_context_complete_and_free (ListPartsContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete (ctx->result);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_free (ctx);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
modem_messaging_load_initial_sms_parts_finish (MMIfaceModemMessaging *self,
|
||||
GAsyncResult *res,
|
||||
@@ -4031,7 +4048,7 @@ sms_state_from_str (const gchar *str)
|
||||
static void
|
||||
sms_text_part_list_ready (MMBroadbandModem *self,
|
||||
GAsyncResult *res,
|
||||
GSimpleAsyncResult *simple)
|
||||
ListPartsContext *ctx)
|
||||
{
|
||||
GRegex *r;
|
||||
GMatchInfo *match_info = NULL;
|
||||
@@ -4040,9 +4057,8 @@ sms_text_part_list_ready (MMBroadbandModem *self,
|
||||
|
||||
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
|
||||
if (error) {
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
list_parts_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4052,12 +4068,11 @@ sms_text_part_list_ready (MMBroadbandModem *self,
|
||||
g_assert (r);
|
||||
|
||||
if (!g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, NULL)) {
|
||||
g_simple_async_result_set_error (simple,
|
||||
g_simple_async_result_set_error (ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_INVALID_ARGS,
|
||||
"Couldn't parse SMS list response");
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
list_parts_context_complete_and_free (ctx);
|
||||
g_regex_unref (r);
|
||||
return;
|
||||
}
|
||||
@@ -4125,7 +4140,8 @@ sms_text_part_list_ready (MMBroadbandModem *self,
|
||||
mm_dbg ("Correctly parsed SMS list entry (%d)", idx);
|
||||
mm_iface_modem_messaging_take_part (MM_IFACE_MODEM_MESSAGING (self),
|
||||
part,
|
||||
sms_state_from_str (stat));
|
||||
sms_state_from_str (stat),
|
||||
ctx->list_storage);
|
||||
g_free (stat);
|
||||
next:
|
||||
g_match_info_next (match_info, NULL);
|
||||
@@ -4134,9 +4150,8 @@ next:
|
||||
g_regex_unref (r);
|
||||
|
||||
/* We consider all done */
|
||||
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||
list_parts_context_complete_and_free (ctx);
|
||||
}
|
||||
|
||||
static MMSmsState
|
||||
@@ -4159,16 +4174,15 @@ sms_state_from_index (guint index)
|
||||
static void
|
||||
sms_pdu_part_list_ready (MMBroadbandModem *self,
|
||||
GAsyncResult *res,
|
||||
GSimpleAsyncResult *simple)
|
||||
ListPartsContext *ctx)
|
||||
{
|
||||
const gchar *response;
|
||||
GError *error = NULL;
|
||||
|
||||
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
|
||||
if (error) {
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
list_parts_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4185,14 +4199,13 @@ sms_pdu_part_list_ready (MMBroadbandModem *self,
|
||||
"+CMGL: %d,%d,,%d %" G_STRINGIFY (SMS_MAX_PDU_LEN) "s %n",
|
||||
&idx, &status, &tpdu_len, pdu, &offset);
|
||||
if (4 != rv) {
|
||||
g_simple_async_result_set_error (simple,
|
||||
g_simple_async_result_set_error (ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_INVALID_ARGS,
|
||||
"Couldn't parse SMS list response: "
|
||||
"only %d fields parsed",
|
||||
rv);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
list_parts_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4204,7 +4217,8 @@ sms_pdu_part_list_ready (MMBroadbandModem *self,
|
||||
mm_dbg ("Correctly parsed PDU (%d)", idx);
|
||||
mm_iface_modem_messaging_take_part (MM_IFACE_MODEM_MESSAGING (self),
|
||||
part,
|
||||
sms_state_from_index (status));
|
||||
sms_state_from_index (status),
|
||||
ctx->list_storage);
|
||||
} else {
|
||||
/* Don't treat the error as critical */
|
||||
mm_dbg ("Error parsing PDU (%d): %s", idx, error->message);
|
||||
@@ -4213,15 +4227,14 @@ sms_pdu_part_list_ready (MMBroadbandModem *self,
|
||||
}
|
||||
|
||||
/* We consider all done */
|
||||
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||
list_parts_context_complete_and_free (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
list_parts_storage_ready (MMBroadbandModem *self,
|
||||
GAsyncResult *res,
|
||||
GSimpleAsyncResult *simple)
|
||||
ListPartsContext *ctx)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
@@ -4229,9 +4242,8 @@ list_parts_storage_ready (MMBroadbandModem *self,
|
||||
MM_IFACE_MODEM_MESSAGING (self),
|
||||
res,
|
||||
&error)) {
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
list_parts_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4249,7 +4261,7 @@ list_parts_storage_ready (MMBroadbandModem *self,
|
||||
(GAsyncReadyCallback) (MM_BROADBAND_MODEM (self)->priv->modem_messaging_sms_pdu_mode ?
|
||||
sms_pdu_part_list_ready :
|
||||
sms_text_part_list_ready),
|
||||
simple);
|
||||
ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -4258,12 +4270,15 @@ modem_messaging_load_initial_sms_parts (MMIfaceModemMessaging *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *result;
|
||||
ListPartsContext *ctx;
|
||||
|
||||
result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
modem_messaging_load_initial_sms_parts);
|
||||
ctx = g_new0 (ListPartsContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
modem_messaging_load_initial_sms_parts);
|
||||
ctx->list_storage = storage;
|
||||
|
||||
mm_dbg ("Listing SMS parts in storage '%s'",
|
||||
mm_sms_storage_get_string (storage));
|
||||
@@ -4274,7 +4289,7 @@ modem_messaging_load_initial_sms_parts (MMIfaceModemMessaging *self,
|
||||
MM_SMS_STORAGE_UNKNOWN,
|
||||
MM_SMS_STORAGE_UNKNOWN,
|
||||
(GAsyncReadyCallback)list_parts_storage_ready,
|
||||
result);
|
||||
ctx);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -273,7 +273,8 @@ handle_list (MmGdbusModemMessaging *skeleton,
|
||||
gboolean
|
||||
mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self,
|
||||
MMSmsPart *sms_part,
|
||||
MMSmsState state)
|
||||
MMSmsState state,
|
||||
MMSmsStorage storage)
|
||||
{
|
||||
MMSmsList *list = NULL;
|
||||
GError *error = NULL;
|
||||
@@ -283,7 +284,7 @@ mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self,
|
||||
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
||||
NULL);
|
||||
g_assert (list != NULL);
|
||||
added = mm_sms_list_take_part (list, sms_part, state, &error);
|
||||
added = mm_sms_list_take_part (list, sms_part, state, storage, &error);
|
||||
if (!added) {
|
||||
mm_dbg ("Couldn't take part in SMS list: '%s'", error->message);
|
||||
g_error_free (error);
|
||||
|
||||
@@ -149,7 +149,8 @@ void mm_iface_modem_messaging_bind_simple_status (MMIfaceModemMessaging *self,
|
||||
/* Report new SMS part */
|
||||
gboolean mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self,
|
||||
MMSmsPart *sms_part,
|
||||
MMSmsState state);
|
||||
MMSmsState state,
|
||||
MMSmsStorage storage);
|
||||
|
||||
/* Set preferred storages */
|
||||
void mm_iface_modem_messaging_set_preferred_storages (MMIfaceModemMessaging *self,
|
||||
|
||||
+7
-2
@@ -222,12 +222,14 @@ static gboolean
|
||||
take_singlepart (MMSmsList *self,
|
||||
MMSmsPart *part,
|
||||
MMSmsState state,
|
||||
MMSmsStorage storage,
|
||||
GError **error)
|
||||
{
|
||||
MMSms *sms;
|
||||
|
||||
sms = mm_sms_singlepart_new (self->priv->modem,
|
||||
state,
|
||||
storage,
|
||||
part,
|
||||
error);
|
||||
if (!sms)
|
||||
@@ -244,6 +246,7 @@ static gboolean
|
||||
take_multipart (MMSmsList *self,
|
||||
MMSmsPart *part,
|
||||
MMSmsState state,
|
||||
MMSmsStorage storage,
|
||||
GError **error)
|
||||
{
|
||||
GList *l;
|
||||
@@ -261,6 +264,7 @@ take_multipart (MMSmsList *self,
|
||||
/* Create new Multipart */
|
||||
sms = mm_sms_multipart_new (self->priv->modem,
|
||||
state,
|
||||
storage,
|
||||
concat_reference,
|
||||
mm_sms_part_get_concat_max (part),
|
||||
part,
|
||||
@@ -288,6 +292,7 @@ gboolean
|
||||
mm_sms_list_take_part (MMSmsList *self,
|
||||
MMSmsPart *part,
|
||||
MMSmsState state,
|
||||
MMSmsStorage storage,
|
||||
GError **error)
|
||||
{
|
||||
/* Ensure we don't have already taken a part with the same index */
|
||||
@@ -304,10 +309,10 @@ mm_sms_list_take_part (MMSmsList *self,
|
||||
|
||||
/* Did we just get a part of a multi-part SMS? */
|
||||
if (mm_sms_part_should_concat (part))
|
||||
return take_multipart (self, part, state, error);
|
||||
return take_multipart (self, part, state, storage, error);
|
||||
|
||||
/* Otherwise, we build a whole new single-part MMSms just from this part */
|
||||
return take_singlepart (self, part, state, error);
|
||||
return take_singlepart (self, part, state, storage, error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -64,6 +64,7 @@ guint mm_sms_list_get_count (MMSmsList *self);
|
||||
gboolean mm_sms_list_take_part (MMSmsList *self,
|
||||
MMSmsPart *part,
|
||||
MMSmsState state,
|
||||
MMSmsStorage storage,
|
||||
GError **error);
|
||||
|
||||
void mm_sms_list_add_sms (MMSmsList *self,
|
||||
|
||||
+17
-1
@@ -110,8 +110,19 @@ handle_store_ready (MMSms *self,
|
||||
MM_SMS_GET_CLASS (self)->store_finish (self, res, &error);
|
||||
if (error)
|
||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||
else
|
||||
else {
|
||||
MMSmsStorage storage = MM_SMS_STORAGE_UNKNOWN;
|
||||
|
||||
/* We'll set now the proper storage, taken from the default mem2 one */
|
||||
g_object_get (self->priv->modem,
|
||||
MM_IFACE_MODEM_MESSAGING_SMS_MEM2_STORAGE, &storage,
|
||||
NULL);
|
||||
g_object_set (self,
|
||||
"storage", storage,
|
||||
NULL);
|
||||
|
||||
mm_gdbus_sms_complete_store (MM_GDBUS_SMS (ctx->self), ctx->invocation);
|
||||
}
|
||||
dbus_call_context_free (ctx);
|
||||
}
|
||||
|
||||
@@ -940,6 +951,7 @@ mm_sms_new (MMBaseModem *modem)
|
||||
MMSms *
|
||||
mm_sms_singlepart_new (MMBaseModem *modem,
|
||||
MMSmsState state,
|
||||
MMSmsStorage storage,
|
||||
MMSmsPart *part,
|
||||
GError **error)
|
||||
{
|
||||
@@ -948,6 +960,7 @@ mm_sms_singlepart_new (MMBaseModem *modem,
|
||||
self = mm_sms_new (modem);
|
||||
g_object_set (self,
|
||||
"state", state,
|
||||
"storage", storage,
|
||||
NULL);
|
||||
|
||||
/* Keep the single part in the list */
|
||||
@@ -965,6 +978,7 @@ mm_sms_singlepart_new (MMBaseModem *modem,
|
||||
MMSms *
|
||||
mm_sms_multipart_new (MMBaseModem *modem,
|
||||
MMSmsState state,
|
||||
MMSmsStorage storage,
|
||||
guint reference,
|
||||
guint max_parts,
|
||||
MMSmsPart *first_part,
|
||||
@@ -983,6 +997,7 @@ mm_sms_multipart_new (MMBaseModem *modem,
|
||||
MM_SMS_MAX_PARTS, max_parts,
|
||||
MM_SMS_MULTIPART_REFERENCE, reference,
|
||||
"state", state,
|
||||
"storage", storage,
|
||||
NULL);
|
||||
|
||||
if (!mm_sms_multipart_take_part (self, first_part, error))
|
||||
@@ -1018,6 +1033,7 @@ mm_sms_new_from_properties (MMBaseModem *modem,
|
||||
|
||||
return mm_sms_singlepart_new (modem,
|
||||
MM_SMS_STATE_UNKNOWN,
|
||||
MM_SMS_STORAGE_UNKNOWN, /* not stored anywhere yet */
|
||||
part,
|
||||
error);
|
||||
}
|
||||
|
||||
@@ -88,11 +88,13 @@ MMSms *mm_sms_new_from_properties (MMBaseModem *modem,
|
||||
|
||||
MMSms *mm_sms_singlepart_new (MMBaseModem *modem,
|
||||
MMSmsState state,
|
||||
MMSmsStorage storage,
|
||||
MMSmsPart *part,
|
||||
GError **error);
|
||||
|
||||
MMSms *mm_sms_multipart_new (MMBaseModem *modem,
|
||||
MMSmsState state,
|
||||
MMSmsStorage storage,
|
||||
guint reference,
|
||||
guint max_parts,
|
||||
MMSmsPart *first_part,
|
||||
|
||||
Reference in New Issue
Block a user