/* rygel-dlna-available-seek-request.c generated by valac 0.56.19, the Vala compiler
 * generated from rygel-dlna-available-seek-request.vala, do not modify */

/*
 * Copyright (C) 2014  Cable Television Laboratories, Inc.
 * Contact: http://www.cablelabs.com/
 *
 * Author: Craig Pratt <craig@ecaspia.com>
 *
 * 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-server.h"
#include <libsoup/soup.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.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

enum  {
	RYGEL_DLNA_AVAILABLE_SEEK_RANGE_REQUEST_0_PROPERTY,
	RYGEL_DLNA_AVAILABLE_SEEK_RANGE_REQUEST_NUM_PROPERTIES
};
static GParamSpec* rygel_dlna_available_seek_range_request_properties[RYGEL_DLNA_AVAILABLE_SEEK_RANGE_REQUEST_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)))

static gpointer rygel_dlna_available_seek_range_request_parent_class = NULL;

VALA_EXTERN RygelDLNAAvailableSeekRangeRequest* rygel_dlna_available_seek_range_request_new (SoupMessage* message,
                                                                                 RygelHTTPGetHandler* handler,
                                                                                 GError** error);
VALA_EXTERN RygelDLNAAvailableSeekRangeRequest* rygel_dlna_available_seek_range_request_construct (GType object_type,
                                                                                       SoupMessage* message,
                                                                                       RygelHTTPGetHandler* handler,
                                                                                       GError** error);
static GType rygel_dlna_available_seek_range_request_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

/**
     * Create a DLNAAvailableSeekRangeRequest corresponding with a HTTPGet
     * that contains a getAvailableSeekRange.dlna.org header value.
     *
     * @param request The HTTP GET/HEAD request
     */
static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

