iface-modem-messaging: load initial parts from all available storages
This commit is contained in:
@@ -4162,16 +4162,23 @@ sms_pdu_part_list_ready (MMBroadbandModem *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
modem_messaging_load_initial_sms_parts (MMIfaceModemMessaging *self,
|
list_parts_storage_ready (MMBroadbandModem *self,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncResult *res,
|
||||||
gpointer user_data)
|
GSimpleAsyncResult *simple)
|
||||||
{
|
{
|
||||||
GSimpleAsyncResult *result;
|
GError *error = NULL;
|
||||||
|
|
||||||
result = g_simple_async_result_new (G_OBJECT (self),
|
if (!mm_iface_modem_messaging_set_preferred_storages_finish (
|
||||||
callback,
|
MM_IFACE_MODEM_MESSAGING (self),
|
||||||
user_data,
|
res,
|
||||||
modem_messaging_load_initial_sms_parts);
|
&error)) {
|
||||||
|
g_simple_async_result_take_error (simple, error);
|
||||||
|
g_simple_async_result_complete (simple);
|
||||||
|
g_object_unref (simple);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Storage now set */
|
||||||
|
|
||||||
/* Get SMS parts from ALL types.
|
/* Get SMS parts from ALL types.
|
||||||
* Different command to be used if we are on Text or PDU mode */
|
* Different command to be used if we are on Text or PDU mode */
|
||||||
@@ -4185,7 +4192,32 @@ modem_messaging_load_initial_sms_parts (MMIfaceModemMessaging *self,
|
|||||||
(GAsyncReadyCallback) (MM_BROADBAND_MODEM (self)->priv->modem_messaging_sms_pdu_mode ?
|
(GAsyncReadyCallback) (MM_BROADBAND_MODEM (self)->priv->modem_messaging_sms_pdu_mode ?
|
||||||
sms_pdu_part_list_ready :
|
sms_pdu_part_list_ready :
|
||||||
sms_text_part_list_ready),
|
sms_text_part_list_ready),
|
||||||
result);
|
simple);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
modem_messaging_load_initial_sms_parts (MMIfaceModemMessaging *self,
|
||||||
|
MMSmsStorage storage,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GSimpleAsyncResult *result;
|
||||||
|
|
||||||
|
result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
modem_messaging_load_initial_sms_parts);
|
||||||
|
|
||||||
|
mm_dbg ("Listing SMS parts in storage '%s'",
|
||||||
|
mm_sms_storage_get_string (storage));
|
||||||
|
|
||||||
|
/* First, request to set the proper storage to read from */
|
||||||
|
mm_iface_modem_messaging_set_preferred_storages (self,
|
||||||
|
storage,
|
||||||
|
MM_SMS_STORAGE_UNKNOWN,
|
||||||
|
MM_SMS_STORAGE_UNKNOWN,
|
||||||
|
(GAsyncReadyCallback)list_parts_storage_ready,
|
||||||
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@@ -317,6 +317,10 @@ is_storage_supported (GArray *supported,
|
|||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
/* We do allow setting UNKNOWN here, so that we set the *default* storage */
|
||||||
|
if (preferred == MM_SMS_STORAGE_UNKNOWN)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
for (i = 0; i < supported->len; i++) {
|
for (i = 0; i < supported->len; i++) {
|
||||||
if (preferred == g_array_index (supported, MMSmsStorage, i))
|
if (preferred == g_array_index (supported, MMSmsStorage, i))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -537,6 +541,8 @@ struct _EnablingContext {
|
|||||||
EnablingStep step;
|
EnablingStep step;
|
||||||
GSimpleAsyncResult *result;
|
GSimpleAsyncResult *result;
|
||||||
MmGdbusModemMessaging *skeleton;
|
MmGdbusModemMessaging *skeleton;
|
||||||
|
|
||||||
|
guint mem1_storage_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
static EnablingContext *
|
static EnablingContext *
|
||||||
@@ -604,7 +610,63 @@ mm_iface_modem_messaging_enable_finish (MMIfaceModemMessaging *self,
|
|||||||
|
|
||||||
VOID_REPLY_READY_FN (setup_sms_format)
|
VOID_REPLY_READY_FN (setup_sms_format)
|
||||||
VOID_REPLY_READY_FN (setup_unsolicited_events)
|
VOID_REPLY_READY_FN (setup_unsolicited_events)
|
||||||
VOID_REPLY_READY_FN (load_initial_sms_parts)
|
|
||||||
|
static void load_initial_sms_parts_from_storages (EnablingContext *ctx);
|
||||||
|
|
||||||
|
static void
|
||||||
|
load_initial_sms_parts_ready (MMIfaceModemMessaging *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
EnablingContext *ctx)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->load_initial_sms_parts_finish (self, res, &error);
|
||||||
|
if (error) {
|
||||||
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
|
enabling_context_complete_and_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Go on with the storage iteration */
|
||||||
|
ctx->mem1_storage_index++;
|
||||||
|
load_initial_sms_parts_from_storages (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
load_initial_sms_parts_from_storages (EnablingContext *ctx)
|
||||||
|
{
|
||||||
|
gboolean all_loaded = FALSE;
|
||||||
|
StorageContext *storage_ctx;
|
||||||
|
|
||||||
|
storage_ctx = get_storage_context (ctx->self);
|
||||||
|
|
||||||
|
if (ctx->mem1_storage_index >= storage_ctx->supported_mem1->len)
|
||||||
|
all_loaded = TRUE;
|
||||||
|
/* We'll skip the 'MT' storage, as that is a combination of 'SM' and 'ME' */
|
||||||
|
else if (g_array_index (storage_ctx->supported_mem1,
|
||||||
|
MMSmsStorage,
|
||||||
|
ctx->mem1_storage_index) == MM_SMS_STORAGE_MT) {
|
||||||
|
ctx->mem1_storage_index++;
|
||||||
|
if (ctx->mem1_storage_index >= storage_ctx->supported_mem1->len)
|
||||||
|
all_loaded = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (all_loaded) {
|
||||||
|
/* Go on with next step */
|
||||||
|
ctx->step++;
|
||||||
|
interface_enabling_step (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->load_initial_sms_parts (
|
||||||
|
ctx->self,
|
||||||
|
g_array_index (storage_ctx->supported_mem1,
|
||||||
|
MMSmsStorage,
|
||||||
|
ctx->mem1_storage_index),
|
||||||
|
(GAsyncReadyCallback)load_initial_sms_parts_ready,
|
||||||
|
ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
interface_enabling_step (EnablingContext *ctx)
|
interface_enabling_step (EnablingContext *ctx)
|
||||||
@@ -664,10 +726,7 @@ interface_enabling_step (EnablingContext *ctx)
|
|||||||
/* Allow loading the initial list of SMS parts */
|
/* Allow loading the initial list of SMS parts */
|
||||||
if (MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->load_initial_sms_parts &&
|
if (MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->load_initial_sms_parts &&
|
||||||
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->load_initial_sms_parts_finish) {
|
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->load_initial_sms_parts_finish) {
|
||||||
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->load_initial_sms_parts (
|
load_initial_sms_parts_from_storages (ctx);
|
||||||
ctx->self,
|
|
||||||
(GAsyncReadyCallback)load_initial_sms_parts_ready,
|
|
||||||
ctx);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Fall down to next step */
|
/* Fall down to next step */
|
||||||
@@ -872,6 +931,8 @@ interface_initialization_step (InitializationContext *ctx)
|
|||||||
initialization_context_complete_and_free (ctx);
|
initialization_context_complete_and_free (ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/* Fall down to next step */
|
||||||
|
ctx->step++;
|
||||||
|
|
||||||
case INITIALIZATION_STEP_LOAD_SUPPORTED_STORAGES:
|
case INITIALIZATION_STEP_LOAD_SUPPORTED_STORAGES:
|
||||||
if (MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->load_supported_storages &&
|
if (MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->load_supported_storages &&
|
||||||
|
@@ -101,6 +101,7 @@ struct _MMIfaceModemMessaging {
|
|||||||
/* Load initial SMS parts (async).
|
/* Load initial SMS parts (async).
|
||||||
* Found parts need to be reported with take_part() */
|
* Found parts need to be reported with take_part() */
|
||||||
void (* load_initial_sms_parts) (MMIfaceModemMessaging *self,
|
void (* load_initial_sms_parts) (MMIfaceModemMessaging *self,
|
||||||
|
MMSmsStorage storage,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
gboolean (*load_initial_sms_parts_finish) (MMIfaceModemMessaging *self,
|
gboolean (*load_initial_sms_parts_finish) (MMIfaceModemMessaging *self,
|
||||||
|
Reference in New Issue
Block a user