/* VPNInfoDialog.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from VPNInfoDialog.vala, do not modify */

/*
 * Copyright (c) 2015-2019 elementary, Inc. (https://elementary.io)
 *
 * This program 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 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
 */

#include "network.h"
#include <NetworkManager.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <granite-7.h>
#include <float.h>
#include <math.h>
#include <glib/gi18n-lib.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	NETWORK_WIDGETS_VPN_INFO_DIALOG_0_PROPERTY,
	NETWORK_WIDGETS_VPN_INFO_DIALOG_CONNECTION_PROPERTY,
	NETWORK_WIDGETS_VPN_INFO_DIALOG_NUM_PROPERTIES
};
static GParamSpec* network_widgets_vpn_info_dialog_properties[NETWORK_WIDGETS_VPN_INFO_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _nm_wireguard_peer_unref0(var) ((var == NULL) ? NULL : (var = (nm_wireguard_peer_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _NetworkWidgetsVPNInfoDialogPrivate {
	NMRemoteConnection* _connection;
	gchar* service_type;
	GtkLabel* vpn_type;
	GtkLabel* gateway;
	GtkLabel* username;
};

static gint NetworkWidgetsVPNInfoDialog_private_offset;
static gpointer network_widgets_vpn_info_dialog_parent_class = NULL;

static gchar* network_widgets_vpn_info_dialog_get_key_group_username (NetworkWidgetsVPNInfoDialog* self);
static gchar* network_widgets_vpn_info_dialog_get_key_gateway (NetworkWidgetsVPNInfoDialog* self);
static gchar* network_widgets_vpn_info_dialog_get_service_type (NMSettingVpn* vpn_settings);
static GObject * network_widgets_vpn_info_dialog_constructor (GType type,
                                                       guint n_construct_properties,
                                                       GObjectConstructParam * construct_properties);
static void _network_widgets_vpn_info_dialog_update_status_nm_connection_changed (NMConnection* _sender,
                                                                           gpointer self);
static void _network_widgets_vpn_info_dialog___lambda12_ (NetworkWidgetsVPNInfoDialog* self,
                                                   gint response);
static void _gtk_window_destroy_gtk_dialog_response (GtkDialog* _sender,
                                              gint response_id,
                                              gpointer self);
static void __network_widgets_vpn_info_dialog___lambda12__gtk_dialog_response (GtkDialog* _sender,
                                                                        gint response_id,
                                                                        gpointer self);
static void network_widgets_vpn_info_dialog_finalize (GObject * obj);
static GType network_widgets_vpn_info_dialog_get_type_once (void);
static void _vala_network_widgets_vpn_info_dialog_get_property (GObject * object,
                                                         guint property_id,
                                                         GValue * value,
                                                         GParamSpec * pspec);
static void _vala_network_widgets_vpn_info_dialog_set_property (GObject * object,
                                                         guint property_id,
                                                         const GValue * value,
                                                         GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

static inline gpointer
network_widgets_vpn_info_dialog_get_instance_private (NetworkWidgetsVPNInfoDialog* self)
{
	return G_STRUCT_MEMBER_P (self, NetworkWidgetsVPNInfoDialog_private_offset);
}

NetworkWidgetsVPNInfoDialog*
network_widgets_vpn_info_dialog_construct (GType object_type,
                                           NMRemoteConnection* connection)
{
	NetworkWidgetsVPNInfoDialog * self = NULL;
	GThemedIcon* _tmp0_;
	GThemedIcon* _tmp1_;
	_tmp0_ = (GThemedIcon*) g_themed_icon_new ("network-vpn");
	_tmp1_ = _tmp0_;
	self = (NetworkWidgetsVPNInfoDialog*) g_object_new (object_type, "image-icon", _tmp1_, "connection", connection, NULL);
	_g_object_unref0 (_tmp1_);
	return self;
}

NetworkWidgetsVPNInfoDialog*
network_widgets_vpn_info_dialog_new (NMRemoteConnection* connection)
{
	return network_widgets_vpn_info_dialog_construct (NETWORK_WIDGETS_TYPE_VPN_INFO_DIALOG, connection);
}

static gchar*
network_widgets_vpn_info_dialog_get_key_group_username (NetworkWidgetsVPNInfoDialog* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	gchar* _tmp8_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->service_type;
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	if ((_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("openvpn")))) || (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("openconnect"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp4_;
				_tmp4_ = g_strdup ("username");
				result = _tmp4_;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("vpnc")))) {
		switch (0) {
			default:
			{
				gchar* _tmp5_;
				_tmp5_ = g_strdup ("Xauth username");
				result = _tmp5_;
				return result;
			}
		}
	} else if ((_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("pptp")))) || (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("l2tp"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp6_;
				_tmp6_ = g_strdup ("user");
				result = _tmp6_;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("openswan")))) {
		switch (0) {
			default:
			{
				gchar* _tmp7_;
				_tmp7_ = g_strdup ("leftxauthusername");
				result = _tmp7_;
				return result;
			}
		}
	}
	_tmp8_ = g_strdup ("");
	result = _tmp8_;
	return result;
}

static gchar*
network_widgets_vpn_info_dialog_get_key_gateway (NetworkWidgetsVPNInfoDialog* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	gchar* _tmp8_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->service_type;
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("openvpn")))) {
		switch (0) {
			default:
			{
				gchar* _tmp4_;
				_tmp4_ = g_strdup ("remote");
				result = _tmp4_;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("vpnc")))) {
		switch (0) {
			default:
			{
				gchar* _tmp5_;
				_tmp5_ = g_strdup ("IPSec gateway");
				result = _tmp5_;
				return result;
			}
		}
	} else if (((_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("pptp")))) || (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("l2tp"))))) || (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("openconnect"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp6_;
				_tmp6_ = g_strdup ("gateway");
				result = _tmp6_;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("openswan")))) {
		switch (0) {
			default:
			{
				gchar* _tmp7_;
				_tmp7_ = g_strdup ("right");
				result = _tmp7_;
				return result;
			}
		}
	}
	_tmp8_ = g_strdup ("");
	result = _tmp8_;
	return result;
}

