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

#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <adwaita.h>
#include <gdk/gdk.h>
#include <libsoup/soup.h>
#include <gobject/gvaluecollector.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TUBA_UTILS_TYPE_HOST (tuba_utils_host_get_type ())
#define TUBA_UTILS_HOST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_UTILS_TYPE_HOST, TubaUtilsHost))
#define TUBA_UTILS_HOST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_UTILS_TYPE_HOST, TubaUtilsHostClass))
#define TUBA_UTILS_IS_HOST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_UTILS_TYPE_HOST))
#define TUBA_UTILS_IS_HOST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_UTILS_TYPE_HOST))
#define TUBA_UTILS_HOST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_UTILS_TYPE_HOST, TubaUtilsHostClass))

typedef struct _TubaUtilsHost TubaUtilsHost;
typedef struct _TubaUtilsHostClass TubaUtilsHostClass;
typedef struct _TubaUtilsHostPrivate TubaUtilsHostPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

#define TUBA_TYPE_SETTINGS (tuba_settings_get_type ())
#define TUBA_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_SETTINGS, TubaSettings))
#define TUBA_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_TYPE_SETTINGS, TubaSettingsClass))
#define TUBA_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_SETTINGS))
#define TUBA_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_TYPE_SETTINGS))
#define TUBA_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_TYPE_SETTINGS, TubaSettingsClass))

typedef struct _TubaSettings TubaSettings;
typedef struct _TubaSettingsClass TubaSettingsClass;
typedef struct _TubaUtilsHostOpenUrlData TubaUtilsHostOpenUrlData;
#define _g_uri_unref0(var) ((var == NULL) ? NULL : (var = (g_uri_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _TubaUtilsHostOpenUriData TubaUtilsHostOpenUriData;

#define TUBA_TYPE_APPLICATION (tuba_application_get_type ())
#define TUBA_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_APPLICATION, TubaApplication))
#define TUBA_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_TYPE_APPLICATION, TubaApplicationClass))
#define TUBA_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_APPLICATION))
#define TUBA_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_TYPE_APPLICATION))
#define TUBA_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_TYPE_APPLICATION, TubaApplicationClass))

typedef struct _TubaApplication TubaApplication;
typedef struct _TubaApplicationClass TubaApplicationClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _TubaUtilsHostOpenInDefaultAppData TubaUtilsHostOpenInDefaultAppData;
typedef struct _TubaUtilsHostOpenInDefaultAppUsingDbusData TubaUtilsHostOpenInDefaultAppUsingDbusData;
typedef struct _TubaUtilsHostOpenContainingFolderData TubaUtilsHostOpenContainingFolderData;

#define TUBA_TYPE_REQUEST_V2 (tuba_request_v2_get_type ())
#define TUBA_REQUEST_V2(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_REQUEST_V2, TubaRequestV2))
#define TUBA_REQUEST_V2_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_TYPE_REQUEST_V2, TubaRequestV2Class))
#define TUBA_IS_REQUEST_V2(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_REQUEST_V2))
#define TUBA_IS_REQUEST_V2_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_TYPE_REQUEST_V2))
#define TUBA_REQUEST_V2_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_TYPE_REQUEST_V2, TubaRequestV2Class))

typedef struct _TubaRequestV2 TubaRequestV2;
typedef struct _TubaRequestV2Class TubaRequestV2Class;
typedef enum  {
	TUBA_REQUEST_V2_METHOD_GET,
	TUBA_REQUEST_V2_METHOD_POST,
	TUBA_REQUEST_V2_METHOD_PUT,
	TUBA_REQUEST_V2_METHOD_DELETE,
	TUBA_REQUEST_V2_METHOD_PATCH
} TubaRequestV2Method;

#define TUBA_REQUEST_V2_TYPE_METHOD (tuba_request_v2_method_get_type ())

#define TUBA_TYPE_OOPSIE (tuba_oopsie_get_type ())
typedef struct _TubaUtilsHostDownloadData TubaUtilsHostDownloadData;
typedef struct _TubaUtilsParamSpecHost TubaUtilsParamSpecHost;

struct _TubaUtilsHost {
	GTypeInstance parent_instance;
	volatile int ref_count;
	TubaUtilsHostPrivate * priv;
};

struct _TubaUtilsHostClass {
	GTypeClass parent_class;
	void (*finalize) (TubaUtilsHost *self);
};

struct _TubaUtilsHostOpenUrlData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gchar* _uri;
	gboolean result;
	gchar* uri;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	TubaSettings* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
};

struct _TubaUtilsHostOpenUriData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GUri* uri;
	gboolean result;
	gchar* url;
	GUri* _tmp0_;
	GUri* _tmp1_;
	gchar* _tmp2_;
	GError* e;
	GError* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	GError* _inner_error0_;
};

struct _TubaUtilsHostOpenInDefaultAppData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gchar* uri;
	gboolean result;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GtkUriLauncher* _tmp3_;
	GtkUriLauncher* _tmp4_;
	TubaApplication* _tmp5_;
	GtkWindow* _tmp6_;
	GtkWindow* _tmp7_;
	GError* e;
	const gchar* _tmp8_;
	GError* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	GError* _inner_error0_;
};

