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

#include "shotwell-plugin-common.h"
#include <glib-object.h>
#include "shotwell-plugin-dev-1.0.h"
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <json-glib/json-glib.h>
#include <libsoup/soup.h>
#include <glib/gi18n-lib.h>
#include "shotwell-publishing.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

#define PUBLISHING_YOU_TUBE_TYPE_UPLOAD_TRANSACTION (publishing_you_tube_upload_transaction_get_type ())
#define PUBLISHING_YOU_TUBE_UPLOAD_TRANSACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PUBLISHING_YOU_TUBE_TYPE_UPLOAD_TRANSACTION, PublishingYouTubeUploadTransaction))
#define PUBLISHING_YOU_TUBE_UPLOAD_TRANSACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PUBLISHING_YOU_TUBE_TYPE_UPLOAD_TRANSACTION, PublishingYouTubeUploadTransactionClass))
#define PUBLISHING_YOU_TUBE_IS_UPLOAD_TRANSACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PUBLISHING_YOU_TUBE_TYPE_UPLOAD_TRANSACTION))
#define PUBLISHING_YOU_TUBE_IS_UPLOAD_TRANSACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PUBLISHING_YOU_TUBE_TYPE_UPLOAD_TRANSACTION))
#define PUBLISHING_YOU_TUBE_UPLOAD_TRANSACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PUBLISHING_YOU_TUBE_TYPE_UPLOAD_TRANSACTION, PublishingYouTubeUploadTransactionClass))

typedef struct _PublishingYouTubeUploadTransaction PublishingYouTubeUploadTransaction;
typedef struct _PublishingYouTubeUploadTransactionClass PublishingYouTubeUploadTransactionClass;
typedef struct _PublishingYouTubeUploadTransactionPrivate PublishingYouTubeUploadTransactionPrivate;

#define PUBLISHING_YOU_TUBE_TYPE_PUBLISHING_PARAMETERS (publishing_you_tube_publishing_parameters_get_type ())
#define PUBLISHING_YOU_TUBE_PUBLISHING_PARAMETERS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PUBLISHING_YOU_TUBE_TYPE_PUBLISHING_PARAMETERS, PublishingYouTubePublishingParameters))
#define PUBLISHING_YOU_TUBE_PUBLISHING_PARAMETERS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PUBLISHING_YOU_TUBE_TYPE_PUBLISHING_PARAMETERS, PublishingYouTubePublishingParametersClass))
#define PUBLISHING_YOU_TUBE_IS_PUBLISHING_PARAMETERS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PUBLISHING_YOU_TUBE_TYPE_PUBLISHING_PARAMETERS))
#define PUBLISHING_YOU_TUBE_IS_PUBLISHING_PARAMETERS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PUBLISHING_YOU_TUBE_TYPE_PUBLISHING_PARAMETERS))
#define PUBLISHING_YOU_TUBE_PUBLISHING_PARAMETERS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PUBLISHING_YOU_TUBE_TYPE_PUBLISHING_PARAMETERS, PublishingYouTubePublishingParametersClass))

typedef struct _PublishingYouTubePublishingParameters PublishingYouTubePublishingParameters;
typedef struct _PublishingYouTubePublishingParametersClass PublishingYouTubePublishingParametersClass;
#define _publishing_you_tube_publishing_parameters_unref0(var) ((var == NULL) ? NULL : (var = (publishing_you_tube_publishing_parameters_unref (var), NULL)))
#define _publishing_rest_support_session_unref0(var) ((var == NULL) ? NULL : (var = (publishing_rest_support_session_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _publishing_rest_support_transaction_unref0(var) ((var == NULL) ? NULL : (var = (publishing_rest_support_transaction_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef enum  {
	PUBLISHING_YOU_TUBE_PRIVACY_SETTING_PUBLIC,
	PUBLISHING_YOU_TUBE_PRIVACY_SETTING_UNLISTED,
	PUBLISHING_YOU_TUBE_PRIVACY_SETTING_PRIVATE
} PublishingYouTubePrivacySetting;

