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

/*
 * Copyright (C) 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 <fsogsm.h>
#include <gio/gio.h>
#include <freesmartphone.h>
#include <stdlib.h>
#include <string.h>


#define TYPE_SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES (samsung_sms_retrieve_text_messages_get_type ())
#define SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES, SamsungSmsRetrieveTextMessages))
#define SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES, SamsungSmsRetrieveTextMessagesClass))
#define IS_SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES))
#define IS_SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES))
#define SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES, SamsungSmsRetrieveTextMessagesClass))

typedef struct _SamsungSmsRetrieveTextMessages SamsungSmsRetrieveTextMessages;
typedef struct _SamsungSmsRetrieveTextMessagesClass SamsungSmsRetrieveTextMessagesClass;
typedef struct _SamsungSmsRetrieveTextMessagesPrivate SamsungSmsRetrieveTextMessagesPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _SamsungSmsRetrieveTextMessagesRunData SamsungSmsRetrieveTextMessagesRunData;

#define TYPE_SAMSUNG_SMS_SEND_TEXT_MESSAGE (samsung_sms_send_text_message_get_type ())
#define SAMSUNG_SMS_SEND_TEXT_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SAMSUNG_SMS_SEND_TEXT_MESSAGE, SamsungSmsSendTextMessage))
#define SAMSUNG_SMS_SEND_TEXT_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SAMSUNG_SMS_SEND_TEXT_MESSAGE, SamsungSmsSendTextMessageClass))
#define IS_SAMSUNG_SMS_SEND_TEXT_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SAMSUNG_SMS_SEND_TEXT_MESSAGE))
#define IS_SAMSUNG_SMS_SEND_TEXT_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SAMSUNG_SMS_SEND_TEXT_MESSAGE))
#define SAMSUNG_SMS_SEND_TEXT_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SAMSUNG_SMS_SEND_TEXT_MESSAGE, SamsungSmsSendTextMessageClass))

typedef struct _SamsungSmsSendTextMessage SamsungSmsSendTextMessage;
typedef struct _SamsungSmsSendTextMessageClass SamsungSmsSendTextMessageClass;
typedef struct _SamsungSmsSendTextMessagePrivate SamsungSmsSendTextMessagePrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _SamsungSmsSendTextMessageRunData SamsungSmsSendTextMessageRunData;

struct _SamsungSmsRetrieveTextMessages {
	FsoGsmSmsRetrieveTextMessages parent_instance;
	SamsungSmsRetrieveTextMessagesPrivate * priv;
};

struct _SamsungSmsRetrieveTextMessagesClass {
	FsoGsmSmsRetrieveTextMessagesClass parent_class;
};

struct _SamsungSmsRetrieveTextMessagesRunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	SamsungSmsRetrieveTextMessages* self;
	GError* _tmp0_;
	GError * _inner_error_;
};

struct _SamsungSmsSendTextMessage {
	FsoGsmSmsSendTextMessage parent_instance;
	SamsungSmsSendTextMessagePrivate * priv;
};

struct _SamsungSmsSendTextMessageClass {
	FsoGsmSmsSendTextMessageClass parent_class;
};

struct _SamsungSmsSendTextMessageRunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	SamsungSmsSendTextMessage* self;
	gchar* recipient_number;
	gchar* contents;
	gboolean want_report;
	GError* _tmp0_;
	GError * _inner_error_;
};


static gpointer samsung_sms_retrieve_text_messages_parent_class = NULL;
static GType samsung_sms_retrieve_text_messages_type_id = 0;
static gpointer samsung_sms_send_text_message_parent_class = NULL;
static GType samsung_sms_send_text_message_type_id = 0;

GType samsung_sms_retrieve_text_messages_get_type (void) G_GNUC_CONST;
GType samsung_sms_retrieve_text_messages_register_type (GTypeModule * module);
enum  {
	SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES_DUMMY_PROPERTY
};
static void samsung_sms_retrieve_text_messages_real_run_data_free (gpointer _data);
static void samsung_sms_retrieve_text_messages_real_run (FsoGsmSmsRetrieveTextMessages* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean samsung_sms_retrieve_text_messages_real_run_co (SamsungSmsRetrieveTextMessagesRunData* _data_);
SamsungSmsRetrieveTextMessages* samsung_sms_retrieve_text_messages_new (void);
SamsungSmsRetrieveTextMessages* samsung_sms_retrieve_text_messages_construct (GType object_type);
GType samsung_sms_send_text_message_get_type (void) G_GNUC_CONST;
GType samsung_sms_send_text_message_register_type (GTypeModule * module);
enum  {
	SAMSUNG_SMS_SEND_TEXT_MESSAGE_DUMMY_PROPERTY
};
static void samsung_sms_send_text_message_real_run_data_free (gpointer _data);
static void samsung_sms_send_text_message_real_run (FsoGsmSmsSendTextMessage* base, const gchar* recipient_number, const gchar* contents, gboolean want_report, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean samsung_sms_send_text_message_real_run_co (SamsungSmsSendTextMessageRunData* _data_);
SamsungSmsSendTextMessage* samsung_sms_send_text_message_new (void);
SamsungSmsSendTextMessage* samsung_sms_send_text_message_construct (GType object_type);


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


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


static void samsung_sms_retrieve_text_messages_real_run (FsoGsmSmsRetrieveTextMessages* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	SamsungSmsRetrieveTextMessages * self;
	SamsungSmsRetrieveTextMessagesRunData* _data_;
	SamsungSmsRetrieveTextMessages* _tmp0_;
	self = (SamsungSmsRetrieveTextMessages*) base;
	_data_ = g_slice_new0 (SamsungSmsRetrieveTextMessagesRunData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, samsung_sms_retrieve_text_messages_real_run);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, samsung_sms_retrieve_text_messages_real_run_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	samsung_sms_retrieve_text_messages_real_run_co (_data_);
}


static void samsung_sms_retrieve_text_messages_real_run_finish (FsoGsmSmsRetrieveTextMessages* base, GAsyncResult* _res_, GError** error) {
	SamsungSmsRetrieveTextMessagesRunData* _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 gboolean samsung_sms_retrieve_text_messages_real_run_co (SamsungSmsRetrieveTextMessagesRunData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_error_new_literal (FREE_SMARTPHONE_ERROR, FREE_SMARTPHONE_ERROR_UNSUPPORTED, "Not yet implemented!");
	_data_->_inner_error_ = _data_->_tmp0_;
	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_);
		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_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;
}


SamsungSmsRetrieveTextMessages* samsung_sms_retrieve_text_messages_construct (GType object_type) {
	SamsungSmsRetrieveTextMessages * self = NULL;
	self = (SamsungSmsRetrieveTextMessages*) fso_gsm_sms_retrieve_text_messages_construct (object_type);
	return self;
}


SamsungSmsRetrieveTextMessages* samsung_sms_retrieve_text_messages_new (void) {
	return samsung_sms_retrieve_text_messages_construct (TYPE_SAMSUNG_SMS_RETRIEVE_TEXT_MESSAGES);
}


static void samsung_sms_retrieve_text_messages_class_init (SamsungSmsRetrieveTextMessagesClass * klass) {
	samsung_sms_retrieve_text_messages_parent_class = g_type_class_peek_parent (klass);
	FSO_GSM_SMS_RETRIEVE_TEXT_MESSAGES_CLASS (klass)->run = samsung_sms_retrieve_text_messages_real_run;
	FSO_GSM_SMS_RETRIEVE_TEXT_MESSAGES_CLASS (klass)->run_finish = samsung_sms_retrieve_text_messages_real_run_finish;
}


static void samsung_sms_retrieve_text_messages_instance_init (SamsungSmsRetrieveTextMessages * self) {
}


/**
 * SMS Mediators
 **/
