/* vnc-display.c generated by valac 0.17.7, the Vala compiler
 * generated from vnc-display.vala, do not modify */

/* This file is part of GNOME Boxes. License: LGPLv2+*/

#include <glib.h>
#include <glib-object.h>
#include <libcommon.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <stdlib.h>
#include <string.h>
#include <gtk-vnc.h>
#include <libxml/uri.h>
#include <glib/gi18n-lib.h>


#define BOXES_TYPE_IPROPERTIES_PROVIDER (boxes_iproperties_provider_get_type ())
#define BOXES_IPROPERTIES_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_IPROPERTIES_PROVIDER, BoxesIPropertiesProvider))
#define BOXES_IS_IPROPERTIES_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_IPROPERTIES_PROVIDER))
#define BOXES_IPROPERTIES_PROVIDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), BOXES_TYPE_IPROPERTIES_PROVIDER, BoxesIPropertiesProviderIface))

typedef struct _BoxesIPropertiesProvider BoxesIPropertiesProvider;
typedef struct _BoxesIPropertiesProviderIface BoxesIPropertiesProviderIface;

#define BOXES_TYPE_PROPERTIES_PAGE (boxes_properties_page_get_type ())

#define BOXES_TYPE_PROPERTY (boxes_property_get_type ())
#define BOXES_PROPERTY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_PROPERTY, BoxesProperty))
#define BOXES_PROPERTY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_PROPERTY, BoxesPropertyClass))
#define BOXES_IS_PROPERTY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_PROPERTY))
#define BOXES_IS_PROPERTY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_PROPERTY))
#define BOXES_PROPERTY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_PROPERTY, BoxesPropertyClass))

typedef struct _BoxesProperty BoxesProperty;
typedef struct _BoxesPropertyClass BoxesPropertyClass;

#define BOXES_TYPE_DISPLAY (boxes_display_get_type ())
#define BOXES_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_DISPLAY, BoxesDisplay))
#define BOXES_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_DISPLAY, BoxesDisplayClass))
#define BOXES_IS_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_DISPLAY))
#define BOXES_IS_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_DISPLAY))
#define BOXES_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_DISPLAY, BoxesDisplayClass))

typedef struct _BoxesDisplay BoxesDisplay;
typedef struct _BoxesDisplayClass BoxesDisplayClass;
typedef struct _BoxesDisplayPrivate BoxesDisplayPrivate;

#define BOXES_TYPE_VNC_DISPLAY (boxes_vnc_display_get_type ())
#define BOXES_VNC_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_VNC_DISPLAY, BoxesVncDisplay))
#define BOXES_VNC_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_VNC_DISPLAY, BoxesVncDisplayClass))
#define BOXES_IS_VNC_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_VNC_DISPLAY))
#define BOXES_IS_VNC_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_VNC_DISPLAY))
#define BOXES_VNC_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_VNC_DISPLAY, BoxesVncDisplayClass))

typedef struct _BoxesVncDisplay BoxesVncDisplay;
typedef struct _BoxesVncDisplayClass BoxesVncDisplayClass;
typedef struct _BoxesVncDisplayPrivate BoxesVncDisplayPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _xmlFreeURI0(var) ((var == NULL) ? NULL : (var = (xmlFreeURI (var), NULL)))
#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))

typedef enum  {
	BOXES_PROPERTIES_PAGE_LOGIN,
	BOXES_PROPERTIES_PAGE_SYSTEM,
	BOXES_PROPERTIES_PAGE_DISPLAY,
	BOXES_PROPERTIES_PAGE_DEVICES,
	BOXES_PROPERTIES_PAGE_LAST
} BoxesPropertiesPage;

struct _BoxesIPropertiesProviderIface {
	GTypeInterface parent_iface;
	GList* (*get_properties) (BoxesIPropertiesProvider* self, BoxesPropertiesPage page);
};

struct _BoxesDisplay {
	BoxesDisplayProperties parent_instance;
	BoxesDisplayPrivate * priv;
	GHashTable* displays;
};

