mirror of git://git.sysmocom.de/ofono
Add: g_at_chat_cancel_all function
This will cancel all commands currently queued.
This commit is contained in:
parent
9b5b1057e4
commit
cf98ebb653
|
@ -1219,6 +1219,33 @@ gboolean g_at_chat_cancel(GAtChat *chat, guint id)
|
||||||
return TRUE;
|
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,
|
static struct at_notify *at_notify_create(GAtChat *chat, const char *prefix,
|
||||||
gboolean pdu)
|
gboolean pdu)
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,6 +118,7 @@ guint g_at_chat_send_pdu_listing(GAtChat *chat, const char *cmd,
|
||||||
gpointer user_data, GDestroyNotify notify);
|
gpointer user_data, GDestroyNotify notify);
|
||||||
|
|
||||||
gboolean g_at_chat_cancel(GAtChat *chat, guint id);
|
gboolean g_at_chat_cancel(GAtChat *chat, guint id);
|
||||||
|
gboolean g_at_chat_cancel_all(GAtChat *chat);
|
||||||
|
|
||||||
guint g_at_chat_register(GAtChat *chat, const char *prefix,
|
guint g_at_chat_register(GAtChat *chat, const char *prefix,
|
||||||
GAtNotifyFunc func, gboolean expect_pdu,
|
GAtNotifyFunc func, gboolean expect_pdu,
|
||||||
|
|
Loading…
Reference in New Issue