/**
 * osd_userinterface_data_releatedArtists.c: Presents metadata
 * 
 * Copyright: See COPYING file that comes with this distribution
 *
 * Author: Matthias Feistel <hitman_47@users.sourceforge.net>, (C) 2006, 2007
 */

#include <vector>
#include <vdr/interface.h>
#include <vdr/menu.h>
#include <vdr/plugin.h>
#include "osd_userinterface_data_relatedArtists.h"
#include "settings.h"
#include "web_metadata.h"

cUserInterface_Data_relatedArtists::cUserInterface_Data_relatedArtists( )
:cOsdMenu( tr( "relatedArtists" ), 20 )
{
	cSettings::GetInstance().SetOsd_Path( "relatedartists" );
	// OSD-Elemente aufbauen
	BuildItems( );
}

cUserInterface_Data_relatedArtists::~cUserInterface_Data_relatedArtists( )
{
	cSettings::GetInstance().SetOsd_Path( "data" );
	///rlog << "relatedArtists destroyed";
}

void cUserInterface_Data_relatedArtists::BuildItems( void )
{
	WebServiceConnector = new cWebServiceConnector();
	cMetaData_relatedArtists
			MetaData_relatedArtists = WebServiceConnector->relatedArtists( );
	
	if( WebServiceConnector )
	{
		delete WebServiceConnector;
		WebServiceConnector = 0;
	}

	std::vector<std::string>::iterator
			it_streamable = MetaData_relatedArtists.m_streamable.begin( );
	std::vector<std::string>::iterator
			it_match = MetaData_relatedArtists.m_match.begin( );
	
	for( std::vector<std::string>::iterator
			it = MetaData_relatedArtists.m_name.begin( ); it
			!= MetaData_relatedArtists.m_name.end( ); it++ )
	{
		std::string it_string = *it;

		std::string it_string_streamable = *it_streamable;
		std::string it_match_date = *it_match;

		Add( new cOsdItem(hk( it_string.c_str( ) ) ) );
		///      Add(new cOsdItem(hk(it_string_streamable.c_str())));
		///      Add(new cOsdItem(hk(it_string_match.c_str())));
		Add( new cOsdItem( hk( "" ) ) ); ///Trennzeile
		it_streamable++;
		it_match++;
	}

	Display( );
}

eOSState cUserInterface_Data_relatedArtists::ProcessKey( eKeys Key )
{
	eOSState state = cOsdMenu::ProcessKey( Key );
	if( strcmp( cSettings::GetInstance().GetOsd_Path( ), "relatedartists" ) == 0 ) ///also: wenn gleich...
	{
		switch( Key )
		{
		// cases f�r bereits belegte Tasten werden erw�hnt, damit die vom dar�berliegenden Men� gleicherma�en belegten Tasten ignoriert werden.
		case kOk:
			///rlog << "OK in cUserInterface_Data_relatedArtists";
			///rlog << "POS: "<< Current( );
			return osContinue;

		default:
			break;
		}
	}

	return state;
}