struct _BoxesDisplayClass {
	BoxesDisplayPropertiesClass parent_class;
	GtkWidget* (*get_display) (BoxesDisplay* self, gint n);
	GdkPixbuf* (*get_pixbuf) (BoxesDisplay* self, gint n, GError** error);
	void (*set_enable_inputs) (BoxesDisplay* self, GtkWidget* widget, gboolean enable);
	void (*connect_it) (BoxesDisplay* self, GError** error);
	void (*disconnect_it) (BoxesDisplay* self);
	GList* (*get_properties) (BoxesDisplay* self, BoxesPropertiesPage page);
	const gchar* (*get_protocol) (BoxesDisplay* self);
	gchar* (*get_uri) (BoxesDisplay* self);
};

struct _BoxesVncDisplay {
	BoxesDisplay parent_instance;
	BoxesVncDisplayPrivate * priv;
};

struct _BoxesVncDisplayClass {
	BoxesDisplayClass parent_class;
};

struct _BoxesVncDisplayPrivate {
	VncDisplay* display;
	gchar* host;
	gint port;
	GtkWindow* window;
	BoxesDisplayPropertiesSavedProperty* saved_properties;
	gint saved_properties_length1;
	gint _saved_properties_size_;
	gboolean connected;
};


static gpointer boxes_vnc_display_parent_class = NULL;

GType boxes_properties_page_get_type (void) G_GNUC_CONST;
GType boxes_property_get_type (void) G_GNUC_CONST;
GType boxes_iproperties_provider_get_type (void) G_GNUC_CONST;
GType boxes_display_get_type (void) G_GNUC_CONST;
GType boxes_vnc_display_get_type (void) G_GNUC_CONST;
#define BOXES_VNC_DISPLAY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BOXES_TYPE_VNC_DISPLAY, BoxesVncDisplayPrivate))
enum  {
	BOXES_VNC_DISPLAY_DUMMY_PROPERTY,
	BOXES_VNC_DISPLAY_PROTOCOL,
	BOXES_VNC_DISPLAY_URI
};
static void _vala_BoxesDisplayPropertiesSavedProperty_array_free (BoxesDisplayPropertiesSavedProperty* array, gint array_length);
BoxesVncDisplay* boxes_vnc_display_new (BoxesDisplayConfig* config, const gchar* host, gint port);
BoxesVncDisplay* boxes_vnc_display_construct (GType object_type, BoxesDisplayConfig* config, const gchar* host, gint port);
BoxesDisplay* boxes_display_construct (GType object_type);
BoxesVncDisplay* boxes_vnc_display_new_with_uri (BoxesDisplayConfig* config, const gchar* _uri, GError** error);
BoxesVncDisplay* boxes_vnc_display_construct_with_uri (GType object_type, BoxesDisplayConfig* config, const gchar* _uri, GError** error);
static GtkWidget* boxes_vnc_display_real_get_display (BoxesDisplay* base, gint n);
static void boxes_vnc_display_real_set_enable_inputs (BoxesDisplay* base, GtkWidget* widget, gboolean enable);
static GdkPixbuf* boxes_vnc_display_real_get_pixbuf (BoxesDisplay* base, gint n, GError** error);
static void boxes_vnc_display_real_connect_it (BoxesDisplay* base, GError** error);
const gchar* boxes_display_get_username (BoxesDisplay* self);
const gchar* boxes_display_get_password (BoxesDisplay* self);
static void boxes_vnc_display_real_disconnect_it (BoxesDisplay* base);
static GList* boxes_vnc_display_real_get_properties (BoxesDisplay* base, BoxesPropertiesPage page);
BoxesProperty* boxes_iproperties_provider_add_property (BoxesIPropertiesProvider* self, GList** list, const gchar* name, GtkWidget* widget);
static void _g_object_unref0_ (gpointer var);
static void _g_list_free__g_object_unref0_ (GList* self);
static GObject * boxes_vnc_display_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
void boxes_display_set_need_password (BoxesDisplay* self, gboolean value);
static void _boxes_vnc_display___lambda64_ (BoxesVncDisplay* self);
static void __boxes_vnc_display___lambda64__vnc_display_vnc_initialized (VncDisplay* _sender, gpointer self);
static void _boxes_vnc_display___lambda65_ (BoxesVncDisplay* self);
static void __boxes_vnc_display___lambda65__vnc_display_vnc_disconnected (VncDisplay* _sender, gpointer self);
static void _boxes_vnc_display___lambda66_ (BoxesVncDisplay* self);
static void __boxes_vnc_display___lambda66__vnc_display_vnc_auth_failure (VncDisplay* _sender, const gchar* object, gpointer self);
static void _boxes_vnc_display___lambda67_ (BoxesVncDisplay* self);
static void __boxes_vnc_display___lambda67__vnc_display_vnc_auth_unsupported (VncDisplay* _sender, guint object, gpointer self);
static void _boxes_vnc_display___lambda68_ (BoxesVncDisplay* self, VncDisplay* vnc, GValueArray* creds);
static VncDisplayCredential* _vnc_display_credential_dup (VncDisplayCredential* self);
void boxes_display_set_need_username (BoxesDisplay* self, gboolean value);
const gchar* vnc_display_credential_to_string (VncDisplayCredential self);
static void __boxes_vnc_display___lambda68__vnc_display_vnc_auth_credential (VncDisplay* _sender, GValueArray* credList, gpointer self);
static void _boxes_vnc_display___lambda69_ (BoxesVncDisplay* self);
static void __boxes_vnc_display___lambda69__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void boxes_vnc_display_finalize (GObject* obj);
const gchar* boxes_display_get_protocol (BoxesDisplay* self);
gchar* boxes_display_get_uri (BoxesDisplay* self);
static void _vala_boxes_vnc_display_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);


