example/lastfmmusicserviceplugin/lastfmmusicserviceplugin.cpp
author cgandhi
Tue, 12 Oct 2010 15:23:52 +0530
changeset 27 b3e1347ac96a
parent 26 83d6a149c755
permissions -rw-r--r--
Updating the information for test applications and results.
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
26
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   479
	//if( aPageNum < 0 || aItemsPerPage < 0 || aVenue.name().isEmpty() ) kindly check this
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   480
	if( aPageNum < 0 || aItemsPerPage < 0)
23
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   481
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   482
		qDebug()<<"Invalid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   483
		return error;
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
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   486
	qDebug()<<"Valid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   487
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   488
	gPageNum = aPageNum;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   489
	gItemsPerPage = aItemsPerPage;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   490
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   491
	// Get the key sets from SMF Plugin Utility class.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   492
	QString apiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   493
	QString apiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   494
	QString token;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   495
	QString userName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   496
	fetchKeys(apiKey, apiSecret, token, userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   497
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   498
	// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   499
	QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   500
	baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   501
	baseString.append("limit"+QString::number(aItemsPerPage));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   502
	baseString.append("methodvenue.search");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   503
	baseString.append("page"+QString::number(aPageNum));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   504
	baseString.append("venue"+aVenue.name());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   505
	baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   506
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   507
	// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   508
	QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   509
	url.addQueryItem("venue", aVenue.name());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   510
	url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   511
	url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   512
	url.addQueryItem("limit", QString::number(aItemsPerPage));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   513
	url.addQueryItem("page", QString::number(aPageNum));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   514
	url.addQueryItem("method", "venue.search");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   515
	url.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   516
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   517
	// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   518
	aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   519
	aRequest.iRequestType = SmfMusicSearchVenue;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   520
	aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   521
	aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   522
	error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   523
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   524
	qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   525
	return error;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   529
 * 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
   530
 * particular place
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   531
 * @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
   532
 * @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
   533
 * @param aPageNum [in] The page to be extracted
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   534
 * @param aItemsPerPage [in] Number of items per page
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   535
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   536
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   537
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   538
SmfPluginError LastFmMusicServicePlugin::searchUser( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   539
		SmfPluginRequestData &aRequest,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   540
		const SmfLocation &aPlace,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   541
		const int aPageNum, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   542
		const int aItemsPerPage )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   543
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   544
	Q_UNUSED(aRequest)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   545
	Q_UNUSED(aPlace)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   546
	Q_UNUSED(aPageNum)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   547
	Q_UNUSED(aItemsPerPage)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   548
	qDebug()<<"Inside LastFmMusicServicePlugin::searchUser()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   549
	SmfPluginError error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   550
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   551
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   552
#if 0
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   553
	Q_UNUSED(aPlace)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   554
	qDebug()<<"Inside LastFmMusicServicePlugin::searchUser()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   555
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   556
	SmfPluginError error = SmfPluginErrInvalidArguments;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   557
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   558
	// invalid arguments
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   559
	if( aPageNum < 0 || aItemsPerPage < 0 )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   560
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   561
		qDebug()<<"Invalid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   562
		return error;
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
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   565
	qDebug()<<"Valid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   566
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   567
	// Get the key sets from SMF Plugin Utility class.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   568
	QString apiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   569
	QString apiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   570
	QString token;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   571
	QString userName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   572
	fetchKeys(apiKey, apiSecret, token, userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   573
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   574
	// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   575
	QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   576
	baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   577
	baseString.append("methoduser.getNeighbours");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   578
	baseString.append("user"+userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   579
	baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   580
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   581
	// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   582
	QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   583
	url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   584
	url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   585
	url.addQueryItem("method", "user.getNeighbours");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   586
	url.addQueryItem("user", userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   587
	url.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   588
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   589
	// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   590
	aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   591
	aRequest.iRequestType = SmfMusicSearchUser;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   592
	aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   593
	aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   594
	error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   595
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   596
	qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   597
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   598
#endif
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   602
 * Method to post the currently playing track
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   603
 * @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
   604
 * @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
   605
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   606
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   607
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   608
SmfPluginError LastFmMusicServicePlugin::postCurrentPlaying( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   609
		SmfPluginRequestData &aRequest,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   610
		const SmfTrackInfo &aTrack )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   611
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   612
	Q_UNUSED(aRequest)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   613
	Q_UNUSED(aTrack)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   614
	qDebug()<<"Inside LastFmMusicServicePlugin::postCurrentPlaying()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   615
	SmfPluginError error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   616
	return error;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   620
 * Method to post the rating on a track
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   621
 * @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
   622
 * @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
   623
 * @param aRating [in] The rating values
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   624
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   625
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   626
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   627
SmfPluginError LastFmMusicServicePlugin::postRating( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   628
		SmfPluginRequestData &aRequest, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   629
		const SmfTrackInfo &aTrack, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   630
		const SmfMusicRating &aRating )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   631
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   632
	Q_UNUSED(aRequest)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   633
	Q_UNUSED(aTrack)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   634
	Q_UNUSED(aRating)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   635
	qDebug()<<"Inside LastFmMusicServicePlugin::postRating()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   636
	SmfPluginError error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   637
	return error;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   641
 * Method to post comment on a track
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   642
 * @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
   643
 * @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
   644
 * @param aComment [in] The comment content
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   645
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   646
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   647
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   648
SmfPluginError LastFmMusicServicePlugin::postComments( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   649
		SmfPluginRequestData &aRequest, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   650
		const SmfTrackInfo &aTrack, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   651
		const SmfComment &aComment )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   652
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   653
	Q_UNUSED(aRequest)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   654
	Q_UNUSED(aTrack)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   655
	Q_UNUSED(aComment)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   656
	qDebug()<<"Inside LastFmMusicServicePlugin::postComments()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   657
	SmfPluginError error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   658
	return error;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   662
 * Customised method for SmfMusicServicePlugin interface
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   663
 * @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
   664
 * @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
   665
 * the client interface and the plugin)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   666
 * @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
   667
 * 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
   668
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   669
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   670
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   671
SmfPluginError LastFmMusicServicePlugin::customRequest( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   672
		SmfPluginRequestData &aRequest, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   673
		const int &aOperation, QByteArray *aData )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   674
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   675
	Q_UNUSED(aRequest)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   676
	Q_UNUSED(aOperation)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   677
	Q_UNUSED(aData)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   678
	qDebug()<<"Inside LastFmMusicServicePlugin::customRequest()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   679
	SmfPluginError error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   680
	return error;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   684
 * 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
   685
 * 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
   686
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   687
void LastFmMusicServicePlugin::initialize( )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   688
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   689
	// Create an instance of LastFmMusicServiceProviderBase
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   690
	m_provider = new LastFmMusicServiceProviderBase;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   691
	m_provider->initialize();
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   695
 * Method to get the provider information
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   696
 * @return Instance of SmfProviderBase
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   697
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   698
SmfProviderBase* LastFmMusicServicePlugin::getProviderInfo( )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   699
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   700
	return m_provider;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   704
 * Method to get the result for a network request.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   705
 * @param aOperation The type of operation to be requested
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   706
 * @param aTransportResult The result of transport operation
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   707
 * @param aResponse The QByteArray instance containing the network response.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   708
 * 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
   709
 * data from it.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   710
 * @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
   711
 * return value is SmfSendRequestAgain, QVariant will be of type 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   712
 * SmfPluginRequestData.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   713
 * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   714
 * 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
   715
 * 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
   716
 * 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
   717
 * 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
   718
 * 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
   719
 * 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
   720
 * postCurrentPlaying() or postRating() or postComments(), aResult will be of
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   721
 * type bool.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   722
 * @param aRetType [out] SmfPluginRetType
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   723
 * @param aPageResult [out] The SmfResultPage structure variable
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   724
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   725
SmfPluginError LastFmMusicServicePlugin::responseAvailable( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   726
		const SmfRequestTypeID aOperation,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   727
		const SmfTransportResult &aTransportResult, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   728
		QByteArray *aResponse, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   729
		QVariant* aResult, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   730
		SmfPluginRetType &aRetType,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   731
		SmfResultPage &aPageResult )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   732
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   733
	Q_UNUSED(aPageResult)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   734
	qDebug()<<"Inside LastFmMusicServicePlugin::responseAvailable()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   735
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   736
	SmfPluginError error = SmfPluginErrNetworkError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   737
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   738
	if( !aResponse || (0 == aResponse->size()) )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   739
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   740
		qDebug()<<"Response is NULL or empty";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   741
		aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   742
		return error;
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
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   745
	QByteArray response(*aResponse);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   746
	delete aResponse;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   747
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   748
	QFile respFile("c://data//SmfMusicServicePluginResponse.txt");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   749
	if(!respFile.open(QIODevice::WriteOnly))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   750
		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
   751
	else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   752
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   753
		respFile.write(response);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   754
		respFile.close();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   755
		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
   756
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   757
	qDebug()<<"FB response size = "<<response.size();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   758
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   759
	if(SmfTransportOpNoError == aTransportResult)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   760
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   761
		qDebug()<<"No transport error";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   762
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   763
		// Get music user info
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   764
		if(SmfMusicGetUserInfo == aOperation)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   765
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   766
			qDebug()<<"Response for getting user profile";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   767
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   768
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   769
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   770
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   771
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   772
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   773
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   774
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   775
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   776
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   777
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   778
				return SmfPluginErrParsingFailed;
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
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   781
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   782
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   783
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   784
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   785
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   786
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   787
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   788
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   789
				if(0 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   790
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   791
					qDebug()<<"For getting logged in user's name";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   792
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   793
					QVariantMap map1 = result["user"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   794
					gUserId.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   795
					gUserId.append(map1["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   796
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   797
				else if(1 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   798
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   799
					qDebug()<<"For getting recent tracks";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   800
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   801
					QVariantMap map1 = result["recenttracks"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   802
					QList<QVariant> list1 = map1["track"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   803
					QListIterator<QVariant> iter1(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   804
					while(iter1.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   805
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   806
						QVariantMap map2 = iter1.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   807
						SmfTrackInfo track;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   808
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   809
						SmfArtists artist;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   810
						QStringList names;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   811
						QVariantMap map3 = map2["artist"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   812
						names.append(map3["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   813
						artist.setNames(names);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   814
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   815
						artist.setId(map3["mbid"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   816
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   817
						track.setArtists(artist);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   818
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   819
						track.setTitle(map2["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   820
						track.setId(map2["mbid"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   821
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   822
						SmfAlbum album;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   823
						QVariantMap map4 = map2["album"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   824
						album.setName(map4["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   825
						album.setId(map4["mbid"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   826
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   827
						track.setAlbum(album);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   828
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   829
						gRecentTracks.append(track);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   830
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   831
						if(gItemsPerPage == gRecentTracks.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   832
							break;
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
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   835
				else if(2 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   836
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   837
					qDebug()<<"For getting favorites";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   838
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   839
					QVariantMap map1 = result["lovedtracks"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   840
					QList<QVariant> list1 = map1["track"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   841
					QListIterator<QVariant> iter1(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   842
					while(iter1.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   843
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   844
						QVariantMap map2 = iter1.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   845
						SmfTrackInfo track;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   846
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   847
						track.setTitle(map2["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   848
						qDebug()<<"Track name : "<<track.title();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   849
						track.setId(map2["mbid"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   850
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   851
						SmfArtists artist;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   852
						QStringList names;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   853
						QVariantMap map3 = map2["artist"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   854
						names.append(map3["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   855
						artist.setNames(names);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   856
						artist.setId(map3["mbid"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   857
						QUrl url(map3["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   858
						artist.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   859
						QList<QVariant> list2 = map3["image"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   860
						QListIterator<QVariant> iter2(list2);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   861
						while(iter2.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   862
							{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   863
							QVariantMap map4 = iter2.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   864
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   865
							// Set the artist's image url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   866
							QUrl url(map4["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   867
							//artist.setImageUrlurl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   868
							qDebug()<<"Track artists image url : "<<url.toString();
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
												
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   871
						track.setArtists(artist);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   872
						qDebug()<<"Favorite tracks count = "<<gFavorites.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   873
						gFavorites.append(track);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   874
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   875
						if(gItemsPerPage == gFavorites.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   876
							break;
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
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   879
				else //if(3 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   880
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   881
					qDebug()<<"For getting user's registered events";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   882
					QVariantMap map1 = result["events"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   883
					QList<QVariant> list1 = map1["event"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   884
					QListIterator<QVariant> iter1(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   885
					while(iter1.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   886
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   887
						QVariantMap map2 = iter1.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   888
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   889
						SmfEvent event;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   890
						event.setId(map2["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   891
						event.setTitle(map2["title"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   892
								
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   893
						// Set the events date and time
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   894
						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
   895
						event.setEventDateTime(dateTime);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   896
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   897
						// Set the events artists
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   898
						SmfArtists artists;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   899
						QStringList names;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   900
						names.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   901
						QVariantMap map3 = map2["artists"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   902
						QList<QVariant> list1 = map3["artist"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   903
						names.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   904
						QListIterator<QVariant> iter1(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   905
						while(iter1.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   906
							names.append(iter1.next().toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   907
						artists.setNames(names);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   908
						event.setArtists(artists);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   909
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   910
						// Set the events venue information
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   911
						QVariantMap map4 = map2["venue"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   912
						SmfLocation location;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   913
						location.setId(map4["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   914
						location.setName(map4["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   915
						QUrl url(map4["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   916
						location.setUrl(url);
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
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   919
						QVariantMap map5 = map4["location"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   920
						location.setCity(map5["city"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   921
						location.setCountry(map5["country"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   922
						location.setStreet(map5["street"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   923
						location.setZipCode(map5["postalcode"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   924
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   925
						QVariantMap map6 = map5["geo:point"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   926
						double latitude = map6["geo:lat"].toDouble();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   927
						double longitude = map6["geo:long"].toDouble();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   928
						QGeoCoordinate coordinate(latitude, longitude);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   929
						QGeoPositionInfo geoInfo;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   930
						geoInfo.setCoordinate(coordinate);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   931
						location.setGeoPositionInfo(geoInfo);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   932
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   933
						event.setVenue(location);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   934
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   935
						// Set the events ticketUrl
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   936
						QUrl ticketUrl(map2["tickets"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   937
						event.setTicketUrl(ticketUrl);
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
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   940
						gUserEvents.append(event);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   941
						
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   942
						if(gItemsPerPage == gUserEvents.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   943
							break;
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
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   948
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   949
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   950
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   951
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   952
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   953
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   954
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   955
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   956
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   957
				if(0 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   958
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   959
					qDebug()<<"current logged in userId  = "<<gUserId;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   960
					aRetType = SmfSendRequestAgain;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   961
					error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   962
					userMusicInfoChance = 1;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   963
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   964
				else if(1 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   965
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   966
					qDebug()<<"Count of user's recent tracks  = "<<gRecentTracks.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   967
					aRetType = SmfSendRequestAgain;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   968
					error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   969
					userMusicInfoChance = 2;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   970
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   971
				else if(2 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   972
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   973
					qDebug()<<"Count of user's favorite tracks  = "<<gFavorites.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   974
					aRetType = SmfSendRequestAgain;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   975
					error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   976
					userMusicInfoChance = 3;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   977
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   978
				else //if(3 == userMusicInfoChance)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   979
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   980
					SmfMusicProfile profile;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   981
					profile.setFavorites(gFavorites);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   982
					profile.setRecentTracks(gRecentTracks);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   983
					profile.setUserEvents(gUserEvents);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   984
					profile.setId(gUserId);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   985
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   986
					qDebug()<<"profile id in last.fm = "<<profile.id();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   987
					aResult->setValue(profile);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   988
					aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   989
					error = SmfPluginErrNone;
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
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   994
		// Artists search
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   995
		else if ( SmfMusicSearchArtist == aOperation )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   996
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   997
			qDebug()<<"Response for searching artists";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   998
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   999
			QList<SmfArtists> list;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1000
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1001
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1002
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1003
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1004
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1005
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1006
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1007
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1008
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1009
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1010
				return SmfPluginErrParsingFailed;
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
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1013
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1014
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1015
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1016
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1017
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1018
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1019
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1020
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1021
				QVariantMap map1 = result["results"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1022
				QVariantMap map2 = map1["artistmatches"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1023
				QList<QVariant> list1 = map2["artist"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1024
				QListIterator<QVariant> iter(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1025
				while(iter.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1026
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1027
					SmfArtists artist;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1028
					QVariantMap map3 = iter.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1029
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1030
					// Name of the artist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1031
					QStringList names;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1032
					names.append(map3["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1033
					artist.setNames(names);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1034
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1035
					// last.fm ID of the artist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1036
					artist.setId(map3["mbid"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1037
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1038
					// last.fm url of the artist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1039
					QUrl url(map3["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1040
					artist.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1041
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1042
					// last.fm image of the artist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1043
					QList<QVariant> list2 = map3["image"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1044
					QListIterator<QVariant> iter2(list2);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1045
					while(iter2.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1046
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1047
						QVariantMap map5 = iter2.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1048
						QUrl imageUrl(map5["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1049
						//artists.setImageUrl(imageUrl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1050
						break;
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
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1053
					list.append(artist);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1054
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1055
					if(gItemsPerPage == list.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1056
						break;
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
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1060
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1061
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1062
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1063
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1064
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1065
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1066
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1067
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1068
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1069
				qDebug()<<"list count = "<<list.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1070
				aResult->setValue(list);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1071
				aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1072
				error = SmfPluginErrNone;
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
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1076
		// Albums search
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1077
		else if ( SmfMusicSearchAlbum == aOperation )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1078
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1079
			qDebug()<<"Response for searching albums";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1080
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1081
			QList<SmfAlbum> list;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1082
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1083
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1084
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1085
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1086
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1087
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1088
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1089
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1090
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1091
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1092
				return SmfPluginErrParsingFailed;
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
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1095
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1096
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1097
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1098
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1099
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1100
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1101
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1102
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1103
				QVariantMap map1 = result["results"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1104
				QVariantMap map2 = map1["albummatches"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1105
				QList<QVariant> list1 = map2["album"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1106
				QListIterator<QVariant> iter(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1107
				while(iter.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1108
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1109
					SmfAlbum album;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1110
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1111
					QVariantMap map3 = iter.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1112
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1113
					album.setName(map3["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1114
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1115
					SmfArtists artists;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1116
					QStringList names;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1117
					names.append(map3["artist"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1118
					artists.setNames(names);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1119
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1120
					QList<QVariant> list2 = map3["image"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1121
					QListIterator<QVariant> iter2(list2);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1122
					while(iter2.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1123
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1124
						QVariantMap map5 = iter2.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1125
						QUrl imageUrl(map5["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1126
						//artists.setImageUrl(imageUrl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1127
						break;
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
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1130
					album.setArtists(artists);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1131
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1132
					album.setId(map3["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1133
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1134
					//QUrl url(map3["url"].toString())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1135
					//album.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1136
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1137
					list.append(album);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1138
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1139
					if(gItemsPerPage == list.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1140
						break;
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
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1144
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1145
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1146
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1147
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1148
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1149
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1150
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1151
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1152
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1153
				qDebug()<<"list count = "<<list.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1154
				aResult->setValue(list);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1155
				aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1156
				error = SmfPluginErrNone;
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
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1161
		// Events search
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1162
		else if (SmfMusicSearchEvent == aOperation)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1163
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1164
			qDebug()<<"Response for searching events";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1165
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1166
			QList<SmfEvent> list;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1167
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1168
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1169
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1170
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1171
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1172
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1173
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1174
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1175
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1176
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1177
				return SmfPluginErrParsingFailed;
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
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1180
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1181
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1182
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1183
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1184
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1185
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1186
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1187
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1188
				QVariantMap map1 = result["event"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1189
				SmfEvent event;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1190
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1191
				// Set the events title
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1192
				event.setTitle(map1["title"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1193
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1194
				// Set the events id
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1195
				event.setId(map1["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1196
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1197
				// Set the events date and time
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1198
				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
  1199
				event.setEventDateTime(dateTime);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1200
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1201
				// Set the events artists
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1202
				SmfArtists artists;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1203
				QStringList names;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1204
				names.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1205
				QVariantMap map2 = map1["artists"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1206
				QList<QVariant> list1 = map2["artist"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1207
				QListIterator<QVariant> iter(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1208
				while(iter.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1209
					names.append(iter.next().toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1210
				artists.setNames(names);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1211
				event.setArtists(artists);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1212
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1213
				// Set the events venue information
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1214
				QVariantMap map3 = map1["venue"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1215
				SmfLocation location;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1216
				location.setName(map3["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1217
				QUrl url(map3["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1218
				location.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1219
				location.setId(map3["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1220
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1221
				QVariantMap map4 = map3["location"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1222
				location.setCity(map4["city"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1223
				location.setCountry(map4["country"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1224
				location.setStreet(map4["street"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1225
				location.setZipCode(map4["postalcode"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1226
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1227
				QVariantMap map5 = map4["geo:point"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1228
				double latitude = map5["geo:lat"].toDouble();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1229
				double longitude = map5["geo:long"].toDouble();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1230
				QGeoCoordinate coordinate(latitude, longitude);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1231
				QGeoPositionInfo geoInfo;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1232
				geoInfo.setCoordinate(coordinate);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1233
				location.setGeoPositionInfo(geoInfo);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1234
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1235
				event.setVenue(location);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1236
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1237
				// Set the events ticketUrl
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1238
				QUrl ticketUrl(map1["tickets"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1239
				event.setTicketUrl(ticketUrl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1240
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1241
				// Set the events id
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1242
				event.setId(map1["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1243
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1244
				list.append(event);
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
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1247
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1248
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1249
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1250
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1251
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1252
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1253
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1254
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1255
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1256
				qDebug()<<"list count = "<<list.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1257
				aResult->setValue(list);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1258
				aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1259
				error = SmfPluginErrNone;
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
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1263
		// Venues Search
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1264
		else if(SmfMusicSearchVenue == aOperation)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1265
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1266
			qDebug()<<"Response for searching venues";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1267
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1268
			QList<SmfLocation> list;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1269
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1270
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1271
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1272
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1273
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1274
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1275
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1276
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1277
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1278
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1279
				return SmfPluginErrParsingFailed;
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
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1282
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1283
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1284
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1285
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1286
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1287
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1288
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1289
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1290
				QVariantMap map1 = result["results"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1291
				QVariantMap map2 = map1["venuematches"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1292
				QList<QVariant> list1 = map2["venue"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1293
				QListIterator<QVariant> iter(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1294
				while(iter.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1295
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1296
					SmfLocation location;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1297
					QVariantMap map3 = iter.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1298
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1299
					location.setName(map3["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1300
					QUrl url(map3["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1301
					location.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1302
					location.setId(map3["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1303
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1304
					QVariantMap map4 = map3["location"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1305
					location.setCity(map4["city"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1306
					location.setCountry(map4["country"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1307
					location.setStreet(map4["street"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1308
					location.setZipCode(map4["postalcode"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1309
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1310
					QVariantMap map5 = map4["geo:point"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1311
					double latitude = map5["geo:lat"].toDouble();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1312
					double longitude = map5["geo:long"].toDouble();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1313
					QGeoCoordinate coordinate(latitude, longitude);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1314
					QGeoPositionInfo geoInfo;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1315
					geoInfo.setCoordinate(coordinate);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1316
					location.setGeoPositionInfo(geoInfo);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1317
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1318
					list.append(location);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1319
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1320
					if(gItemsPerPage == list.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1321
						break;
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
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1325
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1326
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1327
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1328
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1329
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1330
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1331
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1332
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1333
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1334
				qDebug()<<"list count = "<<list.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1335
				aResult->setValue(list);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1336
				aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1337
				error = SmfPluginErrNone;
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
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1341
#if 0
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1342
		// User search
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1343
		else if(SmfMusicSearchUser == aOperation)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1344
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1345
			qDebug()<<"Response for searching users";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1346
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1347
			QList<SmfMusicProfile> list;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1348
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1349
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1350
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1351
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1352
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1353
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1354
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1355
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1356
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1357
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1358
				return SmfPluginErrParsingFailed;
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
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1361
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1362
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1363
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1364
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1365
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1366
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1367
				qDebug()<<"For getting user's neighbours";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1368
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1369
				QVariantMap map1 = result["neighbours"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1370
				QList<QVariant> list1 = map1["user"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1371
				QListIterator<QVariant> iter(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1372
				while(iter.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1373
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1374
					SmfMusicProfile profile;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1375
					QVariantMap map2 = iter.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1376
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1377
/*					QContactName name;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1378
					name.setFirstName(map2["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1379
					QVariant nameVar = QVariant::fromValue<QContactName>(name);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1380
					contact.setValue("Name", nameVar);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1381
											
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1382
					QContactUrl url;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1383
					url.setUrl(map2["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1384
					QVariant urlVar = QVariant::fromValue<QContactUrl>(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1385
					contact.setValue("Url", urlVar);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1386
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1387
					QContactAvatar avatar;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1388
					QList<QVariant> list2 = map2["image"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1389
					QListIterator<QVariant> iter2(list2);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1390
					while(iter2.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1391
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1392
						QVariantMap map3 = iter2.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1393
						QUrl imageUrl(map3["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1394
						avatar.setImageUrl(imageUrl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1395
						break;
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
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1398
					QVariant avatarVar = QVariant::fromValue<QContactAvatar>(avatar);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1399
					contact.setValue("Avatar", avatarVar);*/
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1400
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1401
					profile.setId(map2["name"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1402
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1403
					list.append(profile);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1404
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1405
					if(gItemsPerPage == list.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1406
						break;
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
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1411
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1412
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1413
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1414
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1415
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1416
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1417
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1418
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1419
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1420
				qDebug()<<"list count = "<<list.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1421
				aResult->setValue(list);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1422
				aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1423
				error = SmfPluginErrNone;
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
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1426
#endif
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1427
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1428
		else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1429
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1430
			qDebug()<<"Service unsupported!!!";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1431
			aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1432
			error = SmfPluginErrServiceNotSupported;
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
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1436
		else if(SmfTransportOpOperationCanceledError == aTransportResult)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1437
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1438
			qDebug()<<"Operation Cancelled !!!";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1439
			error = SmfPluginErrCancelComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1440
			aRetType = SmfRequestComplete;
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
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1443
		else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1444
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1445
			qDebug()<<"Transport Error !!!";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1446
			error = SmfPluginErrNetworkError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1447
			aRetType = SmfRequestError;
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
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1450
		return error;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1456
 * Destructor
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1457
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1458
LastFmMusicServiceProviderBase::~LastFmMusicServiceProviderBase( )
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1464
 * Method to get the Localisable name of the service.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1465
 * @return The Localisable name of the service.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1466
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1467
QString LastFmMusicServiceProviderBase::serviceName( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1468
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1469
	return m_serviceName;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1474
 * Method to get the Logo of the service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1475
 * @return The Logo of the service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1476
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1477
QImage LastFmMusicServiceProviderBase::serviceIcon( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1478
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1479
	return m_serviceIcon;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1484
 * Method to get the Readable service description
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1485
 * @return The Readable service description
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1486
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1487
QString LastFmMusicServiceProviderBase::description( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1488
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1489
	return m_description;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1494
 * Method to get the Website of the service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1495
 * @return The Website of the service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1496
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1497
QUrl LastFmMusicServiceProviderBase::serviceUrl( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1498
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1499
	return m_serviceUrl;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1504
 * 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
  1505
 * @return The URL of the Application providing this service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1506
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1507
QUrl LastFmMusicServiceProviderBase::applicationUrl( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1508
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1509
	return m_applicationUrl;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1514
 * Method to get the Icon of the application
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1515
 * @return The Icon of the application
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1516
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1517
QImage LastFmMusicServiceProviderBase::applicationIcon( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1518
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1519
	return m_applicationIcon;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1523
* 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
  1524
* @return List of supported Interafces
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1525
*/
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1526
QList<QString> LastFmMusicServiceProviderBase::supportedInterfaces( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1527
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1528
	return m_supportedInterfaces;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1532
* 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
  1533
* @return a QStringList of languages supported by this service 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1534
* provider in 2 letter ISO 639-1 format.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1535
*/
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1536
QStringList LastFmMusicServiceProviderBase::supportedLanguages( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1537
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1538
	return m_supportedLangs;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1542
 * Method to get the Plugin specific ID
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1543
 * @return The Plugin specific ID
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1544
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1545
QString LastFmMusicServiceProviderBase::pluginId( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1546
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1547
	return m_pluginId;
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1552
 * Method to get the ID of the authentication application 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1553
 * for this service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1554
 * @param aProgram The authentication application name
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1555
 * @param aArguments List of arguments required for authentication app
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1556
 * @param aMode Strting mode for authentication application
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1557
 * @return The ID of the authentication application 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1558
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1559
QString LastFmMusicServiceProviderBase::authenticationApp( QString &aProgram, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1560
		QStringList & aArguments, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1561
		QIODevice::OpenModeFlag aMode ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1562
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1563
	Q_UNUSED(aProgram)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1564
	Q_UNUSED(aArguments)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1565
	Q_UNUSED(aMode)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1566
	return m_authAppId;
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
/**
26
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1571
 * Method to get the authentication application process name
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1572
 * @return The authentication application process name (eg: "FlickrAuthApp.exe")
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1573
 */
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1574
QString LastFmMusicServiceProviderBase::authenticationAppName( ) const
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1575
	{
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1576
	return m_authAppName;
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1577
	}
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1578
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1579
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1580
/**
23
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1581
 * 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
  1582
 * Smf for authorised plugins
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1583
 * @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
  1584
 * authorised plugins
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1585
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1586
QString LastFmMusicServiceProviderBase::smfRegistrationId( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1587
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1588
	return m_smfRegToken;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1589
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1590
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1591
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1592
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1593
 * 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
  1594
 * from the initialize() method of the FBContactFetcherPlugin class
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1595
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1596
void LastFmMusicServiceProviderBase::initialize()
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
	m_serviceName = "last.fm";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1599
	m_description = "Last.fm music service plugin description";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1600
	m_serviceUrl = QUrl(QString("http://www.last.fm"));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1601
	m_pluginId = "lastfmmusicserviceplugin.qtplugin";
26
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1602
	m_authAppId =   "0xE1D8C7D8";
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1603
	m_authAppName = "LastFm.exe";
23
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1604
	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
  1605
	QSettings iSettings;
26
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
  1606
	m_smfRegToken = iSettings.value("CMLastFmRegToken").toString();
23
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1607
	m_validity = iSettings.value("LastFmExpiryTime").toDateTime();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1608
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1609
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1610
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1611
/*
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1612
 * Export Macro
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1613
 * plugin name : LastFmMusicServicePlugin
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1614
 * plugin class : LastFmMusicServicePlugin
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1615
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
  1616
Q_EXPORT_PLUGIN2( lastfmmusicserviceplugin, LastFmMusicServicePlugin )