From: Aki Niemi Date: Sat, 22 Aug 2009 15:01:24 +0000 (+0300) Subject: gisi: Add debugging hooks X-Git-Tag: 0.4~93 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=197cefbba552845955b7cde4c9646fc7940b568e;p=platform%2Fupstream%2Fofono.git gisi: Add debugging hooks --- diff --git a/gisi/client.c b/gisi/client.c index 8f42565..06454c4 100644 --- a/gisi/client.c +++ b/gisi/client.c @@ -58,6 +58,10 @@ struct _GIsiClient { GIsiIndicationFunc func[256]; void *data[256]; } ind; + + /* Debugging */ + GIsiDebugFunc debug_func; + void *debug_data; }; static gboolean g_isi_callback(GIOChannel *channel, GIOCondition cond, @@ -136,6 +140,23 @@ uint8_t g_isi_client_resource(GIsiClient *client) } /** + * Set a debugging function for @a client. This function will be + * called whenever an ISI protocol message is sent or received. + * @param client client to debug + * @param func debug function + * @param opaque user data + */ +void g_isi_client_set_debug(GIsiClient *client, GIsiDebugFunc func, + void *opaque) +{ + if (!client) + return; + + client->debug_func = func; + client->debug_data = opaque; +} + +/** * Destroys an ISI client, cancels all pending transactions and subscriptions. * @param client client to destroy */ @@ -202,6 +223,9 @@ GIsiRequest *g_isi_request_make(GIsiClient *cl, const void *__restrict buf, return NULL; } + if (cl->debug_func) + cl->debug_func(buf, len, cl->debug_data); + cl->func[id] = cb; cl->data[id] = opaque; @@ -360,6 +384,10 @@ static gboolean g_isi_callback(GIOChannel *channel, GIOCondition cond, return TRUE; msg = (uint8_t *)buf; + + if (cl->debug_func) + cl->debug_func(msg, len, cl->debug_data); + if (indication) { /* Message ID at offset 1 */ id = msg[1]; diff --git a/gisi/client.h b/gisi/client.h index 8f9c7bf..448f9e5 100644 --- a/gisi/client.h +++ b/gisi/client.h @@ -46,10 +46,16 @@ typedef void (*GIsiIndicationFunc) (GIsiClient *client, const void *restrict data, size_t len, uint16_t object, void *opaque); +typedef void (*GIsiDebugFunc) (const void *restrict data, size_t len, + void *opaque); + GIsiClient *g_isi_client_create(GIsiModem *modem, uint8_t resource); uint8_t g_isi_client_resource(GIsiClient *client); +void g_isi_client_set_debug(GIsiClient *client, GIsiDebugFunc func, + void *opaque); + void g_isi_client_destroy(GIsiClient *client); int g_isi_client_error(const GIsiClient *client);