All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] gatserver: add command finished functions
@ 2011-08-04 14:29 =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-08-04 14:29 ` [PATCH v2 2/2] emulator: fix indicator notification =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-08-04 14:29 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 3407 bytes --]

---
 gatchat/gatserver.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 gatchat/gatserver.h |    7 +++++++
 2 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/gatchat/gatserver.c b/gatchat/gatserver.c
index ab785f7..8e92071 100644
--- a/gatchat/gatserver.c
+++ b/gatchat/gatserver.c
@@ -115,6 +115,9 @@ struct _GAtServer {
 	gpointer user_disconnect_data;		/* User disconnect data */
 	GAtDebugFunc debugf;			/* Debugging output function */
 	gpointer debug_data;			/* Data to pass to debug func */
+	GAtServerFinishFunc finishf;		/* Command finish function */
+	gpointer finish_data;			/* Finish func data */
+	guint finish_source;
 	GHashTable *command_list;		/* List of AT commands */
 	GQueue *write_queue;			/* Write buffer queue */
 	guint max_read_attempts;		/* Max reads per select */
@@ -1177,12 +1180,27 @@ static void server_wakeup_writer(GAtServer *server)
 	g_at_io_set_write_handler(server->io, can_write_data, server);
 }
 
+static gboolean notify_finish(void *user_data)
+{
+	GAtServer *server = user_data;
+
+	server->finishf(server, server->finish_data);
+	server->finish_source = 0;
+
+	return FALSE;
+}
+
 static void server_resume(GAtServer *server)
 {
 	if (server->suspended == FALSE)
 		return;
 
 	server->suspended = FALSE;
+
+	if (server->finishf)
+		server->finish_source = g_timeout_add_seconds(0, notify_finish,
+								server);
+
 	g_at_io_set_read_handler(server->io, new_bytes, server);
 }
 
@@ -1336,6 +1354,11 @@ void g_at_server_unref(GAtServer *server)
 	if (server == NULL)
 		return;
 
+	if (server->finish_source) {
+		g_source_remove(server->finish_source);
+		server->finish_source = 0;
+	}
+
 	is_zero = g_atomic_int_dec_and_test(&server->ref_count);
 
 	if (is_zero == FALSE)
@@ -1455,3 +1478,24 @@ gboolean g_at_server_unregister(GAtServer *server, const char *prefix)
 
 	return TRUE;
 }
+
+gboolean g_at_server_set_finish_callback(GAtServer *server,
+					GAtServerFinishFunc finish,
+					gpointer user_data)
+{
+	if (server == NULL)
+		return FALSE;
+
+	server->finishf = finish;
+	server->finish_data = user_data;
+
+	return TRUE;
+}
+
+gboolean g_at_server_command_pending(GAtServer *server)
+{
+	if (server == NULL)
+		return FALSE;
+
+	return server->suspended;
+}
diff --git a/gatchat/gatserver.h b/gatchat/gatserver.h
index bb0ae84..599c992 100644
--- a/gatchat/gatserver.h
+++ b/gatchat/gatserver.h
@@ -69,6 +69,8 @@ typedef void (*GAtServerNotifyFunc)(GAtServer *server,
 					GAtServerRequestType type,
 					GAtResult *result, gpointer user_data);
 
+typedef void (*GAtServerFinishFunc)(GAtServer *server, gpointer user_data);
+
 GAtServer *g_at_server_new(GIOChannel *io);
 GIOChannel *g_at_server_get_channel(GAtServer *server);
 GAtIO *g_at_server_get_io(GAtServer *server);
@@ -94,6 +96,11 @@ gboolean g_at_server_register(GAtServer *server, const char *prefix,
 					GDestroyNotify destroy_notify);
 gboolean g_at_server_unregister(GAtServer *server, const char *prefix);
 
+gboolean g_at_server_set_finish_callback(GAtServer *server,
+					GAtServerFinishFunc finish,
+					gpointer user_data);
+gboolean g_at_server_command_pending(GAtServer *server);
+
 /* Send a final result code. E.g. G_AT_SERVER_RESULT_NO_DIALTONE */
 void g_at_server_send_final(GAtServer *server, GAtServerResult result);
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-08-15  5:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-04 14:29 [PATCH v2 1/2] gatserver: add command finished functions =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-08-04 14:29 ` [PATCH v2 2/2] emulator: fix indicator notification =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-08-15  5:24   ` Denis Kenzior
2011-08-12  7:00 ` [PATCH v2 1/2] gatserver: add command finished functions Denis Kenzior
2011-08-15  5:32 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.