#define PUBLISHING_YOU_TUBE_TYPE_PRIVACY_SETTING (publishing_you_tube_privacy_setting_get_type ())
#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)))
#define _soup_message_headers_unref0(var) ((var == NULL) ? NULL : (var = (soup_message_headers_unref (var), NULL)))
#define _g_mapped_file_unref0(var) ((var == NULL) ? NULL : (var = (g_mapped_file_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define __vala_SoupMultipart_free0(var) ((var == NULL) ? NULL : (var = (_vala_SoupMultipart_free (var), NULL)))
typedef struct _PublishingYouTubeUploadTransactionExecuteAsyncData PublishingYouTubeUploadTransactionExecuteAsyncData;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _PublishingYouTubeUploadTransaction {
	PublishingRESTSupportGooglePublisherAuthenticatedTransaction parent_instance;
	PublishingYouTubeUploadTransactionPrivate * priv;
};

struct _PublishingYouTubeUploadTransactionClass {
	PublishingRESTSupportGooglePublisherAuthenticatedTransactionClass parent_class;
};

struct _PublishingYouTubeUploadTransactionPrivate {
	PublishingYouTubePublishingParameters* parameters;
	PublishingRESTSupportGoogleSession* session;
	SpitPublishingPublishable* publishable;
};

struct _PublishingYouTubeUploadTransactionExecuteAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PublishingYouTubeUploadTransaction* self;
	gchar* slug;
	SpitPublishingPublishable* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	SpitPublishingPublishable* _tmp5_;
	gchar* _tmp6_;
	gchar* title;
	SpitPublishingPublishable* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	SpitPublishingPublishable* _tmp10_;
	gchar* _tmp11_;
	JsonBuilder* builder;
	JsonBuilder* _tmp12_;
	JsonBuilder* _tmp13_;
	JsonBuilder* _tmp14_;
	JsonBuilder* _tmp15_;
	JsonBuilder* _tmp16_;
	JsonBuilder* _tmp17_;
	const gchar* _tmp18_;
	JsonBuilder* _tmp19_;
	JsonBuilder* _tmp20_;
	const gchar* _tmp21_;
	JsonBuilder* _tmp22_;
	JsonBuilder* _tmp23_;
	JsonBuilder* _tmp24_;
	JsonBuilder* _tmp25_;
	JsonBuilder* _tmp26_;
	PublishingYouTubePublishingParameters* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	JsonBuilder* _tmp30_;
	JsonBuilder* _tmp31_;
	gchar* meta_data;
	JsonBuilder* _tmp32_;
	JsonNode* _tmp33_;
	JsonNode* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	const gchar* _tmp37_;
	SoupMultipart* message_parts;
	SoupMultipart* _tmp38_;
	SoupMessageHeaders* headers;
	SoupMessageHeaders* _tmp39_;
	GHashTable* encoding;
	GHashFunc _tmp40_;
	GEqualFunc _tmp41_;
	GHashTable* _tmp42_;
	GHashTable* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	SoupMessageHeaders* _tmp46_;
	GHashTable* _tmp47_;
	SoupMultipart* _tmp48_;
	SoupMessageHeaders* _tmp49_;
	const gchar* _tmp50_;
	guint8* _tmp51_;
	gint _tmp51__length1;
	gint _tmp52_;
	guint8* _tmp53_;
	gint _tmp53__length1;
	GBytes* _tmp54_;
	GBytes* _tmp55_;
	SoupMessageHeaders* _tmp56_;
	SoupMessageHeaders* _tmp57_;
	SoupMessageHeaders* _tmp58_;
	GMappedFile* mapped_file;
	GMappedFile* _tmp59_;
	SpitPublishingPublishable* _tmp60_;
	GFile* _tmp61_;
	GFile* _tmp62_;
	gchar* _tmp63_;
	gchar* _tmp64_;
	GMappedFile* _tmp65_;
	GMappedFile* _tmp66_;
	GMappedFile* _tmp67_;
	GError* _tmp68_;
	SoupMultipart* _tmp69_;
	SoupMessageHeaders* _tmp70_;
	GMappedFile* _tmp71_;
	GBytes* _tmp72_;
	GBytes* _tmp73_;
	SoupMessage* outbound_message;
	gchar* _tmp74_;
	gchar* _tmp75_;
	gchar* _tmp76_;
	gchar* _tmp77_;
	gchar* _tmp78_;
	gchar* _tmp79_;
	gchar* _tmp80_;
	gchar* _tmp81_;
	SoupMultipart* _tmp82_;
	SoupMessage* _tmp83_;
	SoupMessage* _tmp84_;
	SoupMessageHeaders* _tmp85_;
	PublishingRESTSupportGoogleSession* _tmp86_;
	gchar* _tmp87_;
	gchar* _tmp88_;
	gchar* _tmp89_;
	gchar* _tmp90_;
	GMappedFile* _tmp91_;
	const gchar* _tmp92_;
	gint _tmp93_;
	gint _tmp94_;
	GError* _inner_error0_;
};

