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

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

#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;
typedef struct _TootleViewsBasePrivate TootleViewsBasePrivate;

#define TOOTLE_TYPE_IACCOUNT_LISTENER (tootle_iaccount_listener_get_type ())
#define TOOTLE_IACCOUNT_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_IACCOUNT_LISTENER, TootleIAccountListener))
#define TOOTLE_IS_IACCOUNT_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_IACCOUNT_LISTENER))
#define TOOTLE_IACCOUNT_LISTENER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TOOTLE_TYPE_IACCOUNT_LISTENER, TootleIAccountListenerIface))

typedef struct _TootleIAccountListener TootleIAccountListener;
typedef struct _TootleIAccountListenerIface TootleIAccountListenerIface;

#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;

#define TOOTLE_TYPE_ISTREAM_LISTENER (tootle_istream_listener_get_type ())
#define TOOTLE_ISTREAM_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_ISTREAM_LISTENER, TootleIStreamListener))
#define TOOTLE_IS_ISTREAM_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_ISTREAM_LISTENER))
#define TOOTLE_ISTREAM_LISTENER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TOOTLE_TYPE_ISTREAM_LISTENER, TootleIStreamListenerIface))

typedef struct _TootleIStreamListener TootleIStreamListener;
typedef struct _TootleIStreamListenerIface TootleIStreamListenerIface;

#define TOOTLE_VIEWS_TYPE_TIMELINE (tootle_views_timeline_get_type ())
#define TOOTLE_VIEWS_TIMELINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_VIEWS_TYPE_TIMELINE, TootleViewsTimeline))
#define TOOTLE_VIEWS_TIMELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_VIEWS_TYPE_TIMELINE, TootleViewsTimelineClass))
#define TOOTLE_VIEWS_IS_TIMELINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_VIEWS_TYPE_TIMELINE))
#define TOOTLE_VIEWS_IS_TIMELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_VIEWS_TYPE_TIMELINE))
#define TOOTLE_VIEWS_TIMELINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_VIEWS_TYPE_TIMELINE, TootleViewsTimelineClass))

typedef struct _TootleViewsTimeline TootleViewsTimeline;
typedef struct _TootleViewsTimelineClass TootleViewsTimelineClass;
typedef struct _TootleViewsTimelinePrivate TootleViewsTimelinePrivate;

#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_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_VIEWS_TYPE_NOTIFICATIONS (tootle_views_notifications_get_type ())
#define TOOTLE_VIEWS_NOTIFICATIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_VIEWS_TYPE_NOTIFICATIONS, TootleViewsNotifications))
#define TOOTLE_VIEWS_NOTIFICATIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_VIEWS_TYPE_NOTIFICATIONS, TootleViewsNotificationsClass))
#define TOOTLE_VIEWS_IS_NOTIFICATIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_VIEWS_TYPE_NOTIFICATIONS))
#define TOOTLE_VIEWS_IS_NOTIFICATIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_VIEWS_TYPE_NOTIFICATIONS))
#define TOOTLE_VIEWS_NOTIFICATIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_VIEWS_TYPE_NOTIFICATIONS, TootleViewsNotificationsClass))

typedef struct _TootleViewsNotifications TootleViewsNotifications;
typedef struct _TootleViewsNotificationsClass TootleViewsNotificationsClass;
typedef struct _TootleViewsNotificationsPrivate TootleViewsNotificationsPrivate;
enum  {
	TOOTLE_VIEWS_NOTIFICATIONS_0_PROPERTY,
	TOOTLE_VIEWS_NOTIFICATIONS_NUM_PROPERTIES
};
static GParamSpec* tootle_views_notifications_properties[TOOTLE_VIEWS_NOTIFICATIONS_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

#define TOOTLE_API_TYPE_NOTIFICATION (tootle_api_notification_get_type ())
#define TOOTLE_API_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_NOTIFICATION, TootleAPINotification))
#define TOOTLE_API_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_NOTIFICATION, TootleAPINotificationClass))
#define TOOTLE_API_IS_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_NOTIFICATION))
#define TOOTLE_API_IS_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_NOTIFICATION))
#define TOOTLE_API_NOTIFICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_NOTIFICATION, TootleAPINotificationClass))

typedef struct _TootleAPINotification TootleAPINotification;
typedef struct _TootleAPINotificationClass TootleAPINotificationClass;

#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_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_NOTIFICATION (tootle_widgets_notification_get_type ())
#define TOOTLE_WIDGETS_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_WIDGETS_TYPE_NOTIFICATION, TootleWidgetsNotification))
#define TOOTLE_WIDGETS_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_WIDGETS_TYPE_NOTIFICATION, TootleWidgetsNotificationClass))
#define TOOTLE_WIDGETS_IS_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_WIDGETS_TYPE_NOTIFICATION))
#define TOOTLE_WIDGETS_IS_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_WIDGETS_TYPE_NOTIFICATION))
#define TOOTLE_WIDGETS_NOTIFICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_WIDGETS_TYPE_NOTIFICATION, TootleWidgetsNotificationClass))

typedef struct _TootleWidgetsNotification TootleWidgetsNotification;
typedef struct _TootleWidgetsNotificationClass TootleWidgetsNotificationClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#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;

struct _TootleViewsBase {
	GtkBox parent_instance;
	TootleViewsBasePrivate * priv;
	HdyHeaderBar* header;
	GtkButton* back_button;
	GtkScrolledWindow* scrolled;
	GtkBox* view;
	HdyClamp* clamp;
	GtkBox* column_view;
	GtkStack* states;
	GtkBox* content_box;
	GtkListBox* content_list;
	GtkButton* status_button;
};

struct _TootleViewsBaseClass {
	GtkBoxClass parent_class;
	void (*build_header) (TootleViewsBase* self);
	void (*clear) (TootleViewsBase* self);
	void (*on_bottom_reached) (TootleViewsBase* self);
	void (*on_shown) (TootleViewsBase* self);
	void (*on_hidden) (TootleViewsBase* self);
	void (*on_content_changed) (TootleViewsBase* self);
	void (*on_error) (TootleViewsBase* self, gint32 code, const gchar* reason);
	void (*on_content_item_activated) (TootleViewsBase* self, GtkListBoxRow* row);
};

struct _TootleIAccountListenerIface {
	GTypeInterface parent_iface;
	void (*on_account_changed) (TootleIAccountListener* self, TootleInstanceAccount* account);
	void (*on_accounts_changed) (TootleIAccountListener* self, GeeArrayList* accounts);
};

struct _TootleIStreamListenerIface {
	GTypeInterface parent_iface;
};

struct _TootleViewsTimeline {
	TootleViewsBase parent_instance;
	TootleViewsTimelinePrivate * priv;
	TootleInstanceAccount* account;
	gulong on_status_added_sigig;
	gchar* stream;
};

struct _TootleViewsTimelineClass {
	TootleViewsBaseClass parent_class;
	gboolean (*is_status_owned) (TootleViewsTimeline* self, TootleAPIStatus* status);
	void (*append) (TootleViewsTimeline* self, GtkWidget* w, gboolean first);
	gchar* (*get_req_url) (TootleViewsTimeline* self);
	TootleRequest* (*append_params) (TootleViewsTimeline* self, TootleRequest* req);
	void (*on_request_finish) (TootleViewsTimeline* self);
	gboolean (*request) (TootleViewsTimeline* self);
	void (*on_refresh) (TootleViewsTimeline* self);
	gchar* (*get_stream_url) (TootleViewsTimeline* self);
	void (*on_account_changed) (TootleViewsTimeline* self, TootleInstanceAccount* acc);
	void (*add_status) (TootleViewsTimeline* self, TootleAPIStatus* status);
	void (*remove_status) (TootleViewsTimeline* self, const gchar* id);
};

struct _TootleViewsNotifications {
	TootleViewsTimeline parent_instance;
	TootleViewsNotificationsPrivate * priv;
	gint64 last_id;
};

struct _TootleViewsNotificationsClass {
	TootleViewsTimelineClass parent_class;
};

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);
};

static gpointer tootle_views_notifications_parent_class = NULL;
extern TootleAccounts* tootle_accounts;
static TootleIAccountListenerIface * tootle_views_notifications_tootle_iaccount_listener_parent_iface = NULL;
static TootleIStreamListenerIface * tootle_views_notifications_tootle_istream_listener_parent_iface = NULL;

GType tootle_views_base_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleViewsBase, g_object_unref)
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_iaccount_listener_get_type (void) G_GNUC_CONST ;
GType tootle_istream_listener_get_type (void) G_GNUC_CONST ;
GType tootle_views_timeline_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleViewsTimeline, g_object_unref)
GType tootle_api_status_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIStatus, g_object_unref)
GType tootle_request_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleRequest, g_object_unref)
GType tootle_views_notifications_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleViewsNotifications, g_object_unref)
gchar* tootle_views_timeline_get_stream_url (TootleViewsTimeline* self);
void tootle_views_base_on_shown (TootleViewsBase* self);
void tootle_views_timeline_append (TootleViewsTimeline* self,
                                   GtkWidget* w,
                                   gboolean first);
void tootle_views_timeline_on_account_changed (TootleViewsTimeline* self,
                                               TootleInstanceAccount* acc);
gboolean tootle_views_timeline_request (TootleViewsTimeline* self);
TootleViewsNotifications* tootle_views_notifications_new (void);
TootleViewsNotifications* tootle_views_notifications_construct (GType object_type);
gchar* tootle_desktop_fallback_icon (const gchar* normal,
                                     const gchar* fallback,
                                     const gchar* fallback2);
GType tootle_api_notification_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPINotification, g_object_unref)
void tootle_views_timeline_set_accepts (TootleViewsTimeline* self,
                                        GType value);
static void tootle_views_notifications_add_notification (TootleViewsNotifications* self,
                                                  TootleAPINotification* n);
static void _tootle_views_notifications_add_notification_tootle_istream_listener_on_notification (TootleIStreamListener* _sender,
                                                                                           TootleAPINotification* n,
                                                                                           gpointer self);
static gchar* tootle_views_notifications_real_get_stream_url (TootleViewsTimeline* base);
const gchar* tootle_instance_account_get_instance (TootleInstanceAccount* self);
const gchar* tootle_instance_account_get_access_token (TootleInstanceAccount* self);
static void tootle_views_notifications_real_on_shown (TootleViewsBase* base);
static gboolean tootle_views_notifications_has_unread (TootleViewsNotifications* self);
void tootle_views_base_set_needs_attention (TootleViewsBase* self,
                                            gboolean value);
void tootle_instance_account_set_has_unread_notifications (TootleInstanceAccount* self,
                                                           gboolean value);
void tootle_instance_account_set_last_seen_notification (TootleInstanceAccount* self,
                                                         gint64 value);
GType tootle_accounts_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAccounts, g_object_unref)
void tootle_accounts_save (TootleAccounts* self,
                           gboolean overwrite);
static void tootle_views_notifications_real_append (TootleViewsTimeline* base,
                                             GtkWidget* w,
                                             gboolean reverse);
GType tootle_widgets_status_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleWidgetsStatus, g_object_unref)
GType tootle_widgets_notification_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleWidgetsNotification, g_object_unref)
TootleAPINotification* tootle_widgets_notification_get_notification (TootleWidgetsNotification* self);
const gchar* tootle_api_notification_get_id (TootleAPINotification* self);
gboolean tootle_views_base_get_current (TootleViewsBase* self);
gboolean tootle_views_base_get_needs_attention (TootleViewsBase* self);
static void tootle_views_notifications_real_on_account_changed (TootleIAccountListener* base,
                                                         TootleInstanceAccount* acc);
gint64 tootle_instance_account_get_last_seen_notification (TootleInstanceAccount* self);
gboolean tootle_instance_account_get_has_unread_notifications (TootleInstanceAccount* self);
static gboolean tootle_views_notifications_real_request (TootleViewsTimeline* base);
GeeArrayList* tootle_instance_account_get_cached_notifications (TootleInstanceAccount* self);
static gboolean ___lambda128_ (TootleViewsNotifications* self,
                        TootleAPINotification* n);
GQuark tootle_oopsie_quark (void);
GType tootle_widgetizable_get_type (void) G_GNUC_CONST ;
GtkWidget* tootle_widgetizable_to_widget (TootleWidgetizable* self,
                                          GError** error);
static gboolean ____lambda128__gee_forall_func (gpointer g,
                                         gpointer self);
void tootle_views_timeline_prepend (TootleViewsTimeline* self,
                                    GtkWidget* w);
void tootle_iaccount_listener_on_account_changed (TootleIAccountListener* self,
                                                  TootleInstanceAccount* account);
static void tootle_views_notifications_finalize (GObject * obj);
static GType tootle_views_notifications_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static void
_tootle_views_notifications_add_notification_tootle_istream_listener_on_notification (TootleIStreamListener* _sender,
                                                                                      TootleAPINotification* n,
                                                                                      gpointer self)
{
	tootle_views_notifications_add_notification ((TootleViewsNotifications*) self, n);
}

TootleViewsNotifications*
tootle_views_notifications_construct (GType object_type)
{
	TootleViewsNotifications * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	_tmp0_ = tootle_desktop_fallback_icon ("notification-symbolic", "preferences-system-notifications-symbolic", "user-invisible-symbolic");
	_tmp1_ = _tmp0_;
	self = (TootleViewsNotifications*) g_object_new (object_type, "url", "/api/v1/notifications", "label", _ ("Notifications"), "icon", _tmp1_, NULL);
	_g_free0 (_tmp1_);
	tootle_views_timeline_set_accepts ((TootleViewsTimeline*) self, TOOTLE_API_TYPE_NOTIFICATION);
	g_signal_connect_object ((TootleIStreamListener*) self, "on-notification", (GCallback) _tootle_views_notifications_add_notification_tootle_istream_listener_on_notification, self, 0);
	g_signal_handler_disconnect ((GObject*) self, ((TootleViewsTimeline*) self)->on_status_added_sigig);
	return self;
}

TootleViewsNotifications*
tootle_views_notifications_new (void)
{
	return tootle_views_notifications_construct (TOOTLE_VIEWS_TYPE_NOTIFICATIONS);
}

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*
tootle_views_notifications_real_get_stream_url (TootleViewsTimeline* base)
{
	TootleViewsNotifications * self;
	gchar* _tmp0_ = NULL;
	TootleInstanceAccount* _tmp1_;
	gchar* result = NULL;
	self = (TootleViewsNotifications*) base;
	_tmp1_ = ((TootleViewsTimeline*) self)->account;
	if (_tmp1_ != NULL) {
		TootleInstanceAccount* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		const gchar* _tmp5_;
		TootleInstanceAccount* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp2_ = ((TootleViewsTimeline*) self)->account;
		_tmp3_ = tootle_instance_account_get_instance (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = string_to_string (_tmp4_);
		_tmp6_ = ((TootleViewsTimeline*) self)->account;
		_tmp7_ = tootle_instance_account_get_access_token (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = string_to_string (_tmp8_);
		_tmp10_ = g_strconcat (_tmp5_, "/api/v1/streaming/?stream=user&access_token=", _tmp9_, NULL);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp10_;
	} else {
		_g_free0 (_tmp0_);
		_tmp0_ = NULL;
	}
	result = _tmp0_;
	return result;
}

static void
tootle_views_notifications_real_on_shown (TootleViewsBase* base)
{
	TootleViewsNotifications * self;
	self = (TootleViewsNotifications*) base;
	if (tootle_views_notifications_has_unread (self)) {
		TootleInstanceAccount* _tmp0_;
		TootleInstanceAccount* _tmp1_;
		TootleAccounts* _tmp2_;
		tootle_views_base_set_needs_attention ((TootleViewsBase*) self, FALSE);
		_tmp0_ = ((TootleViewsTimeline*) self)->account;
		tootle_instance_account_set_has_unread_notifications (_tmp0_, FALSE);
		_tmp1_ = ((TootleViewsTimeline*) self)->account;
		tootle_instance_account_set_last_seen_notification (_tmp1_, self->last_id);
		_tmp2_ = tootle_accounts;
		tootle_accounts_save (_tmp2_, TRUE);
	}
}

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

static gint64
int64_parse (const gchar* str,
             guint _base)
{
	gint64 result = 0LL;
	g_return_val_if_fail (str != NULL, 0LL);
	result = g_ascii_strtoll (str, NULL, _base);
	return result;
}

static void
tootle_views_notifications_real_append (TootleViewsTimeline* base,
                                        GtkWidget* w,
                                        gboolean reverse)
{
	TootleViewsNotifications * self;
	TootleWidgetsNotification* nw = NULL;
	TootleWidgetsNotification* _tmp0_;
	TootleAPINotification* notification = NULL;
	TootleWidgetsNotification* _tmp1_;
	TootleAPINotification* _tmp2_;
	TootleAPINotification* _tmp3_;
	TootleAPINotification* _tmp4_;
	TootleAPINotification* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gboolean _tmp11_ = FALSE;
	gboolean _tmp14_;
	gboolean _tmp15_;
	self = (TootleViewsNotifications*) base;
	TOOTLE_VIEWS_TIMELINE_CLASS (tootle_views_notifications_parent_class)->append (G_TYPE_CHECK_INSTANCE_CAST (self, TOOTLE_VIEWS_TYPE_TIMELINE, TootleViewsTimeline), w, reverse);
	_tmp0_ = _g_object_ref0 (TOOTLE_WIDGETS_IS_NOTIFICATION (w) ? ((TootleWidgetsNotification*) w) : NULL);
	nw = _tmp0_;
	_tmp1_ = nw;
	_tmp2_ = tootle_widgets_notification_get_notification (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	notification = _tmp4_;
	_tmp5_ = notification;
	_tmp6_ = tootle_api_notification_get_id (_tmp5_);
	_tmp7_ = _tmp6_;
	if (int64_parse (_tmp7_, (guint) 0) > self->last_id) {
		TootleAPINotification* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		_tmp8_ = notification;
		_tmp9_ = tootle_api_notification_get_id (_tmp8_);
		_tmp10_ = _tmp9_;
		self->last_id = int64_parse (_tmp10_, (guint) 0);
	}
	if (tootle_views_notifications_has_unread (self)) {
		gboolean _tmp12_;
		gboolean _tmp13_;
		_tmp12_ = tootle_views_base_get_current ((TootleViewsBase*) self);
		_tmp13_ = _tmp12_;
		_tmp11_ = !_tmp13_;
	} else {
		_tmp11_ = FALSE;
	}
	tootle_views_base_set_needs_attention ((TootleViewsBase*) self, _tmp11_);
	_tmp14_ = tootle_views_base_get_needs_attention ((TootleViewsBase*) self);
	_tmp15_ = _tmp14_;
	if (_tmp15_) {
		TootleAccounts* _tmp16_;
		_tmp16_ = tootle_accounts;
		tootle_accounts_save (_tmp16_, TRUE);
	}
	_g_object_unref0 (notification);
	_g_object_unref0 (nw);
}

static void
tootle_views_notifications_real_on_account_changed (TootleIAccountListener* base,
                                                    TootleInstanceAccount* acc)
{
	TootleViewsNotifications * self;
	TootleInstanceAccount* _tmp0_;
	self = (TootleViewsNotifications*) base;
	TOOTLE_VIEWS_TIMELINE_CLASS (tootle_views_notifications_parent_class)->on_account_changed (G_TYPE_CHECK_INSTANCE_CAST (self, TOOTLE_VIEWS_TYPE_TIMELINE, TootleViewsTimeline), acc);
	_tmp0_ = ((TootleViewsTimeline*) self)->account;
	if (_tmp0_ == NULL) {
		self->last_id = (gint64) 0;
		tootle_views_base_set_needs_attention ((TootleViewsBase*) self, FALSE);
	} else {
		TootleInstanceAccount* _tmp1_;
		gint64 _tmp2_;
		gint64 _tmp3_;
		TootleInstanceAccount* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp1_ = ((TootleViewsTimeline*) self)->account;
		_tmp2_ = tootle_instance_account_get_last_seen_notification (_tmp1_);
		_tmp3_ = _tmp2_;
		self->last_id = _tmp3_;
		_tmp4_ = ((TootleViewsTimeline*) self)->account;
		_tmp5_ = tootle_instance_account_get_has_unread_notifications (_tmp4_);
		_tmp6_ = _tmp5_;
		tootle_views_base_set_needs_attention ((TootleViewsBase*) self, _tmp6_);
	}
}

static gboolean
___lambda128_ (TootleViewsNotifications* self,
               TootleAPINotification* n)
{
	GtkWidget* _tmp0_ = NULL;
	GtkWidget* _tmp1_;
	GError* _inner_error0_ = NULL;
	gboolean result = FALSE;
	g_return_val_if_fail (n != NULL, FALSE);
	_tmp1_ = tootle_widgetizable_to_widget ((TootleWidgetizable*) n, &_inner_error0_);
	_tmp0_ = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp2_ = FALSE;
		_g_object_unref0 (n);
		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 _tmp2_;
	}
	tootle_views_timeline_append ((TootleViewsTimeline*) self, _tmp0_, FALSE);
	result = TRUE;
	_g_object_unref0 (_tmp0_);
	_g_object_unref0 (n);
	return result;
}

static gboolean
____lambda128__gee_forall_func (gpointer g,
                                gpointer self)
{
	gboolean result;
	result = ___lambda128_ ((TootleViewsNotifications*) self, (TootleAPINotification*) g);
	return result;
}

static gboolean
tootle_views_notifications_real_request (TootleViewsTimeline* base)
{
	TootleViewsNotifications * self;
	TootleInstanceAccount* _tmp0_;
	gboolean result = FALSE;
	self = (TootleViewsNotifications*) base;
	_tmp0_ = ((TootleViewsTimeline*) self)->account;
	if (_tmp0_ != NULL) {
		TootleInstanceAccount* _tmp1_;
		GeeArrayList* _tmp2_;
		GeeArrayList* _tmp3_;
		_tmp1_ = ((TootleViewsTimeline*) self)->account;
		_tmp2_ = tootle_instance_account_get_cached_notifications (_tmp1_);
		_tmp3_ = _tmp2_;
		gee_abstract_collection_foreach ((GeeAbstractCollection*) _tmp3_, ____lambda128__gee_forall_func, self);
	}
	result = TOOTLE_VIEWS_TIMELINE_CLASS (tootle_views_notifications_parent_class)->request (G_TYPE_CHECK_INSTANCE_CAST (self, TOOTLE_VIEWS_TYPE_TIMELINE, TootleViewsTimeline));
	return result;
}

static gboolean
tootle_views_notifications_has_unread (TootleViewsNotifications* self)
{
	TootleInstanceAccount* _tmp0_;
	gboolean _tmp1_ = FALSE;
	TootleInstanceAccount* _tmp2_;
	gint64 _tmp3_;
	gint64 _tmp4_;
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = ((TootleViewsTimeline*) self)->account;
	if (_tmp0_ == NULL) {
		result = FALSE;
		return result;
	}
	_tmp2_ = ((TootleViewsTimeline*) self)->account;
	_tmp3_ = tootle_instance_account_get_last_seen_notification (_tmp2_);
	_tmp4_ = _tmp3_;
	if (self->last_id > _tmp4_) {
		_tmp1_ = TRUE;
	} else {
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp5_ = tootle_views_base_get_needs_attention ((TootleViewsBase*) self);
		_tmp6_ = _tmp5_;
		_tmp1_ = _tmp6_;
	}
	result = _tmp1_;
	return result;
}

static void
tootle_views_notifications_add_notification (TootleViewsNotifications* self,
                                             TootleAPINotification* n)
{
	GtkWidget* _tmp0_ = NULL;
	GtkWidget* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (n != NULL);
	_tmp1_ = tootle_widgetizable_to_widget ((TootleWidgetizable*) n, &_inner_error0_);
	_tmp0_ = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	tootle_views_timeline_prepend ((TootleViewsTimeline*) self, _tmp0_);
	_g_object_unref0 (_tmp0_);
}

static void
tootle_views_notifications_class_init (TootleViewsNotificationsClass * klass,
                                       gpointer klass_data)
{
	tootle_views_notifications_parent_class = g_type_class_peek_parent (klass);
	((TootleViewsTimelineClass *) klass)->get_stream_url = (gchar* (*) (TootleViewsTimeline*)) tootle_views_notifications_real_get_stream_url;
	((TootleViewsBaseClass *) klass)->on_shown = (void (*) (TootleViewsBase*)) tootle_views_notifications_real_on_shown;
	((TootleViewsTimelineClass *) klass)->append = (void (*) (TootleViewsTimeline*, GtkWidget*, gboolean)) tootle_views_notifications_real_append;
	((TootleViewsTimelineClass *) klass)->on_account_changed = (void (*) (TootleViewsTimeline*, TootleInstanceAccount*)) tootle_views_notifications_real_on_account_changed;
	((TootleViewsTimelineClass *) klass)->request = (gboolean (*) (TootleViewsTimeline*)) tootle_views_notifications_real_request;
	G_OBJECT_CLASS (klass)->finalize = tootle_views_notifications_finalize;
}

static void
tootle_views_notifications_tootle_iaccount_listener_interface_init (TootleIAccountListenerIface * iface,
                                                                    gpointer iface_data)
{
	tootle_views_notifications_tootle_iaccount_listener_parent_iface = g_type_interface_peek_parent (iface);
	iface->on_account_changed = (void (*) (TootleIAccountListener*, TootleInstanceAccount*)) tootle_views_notifications_real_on_account_changed;
}

static void
tootle_views_notifications_tootle_istream_listener_interface_init (TootleIStreamListenerIface * iface,
                                                                   gpointer iface_data)
{
	tootle_views_notifications_tootle_istream_listener_parent_iface = g_type_interface_peek_parent (iface);
}

static void
tootle_views_notifications_instance_init (TootleViewsNotifications * self,
                                          gpointer klass)
{
	self->last_id = (gint64) 0;
}

static void
tootle_views_notifications_finalize (GObject * obj)
{
	TootleViewsNotifications * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_VIEWS_TYPE_NOTIFICATIONS, TootleViewsNotifications);
	G_OBJECT_CLASS (tootle_views_notifications_parent_class)->finalize (obj);
}

static GType
tootle_views_notifications_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleViewsNotificationsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_views_notifications_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleViewsNotifications), 0, (GInstanceInitFunc) tootle_views_notifications_instance_init, NULL };
	static const GInterfaceInfo tootle_iaccount_listener_info = { (GInterfaceInitFunc) tootle_views_notifications_tootle_iaccount_listener_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo tootle_istream_listener_info = { (GInterfaceInitFunc) tootle_views_notifications_tootle_istream_listener_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType tootle_views_notifications_type_id;
	tootle_views_notifications_type_id = g_type_register_static (TOOTLE_VIEWS_TYPE_TIMELINE, "TootleViewsNotifications", &g_define_type_info, 0);
	g_type_add_interface_static (tootle_views_notifications_type_id, TOOTLE_TYPE_IACCOUNT_LISTENER, &tootle_iaccount_listener_info);
	g_type_add_interface_static (tootle_views_notifications_type_id, TOOTLE_TYPE_ISTREAM_LISTENER, &tootle_istream_listener_info);
	return tootle_views_notifications_type_id;
}

GType
tootle_views_notifications_get_type (void)
{
	static volatile gsize tootle_views_notifications_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_views_notifications_type_id__volatile)) {
		GType tootle_views_notifications_type_id;
		tootle_views_notifications_type_id = tootle_views_notifications_get_type_once ();
		g_once_init_leave (&tootle_views_notifications_type_id__volatile, tootle_views_notifications_type_id);
	}
	return tootle_views_notifications_type_id__volatile;
}

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;
}