static void _vala_BoxesDisplayPropertiesSavedProperty_array_free (BoxesDisplayPropertiesSavedProperty* array, gint array_length) {
	if (array != NULL) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			boxes_display_properties_saved_property_destroy (&array[i]);
		}
	}
	g_free (array);
}


BoxesVncDisplay* boxes_vnc_display_construct (GType object_type, BoxesDisplayConfig* config, const gchar* host, gint port) {
	BoxesVncDisplay * self = NULL;
	BoxesDisplayConfig* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gint _tmp3_;
	g_return_val_if_fail (config != NULL, NULL);
	g_return_val_if_fail (host != NULL, NULL);
	self = (BoxesVncDisplay*) boxes_display_construct (object_type);
	_tmp0_ = config;
	boxes_display_properties_set_config ((BoxesDisplayProperties*) self, _tmp0_);
	_tmp1_ = host;
	_tmp2_ = g_strdup (_tmp1_);
	_g_free0 (self->priv->host);
	self->priv->host = _tmp2_;
	_tmp3_ = port;
	self->priv->port = _tmp3_;
	return self;
}


BoxesVncDisplay* boxes_vnc_display_new (BoxesDisplayConfig* config, const gchar* host, gint port) {
	return boxes_vnc_display_construct (BOXES_TYPE_VNC_DISPLAY, config, host, port);
}


BoxesVncDisplay* boxes_vnc_display_construct_with_uri (GType object_type, BoxesDisplayConfig* config, const gchar* _uri, GError** error) {
	BoxesVncDisplay * self = NULL;
	BoxesDisplayConfig* _tmp0_;
	const gchar* _tmp1_;
	xmlURI* _tmp2_ = NULL;
	xmlURI* uri;
	xmlURI* _tmp3_;
	const gchar* _tmp4_;
	xmlURI* _tmp6_;
	const gchar* _tmp7_;
	xmlURI* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gint _tmp12_ = 0;
	xmlURI* _tmp13_;
	gint _tmp14_;
	gint _tmp17_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (config != NULL, NULL);
	g_return_val_if_fail (_uri != NULL, NULL);
	self = (BoxesVncDisplay*) boxes_display_construct (object_type);
	_tmp0_ = config;
	boxes_display_properties_set_config ((BoxesDisplayProperties*) self, _tmp0_);
	_tmp1_ = _uri;
	_tmp2_ = xmlParseURI (_tmp1_);
	uri = _tmp2_;
	_tmp3_ = uri;
	_tmp4_ = _tmp3_->scheme;
	if (g_strcmp0 (_tmp4_, "vnc") != 0) {
		GError* _tmp5_;
		_tmp5_ = g_error_new_literal (BOXES_ERROR, BOXES_ERROR_INVALID, "the URI is not vnc://");
		_inner_error_ = _tmp5_;
		if (_inner_error_->domain == BOXES_ERROR) {
			g_propagate_error (error, _inner_error_);
			_xmlFreeURI0 (uri);
			_g_object_unref0 (self);
			return NULL;
		} else {
			_xmlFreeURI0 (uri);
			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 NULL;
		}
	}
	_tmp6_ = uri;
	_tmp7_ = _tmp6_->server;
	if (_tmp7_ == NULL) {
		GError* _tmp8_;
		_tmp8_ = g_error_new_literal (BOXES_ERROR, BOXES_ERROR_INVALID, "the URI is missing a server");
		_inner_error_ = _tmp8_;
		if (_inner_error_->domain == BOXES_ERROR) {
			g_propagate_error (error, _inner_error_);
			_xmlFreeURI0 (uri);
			_g_object_unref0 (self);
			return NULL;
		} else {
			_xmlFreeURI0 (uri);
			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 NULL;
		}
	}
	_tmp9_ = uri;
	_tmp10_ = _tmp9_->server;
	_tmp11_ = g_strdup (_tmp10_);
	_g_free0 (self->priv->host);
	self->priv->host = _tmp11_;
	_tmp13_ = uri;
	_tmp14_ = _tmp13_->port;
	if (_tmp14_ <= 0) {
		_tmp12_ = 5900;
	} else {
		xmlURI* _tmp15_;
		gint _tmp16_;
		_tmp15_ = uri;
		_tmp16_ = _tmp15_->port;
		_tmp12_ = _tmp16_;
	}
	_tmp17_ = _tmp12_;
	self->priv->port = _tmp17_;
	_xmlFreeURI0 (uri);
	return self;
}


