iface-modem-messaging: load initial list of SMS parts
This commit is contained in:
@@ -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;
|
typedef struct _DisablingContext DisablingContext;
|
||||||
static void interface_disabling_step (DisablingContext *ctx);
|
static void interface_disabling_step (DisablingContext *ctx);
|
||||||
|
|
||||||
@@ -136,6 +164,7 @@ static void interface_enabling_step (EnablingContext *ctx);
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
ENABLING_STEP_FIRST,
|
ENABLING_STEP_FIRST,
|
||||||
ENABLING_STEP_SETUP_SMS_FORMAT,
|
ENABLING_STEP_SETUP_SMS_FORMAT,
|
||||||
|
ENABLING_STEP_LOAD_INITIAL_SMS_PARTS,
|
||||||
ENABLING_STEP_LAST
|
ENABLING_STEP_LAST
|
||||||
} EnablingStep;
|
} EnablingStep;
|
||||||
|
|
||||||
@@ -211,6 +240,28 @@ setup_sms_format_ready (MMIfaceModemMessaging *self,
|
|||||||
interface_enabling_step (ctx);
|
interface_enabling_step (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
interface_enabling_step (EnablingContext *ctx)
|
interface_enabling_step (EnablingContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -241,6 +292,19 @@ interface_enabling_step (EnablingContext *ctx)
|
|||||||
/* Fall down to next step */
|
/* Fall down to next step */
|
||||||
ctx->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:
|
case ENABLING_STEP_LAST:
|
||||||
/* We are done without errors! */
|
/* We are done without errors! */
|
||||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
#include "mm-at-serial-port.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_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))
|
#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,
|
gboolean (*setup_sms_format_finish) (MMIfaceModemMessaging *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error);
|
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);
|
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,
|
void mm_iface_modem_messaging_bind_simple_status (MMIfaceModemMessaging *self,
|
||||||
MMCommonSimpleProperties *status);
|
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 */
|
#endif /* MM_IFACE_MODEM_MESSAGING_H */
|
||||||
|
Reference in New Issue
Block a user