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

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

#define TOOTLE_TYPE_WIDGETIZABLE (tootle_widgetizable_get_type ())
#define TOOTLE_WIDGETIZABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_WIDGETIZABLE, TootleWidgetizable))
#define TOOTLE_IS_WIDGETIZABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_WIDGETIZABLE))
#define TOOTLE_WIDGETIZABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TOOTLE_TYPE_WIDGETIZABLE, TootleWidgetizableIface))

typedef struct _TootleWidgetizable TootleWidgetizable;
typedef struct _TootleWidgetizableIface TootleWidgetizableIface;

#define TOOTLE_TYPE_ENTITY (tootle_entity_get_type ())
#define TOOTLE_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_ENTITY, TootleEntity))
#define TOOTLE_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_ENTITY, TootleEntityClass))
#define TOOTLE_IS_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_ENTITY))
#define TOOTLE_IS_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_ENTITY))
#define TOOTLE_ENTITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_ENTITY, TootleEntityClass))

typedef struct _TootleEntity TootleEntity;
typedef struct _TootleEntityClass TootleEntityClass;

#define TOOTLE_API_TYPE_ACCOUNT (tootle_api_account_get_type ())
#define TOOTLE_API_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_ACCOUNT, TootleAPIAccount))
#define TOOTLE_API_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_ACCOUNT, TootleAPIAccountClass))
#define TOOTLE_API_IS_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_ACCOUNT))
#define TOOTLE_API_IS_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_ACCOUNT))
#define TOOTLE_API_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_ACCOUNT, TootleAPIAccountClass))

typedef struct _TootleAPIAccount TootleAPIAccount;
typedef struct _TootleAPIAccountClass TootleAPIAccountClass;

#define TOOTLE_TYPE_INSTANCE_ACCOUNT (tootle_instance_account_get_type ())
#define TOOTLE_INSTANCE_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_INSTANCE_ACCOUNT, TootleInstanceAccount))
#define TOOTLE_INSTANCE_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_INSTANCE_ACCOUNT, TootleInstanceAccountClass))
#define TOOTLE_IS_INSTANCE_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_INSTANCE_ACCOUNT))
#define TOOTLE_IS_INSTANCE_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_INSTANCE_ACCOUNT))
#define TOOTLE_INSTANCE_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_INSTANCE_ACCOUNT, TootleInstanceAccountClass))

typedef struct _TootleInstanceAccount TootleInstanceAccount;
typedef struct _TootleInstanceAccountClass TootleInstanceAccountClass;
typedef struct _TootleEntityPrivate TootleEntityPrivate;

#define TOOTLE_API_TYPE_ATTACHMENT (tootle_api_attachment_get_type ())
#define TOOTLE_API_ATTACHMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_ATTACHMENT, TootleAPIAttachment))
#define TOOTLE_API_ATTACHMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_ATTACHMENT, TootleAPIAttachmentClass))
#define TOOTLE_API_IS_ATTACHMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_ATTACHMENT))
#define TOOTLE_API_IS_ATTACHMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_ATTACHMENT))
#define TOOTLE_API_ATTACHMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_ATTACHMENT, TootleAPIAttachmentClass))

typedef struct _TootleAPIAttachment TootleAPIAttachment;
typedef struct _TootleAPIAttachmentClass TootleAPIAttachmentClass;
typedef struct _TootleAPIAttachmentPrivate TootleAPIAttachmentPrivate;
enum  {
	TOOTLE_API_ATTACHMENT_0_PROPERTY,
	TOOTLE_API_ATTACHMENT_ID_PROPERTY,
	TOOTLE_API_ATTACHMENT_KIND_PROPERTY,
	TOOTLE_API_ATTACHMENT_URL_PROPERTY,
	TOOTLE_API_ATTACHMENT_DESCRIPTION_PROPERTY,
	TOOTLE_API_ATTACHMENT_PREVIEW_URL_PROPERTY,
	TOOTLE_API_ATTACHMENT_NUM_PROPERTIES
};
static GParamSpec* tootle_api_attachment_properties[TOOTLE_API_ATTACHMENT_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block19Data Block19Data;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define TOOTLE_TYPE_ACCOUNTS (tootle_accounts_get_type ())
#define TOOTLE_ACCOUNTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_ACCOUNTS, TootleAccounts))
#define TOOTLE_ACCOUNTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_ACCOUNTS, TootleAccountsClass))
#define TOOTLE_IS_ACCOUNTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_ACCOUNTS))
#define TOOTLE_IS_ACCOUNTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_ACCOUNTS))
#define TOOTLE_ACCOUNTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_ACCOUNTS, TootleAccountsClass))

typedef struct _TootleAccounts TootleAccounts;
typedef struct _TootleAccountsClass TootleAccountsClass;

#define TOOTLE_TYPE_NETWORK (tootle_network_get_type ())
#define TOOTLE_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_NETWORK, TootleNetwork))
#define TOOTLE_NETWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_NETWORK, TootleNetworkClass))
#define TOOTLE_IS_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_NETWORK))
#define TOOTLE_IS_NETWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_NETWORK))
#define TOOTLE_NETWORK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_NETWORK, TootleNetworkClass))

typedef struct _TootleNetwork TootleNetwork;
typedef struct _TootleNetworkClass TootleNetworkClass;
typedef void (*TootleNetworkSuccessCallback) (SoupSession* session, SoupMessage* msg, gpointer user_data, GError** error);
typedef void (*TootleNetworkErrorCallback) (gint32 code, const gchar* reason, gpointer user_data);
#define __vala_SoupMultipart_free0(var) ((var == NULL) ? NULL : (var = (_vala_SoupMultipart_free (var), NULL)))
#define __vala_SoupBuffer_free0(var) ((var == NULL) ? NULL : (var = (_vala_SoupBuffer_free (var), NULL)))
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
typedef struct _TootleApiAttachmentUploadData TootleApiAttachmentUploadData;

typedef enum  {
	TOOTLE_OOPSIE_USER,
	TOOTLE_OOPSIE_PARSING,
	TOOTLE_OOPSIE_INSTANCE,
	TOOTLE_OOPSIE_INTERNAL
} TootleOopsie;
#define TOOTLE_OOPSIE tootle_oopsie_quark ()
struct _TootleWidgetizableIface {
	GTypeInterface parent_iface;
	GtkWidget* (*to_widget) (TootleWidgetizable* self, GError** error);
	void (*open) (TootleWidgetizable* self);
	void (*resolve_open) (TootleWidgetizable* self, TootleInstanceAccount* account);
};

struct _TootleEntity {
	GObject parent_instance;
	TootleEntityPrivate * priv;
};

struct _TootleEntityClass {
	GObjectClass parent_class;
	gboolean (*is_local) (TootleEntity* self, TootleInstanceAccount* account);
};

struct _TootleAPIAttachment {
	TootleEntity parent_instance;
	TootleAPIAttachmentPrivate * priv;
};

struct _TootleAPIAttachmentClass {
	TootleEntityClass parent_class;
};

struct _TootleAPIAttachmentPrivate {
	gchar* _id;
	gchar* _kind;
	gchar* _url;
	gchar* _description;
	gchar* __preview_url;
};

struct _Block19Data {
	int _ref_count_;
	gchar* _error_;
	gpointer _async_data_;
};

struct _TootleApiAttachmentUploadData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gchar* uri;
	gchar* title;
	gchar* descr;
	TootleAPIAttachment* result;
	Block19Data* _data19_;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	guint8* contents;
	gint contents_length1;
	gint _contents_size_;
	gchar* mime;
	GFileInfo* type;
	GFile* file;
	GFile* _tmp3_;
	GFile* _tmp4_;
	guint8* _tmp5_;
	gsize _tmp6_;
	GFileInfo* _tmp7_;
	GFile* _tmp8_;
	GFileInfo* _tmp9_;
	GFileInfo* _tmp10_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	GError* e;
	gchar* _tmp13_;
	gchar* _tmp14_;
	GError* _tmp15_;
	const gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	GError* _tmp19_;
	GError* _tmp20_;
	gchar* descr_param;
	gchar* _tmp21_;
	gboolean _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	SoupBuffer* buffer;
	guint8* _tmp28_;
	gint _tmp28__length1;
	guint8* _tmp29_;
	gint _tmp29__length1;
	SoupBuffer* _tmp30_;
	SoupMultipart* multipart;
	SoupMultipart* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* url;
	TootleAccounts* _tmp34_;
	TootleInstanceAccount* _tmp35_;
	TootleInstanceAccount* _tmp36_;
	const gchar* _tmp37_;
	const gchar* _tmp38_;
	const gchar* _tmp39_;
	const gchar* _tmp40_;
	const gchar* _tmp41_;
	gchar* _tmp42_;
	SoupMessage* msg;
	SoupMessage* _tmp43_;
	SoupMessageHeaders* _tmp44_;
	TootleAccounts* _tmp45_;
	TootleInstanceAccount* _tmp46_;
	TootleInstanceAccount* _tmp47_;
	const gchar* _tmp48_;
	const gchar* _tmp49_;
	const gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	TootleNetwork* _tmp53_;
	SoupMessage* _tmp54_;
	GError* _tmp55_;
	JsonNode* node;
	TootleNetwork* _tmp56_;
	JsonNode* _tmp57_;
	TootleAPIAttachment* entity;
	JsonNode* _tmp58_;
	TootleAPIAttachment* _tmp59_;
	TootleAPIAttachment* _tmp60_;
	const gchar* _tmp61_;
	const gchar* _tmp62_;
	gchar* _tmp63_;
	gchar* _tmp64_;
	GError* _inner_error0_;
};

static gint TootleAPIAttachment_private_offset;
static gpointer tootle_api_attachment_parent_class = NULL;
extern TootleAccounts* tootle_accounts;
extern TootleNetwork* tootle_network;

GQuark tootle_oopsie_quark (void);
GType tootle_entity_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleEntity, g_object_unref)
GType tootle_api_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIAccount, g_object_unref)
GType tootle_instance_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleInstanceAccount, g_object_unref)
GType tootle_widgetizable_get_type (void) G_GNUC_CONST ;
GType tootle_api_attachment_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIAttachment, g_object_unref)
TootleAPIAttachment* tootle_api_attachment_from (JsonNode* node,
                                                 GError** error);
TootleEntity* tootle_entity_from_json (GType type,
                                       JsonNode* node,
                                       GError** error);
static void tootle_api_attachment_upload_data_free (gpointer _data);
void tootle_api_attachment_upload (const gchar* uri,
                                   const gchar* title,
                                   const gchar* descr,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
TootleAPIAttachment* tootle_api_attachment_upload_finish (GAsyncResult* _res_,
                                                          GError** error);
static gboolean tootle_api_attachment_upload_co (TootleApiAttachmentUploadData* _data_);
static Block19Data* block19_data_ref (Block19Data* _data19_);
static void block19_data_unref (void * _userdata_);
gchar* tootle_html_utils_uri_encode (const gchar* str);
static guint8* _vala_array_dup4 (guint8* self,
                          gint length);
GType tootle_accounts_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAccounts, g_object_unref)
TootleInstanceAccount* tootle_accounts_get_active (TootleAccounts* self);
const gchar* tootle_instance_account_get_instance (TootleInstanceAccount* self);
const gchar* tootle_instance_account_get_access_token (TootleInstanceAccount* self);
GType tootle_network_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleNetwork, g_object_unref)
void tootle_network_queue (TootleNetwork* self,
                           SoupMessage* mess,
                           TootleNetworkSuccessCallback cb,
                           gpointer cb_target,
                           GDestroyNotify cb_target_destroy_notify,
                           TootleNetworkErrorCallback ecb,
                           gpointer ecb_target,
                           GDestroyNotify ecb_target_destroy_notify);
static void __lambda96_ (Block19Data* _data19_,
                  SoupSession* sess,
                  SoupMessage* mess,
                  GError** error);
static void ___lambda96__tootle_network_success_callback (SoupSession* session,
                                                   SoupMessage* msg,
                                                   gpointer self,
                                                   GError** error);
static void __lambda97_ (Block19Data* _data19_,
                  gint32 code,
                  const gchar* reason);
static void ___lambda97__tootle_network_error_callback (gint32 code,
                                                 const gchar* reason,
                                                 gpointer self);
static void _vala_SoupMultipart_free (SoupMultipart* self);
static void _vala_SoupBuffer_free (SoupBuffer* self);
JsonNode* tootle_network_parse_node (TootleNetwork* self,
                                     SoupMessage* msg,
                                     GError** error);
static void _vala_JsonNode_free (JsonNode* self);
const gchar* tootle_api_attachment_get_id (TootleAPIAttachment* self);
TootleAPIAttachment* tootle_api_attachment_new (void);
TootleAPIAttachment* tootle_api_attachment_construct (GType object_type);
TootleEntity* tootle_entity_new (void);
TootleEntity* tootle_entity_construct (GType object_type);
void tootle_api_attachment_set_id (TootleAPIAttachment* self,
                                   const gchar* value);
const gchar* tootle_api_attachment_get_kind (TootleAPIAttachment* self);
void tootle_api_attachment_set_kind (TootleAPIAttachment* self,
                                     const gchar* value);
const gchar* tootle_api_attachment_get_url (TootleAPIAttachment* self);
void tootle_api_attachment_set_url (TootleAPIAttachment* self,
                                    const gchar* value);
const gchar* tootle_api_attachment_get_description (TootleAPIAttachment* self);
void tootle_api_attachment_set_description (TootleAPIAttachment* self,
                                            const gchar* value);
const gchar* tootle_api_attachment_get__preview_url (TootleAPIAttachment* self);
void tootle_api_attachment_set__preview_url (TootleAPIAttachment* self,
                                             const gchar* value);
const gchar* tootle_api_attachment_get_preview_url (TootleAPIAttachment* self);
void tootle_api_attachment_set_preview_url (TootleAPIAttachment* self,
                                            const gchar* value);
static void tootle_api_attachment_finalize (GObject * obj);
static GType tootle_api_attachment_get_type_once (void);
static void _vala_tootle_api_attachment_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_tootle_api_attachment_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

const gchar* TOOTLE_API_ATTACHMENT_SUPPORTED_MIMES[24] = {"image/jpeg", "image/png", "image/gif", "video/webm", "video/mp4", "video/quicktime", "video/ogg", "video/webm", "video/quicktime", "audio/wave", "audio/wav", "audio/x-wav", "audio/x-pn-wave", "audio/ogg", "audio/mpeg", "audio/mp3", "audio/webm", "audio/flac", "audio/aac", "audio/m4a", "audio/x-m4a", "audio/mp4", "audio/3gpp", "video/x-ms-asf"};

static inline gpointer
tootle_api_attachment_get_instance_private (TootleAPIAttachment* self)
{
	return G_STRUCT_MEMBER_P (self, TootleAPIAttachment_private_offset);
}

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

TootleAPIAttachment*
tootle_api_attachment_from (JsonNode* node,
                            GError** error)
{
	TootleEntity* _tmp0_ = NULL;
	TootleEntity* _tmp1_;
	TootleAPIAttachment* _tmp2_;
	GError* _inner_error0_ = NULL;
	TootleAPIAttachment* result = NULL;
	g_return_val_if_fail (node != NULL, NULL);
	_tmp1_ = tootle_entity_from_json (TOOTLE_API_TYPE_ATTACHMENT, node, &_inner_error0_);
	_tmp0_ = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp2_ = _g_object_ref0 (TOOTLE_API_IS_ATTACHMENT (_tmp0_) ? ((TootleAPIAttachment*) _tmp0_) : NULL);
	result = _tmp2_;
	_g_object_unref0 (_tmp0_);
	return result;
}

static void
tootle_api_attachment_upload_data_free (gpointer _data)
{
	TootleApiAttachmentUploadData* _data_;
	_data_ = _data;
	_g_free0 (_data_->uri);
	_g_free0 (_data_->title);
	_g_free0 (_data_->descr);
	_g_object_unref0 (_data_->result);
	g_slice_free (TootleApiAttachmentUploadData, _data_);
}

void
tootle_api_attachment_upload (const gchar* uri,
                              const gchar* title,
                              const gchar* descr,
                              GAsyncReadyCallback _callback_,
                              gpointer _user_data_)
{
	TootleApiAttachmentUploadData* _data_;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (uri != NULL);
	g_return_if_fail (title != NULL);
	_data_ = g_slice_new0 (TootleApiAttachmentUploadData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, tootle_api_attachment_upload_data_free);
	_tmp0_ = g_strdup (uri);
	_g_free0 (_data_->uri);
	_data_->uri = _tmp0_;
	_tmp1_ = g_strdup (title);
	_g_free0 (_data_->title);
	_data_->title = _tmp1_;
	_tmp2_ = g_strdup (descr);
	_g_free0 (_data_->descr);
	_data_->descr = _tmp2_;
	tootle_api_attachment_upload_co (_data_);
}

TootleAPIAttachment*
tootle_api_attachment_upload_finish (GAsyncResult* _res_,
                                     GError** error)
{
	TootleAPIAttachment* result;
	TootleApiAttachmentUploadData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static Block19Data*
block19_data_ref (Block19Data* _data19_)
{
	g_atomic_int_inc (&_data19_->_ref_count_);
	return _data19_;
}

static void
block19_data_unref (void * _userdata_)
{
	Block19Data* _data19_;
	_data19_ = (Block19Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data19_->_ref_count_)) {
		_g_free0 (_data19_->_error_);
		g_slice_free (Block19Data, _data19_);
	}
}

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

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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 NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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 NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	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 NULL;
}

static guint8*
_vala_array_dup4 (guint8* self,
                  gint length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

static void
__lambda96_ (Block19Data* _data19_,
             SoupSession* sess,
             SoupMessage* mess,
             GError** error)
{
	g_return_if_fail (sess != NULL);
	g_return_if_fail (mess != NULL);
	tootle_api_attachment_upload_co (_data19_->_async_data_);
}

static void
___lambda96__tootle_network_success_callback (SoupSession* session,
                                              SoupMessage* msg,
                                              gpointer self,
                                              GError** error)
{
	__lambda96_ (self, session, msg, error);
}

static void
__lambda97_ (Block19Data* _data19_,
             gint32 code,
             const gchar* reason)
{
	gchar* _tmp0_;
	g_return_if_fail (reason != NULL);
	_tmp0_ = g_strdup (reason);
	_g_free0 (_data19_->_error_);
	_data19_->_error_ = _tmp0_;
	tootle_api_attachment_upload_co (_data19_->_async_data_);
}

static void
___lambda97__tootle_network_error_callback (gint32 code,
                                            const gchar* reason,
                                            gpointer self)
{
	__lambda97_ (self, code, reason);
}

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

static void
_vala_SoupBuffer_free (SoupBuffer* self)
{
	g_boxed_free (soup_buffer_get_type (), self);
}

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

static gboolean
tootle_api_attachment_upload_co (TootleApiAttachmentUploadData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data19_ = g_slice_new0 (Block19Data);
	_data_->_data19_->_ref_count_ = 1;
	_data_->_data19_->_async_data_ = _data_;
	_data_->_tmp0_ = string_to_string (_data_->uri);
	_data_->_tmp1_ = g_strconcat ("Uploading new media: ", _data_->_tmp0_, "...", NULL);
	_data_->_tmp2_ = _data_->_tmp1_;
	g_message ("Attachment.vala:46: %s", _data_->_tmp2_);
	_g_free0 (_data_->_tmp2_);
	_data_->contents_length1 = 0;
	_data_->_contents_size_ = 0;
	{
		_data_->_tmp3_ = g_file_new_for_uri (_data_->uri);
		_data_->file = _data_->_tmp3_;
		_data_->_tmp4_ = _data_->file;
		_data_->_tmp5_ = NULL;
		_data_->_tmp6_ = 0;
		g_file_load_contents (_data_->_tmp4_, NULL, &_data_->_tmp5_, &_data_->_tmp6_, NULL, &_data_->_inner_error0_);
		_data_->contents = (g_free (_data_->contents), NULL);
		_data_->contents = _data_->_tmp5_;
		_data_->contents_length1 = _data_->_tmp6_;
		_data_->_contents_size_ = _data_->contents_length1;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->file);
			goto __catch0_g_error;
		}
		_data_->_tmp8_ = _data_->file;
		_data_->_tmp9_ = g_file_query_info (_data_->_tmp8_, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0, NULL, &_data_->_inner_error0_);
		_data_->_tmp7_ = _data_->_tmp9_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->file);
			goto __catch0_g_error;
		}
		_data_->_tmp10_ = _data_->_tmp7_;
		_data_->_tmp7_ = NULL;
		_g_object_unref0 (_data_->type);
		_data_->type = _data_->_tmp10_;
		_data_->_tmp11_ = g_file_info_get_content_type (_data_->type);
		_data_->_tmp12_ = g_strdup (_data_->_tmp11_);
		_g_free0 (_data_->mime);
		_data_->mime = _data_->_tmp12_;
		_g_object_unref0 (_data_->_tmp7_);
		_g_object_unref0 (_data_->file);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp13_ = string_replace (_ ("Can't open file $file:\n$reason"), "$file", _data_->title);
		_data_->_tmp14_ = _data_->_tmp13_;
		_data_->_tmp15_ = _data_->e;
		_data_->_tmp16_ = _data_->_tmp15_->message;
		_data_->_tmp17_ = string_replace (_data_->_tmp14_, "$reason", _data_->_tmp16_);
		_data_->_tmp18_ = _data_->_tmp17_;
		_data_->_tmp19_ = g_error_new_literal (TOOTLE_OOPSIE, TOOTLE_OOPSIE_USER, _data_->_tmp18_);
		_data_->_tmp20_ = _data_->_tmp19_;
		_g_free0 (_data_->_tmp18_);
		_g_free0 (_data_->_tmp14_);
		_data_->_inner_error0_ = _data_->_tmp20_;
		_g_error_free0 (_data_->e);
		goto __finally0;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->type);
		_g_free0 (_data_->mime);
		_data_->contents = (g_free (_data_->contents), NULL);
		block19_data_unref (_data_->_data19_);
		_data_->_data19_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp21_ = g_strdup ("");
	_data_->descr_param = _data_->_tmp21_;
	if (_data_->descr != NULL) {
		_data_->_tmp23_ = string_replace (_data_->descr, " ", "");
		_data_->_tmp24_ = _data_->_tmp23_;
		_data_->_tmp22_ = g_strcmp0 (_data_->_tmp24_, "") != 0;
		_g_free0 (_data_->_tmp24_);
	} else {
		_data_->_tmp22_ = FALSE;
	}
	if (_data_->_tmp22_) {
		_data_->_tmp25_ = tootle_html_utils_uri_encode (_data_->descr);
		_data_->_tmp26_ = _data_->_tmp25_;
		_data_->_tmp27_ = g_strconcat ("?description=", _data_->_tmp26_, NULL);
		_g_free0 (_data_->descr_param);
		_data_->descr_param = _data_->_tmp27_;
		_g_free0 (_data_->_tmp26_);
	}
	_data_->_tmp28_ = _data_->contents;
	_data_->_tmp28__length1 = _data_->contents_length1;
	_data_->_tmp29_ = (_data_->_tmp28_ != NULL) ? _vala_array_dup4 (_data_->_tmp28_, _data_->_tmp28__length1) : _data_->_tmp28_;
	_data_->_tmp29__length1 = _data_->_tmp28__length1;
	_data_->_tmp30_ = soup_buffer_new_take (_data_->_tmp29_, _data_->_tmp29__length1);
	_data_->buffer = _data_->_tmp30_;
	_data_->_tmp31_ = soup_multipart_new (SOUP_FORM_MIME_TYPE_MULTIPART);
	_data_->multipart = _data_->_tmp31_;
	_data_->_tmp32_ = string_replace (_data_->mime, "/", ".");
	_data_->_tmp33_ = _data_->_tmp32_;
	soup_multipart_append_form_file (_data_->multipart, "file", _data_->_tmp33_, _data_->mime, _data_->buffer);
	_g_free0 (_data_->_tmp33_);
	_data_->_tmp34_ = tootle_accounts;
	_data_->_tmp35_ = tootle_accounts_get_active (_data_->_tmp34_);
	_data_->_tmp36_ = _data_->_tmp35_;
	_data_->_tmp37_ = tootle_instance_account_get_instance (_data_->_tmp36_);
	_data_->_tmp38_ = _data_->_tmp37_;
	_data_->_tmp39_ = string_to_string (_data_->_tmp38_);
	_data_->_tmp40_ = _data_->descr_param;
	_data_->_tmp41_ = string_to_string (_data_->_tmp40_);
	_data_->_tmp42_ = g_strconcat (_data_->_tmp39_, "/api/v1/media", _data_->_tmp41_, NULL);
	_data_->url = _data_->_tmp42_;
	_data_->_tmp43_ = soup_form_request_new_from_multipart (_data_->url, _data_->multipart);
	_data_->msg = _data_->_tmp43_;
	_data_->_tmp44_ = _data_->msg->request_headers;
	_data_->_tmp45_ = tootle_accounts;
	_data_->_tmp46_ = tootle_accounts_get_active (_data_->_tmp45_);
	_data_->_tmp47_ = _data_->_tmp46_;
	_data_->_tmp48_ = tootle_instance_account_get_access_token (_data_->_tmp47_);
	_data_->_tmp49_ = _data_->_tmp48_;
	_data_->_tmp50_ = string_to_string (_data_->_tmp49_);
	_data_->_tmp51_ = g_strconcat ("Bearer ", _data_->_tmp50_, NULL);
	_data_->_tmp52_ = _data_->_tmp51_;
	soup_message_headers_append (_data_->_tmp44_, "Authorization", _data_->_tmp52_);
	_g_free0 (_data_->_tmp52_);
	_data_->_data19_->_error_ = NULL;
	_data_->_tmp53_ = tootle_network;
	_data_->_tmp54_ = _g_object_ref0 (_data_->msg);
	tootle_network_queue (_data_->_tmp53_, _data_->_tmp54_, ___lambda96__tootle_network_success_callback, block19_data_ref (_data_->_data19_), block19_data_unref, ___lambda97__tootle_network_error_callback, block19_data_ref (_data_->_data19_), block19_data_unref);
	_data_->_state_ = 1;
	return FALSE;
	_state_1:
	;
	if (_data_->_data19_->_error_ != NULL) {
		_data_->_tmp55_ = g_error_new_literal (TOOTLE_OOPSIE, TOOTLE_OOPSIE_INSTANCE, _data_->_data19_->_error_);
		_data_->_inner_error0_ = _data_->_tmp55_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->msg);
		_g_free0 (_data_->url);
		__vala_SoupMultipart_free0 (_data_->multipart);
		__vala_SoupBuffer_free0 (_data_->buffer);
		_g_free0 (_data_->descr_param);
		_g_object_unref0 (_data_->type);
		_g_free0 (_data_->mime);
		_data_->contents = (g_free (_data_->contents), NULL);
		block19_data_unref (_data_->_data19_);
		_data_->_data19_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	} else {
		_data_->_tmp56_ = tootle_network;
		_data_->_tmp57_ = tootle_network_parse_node (_data_->_tmp56_, _data_->msg, &_data_->_inner_error0_);
		_data_->node = _data_->_tmp57_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->msg);
			_g_free0 (_data_->url);
			__vala_SoupMultipart_free0 (_data_->multipart);
			__vala_SoupBuffer_free0 (_data_->buffer);
			_g_free0 (_data_->descr_param);
			_g_object_unref0 (_data_->type);
			_g_free0 (_data_->mime);
			_data_->contents = (g_free (_data_->contents), NULL);
			block19_data_unref (_data_->_data19_);
			_data_->_data19_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp58_ = _data_->node;
		_data_->_tmp59_ = tootle_api_attachment_from (_data_->_tmp58_, &_data_->_inner_error0_);
		_data_->entity = _data_->_tmp59_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			__vala_JsonNode_free0 (_data_->node);
			_g_object_unref0 (_data_->msg);
			_g_free0 (_data_->url);
			__vala_SoupMultipart_free0 (_data_->multipart);
			__vala_SoupBuffer_free0 (_data_->buffer);
			_g_free0 (_data_->descr_param);
			_g_object_unref0 (_data_->type);
			_g_free0 (_data_->mime);
			_data_->contents = (g_free (_data_->contents), NULL);
			block19_data_unref (_data_->_data19_);
			_data_->_data19_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp60_ = _data_->entity;
		_data_->_tmp61_ = _data_->_tmp60_->priv->_id;
		_data_->_tmp62_ = string_to_string (_data_->_tmp61_);
		_data_->_tmp63_ = g_strconcat ("OK! ID ", _data_->_tmp62_, NULL);
		_data_->_tmp64_ = _data_->_tmp63_;
		g_message ("Attachment.vala:93: %s", _data_->_tmp64_);
		_g_free0 (_data_->_tmp64_);
		_data_->result = _data_->entity;
		__vala_JsonNode_free0 (_data_->node);
		_g_object_unref0 (_data_->msg);
		_g_free0 (_data_->url);
		__vala_SoupMultipart_free0 (_data_->multipart);
		__vala_SoupBuffer_free0 (_data_->buffer);
		_g_free0 (_data_->descr_param);
		_g_object_unref0 (_data_->type);
		_g_free0 (_data_->mime);
		_data_->contents = (g_free (_data_->contents), NULL);
		block19_data_unref (_data_->_data19_);
		_data_->_data19_ = NULL;
		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;
	}
}

TootleAPIAttachment*
tootle_api_attachment_construct (GType object_type)
{
	TootleAPIAttachment * self = NULL;
	self = (TootleAPIAttachment*) tootle_entity_construct (object_type);
	return self;
}

TootleAPIAttachment*
tootle_api_attachment_new (void)
{
	return tootle_api_attachment_construct (TOOTLE_API_TYPE_ATTACHMENT);
}

const gchar*
tootle_api_attachment_get_id (TootleAPIAttachment* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_id;
	result = _tmp0_;
	return result;
}

void
tootle_api_attachment_set_id (TootleAPIAttachment* self,
                              const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_api_attachment_get_id (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_id);
		self->priv->_id = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_api_attachment_properties[TOOTLE_API_ATTACHMENT_ID_PROPERTY]);
	}
}

const gchar*
tootle_api_attachment_get_kind (TootleAPIAttachment* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_kind;
	result = _tmp0_;
	return result;
}

void
tootle_api_attachment_set_kind (TootleAPIAttachment* self,
                                const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_api_attachment_get_kind (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_kind);
		self->priv->_kind = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_api_attachment_properties[TOOTLE_API_ATTACHMENT_KIND_PROPERTY]);
	}
}

const gchar*
tootle_api_attachment_get_url (TootleAPIAttachment* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_url;
	result = _tmp0_;
	return result;
}