GType samsung_sms_retrieve_text_messages_get_type (void) {
	return samsung_sms_retrieve_text_messages_type_id;
}


GType samsung_sms_retrieve_text_messages_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (SamsungSmsRetrieveTextMessagesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) samsung_sms_retrieve_text_messages_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SamsungSmsRetrieveTextMessages), 0, (GInstanceInitFunc) samsung_sms_retrieve_text_messages_instance_init, NULL };
	samsung_sms_retrieve_text_messages_type_id = g_type_module_register_type (module, FSO_GSM_TYPE_SMS_RETRIEVE_TEXT_MESSAGES, "SamsungSmsRetrieveTextMessages", &g_define_type_info, 0);
	return samsung_sms_retrieve_text_messages_type_id;
}


static void samsung_sms_send_text_message_real_run_data_free (gpointer _data) {
	SamsungSmsSendTextMessageRunData* _data_;
	_data_ = _data;
	_g_free0 (_data_->recipient_number);
	_g_free0 (_data_->contents);
	_g_object_unref0 (_data_->self);
	g_slice_free (SamsungSmsSendTextMessageRunData, _data_);
}


static void samsung_sms_send_text_message_real_run (FsoGsmSmsSendTextMessage* base, const gchar* recipient_number, const gchar* contents, gboolean want_report, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	SamsungSmsSendTextMessage * self;
	SamsungSmsSendTextMessageRunData* _data_;
	SamsungSmsSendTextMessage* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gboolean _tmp5_;
	self = (SamsungSmsSendTextMessage*) base;
	_data_ = g_slice_new0 (SamsungSmsSendTextMessageRunData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, samsung_sms_send_text_message_real_run);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, samsung_sms_send_text_message_real_run_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = recipient_number;
	_tmp2_ = g_strdup (_tmp1_);
	_data_->recipient_number = _tmp2_;
	_tmp3_ = contents;
	_tmp4_ = g_strdup (_tmp3_);
	_data_->contents = _tmp4_;
	_tmp5_ = want_report;
	_data_->want_report = _tmp5_;
	samsung_sms_send_text_message_real_run_co (_data_);
}


