summaryrefslogtreecommitdiffstats
path: root/gatchat/gatserver.c
diff options
context:
space:
mode:
authorZhenhua Zhang <zhenhua.zhang@intel.com>2010-03-19 17:44:43 +0800
committerDenis Kenzior <denkenz@gmail.com>2010-03-22 12:59:04 -0500
commit60cf097ffdac13fffc1bc9cba2d986b28049daf2 (patch)
treec6d3a48e14a9e422ce1bbef97828f64a0eec82ba /gatchat/gatserver.c
parent8850d3dc9ef5ee1cb6aaa5b6291e879d98dc56d2 (diff)
downloadofono-60cf097ffdac13fffc1bc9cba2d986b28049daf2.tar.bz2
Add notify at command callback
Diffstat (limited to 'gatchat/gatserver.c')
-rw-r--r--gatchat/gatserver.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/gatchat/gatserver.c b/gatchat/gatserver.c
index cb73b890..3cf6200f 100644
--- a/gatchat/gatserver.c
+++ b/gatchat/gatserver.c
@@ -227,9 +227,57 @@ static gboolean is_extended_character(const char c)
}
}
+static GAtServerRequestType get_command_type(char *buf, char *prefix)
+{
+ GAtServerRequestType type = G_AT_SERVER_REQUEST_TYPE_ERROR;
+
+ buf += strlen(prefix);
+
+ if (buf[0] == '\0')
+ /* Action command could have no sub-parameters */
+ type = G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY;
+ else if (buf[0] == '?')
+ type = G_AT_SERVER_REQUEST_TYPE_QUERY;
+ else if (buf[0] == '=' && buf[1] == '?')
+ type = G_AT_SERVER_REQUEST_TYPE_SUPPORT;
+ else if (buf[0] == '=')
+ type = G_AT_SERVER_REQUEST_TYPE_SET;
+ else if (is_basic_command_prefix(prefix))
+ /* Basic command could follow digits value, like ATE1 */
+ type = G_AT_SERVER_REQUEST_TYPE_SET;
+
+ return type;
+}
+
static gboolean at_command_notify(GAtServer *server, char *command,
char *prefix)
{
+ GAtServerResult res = G_AT_SERVER_RESULT_ERROR;
+ struct at_command *node;
+
+ node = g_hash_table_lookup(server->command_list, prefix);
+ if (node && node->notify) {
+ GAtServerRequestType type;
+ GAtResult result;
+
+ type = get_command_type(command, prefix);
+ if (type == G_AT_SERVER_REQUEST_TYPE_ERROR)
+ goto done;
+
+ result.lines = g_slist_prepend(NULL, command);
+ result.final_or_pdu = 0;
+
+ res = node->notify(type, &result, node->user_data);
+
+ g_slist_free(result.lines);
+ }
+
+done:
+ g_at_server_send_final(server, res);
+
+ if (res == G_AT_SERVER_RESULT_OK)
+ return TRUE;
+
return FALSE;
}