summaryrefslogtreecommitdiffstats
path: root/gatchat/gatchat.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-04-27 17:05:58 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-04-28 17:27:33 -0500
commit3aa1faddef0b6542da8a0ee5e8aeb8f1c73b87c1 (patch)
treec7881e82b898773c94d3937a6a2ae6b02bd63790 /gatchat/gatchat.c
parent7b8f4f5dc8d70c68edab0e17851bff65db598b00 (diff)
downloadofono-3aa1faddef0b6542da8a0ee5e8aeb8f1c73b87c1.tar.bz2
gatchat: Replace shutdown by suspend/resume
Shutdown was actually pointless and according to Marcel he only had it in mind for PPP useage.
Diffstat (limited to 'gatchat/gatchat.c')
-rw-r--r--gatchat/gatchat.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c
index dadee1fe..fc289198 100644
--- a/gatchat/gatchat.c
+++ b/gatchat/gatchat.c
@@ -79,6 +79,7 @@ struct _GAtChat {
GAtDisconnectFunc user_disconnect; /* user disconnect func */
gpointer user_disconnect_data; /* user disconnect data */
guint read_so_far; /* Number of bytes processed */
+ gboolean suspended; /* Are we suspended? */
GAtDebugFunc debugf; /* debugging output function */
gpointer debug_data; /* Data to pass to debug func */
char *pdu_notify; /* Unsolicited Resp w/ PDU */
@@ -638,7 +639,7 @@ static void new_bytes(struct ring_buffer *rbuf, gpointer user_data)
g_at_chat_ref(p);
- while (p->channel && (p->read_so_far < len)) {
+ while (p->suspended == FALSE && (p->read_so_far < len)) {
gsize rbytes = MIN(len - p->read_so_far, wrap - p->read_so_far);
result = p->syntax->feed(p->syntax, (char *)buf, &rbytes);
@@ -933,6 +934,28 @@ GAtChat *g_at_chat_ref(GAtChat *chat)
return chat;
}
+void g_at_chat_suspend(GAtChat *chat)
+{
+ if (chat == NULL)
+ return;
+
+ chat->suspended = TRUE;
+
+ g_at_io_set_read_handler(chat->io, NULL, NULL);
+ g_at_io_set_debug(chat->io, NULL, NULL);
+}
+
+void g_at_chat_resume(GAtChat *chat)
+{
+ if (chat == NULL)
+ return;
+
+ chat->suspended = FALSE;
+
+ g_at_io_set_read_handler(chat->io, new_bytes, chat);
+ g_at_io_set_debug(chat->io, chat->debugf, chat->debug_data);
+}
+
void g_at_chat_unref(GAtChat *chat)
{
gboolean is_zero;
@@ -945,23 +968,15 @@ void g_at_chat_unref(GAtChat *chat)
if (is_zero == FALSE)
return;
- g_at_chat_shutdown(chat);
- g_free(chat);
-}
-
-gboolean g_at_chat_shutdown(GAtChat *chat)
-{
- if (chat->io == NULL)
- return FALSE;
-
if (chat->write_watch)
g_source_remove(chat->write_watch);
- g_at_io_set_read_handler(chat->io, NULL, NULL);
+ g_at_chat_suspend(chat);
+
g_at_io_unref(chat->io);
g_at_chat_cleanup(chat);
- return TRUE;
+ g_free(chat);
}
gboolean g_at_chat_set_disconnect_function(GAtChat *chat,