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

/*
 * Copyright 2012 Tom Beckmann, Rico Tzschichholz
 * Copyright 2018 elementary LLC. (https://elementary.io)
 *
 * 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/>.
 */

#include <glib.h>
#include <stdio.h>
#include <meta/main.h>
#include <meta/meta-context.h>
#include <stdlib.h>
#include <glib-object.h>
#include <meta/meta-plugin.h>

#define CONSTANTS_VERSION "6.1.0"
#define CONSTANTS_GETTEXT_PACKAGE "io.elementary.greeter"
#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 _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER (greeter_compositor_window_manager_get_type ())
#define GREETER_COMPOSITOR_WINDOW_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER, GreeterCompositorWindowManager))
#define GREETER_COMPOSITOR_WINDOW_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER, GreeterCompositorWindowManagerClass))
#define GREETER_COMPOSITOR_IS_WINDOW_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER))
#define GREETER_COMPOSITOR_IS_WINDOW_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER))
#define GREETER_COMPOSITOR_WINDOW_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER, GreeterCompositorWindowManagerClass))

typedef struct _GreeterCompositorWindowManager GreeterCompositorWindowManager;
typedef struct _GreeterCompositorWindowManagerClass GreeterCompositorWindowManagerClass;

#define GREETER_COMPOSITOR_TYPE_UTILS (greeter_compositor_utils_get_type ())
#define GREETER_COMPOSITOR_UTILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GREETER_COMPOSITOR_TYPE_UTILS, GreeterCompositorUtils))
#define GREETER_COMPOSITOR_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GREETER_COMPOSITOR_TYPE_UTILS, GreeterCompositorUtilsClass))
#define GREETER_COMPOSITOR_IS_UTILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_COMPOSITOR_TYPE_UTILS))
#define GREETER_COMPOSITOR_IS_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GREETER_COMPOSITOR_TYPE_UTILS))
#define GREETER_COMPOSITOR_UTILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_COMPOSITOR_TYPE_UTILS, GreeterCompositorUtilsClass))

typedef struct _GreeterCompositorUtils GreeterCompositorUtils;
typedef struct _GreeterCompositorUtilsClass GreeterCompositorUtilsClass;
#define _g_type_class_unref0(var) ((var == NULL) ? NULL : (var = (g_type_class_unref (var), NULL)))

VALA_EXTERN void greeter_compositor_print_version (void);
static gint greeter_compositor_main (gchar** args,
                              gint args_length1);
VALA_EXTERN GType greeter_compositor_window_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GreeterCompositorWindowManager, g_object_unref)
VALA_EXTERN gpointer greeter_compositor_utils_ref (gpointer instance);
VALA_EXTERN void greeter_compositor_utils_unref (gpointer instance);
VALA_EXTERN GParamSpec* greeter_compositor_param_spec_utils (const gchar* name,
                                                 const gchar* nick,
                                                 const gchar* blurb,
                                                 GType object_type,
                                                 GParamFlags flags);
VALA_EXTERN void greeter_compositor_value_set_utils (GValue* value,
                                         gpointer v_object);
VALA_EXTERN void greeter_compositor_value_take_utils (GValue* value,
                                          gpointer v_object);
VALA_EXTERN gpointer greeter_compositor_value_get_utils (const GValue* value);
VALA_EXTERN GType greeter_compositor_utils_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GreeterCompositorUtils, greeter_compositor_utils_unref)

const GOptionEntry GREETER_COMPOSITOR_OPTIONS[2] = {{"version", (gchar) 0, (gint) G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (void*) greeter_compositor_print_version, "Print version", NULL}, {NULL}};

void
greeter_compositor_print_version (void)
{
	FILE* _tmp0_;
	_tmp0_ = stdout;
	fprintf (_tmp0_, "GreeterCompositor %s\n", CONSTANTS_VERSION);
	meta_exit (META_EXIT_SUCCESS);
}

static gint
greeter_compositor_main (gchar** args,
                         gint args_length1)
{
	MetaContext* ctx = NULL;
	MetaContext* _tmp0_;
	MetaContext* _tmp1_;
	MetaContext* _tmp7_;
	GTypeClass* _tmp13_;
	GTypeClass* _tmp14_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = meta_create_context ("Mutter(GreeterCompositor)");
	ctx = _tmp0_;
	_tmp1_ = ctx;
	meta_context_add_option_entries (_tmp1_, GREETER_COMPOSITOR_OPTIONS, CONSTANTS_GETTEXT_PACKAGE);
	{
		MetaContext* _tmp2_;
		_tmp2_ = ctx;
		meta_context_configure (_tmp2_, (gint*) (&args_length1), &args, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		FILE* _tmp3_;
		GError* _tmp4_;
		const gchar* _tmp5_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = stderr;
		_tmp4_ = e;
		_tmp5_ = _tmp4_->message;
		fprintf (_tmp3_, "Error initializing: %s\n", _tmp5_);
		result = EXIT_FAILURE;
		_g_error_free0 (e);
		_g_object_unref0 (ctx);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp6_ = -1;
		_g_object_unref0 (ctx);
		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 _tmp6_;
	}
	_tmp7_ = ctx;
	meta_context_set_plugin_gtype (_tmp7_, GREETER_COMPOSITOR_TYPE_WINDOW_MANAGER);
	{
		MetaContext* _tmp8_;
		_tmp8_ = ctx;
		meta_context_setup (_tmp8_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		FILE* _tmp9_;
		GError* _tmp10_;
		const gchar* _tmp11_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp9_ = stderr;
		_tmp10_ = e;
		_tmp11_ = _tmp10_->message;
		fprintf (_tmp9_, "Failed to setup: %s\n", _tmp11_);
		result = EXIT_FAILURE;
		_g_error_free0 (e);
		_g_object_unref0 (ctx);
		return result;
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp12_ = -1;
		_g_object_unref0 (ctx);
		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 _tmp12_;
	}
	_tmp13_ = g_type_class_ref (GREETER_COMPOSITOR_TYPE_UTILS);
	_tmp14_ = _tmp13_;
	_g_type_class_unref0 (_tmp14_);
	{
		MetaContext* _tmp15_;
		_tmp15_ = ctx;
		meta_context_start (_tmp15_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch2_g_error;
		}
	}
	goto __finally2;
	__catch2_g_error:
	{
		GError* e = NULL;
		FILE* _tmp16_;
		GError* _tmp17_;
		const gchar* _tmp18_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp16_ = stderr;
		_tmp17_ = e;
		_tmp18_ = _tmp17_->message;
		fprintf (_tmp16_, "Failed to start: %s\n", _tmp18_);
		result = EXIT_FAILURE;
		_g_error_free0 (e);
		_g_object_unref0 (ctx);
		return result;
	}
	__finally2:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp19_ = -1;
		_g_object_unref0 (ctx);
		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 _tmp19_;
	}
	{
		MetaContext* _tmp20_;
		_tmp20_ = ctx;
		meta_context_run_main_loop (_tmp20_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch3_g_error;
		}
	}
	goto __finally3;
	__catch3_g_error:
	{
		GError* e = NULL;
		FILE* _tmp21_;
		GError* _tmp22_;
		const gchar* _tmp23_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp21_ = stderr;
		_tmp22_ = e;
		_tmp23_ = _tmp22_->message;
		fprintf (_tmp21_, "Greeter Compositor terminated with a failure: %s\n", _tmp23_);
		result = EXIT_FAILURE;
		_g_error_free0 (e);
		_g_object_unref0 (ctx);
		return result;
	}
	__finally3:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp24_ = -1;
		_g_object_unref0 (ctx);
		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 _tmp24_;
	}
	result = EXIT_SUCCESS;
	_g_object_unref0 (ctx);
	return result;
}

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

