sms-qmi: port to use object logging

This commit is contained in:
Aleksander Morgado
2020-03-31 07:32:00 +02:00
parent 0e05d0dcf0
commit cc1bb544ee

View File

@@ -31,7 +31,7 @@
#include "mm-base-modem.h" #include "mm-base-modem.h"
#include "mm-sms-part-3gpp.h" #include "mm-sms-part-3gpp.h"
#include "mm-sms-part-cdma.h" #include "mm-sms-part-cdma.h"
#include "mm-log.h" #include "mm-log-object.h"
G_DEFINE_TYPE (MMSmsQmi, mm_sms_qmi, MM_TYPE_BASE_SMS) G_DEFINE_TYPE (MMSmsQmi, mm_sms_qmi, MM_TYPE_BASE_SMS)
@@ -329,11 +329,14 @@ send_generic_ready (QmiClientWms *client,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMSmsQmi *self;
SmsSendContext *ctx; SmsSendContext *ctx;
QmiMessageWmsRawSendOutput *output = NULL; QmiMessageWmsRawSendOutput *output = NULL;
GError *error = NULL; GError *error = NULL;
guint16 message_id; guint16 message_id;
self = g_task_get_source_object (task);
output = qmi_client_wms_raw_send_finish (client, res, &error); output = qmi_client_wms_raw_send_finish (client, res, &error);
if (!output) { if (!output) {
g_prefix_error (&error, "QMI operation failed: "); g_prefix_error (&error, "QMI operation failed: ");
@@ -351,11 +354,11 @@ send_generic_ready (QmiClientWms *client,
&rp_cause, &rp_cause,
&tp_cause, &tp_cause,
NULL)) { NULL)) {
mm_warn ("Couldn't send SMS; RP cause (%u): '%s'; TP cause (%u): '%s'", mm_obj_warn (self, "couldn't send SMS; RP cause (%u): %s; TP cause (%u): %s",
rp_cause, rp_cause,
qmi_wms_gsm_umts_rp_cause_get_string (rp_cause), qmi_wms_gsm_umts_rp_cause_get_string (rp_cause),
tp_cause, tp_cause,
qmi_wms_gsm_umts_tp_cause_get_string (tp_cause)); qmi_wms_gsm_umts_tp_cause_get_string (tp_cause));
} }
qmi_message_wms_raw_send_output_unref (output); qmi_message_wms_raw_send_output_unref (output);
@@ -442,11 +445,13 @@ send_from_storage_ready (QmiClientWms *client,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMSmsQmi *self;
SmsSendContext *ctx; SmsSendContext *ctx;
QmiMessageWmsSendFromMemoryStorageOutput *output = NULL; QmiMessageWmsSendFromMemoryStorageOutput *output = NULL;
GError *error = NULL; GError *error = NULL;
guint16 message_id; guint16 message_id;
self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
output = qmi_client_wms_send_from_memory_storage_finish (client, res, &error); output = qmi_client_wms_send_from_memory_storage_finish (client, res, &error);
@@ -454,8 +459,7 @@ send_from_storage_ready (QmiClientWms *client,
if (g_error_matches (error, if (g_error_matches (error,
QMI_CORE_ERROR, QMI_CORE_ERROR,
QMI_CORE_ERROR_UNSUPPORTED)) { QMI_CORE_ERROR_UNSUPPORTED)) {
mm_dbg ("Couldn't send SMS from storage: '%s'; trying generic send...", mm_obj_dbg (self, "couldn't send SMS from storage: %s; trying generic send...", error->message);
error->message);
g_error_free (error); g_error_free (error);
ctx->from_storage = FALSE; ctx->from_storage = FALSE;
sms_send_next_part (task); sms_send_next_part (task);
@@ -473,8 +477,7 @@ send_from_storage_ready (QmiClientWms *client,
if (g_error_matches (error, if (g_error_matches (error,
QMI_PROTOCOL_ERROR, QMI_PROTOCOL_ERROR,
QMI_PROTOCOL_ERROR_INVALID_QMI_COMMAND)) { QMI_PROTOCOL_ERROR_INVALID_QMI_COMMAND)) {
mm_dbg ("Couldn't send SMS from storage: '%s'; trying generic send...", mm_obj_dbg (self, "couldn't send SMS from storage: %s; trying generic send...", error->message);
error->message);
g_error_free (error); g_error_free (error);
ctx->from_storage = FALSE; ctx->from_storage = FALSE;
sms_send_next_part (task); sms_send_next_part (task);
@@ -489,29 +492,29 @@ send_from_storage_ready (QmiClientWms *client,
&rp_cause, &rp_cause,
&tp_cause, &tp_cause,
NULL)) { NULL)) {
mm_warn ("Couldn't send SMS; RP cause (%u): '%s'; TP cause (%u): '%s'", mm_obj_warn (self, "couldn't send SMS; RP cause (%u): %s; TP cause (%u): %s",
rp_cause, rp_cause,
qmi_wms_gsm_umts_rp_cause_get_string (rp_cause), qmi_wms_gsm_umts_rp_cause_get_string (rp_cause),
tp_cause, tp_cause,
qmi_wms_gsm_umts_tp_cause_get_string (tp_cause)); qmi_wms_gsm_umts_tp_cause_get_string (tp_cause));
} }
if (qmi_message_wms_send_from_memory_storage_output_get_cdma_cause_code ( if (qmi_message_wms_send_from_memory_storage_output_get_cdma_cause_code (
output, output,
&cdma_cause_code, &cdma_cause_code,
NULL)) { NULL)) {
mm_warn ("Couldn't send SMS; cause code (%u): '%s'", mm_obj_warn (self, "couldn't send SMS; cause code (%u): %s",
cdma_cause_code, cdma_cause_code,
qmi_wms_cdma_cause_code_get_string (cdma_cause_code)); qmi_wms_cdma_cause_code_get_string (cdma_cause_code));
} }
if (qmi_message_wms_send_from_memory_storage_output_get_cdma_error_class ( if (qmi_message_wms_send_from_memory_storage_output_get_cdma_error_class (
output, output,
&cdma_error_class, &cdma_error_class,
NULL)) { NULL)) {
mm_warn ("Couldn't send SMS; error class (%u): '%s'", mm_obj_warn (self, "couldn't send SMS; error class (%u): %s",
cdma_error_class, cdma_error_class,
qmi_wms_cdma_error_class_get_string (cdma_error_class)); qmi_wms_cdma_error_class_get_string (cdma_error_class));
} }
g_prefix_error (&error, "Couldn't write SMS part: "); g_prefix_error (&error, "Couldn't write SMS part: ");
@@ -658,24 +661,26 @@ delete_part_ready (QmiClientWms *client,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMSmsQmi *self;
SmsDeletePartsContext *ctx; SmsDeletePartsContext *ctx;
QmiMessageWmsDeleteOutput *output = NULL; QmiMessageWmsDeleteOutput *output = NULL;
GError *error = NULL; GError *error = NULL;
self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
output = qmi_client_wms_delete_finish (client, res, &error); output = qmi_client_wms_delete_finish (client, res, &error);
if (!output) { if (!output) {
ctx->n_failed++; ctx->n_failed++;
mm_dbg ("QMI operation failed: Couldn't delete SMS part with index %u: '%s'", mm_obj_dbg (self, "QMI operation failed: couldn't delete SMS part with index %u: %s",
mm_sms_part_get_index ((MMSmsPart *)ctx->current->data), mm_sms_part_get_index ((MMSmsPart *)ctx->current->data),
error->message); error->message);
g_error_free (error); g_error_free (error);
} else if (!qmi_message_wms_delete_output_get_result (output, &error)) { } else if (!qmi_message_wms_delete_output_get_result (output, &error)) {
ctx->n_failed++; ctx->n_failed++;
mm_dbg ("Couldn't delete SMS part with index %u: '%s'", mm_obj_dbg (self, "couldn't delete SMS part with index %u: %s",
mm_sms_part_get_index ((MMSmsPart *)ctx->current->data), mm_sms_part_get_index ((MMSmsPart *)ctx->current->data),
error->message); error->message);
g_error_free (error); g_error_free (error);
} }