modem-helpers: rework AT string quote operation and add unit tests
Rework the AT string quote operation to build the output with the GString helper, instead of manually calculating how many bytes we'll need in the output. It just makes it clearer.
This commit is contained in:
@@ -196,7 +196,7 @@ connect_3gpp (MMBroadbandBearer *self,
|
||||
g_task_set_task_data (task, ctx, (GDestroyNotify)detailed_connect_context_free);
|
||||
|
||||
config = mm_base_bearer_peek_config (MM_BASE_BEARER (self));
|
||||
apn = mm_port_serial_at_quote_string (mm_bearer_properties_get_apn (config));
|
||||
apn = mm_at_quote_string (mm_bearer_properties_get_apn (config));
|
||||
command = g_strdup_printf ("%%APNN=%s", apn);
|
||||
g_free (apn);
|
||||
mm_base_modem_at_command_full (ctx->modem,
|
||||
|
||||
@@ -1374,7 +1374,7 @@ set_initial_eps_step (GTask *task)
|
||||
apn = mm_bearer_properties_get_apn (ctx->properties);
|
||||
mm_obj_dbg (self, "context %d with APN '%s' and PDP type '%s'",
|
||||
self->priv->initial_eps_bearer_cid, apn, ip_family_str);
|
||||
quoted_apn = mm_port_serial_at_quote_string (apn);
|
||||
quoted_apn = mm_at_quote_string (apn);
|
||||
apn_cmd = g_strdup_printf ("+CGDCONT=%u,\"%s\",%s",
|
||||
self->priv->initial_eps_bearer_cid, ip_family_str, quoted_apn);
|
||||
mm_base_modem_at_command (
|
||||
|
||||
@@ -1855,8 +1855,8 @@ mm_cinterion_build_auth_string (gpointer log_object,
|
||||
return g_strdup_printf ("^SGAUTH=%u,%d", cid, encoded_auth);
|
||||
}
|
||||
|
||||
quoted_user = mm_port_serial_at_quote_string (user ? user : "");
|
||||
quoted_passwd = mm_port_serial_at_quote_string (passwd ? passwd : "");
|
||||
quoted_user = mm_at_quote_string (user ? user : "");
|
||||
quoted_passwd = mm_at_quote_string (passwd ? passwd : "");
|
||||
|
||||
if (modem_family == MM_CINTERION_MODEM_FAMILY_IMT)
|
||||
return g_strdup_printf ("^SGAUTH=%u,%d,%s,%s",
|
||||
|
||||
@@ -2052,8 +2052,8 @@ profile_manager_store_profile_auth_settings (GTask *task)
|
||||
return;
|
||||
}
|
||||
|
||||
quoted_user = mm_port_serial_at_quote_string (user);
|
||||
quoted_password = mm_port_serial_at_quote_string (password);
|
||||
quoted_user = mm_at_quote_string (user);
|
||||
quoted_password = mm_at_quote_string (password);
|
||||
ctx->cmd = g_strdup_printf ("%%IPDPCFG=%d,0,%u,%s,%s",
|
||||
ctx->profile_id,
|
||||
icera_auth,
|
||||
|
||||
@@ -299,9 +299,9 @@ connect_3gpp_authenticate (GTask *task)
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
config = mm_base_bearer_peek_config (MM_BASE_BEARER (self));
|
||||
apn = mm_port_serial_at_quote_string (mm_bearer_properties_get_apn (config));
|
||||
user = mm_port_serial_at_quote_string (mm_bearer_properties_get_user (config));
|
||||
password = mm_port_serial_at_quote_string (mm_bearer_properties_get_password (config));
|
||||
apn = mm_at_quote_string (mm_bearer_properties_get_apn (config));
|
||||
user = mm_at_quote_string (mm_bearer_properties_get_user (config));
|
||||
password = mm_at_quote_string (mm_bearer_properties_get_password (config));
|
||||
command = g_strdup_printf ("$NWQMICONNECT=,,,,,,%s,,,%s,%s",
|
||||
apn, user, password);
|
||||
g_free (apn);
|
||||
|
||||
@@ -557,8 +557,8 @@ authenticate (GTask *task)
|
||||
return;
|
||||
}
|
||||
|
||||
quoted_user = mm_port_serial_at_quote_string (user);
|
||||
quoted_password = mm_port_serial_at_quote_string (password);
|
||||
quoted_user = mm_at_quote_string (user);
|
||||
quoted_password = mm_at_quote_string (password);
|
||||
command = g_strdup_printf ("%s=%d,%u,%s,%s",
|
||||
auth_commands[ctx->auth_idx],
|
||||
ctx->cid,
|
||||
|
||||
@@ -361,8 +361,8 @@ dial_3gpp_context_step (GTask *task)
|
||||
return;
|
||||
}
|
||||
|
||||
quoted_user = mm_port_serial_at_quote_string (user);
|
||||
quoted_password = mm_port_serial_at_quote_string (password);
|
||||
quoted_user = mm_at_quote_string (user);
|
||||
quoted_password = mm_at_quote_string (password);
|
||||
if (self->priv->is_icera) {
|
||||
command = g_strdup_printf ("%%IPDPCFG=%d,0,%u,%s,%s",
|
||||
ctx->cid,
|
||||
|
||||
@@ -533,8 +533,8 @@ out:
|
||||
user = mm_bearer_properties_get_user (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
|
||||
password = mm_bearer_properties_get_password (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
|
||||
|
||||
quoted_user = mm_port_serial_at_quote_string (user);
|
||||
quoted_password = mm_port_serial_at_quote_string (password);
|
||||
quoted_user = mm_at_quote_string (user);
|
||||
quoted_password = mm_at_quote_string (password);
|
||||
|
||||
cmd = g_strdup_printf ("+UAUTHREQ=%u,%u,%s,%s",
|
||||
ctx->cid,
|
||||
|
||||
Reference in New Issue
Block a user