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

/*
 * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>.
 * Copyright (C) 2008,2010 Nokia Corporation.
 *
 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
 *
 * This file is part of Rygel.
 *
 * Rygel is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Rygel 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "rygel-localsearch.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include "rygel-server.h"
#include <gee.h>

#define RYGEL_LOCAL_SEARCH_NEW_ADDED_PREDICATE "nrl:added"
#define RYGEL_LOCAL_SEARCH_NEW_ADDED_VARIABLE "?added"
#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

enum  {
	RYGEL_LOCAL_SEARCH_NEW_0_PROPERTY,
	RYGEL_LOCAL_SEARCH_NEW_NUM_PROPERTIES
};
static GParamSpec* rygel_local_search_new_properties[RYGEL_LOCAL_SEARCH_NEW_NUM_PROPERTIES];
#define _rygel_local_search_query_triplet_unref0(var) ((var == NULL) ? NULL : (var = (rygel_local_search_query_triplet_unref (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer rygel_local_search_new_parent_class = NULL;

static GType rygel_local_search_new_get_type_once (void);

RygelLocalSearchNew*
rygel_local_search_new_construct (GType object_type,
                                  RygelMediaContainer* parent,
                                  RygelLocalSearchItemFactory* item_factory)
{
	RygelLocalSearchNew * self = NULL;
	RygelLocalSearchQueryTriplets* triplets = NULL;
	RygelLocalSearchQueryTriplets* _tmp0_;
	const gchar* _tmp1_;
	RygelLocalSearchQueryTriplet* _tmp2_;
	RygelLocalSearchQueryTriplet* _tmp3_;
	RygelLocalSearchQueryTriplet* _tmp4_;
	RygelLocalSearchQueryTriplet* _tmp5_;
	GDateTime* now = NULL;
	GDateTime* _tmp6_;
	GDateTime* _tmp7_;
	GDateTime* _tmp8_;
	gchar* three_days_ago = NULL;
	GDateTime* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	GeeArrayList* filters = NULL;
	GeeArrayList* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	g_return_val_if_fail (parent != NULL, NULL);
	g_return_val_if_fail (item_factory != NULL, NULL);
	_tmp0_ = rygel_local_search_query_triplets_new ();
	triplets = _tmp0_;
	_tmp1_ = item_factory->category;
	_tmp2_ = rygel_local_search_query_triplet_new (RYGEL_LOCAL_SEARCH_SELECTION_QUERY_ITEM_VARIABLE, "a", _tmp1_);
	_tmp3_ = _tmp2_;
	gee_abstract_collection_add ((GeeAbstractCollection*) triplets, _tmp3_);
	_rygel_local_search_query_triplet_unref0 (_tmp3_);
	_tmp4_ = rygel_local_search_query_triplet_new (RYGEL_LOCAL_SEARCH_SELECTION_QUERY_ITEM_VARIABLE, RYGEL_LOCAL_SEARCH_NEW_ADDED_PREDICATE, RYGEL_LOCAL_SEARCH_NEW_ADDED_VARIABLE);
	_tmp5_ = _tmp4_;
	gee_abstract_collection_add ((GeeAbstractCollection*) triplets, _tmp5_);
	_rygel_local_search_query_triplet_unref0 (_tmp5_);
	_tmp6_ = g_date_time_new_now_utc ();
	now = _tmp6_;
	_tmp7_ = now;
	_tmp8_ = g_date_time_add_days (_tmp7_, -3);
	_g_date_time_unref0 (now);
	now = _tmp8_;
	_tmp9_ = now;
	_tmp10_ = g_date_time_format (_tmp9_, "%Y-%m-%dT%H:%M:%S");
	_tmp11_ = _tmp10_;
	_tmp12_ = g_strdup_printf ("%sZ", _tmp11_);
	_tmp13_ = _tmp12_;
	_g_free0 (_tmp11_);
	three_days_ago = _tmp13_;
	_tmp14_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	filters = _tmp14_;
	_tmp15_ = g_strconcat (RYGEL_LOCAL_SEARCH_NEW_ADDED_VARIABLE " > \"", three_days_ago, NULL);
	_tmp16_ = _tmp15_;
	_tmp17_ = g_strconcat (_tmp16_, "\"^^xsd:dateTime", NULL);
	_tmp18_ = _tmp17_;
	gee_abstract_collection_add ((GeeAbstractCollection*) filters, _tmp18_);
	_g_free0 (_tmp18_);
	_g_free0 (_tmp16_);
	_tmp19_ = rygel_media_object_get_id ((RygelMediaObject*) parent);
	_tmp20_ = _tmp19_;
	_tmp21_ = g_strconcat (_tmp20_, "New", NULL);
	_tmp22_ = _tmp21_;
	self = (RygelLocalSearchNew*) rygel_local_search_search_container_construct (object_type, _tmp22_, parent, "New", item_factory, triplets, filters);
	_g_free0 (_tmp22_);
	_g_object_unref0 (filters);
	_g_free0 (three_days_ago);
	_g_date_time_unref0 (now);
	_g_object_unref0 (triplets);
	return self;
}

RygelLocalSearchNew*
rygel_local_search_new_new (RygelMediaContainer* parent,
                            RygelLocalSearchItemFactory* item_factory)
{
	return rygel_local_search_new_construct (RYGEL_LOCAL_SEARCH_TYPE_NEW, parent, item_factory);
}

static void
rygel_local_search_new_class_init (RygelLocalSearchNewClass * klass,
                                   gpointer klass_data)
{
	rygel_local_search_new_parent_class = g_type_class_peek_parent (klass);
}

static void
rygel_local_search_new_instance_init (RygelLocalSearchNew * self,
                                      gpointer klass)
{
}

/**
 * A container listing all newly (<3 days) added items.
 */
 G_GNUC_NO_INLINE static GType
rygel_local_search_new_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelLocalSearchNewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_local_search_new_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelLocalSearchNew), 0, (GInstanceInitFunc) rygel_local_search_new_instance_init, NULL };
	GType rygel_local_search_new_type_id;
	rygel_local_search_new_type_id = g_type_register_static (RYGEL_LOCAL_SEARCH_TYPE_SEARCH_CONTAINER, "RygelLocalSearchNew", &g_define_type_info, 0);
	return rygel_local_search_new_type_id;
}

GType
rygel_local_search_new_get_type (void)
{
	static volatile gsize rygel_local_search_new_type_id__once = 0;
	if (g_once_init_enter (&rygel_local_search_new_type_id__once)) {
		GType rygel_local_search_new_type_id;
		rygel_local_search_new_type_id = rygel_local_search_new_get_type_once ();
		g_once_init_leave (&rygel_local_search_new_type_id__once, rygel_local_search_new_type_id);
	}
	return rygel_local_search_new_type_id__once;
}

