iface-modem: new methods to setup/cleanup unsolicited result codes
This commit is contained in:
@@ -24,6 +24,11 @@
|
|||||||
#include "mm-bearer-list.h"
|
#include "mm-bearer-list.h"
|
||||||
#include "mm-log.h"
|
#include "mm-log.h"
|
||||||
|
|
||||||
|
#define INDICATORS_CHECKED_TAG "indicators-checked-tag"
|
||||||
|
#define UNSOLICITED_EVENTS_SUPPORTED_TAG "unsolicited-events-supported-tag"
|
||||||
|
static GQuark indicators_checked;
|
||||||
|
static GQuark unsolicited_events_supported;
|
||||||
|
|
||||||
typedef struct _InitializationContext InitializationContext;
|
typedef struct _InitializationContext InitializationContext;
|
||||||
static void interface_initialization_step (InitializationContext *ctx);
|
static void interface_initialization_step (InitializationContext *ctx);
|
||||||
|
|
||||||
@@ -1376,6 +1381,7 @@ mm_iface_modem_unlock_check (MMIfaceModem *self,
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DISABLING_STEP_FIRST,
|
DISABLING_STEP_FIRST,
|
||||||
|
DISABLING_STEP_DISABLE_UNSOLICITED_EVENTS,
|
||||||
DISABLING_STEP_MODEM_POWER_DOWN,
|
DISABLING_STEP_MODEM_POWER_DOWN,
|
||||||
DISABLING_STEP_CLOSE_PORT,
|
DISABLING_STEP_CLOSE_PORT,
|
||||||
DISABLING_STEP_LAST
|
DISABLING_STEP_LAST
|
||||||
@@ -1470,6 +1476,7 @@ mm_iface_modem_disable_finish (MMIfaceModem *self,
|
|||||||
interface_disabling_step (ctx); \
|
interface_disabling_step (ctx); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID_REPLY_READY_FN (disable_unsolicited_events)
|
||||||
VOID_REPLY_READY_FN (modem_power_down)
|
VOID_REPLY_READY_FN (modem_power_down)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1480,6 +1487,26 @@ interface_disabling_step (DisablingContext *ctx)
|
|||||||
/* Fall down to next step */
|
/* Fall down to next step */
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
|
|
||||||
|
case DISABLING_STEP_DISABLE_UNSOLICITED_EVENTS:
|
||||||
|
if (G_UNLIKELY (!unsolicited_events_supported))
|
||||||
|
unsolicited_events_supported = (g_quark_from_static_string (
|
||||||
|
UNSOLICITED_EVENTS_SUPPORTED_TAG));
|
||||||
|
|
||||||
|
/* Only try to disable if supported */
|
||||||
|
if (GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (ctx->self),
|
||||||
|
unsolicited_events_supported))) {
|
||||||
|
if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->disable_unsolicited_events &&
|
||||||
|
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->disable_unsolicited_events_finish) {
|
||||||
|
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->disable_unsolicited_events (
|
||||||
|
ctx->self,
|
||||||
|
(GAsyncReadyCallback)disable_unsolicited_events_ready,
|
||||||
|
ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Fall down to next step */
|
||||||
|
ctx->step++;
|
||||||
|
|
||||||
case DISABLING_STEP_MODEM_POWER_DOWN:
|
case DISABLING_STEP_MODEM_POWER_DOWN:
|
||||||
/* CFUN=0 is dangerous and often will shoot devices in the head (that's
|
/* CFUN=0 is dangerous and often will shoot devices in the head (that's
|
||||||
* what it's supposed to do). So don't use CFUN=0 by default, but let
|
* what it's supposed to do). So don't use CFUN=0 by default, but let
|
||||||
@@ -1543,6 +1570,8 @@ typedef enum {
|
|||||||
ENABLING_STEP_FLOW_CONTROL,
|
ENABLING_STEP_FLOW_CONTROL,
|
||||||
ENABLING_STEP_SUPPORTED_CHARSETS,
|
ENABLING_STEP_SUPPORTED_CHARSETS,
|
||||||
ENABLING_STEP_CHARSET,
|
ENABLING_STEP_CHARSET,
|
||||||
|
ENABLING_STEP_SETUP_INDICATORS,
|
||||||
|
ENABLING_STEP_ENABLE_UNSOLICITED_EVENTS,
|
||||||
ENABLING_STEP_LAST
|
ENABLING_STEP_LAST
|
||||||
} EnablingStep;
|
} EnablingStep;
|
||||||
|
|
||||||
@@ -1648,6 +1677,60 @@ VOID_REPLY_READY_FN (modem_power_up);
|
|||||||
VOID_REPLY_READY_FN (modem_after_power_up);
|
VOID_REPLY_READY_FN (modem_after_power_up);
|
||||||
VOID_REPLY_READY_FN (setup_flow_control);
|
VOID_REPLY_READY_FN (setup_flow_control);
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_indicators_ready (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
EnablingContext *ctx)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
MM_IFACE_MODEM_GET_INTERFACE (self)->setup_indicators_finish (self, res, &error);
|
||||||
|
if (error) {
|
||||||
|
/* This error shouldn't be treated as critical */
|
||||||
|
mm_dbg ("Indicator control setup failed: '%s'", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
|
||||||
|
/* If we get an error setting up indicators, don't even bother trying to
|
||||||
|
* enable unsolicited events. */
|
||||||
|
ctx->step = ENABLING_STEP_ENABLE_UNSOLICITED_EVENTS + 1;
|
||||||
|
interface_enabling_step (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Indicators setup, so assume we support unsolicited events */
|
||||||
|
g_object_set_qdata (G_OBJECT (self),
|
||||||
|
unsolicited_events_supported,
|
||||||
|
GUINT_TO_POINTER (TRUE));
|
||||||
|
|
||||||
|
/* Go on to next step */
|
||||||
|
ctx->step++;
|
||||||
|
interface_enabling_step (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
enable_unsolicited_events_ready (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
EnablingContext *ctx)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
MM_IFACE_MODEM_GET_INTERFACE (self)->enable_unsolicited_events_finish (self, res, &error);
|
||||||
|
if (error) {
|
||||||
|
/* This error shouldn't be treated as critical */
|
||||||
|
mm_dbg ("Enabling unsolicited events failed: '%s'", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
|
||||||
|
/* Reset support flag */
|
||||||
|
g_object_set_qdata (G_OBJECT (self),
|
||||||
|
unsolicited_events_supported,
|
||||||
|
GUINT_TO_POINTER (FALSE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Go on to next step */
|
||||||
|
ctx->step++;
|
||||||
|
interface_enabling_step (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
load_supported_charsets_ready (MMIfaceModem *self,
|
load_supported_charsets_ready (MMIfaceModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
@@ -1720,6 +1803,13 @@ interface_enabling_step (EnablingContext *ctx)
|
|||||||
{
|
{
|
||||||
switch (ctx->step) {
|
switch (ctx->step) {
|
||||||
case ENABLING_STEP_FIRST:
|
case ENABLING_STEP_FIRST:
|
||||||
|
/* Setup quarks if we didn't do it before */
|
||||||
|
if (G_UNLIKELY (!indicators_checked))
|
||||||
|
indicators_checked = (g_quark_from_static_string (
|
||||||
|
INDICATORS_CHECKED_TAG));
|
||||||
|
if (G_UNLIKELY (!unsolicited_events_supported))
|
||||||
|
unsolicited_events_supported = (g_quark_from_static_string (
|
||||||
|
UNSOLICITED_EVENTS_SUPPORTED_TAG));
|
||||||
/* Fall down to next step */
|
/* Fall down to next step */
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
|
|
||||||
@@ -1847,6 +1937,44 @@ interface_enabling_step (EnablingContext *ctx)
|
|||||||
/* Fall down to next step */
|
/* Fall down to next step */
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
|
|
||||||
|
case ENABLING_STEP_SETUP_INDICATORS:
|
||||||
|
if (!GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (ctx->self),
|
||||||
|
indicators_checked))) {
|
||||||
|
/* Set the checked flag so that we don't run it again */
|
||||||
|
g_object_set_qdata (G_OBJECT (ctx->self),
|
||||||
|
indicators_checked,
|
||||||
|
GUINT_TO_POINTER (TRUE));
|
||||||
|
/* Initially, assume we don't support unsolicited events */
|
||||||
|
g_object_set_qdata (G_OBJECT (ctx->self),
|
||||||
|
unsolicited_events_supported,
|
||||||
|
GUINT_TO_POINTER (FALSE));
|
||||||
|
if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->setup_indicators &&
|
||||||
|
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->setup_indicators_finish) {
|
||||||
|
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->setup_indicators (
|
||||||
|
ctx->self,
|
||||||
|
(GAsyncReadyCallback)setup_indicators_ready,
|
||||||
|
ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Fall down to next step */
|
||||||
|
ctx->step++;
|
||||||
|
|
||||||
|
case ENABLING_STEP_ENABLE_UNSOLICITED_EVENTS:
|
||||||
|
if (!GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (ctx->self),
|
||||||
|
unsolicited_events_supported))) {
|
||||||
|
if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->enable_unsolicited_events &&
|
||||||
|
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->enable_unsolicited_events_finish) {
|
||||||
|
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->enable_unsolicited_events (
|
||||||
|
ctx->self,
|
||||||
|
(GAsyncReadyCallback)enable_unsolicited_events_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);
|
||||||
|
@@ -221,6 +221,30 @@ struct _MMIfaceModem {
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
/* Asynchronous setup of indicators */
|
||||||
|
void (*setup_indicators) (MMIfaceModem *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
gboolean (*setup_indicators_finish) (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
/* Asynchronous enabling of unsolicited events */
|
||||||
|
void (*enable_unsolicited_events) (MMIfaceModem *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
gboolean (*enable_unsolicited_events_finish) (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
/* Asynchronous disabling of unsolicited events */
|
||||||
|
void (*disable_unsolicited_events) (MMIfaceModem *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
gboolean (*disable_unsolicited_events_finish) (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
/* Asynchronous modem power-down operation */
|
/* Asynchronous modem power-down operation */
|
||||||
void (*modem_power_down) (MMIfaceModem *self,
|
void (*modem_power_down) (MMIfaceModem *self,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
|
Reference in New Issue
Block a user