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

/*
 * Copyright (C) 2010  Antonio Ospite <ospite@studenti.unina.it>
 *
 * 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 <fsobasics.h>
#include <freesmartphone.h>


#define FREESCALE_NEPTUNE_TYPE_UNSOLICITED_RESPONSE_HANDLER (freescale_neptune_unsolicited_response_handler_get_type ())
#define FREESCALE_NEPTUNE_UNSOLICITED_RESPONSE_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FREESCALE_NEPTUNE_TYPE_UNSOLICITED_RESPONSE_HANDLER, FreescaleNeptuneUnsolicitedResponseHandler))
#define FREESCALE_NEPTUNE_UNSOLICITED_RESPONSE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FREESCALE_NEPTUNE_TYPE_UNSOLICITED_RESPONSE_HANDLER, FreescaleNeptuneUnsolicitedResponseHandlerClass))
#define FREESCALE_NEPTUNE_IS_UNSOLICITED_RESPONSE_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FREESCALE_NEPTUNE_TYPE_UNSOLICITED_RESPONSE_HANDLER))
#define FREESCALE_NEPTUNE_IS_UNSOLICITED_RESPONSE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FREESCALE_NEPTUNE_TYPE_UNSOLICITED_RESPONSE_HANDLER))
#define FREESCALE_NEPTUNE_UNSOLICITED_RESPONSE_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FREESCALE_NEPTUNE_TYPE_UNSOLICITED_RESPONSE_HANDLER, FreescaleNeptuneUnsolicitedResponseHandlerClass))

typedef struct _FreescaleNeptuneUnsolicitedResponseHandler FreescaleNeptuneUnsolicitedResponseHandler;
typedef struct _FreescaleNeptuneUnsolicitedResponseHandlerClass FreescaleNeptuneUnsolicitedResponseHandlerClass;
typedef struct _FreescaleNeptuneUnsolicitedResponseHandlerPrivate FreescaleNeptuneUnsolicitedResponseHandlerPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _fso_gsm_constants_unref0(var) ((var == NULL) ? NULL : (var = (fso_gsm_constants_unref (var), NULL)))

#define FREESCALE_NEPTUNE_TYPE_MODEM (freescale_neptune_modem_get_type ())
#define FREESCALE_NEPTUNE_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FREESCALE_NEPTUNE_TYPE_MODEM, FreescaleNeptuneModem))
#define FREESCALE_NEPTUNE_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FREESCALE_NEPTUNE_TYPE_MODEM, FreescaleNeptuneModemClass))
#define FREESCALE_NEPTUNE_IS_MODEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FREESCALE_NEPTUNE_TYPE_MODEM))
#define FREESCALE_NEPTUNE_IS_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FREESCALE_NEPTUNE_TYPE_MODEM))
#define FREESCALE_NEPTUNE_MODEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FREESCALE_NEPTUNE_TYPE_MODEM, FreescaleNeptuneModemClass))

typedef struct _FreescaleNeptuneModem FreescaleNeptuneModem;
typedef struct _FreescaleNeptuneModemClass FreescaleNeptuneModemClass;

struct _FreescaleNeptuneUnsolicitedResponseHandler {
	FsoGsmAtUnsolicitedResponseHandler parent_instance;
	FreescaleNeptuneUnsolicitedResponseHandlerPrivate * priv;
};

struct _FreescaleNeptuneUnsolicitedResponseHandlerClass {
	FsoGsmAtUnsolicitedResponseHandlerClass parent_class;
	void (*channelReady) (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs);
	void (*dummy) (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs);
};


static gpointer freescale_neptune_unsolicited_response_handler_parent_class = NULL;
static GType freescale_neptune_unsolicited_response_handler_type_id = 0;

GType freescale_neptune_unsolicited_response_handler_get_type (void) G_GNUC_CONST;
GType freescale_neptune_unsolicited_response_handler_register_type (GTypeModule * module);
enum  {
	FREESCALE_NEPTUNE_UNSOLICITED_RESPONSE_HANDLER_DUMMY_PROPERTY
};
FreescaleNeptuneUnsolicitedResponseHandler* freescale_neptune_unsolicited_response_handler_new (void);
FreescaleNeptuneUnsolicitedResponseHandler* freescale_neptune_unsolicited_response_handler_construct (GType object_type);
void freescale_neptune_unsolicited_response_handler_channelReady (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs);
static void _freescale_neptune_unsolicited_response_handler_channelReady_unsolicited_response_handler_func (const gchar* prefix, const gchar* rhs, gpointer self);
void freescale_neptune_unsolicited_response_handler_plusCLIN (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs);
static void _freescale_neptune_unsolicited_response_handler_plusCLIN_unsolicited_response_handler_func (const gchar* prefix, const gchar* rhs, gpointer self);
static void _fso_gsm_at_unsolicited_response_handler_plusCLIP_unsolicited_response_handler_func (const gchar* prefix, const gchar* rhs, gpointer self);
void freescale_neptune_unsolicited_response_handler_plusEBPV (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs);
static void _freescale_neptune_unsolicited_response_handler_plusEBPV_unsolicited_response_handler_func (const gchar* prefix, const gchar* rhs, gpointer self);
void freescale_neptune_unsolicited_response_handler_plusEBAD (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs);
static void _freescale_neptune_unsolicited_response_handler_plusEBAD_unsolicited_response_handler_func (const gchar* prefix, const gchar* rhs, gpointer self);
void freescale_neptune_unsolicited_response_handler_dummy (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs);
static void _freescale_neptune_unsolicited_response_handler_dummy_unsolicited_response_handler_func (const gchar* prefix, const gchar* rhs, gpointer self);
static void freescale_neptune_unsolicited_response_handler_real_channelReady (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs);
static void freescale_neptune_unsolicited_response_handler_real_plusCIEV (FsoGsmAtUnsolicitedResponseHandler* base, const gchar* prefix, const gchar* rhs);
static void freescale_neptune_unsolicited_response_handler_real_plusCLIP (FsoGsmAtUnsolicitedResponseHandler* base, const gchar* prefix, const gchar* rhs);
GType freescale_neptune_modem_get_type (void) G_GNUC_CONST;
GType freescale_neptune_modem_register_type (GTypeModule * module);
void freescale_neptune_modem_set_revision (FreescaleNeptuneModem* self, const gchar* value);
guint8* freescale_neptune_modem_get_bdaddr (FreescaleNeptuneModem* self, int* result_length1);
static void freescale_neptune_unsolicited_response_handler_real_dummy (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs);
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 gint _vala_array_length (gpointer array);


static void _freescale_neptune_unsolicited_response_handler_channelReady_unsolicited_response_handler_func (const gchar* prefix, const gchar* rhs, gpointer self) {
	freescale_neptune_unsolicited_response_handler_channelReady (self, prefix, rhs);
}


static void _freescale_neptune_unsolicited_response_handler_plusCLIN_unsolicited_response_handler_func (const gchar* prefix, const gchar* rhs, gpointer self) {
	freescale_neptune_unsolicited_response_handler_plusCLIN (self, prefix, rhs);
}


static void _fso_gsm_at_unsolicited_response_handler_plusCLIP_unsolicited_response_handler_func (const gchar* prefix, const gchar* rhs, gpointer self) {
	fso_gsm_at_unsolicited_response_handler_plusCLIP (self, prefix, rhs);
}


static void _freescale_neptune_unsolicited_response_handler_plusEBPV_unsolicited_response_handler_func (const gchar* prefix, const gchar* rhs, gpointer self) {
	freescale_neptune_unsolicited_response_handler_plusEBPV (self, prefix, rhs);
}


static void _freescale_neptune_unsolicited_response_handler_plusEBAD_unsolicited_response_handler_func (const gchar* prefix, const gchar* rhs, gpointer self) {
	freescale_neptune_unsolicited_response_handler_plusEBAD (self, prefix, rhs);
}


static void _freescale_neptune_unsolicited_response_handler_dummy_unsolicited_response_handler_func (const gchar* prefix, const gchar* rhs, gpointer self) {
	freescale_neptune_unsolicited_response_handler_dummy (self, prefix, rhs);
}


FreescaleNeptuneUnsolicitedResponseHandler* freescale_neptune_unsolicited_response_handler_construct (GType object_type) {
	FreescaleNeptuneUnsolicitedResponseHandler * self = NULL;
	self = (FreescaleNeptuneUnsolicitedResponseHandler*) fso_gsm_at_unsolicited_response_handler_construct (object_type);
	fso_gsm_base_unsolicited_response_handler_registerUrc ((FsoGsmBaseUnsolicitedResponseHandler*) self, "+MBAN", _freescale_neptune_unsolicited_response_handler_channelReady_unsolicited_response_handler_func, self);
	fso_gsm_base_unsolicited_response_handler_registerUrc ((FsoGsmBaseUnsolicitedResponseHandler*) self, "+CLIN", _freescale_neptune_unsolicited_response_handler_plusCLIN_unsolicited_response_handler_func, self);
	fso_gsm_base_unsolicited_response_handler_registerUrc ((FsoGsmBaseUnsolicitedResponseHandler*) self, "+CLIP", _fso_gsm_at_unsolicited_response_handler_plusCLIP_unsolicited_response_handler_func, (FsoGsmAtUnsolicitedResponseHandler*) self);
	fso_gsm_base_unsolicited_response_handler_registerUrc ((FsoGsmBaseUnsolicitedResponseHandler*) self, "+EBPV", _freescale_neptune_unsolicited_response_handler_plusEBPV_unsolicited_response_handler_func, self);
	fso_gsm_base_unsolicited_response_handler_registerUrc ((FsoGsmBaseUnsolicitedResponseHandler*) self, "+EBAD", _freescale_neptune_unsolicited_response_handler_plusEBAD_unsolicited_response_handler_func, self);
	fso_gsm_base_unsolicited_response_handler_registerUrc ((FsoGsmBaseUnsolicitedResponseHandler*) self, "+EFLEX", _freescale_neptune_unsolicited_response_handler_dummy_unsolicited_response_handler_func, self);
	return self;
}


FreescaleNeptuneUnsolicitedResponseHandler* freescale_neptune_unsolicited_response_handler_new (void) {
	return freescale_neptune_unsolicited_response_handler_construct (FREESCALE_NEPTUNE_TYPE_UNSOLICITED_RESPONSE_HANDLER);
}


static void freescale_neptune_unsolicited_response_handler_real_channelReady (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs) {
	FsoGsmModem* _tmp0_;
	FsoFrameworkLogger* _tmp1_;
	gboolean _tmp2_ = FALSE;
	g_return_if_fail (prefix != NULL);
	g_return_if_fail (rhs != NULL);
	_tmp0_ = fso_gsm_theModem;
	_tmp1_ = ((FsoFrameworkAbstractObject*) _tmp0_)->logger;
	_tmp2_ = fso_framework_logger_debug (_tmp1_, "Congratulations Madam, it's a channel!");
	g_assert (_tmp2_);
}


void freescale_neptune_unsolicited_response_handler_channelReady (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs) {
	g_return_if_fail (self != NULL);
	FREESCALE_NEPTUNE_UNSOLICITED_RESPONSE_HANDLER_GET_CLASS (self)->channelReady (self, prefix, rhs);
}


/**
     * Indicator Event Reporting. Based on 3GPP TS 07.07, Chapter 8.9, but slightly extended.
     *
     * As +CIND=? gives us a hint (one of the few test commands EZX exposes), we conclude:
     *
     *  0: battery charge level (0-5)
     *  1: signal level (0-5)
     *  2: service availability (0-1)
     *  3: call active? (0-1)
     *  4: voice mail (message) (0-1)
     *  5: transmit activated by voice activity (0-1)
     *  6: call progress (0-3) [0:no more in progress, 1:incoming, 2:outgoing, 3:ringing]
     *  7: roaming (0-2) [0:local, 1:home roaming, 2:overseas roaming]
     *  8: sms storage full (0-1)
     * 11: gprs context attachment (0-2) [0:detach, 1:attach, 2:combined attach]
     * 12: gprs service availability (0-1)
     * 13: gprs automatic attach availability (0-1)
     * 14: gprs status (0-1)
     * 15: gprs display status (0-1) [0:display, 1:do not display]
     * 18: power on mode (0-1)
     * 19: EONS status (0-1)
     * 20: EGPRS possible (0-1)
     * 21: EGPRS in use (0-1)
     **/
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 void freescale_neptune_unsolicited_response_handler_real_plusCIEV (FsoGsmAtUnsolicitedResponseHandler* base, const gchar* prefix, const gchar* rhs) {
	FreescaleNeptuneUnsolicitedResponseHandler * self;
	FsoGsmModem* _tmp0_;
	gpointer _tmp1_ = NULL;
	FsoGsmPlusCIEV* ciev;
	FsoGsmPlusCIEV* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_;
	const gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* _tmp8_;
	FsoGsmConstantsAtResponse _tmp9_ = 0;
	gboolean _tmp10_;
	FsoGsmPlusCIEV* _tmp16_;
	gconstpointer _tmp17_;
	self = (FreescaleNeptuneUnsolicitedResponseHandler*) base;
	g_return_if_fail (prefix != NULL);
	g_return_if_fail (rhs != NULL);
	_tmp0_ = fso_gsm_theModem;
	_tmp1_ = fso_gsm_modem_createAtCommand (_tmp0_, FSO_GSM_TYPE_PLUS_CIEV, (GBoxedCopyFunc) g_object_ref, g_object_unref, "+CIEV");
	ciev = (FsoGsmPlusCIEV*) _tmp1_;
	_tmp2_ = ciev;
	_tmp3_ = prefix;
	_tmp4_ = string_to_string (_tmp3_);
	_tmp5_ = rhs;
	_tmp6_ = string_to_string (_tmp5_);
	_tmp7_ = g_strconcat (_tmp4_, ": ", _tmp6_, NULL);
	_tmp8_ = _tmp7_;
	_tmp9_ = fso_gsm_abstract_at_command_validateUrc ((FsoGsmAbstractAtCommand*) _tmp2_, _tmp8_);
	_tmp10_ = !(_tmp9_ == FSO_GSM_CONSTANTS_AT_RESPONSE_VALID);
	_g_free0 (_tmp8_);
	if (_tmp10_) {
		FsoFrameworkLogger* _tmp11_;
		const gchar* _tmp12_;
		const gchar* _tmp13_ = NULL;
		gchar* _tmp14_ = NULL;
		gchar* _tmp15_;
		_tmp11_ = ((FsoFrameworkAbstractObject*) self)->logger;
		_tmp12_ = rhs;
		_tmp13_ = string_to_string (_tmp12_);
		_tmp14_ = g_strconcat ("Received invalid +CIEV message ", _tmp13_, ". Please report", NULL);
		_tmp15_ = _tmp14_;
		fso_framework_logger_warning (_tmp11_, _tmp15_);
		_g_free0 (_tmp15_);
		_g_object_unref0 (ciev);
		return;
	}
	_tmp16_ = ciev;
	_tmp17_ = ((FsoGsmTwoParamsAtCommand*) _tmp16_)->value1;
	switch (GPOINTER_TO_INT (_tmp17_)) {
		case 1:
		{
			FsoGsmModem* _tmp18_;
			gpointer _tmp19_ = NULL;
			FreeSmartphoneGSMNetwork* obj;
			FreeSmartphoneGSMNetwork* _tmp20_;
			FsoGsmConstants* _tmp21_ = NULL;
			FsoGsmConstants* _tmp22_;
			FsoGsmPlusCIEV* _tmp23_;
			gconstpointer _tmp24_;
			gint _tmp25_ = 0;
			_tmp18_ = fso_gsm_theModem;
			_tmp19_ = fso_gsm_modem_theDevice (_tmp18_, FREE_SMARTPHONE_GSM_TYPE_NETWORK, (GBoxedCopyFunc) g_object_ref, g_object_unref);
			obj = (FreeSmartphoneGSMNetwork*) _tmp19_;
			_tmp20_ = obj;
			_tmp21_ = fso_gsm_constants_instance ();
			_tmp22_ = _tmp21_;
			_tmp23_ = ciev;
			_tmp24_ = ((FsoGsmTwoParamsAtCommand*) _tmp23_)->value2;
			_tmp25_ = fso_gsm_constants_networkSignalIndicatorToPercentage (_tmp22_, GPOINTER_TO_INT (_tmp24_));
			g_signal_emit_by_name (_tmp20_, "signal-strength", _tmp25_);
			_fso_gsm_constants_unref0 (_tmp22_);
			_g_object_unref0 (obj);
			break;
		}
		default:
		{
			FsoGsmModem* _tmp26_;
			FsoFrameworkLogger* _tmp27_;
			FsoGsmPlusCIEV* _tmp28_;
			gconstpointer _tmp29_;
			gchar* _tmp30_ = NULL;
			gchar* _tmp31_;
			FsoGsmPlusCIEV* _tmp32_;
			gconstpointer _tmp33_;
			gchar* _tmp34_ = NULL;
			gchar* _tmp35_;
			gchar* _tmp36_ = NULL;
			gchar* _tmp37_;
			_tmp26_ = fso_gsm_theModem;
			_tmp27_ = ((FsoFrameworkAbstractObject*) _tmp26_)->logger;
			_tmp28_ = ciev;
			_tmp29_ = ((FsoGsmTwoParamsAtCommand*) _tmp28_)->value1;
			_tmp30_ = g_strdup_printf ("%i", GPOINTER_TO_INT (_tmp29_));
			_tmp31_ = _tmp30_;
			_tmp32_ = ciev;
			_tmp33_ = ((FsoGsmTwoParamsAtCommand*) _tmp32_)->value2;
			_tmp34_ = g_strdup_printf ("%i", GPOINTER_TO_INT (_tmp33_));
			_tmp35_ = _tmp34_;
			_tmp36_ = g_strconcat ("plusCIEV: ", _tmp31_, ",", _tmp35_, " unknown or not implemented", NULL);
			_tmp37_ = _tmp36_;
			fso_framework_logger_warning (_tmp27_, _tmp37_);
			_g_free0 (_tmp37_);
			_g_free0 (_tmp35_);
			_g_free0 (_tmp31_);
			break;
		}
	}
	_g_object_unref0 (ciev);
}