BoxesVncDisplay* boxes_vnc_display_new_with_uri (BoxesDisplayConfig* config, const gchar* _uri, GError** error) {
	return boxes_vnc_display_construct_with_uri (BOXES_TYPE_VNC_DISPLAY, config, _uri, error);
}


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


static GtkWidget* boxes_vnc_display_real_get_display (BoxesDisplay* base, gint n) {
	BoxesVncDisplay * self;
	GtkWidget* result = NULL;
	GtkWindow* _tmp0_;
	VncDisplay* _tmp1_;
	VncDisplay* _tmp2_;
	GtkWidget* _tmp3_;
	self = (BoxesVncDisplay*) base;
	_tmp0_ = self->priv->window;
	_tmp1_ = self->priv->display;
	gtk_container_remove ((GtkContainer*) _tmp0_, (GtkWidget*) _tmp1_);
	_tmp2_ = self->priv->display;
	_tmp3_ = _g_object_ref0 ((GtkWidget*) _tmp2_);
	result = _tmp3_;
	return result;
}


static void boxes_vnc_display_real_set_enable_inputs (BoxesDisplay* base, GtkWidget* widget, gboolean enable) {
	BoxesVncDisplay * self;
	GtkWidget* _tmp0_;
	gboolean _tmp1_;
	self = (BoxesVncDisplay*) base;
	g_return_if_fail (widget != NULL);
	_tmp0_ = widget;
	_tmp1_ = enable;
	vnc_display_set_read_only (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, vnc_display_get_type ()) ? ((VncDisplay*) _tmp0_) : NULL, !_tmp1_);
}


static GdkPixbuf* boxes_vnc_display_real_get_pixbuf (BoxesDisplay* base, gint n, GError** error) {
	BoxesVncDisplay * self;
	GdkPixbuf* result = NULL;
	VncDisplay* _tmp0_;
	GdkPixbuf* _tmp1_ = NULL;
	self = (BoxesVncDisplay*) base;
	_tmp0_ = self->priv->display;
	_tmp1_ = vnc_display_get_pixbuf (_tmp0_);
	result = _tmp1_;
	return result;
}


static void boxes_vnc_display_real_connect_it (BoxesDisplay* base, GError** error) {
	BoxesVncDisplay * self;
	gboolean _tmp0_;
	VncDisplay* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	VncDisplay* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	VncDisplay* _tmp7_;
	VncDisplay* _tmp8_;
	const gchar* _tmp9_;
	gint _tmp10_;
	gchar* _tmp11_ = NULL;
	gchar* _tmp12_;
	self = (BoxesVncDisplay*) base;
	_tmp0_ = self->priv->connected;
	if (_tmp0_) {
		return;
	}
	self->priv->connected = TRUE;
	_tmp1_ = self->priv->display;
	_tmp2_ = boxes_display_get_username ((BoxesDisplay*) self);
	_tmp3_ = _tmp2_;
	vnc_display_set_credential (_tmp1_, (gint) VNC_DISPLAY_CREDENTIAL_USERNAME, _tmp3_);
	_tmp4_ = self->priv->display;
	_tmp5_ = boxes_display_get_password ((BoxesDisplay*) self);
	_tmp6_ = _tmp5_;
	vnc_display_set_credential (_tmp4_, (gint) VNC_DISPLAY_CREDENTIAL_PASSWORD, _tmp6_);
	_tmp7_ = self->priv->display;
	vnc_display_set_credential (_tmp7_, (gint) VNC_DISPLAY_CREDENTIAL_CLIENTNAME, "boxes");
	_tmp8_ = self->priv->display;
	_tmp9_ = self->priv->host;
	_tmp10_ = self->priv->port;
	_tmp11_ = g_strdup_printf ("%i", _tmp10_);
	_tmp12_ = _tmp11_;
	vnc_display_open_host (_tmp8_, _tmp9_, _tmp12_);
	_g_free0 (_tmp12_);
}


