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

/*
    Util.vala
    Copyright (C) 2010 Maia Kozheva <sikon@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 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-object.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"

#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 STEADYFLOW_CORE_TYPE_UTIL (steadyflow_core_util_get_type ())
#define STEADYFLOW_CORE_UTIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STEADYFLOW_CORE_TYPE_UTIL, SteadyflowCoreUtil))
#define STEADYFLOW_CORE_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STEADYFLOW_CORE_TYPE_UTIL, SteadyflowCoreUtilClass))
#define STEADYFLOW_CORE_IS_UTIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), STEADYFLOW_CORE_TYPE_UTIL))
#define STEADYFLOW_CORE_IS_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), STEADYFLOW_CORE_TYPE_UTIL))
#define STEADYFLOW_CORE_UTIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), STEADYFLOW_CORE_TYPE_UTIL, SteadyflowCoreUtilClass))

typedef struct _SteadyflowCoreUtil SteadyflowCoreUtil;
typedef struct _SteadyflowCoreUtilClass SteadyflowCoreUtilClass;
typedef struct _SteadyflowCoreUtilPrivate SteadyflowCoreUtilPrivate;
enum  {
	STEADYFLOW_CORE_UTIL_0_PROPERTY,
	STEADYFLOW_CORE_UTIL_NUM_PROPERTIES
};
static GParamSpec* steadyflow_core_util_properties[STEADYFLOW_CORE_UTIL_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	STEADYFLOW_CORE_UTIL_FATAL_ERROR_SIG_SIGNAL,
	STEADYFLOW_CORE_UTIL_NUM_SIGNALS
};
static guint steadyflow_core_util_signals[STEADYFLOW_CORE_UTIL_NUM_SIGNALS] = {0};

struct _SteadyflowCoreUtil {
	GObject parent_instance;
	SteadyflowCoreUtilPrivate * priv;
};

struct _SteadyflowCoreUtilClass {
	GObjectClass parent_class;
};

static gpointer steadyflow_core_util_parent_class = NULL;
static gboolean steadyflow_core_util_first_run;
static gboolean steadyflow_core_util_first_run = TRUE;
static gboolean steadyflow_core_util_local_install;
static gboolean steadyflow_core_util_local_install = FALSE;
static SteadyflowCoreUtil* steadyflow_core_util_instance;
static SteadyflowCoreUtil* steadyflow_core_util_instance = NULL;

VALA_EXTERN GType steadyflow_core_util_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SteadyflowCoreUtil, g_object_unref)
static SteadyflowCoreUtil* steadyflow_core_util_new (void);
static SteadyflowCoreUtil* steadyflow_core_util_construct (GType object_type);
VALA_EXTERN gboolean steadyflow_core_util_is_local_install (void);
static gchar* steadyflow_core_util_get_data_dir (void);
VALA_EXTERN gchar* steadyflow_core_util_resolve_path (const gchar* rel_path);
VALA_EXTERN gboolean steadyflow_core_util_is_valid_url (const gchar* url);
VALA_EXTERN void steadyflow_core_util_fatal_error (GError* e,
                                       const gchar* message);
VALA_EXTERN SteadyflowCoreUtil* steadyflow_core_util_get_signaller (void);
static void g_cclosure_user_marshal_VOID__BOXED_STRING (GClosure * closure,
                                                 GValue * return_value,
                                                 guint n_param_values,
                                                 const GValue * param_values,
                                                 gpointer invocation_hint,
                                                 gpointer marshal_data);
static void steadyflow_core_util_finalize (GObject * obj);
static GType steadyflow_core_util_get_type_once (void);
static void _vala_steadyflow_core_util_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);

static SteadyflowCoreUtil*
steadyflow_core_util_construct (GType object_type)
{
	SteadyflowCoreUtil * self = NULL;
	self = (SteadyflowCoreUtil*) g_object_new (object_type, NULL);
	return self;
}

static SteadyflowCoreUtil*
steadyflow_core_util_new (void)
{
	return steadyflow_core_util_construct (STEADYFLOW_CORE_TYPE_UTIL);
}

gboolean
steadyflow_core_util_is_local_install (void)
{
	gboolean result;
	if (steadyflow_core_util_first_run) {
		steadyflow_core_util_local_install = g_file_test ("Steadyflow/Application.vala", G_FILE_TEST_EXISTS);
		steadyflow_core_util_first_run = FALSE;
	}
	result = steadyflow_core_util_local_install;
	return result;
}

static gchar*
steadyflow_core_util_get_data_dir (void)
{
	gchar* _tmp1_;
	gchar* result;
	if (steadyflow_core_util_is_local_install ()) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("data");
		result = _tmp0_;
		return result;
	}
	_tmp1_ = g_strdup (CMAKE_INSTALL_APP_DATA_DIR);
	result = _tmp1_;
	return result;
}

gchar*
steadyflow_core_util_resolve_path (const gchar* rel_path)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (rel_path != NULL, NULL);
	_tmp0_ = steadyflow_core_util_get_data_dir ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_build_filename (_tmp1_, rel_path, NULL);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	result = _tmp3_;
	return result;
}

gboolean
steadyflow_core_util_is_valid_url (const gchar* url)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_;
	gboolean result;
	g_return_val_if_fail (url != NULL, FALSE);
	_tmp0_ = g_uri_parse_scheme (url);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_ != NULL;
	_g_free0 (_tmp1_);
	result = _tmp2_;
	return result;
}

void
steadyflow_core_util_fatal_error (GError* e,
                                  const gchar* message)
{
	SteadyflowCoreUtil* _tmp0_;
	SteadyflowCoreUtil* _tmp1_;
	g_return_if_fail (e != NULL);
	_tmp0_ = steadyflow_core_util_get_signaller ();
	_tmp1_ = _tmp0_;
	g_signal_emit (_tmp1_, steadyflow_core_util_signals[STEADYFLOW_CORE_UTIL_FATAL_ERROR_SIG_SIGNAL], 0, e, message);
}

SteadyflowCoreUtil*
steadyflow_core_util_get_signaller (void)
{
	SteadyflowCoreUtil* result;
	SteadyflowCoreUtil* _tmp0_;
	SteadyflowCoreUtil* _tmp2_;
	_tmp0_ = steadyflow_core_util_instance;
	if (_tmp0_ == NULL) {
		SteadyflowCoreUtil* _tmp1_;
		_tmp1_ = steadyflow_core_util_new ();
		_g_object_unref0 (steadyflow_core_util_instance);
		steadyflow_core_util_instance = _tmp1_;
	}
	_tmp2_ = steadyflow_core_util_instance;
	result = _tmp2_;
	return result;
}

static void
g_cclosure_user_marshal_VOID__BOXED_STRING (GClosure * closure,
                                            GValue * return_value,
                                            guint n_param_values,
                                            const GValue * param_values,
                                            gpointer invocation_hint,
                                            gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__BOXED_STRING) (gpointer data1, gpointer arg_1, const char* arg_2, gpointer data2);
	register GMarshalFunc_VOID__BOXED_STRING callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__BOXED_STRING) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_boxed (param_values + 1), g_value_get_string (param_values + 2), data2);
}

static void
steadyflow_core_util_class_init (SteadyflowCoreUtilClass * klass,
                                 gpointer klass_data)
{
	steadyflow_core_util_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_steadyflow_core_util_get_property;
	G_OBJECT_CLASS (klass)->finalize = steadyflow_core_util_finalize;
	steadyflow_core_util_signals[STEADYFLOW_CORE_UTIL_FATAL_ERROR_SIG_SIGNAL] = g_signal_new ("fatal-error-sig", STEADYFLOW_CORE_TYPE_UTIL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__BOXED_STRING, G_TYPE_NONE, 2, G_TYPE_ERROR, G_TYPE_STRING);
}

static void
steadyflow_core_util_instance_init (SteadyflowCoreUtil * self,
                                    gpointer klass)
{
}

static void
steadyflow_core_util_finalize (GObject * obj)
{
	SteadyflowCoreUtil * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, STEADYFLOW_CORE_TYPE_UTIL, SteadyflowCoreUtil);
	G_OBJECT_CLASS (steadyflow_core_util_parent_class)->finalize (obj);
}

static GType
steadyflow_core_util_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SteadyflowCoreUtilClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) steadyflow_core_util_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SteadyflowCoreUtil), 0, (GInstanceInitFunc) steadyflow_core_util_instance_init, NULL };
	GType steadyflow_core_util_type_id;
	steadyflow_core_util_type_id = g_type_register_static (G_TYPE_OBJECT, "SteadyflowCoreUtil", &g_define_type_info, 0);
	return steadyflow_core_util_type_id;
}

GType
steadyflow_core_util_get_type (void)
{
	static volatile gsize steadyflow_core_util_type_id__once = 0;
	if (g_once_init_enter (&steadyflow_core_util_type_id__once)) {
		GType steadyflow_core_util_type_id;
		steadyflow_core_util_type_id = steadyflow_core_util_get_type_once ();
		g_once_init_leave (&steadyflow_core_util_type_id__once, steadyflow_core_util_type_id);
	}
	return steadyflow_core_util_type_id__once;
}

static void
_vala_steadyflow_core_util_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	SteadyflowCoreUtil * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, STEADYFLOW_CORE_TYPE_UTIL, SteadyflowCoreUtil);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