static gchar*
network_widgets_vpn_info_dialog_get_service_type (NMSettingVpn* vpn_settings)
{
	gchar* service_type = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar** arr = NULL;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gint arr_length1;
	gint _arr_size_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* result;
	g_return_val_if_fail (vpn_settings != NULL, NULL);
	_tmp0_ = nm_setting_vpn_get_service_type (vpn_settings);
	_tmp1_ = g_strdup (_tmp0_);
	service_type = _tmp1_;
	_tmp3_ = _tmp2_ = g_strsplit (service_type, ".", 0);
	arr = _tmp3_;
	arr_length1 = _vala_array_length (_tmp2_);
	_arr_size_ = arr_length1;
	_tmp4_ = arr[arr_length1 - 1];
	_tmp5_ = g_strdup (_tmp4_);
	result = _tmp5_;
	arr = (_vala_array_free (arr, arr_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (service_type);
	return result;
}

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

static gpointer
_nm_wireguard_peer_ref0 (gpointer self)
{
	return self ? nm_wireguard_peer_ref (self) : NULL;
}

void
network_widgets_vpn_info_dialog_update_status (NetworkWidgetsVPNInfoDialog* self)
{
	NMRemoteConnection* _tmp0_;
	NMRemoteConnection* _tmp1_;
	const gchar* _tmp2_;
	NMRemoteConnection* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	GQuark _tmp7_ = 0U;
	static GQuark _tmp6_label0 = 0;
	static GQuark _tmp6_label1 = 0;
	GtkLabel* _tmp41_;
	GtkLabel* _tmp42_;
	const gchar* _tmp43_;
	const gchar* _tmp44_;
	GtkLabel* _tmp45_;
	GtkLabel* _tmp46_;
	const gchar* _tmp47_;
	const gchar* _tmp48_;
	GtkLabel* _tmp49_;
	GtkLabel* _tmp50_;
	const gchar* _tmp51_;
	const gchar* _tmp52_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_connection;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->_connection;
	_tmp2_ = nm_connection_get_id ((NMConnection*) _tmp1_);
	granite_message_dialog_set_primary_text ((GraniteMessageDialog*) self, _tmp2_);
	_tmp3_ = self->priv->_connection;
	_tmp4_ = nm_connection_get_connection_type ((NMConnection*) _tmp3_);
	_tmp5_ = _tmp4_;
	_tmp7_ = (NULL == _tmp5_) ? 0 : g_quark_from_string (_tmp5_);
	if (_tmp7_ == ((0 != _tmp6_label0) ? _tmp6_label0 : (_tmp6_label0 = g_quark_from_static_string (NM_SETTING_WIREGUARD_SETTING_NAME)))) {
		switch (0) {
			default:
			{
				gchar* _tmp8_;
				GtkLabel* _tmp9_;
				const gchar* _tmp10_;
				NMSettingWireGuard* wireguard_settings = NULL;
				NMRemoteConnection* _tmp11_;
				NMSetting* _tmp12_;
				NMSettingWireGuard* _tmp13_;
				NMSettingWireGuard* _tmp14_;
				_tmp8_ = g_strdup (NM_SETTING_WIREGUARD_SETTING_NAME);
				_g_free0 (self->priv->service_type);
				self->priv->service_type = _tmp8_;
				_tmp9_ = self->priv->vpn_type;
				_tmp10_ = self->priv->service_type;
				gtk_label_set_label (_tmp9_, _tmp10_);
				_tmp11_ = self->priv->_connection;
				_tmp12_ = nm_connection_get_setting ((NMConnection*) _tmp11_, nm_setting_wireguard_get_type ());
				_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, nm_setting_wireguard_get_type (), NMSettingWireGuard));
				wireguard_settings = _tmp13_;
				_tmp14_ = wireguard_settings;
				if (_tmp14_ != NULL) {
					NMSettingWireGuard* _tmp15_;
					_tmp15_ = wireguard_settings;
					if (nm_setting_wireguard_get_peers_len (_tmp15_) >= ((guint) 1)) {
						NMWireGuardPeer* first_peer = NULL;
						NMSettingWireGuard* _tmp16_;
						NMWireGuardPeer* _tmp17_;
						NMWireGuardPeer* _tmp18_;
						GtkLabel* _tmp19_;
						NMWireGuardPeer* _tmp20_;
						const gchar* _tmp21_;
						GtkLabel* _tmp22_;
						_tmp16_ = wireguard_settings;
						_tmp17_ = nm_setting_wireguard_get_peer (_tmp16_, (guint) 0);
						_tmp18_ = _nm_wireguard_peer_ref0 (_tmp17_);
						first_peer = _tmp18_;
						_tmp19_ = self->priv->gateway;
						_tmp20_ = first_peer;
						_tmp21_ = nm_wireguard_peer_get_endpoint (_tmp20_);
						gtk_label_set_label (_tmp19_, _tmp21_);
						_tmp22_ = self->priv->username;
						gtk_label_set_label (_tmp22_, "");
						_nm_wireguard_peer_unref0 (first_peer);
					}
				}
				_g_object_unref0 (wireguard_settings);
				break;
			}
		}
	} else if (_tmp7_ == ((0 != _tmp6_label1) ? _tmp6_label1 : (_tmp6_label1 = g_quark_from_static_string (NM_SETTING_VPN_SETTING_NAME)))) {
		switch (0) {
			default:
			{
				NMSettingVpn* vpn_settings = NULL;
				NMRemoteConnection* _tmp23_;
				NMSettingVpn* _tmp24_;
				NMSettingVpn* _tmp25_;
				NMSettingVpn* _tmp26_;
				_tmp23_ = self->priv->_connection;
				_tmp24_ = nm_connection_get_setting_vpn ((NMConnection*) _tmp23_);
				_tmp25_ = _g_object_ref0 (_tmp24_);
				vpn_settings = _tmp25_;
				_tmp26_ = vpn_settings;
				if (_tmp26_ != NULL) {
					NMSettingVpn* _tmp27_;
					gchar* _tmp28_;
					GtkLabel* _tmp29_;
					const gchar* _tmp30_;
					GtkLabel* _tmp31_;
					NMSettingVpn* _tmp32_;
					gchar* _tmp33_;
					gchar* _tmp34_;
					const gchar* _tmp35_;
					GtkLabel* _tmp36_;
					NMSettingVpn* _tmp37_;
					gchar* _tmp38_;
					gchar* _tmp39_;
					const gchar* _tmp40_;
					_tmp27_ = vpn_settings;
					_tmp28_ = network_widgets_vpn_info_dialog_get_service_type (_tmp27_);
					_g_free0 (self->priv->service_type);
					self->priv->service_type = _tmp28_;
					_tmp29_ = self->priv->vpn_type;
					_tmp30_ = self->priv->service_type;
					gtk_label_set_label (_tmp29_, _tmp30_);
					_tmp31_ = self->priv->gateway;
					_tmp32_ = vpn_settings;
					_tmp33_ = network_widgets_vpn_info_dialog_get_key_gateway (self);
					_tmp34_ = _tmp33_;
					_tmp35_ = nm_setting_vpn_get_data_item (_tmp32_, _tmp34_);
					gtk_label_set_label (_tmp31_, _tmp35_);
					_g_free0 (_tmp34_);
					_tmp36_ = self->priv->username;
					_tmp37_ = vpn_settings;
					_tmp38_ = network_widgets_vpn_info_dialog_get_key_group_username (self);
					_tmp39_ = _tmp38_;
					_tmp40_ = nm_setting_vpn_get_data_item (_tmp37_, _tmp39_);
					gtk_label_set_label (_tmp36_, _tmp40_);
					_g_free0 (_tmp39_);
				}
				_g_object_unref0 (vpn_settings);
				break;
			}
		}
	}
	_tmp41_ = self->priv->vpn_type;
	_tmp42_ = self->priv->vpn_type;
	_tmp43_ = gtk_label_get_label (_tmp42_);
	_tmp44_ = _tmp43_;
	gtk_widget_set_visible ((GtkWidget*) _tmp41_, g_strcmp0 (_tmp44_, "") != 0);
	_tmp45_ = self->priv->gateway;
	_tmp46_ = self->priv->gateway;
	_tmp47_ = gtk_label_get_label (_tmp46_);
	_tmp48_ = _tmp47_;
	gtk_widget_set_visible ((GtkWidget*) _tmp45_, g_strcmp0 (_tmp48_, "") != 0);
	_tmp49_ = self->priv->username;
	_tmp50_ = self->priv->username;
	_tmp51_ = gtk_label_get_label (_tmp50_);
	_tmp52_ = _tmp51_;
	gtk_widget_set_visible ((GtkWidget*) _tmp49_, g_strcmp0 (_tmp52_, "") != 0);
}

