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

/*
 * Copyright (C) 2009-2011 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
 *                         Klaus 'mrmoku' Kurzmann <mok@fluxnetz.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 <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <freesmartphone.h>
#include <fsobasics.h>


#define PDP_TYPE_OPTION_GTM601 (pdp_option_gtm601_get_type ())
#define PDP_OPTION_GTM601(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDP_TYPE_OPTION_GTM601, PdpOptionGtm601))
#define PDP_OPTION_GTM601_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDP_TYPE_OPTION_GTM601, PdpOptionGtm601Class))
#define PDP_IS_OPTION_GTM601(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDP_TYPE_OPTION_GTM601))
#define PDP_IS_OPTION_GTM601_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDP_TYPE_OPTION_GTM601))
#define PDP_OPTION_GTM601_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDP_TYPE_OPTION_GTM601, PdpOptionGtm601Class))

typedef struct _PdpOptionGtm601 PdpOptionGtm601;
typedef struct _PdpOptionGtm601Class PdpOptionGtm601Class;
typedef struct _PdpOptionGtm601Private PdpOptionGtm601Private;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GTM601_TYPE_UNDERSCORE_OWANCALL (gtm601_underscore_owancall_get_type ())
#define GTM601_UNDERSCORE_OWANCALL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTM601_TYPE_UNDERSCORE_OWANCALL, Gtm601UnderscoreOWANCALL))
#define GTM601_UNDERSCORE_OWANCALL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTM601_TYPE_UNDERSCORE_OWANCALL, Gtm601UnderscoreOWANCALLClass))
#define GTM601_IS_UNDERSCORE_OWANCALL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTM601_TYPE_UNDERSCORE_OWANCALL))
#define GTM601_IS_UNDERSCORE_OWANCALL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTM601_TYPE_UNDERSCORE_OWANCALL))
#define GTM601_UNDERSCORE_OWANCALL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTM601_TYPE_UNDERSCORE_OWANCALL, Gtm601UnderscoreOWANCALLClass))

typedef struct _Gtm601UnderscoreOWANCALL Gtm601UnderscoreOWANCALL;
typedef struct _Gtm601UnderscoreOWANCALLClass Gtm601UnderscoreOWANCALLClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define GTM601_TYPE_UNDERSCORE_OWANDATA (gtm601_underscore_owandata_get_type ())
#define GTM601_UNDERSCORE_OWANDATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTM601_TYPE_UNDERSCORE_OWANDATA, Gtm601UnderscoreOWANDATA))
#define GTM601_UNDERSCORE_OWANDATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTM601_TYPE_UNDERSCORE_OWANDATA, Gtm601UnderscoreOWANDATAClass))
#define GTM601_IS_UNDERSCORE_OWANDATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTM601_TYPE_UNDERSCORE_OWANDATA))
#define GTM601_IS_UNDERSCORE_OWANDATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTM601_TYPE_UNDERSCORE_OWANDATA))
#define GTM601_UNDERSCORE_OWANDATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTM601_TYPE_UNDERSCORE_OWANDATA, Gtm601UnderscoreOWANDATAClass))

typedef struct _Gtm601UnderscoreOWANDATA Gtm601UnderscoreOWANDATA;
typedef struct _Gtm601UnderscoreOWANDATAClass Gtm601UnderscoreOWANDATAClass;
typedef struct _Gtm601UnderscoreOWANDATAPrivate Gtm601UnderscoreOWANDATAPrivate;
#define _fso_gsm_route_info_unref0(var) ((var == NULL) ? NULL : (var = (fso_gsm_route_info_unref (var), NULL)))
typedef struct _PdpOptionGtm601ScActivateData PdpOptionGtm601ScActivateData;
typedef struct _PdpOptionGtm601ScDeactivateData PdpOptionGtm601ScDeactivateData;
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _pdp_option_gtm601_statusUpdateData pdp_option_gtm601_statusUpdateData;

struct _PdpOptionGtm601 {
	FsoGsmPdpHandler parent_instance;
	PdpOptionGtm601Private * priv;
};

struct _PdpOptionGtm601Class {
	FsoGsmPdpHandlerClass parent_class;
};

struct _Gtm601UnderscoreOWANDATA {
	FsoGsmAbstractAtCommand parent_instance;
	Gtm601UnderscoreOWANDATAPrivate * priv;
	gboolean connected;
	gchar* ip;
	gchar* gateway;
	gchar* dns1;
	gchar* dns2;
	gchar* nbns1;
	gchar* nbns2;
	gchar* speed;
};

struct _Gtm601UnderscoreOWANDATAClass {
	FsoGsmAbstractAtCommandClass parent_class;
};

struct _PdpOptionGtm601ScActivateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	PdpOptionGtm601* self;
	FsoGsmModem* _tmp0_;
	FsoGsmModemData* _tmp1_;
	FsoGsmModemData* data;
	FsoGsmModemData* _tmp2_;
	FsoGsmContextParams* _tmp3_;
	GError* _tmp4_;
	FsoGsmModemData* _tmp5_;
	FsoGsmContextParams* _tmp6_;
	const gchar* _tmp7_;
	GError* _tmp8_;
	FsoGsmModem* _tmp9_;
	gpointer _tmp10_;
	Gtm601UnderscoreOWANCALL* cmd;
	FsoGsmModem* _tmp11_;
	Gtm601UnderscoreOWANCALL* _tmp12_;
	Gtm601UnderscoreOWANCALL* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gint _tmp16_;
	gchar** _tmp17_;
	gchar** _tmp18_;
	gint _tmp18__length1;
	gchar** response;
	gint response_length1;
	gint _response_size_;
	Gtm601UnderscoreOWANCALL* _tmp19_;
	gchar** _tmp20_;
	gint _tmp20__length1;
	GError* e;
	GError* _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	GError* _tmp26_;
	GError* _tmp27_;
	FsoGsmModem* _tmp28_;
	gpointer _tmp29_;
	Gtm601UnderscoreOWANDATA* cmd2;
	FsoGsmModem* _tmp30_;
	Gtm601UnderscoreOWANDATA* _tmp31_;
	Gtm601UnderscoreOWANDATA* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gint _tmp35_;
	gchar** _tmp36_;
	gchar** _tmp37_;
	gint _tmp37__length1;
	gchar** response2;
	gint response2_length1;
	gint _response2_size_;
	Gtm601UnderscoreOWANDATA* _tmp38_;
	gchar** _tmp39_;
	gint _tmp39__length1;
	Gtm601UnderscoreOWANDATA* _tmp40_;
	gboolean _tmp41_;
	GError* _tmp42_;
	FsoFrameworkLogger* _tmp43_;
	gboolean _tmp44_;
	FsoFrameworkLogger* _tmp45_;
	Gtm601UnderscoreOWANDATA* _tmp46_;
	const gchar* _tmp47_;
	const gchar* _tmp48_;
	gchar* _tmp49_;
	gchar* _tmp50_;
	gboolean _tmp51_;
	FsoFrameworkLogger* _tmp52_;
	Gtm601UnderscoreOWANDATA* _tmp53_;
	const gchar* _tmp54_;
	const gchar* _tmp55_;
	Gtm601UnderscoreOWANDATA* _tmp56_;
	const gchar* _tmp57_;
	const gchar* _tmp58_;
	Gtm601UnderscoreOWANDATA* _tmp59_;
	const gchar* _tmp60_;
	const gchar* _tmp61_;
	gchar* _tmp62_;
	gchar* _tmp63_;
	gboolean _tmp64_;
	gchar* _tmp65_;
	Gtm601UnderscoreOWANDATA* _tmp66_;
	const gchar* _tmp67_;
	gchar* _tmp68_;
	gchar* _tmp69_;
	Gtm601UnderscoreOWANDATA* _tmp70_;
	const gchar* _tmp71_;
	gchar* _tmp72_;
	Gtm601UnderscoreOWANDATA* _tmp73_;
	const gchar* _tmp74_;
	gchar* _tmp75_;
	Gtm601UnderscoreOWANDATA* _tmp76_;
	const gchar* _tmp77_;
	gchar* _tmp78_;
	FsoGsmRouteInfo* _tmp79_;
	FsoGsmRouteInfo* route;
	FsoGsmRouteInfo* _tmp80_;
	GError* e2;
	GError* _tmp81_;
	const gchar* _tmp82_;
	const gchar* _tmp83_;
	gchar* _tmp84_;
	gchar* _tmp85_;
	GError* _tmp86_;
	GError* _tmp87_;
	GError * _inner_error_;
};

struct _PdpOptionGtm601ScDeactivateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	PdpOptionGtm601* self;
	FsoGsmModem* _tmp0_;
	gpointer _tmp1_;
	Gtm601UnderscoreOWANCALL* cmd;
	FsoGsmModem* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gint _tmp5_;
	gchar** _tmp6_;
	gchar** _tmp7_;
	gint _tmp7__length1;
	gchar** response;
	gint response_length1;
	gint _response_size_;
	GError* e;
	FsoFrameworkLogger* _tmp8_;
	GError* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	GError * _inner_error_;
};

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


static gpointer pdp_option_gtm601_parent_class = NULL;
static GType pdp_option_gtm601_type_id = 0;

GType pdp_option_gtm601_get_type (void) G_GNUC_CONST;
GType pdp_option_gtm601_register_type (GTypeModule * module);
enum  {
	PDP_OPTION_GTM601_DUMMY_PROPERTY
};
#define PDP_OPTION_GTM601_MODULE_NAME "fsogsm.pdp_option_gtm601"
#define PDP_OPTION_GTM601_HSO_IFACE "hso0"
static gchar* pdp_option_gtm601_real_repr (FsoFrameworkAbstractObject* base);
static void pdp_option_gtm601_real_sc_activate_data_free (gpointer _data);
static void pdp_option_gtm601_real_sc_activate (FsoGsmPdpHandler* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean pdp_option_gtm601_real_sc_activate_co (PdpOptionGtm601ScActivateData* _data_);
GType gtm601_underscore_owancall_get_type (void) G_GNUC_CONST;
GType gtm601_underscore_owancall_register_type (GTypeModule * module);
gchar* gtm601_underscore_owancall_issue (Gtm601UnderscoreOWANCALL* self, gboolean connect);
static void pdp_option_gtm601_sc_activate_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
GType gtm601_underscore_owandata_get_type (void) G_GNUC_CONST;
GType gtm601_underscore_owandata_register_type (GTypeModule * module);
gchar* gtm601_underscore_owandata_issue (Gtm601UnderscoreOWANDATA* self);
static void pdp_option_gtm601_real_sc_deactivate_data_free (gpointer _data);
static void pdp_option_gtm601_real_sc_deactivate (FsoGsmPdpHandler* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean pdp_option_gtm601_real_sc_deactivate_co (PdpOptionGtm601ScDeactivateData* _data_);
static void pdp_option_gtm601_sc_deactivate_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void pdp_option_gtm601_real_statusUpdate_data_free (gpointer _data);
static void pdp_option_gtm601_real_statusUpdate (FsoGsmPdpHandler* base, const gchar* status, GHashTable* properties, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean pdp_option_gtm601_real_statusUpdate_co (pdp_option_gtm601_statusUpdateData* _data_);
PdpOptionGtm601* pdp_option_gtm601_new (void);
PdpOptionGtm601* pdp_option_gtm601_construct (GType object_type);
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_option_gtm601_real_repr (FsoFrameworkAbstractObject* base) {
	PdpOptionGtm601 * self;
	gchar* result = NULL;
	gchar* _tmp0_;
	self = (PdpOptionGtm601*) base;
	_tmp0_ = g_strdup ("<>");
	result = _tmp0_;
	return result;
}


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


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


static void pdp_option_gtm601_real_sc_activate (FsoGsmPdpHandler* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	PdpOptionGtm601 * self;
	PdpOptionGtm601ScActivateData* _data_;
	PdpOptionGtm601* _tmp0_;
	self = (PdpOptionGtm601*) base;
	_data_ = g_slice_new0 (PdpOptionGtm601ScActivateData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, pdp_option_gtm601_real_sc_activate);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, pdp_option_gtm601_real_sc_activate_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	pdp_option_gtm601_real_sc_activate_co (_data_);
}


static void pdp_option_gtm601_real_sc_activate_finish (FsoGsmPdpHandler* base, GAsyncResult* _res_, GError** error) {
	PdpOptionGtm601ScActivateData* _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_option_gtm601_sc_activate_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	PdpOptionGtm601ScActivateData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	pdp_option_gtm601_real_sc_activate_co (_data_);
}


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;
}


static gboolean pdp_option_gtm601_real_sc_activate_co (PdpOptionGtm601ScActivateData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		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) {
		_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) {
		_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_->_tmp9_ = fso_gsm_theModem;
		_data_->_tmp10_ = NULL;
		_data_->_tmp10_ = fso_gsm_modem_createAtCommand (_data_->_tmp9_, GTM601_TYPE_UNDERSCORE_OWANCALL, (GBoxedCopyFunc) g_object_ref, g_object_unref, "_OWANCALL");
		_data_->cmd = (Gtm601UnderscoreOWANCALL*) _data_->_tmp10_;
		_data_->_tmp11_ = fso_gsm_theModem;
		_data_->_tmp12_ = _data_->cmd;
		_data_->_tmp13_ = _data_->cmd;
		_data_->_tmp14_ = NULL;
		_data_->_tmp14_ = gtm601_underscore_owancall_issue (_data_->_tmp13_, TRUE);
		_data_->_tmp15_ = _data_->_tmp14_;
		_data_->_tmp16_ = 0;
		_data_->_state_ = 1;
		fso_gsm_modem_processAtCommandAsync (_data_->_tmp11_, (FsoGsmAtCommand*) _data_->_tmp12_, _data_->_tmp15_, FSO_GSM_MODEM_DEFAULT_RETRIES, pdp_option_gtm601_sc_activate_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp17_ = NULL;
		_data_->_tmp17_ = fso_gsm_modem_processAtCommandAsync_finish (_data_->_tmp11_, _data_->_res_, &_data_->_tmp16_);
		_data_->_tmp18_ = _data_->_tmp17_;
		_data_->_tmp18__length1 = _data_->_tmp16_;
		_g_free0 (_data_->_tmp15_);
		_data_->response = _data_->_tmp18_;
		_data_->response_length1 = _data_->_tmp18__length1;
		_data_->_response_size_ = _data_->response_length1;
		_data_->_tmp19_ = _data_->cmd;
		_data_->_tmp20_ = _data_->response;
		_data_->_tmp20__length1 = _data_->response_length1;
		fso_gsm_checkResponseOk ((FsoGsmAtCommand*) _data_->_tmp19_, _data_->_tmp20_, _data_->_tmp20__length1, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			_data_->response = (_vala_array_free (_data_->response, _data_->response_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (_data_->cmd);
			goto __catch3_g_error;
		}
		_data_->response = (_vala_array_free (_data_->response, _data_->response_length1, (GDestroyNotify) g_free), NULL);
		_g_object_unref0 (_data_->cmd);
	}
	goto __finally3;
	__catch3_g_error:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp21_ = _data_->e;
		_data_->_tmp22_ = _data_->_tmp21_->message;
		_data_->_tmp23_ = NULL;
		_data_->_tmp23_ = string_to_string (_data_->_tmp22_);
		_data_->_tmp24_ = NULL;
		_data_->_tmp24_ = g_strconcat ("Failed to execute _OWANCALL command to activate PDP context: ", _data_->_tmp23_, NULL);
		_data_->_tmp25_ = _data_->_tmp24_;
		_data_->_tmp26_ = g_error_new_literal (FREE_SMARTPHONE_ERROR, FREE_SMARTPHONE_ERROR_INTERNAL_ERROR, _data_->_tmp25_);
		_data_->_tmp27_ = _data_->_tmp26_;
		_g_free0 (_data_->_tmp25_);
		_data_->_inner_error_ = _data_->_tmp27_;
		_g_error_free0 (_data_->e);
		goto __finally3;
	}
	__finally3:
	if (_data_->_inner_error_ != NULL) {
		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_->_tmp28_ = fso_gsm_theModem;
		_data_->_tmp29_ = NULL;
		_data_->_tmp29_ = fso_gsm_modem_createAtCommand (_data_->_tmp28_, GTM601_TYPE_UNDERSCORE_OWANDATA, (GBoxedCopyFunc) g_object_ref, g_object_unref, "_OWANDATA");
		_data_->cmd2 = (Gtm601UnderscoreOWANDATA*) _data_->_tmp29_;
		_data_->_tmp30_ = fso_gsm_theModem;
		_data_->_tmp31_ = _data_->cmd2;
		_data_->_tmp32_ = _data_->cmd2;
		_data_->_tmp33_ = NULL;
		_data_->_tmp33_ = gtm601_underscore_owandata_issue (_data_->_tmp32_);
		_data_->_tmp34_ = _data_->_tmp33_;
		_data_->_tmp35_ = 0;
		_data_->_state_ = 2;
		fso_gsm_modem_processAtCommandAsync (_data_->_tmp30_, (FsoGsmAtCommand*) _data_->_tmp31_, _data_->_tmp34_, FSO_GSM_MODEM_DEFAULT_RETRIES, pdp_option_gtm601_sc_activate_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp36_ = NULL;
		_data_->_tmp36_ = fso_gsm_modem_processAtCommandAsync_finish (_data_->_tmp30_, _data_->_res_, &_data_->_tmp35_);
		_data_->_tmp37_ = _data_->_tmp36_;
		_data_->_tmp37__length1 = _data_->_tmp35_;
		_g_free0 (_data_->_tmp34_);
		_data_->response2 = _data_->_tmp37_;
		_data_->response2_length1 = _data_->_tmp37__length1;
		_data_->_response2_size_ = _data_->response2_length1;
		_data_->_tmp38_ = _data_->cmd2;
		_data_->_tmp39_ = _data_->response2;
		_data_->_tmp39__length1 = _data_->response2_length1;
		fso_gsm_checkResponseOk ((FsoGsmAtCommand*) _data_->_tmp38_, _data_->_tmp39_, _data_->_tmp39__length1, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			_data_->response2 = (_vala_array_free (_data_->response2, _data_->response2_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (_data_->cmd2);
			goto __catch4_g_error;
		}
		_data_->_tmp40_ = _data_->cmd2;
		_data_->_tmp41_ = _data_->_tmp40_->connected;
		if (!_data_->_tmp41_) {
			_data_->_tmp42_ = g_error_new_literal (FREE_SMARTPHONE_ERROR, FREE_SMARTPHONE_ERROR_INTERNAL_ERROR, "Modem reports that PDP session is not yet established!");
			_data_->_inner_error_ = _data_->_tmp42_;
			_data_->response2 = (_vala_array_free (_data_->response2, _data_->response2_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (_data_->cmd2);
			goto __catch4_g_error;
		}
		_data_->_tmp43_ = ((FsoFrameworkAbstractObject*) _data_->self)->logger;
		_data_->_tmp44_ = FALSE;
		_data_->_tmp44_ = fso_framework_logger_debug (_data_->_tmp43_, "Got IP configuration from modem:");
		g_assert (_data_->_tmp44_);
		_data_->_tmp45_ = ((FsoFrameworkAbstractObject*) _data_->self)->logger;
		_data_->_tmp46_ = _data_->cmd2;
		_data_->_tmp47_ = _data_->_tmp46_->ip;
		_data_->_tmp48_ = NULL;
		_data_->_tmp48_ = string_to_string (_data_->_tmp47_);
		_data_->_tmp49_ = NULL;
		_data_->_tmp49_ = g_strconcat ("local = ", _data_->_tmp48_, NULL);
		_data_->_tmp50_ = _data_->_tmp49_;
		_data_->_tmp51_ = FALSE;
		_data_->_tmp51_ = fso_framework_logger_debug (_data_->_tmp45_, _data_->_tmp50_);
		g_assert (_data_->_tmp51_);
		_g_free0 (_data_->_tmp50_);
		_data_->_tmp52_ = ((FsoFrameworkAbstractObject*) _data_->self)->logger;
		_data_->_tmp53_ = _data_->cmd2;
		_data_->_tmp54_ = _data_->_tmp53_->gateway;
		_data_->_tmp55_ = NULL;
		_data_->_tmp55_ = string_to_string (_data_->_tmp54_);
		_data_->_tmp56_ = _data_->cmd2;
		_data_->_tmp57_ = _data_->_tmp56_->dns1;
		_data_->_tmp58_ = NULL;
		_data_->_tmp58_ = string_to_string (_data_->_tmp57_);
		_data_->_tmp59_ = _data_->cmd2;
		_data_->_tmp60_ = _data_->_tmp59_->dns2;
		_data_->_tmp61_ = NULL;
		_data_->_tmp61_ = string_to_string (_data_->_tmp60_);
		_data_->_tmp62_ = NULL;
		_data_->_tmp62_ = g_strconcat ("gateway = ", _data_->_tmp55_, ", dns1 = ", _data_->_tmp58_, ", dns2 = ", _data_->_tmp61_, NULL);
		_data_->_tmp63_ = _data_->_tmp62_;
		_data_->_tmp64_ = FALSE;
		_data_->_tmp64_ = fso_framework_logger_debug (_data_->_tmp52_, _data_->_tmp63_);
		g_assert (_data_->_tmp64_);
		_g_free0 (_data_->_tmp63_);
		_data_->_tmp65_ = g_strdup (PDP_OPTION_GTM601_HSO_IFACE);
		_data_->_tmp66_ = _data_->cmd2;
		_data_->_tmp67_ = _data_->_tmp66_->ip;
		_data_->_tmp68_ = g_strdup (_data_->_tmp67_);
		_data_->_tmp69_ = g_strdup ("255.255.255.0");
		_data_->_tmp70_ = _data_->cmd2;
		_data_->_tmp71_ = _data_->_tmp70_->gateway;
		_data_->_tmp72_ = g_strdup (_data_->_tmp71_);
		_data_->_tmp73_ = _data_->cmd2;
		_data_->_tmp74_ = _data_->_tmp73_->dns1;
		_data_->_tmp75_ = g_strdup (_data_->_tmp74_);
		_data_->_tmp76_ = _data_->cmd2;
		_data_->_tmp77_ = _data_->_tmp76_->dns2;
		_data_->_tmp78_ = g_strdup (_data_->_tmp77_);
		_data_->_tmp79_ = NULL;
		_data_->_tmp79_ = fso_gsm_route_info_new ();
		_g_free0 (_data_->_tmp79_->iface);
		_data_->_tmp79_->iface = _data_->_tmp65_;
		_g_free0 (_data_->_tmp79_->ipv4addr);
		_data_->_tmp79_->ipv4addr = _data_->_tmp68_;
		_g_free0 (_data_->_tmp79_->ipv4mask);
		_data_->_tmp79_->ipv4mask = _data_->_tmp69_;
		_g_free0 (_data_->_tmp79_->ipv4gateway);
		_data_->_tmp79_->ipv4gateway = _data_->_tmp72_;
		_g_free0 (_data_->_tmp79_->dns1);
		_data_->_tmp79_->dns1 = _data_->_tmp75_;
		_g_free0 (_data_->_tmp79_->dns2);
		_data_->_tmp79_->dns2 = _data_->_tmp78_;
		_data_->route = _data_->_tmp79_;
		_data_->_tmp80_ = _data_->route;
		fso_gsm_ipdp_handler_connectedWithNewDefaultRoute ((FsoGsmIPdpHandler*) _data_->self, _data_->_tmp80_, NULL, NULL);
		_fso_gsm_route_info_unref0 (_data_->route);
		_data_->response2 = (_vala_array_free (_data_->response2, _data_->response2_length1, (GDestroyNotify) g_free), NULL);
		_g_object_unref0 (_data_->cmd2);
	}
	goto __finally4;
	__catch4_g_error:
	{
		_data_->e2 = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp81_ = _data_->e2;
		_data_->_tmp82_ = _data_->_tmp81_->message;
		_data_->_tmp83_ = NULL;
		_data_->_tmp83_ = string_to_string (_data_->_tmp82_);
		_data_->_tmp84_ = NULL;
		_data_->_tmp84_ = g_strconcat ("Failed to execute _OWANDATA to retrieve PDP context configuration from" \
" modem: ", _data_->_tmp83_, NULL);
		_data_->_tmp85_ = _data_->_tmp84_;
		_data_->_tmp86_ = g_error_new_literal (FREE_SMARTPHONE_ERROR, FREE_SMARTPHONE_ERROR_INTERNAL_ERROR, _data_->_tmp85_);
		_data_->_tmp87_ = _data_->_tmp86_;
		_g_free0 (_data_->_tmp85_);
		_data_->_inner_error_ = _data_->_tmp87_;
		_g_error_free0 (_data_->e2);
		goto __finally4;
	}
	__finally4:
	if (_data_->_inner_error_ != NULL) {
		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;
		}
	}
	_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_option_gtm601_real_sc_deactivate_data_free (gpointer _data) {
	PdpOptionGtm601ScDeactivateData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (PdpOptionGtm601ScDeactivateData, _data_);
}


static void pdp_option_gtm601_real_sc_deactivate (FsoGsmPdpHandler* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	PdpOptionGtm601 * self;
	PdpOptionGtm601ScDeactivateData* _data_;
	PdpOptionGtm601* _tmp0_;
	self = (PdpOptionGtm601*) base;
	_data_ = g_slice_new0 (PdpOptionGtm601ScDeactivateData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, pdp_option_gtm601_real_sc_deactivate);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, pdp_option_gtm601_real_sc_deactivate_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	pdp_option_gtm601_real_sc_deactivate_co (_data_);
}


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


static void pdp_option_gtm601_sc_deactivate_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	PdpOptionGtm601ScDeactivateData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	pdp_option_gtm601_real_sc_deactivate_co (_data_);
}


static gboolean pdp_option_gtm601_real_sc_deactivate_co (PdpOptionGtm601ScDeactivateData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = fso_gsm_theModem;
		_data_->_tmp1_ = NULL;
		_data_->_tmp1_ = fso_gsm_modem_createAtCommand (_data_->_tmp0_, GTM601_TYPE_UNDERSCORE_OWANCALL, (GBoxedCopyFunc) g_object_ref, g_object_unref, "_OWANCALL");
		_data_->cmd = (Gtm601UnderscoreOWANCALL*) _data_->_tmp1_;
		_data_->_tmp2_ = fso_gsm_theModem;
		_data_->_tmp3_ = NULL;
		_data_->_tmp3_ = gtm601_underscore_owancall_issue (_data_->cmd, FALSE);
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = 0;
		_data_->_state_ = 1;
		fso_gsm_modem_processAtCommandAsync (_data_->_tmp2_, (FsoGsmAtCommand*) _data_->cmd, _data_->_tmp4_, FSO_GSM_MODEM_DEFAULT_RETRIES, pdp_option_gtm601_sc_deactivate_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp6_ = NULL;
		_data_->_tmp6_ = fso_gsm_modem_processAtCommandAsync_finish (_data_->_tmp2_, _data_->_res_, &_data_->_tmp5_);
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp7__length1 = _data_->_tmp5_;
		_g_free0 (_data_->_tmp4_);
		_data_->response = _data_->_tmp7_;
		_data_->response_length1 = _data_->_tmp7__length1;
		_data_->_response_size_ = _data_->response_length1;
		fso_gsm_checkResponseOk ((FsoGsmAtCommand*) _data_->cmd, _data_->response, _data_->response_length1, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			_data_->response = (_vala_array_free (_data_->response, _data_->response_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (_data_->cmd);
			goto __catch5_g_error;
		}
		_data_->response = (_vala_array_free (_data_->response, _data_->response_length1, (GDestroyNotify) g_free), NULL);
		_g_object_unref0 (_data_->cmd);
	}
	goto __finally5;
	__catch5_g_error:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp8_ = ((FsoFrameworkAbstractObject*) _data_->self)->logger;
		_data_->_tmp9_ = _data_->e;
		_data_->_tmp10_ = _data_->_tmp9_->message;
		_data_->_tmp11_ = NULL;
		_data_->_tmp11_ = string_to_string (_data_->_tmp10_);
		_data_->_tmp12_ = NULL;
		_data_->_tmp12_ = g_strconcat ("Failed to execute _OWANDATA command to deactivate PDP context: ", _data_->_tmp11_, NULL);
		_data_->_tmp13_ = _data_->_tmp12_;
		fso_framework_logger_error (_data_->_tmp8_, _data_->_tmp13_);
		_g_free0 (_data_->_tmp13_);
		_g_error_free0 (_data_->e);
	}
	__finally5:
	if (_data_->_inner_error_ != NULL) {
		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;
	}
	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_option_gtm601_real_statusUpdate_data_free (gpointer _data) {
	pdp_option_gtm601_statusUpdateData* _data_;
	_data_ = _data;
	_g_free0 (_data_->status);
	_g_hash_table_unref0 (_data_->properties);
	_g_object_unref0 (_data_->self);
	g_slice_free (pdp_option_gtm601_statusUpdateData, _data_);
}


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


static void pdp_option_gtm601_real_statusUpdate (FsoGsmPdpHandler* base, const gchar* status, GHashTable* properties, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	PdpOptionGtm601 * self;
	pdp_option_gtm601_statusUpdateData* _data_;
	PdpOptionGtm601* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GHashTable* _tmp3_;
	GHashTable* _tmp4_;
	self = (PdpOptionGtm601*) base;
	_data_ = g_slice_new0 (pdp_option_gtm601_statusUpdateData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, pdp_option_gtm601_real_statusUpdate);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, pdp_option_gtm601_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_option_gtm601_real_statusUpdate_co (_data_);
}


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


static gboolean pdp_option_gtm601_real_statusUpdate_co (pdp_option_gtm601_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;
}


PdpOptionGtm601* pdp_option_gtm601_construct (GType object_type) {
	PdpOptionGtm601 * self = NULL;
	self = (PdpOptionGtm601*) fso_gsm_pdp_handler_construct (object_type);
	return self;
}


PdpOptionGtm601* pdp_option_gtm601_new (void) {
	return pdp_option_gtm601_construct (PDP_TYPE_OPTION_GTM601);
}


static void pdp_option_gtm601_class_init (PdpOptionGtm601Class * klass) {
	pdp_option_gtm601_parent_class = g_type_class_peek_parent (klass);
	FSO_FRAMEWORK_ABSTRACT_OBJECT_CLASS (klass)->repr = pdp_option_gtm601_real_repr;
	FSO_GSM_PDP_HANDLER_CLASS (klass)->sc_activate = pdp_option_gtm601_real_sc_activate;
	FSO_GSM_PDP_HANDLER_CLASS (klass)->sc_activate_finish = pdp_option_gtm601_real_sc_activate_finish;
	FSO_GSM_PDP_HANDLER_CLASS (klass)->sc_deactivate = pdp_option_gtm601_real_sc_deactivate;
	FSO_GSM_PDP_HANDLER_CLASS (klass)->sc_deactivate_finish = pdp_option_gtm601_real_sc_deactivate_finish;
	FSO_GSM_PDP_HANDLER_CLASS (klass)->statusUpdate = pdp_option_gtm601_real_statusUpdate;
	FSO_GSM_PDP_HANDLER_CLASS (klass)->statusUpdate_finish = pdp_option_gtm601_real_statusUpdate_finish;
}


static void pdp_option_gtm601_instance_init (PdpOptionGtm601 * self) {
}


/**
 * @class Pdp.OptionGtm601
 *
 * Pdp Handler implemented with the proprietary Qualcomm Management Interface protocol
 **/
GType pdp_option_gtm601_get_type (void) {
	return pdp_option_gtm601_type_id;
}


GType pdp_option_gtm601_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (PdpOptionGtm601Class), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdp_option_gtm601_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PdpOptionGtm601), 0, (GInstanceInitFunc) pdp_option_gtm601_instance_init, NULL };
	pdp_option_gtm601_type_id = g_type_module_register_type (module, FSO_GSM_TYPE_PDP_HANDLER, "PdpOptionGtm601", &g_define_type_info, 0);
	return pdp_option_gtm601_type_id;
}


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);
}



