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

#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>

#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_DBUS_SERVER (pdfpc_dbus_server_get_type ())
#define PDFPC_DBUS_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_TYPE_DBUS_SERVER, pdfpcDBusServer))
#define PDFPC_DBUS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_TYPE_DBUS_SERVER, pdfpcDBusServerClass))
#define PDFPC_IS_DBUS_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_TYPE_DBUS_SERVER))
#define PDFPC_IS_DBUS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_TYPE_DBUS_SERVER))
#define PDFPC_DBUS_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_TYPE_DBUS_SERVER, pdfpcDBusServerClass))

typedef struct _pdfpcDBusServer pdfpcDBusServer;
typedef struct _pdfpcDBusServerClass pdfpcDBusServerClass;
typedef struct _pdfpcDBusServerPrivate pdfpcDBusServerPrivate;

#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;
enum  {
	PDFPC_DBUS_SERVER_0_PROPERTY,
	PDFPC_DBUS_SERVER_NUMBER_OF_OVERLAYS_PROPERTY,
	PDFPC_DBUS_SERVER_NUMBER_OF_SLIDES_PROPERTY,
	PDFPC_DBUS_SERVER_URL_PROPERTY,
	PDFPC_DBUS_SERVER_NUM_PROPERTIES
};
static GParamSpec* pdfpc_dbus_server_properties[PDFPC_DBUS_SERVER_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block2Data Block2Data;

#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;
typedef struct _Block3Data Block3Data;
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
enum  {
	PDFPC_DBUS_SERVER_OVERLAY_CHANGE_SIGNAL,
	PDFPC_DBUS_SERVER_SLIDE_CHANGE_SIGNAL,
	PDFPC_DBUS_SERVER_NUM_SIGNALS
};
static guint pdfpc_dbus_server_signals[PDFPC_DBUS_SERVER_NUM_SIGNALS] = {0};

struct _pdfpcDBusServer {
	GObject parent_instance;
	pdfpcDBusServerPrivate * priv;
	pdfpcPresentationController* controller;
};

struct _pdfpcDBusServerClass {
	GObjectClass parent_class;
};

struct _pdfpcDBusServerPrivate {
	gchar* _url;
};

struct _Block2Data {
	int _ref_count_;
	pdfpcDBusServer* self;
	pdfpcPresentationController* controller;
};

struct _Block3Data {
	int _ref_count_;
	pdfpcPresentationController* controller;
};

static gint pdfpcDBusServer_private_offset;
static gpointer pdfpc_dbus_server_parent_class = NULL;

VALA_EXTERN GType pdfpc_dbus_server_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcDBusServer, g_object_unref)
VALA_EXTERN guint pdfpc_dbus_server_register_object (void* object,
                                         GDBusConnection* connection,
                                         const gchar* path,
                                         GError** error);
VALA_EXTERN GType pdfpc_presentation_controller_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcPresentationController, g_object_unref)
VALA_EXTERN pdfpcDBusServer* pdfpc_dbus_server_new (pdfpcPresentationController* controller);
VALA_EXTERN pdfpcDBusServer* pdfpc_dbus_server_construct (GType object_type,
                                              pdfpcPresentationController* controller);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
VALA_EXTERN GType pdfpc_metadata_pdf_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcMetadataPdf, g_object_unref)
VALA_EXTERN pdfpcMetadataPdf* pdfpc_presentation_controller_get_metadata (pdfpcPresentationController* self);
VALA_EXTERN gchar* pdfpc_metadata_pdf_get_url (pdfpcMetadataPdf* self);
static void __lambda45_ (Block2Data* _data2_);
VALA_EXTERN gint pdfpc_presentation_controller_get_current_slide_number (pdfpcPresentationController* self);
static void ___lambda45__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda46_ (Block2Data* _data2_);
VALA_EXTERN gint pdfpc_presentation_controller_get_current_user_slide_number (pdfpcPresentationController* self);
static void ___lambda46__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
VALA_EXTERN void pdfpc_dbus_server_start_server (pdfpcPresentationController* controller);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static void __lambda47_ (Block3Data* _data3_,
                  GDBusConnection* connection);
static void ___lambda47__gbus_acquired_callback (GDBusConnection* connection,
                                          const gchar* name,
                                          gpointer self);
static void __lambda48_ (void);
static void ___lambda48__gbus_name_acquired_callback (GDBusConnection* connection,
                                               const gchar* name,
                                               gpointer self);
static void __lambda49_ (void);
static void ___lambda49__gbus_name_lost_callback (GDBusConnection* connection,
                                           const gchar* name,
                                           gpointer self);
VALA_EXTERN void pdfpc_dbus_server_trigger_action (pdfpcDBusServer* self,
                                       const gchar* name,
                                       GError** error);
VALA_EXTERN void pdfpc_presentation_controller_trigger_action (pdfpcPresentationController* self,
                                                   const gchar* name,
                                                   GVariant* parameter);
VALA_EXTERN void pdfpc_dbus_server_trigger_action_arg (pdfpcDBusServer* self,
                                           const gchar* name,
                                           const gchar* parameter,
                                           GError** error);
static GVariant* _variant_new1 (const gchar* value);
VALA_EXTERN gchar* pdfpc_dbus_server_get_notes (pdfpcDBusServer* self,
                                    GError** error);
VALA_EXTERN gchar* pdfpc_metadata_pdf_get_note (pdfpcMetadataPdf* self,
                                    gint slide_number);
VALA_EXTERN gint pdfpc_dbus_server_get_number_of_overlays (pdfpcDBusServer* self);
VALA_EXTERN guint pdfpc_metadata_pdf_get_slide_count (pdfpcMetadataPdf* self);
VALA_EXTERN gint pdfpc_dbus_server_get_number_of_slides (pdfpcDBusServer* self);
VALA_EXTERN gint pdfpc_metadata_pdf_get_user_slide_count (pdfpcMetadataPdf* self);
VALA_EXTERN const gchar* pdfpc_dbus_server_get_url (pdfpcDBusServer* self);
static void pdfpc_dbus_server_finalize (GObject * obj);
static GType pdfpc_dbus_server_get_type_once (void);
static void _vala_pdfpc_dbus_server_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _dbus_pdfpc_dbus_server_trigger_action (pdfpcDBusServer* self,
                                             GVariant* _parameters_,
                                             GDBusMethodInvocation* invocation);
static void _dbus_pdfpc_dbus_server_trigger_action_arg (pdfpcDBusServer* self,
                                                 GVariant* _parameters_,
                                                 GDBusMethodInvocation* invocation);
static void _dbus_pdfpc_dbus_server_get_notes (pdfpcDBusServer* self,
                                        GVariant* _parameters_,
                                        GDBusMethodInvocation* invocation);
static void pdfpc_dbus_server_dbus_interface_method_call (GDBusConnection* connection,
                                                   const gchar* sender,
                                                   const gchar* object_path,
                                                   const gchar* interface_name,
                                                   const gchar* method_name,
                                                   GVariant* parameters,
                                                   GDBusMethodInvocation* invocation,
                                                   gpointer user_data);
static GVariant* pdfpc_dbus_server_dbus_interface_get_property (GDBusConnection* connection,
                                                         const gchar* sender,
                                                         const gchar* object_path,
                                                         const gchar* interface_name,
                                                         const gchar* property_name,
                                                         GError** error,
                                                         gpointer user_data);
static GVariant* _dbus_pdfpc_dbus_server_get_number_of_overlays (pdfpcDBusServer* self);
static GVariant* _dbus_pdfpc_dbus_server_get_number_of_slides (pdfpcDBusServer* self);
static GVariant* _dbus_pdfpc_dbus_server_get_url (pdfpcDBusServer* self);
static gboolean pdfpc_dbus_server_dbus_interface_set_property (GDBusConnection* connection,
                                                        const gchar* sender,
                                                        const gchar* object_path,
                                                        const gchar* interface_name,
                                                        const gchar* property_name,
                                                        GVariant* value,
                                                        GError** error,
                                                        gpointer user_data);
static void _dbus_pdfpc_dbus_server_overlay_change (GObject* _sender,
                                             gint number,
                                             gpointer* _data);
static void _dbus_pdfpc_dbus_server_slide_change (GObject* _sender,
                                           gint number,
                                           gpointer* _data);
static void _pdfpc_dbus_server_unregister_object (gpointer user_data);

static const GDBusArgInfo _pdfpc_dbus_server_dbus_arg_info_trigger_action_name = {-1, "name", "s", NULL};
static const GDBusArgInfo * const _pdfpc_dbus_server_dbus_arg_info_trigger_action_in[] = {&_pdfpc_dbus_server_dbus_arg_info_trigger_action_name, NULL};
static const GDBusArgInfo * const _pdfpc_dbus_server_dbus_arg_info_trigger_action_out[] = {NULL};
static const GDBusMethodInfo _pdfpc_dbus_server_dbus_method_info_trigger_action = {-1, "TriggerAction", (GDBusArgInfo **) (&_pdfpc_dbus_server_dbus_arg_info_trigger_action_in), (GDBusArgInfo **) (&_pdfpc_dbus_server_dbus_arg_info_trigger_action_out), NULL};
static const GDBusArgInfo _pdfpc_dbus_server_dbus_arg_info_trigger_action_arg_name = {-1, "name", "s", NULL};
static const GDBusArgInfo _pdfpc_dbus_server_dbus_arg_info_trigger_action_arg_parameter = {-1, "parameter", "s", NULL};
static const GDBusArgInfo * const _pdfpc_dbus_server_dbus_arg_info_trigger_action_arg_in[] = {&_pdfpc_dbus_server_dbus_arg_info_trigger_action_arg_name, &_pdfpc_dbus_server_dbus_arg_info_trigger_action_arg_parameter, NULL};
static const GDBusArgInfo * const _pdfpc_dbus_server_dbus_arg_info_trigger_action_arg_out[] = {NULL};
static const GDBusMethodInfo _pdfpc_dbus_server_dbus_method_info_trigger_action_arg = {-1, "TriggerActionArg", (GDBusArgInfo **) (&_pdfpc_dbus_server_dbus_arg_info_trigger_action_arg_in), (GDBusArgInfo **) (&_pdfpc_dbus_server_dbus_arg_info_trigger_action_arg_out), NULL};
static const GDBusArgInfo _pdfpc_dbus_server_dbus_arg_info_get_notes_result = {-1, "result", "s", NULL};
static const GDBusArgInfo * const _pdfpc_dbus_server_dbus_arg_info_get_notes_in[] = {NULL};
static const GDBusArgInfo * const _pdfpc_dbus_server_dbus_arg_info_get_notes_out[] = {&_pdfpc_dbus_server_dbus_arg_info_get_notes_result, NULL};
static const GDBusMethodInfo _pdfpc_dbus_server_dbus_method_info_get_notes = {-1, "GetNotes", (GDBusArgInfo **) (&_pdfpc_dbus_server_dbus_arg_info_get_notes_in), (GDBusArgInfo **) (&_pdfpc_dbus_server_dbus_arg_info_get_notes_out), NULL};
static const GDBusMethodInfo * const _pdfpc_dbus_server_dbus_method_info[] = {&_pdfpc_dbus_server_dbus_method_info_trigger_action, &_pdfpc_dbus_server_dbus_method_info_trigger_action_arg, &_pdfpc_dbus_server_dbus_method_info_get_notes, NULL};
static const GDBusArgInfo _pdfpc_dbus_server_dbus_arg_info_overlay_change_number = {-1, "number", "i", NULL};
static const GDBusArgInfo * const _pdfpc_dbus_server_dbus_arg_info_overlay_change[] = {&_pdfpc_dbus_server_dbus_arg_info_overlay_change_number, NULL};
static const GDBusSignalInfo _pdfpc_dbus_server_dbus_signal_info_overlay_change = {-1, "OverlayChange", (GDBusArgInfo **) (&_pdfpc_dbus_server_dbus_arg_info_overlay_change), NULL};
static const GDBusArgInfo _pdfpc_dbus_server_dbus_arg_info_slide_change_number = {-1, "number", "i", NULL};
static const GDBusArgInfo * const _pdfpc_dbus_server_dbus_arg_info_slide_change[] = {&_pdfpc_dbus_server_dbus_arg_info_slide_change_number, NULL};
static const GDBusSignalInfo _pdfpc_dbus_server_dbus_signal_info_slide_change = {-1, "SlideChange", (GDBusArgInfo **) (&_pdfpc_dbus_server_dbus_arg_info_slide_change), NULL};
static const GDBusSignalInfo * const _pdfpc_dbus_server_dbus_signal_info[] = {&_pdfpc_dbus_server_dbus_signal_info_overlay_change, &_pdfpc_dbus_server_dbus_signal_info_slide_change, NULL};
static const GDBusPropertyInfo _pdfpc_dbus_server_dbus_property_info_number_of_overlays = {-1, "NumberOfOverlays", "i", G_DBUS_PROPERTY_INFO_FLAGS_READABLE, NULL};
static const GDBusPropertyInfo _pdfpc_dbus_server_dbus_property_info_number_of_slides = {-1, "NumberOfSlides", "i", G_DBUS_PROPERTY_INFO_FLAGS_READABLE, NULL};
static const GDBusPropertyInfo _pdfpc_dbus_server_dbus_property_info_url = {-1, "Url", "s", G_DBUS_PROPERTY_INFO_FLAGS_READABLE, NULL};
static const GDBusPropertyInfo * const _pdfpc_dbus_server_dbus_property_info[] = {&_pdfpc_dbus_server_dbus_property_info_number_of_overlays, &_pdfpc_dbus_server_dbus_property_info_number_of_slides, &_pdfpc_dbus_server_dbus_property_info_url, NULL};
static const GDBusInterfaceInfo _pdfpc_dbus_server_dbus_interface_info = {-1, "io.github.pdfpc", (GDBusMethodInfo **) (&_pdfpc_dbus_server_dbus_method_info), (GDBusSignalInfo **) (&_pdfpc_dbus_server_dbus_signal_info), (GDBusPropertyInfo **) (&_pdfpc_dbus_server_dbus_property_info), NULL};
static const GDBusInterfaceVTable _pdfpc_dbus_server_dbus_interface_vtable = {pdfpc_dbus_server_dbus_interface_method_call, pdfpc_dbus_server_dbus_interface_get_property, pdfpc_dbus_server_dbus_interface_set_property};

static inline gpointer
pdfpc_dbus_server_get_instance_private (pdfpcDBusServer* self)
{
	return G_STRUCT_MEMBER_P (self, pdfpcDBusServer_private_offset);
}

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

static Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		pdfpcDBusServer* self;
		self = _data2_->self;
		_g_object_unref0 (_data2_->controller);
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}

static void
__lambda45_ (Block2Data* _data2_)
{
	pdfpcDBusServer* self;
	gint _tmp0_;
	gint _tmp1_;
	self = _data2_->self;
	_tmp0_ = pdfpc_presentation_controller_get_current_slide_number (_data2_->controller);
	_tmp1_ = _tmp0_;
	g_signal_emit (self, pdfpc_dbus_server_signals[PDFPC_DBUS_SERVER_OVERLAY_CHANGE_SIGNAL], 0, _tmp1_);
}

static void
___lambda45__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda45_ (self);
}

static void
__lambda46_ (Block2Data* _data2_)
{
	pdfpcDBusServer* self;
	gint _tmp0_;
	gint _tmp1_;
	self = _data2_->self;
	_tmp0_ = pdfpc_presentation_controller_get_current_user_slide_number (_data2_->controller);
	_tmp1_ = _tmp0_;
	g_signal_emit (self, pdfpc_dbus_server_signals[PDFPC_DBUS_SERVER_SLIDE_CHANGE_SIGNAL], 0, _tmp1_);
}

static void
___lambda46__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda46_ (self);
}

pdfpcDBusServer*
pdfpc_dbus_server_construct (GType object_type,
                             pdfpcPresentationController* controller)
{
	pdfpcDBusServer * self = NULL;
	Block2Data* _data2_;
	pdfpcPresentationController* _tmp0_;
	pdfpcPresentationController* _tmp1_;
	pdfpcPresentationController* _tmp2_;
	pdfpcMetadataPdf* _tmp3_;
	pdfpcMetadataPdf* _tmp4_;
	gchar* _tmp5_;
	g_return_val_if_fail (controller != NULL, NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (controller);
	_g_object_unref0 (_data2_->controller);
	_data2_->controller = _tmp0_;
	self = (pdfpcDBusServer*) g_object_new (object_type, NULL);
	_data2_->self = g_object_ref (self);
	_tmp1_ = _g_object_ref0 (_data2_->controller);
	_g_object_unref0 (self->controller);
	self->controller = _tmp1_;
	_tmp2_ = self->controller;
	_tmp3_ = pdfpc_presentation_controller_get_metadata (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = pdfpc_metadata_pdf_get_url (_tmp4_);
	_g_free0 (self->priv->_url);
	self->priv->_url = _tmp5_;
	g_signal_connect_data ((GObject*) _data2_->controller, "notify::current-slide-number", (GCallback) ___lambda45__g_object_notify, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	g_signal_connect_data ((GObject*) _data2_->controller, "notify::current-user-slide-number", (GCallback) ___lambda46__g_object_notify, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	block2_data_unref (_data2_);
	_data2_ = NULL;
	return self;
}

pdfpcDBusServer*
pdfpc_dbus_server_new (pdfpcPresentationController* controller)
{
	return pdfpc_dbus_server_construct (PDFPC_TYPE_DBUS_SERVER, controller);
}

static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		_g_object_unref0 (_data3_->controller);
		g_slice_free (Block3Data, _data3_);
	}
}

static void
__lambda47_ (Block3Data* _data3_,
             GDBusConnection* connection)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (connection != NULL);
	{
		pdfpcDBusServer* _tmp0_;
		pdfpcDBusServer* _tmp1_;
		_tmp0_ = pdfpc_dbus_server_new (_data3_->controller);
		_tmp1_ = _tmp0_;
		pdfpc_dbus_server_register_object (_tmp1_, connection, "/io/github/pdfpc", &_inner_error0_);
		_g_object_unref0 (_tmp1_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	goto __finally0;
	__catch0_g_io_error:
	{
		g_clear_error (&_inner_error0_);
		g_printerr ("Could not register DBus service.\n");
	}
	__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
___lambda47__gbus_acquired_callback (GDBusConnection* connection,
                                     const gchar* name,
                                     gpointer self)
{
	__lambda47_ (self, connection);
}

static void
__lambda48_ (void)
{
}

static void
___lambda48__gbus_name_acquired_callback (GDBusConnection* connection,
                                          const gchar* name,
                                          gpointer self)
{
	__lambda48_ ();
}

static void
__lambda49_ (void)
{
	g_printerr ("Could not acquire DBus bus.\n");
}

static void
___lambda49__gbus_name_lost_callback (GDBusConnection* connection,
                                      const gchar* name,
                                      gpointer self)
{
	__lambda49_ ();
}

void
pdfpc_dbus_server_start_server (pdfpcPresentationController* controller)
{
	Block3Data* _data3_;
	pdfpcPresentationController* _tmp0_;
	g_return_if_fail (controller != NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (controller);
	_g_object_unref0 (_data3_->controller);
	_data3_->controller = _tmp0_;
	g_bus_own_name_with_closures (G_BUS_TYPE_SESSION, "io.github.pdfpc", G_BUS_NAME_OWNER_FLAGS_NONE, (GClosure*) ((___lambda47__gbus_acquired_callback == NULL) ? NULL : g_cclosure_new ((GCallback) ___lambda47__gbus_acquired_callback, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref)), (GClosure*) ((___lambda48__gbus_name_acquired_callback == NULL) ? NULL : g_cclosure_new ((GCallback) ___lambda48__gbus_name_acquired_callback, NULL, (GClosureNotify) NULL)), (GClosure*) ((___lambda49__gbus_name_lost_callback == NULL) ? NULL : g_cclosure_new ((GCallback) ___lambda49__gbus_name_lost_callback, NULL, (GClosureNotify) NULL)));
	block3_data_unref (_data3_);
	_data3_ = NULL;
}

void
pdfpc_dbus_server_trigger_action (pdfpcDBusServer* self,
                                  const gchar* name,
                                  GError** error)
{
	pdfpcPresentationController* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = self->controller;
	pdfpc_presentation_controller_trigger_action (_tmp0_, name, NULL);
}

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

void
pdfpc_dbus_server_trigger_action_arg (pdfpcDBusServer* self,
                                      const gchar* name,
                                      const gchar* parameter,
                                      GError** error)
{
	pdfpcPresentationController* _tmp0_;
	GVariant* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (parameter != NULL);
	_tmp0_ = self->controller;
	_tmp1_ = _variant_new1 (parameter);
	pdfpc_presentation_controller_trigger_action (_tmp0_, name, _tmp1_);
	_g_variant_unref0 (_tmp1_);
}

gchar*
pdfpc_dbus_server_get_notes (pdfpcDBusServer* self,
                             GError** error)
{
	pdfpcPresentationController* _tmp0_;
	pdfpcMetadataPdf* _tmp1_;
	pdfpcMetadataPdf* _tmp2_;
	pdfpcPresentationController* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gchar* _tmp6_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->controller;
	_tmp1_ = pdfpc_presentation_controller_get_metadata (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->controller;
	_tmp4_ = pdfpc_presentation_controller_get_current_slide_number (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = pdfpc_metadata_pdf_get_note (_tmp2_, _tmp5_);
	result = _tmp6_;
	return result;
}

gint
pdfpc_dbus_server_get_number_of_overlays (pdfpcDBusServer* self)
{
	gint result;
	pdfpcPresentationController* _tmp0_;
	pdfpcMetadataPdf* _tmp1_;
	pdfpcMetadataPdf* _tmp2_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->controller;
	_tmp1_ = pdfpc_presentation_controller_get_metadata (_tmp0_);
	_tmp2_ = _tmp1_;
	result = (gint) pdfpc_metadata_pdf_get_slide_count (_tmp2_);
	return result;
}

gint
pdfpc_dbus_server_get_number_of_slides (pdfpcDBusServer* self)
{
	gint result;
	pdfpcPresentationController* _tmp0_;
	pdfpcMetadataPdf* _tmp1_;
	pdfpcMetadataPdf* _tmp2_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->controller;
	_tmp1_ = pdfpc_presentation_controller_get_metadata (_tmp0_);
	_tmp2_ = _tmp1_;
	result = pdfpc_metadata_pdf_get_user_slide_count (_tmp2_);
	return result;
}

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

static void
pdfpc_dbus_server_class_init (pdfpcDBusServerClass * klass,
                              gpointer klass_data)
{
	pdfpc_dbus_server_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &pdfpcDBusServer_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_pdfpc_dbus_server_get_property;
	G_OBJECT_CLASS (klass)->finalize = pdfpc_dbus_server_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFPC_DBUS_SERVER_NUMBER_OF_OVERLAYS_PROPERTY, pdfpc_dbus_server_properties[PDFPC_DBUS_SERVER_NUMBER_OF_OVERLAYS_PROPERTY] = g_param_spec_int ("number-of-overlays", "number-of-overlays", "number-of-overlays", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFPC_DBUS_SERVER_NUMBER_OF_SLIDES_PROPERTY, pdfpc_dbus_server_properties[PDFPC_DBUS_SERVER_NUMBER_OF_SLIDES_PROPERTY] = g_param_spec_int ("number-of-slides", "number-of-slides", "number-of-slides", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PDFPC_DBUS_SERVER_URL_PROPERTY, pdfpc_dbus_server_properties[PDFPC_DBUS_SERVER_URL_PROPERTY] = g_param_spec_string ("url", "url", "url", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	pdfpc_dbus_server_signals[PDFPC_DBUS_SERVER_OVERLAY_CHANGE_SIGNAL] = g_signal_new ("overlay-change", PDFPC_TYPE_DBUS_SERVER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
	pdfpc_dbus_server_signals[PDFPC_DBUS_SERVER_SLIDE_CHANGE_SIGNAL] = g_signal_new ("slide-change", PDFPC_TYPE_DBUS_SERVER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
}

static void
pdfpc_dbus_server_instance_init (pdfpcDBusServer * self,
                                 gpointer klass)
{
	self->priv = pdfpc_dbus_server_get_instance_private (self);
}

static void
pdfpc_dbus_server_finalize (GObject * obj)
{
	pdfpcDBusServer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFPC_TYPE_DBUS_SERVER, pdfpcDBusServer);
	_g_free0 (self->priv->_url);
	_g_object_unref0 (self->controller);
	G_OBJECT_CLASS (pdfpc_dbus_server_parent_class)->finalize (obj);
}

static GType
pdfpc_dbus_server_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (pdfpcDBusServerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdfpc_dbus_server_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (pdfpcDBusServer), 0, (GInstanceInitFunc) pdfpc_dbus_server_instance_init, NULL };
	GType pdfpc_dbus_server_type_id;
	pdfpc_dbus_server_type_id = g_type_register_static (G_TYPE_OBJECT, "pdfpcDBusServer", &g_define_type_info, 0);
	g_type_set_qdata (pdfpc_dbus_server_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) pdfpc_dbus_server_register_object);
	pdfpcDBusServer_private_offset = g_type_add_instance_private (pdfpc_dbus_server_type_id, sizeof (pdfpcDBusServerPrivate));
	return pdfpc_dbus_server_type_id;
}

GType
pdfpc_dbus_server_get_type (void)
{
	static volatile gsize pdfpc_dbus_server_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_dbus_server_type_id__once)) {
		GType pdfpc_dbus_server_type_id;
		pdfpc_dbus_server_type_id = pdfpc_dbus_server_get_type_once ();
		g_once_init_leave (&pdfpc_dbus_server_type_id__once, pdfpc_dbus_server_type_id);
	}
	return pdfpc_dbus_server_type_id__once;
}

static void
_vala_pdfpc_dbus_server_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	pdfpcDBusServer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PDFPC_TYPE_DBUS_SERVER, pdfpcDBusServer);
	switch (property_id) {
		case PDFPC_DBUS_SERVER_NUMBER_OF_OVERLAYS_PROPERTY:
		g_value_set_int (value, pdfpc_dbus_server_get_number_of_overlays (self));
		break;
		case PDFPC_DBUS_SERVER_NUMBER_OF_SLIDES_PROPERTY:
		g_value_set_int (value, pdfpc_dbus_server_get_number_of_slides (self));
		break;
		case PDFPC_DBUS_SERVER_URL_PROPERTY:
		g_value_set_string (value, pdfpc_dbus_server_get_url (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_dbus_pdfpc_dbus_server_trigger_action (pdfpcDBusServer* self,
                                        GVariant* _parameters_,
                                        GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	gchar* name = NULL;
	GVariant* _tmp0_;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_tmp0_ = g_variant_iter_next_value (&_arguments_iter);
	name = g_variant_dup_string (_tmp0_, NULL);
	g_variant_unref (_tmp0_);
	pdfpc_dbus_server_trigger_action (self, name, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		goto _error;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
	_error:
	_g_free0 (name);
	;
}

static void
_dbus_pdfpc_dbus_server_trigger_action_arg (pdfpcDBusServer* self,
                                            GVariant* _parameters_,
                                            GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	gchar* name = NULL;
	GVariant* _tmp1_;
	gchar* parameter = NULL;
	GVariant* _tmp2_;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_tmp1_ = g_variant_iter_next_value (&_arguments_iter);
	name = g_variant_dup_string (_tmp1_, NULL);
	g_variant_unref (_tmp1_);
	_tmp2_ = g_variant_iter_next_value (&_arguments_iter);
	parameter = g_variant_dup_string (_tmp2_, NULL);
	g_variant_unref (_tmp2_);
	pdfpc_dbus_server_trigger_action_arg (self, name, parameter, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		goto _error;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
	_error:
	_g_free0 (name);
	_g_free0 (parameter);
	;
}

static void
_dbus_pdfpc_dbus_server_get_notes (pdfpcDBusServer* self,
                                   GVariant* _parameters_,
                                   GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	gchar* result;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	result = pdfpc_dbus_server_get_notes (self, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		return;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add_value (&_reply_builder, g_variant_new_string (result));
	_g_free0 (result);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
}

static void
pdfpc_dbus_server_dbus_interface_method_call (GDBusConnection* connection,
                                              const gchar* sender,
                                              const gchar* object_path,
                                              const gchar* interface_name,
                                              const gchar* method_name,
                                              GVariant* parameters,
                                              GDBusMethodInvocation* invocation,
                                              gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	if (strcmp (method_name, "TriggerAction") == 0) {
		_dbus_pdfpc_dbus_server_trigger_action (object, parameters, invocation);
	} else if (strcmp (method_name, "TriggerActionArg") == 0) {
		_dbus_pdfpc_dbus_server_trigger_action_arg (object, parameters, invocation);
	} else if (strcmp (method_name, "GetNotes") == 0) {
		_dbus_pdfpc_dbus_server_get_notes (object, parameters, invocation);
	} else {
		g_object_unref (invocation);
	}
}

static GVariant*
_dbus_pdfpc_dbus_server_get_number_of_overlays (pdfpcDBusServer* self)
{
	gint result;
	GVariant* _reply;
	result = pdfpc_dbus_server_get_number_of_overlays (self);
	_reply = g_variant_new_int32 (result);
	return _reply;
}

static GVariant*
_dbus_pdfpc_dbus_server_get_number_of_slides (pdfpcDBusServer* self)
{
	gint result;
	GVariant* _reply;
	result = pdfpc_dbus_server_get_number_of_slides (self);
	_reply = g_variant_new_int32 (result);
	return _reply;
}

static GVariant*
_dbus_pdfpc_dbus_server_get_url (pdfpcDBusServer* self)
{
	const gchar* result;
	GVariant* _reply;
	result = pdfpc_dbus_server_get_url (self);
	_reply = g_variant_new_string (result);
	return _reply;
}

static GVariant*
pdfpc_dbus_server_dbus_interface_get_property (GDBusConnection* connection,
                                               const gchar* sender,
                                               const gchar* object_path,
                                               const gchar* interface_name,
                                               const gchar* property_name,
                                               GError** error,
                                               gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	if (strcmp (property_name, "NumberOfOverlays") == 0) {
		return _dbus_pdfpc_dbus_server_get_number_of_overlays (object);
	} else if (strcmp (property_name, "NumberOfSlides") == 0) {
		return _dbus_pdfpc_dbus_server_get_number_of_slides (object);
	} else if (strcmp (property_name, "Url") == 0) {
		return _dbus_pdfpc_dbus_server_get_url (object);
	}
	return NULL;
}

static gboolean
pdfpc_dbus_server_dbus_interface_set_property (GDBusConnection* connection,
                                               const gchar* sender,
                                               const gchar* object_path,
                                               const gchar* interface_name,
                                               const gchar* property_name,
                                               GVariant* value,
                                               GError** error,
                                               gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	return FALSE;
}

static void
_dbus_pdfpc_dbus_server_overlay_change (GObject* _sender,
                                        gint number,
                                        gpointer* _data)
{
	GDBusConnection * _connection;
	const gchar * _path;
	GVariant *_arguments;
	GVariantBuilder _arguments_builder;
	_connection = _data[1];
	_path = _data[2];
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_int32 (number));
	_arguments = g_variant_builder_end (&_arguments_builder);
	g_dbus_connection_emit_signal (_connection, NULL, _path, "io.github.pdfpc", "OverlayChange", _arguments, NULL);
}

static void
_dbus_pdfpc_dbus_server_slide_change (GObject* _sender,
                                      gint number,
                                      gpointer* _data)
{
	GDBusConnection * _connection;
	const gchar * _path;
	GVariant *_arguments;
	GVariantBuilder _arguments_builder;
	_connection = _data[1];
	_path = _data[2];
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_int32 (number));
	_arguments = g_variant_builder_end (&_arguments_builder);
	g_dbus_connection_emit_signal (_connection, NULL, _path, "io.github.pdfpc", "SlideChange", _arguments, NULL);
}

guint
pdfpc_dbus_server_register_object (gpointer object,
                                   GDBusConnection* connection,
                                   const gchar* path,
                                   GError** error)
{
	guint result;
	gpointer *data;
	data = g_new (gpointer, 3);
	data[0] = g_object_ref (object);
	data[1] = g_object_ref (connection);
	data[2] = g_strdup (path);
	result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_pdfpc_dbus_server_dbus_interface_info), &_pdfpc_dbus_server_dbus_interface_vtable, data, _pdfpc_dbus_server_unregister_object, error);
	if (!result) {
		return 0;
	}
	g_signal_connect (object, "overlay-change", (GCallback) _dbus_pdfpc_dbus_server_overlay_change, data);
	g_signal_connect (object, "slide-change", (GCallback) _dbus_pdfpc_dbus_server_slide_change, data);
	return result;
}

static void
_pdfpc_dbus_server_unregister_object (gpointer user_data)
{
	gpointer* data;
	data = user_data;
	g_signal_handlers_disconnect_by_func (data[0], _dbus_pdfpc_dbus_server_overlay_change, data);
	g_signal_handlers_disconnect_by_func (data[0], _dbus_pdfpc_dbus_server_slide_change, data);
	g_object_unref (data[0]);
	g_object_unref (data[1]);
	g_free (data[2]);
	g_free (data);
}

