---
Changes:
o Changed order of files in Makefile
o Fixed missing empty line in copyright
o Formatted enum better
o Removed default is switches
o Removed ste in function names
Makefile.am |2 +
drivers/stemodem/radio-settings.c | 230 +
drivers/stemodem/stemodem.c |2 +
drivers/stemodem/stemodem.h |2 +
4 files changed, 236 insertions(+), 0 deletions(-)
create mode 100644 drivers/stemodem/radio-settings.c
diff --git a/Makefile.am b/Makefile.am
index 16a3a3d..d8f36f2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -202,10 +202,12 @@ builtin_sources += drivers/atmodem/atutil.h \
drivers/stemodem/stemodem.h \
drivers/stemodem/stemodem.c \
drivers/stemodem/voicecall.c \
+ drivers/stemodem/radio-settings.c \
drivers/stemodem/gprs-context.c \
drivers/stemodem/caif_socket.h \
drivers/stemodem/if_caif.h
+
builtin_modules += phonesim
builtin_sources += plugins/phonesim.c
diff --git a/drivers/stemodem/radio-settings.c
b/drivers/stemodem/radio-settings.c
new file mode 100644
index 000..9f93695
--- /dev/null
+++ b/drivers/stemodem/radio-settings.c
@@ -0,0 +1,230 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2010 ST-Ericsson AB.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#define _GNU_SOURCE
+#include string.h
+#include stdlib.h
+#include stdio.h
+#include errno.h
+
+#include glib.h
+
+#include ofono/log.h
+#include ofono/modem.h
+#include ofono/radio-settings.h
+
+#include gatchat.h
+#include gatresult.h
+
+#include stemodem.h
+
+static const char *none_prefix[] = { NULL };
+static const char *cfun_prefix[] = { +CFUN:, NULL };
+
+struct radio_settings_data {
+ GAtChat *chat;
+};
+
+enum ste_radio_mode {
+ STE_RADIO_OFF = 0,
+ STE_RADIO_ON = 1,
+ STE_RADIO_FLIGHT_MODE = 4,
+ STE_RADIO_GSM_ONLY =5,
+ STE_RADIO_WCDMA_ONLY = 6
+};
+
+static gboolean ste_mode_to_ofono_mode(enum ste_radio_mode stemode,
+ enum ofono_radio_access_mode *mode)
+{
+ switch (stemode) {
+ case STE_RADIO_ON:
+ *mode = OFONO_RADIO_ACCESS_MODE_ANY;
+ return TRUE;
+ case STE_RADIO_GSM_ONLY:
+ *mode = OFONO_RADIO_ACCESS_MODE_GSM;
+ return TRUE;
+ case STE_RADIO_WCDMA_ONLY:
+ *mode = OFONO_RADIO_ACCESS_MODE_UMTS;
+ return TRUE;
+ case STE_RADIO_OFF:
+ case STE_RADIO_FLIGHT_MODE:
+ break;
+ }
+
+ return FALSE;
+}
+
+static gboolean ofono_mode_to_ste_mode(enum ofono_radio_access_mode mode,
+ enum ste_radio_mode *stemode)
+{
+ switch (mode) {
+ case OFONO_RADIO_ACCESS_MODE_ANY:
+ *stemode = STE_RADIO_ON;
+ return TRUE;
+ case OFONO_RADIO_ACCESS_MODE_GSM:
+ *stemode = STE_RADIO_GSM_ONLY;
+ return TRUE;
+ case OFONO_RADIO_ACCESS_MODE_UMTS:
+ *stemode = STE_RADIO_WCDMA_ONLY;
+ return TRUE;
+ case OFONO_RADIO_ACCESS_MODE_LTE:
+ break;
+ }
+
+ return FALSE;
+}
+
+static void rat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_radio_settings_rat_mode_query_cb_t cb = cbd-cb;
+ enum ofono_radio_access_mode mode;
+ struct ofono_error error;
+ GAtResultIter iter;
+ int value;
+
+ decode_at_error(error, g_at_result_final_response(result));
+
+ if (!ok) {
+ cb(error, -1, cbd-data);
+ return;
+ }
+
+ g_at_result_iter_init(iter, result);
+
+ if (!g_at_result_iter_next(iter, +CFUN:))
+ goto err;
+
+ if (!g_at_result_iter_next_number(iter, value))
+ goto err;
+
+ if (!ste_mode_to_ofono_mode(value, mode))
+ goto err;
+
+ CALLBACK_WITH_SUCCESS(cb, mode, cbd-data);
+
+ return;
+
+err:
+ CALLBACK_WITH_FAILURE(cb, -1, cbd-data);
+}
+