struct _TubaUtilsHostOpenInDefaultAppUsingDbusData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gchar* uri;
	gboolean result;
	GError* e;
	const gchar* _tmp0_;
	GError* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GError* _inner_error0_;
};

struct _TubaUtilsHostOpenContainingFolderData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gchar* path;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GFile* _tmp3_;
	GFile* _tmp4_;
	GtkFileLauncher* _tmp5_;
	GtkFileLauncher* _tmp6_;
	TubaApplication* _tmp7_;
	GtkWindow* _tmp8_;
	GtkWindow* _tmp9_;
	GError* e;
	const gchar* _tmp10_;
	GError* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	GError* _inner_error0_;
};

typedef enum  {
	TUBA_OOPSIE_USER,
	TUBA_OOPSIE_PARSING,
	TUBA_OOPSIE_INSTANCE,
	TUBA_OOPSIE_INTERNAL,
	TUBA_OOPSIE_HTTP_401 = 401,
	TUBA_OOPSIE_HTTP_403 = 403,
	TUBA_OOPSIE_HTTP_404 = 404,
	TUBA_OOPSIE_HTTP_410 = 410,
	TUBA_OOPSIE_HTTP_422 = 422,
	TUBA_OOPSIE_HTTP_429 = 429,
	TUBA_OOPSIE_HTTP_500 = 500,
	TUBA_OOPSIE_HTTP_503 = 503
} TubaOopsie;
#define TUBA_OOPSIE tuba_oopsie_quark ()

struct _TubaUtilsHostDownloadData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gchar* url;
	gchar* result;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* file_name;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* dir_name;
	gchar* _tmp7_;
	gchar* dir_path;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* file_path;
	const gchar* _tmp10_;
	GHashFunc _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	GFile* dir;
	const gchar* _tmp20_;
	GFile* _tmp21_;
	GFile* _tmp22_;
	GFile* _tmp23_;
	GFile* file;
	const gchar* _tmp24_;
	GFile* _tmp25_;
	GFile* _tmp26_;
	TubaRequestV2* msg;
	TubaRequestV2* _tmp27_;
	GInputStream* in_stream;
	TubaRequestV2* _tmp28_;
	GInputStream* _tmp29_;
	GInputStream* data;
	GInputStream* _tmp30_;
	GInputStream* _tmp31_;
	GFileOutputStream* stream;
	GFile* _tmp32_;
	GFileOutputStream* _tmp33_;
	GFileOutputStream* _tmp34_;
	GInputStream* _tmp35_;
	const gchar* _tmp36_;
	const gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	GError* _inner_error0_;
};

struct _TubaUtilsParamSpecHost {
	GParamSpec parent_instance;
};

static gpointer tuba_utils_host_parent_class = NULL;
VALA_EXTERN TubaSettings* tuba_settings;
VALA_EXTERN TubaApplication* tuba_app;
VALA_EXTERN gchar* tuba_cache_path;

VALA_EXTERN gpointer tuba_utils_host_ref (gpointer instance);
VALA_EXTERN void tuba_utils_host_unref (gpointer instance);
VALA_EXTERN GParamSpec* tuba_utils_param_spec_host (const gchar* name,
                                        const gchar* nick,
                                        const gchar* blurb,
                                        GType object_type,
                                        GParamFlags flags);
VALA_EXTERN void tuba_utils_value_set_host (GValue* value,
                                gpointer v_object);
VALA_EXTERN void tuba_utils_value_take_host (GValue* value,
                                 gpointer v_object);
VALA_EXTERN gpointer tuba_utils_value_get_host (const GValue* value);
VALA_EXTERN GType tuba_utils_host_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaUtilsHost, tuba_utils_host_unref)
static void tuba_utils_host_open_url_data_free (gpointer _data);
VALA_EXTERN void tuba_utils_host_open_url (const gchar* _uri,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_);
VALA_EXTERN gboolean tuba_utils_host_open_url_finish (GAsyncResult* _res_);
static gboolean tuba_utils_host_open_url_co (TubaUtilsHostOpenUrlData* _data_);
VALA_EXTERN GType tuba_settings_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaSettings, g_object_unref)
VALA_EXTERN gboolean tuba_settings_get_strip_tracking (TubaSettings* self);
VALA_EXTERN gchar* tuba_utils_tracking_strip_utm (const gchar* url);
static void tuba_utils_host_open_in_default_app (const gchar* uri,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
static gboolean tuba_utils_host_open_in_default_app_finish (GAsyncResult* _res_);
static void tuba_utils_host_open_url_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_);
static void tuba_utils_host_open_uri_data_free (gpointer _data);
VALA_EXTERN void tuba_utils_host_open_uri (GUri* uri,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_);
VALA_EXTERN gboolean tuba_utils_host_open_uri_finish (GAsyncResult* _res_);
static gboolean tuba_utils_host_open_uri_co (TubaUtilsHostOpenUriData* _data_);
VALA_EXTERN GUri* tuba_utils_tracking_strip_utm_from_uri (GUri* uri,
                                              GError** error);