NMRemoteConnection*
network_widgets_vpn_info_dialog_get_connection (NetworkWidgetsVPNInfoDialog* self)
{
	NMRemoteConnection* result;
	NMRemoteConnection* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_connection;
	result = _tmp0_;
	return result;
}

static void
network_widgets_vpn_info_dialog_set_connection (NetworkWidgetsVPNInfoDialog* self,
                                                NMRemoteConnection* value)
{
	NMRemoteConnection* old_value;
	g_return_if_fail (self != NULL);
	old_value = network_widgets_vpn_info_dialog_get_connection (self);
	if (old_value != value) {
		NMRemoteConnection* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_connection);
		self->priv->_connection = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, network_widgets_vpn_info_dialog_properties[NETWORK_WIDGETS_VPN_INFO_DIALOG_CONNECTION_PROPERTY]);
	}
}

static void
_network_widgets_vpn_info_dialog_update_status_nm_connection_changed (NMConnection* _sender,
                                                                      gpointer self)
{
	network_widgets_vpn_info_dialog_update_status ((NetworkWidgetsVPNInfoDialog*) self);
}

static void
_gtk_window_destroy_gtk_dialog_response (GtkDialog* _sender,
                                         gint response_id,
                                         gpointer self)
{
	gtk_window_destroy ((GtkWindow*) self);
}

