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

/*
 * Copyright (C) 2009-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 <stdlib.h>
#include <string.h>
#include <fsogsm.h>
#include <fsotransport.h>
#include <gee.h>
#include <fsobasics.h>
#include <gio/gio.h>
#include <fsoframework.h>


#define CINTERION_MC75_TYPE_MODEM (cinterion_mc75_modem_get_type ())
#define CINTERION_MC75_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CINTERION_MC75_TYPE_MODEM, CinterionMc75Modem))
#define CINTERION_MC75_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CINTERION_MC75_TYPE_MODEM, CinterionMc75ModemClass))
#define CINTERION_MC75_IS_MODEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CINTERION_MC75_TYPE_MODEM))
#define CINTERION_MC75_IS_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CINTERION_MC75_TYPE_MODEM))
#define CINTERION_MC75_MODEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CINTERION_MC75_TYPE_MODEM, CinterionMc75ModemClass))

typedef struct _CinterionMc75Modem CinterionMc75Modem;
typedef struct _CinterionMc75ModemClass CinterionMc75ModemClass;
typedef struct _CinterionMc75ModemPrivate CinterionMc75ModemPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _fso_gsm_at_command_sequence_unref0(var) ((var == NULL) ? NULL : (var = (fso_gsm_at_command_sequence_unref (var), NULL)))
typedef struct _CinterionMc75ModemOpenData CinterionMc75ModemOpenData;
typedef struct _CinterionMc75ModemCloseData CinterionMc75ModemCloseData;

#define CINTERION_MC75_TYPE_UNSOLICITED_RESPONSE_HANDLER (cinterion_mc75_unsolicited_response_handler_get_type ())
#define CINTERION_MC75_UNSOLICITED_RESPONSE_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CINTERION_MC75_TYPE_UNSOLICITED_RESPONSE_HANDLER, CinterionMc75UnsolicitedResponseHandler))
#define CINTERION_MC75_UNSOLICITED_RESPONSE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CINTERION_MC75_TYPE_UNSOLICITED_RESPONSE_HANDLER, CinterionMc75UnsolicitedResponseHandlerClass))
#define CINTERION_MC75_IS_UNSOLICITED_RESPONSE_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CINTERION_MC75_TYPE_UNSOLICITED_RESPONSE_HANDLER))
#define CINTERION_MC75_IS_UNSOLICITED_RESPONSE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CINTERION_MC75_TYPE_UNSOLICITED_RESPONSE_HANDLER))
#define CINTERION_MC75_UNSOLICITED_RESPONSE_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CINTERION_MC75_TYPE_UNSOLICITED_RESPONSE_HANDLER, CinterionMc75UnsolicitedResponseHandlerClass))

typedef struct _CinterionMc75UnsolicitedResponseHandler CinterionMc75UnsolicitedResponseHandler;
typedef struct _CinterionMc75UnsolicitedResponseHandlerClass CinterionMc75UnsolicitedResponseHandlerClass;

struct _CinterionMc75Modem {
	FsoGsmAbstractModem parent_instance;
	CinterionMc75ModemPrivate * priv;
};

struct _CinterionMc75ModemClass {
	FsoGsmAbstractModemClass parent_class;
};

struct _CinterionMc75ModemPrivate {
	FsoFrameworkNgsmBasicMuxTransport* muxtransport;
};

struct _CinterionMc75ModemOpenData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	CinterionMc75Modem* self;
	gboolean result;
	FsoFrameworkTransportSpec* _tmp0_;
	FsoFrameworkTransportSpec* _tmp1_;
	const gchar* _tmp2_;
	gboolean _tmp3_;
	FsoFrameworkTransportSpec* _tmp4_;
	FsoFrameworkTransportSpec* _tmp5_;
	const gchar* _tmp6_;
	FsoFrameworkTransportSpec* _tmp7_;
	FsoFrameworkTransportSpec* _tmp8_;
	guint _tmp9_;
	FsoFrameworkNgsmBasicMuxTransport* _tmp10_;
	FsoFrameworkNgsmBasicMuxTransport* _tmp11_;
	gboolean _tmp12_;
	gboolean _tmp13_;
};

struct _CinterionMc75ModemCloseData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	CinterionMc75Modem* self;
	FsoFrameworkNgsmBasicMuxTransport* _tmp0_;
	FsoFrameworkNgsmBasicMuxTransport* _tmp1_;
};


static gpointer cinterion_mc75_modem_parent_class = NULL;
static GType cinterion_mc75_modem_type_id = 0;

#define CINTERION_MC75_MODULE_NAME "fsogsm.modem_cinterion_mc75"
GType cinterion_mc75_modem_get_type (void) G_GNUC_CONST;
GType cinterion_mc75_modem_register_type (GTypeModule * module);
#define CINTERION_MC75_MODEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CINTERION_MC75_TYPE_MODEM, CinterionMc75ModemPrivate))
enum  {
	CINTERION_MC75_MODEM_DUMMY_PROPERTY
};
static gchar* cinterion_mc75_modem_real_repr (FsoFrameworkAbstractObject* base);
static void cinterion_mc75_modem_real_configureData (FsoGsmAbstractModem* base);
static void cinterion_mc75_modem_real_open_data_free (gpointer _data);
static void cinterion_mc75_modem_real_open (FsoGsmAbstractModem* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean cinterion_mc75_modem_real_open_co (CinterionMc75ModemOpenData* _data_);
static void cinterion_mc75_modem_open_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void cinterion_mc75_modem_real_close_data_free (gpointer _data);
static void cinterion_mc75_modem_real_close (FsoGsmAbstractModem* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean cinterion_mc75_modem_real_close_co (CinterionMc75ModemCloseData* _data_);
static void cinterion_mc75_modem_close_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void cinterion_mc75_modem_real_createChannels (FsoGsmAbstractModem* base);
static FsoGsmUnsolicitedResponseHandler* cinterion_mc75_modem_real_createUnsolicitedHandler (FsoGsmAbstractModem* base);
CinterionMc75UnsolicitedResponseHandler* cinterion_mc75_unsolicited_response_handler_new (void);
CinterionMc75UnsolicitedResponseHandler* cinterion_mc75_unsolicited_response_handler_construct (GType object_type);
GType cinterion_mc75_unsolicited_response_handler_get_type (void) G_GNUC_CONST;
GType cinterion_mc75_unsolicited_response_handler_register_type (GTypeModule * module);
static void cinterion_mc75_modem_real_registerCustomAtCommands (FsoGsmAbstractModem* base, GeeHashMap* commands);
void cinterion_mc75_registerCustomAtCommands (GeeHashMap* table);
static FsoGsmChannel* cinterion_mc75_modem_real_channelForCommand (FsoGsmAbstractModem* base, FsoGsmAtCommand* command, const gchar* query);
static gchar* cinterion_mc75_modem_real_allocateDataPort (FsoGsmAbstractModem* base);
CinterionMc75Modem* cinterion_mc75_modem_new (void);
CinterionMc75Modem* cinterion_mc75_modem_construct (GType object_type);
static void cinterion_mc75_modem_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);

const gchar* CINTERION_MC75_CHANNEL_NAMES[3] = {"main", "data", "call"};

static gchar* cinterion_mc75_modem_real_repr (FsoFrameworkAbstractObject* base) {
	CinterionMc75Modem * self;
	gchar* result = NULL;
	GeeHashMap* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_;
	self = (CinterionMc75Modem*) base;
	_tmp0_ = ((FsoGsmAbstractModem*) self)->channels;
	_tmp1_ = gee_abstract_map_get_size ((GeeMap*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup_printf ("%i", _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strconcat ("<", _tmp4_, "C>", NULL);
	_tmp6_ = _tmp5_;
	_g_free0 (_tmp4_);
	result = _tmp6_;
	return result;
}


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


static void cinterion_mc75_modem_real_configureData (FsoGsmAbstractModem* base) {
	CinterionMc75Modem * self;
	FsoGsmModemData* _tmp0_;
	FsoGsmModemData* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar** _tmp27_ = NULL;
	gchar** _tmp28_;
	gint _tmp28__length1;
	FsoGsmAtCommandSequence* _tmp29_;
	FsoGsmAtCommandSequence* _tmp30_;
	FsoGsmModemData* _tmp31_;
	GeeHashMap* _tmp32_;
	GeeHashMap* _tmp33_;
	GeeHashMap* seq;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar** _tmp36_ = NULL;
	gchar** _tmp37_;
	gint _tmp37__length1;
	FsoGsmAtCommandSequence* _tmp38_;
	FsoGsmAtCommandSequence* _tmp39_;
	FsoGsmModemData* _tmp40_;
	FsoFrameworkSmartKeyFile* _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	gchar* _tmp49_;
	gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	gchar* _tmp53_;
	gchar* _tmp54_;
	gchar* _tmp55_;
	gchar* _tmp56_;
	gchar* _tmp57_;
	gchar* _tmp58_;
	gchar* _tmp59_;
	gchar* _tmp60_;
	gchar* _tmp61_;
	gchar* _tmp62_;
	gchar** _tmp63_ = NULL;
	gchar** _tmp64_;
	gint _tmp64__length1;
	gint _tmp65_ = 0;
	gchar** _tmp66_ = NULL;
	self = (CinterionMc75Modem*) base;
	_tmp0_ = ((FsoGsmAbstractModem*) self)->modem_data;
	g_assert (_tmp0_ != NULL);
	_tmp1_ = ((FsoGsmAbstractModem*) self)->modem_data;
	_tmp1_->simHasReadySignal = TRUE;
	_tmp2_ = g_strdup ("+CREG=2");
	_tmp3_ = g_strdup ("^SM20=0,0");
	_tmp4_ = g_strdup ("^SSET=1");
	_tmp5_ = g_strdup ("^SIND=\"battchg\",1");
	_tmp6_ = g_strdup ("^SIND=\"signal\",1");
	_tmp7_ = g_strdup ("^SIND=\"service\",1");
	_tmp8_ = g_strdup ("^SIND=\"sounder\",1");
	_tmp9_ = g_strdup ("^SIND=\"message\",1");
	_tmp10_ = g_strdup ("^SIND=\"call\",1");
	_tmp11_ = g_strdup ("^SIND=\"roam\",1");
	_tmp12_ = g_strdup ("^SIND=\"smsfull\",1");
	_tmp13_ = g_strdup ("^SIND=\"rssi\",1");
	_tmp14_ = g_strdup ("^SIND=\"audio\",1");
	_tmp15_ = g_strdup ("^SIND=\"simstatus\",1");
	_tmp16_ = g_strdup ("^SIND=\"vmwait1\",1");
	_tmp17_ = g_strdup ("^SIND=\"vmwait2\",1");
	_tmp18_ = g_strdup ("^SIND=\"ciphcall\",1");
	_tmp19_ = g_strdup ("^SIND=\"adnread\",1");
	_tmp20_ = g_strdup ("^SIND=\"eons\",1");
	_tmp21_ = g_strdup ("^SIND=\"nitz\",1");
	_tmp22_ = g_strdup ("^SIND=\"lsta\",1");
	_tmp23_ = g_strdup ("^SIND=\"band\",1");
	_tmp24_ = g_strdup ("^SIND=\"simlocal\",1");
	_tmp25_ = g_strdup ("+CMER=3,0,0,2,0");
	_tmp26_ = g_strdup ("+CFUN=1");
	_tmp27_ = g_new0 (gchar*, 25 + 1);
	_tmp27_[0] = _tmp2_;
	_tmp27_[1] = _tmp3_;
	_tmp27_[2] = _tmp4_;
	_tmp27_[3] = _tmp5_;
	_tmp27_[4] = _tmp6_;
	_tmp27_[5] = _tmp7_;
	_tmp27_[6] = _tmp8_;
	_tmp27_[7] = _tmp9_;
	_tmp27_[8] = _tmp10_;
	_tmp27_[9] = _tmp11_;
	_tmp27_[10] = _tmp12_;
	_tmp27_[11] = _tmp13_;
	_tmp27_[12] = _tmp14_;
	_tmp27_[13] = _tmp15_;
	_tmp27_[14] = _tmp16_;
	_tmp27_[15] = _tmp17_;
	_tmp27_[16] = _tmp18_;
	_tmp27_[17] = _tmp19_;
	_tmp27_[18] = _tmp20_;
	_tmp27_[19] = _tmp21_;
	_tmp27_[20] = _tmp22_;
	_tmp27_[21] = _tmp23_;
	_tmp27_[22] = _tmp24_;
	_tmp27_[23] = _tmp25_;
	_tmp27_[24] = _tmp26_;
	_tmp28_ = _tmp27_;
	_tmp28__length1 = 25;
	_tmp29_ = fso_gsm_at_command_sequence_new (_tmp28_, 25);
	_tmp30_ = _tmp29_;
	fso_gsm_modem_registerAtCommandSequence ((FsoGsmModem*) self, "main", "init", _tmp30_);
	_fso_gsm_at_command_sequence_unref0 (_tmp30_);
	_tmp28_ = (_vala_array_free (_tmp28_, _tmp28__length1, (GDestroyNotify) g_free), NULL);
	_tmp31_ = ((FsoGsmAbstractModem*) self)->modem_data;
	_tmp32_ = _tmp31_->cmdSequences;
	_tmp33_ = _g_object_ref0 (_tmp32_);
	seq = _tmp33_;
	_tmp34_ = g_strdup ("+CSMS=1");
	_tmp35_ = g_strdup ("+CNMI=3,3,3,2,1");
	_tmp36_ = g_new0 (gchar*, 2 + 1);
	_tmp36_[0] = _tmp34_;
	_tmp36_[1] = _tmp35_;
	_tmp37_ = _tmp36_;
	_tmp37__length1 = 2;
	_tmp38_ = fso_gsm_at_command_sequence_new (_tmp37_, 2);
	_tmp39_ = _tmp38_;
	fso_gsm_modem_registerAtCommandSequence ((FsoGsmModem*) self, "main", "registered", _tmp39_);
	_fso_gsm_at_command_sequence_unref0 (_tmp39_);
	_tmp37_ = (_vala_array_free (_tmp37_, _tmp37__length1, (GDestroyNotify) g_free), NULL);
	_tmp40_ = ((FsoGsmAbstractModem*) self)->modem_data;
	_tmp41_ = ((FsoFrameworkAbstractObject*) self)->config;
	_tmp42_ = g_strdup ("115200");
	_tmp43_ = g_strdup ("nodetach");
	_tmp44_ = g_strdup ("nodefaultroute");
	_tmp45_ = g_strdup ("noreplacedefaultroute");
	_tmp46_ = g_strdup ("debug");
	_tmp47_ = g_strdup ("ipcp-accept-local");
	_tmp48_ = g_strdup ("ipcp-accept-remote");
	_tmp49_ = g_strdup ("ktune");
	_tmp50_ = g_strdup ("ipcp-max-failure");
	_tmp51_ = g_strdup ("10");
	_tmp52_ = g_strdup ("local");
	_tmp53_ = g_strdup ("name");
	_tmp54_ = g_strdup ("fsogsmd");
	_tmp55_ = g_strdup ("noauth");
	_tmp56_ = g_strdup ("noccp");
	_tmp57_ = g_strdup ("noipdefault");
	_tmp58_ = g_strdup ("novj");
	_tmp59_ = g_strdup ("novjccomp");
	_tmp60_ = g_strdup ("proxyarp");
	_tmp61_ = g_strdup ("silent");
	_tmp62_ = g_strdup ("usepeerdns");
	_tmp63_ = g_new0 (gchar*, 21 + 1);
	_tmp63_[0] = _tmp42_;
	_tmp63_[1] = _tmp43_;
	_tmp63_[2] = _tmp44_;
	_tmp63_[3] = _tmp45_;
	_tmp63_[4] = _tmp46_;
	_tmp63_[5] = _tmp47_;
	_tmp63_[6] = _tmp48_;
	_tmp63_[7] = _tmp49_;
	_tmp63_[8] = _tmp50_;
	_tmp63_[9] = _tmp51_;
	_tmp63_[10] = _tmp52_;
	_tmp63_[11] = _tmp53_;
	_tmp63_[12] = _tmp54_;
	_tmp63_[13] = _tmp55_;
	_tmp63_[14] = _tmp56_;
	_tmp63_[15] = _tmp57_;
	_tmp63_[16] = _tmp58_;
	_tmp63_[17] = _tmp59_;
	_tmp63_[18] = _tmp60_;
	_tmp63_[19] = _tmp61_;
	_tmp63_[20] = _tmp62_;
	_tmp64_ = _tmp63_;
	_tmp64__length1 = 21;
	_tmp66_ = fso_framework_smart_key_file_stringListValue (_tmp41_, FSO_GSM_CONFIG_SECTION, "ppp_options", _tmp64_, 21, &_tmp65_);
	_tmp40_->pppOptions = (_vala_array_free (_tmp40_->pppOptions, _tmp40_->pppOptions_length1, (GDestroyNotify) g_free), NULL);
	_tmp40_->pppOptions = _tmp66_;
	_tmp40_->pppOptions_length1 = _tmp65_;
	_tmp64_ = (_vala_array_free (_tmp64_, _tmp64__length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (seq);
}


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


static void cinterion_mc75_modem_real_open (FsoGsmAbstractModem* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	CinterionMc75Modem * self;
	CinterionMc75ModemOpenData* _data_;
	CinterionMc75Modem* _tmp0_;
	self = (CinterionMc75Modem*) base;
	_data_ = g_slice_new0 (CinterionMc75ModemOpenData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, cinterion_mc75_modem_real_open);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, cinterion_mc75_modem_real_open_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	cinterion_mc75_modem_real_open_co (_data_);
}


static gboolean cinterion_mc75_modem_real_open_finish (FsoGsmAbstractModem* base, GAsyncResult* _res_) {
	gboolean result;
	CinterionMc75ModemOpenData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
	result = _data_->result;
	return result;
}


static void cinterion_mc75_modem_open_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	CinterionMc75ModemOpenData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	cinterion_mc75_modem_real_open_co (_data_);
}


static gboolean cinterion_mc75_modem_real_open_co (CinterionMc75ModemOpenData* _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_abstract_modem_get_modem_transport_spec ((FsoGsmAbstractModem*) _data_->self);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = _data_->_tmp1_->type;
	_data_->_tmp3_ = FALSE;
	_data_->_tmp3_ = g_str_has_prefix (_data_->_tmp2_, "ngsm");
	if (_data_->_tmp3_) {
		_data_->_tmp4_ = fso_gsm_abstract_modem_get_modem_transport_spec ((FsoGsmAbstractModem*) _data_->self);
		_data_->_tmp5_ = _data_->_tmp4_;
		_data_->_tmp6_ = _data_->_tmp5_->name;
		_data_->_tmp7_ = fso_gsm_abstract_modem_get_modem_transport_spec ((FsoGsmAbstractModem*) _data_->self);
		_data_->_tmp8_ = _data_->_tmp7_;
		_data_->_tmp9_ = _data_->_tmp8_->speed;
		_data_->_tmp10_ = fso_framework_ngsm_basic_mux_transport_new (_data_->_tmp6_, _data_->_tmp9_, (guint) 64);
		_g_object_unref0 (_data_->self->priv->muxtransport);
		_data_->self->priv->muxtransport = _data_->_tmp10_;
		_data_->_tmp11_ = _data_->self->priv->muxtransport;
		_data_->_tmp12_ = FALSE;
		_data_->_tmp12_ = fso_framework_transport_open ((FsoFrameworkTransport*) _data_->_tmp11_);
		if (!_data_->_tmp12_) {
			_data_->result = 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;
		}
	}
	_data_->_state_ = 1;
	FSO_GSM_ABSTRACT_MODEM_CLASS (cinterion_mc75_modem_parent_class)->open (FSO_GSM_ABSTRACT_MODEM (_data_->self), cinterion_mc75_modem_open_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp13_ = FALSE;
	_data_->_tmp13_ = FSO_GSM_ABSTRACT_MODEM_CLASS (cinterion_mc75_modem_parent_class)->open_finish (FSO_GSM_ABSTRACT_MODEM (_data_->self), _data_->_res_);
	_data_->result = _data_->_tmp13_;
	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;
	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 cinterion_mc75_modem_real_close_data_free (gpointer _data) {
	CinterionMc75ModemCloseData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (CinterionMc75ModemCloseData, _data_);
}


static void cinterion_mc75_modem_real_close (FsoGsmAbstractModem* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	CinterionMc75Modem * self;
	CinterionMc75ModemCloseData* _data_;
	CinterionMc75Modem* _tmp0_;
	self = (CinterionMc75Modem*) base;
	_data_ = g_slice_new0 (CinterionMc75ModemCloseData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, cinterion_mc75_modem_real_close);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, cinterion_mc75_modem_real_close_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	cinterion_mc75_modem_real_close_co (_data_);
}


static void cinterion_mc75_modem_real_close_finish (FsoGsmAbstractModem* base, GAsyncResult* _res_) {
	CinterionMc75ModemCloseData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void cinterion_mc75_modem_close_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	CinterionMc75ModemCloseData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	cinterion_mc75_modem_real_close_co (_data_);
}


static gboolean cinterion_mc75_modem_real_close_co (CinterionMc75ModemCloseData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_state_ = 1;
	FSO_GSM_ABSTRACT_MODEM_CLASS (cinterion_mc75_modem_parent_class)->close (FSO_GSM_ABSTRACT_MODEM (_data_->self), cinterion_mc75_modem_close_ready, _data_);
	return FALSE;
	_state_1:
	FSO_GSM_ABSTRACT_MODEM_CLASS (cinterion_mc75_modem_parent_class)->close_finish (FSO_GSM_ABSTRACT_MODEM (_data_->self), _data_->_res_);
	_data_->_tmp0_ = _data_->self->priv->muxtransport;
	if (_data_->_tmp0_ != NULL) {
		_data_->_tmp1_ = _data_->self->priv->muxtransport;
		fso_framework_transport_close ((FsoFrameworkTransport*) _data_->_tmp1_);
		_g_object_unref0 (_data_->self->priv->muxtransport);
		_data_->self->priv->muxtransport = 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 cinterion_mc75_modem_real_createChannels (FsoGsmAbstractModem* base) {
	CinterionMc75Modem * self;
	FsoFrameworkTransportSpec* _tmp0_;
	FsoFrameworkTransportSpec* _tmp1_;
	const gchar* _tmp2_;
	gboolean _tmp3_ = FALSE;
	self = (CinterionMc75Modem*) base;
	_tmp0_ = fso_gsm_abstract_modem_get_modem_transport_spec ((FsoGsmAbstractModem*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_->type;
	_tmp3_ = g_str_has_prefix (_tmp2_, "ngsm");
	if (_tmp3_) {
		FsoFrameworkSerialTransport* _tmp4_;
		FsoFrameworkSerialTransport* _tmp5_;
		FsoGsmStateBasedAtParser* _tmp6_;
		FsoGsmStateBasedAtParser* _tmp7_;
		FsoGsmAtChannel* _tmp8_;
		FsoGsmAtChannel* _tmp9_;
		FsoFrameworkSerialTransport* _tmp10_;
		FsoFrameworkSerialTransport* _tmp11_;
		FsoGsmStateBasedAtParser* _tmp12_;
		FsoGsmStateBasedAtParser* _tmp13_;
		FsoGsmAtChannel* _tmp14_;
		FsoGsmAtChannel* _tmp15_;
		_tmp4_ = fso_framework_serial_transport_new ("/dev/ttygsm1", (guint) 115200, TRUE, TRUE);
		_tmp5_ = _tmp4_;
		_tmp6_ = fso_gsm_state_based_at_parser_new ();
		_tmp7_ = _tmp6_;
		_tmp8_ = fso_gsm_at_channel_new ("main", (FsoFrameworkTransport*) _tmp5_, (FsoFrameworkParser*) _tmp7_);
		_tmp9_ = _tmp8_;
		_g_object_unref0 (_tmp9_);
		_g_object_unref0 (_tmp7_);
		_g_object_unref0 (_tmp5_);
		_tmp10_ = fso_framework_serial_transport_new ("/dev/ttygsm3", (guint) 115200, TRUE, TRUE);
		_tmp11_ = _tmp10_;
		_tmp12_ = fso_gsm_state_based_at_parser_new ();
		_tmp13_ = _tmp12_;
		_tmp14_ = fso_gsm_at_channel_new ("call", (FsoFrameworkTransport*) _tmp11_, (FsoFrameworkParser*) _tmp13_);
		_tmp15_ = _tmp14_;
		_g_object_unref0 (_tmp15_);
		_g_object_unref0 (_tmp13_);
		_g_object_unref0 (_tmp11_);
		return;
	}
	{
		gint i;
		i = 0;
		{
			gboolean _tmp16_;
			_tmp16_ = TRUE;
			while (TRUE) {
				gboolean _tmp17_;
				gint _tmp19_;
				gint _tmp20_;
				FsoGsmLibGsm0710muxTransport* _tmp21_;
				FsoGsmLibGsm0710muxTransport* transport;
				FsoGsmStateBasedAtParser* _tmp22_;
				FsoGsmStateBasedAtParser* parser;
				gint _tmp23_;
				const gchar* _tmp24_;
				FsoGsmLibGsm0710muxTransport* _tmp25_;
				FsoGsmStateBasedAtParser* _tmp26_;
				FsoGsmAtChannel* _tmp27_;
				FsoGsmAtChannel* _tmp28_;
				_tmp17_ = _tmp16_;
				if (!_tmp17_) {
					gint _tmp18_;
					_tmp18_ = i;
					i = _tmp18_ + 1;
				}
				_tmp16_ = FALSE;
				_tmp19_ = i;
				if (!(_tmp19_ < G_N_ELEMENTS (CINTERION_MC75_CHANNEL_NAMES))) {
					break;
				}
				_tmp20_ = i;
				_tmp21_ = fso_gsm_lib_gsm0710mux_transport_new (_tmp20_ + 1);
				transport = _tmp21_;
				_tmp22_ = fso_gsm_state_based_at_parser_new ();
				parser = _tmp22_;
				_tmp23_ = i;
				_tmp24_ = CINTERION_MC75_CHANNEL_NAMES[_tmp23_];
				_tmp25_ = transport;
				_tmp26_ = parser;
				_tmp27_ = fso_gsm_at_channel_new (_tmp24_, (FsoFrameworkTransport*) _tmp25_, (FsoFrameworkParser*) _tmp26_);
				_tmp28_ = _tmp27_;
				_g_object_unref0 (_tmp28_);
				_g_object_unref0 (parser);
				_g_object_unref0 (transport);
			}
		}
	}
}


static FsoGsmUnsolicitedResponseHandler* cinterion_mc75_modem_real_createUnsolicitedHandler (FsoGsmAbstractModem* base) {
	CinterionMc75Modem * self;
	FsoGsmUnsolicitedResponseHandler* result = NULL;
	CinterionMc75UnsolicitedResponseHandler* _tmp0_;
	self = (CinterionMc75Modem*) base;
	_tmp0_ = cinterion_mc75_unsolicited_response_handler_new ();
	result = (FsoGsmUnsolicitedResponseHandler*) _tmp0_;
	return result;
}


static void cinterion_mc75_modem_real_registerCustomAtCommands (FsoGsmAbstractModem* base, GeeHashMap* commands) {
	CinterionMc75Modem * self;
	GeeHashMap* _tmp0_;
	self = (CinterionMc75Modem*) base;
	g_return_if_fail (commands != NULL);
	_tmp0_ = commands;
	cinterion_mc75_registerCustomAtCommands (_tmp0_);
}


static FsoGsmChannel* cinterion_mc75_modem_real_channelForCommand (FsoGsmAbstractModem* base, FsoGsmAtCommand* command, const gchar* query) {
	CinterionMc75Modem * self;
	FsoGsmChannel* result = NULL;
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp5_;
	GeeHashMap* _tmp8_;
	gpointer _tmp9_ = NULL;
	self = (CinterionMc75Modem*) base;
	g_return_val_if_fail (command != NULL, NULL);
	g_return_val_if_fail (query != NULL, NULL);
	_tmp1_ = query;
	_tmp2_ = g_str_has_prefix (_tmp1_, "D*99");
	if (_tmp2_) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp3_;
		gboolean _tmp4_ = FALSE;
		_tmp3_ = query;
		_tmp4_ = g_str_has_prefix (_tmp3_, "+CGD");
		_tmp0_ = _tmp4_;
	}
	_tmp5_ = _tmp0_;
	if (_tmp5_) {
		GeeHashMap* _tmp6_;
		gpointer _tmp7_ = NULL;
		_tmp6_ = ((FsoGsmAbstractModem*) self)->channels;
		_tmp7_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp6_, "data");
		result = (FsoGsmChannel*) _tmp7_;
		return result;
	}
	_tmp8_ = ((FsoGsmAbstractModem*) self)->channels;
	_tmp9_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp8_, "main");
	result = (FsoGsmChannel*) _tmp9_;
	return result;
}


static gchar* cinterion_mc75_modem_real_allocateDataPort (FsoGsmAbstractModem* base) {
	CinterionMc75Modem * self;
	gchar* result = NULL;
	self = (CinterionMc75Modem*) base;
	g_assert_not_reached ();
	return result;
}


CinterionMc75Modem* cinterion_mc75_modem_construct (GType object_type) {
	CinterionMc75Modem * self = NULL;
	self = (CinterionMc75Modem*) fso_gsm_abstract_modem_construct (object_type);
	return self;
}


CinterionMc75Modem* cinterion_mc75_modem_new (void) {
	return cinterion_mc75_modem_construct (CINTERION_MC75_TYPE_MODEM);
}


static void cinterion_mc75_modem_class_init (CinterionMc75ModemClass * klass) {
	cinterion_mc75_modem_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (CinterionMc75ModemPrivate));
	FSO_FRAMEWORK_ABSTRACT_OBJECT_CLASS (klass)->repr = cinterion_mc75_modem_real_repr;
	FSO_GSM_ABSTRACT_MODEM_CLASS (klass)->configureData = cinterion_mc75_modem_real_configureData;
	FSO_GSM_ABSTRACT_MODEM_CLASS (klass)->open = cinterion_mc75_modem_real_open;
	FSO_GSM_ABSTRACT_MODEM_CLASS (klass)->open_finish = cinterion_mc75_modem_real_open_finish;
	FSO_GSM_ABSTRACT_MODEM_CLASS (klass)->close = cinterion_mc75_modem_real_close;
	FSO_GSM_ABSTRACT_MODEM_CLASS (klass)->close_finish = cinterion_mc75_modem_real_close_finish;
	FSO_GSM_ABSTRACT_MODEM_CLASS (klass)->createChannels = cinterion_mc75_modem_real_createChannels;
	FSO_GSM_ABSTRACT_MODEM_CLASS (klass)->createUnsolicitedHandler = cinterion_mc75_modem_real_createUnsolicitedHandler;
	FSO_GSM_ABSTRACT_MODEM_CLASS (klass)->registerCustomAtCommands = cinterion_mc75_modem_real_registerCustomAtCommands;
	FSO_GSM_ABSTRACT_MODEM_CLASS (klass)->channelForCommand = cinterion_mc75_modem_real_channelForCommand;
	FSO_GSM_ABSTRACT_MODEM_CLASS (klass)->allocateDataPort = cinterion_mc75_modem_real_allocateDataPort;
	G_OBJECT_CLASS (klass)->finalize = cinterion_mc75_modem_finalize;
}


static void cinterion_mc75_modem_instance_init (CinterionMc75Modem * self) {
	self->priv = CINTERION_MC75_MODEM_GET_PRIVATE (self);
}


static void cinterion_mc75_modem_finalize (GObject* obj) {
	CinterionMc75Modem * self;
	self = CINTERION_MC75_MODEM (obj);
	_g_object_unref0 (self->priv->muxtransport);
	G_OBJECT_CLASS (cinterion_mc75_modem_parent_class)->finalize (obj);
}


/**
 * @class CinterionMc75.Modem
 *
 * This modem plugin supports a wide variety of SIEMENS / CINTERION industrial
 * modems, however the main target is the mc75(i).
 *
 * We're operating this modem in basic MUX mode (NOT the SIEMENS proprietary MUX mode)
 * and use all of its three channels:
 * 'call': First channel will be reserved for calling commands (ATD and friends).
 * 'main': Second channel will be used for receiving URC and sending misc. commands.
 * 'data': Third channel will be used for data connectivity (ppp), but also misc. commands,
 * when the data connection is not in use.
 *
 **/
GType cinterion_mc75_modem_get_type (void) {
	return cinterion_mc75_modem_type_id;
}


GType cinterion_mc75_modem_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (CinterionMc75ModemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) cinterion_mc75_modem_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CinterionMc75Modem), 0, (GInstanceInitFunc) cinterion_mc75_modem_instance_init, NULL };
	cinterion_mc75_modem_type_id = g_type_module_register_type (module, FSO_GSM_TYPE_ABSTRACT_MODEM, "CinterionMc75Modem", &g_define_type_info, 0);
	return cinterion_mc75_modem_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_;
	gchar* _tmp1_;
	g_return_val_if_fail (subsystem != NULL, NULL);
	_tmp0_ = fso_framework_theLogger;
	fso_framework_logger_debug (_tmp0_, "mc75 fso_factory_function");
	_tmp1_ = g_strdup (CINTERION_MC75_MODULE_NAME);
	result = _tmp1_;
	return result;
}


void fso_register_function (GTypeModule* module) {
	g_return_if_fail (module != NULL);
	cinterion_mc75_cinterion_plus_ciev_register_type (module);
	cinterion_mc75_unsolicited_response_handler_register_type (module);
	cinterion_mc75_modem_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);
}



