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

/*
 * Copyright (C) 2011-2012 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library 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
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; 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 <fsosystem.h>
#include <stdlib.h>
#include <string.h>

#define _fso_framework_network_interface_unref0(var) ((var == NULL) ? NULL : (var = (fso_framework_network_interface_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))



void test_network_interface_updown (void);
void test_wireless_network_power_status (void);
void _vala_main (gchar** args, int args_length1);
static void _test_network_interface_updown_gcallback (void);
static void _test_wireless_network_power_status_gcallback (void);


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;
}


void test_network_interface_updown (void) {
	GError * _inner_error_ = NULL;
	{
		FsoFrameworkNetworkInterface* _tmp0_;
		FsoFrameworkNetworkInterface* iface;
		FsoFrameworkNetworkInterface* _tmp1_;
		gboolean _tmp2_ = FALSE;
		gboolean _tmp3_;
		_tmp0_ = fso_framework_network_interface_new ("eth0", &_inner_error_);
		iface = _tmp0_;
		if (_inner_error_ != NULL) {
			goto __catch0_g_error;
		}
		_tmp1_ = iface;
		_tmp2_ = fso_framework_network_interface_is_up (_tmp1_, &_inner_error_);
		_tmp3_ = _tmp2_;
		if (_inner_error_ != NULL) {
			_fso_framework_network_interface_unref0 (iface);
			goto __catch0_g_error;
		}
		if (_tmp3_) {
			FsoFrameworkNetworkInterface* _tmp4_;
			FsoFrameworkNetworkInterface* _tmp5_;
			gboolean _tmp6_ = FALSE;
			gboolean _tmp7_;
			_tmp4_ = iface;
			fso_framework_network_interface_down (_tmp4_, &_inner_error_);
			if (_inner_error_ != NULL) {
				_fso_framework_network_interface_unref0 (iface);
				goto __catch0_g_error;
			}
			_tmp5_ = iface;
			_tmp6_ = fso_framework_network_interface_is_up (_tmp5_, &_inner_error_);
			_tmp7_ = _tmp6_;
			if (_inner_error_ != NULL) {
				_fso_framework_network_interface_unref0 (iface);
				goto __catch0_g_error;
			}
			g_assert (!_tmp7_);
		} else {
			FsoFrameworkNetworkInterface* _tmp8_;
			FsoFrameworkNetworkInterface* _tmp9_;
			gboolean _tmp10_ = FALSE;
			gboolean _tmp11_;
			_tmp8_ = iface;
			fso_framework_network_interface_up (_tmp8_, &_inner_error_);
			if (_inner_error_ != NULL) {
				_fso_framework_network_interface_unref0 (iface);
				goto __catch0_g_error;
			}
			_tmp9_ = iface;
			_tmp10_ = fso_framework_network_interface_is_up (_tmp9_, &_inner_error_);
			_tmp11_ = _tmp10_;
			if (_inner_error_ != NULL) {
				_fso_framework_network_interface_unref0 (iface);
				goto __catch0_g_error;
			}
			g_assert (_tmp11_);
		}
		_fso_framework_network_interface_unref0 (iface);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		const gchar* _tmp12_;
		const gchar* _tmp13_ = NULL;
		gchar* _tmp14_ = NULL;
		gchar* _tmp15_;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp12_ = err->message;
		_tmp13_ = string_to_string (_tmp12_);
		_tmp14_ = g_strconcat ("test_network_interface_updown failed: ", _tmp13_, NULL);
		_tmp15_ = _tmp14_;
		g_error ("testnetwork.vala:42: %s", _tmp15_);
		_g_free0 (_tmp15_);
		_g_error_free0 (err);
	}
	__finally0:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


void test_wireless_network_power_status (void) {
	GError * _inner_error_ = NULL;
	{
		FsoFrameworkNetworkWextInterface* _tmp0_;
		FsoFrameworkNetworkWextInterface* iface;
		FsoFrameworkNetworkWextInterface* _tmp1_;
		FsoFrameworkNetworkWextInterface* _tmp2_;
		_tmp0_ = fso_framework_network_wext_interface_new ("eth1", &_inner_error_);
		iface = _tmp0_;
		if (_inner_error_ != NULL) {
			goto __catch1_g_error;
		}
		_tmp1_ = iface;
		fso_framework_network_interface_up ((FsoFrameworkNetworkInterface*) _tmp1_, &_inner_error_);
		if (_inner_error_ != NULL) {
			_fso_framework_network_interface_unref0 (iface);
			goto __catch1_g_error;
		}
		_tmp2_ = iface;
		fso_framework_network_wext_interface_set_power (_tmp2_, TRUE, &_inner_error_);
		if (_inner_error_ != NULL) {
			_fso_framework_network_interface_unref0 (iface);
			goto __catch1_g_error;
		}
		_fso_framework_network_interface_unref0 (iface);
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* err = NULL;
		const gchar* _tmp3_;
		const gchar* _tmp4_ = NULL;
		gchar* _tmp5_ = NULL;
		gchar* _tmp6_;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp3_ = err->message;
		_tmp4_ = string_to_string (_tmp3_);
		_tmp5_ = g_strconcat ("test_wireless_network_power_status failed: ", _tmp4_, NULL);
		_tmp6_ = _tmp5_;
		g_error ("testnetwork.vala:56: %s", _tmp6_);
		_g_free0 (_tmp6_);
		_g_error_free0 (err);
	}
	__finally1:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


static void _test_network_interface_updown_gcallback (void) {
	test_network_interface_updown ();
}


static void _test_wireless_network_power_status_gcallback (void) {
	test_wireless_network_power_status ();
}


void _vala_main (gchar** args, int args_length1) {
	g_test_init (&args_length1, &args, NULL);
	g_test_add_func ("/Network/Interface/UpDown", _test_network_interface_updown_gcallback);
	g_test_add_func ("/Network/WextInterface/PowerStatus", _test_wireless_network_power_status_gcallback);
	g_test_run ();
}


int main (int argc, char ** argv) {
	g_type_init ();
	_vala_main (argv, argc);
	return 0;
}



