/* Conversation.c generated by valac 0.52.4, the Vala compiler
 * generated from Conversation.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 <gee.h>
#include <handy.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_CONVERSATION (tootle_api_conversation_get_type ())
#define TOOTLE_API_CONVERSATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_CONVERSATION, TootleAPIConversation))
#define TOOTLE_API_CONVERSATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_CONVERSATION, TootleAPIConversationClass))
#define TOOTLE_API_IS_CONVERSATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_CONVERSATION))
#define TOOTLE_API_IS_CONVERSATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_CONVERSATION))
#define TOOTLE_API_CONVERSATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_CONVERSATION, TootleAPIConversationClass))

typedef struct _TootleAPIConversation TootleAPIConversation;
typedef struct _TootleAPIConversationClass TootleAPIConversationClass;
typedef struct _TootleAPIConversationPrivate TootleAPIConversationPrivate;

#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;
enum  {
	TOOTLE_API_CONVERSATION_0_PROPERTY,
	TOOTLE_API_CONVERSATION_ID_PROPERTY,
	TOOTLE_API_CONVERSATION_ACCOUNTS_PROPERTY,
	TOOTLE_API_CONVERSATION_UNREAD_PROPERTY,
	TOOTLE_API_CONVERSATION_LAST_STATUS_PROPERTY,
	TOOTLE_API_CONVERSATION_NUM_PROPERTIES
};
static GParamSpec* tootle_api_conversation_properties[TOOTLE_API_CONVERSATION_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)))

#define TOOTLE_WIDGETS_TYPE_STATUS (tootle_widgets_status_get_type ())
#define TOOTLE_WIDGETS_STATUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_WIDGETS_TYPE_STATUS, TootleWidgetsStatus))
#define TOOTLE_WIDGETS_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_WIDGETS_TYPE_STATUS, TootleWidgetsStatusClass))
#define TOOTLE_WIDGETS_IS_STATUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_WIDGETS_TYPE_STATUS))
#define TOOTLE_WIDGETS_IS_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_WIDGETS_TYPE_STATUS))
#define TOOTLE_WIDGETS_STATUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_WIDGETS_TYPE_STATUS, TootleWidgetsStatusClass))

typedef struct _TootleWidgetsStatus TootleWidgetsStatus;
typedef struct _TootleWidgetsStatusClass TootleWidgetsStatusClass;

#define TOOTLE_WIDGETS_TYPE_CONVERSATION (tootle_widgets_conversation_get_type ())
#define TOOTLE_WIDGETS_CONVERSATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_WIDGETS_TYPE_CONVERSATION, TootleWidgetsConversation))
#define TOOTLE_WIDGETS_CONVERSATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_WIDGETS_TYPE_CONVERSATION, TootleWidgetsConversationClass))
#define TOOTLE_WIDGETS_IS_CONVERSATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_WIDGETS_TYPE_CONVERSATION))
#define TOOTLE_WIDGETS_IS_CONVERSATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_WIDGETS_TYPE_CONVERSATION))
#define TOOTLE_WIDGETS_CONVERSATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_WIDGETS_TYPE_CONVERSATION, TootleWidgetsConversationClass))

typedef struct _TootleWidgetsConversation TootleWidgetsConversation;
typedef struct _TootleWidgetsConversationClass TootleWidgetsConversationClass;

#define TOOTLE_VIEWS_TYPE_BASE (tootle_views_base_get_type ())
#define TOOTLE_VIEWS_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_VIEWS_TYPE_BASE, TootleViewsBase))
#define TOOTLE_VIEWS_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_VIEWS_TYPE_BASE, TootleViewsBaseClass))
#define TOOTLE_VIEWS_IS_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_VIEWS_TYPE_BASE))
#define TOOTLE_VIEWS_IS_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_VIEWS_TYPE_BASE))
#define TOOTLE_VIEWS_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_VIEWS_TYPE_BASE, TootleViewsBaseClass))

typedef struct _TootleViewsBase TootleViewsBase;
typedef struct _TootleViewsBaseClass TootleViewsBaseClass;

#define TOOTLE_VIEWS_TYPE_THREAD (tootle_views_thread_get_type ())
#define TOOTLE_VIEWS_THREAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_VIEWS_TYPE_THREAD, TootleViewsThread))
#define TOOTLE_VIEWS_THREAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_VIEWS_TYPE_THREAD, TootleViewsThreadClass))
#define TOOTLE_VIEWS_IS_THREAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_VIEWS_TYPE_THREAD))
#define TOOTLE_VIEWS_IS_THREAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_VIEWS_TYPE_THREAD))
#define TOOTLE_VIEWS_THREAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_VIEWS_TYPE_THREAD, TootleViewsThreadClass))

typedef struct _TootleViewsThread TootleViewsThread;
typedef struct _TootleViewsThreadClass TootleViewsThreadClass;

#define TOOTLE_DIALOGS_TYPE_MAIN_WINDOW (tootle_dialogs_main_window_get_type ())
#define TOOTLE_DIALOGS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_DIALOGS_TYPE_MAIN_WINDOW, TootleDialogsMainWindow))
#define TOOTLE_DIALOGS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_DIALOGS_TYPE_MAIN_WINDOW, TootleDialogsMainWindowClass))
#define TOOTLE_DIALOGS_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_DIALOGS_TYPE_MAIN_WINDOW))
#define TOOTLE_DIALOGS_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_DIALOGS_TYPE_MAIN_WINDOW))
#define TOOTLE_DIALOGS_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_DIALOGS_TYPE_MAIN_WINDOW, TootleDialogsMainWindowClass))

typedef struct _TootleDialogsMainWindow TootleDialogsMainWindow;
typedef struct _TootleDialogsMainWindowClass TootleDialogsMainWindowClass;

#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_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;
typedef void (*TootleNetworkSuccessCallback) (SoupSession* session, SoupMessage* msg, gpointer user_data, GError** error);
typedef void (*TootleNetworkErrorCallback) (gint32 code, const gchar* reason, gpointer user_data);

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 _TootleAPIConversation {
	TootleEntity parent_instance;
	TootleAPIConversationPrivate * priv;
};

struct _TootleAPIConversationClass {
	TootleEntityClass parent_class;
};

struct _TootleAPIConversationPrivate {
	gchar* _id;
	GeeArrayList* _accounts;
	gboolean _unread;
	TootleAPIStatus* _last_status;
};

static gint TootleAPIConversation_private_offset;
static gpointer tootle_api_conversation_parent_class = NULL;
extern TootleDialogsMainWindow* tootle_window;
extern TootleAccounts* tootle_accounts;
static TootleWidgetizableIface * tootle_api_conversation_tootle_widgetizable_parent_iface = NULL;

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_conversation_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIConversation, g_object_unref)
GType tootle_api_status_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIStatus, g_object_unref)
static GtkWidget* tootle_api_conversation_real_to_widget (TootleWidgetizable* base,
                                                   GError** error);
TootleWidgetsConversation* tootle_widgets_conversation_new (TootleAPIConversation* entity);
TootleWidgetsConversation* tootle_widgets_conversation_construct (GType object_type,
                                                                  TootleAPIConversation* entity);
GType tootle_widgets_status_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleWidgetsStatus, g_object_unref)
GType tootle_widgets_conversation_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleWidgetsConversation, g_object_unref)
static void tootle_api_conversation_real_open (TootleWidgetizable* base);
GType tootle_views_base_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleViewsBase, g_object_unref)
GType tootle_views_thread_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleViewsThread, g_object_unref)
TootleAPIStatus* tootle_api_conversation_get_last_status (TootleAPIConversation* self);
TootleAPIStatus* tootle_api_status_get_formal (TootleAPIStatus* self);
TootleViewsThread* tootle_views_thread_new (TootleAPIStatus* status);
TootleViewsThread* tootle_views_thread_construct (GType object_type,
                                                  TootleAPIStatus* status);
GType tootle_dialogs_main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleDialogsMainWindow, g_object_unref)
TootleViewsBase* tootle_dialogs_main_window_open_view (TootleDialogsMainWindow* self,
                                                       TootleViewsBase* view);
gboolean tootle_api_conversation_get_unread (TootleAPIConversation* self);
void tootle_api_conversation_mark_read (TootleAPIConversation* self);
const gchar* tootle_api_conversation_get_id (TootleAPIConversation* self);
TootleRequest* tootle_request_new_POST (const gchar* url);
TootleRequest* tootle_request_construct_POST (GType object_type,
                                              const gchar* url);
GType tootle_request_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleRequest, g_object_unref)
TootleRequest* tootle_request_with_account (TootleRequest* self,
                                            TootleInstanceAccount* account);
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);
TootleRequest* tootle_request_then (TootleRequest* self,
                                    TootleNetworkSuccessCallback cb,
                                    gpointer cb_target,
                                    GDestroyNotify cb_target_destroy_notify);
static void __lambda110_ (TootleAPIConversation* self,
                   GError** error);
void tootle_api_conversation_set_unread (TootleAPIConversation* self,
                                         gboolean value);
static void ___lambda110__tootle_network_success_callback (SoupSession* session,
                                                    SoupMessage* msg,
                                                    gpointer self,
                                                    GError** error);
TootleRequest* tootle_request_on_error (TootleRequest* self,
                                        TootleNetworkErrorCallback cb,
                                        gpointer cb_target,
                                        GDestroyNotify cb_target_destroy_notify);
static void __lambda111_ (TootleAPIConversation* self);
static void ___lambda111__tootle_network_error_callback (gint32 code,
                                                  const gchar* reason,
                                                  gpointer self);
TootleRequest* tootle_request_exec (TootleRequest* self);
TootleAPIConversation* tootle_api_conversation_new (void);
TootleAPIConversation* tootle_api_conversation_construct (GType object_type);
TootleEntity* tootle_entity_new (void);
TootleEntity* tootle_entity_construct (GType object_type);
void tootle_api_conversation_set_id (TootleAPIConversation* self,
                                     const gchar* value);
GeeArrayList* tootle_api_conversation_get_accounts (TootleAPIConversation* self);
void tootle_api_conversation_set_accounts (TootleAPIConversation* self,
                                           GeeArrayList* value);
void tootle_api_conversation_set_last_status (TootleAPIConversation* self,
                                              TootleAPIStatus* value);
GtkWidget* tootle_widgetizable_to_widget (TootleWidgetizable* self,
                                          GError** error);
void tootle_widgetizable_open (TootleWidgetizable* self);
static void tootle_api_conversation_finalize (GObject * obj);
static GType tootle_api_conversation_get_type_once (void);
static void _vala_tootle_api_conversation_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_tootle_api_conversation_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_conversation_get_instance_private (TootleAPIConversation* self)
{
	return G_STRUCT_MEMBER_P (self, TootleAPIConversation_private_offset);
}

static GtkWidget*
tootle_api_conversation_real_to_widget (TootleWidgetizable* base,
                                        GError** error)
{
	TootleAPIConversation * self;
	TootleWidgetsConversation* _tmp0_;
	GtkWidget* result = NULL;
	self = (TootleAPIConversation*) base;
	_tmp0_ = tootle_widgets_conversation_new (self);
	g_object_ref_sink (_tmp0_);
	result = (GtkWidget*) _tmp0_;
	return result;
}

static void
tootle_api_conversation_real_open (TootleWidgetizable* base)
{
	TootleAPIConversation * self;
	TootleViewsThread* view = NULL;
	TootleAPIStatus* _tmp0_;
	TootleAPIStatus* _tmp1_;
	TootleAPIStatus* _tmp2_;
	TootleViewsThread* _tmp3_;
	TootleDialogsMainWindow* _tmp4_;
	TootleViewsThread* _tmp5_;
	TootleViewsBase* _tmp6_;
	TootleViewsBase* _tmp7_;
	gboolean _tmp8_;
	self = (TootleAPIConversation*) base;
	_tmp0_ = self->priv->_last_status;
	_tmp1_ = tootle_api_status_get_formal (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = tootle_views_thread_new (_tmp2_);
	g_object_ref_sink (_tmp3_);
	view = _tmp3_;
	_tmp4_ = tootle_window;
	_tmp5_ = view;
	_tmp6_ = tootle_dialogs_main_window_open_view (_tmp4_, (TootleViewsBase*) _tmp5_);
	_tmp7_ = _tmp6_;
	_g_object_unref0 (_tmp7_);
	_tmp8_ = self->priv->_unread;
	if (_tmp8_) {
		tootle_api_conversation_mark_read (self);
	}
	_g_object_unref0 (view);
}

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 void
__lambda110_ (TootleAPIConversation* self,
              GError** error)
{
	tootle_api_conversation_set_unread (self, FALSE);
}

static void
___lambda110__tootle_network_success_callback (SoupSession* session,
                                               SoupMessage* msg,
                                               gpointer self,
                                               GError** error)
{
	__lambda110_ ((TootleAPIConversation*) self, error);
}

static void
__lambda111_ (TootleAPIConversation* self)
{
}

static void
___lambda111__tootle_network_error_callback (gint32 code,
                                             const gchar* reason,
                                             gpointer self)
{
	__lambda111_ ((TootleAPIConversation*) self);
}

void
tootle_api_conversation_mark_read (TootleAPIConversation* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	TootleRequest* _tmp4_;
	TootleRequest* _tmp5_;
	TootleAccounts* _tmp6_;
	TootleInstanceAccount* _tmp7_;
	TootleInstanceAccount* _tmp8_;
	TootleRequest* _tmp9_;
	TootleRequest* _tmp10_;
	TootleRequest* _tmp11_;
	TootleRequest* _tmp12_;
	TootleRequest* _tmp13_;
	TootleRequest* _tmp14_;
	TootleRequest* _tmp15_;
	TootleRequest* _tmp16_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_id;
	_tmp1_ = string_to_string (_tmp0_);
	_tmp2_ = g_strconcat ("/api/v1/conversations/", _tmp1_, "/read", NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = tootle_request_new_POST (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = tootle_accounts;
	_tmp7_ = tootle_accounts_get_active (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = tootle_request_with_account (_tmp5_, _tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = tootle_request_then (_tmp10_, ___lambda110__tootle_network_success_callback, g_object_ref (self), g_object_unref);
	_tmp12_ = _tmp11_;
	_tmp13_ = tootle_request_on_error (_tmp12_, ___lambda111__tootle_network_error_callback, g_object_ref (self), g_object_unref);
	_tmp14_ = _tmp13_;
	_tmp15_ = tootle_request_exec (_tmp14_);
	_tmp16_ = _tmp15_;
	_g_object_unref0 (_tmp16_);
	_g_object_unref0 (_tmp14_);
	_g_object_unref0 (_tmp12_);
	_g_object_unref0 (_tmp10_);
	_g_object_unref0 (_tmp5_);
	_g_free0 (_tmp3_);
}

TootleAPIConversation*
tootle_api_conversation_construct (GType object_type)
{
	TootleAPIConversation * self = NULL;
	self = (TootleAPIConversation*) tootle_entity_construct (object_type);
	return self;
}

TootleAPIConversation*
tootle_api_conversation_new (void)
{
	return tootle_api_conversation_construct (TOOTLE_API_TYPE_CONVERSATION);
}

const gchar*
tootle_api_conversation_get_id (TootleAPIConversation* 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_conversation_set_id (TootleAPIConversation* self,
                                const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_api_conversation_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_conversation_properties[TOOTLE_API_CONVERSATION_ID_PROPERTY]);
	}
}

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

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

void
tootle_api_conversation_set_accounts (TootleAPIConversation* self,
                                      GeeArrayList* value)
{
	GeeArrayList* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_api_conversation_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_conversation_properties[TOOTLE_API_CONVERSATION_ACCOUNTS_PROPERTY]);
	}
}

gboolean
tootle_api_conversation_get_unread (TootleAPIConversation* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_unread;
	return result;
}

void
tootle_api_conversation_set_unread (TootleAPIConversation* self,
                                    gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_api_conversation_get_unread (self);
	if (old_value != value) {
		self->priv->_unread = value;
		g_object_notify_by_pspec ((GObject *) self, tootle_api_conversation_properties[TOOTLE_API_CONVERSATION_UNREAD_PROPERTY]);
	}
}

TootleAPIStatus*
tootle_api_conversation_get_last_status (TootleAPIConversation* self)
{
	TootleAPIStatus* result;
	TootleAPIStatus* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_last_status;
	result = _tmp0_;
	return result;
}

void
tootle_api_conversation_set_last_status (TootleAPIConversation* self,
                                         TootleAPIStatus* value)
{
	TootleAPIStatus* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_api_conversation_get_last_status (self);
	if (old_value != value) {
		TootleAPIStatus* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_last_status);
		self->priv->_last_status = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_api_conversation_properties[TOOTLE_API_CONVERSATION_LAST_STATUS_PROPERTY]);
	}
}

static void
tootle_api_conversation_class_init (TootleAPIConversationClass * klass,
                                    gpointer klass_data)
{
	tootle_api_conversation_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TootleAPIConversation_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tootle_api_conversation_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tootle_api_conversation_set_property;
	G_OBJECT_CLASS (klass)->finalize = tootle_api_conversation_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_API_CONVERSATION_ID_PROPERTY, tootle_api_conversation_properties[TOOTLE_API_CONVERSATION_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_CONVERSATION_ACCOUNTS_PROPERTY, tootle_api_conversation_properties[TOOTLE_API_CONVERSATION_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_CONVERSATION_UNREAD_PROPERTY, tootle_api_conversation_properties[TOOTLE_API_CONVERSATION_UNREAD_PROPERTY] = g_param_spec_boolean ("unread", "unread", "unread", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_API_CONVERSATION_LAST_STATUS_PROPERTY, tootle_api_conversation_properties[TOOTLE_API_CONVERSATION_LAST_STATUS_PROPERTY] = g_param_spec_object ("last-status", "last-status", "last-status", TOOTLE_API_TYPE_STATUS, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
tootle_api_conversation_tootle_widgetizable_interface_init (TootleWidgetizableIface * iface,
                                                            gpointer iface_data)
{
	tootle_api_conversation_tootle_widgetizable_parent_iface = g_type_interface_peek_parent (iface);
	iface->to_widget = (GtkWidget* (*) (TootleWidgetizable*, GError**)) tootle_api_conversation_real_to_widget;
	iface->open = (void (*) (TootleWidgetizable*)) tootle_api_conversation_real_open;
}

static void
tootle_api_conversation_instance_init (TootleAPIConversation * self,
                                       gpointer klass)
{
	self->priv = tootle_api_conversation_get_instance_private (self);
	self->priv->_unread = FALSE;
	self->priv->_last_status = NULL;
}

static void
tootle_api_conversation_finalize (GObject * obj)
{
	TootleAPIConversation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_API_TYPE_CONVERSATION, TootleAPIConversation);
	_g_free0 (self->priv->_id);
	_g_object_unref0 (self->priv->_accounts);
	_g_object_unref0 (self->priv->_last_status);
	G_OBJECT_CLASS (tootle_api_conversation_parent_class)->finalize (obj);
}

static GType
tootle_api_conversation_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleAPIConversationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_api_conversation_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleAPIConversation), 0, (GInstanceInitFunc) tootle_api_conversation_instance_init, NULL };
	static const GInterfaceInfo tootle_widgetizable_info = { (GInterfaceInitFunc) tootle_api_conversation_tootle_widgetizable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType tootle_api_conversation_type_id;
	tootle_api_conversation_type_id = g_type_register_static (TOOTLE_TYPE_ENTITY, "TootleAPIConversation", &g_define_type_info, 0);
	g_type_add_interface_static (tootle_api_conversation_type_id, TOOTLE_TYPE_WIDGETIZABLE, &tootle_widgetizable_info);
	TootleAPIConversation_private_offset = g_type_add_instance_private (tootle_api_conversation_type_id, sizeof (TootleAPIConversationPrivate));
	return tootle_api_conversation_type_id;
}

GType
tootle_api_conversation_get_type (void)
{
	static volatile gsize tootle_api_conversation_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_api_conversation_type_id__volatile)) {
		GType tootle_api_conversation_type_id;
		tootle_api_conversation_type_id = tootle_api_conversation_get_type_once ();
		g_once_init_leave (&tootle_api_conversation_type_id__volatile, tootle_api_conversation_type_id);
	}
	return tootle_api_conversation_type_id__volatile;
}

static void
_vala_tootle_api_conversation_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	TootleAPIConversation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_API_TYPE_CONVERSATION, TootleAPIConversation);
	switch (property_id) {
		case TOOTLE_API_CONVERSATION_ID_PROPERTY:
		g_value_set_string (value, tootle_api_conversation_get_id (self));
		break;
		case TOOTLE_API_CONVERSATION_ACCOUNTS_PROPERTY:
		g_value_set_object (value, tootle_api_conversation_get_accounts (self));
		break;
		case TOOTLE_API_CONVERSATION_UNREAD_PROPERTY:
		g_value_set_boolean (value, tootle_api_conversation_get_unread (self));
		break;
		case TOOTLE_API_CONVERSATION_LAST_STATUS_PROPERTY:
		g_value_set_object (value, tootle_api_conversation_get_last_status (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tootle_api_conversation_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec)
{
	TootleAPIConversation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_API_TYPE_CONVERSATION, TootleAPIConversation);
	switch (property_id) {
		case TOOTLE_API_CONVERSATION_ID_PROPERTY:
		tootle_api_conversation_set_id (self, g_value_get_string (value));
		break;
		case TOOTLE_API_CONVERSATION_ACCOUNTS_PROPERTY:
		tootle_api_conversation_set_accounts (self, g_value_get_object (value));
		break;
		case TOOTLE_API_CONVERSATION_UNREAD_PROPERTY:
		tootle_api_conversation_set_unread (self, g_value_get_boolean (value));
		break;
		case TOOTLE_API_CONVERSATION_LAST_STATUS_PROPERTY:
		tootle_api_conversation_set_last_status (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;
}

