diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-02-10 15:43:34 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:15:03 +0100 |
commit | 9e3f66393fc03b7d285c4326f23c7962c833dae5 (patch) | |
tree | 811dec754541c3a68e1855b64ede2e5ffbed1a92 | |
parent | cd184f33f9f78692dbf9135818e69c98cdf1fcb8 (diff) |
iface-modem-messaging: load initial parts from all available storages
-rw-r--r-- | src/mm-broadband-modem.c | 50 | ||||
-rw-r--r-- | src/mm-iface-modem-messaging.c | 71 | ||||
-rw-r--r-- | src/mm-iface-modem-messaging.h | 1 |
3 files changed, 108 insertions, 14 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index 7220a194..4d819297 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -4162,16 +4162,23 @@ sms_pdu_part_list_ready (MMBroadbandModem *self, } static void -modem_messaging_load_initial_sms_parts (MMIfaceModemMessaging *self, - GAsyncReadyCallback callback, - gpointer user_data) +list_parts_storage_ready (MMBroadbandModem *self, + GAsyncResult *res, + GSimpleAsyncResult *simple) { - GSimpleAsyncResult *result; + GError *error = NULL; - result = g_simple_async_result_new (G_OBJECT (self), - callback, - user_data, - modem_messaging_load_initial_sms_parts); + if (!mm_iface_modem_messaging_set_preferred_storages_finish ( + 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); + return; + } + + /* Storage now set */ /* Get SMS parts from ALL types. * 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 ? sms_pdu_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); } /*****************************************************************************/ diff --git a/src/mm-iface-modem-messaging.c b/src/mm-iface-modem-messaging.c index e106821f..bbc8054b 100644 --- a/src/mm-iface-modem-messaging.c +++ b/src/mm-iface-modem-messaging.c @@ -317,6 +317,10 @@ is_storage_supported (GArray *supported, { 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++) { if (preferred == g_array_index (supported, MMSmsStorage, i)) return TRUE; @@ -537,6 +541,8 @@ struct _EnablingContext { EnablingStep step; GSimpleAsyncResult *result; MmGdbusModemMessaging *skeleton; + + guint mem1_storage_index; }; 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_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 interface_enabling_step (EnablingContext *ctx) @@ -664,10 +726,7 @@ interface_enabling_step (EnablingContext *ctx) /* Allow loading the initial list of 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 ( - ctx->self, - (GAsyncReadyCallback)load_initial_sms_parts_ready, - ctx); + load_initial_sms_parts_from_storages (ctx); return; } /* Fall down to next step */ @@ -872,6 +931,8 @@ interface_initialization_step (InitializationContext *ctx) initialization_context_complete_and_free (ctx); return; } + /* Fall down to next step */ + ctx->step++; case INITIALIZATION_STEP_LOAD_SUPPORTED_STORAGES: if (MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->load_supported_storages && diff --git a/src/mm-iface-modem-messaging.h b/src/mm-iface-modem-messaging.h index e3268af3..23ef31fc 100644 --- a/src/mm-iface-modem-messaging.h +++ b/src/mm-iface-modem-messaging.h @@ -101,6 +101,7 @@ struct _MMIfaceModemMessaging { /* Load initial SMS parts (async). * Found parts need to be reported with take_part() */ void (* load_initial_sms_parts) (MMIfaceModemMessaging *self, + MMSmsStorage storage, GAsyncReadyCallback callback, gpointer user_data); gboolean (*load_initial_sms_parts_finish) (MMIfaceModemMessaging *self, |