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

/* 
 *      Copyright 2012 Julien Lavergne <gilir@ubuntu.com>
 *
 *      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 2 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, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <lxpolkit/lxpolkit.h>

#define GETTEXT_PACKAGE "lxsession"
#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 LXSESSION_TYPE_MAIN (lxsession_main_get_type ())
#define LXSESSION_MAIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LXSESSION_TYPE_MAIN, LxsessionMain))
#define LXSESSION_MAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LXSESSION_TYPE_MAIN, LxsessionMainClass))
#define LXSESSION_IS_MAIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LXSESSION_TYPE_MAIN))
#define LXSESSION_IS_MAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LXSESSION_TYPE_MAIN))
#define LXSESSION_MAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LXSESSION_TYPE_MAIN, LxsessionMainClass))

typedef struct _LxsessionMain LxsessionMain;
typedef struct _LxsessionMainClass LxsessionMainClass;
typedef struct _LxsessionMainPrivate LxsessionMainPrivate;
enum  {
	LXSESSION_MAIN_0_PROPERTY,
	LXSESSION_MAIN_NUM_PROPERTIES
};
static GParamSpec* lxsession_main_properties[LXSESSION_MAIN_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))

struct _LxsessionMain {
	GObject parent_instance;
	LxsessionMainPrivate * priv;
};

struct _LxsessionMainClass {
	GObjectClass parent_class;
};

static gpointer lxsession_main_parent_class = NULL;

VALA_EXTERN GType lxsession_main_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (LxsessionMain, g_object_unref)
static gint lxsession_main_main (gchar** args,
                          gint args_length1);
VALA_EXTERN LxsessionMain* lxsession_main_new (void);
VALA_EXTERN LxsessionMain* lxsession_main_construct (GType object_type);
static GType lxsession_main_get_type_once (void);

static gint
lxsession_main_main (gchar** args,
                     gint args_length1)
{
	GApplication* app = NULL;
	GApplication* _tmp0_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GMainLoop* _tmp4_;
	GMainLoop* _tmp5_;
	GError* _inner_error0_ = NULL;
	gint result;
	textdomain (GETTEXT_PACKAGE);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "utf-8");
	gtk_init ((gint*) (&args_length1), &args);
	_tmp0_ = g_application_new ("org.lxde.lxpolkit", G_APPLICATION_FLAGS_NONE);
	app = _tmp0_;
	g_application_register (app, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp1_ = -1;
		_g_object_unref0 (app);
		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 _tmp1_;
	}
	_tmp2_ = g_application_get_is_remote (app);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		g_message ("main.vala:40: %s", _ ("lxpolkit is already running. Exiting"));
		result = 0;
		_g_object_unref0 (app);
		return result;
	}
	policykit_agent_init ();
	_tmp4_ = g_main_loop_new (NULL, FALSE);
	_tmp5_ = _tmp4_;
	g_main_loop_run (_tmp5_);
	_g_main_loop_unref0 (_tmp5_);
	policykit_agent_finalize ();
	result = 0;
	_g_object_unref0 (app);
	return result;
}

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

LxsessionMain*
lxsession_main_construct (GType object_type)
{
	LxsessionMain * self = NULL;
	self = (LxsessionMain*) g_object_new (object_type, NULL);
	return self;
}

LxsessionMain*
lxsession_main_new (void)
{
	return lxsession_main_construct (LXSESSION_TYPE_MAIN);
}

static void
lxsession_main_class_init (LxsessionMainClass * klass,
                           gpointer klass_data)
{
	lxsession_main_parent_class = g_type_class_peek_parent (klass);
}

static void
lxsession_main_instance_init (LxsessionMain * self,
                              gpointer klass)
{
}

static GType
lxsession_main_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (LxsessionMainClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) lxsession_main_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LxsessionMain), 0, (GInstanceInitFunc) lxsession_main_instance_init, NULL };
	GType lxsession_main_type_id;
	lxsession_main_type_id = g_type_register_static (G_TYPE_OBJECT, "LxsessionMain", &g_define_type_info, 0);
	return lxsession_main_type_id;
}

GType
lxsession_main_get_type (void)
{
	static volatile gsize lxsession_main_type_id__once = 0;
	if (g_once_init_enter (&lxsession_main_type_id__once)) {
		GType lxsession_main_type_id;
		lxsession_main_type_id = lxsession_main_get_type_once ();
		g_once_init_leave (&lxsession_main_type_id__once, lxsession_main_type_id);
	}
	return lxsession_main_type_id__once;
}

