diff options
author | Denis Kenzior <denkenz@gmail.com> | 2015-04-22 17:57:53 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2015-05-13 09:57:52 -0500 |
commit | bce5d9579c045482bb54f51564a3ce3277c3fc6f (patch) | |
tree | 27435f1d58de44034f0a6981d6039e6c10aff770 /gatchat | |
parent | 1c2987670d48bea015a7988837fb8ff8d4b8e81b (diff) | |
download | ofono-bce5d9579c045482bb54f51564a3ce3277c3fc6f.tar.bz2 |
gatchat: Introduce g_at_chat_get_userdata
Diffstat (limited to 'gatchat')
-rw-r--r-- | gatchat/gatchat.c | 31 | ||||
-rw-r--r-- | gatchat/gatchat.h | 2 |
2 files changed, 33 insertions, 0 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c index aaf6e9b1..33bfc212 100644 --- a/gatchat/gatchat.c +++ b/gatchat/gatchat.c @@ -1135,6 +1135,29 @@ static gboolean at_chat_cancel_group(struct at_chat *chat, guint group) return TRUE; } +static gpointer at_chat_get_userdata(struct at_chat *chat, + guint group, guint id) +{ + GList *l; + struct at_command *c; + + if (chat->command_queue == NULL) + return NULL; + + l = g_queue_find_custom(chat->command_queue, GUINT_TO_POINTER(id), + at_command_compare_by_id); + + if (l == NULL) + return NULL; + + c = l->data; + + if (c->gid != group) + return NULL; + + return c->user_data; +} + static guint at_chat_register(struct at_chat *chat, guint group, const char *prefix, GAtNotifyFunc func, gboolean expect_pdu, gpointer user_data, @@ -1540,6 +1563,14 @@ gboolean g_at_chat_cancel_all(GAtChat *chat) return at_chat_cancel_group(chat->parent, chat->group); } +gpointer g_at_chat_get_userdata(GAtChat *chat, guint id) +{ + if (chat == NULL) + return NULL; + + return at_chat_get_userdata(chat->parent, chat->group, id); +} + guint g_at_chat_register(GAtChat *chat, const char *prefix, GAtNotifyFunc func, gboolean expect_pdu, gpointer user_data, diff --git a/gatchat/gatchat.h b/gatchat/gatchat.h index 367581ee..7290b34f 100644 --- a/gatchat/gatchat.h +++ b/gatchat/gatchat.h @@ -150,6 +150,8 @@ guint g_at_chat_send_and_expect_short_prompt(GAtChat *chat, const char *cmd, gboolean g_at_chat_cancel(GAtChat *chat, guint id); gboolean g_at_chat_cancel_all(GAtChat *chat); +gpointer g_at_chat_get_userdata(GAtChat *chat, guint id); + guint g_at_chat_register(GAtChat *chat, const char *prefix, GAtNotifyFunc func, gboolean expect_pdu, gpointer user_data, GDestroyNotify notify); |