/* budgie-desktop-settings.c generated by valac 0.56.3, the Vala compiler
 * generated from budgie-desktop-settings.vala, do not modify */

/*
 * This file is part of budgie-desktop
 *
 * Copyright © 2015-2022 Budgie Desktop Developers
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

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

#define PANEL_DBUS_NAME "org.budgie_desktop.Panel"
#define PANEL_DBUS_OBJECT_PATH "/org/budgie_desktop/Panel"
#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 TYPE_PANEL_REMOTE (panel_remote_get_type ())
#define PANEL_REMOTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PANEL_REMOTE, PanelRemote))
#define IS_PANEL_REMOTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PANEL_REMOTE))
#define PANEL_REMOTE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_PANEL_REMOTE, PanelRemoteIface))

typedef struct _PanelRemote PanelRemote;
typedef struct _PanelRemoteIface PanelRemoteIface;

#define TYPE_PANEL_REMOTE_PROXY (panel_remote_proxy_get_type ())
typedef GDBusProxy PanelRemoteProxy;
typedef GDBusProxyClass PanelRemoteProxyClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _PanelRemoteIface {
	GTypeInterface parent_iface;
	void (*OpenSettings) (PanelRemote* self, GError** error);
};

VALA_EXTERN GType panel_remote_proxy_get_type (void) G_GNUC_CONST ;
VALA_EXTERN guint panel_remote_register_object (void* object,
                                    GDBusConnection* connection,
                                    const gchar* path,
                                    GError** error);
VALA_EXTERN GType panel_remote_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PanelRemote, g_object_unref)
VALA_EXTERN void panel_remote_OpenSettings (PanelRemote* self,
                                GError** error);
static GType panel_remote_get_type_once (void);
static void panel_remote_proxy_g_signal (GDBusProxy* proxy,
                                  const gchar* sender_name,
                                  const gchar* signal_name,
                                  GVariant* parameters);
static void panel_remote_proxy_OpenSettings (PanelRemote* self,
                                      GError** error);
static void panel_remote_proxy_panel_remote_interface_init (PanelRemoteIface* iface);
static void _dbus_panel_remote_OpenSettings (PanelRemote* self,
                                      GVariant* _parameters_,
                                      GDBusMethodInvocation* invocation);
static void panel_remote_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* panel_remote_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 gboolean panel_remote_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 _panel_remote_unregister_object (gpointer user_data);
static void _vala_main (gchar** args,
                 gint args_length1);

static const GDBusArgInfo * const _panel_remote_dbus_arg_info_OpenSettings_in[] = {NULL};
static const GDBusArgInfo * const _panel_remote_dbus_arg_info_OpenSettings_out[] = {NULL};
static const GDBusMethodInfo _panel_remote_dbus_method_info_OpenSettings = {-1, "OpenSettings", (GDBusArgInfo **) (&_panel_remote_dbus_arg_info_OpenSettings_in), (GDBusArgInfo **) (&_panel_remote_dbus_arg_info_OpenSettings_out), NULL};
static const GDBusMethodInfo * const _panel_remote_dbus_method_info[] = {&_panel_remote_dbus_method_info_OpenSettings, NULL};
static const GDBusSignalInfo * const _panel_remote_dbus_signal_info[] = {NULL};
static const GDBusPropertyInfo * const _panel_remote_dbus_property_info[] = {NULL};
static const GDBusInterfaceInfo _panel_remote_dbus_interface_info = {-1, "org.budgie_desktop.Panel", (GDBusMethodInfo **) (&_panel_remote_dbus_method_info), (GDBusSignalInfo **) (&_panel_remote_dbus_signal_info), (GDBusPropertyInfo **) (&_panel_remote_dbus_property_info), NULL};
static const GDBusInterfaceVTable _panel_remote_dbus_interface_vtable = {panel_remote_dbus_interface_method_call, panel_remote_dbus_interface_get_property, panel_remote_dbus_interface_set_property};

void
panel_remote_OpenSettings (PanelRemote* self,
                           GError** error)
{
	PanelRemoteIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = PANEL_REMOTE_GET_INTERFACE (self);
	if (_iface_->OpenSettings) {
		_iface_->OpenSettings (self, error);
	}
}

static void
panel_remote_default_init (PanelRemoteIface * iface,
                           gpointer iface_data)
{
}

 G_GNUC_NO_INLINE static GType
panel_remote_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PanelRemoteIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) panel_remote_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType panel_remote_type_id;
	panel_remote_type_id = g_type_register_static (G_TYPE_INTERFACE, "PanelRemote", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (panel_remote_type_id, G_TYPE_OBJECT);
	g_type_set_qdata (panel_remote_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) panel_remote_proxy_get_type);
	g_type_set_qdata (panel_remote_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.budgie_desktop.Panel");
	g_type_set_qdata (panel_remote_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_panel_remote_dbus_interface_info));
	g_type_set_qdata (panel_remote_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) panel_remote_register_object);
	return panel_remote_type_id;
}

GType
panel_remote_get_type (void)
{
	static volatile gsize panel_remote_type_id__once = 0;
	if (g_once_init_enter (&panel_remote_type_id__once)) {
		GType panel_remote_type_id;
		panel_remote_type_id = panel_remote_get_type_once ();
		g_once_init_leave (&panel_remote_type_id__once, panel_remote_type_id);
	}
	return panel_remote_type_id__once;
}

G_DEFINE_TYPE_EXTENDED (PanelRemoteProxy, panel_remote_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (TYPE_PANEL_REMOTE, panel_remote_proxy_panel_remote_interface_init) )
static void
panel_remote_proxy_class_init (PanelRemoteProxyClass* klass)
{
	G_DBUS_PROXY_CLASS (klass)->g_signal = panel_remote_proxy_g_signal;
}

static void
panel_remote_proxy_g_signal (GDBusProxy* proxy,
                             const gchar* sender_name,
                             const gchar* signal_name,
                             GVariant* parameters)
{
}

static void
panel_remote_proxy_init (PanelRemoteProxy* self)
{
	g_dbus_proxy_set_interface_info (G_DBUS_PROXY (self), (GDBusInterfaceInfo *) (&_panel_remote_dbus_interface_info));
}

static void
panel_remote_proxy_OpenSettings (PanelRemote* self,
                                 GError** error)
{
	GDBusMessage *_message;
	GVariant *_arguments;
	GVariantBuilder _arguments_builder;
	GDBusMessage *_reply_message;
	_message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.budgie_desktop.Panel", "OpenSettings");
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	_arguments = g_variant_builder_end (&_arguments_builder);
	g_dbus_message_set_body (_message, _arguments);
	_reply_message = g_dbus_connection_send_message_with_reply_sync (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, error);
	g_object_unref (_message);
	if (!_reply_message) {
		return;
	}
	if (g_dbus_message_to_gerror (_reply_message, error)) {
		g_object_unref (_reply_message);
		return;
	}
	g_object_unref (_reply_message);
}

static void
panel_remote_proxy_panel_remote_interface_init (PanelRemoteIface* iface)
{
	iface->OpenSettings = panel_remote_proxy_OpenSettings;
}

static void
_dbus_panel_remote_OpenSettings (PanelRemote* self,
                                 GVariant* _parameters_,
                                 GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	panel_remote_OpenSettings (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);
	_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
panel_remote_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, "OpenSettings") == 0) {
		_dbus_panel_remote_OpenSettings (object, parameters, invocation);
	} else {
		g_object_unref (invocation);
	}
}

static GVariant*
panel_remote_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];
	return NULL;
}

static gboolean
panel_remote_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;
}

guint
panel_remote_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 *) (&_panel_remote_dbus_interface_info), &_panel_remote_dbus_interface_vtable, data, _panel_remote_unregister_object, error);
	if (!result) {
		return 0;
	}
	return result;
}

static void
_panel_remote_unregister_object (gpointer user_data)
{
	gpointer* data;
	data = user_data;
	g_object_unref (data[0]);
	g_object_unref (data[1]);
	g_free (data[2]);
	g_free (data);
}

static void
_vala_main (gchar** args,
            gint args_length1)
{
	GError* _inner_error0_ = NULL;
	{
		PanelRemote* proxy = NULL;
		PanelRemote* _tmp0_;
		PanelRemote* _tmp1_;
		_tmp0_ = (PanelRemote*) g_initable_new (TYPE_PANEL_REMOTE_PROXY, NULL, &_inner_error0_, "g-flags", 0, "g-name", PANEL_DBUS_NAME, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", PANEL_DBUS_OBJECT_PATH, "g-interface-name", "org.budgie_desktop.Panel", NULL);
		proxy = (PanelRemote*) _tmp0_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp1_ = proxy;
		panel_remote_OpenSettings (_tmp1_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (proxy);
			goto __catch0_g_error;
		}
		_g_object_unref0 (proxy);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		g_warning ("budgie-desktop-settings.vala:25: Failed to launch settings UI: %s", _tmp3_);
		_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;
	}
}

int
main (int argc,
      char ** argv)
{
	_vala_main (argv, argc);
	return 0;
}

