From 6b827cc7a306ef2f3719ba7310952305b97fa04c Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sat, 13 Apr 2013 15:20:07 +0200 Subject: broadband-modem-mbim: implement 3GPP unsolicited messages setup/cleanup --- src/mm-broadband-modem-mbim.c | 78 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index 6dc882a7..cad53173 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -49,6 +49,9 @@ struct _MMBroadbandModemMbimPrivate { guint caps_max_sessions; gchar *caps_device_id; gchar *caps_firmware_info; + + /* Process unsolicited notifications */ + guint notification_id; }; /*****************************************************************************/ @@ -1353,6 +1356,76 @@ modem_3gpp_load_enabled_facility_locks (MMIfaceModem3gpp *self, mbim_message_unref (message); } +/*****************************************************************************/ +/* Setup/cleanup unsolicited events */ + +static void +device_notification_cb (MbimDevice *device, + MbimMessage *notification, + MMBroadbandModemMbim *self) +{ +} + +static gboolean +common_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 +common_setup_cleanup_unsolicited_events (MMIfaceModem3gpp *_self, + gboolean setup, + GAsyncReadyCallback callback, + gpointer user_data) +{ + MMBroadbandModemMbim *self = MM_BROADBAND_MODEM_MBIM (_self); + MbimDevice *device; + GSimpleAsyncResult *result; + + if (!peek_device (self, &device, callback, user_data)) + return; + + result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + common_setup_cleanup_unsolicited_events); + + if (setup) { + if (!self->priv->notification_id) + self->priv->notification_id = + g_signal_connect (device, + MBIM_DEVICE_SIGNAL_INDICATE_STATUS, + G_CALLBACK (device_notification_cb), + self); + } else { + if (self->priv->notification_id && + g_signal_handler_is_connected (device, self->priv->notification_id)) + g_signal_handler_disconnect (device, self->priv->notification_id); + self->priv->notification_id = 0; + } + + g_simple_async_result_complete_in_idle (result); + g_object_unref (result); +} + +static void +cleanup_unsolicited_events (MMIfaceModem3gpp *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + common_setup_cleanup_unsolicited_events (self, FALSE, callback, user_data); +} + +static void +setup_unsolicited_events (MMIfaceModem3gpp *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + common_setup_cleanup_unsolicited_events (self, TRUE, callback, user_data); +} + /*****************************************************************************/ MMBroadbandModemMbim * @@ -1458,6 +1531,11 @@ iface_modem_3gpp_init (MMIfaceModem3gpp *iface) iface->load_imei_finish = modem_3gpp_load_imei_finish; iface->load_enabled_facility_locks = modem_3gpp_load_enabled_facility_locks; iface->load_enabled_facility_locks_finish = modem_3gpp_load_enabled_facility_locks_finish; + + iface->setup_unsolicited_events = setup_unsolicited_events; + iface->setup_unsolicited_events_finish = common_setup_cleanup_unsolicited_events_finish; + iface->cleanup_unsolicited_events = cleanup_unsolicited_events; + iface->cleanup_unsolicited_events_finish = common_setup_cleanup_unsolicited_events_finish; } static void -- cgit v1.2.3