/**
 * web_servicecontroller_scrobbler.h: static function that can be call
 * in order to scrobble music
 * 
 * Copyright: See COPYING file that comes with this distribution
 *
 * Author: Matthias Feistel <hitman_47@users.sourceforge.net>, (C) 2007
 */

#ifndef WEB_SERVICECONNECTOR_SCROBBLER_H_
#define WEB_SERVICECONNECTOR_SCROBBLER_H_

#include <string>

class cWebServiceConnectorScrobbler
{
public:
	/*	
	 s=<sessionID>
	 The Session ID string as returned by the handshake. Required.
	 a[0]=<artist>
	 The artist name. Required.
	 t[0]=<track>
	 The track title. Required.
	 i[0]=<time>
	 The time the track started playing, in UNIX timestamp format (integer number of seconds since 00:00:00, January 1st 1970 UTC). This must be in the UTC time zone, and is required.
	 o[0]=<source>
	 The source of the track. Required, must be one of the following codes:

	 P
	 Chosen by the user
	 R
	 Non-personalised broadcast (e.g. Shoutcast, BBC Radio 1)
	 E
	 Personalised recommendation except Last.fm (e.g. Pandora, Launchcast)
	 L
	 Last.fm (any mode). In this case, the 5-digit Last.fm recommendation key must be appended to this source ID to prove the validity of the submission (for example, "o[0]=L1b48a").
	 U
	 Source unknown

	 r[0]=<rating>
	 The rating of the track. Empty if not applicable.

	 L
	 Love (on any mode if the user has manually loved the track)
	 B
	 Ban (only if source=L)
	 S
	 Skip (only if source=L)

	 Note: Currently, a web-service must also be called to set love/ban status. We anticipate that this will be phased out soon, and the submission service will handle the whole process.
	 l[0]=<secs>
	 The length of the track in seconds. Required when the source is P, optional otherwise.
	 b[0]=<album>
	 The album title, or empty if not known.
	 n[0]=<tracknumber>
	 The position of the track on the album, or empty if not known.
	 m[0]=<mb-trackid>
	 The MusicBrainz Track ID, or empty if not known. 
	 */
	static int Submission( const std::string submissionurl,
			const std::string sessionid, const std::string artist,
			const std::string track, const std::string tracktime,
			const std::string source, const int position, const int total,
			const std::string album = "", const std::string secs = "",
			const std::string tracknumber = "",	const std::string mb_trackid = "",
			const std::string rating = "" );

	/**
	 * 
	 * HandshakeV12
	 * 
	 * ////http://post.audioscrobbler.com/?hs=true&p=1.1&c=<clientid>&v=<clientver>&u=<user>
	 * @param: username
	 * @param: password
	 * 
	 * @return: 0==noerror; 3==scrobbling deactivated
	 */
	static int HandshakeV12( const std::string username,
			const std::string password_md5, std::string &data_npurl,
			std::string &data_protourl, std::string &data_sessionid );

	/*
	 s=<sessionID>
	 The Session ID string as returned by the handshake. Required.
	 a=<artist>
	 The artist name. Required.
	 t=<track>
	 The track name. Required.
	 b=<album>
	 The album title, or empty if not known.
	 l=<secs>
	 The length of the track in seconds, or empty if not known.
	 n=<tracknumber>
	 The position of the track on the album, or empty if not known.
	 m=<mb-trackid>
	 The MusicBrainz Track ID, or empty if not known. 
	 */
	static int NowPlaying(
			const std::string submissionurl, const std::string sessionid,
			const std::string artist, const std::string track,
			const std::string album = "", const std::string secs = "",
			const std::string tracknumber = "", const std::string mb_trackid = "" );

};

#endif // WEB_SERVICECONNECTOR_SCROBBLER_H_
