example/lastfmplaylistserviceplugin/lastfmplaylistserviceplugin.cpp
author cgandhi
Mon, 11 Oct 2010 21:59:54 +0530
changeset 26 83d6a149c755
parent 23 574948b60dab
permissions -rw-r--r--
Submitting following changes - AuthApps for Last.fm and Twitter added API for checking ServiceAuthorization added for SMFCredMgrClient API added for forcefully removing credential details from SMFCredMgr Extra argument checks in SMfClient APIs APIs for service login and logout from SMFClient Redundant members removed from SmfServerSymbian DSM bug fixes Test Apps included
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
 * Sangeeta Prasad, 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
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    31
#include "lastfmplaylistserviceplugin.h"
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    32
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
static int gPageNum = 0; 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    35
static int gItemsPerPage = 0;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    36
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    37
//Payload data array
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    38
QByteArray payload;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    39
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    40
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    41
 * Destructor
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    42
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    43
LastFmPlaylistServicePlugin::~LastFmPlaylistServicePlugin( )
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
	if(m_provider)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    46
		delete m_provider;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    47
	}
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    50
 * 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
    51
 * @param aApiKey [out] The api key
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    52
 * @param aApiSecret [out] The api secret
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    53
 * @param aSessionKey [out] The session key
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    54
 * @param aToken [out] The session token
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    55
 * @param aName [out] The user name
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    56
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    57
void LastFmPlaylistServicePlugin::fetchKeys( QString &aApiKey, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    58
		QString &aApiSecret, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    59
		QString &aToken,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    60
		QString &aName )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    61
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    62
	qDebug()<<"Reg Token = "<<m_provider->m_smfRegToken;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    63
	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
    64
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    65
	SmfAuthParams keys;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    66
	SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    67
	util.getAuthKeys(keys, m_provider->m_smfRegToken, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    68
			m_provider->m_validity, m_provider->m_pluginId);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    69
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    70
    QByteArray keyName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    71
    keyName.append("ApiKey");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    72
	aApiKey.append(keys.value(keyName));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    73
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    74
    keyName.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    75
    keyName.append("ApiSecret");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    76
	aApiSecret.append(keys.value(keyName));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    77
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    78
	keyName.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    79
    keyName.append("Token");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    80
	aToken.append(keys.value(keyName));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    81
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    82
	keyName.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    83
    keyName.append("Name");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    84
	aName.append(keys.value(keyName));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    85
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    86
	qDebug()<<"Api Key = "<<aApiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    87
	qDebug()<<"Api Secret = "<<aApiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    88
	qDebug()<<"Token = "<<aToken;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    89
	qDebug()<<"Name = "<<aName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    90
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    91
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    92
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    93
 * 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
    94
 * @param aBaseString The base string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    95
 * @return The md5 hash of the base string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    96
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    97
QString LastFmPlaylistServicePlugin::generateSignature(const QString aBaseString)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    98
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
    99
	// Create md5 hash of the signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   100
    QByteArray byteArray;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   101
    byteArray.insert(0, aBaseString.toAscii());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   102
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   103
    QByteArray md5Hash = QCryptographicHash::hash(byteArray,QCryptographicHash::Md5 ).toHex();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   104
    QString returnString (md5Hash);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   105
    return returnString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   106
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   107
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   108
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   109
 * Method to get the playlist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   110
 * @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
   111
 * @param aPageNum [in] The page to be extracted
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   112
 * @param aItemsPerPage [in] Number of items per page
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   113
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   114
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   115
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   116
SmfPluginError LastFmPlaylistServicePlugin::playlists( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   117
		SmfPluginRequestData &aRequest,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   118
		const int aPageNum,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   119
		const int aItemsPerPage )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   120
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   121
	qDebug()<<"Inside LastFmPlaylistServicePlugin::playlists()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   122
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   123
	SmfPluginError error = SmfPluginErrInvalidArguments;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   124
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   125
	// invalid arguments
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   126
	if( aPageNum < 0 || aItemsPerPage < 0 )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   127
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   128
		qDebug()<<"Invalid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   129
		return error;
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
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   132
	qDebug()<<"Valid arguments";
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
	gPageNum = aPageNum;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   135
	gItemsPerPage = aItemsPerPage;
