summaryrefslogtreecommitdiffstats
path: root/gatchat/gatchat.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-12-02 15:28:44 -0600
committerDenis Kenzior <denkenz@gmail.com>2009-12-02 19:10:04 -0600
commitcf98ebb6533223bf1ce998d3fbfde3f372951ba5 (patch)
tree3055c1d0f7a6d3ff8022d68dec22d4263a59a468 /gatchat/gatchat.c
parent9b5b1057e4403c8bc008f8f6d2d2cbcb04e5ed9a (diff)
downloadofono-cf98ebb6533223bf1ce998d3fbfde3f372951ba5.tar.bz2
Add: g_at_chat_cancel_all function
This will cancel all commands currently queued.
Diffstat (limited to 'gatchat/gatchat.c')
-rw-r--r--gatchat/gatchat.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c
index df659066..54e64340 100644
--- a/gatchat/gatchat.c
+++ b/gatchat/gatchat.c
@@ -1219,6 +1219,33 @@ gboolean g_at_chat_cancel(GAtChat *chat, guint id)
return TRUE;
}
+gboolean g_at_chat_cancel_all(GAtChat *chat)
+{
+ int n = 0;
+ struct at_command *c;
+
+ if (chat == NULL || chat->command_queue == NULL)
+ return FALSE;
+
+ while ((c = g_queue_peek_nth(chat->command_queue, n)) != NULL) {
+ if (c->id == 0) {
+ n += 1;
+ continue;
+ }
+
+ if (n == 0 && chat->cmd_bytes_written > 0) {
+ c->callback = NULL;
+ n += 1;
+ continue;
+ }
+
+ at_command_destroy(c);
+ g_queue_remove(chat->command_queue, c);
+ }
+
+ return TRUE;
+}
+
static struct at_notify *at_notify_create(GAtChat *chat, const char *prefix,
gboolean pdu)
{