example/lastfmmusicserviceplugin/lastfmmusicserviceplugin.cpp
author cgandhi
Thu, 23 Sep 2010 17:15:03 +0530
changeset 23 574948b60dab
child 26 83d6a149c755
permissions -rw-r--r--
updating the lastfm music plugins and adding the smfhelp.chm
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
     1
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
     2
 * Copyright (c) 2010 Sasken Communication Technologies Ltd.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
     3
 * All rights reserved.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
     5
 * under the terms of the "Eclipse Public License v1.0"
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
     6
 * which accompanies  this distribution, and is available
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html"
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
     8
 *
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
     9
 * Initial Contributors:
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    10
 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    11
 *
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    12
 * Contributors:
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    13
 * Nalina Hariharan
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    14
 *
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    15
 * Description:
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    16
 * The Plugin that does music services related functionalities from last.fm site
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    17
 *
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    18
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    19
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    20
// Include files
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    21
#include <QtPlugin>
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    22
#include <QDebug>
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    23
#include <QCryptographicHash>
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    24
#include <QTextStream>
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    25
#include <QFile>
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    26
#include <QMap>
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    27
#include <QListIterator>
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    28
#include <QSettings>
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    29
#include <smfpluginutil.h>
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    30
#include <smfcontact.h>
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    31
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    32
#include "lastfmmusicserviceplugin.h"
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    33
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    34
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    35
static int gPageNum = 0; 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    36
static int gItemsPerPage = 0;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    37
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    38
QString gUserId;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    39
static int userMusicInfoChance = 0;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    40
QList<SmfTrackInfo> gRecentTracks;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    41
QList<SmfTrackInfo> gFavorites;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    42
QList<SmfEvent> gUserEvents;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    43
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    44
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    45
 * Destructor
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    46
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    47
LastFmMusicServicePlugin::~LastFmMusicServicePlugin( )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    48
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    49
	if(m_provider)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    50
		delete m_provider;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    51
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    52
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    53
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    54
 * Method to interpret the key sets obtained from credential manager 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    55
 * @param aApiKey [out] The api key
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    56
 * @param aApiSecret [out] The api secret
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    57
 * @param aSessionKey [out] The session key
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    58
 * @param aToken [out] The session token
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    59
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    60
void LastFmMusicServicePlugin::fetchKeys( QString &aApiKey, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    61
		QString &aApiSecret, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    62
		QString &aToken,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    63
		QString &aName )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    64
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    65
	qDebug()<<"Reg Token = "<<m_provider->m_smfRegToken;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    66
	qDebug()<<"Expiry Date as int = "<<m_provider->m_validity.toTime_t();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    67
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    68
	SmfAuthParams keys;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    69
	SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    70
	util.getAuthKeys(keys, m_provider->m_smfRegToken, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    71
			m_provider->m_validity, m_provider->m_pluginId);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    72
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    73
    QByteArray keyName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    74
    keyName.append("ApiKey");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    75
	aApiKey.append(keys.value(keyName));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    76
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    77
    keyName.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    78
    keyName.append("ApiSecret");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    79
	aApiSecret.append(keys.value(keyName));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    80
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    81
	keyName.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    82
    keyName.append("Token");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    83
	aToken.append(keys.value(keyName));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    84
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    85
	keyName.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    86
    keyName.append("Name");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    87
	aName.append(keys.value(keyName));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    88
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    89
	qDebug()<<"Api Key = "<<aApiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    90
	qDebug()<<"Api Secret = "<<aApiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    91
	qDebug()<<"Token = "<<aToken;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    92
	qDebug()<<"Name = "<<aName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    93
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    94
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    95
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    96
 * Method called by plugins to generate a signature string from a base string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    97
 * @param aBaseString The base string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    98
 * @return The md5 hash of the base string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    99
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   100
QString LastFmMusicServicePlugin::generateSignature(const QString aBaseString)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   101
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   102
	// Create md5 hash of the signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   103
    QByteArray byteArray;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   104
    byteArray.insert(0, aBaseString.toAscii());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   105
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   106
    QByteArray md5Hash = QCryptographicHash::hash(byteArray,QCryptographicHash::Md5 ).toHex();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   107
    QString returnString (md5Hash);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   108
    return returnString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   109
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   110
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   111
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   112
 * Method to get self profile information
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   113
 * @param aRequest [out] The request data to be sent to network
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   114
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   115
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   116
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   117
SmfPluginError LastFmMusicServicePlugin::userMusicInfo( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   118
		SmfPluginRequestData &aRequest )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   119
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   120
	qDebug()<<"Inside LastFmMusicServicePlugin::userMusicInfo()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   121
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   122
	SmfPluginError error = SmfPluginErrInvalidArguments;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   123
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   124
	// Get the key sets from SMF Plugin Utility class.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   125
	QString apiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   126
	QString apiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   127
	QString token;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   128
	QString userName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   129
	fetchKeys(apiKey, apiSecret, token, userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   130
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   131
	// Get the current logged in user id
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   132
	if(0 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   133
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   134
		// Clear the global variables
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   135
		gUserId.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   136
		gRecentTracks.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   137
		gFavorites.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   138
		gUserEvents.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   139
		gPageNum = 1;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   140
		gItemsPerPage = 5;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   141
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   142
		// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   143
		QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   144
		baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   145
		baseString.append("methoduser.getInfo");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   146
		baseString.append("user"+userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   147
		baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   148
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   149
		// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   150
		QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   151
		url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   152
		url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   153
		url.addQueryItem("method", "user.getInfo");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   154
		url.addQueryItem("user", userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   155
		url.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   156
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   157
		// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   158
		aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   159
		aRequest.iRequestType = SmfMusicGetUserInfo;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   160
		aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   161
		aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   162
		error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   163
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   164
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   165
	// Getting the user's recent tracks
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   166
	else if(1 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   167
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   168
		// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   169
		QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   170
		baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   171
		baseString.append("limit"+QString::number(gItemsPerPage));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   172
		baseString.append("methoduser.getRecentTracks");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   173
		baseString.append("page"+QString::number(gPageNum));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   174
		baseString.append("user"+userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   175
		baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   176
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   177
		// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   178
		QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   179
		url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   180
		url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   181
		url.addQueryItem("limit", QString::number(gItemsPerPage));		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   182
		url.addQueryItem("method", "user.getRecentTracks");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   183
		url.addQueryItem("page", QString::number(gPageNum));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   184
		url.addQueryItem("user", userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   185
		url.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   186
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   187
		// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   188
		aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   189
		aRequest.iRequestType = SmfMusicGetUserInfo;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   190
		aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   191
		aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   192
		error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   193
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   194
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   195
	// Getting the user's favorites
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   196
	else if(2 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   197
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   198
		// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   199
		QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   200
		baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   201
		baseString.append("limit"+QString::number(gItemsPerPage));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   202
		baseString.append("methoduser.getLovedTracks");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   203
		baseString.append("page"+QString::number(gPageNum));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   204
		baseString.append("user"+userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   205
		baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   206
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   207
		// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   208
		QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   209
		url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   210
		url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   211
		url.addQueryItem("limit", QString::number(gItemsPerPage));		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   212
		url.addQueryItem("method", "user.getLovedTracks");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   213
		url.addQueryItem("page", QString::number(gPageNum));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   214
		url.addQueryItem("user", userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   215
		url.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   216
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   217
		// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   218
		aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   219
		aRequest.iRequestType = SmfMusicGetUserInfo;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   220
		aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   221
		aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   222
		error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   223
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   224
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   225
	// Get the user's events
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   226
	else //if(3 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   227
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   228
		// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   229
		QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   230
		baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   231
		baseString.append("methoduser.getEvents");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   232
		baseString.append("user"+userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   233
		baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   234
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   235
		// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   236
		QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   237
		url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   238
		url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   239
		url.addQueryItem("method", "user.getEvents");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   240
		url.addQueryItem("user", userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   241
		url.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   242
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   243
		// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   244
		aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   245
		aRequest.iRequestType = SmfMusicGetUserInfo;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   246
		aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   247
		aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   248
		error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   249
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   250
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   251
	qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   252
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   253
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   254
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   255
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   256
 * Method to search information about artists. All information 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   257
 * in SmfArtists is not required, however more available the better
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   258
 * @param aRequest [out] The request data to be sent to network
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   259
 * @param aArtist The artist which is the search criteria
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   260
 * @param aPageNum The page to be extracted
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   261
 * @param aItemsPerPage Number of items per page
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   262
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   263
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   264
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   265
SmfPluginError LastFmMusicServicePlugin::searchArtist( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   266
		SmfPluginRequestData &aRequest,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   267
		const SmfArtists &aArtist,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   268
		const int aPageNum , 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   269
		const int aItemsPerPage )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   270
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   271
	qDebug()<<"Inside LastFmMusicServicePlugin::searchArtist()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   272
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   273
	SmfPluginError error = SmfPluginErrInvalidArguments;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   274
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   275
	// invalid arguments
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   276
	if( aPageNum < 0 || aItemsPerPage < 0 || aArtist.names().at(0).isEmpty() )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   277
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   278
		qDebug()<<"Invalid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   279
		return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   280
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   281
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   282
	qDebug()<<"Valid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   283
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   284
	gPageNum = aPageNum;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   285
	gItemsPerPage = aItemsPerPage;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   286
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   287
	// Get the key sets from SMF Plugin Utility class.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   288
	QString apiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   289
	QString apiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   290
	QString token;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   291
	QString userName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   292
	fetchKeys(apiKey, apiSecret, token, userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   293
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   294
	// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   295
	QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   296
	baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   297
	baseString.append("artist"+aArtist.names().at(0));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   298
	baseString.append("limit"+QString::number(aItemsPerPage));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   299
	baseString.append("methodartist.search");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   300
	baseString.append("page"+QString::number(aPageNum));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   301
	baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   302
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   303
	// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   304
	QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   305
	url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   306
	url.addQueryItem("artist", aArtist.names().at(0));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   307
	url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   308
	url.addQueryItem("limit", QString::number(aItemsPerPage));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   309
	url.addQueryItem("page", QString::number(aPageNum));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   310
	url.addQueryItem("method", "artist.search");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   311
	url.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   312
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   313
	// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   314
	aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   315
	aRequest.iRequestType = SmfMusicSearchArtist;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   316
	aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   317
	aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   318
	error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   319
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   320
	qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   321
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   322
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   323
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   324
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   325
 * Method to search information about album. All information 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   326
 * in SmfAlbum is not required, however more available the better
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   327
 * @param aRequest [out] The request data to be sent to network
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   328
 * @param aAlbum [in] The album which is the search criteria
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   329
 * @param aPageNum [in] The page to be extracted
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   330
 * @param aItemsPerPage [in] Number of items per page
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   331
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   332
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   333
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   334
SmfPluginError LastFmMusicServicePlugin::searchAlbum( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   335
		SmfPluginRequestData &aRequest,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   336
		const SmfAlbum &aAlbum,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   337
		const int aPageNum, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   338
		const int aItemsPerPage )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   339
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   340
	qDebug()<<"Inside LastFmMusicServicePlugin::searchAlbum()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   341
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   342
	SmfPluginError error = SmfPluginErrInvalidArguments;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   343
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   344
	// invalid arguments
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   345
	if( aPageNum < 0 || aItemsPerPage < 0 || aAlbum.name().isEmpty() )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   346
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   347
		qDebug()<<"Invalid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   348
		return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   349
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   350
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   351
	qDebug()<<"Valid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   352
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   353
	gPageNum = aPageNum;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   354
	gItemsPerPage = aItemsPerPage;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   355
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   356
	// Get the key sets from SMF Plugin Utility class.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   357
	QString apiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   358
	QString apiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   359
	QString token;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   360
	QString userName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   361
	fetchKeys(apiKey, apiSecret, token, userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   362
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   363
	// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   364
	QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   365
	baseString.append("album"+aAlbum.name());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   366
	baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   367
	baseString.append("limit"+QString::number(aItemsPerPage));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   368
	baseString.append("methodalbum.search");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   369
	baseString.append("page"+QString::number(aPageNum));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   370
	baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   371
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   372
	// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   373
	QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   374
	url.addQueryItem("album", aAlbum.name());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   375
	url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   376
	url.addQueryItem("limit", QString::number(aItemsPerPage));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   377
	url.addQueryItem("page", QString::number(aPageNum));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   378
	url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   379
	url.addQueryItem("method", "album.search");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   380
	url.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   381
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   382
	// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   383
	aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   384
	aRequest.iRequestType = SmfMusicSearchAlbum;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   385
	aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   386
	aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   387
	error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   388
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   389
	qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   390
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   391
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   392
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   393
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   394
 * Method to search information about events. All information 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   395
 * in SmfEvent is not required, however more available the better
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   396
 * @param aRequest [out] The request data to be sent to network
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   397
 * @param aEvent [in] The event which is the search criteria
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   398
 * @param aPageNum [in] The page to be extracted
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   399
 * @param aItemsPerPage [in] Number of items per page
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   400
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   401
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   402
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   403
SmfPluginError LastFmMusicServicePlugin::searchEvents( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   404
		SmfPluginRequestData &aRequest,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   405
		const SmfEvent &aEvent,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   406
		const int aPageNum, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   407
		const int aItemsPerPage )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   408
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   409
	qDebug()<<"Inside LastFmMusicServicePlugin::searchEvents()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   410
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   411
	SmfPluginError error = SmfPluginErrInvalidArguments;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   412
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   413
	// invalid arguments
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   414
	if( aPageNum < 0 || aItemsPerPage < 0 || aEvent.id().isEmpty() )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   415
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   416
		qDebug()<<"Invalid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   417
		return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   418
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   419
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   420
	qDebug()<<"Valid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   421
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   422
	gPageNum = aPageNum;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   423
	gItemsPerPage = aItemsPerPage;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   424
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   425
	// Get the key sets from SMF Plugin Utility class.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   426
	QString apiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   427
	QString apiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   428
	QString token;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   429
	QString userName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   430
	fetchKeys(apiKey, apiSecret, token, userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   431
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   432
	// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   433
	QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   434
	baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   435
	baseString.append("event"+aEvent.id());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   436
	baseString.append("methodevent.getInfo");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   437
	baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   438
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   439
	// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   440
	QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   441
	url.addQueryItem("event", aEvent.id());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   442
	url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   443
	url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   444
	url.addQueryItem("method", "event.getInfo");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   445
	url.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   446
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   447
	// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   448
	aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   449
	aRequest.iRequestType = SmfMusicSearchEvent;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   450
	aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   451
	aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   452
	error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   453
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   454
	qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   455
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   456
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   457
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   458
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   459
 * Method to search information about venue. All information 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   460
 * in SmfLocation is not required, however more available the better
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   461
 * @param aRequest [out] The request data to be sent to network
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   462
 * @param aVenue [in] The venue which is the search criteria
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   463
 * @param aPageNum [in] The page to be extracted
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   464
 * @param aItemsPerPage [in] Number of items per page
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   465
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   466
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   467
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   468
SmfPluginError LastFmMusicServicePlugin::searchVenue( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   469
		SmfPluginRequestData &aRequest,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   470
		const SmfLocation &aVenue,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   471
		const int aPageNum, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   472
		const int aItemsPerPage )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   473
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   474
	qDebug()<<"Inside LastFmMusicServicePlugin::searchVenue()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   475
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   476
	SmfPluginError error = SmfPluginErrInvalidArguments;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   477
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   478
	// invalid arguments
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   479
	if( aPageNum < 0 || aItemsPerPage < 0 || aVenue.name().isEmpty() )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   480
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   481
		qDebug()<<"Invalid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   482
		return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   483
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   484
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   485
	qDebug()<<"Valid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   486
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   487
	gPageNum = aPageNum;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   488
	gItemsPerPage = aItemsPerPage;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   489
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   490
	// Get the key sets from SMF Plugin Utility class.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   491
	QString apiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   492
	QString apiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   493
	QString token;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   494
	QString userName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   495
	fetchKeys(apiKey, apiSecret, token, userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   496
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   497
	// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   498
	QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   499
	baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   500
	baseString.append("limit"+QString::number(aItemsPerPage));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   501
	baseString.append("methodvenue.search");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   502
	baseString.append("page"+QString::number(aPageNum));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   503
	baseString.append("venue"+aVenue.name());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   504
	baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   505
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   506
	// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   507
	QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   508
	url.addQueryItem("venue", aVenue.name());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   509
	url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   510
	url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   511
	url.addQueryItem("limit", QString::number(aItemsPerPage));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   512
	url.addQueryItem("page", QString::number(aPageNum));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   513
	url.addQueryItem("method", "venue.search");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   514
	url.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   515
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   516
	// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   517
	aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   518
	aRequest.iRequestType = SmfMusicSearchVenue;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   519
	aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   520
	aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   521
	error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   522
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   523
	qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   524
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   525
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   526
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   527
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   528
 * Method to search information about other service users for a 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   529
 * particular place
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   530
 * @param aRequest [out] The request data to be sent to network
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   531
 * @param aPlace [in] The place which is the search criteria
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   532
 * @param aPageNum [in] The page to be extracted
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   533
 * @param aItemsPerPage [in] Number of items per page
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   534
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   535
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   536
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   537
SmfPluginError LastFmMusicServicePlugin::searchUser( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   538
		SmfPluginRequestData &aRequest,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   539
		const SmfLocation &aPlace,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   540
		const int aPageNum, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   541
		const int aItemsPerPage )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   542
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   543
	Q_UNUSED(aRequest)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   544
	Q_UNUSED(aPlace)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   545
	Q_UNUSED(aPageNum)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   546
	Q_UNUSED(aItemsPerPage)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   547
	qDebug()<<"Inside LastFmMusicServicePlugin::searchUser()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   548
	SmfPluginError error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   549
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   550
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   551
#if 0
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   552
	Q_UNUSED(aPlace)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   553
	qDebug()<<"Inside LastFmMusicServicePlugin::searchUser()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   554
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   555
	SmfPluginError error = SmfPluginErrInvalidArguments;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   556
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   557
	// invalid arguments
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   558
	if( aPageNum < 0 || aItemsPerPage < 0 )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   559
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   560
		qDebug()<<"Invalid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   561
		return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   562
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   563
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   564
	qDebug()<<"Valid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   565
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   566
	// Get the key sets from SMF Plugin Utility class.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   567
	QString apiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   568
	QString apiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   569
	QString token;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   570
	QString userName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   571
	fetchKeys(apiKey, apiSecret, token, userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   572
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   573
	// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   574
	QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   575
	baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   576
	baseString.append("methoduser.getNeighbours");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   577
	baseString.append("user"+userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   578
	baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   579
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   580
	// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   581
	QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   582
	url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   583
	url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   584
	url.addQueryItem("method", "user.getNeighbours");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   585
	url.addQueryItem("user", userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   586
	url.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   587
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   588
	// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   589
	aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   590
	aRequest.iRequestType = SmfMusicSearchUser;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   591
	aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   592
	aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   593
	error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   594
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   595
	qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   596
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   597
#endif
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   598
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   599
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   600
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   601
 * Method to post the currently playing track
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   602
 * @param aRequest [out] The request data to be sent to network
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   603
 * @param aTrack [in] The current playing track, that should be posted
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   604
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   605
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   606
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   607
SmfPluginError LastFmMusicServicePlugin::postCurrentPlaying( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   608
		SmfPluginRequestData &aRequest,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   609
		const SmfTrackInfo &aTrack )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   610
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   611
	Q_UNUSED(aRequest)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   612
	Q_UNUSED(aTrack)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   613
	qDebug()<<"Inside LastFmMusicServicePlugin::postCurrentPlaying()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   614
	SmfPluginError error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   615
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   616
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   617
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   618
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   619
 * Method to post the rating on a track
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   620
 * @param aRequest [out] The request data to be sent to network
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   621
 * @param aTrack [in] The track on which rating should be posted
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   622
 * @param aRating [in] The rating values
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   623
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   624
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   625
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   626
SmfPluginError LastFmMusicServicePlugin::postRating( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   627
		SmfPluginRequestData &aRequest, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   628
		const SmfTrackInfo &aTrack, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   629
		const SmfMusicRating &aRating )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   630
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   631
	Q_UNUSED(aRequest)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   632
	Q_UNUSED(aTrack)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   633
	Q_UNUSED(aRating)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   634
	qDebug()<<"Inside LastFmMusicServicePlugin::postRating()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   635
	SmfPluginError error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   636
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   637
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   638
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   639
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   640
 * Method to post comment on a track
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   641
 * @param aRequest [out] The request data to be sent to network
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   642
 * @param aTrack [in] The track on which comment should be posted
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   643
 * @param aComment [in] The comment content
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   644
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   645
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   646
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   647
SmfPluginError LastFmMusicServicePlugin::postComments( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   648
		SmfPluginRequestData &aRequest, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   649
		const SmfTrackInfo &aTrack, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   650
		const SmfComment &aComment )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   651
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   652
	Q_UNUSED(aRequest)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   653
	Q_UNUSED(aTrack)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   654
	Q_UNUSED(aComment)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   655
	qDebug()<<"Inside LastFmMusicServicePlugin::postComments()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   656
	SmfPluginError error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   657
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   658
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   659
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   660
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   661
 * Customised method for SmfMusicServicePlugin interface
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   662
 * @param aRequest [out] The request data to be sent to network
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   663
 * @param aOperation [in] The operation type (should be known between 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   664
 * the client interface and the plugin)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   665
 * @param aData [in] The data required to form the request (The type 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   666
 * of data should be known between client and the plugin)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   667
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   668
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   669
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   670
SmfPluginError LastFmMusicServicePlugin::customRequest( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   671
		SmfPluginRequestData &aRequest, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   672
		const int &aOperation, QByteArray *aData )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   673
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   674
	Q_UNUSED(aRequest)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   675
	Q_UNUSED(aOperation)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   676
	Q_UNUSED(aData)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   677
	qDebug()<<"Inside LastFmMusicServicePlugin::customRequest()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   678
	SmfPluginError error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   679
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   680
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   681
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   682
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   683
 * The first method to be called in the plugin that implements this interface.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   684
 * If this method is not called, plugin may not behave as expected.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   685
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   686
void LastFmMusicServicePlugin::initialize( )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   687
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   688
	// Create an instance of LastFmMusicServiceProviderBase
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   689
	m_provider = new LastFmMusicServiceProviderBase;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   690
	m_provider->initialize();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   691
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   692
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   693
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   694
 * Method to get the provider information
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   695
 * @return Instance of SmfProviderBase
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   696
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   697
SmfProviderBase* LastFmMusicServicePlugin::getProviderInfo( )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   698
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   699
	return m_provider;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   700
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   701
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   702
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   703
 * Method to get the result for a network request.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   704
 * @param aOperation The type of operation to be requested
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   705
 * @param aTransportResult The result of transport operation
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   706
 * @param aResponse The QByteArray instance containing the network response.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   707
 * The plugins should delete this instance once they have read the 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   708
 * data from it.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   709
 * @param aResult [out] An output parameter to the plugin manager.If the 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   710
 * return value is SmfSendRequestAgain, QVariant will be of type 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   711
 * SmfPluginRequestData.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   712
 * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   713
 * will be of type SmfMusicProfile. If last operation was searchArtist(),
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   714
 * aResult will be of type QList<SmfArtists>. If last operation was searchAlbum(),
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   715
 * aResult will be of type QList<SmfAlbum>. If last operation was searchEvents(),
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   716
 * aResult will be of type QList<SmfEvent>. If last operation was searchVenue(),
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   717
 * aResult will be of type QList<Smfocation>. If last operation was searchUser(),
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   718
 * aResult will be of type QList<SmfMusicProfile>. If last operation was
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   719
 * postCurrentPlaying() or postRating() or postComments(), aResult will be of
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   720
 * type bool.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   721
 * @param aRetType [out] SmfPluginRetType
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   722
 * @param aPageResult [out] The SmfResultPage structure variable
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   723
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   724
SmfPluginError LastFmMusicServicePlugin::responseAvailable( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   725
		const SmfRequestTypeID aOperation,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   726
		const SmfTransportResult &aTransportResult, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   727
		QByteArray *aResponse, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   728
		QVariant* aResult, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   729
		SmfPluginRetType &aRetType,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   730
		SmfResultPage &aPageResult )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   731
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   732
	Q_UNUSED(aPageResult)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   733
	qDebug()<<"Inside LastFmMusicServicePlugin::responseAvailable()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   734
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   735
	SmfPluginError error = SmfPluginErrNetworkError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   736
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   737
	if( !aResponse || (0 == aResponse->size()) )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   738
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   739
		qDebug()<<"Response is NULL or empty";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   740
		aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   741
		return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   742
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   743
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   744
	QByteArray response(*aResponse);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   745
	delete aResponse;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   746
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   747
	QFile respFile("c://data//SmfMusicServicePluginResponse.txt");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   748
	if(!respFile.open(QIODevice::WriteOnly))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   749
		qDebug()<<"File to write the response could not be opened";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   750
	else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   751
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   752
		respFile.write(response);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   753
		respFile.close();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   754
		qDebug()<<"Writing FB response to a file named 'SmfMusicServicePluginResponse.txt'";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   755
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   756
	qDebug()<<"FB response size = "<<response.size();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   757
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   758
	if(SmfTransportOpNoError == aTransportResult)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   759
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   760
		qDebug()<<"No transport error";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   761
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   762
		// Get music user info
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   763
		if(SmfMusicGetUserInfo == aOperation)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   764
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   765
			qDebug()<<"Response for getting user profile";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   766
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   767
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   768
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   769
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   770
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   771
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   772
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   773
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   774
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   775
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   776
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   777
				return SmfPluginErrParsingFailed;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   778
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   779
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   780
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   781
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   782
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   783
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   784
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   785
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   786
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   787
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   788
				if(0 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   789
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   790
					qDebug()<<"For getting logged in user's name";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   791
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   792
					QVariantMap map1 = result["user"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   793
					gUserId.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   794
					gUserId.append(map1["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   795
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   796
				else if(1 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   797
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   798
					qDebug()<<"For getting recent tracks";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   799
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   800
					QVariantMap map1 = result["recenttracks"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   801
					QList<QVariant> list1 = map1["track"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   802
					QListIterator<QVariant> iter1(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   803
					while(iter1.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   804
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   805
						QVariantMap map2 = iter1.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   806
						SmfTrackInfo track;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   807
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   808
						SmfArtists artist;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   809
						QStringList names;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   810
						QVariantMap map3 = map2["artist"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   811
						names.append(map3["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   812
						artist.setNames(names);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   813
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   814
						artist.setId(map3["mbid"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   815
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   816
						track.setArtists(artist);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   817
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   818
						track.setTitle(map2["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   819
						track.setId(map2["mbid"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   820
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   821
						SmfAlbum album;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   822
						QVariantMap map4 = map2["album"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   823
						album.setName(map4["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   824
						album.setId(map4["mbid"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   825
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   826
						track.setAlbum(album);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   827
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   828
						gRecentTracks.append(track);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   829
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   830
						if(gItemsPerPage == gRecentTracks.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   831
							break;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   832
						}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   833
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   834
				else if(2 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   835
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   836
					qDebug()<<"For getting favorites";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   837
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   838
					QVariantMap map1 = result["lovedtracks"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   839
					QList<QVariant> list1 = map1["track"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   840
					QListIterator<QVariant> iter1(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   841
					while(iter1.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   842
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   843
						QVariantMap map2 = iter1.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   844
						SmfTrackInfo track;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   845
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   846
						track.setTitle(map2["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   847
						qDebug()<<"Track name : "<<track.title();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   848
						track.setId(map2["mbid"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   849
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   850
						SmfArtists artist;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   851
						QStringList names;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   852
						QVariantMap map3 = map2["artist"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   853
						names.append(map3["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   854
						artist.setNames(names);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   855
						artist.setId(map3["mbid"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   856
						QUrl url(map3["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   857
						artist.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   858
						QList<QVariant> list2 = map3["image"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   859
						QListIterator<QVariant> iter2(list2);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   860
						while(iter2.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   861
							{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   862
							QVariantMap map4 = iter2.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   863
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   864
							// Set the artist's image url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   865
							QUrl url(map4["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   866
							//artist.setImageUrlurl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   867
							qDebug()<<"Track artists image url : "<<url.toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   868
							}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   869
												
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   870
						track.setArtists(artist);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   871
						qDebug()<<"Favorite tracks count = "<<gFavorites.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   872
						gFavorites.append(track);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   873
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   874
						if(gItemsPerPage == gFavorites.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   875
							break;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   876
						}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   877
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   878
				else //if(3 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   879
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   880
					qDebug()<<"For getting user's registered events";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   881
					QVariantMap map1 = result["events"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   882
					QList<QVariant> list1 = map1["event"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   883
					QListIterator<QVariant> iter1(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   884
					while(iter1.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   885
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   886
						QVariantMap map2 = iter1.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   887
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   888
						SmfEvent event;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   889
						event.setId(map2["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   890
						event.setTitle(map2["title"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   891
								
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   892
						// Set the events date and time
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   893
						QDateTime dateTime;// = QDateTime::fromString("M1d1y9800:01:02","'M'M'd'd'y'yyhh:mm:ss");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   894
						event.setEventDateTime(dateTime);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   895
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   896
						// Set the events artists
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   897
						SmfArtists artists;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   898
						QStringList names;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   899
						names.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   900
						QVariantMap map3 = map2["artists"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   901
						QList<QVariant> list1 = map3["artist"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   902
						names.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   903
						QListIterator<QVariant> iter1(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   904
						while(iter1.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   905
							names.append(iter1.next().toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   906
						artists.setNames(names);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   907
						event.setArtists(artists);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   908
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   909
						// Set the events venue information
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   910
						QVariantMap map4 = map2["venue"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   911
						SmfLocation location;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   912
						location.setId(map4["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   913
						location.setName(map4["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   914
						QUrl url(map4["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   915
						location.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   916
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   917
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   918
						QVariantMap map5 = map4["location"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   919
						location.setCity(map5["city"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   920
						location.setCountry(map5["country"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   921
						location.setStreet(map5["street"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   922
						location.setZipCode(map5["postalcode"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   923
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   924
						QVariantMap map6 = map5["geo:point"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   925
						double latitude = map6["geo:lat"].toDouble();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   926
						double longitude = map6["geo:long"].toDouble();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   927
						QGeoCoordinate coordinate(latitude, longitude);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   928
						QGeoPositionInfo geoInfo;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   929
						geoInfo.setCoordinate(coordinate);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   930
						location.setGeoPositionInfo(geoInfo);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   931
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   932
						event.setVenue(location);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   933
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   934
						// Set the events ticketUrl
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   935
						QUrl ticketUrl(map2["tickets"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   936
						event.setTicketUrl(ticketUrl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   937
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   938
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   939
						gUserEvents.append(event);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   940
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   941
						if(gItemsPerPage == gUserEvents.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   942
							break;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   943
						}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   944
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   945
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   946
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   947
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   948
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   949
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   950
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   951
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   952
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   953
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   954
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   955
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   956
				if(0 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   957
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   958
					qDebug()<<"current logged in userId  = "<<gUserId;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   959
					aRetType = SmfSendRequestAgain;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   960
					error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   961
					userMusicInfoChance = 1;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   962
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   963
				else if(1 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   964
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   965
					qDebug()<<"Count of user's recent tracks  = "<<gRecentTracks.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   966
					aRetType = SmfSendRequestAgain;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   967
					error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   968
					userMusicInfoChance = 2;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   969
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   970
				else if(2 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   971
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   972
					qDebug()<<"Count of user's favorite tracks  = "<<gFavorites.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   973
					aRetType = SmfSendRequestAgain;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   974
					error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   975
					userMusicInfoChance = 3;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   976
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   977
				else //if(3 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   978
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   979
					SmfMusicProfile profile;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   980
					profile.setFavorites(gFavorites);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   981
					profile.setRecentTracks(gRecentTracks);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   982
					profile.setUserEvents(gUserEvents);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   983
					profile.setId(gUserId);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   984
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   985
					qDebug()<<"profile id in last.fm = "<<profile.id();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   986
					aResult->setValue(profile);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   987
					aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   988
					error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   989
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   990
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   991
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   992
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   993
		// Artists search
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   994
		else if ( SmfMusicSearchArtist == aOperation )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   995
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   996
			qDebug()<<"Response for searching artists";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   997
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   998
			QList<SmfArtists> list;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   999
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1000
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1001
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1002
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1003
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1004
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1005
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1006
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1007
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1008
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1009
				return SmfPluginErrParsingFailed;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1010
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1011
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1012
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1013
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1014
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1015
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1016
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1017
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1018
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1019
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1020
				QVariantMap map1 = result["results"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1021
				QVariantMap map2 = map1["artistmatches"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1022
				QList<QVariant> list1 = map2["artist"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1023
				QListIterator<QVariant> iter(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1024
				while(iter.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1025
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1026
					SmfArtists artist;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1027
					QVariantMap map3 = iter.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1028
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1029
					// Name of the artist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1030
					QStringList names;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1031
					names.append(map3["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1032
					artist.setNames(names);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1033
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1034
					// last.fm ID of the artist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1035
					artist.setId(map3["mbid"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1036
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1037
					// last.fm url of the artist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1038
					QUrl url(map3["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1039
					artist.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1040
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1041
					// last.fm image of the artist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1042
					QList<QVariant> list2 = map3["image"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1043
					QListIterator<QVariant> iter2(list2);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1044
					while(iter2.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1045
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1046
						QVariantMap map5 = iter2.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1047
						QUrl imageUrl(map5["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1048
						//artists.setImageUrl(imageUrl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1049
						break;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1050
						}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1051
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1052
					list.append(artist);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1053
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1054
					if(gItemsPerPage == list.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1055
						break;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1056
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1057
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1058
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1059
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1060
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1061
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1062
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1063
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1064
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1065
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1066
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1067
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1068
				qDebug()<<"list count = "<<list.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1069
				aResult->setValue(list);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1070
				aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1071
				error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1072
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1073
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1074
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1075
		// Albums search
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1076
		else if ( SmfMusicSearchAlbum == aOperation )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1077
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1078
			qDebug()<<"Response for searching albums";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1079
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1080
			QList<SmfAlbum> list;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1081
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1082
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1083
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1084
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1085
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1086
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1087
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1088
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1089
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1090
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1091
				return SmfPluginErrParsingFailed;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1092
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1093
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1094
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1095
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1096
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1097
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1098
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1099
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1100
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1101
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1102
				QVariantMap map1 = result["results"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1103
				QVariantMap map2 = map1["albummatches"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1104
				QList<QVariant> list1 = map2["album"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1105
				QListIterator<QVariant> iter(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1106
				while(iter.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1107
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1108
					SmfAlbum album;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1109
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1110
					QVariantMap map3 = iter.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1111
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1112
					album.setName(map3["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1113
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1114
					SmfArtists artists;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1115
					QStringList names;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1116
					names.append(map3["artist"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1117
					artists.setNames(names);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1118
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1119
					QList<QVariant> list2 = map3["image"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1120
					QListIterator<QVariant> iter2(list2);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1121
					while(iter2.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1122
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1123
						QVariantMap map5 = iter2.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1124
						QUrl imageUrl(map5["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1125
						//artists.setImageUrl(imageUrl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1126
						break;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1127
						}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1128
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1129
					album.setArtists(artists);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1130
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1131
					album.setId(map3["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1132
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1133
					//QUrl url(map3["url"].toString())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1134
					//album.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1135
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1136
					list.append(album);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1137
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1138
					if(gItemsPerPage == list.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1139
						break;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1140
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1141
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1142
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1143
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1144
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1145
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1146
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1147
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1148
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1149
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1150
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1151
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1152
				qDebug()<<"list count = "<<list.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1153
				aResult->setValue(list);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1154
				aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1155
				error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1156
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1157
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1158
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1159
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1160
		// Events search
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1161
		else if (SmfMusicSearchEvent == aOperation)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1162
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1163
			qDebug()<<"Response for searching events";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1164
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1165
			QList<SmfEvent> list;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1166
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1167
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1168
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1169
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1170
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1171
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1172
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1173
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1174
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1175
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1176
				return SmfPluginErrParsingFailed;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1177
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1178
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1179
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1180
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1181
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1182
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1183
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1184
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1185
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1186
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1187
				QVariantMap map1 = result["event"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1188
				SmfEvent event;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1189
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1190
				// Set the events title
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1191
				event.setTitle(map1["title"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1192
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1193
				// Set the events id
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1194
				event.setId(map1["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1195
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1196
				// Set the events date and time
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1197
				QDateTime dateTime;// = QDateTime::fromString("M1d1y9800:01:02","'M'M'd'd'y'yyhh:mm:ss");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1198
				event.setEventDateTime(dateTime);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1199
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1200
				// Set the events artists
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1201
				SmfArtists artists;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1202
				QStringList names;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1203
				names.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1204
				QVariantMap map2 = map1["artists"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1205
				QList<QVariant> list1 = map2["artist"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1206
				QListIterator<QVariant> iter(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1207
				while(iter.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1208
					names.append(iter.next().toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1209
				artists.setNames(names);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1210
				event.setArtists(artists);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1211
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1212
				// Set the events venue information
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1213
				QVariantMap map3 = map1["venue"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1214
				SmfLocation location;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1215
				location.setName(map3["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1216
				QUrl url(map3["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1217
				location.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1218
				location.setId(map3["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1219
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1220
				QVariantMap map4 = map3["location"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1221
				location.setCity(map4["city"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1222
				location.setCountry(map4["country"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1223
				location.setStreet(map4["street"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1224
				location.setZipCode(map4["postalcode"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1225
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1226
				QVariantMap map5 = map4["geo:point"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1227
				double latitude = map5["geo:lat"].toDouble();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1228
				double longitude = map5["geo:long"].toDouble();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1229
				QGeoCoordinate coordinate(latitude, longitude);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1230
				QGeoPositionInfo geoInfo;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1231
				geoInfo.setCoordinate(coordinate);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1232
				location.setGeoPositionInfo(geoInfo);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1233
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1234
				event.setVenue(location);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1235
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1236
				// Set the events ticketUrl
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1237
				QUrl ticketUrl(map1["tickets"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1238
				event.setTicketUrl(ticketUrl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1239
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1240
				// Set the events id
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1241
				event.setId(map1["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1242
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1243
				list.append(event);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1244
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1245
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1246
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1247
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1248
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1249
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1250
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1251
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1252
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1253
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1254
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1255
				qDebug()<<"list count = "<<list.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1256
				aResult->setValue(list);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1257
				aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1258
				error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1259
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1260
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1261
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1262
		// Venues Search
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1263
		else if(SmfMusicSearchVenue == aOperation)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1264
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1265
			qDebug()<<"Response for searching venues";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1266
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1267
			QList<SmfLocation> list;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1268
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1269
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1270
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1271
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1272
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1273
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1274
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1275
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1276
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1277
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1278
				return SmfPluginErrParsingFailed;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1279
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1280
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1281
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1282
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1283
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1284
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1285
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1286
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1287
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1288
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1289
				QVariantMap map1 = result["results"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1290
				QVariantMap map2 = map1["venuematches"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1291
				QList<QVariant> list1 = map2["venue"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1292
				QListIterator<QVariant> iter(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1293
				while(iter.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1294
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1295
					SmfLocation location;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1296
					QVariantMap map3 = iter.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1297
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1298
					location.setName(map3["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1299
					QUrl url(map3["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1300
					location.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1301
					location.setId(map3["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1302
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1303
					QVariantMap map4 = map3["location"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1304
					location.setCity(map4["city"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1305
					location.setCountry(map4["country"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1306
					location.setStreet(map4["street"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1307
					location.setZipCode(map4["postalcode"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1308
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1309
					QVariantMap map5 = map4["geo:point"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1310
					double latitude = map5["geo:lat"].toDouble();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1311
					double longitude = map5["geo:long"].toDouble();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1312
					QGeoCoordinate coordinate(latitude, longitude);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1313
					QGeoPositionInfo geoInfo;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1314
					geoInfo.setCoordinate(coordinate);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1315
					location.setGeoPositionInfo(geoInfo);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1316
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1317
					list.append(location);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1318
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1319
					if(gItemsPerPage == list.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1320
						break;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1321
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1322
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1323
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1324
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1325
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1326
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1327
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1328
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1329
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1330
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1331
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1332
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1333
				qDebug()<<"list count = "<<list.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1334
				aResult->setValue(list);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1335
				aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1336
				error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1337
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1338
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1339
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1340
#if 0
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1341
		// User search
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1342
		else if(SmfMusicSearchUser == aOperation)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1343
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1344
			qDebug()<<"Response for searching users";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1345
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1346
			QList<SmfMusicProfile> list;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1347
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1348
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1349
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1350
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1351
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1352
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1353
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1354
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1355
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1356
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1357
				return SmfPluginErrParsingFailed;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1358
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1359
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1360
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1361
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1362
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1363
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1364
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1365
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1366
				qDebug()<<"For getting user's neighbours";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1367
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1368
				QVariantMap map1 = result["neighbours"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1369
				QList<QVariant> list1 = map1["user"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1370
				QListIterator<QVariant> iter(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1371
				while(iter.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1372
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1373
					SmfMusicProfile profile;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1374
					QVariantMap map2 = iter.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1375
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1376
/*					QContactName name;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1377
					name.setFirstName(map2["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1378
					QVariant nameVar = QVariant::fromValue<QContactName>(name);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1379
					contact.setValue("Name", nameVar);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1380
											
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1381
					QContactUrl url;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1382
					url.setUrl(map2["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1383
					QVariant urlVar = QVariant::fromValue<QContactUrl>(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1384
					contact.setValue("Url", urlVar);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1385
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1386
					QContactAvatar avatar;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1387
					QList<QVariant> list2 = map2["image"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1388
					QListIterator<QVariant> iter2(list2);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1389
					while(iter2.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1390
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1391
						QVariantMap map3 = iter2.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1392
						QUrl imageUrl(map3["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1393
						avatar.setImageUrl(imageUrl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1394
						break;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1395
						}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1396
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1397
					QVariant avatarVar = QVariant::fromValue<QContactAvatar>(avatar);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1398
					contact.setValue("Avatar", avatarVar);*/
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1399
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1400
					profile.setId(map2["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1401
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1402
					list.append(profile);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1403
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1404
					if(gItemsPerPage == list.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1405
						break;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1406
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1407
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1408
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1409
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1410
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1411
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1412
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1413
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1414
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1415
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1416
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1417
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1418
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1419
				qDebug()<<"list count = "<<list.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1420
				aResult->setValue(list);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1421
				aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1422
				error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1423
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1424
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1425
#endif
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1426
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1427
		else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1428
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1429
			qDebug()<<"Service unsupported!!!";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1430
			aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1431
			error = SmfPluginErrServiceNotSupported;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1432
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1433
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1434
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1435
		else if(SmfTransportOpOperationCanceledError == aTransportResult)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1436
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1437
			qDebug()<<"Operation Cancelled !!!";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1438
			error = SmfPluginErrCancelComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1439
			aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1440
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1441
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1442
		else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1443
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1444
			qDebug()<<"Transport Error !!!";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1445
			error = SmfPluginErrNetworkError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1446
			aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1447
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1448
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1449
		return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1450
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1451
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1452
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1453
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1454
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1455
 * Destructor
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1456
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1457
LastFmMusicServiceProviderBase::~LastFmMusicServiceProviderBase( )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1458
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1459
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1460
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1461
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1462
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1463
 * Method to get the Localisable name of the service.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1464
 * @return The Localisable name of the service.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1465
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1466
QString LastFmMusicServiceProviderBase::serviceName( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1467
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1468
	return m_serviceName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1469
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1470
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1471
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1472
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1473
 * Method to get the Logo of the service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1474
 * @return The Logo of the service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1475
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1476
QImage LastFmMusicServiceProviderBase::serviceIcon( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1477
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1478
	return m_serviceIcon;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1479
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1480
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1481
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1482
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1483
 * Method to get the Readable service description
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1484
 * @return The Readable service description
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1485
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1486
QString LastFmMusicServiceProviderBase::description( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1487
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1488
	return m_description;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1489
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1490
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1491
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1492
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1493
 * Method to get the Website of the service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1494
 * @return The Website of the service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1495
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1496
QUrl LastFmMusicServiceProviderBase::serviceUrl( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1497
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1498
	return m_serviceUrl;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1499
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1500
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1501
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1502
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1503
 * Method to get the URL of the Application providing this service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1504
 * @return The URL of the Application providing this service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1505
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1506
QUrl LastFmMusicServiceProviderBase::applicationUrl( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1507
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1508
	return m_applicationUrl;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1509
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1510
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1511
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1512
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1513
 * Method to get the Icon of the application
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1514
 * @return The Icon of the application
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1515
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1516
QImage LastFmMusicServiceProviderBase::applicationIcon( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1517
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1518
	return m_applicationIcon;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1519
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1520
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1521
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1522
* Method to get the list of interfaces that this provider support
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1523
* @return List of supported Interafces
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1524
*/
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1525
QList<QString> LastFmMusicServiceProviderBase::supportedInterfaces( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1526
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1527
	return m_supportedInterfaces;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1528
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1529
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1530
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1531
* Method to get the list of languages supported by this service provider
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1532
* @return a QStringList of languages supported by this service 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1533
* provider in 2 letter ISO 639-1 format.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1534
*/
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1535
QStringList LastFmMusicServiceProviderBase::supportedLanguages( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1536
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1537
	return m_supportedLangs;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1538
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1539
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1540
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1541
 * Method to get the Plugin specific ID
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1542
 * @return The Plugin specific ID
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1543
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1544
QString LastFmMusicServiceProviderBase::pluginId( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1545
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1546
	return m_pluginId;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1547
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1548
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1549
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1550
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1551
 * Method to get the ID of the authentication application 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1552
 * for this service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1553
 * @param aProgram The authentication application name
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1554
 * @param aArguments List of arguments required for authentication app
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1555
 * @param aMode Strting mode for authentication application
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1556
 * @return The ID of the authentication application 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1557
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1558
QString LastFmMusicServiceProviderBase::authenticationApp( QString &aProgram, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1559
		QStringList & aArguments, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1560
		QIODevice::OpenModeFlag aMode ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1561
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1562
	Q_UNUSED(aProgram)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1563
	Q_UNUSED(aArguments)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1564
	Q_UNUSED(aMode)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1565
	return m_authAppId;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1566
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1567
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1568
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1569
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1570
 * Method to get the unique registration ID provided by the 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1571
 * Smf for authorised plugins
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1572
 * @return The unique registration ID/token provided by the Smf for 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1573
 * authorised plugins
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1574
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1575
QString LastFmMusicServiceProviderBase::smfRegistrationId( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1576
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1577
	return m_smfRegToken;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1578
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1579
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1580
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1581
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1582
 * Method that initializes this class. This method should be called 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1583
 * from the initialize() method of the FBContactFetcherPlugin class
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1584
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1585
void LastFmMusicServiceProviderBase::initialize()
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1586
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1587
	m_serviceName = "last.fm";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1588
	m_description = "Last.fm music service plugin description";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1589
	m_serviceUrl = QUrl(QString("http://www.last.fm"));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1590
	m_pluginId = "lastfmmusicserviceplugin.qtplugin";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1591
	m_authAppId = "0x12345678";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1592
	m_supportedInterfaces.append("org.symbian.smf.plugin.music.service/v0.2");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1593
	QSettings iSettings;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1594
	m_smfRegToken = iSettings.value("LastFmRegToken").toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1595
	m_validity = iSettings.value("LastFmExpiryTime").toDateTime();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1596
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1597
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1598
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1599
/*
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1600
 * Export Macro
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1601
 * plugin name : LastFmMusicServicePlugin
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1602
 * plugin class : LastFmMusicServicePlugin
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1603
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1604
Q_EXPORT_PLUGIN2( lastfmmusicserviceplugin, LastFmMusicServicePlugin )