26
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   136
	qDebug()<<"Pagenumber = "<<gPageNum;
23
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   137
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   138
	// Get the key sets from SMF Plugin Utility class.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   139
	QString apiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   140
	QString apiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   141
	QString token;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   142
	QString userName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   143
	fetchKeys(apiKey, apiSecret, token, userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   144
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   145
	// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   146
	QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   147
	baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   148
	baseString.append("methoduser.getPlaylists");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   149
	baseString.append("user"+userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   150
	baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   151
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   152
	// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   153
	QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   154
	url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   155
	url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   156
	url.addQueryItem("method", "user.getPlaylists");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   157
	url.addQueryItem("user", userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   158
	url.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   159
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   160
	// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   161
	aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   162
	aRequest.iRequestType = SmfMusicGetPlaylists;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   163
	aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   164
	aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   165
	error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   166
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   167
	qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   168
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   169
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   170
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   171
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   172
 * Method to get the playlist of a particular user
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   173
 * @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
   174
 * @param aUser [in] The user whose playlists need to be fetched
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   175
 * @param aPageNum [in] The page to be extracted
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   176
 * @param aItemsPerPage [in] Number of items per page
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   177
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   178
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   179
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   180
SmfPluginError LastFmPlaylistServicePlugin::playlistsOf( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   181
		SmfPluginRequestData &aRequest,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   182
		const SmfContact &aUser,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   183
		const int aPageNum, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   184
		const int aItemsPerPage )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   185
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   186
	qDebug()<<"Inside LastFmPlaylistServicePlugin::playlistsOf()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   187
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   188
	SmfPluginError error = SmfPluginErrInvalidArguments;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   189
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   190
	// invalid arguments
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   191
	if( aPageNum < 0 || aItemsPerPage < 0 || 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   192
			aUser.value("Name").value<QContactName>().firstName().isEmpty() )
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
		qDebug()<<"Invalid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   195
		return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   196
		}
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
	qDebug()<<"Valid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   199
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   200
	gPageNum = aPageNum;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   201
	gItemsPerPage = aItemsPerPage;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   202
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   203
	// Get the key sets from SMF Plugin Utility class.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   204
	QString apiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   205
	QString apiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   206
	QString token;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   207
	QString userName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   208
	fetchKeys(apiKey, apiSecret, token, userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   209
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   210
	userName.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   211
	userName = aUser.value("Name").value<QContactName>().firstName();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   212
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   213
	// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   214
	QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   215
	baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   216
	baseString.append("methoduser.getPlaylists");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   217
	baseString.append("user"+userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   218
	baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   219
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   220
	// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   221
	QUrl url("http://ws.audioscrobbler.com/2.0/?");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   222
	url.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   223
	url.addQueryItem("format", "json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   224
	url.addQueryItem("method", "user.getPlaylists");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   225
	url.addQueryItem("user", userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   226
	url.addQueryItem("api_sig", generateSignature(baseString));
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 request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   229
	aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   230
	aRequest.iRequestType = SmfMusicGetPlaylistsOfUser;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   231
	aRequest.iPostData = NULL;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   232
	aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   233
	error = SmfPluginErrNone;
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
	qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   236
	return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   237
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   238
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   239
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   240
 * Method to add tracks to a playlist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   241
 * @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
   242
 * @param aPlaylist [in] The playlist where tracks should be added
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   243
 * @param aTracks [in] The tracks to be added to the playlist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   244
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   245
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   246
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   247
SmfPluginError LastFmPlaylistServicePlugin::addToPlaylist( 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   248
		SmfPluginRequestData &aRequest,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   249
		const SmfPlaylist &aPlaylist, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   250
		const QList<SmfTrackInfo> &aTracks )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   251
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   252
	qDebug()<<"Inside LastFmPlaylistServicePlugin::addToPlaylist()";
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
	SmfPluginError error = SmfPluginErrInvalidArguments;
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
	// invalid arguments
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   257
	if( aPlaylist.id().isEmpty() || (0 == aTracks.count()) )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   258
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   259
		qDebug()<<"Invalid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   260
		return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   261
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   262
	else if(aTracks.at(0).title().isEmpty() || aTracks.at(0).artists().names().at(0).isEmpty())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   263
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   264
		qDebug()<<"Invalid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   265
		return error;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   266
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   267
	else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   268
		qDebug()<<"Valid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   269
	
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
	// Get the key sets from SMF Plugin Utility class.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   272
	QString apiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   273
	QString apiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   274
	QString token;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   275
	QString userName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   276
	fetchKeys(apiKey, apiSecret, token, userName);
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
	// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   279
	QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   280
	baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   281
	baseString.append("artist"+aTracks.at(0).artists().names().at(0));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   282
	baseString.append("methodplaylist.addTrack");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   283
	baseString.append("playlistID"+aPlaylist.id());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   284
	baseString.append("sk"+token);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   285
	baseString.append("track"+aTracks.at(0).title());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   286
	baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   287
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   288
	QUrl postData;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   289
	postData.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   290
	postData.addQueryItem("artist", aTracks.at(0).artists().names().at(0));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   291
	postData.addQueryItem("format","json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   292
	postData.addQueryItem("method", "playlist.addTrack");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   293
	postData.addQueryItem("playlistID",aPlaylist.id());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   294
	postData.addQueryItem("sk",token);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   295
	postData.addQueryItem("track",aTracks.at(0).title());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   296
	postData.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   297
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   298
	QString data(postData.toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   299
	data.remove(0, 1); // Remove the first ?
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   300
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   301
	payload.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   302
	payload.append(data.toAscii());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   303
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   304
	qDebug()<<"Data = "<<QString(payload);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   305
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   306
	// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   307
	QUrl url("http://ws.audioscrobbler.com/2.0/");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   308
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   309
	// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   310
	aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   311
	aRequest.iNetworkRequest.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   312
	aRequest.iRequestType = SmfMusicAddToPlaylist;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   313
	aRequest.iPostData = new QBuffer(&payload);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   314
	aRequest.iHttpOperationType = QNetworkAccessManager::PostOperation;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   315
	error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   316
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   317
	qDebug()<<"Url string is : "<<aRequest.iNetworkRequest.url().toString();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   318
	return error;
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
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   321
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   322
 * Method to post the current playing playlist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   323
 * @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
   324
 * @param aPlaylist [in] The current playing playlist which should be posted
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   325
 * @return Appropriate value of the enum SmfPluginError.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   326
 * Plugin error if any, else SmfPluginErrNone for success
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   327
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   328
SmfPluginError LastFmPlaylistServicePlugin::postCurrentPlayingPlaylist(
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   329
		SmfPluginRequestData &aRequest, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   330
		const SmfPlaylist &aPlaylist )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   331
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   332
	qDebug()<<"Inside LastFmPlaylistServicePlugin::postCurrentPlayingPlaylist()";
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 error = SmfPluginErrInvalidArguments;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   335
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   336
	// invalid arguments
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   337
/*	if( aPlaylist.playListTitle().isEmpty() )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   338
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   339
		qDebug()<<"Invalid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   340
		return error;
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
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   343
	qDebug()<<"Valid arguments";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   344
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   345
	// Get the key sets from SMF Plugin Utility class.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   346
	QString apiKey;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   347
	QString apiSecret;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   348
	QString token;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   349
	QString userName;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   350
	fetchKeys(apiKey, apiSecret, token, userName);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   351
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   352
	// Create the API signature string
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   353
	QString baseString;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   354
	baseString.append("api_key"+apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   355
	baseString.append("methodplaylist.create");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   356
	baseString.append("sk"+token);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   357
	if( !aPlaylist.playListTitle().isEmpty()) //you can create a playlist without name also
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   358
		baseString.append("title"+aPlaylist.playListTitle());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   359
	baseString.append(apiSecret);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   360
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   361
	QUrl postData;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   362
	postData.addQueryItem("api_key", apiKey);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   363
	postData.addQueryItem("format","json");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   364
	postData.addQueryItem("method", "playlist.create");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   365
	postData.addQueryItem("sk",token);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   366
	if( !aPlaylist.playListTitle().isEmpty())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   367
		postData.addQueryItem("title",aPlaylist.playListTitle());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   368
	postData.addQueryItem("api_sig", generateSignature(baseString));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   369
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   370
	QString data(postData.toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   371
	data.remove(0, 1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   372
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   373
	payload.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   374
	payload.append(data.toAscii());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   375
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   376
	qDebug()<<"Data = "<<QString(payload);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   377
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   378
	// Create the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   379
	QUrl url("http://ws.audioscrobbler.com/2.0/");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   380
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   381
	// Create the request, set the url
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   382
	aRequest.iNetworkRequest.setUrl(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   383
	aRequest.iNetworkRequest.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   384
	aRequest.iRequestType = SmfMusicPostCurrentPlayingPlaylist;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   385
	aRequest.iPostData = new QBuffer(&payload);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   386
	aRequest.iHttpOperationType = QNetworkAccessManager::PostOperation;
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
 * Customised method for SmfPlaylistServicePlugin interface
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   395
 * @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
   396
 * @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
   397
 * the client interface and the plugin)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   398
 * @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
   399
 * 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
   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 LastFmPlaylistServicePlugin::customRequest( SmfPluginRequestData &aRequest, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   404
		const int &aOperation, QByteArray *aData )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   405
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   406
	Q_UNUSED(aRequest)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   407
	Q_UNUSED(aOperation)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   408
	Q_UNUSED(aData)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   409
	qDebug()<<"Inside LastFmPlaylistServicePlugin::customRequest()";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   410
	SmfPluginError error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   411
	return error;
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
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   414
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   415
 * 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
   416
 * 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
   417
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   418
void LastFmPlaylistServicePlugin::initialize( )
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
	// Create an instance of LastFmMusicServiceProviderBase
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   421
	m_provider = new LastFmPlaylistServiceProviderBase;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   422
	m_provider->initialize();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   423
	}
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   426
 * Method to get the provider information
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   427
 * @return Instance of SmfProviderBase
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   428
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   429
SmfProviderBase* LastFmPlaylistServicePlugin::getProviderInfo( )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   430
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   431
	return m_provider;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   432
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   433
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   434
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   435
 * Method to get the result for a network request.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   436
 * @param aOperation The type of operation to be requested
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   437
 * @param aTransportResult The result of transport operation
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   438
 * @param aResponse The QByteArray instance containing the network response.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   439
 * 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
   440
 * data from it.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   441
 * @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
   442
 * return value is SmfSendRequestAgain, QVariant will be of type
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   443
 * SmfPluginRequestData.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   444
 * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   445
 * 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
   446
 * 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
   447
 * 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
   448
 * 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
   449
 * 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
   450
 * 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
   451
 * postCurrentPlaying() or postRating() or postComments(), aResult will be of 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   452
 * type bool.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   453
 * @param aRetType [out] SmfPluginRetType
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   454
 * @param aPageResult [out] The SmfResultPage structure variable
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   455
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   456
SmfPluginError LastFmPlaylistServicePlugin::responseAvailable(
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   457
		const SmfRequestTypeID aOperation,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   458
		const SmfTransportResult &aTransportResult,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   459
		QByteArray *aResponse,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   460
		QVariant* aResult,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   461
		SmfPluginRetType &aRetType,
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   462
		SmfResultPage &aPageResult )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   463
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   464
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   465
	Q_UNUSED(aPageResult)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   466
	qDebug()<<"Inside LastFmPlaylistServicePlugin::responseAvailable()";
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 error = SmfPluginErrNetworkError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   469
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   470
	if( !aResponse || (0 == aResponse->size()) )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   471
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   472
		qDebug()<<"Response is NULL or empty";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   473
		aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   474
		return error;
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
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   477
	QByteArray response(*aResponse);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   478
	delete aResponse;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   479
	
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   480
	QFile respFile("c://data//SmfMusicPlaylistPluginResponse.txt");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   481
	if(!respFile.open(QIODevice::WriteOnly))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   482
		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
   483
	else
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
		respFile.write(response);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   486
		respFile.close();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   487
		qDebug()<<"Writing FB response to a file named 'SmfMusicPlaylistPluginResponse.txt'";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   488
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   489
	qDebug()<<"FB response size = "<<response.size();
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
	if(SmfTransportOpNoError == aTransportResult)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   492
		{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   493
		qDebug()<<"No transport error";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   494
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   495
		// Get user's playlists
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   496
		if(SmfMusicGetPlaylists == aOperation)
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
			qDebug()<<"Response for getting user's playlist";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   499
			QList<SmfPlaylist> list;				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   500
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   501
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   502
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   503
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   504
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   505
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   506
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   507
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   508
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   509
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   510
				return SmfPluginErrParsingFailed;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   511
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   512
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   513
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   514
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   515
			if(response.contains(QByteArray("error")))
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
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   518
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   519
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   520
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   521
				QVariantMap map1 = result["playlists"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   522
				QList<QVariant> list1 = map1["playlist"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   523
				QListIterator<QVariant> iter1(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   524
				bool ifList = false;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   525
				while(iter1.hasNext())
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
					ifList = true;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   528
					QVariantMap map2 = iter1.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   529
					SmfPlaylist playlist;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   530
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   531
					playlist.setPlayListTitle(map2["title"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   532
					playlist.setId(map2["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   533
					playlist.setAuthor(map2["creator"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   534
					QUrl url(map2["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   535
					playlist.setInfo(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   536
					playlist.setLocation(url);
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
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   539
					QList<QVariant> list2 = map2["image"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   540
					QListIterator<QVariant> iter2(list2);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   541
					while(iter2.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   542
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   543
						QVariantMap map3 = iter2.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   544
						QUrl imageUrl(map3["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   545
						playlist.setImage(imageUrl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   546
						}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   547
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   548
					list.append((playlist));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   549
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   550
					if(gItemsPerPage == list.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   551
						break;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   552
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   553
				if(!ifList)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   554
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   555
					QVariantMap map2 = map1["playlist"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   556
					SmfPlaylist playlist;
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
					playlist.setPlayListTitle(map2["title"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   559
					playlist.setId(map2["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   560
					playlist.setAuthor(map2["creator"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   561
					QUrl url(map2["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   562
					playlist.setInfo(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   563
					playlist.setLocation(url);
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
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   566
					QList<QVariant> list2 = map2["image"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   567
					QListIterator<QVariant> iter2(list2);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   568
					while(iter2.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   569
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   570
						QVariantMap map3 = iter2.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   571
						QUrl imageUrl(map3["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   572
						playlist.setImage(imageUrl);
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
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   575
					list.append((playlist));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   576
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   577
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   578
				if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   579
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   580
					qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   581
					error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   582
					aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   583
					aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   584
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   585
				else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   586
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   587
					qDebug()<<"Count of user's recent tracks  = "<<list.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   588
					aResult->setValue(list);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   589
					aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   590
					error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   591
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   592
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   593
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   594
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   595
		// Playlists of another user
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   596
		else if ( SmfMusicGetPlaylistsOfUser == aOperation )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   597
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   598
			qDebug()<<"Response for getting another user's playlist";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   599
			QList<SmfPlaylist> list;				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   600
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   601
			errStr.clear();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   602
				
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   603
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   604
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   605
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   606
			if (!ok) 
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
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   609
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   610
				return SmfPluginErrParsingFailed;
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
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   613
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   614
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   615
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   616
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   617
				errStr.append(result["message"].toString());
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
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   620
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   621
				QVariantMap map1 = result["playlists"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   622
				QList<QVariant> list1 = map1["playlist"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   623
				QListIterator<QVariant> iter1(list1);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   624
				bool ifList = false;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   625
				while(iter1.hasNext())
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
					ifList = true;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   628
					QVariantMap map2 = iter1.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   629
					SmfPlaylist playlist;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   630
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   631
					playlist.setPlayListTitle(map2["title"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   632
					playlist.setId(map2["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   633
					playlist.setAuthor(map2["creator"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   634
					QUrl url(map2["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   635
					playlist.setInfo(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   636
					playlist.setLocation(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   637
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   638
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   639
					QList<QVariant> list2 = map2["image"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   640
					QListIterator<QVariant> iter2(list2);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   641
					while(iter2.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   642
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   643
						QVariantMap map3 = iter2.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   644
						QUrl imageUrl(map3["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   645
						playlist.setImage(imageUrl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   646
						}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   647
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   648
					list.append((playlist));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   649
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   650
					if(gItemsPerPage == list.count())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   651
						break;
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
				if(!ifList)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   654
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   655
					QVariantMap map2 = map1["playlist"].toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   656
					SmfPlaylist playlist;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   657
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   658
					playlist.setPlayListTitle(map2["title"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   659
					playlist.setId(map2["id"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   660
					playlist.setAuthor(map2["creator"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   661
					QUrl url(map2["url"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   662
					playlist.setInfo(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   663
					playlist.setLocation(url);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   664
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   665
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   666
					QList<QVariant> list2 = map2["image"].toList();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   667
					QListIterator<QVariant> iter2(list2);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   668
					while(iter2.hasNext())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   669
						{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   670
						QVariantMap map3 = iter2.next().toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   671
						QUrl imageUrl(map3["#text"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   672
						playlist.setImage(imageUrl);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   673
						}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   674
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   675
					list.append((playlist));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   676
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   677
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   678
				if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   679
					{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   680
					qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   681
					error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   682
					aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   683
					aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   684
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   685
				else
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
					qDebug()<<"Count of friend's playlists  = "<<list.count();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   688
					aResult->setValue(list);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   689
					aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   690
					error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   691
					}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   692
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   693
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   694
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   695
		// Adding track to playlist AND
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   696
		// Post current playing playlist
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   697
		else if ((SmfMusicAddToPlaylist == aOperation) || (SmfMusicPostCurrentPlayingPlaylist == aOperation))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   698
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   699
			qDebug()<<"Response for adding track to playlist";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   700
			bool reqSuccess = false;		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   701
			QString errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   702
			errStr.clear();
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
			bool ok;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   705
			SmfPluginUtil util;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   706
			QVariantMap result = util.parse(response, &ok).toMap();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   707
			if (!ok) 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   708
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   709
				qDebug()<<"An error occurred during json parsing";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   710
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   711
				return SmfPluginErrParsingFailed;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   712
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   713
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   714
			qDebug()<<"Json parsing complete";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   715
			
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   716
			if(response.contains(QByteArray("error")))
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   717
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   718
				errStr.append(result["message"].toString());
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   719
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   720
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   721
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   722
				reqSuccess = true;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   723
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   724
					
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   725
			if(errStr.size())
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   726
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   727
				qDebug()<<"Response error found = "<<errStr;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   728
				error = SmfPluginErrInvalidRequest;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   729
				aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   730
				aResult->setValue(errStr);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   731
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   732
			else
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   733
				{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   734
				qDebug()<<"Track added to playlist?? "<<reqSuccess;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   735
				aResult->setValue(reqSuccess);
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   736
				aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   737
				error = SmfPluginErrNone;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   738
				}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   739
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   740
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   741
		// Other Service requests - NOT SUPPORTED
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   742
		else
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
			qDebug()<<"Service unsupported!!!";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   745
			aRetType = SmfRequestError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   746
			error = SmfPluginErrServiceNotSupported;
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
		}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   749
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   750
		else if(SmfTransportOpOperationCanceledError == aTransportResult)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   751
			{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   752
			qDebug()<<"Operation Cancelled !!!";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   753
			error = SmfPluginErrCancelComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   754
			aRetType = SmfRequestComplete;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   755
			}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   756
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   757
		else
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
			qDebug()<<"Transport Error !!!";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   760
			error = SmfPluginErrNetworkError;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   761
			aRetType = SmfRequestError;
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
		
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   764
		return error;
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
	}
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
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   769
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   770
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   771
 * Destructor
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   772
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   773
LastFmPlaylistServiceProviderBase::~LastFmPlaylistServiceProviderBase( )
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   774
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   775
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   776
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   777
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   778
 * Method to get the Localisable name of the service.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   779
 * @return The Localisable name of the service.
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
QString LastFmPlaylistServiceProviderBase::serviceName( ) const
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
	return m_serviceName;
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
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   788
 * Method to get the Logo of the service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   789
 * @return The Logo of the service
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
QImage LastFmPlaylistServiceProviderBase::serviceIcon( ) const
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
	return m_serviceIcon;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   794
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   795
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   796
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   797
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   798
 * Method to get the Readable service description
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   799
 * @return The Readable service description
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
QString LastFmPlaylistServiceProviderBase::description( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   802
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   803
	return m_description;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   804
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   805
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   806
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   807
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   808
 * Method to get the Website of the service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   809
 * @return The Website of the service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   810
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   811
QUrl LastFmPlaylistServiceProviderBase::serviceUrl( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   812
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   813
	return m_serviceUrl;
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
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   818
 * 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
   819
 * @return The URL of the Application providing this service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   820
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   821
QUrl LastFmPlaylistServiceProviderBase::applicationUrl( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   822
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   823
	return m_applicationUrl;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   824
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   825
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   826
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   827
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   828
 * Method to get the Icon of the application
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   829
 * @return The Icon of the application
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
QImage LastFmPlaylistServiceProviderBase::applicationIcon( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   832
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   833
	return m_applicationIcon;
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
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
* 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
   838
* @return List of supported Interafces
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   839
*/
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   840
QList<QString> LastFmPlaylistServiceProviderBase::supportedInterfaces( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   841
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   842
	return m_supportedInterfaces;
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
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   845
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   846
* 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
   847
* @return a QStringList of languages supported by this service 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   848
* provider in 2 letter ISO 639-1 format.
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   849
*/
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   850
QStringList LastFmPlaylistServiceProviderBase::supportedLanguages( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   851
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   852
	return m_supportedLangs;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   853
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   854
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   855
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   856
 * Method to get the Plugin specific ID
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   857
 * @return The Plugin specific ID
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   858
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   859
QString LastFmPlaylistServiceProviderBase::pluginId( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   860
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   861
	return m_pluginId;
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
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
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   866
 * Method to get the ID of the authentication application 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   867
 * for this service
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   868
 * @param aProgram The authentication application name
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   869
 * @param aArguments List of arguments required for authentication app
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   870
 * @param aMode Strting mode for authentication application
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   871
 * @return The ID of the authentication application 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   872
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   873
QString LastFmPlaylistServiceProviderBase::authenticationApp( QString &aProgram, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   874
		QStringList & aArguments, 
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   875
		QIODevice::OpenModeFlag aMode ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   876
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   877
	Q_UNUSED(aProgram)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   878
	Q_UNUSED(aArguments)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   879
	Q_UNUSED(aMode)
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   880
	return m_authAppId;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   881
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   882
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   883
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   884
/**
26
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   885
 * Method to get the authentication application process name
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   886
 * @return The authentication application process name (eg: "FlickrAuthApp.exe")
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   887
 */
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   888
QString LastFmPlaylistServiceProviderBase::authenticationAppName( ) const
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   889
	{
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   890
	return m_authAppName;
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   891
	}
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   892
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   893
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   894
/**
23
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   895
 * 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
   896
 * Smf for authorised plugins
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   897
 * @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
   898
 * authorised plugins
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   899
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   900
QString LastFmPlaylistServiceProviderBase::smfRegistrationId( ) const
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   901
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   902
	return m_smfRegToken;
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   903
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   904
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   905
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   906
/**
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   907
 * 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
   908
 * from the initialize() method of the FBContactFetcherPlugin class
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
void LastFmPlaylistServiceProviderBase::initialize()
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   911
	{
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   912
	m_serviceName = "last.fm";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   913
	m_description = "Last.fm music playlist plugin description";
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   914
	m_serviceUrl = QUrl(QString("http://www.last.fm"));
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   915
	m_pluginId = "lastfmplaylistserviceplugin.qtplugin";
26
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   916
	m_authAppId =   "0xE1D8C7D8";
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   917
	m_authAppName = "LastFm.exe";
23
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   918
	m_supportedInterfaces.append("org.symbian.smf.plugin.music.playlist/v0.2");
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   919
	QSettings iSettings;
26
83d6a149c755 Submitting following changes -
cgandhi
parents: 23
diff changeset
   920
	m_smfRegToken = iSettings.value("CMLastFmRegToken").toString();
23
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   921
	m_validity = iSettings.value("LastFmExpiryTime").toDateTime();
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   922
	}
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   923
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   924
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   925
/*
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   926
 * Export Macro
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   927
 * plugin name : lastfmplaylistserviceplugin
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   928
 * plugin class : LastFmPlaylistServicePlugin
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   929
 */
574948b60dab updating the lastfm music plugins and adding the smfhelp.chm
cgandhi
parents:
diff changeset
   930
Q_EXPORT_PLUGIN2( lastfmplaylistserviceplugin, LastFmPlaylistServicePlugin )