diff options
-rw-r--r-- | src/mm-iface-modem-messaging.c | 64 | ||||
-rw-r--r-- | src/mm-iface-modem-messaging.h | 15 |
2 files changed, 79 insertions, 0 deletions
diff --git a/src/mm-iface-modem-messaging.c b/src/mm-iface-modem-messaging.c index f6a5c286..c28a6422 100644 --- a/src/mm-iface-modem-messaging.c +++ b/src/mm-iface-modem-messaging.c @@ -37,6 +37,34 @@ mm_iface_modem_messaging_bind_simple_status (MMIfaceModemMessaging *self, /*****************************************************************************/ +gboolean +mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self, + MMSmsPart *sms_part, + gboolean received) +{ + MMSmsList *list = NULL; + GError *error = NULL; + gboolean added; + + g_object_get (self, + MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list, + NULL); + g_assert (list != NULL); + added = mm_sms_list_take_part (list, sms_part, received, &error); + if (!added) { + mm_dbg ("Couldn't take part in SMS list: '%s'", error->message); + g_error_free (error); + + /* If part wasn't taken, we need to free the part ourselves */ + mm_sms_part_free (sms_part); + } + g_object_unref (list); + + return added; +} + +/*****************************************************************************/ + typedef struct _DisablingContext DisablingContext; static void interface_disabling_step (DisablingContext *ctx); @@ -136,6 +164,7 @@ static void interface_enabling_step (EnablingContext *ctx); typedef enum { ENABLING_STEP_FIRST, ENABLING_STEP_SETUP_SMS_FORMAT, + ENABLING_STEP_LOAD_INITIAL_SMS_PARTS, ENABLING_STEP_LAST } EnablingStep; @@ -212,6 +241,28 @@ setup_sms_format_ready (MMIfaceModemMessaging *self, } static void +load_initial_sms_parts_ready (MMIfaceModemMessaging *self, + GAsyncResult *res, + EnablingContext *ctx) +{ + GError *error = NULL; + + if (!MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->load_initial_sms_parts_finish (self, + res, + &error)) { + g_simple_async_result_take_error (ctx->result, error); + enabling_context_complete_and_free (ctx); + return; + } + + mm_dbg ("Initial SMS parts correctly loaded"); + + /* Go on to next step */ + ctx->step++; + interface_enabling_step (ctx); +} + +static void interface_enabling_step (EnablingContext *ctx) { switch (ctx->step) { @@ -241,6 +292,19 @@ interface_enabling_step (EnablingContext *ctx) /* Fall down to next step */ ctx->step++; + case ENABLING_STEP_LOAD_INITIAL_SMS_PARTS: + /* 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); + return; + } + /* Fall down to next step */ + ctx->step++; + case ENABLING_STEP_LAST: /* We are done without errors! */ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); diff --git a/src/mm-iface-modem-messaging.h b/src/mm-iface-modem-messaging.h index 09a75830..8aafccf8 100644 --- a/src/mm-iface-modem-messaging.h +++ b/src/mm-iface-modem-messaging.h @@ -20,6 +20,7 @@ #include <gio/gio.h> #include "mm-at-serial-port.h" +#include "mm-sms-part.h" #define MM_TYPE_IFACE_MODEM_MESSAGING (mm_iface_modem_messaging_get_type ()) #define MM_IFACE_MODEM_MESSAGING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_IFACE_MODEM_MESSAGING, MMIfaceModemMessaging)) @@ -49,6 +50,15 @@ struct _MMIfaceModemMessaging { gboolean (*setup_sms_format_finish) (MMIfaceModemMessaging *self, GAsyncResult *res, GError **error); + + /* Load initial SMS parts (async). + * Found parts need to be reported with take_part() */ + void (* load_initial_sms_parts) (MMIfaceModemMessaging *self, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (*load_initial_sms_parts_finish) (MMIfaceModemMessaging *self, + GAsyncResult *res, + GError **error); }; GType mm_iface_modem_messaging_get_type (void); @@ -85,4 +95,9 @@ void mm_iface_modem_messaging_shutdown (MMIfaceModemMessaging *self); void mm_iface_modem_messaging_bind_simple_status (MMIfaceModemMessaging *self, MMCommonSimpleProperties *status); +/* Report new SMS part */ +gboolean mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self, + MMSmsPart *sms_part, + gboolean received); + #endif /* MM_IFACE_MODEM_MESSAGING_H */ |