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

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


#define NOKIA_ISI_TYPE_ISI_PDP_SET_CREDENTIALS (nokia_isi_isi_pdp_set_credentials_get_type ())
#define NOKIA_ISI_ISI_PDP_SET_CREDENTIALS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NOKIA_ISI_TYPE_ISI_PDP_SET_CREDENTIALS, NokiaIsiIsiPdpSetCredentials))
#define NOKIA_ISI_ISI_PDP_SET_CREDENTIALS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NOKIA_ISI_TYPE_ISI_PDP_SET_CREDENTIALS, NokiaIsiIsiPdpSetCredentialsClass))
#define NOKIA_ISI_IS_ISI_PDP_SET_CREDENTIALS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NOKIA_ISI_TYPE_ISI_PDP_SET_CREDENTIALS))
#define NOKIA_ISI_IS_ISI_PDP_SET_CREDENTIALS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NOKIA_ISI_TYPE_ISI_PDP_SET_CREDENTIALS))
#define NOKIA_ISI_ISI_PDP_SET_CREDENTIALS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NOKIA_ISI_TYPE_ISI_PDP_SET_CREDENTIALS, NokiaIsiIsiPdpSetCredentialsClass))

typedef struct _NokiaIsiIsiPdpSetCredentials NokiaIsiIsiPdpSetCredentials;
typedef struct _NokiaIsiIsiPdpSetCredentialsClass NokiaIsiIsiPdpSetCredentialsClass;
typedef struct _NokiaIsiIsiPdpSetCredentialsPrivate NokiaIsiIsiPdpSetCredentialsPrivate;
#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_context_params_unref0(var) ((var == NULL) ? NULL : (var = (fso_gsm_context_params_unref (var), NULL)))
typedef struct _NokiaIsiIsiPdpSetCredentialsRunData NokiaIsiIsiPdpSetCredentialsRunData;

struct _NokiaIsiIsiPdpSetCredentials {
	FsoGsmPdpSetCredentials parent_instance;
	NokiaIsiIsiPdpSetCredentialsPrivate * priv;
};

struct _NokiaIsiIsiPdpSetCredentialsClass {
	FsoGsmPdpSetCredentialsClass parent_class;
};

struct _NokiaIsiIsiPdpSetCredentialsRunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	NokiaIsiIsiPdpSetCredentials* self;
	gchar* apn;
	gchar* username;
	gchar* password;
	FsoGsmModem* _tmp0_;
	FsoGsmModemData* _tmp1_;
	FsoGsmModemData* data;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	FsoGsmContextParams* _tmp5_;
};


static gpointer nokia_isi_isi_pdp_set_credentials_parent_class = NULL;
static GType nokia_isi_isi_pdp_set_credentials_type_id = 0;