static gint PublishingYouTubeUploadTransaction_private_offset;
static gpointer publishing_you_tube_upload_transaction_parent_class = NULL;

VALA_EXTERN GType publishing_you_tube_upload_transaction_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gpointer publishing_you_tube_publishing_parameters_ref (gpointer instance);
VALA_EXTERN void publishing_you_tube_publishing_parameters_unref (gpointer instance);
VALA_EXTERN GParamSpec* publishing_you_tube_param_spec_publishing_parameters (const gchar* name,
                                                                  const gchar* nick,
                                                                  const gchar* blurb,
                                                                  GType object_type,
                                                                  GParamFlags flags);
VALA_EXTERN void publishing_you_tube_value_set_publishing_parameters (GValue* value,
                                                          gpointer v_object);
VALA_EXTERN void publishing_you_tube_value_take_publishing_parameters (GValue* value,
                                                           gpointer v_object);
VALA_EXTERN gpointer publishing_you_tube_value_get_publishing_parameters (const GValue* value);
VALA_EXTERN GType publishing_you_tube_publishing_parameters_get_type (void) G_GNUC_CONST ;
VALA_EXTERN PublishingYouTubeUploadTransaction* publishing_you_tube_upload_transaction_new (PublishingRESTSupportGoogleSession* session,
                                                                                PublishingYouTubePublishingParameters* parameters,
                                                                                SpitPublishingPublishable* publishable);
VALA_EXTERN PublishingYouTubeUploadTransaction* publishing_you_tube_upload_transaction_construct (GType object_type,
                                                                                      PublishingRESTSupportGoogleSession* session,
                                                                                      PublishingYouTubePublishingParameters* parameters,
                                                                                      SpitPublishingPublishable* publishable);
static void publishing_you_tube_upload_transaction_real_execute_async_data_free (gpointer _data);
static void publishing_you_tube_upload_transaction_real_execute_async (PublishingRESTSupportTransaction* base,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_);
static gboolean publishing_you_tube_upload_transaction_real_execute_async_co (PublishingYouTubeUploadTransactionExecuteAsyncData* _data_);
VALA_EXTERN GType publishing_you_tube_privacy_setting_get_type (void) G_GNUC_CONST ;
VALA_EXTERN PublishingYouTubePrivacySetting publishing_you_tube_publishing_parameters_get_privacy (PublishingYouTubePublishingParameters* self);
VALA_EXTERN gchar* publishing_you_tube_privacy_setting_to_string (PublishingYouTubePrivacySetting self);
static void _vala_JsonNode_free (JsonNode* self);
static void _g_free0_ (gpointer var);
static void _vala_SoupMultipart_free (SoupMultipart* self);
static void publishing_you_tube_upload_transaction_execute_async_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_);
static void publishing_you_tube_upload_transaction_finalize (PublishingRESTSupportTransaction * obj);
static GType publishing_you_tube_upload_transaction_get_type_once (void);

static inline gpointer
publishing_you_tube_upload_transaction_get_instance_private (PublishingYouTubeUploadTransaction* self)
{
	return G_STRUCT_MEMBER_P (self, PublishingYouTubeUploadTransaction_private_offset);
}

static gpointer
_publishing_rest_support_session_ref0 (gpointer self)
{
	return self ? publishing_rest_support_session_ref (self) : NULL;
}

static gpointer
_publishing_you_tube_publishing_parameters_ref0 (gpointer self)
{
	return self ? publishing_you_tube_publishing_parameters_ref (self) : NULL;
}

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

