/* plugin.c generated by valac 0.14.2, the Vala compiler
 * generated from plugin.vala, do not modify */

/*
 * Copyright (C) 2011 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 */

#include <glib.h>
#include <glib-object.h>
#include <fsogsm.h>
#include <fsotransport.h>
#include <gatppp.h>
#include <stdlib.h>
#include <string.h>
#include <fsobasics.h>
#include <gio/gio.h>
#include <freesmartphone.h>
#include <fsoframework.h>


#define PDP_TYPE_PPP_INTERNAL (pdp_ppp_internal_get_type ())
#define PDP_PPP_INTERNAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDP_TYPE_PPP_INTERNAL, PdpPppInternal))
#define PDP_PPP_INTERNAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDP_TYPE_PPP_INTERNAL, PdpPppInternalClass))
#define PDP_IS_PPP_INTERNAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDP_TYPE_PPP_INTERNAL))
#define PDP_IS_PPP_INTERNAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDP_TYPE_PPP_INTERNAL))
#define PDP_PPP_INTERNAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDP_TYPE_PPP_INTERNAL, PdpPppInternalClass))

typedef struct _PdpPppInternal PdpPppInternal;
typedef struct _PdpPppInternalClass PdpPppInternalClass;
typedef struct _PdpPppInternalPrivate PdpPppInternalPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_at_ppp_unref0(var) ((var == NULL) ? NULL : (var = (g_at_ppp_unref (var), NULL)))
#define _g_io_channel_unref0(var) ((var == NULL) ? NULL : (var = (g_io_channel_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _fso_gsm_route_info_unref0(var) ((var == NULL) ? NULL : (var = (fso_gsm_route_info_unref (var), NULL)))
typedef struct _PdpPppInternalScActivateData PdpPppInternalScActivateData;
typedef struct _PdpPppInternalScDeactivateData PdpPppInternalScDeactivateData;
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _pdp_ppp_internal_statusUpdateData pdp_ppp_internal_statusUpdateData;

struct _PdpPppInternal {
	FsoGsmPdpHandler parent_instance;
	PdpPppInternalPrivate * priv;
};

struct _PdpPppInternalClass {
	FsoGsmPdpHandlerClass parent_class;
};

struct _PdpPppInternalPrivate {
	FsoFrameworkTransport* transport;
	GAtPPP* ppp;
	GIOChannel* iochannel;
};

struct _PdpPppInternalScActivateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	PdpPppInternal* self;
	FsoGsmModem* _tmp0_;
	FsoGsmModemData* _tmp1_;
	FsoGsmModemData* data;
	FsoGsmModemData* _tmp2_;
	FsoGsmContextParams* _tmp3_;
	GError* _tmp4_;
	FsoGsmModemData* _tmp5_;
	FsoGsmContextParams* _tmp6_;
	const gchar* _tmp7_;
	GError* _tmp8_;
	gboolean _tmp9_;
	FsoGsmModem* _tmp10_;
	FsoFrameworkTransportSpec* _tmp11_;
	FsoFrameworkTransportSpec* _tmp12_;
	const gchar* _tmp13_;
	FsoGsmModem* _tmp14_;
	FsoFrameworkTransportSpec* _tmp15_;
	FsoFrameworkTransportSpec* _tmp16_;
	const gchar* _tmp17_;
	gboolean _tmp18_;
	GError* _tmp19_;
	FsoGsmModem* _tmp20_;
	FsoFrameworkTransportSpec* _tmp21_;
	FsoFrameworkTransportSpec* _tmp22_;
	FsoFrameworkTransport* _tmp23_;
	FsoFrameworkTransport* _tmp24_;
	FsoFrameworkTransport* _tmp25_;
	FsoFrameworkSerialTransport* _tmp26_;
	FsoFrameworkSerialTransport* serial_transport;
	FsoFrameworkSerialTransport* _tmp27_;
	FsoFrameworkSmartKeyFile* _tmp28_;
	gboolean _tmp29_;
	FsoFrameworkTransport* _tmp30_;
	FsoGsmStateBasedAtParser* _tmp31_;
	FsoGsmStateBasedAtParser* _tmp32_;
	FsoGsmAtChannel* _tmp33_;
	FsoGsmAtChannel* _tmp34_;
	FsoGsmAtChannel* channel;
	FsoGsmAtChannel* _tmp35_;
	gboolean _tmp36_;
	GError* _tmp37_;
	FsoFrameworkSmartKeyFile* _tmp38_;
	gint _tmp39_;
	gint delay;
	gint _tmp40_;
	FsoGsmAtChannel* _tmp41_;
	FsoGsmCustomAtCommand* _tmp42_;
	FsoGsmCustomAtCommand* _tmp43_;
	gint _tmp44_;
	gchar** _tmp45_;
	gchar** _tmp46_;
	gint _tmp46__length1;
	FsoGsmAtChannel* _tmp47_;
	FsoGsmCustomAtCommand* _tmp48_;
	FsoGsmCustomAtCommand* _tmp49_;
	gint _tmp50_;
	gchar** _tmp51_;
	gchar** _tmp52_;
	gint _tmp52__length1;
	gchar** response;
	gint response_length1;
	gint _response_size_;
	FsoGsmAtChannel* _tmp53_;
	FsoGsmCustomAtCommand* _tmp54_;
	FsoGsmCustomAtCommand* _tmp55_;
	FsoGsmModemData* _tmp56_;
	FsoGsmContextParams* _tmp57_;
	const gchar* _tmp58_;
	gchar* _tmp59_;
	gchar* _tmp60_;
	gint _tmp61_;
	gchar** _tmp62_;
	gchar** _tmp63_;
	gint _tmp63__length1;
	const gchar* _tmp64_;
	gchar* _tmp65_;
	gchar* _tmp66_;
	gboolean _tmp67_;
	gboolean _tmp68_;
	FsoGsmAtChannel* _tmp69_;
	GError* _tmp70_;
	FsoGsmAtChannel* _tmp71_;
	FsoGsmCustomAtCommand* _tmp72_;
	FsoGsmCustomAtCommand* _tmp73_;
	gint _tmp74_;
	gchar** _tmp75_;
	gchar** _tmp76_;
	gint _tmp76__length1;
	const gchar* _tmp77_;
	gchar* _tmp78_;
	gchar* _tmp79_;
	gboolean _tmp80_;
	gboolean _tmp81_;
	FsoGsmAtChannel* _tmp82_;
	GError* _tmp83_;
	FsoFrameworkTransport* _tmp84_;
	gint _tmp85_;
	GIOChannel* _tmp86_;
	FsoFrameworkSmartKeyFile* _tmp87_;
	gint _tmp88_;
	gint _tmp89_;
	GIOChannel* _tmp90_;
	GAtPPP* _tmp91_;
	GAtPPP* _tmp92_;
	GAtPPP* _tmp93_;
	GAtPPP* _tmp94_;
	FsoGsmModemData* _tmp95_;
	FsoGsmContextParams* _tmp96_;
	const gchar* _tmp97_;
	FsoGsmModemData* _tmp98_;
	FsoGsmContextParams* _tmp99_;
	const gchar* _tmp100_;
	GAtPPP* _tmp101_;
	GAtPPP* _tmp102_;
	GAtPPP* _tmp103_;
	GError * _inner_error_;
};

struct _PdpPppInternalScDeactivateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	PdpPppInternal* self;
	FsoFrameworkTransport* _tmp0_;
};

struct _pdp_ppp_internal_statusUpdateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	PdpPppInternal* self;
	gchar* status;
	GHashTable* properties;
};


static gpointer pdp_ppp_internal_parent_class = NULL;
static GType pdp_ppp_internal_type_id = 0;
extern gchar* sysfs_root;
gchar* sysfs_root = NULL;
extern gchar* devfs_root;
gchar* devfs_root = NULL;

GType pdp_ppp_internal_get_type (void) G_GNUC_CONST;
GType pdp_ppp_internal_register_type (GTypeModule * module);
#define PDP_PPP_INTERNAL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PDP_TYPE_PPP_INTERNAL, PdpPppInternalPrivate))
enum  {
	PDP_PPP_INTERNAL_DUMMY_PROPERTY
};
#define PDP_PPP_INTERNAL_MODULE_NAME "fsogsm.pdp_ppp_internal"
static gchar* pdp_ppp_internal_real_repr (FsoFrameworkAbstractObject* base);
void pdp_ppp_internal_onDebugFromAtPPP (PdpPppInternal* self, const gchar* str);
void pdp_ppp_internal_onConnectFromAtPPPP (PdpPppInternal* self, const gchar* iface, const gchar* local, const gchar* peer, const gchar* dns1, const gchar* dns2);
void pdp_ppp_internal_onDisconnectFromAtPPP (PdpPppInternal* self, GAtPPPDisconnectReason reason);
const gchar* g_at_ppp_disconnect_reason_to_string (GAtPPPDisconnectReason self);
static const char* _g_at_ppp_disconnect_reason_to_string (GAtPPPDisconnectReason value);
static void pdp_ppp_internal_real_sc_activate_data_free (gpointer _data);
static void pdp_ppp_internal_real_sc_activate (FsoGsmPdpHandler* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean pdp_ppp_internal_real_sc_activate_co (PdpPppInternalScActivateData* _data_);
static void pdp_ppp_internal_sc_activate_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static gboolean _pdp_ppp_internal_real_sc_activate_co_gsource_func (gpointer self);
static void _pdp_ppp_internal_onDebugFromAtPPP_gat_debug_func (const gchar* message, gpointer self);
static void _pdp_ppp_internal_onConnectFromAtPPPP_gat_ppp_connect_func (const gchar* iface, const gchar* local, const gchar* peer, const gchar* dns1, const gchar* dns2, gpointer self);
static void _pdp_ppp_internal_onDisconnectFromAtPPP_gat_ppp_disconnect_func (GAtPPPDisconnectReason reason, gpointer self);
static void pdp_ppp_internal_real_sc_deactivate_data_free (gpointer _data);
static void pdp_ppp_internal_real_sc_deactivate (FsoGsmPdpHandler* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean pdp_ppp_internal_real_sc_deactivate_co (PdpPppInternalScDeactivateData* _data_);
static void pdp_ppp_internal_real_statusUpdate_data_free (gpointer _data);
static void pdp_ppp_internal_real_statusUpdate (FsoGsmPdpHandler* base, const gchar* status, GHashTable* properties, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean pdp_ppp_internal_real_statusUpdate_co (pdp_ppp_internal_statusUpdateData* _data_);
PdpPppInternal* pdp_ppp_internal_new (void);
PdpPppInternal* pdp_ppp_internal_construct (GType object_type);
static GObject * pdp_ppp_internal_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void pdp_ppp_internal_finalize (GObject* obj);
gchar* fso_factory_function (FsoFrameworkSubsystem* subsystem, GError** error);
void fso_register_function (GTypeModule* module);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static gchar* pdp_ppp_internal_real_repr (FsoFrameworkAbstractObject* base) {
	PdpPppInternal * self;
	gchar* result = NULL;
	gchar* _tmp0_;
	self = (PdpPppInternal*) base;
	_tmp0_ = g_strdup ("<>");
	result = _tmp0_;
	return result;
}


static const gchar* string_to_string (const gchar* self) {
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}


void pdp_ppp_internal_onDebugFromAtPPP (PdpPppInternal* self, const gchar* str) {
	FsoFrameworkLogger* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_;
	gboolean _tmp5_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (str != NULL);
	_tmp0_ = ((FsoFrameworkAbstractObject*) self)->logger;
	_tmp1_ = str;
	_tmp2_ = string_to_string (_tmp1_);
	_tmp3_ = g_strconcat ("ThirdParty.At.PPP: ", _tmp2_, NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = fso_framework_logger_debug (_tmp0_, _tmp4_);
	g_assert (_tmp5_);
	_g_free0 (_tmp4_);
}


void pdp_ppp_internal_onConnectFromAtPPPP (PdpPppInternal* self, const gchar* iface, const gchar* local, const gchar* peer, const gchar* dns1, const gchar* dns2) {
	FsoFrameworkLogger* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_ = NULL;
	const gchar* _tmp3_;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_;
	const gchar* _tmp6_ = NULL;
	const gchar* _tmp7_;
	const gchar* _tmp8_ = NULL;
	const gchar* _tmp9_;
	const gchar* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	const gchar* _tmp22_;
	gchar* _tmp23_;
	FsoGsmRouteInfo* _tmp24_ = NULL;
	FsoGsmRouteInfo* route;
	g_return_if_fail (self != NULL);
	g_return_if_fail (iface != NULL);
	g_return_if_fail (local != NULL);
	g_return_if_fail (peer != NULL);
	g_return_if_fail (dns1 != NULL);
	g_return_if_fail (dns2 != NULL);
	_tmp0_ = ((FsoFrameworkAbstractObject*) self)->logger;
	_tmp1_ = iface;
	_tmp2_ = string_to_string (_tmp1_);
	_tmp3_ = local;
	_tmp4_ = string_to_string (_tmp3_);
	_tmp5_ = peer;
	_tmp6_ = string_to_string (_tmp5_);
	_tmp7_ = dns1;
	_tmp8_ = string_to_string (_tmp7_);
	_tmp9_ = dns2;
	_tmp10_ = string_to_string (_tmp9_);
	_tmp11_ = g_strconcat ("PPP stack now online via ", _tmp2_, ". Local IP is ", _tmp4_, ", remote IP is ", _tmp6_, ", DNS1 is ", _tmp8_, ", DNS2 is ", _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	fso_framework_logger_info (_tmp0_, _tmp12_);
	_g_free0 (_tmp12_);
	_tmp13_ = iface;
	_tmp14_ = g_strdup (_tmp13_);
	_tmp15_ = local;
	_tmp16_ = g_strdup (_tmp15_);
	_tmp17_ = g_strdup ("255.255.255.0");
	_tmp18_ = peer;
	_tmp19_ = g_strdup (_tmp18_);
	_tmp20_ = dns1;
	_tmp21_ = g_strdup (_tmp20_);
	_tmp22_ = dns2;
	_tmp23_ = g_strdup (_tmp22_);
	_tmp24_ = fso_gsm_route_info_new ();
	_g_free0 (_tmp24_->iface);
	_tmp24_->iface = _tmp14_;
	_g_free0 (_tmp24_->ipv4addr);
	_tmp24_->ipv4addr = _tmp16_;
	_g_free0 (_tmp24_->ipv4mask);
	_tmp24_->ipv4mask = _tmp17_;
	_g_free0 (_tmp24_->ipv4gateway);
	_tmp24_->ipv4gateway = _tmp19_;
	_g_free0 (_tmp24_->dns1);
	_tmp24_->dns1 = _tmp21_;
	_g_free0 (_tmp24_->dns2);
	_tmp24_->dns2 = _tmp23_;
	route = _tmp24_;
	fso_gsm_ipdp_handler_connectedWithNewDefaultRoute ((FsoGsmIPdpHandler*) self, route, NULL, NULL);
	_fso_gsm_route_info_unref0 (route);
}


static const char* _g_at_ppp_disconnect_reason_to_string (GAtPPPDisconnectReason value) {
	switch (value) {
		case G_AT_PPP_REASON_UNKNOWN:
		return "G_AT_PPP_REASON_UNKNOWN";
		case G_AT_PPP_REASON_AUTH_FAIL:
		return "G_AT_PPP_REASON_AUTH_FAIL";
		case G_AT_PPP_REASON_IPCP_FAIL:
		return "G_AT_PPP_REASON_IPCP_FAIL";
		case G_AT_PPP_REASON_NET_FAIL:
		return "G_AT_PPP_REASON_NET_FAIL";
		case G_AT_PPP_REASON_PEER_CLOSED:
		return "G_AT_PPP_REASON_PEER_CLOSED";
		case G_AT_PPP_REASON_LINK_DEAD:
		return "G_AT_PPP_REASON_LINK_DEAD";
		case G_AT_PPP_REASON_LOCAL_CLOSE:
		return "G_AT_PPP_REASON_LOCAL_CLOSE";
	}
	return NULL;
}


void pdp_ppp_internal_onDisconnectFromAtPPP (PdpPppInternal* self, GAtPPPDisconnectReason reason) {
	FsoFrameworkLogger* _tmp0_;
	GAtPPPDisconnectReason _tmp1_;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = ((FsoFrameworkAbstractObject*) self)->logger;
	_tmp1_ = reason;
	_tmp2_ = _g_at_ppp_disconnect_reason_to_string (_tmp1_);
	_tmp3_ = g_strconcat ("PPP stack now offline. Disconnect reason is ", _tmp2_, NULL);
	_tmp4_ = _tmp3_;
	fso_framework_logger_info (_tmp0_, _tmp4_);
	_g_free0 (_tmp4_);
	fso_gsm_pdp_handler_sc_deactivate ((FsoGsmPdpHandler*) self, NULL, NULL);
	fso_gsm_ipdp_handler_disconnected ((FsoGsmIPdpHandler*) self);
}


static void pdp_ppp_internal_real_sc_activate_data_free (gpointer _data) {
	PdpPppInternalScActivateData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (PdpPppInternalScActivateData, _data_);
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static void pdp_ppp_internal_real_sc_activate (FsoGsmPdpHandler* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	PdpPppInternal * self;
	PdpPppInternalScActivateData* _data_;
	PdpPppInternal* _tmp0_;
	self = (PdpPppInternal*) base;
	_data_ = g_slice_new0 (PdpPppInternalScActivateData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, pdp_ppp_internal_real_sc_activate);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, pdp_ppp_internal_real_sc_activate_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	pdp_ppp_internal_real_sc_activate_co (_data_);
}


static void pdp_ppp_internal_real_sc_activate_finish (FsoGsmPdpHandler* base, GAsyncResult* _res_, GError** error) {
	PdpPppInternalScActivateData* _data_;
	if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
		return;
	}
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void pdp_ppp_internal_sc_activate_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	PdpPppInternalScActivateData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	pdp_ppp_internal_real_sc_activate_co (_data_);
}


static gboolean _pdp_ppp_internal_real_sc_activate_co_gsource_func (gpointer self) {
	gboolean result;
	result = pdp_ppp_internal_real_sc_activate_co (self);
	return result;
}


static gchar* string_strip (const gchar* self) {
	gchar* result = NULL;
	gchar* _tmp0_ = NULL;
	gchar* _result_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	g_strstrip (_tmp1_);
	result = _result_;
	return result;
}


static void _pdp_ppp_internal_onDebugFromAtPPP_gat_debug_func (const gchar* message, gpointer self) {
	pdp_ppp_internal_onDebugFromAtPPP (self, message);
}


static void _pdp_ppp_internal_onConnectFromAtPPPP_gat_ppp_connect_func (const gchar* iface, const gchar* local, const gchar* peer, const gchar* dns1, const gchar* dns2, gpointer self) {
	pdp_ppp_internal_onConnectFromAtPPPP (self, iface, local, peer, dns1, dns2);
}


static void _pdp_ppp_internal_onDisconnectFromAtPPP_gat_ppp_disconnect_func (GAtPPPDisconnectReason reason, gpointer self) {
	pdp_ppp_internal_onDisconnectFromAtPPP (self, reason);
}


static gboolean pdp_ppp_internal_real_sc_activate_co (PdpPppInternalScActivateData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		case 5:
		goto _state_5;
		case 6:
		goto _state_6;
		case 7:
		goto _state_7;
		case 8:
		goto _state_8;
		case 9:
		goto _state_9;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = fso_gsm_theModem;
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = fso_gsm_modem_data (_data_->_tmp0_);
	_data_->data = _data_->_tmp1_;
	_data_->_tmp2_ = _data_->data;
	_data_->_tmp3_ = _data_->_tmp2_->contextParams;
	if (_data_->_tmp3_ == NULL) {
		fso_gsm_ipdp_handler_disconnected ((FsoGsmIPdpHandler*) _data_->self);
		_data_->_tmp4_ = g_error_new_literal (FREE_SMARTPHONE_ERROR, FREE_SMARTPHONE_ERROR_INTERNAL_ERROR, "Context parameters not set");
		_data_->_inner_error_ = _data_->_tmp4_;
		if ((_data_->_inner_error_->domain == FREE_SMARTPHONE_GSM_ERROR) || (_data_->_inner_error_->domain == FREE_SMARTPHONE_ERROR)) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			_g_object_unref0 (_data_->data);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_object_unref0 (_data_->data);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
			g_clear_error (&_data_->_inner_error_);
			return FALSE;
		}
	}
	_data_->_tmp5_ = _data_->data;
	_data_->_tmp6_ = _data_->_tmp5_->contextParams;
	_data_->_tmp7_ = _data_->_tmp6_->apn;
	if (_data_->_tmp7_ == NULL) {
		fso_gsm_ipdp_handler_disconnected ((FsoGsmIPdpHandler*) _data_->self);
		_data_->_tmp8_ = g_error_new_literal (FREE_SMARTPHONE_ERROR, FREE_SMARTPHONE_ERROR_INTERNAL_ERROR, "APN not set");
		_data_->_inner_error_ = _data_->_tmp8_;
		if ((_data_->_inner_error_->domain == FREE_SMARTPHONE_GSM_ERROR) || (_data_->_inner_error_->domain == FREE_SMARTPHONE_ERROR)) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			_g_object_unref0 (_data_->data);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_object_unref0 (_data_->data);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
			g_clear_error (&_data_->_inner_error_);
			return FALSE;
		}
	}
	_data_->_tmp10_ = fso_gsm_theModem;
	_data_->_tmp11_ = fso_gsm_abstract_modem_get_data_transport_spec (FSO_GSM_ABSTRACT_MODEM (_data_->_tmp10_));
	_data_->_tmp12_ = _data_->_tmp11_;
	_data_->_tmp13_ = _data_->_tmp12_->type;
	if (g_strcmp0 (_data_->_tmp13_, "serial") != 0) {
		_data_->_tmp14_ = fso_gsm_theModem;
		_data_->_tmp15_ = fso_gsm_abstract_modem_get_data_transport_spec (FSO_GSM_ABSTRACT_MODEM (_data_->_tmp14_));
		_data_->_tmp16_ = _data_->_tmp15_;
		_data_->_tmp17_ = _data_->_tmp16_->type;
		_data_->_tmp9_ = g_strcmp0 (_data_->_tmp17_, "tcp") != 0;
	} else {
		_data_->_tmp9_ = FALSE;
	}
	_data_->_tmp18_ = _data_->_tmp9_;
	if (_data_->_tmp18_) {
		fso_gsm_ipdp_handler_disconnected ((FsoGsmIPdpHandler*) _data_->self);
		_data_->_tmp19_ = g_error_new_literal (FREE_SMARTPHONE_ERROR, FREE_SMARTPHONE_ERROR_INTERNAL_ERROR, "ippp only supports data transport types 'serial' and 'tcp' for now");
		_data_->_inner_error_ = _data_->_tmp19_;
		if ((_data_->_inner_error_->domain == FREE_SMARTPHONE_GSM_ERROR) || (_data_->_inner_error_->domain == FREE_SMARTPHONE_ERROR)) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			_g_object_unref0 (_data_->data);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_object_unref0 (_data_->data);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
			g_clear_error (&_data_->_inner_error_);
			return FALSE;
		}
	}
	_data_->_tmp20_ = fso_gsm_theModem;
	_data_->_tmp21_ = fso_gsm_abstract_modem_get_data_transport_spec (FSO_GSM_ABSTRACT_MODEM (_data_->_tmp20_));
	_data_->_tmp22_ = _data_->_tmp21_;
	_data_->_tmp23_ = NULL;
	_data_->_tmp23_ = fso_framework_transport_spec_create (_data_->_tmp22_);
	_g_object_unref0 (_data_->self->priv->transport);
	_data_->self->priv->transport = _data_->_tmp23_;
	_data_->_tmp24_ = _data_->self->priv->transport;
	if (FSO_FRAMEWORK_IS_SERIAL_TRANSPORT (_data_->_tmp24_)) {
		_data_->_tmp25_ = _data_->self->priv->transport;
		_data_->_tmp26_ = _g_object_ref0 (FSO_FRAMEWORK_IS_SERIAL_TRANSPORT (_data_->_tmp25_) ? ((FsoFrameworkSerialTransport*) _data_->_tmp25_) : NULL);
		_data_->serial_transport = _data_->_tmp26_;
		_data_->_tmp27_ = _data_->serial_transport;
		_data_->_tmp28_ = fso_framework_theConfig;
		_data_->_tmp29_ = FALSE;
		_data_->_tmp29_ = fso_framework_smart_key_file_boolValue (_data_->_tmp28_, PDP_PPP_INTERNAL_MODULE_NAME, "dtr_cycle", FALSE);
		_data_->_tmp27_->dtr_cycle = _data_->_tmp29_;
		_g_object_unref0 (_data_->serial_transport);
	}
	_data_->_tmp30_ = _data_->self->priv->transport;
	_data_->_tmp31_ = fso_gsm_state_based_at_parser_new ();
	_data_->_tmp32_ = _data_->_tmp31_;
	_data_->_tmp33_ = fso_gsm_at_channel_new (NULL, _data_->_tmp30_, (FsoFrameworkParser*) _data_->_tmp32_);
	_data_->_tmp34_ = _data_->_tmp33_;
	_g_object_unref0 (_data_->_tmp32_);
	_data_->channel = _data_->_tmp34_;
	_data_->_tmp35_ = _data_->channel;
	_data_->_state_ = 1;
	fso_framework_abstract_command_queue_open ((FsoFrameworkAbstractCommandQueue*) _data_->_tmp35_, pdp_ppp_internal_sc_activate_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp36_ = FALSE;
	_data_->_tmp36_ = fso_framework_abstract_command_queue_open_finish ((FsoFrameworkAbstractCommandQueue*) _data_->_tmp35_, _data_->_res_);
	if (!_data_->_tmp36_) {
		fso_gsm_ipdp_handler_disconnected ((FsoGsmIPdpHandler*) _data_->self);
		_data_->_tmp37_ = g_error_new_literal (FREE_SMARTPHONE_ERROR, FREE_SMARTPHONE_ERROR_SYSTEM_ERROR, "Can't open data channel or transport");
		_data_->_inner_error_ = _data_->_tmp37_;
		if ((_data_->_inner_error_->domain == FREE_SMARTPHONE_GSM_ERROR) || (_data_->_inner_error_->domain == FREE_SMARTPHONE_ERROR)) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			_g_object_unref0 (_data_->channel);
			_g_object_unref0 (_data_->data);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_object_unref0 (_data_->channel);
			_g_object_unref0 (_data_->data);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
			g_clear_error (&_data_->_inner_error_);
			return FALSE;
		}
	}
	_data_->_tmp38_ = ((FsoFrameworkAbstractObject*) _data_->self)->config;
	_data_->_tmp39_ = 0;
	_data_->_tmp39_ = fso_framework_smart_key_file_intValue (_data_->_tmp38_, PDP_PPP_INTERNAL_MODULE_NAME, "post_open_delay", 500);
	_data_->delay = _data_->_tmp39_;
	_data_->_tmp40_ = _data_->delay;
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) _data_->_tmp40_, _pdp_ppp_internal_real_sc_activate_co_gsource_func, _data_, NULL);
	_data_->_state_ = 2;
	return FALSE;
	_state_2:
	;
	_data_->_tmp41_ = _data_->channel;
	_data_->_tmp42_ = fso_gsm_custom_at_command_new ("", FALSE);
	_data_->_tmp43_ = _data_->_tmp42_;
	_data_->_tmp44_ = 0;
	_data_->_state_ = 3;
	fso_gsm_at_command_queue_enqueueAsync ((FsoGsmAtCommandQueue*) _data_->_tmp41_, (FsoGsmAtCommandQueueCommand*) _data_->_tmp43_, "Z", 0, 0, pdp_ppp_internal_sc_activate_ready, _data_);
	return FALSE;
	_state_3:
	_data_->_tmp45_ = NULL;
	_data_->_tmp45_ = fso_gsm_at_command_queue_enqueueAsync_finish ((FsoGsmAtCommandQueue*) _data_->_tmp41_, _data_->_res_, &_data_->_tmp44_);
	_data_->_tmp46_ = _data_->_tmp45_;
	_data_->_tmp46__length1 = _data_->_tmp44_;
	_data_->_tmp46_ = (_vala_array_free (_data_->_tmp46_, _data_->_tmp46__length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (_data_->_tmp43_);
	_data_->_tmp47_ = _data_->channel;
	_data_->_tmp48_ = fso_gsm_custom_at_command_new ("", FALSE);
	_data_->_tmp49_ = _data_->_tmp48_;
	_data_->_tmp50_ = 0;
	_data_->_state_ = 4;
	fso_gsm_at_command_queue_enqueueAsync ((FsoGsmAtCommandQueue*) _data_->_tmp47_, (FsoGsmAtCommandQueueCommand*) _data_->_tmp49_, "+CGQREQ=1;+CGQMIN=1;+CGEQREQ=1;+CGEQMIN=1", 0, 0, pdp_ppp_internal_sc_activate_ready, _data_);
	return FALSE;
	_state_4:
	_data_->_tmp51_ = NULL;
	_data_->_tmp51_ = fso_gsm_at_command_queue_enqueueAsync_finish ((FsoGsmAtCommandQueue*) _data_->_tmp47_, _data_->_res_, &_data_->_tmp50_);
	_data_->_tmp52_ = _data_->_tmp51_;
	_data_->_tmp52__length1 = _data_->_tmp50_;
	_g_object_unref0 (_data_->_tmp49_);
	_data_->response = _data_->_tmp52_;
	_data_->response_length1 = _data_->_tmp52__length1;
	_data_->_response_size_ = _data_->response_length1;
	_data_->_tmp53_ = _data_->channel;
	_data_->_tmp54_ = fso_gsm_custom_at_command_new ("", FALSE);
	_data_->_tmp55_ = _data_->_tmp54_;
	_data_->_tmp56_ = _data_->data;
	_data_->_tmp57_ = _data_->_tmp56_->contextParams;
	_data_->_tmp58_ = _data_->_tmp57_->apn;
	_data_->_tmp59_ = NULL;
	_data_->_tmp59_ = g_strdup_printf ("+CGDCONT=1,\"IP\",\"%s\",,0,0", _data_->_tmp58_);
	_data_->_tmp60_ = _data_->_tmp59_;
	_data_->_tmp61_ = 0;
	_data_->_state_ = 5;
	fso_gsm_at_command_queue_enqueueAsync ((FsoGsmAtCommandQueue*) _data_->_tmp53_, (FsoGsmAtCommandQueueCommand*) _data_->_tmp55_, _data_->_tmp60_, 0, 0, pdp_ppp_internal_sc_activate_ready, _data_);
	return FALSE;
	_state_5:
	_data_->_tmp62_ = NULL;
	_data_->_tmp62_ = fso_gsm_at_command_queue_enqueueAsync_finish ((FsoGsmAtCommandQueue*) _data_->_tmp53_, _data_->_res_, &_data_->_tmp61_);
	_data_->response = (_vala_array_free (_data_->response, _data_->response_length1, (GDestroyNotify) g_free), NULL);
	_data_->response = _data_->_tmp62_;
	_data_->response_length1 = _data_->_tmp61_;
	_data_->_response_size_ = _data_->response_length1;
	_g_free0 (_data_->_tmp60_);
	_g_object_unref0 (_data_->_tmp55_);
	_data_->_tmp63_ = _data_->response;
	_data_->_tmp63__length1 = _data_->response_length1;
	_data_->_tmp64_ = _data_->_tmp63_[0];
	_data_->_tmp65_ = NULL;
	_data_->_tmp65_ = string_strip (_data_->_tmp64_);
	_data_->_tmp66_ = _data_->_tmp65_;
	_data_->_tmp67_ = FALSE;
	_data_->_tmp67_ = g_str_has_suffix (_data_->_tmp66_, "OK");
	_data_->_tmp68_ = !_data_->_tmp67_;
	_g_free0 (_data_->_tmp66_);
	if (_data_->_tmp68_) {
		_data_->_tmp69_ = _data_->channel;
		_data_->_state_ = 6;
		fso_framework_abstract_command_queue_close ((FsoFrameworkAbstractCommandQueue*) _data_->_tmp69_, pdp_ppp_internal_sc_activate_ready, _data_);
		return FALSE;
		_state_6:
		fso_framework_abstract_command_queue_close_finish ((FsoFrameworkAbstractCommandQueue*) _data_->_tmp69_, _data_->_res_);
		_g_object_unref0 (_data_->self->priv->transport);
		_data_->self->priv->transport = NULL;
		fso_gsm_ipdp_handler_disconnected ((FsoGsmIPdpHandler*) _data_->self);
		_data_->_tmp70_ = g_error_new_literal (FREE_SMARTPHONE_ERROR, FREE_SMARTPHONE_ERROR_SYSTEM_ERROR, "Can't initialize data transport");
		_data_->_inner_error_ = _data_->_tmp70_;
		if ((_data_->_inner_error_->domain == FREE_SMARTPHONE_GSM_ERROR) || (_data_->_inner_error_->domain == FREE_SMARTPHONE_ERROR)) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			_data_->response = (_vala_array_free (_data_->response, _data_->response_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (_data_->channel);
			_g_object_unref0 (_data_->data);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_data_->response = (_vala_array_free (_data_->response, _data_->response_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (_data_->channel);
			_g_object_unref0 (_data_->data);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
			g_clear_error (&_data_->_inner_error_);
			return FALSE;
		}
	}
	_data_->_tmp71_ = _data_->channel;
	_data_->_tmp72_ = fso_gsm_custom_at_command_new ("", FALSE);
	_data_->_tmp73_ = _data_->_tmp72_;
	_data_->_tmp74_ = 0;
	_data_->_state_ = 7;
	fso_gsm_at_command_queue_enqueueAsync ((FsoGsmAtCommandQueue*) _data_->_tmp71_, (FsoGsmAtCommandQueueCommand*) _data_->_tmp73_, "D*99***1#", 0, 0, pdp_ppp_internal_sc_activate_ready, _data_);
	return FALSE;
	_state_7:
	_data_->_tmp75_ = NULL;
	_data_->_tmp75_ = fso_gsm_at_command_queue_enqueueAsync_finish ((FsoGsmAtCommandQueue*) _data_->_tmp71_, _data_->_res_, &_data_->_tmp74_);
	_data_->response = (_vala_array_free (_data_->response, _data_->response_length1, (GDestroyNotify) g_free), NULL);
	_data_->response = _data_->_tmp75_;
	_data_->response_length1 = _data_->_tmp74_;
	_data_->_response_size_ = _data_->response_length1;
	_g_object_unref0 (_data_->_tmp73_);
	_data_->_tmp76_ = _data_->response;
	_data_->_tmp76__length1 = _data_->response_length1;
	_data_->_tmp77_ = _data_->_tmp76_[0];
	_data_->_tmp78_ = NULL;
	_data_->_tmp78_ = string_strip (_data_->_tmp77_);
	_data_->_tmp79_ = _data_->_tmp78_;
	_data_->_tmp80_ = FALSE;
	_data_->_tmp80_ = g_str_has_suffix (_data_->_tmp79_, "CONNECT");
	_data_->_tmp81_ = !_data_->_tmp80_;
	_g_free0 (_data_->_tmp79_);
	if (_data_->_tmp81_) {
		_data_->_tmp82_ = _data_->channel;
		_data_->_state_ = 8;
		fso_framework_abstract_command_queue_close ((FsoFrameworkAbstractCommandQueue*) _data_->_tmp82_, pdp_ppp_internal_sc_activate_ready, _data_);
		return FALSE;
		_state_8:
		fso_framework_abstract_command_queue_close_finish ((FsoFrameworkAbstractCommandQueue*) _data_->_tmp82_, _data_->_res_);
		_g_object_unref0 (_data_->self->priv->transport);
		_data_->self->priv->transport = NULL;
		fso_gsm_ipdp_handler_disconnected ((FsoGsmIPdpHandler*) _data_->self);
		_data_->_tmp83_ = g_error_new_literal (FREE_SMARTPHONE_ERROR, FREE_SMARTPHONE_ERROR_SYSTEM_ERROR, "Can't initialize data transport");
		_data_->_inner_error_ = _data_->_tmp83_;
		if ((_data_->_inner_error_->domain == FREE_SMARTPHONE_GSM_ERROR) || (_data_->_inner_error_->domain == FREE_SMARTPHONE_ERROR)) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			_data_->response = (_vala_array_free (_data_->response, _data_->response_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (_data_->channel);
			_g_object_unref0 (_data_->data);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_data_->response = (_vala_array_free (_data_->response, _data_->response_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (_data_->channel);
			_g_object_unref0 (_data_->data);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
			g_clear_error (&_data_->_inner_error_);
			return FALSE;
		}
	}
	_data_->_tmp84_ = _data_->self->priv->transport;
	_data_->_tmp85_ = 0;
	_data_->_tmp85_ = fso_framework_transport_freeze (_data_->_tmp84_);
	_data_->_tmp86_ = g_io_channel_unix_new (_data_->_tmp85_);
	_g_io_channel_unref0 (_data_->self->priv->iochannel);
	_data_->self->priv->iochannel = _data_->_tmp86_;
	_data_->_tmp87_ = ((FsoFrameworkAbstractObject*) _data_->self)->config;
	_data_->_tmp88_ = 0;
	_data_->_tmp88_ = fso_framework_smart_key_file_intValue (_data_->_tmp87_, PDP_PPP_INTERNAL_MODULE_NAME, "post_connect_delay", 500);
	_data_->delay = _data_->_tmp88_;
	_data_->_tmp89_ = _data_->delay;
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) _data_->_tmp89_, _pdp_ppp_internal_real_sc_activate_co_gsource_func, _data_, NULL);
	_data_->_state_ = 9;
	return FALSE;
	_state_9:
	;
	_data_->_tmp90_ = _data_->self->priv->iochannel;
	_data_->_tmp91_ = g_at_ppp_new (_data_->_tmp90_);
	_g_at_ppp_unref0 (_data_->self->priv->ppp);
	_data_->self->priv->ppp = _data_->_tmp91_;
	_data_->_tmp92_ = _data_->self->priv->ppp;
	g_at_ppp_set_debug (_data_->_tmp92_, _pdp_ppp_internal_onDebugFromAtPPP_gat_debug_func, _data_->self);
	_data_->_tmp93_ = _data_->self->priv->ppp;
	g_at_ppp_set_recording (_data_->_tmp93_, "/tmp/ppp.log");
	_data_->_tmp94_ = _data_->self->priv->ppp;
	_data_->_tmp95_ = _data_->data;
	_data_->_tmp96_ = _data_->_tmp95_->contextParams;
	_data_->_tmp97_ = _data_->_tmp96_->username;
	_data_->_tmp98_ = _data_->data;
	_data_->_tmp99_ = _data_->_tmp98_->contextParams;
	_data_->_tmp100_ = _data_->_tmp99_->password;
	g_at_ppp_set_credentials (_data_->_tmp94_, _data_->_tmp97_, _data_->_tmp100_);
	_data_->_tmp101_ = _data_->self->priv->ppp;
	g_at_ppp_set_connect_function (_data_->_tmp101_, _pdp_ppp_internal_onConnectFromAtPPPP_gat_ppp_connect_func, _data_->self);
	_data_->_tmp102_ = _data_->self->priv->ppp;
	g_at_ppp_set_disconnect_function (_data_->_tmp102_, _pdp_ppp_internal_onDisconnectFromAtPPP_gat_ppp_disconnect_func, _data_->self);
	_data_->_tmp103_ = _data_->self->priv->ppp;
	g_at_ppp_open (_data_->_tmp103_);
	_data_->response = (_vala_array_free (_data_->response, _data_->response_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (_data_->channel);
	_g_object_unref0 (_data_->data);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void pdp_ppp_internal_real_sc_deactivate_data_free (gpointer _data) {
	PdpPppInternalScDeactivateData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (PdpPppInternalScDeactivateData, _data_);
}


static void pdp_ppp_internal_real_sc_deactivate (FsoGsmPdpHandler* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	PdpPppInternal * self;
	PdpPppInternalScDeactivateData* _data_;
	PdpPppInternal* _tmp0_;
	self = (PdpPppInternal*) base;
	_data_ = g_slice_new0 (PdpPppInternalScDeactivateData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, pdp_ppp_internal_real_sc_deactivate);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, pdp_ppp_internal_real_sc_deactivate_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	pdp_ppp_internal_real_sc_deactivate_co (_data_);
}


static void pdp_ppp_internal_real_sc_deactivate_finish (FsoGsmPdpHandler* base, GAsyncResult* _res_, GError** error) {
	PdpPppInternalScDeactivateData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static gboolean pdp_ppp_internal_real_sc_deactivate_co (PdpPppInternalScDeactivateData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_g_at_ppp_unref0 (_data_->self->priv->ppp);
	_data_->self->priv->ppp = NULL;
	_g_io_channel_unref0 (_data_->self->priv->iochannel);
	_data_->self->priv->iochannel = NULL;
	_data_->_tmp0_ = _data_->self->priv->transport;
	fso_framework_transport_close (_data_->_tmp0_);
	_g_object_unref0 (_data_->self->priv->transport);
	_data_->self->priv->transport = NULL;
	_g_io_channel_unref0 (_data_->self->priv->iochannel);
	_data_->self->priv->iochannel = NULL;
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void pdp_ppp_internal_real_statusUpdate_data_free (gpointer _data) {
	pdp_ppp_internal_statusUpdateData* _data_;
	_data_ = _data;
	_g_free0 (_data_->status);
	_g_hash_table_unref0 (_data_->properties);
	_g_object_unref0 (_data_->self);
	g_slice_free (pdp_ppp_internal_statusUpdateData, _data_);
}


static gpointer _g_hash_table_ref0 (gpointer self) {
	return self ? g_hash_table_ref (self) : NULL;
}


static void pdp_ppp_internal_real_statusUpdate (FsoGsmPdpHandler* base, const gchar* status, GHashTable* properties, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	PdpPppInternal * self;
	pdp_ppp_internal_statusUpdateData* _data_;
	PdpPppInternal* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GHashTable* _tmp3_;
	GHashTable* _tmp4_;
	self = (PdpPppInternal*) base;
	_data_ = g_slice_new0 (pdp_ppp_internal_statusUpdateData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, pdp_ppp_internal_real_statusUpdate);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, pdp_ppp_internal_real_statusUpdate_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = status;
	_tmp2_ = g_strdup (_tmp1_);
	_data_->status = _tmp2_;
	_tmp3_ = properties;
	_tmp4_ = _g_hash_table_ref0 (_tmp3_);
	_data_->properties = _tmp4_;
	pdp_ppp_internal_real_statusUpdate_co (_data_);
}


static void pdp_ppp_internal_real_statusUpdate_finish (FsoGsmPdpHandler* base, GAsyncResult* _res_) {
	pdp_ppp_internal_statusUpdateData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static gboolean pdp_ppp_internal_real_statusUpdate_co (pdp_ppp_internal_statusUpdateData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	g_assert_not_reached ();
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


PdpPppInternal* pdp_ppp_internal_construct (GType object_type) {
	PdpPppInternal * self = NULL;
	self = (PdpPppInternal*) fso_gsm_pdp_handler_construct (object_type);
	return self;
}


PdpPppInternal* pdp_ppp_internal_new (void) {
	return pdp_ppp_internal_construct (PDP_TYPE_PPP_INTERNAL);
}


static GObject * pdp_ppp_internal_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	PdpPppInternal * self;
	parent_class = G_OBJECT_CLASS (pdp_ppp_internal_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = PDP_PPP_INTERNAL (obj);
	return obj;
}


static void pdp_ppp_internal_class_init (PdpPppInternalClass * klass) {
	pdp_ppp_internal_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (PdpPppInternalPrivate));
	FSO_FRAMEWORK_ABSTRACT_OBJECT_CLASS (klass)->repr = pdp_ppp_internal_real_repr;
	FSO_GSM_PDP_HANDLER_CLASS (klass)->sc_activate = pdp_ppp_internal_real_sc_activate;
	FSO_GSM_PDP_HANDLER_CLASS (klass)->sc_activate_finish = pdp_ppp_internal_real_sc_activate_finish;
	FSO_GSM_PDP_HANDLER_CLASS (klass)->sc_deactivate = pdp_ppp_internal_real_sc_deactivate;
	FSO_GSM_PDP_HANDLER_CLASS (klass)->sc_deactivate_finish = pdp_ppp_internal_real_sc_deactivate_finish;
	FSO_GSM_PDP_HANDLER_CLASS (klass)->statusUpdate = pdp_ppp_internal_real_statusUpdate;
	FSO_GSM_PDP_HANDLER_CLASS (klass)->statusUpdate_finish = pdp_ppp_internal_real_statusUpdate_finish;
	G_OBJECT_CLASS (klass)->constructor = pdp_ppp_internal_constructor;
	G_OBJECT_CLASS (klass)->finalize = pdp_ppp_internal_finalize;
}


static void pdp_ppp_internal_instance_init (PdpPppInternal * self) {
	self->priv = PDP_PPP_INTERNAL_GET_PRIVATE (self);
}


static void pdp_ppp_internal_finalize (GObject* obj) {
	PdpPppInternal * self;
	self = PDP_PPP_INTERNAL (obj);
	_g_object_unref0 (self->priv->transport);
	_g_at_ppp_unref0 (self->priv->ppp);
	_g_io_channel_unref0 (self->priv->iochannel);
	G_OBJECT_CLASS (pdp_ppp_internal_parent_class)->finalize (obj);
}


/**
 * @class Pdp.PppInternal
 *
 * Pdp Handler implemented with the internal PPP stack
 **/
GType pdp_ppp_internal_get_type (void) {
	return pdp_ppp_internal_type_id;
}


GType pdp_ppp_internal_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (PdpPppInternalClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdp_ppp_internal_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PdpPppInternal), 0, (GInstanceInitFunc) pdp_ppp_internal_instance_init, NULL };
	pdp_ppp_internal_type_id = g_type_module_register_type (module, FSO_GSM_TYPE_PDP_HANDLER, "PdpPppInternal", &g_define_type_info, 0);
	return pdp_ppp_internal_type_id;
}


/**
 * This function gets called on plugin initialization time.
 * @return the name of your plugin here
 * @note that it needs to be a name in the format <subsystem>.<plugin>
 * else your module will be unloaded immediately.
 **/
gchar* fso_factory_function (FsoFrameworkSubsystem* subsystem, GError** error) {
	gchar* result = NULL;
	FsoFrameworkLogger* _tmp0_;
	FsoFrameworkSmartKeyFile* _tmp1_;
	FsoFrameworkSmartKeyFile* _tmp2_;
	FsoFrameworkSmartKeyFile* config;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_;
	g_return_val_if_fail (subsystem != NULL, NULL);
	_tmp0_ = fso_framework_theLogger;
	fso_framework_logger_debug (_tmp0_, "pdp_ppp_internal fso_factory_function");
	_tmp1_ = fso_framework_theConfig;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	config = _tmp2_;
	_tmp3_ = fso_framework_smart_key_file_stringValue (config, "cornucopia", "sysfs_root", "/sys");
	_g_free0 (sysfs_root);
	sysfs_root = _tmp3_;
	_tmp4_ = fso_framework_smart_key_file_stringValue (config, "cornucopia", "devfs_root", "/dev");
	_g_free0 (devfs_root);
	devfs_root = _tmp4_;
	_tmp5_ = g_strdup (PDP_PPP_INTERNAL_MODULE_NAME);
	result = _tmp5_;
	_g_object_unref0 (config);
	return result;
}


void fso_register_function (GTypeModule* module) {
	g_return_if_fail (module != NULL);
	pdp_ppp_internal_register_type (module);
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



