aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-04-04 15:23:19 +0200
committerAleksander Morgado <aleksander@aleksander.es>2020-04-08 16:35:09 +0200
commit261ba90d088e6e7b6c4c628b4fd02267111cc7ae (patch)
tree81e449a696931fb3d9d6bc19b807cfa805f2e2be
parentfe4b8f6817490763103b0b52ec19a0173ea13537 (diff)
cinterion: port to use object logging
-rw-r--r--plugins/cinterion/mm-broadband-bearer-cinterion.c69
-rw-r--r--plugins/cinterion/mm-broadband-modem-cinterion.c91
-rw-r--r--plugins/cinterion/mm-modem-helpers-cinterion.c21
-rw-r--r--plugins/cinterion/mm-modem-helpers-cinterion.h5
-rw-r--r--plugins/cinterion/mm-plugin-cinterion.c16
-rw-r--r--plugins/cinterion/mm-shared-cinterion.c146
-rw-r--r--plugins/cinterion/tests/test-modem-helpers-cinterion.c8
7 files changed, 164 insertions, 192 deletions
diff --git a/plugins/cinterion/mm-broadband-bearer-cinterion.c b/plugins/cinterion/mm-broadband-bearer-cinterion.c
index 5c893b69..2f895efb 100644
--- a/plugins/cinterion/mm-broadband-bearer-cinterion.c
+++ b/plugins/cinterion/mm-broadband-bearer-cinterion.c
@@ -24,7 +24,7 @@
#include <ModemManager.h>
#include "mm-base-modem-at.h"
#include "mm-broadband-bearer-cinterion.h"
-#include "mm-log.h"
+#include "mm-log-object.h"
#include "mm-modem-helpers.h"
#include "mm-modem-helpers-cinterion.h"
#include "mm-daemon-enums-types.h"
@@ -101,11 +101,13 @@ swwan_check_status_ready (MMBaseModem *modem,
GAsyncResult *res,
GTask *task)
{
- const gchar *response;
- GError *error = NULL;
- MMBearerConnectionStatus status;
- guint cid;
+ MMBroadbandBearerCinterion *self;
+ const gchar *response;
+ GError *error = NULL;
+ MMBearerConnectionStatus status;
+ guint cid;
+ self = g_task_get_source_object (task);
cid = GPOINTER_TO_UINT (g_task_get_task_data (task));
response = mm_base_modem_at_command_finish (modem, res, &error);
@@ -114,7 +116,7 @@ swwan_check_status_ready (MMBaseModem *modem,
goto out;
}
- status = mm_cinterion_parse_swwan_response (response, cid, &error);
+ status = mm_cinterion_parse_swwan_response (response, cid, self, &error);
if (status == MM_BEARER_CONNECTION_STATUS_UNKNOWN) {
g_task_return_error (task, error);
goto out;
@@ -197,8 +199,9 @@ parse_auth_type (MMBearerAllowedAuth mm_auth)
/* AT^SGAUTH=<cid>[, <auth_type>[, <passwd>, <user>]] */
static gchar *
-build_auth_string (MMBearerProperties *config,
- guint cid)
+build_auth_string (MMBroadbandBearerCinterion *self,
+ MMBearerProperties *config,
+ guint cid)
{
const gchar *user;
const gchar *passwd;
@@ -218,7 +221,7 @@ build_auth_string (MMBearerProperties *config,
/* When 'none' requested, we won't require user/password */
if (encoded_auth == BEARER_CINTERION_AUTH_NONE) {
if (has_user || has_passwd)
- mm_warn ("APN user/password given but 'none' authentication requested");
+ mm_obj_warn (self, "APN user/password given but 'none' authentication requested");
return g_strdup_printf ("^SGAUTH=%u,%d", cid, encoded_auth);
}
@@ -229,7 +232,7 @@ build_auth_string (MMBearerProperties *config,
return NULL;
/* If user/passwd given, default to PAP */
- mm_dbg ("APN user/password given but no authentication type explicitly requested: defaulting to 'PAP'");
+ mm_obj_dbg (self, "APN user/password given but no authentication type explicitly requested: defaulting to 'PAP'");
encoded_auth = BEARER_CINTERION_AUTH_PAP;
}
@@ -356,9 +359,11 @@ handle_cancel_dial (GTask *task)
static void
dial_3gpp_context_step (GTask *task)
{
- Dial3gppContext *ctx;
+ MMBroadbandBearerCinterion *self;
+ Dial3gppContext *ctx;
- ctx = (Dial3gppContext *) g_task_get_task_data (task);
+ self = g_task_get_source_object (task);
+ ctx = g_task_get_task_data (task);
/* Check for cancellation */
if (g_task_return_error_if_cancelled (task)) {
@@ -378,7 +383,7 @@ dial_3gpp_context_step (GTask *task)
ip_family = mm_base_bearer_get_default_ip_family (MM_BASE_BEARER (ctx->self));
ip_family_str = mm_bearer_ip_family_build_string_from_mask (ip_family);
- mm_dbg ("No specific IP family requested, defaulting to %s", ip_family_str);
+ mm_obj_dbg (self, "no specific IP family requested, defaulting to %s", ip_family_str);
g_free (ip_family_str);
}
@@ -395,9 +400,9 @@ dial_3gpp_context_step (GTask *task)
case DIAL_3GPP_CONTEXT_STEP_AUTH: {
gchar *command;
- command = build_auth_string (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self)), ctx->cid);
+ command = build_auth_string (self, mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self)), ctx->cid);
if (command) {
- mm_dbg ("cinterion dial step %u/%u: authenticating...", ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST);
+ mm_obj_dbg (self, "cinterion dial step %u/%u: authenticating...", ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST);
/* Send SGAUTH write, if User & Pass are provided.
* advance to next state by callback */
mm_base_modem_at_command_full (ctx->modem,
@@ -413,15 +418,15 @@ dial_3gpp_context_step (GTask *task)
return;
}
- mm_dbg ("cinterion dial step %u/%u: authentication not required", ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST);
+ mm_obj_dbg (self, "cinterion dial step %u/%u: authentication not required", ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST);
ctx->step++;
} /* fall through */
case DIAL_3GPP_CONTEXT_STEP_START_SWWAN: {
gchar *command;
- mm_dbg ("cinterion dial step %u/%u: starting SWWAN interface %u connection...",
- ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST, usb_interface_configs[ctx->usb_interface_config_index].swwan_index);
+ mm_obj_dbg (self, "cinterion dial step %u/%u: starting SWWAN interface %u connection...",
+ ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST, usb_interface_configs[ctx->usb_interface_config_index].swwan_index);
command = g_strdup_printf ("^SWWAN=1,%u,%u",
ctx->cid,
usb_interface_configs[ctx->usb_interface_config_index].swwan_index);
@@ -439,8 +444,8 @@ dial_3gpp_context_step (GTask *task)
}
case DIAL_3GPP_CONTEXT_STEP_VALIDATE_CONNECTION:
- mm_dbg ("cinterion dial step %u/%u: checking SWWAN interface %u status...",
- ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST, usb_interface_configs[ctx->usb_interface_config_index].swwan_index);
+ mm_obj_dbg (self, "cinterion dial step %u/%u: checking SWWAN interface %u status...",
+ ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST, usb_interface_configs[ctx->usb_interface_config_index].swwan_index);
load_connection_status_by_cid (ctx->self,
ctx->cid,
(GAsyncReadyCallback) dial_connection_status_ready,
@@ -448,7 +453,7 @@ dial_3gpp_context_step (GTask *task)
return;
case DIAL_3GPP_CONTEXT_STEP_LAST:
- mm_dbg ("cinterion dial step %u/%u: finished", ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST);
+ mm_obj_dbg (self, "cinterion dial step %u/%u: finished", ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST);
g_task_return_pointer (task, g_object_ref (ctx->data), g_object_unref);
g_object_unref (task);
return;
@@ -562,7 +567,7 @@ disconnect_connection_status_ready (MMBroadbandBearerCinterion *self,
switch (status) {
case MM_BEARER_CONNECTION_STATUS_UNKNOWN:
/* Assume disconnected */
- mm_dbg ("couldn't get CID %u status, assume disconnected: %s", ctx->cid, error->message);
+ mm_obj_dbg (self, "couldn't get CID %u status, assume disconnected: %s", ctx->cid, error->message);
g_clear_error (&error);
break;
case MM_BEARER_CONNECTION_STATUS_DISCONNECTED:
@@ -604,9 +609,11 @@ swwan_disconnect_ready (MMBaseModem *modem,
static void
disconnect_3gpp_context_step (GTask *task)
{
- Disconnect3gppContext *ctx;
+ MMBroadbandBearerCinterion *self;
+ Disconnect3gppContext *ctx;
- ctx = (Disconnect3gppContext *) g_task_get_task_data (task);
+ self = g_task_get_source_object (task);
+ ctx = g_task_get_task_data (task);
switch (ctx->step) {
case DISCONNECT_3GPP_CONTEXT_STEP_FIRST:
@@ -618,8 +625,8 @@ disconnect_3gpp_context_step (GTask *task)
command = g_strdup_printf ("^SWWAN=0,%u,%u",
ctx->cid, usb_interface_configs[ctx->usb_interface_config_index].swwan_index);
- mm_dbg ("cinterion disconnect step %u/%u: disconnecting PDP CID %u...",
- ctx->step, DISCONNECT_3GPP_CONTEXT_STEP_LAST, ctx->cid);
+ mm_obj_dbg (self, "cinterion disconnect step %u/%u: disconnecting PDP CID %u...",
+ ctx->step, DISCONNECT_3GPP_CONTEXT_STEP_LAST, ctx->cid);
mm_base_modem_at_command_full (ctx->modem,
ctx->primary,
command,
@@ -634,9 +641,9 @@ disconnect_3gpp_context_step (GTask *task)
}
case DISCONNECT_3GPP_CONTEXT_STEP_CONNECTION_STATUS:
- mm_dbg ("cinterion disconnect step %u/%u: checking SWWAN interface %u status...",
- ctx->step, DISCONNECT_3GPP_CONTEXT_STEP_LAST,
- usb_interface_configs[ctx->usb_interface_config_index].swwan_index);
+ mm_obj_dbg (self, "cinterion disconnect step %u/%u: checking SWWAN interface %u status...",
+ ctx->step, DISCONNECT_3GPP_CONTEXT_STEP_LAST,
+ usb_interface_configs[ctx->usb_interface_config_index].swwan_index);
load_connection_status_by_cid (MM_BROADBAND_BEARER_CINTERION (ctx->self),
ctx->cid,
(GAsyncReadyCallback) disconnect_connection_status_ready,
@@ -644,8 +651,8 @@ disconnect_3gpp_context_step (GTask *task)
return;
case DISCONNECT_3GPP_CONTEXT_STEP_LAST:
- mm_dbg ("cinterion disconnect step %u/%u: finished",
- ctx->step, DISCONNECT_3GPP_CONTEXT_STEP_LAST);
+ mm_obj_dbg (self, "cinterion disconnect step %u/%u: finished",
+ ctx->step, DISCONNECT_3GPP_CONTEXT_STEP_LAST);
g_task_return_boolean (task, TRUE);
g_object_unref (task);
return;
diff --git a/plugins/cinterion/mm-broadband-modem-cinterion.c b/plugins/cinterion/mm-broadband-modem-cinterion.c
index c517288f..09b4e13c 100644
--- a/plugins/cinterion/mm-broadband-modem-cinterion.c
+++ b/plugins/cinterion/mm-broadband-modem-cinterion.c
@@ -28,7 +28,7 @@
#include "ModemManager.h"
#include "mm-modem-helpers.h"
#include "mm-serial-parsers.h"
-#include "mm-log.h"
+#include "mm-log-object.h"
#include "mm-errors-types.h"
#include "mm-iface-modem.h"
#include "mm-iface-modem-3gpp.h"
@@ -256,7 +256,7 @@ cnmi_format_check_ready (MMBaseModem *_self,
&self->priv->cnmi_supported_ds,
&self->priv->cnmi_supported_bfr,
&error)) {
- mm_warn ("error reading SMS setup: %s", error->message);
+ mm_obj_warn (self, "error reading SMS setup: %s", error->message);
g_error_free (error);
}
@@ -333,13 +333,10 @@ sleep_ready (MMBaseModem *self,
GAsyncResult *res,
GTask *task)
{
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
- if (!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error)) {
- /* Ignore errors */
- mm_dbg ("Couldn't send power down command: '%s'", error->message);
- g_error_free (error);
- }
+ if (!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error))
+ mm_obj_dbg (self, "couldn't send power down command: %s", error->message);
g_task_return_boolean (task, TRUE);
g_object_unref (task);
@@ -374,14 +371,13 @@ supported_functionality_status_query_ready (MMBaseModem *_self,
{
MMBroadbandModemCinterion *self = MM_BROADBAND_MODEM_CINTERION (_self);
const gchar *response;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
g_assert (self->priv->sleep_mode_cmd == NULL);
response = mm_base_modem_at_command_finish (_self, res, &error);
if (!response) {
- mm_warn ("Couldn't query supported functionality status: '%s'", error->message);
- g_error_free (error);
+ mm_obj_warn (self, "couldn't query supported functionality status: %s", error->message);
self->priv->sleep_mode_cmd = g_strdup ("");
} else {
/* We need to get which power-off command to use to put the modem in low
@@ -395,13 +391,13 @@ supported_functionality_status_query_ready (MMBaseModem *_self,
* not found, report warning and don't use any.
*/
if (strstr (response, "4") != NULL) {
- mm_dbg ("Device supports CFUN=4 sleep mode");
+ mm_obj_dbg (self, "device supports CFUN=4 sleep mode");
self->priv->sleep_mode_cmd = g_strdup ("+CFUN=4");
} else if (strstr (response, "7") != NULL) {
- mm_dbg ("Device supports CFUN=7 sleep mode");
+ mm_obj_dbg (self, "device supports CFUN=7 sleep mode");
self->priv->sleep_mode_cmd = g_strdup ("+CFUN=7");
} else {
- mm_warn ("Unknown functionality mode to go into sleep mode");
+ mm_obj_warn (self, "unknown functionality mode to go into sleep mode");
self->priv->sleep_mode_cmd = g_strdup ("");
}
}
@@ -684,12 +680,10 @@ parent_disable_unsolicited_events_ready (MMIfaceModem3gpp *self,
GAsyncResult *res,
GTask *task)
{
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
- if (!iface_modem_3gpp_parent->disable_unsolicited_events_finish (self, res, &error)) {
- mm_warn ("Couldn't disable parent 3GPP unsolicited events: %s", error->message);
- g_error_free (error);
- }
+ if (!iface_modem_3gpp_parent->disable_unsolicited_events_finish (self, res, &error))
+ mm_obj_warn (self, "couldn't disable parent 3GPP unsolicited events: %s", error->message);
g_task_return_boolean (task, TRUE);
g_object_unref (task);
@@ -710,12 +704,10 @@ sind_psinfo_disable_ready (MMBaseModem *self,
GAsyncResult *res,
GTask *task)
{
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
- if (!mm_base_modem_at_command_finish (self, res, &error)) {
- mm_warn ("Couldn't disable ^SIND psinfo notifications: %s", error->message);
- g_error_free (error);
- }
+ if (!mm_base_modem_at_command_finish (self, res, &error))
+ mm_obj_warn (self, "Couldn't disable ^SIND psinfo notifications: %s", error->message);
parent_disable_unsolicited_messages (task);
}
@@ -763,7 +755,7 @@ sind_psinfo_enable_ready (MMBaseModem *_self,
GTask *task)
{
MMBroadbandModemCinterion *self;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
const gchar *response;
guint mode;
guint val;
@@ -771,20 +763,18 @@ sind_psinfo_enable_ready (MMBaseModem *_self,
self = MM_BROADBAND_MODEM_CINTERION (_self);
if (!(response = mm_base_modem_at_command_finish (_self, res, &error))) {
self->priv->sind_psinfo_support = FEATURE_NOT_SUPPORTED;
- mm_warn ("Couldn't enable ^SIND psinfo notifications: %s", error->message);
- g_error_free (error);
+ mm_obj_warn (self, "couldn't enable ^SIND psinfo notifications: %s", error->message);
} else if (!mm_cinterion_parse_sind_response (response, NULL, &mode, &val, &error)) {
self->priv->sind_psinfo_support = FEATURE_NOT_SUPPORTED;
- mm_warn ("Couldn't parse ^SIND psinfo response: %s", error->message);
- g_error_free (error);
+ mm_obj_warn (self, "couldn't parse ^SIND psinfo response: %s", error->message);
} else {
/* Flag ^SIND psinfo supported so that we don't poll */
self->priv->sind_psinfo_support = FEATURE_SUPPORTED;
/* Report initial access technology gathered right away */
- mm_dbg ("Reporting initial access technologies...");
+ mm_obj_dbg (self, "reporting initial access technologies...");
mm_iface_modem_update_access_technologies (MM_IFACE_MODEM (self),
- mm_cinterion_get_access_technology_from_sind_psinfo (val),
+ mm_cinterion_get_access_technology_from_sind_psinfo (val, self),
MM_IFACE_MODEM_3GPP_ALL_ACCESS_TECHNOLOGIES_MASK);
}
@@ -798,14 +788,12 @@ parent_enable_unsolicited_events_ready (MMIfaceModem3gpp *_self,
GTask *task)
{
MMBroadbandModemCinterion *self;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
self = MM_BROADBAND_MODEM_CINTERION (_self);
- if (!iface_modem_3gpp_parent->enable_unsolicited_events_finish (_self, res, &error)) {
- mm_warn ("Couldn't enable parent 3GPP unsolicited events: %s", error->message);
- g_error_free (error);
- }
+ if (!iface_modem_3gpp_parent->enable_unsolicited_events_finish (_self, res, &error))
+ mm_obj_warn (self, "couldn't enable parent 3GPP unsolicited events: %s", error->message);
if (self->priv->sind_psinfo_support != FEATURE_NOT_SUPPORTED) {
/* Enable access technology update reporting */
@@ -851,12 +839,12 @@ sind_ciev_received (MMPortSerialAt *port,
indicator = mm_get_string_unquoted_from_match_info (match_info, 1);
if (!mm_get_uint_from_match_info (match_info, 2, &val))
- mm_dbg ("couldn't parse indicator '%s' value", indicator);
+ mm_obj_dbg (self, "couldn't parse indicator '%s' value", indicator);
else {
- mm_dbg ("received indicator '%s' update: %u", indicator, val);
+ mm_obj_dbg (self, "received indicator '%s' update: %u", indicator, val);
if (g_strcmp0 (indicator, "psinfo") == 0) {
mm_iface_modem_update_access_technologies (MM_IFACE_MODEM (self),
- mm_cinterion_get_access_technology_from_sind_psinfo (val),
+ mm_cinterion_get_access_technology_from_sind_psinfo (val, self),
MM_IFACE_MODEM_3GPP_ALL_ACCESS_TECHNOLOGIES_MASK);
}
}
@@ -1467,23 +1455,22 @@ spic_ready (MMBaseModem *self,
{
LoadUnlockRetriesContext *ctx;
const gchar *response;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
ctx = g_task_get_task_data (task);
response = mm_base_modem_at_command_finish (self, res, &error);
if (!response) {
- mm_dbg ("Couldn't load retry count for lock '%s': %s",
- mm_modem_lock_get_string (unlock_retries_map[ctx->i].lock),
- error->message);
- g_error_free (error);
+ mm_obj_dbg (self, "Couldn't load retry count for lock '%s': %s",
+ mm_modem_lock_get_string (unlock_retries_map[ctx->i].lock),
+ error->message);
} else {
guint val;
response = mm_strip_tag (response, "^SPIC:");
if (!mm_get_uint_from_str (response, &val))
- mm_dbg ("Couldn't parse retry count value for lock '%s'",
- mm_modem_lock_get_string (unlock_retries_map[ctx->i].lock));
+ mm_obj_dbg (self, "couldn't parse retry count value for lock '%s'",
+ mm_modem_lock_get_string (unlock_retries_map[ctx->i].lock));
else
mm_unlock_retries_set (ctx->retries, unlock_retries_map[ctx->i].lock, val);
}
@@ -1698,7 +1685,7 @@ common_create_bearer (GTask *task)
switch (self->priv->swwan_support) {
case FEATURE_NOT_SUPPORTED:
- mm_dbg ("^SWWAN not supported, creating default bearer...");
+ mm_obj_dbg (self, "^SWWAN not supported, creating default bearer...");
mm_broadband_bearer_new (MM_BROADBAND_MODEM (self),
g_task_get_task_data (task),
NULL, /* cancellable */
@@ -1706,7 +1693,7 @@ common_create_bearer (GTask *task)
task);
return;
case FEATURE_SUPPORTED:
- mm_dbg ("^SWWAN supported, creating cinterion bearer...");
+ mm_obj_dbg (self, "^SWWAN supported, creating cinterion bearer...");
mm_broadband_bearer_cinterion_new (MM_BROADBAND_MODEM_CINTERION (self),
g_task_get_task_data (task),
NULL, /* cancellable */
@@ -1729,10 +1716,10 @@ swwan_test_ready (MMBaseModem *_self,
/* Fetch the result to the SWWAN test. If no response given (error triggered),
* assume unsupported */
if (!mm_base_modem_at_command_finish (_self, res, NULL)) {
- mm_dbg ("SWWAN unsupported");
+ mm_obj_dbg (self, "SWWAN unsupported");
self->priv->swwan_support = FEATURE_NOT_SUPPORTED;
} else {
- mm_dbg ("SWWAN supported");
+ mm_obj_dbg (self, "SWWAN supported");
self->priv->swwan_support = FEATURE_SUPPORTED;
}
@@ -1762,13 +1749,13 @@ cinterion_modem_create_bearer (MMIfaceModem *_self,
/* If we don't have a data port, don't even bother checking for ^SWWAN
* support. */
if (!mm_base_modem_peek_best_data_port (MM_BASE_MODEM (self), MM_PORT_TYPE_NET)) {
- mm_dbg ("skipping ^SWWAN check as no data port is available");
+ mm_obj_dbg (self, "skipping ^SWWAN check as no data port is available");
self->priv->swwan_support = FEATURE_NOT_SUPPORTED;
common_create_bearer (task);
return;
}
- mm_dbg ("checking ^SWWAN support...");
+ mm_obj_dbg (self, "checking ^SWWAN support...");
mm_base_modem_at_command (MM_BASE_MODEM (self),
"^SWWAN=?",
6,
diff --git a/plugins/cinterion/mm-modem-helpers-cinterion.c b/plugins/cinterion/mm-modem-helpers-cinterion.c
index 0eac9125..da2dd643 100644
--- a/plugins/cinterion/mm-modem-helpers-cinterion.c
+++ b/plugins/cinterion/mm-modem-helpers-cinterion.c
@@ -24,7 +24,7 @@
#include "ModemManager.h"
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
-#include "mm-log.h"
+#include "mm-log-object.h"
#include "mm-charsets.h"
#include "mm-errors-types.h"
#include "mm-modem-helpers-cinterion.h"
@@ -500,6 +500,7 @@ enum {
MMBearerConnectionStatus
mm_cinterion_parse_swwan_response (const gchar *response,
guint cid,
+ gpointer log_object,
GError **error)
{
GRegex *r;
@@ -531,9 +532,9 @@ mm_cinterion_parse_swwan_response (const gchar *response,
guint read_cid;
if (!mm_get_uint_from_match_info (match_info, 1, &read_cid))
- mm_warn ("Couldn't read cid in ^SWWAN response: '%s'", response);
+ mm_obj_warn (log_object, "couldn't read cid in ^SWWAN response: %s", response);
else if (!mm_get_uint_from_match_info (match_info, 2, &read_state))
- mm_warn ("Couldn't read state in ^SWWAN response: '%s'", response);
+ mm_obj_warn (log_object, "couldn't read state in ^SWWAN response: %s", response);
else if (read_cid == cid) {
if (read_state == MM_SWWAN_STATE_CONNECTED) {
status = MM_BEARER_CONNECTION_STATUS_CONNECTED;
@@ -543,7 +544,7 @@ mm_cinterion_parse_swwan_response (const gchar *response,
status = MM_BEARER_CONNECTION_STATUS_DISCONNECTED;
break;
}
- mm_warn ("Invalid state read in ^SWWAN response: %u", read_state);
+ mm_obj_warn (log_object, "invalid state read in ^SWWAN response: %u", read_state);
break;
}
g_match_info_next (match_info, &inner_error);
@@ -640,7 +641,8 @@ mm_cinterion_parse_smong_response (const gchar *response,
/* ^SIND psinfo helper */
MMModemAccessTechnology
-mm_cinterion_get_access_technology_from_sind_psinfo (guint val)
+mm_cinterion_get_access_technology_from_sind_psinfo (guint val,
+ gpointer log_object)
{
switch (val) {
case 0:
@@ -664,7 +666,7 @@ mm_cinterion_get_access_technology_from_sind_psinfo (guint val)
case 17:
return MM_MODEM_ACCESS_TECHNOLOGY_LTE;
default:
- mm_dbg ("Unable to identify access technology from psinfo reported value: %u", val);
+ mm_obj_dbg (log_object, "unable to identify access technology from psinfo reported value: %u", val);
return MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN;
}
}
@@ -694,6 +696,7 @@ cinterion_call_info_free (MMCallInfo *info)
gboolean
mm_cinterion_parse_slcc_list (const gchar *str,
+ gpointer log_object,
GList **out_list,
GError **error)
{
@@ -747,20 +750,20 @@ mm_cinterion_parse_slcc_list (const gchar *str,
call_info = g_slice_new0 (MMCallInfo);
if (!mm_get_uint_from_match_info (match_info, 1, &call_info->index)) {
- mm_warn ("couldn't parse call index from ^SLCC line");
+ mm_obj_warn (log_object, "couldn't parse call index from ^SLCC line");
goto next;
}
if (!mm_get_uint_from_match_info (match_info, 2, &aux) ||
(aux >= G_N_ELEMENTS (cinterion_call_direction))) {
- mm_warn ("couldn't parse call direction from ^SLCC line");
+ mm_obj_warn (log_object, "couldn't parse call direction from ^SLCC line");
goto next;
}
call_info->direction = cinterion_call_direction[aux];
if (!mm_get_uint_from_match_info (match_info, 3, &aux) ||
(aux >= G_N_ELEMENTS (cinterion_call_state))) {
- mm_warn ("couldn't parse call state from ^SLCC line");
+ mm_obj_warn (log_object, "couldn't parse call state from ^SLCC line");
goto next;
}
call_info->state = cinterion_call_state[aux];
diff --git a/plugins/cinterion/mm-modem-helpers-cinterion.h b/plugins/cinterion/mm-modem-helpers-cinterion.h
index a318b8d0..ad6a5fa1 100644
--- a/plugins/cinterion/mm-modem-helpers-cinterion.h
+++ b/plugins/cinterion/mm-modem-helpers-cinterion.h
@@ -76,6 +76,7 @@ gboolean mm_cinterion_parse_sind_response (const gchar *response,
MMBearerConnectionStatus mm_cinterion_parse_swwan_response (const gchar *response,
guint swwan_index,
+ gpointer log_object,
GError **error);
/*****************************************************************************/
@@ -88,7 +89,8 @@ gboolean mm_cinterion_parse_smong_response (const gchar *response,
/*****************************************************************************/
/* ^SIND psinfo helper */
-MMModemAccessTechnology mm_cinterion_get_access_technology_from_sind_psinfo (guint val);
+MMModemAccessTechnology mm_cinterion_get_access_technology_from_sind_psinfo (guint val,
+ gpointer log_object);
/*****************************************************************************/
/* ^SLCC URC helpers */
@@ -97,6 +99,7 @@ GRegex *mm_cinterion_get_slcc_regex (void);
/* MMCallInfo list management */
gboolean mm_cinterion_parse_slcc_list (const gchar *str,
+ gpointer log_object,
GList **out_list,
GError **error);
void mm_cinterion_call_info_list_free (GList *call_info_list);
diff --git a/plugins/cinterion/mm-plugin-cinterion.c b/plugins/cinterion/mm-plugin-cinterion.c
index bdca6188..30c0f481 100644
--- a/plugins/cinterion/mm-plugin-cinterion.c
+++ b/plugins/cinterion/mm-plugin-cinterion.c
@@ -29,7 +29,7 @@
#include "mm-plugin-cinterion.h"
#include "mm-broadband-modem-cinterion.h"
-#include "mm-log.h"
+#include "mm-log-object.h"
#if defined WITH_QMI
#include "mm-broadband-modem-qmi-cinterion.h"
@@ -115,7 +115,7 @@ create_modem (MMPlugin *self,
{
#if defined WITH_QMI
if (mm_port_probe_list_has_qmi_port (probes)) {
- mm_dbg ("QMI-powered Cinterion modem found...");
+ mm_obj_dbg (self, "QMI-powered Cinterion modem found...");
return MM_BASE_MODEM (mm_broadband_modem_qmi_cinterion_new (uid,
drivers,
mm_plugin_get_name (self),
@@ -143,14 +143,14 @@ grab_port (MMPlugin *self,
ptype = mm_port_probe_get_port_type (probe);
if (g_object_get_data (G_OBJECT (probe), TAG_CINTERION_APP_PORT)) {
- mm_dbg ("(%s/%s)' Port flagged as primary",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
+ mm_obj_dbg (self, "port '%s/%s' flagged as primary",
+ mm_port_probe_get_port_subsys (probe),
+ mm_port_probe_get_port_name (probe));
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
} else if (g_object_get_data (G_OBJECT (probe), TAG_CINTERION_MODEM_PORT)) {
- mm_dbg ("(%s/%s)' Port flagged as PPP",
- mm_port_probe_get_port_subsys (probe),
- mm_port_probe_get_port_name (probe));
+ mm_obj_dbg (self, "port '%s/%s' flagged as PPP",
+ mm_port_probe_get_port_subsys (probe),
+ mm_port_probe_get_port_name (probe));
pflags = MM_PORT_SERIAL_AT_FLAG_PPP;
}
diff --git a/plugins/cinterion/mm-shared-cinterion.c b/plugins/cinterion/mm-shared-cinterion.c
index 8ae8e88e..9ad03a75 100644
--- a/plugins/cinterion/mm-shared-cinterion.c
+++ b/plugins/cinterion/mm-shared-cinterion.c
@@ -23,7 +23,7 @@
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
-#include "mm-log.h"
+#include "mm-log-object.h"
#include "mm-iface-modem.h"
#include "mm-iface-modem-location.h"
#include "mm-base-modem.h"
@@ -217,7 +217,7 @@ probe_gps_features (GTask *task)
sources = GPOINTER_TO_UINT (g_task_get_task_data (task));
if (priv->sgpss_support == FEATURE_SUPPORTED || priv->sgpsc_support == FEATURE_SUPPORTED) {
- mm_dbg ("GPS commands supported: GPS capabilities enabled");
+ mm_obj_dbg (self, "GPS commands supported: GPS capabilities enabled");
/* We only flag as supported by this implementation those sources not already
* supported by the parent implementation */
@@ -236,7 +236,7 @@ probe_gps_features (GTask *task)
self,
NULL);
} else
- mm_dbg ("No GPS command supported: no GPS capabilities");
+ mm_obj_dbg (self, "no GPS command supported: no GPS capabilities");
g_task_return_int (task, (gssize) sources);
g_object_unref (task);
@@ -262,7 +262,7 @@ parent_load_capabilities_ready (MMIfaceModemLocation *self,
/* Now our own check. If we don't have any GPS port, we're done */
if (!mm_base_modem_peek_port_gps (MM_BASE_MODEM (self))) {
- mm_dbg ("No GPS data port found: no GPS capabilities");
+ mm_obj_dbg (self, "no GPS data port found: no GPS capabilities");
g_task_return_int (task, sources);
g_object_unref (task);
return;
@@ -610,7 +610,7 @@ enable_sgpsc_or_sgpss_ready (MMBaseModem *self,
* Engine; so we'll run some retries of the same command ourselves. */
if (ctx->gps_step == ENABLE_LOCATION_GATHERING_GPS_STEP_SGPSC_ENGINE) {
ctx->sgpsc_engine_retries++;
- mm_dbg ("GPS Engine setup failed (%u/%u)", ctx->sgpsc_engine_retries, MAX_SGPSC_ENGINE_RETRIES);
+ mm_obj_dbg (self, "GPS engine setup failed (%u/%u)", ctx->sgpsc_engine_retries, MAX_SGPSC_ENGINE_RETRIES);
if (ctx->sgpsc_engine_retries < MAX_SGPSC_ENGINE_RETRIES) {
g_clear_error (&error);
goto schedule;
@@ -803,7 +803,7 @@ mm_shared_cinterion_create_call (MMIfaceModemVoice *self,
/* If ^SLCC is supported create a cinterion call object */
priv = get_private (MM_SHARED_CINTERION (self));
if (priv->slcc_support == FEATURE_SUPPORTED) {
- mm_dbg ("Created new call with ^SLCC support");
+ mm_obj_dbg (self, "created new call with ^SLCC support");
return mm_base_call_new (MM_BASE_MODEM (self),
direction,
number,
@@ -857,16 +857,14 @@ slcc_command_ready (MMBaseModem *self,
GTask *task)
{
VoiceUnsolicitedEventsContext *ctx;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
ctx = g_task_get_task_data (task);
- if (!mm_base_modem_at_command_full_finish (self, res, &error)) {
- mm_dbg ("Couldn't %s ^SLCC reporting: '%s'",
- ctx->enable ? "enable" : "disable",
- error->message);
- g_error_free (error);
- }
+ if (!mm_base_modem_at_command_full_finish (self, res, &error))
+ mm_obj_dbg (self, "couldn't %s ^SLCC reporting: %s",
+ ctx->enable ? "enable" : "disable",
+ error->message);
/* Continue on next port */
run_voice_enable_disable_unsolicited_events (task);
@@ -892,13 +890,13 @@ run_voice_enable_disable_unsolicited_events (GTask *task)
}
if (!ctx->slcc_primary_done && ctx->primary) {
- mm_dbg ("%s ^SLCC extended list of current calls reporting in primary port...",
- ctx->enable ? "Enabling" : "Disabling");
+ mm_obj_dbg (self, "%s ^SLCC extended list of current calls reporting in primary port...",
+ ctx->enable ? "enabling" : "disabling");
ctx->slcc_primary_done = TRUE;
port = ctx->primary;
} else if (!ctx->slcc_secondary_done && ctx->secondary) {
- mm_dbg ("%s ^SLCC extended list of current calls reporting in secondary port...",
- ctx->enable ? "Enabling" : "Disabling");
+ mm_obj_dbg (self, "%s ^SLCC extended list of current calls reporting in secondary port...",
+ ctx->enable ? "enabling" : "disabling");
ctx->slcc_secondary_done = TRUE;
port = ctx->secondary;
}
@@ -961,15 +959,13 @@ parent_voice_disable_unsolicited_events_ready (MMIfaceModemVoice *self,
GAsyncResult *res,
GTask *task)
{
- GError *error = NULL;
- Private *priv;
+ g_autoptr(GError) error = NULL;
+ Private *priv;
priv = get_private (MM_SHARED_CINTERION (self));
- if (!priv->iface_modem_voice_parent->disable_unsolicited_events_finish (self, res, &error)) {
- mm_warn ("Couldn't disable parent voice unsolicited events: %s", error->message);
- g_error_free (error);
- }
+ if (!priv->iface_modem_voice_parent->disable_unsolicited_events_finish (self, res, &error))
+ mm_obj_warn (self, "couldn't disable parent voice unsolicited events: %s", error->message);
g_task_return_boolean (task, TRUE);
g_object_unref (task);
@@ -980,13 +976,11 @@ voice_disable_unsolicited_events_ready (MMSharedCinterion *self,
GAsyncResult *res,
GTask *task)
{
- Private *priv;
- GError *error = NULL;
+ Private *priv;
+ g_autoptr(GError) error = NULL;
- if (!common_voice_enable_disable_unsolicited_events_finish (self, res, &error)) {
- mm_warn ("Couldn't disable Cinterion-specific voice unsolicited events: %s", error->message);
- g_error_free (error);
- }
+ if (!common_voice_enable_disable_unsolicited_events_finish (self, res, &error))
+ mm_obj_warn (self, "couldn't disable Cinterion-specific voice unsolicited events: %s", error->message);
priv = get_private (MM_SHARED_CINTERION (self));
g_assert (priv->iface_modem_voice_parent);
@@ -1032,12 +1026,10 @@ voice_enable_unsolicited_events_ready (MMSharedCinterion *self,
GAsyncResult *res,
GTask *task)
{
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
- if (!common_voice_enable_disable_unsolicited_events_finish (self, res, &error)) {
- mm_warn ("Couldn't enable Cinterion-specific voice unsolicited events: %s", error->message);
- g_error_free (error);
- }
+ if (!common_voice_enable_disable_unsolicited_events_finish (self, res, &error))
+ mm_obj_warn (self, "couldn't enable Cinterion-specific voice unsolicited events: %s", error->message);
g_task_return_boolean (task, TRUE);
g_object_unref (task);
@@ -1048,15 +1040,13 @@ parent_voice_enable_unsolicited_events_ready (MMIfaceModemVoice *self,
GAsyncResult *res,
GTask *task)
{
- GError *error = NULL;
- Private *priv;
+ g_autoptr(GError) error = NULL;
+ Private *priv;
priv = get_private (MM_SHARED_CINTERION (self));
- if (!priv->iface_modem_voice_parent->enable_unsolicited_events_finish (self, res, &error)) {
- mm_warn ("Couldn't enable parent voice unsolicited events: %s", error->message);
- g_error_free (error);
- }
+ if (!priv->iface_modem_voice_parent->enable_unsolicited_events_finish (self, res, &error))
+ mm_obj_warn (self, "couldn't enable parent voice unsolicited events: %s", error->message);
/* our own enabling next */
common_voice_enable_disable_unsolicited_events (MM_SHARED_CINTERION (self),
@@ -1095,20 +1085,16 @@ slcc_received (MMPortSerialAt *port,
GMatchInfo *match_info,
MMSharedCinterion *self)
{
- gchar *full;
- GError *error = NULL;
- GList *call_info_list = NULL;
+ g_autofree gchar *full = NULL;
+ g_autoptr(GError) error = NULL;
+ GList *call_info_list = NULL;
full = g_match_info_fetch (match_info, 0);
-
- if (!mm_cinterion_parse_slcc_list (full, &call_info_list, &error)) {
- mm_warn ("couldn't parse ^SLCC list: %s", error->message);
- g_error_free (error);
- } else
+ if (!mm_cinterion_parse_slcc_list (full, self, &call_info_list, &error))
+ mm_obj_warn (self, "couldn't parse ^SLCC list: %s", error->message);
+ else
mm_iface_modem_voice_report_all_calls (MM_IFACE_MODEM_VOICE (self), call_info_list);
-
mm_cinterion_call_info_list_free (call_info_list);
- g_free (full);
}
static void
@@ -1152,15 +1138,13 @@ parent_voice_cleanup_unsolicited_events_ready (MMIfaceModemVoice *self,
GAsyncResult *res,
GTask *task)
{
- GError *error = NULL;
- Private *priv;
+ g_autoptr(GError) error = NULL;
+ Private *priv;
priv = get_private (MM_SHARED_CINTERION (self));
- if (!priv->iface_modem_voice_parent->cleanup_unsolicited_events_finish (self, res, &error)) {
- mm_warn ("Couldn't cleanup parent voice unsolicited events: %s", error->message);
- g_error_free (error);
- }
+ if (!priv->iface_modem_voice_parent->cleanup_unsolicited_events_finish (self, res, &error))
+ mm_obj_warn (self, "couldn't cleanup parent voice unsolicited events: %s", error->message);
g_task_return_boolean (task, TRUE);
g_object_unref (task);
@@ -1207,15 +1191,13 @@ parent_voice_setup_unsolicited_events_ready (MMIfaceModemVoice *self,
GAsyncResult *res,
GTask *task)
{
- GError *error = NULL;
- Private *priv;
+ g_autoptr(GError) error = NULL;
+ Private *priv;
priv = get_private (MM_SHARED_CINTERION (self));
- if (!priv->iface_modem_voice_parent->setup_unsolicited_events_finish (self, res, &error)) {
- mm_warn ("Couldn't setup parent voice unsolicited events: %s", error->message);
- g_error_free (error);
- }
+ if (!priv->iface_modem_voice_parent->setup_unsolicited_events_finish (self, res, &error))
+ mm_obj_warn (self, "Couldn't setup parent voice unsolicited events: %s", error->message);
/* our own setup next */
common_voice_setup_cleanup_unsolicited_events (MM_SHARED_CINTERION (self), TRUE);
@@ -1337,24 +1319,18 @@ ctzu_received (MMPortSerialAt *port,
GMatchInfo *match_info,
MMSharedCinterion *self)
{
- gchar *iso8601 = NULL;
- MMNetworkTimezone *tz = NULL;
- GError *error = NULL;
+ g_autofree gchar *iso8601 = NULL;
+ g_autoptr(MMNetworkTimezone) tz = NULL;
+ g_autoptr(GError) error = NULL;
if (!mm_cinterion_parse_ctzu_urc (match_info, &iso8601, &tz, &error)) {
- mm_dbg ("Couldn't process +CTZU URC: %s", error->message);
- g_error_free (error);
+ mm_obj_dbg (self, "couldn't process +CTZU URC: %s", error->message);
return;
}
- g_assert (iso8601);
- mm_dbg ("+CTZU URC received: %s", iso8601);
+ mm_obj_dbg (self, "+CTZU URC received: %s", iso8601);
mm_iface_modem_time_update_network_time (MM_IFACE_MODEM_TIME (self), iso8601);
- g_free (iso8601);
-
- g_assert (tz);
mm_iface_modem_time_update_network_timezone (MM_IFACE_MODEM_TIME (self), tz);
- g_object_unref (tz);
}
static void
@@ -1370,8 +1346,8 @@ common_time_setup_cleanup_unsolicited_events (MMSharedCinterion *self,
ports[0] = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
ports[1] = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
- mm_dbg ("%s up time unsolicited events...",
- enable ? "Setting" : "Cleaning");
+ mm_obj_dbg (self, "%s up time unsolicited events...",
+ enable ? "setting" : "cleaning");
for (i = 0; i < G_N_ELEMENTS (ports); i++) {
if (!ports[i])
@@ -1401,15 +1377,13 @@ parent_time_cleanup_unsolicited_events_ready (MMIfaceModemTime *self,
GAsyncResult *res,
GTask *task)
{
- GError *error = NULL;
- Private *priv;
+ g_autoptr(GError) error = NULL;
+ Private *priv;
priv = get_private (MM_SHARED_CINTERION (self));
- if (!priv->iface_modem_time_parent->cleanup_unsolicited_events_finish (self, res, &error)) {
- mm_warn ("Couldn't cleanup parent time unsolicited events: %s", error->message);
- g_error_free (error);
- }
+ if (!priv->iface_modem_time_parent->cleanup_unsolicited_events_finish (self, res, &error))
+ mm_obj_warn (self, "couldn't cleanup parent time unsolicited events: %s", error->message);
g_task_return_boolean (task, TRUE);
g_object_unref (task);
@@ -1475,15 +1449,13 @@ parent_time_setup_unsolicited_events_ready (MMIfaceModemTime *self,
GAsyncResult *res,
GTask *task)
{
- GError *error = NULL;
- Private *priv;
+ g_autoptr(GError) error = NULL;
+ Private *priv;
priv = get_private (MM_SHARED_CINTERION (self));
- if (!priv->iface_modem_time_parent->cleanup_unsolicited_events_finish (self, res, &error)) {
- mm_warn ("Couldn't cleanup parent time unsolicited events: %s", error->message);
- g_error_free (error);
- }
+ if (!priv->iface_modem_time_parent->cleanup_unsolicited_events_finish (self, res, &error))
+ mm_obj_warn (self, "Couldn't cleanup parent time unsolicited events: %s", error->message);
own_time_setup_unsolicited_events (task);
}
diff --git a/plugins/cinterion/tests/test-modem-helpers-cinterion.c b/plugins/cinterion/tests/test-modem-helpers-cinterion.c
index f1d6cddb..88e0f74c 100644
--- a/plugins/cinterion/tests/test-modem-helpers-cinterion.c
+++ b/plugins/cinterion/tests/test-modem-helpers-cinterion.c
@@ -565,7 +565,7 @@ test_swwan_pls8 (void)
/* Query for the expected items (CIDs 2 and 3) */
for (j = 0; j < SWWAN_TEST_MAX_CIDS; j++) {
- read_state = mm_cinterion_parse_swwan_response (swwan_tests[i].response, swwan_tests[i].expected_items[j].cid, &error);
+ read_state = mm_cinterion_parse_swwan_response (swwan_tests[i].response, swwan_tests[i].expected_items[j].cid, NULL, &error);
if (swwan_tests[i].expected_items[j].state == MM_BEARER_CONNECTION_STATUS_UNKNOWN) {
g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED);
g_clear_error (&error);
@@ -576,7 +576,7 @@ test_swwan_pls8 (void)
/* Query for a CID which isn't replied (e.g. 12) */
if (!swwan_tests[i].skip_test_other_cids) {
- read_state = mm_cinterion_parse_swwan_response (swwan_tests[i].response, 12, &error);
+ read_state = mm_cinterion_parse_swwan_response (swwan_tests[i].response, 12, NULL, &error);
g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED);
g_assert_cmpint (read_state, ==, MM_BEARER_CONNECTION_STATUS_UNKNOWN);
g_clear_error (&error);
@@ -584,7 +584,7 @@ test_swwan_pls8 (void)
}
/* Additional tests for errors */
- read_state = mm_cinterion_parse_swwan_response ("^GARBAGE", 2, &error);
+ read_state = mm_cinterion_parse_swwan_response ("^GARBAGE", 2, NULL, &error);
g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED);
g_assert_cmpint (read_state, ==, MM_BEARER_CONNECTION_STATUS_UNKNOWN);
g_clear_error (&error);
@@ -695,7 +695,7 @@ common_test_slcc_urc (const gchar *urc,
str = g_match_info_fetch (match_info, 0);
g_assert (str);
- result = mm_cinterion_parse_slcc_list (str, &call_info_list, &error);
+ result = mm_cinterion_parse_slcc_list (str, NULL, &call_info_list, &error);
g_assert_no_error (error);
g_assert (result);