diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-08-12 10:14:53 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-08-12 16:06:32 -0500 |
commit | 5f47eca7ed59706bbcee257d8fff7ad29e2fd32d (patch) | |
tree | fd37be0808030e3f5f66f97edbe97fe3a344061e /gatchat/gatchat.c | |
parent | 2356ebf9ef8796226aa17092366b62af0f00b73a (diff) | |
download | ofono-5f47eca7ed59706bbcee257d8fff7ad29e2fd32d.tar.bz2 |
gatchat: Add g_at_chat_clone
This function will clone a chat object, but will create a new group
internally.
Diffstat (limited to 'gatchat/gatchat.c')
-rw-r--r-- | gatchat/gatchat.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c index 31ec81e5..8f060eeb 100644 --- a/gatchat/gatchat.c +++ b/gatchat/gatchat.c @@ -1231,6 +1231,25 @@ GAtChat *g_at_chat_new_blocking(GIOChannel *channel, GAtSyntax *syntax) return g_at_chat_new_common(channel, 0, syntax); } +GAtChat *g_at_chat_clone(GAtChat *clone) +{ + GAtChat *chat; + + if (clone == NULL) + return NULL; + + chat = g_try_new0(GAtChat, 1); + if (chat == NULL) + return NULL; + + chat->parent = clone->parent; + chat->group = chat->parent->next_gid++; + chat->ref_count = 1; + g_atomic_int_inc(&chat->parent->ref_count); + + return chat; +} + GIOChannel *g_at_chat_get_channel(GAtChat *chat) { if (chat == NULL || chat->parent->io == NULL) |