PublishingYouTubeUploadTransaction*
publishing_you_tube_upload_transaction_construct (GType object_type,
                                                  PublishingRESTSupportGoogleSession* session,
                                                  PublishingYouTubePublishingParameters* parameters,
                                                  SpitPublishingPublishable* publishable)
{
	PublishingYouTubeUploadTransaction* self = NULL;
	PublishingRESTSupportGoogleSession* _tmp0_;
	PublishingYouTubePublishingParameters* _tmp1_;
	SpitPublishingPublishable* _tmp2_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (session, PUBLISHING_REST_SUPPORT_TYPE_GOOGLE_SESSION), NULL);
	g_return_val_if_fail (PUBLISHING_YOU_TUBE_IS_PUBLISHING_PARAMETERS (parameters), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (publishable, SPIT_PUBLISHING_TYPE_PUBLISHABLE), NULL);
	self = (PublishingYouTubeUploadTransaction*) publishing_rest_support_google_publisher_authenticated_transaction_construct (object_type, session, "https://www.googleapis.com/upload/youtube/v3/videos", PUBLISHING_REST_SUPPORT_HTTP_METHOD_POST);
	_vala_assert (publishing_rest_support_session_is_authenticated (G_TYPE_CHECK_INSTANCE_CAST (session, PUBLISHING_REST_SUPPORT_TYPE_SESSION, PublishingRESTSupportSession)), "session.is_authenticated()");
	_tmp0_ = _publishing_rest_support_session_ref0 (session);
	_publishing_rest_support_session_unref0 (self->priv->session);
	self->priv->session = _tmp0_;
	_tmp1_ = _publishing_you_tube_publishing_parameters_ref0 (parameters);
	_publishing_you_tube_publishing_parameters_unref0 (self->priv->parameters);
	self->priv->parameters = _tmp1_;
	_tmp2_ = _g_object_ref0 (publishable);
	_g_object_unref0 (self->priv->publishable);
	self->priv->publishable = _tmp2_;
	return self;
}

PublishingYouTubeUploadTransaction*
publishing_you_tube_upload_transaction_new (PublishingRESTSupportGoogleSession* session,
                                            PublishingYouTubePublishingParameters* parameters,
                                            SpitPublishingPublishable* publishable)
{
	return publishing_you_tube_upload_transaction_construct (PUBLISHING_YOU_TUBE_TYPE_UPLOAD_TRANSACTION, session, parameters, publishable);
}

static void
publishing_you_tube_upload_transaction_real_execute_async_data_free (gpointer _data)
{
	PublishingYouTubeUploadTransactionExecuteAsyncData* _data_;
	_data_ = _data;
	_publishing_rest_support_transaction_unref0 (_data_->self);
	g_slice_free (PublishingYouTubeUploadTransactionExecuteAsyncData, _data_);
}

static gpointer
_publishing_rest_support_transaction_ref0 (gpointer self)
{
	return self ? publishing_rest_support_transaction_ref (self) : NULL;
}

static void
publishing_you_tube_upload_transaction_real_execute_async (PublishingRESTSupportTransaction* base,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_)
{
	PublishingYouTubeUploadTransaction * self;
	PublishingYouTubeUploadTransactionExecuteAsyncData* _data_;
	PublishingYouTubeUploadTransaction* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, PUBLISHING_YOU_TUBE_TYPE_UPLOAD_TRANSACTION, PublishingYouTubeUploadTransaction);
	_data_ = g_slice_new0 (PublishingYouTubeUploadTransactionExecuteAsyncData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, publishing_you_tube_upload_transaction_real_execute_async_data_free);
	_tmp0_ = _publishing_rest_support_transaction_ref0 (self);
	_data_->self = _tmp0_;
	publishing_you_tube_upload_transaction_real_execute_async_co (_data_);
}

static void
publishing_you_tube_upload_transaction_execute_finish (PublishingRESTSupportTransaction* base,
                                                       GAsyncResult* _res_,
                                                       GError** error)
{
	PublishingYouTubeUploadTransactionExecuteAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

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

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static guint8*
string_get_data (const gchar* self,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res;
	_tmp2__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static void
_vala_SoupMultipart_free (SoupMultipart* self)
{
	g_boxed_free (soup_multipart_get_type (), self);
}

static void
publishing_you_tube_upload_transaction_execute_async_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_)
{
	PublishingYouTubeUploadTransactionExecuteAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	publishing_you_tube_upload_transaction_real_execute_async_co (_data_);
}

static gboolean
publishing_you_tube_upload_transaction_real_execute_async_co (PublishingYouTubeUploadTransactionExecuteAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->publishable;
	_data_->_tmp1_ = spit_publishing_publishable_get_param_string (_data_->_tmp0_, SPIT_PUBLISHING_PUBLISHABLE_PARAM_STRING_COMMENT);
	_data_->slug = _data_->_tmp1_;
	_data_->_tmp3_ = _data_->slug;
	if (_data_->_tmp3_ == NULL) {
		_data_->_tmp2_ = TRUE;
	} else {
		_data_->_tmp4_ = _data_->slug;
		_data_->_tmp2_ = g_strcmp0 (_data_->_tmp4_, "") == 0;
	}
	if (_data_->_tmp2_) {
		_data_->_tmp5_ = _data_->self->priv->publishable;
		_data_->_tmp6_ = spit_publishing_publishable_get_param_string (_data_->_tmp5_, SPIT_PUBLISHING_PUBLISHABLE_PARAM_STRING_BASENAME);
		_g_free0 (_data_->slug);
		_data_->slug = _data_->_tmp6_;
	}
	_data_->_tmp7_ = _data_->self->priv->publishable;
	_data_->_tmp8_ = spit_publishing_publishable_get_publishing_name (_data_->_tmp7_);
	_data_->title = _data_->_tmp8_;
	_data_->_tmp9_ = _data_->title;
	if (g_strcmp0 (_data_->_tmp9_, "") == 0) {
		_data_->_tmp10_ = _data_->self->priv->publishable;
		_data_->_tmp11_ = spit_publishing_publishable_get_param_string (_data_->_tmp10_, SPIT_PUBLISHING_PUBLISHABLE_PARAM_STRING_BASENAME);
		_g_free0 (_data_->title);
		_data_->title = _data_->_tmp11_;
	}
	_data_->_tmp12_ = json_builder_new ();
	_data_->builder = _data_->_tmp12_;
	_data_->_tmp13_ = _data_->builder;
	json_builder_begin_object (_data_->_tmp13_);
	_data_->_tmp14_ = _data_->builder;
	json_builder_set_member_name (_data_->_tmp14_, "snippet");
	_data_->_tmp15_ = _data_->builder;
	json_builder_begin_object (_data_->_tmp15_);
	_data_->_tmp16_ = _data_->builder;
	json_builder_set_member_name (_data_->_tmp16_, "description");
	_data_->_tmp17_ = _data_->builder;
	_data_->_tmp18_ = _data_->slug;
	json_builder_add_string_value (_data_->_tmp17_, _data_->_tmp18_);
	_data_->_tmp19_ = _data_->builder;
	json_builder_set_member_name (_data_->_tmp19_, "title");
	_data_->_tmp20_ = _data_->builder;
	_data_->_tmp21_ = _data_->title;
	json_builder_add_string_value (_data_->_tmp20_, _data_->_tmp21_);
	_data_->_tmp22_ = _data_->builder;
	json_builder_end_object (_data_->_tmp22_);
	_data_->_tmp23_ = _data_->builder;
	json_builder_set_member_name (_data_->_tmp23_, "status");
	_data_->_tmp24_ = _data_->builder;
	json_builder_begin_object (_data_->_tmp24_);
	_data_->_tmp25_ = _data_->builder;
	json_builder_set_member_name (_data_->_tmp25_, "privacyStatus");
	_data_->_tmp26_ = _data_->builder;
	_data_->_tmp27_ = _data_->self->priv->parameters;
	_data_->_tmp28_ = publishing_you_tube_privacy_setting_to_string (publishing_you_tube_publishing_parameters_get_privacy (_data_->_tmp27_));
	_data_->_tmp29_ = _data_->_tmp28_;
	json_builder_add_string_value (_data_->_tmp26_, _data_->_tmp29_);
	_g_free0 (_data_->_tmp29_);
	_data_->_tmp30_ = _data_->builder;
	json_builder_end_object (_data_->_tmp30_);
	_data_->_tmp31_ = _data_->builder;
	json_builder_end_object (_data_->_tmp31_);
	_data_->_tmp32_ = _data_->builder;
	_data_->_tmp33_ = json_builder_get_root (_data_->_tmp32_);
	_data_->_tmp34_ = _data_->_tmp33_;
	_data_->_tmp35_ = json_to_string (_data_->_tmp34_, FALSE);
	_data_->_tmp36_ = _data_->_tmp35_;
	__vala_JsonNode_free0 (_data_->_tmp34_);
	_data_->meta_data = _data_->_tmp36_;
	_data_->_tmp37_ = _data_->meta_data;
	g_debug ("YoutubeUploader.vala:48: Parameters: %s", _data_->_tmp37_);
	_data_->_tmp38_ = soup_multipart_new ("multipart/related");
	_data_->message_parts = _data_->_tmp38_;
	_data_->_tmp39_ = soup_message_headers_new (SOUP_MESSAGE_HEADERS_MULTIPART);
	_data_->headers = _data_->_tmp39_;
	_data_->_tmp40_ = g_str_hash;
	_data_->_tmp41_ = g_str_equal;
	_data_->_tmp42_ = g_hash_table_new_full (_data_->_tmp40_, _data_->_tmp41_, _g_free0_, _g_free0_);
	_data_->encoding = _data_->_tmp42_;
	_data_->_tmp43_ = _data_->encoding;
	_data_->_tmp44_ = g_strdup ("encoding");
	_data_->_tmp45_ = g_strdup ("UTF-8");
	g_hash_table_insert (_data_->_tmp43_, _data_->_tmp44_, _data_->_tmp45_);
	_data_->_tmp46_ = _data_->headers;
	_data_->_tmp47_ = _data_->encoding;
	soup_message_headers_set_content_type (_data_->_tmp46_, "application/json", _data_->_tmp47_);
	_data_->_tmp48_ = _data_->message_parts;
	_data_->_tmp49_ = _data_->headers;
	_data_->_tmp50_ = _data_->meta_data;
	_data_->_tmp52_ = 0;
	_data_->_tmp51_ = string_get_data (_data_->_tmp50_, &_data_->_tmp52_);
	_data_->_tmp51__length1 = _data_->_tmp52_;
	_data_->_tmp53_ = _data_->_tmp51_;
	_data_->_tmp53__length1 = _data_->_tmp51__length1;
	_data_->_tmp54_ = g_bytes_new (_data_->_tmp53_, _data_->_tmp53__length1);
	_data_->_tmp55_ = _data_->_tmp54_;
	soup_multipart_append_part (_data_->_tmp48_, _data_->_tmp49_, _data_->_tmp55_);
	_g_bytes_unref0 (_data_->_tmp55_);
	_data_->_tmp56_ = soup_message_headers_new (SOUP_MESSAGE_HEADERS_MULTIPART);
	_soup_message_headers_unref0 (_data_->headers);
	_data_->headers = _data_->_tmp56_;
	_data_->_tmp57_ = _data_->headers;
	soup_message_headers_set_content_type (_data_->_tmp57_, "application/octet-stream", NULL);
	_data_->_tmp58_ = _data_->headers;
	soup_message_headers_append (_data_->_tmp58_, "Content-Transfer-Encoding", "binary");
	_data_->mapped_file = NULL;
	{
		_data_->_tmp60_ = _data_->self->priv->publishable;
		_data_->_tmp61_ = spit_publishing_publishable_get_serialized_file (_data_->_tmp60_);
		_data_->_tmp62_ = _data_->_tmp61_;
		_data_->_tmp63_ = g_file_get_path (_data_->_tmp62_);
		_data_->_tmp64_ = _data_->_tmp63_;
		_data_->_tmp65_ = g_mapped_file_new (_data_->_tmp64_, FALSE, &_data_->_inner_error0_);
		_data_->_tmp66_ = _data_->_tmp65_;
		_g_free0 (_data_->_tmp64_);
		_g_object_unref0 (_data_->_tmp62_);
		_data_->_tmp59_ = _data_->_tmp66_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp67_ = _data_->_tmp59_;
		_data_->_tmp59_ = NULL;
		_g_mapped_file_unref0 (_data_->mapped_file);
		_data_->mapped_file = _data_->_tmp67_;
		_g_mapped_file_unref0 (_data_->_tmp59_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
		_data_->_tmp68_ = g_error_new_literal (SPIT_PUBLISHING_PUBLISHING_ERROR, SPIT_PUBLISHING_PUBLISHING_ERROR_LOCAL_FILE_ERROR, _ ("A temporary file needed for publishing is unavailable"));
		_data_->_inner_error0_ = _data_->_tmp68_;
		goto __finally0;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		if (_data_->_inner_error0_->domain == SPIT_PUBLISHING_PUBLISHING_ERROR) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_mapped_file_unref0 (_data_->mapped_file);
			_g_hash_table_unref0 (_data_->encoding);
			_soup_message_headers_unref0 (_data_->headers);
			__vala_SoupMultipart_free0 (_data_->message_parts);
			_g_free0 (_data_->meta_data);
			_g_object_unref0 (_data_->builder);
			_g_free0 (_data_->title);
			_g_free0 (_data_->slug);
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_mapped_file_unref0 (_data_->mapped_file);
			_g_hash_table_unref0 (_data_->encoding);
			_soup_message_headers_unref0 (_data_->headers);
			__vala_SoupMultipart_free0 (_data_->message_parts);
			_g_free0 (_data_->meta_data);
			_g_object_unref0 (_data_->builder);
			_g_free0 (_data_->title);
			_g_free0 (_data_->slug);
			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_->_tmp69_ = _data_->message_parts;
	_data_->_tmp70_ = _data_->headers;
	_data_->_tmp71_ = _data_->mapped_file;
	_data_->_tmp72_ = g_mapped_file_get_bytes (_data_->_tmp71_);
	_data_->_tmp73_ = _data_->_tmp72_;
	soup_multipart_append_part (_data_->_tmp69_, _data_->_tmp70_, _data_->_tmp73_);
	_g_bytes_unref0 (_data_->_tmp73_);
	_data_->_tmp74_ = publishing_rest_support_transaction_get_endpoint_url (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PUBLISHING_REST_SUPPORT_TYPE_TRANSACTION, PublishingRESTSupportTransaction));
	_data_->_tmp75_ = _data_->_tmp74_;
	_data_->_tmp76_ = g_strconcat (_data_->_tmp75_, "?part=", NULL);
	_data_->_tmp77_ = _data_->_tmp76_;
	_data_->_tmp78_ = g_uri_escape_string ("snippet,status", NULL, TRUE);
	_data_->_tmp79_ = _data_->_tmp78_;
	_data_->_tmp80_ = g_strconcat (_data_->_tmp77_, _data_->_tmp79_, NULL);
	_data_->_tmp81_ = _data_->_tmp80_;
	_data_->_tmp82_ = _data_->message_parts;
	_data_->_tmp83_ = soup_message_new_from_multipart (_data_->_tmp81_, _data_->_tmp82_);
	_data_->_tmp84_ = _data_->_tmp83_;
	_g_free0 (_data_->_tmp81_);
	_g_free0 (_data_->_tmp79_);
	_g_free0 (_data_->_tmp77_);
	_g_free0 (_data_->_tmp75_);
	_data_->outbound_message = _data_->_tmp84_;
	_data_->_tmp85_ = soup_message_get_request_headers (_data_->outbound_message);
	_data_->_tmp86_ = _data_->self->priv->session;
	_data_->_tmp87_ = publishing_rest_support_google_session_get_access_token (_data_->_tmp86_);
	_data_->_tmp88_ = _data_->_tmp87_;
	_data_->_tmp89_ = g_strconcat ("Bearer ", _data_->_tmp88_, NULL);
	_data_->_tmp90_ = _data_->_tmp89_;
	soup_message_headers_append (_data_->_tmp85_, "Authorization", _data_->_tmp90_);
	_g_free0 (_data_->_tmp90_);
	_g_free0 (_data_->_tmp88_);
	_data_->_tmp91_ = _data_->mapped_file;
	_data_->_tmp92_ = _data_->meta_data;
	_data_->_tmp93_ = strlen (_data_->_tmp92_);
	_data_->_tmp94_ = _data_->_tmp93_;
	publishing_rest_support_transaction_set_message (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PUBLISHING_REST_SUPPORT_TYPE_TRANSACTION, PublishingRESTSupportTransaction), _data_->outbound_message, (gulong) (g_mapped_file_get_length (_data_->_tmp91_) + _data_->_tmp94_));
	publishing_rest_support_transaction_set_is_executed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PUBLISHING_REST_SUPPORT_TYPE_TRANSACTION, PublishingRESTSupportTransaction), TRUE);
	_data_->_state_ = 1;
	publishing_rest_support_transaction_send_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PUBLISHING_REST_SUPPORT_TYPE_TRANSACTION, PublishingRESTSupportTransaction), publishing_you_tube_upload_transaction_execute_async_ready, _data_);
	return FALSE;
	_state_1:
	publishing_rest_support_transaction_send_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PUBLISHING_REST_SUPPORT_TYPE_TRANSACTION, PublishingRESTSupportTransaction), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		if (_data_->_inner_error0_->domain == SPIT_PUBLISHING_PUBLISHING_ERROR) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->outbound_message);
			_g_mapped_file_unref0 (_data_->mapped_file);
			_g_hash_table_unref0 (_data_->encoding);
			_soup_message_headers_unref0 (_data_->headers);
			__vala_SoupMultipart_free0 (_data_->message_parts);
			_g_free0 (_data_->meta_data);
			_g_object_unref0 (_data_->builder);
			_g_free0 (_data_->title);
			_g_free0 (_data_->slug);
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_object_unref0 (_data_->outbound_message);
			_g_mapped_file_unref0 (_data_->mapped_file);
			_g_hash_table_unref0 (_data_->encoding);
			_soup_message_headers_unref0 (_data_->headers);
			__vala_SoupMultipart_free0 (_data_->message_parts);
			_g_free0 (_data_->meta_data);
			_g_object_unref0 (_data_->builder);
			_g_free0 (_data_->title);
			_g_free0 (_data_->slug);
			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_object_unref0 (_data_->outbound_message);
	_g_mapped_file_unref0 (_data_->mapped_file);
	_g_hash_table_unref0 (_data_->encoding);
	_soup_message_headers_unref0 (_data_->headers);
	__vala_SoupMultipart_free0 (_data_->message_parts);
	_g_free0 (_data_->meta_data);
	_g_object_unref0 (_data_->builder);
	_g_free0 (_data_->title);
	_g_free0 (_data_->slug);
	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