static void boxes_vnc_display_real_disconnect_it (BoxesDisplay* base) {
	BoxesVncDisplay * self;
	VncDisplay* _tmp0_;
	gboolean _tmp1_ = FALSE;
	self = (BoxesVncDisplay*) base;
	_tmp0_ = self->priv->display;
	_tmp1_ = vnc_display_is_open (_tmp0_);
	if (_tmp1_) {
		VncDisplay* _tmp2_;
		_tmp2_ = self->priv->display;
		vnc_display_close (_tmp2_);
	}
}


static void _g_object_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}


static void _g_list_free__g_object_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
	g_list_free (self);
}


static GList* boxes_vnc_display_real_get_properties (BoxesDisplay* base, BoxesPropertiesPage page) {
	BoxesVncDisplay * self;
	GList* result = NULL;
	GList* list;
	BoxesPropertiesPage _tmp0_;
	self = (BoxesVncDisplay*) base;
	list = NULL;
	_tmp0_ = page;
	switch (_tmp0_) {
		case BOXES_PROPERTIES_PAGE_DISPLAY:
		{
			GtkSwitch* _tmp1_;
			GtkSwitch* toggle;
			VncDisplay* _tmp2_;
			GtkSwitch* _tmp3_;
			const gchar* _tmp4_ = NULL;
			GtkSwitch* _tmp5_;
			BoxesProperty* _tmp6_ = NULL;
			BoxesProperty* _tmp7_;
			_tmp1_ = (GtkSwitch*) gtk_switch_new ();
			g_object_ref_sink (_tmp1_);
			toggle = _tmp1_;
			_tmp2_ = self->priv->display;
			_tmp3_ = toggle;
			g_object_bind_property_with_closures ((GObject*) _tmp2_, "read-only", (GObject*) _tmp3_, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, NULL)));
			_tmp4_ = _ ("Read-only");
			_tmp5_ = toggle;
			_tmp6_ = boxes_iproperties_provider_add_property ((BoxesIPropertiesProvider*) self, &list, _tmp4_, (GtkWidget*) _tmp5_);
			_tmp7_ = _tmp6_;
			_g_object_unref0 (_tmp7_);
			_g_object_unref0 (toggle);
			break;
		}
		default:
		break;
	}
	result = list;
	return result;
}


static const gchar* boxes_vnc_display_real_get_protocol (BoxesDisplay* base) {
	const gchar* result;
	BoxesVncDisplay* self;
	self = (BoxesVncDisplay*) base;
	result = "VNC";
	return result;
}


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


