diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-12 07:30:51 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-08-06 20:07:22 +0200 |
commit | b25b7f91cb625c4a89e1322797b2fa03134ddc3c (patch) | |
tree | 1fe54ddc12a47b5daf478523b94f9d7d05e6cc43 /plugins | |
parent | 98f28db6e3bae0c38bc6e0679317fb38eb6d9ece (diff) |
huawei: setup/cleanup unsolicited message handlers in the 3GPP interface
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/huawei/mm-broadband-modem-huawei.c | 103 |
1 files changed, 102 insertions, 1 deletions
diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c index 2f4e49e6..d1cb4178 100644 --- a/plugins/huawei/mm-broadband-modem-huawei.c +++ b/plugins/huawei/mm-broadband-modem-huawei.c @@ -27,9 +27,15 @@ #include "mm-log.h" #include "mm-errors-types.h" #include "mm-base-modem-at.h" +#include "mm-iface-modem-3gpp.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 { /* Regex for signal quality related notifications */ @@ -46,6 +52,7 @@ struct _MMBroadbandModemHuaweiPrivate { }; /*****************************************************************************/ +/* Setup/Cleanup unsolicited events (3GPP interface) */ static void 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) */ @@ -179,6 +269,17 @@ finalize (GObject *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 mm_broadband_modem_huawei_class_init (MMBroadbandModemHuaweiClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); |