summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJukka Saunamaki <jukka.saunamaki@nokia.com>2011-01-26 14:34:15 +0200
committerDenis Kenzior <denkenz@gmail.com>2011-01-26 14:55:58 -0600
commitb186231ad207442ceae7864ecd5371c9ca0ce89e (patch)
treebff3bb5339b9839f6880f6c6c3b1cd50bddc6f01 /examples
parent7a5f06dd6aded8062ffef2e63c975b9549f4eff5 (diff)
downloadofono-b186231ad207442ceae7864ecd5371c9ca0ce89e.tar.bz2
gprs-provision: add example context provisioning driver
Diffstat (limited to 'examples')
-rw-r--r--examples/provision.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/examples/provision.c b/examples/provision.c
new file mode 100644
index 00000000..80688a42
--- /dev/null
+++ b/examples/provision.c
@@ -0,0 +1,95 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * 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
+
+#include <string.h>
+#include <glib.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+
+#include <ofono/modem.h>
+#include <ofono/gprs-provision.h>
+#include <ofono/types.h>
+#include <ofono/plugin.h>
+#include <ofono/log.h>
+
+static void example_provision_get_settings(const char *mcc, const char *mnc,
+ struct ofono_gprs_provision_data **settings,
+ int *count)
+{
+ ofono_debug("Provisioning...");
+ *count = 0;
+ *settings = NULL;
+
+ ofono_debug("Finding settings for MCC %s, MNC %s",
+ mcc, mnc);
+
+ if (strcmp(mcc, "246") != 0 || strcmp(mnc, "81") != 0)
+ return;
+
+ ofono_debug("Creating example settings for phonesim");
+
+ *settings = g_try_new0(struct ofono_gprs_provision_data, 2);
+ if (*settings == NULL)
+ return;
+
+ *count = 2;
+
+ /* Internet context settings */
+ (*settings)[0].proto = OFONO_GPRS_PROTO_IP;
+ (*settings)[0].type = OFONO_GPRS_CONTEXT_TYPE_INTERNET;
+ (*settings)[0].name = g_strdup("Phonesim Internet");
+ (*settings)[0].apn = g_strdup("internetapn");
+
+ /* MMS context settings */
+ (*settings)[1].proto = OFONO_GPRS_PROTO_IP;
+ (*settings)[1].type = OFONO_GPRS_CONTEXT_TYPE_MMS;
+ (*settings)[1].name = g_strdup("Phonesim MMS");
+ (*settings)[1].apn = g_strdup("mmsapn");
+ (*settings)[1].username = g_strdup("mmsuser");
+ (*settings)[1].password = g_strdup("mmspass");
+ (*settings)[1].message_proxy = g_strdup("10.11.12.13:8080");
+ (*settings)[1].message_center = g_strdup("http://mms.example.com:8000");
+}
+
+static struct ofono_gprs_provision_driver example_driver = {
+ .name = "Example GPRS context provisioning",
+ .priority = OFONO_PLUGIN_PRIORITY_LOW,
+ .get_settings = example_provision_get_settings,
+};
+
+static int example_provision_init(void)
+{
+ return ofono_gprs_provision_driver_register(&example_driver);
+}
+
+static void example_provision_exit(void)
+{
+ ofono_gprs_provision_driver_unregister(&example_driver);
+}
+
+OFONO_PLUGIN_DEFINE(example_provision, "Example Provisioning Plugin",
+ VERSION, OFONO_PLUGIN_PRIORITY_DEFAULT,
+ example_provision_init,
+ example_provision_exit)