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

/*
 * Copyright (C) 2011-2012 Simon Busch <morphis@gravedo.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 <fsotransport.h>
#include <radio.h>
#include <fsobasics.h>
#include <stdlib.h>
#include <string.h>


#define SAMSUNG_TYPE_COMMAND_HANDLER (samsung_command_handler_get_type ())
#define SAMSUNG_COMMAND_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SAMSUNG_TYPE_COMMAND_HANDLER, SamsungCommandHandler))
#define SAMSUNG_COMMAND_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SAMSUNG_TYPE_COMMAND_HANDLER, SamsungCommandHandlerClass))
#define SAMSUNG_IS_COMMAND_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SAMSUNG_TYPE_COMMAND_HANDLER))
#define SAMSUNG_IS_COMMAND_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SAMSUNG_TYPE_COMMAND_HANDLER))
#define SAMSUNG_COMMAND_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SAMSUNG_TYPE_COMMAND_HANDLER, SamsungCommandHandlerClass))

typedef struct _SamsungCommandHandler SamsungCommandHandler;
typedef struct _SamsungCommandHandlerClass SamsungCommandHandlerClass;
typedef struct _SamsungCommandHandlerPrivate SamsungCommandHandlerPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _SamsungCommandHandler {
	FsoFrameworkAbstractCommandHandler parent_instance;
	SamsungCommandHandlerPrivate * priv;
	struct ipc_client* client;
	guint8 id;
	int request_type;
	unsigned short message_type;
	guint8* data;
	gint data_length1;
	struct ipc_message_info response;
	gboolean timed_out;
};

struct _SamsungCommandHandlerClass {
	FsoFrameworkAbstractCommandHandlerClass parent_class;
};


static gpointer samsung_command_handler_parent_class = NULL;
static GType samsung_command_handler_type_id = 0;

GType samsung_command_handler_get_type (void) G_GNUC_CONST;
GType samsung_command_handler_register_type (GTypeModule * module);
enum  {
	SAMSUNG_COMMAND_HANDLER_DUMMY_PROPERTY
};
static void samsung_command_handler_real_writeToTransport (FsoFrameworkAbstractCommandHandler* base, FsoFrameworkTransport* t);
const gchar* samsung_ipc_request_type_to_string (int self);
static const char* _samsung_ipc_request_type_to_string (int value);
const gchar* samsung_ipc_message_type_to_string (unsigned short self);
static const char* _samsung_ipc_message_type_to_string (unsigned short value);
static gchar* samsung_command_handler_real_to_string (FsoFrameworkAbstractCommandHandler* base);
SamsungCommandHandler* samsung_command_handler_new (void);
SamsungCommandHandler* samsung_command_handler_construct (GType object_type);
static void samsung_command_handler_finalize (FsoFrameworkAbstractCommandHandler* obj);


static const char* _samsung_ipc_request_type_to_string (int value) {
	switch (value) {
		case IPC_TYPE_EXEC:
		return "IPC_TYPE_EXEC";
		case IPC_TYPE_GET:
		return "IPC_TYPE_GET";
		case IPC_TYPE_SET:
		return "IPC_TYPE_SET";
		case IPC_TYPE_CFRM:
		return "IPC_TYPE_CFRM";
		case IPC_TYPE_EVENT:
		return "IPC_TYPE_EVENT";
	}
	return NULL;
}


static const char* _samsung_ipc_message_type_to_string (unsigned short value) {
	switch (value) {
		case IPC_PWR_PHONE_PWR_OFF:
		return "IPC_PWR_PHONE_PWR_OFF";
		case IPC_PWR_PHONE_PWR_UP:
		return "IPC_PWR_PHONE_PWR_UP";
		case IPC_PWR_PHONE_RESET:
		return "IPC_PWR_PHONE_RESET";
		case IPC_PWR_BATT_STATUS:
		return "IPC_PWR_BATT_STATUS";
		case IPC_PWR_BATT_TYPE:
		return "IPC_PWR_BATT_TYPE";
		case IPC_PWR_BATT_COMP:
		return "IPC_PWR_BATT_COMP";
		case IPC_PWR_PHONE_STATE:
		return "IPC_PWR_PHONE_STATE";
		case IPC_PB_ACCESS:
		return "IPC_PB_ACCESS";
		case IPC_PB_STORAGE:
		return "IPC_PB_STORAGE";
		case IPC_PB_STORAGE_LIST:
		return "IPC_PB_STORAGE_LIST";
		case IPC_PB_ENTRY_INFO:
		return "IPC_PB_ENTRY_INFO";
		case IPC_PB_CAPABILITY_INFO:
		return "IPC_PB_CAPABILITY_INFO";
		case IPC_SS_WAITING:
		return "IPC_SS_WAITING";
		case IPC_SS_CLI:
		return "IPC_SS_CLI";
		case IPC_SS_BARRING:
		return "IPC_SS_BARRING";
		case IPC_SS_BARRING_PW:
		return "IPC_SS_BARRING_PW";
		case IPC_SS_FORWARDING:
		return "IPC_SS_FORWARDING";
		case IPC_SS_INFO:
		return "IPC_SS_INFO";
		case IPC_SS_MANAGE_CALL:
		return "IPC_SS_MANAGE_CALL";
		case IPC_SS_USSD:
		return "IPC_SS_USSD";
		case IPC_SS_AOC:
		return "IPC_SS_AOC";
		case IPC_SS_RELEASE_COMPLETE:
		return "IPC_SS_RELEASE_COMPLETE";
		case IPC_GPRS_DEFINE_PDP_CONTEXT:
		return "IPC_GPRS_DEFINE_PDP_CONTEXT";
		case IPC_GPRS_QOS:
		return "IPC_GPRS_QOS";
		case IPC_GPRS_PS:
		return "IPC_GPRS_PS";
		case IPC_GPRS_PDP_CONTEXT:
		return "IPC_GPRS_PDP_CONTEXT";
		case IPC_GPRS_SHOW_PDP_ADDR:
		return "IPC_GPRS_SHOW_PDP_ADDR";
		case IPC_GPRS_3G_QUAL_SERVICE_PROFILE:
		return "IPC_GPRS_3G_QUAL_SERVICE_PROFILE";
		case IPC_GPRS_IP_CONFIGURATION:
		return "IPC_GPRS_IP_CONFIGURATION";
		case IPC_GPRS_DEFINE_SEC_PDP_CONTEXT:
		return "IPC_GPRS_DEFINE_SEC_PDP_CONTEXT";
		case IPC_GPRS_TFT:
		return "IPC_GPRS_TFT";
		case IPC_GPRS_HSDPA_STATUS:
		return "IPC_GPRS_HSDPA_STATUS";
		case IPC_GPRS_CURRENT_SESSION_DATA_COUNT:
		return "IPC_GPRS_CURRENT_SESSION_DATA_COUNT";
		case IPC_GPRS_DATA_DORMANT:
		return "IPC_GPRS_DATA_DORMANT";
		case IPC_GPRS_DUN_PIN_CTRL:
		return "IPC_GPRS_DUN_PIN_CTRL";
		case IPC_GPRS_CALL_STATUS:
		return "IPC_GPRS_CALL_STATUS";
		case IPC_SAT_PROFILE_DOWNLOAD:
		return "IPC_SAT_PROFILE_DOWNLOAD";
		case IPC_SAT_ENVELOPE_CMD:
		return "IPC_SAT_ENVELOPE_CMD";
		case IPC_SAT_PROACTIVE_CMD:
		return "IPC_SAT_PROACTIVE_CMD";
		case IPC_SAT_TERMINATE_USAT_SESSION:
		return "IPC_SAT_TERMINATE_USAT_SESSION";
		case IPC_SAT_EVENT_DOWNLOAD:
		return "IPC_SAT_EVENT_DOWNLOAD";
		case IPC_SAT_PROVIDE_LOCAL_INFO:
		return "IPC_SAT_PROVIDE_LOCAL_INFO";
		case IPC_SAT_POLLING:
		return "IPC_SAT_POLLING";
		case IPC_SAT_REFRESH:
		return "IPC_SAT_REFRESH";
		case IPC_SAT_SETUP_EVENT_LIST:
		return "IPC_SAT_SETUP_EVENT_LIST";
		case IPC_SAT_CALL_CONTROL_RESULT:
		return "IPC_SAT_CALL_CONTROL_RESULT";
		case IPC_SAT_IMAGE_CLUT:
		return "IPC_SAT_IMAGE_CLUT";
		case IPC_SAT_CALL_PROCESSING:
		return "IPC_SAT_CALL_PROCESSING";
		case IPC_IMEI_START:
		return "IPC_IMEI_START";
		case IPC_IMEI_CHECK_DEVICE_INFO:
		return "IPC_IMEI_CHECK_DEVICE_INFO";
		case IPC_CALL_OUTGOING:
		return "IPC_CALL_OUTGOING";
		case IPC_CALL_INCOMING:
		return "IPC_CALL_INCOMING";
		case IPC_CALL_RELEASE:
		return "IPC_CALL_RELEASE";
		case IPC_CALL_ANSWER:
		return "IPC_CALL_ANSWER";
		case IPC_CALL_STATUS:
		return "IPC_CALL_STATUS";
		case IPC_CALL_LIST:
		return "IPC_CALL_LIST";
		case IPC_CALL_BURST_DTMF:
		return "IPC_CALL_BURST_DTMF";
		case IPC_CALL_CONT_DTMF:
		return "IPC_CALL_CONT_DTMF";
		case IPC_CALL_WAITING:
		return "IPC_CALL_WAITING";
		case IPC_CALL_LINE_ID:
		return "IPC_CALL_LINE_ID";
		case IPC_DISP_ICON_INFO:
		return "IPC_DISP_ICON_INFO";
		case IPC_DISP_HOMEZONE_INFO:
		return "IPC_DISP_HOMEZONE_INFO";
		case IPC_DISP_RSSI_INFO:
		return "IPC_DISP_RSSI_INFO";
		case IPC_SEC_PIN_STATUS:
		return "IPC_SEC_PIN_STATUS";
		case IPC_SEC_PHONE_LOCK:
		return "IPC_SEC_PHONE_LOCK";
		case IPC_SEC_CHANGE_LOCKING_PW:
		return "IPC_SEC_CHANGE_LOCKING_PW";
		case IPC_SEC_SIM_LANG:
		return "IPC_SEC_SIM_LANG";
		case IPC_SEC_RSIM_ACCESS:
		return "IPC_SEC_RSIM_ACCESS";
		case IPC_SEC_GSIM_ACCESS:
		return "IPC_SEC_GSIM_ACCESS";
		case IPC_SEC_SIM_ICC_TYPE:
		return "IPC_SEC_SIM_ICC_TYPE";
		case IPC_SEC_LOCK_INFO:
		return "IPC_SEC_LOCK_INFO";
		case IPC_SEC_ISIM_AUTH:
		return "IPC_SEC_ISIM_AUTH";
		case IPC_NET_PREF_PLMN:
		return "IPC_NET_PREF_PLMN";
		case IPC_NET_PLMN_SEL:
		return "IPC_NET_PLMN_SEL";
		case IPC_NET_CURRENT_PLMN:
		return "IPC_NET_CURRENT_PLMN";
		case IPC_NET_PLMN_LIST:
		return "IPC_NET_PLMN_LIST";
		case IPC_NET_REGIST:
		return "IPC_NET_REGIST";
		case IPC_NET_SUBSCRIBER_NUM:
		return "IPC_NET_SUBSCRIBER_NUM";
		case IPC_NET_BAND_SEL:
		return "IPC_NET_BAND_SEL";
		case IPC_NET_SERVICE_DOMAIN_CONFIG:
		return "IPC_NET_SERVICE_DOMAIN_CONFIG";
		case IPC_NET_POWERON_ATTACH:
		return "IPC_NET_POWERON_ATTACH";
		case IPC_NET_MODE_SEL:
		return "IPC_NET_MODE_SEL";
		case IPC_NET_ACQ_ORDER:
		return "IPC_NET_ACQ_ORDER";
		case IPC_NET_IDENTITY:
		return "IPC_NET_IDENTITY";
		case IPC_NET_CURRENT_RRC_STATUS:
		return "IPC_NET_CURRENT_RRC_STATUS";
		case IPC_GEN_PHONE_RES:
		return "IPC_GEN_PHONE_RES";
		case IPC_MISC_ME_VERSION:
		return "IPC_MISC_ME_VERSION";
		case IPC_MISC_ME_IMSI:
		return "IPC_MISC_ME_IMSI";
		case IPC_MISC_ME_SN:
		return "IPC_MISC_ME_SN";
		case IPC_MISC_TIME_INFO:
		return "IPC_MISC_TIME_INFO";
		case IPC_SMS_SEND_MSG:
		return "IPC_SMS_SEND_MSG";
		case IPC_SMS_INCOMING_MSG:
		return "IPC_SMS_INCOMING_MSG";
		case IPC_SMS_READ_MSG:
		return "IPC_SMS_READ_MSG";
		case IPC_SMS_SAVE_MSG:
		return "IPC_SMS_SAVE_MSG";
		case IPC_SMS_DEL_MSG:
		return "IPC_SMS_DEL_MSG";
		case IPC_SMS_DELIVER_REPORT:
		return "IPC_SMS_DELIVER_REPORT";
		case IPC_SMS_DEVICE_READY:
		return "IPC_SMS_DEVICE_READY";
		case IPC_SMS_SEL_MEM:
		return "IPC_SMS_SEL_MEM";
		case IPC_SMS_STORED_MSG_COUNT:
		return "IPC_SMS_STORED_MSG_COUNT";
		case IPC_SMS_SVC_CENTER_ADDR:
		return "IPC_SMS_SVC_CENTER_ADDR";
		case IPC_SMS_SVC_OPTION:
		return "IPC_SMS_SVC_OPTION";
		case IPC_SMS_MEM_STATUS:
		return "IPC_SMS_MEM_STATUS";
		case IPC_SMS_CBS_MSG:
		return "IPC_SMS_CBS_MSG";
		case IPC_SMS_CBS_CONFIG:
		return "IPC_SMS_CBS_CONFIG";
		case IPC_SMS_STORED_MSG_STATUS:
		return "IPC_SMS_STORED_MSG_STATUS";
		case IPC_SMS_PARAM_COUNT:
		return "IPC_SMS_PARAM_COUNT";
		case IPC_SMS_PARAM:
		return "IPC_SMS_PARAM";
		case IPC_SND_SPKR_VOLUME_CTRL:
		return "IPC_SND_SPKR_VOLUME_CTRL";
		case IPC_SND_MIC_MUTE_CTRL:
		return "IPC_SND_MIC_MUTE_CTRL";
		case IPC_SND_AUDIO_PATH_CTRL:
		return "IPC_SND_AUDIO_PATH_CTRL";
		case IPC_SND_RINGBACK_TONE_CTRL:
		return "IPC_SND_RINGBACK_TONE_CTRL";
		case IPC_SND_CLOCK_CTRL:
		return "IPC_SND_CLOCK_CTRL";
		case IPC_RFS_NV_READ_ITEM:
		return "IPC_RFS_NV_READ_ITEM";
		case IPC_RFS_NV_WRITE_ITEM:
		return "IPC_RFS_NV_WRITE_ITEM";
	}
	return NULL;
}


static void samsung_command_handler_real_writeToTransport (FsoFrameworkAbstractCommandHandler* base, FsoFrameworkTransport* t) {
	SamsungCommandHandler * self;
	FsoFrameworkLogger* _tmp0_;
	guint8 _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	int _tmp4_;
	const gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_;
	unsigned short _tmp8_;
	const gchar* _tmp9_ = NULL;
	gchar* _tmp10_ = NULL;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gboolean _tmp14_ = FALSE;
	FsoFrameworkLogger* _tmp15_;
	guint8* _tmp16_;
	gint _tmp16__length1;
	gchar* _tmp17_ = NULL;
	gchar* _tmp18_;
	gchar* _tmp19_ = NULL;
	gchar* _tmp20_;
	gboolean _tmp21_ = FALSE;
	FsoFrameworkLogger* _tmp22_;
	guint8* _tmp23_;
	gint _tmp23__length1;
	gchar* _tmp24_ = NULL;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gboolean _tmp28_ = FALSE;
	struct ipc_client* _tmp29_;
	unsigned short _tmp30_;
	int _tmp31_;
	guint8* _tmp32_;
	gint _tmp32__length1;
	guint8 _tmp33_;
	self = (SamsungCommandHandler*) base;
	g_return_if_fail (t != NULL);
	_tmp0_ = fso_framework_theLogger;
	_tmp1_ = self->id;
	_tmp2_ = g_strdup_printf ("%hhu", _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = self->request_type;
	_tmp5_ = _samsung_ipc_request_type_to_string (_tmp4_);
	_tmp6_ = g_strconcat ("Sending request with id = ", _tmp3_, ", request_type = ", _tmp5_, ", ", NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = self->message_type;
	_tmp9_ = _samsung_ipc_message_type_to_string (_tmp8_);
	_tmp10_ = g_strconcat ("message_type = ", _tmp9_, " ", NULL);
	_tmp11_ = _tmp10_;
	_tmp12_ = g_strconcat (_tmp7_, _tmp11_, NULL);
	_tmp13_ = _tmp12_;
	_tmp14_ = fso_framework_logger_debug (_tmp0_, _tmp13_);
	g_assert (_tmp14_);
	_g_free0 (_tmp13_);
	_g_free0 (_tmp11_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp3_);
	_tmp15_ = fso_framework_theLogger;
	_tmp16_ = self->data;
	_tmp16__length1 = self->data_length1;
	_tmp17_ = g_strdup_printf ("%i", _tmp16__length1);
	_tmp18_ = _tmp17_;
	_tmp19_ = g_strconcat ("request data (length = ", _tmp18_, "):", NULL);
	_tmp20_ = _tmp19_;
	_tmp21_ = fso_framework_logger_debug (_tmp15_, _tmp20_);
	g_assert (_tmp21_);
	_g_free0 (_tmp20_);
	_g_free0 (_tmp18_);
	_tmp22_ = fso_framework_theLogger;
	_tmp23_ = self->data;
	_tmp23__length1 = self->data_length1;
	_tmp24_ = fso_framework_string_handling_hexdump (_tmp23_, _tmp23__length1, 16, "", (guchar) '?');
	_tmp25_ = _tmp24_;
	_tmp26_ = g_strconcat ("\n", _tmp25_, NULL);
	_tmp27_ = _tmp26_;
	_tmp28_ = fso_framework_logger_debug (_tmp22_, _tmp27_);
	g_assert (_tmp28_);
	_g_free0 (_tmp27_);
	_g_free0 (_tmp25_);
	_tmp29_ = self->client;
	_tmp30_ = self->message_type;
	_tmp31_ = self->request_type;
	_tmp32_ = self->data;
	_tmp32__length1 = self->data_length1;
	_tmp33_ = self->id;
	ipc_client_send (_tmp29_, _tmp30_, _tmp31_, _tmp32_, _tmp32__length1, _tmp33_);
}


static gchar* samsung_command_handler_real_to_string (FsoFrameworkAbstractCommandHandler* base) {
	SamsungCommandHandler * self;
	gchar* result = NULL;
	gchar* _tmp0_;
	self = (SamsungCommandHandler*) base;
	_tmp0_ = g_strdup ("<>");
	result = _tmp0_;
	return result;
}


SamsungCommandHandler* samsung_command_handler_construct (GType object_type) {
	SamsungCommandHandler* self = NULL;
	self = (SamsungCommandHandler*) fso_framework_abstract_command_handler_construct (object_type);
	return self;
}


SamsungCommandHandler* samsung_command_handler_new (void) {
	return samsung_command_handler_construct (SAMSUNG_TYPE_COMMAND_HANDLER);
}


static void samsung_command_handler_class_init (SamsungCommandHandlerClass * klass) {
	samsung_command_handler_parent_class = g_type_class_peek_parent (klass);
	FSO_FRAMEWORK_ABSTRACT_COMMAND_HANDLER_CLASS (klass)->finalize = samsung_command_handler_finalize;
	FSO_FRAMEWORK_ABSTRACT_COMMAND_HANDLER_CLASS (klass)->writeToTransport = samsung_command_handler_real_writeToTransport;
	FSO_FRAMEWORK_ABSTRACT_COMMAND_HANDLER_CLASS (klass)->to_string = samsung_command_handler_real_to_string;
}


static void samsung_command_handler_instance_init (SamsungCommandHandler * self) {
	self->timed_out = FALSE;
}


static void samsung_command_handler_finalize (FsoFrameworkAbstractCommandHandler* obj) {
	SamsungCommandHandler * self;
	self = SAMSUNG_COMMAND_HANDLER (obj);
	self->data = (g_free (self->data), NULL);
	FSO_FRAMEWORK_ABSTRACT_COMMAND_HANDLER_CLASS (samsung_command_handler_parent_class)->finalize (obj);
}


GType samsung_command_handler_get_type (void) {
	return samsung_command_handler_type_id;
}


GType samsung_command_handler_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (SamsungCommandHandlerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) samsung_command_handler_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SamsungCommandHandler), 0, (GInstanceInitFunc) samsung_command_handler_instance_init, NULL };
	samsung_command_handler_type_id = g_type_module_register_type (module, FSO_FRAMEWORK_TYPE_ABSTRACT_COMMAND_HANDLER, "SamsungCommandHandler", &g_define_type_info, 0);
	return samsung_command_handler_type_id;
}