static void
_network_widgets_vpn_info_dialog___lambda12_ (NetworkWidgetsVPNInfoDialog* self,
                                              gint response)
{
	GError* _inner_error0_ = NULL;
	if (response == 1) {
		{
			GAppInfo* appinfo = NULL;
			NMRemoteConnection* _tmp0_;
			const gchar* _tmp1_;
			gchar* _tmp2_;
			gchar* _tmp3_;
			GAppInfo* _tmp4_;
			GAppInfo* _tmp5_;
			GAppInfo* _tmp6_;
			_tmp0_ = self->priv->_connection;
			_tmp1_ = nm_connection_get_uuid ((NMConnection*) _tmp0_);
			_tmp2_ = g_strdup_printf ("nm-connection-editor --edit=%s", _tmp1_);
			_tmp3_ = _tmp2_;
			_tmp4_ = g_app_info_create_from_commandline (_tmp3_, NULL, G_APP_INFO_CREATE_NONE, &_inner_error0_);
			_tmp5_ = _tmp4_;
			_g_free0 (_tmp3_);
			appinfo = _tmp5_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp6_ = appinfo;
			g_app_info_launch (_tmp6_, NULL, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (appinfo);
				goto __catch0_g_error;
			}
			_g_object_unref0 (appinfo);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* _error_ = NULL;
			GraniteMessageDialog* dialog = NULL;
			GThemedIcon* _tmp7_;
			GThemedIcon* _tmp8_;
			GThemedIcon* _tmp9_;
			GtkRoot* _tmp10_;
			GtkWindow* _tmp11_;
			GraniteMessageDialog* _tmp12_ = NULL;
			GraniteMessageDialog* _tmp13_;
			GraniteMessageDialog* _tmp14_;
			GError* _tmp15_;
			const gchar* _tmp16_;
			GraniteMessageDialog* _tmp17_;
			GraniteMessageDialog* _tmp18_;
			GraniteMessageDialog* _tmp19_;
			_error_ = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp7_ = (GThemedIcon*) g_themed_icon_new ("network-vpn");
			_tmp8_ = _tmp7_;
			_tmp9_ = (GThemedIcon*) g_themed_icon_new ("dialog-error");
			_tmp10_ = gtk_widget_get_root ((GtkWidget*) self);
			_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_window_get_type (), GtkWindow));
			_tmp12_ = granite_message_dialog_new (_ ("Failed to run Connection Editor"), _ ("The program \"nm-connection-editor\" may not be installed."), (GIcon*) _tmp8_, GTK_BUTTONS_CLOSE);
			granite_message_dialog_set_badge_icon (_tmp12_, (GIcon*) _tmp9_);
			_g_object_unref0 (_tmp9_);
			gtk_window_set_modal ((GtkWindow*) _tmp12_, TRUE);
			gtk_window_set_transient_for ((GtkWindow*) _tmp12_, _tmp11_);
			_g_object_unref0 (_tmp11_);
			g_object_ref_sink (_tmp12_);
			_tmp13_ = _tmp12_;
			_g_object_unref0 (_tmp8_);
			dialog = _tmp13_;
			_tmp14_ = dialog;
			_tmp15_ = _error_;
			_tmp16_ = _tmp15_->message;
			granite_message_dialog_show_error_details (_tmp14_, _tmp16_);
			_tmp17_ = dialog;
			gtk_window_present ((GtkWindow*) _tmp17_);
			_tmp18_ = dialog;
			_tmp19_ = dialog;
			g_signal_connect_object ((GtkDialog*) _tmp18_, "response", (GCallback) _gtk_window_destroy_gtk_dialog_response, (GtkWindow*) _tmp19_, 0);
			_g_object_unref0 (dialog);
			_g_error_free0 (_error_);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	gtk_window_destroy ((GtkWindow*) self);
}

