From 5f47eca7ed59706bbcee257d8fff7ad29e2fd32d Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 12 Aug 2010 10:14:53 -0500 Subject: gatchat: Add g_at_chat_clone This function will clone a chat object, but will create a new group internally. --- gatchat/gatchat.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'gatchat/gatchat.c') 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) -- cgit v1.2.3