From 5ffe6f7beb1904a1ee745c925bac65f71e012994 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Sat, 26 Feb 2011 00:12:02 -0600 Subject: [PATCH] gatio: Add write 'done' notifier This allows external clients to get notified when GAtIO no longer has a registered write watcher. E.g. no more data is currently pending. --- gatchat/gatio.c | 18 ++++++++++++++++++ gatchat/gatio.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/gatchat/gatio.c b/gatchat/gatio.c index 9d44a780..e6556200 100644 --- a/gatchat/gatio.c +++ b/gatchat/gatio.c @@ -52,6 +52,8 @@ struct _GAtIO { gpointer write_data; /* Write callback userdata */ GAtDebugFunc debugf; /* debugging output function */ gpointer debug_data; /* Data to pass to debug func */ + GAtDisconnectFunc write_done_func; + gpointer write_done_data; gboolean destroyed; /* Re-entrancy guard */ }; @@ -158,6 +160,12 @@ static void write_watcher_destroy_notify(gpointer user_data) io->write_watch = 0; io->write_handler = NULL; io->write_data = NULL; + + if (io->write_done_func) { + io->write_done_func(io->write_done_data); + io->write_done_func = NULL; + io->write_done_data = NULL; + } } static gboolean can_write_data(GIOChannel *channel, GIOCondition cond, @@ -370,3 +378,13 @@ gboolean g_at_io_set_debug(GAtIO *io, GAtDebugFunc func, gpointer user_data) return TRUE; } + +void g_at_io_set_write_done(GAtIO *io, GAtDisconnectFunc func, + gpointer user_data) +{ + if (io == NULL) + return; + + io->write_done_func = func; + io->write_done_data = user_data; +} diff --git a/gatchat/gatio.h b/gatchat/gatio.h index 5a9f9f93..ca9618fd 100644 --- a/gatchat/gatio.h +++ b/gatchat/gatio.h @@ -49,6 +49,9 @@ gboolean g_at_io_set_read_handler(GAtIO *io, GAtIOReadFunc read_handler, gpointer user_data); gboolean g_at_io_set_write_handler(GAtIO *io, GAtIOWriteFunc write_handler, gpointer user_data); +void g_at_io_set_write_done(GAtIO *io, GAtDisconnectFunc func, + gpointer user_data); + gsize g_at_io_write(GAtIO *io, const gchar *data, gsize count); gboolean g_at_io_set_disconnect_function(GAtIO *io,