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

#include <glib-object.h>
#include <libsoup/soup.h>
#include <glib.h>
#include <adwaita.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <json-glib/json-glib.h>

#define BUILD_NAME "Tuba"
#define BUILD_VERSION "0.11.1"
#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_TYPE_NETWORK (tuba_network_get_type ())
#define TUBA_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_TYPE_NETWORK, TubaNetwork))
#define TUBA_NETWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_TYPE_NETWORK, TubaNetworkClass))
#define TUBA_IS_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_TYPE_NETWORK))
#define TUBA_IS_NETWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_TYPE_NETWORK))
#define TUBA_NETWORK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_TYPE_NETWORK, TubaNetworkClass))

typedef struct _TubaNetwork TubaNetwork;
typedef struct _TubaNetworkClass TubaNetworkClass;
typedef struct _TubaNetworkPrivate TubaNetworkPrivate;
enum  {
	TUBA_NETWORK_0_PROPERTY,
	TUBA_NETWORK_SESSION_PROPERTY,
	TUBA_NETWORK_NUM_PROPERTIES
};
static GParamSpec* tuba_network_properties[TUBA_NETWORK_NUM_PROPERTIES];
typedef enum  {
	TUBA_NETWORK_EXTRA_DATA_RESPONSE_HEADERS
} TubaNetworkExtraData;

#define TUBA_NETWORK_TYPE_EXTRA_DATA (tuba_network_extra_data_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#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 TUBA_TYPE_OOPSIE (tuba_oopsie_get_type ())
#define _soup_message_headers_unref0(var) ((var == NULL) ? NULL : (var = (soup_message_headers_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))
typedef struct _TubaNetworkQueueV2Data TubaNetworkQueueV2Data;
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
#define _g_bytes_unref0(var) ((var == NULL) ? NULL : (var = (g_bytes_unref (var), NULL)))
typedef struct _TubaNetworkGetParserFromInputstreamAsyncData TubaNetworkGetParserFromInputstreamAsyncData;
#define _json_array_unref0(var) ((var == NULL) ? NULL : (var = (json_array_unref (var), NULL)))
typedef void (*TubaNetworkNodeCallback) (JsonNode* node, gpointer user_data, GError** error);
typedef struct _Block57Data Block57Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef void (*TubaNetworkErrorCallback) (gint32 code, const gchar* reason, gpointer user_data);
typedef void (*TubaNetworkSuccessCallback) (GInputStream* in_stream, SoupMessageHeaders* response_headers, gpointer user_data, GError** error);
typedef void (*TubaNetworkObjectCallback) (JsonObject* node, gpointer user_data, GError** error);
enum  {
	TUBA_NETWORK_STARTED_SIGNAL,
	TUBA_NETWORK_FINISHED_SIGNAL,
	TUBA_NETWORK_NUM_SIGNALS
};
static guint tuba_network_signals[TUBA_NETWORK_NUM_SIGNALS] = {0};

struct _TubaNetwork {
	GObject parent_instance;
	TubaNetworkPrivate * priv;
};

struct _TubaNetworkClass {
	GObjectClass parent_class;
};

struct _TubaNetworkPrivate {
	SoupSession* _session;
	SoupCache* cache;
	gint requests_processing;
};

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 _TubaNetworkQueueV2Data {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	TubaNetwork* self;
	SoupMessage* msg;
	GCancellable* cancellable;
	SoupMessageHeaders* response_headers;
	GInputStream* result;
	gint _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GUri* _tmp4_;
	GUri* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	GInputStream* in_stream;
	SoupSession* _tmp11_;
	GInputStream* _tmp12_;
	guint status;
	guint _tmp13_;
	guint _tmp14_;
	SoupMessageHeaders* _tmp15_;
	SoupMessageHeaders* _tmp16_;
	SoupMessageHeaders* _tmp17_;
	gboolean _tmp18_;
	const gchar* error_msg;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	JsonParser* parser;
	GInputStream* _tmp21_;
	JsonParser* _tmp22_;
	JsonObject* root;
	TubaNetwork* _tmp23_;
	JsonParser* _tmp24_;
	JsonObject* _tmp25_;
	JsonObject* _tmp26_;
	const gchar* _tmp27_;
	JsonObject* _tmp28_;
	JsonObject* _tmp29_;
	const gchar* _tmp30_;
	const gchar* _tmp31_;
	const gchar* _tmp32_;
	JsonObject* _tmp33_;
	const gchar* _tmp34_;
	const gchar* _tmp35_;
	const gchar* _tmp36_;
	GUri* _tmp37_;
	GUri* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	const gchar* _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	const gchar* _tmp44_;
	const gchar* _tmp45_;
	const gchar* _tmp46_;
	const gchar* _tmp47_;
	const gchar* _tmp48_;
	gchar* _tmp49_;
	gchar* _tmp50_;
	const gchar* _tmp51_;
	GError* _tmp52_;
	const gchar* _tmp53_;
	GError* _tmp54_;
	const gchar* _tmp55_;
	GError* _tmp56_;
	const gchar* _tmp57_;
	GError* _tmp58_;
	const gchar* _tmp59_;
	GError* _tmp60_;
	const gchar* _tmp61_;
	GError* _tmp62_;
	const gchar* _tmp63_;
	GError* _tmp64_;
	const gchar* _tmp65_;
	GError* _tmp66_;
	const gchar* _tmp67_;
	GError* _tmp68_;
	GError* _inner_error0_;
};

struct _TubaNetworkGetParserFromInputstreamAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GInputStream* in_stream;
	GCancellable* cancellable;
	JsonParser* result;
	GMemoryOutputStream* mem_out;
	GMemoryOutputStream* _tmp0_;
	GMemoryOutputStream* _tmp1_;
	GMemoryOutputStream* _tmp2_;
	GMemoryInputStream* mem_in;
	GMemoryOutputStream* _tmp3_;
	GBytes* _tmp4_;
	GBytes* _tmp5_;
	GMemoryInputStream* _tmp6_;
	GMemoryInputStream* _tmp7_;
	JsonParser* parser;
	JsonParser* _tmp8_;
	JsonParser* _tmp9_;
	GMemoryInputStream* _tmp10_;
	GError* _inner_error0_;
};

struct _Block57Data {
	int _ref_count_;
	TubaNetworkNodeCallback cb;
	gpointer cb_target;
	GDestroyNotify cb_target_destroy_notify;
};

static gint TubaNetwork_private_offset;
static gpointer tuba_network_parent_class = NULL;
VALA_EXTERN TubaApplication* tuba_app;
VALA_EXTERN TubaNetwork* tuba_network;
VALA_EXTERN gchar* tuba_cache_path;

VALA_EXTERN GType tuba_network_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaNetwork, g_object_unref)
VALA_EXTERN GType tuba_network_extra_data_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void tuba_network_clear_cache (TubaNetwork* self);
VALA_EXTERN void tuba_helper_image_clear_cache (void);
VALA_EXTERN void tuba_network_flush_cache (TubaNetwork* self);
VALA_EXTERN void tuba_helper_image_flush_cache (void);
static void tuba_network_on_proxy_change (TubaNetwork* self);
VALA_EXTERN SoupSession* tuba_network_get_session (TubaNetwork* self);
VALA_EXTERN GType tuba_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaApplication, g_object_unref)
VALA_EXTERN GProxyResolver* tuba_application_get_proxy (TubaApplication* self);
static void tuba_network_queue_v2_data_free (gpointer _data);
VALA_EXTERN GQuark tuba_oopsie_quark (void);
VALA_EXTERN GType tuba_oopsie_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void tuba_network_queue_v2 (TubaNetwork* self,
                            SoupMessage* msg,
                            GCancellable* cancellable,
                            GAsyncReadyCallback _callback_,
                            gpointer _user_data_);
VALA_EXTERN GInputStream* tuba_network_queue_v2_finish (TubaNetwork* self,
                                            GAsyncResult* _res_,
                                            SoupMessageHeaders** response_headers,
                                            GError** error);
static gboolean tuba_network_queue_v2_co (TubaNetworkQueueV2Data* _data_);
static void tuba_network_queue_v2_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_);
VALA_EXTERN void tuba_network_get_parser_from_inputstream_async (GInputStream* in_stream,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
VALA_EXTERN JsonParser* tuba_network_get_parser_from_inputstream_finish (GAsyncResult* _res_,
                                                             GError** error);
VALA_EXTERN JsonObject* tuba_network_parse (TubaNetwork* self,
                                JsonParser* parser);
VALA_EXTERN void tuba_network_on_error (TubaNetwork* self,
                            gint32 code,
                            const gchar* message);
VALA_EXTERN JsonNode* tuba_network_parse_node (TubaNetwork* self,
                                   JsonParser* parser);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
static void _vala_JsonNode_free (JsonNode* self);
static void tuba_network_get_parser_from_inputstream_async_data_free (gpointer _data);
static gboolean tuba_network_get_parser_from_inputstream_async_co (TubaNetworkGetParserFromInputstreamAsyncData* _data_);
static void tuba_network_get_parser_from_inputstream_async_ready (GObject* source_object,
                                                           GAsyncResult* _res_,
                                                           gpointer _user_data_);
VALA_EXTERN JsonArray* tuba_network_get_array_mstd (JsonParser* parser);
VALA_EXTERN guint tuba_network_get_array_size (JsonParser* parser);
VALA_EXTERN void tuba_network_parse_array (JsonParser* parser,
                               TubaNetworkNodeCallback cb,
                               gpointer cb_target,
                               GDestroyNotify cb_target_destroy_notify,
                               GError** error);
static Block57Data* block57_data_ref (Block57Data* _data57_);
static void block57_data_unref (void * _userdata_);
static void __lambda12_ (Block57Data* _data57_,
                  JsonArray* array,
                  guint i,
                  JsonNode* node);
static void ___lambda12__json_array_foreach (JsonArray* array,
                                      guint index_,
                                      JsonNode* element_node,
                                      gpointer self);
VALA_EXTERN TubaNetwork* tuba_network_new (void);
VALA_EXTERN TubaNetwork* tuba_network_construct (GType object_type);
VALA_EXTERN void tuba_network_set_session (TubaNetwork* self,
                               SoupSession* value);
static GObject * tuba_network_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties);
static void _tuba_network___lambda13_ (TubaNetwork* self,
                                SoupMessage* msg);
static void __tuba_network___lambda13__soup_session_request_unqueued (SoupSession* _sender,
                                                               SoupMessage* msg,
                                                               gpointer self);
