diff options
-rw-r--r-- | src/mm-bearer-3gpp.c | 41 | ||||
-rw-r--r-- | src/mm-bearer-3gpp.h | 12 | ||||
-rw-r--r-- | src/mm-bearer-cdma.c | 28 | ||||
-rw-r--r-- | src/mm-bearer-cdma.h | 12 | ||||
-rw-r--r-- | src/mm-broadband-modem.c | 119 | ||||
-rw-r--r-- | src/mm-iface-modem-3gpp.c | 33 | ||||
-rw-r--r-- | src/mm-iface-modem-3gpp.h | 20 | ||||
-rw-r--r-- | src/mm-iface-modem-cdma.c | 34 | ||||
-rw-r--r-- | src/mm-iface-modem-cdma.h | 20 |
9 files changed, 221 insertions, 98 deletions
diff --git a/src/mm-bearer-3gpp.c b/src/mm-bearer-3gpp.c index 82a90e54..f4c79725 100644 --- a/src/mm-bearer-3gpp.c +++ b/src/mm-bearer-3gpp.c @@ -777,21 +777,42 @@ disconnect (MMBearer *self, /*****************************************************************************/ MMBearer * -mm_bearer_3gpp_new (MMBaseModem *modem, +mm_bearer_3gpp_new_finish (MMIfaceModem3gpp *modem, + GAsyncResult *res, + GError **error) +{ + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) + return NULL; + + return MM_BEARER (g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)))); +} + +void +mm_bearer_3gpp_new (MMIfaceModem3gpp *modem, MMCommonBearerProperties *properties, - GError **error) + GAsyncReadyCallback callback, + gpointer user_data) { + GSimpleAsyncResult *result; static guint id = 0; MMBearer3gpp *bearer; gchar *path; + result = g_simple_async_result_new (G_OBJECT (modem), + callback, + user_data, + mm_bearer_3gpp_new); + /* Check mandatory properties */ if (!mm_common_bearer_properties_get_apn (properties)) { - g_set_error (error, - MM_CORE_ERROR, - MM_CORE_ERROR_INVALID_ARGS, - "Invalid input properties: 3GPP bearer requires 'apn'"); - return NULL; + g_simple_async_result_set_error ( + result, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Invalid input properties: 3GPP bearer requires 'apn'"); + g_simple_async_result_complete_in_idle (result); + g_object_unref (result); + return; } /* Create the object */ @@ -810,7 +831,11 @@ mm_bearer_3gpp_new (MMBaseModem *modem, NULL); g_free (path); - return MM_BEARER (bearer); + g_simple_async_result_set_op_res_gpointer (result, + bearer, + (GDestroyNotify)g_object_unref); + g_simple_async_result_complete_in_idle (result); + g_object_unref (result); } static void diff --git a/src/mm-bearer-3gpp.h b/src/mm-bearer-3gpp.h index 8cc21a90..a1e4d082 100644 --- a/src/mm-bearer-3gpp.h +++ b/src/mm-bearer-3gpp.h @@ -22,7 +22,7 @@ #include <glib-object.h> #include "mm-bearer.h" -#include "mm-base-modem.h" +#include "mm-iface-modem-3gpp.h" #define MM_TYPE_BEARER_3GPP (mm_bearer_3gpp_get_type ()) #define MM_BEARER_3GPP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BEARER_3GPP, MMBearer3gpp)) @@ -54,9 +54,13 @@ struct _MMBearer3gppClass { GType mm_bearer_3gpp_get_type (void); /* Default 3GPP bearer creation implementation */ -MMBearer *mm_bearer_3gpp_new (MMBaseModem *modem, - MMCommonBearerProperties *properties, - GError **error); +void mm_bearer_3gpp_new (MMIfaceModem3gpp *modem, + MMCommonBearerProperties *properties, + GAsyncReadyCallback callback, + gpointer user_data); +MMBearer *mm_bearer_3gpp_new_finish (MMIfaceModem3gpp *modem, + GAsyncResult *res, + GError **error); const gchar *mm_bearer_3gpp_get_apn (MMBearer3gpp *self); const gchar *mm_bearer_3gpp_get_ip_type (MMBearer3gpp *self); diff --git a/src/mm-bearer-cdma.c b/src/mm-bearer-cdma.c index d016f79f..e12fac1b 100644 --- a/src/mm-bearer-cdma.c +++ b/src/mm-bearer-cdma.c @@ -95,14 +95,32 @@ disconnect (MMBearer *self, /*****************************************************************************/ MMBearer * -mm_bearer_cdma_new (MMBaseModem *modem, +mm_bearer_cdma_new_finish (MMIfaceModemCdma *modem, + GAsyncResult *res, + GError **error) +{ + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) + return NULL; + + return MM_BEARER (g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)))); +} + +void +mm_bearer_cdma_new (MMIfaceModemCdma *modem, MMCommonBearerProperties *properties, - GError **error) + GAsyncReadyCallback callback, + gpointer user_data) { + GSimpleAsyncResult *result; static guint id = 0; MMBearerCdma *bearer; gchar *path; + result = g_simple_async_result_new (G_OBJECT (modem), + callback, + user_data, + mm_bearer_cdma_new); + /* Create the object */ bearer = g_object_new (MM_TYPE_BEARER_CDMA, MM_BEARER_CDMA_RM_PROTOCOL, mm_common_bearer_properties_get_rm_protocol (properties), @@ -118,7 +136,11 @@ mm_bearer_cdma_new (MMBaseModem *modem, NULL); g_free (path); - return MM_BEARER (bearer); + g_simple_async_result_set_op_res_gpointer (result, + bearer, + (GDestroyNotify)g_object_unref); + g_simple_async_result_complete_in_idle (result); + g_object_unref (result); } static void diff --git a/src/mm-bearer-cdma.h b/src/mm-bearer-cdma.h index 8a4e4d7f..20d65820 100644 --- a/src/mm-bearer-cdma.h +++ b/src/mm-bearer-cdma.h @@ -22,7 +22,7 @@ #include <glib-object.h> #include "mm-bearer.h" -#include "mm-base-modem.h" +#include "mm-iface-modem-cdma.h" #define MM_TYPE_BEARER_CDMA (mm_bearer_cdma_get_type ()) #define MM_BEARER_CDMA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BEARER_CDMA, MMBearerCdma)) @@ -52,9 +52,13 @@ struct _MMBearerCdmaClass { GType mm_bearer_cdma_get_type (void); /* Default CDMA bearer creation implementation */ -MMBearer *mm_bearer_cdma_new (MMBaseModem *modem, - MMCommonBearerProperties *properties, - GError **error); +void mm_bearer_cdma_new (MMIfaceModemCdma *modem, + MMCommonBearerProperties *properties, + GAsyncReadyCallback callback, + gpointer user_data); +MMBearer *mm_bearer_cdma_new_finish (MMIfaceModemCdma *modem, + GAsyncResult *res, + GError **error); guint mm_bearer_cdma_get_rm_protocol (MMBearerCdma *self); diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index d44c8391..ced88b79 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -134,69 +134,100 @@ modem_create_bearer_finish (MMIfaceModem *self, } static void +modem_cdma_create_bearer_ready (MMIfaceModemCdma *self, + GAsyncResult *res, + GSimpleAsyncResult *simple) +{ + MMBearer *bearer = NULL; + GError *error = NULL; + + bearer = mm_iface_modem_cdma_create_bearer_finish (self, res, &error); + if (!bearer) + g_simple_async_result_take_error (simple, error); + else + g_simple_async_result_set_op_res_gpointer (simple, + bearer, + (GDestroyNotify)g_object_unref); + g_simple_async_result_complete (simple); + g_object_unref (simple); +} + +static void +modem_3gpp_create_bearer_ready (MMIfaceModem3gpp *self, + GAsyncResult *res, + GSimpleAsyncResult *simple) +{ + MMBearer *bearer = NULL; + GError *error = NULL; + + bearer = mm_iface_modem_3gpp_create_bearer_finish (self, res, &error); + if (!bearer) + g_simple_async_result_take_error (simple, error); + else + g_simple_async_result_set_op_res_gpointer (simple, + bearer, + (GDestroyNotify)g_object_unref); + g_simple_async_result_complete (simple); + g_object_unref (simple); +} + +static void modem_create_bearer (MMIfaceModem *self, MMCommonBearerProperties *properties, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *result; - MMBearer *bearer = NULL; - GError *error = NULL; + + + /* Set a new ref to the bearer object as result */ + result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + modem_create_bearer); /* On 3GPP-only modems, new 3GPP bearer */ if (mm_iface_modem_is_3gpp_only (self)) { mm_dbg ("Creating 3GPP Bearer in 3GPP-only modem"); - bearer = mm_iface_modem_3gpp_create_bearer (MM_IFACE_MODEM_3GPP (self), - properties, - &error); + mm_iface_modem_3gpp_create_bearer (MM_IFACE_MODEM_3GPP (self), + properties, + (GAsyncReadyCallback)modem_3gpp_create_bearer_ready, + result); + return; } + /* On CDMA-only modems, new CDMA bearer */ - else if (mm_iface_modem_is_cdma_only (self)) { + if (mm_iface_modem_is_cdma_only (self)) { mm_dbg ("Creating CDMA Bearer in CDMA-only modem"); - bearer = mm_iface_modem_cdma_create_bearer (MM_IFACE_MODEM_CDMA (self), - properties, - &error); + mm_iface_modem_cdma_create_bearer (MM_IFACE_MODEM_CDMA (self), + properties, + (GAsyncReadyCallback)modem_cdma_create_bearer_ready, + result); + return; } + /* On mixed LTE and CDMA modems, we'll default to building a 3GPP bearer. * Plugins supporting mixed LTE+CDMA modems can override this and provide * their own specific and detailed logic. */ - else if (mm_iface_modem_is_cdma (self) && - mm_iface_modem_is_3gpp_lte (self)) { + if (mm_iface_modem_is_cdma (self) && + mm_iface_modem_is_3gpp_lte (self)) { mm_dbg ("Creating 3GPP Bearer in mixed CDMA+LTE modem"); - bearer = mm_iface_modem_3gpp_create_bearer (MM_IFACE_MODEM_3GPP (self), - properties, - &error); - } - else { - g_set_error (&error, - MM_CORE_ERROR, - MM_CORE_ERROR_UNSUPPORTED, - "Cannot create bearer in modem of unknown type. " - "CDMA: %s, 3GPP: %s (LTE: %s)", - mm_iface_modem_is_cdma (self) ? "yes" : "no", - mm_iface_modem_is_3gpp (self) ? "yes" : "no", - mm_iface_modem_is_3gpp_lte (self) ? "yes" : "no"); - } - - if (!bearer) { - g_simple_async_report_take_gerror_in_idle (G_OBJECT (self), - callback, - user_data, - error); - return; + mm_iface_modem_3gpp_create_bearer (MM_IFACE_MODEM_3GPP (self), + properties, + (GAsyncReadyCallback)modem_3gpp_create_bearer_ready, + result); + return; } - /* Expose all properties used during creation */ - mm_bearer_expose_properties (bearer, properties); - - /* Set a new ref to the bearer object as result */ - result = g_simple_async_result_new (G_OBJECT (self), - callback, - user_data, - modem_create_bearer); - g_simple_async_result_set_op_res_gpointer (result, - bearer, - (GDestroyNotify)g_object_unref); + g_simple_async_result_set_error ( + result, + MM_CORE_ERROR, + MM_CORE_ERROR_UNSUPPORTED, + "Cannot create bearer in modem of unknown type. " + "CDMA: %s, 3GPP: %s (LTE: %s)", + mm_iface_modem_is_cdma (self) ? "yes" : "no", + mm_iface_modem_is_3gpp (self) ? "yes" : "no", + mm_iface_modem_is_3gpp_lte (self) ? "yes" : "no"); g_simple_async_result_complete_in_idle (result); g_object_unref (result); } @@ -4630,6 +4661,7 @@ iface_modem_3gpp_init (MMIfaceModem3gpp *iface) iface->scan_networks = scan_networks; iface->scan_networks_finish = scan_networks_finish; iface->create_3gpp_bearer = mm_bearer_3gpp_new; + iface->create_3gpp_bearer_finish = mm_bearer_3gpp_new_finish; } static void @@ -4655,6 +4687,7 @@ iface_modem_cdma_init (MMIfaceModemCdma *iface) /* Additional actions */ iface->create_cdma_bearer = mm_bearer_cdma_new; + iface->create_cdma_bearer_finish = mm_bearer_cdma_new_finish; } static void diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c index 853bc9d6..4837f2d5 100644 --- a/src/mm-iface-modem-3gpp.c +++ b/src/mm-iface-modem-3gpp.c @@ -359,24 +359,20 @@ handle_scan (MmGdbusModem3gpp *skeleton, } /*****************************************************************************/ - /* Create new 3GPP bearer */ + MMBearer * -mm_iface_modem_3gpp_create_bearer (MMIfaceModem3gpp *self, - MMCommonBearerProperties *properties, - GError **error) +mm_iface_modem_3gpp_create_bearer_finish (MMIfaceModem3gpp *self, + GAsyncResult *res, + GError **error) { MMModem3gppRegistrationState current_state; MMBearer *bearer; - g_assert (MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->create_3gpp_bearer != NULL); - - /* Create new 3GPP bearer using the method set in the interface, so that - * plugins can subclass it and implement their own. */ - bearer = MM_BEARER (MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->create_3gpp_bearer ( - MM_BASE_MODEM (self), - properties, - error)); + g_assert (MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->create_3gpp_bearer_finish != NULL); + bearer = MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->create_3gpp_bearer_finish (self, + res, + error); if (!bearer) return NULL; @@ -403,6 +399,19 @@ mm_iface_modem_3gpp_create_bearer (MMIfaceModem3gpp *self, return bearer; } +void +mm_iface_modem_3gpp_create_bearer (MMIfaceModem3gpp *self, + MMCommonBearerProperties *properties, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_assert (MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->create_3gpp_bearer != NULL); + MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->create_3gpp_bearer (self, + properties, + callback, + user_data); +} + /*****************************************************************************/ typedef struct { diff --git a/src/mm-iface-modem-3gpp.h b/src/mm-iface-modem-3gpp.h index 70bfc7bc..e45934f6 100644 --- a/src/mm-iface-modem-3gpp.h +++ b/src/mm-iface-modem-3gpp.h @@ -172,9 +172,13 @@ struct _MMIfaceModem3gpp { GError **error); /* Create 3GPP bearer */ - MMBearer * (* create_3gpp_bearer) (MMBaseModem *modem, - MMCommonBearerProperties *properties, - GError **error); + void (* create_3gpp_bearer) (MMIfaceModem3gpp *self, + MMCommonBearerProperties *properties, + GAsyncReadyCallback callback, + gpointer user_data); + MMBearer * (* create_3gpp_bearer_finish) (MMIfaceModem3gpp *self, + GAsyncResult *res, + GError **error); }; GType mm_iface_modem_3gpp_get_type (void); @@ -226,9 +230,13 @@ gboolean mm_iface_modem_3gpp_run_all_registration_checks_finish (MMIfaceModem3gp GError **error); /* Create new 3GPP bearer */ -MMBearer *mm_iface_modem_3gpp_create_bearer (MMIfaceModem3gpp *self, - MMCommonBearerProperties *properties, - GError **error); +void mm_iface_modem_3gpp_create_bearer (MMIfaceModem3gpp *self, + MMCommonBearerProperties *properties, + GAsyncReadyCallback callback, + gpointer user_data); +MMBearer *mm_iface_modem_3gpp_create_bearer_finish (MMIfaceModem3gpp *self, + GAsyncResult *res, + GError **error); /* Allow registering in the network */ gboolean mm_iface_modem_3gpp_register_in_network_finish (MMIfaceModem3gpp *self, diff --git a/src/mm-iface-modem-cdma.c b/src/mm-iface-modem-cdma.c index 3ad03709..732e4e46 100644 --- a/src/mm-iface-modem-cdma.c +++ b/src/mm-iface-modem-cdma.c @@ -370,28 +370,25 @@ handle_activate_manual (MmGdbusModemCdma *skeleton, } /*****************************************************************************/ - /* Create new CDMA bearer */ + MMBearer * -mm_iface_modem_cdma_create_bearer (MMIfaceModemCdma *self, - MMCommonBearerProperties *properties, - GError **error) +mm_iface_modem_cdma_create_bearer_finish (MMIfaceModemCdma *self, + GAsyncResult *res, + GError **error) { MMModemCdmaRegistrationState cdma1x_current_state; MMModemCdmaRegistrationState evdo_current_state; MMBearer *bearer; - g_assert (MM_IFACE_MODEM_CDMA_GET_INTERFACE (self)->create_cdma_bearer != NULL); - - /* Create new CDMA bearer using the method set in the interface, so that - * plugins can subclass it and implement their own. */ - bearer = MM_BEARER (MM_IFACE_MODEM_CDMA_GET_INTERFACE (self)->create_cdma_bearer ( - MM_BASE_MODEM (self), - properties, - error)); + g_assert (MM_IFACE_MODEM_CDMA_GET_INTERFACE (self)->create_cdma_bearer_finish != NULL); + bearer = MM_IFACE_MODEM_CDMA_GET_INTERFACE (self)->create_cdma_bearer_finish (self, + res, + error); if (!bearer) return NULL; + g_object_get (self, MM_IFACE_MODEM_CDMA_CDMA1X_REGISTRATION_STATE, &cdma1x_current_state, MM_IFACE_MODEM_CDMA_EVDO_REGISTRATION_STATE, &evdo_current_state, @@ -418,6 +415,19 @@ mm_iface_modem_cdma_create_bearer (MMIfaceModemCdma *self, return bearer; } +void +mm_iface_modem_cdma_create_bearer (MMIfaceModemCdma *self, + MMCommonBearerProperties *properties, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_assert (MM_IFACE_MODEM_CDMA_GET_INTERFACE (self)->create_cdma_bearer != NULL); + MM_IFACE_MODEM_CDMA_GET_INTERFACE (self)->create_cdma_bearer (self, + properties, + callback, + user_data); +} + /*****************************************************************************/ typedef struct _RunAllRegistrationChecksContext RunAllRegistrationChecksContext; diff --git a/src/mm-iface-modem-cdma.h b/src/mm-iface-modem-cdma.h index c1855bc1..59c3f2f5 100644 --- a/src/mm-iface-modem-cdma.h +++ b/src/mm-iface-modem-cdma.h @@ -141,9 +141,13 @@ struct _MMIfaceModemCdma { GError **error); /* Create CDMA bearer */ - MMBearer * (* create_cdma_bearer) (MMBaseModem *modem, - MMCommonBearerProperties *properties, - GError **error); + void (* create_cdma_bearer) (MMIfaceModemCdma *self, + MMCommonBearerProperties *properties, + GAsyncReadyCallback callback, + gpointer user_data); + MMBearer * (* create_cdma_bearer_finish) (MMIfaceModemCdma *self, + GAsyncResult *res, + GError **error); }; GType mm_iface_modem_cdma_get_type (void); @@ -211,9 +215,13 @@ gboolean mm_iface_modem_cdma_run_all_registration_checks_finish (MMIfaceModemCdm GError **error); /* Create new CDMA bearer */ -MMBearer *mm_iface_modem_cdma_create_bearer (MMIfaceModemCdma *self, - MMCommonBearerProperties *properties, - GError **error); +void mm_iface_modem_cdma_create_bearer (MMIfaceModemCdma *self, + MMCommonBearerProperties *properties, + GAsyncReadyCallback callback, + gpointer user_data); +MMBearer *mm_iface_modem_cdma_create_bearer_finish (MMIfaceModemCdma *self, + GAsyncResult *res, + GError **error); /* Bind properties for simple GetStatus() */ void mm_iface_modem_cdma_bind_simple_status (MMIfaceModemCdma *self, |