/* rygel-http-server.c generated by valac 0.31.1.6-4f062, the Vala compiler
 * generated from rygel-http-server.vala, do not modify */

/*
 * Copyright (C) 2008, 2009 Nokia Corporation.
 * Copyright (C) 2012 Intel Corporation.
 * Copyright (C) 2013 Cable Television Laboratories, Inc.
 *
 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
 *                               <zeeshan.ali@nokia.com>
 *         Jens Georg <jensg@openismus.com>
 *         Doug Galligan <doug@sentosatech.com>
 *         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 <glib.h>
#include <glib-object.h>
#include <rygel-core.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <libgupnp-av/gupnp-av.h>
#include <libgupnp/gupnp.h>
#include <gio/gio.h>
#include <config.h>
#include <libgssdp/gssdp.h>
#include <libsoup/soup.h>


#define RYGEL_TYPE_HTTP_SERVER (rygel_http_server_get_type ())
#define RYGEL_HTTP_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_HTTP_SERVER, RygelHTTPServer))
#define RYGEL_HTTP_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_HTTP_SERVER, RygelHTTPServerClass))
#define RYGEL_IS_HTTP_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_HTTP_SERVER))
#define RYGEL_IS_HTTP_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_HTTP_SERVER))
#define RYGEL_HTTP_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_HTTP_SERVER, RygelHTTPServerClass))

typedef struct _RygelHTTPServer RygelHTTPServer;
typedef struct _RygelHTTPServerClass RygelHTTPServerClass;
typedef struct _RygelHTTPServerPrivate RygelHTTPServerPrivate;

#define RYGEL_TYPE_MEDIA_OBJECT (rygel_media_object_get_type ())
#define RYGEL_MEDIA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_OBJECT, RygelMediaObject))
#define RYGEL_MEDIA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MEDIA_OBJECT, RygelMediaObjectClass))
#define RYGEL_IS_MEDIA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_OBJECT))
#define RYGEL_IS_MEDIA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MEDIA_OBJECT))
#define RYGEL_MEDIA_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MEDIA_OBJECT, RygelMediaObjectClass))

typedef struct _RygelMediaObject RygelMediaObject;
typedef struct _RygelMediaObjectClass RygelMediaObjectClass;

#define RYGEL_TYPE_MEDIA_CONTAINER (rygel_media_container_get_type ())
#define RYGEL_MEDIA_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_CONTAINER, RygelMediaContainer))
#define RYGEL_MEDIA_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MEDIA_CONTAINER, RygelMediaContainerClass))
#define RYGEL_IS_MEDIA_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_CONTAINER))
#define RYGEL_IS_MEDIA_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MEDIA_CONTAINER))
#define RYGEL_MEDIA_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MEDIA_CONTAINER, RygelMediaContainerClass))

typedef struct _RygelMediaContainer RygelMediaContainer;
typedef struct _RygelMediaContainerClass RygelMediaContainerClass;

#define RYGEL_TYPE_HTTP_REQUEST (rygel_http_request_get_type ())
#define RYGEL_HTTP_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_HTTP_REQUEST, RygelHTTPRequest))
#define RYGEL_HTTP_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_HTTP_REQUEST, RygelHTTPRequestClass))
#define RYGEL_IS_HTTP_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_HTTP_REQUEST))
#define RYGEL_IS_HTTP_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_HTTP_REQUEST))
#define RYGEL_HTTP_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_HTTP_REQUEST, RygelHTTPRequestClass))

typedef struct _RygelHTTPRequest RygelHTTPRequest;
typedef struct _RygelHTTPRequestClass RygelHTTPRequestClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))

#define RYGEL_TYPE_CONTENT_DIRECTORY (rygel_content_directory_get_type ())
#define RYGEL_CONTENT_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_CONTENT_DIRECTORY, RygelContentDirectory))
#define RYGEL_CONTENT_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_CONTENT_DIRECTORY, RygelContentDirectoryClass))
#define RYGEL_IS_CONTENT_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_CONTENT_DIRECTORY))
#define RYGEL_IS_CONTENT_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_CONTENT_DIRECTORY))
#define RYGEL_CONTENT_DIRECTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_CONTENT_DIRECTORY, RygelContentDirectoryClass))

typedef struct _RygelContentDirectory RygelContentDirectory;
typedef struct _RygelContentDirectoryClass RygelContentDirectoryClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _RygelContentDirectoryPrivate RygelContentDirectoryPrivate;
typedef struct _RygelHttpServerRunData RygelHttpServerRunData;

#define RYGEL_TYPE_MEDIA_RESOURCE (rygel_media_resource_get_type ())
#define RYGEL_MEDIA_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_RESOURCE, RygelMediaResource))
#define RYGEL_MEDIA_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MEDIA_RESOURCE, RygelMediaResourceClass))
#define RYGEL_IS_MEDIA_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_RESOURCE))
#define RYGEL_IS_MEDIA_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MEDIA_RESOURCE))
#define RYGEL_MEDIA_RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MEDIA_RESOURCE, RygelMediaResourceClass))

typedef struct _RygelMediaResource RygelMediaResource;
typedef struct _RygelMediaResourceClass RygelMediaResourceClass;

#define RYGEL_TYPE_HTTP_ITEM_URI (rygel_http_item_uri_get_type ())
#define RYGEL_HTTP_ITEM_URI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_HTTP_ITEM_URI, RygelHTTPItemURI))
#define RYGEL_HTTP_ITEM_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_HTTP_ITEM_URI, RygelHTTPItemURIClass))
#define RYGEL_IS_HTTP_ITEM_URI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_HTTP_ITEM_URI))
#define RYGEL_IS_HTTP_ITEM_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_HTTP_ITEM_URI))
#define RYGEL_HTTP_ITEM_URI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_HTTP_ITEM_URI, RygelHTTPItemURIClass))

typedef struct _RygelHTTPItemURI RygelHTTPItemURI;
typedef struct _RygelHTTPItemURIClass RygelHTTPItemURIClass;
typedef struct _RygelHTTPRequestPrivate RygelHTTPRequestPrivate;

#define RYGEL_TYPE_CLIENT_HACKS (rygel_client_hacks_get_type ())
#define RYGEL_CLIENT_HACKS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_CLIENT_HACKS, RygelClientHacks))
#define RYGEL_CLIENT_HACKS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_CLIENT_HACKS, RygelClientHacksClass))
#define RYGEL_IS_CLIENT_HACKS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_CLIENT_HACKS))
#define RYGEL_IS_CLIENT_HACKS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_CLIENT_HACKS))
#define RYGEL_CLIENT_HACKS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_CLIENT_HACKS, RygelClientHacksClass))

typedef struct _RygelClientHacks RygelClientHacks;
typedef struct _RygelClientHacksClass RygelClientHacksClass;

#define RYGEL_TYPE_HTTP_GET (rygel_http_get_get_type ())
#define RYGEL_HTTP_GET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_HTTP_GET, RygelHTTPGet))
#define RYGEL_HTTP_GET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_HTTP_GET, RygelHTTPGetClass))
#define RYGEL_IS_HTTP_GET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_HTTP_GET))
#define RYGEL_IS_HTTP_GET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_HTTP_GET))
#define RYGEL_HTTP_GET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_HTTP_GET, RygelHTTPGetClass))

typedef struct _RygelHTTPGet RygelHTTPGet;
typedef struct _RygelHTTPGetClass RygelHTTPGetClass;

#define RYGEL_TYPE_HTTP_POST (rygel_http_post_get_type ())
#define RYGEL_HTTP_POST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_HTTP_POST, RygelHTTPPost))
#define RYGEL_HTTP_POST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_HTTP_POST, RygelHTTPPostClass))
#define RYGEL_IS_HTTP_POST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_HTTP_POST))
#define RYGEL_IS_HTTP_POST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_HTTP_POST))
#define RYGEL_HTTP_POST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_HTTP_POST, RygelHTTPPostClass))

typedef struct _RygelHTTPPost RygelHTTPPost;
typedef struct _RygelHTTPPostClass RygelHTTPPostClass;

struct _RygelHTTPServer {
	GObject parent_instance;
	RygelHTTPServerPrivate * priv;
	RygelMediaContainer* root_container;
	GUPnPContext* context;
	GHashTable* replacements;
};

struct _RygelHTTPServerClass {
	GObjectClass parent_class;
	gchar* (*get_protocol) (RygelHTTPServer* self);
	GeeArrayList* (*get_protocol_info) (RygelHTTPServer* self);
};

struct _RygelHTTPServerPrivate {
	gchar* _path_root;
	gchar* _server_name;
	GeeArrayList* requests;
	gboolean locally_hosted;
	GCancellable* _cancellable;
};

struct _RygelContentDirectory {
	GUPnPService parent_instance;
	RygelContentDirectoryPrivate * priv;
	gchar* feature_list;
	RygelHTTPServer* http_server;
	RygelMediaContainer* root_container;
	GCancellable* cancellable;
	guint32 system_update_id;
};

struct _RygelContentDirectoryClass {
	GUPnPServiceClass parent_class;
};

struct _RygelHttpServerRunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	RygelHTTPServer* self;
	GUPnPContext* _tmp0_;
	const gchar* _tmp1_;
	GUPnPContext* _tmp2_;
	SoupServer* _tmp3_;
	SoupServer* _tmp4_;
	GUPnPContext* _tmp5_;
	SoupServer* _tmp6_;
	SoupServer* _tmp7_;
	GCancellable* _tmp8_;
	GCancellable* _tmp9_;
	GCancellable* _tmp10_;
	GCancellable* _tmp11_;
};

struct _RygelHTTPRequest {
	GObject parent_instance;
	RygelHTTPRequestPrivate * priv;
	RygelHTTPServer* http_server;
	SoupServer* server;
	SoupMessage* msg;
	RygelHTTPItemURI* uri;
	RygelMediaObject* object;
	RygelClientHacks* hack;
};

struct _RygelHTTPRequestClass {
	GObjectClass parent_class;
	void (*handle) (RygelHTTPRequest* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*handle_finish) (RygelHTTPRequest* self, GAsyncResult* _res_, GError** error);
	void (*find_item) (RygelHTTPRequest* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*find_item_finish) (RygelHTTPRequest* self, GAsyncResult* _res_, GError** error);
};


static gpointer rygel_http_server_parent_class = NULL;
static RygelStateMachineIface* rygel_http_server_rygel_state_machine_parent_iface = NULL;

GType rygel_http_server_get_type (void) G_GNUC_CONST;
GType rygel_media_object_get_type (void) G_GNUC_CONST;
GType rygel_media_container_get_type (void) G_GNUC_CONST;
GType rygel_http_request_get_type (void) G_GNUC_CONST;
#define RYGEL_HTTP_SERVER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_TYPE_HTTP_SERVER, RygelHTTPServerPrivate))
enum  {
	RYGEL_HTTP_SERVER_DUMMY_PROPERTY,
	RYGEL_HTTP_SERVER_PATH_ROOT,
	RYGEL_HTTP_SERVER_SERVER_NAME,
	RYGEL_HTTP_SERVER_CANCELLABLE
};
#define RYGEL_HTTP_SERVER_SERVER_TEMPLATE "%s/%s %s/%s DLNA/1.51 UPnP/1.0"
GType rygel_content_directory_get_type (void) G_GNUC_CONST;
RygelHTTPServer* rygel_http_server_new (RygelContentDirectory* content_dir, const gchar* name);
RygelHTTPServer* rygel_http_server_construct (GType object_type, RygelContentDirectory* content_dir, const gchar* name);
void rygel_http_server_set_server_name (RygelHTTPServer* self, const gchar* value);
static void rygel_http_server_set_path_root (RygelHTTPServer* self, const gchar* value);
static void _g_free0_ (gpointer var);
static void rygel_http_server_real_run_data_free (gpointer _data);
static void rygel_http_server_real_run (RygelStateMachine* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean rygel_http_server_real_run_co (RygelHttpServerRunData* _data_);
const gchar* rygel_http_server_get_path_root (RygelHTTPServer* self);
static void rygel_http_server_server_handler (RygelHTTPServer* self, SoupServer* server, SoupMessage* msg, const gchar* server_path, GHashTable* query, SoupClientContext* soup_client);
static void _rygel_http_server_server_handler_soup_server_callback (SoupServer* server, SoupMessage* msg, const gchar* path, GHashTable* query, SoupClientContext* client, gpointer self);
static void rygel_http_server_on_request_aborted (RygelHTTPServer* self, SoupServer* server, SoupMessage* message, SoupClientContext* client);
static void _rygel_http_server_on_request_aborted_soup_server_request_aborted (SoupServer* _sender, SoupMessage* msg, SoupClientContext* client, gpointer self);
static void rygel_http_server_on_request_started (RygelHTTPServer* self, SoupServer* server, SoupMessage* message, SoupClientContext* client);
static void _rygel_http_server_on_request_started_soup_server_request_started (SoupServer* _sender, SoupMessage* msg, SoupClientContext* client, gpointer self);
static void rygel_http_server_on_cancelled (RygelHTTPServer* self, GCancellable* cancellable);
static void _rygel_http_server_on_cancelled_g_cancellable_cancelled (GCancellable* _sender, gpointer self);
GType rygel_media_resource_get_type (void) G_GNUC_CONST;
void rygel_http_server_set_resource_delivery_options (RygelHTTPServer* self, RygelMediaResource* res);
gchar* rygel_http_server_get_protocol (RygelHTTPServer* self);
void rygel_media_resource_set_protocol (RygelMediaResource* self, const gchar* value);
GUPnPDLNAFlags rygel_media_resource_get_dlna_flags (RygelMediaResource* self);
void rygel_media_resource_set_dlna_flags (RygelMediaResource* self, GUPnPDLNAFlags value);
gboolean rygel_http_server_need_proxy (RygelHTTPServer* self, const gchar* uri);
gchar* rygel_http_server_create_uri_for_object (RygelHTTPServer* self, RygelMediaObject* object, gint thumbnail_index, gint subtitle_index, const gchar* resource_name);
GType rygel_http_item_uri_get_type (void) G_GNUC_CONST;
RygelHTTPItemURI* rygel_http_item_uri_new (RygelMediaObject* object, RygelHTTPServer* http_server, gint thumbnail_index, gint subtitle_index, const gchar* resource_name);
RygelHTTPItemURI* rygel_http_item_uri_construct (GType object_type, RygelMediaObject* object, RygelHTTPServer* http_server, gint thumbnail_index, gint subtitle_index, const gchar* resource_name);
gchar* rygel_http_item_uri_to_string (RygelHTTPItemURI* self);
static gchar* rygel_http_server_real_get_protocol (RygelHTTPServer* self);
GeeArrayList* rygel_http_server_get_protocol_info (RygelHTTPServer* self);
static GeeArrayList* rygel_http_server_real_get_protocol_info (RygelHTTPServer* self);
GHashTable* rygel_http_server_get_replacements (RygelHTTPServer* self);
gboolean rygel_http_server_is_local (RygelHTTPServer* self);
static void rygel_http_server_on_request_completed (RygelHTTPServer* self, RygelStateMachine* machine);
GType rygel_client_hacks_get_type (void) G_GNUC_CONST;
static void __lambda16_ (RygelHTTPServer* self, const gchar* name, const gchar* value);
static void ___lambda16__soup_message_headers_foreach_func (const gchar* name, const gchar* value, gpointer self);
static void rygel_http_server_queue_request (RygelHTTPServer* self, RygelHTTPRequest* request);
RygelHTTPGet* rygel_http_get_new (RygelHTTPServer* http_server, SoupServer* server, SoupMessage* msg);
RygelHTTPGet* rygel_http_get_construct (GType object_type, RygelHTTPServer* http_server, SoupServer* server, SoupMessage* msg);
GType rygel_http_get_get_type (void) G_GNUC_CONST;
static void rygel_http_server_on_got_headers (RygelHTTPServer* self, SoupMessage* msg);
static void _rygel_http_server_on_got_headers_soup_message_got_headers (SoupMessage* _sender, gpointer self);
RygelHTTPPost* rygel_http_post_new (RygelHTTPServer* http_server, SoupServer* server, SoupMessage* msg);
RygelHTTPPost* rygel_http_post_construct (GType object_type, RygelHTTPServer* http_server, SoupServer* server, SoupMessage* msg);
GType rygel_http_post_get_type (void) G_GNUC_CONST;
static void _rygel_http_server_on_request_completed_rygel_state_machine_completed (RygelStateMachine* _sender, gpointer self);
const gchar* rygel_http_server_get_server_name (RygelHTTPServer* self);
static void rygel_http_server_finalize (GObject* obj);
static void _vala_rygel_http_server_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_rygel_http_server_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static void _g_free0_ (gpointer var) {
	var = (g_free (var), NULL);
}


RygelHTTPServer* rygel_http_server_construct (GType object_type, RygelContentDirectory* content_dir, const gchar* name) {
	RygelHTTPServer * self = NULL;
	RygelContentDirectory* _tmp8_ = NULL;
	RygelMediaContainer* _tmp9_ = NULL;
	RygelMediaContainer* _tmp10_ = NULL;
	RygelContentDirectory* _tmp11_ = NULL;
	GUPnPContext* _tmp12_ = NULL;
	GUPnPContext* _tmp13_ = NULL;
	GUPnPContext* _tmp14_ = NULL;
	GeeArrayList* _tmp15_ = NULL;
	RygelContentDirectory* _tmp16_ = NULL;
	GCancellable* _tmp17_ = NULL;
	gboolean _tmp18_ = FALSE;
	GUPnPContext* _tmp19_ = NULL;
	const gchar* _tmp20_ = NULL;
	const gchar* _tmp21_ = NULL;
	const gchar* _tmp26_ = NULL;
	gchar* _tmp27_ = NULL;
	gchar* _tmp28_ = NULL;
	GHashFunc _tmp29_ = NULL;
	GEqualFunc _tmp30_ = NULL;
	GHashTable* _tmp31_ = NULL;
	GHashTable* _tmp32_ = NULL;
	gchar* _tmp33_ = NULL;
	GUPnPContext* _tmp34_ = NULL;
	gchar* _tmp35_ = NULL;
	gchar* _tmp36_ = NULL;
	GHashTable* _tmp37_ = NULL;
	gchar* _tmp38_ = NULL;
	GUPnPContext* _tmp39_ = NULL;
	gchar* _tmp40_ = NULL;
	gchar* _tmp41_ = NULL;
	GHashTable* _tmp42_ = NULL;
	gchar* _tmp43_ = NULL;
	GUPnPContext* _tmp44_ = NULL;
	const gchar* _tmp45_ = NULL;
	const gchar* _tmp46_ = NULL;
	gchar* _tmp47_ = NULL;
	GHashTable* _tmp48_ = NULL;
	gchar* _tmp49_ = NULL;
	GUPnPContext* _tmp50_ = NULL;
	guint _tmp51_ = 0U;
	guint _tmp52_ = 0U;
	gchar* _tmp53_ = NULL;
	GHashTable* _tmp54_ = NULL;
	gchar* _tmp55_ = NULL;
	const gchar* _tmp56_ = NULL;
	gchar* _tmp57_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (content_dir != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	self = (RygelHTTPServer*) g_object_new (object_type, NULL);
	{
		RygelMetaConfig* config = NULL;
		RygelMetaConfig* _tmp0_ = NULL;
		gchar* _tmp1_ = NULL;
		const gchar* _tmp2_ = NULL;
		gchar* _tmp3_ = NULL;
		_tmp0_ = rygel_meta_config_get_default ();
		config = _tmp0_;
		_tmp2_ = name;
		_tmp3_ = rygel_configuration_get_string ((RygelConfiguration*) config, _tmp2_, "server-name", &_inner_error_);
		_tmp1_ = _tmp3_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (config);
			goto __catch51_g_error;
		}
		rygel_http_server_set_server_name (self, _tmp1_);
		_g_free0 (_tmp1_);
		_g_object_unref0 (config);
	}
	goto __finally51;
	__catch51_g_error:
	{
		GError* _error_ = NULL;
		const gchar* _tmp4_ = NULL;
		const gchar* _tmp5_ = NULL;
		gchar* _tmp6_ = NULL;
		gchar* _tmp7_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp4_ = name;
		_tmp5_ = g_get_prgname ();
		_tmp6_ = g_strdup_printf (RYGEL_HTTP_SERVER_SERVER_TEMPLATE, _tmp4_, PACKAGE_VERSION, _tmp5_, PACKAGE_VERSION);
		_tmp7_ = _tmp6_;
		rygel_http_server_set_server_name (self, _tmp7_);
		_g_free0 (_tmp7_);
		_g_error_free0 (_error_);
	}
	__finally51:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	_tmp8_ = content_dir;
	_tmp9_ = _tmp8_->root_container;
	_tmp10_ = _g_object_ref0 (_tmp9_);
	_g_object_unref0 (self->root_container);
	self->root_container = _tmp10_;
	_tmp11_ = content_dir;
	_tmp12_ = gupnp_service_info_get_context ((GUPnPServiceInfo*) _tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = _g_object_ref0 (_tmp13_);
	_g_object_unref0 (self->context);
	self->context = _tmp14_;
	_tmp15_ = gee_array_list_new (RYGEL_TYPE_HTTP_REQUEST, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->requests);
	self->priv->requests = _tmp15_;
	_tmp16_ = content_dir;
	_tmp17_ = _tmp16_->cancellable;
	rygel_state_machine_set_cancellable ((RygelStateMachine*) self, _tmp17_);
	_tmp19_ = self->context;
	_tmp20_ = gssdp_client_get_interface ((GSSDPClient*) _tmp19_);
	_tmp21_ = _tmp20_;
	if (g_strcmp0 (_tmp21_, "lo") == 0) {
		_tmp18_ = TRUE;
	} else {
		GUPnPContext* _tmp22_ = NULL;
		gchar* _tmp23_ = NULL;
		gchar* _tmp24_ = NULL;
		gchar* _tmp25_ = NULL;
		_tmp22_ = self->context;
		g_object_get ((GSSDPClient*) _tmp22_, "host-ip", &_tmp23_, NULL);
		_tmp24_ = _tmp23_;
		_tmp25_ = _tmp24_;
		_tmp18_ = g_strcmp0 (_tmp25_, "127.0.0.1") == 0;
		_g_free0 (_tmp25_);
	}
	self->priv->locally_hosted = _tmp18_;
	_tmp26_ = name;
	_tmp27_ = g_strconcat ("/", _tmp26_, NULL);
	_tmp28_ = _tmp27_;
	rygel_http_server_set_path_root (self, _tmp28_);
	_g_free0 (_tmp28_);
	_tmp29_ = g_str_hash;
	_tmp30_ = g_str_equal;
	_tmp31_ = g_hash_table_new_full (_tmp29_, _tmp30_, _g_free0_, _g_free0_);
	_g_hash_table_unref0 (self->replacements);
	self->replacements = _tmp31_;
	_tmp32_ = self->replacements;
	_tmp33_ = g_strdup ("@SERVICE_ADDRESS@");
	_tmp34_ = self->context;
	g_object_get ((GSSDPClient*) _tmp34_, "host-ip", &_tmp35_, NULL);
	_tmp36_ = _tmp35_;
	g_hash_table_insert (_tmp32_, _tmp33_, _tmp36_);
	_tmp37_ = self->replacements;
	_tmp38_ = g_strdup ("@ADDRESS@");
	_tmp39_ = self->context;
	g_object_get ((GSSDPClient*) _tmp39_, "host-ip", &_tmp40_, NULL);
	_tmp41_ = _tmp40_;
	g_hash_table_insert (_tmp37_, _tmp38_, _tmp41_);
	_tmp42_ = self->replacements;
	_tmp43_ = g_strdup ("@SERVICE_INTERFACE@");
	_tmp44_ = self->context;
	_tmp45_ = gssdp_client_get_interface ((GSSDPClient*) _tmp44_);
	_tmp46_ = _tmp45_;
	_tmp47_ = g_strdup (_tmp46_);
	g_hash_table_insert (_tmp42_, _tmp43_, _tmp47_);
	_tmp48_ = self->replacements;
	_tmp49_ = g_strdup ("@SERVICE_PORT@");
	_tmp50_ = self->context;
	_tmp51_ = gupnp_context_get_port (_tmp50_);
	_tmp52_ = _tmp51_;
	_tmp53_ = g_strdup_printf ("%u", _tmp52_);
	g_hash_table_insert (_tmp48_, _tmp49_, _tmp53_);
	_tmp54_ = self->replacements;
	_tmp55_ = g_strdup ("@HOSTNAME@");
	_tmp56_ = g_get_host_name ();
	_tmp57_ = g_strdup (_tmp56_);
	g_hash_table_insert (_tmp54_, _tmp55_, _tmp57_);
	return self;
}


RygelHTTPServer* rygel_http_server_new (RygelContentDirectory* content_dir, const gchar* name) {
	return rygel_http_server_construct (RYGEL_TYPE_HTTP_SERVER, content_dir, name);
}


static void rygel_http_server_real_run_data_free (gpointer _data) {
	RygelHttpServerRunData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelHttpServerRunData, _data_);
}


static void rygel_http_server_real_run (RygelStateMachine* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	RygelHTTPServer * self;
	RygelHttpServerRunData* _data_;
	RygelHTTPServer* _tmp0_ = NULL;
	self = (RygelHTTPServer*) base;
	_data_ = g_slice_new0 (RygelHttpServerRunData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_http_server_real_run);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_http_server_real_run_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	rygel_http_server_real_run_co (_data_);
}


static void rygel_http_server_real_run_finish (RygelStateMachine* base, GAsyncResult* _res_) {
	RygelHttpServerRunData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void _rygel_http_server_server_handler_soup_server_callback (SoupServer* server, SoupMessage* msg, const gchar* path, GHashTable* query, SoupClientContext* client, gpointer self) {
	rygel_http_server_server_handler ((RygelHTTPServer*) self, server, msg, path, query, client);
}


static void _rygel_http_server_on_request_aborted_soup_server_request_aborted (SoupServer* _sender, SoupMessage* msg, SoupClientContext* client, gpointer self) {
	rygel_http_server_on_request_aborted ((RygelHTTPServer*) self, _sender, msg, client);
}


static void _rygel_http_server_on_request_started_soup_server_request_started (SoupServer* _sender, SoupMessage* msg, SoupClientContext* client, gpointer self) {
	rygel_http_server_on_request_started ((RygelHTTPServer*) self, _sender, msg, client);
}


static void _rygel_http_server_on_cancelled_g_cancellable_cancelled (GCancellable* _sender, gpointer self) {
	rygel_http_server_on_cancelled ((RygelHTTPServer*) self, _sender);
}


static gboolean rygel_http_server_real_run_co (RygelHttpServerRunData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp0_ = _data_->self->context;
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = _data_->self->priv->_path_root;
	gupnp_context_add_server_handler (_data_->_tmp0_, TRUE, _data_->_tmp1_, _rygel_http_server_server_handler_soup_server_callback, g_object_ref (_data_->self), g_object_unref);
	_data_->_tmp2_ = NULL;
	_data_->_tmp2_ = _data_->self->context;
	_data_->_tmp3_ = NULL;
	_data_->_tmp3_ = gupnp_context_get_server (_data_->_tmp2_);
	_data_->_tmp4_ = NULL;
	_data_->_tmp4_ = _data_->_tmp3_;
	g_signal_connect_object (_data_->_tmp4_, "request-aborted", (GCallback) _rygel_http_server_on_request_aborted_soup_server_request_aborted, _data_->self, 0);
	_data_->_tmp5_ = NULL;
	_data_->_tmp5_ = _data_->self->context;
	_data_->_tmp6_ = NULL;
	_data_->_tmp6_ = gupnp_context_get_server (_data_->_tmp5_);
	_data_->_tmp7_ = NULL;
	_data_->_tmp7_ = _data_->_tmp6_;
	g_signal_connect_object (_data_->_tmp7_, "request-started", (GCallback) _rygel_http_server_on_request_started_soup_server_request_started, _data_->self, 0);
	_data_->_tmp8_ = NULL;
	_data_->_tmp8_ = rygel_state_machine_get_cancellable ((RygelStateMachine*) _data_->self);
	_data_->_tmp9_ = NULL;
	_data_->_tmp9_ = _data_->_tmp8_;
	if (_data_->_tmp9_ != NULL) {
		_data_->_tmp10_ = NULL;
		_data_->_tmp10_ = rygel_state_machine_get_cancellable ((RygelStateMachine*) _data_->self);
		_data_->_tmp11_ = NULL;
		_data_->_tmp11_ = _data_->_tmp10_;
		g_signal_connect_object (_data_->_tmp11_, "cancelled", (GCallback) _rygel_http_server_on_cancelled_g_cancellable_cancelled, _data_->self, 0);
	}
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


/**
     * Set or unset options the server supports/doesn't support
     *
     * Resources should be setup assuming server supports all optional
     * delivery modes
     */
