diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-08 12:47:45 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-16 14:53:23 +0100 |
commit | cc6d4a97fb0a11c799f1079c6db86b31db7eadf7 (patch) | |
tree | a1b6214fdc960285dcb020f45b132db2598fd3c1 /src/mm-sim.c | |
parent | 48285dcfdf04becbe90922ac3f2dd942bc43de53 (diff) |
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.
Diffstat (limited to 'src/mm-sim.c')
-rw-r--r-- | src/mm-sim.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/src/mm-sim.c b/src/mm-sim.c index 95a1eec5..fbb20752 100644 --- a/src/mm-sim.c +++ b/src/mm-sim.c @@ -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); } |