static void tuba_utils_host_open_uri_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_);
static void tuba_utils_host_open_in_default_app_data_free (gpointer _data);
static gboolean tuba_utils_host_open_in_default_app_co (TubaUtilsHostOpenInDefaultAppData* _data_);
VALA_EXTERN GType tuba_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaApplication, g_object_unref)
static void tuba_utils_host_open_in_default_app_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_);
static void tuba_utils_host_open_in_default_app_using_dbus (const gchar* uri,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
static gboolean tuba_utils_host_open_in_default_app_using_dbus_finish (GAsyncResult* _res_);
static void tuba_utils_host_open_in_default_app_using_dbus_data_free (gpointer _data);
static gboolean tuba_utils_host_open_in_default_app_using_dbus_co (TubaUtilsHostOpenInDefaultAppUsingDbusData* _data_);
static void tuba_utils_host_open_in_default_app_using_dbus_ready (GObject* source_object,
                                                           GAsyncResult* _res_,
                                                           gpointer _user_data_);
static void tuba_utils_host_open_containing_folder_data_free (gpointer _data);
VALA_EXTERN void tuba_utils_host_open_containing_folder (const gchar* path,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
VALA_EXTERN void tuba_utils_host_open_containing_folder_finish (GAsyncResult* _res_);
static gboolean tuba_utils_host_open_containing_folder_co (TubaUtilsHostOpenContainingFolderData* _data_);
static void tuba_utils_host_open_containing_folder_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
VALA_EXTERN void tuba_utils_host_copy (const gchar* str);
static void tuba_utils_host_download_data_free (gpointer _data);
VALA_EXTERN void tuba_utils_host_download (const gchar* url,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_);
VALA_EXTERN gchar* tuba_utils_host_download_finish (GAsyncResult* _res_,
                                        GError** error);
static gboolean tuba_utils_host_download_co (TubaUtilsHostDownloadData* _data_);
VALA_EXTERN GType tuba_request_v2_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaRequestV2, g_object_unref)
VALA_EXTERN GType tuba_request_v2_method_get_type (void) G_GNUC_CONST ;
VALA_EXTERN TubaRequestV2* tuba_request_v2_new (const gchar* url,
                                    TubaRequestV2Method method);
VALA_EXTERN TubaRequestV2* tuba_request_v2_construct (GType object_type,
                                          const gchar* url,
                                          TubaRequestV2Method method);
VALA_EXTERN void tuba_request_v2_set_cache (TubaRequestV2* self,
                                gboolean value);
VALA_EXTERN void tuba_request_v2_exec (TubaRequestV2* self,
                           GAsyncReadyCallback _callback_,
                           gpointer _user_data_);
VALA_EXTERN GQuark tuba_oopsie_quark (void);
VALA_EXTERN GType tuba_oopsie_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GInputStream* tuba_request_v2_exec_finish (TubaRequestV2* self,
                                           GAsyncResult* _res_,
                                           SoupMessageHeaders** response_headers,
                                           GError** error);
static void tuba_utils_host_download_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_);
VALA_EXTERN TubaUtilsHost* tuba_utils_host_new (void);
VALA_EXTERN TubaUtilsHost* tuba_utils_host_construct (GType object_type);
static void tuba_utils_host_finalize (TubaUtilsHost * obj);
static GType tuba_utils_host_get_type_once (void);

static void
tuba_utils_host_open_url_data_free (gpointer _data)
{
	TubaUtilsHostOpenUrlData* _data_;
	_data_ = _data;
	_g_free0 (_data_->_uri);
	g_slice_free (TubaUtilsHostOpenUrlData, _data_);
}

void
tuba_utils_host_open_url (const gchar* _uri,
                          GAsyncReadyCallback _callback_,
                          gpointer _user_data_)
{
	TubaUtilsHostOpenUrlData* _data_;
	gchar* _tmp0_;
	g_return_if_fail (_uri != NULL);
	_data_ = g_slice_new0 (TubaUtilsHostOpenUrlData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, tuba_utils_host_open_url_data_free);
	_tmp0_ = g_strdup (_uri);
	_g_free0 (_data_->_uri);
	_data_->_uri = _tmp0_;
	tuba_utils_host_open_url_co (_data_);
}