static void samsung_sms_send_text_message_real_run_finish (FsoGsmSmsSendTextMessage* base, GAsyncResult* _res_, GError** error) {
	SamsungSmsSendTextMessageRunData* _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 gboolean samsung_sms_send_text_message_real_run_co (SamsungSmsSendTextMessageRunData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_error_new_literal (FREE_SMARTPHONE_ERROR, FREE_SMARTPHONE_ERROR_UNSUPPORTED, "Not yet implemented!");
	_data_->_inner_error_ = _data_->_tmp0_;
	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_);
		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_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;
}


SamsungSmsSendTextMessage* samsung_sms_send_text_message_construct (GType object_type) {
	SamsungSmsSendTextMessage * self = NULL;
	self = (SamsungSmsSendTextMessage*) fso_gsm_sms_send_text_message_construct (object_type);
	return self;
}


SamsungSmsSendTextMessage* samsung_sms_send_text_message_new (void) {
	return samsung_sms_send_text_message_construct (TYPE_SAMSUNG_SMS_SEND_TEXT_MESSAGE);
}


static void samsung_sms_send_text_message_class_init (SamsungSmsSendTextMessageClass * klass) {
	samsung_sms_send_text_message_parent_class = g_type_class_peek_parent (klass);
	FSO_GSM_SMS_SEND_TEXT_MESSAGE_CLASS (klass)->run = samsung_sms_send_text_message_real_run;
	FSO_GSM_SMS_SEND_TEXT_MESSAGE_CLASS (klass)->run_finish = samsung_sms_send_text_message_real_run_finish;
}


static void samsung_sms_send_text_message_instance_init (SamsungSmsSendTextMessage * self) {
}


GType samsung_sms_send_text_message_get_type (void) {
	return samsung_sms_send_text_message_type_id;
}


GType samsung_sms_send_text_message_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (SamsungSmsSendTextMessageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) samsung_sms_send_text_message_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SamsungSmsSendTextMessage), 0, (GInstanceInitFunc) samsung_sms_send_text_message_instance_init, NULL };
	samsung_sms_send_text_message_type_id = g_type_module_register_type (module, FSO_GSM_TYPE_SMS_SEND_TEXT_MESSAGE, "SamsungSmsSendTextMessage", &g_define_type_info, 0);
	return samsung_sms_send_text_message_type_id;
}



