diff options
author | Denis Kenzior <denkenz@gmail.com> | 2014-01-20 21:42:13 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2014-10-20 13:40:27 -0500 |
commit | 02c5b73f6e3882ae2872ce9653289cda391e9cc5 (patch) | |
tree | 1215577abad70b2272decc25bbf52012642f88ff | |
parent | 0727da1d5b004da0361f0a807ecbef2339cb35e2 (diff) | |
download | ofono-02c5b73f6e3882ae2872ce9653289cda391e9cc5.tar.bz2 |
emulator: Fix CHLD=? not treated as part of SLC
-rw-r--r-- | src/emulator.c | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/src/emulator.c b/src/emulator.c index 6171525e..95697d35 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -1073,16 +1073,11 @@ struct ofono_emulator_request { }; static void handler_proxy(GAtServer *server, GAtServerRequestType type, - GAtResult *result, gpointer userdata) + GAtResult *result, gpointer userdata) { struct handler *h = userdata; struct ofono_emulator_request req; - if (h->em->type == OFONO_EMULATOR_TYPE_HFP && h->em->slc == FALSE) { - g_at_server_send_final(h->em->server, G_AT_SERVER_RESULT_ERROR); - return; - } - switch (type) { case G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY: req.type = OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY; @@ -1103,6 +1098,33 @@ static void handler_proxy(GAtServer *server, GAtServerRequestType type, h->cb(h->em, &req, h->data); } +static void handler_proxy_need_slc(GAtServer *server, + GAtServerRequestType type, + GAtResult *result, gpointer userdata) +{ + struct handler *h = userdata; + + if (h->em->slc == FALSE) { + g_at_server_send_final(h->em->server, G_AT_SERVER_RESULT_ERROR); + return; + } + + handler_proxy(server, type, result, userdata); +} + +static void handler_proxy_chld(GAtServer *server, GAtServerRequestType type, + GAtResult *result, gpointer userdata) +{ + struct handler *h = userdata; + + if (h->em->slc == FALSE && type != G_AT_SERVER_REQUEST_TYPE_SUPPORT) { + g_at_server_send_final(h->em->server, G_AT_SERVER_RESULT_ERROR); + return; + } + + handler_proxy(server, type, result, userdata); +} + static void handler_destroy(gpointer userdata) { struct handler *h = userdata; @@ -1119,6 +1141,7 @@ ofono_bool_t ofono_emulator_add_handler(struct ofono_emulator *em, void *data, ofono_destroy_func destroy) { struct handler *h; + GAtServerNotifyFunc func = handler_proxy; h = g_new0(struct handler, 1); h->cb = cb; @@ -1126,7 +1149,14 @@ ofono_bool_t ofono_emulator_add_handler(struct ofono_emulator *em, h->destroy = destroy; h->em = em; - if (g_at_server_register(em->server, prefix, handler_proxy, h, + if (em->type == OFONO_EMULATOR_TYPE_HFP) { + func = handler_proxy_need_slc; + + if (!strcmp(prefix, "+CHLD")) + func = handler_proxy_chld; + } + + if (g_at_server_register(em->server, prefix, func, h, handler_destroy) == TRUE) return TRUE; |