static gchar* boxes_vnc_display_real_get_uri (BoxesDisplay* base) {
	gchar* result;
	BoxesVncDisplay* self;
	const gchar* _tmp0_;
	const gchar* _tmp1_ = NULL;
	gint _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_;
	self = (BoxesVncDisplay*) base;
	_tmp0_ = self->priv->host;
	_tmp1_ = string_to_string (_tmp0_);
	_tmp2_ = self->priv->port;
	_tmp3_ = g_strdup_printf ("%i", _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strconcat ("vnc://", _tmp1_, ":", _tmp4_, NULL);
	_tmp6_ = _tmp5_;
	_g_free0 (_tmp4_);
	result = _tmp6_;
	return result;
}


static void _boxes_vnc_display___lambda64_ (BoxesVncDisplay* self) {
	g_signal_emit_by_name ((BoxesDisplay*) self, "show", 0);
	boxes_display_properties_access_start ((BoxesDisplayProperties*) self);
}


static void __boxes_vnc_display___lambda64__vnc_display_vnc_initialized (VncDisplay* _sender, gpointer self) {
	_boxes_vnc_display___lambda64_ (self);
}


static void _boxes_vnc_display___lambda65_ (BoxesVncDisplay* self) {
	g_signal_emit_by_name ((BoxesDisplay*) self, "hide", 0);
	boxes_display_properties_access_finish ((BoxesDisplayProperties*) self);
}


static void __boxes_vnc_display___lambda65__vnc_display_vnc_disconnected (VncDisplay* _sender, gpointer self) {
	_boxes_vnc_display___lambda65_ (self);
}


static void _boxes_vnc_display___lambda66_ (BoxesVncDisplay* self) {
	g_debug ("vnc-display.vala:43: auth failure");
}


static void __boxes_vnc_display___lambda66__vnc_display_vnc_auth_failure (VncDisplay* _sender, const gchar* object, gpointer self) {
	_boxes_vnc_display___lambda66_ (self);
}


static void _boxes_vnc_display___lambda67_ (BoxesVncDisplay* self) {
	g_debug ("vnc-display.vala:46: auth unsupported");
}


static void __boxes_vnc_display___lambda67__vnc_display_vnc_auth_unsupported (VncDisplay* _sender, guint object, gpointer self) {
	_boxes_vnc_display___lambda67_ (self);
}


static VncDisplayCredential* _vnc_display_credential_dup (VncDisplayCredential* self) {
	VncDisplayCredential* dup;
	dup = g_new0 (VncDisplayCredential, 1);
	memcpy (dup, self, sizeof (VncDisplayCredential));
	return dup;
}


static gpointer __vnc_display_credential_dup0 (gpointer self) {
	return self ? _vnc_display_credential_dup (self) : NULL;
}


static void _boxes_vnc_display___lambda68_ (BoxesVncDisplay* self, VncDisplay* vnc, GValueArray* creds) {
	GValueArray* _tmp0_;
	VncDisplay* _tmp8_;
	g_return_if_fail (vnc != NULL);
	g_return_if_fail (creds != NULL);
	_tmp0_ = creds;
	{
		GValueArray* cred_collection = NULL;
		guint cred_index = 0U;
		cred_collection = _tmp0_;
		for (cred_index = 0; cred_index < cred_collection->n_values; cred_index = cred_index + 1) {
			GValue cred = {0};
			cred = *g_value_array_get_nth (cred_collection, cred_index);
			{
				GValue _tmp1_;
				VncDisplayCredential* _tmp2_;
				VncDisplayCredential* credential;
				VncDisplayCredential* _tmp3_;
				_tmp1_ = cred;
				_tmp2_ = __vnc_display_credential_dup0 (g_value_get_enum (&_tmp1_));
				credential = _tmp2_;
				_tmp3_ = credential;
				switch (*_tmp3_) {
					case VNC_DISPLAY_CREDENTIAL_USERNAME:
					{
						boxes_display_set_need_username ((BoxesDisplay*) self, TRUE);
						break;
					}
					case VNC_DISPLAY_CREDENTIAL_PASSWORD:
					{
						boxes_display_set_need_password ((BoxesDisplay*) self, TRUE);
						break;
					}
					case VNC_DISPLAY_CREDENTIAL_CLIENTNAME:
					{
						break;
					}
					default:
					{
						VncDisplayCredential* _tmp4_;
						GEnumValue* _tmp5_;
						gchar* _tmp6_ = NULL;
						gchar* _tmp7_;
						_tmp4_ = credential;
						_tmp5_ = g_enum_get_value (g_type_class_ref (vnc_display_credential_get_type ()), *_tmp4_);
						_tmp6_ = g_strdup_printf ("Unsupported credential: %s", (_tmp5_ != NULL) ? _tmp5_->value_name : NULL);
						_tmp7_ = _tmp6_;
						g_debug ("vnc-display.vala:66: %s", _tmp7_);
						_g_free0 (_tmp7_);
						break;
					}
				}
				_g_free0 (credential);
			}
		}
	}
	_tmp8_ = self->priv->display;
	vnc_display_close (_tmp8_);
}


static void __boxes_vnc_display___lambda68__vnc_display_vnc_auth_credential (VncDisplay* _sender, GValueArray* credList, gpointer self) {
	_boxes_vnc_display___lambda68_ (self, _sender, credList);
}


static void _boxes_vnc_display___lambda69_ (BoxesVncDisplay* self) {
	VncDisplay* _tmp0_;
	BoxesDisplayPropertiesSavedProperty* _tmp1_;
	gint _tmp1__length1;
	_tmp0_ = self->priv->display;
	_tmp1_ = self->priv->saved_properties;
	_tmp1__length1 = self->priv->saved_properties_length1;
	boxes_display_properties_sync_config_with_display ((BoxesDisplayProperties*) self, (GObject*) _tmp0_, _tmp1_, _tmp1__length1);
}


static void __boxes_vnc_display___lambda69__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	_boxes_vnc_display___lambda69_ (self);
}