static void
__network_widgets_vpn_info_dialog___lambda12__gtk_dialog_response (GtkDialog* _sender,
                                                                   gint response_id,
                                                                   gpointer self)
{
	_network_widgets_vpn_info_dialog___lambda12_ ((NetworkWidgetsVPNInfoDialog*) self, response_id);
}

static GObject *
network_widgets_vpn_info_dialog_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	NetworkWidgetsVPNInfoDialog * self;
	GtkLabel* _tmp0_ = NULL;
	GtkLabel* _tmp1_ = NULL;
	GtkLabel* _tmp2_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp3_;
	GtkBox* _tmp4_;
	GraniteHeaderLabel* _tmp5_;
	GraniteHeaderLabel* _tmp6_;
	GtkBox* _tmp7_;
	GtkLabel* _tmp8_;
	GtkBox* _tmp9_;
	GraniteHeaderLabel* _tmp10_;
	GraniteHeaderLabel* _tmp11_;
	GtkBox* _tmp12_;
	GtkLabel* _tmp13_;
	GtkBox* _tmp14_;
	GraniteHeaderLabel* _tmp15_;
	GraniteHeaderLabel* _tmp16_;
	GtkBox* _tmp17_;
	GtkLabel* _tmp18_;
	GtkBox* _tmp19_;
	GtkBox* _tmp20_;
	GtkBox* _tmp21_;
	NMRemoteConnection* _tmp22_;
	parent_class = G_OBJECT_CLASS (network_widgets_vpn_info_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NETWORK_WIDGETS_TYPE_VPN_INFO_DIALOG, NetworkWidgetsVPNInfoDialog);
	_tmp0_ = (GtkLabel*) gtk_label_new (NULL);
	gtk_label_set_selectable (_tmp0_, TRUE);
	gtk_label_set_xalign (_tmp0_, (gfloat) 0);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->vpn_type);
	self->priv->vpn_type = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new (NULL);
	gtk_label_set_selectable (_tmp1_, TRUE);
	gtk_label_set_xalign (_tmp1_, (gfloat) 0);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->username);
	self->priv->username = _tmp1_;
	_tmp2_ = (GtkLabel*) gtk_label_new (NULL);
	gtk_label_set_selectable (_tmp2_, TRUE);
	gtk_label_set_xalign (_tmp2_, (gfloat) 0);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->gateway);
	self->priv->gateway = _tmp2_;
	granite_dialog_add_button ((GraniteDialog*) self, _ ("Edit Connection…"), 1);
	granite_dialog_add_button ((GraniteDialog*) self, _ ("Close"), (gint) GTK_RESPONSE_CLOSE);
	_tmp3_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp3_);
	box = _tmp3_;
	_tmp4_ = box;
	_tmp5_ = granite_header_label_new ("VPN Type");
	g_object_ref_sink (_tmp5_);
	_tmp6_ = _tmp5_;
	gtk_box_append (_tmp4_, (GtkWidget*) _tmp6_);
	_g_object_unref0 (_tmp6_);
	_tmp7_ = box;
	_tmp8_ = self->priv->vpn_type;
	gtk_box_append (_tmp7_, (GtkWidget*) _tmp8_);
	_tmp9_ = box;
	_tmp10_ = granite_header_label_new ("Username");
	g_object_ref_sink (_tmp10_);
	_tmp11_ = _tmp10_;
	gtk_box_append (_tmp9_, (GtkWidget*) _tmp11_);
	_g_object_unref0 (_tmp11_);
	_tmp12_ = box;
	_tmp13_ = self->priv->username;
	gtk_box_append (_tmp12_, (GtkWidget*) _tmp13_);
	_tmp14_ = box;
	_tmp15_ = granite_header_label_new ("Gateway");
	g_object_ref_sink (_tmp15_);
	_tmp16_ = _tmp15_;
	gtk_box_append (_tmp14_, (GtkWidget*) _tmp16_);
	_g_object_unref0 (_tmp16_);
	_tmp17_ = box;
	_tmp18_ = self->priv->gateway;
	gtk_box_append (_tmp17_, (GtkWidget*) _tmp18_);
	gtk_window_set_resizable ((GtkWindow*) self, FALSE);
	_tmp19_ = granite_message_dialog_get_custom_bin ((GraniteMessageDialog*) self);
	_tmp20_ = _tmp19_;
	_tmp21_ = box;
	gtk_box_append (_tmp20_, (GtkWidget*) _tmp21_);
	_tmp22_ = self->priv->_connection;
	g_signal_connect_object ((NMConnection*) _tmp22_, "changed", (GCallback) _network_widgets_vpn_info_dialog_update_status_nm_connection_changed, self, 0);
	network_widgets_vpn_info_dialog_update_status (self);
	g_signal_connect_object ((GtkDialog*) self, "response", (GCallback) __network_widgets_vpn_info_dialog___lambda12__gtk_dialog_response, self, 0);
	_g_object_unref0 (box);
	return obj;
}