RygelDLNAAvailableSeekRangeRequest*
rygel_dlna_available_seek_range_request_construct (GType object_type,
                                                   SoupMessage* message,
                                                   RygelHTTPGetHandler* handler,
                                                   GError** error)
{
	RygelDLNAAvailableSeekRangeRequest * self = NULL;
	gchar* params = NULL;
	SoupMessageHeaders* _tmp0_;
	SoupMessageHeaders* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gboolean _tmp9_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (message != NULL, NULL);
	g_return_val_if_fail (handler != NULL, NULL);
	self = (RygelDLNAAvailableSeekRangeRequest*) rygel_http_seek_request_construct (object_type);
	_tmp0_ = soup_message_get_request_headers (message);
	_tmp1_ = _tmp0_;
	_tmp2_ = soup_message_headers_get_one (_tmp1_, RYGEL_DLNA_AVAILABLE_SEEK_RANGE_REQUEST_GET_AVAILABLE_SEEK_RANGE_HEADER);
	_tmp3_ = g_strdup (_tmp2_);
	params = _tmp3_;
	_tmp4_ = params;
	if (_tmp4_ == NULL) {
		GError* _tmp5_;
		_tmp5_ = g_error_new (RYGEL_HTTP_SEEK_REQUEST_ERROR, RYGEL_HTTP_SEEK_REQUEST_ERROR_BAD_REQUEST, "%s not present", RYGEL_DLNA_AVAILABLE_SEEK_RANGE_REQUEST_GET_AVAILABLE_SEEK_RANGE_HEADER);
		_inner_error0_ = _tmp5_;
		if (_inner_error0_->domain == RYGEL_HTTP_SEEK_REQUEST_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (params);
			_g_object_unref0 (self);
			return NULL;
		} else {
			_g_free0 (params);
			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 NULL;
		}
	}
	_tmp6_ = params;
	_tmp7_ = string_strip (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_strcmp0 (_tmp8_, "1") != 0;
	_g_free0 (_tmp8_);
	if (_tmp9_) {
		const gchar* _tmp10_;
		GError* _tmp11_;
		_tmp10_ = params;
		_tmp11_ = g_error_new (RYGEL_HTTP_SEEK_REQUEST_ERROR, RYGEL_HTTP_SEEK_REQUEST_ERROR_BAD_REQUEST, "%s != 1 (found \"%s\")", RYGEL_DLNA_AVAILABLE_SEEK_RANGE_REQUEST_GET_AVAILABLE_SEEK_RANGE_HEADER, _tmp10_);
		_inner_error0_ = _tmp11_;
		if (_inner_error0_->domain == RYGEL_HTTP_SEEK_REQUEST_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (params);
			_g_object_unref0 (self);
			return NULL;
		} else {
			_g_free0 (params);
			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 NULL;
		}
	}
	_g_free0 (params);
	return self;
}

RygelDLNAAvailableSeekRangeRequest*
rygel_dlna_available_seek_range_request_new (SoupMessage* message,
                                             RygelHTTPGetHandler* handler,
                                             GError** error)
{
	return rygel_dlna_available_seek_range_request_construct (RYGEL_TYPE_DLNA_AVAILABLE_SEEK_RANGE_REQUEST, message, handler, error);
}

/**
     * Return true if getAvailableSeekRange is supported.
     */
gboolean
rygel_dlna_available_seek_range_request_supported (SoupMessage* message,
                                                   RygelHTTPGetHandler* handler)
{
	gboolean result;
	g_return_val_if_fail (message != NULL, FALSE);
	g_return_val_if_fail (handler != NULL, FALSE);
	result = TRUE;
	return result;
}

/**
     * Return true of the HTTPGet contains a getAvailableSeekRange request.
     */
gboolean
rygel_dlna_available_seek_range_request_requested (SoupMessage* message)
{
	SoupMessageHeaders* _tmp0_;
	SoupMessageHeaders* _tmp1_;
	const gchar* _tmp2_;
	gboolean result;
	g_return_val_if_fail (message != NULL, FALSE);
	_tmp0_ = soup_message_get_request_headers (message);
	_tmp1_ = _tmp0_;
	_tmp2_ = soup_message_headers_get_one (_tmp1_, RYGEL_DLNA_AVAILABLE_SEEK_RANGE_REQUEST_GET_AVAILABLE_SEEK_RANGE_HEADER);
	result = _tmp2_ != NULL;
	return result;
}

static void
rygel_dlna_available_seek_range_request_class_init (RygelDLNAAvailableSeekRangeRequestClass * klass,
                                                    gpointer klass_data)
{
	rygel_dlna_available_seek_range_request_parent_class = g_type_class_peek_parent (klass);
}

static void
rygel_dlna_available_seek_range_request_instance_init (RygelDLNAAvailableSeekRangeRequest * self,
                                                       gpointer klass)
{
}

/**
 * This class represents a DLNA getAvailableSeekRange request.
 *
 * A getAvailableSeekRange request can only have a single parameter: "1"
 */
 G_GNUC_NO_INLINE static GType
rygel_dlna_available_seek_range_request_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelDLNAAvailableSeekRangeRequestClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_dlna_available_seek_range_request_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelDLNAAvailableSeekRangeRequest), 0, (GInstanceInitFunc) rygel_dlna_available_seek_range_request_instance_init, NULL };
	GType rygel_dlna_available_seek_range_request_type_id;
	rygel_dlna_available_seek_range_request_type_id = g_type_register_static (RYGEL_TYPE_HTTP_SEEK_REQUEST, "RygelDLNAAvailableSeekRangeRequest", &g_define_type_info, 0);
	return rygel_dlna_available_seek_range_request_type_id;
}

GType
rygel_dlna_available_seek_range_request_get_type (void)
{
	static volatile gsize rygel_dlna_available_seek_range_request_type_id__once = 0;
	if (g_once_init_enter (&rygel_dlna_available_seek_range_request_type_id__once)) {
		GType rygel_dlna_available_seek_range_request_type_id;
		rygel_dlna_available_seek_range_request_type_id = rygel_dlna_available_seek_range_request_get_type_once ();
		g_once_init_leave (&rygel_dlna_available_seek_range_request_type_id__once, rygel_dlna_available_seek_range_request_type_id);
	}
	return rygel_dlna_available_seek_range_request_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

