gatchat: Add g_at_chat_clone

This function will clone a chat object, but will create a new group
internally.
This commit is contained in:
Denis Kenzior 2010-08-12 10:14:53 -05:00
parent 2356ebf9ef
commit 5f47eca7ed
2 changed files with 21 additions and 0 deletions

View File

@ -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)

View File

@ -48,6 +48,8 @@ GAtIO *g_at_chat_get_io(GAtChat *chat);
GAtChat *g_at_chat_ref(GAtChat *chat);
void g_at_chat_unref(GAtChat *chat);
GAtChat *g_at_chat_clone(GAtChat *chat);
void g_at_chat_suspend(GAtChat *chat);
void g_at_chat_resume(GAtChat *chat);