/* rygel-player-controller.c generated by valac 0.27.2.2-e6bbc, the Vala compiler
 * generated from rygel-player-controller.vala, do not modify */

/*
 * Copyright (C) 2012 Intel Corporation.
 * Copyright (C) 2014 Atlantic PuffinPack AB.
 *
 * Author: Jens Georg <jensg@openismus.com>
 *
 * 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 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 program; 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 <stdlib.h>
#include <string.h>
#include <libgupnp-av/gupnp-av.h>


#define RYGEL_TYPE_PLAYER_CONTROLLER (rygel_player_controller_get_type ())
#define RYGEL_PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_PLAYER_CONTROLLER, RygelPlayerController))
#define RYGEL_IS_PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_PLAYER_CONTROLLER))
#define RYGEL_PLAYER_CONTROLLER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), RYGEL_TYPE_PLAYER_CONTROLLER, RygelPlayerControllerIface))

typedef struct _RygelPlayerController RygelPlayerController;
typedef struct _RygelPlayerControllerIface RygelPlayerControllerIface;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _RygelPlayerControllerIface {
	GTypeInterface parent_iface;
	gboolean (*next) (RygelPlayerController* self);
	gboolean (*previous) (RygelPlayerController* self);
	void (*set_single_play_uri) (RygelPlayerController* self, const gchar* uri, const gchar* metadata, const gchar* mime, const gchar* features);
	void (*set_playlist_uri) (RygelPlayerController* self, const gchar* uri, const gchar* metadata, GUPnPMediaCollection* collection);
	void (*set_next_single_play_uri) (RygelPlayerController* self, const gchar* uri, const gchar* metadata, const gchar* mime, const gchar* features);
	void (*set_next_playlist_uri) (RygelPlayerController* self, const gchar* uri, const gchar* metadata, GUPnPMediaCollection* collection);
	gboolean (*is_play_mode_valid) (RygelPlayerController* self, const gchar* play_mode);
	const gchar* (*get_playback_state) (RygelPlayerController* self);
	void (*set_playback_state) (RygelPlayerController* self, const gchar* value);
	guint (*get_n_tracks) (RygelPlayerController* self);
	void (*set_n_tracks) (RygelPlayerController* self, guint value);
	guint (*get_track) (RygelPlayerController* self);
	void (*set_track) (RygelPlayerController* self, guint value);
	gchar* (*get_uri) (RygelPlayerController* self);
	void (*set_uri) (RygelPlayerController* self, const gchar* value);
	gchar* (*get_metadata) (RygelPlayerController* self);
	void (*set_metadata) (RygelPlayerController* self, const gchar* value);
	gchar* (*get_track_uri) (RygelPlayerController* self);
	void (*set_track_uri) (RygelPlayerController* self, const gchar* value);
	gchar* (*get_track_metadata) (RygelPlayerController* self);
	void (*set_track_metadata) (RygelPlayerController* self, const gchar* value);
	gchar* (*get_next_uri) (RygelPlayerController* self);
	void (*set_next_uri) (RygelPlayerController* self, const gchar* value);
	gchar* (*get_next_metadata) (RygelPlayerController* self);
	void (*set_next_metadata) (RygelPlayerController* self, const gchar* value);
	gchar* (*get_current_transport_actions) (RygelPlayerController* self);
	const gchar* (*get_play_mode) (RygelPlayerController* self);
	void (*set_play_mode) (RygelPlayerController* self, const gchar* value);
};



GType rygel_player_controller_get_type (void) G_GNUC_CONST;
gboolean rygel_player_controller_next (RygelPlayerController* self);
gboolean rygel_player_controller_previous (RygelPlayerController* self);
void rygel_player_controller_set_single_play_uri (RygelPlayerController* self, const gchar* uri, const gchar* metadata, const gchar* mime, const gchar* features);
void rygel_player_controller_set_playlist_uri (RygelPlayerController* self, const gchar* uri, const gchar* metadata, GUPnPMediaCollection* collection);
void rygel_player_controller_set_next_single_play_uri (RygelPlayerController* self, const gchar* uri, const gchar* metadata, const gchar* mime, const gchar* features);
void rygel_player_controller_set_next_playlist_uri (RygelPlayerController* self, const gchar* uri, const gchar* metadata, GUPnPMediaCollection* collection);
gboolean rygel_player_controller_is_play_mode_valid (RygelPlayerController* self, const gchar* play_mode);
gchar* rygel_player_controller_unescape (RygelPlayerController* self, const gchar* input);
const gchar* rygel_player_controller_get_playback_state (RygelPlayerController* self);
void rygel_player_controller_set_playback_state (RygelPlayerController* self, const gchar* value);
guint rygel_player_controller_get_n_tracks (RygelPlayerController* self);
void rygel_player_controller_set_n_tracks (RygelPlayerController* self, guint value);
guint rygel_player_controller_get_track (RygelPlayerController* self);
void rygel_player_controller_set_track (RygelPlayerController* self, guint value);
gchar* rygel_player_controller_get_uri (RygelPlayerController* self);
void rygel_player_controller_set_uri (RygelPlayerController* self, const gchar* value);
gchar* rygel_player_controller_get_metadata (RygelPlayerController* self);
void rygel_player_controller_set_metadata (RygelPlayerController* self, const gchar* value);
gchar* rygel_player_controller_get_track_uri (RygelPlayerController* self);
void rygel_player_controller_set_track_uri (RygelPlayerController* self, const gchar* value);
gchar* rygel_player_controller_get_track_metadata (RygelPlayerController* self);
void rygel_player_controller_set_track_metadata (RygelPlayerController* self, const gchar* value);
gchar* rygel_player_controller_get_next_uri (RygelPlayerController* self);
void rygel_player_controller_set_next_uri (RygelPlayerController* self, const gchar* value);
gchar* rygel_player_controller_get_next_metadata (RygelPlayerController* self);
void rygel_player_controller_set_next_metadata (RygelPlayerController* self, const gchar* value);
gchar* rygel_player_controller_get_current_transport_actions (RygelPlayerController* self);
const gchar* rygel_player_controller_get_play_mode (RygelPlayerController* self);
void rygel_player_controller_set_play_mode (RygelPlayerController* self, const gchar* value);


gboolean rygel_player_controller_next (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, FALSE);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->next (self);
}


gboolean rygel_player_controller_previous (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, FALSE);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->previous (self);
}


void rygel_player_controller_set_single_play_uri (RygelPlayerController* self, const gchar* uri, const gchar* metadata, const gchar* mime, const gchar* features) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_single_play_uri (self, uri, metadata, mime, features);
}


void rygel_player_controller_set_playlist_uri (RygelPlayerController* self, const gchar* uri, const gchar* metadata, GUPnPMediaCollection* collection) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_playlist_uri (self, uri, metadata, collection);
}


void rygel_player_controller_set_next_single_play_uri (RygelPlayerController* self, const gchar* uri, const gchar* metadata, const gchar* mime, const gchar* features) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_next_single_play_uri (self, uri, metadata, mime, features);
}


void rygel_player_controller_set_next_playlist_uri (RygelPlayerController* self, const gchar* uri, const gchar* metadata, GUPnPMediaCollection* collection) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_next_playlist_uri (self, uri, metadata, collection);
}


gboolean rygel_player_controller_is_play_mode_valid (RygelPlayerController* self, const gchar* play_mode) {
	g_return_val_if_fail (self != NULL, FALSE);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->is_play_mode_valid (self, play_mode);
}


static gchar* string_replace (const gchar* self, const gchar* old, const gchar* replacement) {
	gchar* result = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	{
		GRegex* regex = NULL;
		const gchar* _tmp0_ = NULL;
		gchar* _tmp1_ = NULL;
		gchar* _tmp2_ = NULL;
		GRegex* _tmp3_ = NULL;
		GRegex* _tmp4_ = NULL;
		gchar* _tmp5_ = NULL;
		GRegex* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		gchar* _tmp8_ = NULL;
		gchar* _tmp9_ = NULL;
		_tmp0_ = old;
		_tmp1_ = g_regex_escape_string (_tmp0_, -1);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_regex_new (_tmp2_, 0, 0, &_inner_error_);
		_tmp4_ = _tmp3_;
		_g_free0 (_tmp2_);
		regex = _tmp4_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch1_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp6_ = regex;
		_tmp7_ = replacement;
		_tmp8_ = g_regex_replace_literal (_tmp6_, self, (gssize) (-1), 0, _tmp7_, 0, &_inner_error_);
		_tmp5_ = _tmp8_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch1_g_regex_error;
			}
			_g_regex_unref0 (regex);
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp9_ = _tmp5_;
		_tmp5_ = NULL;
		result = _tmp9_;
		_g_free0 (_tmp5_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally1;
	__catch1_g_regex_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		g_assert_not_reached ();
		_g_error_free0 (e);
	}
	__finally1:
	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;
	}
}


gchar* rygel_player_controller_unescape (RygelPlayerController* self, const gchar* input) {
	gchar* result = NULL;
	gchar* _result_ = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	const gchar* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	g_return_val_if_fail (input != NULL, NULL);
	_tmp0_ = input;
	_tmp1_ = string_replace (_tmp0_, "&quot;", "\"");
	_result_ = _tmp1_;
	_tmp2_ = _result_;
	_tmp3_ = string_replace (_tmp2_, "&lt;", "<");
	_g_free0 (_result_);
	_result_ = _tmp3_;
	_tmp4_ = _result_;
	_tmp5_ = string_replace (_tmp4_, "&gt;", ">");
	_g_free0 (_result_);
	_result_ = _tmp5_;
	_tmp6_ = _result_;
	_tmp7_ = string_replace (_tmp6_, "&apos;", "'");
	_g_free0 (_result_);
	_result_ = _tmp7_;
	_tmp8_ = _result_;
	_tmp9_ = string_replace (_tmp8_, "&amp;", "&");
	_g_free0 (_result_);
	_result_ = _tmp9_;
	result = _result_;
	return result;
}


const gchar* rygel_player_controller_get_playback_state (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->get_playback_state (self);
}


void rygel_player_controller_set_playback_state (RygelPlayerController* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_playback_state (self, value);
}


guint rygel_player_controller_get_n_tracks (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, 0U);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->get_n_tracks (self);
}


void rygel_player_controller_set_n_tracks (RygelPlayerController* self, guint value) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_n_tracks (self, value);
}


guint rygel_player_controller_get_track (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, 0U);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->get_track (self);
}


void rygel_player_controller_set_track (RygelPlayerController* self, guint value) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_track (self, value);
}


gchar* rygel_player_controller_get_uri (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->get_uri (self);
}


void rygel_player_controller_set_uri (RygelPlayerController* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_uri (self, value);
}


gchar* rygel_player_controller_get_metadata (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->get_metadata (self);
}


void rygel_player_controller_set_metadata (RygelPlayerController* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_metadata (self, value);
}


gchar* rygel_player_controller_get_track_uri (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->get_track_uri (self);
}


void rygel_player_controller_set_track_uri (RygelPlayerController* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_track_uri (self, value);
}


gchar* rygel_player_controller_get_track_metadata (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->get_track_metadata (self);
}


void rygel_player_controller_set_track_metadata (RygelPlayerController* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_track_metadata (self, value);
}


gchar* rygel_player_controller_get_next_uri (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->get_next_uri (self);
}


void rygel_player_controller_set_next_uri (RygelPlayerController* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_next_uri (self, value);
}


gchar* rygel_player_controller_get_next_metadata (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->get_next_metadata (self);
}


void rygel_player_controller_set_next_metadata (RygelPlayerController* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_next_metadata (self, value);
}


gchar* rygel_player_controller_get_current_transport_actions (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->get_current_transport_actions (self);
}


const gchar* rygel_player_controller_get_play_mode (RygelPlayerController* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->get_play_mode (self);
}


void rygel_player_controller_set_play_mode (RygelPlayerController* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	RYGEL_PLAYER_CONTROLLER_GET_INTERFACE (self)->set_play_mode (self, value);
}


static void rygel_player_controller_base_init (RygelPlayerControllerIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
		g_object_interface_install_property (iface, g_param_spec_string ("playback-state", "playback-state", "playback-state", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
		g_object_interface_install_property (iface, g_param_spec_uint ("n-tracks", "n-tracks", "n-tracks", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
		g_object_interface_install_property (iface, g_param_spec_uint ("track", "track", "track", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
		g_object_interface_install_property (iface, g_param_spec_string ("uri", "uri", "uri", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
		g_object_interface_install_property (iface, g_param_spec_string ("metadata", "metadata", "metadata", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
		g_object_interface_install_property (iface, g_param_spec_string ("track-uri", "track-uri", "track-uri", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
		g_object_interface_install_property (iface, g_param_spec_string ("track-metadata", "track-metadata", "track-metadata", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
		g_object_interface_install_property (iface, g_param_spec_string ("next-uri", "next-uri", "next-uri", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
		g_object_interface_install_property (iface, g_param_spec_string ("next-metadata", "next-metadata", "next-metadata", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
		g_object_interface_install_property (iface, g_param_spec_string ("current-transport-actions", "current-transport-actions", "current-transport-actions", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
		g_object_interface_install_property (iface, g_param_spec_string ("play-mode", "play-mode", "play-mode", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	}
}


/**
 * This class keeps track of global states that are not dependant on the
 * RygelMediaPlayer.
 *
 * These states are:
 * # URI
 * # MetaData
 * # Number of tracks
 * # Current track
 * # Playback state
 *
 * In case of playlists this class will also control the player. It needs to
 * proxy the playback state to react on end of item to be able to switch to
 * the next item.
 */
GType rygel_player_controller_get_type (void) {
	static volatile gsize rygel_player_controller_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_player_controller_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelPlayerControllerIface), (GBaseInitFunc) rygel_player_controller_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType rygel_player_controller_type_id;
		rygel_player_controller_type_id = g_type_register_static (G_TYPE_INTERFACE, "RygelPlayerController", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (rygel_player_controller_type_id, G_TYPE_OBJECT);
		g_once_init_leave (&rygel_player_controller_type_id__volatile, rygel_player_controller_type_id);
	}
	return rygel_player_controller_type_id__volatile;
}