static void _tuba_network_on_proxy_change_g_object_notify (GObject* _sender,
                                                    GParamSpec* pspec,
                                                    gpointer self);
static void tuba_network_finalize (GObject * obj);
static GType tuba_network_get_type_once (void);
static void _vala_tuba_network_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec);
static void _vala_tuba_network_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec);

static inline gpointer
tuba_network_get_instance_private (TubaNetwork* self)
{
	return G_STRUCT_MEMBER_P (self, TubaNetwork_private_offset);
}

 G_GNUC_NO_INLINE static GType
tuba_network_extra_data_get_type_once (void)
{
	static const GEnumValue values[] = {{TUBA_NETWORK_EXTRA_DATA_RESPONSE_HEADERS, "TUBA_NETWORK_EXTRA_DATA_RESPONSE_HEADERS", "response-headers"}, {0, NULL, NULL}};
	GType tuba_network_extra_data_type_id;
	tuba_network_extra_data_type_id = g_enum_register_static ("TubaNetworkExtraData", values);
	return tuba_network_extra_data_type_id;
}

GType
tuba_network_extra_data_get_type (void)
{
	static GType tuba_network_extra_data_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_network_extra_data_type_id__once)) {
		GType tuba_network_extra_data_type_id;
		tuba_network_extra_data_type_id = tuba_network_extra_data_get_type_once ();
		g_once_init_leave_pointer (&tuba_network_extra_data_type_id__once, tuba_network_extra_data_type_id);
	}
	return tuba_network_extra_data_type_id__once;
}

void
tuba_network_clear_cache (TubaNetwork* self)
{
	SoupCache* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->cache;
	soup_cache_clear (_tmp0_);
	tuba_helper_image_clear_cache ();
}

void
tuba_network_flush_cache (TubaNetwork* self)
{
	SoupCache* _tmp0_;
	SoupCache* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->cache;
	soup_cache_flush (_tmp0_);
	_tmp1_ = self->priv->cache;
	soup_cache_dump (_tmp1_);
	tuba_helper_image_flush_cache ();
}

static void
tuba_network_on_proxy_change (TubaNetwork* self)
{
	SoupSession* _tmp0_;
	TubaApplication* _tmp1_;
	GProxyResolver* _tmp2_;
	GProxyResolver* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_session;
	_tmp1_ = tuba_app;
	_tmp2_ = tuba_application_get_proxy (_tmp1_);
	_tmp3_ = _tmp2_;
	soup_session_set_proxy_resolver (_tmp0_, _tmp3_);
}

static void
tuba_network_queue_v2_data_free (gpointer _data)
{
	TubaNetworkQueueV2Data* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->msg);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (TubaNetworkQueueV2Data, _data_);
}

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

void
tuba_network_queue_v2 (TubaNetwork* self,
                       SoupMessage* msg,
                       GCancellable* cancellable,
                       GAsyncReadyCallback _callback_,
                       gpointer _user_data_)
{
	TubaNetworkQueueV2Data* _data_;
	TubaNetwork* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (msg != NULL);
	_data_ = g_slice_new0 (TubaNetworkQueueV2Data);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, tuba_network_queue_v2_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_g_object_unref0 (_data_->msg);
	_data_->msg = msg;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	tuba_network_queue_v2_co (_data_);
}

