bearer-qmi: port _connect to use GTask
This commit is contained in:

committed by
Aleksander Morgado

parent
dfcffbae04
commit
a6547642ed
@@ -247,8 +247,6 @@ typedef enum {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MMBearerQmi *self;
|
MMBearerQmi *self;
|
||||||
GSimpleAsyncResult *result;
|
|
||||||
GCancellable *cancellable;
|
|
||||||
ConnectStep step;
|
ConnectStep step;
|
||||||
MMPort *data;
|
MMPort *data;
|
||||||
MMPortQmi *qmi;
|
MMPortQmi *qmi;
|
||||||
@@ -281,10 +279,8 @@ typedef struct {
|
|||||||
} ConnectContext;
|
} ConnectContext;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
connect_context_complete_and_free (ConnectContext *ctx)
|
connect_context_free (ConnectContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete_in_idle (ctx->result);
|
|
||||||
g_object_unref (ctx->result);
|
|
||||||
g_free (ctx->apn);
|
g_free (ctx->apn);
|
||||||
g_free (ctx->user);
|
g_free (ctx->user);
|
||||||
g_free (ctx->password);
|
g_free (ctx->password);
|
||||||
@@ -320,7 +316,6 @@ connect_context_complete_and_free (ConnectContext *ctx)
|
|||||||
g_clear_object (&ctx->ipv6_config);
|
g_clear_object (&ctx->ipv6_config);
|
||||||
g_object_unref (ctx->data);
|
g_object_unref (ctx->data);
|
||||||
g_object_unref (ctx->qmi);
|
g_object_unref (ctx->qmi);
|
||||||
g_object_unref (ctx->cancellable);
|
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
g_slice_free (ConnectContext, ctx);
|
g_slice_free (ConnectContext, ctx);
|
||||||
}
|
}
|
||||||
@@ -330,22 +325,21 @@ connect_finish (MMBaseBearer *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
return g_task_propagate_pointer (G_TASK (res), error);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return mm_bearer_connect_result_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void connect_context_step (ConnectContext *ctx);
|
static void connect_context_step (GTask *task);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
start_network_ready (QmiClientWds *client,
|
start_network_ready (QmiClientWds *client,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
ConnectContext *ctx)
|
GTask *task)
|
||||||
{
|
{
|
||||||
|
ConnectContext *ctx;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
QmiMessageWdsStartNetworkOutput *output;
|
QmiMessageWdsStartNetworkOutput *output;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
|
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
|
||||||
g_assert (!(ctx->running_ipv4 && ctx->running_ipv6));
|
g_assert (!(ctx->running_ipv4 && ctx->running_ipv6));
|
||||||
|
|
||||||
@@ -416,7 +410,7 @@ start_network_ready (QmiClientWds *client,
|
|||||||
|
|
||||||
/* Keep on */
|
/* Keep on */
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
connect_context_step (ctx);
|
connect_context_step (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QmiMessageWdsStartNetworkInput *
|
static QmiMessageWdsStartNetworkInput *
|
||||||
@@ -660,11 +654,13 @@ get_ipv6_config (MMBearerQmi *self,
|
|||||||
static void
|
static void
|
||||||
get_current_settings_ready (QmiClientWds *client,
|
get_current_settings_ready (QmiClientWds *client,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
ConnectContext *ctx)
|
GTask *task)
|
||||||
{
|
{
|
||||||
|
ConnectContext *ctx;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
QmiMessageWdsGetCurrentSettingsOutput *output;
|
QmiMessageWdsGetCurrentSettingsOutput *output;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
|
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
|
||||||
|
|
||||||
output = qmi_client_wds_get_current_settings_finish (client, res, &error);
|
output = qmi_client_wds_get_current_settings_finish (client, res, &error);
|
||||||
@@ -721,15 +717,17 @@ get_current_settings_ready (QmiClientWds *client,
|
|||||||
|
|
||||||
/* Keep on */
|
/* Keep on */
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
connect_context_step (ctx);
|
connect_context_step (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_current_settings (ConnectContext *ctx, QmiClientWds *client)
|
get_current_settings (GTask *task, QmiClientWds *client)
|
||||||
{
|
{
|
||||||
|
ConnectContext *ctx;
|
||||||
QmiMessageWdsGetCurrentSettingsInput *input;
|
QmiMessageWdsGetCurrentSettingsInput *input;
|
||||||
QmiWdsGetCurrentSettingsRequestedSettings requested;
|
QmiWdsGetCurrentSettingsRequestedSettings requested;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
|
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
|
||||||
|
|
||||||
requested = QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_DNS_ADDRESS |
|
requested = QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_DNS_ADDRESS |
|
||||||
@@ -745,20 +743,22 @@ get_current_settings (ConnectContext *ctx, QmiClientWds *client)
|
|||||||
qmi_client_wds_get_current_settings (client,
|
qmi_client_wds_get_current_settings (client,
|
||||||
input,
|
input,
|
||||||
10,
|
10,
|
||||||
ctx->cancellable,
|
g_task_get_cancellable (task),
|
||||||
(GAsyncReadyCallback)get_current_settings_ready,
|
(GAsyncReadyCallback)get_current_settings_ready,
|
||||||
ctx);
|
task);
|
||||||
qmi_message_wds_get_current_settings_input_unref (input);
|
qmi_message_wds_get_current_settings_input_unref (input);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_ip_family_ready (QmiClientWds *client,
|
set_ip_family_ready (QmiClientWds *client,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
ConnectContext *ctx)
|
GTask *task)
|
||||||
{
|
{
|
||||||
|
ConnectContext *ctx;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
QmiMessageWdsSetIpFamilyOutput *output;
|
QmiMessageWdsSetIpFamilyOutput *output;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
|
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
|
||||||
g_assert (!(ctx->running_ipv4 && ctx->running_ipv6));
|
g_assert (!(ctx->running_ipv4 && ctx->running_ipv6));
|
||||||
|
|
||||||
@@ -780,7 +780,7 @@ set_ip_family_ready (QmiClientWds *client,
|
|||||||
|
|
||||||
/* Keep on */
|
/* Keep on */
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
connect_context_step (ctx);
|
connect_context_step (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -885,8 +885,11 @@ connect_enable_indications_ready (QmiClientWds *client,
|
|||||||
static void
|
static void
|
||||||
connect_enable_indications_ipv4_ready (QmiClientWds *client,
|
connect_enable_indications_ipv4_ready (QmiClientWds *client,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
ConnectContext *ctx)
|
GTask *task)
|
||||||
{
|
{
|
||||||
|
ConnectContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
g_assert (ctx->event_report_ipv4_indication_id == 0);
|
g_assert (ctx->event_report_ipv4_indication_id == 0);
|
||||||
|
|
||||||
ctx->event_report_ipv4_indication_id =
|
ctx->event_report_ipv4_indication_id =
|
||||||
@@ -897,14 +900,17 @@ connect_enable_indications_ipv4_ready (QmiClientWds *client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
connect_context_step (ctx);
|
connect_context_step (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
connect_enable_indications_ipv6_ready (QmiClientWds *client,
|
connect_enable_indications_ipv6_ready (QmiClientWds *client,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
ConnectContext *ctx)
|
GTask *task)
|
||||||
{
|
{
|
||||||
|
ConnectContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
g_assert (ctx->event_report_ipv6_indication_id == 0);
|
g_assert (ctx->event_report_ipv6_indication_id == 0);
|
||||||
|
|
||||||
ctx->event_report_ipv6_indication_id =
|
ctx->event_report_ipv6_indication_id =
|
||||||
@@ -915,7 +921,7 @@ connect_enable_indications_ipv6_ready (QmiClientWds *client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
connect_context_step (ctx);
|
connect_context_step (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QmiMessageWdsSetEventReportInput *
|
static QmiMessageWdsSetEventReportInput *
|
||||||
@@ -982,16 +988,18 @@ cleanup_event_report_unsolicited_events (MMBearerQmi *self,
|
|||||||
static void
|
static void
|
||||||
qmi_port_allocate_client_ready (MMPortQmi *qmi,
|
qmi_port_allocate_client_ready (MMPortQmi *qmi,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
ConnectContext *ctx)
|
GTask *task)
|
||||||
{
|
{
|
||||||
|
ConnectContext *ctx;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
|
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
|
||||||
g_assert (!(ctx->running_ipv4 && ctx->running_ipv6));
|
g_assert (!(ctx->running_ipv4 && ctx->running_ipv6));
|
||||||
|
|
||||||
if (!mm_port_qmi_allocate_client_finish (qmi, res, &error)) {
|
if (!mm_port_qmi_allocate_client_finish (qmi, res, &error)) {
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
g_task_return_error (task, error);
|
||||||
connect_context_complete_and_free (ctx);
|
g_object_unref (task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1006,40 +1014,44 @@ qmi_port_allocate_client_ready (MMPortQmi *qmi,
|
|||||||
|
|
||||||
/* Keep on */
|
/* Keep on */
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
connect_context_step (ctx);
|
connect_context_step (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
qmi_port_open_ready (MMPortQmi *qmi,
|
qmi_port_open_ready (MMPortQmi *qmi,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
ConnectContext *ctx)
|
GTask *task)
|
||||||
{
|
{
|
||||||
|
ConnectContext *ctx;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!mm_port_qmi_open_finish (qmi, res, &error)) {
|
if (!mm_port_qmi_open_finish (qmi, res, &error)) {
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
g_task_return_error (task, error);
|
||||||
connect_context_complete_and_free (ctx);
|
g_object_unref (task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keep on */
|
/* Keep on */
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
ctx->step++;
|
ctx->step++;
|
||||||
connect_context_step (ctx);
|
connect_context_step (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
connect_context_step (ConnectContext *ctx)
|
connect_context_step (GTask *task)
|
||||||
{
|
{
|
||||||
|
ConnectContext *ctx;
|
||||||
|
GCancellable *cancellable;
|
||||||
|
|
||||||
/* If cancelled, complete */
|
/* If cancelled, complete */
|
||||||
if (g_cancellable_is_cancelled (ctx->cancellable)) {
|
if (g_task_return_error_if_cancelled (task)) {
|
||||||
g_simple_async_result_set_error (ctx->result,
|
g_object_unref (task);
|
||||||
MM_CORE_ERROR,
|
|
||||||
MM_CORE_ERROR_CANCELLED,
|
|
||||||
"Connection setup operation has been cancelled");
|
|
||||||
connect_context_complete_and_free (ctx);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
|
cancellable = g_task_get_cancellable (task);
|
||||||
|
|
||||||
switch (ctx->step) {
|
switch (ctx->step) {
|
||||||
case CONNECT_STEP_FIRST:
|
case CONNECT_STEP_FIRST:
|
||||||
|
|
||||||
@@ -1052,9 +1064,9 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
if (!mm_port_qmi_is_open (ctx->qmi)) {
|
if (!mm_port_qmi_is_open (ctx->qmi)) {
|
||||||
mm_port_qmi_open (ctx->qmi,
|
mm_port_qmi_open (ctx->qmi,
|
||||||
TRUE,
|
TRUE,
|
||||||
ctx->cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback)qmi_port_open_ready,
|
(GAsyncReadyCallback)qmi_port_open_ready,
|
||||||
ctx);
|
task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1080,7 +1092,7 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
/* If no IPv4 setup needed, jump to IPv6 */
|
/* If no IPv4 setup needed, jump to IPv6 */
|
||||||
if (!ctx->ipv4) {
|
if (!ctx->ipv4) {
|
||||||
ctx->step = CONNECT_STEP_IPV6;
|
ctx->step = CONNECT_STEP_IPV6;
|
||||||
connect_context_step (ctx);
|
connect_context_step (task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1102,9 +1114,9 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
mm_port_qmi_allocate_client (ctx->qmi,
|
mm_port_qmi_allocate_client (ctx->qmi,
|
||||||
QMI_SERVICE_WDS,
|
QMI_SERVICE_WDS,
|
||||||
MM_PORT_QMI_FLAG_WDS_IPV4,
|
MM_PORT_QMI_FLAG_WDS_IPV4,
|
||||||
ctx->cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback)qmi_port_allocate_client_ready,
|
(GAsyncReadyCallback)qmi_port_allocate_client_ready,
|
||||||
ctx);
|
task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1125,9 +1137,9 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
qmi_client_wds_set_ip_family (ctx->client_ipv4,
|
qmi_client_wds_set_ip_family (ctx->client_ipv4,
|
||||||
input,
|
input,
|
||||||
10,
|
10,
|
||||||
ctx->cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback)set_ip_family_ready,
|
(GAsyncReadyCallback)set_ip_family_ready,
|
||||||
ctx);
|
task);
|
||||||
qmi_message_wds_set_ip_family_input_unref (input);
|
qmi_message_wds_set_ip_family_input_unref (input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1144,9 +1156,9 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
&ctx->packet_service_status_ipv4_indication_id);
|
&ctx->packet_service_status_ipv4_indication_id);
|
||||||
setup_event_report_unsolicited_events (ctx->self,
|
setup_event_report_unsolicited_events (ctx->self,
|
||||||
ctx->client_ipv4,
|
ctx->client_ipv4,
|
||||||
ctx->cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback) connect_enable_indications_ipv4_ready,
|
(GAsyncReadyCallback) connect_enable_indications_ipv4_ready,
|
||||||
ctx);
|
task);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case CONNECT_STEP_START_NETWORK_IPV4: {
|
case CONNECT_STEP_START_NETWORK_IPV4: {
|
||||||
@@ -1157,9 +1169,9 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
qmi_client_wds_start_network (ctx->client_ipv4,
|
qmi_client_wds_start_network (ctx->client_ipv4,
|
||||||
input,
|
input,
|
||||||
45,
|
45,
|
||||||
ctx->cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback)start_network_ready,
|
(GAsyncReadyCallback)start_network_ready,
|
||||||
ctx);
|
task);
|
||||||
qmi_message_wds_start_network_input_unref (input);
|
qmi_message_wds_start_network_input_unref (input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1168,7 +1180,7 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
/* Retrieve and print IP configuration */
|
/* Retrieve and print IP configuration */
|
||||||
if (ctx->packet_data_handle_ipv4) {
|
if (ctx->packet_data_handle_ipv4) {
|
||||||
mm_dbg ("Getting IPv4 configuration...");
|
mm_dbg ("Getting IPv4 configuration...");
|
||||||
get_current_settings (ctx, ctx->client_ipv4);
|
get_current_settings (task, ctx->client_ipv4);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
@@ -1179,7 +1191,7 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
/* If no IPv6 setup needed, jump to last */
|
/* If no IPv6 setup needed, jump to last */
|
||||||
if (!ctx->ipv6) {
|
if (!ctx->ipv6) {
|
||||||
ctx->step = CONNECT_STEP_LAST;
|
ctx->step = CONNECT_STEP_LAST;
|
||||||
connect_context_step (ctx);
|
connect_context_step (task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1201,9 +1213,9 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
mm_port_qmi_allocate_client (ctx->qmi,
|
mm_port_qmi_allocate_client (ctx->qmi,
|
||||||
QMI_SERVICE_WDS,
|
QMI_SERVICE_WDS,
|
||||||
MM_PORT_QMI_FLAG_WDS_IPV6,
|
MM_PORT_QMI_FLAG_WDS_IPV6,
|
||||||
ctx->cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback)qmi_port_allocate_client_ready,
|
(GAsyncReadyCallback)qmi_port_allocate_client_ready,
|
||||||
ctx);
|
task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1226,9 +1238,9 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
qmi_client_wds_set_ip_family (ctx->client_ipv6,
|
qmi_client_wds_set_ip_family (ctx->client_ipv6,
|
||||||
input,
|
input,
|
||||||
10,
|
10,
|
||||||
ctx->cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback)set_ip_family_ready,
|
(GAsyncReadyCallback)set_ip_family_ready,
|
||||||
ctx);
|
task);
|
||||||
qmi_message_wds_set_ip_family_input_unref (input);
|
qmi_message_wds_set_ip_family_input_unref (input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1245,9 +1257,9 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
&ctx->packet_service_status_ipv6_indication_id);
|
&ctx->packet_service_status_ipv6_indication_id);
|
||||||
setup_event_report_unsolicited_events (ctx->self,
|
setup_event_report_unsolicited_events (ctx->self,
|
||||||
ctx->client_ipv6,
|
ctx->client_ipv6,
|
||||||
ctx->cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback) connect_enable_indications_ipv6_ready,
|
(GAsyncReadyCallback) connect_enable_indications_ipv6_ready,
|
||||||
ctx);
|
task);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case CONNECT_STEP_START_NETWORK_IPV6: {
|
case CONNECT_STEP_START_NETWORK_IPV6: {
|
||||||
@@ -1258,9 +1270,9 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
qmi_client_wds_start_network (ctx->client_ipv6,
|
qmi_client_wds_start_network (ctx->client_ipv6,
|
||||||
input,
|
input,
|
||||||
45,
|
45,
|
||||||
ctx->cancellable,
|
cancellable,
|
||||||
(GAsyncReadyCallback)start_network_ready,
|
(GAsyncReadyCallback)start_network_ready,
|
||||||
ctx);
|
task);
|
||||||
qmi_message_wds_start_network_input_unref (input);
|
qmi_message_wds_start_network_input_unref (input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1269,7 +1281,7 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
/* Retrieve and print IP configuration */
|
/* Retrieve and print IP configuration */
|
||||||
if (ctx->packet_data_handle_ipv6) {
|
if (ctx->packet_data_handle_ipv6) {
|
||||||
mm_dbg ("Getting IPv6 configuration...");
|
mm_dbg ("Getting IPv6 configuration...");
|
||||||
get_current_settings (ctx, ctx->client_ipv6);
|
get_current_settings (task, ctx->client_ipv6);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
@@ -1309,8 +1321,8 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set operation result */
|
/* Set operation result */
|
||||||
g_simple_async_result_set_op_res_gpointer (
|
g_task_return_pointer (
|
||||||
ctx->result,
|
task,
|
||||||
mm_bearer_connect_result_new (ctx->data, ctx->ipv4_config, ctx->ipv6_config),
|
mm_bearer_connect_result_new (ctx->data, ctx->ipv4_config, ctx->ipv6_config),
|
||||||
(GDestroyNotify)mm_bearer_connect_result_unref);
|
(GDestroyNotify)mm_bearer_connect_result_unref);
|
||||||
} else {
|
} else {
|
||||||
@@ -1325,10 +1337,10 @@ connect_context_step (ConnectContext *ctx)
|
|||||||
ctx->error_ipv6 = NULL;
|
ctx->error_ipv6 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
g_task_return_error (task, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect_context_complete_and_free (ctx);
|
g_object_unref (task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1346,6 +1358,7 @@ _connect (MMBaseBearer *self,
|
|||||||
MMPortQmi *qmi;
|
MMPortQmi *qmi;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const gchar *apn;
|
const gchar *apn;
|
||||||
|
GTask *task;
|
||||||
|
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_BASE_BEARER_MODEM, &modem,
|
MM_BASE_BEARER_MODEM, &modem,
|
||||||
@@ -1355,10 +1368,11 @@ _connect (MMBaseBearer *self,
|
|||||||
/* Grab a data port */
|
/* Grab a data port */
|
||||||
data = mm_base_modem_get_best_data_port (modem, MM_PORT_TYPE_NET);
|
data = mm_base_modem_get_best_data_port (modem, MM_PORT_TYPE_NET);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
g_simple_async_report_error_in_idle (
|
g_task_report_new_error (
|
||||||
G_OBJECT (self),
|
self,
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
|
_connect,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_NOT_FOUND,
|
MM_CORE_ERROR_NOT_FOUND,
|
||||||
"No valid data port found to launch connection");
|
"No valid data port found to launch connection");
|
||||||
@@ -1369,10 +1383,11 @@ _connect (MMBaseBearer *self,
|
|||||||
/* Each data port has a single QMI port associated */
|
/* Each data port has a single QMI port associated */
|
||||||
qmi = mm_base_modem_get_port_qmi_for_data (modem, data, &error);
|
qmi = mm_base_modem_get_port_qmi_for_data (modem, data, &error);
|
||||||
if (!qmi) {
|
if (!qmi) {
|
||||||
g_simple_async_report_take_gerror_in_idle (
|
g_task_report_error (
|
||||||
G_OBJECT (self),
|
self,
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
|
_connect,
|
||||||
error);
|
error);
|
||||||
g_object_unref (data);
|
g_object_unref (data);
|
||||||
g_object_unref (modem);
|
g_object_unref (modem);
|
||||||
@@ -1384,10 +1399,11 @@ _connect (MMBaseBearer *self,
|
|||||||
|
|
||||||
/* Is this a 3GPP only modem and no APN was given? If so, error */
|
/* Is this a 3GPP only modem and no APN was given? If so, error */
|
||||||
if (mm_iface_modem_is_3gpp_only (MM_IFACE_MODEM (modem)) && !apn) {
|
if (mm_iface_modem_is_3gpp_only (MM_IFACE_MODEM (modem)) && !apn) {
|
||||||
g_simple_async_report_error_in_idle (
|
g_task_report_new_error (
|
||||||
G_OBJECT (self),
|
self,
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
|
_connect,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_INVALID_ARGS,
|
MM_CORE_ERROR_INVALID_ARGS,
|
||||||
"3GPP connection logic requires APN setting");
|
"3GPP connection logic requires APN setting");
|
||||||
@@ -1397,10 +1413,11 @@ _connect (MMBaseBearer *self,
|
|||||||
|
|
||||||
/* Is this a 3GPP2 only modem and APN was given? If so, error */
|
/* Is this a 3GPP2 only modem and APN was given? If so, error */
|
||||||
if (mm_iface_modem_is_cdma_only (MM_IFACE_MODEM (modem)) && apn) {
|
if (mm_iface_modem_is_cdma_only (MM_IFACE_MODEM (modem)) && apn) {
|
||||||
g_simple_async_report_error_in_idle (
|
g_task_report_new_error (
|
||||||
G_OBJECT (self),
|
self,
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
|
_connect,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_INVALID_ARGS,
|
MM_CORE_ERROR_INVALID_ARGS,
|
||||||
"3GPP2 doesn't support APN setting");
|
"3GPP2 doesn't support APN setting");
|
||||||
@@ -1420,18 +1437,16 @@ _connect (MMBaseBearer *self,
|
|||||||
ctx->self = g_object_ref (self);
|
ctx->self = g_object_ref (self);
|
||||||
ctx->qmi = qmi;
|
ctx->qmi = qmi;
|
||||||
ctx->data = data;
|
ctx->data = data;
|
||||||
ctx->cancellable = g_object_ref (cancellable);
|
|
||||||
ctx->step = CONNECT_STEP_FIRST;
|
ctx->step = CONNECT_STEP_FIRST;
|
||||||
ctx->ip_method = MM_BEARER_IP_METHOD_UNKNOWN;
|
ctx->ip_method = MM_BEARER_IP_METHOD_UNKNOWN;
|
||||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
connect);
|
|
||||||
|
|
||||||
g_object_get (self,
|
g_object_get (self,
|
||||||
MM_BASE_BEARER_CONFIG, &properties,
|
MM_BASE_BEARER_CONFIG, &properties,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
task = g_task_new (self, cancellable, callback, user_data);
|
||||||
|
g_task_set_task_data (task, ctx, (GDestroyNotify)connect_context_free);
|
||||||
|
|
||||||
if (properties) {
|
if (properties) {
|
||||||
MMBearerAllowedAuth auth;
|
MMBearerAllowedAuth auth;
|
||||||
MMBearerIpFamily ip_family;
|
MMBearerIpFamily ip_family;
|
||||||
@@ -1466,14 +1481,14 @@ _connect (MMBaseBearer *self,
|
|||||||
gchar *str;
|
gchar *str;
|
||||||
|
|
||||||
str = mm_bearer_ip_family_build_string_from_mask (ip_family);
|
str = mm_bearer_ip_family_build_string_from_mask (ip_family);
|
||||||
g_simple_async_result_set_error (
|
g_task_return_new_error (
|
||||||
ctx->result,
|
task,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_UNSUPPORTED,
|
MM_CORE_ERROR_UNSUPPORTED,
|
||||||
"Unsupported IP type requested: '%s'",
|
"Unsupported IP type requested: '%s'",
|
||||||
str);
|
str);
|
||||||
|
g_object_unref (task);
|
||||||
g_free (str);
|
g_free (str);
|
||||||
connect_context_complete_and_free (ctx);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1492,20 +1507,20 @@ _connect (MMBaseBearer *self,
|
|||||||
gchar *str;
|
gchar *str;
|
||||||
|
|
||||||
str = mm_bearer_allowed_auth_build_string_from_mask (auth);
|
str = mm_bearer_allowed_auth_build_string_from_mask (auth);
|
||||||
g_simple_async_result_set_error (
|
g_task_return_new_error (
|
||||||
ctx->result,
|
task,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_UNSUPPORTED,
|
MM_CORE_ERROR_UNSUPPORTED,
|
||||||
"Cannot use any of the specified authentication methods (%s)",
|
"Cannot use any of the specified authentication methods (%s)",
|
||||||
str);
|
str);
|
||||||
|
g_object_unref (task);
|
||||||
g_free (str);
|
g_free (str);
|
||||||
connect_context_complete_and_free (ctx);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run! */
|
/* Run! */
|
||||||
connect_context_step (ctx);
|
connect_context_step (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
Reference in New Issue
Block a user