iface-modem-3gpp-ussd: implement logic to enable/disable URCs
This commit is contained in:
@@ -47,6 +47,7 @@ static void interface_disabling_step (DisablingContext *ctx);
|
||||
|
||||
typedef enum {
|
||||
DISABLING_STEP_FIRST,
|
||||
DISABLING_STEP_DISABLE_UNSOLICITED_RESULT_CODES,
|
||||
DISABLING_STEP_LAST
|
||||
} DisablingStep;
|
||||
|
||||
@@ -100,6 +101,27 @@ mm_iface_modem_3gpp_ussd_disable_finish (MMIfaceModem3gppUssd *self,
|
||||
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
disable_unsolicited_result_codes_ready (MMIfaceModem3gppUssd *self,
|
||||
GAsyncResult *res,
|
||||
DisablingContext *ctx)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (self)->disable_unsolicited_result_codes_finish (self,
|
||||
res,
|
||||
&error);
|
||||
if (error) {
|
||||
/* This error shouldn't be treated as critical */
|
||||
mm_dbg ("Couldn't disable unsolicited result codes: '%s'", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
/* Go on to next step */
|
||||
ctx->step++;
|
||||
interface_disabling_step (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
interface_disabling_step (DisablingContext *ctx)
|
||||
{
|
||||
@@ -108,6 +130,18 @@ interface_disabling_step (DisablingContext *ctx)
|
||||
/* Fall down to next step */
|
||||
ctx->step++;
|
||||
|
||||
case DISABLING_STEP_DISABLE_UNSOLICITED_RESULT_CODES:
|
||||
if (MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (ctx->self)->disable_unsolicited_result_codes &&
|
||||
MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (ctx->self)->disable_unsolicited_result_codes_finish) {
|
||||
MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (ctx->self)->disable_unsolicited_result_codes (
|
||||
ctx->self,
|
||||
(GAsyncReadyCallback)disable_unsolicited_result_codes_ready,
|
||||
ctx);
|
||||
return;
|
||||
}
|
||||
/* Fall down to next step */
|
||||
ctx->step++;
|
||||
|
||||
case DISABLING_STEP_LAST:
|
||||
/* We are done without errors! */
|
||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||
@@ -135,6 +169,7 @@ static void interface_enabling_step (EnablingContext *ctx);
|
||||
|
||||
typedef enum {
|
||||
ENABLING_STEP_FIRST,
|
||||
ENABLING_STEP_ENABLE_UNSOLICITED_RESULT_CODES,
|
||||
ENABLING_STEP_LAST
|
||||
} EnablingStep;
|
||||
|
||||
@@ -188,6 +223,27 @@ mm_iface_modem_3gpp_ussd_enable_finish (MMIfaceModem3gppUssd *self,
|
||||
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
enable_unsolicited_result_codes_ready (MMIfaceModem3gppUssd *self,
|
||||
GAsyncResult *res,
|
||||
EnablingContext *ctx)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (self)->enable_unsolicited_result_codes_finish (self,
|
||||
res,
|
||||
&error);
|
||||
if (error) {
|
||||
/* This error shouldn't be treated as critical */
|
||||
mm_dbg ("Couldn't enable unsolicited result codes: '%s'", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
/* Go on to next step */
|
||||
ctx->step++;
|
||||
interface_enabling_step (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
interface_enabling_step (EnablingContext *ctx)
|
||||
{
|
||||
@@ -196,6 +252,18 @@ interface_enabling_step (EnablingContext *ctx)
|
||||
/* Fall down to next step */
|
||||
ctx->step++;
|
||||
|
||||
case ENABLING_STEP_ENABLE_UNSOLICITED_RESULT_CODES:
|
||||
if (MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (ctx->self)->enable_unsolicited_result_codes &&
|
||||
MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (ctx->self)->enable_unsolicited_result_codes_finish) {
|
||||
MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (ctx->self)->enable_unsolicited_result_codes (
|
||||
ctx->self,
|
||||
(GAsyncReadyCallback)enable_unsolicited_result_codes_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);
|
||||
|
||||
@@ -42,6 +42,22 @@ struct _MMIfaceModem3gppUssd {
|
||||
gboolean (*check_support_finish) (MMIfaceModem3gppUssd *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
/* Asynchronous enabling of unsolicited result codes */
|
||||
void (*enable_unsolicited_result_codes) (MMIfaceModem3gppUssd *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean (*enable_unsolicited_result_codes_finish) (MMIfaceModem3gppUssd *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
/* Asynchronous disabling of unsolicited result codes */
|
||||
void (*disable_unsolicited_result_codes) (MMIfaceModem3gppUssd *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean (*disable_unsolicited_result_codes_finish) (MMIfaceModem3gppUssd *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
};
|
||||
|
||||
GType mm_iface_modem_3gpp_ussd_get_type (void);
|
||||
|
||||
Reference in New Issue
Block a user