GInputStream*
tuba_network_queue_v2_finish (TubaNetwork* self,
                              GAsyncResult* _res_,
                              SoupMessageHeaders** response_headers,
                              GError** error)
{
	GInputStream* result;
	TubaNetworkQueueV2Data* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	if (response_headers) {
		*response_headers = _data_->response_headers;
	} else {
		_soup_message_headers_unref0 (_data_->response_headers);
	}
	_data_->response_headers = NULL;
	result = _data_->result;
	_data_->result = NULL;
	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_network_queue_v2_ready (GObject* source_object,
                             GAsyncResult* _res_,
                             gpointer _user_data_)
{
	TubaNetworkQueueV2Data* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	tuba_network_queue_v2_co (_data_);
}

static gpointer
_soup_message_headers_ref0 (gpointer self)
{
	return self ? soup_message_headers_ref (self) : NULL;
}

static gboolean
tuba_network_queue_v2_co (TubaNetworkQueueV2Data* _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_ = _data_->self->priv->requests_processing;
	_data_->self->priv->requests_processing = _data_->_tmp0_ + 1;
	_data_->_tmp1_ = soup_message_get_method (_data_->msg);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = string_to_string (_data_->_tmp2_);
	_data_->_tmp4_ = soup_message_get_uri (_data_->msg);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = g_uri_to_string (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_tmp8_ = string_to_string (_data_->_tmp7_);
	_data_->_tmp9_ = g_strconcat (_data_->_tmp3_, ": ", _data_->_tmp8_, NULL);
	_data_->_tmp10_ = _data_->_tmp9_;
	g_debug ("Network.vala:115: %s", _data_->_tmp10_);
	_g_free0 (_data_->_tmp10_);
	_g_free0 (_data_->_tmp7_);
	_data_->_tmp11_ = _data_->self->priv->_session;
	_data_->_state_ = 1;
	soup_session_send_async (_data_->_tmp11_, _data_->msg, 0, _data_->cancellable, tuba_network_queue_v2_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp12_ = soup_session_send_finish (_data_->_tmp11_, _data_->_res_, &_data_->_inner_error0_);
	_data_->in_stream = _data_->_tmp12_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->msg);
		_soup_message_headers_unref0 (_data_->response_headers);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_object_get (_data_->msg, "status-code", &_data_->_tmp13_, NULL);
	_data_->_tmp14_ = _data_->_tmp13_;
	_data_->status = _data_->_tmp14_;
	_data_->_tmp15_ = soup_message_get_response_headers (_data_->msg);
	_data_->_tmp16_ = _data_->_tmp15_;
	_data_->_tmp17_ = _soup_message_headers_ref0 (_data_->_tmp16_);
	_soup_message_headers_unref0 (_data_->response_headers);
	_data_->response_headers = _data_->_tmp17_;
	if (_data_->status >= ((guint) 200)) {
		_data_->_tmp18_ = _data_->status < ((guint) 300);
	} else {
		_data_->_tmp18_ = FALSE;
	}
	if (_data_->_tmp18_) {
		_data_->result = _data_->in_stream;
		_g_object_unref0 (_data_->msg);
		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;
	}
	_data_->_tmp19_ = soup_message_get_reason_phrase (_data_->msg);
	_data_->_tmp20_ = _data_->_tmp19_;
	_data_->error_msg = _data_->_tmp20_;
	{
		_data_->_tmp21_ = _data_->in_stream;
		_data_->_state_ = 2;
		tuba_network_get_parser_from_inputstream_async (_data_->_tmp21_, NULL, tuba_network_queue_v2_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp22_ = tuba_network_get_parser_from_inputstream_finish (_data_->_res_, &_data_->_inner_error0_);
		_data_->parser = _data_->_tmp22_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp23_ = tuba_network;
		_data_->_tmp24_ = _data_->parser;
		_data_->_tmp25_ = tuba_network_parse (_data_->_tmp23_, _data_->_tmp24_);
		_data_->root = _data_->_tmp25_;
		_data_->_tmp26_ = _data_->root;
		if (_data_->_tmp26_ != NULL) {
			_data_->_tmp28_ = _data_->root;
			if (json_object_has_member (_data_->_tmp28_, "message")) {
				_data_->_tmp29_ = _data_->root;
				_data_->_tmp30_ = soup_message_get_reason_phrase (_data_->msg);
				_data_->_tmp31_ = _data_->_tmp30_;
				_data_->_tmp32_ = json_object_get_string_member_with_default (_data_->_tmp29_, "message", _data_->_tmp31_);
				_data_->_tmp27_ = _data_->_tmp32_;
			} else {
				_data_->_tmp33_ = _data_->root;
				_data_->_tmp34_ = soup_message_get_reason_phrase (_data_->msg);
				_data_->_tmp35_ = _data_->_tmp34_;
				_data_->_tmp36_ = json_object_get_string_member_with_default (_data_->_tmp33_, "error", _data_->_tmp35_);
				_data_->_tmp27_ = _data_->_tmp36_;
			}
			_data_->error_msg = _data_->_tmp27_;
		}
		_json_object_unref0 (_data_->root);
		_g_object_unref0 (_data_->parser);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->in_stream);
		_g_object_unref0 (_data_->msg);
		_soup_message_headers_unref0 (_data_->response_headers);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp37_ = soup_message_get_uri (_data_->msg);
	_data_->_tmp38_ = _data_->_tmp37_;
	_data_->_tmp39_ = g_uri_to_string (_data_->_tmp38_);
	_data_->_tmp40_ = _data_->_tmp39_;
	_data_->_tmp41_ = string_to_string (_data_->_tmp40_);
	_data_->_tmp42_ = g_strdup_printf ("%u", _data_->status);
	_data_->_tmp43_ = _data_->_tmp42_;
	_data_->_tmp44_ = soup_message_get_reason_phrase (_data_->msg);
	_data_->_tmp45_ = _data_->_tmp44_;
	_data_->_tmp46_ = string_to_string (_data_->_tmp45_);
	_data_->_tmp47_ = _data_->error_msg;
	_data_->_tmp48_ = string_to_string (_data_->_tmp47_);
	_data_->_tmp49_ = g_strconcat ("Request \"", _data_->_tmp41_, "\" failed: ", _data_->_tmp43_, " ", _data_->_tmp46_, " ", _data_->_tmp48_, NULL);
	_data_->_tmp50_ = _data_->_tmp49_;
	g_critical ("Network.vala:134: %s", _data_->_tmp50_);
	_g_free0 (_data_->_tmp50_);
	_g_free0 (_data_->_tmp43_);
	_g_free0 (_data_->_tmp40_);
	switch (_data_->status) {
		case 401:
		{
			_data_->_tmp51_ = _data_->error_msg;
			_data_->_tmp52_ = g_error_new_literal (TUBA_OOPSIE, TUBA_OOPSIE_HTTP_401, _data_->_tmp51_);
			_data_->_inner_error0_ = _data_->_tmp52_;
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->in_stream);
			_g_object_unref0 (_data_->msg);
			_soup_message_headers_unref0 (_data_->response_headers);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		case 403:
		{
			_data_->_tmp53_ = _data_->error_msg;
			_data_->_tmp54_ = g_error_new_literal (TUBA_OOPSIE, TUBA_OOPSIE_HTTP_403, _data_->_tmp53_);
			_data_->_inner_error0_ = _data_->_tmp54_;
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->in_stream);
			_g_object_unref0 (_data_->msg);
			_soup_message_headers_unref0 (_data_->response_headers);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		case 404:
		{
			_data_->_tmp55_ = _data_->error_msg;
			_data_->_tmp56_ = g_error_new_literal (TUBA_OOPSIE, TUBA_OOPSIE_HTTP_404, _data_->_tmp55_);
			_data_->_inner_error0_ = _data_->_tmp56_;
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->in_stream);
			_g_object_unref0 (_data_->msg);
			_soup_message_headers_unref0 (_data_->response_headers);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		case 410:
		{
			_data_->_tmp57_ = _data_->error_msg;
			_data_->_tmp58_ = g_error_new_literal (TUBA_OOPSIE, TUBA_OOPSIE_HTTP_410, _data_->_tmp57_);
			_data_->_inner_error0_ = _data_->_tmp58_;
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->in_stream);
			_g_object_unref0 (_data_->msg);
			_soup_message_headers_unref0 (_data_->response_headers);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		case 422:
		{
			_data_->_tmp59_ = _data_->error_msg;
			_data_->_tmp60_ = g_error_new_literal (TUBA_OOPSIE, TUBA_OOPSIE_HTTP_422, _data_->_tmp59_);
			_data_->_inner_error0_ = _data_->_tmp60_;
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->in_stream);
			_g_object_unref0 (_data_->msg);
			_soup_message_headers_unref0 (_data_->response_headers);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		case 429:
		{
			_data_->_tmp61_ = _data_->error_msg;
			_data_->_tmp62_ = g_error_new_literal (TUBA_OOPSIE, TUBA_OOPSIE_HTTP_429, _data_->_tmp61_);
			_data_->_inner_error0_ = _data_->_tmp62_;
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->in_stream);
			_g_object_unref0 (_data_->msg);
			_soup_message_headers_unref0 (_data_->response_headers);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		case 500:
		{
			_data_->_tmp63_ = _data_->error_msg;
			_data_->_tmp64_ = g_error_new_literal (TUBA_OOPSIE, TUBA_OOPSIE_HTTP_500, _data_->_tmp63_);
			_data_->_inner_error0_ = _data_->_tmp64_;
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->in_stream);
			_g_object_unref0 (_data_->msg);
			_soup_message_headers_unref0 (_data_->response_headers);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		case 503:
		{
			_data_->_tmp65_ = _data_->error_msg;
			_data_->_tmp66_ = g_error_new_literal (TUBA_OOPSIE, TUBA_OOPSIE_HTTP_503, _data_->_tmp65_);
			_data_->_inner_error0_ = _data_->_tmp66_;
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->in_stream);
			_g_object_unref0 (_data_->msg);
			_soup_message_headers_unref0 (_data_->response_headers);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		default:
		break;
	}
	_data_->_tmp67_ = _data_->error_msg;
	_data_->_tmp68_ = g_error_new_literal (TUBA_OOPSIE, TUBA_OOPSIE_INSTANCE, _data_->_tmp67_);
	_data_->_inner_error0_ = _data_->_tmp68_;
	g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
	_g_object_unref0 (_data_->in_stream);
	_g_object_unref0 (_data_->msg);
	_soup_message_headers_unref0 (_data_->response_headers);
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
tuba_network_on_error (TubaNetwork* self,
                       gint32 code,
                       const gchar* message)
{
	TubaApplication* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	g_warning ("Network.vala:150: %s", message);
	_tmp0_ = tuba_app;
	g_signal_emit_by_name (_tmp0_, "toast", message, (guint) 0, NULL, NULL, NULL);
}

static JsonNode*
_vala_JsonNode_copy (JsonNode* self)
{
	return g_boxed_copy (json_node_get_type (), self);
}

static gpointer
__vala_JsonNode_copy0 (gpointer self)
{
	return self ? _vala_JsonNode_copy (self) : NULL;
}

JsonNode*
tuba_network_parse_node (TubaNetwork* self,
                         JsonParser* parser)
{
	JsonNode* _tmp0_;
	JsonNode* _tmp1_;
	JsonNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (parser != NULL, NULL);
	_tmp0_ = json_parser_get_root (parser);
	_tmp1_ = __vala_JsonNode_copy0 (_tmp0_);
	result = _tmp1_;
	return result;
}

static void
_vala_JsonNode_free (JsonNode* self)
{
	g_boxed_free (json_node_get_type (), self);
}

static gpointer
_json_object_ref0 (gpointer self)
{
	return self ? json_object_ref (self) : NULL;
}

JsonObject*
tuba_network_parse (TubaNetwork* self,
                    JsonParser* parser)
{
	JsonNode* node = NULL;
	JsonNode* _tmp0_;
	JsonNode* _tmp1_;
	JsonNode* _tmp2_;
	JsonObject* _tmp3_;
	JsonObject* _tmp4_;
	JsonObject* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (parser != NULL, NULL);
	_tmp0_ = tuba_network_parse_node (self, parser);
	node = _tmp0_;
	_tmp1_ = node;
	if (_tmp1_ == NULL) {
		result = NULL;
		__vala_JsonNode_free0 (node);
		return result;
	}
	_tmp2_ = node;
	_tmp3_ = json_node_get_object (_tmp2_);
	_tmp4_ = _json_object_ref0 (_tmp3_);
	result = _tmp4_;
	__vala_JsonNode_free0 (node);
	return result;
}

static void
tuba_network_get_parser_from_inputstream_async_data_free (gpointer _data)
{
	TubaNetworkGetParserFromInputstreamAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->in_stream);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	g_slice_free (TubaNetworkGetParserFromInputstreamAsyncData, _data_);
}

void
tuba_network_get_parser_from_inputstream_async (GInputStream* in_stream,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	TubaNetworkGetParserFromInputstreamAsyncData* _data_;
	GInputStream* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (in_stream != NULL);
	_data_ = g_slice_new0 (TubaNetworkGetParserFromInputstreamAsyncData);
	_data_->_async_result = g_task_new (NULL, cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, tuba_network_get_parser_from_inputstream_async_data_free);
	_tmp0_ = _g_object_ref0 (in_stream);
	_g_object_unref0 (_data_->in_stream);
	_data_->in_stream = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	tuba_network_get_parser_from_inputstream_async_co (_data_);
}

JsonParser*
tuba_network_get_parser_from_inputstream_finish (GAsyncResult* _res_,
                                                 GError** error)
{
	JsonParser* result;
	TubaNetworkGetParserFromInputstreamAsyncData* _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_network_get_parser_from_inputstream_async_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_)
{
	TubaNetworkGetParserFromInputstreamAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	tuba_network_get_parser_from_inputstream_async_co (_data_);
}

static gboolean
tuba_network_get_parser_from_inputstream_async_co (TubaNetworkGetParserFromInputstreamAsyncData* _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_ = (GMemoryOutputStream*) g_memory_output_stream_new_resizable ();
	_data_->mem_out = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->mem_out;
	_data_->_state_ = 1;
	g_output_stream_splice_async ((GOutputStream*) _data_->_tmp1_, _data_->in_stream, G_OUTPUT_STREAM_SPLICE_NONE, G_PRIORITY_DEFAULT, _data_->cancellable, tuba_network_get_parser_from_inputstream_async_ready, _data_);
	return FALSE;
	_state_1:
	g_output_stream_splice_finish ((GOutputStream*) _data_->_tmp1_, _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_->mem_out);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp2_ = _data_->mem_out;
	_data_->_state_ = 2;
	g_output_stream_close_async ((GOutputStream*) _data_->_tmp2_, G_PRIORITY_DEFAULT, _data_->cancellable, tuba_network_get_parser_from_inputstream_async_ready, _data_);
	return FALSE;
	_state_2:
	g_output_stream_close_finish ((GOutputStream*) _data_->_tmp2_, _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_->mem_out);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp3_ = _data_->mem_out;
	_data_->_tmp4_ = g_memory_output_stream_steal_as_bytes (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = (GMemoryInputStream*) g_memory_input_stream_new_from_bytes (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_g_bytes_unref0 (_data_->_tmp5_);
	_data_->mem_in = _data_->_tmp7_;
	_data_->_tmp8_ = json_parser_new ();
	_data_->parser = _data_->_tmp8_;
	_data_->_tmp9_ = _data_->parser;
	_data_->_tmp10_ = _data_->mem_in;
	_data_->_state_ = 3;
	json_parser_load_from_stream_async (_data_->_tmp9_, (GInputStream*) _data_->_tmp10_, NULL, tuba_network_get_parser_from_inputstream_async_ready, _data_);
	return FALSE;
	_state_3:
	json_parser_load_from_stream_finish (_data_->_tmp9_, _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_->parser);
		_g_object_unref0 (_data_->mem_in);
		_g_object_unref0 (_data_->mem_out);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = _data_->parser;
	_g_object_unref0 (_data_->mem_in);
	_g_object_unref0 (_data_->mem_out);
	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
_json_array_ref0 (gpointer self)
{
	return self ? json_array_ref (self) : NULL;
}

JsonArray*
tuba_network_get_array_mstd (JsonParser* parser)
{
	JsonNode* _tmp0_;
	JsonArray* _tmp1_;
	JsonArray* _tmp2_;
	JsonArray* result;
	g_return_val_if_fail (parser != NULL, NULL);
	_tmp0_ = json_parser_get_root (parser);
	_tmp1_ = json_node_get_array (_tmp0_);
	_tmp2_ = _json_array_ref0 (_tmp1_);
	result = _tmp2_;
	return result;
}

guint
tuba_network_get_array_size (JsonParser* parser)
{
	JsonArray* _tmp0_;
	JsonArray* _tmp1_;
	guint _tmp2_;
	guint result;
	g_return_val_if_fail (parser != NULL, 0U);
	_tmp0_ = tuba_network_get_array_mstd (parser);
	_tmp1_ = _tmp0_;
	_tmp2_ = json_array_get_length (_tmp1_);
	_json_array_unref0 (_tmp1_);
	result = _tmp2_;
	return result;
}

static Block57Data*
block57_data_ref (Block57Data* _data57_)
{
	g_atomic_int_inc (&_data57_->_ref_count_);
	return _data57_;
}

static void
block57_data_unref (void * _userdata_)
{
	Block57Data* _data57_;
	_data57_ = (Block57Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data57_->_ref_count_)) {
		(_data57_->cb_target_destroy_notify == NULL) ? NULL : (_data57_->cb_target_destroy_notify (_data57_->cb_target), NULL);
		_data57_->cb = NULL;
		_data57_->cb_target = NULL;
		_data57_->cb_target_destroy_notify = NULL;
		g_slice_free (Block57Data, _data57_);
	}
}

static void
__lambda12_ (Block57Data* _data57_,
             JsonArray* array,
             guint i,
             JsonNode* node)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (array != NULL);
	g_return_if_fail (node != NULL);
	{
		_data57_->cb (node, _data57_->cb_target, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp0_;
		const gchar* _tmp1_;
		const gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp0_ = e;
		_tmp1_ = _tmp0_->message;
		_tmp2_ = string_to_string (_tmp1_);
		_tmp3_ = g_strconcat ("Error parsing array: ", _tmp2_, NULL);
		_tmp4_ = _tmp3_;
		g_warning ("Network.vala:200: %s", _tmp4_);
		_g_free0 (_tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda12__json_array_foreach (JsonArray* array,
                                 guint index_,
                                 JsonNode* element_node,
                                 gpointer self)
{
	__lambda12_ (self, array, index_, element_node);
}

void
tuba_network_parse_array (JsonParser* parser,
                          TubaNetworkNodeCallback cb,
                          gpointer cb_target,
                          GDestroyNotify cb_target_destroy_notify,
                          GError** error)
{
	Block57Data* _data57_;
	JsonArray* _tmp0_;
	JsonArray* _tmp1_;
	g_return_if_fail (parser != NULL);
	_data57_ = g_slice_new0 (Block57Data);
	_data57_->_ref_count_ = 1;
	(_data57_->cb_target_destroy_notify == NULL) ? NULL : (_data57_->cb_target_destroy_notify (_data57_->cb_target), NULL);
	_data57_->cb = NULL;
	_data57_->cb_target = NULL;
	_data57_->cb_target_destroy_notify = NULL;
	_data57_->cb = cb;
	_data57_->cb_target = cb_target;
	_data57_->cb_target_destroy_notify = cb_target_destroy_notify;
	_tmp0_ = tuba_network_get_array_mstd (parser);
	_tmp1_ = _tmp0_;
	json_array_foreach_element (_tmp1_, ___lambda12__json_array_foreach, _data57_);
	_json_array_unref0 (_tmp1_);
	block57_data_unref (_data57_);
	_data57_ = NULL;
}

TubaNetwork*
tuba_network_construct (GType object_type)
{
	TubaNetwork * self = NULL;
	self = (TubaNetwork*) g_object_new (object_type, NULL);
	return self;
}

TubaNetwork*
tuba_network_new (void)
{
	return tuba_network_construct (TUBA_TYPE_NETWORK);
}

SoupSession*
tuba_network_get_session (TubaNetwork* self)
{
	SoupSession* result;
	SoupSession* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_session;
	result = _tmp0_;
	return result;
}

void
tuba_network_set_session (TubaNetwork* self,
                          SoupSession* value)
{
	SoupSession* old_value;
	g_return_if_fail (self != NULL);
	old_value = tuba_network_get_session (self);
	if (old_value != value) {
		SoupSession* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_session);
		self->priv->_session = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tuba_network_properties[TUBA_NETWORK_SESSION_PROPERTY]);
	}
}

static void
_tuba_network___lambda13_ (TubaNetwork* self,
                           SoupMessage* msg)
{
	gint _tmp0_;
	g_return_if_fail (msg != NULL);
	_tmp0_ = self->priv->requests_processing;
	self->priv->requests_processing = _tmp0_ - 1;
	if (self->priv->requests_processing <= 0) {
		g_signal_emit (self, tuba_network_signals[TUBA_NETWORK_FINISHED_SIGNAL], 0);
	}
}

static void
__tuba_network___lambda13__soup_session_request_unqueued (SoupSession* _sender,
                                                          SoupMessage* msg,
                                                          gpointer self)
{
	_tuba_network___lambda13_ ((TubaNetwork*) self, msg);
}

static void
_tuba_network_on_proxy_change_g_object_notify (GObject* _sender,
                                               GParamSpec* pspec,
                                               gpointer self)
{
	tuba_network_on_proxy_change ((TubaNetwork*) self);
}

static GObject *
tuba_network_constructor (GType type,
                          guint n_construct_properties,
                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	TubaNetwork * self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	SoupCache* _tmp3_;
	SoupCache* _tmp4_;
	SoupCache* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	SoupSession* _tmp21_ = NULL;
	SoupSession* _tmp22_;
	SoupSession* _tmp23_;
	SoupCache* _tmp24_;
	SoupSession* _tmp25_;
	TubaApplication* _tmp26_;
	parent_class = G_OBJECT_CLASS (tuba_network_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TUBA_TYPE_NETWORK, TubaNetwork);
	_tmp0_ = tuba_cache_path;
	_tmp1_ = g_build_path (G_DIR_SEPARATOR_S, _tmp0_, "soup", "misc", NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = soup_cache_new (_tmp2_, SOUP_CACHE_SINGLE_USER);
	_g_object_unref0 (self->priv->cache);
	self->priv->cache = _tmp3_;
	_g_free0 (_tmp2_);
	_tmp4_ = self->priv->cache;
	soup_cache_load (_tmp4_);
	_tmp5_ = self->priv->cache;
	soup_cache_set_max_size (_tmp5_, (guint) ((1024 * 1024) * 100));
	_tmp6_ = string_to_string (BUILD_NAME);
	_tmp7_ = string_to_string (BUILD_VERSION);
	_tmp8_ = g_strdup_printf ("%u", soup_get_major_version ());
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strdup_printf ("%u", soup_get_minor_version ());
	_tmp11_ = _tmp10_;
	_tmp12_ = g_strdup_printf ("%u", soup_get_micro_version ());
	_tmp13_ = _tmp12_;
	_tmp14_ = g_strdup_printf ("%i", SOUP_MAJOR_VERSION);
	_tmp15_ = _tmp14_;
	_tmp16_ = g_strdup_printf ("%i", SOUP_MINOR_VERSION);
	_tmp17_ = _tmp16_;
	_tmp18_ = g_strdup_printf ("%i", SOUP_MICRO_VERSION);
	_tmp19_ = _tmp18_;
	_tmp20_ = g_strconcat (_tmp6_, "/", _tmp7_, " libsoup/", _tmp9_, ".", _tmp11_, ".", _tmp13_, " (", _tmp15_, ".", _tmp17_, ".", _tmp19_, ")", NULL);
	_tmp21_ = soup_session_new_with_options ("max-conns", 64, "max-conns-per-host", 64, NULL);
	soup_session_set_user_agent (_tmp21_, _tmp20_);
	_g_free0 (_tmp20_);
	_tmp22_ = _tmp21_;
	tuba_network_set_session (self, _tmp22_);
	_g_object_unref0 (_tmp22_);
	_g_free0 (_tmp19_);
	_g_free0 (_tmp17_);
	_g_free0 (_tmp15_);
	_g_free0 (_tmp13_);
	_g_free0 (_tmp11_);
	_g_free0 (_tmp9_);
	_tmp23_ = self->priv->_session;
	_tmp24_ = self->priv->cache;
	soup_session_add_feature (_tmp23_, (SoupSessionFeature*) _tmp24_);
	_tmp25_ = self->priv->_session;
	g_signal_connect_object (_tmp25_, "request-unqueued", (GCallback) __tuba_network___lambda13__soup_session_request_unqueued, self, 0);
	_tmp26_ = tuba_app;
	g_signal_connect_object ((GObject*) _tmp26_, "notify::proxy", (GCallback) _tuba_network_on_proxy_change_g_object_notify, self, 0);
	return obj;
}

static void
tuba_network_class_init (TubaNetworkClass * klass,
                         gpointer klass_data)
{
	tuba_network_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TubaNetwork_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tuba_network_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tuba_network_set_property;
	G_OBJECT_CLASS (klass)->constructor = tuba_network_constructor;
	G_OBJECT_CLASS (klass)->finalize = tuba_network_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TUBA_NETWORK_SESSION_PROPERTY, tuba_network_properties[TUBA_NETWORK_SESSION_PROPERTY] = g_param_spec_object ("session", "session", "session", soup_session_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	tuba_network_signals[TUBA_NETWORK_STARTED_SIGNAL] = g_signal_new ("started", TUBA_TYPE_NETWORK, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	tuba_network_signals[TUBA_NETWORK_FINISHED_SIGNAL] = g_signal_new ("finished", TUBA_TYPE_NETWORK, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
tuba_network_instance_init (TubaNetwork * self,
                            gpointer klass)
{
	self->priv = tuba_network_get_instance_private (self);
	self->priv->requests_processing = 0;
}

static void
tuba_network_finalize (GObject * obj)
{
	TubaNetwork * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TUBA_TYPE_NETWORK, TubaNetwork);
	_g_object_unref0 (self->priv->_session);
	_g_object_unref0 (self->priv->cache);
	G_OBJECT_CLASS (tuba_network_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
tuba_network_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TubaNetworkClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tuba_network_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TubaNetwork), 0, (GInstanceInitFunc) tuba_network_instance_init, NULL };
	GType tuba_network_type_id;
	tuba_network_type_id = g_type_register_static (G_TYPE_OBJECT, "TubaNetwork", &g_define_type_info, G_TYPE_FLAG_NONE);
	TubaNetwork_private_offset = g_type_add_instance_private (tuba_network_type_id, sizeof (TubaNetworkPrivate));
	return tuba_network_type_id;
}

GType
tuba_network_get_type (void)
{
	static GType tuba_network_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_network_type_id__once)) {
		GType tuba_network_type_id;
		tuba_network_type_id = tuba_network_get_type_once ();
		g_once_init_leave_pointer (&tuba_network_type_id__once, tuba_network_type_id);
	}
	return tuba_network_type_id__once;
}

static void
_vala_tuba_network_get_property (GObject * object,
                                 guint property_id,
                                 GValue * value,
                                 GParamSpec * pspec)
{
	TubaNetwork * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TUBA_TYPE_NETWORK, TubaNetwork);
	switch (property_id) {
		case TUBA_NETWORK_SESSION_PROPERTY:
		g_value_set_object (value, tuba_network_get_session (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tuba_network_set_property (GObject * object,
                                 guint property_id,
                                 const GValue * value,
                                 GParamSpec * pspec)
{
	TubaNetwork * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TUBA_TYPE_NETWORK, TubaNetwork);
	switch (property_id) {
		case TUBA_NETWORK_SESSION_PROPERTY:
		tuba_network_set_session (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

