Skip to contentSkip to conversation

Allow use of from_io constructor

PATCH In review Kristen Carlson Accardi 2 participants 5 messages May 10, 2010

lore
Share & tools
lore
#0 lore raw

cover Allow use of from_io constructor

Create a way to get the GAtIO object from GAtChat. Use it to call g_at_ppp_new_from_io so that g_at_chat_suspend will work properly.

Kristen Carlson Accardi (3):
gsmdial: use g_at_chat_suspend
gatchat: implement g_at_chat_get_io()
gsmdial: use g_at_ppp_new_from_io()

 gatchat/gatchat.c |    8 ++++++++
 gatchat/gatchat.h |    2 ++
 gatchat/gsmdial.c |   14 +++++++-------
 3 files changed, 17 insertions(+), 7 deletions(-)
#1 lore raw

PATCH 1/3 gsmdial: use g_at_chat_suspend

---
 gatchat/gsmdial.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
gatchat/gsmdial.c +4 -4
index a531aa3..fd9b73b 100644
@@ -235,6 +235,8 @@ static void ppp_connect(const char *iface, const char *ip,
 static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
 {
 	g_print("PPP Link down: %d\n", reason);
+	g_at_chat_resume(control);
+	g_at_chat_resume(modem);
 }
 
 static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -253,10 +255,8 @@ static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	 * shutdown gatchat or else it tries to take all the input
 	 * from the modem and does not let PPP get it.
 	 */
-	g_at_chat_unref(control);
-	control = NULL;
-	g_at_chat_unref(modem);
-	modem = NULL;
+	g_at_chat_suspend(control);
+	g_at_chat_suspend(modem);
 
 	/* open ppp */
 	ppp = g_at_ppp_new(channel);
Signature · 1 line
1.6.6.1
#2 lore raw

PATCH 2/3 gatchat: implement g_at_chat_get_io()

In reply to Kristen Carlson Accardi
---
 gatchat/gatchat.c |    8 ++++++++
 gatchat/gatchat.h |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)
gatchat/gatchat.c +8 -0
index f94605f..3f238a2 100644
@@ -876,6 +876,14 @@ GIOChannel *g_at_chat_get_channel(GAtChat *chat)
 	return g_at_io_get_channel(chat->io);
 }
 
+GAtIO *g_at_chat_get_io(GAtChat *chat)
+{
+	if (chat == NULL)
+		return NULL;
+
+	return chat->io;
+}
+
 GAtChat *g_at_chat_ref(GAtChat *chat)
 {
 	if (chat == NULL)
gatchat/gatchat.h +2 -0
index ea6626e..9fd7ced 100644
@@ -29,6 +29,7 @@ extern "C" {
 #include "gatresult.h"
 #include "gatsyntax.h"
 #include "gatutil.h"
+#include "gatio.h"
 
 struct _GAtChat;
 
@@ -42,6 +43,7 @@ GAtChat *g_at_chat_new(GIOChannel *channel, GAtSyntax *syntax);
 GAtChat *g_at_chat_new_blocking(GIOChannel *channel, GAtSyntax *syntax);
 
 GIOChannel *g_at_chat_get_channel(GAtChat *chat);
+GAtIO *g_at_chat_get_io(GAtChat *chat);
 
 GAtChat *g_at_chat_ref(GAtChat *chat);
 void g_at_chat_unref(GAtChat *chat);
Signature · 1 line
1.6.6.1
#3 lore raw

PATCH 3/3 gsmdial: use g_at_ppp_new_from_io()

In reply to Kristen Carlson Accardi
---
 gatchat/gsmdial.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
gatchat/gsmdial.c +3 -3
index fd9b73b..cfdec87 100644
@@ -241,7 +241,7 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
 
 static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
-	GIOChannel *channel;
+	GAtIO *io;
 
 	if (!ok) {
 		g_print("Unable to define context\n");
@@ -249,7 +249,7 @@ static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	}
 
 	/* get the data IO channel */
-	channel = g_at_chat_get_channel(modem);
+	io = g_at_chat_get_io(modem);
 
 	/*
 	 * shutdown gatchat or else it tries to take all the input
@@ -259,7 +259,7 @@ static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	g_at_chat_suspend(modem);
 
 	/* open ppp */
-	ppp = g_at_ppp_new(channel);
+	ppp = g_at_ppp_new_from_io(io);
 	if (!ppp) {
 		g_print("Unable to create PPP object\n");
 		exit(1);
Signature · 1 line
1.6.6.1
#4 lore raw
In reply to Kristen Carlson Accardi

Hi Kristen,

Quoted 8 lines

Create a way to get the GAtIO object from GAtChat. Use it to call g_at_ppp_new_from_io so that g_at_chat_suspend will work properly.

Kristen Carlson Accardi (3):
gsmdial: use g_at_chat_suspend
gatchat: implement g_at_chat_get_io()
gsmdial: use g_at_ppp_new_from_io()

Quoted 5 lines
 gatchat/gatchat.c |    8 ++++++++
 gatchat/gatchat.h |    2 ++
 gatchat/gsmdial.c |   14 +++++++-------
 3 files changed, 17 insertions(+), 7 deletions(-)

All three have been applied, thanks.

Regards,
-Denis