[PATCH] port-mbim: port mm_port_mbim_{open,close} to use GTask

2017-04-06 Thread Ben Chan
---
 src/mm-port-mbim.c | 130 +
 1 file changed, 50 insertions(+), 80 deletions(-)

diff --git a/src/mm-port-mbim.c b/src/mm-port-mbim.c
index 2b649963..5015c388 100644
--- a/src/mm-port-mbim.c
+++ b/src/mm-port-mbim.c
@@ -31,90 +31,58 @@ struct _MMPortMbimPrivate {
 
 /*/
 
-typedef struct {
-MMPortMbim *self;
-GSimpleAsyncResult *result;
-GCancellable *cancellable;
-} PortContext;
-
-static void
-port_context_complete_and_free (PortContext *ctx)
-{
-g_simple_async_result_complete_in_idle (ctx->result);
-if (ctx->cancellable)
-g_object_unref (ctx->cancellable);
-g_object_unref (ctx->result);
-g_object_unref (ctx->self);
-g_slice_free (PortContext, ctx);
-}
-
-static PortContext *
-port_context_new (MMPortMbim *self,
-  GCancellable *cancellable,
-  GAsyncReadyCallback callback,
-  gpointer user_data)
-{
-PortContext *ctx;
-
-ctx = g_slice_new0 (PortContext);
-ctx->self = g_object_ref (self);
-ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- port_context_new);
-ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
-return ctx;
-}
-
-/*/
-
 gboolean
 mm_port_mbim_open_finish (MMPortMbim *self,
   GAsyncResult *res,
   GError **error)
 {
-return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
(res), error);
+return g_task_propagate_boolean (G_TASK (res), error);
 }
 
 static void
 mbim_device_open_ready (MbimDevice *mbim_device,
 GAsyncResult *res,
-PortContext *ctx)
+GTask *task)
 {
 GError *error = NULL;
+MMPortMbim *self;
+
+self = g_task_get_source_object (task);
 
 /* Reset the progress flag */
-ctx->self->priv->in_progress = FALSE;
+self->priv->in_progress = FALSE;
 if (!mbim_device_open_full_finish (mbim_device, res, )) {
-g_clear_object (>self->priv->mbim_device);
-g_simple_async_result_take_error (ctx->result, error);
+g_clear_object (>priv->mbim_device);
+g_task_return_error (task, error);
 } else
-g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
+g_task_return_boolean (task, TRUE);
 
-port_context_complete_and_free (ctx);
+g_object_unref (task);
 }
 
 static void
 mbim_device_new_ready (GObject *unused,
GAsyncResult *res,
-   PortContext *ctx)
+   GTask *task)
 {
 GError *error = NULL;
+MMPortMbim *self;
 
-ctx->self->priv->mbim_device = mbim_device_new_finish (res, );
-if (!ctx->self->priv->mbim_device) {
-g_simple_async_result_take_error (ctx->result, error);
-port_context_complete_and_free (ctx);
+self = g_task_get_source_object (task);
+self->priv->mbim_device = mbim_device_new_finish (res, );
+if (!self->priv->mbim_device) {
+g_task_return_error (task, error);
+g_object_unref (task);
 return;
 }
 
 /* Now open the MBIM device */
-mbim_device_open_full (ctx->self->priv->mbim_device,
+mbim_device_open_full (self->priv->mbim_device,
MBIM_DEVICE_OPEN_FLAGS_PROXY,
30,
-   ctx->cancellable,
+   g_task_get_cancellable (task),
(GAsyncReadyCallback)mbim_device_open_ready,
-   ctx);
+   task);
 }
 
 void
@@ -125,24 +93,24 @@ mm_port_mbim_open (MMPortMbim *self,
 {
 GFile *file;
 gchar *fullpath;
-PortContext *ctx;
+GTask *task;
 
 g_return_if_fail (MM_IS_PORT_MBIM (self));
 
-ctx = port_context_new (self, cancellable, callback, user_data);
+task = g_task_new (self, cancellable, callback, user_data);
 
 if (self->priv->in_progress) {
-g_simple_async_result_set_error (ctx->result,
- MM_CORE_ERROR,
- MM_CORE_ERROR_IN_PROGRESS,
- "MBIM device open/close operation in 
progress");
-port_context_complete_and_free (ctx);
+g_task_return_new_error (task,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_IN_PROGRESS,
+ "MBIM device open/close operation in 
progress");
+g_object_unref (task);
 return;
 }
 
 if (self->priv->mbim_device) {
-g_simple_async_result_set_op_res_gboolean 

[PATCH 2/2] port-qmi: port mm_port_qmi_allocate_client to use GTask

2017-04-06 Thread Ben Chan
---
 src/mm-port-qmi.c | 51 ++-
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/src/mm-port-qmi.c b/src/mm-port-qmi.c
index c6ae0615..2baeea7c 100644
--- a/src/mm-port-qmi.c
+++ b/src/mm-port-qmi.c
@@ -73,21 +73,16 @@ mm_port_qmi_get_client (MMPortQmi *self,
 /*/
 
 typedef struct {
-MMPortQmi *self;
-GSimpleAsyncResult *result;
 ServiceInfo *info;
 } AllocateClientContext;
 
 static void
-allocate_client_context_complete_and_free (AllocateClientContext *ctx)
+allocate_client_context_free (AllocateClientContext *ctx)
 {
-g_simple_async_result_complete (ctx->result);
 if (ctx->info) {
 g_assert (ctx->info->client == NULL);
 g_free (ctx->info);
 }
-g_object_unref (ctx->result);
-g_object_unref (ctx->self);
 g_free (ctx);
 }
 
@@ -96,30 +91,34 @@ mm_port_qmi_allocate_client_finish (MMPortQmi *self,
 GAsyncResult *res,
 GError **error)
 {
-return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
(res), error);
+return g_task_propagate_boolean (G_TASK (res), error);
 }
 
 static void
 allocate_client_ready (QmiDevice *qmi_device,
GAsyncResult *res,
-   AllocateClientContext *ctx)
+   GTask *task)
 {
+MMPortQmi *self;
+AllocateClientContext *ctx;
 GError *error = NULL;
 
+self = g_task_get_source_object (task);
+ctx = g_task_get_task_data (task);
 ctx->info->client = qmi_device_allocate_client_finish (qmi_device, res, 
);
 if (!ctx->info->client) {
 g_prefix_error (,
 "Couldn't create client for service '%s': ",
 qmi_service_get_string (ctx->info->service));
-g_simple_async_result_take_error (ctx->result, error);
+g_task_return_error (task, error);
 } else {
-g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
+g_task_return_boolean (task, TRUE);
 /* Move the service info to our internal list */
-ctx->self->priv->services = g_list_prepend (ctx->self->priv->services, 
ctx->info);
+self->priv->services = g_list_prepend (self->priv->services, 
ctx->info);
 ctx->info = NULL;
 }
 
-allocate_client_context_complete_and_free (ctx);
+g_object_unref (task);
 }
 
 void
@@ -131,35 +130,37 @@ mm_port_qmi_allocate_client (MMPortQmi *self,
  gpointer user_data)
 {
 AllocateClientContext *ctx;
+GTask *task;
 
 if (!!mm_port_qmi_peek_client (self, service, flag)) {
-g_simple_async_report_error_in_idle (G_OBJECT (self),
- callback,
- user_data,
- MM_CORE_ERROR,
- MM_CORE_ERROR_EXISTS,
- "Client for service '%s' already 
allocated",
- qmi_service_get_string (service));
+g_task_report_new_error (self,
+ callback,
+ user_data,
+ mm_port_qmi_allocate_client,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_EXISTS,
+ "Client for service '%s' already allocated",
+ qmi_service_get_string (service));
 return;
 }
 
 ctx = g_new0 (AllocateClientContext, 1);
-ctx->self = g_object_ref (self);
-ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- mm_port_qmi_allocate_client);
 ctx->info = g_new0 (ServiceInfo, 1);
 ctx->info->service = service;
 ctx->info->flag = flag;
 
+task = g_task_new (self, cancellable, callback, user_data);
+g_task_set_task_data (task,
+  ctx,
+  (GDestroyNotify)allocate_client_context_free);
+
 qmi_device_allocate_client (self->priv->qmi_device,
 service,
 QMI_CID_NONE,
 10,
 cancellable,
 (GAsyncReadyCallback)allocate_client_ready,
-ctx);
+task);
 }
 
 /*/
-- 
2.12.2.715.g7642488e1d-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org

[PATCH 1/2] port-qmi: port mm_port_qmi_open to use GTask

2017-04-06 Thread Ben Chan
---
 src/mm-port-qmi.c | 142 +-
 1 file changed, 76 insertions(+), 66 deletions(-)

diff --git a/src/mm-port-qmi.c b/src/mm-port-qmi.c
index eb163006..c6ae0615 100644
--- a/src/mm-port-qmi.c
+++ b/src/mm-port-qmi.c
@@ -188,9 +188,6 @@ typedef enum {
 } PortOpenStep;
 
 typedef struct {
-MMPortQmi *self;
-GSimpleAsyncResult *result;
-GCancellable *cancellable;
 QmiDevice *device;
 QmiClient *wda;
 GError *error;
@@ -201,9 +198,8 @@ typedef struct {
 } PortOpenContext;
 
 static void
-port_open_context_complete_and_free (PortOpenContext *ctx)
+port_open_context_free (PortOpenContext *ctx)
 {
-g_simple_async_result_complete_in_idle (ctx->result);
 if (ctx->wda) {
 g_assert (ctx->device);
 qmi_device_release_client (ctx->device,
@@ -214,10 +210,6 @@ port_open_context_complete_and_free (PortOpenContext *ctx)
 }
 if (ctx->device)
 g_object_unref (ctx->device);
-if (ctx->cancellable)
-g_object_unref (ctx->cancellable);
-g_object_unref (ctx->result);
-g_object_unref (ctx->self);
 g_slice_free (PortOpenContext, ctx);
 }
 
@@ -226,30 +218,36 @@ mm_port_qmi_open_finish (MMPortQmi *self,
  GAsyncResult *res,
  GError **error)
 {
-return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
(res), error);
+return g_task_propagate_boolean (G_TASK (res), error);
 }
 
-static void port_open_context_step (PortOpenContext *ctx);
+static void port_open_step (GTask *task);
 
 static void
 qmi_device_open_second_ready (QmiDevice *qmi_device,
   GAsyncResult *res,
-  PortOpenContext *ctx)
+  GTask *task)
 {
+PortOpenContext *ctx;
+
+ctx = g_task_get_task_data (task);
+
 qmi_device_open_finish (qmi_device, res, >error);
 
 /* In both error and success, we go to last step */
 ctx->step = PORT_OPEN_STEP_LAST;
-port_open_context_step (ctx);
+port_open_step (task);
 }
 
 static void
 get_data_format_ready (QmiClientWda *client,
GAsyncResult *res,
-   PortOpenContext *ctx)
+   GTask *task)
 {
+PortOpenContext *ctx;
 QmiMessageWdaGetDataFormatOutput *output;
 
+ctx = g_task_get_task_data (task);
 output = qmi_client_wda_get_data_format_finish (client, res, NULL);
 if (!output ||
 !qmi_message_wda_get_data_format_output_get_result (output, NULL) ||
@@ -263,33 +261,39 @@ get_data_format_ready (QmiClientWda *client,
 if (output)
 qmi_message_wda_get_data_format_output_unref (output);
 
-port_open_context_step (ctx);
+port_open_step (task);
 }
 
 static void
 allocate_client_wda_ready (QmiDevice *device,
GAsyncResult *res,
-   PortOpenContext *ctx)
+   GTask *task)
 {
+PortOpenContext *ctx;
+
+ctx = g_task_get_task_data (task);
 ctx->wda = qmi_device_allocate_client_finish (device, res, NULL);
 if (!ctx->wda) {
 /* If no WDA supported, then we just fallback to reopening explicitly
  * requesting 802.3 in the CTL service. */
 ctx->step = PORT_OPEN_STEP_OPEN_WITH_DATA_FORMAT;
-port_open_context_step (ctx);
+port_open_step (task);
 return;
 }
 
 /* Go on to next step */
 ctx->step++;
-port_open_context_step (ctx);
+port_open_step (task);
 }
 
 static void
 qmi_device_open_first_ready (QmiDevice *qmi_device,
  GAsyncResult *res,
- PortOpenContext *ctx)
+ GTask *task)
 {
+PortOpenContext *ctx;
+
+ctx = g_task_get_task_data (task);
 if (!qmi_device_open_finish (qmi_device, res, >error))
 /* Error opening the device */
 ctx->step = PORT_OPEN_STEP_LAST;
@@ -299,14 +303,17 @@ qmi_device_open_first_ready (QmiDevice *qmi_device,
 else
 /* Go on to next step */
 ctx->step++;
-port_open_context_step (ctx);
+port_open_step (task);
 }
 
 static void
 qmi_device_new_ready (GObject *unused,
   GAsyncResult *res,
-  PortOpenContext *ctx)
+  GTask *task)
 {
+PortOpenContext *ctx;
+
+ctx = g_task_get_task_data (task);
 /* Store the device in the context until the operation is fully done,
  * so that we return IN_PROGRESS errors until we finish this async
  * operation. */
@@ -317,12 +324,17 @@ qmi_device_new_ready (GObject *unused,
 else
 /* Go on to next step */
 ctx->step++;
-port_open_context_step (ctx);
+port_open_step (task);
 }
 
 static void
-port_open_context_step (PortOpenContext *ctx)
+port_open_step (GTask *task)
 {
+MMPortQmi *self;
+PortOpenContext *ctx;
+
+self = g_task_get_source_object (task);
+ctx = 

[PATCH 2/2] sms-mbim: port sms_delete to use GTask

2017-04-06 Thread Ben Chan
---
 src/mm-sms-mbim.c | 48 +++-
 1 file changed, 23 insertions(+), 25 deletions(-)

diff --git a/src/mm-sms-mbim.c b/src/mm-sms-mbim.c
index 085a2d59..99e0de74 100644
--- a/src/mm-sms-mbim.c
+++ b/src/mm-sms-mbim.c
@@ -207,22 +207,17 @@ sms_send (MMBaseSms *self,
 /*/
 
 typedef struct {
-MMBaseSms *self;
 MMBaseModem *modem;
 MbimDevice *device;
-GSimpleAsyncResult *result;
 GList *current;
 guint n_failed;
 } SmsDeletePartsContext;
 
 static void
-sms_delete_parts_context_complete_and_free (SmsDeletePartsContext *ctx)
+sms_delete_parts_context_free (SmsDeletePartsContext *ctx)
 {
-g_simple_async_result_complete_in_idle (ctx->result);
-g_object_unref (ctx->result);
 g_object_unref (ctx->device);
 g_object_unref (ctx->modem);
-g_object_unref (ctx->self);
 g_slice_free (SmsDeletePartsContext, ctx);
 }
 
@@ -231,19 +226,21 @@ sms_delete_finish (MMBaseSms *self,
GAsyncResult *res,
GError **error)
 {
-return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
(res), error);
+return g_task_propagate_boolean (G_TASK (res), error);
 }
 
-static void delete_next_part (SmsDeletePartsContext *ctx);
+static void delete_next_part (GTask *task);
 
 static void
 sms_delete_set_ready (MbimDevice *device,
   GAsyncResult *res,
-  SmsDeletePartsContext *ctx)
+  GTask *task)
 {
+SmsDeletePartsContext *ctx;
 MbimMessage *response;
 GError *error = NULL;
 
+ctx = g_task_get_task_data (task);
 response = mbim_device_command_finish (device, res, );
 if (response &&
 mbim_message_response_get_result (response, 
MBIM_MESSAGE_TYPE_COMMAND_DONE, ))
@@ -264,14 +261,16 @@ sms_delete_set_ready (MbimDevice *device,
 mm_sms_part_set_index ((MMSmsPart *)ctx->current->data, 
SMS_PART_INVALID_INDEX);
 
 ctx->current = g_list_next (ctx->current);
-delete_next_part (ctx);
+delete_next_part (task);
 }
 
 static void
-delete_next_part (SmsDeletePartsContext *ctx)
+delete_next_part (GTask *task)
 {
+SmsDeletePartsContext *ctx;
 MbimMessage *message;
 
+ctx = g_task_get_task_data (task);
 /* Skip non-stored parts */
 while (ctx->current &&
mm_sms_part_get_index ((MMSmsPart *)ctx->current->data) == 
SMS_PART_INVALID_INDEX)
@@ -280,15 +279,15 @@ delete_next_part (SmsDeletePartsContext *ctx)
 /* If all removed, we're done */
 if (!ctx->current) {
 if (ctx->n_failed > 0)
-g_simple_async_result_set_error (ctx->result,
- MM_CORE_ERROR,
- MM_CORE_ERROR_FAILED,
- "Couldn't delete %u parts from 
this SMS",
- ctx->n_failed);
+g_task_return_new_error (task,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't delete %u parts from this SMS",
+ ctx->n_failed);
 else
-g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
+g_task_return_boolean (task, TRUE);
 
-sms_delete_parts_context_complete_and_free (ctx);
+g_object_unref (task);
 return;
 }
 
@@ -300,7 +299,7 @@ delete_next_part (SmsDeletePartsContext *ctx)
  10,
  NULL,
  (GAsyncReadyCallback)sms_delete_set_ready,
- ctx);
+ task);
 mbim_message_unref (message);
 
 }
@@ -312,24 +311,23 @@ sms_delete (MMBaseSms *self,
 {
 SmsDeletePartsContext *ctx;
 MbimDevice *device;
+GTask *task;
 
 if (!peek_device (self, , callback, user_data))
 return;
 
 ctx = g_slice_new0 (SmsDeletePartsContext);
-ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- sms_delete);
-ctx->self = g_object_ref (self);
 ctx->device = g_object_ref (device);
 g_object_get (self,
   MM_BASE_SMS_MODEM, >modem,
   NULL);
 
+task = g_task_new (self, NULL, callback, user_data);
+g_task_set_task_data (task, ctx, 
(GDestroyNotify)sms_delete_parts_context_free);
+
 /* Go on deleting parts */
 ctx->current = mm_base_sms_get_parts (self);
-delete_next_part (ctx);
+delete_next_part (task);
 }
 
 /*/
-- 
2.12.2.715.g7642488e1d-goog

___
ModemManager-devel mailing list

[PATCH 1/2] sms-mbim: port sms_send to use GTask

2017-04-06 Thread Ben Chan
---
 src/mm-sms-mbim.c | 46 ++
 1 file changed, 22 insertions(+), 24 deletions(-)

diff --git a/src/mm-sms-mbim.c b/src/mm-sms-mbim.c
index eded51fc..085a2d59 100644
--- a/src/mm-sms-mbim.c
+++ b/src/mm-sms-mbim.c
@@ -74,21 +74,16 @@ peek_device (gpointer self,
 /* Send the SMS */
 
 typedef struct {
-MMBaseSms *self;
 MMBaseModem *modem;
 MbimDevice *device;
-GSimpleAsyncResult *result;
 GList *current;
 } SmsSendContext;
 
 static void
-sms_send_context_complete_and_free (SmsSendContext *ctx)
+sms_send_context_free (SmsSendContext *ctx)
 {
-g_simple_async_result_complete_in_idle (ctx->result);
-g_object_unref (ctx->result);
 g_object_unref (ctx->device);
 g_object_unref (ctx->modem);
-g_object_unref (ctx->self);
 g_slice_free (SmsSendContext, ctx);
 }
 
@@ -97,20 +92,22 @@ sms_send_finish (MMBaseSms *self,
  GAsyncResult *res,
  GError **error)
 {
-return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
(res), error);
+return g_task_propagate_boolean (G_TASK (res), error);
 }
 
