The server response could be either result code or information text. Result code types: final, intermediate and unsolicited. Information text: one or multiple lines of text. --- gatchat/gatserver.c | 37 +++++++++++++++++++++++++++++++++++++ gatchat/gatserver.h | 11 +++++++++++ 2 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/gatchat/gatserver.c b/gatchat/gatserver.c index 7ac6d34..06ea912 100644 --- a/gatchat/gatserver.c +++ b/gatchat/gatserver.c @@ -196,6 +196,43 @@ static void g_at_server_send_final(GAtServer *server, GAtServerResult result) send_result_common(server, buf); } +void g_at_server_send_intermediate(GAtServer *server, const char *result) +{ + send_result_common(server, result); +} + +void g_at_server_send_unsolicited(GAtServer *server, const char *result) +{ + send_result_common(server, result); +} + +void g_at_server_send_info_text(GAtServer *server, GSList *text) +{ + char buf[MAX_TEXT_SIZE]; + char t = server->v250.s3; + char r = server->v250.s4; + unsigned int len; + GSList *l = text; + char *line; + + if (!text) + return; + + while(l) { + line = l->data; + if (!line) + return; + + len = snprintf(buf, sizeof(buf), "%c%c%s", t, r, line); + send_common(server, buf, MIN(len, sizeof(buf)-1)); + + l = l->next; + } + + len = snprintf(buf, sizeof(buf), "%c%c", t, r); + send_common(server, buf, len); +} + static inline gboolean is_extended_command_prefix(const char c) { switch (c) { diff --git a/gatchat/gatserver.h b/gatchat/gatserver.h index 6fb78bd..19d7cb5 100644 --- a/gatchat/gatserver.h +++ b/gatchat/gatserver.h @@ -88,6 +88,17 @@ gboolean g_at_server_register(GAtServer *server, char *prefix, GDestroyNotify destroy_notify); gboolean g_at_server_unregister(GAtServer *server, const char *prefix); +/* Send an intermediate result code to report the progress. E.g. CONNECT */ +void g_at_server_send_intermediate(GAtServer *server, const char *result); + +/* Send an unsolicited result code. E.g. RING */ +void g_at_server_send_unsolicited(GAtServer *server, const char *result); + +/* Send an information text. The text could contain multiple lines. Each + * line, including line terminators, should not exceed 2048 characters. + */ +void g_at_server_send_info_text(GAtServer *server, GSList *text); + #ifdef __cplusplus } #endif -- 1.6.6.1 _______________________________________________ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono