huawei: setup/cleanup unsolicited message handlers in the 3GPP interface
This commit is contained in:
@@ -27,9 +27,15 @@
|
|||||||
#include "mm-log.h"
|
#include "mm-log.h"
|
||||||
#include "mm-errors-types.h"
|
#include "mm-errors-types.h"
|
||||||
#include "mm-base-modem-at.h"
|
#include "mm-base-modem-at.h"
|
||||||
|
#include "mm-iface-modem-3gpp.h"
|
||||||
#include "mm-broadband-modem-huawei.h"
|
#include "mm-broadband-modem-huawei.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (MMBroadbandModemHuawei, mm_broadband_modem_huawei, MM_TYPE_BROADBAND_MODEM);
|
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
|
||||||
|
|
||||||
|
static MMIfaceModem3gpp *iface_modem_3gpp_parent;
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemHuawei, mm_broadband_modem_huawei, MM_TYPE_BROADBAND_MODEM, 0,
|
||||||
|
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init));
|
||||||
|
|
||||||
struct _MMBroadbandModemHuaweiPrivate {
|
struct _MMBroadbandModemHuaweiPrivate {
|
||||||
/* Regex for signal quality related notifications */
|
/* Regex for signal quality related notifications */
|
||||||
@@ -46,6 +52,7 @@ struct _MMBroadbandModemHuaweiPrivate {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
/* Setup/Cleanup unsolicited events (3GPP interface) */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
huawei_signal_changed (MMAtSerialPort *port,
|
huawei_signal_changed (MMAtSerialPort *port,
|
||||||
@@ -116,6 +123,89 @@ set_3gpp_unsolicited_events_handlers (MMBroadbandModemHuawei *self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
modem_3gpp_setup_cleanup_unsolicited_events_finish (MMIfaceModem3gpp *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
parent_3gpp_setup_unsolicited_events_ready (MMIfaceModem3gpp *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GSimpleAsyncResult *simple)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!iface_modem_3gpp_parent->setup_unsolicited_events_finish (self, res, &error))
|
||||||
|
g_simple_async_result_take_error (simple, error);
|
||||||
|
else {
|
||||||
|
/* Our own setup now */
|
||||||
|
set_3gpp_unsolicited_events_handlers (MM_BROADBAND_MODEM_HUAWEI (self), TRUE);
|
||||||
|
g_simple_async_result_set_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res), TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_simple_async_result_complete (simple);
|
||||||
|
g_object_unref (simple);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
modem_3gpp_setup_unsolicited_events (MMIfaceModem3gpp *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GSimpleAsyncResult *result;
|
||||||
|
|
||||||
|
result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
modem_3gpp_setup_unsolicited_events);
|
||||||
|
|
||||||
|
/* Chain up parent's setup */
|
||||||
|
iface_modem_3gpp_parent->setup_unsolicited_events (
|
||||||
|
self,
|
||||||
|
(GAsyncReadyCallback)parent_3gpp_setup_unsolicited_events_ready,
|
||||||
|
result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
parent_3gpp_cleanup_unsolicited_events_ready (MMIfaceModem3gpp *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GSimpleAsyncResult *simple)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!iface_modem_3gpp_parent->cleanup_unsolicited_events_finish (self, res, &error))
|
||||||
|
g_simple_async_result_take_error (simple, error);
|
||||||
|
else
|
||||||
|
g_simple_async_result_set_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res), TRUE);
|
||||||
|
g_simple_async_result_complete (simple);
|
||||||
|
g_object_unref (simple);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
modem_3gpp_cleanup_unsolicited_events (MMIfaceModem3gpp *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GSimpleAsyncResult *result;
|
||||||
|
|
||||||
|
result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
modem_3gpp_cleanup_unsolicited_events);
|
||||||
|
|
||||||
|
/* Our own cleanup first */
|
||||||
|
set_3gpp_unsolicited_events_handlers (MM_BROADBAND_MODEM_HUAWEI (self), FALSE);
|
||||||
|
|
||||||
|
/* And now chain up parent's cleanup */
|
||||||
|
iface_modem_3gpp_parent->cleanup_unsolicited_events (
|
||||||
|
self,
|
||||||
|
(GAsyncReadyCallback)parent_3gpp_cleanup_unsolicited_events_ready,
|
||||||
|
result);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Setup ports (Broadband modem class) */
|
/* Setup ports (Broadband modem class) */
|
||||||
|
|
||||||
@@ -178,6 +268,17 @@ finalize (GObject *object)
|
|||||||
G_OBJECT_CLASS (mm_broadband_modem_huawei_parent_class)->finalize (object);
|
G_OBJECT_CLASS (mm_broadband_modem_huawei_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
|
||||||
|
{
|
||||||
|
iface_modem_3gpp_parent = g_type_interface_peek_parent (iface);
|
||||||
|
|
||||||
|
iface->setup_unsolicited_events = modem_3gpp_setup_unsolicited_events;
|
||||||
|
iface->setup_unsolicited_events_finish = modem_3gpp_setup_cleanup_unsolicited_events_finish;
|
||||||
|
iface->cleanup_unsolicited_events = modem_3gpp_cleanup_unsolicited_events;
|
||||||
|
iface->cleanup_unsolicited_events_finish = modem_3gpp_setup_cleanup_unsolicited_events_finish;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mm_broadband_modem_huawei_class_init (MMBroadbandModemHuaweiClass *klass)
|
mm_broadband_modem_huawei_class_init (MMBroadbandModemHuaweiClass *klass)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user