From 094fdd4e71dff7fe982bab7f6cebc7a8f666ca49 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 6 Sep 2009 00:31:26 +0200 Subject: [PATCH] Add functions for disconnect and debug handling --- gatchat/gatmux.c | 31 +++++++++++++++++++++++++++++-- gatchat/gatmux.h | 7 +++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/gatchat/gatmux.c b/gatchat/gatmux.c index 6c67bfd..aeb5b59 100644 --- a/gatchat/gatmux.c +++ b/gatchat/gatmux.c @@ -35,8 +35,12 @@ #include "gatmux.h" struct _GAtMux { - gint ref_count; /* Ref count */ - GIOChannel *channel; /* channel */ + gint ref_count; /* Ref count */ + GIOChannel *channel; /* channel */ + GAtDisconnectFunc user_disconnect; /* user disconnect func */ + gpointer user_disconnect_data; /* user disconnect data */ + GAtDebugFunc debugf; /* debugging output function */ + gpointer debug_data; /* Data to pass to debug func */ }; GAtMux *g_at_mux_new(GIOChannel *channel) @@ -125,3 +129,26 @@ gboolean g_at_mux_shutdown(GAtMux *mux) return TRUE; } + +gboolean g_at_mux_set_disconnect_function(GAtMux *mux, + GAtDisconnectFunc disconnect, gpointer user_data) +{ + if (mux == NULL) + return FALSE; + + mux->user_disconnect = disconnect; + mux->user_disconnect_data = user_data; + + return TRUE; +} + +gboolean g_at_mux_set_debug(GAtMux *mux, GAtDebugFunc func, gpointer user) +{ + if (mux == NULL) + return FALSE; + + mux->debugf = func; + mux->debug_data = user; + + return TRUE; +} diff --git a/gatchat/gatmux.h b/gatchat/gatmux.h index 397ca75..8bf013d 100644 --- a/gatchat/gatmux.h +++ b/gatchat/gatmux.h @@ -26,6 +26,8 @@ extern "C" { #endif +#include "gatchat.h" + struct _GAtMux; typedef struct _GAtMux GAtMux; @@ -38,6 +40,11 @@ void g_at_mux_unref(GAtMux *mux); gboolean g_at_mux_shutdown(GAtMux *mux); +gboolean g_at_mux_set_disconnect_function(GAtMux *mux, + GAtDisconnectFunc disconnect, gpointer user_data); + +gboolean g_at_mux_set_debug(GAtMux *mux, GAtDebugFunc func, gpointer user); + #ifdef __cplusplus } #endif -- 2.7.4