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

/* UserActivity.vala
 *
 * Copyright 2020 Dylan McCall <dylan@dylanmccall.ca>
 *
 * 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/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "daemon.h"
#include <json-glib/json-glib.h>
#include <glib.h>
#include <string.h>
#include <stdlib.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

#define _g_free0(var) (var = (g_free (var), NULL))

JsonObject*
break_timer_daemon_activity_user_activity_serialize (BreakTimerDaemonActivityUserActivity *self)
{
	JsonObject* json_root = NULL;
	JsonObject* _tmp0_;
	JsonObject* result;
	_tmp0_ = json_object_new ();
	json_root = _tmp0_;
	json_object_set_int_member (json_root, "type", (gint64) ((gint) (*self).type));
	json_object_set_int_member (json_root, "idle_time", (*self).idle_time);
	json_object_set_int_member (json_root, "time_since_active", (*self).time_since_active);
	json_object_set_int_member (json_root, "time_correction", (*self).time_correction);
	result = json_root;
	return result;
}

void
break_timer_daemon_activity_user_activity_deserialize (JsonObject** json_root,
                                                       BreakTimerDaemonActivityUserActivity* result)
{
	BreakTimerDaemonActivityUserActivity _tmp0_ = {0};
	g_return_if_fail (*json_root != NULL);
	memset (&_tmp0_, 0, sizeof (BreakTimerDaemonActivityUserActivity));
	_tmp0_.type = (BreakTimerDaemonActivityActivityType) json_object_get_int_member (*json_root, "type");
	_tmp0_.idle_time = json_object_get_int_member (*json_root, "idle_time");
	_tmp0_.time_since_active = json_object_get_int_member (*json_root, "time_since_active");
	_tmp0_.time_correction = json_object_get_int_member (*json_root, "time_correction");
	*result = _tmp0_;
	return;
}

gboolean
break_timer_daemon_activity_user_activity_is_active (BreakTimerDaemonActivityUserActivity *self)
{
	gboolean result;
	result = (*self).type > BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_NONE;
	return result;
}

gchar*
break_timer_daemon_activity_user_activity_to_string (BreakTimerDaemonActivityUserActivity *self)
{
	static const char format[] = "%s (" "idle_time: %" G_GINT64_FORMAT ", " "time_since_active %" G_GINT64_FORMAT ", " "time_correction: %" G_GINT64_FORMAT ")";
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	_tmp0_ = break_timer_daemon_activity_activity_type_to_string ((*self).type);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup_printf (format, _tmp1_, (*self).idle_time, (*self).time_since_active, (*self).time_correction);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	result = _tmp3_;
	return result;
}

BreakTimerDaemonActivityUserActivity*
break_timer_daemon_activity_user_activity_dup (const BreakTimerDaemonActivityUserActivity* self)
{
	BreakTimerDaemonActivityUserActivity* dup;
	dup = g_new0 (BreakTimerDaemonActivityUserActivity, 1);
	memcpy (dup, self, sizeof (BreakTimerDaemonActivityUserActivity));
	return dup;
}

void
break_timer_daemon_activity_user_activity_free (BreakTimerDaemonActivityUserActivity* self)
{
	g_free (self);
}

static GType
break_timer_daemon_activity_user_activity_get_type_once (void)
{
	GType break_timer_daemon_activity_user_activity_type_id;
	break_timer_daemon_activity_user_activity_type_id = g_boxed_type_register_static ("BreakTimerDaemonActivityUserActivity", (GBoxedCopyFunc) break_timer_daemon_activity_user_activity_dup, (GBoxedFreeFunc) break_timer_daemon_activity_user_activity_free);
	return break_timer_daemon_activity_user_activity_type_id;
}

GType
break_timer_daemon_activity_user_activity_get_type (void)
{
	static volatile gsize break_timer_daemon_activity_user_activity_type_id__once = 0;
	if (g_once_init_enter (&break_timer_daemon_activity_user_activity_type_id__once)) {
		GType break_timer_daemon_activity_user_activity_type_id;
		break_timer_daemon_activity_user_activity_type_id = break_timer_daemon_activity_user_activity_get_type_once ();
		g_once_init_leave (&break_timer_daemon_activity_user_activity_type_id__once, break_timer_daemon_activity_user_activity_type_id);
	}
	return break_timer_daemon_activity_user_activity_type_id__once;
}

gchar*
break_timer_daemon_activity_activity_type_to_string (BreakTimerDaemonActivityActivityType self)
{
	gchar* result;
	switch (self) {
		case BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_SLEEP:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup ("Sleep");
			result = _tmp0_;
			return result;
		}
		case BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_LOCKED:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("Locked");
			result = _tmp1_;
			return result;
		}
		case BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_NONE:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup ("None");
			result = _tmp2_;
			return result;
		}
		case BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_INPUT:
		{
			gchar* _tmp3_;
			_tmp3_ = g_strdup ("Input");
			result = _tmp3_;
			return result;
		}
		case BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_UNLOCK:
		{
			gchar* _tmp4_;
			_tmp4_ = g_strdup ("Unlock");
			result = _tmp4_;
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

static GType
break_timer_daemon_activity_activity_type_get_type_once (void)
{
	static const GEnumValue values[] = {{BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_SLEEP, "BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_SLEEP", "sleep"}, {BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_LOCKED, "BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_LOCKED", "locked"}, {BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_NONE, "BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_NONE", "none"}, {BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_INPUT, "BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_INPUT", "input"}, {BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_UNLOCK, "BREAK_TIMER_DAEMON_ACTIVITY_ACTIVITY_TYPE_UNLOCK", "unlock"}, {0, NULL, NULL}};
	GType break_timer_daemon_activity_activity_type_type_id;
	break_timer_daemon_activity_activity_type_type_id = g_enum_register_static ("BreakTimerDaemonActivityActivityType", values);
	return break_timer_daemon_activity_activity_type_type_id;
}

GType
break_timer_daemon_activity_activity_type_get_type (void)
{
	static volatile gsize break_timer_daemon_activity_activity_type_type_id__once = 0;
	if (g_once_init_enter (&break_timer_daemon_activity_activity_type_type_id__once)) {
		GType break_timer_daemon_activity_activity_type_type_id;
		break_timer_daemon_activity_activity_type_type_id = break_timer_daemon_activity_activity_type_get_type_once ();
		g_once_init_leave (&break_timer_daemon_activity_activity_type_type_id__once, break_timer_daemon_activity_activity_type_type_id);
	}
	return break_timer_daemon_activity_activity_type_type_id__once;
}