-static void sms_send_next_part (SmsSendContext *ctx);
+static void sms_send_next_part (GTask *task);
 
 static void
 sms_send_set_ready (MbimDevice *device,
 GAsyncResult *res,
-SmsSendContext *ctx)
+GTask *task)
 {
+SmsSendContext *ctx;
 MbimMessage *response;
 GError *error = NULL;
 guint32 message_reference;
 
+ctx = g_task_get_task_data (task);
 response = mbim_device_command_finish (device, res, );
 if (response &&
 mbim_message_response_get_result (response, 
MBIM_MESSAGE_TYPE_COMMAND_DONE, ) &&
@@ -127,19 +124,20 @@ sms_send_set_ready (MbimDevice *device,
 
 if (error) {
 g_prefix_error (, "Couldn't send SMS part: ");
-g_simple_async_result_take_error (ctx->result, error);
-sms_send_context_complete_and_free (ctx);
+g_task_return_error (task, error);
+g_object_unref (task);
 return;
 }
 
 /* Go on with next part */
 ctx->current = g_list_next (ctx->current);
-sms_send_next_part (ctx);
+sms_send_next_part (task);
 }
 
 static void
-sms_send_next_part (SmsSendContext *ctx)
+sms_send_next_part (GTask *task)
 {
+SmsSendContext *ctx;
 MbimMessage *message;
 guint8 *pdu;
 guint pdulen = 0;
@@ -147,18 +145,19 @@ sms_send_next_part (SmsSendContext *ctx)
 GError *error = NULL;
 MbimSmsPduSendRecord send_record;
 
+ctx = g_task_get_task_data (task);
 if (!ctx->current) {
 /* Done we are */
-g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
-sms_send_context_complete_and_free (ctx);
+g_task_return_boolean (task, TRUE);
+g_object_unref (task);
 return;
 }
 
 /* Get PDU */
 pdu = mm_sms_part_3gpp_get_submit_pdu ((MMSmsPart *)ctx->current->data, 
, , );
 if (!pdu) {
-g_simple_async_result_take_error (ctx->result, error);
-sms_send_context_complete_and_free (ctx);
+g_task_return_error (task, error);
+g_object_unref (task);
 return;
 }
 
@@ -174,7 +173,7 @@ sms_send_next_part (SmsSendContext *ctx)
  30,
  NULL,
  (GAsyncReadyCallback)sms_send_set_ready,
- ctx);
+ task);
 mbim_message_unref (message);
 g_free (pdu);
 }
