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

/* -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-*/
/*-
 * Copyright (c) 2011-2015 elementary LLC
 *
 * 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/>.
 *
 * Authored by: Mario Guerriero <marioguerriero33@gmail.com>
 */

#include <glib-object.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>

#define MAYA_SERVICES_EVENT_PARSER_HANDLER_FALLBACK_LANG "en"
#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 MAYA_SERVICES_TYPE_EVENT_PARSER_HANDLER (maya_services_event_parser_handler_get_type ())
#define MAYA_SERVICES_EVENT_PARSER_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAYA_SERVICES_TYPE_EVENT_PARSER_HANDLER, MayaServicesEventParserHandler))
#define MAYA_SERVICES_EVENT_PARSER_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAYA_SERVICES_TYPE_EVENT_PARSER_HANDLER, MayaServicesEventParserHandlerClass))
#define MAYA_SERVICES_IS_EVENT_PARSER_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAYA_SERVICES_TYPE_EVENT_PARSER_HANDLER))
#define MAYA_SERVICES_IS_EVENT_PARSER_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAYA_SERVICES_TYPE_EVENT_PARSER_HANDLER))
#define MAYA_SERVICES_EVENT_PARSER_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAYA_SERVICES_TYPE_EVENT_PARSER_HANDLER, MayaServicesEventParserHandlerClass))

typedef struct _MayaServicesEventParserHandler MayaServicesEventParserHandler;
typedef struct _MayaServicesEventParserHandlerClass MayaServicesEventParserHandlerClass;
typedef struct _MayaServicesEventParserHandlerPrivate MayaServicesEventParserHandlerPrivate;

#define MAYA_SERVICES_TYPE_EVENT_PARSER (maya_services_event_parser_get_type ())
#define MAYA_SERVICES_EVENT_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAYA_SERVICES_TYPE_EVENT_PARSER, MayaServicesEventParser))
#define MAYA_SERVICES_IS_EVENT_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAYA_SERVICES_TYPE_EVENT_PARSER))
#define MAYA_SERVICES_EVENT_PARSER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MAYA_SERVICES_TYPE_EVENT_PARSER, MayaServicesEventParserIface))

typedef struct _MayaServicesEventParser MayaServicesEventParser;
typedef struct _MayaServicesEventParserIface MayaServicesEventParserIface;

#define MAYA_SERVICES_TYPE_PARSED_EVENT (maya_services_parsed_event_get_type ())
#define MAYA_SERVICES_PARSED_EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAYA_SERVICES_TYPE_PARSED_EVENT, MayaServicesParsedEvent))
#define MAYA_SERVICES_PARSED_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAYA_SERVICES_TYPE_PARSED_EVENT, MayaServicesParsedEventClass))
#define MAYA_SERVICES_IS_PARSED_EVENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAYA_SERVICES_TYPE_PARSED_EVENT))
#define MAYA_SERVICES_IS_PARSED_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAYA_SERVICES_TYPE_PARSED_EVENT))
#define MAYA_SERVICES_PARSED_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAYA_SERVICES_TYPE_PARSED_EVENT, MayaServicesParsedEventClass))

typedef struct _MayaServicesParsedEvent MayaServicesParsedEvent;
typedef struct _MayaServicesParsedEventClass MayaServicesParsedEventClass;
enum  {
	MAYA_SERVICES_EVENT_PARSER_HANDLER_0_PROPERTY,
	MAYA_SERVICES_EVENT_PARSER_HANDLER_NUM_PROPERTIES
};
static GParamSpec* maya_services_event_parser_handler_properties[MAYA_SERVICES_EVENT_PARSER_HANDLER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define MAYA_SERVICES_TYPE_PARSER_EN (maya_services_parser_en_get_type ())
#define MAYA_SERVICES_PARSER_EN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAYA_SERVICES_TYPE_PARSER_EN, MayaServicesParserEn))
#define MAYA_SERVICES_PARSER_EN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAYA_SERVICES_TYPE_PARSER_EN, MayaServicesParserEnClass))
#define MAYA_SERVICES_IS_PARSER_EN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAYA_SERVICES_TYPE_PARSER_EN))
#define MAYA_SERVICES_IS_PARSER_EN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAYA_SERVICES_TYPE_PARSER_EN))
#define MAYA_SERVICES_PARSER_EN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAYA_SERVICES_TYPE_PARSER_EN, MayaServicesParserEnClass))

typedef struct _MayaServicesParserEn MayaServicesParserEn;
typedef struct _MayaServicesParserEnClass MayaServicesParserEnClass;
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))

#define MAYA_SERVICES_TYPE_PARSER_DE (maya_services_parser_de_get_type ())
#define MAYA_SERVICES_PARSER_DE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAYA_SERVICES_TYPE_PARSER_DE, MayaServicesParserDe))
#define MAYA_SERVICES_PARSER_DE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAYA_SERVICES_TYPE_PARSER_DE, MayaServicesParserDeClass))
#define MAYA_SERVICES_IS_PARSER_DE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAYA_SERVICES_TYPE_PARSER_DE))
#define MAYA_SERVICES_IS_PARSER_DE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAYA_SERVICES_TYPE_PARSER_DE))
#define MAYA_SERVICES_PARSER_DE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAYA_SERVICES_TYPE_PARSER_DE, MayaServicesParserDeClass))

typedef struct _MayaServicesParserDe MayaServicesParserDe;
typedef struct _MayaServicesParserDeClass MayaServicesParserDeClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _MayaServicesEventParserHandler {
	GObject parent_instance;
	MayaServicesEventParserHandlerPrivate * priv;
};

struct _MayaServicesEventParserHandlerClass {
	GObjectClass parent_class;
};

struct _MayaServicesEventParserIface {
	GTypeInterface parent_iface;
	MayaServicesParsedEvent* (*parse_source) (MayaServicesEventParser* self, const gchar* source);
	gchar* (*get_language) (MayaServicesEventParser* self);
};

struct _MayaServicesEventParserHandlerPrivate {
	GeeHashMap* handlers;
};

static gint MayaServicesEventParserHandler_private_offset;
static gpointer maya_services_event_parser_handler_parent_class = NULL;

VALA_EXTERN GType maya_services_event_parser_handler_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MayaServicesEventParserHandler, g_object_unref)
VALA_EXTERN GType maya_services_parsed_event_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MayaServicesParsedEvent, g_object_unref)
VALA_EXTERN GType maya_services_event_parser_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MayaServicesEventParser, g_object_unref)
VALA_EXTERN MayaServicesEventParserHandler* maya_services_event_parser_handler_new (const gchar* lang);
VALA_EXTERN MayaServicesEventParserHandler* maya_services_event_parser_handler_construct (GType object_type,
                                                                              const gchar* lang);
VALA_EXTERN const gchar* maya_services_event_parser_handler_get_locale (MayaServicesEventParserHandler* self);
VALA_EXTERN void maya_services_event_parser_handler_register_handler (MayaServicesEventParserHandler* self,
                                                          const gchar* lang,
                                                          MayaServicesEventParser* parser);
VALA_EXTERN MayaServicesParserEn* maya_services_parser_en_new (GDateTime* _simulated_dt);
VALA_EXTERN MayaServicesParserEn* maya_services_parser_en_construct (GType object_type,
                                                         GDateTime* _simulated_dt);
VALA_EXTERN GType maya_services_parser_en_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MayaServicesParserEn, g_object_unref)
VALA_EXTERN GType maya_services_parser_de_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MayaServicesParserDe, g_object_unref)
VALA_EXTERN MayaServicesParserDe* maya_services_parser_de_new (GDateTime* _simulated_dt);
VALA_EXTERN MayaServicesParserDe* maya_services_parser_de_construct (GType object_type,
                                                         GDateTime* _simulated_dt);
VALA_EXTERN gchar* maya_services_event_parser_get_language (MayaServicesEventParser* self);
VALA_EXTERN MayaServicesEventParser* maya_services_event_parser_handler_get_parser (MayaServicesEventParserHandler* self,
                                                                        const gchar* lang);
static void maya_services_event_parser_handler_finalize (GObject * obj);
static GType maya_services_event_parser_handler_get_type_once (void);

static inline gpointer
maya_services_event_parser_handler_get_instance_private (MayaServicesEventParserHandler* self)
{
	return G_STRUCT_MEMBER_P (self, MayaServicesEventParserHandler_private_offset);
}

MayaServicesEventParserHandler*
maya_services_event_parser_handler_construct (GType object_type,
                                              const gchar* lang)
{
	MayaServicesEventParserHandler * self = NULL;
	GeeHashMap* _tmp0_;
	GDateTime* _tmp2_;
	GDateTime* _tmp3_;
	MayaServicesParserEn* _tmp4_;
	MayaServicesParserEn* _tmp5_;
	MayaServicesParserDe* parser = NULL;
	GDateTime* _tmp6_;
	GDateTime* _tmp7_;
	MayaServicesParserDe* _tmp8_;
	MayaServicesParserDe* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	self = (MayaServicesEventParserHandler*) g_object_new (object_type, NULL);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, MAYA_SERVICES_TYPE_EVENT_PARSER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->handlers);
	self->priv->handlers = _tmp0_;
	if (lang == NULL) {
		const gchar* _tmp1_;
		_tmp1_ = maya_services_event_parser_handler_get_locale (self);
		lang = _tmp1_;
	}
	_tmp2_ = g_date_time_new_now_local ();
	_tmp3_ = _tmp2_;
	_tmp4_ = maya_services_parser_en_new (_tmp3_);
	_tmp5_ = _tmp4_;
	maya_services_event_parser_handler_register_handler (self, MAYA_SERVICES_EVENT_PARSER_HANDLER_FALLBACK_LANG, (MayaServicesEventParser*) _tmp5_);
	_g_object_unref0 (_tmp5_);
	_g_date_time_unref0 (_tmp3_);
	_tmp6_ = g_date_time_new_now_local ();
	_tmp7_ = _tmp6_;
	_tmp8_ = maya_services_parser_de_new (_tmp7_);
	_tmp9_ = _tmp8_;
	_g_date_time_unref0 (_tmp7_);
	parser = _tmp9_;
	_tmp10_ = maya_services_event_parser_get_language ((MayaServicesEventParser*) parser);
	_tmp11_ = _tmp10_;
	maya_services_event_parser_handler_register_handler (self, _tmp11_, (MayaServicesEventParser*) parser);
	_g_free0 (_tmp11_);
	_g_object_unref0 (parser);
	return self;
}

MayaServicesEventParserHandler*
maya_services_event_parser_handler_new (const gchar* lang)
{
	return maya_services_event_parser_handler_construct (MAYA_SERVICES_TYPE_EVENT_PARSER_HANDLER, lang);
}

void
maya_services_event_parser_handler_register_handler (MayaServicesEventParserHandler* self,
                                                     const gchar* lang,
                                                     MayaServicesEventParser* parser)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (lang != NULL);
	g_return_if_fail (parser != NULL);
	_tmp0_ = self->priv->handlers;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp0_, lang, parser);
}

MayaServicesEventParser*
maya_services_event_parser_handler_get_parser (MayaServicesEventParserHandler* self,
                                               const gchar* lang)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp3_;
	gpointer _tmp4_;
	MayaServicesEventParser* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (lang != NULL, NULL);
	_tmp0_ = self->priv->handlers;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, lang)) {
		GeeHashMap* _tmp1_;
		gpointer _tmp2_;
		_tmp1_ = self->priv->handlers;
		_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, MAYA_SERVICES_EVENT_PARSER_HANDLER_FALLBACK_LANG);
		result = (MayaServicesEventParser*) _tmp2_;
		return result;
	}
	_tmp3_ = self->priv->handlers;
	_tmp4_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp3_, lang);
	result = (MayaServicesEventParser*) _tmp4_;
	return result;
}

const gchar*
maya_services_event_parser_handler_get_locale (MayaServicesEventParserHandler* self)
{
	const gchar* _tmp0_;
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_getenv ("LANGUAGE");
	result = _tmp0_;
	return result;
}

static void
maya_services_event_parser_handler_class_init (MayaServicesEventParserHandlerClass * klass,
                                               gpointer klass_data)
{
	maya_services_event_parser_handler_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &MayaServicesEventParserHandler_private_offset);
	G_OBJECT_CLASS (klass)->finalize = maya_services_event_parser_handler_finalize;
}

static void
maya_services_event_parser_handler_instance_init (MayaServicesEventParserHandler * self,
                                                  gpointer klass)
{
	self->priv = maya_services_event_parser_handler_get_instance_private (self);
}

static void
maya_services_event_parser_handler_finalize (GObject * obj)
{
	MayaServicesEventParserHandler * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAYA_SERVICES_TYPE_EVENT_PARSER_HANDLER, MayaServicesEventParserHandler);
	_g_object_unref0 (self->priv->handlers);
	G_OBJECT_CLASS (maya_services_event_parser_handler_parent_class)->finalize (obj);
}

static GType
maya_services_event_parser_handler_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MayaServicesEventParserHandlerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) maya_services_event_parser_handler_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MayaServicesEventParserHandler), 0, (GInstanceInitFunc) maya_services_event_parser_handler_instance_init, NULL };
	GType maya_services_event_parser_handler_type_id;
	maya_services_event_parser_handler_type_id = g_type_register_static (G_TYPE_OBJECT, "MayaServicesEventParserHandler", &g_define_type_info, 0);
	MayaServicesEventParserHandler_private_offset = g_type_add_instance_private (maya_services_event_parser_handler_type_id, sizeof (MayaServicesEventParserHandlerPrivate));
	return maya_services_event_parser_handler_type_id;
}

GType
maya_services_event_parser_handler_get_type (void)
{
	static volatile gsize maya_services_event_parser_handler_type_id__once = 0;
	if (g_once_init_enter (&maya_services_event_parser_handler_type_id__once)) {
		GType maya_services_event_parser_handler_type_id;
		maya_services_event_parser_handler_type_id = maya_services_event_parser_handler_get_type_once ();
		g_once_init_leave (&maya_services_event_parser_handler_type_id__once, maya_services_event_parser_handler_type_id);
	}
	return maya_services_event_parser_handler_type_id__once;
}

