iface-modem-messaging: allow setting up unsolicited events
This commit is contained in:
@@ -189,6 +189,7 @@ static void interface_disabling_step (DisablingContext *ctx);
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DISABLING_STEP_FIRST,
|
DISABLING_STEP_FIRST,
|
||||||
|
DISABLING_STEP_CLEANUP_UNSOLICITED_EVENTS,
|
||||||
DISABLING_STEP_LAST
|
DISABLING_STEP_LAST
|
||||||
} DisablingStep;
|
} DisablingStep;
|
||||||
|
|
||||||
@@ -242,6 +243,25 @@ mm_iface_modem_messaging_disable_finish (MMIfaceModemMessaging *self,
|
|||||||
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cleanup_unsolicited_events_ready (MMIfaceModemMessaging *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
DisablingContext *ctx)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->cleanup_unsolicited_events_finish (self, res, &error);
|
||||||
|
if (error) {
|
||||||
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
|
disabling_context_complete_and_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Go on to next step */
|
||||||
|
ctx->step++;
|
||||||
|
interface_disabling_step (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
interface_disabling_step (DisablingContext *ctx)
|
interface_disabling_step (DisablingContext *ctx)
|
||||||
{
|
{
|
||||||
@@ -250,6 +270,19 @@ interface_disabling_step (DisablingContext *ctx)
|
|||||||
/* Fall down to next step */
|
/* Fall down to next step */
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
|
|
||||||
|
case DISABLING_STEP_CLEANUP_UNSOLICITED_EVENTS:
|
||||||
|
/* Allow cleaning up unsolicited events */
|
||||||
|
if (MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->cleanup_unsolicited_events &&
|
||||||
|
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->cleanup_unsolicited_events_finish) {
|
||||||
|
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->cleanup_unsolicited_events (
|
||||||
|
ctx->self,
|
||||||
|
(GAsyncReadyCallback)cleanup_unsolicited_events_ready,
|
||||||
|
ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* Fall down to next step */
|
||||||
|
ctx->step++;
|
||||||
|
|
||||||
case DISABLING_STEP_LAST:
|
case DISABLING_STEP_LAST:
|
||||||
/* Clear SMS list */
|
/* Clear SMS list */
|
||||||
g_object_set (ctx->self,
|
g_object_set (ctx->self,
|
||||||
@@ -283,6 +316,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_SETUP_UNSOLICITED_EVENTS,
|
||||||
ENABLING_STEP_LOAD_INITIAL_SMS_PARTS,
|
ENABLING_STEP_LOAD_INITIAL_SMS_PARTS,
|
||||||
ENABLING_STEP_LAST
|
ENABLING_STEP_LAST
|
||||||
} EnablingStep;
|
} EnablingStep;
|
||||||
@@ -337,49 +371,30 @@ mm_iface_modem_messaging_enable_finish (MMIfaceModemMessaging *self,
|
|||||||
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
#undef VOID_REPLY_READY_FN
|
||||||
setup_sms_format_ready (MMIfaceModemMessaging *self,
|
#define VOID_REPLY_READY_FN(NAME) \
|
||||||
GAsyncResult *res,
|
static void \
|
||||||
EnablingContext *ctx)
|
NAME##_ready (MMIfaceModemMessaging *self, \
|
||||||
{
|
GAsyncResult *res, \
|
||||||
GError *error = NULL;
|
EnablingContext *ctx) \
|
||||||
|
{ \
|
||||||
if (!MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->setup_sms_format_finish (self,
|
GError *error = NULL; \
|
||||||
res,
|
\
|
||||||
&error)) {
|
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->NAME##_finish (self, res, &error); \
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
if (error) { \
|
||||||
enabling_context_complete_and_free (ctx);
|
g_simple_async_result_take_error (ctx->result, error); \
|
||||||
return;
|
enabling_context_complete_and_free (ctx); \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
/* Go on to next step */ \
|
||||||
|
ctx->step++; \
|
||||||
|
interface_enabling_step (ctx); \
|
||||||
}
|
}
|
||||||
|
|
||||||
mm_dbg ("SMS format correctly setup");
|
VOID_REPLY_READY_FN (setup_sms_format)
|
||||||
|
VOID_REPLY_READY_FN (setup_unsolicited_events)
|
||||||
/* Go on to next step */
|
VOID_REPLY_READY_FN (load_initial_sms_parts)
|
||||||
ctx->step++;
|
|
||||||
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)
|
||||||
@@ -422,6 +437,19 @@ interface_enabling_step (EnablingContext *ctx)
|
|||||||
/* Fall down to next step */
|
/* Fall down to next step */
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
|
|
||||||
|
case ENABLING_STEP_SETUP_UNSOLICITED_EVENTS:
|
||||||
|
/* Allow setting up unsolicited events */
|
||||||
|
if (MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->setup_unsolicited_events &&
|
||||||
|
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->setup_unsolicited_events_finish) {
|
||||||
|
MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (ctx->self)->setup_unsolicited_events (
|
||||||
|
ctx->self,
|
||||||
|
(GAsyncReadyCallback)setup_unsolicited_events_ready,
|
||||||
|
ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* Fall down to next step */
|
||||||
|
ctx->step++;
|
||||||
|
|
||||||
case ENABLING_STEP_LOAD_INITIAL_SMS_PARTS:
|
case ENABLING_STEP_LOAD_INITIAL_SMS_PARTS:
|
||||||
/* 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 &&
|
||||||
|
@@ -51,6 +51,22 @@ struct _MMIfaceModemMessaging {
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
/* Asynchronous setting up unsolicited SMS reception events */
|
||||||
|
void (*setup_unsolicited_events) (MMIfaceModemMessaging *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
gboolean (*setup_unsolicited_events_finish) (MMIfaceModemMessaging *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
/* Asynchronous cleaning up of unsolicited SMS reception events */
|
||||||
|
void (*cleanup_unsolicited_events) (MMIfaceModemMessaging *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
gboolean (*cleanup_unsolicited_events_finish) (MMIfaceModemMessaging *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
/* 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,
|
||||||
|
Reference in New Issue
Block a user