@@ -186,24 +185,23 @@ sms_send (MMBaseSms *self,
 {
 SmsSendContext *ctx;
 MbimDevice *device;
+GTask *task;
 
 if (!peek_device (self, , callback, user_data))
 return;
 
 /* Setup the context */
 ctx = g_slice_new0 (SmsSendContext);
-ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- sms_send);
-ctx->self = g_object_ref (self);
 ctx->device = g_object_ref (device);
 g_object_get (self,
   MM_BASE_SMS_MODEM, >modem,
   NULL);
 
+task = g_task_new (self, NULL, callback, user_data);
+g_task_set_task_data (task, ctx, (GDestroyNotify)sms_send_context_free);
+
 ctx->current = mm_base_sms_get_parts (self);;
-sms_send_next_part (ctx);
+sms_send_next_part (task);
 }
 
 /*/
-- 
2.12.2.715.g7642488e1d-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] call-list: port mm_call_list_delete_call to use GTask

2017-04-06 Thread Ben Chan
---
 src/mm-call-list.c | 55 +++---
 1 file changed, 19 insertions(+), 36 deletions(-)

diff --git a/src/mm-call-list.c b/src/mm-call-list.c
index fae66035..1cc1f543 100644
--- a/src/mm-call-list.c
+++ b/src/mm-call-list.c
@@ -214,28 +214,12 @@ gboolean 
mm_call_list_send_dtmf_to_active_calls(MMCallList *self, gchar *dtmf)
 
 /*/
 
-typedef struct {
-MMCallList *self;
-GSimpleAsyncResult *result;
-gchar *path;
-} DeleteCallContext;
-
-static void
-delete_call_context_complete_and_free (DeleteCallContext *ctx)
-{
-g_simple_async_result_complete (ctx->result);
-g_object_unref (ctx->result);
-g_object_unref (ctx->self);
-g_free (ctx->path);
-g_free (ctx);
-}
-
 gboolean
 mm_call_list_delete_call_finish (MMCallList *self,
GAsyncResult *res,
GError **error)
 {
-return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
(res), error);
+return g_task_propagate_boolean (G_TASK (res), error);
 }
 
 static guint
@@ -248,25 +232,29 @@ cmp_call_by_path (MMBaseCall *call,
 static void
 delete_ready (MMBaseCall *call,
   GAsyncResult *res,
-  DeleteCallContext *ctx)
+  GTask *task)
 {
+MMCallList *self;
+const gchar *path;
 GError *error = NULL;
 GList *l;
 
+self = g_task_get_source_object (task);
+path = g_task_get_task_data (task);
 if (!mm_base_call_delete_finish (call, res, )) {
 /* We report the error */
-g_simple_async_result_take_error (ctx->result, error);
-delete_call_context_complete_and_free (ctx);
+g_task_return_error (task, error);
+g_object_unref (task);
 return;
 }
 
 /* The CALL was properly deleted, we now remove it from our list */
-l = g_list_find_custom (ctx->self->priv->list,
-ctx->path,
+l = g_list_find_custom (self->priv->list,
+path,
 (GCompareFunc)cmp_call_by_path);
 if (l) {
 g_object_unref (MM_BASE_CALL (l->data));
-ctx->self->priv->list = g_list_delete_link (ctx->self->priv->list, l);
+self->priv->list = g_list_delete_link (self->priv->list, l);
 }
 
 /* We don't need to unref the CALL any more, but we can use the
@@ -274,12 +262,12 @@ delete_ready (MMBaseCall *call,
  * during the async operation. */
 mm_base_call_unexport (call);
 
-g_signal_emit (ctx->self,
+g_signal_emit (self,
signals[SIGNAL_CALL_DELETED], 0,
-   ctx->path);
+   path);
 
-g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
-delete_call_context_complete_and_free (ctx);
+g_task_return_boolean (task, TRUE);
+g_object_unref (task);
 }
 
 void
@@ -288,8 +276,8 @@ mm_call_list_delete_call (MMCallList *self,
 GAsyncReadyCallback callback,
 gpointer user_data)
 {
-DeleteCallContext *ctx;
 GList *l;
+GTask *task;
 
 l = g_list_find_custom (self->priv->list,
 (gpointer)call_path,
@@ -306,17 +294,12 @@ mm_call_list_delete_call (MMCallList *self,
 }
 
 /* Delete all CALL parts */
-ctx = g_new0 (DeleteCallContext, 1);
-ctx->self = g_object_ref (self);
-ctx->path = g_strdup (call_path);
-ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- mm_call_list_delete_call);
+task = g_task_new (self, NULL, callback, user_data);
+g_task_set_task_data (task, g_strdup (call_path), g_free);
 
 mm_base_call_delete (MM_BASE_CALL (l->data),
 (GAsyncReadyCallback)delete_ready,
-ctx);
+task);
 }
 
 /*/
-- 
2.12.2.715.g7642488e1d-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] sms-list: port mm_sms_list_delete_sms to use GTask

2017-04-06 Thread Ben Chan
---
 src/mm-sms-list.c | 70 +--
 1 file changed, 27 insertions(+), 43 deletions(-)

diff --git a/src/mm-sms-list.c b/src/mm-sms-list.c
index 7819b3ad..22c2cd9a 100644
--- a/src/mm-sms-list.c
+++ b/src/mm-sms-list.c
@@ -113,28 +113,12 @@ mm_sms_list_get_paths (MMSmsList *self)
 
 /*/
 
-typedef struct {
-MMSmsList *self;
-GSimpleAsyncResult *result;
-gchar *path;
-} DeleteSmsContext;
-
-static void
-delete_sms_context_complete_and_free (DeleteSmsContext *ctx)
-{
-g_simple_async_result_complete (ctx->result);
-g_object_unref (ctx->result);
-g_object_unref (ctx->self);
-g_free (ctx->path);
-g_free (ctx);
-}
-
 gboolean
 mm_sms_list_delete_sms_finish (MMSmsList *self,
GAsyncResult *res,
GError **error)
 {
-return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
(res), error);
+return g_task_propagate_boolean (G_TASK (res), error);
 }
 
 static guint
@@ -147,25 +131,29 @@ cmp_sms_by_path (MMBaseSms *sms,
 static void
 delete_ready (MMBaseSms *sms,
   GAsyncResult *res,
-  DeleteSmsContext *ctx)
+  GTask *task)
 {
+MMSmsList *self;
+const gchar *path;
 GError *error = NULL;
 GList *l;
 
 if (!mm_base_sms_delete_finish (sms, res, )) {
 /* We report the error */
-g_simple_async_result_take_error (ctx->result, error);
-delete_sms_context_complete_and_free (ctx);
+g_task_return_error (task, error);
+g_object_unref (task);
 return;
 }
 
+self = g_task_get_source_object (task);
+path = g_task_get_task_data (task);
 /* The SMS was properly deleted, we now remove it from our list */
-l = g_list_find_custom (ctx->self->priv->list,
-ctx->path,
+l = g_list_find_custom (self->priv->list,
+path,
 (GCompareFunc)cmp_sms_by_path);
 if (l) {
 g_object_unref (MM_BASE_SMS (l->data));
-ctx->self->priv->list = g_list_delete_link (ctx->self->priv->list, l);
+self->priv->list = g_list_delete_link (self->priv->list, l);
 }
 
 /* We don't need to unref the SMS any more, but we can use the
@@ -173,12 +161,12 @@ delete_ready (MMBaseSms *sms,
  * during the async operation. */
 mm_base_sms_unexport (sms);
 
-g_signal_emit (ctx->self,
+g_signal_emit (self,
signals[SIGNAL_DELETED], 0,
-   ctx->path);
+   path);
 
-g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
-delete_sms_context_complete_and_free (ctx);
+g_task_return_boolean (task, TRUE);
+g_object_unref (task);
 }
 
 void
@@ -187,35 +175,31 @@ mm_sms_list_delete_sms (MMSmsList *self,
 GAsyncReadyCallback callback,
 gpointer user_data)
 {
-DeleteSmsContext *ctx;
 GList *l;
+GTask *task;
 
 l = g_list_find_custom (self->priv->list,
 (gpointer)sms_path,
 (GCompareFunc)cmp_sms_by_path);
 if (!l) {
-g_simple_async_report_error_in_idle (G_OBJECT (self),
- callback,
- user_data,
- MM_CORE_ERROR,
- MM_CORE_ERROR_NOT_FOUND,
- "No SMS found with path '%s'",
- sms_path);
+g_task_report_new_error (self,
+ callback,
+ user_data,
+ mm_sms_list_delete_sms,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_NOT_FOUND,
+ "No SMS found with path '%s'",
+ sms_path);
 return;
 }
 
 /* Delete all SMS parts */
-ctx = g_new0 (DeleteSmsContext, 1);
-ctx->self = g_object_ref (self);
-ctx->path = g_strdup (sms_path);
-ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- mm_sms_list_delete_sms);
+task = g_task_new (self, NULL, callback, user_data);
+g_task_set_task_data (task, g_strdup (sms_path), g_free);
 
 mm_base_sms_delete (MM_BASE_SMS (l->data),
 (GAsyncReadyCallback)delete_ready,
-ctx);
+task);
 }
 
 /*/
-- 
2.12.2.715.g7642488e1d-goog


[PATCH 1/2] auth: port authorize to use GTask

2017-04-06 Thread Ben Chan
---
 src/mm-auth-provider.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/mm-auth-provider.c b/src/mm-auth-provider.c
index 4ef56234..4d8766c0 100644
--- a/src/mm-auth-provider.c
+++ b/src/mm-auth-provider.c
@@ -75,15 +75,12 @@ authorize (MMAuthProvider *self,
GAsyncReadyCallback callback,
gpointer user_data)
 {
-GSimpleAsyncResult *result;
+GTask *task;
 
 /* Just create the result and complete it */
