/* vnc-display.c generated by valac 0.17.1.6-d284, 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 <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.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_PAIR (boxes_pair_get_type ())
#define BOXES_PAIR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_PAIR, BoxesPair))
#define BOXES_PAIR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_PAIR, BoxesPairClass))
#define BOXES_IS_PAIR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_PAIR))
#define BOXES_IS_PAIR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_PAIR))
#define BOXES_PAIR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_PAIR, BoxesPairClass))

typedef struct _BoxesPair BoxesPair;
typedef struct _BoxesPairClass BoxesPairClass;

#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 BOXES_DISPLAY_TYPE_SAVED_PROPERTY (boxes_display_saved_property_get_type ())
typedef struct _BoxesDisplaySavedProperty BoxesDisplaySavedProperty;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define BOXES_TYPE_DISPLAY_CONFIG (boxes_display_config_get_type ())
#define BOXES_DISPLAY_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_DISPLAY_CONFIG, BoxesDisplayConfig))
#define BOXES_DISPLAY_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_DISPLAY_CONFIG, BoxesDisplayConfigClass))
#define BOXES_IS_DISPLAY_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_DISPLAY_CONFIG))
#define BOXES_IS_DISPLAY_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_DISPLAY_CONFIG))
#define BOXES_DISPLAY_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_DISPLAY_CONFIG, BoxesDisplayConfigClass))

typedef struct _BoxesDisplayConfig BoxesDisplayConfig;
typedef struct _BoxesDisplayConfigClass BoxesDisplayConfigClass;
#define _xmlFreeURI0(var) ((var == NULL) ? NULL : (var = (xmlFreeURI (var), NULL)))
#define __g_list_free__boxes_pair_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__boxes_pair_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);
};

typedef enum  {
	BOXES_ERROR_INVALID,
	BOXES_ERROR_COMMAND_FAILED
} BoxesError;
#define BOXES_ERROR boxes_error_quark ()
struct _BoxesDisplay {
	GObject parent_instance;
	BoxesDisplayPrivate * priv;
	GHashTable* displays;
};

struct _BoxesDisplayClass {
	GObjectClass parent_class;
	GtkWidget* (*get_display) (BoxesDisplay* self, gint n, GError** error);
	GdkPixbuf* (*get_pixbuf) (BoxesDisplay* self, gint n, GError** error);
	void (*set_enable_inputs) (BoxesDisplay* self, GtkWidget* widget, gboolean enable);
	void (*connect_it) (BoxesDisplay* self);
	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 _BoxesDisplaySavedProperty {
	gchar* name;
	GValue default_value;
};

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


static gpointer boxes_vnc_display_parent_class = NULL;

GType boxes_properties_page_get_type (void) G_GNUC_CONST;
gpointer boxes_pair_ref (gpointer instance);
void boxes_pair_unref (gpointer instance);
GParamSpec* boxes_param_spec_pair (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void boxes_value_set_pair (GValue* value, gpointer v_object);
void boxes_value_take_pair (GValue* value, gpointer v_object);
gpointer boxes_value_get_pair (const GValue* value);
GType boxes_pair_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;
GQuark boxes_error_quark (void);
GType boxes_vnc_display_get_type (void) G_GNUC_CONST;
GType boxes_display_saved_property_get_type (void) G_GNUC_CONST;
BoxesDisplaySavedProperty* boxes_display_saved_property_dup (const BoxesDisplaySavedProperty* self);
void boxes_display_saved_property_free (BoxesDisplaySavedProperty* self);
void boxes_display_saved_property_copy (const BoxesDisplaySavedProperty* self, BoxesDisplaySavedProperty* dest);
void boxes_display_saved_property_destroy (BoxesDisplaySavedProperty* self);
#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_BoxesDisplaySavedProperty_array_free (BoxesDisplaySavedProperty* array, gint array_length);
GType boxes_display_config_get_type (void) G_GNUC_CONST;
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);
void boxes_display_set_config (BoxesDisplay* self, BoxesDisplayConfig* value);
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, GError** error);
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);
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);
void boxes_iproperties_provider_add_property (BoxesIPropertiesProvider* self, GList** list, const gchar* name, GtkWidget* widget);
static void _boxes_pair_unref0_ (gpointer var);
static void _g_list_free__boxes_pair_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___lambda62_ (BoxesVncDisplay* self);
static void __boxes_vnc_display___lambda62__vnc_display_vnc_initialized (VncDisplay* _sender, gpointer self);
static void _boxes_vnc_display___lambda63_ (BoxesVncDisplay* self);
static void __boxes_vnc_display___lambda63__vnc_display_vnc_disconnected (VncDisplay* _sender, gpointer self);
static void _boxes_vnc_display___lambda64_ (BoxesVncDisplay* self);
static void __boxes_vnc_display___lambda64__vnc_display_vnc_auth_failure (VncDisplay* _sender, const gchar* object, gpointer self);
static void _boxes_vnc_display___lambda65_ (BoxesVncDisplay* self);
static void __boxes_vnc_display___lambda65__vnc_display_vnc_auth_unsupported (VncDisplay* _sender, guint object, gpointer self);
static void _boxes_vnc_display___lambda66_ (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___lambda66__vnc_display_vnc_auth_credential (VncDisplay* _sender, GValueArray* credList, gpointer self);
static void _boxes_vnc_display___lambda67_ (BoxesVncDisplay* self);
void boxes_display_sync_config_with_display (BoxesDisplay* self, GObject* display, BoxesDisplaySavedProperty* saved_properties, int saved_properties_length1);
static void __boxes_vnc_display___lambda67__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_BoxesDisplaySavedProperty_array_free (BoxesDisplaySavedProperty* array, gint array_length) {
	if (array != NULL) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			boxes_display_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_set_config ((BoxesDisplay*) 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_set_config ((BoxesDisplay*) 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, GError** error) {
	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 (VNC_IS_DISPLAY (_tmp0_) ? ((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) {
	BoxesVncDisplay * self;
	VncDisplay* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	VncDisplay* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	VncDisplay* _tmp6_;
	VncDisplay* _tmp7_;
	const gchar* _tmp8_;
	gint _tmp9_;
	gchar* _tmp10_ = NULL;
	gchar* _tmp11_;
	self = (BoxesVncDisplay*) base;
	_tmp0_ = self->priv->display;
	_tmp1_ = boxes_display_get_username ((BoxesDisplay*) self);
	_tmp2_ = _tmp1_;
	vnc_display_set_credential (_tmp0_, (gint) VNC_DISPLAY_CREDENTIAL_USERNAME, _tmp2_);
	_tmp3_ = self->priv->display;
	_tmp4_ = boxes_display_get_password ((BoxesDisplay*) self);
	_tmp5_ = _tmp4_;
	vnc_display_set_credential (_tmp3_, (gint) VNC_DISPLAY_CREDENTIAL_PASSWORD, _tmp5_);
	_tmp6_ = self->priv->display;
	vnc_display_set_credential (_tmp6_, (gint) VNC_DISPLAY_CREDENTIAL_CLIENTNAME, "boxes");
	_tmp7_ = self->priv->display;
	_tmp8_ = self->priv->host;
	_tmp9_ = self->priv->port;
	_tmp10_ = g_strdup_printf ("%i", _tmp9_);
	_tmp11_ = _tmp10_;
	vnc_display_open_host (_tmp7_, _tmp8_, _tmp11_);
	_g_free0 (_tmp11_);
}


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 _boxes_pair_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (boxes_pair_unref (var), NULL));
}


static void _g_list_free__boxes_pair_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _boxes_pair_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* _tmp2_;
			GtkSwitch* toggle;
			VncDisplay* _tmp3_;
			GtkSwitch* _tmp4_;
			const gchar* _tmp5_ = NULL;
			GtkSwitch* _tmp6_;
			_tmp1_ = (GtkSwitch*) gtk_switch_new ();
			_tmp2_ = g_object_ref_sink (_tmp1_);
			toggle = _tmp2_;
			_tmp3_ = self->priv->display;
			_tmp4_ = toggle;
			g_object_bind_property_with_closures ((GObject*) _tmp3_, "read-only", (GObject*) _tmp4_, "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)));
			_tmp5_ = _ ("Read-only");
			_tmp6_ = toggle;
			boxes_iproperties_provider_add_property ((BoxesIPropertiesProvider*) self, &list, _tmp5_, (GtkWidget*) _tmp6_);
			_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___lambda62_ (BoxesVncDisplay* self) {
	g_signal_emit_by_name ((BoxesDisplay*) self, "show", 0);
}


static void __boxes_vnc_display___lambda62__vnc_display_vnc_initialized (VncDisplay* _sender, gpointer self) {
	_boxes_vnc_display___lambda62_ (self);
}


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


static void __boxes_vnc_display___lambda63__vnc_display_vnc_disconnected (VncDisplay* _sender, gpointer self) {
	_boxes_vnc_display___lambda63_ (self);
}


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


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


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


static void __boxes_vnc_display___lambda65__vnc_display_vnc_auth_unsupported (VncDisplay* _sender, guint object, gpointer self) {
	_boxes_vnc_display___lambda65_ (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___lambda66_ (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_TYPE_DISPLAY_CREDENTIAL), *_tmp4_);
						_tmp6_ = g_strdup_printf ("Unsupported credential: %s", (_tmp5_ != NULL) ? _tmp5_->value_name : NULL);
						_tmp7_ = _tmp6_;
						g_debug ("vnc-display.vala:63: %s", _tmp7_);
						_g_free0 (_tmp7_);
						break;
					}
				}
				_g_free0 (credential);
			}
		}
	}
	_tmp8_ = self->priv->display;
	vnc_display_close (_tmp8_);
}


static void __boxes_vnc_display___lambda66__vnc_display_vnc_auth_credential (VncDisplay* _sender, GValueArray* credList, gpointer self) {
	_boxes_vnc_display___lambda66_ (self, _sender, credList);
}


static void _boxes_vnc_display___lambda67_ (BoxesVncDisplay* self) {
	VncDisplay* _tmp0_;
	BoxesDisplaySavedProperty* _tmp1_;
	gint _tmp1__length1;
	_tmp0_ = self->priv->display;
	_tmp1_ = self->priv->saved_properties;
	_tmp1__length1 = self->priv->saved_properties_length1;
	boxes_display_sync_config_with_display ((BoxesDisplay*) self, (GObject*) _tmp0_, _tmp1_, _tmp1__length1);
}


static void __boxes_vnc_display___lambda67__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	_boxes_vnc_display___lambda67_ (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};
	BoxesDisplaySavedProperty _tmp2_ = {0};
	BoxesDisplaySavedProperty* _tmp3_ = NULL;
	VncDisplay* _tmp4_;
	VncDisplay* _tmp5_;
	VncDisplay* _tmp6_;
	VncDisplay* _tmp7_;
	VncDisplay* _tmp8_;
	VncDisplay* _tmp9_;
	GtkWindow* _tmp10_;
	GtkWindow* _tmp11_;
	GtkWindow* _tmp12_;
	VncDisplay* _tmp13_;
	VncDisplay* _tmp14_;
	VncDisplay* _tmp15_;
	VncDisplay* _tmp16_;
	VncDisplay* _tmp17_;
	VncDisplay* _tmp18_;
	VncDisplay* _tmp19_;
	parent_class = G_OBJECT_CLASS (boxes_vnc_display_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = BOXES_VNC_DISPLAY (obj);
	_tmp0_ = g_strdup ("read-only");
	g_value_init (&_tmp1_, G_TYPE_BOOLEAN);
	g_value_set_boolean (&_tmp1_, FALSE);
	memset (&_tmp2_, 0, sizeof (BoxesDisplaySavedProperty));
	_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 (BoxesDisplaySavedProperty, 1);
	_tmp3_[0] = _tmp2_;
	self->priv->saved_properties = (_vala_BoxesDisplaySavedProperty_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 ();
	_tmp5_ = g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->display);
	self->priv->display = _tmp5_;
	_tmp6_ = self->priv->display;
	vnc_display_set_keyboard_grab (_tmp6_, TRUE);
	_tmp7_ = self->priv->display;
	vnc_display_set_pointer_grab (_tmp7_, TRUE);
	_tmp8_ = self->priv->display;
	vnc_display_set_force_size (_tmp8_, FALSE);
	_tmp9_ = self->priv->display;
	vnc_display_set_scaling (_tmp9_, TRUE);
	_tmp10_ = (GtkWindow*) gtk_window_new (GTK_WINDOW_TOPLEVEL);
	_tmp11_ = g_object_ref_sink (_tmp10_);
	_g_object_unref0 (self->priv->window);
	self->priv->window = _tmp11_;
	_tmp12_ = self->priv->window;
	_tmp13_ = self->priv->display;
	gtk_container_add ((GtkContainer*) _tmp12_, (GtkWidget*) _tmp13_);
	_tmp14_ = self->priv->display;
	gtk_widget_realize ((GtkWidget*) _tmp14_);
	_tmp15_ = self->priv->display;
	g_signal_connect_object (_tmp15_, "vnc-initialized", (GCallback) __boxes_vnc_display___lambda62__vnc_display_vnc_initialized, self, 0);
	_tmp16_ = self->priv->display;
	g_signal_connect_object (_tmp16_, "vnc-disconnected", (GCallback) __boxes_vnc_display___lambda63__vnc_display_vnc_disconnected, self, 0);
	_tmp17_ = self->priv->display;
	g_signal_connect_object (_tmp17_, "vnc-auth-failure", (GCallback) __boxes_vnc_display___lambda64__vnc_display_vnc_auth_failure, self, 0);
	_tmp18_ = self->priv->display;
	g_signal_connect_object (_tmp18_, "vnc-auth-unsupported", (GCallback) __boxes_vnc_display___lambda65__vnc_display_vnc_auth_unsupported, self, 0);
	_tmp19_ = self->priv->display;
	g_signal_connect_object (_tmp19_, "vnc-auth-credential", (GCallback) __boxes_vnc_display___lambda66__vnc_display_vnc_auth_credential, self, 0);
	g_signal_connect_object ((GObject*) self, "notify::config", (GCallback) __boxes_vnc_display___lambda67__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 = BOXES_VNC_DISPLAY (obj);
	_g_object_unref0 (self->priv->display);
	_g_free0 (self->priv->host);
	_g_object_unref0 (self->priv->window);
	self->priv->saved_properties = (_vala_BoxesDisplaySavedProperty_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 = BOXES_VNC_DISPLAY (object);
	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;
	}
}



