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

#include <libsoup/soup.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <json-glib/json-glib.h>
#include <float.h>
#include <math.h>
#include <gee.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <cairo-gobject.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
#include <unistd.h>

#define PDFPC_PATHS_SOURCE_PATH "/build/pdfpc/src/pdfpc-4.7.0"
#define PDFPC_PATHS_SHARE_PATH "/usr/share/pdfpc"
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define PDFPC_TYPE_REST_SERVER (pdfpc_rest_server_get_type ())
#define PDFPC_REST_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_TYPE_REST_SERVER, pdfpcRestServer))
#define PDFPC_REST_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_TYPE_REST_SERVER, pdfpcRestServerClass))
#define PDFPC_IS_REST_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_TYPE_REST_SERVER))
#define PDFPC_IS_REST_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_TYPE_REST_SERVER))
#define PDFPC_REST_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_TYPE_REST_SERVER, pdfpcRestServerClass))

typedef struct _pdfpcRestServer pdfpcRestServer;
typedef struct _pdfpcRestServerClass pdfpcRestServerClass;
typedef struct _pdfpcRestServerPrivate pdfpcRestServerPrivate;

#define PDFPC_METADATA_TYPE_PDF (pdfpc_metadata_pdf_get_type ())
#define PDFPC_METADATA_PDF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_METADATA_TYPE_PDF, pdfpcMetadataPdf))
#define PDFPC_METADATA_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_METADATA_TYPE_PDF, pdfpcMetadataPdfClass))
#define PDFPC_METADATA_IS_PDF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_METADATA_TYPE_PDF))
#define PDFPC_METADATA_IS_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_METADATA_TYPE_PDF))
#define PDFPC_METADATA_PDF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_METADATA_TYPE_PDF, pdfpcMetadataPdfClass))

typedef struct _pdfpcMetadataPdf pdfpcMetadataPdf;
typedef struct _pdfpcMetadataPdfClass pdfpcMetadataPdfClass;
enum  {
	PDFPC_REST_SERVER_0_PROPERTY,
	PDFPC_REST_SERVER_NUM_PROPERTIES
};
static GParamSpec* pdfpc_rest_server_properties[PDFPC_REST_SERVER_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 PDFPC_TYPE_PRESENTATION_CONTROLLER (pdfpc_presentation_controller_get_type ())
#define PDFPC_PRESENTATION_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_TYPE_PRESENTATION_CONTROLLER, pdfpcPresentationController))
#define PDFPC_PRESENTATION_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_TYPE_PRESENTATION_CONTROLLER, pdfpcPresentationControllerClass))
#define PDFPC_IS_PRESENTATION_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_TYPE_PRESENTATION_CONTROLLER))
#define PDFPC_IS_PRESENTATION_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_TYPE_PRESENTATION_CONTROLLER))
#define PDFPC_PRESENTATION_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_TYPE_PRESENTATION_CONTROLLER, pdfpcPresentationControllerClass))

typedef struct _pdfpcPresentationController pdfpcPresentationController;
typedef struct _pdfpcPresentationControllerClass pdfpcPresentationControllerClass;
typedef struct _pdfpcMetadataPdfPrivate pdfpcMetadataPdfPrivate;
typedef enum  {
	PDFPC_METADATA_NOTES_POSITION_NONE,
	PDFPC_METADATA_NOTES_POSITION_TOP,
	PDFPC_METADATA_NOTES_POSITION_BOTTOM,
	PDFPC_METADATA_NOTES_POSITION_RIGHT,
	PDFPC_METADATA_NOTES_POSITION_LEFT
} pdfpcMetadataNotesPosition;

#define PDFPC_METADATA_TYPE_NOTES_POSITION (pdfpc_metadata_notes_position_get_type ())
typedef struct _pdfpcPresentationControllerPrivate pdfpcPresentationControllerPrivate;

#define PDFPC_PRESENTATION_CONTROLLER_TYPE_SCALED_RECTANGLE (pdfpc_presentation_controller_scaled_rectangle_get_type ())
typedef struct _pdfpcPresentationControllerScaledRectangle pdfpcPresentationControllerScaledRectangle;

#define PDFPC_TYPE_CONTROLLABLE (pdfpc_controllable_get_type ())
#define PDFPC_CONTROLLABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_TYPE_CONTROLLABLE, pdfpcControllable))
#define PDFPC_IS_CONTROLLABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_TYPE_CONTROLLABLE))
#define PDFPC_CONTROLLABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), PDFPC_TYPE_CONTROLLABLE, pdfpcControllableIface))

typedef struct _pdfpcControllable pdfpcControllable;
typedef struct _pdfpcControllableIface pdfpcControllableIface;

#define PDFPC_VIEW_TYPE_PDF (pdfpc_view_pdf_get_type ())
#define PDFPC_VIEW_PDF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_VIEW_TYPE_PDF, pdfpcViewPdf))
#define PDFPC_VIEW_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_VIEW_TYPE_PDF, pdfpcViewPdfClass))
#define PDFPC_VIEW_IS_PDF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_VIEW_TYPE_PDF))
#define PDFPC_VIEW_IS_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_VIEW_TYPE_PDF))
#define PDFPC_VIEW_PDF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_VIEW_TYPE_PDF, pdfpcViewPdfClass))

typedef struct _pdfpcViewPdf pdfpcViewPdf;
typedef struct _pdfpcViewPdfClass pdfpcViewPdfClass;

#define PDFPC_TYPE_TIMER (pdfpc_timer_get_type ())
#define PDFPC_TIMER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_TYPE_TIMER, pdfpcTimer))
#define PDFPC_TIMER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_TYPE_TIMER, pdfpcTimerClass))
#define PDFPC_IS_TIMER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_TYPE_TIMER))
#define PDFPC_IS_TIMER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_TYPE_TIMER))
#define PDFPC_TIMER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_TYPE_TIMER, pdfpcTimerClass))

typedef struct _pdfpcTimer pdfpcTimer;
typedef struct _pdfpcTimerClass pdfpcTimerClass;

#define PDFPC_PRESENTATION_CONTROLLER_TYPE_ACTION_DESCRIPTION (pdfpc_presentation_controller_action_description_get_type ())
#define PDFPC_PRESENTATION_CONTROLLER_ACTION_DESCRIPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_PRESENTATION_CONTROLLER_TYPE_ACTION_DESCRIPTION, pdfpcPresentationControllerActionDescription))
#define PDFPC_PRESENTATION_CONTROLLER_ACTION_DESCRIPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_PRESENTATION_CONTROLLER_TYPE_ACTION_DESCRIPTION, pdfpcPresentationControllerActionDescriptionClass))
#define PDFPC_PRESENTATION_CONTROLLER_IS_ACTION_DESCRIPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_PRESENTATION_CONTROLLER_TYPE_ACTION_DESCRIPTION))
#define PDFPC_PRESENTATION_CONTROLLER_IS_ACTION_DESCRIPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_PRESENTATION_CONTROLLER_TYPE_ACTION_DESCRIPTION))
#define PDFPC_PRESENTATION_CONTROLLER_ACTION_DESCRIPTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_PRESENTATION_CONTROLLER_TYPE_ACTION_DESCRIPTION, pdfpcPresentationControllerActionDescriptionClass))

typedef struct _pdfpcPresentationControllerActionDescription pdfpcPresentationControllerActionDescription;
typedef struct _pdfpcPresentationControllerActionDescriptionClass pdfpcPresentationControllerActionDescriptionClass;

#define PDFPC_TYPE_KEY_DEF (pdfpc_key_def_get_type ())
#define PDFPC_KEY_DEF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_TYPE_KEY_DEF, pdfpcKeyDef))
#define PDFPC_KEY_DEF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_TYPE_KEY_DEF, pdfpcKeyDefClass))
#define PDFPC_IS_KEY_DEF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_TYPE_KEY_DEF))
#define PDFPC_IS_KEY_DEF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_TYPE_KEY_DEF))
#define PDFPC_KEY_DEF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_TYPE_KEY_DEF, pdfpcKeyDefClass))

typedef struct _pdfpcKeyDef pdfpcKeyDef;
typedef struct _pdfpcKeyDefClass pdfpcKeyDefClass;

#define PDFPC_PRESENTATION_CONTROLLER_TYPE_ACTION_AND_PARAMETER (pdfpc_presentation_controller_action_and_parameter_get_type ())
#define PDFPC_PRESENTATION_CONTROLLER_ACTION_AND_PARAMETER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_PRESENTATION_CONTROLLER_TYPE_ACTION_AND_PARAMETER, pdfpcPresentationControllerActionAndParameter))
#define PDFPC_PRESENTATION_CONTROLLER_ACTION_AND_PARAMETER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_PRESENTATION_CONTROLLER_TYPE_ACTION_AND_PARAMETER, pdfpcPresentationControllerActionAndParameterClass))
#define PDFPC_PRESENTATION_CONTROLLER_IS_ACTION_AND_PARAMETER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_PRESENTATION_CONTROLLER_TYPE_ACTION_AND_PARAMETER))
#define PDFPC_PRESENTATION_CONTROLLER_IS_ACTION_AND_PARAMETER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_PRESENTATION_CONTROLLER_TYPE_ACTION_AND_PARAMETER))
#define PDFPC_PRESENTATION_CONTROLLER_ACTION_AND_PARAMETER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_PRESENTATION_CONTROLLER_TYPE_ACTION_AND_PARAMETER, pdfpcPresentationControllerActionAndParameterClass))

typedef struct _pdfpcPresentationControllerActionAndParameter pdfpcPresentationControllerActionAndParameter;
typedef struct _pdfpcPresentationControllerActionAndParameterClass pdfpcPresentationControllerActionAndParameterClass;

#define TYPE_SCREEN_SAVER (screen_saver_get_type ())
#define SCREEN_SAVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SCREEN_SAVER, ScreenSaver))
#define IS_SCREEN_SAVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SCREEN_SAVER))
#define SCREEN_SAVER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_SCREEN_SAVER, ScreenSaverIface))

typedef struct _ScreenSaver ScreenSaver;
typedef struct _ScreenSaverIface ScreenSaverIface;

#define TYPE_SCREEN_SAVER_PROXY (screen_saver_proxy_get_type ())

#define PDFPC_PRESENTATION_CONTROLLER_TYPE_POINTER_TOOL (pdfpc_presentation_controller_pointer_tool_get_type ())
#define PDFPC_PRESENTATION_CONTROLLER_POINTER_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_PRESENTATION_CONTROLLER_TYPE_POINTER_TOOL, pdfpcPresentationControllerPointerTool))
#define PDFPC_PRESENTATION_CONTROLLER_POINTER_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_PRESENTATION_CONTROLLER_TYPE_POINTER_TOOL, pdfpcPresentationControllerPointerToolClass))
#define PDFPC_PRESENTATION_CONTROLLER_IS_POINTER_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_PRESENTATION_CONTROLLER_TYPE_POINTER_TOOL))
#define PDFPC_PRESENTATION_CONTROLLER_IS_POINTER_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_PRESENTATION_CONTROLLER_TYPE_POINTER_TOOL))
#define PDFPC_PRESENTATION_CONTROLLER_POINTER_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_PRESENTATION_CONTROLLER_TYPE_POINTER_TOOL, pdfpcPresentationControllerPointerToolClass))

typedef struct _pdfpcPresentationControllerPointerTool pdfpcPresentationControllerPointerTool;
typedef struct _pdfpcPresentationControllerPointerToolClass pdfpcPresentationControllerPointerToolClass;

#define PDFPC_DRAWINGS_TYPE_DRAWING (pdfpc_drawings_drawing_get_type ())
#define PDFPC_DRAWINGS_DRAWING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_DRAWINGS_TYPE_DRAWING, pdfpcDrawingsDrawing))
#define PDFPC_DRAWINGS_DRAWING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_DRAWINGS_TYPE_DRAWING, pdfpcDrawingsDrawingClass))
#define PDFPC_DRAWINGS_IS_DRAWING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_DRAWINGS_TYPE_DRAWING))
#define PDFPC_DRAWINGS_IS_DRAWING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_DRAWINGS_TYPE_DRAWING))
#define PDFPC_DRAWINGS_DRAWING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_DRAWINGS_TYPE_DRAWING, pdfpcDrawingsDrawingClass))

typedef struct _pdfpcDrawingsDrawing pdfpcDrawingsDrawing;
typedef struct _pdfpcDrawingsDrawingClass pdfpcDrawingsDrawingClass;

#define PDFPC_DRAWINGS_TYPE_DRAWING_TOOL (pdfpc_drawings_drawing_tool_get_type ())
#define PDFPC_DRAWINGS_DRAWING_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_DRAWINGS_TYPE_DRAWING_TOOL, pdfpcDrawingsDrawingTool))
#define PDFPC_DRAWINGS_DRAWING_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_DRAWINGS_TYPE_DRAWING_TOOL, pdfpcDrawingsDrawingToolClass))
#define PDFPC_DRAWINGS_IS_DRAWING_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_DRAWINGS_TYPE_DRAWING_TOOL))
#define PDFPC_DRAWINGS_IS_DRAWING_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_DRAWINGS_TYPE_DRAWING_TOOL))
#define PDFPC_DRAWINGS_DRAWING_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_DRAWINGS_TYPE_DRAWING_TOOL, pdfpcDrawingsDrawingToolClass))

typedef struct _pdfpcDrawingsDrawingTool pdfpcDrawingsDrawingTool;
typedef struct _pdfpcDrawingsDrawingToolClass pdfpcDrawingsDrawingToolClass;
typedef enum  {
	PDFPC_PRESENTATION_CONTROLLER_PROGRESS_STATUS_PreTalk,
	PDFPC_PRESENTATION_CONTROLLER_PROGRESS_STATUS_Normal,
	PDFPC_PRESENTATION_CONTROLLER_PROGRESS_STATUS_Slow,
	PDFPC_PRESENTATION_CONTROLLER_PROGRESS_STATUS_Fast,
	PDFPC_PRESENTATION_CONTROLLER_PROGRESS_STATUS_LastMinutes,
	PDFPC_PRESENTATION_CONTROLLER_PROGRESS_STATUS_Overtime
} pdfpcPresentationControllerProgressStatus;

#define PDFPC_PRESENTATION_CONTROLLER_TYPE_PROGRESS_STATUS (pdfpc_presentation_controller_progress_status_get_type ())

#define PDFPC_RENDERER_TYPE_PDF (pdfpc_renderer_pdf_get_type ())
#define PDFPC_RENDERER_PDF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_RENDERER_TYPE_PDF, pdfpcRendererPdf))
#define PDFPC_RENDERER_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_RENDERER_TYPE_PDF, pdfpcRendererPdfClass))
#define PDFPC_RENDERER_IS_PDF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_RENDERER_TYPE_PDF))
#define PDFPC_RENDERER_IS_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_RENDERER_TYPE_PDF))
#define PDFPC_RENDERER_PDF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_RENDERER_TYPE_PDF, pdfpcRendererPdfClass))

typedef struct _pdfpcRendererPdf pdfpcRendererPdf;
typedef struct _pdfpcRendererPdfClass pdfpcRendererPdfClass;

#define PDFPC_RENDERER_TYPE_RENDER_ERROR (pdfpc_renderer_render_error_get_type ())
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _soup_message_headers_unref0(var) ((var == NULL) ? NULL : (var = (soup_message_headers_unref (var), NULL)))
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _soup_message_body_unref0(var) ((var == NULL) ? NULL : (var = (soup_message_body_unref (var), NULL)))
#define _g_rand_free0(var) ((var == NULL) ? NULL : (var = (g_rand_free (var), NULL)))

struct _pdfpcRestServer {
	SoupServer parent_instance;
	pdfpcRestServerPrivate * priv;
};

struct _pdfpcRestServerClass {
	SoupServerClass parent_class;
};

struct _pdfpcRestServerPrivate {
	gint api_version;
	pdfpcMetadataPdf* metadata;
	gint port_num;
	gboolean locked;
	gchar* client_host;
	gchar* static_root;
};

struct _pdfpcMetadataPdf {
	GObject parent_instance;
	pdfpcMetadataPdfPrivate * priv;
	pdfpcPresentationController* controller;
	gchar* pdfpc_fname;
	guint page_count;
	gdouble original_page_width;
	gdouble original_page_height;
	gint format_version;
	pdfpcMetadataNotesPosition notes_position;
	gboolean disable_markdown;
	guint duration;
	gchar* start_time;
	gchar* end_time;
	guint last_minutes;
	gint font_size;
};

struct _pdfpcMetadataPdfClass {
	GObjectClass parent_class;
};

struct _pdfpcPresentationControllerScaledRectangle {
	gdouble x;
	gdouble y;
	gdouble width;
	gdouble height;
};

struct _pdfpcControllableIface {
	GTypeInterface parent_iface;
	pdfpcPresentationController* (*get_controller) (pdfpcControllable* self);
	void (*set_controller) (pdfpcControllable* self, pdfpcPresentationController* value);
	pdfpcViewPdf* (*get_main_view) (pdfpcControllable* self);
	void (*set_main_view) (pdfpcControllable* self, pdfpcViewPdf* value);
};

struct _ScreenSaverIface {
	GTypeInterface parent_iface;
	void (*inhibit) (ScreenSaver* self, const gchar* application_name, const gchar* reason, GAsyncReadyCallback _callback_, gpointer _user_data_);
	guint32 (*inhibit_finish) (ScreenSaver* self, GAsyncResult* _res_, GError** error);
	void (*un_inhibit) (ScreenSaver* self, guint32 cookie, GError** error);
};

struct _pdfpcPresentationController {
	GObject parent_instance;
	pdfpcPresentationControllerPrivate * priv;
	pdfpcPresentationControllerScaledRectangle highlight;
	gboolean zoom_stack_drawing;
	pdfpcPresentationControllerScaledRectangle zoom_stack_highlight;
	GeeList* controllables;
	pdfpcTimer* timer;
	GSimpleActionGroup* action_group;
	GeeArrayList* action_descriptions;
	GeeHashMap* keyBindings;
	GeeHashMap* mouseBindings;
	ScreenSaver* screensaver;
	guint32 screensaver_cookie;
	pdfpcPresentationControllerPointerTool* pointer;
	pdfpcPresentationControllerPointerTool* spotlight;
	pdfpcDrawingsDrawing* pen_drawing;
	pdfpcDrawingsDrawingTool* current_pen_drawing_tool;
	gdouble pen_last_x;
	gdouble pen_last_y;
	gboolean pen_is_pressed;
	guint pointer_step;
	gboolean pointer_hidden;
	guint pointer_timeout_id;
	guint autoadvance_timeout_id;
	gdouble drag_x;
	gdouble drag_y;
	gdouble pointer_x;
	gdouble pointer_y;
};

struct _pdfpcPresentationControllerClass {
	GObjectClass parent_class;
};

typedef enum  {
	PDFPC_RENDERER_RENDER_ERROR_SLIDE_DOES_NOT_EXIST
} pdfpcRendererRenderError;
#define PDFPC_RENDERER_RENDER_ERROR pdfpc_renderer_render_error_quark ()

static gint pdfpcRestServer_private_offset;
static gpointer pdfpc_rest_server_parent_class = NULL;
VALA_EXTERN gchar* pdfpc_options_end_time;
VALA_EXTERN gchar* pdfpc_options_start_time;
VALA_EXTERN guint pdfpc_options_last_minutes;
VALA_EXTERN gchar* pdfpc_options_default_transition;
VALA_EXTERN gboolean pdfpc_options_rest_https;
VALA_EXTERN gchar* pdfpc_options_rest_static_root;
VALA_EXTERN gboolean pdfpc_options_no_install;
VALA_EXTERN gchar* pdfpc_options_rest_passwd;

VALA_EXTERN GType pdfpc_rest_server_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcRestServer, g_object_unref)
VALA_EXTERN GType pdfpc_metadata_pdf_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcMetadataPdf, g_object_unref)
static JsonNode* pdfpc_rest_server_helo_data (pdfpcRestServer* self);
static JsonNode* pdfpc_rest_server_meta_data (pdfpcRestServer* self);
VALA_EXTERN guint pdfpc_metadata_pdf_get_slide_count (pdfpcMetadataPdf* self);
VALA_EXTERN gint pdfpc_metadata_pdf_get_user_slide_count (pdfpcMetadataPdf* self);
VALA_EXTERN guint pdfpc_metadata_pdf_get_duration (pdfpcMetadataPdf* self);
VALA_EXTERN gdouble pdfpc_metadata_pdf_get_page_width (pdfpcMetadataPdf* self);
VALA_EXTERN gdouble pdfpc_metadata_pdf_get_page_height (pdfpcMetadataPdf* self);
VALA_EXTERN gboolean pdfpc_metadata_pdf_get_has_beamer_notes (pdfpcMetadataPdf* self);
static JsonNode* pdfpc_rest_server_error_data (pdfpcRestServer* self,
                                        const gchar* message);
static JsonNode* pdfpc_rest_server_pointer_data (pdfpcRestServer* self);
VALA_EXTERN GType pdfpc_presentation_controller_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcPresentationController, g_object_unref)
VALA_EXTERN GType pdfpc_metadata_notes_position_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar* pdfpc_presentation_controller_get_mode_string (pdfpcPresentationController* self);
VALA_EXTERN GType pdfpc_presentation_controller_scaled_rectangle_get_type (void) G_GNUC_CONST ;
VALA_EXTERN pdfpcPresentationControllerScaledRectangle* pdfpc_presentation_controller_scaled_rectangle_dup (const pdfpcPresentationControllerScaledRectangle* self);
VALA_EXTERN void pdfpc_presentation_controller_scaled_rectangle_free (pdfpcPresentationControllerScaledRectangle* self);
VALA_EXTERN GType pdfpc_view_pdf_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcViewPdf, g_object_unref)
VALA_EXTERN GType pdfpc_controllable_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcControllable, g_object_unref)
VALA_EXTERN GType pdfpc_timer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcTimer, g_object_unref)
VALA_EXTERN GType pdfpc_presentation_controller_action_description_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcPresentationControllerActionDescription, g_object_unref)
VALA_EXTERN GType pdfpc_key_def_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcKeyDef, g_object_unref)
VALA_EXTERN GType pdfpc_presentation_controller_action_and_parameter_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcPresentationControllerActionAndParameter, g_object_unref)
VALA_EXTERN GType screen_saver_proxy_get_type (void) G_GNUC_CONST ;
VALA_EXTERN guint screen_saver_register_object (void* object,
                                    GDBusConnection* connection,
                                    const gchar* path,
                                    GError** error);
VALA_EXTERN GType screen_saver_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScreenSaver, g_object_unref)
VALA_EXTERN gpointer pdfpc_presentation_controller_pointer_tool_ref (gpointer instance);
VALA_EXTERN void pdfpc_presentation_controller_pointer_tool_unref (gpointer instance);
VALA_EXTERN GParamSpec* pdfpc_presentation_controller_param_spec_pointer_tool (const gchar* name,
                                                                   const gchar* nick,
                                                                   const gchar* blurb,
                                                                   GType object_type,
                                                                   GParamFlags flags);
VALA_EXTERN void pdfpc_presentation_controller_value_set_pointer_tool (GValue* value,
                                                           gpointer v_object);
VALA_EXTERN void pdfpc_presentation_controller_value_take_pointer_tool (GValue* value,
                                                            gpointer v_object);
VALA_EXTERN gpointer pdfpc_presentation_controller_value_get_pointer_tool (const GValue* value);
VALA_EXTERN GType pdfpc_presentation_controller_pointer_tool_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcPresentationControllerPointerTool, pdfpc_presentation_controller_pointer_tool_unref)
VALA_EXTERN GType pdfpc_drawings_drawing_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcDrawingsDrawing, g_object_unref)
VALA_EXTERN gpointer pdfpc_drawings_drawing_tool_ref (gpointer instance);
VALA_EXTERN void pdfpc_drawings_drawing_tool_unref (gpointer instance);
VALA_EXTERN GParamSpec* pdfpc_drawings_param_spec_drawing_tool (const gchar* name,
                                                    const gchar* nick,
                                                    const gchar* blurb,
                                                    GType object_type,
                                                    GParamFlags flags);
VALA_EXTERN void pdfpc_drawings_value_set_drawing_tool (GValue* value,
                                            gpointer v_object);
VALA_EXTERN void pdfpc_drawings_value_take_drawing_tool (GValue* value,
                                             gpointer v_object);
VALA_EXTERN gpointer pdfpc_drawings_value_get_drawing_tool (const GValue* value);
VALA_EXTERN GType pdfpc_drawings_drawing_tool_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcDrawingsDrawingTool, pdfpc_drawings_drawing_tool_unref)
static JsonNode* pdfpc_rest_server_state_data (pdfpcRestServer* self);
VALA_EXTERN gboolean pdfpc_presentation_controller_is_running (pdfpcPresentationController* self);
VALA_EXTERN gboolean pdfpc_presentation_controller_is_paused (pdfpcPresentationController* self);
VALA_EXTERN GType pdfpc_presentation_controller_progress_status_get_type (void) G_GNUC_CONST ;
VALA_EXTERN pdfpcPresentationControllerProgressStatus pdfpc_presentation_controller_get_progress_status (pdfpcPresentationController* self);
VALA_EXTERN gboolean pdfpc_presentation_controller_get_frozen (pdfpcPresentationController* self);
VALA_EXTERN gboolean pdfpc_presentation_controller_get_hidden (pdfpcPresentationController* self);
VALA_EXTERN gboolean pdfpc_presentation_controller_get_faded_to_black (pdfpcPresentationController* self);
VALA_EXTERN gint pdfpc_presentation_controller_get_current_slide_number (pdfpcPresentationController* self);
VALA_EXTERN gint pdfpc_presentation_controller_get_current_user_slide_number (pdfpcPresentationController* self);
VALA_EXTERN gint pdfpc_metadata_pdf_get_end_user_slide (pdfpcMetadataPdf* self);
VALA_EXTERN gint pdfpc_metadata_pdf_get_font_size (pdfpcMetadataPdf* self);
VALA_EXTERN gboolean pdfpc_presentation_controller_get_in_zoom (pdfpcPresentationController* self);
static JsonNode* pdfpc_rest_server_slide_data (pdfpcRestServer* self,
                                        gint slide_number);
VALA_EXTERN gint pdfpc_metadata_pdf_real_slide_to_user_slide (pdfpcMetadataPdf* self,
                                                  gint number);
static JsonNode* pdfpc_rest_server_note_data (pdfpcRestServer* self,
                                       gint slide_number);
static guint8* pdfpc_rest_server_get_slide_png (pdfpcRestServer* self,
                                         gint slide_number,
                                         gint width,
                                         gint height,
                                         gboolean notes_area,
                                         gint* result_length1);
VALA_EXTERN GType pdfpc_renderer_pdf_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcRendererPdf, g_object_unref)
VALA_EXTERN pdfpcRendererPdf* pdfpc_metadata_pdf_get_renderer (pdfpcMetadataPdf* self);
VALA_EXTERN GQuark pdfpc_renderer_render_error_quark (void);
VALA_EXTERN GType pdfpc_renderer_render_error_get_type (void) G_GNUC_CONST ;
VALA_EXTERN cairo_surface_t* pdfpc_renderer_pdf_render (pdfpcRendererPdf* self,
                                            gint slide_number,
                                            gboolean notes_area,
                                            gint width,
                                            gint height,
                                            gboolean force_cache,
                                            gboolean permanent_cache,
                                            pdfpcPresentationControllerScaledRectangle* zoom_area,
                                            GError** error);
static void pdfpc_rest_server_static_handler (pdfpcRestServer* self,
                                       SoupServer* server,
                                       SoupServerMessage* msg,
                                       const gchar* path,
                                       GHashTable* query);
static void pdfpc_rest_server_api_handler (pdfpcRestServer* self,
                                    SoupServer* server,
                                    SoupServerMessage* msg,
                                    const gchar* path,
                                    GHashTable* query);
VALA_EXTERN void pdfpc_presentation_controller_hide_qrcode (pdfpcPresentationController* self);
static void _vala_JsonNode_free (JsonNode* self);
VALA_EXTERN gchar* pdfpc_metadata_pdf_get_note (pdfpcMetadataPdf* self,
                                    gint slide_number);
VALA_EXTERN gchar* pdfpc_renderer_md_render (const gchar* text,
                                 gboolean plain_text);
VALA_EXTERN gboolean pdfpc_metadata_pdf_get_disable_markdown (pdfpcMetadataPdf* self);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
VALA_EXTERN void pdfpc_presentation_controller_trigger_action (pdfpcPresentationController* self,
                                                   const gchar* name,
                                                   GVariant* parameter);
static GVariant* _variant_new2 (const gchar* value);
VALA_EXTERN pdfpcRestServer* pdfpc_rest_server_new (pdfpcMetadataPdf* metadata,
                                        gint port_num);
VALA_EXTERN pdfpcRestServer* pdfpc_rest_server_construct (GType object_type,
                                              pdfpcMetadataPdf* metadata,
                                              gint port_num);
static void _pdfpc_rest_server_api_handler_soup_server_callback (SoupServer* server,
                                                          SoupServerMessage* msg,
                                                          const gchar* path,
                                                          GHashTable* query,
                                                          gpointer self);
static void _pdfpc_rest_server_static_handler_soup_server_callback (SoupServer* server,
                                                             SoupServerMessage* msg,
                                                             const gchar* path,
                                                             GHashTable* query,
                                                             gpointer self);
static gboolean __lambda9_ (pdfpcRestServer* self,
                     SoupAuthDomainBasic* domain,
                     SoupServerMessage* msg,
                     const gchar* username,
                     const gchar* password);
static gboolean ___lambda9__soup_auth_domain_basic_auth_callback (SoupAuthDomainBasic* domain,
                                                           SoupServerMessage* msg,
                                                           const gchar* username,
                                                           const gchar* password,
                                                           gpointer self);
static gboolean __lambda10_ (pdfpcRestServer* self,
                      SoupAuthDomain* domain,
                      SoupServerMessage* msg);
static gboolean ___lambda10__soup_auth_domain_filter (SoupAuthDomain* domain,
                                               SoupServerMessage* msg,
                                               gpointer self);
VALA_EXTERN void pdfpc_rest_server_start (pdfpcRestServer* self);
VALA_EXTERN gchar* pdfpc_rest_server_get_connection_info (pdfpcRestServer* self);
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
static void pdfpc_rest_server_finalize (GObject * obj);
static GType pdfpc_rest_server_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
pdfpc_rest_server_get_instance_private (pdfpcRestServer* self)
{
	return G_STRUCT_MEMBER_P (self, pdfpcRestServer_private_offset);
}

static JsonNode*
pdfpc_rest_server_helo_data (pdfpcRestServer* self)
{
	JsonBuilder* builder = NULL;
	JsonBuilder* _tmp0_;
	JsonNode* _tmp1_;
	JsonNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = json_builder_new ();
	builder = _tmp0_;
	json_builder_begin_object (builder);
	json_builder_set_member_name (builder, "application");
	json_builder_add_string_value (builder, "pdfpc");
	json_builder_set_member_name (builder, "api");
	json_builder_add_int_value (builder, (gint64) self->priv->api_version);
	json_builder_end_object (builder);
	_tmp1_ = json_builder_get_root (builder);
	result = _tmp1_;
	_g_object_unref0 (builder);
	return result;
}

static JsonNode*
pdfpc_rest_server_meta_data (pdfpcRestServer* self)
{
	JsonBuilder* builder = NULL;
	JsonBuilder* _tmp0_;
	pdfpcMetadataPdf* _tmp1_;
	pdfpcMetadataPdf* _tmp2_;
	pdfpcMetadataPdf* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gdouble aspect_ratio = 0.0;
	pdfpcMetadataPdf* _tmp7_;
	pdfpcMetadataPdf* _tmp8_;
	gchar* buf = NULL;
	gchar* _tmp9_;
	gint buf_length1;
	gint _buf_size_;
	const gchar* _tmp10_;
	pdfpcMetadataPdf* _tmp11_;
	gboolean _tmp12_;
	gboolean _tmp13_;
	JsonNode* _tmp14_;
	JsonNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = json_builder_new ();
	builder = _tmp0_;
	json_builder_begin_object (builder);
	json_builder_set_member_name (builder, "slides");
	_tmp1_ = self->priv->metadata;
	json_builder_add_int_value (builder, (gint64) pdfpc_metadata_pdf_get_slide_count (_tmp1_));
	json_builder_set_member_name (builder, "user_slides");
	_tmp2_ = self->priv->metadata;
	json_builder_add_int_value (builder, (gint64) pdfpc_metadata_pdf_get_user_slide_count (_tmp2_));
	json_builder_set_member_name (builder, "duration");
	_tmp3_ = self->priv->metadata;
	json_builder_add_int_value (builder, (gint64) pdfpc_metadata_pdf_get_duration (_tmp3_));
	json_builder_set_member_name (builder, "end_time");
	_tmp4_ = pdfpc_options_end_time;
	json_builder_add_string_value (builder, _tmp4_);
	json_builder_set_member_name (builder, "start_time");
	_tmp5_ = pdfpc_options_start_time;
	json_builder_add_string_value (builder, _tmp5_);
	json_builder_set_member_name (builder, "last_minutes");
	json_builder_add_int_value (builder, (gint64) pdfpc_options_last_minutes);
	json_builder_set_member_name (builder, "default_transition");
	_tmp6_ = pdfpc_options_default_transition;
	json_builder_add_string_value (builder, _tmp6_);
	_tmp7_ = self->priv->metadata;
	_tmp8_ = self->priv->metadata;
	aspect_ratio = pdfpc_metadata_pdf_get_page_width (_tmp7_) / pdfpc_metadata_pdf_get_page_height (_tmp8_);
	_tmp9_ = g_new0 (gchar, G_ASCII_DTOSTR_BUF_SIZE);
	buf = _tmp9_;
	buf_length1 = G_ASCII_DTOSTR_BUF_SIZE;
	_buf_size_ = buf_length1;
	json_builder_set_member_name (builder, "aspect_ratio");
	_tmp10_ = g_ascii_formatd (buf, (gint) buf_length1, "%.4f", aspect_ratio);
	json_builder_add_string_value (builder, _tmp10_);
	json_builder_set_member_name (builder, "note_is_image");
	_tmp11_ = self->priv->metadata;
	_tmp12_ = pdfpc_metadata_pdf_get_has_beamer_notes (_tmp11_);
	_tmp13_ = _tmp12_;
	json_builder_add_boolean_value (builder, _tmp13_);
	json_builder_end_object (builder);
	_tmp14_ = json_builder_get_root (builder);
	result = _tmp14_;
	buf = (g_free (buf), NULL);
	_g_object_unref0 (builder);
	return result;
}

static JsonNode*
pdfpc_rest_server_error_data (pdfpcRestServer* self,
                              const gchar* message)
{
	JsonBuilder* builder = NULL;
	JsonBuilder* _tmp0_;
	JsonNode* _tmp1_;
	JsonNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (message != NULL, NULL);
	_tmp0_ = json_builder_new ();
	builder = _tmp0_;
	json_builder_begin_object (builder);
	json_builder_set_member_name (builder, "message");
	json_builder_add_string_value (builder, message);
	json_builder_end_object (builder);
	_tmp1_ = json_builder_get_root (builder);
	result = _tmp1_;
	_g_object_unref0 (builder);
	return result;
}

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

static JsonNode*
pdfpc_rest_server_pointer_data (pdfpcRestServer* self)
{
	pdfpcPresentationController* controller = NULL;
	pdfpcMetadataPdf* _tmp0_;
	pdfpcPresentationController* _tmp1_;
	pdfpcPresentationController* _tmp2_;
	JsonBuilder* builder = NULL;
	JsonBuilder* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	JsonNode* _tmp6_;
	JsonNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->metadata;
	_tmp1_ = _tmp0_->controller;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	controller = _tmp2_;
	_tmp3_ = json_builder_new ();
	builder = _tmp3_;
	json_builder_begin_object (builder);
	json_builder_set_member_name (builder, "mode");
	_tmp4_ = pdfpc_presentation_controller_get_mode_string (controller);
	_tmp5_ = _tmp4_;
	json_builder_add_string_value (builder, _tmp5_);
	_g_free0 (_tmp5_);
	json_builder_set_member_name (builder, "x");
	json_builder_add_double_value (builder, controller->pointer_x);
	json_builder_set_member_name (builder, "y");
	json_builder_add_double_value (builder, controller->pointer_y);
	json_builder_end_object (builder);
	_tmp6_ = json_builder_get_root (builder);
	result = _tmp6_;
	_g_object_unref0 (builder);
	_g_object_unref0 (controller);
	return result;
}

static JsonNode*
pdfpc_rest_server_state_data (pdfpcRestServer* self)
{
	pdfpcPresentationController* controller = NULL;
	pdfpcMetadataPdf* _tmp0_;
	pdfpcPresentationController* _tmp1_;
	pdfpcPresentationController* _tmp2_;
	JsonBuilder* builder = NULL;
	JsonBuilder* _tmp3_;
	JsonBuilder* _tmp4_;
	gchar* statestr = NULL;
	JsonBuilder* _tmp5_;
	pdfpcPresentationController* _tmp6_;
	JsonBuilder* _tmp11_;
	const gchar* _tmp12_;
	JsonBuilder* _tmp13_;
	gchar* progress_status_str = NULL;
	pdfpcPresentationController* _tmp14_;
	pdfpcPresentationControllerProgressStatus _tmp15_;
	pdfpcPresentationControllerProgressStatus _tmp16_;
	JsonBuilder* _tmp23_;
	const gchar* _tmp24_;
	JsonBuilder* _tmp25_;
	JsonBuilder* _tmp26_;
	pdfpcPresentationController* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	JsonBuilder* _tmp30_;
	JsonBuilder* _tmp31_;
	pdfpcPresentationController* _tmp32_;
	gboolean _tmp33_;
	gboolean _tmp34_;
	JsonBuilder* _tmp35_;
	JsonBuilder* _tmp36_;
	pdfpcPresentationController* _tmp37_;
	gboolean _tmp38_;
	gboolean _tmp39_;
	JsonBuilder* _tmp40_;
	JsonBuilder* _tmp41_;
	pdfpcPresentationController* _tmp42_;
	gboolean _tmp43_;
	gboolean _tmp44_;
	JsonBuilder* _tmp45_;
	JsonBuilder* _tmp46_;
	pdfpcPresentationController* _tmp47_;
	gint _tmp48_;
	gint _tmp49_;
	JsonBuilder* _tmp50_;
	JsonBuilder* _tmp51_;
	pdfpcPresentationController* _tmp52_;
	gint _tmp53_;
	gint _tmp54_;
	JsonBuilder* _tmp55_;
	JsonBuilder* _tmp56_;
	pdfpcMetadataPdf* _tmp57_;
	JsonBuilder* _tmp58_;
	JsonBuilder* _tmp59_;
	pdfpcMetadataPdf* _tmp60_;
	JsonBuilder* _tmp61_;
	JsonBuilder* _tmp62_;
	pdfpcPresentationController* _tmp63_;
	gboolean _tmp64_;
	gboolean _tmp65_;
	JsonBuilder* _tmp66_;
	JsonBuilder* _tmp67_;
	JsonBuilder* _tmp68_;
	JsonBuilder* _tmp69_;
	pdfpcPresentationController* _tmp70_;
	pdfpcPresentationControllerScaledRectangle _tmp71_;
	JsonBuilder* _tmp72_;
	JsonBuilder* _tmp73_;
	pdfpcPresentationController* _tmp74_;
	pdfpcPresentationControllerScaledRectangle _tmp75_;
	JsonBuilder* _tmp76_;
	JsonBuilder* _tmp77_;
	pdfpcPresentationController* _tmp78_;
	pdfpcPresentationControllerScaledRectangle _tmp79_;
	JsonBuilder* _tmp80_;
	JsonBuilder* _tmp81_;
	pdfpcPresentationController* _tmp82_;
	pdfpcPresentationControllerScaledRectangle _tmp83_;
	JsonBuilder* _tmp84_;
	JsonBuilder* _tmp85_;
	JsonBuilder* _tmp86_;
	JsonNode* _tmp87_;
	JsonNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->metadata;
	_tmp1_ = _tmp0_->controller;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	controller = _tmp2_;
	_tmp3_ = json_builder_new ();
	builder = _tmp3_;
	_tmp4_ = builder;
	json_builder_begin_object (_tmp4_);
	_tmp5_ = builder;
	json_builder_set_member_name (_tmp5_, "state");
	_tmp6_ = controller;
	if (pdfpc_presentation_controller_is_running (_tmp6_)) {
		gchar* _tmp7_;
		_tmp7_ = g_strdup ("running");
		_g_free0 (statestr);
		statestr = _tmp7_;
	} else {
		pdfpcPresentationController* _tmp8_;
		_tmp8_ = controller;
		if (pdfpc_presentation_controller_is_paused (_tmp8_)) {
			gchar* _tmp9_;
			_tmp9_ = g_strdup ("paused");
			_g_free0 (statestr);
			statestr = _tmp9_;
		} else {
			gchar* _tmp10_;
			_tmp10_ = g_strdup ("stopped");
			_g_free0 (statestr);
			statestr = _tmp10_;
		}
	}
	_tmp11_ = builder;
	_tmp12_ = statestr;
	json_builder_add_string_value (_tmp11_, _tmp12_);
	_tmp13_ = builder;
	json_builder_set_member_name (_tmp13_, "progress_status");
	_tmp14_ = controller;
	_tmp15_ = pdfpc_presentation_controller_get_progress_status (_tmp14_);
	_tmp16_ = _tmp15_;
	switch (_tmp16_) {
		case PDFPC_PRESENTATION_CONTROLLER_PROGRESS_STATUS_PreTalk:
		{
			gchar* _tmp17_;
			_tmp17_ = g_strdup ("pretalk");
			_g_free0 (progress_status_str);
			progress_status_str = _tmp17_;
			break;
		}
		case PDFPC_PRESENTATION_CONTROLLER_PROGRESS_STATUS_Fast:
		{
			gchar* _tmp18_;
			_tmp18_ = g_strdup ("too-fast");
			_g_free0 (progress_status_str);
			progress_status_str = _tmp18_;
			break;
		}
		case PDFPC_PRESENTATION_CONTROLLER_PROGRESS_STATUS_Slow:
		{
			gchar* _tmp19_;
			_tmp19_ = g_strdup ("too-slow");
			_g_free0 (progress_status_str);
			progress_status_str = _tmp19_;
			break;
		}
		case PDFPC_PRESENTATION_CONTROLLER_PROGRESS_STATUS_LastMinutes:
		{
			gchar* _tmp20_;
			_tmp20_ = g_strdup ("last-minutes");
			_g_free0 (progress_status_str);
			progress_status_str = _tmp20_;
			break;
		}
		case PDFPC_PRESENTATION_CONTROLLER_PROGRESS_STATUS_Overtime:
		{
			gchar* _tmp21_;
			_tmp21_ = g_strdup ("overtime");
			_g_free0 (progress_status_str);
			progress_status_str = _tmp21_;
			break;
		}
		default:
		{
			gchar* _tmp22_;
			_tmp22_ = g_strdup ("normal");
			_g_free0 (progress_status_str);
			progress_status_str = _tmp22_;
			break;
		}
	}
	_tmp23_ = builder;
	_tmp24_ = progress_status_str;
	json_builder_add_string_value (_tmp23_, _tmp24_);
	_tmp25_ = builder;
	json_builder_set_member_name (_tmp25_, "mode");
	_tmp26_ = builder;
	_tmp27_ = controller;
	_tmp28_ = pdfpc_presentation_controller_get_mode_string (_tmp27_);
	_tmp29_ = _tmp28_;
	json_builder_add_string_value (_tmp26_, _tmp29_);
	_g_free0 (_tmp29_);
	_tmp30_ = builder;
	json_builder_set_member_name (_tmp30_, "frozen");
	_tmp31_ = builder;
	_tmp32_ = controller;
	_tmp33_ = pdfpc_presentation_controller_get_frozen (_tmp32_);
	_tmp34_ = _tmp33_;
	json_builder_add_boolean_value (_tmp31_, _tmp34_);
	_tmp35_ = builder;
	json_builder_set_member_name (_tmp35_, "hidden");
	_tmp36_ = builder;
	_tmp37_ = controller;
	_tmp38_ = pdfpc_presentation_controller_get_hidden (_tmp37_);
	_tmp39_ = _tmp38_;
	json_builder_add_boolean_value (_tmp36_, _tmp39_);
	_tmp40_ = builder;
	json_builder_set_member_name (_tmp40_, "black");
	_tmp41_ = builder;
	_tmp42_ = controller;
	_tmp43_ = pdfpc_presentation_controller_get_faded_to_black (_tmp42_);
	_tmp44_ = _tmp43_;
	json_builder_add_boolean_value (_tmp41_, _tmp44_);
	_tmp45_ = builder;
	json_builder_set_member_name (_tmp45_, "slide");
	_tmp46_ = builder;
	_tmp47_ = controller;
	_tmp48_ = pdfpc_presentation_controller_get_current_slide_number (_tmp47_);
	_tmp49_ = _tmp48_;
	json_builder_add_int_value (_tmp46_, (gint64) _tmp49_);
	_tmp50_ = builder;
	json_builder_set_member_name (_tmp50_, "user_slide");
	_tmp51_ = builder;
	_tmp52_ = controller;
	_tmp53_ = pdfpc_presentation_controller_get_current_user_slide_number (_tmp52_);
	_tmp54_ = _tmp53_;
	json_builder_add_int_value (_tmp51_, (gint64) _tmp54_);
	_tmp55_ = builder;
	json_builder_set_member_name (_tmp55_, "end_user_slide");
	_tmp56_ = builder;
	_tmp57_ = self->priv->metadata;
	json_builder_add_int_value (_tmp56_, (gint64) pdfpc_metadata_pdf_get_end_user_slide (_tmp57_));
	_tmp58_ = builder;
	json_builder_set_member_name (_tmp58_, "note_font_size");
	_tmp59_ = builder;
	_tmp60_ = self->priv->metadata;
	json_builder_add_int_value (_tmp59_, (gint64) pdfpc_metadata_pdf_get_font_size (_tmp60_));
	_tmp61_ = builder;
	json_builder_set_member_name (_tmp61_, "in_zoom");
	_tmp62_ = builder;
	_tmp63_ = controller;
	_tmp64_ = pdfpc_presentation_controller_get_in_zoom (_tmp63_);
	_tmp65_ = _tmp64_;
	json_builder_add_boolean_value (_tmp62_, _tmp65_);
	_tmp66_ = builder;
	json_builder_set_member_name (_tmp66_, "highlighted_area");
	_tmp67_ = builder;
	json_builder_begin_object (_tmp67_);
	_tmp68_ = builder;
	json_builder_set_member_name (_tmp68_, "x");
	_tmp69_ = builder;
	_tmp70_ = controller;
	_tmp71_ = _tmp70_->highlight;
	json_builder_add_double_value (_tmp69_, _tmp71_.x);
	_tmp72_ = builder;
	json_builder_set_member_name (_tmp72_, "y");
	_tmp73_ = builder;
	_tmp74_ = controller;
	_tmp75_ = _tmp74_->highlight;
	json_builder_add_double_value (_tmp73_, _tmp75_.y);
	_tmp76_ = builder;
	json_builder_set_member_name (_tmp76_, "width");
	_tmp77_ = builder;
	_tmp78_ = controller;
	_tmp79_ = _tmp78_->highlight;
	json_builder_add_double_value (_tmp77_, _tmp79_.width);
	_tmp80_ = builder;
	json_builder_set_member_name (_tmp80_, "height");
	_tmp81_ = builder;
	_tmp82_ = controller;
	_tmp83_ = _tmp82_->highlight;
	json_builder_add_double_value (_tmp81_, _tmp83_.height);
	_tmp84_ = builder;
	json_builder_end_object (_tmp84_);
	_tmp85_ = builder;
	json_builder_end_object (_tmp85_);
	_tmp86_ = builder;
	_tmp87_ = json_builder_get_root (_tmp86_);
	result = _tmp87_;
	_g_free0 (progress_status_str);
	_g_free0 (statestr);
	_g_object_unref0 (builder);
	_g_object_unref0 (controller);
	return result;
}

static JsonNode*
pdfpc_rest_server_slide_data (pdfpcRestServer* self,
                              gint slide_number)
{
	JsonBuilder* builder = NULL;
	JsonBuilder* _tmp0_;
	gint user_slide = 0;
	pdfpcMetadataPdf* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	JsonNode* _tmp12_;
	JsonNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = json_builder_new ();
	builder = _tmp0_;
	json_builder_begin_object (builder);
	_tmp1_ = self->priv->metadata;
	user_slide = pdfpc_metadata_pdf_real_slide_to_user_slide (_tmp1_, slide_number);
	json_builder_set_member_name (builder, "user_slide");
	json_builder_add_int_value (builder, (gint64) user_slide);
	json_builder_set_member_name (builder, "image_url");
	_tmp2_ = g_strdup_printf ("%i", slide_number);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strconcat ("/api/slides/", _tmp3_, NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strconcat (_tmp5_, "/image", NULL);
	_tmp7_ = _tmp6_;
	json_builder_add_string_value (builder, _tmp7_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_g_free0 (_tmp3_);
	json_builder_set_member_name (builder, "note_url");
	_tmp8_ = g_strdup_printf ("%i", slide_number);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strconcat ("/api/notes/", _tmp9_, NULL);
	_tmp11_ = _tmp10_;
	json_builder_add_string_value (builder, _tmp11_);
	_g_free0 (_tmp11_);
	_g_free0 (_tmp9_);
	json_builder_end_object (builder);
	_tmp12_ = json_builder_get_root (builder);
	result = _tmp12_;
	_g_object_unref0 (builder);
	return result;
}

static JsonNode*
pdfpc_rest_server_note_data (pdfpcRestServer* self,
                             gint slide_number)
{
	JsonBuilder* builder = NULL;
	JsonBuilder* _tmp0_;
	JsonBuilder* _tmp1_;
	gchar* basestr = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	pdfpcMetadataPdf* _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	JsonBuilder* _tmp24_;
	JsonBuilder* _tmp25_;
	JsonNode* _tmp26_;
	JsonNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = json_builder_new ();
	builder = _tmp0_;
	_tmp1_ = builder;
	json_builder_begin_object (_tmp1_);
	_tmp2_ = g_strdup_printf ("%i", slide_number);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strconcat ("/api/notes/", _tmp3_, NULL);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	basestr = _tmp5_;
	_tmp6_ = self->priv->metadata;
	_tmp7_ = pdfpc_metadata_pdf_get_has_beamer_notes (_tmp6_);
	_tmp8_ = _tmp7_;
	if (_tmp8_) {
		JsonBuilder* _tmp9_;
		JsonBuilder* _tmp10_;
		const gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		_tmp9_ = builder;
		json_builder_set_member_name (_tmp9_, "image_url");
		_tmp10_ = builder;
		_tmp11_ = basestr;
		_tmp12_ = g_strconcat (_tmp11_, "/image", NULL);
		_tmp13_ = _tmp12_;
		json_builder_add_string_value (_tmp10_, _tmp13_);
		_g_free0 (_tmp13_);
	} else {
		JsonBuilder* _tmp14_;
		JsonBuilder* _tmp15_;
		const gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		JsonBuilder* _tmp19_;
		JsonBuilder* _tmp20_;
		const gchar* _tmp21_;
		gchar* _tmp22_;
		gchar* _tmp23_;
		_tmp14_ = builder;
		json_builder_set_member_name (_tmp14_, "raw_url");
		_tmp15_ = builder;
		_tmp16_ = basestr;
		_tmp17_ = g_strconcat (_tmp16_, "/raw", NULL);
		_tmp18_ = _tmp17_;
		json_builder_add_string_value (_tmp15_, _tmp18_);
		_g_free0 (_tmp18_);
		_tmp19_ = builder;
		json_builder_set_member_name (_tmp19_, "html_url");
		_tmp20_ = builder;
		_tmp21_ = basestr;
		_tmp22_ = g_strconcat (_tmp21_, "/html", NULL);
		_tmp23_ = _tmp22_;
		json_builder_add_string_value (_tmp20_, _tmp23_);
		_g_free0 (_tmp23_);
	}
	_tmp24_ = builder;
	json_builder_end_object (_tmp24_);
	_tmp25_ = builder;
	_tmp26_ = json_builder_get_root (_tmp25_);
	result = _tmp26_;
	_g_free0 (basestr);
	_g_object_unref0 (builder);
	return result;
}

static guint8*
pdfpc_rest_server_get_slide_png (pdfpcRestServer* self,
                                 gint slide_number,
                                 gint width,
                                 gint height,
                                 gboolean notes_area,
                                 gint* result_length1)
{
	GError* _inner_error0_ = NULL;
	guint8* result;
	g_return_val_if_fail (self != NULL, NULL);
	{
		cairo_surface_t* surface = NULL;
		pdfpcMetadataPdf* _tmp0_;
		pdfpcRendererPdf* _tmp1_;
		pdfpcRendererPdf* _tmp2_;
		cairo_surface_t* _tmp3_;
		GdkPixbuf* pixbuf = NULL;
		cairo_surface_t* _tmp4_;
		cairo_surface_t* _tmp5_;
		cairo_surface_t* _tmp6_;
		GdkPixbuf* _tmp7_;
		guint8* png_data = NULL;
		gint png_data_length1 = 0;
		gint _png_data_size_ = 0;
		GdkPixbuf* _tmp8_;
		guint8* _tmp9_ = NULL;
		gsize _tmp10_ = 0;
		guint8* _tmp11_;
		gint _tmp11__length1;
		_tmp0_ = self->priv->metadata;
		_tmp1_ = pdfpc_metadata_pdf_get_renderer (_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = pdfpc_renderer_pdf_render (_tmp2_, slide_number, notes_area, width, height, FALSE, FALSE, NULL, &_inner_error0_);
		surface = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp4_ = surface;
		_tmp5_ = surface;
		_tmp6_ = surface;
		_tmp7_ = gdk_pixbuf_get_from_surface (_tmp4_, 0, 0, cairo_image_surface_get_width (_tmp5_), cairo_image_surface_get_height (_tmp6_));
		pixbuf = _tmp7_;
		_tmp8_ = pixbuf;
		gdk_pixbuf_save_to_buffer (_tmp8_, &_tmp9_, &_tmp10_, "png", &_inner_error0_, "compression", "1", NULL, NULL);
		png_data = (g_free (png_data), NULL);
		png_data = _tmp9_;
		png_data_length1 = _tmp10_;
		_png_data_size_ = png_data_length1;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			png_data = (g_free (png_data), NULL);
			_g_object_unref0 (pixbuf);
			_cairo_surface_destroy0 (surface);
			goto __catch0_g_error;
		}
		_tmp11_ = png_data;
		_tmp11__length1 = png_data_length1;
		if (result_length1) {
			*result_length1 = _tmp11__length1;
		}
		result = _tmp11_;
		_g_object_unref0 (pixbuf);
		_cairo_surface_destroy0 (surface);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		guint8* _tmp12_;
		gint _tmp12__length1;
		g_clear_error (&_inner_error0_);
		_tmp12_ = NULL;
		_tmp12__length1 = 0;
		if (result_length1) {
			*result_length1 = _tmp12__length1;
		}
		result = _tmp12_;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static void
pdfpc_rest_server_static_handler (pdfpcRestServer* self,
                                  SoupServer* server,
                                  SoupServerMessage* msg,
                                  const gchar* path,
                                  GHashTable* query)
{
	gchar* fname = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	guint8* raw_datau8 = NULL;
	gint raw_datau8_length1 = 0;
	gint _raw_datau8_size_ = 0;
	GFile* file = NULL;
	const gchar* _tmp5_;
	GFile* _tmp6_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (server != NULL);
	g_return_if_fail (msg != NULL);
	g_return_if_fail (path != NULL);
	_tmp0_ = self->priv->static_root;
	_tmp1_ = g_strconcat (_tmp0_, path, NULL);
	fname = _tmp1_;
	_tmp2_ = fname;
	if (g_str_has_suffix (_tmp2_, "/")) {
		const gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp3_ = fname;
		_tmp4_ = g_strconcat (_tmp3_, "index.html", NULL);
		_g_free0 (fname);
		fname = _tmp4_;
	}
	_tmp5_ = fname;
	_tmp6_ = g_file_new_for_path (_tmp5_);
	file = _tmp6_;
	{
		guint8* _tmp7_ = NULL;
		gsize _tmp8_ = 0;
		gboolean result_uncertain = FALSE;
		gchar* mime = NULL;
		const gchar* _tmp9_;
		gboolean _tmp10_ = FALSE;
		gchar* _tmp11_;
		const gchar* _tmp12_;
		g_file_load_contents (file, NULL, &_tmp7_, &_tmp8_, NULL, &_inner_error0_);
		raw_datau8 = (g_free (raw_datau8), NULL);
		raw_datau8 = _tmp7_;
		raw_datau8_length1 = _tmp8_;
		_raw_datau8_size_ = raw_datau8_length1;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp9_ = fname;
		_tmp11_ = g_content_type_guess (_tmp9_, raw_datau8, (gsize) raw_datau8_length1, &_tmp10_);
		result_uncertain = _tmp10_;
		mime = _tmp11_;
		_tmp12_ = mime;
		soup_server_message_set_response (msg, _tmp12_, SOUP_MEMORY_COPY, raw_datau8, (gsize) raw_datau8_length1);
		soup_server_message_set_status (msg, (guint) 200, NULL);
		_g_free0 (mime);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp13_;
		GError* _tmp14_;
		const gchar* _tmp15_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp13_ = fname;
		_tmp14_ = e;
		_tmp15_ = _tmp14_->message;
		g_printerr ("Failed opening file %s: %s\n", _tmp13_, _tmp15_);
		soup_server_message_set_status (msg, (guint) 404, NULL);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (file);
		raw_datau8 = (g_free (raw_datau8), NULL);
		_g_free0 (fname);
		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;
	}
	_g_object_unref0 (file);
	raw_datau8 = (g_free (raw_datau8), NULL);
	_g_free0 (fname);
}

static gpointer
_soup_message_headers_ref0 (gpointer self)
{
	return self ? soup_message_headers_ref (self) : NULL;
}

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

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

static gpointer
_soup_message_body_ref0 (gpointer self)
{
	return self ? soup_message_body_ref (self) : NULL;
}

static JsonNode*
_vala_JsonNode_copy (JsonNode* self)
{
	return g_boxed_copy (json_node_get_type (), self);
}

static gpointer
__vala_JsonNode_copy0 (gpointer self)
{
	return self ? _vala_JsonNode_copy (self) : NULL;
}

static GVariant*
_variant_new2 (const gchar* value)
{
	return g_variant_ref_sink (g_variant_new_string (value));
}

static void
pdfpc_rest_server_api_handler (pdfpcRestServer* self,
                               SoupServer* server,
                               SoupServerMessage* msg,
                               const gchar* path,
                               GHashTable* query)
{
	gboolean _tmp0_ = FALSE;
	SoupMessageHeaders* headers = NULL;
	SoupMessageHeaders* _tmp4_;
	SoupMessageHeaders* _tmp5_;
	SoupMessageHeaders* _tmp6_;
	SoupMessageHeaders* _tmp7_;
	SoupMessageHeaders* _tmp8_;
	const gchar* _tmp9_;
	JsonNode* root = NULL;
	JsonNode* _tmp142_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (server != NULL);
	g_return_if_fail (msg != NULL);
	g_return_if_fail (path != NULL);
	if (self->priv->locked) {
		const gchar* _tmp1_;
		const gchar* _tmp2_;
		_tmp1_ = self->priv->client_host;
		_tmp2_ = soup_server_message_get_remote_host (msg);
		_tmp0_ = g_strcmp0 (_tmp1_, _tmp2_) != 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		const gchar* _tmp3_;
		soup_server_message_set_status (msg, (guint) 403, NULL);
		_tmp3_ = soup_server_message_get_remote_host (msg);
		g_printerr ("Refused to serve client %s\n", _tmp3_);
		return;
	}
	_tmp4_ = soup_server_message_get_response_headers (msg);
	_tmp5_ = _soup_message_headers_ref0 (_tmp4_);
	headers = _tmp5_;
	_tmp6_ = headers;
	soup_message_headers_append (_tmp6_, "Access-Control-Allow-Origin", "*");
	_tmp7_ = headers;
	soup_message_headers_append (_tmp7_, "Access-Control-Allow-Methods", "GET,PUT");
	_tmp8_ = headers;
	soup_message_headers_append (_tmp8_, "Access-Control-Allow-Headers", "authorization,content-type");
	_tmp9_ = soup_server_message_get_method (msg);
	if (g_strcmp0 (_tmp9_, "OPTIONS") == 0) {
		soup_server_message_set_status (msg, (guint) 204, NULL);
		_soup_message_headers_unref0 (headers);
		return;
	}
	if (g_strcmp0 (path, "/api/helo") == 0) {
		if (!self->priv->locked) {
			const gchar* _tmp10_;
			gchar* _tmp11_;
			pdfpcMetadataPdf* _tmp12_;
			pdfpcPresentationController* _tmp13_;
			self->priv->locked = TRUE;
			_tmp10_ = soup_server_message_get_remote_host (msg);
			_tmp11_ = g_strdup (_tmp10_);
			_g_free0 (self->priv->client_host);
			self->priv->client_host = _tmp11_;
			_tmp12_ = self->priv->metadata;
			_tmp13_ = _tmp12_->controller;
			pdfpc_presentation_controller_hide_qrcode (_tmp13_);
		}
	} else {
		if (!self->priv->locked) {
			soup_server_message_set_status (msg, (guint) 412, NULL);
			_soup_message_headers_unref0 (headers);
			return;
		}
	}
	soup_server_message_set_status (msg, (guint) 200, NULL);
	if (g_strcmp0 (path, "/api/helo") == 0) {
		JsonNode* _tmp14_;
		_tmp14_ = pdfpc_rest_server_helo_data (self);
		__vala_JsonNode_free0 (root);
		root = _tmp14_;
	} else {
		if (g_strcmp0 (path, "/api/state") == 0) {
			JsonNode* _tmp15_;
			_tmp15_ = pdfpc_rest_server_state_data (self);
			__vala_JsonNode_free0 (root);
			root = _tmp15_;
		} else {
			if (g_strcmp0 (path, "/api/meta") == 0) {
				JsonNode* _tmp16_;
				_tmp16_ = pdfpc_rest_server_meta_data (self);
				__vala_JsonNode_free0 (root);
				root = _tmp16_;
			} else {
				if (g_str_has_prefix (path, "/api/slides/")) {
					{
						GRegex* regex = NULL;
						GRegex* _tmp17_;
						gchar** parts = NULL;
						GRegex* _tmp18_;
						gchar** _tmp19_;
						gchar** _tmp20_;
						gint parts_length1;
						gint _parts_size_;
						gint nparts = 0;
						gchar** _tmp21_;
						gint _tmp21__length1;
						gint slide_number = 0;
						_tmp17_ = g_regex_new ("/api/slides/(\\d+)(/image)?", 0, 0, &_inner_error0_);
						regex = _tmp17_;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							goto __catch0_g_error;
						}
						_tmp18_ = regex;
						_tmp20_ = _tmp19_ = g_regex_split (_tmp18_, path, 0);
						parts = _tmp20_;
						parts_length1 = _vala_array_length (_tmp19_);
						_parts_size_ = parts_length1;
						_tmp21_ = parts;
						_tmp21__length1 = parts_length1;
						nparts = _tmp21__length1;
						slide_number = 0;
						if (nparts < 2) {
							JsonNode* _tmp22_;
							_tmp22_ = pdfpc_rest_server_error_data (self, "Bad request");
							__vala_JsonNode_free0 (root);
							root = _tmp22_;
							soup_server_message_set_status (msg, (guint) 400, NULL);
						} else {
							gchar** _tmp23_;
							gint _tmp23__length1;
							const gchar* _tmp24_;
							gboolean _tmp25_ = FALSE;
							_tmp23_ = parts;
							_tmp23__length1 = parts_length1;
							_tmp24_ = _tmp23_[1];
							slide_number = atoi (_tmp24_);
							if (nparts == 4) {
								_tmp25_ = query != NULL;
							} else {
								_tmp25_ = FALSE;
							}
							if (_tmp25_) {
								gchar* wstr = NULL;
								gconstpointer _tmp26_;
								gchar* _tmp27_;
								gchar* hstr = NULL;
								gconstpointer _tmp28_;
								gchar* _tmp29_;
								gboolean _tmp30_ = FALSE;
								const gchar* _tmp31_;
								JsonNode* _tmp40_;
								_tmp26_ = g_hash_table_lookup (query, "w");
								_tmp27_ = g_strdup ((const gchar*) _tmp26_);
								wstr = _tmp27_;
								_tmp28_ = g_hash_table_lookup (query, "h");
								_tmp29_ = g_strdup ((const gchar*) _tmp28_);
								hstr = _tmp29_;
								_tmp31_ = wstr;
								if (_tmp31_ != NULL) {
									const gchar* _tmp32_;
									_tmp32_ = hstr;
									_tmp30_ = _tmp32_ != NULL;
								} else {
									_tmp30_ = FALSE;
								}
								if (_tmp30_) {
									gint width = 0;
									const gchar* _tmp33_;
									gint height = 0;
									const gchar* _tmp34_;
									gboolean _tmp35_ = FALSE;
									_tmp33_ = wstr;
									width = atoi (_tmp33_);
									_tmp34_ = hstr;
									height = atoi (_tmp34_);
									if (width > 0) {
										_tmp35_ = height > 0;
									} else {
										_tmp35_ = FALSE;
									}
									if (_tmp35_) {
										guint8* png_data = NULL;
										gint _tmp36_ = 0;
										guint8* _tmp37_;
										gint png_data_length1;
										gint _png_data_size_;
										guint8* _tmp38_;
										gint _tmp38__length1;
										_tmp37_ = pdfpc_rest_server_get_slide_png (self, slide_number, width, height, FALSE, &_tmp36_);
										png_data = _tmp37_;
										png_data_length1 = _tmp36_;
										_png_data_size_ = png_data_length1;
										_tmp38_ = png_data;
										_tmp38__length1 = png_data_length1;
										if (_tmp38_ != NULL) {
											guint8* _tmp39_;
											gint _tmp39__length1;
											_tmp39_ = png_data;
											_tmp39__length1 = png_data_length1;
											soup_server_message_set_response (msg, "image/png", SOUP_MEMORY_COPY, _tmp39_, (gsize) _tmp39__length1);
											png_data = (g_free (png_data), NULL);
											_g_free0 (hstr);
											_g_free0 (wstr);
											parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
											_g_regex_unref0 (regex);
											__vala_JsonNode_free0 (root);
											_soup_message_headers_unref0 (headers);
											return;
										}
										png_data = (g_free (png_data), NULL);
									}
								}
								_tmp40_ = pdfpc_rest_server_error_data (self, "Rendering failed");
								__vala_JsonNode_free0 (root);
								root = _tmp40_;
								soup_server_message_set_status (msg, (guint) 500, NULL);
								_g_free0 (hstr);
								_g_free0 (wstr);
							} else {
								JsonNode* _tmp41_;
								_tmp41_ = pdfpc_rest_server_slide_data (self, slide_number);
								__vala_JsonNode_free0 (root);
								root = _tmp41_;
							}
						}
						parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
						_g_regex_unref0 (regex);
					}
					goto __finally0;
					__catch0_g_error:
					{
						GError* e = NULL;
						GError* _tmp42_;
						const gchar* _tmp43_;
						JsonNode* _tmp44_;
						e = _inner_error0_;
						_inner_error0_ = NULL;
						_tmp42_ = e;
						_tmp43_ = _tmp42_->message;
						_tmp44_ = pdfpc_rest_server_error_data (self, _tmp43_);
						__vala_JsonNode_free0 (root);
						root = _tmp44_;
						soup_server_message_set_status (msg, (guint) 500, NULL);
						_g_error_free0 (e);
					}
					__finally0:
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						__vala_JsonNode_free0 (root);
						_soup_message_headers_unref0 (headers);
						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;
					}
				} else {
					if (g_str_has_prefix (path, "/api/notes/")) {
						{
							GRegex* regex = NULL;
							GRegex* _tmp45_;
							gchar** parts = NULL;
							GRegex* _tmp46_;
							gchar** _tmp47_;
							gchar** _tmp48_;
							gint parts_length1;
							gint _parts_size_;
							gint nparts = 0;
							gchar** _tmp49_;
							gint _tmp49__length1;
							gint slide_number = 0;
							_tmp45_ = g_regex_new ("/api/notes/(\\d+)(/.+)?", 0, 0, &_inner_error0_);
							regex = _tmp45_;
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								goto __catch1_g_error;
							}
							_tmp46_ = regex;
							_tmp48_ = _tmp47_ = g_regex_split (_tmp46_, path, 0);
							parts = _tmp48_;
							parts_length1 = _vala_array_length (_tmp47_);
							_parts_size_ = parts_length1;
							_tmp49_ = parts;
							_tmp49__length1 = parts_length1;
							nparts = _tmp49__length1;
							slide_number = 0;
							if (nparts < 2) {
								JsonNode* _tmp50_;
								_tmp50_ = pdfpc_rest_server_error_data (self, "Bad request");
								__vala_JsonNode_free0 (root);
								root = _tmp50_;
								soup_server_message_set_status (msg, (guint) 400, NULL);
							} else {
								gchar** _tmp51_;
								gint _tmp51__length1;
								const gchar* _tmp52_;
								_tmp51_ = parts;
								_tmp51__length1 = parts_length1;
								_tmp52_ = _tmp51_[1];
								slide_number = atoi (_tmp52_);
								if (nparts == 4) {
									gchar* type = NULL;
									gchar** _tmp53_;
									gint _tmp53__length1;
									const gchar* _tmp54_;
									gchar* _tmp55_;
									const gchar* _tmp56_;
									const gchar* _tmp57_;
									GQuark _tmp59_ = 0U;
									static GQuark _tmp58_label0 = 0;
									static GQuark _tmp58_label1 = 0;
									_tmp53_ = parts;
									_tmp53__length1 = parts_length1;
									_tmp54_ = _tmp53_[2];
									_tmp55_ = g_strdup (_tmp54_);
									type = _tmp55_;
									_tmp56_ = type;
									_tmp57_ = _tmp56_;
									_tmp59_ = (NULL == _tmp57_) ? 0 : g_quark_from_string (_tmp57_);
									if (_tmp59_ == ((0 != _tmp58_label0) ? _tmp58_label0 : (_tmp58_label0 = g_quark_from_static_string ("/html")))) {
										switch (0) {
											default:
											{
												gchar* note = NULL;
												pdfpcMetadataPdf* _tmp60_;
												gchar* _tmp61_;
												gchar* doc = NULL;
												const gchar* _tmp62_;
												pdfpcMetadataPdf* _tmp63_;
												gchar* _tmp64_;
												const gchar* _tmp65_;
												guint8* _tmp66_;
												gint _tmp66__length1;
												gint _tmp67_ = 0;
												guint8* _tmp68_;
												gint _tmp68__length1;
												_tmp60_ = self->priv->metadata;
												_tmp61_ = pdfpc_metadata_pdf_get_note (_tmp60_, slide_number);
												note = _tmp61_;
												_tmp62_ = note;
												_tmp63_ = self->priv->metadata;
												_tmp64_ = pdfpc_renderer_md_render (_tmp62_, pdfpc_metadata_pdf_get_disable_markdown (_tmp63_));
												doc = _tmp64_;
												_tmp65_ = doc;
												_tmp66_ = string_get_data (_tmp65_, &_tmp67_);
												_tmp66__length1 = _tmp67_;
												_tmp68_ = _tmp66_;
												_tmp68__length1 = _tmp66__length1;
												soup_server_message_set_response (msg, "text/html", SOUP_MEMORY_COPY, _tmp68_, (gsize) _tmp68__length1);
												_g_free0 (doc);
												_g_free0 (note);
												_g_free0 (type);
												parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
												_g_regex_unref0 (regex);
												__vala_JsonNode_free0 (root);
												_soup_message_headers_unref0 (headers);
												return;
											}
										}
									} else if (_tmp59_ == ((0 != _tmp58_label1) ? _tmp58_label1 : (_tmp58_label1 = g_quark_from_static_string ("/image")))) {
										switch (0) {
											default:
											{
												gchar* wstr = NULL;
												gchar* hstr = NULL;
												gboolean _tmp73_ = FALSE;
												const gchar* _tmp74_;
												JsonNode* _tmp83_;
												wstr = NULL;
												hstr = NULL;
												if (query != NULL) {
													gconstpointer _tmp69_;
													gchar* _tmp70_;
													gconstpointer _tmp71_;
													gchar* _tmp72_;
													_tmp69_ = g_hash_table_lookup (query, "w");
													_tmp70_ = g_strdup ((const gchar*) _tmp69_);
													_g_free0 (wstr);
													wstr = _tmp70_;
													_tmp71_ = g_hash_table_lookup (query, "h");
													_tmp72_ = g_strdup ((const gchar*) _tmp71_);
													_g_free0 (hstr);
													hstr = _tmp72_;
												}
												_tmp74_ = wstr;
												if (_tmp74_ != NULL) {
													const gchar* _tmp75_;
													_tmp75_ = hstr;
													_tmp73_ = _tmp75_ != NULL;
												} else {
													_tmp73_ = FALSE;
												}
												if (_tmp73_) {
													gint width = 0;
													const gchar* _tmp76_;
													gint height = 0;
													const gchar* _tmp77_;
													gboolean _tmp78_ = FALSE;
													_tmp76_ = wstr;
													width = atoi (_tmp76_);
													_tmp77_ = hstr;
													height = atoi (_tmp77_);
													if (width > 0) {
														_tmp78_ = height > 0;
													} else {
														_tmp78_ = FALSE;
													}
													if (_tmp78_) {
														guint8* png_data = NULL;
														gint _tmp79_ = 0;
														guint8* _tmp80_;
														gint png_data_length1;
														gint _png_data_size_;
														guint8* _tmp81_;
														gint _tmp81__length1;
														_tmp80_ = pdfpc_rest_server_get_slide_png (self, slide_number, width, height, TRUE, &_tmp79_);
														png_data = _tmp80_;
														png_data_length1 = _tmp79_;
														_png_data_size_ = png_data_length1;
														_tmp81_ = png_data;
														_tmp81__length1 = png_data_length1;
														if (_tmp81_ != NULL) {
															guint8* _tmp82_;
															gint _tmp82__length1;
															_tmp82_ = png_data;
															_tmp82__length1 = png_data_length1;
															soup_server_message_set_response (msg, "image/png", SOUP_MEMORY_COPY, _tmp82_, (gsize) _tmp82__length1);
															png_data = (g_free (png_data), NULL);
															_g_free0 (hstr);
															_g_free0 (wstr);
															_g_free0 (type);
															parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
															_g_regex_unref0 (regex);
															__vala_JsonNode_free0 (root);
															_soup_message_headers_unref0 (headers);
															return;
														}
														png_data = (g_free (png_data), NULL);
													}
												}
												_tmp83_ = pdfpc_rest_server_error_data (self, "Rendering failed");
												__vala_JsonNode_free0 (root);
												root = _tmp83_;
												soup_server_message_set_status (msg, (guint) 500, NULL);
												_g_free0 (hstr);
												_g_free0 (wstr);
												break;
											}
										}
									} else {
										switch (0) {
											default:
											{
												JsonNode* _tmp84_;
												_tmp84_ = pdfpc_rest_server_error_data (self, "Bad request");
												__vala_JsonNode_free0 (root);
												root = _tmp84_;
												soup_server_message_set_status (msg, (guint) 400, NULL);
												break;
											}
										}
									}
									_g_free0 (type);
								} else {
									JsonNode* _tmp85_;
									_tmp85_ = pdfpc_rest_server_note_data (self, slide_number);
									__vala_JsonNode_free0 (root);
									root = _tmp85_;
								}
							}
							parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
							_g_regex_unref0 (regex);
						}
						goto __finally1;
						__catch1_g_error:
						{
							GError* e = NULL;
							GError* _tmp86_;
							const gchar* _tmp87_;
							JsonNode* _tmp88_;
							e = _inner_error0_;
							_inner_error0_ = NULL;
							_tmp86_ = e;
							_tmp87_ = _tmp86_->message;
							_tmp88_ = pdfpc_rest_server_error_data (self, _tmp87_);
							__vala_JsonNode_free0 (root);
							root = _tmp88_;
							soup_server_message_set_status (msg, (guint) 500, NULL);
							_g_error_free0 (e);
						}
						__finally1:
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							__vala_JsonNode_free0 (root);
							_soup_message_headers_unref0 (headers);
							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;
						}
					} else {
						gboolean _tmp89_ = FALSE;
						if (g_strcmp0 (path, "/api/control") == 0) {
							const gchar* _tmp90_;
							_tmp90_ = soup_server_message_get_method (msg);
							_tmp89_ = g_strcmp0 (_tmp90_, "PUT") == 0;
						} else {
							_tmp89_ = FALSE;
						}
						if (_tmp89_) {
							SoupMessageBody* body = NULL;
							SoupMessageBody* _tmp91_;
							SoupMessageBody* _tmp92_;
							JsonParser* parser = NULL;
							JsonParser* _tmp93_;
							_tmp91_ = soup_server_message_get_request_body (msg);
							_tmp92_ = _soup_message_body_ref0 (_tmp91_);
							body = _tmp92_;
							_tmp93_ = json_parser_new ();
							parser = _tmp93_;
							{
								JsonParser* _tmp94_;
								SoupMessageBody* _tmp95_;
								guint8* _tmp96_;
								gint _tmp96__length1;
								SoupMessageBody* _tmp97_;
								JsonNode* node = NULL;
								JsonParser* _tmp98_;
								JsonNode* _tmp99_;
								JsonNode* _tmp100_;
								gboolean _tmp101_ = FALSE;
								JsonNode* _tmp102_;
								_tmp94_ = parser;
								_tmp95_ = body;
								_tmp96_ = _tmp95_->data;
								_tmp96__length1 = _tmp95_->length;
								_tmp97_ = body;
								json_parser_load_from_data (_tmp94_, (const gchar*) _tmp96_, (gssize) _tmp97_->length, &_inner_error0_);
								if (G_UNLIKELY (_inner_error0_ != NULL)) {
									goto __catch2_g_error;
								}
								_tmp98_ = parser;
								_tmp99_ = json_parser_get_root (_tmp98_);
								_tmp100_ = __vala_JsonNode_copy0 (_tmp99_);
								node = _tmp100_;
								_tmp102_ = node;
								if (_tmp102_ != NULL) {
									JsonNode* _tmp103_;
									_tmp103_ = node;
									_tmp101_ = json_node_get_node_type (_tmp103_) == JSON_NODE_OBJECT;
								} else {
									_tmp101_ = FALSE;
								}
								if (_tmp101_) {
									JsonObject* obj = NULL;
									JsonNode* _tmp104_;
									JsonObject* _tmp105_;
									gchar* action = NULL;
									gchar* argument = NULL;
									JsonObject* _tmp106_;
									GList* _tmp107_;
									const gchar* _tmp121_;
									_tmp104_ = node;
									_tmp105_ = json_node_get_object (_tmp104_);
									obj = _tmp105_;
									action = NULL;
									argument = NULL;
									_tmp106_ = obj;
									_tmp107_ = json_object_get_members (_tmp106_);
									{
										GList* name_collection = NULL;
										GList* name_it = NULL;
										name_collection = _tmp107_;
										for (name_it = name_collection; name_it != NULL; name_it = name_it->next) {
											const gchar* name = NULL;
											name = (const gchar*) name_it->data;
											{
												JsonNode* item = NULL;
												JsonObject* _tmp108_;
												const gchar* _tmp109_;
												JsonNode* _tmp110_;
												const gchar* _tmp111_;
												const gchar* _tmp112_;
												GQuark _tmp114_ = 0U;
												static GQuark _tmp113_label0 = 0;
												static GQuark _tmp113_label1 = 0;
												_tmp108_ = obj;
												_tmp109_ = name;
												_tmp110_ = json_object_get_member (_tmp108_, _tmp109_);
												item = _tmp110_;
												_tmp111_ = name;
												_tmp112_ = _tmp111_;
												_tmp114_ = (NULL == _tmp112_) ? 0 : g_quark_from_string (_tmp112_);
												if (_tmp114_ == ((0 != _tmp113_label0) ? _tmp113_label0 : (_tmp113_label0 = g_quark_from_static_string ("action")))) {
													switch (0) {
														default:
														{
															JsonNode* _tmp115_;
															const gchar* _tmp116_;
															gchar* _tmp117_;
															_tmp115_ = item;
															_tmp116_ = json_node_get_string (_tmp115_);
															_tmp117_ = g_strdup (_tmp116_);
															_g_free0 (action);
															action = _tmp117_;
															break;
														}
													}
												} else if (_tmp114_ == ((0 != _tmp113_label1) ? _tmp113_label1 : (_tmp113_label1 = g_quark_from_static_string ("argument")))) {
													switch (0) {
														default:
														{
															JsonNode* _tmp118_;
															const gchar* _tmp119_;
															gchar* _tmp120_;
															_tmp118_ = item;
															_tmp119_ = json_node_get_string (_tmp118_);
															_tmp120_ = g_strdup (_tmp119_);
															_g_free0 (argument);
															argument = _tmp120_;
															break;
														}
													}
												}
											}
										}
										(name_collection == NULL) ? NULL : (name_collection = (g_list_free (name_collection), NULL));
									}
									_tmp121_ = action;
									if (_tmp121_ != NULL) {
										gboolean _tmp122_ = FALSE;
										const gchar* _tmp123_;
										const gchar* _tmp133_;
										_tmp123_ = argument;
										if (g_strcmp0 (_tmp123_, "") == 0) {
											_tmp122_ = TRUE;
										} else {
											const gchar* _tmp124_;
											_tmp124_ = argument;
											_tmp122_ = _tmp124_ == NULL;
										}
										if (_tmp122_) {
											pdfpcMetadataPdf* _tmp125_;
											pdfpcPresentationController* _tmp126_;
											const gchar* _tmp127_;
											_tmp125_ = self->priv->metadata;
											_tmp126_ = _tmp125_->controller;
											_tmp127_ = action;
											pdfpc_presentation_controller_trigger_action (_tmp126_, _tmp127_, NULL);
										} else {
											pdfpcMetadataPdf* _tmp128_;
											pdfpcPresentationController* _tmp129_;
											const gchar* _tmp130_;
											const gchar* _tmp131_;
											GVariant* _tmp132_;
											_tmp128_ = self->priv->metadata;
											_tmp129_ = _tmp128_->controller;
											_tmp130_ = action;
											_tmp131_ = argument;
											_tmp132_ = _variant_new2 (_tmp131_);
											pdfpc_presentation_controller_trigger_action (_tmp129_, _tmp130_, _tmp132_);
											_g_variant_unref0 (_tmp132_);
										}
										_tmp133_ = action;
										if (g_strcmp0 (_tmp133_, "movePointer") == 0) {
											JsonNode* _tmp134_;
											_tmp134_ = pdfpc_rest_server_pointer_data (self);
											__vala_JsonNode_free0 (root);
											root = _tmp134_;
										} else {
											JsonNode* _tmp135_;
											_tmp135_ = pdfpc_rest_server_state_data (self);
											__vala_JsonNode_free0 (root);
											root = _tmp135_;
										}
									} else {
										JsonNode* _tmp136_;
										_tmp136_ = pdfpc_rest_server_error_data (self, "Action not defined");
										__vala_JsonNode_free0 (root);
										root = _tmp136_;
										soup_server_message_set_status (msg, (guint) 400, NULL);
									}
									_g_free0 (argument);
									_g_free0 (action);
								} else {
									JsonNode* _tmp137_;
									_tmp137_ = pdfpc_rest_server_error_data (self, "Invalid request");
									__vala_JsonNode_free0 (root);
									root = _tmp137_;
									soup_server_message_set_status (msg, (guint) 400, NULL);
								}
								__vala_JsonNode_free0 (node);
							}
							goto __finally2;
							__catch2_g_error:
							{
								GError* e = NULL;
								GError* _tmp138_;
								const gchar* _tmp139_;
								JsonNode* _tmp140_;
								e = _inner_error0_;
								_inner_error0_ = NULL;
								_tmp138_ = e;
								_tmp139_ = _tmp138_->message;
								_tmp140_ = pdfpc_rest_server_error_data (self, _tmp139_);
								__vala_JsonNode_free0 (root);
								root = _tmp140_;
								soup_server_message_set_status (msg, (guint) 400, NULL);
								_g_error_free0 (e);
							}
							__finally2:
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								_g_object_unref0 (parser);
								_soup_message_body_unref0 (body);
								__vala_JsonNode_free0 (root);
								_soup_message_headers_unref0 (headers);
								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;
							}
							_g_object_unref0 (parser);
							_soup_message_body_unref0 (body);
						} else {
							JsonNode* _tmp141_;
							_tmp141_ = pdfpc_rest_server_error_data (self, "Not found");
							__vala_JsonNode_free0 (root);
							root = _tmp141_;
							soup_server_message_set_status (msg, (guint) 404, NULL);
						}
					}
				}
			}
		}
	}
	_tmp142_ = root;
	if (_tmp142_ != NULL) {
		JsonGenerator* generator = NULL;
		JsonGenerator* _tmp143_;
		JsonGenerator* _tmp144_;
		JsonNode* _tmp145_;
		gchar* response = NULL;
		JsonGenerator* _tmp146_;
		gchar* _tmp147_;
		const gchar* _tmp148_;
		guint8* _tmp149_;
		gint _tmp149__length1;
		gint _tmp150_ = 0;
		guint8* _tmp151_;
		gint _tmp151__length1;
		_tmp143_ = json_generator_new ();
		generator = _tmp143_;
		_tmp144_ = generator;
		_tmp145_ = root;
		json_generator_set_root (_tmp144_, _tmp145_);
		_tmp146_ = generator;
		_tmp147_ = json_generator_to_data (_tmp146_, NULL);
		response = _tmp147_;
		_tmp148_ = response;
		_tmp149_ = string_get_data (_tmp148_, &_tmp150_);
		_tmp149__length1 = _tmp150_;
		_tmp151_ = _tmp149_;
		_tmp151__length1 = _tmp149__length1;
		soup_server_message_set_response (msg, "application/json", SOUP_MEMORY_COPY, _tmp151_, (gsize) _tmp151__length1);
		_g_free0 (response);
		_g_object_unref0 (generator);
	}
	__vala_JsonNode_free0 (root);
	_soup_message_headers_unref0 (headers);
}

static void
_pdfpc_rest_server_api_handler_soup_server_callback (SoupServer* server,
                                                     SoupServerMessage* msg,
                                                     const gchar* path,
                                                     GHashTable* query,
                                                     gpointer self)
{
	pdfpc_rest_server_api_handler ((pdfpcRestServer*) self, server, msg, path, query);
}

static void
_pdfpc_rest_server_static_handler_soup_server_callback (SoupServer* server,
                                                        SoupServerMessage* msg,
                                                        const gchar* path,
                                                        GHashTable* query,
                                                        gpointer self)
{
	pdfpc_rest_server_static_handler ((pdfpcRestServer*) self, server, msg, path, query);
}

static gboolean
__lambda9_ (pdfpcRestServer* self,
            SoupAuthDomainBasic* domain,
            SoupServerMessage* msg,
            const gchar* username,
            const gchar* password)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (domain != NULL, FALSE);
	g_return_val_if_fail (msg != NULL, FALSE);
	g_return_val_if_fail (username != NULL, FALSE);
	g_return_val_if_fail (password != NULL, FALSE);
	if (g_strcmp0 (username, "pdfpc") == 0) {
		const gchar* _tmp1_;
		_tmp1_ = pdfpc_options_rest_passwd;
		_tmp0_ = g_strcmp0 (password, _tmp1_) == 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		result = TRUE;
		return result;
	} else {
		g_printerr ("Authorization failed: user=%s, pass=%s\n", username, password);
		result = FALSE;
		return result;
	}
}

static gboolean
___lambda9__soup_auth_domain_basic_auth_callback (SoupAuthDomainBasic* domain,
                                                  SoupServerMessage* msg,
                                                  const gchar* username,
                                                  const gchar* password,
                                                  gpointer self)
{
	gboolean result;
	result = __lambda9_ ((pdfpcRestServer*) self, domain, msg, username, password);
	return result;
}

static gboolean
__lambda10_ (pdfpcRestServer* self,
             SoupAuthDomain* domain,
             SoupServerMessage* msg)
{
	const gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (domain != NULL, FALSE);
	g_return_val_if_fail (msg != NULL, FALSE);
	_tmp0_ = soup_server_message_get_method (msg);
	if (g_strcmp0 (_tmp0_, "OPTIONS") == 0) {
		result = FALSE;
		return result;
	} else {
		gchar* path = NULL;
		GUri* _tmp1_;
		const gchar* _tmp2_;
		gchar* _tmp3_;
		gboolean _tmp4_ = FALSE;
		const gchar* _tmp5_;
		_tmp1_ = soup_server_message_get_uri (msg);
		_tmp2_ = g_uri_get_path (_tmp1_);
		_tmp3_ = g_strdup (_tmp2_);
		path = _tmp3_;
		_tmp5_ = path;
		if (g_str_has_prefix (_tmp5_, "/api/slides")) {
			_tmp4_ = TRUE;
		} else {
			const gchar* _tmp6_;
			_tmp6_ = path;
			_tmp4_ = g_str_has_prefix (_tmp6_, "/api/notes");
		}
		if (_tmp4_) {
			result = FALSE;
			_g_free0 (path);
			return result;
		} else {
			result = TRUE;
			_g_free0 (path);
			return result;
		}
		_g_free0 (path);
	}
}

static gboolean
___lambda10__soup_auth_domain_filter (SoupAuthDomain* domain,
                                      SoupServerMessage* msg,
                                      gpointer self)
{
	gboolean result;
	result = __lambda10_ ((pdfpcRestServer*) self, domain, msg);
	return result;
}

pdfpcRestServer*
pdfpc_rest_server_construct (GType object_type,
                             pdfpcMetadataPdf* metadata,
                             gint port_num)
{
	pdfpcRestServer * self = NULL;
	GTlsCertificate* cert = NULL;
	GTlsCertificate* _tmp12_;
	pdfpcMetadataPdf* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp21_;
	SoupAuthDomainBasic* auth = NULL;
	SoupAuthDomainBasic* _tmp34_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (metadata != NULL, NULL);
	cert = NULL;
	if (pdfpc_options_rest_https) {
		gchar* user_conf_dir = NULL;
		const gchar* _tmp0_;
		gchar* _tmp1_;
		gchar* cert_fname = NULL;
		const gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* key_fname = NULL;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp0_ = g_get_user_config_dir ();
		_tmp1_ = g_strdup (_tmp0_);
		user_conf_dir = _tmp1_;
		_tmp2_ = user_conf_dir;
		_tmp3_ = g_build_filename (_tmp2_, "pdfpc", "cert.pem", NULL);
		cert_fname = _tmp3_;
		_tmp4_ = user_conf_dir;
		_tmp5_ = g_build_filename (_tmp4_, "pdfpc", "key.pem", NULL);
		key_fname = _tmp5_;
		{
			GTlsCertificate* _tmp6_ = NULL;
			const gchar* _tmp7_;
			const gchar* _tmp8_;
			GTlsCertificate* _tmp9_;
			GTlsCertificate* _tmp10_;
			_tmp7_ = cert_fname;
			_tmp8_ = key_fname;
			_tmp9_ = g_tls_certificate_new_from_files (_tmp7_, _tmp8_, &_inner_error0_);
			_tmp6_ = _tmp9_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp10_ = _tmp6_;
			_tmp6_ = NULL;
			_g_object_unref0 (cert);
			cert = _tmp10_;
			_g_object_unref0 (_tmp6_);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			const gchar* _tmp11_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp11_ = e->message;
			g_printerr ("Error loading TLS certificate: %s\n", _tmp11_);
			exit (1);
			_g_error_free0 (e);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (key_fname);
			_g_free0 (cert_fname);
			_g_free0 (user_conf_dir);
			_g_object_unref0 (cert);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_g_free0 (key_fname);
		_g_free0 (cert_fname);
		_g_free0 (user_conf_dir);
	}
	_tmp12_ = cert;
	self = (pdfpcRestServer*) g_object_new (object_type, "tls-certificate", _tmp12_, NULL);
	_tmp13_ = _g_object_ref0 (metadata);
	_g_object_unref0 (self->priv->metadata);
	self->priv->metadata = _tmp13_;
	if (port_num == 0) {
		port_num = 8088;
	}
	self->priv->port_num = port_num;
	_tmp14_ = pdfpc_options_rest_static_root;
	if (g_str_has_prefix (_tmp14_, "/")) {
		const gchar* _tmp15_;
		gchar* _tmp16_;
		_tmp15_ = pdfpc_options_rest_static_root;
		_tmp16_ = g_strdup (_tmp15_);
		_g_free0 (self->priv->static_root);
		self->priv->static_root = _tmp16_;
	} else {
		if (pdfpc_options_no_install) {
			const gchar* _tmp17_;
			gchar* _tmp18_;
			_tmp17_ = pdfpc_options_rest_static_root;
			_tmp18_ = g_build_filename (PDFPC_PATHS_SOURCE_PATH, _tmp17_, NULL);
			_g_free0 (self->priv->static_root);
			self->priv->static_root = _tmp18_;
		} else {
			const gchar* _tmp19_;
			gchar* _tmp20_;
			_tmp19_ = pdfpc_options_rest_static_root;
			_tmp20_ = g_build_filename (PDFPC_PATHS_SHARE_PATH, _tmp19_, NULL);
			_g_free0 (self->priv->static_root);
			self->priv->static_root = _tmp20_;
		}
	}
	soup_server_add_handler ((SoupServer*) self, "/api", _pdfpc_rest_server_api_handler_soup_server_callback, g_object_ref (self), g_object_unref);
	soup_server_add_handler ((SoupServer*) self, "/", _pdfpc_rest_server_static_handler_soup_server_callback, g_object_ref (self), g_object_unref);
	_tmp21_ = pdfpc_options_rest_passwd;
	if (_tmp21_ == NULL) {
		gchar* _tmp22_;
		GRand* r = NULL;
		GRand* _tmp23_;
		gint i = 0;
		const gchar* _tmp30_;
		guint8* _tmp31_;
		gint _tmp31__length1;
		gint _tmp32_ = 0;
		guint8* _tmp33_;
		gint _tmp33__length1;
		_tmp22_ = g_strdup ("");
		_g_free0 (pdfpc_options_rest_passwd);
		pdfpc_options_rest_passwd = _tmp22_;
		_tmp23_ = g_rand_new ();
		r = _tmp23_;
		i = 0;
		while (TRUE) {
			gchar c = '\0';
			GRand* _tmp24_;
			if (!(i < 8)) {
				break;
			}
			_tmp24_ = r;
			c = (gchar) g_rand_int_range (_tmp24_, (gint32) 0, (gint32) 0x7f);
			if (g_ascii_isalnum (c) == TRUE) {
				const gchar* _tmp25_;
				guint8* _tmp26_;
				gint _tmp26__length1;
				gint _tmp27_ = 0;
				guint8* _tmp28_;
				gint _tmp28__length1;
				gint _tmp29_;
				_tmp25_ = pdfpc_options_rest_passwd;
				_tmp26_ = string_get_data (_tmp25_, &_tmp27_);
				_tmp26__length1 = _tmp27_;
				_tmp28_ = _tmp26_;
				_tmp28__length1 = _tmp26__length1;
				_tmp28_[i] = (guint8) c;
				_tmp29_ = i;
				i = _tmp29_ + 1;
			}
		}
		_tmp30_ = pdfpc_options_rest_passwd;
		_tmp31_ = string_get_data (_tmp30_, &_tmp32_);
		_tmp31__length1 = _tmp32_;
		_tmp33_ = _tmp31_;
		_tmp33__length1 = _tmp31__length1;
		_tmp33_[i] = (guint8) '\0';
		_g_rand_free0 (r);
	}
	_tmp34_ = (SoupAuthDomainBasic*) soup_auth_domain_basic_new ("realm", "pdfpc REST service", NULL);
	auth = _tmp34_;
	soup_auth_domain_add_path ((SoupAuthDomain*) auth, "/api");
	soup_auth_domain_basic_set_auth_callback (auth, ___lambda9__soup_auth_domain_basic_auth_callback, g_object_ref (self), g_object_unref);
	soup_auth_domain_set_filter ((SoupAuthDomain*) auth, ___lambda10__soup_auth_domain_filter, g_object_ref (self), g_object_unref);
	soup_server_add_auth_domain ((SoupServer*) self, (SoupAuthDomain*) auth);
	_g_object_unref0 (auth);
	_g_object_unref0 (cert);
	return self;
}

pdfpcRestServer*
pdfpc_rest_server_new (pdfpcMetadataPdf* metadata,
                       gint port_num)
{
	return pdfpc_rest_server_construct (PDFPC_TYPE_REST_SERVER, metadata, port_num);
}

void
pdfpc_rest_server_start (pdfpcRestServer* self)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	{
		gint options = 0;
		options = 0;
		if (pdfpc_options_rest_https) {
			options = (gint) SOUP_SERVER_LISTEN_HTTPS;
		}
		soup_server_listen_all ((SoupServer*) self, (guint) self->priv->port_num, options, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp0_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp0_ = e->message;
		g_printerr ("Error starting REST server: %s\n", _tmp0_);
		exit (1);
		_g_error_free0 (e);
	}
	__finally0:
	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;
	}
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static inline void
_g_list_free__g_object_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

gchar*
pdfpc_rest_server_get_connection_info (pdfpcRestServer* self)
{
	gchar* ipaddr4 = NULL;
	JsonBuilder* builder = NULL;
	JsonBuilder* _tmp8_;
	JsonBuilder* _tmp9_;
	JsonBuilder* _tmp10_;
	JsonBuilder* _tmp11_;
	const gchar* _tmp12_;
	JsonBuilder* _tmp13_;
	JsonBuilder* _tmp14_;
	JsonBuilder* _tmp15_;
	JsonBuilder* _tmp16_;
	JsonBuilder* _tmp17_;
	JsonBuilder* _tmp18_;
	const gchar* _tmp19_;
	JsonBuilder* _tmp20_;
	JsonNode* root = NULL;
	JsonBuilder* _tmp21_;
	JsonNode* _tmp22_;
	JsonGenerator* generator = NULL;
	JsonGenerator* _tmp23_;
	JsonGenerator* _tmp24_;
	JsonNode* _tmp25_;
	JsonGenerator* _tmp26_;
	gchar* _tmp27_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	{
		gchar hostname[256] = {0};
		GResolver* resolver = NULL;
		GResolver* _tmp0_;
		GList* addresses = NULL;
		GResolver* _tmp1_;
		GList* _tmp2_;
		GInetAddress* address4 = NULL;
		GList* _tmp3_;
		gconstpointer _tmp4_;
		GInetAddress* _tmp5_;
		GInetAddress* _tmp6_;
		gchar* _tmp7_;
		gethostname (hostname, (gint) 256);
		_tmp0_ = g_resolver_get_default ();
		resolver = _tmp0_;
		_tmp1_ = resolver;
		_tmp2_ = g_resolver_lookup_by_name (_tmp1_, (const gchar*) hostname, NULL, &_inner_error0_);
		addresses = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (resolver);
			goto __catch0_g_error;
		}
		_tmp3_ = addresses;
		_tmp4_ = g_list_nth_data (_tmp3_, (guint) 0);
		_tmp5_ = _g_object_ref0 ((GInetAddress*) _tmp4_);
		address4 = _tmp5_;
		_tmp6_ = address4;
		_tmp7_ = g_inet_address_to_string (_tmp6_);
		_g_free0 (ipaddr4);
		ipaddr4 = _tmp7_;
		_g_object_unref0 (address4);
		(addresses == NULL) ? NULL : (addresses = (_g_list_free__g_object_unref0_ (addresses), NULL));
		_g_object_unref0 (resolver);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = NULL;
		_g_free0 (ipaddr4);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (ipaddr4);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp8_ = json_builder_new ();
	builder = _tmp8_;
	_tmp9_ = builder;
	json_builder_begin_object (_tmp9_);
	_tmp10_ = builder;
	json_builder_set_member_name (_tmp10_, "address");
	_tmp11_ = builder;
	_tmp12_ = ipaddr4;
	json_builder_add_string_value (_tmp11_, _tmp12_);
	_tmp13_ = builder;
	json_builder_set_member_name (_tmp13_, "port");
	_tmp14_ = builder;
	json_builder_add_int_value (_tmp14_, (gint64) self->priv->port_num);
	_tmp15_ = builder;
	json_builder_set_member_name (_tmp15_, "ssl");
	_tmp16_ = builder;
	json_builder_add_boolean_value (_tmp16_, soup_server_is_https ((SoupServer*) self));
	_tmp17_ = builder;
	json_builder_set_member_name (_tmp17_, "password");
	_tmp18_ = builder;
	_tmp19_ = pdfpc_options_rest_passwd;
	json_builder_add_string_value (_tmp18_, _tmp19_);
	_tmp20_ = builder;
	json_builder_end_object (_tmp20_);
	_tmp21_ = builder;
	_tmp22_ = json_builder_get_root (_tmp21_);
	root = _tmp22_;
	_tmp23_ = json_generator_new ();
	generator = _tmp23_;
	_tmp24_ = generator;
	_tmp25_ = root;
	json_generator_set_root (_tmp24_, _tmp25_);
	_tmp26_ = generator;
	_tmp27_ = json_generator_to_data (_tmp26_, NULL);
	result = _tmp27_;
	_g_object_unref0 (generator);
	__vala_JsonNode_free0 (root);
	_g_object_unref0 (builder);
	_g_free0 (ipaddr4);
	return result;
}

static void
pdfpc_rest_server_class_init (pdfpcRestServerClass * klass,
                              gpointer klass_data)
{
	pdfpc_rest_server_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &pdfpcRestServer_private_offset);
	G_OBJECT_CLASS (klass)->finalize = pdfpc_rest_server_finalize;
}

static void
pdfpc_rest_server_instance_init (pdfpcRestServer * self,
                                 gpointer klass)
{
	gchar* _tmp0_;
	self->priv = pdfpc_rest_server_get_instance_private (self);
	self->priv->api_version = 1;
	self->priv->locked = FALSE;
	self->priv->client_host = NULL;
	_tmp0_ = g_strdup (".");
	self->priv->static_root = _tmp0_;
}

static void
pdfpc_rest_server_finalize (GObject * obj)
{
	pdfpcRestServer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFPC_TYPE_REST_SERVER, pdfpcRestServer);
	_g_object_unref0 (self->priv->metadata);
	_g_free0 (self->priv->client_host);
	_g_free0 (self->priv->static_root);
	G_OBJECT_CLASS (pdfpc_rest_server_parent_class)->finalize (obj);
}

static GType
pdfpc_rest_server_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (pdfpcRestServerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdfpc_rest_server_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (pdfpcRestServer), 0, (GInstanceInitFunc) pdfpc_rest_server_instance_init, NULL };
	GType pdfpc_rest_server_type_id;
	pdfpc_rest_server_type_id = g_type_register_static (soup_server_get_type (), "pdfpcRestServer", &g_define_type_info, 0);
	pdfpcRestServer_private_offset = g_type_add_instance_private (pdfpc_rest_server_type_id, sizeof (pdfpcRestServerPrivate));
	return pdfpc_rest_server_type_id;
}

GType
pdfpc_rest_server_get_type (void)
{
	static volatile gsize pdfpc_rest_server_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_rest_server_type_id__once)) {
		GType pdfpc_rest_server_type_id;
		pdfpc_rest_server_type_id = pdfpc_rest_server_get_type_once ();
		g_once_init_leave (&pdfpc_rest_server_type_id__once, pdfpc_rest_server_type_id);
	}
	return pdfpc_rest_server_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

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

