mirror of git://git.sysmocom.de/ofono
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.
This commit is contained in:
parent
3f2f11fe8f
commit
5ffe6f7beb
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue