/* rygel-samsung-tv-hacks.c generated by valac 0.56.1, the Vala compiler
 * generated from rygel-samsung-tv-hacks.vala, do not modify */

/*
 * Copyright (C) 2012 Choe Hwanjin <choe.hwanjin@gmail.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-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "rygel-server.h"
#include <gio/gio.h>
#include <libsoup/soup.h>
#include <gee.h>
#include "rygel-core.h"

#define RYGEL_SAMSUNG_TV_HACKS_AGENT ".*SEC_HHP.*|.*SEC HHP.*"

#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;
typedef struct _RygelClientHacksPrivate RygelClientHacksPrivate;

#define RYGEL_TYPE_MEDIA_QUERY_ACTION (rygel_media_query_action_get_type ())
#define RYGEL_MEDIA_QUERY_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_QUERY_ACTION, RygelMediaQueryAction))
#define RYGEL_MEDIA_QUERY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MEDIA_QUERY_ACTION, RygelMediaQueryActionClass))
#define RYGEL_IS_MEDIA_QUERY_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_QUERY_ACTION))
#define RYGEL_IS_MEDIA_QUERY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MEDIA_QUERY_ACTION))
#define RYGEL_MEDIA_QUERY_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MEDIA_QUERY_ACTION, RygelMediaQueryActionClass))

typedef struct _RygelMediaQueryAction RygelMediaQueryAction;
typedef struct _RygelMediaQueryActionClass RygelMediaQueryActionClass;

#define RYGEL_TYPE_SAMSUNG_TV_HACKS (rygel_samsung_tv_hacks_get_type ())
#define RYGEL_SAMSUNG_TV_HACKS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_SAMSUNG_TV_HACKS, RygelSamsungTVHacks))
#define RYGEL_SAMSUNG_TV_HACKS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_SAMSUNG_TV_HACKS, RygelSamsungTVHacksClass))
#define RYGEL_IS_SAMSUNG_TV_HACKS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_SAMSUNG_TV_HACKS))
#define RYGEL_IS_SAMSUNG_TV_HACKS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_SAMSUNG_TV_HACKS))
#define RYGEL_SAMSUNG_TV_HACKS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_SAMSUNG_TV_HACKS, RygelSamsungTVHacksClass))

typedef struct _RygelSamsungTVHacks RygelSamsungTVHacks;
typedef struct _RygelSamsungTVHacksClass RygelSamsungTVHacksClass;
typedef struct _RygelSamsungTVHacksPrivate RygelSamsungTVHacksPrivate;
enum  {
	RYGEL_SAMSUNG_TV_HACKS_0_PROPERTY,
	RYGEL_SAMSUNG_TV_HACKS_NUM_PROPERTIES
};
static GParamSpec* rygel_samsung_tv_hacks_properties[RYGEL_SAMSUNG_TV_HACKS_NUM_PROPERTIES];

#define RYGEL_TYPE_CLIENT_HACKS_ERROR (rygel_client_hacks_error_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _rygel_icon_info_unref0(var) ((var == NULL) ? NULL : (var = (rygel_icon_info_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))

struct _RygelClientHacks {
	GObject parent_instance;
	RygelClientHacksPrivate * priv;
	GRegex* agent_regex;
};

struct _RygelClientHacksClass {
	GObjectClass parent_class;
	void (*translate_container_id) (RygelClientHacks* self, RygelMediaQueryAction* action, gchar** container_id);
	void (*apply) (RygelClientHacks* self, RygelMediaObject* object);
	void (*filter_sort_criteria) (RygelClientHacks* self, gchar** sort_criteria);
	gboolean (*force_seek) (RygelClientHacks* self);
	void (*modify_headers) (RygelClientHacks* self, RygelHTTPRequest* request);
	void (*search) (RygelClientHacks* self, RygelSearchableContainer* container, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	RygelMediaObjects* (*search_finish) (RygelClientHacks* self, GAsyncResult* _res_, guint* total_matches, GError** error);
};

struct _RygelSamsungTVHacks {
	RygelClientHacks parent_instance;
	RygelSamsungTVHacksPrivate * priv;
};

struct _RygelSamsungTVHacksClass {
	RygelClientHacksClass parent_class;
};

typedef enum  {
	RYGEL_CLIENT_HACKS_ERROR_NA
} RygelClientHacksError;
#define RYGEL_CLIENT_HACKS_ERROR rygel_client_hacks_error_quark ()

static gpointer rygel_samsung_tv_hacks_parent_class = NULL;
static GRegex* rygel_samsung_tv_hacks_mime_regex;
static GRegex* rygel_samsung_tv_hacks_mime_regex = NULL;
static GRegex* rygel_samsung_tv_hacks_dlna_regex;
static GRegex* rygel_samsung_tv_hacks_dlna_regex = NULL;

VALA_EXTERN GType rygel_client_hacks_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType rygel_media_query_action_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType rygel_samsung_tv_hacks_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void rygel_client_hacks_apply (RygelClientHacks* self,
                               RygelMediaObject* object);
VALA_EXTERN gboolean rygel_client_hacks_force_seek (RygelClientHacks* self);
VALA_EXTERN void rygel_client_hacks_modify_headers (RygelClientHacks* self,
                                        RygelHTTPRequest* request);
VALA_EXTERN GQuark rygel_client_hacks_error_quark (void);
GType rygel_client_hacks_error_get_type (void) G_GNUC_CONST ;
VALA_EXTERN RygelSamsungTVHacks* rygel_samsung_tv_hacks_new (SoupMessage* message,
                                                 GError** error);
VALA_EXTERN RygelSamsungTVHacks* rygel_samsung_tv_hacks_construct (GType object_type,
                                                       SoupMessage* message,
                                                       GError** error);
VALA_EXTERN RygelClientHacks* rygel_client_hacks_construct (GType object_type,
                                                const gchar* agent,
                                                SoupMessage* message,
                                                GError** error);
static void rygel_samsung_tv_hacks_real_apply (RygelClientHacks* base,
                                        RygelMediaObject* object);
static gboolean rygel_samsung_tv_hacks_real_force_seek (RygelClientHacks* base);
static void rygel_samsung_tv_hacks_real_modify_headers (RygelClientHacks* base,
                                                 RygelHTTPRequest* request);
VALA_EXTERN gchar* rygel_http_server_create_uri_for_object (RygelHTTPServer* self,
                                                RygelMediaObject* object,
                                                gint thumbnail_index,
                                                gint subtitle_index,
                                                const gchar* resource_name);
static void rygel_samsung_tv_hacks_finalize (GObject * obj);
static GType rygel_samsung_tv_hacks_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

RygelSamsungTVHacks*
rygel_samsung_tv_hacks_construct (GType object_type,
                                  SoupMessage* message,
                                  GError** error)
{
	RygelSamsungTVHacks * self = NULL;
	GError* _inner_error0_ = NULL;
	self = (RygelSamsungTVHacks*) rygel_client_hacks_construct (object_type, RYGEL_SAMSUNG_TV_HACKS_AGENT, message, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == RYGEL_CLIENT_HACKS_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (self);
			return NULL;
		} else {
			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;
		}
	}
	return self;
}

RygelSamsungTVHacks*
rygel_samsung_tv_hacks_new (SoupMessage* message,
                            GError** error)
{
	return rygel_samsung_tv_hacks_construct (RYGEL_TYPE_SAMSUNG_TV_HACKS, message, error);
}

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

static void
rygel_samsung_tv_hacks_real_apply (RygelClientHacks* base,
                                   RygelMediaObject* object)
{
	RygelSamsungTVHacks * self;
	RygelVisualItem* item = NULL;
	RygelVisualItem* _tmp20_;
	RygelVisualItem* _tmp21_;
	GError* _inner_error0_ = NULL;
	self = (RygelSamsungTVHacks*) base;
	g_return_if_fail (object != NULL);
	{
		GeeList* _resource_list = NULL;
		GeeList* _tmp0_;
		gint _resource_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _resource_index = 0;
		_tmp0_ = rygel_media_object_get_resource_list (object);
		_resource_list = _tmp0_;
		_tmp1_ = _resource_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_resource_size = _tmp3_;
		_resource_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			RygelMediaResource* resource = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			RygelMediaResource* _tmp8_;
			const gchar* _tmp9_;
			const gchar* _tmp10_;
			_resource_index = _resource_index + 1;
			_tmp4_ = _resource_index;
			_tmp5_ = _resource_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _resource_list;
			_tmp7_ = gee_list_get (_tmp6_, _resource_index);
			resource = (RygelMediaResource*) _tmp7_;
			_tmp8_ = resource;
			_tmp9_ = rygel_media_resource_get_mime_type (_tmp8_);
			_tmp10_ = _tmp9_;
			if (g_strcmp0 (_tmp10_, "video/x-matroska") == 0) {
				RygelMediaResource* _tmp11_;
				_tmp11_ = resource;
				rygel_media_resource_set_mime_type (_tmp11_, "video/x-mkv");
			} else {
				RygelMediaResource* _tmp12_;
				const gchar* _tmp13_;
				const gchar* _tmp14_;
				_tmp12_ = resource;
				_tmp13_ = rygel_media_resource_get_mime_type (_tmp12_);
				_tmp14_ = _tmp13_;
				if (g_strcmp0 (_tmp14_, "video/mp2t") == 0) {
					RygelMediaResource* _tmp15_;
					_tmp15_ = resource;
					rygel_media_resource_set_mime_type (_tmp15_, "video/vnd.dlna.mpeg-tts");
				} else {
					RygelMediaResource* _tmp16_;
					const gchar* _tmp17_;
					const gchar* _tmp18_;
					_tmp16_ = resource;
					_tmp17_ = rygel_media_resource_get_mime_type (_tmp16_);
					_tmp18_ = _tmp17_;
					if (g_strcmp0 (_tmp18_, "video/quicktime") == 0) {
						RygelMediaResource* _tmp19_;
						_tmp19_ = resource;
						rygel_media_resource_set_mime_type (_tmp19_, "video/mp4");
					}
				}
			}
			_g_object_unref0 (resource);
		}
		_g_object_unref0 (_resource_list);
	}
	_tmp20_ = _g_object_ref0 (RYGEL_IS_VISUAL_ITEM (object) ? ((RygelVisualItem*) object) : NULL);
	item = _tmp20_;
	_tmp21_ = item;
	if (_tmp21_ == NULL) {
		_g_object_unref0 (item);
		return;
	}
	{
		GeeArrayList* _thumbnail_list = NULL;
		RygelVisualItem* _tmp22_;
		GeeArrayList* _tmp23_;
		GeeArrayList* _tmp24_;
		gint _thumbnail_size = 0;
		GeeArrayList* _tmp25_;
		gint _tmp26_;
		gint _tmp27_;
		gint _thumbnail_index = 0;
		_tmp22_ = item;
		_tmp23_ = rygel_visual_item_get_thumbnails (_tmp22_);
		_tmp24_ = _tmp23_;
		_thumbnail_list = _tmp24_;
		_tmp25_ = _thumbnail_list;
		_tmp26_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp25_);
		_tmp27_ = _tmp26_;
		_thumbnail_size = _tmp27_;
		_thumbnail_index = -1;
		while (TRUE) {
			gint _tmp28_;
			gint _tmp29_;
			RygelThumbnail* thumbnail = NULL;
			GeeArrayList* _tmp30_;
			gpointer _tmp31_;
			_thumbnail_index = _thumbnail_index + 1;
			_tmp28_ = _thumbnail_index;
			_tmp29_ = _thumbnail_size;
			if (!(_tmp28_ < _tmp29_)) {
				break;
			}
			_tmp30_ = _thumbnail_list;
			_tmp31_ = gee_abstract_list_get ((GeeAbstractList*) _tmp30_, _thumbnail_index);
			thumbnail = (RygelThumbnail*) _tmp31_;
			{
				gchar* _tmp32_ = NULL;
				GRegex* _tmp33_;
				RygelThumbnail* _tmp34_;
				const gchar* _tmp35_;
				gchar* _tmp36_;
				RygelThumbnail* _tmp37_;
				gchar* _tmp38_;
				gchar* _tmp39_ = NULL;
				GRegex* _tmp40_;
				RygelThumbnail* _tmp41_;
				const gchar* _tmp42_;
				gchar* _tmp43_;
				RygelThumbnail* _tmp44_;
				gchar* _tmp45_;
				_tmp33_ = rygel_samsung_tv_hacks_mime_regex;
				_tmp34_ = thumbnail;
				_tmp35_ = ((RygelIconInfo*) _tmp34_)->mime_type;
				_tmp36_ = g_regex_replace_literal (_tmp33_, _tmp35_, (gssize) -1, 0, "jpeg", 0, &_inner_error0_);
				_tmp32_ = _tmp36_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					if (_inner_error0_->domain == G_REGEX_ERROR) {
						goto __catch0_g_regex_error;
					}
					_rygel_icon_info_unref0 (thumbnail);
					_g_object_unref0 (item);
					g_critical ("file %s: line %d: unexpected 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;
				}
				_tmp37_ = thumbnail;
				_tmp38_ = _tmp32_;
				_tmp32_ = NULL;
				_g_free0 (((RygelIconInfo*) _tmp37_)->mime_type);
				((RygelIconInfo*) _tmp37_)->mime_type = _tmp38_;
				_tmp40_ = rygel_samsung_tv_hacks_dlna_regex;
				_tmp41_ = thumbnail;
				_tmp42_ = _tmp41_->dlna_profile;
				_tmp43_ = g_regex_replace_literal (_tmp40_, _tmp42_, (gssize) -1, 0, "JPEG", 0, &_inner_error0_);
				_tmp39_ = _tmp43_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_free0 (_tmp32_);
					if (_inner_error0_->domain == G_REGEX_ERROR) {
						goto __catch0_g_regex_error;
					}
					_rygel_icon_info_unref0 (thumbnail);
					_g_object_unref0 (item);
					g_critical ("file %s: line %d: unexpected 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;
				}
				_tmp44_ = thumbnail;
				_tmp45_ = _tmp39_;
				_tmp39_ = NULL;
				_g_free0 (_tmp44_->dlna_profile);
				_tmp44_->dlna_profile = _tmp45_;
				_g_free0 (_tmp39_);
				_g_free0 (_tmp32_);
			}
			goto __finally0;
			__catch0_g_regex_error:
			{
				g_clear_error (&_inner_error0_);
				g_assert_not_reached ();
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_rygel_icon_info_unref0 (thumbnail);
				_g_object_unref0 (item);
				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;
			}
			_rygel_icon_info_unref0 (thumbnail);
		}
	}
	_g_object_unref0 (item);
}

static gboolean
rygel_samsung_tv_hacks_real_force_seek (RygelClientHacks* base)
{
	RygelSamsungTVHacks * self;
	gboolean result;
	self = (RygelSamsungTVHacks*) base;
	result = TRUE;
	return result;
}

static void
rygel_samsung_tv_hacks_real_modify_headers (RygelClientHacks* base,
                                            RygelHTTPRequest* request)
{
	RygelSamsungTVHacks * self;
	RygelVideoItem* item = NULL;
	RygelMediaObject* _tmp0_;
	RygelVideoItem* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	SoupMessage* _tmp4_;
	SoupMessageHeaders* _tmp5_;
	const gchar* _tmp6_;
	self = (RygelSamsungTVHacks*) base;
	g_return_if_fail (request != NULL);
	_tmp0_ = request->object;
	_tmp1_ = _g_object_ref0 (RYGEL_IS_VIDEO_ITEM (_tmp0_) ? ((RygelVideoItem*) _tmp0_) : NULL);
	item = _tmp1_;
	_tmp4_ = request->msg;
	_tmp5_ = _tmp4_->request_headers;
	_tmp6_ = soup_message_headers_get_one (_tmp5_, "getCaptionInfo.sec");
	if (_tmp6_ != NULL) {
		RygelVideoItem* _tmp7_;
		_tmp7_ = item;
		_tmp3_ = _tmp7_ != NULL;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		RygelVideoItem* _tmp8_;
		GeeArrayList* _tmp9_;
		GeeArrayList* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		_tmp8_ = item;
		_tmp9_ = rygel_video_item_get_subtitles (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp10_);
		_tmp12_ = _tmp11_;
		_tmp2_ = _tmp12_ > 0;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		gchar* caption_uri = NULL;
		RygelHTTPServer* _tmp13_;
		RygelVideoItem* _tmp14_;
		gchar* _tmp15_;
		SoupMessage* _tmp16_;
		SoupMessageHeaders* _tmp17_;
		const gchar* _tmp18_;
		_tmp13_ = request->http_server;
		_tmp14_ = item;
		_tmp15_ = rygel_http_server_create_uri_for_object (_tmp13_, (RygelMediaObject*) _tmp14_, -1, 0, NULL);
		caption_uri = _tmp15_;
		_tmp16_ = request->msg;
		_tmp17_ = _tmp16_->response_headers;
		_tmp18_ = caption_uri;
		soup_message_headers_append (_tmp17_, "CaptionInfo.sec", _tmp18_);
		_g_free0 (caption_uri);
	}
	_g_object_unref0 (item);
}

static void
rygel_samsung_tv_hacks_class_init (RygelSamsungTVHacksClass * klass,
                                   gpointer klass_data)
{
	GError* _inner_error0_ = NULL;
	rygel_samsung_tv_hacks_parent_class = g_type_class_peek_parent (klass);
	((RygelClientHacksClass *) klass)->apply = (void (*) (RygelClientHacks*, RygelMediaObject*)) rygel_samsung_tv_hacks_real_apply;
	((RygelClientHacksClass *) klass)->force_seek = (gboolean (*) (RygelClientHacks*)) rygel_samsung_tv_hacks_real_force_seek;
	((RygelClientHacksClass *) klass)->modify_headers = (void (*) (RygelClientHacks*, RygelHTTPRequest*)) rygel_samsung_tv_hacks_real_modify_headers;
	G_OBJECT_CLASS (klass)->finalize = rygel_samsung_tv_hacks_finalize;
	{
		GRegex* _tmp0_ = NULL;
		GRegex* _tmp1_;
		GRegex* _tmp2_;
		GRegex* _tmp3_ = NULL;
		GRegex* _tmp4_;
		GRegex* _tmp5_;
		_tmp1_ = g_regex_new ("png", 0, 0, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_regex_unref0 (rygel_samsung_tv_hacks_mime_regex);
		rygel_samsung_tv_hacks_mime_regex = _tmp2_;
		_tmp4_ = g_regex_new ("PNG", 0, 0, &_inner_error0_);
		_tmp3_ = _tmp4_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (_tmp0_);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
		}
		_tmp5_ = _tmp3_;
		_tmp3_ = NULL;
		_g_regex_unref0 (rygel_samsung_tv_hacks_dlna_regex);
		rygel_samsung_tv_hacks_dlna_regex = _tmp5_;
		_g_regex_unref0 (_tmp3_);
		_g_regex_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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_);
	}
}

static void
rygel_samsung_tv_hacks_instance_init (RygelSamsungTVHacks * self,
                                      gpointer klass)
{
}

static void
rygel_samsung_tv_hacks_finalize (GObject * obj)
{
	RygelSamsungTVHacks * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_SAMSUNG_TV_HACKS, RygelSamsungTVHacks);
	G_OBJECT_CLASS (rygel_samsung_tv_hacks_parent_class)->finalize (obj);
}

static GType
rygel_samsung_tv_hacks_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelSamsungTVHacksClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_samsung_tv_hacks_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelSamsungTVHacks), 0, (GInstanceInitFunc) rygel_samsung_tv_hacks_instance_init, NULL };
	GType rygel_samsung_tv_hacks_type_id;
	rygel_samsung_tv_hacks_type_id = g_type_register_static (RYGEL_TYPE_CLIENT_HACKS, "RygelSamsungTVHacks", &g_define_type_info, 0);
	return rygel_samsung_tv_hacks_type_id;
}

GType
rygel_samsung_tv_hacks_get_type (void)
{
	static volatile gsize rygel_samsung_tv_hacks_type_id__once = 0;
	if (g_once_init_enter (&rygel_samsung_tv_hacks_type_id__once)) {
		GType rygel_samsung_tv_hacks_type_id;
		rygel_samsung_tv_hacks_type_id = rygel_samsung_tv_hacks_get_type_once ();
		g_once_init_leave (&rygel_samsung_tv_hacks_type_id__once, rygel_samsung_tv_hacks_type_id);
	}
	return rygel_samsung_tv_hacks_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;
}

