diff options
Diffstat (limited to 'gatchat')
-rw-r--r-- | gatchat/gatchat.c | 31 | ||||
-rw-r--r-- | gatchat/gatchat.h | 3 |
2 files changed, 34 insertions, 0 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c index d05f4668..f3bd3ec6 100644 --- a/gatchat/gatchat.c +++ b/gatchat/gatchat.c @@ -105,6 +105,7 @@ struct _GAtChat { gint ref_count; struct at_chat *parent; guint group; + GAtChat *slave; }; struct terminator_info { @@ -1304,9 +1305,36 @@ GAtChat *g_at_chat_clone(GAtChat *clone) chat->ref_count = 1; g_atomic_int_inc(&chat->parent->ref_count); + if (clone->slave != NULL) + chat->slave = g_at_chat_clone(clone->slave); + return chat; } +GAtChat *g_at_chat_set_slave(GAtChat *chat, GAtChat *slave) +{ + if (chat == NULL) + return; + + if (chat->slave != NULL) + g_at_chat_unref(chat->slave); + + if (slave != NULL) + chat->slave = g_at_chat_ref(slave); + else + chat->slave = NULL; + + return chat->slave; +} + +GAtChat *g_at_chat_get_slave(GAtChat *chat) +{ + if (chat == NULL) + return NULL; + + return chat->slave; +} + GIOChannel *g_at_chat_get_channel(GAtChat *chat) { if (chat == NULL || chat->parent->io == NULL) @@ -1361,6 +1389,9 @@ void g_at_chat_unref(GAtChat *chat) if (is_zero == FALSE) return; + if (chat->slave != NULL) + g_at_chat_unref(chat->slave); + at_chat_cancel_group(chat->parent, chat->group); g_at_chat_unregister_all(chat); at_chat_unref(chat->parent); diff --git a/gatchat/gatchat.h b/gatchat/gatchat.h index f61fe538..8cbb5598 100644 --- a/gatchat/gatchat.h +++ b/gatchat/gatchat.h @@ -50,6 +50,9 @@ void g_at_chat_unref(GAtChat *chat); GAtChat *g_at_chat_clone(GAtChat *chat); +GAtChat *g_at_chat_set_slave(GAtChat *chat, GAtChat *slave); +GAtChat *g_at_chat_get_slave(GAtChat *chat); + void g_at_chat_suspend(GAtChat *chat); void g_at_chat_resume(GAtChat *chat); |