aboutsummaryrefslogtreecommitdiff
path: root/plugins/iridium
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2013-02-17 20:27:24 +0100
committerAleksander Morgado <aleksander@lanedo.com>2013-02-18 15:41:26 +0100
commit15d34d56fd3277b23c5f477d9aab257cb0bc10a7 (patch)
treed236228bfdd57acf160333925a507493664d80b3 /plugins/iridium
parent1746949277cbcf9209fc67b36a091177a8476b29 (diff)
bearer: new helper 'MMBearerConnectResult' type
Instead of returning 3 variables in connect_finish(), return a single reference counted struct. This simplifies how the result is built and passed within a GSimpleAsyncResult to each _finish() method. This also simplifies the dialling step in the 3GPP connection sequence, as we can use the same new type.
Diffstat (limited to 'plugins/iridium')
-rw-r--r--plugins/iridium/mm-bearer-iridium.c49
1 files changed, 9 insertions, 40 deletions
diff --git a/plugins/iridium/mm-bearer-iridium.c b/plugins/iridium/mm-bearer-iridium.c
index fe2013bd..e19d427b 100644
--- a/plugins/iridium/mm-bearer-iridium.c
+++ b/plugins/iridium/mm-bearer-iridium.c
@@ -37,23 +37,6 @@ G_DEFINE_TYPE (MMBearerIridium, mm_bearer_iridium, MM_TYPE_BEARER);
/* Connect */
typedef struct {
- MMPort *data;
- MMBearerIpConfig *ipv4_config;
- MMBearerIpConfig *ipv6_config;
-} ConnectResult;
-
-static void
-connect_result_free (ConnectResult *result)
-{
- if (result->ipv4_config)
- g_object_unref (result->ipv4_config);
- if (result->ipv6_config)
- g_object_unref (result->ipv6_config);
- g_object_unref (result->data);
- g_free (result);
-}
-
-typedef struct {
MMBearerIridium *self;
GSimpleAsyncResult *result;
GCancellable *cancellable;
@@ -75,25 +58,15 @@ connect_context_complete_and_free (ConnectContext *ctx)
g_free (ctx);
}
-static gboolean
+static MMBearerConnectResult *
connect_finish (MMBearer *self,
GAsyncResult *res,
- MMPort **data,
- MMBearerIpConfig **ipv4_config,
- MMBearerIpConfig **ipv6_config,
GError **error)
{
- ConnectResult *result;
-
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
- return FALSE;
+ return NULL;
- result = (ConnectResult *) g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
- *data = MM_PORT (g_object_ref (result->data));
- *ipv4_config = (result->ipv4_config ? g_object_ref (result->ipv4_config) : NULL);
- *ipv6_config = (result->ipv6_config ? g_object_ref (result->ipv6_config) : NULL);
-
- return TRUE;
+ return mm_bearer_connect_result_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
}
static void
@@ -141,7 +114,6 @@ dial_ready (MMBaseModem *modem,
ConnectContext *ctx)
{
MMBearerIpConfig *config;
- ConnectResult *result;
/* DO NOT check for cancellable here. If we got here without errors, the
* bearer is really connected and therefore we need to reflect that in
@@ -169,16 +141,13 @@ dial_ready (MMBaseModem *modem,
config = mm_bearer_ip_config_new ();
mm_bearer_ip_config_set_method (config, MM_BEARER_IP_METHOD_PPP);
- /* Build result */
- result = g_new0 (ConnectResult, 1);
- result->data = g_object_ref (ctx->primary);
- result->ipv4_config = config;
- result->ipv6_config = g_object_ref (config);
-
/* Set operation result */
- g_simple_async_result_set_op_res_gpointer (ctx->result,
- result,
- (GDestroyNotify)connect_result_free);
+ g_simple_async_result_set_op_res_gpointer (
+ ctx->result,
+ mm_bearer_connect_result_new (MM_PORT (ctx->primary), config, NULL),
+ (GDestroyNotify)mm_bearer_connect_result_unref);
+ g_object_unref (config);
+
connect_context_complete_and_free (ctx);
}