publishing_you_tube_upload_transaction_class_init (PublishingYouTubeUploadTransactionClass * klass,
                                                   gpointer klass_data)
{
	publishing_you_tube_upload_transaction_parent_class = g_type_class_peek_parent (klass);
	((PublishingRESTSupportTransactionClass *) klass)->finalize = publishing_you_tube_upload_transaction_finalize;
	g_type_class_adjust_private_offset (klass, &PublishingYouTubeUploadTransaction_private_offset);
	((PublishingRESTSupportTransactionClass *) klass)->execute_async = (void (*) (PublishingRESTSupportTransaction*, GAsyncReadyCallback, gpointer)) publishing_you_tube_upload_transaction_real_execute_async;
	((PublishingRESTSupportTransactionClass *) klass)->execute_finish = (void (*) (PublishingRESTSupportTransaction*, GAsyncResult*, GError**)) publishing_you_tube_upload_transaction_execute_finish;
}

static void
publishing_you_tube_upload_transaction_instance_init (PublishingYouTubeUploadTransaction * self,
                                                      gpointer klass)
{
	self->priv = publishing_you_tube_upload_transaction_get_instance_private (self);
}

static void
publishing_you_tube_upload_transaction_finalize (PublishingRESTSupportTransaction * obj)
{
	PublishingYouTubeUploadTransaction * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PUBLISHING_YOU_TUBE_TYPE_UPLOAD_TRANSACTION, PublishingYouTubeUploadTransaction);
	_publishing_you_tube_publishing_parameters_unref0 (self->priv->parameters);
	_publishing_rest_support_session_unref0 (self->priv->session);
	_g_object_unref0 (self->priv->publishable);
	PUBLISHING_REST_SUPPORT_TRANSACTION_CLASS (publishing_you_tube_upload_transaction_parent_class)->finalize (obj);
}

static GType
publishing_you_tube_upload_transaction_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PublishingYouTubeUploadTransactionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) publishing_you_tube_upload_transaction_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PublishingYouTubeUploadTransaction), 0, (GInstanceInitFunc) publishing_you_tube_upload_transaction_instance_init, NULL };
	GType publishing_you_tube_upload_transaction_type_id;
	publishing_you_tube_upload_transaction_type_id = g_type_register_static (PUBLISHING_REST_SUPPORT_GOOGLE_PUBLISHER_TYPE_AUTHENTICATED_TRANSACTION, "PublishingYouTubeUploadTransaction", &g_define_type_info, 0);
	PublishingYouTubeUploadTransaction_private_offset = g_type_add_instance_private (publishing_you_tube_upload_transaction_type_id, sizeof (PublishingYouTubeUploadTransactionPrivate));
	return publishing_you_tube_upload_transaction_type_id;
}

GType
publishing_you_tube_upload_transaction_get_type (void)
{
	static volatile gsize publishing_you_tube_upload_transaction_type_id__once = 0;
	if (g_once_init_enter (&publishing_you_tube_upload_transaction_type_id__once)) {
		GType publishing_you_tube_upload_transaction_type_id;
		publishing_you_tube_upload_transaction_type_id = publishing_you_tube_upload_transaction_get_type_once ();
		g_once_init_leave (&publishing_you_tube_upload_transaction_type_id__once, publishing_you_tube_upload_transaction_type_id);
	}
	return publishing_you_tube_upload_transaction_type_id__once;
}

