summaryrefslogtreecommitdiffstats
path: root/gatchat/gatppp.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-04-30 10:52:16 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-04-30 10:52:16 -0500
commitc7ef06f91e32c1fa07a5cf8cf6f6b487eee021a9 (patch)
tree763174159e2a1126d2356c5d51232882c88b7e53 /gatchat/gatppp.c
parent5ef90f934b28cb696b86f7852306f67120cc4046 (diff)
downloadofono-c7ef06f91e32c1fa07a5cf8cf6f6b487eee021a9.tar.bz2
ppp: Add _from_io constructor
Diffstat (limited to 'gatchat/gatppp.c')
-rw-r--r--gatchat/gatppp.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index 2446d4e3..4205a795 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -396,7 +396,7 @@ void g_at_ppp_unref(GAtPPP *ppp)
g_free(ppp);
}
-GAtPPP *g_at_ppp_new(GIOChannel *modem)
+static GAtPPP *ppp_init_common(GAtHDLC *hdlc)
{
GAtPPP *ppp;
@@ -404,12 +404,7 @@ GAtPPP *g_at_ppp_new(GIOChannel *modem)
if (!ppp)
return NULL;
- ppp->hdlc = g_at_hdlc_new(modem);
-
- if (ppp->hdlc == NULL) {
- g_free(ppp);
- return NULL;
- }
+ ppp->hdlc = g_at_hdlc_ref(hdlc);
ppp->ref_count = 1;
@@ -429,3 +424,33 @@ GAtPPP *g_at_ppp_new(GIOChannel *modem)
return ppp;
}
+
+GAtPPP *g_at_ppp_new(GIOChannel *modem)
+{
+ GAtHDLC *hdlc;
+ GAtPPP *ppp;
+
+ hdlc = g_at_hdlc_new(modem);
+ if (hdlc == NULL)
+ return NULL;
+
+ ppp = ppp_init_common(hdlc);
+ g_at_hdlc_unref(hdlc);
+
+ return ppp;
+}
+
+GAtPPP *g_at_ppp_new_from_io(GAtIO *io)
+{
+ GAtHDLC *hdlc;
+ GAtPPP *ppp;
+
+ hdlc = g_at_hdlc_new_from_io(io);
+ if (hdlc == NULL)
+ return NULL;
+
+ ppp = ppp_init_common(hdlc);
+ g_at_hdlc_unref(hdlc);
+
+ return ppp;
+}