summaryrefslogtreecommitdiff
path: root/src/mm-modem-helpers.c
diff options
context:
space:
mode:
authorCarlo Lobrano <c.lobrano@gmail.com>2016-03-09 11:27:43 +0100
committerAleksander Morgado <aleksander@aleksander.es>2016-03-09 14:43:08 +0100
commitbe317e8b80cd984149ea152c9d00c6bb814e7c88 (patch)
treeb59255b3611d3be0804a0f081e298c967d4b44c5 /src/mm-modem-helpers.c
parent7c2d5b1aa358c4edb94203d7de586d489b656576 (diff)
downloadModemManager-be317e8b80cd984149ea152c9d00c6bb814e7c88.tar.gz
broadband-modem: fix +CPMS empty parameter support
* Add new async virtual method init_current_storages to MMIfaceModemMessaging * Add logic of init_current_storages to MMBroadbandModem * Add step "INIT_CURRENT_STORAGES" in MMIfaceModemMessaging initialization in order to load and store current SMS storages for mem1 and mem2. * Add usage of current sms storage value for mem1 in place of an empty string parameter when the command AT+CPMS is used. https://bugs.freedesktop.org/show_bug.cgi?id=93135
Diffstat (limited to 'src/mm-modem-helpers.c')
-rw-r--r--src/mm-modem-helpers.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index 58394ee6e..74e554620 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -1507,6 +1507,82 @@ mm_3gpp_parse_cpms_test_response (const gchar *reply,
return FALSE;
}
+/**********************************************************************
+ * AT+CPMS?
+ * +CPMS: <memr>,<usedr>,<totalr>,<memw>,<usedw>,<totalw>, <mems>,<useds>,<totals>
+ */
+
+#define CPMS_QUERY_REGEX "\\+CPMS:\\s*\"(?P<memr>.*)\",[0-9]+,[0-9]+,\"(?P<memw>.*)\",[0-9]+,[0-9]+,\"(?P<mems>.*)\",[0-9]+,[0-9]"
+
+gboolean
+mm_3gpp_parse_cpms_query_response (const gchar *reply,
+ MMSmsStorage *memr,
+ MMSmsStorage *memw,
+ GError **error)
+{
+ GRegex *r = NULL;
+ gboolean ret = FALSE;
+ GMatchInfo *match_info = NULL;
+
+ r = g_regex_new (CPMS_QUERY_REGEX, G_REGEX_RAW, 0, NULL);
+
+ g_assert(r);
+
+ if (!g_regex_match (r, reply, 0, &match_info)) {
+ g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
+ "Could not parse CPMS query reponse '%s'", reply);
+ goto end;
+ }
+
+ if (!g_match_info_matches(match_info)) {
+ g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
+ "Could not find matches in CPMS query reply '%s'", reply);
+ goto end;
+ }
+
+ if (!mm_3gpp_get_cpms_storage_match (match_info, "memr", memr, error)) {
+ goto end;
+ }
+
+ if (!mm_3gpp_get_cpms_storage_match (match_info, "memw", memw, error)) {
+ goto end;
+ }
+
+ ret = TRUE;
+
+end:
+ if (r != NULL)
+ g_regex_unref (r);
+
+ if (match_info != NULL)
+ g_match_info_free (match_info);
+
+ return ret;
+}
+
+gboolean
+mm_3gpp_get_cpms_storage_match (GMatchInfo *match_info,
+ const gchar *match_name,
+ MMSmsStorage *storage,
+ GError **error)
+{
+ gboolean ret = TRUE;
+ gchar *str = NULL;
+
+ str = g_match_info_fetch_named(match_info, match_name);
+ if (str == NULL || str[0] == '\0') {
+ g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
+ "Could not find '%s' from CPMS reply", match_name);
+ ret = FALSE;
+ } else {
+ *storage = storage_from_str (str);
+ }
+
+ g_free (str);
+
+ return ret;
+}
+
/*************************************************************************/
gboolean