It's used to either dial voicecall or GPRS dial up.
---
 src/emulator.c |   78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/ofono.h    |    8 ++++++
 2 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index e66e9ca..1063b0c 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -115,6 +115,80 @@ static const char *emulator_build_path(const struct 
ofono_emulator *oe,
        return path;
 }
 
+static void dial_common_cb(GAtServerResult res, void *user_data)
+{
+       struct emulator *e = user_data;
+       GAtServer *server = e->server;
+
+       g_at_server_send_final(server, res);
+
+       e->status = OFONO_EMULATOR_STATUS_IDLE;
+
+       notify_status_watches(e, NULL);
+}
+
+static gboolean dial_call(struct emulator *e, const char *dial_str)
+{
+       struct ofono_emulator_dial_req *req = NULL;
+
+       DBG("dial call %s", dial_str);
+
+       req = g_try_new0(struct ofono_emulator_dial_req, 1);
+       if (!req)
+               return FALSE;
+
+       req->dial_str = dial_str;
+       req->cb = dial_common_cb;
+       req->data = e;
+
+       if (dial_str[0] == '*' || dial_str[0] == '#') {
+               /* Supplementary service request */
+               g_at_server_send_intermediate(e->server, "CONNECT");
+
+               e->status = OFONO_EMULATOR_STATUS_GPRS_CONNECT;
+
+               notify_status_watches(e, req);
+       } else {
+               e->status = OFONO_EMULATOR_STATUS_DIAL_VOICECALL;
+
+               notify_status_watches(e, req);
+       }
+
+       g_free(req);
+
+       return TRUE;
+}
+
+static void dial_cb(GAtServerRequestType type, GAtResult *result,
+                                       gpointer user_data)
+{
+       struct emulator *e = user_data;
+       GAtServer *server = e->server;
+       GAtServerResult res = G_AT_SERVER_RESULT_ERROR;
+       GAtResultIter iter;
+       const char *dial_str;
+
+       if (type != G_AT_SERVER_REQUEST_TYPE_SET)
+               goto error;
+
+       g_at_result_iter_init(&iter, result);
+
+       if (!g_at_result_iter_next(&iter, "D"))
+               goto error;
+
+       dial_str = g_at_result_iter_raw_line(&iter);
+       if (!dial_str)
+               goto error;
+
+       if (!dial_call(e, dial_str))
+               goto error;
+
+       return;
+
+error:
+       g_at_server_send_final(server, res);
+}
+
 static void emulator_remove(void *data)
 {
        struct emulator *e = data;
@@ -128,6 +202,8 @@ static void emulator_remove(void *data)
        oe->emulator_list = g_slist_remove(oe->emulator_list, e);
        emulator_release_id(oe, e->id);
 
+       g_at_server_unregister(server, "D");
+
        g_at_server_shutdown(server);
        g_at_server_unref(server);
        server = NULL;
@@ -163,6 +239,8 @@ static struct emulator *emulator_create(struct 
ofono_emulator *oe,
        e->server = server;
        e->status = OFONO_EMULATOR_STATUS_CREATE;
 
+       g_at_server_register(e->server, "D", dial_cb, e, NULL);
+
        oe->emulator_list = g_slist_prepend(oe->emulator_list, e);
 
        notify_status_watches(e, NULL);
diff --git a/src/ofono.h b/src/ofono.h
index 047260c..e1d272e 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -287,6 +287,14 @@ enum ofono_emulator_type {
        OFONO_EMULATOR_TYPE_SPP,
 };
 
+typedef void (*ofono_emulator_cb_t)(enum _GAtServerResult res, void *data);
+
+struct ofono_emulator_dial_req {
+       const char *dial_str;
+       ofono_emulator_cb_t cb;
+       void *data;
+};
+
 typedef void (*ofono_emulator_status_notify_cb_t)(struct emulator *e,
                                        enum ofono_emulator_status status,
                                        void *data, void *user_data);
-- 
1.6.3.3

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to