-result = g_simple_async_result_new (G_OBJECT (self),
-callback,
-user_data,
-authorize);
-g_simple_async_result_complete_in_idle (result);
-g_object_unref (result);
+task = g_task_new (self, cancellable, callback, user_data);
+g_task_return_boolean (task, TRUE);
+g_object_unref (task);
 }
 
 /*/
-- 
2.12.2.715.g7642488e1d-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


[PATCH] novatel: obtain MMPortProbe from GTask source object

2017-04-06 Thread Ben Chan
The MMPortProbe object is already referenced by the GTask object for
custom init. Instead of keeping another reference of MMPortProbe in the
CustomInitContext, this patch changes the code to simply obtain it from
the source object of GTask.

See 
https://lists.freedesktop.org/archives/modemmanager-devel/2017-April/004420.html
---
 plugins/novatel/mm-common-novatel.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/plugins/novatel/mm-common-novatel.c 
b/plugins/novatel/mm-common-novatel.c
index a8f2da90..96d845f1 100644
--- a/plugins/novatel/mm-common-novatel.c
+++ b/plugins/novatel/mm-common-novatel.c
@@ -20,7 +20,6 @@
 /* Custom init */
 
 typedef struct {
-MMPortProbe *probe;
 MMPortSerialAt *port;
 guint nwdmat_retries;
 guint wait_time;
@@ -30,7 +29,6 @@ static void
 custom_init_context_free (CustomInitContext *ctx)
 {
 g_object_unref (ctx->port);
-g_object_unref (ctx->probe);
 g_slice_free (CustomInitContext, ctx);
 }
 
@@ -84,6 +82,7 @@ static void
 custom_init_step (GTask *task)
 {
 CustomInitContext *ctx;
+MMPortProbe *probe;
 
 ctx = g_task_get_task_data (task);
 
@@ -96,8 +95,10 @@ custom_init_step (GTask *task)
 return;
 }
 
+probe = g_task_get_source_object (task);
+
 /* If device has a QMI port, don't run $NWDMAT */
-if (mm_port_probe_list_has_qmi_port (mm_device_peek_port_probe_list 
(mm_port_probe_peek_device (ctx->probe {
+if (mm_port_probe_list_has_qmi_port (mm_device_peek_port_probe_list 
(mm_port_probe_peek_device (probe {
 mm_dbg ("(Novatel) no need to run custom init in (%s): device has QMI 
port",
 mm_port_get_device (MM_PORT (ctx->port)));
 g_task_return_boolean (task, TRUE);
@@ -142,7 +143,6 @@ mm_common_novatel_custom_init (MMPortProbe *probe,
 GTask *task;
 
 ctx = g_slice_new (CustomInitContext);
-ctx->probe = g_object_ref (probe);
 ctx->port = g_object_ref (port);
 ctx->nwdmat_retries = 3;
 ctx->wait_time = 2;
-- 
2.12.2.715.g7642488e1d-goog

___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: ModemManager: symbol lookup error: ModemManager: undefined symbol: mm_kernel_event_properties_get_type

2017-04-06 Thread Aleksander Morgado
On 06/04/17 21:26, Jan Graczyk wrote:
> I have used ./configure --with-qmi=yes than make and make install and I have 
> run ModemManager with a command ModemManager --debug. Am I missing any other 
> option in ./configure? Thank you for your help.

If you are not using --prefix=/somewhere in ./configure, by default it
will get installed under /usr/local. i.e. the daemon in
/usr/local/bin/ModemManager and the libraries in /usr/local/lib.

There are distributions out there that include /usr/local/bin by default
in the $PATH, but then, they don't add /usr/local/lib in the default
paths for library loading. This is likely your case: you're running
/usr/local/bin/ModemManager but it is trying to link to
/usr/lib/libmm-glib.so, instead of /usr/local/lib/libmm-glib.so.

Given that you're upgrading MM to a completely new version which also
includes DBus updates, you may want to directly just install under /usr,
overwriting whatever was there before... for that you can just configure
using --prefix=/usr.

Otherwise, if you do want to keep installing under /usr/local, you'll
need to explicitly update the LD_LIBRARY_PATH when running ModemManager
like this:

$ sudo LD_LIBRARY_PATH=/usr/local/lib /usr/local/bin/ModemManager


-- 
Aleksander
https://aleksander.es
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [PATCH] iface-modem-simple: port register_in_3gpp_or_cdma_network to use GTask

2017-04-06 Thread Aleksander Morgado
On 04/04/17 08:37, Ben Chan wrote:
> ---
>  src/mm-iface-modem-simple.c | 59 
> ++---
>  1 file changed, 34 insertions(+), 25 deletions(-)
> 

Pushed to git master, thanks.

> diff --git a/src/mm-iface-modem-simple.c b/src/mm-iface-modem-simple.c
> index 572c4f92..a16adb19 100644
> --- a/src/mm-iface-modem-simple.c
> +++ b/src/mm-iface-modem-simple.c
> @@ -32,7 +32,6 @@
>  /* Register in either a CDMA or a 3GPP network (or both) */
>  
>  typedef struct {
> -GSimpleAsyncResult *result;
>  MMIfaceModemSimple *self;
>  gchar *operator_id;
>  guint remaining_tries_cdma;
> @@ -41,11 +40,9 @@ typedef struct {
>  } RegisterInNetworkContext;
>  
>  static void
> -register_in_network_context_complete_and_free (RegisterInNetworkContext *ctx)
> +register_in_network_context_free (RegisterInNetworkContext *ctx)
>  {
> -g_simple_async_result_complete_in_idle (ctx->result);
>  g_free (ctx->operator_id);
> -g_object_unref (ctx->result);
>  g_object_unref (ctx->self);
>  g_free (ctx);
>  }
> @@ -55,59 +52,69 @@ register_in_3gpp_or_cdma_network_finish 
> (MMIfaceModemSimple *self,
>   GAsyncResult *res,
>   GError **error)
>  {
> -return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
> (res), error);
> +return g_task_propagate_boolean (G_TASK (res), error);
>  }
>  
> -static void check_next_registration (RegisterInNetworkContext *ctx);
> +static void check_next_registration (GTask *task);
>  
>  static void
>  register_in_cdma_network_ready (MMIfaceModemCdma *self,
>  GAsyncResult *res,
> -RegisterInNetworkContext *ctx)
> +GTask *task)
>  {
> +RegisterInNetworkContext *ctx;
> +
> +ctx = g_task_get_task_data (task);
>  ctx->remaining_tries_cdma--;
>  
>  if (!mm_iface_modem_cdma_register_in_network_finish (
>  MM_IFACE_MODEM_CDMA (self), res, NULL)) {
>  /* Retry check */
> -check_next_registration (ctx);
> +check_next_registration (task);
>  return;
>  }
>  
>  /* Registered we are! */
> -g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
> -register_in_network_context_complete_and_free (ctx);
> +g_task_return_boolean (task, TRUE);
> +g_object_unref (task);
>  }
>  
>  static void
>  register_in_3gpp_network_ready (MMIfaceModem3gpp *self,
>  GAsyncResult *res,
> -RegisterInNetworkContext *ctx)
> +GTask *task)
>  {
> +RegisterInNetworkContext *ctx;
> +
> +ctx = g_task_get_task_data (task);
>  ctx->remaining_tries_3gpp--;
>  
>  if (!mm_iface_modem_3gpp_register_in_network_finish (
>  MM_IFACE_MODEM_3GPP (self), res, NULL)) {
>  /* Retry check */
> -check_next_registration (ctx);
> +check_next_registration (task);
>  return;
>  }
>  
>  /* Registered we are! */
> -g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
> -register_in_network_context_complete_and_free (ctx);
> +g_task_return_boolean (task, TRUE);
> +g_object_unref (task);
>  }
>  
>  static void
> -check_next_registration (RegisterInNetworkContext *ctx)
> +check_next_registration (GTask *task)
>  {
> +RegisterInNetworkContext *ctx;
> +
> +ctx = g_task_get_task_data (task);
> +
>  if (ctx->remaining_tries_cdma > ctx->remaining_tries_3gpp &&
>  ctx->remaining_tries_cdma > 0) {
>  mm_iface_modem_cdma_register_in_network (
>  MM_IFACE_MODEM_CDMA (ctx->self),
>  ctx->max_try_time,
>  (GAsyncReadyCallback)register_in_cdma_network_ready,
> -ctx);
> +task);
>  return;
>  }
>  
> @@ -117,15 +124,15 @@ check_next_registration (RegisterInNetworkContext *ctx)
>  ctx->operator_id,
>  ctx->max_try_time,
>  (GAsyncReadyCallback)register_in_3gpp_network_ready,
> -ctx);
> +task);
>  return;
>  }
>  
>  /* No more tries of anything */
> -g_simple_async_result_take_error (
> -ctx->result,
> +g_task_return_error (
> +task,
>  mm_mobile_equipment_error_for_code 
> (MM_MOBILE_EQUIPMENT_ERROR_NETWORK_TIMEOUT));
> -register_in_network_context_complete_and_free (ctx);
> +g_object_unref (task);
>  }
>  
>  static void
> @@ -135,14 +142,11 @@ register_in_3gpp_or_cdma_network (MMIfaceModemSimple 
> *self,
>gpointer user_data)
>  {
>  RegisterInNetworkContext *ctx;
> +GTask *task;
>  
>  ctx = g_new0 (RegisterInNetworkContext, 1);
>  ctx->self = g_object_ref (self);
>  ctx->operator_id = g_strdup (operator_id);
> -ctx->result = g_simple_async_result_new (G_OBJECT 

RE: ModemManager: symbol lookup error: ModemManager: undefined symbol: mm_kernel_event_properties_get_type

2017-04-06 Thread Jan Graczyk
Hello Aleksander,

I have used ./configure --with-qmi=yes than make and make install and I have 
run ModemManager with a command ModemManager --debug. Am I missing any other 
option in ./configure? Thank you for your help.

Jan Graczyk

-Original Message-
From: Aleksander Morgado [mailto:aleksan...@aleksander.es] 
Sent: Thursday, April 6, 2017 12:21 PM
To: Jan Graczyk ; modemmanager-devel@lists.freedesktop.org
Subject: Re: ModemManager: symbol lookup error: ModemManager: undefined symbol: 
mm_kernel_event_properties_get_type

On 06/04/17 21:14, Jan Graczyk wrote:
> I am using Quectel UC20 mini PCIe modem on my development board and running 
> ModemManager on it. Since ModemManager is using by default baud rate set to 
> 57600 I have decided to move to the latest version of ModemManager (1.7.0) 
> since there is a possibility to set udev rule for baud rate 
> ENV{ID_MM_TTY_BAUDRATE}="115200". However after rebuilding ModemManager 
> version 1.7.0 for ARM architecture and running it on my development board I 
> have got the following error:
> 
> ModemManager[1624]:  [1491504870.296599] 
> [mm-plugin-manager.c:1609] load_plugins(): [plugin manager] 
> successfully loaded 32 plugins
> ModemManager[1624]:  [1491504870.304070] [main.c:106] 
> name_acquired_cb(): Service name 'org.freedesktop.ModemManager1' was 
> acquired
> ModemManager[1624]:  [1491504870.636683] [mm-base-manager.c:573] 
> mm_base_manager_start(): Starting automatic device scan...
> ModemManager[1624]:  [1491504870.720354] [mm-base-manager.c:575] 
> mm_base_manager_start(): Finished device scan...
> ModemManager: symbol lookup error: ModemManager: undefined symbol: 
> mm_kernel_event_properties_get_type
> 
> [1]+  Exit 127ModemManager -debug
> 
> The only stable version of ModemManager which runs on my development board is 
> 1.4.0. But when using that version I need to set Quectel UC20 modem baud rate 
> to 57600 using AT+IPR=57600 command. I would like to take advantage of 
> ModemManager version 1.7.0 but unfortunately I am getting the above error 
> while running it.

Looks like you didn't install the newly compiled version properly.
You're running the ModemManager daemon from git master, and looks like it's 
linking to "libmm-glib" from an older version.

How did you configure ModemManager to build, and how are you running it?

--
Aleksander
https://aleksander.es
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [PATCH] bearer-list: port mm_bearer_list_disconnect_all_bearers to use GTask

2017-04-06 Thread Aleksander Morgado
On 04/04/17 08:37, Ben Chan wrote:
> ---
>  src/mm-bearer-list.c | 40 +---
>  1 file changed, 21 insertions(+), 19 deletions(-)
> 

Pushed to git master, thanks.

> diff --git a/src/mm-bearer-list.c b/src/mm-bearer-list.c
> index e021e34a..9ad98aeb 100644
> --- a/src/mm-bearer-list.c
> +++ b/src/mm-bearer-list.c
> @@ -177,16 +177,13 @@ mm_bearer_list_find_by_path (MMBearerList *self,
>  
> /*/
>  
>  typedef struct {
> -GSimpleAsyncResult *result;
>  GList *pending;
>  MMBaseBearer *current;
>  } DisconnectAllContext;
>  
>  static void
> -disconnect_all_context_complete_and_free (DisconnectAllContext *ctx)
> +disconnect_all_context_free (DisconnectAllContext *ctx)
>  {
> -g_simple_async_result_complete (ctx->result);
> -g_object_unref (ctx->result);
>  if (ctx->current)
>  g_object_unref (ctx->current);
>  g_list_free_full (ctx->pending, g_object_unref);
> @@ -198,37 +195,40 @@ mm_bearer_list_disconnect_all_bearers_finish 
> (MMBearerList *self,
>GAsyncResult *res,
>GError **error)
>  {
> -return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
> (res), error);
> +return g_task_propagate_boolean (G_TASK (res), error);
>  }
>  
> -static void disconnect_next_bearer (DisconnectAllContext *ctx);
> +static void disconnect_next_bearer (GTask *task);
>  
>  static void
>  disconnect_ready (MMBaseBearer *bearer,
>GAsyncResult *res,
> -  DisconnectAllContext *ctx)
> +  GTask *task)
>  {
>  GError *error = NULL;
>  
>  if (!mm_base_bearer_disconnect_finish (bearer, res, )) {
> -g_simple_async_result_take_error (ctx->result, error);
> -disconnect_all_context_complete_and_free (ctx);
> +g_task_return_error (task, error);
> +g_object_unref (task);
>  return;
>  }
>  
> -disconnect_next_bearer (ctx);
> +disconnect_next_bearer (task);
>  }
>  
>  static void
> -disconnect_next_bearer (DisconnectAllContext *ctx)
> +disconnect_next_bearer (GTask *task)
>  {
> +DisconnectAllContext *ctx;
> +
> +ctx = g_task_get_task_data (task);
>  if (ctx->current)
>  g_clear_object (>current);
>  
>  /* No more bearers? all done! */
>  if (!ctx->pending) {
> -g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
> -disconnect_all_context_complete_and_free (ctx);
> +g_task_return_boolean (task, TRUE);
> +g_object_unref (task);
>  return;
>  }
>  
> @@ -237,7 +237,7 @@ disconnect_next_bearer (DisconnectAllContext *ctx)
>  
>  mm_base_bearer_disconnect (ctx->current,
> (GAsyncReadyCallback)disconnect_ready,
> -   ctx);
> +   task);
>  }
>  
>  void
> @@ -246,17 +246,19 @@ mm_bearer_list_disconnect_all_bearers (MMBearerList 
> *self,
> gpointer user_data)
>  {
>  DisconnectAllContext *ctx;
> +GTask *task;
>  
>  ctx = g_new0 (DisconnectAllContext, 1);
> -ctx->result = g_simple_async_result_new (G_OBJECT (self),
> - callback,
> - user_data,
> - 
> mm_bearer_list_disconnect_all_bearers);
>  /* Get a copy of the list */
>  ctx->pending = g_list_copy (self->priv->bearers);
>  g_list_foreach (ctx->pending, (GFunc) g_object_ref, NULL);
>  
> -disconnect_next_bearer (ctx);
> +task = g_task_new (self, NULL, callback, user_data);
> +g_task_set_task_data (task,
> +  ctx,
> +  (GDestroyNotify)disconnect_all_context_free);
> +
> +disconnect_next_bearer (task);
>  }
>  
>  
> /*/
> 


-- 
Aleksander
https://aleksander.es
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: ModemManager: symbol lookup error: ModemManager: undefined symbol: mm_kernel_event_properties_get_type

2017-04-06 Thread Aleksander Morgado
On 06/04/17 21:14, Jan Graczyk wrote:
> I am using Quectel UC20 mini PCIe modem on my development board and running 
> ModemManager on it. Since ModemManager is using by default baud rate set to 
> 57600 I have decided to move to the latest version of ModemManager (1.7.0) 
> since there is a possibility to set udev rule for baud rate 
> ENV{ID_MM_TTY_BAUDRATE}="115200". However after rebuilding ModemManager 
> version 1.7.0 for ARM architecture and running it on my development board I 
> have got the following error:
> 
> ModemManager[1624]:  [1491504870.296599] [mm-plugin-manager.c:1609] 
> load_plugins(): [plugin manager] successfully loaded 32 plugins
> ModemManager[1624]:  [1491504870.304070] [main.c:106] 
> name_acquired_cb(): Service name 'org.freedesktop.ModemManager1' was acquired
> ModemManager[1624]:  [1491504870.636683] [mm-base-manager.c:573] 
> mm_base_manager_start(): Starting automatic device scan...
> ModemManager[1624]:  [1491504870.720354] [mm-base-manager.c:575] 
> mm_base_manager_start(): Finished device scan...
> ModemManager: symbol lookup error: ModemManager: undefined symbol: 
> mm_kernel_event_properties_get_type
> 
> [1]+  Exit 127ModemManager -debug
> 
> The only stable version of ModemManager which runs on my development board is 
> 1.4.0. But when using that version I need to set Quectel UC20 modem baud rate 
> to 57600 using AT+IPR=57600 command. I would like to take advantage of 
> ModemManager version 1.7.0 but unfortunately I am getting the above error 
> while running it.

Looks like you didn't install the newly compiled version properly.
You're running the ModemManager daemon from git master, and looks like
it's linking to "libmm-glib" from an older version.

How did you configure ModemManager to build, and how are you running it?

-- 
Aleksander
https://aleksander.es
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [PATCH v3] telit: add error_code recognition to +CSIM parser

2017-04-06 Thread Aleksander Morgado
Hey Carlo,

On 04/04/17 14:55, Carlo Lobrano wrote:
> - Refactored mm_telit_parse_csim_response in order to correctly recognize the
>   following +CSIM error codes:
> 
> * 6300 - Verification failed
> * 6983 - Authentication method blocked
> * 6984 - Reference data invalidated
> * 6A86 - Incorrect parameters
> * 6A88 - Reference data not found
> 
> - Updated correspondent tests.
> - Finally, some minor changes in other files for better error logging
> 
> Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=100374
> 
> ---
> 
> As a side note, I observed that sometimes the modem replies with error
> code
> 
> 6A86 - Incorrect parameters
> 
> when #QSS: 3 has not been received yet. This seems to be a modem's bug
> because the very same request is accepted as correct when issued later,
> namely when the SIM is ready.
> 

See comments inline below.

> ---
>  plugins/telit/mm-broadband-modem-telit.c  |  6 +-
>  plugins/telit/mm-modem-helpers-telit.c| 93 
> ---
>  plugins/telit/mm-modem-helpers-telit.h|  3 +-
>  plugins/telit/tests/test-mm-modem-helpers-telit.c | 72 +-
>  4 files changed, 105 insertions(+), 69 deletions(-)
> 
> diff --git a/plugins/telit/mm-broadband-modem-telit.c 
> b/plugins/telit/mm-broadband-modem-telit.c
> index cce0229..f316e30 100644
> --- a/plugins/telit/mm-broadband-modem-telit.c
> +++ b/plugins/telit/mm-broadband-modem-telit.c
> @@ -541,13 +541,13 @@ csim_query_ready (MMBaseModem *self,
>  response = mm_base_modem_at_command_finish (self, res, );
>  
>  if (!response) {
> -mm_warn ("No respose for step %d: %s", ctx->step, error->message);
> +mm_warn ("load unlock retries: no respose for step %d: %s", 
> ctx->step, error->message);

I don't think we should be printing the "step number", especially not
via warning. This information would be useful if instead we gave the
actual lock name associated to the step, though.

As the csim_query_ready() is being reused for multiple locks, we could
have an array of strings specifying which lock is being processed at
each step, e.g.:

static const gchar *step_lock_names[LOAD_UNLOCK_RETRIES_STEP_LAST] = {
[LOAD_UNLOCK_RETRIES_STEP_PIN] = "PIN",
[LOAD_UNLOCK_RETRIES_STEP_PUK] = "PUK",
[LOAD_UNLOCK_RETRIES_STEP_PIN2] = "PIN2",
[LOAD_UNLOCK_RETRIES_STEP_PUK2] = "PUK2",
};

What do you think? I know this issue was already there, but just spotted
it :) Maybe handled in a separate new patch better?


>  g_error_free (error);
>  goto next_step;
>  }
>  
> -if ( (unlock_retries = mm_telit_parse_csim_response (ctx->step, 
> response, )) < 0) {
> -mm_warn ("Parse error in step %d: %s.", ctx->step, error->message);
> +if ( (unlock_retries = mm_telit_parse_csim_response (response, )) 
> < 0) {
> +mm_warn ("load unlock retries: parse error in step %d: %s.", 
> ctx->step, error->message);

Same here with the step number.

>  g_error_free (error);
>  goto next_step;
>  }
> diff --git a/plugins/telit/mm-modem-helpers-telit.c 
> b/plugins/telit/mm-modem-helpers-telit.c
> index c8c1f4b..cb3ff24 100644
> --- a/plugins/telit/mm-modem-helpers-telit.c
> +++ b/plugins/telit/mm-modem-helpers-telit.c
> @@ -17,6 +17,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #define _LIBMM_INSIDE_MMCLI
> @@ -113,54 +114,92 @@ mm_telit_get_band_flag (GArray *bands_array,
>  
>  
> /*/
>  /* +CSIM response parser */
> +#define MM_TELIT_MIN_SIM_RETRY_HEX 0x63C0
> +#define MM_TELIT_MAX_SIM_RETRY_HEX 0x63CF
>  
>  gint
> -mm_telit_parse_csim_response (const guint step,
> -  const gchar *response,
> +mm_telit_parse_csim_response (const gchar *response,
>GError **error)
>  {
> -GRegex *r = NULL;
>  GMatchInfo *match_info = NULL;
> -gchar *retries_hex_str;
> -guint retries;
> -
> -r = g_regex_new ("\\+CSIM:\\s*[0-9]+,\\s*.*63C(.*)\"", G_REGEX_RAW, 0, 
> NULL);
> +GRegex *r = NULL;
> +gchar *str_code = NULL;
> +gint retries = -1;
> +guint64 hex_code = 0x0;
>  
> +r = g_regex_new ("\\+CSIM:\\s*[0-9]+,\\s*.*([0-9a-fA-F]{4})\"", 
> G_REGEX_RAW, 0, NULL);

The regex is matching the trailing double-quotes; why not the leading
ones as well? E.g.:

"\\+CSIM:\\s*[0-9]+,\\s*\".*([0-9a-fA-F]{4})\""



>  if (!g_regex_match (r, response, 0, _info)) {
>  g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
> - "Could not parse reponse '%s'", response);
> -g_match_info_free (match_info);
> -g_regex_unref (r);
> -return -1;
> + "Could not recognize response '%s'", response);
> +goto out;
>  }
>  
> -if (!g_match_info_matches (match_info)) {
> +if (match_info == NULL || !g_match_info_matches (match_info)) {

match_info 

ModemManager: symbol lookup error: ModemManager: undefined symbol: mm_kernel_event_properties_get_type

2017-04-06 Thread Jan Graczyk
Hello All,

I am using Quectel UC20 mini PCIe modem on my development board and running 
ModemManager on it. Since ModemManager is using by default baud rate set to 
57600 I have decided to move to the latest version of ModemManager (1.7.0) 
since there is a possibility to set udev rule for baud rate 
ENV{ID_MM_TTY_BAUDRATE}="115200". However after rebuilding ModemManager version 
1.7.0 for ARM architecture and running it on my development board I have got 
the following error:

ModemManager[1624]:  [1491504870.296599] [mm-plugin-manager.c:1609] 
load_plugins(): [plugin manager] successfully loaded 32 plugins
ModemManager[1624]:  [1491504870.304070] [main.c:106] 
name_acquired_cb(): Service name 'org.freedesktop.ModemManager1' was acquired
ModemManager[1624]:  [1491504870.636683] [mm-base-manager.c:573] 
mm_base_manager_start(): Starting automatic device scan...
ModemManager[1624]:  [1491504870.720354] [mm-base-manager.c:575] 
mm_base_manager_start(): Finished device scan...
ModemManager: symbol lookup error: ModemManager: undefined symbol: 
mm_kernel_event_properties_get_type

[1]+  Exit 127ModemManager -debug

The only stable version of ModemManager which runs on my development board is 
1.4.0. But when using that version I need to set Quectel UC20 modem baud rate 
to 57600 using AT+IPR=57600 command. I would like to take advantage of 
ModemManager version 1.7.0 but unfortunately I am getting the above error while 
running it.

Best Regards,

Jan Graczyk
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: Porting to GTask: pointer to self in context?

2017-04-06 Thread Dan Williams
On Thu, 2017-04-06 at 20:09 +0200, Aleksander Morgado wrote:
> Hey Ben, Dan and everyone else,
> 
> Related to the ports to GTask sent by Ben...
> 
> When using the GSimpleAsyncResult logic, I usually always added a
> full
> reference to the "source object" of the async operation in the
> "Context" struct, so that I could use it directly, e.g. ctx->self.
> This was really not necessary, because the GSimpleAsyncResult hold
> itself a reference to the "source object", but it was handy because I
> could use the object right away without needing to call
> g_async_result_get_source_object(), which returns a full reference
> (and therefore then I would have needed to unref that one
> explicitly...)
> 
> When using GTask, though, we have  g_task_get_source_object(), which
> doesn't return a full reference.  So, in the GTask implementations
> I've done I've tried to avoid having a full "self" reference in the
> Contexts set as GTask data, and instead I would just pass around the
> GTask in the different callbacks and then just create local variables
> whenever needed like this:
> 
> Context *ctx;
> MMSomeObject *self;
> 
> ctx = g_task_get_task_data (task);
> self = g_task_get_source_object (task);
> 
> Question being, should we still keep the "self" pointer in the
> Context
> struct as we did with GSimpleAsyncResult, or default to just using
> g_task_get_source_object() when/where needed?
> 
> What does everyone think?

I think in the ports I've done, I've tended towards
g_task_get_source_object().  Not everywhere, but most places.

I think ctx->self can be useful if we have a lot of ->self references,
so maybe we default to get_source_object() and then use ->self on a
case-by-case basis?

Dan
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [PATCH 1/2] novatel: port custom init to use GTask

2017-04-06 Thread Ben Chan
On Thu, Apr 6, 2017 at 11:36 AM, Aleksander Morgado
 wrote:
> On 03/04/17 21:37, Ben Chan wrote:
>> ---
>>  plugins/novatel/mm-common-novatel.c | 62 
>> +
>>  1 file changed, 29 insertions(+), 33 deletions(-)
>>
>
> Pushed to git master.
>
> In this case, though, we may have been able to avoid the ctx->probe
> reference, right?

Oh, right. I was fooled by the fact that the variable isn't named
|self| :p   Will upload a fix if no one objects the removal of self
reference in context object for GTask.


>
>> diff --git a/plugins/novatel/mm-common-novatel.c 
>> b/plugins/novatel/mm-common-novatel.c
>> index 4c39c7c7..a8f2da90 100644
>> --- a/plugins/novatel/mm-common-novatel.c
>> +++ b/plugins/novatel/mm-common-novatel.c
>> @@ -22,22 +22,15 @@
>>  typedef struct {
>>  MMPortProbe *probe;
>>  MMPortSerialAt *port;
>> -GCancellable *cancellable;
>> -GSimpleAsyncResult *result;
>>  guint nwdmat_retries;
>>  guint wait_time;
>>  } CustomInitContext;
>>
>>  static void
>> -custom_init_context_complete_and_free (CustomInitContext *ctx)
>> +custom_init_context_free (CustomInitContext *ctx)
>>  {
>> -g_simple_async_result_complete_in_idle (ctx->result);
>> -
>> -if (ctx->cancellable)
>> -g_object_unref (ctx->cancellable);
>>  g_object_unref (ctx->port);
>>  g_object_unref (ctx->probe);
>> -g_object_unref (ctx->result);
>>  g_slice_free (CustomInitContext, ctx);
>>  }
>>
>> @@ -46,15 +39,15 @@ mm_common_novatel_custom_init_finish (MMPortProbe *probe,
>>GAsyncResult *result,
>>GError **error)
>>  {
>> -return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
>> (result), error);
>> +return g_task_propagate_boolean (G_TASK (result), error);
>>  }
>>
>> -static void custom_init_step (CustomInitContext *ctx);
>> +static void custom_init_step (GTask *task);
>>
>>  static void
>>  nwdmat_ready (MMPortSerialAt *port,
>>GAsyncResult *res,
>> -  CustomInitContext *ctx)
>> +  GTask* task)
>>  {
>>  const gchar *response;
>>  GError *error = NULL;
>> @@ -64,7 +57,7 @@ nwdmat_ready (MMPortSerialAt *port,
>>  if (g_error_matches (error,
>>   MM_SERIAL_ERROR,
>>   MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
>> -custom_init_step (ctx);
>> +custom_init_step (task);
>>  goto out;
>>  }
>>
>> @@ -72,8 +65,8 @@ nwdmat_ready (MMPortSerialAt *port,
>>  }
>>
>>  /* Finish custom_init */
>> -g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
>> -custom_init_context_complete_and_free (ctx);
>> +g_task_return_boolean (task, TRUE);
>> +g_object_unref (task);
>>
>>  out:
>>  if (error)
>> @@ -81,21 +74,25 @@ out:
>>  }
>>
>>  static gboolean
>> -custom_init_wait_cb (CustomInitContext *ctx)
>> +custom_init_wait_cb (GTask *task)
>>  {
>> -custom_init_step (ctx);
>> +custom_init_step (task);
>>  return G_SOURCE_REMOVE;
>>  }
>>
>>  static void
>> -custom_init_step (CustomInitContext *ctx)
>> +custom_init_step (GTask *task)
>>  {
>> +CustomInitContext *ctx;
>> +
>> +ctx = g_task_get_task_data (task);
>> +
>>  /* If cancelled, end */
>> -if (g_cancellable_is_cancelled (ctx->cancellable)) {
>> +if (g_cancellable_is_cancelled (g_task_get_cancellable (task))) {
>>  mm_dbg ("(Novatel) no need to keep on running custom init in (%s)",
>>  mm_port_get_device (MM_PORT (ctx->port)));
>> -g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
>> -custom_init_context_complete_and_free (ctx);
>> +g_task_return_boolean (task, TRUE);
>> +g_object_unref (task);
>>  return;
>>  }
>>
>> @@ -103,14 +100,14 @@ custom_init_step (CustomInitContext *ctx)
>>  if (mm_port_probe_list_has_qmi_port (mm_device_peek_port_probe_list 
>> (mm_port_probe_peek_device (ctx->probe {
>>  mm_dbg ("(Novatel) no need to run custom init in (%s): device has 
>> QMI port",
>>  mm_port_get_device (MM_PORT (ctx->port)));
>> -g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
>> -custom_init_context_complete_and_free (ctx);
>> +g_task_return_boolean (task, TRUE);
>> +g_object_unref (task);
>>  return;
>>  }
>>
>>  if (ctx->wait_time > 0) {
>>  ctx->wait_time--;
>> -g_timeout_add_seconds (1, (GSourceFunc)custom_init_wait_cb, ctx);
>> +g_timeout_add_seconds (1, (GSourceFunc)custom_init_wait_cb, task);
>>  return;
>>  }
>>
>> @@ -121,17 +118,17 @@ custom_init_step (CustomInitContext *ctx)
>> 3,
>> FALSE, /* raw */
>> FALSE, /* allow_cached */
>> -  

Re: [PATCH 2/2] novatel: port IMSI loading to use GTask

2017-04-06 Thread Aleksander Morgado
On 03/04/17 21:37, Ben Chan wrote:
> ---
>  plugins/novatel/mm-sim-novatel-lte.c | 89 
> +++-
>  1 file changed, 36 insertions(+), 53 deletions(-)
> 

I love this one! Re-using the "imsi" array in stack as result in the
GSimpleAsyncResult was a bit of a hack, as that only worked as long as
the completion wasn't in idle.

Pushed to git master, thanks!

> diff --git a/plugins/novatel/mm-sim-novatel-lte.c 
> b/plugins/novatel/mm-sim-novatel-lte.c
> index 41d30411..1088d0d0 100644
> --- a/plugins/novatel/mm-sim-novatel-lte.c
> +++ b/plugins/novatel/mm-sim-novatel-lte.c
> @@ -39,20 +39,13 @@ load_imsi_finish (MMBaseSim *self,
>GAsyncResult *res,
>GError **error)
>  {
> -gchar *imsi;
> -
> -if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), 
> error))
> -return NULL;
> -
> -imsi = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT 
> (res));
> -mm_dbg ("loaded IMSI: %s", imsi);
> -return g_strdup (imsi);
> +return g_task_propagate_pointer (G_TASK (res), error);
>  }
>  
>  static void
>  imsi_read_ready (MMBaseModem *modem,
>   GAsyncResult *res,
> - GSimpleAsyncResult *simple)
> + GTask *task)
>  {
>  GError *error = NULL;
>  const gchar *response, *str;
> @@ -64,9 +57,8 @@ imsi_read_ready (MMBaseModem *modem,
>  
>  response = mm_base_modem_at_command_finish (modem, res, );
>  if (!response) {
> -g_simple_async_result_take_error (simple, error);
> -g_simple_async_result_complete (simple);
> -g_object_unref (simple);
> +g_task_return_error (task, error);
> +g_object_unref (task);
>  return;
>  }
>  
> @@ -76,13 +68,12 @@ imsi_read_ready (MMBaseModem *modem,
>  /* With or without quotes... */
>  if (sscanf (str, "%d,%d,\"%18c\"", , , (char *) ) != 3 &&
>  sscanf (str, "%d,%d,%18c", , , (char *) ) != 3) {
> -g_simple_async_result_set_error (simple,
> - MM_CORE_ERROR,
> - MM_CORE_ERROR_FAILED,
> - "Failed to parse the CRSM response: 
> '%s'",
> - response);
> -g_simple_async_result_complete (simple);
> -g_object_unref (simple);
> +g_task_return_new_error (task,
> + MM_CORE_ERROR,
> + MM_CORE_ERROR_FAILED,
> + "Failed to parse the CRSM response: '%s'",
> + response);
> +g_object_unref (task);
>  return;
>  }
>  
> @@ -90,13 +81,12 @@ imsi_read_ready (MMBaseModem *modem,
>  (sw1 != 0x91) &&
>  (sw1 != 0x92) &&
>  (sw1 != 0x9f)) {
> -g_simple_async_result_set_error (simple,
> - MM_CORE_ERROR,
> - MM_CORE_ERROR_FAILED,
> - "SIM failed to handle CRSM request 
> (sw1 %d sw2 %d)",
> - sw1, sw2);
> -g_simple_async_result_complete (simple);
> -g_object_unref (simple);
> +g_task_return_new_error (task,
> + MM_CORE_ERROR,
> + MM_CORE_ERROR_FAILED,
> + "SIM failed to handle CRSM request (sw1 %d 
> sw2 %d)",
> + sw1, sw2);
> +g_object_unref (task);
>  return;
>  }
>  
> @@ -114,25 +104,23 @@ imsi_read_ready (MMBaseModem *modem,
>  }
>  
>  /* Invalid character */
> -g_simple_async_result_set_error (simple,
> - MM_CORE_ERROR,
> - MM_CORE_ERROR_FAILED,
> - "CRSM IMSI response contained 
> invalid character '%c'",
> - buf[len]);
> -g_simple_async_result_complete (simple);
> -g_object_unref (simple);
> +g_task_return_new_error (task,
> + MM_CORE_ERROR,
> + MM_CORE_ERROR_FAILED,
> + "CRSM IMSI response contained invalid 
> character '%c'",
> + buf[len]);
> +g_object_unref (task);
>  return;
>  }
>  
>  /* BCD encoded IMSIs plus the length byte and parity are 18 digits long 
> */
>  if (len != 18) {
> -g_simple_async_result_set_error (simple,
> - MM_CORE_ERROR,
> - MM_CORE_ERROR_FAILED,
> - "Invalid +CRSM IMSI response size 
> (was %zd, expected 18)",
> -

Re: [PATCH 1/2] novatel: port custom init to use GTask

2017-04-06 Thread Aleksander Morgado
On 03/04/17 21:37, Ben Chan wrote:
> ---
>  plugins/novatel/mm-common-novatel.c | 62 
> +
>  1 file changed, 29 insertions(+), 33 deletions(-)
> 

Pushed to git master.

In this case, though, we may have been able to avoid the ctx->probe
reference, right?

> diff --git a/plugins/novatel/mm-common-novatel.c 
> b/plugins/novatel/mm-common-novatel.c
> index 4c39c7c7..a8f2da90 100644
> --- a/plugins/novatel/mm-common-novatel.c
> +++ b/plugins/novatel/mm-common-novatel.c
> @@ -22,22 +22,15 @@
>  typedef struct {
>  MMPortProbe *probe;
>  MMPortSerialAt *port;
> -GCancellable *cancellable;
> -GSimpleAsyncResult *result;
>  guint nwdmat_retries;
>  guint wait_time;
>  } CustomInitContext;
>  
>  static void
> -custom_init_context_complete_and_free (CustomInitContext *ctx)
> +custom_init_context_free (CustomInitContext *ctx)
>  {
> -g_simple_async_result_complete_in_idle (ctx->result);
> -
> -if (ctx->cancellable)
> -g_object_unref (ctx->cancellable);
>  g_object_unref (ctx->port);
>  g_object_unref (ctx->probe);
> -g_object_unref (ctx->result);
>  g_slice_free (CustomInitContext, ctx);
>  }
>  
> @@ -46,15 +39,15 @@ mm_common_novatel_custom_init_finish (MMPortProbe *probe,
>GAsyncResult *result,
>GError **error)
>  {
> -return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
> (result), error);
> +return g_task_propagate_boolean (G_TASK (result), error);
>  }
>  
> -static void custom_init_step (CustomInitContext *ctx);
> +static void custom_init_step (GTask *task);
>  
>  static void
>  nwdmat_ready (MMPortSerialAt *port,
>GAsyncResult *res,
> -  CustomInitContext *ctx)
> +  GTask* task)
>  {
>  const gchar *response;
>  GError *error = NULL;
> @@ -64,7 +57,7 @@ nwdmat_ready (MMPortSerialAt *port,
>  if (g_error_matches (error,
>   MM_SERIAL_ERROR,
>   MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
> -custom_init_step (ctx);
> +custom_init_step (task);
>  goto out;
>  }
>  
> @@ -72,8 +65,8 @@ nwdmat_ready (MMPortSerialAt *port,
>  }
>  
>  /* Finish custom_init */
> -g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
> -custom_init_context_complete_and_free (ctx);
> +g_task_return_boolean (task, TRUE);
> +g_object_unref (task);
>  
>  out:
>  if (error)
> @@ -81,21 +74,25 @@ out:
>  }
>  
>  static gboolean
> -custom_init_wait_cb (CustomInitContext *ctx)
> +custom_init_wait_cb (GTask *task)
>  {
> -custom_init_step (ctx);
> +custom_init_step (task);
>  return G_SOURCE_REMOVE;
>  }
>  
>  static void
> -custom_init_step (CustomInitContext *ctx)
> +custom_init_step (GTask *task)
>  {
> +CustomInitContext *ctx;
> +
> +ctx = g_task_get_task_data (task);
> +
>  /* If cancelled, end */
> -if (g_cancellable_is_cancelled (ctx->cancellable)) {
> +if (g_cancellable_is_cancelled (g_task_get_cancellable (task))) {
>  mm_dbg ("(Novatel) no need to keep on running custom init in (%s)",
>  mm_port_get_device (MM_PORT (ctx->port)));
> -g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
> -custom_init_context_complete_and_free (ctx);
> +g_task_return_boolean (task, TRUE);
> +g_object_unref (task);
>  return;
>  }
>  
> @@ -103,14 +100,14 @@ custom_init_step (CustomInitContext *ctx)
>  if (mm_port_probe_list_has_qmi_port (mm_device_peek_port_probe_list 
> (mm_port_probe_peek_device (ctx->probe {
>  mm_dbg ("(Novatel) no need to run custom init in (%s): device has 
> QMI port",
>  mm_port_get_device (MM_PORT (ctx->port)));
> -g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
> -custom_init_context_complete_and_free (ctx);
> +g_task_return_boolean (task, TRUE);
> +g_object_unref (task);
>  return;
>  }
>  
>  if (ctx->wait_time > 0) {
>  ctx->wait_time--;
> -g_timeout_add_seconds (1, (GSourceFunc)custom_init_wait_cb, ctx);
> +g_timeout_add_seconds (1, (GSourceFunc)custom_init_wait_cb, task);
>  return;
>  }
>  
> @@ -121,17 +118,17 @@ custom_init_step (CustomInitContext *ctx)
> 3,
> FALSE, /* raw */
> FALSE, /* allow_cached */
> -   ctx->cancellable,
> +   g_task_get_cancellable (task),
> (GAsyncReadyCallback)nwdmat_ready,
> -   ctx);
> +   task);
>  return;
>  }
>  
>  /* Finish custom_init */
>  mm_dbg ("(Novatel) couldn't flip 

Re: [PATCH] base-modem: port mm_base_modem_authorize to use GTask

2017-04-06 Thread Aleksander Morgado
On 04/04/17 08:37, Ben Chan wrote:
> ---
>  src/mm-base-modem.c | 25 ++---
>  1 file changed, 10 insertions(+), 15 deletions(-)
> 

Pushed to git master, thanks!

> diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
> index 430ce59d..76286f6b 100644
> --- a/src/mm-base-modem.c
> +++ b/src/mm-base-modem.c
> @@ -1172,23 +1172,22 @@ mm_base_modem_authorize_finish (MMBaseModem *self,
>  GAsyncResult *res,
>  GError **error)
>  {
> -return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT 
> (res), error);
> +return g_task_propagate_boolean (G_TASK (res), error);
>  }
>  
>  static void
>  authorize_ready (MMAuthProvider *authp,
>   GAsyncResult *res,
> - GSimpleAsyncResult *simple)
> + GTask *task)
>  {
>  GError *error = NULL;
>  
>  if (!mm_auth_provider_authorize_finish (authp, res, ))
> -g_simple_async_result_take_error (simple, error);
> +g_task_return_error (task, error);
>  else
> -g_simple_async_result_set_op_res_gboolean (simple, TRUE);
> +g_task_return_boolean (task, TRUE);
>  
> -g_simple_async_result_complete (simple);
> -g_object_unref (simple);
> +g_object_unref (task);
>  }
>  
>  void
> @@ -1198,18 +1197,14 @@ mm_base_modem_authorize (MMBaseModem *self,
>   GAsyncReadyCallback callback,
>   gpointer user_data)
>  {
> -GSimpleAsyncResult *result;
> +GTask *task;
>  
> -result = g_simple_async_result_new (G_OBJECT (self),
> -callback,
> -user_data,
> -mm_base_modem_authorize);
> +task = g_task_new (self, self->priv->authp_cancellable, callback, 
> user_data);
>  
>  /* When running in the session bus for tests, default to always allow */
>  if (mm_context_get_test_session ()) {
> -g_simple_async_result_set_op_res_gboolean (result, TRUE);
> -g_simple_async_result_complete_in_idle (result);
> -g_object_unref (result);
> +g_task_return_boolean (task, TRUE);
> +g_object_unref (task);
>  return;
>  }
>  
> @@ -1218,7 +1213,7 @@ mm_base_modem_authorize (MMBaseModem *self,
>  authorization,
>  self->priv->authp_cancellable,
>  (GAsyncReadyCallback)authorize_ready,
> -result);
> +task);
>  }
>  
>  
> /*/
> 


-- 
Aleksander
https://aleksander.es
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [PATCH] telit: unsupported CSIM lock should not skip loading unlock retries

2017-04-06 Thread Aleksander Morgado
On 06/04/17 14:37, Carlo Lobrano wrote:
> Some modems do not support CSIM lock/unlock, but they do support
> querying SIM unlock retries through +CSIM command.
> 
> If CSIM lock returns with "unsupported command" do not propagate
> the error and continue with the other CSIM queries instead.
> ---
> 
> Sorry for not having caught this problem earlier,
> when reviewing the CSIM lock patch.
> 

Yes, this is a good logic change that we should have done...

How about we store the "not supported" information somewhere, like e.g.
in a "FeatureSupport" enum value as we do in Huawei for other things:
https://cgit.freedesktop.org/ModemManager/ModemManager/tree/plugins/huawei/mm-broadband-modem-huawei.c#n79

i.e. when the object is created:
  self->priv->csim_lock_supported = FEATURE_SUPPORT_UNKNOWN;

Them, after the first time we try the CSIM lock operation, we store the
proper result (e.g. FEATURE_NOT_SUPPORTED or FEATURE_SUPPORTED).

Then, the next time we are going to do a CSIM lock (or unlock)
operation, we check whether the feature is supported or not, and if it
isn't, we just ignore the operation right away.

What do you think? This would help to also avoid trying the CSIM unlock
operation if we already know CSIM lock is unsupported.


> ---
> 
>  plugins/telit/mm-broadband-modem-telit.c | 15 +++
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/plugins/telit/mm-broadband-modem-telit.c 
> b/plugins/telit/mm-broadband-modem-telit.c
> index cce0229..3680a8a 100644
> --- a/plugins/telit/mm-broadband-modem-telit.c
> +++ b/plugins/telit/mm-broadband-modem-telit.c
> @@ -591,10 +591,17 @@ csim_lock_ready (MMBaseModem  *self,
>  
>  response = mm_base_modem_at_command_finish (self, res, );
>  if (!response) {
> -g_prefix_error (, "Couldn't lock SIM card: ");
> -g_simple_async_result_take_error (ctx->result, error);
> -load_unlock_retries_context_complete_and_free (ctx);
> -return;
> +if (g_error_matches (error,
> + MM_MOBILE_EQUIPMENT_ERROR,
> + MM_MOBILE_EQUIPMENT_ERROR_NOT_SUPPORTED)) {
> +mm_warn ("Couldn't lock SIM card: %s. Continuing as well...", 
> error->message);
> +g_error_free (error);
> +} else {
> +g_prefix_error (, "Couldn't lock SIM card: ");
> +g_simple_async_result_take_error (ctx->result, error);
> +load_unlock_retries_context_complete_and_free (ctx);
> +return;
> +}
>  }
>  
>  ctx->step++;
> 


-- 
Aleksander
https://aleksander.es
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: Porting to GTask: pointer to self in context?

2017-04-06 Thread Ben Chan
On Thu, Apr 6, 2017 at 11:09 AM, Aleksander Morgado
 wrote:
> Hey Ben, Dan and everyone else,
>
> Related to the ports to GTask sent by Ben...
>
> When using the GSimpleAsyncResult logic, I usually always added a full
> reference to the "source object" of the async operation in the
> "Context" struct, so that I could use it directly, e.g. ctx->self.
> This was really not necessary, because the GSimpleAsyncResult hold
> itself a reference to the "source object", but it was handy because I
> could use the object right away without needing to call
> g_async_result_get_source_object(), which returns a full reference
> (and therefore then I would have needed to unref that one
> explicitly...)
>
> When using GTask, though, we have  g_task_get_source_object(), which
> doesn't return a full reference.  So, in the GTask implementations
> I've done I've tried to avoid having a full "self" reference in the
> Contexts set as GTask data, and instead I would just pass around the
> GTask in the different callbacks and then just create local variables
> whenever needed like this:
>
> Context *ctx;
> MMSomeObject *self;
>
> ctx = g_task_get_task_data (task);
> self = g_task_get_source_object (task);
>
> Question being, should we still keep the "self" pointer in the Context
> struct as we did with GSimpleAsyncResult, or default to just using
> g_task_get_source_object() when/where needed?
>
> What does everyone think?

Yep, I noticed that as well and though the self reference isn't
necessary. During my porting, I remove the ctx->self and simply use
g_task_get_source_object(). In some cases, that removes the need to
have a context struct as well.


>
> --
> Aleksander
> https://aleksander.es
> ___
> ModemManager-devel mailing list
> ModemManager-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: [PATCH] novatel-lte: revert to original plugin library name

2017-04-06 Thread Aleksander Morgado
On 03/04/17 23:16, Dan Williams wrote:
> On Mon, 2017-04-03 at 13:05 -0700, Ben Chan wrote:
>> Commit f9c63bfa0 "build,plugins: update build rules" accidentally
>> changed the Novatel LTE plugin from 'libmm-plugins-novatel-lte.so' to
>> 'libmm-plugins-novatel_lte.so'. The name becomes inconsistent with
>> other
>> plugin names.
> 
> Seems fine to me.
> 
> Dan
> 

Pushed to git master, thanks!

>> ---
>> It probably doesn't matter how the plugin library is named, but the
>> original
>> name is preferred for consistency.
>>
>> Ben
>>
>>  plugins/Makefile.am | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/plugins/Makefile.am b/plugins/Makefile.am
>> index 596866b7..2a4ff2b6 100644
>> --- a/plugins/Makefile.am
>> +++ b/plugins/Makefile.am
>> @@ -720,7 +720,7 @@ libmm_plugin_thuraya_la_LIBADD   =
>> $(builddir)/libhelpers-thuraya.la
>>  # plugin: novatel lte
>>  
>> 
>>  
>> -pkglib_LTLIBRARIES += libmm-plugin-novatel_lte.la
>> +pkglib_LTLIBRARIES += libmm-plugin-novatel-lte.la
>>  libmm_plugin_novatel_lte_la_SOURCES = \
>>  novatel/mm-plugin-novatel-lte.c \
>>  novatel/mm-plugin-novatel-lte.h \


-- 
Aleksander
https://aleksander.es
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Porting to GTask: pointer to self in context?

2017-04-06 Thread Aleksander Morgado
Hey Ben, Dan and everyone else,

Related to the ports to GTask sent by Ben...

When using the GSimpleAsyncResult logic, I usually always added a full
reference to the "source object" of the async operation in the
"Context" struct, so that I could use it directly, e.g. ctx->self.
This was really not necessary, because the GSimpleAsyncResult hold
itself a reference to the "source object", but it was handy because I
could use the object right away without needing to call
g_async_result_get_source_object(), which returns a full reference
(and therefore then I would have needed to unref that one
explicitly...)

When using GTask, though, we have  g_task_get_source_object(), which
doesn't return a full reference.  So, in the GTask implementations
I've done I've tried to avoid having a full "self" reference in the
Contexts set as GTask data, and instead I would just pass around the
GTask in the different callbacks and then just create local variables
whenever needed like this:

Context *ctx;
MMSomeObject *self;

ctx = g_task_get_task_data (task);
self = g_task_get_source_object (task);

Question being, should we still keep the "self" pointer in the Context
struct as we did with GSimpleAsyncResult, or default to just using
g_task_get_source_object() when/where needed?

What does everyone think?

-- 
Aleksander
https://aleksander.es
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


Re: Failed to find primary AT port

2017-04-06 Thread Aleksander Morgado
On Thu, Apr 6, 2017 at 12:39 AM, Jan Graczyk  wrote:
> Thank you for your response. I have looked into ModemManager version 1.6.4 
> and this patch you are mentioning in your e-mail does not reflect the line 
> number in src/mm-base-modem.c:
>
> @@ -219,6 +219,12 @@ mm_base_modem_grab_port (MMBaseModem *self,
>"timed-out",
>G_CALLBACK (serial_port_timed_out_cb),
>self);
> +
> +/* For serial ports, optionally use a specific baudrate */
> +if (mm_kernel_device_has_property (kernel_device, 
> "ID_MM_TTY_BAUDRATE"))
> +g_object_set (port,
> +  MM_PORT_SERIAL_BAUD, 
> mm_kernel_device_get_property_as_int (kernel_device, "ID_MM_TTY_BAUDRATE"),
> +  NULL);
>  }
>  /* Net ports... */
>  else if (g_str_equal (subsys, "net")) {
>
> I also have built ModemManager1.6.4 for ARM architecture and run on my 
> development board. However I am getting the following error:
>
> ModemManager[1631]:  [1491431437.689341] [mm-plugin.c:804] 
> mm_plugin_supports_port(): (Generic) [ttymxc2] probe required: 'at, qcdm'
> ModemManager[1631]:  [1491431437.689422] [mm-port-probe.c:1376] 
> mm_port_probe_run(): (tty/ttymxc2) port probing finished: no more probings 
> needed
> ModemManager[1631]:  [1491431437.689575] [mm-plugin-manager.c:283] 
> port_context_supported(): [plugin manager] task 0,ttymxc2: found best plugin 
> for port (Generic)
> ModemManager[1631]:  [1491431437.689678] [mm-plugin-manager.c:265] 
> port_context_complete(): [plugin manager] task 0,ttymxc2: finished in 
> '10.416165' seconds
> ModemManager[1631]:  [1491431437.690192] [mm-plugin-manager.c:979] 
> device_context_continue(): [plugin manager] task 0: no more ports to probe
> ModemManager[1631]:  [1491431437.690297] [mm-plugin-manager.c:813] 
> device_context_complete(): [plugin manager] task 0: finished in '10.417578' 
> seconds
> ModemManager[1631]:   [1491431437.690453] [mm-device.c:525] 
> mm_device_create_modem(): Creating modem with plugin 'Generic' and '1' ports
> ModemManager: symbol lookup error: ModemManager: undefined symbol: 
> mm_gdbus_modem_voice_skeleton_get_type
>
> Could you tell me which version of ModemManager I should use?

If you want to configure baudrate via udev rules, you should use
ModemManager from git master. Or, default to 57600bps in the modem.

But, as Dan said in a couple of emails back, this modem should be
running in QMI mode, and therefore controlled via cdc-wdm port and
with data connection over a WWAN port. If this is a custom system
you're preparing, you should check your build and see why the qmi_wwan
or cdc-wdm kernel modules aren't being built or used.

-- 
Aleksander
https://aleksander.es
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel