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

#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <json-glib/json-glib.h>
#include <gee.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.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_SEARCH_RESULTS (tootle_api_search_results_get_type ())
#define TOOTLE_API_SEARCH_RESULTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_SEARCH_RESULTS, TootleAPISearchResults))
#define TOOTLE_API_SEARCH_RESULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_SEARCH_RESULTS, TootleAPISearchResultsClass))
#define TOOTLE_API_IS_SEARCH_RESULTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_SEARCH_RESULTS))
#define TOOTLE_API_IS_SEARCH_RESULTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_SEARCH_RESULTS))
#define TOOTLE_API_SEARCH_RESULTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_SEARCH_RESULTS, TootleAPISearchResultsClass))

typedef struct _TootleAPISearchResults TootleAPISearchResults;
typedef struct _TootleAPISearchResultsClass TootleAPISearchResultsClass;
typedef struct _TootleAPISearchResultsPrivate TootleAPISearchResultsPrivate;

#define TOOTLE_API_TYPE_STATUS (tootle_api_status_get_type ())
#define TOOTLE_API_STATUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_STATUS, TootleAPIStatus))
#define TOOTLE_API_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_STATUS, TootleAPIStatusClass))
#define TOOTLE_API_IS_STATUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_STATUS))
#define TOOTLE_API_IS_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_STATUS))
#define TOOTLE_API_STATUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_STATUS, TootleAPIStatusClass))

typedef struct _TootleAPIStatus TootleAPIStatus;
typedef struct _TootleAPIStatusClass TootleAPIStatusClass;

#define TOOTLE_API_TYPE_TAG (tootle_api_tag_get_type ())
#define TOOTLE_API_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_TAG, TootleAPITag))
#define TOOTLE_API_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_TAG, TootleAPITagClass))
#define TOOTLE_API_IS_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_TAG))
#define TOOTLE_API_IS_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_TAG))
#define TOOTLE_API_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_TAG, TootleAPITagClass))

typedef struct _TootleAPITag TootleAPITag;
typedef struct _TootleAPITagClass TootleAPITagClass;
enum  {
	TOOTLE_API_SEARCH_RESULTS_0_PROPERTY,
	TOOTLE_API_SEARCH_RESULTS_ACCOUNTS_PROPERTY,
	TOOTLE_API_SEARCH_RESULTS_STATUSES_PROPERTY,
	TOOTLE_API_SEARCH_RESULTS_HASHTAGS_PROPERTY,
	TOOTLE_API_SEARCH_RESULTS_NUM_PROPERTIES
};
static GParamSpec* tootle_api_search_results_properties[TOOTLE_API_SEARCH_RESULTS_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define TOOTLE_TYPE_REQUEST (tootle_request_get_type ())
#define TOOTLE_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_REQUEST, TootleRequest))
#define TOOTLE_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_REQUEST, TootleRequestClass))
#define TOOTLE_IS_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_REQUEST))
#define TOOTLE_IS_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_REQUEST))
#define TOOTLE_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_REQUEST, TootleRequestClass))

typedef struct _TootleRequest TootleRequest;
typedef struct _TootleRequestClass TootleRequestClass;

#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;
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
typedef struct _TootleApiSearchResultsRequestData TootleApiSearchResultsRequestData;

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 _TootleAPISearchResults {
	TootleEntity parent_instance;
	TootleAPISearchResultsPrivate * priv;
};

struct _TootleAPISearchResultsClass {
	TootleEntityClass parent_class;
};

struct _TootleAPISearchResultsPrivate {
	GeeArrayList* _accounts;
	GeeArrayList* _statuses;
	GeeArrayList* _hashtags;
};

struct _TootleApiSearchResultsRequestData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gchar* q;
	TootleInstanceAccount* account;
	TootleAPISearchResults* result;
	TootleRequest* req;
	TootleRequest* _tmp0_;
	TootleRequest* _tmp1_;
	TootleRequest* _tmp2_;
	TootleRequest* _tmp3_;
	TootleRequest* _tmp4_;
	TootleRequest* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	TootleRequest* _tmp8_;
	TootleRequest* _tmp9_;
	TootleRequest* _tmp10_;
	TootleRequest* _tmp11_;
	TootleRequest* _tmp12_;
	JsonNode* _tmp13_;
	TootleNetwork* _tmp14_;
	TootleRequest* _tmp15_;
	JsonNode* _tmp16_;
	TootleAPISearchResults* _tmp17_;
	TootleAPISearchResults* _tmp18_;
	TootleAPISearchResults* _tmp19_;
	GError* _inner_error0_;
};

static gint TootleAPISearchResults_private_offset;
static gpointer tootle_api_search_results_parent_class = NULL;
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_search_results_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPISearchResults, g_object_unref)
GType tootle_api_status_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIStatus, g_object_unref)
GType tootle_api_tag_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPITag, g_object_unref)
TootleAPISearchResults* tootle_api_search_results_from (JsonNode* node,
                                                        GError** error);
TootleEntity* tootle_entity_from_json (GType type,
                                       JsonNode* node,
                                       GError** error);
TootleEntity* tootle_api_search_results_first (TootleAPISearchResults* self,
                                               GError** error);
GeeArrayList* tootle_api_search_results_get_accounts (TootleAPISearchResults* self);
GeeArrayList* tootle_api_search_results_get_statuses (TootleAPISearchResults* self);
GeeArrayList* tootle_api_search_results_get_hashtags (TootleAPISearchResults* self);
static void tootle_api_search_results_request_data_free (gpointer _data);
void tootle_api_search_results_request (const gchar* q,
                                        TootleInstanceAccount* account,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
TootleAPISearchResults* tootle_api_search_results_request_finish (GAsyncResult* _res_,
                                                                  GError** error);
static gboolean tootle_api_search_results_request_co (TootleApiSearchResultsRequestData* _data_);
GType tootle_request_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleRequest, g_object_unref)
TootleRequest* tootle_request_new_GET (const gchar* url);
TootleRequest* tootle_request_construct_GET (GType object_type,
                                             const gchar* url);
TootleRequest* tootle_request_with_account (TootleRequest* self,
                                            TootleInstanceAccount* account);
TootleRequest* tootle_request_with_param (TootleRequest* self,
                                          const gchar* name,
                                          const gchar* val);
void tootle_request_await (TootleRequest* self,
                           GAsyncReadyCallback _callback_,
                           gpointer _user_data_);
TootleRequest* tootle_request_await_finish (TootleRequest* self,
                                            GAsyncResult* _res_,
                                            GError** error);
static void tootle_api_search_results_request_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_);
GType tootle_network_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleNetwork, g_object_unref)
JsonNode* tootle_network_parse_node (TootleNetwork* self,
                                     SoupMessage* msg,
                                     GError** error);
static void _vala_JsonNode_free (JsonNode* self);
TootleAPISearchResults* tootle_api_search_results_new (void);
TootleAPISearchResults* tootle_api_search_results_construct (GType object_type);
TootleEntity* tootle_entity_new (void);
TootleEntity* tootle_entity_construct (GType object_type);
void tootle_api_search_results_set_accounts (TootleAPISearchResults* self,
                                             GeeArrayList* value);
void tootle_api_search_results_set_statuses (TootleAPISearchResults* self,
                                             GeeArrayList* value);
void tootle_api_search_results_set_hashtags (TootleAPISearchResults* self,
                                             GeeArrayList* value);
static void tootle_api_search_results_finalize (GObject * obj);
static GType tootle_api_search_results_get_type_once (void);
static void _vala_tootle_api_search_results_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static void _vala_tootle_api_search_results_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
tootle_api_search_results_get_instance_private (TootleAPISearchResults* self)
{
	return G_STRUCT_MEMBER_P (self, TootleAPISearchResults_private_offset);
}

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

TootleAPISearchResults*
tootle_api_search_results_from (JsonNode* node,
                                GError** error)
{
	TootleEntity* _tmp0_ = NULL;
	TootleEntity* _tmp1_;
	TootleAPISearchResults* _tmp2_;
	GError* _inner_error0_ = NULL;
	TootleAPISearchResults* result = NULL;
	g_return_val_if_fail (node != NULL, NULL);
	_tmp1_ = tootle_entity_from_json (TOOTLE_API_TYPE_SEARCH_RESULTS, 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_SEARCH_RESULTS (_tmp0_) ? ((TootleAPISearchResults*) _tmp0_) : NULL);
	result = _tmp2_;
	_g_object_unref0 (_tmp0_);
	return result;
}

TootleEntity*
tootle_api_search_results_first (TootleAPISearchResults* self,
                                 GError** error)
{
	GeeArrayList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	GError* _inner_error0_ = NULL;
	TootleEntity* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_accounts;
	_tmp1_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ > 0) {
		GeeArrayList* _tmp3_;
		gpointer _tmp4_;
		_tmp3_ = self->priv->_accounts;
		_tmp4_ = gee_abstract_list_get ((GeeAbstractList*) _tmp3_, 0);
		result = (TootleEntity*) ((TootleAPIAccount*) _tmp4_);
		return result;
	} else {
		GeeArrayList* _tmp5_;
		gint _tmp6_;
		gint _tmp7_;
		_tmp5_ = self->priv->_statuses;
		_tmp6_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp5_);
		_tmp7_ = _tmp6_;
		if (_tmp7_ > 0) {
			GeeArrayList* _tmp8_;
			gpointer _tmp9_;
			_tmp8_ = self->priv->_statuses;
			_tmp9_ = gee_abstract_list_get ((GeeAbstractList*) _tmp8_, 0);
			result = (TootleEntity*) ((TootleAPIStatus*) _tmp9_);
			return result;
		} else {
			GeeArrayList* _tmp10_;
			gint _tmp11_;
			gint _tmp12_;
			_tmp10_ = self->priv->_hashtags;
			_tmp11_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp10_);
			_tmp12_ = _tmp11_;
			if (_tmp12_ > 0) {
				GeeArrayList* _tmp13_;
				gpointer _tmp14_;
				_tmp13_ = self->priv->_hashtags;
				_tmp14_ = gee_abstract_list_get ((GeeAbstractList*) _tmp13_, 0);
				result = (TootleEntity*) ((TootleAPITag*) _tmp14_);
				return result;
			} else {
				GError* _tmp15_;
				_tmp15_ = g_error_new_literal (TOOTLE_OOPSIE, TOOTLE_OOPSIE_INTERNAL, _ ("Search returned no results"));
				_inner_error0_ = _tmp15_;
				g_propagate_error (error, _inner_error0_);
				return NULL;
			}
		}
	}
}

static void
tootle_api_search_results_request_data_free (gpointer _data)
{
	TootleApiSearchResultsRequestData* _data_;
	_data_ = _data;
	_g_free0 (_data_->q);
	_g_object_unref0 (_data_->account);
	_g_object_unref0 (_data_->result);
	g_slice_free (TootleApiSearchResultsRequestData, _data_);
}

void
tootle_api_search_results_request (const gchar* q,
                                   TootleInstanceAccount* account,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_)
{
	TootleApiSearchResultsRequestData* _data_;
	gchar* _tmp0_;
	TootleInstanceAccount* _tmp1_;
	g_return_if_fail (q != NULL);
	g_return_if_fail (account != NULL);
	_data_ = g_slice_new0 (TootleApiSearchResultsRequestData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, tootle_api_search_results_request_data_free);
	_tmp0_ = g_strdup (q);
	_g_free0 (_data_->q);
	_data_->q = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	tootle_api_search_results_request_co (_data_);
}

TootleAPISearchResults*
tootle_api_search_results_request_finish (GAsyncResult* _res_,
                                          GError** error)
{
	TootleAPISearchResults* result;
	TootleApiSearchResultsRequestData* _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
tootle_api_search_results_request_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_)
{
	TootleApiSearchResultsRequestData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	tootle_api_search_results_request_co (_data_);
}

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