void
tootle_api_attachment_set_url (TootleAPIAttachment* self,
                               const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_api_attachment_get_url (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_url);
		self->priv->_url = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_api_attachment_properties[TOOTLE_API_ATTACHMENT_URL_PROPERTY]);
	}
}

const gchar*
tootle_api_attachment_get_description (TootleAPIAttachment* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_description;
	result = _tmp0_;
	return result;
}

void
tootle_api_attachment_set_description (TootleAPIAttachment* self,
                                       const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_api_attachment_get_description (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_description);
		self->priv->_description = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_api_attachment_properties[TOOTLE_API_ATTACHMENT_DESCRIPTION_PROPERTY]);
	}
}

const gchar*
tootle_api_attachment_get__preview_url (TootleAPIAttachment* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->__preview_url;
	result = _tmp0_;
	return result;
}

void
tootle_api_attachment_set__preview_url (TootleAPIAttachment* self,
                                        const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->__preview_url);
	self->priv->__preview_url = _tmp0_;
}

const gchar*
tootle_api_attachment_get_preview_url (TootleAPIAttachment* self)
{
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp2_ = self->priv->__preview_url;
	if (_tmp2_ == NULL) {
		_tmp1_ = TRUE;
	} else {
		const gchar* _tmp3_;
		_tmp3_ = self->priv->__preview_url;
		_tmp1_ = g_strcmp0 (_tmp3_, "") == 0;
	}
	if (_tmp1_) {
		const gchar* _tmp4_;
		_tmp4_ = self->priv->_url;
		_tmp0_ = _tmp4_;
	} else {
		const gchar* _tmp5_;
		_tmp5_ = self->priv->__preview_url;
		_tmp0_ = _tmp5_;
	}
	result = _tmp0_;
	return result;
}

void
tootle_api_attachment_set_preview_url (TootleAPIAttachment* self,
                                       const gchar* value)
{
	g_return_if_fail (self != NULL);
	tootle_api_attachment_set__preview_url (self, value);
	g_object_notify_by_pspec ((GObject *) self, tootle_api_attachment_properties[TOOTLE_API_ATTACHMENT_PREVIEW_URL_PROPERTY]);
}

static void
tootle_api_attachment_class_init (TootleAPIAttachmentClass * klass,
                                  gpointer klass_data)
{
	tootle_api_attachment_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TootleAPIAttachment_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tootle_api_attachment_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tootle_api_attachment_set_property;
	G_OBJECT_CLASS (klass)->finalize = tootle_api_attachment_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_API_ATTACHMENT_ID_PROPERTY, tootle_api_attachment_properties[TOOTLE_API_ATTACHMENT_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_API_ATTACHMENT_KIND_PROPERTY, tootle_api_attachment_properties[TOOTLE_API_ATTACHMENT_KIND_PROPERTY] = g_param_spec_string ("kind", "kind", "kind", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_API_ATTACHMENT_URL_PROPERTY, tootle_api_attachment_properties[TOOTLE_API_ATTACHMENT_URL_PROPERTY] = g_param_spec_string ("url", "url", "url", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_API_ATTACHMENT_DESCRIPTION_PROPERTY, tootle_api_attachment_properties[TOOTLE_API_ATTACHMENT_DESCRIPTION_PROPERTY] = g_param_spec_string ("description", "description", "description", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_API_ATTACHMENT_PREVIEW_URL_PROPERTY, tootle_api_attachment_properties[TOOTLE_API_ATTACHMENT_PREVIEW_URL_PROPERTY] = g_param_spec_string ("preview-url", "preview-url", "preview-url", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
tootle_api_attachment_instance_init (TootleAPIAttachment * self,
                                     gpointer klass)
{
	self->priv = tootle_api_attachment_get_instance_private (self);
}

static void
tootle_api_attachment_finalize (GObject * obj)
{
	TootleAPIAttachment * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_API_TYPE_ATTACHMENT, TootleAPIAttachment);
	_g_free0 (self->priv->_id);
	_g_free0 (self->priv->_kind);
	_g_free0 (self->priv->_url);
	_g_free0 (self->priv->_description);
	_g_free0 (self->priv->__preview_url);
	G_OBJECT_CLASS (tootle_api_attachment_parent_class)->finalize (obj);
}

static GType
tootle_api_attachment_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleAPIAttachmentClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_api_attachment_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleAPIAttachment), 0, (GInstanceInitFunc) tootle_api_attachment_instance_init, NULL };
	GType tootle_api_attachment_type_id;
	tootle_api_attachment_type_id = g_type_register_static (TOOTLE_TYPE_ENTITY, "TootleAPIAttachment", &g_define_type_info, 0);
	TootleAPIAttachment_private_offset = g_type_add_instance_private (tootle_api_attachment_type_id, sizeof (TootleAPIAttachmentPrivate));
	return tootle_api_attachment_type_id;
}

GType
tootle_api_attachment_get_type (void)
{
	static volatile gsize tootle_api_attachment_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_api_attachment_type_id__volatile)) {
		GType tootle_api_attachment_type_id;
		tootle_api_attachment_type_id = tootle_api_attachment_get_type_once ();
		g_once_init_leave (&tootle_api_attachment_type_id__volatile, tootle_api_attachment_type_id);
	}
	return tootle_api_attachment_type_id__volatile;
}

static void
_vala_tootle_api_attachment_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	TootleAPIAttachment * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_API_TYPE_ATTACHMENT, TootleAPIAttachment);
	switch (property_id) {
		case TOOTLE_API_ATTACHMENT_ID_PROPERTY:
		g_value_set_string (value, tootle_api_attachment_get_id (self));
		break;
		case TOOTLE_API_ATTACHMENT_KIND_PROPERTY:
		g_value_set_string (value, tootle_api_attachment_get_kind (self));
		break;
		case TOOTLE_API_ATTACHMENT_URL_PROPERTY:
		g_value_set_string (value, tootle_api_attachment_get_url (self));
		break;
		case TOOTLE_API_ATTACHMENT_DESCRIPTION_PROPERTY:
		g_value_set_string (value, tootle_api_attachment_get_description (self));
		break;
		case TOOTLE_API_ATTACHMENT_PREVIEW_URL_PROPERTY:
		g_value_set_string (value, tootle_api_attachment_get_preview_url (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tootle_api_attachment_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec)
{
	TootleAPIAttachment * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_API_TYPE_ATTACHMENT, TootleAPIAttachment);
	switch (property_id) {
		case TOOTLE_API_ATTACHMENT_ID_PROPERTY:
		tootle_api_attachment_set_id (self, g_value_get_string (value));
		break;
		case TOOTLE_API_ATTACHMENT_KIND_PROPERTY:
		tootle_api_attachment_set_kind (self, g_value_get_string (value));
		break;
		case TOOTLE_API_ATTACHMENT_URL_PROPERTY:
		tootle_api_attachment_set_url (self, g_value_get_string (value));
		break;
		case TOOTLE_API_ATTACHMENT_DESCRIPTION_PROPERTY:
		tootle_api_attachment_set_description (self, g_value_get_string (value));
		break;
		case TOOTLE_API_ATTACHMENT_PREVIEW_URL_PROPERTY:
		tootle_api_attachment_set_preview_url (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