GType nokia_isi_isi_pdp_set_credentials_get_type (void) G_GNUC_CONST;
GType nokia_isi_isi_pdp_set_credentials_register_type (GTypeModule * module);
enum  {
	NOKIA_ISI_ISI_PDP_SET_CREDENTIALS_DUMMY_PROPERTY
};
static void nokia_isi_isi_pdp_set_credentials_real_run_data_free (gpointer _data);
static void nokia_isi_isi_pdp_set_credentials_real_run (FsoGsmPdpSetCredentials* base, const gchar* apn, const gchar* username, const gchar* password, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean nokia_isi_isi_pdp_set_credentials_real_run_co (NokiaIsiIsiPdpSetCredentialsRunData* _data_);
NokiaIsiIsiPdpSetCredentials* nokia_isi_isi_pdp_set_credentials_new (void);
NokiaIsiIsiPdpSetCredentials* nokia_isi_isi_pdp_set_credentials_construct (GType object_type);


static void nokia_isi_isi_pdp_set_credentials_real_run_data_free (gpointer _data) {
	NokiaIsiIsiPdpSetCredentialsRunData* _data_;
	_data_ = _data;
	_g_free0 (_data_->apn);
	_g_free0 (_data_->username);
	_g_free0 (_data_->password);
	_g_object_unref0 (_data_->self);
	g_slice_free (NokiaIsiIsiPdpSetCredentialsRunData, _data_);
}


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


static void nokia_isi_isi_pdp_set_credentials_real_run (FsoGsmPdpSetCredentials* base, const gchar* apn, const gchar* username, const gchar* password, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	NokiaIsiIsiPdpSetCredentials * self;
	NokiaIsiIsiPdpSetCredentialsRunData* _data_;
	NokiaIsiIsiPdpSetCredentials* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	self = (NokiaIsiIsiPdpSetCredentials*) base;
	_data_ = g_slice_new0 (NokiaIsiIsiPdpSetCredentialsRunData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, nokia_isi_isi_pdp_set_credentials_real_run);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, nokia_isi_isi_pdp_set_credentials_real_run_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = apn;
	_tmp2_ = g_strdup (_tmp1_);
	_data_->apn = _tmp2_;
	_tmp3_ = username;
	_tmp4_ = g_strdup (_tmp3_);
	_data_->username = _tmp4_;
	_tmp5_ = password;
	_tmp6_ = g_strdup (_tmp5_);
	_data_->password = _tmp6_;
	nokia_isi_isi_pdp_set_credentials_real_run_co (_data_);
}


static void nokia_isi_isi_pdp_set_credentials_real_run_finish (FsoGsmPdpSetCredentials* base, GAsyncResult* _res_, GError** error) {
	NokiaIsiIsiPdpSetCredentialsRunData* _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 nokia_isi_isi_pdp_set_credentials_real_run_co (NokiaIsiIsiPdpSetCredentialsRunData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		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_->apn;
	_data_->_tmp3_ = _data_->username;
	_data_->_tmp4_ = _data_->password;
	_data_->_tmp5_ = fso_gsm_context_params_new (_data_->_tmp2_, _data_->_tmp3_, _data_->_tmp4_);
	_fso_gsm_context_params_unref0 (_data_->data->contextParams);
	_data_->data->contextParams = _data_->_tmp5_;
	_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;
}


NokiaIsiIsiPdpSetCredentials* nokia_isi_isi_pdp_set_credentials_construct (GType object_type) {
	NokiaIsiIsiPdpSetCredentials * self = NULL;
	self = (NokiaIsiIsiPdpSetCredentials*) fso_gsm_pdp_set_credentials_construct (object_type);
	return self;
}


NokiaIsiIsiPdpSetCredentials* nokia_isi_isi_pdp_set_credentials_new (void) {
	return nokia_isi_isi_pdp_set_credentials_construct (NOKIA_ISI_TYPE_ISI_PDP_SET_CREDENTIALS);
}


static void nokia_isi_isi_pdp_set_credentials_class_init (NokiaIsiIsiPdpSetCredentialsClass * klass) {
	nokia_isi_isi_pdp_set_credentials_parent_class = g_type_class_peek_parent (klass);
	FSO_GSM_PDP_SET_CREDENTIALS_CLASS (klass)->run = nokia_isi_isi_pdp_set_credentials_real_run;
	FSO_GSM_PDP_SET_CREDENTIALS_CLASS (klass)->run_finish = nokia_isi_isi_pdp_set_credentials_real_run_finish;
}


static void nokia_isi_isi_pdp_set_credentials_instance_init (NokiaIsiIsiPdpSetCredentials * self) {
}


GType nokia_isi_isi_pdp_set_credentials_get_type (void) {
	return nokia_isi_isi_pdp_set_credentials_type_id;
}


GType nokia_isi_isi_pdp_set_credentials_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (NokiaIsiIsiPdpSetCredentialsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) nokia_isi_isi_pdp_set_credentials_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NokiaIsiIsiPdpSetCredentials), 0, (GInstanceInitFunc) nokia_isi_isi_pdp_set_credentials_instance_init, NULL };
	nokia_isi_isi_pdp_set_credentials_type_id = g_type_module_register_type (module, FSO_GSM_TYPE_PDP_SET_CREDENTIALS, "NokiaIsiIsiPdpSetCredentials", &g_define_type_info, 0);
	return nokia_isi_isi_pdp_set_credentials_type_id;
}



