/* imap-select-command.c generated by valac 0.56.3, the Vala compiler
 * generated from imap-select-command.vala, do not modify */

/*
 * Copyright 2016 Software Freedom Conservancy Inc.
 *
 * 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-engine.h"
#include <glib.h>
#include <gio/gio.h>

enum  {
	GEARY_IMAP_SELECT_COMMAND_0_PROPERTY,
	GEARY_IMAP_SELECT_COMMAND_MAILBOX_PROPERTY,
	GEARY_IMAP_SELECT_COMMAND_NUM_PROPERTIES
};
static GParamSpec* geary_imap_select_command_properties[GEARY_IMAP_SELECT_COMMAND_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GearyImapSelectCommandPrivate {
	GearyImapMailboxSpecifier* _mailbox;
};

static gint GearyImapSelectCommand_private_offset;
static gpointer geary_imap_select_command_parent_class = NULL;

static void geary_imap_select_command_set_mailbox (GearyImapSelectCommand* self,
                                            GearyImapMailboxSpecifier* value);
static void geary_imap_select_command_finalize (GObject * obj);
static GType geary_imap_select_command_get_type_once (void);
static void _vala_geary_imap_select_command_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static void _vala_geary_imap_select_command_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec);

static inline gpointer
geary_imap_select_command_get_instance_private (GearyImapSelectCommand* self)
{
	return G_STRUCT_MEMBER_P (self, GearyImapSelectCommand_private_offset);
}

GearyImapMailboxSpecifier*
geary_imap_select_command_get_mailbox (GearyImapSelectCommand* self)
{
	GearyImapMailboxSpecifier* result;
	GearyImapMailboxSpecifier* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_IS_SELECT_COMMAND (self), NULL);
	_tmp0_ = self->priv->_mailbox;
	result = _tmp0_;
	return result;
}

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

static void
geary_imap_select_command_set_mailbox (GearyImapSelectCommand* self,
                                       GearyImapMailboxSpecifier* value)
{
	GearyImapMailboxSpecifier* old_value;
	g_return_if_fail (GEARY_IMAP_IS_SELECT_COMMAND (self));
	old_value = geary_imap_select_command_get_mailbox (self);
	if (old_value != value) {
		GearyImapMailboxSpecifier* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_mailbox);
		self->priv->_mailbox = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_imap_select_command_properties[GEARY_IMAP_SELECT_COMMAND_MAILBOX_PROPERTY]);
	}
}

GearyImapSelectCommand*
geary_imap_select_command_construct (GType object_type,
                                     GearyImapMailboxSpecifier* mailbox,
                                     GCancellable* should_send)
{
	GearyImapSelectCommand * self = NULL;
	GearyImapListParameter* _tmp0_;
	GearyImapListParameter* _tmp1_;
	GearyImapParameter* _tmp2_;
	GearyImapParameter* _tmp3_;
	g_return_val_if_fail (GEARY_IMAP_IS_MAILBOX_SPECIFIER (mailbox), NULL);
	g_return_val_if_fail ((should_send == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (should_send, g_cancellable_get_type ()), NULL);
	self = (GearyImapSelectCommand*) geary_imap_command_construct (object_type, GEARY_IMAP_SELECT_COMMAND_NAME, NULL, (gint) 0, should_send);
	geary_imap_select_command_set_mailbox (self, mailbox);
	_tmp0_ = geary_imap_command_get_args (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_TYPE_COMMAND, GearyImapCommand));
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_imap_mailbox_specifier_to_parameter (mailbox);
	_tmp3_ = _tmp2_;
	geary_imap_list_parameter_add (_tmp1_, _tmp3_);
	_g_object_unref0 (_tmp3_);
	return self;
}

GearyImapSelectCommand*
geary_imap_select_command_new (GearyImapMailboxSpecifier* mailbox,
                               GCancellable* should_send)
{
	return geary_imap_select_command_construct (GEARY_IMAP_TYPE_SELECT_COMMAND, mailbox, should_send);
}

static void
geary_imap_select_command_class_init (GearyImapSelectCommandClass * klass,
                                      gpointer klass_data)
{
	geary_imap_select_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyImapSelectCommand_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_geary_imap_select_command_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_geary_imap_select_command_set_property;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_select_command_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_SELECT_COMMAND_MAILBOX_PROPERTY, geary_imap_select_command_properties[GEARY_IMAP_SELECT_COMMAND_MAILBOX_PROPERTY] = g_param_spec_object ("mailbox", "mailbox", "mailbox", GEARY_IMAP_TYPE_MAILBOX_SPECIFIER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
geary_imap_select_command_instance_init (GearyImapSelectCommand * self,
                                         gpointer klass)
{
	self->priv = geary_imap_select_command_get_instance_private (self);
}

static void
geary_imap_select_command_finalize (GObject * obj)
{
	GearyImapSelectCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_TYPE_SELECT_COMMAND, GearyImapSelectCommand);
	_g_object_unref0 (self->priv->_mailbox);
	G_OBJECT_CLASS (geary_imap_select_command_parent_class)->finalize (obj);
}

/**
 * See [[http://tools.ietf.org/html/rfc3501#section-6.3.1]]
 *
 * @see ExamineCommand
 */
 G_GNUC_NO_INLINE static GType
geary_imap_select_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapSelectCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_select_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapSelectCommand), 0, (GInstanceInitFunc) geary_imap_select_command_instance_init, NULL };
	GType geary_imap_select_command_type_id;
	geary_imap_select_command_type_id = g_type_register_static (GEARY_IMAP_TYPE_COMMAND, "GearyImapSelectCommand", &g_define_type_info, 0);
	GearyImapSelectCommand_private_offset = g_type_add_instance_private (geary_imap_select_command_type_id, sizeof (GearyImapSelectCommandPrivate));
	return geary_imap_select_command_type_id;
}

GType
geary_imap_select_command_get_type (void)
{
	static gsize geary_imap_select_command_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_select_command_type_id__once)) {
		GType geary_imap_select_command_type_id;
		geary_imap_select_command_type_id = geary_imap_select_command_get_type_once ();
		g_once_init_leave (&geary_imap_select_command_type_id__once, geary_imap_select_command_type_id);
	}
	return geary_imap_select_command_type_id__once;
}

static void
_vala_geary_imap_select_command_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	GearyImapSelectCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_IMAP_TYPE_SELECT_COMMAND, GearyImapSelectCommand);
	switch (property_id) {
		case GEARY_IMAP_SELECT_COMMAND_MAILBOX_PROPERTY:
		g_value_set_object (value, geary_imap_select_command_get_mailbox (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_geary_imap_select_command_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec)
{
	GearyImapSelectCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_IMAP_TYPE_SELECT_COMMAND, GearyImapSelectCommand);
	switch (property_id) {
		case GEARY_IMAP_SELECT_COMMAND_MAILBOX_PROPERTY:
		geary_imap_select_command_set_mailbox (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

