aboutsummaryrefslogtreecommitdiff
path: root/plugins/linktop/mm-modem-helpers-linktop.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2016-10-11 17:49:43 +0200
committerAleksander Morgado <aleksander@aleksander.es>2016-10-12 11:29:52 +0200
commitd7fdda224765e8ea9c1b4713dfa3708f2251b8c3 (patch)
tree974af01fff06af2cde17d0018d6cce14b112890f /plugins/linktop/mm-modem-helpers-linktop.c
parent74fd7da774c3a4c644106618499d68eb92a95baf (diff)
linktop: new Linktop specific +CFUN? response parser
We handle all known CFUN? response values in the new parser, and report an error if an unknown value is found.
Diffstat (limited to 'plugins/linktop/mm-modem-helpers-linktop.c')
-rw-r--r--plugins/linktop/mm-modem-helpers-linktop.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/plugins/linktop/mm-modem-helpers-linktop.c b/plugins/linktop/mm-modem-helpers-linktop.c
new file mode 100644
index 00000000..7b9b5f14
--- /dev/null
+++ b/plugins/linktop/mm-modem-helpers-linktop.c
@@ -0,0 +1,55 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2008 - 2009 Novell, Inc.
+ * Copyright (C) 2009 - 2016 Red Hat, Inc.
+ * Copyright (C) 2016 Aleksander Morgado <aleksander@aleksander.es>
+ */
+
+#include "mm-log.h"
+#include "mm-modem-helpers.h"
+#include "mm-modem-helpers-linktop.h"
+
+/*****************************************************************************/
+
+gboolean
+mm_linktop_parse_cfun_query_current_modes (const gchar *response,
+ MMModemMode *allowed,
+ GError **error)
+{
+ guint state;
+
+ g_assert (allowed);
+
+ if (!mm_3gpp_parse_cfun_query_response (response, &state, error))
+ return FALSE;
+
+ switch (state) {
+ case LINKTOP_MODE_OFFLINE:
+ case LINKTOP_MODE_LOW_POWER:
+ *allowed = MM_MODEM_MODE_NONE;
+ return TRUE;
+ case LINKTOP_MODE_2G:
+ *allowed = MM_MODEM_MODE_2G;
+ return TRUE;
+ case LINKTOP_MODE_3G:
+ *allowed = MM_MODEM_MODE_3G;
+ return TRUE;
+ case LINKTOP_MODE_ANY:
+ *allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
+ return TRUE;
+ default:
+ g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
+ "Unknown linktop +CFUN current mode: %u", state);
+ return FALSE;
+ }
+}