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

/* IFreedesktopApplication.vala
 *
 * Copyright 2020 Dylan McCall <dylan@dylanmccall.ca>
 *
 * 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 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "common.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.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

typedef GDBusProxy BreakTimerCommonIFreedesktopApplicationProxy;
typedef GDBusProxyClass BreakTimerCommonIFreedesktopApplicationProxyClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))

static GType break_timer_common_ifreedesktop_application_get_type_once (void);
static void break_timer_common_ifreedesktop_application_proxy_g_signal (GDBusProxy* proxy,
                                                                 const gchar* sender_name,
                                                                 const gchar* signal_name,
                                                                 GVariant* parameters);
static void break_timer_common_ifreedesktop_application_proxy_activate_action (BreakTimerCommonIFreedesktopApplication* self,
                                                                        const gchar* action_name,
                                                                        GVariant** parameter,
                                                                        gint parameter_length1,
                                                                        GHashTable* platform_data,
                                                                        GError** error);
static void break_timer_common_ifreedesktop_application_proxy_break_timer_common_ifreedesktop_application_interface_init (BreakTimerCommonIFreedesktopApplicationIface* iface);
static void _dbus_break_timer_common_ifreedesktop_application_activate_action (BreakTimerCommonIFreedesktopApplication* self,
                                                                        GVariant* _parameters_,
                                                                        GDBusMethodInvocation* invocation);
static void break_timer_common_ifreedesktop_application_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* break_timer_common_ifreedesktop_application_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 break_timer_common_ifreedesktop_application_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 _break_timer_common_ifreedesktop_application_unregister_object (gpointer user_data);
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 const GDBusArgInfo _break_timer_common_ifreedesktop_application_dbus_arg_info_activate_action_action_name = {-1, "action_name", "s", NULL};
static const GDBusArgInfo _break_timer_common_ifreedesktop_application_dbus_arg_info_activate_action_parameter = {-1, "parameter", "av", NULL};
static const GDBusArgInfo _break_timer_common_ifreedesktop_application_dbus_arg_info_activate_action_platform_data = {-1, "platform_data", "a{sv}", NULL};
static const GDBusArgInfo * const _break_timer_common_ifreedesktop_application_dbus_arg_info_activate_action_in[] = {&_break_timer_common_ifreedesktop_application_dbus_arg_info_activate_action_action_name, &_break_timer_common_ifreedesktop_application_dbus_arg_info_activate_action_parameter, &_break_timer_common_ifreedesktop_application_dbus_arg_info_activate_action_platform_data, NULL};
static const GDBusArgInfo * const _break_timer_common_ifreedesktop_application_dbus_arg_info_activate_action_out[] = {NULL};
static const GDBusMethodInfo _break_timer_common_ifreedesktop_application_dbus_method_info_activate_action = {-1, "ActivateAction", (GDBusArgInfo **) (&_break_timer_common_ifreedesktop_application_dbus_arg_info_activate_action_in), (GDBusArgInfo **) (&_break_timer_common_ifreedesktop_application_dbus_arg_info_activate_action_out), NULL};
static const GDBusMethodInfo * const _break_timer_common_ifreedesktop_application_dbus_method_info[] = {&_break_timer_common_ifreedesktop_application_dbus_method_info_activate_action, NULL};
static const GDBusSignalInfo * const _break_timer_common_ifreedesktop_application_dbus_signal_info[] = {NULL};
static const GDBusPropertyInfo * const _break_timer_common_ifreedesktop_application_dbus_property_info[] = {NULL};
static const GDBusInterfaceInfo _break_timer_common_ifreedesktop_application_dbus_interface_info = {-1, "org.freedesktop.Application", (GDBusMethodInfo **) (&_break_timer_common_ifreedesktop_application_dbus_method_info), (GDBusSignalInfo **) (&_break_timer_common_ifreedesktop_application_dbus_signal_info), (GDBusPropertyInfo **) (&_break_timer_common_ifreedesktop_application_dbus_property_info), NULL};
static const GDBusInterfaceVTable _break_timer_common_ifreedesktop_application_dbus_interface_vtable = {break_timer_common_ifreedesktop_application_dbus_interface_method_call, break_timer_common_ifreedesktop_application_dbus_interface_get_property, break_timer_common_ifreedesktop_application_dbus_interface_set_property};

void
break_timer_common_ifreedesktop_application_activate_action (BreakTimerCommonIFreedesktopApplication* self,
                                                             const gchar* action_name,
                                                             GVariant** parameter,
                                                             gint parameter_length1,
                                                             GHashTable* platform_data,
                                                             GError** error)
{
	BreakTimerCommonIFreedesktopApplicationIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = BREAK_TIMER_COMMON_IFREEDESKTOP_APPLICATION_GET_INTERFACE (self);
	if (_iface_->activate_action) {
		_iface_->activate_action (self, action_name, parameter, parameter_length1, platform_data, error);
	}
}

static void
break_timer_common_ifreedesktop_application_default_init (BreakTimerCommonIFreedesktopApplicationIface * iface,
                                                          gpointer iface_data)
{
}

static GType
break_timer_common_ifreedesktop_application_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BreakTimerCommonIFreedesktopApplicationIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) break_timer_common_ifreedesktop_application_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType break_timer_common_ifreedesktop_application_type_id;
	break_timer_common_ifreedesktop_application_type_id = g_type_register_static (G_TYPE_INTERFACE, "BreakTimerCommonIFreedesktopApplication", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (break_timer_common_ifreedesktop_application_type_id, G_TYPE_OBJECT);
	g_type_set_qdata (break_timer_common_ifreedesktop_application_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) break_timer_common_ifreedesktop_application_proxy_get_type);
	g_type_set_qdata (break_timer_common_ifreedesktop_application_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.freedesktop.Application");
	g_type_set_qdata (break_timer_common_ifreedesktop_application_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_break_timer_common_ifreedesktop_application_dbus_interface_info));
	g_type_set_qdata (break_timer_common_ifreedesktop_application_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) break_timer_common_ifreedesktop_application_register_object);
	return break_timer_common_ifreedesktop_application_type_id;
}

GType
break_timer_common_ifreedesktop_application_get_type (void)
{
	static volatile gsize break_timer_common_ifreedesktop_application_type_id__once = 0;
	if (g_once_init_enter (&break_timer_common_ifreedesktop_application_type_id__once)) {
		GType break_timer_common_ifreedesktop_application_type_id;
		break_timer_common_ifreedesktop_application_type_id = break_timer_common_ifreedesktop_application_get_type_once ();
		g_once_init_leave (&break_timer_common_ifreedesktop_application_type_id__once, break_timer_common_ifreedesktop_application_type_id);
	}
	return break_timer_common_ifreedesktop_application_type_id__once;
}

G_DEFINE_TYPE_EXTENDED (BreakTimerCommonIFreedesktopApplicationProxy, break_timer_common_ifreedesktop_application_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (BREAK_TIMER_COMMON_TYPE_IFREEDESKTOP_APPLICATION, break_timer_common_ifreedesktop_application_proxy_break_timer_common_ifreedesktop_application_interface_init) )
static void
break_timer_common_ifreedesktop_application_proxy_class_init (BreakTimerCommonIFreedesktopApplicationProxyClass* klass)
{
	G_DBUS_PROXY_CLASS (klass)->g_signal = break_timer_common_ifreedesktop_application_proxy_g_signal;
}

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

static void
break_timer_common_ifreedesktop_application_proxy_init (BreakTimerCommonIFreedesktopApplicationProxy* self)
{
	g_dbus_proxy_set_interface_info (G_DBUS_PROXY (self), (GDBusInterfaceInfo *) (&_break_timer_common_ifreedesktop_application_dbus_interface_info));
}

static void
break_timer_common_ifreedesktop_application_proxy_activate_action (BreakTimerCommonIFreedesktopApplication* self,
                                                                   const gchar* action_name,
                                                                   GVariant** parameter,
                                                                   gint parameter_length1,
                                                                   GHashTable* platform_data,
                                                                   GError** error)
{
	GDBusMessage *_message;
	GVariant *_arguments;
	GVariantBuilder _arguments_builder;
	GVariant** _tmp32_;
	GVariantBuilder _tmp33_;
	gint _tmp34_;
	GVariantBuilder _tmp35_;
	GHashTableIter _tmp36_;
	gpointer _tmp37_;
	gpointer _tmp38_;
	GDBusMessage *_reply_message;
	G_DBUS_ERROR;
	G_IO_ERROR;
	_message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.freedesktop.Application", "ActivateAction");
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (action_name));
	_tmp32_ = parameter;
	g_variant_builder_init (&_tmp33_, G_VARIANT_TYPE ("av"));
	for (_tmp34_ = 0; _tmp34_ < parameter_length1; _tmp34_++) {
		g_variant_builder_add_value (&_tmp33_, g_variant_new_variant (*_tmp32_));
		_tmp32_++;
	}
	g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp33_));
	g_hash_table_iter_init (&_tmp36_, platform_data);
	g_variant_builder_init (&_tmp35_, G_VARIANT_TYPE ("a{sv}"));
	while (g_hash_table_iter_next (&_tmp36_, &_tmp37_, &_tmp38_)) {
		gchar* _key;
		GVariant* _value;
		_key = (gchar*) _tmp37_;
		_value = (GVariant*) _tmp38_;
		g_variant_builder_add (&_tmp35_, "{?*}", g_variant_new_string (_key), g_variant_new_variant (_value));
	}
	g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp35_));
	_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
break_timer_common_ifreedesktop_application_proxy_break_timer_common_ifreedesktop_application_interface_init (BreakTimerCommonIFreedesktopApplicationIface* iface)
{
	iface->activate_action = break_timer_common_ifreedesktop_application_proxy_activate_action;
}

static void
_dbus_break_timer_common_ifreedesktop_application_activate_action (BreakTimerCommonIFreedesktopApplication* self,
                                                                   GVariant* _parameters_,
                                                                   GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	gchar* action_name = NULL;
	GVariant* _tmp39_;
	GVariant** parameter = NULL;
	gint parameter_length1 = 0;
	GVariant* _tmp40_;
	GVariant** _tmp41_;
	gint _tmp41__length;
	gint _tmp41__size;
	gint _tmp41__length1;
	GVariantIter _tmp42_;
	GVariant* _tmp43_;
	GHashTable* platform_data = NULL;
	GVariant* _tmp44_;
	GHashTable* _tmp45_;
	GVariantIter _tmp46_;
	GVariant* _tmp47_;
	GVariant* _tmp48_;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_tmp39_ = g_variant_iter_next_value (&_arguments_iter);
	action_name = g_variant_dup_string (_tmp39_, NULL);
	g_variant_unref (_tmp39_);
	_tmp40_ = g_variant_iter_next_value (&_arguments_iter);
	_tmp41_ = g_new (GVariant*, 5);
	_tmp41__length = 0;
	_tmp41__size = 4;
	_tmp41__length1 = 0;
	g_variant_iter_init (&_tmp42_, _tmp40_);
	for (; (_tmp43_ = g_variant_iter_next_value (&_tmp42_)) != NULL; _tmp41__length1++) {
		if (_tmp41__size == _tmp41__length) {
			_tmp41__size = 2 * _tmp41__size;
			_tmp41_ = g_renew (GVariant*, _tmp41_, _tmp41__size + 1);
		}
		_tmp41_[_tmp41__length++] = g_variant_get_variant (_tmp43_);
		g_variant_unref (_tmp43_);
	}
	parameter_length1 = _tmp41__length1;
	_tmp41_[_tmp41__length] = NULL;
	parameter = _tmp41_;
	g_variant_unref (_tmp40_);
	_tmp44_ = g_variant_iter_next_value (&_arguments_iter);
	_tmp45_ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
	g_variant_iter_init (&_tmp46_, _tmp44_);
	while (g_variant_iter_loop (&_tmp46_, "{?*}", &_tmp47_, &_tmp48_)) {
		g_hash_table_insert (_tmp45_, g_variant_dup_string (_tmp47_, NULL), g_variant_get_variant (_tmp48_));
	}
	platform_data = _tmp45_;
	g_variant_unref (_tmp44_);
	break_timer_common_ifreedesktop_application_activate_action (self, action_name, parameter, parameter_length1, platform_data, &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 (action_name);
	parameter = (_vala_array_free (parameter, parameter_length1, (GDestroyNotify) g_variant_unref), NULL);
	_g_hash_table_unref0 (platform_data);
	;
}

static void
break_timer_common_ifreedesktop_application_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, "ActivateAction") == 0) {
		_dbus_break_timer_common_ifreedesktop_application_activate_action (object, parameters, invocation);
	} else {
		g_object_unref (invocation);
	}
}

static GVariant*
break_timer_common_ifreedesktop_application_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)
{
	return NULL;
}

static gboolean
break_timer_common_ifreedesktop_application_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)
{
	return FALSE;
}

guint
break_timer_common_ifreedesktop_application_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 *) (&_break_timer_common_ifreedesktop_application_dbus_interface_info), &_break_timer_common_ifreedesktop_application_dbus_interface_vtable, data, _break_timer_common_ifreedesktop_application_unregister_object, error);
	if (!result) {
		return 0;
	}
	return result;
}

static void
_break_timer_common_ifreedesktop_application_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_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);
}