gboolean
tuba_utils_host_open_url_finish (GAsyncResult* _res_)
{
	gboolean result;
	TubaUtilsHostOpenUrlData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static void
tuba_utils_host_open_url_ready (GObject* source_object,
                                GAsyncResult* _res_,
                                gpointer _user_data_)
{
	TubaUtilsHostOpenUrlData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	tuba_utils_host_open_url_co (_data_);
}

static gboolean
tuba_utils_host_open_url_co (TubaUtilsHostOpenUrlData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_strdup (_data_->_uri);
	_data_->uri = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->uri;
	if (!string_contains (_data_->_tmp1_, "://")) {
		_data_->_tmp2_ = g_strconcat ("file://", _data_->_uri, NULL);
		_g_free0 (_data_->uri);
		_data_->uri = _data_->_tmp2_;
	}
	_data_->_tmp3_ = tuba_settings;
	_data_->_tmp4_ = tuba_settings_get_strip_tracking (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	if (_data_->_tmp5_) {
		_data_->_tmp6_ = _data_->uri;
		_data_->_tmp7_ = tuba_utils_tracking_strip_utm (_data_->_tmp6_);
		_g_free0 (_data_->uri);
		_data_->uri = _data_->_tmp7_;
	}
	_data_->_tmp8_ = _data_->uri;
	_data_->_state_ = 1;
	tuba_utils_host_open_in_default_app (_data_->_tmp8_, tuba_utils_host_open_url_ready, _data_);
	return FALSE;
	_state_1:
	_data_->result = tuba_utils_host_open_in_default_app_finish (_data_->_res_);
	_g_free0 (_data_->uri);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
tuba_utils_host_open_uri_data_free (gpointer _data)
{
	TubaUtilsHostOpenUriData* _data_;
	_data_ = _data;
	_g_uri_unref0 (_data_->uri);
	g_slice_free (TubaUtilsHostOpenUriData, _data_);
}

static gpointer
_g_uri_ref0 (gpointer self)
{
	return self ? g_uri_ref (self) : NULL;
}

void
tuba_utils_host_open_uri (GUri* uri,
                          GAsyncReadyCallback _callback_,
                          gpointer _user_data_)
{
	TubaUtilsHostOpenUriData* _data_;
	GUri* _tmp0_;
	g_return_if_fail (uri != NULL);
	_data_ = g_slice_new0 (TubaUtilsHostOpenUriData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, tuba_utils_host_open_uri_data_free);
	_tmp0_ = _g_uri_ref0 (uri);
	_g_uri_unref0 (_data_->uri);
	_data_->uri = _tmp0_;
	tuba_utils_host_open_uri_co (_data_);
}

gboolean
tuba_utils_host_open_uri_finish (GAsyncResult* _res_)
{
	gboolean result;
	TubaUtilsHostOpenUriData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static void
tuba_utils_host_open_uri_ready (GObject* source_object,
                                GAsyncResult* _res_,
                                gpointer _user_data_)
{
	TubaUtilsHostOpenUriData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	tuba_utils_host_open_uri_co (_data_);
}

static gboolean
tuba_utils_host_open_uri_co (TubaUtilsHostOpenUriData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp1_ = tuba_utils_tracking_strip_utm_from_uri (_data_->uri, &_data_->_inner_error0_);
		_data_->_tmp0_ = _data_->_tmp1_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp2_ = g_uri_to_string (_data_->_tmp0_);
		_g_free0 (_data_->url);
		_data_->url = _data_->_tmp2_;
		_g_uri_unref0 (_data_->_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp3_ = _data_->e;
		_data_->_tmp4_ = _data_->_tmp3_->message;
		_data_->_tmp5_ = string_to_string (_data_->_tmp4_);
		_data_->_tmp6_ = g_strconcat ("Error while stripping tracking params: ", _data_->_tmp5_, NULL);
		_data_->_tmp7_ = _data_->_tmp6_;
		g_warning ("Host.vala:22: %s", _data_->_tmp7_);
		_g_free0 (_data_->_tmp7_);
		_data_->_tmp8_ = g_uri_to_string (_data_->uri);
		_g_free0 (_data_->url);
		_data_->url = _data_->_tmp8_;
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->url);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp9_ = _data_->url;
	_data_->_state_ = 1;
	tuba_utils_host_open_in_default_app (_data_->_tmp9_, tuba_utils_host_open_uri_ready, _data_);
	return FALSE;
	_state_1:
	_data_->result = tuba_utils_host_open_in_default_app_finish (_data_->_res_);
	_g_free0 (_data_->url);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
tuba_utils_host_open_in_default_app_data_free (gpointer _data)
{
	TubaUtilsHostOpenInDefaultAppData* _data_;
	_data_ = _data;
	_g_free0 (_data_->uri);
	g_slice_free (TubaUtilsHostOpenInDefaultAppData, _data_);
}

static void
tuba_utils_host_open_in_default_app (const gchar* uri,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	TubaUtilsHostOpenInDefaultAppData* _data_;
	gchar* _tmp0_;
	g_return_if_fail (uri != NULL);
	_data_ = g_slice_new0 (TubaUtilsHostOpenInDefaultAppData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, tuba_utils_host_open_in_default_app_data_free);
	_tmp0_ = g_strdup (uri);
	_g_free0 (_data_->uri);
	_data_->uri = _tmp0_;
	tuba_utils_host_open_in_default_app_co (_data_);
}

static gboolean
tuba_utils_host_open_in_default_app_finish (GAsyncResult* _res_)
{
	gboolean result;
	TubaUtilsHostOpenInDefaultAppData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
tuba_utils_host_open_in_default_app_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_)
{
	TubaUtilsHostOpenInDefaultAppData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	tuba_utils_host_open_in_default_app_co (_data_);
}

static gboolean
tuba_utils_host_open_in_default_app_co (TubaUtilsHostOpenInDefaultAppData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = string_to_string (_data_->uri);
	_data_->_tmp1_ = g_strconcat ("Opening URI: ", _data_->_tmp0_, NULL);
	_data_->_tmp2_ = _data_->_tmp1_;
	g_debug ("Host.vala:29: %s", _data_->_tmp2_);
	_g_free0 (_data_->_tmp2_);
	{
		_data_->_tmp3_ = gtk_uri_launcher_new (_data_->uri);
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = tuba_app;
		_data_->_tmp6_ = gtk_application_get_active_window ((GtkApplication*) _data_->_tmp5_);
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_state_ = 1;
		gtk_uri_launcher_launch (_data_->_tmp4_, _data_->_tmp7_, NULL, tuba_utils_host_open_in_default_app_ready, _data_);
		return FALSE;
		_state_1:
		gtk_uri_launcher_launch_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp4_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp8_ = string_to_string (_data_->uri);
		_data_->_tmp9_ = _data_->e;
		_data_->_tmp10_ = _data_->_tmp9_->message;
		_data_->_tmp11_ = string_to_string (_data_->_tmp10_);
		_data_->_tmp12_ = g_strconcat ("Error opening uri \"", _data_->_tmp8_, "\": ", _data_->_tmp11_, NULL);
		_data_->_tmp13_ = _data_->_tmp12_;
		g_warning ("Host.vala:34: %s", _data_->_tmp13_);
		_g_free0 (_data_->_tmp13_);
		_data_->_state_ = 2;
		tuba_utils_host_open_in_default_app_using_dbus (_data_->uri, tuba_utils_host_open_in_default_app_ready, _data_);
		return FALSE;
		_state_2:
		_data_->result = tuba_utils_host_open_in_default_app_using_dbus_finish (_data_->_res_);
		_g_error_free0 (_data_->e);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = TRUE;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
tuba_utils_host_open_in_default_app_using_dbus_data_free (gpointer _data)
{
	TubaUtilsHostOpenInDefaultAppUsingDbusData* _data_;
	_data_ = _data;
	_g_free0 (_data_->uri);
	g_slice_free (TubaUtilsHostOpenInDefaultAppUsingDbusData, _data_);
}

static void
tuba_utils_host_open_in_default_app_using_dbus (const gchar* uri,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	TubaUtilsHostOpenInDefaultAppUsingDbusData* _data_;
	gchar* _tmp0_;
	g_return_if_fail (uri != NULL);
	_data_ = g_slice_new0 (TubaUtilsHostOpenInDefaultAppUsingDbusData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, tuba_utils_host_open_in_default_app_using_dbus_data_free);
	_tmp0_ = g_strdup (uri);
	_g_free0 (_data_->uri);
	_data_->uri = _tmp0_;
	tuba_utils_host_open_in_default_app_using_dbus_co (_data_);
}

static gboolean
tuba_utils_host_open_in_default_app_using_dbus_finish (GAsyncResult* _res_)
{
	gboolean result;
	TubaUtilsHostOpenInDefaultAppUsingDbusData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
tuba_utils_host_open_in_default_app_using_dbus_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_)
{
	TubaUtilsHostOpenInDefaultAppUsingDbusData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	tuba_utils_host_open_in_default_app_using_dbus_co (_data_);
}

static gboolean
tuba_utils_host_open_in_default_app_using_dbus_co (TubaUtilsHostOpenInDefaultAppUsingDbusData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_state_ = 1;
		g_app_info_launch_default_for_uri_async (_data_->uri, NULL, NULL, tuba_utils_host_open_in_default_app_using_dbus_ready, _data_);
		return FALSE;
		_state_1:
		g_app_info_launch_default_for_uri_finish (_data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp0_ = string_to_string (_data_->uri);
		_data_->_tmp1_ = _data_->e;
		_data_->_tmp2_ = _data_->_tmp1_->message;
		_data_->_tmp3_ = string_to_string (_data_->_tmp2_);
		_data_->_tmp4_ = g_strconcat ("Error opening using launch_default_for_uri \"", _data_->_tmp0_, "\": ", _data_->_tmp3_, NULL);
		_data_->_tmp5_ = _data_->_tmp4_;
		g_warning ("Host.vala:45: %s", _data_->_tmp5_);
		_g_free0 (_data_->_tmp5_);
		_data_->result = FALSE;
		_g_error_free0 (_data_->e);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = TRUE;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
tuba_utils_host_open_containing_folder_data_free (gpointer _data)
{
	TubaUtilsHostOpenContainingFolderData* _data_;
	_data_ = _data;
	_g_free0 (_data_->path);
	g_slice_free (TubaUtilsHostOpenContainingFolderData, _data_);
}

void
tuba_utils_host_open_containing_folder (const gchar* path,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_)
{
	TubaUtilsHostOpenContainingFolderData* _data_;
	gchar* _tmp0_;
	g_return_if_fail (path != NULL);
	_data_ = g_slice_new0 (TubaUtilsHostOpenContainingFolderData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, tuba_utils_host_open_containing_folder_data_free);
	_tmp0_ = g_strdup (path);
	_g_free0 (_data_->path);
	_data_->path = _tmp0_;
	tuba_utils_host_open_containing_folder_co (_data_);
}

void
tuba_utils_host_open_containing_folder_finish (GAsyncResult* _res_)
{
	TubaUtilsHostOpenContainingFolderData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
tuba_utils_host_open_containing_folder_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	TubaUtilsHostOpenContainingFolderData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	tuba_utils_host_open_containing_folder_co (_data_);
}

static gboolean
tuba_utils_host_open_containing_folder_co (TubaUtilsHostOpenContainingFolderData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = string_to_string (_data_->path);
	_data_->_tmp1_ = g_strconcat ("Opening containing folder for ", _data_->_tmp0_, NULL);
	_data_->_tmp2_ = _data_->_tmp1_;
	g_debug ("Host.vala:53: %s", _data_->_tmp2_);
	_g_free0 (_data_->_tmp2_);
	{
		_data_->_tmp3_ = g_file_new_for_path (_data_->path);
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = gtk_file_launcher_new (_data_->_tmp4_);
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_tmp7_ = tuba_app;
		_data_->_tmp8_ = gtk_application_get_active_window ((GtkApplication*) _data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_state_ = 1;
		gtk_file_launcher_open_containing_folder (_data_->_tmp6_, _data_->_tmp9_, NULL, tuba_utils_host_open_containing_folder_ready, _data_);
		return FALSE;
		_state_1:
		gtk_file_launcher_open_containing_folder_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp6_);
		_g_object_unref0 (_data_->_tmp4_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp10_ = string_to_string (_data_->path);
		_data_->_tmp11_ = _data_->e;
		_data_->_tmp12_ = _data_->_tmp11_->message;
		_data_->_tmp13_ = string_to_string (_data_->_tmp12_);
		_data_->_tmp14_ = g_strconcat ("Error opening containing folder for \"", _data_->_tmp10_, "\": ", _data_->_tmp13_, NULL);
		_data_->_tmp15_ = _data_->_tmp14_;
		g_warning ("Host.vala:58: %s", _data_->_tmp15_);
		_g_free0 (_data_->_tmp15_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

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

void
tuba_utils_host_copy (const gchar* str)
{
	GdkDisplay* display = NULL;
	GdkDisplay* _tmp0_;
	GdkDisplay* _tmp1_;
	GdkDisplay* _tmp2_;
	GdkDisplay* _tmp3_;
	GdkClipboard* _tmp4_;
	g_return_if_fail (str != NULL);
	_tmp0_ = gdk_display_get_default ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	display = _tmp1_;
	_tmp2_ = display;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (display);
		return;
	}
	_tmp3_ = display;
	_tmp4_ = gdk_display_get_clipboard (_tmp3_);
	gdk_clipboard_set_text (_tmp4_, str);
	_g_object_unref0 (display);
}

static void
tuba_utils_host_download_data_free (gpointer _data)
{
	TubaUtilsHostDownloadData* _data_;
	_data_ = _data;
	_g_free0 (_data_->url);
	_g_free0 (_data_->result);
	g_slice_free (TubaUtilsHostDownloadData, _data_);
}

void
tuba_utils_host_download (const gchar* url,
                          GAsyncReadyCallback _callback_,
                          gpointer _user_data_)
{
	TubaUtilsHostDownloadData* _data_;
	gchar* _tmp0_;
	g_return_if_fail (url != NULL);
	_data_ = g_slice_new0 (TubaUtilsHostDownloadData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, tuba_utils_host_download_data_free);
	_tmp0_ = g_strdup (url);
	_g_free0 (_data_->url);
	_data_->url = _tmp0_;
	tuba_utils_host_download_co (_data_);
}

gchar*
tuba_utils_host_download_finish (GAsyncResult* _res_,
                                 GError** error)
{
	gchar* result;
	TubaUtilsHostDownloadData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
tuba_utils_host_download_ready (GObject* source_object,
                                GAsyncResult* _res_,
                                gpointer _user_data_)
{
	TubaUtilsHostDownloadData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	tuba_utils_host_download_co (_data_);
}

static gboolean
tuba_utils_host_download_co (TubaUtilsHostDownloadData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = string_to_string (_data_->url);
	_data_->_tmp1_ = g_strconcat ("Downloading file: ", _data_->_tmp0_, "…", NULL);
	_data_->_tmp2_ = _data_->_tmp1_;
	g_debug ("Host.vala:70: %s", _data_->_tmp2_);
	_g_free0 (_data_->_tmp2_);
	_data_->_tmp3_ = g_path_get_basename (_data_->url);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = g_uri_unescape_string (_data_->_tmp4_, NULL);
	_data_->_tmp6_ = _data_->_tmp5_;
	_g_free0 (_data_->_tmp4_);
	_data_->file_name = _data_->_tmp6_;
	_data_->_tmp7_ = g_path_get_dirname (_data_->url);
	_data_->dir_name = _data_->_tmp7_;
	_data_->_tmp8_ = tuba_cache_path;
	_data_->_tmp9_ = g_build_path (G_DIR_SEPARATOR_S, _data_->_tmp8_, "manual", "media", NULL);
	_data_->dir_path = _data_->_tmp9_;
	_data_->_tmp10_ = _data_->dir_path;
	_data_->_tmp11_ = g_str_hash;
	_data_->_tmp12_ = _data_->dir_name;
	_data_->_tmp13_ = g_strdup_printf ("%u", _data_->_tmp11_ (_data_->_tmp12_));
	_data_->_tmp14_ = _data_->_tmp13_;
	_data_->_tmp15_ = _data_->file_name;
	_data_->_tmp16_ = g_strconcat (_data_->_tmp14_, _data_->_tmp15_, NULL);
	_data_->_tmp17_ = _data_->_tmp16_;
	_data_->_tmp18_ = g_build_path (G_DIR_SEPARATOR_S, _data_->_tmp10_, _data_->_tmp17_, NULL);
	_data_->_tmp19_ = _data_->_tmp18_;
	_g_free0 (_data_->_tmp17_);
	_g_free0 (_data_->_tmp14_);
	_data_->file_path = _data_->_tmp19_;
	_data_->_tmp20_ = _data_->dir_path;
	_data_->_tmp21_ = g_file_new_for_path (_data_->_tmp20_);
	_data_->dir = _data_->_tmp21_;
	_data_->_tmp22_ = _data_->dir;
	if (!g_file_query_exists (_data_->_tmp22_, NULL)) {
		_data_->_tmp23_ = _data_->dir;
		g_file_make_directory_with_parents (_data_->_tmp23_, NULL, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->dir);
			_g_free0 (_data_->file_path);
			_g_free0 (_data_->dir_path);
			_g_free0 (_data_->dir_name);
			_g_free0 (_data_->file_name);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_data_->_tmp24_ = _data_->file_path;
	_data_->_tmp25_ = g_file_new_for_path (_data_->_tmp24_);
	_data_->file = _data_->_tmp25_;
	_data_->_tmp26_ = _data_->file;
	if (!g_file_query_exists (_data_->_tmp26_, NULL)) {
		_data_->_tmp27_ = NULL;
		_data_->_tmp27_ = tuba_request_v2_new (_data_->url, TUBA_REQUEST_V2_METHOD_GET);
		tuba_request_v2_set_cache (_data_->_tmp27_, FALSE);
		_data_->msg = _data_->_tmp27_;
		_data_->_tmp28_ = _data_->msg;
		_data_->_state_ = 1;
		tuba_request_v2_exec (_data_->_tmp28_, tuba_utils_host_download_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp29_ = tuba_request_v2_exec_finish (_data_->_tmp28_, _data_->_res_, NULL, &_data_->_inner_error0_);
		_data_->in_stream = _data_->_tmp29_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->msg);
			_g_object_unref0 (_data_->file);
			_g_object_unref0 (_data_->dir);
			_g_free0 (_data_->file_path);
			_g_free0 (_data_->dir_path);
			_g_free0 (_data_->dir_name);
			_g_free0 (_data_->file_name);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp30_ = _data_->in_stream;
		_data_->_tmp31_ = _g_object_ref0 (_data_->_tmp30_);
		_data_->data = _data_->_tmp31_;
		_data_->_tmp32_ = _data_->file;
		_data_->_state_ = 2;
		g_file_create_async (_data_->_tmp32_, G_FILE_CREATE_PRIVATE, G_PRIORITY_DEFAULT, NULL, tuba_utils_host_download_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp33_ = g_file_create_finish (_data_->_tmp32_, _data_->_res_, &_data_->_inner_error0_);
		_data_->stream = _data_->_tmp33_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->data);
			_g_object_unref0 (_data_->in_stream);
			_g_object_unref0 (_data_->msg);
			_g_object_unref0 (_data_->file);
			_g_object_unref0 (_data_->dir);
			_g_free0 (_data_->file_path);
			_g_free0 (_data_->dir_path);
			_g_free0 (_data_->dir_name);
			_g_free0 (_data_->file_name);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp34_ = _data_->stream;
		_data_->_tmp35_ = _data_->data;
		_data_->_state_ = 3;
		g_output_stream_splice_async ((GOutputStream*) _data_->_tmp34_, _data_->_tmp35_, G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, G_PRIORITY_DEFAULT, NULL, tuba_utils_host_download_ready, _data_);
		return FALSE;
		_state_3:
		g_output_stream_splice_finish ((GOutputStream*) _data_->_tmp34_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->stream);
			_g_object_unref0 (_data_->data);
			_g_object_unref0 (_data_->in_stream);
			_g_object_unref0 (_data_->msg);
			_g_object_unref0 (_data_->file);
			_g_object_unref0 (_data_->dir);
			_g_free0 (_data_->file_path);
			_g_free0 (_data_->dir_path);
			_g_free0 (_data_->dir_name);
			_g_free0 (_data_->file_name);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp36_ = _data_->file_path;
		_data_->_tmp37_ = string_to_string (_data_->_tmp36_);
		_data_->_tmp38_ = g_strconcat ("   OK: File written to: ", _data_->_tmp37_, NULL);
		_data_->_tmp39_ = _data_->_tmp38_;
		g_debug ("Host.vala:97: %s", _data_->_tmp39_);
		_g_free0 (_data_->_tmp39_);
		_g_object_unref0 (_data_->stream);
		_g_object_unref0 (_data_->data);
		_g_object_unref0 (_data_->in_stream);
		_g_object_unref0 (_data_->msg);
	} else {
		g_debug ("Host.vala:100:    OK: File already exists");
	}
	_data_->result = _data_->file_path;
	_g_object_unref0 (_data_->file);
	_g_object_unref0 (_data_->dir);
	_g_free0 (_data_->dir_path);
	_g_free0 (_data_->dir_name);
	_g_free0 (_data_->file_name);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

TubaUtilsHost*
tuba_utils_host_construct (GType object_type)
{
	TubaUtilsHost* self = NULL;
	self = (TubaUtilsHost*) g_type_create_instance (object_type);
	return self;
}

TubaUtilsHost*
tuba_utils_host_new (void)
{
	return tuba_utils_host_construct (TUBA_UTILS_TYPE_HOST);
}

static void
tuba_utils_value_host_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
tuba_utils_value_host_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		tuba_utils_host_unref (value->data[0].v_pointer);
	}
}

static void
tuba_utils_value_host_copy_value (const GValue* src_value,
                                  GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = tuba_utils_host_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
tuba_utils_value_host_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
tuba_utils_value_host_collect_value (GValue* value,
                                     guint n_collect_values,
                                     GTypeCValue* collect_values,
                                     guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		TubaUtilsHost * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = tuba_utils_host_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
tuba_utils_value_host_lcopy_value (const GValue* value,
                                   guint n_collect_values,
                                   GTypeCValue* collect_values,
                                   guint collect_flags)
{
	TubaUtilsHost ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = tuba_utils_host_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
tuba_utils_param_spec_host (const gchar* name,
                            const gchar* nick,
                            const gchar* blurb,
                            GType object_type,
                            GParamFlags flags)
{
	TubaUtilsParamSpecHost* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TUBA_UTILS_TYPE_HOST), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
tuba_utils_value_get_host (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TUBA_UTILS_TYPE_HOST), NULL);
	return value->data[0].v_pointer;
}

void
tuba_utils_value_set_host (GValue* value,
                           gpointer v_object)
{
	TubaUtilsHost * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TUBA_UTILS_TYPE_HOST));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TUBA_UTILS_TYPE_HOST));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		tuba_utils_host_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		tuba_utils_host_unref (old);
	}
}

void
tuba_utils_value_take_host (GValue* value,
                            gpointer v_object)
{
	TubaUtilsHost * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TUBA_UTILS_TYPE_HOST));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TUBA_UTILS_TYPE_HOST));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		tuba_utils_host_unref (old);
	}
}

static void
tuba_utils_host_class_init (TubaUtilsHostClass * klass,
                            gpointer klass_data)
{
	tuba_utils_host_parent_class = g_type_class_peek_parent (klass);
	((TubaUtilsHostClass *) klass)->finalize = tuba_utils_host_finalize;
}

static void
tuba_utils_host_instance_init (TubaUtilsHost * self,
                               gpointer klass)
{
	self->ref_count = 1;
}

static void
tuba_utils_host_finalize (TubaUtilsHost * obj)
{
	TubaUtilsHost * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TUBA_UTILS_TYPE_HOST, TubaUtilsHost);
	g_signal_handlers_destroy (self);
}

 G_GNUC_NO_INLINE static GType
tuba_utils_host_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { tuba_utils_value_host_init, tuba_utils_value_host_free_value, tuba_utils_value_host_copy_value, tuba_utils_value_host_peek_pointer, "p", tuba_utils_value_host_collect_value, "p", tuba_utils_value_host_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (TubaUtilsHostClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tuba_utils_host_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TubaUtilsHost), 0, (GInstanceInitFunc) tuba_utils_host_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType tuba_utils_host_type_id;
	tuba_utils_host_type_id = g_type_register_fundamental (g_type_fundamental_next (), "TubaUtilsHost", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_NONE);
	return tuba_utils_host_type_id;
}

GType
tuba_utils_host_get_type (void)
{
	static GType tuba_utils_host_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_utils_host_type_id__once)) {
		GType tuba_utils_host_type_id;
		tuba_utils_host_type_id = tuba_utils_host_get_type_once ();
		g_once_init_leave_pointer (&tuba_utils_host_type_id__once, tuba_utils_host_type_id);
	}
	return tuba_utils_host_type_id__once;
}

gpointer
tuba_utils_host_ref (gpointer instance)
{
	TubaUtilsHost * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
tuba_utils_host_unref (gpointer instance)
{
	TubaUtilsHost * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		TUBA_UTILS_HOST_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