static GObject * boxes_vnc_display_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	BoxesVncDisplay * self;
	gchar* _tmp0_;
	GValue _tmp1_ = {0};
	BoxesDisplayPropertiesSavedProperty _tmp2_ = {0};
	BoxesDisplayPropertiesSavedProperty* _tmp3_ = NULL;
	VncDisplay* _tmp4_;
	VncDisplay* _tmp5_;
	VncDisplay* _tmp6_;
	VncDisplay* _tmp7_;
	VncDisplay* _tmp8_;
	GtkWindow* _tmp9_;
	GtkWindow* _tmp10_;
	VncDisplay* _tmp11_;
	VncDisplay* _tmp12_;
	VncDisplay* _tmp13_;
	VncDisplay* _tmp14_;
	VncDisplay* _tmp15_;
	VncDisplay* _tmp16_;
	VncDisplay* _tmp17_;
	parent_class = G_OBJECT_CLASS (boxes_vnc_display_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_VNC_DISPLAY, BoxesVncDisplay);
	_tmp0_ = g_strdup ("read-only");
	g_value_init (&_tmp1_, G_TYPE_BOOLEAN);
	g_value_set_boolean (&_tmp1_, FALSE);
	memset (&_tmp2_, 0, sizeof (BoxesDisplayPropertiesSavedProperty));
	_g_free0 (_tmp2_.name);
	_tmp2_.name = _tmp0_;
	G_IS_VALUE (&_tmp2_.default_value) ? (g_value_unset (&_tmp2_.default_value), NULL) : NULL;
	_tmp2_.default_value = _tmp1_;
	_tmp3_ = g_new0 (BoxesDisplayPropertiesSavedProperty, 1);
	_tmp3_[0] = _tmp2_;
	self->priv->saved_properties = (_vala_BoxesDisplayPropertiesSavedProperty_array_free (self->priv->saved_properties, self->priv->saved_properties_length1), NULL);
	self->priv->saved_properties = _tmp3_;
	self->priv->saved_properties_length1 = 1;
	self->priv->_saved_properties_size_ = self->priv->saved_properties_length1;
	boxes_display_set_need_password ((BoxesDisplay*) self, FALSE);
	_tmp4_ = (VncDisplay*) vnc_display_new ();
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->display);
	self->priv->display = _tmp4_;
	_tmp5_ = self->priv->display;
	vnc_display_set_keyboard_grab (_tmp5_, TRUE);
	_tmp6_ = self->priv->display;
	vnc_display_set_pointer_grab (_tmp6_, TRUE);
	_tmp7_ = self->priv->display;
	vnc_display_set_force_size (_tmp7_, FALSE);
	_tmp8_ = self->priv->display;
	vnc_display_set_scaling (_tmp8_, TRUE);
	_tmp9_ = (GtkWindow*) gtk_window_new (GTK_WINDOW_TOPLEVEL);
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->window);
	self->priv->window = _tmp9_;
	_tmp10_ = self->priv->window;
	_tmp11_ = self->priv->display;
	gtk_container_add ((GtkContainer*) _tmp10_, (GtkWidget*) _tmp11_);
	_tmp12_ = self->priv->display;
	gtk_widget_realize ((GtkWidget*) _tmp12_);
	_tmp13_ = self->priv->display;
	g_signal_connect_object (_tmp13_, "vnc-initialized", (GCallback) __boxes_vnc_display___lambda64__vnc_display_vnc_initialized, self, 0);
	_tmp14_ = self->priv->display;
	g_signal_connect_object (_tmp14_, "vnc-disconnected", (GCallback) __boxes_vnc_display___lambda65__vnc_display_vnc_disconnected, self, 0);
	_tmp15_ = self->priv->display;
	g_signal_connect_object (_tmp15_, "vnc-auth-failure", (GCallback) __boxes_vnc_display___lambda66__vnc_display_vnc_auth_failure, self, 0);
	_tmp16_ = self->priv->display;
	g_signal_connect_object (_tmp16_, "vnc-auth-unsupported", (GCallback) __boxes_vnc_display___lambda67__vnc_display_vnc_auth_unsupported, self, 0);
	_tmp17_ = self->priv->display;
	g_signal_connect_object (_tmp17_, "vnc-auth-credential", (GCallback) __boxes_vnc_display___lambda68__vnc_display_vnc_auth_credential, self, 0);
	g_signal_connect_object ((GObject*) self, "notify::config", (GCallback) __boxes_vnc_display___lambda69__g_object_notify, self, 0);
	return obj;
}


