aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-12-28 08:00:04 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-12-28 08:00:04 +0100
commit1b0ab2ea60eef1fb8d9b9c185d2700dab562be0d (patch)
treeb7250febc06df79790b00a8a17c0f4c84f6bd5c2
parent731812fe342ba4d2a5531992638a21b8a27bdbb4 (diff)
broadband-bearer: dial port may be different to the primary port
-rw-r--r--src/mm-broadband-bearer.c51
1 files changed, 19 insertions, 32 deletions
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
index b314a9ed..f9a0dad0 100644
--- a/src/mm-broadband-bearer.c
+++ b/src/mm-broadband-bearer.c
@@ -438,33 +438,12 @@ typedef struct {
MMBroadbandBearer *self;
MMBaseModem *modem;
MMAtSerialPort *primary;
+ MMAtSerialPort *dial_port;
GCancellable *cancellable;
GSimpleAsyncResult *result;
GError *saved_error;
} Dial3gppContext;
-static Dial3gppContext *
-dial_3gpp_context_new (MMBroadbandBearer *self,
- MMBaseModem *modem,
- MMAtSerialPort *primary,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- Dial3gppContext *ctx;
-
- ctx = g_new0 (Dial3gppContext, 1);
- ctx->self = g_object_ref (self);
- ctx->modem = g_object_ref (modem);
- ctx->primary = g_object_ref (primary);
- ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- dial_3gpp_context_new);
- ctx->cancellable = g_object_ref (cancellable);
- return ctx;
-}
-
static void
dial_3gpp_context_complete_and_free (Dial3gppContext *ctx)
{
@@ -473,15 +452,16 @@ dial_3gpp_context_complete_and_free (Dial3gppContext *ctx)
g_object_unref (ctx->cancellable);
g_simple_async_result_complete (ctx->result);
g_object_unref (ctx->result);
+ g_object_unref (ctx->dial_port);
g_object_unref (ctx->primary);
g_object_unref (ctx->modem);
g_object_unref (ctx->self);
- g_free (ctx);
+ g_slice_free (Dial3gppContext, ctx);
}
static gboolean
dial_3gpp_context_set_error_if_cancelled (Dial3gppContext *ctx,
- GError **error)
+ GError **error)
{
if (!g_cancellable_is_cancelled (ctx->cancellable))
return FALSE;
@@ -576,7 +556,7 @@ static void
dial_3gpp (MMBroadbandBearer *self,
MMBaseModem *modem,
MMAtSerialPort *primary,
- MMPort *data, /* unused by us */
+ MMPort *data,
guint cid,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -587,17 +567,24 @@ dial_3gpp (MMBroadbandBearer *self,
g_assert (primary != NULL);
- ctx = dial_3gpp_context_new (self,
- modem,
- primary,
- cancellable,
- callback,
- user_data);
+ ctx = g_slice_new0 (Dial3gppContext);
+ ctx->self = g_object_ref (self);
+ ctx->modem = g_object_ref (modem);
+ /* Dial port might not be the primary port */
+ ctx->primary = g_object_ref (primary);
+ ctx->dial_port = (data && MM_IS_AT_SERIAL_PORT (data) ?
+ g_object_ref (data) :
+ g_object_ref (primary));
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ dial_3gpp);
+ ctx->cancellable = g_object_ref (cancellable);
/* Use default *99 to connect */
command = g_strdup_printf ("ATD*99***%d#", cid);
mm_base_modem_at_command_full (ctx->modem,
- ctx->primary,
+ ctx->dial_port,
command,
60,
FALSE,