static gboolean
tootle_api_search_results_request_co (TootleApiSearchResultsRequestData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = tootle_request_new_GET ("/api/v2/search");
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = tootle_request_with_account (_data_->_tmp1_, _data_->account);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = tootle_request_with_param (_data_->_tmp3_, "resolve", "true");
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = soup_uri_encode (_data_->q, NULL);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_tmp8_ = tootle_request_with_param (_data_->_tmp5_, "q", _data_->_tmp7_);
	_data_->_tmp9_ = _data_->_tmp8_;
	_g_free0 (_data_->_tmp7_);
	_g_object_unref0 (_data_->_tmp5_);
	_g_object_unref0 (_data_->_tmp3_);
	_g_object_unref0 (_data_->_tmp1_);
	_data_->req = _data_->_tmp9_;
	_data_->_tmp10_ = _data_->req;
	_data_->_state_ = 1;
	tootle_request_await (_data_->_tmp10_, tootle_api_search_results_request_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp11_ = tootle_request_await_finish (_data_->_tmp10_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp12_ = _data_->_tmp11_;
	_g_object_unref0 (_data_->_tmp12_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->req);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp14_ = tootle_network;
	_data_->_tmp15_ = _data_->req;
	_data_->_tmp16_ = tootle_network_parse_node (_data_->_tmp14_, (SoupMessage*) _data_->_tmp15_, &_data_->_inner_error0_);
	_data_->_tmp13_ = _data_->_tmp16_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->req);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp18_ = tootle_api_search_results_from (_data_->_tmp13_, &_data_->_inner_error0_);
	_data_->_tmp17_ = _data_->_tmp18_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		__vala_JsonNode_free0 (_data_->_tmp13_);
		_g_object_unref0 (_data_->req);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp19_ = _data_->_tmp17_;
	_data_->_tmp17_ = NULL;
	_data_->result = _data_->_tmp19_;
	_g_object_unref0 (_data_->_tmp17_);
	__vala_JsonNode_free0 (_data_->_tmp13_);
	_g_object_unref0 (_data_->req);
	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;
}

TootleAPISearchResults*
tootle_api_search_results_construct (GType object_type)
{
	TootleAPISearchResults * self = NULL;
	self = (TootleAPISearchResults*) tootle_entity_construct (object_type);
	return self;
}

TootleAPISearchResults*
tootle_api_search_results_new (void)
{
	return tootle_api_search_results_construct (TOOTLE_API_TYPE_SEARCH_RESULTS);
}

GeeArrayList*
tootle_api_search_results_get_accounts (TootleAPISearchResults* self)
{
	GeeArrayList* result;
	GeeArrayList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_accounts;
	result = _tmp0_;
	return result;
}

void
tootle_api_search_results_set_accounts (TootleAPISearchResults* self,
                                        GeeArrayList* value)
{
	GeeArrayList* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_api_search_results_get_accounts (self);
	if (old_value != value) {
		GeeArrayList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_accounts);
		self->priv->_accounts = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_api_search_results_properties[TOOTLE_API_SEARCH_RESULTS_ACCOUNTS_PROPERTY]);
	}
}

GeeArrayList*
tootle_api_search_results_get_statuses (TootleAPISearchResults* self)
{
	GeeArrayList* result;
	GeeArrayList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_statuses;
	result = _tmp0_;
	return result;
}

void
tootle_api_search_results_set_statuses (TootleAPISearchResults* self,
                                        GeeArrayList* value)
{
	GeeArrayList* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_api_search_results_get_statuses (self);
	if (old_value != value) {
		GeeArrayList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_statuses);
		self->priv->_statuses = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_api_search_results_properties[TOOTLE_API_SEARCH_RESULTS_STATUSES_PROPERTY]);
	}
}

GeeArrayList*
tootle_api_search_results_get_hashtags (TootleAPISearchResults* self)
{
	GeeArrayList* result;
	GeeArrayList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_hashtags;
	result = _tmp0_;
	return result;
}

void
tootle_api_search_results_set_hashtags (TootleAPISearchResults* self,
                                        GeeArrayList* value)
{
	GeeArrayList* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_api_search_results_get_hashtags (self);
	if (old_value != value) {
		GeeArrayList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_hashtags);
		self->priv->_hashtags = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_api_search_results_properties[TOOTLE_API_SEARCH_RESULTS_HASHTAGS_PROPERTY]);
	}
}

static void
tootle_api_search_results_class_init (TootleAPISearchResultsClass * klass,
                                      gpointer klass_data)
{
	tootle_api_search_results_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TootleAPISearchResults_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tootle_api_search_results_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tootle_api_search_results_set_property;
	G_OBJECT_CLASS (klass)->finalize = tootle_api_search_results_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_API_SEARCH_RESULTS_ACCOUNTS_PROPERTY, tootle_api_search_results_properties[TOOTLE_API_SEARCH_RESULTS_ACCOUNTS_PROPERTY] = g_param_spec_object ("accounts", "accounts", "accounts", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_API_SEARCH_RESULTS_STATUSES_PROPERTY, tootle_api_search_results_properties[TOOTLE_API_SEARCH_RESULTS_STATUSES_PROPERTY] = g_param_spec_object ("statuses", "statuses", "statuses", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_API_SEARCH_RESULTS_HASHTAGS_PROPERTY, tootle_api_search_results_properties[TOOTLE_API_SEARCH_RESULTS_HASHTAGS_PROPERTY] = g_param_spec_object ("hashtags", "hashtags", "hashtags", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
tootle_api_search_results_instance_init (TootleAPISearchResults * self,
                                         gpointer klass)
{
	self->priv = tootle_api_search_results_get_instance_private (self);
}

static void
tootle_api_search_results_finalize (GObject * obj)
{
	TootleAPISearchResults * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_API_TYPE_SEARCH_RESULTS, TootleAPISearchResults);
	_g_object_unref0 (self->priv->_accounts);
	_g_object_unref0 (self->priv->_statuses);
	_g_object_unref0 (self->priv->_hashtags);
	G_OBJECT_CLASS (tootle_api_search_results_parent_class)->finalize (obj);
}

static GType
tootle_api_search_results_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleAPISearchResultsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_api_search_results_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleAPISearchResults), 0, (GInstanceInitFunc) tootle_api_search_results_instance_init, NULL };
	GType tootle_api_search_results_type_id;
	tootle_api_search_results_type_id = g_type_register_static (TOOTLE_TYPE_ENTITY, "TootleAPISearchResults", &g_define_type_info, 0);
	TootleAPISearchResults_private_offset = g_type_add_instance_private (tootle_api_search_results_type_id, sizeof (TootleAPISearchResultsPrivate));
	return tootle_api_search_results_type_id;
}

GType
tootle_api_search_results_get_type (void)
{
	static volatile gsize tootle_api_search_results_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_api_search_results_type_id__volatile)) {
		GType tootle_api_search_results_type_id;
		tootle_api_search_results_type_id = tootle_api_search_results_get_type_once ();
		g_once_init_leave (&tootle_api_search_results_type_id__volatile, tootle_api_search_results_type_id);
	}
	return tootle_api_search_results_type_id__volatile;
}

static void
_vala_tootle_api_search_results_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	TootleAPISearchResults * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_API_TYPE_SEARCH_RESULTS, TootleAPISearchResults);
	switch (property_id) {
		case TOOTLE_API_SEARCH_RESULTS_ACCOUNTS_PROPERTY:
		g_value_set_object (value, tootle_api_search_results_get_accounts (self));
		break;
		case TOOTLE_API_SEARCH_RESULTS_STATUSES_PROPERTY:
		g_value_set_object (value, tootle_api_search_results_get_statuses (self));
		break;
		case TOOTLE_API_SEARCH_RESULTS_HASHTAGS_PROPERTY:
		g_value_set_object (value, tootle_api_search_results_get_hashtags (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tootle_api_search_results_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec)
{
	TootleAPISearchResults * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_API_TYPE_SEARCH_RESULTS, TootleAPISearchResults);
	switch (property_id) {
		case TOOTLE_API_SEARCH_RESULTS_ACCOUNTS_PROPERTY:
		tootle_api_search_results_set_accounts (self, g_value_get_object (value));
		break;
		case TOOTLE_API_SEARCH_RESULTS_STATUSES_PROPERTY:
		tootle_api_search_results_set_statuses (self, g_value_get_object (value));
		break;
		case TOOTLE_API_SEARCH_RESULTS_HASHTAGS_PROPERTY:
		tootle_api_search_results_set_hashtags (self, g_value_get_object (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;
}