static void boxes_vnc_display_class_init (BoxesVncDisplayClass * klass) {
	boxes_vnc_display_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (BoxesVncDisplayPrivate));
	BOXES_DISPLAY_CLASS (klass)->get_display = boxes_vnc_display_real_get_display;
	BOXES_DISPLAY_CLASS (klass)->set_enable_inputs = boxes_vnc_display_real_set_enable_inputs;
	BOXES_DISPLAY_CLASS (klass)->get_pixbuf = boxes_vnc_display_real_get_pixbuf;
	BOXES_DISPLAY_CLASS (klass)->connect_it = boxes_vnc_display_real_connect_it;
	BOXES_DISPLAY_CLASS (klass)->disconnect_it = boxes_vnc_display_real_disconnect_it;
	BOXES_DISPLAY_CLASS (klass)->get_properties = boxes_vnc_display_real_get_properties;
	BOXES_DISPLAY_CLASS (klass)->get_protocol = boxes_vnc_display_real_get_protocol;
	BOXES_DISPLAY_CLASS (klass)->get_uri = boxes_vnc_display_real_get_uri;
	G_OBJECT_CLASS (klass)->get_property = _vala_boxes_vnc_display_get_property;
	G_OBJECT_CLASS (klass)->constructor = boxes_vnc_display_constructor;
	G_OBJECT_CLASS (klass)->finalize = boxes_vnc_display_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_VNC_DISPLAY_PROTOCOL, g_param_spec_string ("protocol", "protocol", "protocol", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_VNC_DISPLAY_URI, g_param_spec_string ("uri", "uri", "uri", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void boxes_vnc_display_instance_init (BoxesVncDisplay * self) {
	self->priv = BOXES_VNC_DISPLAY_GET_PRIVATE (self);
}


static void boxes_vnc_display_finalize (GObject* obj) {
	BoxesVncDisplay * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_VNC_DISPLAY, BoxesVncDisplay);
	_g_object_unref0 (self->priv->display);
	_g_free0 (self->priv->host);
	_g_object_unref0 (self->priv->window);
	self->priv->saved_properties = (_vala_BoxesDisplayPropertiesSavedProperty_array_free (self->priv->saved_properties, self->priv->saved_properties_length1), NULL);
	G_OBJECT_CLASS (boxes_vnc_display_parent_class)->finalize (obj);
}


GType boxes_vnc_display_get_type (void) {
	static volatile gsize boxes_vnc_display_type_id__volatile = 0;
	if (g_once_init_enter (&boxes_vnc_display_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (BoxesVncDisplayClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_vnc_display_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesVncDisplay), 0, (GInstanceInitFunc) boxes_vnc_display_instance_init, NULL };
		GType boxes_vnc_display_type_id;
		boxes_vnc_display_type_id = g_type_register_static (BOXES_TYPE_DISPLAY, "BoxesVncDisplay", &g_define_type_info, 0);
		g_once_init_leave (&boxes_vnc_display_type_id__volatile, boxes_vnc_display_type_id);
	}
	return boxes_vnc_display_type_id__volatile;
}


static void _vala_boxes_vnc_display_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	BoxesVncDisplay * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_VNC_DISPLAY, BoxesVncDisplay);
	switch (property_id) {
		case BOXES_VNC_DISPLAY_PROTOCOL:
		g_value_set_string (value, boxes_display_get_protocol ((BoxesDisplay*) self));
		break;
		case BOXES_VNC_DISPLAY_URI:
		g_value_take_string (value, boxes_display_get_uri ((BoxesDisplay*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



