[PATCH 06/11] Add notify at command callback

Zhenhua Zhang zhenhua.zhang at intel.com
Wed Mar 17 07:30:36 PDT 2010


---
 gatchat/gatserver.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/gatchat/gatserver.c b/gatchat/gatserver.c
index bbaef52..6e3347c 100644
--- a/gatchat/gatserver.c
+++ b/gatchat/gatserver.c
@@ -227,10 +227,48 @@ 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 GAtServerResult 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)
+			return res;
+
+		result.lines = g_slist_prepend(NULL, command);
+		result.final_or_pdu = 0;
+
+		res = node->notify(type, &result, node->user_data);
+	}
 
 	return res;
 }
-- 
1.6.6.1



More information about the ofono mailing list