Open Source Telephony
 help / color / mirror / Atom feed
From: Olivier Guiter <olivier.guiter@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 1/3] gprs.c: add emulator CGDCONT handler
Date: Mon, 21 Mar 2011 14:45:12 +0100	[thread overview]
Message-ID: <1300715114-5790-2-git-send-email-olivier.guiter@linux.intel.com> (raw)
In-Reply-To: <1300715114-5790-1-git-send-email-olivier.guiter@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 3481 bytes --]

---
 src/gprs.c |   64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/src/gprs.c b/src/gprs.c
index 00f6d6d..04432c3 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -90,6 +90,7 @@ struct ofono_gprs {
 	struct ofono_netreg *netreg;
 	unsigned int netreg_watch;
 	unsigned int status_watch;
+	unsigned int dun_watch;
 	GKeyFile *settings;
 	char *imsi;
 	DBusMessage *pending;
@@ -2294,7 +2295,7 @@ struct ofono_modem *ofono_gprs_context_get_modem(struct ofono_gprs_context *gc)
 }
 
 void ofono_gprs_context_set_type(struct ofono_gprs_context *gc,
-                                        enum ofono_gprs_context_type type)
+					enum ofono_gprs_context_type type)
 {
 	DBG("type %d", type);
 
@@ -2862,12 +2863,63 @@ static void provision_contexts(struct ofono_gprs *gprs, const char *mcc,
 	__ofono_gprs_provision_free_settings(settings, count);
 }
 
+/* Process the usual AT+CGDCONT command
+ */
+static void cgdcont_cb(struct ofono_emulator *em,
+			struct ofono_emulator_request *req, void *userdata)
+{
+	struct ofono_error result;
+	char buf[256];
+
+	result.error = 0;
+
+	switch (ofono_emulator_request_get_type(req)) {
+	case OFONO_EMULATOR_REQUEST_TYPE_SUPPORT:
+		/* TODO: check additionnal parameters */
+		snprintf(buf, 255, "+CGDCONT: (1-2),\"IP\",,,(0-2),(0,1,2,3,4)");
+		ofono_emulator_send_info(em, buf, FALSE);
+		result.type = OFONO_ERROR_TYPE_NO_ERROR;
+		ofono_emulator_send_final(em, &result);
+		break;
+
+	case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY:
+		result.type = OFONO_ERROR_TYPE_FAILURE;
+		ofono_emulator_send_final(em, &result);
+		break;
+
+	case OFONO_EMULATOR_REQUEST_TYPE_QUERY:
+		result.type = OFONO_ERROR_TYPE_FAILURE;
+		ofono_emulator_send_final(em, &result);
+		break;
+	case OFONO_EMULATOR_REQUEST_TYPE_SET:
+		result.type = OFONO_ERROR_TYPE_FAILURE;
+		ofono_emulator_send_final(em, &result);
+		break;
+	default:
+		result.type = OFONO_ERROR_TYPE_FAILURE;
+		ofono_emulator_send_final(em, &result);
+	};
+}
+
+static void gprs_dun_watch(struct ofono_atom *atom,
+			enum ofono_atom_watch_condition cond, void *data)
+{
+	struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+	if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED)
+		return;
+
+	ofono_emulator_add_handler(em, "+CGDCONT", cgdcont_cb, data, NULL);
+}
+
+
 static void ofono_gprs_finish_register(struct ofono_gprs *gprs)
 {
 	DBusConnection *conn = ofono_dbus_get_connection();
 	struct ofono_modem *modem = __ofono_atom_get_modem(gprs->atom);
 	const char *path = __ofono_atom_get_path(gprs->atom);
 	struct ofono_atom *netreg_atom;
+	struct ofono_atom *dun_atom;
 
 	if (gprs->contexts == NULL) /* Automatic provisioning failed */
 		add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET);
@@ -2896,6 +2948,16 @@ static void ofono_gprs_finish_register(struct ofono_gprs *gprs)
 		netreg_watch(netreg_atom,
 				OFONO_ATOM_WATCH_CONDITION_REGISTERED, gprs);
 
+	gprs->dun_watch = __ofono_modem_add_atom_watch(modem,
+						OFONO_ATOM_TYPE_EMULATOR_DUN,
+						gprs_dun_watch, gprs, NULL);
+
+	dun_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_EMULATOR_DUN);
+
+	if (dun_atom && __ofono_atom_get_registered(dun_atom))
+		gprs_dun_watch(dun_atom, OFONO_ATOM_WATCH_CONDITION_REGISTERED,
+				gprs);
+
 	__ofono_atom_register(gprs->atom, gprs_unregister);
 }
 
-- 
1.7.1


  reply	other threads:[~2011-03-21 13:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-21 13:45 [PATCH 0/3] Emulator CGDCONT Olivier Guiter
2011-03-21 13:45 ` Olivier Guiter [this message]
2011-03-21 13:45 ` [PATCH 2/3] idmap.c: add get size function Olivier Guiter
2011-03-21 13:45 ` [PATCH 3/3] gprs.c: add list contexts for emulator Olivier Guiter
2011-03-22  2:06   ` Denis Kenzior
2011-03-22 10:49     ` Olivier Guiter
2011-03-22 15:08       ` Denis Kenzior
2011-03-22 15:17         ` Aygon, Bertrand
2011-03-22 17:24           ` Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1300715114-5790-2-git-send-email-olivier.guiter@linux.intel.com \
    --to=olivier.guiter@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox