/* plugin-plugin-base.c generated by valac 0.56.3, the Vala compiler
 * generated from plugin-plugin-base.vala, do not modify */

/*
 * Copyright © 2020 Michael Gratton <mike@vee.net>
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later). See the COPYING file in this distribution.
 */

#include "geary-client-43.0.h"
#include <glib.h>
#include <gio/gio.h>
#include "geary-engine.h"

enum  {
	PLUGIN_PLUGIN_BASE_0_PROPERTY,
	PLUGIN_PLUGIN_BASE_PLUGIN_APPLICATION_PROPERTY,
	PLUGIN_PLUGIN_BASE_NUM_PROPERTIES
};
static GParamSpec* plugin_plugin_base_properties[PLUGIN_PLUGIN_BASE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _PluginPluginBasePrivate {
	PluginApplication* _plugin_application;
};

static gint PluginPluginBase_private_offset;
static gpointer plugin_plugin_base_parent_class = NULL;

static void plugin_plugin_base_finalize (GObject * obj);
static GType plugin_plugin_base_get_type_once (void);
static void _vala_plugin_plugin_base_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_plugin_plugin_base_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec);

static inline gpointer
plugin_plugin_base_get_instance_private (PluginPluginBase* self)
{
	return G_STRUCT_MEMBER_P (self, PluginPluginBase_private_offset);
}

PluginApplication*
plugin_plugin_base_get_plugin_application (PluginPluginBase* self)
{
	PluginApplication* result;
	PluginApplication* _tmp0_;
	g_return_val_if_fail (PLUGIN_IS_PLUGIN_BASE (self), NULL);
	_tmp0_ = self->priv->_plugin_application;
	result = _tmp0_;
	return result;
}

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

static void
plugin_plugin_base_set_plugin_application (PluginPluginBase* self,
                                           PluginApplication* value)
{
	PluginApplication* old_value;
	g_return_if_fail (PLUGIN_IS_PLUGIN_BASE (self));
	old_value = plugin_plugin_base_get_plugin_application (self);
	if (old_value != value) {
		PluginApplication* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_plugin_application);
		self->priv->_plugin_application = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, plugin_plugin_base_properties[PLUGIN_PLUGIN_BASE_PLUGIN_APPLICATION_PROPERTY]);
	}
}

void
plugin_plugin_base_activate (PluginPluginBase* self,
                             gboolean is_startup,
                             GAsyncReadyCallback _callback_,
                             gpointer _user_data_)
{
	PluginPluginBaseClass* _klass_;
	_klass_ = PLUGIN_PLUGIN_BASE_GET_CLASS (self);
	if (_klass_->activate) {
		_klass_->activate (self, is_startup, _callback_, _user_data_);
	}
}

void
plugin_plugin_base_activate_finish (PluginPluginBase* self,
                                    GAsyncResult* _res_,
                                    GError** error)
{
	PluginPluginBaseClass* _klass_;
	_klass_ = PLUGIN_PLUGIN_BASE_GET_CLASS (self);
	if (_klass_->activate_finish) {
		_klass_->activate_finish (self, _res_, error);
	}
}

void
plugin_plugin_base_deactivate (PluginPluginBase* self,
                               gboolean is_shutdown,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	PluginPluginBaseClass* _klass_;
	_klass_ = PLUGIN_PLUGIN_BASE_GET_CLASS (self);
	if (_klass_->deactivate) {
		_klass_->deactivate (self, is_shutdown, _callback_, _user_data_);
	}
}

void
plugin_plugin_base_deactivate_finish (PluginPluginBase* self,
                                      GAsyncResult* _res_,
                                      GError** error)
{
	PluginPluginBaseClass* _klass_;
	_klass_ = PLUGIN_PLUGIN_BASE_GET_CLASS (self);
	if (_klass_->deactivate_finish) {
		_klass_->deactivate_finish (self, _res_, error);
	}
}

PluginPluginBase*
plugin_plugin_base_construct (GType object_type)
{
	PluginPluginBase * self = NULL;
	self = (PluginPluginBase*) geary_base_object_construct (object_type);
	return self;
}

static void
plugin_plugin_base_class_init (PluginPluginBaseClass * klass,
                               gpointer klass_data)
{
	plugin_plugin_base_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PluginPluginBase_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_plugin_plugin_base_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_plugin_plugin_base_set_property;
	G_OBJECT_CLASS (klass)->finalize = plugin_plugin_base_finalize;
	/**
	     * Returns an object for interacting with the client application.
	     *
	     * No special permissions are required to use access this
	     * resource.
	     *
	     * This will be set during (or just after) plugin construction,
	     * before {@link PluginBase.activate} is called.
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), PLUGIN_PLUGIN_BASE_PLUGIN_APPLICATION_PROPERTY, plugin_plugin_base_properties[PLUGIN_PLUGIN_BASE_PLUGIN_APPLICATION_PROPERTY] = g_param_spec_object ("plugin-application", "plugin-application", "plugin-application", PLUGIN_TYPE_APPLICATION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
plugin_plugin_base_instance_init (PluginPluginBase * self,
                                  gpointer klass)
{
	self->priv = plugin_plugin_base_get_instance_private (self);
}

static void
plugin_plugin_base_finalize (GObject * obj)
{
	PluginPluginBase * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PLUGIN_TYPE_PLUGIN_BASE, PluginPluginBase);
	_g_object_unref0 (self->priv->_plugin_application);
	G_OBJECT_CLASS (plugin_plugin_base_parent_class)->finalize (obj);
}

/**
 * The base class for objects implementing a client plugin.
 *
 * To implement a new plugin, have it derive from this type and
 * implement any additional extension interfaces (such as {@link
 * NotificationExtension}) as required.
 */
static GType
plugin_plugin_base_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PluginPluginBaseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) plugin_plugin_base_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PluginPluginBase), 0, (GInstanceInitFunc) plugin_plugin_base_instance_init, NULL };
	GType plugin_plugin_base_type_id;
	plugin_plugin_base_type_id = g_type_register_static (GEARY_TYPE_BASE_OBJECT, "PluginPluginBase", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	PluginPluginBase_private_offset = g_type_add_instance_private (plugin_plugin_base_type_id, sizeof (PluginPluginBasePrivate));
	return plugin_plugin_base_type_id;
}

GType
plugin_plugin_base_get_type (void)
{
	static volatile gsize plugin_plugin_base_type_id__once = 0;
	if (g_once_init_enter (&plugin_plugin_base_type_id__once)) {
		GType plugin_plugin_base_type_id;
		plugin_plugin_base_type_id = plugin_plugin_base_get_type_once ();
		g_once_init_leave (&plugin_plugin_base_type_id__once, plugin_plugin_base_type_id);
	}
	return plugin_plugin_base_type_id__once;
}

static void
_vala_plugin_plugin_base_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	PluginPluginBase * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PLUGIN_TYPE_PLUGIN_BASE, PluginPluginBase);
	switch (property_id) {
		case PLUGIN_PLUGIN_BASE_PLUGIN_APPLICATION_PROPERTY:
		g_value_set_object (value, plugin_plugin_base_get_plugin_application (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_plugin_plugin_base_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	PluginPluginBase * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PLUGIN_TYPE_PLUGIN_BASE, PluginPluginBase);
	switch (property_id) {
		case PLUGIN_PLUGIN_BASE_PLUGIN_APPLICATION_PROPERTY:
		plugin_plugin_base_set_plugin_application (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