static void
network_widgets_vpn_info_dialog_class_init (NetworkWidgetsVPNInfoDialogClass * klass,
                                            gpointer klass_data)
{
	network_widgets_vpn_info_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &NetworkWidgetsVPNInfoDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_network_widgets_vpn_info_dialog_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_network_widgets_vpn_info_dialog_set_property;
	G_OBJECT_CLASS (klass)->constructor = network_widgets_vpn_info_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = network_widgets_vpn_info_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), NETWORK_WIDGETS_VPN_INFO_DIALOG_CONNECTION_PROPERTY, network_widgets_vpn_info_dialog_properties[NETWORK_WIDGETS_VPN_INFO_DIALOG_CONNECTION_PROPERTY] = g_param_spec_object ("connection", "connection", "connection", nm_remote_connection_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
network_widgets_vpn_info_dialog_instance_init (NetworkWidgetsVPNInfoDialog * self,
                                               gpointer klass)
{
	self->priv = network_widgets_vpn_info_dialog_get_instance_private (self);
	self->priv->_connection = NULL;
}

static void
network_widgets_vpn_info_dialog_finalize (GObject * obj)
{
	NetworkWidgetsVPNInfoDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NETWORK_WIDGETS_TYPE_VPN_INFO_DIALOG, NetworkWidgetsVPNInfoDialog);
	_g_object_unref0 (self->priv->_connection);
	_g_free0 (self->priv->service_type);
	_g_object_unref0 (self->priv->vpn_type);
	_g_object_unref0 (self->priv->gateway);
	_g_object_unref0 (self->priv->username);
	G_OBJECT_CLASS (network_widgets_vpn_info_dialog_parent_class)->finalize (obj);
}

