32
32
#include "mm-log.h"
33
33
#include "mm-modem-helpers.h"
34
34
#include "mm-error-helpers.h"
35
#include "mm-daemon-enums-types.h"
36
37
G_DEFINE_TYPE (MMBroadbandBearerIcera, mm_broadband_bearer_icera, MM_TYPE_BROADBAND_BEARER);
362
363
report_disconnect_status (MMBroadbandBearerIcera *self,
363
MMBroadbandBearerIceraConnectionStatus status)
364
MMBearerConnectionStatus status)
365
366
Disconnect3gppContext *ctx;
367
368
/* Recover context */
368
369
ctx = self->priv->disconnect_pending;
369
370
self->priv->disconnect_pending = NULL;
371
g_assert (ctx != NULL);
371
373
/* Cleanup timeout, if any */
372
374
if (self->priv->disconnect_pending_id) {
374
376
self->priv->disconnect_pending_id = 0;
378
case MM_BROADBAND_BEARER_ICERA_CONNECTION_STATUS_UNKNOWN:
379
g_warn_if_reached ();
382
case MM_BROADBAND_BEARER_ICERA_CONNECTION_STATUS_CONNECTED:
379
/* Received 'CONNECTED' during a disconnection attempt? */
380
if (status == MM_BEARER_CONNECTION_STATUS_CONNECTED) {
386
381
g_simple_async_result_set_error (ctx->result,
388
383
MM_CORE_ERROR_FAILED,
389
384
"Disconnection failed");
390
385
disconnect_3gpp_context_complete_and_free (ctx);
393
case MM_BROADBAND_BEARER_ICERA_CONNECTION_STATUS_CONNECTION_FAILED:
397
/* Well, this actually means disconnection, right? */
398
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
399
disconnect_3gpp_context_complete_and_free (ctx);
402
case MM_BROADBAND_BEARER_ICERA_CONNECTION_STATUS_DISCONNECTED:
404
mm_dbg ("Received spontaneous %%IPDPACT disconnect");
405
mm_bearer_report_disconnection (MM_BEARER (self));
409
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
410
disconnect_3gpp_context_complete_and_free (ctx);
389
/* Received 'DISCONNECTED' during a disconnection attempt? */
390
if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED ||
391
status == MM_BEARER_CONNECTION_STATUS_CONNECTION_FAILED) {
392
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
393
disconnect_3gpp_context_complete_and_free (ctx);
397
/* No other status is expected by this implementation */
398
g_assert_not_reached ();
658
644
MMBroadbandBearerIcera *self)
660
646
/* Just treat the forced close event as any other unsolicited message */
661
mm_broadband_bearer_icera_report_connection_status (
663
MM_BROADBAND_BEARER_ICERA_CONNECTION_STATUS_CONNECTION_FAILED);
647
mm_bearer_report_connection_status (MM_BEARER (self),
648
MM_BEARER_CONNECTION_STATUS_CONNECTION_FAILED);
701
686
report_connect_status (MMBroadbandBearerIcera *self,
702
MMBroadbandBearerIceraConnectionStatus status)
687
MMBearerConnectionStatus status)
704
689
Dial3gppContext *ctx;
691
g_assert (status == MM_BEARER_CONNECTION_STATUS_CONNECTED ||
692
status == MM_BEARER_CONNECTION_STATUS_CONNECTION_FAILED ||
693
status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED);
706
695
/* Recover context and remove it from the private info */
707
696
ctx = self->priv->connect_pending;
708
697
self->priv->connect_pending = NULL;
698
g_assert (ctx != NULL);
710
700
/* Cleanup cancellable, timeout and port closed watch, if any */
711
701
if (self->priv->connect_pending_id) {
713
703
self->priv->connect_pending_id = 0;
716
if (ctx && self->priv->connect_cancellable_id) {
706
if (self->priv->connect_cancellable_id) {
717
707
g_cancellable_disconnect (ctx->cancellable,
718
708
self->priv->connect_cancellable_id);
719
709
self->priv->connect_cancellable_id = 0;
722
if (ctx && self->priv->connect_port_closed_id) {
712
if (self->priv->connect_port_closed_id) {
723
713
g_signal_handler_disconnect (ctx->primary, self->priv->connect_port_closed_id);
724
714
self->priv->connect_port_closed_id = 0;
728
case MM_BROADBAND_BEARER_ICERA_CONNECTION_STATUS_UNKNOWN:
731
case MM_BROADBAND_BEARER_ICERA_CONNECTION_STATUS_CONNECTED:
733
/* We may get this if the timeout for the connection attempt is
734
* reached before the unsolicited response. We should probably
735
* keep the CID around to request explicit disconnection in this
717
/* Received 'CONNECTED' during a connection attempt? */
718
if (status == MM_BEARER_CONNECTION_STATUS_CONNECTED) {
739
719
/* If we wanted to get cancelled before, do it now */
740
720
if (ctx->saved_error) {
751
731
(GDestroyNotify)g_object_unref);
752
732
dial_3gpp_context_complete_and_free (ctx);
755
case MM_BROADBAND_BEARER_ICERA_CONNECTION_STATUS_CONNECTION_FAILED:
759
/* If we wanted to get cancelled before and now we couldn't connect,
760
* use the cancelled error and return */
761
if (ctx->saved_error) {
762
g_simple_async_result_take_error (ctx->result, ctx->saved_error);
763
ctx->saved_error = NULL;
764
dial_3gpp_context_complete_and_free (ctx);
736
/* If we wanted to get cancelled before and now we couldn't connect,
737
* use the cancelled error and return */
738
if (ctx->saved_error) {
739
g_simple_async_result_take_error (ctx->result, ctx->saved_error);
740
ctx->saved_error = NULL;
741
dial_3gpp_context_complete_and_free (ctx);
745
/* Received CONNECTION_FAILED during a connection attempt? */
746
if (status == MM_BEARER_CONNECTION_STATUS_CONNECTION_FAILED) {
768
747
/* Try to gather additional info about the connection failure */
769
748
mm_base_modem_at_command_full (
777
756
(GAsyncReadyCallback)ier_query_ready,
781
case MM_BROADBAND_BEARER_ICERA_CONNECTION_STATUS_DISCONNECTED:
783
/* If we wanted to get cancelled before and now we couldn't connect,
784
* use the cancelled error and return */
785
if (ctx->saved_error) {
786
g_simple_async_result_take_error (ctx->result, ctx->saved_error);
787
ctx->saved_error = NULL;
788
dial_3gpp_context_complete_and_free (ctx);
792
g_simple_async_result_set_error (ctx->result,
794
MM_CORE_ERROR_FAILED,
795
"Call setup failed");
796
dial_3gpp_context_complete_and_free (ctx);
800
/* Just ensure we mark ourselves as being disconnected... */
801
mm_bearer_report_disconnection (MM_BEARER (self));
805
g_warn_if_reached ();
761
/* Otherwise, received 'DISCONNECTED' during a connection attempt? */
762
g_simple_async_result_set_error (ctx->result,
764
MM_CORE_ERROR_FAILED,
765
"Call setup failed");
766
dial_3gpp_context_complete_and_free (ctx);
1061
1022
/*****************************************************************************/
1064
mm_broadband_bearer_icera_report_connection_status (MMBroadbandBearerIcera *self,
1065
MMBroadbandBearerIceraConnectionStatus status)
1025
report_connection_status (MMBearer *bearer,
1026
MMBearerConnectionStatus status)
1067
if (self->priv->connect_pending)
1028
MMBroadbandBearerIcera *self = MM_BROADBAND_BEARER_ICERA (bearer);
1030
/* Process pending connection attempt */
1031
if (self->priv->connect_pending) {
1068
1032
report_connect_status (self, status);
1070
if (self->priv->disconnect_pending)
1036
/* Process pending disconnection attempt */
1037
if (self->priv->disconnect_pending) {
1071
1038
report_disconnect_status (self, status);
1042
mm_dbg ("Received spontaneous %%IPDPACT (%s)",
1043
mm_bearer_connection_status_get_string (status));
1045
/* Received a random 'DISCONNECTED'...*/
1046
if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED ||
1047
status == MM_BEARER_CONNECTION_STATUS_CONNECTION_FAILED) {
1048
/* If no connection/disconnection attempt on-going, make sure we mark ourselves as
1049
* disconnected. Make sure we only pass 'DISCONNECTED' to the parent */
1050
MM_BEARER_CLASS (mm_broadband_bearer_icera_parent_class)->report_connection_status (
1052
MM_BEARER_CONNECTION_STATUS_DISCONNECTED);
1074
1056
/*****************************************************************************/
1165
1147
mm_broadband_bearer_icera_class_init (MMBroadbandBearerIceraClass *klass)
1167
1149
GObjectClass *object_class = G_OBJECT_CLASS (klass);
1150
MMBearerClass *bearer_class = MM_BEARER_CLASS (klass);
1168
1151
MMBroadbandBearerClass *broadband_bearer_class = MM_BROADBAND_BEARER_CLASS (klass);
1170
1153
g_type_class_add_private (object_class, sizeof (MMBroadbandBearerIceraPrivate));
1172
1155
object_class->get_property = get_property;
1173
1156
object_class->set_property = set_property;
1157
bearer_class->report_connection_status = report_connection_status;
1174
1158
broadband_bearer_class->dial_3gpp = dial_3gpp;
1175
1159
broadband_bearer_class->dial_3gpp_finish = dial_3gpp_finish;
1176
1160
broadband_bearer_class->get_ip_config_3gpp = get_ip_config_3gpp;