/**
     * When an incoming call arrives we get the URC:
     * +CLIN: 0
     **/
void freescale_neptune_unsolicited_response_handler_plusCLIN (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs) {
	FsoGsmModem* _tmp0_;
	FsoGsmCallHandler* _tmp1_;
	FsoGsmCallHandler* _tmp2_;
	FsoGsmCallInfo* _tmp3_;
	FsoGsmCallInfo* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (prefix != NULL);
	g_return_if_fail (rhs != NULL);
	_tmp0_ = fso_gsm_theModem;
	_tmp1_ = fso_gsm_modem_get_callhandler (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = fso_gsm_call_info_new_with_ctype ("VOICE");
	_tmp4_ = _tmp3_;
	fso_gsm_call_handler_handleIncomingCall (_tmp2_, _tmp4_);
	_g_object_unref0 (_tmp4_);
}


/**
     * +CLIP: "+4969123456789",145
     **/
static void freescale_neptune_unsolicited_response_handler_real_plusCLIP (FsoGsmAtUnsolicitedResponseHandler* base, const gchar* prefix, const gchar* rhs) {
	FreescaleNeptuneUnsolicitedResponseHandler * self;
	FsoGsmModem* _tmp0_;
	FsoFrameworkLogger* _tmp1_;
	gboolean _tmp2_ = FALSE;
	self = (FreescaleNeptuneUnsolicitedResponseHandler*) base;
	g_return_if_fail (prefix != NULL);
	g_return_if_fail (rhs != NULL);
	_tmp0_ = fso_gsm_theModem;
	_tmp1_ = ((FsoFrameworkAbstractObject*) _tmp0_)->logger;
	_tmp2_ = fso_framework_logger_debug (_tmp1_, "plusCLIP: not implemented on Neptune");
	g_assert (_tmp2_);
}


/**
     * When the main channel is opened the BP shows its revision
     * +EBPV: "R52_G_0D.C0.B1P","GCOA780XXXXXXXX","XXXXXXXX","Quad-Band GSM"
     **/
static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


void freescale_neptune_unsolicited_response_handler_plusEBPV (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs) {
	FsoGsmModem* _tmp0_;
	FreescaleNeptuneModem* _tmp1_;
	FreescaleNeptuneModem* modem;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (prefix != NULL);
	g_return_if_fail (rhs != NULL);
	_tmp0_ = fso_gsm_theModem;
	_tmp1_ = _g_object_ref0 (FREESCALE_NEPTUNE_IS_MODEM (_tmp0_) ? ((FreescaleNeptuneModem*) _tmp0_) : NULL);
	modem = _tmp1_;
	_tmp2_ = rhs;
	freescale_neptune_modem_set_revision (modem, _tmp2_);
	_g_object_unref0 (modem);
}


/**
     * +EBAD shows the bluetooth device address, with octets in decimal
     * +EBAD:n,n,n,n,n,n
     **/
void freescale_neptune_unsolicited_response_handler_plusEBAD (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs) {
	FsoGsmModem* _tmp0_;
	FreescaleNeptuneModem* _tmp1_;
	FreescaleNeptuneModem* modem;
	const gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_ = NULL;
	gchar** octets;
	gint octets_length1;
	gint _octets_size_;
	FsoGsmModem* _tmp19_;
	FsoFrameworkLogger* _tmp20_;
	FreescaleNeptuneModem* _tmp21_;
	guint8* _tmp22_;
	gint _tmp22__length1;
	guint8* _tmp23_;
	gint _tmp23__length1;
	guint8 _tmp24_;
	FreescaleNeptuneModem* _tmp25_;
	guint8* _tmp26_;
	gint _tmp26__length1;
	guint8* _tmp27_;
	gint _tmp27__length1;
	guint8 _tmp28_;
	FreescaleNeptuneModem* _tmp29_;
	guint8* _tmp30_;
	gint _tmp30__length1;
	guint8* _tmp31_;
	gint _tmp31__length1;
	guint8 _tmp32_;
	FreescaleNeptuneModem* _tmp33_;
	guint8* _tmp34_;
	gint _tmp34__length1;
	guint8* _tmp35_;
	gint _tmp35__length1;
	guint8 _tmp36_;
	FreescaleNeptuneModem* _tmp37_;
	guint8* _tmp38_;
	gint _tmp38__length1;
	guint8* _tmp39_;
	gint _tmp39__length1;
	guint8 _tmp40_;
	FreescaleNeptuneModem* _tmp41_;
	guint8* _tmp42_;
	gint _tmp42__length1;
	guint8* _tmp43_;
	gint _tmp43__length1;
	guint8 _tmp44_;
	gchar* _tmp45_ = NULL;
	gchar* _tmp46_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (prefix != NULL);
	g_return_if_fail (rhs != NULL);
	_tmp0_ = fso_gsm_theModem;
	_tmp1_ = _g_object_ref0 (FREESCALE_NEPTUNE_IS_MODEM (_tmp0_) ? ((FreescaleNeptuneModem*) _tmp0_) : NULL);
	modem = _tmp1_;
	_tmp2_ = rhs;
	_tmp4_ = _tmp3_ = g_strsplit (_tmp2_, ",", 0);
	octets = _tmp4_;
	octets_length1 = _vala_array_length (_tmp3_);
	_octets_size_ = octets_length1;
	{
		guint i;
		i = (guint) 0;
		{
			gboolean _tmp5_;
			_tmp5_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_;
				guint _tmp8_;
				gchar** _tmp9_;
				gint _tmp9__length1;
				FreescaleNeptuneModem* _tmp10_;
				guint8* _tmp11_;
				gint _tmp11__length1;
				guint8* _tmp12_;
				gint _tmp12__length1;
				guint _tmp13_;
				gchar** _tmp14_;
				gint _tmp14__length1;
				guint _tmp15_;
				const gchar* _tmp16_;
				gint _tmp17_ = 0;
				guint8 _tmp18_;
				_tmp6_ = _tmp5_;
				if (!_tmp6_) {
					guint _tmp7_;
					_tmp7_ = i;
					i = _tmp7_ + 1;
				}
				_tmp5_ = FALSE;
				_tmp8_ = i;
				_tmp9_ = octets;
				_tmp9__length1 = octets_length1;
				if (!(_tmp8_ < ((guint) _tmp9__length1))) {
					break;
				}
				_tmp10_ = modem;
				_tmp11_ = freescale_neptune_modem_get_bdaddr (_tmp10_, &_tmp11__length1);
				_tmp12_ = _tmp11_;
				_tmp12__length1 = _tmp11__length1;
				_tmp13_ = i;
				_tmp14_ = octets;
				_tmp14__length1 = octets_length1;
				_tmp15_ = i;
				_tmp16_ = _tmp14_[_tmp15_];
				_tmp17_ = atoi (_tmp16_);
				_tmp12_[_tmp13_] = (guint8) _tmp17_;
				_tmp18_ = _tmp12_[_tmp13_];
			}
		}
	}
	_tmp19_ = fso_gsm_theModem;
	_tmp20_ = ((FsoFrameworkAbstractObject*) _tmp19_)->logger;
	_tmp21_ = modem;
	_tmp22_ = freescale_neptune_modem_get_bdaddr (_tmp21_, &_tmp22__length1);
	_tmp23_ = _tmp22_;
	_tmp23__length1 = _tmp22__length1;
	_tmp24_ = _tmp23_[0];
	_tmp25_ = modem;
	_tmp26_ = freescale_neptune_modem_get_bdaddr (_tmp25_, &_tmp26__length1);
	_tmp27_ = _tmp26_;
	_tmp27__length1 = _tmp26__length1;
	_tmp28_ = _tmp27_[1];
	_tmp29_ = modem;
	_tmp30_ = freescale_neptune_modem_get_bdaddr (_tmp29_, &_tmp30__length1);
	_tmp31_ = _tmp30_;
	_tmp31__length1 = _tmp30__length1;
	_tmp32_ = _tmp31_[2];
	_tmp33_ = modem;
	_tmp34_ = freescale_neptune_modem_get_bdaddr (_tmp33_, &_tmp34__length1);
	_tmp35_ = _tmp34_;
	_tmp35__length1 = _tmp34__length1;
	_tmp36_ = _tmp35_[3];
	_tmp37_ = modem;
	_tmp38_ = freescale_neptune_modem_get_bdaddr (_tmp37_, &_tmp38__length1);
	_tmp39_ = _tmp38_;
	_tmp39__length1 = _tmp38__length1;
	_tmp40_ = _tmp39_[4];
	_tmp41_ = modem;
	_tmp42_ = freescale_neptune_modem_get_bdaddr (_tmp41_, &_tmp42__length1);
	_tmp43_ = _tmp42_;
	_tmp43__length1 = _tmp42__length1;
	_tmp44_ = _tmp43_[5];
	_tmp45_ = g_strdup_printf ("bdaddr: %02X:%02X:%02X:%02X:%02X:%02X", (guint) _tmp24_, (guint) _tmp28_, (guint) _tmp32_, (guint) _tmp36_, (guint) _tmp40_, (guint) _tmp44_);
	_tmp46_ = _tmp45_;
	fso_framework_logger_debug (_tmp20_, _tmp46_);
	_g_free0 (_tmp46_);
	octets = (_vala_array_free (octets, octets_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (modem);
}


static void freescale_neptune_unsolicited_response_handler_real_dummy (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs) {
	FsoGsmModem* _tmp0_;
	FsoFrameworkLogger* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_;
	gboolean _tmp6_ = FALSE;
	g_return_if_fail (prefix != NULL);
	g_return_if_fail (rhs != NULL);
	_tmp0_ = fso_gsm_theModem;
	_tmp1_ = ((FsoFrameworkAbstractObject*) _tmp0_)->logger;
	_tmp2_ = prefix;
	_tmp3_ = string_to_string (_tmp2_);
	_tmp4_ = g_strconcat ("URC: ", _tmp3_, " not implemented on Neptune", NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = fso_framework_logger_debug (_tmp1_, _tmp5_);
	g_assert (_tmp6_);
	_g_free0 (_tmp5_);
}


void freescale_neptune_unsolicited_response_handler_dummy (FreescaleNeptuneUnsolicitedResponseHandler* self, const gchar* prefix, const gchar* rhs) {
	g_return_if_fail (self != NULL);
	FREESCALE_NEPTUNE_UNSOLICITED_RESPONSE_HANDLER_GET_CLASS (self)->dummy (self, prefix, rhs);
}


static void freescale_neptune_unsolicited_response_handler_class_init (FreescaleNeptuneUnsolicitedResponseHandlerClass * klass) {
	freescale_neptune_unsolicited_response_handler_parent_class = g_type_class_peek_parent (klass);
	FREESCALE_NEPTUNE_UNSOLICITED_RESPONSE_HANDLER_CLASS (klass)->channelReady = freescale_neptune_unsolicited_response_handler_real_channelReady;
	FSO_GSM_AT_UNSOLICITED_RESPONSE_HANDLER_CLASS (klass)->plusCIEV = freescale_neptune_unsolicited_response_handler_real_plusCIEV;
	FSO_GSM_AT_UNSOLICITED_RESPONSE_HANDLER_CLASS (klass)->plusCLIP = freescale_neptune_unsolicited_response_handler_real_plusCLIP;
	FREESCALE_NEPTUNE_UNSOLICITED_RESPONSE_HANDLER_CLASS (klass)->dummy = freescale_neptune_unsolicited_response_handler_real_dummy;
}


static void freescale_neptune_unsolicited_response_handler_instance_init (FreescaleNeptuneUnsolicitedResponseHandler * self) {
}


GType freescale_neptune_unsolicited_response_handler_get_type (void) {
	return freescale_neptune_unsolicited_response_handler_type_id;
}


GType freescale_neptune_unsolicited_response_handler_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (FreescaleNeptuneUnsolicitedResponseHandlerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) freescale_neptune_unsolicited_response_handler_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FreescaleNeptuneUnsolicitedResponseHandler), 0, (GInstanceInitFunc) freescale_neptune_unsolicited_response_handler_instance_init, NULL };
	freescale_neptune_unsolicited_response_handler_type_id = g_type_module_register_type (module, FSO_GSM_TYPE_AT_UNSOLICITED_RESPONSE_HANDLER, "FreescaleNeptuneUnsolicitedResponseHandler", &g_define_type_info, 0);
	return freescale_neptune_unsolicited_response_handler_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);
}


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