void rygel_http_server_set_resource_delivery_options (RygelHTTPServer* self, RygelMediaResource* res) {
	RygelMediaResource* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	RygelMediaResource* _tmp3_ = NULL;
	RygelMediaResource* _tmp4_ = NULL;
	GUPnPDLNAFlags _tmp5_ = 0;
	GUPnPDLNAFlags _tmp6_ = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (res != NULL);
	_tmp0_ = res;
	_tmp1_ = rygel_http_server_get_protocol (self);
	_tmp2_ = _tmp1_;
	rygel_media_resource_set_protocol (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
	_tmp3_ = res;
	_tmp4_ = res;
	_tmp5_ = rygel_media_resource_get_dlna_flags (_tmp4_);
	_tmp6_ = _tmp5_;
	rygel_media_resource_set_dlna_flags (_tmp4_, _tmp6_ | GUPNP_DLNA_FLAGS_DLNA_V15);
}


gboolean rygel_http_server_need_proxy (RygelHTTPServer* self, const gchar* uri) {
	gboolean result = FALSE;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (uri != NULL, FALSE);
	_tmp0_ = uri;
	_tmp1_ = g_uri_parse_scheme (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strcmp0 (_tmp2_, "http") != 0;
	_g_free0 (_tmp2_);
	result = _tmp3_;
	return result;
}


static void rygel_http_server_on_cancelled (RygelHTTPServer* self, GCancellable* cancellable) {
	GCancellable* _tmp0_ = NULL;
	GCancellable* _tmp1_ = NULL;
	GUPnPContext* _tmp2_ = NULL;
	SoupServer* _tmp3_ = NULL;
	SoupServer* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (cancellable != NULL);
	_tmp0_ = rygel_state_machine_get_cancellable ((RygelStateMachine*) self);
	_tmp1_ = _tmp0_;
	g_cancellable_cancel (_tmp1_);
	_tmp2_ = self->context;
	_tmp3_ = gupnp_context_get_server (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->_path_root;
	soup_server_remove_handler (_tmp4_, _tmp5_);
	g_signal_emit_by_name ((RygelStateMachine*) self, "completed");
}


gchar* rygel_http_server_create_uri_for_object (RygelHTTPServer* self, RygelMediaObject* object, gint thumbnail_index, gint subtitle_index, const gchar* resource_name) {
	gchar* result = NULL;
	RygelHTTPItemURI* uri = NULL;
	RygelMediaObject* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	const gchar* _tmp3_ = NULL;
	RygelHTTPItemURI* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (object != NULL, NULL);
	_tmp0_ = object;
	_tmp1_ = thumbnail_index;
	_tmp2_ = subtitle_index;
	_tmp3_ = resource_name;
	_tmp4_ = rygel_http_item_uri_new (_tmp0_, self, _tmp1_, _tmp2_, _tmp3_);
	uri = _tmp4_;
	_tmp5_ = rygel_http_item_uri_to_string (uri);
	result = _tmp5_;
	_g_object_unref0 (uri);
	return result;
}


static gchar* rygel_http_server_real_get_protocol (RygelHTTPServer* self) {
	gchar* result = NULL;
	gchar* _tmp0_ = NULL;
	_tmp0_ = g_strdup ("http-get");
	result = _tmp0_;
	return result;
}


gchar* rygel_http_server_get_protocol (RygelHTTPServer* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_HTTP_SERVER_GET_CLASS (self)->get_protocol (self);
}


static GeeArrayList* rygel_http_server_real_get_protocol_info (RygelHTTPServer* self) {
	GeeArrayList* result = NULL;
	GeeArrayList* _tmp0_ = NULL;
	_tmp0_ = gee_array_list_new (gupnp_protocol_info_get_type (), (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
	result = _tmp0_;
	return result;
}


GeeArrayList* rygel_http_server_get_protocol_info (RygelHTTPServer* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_HTTP_SERVER_GET_CLASS (self)->get_protocol_info (self);
}


static gpointer _g_hash_table_ref0 (gpointer self) {
	return self ? g_hash_table_ref (self) : NULL;
}


GHashTable* rygel_http_server_get_replacements (RygelHTTPServer* self) {
	GHashTable* result = NULL;
	GHashTable* _tmp0_ = NULL;
	GHashTable* _tmp1_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->replacements;
	_tmp1_ = _g_hash_table_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}


gboolean rygel_http_server_is_local (RygelHTTPServer* self) {
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->locally_hosted;
	result = _tmp0_;
	return result;
}


static void rygel_http_server_on_request_completed (RygelHTTPServer* self, RygelStateMachine* machine) {
	RygelHTTPRequest* request = NULL;
	RygelStateMachine* _tmp0_ = NULL;
	RygelHTTPRequest* _tmp1_ = NULL;
	GeeArrayList* _tmp2_ = NULL;
	SoupMessage* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	SoupMessage* _tmp7_ = NULL;
	SoupURI* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gchar* _tmp10_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (machine != NULL);
	_tmp0_ = machine;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, RYGEL_TYPE_HTTP_REQUEST) ? ((RygelHTTPRequest*) _tmp0_) : NULL);
	request = _tmp1_;
	_tmp2_ = self->priv->requests;
	gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp2_, request);
	_tmp3_ = request->msg;
	g_object_get (_tmp3_, "method", &_tmp4_, NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp7_ = request->msg;
	_tmp8_ = soup_message_get_uri (_tmp7_);
	_tmp9_ = soup_uri_to_string (_tmp8_, FALSE);
	_tmp10_ = _tmp9_;
	g_debug ("rygel-http-server.vala:155: HTTP %s request for URI '%s' handled.", _tmp6_, _tmp10_);
	_g_free0 (_tmp10_);
	_g_free0 (_tmp6_);
	_g_object_unref0 (request);
}


static void __lambda16_ (RygelHTTPServer* self, const gchar* name, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	g_return_if_fail (name != NULL);
	g_return_if_fail (value != NULL);
	_tmp0_ = name;
	_tmp1_ = value;
	g_debug ("rygel-http-server.vala:174:     %s : %s", _tmp0_, _tmp1_);
}


static void ___lambda16__soup_message_headers_foreach_func (const gchar* name, const gchar* value, gpointer self) {
	__lambda16_ ((RygelHTTPServer*) self, name, value);
}


static void rygel_http_server_server_handler (RygelHTTPServer* self, SoupServer* server, SoupMessage* msg, const gchar* server_path, GHashTable* query, SoupClientContext* soup_client) {
	SoupMessage* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gboolean _tmp4_ = FALSE;
	SoupMessage* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	SoupMessage* _tmp9_ = NULL;
	SoupURI* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	gchar* _tmp12_ = NULL;
	SoupMessage* _tmp13_ = NULL;
	SoupMessageHeaders* _tmp14_ = NULL;
	SoupServer* _tmp15_ = NULL;
	SoupMessage* _tmp16_ = NULL;
	RygelHTTPGet* _tmp17_ = NULL;
	RygelHTTPGet* _tmp18_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (server != NULL);
	g_return_if_fail (msg != NULL);
	g_return_if_fail (server_path != NULL);
	g_return_if_fail (soup_client != NULL);
	_tmp0_ = msg;
	g_object_get (_tmp0_, "method", &_tmp1_, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strcmp0 (_tmp3_, "POST") == 0;
	_g_free0 (_tmp3_);
	if (_tmp4_) {
		return;
	}
	_tmp5_ = msg;
	g_object_get (_tmp5_, "method", &_tmp6_, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp9_ = msg;
	_tmp10_ = soup_message_get_uri (_tmp9_);
	_tmp11_ = soup_uri_to_string (_tmp10_, FALSE);
	_tmp12_ = _tmp11_;
	g_debug ("rygel-http-server.vala:170: HTTP %s request for URI '%s'. Headers:", _tmp8_, _tmp12_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp8_);
	_tmp13_ = msg;
	_tmp14_ = _tmp13_->request_headers;
	soup_message_headers_foreach (_tmp14_, ___lambda16__soup_message_headers_foreach_func, self);
	_tmp15_ = server;
	_tmp16_ = msg;
	_tmp17_ = rygel_http_get_new (self, _tmp15_, _tmp16_);
	_tmp18_ = _tmp17_;
	rygel_http_server_queue_request (self, (RygelHTTPRequest*) _tmp18_);
	_g_object_unref0 (_tmp18_);
}


static void rygel_http_server_on_request_aborted (RygelHTTPServer* self, SoupServer* server, SoupMessage* message, SoupClientContext* client) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (server != NULL);
	g_return_if_fail (message != NULL);
	g_return_if_fail (client != NULL);
	{
		GeeArrayList* _request_list = NULL;
		GeeArrayList* _tmp0_ = NULL;
		GeeArrayList* _tmp1_ = NULL;
		gint _request_size = 0;
		GeeArrayList* _tmp2_ = NULL;
		gint _tmp3_ = 0;
		gint _tmp4_ = 0;
		gint _request_index = 0;
		_tmp0_ = self->priv->requests;
		_tmp1_ = _g_object_ref0 (_tmp0_);
		_request_list = _tmp1_;
		_tmp2_ = _request_list;
		_tmp3_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_request_size = _tmp4_;
		_request_index = -1;
		while (TRUE) {
			gint _tmp5_ = 0;
			gint _tmp6_ = 0;
			gint _tmp7_ = 0;
			RygelHTTPRequest* request = NULL;
			GeeArrayList* _tmp8_ = NULL;
			gint _tmp9_ = 0;
			gpointer _tmp10_ = NULL;
			RygelHTTPRequest* _tmp11_ = NULL;
			SoupMessage* _tmp12_ = NULL;
			SoupMessage* _tmp13_ = NULL;
			_tmp5_ = _request_index;
			_request_index = _tmp5_ + 1;
			_tmp6_ = _request_index;
			_tmp7_ = _request_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _request_list;
			_tmp9_ = _request_index;
			_tmp10_ = gee_abstract_list_get ((GeeAbstractList*) _tmp8_, _tmp9_);
			request = (RygelHTTPRequest*) _tmp10_;
			_tmp11_ = request;
			_tmp12_ = _tmp11_->msg;
			_tmp13_ = message;
			if (_tmp12_ == _tmp13_) {
				RygelHTTPRequest* _tmp14_ = NULL;
				GCancellable* _tmp15_ = NULL;
				GCancellable* _tmp16_ = NULL;
				RygelHTTPRequest* _tmp17_ = NULL;
				SoupMessage* _tmp18_ = NULL;
				gchar* _tmp19_ = NULL;
				gchar* _tmp20_ = NULL;
				gchar* _tmp21_ = NULL;
				RygelHTTPRequest* _tmp22_ = NULL;
				SoupMessage* _tmp23_ = NULL;
				SoupURI* _tmp24_ = NULL;
				gchar* _tmp25_ = NULL;
				gchar* _tmp26_ = NULL;
				_tmp14_ = request;
				_tmp15_ = rygel_state_machine_get_cancellable ((RygelStateMachine*) _tmp14_);
				_tmp16_ = _tmp15_;
				g_cancellable_cancel (_tmp16_);
				_tmp17_ = request;
				_tmp18_ = _tmp17_->msg;
				g_object_get (_tmp18_, "method", &_tmp19_, NULL);
				_tmp20_ = _tmp19_;
				_tmp21_ = _tmp20_;
				_tmp22_ = request;
				_tmp23_ = _tmp22_->msg;
				_tmp24_ = soup_message_get_uri (_tmp23_);
				_tmp25_ = soup_uri_to_string (_tmp24_, FALSE);
				_tmp26_ = _tmp25_;
				g_debug ("rygel-http-server.vala:186: HTTP client aborted %s request for URI '%s" \
"'.", _tmp21_, _tmp26_);
				_g_free0 (_tmp26_);
				_g_free0 (_tmp21_);
				_g_object_unref0 (request);
				break;
			}
			_g_object_unref0 (request);
		}
		_g_object_unref0 (_request_list);
	}
}


static void _rygel_http_server_on_got_headers_soup_message_got_headers (SoupMessage* _sender, gpointer self) {
	rygel_http_server_on_got_headers ((RygelHTTPServer*) self, _sender);
}


static void rygel_http_server_on_request_started (RygelHTTPServer* self, SoupServer* server, SoupMessage* message, SoupClientContext* client) {
	SoupMessage* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (server != NULL);
	g_return_if_fail (message != NULL);
	g_return_if_fail (client != NULL);
	_tmp0_ = message;
	g_signal_connect_object (_tmp0_, "got-headers", (GCallback) _rygel_http_server_on_got_headers_soup_message_got_headers, self, 0);
}


static void rygel_http_server_on_got_headers (RygelHTTPServer* self, SoupMessage* msg) {
	gboolean _tmp0_ = FALSE;
	SoupMessage* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gboolean _tmp5_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (msg != NULL);
	_tmp1_ = msg;
	g_object_get (_tmp1_, "method", &_tmp2_, NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strcmp0 (_tmp4_, "POST") == 0;
	_g_free0 (_tmp4_);
	if (_tmp5_) {
		SoupMessage* _tmp6_ = NULL;
		SoupURI* _tmp7_ = NULL;
		SoupURI* _tmp8_ = NULL;
		const gchar* _tmp9_ = NULL;
		const gchar* _tmp10_ = NULL;
		gboolean _tmp11_ = FALSE;
		_tmp6_ = msg;
		_tmp7_ = soup_message_get_uri (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = _tmp8_->path;
		_tmp10_ = self->priv->_path_root;
		_tmp11_ = g_str_has_prefix (_tmp9_, _tmp10_);
		_tmp0_ = _tmp11_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		SoupMessage* _tmp12_ = NULL;
		SoupURI* _tmp13_ = NULL;
		gchar* _tmp14_ = NULL;
		gchar* _tmp15_ = NULL;
		GUPnPContext* _tmp16_ = NULL;
		SoupServer* _tmp17_ = NULL;
		SoupServer* _tmp18_ = NULL;
		SoupMessage* _tmp19_ = NULL;
		RygelHTTPPost* _tmp20_ = NULL;
		RygelHTTPPost* _tmp21_ = NULL;
		_tmp12_ = msg;
		_tmp13_ = soup_message_get_uri (_tmp12_);
		_tmp14_ = soup_uri_to_string (_tmp13_, FALSE);
		_tmp15_ = _tmp14_;
		g_debug ("rygel-http-server.vala:204: HTTP POST request for URI '%s'", _tmp15_);
		_g_free0 (_tmp15_);
		_tmp16_ = self->context;
		_tmp17_ = gupnp_context_get_server (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = msg;
		_tmp20_ = rygel_http_post_new (self, _tmp18_, _tmp19_);
		_tmp21_ = _tmp20_;
		rygel_http_server_queue_request (self, (RygelHTTPRequest*) _tmp21_);
		_g_object_unref0 (_tmp21_);
	}
}


static void _rygel_http_server_on_request_completed_rygel_state_machine_completed (RygelStateMachine* _sender, gpointer self) {
	rygel_http_server_on_request_completed ((RygelHTTPServer*) self, _sender);
}


static void rygel_http_server_queue_request (RygelHTTPServer* self, RygelHTTPRequest* request) {
	RygelHTTPRequest* _tmp0_ = NULL;
	GeeArrayList* _tmp1_ = NULL;
	RygelHTTPRequest* _tmp2_ = NULL;
	RygelHTTPRequest* _tmp3_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (request != NULL);
	_tmp0_ = request;
	g_signal_connect_object ((RygelStateMachine*) _tmp0_, "completed", (GCallback) _rygel_http_server_on_request_completed_rygel_state_machine_completed, self, 0);
	_tmp1_ = self->priv->requests;
	_tmp2_ = request;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp1_, _tmp2_);
	_tmp3_ = request;
	rygel_state_machine_run ((RygelStateMachine*) _tmp3_, NULL, NULL);
}


const gchar* rygel_http_server_get_path_root (RygelHTTPServer* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_path_root;
	result = _tmp0_;
	return result;
}


static void rygel_http_server_set_path_root (RygelHTTPServer* self, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_path_root);
	self->priv->_path_root = _tmp1_;
	g_object_notify ((GObject *) self, "path-root");
}


const gchar* rygel_http_server_get_server_name (RygelHTTPServer* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_server_name;
	result = _tmp0_;
	return result;
}


void rygel_http_server_set_server_name (RygelHTTPServer* self, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_server_name);
	self->priv->_server_name = _tmp1_;
	g_object_notify ((GObject *) self, "server-name");
}


static GCancellable* rygel_http_server_real_get_cancellable (RygelStateMachine* base) {
	GCancellable* result;
	RygelHTTPServer* self;
	GCancellable* _tmp0_ = NULL;
	self = (RygelHTTPServer*) base;
	_tmp0_ = self->priv->_cancellable;
	result = _tmp0_;
	return result;
}


static void rygel_http_server_real_set_cancellable (RygelStateMachine* base, GCancellable* value) {
	RygelHTTPServer* self;
	GCancellable* _tmp0_ = NULL;
	GCancellable* _tmp1_ = NULL;
	self = (RygelHTTPServer*) base;
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_cancellable);
	self->priv->_cancellable = _tmp1_;
	g_object_notify ((GObject *) self, "cancellable");
}


static void rygel_http_server_class_init (RygelHTTPServerClass * klass) {
	rygel_http_server_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RygelHTTPServerPrivate));
	((RygelHTTPServerClass *) klass)->get_protocol = rygel_http_server_real_get_protocol;
	((RygelHTTPServerClass *) klass)->get_protocol_info = rygel_http_server_real_get_protocol_info;
	G_OBJECT_CLASS (klass)->get_property = _vala_rygel_http_server_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_rygel_http_server_set_property;
	G_OBJECT_CLASS (klass)->finalize = rygel_http_server_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_HTTP_SERVER_PATH_ROOT, g_param_spec_string ("path-root", "path-root", "path-root", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_HTTP_SERVER_SERVER_NAME, g_param_spec_string ("server-name", "server-name", "server-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_HTTP_SERVER_CANCELLABLE, g_param_spec_object ("cancellable", "cancellable", "cancellable", g_cancellable_get_type (), G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void rygel_http_server_rygel_state_machine_interface_init (RygelStateMachineIface * iface) {
	rygel_http_server_rygel_state_machine_parent_iface = g_type_interface_peek_parent (iface);
	iface->run = (void (*)(RygelStateMachine*)) rygel_http_server_real_run;
	iface->run_finish = rygel_http_server_real_run_finish;
	iface->get_cancellable = rygel_http_server_real_get_cancellable;
	iface->set_cancellable = rygel_http_server_real_set_cancellable;
}


static void rygel_http_server_instance_init (RygelHTTPServer * self) {
	self->priv = RYGEL_HTTP_SERVER_GET_PRIVATE (self);
}


static void rygel_http_server_finalize (GObject* obj) {
	RygelHTTPServer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_HTTP_SERVER, RygelHTTPServer);
	_g_free0 (self->priv->_path_root);
	_g_free0 (self->priv->_server_name);
	_g_object_unref0 (self->root_container);
	_g_object_unref0 (self->context);
	_g_object_unref0 (self->priv->requests);
	_g_hash_table_unref0 (self->replacements);
	_g_object_unref0 (self->priv->_cancellable);
	G_OBJECT_CLASS (rygel_http_server_parent_class)->finalize (obj);
}


GType rygel_http_server_get_type (void) {
	static volatile gsize rygel_http_server_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_http_server_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelHTTPServerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_http_server_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelHTTPServer), 0, (GInstanceInitFunc) rygel_http_server_instance_init, NULL };
		static const GInterfaceInfo rygel_state_machine_info = { (GInterfaceInitFunc) rygel_http_server_rygel_state_machine_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType rygel_http_server_type_id;
		rygel_http_server_type_id = g_type_register_static (G_TYPE_OBJECT, "RygelHTTPServer", &g_define_type_info, 0);
		g_type_add_interface_static (rygel_http_server_type_id, RYGEL_TYPE_STATE_MACHINE, &rygel_state_machine_info);
		g_once_init_leave (&rygel_http_server_type_id__volatile, rygel_http_server_type_id);
	}
	return rygel_http_server_type_id__volatile;
}


static void _vala_rygel_http_server_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	RygelHTTPServer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_TYPE_HTTP_SERVER, RygelHTTPServer);
	switch (property_id) {
		case RYGEL_HTTP_SERVER_PATH_ROOT:
		g_value_set_string (value, rygel_http_server_get_path_root (self));
		break;
		case RYGEL_HTTP_SERVER_SERVER_NAME:
		g_value_set_string (value, rygel_http_server_get_server_name (self));
		break;
		case RYGEL_HTTP_SERVER_CANCELLABLE:
		g_value_set_object (value, rygel_state_machine_get_cancellable ((RygelStateMachine*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_rygel_http_server_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	RygelHTTPServer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_TYPE_HTTP_SERVER, RygelHTTPServer);
	switch (property_id) {
		case RYGEL_HTTP_SERVER_PATH_ROOT:
		rygel_http_server_set_path_root (self, g_value_get_string (value));
		break;
		case RYGEL_HTTP_SERVER_SERVER_NAME:
		rygel_http_server_set_server_name (self, g_value_get_string (value));
		break;
		case RYGEL_HTTP_SERVER_CANCELLABLE:
		rygel_state_machine_set_cancellable ((RygelStateMachine*) self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



