base-modem: new port getters and peekers
* mm_base_modem_peek_port_* () will return either a port object (no new reference), or NULL if none available. You would usually peek() a port if you're going to use it just in the current method, as there is no way to that reference to get invalid (we're single threaded). * mm_base_modem_get_port_* () will return either NEW references to valid port objects, or NULL if none available. And, you would usually get() a port, whenever you want the port object to be valid even out of the current method, for example when keeping it in the context of an async operation. Also, we need to consider that the primary AT port MAY BE NULL when you peek() or get() it. This is due to the fact that we may be releasing ports (due to device disconnection) in the middle of async operations.
This commit is contained in:
@@ -277,7 +277,7 @@ mm_base_modem_at_sequence (MMBaseModem *self,
|
||||
GError *error = NULL;
|
||||
|
||||
/* No port given, so we'll try to guess which is best */
|
||||
port = mm_base_modem_get_best_at_port (self, &error);
|
||||
port = mm_base_modem_peek_best_at_port (self, &error);
|
||||
if (!port) {
|
||||
g_assert (error != NULL);
|
||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (self),
|
||||
@@ -487,7 +487,7 @@ mm_base_modem_at_command (MMBaseModem *self,
|
||||
GError *error = NULL;
|
||||
|
||||
/* No port given, so we'll try to guess which is best */
|
||||
port = mm_base_modem_get_best_at_port (self, &error);
|
||||
port = mm_base_modem_peek_best_at_port (self, &error);
|
||||
if (!port) {
|
||||
g_assert (error != NULL);
|
||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (self),
|
||||
@@ -536,7 +536,7 @@ mm_base_modem_at_command_ignore_reply (MMBaseModem *self,
|
||||
MMAtSerialPort *port;
|
||||
|
||||
/* No port given, so we'll try to guess which is best */
|
||||
port = mm_base_modem_get_best_at_port (self, NULL);
|
||||
port = mm_base_modem_peek_best_at_port (self, NULL);
|
||||
if (!port)
|
||||
/* No valid port, and we ignore replies, so just exit. */
|
||||
return;
|
||||
|
||||
+49
-8
@@ -325,6 +325,14 @@ mm_base_modem_get_port_primary (MMBaseModem *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_BASE_MODEM (self), NULL);
|
||||
|
||||
return (self->priv->primary ? g_object_ref (self->priv->primary) : NULL);
|
||||
}
|
||||
|
||||
MMAtSerialPort *
|
||||
mm_base_modem_peek_port_primary (MMBaseModem *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_BASE_MODEM (self), NULL);
|
||||
|
||||
return self->priv->primary;
|
||||
}
|
||||
|
||||
@@ -333,6 +341,14 @@ mm_base_modem_get_port_secondary (MMBaseModem *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_BASE_MODEM (self), NULL);
|
||||
|
||||
return (self->priv->secondary ? g_object_ref (self->priv->secondary) : NULL);
|
||||
}
|
||||
|
||||
MMAtSerialPort *
|
||||
mm_base_modem_peek_port_secondary (MMBaseModem *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_BASE_MODEM (self), NULL);
|
||||
|
||||
return self->priv->secondary;
|
||||
}
|
||||
|
||||
@@ -341,11 +357,28 @@ mm_base_modem_get_port_qcdm (MMBaseModem *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_BASE_MODEM (self), NULL);
|
||||
|
||||
return (self->priv->qcdm ? g_object_ref (self->priv->qcdm) : NULL);
|
||||
}
|
||||
|
||||
MMQcdmSerialPort *
|
||||
mm_base_modem_peek_port_qcdm (MMBaseModem *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_BASE_MODEM (self), NULL);
|
||||
|
||||
return self->priv->qcdm;
|
||||
}
|
||||
|
||||
MMPort *
|
||||
mm_base_modem_get_best_data_port (MMBaseModem *self)
|
||||
{
|
||||
MMPort *port;
|
||||
|
||||
port = mm_base_modem_peek_best_data_port (self);
|
||||
return (port ? g_object_ref (port) : NULL);
|
||||
}
|
||||
|
||||
MMPort *
|
||||
mm_base_modem_peek_best_data_port (MMBaseModem *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_BASE_MODEM (self), NULL);
|
||||
|
||||
@@ -361,24 +394,32 @@ MMAtSerialPort *
|
||||
mm_base_modem_get_best_at_port (MMBaseModem *self,
|
||||
GError **error)
|
||||
{
|
||||
MMAtSerialPort *port;
|
||||
MMAtSerialPort *best;
|
||||
|
||||
best = mm_base_modem_peek_best_at_port (self, error);
|
||||
return (best ? g_object_ref (best) : NULL);
|
||||
}
|
||||
|
||||
MMAtSerialPort *
|
||||
mm_base_modem_peek_best_at_port (MMBaseModem *self,
|
||||
GError **error)
|
||||
{
|
||||
/* Decide which port to use */
|
||||
port = mm_base_modem_get_port_primary (self);
|
||||
if (port && !mm_port_get_connected (MM_PORT (port)))
|
||||
return port;
|
||||
if (self->priv->primary &&
|
||||
!mm_port_get_connected (MM_PORT (self->priv->primary)))
|
||||
return self->priv->primary;
|
||||
|
||||
/* If primary port is connected, check if we can get the secondary
|
||||
* port */
|
||||
port = mm_base_modem_get_port_secondary (self);
|
||||
if (port && !mm_port_get_connected (MM_PORT (port)))
|
||||
return port;
|
||||
if (self->priv->secondary &&
|
||||
!mm_port_get_connected (MM_PORT (self->priv->secondary)))
|
||||
return self->priv->secondary;
|
||||
|
||||
/* Otherwise, we cannot get any port */
|
||||
g_set_error (error,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_CONNECTED,
|
||||
"No port available to run command");
|
||||
"No AT port available to run command");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
+14
-6
@@ -114,12 +114,20 @@ gboolean mm_base_modem_owns_port (MMBaseModem *self,
|
||||
gboolean mm_base_modem_organize_ports (MMBaseModem *self,
|
||||
GError **error);
|
||||
|
||||
MMAtSerialPort *mm_base_modem_get_port_primary (MMBaseModem *self);
|
||||
MMAtSerialPort *mm_base_modem_get_port_secondary (MMBaseModem *self);
|
||||
MMQcdmSerialPort *mm_base_modem_get_port_qcdm (MMBaseModem *self);
|
||||
MMPort *mm_base_modem_get_best_data_port (MMBaseModem *self);
|
||||
MMAtSerialPort *mm_base_modem_get_best_at_port (MMBaseModem *self,
|
||||
GError **error);
|
||||
MMAtSerialPort *mm_base_modem_peek_port_primary (MMBaseModem *self);
|
||||
MMAtSerialPort *mm_base_modem_peek_port_secondary (MMBaseModem *self);
|
||||
MMQcdmSerialPort *mm_base_modem_peek_port_qcdm (MMBaseModem *self);
|
||||
MMAtSerialPort *mm_base_modem_peek_best_at_port (MMBaseModem *self,
|
||||
GError **error);
|
||||
MMPort *mm_base_modem_peek_best_data_port (MMBaseModem *self);
|
||||
|
||||
MMAtSerialPort *mm_base_modem_get_port_primary (MMBaseModem *self);
|
||||
MMAtSerialPort *mm_base_modem_get_port_secondary (MMBaseModem *self);
|
||||
MMQcdmSerialPort *mm_base_modem_get_port_qcdm (MMBaseModem *self);
|
||||
MMAtSerialPort *mm_base_modem_get_best_at_port (MMBaseModem *self,
|
||||
GError **error);
|
||||
MMPort *mm_base_modem_get_best_data_port (MMBaseModem *self);
|
||||
|
||||
|
||||
void mm_base_modem_set_valid (MMBaseModem *self,
|
||||
gboolean valid);
|
||||
|
||||
+62
-11
@@ -412,6 +412,8 @@ connect_cdma (MMBroadbandBearer *self,
|
||||
{
|
||||
DetailedConnectContext *ctx;
|
||||
|
||||
g_assert (primary != NULL);
|
||||
|
||||
ctx = detailed_connect_context_new (self,
|
||||
modem,
|
||||
primary,
|
||||
@@ -591,6 +593,8 @@ dial_3gpp (MMBroadbandBearer *self,
|
||||
gchar *command;
|
||||
Dial3gppContext *ctx;
|
||||
|
||||
g_assert (primary != NULL);
|
||||
|
||||
ctx = dial_3gpp_context_new (self,
|
||||
modem,
|
||||
primary,
|
||||
@@ -899,6 +903,8 @@ connect_3gpp (MMBroadbandBearer *self,
|
||||
{
|
||||
DetailedConnectContext *ctx;
|
||||
|
||||
g_assert (primary != NULL);
|
||||
|
||||
ctx = detailed_connect_context_new (self,
|
||||
modem,
|
||||
primary,
|
||||
@@ -1084,8 +1090,21 @@ connect (MMBearer *self,
|
||||
NULL);
|
||||
g_assert (modem != NULL);
|
||||
|
||||
/* We will launch the ATD call in the primary port */
|
||||
primary = mm_base_modem_get_port_primary (modem);
|
||||
/* We will launch the ATD call in the primary port... */
|
||||
primary = mm_base_modem_peek_port_primary (modem);
|
||||
if (!primary) {
|
||||
g_simple_async_report_error_in_idle (
|
||||
G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_CONNECTED,
|
||||
"Couldn't connect: couldn't get primary port");
|
||||
g_object_unref (modem);
|
||||
return;
|
||||
}
|
||||
|
||||
/* ...only if not already connected */
|
||||
if (mm_port_get_connected (MM_PORT (primary))) {
|
||||
g_simple_async_report_error_in_idle (
|
||||
G_OBJECT (self),
|
||||
@@ -1099,7 +1118,7 @@ connect (MMBearer *self,
|
||||
}
|
||||
|
||||
/* Look for best data port, NULL if none available. */
|
||||
data = mm_base_modem_get_best_data_port (modem);
|
||||
data = mm_base_modem_peek_best_data_port (modem);
|
||||
if (!data) {
|
||||
g_simple_async_report_error_in_idle (
|
||||
G_OBJECT (self),
|
||||
@@ -1149,7 +1168,7 @@ connect (MMBearer *self,
|
||||
MM_BROADBAND_BEARER (self),
|
||||
MM_BROADBAND_MODEM (modem),
|
||||
primary,
|
||||
mm_base_modem_get_port_secondary (modem),
|
||||
mm_base_modem_peek_port_secondary (modem),
|
||||
data,
|
||||
cancellable,
|
||||
(GAsyncReadyCallback) connect_3gpp_ready,
|
||||
@@ -1170,7 +1189,7 @@ connect (MMBearer *self,
|
||||
MM_BROADBAND_BEARER (self),
|
||||
MM_BROADBAND_MODEM (modem),
|
||||
primary,
|
||||
mm_base_modem_get_port_secondary (modem),
|
||||
mm_base_modem_peek_port_secondary (modem),
|
||||
data,
|
||||
cancellable,
|
||||
(GAsyncReadyCallback) connect_cdma_ready,
|
||||
@@ -1294,6 +1313,8 @@ disconnect_cdma (MMBroadbandBearer *self,
|
||||
{
|
||||
DetailedDisconnectContext *ctx;
|
||||
|
||||
g_assert (primary != NULL);
|
||||
|
||||
ctx = detailed_disconnect_context_new (self,
|
||||
modem,
|
||||
primary,
|
||||
@@ -1419,6 +1440,8 @@ disconnect_3gpp (MMBroadbandBearer *self,
|
||||
{
|
||||
DetailedDisconnectContext *ctx;
|
||||
|
||||
g_assert (primary != NULL);
|
||||
|
||||
ctx = detailed_disconnect_context_new (self,
|
||||
modem,
|
||||
primary,
|
||||
@@ -1552,6 +1575,7 @@ disconnect (MMBearer *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMAtSerialPort *primary;
|
||||
MMBaseModem *modem = NULL;
|
||||
DisconnectContext *ctx;
|
||||
|
||||
@@ -1571,6 +1595,20 @@ disconnect (MMBearer *self,
|
||||
NULL);
|
||||
g_assert (modem != NULL);
|
||||
|
||||
/* We need the primary port to disconnect... */
|
||||
primary = mm_base_modem_peek_port_primary (modem);
|
||||
if (!primary) {
|
||||
g_simple_async_report_error_in_idle (
|
||||
G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
"Couldn't disconnect: couldn't get primary port");
|
||||
g_object_unref (modem);
|
||||
return;
|
||||
}
|
||||
|
||||
/* In this context, we only keep the stuff we'll need later */
|
||||
ctx = g_new0 (DisconnectContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
@@ -1585,8 +1623,8 @@ disconnect (MMBearer *self,
|
||||
MM_BROADBAND_BEARER_GET_CLASS (self)->disconnect_3gpp (
|
||||
MM_BROADBAND_BEARER (self),
|
||||
MM_BROADBAND_MODEM (modem),
|
||||
mm_base_modem_get_port_primary (modem),
|
||||
mm_base_modem_get_port_secondary (modem),
|
||||
primary,
|
||||
mm_base_modem_peek_port_secondary (modem),
|
||||
MM_BROADBAND_BEARER (self)->priv->port,
|
||||
(GAsyncReadyCallback) disconnect_3gpp_ready,
|
||||
ctx);
|
||||
@@ -1596,8 +1634,8 @@ disconnect (MMBearer *self,
|
||||
MM_BROADBAND_BEARER_GET_CLASS (self)->disconnect_cdma (
|
||||
MM_BROADBAND_BEARER (self),
|
||||
MM_BROADBAND_MODEM (modem),
|
||||
mm_base_modem_get_port_primary (modem),
|
||||
mm_base_modem_get_port_secondary (modem),
|
||||
primary,
|
||||
mm_base_modem_peek_port_secondary (modem),
|
||||
MM_BROADBAND_BEARER (self)->priv->port,
|
||||
(GAsyncReadyCallback) disconnect_cdma_ready,
|
||||
ctx);
|
||||
@@ -1655,8 +1693,11 @@ static void
|
||||
init_async_context_free (InitAsyncContext *ctx,
|
||||
gboolean close_port)
|
||||
{
|
||||
if (close_port)
|
||||
mm_serial_port_close (MM_SERIAL_PORT (ctx->port));
|
||||
if (ctx->port) {
|
||||
if (close_port)
|
||||
mm_serial_port_close (MM_SERIAL_PORT (ctx->port));
|
||||
g_object_unref (ctx->port);
|
||||
}
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->modem);
|
||||
g_object_unref (ctx->result);
|
||||
@@ -1919,6 +1960,16 @@ initable_init_async (GAsyncInitable *initable,
|
||||
NULL);
|
||||
|
||||
ctx->port = mm_base_modem_get_port_primary (ctx->modem);
|
||||
if (!ctx->port) {
|
||||
g_simple_async_result_set_error (ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
"Couldn't get primary port");
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
init_async_context_free (ctx, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->port), &error)) {
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
|
||||
+102
-71
@@ -1246,7 +1246,6 @@ modem_load_signal_quality (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMSerialPort *port;
|
||||
SignalQualityContext *ctx;
|
||||
GError *error = NULL;
|
||||
|
||||
@@ -1259,9 +1258,8 @@ modem_load_signal_quality (MMIfaceModem *self,
|
||||
modem_load_signal_quality);
|
||||
|
||||
/* Check whether we can get a non-connected AT port */
|
||||
port = (MMSerialPort *)mm_base_modem_get_best_at_port (MM_BASE_MODEM (self), &error);
|
||||
if (port) {
|
||||
ctx->port = g_object_ref (port);
|
||||
ctx->port = (MMSerialPort *)mm_base_modem_get_best_at_port (MM_BASE_MODEM (self), &error);
|
||||
if (ctx->port) {
|
||||
if (MM_BROADBAND_MODEM (self)->priv->modem_cind_supported)
|
||||
signal_quality_cind (ctx);
|
||||
else
|
||||
@@ -1270,10 +1268,9 @@ modem_load_signal_quality (MMIfaceModem *self,
|
||||
}
|
||||
|
||||
/* If no best AT port available (all connected), try with QCDM ports */
|
||||
port = (MMSerialPort *)mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
|
||||
if (port) {
|
||||
ctx->port = (MMSerialPort *)mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
|
||||
if (ctx->port) {
|
||||
g_error_free (error);
|
||||
ctx->port = g_object_ref (port);
|
||||
signal_quality_qcdm (ctx);
|
||||
return;
|
||||
}
|
||||
@@ -1446,13 +1443,17 @@ set_unsolicited_events_handlers (MMIfaceModem3gpp *self,
|
||||
set_unsolicited_events_handlers);
|
||||
|
||||
ciev_regex = mm_3gpp_ciev_regex_get ();
|
||||
ports[0] = mm_base_modem_get_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
|
||||
ports[0] = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
|
||||
|
||||
/* Enable unsolicited events in given port */
|
||||
for (i = 0; ports[i] && i < 2; i++) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!ports[i])
|
||||
continue;
|
||||
|
||||
/* Set/unset unsolicited CIEV event handler */
|
||||
mm_dbg ("%s unsolicited events handlers",
|
||||
mm_dbg ("(%s) %s 3GPP unsolicited events handlers",
|
||||
mm_port_get_device (MM_PORT (ports[i])),
|
||||
enable ? "Setting" : "Removing");
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (
|
||||
ports[i],
|
||||
@@ -1546,10 +1547,10 @@ run_unsolicited_events_setup (UnsolicitedEventsContext *ctx)
|
||||
|
||||
if (!ctx->cmer_primary_done) {
|
||||
ctx->cmer_primary_done = TRUE;
|
||||
port = mm_base_modem_get_port_primary (MM_BASE_MODEM (ctx->self));
|
||||
port = mm_base_modem_peek_port_primary (MM_BASE_MODEM (ctx->self));
|
||||
} else if (!ctx->cmer_secondary_done) {
|
||||
ctx->cmer_secondary_done = TRUE;
|
||||
port = mm_base_modem_get_port_secondary (MM_BASE_MODEM (ctx->self));
|
||||
port = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (ctx->self));
|
||||
}
|
||||
|
||||
/* Enable unsolicited events in given port */
|
||||
@@ -2295,31 +2296,31 @@ modem_3gpp_setup_unsolicited_registration (MMIfaceModem3gpp *self,
|
||||
MMAtSerialPort *ports[2];
|
||||
GPtrArray *array;
|
||||
guint i;
|
||||
|
||||
mm_dbg ("setting up unsolicited registration messages handling");
|
||||
guint j;
|
||||
|
||||
result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
modem_3gpp_setup_unsolicited_registration);
|
||||
|
||||
ports[0] = mm_base_modem_get_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
|
||||
ports[0] = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
|
||||
|
||||
/* Set up CREG unsolicited message handlers in both ports */
|
||||
array = mm_3gpp_creg_regex_get (FALSE);
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (ports[i]) {
|
||||
guint j;
|
||||
if (!ports[i])
|
||||
continue;
|
||||
|
||||
for (j = 0; j < array->len; j++) {
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (
|
||||
MM_AT_SERIAL_PORT (ports[i]),
|
||||
(GRegex *) g_ptr_array_index (array, j),
|
||||
(MMAtSerialUnsolicitedMsgFn)registration_state_changed,
|
||||
self,
|
||||
NULL);
|
||||
}
|
||||
mm_dbg ("(%s) setting up 3GPP unsolicited registration messages handlers",
|
||||
mm_port_get_device (MM_PORT (ports[i])));
|
||||
for (j = 0; j < array->len; j++) {
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (
|
||||
MM_AT_SERIAL_PORT (ports[i]),
|
||||
(GRegex *) g_ptr_array_index (array, j),
|
||||
(MMAtSerialUnsolicitedMsgFn)registration_state_changed,
|
||||
self,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
mm_3gpp_creg_regex_destroy (array);
|
||||
@@ -2349,30 +2350,32 @@ modem_3gpp_cleanup_unsolicited_registration (MMIfaceModem3gpp *self,
|
||||
MMAtSerialPort *ports[2];
|
||||
GPtrArray *array;
|
||||
guint i;
|
||||
guint j;
|
||||
|
||||
mm_dbg ("cleaning up unsolicited registration messages handling");
|
||||
result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
modem_3gpp_cleanup_unsolicited_registration);
|
||||
|
||||
ports[0] = mm_base_modem_get_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
|
||||
ports[0] = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
|
||||
|
||||
/* Set up CREG unsolicited message handlers in both ports */
|
||||
array = mm_3gpp_creg_regex_get (FALSE);
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (ports[i]) {
|
||||
guint j;
|
||||
if (!ports[i])
|
||||
continue;
|
||||
|
||||
for (j = 0; j < array->len; j++) {
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (
|
||||
MM_AT_SERIAL_PORT (ports[i]),
|
||||
(GRegex *) g_ptr_array_index (array, j),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
mm_dbg ("(%s) cleaning up unsolicited registration messages handlers",
|
||||
mm_port_get_device (MM_PORT (ports[i])));
|
||||
|
||||
for (j = 0; j < array->len; j++) {
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (
|
||||
MM_AT_SERIAL_PORT (ports[i]),
|
||||
(GRegex *) g_ptr_array_index (array, j),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
mm_3gpp_creg_regex_destroy (array);
|
||||
@@ -2858,7 +2861,7 @@ cleanup_registration_sequence_ready (MMBroadbandModem *self,
|
||||
if (!ctx->secondary_done) {
|
||||
MMAtSerialPort *secondary;
|
||||
|
||||
secondary = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
|
||||
secondary = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
|
||||
if (secondary) {
|
||||
/* Now use the same registration setup in secondary port, if any */
|
||||
ctx->secondary_done = TRUE;
|
||||
@@ -2911,7 +2914,7 @@ modem_3gpp_cleanup_cs_registration (MMIfaceModem3gpp *self,
|
||||
|
||||
mm_base_modem_at_command_in_port (
|
||||
MM_BASE_MODEM (self),
|
||||
mm_base_modem_get_port_primary (MM_BASE_MODEM (self)),
|
||||
mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
|
||||
ctx->command,
|
||||
10,
|
||||
FALSE,
|
||||
@@ -2936,7 +2939,7 @@ modem_3gpp_cleanup_ps_registration (MMIfaceModem3gpp *self,
|
||||
|
||||
mm_base_modem_at_command_in_port (
|
||||
MM_BASE_MODEM (self),
|
||||
mm_base_modem_get_port_primary (MM_BASE_MODEM (self)),
|
||||
mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
|
||||
ctx->command,
|
||||
10,
|
||||
FALSE,
|
||||
@@ -3040,13 +3043,13 @@ setup_registration_sequence_ready (MMBroadbandModem *self,
|
||||
return;
|
||||
}
|
||||
|
||||
secondary = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
|
||||
secondary = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
|
||||
if (secondary) {
|
||||
/* Now use the same registration setup in secondary port, if any */
|
||||
ctx->secondary_done = TRUE;
|
||||
mm_base_modem_at_command_in_port (
|
||||
MM_BASE_MODEM (self),
|
||||
mm_base_modem_get_port_primary (MM_BASE_MODEM (self)),
|
||||
mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
|
||||
g_variant_get_string (command, NULL),
|
||||
3,
|
||||
FALSE,
|
||||
@@ -3078,7 +3081,7 @@ modem_3gpp_setup_cs_registration (MMIfaceModem3gpp *self,
|
||||
modem_3gpp_setup_cs_registration);
|
||||
mm_base_modem_at_sequence_in_port (
|
||||
MM_BASE_MODEM (self),
|
||||
mm_base_modem_get_port_primary (MM_BASE_MODEM (self)),
|
||||
mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
|
||||
cs_registration_sequence,
|
||||
NULL, /* response processor context */
|
||||
NULL, /* response processor context free */
|
||||
@@ -3101,7 +3104,7 @@ modem_3gpp_setup_ps_registration (MMIfaceModem3gpp *self,
|
||||
modem_3gpp_setup_ps_registration);
|
||||
mm_base_modem_at_sequence_in_port (
|
||||
MM_BASE_MODEM (self),
|
||||
mm_base_modem_get_port_primary (MM_BASE_MODEM (self)),
|
||||
mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
|
||||
ps_registration_sequence,
|
||||
NULL, /* response processor context */
|
||||
NULL, /* response processor context free */
|
||||
@@ -3501,13 +3504,16 @@ set_unsolicited_result_code_handlers (MMIfaceModem3gppUssd *self,
|
||||
set_unsolicited_events_handlers);
|
||||
|
||||
cusd_regex = mm_3gpp_cusd_regex_get ();
|
||||
ports[0] = mm_base_modem_get_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
|
||||
ports[0] = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
|
||||
|
||||
/* Enable unsolicited result codes in given port */
|
||||
for (i = 0; ports[i] && i < 2; i++) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!ports[i])
|
||||
continue;
|
||||
/* Set/unset unsolicited CUSD event handler */
|
||||
mm_dbg ("%s unsolicited result code handlers",
|
||||
mm_dbg ("(%s) %s unsolicited result code handlers",
|
||||
mm_port_get_device (MM_PORT (ports[i])),
|
||||
enable ? "Setting" : "Removing");
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (
|
||||
ports[i],
|
||||
@@ -4150,13 +4156,17 @@ set_messaging_unsolicited_events_handlers (MMIfaceModemMessaging *self,
|
||||
set_messaging_unsolicited_events_handlers);
|
||||
|
||||
cmti_regex = mm_3gpp_cmti_regex_get ();
|
||||
ports[0] = mm_base_modem_get_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
|
||||
ports[0] = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
|
||||
|
||||
/* Enable unsolicited events in given port */
|
||||
for (i = 0; ports[i] && i < 2; i++) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!ports[i])
|
||||
continue;
|
||||
|
||||
/* Set/unset unsolicited CMTI event handler */
|
||||
mm_dbg ("%s messaging unsolicited events handlers",
|
||||
mm_dbg ("(%s) %s messaging unsolicited events handlers",
|
||||
mm_port_get_device (MM_PORT (ports[i])),
|
||||
enable ? "Setting" : "Removing");
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (
|
||||
ports[i],
|
||||
@@ -4679,7 +4689,7 @@ modem_cdma_get_hdr_state (MMIfaceModemCdma *self,
|
||||
HdrStateContext *ctx;
|
||||
GByteArray *hdrstate;
|
||||
|
||||
qcdm = mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
|
||||
qcdm = mm_base_modem_peek_port_qcdm (MM_BASE_MODEM (self));
|
||||
if (!qcdm) {
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (self),
|
||||
callback,
|
||||
@@ -4803,7 +4813,7 @@ modem_cdma_get_call_manager_state (MMIfaceModemCdma *self,
|
||||
CallManagerStateContext *ctx;
|
||||
GByteArray *cmstate;
|
||||
|
||||
qcdm = mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
|
||||
qcdm = mm_base_modem_peek_port_qcdm (MM_BASE_MODEM (self));
|
||||
if (!qcdm) {
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (self),
|
||||
callback,
|
||||
@@ -5093,8 +5103,6 @@ modem_cdma_get_cdma1x_serving_system (MMIfaceModemCdma *self,
|
||||
if (ctx->qcdm) {
|
||||
GByteArray *cdma_status;
|
||||
|
||||
g_object_ref (ctx->qcdm);
|
||||
|
||||
/* Setup command */
|
||||
cdma_status = g_byte_array_sized_new (25);
|
||||
cdma_status->len = qcdm_cmd_cdma_status_new ((char *) cdma_status->data, 25);
|
||||
@@ -5351,7 +5359,7 @@ modem_cdma_get_detailed_registration_state (MMIfaceModemCdma *self,
|
||||
/* The default implementation to get detailed registration state
|
||||
* requires the use of an AT port; so if we cannot get any, just
|
||||
* return the error */
|
||||
port = mm_base_modem_get_best_at_port (MM_BASE_MODEM (self), &error);
|
||||
port = mm_base_modem_peek_best_at_port (MM_BASE_MODEM (self), &error);
|
||||
if (!port) {
|
||||
g_simple_async_report_take_gerror_in_idle (G_OBJECT (self),
|
||||
callback,
|
||||
@@ -5534,7 +5542,7 @@ modem_cdma_setup_registration_checks (MMIfaceModemCdma *self,
|
||||
modem_cdma_setup_registration_checks);
|
||||
|
||||
/* Check if we have a QCDM port */
|
||||
ctx->has_qcdm_port = !!mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
|
||||
ctx->has_qcdm_port = !!mm_base_modem_peek_port_qcdm (MM_BASE_MODEM (self));
|
||||
|
||||
/* If we have cached results of Sprint command checking, use them */
|
||||
if (ctx->self->priv->checked_sprint_support) {
|
||||
@@ -5771,14 +5779,17 @@ setup_ports (MMBroadbandModem *self)
|
||||
GPtrArray *array;
|
||||
gint i, j;
|
||||
|
||||
ports[0] = mm_base_modem_get_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
|
||||
ports[0] = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
|
||||
|
||||
/* Cleanup all unsolicited message handlers in all AT ports */
|
||||
|
||||
/* Set up CREG unsolicited message handlers, with NULL callbacks */
|
||||
array = mm_3gpp_creg_regex_get (FALSE);
|
||||
for (i = 0; ports[i] && i < 2; i++) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!ports[i])
|
||||
continue;
|
||||
|
||||
for (j = 0; j < array->len; j++) {
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (ports[i]),
|
||||
(GRegex *)g_ptr_array_index (array, j),
|
||||
@@ -5791,7 +5802,10 @@ setup_ports (MMBroadbandModem *self)
|
||||
|
||||
/* Set up CIEV unsolicited message handler, with NULL callback */
|
||||
regex = mm_3gpp_ciev_regex_get ();
|
||||
for (i = 0; ports[i] && i < 2; i++) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!ports[i])
|
||||
continue;
|
||||
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (ports[i]),
|
||||
regex,
|
||||
NULL,
|
||||
@@ -5802,7 +5816,10 @@ setup_ports (MMBroadbandModem *self)
|
||||
|
||||
/* Set up CMTI unsolicited message handler, with NULL callback */
|
||||
regex = mm_3gpp_cmti_regex_get ();
|
||||
for (i = 0; ports[i] && i < 2; i++) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!ports[i])
|
||||
continue;
|
||||
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (ports[i]),
|
||||
regex,
|
||||
NULL,
|
||||
@@ -5813,7 +5830,10 @@ setup_ports (MMBroadbandModem *self)
|
||||
|
||||
/* Set up CUSD unsolicited message handler, with NULL callback */
|
||||
regex = mm_3gpp_cusd_regex_get ();
|
||||
for (i = 0; ports[i] && i < 2; i++) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!ports[i])
|
||||
continue;
|
||||
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (ports[i]),
|
||||
regex,
|
||||
NULL,
|
||||
@@ -6396,9 +6416,11 @@ initialize_context_complete_and_free (InitializeContext *ctx)
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->result);
|
||||
/* balance open/close count */
|
||||
if (ctx->close_port)
|
||||
mm_serial_port_close (MM_SERIAL_PORT (ctx->port));
|
||||
g_object_unref (ctx->port);
|
||||
if (ctx->port) {
|
||||
if (ctx->close_port)
|
||||
mm_serial_port_close (MM_SERIAL_PORT (ctx->port));
|
||||
g_object_unref (ctx->port);
|
||||
}
|
||||
g_object_unref (ctx->self);
|
||||
g_free (ctx);
|
||||
}
|
||||
@@ -6473,11 +6495,20 @@ initialize_step (InitializeContext *ctx)
|
||||
case INITIALIZE_STEP_PRIMARY_OPEN: {
|
||||
GError *error = NULL;
|
||||
|
||||
ctx->port = mm_base_modem_get_port_primary (MM_BASE_MODEM (ctx->self));
|
||||
if (!ctx->port) {
|
||||
g_simple_async_result_set_error (ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
"Cannot initialize: couldn't get primary port");
|
||||
initialize_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Open and send first commands to the primary serial port.
|
||||
* We do keep the primary port open during the whole initialization
|
||||
* sequence. Note that this port is not really passed to the interfaces,
|
||||
* they will get the primary port themselves. */
|
||||
ctx->port = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (ctx->self)));
|
||||
if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->port), &error)) {
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
initialize_context_complete_and_free (ctx);
|
||||
|
||||
@@ -405,7 +405,6 @@ typedef enum {
|
||||
|
||||
struct _DisablingContext {
|
||||
MMIfaceModem3gppUssd *self;
|
||||
MMAtSerialPort *primary;
|
||||
DisablingStep step;
|
||||
GSimpleAsyncResult *result;
|
||||
MmGdbusModem3gppUssd *skeleton;
|
||||
@@ -420,7 +419,6 @@ disabling_context_new (MMIfaceModem3gppUssd *self,
|
||||
|
||||
ctx = g_new0 (DisablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -439,7 +437,6 @@ disabling_context_complete_and_free (DisablingContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_free (ctx);
|
||||
@@ -551,7 +548,6 @@ typedef enum {
|
||||
|
||||
struct _EnablingContext {
|
||||
MMIfaceModem3gppUssd *self;
|
||||
MMAtSerialPort *primary;
|
||||
EnablingStep step;
|
||||
GSimpleAsyncResult *result;
|
||||
MmGdbusModem3gppUssd *skeleton;
|
||||
@@ -566,7 +562,6 @@ enabling_context_new (MMIfaceModem3gppUssd *self,
|
||||
|
||||
ctx = g_new0 (EnablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -585,7 +580,6 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_free (ctx);
|
||||
|
||||
@@ -925,7 +925,6 @@ typedef enum {
|
||||
|
||||
struct _DisablingContext {
|
||||
MMIfaceModem3gpp *self;
|
||||
MMAtSerialPort *primary;
|
||||
DisablingStep step;
|
||||
GSimpleAsyncResult *result;
|
||||
MmGdbusModem *skeleton;
|
||||
@@ -940,7 +939,6 @@ disabling_context_new (MMIfaceModem3gpp *self,
|
||||
|
||||
ctx = g_new0 (DisablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -959,7 +957,6 @@ disabling_context_complete_and_free (DisablingContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_free (ctx);
|
||||
@@ -1148,7 +1145,6 @@ typedef enum {
|
||||
|
||||
struct _EnablingContext {
|
||||
MMIfaceModem3gpp *self;
|
||||
MMAtSerialPort *primary;
|
||||
EnablingStep step;
|
||||
GSimpleAsyncResult *result;
|
||||
MmGdbusModem3gpp *skeleton;
|
||||
@@ -1163,7 +1159,6 @@ enabling_context_new (MMIfaceModem3gpp *self,
|
||||
|
||||
ctx = g_new0 (EnablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -1182,7 +1177,6 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_free (ctx);
|
||||
|
||||
@@ -1101,7 +1101,6 @@ typedef enum {
|
||||
|
||||
struct _DisablingContext {
|
||||
MMIfaceModemCdma *self;
|
||||
MMAtSerialPort *primary;
|
||||
DisablingStep step;
|
||||
GSimpleAsyncResult *result;
|
||||
MmGdbusModemCdma *skeleton;
|
||||
@@ -1116,7 +1115,6 @@ disabling_context_new (MMIfaceModemCdma *self,
|
||||
|
||||
ctx = g_new0 (DisablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -1135,7 +1133,6 @@ disabling_context_complete_and_free (DisablingContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_free (ctx);
|
||||
@@ -1196,7 +1193,6 @@ typedef enum {
|
||||
|
||||
struct _EnablingContext {
|
||||
MMIfaceModemCdma *self;
|
||||
MMAtSerialPort *primary;
|
||||
EnablingStep step;
|
||||
GSimpleAsyncResult *result;
|
||||
MmGdbusModemCdma *skeleton;
|
||||
@@ -1211,7 +1207,6 @@ enabling_context_new (MMIfaceModemCdma *self,
|
||||
|
||||
ctx = g_new0 (EnablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -1230,7 +1225,6 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_free (ctx);
|
||||
|
||||
@@ -451,7 +451,6 @@ typedef enum {
|
||||
|
||||
struct _DisablingContext {
|
||||
MMIfaceModemLocation *self;
|
||||
MMAtSerialPort *primary;
|
||||
DisablingStep step;
|
||||
GSimpleAsyncResult *result;
|
||||
MmGdbusModemLocation *skeleton;
|
||||
@@ -466,7 +465,6 @@ disabling_context_new (MMIfaceModemLocation *self,
|
||||
|
||||
ctx = g_new0 (DisablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -485,7 +483,6 @@ disabling_context_complete_and_free (DisablingContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_free (ctx);
|
||||
@@ -575,7 +572,6 @@ typedef enum {
|
||||
|
||||
struct _EnablingContext {
|
||||
MMIfaceModemLocation *self;
|
||||
MMAtSerialPort *primary;
|
||||
EnablingStep step;
|
||||
GSimpleAsyncResult *result;
|
||||
MmGdbusModemLocation *skeleton;
|
||||
@@ -590,7 +586,6 @@ enabling_context_new (MMIfaceModemLocation *self,
|
||||
|
||||
ctx = g_new0 (EnablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -609,7 +604,6 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_free (ctx);
|
||||
|
||||
@@ -486,7 +486,6 @@ typedef enum {
|
||||
|
||||
struct _DisablingContext {
|
||||
MMIfaceModemMessaging *self;
|
||||
MMAtSerialPort *primary;
|
||||
DisablingStep step;
|
||||
GSimpleAsyncResult *result;
|
||||
MmGdbusModemMessaging *skeleton;
|
||||
@@ -501,7 +500,6 @@ disabling_context_new (MMIfaceModemMessaging *self,
|
||||
|
||||
ctx = g_new0 (DisablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -520,7 +518,6 @@ disabling_context_complete_and_free (DisablingContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_free (ctx);
|
||||
@@ -648,7 +645,6 @@ typedef enum {
|
||||
|
||||
struct _EnablingContext {
|
||||
MMIfaceModemMessaging *self;
|
||||
MMAtSerialPort *primary;
|
||||
EnablingStep step;
|
||||
GSimpleAsyncResult *result;
|
||||
MmGdbusModemMessaging *skeleton;
|
||||
@@ -665,7 +661,6 @@ enabling_context_new (MMIfaceModemMessaging *self,
|
||||
|
||||
ctx = g_new0 (EnablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -684,7 +679,6 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_free (ctx);
|
||||
|
||||
@@ -395,7 +395,6 @@ typedef enum {
|
||||
|
||||
struct _DisablingContext {
|
||||
MMIfaceModemTime *self;
|
||||
MMAtSerialPort *primary;
|
||||
DisablingStep step;
|
||||
GSimpleAsyncResult *result;
|
||||
MmGdbusModemTime *skeleton;
|
||||
@@ -410,7 +409,6 @@ disabling_context_new (MMIfaceModemTime *self,
|
||||
|
||||
ctx = g_new0 (DisablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -429,7 +427,6 @@ disabling_context_complete_and_free (DisablingContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_free (ctx);
|
||||
@@ -570,7 +567,6 @@ typedef enum {
|
||||
|
||||
struct _EnablingContext {
|
||||
MMIfaceModemTime *self;
|
||||
MMAtSerialPort *primary;
|
||||
EnablingStep step;
|
||||
GSimpleAsyncResult *result;
|
||||
MmGdbusModemTime *skeleton;
|
||||
@@ -585,7 +581,6 @@ enabling_context_new (MMIfaceModemTime *self,
|
||||
|
||||
ctx = g_new0 (EnablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -604,7 +599,6 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
||||
{
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
g_object_unref (ctx->result);
|
||||
g_object_unref (ctx->skeleton);
|
||||
g_free (ctx);
|
||||
|
||||
+16
-13
@@ -2300,13 +2300,9 @@ disabling_context_new (MMIfaceModem *self,
|
||||
|
||||
ctx = g_new0 (DisablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->primary = mm_base_modem_get_port_primary (MM_BASE_MODEM (self));
|
||||
ctx->secondary = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
|
||||
if (ctx->secondary)
|
||||
g_object_ref (ctx->secondary);
|
||||
ctx->qcdm = mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
|
||||
if (ctx->qcdm)
|
||||
g_object_ref (ctx->qcdm);
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -2341,7 +2337,8 @@ disabling_context_complete_and_free (DisablingContext *ctx)
|
||||
MM_MODEM_STATE_CHANGE_REASON_UNKNOWN);
|
||||
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
if (ctx->primary)
|
||||
g_object_unref (ctx->primary);
|
||||
if (ctx->secondary)
|
||||
g_object_unref (ctx->secondary);
|
||||
if (ctx->qcdm)
|
||||
@@ -2427,7 +2424,7 @@ interface_disabling_step (DisablingContext *ctx)
|
||||
* be safe to check whether they are really open before trying to close.
|
||||
*/
|
||||
mm_dbg ("Closing all ports...");
|
||||
if (mm_serial_port_is_open (MM_SERIAL_PORT (ctx->primary)))
|
||||
if (ctx->primary && mm_serial_port_is_open (MM_SERIAL_PORT (ctx->primary)))
|
||||
mm_serial_port_close (MM_SERIAL_PORT (ctx->primary));
|
||||
if (ctx->secondary && mm_serial_port_is_open (MM_SERIAL_PORT (ctx->secondary)))
|
||||
mm_serial_port_close (MM_SERIAL_PORT (ctx->secondary));
|
||||
@@ -2503,13 +2500,9 @@ enabling_context_new (MMIfaceModem *self,
|
||||
|
||||
ctx = g_new0 (EnablingContext, 1);
|
||||
ctx->self = g_object_ref (self);
|
||||
ctx->primary = g_object_ref (mm_base_modem_get_port_primary (MM_BASE_MODEM (self)));
|
||||
ctx->primary = mm_base_modem_get_port_primary (MM_BASE_MODEM (self));
|
||||
ctx->secondary = mm_base_modem_get_port_secondary (MM_BASE_MODEM (self));
|
||||
if (ctx->secondary)
|
||||
g_object_ref (ctx->secondary);
|
||||
ctx->qcdm = mm_base_modem_get_port_qcdm (MM_BASE_MODEM (self));
|
||||
if (ctx->qcdm)
|
||||
g_object_ref (ctx->qcdm);
|
||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
@@ -2554,7 +2547,8 @@ enabling_context_complete_and_free (EnablingContext *ctx)
|
||||
}
|
||||
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->primary);
|
||||
if (ctx->primary)
|
||||
g_object_unref (ctx->primary);
|
||||
if (ctx->secondary)
|
||||
g_object_unref (ctx->secondary);
|
||||
if (ctx->qcdm)
|
||||
@@ -2737,6 +2731,15 @@ interface_enabling_step (EnablingContext *ctx)
|
||||
GError *error = NULL;
|
||||
|
||||
/* Open primary port */
|
||||
if (!ctx->primary) {
|
||||
g_simple_async_result_set_error (ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
"Cannot enable: no primary port");
|
||||
enabling_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->primary), &error)) {
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
enabling_context_complete_and_free (ctx);
|
||||
|
||||
+2
-15
@@ -1386,15 +1386,11 @@ struct _InitAsyncContext {
|
||||
MMSim *self;
|
||||
InitializationStep step;
|
||||
guint sim_identifier_tries;
|
||||
MMAtSerialPort *port;
|
||||
};
|
||||
|
||||
static void
|
||||
init_async_context_free (InitAsyncContext *ctx,
|
||||
gboolean close_port)
|
||||
init_async_context_free (InitAsyncContext *ctx)
|
||||
{
|
||||
if (close_port)
|
||||
mm_serial_port_close (MM_SERIAL_PORT (ctx->port));
|
||||
g_object_unref (ctx->self);
|
||||
g_object_unref (ctx->result);
|
||||
if (ctx->cancellable)
|
||||
@@ -1569,7 +1565,7 @@ interface_initialization_step (InitAsyncContext *ctx)
|
||||
/* We are done without errors! */
|
||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
init_async_context_free (ctx, TRUE);
|
||||
init_async_context_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1585,7 +1581,6 @@ common_init_async (GAsyncInitable *initable,
|
||||
|
||||
{
|
||||
InitAsyncContext *ctx;
|
||||
GError *error = NULL;
|
||||
|
||||
ctx = g_new (InitAsyncContext, 1);
|
||||
ctx->self = g_object_ref (initable);
|
||||
@@ -1599,14 +1594,6 @@ common_init_async (GAsyncInitable *initable,
|
||||
ctx->step = INITIALIZATION_STEP_FIRST;
|
||||
ctx->sim_identifier_tries = 0;
|
||||
|
||||
ctx->port = mm_base_modem_get_port_primary (ctx->self->priv->modem);
|
||||
if (!mm_serial_port_open (MM_SERIAL_PORT (ctx->port), &error)) {
|
||||
g_simple_async_result_take_error (ctx->result, error);
|
||||
g_simple_async_result_complete_in_idle (ctx->result);
|
||||
init_async_context_free (ctx, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
interface_initialization_step (ctx);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user