static GType
network_widgets_vpn_info_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (NetworkWidgetsVPNInfoDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) network_widgets_vpn_info_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NetworkWidgetsVPNInfoDialog), 0, (GInstanceInitFunc) network_widgets_vpn_info_dialog_instance_init, NULL };
	GType network_widgets_vpn_info_dialog_type_id;
	network_widgets_vpn_info_dialog_type_id = g_type_register_static (GRANITE_TYPE_MESSAGE_DIALOG, "NetworkWidgetsVPNInfoDialog", &g_define_type_info, 0);
	NetworkWidgetsVPNInfoDialog_private_offset = g_type_add_instance_private (network_widgets_vpn_info_dialog_type_id, sizeof (NetworkWidgetsVPNInfoDialogPrivate));
	return network_widgets_vpn_info_dialog_type_id;
}

GType
network_widgets_vpn_info_dialog_get_type (void)
{
	static volatile gsize network_widgets_vpn_info_dialog_type_id__once = 0;
	if (g_once_init_enter (&network_widgets_vpn_info_dialog_type_id__once)) {
		GType network_widgets_vpn_info_dialog_type_id;
		network_widgets_vpn_info_dialog_type_id = network_widgets_vpn_info_dialog_get_type_once ();
		g_once_init_leave (&network_widgets_vpn_info_dialog_type_id__once, network_widgets_vpn_info_dialog_type_id);
	}
	return network_widgets_vpn_info_dialog_type_id__once;
}

static void
_vala_network_widgets_vpn_info_dialog_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec)
{
	NetworkWidgetsVPNInfoDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, NETWORK_WIDGETS_TYPE_VPN_INFO_DIALOG, NetworkWidgetsVPNInfoDialog);
	switch (property_id) {
		case NETWORK_WIDGETS_VPN_INFO_DIALOG_CONNECTION_PROPERTY:
		g_value_set_object (value, network_widgets_vpn_info_dialog_get_connection (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_network_widgets_vpn_info_dialog_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec)
{
	NetworkWidgetsVPNInfoDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, NETWORK_WIDGETS_TYPE_VPN_INFO_DIALOG, NetworkWidgetsVPNInfoDialog);
	switch (property_id) {
		case NETWORK_WIDGETS_VPN_INFO_DIALOG_CONNECTION_PROPERTY:
		network_widgets_vpn_info_dialog_set_connection (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize 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,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

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

