---
Changes since last patch set:
o Moved updates to plugins/ste to separate patch.
o Updated error handling.
o Style issues.
Makefile.am |4 +-
drivers/stemodem/radio-settings.c | 223 +
drivers/stemodem/stemodem.c |2 +
drivers/stemodem/stemodem.h |2 +
4 files changed, 230 insertions(+), 1 deletions(-)
create mode 100644 drivers/stemodem/radio-settings.c
diff --git a/Makefile.am b/Makefile.am
index 2f0b745..3e1efde 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -204,7 +204,9 @@ builtin_sources += drivers/atmodem/atutil.h \
drivers/stemodem/voicecall.c \
drivers/stemodem/gprs-context.c \
drivers/stemodem/caif_socket.h \
- drivers/stemodem/if_caif.h
+ drivers/stemodem/if_caif.h \
+ drivers/stemodem/radio-settings.c
+
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..0c5b438
--- /dev/null
+++ b/drivers/stemodem/radio-settings.c
@@ -0,0 +1,223 @@
+/*
+ *
+ * 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
+#endif
+
+#define _GNU_SOURCE
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+
+#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;
+ default:
+ 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;
+ default:
+ return FALSE;
+ }
+}
+
+static void sterat_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;
+ 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);
+}
+
+static void ste_query_rat_mode(struct ofono_radio_settings *rs,
+ ofono_radio_settings_rat_mode_query_cb_t cb,
+ void *data)
+{
+ struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ if (g_