# HG changeset patch # User cgandhi # Date 1285242303 -19800 # Node ID 574948b60dabc230cbd44df2b3ee674caa1298c5 # Parent b2eb79881f9d163a0f2da37b3479b40f666334c5 updating the lastfm music plugins and adding the smfhelp.chm diff -r b2eb79881f9d -r 574948b60dab doc/html.rar Binary file doc/html.rar has changed diff -r b2eb79881f9d -r 574948b60dab doc/smfhelp.chm Binary file doc/smfhelp.chm has changed diff -r b2eb79881f9d -r 574948b60dab example/AuthApp/ui_AuthApp.h --- a/example/AuthApp/ui_AuthApp.h Thu Sep 16 11:15:30 2010 +0530 +++ b/example/AuthApp/ui_AuthApp.h Thu Sep 23 17:15:03 2010 +0530 @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'AuthApp.ui' ** -** Created: Fri Jul 30 14:06:33 2010 +** Created: Wed Sep 22 18:28:00 2010 ** by: Qt User Interface Compiler version 4.6.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! diff -r b2eb79881f9d -r 574948b60dab example/AuthApp/ui_progressbar.h --- a/example/AuthApp/ui_progressbar.h Thu Sep 16 11:15:30 2010 +0530 +++ b/example/AuthApp/ui_progressbar.h Thu Sep 23 17:15:03 2010 +0530 @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'progressbar.ui' ** -** Created: Fri Jul 30 14:06:30 2010 +** Created: Wed Sep 22 18:27:56 2010 ** by: Qt User Interface Compiler version 4.6.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! diff -r b2eb79881f9d -r 574948b60dab example/DemoGUI/.cproject --- a/example/DemoGUI/.cproject Thu Sep 16 11:15:30 2010 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r b2eb79881f9d -r 574948b60dab example/DemoGUI/ImageDownload.cpp --- a/example/DemoGUI/ImageDownload.cpp Thu Sep 16 11:15:30 2010 +0530 +++ b/example/DemoGUI/ImageDownload.cpp Thu Sep 23 17:15:03 2010 +0530 @@ -65,9 +65,6 @@ // For proxy settings on emulator only - REMOVE for device QString httpProxy = "10.1.0.214"; QString httpPort = "3128"; - - qDebug()< +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "musiclyricsplugin.h" + + + +//Added for testing - start +//static const QString apiKey = "8823ece35e487bada68fa893d7ecf91e"; +static const QString apiKey = "1b76e55254f5f22ae"; +//static const QString apiSecret = "20ccb1cc62aa50caf7d8aae31808d429"; +//static const QString miniToken = "773193698 "; + +//QString fullToken = "72157624000326005-e6cba1c7665a778e"; + +//Payload data array +QByteArray payload; +QString uids; +/** + * Method called by plugins for logging + * @param log string to be logged + */ +void MusicLyricsPlugin::writeLog(QString log) const + { + QFile file("c:\\data\\LyricsPluginLogs.txt"); + if (!file.open(QIODevice::Append | QIODevice::Text)) + ; + QTextStream out(&file); + out << log << "\n"; + file.close(); + } + +/** + * Destructor + */ +MusicLyricsPlugin::~MusicLyricsPlugin() + { + if(m_provider) + delete m_provider; + } + + +/** + * Method called by plugins to generate a signature string from a base string + * @param aBaseString The base string + * @return The md5 hash of the base string + */ +QString MusicLyricsPlugin::generateSignature(const QString aBaseString) + { + writeLog("MusicLyricsPlugin::generateSignature"); + + // Create md5 hash of the signature string + QByteArray byteArray; + byteArray.insert(0, aBaseString.toAscii()); + + QByteArray md5Hash = QCryptographicHash::hash(byteArray,QCryptographicHash::Md5 ).toHex(); + QString returnString (md5Hash); + return returnString; + } + + +SmfPluginError MusicLyricsPlugin::lyrics( SmfPluginRequestData &aRequest, + const SmfTrackInfo &aTrack, + const int aPageNum , + const int aItemsPerPage ) + { + SmfPluginError error = SmfPluginErrUserNotLoggedIn; + + writeLog("MusicLyricsPlugin::lyrics()"); + + QString baseString; + //spanda + QString Url1 = "http://api.lyricsfly.com/api/txt-api.php?"; + Url1 += "i=7a48a610d6c65171a-temporary.API.access";//[USER ID] + Url1 += "&"; + Url1 += "l=one_love";//[LYRICS TEXT STRING] + //till here + + //baseString.append(apiSecret); +/* baseString.append("api_key"+apiKey); + //baseString.append("auth_token"); + //baseString.append("method=geo.getEvents"); + writeLog("Url string is :"+baseString); + // Create the url + QUrl url("http://api.lyricsfly.com/api/"); + //url.addQueryItem("method", "geo.getevents"); + //url.addQueryItem("location","madrid"); + url.addQueryItem("api_key", apiKey); + url.addQueryItem("api_sig", generateSignature(baseString)); + writeLog("/n/n"+generateSignature(baseString)); + writeLog("/n/n Response is :"+url.toString());*/ + // Create the request, set the url + aRequest.iNetworkRequest.setUrl(Url1); + aRequest.iRequestType = SmfMusicGetLyrics; + + //aRequest.iPostData = NULL; + aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; + writeLog("/n/n responseAvailble() is getting called"); + error = SmfPluginErrNone; + return error; + } + +SmfPluginError MusicLyricsPlugin::subtitles( SmfPluginRequestData &aRequest, + const SmfTrackInfo &aTrack, + const SmfSubtitleSearchFilter &aFilter , + const int aPageNum , + const int aItemsPerPage ) + { + //spanda_13 + SmfPluginError error = SmfPluginErrUserNotLoggedIn; + + writeLog("MusicLyricsPlugin::subtitle()"); + + QString baseString; + //spanda + QString Url2 = "http://api.allsubs.org/index.php?"; + Url2 += "search=anaconda"; + Url2 += "&"; + Url2 += "language=en"; + Url2 += "&"; + Url2 += "limit=3"; + + + aRequest.iNetworkRequest.setUrl(Url2); + aRequest.iRequestType = SmfMusicGetSubtitle; + + //aRequest.iPostData = NULL; + aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; + //writeLog("/n/n responseAvailble() is getting called"); + error = SmfPluginErrNone; + return error; + //till here + } +/** + * Customised method for SmfMusicEventsPlugin interface + * @param aRequest [out] The request data to be sent to network + * @param aOperation The operation type (should be known between + * the client interface and the plugin) + * @param aData The data required to form the request (The type + * of data should be known between client and the plugin) + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ +SmfPluginError MusicLyricsPlugin::customRequest( SmfPluginRequestData &aRequest, + const int &aOperation, QByteArray *aData ) + { + Q_UNUSED(aRequest) + Q_UNUSED(aOperation) + Q_UNUSED(aData) + return SmfPluginErrServiceNotSupported; + } + +/** + * The first method to be called in the plugin that implements this interface. + * If this method is not called, plugin may not behave as expected. + * Plugins are expected to save the aUtil handle and use and when required. + * @param aUtil The instance of SmfPluginUtil + */ +void MusicLyricsPlugin::initialize( /*SmfPluginUtil *aUtil*/) + { + // Save the SmfPluginUtil handle + //m_util = aUtil; + + // Create an instance of MusicProviderBase + m_provider = new MusicProviderBase; + m_provider->initialize(); + } + +/** + * Method to get the provider information + * @return Instance of SmfProviderBase + */ +SmfProviderBase* MusicLyricsPlugin::getProviderInfo( ) + { + return m_provider; + } + +/** + * Method to get the result for a network request. + * @param aOperation The type of operation to be requested + * @param aTransportResult The result of transport operation + * @param aResponse The QByteArray instance containing the network response. + * The plugins should delete this instance once they have read the + * data from it. + * @param aResult [out] An output parameter to the plugin manager.If the + * return value is SmfSendRequestAgain, QVariant will be of type + * SmfPluginRequestData. + * For SmfLyricsServicePlugin: If last operation was lyrics(), aResult will + * be of type QList. If last operation was subtitles(), aResult will +* be of type QList. + */ +SmfPluginError MusicLyricsPlugin::responseAvailable( + const SmfRequestTypeID aOperation, + const SmfTransportResult &aTransportResult, + QByteArray *aResponse, + QVariant* aResult, + SmfPluginRetType &aRetType, + SmfResultPage &aPageResult ) + { + writeLog("MusicLyricsPlugin::responseAvailable"); + Q_UNUSED(aPageResult) + SmfPluginError error = SmfPluginErrNetworkError; + + if( !aResponse || (0 == aResponse->size()) ) + { + writeLog("Response is NULL or empty"); + aRetType = SmfRequestError; + return error; + } + + QByteArray response(*aResponse); + delete aResponse; + + //Write the response to a file + QFile file("c:\\data\\musiclyricsresponse.txt"); + writeLog("response data written to c:\\data\\musiclyricsresponse.txt"); + + if (!file.open(QIODevice::Append | QIODevice::Text)); + file.write(response); + file.close(); + + writeLog("MusicEvent response = "+QString(response)); + writeLog("MusicEvent response size = "+QString::number(response.size(), 10)); + + if(SmfTransportOpNoError == aTransportResult) + { + qDebug()<<"No transport error"; + + if(SmfMusicGetLyrics == aOperation ) + { + QList SmfLyricsList; + //spanda_14 + qDebug()<<"Xml parsing"; + + //For getting contacts from xml response + QXmlStreamReader xml(response); + //int count = 0; + while (!xml.atEnd()) + { + xml.readNext(); + if (xml.tokenType() == QXmlStreamReader::StartElement) + { + SmfLyrics lyrics; + //SmfLyrics + if (xml.name() == "id") + { + + + qDebug()<<"id tag found"; + QString id ; + QString message(xml.readElementText()); + id.append(message); + qDebug()<<" IDS : "<< id; + lyrics.setId(id); + //count++; + + } + if (xml.name() == "tx") + { + + qDebug()<<"tx tag found"; + QString tx; + QString message(xml.readElementText()); + tx.append(message); + qDebug()<<" text : "<< tx; + QByteArray data; + QDataStream stream(&data, QIODevice::ReadWrite); + stream< SmfSubtitleList; + + writeLog("Xml parsing"); + + SmfSubtitle Lyricssubtiltle1; + Lyricssubtiltle1.setSubtitleUrl(QUrl("http://www.allsubs.org/subs-download/anaconda/1276543/")); + Lyricssubtiltle1.setLanguage("english"); + QDateTime dt = QDateTime::currentDateTime(); + Lyricssubtiltle1.setReleaseYear(dt); + SmfSubtitleList.append(Lyricssubtiltle1); + + SmfSubtitle Lyricssubtiltle2; + Lyricssubtiltle2.setSubtitleUrl(QUrl("http://www.allsubs.org/subs-download/")); + Lyricssubtiltle2.setLanguage("hindi"); + QDateTime dt1 = QDateTime::currentDateTime(); + Lyricssubtiltle2.setReleaseYear(dt1); + SmfSubtitleList.append(Lyricssubtiltle2); + + SmfSubtitle Lyricssubtiltle3; + Lyricssubtiltle3.setSubtitleUrl(QUrl("http://www.allsubs.org")); + Lyricssubtiltle3.setLanguage("hindi"); + QDateTime dt2 = QDateTime::currentDateTime(); + Lyricssubtiltle3.setReleaseYear(dt2); + SmfSubtitleList.append(Lyricssubtiltle3); + + //For getting contacts from xml response + QXmlStreamReader xml(response); + //int count = 0; + /*while (!xml.atEnd()) + { + SmfSubtitle Lyricssubtiltle; + xml.readNext(); + + if(xml.tokenType() == QXmlStreamReader::StartDocument) + { + continue; + } + + if (xml.tokenType() == QXmlStreamReader::StartElement) + { + if (xml.name() == "AllSubsAPI") + { + continue; + } + //writeLog("START ELEMNT"+xml.name().toString()); + if (xml.name() == "items") + continue; + + if (xml.name() == "item") + { + // xml.readNext(); + while(!(xml.tokenType() == QXmlStreamReader::EndElement && + xml.name() == "item")) + { + writeLog("loop"); + if(xml.tokenType() == QXmlStreamReader::StartElement) + { + + //} + // We've found link. + if(xml.name() == "link") + { + + Lyricssubtiltle.setSubtitleUrl(xml.readElementText()); + writeLog("link "+ Lyricssubtiltle.subtitleUrl()); + writeLog("LINK"+xml.readElementText()); + + } + // We've found email. + if(xml.name() == "languages") + { + Lyricssubtiltle.setLanguage(xml.readElementText()); + writeLog("languages "+Lyricssubtiltle.language()); + writeLog("languages"+xml.readElementText()); + + + } + // We've found website. + if(xml.name() == "added_on") + { + QDateTime dt = QDateTime::fromString(xml.readElementText());//stringToTime() + Lyricssubtiltle.setReleaseYear(dt); + writeLog("added_on "+Lyricssubtiltle.releaseYear().toString()); + writeLog("added_on"+xml.readElementText()); + } + + } + SmfSubtitleList.append(Lyricssubtiltle); + // ...and next... + xml.readNext(); + }//while + + //} + + }//end OF IF iem + // }//end of If + }//end of start elementIF + + + + }//end of while*/ + + //} + writeLog("End Of Log"); + writeLog("Count of subtitlles List:"+QString::number(SmfSubtitleList.count(),10)); + aResult->setValue(SmfSubtitleList); + aRetType = SmfRequestComplete; + + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + else + { + writeLog("Service unsupported!!!"); + aRetType = SmfRequestError; + error = SmfPluginErrServiceNotSupported; + } + }//end if of if(SmfTransportOpNoError == aTransportResult) + + else if(SmfTransportOpOperationCanceledError == aTransportResult) + { + writeLog("Operation Cancelled !!!"); + error = SmfPluginErrCancelComplete; + aRetType = SmfRequestComplete; + } + + else + { + writeLog("Transport Error !!!"); + error = SmfPluginErrNetworkError; + aRetType = SmfRequestError; + } + + return error; + } + + +/** + * Destructor + */ +MusicProviderBase::~MusicProviderBase( ) + { + } + +/** + * Method to get the Localisable name of the service. + * @return The Localisable name of the service. + */ +QString MusicProviderBase::serviceName( ) const + { + return m_serviceName; + } + +/** + * Method to get the Logo of the service + * @return The Logo of the service + */ +QImage MusicProviderBase::serviceIcon( ) const + { + return m_serviceIcon; + } + +/** + * Method to get the Readable service description + * @return The Readable service description + */ +QString MusicProviderBase::description( ) const + { + return m_description; + } + +/** + * Method to get the Website of the service + * @return The Website of the service + */ +QUrl MusicProviderBase::serviceUrl( ) const + { + return m_serviceUrl; + } + +/** + * Method to get the URL of the Application providing this service + * @return The URL of the Application providing this service + */ +QUrl MusicProviderBase::applicationUrl( ) const + { + return m_applicationUrl; + } + +/** + * Method to get the Icon of the application + * @return The Icon of the application + */ +QImage MusicProviderBase::applicationIcon( ) const + { + return m_applicationIcon; + } +/** +* Method to get the list of interfaces that this provider support +* @return List of supported Interafces +*/ +QList MusicProviderBase::supportedInterfaces( ) const + { + return m_serviceType; + } + +/** +* Method to get the list of languages supported by this service provider +* @return a QStringList of languages supported by this service +* provider in 2 letter ISO 639-1 format. +*/ +QStringList MusicProviderBase::supportedLanguages( ) const + { + return m_supportedLanguages; + } + +/** + * Method to get the Plugin specific ID + * @return The Plugin specific ID + */ +QString MusicProviderBase::pluginId( ) const + { + return m_pluginId; + } + +/** + * Method to get the ID of the authentication application + * for this service + * @param aProgram The authentication application name + * @param aArguments List of arguments required for authentication app + * @param aMode Strting mode for authentication application + * @return The ID of the authentication application + */ +QString MusicProviderBase::authenticationApp( QString &aProgram, + QStringList & aArguments, + QIODevice::OpenModeFlag aMode ) const + { + return m_authAppId; + } + +/** + * Method to get the unique registration ID provided by the + * Smf for authorised plugins + * @return The unique registration ID/token provided by the Smf for + * authorised plugins + */ +QString MusicProviderBase::smfRegistrationId( ) const + { + return m_smfRegToken; + } + +void MusicProviderBase::initialize() + { + m_serviceName = "LyricsFly"; + m_description = "Description"; + m_serviceUrl = QUrl(QString("http://api.lyricsfly.com")); + m_serviceType << m_serviceName << m_description;// << (QString)(m_serviceUrl); + m_supportedLanguages << "English" ; + m_pluginId = "musiclyricsplugin.qtplugin"; + m_authAppId = "0xEFE2FD23"; + m_smfRegToken = "hsdfusdghf"; + + //sandeep_Added_13-08-2010 + /* m_serviceName = "allsubs"; + m_description = "Description"; + //m_serviceUrl = QUrl(QString//("http://api.allsubs.org")); + + // m_serviceType << m_serviceName << m_description;// << (QString)(m_serviceUrl); + m_supportedLanguages << "English" ; + m_pluginId = "musiclyricsplugin.qtplugin"; + m_authAppId = "0xEFE2FD23"; + m_smfRegToken = "hsdfusdghf"; + //m_smfRegToken = "hsdfusdghf"; //yet to be recvd*/ + + } + + +/* + * Export Macro + * plugin name : MusicLyricsPlugin + * plugin class : MusicLyricsPlugin + */ +Q_EXPORT_PLUGIN2( musiclyricsplugin, MusicLyricsPlugin ) diff -r b2eb79881f9d -r 574948b60dab example/MusicLyricsPlugin/MusicLyricsPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/MusicLyricsPlugin/MusicLyricsPlugin.h Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,253 @@ +/* + * MusicLyricsPlugin.h + * + * Created on: Aug 18, 2010 + * Author: sanpra + */ + + + +#ifndef MUSICLYRICSPLUGIN_H_ +#define MUSICLYRICSPLUGIN_H_ + +// Include files +#include "smflyricsserviceplugin.h" +#include "smfpluginutil.h" + +#include + +// Forward declarations +class MusicProviderBase; +class QVariant; +class QNetworkReply; + +// Class declaration +class MusicLyricsPlugin : public QObject, public SmfLyricsServicePlugin +{ + Q_OBJECT + Q_INTERFACES( SmfLyricsServicePlugin SmfPluginBase ) + +public: + virtual ~MusicLyricsPlugin(); + +public: // From SmfMusicEventsPlugin + + /** + * Method to get the lyrics + * @param aRequest [out] The request data to be sent to network + * @param aTrack The track whose lyrics need to be fetched + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError lyrics( SmfPluginRequestData &aRequest, + const SmfTrackInfo &aTrack, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ) ; + + /** + * Method to get the subtitle + * @param aRequest [out] The request data to be sent to network + * @param aTrack The track whose subtitle need to be fetched + * @param aFilter The subtitle search filter if any + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError subtitles( SmfPluginRequestData &aRequest, + const SmfTrackInfo &aTrack, + const SmfSubtitleSearchFilter &aFilter = SubtitleAll, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ) ; + /** + * Customised method for SmfMusicEventsPlugin interface + * @param aRequest [out] The request data to be sent to network + * @param aOperation The operation type (should be known between + * the client interface and the plugin) + * @param aData The data required to form the request (The type + * of data should be known between client and the plugin) + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError customRequest( SmfPluginRequestData &aRequest, + const int &aOperation, QByteArray *aData ); + +public: // From SmfPluginBase + /** + * The first method to be called in the plugin that implements this interface. + * If this method is not called, plugin may not behave as expected. + * Plugins are expected to save the aUtil handle and use and when required. + * @param aUtil The instance of SmfPluginUtil + */ + void initialize(/*SmfPluginUtil *aUtil*/); + + /** + * Method to get the provider information + * @return Instance of SmfProviderBase + */ + SmfProviderBase* getProviderInfo( ); + + /** + * Method to get the result for a network request. + * @param aTransportResult The result of transport operation + * @param aReply The QNetworkReply instance for the request + * @param aResult [out] An output parameter to the plugin manager.If the + * return value is SmfSendRequestAgain, QVariant will be of type + * SmfPluginRequestData. + * For SmfGalleryPlugin: If last operation was pictures(), aResult will + * be of type QList. If last operation was description(), + * aResult will be of type QString. If last operation was upload() or + * postComment(), aResult will be of type bool. + * @param aRetType [out] SmfPluginRetType + * @param aPageResult [out] The SmfResultPage structure variable + */ + /* SmfPluginError responseAvailable( + const SmfTransportResult &aTransportResult, + QNetworkReply *aReply, + QVariant* aResult, + SmfPluginRetType &aRetType, + SmfResultPage &aPageResult );*/ + SmfPluginError responseAvailable( + const SmfRequestTypeID aOperation, + const SmfTransportResult &aTransportResult, + QByteArray *aResponse, + QVariant* aResult, + SmfPluginRetType &aRetType, + SmfResultPage &aPageResult ); + + void writeLog(QString log) const; + + +private: + + QString generateSignature(const QString aBaseString); + + +private slots: + + + +private: + /** + * Method called by plugins to generate a request data + * @param aRequest [out] The request data to be sent to network + * @param aOperation The type of http operation + * @param aSignatureMethod The signature method to be used + * @param aParams A map of parameters to its values + * @param aMode The mode of creation of the request + * @param aPostData The data to be posted (for HTTP POST + * only, else it will be NULL) + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError createRequest( SmfPluginRequestData &aRequest,const QNetworkAccessManager::Operation aOperation, + const SmfSignatureMethod aSignatureMethod, + QMultiMap &aParams, + const SmfParsingMode aMode, + QBuffer *aPostData ); + +private: + MusicProviderBase *m_provider; + SmfPluginUtil *m_util; +}; + +// Class declaration +class MusicProviderBase : public QObject, public SmfProviderBase + { + Q_OBJECT + Q_INTERFACES( SmfProviderBase ) + +public: + virtual ~MusicProviderBase( ); + + /** + * Method to get the Localisable name of the service. + * @return The Localisable name of the service. + */ + QString serviceName( ) const; + + /** + * Method to get the Logo of the service + * @return The Logo of the service + */ + QImage serviceIcon( ) const; + + /** + * Method to get the Readable service description + * @return The Readable service description + */ + QString description( ) const; + + /** + * Method to get the Website of the service + * @return The Website of the service + */ + QUrl serviceUrl( ) const; + + /** + * Method to get the URL of the Application providing this service + * @return The URL of the Application providing this service + */ + QUrl applicationUrl( ) const; + + /** + * Method to get the Icon of the application + * @return The Icon of the application + */ + QImage applicationIcon( ) const; + + /** + * Method to get the list of interfaces that this provider support + * @return List of supported Interafces + */ + QList supportedInterfaces( ) const; + + /** + * Method to get the list of languages supported by this service provider + * @return a QStringList of languages supported by this service + * provider in 2 letter ISO 639-1 format. + */ + QStringList supportedLanguages( ) const; + + /** + * Method to get the Plugin specific ID + * @return The Plugin specific ID + */ + QString pluginId( ) const; + + /** + * Method to get the ID of the authentication application + * for this service + * @param aProgram The authentication application name + * @param aArguments List of arguments required for authentication app + * @param aMode Strting mode for authentication application + * @return The ID of the authentication application + */ + QString authenticationApp( QString &aProgram, QStringList & aArguments, + QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const; + + /** + * Method to get the unique registration ID provided by the + * Smf for authorised plugins + * @return The unique registration ID/token provided by the Smf for + * authorised plugins + */ + QString smfRegistrationId( ) const; + +private: + friend class MusicLyricsPlugin; + void initialize(); + QString m_serviceName; + QImage m_serviceIcon; + QString m_description; + QUrl m_serviceUrl; + QUrl m_applicationUrl; + QImage m_applicationIcon; + QStringList m_serviceType; + QStringList m_supportedLanguages; + QString m_pluginId; + QString m_authAppId; + QString m_smfRegToken; + }; + + + +#endif /* MUSICLYRICSPLUGIN_H_ */ diff -r b2eb79881f9d -r 574948b60dab example/MusicLyricsPlugin/MusicLyricsPlugin.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/MusicLyricsPlugin/MusicLyricsPlugin.pro Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,37 @@ +TEMPLATE = lib +CONFIG += plugin \ + mobility +MOBILITY += location +QT += core \ + xml \ + network +HEADERS = musiclyricsplugin.h +SOURCES = musiclyricsplugin.cpp +TARGET = $$qtLibraryTarget(musiclyricsplugin) +symbian: { + # Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files + load(data_caging_paths) + + # EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data + TARGET.EPOCALLOWDLLDATA = 1 + + # Defines plugin files into Symbian .pkg package + pluginDep.sources = musiclyricsplugin.dll + pluginDep.path = $$QT_PLUGINS_BASE_DIR/smf/plugin/music.lyrics + DEPLOYMENT += pluginDep + TARGET.CAPABILITY = ReadUserData \ + WriteUserData \ + LocalServices \ + NetworkServices \ + UserEnvironment \ + ReadDeviceData \ + WriteDeviceData + LIBS += -lsmfclient.dll + LIBS += -lsmfcommon + LIBS += -lqjson.dll +} +target.path += $$[QT_INSTALL_PLUGINS]/smf/plugin/music.lyrics +INSTALLS += target + + + diff -r b2eb79881f9d -r 574948b60dab example/MusicLyricsPlugin/plugin_commonU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/MusicLyricsPlugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,16 @@ +; ============================================================================== +; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50 +; This file is generated by qmake and should not be modified by the +; user. +; Name : plugin_commonU.def +; Part of : musiclyricsplugin +; Description : Fixes common plugin symbols to known ordinals +; Version : +; +; ============================================================================== + + +EXPORTS + qt_plugin_query_verification_data @ 1 NONAME + qt_plugin_instance @ 2 NONAME + diff -r b2eb79881f9d -r 574948b60dab example/MusicLyricsPlugin/qmakepluginstubs/musiclyricsplugin.qtplugin --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/MusicLyricsPlugin/qmakepluginstubs/musiclyricsplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,1 @@ +This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50 diff -r b2eb79881f9d -r 574948b60dab example/example.pro --- a/example/example.pro Thu Sep 16 11:15:30 2010 +0530 +++ b/example/example.pro Thu Sep 23 17:15:03 2010 +0530 @@ -6,6 +6,11 @@ fbpostproviderplugin \ flickrcontactfetcherplugin \ flickrgalleryplugin \ + lastfmmusicsearchplugin \ + lastfmmusicserviceplugin \ + lastfmplaylistserviceplugin \ + lastfmmusiceventplugin \ + MusicLyricsPlugin \ smfclientapp \ DemoGUI CONFIG += ordered \ No newline at end of file diff -r b2eb79881f9d -r 574948b60dab example/fbactivityfetcherplugin/plugin_commonU.def --- a/example/fbactivityfetcherplugin/plugin_commonU.def Thu Sep 16 11:15:30 2010 +0530 +++ b/example/fbactivityfetcherplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530 @@ -1,5 +1,5 @@ ; ============================================================================== -; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-07-30T14:11:44 +; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50 ; This file is generated by qmake and should not be modified by the ; user. ; Name : plugin_commonU.def diff -r b2eb79881f9d -r 574948b60dab example/fbactivityfetcherplugin/qmakepluginstubs/fbactivityfetcherplugin.qtplugin --- a/example/fbactivityfetcherplugin/qmakepluginstubs/fbactivityfetcherplugin.qtplugin Thu Sep 16 11:15:30 2010 +0530 +++ b/example/fbactivityfetcherplugin/qmakepluginstubs/fbactivityfetcherplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530 @@ -1,1 +1,1 @@ -This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-07-30T14:11:44 +This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50 diff -r b2eb79881f9d -r 574948b60dab example/fbcontactfetcherplugin/fbcontactfetcherplugin.cpp --- a/example/fbcontactfetcherplugin/fbcontactfetcherplugin.cpp Thu Sep 16 11:15:30 2010 +0530 +++ b/example/fbcontactfetcherplugin/fbcontactfetcherplugin.cpp Thu Sep 23 17:15:03 2010 +0530 @@ -405,12 +405,14 @@ * Method to search for a contact in a group * @param aRequest [out] The request data to be sent to network * @param aGroup the group in which to search + * @param aContact The contact to be searched, default (NULL) is the self contact. * @param aPageNum The page to be extracted * @param aItemsPerPage Number of items per page * @return SmfPluginError Plugin error if any, else SmfPluginErrNone */ SmfPluginError FBContactFetcherPlugin::searchInGroup( SmfPluginRequestData &aRequest, const SmfGroup &aGroup, + SmfContact *aContact, const int aPageNum , const int aItemsPerPage ) { diff -r b2eb79881f9d -r 574948b60dab example/fbcontactfetcherplugin/fbcontactfetcherplugin.h --- a/example/fbcontactfetcherplugin/fbcontactfetcherplugin.h Thu Sep 16 11:15:30 2010 +0530 +++ b/example/fbcontactfetcherplugin/fbcontactfetcherplugin.h Thu Sep 23 17:15:03 2010 +0530 @@ -112,12 +112,14 @@ * Method to search for a contact in a group * @param aRequest [out] The request data to be sent to network * @param aGroup the group in which to search + * @param aContact The contact to be searched, default (NULL) is the self contact. * @param aPageNum The page to be extracted * @param aItemsPerPage Number of items per page * @return SmfPluginError Plugin error if any, else SmfPluginErrNone */ SmfPluginError searchInGroup( SmfPluginRequestData &aRequest, const SmfGroup &aGroup, + SmfContact *aContact = NULL, const int aPageNum = SMF_FIRST_PAGE, const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); diff -r b2eb79881f9d -r 574948b60dab example/fbcontactfetcherplugin/plugin_commonU.def --- a/example/fbcontactfetcherplugin/plugin_commonU.def Thu Sep 16 11:15:30 2010 +0530 +++ b/example/fbcontactfetcherplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530 @@ -1,5 +1,5 @@ ; ============================================================================== -; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-07-30T14:11:44 +; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50 ; This file is generated by qmake and should not be modified by the ; user. ; Name : plugin_commonU.def diff -r b2eb79881f9d -r 574948b60dab example/fbcontactfetcherplugin/qmakepluginstubs/fbcontactfetcherplugin.qtplugin --- a/example/fbcontactfetcherplugin/qmakepluginstubs/fbcontactfetcherplugin.qtplugin Thu Sep 16 11:15:30 2010 +0530 +++ b/example/fbcontactfetcherplugin/qmakepluginstubs/fbcontactfetcherplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530 @@ -1,1 +1,1 @@ -This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-07-30T14:11:44 +This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50 diff -r b2eb79881f9d -r 574948b60dab example/fbpostproviderplugin/plugin_commonU.def --- a/example/fbpostproviderplugin/plugin_commonU.def Thu Sep 16 11:15:30 2010 +0530 +++ b/example/fbpostproviderplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530 @@ -1,5 +1,5 @@ ; ============================================================================== -; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-07-30T14:11:44 +; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50 ; This file is generated by qmake and should not be modified by the ; user. ; Name : plugin_commonU.def diff -r b2eb79881f9d -r 574948b60dab example/fbpostproviderplugin/qmakepluginstubs/fbpostproviderplugin.qtplugin --- a/example/fbpostproviderplugin/qmakepluginstubs/fbpostproviderplugin.qtplugin Thu Sep 16 11:15:30 2010 +0530 +++ b/example/fbpostproviderplugin/qmakepluginstubs/fbpostproviderplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530 @@ -1,1 +1,1 @@ -This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-07-30T14:11:44 +This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50 diff -r b2eb79881f9d -r 574948b60dab example/flickrcontactfetcherplugin/flickrcontactfetcherplugin.cpp --- a/example/flickrcontactfetcherplugin/flickrcontactfetcherplugin.cpp Thu Sep 16 11:15:30 2010 +0530 +++ b/example/flickrcontactfetcherplugin/flickrcontactfetcherplugin.cpp Thu Sep 23 17:15:03 2010 +0530 @@ -183,11 +183,70 @@ const int aPageNum , const int aItemsPerPage ) { +#ifndef TESTINGTHISFUNCTION Q_UNUSED(aRequest) Q_UNUSED(aPageNum) Q_UNUSED(aItemsPerPage) qDebug()<<"Inside FlickrContactFetcherPlugin::followers()"; return SmfPluginErrServiceNotSupported; +#else + SmfPluginError error = SmfPluginErrInvalidArguments; + + // invalid arguments + if( aPageNum < 0 || aItemsPerPage < 0 ) + { + qDebug()<<"Invalid arguments"; + return error; + } + + qDebug()<<"Valid arguments"; + + // Get the key sets from SMF Plugin Utility class. + QString apiKey; + QString apiSecret; + QString authToken; + fetchKeys(apiKey, apiSecret, authToken ); + + // Create the API signature string + QString baseString; + baseString.append(apiSecret); + baseString.append("api_key"+apiKey); + baseString.append("auth_token"+authToken); + baseString.append("filterfriends"); +#ifdef SMF_XMLPARSING + baseString.append("formatxml"); +#else + baseString.append("formatjson"); +#endif + baseString.append("methodflickr.contacts.getList"); + baseString.append("page"+QString::number(aPageNum)); + baseString.append("per_page"+QString::number(aItemsPerPage)); + + // Create the url + QUrl url("http://api.flickr.com/services/rest/?"); + url.addQueryItem("api_key", apiKey); + url.addQueryItem("auth_token", authToken); + url.addQueryItem("filter", "friends"); +#ifdef SMF_XMLPARSING + url.addQueryItem("format", "x"); +#else + url.addQueryItem("format", "json"); +#endif + url.addQueryItem("method", "flickr.contacts.getList"); + url.addQueryItem("page", QString::number(aPageNum)); + url.addQueryItem("per_page", QString::number(aItemsPerPage)); + url.addQueryItem("api_sig", generateSignature(baseString)); + + // Create the request, set the url + aRequest.iNetworkRequest.setUrl(url); + aRequest.iRequestType = SmfContactGetFollowers; + aRequest.iPostData = NULL; + aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; + error = SmfPluginErrNone; + + qDebug()<<"Url string is : "<().firstName())); + + + // Create the url + QUrl url("http://api.flickr.com/services/rest/?"); + url.addQueryItem("api_key", apiKey); + url.addQueryItem("auth_token", authToken); + url.addQueryItem("format", "json"); + url.addQueryItem("method", "flickr.people.findByUsername"); + url.addQueryItem("username",aContact.value("Name").value().firstName()); + //url.addQueryItem("page", QString::number(10)); + //url.addQueryItem("per_page", QString::number(10)); + + url.addQueryItem("api_sig", generateSignature(baseString)); + + // Create the request, set the url + aRequest.iNetworkRequest.setUrl(url); + aRequest.iRequestType = SmfContactSearch; + aRequest.iPostData = NULL; + aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; + error = SmfPluginErrNone; +// writeLog("Url string is :"+aRequest.iNetworkRequest.url().toString()); + return error; + +#endif } /** @@ -227,6 +330,7 @@ const int aPageNum , const int aItemsPerPage ) { +#ifndef TESTINGTHISFUNCTION Q_UNUSED(aRequest) Q_UNUSED(aLocation) Q_UNUSED(aProximity) @@ -234,6 +338,64 @@ Q_UNUSED(aItemsPerPage) qDebug()<<"Inside FlickrContactFetcherPlugin::searchNear()"; return SmfPluginErrServiceNotSupported; +#else + SmfPluginError error = SmfPluginErrInvalidArguments; + + // invalid arguments + if( aPageNum < 0 || aItemsPerPage < 0 ) + { + qDebug()<<"Invalid arguments"; + return error; + } + + qDebug()<<"Valid arguments"; + + // Get the key sets from SMF Plugin Utility class. + QString apiKey; + QString apiSecret; + QString authToken; + fetchKeys(apiKey, apiSecret, authToken ); + + // Create the API signature string + QString baseString; + baseString.append(apiSecret); + baseString.append("api_key"+apiKey); + baseString.append("auth_token"+authToken); + baseString.append("filterfriends"); +#ifdef SMF_XMLPARSING + baseString.append("formatxml"); +#else + baseString.append("formatjson"); +#endif + baseString.append("methodflickr.contacts.getList"); + baseString.append("page"+QString::number(aPageNum)); + baseString.append("per_page"+QString::number(aItemsPerPage)); + + // Create the url + QUrl url("http://api.flickr.com/services/rest/?"); + url.addQueryItem("api_key", apiKey); + url.addQueryItem("auth_token", authToken); + url.addQueryItem("filter", "friends"); +#ifdef SMF_XMLPARSING + url.addQueryItem("format", "x"); +#else + url.addQueryItem("format", "json"); +#endif + url.addQueryItem("method", "flickr.contacts.getList"); + url.addQueryItem("page", QString::number(aPageNum)); + url.addQueryItem("per_page", QString::number(aItemsPerPage)); + url.addQueryItem("api_sig", generateSignature(baseString)); + + // Create the request, set the url + aRequest.iNetworkRequest.setUrl(url); + aRequest.iRequestType = SmfContactSearchNear; + aRequest.iPostData = NULL; + aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; + error = SmfPluginErrNone; + + qDebug()<<"Url string is : "< list; + QVariantMap map2 = map1["groups"].toMap(); + int page = map2["page"].toInt(&ok); + qDebug()<<"PAGE = "< list1 = map2["group"].toList(); + QListIterator iter(list1); + + //Getting the group list from QJson Parser + while(iter.hasNext()) + { + QVariantMap map2 = iter.next().toMap(); + qDebug()<<"name = "<setValue(result); + if (listIndex < count) + { + listIndex=listIndex+1; + error = SmfPluginErrNone; + aRetType = SmfSendRequestAgain; + + } + else + { + //Final result sent + count=1; //clear counter + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + + } else if (SmfPicturePostComment == aOperation) { qDebug()<<"Response for adding comment on a photo"; diff -r b2eb79881f9d -r 574948b60dab example/flickrgalleryplugin/plugin_commonU.def --- a/example/flickrgalleryplugin/plugin_commonU.def Thu Sep 16 11:15:30 2010 +0530 +++ b/example/flickrgalleryplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530 @@ -1,5 +1,5 @@ ; ============================================================================== -; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-07-30T14:11:44 +; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50 ; This file is generated by qmake and should not be modified by the ; user. ; Name : plugin_commonU.def diff -r b2eb79881f9d -r 574948b60dab example/flickrgalleryplugin/qmakepluginstubs/flickrgalleryplugin.qtplugin --- a/example/flickrgalleryplugin/qmakepluginstubs/flickrgalleryplugin.qtplugin Thu Sep 16 11:15:30 2010 +0530 +++ b/example/flickrgalleryplugin/qmakepluginstubs/flickrgalleryplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530 @@ -1,1 +1,1 @@ -This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-07-30T14:11:44 +This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50 diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusiceventplugin/lastfmmusiceventplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusiceventplugin/lastfmmusiceventplugin.cpp Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,955 @@ +/* + * lastfmmusiceventplugin.cpp + * + * Created on: Jun 21, 2010 + * Author: ankitg + */ + +//Include files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "lastfmmusiceventplugin.h" + + + +//Added for testing - start +//static const QString apiKey = "8823ece35e487bada68fa893d7ecf91e"; +//static const QString apiKey = "50ac6d6581c3784efe40748fe87d8413"; +//static const QString apiSecret = "20ccb1cc62aa50caf7d8aae31808d429"; +//static const QString apiSecret = "623f4274bcea772fd6f411cf298b6bfa"; +//static const QString miniToken = "773193698 "; + +//static const QString apiKey = "eb3a2d8361718782ebf3887f2bb8775b"; +//static const QString apiSecret = "7a390c4c1ec4fef41cef4d77354b30f8"; // created on 12th Aug + +static const QString apiKey = "50ac6d6581c3784efe40748fe87d8413"; +static const QString apiSecret = "623f4274bcea772fd6f411cf298b6bfa"; // created on 23th Aug + +//QString fullToken = "72157624000326005-e6cba1c7665a778e"; + +//Payload data array +QByteArray payload; +QString uids; +/** + * Method called by plugins for logging + * @param log string to be logged + */ +void MusicEventPlugin::writeLog(QString log) const + { + QFile file("c:\\data\\PluginLogs.txt"); + if (!file.open(QIODevice::Append | QIODevice::Text)) + ; + QTextStream out(&file); + out << log << "\n"; + file.close(); + } +/** + * Method to interpret the key sets obtained from credential manager + * @param aApiKey [out] The api key + * @param aApiSecret [out] The api secret + * @param aSessionKey [out] The session key + * @param aSessionSecret [out] The session secret + * @param aAppId [out] The application ID + */ +void MusicEventPlugin::fetchKeys( QString &aApiKey, + QString &aApiSecret, + QString &aSessionKey, + QString &aSessionSecret ) + { + writeLog("Inside MusicEventPlugin::fetchKeys()"); + + writeLog("Reg Token = "+m_provider->m_smfRegToken); + writeLog("Expiry Date as int = "+m_provider->m_validity.toTime_t()); + + SmfAuthParams keys; + SmfPluginUtil util; + util.getAuthKeys(keys, m_provider->m_smfRegToken, + m_provider->m_validity, m_provider->m_pluginId); + + writeLog("Number of key-value pairs = "+keys.count()); + + QByteArray keyName; + keyName.append("ApiKey"); + aApiKey.append(keys.value(keyName)); + + keyName.clear(); + keyName.append("ApiSecret"); + aApiSecret.append(keys.value(keyName)); + + keyName.clear(); + keyName.append("SessionKey"); + aSessionKey.append(keys.value(keyName)); + + keyName.clear(); + keyName.append("SessionSecret"); + aSessionSecret.append(keys.value(keyName)); + + writeLog("Api Key = "+aApiKey); + writeLog("Api Secret = "+aApiSecret); + writeLog("session Key = "+aSessionKey); + writeLog("session Secret = "+aSessionSecret); + } +/** + * Destructor + */ +MusicEventPlugin::~MusicEventPlugin() + { + if(m_provider) + delete m_provider; + } + + +/** + * Method called by plugins to generate a signature string from a base string + * @param aBaseString The base string + * @return The md5 hash of the base string + */ +QString MusicEventPlugin::generateSignature(const QString aBaseString) + { + writeLog("MusicEventPlugin::generateSignature"); + + // Create md5 hash of the signature string + QByteArray byteArray; + byteArray.insert(0, aBaseString.toAscii()); + + QByteArray md5Hash = QCryptographicHash::hash(byteArray,QCryptographicHash::Md5 ).toHex(); + QString returnString (md5Hash); + return returnString; + } + +/** + * Method to get the events based on location + * @param aRequest [out] The request data to be sent to network + * @param aLocation Location of the event + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ +/*SmfPluginError MusicEventPlugin::events( SmfPluginRequestData &aRequest, + const QGeoPositionInfo &aLocation,const int aPageNum, + const int aItemsPerPage) + { + Q_UNUSED(aItemsPerPage); + SmfPluginError error = SmfPluginErrUserNotLoggedIn; + + writeLog("MusicEventPlugin::events()"); + + QString baseString; + baseString.append(apiSecret); + baseString.append("api_key"+apiKey); + baseString.append("auth_token"); + baseString.append("formatjson"); + baseString.append("location=Delhi"); + baseString.append("method=geo.getEvents"); + writeLog("Url string is :"+baseString); + + // Create the url + QUrl url("http://ws.audioscrobbler.com/2.0/?"); + url.addQueryItem("method", "geo.getevents"); + url.addQueryItem("location","madrid"); + url.addQueryItem("api_key", apiKey); + url.addQueryItem("format","json"); + url.addQueryItem("auth_token",""); + url.addQueryItem("api_sig", generateSignature(baseString)); + writeLog("/n/n"+generateSignature(baseString)); + writeLog("/n/n Response is :"+url.toString()); + // Create the request, set the url + aRequest.iNetworkRequest.setUrl(url); + aRequest.iRequestType = SmfMusicGetEventsOnLoc; + aRequest.iPostData = NULL; + aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; + error = SmfPluginErrNone; + return error; + } + */ +/** + * Method to get the venues based on location + * @param aRequest [out] The request data to be sent to network + * @param aLocation Location of the venue + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ +SmfPluginError MusicEventPlugin::venues( SmfPluginRequestData &aRequest, + const SmfLocation &aLocation,const int aPageNum, + const int aItemsPerPage) + { + Q_UNUSED(aItemsPerPage); + Q_UNUSED(aPageNum); + + SmfPluginError error = SmfPluginErrUserNotLoggedIn; + + // Get the key sets from SMF Plugin Utility class. + QString apiKey; + QString apiSecret; + QString sessionKey; + QString sessionSecret; + fetchKeys(apiKey, apiSecret, sessionKey, sessionSecret); + writeLog("API KEY"+apiKey); + writeLog("API SECRET"+apiSecret); + writeLog("SessionKey"+sessionKey); + writeLog("sessionSecret"+sessionSecret); + writeLog("MusicEventPlugin::Venues()"); + //QString qName("New York"); + //aLocation.setCity(qName); + //QString qLocation = aLocation.city(); + //640418 + //QString qLocation("New York"); +/* QString baseString; + baseString.append(apiSecret); + baseString.append("api_key"+apiKey); + baseString.append("auth_token"); + baseString.append("formatjson"); + baseString.append("location ="+aLocation.city()); + baseString.append("method=geo.getEvents"); + writeLog("Url string is :"+baseString); + + //Create the url + QUrl url("http://ws.audioscrobbler.com/2.0/?"); + url.addQueryItem("method", "geo.getevents"); + url.addQueryItem("location",aLocation.city()); + url.addQueryItem("api_key", apiKey); + url.addQueryItem("api_key", apiKey); + url.addQueryItem("format","json"); + url.addQueryItem("auth_token",""); + url.addQueryItem("api_sig", generateSignature(baseString)); + + writeLog("/n/n"+generateSignature(baseString)); + writeLog("/n/n Response is :"+url.toString()); + //Create the request, set the url + aRequest.iNetworkRequest.setUrl(url); + aRequest.iRequestType = SmfEventsGetVenues; + aRequest.iPostData = NULL; + aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; + error = SmfPluginErrNone; + return error; */ + + + QString baseString; + baseString.append(apiSecret); + baseString.append("api_key"+apiKey); + baseString.append("auth_token"); + baseString.append("formatjson"); + baseString.append("location=Newyork"); + baseString.append("method=geo.getEvents"); + writeLog("Url string is :"+baseString); + + // Create the url + QUrl url("http://ws.audioscrobbler.com/2.0/?"); + url.addQueryItem("method", "geo.getevents"); + url.addQueryItem("location","Newyork"); + url.addQueryItem("api_key", apiKey); + url.addQueryItem("format","json"); + url.addQueryItem("auth_token",""); + url.addQueryItem("api_sig", generateSignature(baseString)); + writeLog("/n/n"+generateSignature(baseString)); + writeLog("/n/n Response is :"+url.toString()); + // Create the request, set the url + aRequest.iNetworkRequest.setUrl(url); + aRequest.iRequestType = SmfEventsGetEvents; + aRequest.iPostData = NULL; + aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; + error = SmfPluginErrNone; + return error; + + + } + +/** + * Method to get the events based on venues + * @param aRequest [out] The request data to be sent to network + * @param aVenue Venue of the event + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ +SmfPluginError MusicEventPlugin::events( SmfPluginRequestData &aRequest, + const SmfLocation &aVenue,const int aPageNum, + const int aItemsPerPage) + { + Q_UNUSED(aItemsPerPage); + Q_UNUSED(aPageNum); + + SmfPluginError error = SmfPluginErrUserNotLoggedIn; + + + // Get the key sets from SMF Plugin Utility class. + QString apiKey; + QString apiSecret; + QString sessionKey; + QString sessionSecret; + fetchKeys(apiKey, apiSecret, sessionKey, sessionSecret); + writeLog("API KEY"+apiKey); + writeLog("API SECRET"+apiSecret); + writeLog("SessionKey"+sessionKey); + writeLog("sessionSecret"+sessionSecret); + + QString baseString; + baseString.append(apiSecret); + baseString.append("api_key"+apiKey); + baseString.append("auth_token"); + baseString.append("formatjson"); + baseString.append("location="+aVenue.city()); + baseString.append("method=geo.getEvents"); + writeLog("Url string is :"+baseString); + + // Create the url + QUrl url("http://ws.audioscrobbler.com/2.0/?"); + url.addQueryItem("method", "geo.getevents"); + url.addQueryItem("location",aVenue.city()); + url.addQueryItem("api_key", apiKey); + url.addQueryItem("format","json"); + url.addQueryItem("auth_token",""); + url.addQueryItem("api_sig", generateSignature(baseString)); + writeLog("/n/n"+generateSignature(baseString)); + writeLog("/n/n Response is :"+url.toString()); + //Create the request, set the url + aRequest.iNetworkRequest.setUrl(url); + aRequest.iRequestType = SmfEventsGetEvents; + aRequest.iPostData = NULL; + aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; + error = SmfPluginErrNone; + return error; + + } + +/** + * Method to post events + * @param aRequest [out] The request data to be sent to network + * @param aEventList The list of events to be posted + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ +SmfPluginError MusicEventPlugin::postEvents( SmfPluginRequestData &aRequest, + const QList &aEventList ) + { + Q_UNUSED(aEventList) + SmfPluginError error = SmfPluginErrUserNotLoggedIn; + writeLog("MusicEventPlugin::events()"); + int count =aEventList.count(); + for(int i=0;iinitialize(); + } + +/** + * Method to get the provider information + * @return Instance of SmfProviderBase + */ +SmfProviderBase* MusicEventPlugin::getProviderInfo( ) + { + return m_provider; + } + +/** + * Method to get the result for a network request. + * @param aOperation The type of operation to be requested + * @param aTransportResult The result of transport operation + * @param aResponse The QByteArray instance containing the network response. + * The plugins should delete this instance once they have read the + * data from it. + * @param aResult [out] An output parameter to the plugin manager.If the + * return value is SmfSendRequestAgain, QVariant will be of type + * SmfPluginRequestData. + * For SmfGalleryPlugin: If last operation was pictures(), aResult will + * be of type QList. If last operation was description(), + * aResult will be of type QString. If last operation was upload() or + * postComment(), aResult will be of type bool. + * @param aRetType [out] SmfPluginRetType + * @param aPageResult [out] The SmfResultPage structure variable + */ +SmfPluginError MusicEventPlugin::responseAvailable( + const SmfRequestTypeID aOperation, + const SmfTransportResult &aTransportResult, + QByteArray *aResponse, + QVariant* aResult, + SmfPluginRetType &aRetType, + SmfResultPage &aPageResult ) + { + writeLog("MusicEventPlugin::responseAvailable"); + Q_UNUSED(aPageResult) + SmfPluginError error = SmfPluginErrNetworkError; + + if( !aResponse || (0 == aResponse->size()) ) + { + writeLog("Response is NULL or empty"); + aRetType = SmfRequestError; + return error; + } + + QByteArray response(*aResponse); + delete aResponse; + + //Write the response to a file + QFile file("c:\\data\\musiceventresponse.txt"); + writeLog("response data written to c:\\data\\musiceventresponse.txt"); + + if (!file.open(QIODevice::Append | QIODevice::Text)); + file.write(response); + file.close(); + + writeLog("MusicEvent response = "+QString(response)); + writeLog("MusicEvent response size = "+QString::number(response.size(), 10)); + + if(SmfTransportOpNoError == aTransportResult) + { + writeLog("No transport error"); + // QVariantMap map1; + // bool resType=response.startsWith(" eventlist; + + + + //Tested By Hardcoding + + SmfEvent event; + event.setId("111111"); + event.setTitle("bangalore"); + event.setEventDateTime(dt); + QStringList stringList; //for artist + stringList.append("sssss"); + stringList.append("aaaa"); + SmfArtists artists; + artists.setNames(stringList); + event.setArtists(artists); + + SmfLocation Location; + Location.setCity("Bangalore"); + Location.setCountry("india"); + + event.setVenue(Location); + eventlist.append(event); + + //2nd Event + SmfEvent event1; + event1.setId("2222"); + event1.setTitle("delhi"); + event1.setEventDateTime(dt); + QStringList stringList1; //for artist + stringList1.append("ddddd"); + stringList1.append("rrrrrr"); + SmfArtists artists1; + artists1.setNames(stringList1); + event1.setArtists(artists1); + + SmfLocation Location1; + Location1.setCity("Delhi"); + Location1.setCountry("india"); + + event1.setVenue(Location1); + eventlist.append(event1); + + writeLog("SmfEventsGetEvents = "); + /*QVariantMap eventmap = map1["events"].toMap(); + QList list1 = eventmap["event"].toList(); + + QListIterator iter(list1); + writeLog("SmfEventsGetEvents123 = "); + while(iter.hasNext()) //not runing for one event + { + SmfEvent event; + QVariantMap map2 = iter.next().toMap(); + writeLog("id = "+map2["id"].toString()); + event.setId(map2["id"].toString()); + writeLog("title = "+map2["title"].toString()); + event.setTitle(map2["title"].toString()); + writeLog("EventDateTime= "+map2["startDate"].toString()); + event.setEventDateTime(map2["startDate"].toDateTime()); + // writeLog("SetdUration= "+map2["startDate"].toDateTime()); //didn't find that + //for Getting the Artist List + QVariantMap map4 = map2["artists"].toMap(); + QList artistList =map4["artist"].toList(); + + writeLog("artist"+map4["artist"].toString()); + + // writeLog("artists"+artistList["artist"].toString()); + // QList artistList =map2["artists"].toList(); + + + QListIterator iterartists(artistList); + SmfArtists artists; + QStringList stringList; + while(iterartists.hasNext()) + { + + //QString artistName; + QString artistName = iterartists.next().toString(); + writeLog("artist Name = "+ artistName); + //artistName.append(map2["artist"].toString()); + stringList.append(artistName); + + }//end while + //writeLog("artists= "+stringList[0]); + + artists.setNames(stringList); + event.setArtists(artists); + + //all Artist list we got + //For Venue + SmfLocation Location; + QVariantMap map3 = map2["venue"].toMap(); + writeLog("LocationId : "+map3["id"].toString()); + Location.setId(map3["id"].toString()); + //for city + QVariantMap map6 = map3["location"].toMap(); + writeLog("Location city : "+map6["city"].toString()); + Location.setCity(map6["city"].toString()); + writeLog("Location city : "+map6["country"].toString()); + Location.setCountry(map6["country"].toString()); + // Location.geoPositionInfo() dont know how to set + event.setVenue(Location); + eventlist.append(event); + }//end While*/ + aResult->setValue(eventlist); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + else if(SmfEventsGetVenues == aOperation) + { + writeLog("SmfEventsGetVenues = "); + QList LocationList; + SmfLocation Location; + Location.setId("111111"); + //for city + Location.setCity("delhi"); + Location.setCountry("India"); + Location.setUrl(QUrl("http://wwwqqqqq/ee")); + LocationList.append(Location); + + SmfLocation Location1; + Location1.setId("22222"); + //for city + Location1.setCity("bangalore"); + Location1.setCountry("India"); + LocationList.append(Location1); + + aResult->setValue(LocationList); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + + + } + + else if (SmfEventsPostEvents == aOperation) + { + writeLog("SmfEventsPostEvents = "); + bool postEvent=true; + aResult->setValue(postEvent); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + + } + else if (SmfEventsGetEventAttendees == aOperation) + { + + QList contactList; + + writeLog("SmfMusicGetEventsAttendees = "); + bool ok; + writeLog("Before Parser--"); + + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + writeLog("An error occurred during json parsing"); + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + + } + + //QVariantMap map1 = result.toMap(); + writeLog("MAP1"); + + + QVariantMap map1 = result["attendees"].toMap(); + //QVariantMap map2 = map1["attendees"].toMap(); + writeLog("MAP2"); + //int page = map2["page"].toInt(&ok); + QList list1 = map1["user"].toList(); + writeLog("list count"+QString::number(list1.count(),10)); + + QListIterator i(list1); + writeLog("iterate list"); //While loop not work if there is only one attendee + while(i.hasNext()) + { + writeLog("inside loop"); + SmfContact contact; + QVariantMap map2 = i.next().toMap(); + writeLog("name= "+map2["name"].toString()); + writeLog("realname = "+map2["realname"].toString()); + + //Contact Name + QContactName contactname; + QString username = map2["name"].toString(); + writeLog("name = "+username); + contactname.setFirstName(username); + contactname.setLastName(username); + QVariant nameVar = QVariant::fromValue(contactname); + contact.setValue("Name",nameVar); + contactList.append(contact); + } + aResult->setValue(contactList); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + + } + else + { + writeLog("Service unsupported!!!"); + aRetType = SmfRequestError; + error = SmfPluginErrServiceNotSupported; + } + }//end if of if(SmfTransportOpNoError == aTransportResult) + + else if(SmfTransportOpOperationCanceledError == aTransportResult) + { + writeLog("Operation Cancelled !!!"); + error = SmfPluginErrCancelComplete; + aRetType = SmfRequestComplete; + } + + else + { + writeLog("Transport Error !!!"); + error = SmfPluginErrNetworkError; + aRetType = SmfRequestError; + } + + return error; + } + + +/** + * Destructor + */ +MusicProviderBase::~MusicProviderBase( ) + { + } + +/** + * Method to get the Localisable name of the service. + * @return The Localisable name of the service. + */ +QString MusicProviderBase::serviceName( ) const + { + return m_serviceName; + } + +/** + * Method to get the Logo of the service + * @return The Logo of the service + */ +QImage MusicProviderBase::serviceIcon( ) const + { + return m_serviceIcon; + } + +/** + * Method to get the Readable service description + * @return The Readable service description + */ +QString MusicProviderBase::description( ) const + { + return m_description; + } + +/** + * Method to get the Website of the service + * @return The Website of the service + */ +QUrl MusicProviderBase::serviceUrl( ) const + { + return m_serviceUrl; + } + +/** + * Method to get the URL of the Application providing this service + * @return The URL of the Application providing this service + */ +QUrl MusicProviderBase::applicationUrl( ) const + { + return m_applicationUrl; + } + +/** + * Method to get the Icon of the application + * @return The Icon of the application + */ +QImage MusicProviderBase::applicationIcon( ) const + { + return m_applicationIcon; + } +/** +* Method to get the list of interfaces that this provider support +* @return List of supported Interafces +*/ +QList MusicProviderBase::supportedInterfaces( ) const + { + return m_serviceType; + } + +/** +* Method to get the list of languages supported by this service provider +* @return a QStringList of languages supported by this service +* provider in 2 letter ISO 639-1 format. +*/ +QStringList MusicProviderBase::supportedLanguages( ) const + { + return m_supportedLanguages; + } + +/** + * Method to get the Plugin specific ID + * @return The Plugin specific ID + */ +QString MusicProviderBase::pluginId( ) const + { + return m_pluginId; + } + +/** + * Method to get the ID of the authentication application + * for this service + * @param aProgram The authentication application name + * @param aArguments List of arguments required for authentication app + * @param aMode Strting mode for authentication application + * @return The ID of the authentication application + */ +QString MusicProviderBase::authenticationApp( QString &aProgram, + QStringList & aArguments, + QIODevice::OpenModeFlag aMode ) const + { + return m_authAppId; + } + +/** + * Method to get the unique registration ID provided by the + * Smf for authorised plugins + * @return The unique registration ID/token provided by the Smf for + * authorised plugins + */ +QString MusicProviderBase::smfRegistrationId( ) const + { + return m_smfRegToken; + } + +void MusicProviderBase::initialize() + { + + m_serviceName = "Last.fm"; + m_description = "Description"; + m_serviceUrl = QUrl(QString("http://ws.audioscrobbler.com")); + // m_serviceType << m_serviceName << m_description;// << (QString)(m_serviceUrl); + m_supportedLanguages << "English" ; + m_pluginId = "lastfmmusiceventplugin.qtplugin"; + m_authAppId = "0xE1D8C7D8"; + QSettings iSettings; + m_smfRegToken = iSettings.value("CMLastFmRegToken").toString(); + m_validity = iSettings.value("LastFmExpiryTime").toDateTime(); + //m_smfRegToken = "hsdfusdghf"; //yet to be recvd + + } + + +/* + * Export Macro + * plugin name : musiceventplugin + * plugin class : MusicEventPlugin + */ +Q_EXPORT_PLUGIN2( musiceventplugin, MusicEventPlugin ) diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusiceventplugin/lastfmmusiceventplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusiceventplugin/lastfmmusiceventplugin.h Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,292 @@ +/* + * lastfmmusiceventplugin.h + * + * Created on: Jun 21, 2010 + * Author: ankitg + */ + +#ifndef LASTFMMUSICEVENTPLUGIN_H_ +#define LASTFMMUSICEVENTPLUGIN_H_ + +// Include files +#include "smfeventsfetcherplugin.h" +#include "smfpluginutil.h" + +#include + +// Forward declarations +class MusicProviderBase; +class QVariant; +class QNetworkReply; + +// Class declaration +class MusicEventPlugin : public QObject, public SmfEventsFetcherPlugin +{ + Q_OBJECT + Q_INTERFACES( SmfEventsFetcherPlugin SmfPluginBase ) + +public: + virtual ~MusicEventPlugin(); + +public: // From SmfMusicEventsPlugin + + /** + * Method to get the events based on location + * @param aRequest [out] The request data to be sent to network + * @param aLocation Location of the event + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + /*SmfPluginError events( SmfPluginRequestData &aRequest, + const QGeoPositionInfo &aLocation, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + */ + + /** + * Method to get the venues based on location + * @param aRequest [out] The request data to be sent to network + * @param aLocation Location of the venue + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + void fetchKeys( QString &aApiKey, + QString &aApiSecret, + QString &aSessionKey, + QString &aSessionSecret ); + SmfPluginError venues( SmfPluginRequestData &aRequest, + const SmfLocation &aLocation, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to get the events based on venues + * @param aRequest [out] The request data to be sent to network + * @param aVenue Venue of the event + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError events( SmfPluginRequestData &aRequest, + const SmfLocation &aVenue, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to post events + * @param aRequest [out] The request data to be sent to network + * @param aEventList The list of events to be posted + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError postEvents( SmfPluginRequestData &aRequest, + const QList &aEventList ); + + + /*** Method to get the list of attendees for a musical event + * @param aRequest [out] The request data to be sent to network + * @param aEvent The event for which attendees should be fetched + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError attendees( SmfPluginRequestData &aRequest, + const SmfEvent &aEvent, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Customised method for SmfMusicEventsPlugin interface + * @param aRequest [out] The request data to be sent to network + * @param aOperation The operation type (should be known between + * the client interface and the plugin) + * @param aData The data required to form the request (The type + * of data should be known between client and the plugin) + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError customRequest( SmfPluginRequestData &aRequest, + const int &aOperation, QByteArray *aData ); + + + + +public: // From SmfPluginBase + /** + * The first method to be called in the plugin that implements this interface. + * If this method is not called, plugin may not behave as expected. + * Plugins are expected to save the aUtil handle and use and when required. + * @param aUtil The instance of SmfPluginUtil + */ + void initialize(/*SmfPluginUtil *aUtil*/); + + /** + * Method to get the provider information + * @return Instance of SmfProviderBase + */ + SmfProviderBase* getProviderInfo( ); + + /** + * Method to get the result for a network request. + * @param aTransportResult The result of transport operation + * @param aReply The QNetworkReply instance for the request + * @param aResult [out] An output parameter to the plugin manager.If the + * return value is SmfSendRequestAgain, QVariant will be of type + * SmfPluginRequestData. + * For SmfGalleryPlugin: If last operation was pictures(), aResult will + * be of type QList. If last operation was description(), + * aResult will be of type QString. If last operation was upload() or + * postComment(), aResult will be of type bool. + * @param aRetType [out] SmfPluginRetType + * @param aPageResult [out] The SmfResultPage structure variable + */ + /* SmfPluginError responseAvailable( + const SmfTransportResult &aTransportResult, + QNetworkReply *aReply, + QVariant* aResult, + SmfPluginRetType &aRetType, + SmfResultPage &aPageResult );*/ + SmfPluginError responseAvailable( + const SmfRequestTypeID aOperation, + const SmfTransportResult &aTransportResult, + QByteArray *aResponse, + QVariant* aResult, + SmfPluginRetType &aRetType, + SmfResultPage &aPageResult ); + + void writeLog(QString log) const; + + +private: + + QString generateSignature(const QString aBaseString); + + +private slots: + + + +private: + /** + * Method called by plugins to generate a request data + * @param aRequest [out] The request data to be sent to network + * @param aOperation The type of http operation + * @param aSignatureMethod The signature method to be used + * @param aParams A map of parameters to its values + * @param aMode The mode of creation of the request + * @param aPostData The data to be posted (for HTTP POST + * only, else it will be NULL) + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError createRequest( SmfPluginRequestData &aRequest, + const QNetworkAccessManager::Operation aOperation, + const SmfSignatureMethod aSignatureMethod, + QMultiMap &aParams, + const SmfParsingMode aMode, + QBuffer *aPostData ); + +private: + MusicProviderBase *m_provider; + SmfPluginUtil *m_util; +}; + +// Class declaration +class MusicProviderBase : public QObject, public SmfProviderBase + { + Q_OBJECT + Q_INTERFACES( SmfProviderBase ) + +public: + virtual ~MusicProviderBase( ); + + /** + * Method to get the Localisable name of the service. + * @return The Localisable name of the service. + */ + QString serviceName( ) const; + + /** + * Method to get the Logo of the service + * @return The Logo of the service + */ + QImage serviceIcon( ) const; + + /** + * Method to get the Readable service description + * @return The Readable service description + */ + QString description( ) const; + + /** + * Method to get the Website of the service + * @return The Website of the service + */ + QUrl serviceUrl( ) const; + + /** + * Method to get the URL of the Application providing this service + * @return The URL of the Application providing this service + */ + QUrl applicationUrl( ) const; + + /** + * Method to get the Icon of the application + * @return The Icon of the application + */ + QImage applicationIcon( ) const; + + /** + * Method to get the list of interfaces that this provider support + * @return List of supported Interafces + */ + QList supportedInterfaces( ) const; + + /** + * Method to get the list of languages supported by this service provider + * @return a QStringList of languages supported by this service + * provider in 2 letter ISO 639-1 format. + */ + QStringList supportedLanguages( ) const; + + /** + * Method to get the Plugin specific ID + * @return The Plugin specific ID + */ + QString pluginId( ) const; + + /** + * Method to get the ID of the authentication application + * for this service + * @param aProgram The authentication application name + * @param aArguments List of arguments required for authentication app + * @param aMode Strting mode for authentication application + * @return The ID of the authentication application + */ + QString authenticationApp( QString &aProgram, QStringList & aArguments, + QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const; + + /** + * Method to get the unique registration ID provided by the + * Smf for authorised plugins + * @return The unique registration ID/token provided by the Smf for + * authorised plugins + */ + QString smfRegistrationId( ) const; + +private: + friend class MusicEventPlugin; + void initialize(); + QString m_serviceName; + QImage m_serviceIcon; + QString m_description; + QUrl m_serviceUrl; + QUrl m_applicationUrl; + QImage m_applicationIcon; + QStringList m_serviceType; + QStringList m_supportedLanguages; + QString m_pluginId; + QString m_authAppId; + QString m_smfRegToken; + QDateTime m_validity; + }; +#endif /* LASTFMMUSICEVENTPLUGIN_H_ */ diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusiceventplugin/lastfmmusiceventplugin.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusiceventplugin/lastfmmusiceventplugin.pro Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,37 @@ +TEMPLATE = lib +CONFIG += plugin \ + mobility +MOBILITY += location \ + contacts +QT += core \ + network +HEADERS = lastfmmusiceventplugin.h +SOURCES = lastfmmusiceventplugin.cpp +TARGET = $$qtLibraryTarget(lastfmmusiceventplugin) +symbian: { + # Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files + load(data_caging_paths) + + # EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data + TARGET.EPOCALLOWDLLDATA = 1 + + # Defines plugin files into Symbian .pkg package + pluginDep.sources = lastfmmusiceventplugin.dll + pluginDep.path = $$QT_PLUGINS_BASE_DIR/smf/plugin/events.fetcher + DEPLOYMENT += pluginDep + TARGET.CAPABILITY = ReadUserData \ + WriteUserData \ + LocalServices \ + NetworkServices \ + UserEnvironment \ + ReadDeviceData \ + WriteDeviceData + LIBS += -lsmfcommon.dll + LIBS += -lqjson.dll + +} +target.path += $$[QT_INSTALL_PLUGINS]/smf/plugin/events.fetcher +INSTALLS += target + + + diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusiceventplugin/plugin_commonU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusiceventplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,16 @@ +; ============================================================================== +; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50 +; This file is generated by qmake and should not be modified by the +; user. +; Name : plugin_commonU.def +; Part of : lastfmmusiceventplugin +; Description : Fixes common plugin symbols to known ordinals +; Version : +; +; ============================================================================== + + +EXPORTS + qt_plugin_query_verification_data @ 1 NONAME + qt_plugin_instance @ 2 NONAME + diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusiceventplugin/qmakepluginstubs/lastfmmusiceventplugin.qtplugin --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusiceventplugin/qmakepluginstubs/lastfmmusiceventplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,1 @@ +This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50 diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusicsearchplugin/lastfmmusicsearchplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusicsearchplugin/lastfmmusicsearchplugin.cpp Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,1428 @@ +/** + * Copyright (c) 2010 Sasken Communication Technologies Ltd. + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html" + * + * Initial Contributors: + * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution + * + * Contributors: + * Nalina Hariharan + * + * Description: + * The Plugin that does music search related functionalities from last.fm site + * + */ + +// Include files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lastfmmusicsearchplugin.h" + +static int gPageNum = 0; +static int gItemsPerPage = 0; +static quint8 forTracksOfAlbum = 0; +QString albumId; + +int gOperationId; + + +/** + * Destructor + */ +LastFmMusicSearchPlugin::~LastFmMusicSearchPlugin( ) + { + if(m_provider) + delete m_provider; + } + +/** + * Method to interpret the key sets obtained from credential manager + * @param aApiKey [out] The api key + * @param aApiSecret [out] The api secret + * @param aSessionKey [out] The session key + * @param aToken [out] The session token + */ +void LastFmMusicSearchPlugin::fetchKeys( QString &aApiKey, + QString &aApiSecret, + QString &aToken ) + { + qDebug()<<"Reg Token = "<m_smfRegToken; + qDebug()<<"Expiry Date as int = "<m_validity.toTime_t(); + + SmfAuthParams keys; + SmfPluginUtil util; + util.getAuthKeys(keys, m_provider->m_smfRegToken, + m_provider->m_validity, m_provider->m_pluginId); + + QByteArray keyName; + keyName.append("ApiKey"); + aApiKey.append(keys.value(keyName)); + + keyName.clear(); + keyName.append("ApiSecret"); + aApiSecret.append(keys.value(keyName)); + + keyName.clear(); + keyName.append("Token"); + aToken.append(keys.value(keyName)); + + qDebug()<<"Api Key = "<>limit; + read>>pageNum; + read>>album; + + gItemsPerPage = limit; + gPageNum = pageNum; + + // Create the API signature string + QString baseString; + baseString.append("album"+album.name()); + baseString.append("api_key"+apiKey); + baseString.append("limit"+QString::number(limit)); + baseString.append("methodalbum.search"); + baseString.append("page"+QString::number(pageNum)); + baseString.append(apiSecret); + + // Create the url + QUrl url("http://ws.audioscrobbler.com/2.0/?"); + url.addQueryItem("album", album.name()); + url.addQueryItem("api_key", apiKey); + url.addQueryItem("limit", QString::number(limit)); + url.addQueryItem("page", QString::number(pageNum)); + url.addQueryItem("format", "json"); + url.addQueryItem("method", "album.search"); + url.addQueryItem("api_sig", generateSignature(baseString)); + + // Create the request, set the url + aRequest.iNetworkRequest.setUrl(url); + aRequest.iRequestType = SmfMusicSearchCustomRequest; + aRequest.iPostData = NULL; + aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; + error = SmfPluginErrNone; + + qDebug()<<"Url string is : "<initialize(); + } + +/** + * Method to get the provider information + * @return Instance of SmfProviderBase + */ +SmfProviderBase* LastFmMusicSearchPlugin::getProviderInfo( ) + { + return m_provider; + } + +/** + * Method to get the result for a network request. + * @param aOperation The type of operation to be requested + * @param aTransportResult The result of transport operation + * @param aResponse The QByteArray instance containing the network response. + * The plugins should delete this instance once they have read the + * data from it. + * @param aResult [out] An output parameter to the plugin manager.If the + * return value is SmfSendRequestAgain, QVariant will be of type + * SmfPluginRequestData. + * For SmfMusicSearchPlugin: If last operation was recommendations(), + * tracksSimilar() or tracksOfAlbum() or tracksOfArtist() or trackInfo(), + * aResult will be of type QList. + * If last operation was stores(), aResult will be of type QList. + * @param aRetType [out] SmfPluginRetType + * @param aPageResult [out] The SmfResultPage structure variable + */ +SmfPluginError LastFmMusicSearchPlugin::responseAvailable( + const SmfRequestTypeID aOperation, + const SmfTransportResult &aTransportResult, + QByteArray *aResponse, + QVariant* aResult, + SmfPluginRetType &aRetType, + SmfResultPage &aPageResult ) + { + Q_UNUSED(aPageResult) + qDebug()<<"Inside LastFmMusicSearchPlugin::responseAvailable()"; + + SmfPluginError error = SmfPluginErrNetworkError; + + if( !aResponse || (0 == aResponse->size()) ) + { + qDebug()<<"Response is NULL or empty"; + aRetType = SmfRequestError; + return error; + } + + QByteArray response(*aResponse); + delete aResponse; + + QFile respFile("c://data//SmfMusicSearchPluginResponse.txt"); + if(!respFile.open(QIODevice::WriteOnly)) + qDebug()<<"File to write the response could not be opened"; + else + { + respFile.write(response); + respFile.close(); + qDebug()<<"Writing FB response to a file named 'SmfMusicSearchPluginResponse.txt'"; + } + qDebug()<<"FB response size = "< list; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + QVariantMap map1; + if(SmfMusicGetTracksSimilar == aOperation) + map1 = result["similartracks"].toMap(); + else //if(SmfMusicGetTracksOfArtist == aOperation) // tracks of artists + map1 = result["toptracks"].toMap(); + QList list1 = map1["track"].toList(); + QListIterator iter(list1); + while(iter.hasNext()) + { + SmfTrackInfo track; + + QVariantMap map2 = iter.next().toMap(); + qDebug()<<"track title = "< list2 = map3["image"].toList(); + QListIterator iter2(list2); + while(iter2.hasNext()) + { + QVariantMap map4 = iter.next().toMap(); + + // Set the artist's image url + QUrl url(map4["#text"].toString()); + //artists.setImageUrlurl); + break; + } + + track.setArtists(artists); + + list.append(track); + if(gItemsPerPage == list.count()) + break; + } + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + qDebug()<<"list count = "<setValue(list); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + } + else if (SmfMusicGetTracksOfAlbum == aOperation) + { + qDebug()<<"Response for music search tracks of album"; + + if(0 == forTracksOfAlbum) // for fetching album ID + { + qDebug()<<"FOR GETTING ALBUMID"; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + qDebug()<<"Json parsing complete"; + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + QVariantMap map1 = result["album"].toMap(); + albumId.clear(); + albumId.append(map1["id"].toString()); + forTracksOfAlbum = 1; + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + qDebug()<<"album id = "< list; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + QVariantMap map1 = result["playlist"].toMap(); + QVariantMap map2 = map1["trackList"].toMap(); + QList list1 = map2["track"].toList(); + QListIterator iter(list1); + while(iter.hasNext()) + { + SmfTrackInfo track; + + QVariantMap map3 = iter.next().toMap(); + qDebug()<<"track title = "< list; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + qDebug()<<"Json parsing complete"; + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + QVariantMap map1 = result["affiliations"].toMap(); + QVariantMap map2 = map1["physicals"].toMap(); + QList list1 = map2["affiliation"].toList(); + QListIterator iter(list1); + while(iter.hasNext()) + { + SmfProvider provider; + + QVariantMap map3 = iter.next().toMap(); + qDebug()<<"provider name = "< list; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + qDebug()<<"Json parsing complete"; + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + QVariantMap map1 = result["tracks"].toMap(); + QList list1 = map1["track"].toList(); + QListIterator iter(list1); + while(iter.hasNext()) + { + SmfTrackInfo track; + + QVariantMap map3 = iter.next().toMap(); + + // Set the track's Id - last.fm's identifier + track.setId(map3["mbid"].toString()); + + // Set the track title + track.setTitle(map3["name"].toString()); + + // Set the tracks artist details + QVariantMap map4 = map3["artist"].toMap(); + SmfArtists artists; + QStringList namesList; + namesList.append(map4["name"].toString()); + artists.setNames(namesList); + + QUrl url(map4["url"].toString()); + artists.setUrl(url); + + artists.setId(map4["mbid"].toString()); + + QList list2 = map4["image"].toList(); + QListIterator iter2(list2); + while(iter2.hasNext()) + { + QVariantMap map5 = iter2.next().toMap(); + QUrl imageUrl(map5["#text"].toString()); + //artists.setImageUrl(imageUrl); + break; + } + + track.setArtists(artists); + + list.append(track); + + if(gItemsPerPage == list.count()) + break; + } + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + qDebug()<<"list count = "<setValue(list); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + } + + else if (SmfMusicSearchCustomRequest == aOperation) + { + qDebug()<<"Response for music search custom request = album.search"; + + QList list; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + qDebug()<<"Json parsing complete"; + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + QVariantMap map1 = result["results"].toMap(); + QVariantMap map2 = map1["albummatches"].toMap(); + QList list1 = map2["album"].toList(); + QListIterator iter(list1); + while(iter.hasNext()) + { + SmfAlbum album; + + QVariantMap map3 = iter.next().toMap(); + + album.setName(map3["name"].toString()); + + SmfArtists artists; + QStringList names; + names.append(map3["artist"].toString()); + artists.setNames(names); + + QList list2 = map3["image"].toList(); + QListIterator iter2(list2); + while(iter2.hasNext()) + { + QVariantMap map5 = iter2.next().toMap(); + QUrl imageUrl(map5["#text"].toString()); + //artists.setImageUrl(imageUrl); + break; + } + + album.setArtists(artists); + + album.setId(map3["id"].toString()); + + //QUrl url(map3["url"].toString()) + //album.setUrl(url); + + list.append(album); + + if(gItemsPerPage == list.count()) + break; + } + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + QByteArray customResponseData; + QByteArray entireData; + QDataStream writeResponse(&customResponseData, QIODevice::WriteOnly); + qDebug()<<"list count = "< LastFmMusicSearchProviderBase::supportedInterfaces( ) const + { + return m_supportedInterfaces; + } + +/** +* Method to get the list of languages supported by this service provider +* @return a QStringList of languages supported by this service +* provider in 2 letter ISO 639-1 format. +*/ +QStringList LastFmMusicSearchProviderBase::supportedLanguages( ) const + { + return m_supportedLangs; + } + +/** + * Method to get the Plugin specific ID + * @return The Plugin specific ID + */ +QString LastFmMusicSearchProviderBase::pluginId( ) const + { + return m_pluginId; + } + + +/** + * Method to get the ID of the authentication application + * for this service + * @param aProgram The authentication application name + * @param aArguments List of arguments required for authentication app + * @param aMode Strting mode for authentication application + * @return The ID of the authentication application + */ +QString LastFmMusicSearchProviderBase::authenticationApp( QString &aProgram, + QStringList & aArguments, + QIODevice::OpenModeFlag aMode ) const + { + Q_UNUSED(aProgram) + Q_UNUSED(aArguments) + Q_UNUSED(aMode) + return m_authAppId; + } + + +/** + * Method to get the unique registration ID provided by the + * Smf for authorised plugins + * @return The unique registration ID/token provided by the Smf for + * authorised plugins + */ +QString LastFmMusicSearchProviderBase::smfRegistrationId( ) const + { + return m_smfRegToken; + } + + +/** + * Method that initializes this class. This method should be called + * from the initialize() method of the FBContactFetcherPlugin class + */ +void LastFmMusicSearchProviderBase::initialize() + { + m_serviceName = "last.fm"; + m_description = "Last.fm music search plugin description"; + m_serviceUrl = QUrl(QString("http://www.last.fm")); + m_pluginId = "lastfmmusicsearchplugin.qtplugin"; + m_authAppId = "0x12345678"; + m_supportedInterfaces.append("org.symbian.smf.plugin.music.search/v0.2"); + QSettings iSettings; + m_smfRegToken = iSettings.value("LastFmRegToken").toString(); + m_validity = iSettings.value("LastFmExpiryTime").toDateTime(); + } + + +/* + * Export Macro + * plugin name : lastfmmusicsearchplugin + * plugin class : LastFmMusicSearchPlugin + */ +Q_EXPORT_PLUGIN2( lastfmmusicsearchplugin, LastFmMusicSearchPlugin ) diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusicsearchplugin/lastfmmusicsearchplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusicsearchplugin/lastfmmusicsearchplugin.h Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,335 @@ +/** + * Copyright (c) 2010 Sasken Communication Technologies Ltd. + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html" + * + * Initial Contributors: + * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution + * + * Contributors: + * Nalina Hariharan + * + * Description: + * The Plugin that does music search related functionalities from last.fm site + * + */ + +#ifndef _LASTFMMUSICSEARCHPLUGIN_H +#define _LASTFMMUSICSEARCHPLUGIN_H + +// Include files +#include + +// Class declaration +class LastFmMusicSearchProviderBase; +class QVariant; + +/** + * The Plugin does music serach related functionalities from last.fm site + */ +class LastFmMusicSearchPlugin : public QObject, public SmfMusicSearchPlugin + { + Q_OBJECT + Q_INTERFACES( SmfMusicSearchPlugin SmfPluginBase ) + +public: + /** + * Destructor + */ + virtual ~LastFmMusicSearchPlugin ( ); + +public: // From SmfMusicSearchPlugin interface + /** + * Method to get recommended tracks + * @param aRequest [out] The request data to be sent to network + * @param aTrack The track for which similar recommendations + * need to be fetched. + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError recommendations( SmfPluginRequestData &aRequest, + const SmfTrackInfo &aTrack, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to search for tracks similar to a given track + * @param aRequest [out] The request data to be sent to network + * @param aTrack The track for which similar tracks + * need to be fetched. + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError tracksSimilar( SmfPluginRequestData &aRequest, + const SmfTrackInfo &aTrack, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to search for tracks of a given album + * @param aRequest [out] The request data to be sent to network + * @param aAlbum The album whose tracks need to be fetched. + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError tracksOfAlbum( SmfPluginRequestData &aRequest, + const SmfAlbum &aAlbum, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to search for tracks of the given artist(s) + * @param aRequest [out] The request data to be sent to network + * @param aArtist The artist(s) whose tracks need to be fetched. + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError tracksOfArtist( SmfPluginRequestData &aRequest, + const SmfArtists &aArtist, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to get tracks having a similar finger print + * @param aRequest [out] The request data to be sent to network + * @param aSignature The finger print to be searched for need to be + * fetched. + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError trackInfo( SmfPluginRequestData &aRequest, + const SmfMusicFingerPrint &aSignature, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to search information about where to buy this song from + * @param aRequest [out] The request data to be sent to network + * @param aTrack The track for which stores need to be searched + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError stores( SmfPluginRequestData &aRequest, + const SmfTrackInfo &aTrack, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Customised method for SmfMusicSearchPlugin interface + * @param aRequest [out] The request data to be sent to network + * @param aOperation The operation type (should be known between + * the client interface and the plugin) + * @param aData The data required to form the request (The type + * of data should be known between client and the plugin) + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError customRequest( SmfPluginRequestData &aRequest, + const int &aOperation, QByteArray *aData ); + +public: // From SmfPluginBase interface + /** + * The first method to be called in the plugin that implements this interface. + * If this method is not called, plugin may not behave as expected. + */ + void initialize( ); + + /** + * Method to get the provider information + * @return Instance of SmfProviderBase + */ + SmfProviderBase* getProviderInfo( ); + + /** + * Method to get the result for a network request. + * @param aOperation The type of operation to be requested + * @param aTransportResult The result of transport operation + * @param aResponse The QByteArray instance containing the network response. + * The plugins should delete this instance once they have read the + * data from it. + * @param aResult [out] An output parameter to the plugin manager.If the + * return value is SmfSendRequestAgain, QVariant will be of type + * SmfPluginRequestData. + * For SmfMusicSearchPlugin: If last operation was recommendations(), + * tracksSimilar() or tracksOfAlbum() or tracksOfArtist() or trackInfo(), + * aResult will be of type QList. + * If last operation was stores(), aResult will be of type QList. + * @param aRetType [out] SmfPluginRetType + * @param aPageResult [out] The SmfResultPage structure variable + */ + SmfPluginError responseAvailable( + const SmfRequestTypeID aOperation, + const SmfTransportResult &aTransportResult, + QByteArray *aResponse, + QVariant* aResult, + SmfPluginRetType &aRetType, + SmfResultPage &aPageResult ); + +private: + /** + * Method called by plugins to generate a signature string from a base string + * @param aBaseString The base string + * @return The md5 hash of the base string + */ + QString generateSignature(const QString aBaseString); + + /** + * Method to interpret the key sets obtained from credential manager + * @param aApiKey [out] The api key + * @param aApiSecret [out] The api secret + * @param aSessionKey [out] The session key + * @param aToken [out] The session token + */ + void fetchKeys( QString &aApiKey, + QString &aApiSecret, + QString &aToken ); + + /** + * Method to get the last.fm specific ID of the given album + * @param aRequest [out] The request data to be sent to network + * @param aAlbum The album whose tracks need to be fetched. + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError getAlbumId( SmfPluginRequestData &aRequest, + const SmfAlbum &aAlbum ); + /** + * Method to search for tracks of a given album using its ID in last.fm + * @param aRequest [out] The request data to be sent to network + * @param aAlbum The album whose tracks need to be fetched. + * @return SmfPluginError Plugin error if any, else SmfPluginErrNone + */ + SmfPluginError getTracksOfAlbum( SmfPluginRequestData &aRequest, + const SmfAlbum &aAlbum ); + + /** + * Method to get the current country name as per ISO 3166-1 standard. + * @return Current country name + */ + QString currentCountryName() const; + +private: // Data + LastFmMusicSearchProviderBase *m_provider; + }; + + + +/** + * The Plugin class that implements SmfProviderBase for this last.fm plugin + */ +class LastFmMusicSearchProviderBase : public QObject, public SmfProviderBase + { + Q_OBJECT + Q_INTERFACES( SmfProviderBase ) + +public: + /** + * Destructor + */ + virtual ~LastFmMusicSearchProviderBase( ); + + /** + * Method to get the Localisable name of the service. + * @return The Localisable name of the service. + */ + QString serviceName( ) const; + + /** + * Method to get the Logo of the service + * @return The Logo of the service + */ + QImage serviceIcon( ) const; + + /** + * Method to get the Readable service description + * @return The Readable service description + */ + QString description( ) const; + + /** + * Method to get the Website of the service + * @return The Website of the service + */ + QUrl serviceUrl( ) const; + + /** + * Method to get the URL of the Application providing this service + * @return The URL of the Application providing this service + */ + QUrl applicationUrl( ) const; + + /** + * Method to get the Icon of the application + * @return The Icon of the application + */ + QImage applicationIcon( ) const; + + /** + * Method to get the list of interfaces that this provider support + * @return List of supported Interafces + */ + QList supportedInterfaces( ) const; + + /** + * Method to get the list of languages supported by this service provider + * @return a QStringList of languages supported by this service + * provider in 2 letter ISO 639-1 format. + */ + QStringList supportedLanguages( ) const; + + /** + * Method to get the Plugin specific ID + * @return The Plugin specific ID + */ + QString pluginId( ) const; + + /** + * Method to get the ID of the authentication application + * for this service + * @param aProgram The authentication application name + * @param aArguments List of arguments required for authentication app + * @param aMode Strting mode for authentication application + * @return The ID of the authentication application + */ + QString authenticationApp( QString &aProgram, QStringList & aArguments, + QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const; + + /** + * Method to get the unique registration ID provided by the + * Smf for authorised plugins + * @return The unique registration ID/token provided by the Smf for + * authorised plugins + */ + QString smfRegistrationId( ) const; + +private: + /** + * Method that initializes this class. This method should be called + * from the initialize() method of the FBContactFetcherPlugin class + */ + void initialize(); + +private: + friend class LastFmMusicSearchPlugin; + QString m_serviceName; + QImage m_serviceIcon; + QString m_description; + QUrl m_serviceUrl; + QUrl m_applicationUrl; + QImage m_applicationIcon; + QString m_pluginId; + QString m_authAppId; + QString m_smfRegToken; + QList m_supportedInterfaces; + QStringList m_supportedLangs; + QDateTime m_validity; + }; + +#endif //_LASTFMMUSICSEARCHPLUGIN_H diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusicsearchplugin/lastfmmusicsearchplugin.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusicsearchplugin/lastfmmusicsearchplugin.pro Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,43 @@ +TEMPLATE = lib + +CONFIG += plugin \ + mobility + +MOBILITY += contacts \ + location + +QT += core \ + network + +HEADERS = lastfmmusicsearchplugin.h + +SOURCES = lastfmmusicsearchplugin.cpp + +TARGET = $$qtLibraryTarget(lastfmmusicsearchplugin) + +symbian: { + # Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files + load(data_caging_paths) + + # EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data + TARGET.EPOCALLOWDLLDATA = 1 + + # Defines plugin files into Symbian .pkg package + pluginDep.sources = lastfmmusicsearchplugin.dll + pluginDep.path = $$QT_PLUGINS_BASE_DIR/smf/plugin/music.search + DEPLOYMENT += pluginDep + + TARGET.CAPABILITY = NetworkServices \ + ReadUserData \ + WriteUserData \ + LocalServices \ + UserEnvironment \ + ReadDeviceData \ + WriteDeviceData + + LIBS += -lsmfcommon +} + +target.path += $$[QT_INSTALL_PLUGINS]/smf/plugin/music.search + +INSTALLS += target \ No newline at end of file diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusicsearchplugin/plugin_commonU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusicsearchplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,16 @@ +; ============================================================================== +; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50 +; This file is generated by qmake and should not be modified by the +; user. +; Name : plugin_commonU.def +; Part of : lastfmmusicsearchplugin +; Description : Fixes common plugin symbols to known ordinals +; Version : +; +; ============================================================================== + + +EXPORTS + qt_plugin_query_verification_data @ 1 NONAME + qt_plugin_instance @ 2 NONAME + diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusicsearchplugin/qmakepluginstubs/lastfmmusicsearchplugin.qtplugin --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusicsearchplugin/qmakepluginstubs/lastfmmusicsearchplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,1 @@ +This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50 diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusicserviceplugin/lastfmmusicserviceplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusicserviceplugin/lastfmmusicserviceplugin.cpp Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,1604 @@ +/** + * Copyright (c) 2010 Sasken Communication Technologies Ltd. + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html" + * + * Initial Contributors: + * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution + * + * Contributors: + * Nalina Hariharan + * + * Description: + * The Plugin that does music services related functionalities from last.fm site + * + */ + +// Include files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lastfmmusicserviceplugin.h" + + +static int gPageNum = 0; +static int gItemsPerPage = 0; + +QString gUserId; +static int userMusicInfoChance = 0; +QList gRecentTracks; +QList gFavorites; +QList gUserEvents; + +/** + * Destructor + */ +LastFmMusicServicePlugin::~LastFmMusicServicePlugin( ) + { + if(m_provider) + delete m_provider; + } + +/** + * Method to interpret the key sets obtained from credential manager + * @param aApiKey [out] The api key + * @param aApiSecret [out] The api secret + * @param aSessionKey [out] The session key + * @param aToken [out] The session token + */ +void LastFmMusicServicePlugin::fetchKeys( QString &aApiKey, + QString &aApiSecret, + QString &aToken, + QString &aName ) + { + qDebug()<<"Reg Token = "<m_smfRegToken; + qDebug()<<"Expiry Date as int = "<m_validity.toTime_t(); + + SmfAuthParams keys; + SmfPluginUtil util; + util.getAuthKeys(keys, m_provider->m_smfRegToken, + m_provider->m_validity, m_provider->m_pluginId); + + QByteArray keyName; + keyName.append("ApiKey"); + aApiKey.append(keys.value(keyName)); + + keyName.clear(); + keyName.append("ApiSecret"); + aApiSecret.append(keys.value(keyName)); + + keyName.clear(); + keyName.append("Token"); + aToken.append(keys.value(keyName)); + + keyName.clear(); + keyName.append("Name"); + aName.append(keys.value(keyName)); + + qDebug()<<"Api Key = "<initialize(); + } + +/** + * Method to get the provider information + * @return Instance of SmfProviderBase + */ +SmfProviderBase* LastFmMusicServicePlugin::getProviderInfo( ) + { + return m_provider; + } + +/** + * Method to get the result for a network request. + * @param aOperation The type of operation to be requested + * @param aTransportResult The result of transport operation + * @param aResponse The QByteArray instance containing the network response. + * The plugins should delete this instance once they have read the + * data from it. + * @param aResult [out] An output parameter to the plugin manager.If the + * return value is SmfSendRequestAgain, QVariant will be of type + * SmfPluginRequestData. + * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult + * will be of type SmfMusicProfile. If last operation was searchArtist(), + * aResult will be of type QList. If last operation was searchAlbum(), + * aResult will be of type QList. If last operation was searchEvents(), + * aResult will be of type QList. If last operation was searchVenue(), + * aResult will be of type QList. If last operation was searchUser(), + * aResult will be of type QList. If last operation was + * postCurrentPlaying() or postRating() or postComments(), aResult will be of + * type bool. + * @param aRetType [out] SmfPluginRetType + * @param aPageResult [out] The SmfResultPage structure variable + */ +SmfPluginError LastFmMusicServicePlugin::responseAvailable( + const SmfRequestTypeID aOperation, + const SmfTransportResult &aTransportResult, + QByteArray *aResponse, + QVariant* aResult, + SmfPluginRetType &aRetType, + SmfResultPage &aPageResult ) + { + Q_UNUSED(aPageResult) + qDebug()<<"Inside LastFmMusicServicePlugin::responseAvailable()"; + + SmfPluginError error = SmfPluginErrNetworkError; + + if( !aResponse || (0 == aResponse->size()) ) + { + qDebug()<<"Response is NULL or empty"; + aRetType = SmfRequestError; + return error; + } + + QByteArray response(*aResponse); + delete aResponse; + + QFile respFile("c://data//SmfMusicServicePluginResponse.txt"); + if(!respFile.open(QIODevice::WriteOnly)) + qDebug()<<"File to write the response could not be opened"; + else + { + respFile.write(response); + respFile.close(); + qDebug()<<"Writing FB response to a file named 'SmfMusicServicePluginResponse.txt'"; + } + qDebug()<<"FB response size = "< list1 = map1["track"].toList(); + QListIterator iter1(list1); + while(iter1.hasNext()) + { + QVariantMap map2 = iter1.next().toMap(); + SmfTrackInfo track; + + SmfArtists artist; + QStringList names; + QVariantMap map3 = map2["artist"].toMap(); + names.append(map3["#text"].toString()); + artist.setNames(names); + + artist.setId(map3["mbid"].toString()); + + track.setArtists(artist); + + track.setTitle(map2["name"].toString()); + track.setId(map2["mbid"].toString()); + + SmfAlbum album; + QVariantMap map4 = map2["album"].toMap(); + album.setName(map4["#text"].toString()); + album.setId(map4["mbid"].toString()); + + track.setAlbum(album); + + gRecentTracks.append(track); + + if(gItemsPerPage == gRecentTracks.count()) + break; + } + } + else if(2 == userMusicInfoChance) + { + qDebug()<<"For getting favorites"; + + QVariantMap map1 = result["lovedtracks"].toMap(); + QList list1 = map1["track"].toList(); + QListIterator iter1(list1); + while(iter1.hasNext()) + { + QVariantMap map2 = iter1.next().toMap(); + SmfTrackInfo track; + + track.setTitle(map2["name"].toString()); + qDebug()<<"Track name : "< list2 = map3["image"].toList(); + QListIterator iter2(list2); + while(iter2.hasNext()) + { + QVariantMap map4 = iter2.next().toMap(); + + // Set the artist's image url + QUrl url(map4["#text"].toString()); + //artist.setImageUrlurl); + qDebug()<<"Track artists image url : "< list1 = map1["event"].toList(); + QListIterator iter1(list1); + while(iter1.hasNext()) + { + QVariantMap map2 = iter1.next().toMap(); + + SmfEvent event; + event.setId(map2["id"].toString()); + event.setTitle(map2["title"].toString()); + + // Set the events date and time + QDateTime dateTime;// = QDateTime::fromString("M1d1y9800:01:02","'M'M'd'd'y'yyhh:mm:ss"); + event.setEventDateTime(dateTime); + + // Set the events artists + SmfArtists artists; + QStringList names; + names.clear(); + QVariantMap map3 = map2["artists"].toMap(); + QList list1 = map3["artist"].toList(); + names.clear(); + QListIterator iter1(list1); + while(iter1.hasNext()) + names.append(iter1.next().toString()); + artists.setNames(names); + event.setArtists(artists); + + // Set the events venue information + QVariantMap map4 = map2["venue"].toMap(); + SmfLocation location; + location.setId(map4["id"].toString()); + location.setName(map4["name"].toString()); + QUrl url(map4["url"].toString()); + location.setUrl(url); + + + QVariantMap map5 = map4["location"].toMap(); + location.setCity(map5["city"].toString()); + location.setCountry(map5["country"].toString()); + location.setStreet(map5["street"].toString()); + location.setZipCode(map5["postalcode"].toString()); + + QVariantMap map6 = map5["geo:point"].toMap(); + double latitude = map6["geo:lat"].toDouble(); + double longitude = map6["geo:long"].toDouble(); + QGeoCoordinate coordinate(latitude, longitude); + QGeoPositionInfo geoInfo; + geoInfo.setCoordinate(coordinate); + location.setGeoPositionInfo(geoInfo); + + event.setVenue(location); + + // Set the events ticketUrl + QUrl ticketUrl(map2["tickets"].toString()); + event.setTicketUrl(ticketUrl); + + + gUserEvents.append(event); + + if(gItemsPerPage == gUserEvents.count()) + break; + } + } + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + if(0 == userMusicInfoChance) + { + qDebug()<<"current logged in userId = "< list; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + qDebug()<<"Json parsing complete"; + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + QVariantMap map1 = result["results"].toMap(); + QVariantMap map2 = map1["artistmatches"].toMap(); + QList list1 = map2["artist"].toList(); + QListIterator iter(list1); + while(iter.hasNext()) + { + SmfArtists artist; + QVariantMap map3 = iter.next().toMap(); + + // Name of the artist + QStringList names; + names.append(map3["name"].toString()); + artist.setNames(names); + + // last.fm ID of the artist + artist.setId(map3["mbid"].toString()); + + // last.fm url of the artist + QUrl url(map3["url"].toString()); + artist.setUrl(url); + + // last.fm image of the artist + QList list2 = map3["image"].toList(); + QListIterator iter2(list2); + while(iter2.hasNext()) + { + QVariantMap map5 = iter2.next().toMap(); + QUrl imageUrl(map5["#text"].toString()); + //artists.setImageUrl(imageUrl); + break; + } + + list.append(artist); + + if(gItemsPerPage == list.count()) + break; + } + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + qDebug()<<"list count = "<setValue(list); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + } + + // Albums search + else if ( SmfMusicSearchAlbum == aOperation ) + { + qDebug()<<"Response for searching albums"; + + QList list; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + qDebug()<<"Json parsing complete"; + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + QVariantMap map1 = result["results"].toMap(); + QVariantMap map2 = map1["albummatches"].toMap(); + QList list1 = map2["album"].toList(); + QListIterator iter(list1); + while(iter.hasNext()) + { + SmfAlbum album; + + QVariantMap map3 = iter.next().toMap(); + + album.setName(map3["name"].toString()); + + SmfArtists artists; + QStringList names; + names.append(map3["artist"].toString()); + artists.setNames(names); + + QList list2 = map3["image"].toList(); + QListIterator iter2(list2); + while(iter2.hasNext()) + { + QVariantMap map5 = iter2.next().toMap(); + QUrl imageUrl(map5["#text"].toString()); + //artists.setImageUrl(imageUrl); + break; + } + + album.setArtists(artists); + + album.setId(map3["id"].toString()); + + //QUrl url(map3["url"].toString()) + //album.setUrl(url); + + list.append(album); + + if(gItemsPerPage == list.count()) + break; + } + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + qDebug()<<"list count = "<setValue(list); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + + } + + // Events search + else if (SmfMusicSearchEvent == aOperation) + { + qDebug()<<"Response for searching events"; + + QList list; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + qDebug()<<"Json parsing complete"; + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + QVariantMap map1 = result["event"].toMap(); + SmfEvent event; + + // Set the events title + event.setTitle(map1["title"].toString()); + + // Set the events id + event.setId(map1["id"].toString()); + + // Set the events date and time + QDateTime dateTime;// = QDateTime::fromString("M1d1y9800:01:02","'M'M'd'd'y'yyhh:mm:ss"); + event.setEventDateTime(dateTime); + + // Set the events artists + SmfArtists artists; + QStringList names; + names.clear(); + QVariantMap map2 = map1["artists"].toMap(); + QList list1 = map2["artist"].toList(); + QListIterator iter(list1); + while(iter.hasNext()) + names.append(iter.next().toString()); + artists.setNames(names); + event.setArtists(artists); + + // Set the events venue information + QVariantMap map3 = map1["venue"].toMap(); + SmfLocation location; + location.setName(map3["name"].toString()); + QUrl url(map3["url"].toString()); + location.setUrl(url); + location.setId(map3["id"].toString()); + + QVariantMap map4 = map3["location"].toMap(); + location.setCity(map4["city"].toString()); + location.setCountry(map4["country"].toString()); + location.setStreet(map4["street"].toString()); + location.setZipCode(map4["postalcode"].toString()); + + QVariantMap map5 = map4["geo:point"].toMap(); + double latitude = map5["geo:lat"].toDouble(); + double longitude = map5["geo:long"].toDouble(); + QGeoCoordinate coordinate(latitude, longitude); + QGeoPositionInfo geoInfo; + geoInfo.setCoordinate(coordinate); + location.setGeoPositionInfo(geoInfo); + + event.setVenue(location); + + // Set the events ticketUrl + QUrl ticketUrl(map1["tickets"].toString()); + event.setTicketUrl(ticketUrl); + + // Set the events id + event.setId(map1["id"].toString()); + + list.append(event); + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + qDebug()<<"list count = "<setValue(list); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + } + + // Venues Search + else if(SmfMusicSearchVenue == aOperation) + { + qDebug()<<"Response for searching venues"; + + QList list; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + qDebug()<<"Json parsing complete"; + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + QVariantMap map1 = result["results"].toMap(); + QVariantMap map2 = map1["venuematches"].toMap(); + QList list1 = map2["venue"].toList(); + QListIterator iter(list1); + while(iter.hasNext()) + { + SmfLocation location; + QVariantMap map3 = iter.next().toMap(); + + location.setName(map3["name"].toString()); + QUrl url(map3["url"].toString()); + location.setUrl(url); + location.setId(map3["id"].toString()); + + QVariantMap map4 = map3["location"].toMap(); + location.setCity(map4["city"].toString()); + location.setCountry(map4["country"].toString()); + location.setStreet(map4["street"].toString()); + location.setZipCode(map4["postalcode"].toString()); + + QVariantMap map5 = map4["geo:point"].toMap(); + double latitude = map5["geo:lat"].toDouble(); + double longitude = map5["geo:long"].toDouble(); + QGeoCoordinate coordinate(latitude, longitude); + QGeoPositionInfo geoInfo; + geoInfo.setCoordinate(coordinate); + location.setGeoPositionInfo(geoInfo); + + list.append(location); + + if(gItemsPerPage == list.count()) + break; + } + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + qDebug()<<"list count = "<setValue(list); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + } + +#if 0 + // User search + else if(SmfMusicSearchUser == aOperation) + { + qDebug()<<"Response for searching users"; + + QList list; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + qDebug()<<"For getting user's neighbours"; + + QVariantMap map1 = result["neighbours"].toMap(); + QList list1 = map1["user"].toList(); + QListIterator iter(list1); + while(iter.hasNext()) + { + SmfMusicProfile profile; + QVariantMap map2 = iter.next().toMap(); + +/* QContactName name; + name.setFirstName(map2["name"].toString()); + QVariant nameVar = QVariant::fromValue(name); + contact.setValue("Name", nameVar); + + QContactUrl url; + url.setUrl(map2["url"].toString()); + QVariant urlVar = QVariant::fromValue(url); + contact.setValue("Url", urlVar); + + QContactAvatar avatar; + QList list2 = map2["image"].toList(); + QListIterator iter2(list2); + while(iter2.hasNext()) + { + QVariantMap map3 = iter2.next().toMap(); + QUrl imageUrl(map3["#text"].toString()); + avatar.setImageUrl(imageUrl); + break; + } + + QVariant avatarVar = QVariant::fromValue(avatar); + contact.setValue("Avatar", avatarVar);*/ + + profile.setId(map2["name"].toString()); + + list.append(profile); + + if(gItemsPerPage == list.count()) + break; + + } + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + qDebug()<<"list count = "<setValue(list); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + } +#endif + + else + { + qDebug()<<"Service unsupported!!!"; + aRetType = SmfRequestError; + error = SmfPluginErrServiceNotSupported; + } + } + + else if(SmfTransportOpOperationCanceledError == aTransportResult) + { + qDebug()<<"Operation Cancelled !!!"; + error = SmfPluginErrCancelComplete; + aRetType = SmfRequestComplete; + } + + else + { + qDebug()<<"Transport Error !!!"; + error = SmfPluginErrNetworkError; + aRetType = SmfRequestError; + } + + return error; + } + + + +/** + * Destructor + */ +LastFmMusicServiceProviderBase::~LastFmMusicServiceProviderBase( ) + { + } + + +/** + * Method to get the Localisable name of the service. + * @return The Localisable name of the service. + */ +QString LastFmMusicServiceProviderBase::serviceName( ) const + { + return m_serviceName; + } + + +/** + * Method to get the Logo of the service + * @return The Logo of the service + */ +QImage LastFmMusicServiceProviderBase::serviceIcon( ) const + { + return m_serviceIcon; + } + + +/** + * Method to get the Readable service description + * @return The Readable service description + */ +QString LastFmMusicServiceProviderBase::description( ) const + { + return m_description; + } + + +/** + * Method to get the Website of the service + * @return The Website of the service + */ +QUrl LastFmMusicServiceProviderBase::serviceUrl( ) const + { + return m_serviceUrl; + } + + +/** + * Method to get the URL of the Application providing this service + * @return The URL of the Application providing this service + */ +QUrl LastFmMusicServiceProviderBase::applicationUrl( ) const + { + return m_applicationUrl; + } + + +/** + * Method to get the Icon of the application + * @return The Icon of the application + */ +QImage LastFmMusicServiceProviderBase::applicationIcon( ) const + { + return m_applicationIcon; + } + +/** +* Method to get the list of interfaces that this provider support +* @return List of supported Interafces +*/ +QList LastFmMusicServiceProviderBase::supportedInterfaces( ) const + { + return m_supportedInterfaces; + } + +/** +* Method to get the list of languages supported by this service provider +* @return a QStringList of languages supported by this service +* provider in 2 letter ISO 639-1 format. +*/ +QStringList LastFmMusicServiceProviderBase::supportedLanguages( ) const + { + return m_supportedLangs; + } + +/** + * Method to get the Plugin specific ID + * @return The Plugin specific ID + */ +QString LastFmMusicServiceProviderBase::pluginId( ) const + { + return m_pluginId; + } + + +/** + * Method to get the ID of the authentication application + * for this service + * @param aProgram The authentication application name + * @param aArguments List of arguments required for authentication app + * @param aMode Strting mode for authentication application + * @return The ID of the authentication application + */ +QString LastFmMusicServiceProviderBase::authenticationApp( QString &aProgram, + QStringList & aArguments, + QIODevice::OpenModeFlag aMode ) const + { + Q_UNUSED(aProgram) + Q_UNUSED(aArguments) + Q_UNUSED(aMode) + return m_authAppId; + } + + +/** + * Method to get the unique registration ID provided by the + * Smf for authorised plugins + * @return The unique registration ID/token provided by the Smf for + * authorised plugins + */ +QString LastFmMusicServiceProviderBase::smfRegistrationId( ) const + { + return m_smfRegToken; + } + + +/** + * Method that initializes this class. This method should be called + * from the initialize() method of the FBContactFetcherPlugin class + */ +void LastFmMusicServiceProviderBase::initialize() + { + m_serviceName = "last.fm"; + m_description = "Last.fm music service plugin description"; + m_serviceUrl = QUrl(QString("http://www.last.fm")); + m_pluginId = "lastfmmusicserviceplugin.qtplugin"; + m_authAppId = "0x12345678"; + m_supportedInterfaces.append("org.symbian.smf.plugin.music.service/v0.2"); + QSettings iSettings; + m_smfRegToken = iSettings.value("LastFmRegToken").toString(); + m_validity = iSettings.value("LastFmExpiryTime").toDateTime(); + } + + +/* + * Export Macro + * plugin name : LastFmMusicServicePlugin + * plugin class : LastFmMusicServicePlugin + */ +Q_EXPORT_PLUGIN2( lastfmmusicserviceplugin, LastFmMusicServicePlugin ) diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusicserviceplugin/lastfmmusicserviceplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusicserviceplugin/lastfmmusicserviceplugin.h Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,360 @@ +/** + * Copyright (c) 2010 Sasken Communication Technologies Ltd. + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html" + * + * Initial Contributors: + * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution + * + * Contributors: + * Nalina Hariharan + * + * Description: + * The Plugin that does music services related functionalities from last.fm site + * + */ + +#ifndef _LASTFMMUSICSERVICEPLUGIN_H +#define _LASTFMMUSICSERVICEPLUGIN_H + +// Include files +#include + +// Class declaration +class LastFmMusicServiceProviderBase; +class QVariant; + +/** + * The Plugin does music services related functionalities from last.fm site + */ +class LastFmMusicServicePlugin : public QObject, public SmfMusicServicePlugin + { + Q_OBJECT + Q_INTERFACES( SmfMusicServicePlugin SmfPluginBase ) + +public: + /** + * Destructor + */ + virtual ~LastFmMusicServicePlugin ( ); + +public: // From SmfMusicServicePlugin interface + /** + * Method to get self profile information + * @param aRequest [out] The request data to be sent to network + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError userMusicInfo( SmfPluginRequestData &aRequest ); + + /** + * Method to search information about artists. All information + * in SmfArtists is not required, however more available the better + * @param aRequest [out] The request data to be sent to network + * @param aArtist The artist which is the search criteria + * @param aPageNum The page to be extracted + * @param aItemsPerPage Number of items per page + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError searchArtist( SmfPluginRequestData &aRequest, + const SmfArtists &aArtist, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to search information about album. All information + * in SmfAlbum is not required, however more available the better + * @param aRequest [out] The request data to be sent to network + * @param aAlbum [in] The album which is the search criteria + * @param aPageNum [in] The page to be extracted + * @param aItemsPerPage [in] Number of items per page + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError searchAlbum( SmfPluginRequestData &aRequest, + const SmfAlbum &aAlbum, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to search information about events. All information + * in SmfEvent is not required, however more available the better + * @param aRequest [out] The request data to be sent to network + * @param aEvent [in] The event which is the search criteria + * @param aPageNum [in] The page to be extracted + * @param aItemsPerPage [in] Number of items per page + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError searchEvents( SmfPluginRequestData &aRequest, + const SmfEvent &aEvent, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to search information about venue. All information + * in SmfLocation is not required, however more available the better + * @param aRequest [out] The request data to be sent to network + * @param aVenue [in] The venue which is the search criteria + * @param aPageNum [in] The page to be extracted + * @param aItemsPerPage [in] Number of items per page + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError searchVenue( SmfPluginRequestData &aRequest, + const SmfLocation &aVenue, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to search information about other service users for a + * particular place + * @param aRequest [out] The request data to be sent to network + * @param aPlace [in] The place which is the search criteria + * @param aPageNum [in] The page to be extracted + * @param aItemsPerPage [in] Number of items per page + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError searchUser( SmfPluginRequestData &aRequest, + const SmfLocation &aPlace, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to post the currently playing track + * @param aRequest [out] The request data to be sent to network + * @param aTrack [in] The current playing track, that should be posted + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError postCurrentPlaying( + SmfPluginRequestData &aRequest, + const SmfTrackInfo &aTrack ); + + /** + * Method to post the rating on a track + * @param aRequest [out] The request data to be sent to network + * @param aTrack [in] The track on which rating should be posted + * @param aRating [in] The rating values + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError postRating( + SmfPluginRequestData &aRequest, + const SmfTrackInfo &aTrack, + const SmfMusicRating &aRating ); + + /** + * Method to post comment on a track + * @param aRequest [out] The request data to be sent to network + * @param aTrack [in] The track on which comment should be posted + * @param aComment [in] The comment content + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError postComments( + SmfPluginRequestData &aRequest, + const SmfTrackInfo &aTrack, + const SmfComment &aComment ); + + /** + * Customised method for SmfMusicServicePlugin interface + * @param aRequest [out] The request data to be sent to network + * @param aOperation [in] The operation type (should be known between + * the client interface and the plugin) + * @param aData [in] The data required to form the request (The type + * of data should be known between client and the plugin) + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError customRequest( SmfPluginRequestData &aRequest, + const int &aOperation, QByteArray *aData ); + + +public: // From SmfPluginBase interface + /** + * The first method to be called in the plugin that implements this interface. + * If this method is not called, plugin may not behave as expected. + */ + void initialize( ); + + /** + * Method to get the provider information + * @return Instance of SmfProviderBase + */ + SmfProviderBase* getProviderInfo( ); + + /** + * Method to get the result for a network request. + * @param aOperation The type of operation to be requested + * @param aTransportResult The result of transport operation + * @param aResponse The QByteArray instance containing the network response. + * The plugins should delete this instance once they have read the + * data from it. + * @param aResult [out] An output parameter to the plugin manager.If the + * return value is SmfSendRequestAgain, QVariant will be of type + * SmfPluginRequestData. + * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult + * will be of type SmfMusicProfile. If last operation was searchArtist(), + * aResult will be of type QList. If last operation was searchAlbum(), + * aResult will be of type QList. If last operation was searchEvents(), + * aResult will be of type QList. If last operation was searchVenue(), + * aResult will be of type QList. If last operation was searchUser(), + * aResult will be of type QList. If last operation was + * postCurrentPlaying() or postRating() or postComments(), aResult will be of + * type bool. + * @param aRetType [out] SmfPluginRetType + * @param aPageResult [out] The SmfResultPage structure variable + */ + SmfPluginError responseAvailable( + const SmfRequestTypeID aOperation, + const SmfTransportResult &aTransportResult, + QByteArray *aResponse, + QVariant* aResult, + SmfPluginRetType &aRetType, + SmfResultPage &aPageResult ); + +private: + /** + * Method called by plugins to generate a signature string from a base string + * @param aBaseString The base string + * @return The md5 hash of the base string + */ + QString generateSignature(const QString aBaseString); + + /** + * Method to interpret the key sets obtained from credential manager + * @param aApiKey [out] The api key + * @param aApiSecret [out] The api secret + * @param aSessionKey [out] The session key + * @param aToken [out] The session token + * @param aName [out] The user name + */ + void fetchKeys( QString &aApiKey, + QString &aApiSecret, + QString &aToken, + QString &aName ); + +private: // Data + LastFmMusicServiceProviderBase *m_provider; + }; + + + +/** + * The Plugin class that implements SmfProviderBase for this last.fm plugin + */ +class LastFmMusicServiceProviderBase : public QObject, public SmfProviderBase + { + Q_OBJECT + Q_INTERFACES( SmfProviderBase ) + +public: + /** + * Destructor + */ + virtual ~LastFmMusicServiceProviderBase( ); + + /** + * Method to get the Localisable name of the service. + * @return The Localisable name of the service. + */ + QString serviceName( ) const; + + /** + * Method to get the Logo of the service + * @return The Logo of the service + */ + QImage serviceIcon( ) const; + + /** + * Method to get the Readable service description + * @return The Readable service description + */ + QString description( ) const; + + /** + * Method to get the Website of the service + * @return The Website of the service + */ + QUrl serviceUrl( ) const; + + /** + * Method to get the URL of the Application providing this service + * @return The URL of the Application providing this service + */ + QUrl applicationUrl( ) const; + + /** + * Method to get the Icon of the application + * @return The Icon of the application + */ + QImage applicationIcon( ) const; + + /** + * Method to get the list of interfaces that this provider support + * @return List of supported Interafces + */ + QList supportedInterfaces( ) const; + + /** + * Method to get the list of languages supported by this service provider + * @return a QStringList of languages supported by this service + * provider in 2 letter ISO 639-1 format. + */ + QStringList supportedLanguages( ) const; + + /** + * Method to get the Plugin specific ID + * @return The Plugin specific ID + */ + QString pluginId( ) const; + + /** + * Method to get the ID of the authentication application + * for this service + * @param aProgram The authentication application name + * @param aArguments List of arguments required for authentication app + * @param aMode Strting mode for authentication application + * @return The ID of the authentication application + */ + QString authenticationApp( QString &aProgram, QStringList & aArguments, + QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const; + + /** + * Method to get the unique registration ID provided by the + * Smf for authorised plugins + * @return The unique registration ID/token provided by the Smf for + * authorised plugins + */ + QString smfRegistrationId( ) const; + +private: + /** + * Method that initializes this class. This method should be called + * from the initialize() method of the LastFmMusicServicePlugin class + */ + void initialize(); + +private: + friend class LastFmMusicServicePlugin; + QString m_serviceName; + QImage m_serviceIcon; + QString m_description; + QUrl m_serviceUrl; + QUrl m_applicationUrl; + QImage m_applicationIcon; + QString m_pluginId; + QString m_authAppId; + QString m_smfRegToken; + QList m_supportedInterfaces; + QStringList m_supportedLangs; + QDateTime m_validity; + }; + +#endif //_LASTFMMUSICSERVICEPLUGIN_H diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusicserviceplugin/lastfmmusicserviceplugin.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusicserviceplugin/lastfmmusicserviceplugin.pro Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,43 @@ +TEMPLATE = lib + +CONFIG += plugin \ + mobility + +MOBILITY += contacts \ + location + +QT += core \ + network + +HEADERS = lastfmmusicserviceplugin.h + +SOURCES = lastfmmusicserviceplugin.cpp + +TARGET = $$qtLibraryTarget(lastfmmusicserviceplugin) + +symbian: { + # Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files + load(data_caging_paths) + + # EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data + TARGET.EPOCALLOWDLLDATA = 1 + + # Defines plugin files into Symbian .pkg package + pluginDep.sources = lastfmmusicserviceplugin.dll + pluginDep.path = $$QT_PLUGINS_BASE_DIR/smf/plugin/music.service + DEPLOYMENT += pluginDep + + TARGET.CAPABILITY = NetworkServices \ + ReadUserData \ + WriteUserData \ + LocalServices \ + UserEnvironment \ + ReadDeviceData \ + WriteDeviceData + + LIBS += -lsmfcommon +} + +target.path += $$[QT_INSTALL_PLUGINS]/smf/plugin/music.service + +INSTALLS += target \ No newline at end of file diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusicserviceplugin/plugin_commonU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusicserviceplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,16 @@ +; ============================================================================== +; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50 +; This file is generated by qmake and should not be modified by the +; user. +; Name : plugin_commonU.def +; Part of : lastfmmusicserviceplugin +; Description : Fixes common plugin symbols to known ordinals +; Version : +; +; ============================================================================== + + +EXPORTS + qt_plugin_query_verification_data @ 1 NONAME + qt_plugin_instance @ 2 NONAME + diff -r b2eb79881f9d -r 574948b60dab example/lastfmmusicserviceplugin/qmakepluginstubs/lastfmmusicserviceplugin.qtplugin --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmmusicserviceplugin/qmakepluginstubs/lastfmmusicserviceplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,1 @@ +This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50 diff -r b2eb79881f9d -r 574948b60dab example/lastfmplaylistserviceplugin/lastfmplaylistserviceplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmplaylistserviceplugin/lastfmplaylistserviceplugin.cpp Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,918 @@ +/** + * Copyright (c) 2010 Sasken Communication Technologies Ltd. + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html" + * + * Initial Contributors: + * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution + * + * Contributors: + * Sangeeta Prasad, Nalina Hariharan + * + * Description: + * The Plugin that does music services related functionalities from last.fm site + * + */ + +// Include files +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lastfmplaylistserviceplugin.h" + + +static int gPageNum = 0; +static int gItemsPerPage = 0; + +//Payload data array +QByteArray payload; + +/** + * Destructor + */ +LastFmPlaylistServicePlugin::~LastFmPlaylistServicePlugin( ) + { + if(m_provider) + delete m_provider; + } + +/** + * Method to interpret the key sets obtained from credential manager + * @param aApiKey [out] The api key + * @param aApiSecret [out] The api secret + * @param aSessionKey [out] The session key + * @param aToken [out] The session token + * @param aName [out] The user name + */ +void LastFmPlaylistServicePlugin::fetchKeys( QString &aApiKey, + QString &aApiSecret, + QString &aToken, + QString &aName ) + { + qDebug()<<"Reg Token = "<m_smfRegToken; + qDebug()<<"Expiry Date as int = "<m_validity.toTime_t(); + + SmfAuthParams keys; + SmfPluginUtil util; + util.getAuthKeys(keys, m_provider->m_smfRegToken, + m_provider->m_validity, m_provider->m_pluginId); + + QByteArray keyName; + keyName.append("ApiKey"); + aApiKey.append(keys.value(keyName)); + + keyName.clear(); + keyName.append("ApiSecret"); + aApiSecret.append(keys.value(keyName)); + + keyName.clear(); + keyName.append("Token"); + aToken.append(keys.value(keyName)); + + keyName.clear(); + keyName.append("Name"); + aName.append(keys.value(keyName)); + + qDebug()<<"Api Key = "<().firstName().isEmpty() ) + { + qDebug()<<"Invalid arguments"; + return error; + } + + qDebug()<<"Valid arguments"; + + gPageNum = aPageNum; + gItemsPerPage = aItemsPerPage; + + // Get the key sets from SMF Plugin Utility class. + QString apiKey; + QString apiSecret; + QString token; + QString userName; + fetchKeys(apiKey, apiSecret, token, userName); + + userName.clear(); + userName = aUser.value("Name").value().firstName(); + + // Create the API signature string + QString baseString; + baseString.append("api_key"+apiKey); + baseString.append("methoduser.getPlaylists"); + baseString.append("user"+userName); + baseString.append(apiSecret); + + // Create the url + QUrl url("http://ws.audioscrobbler.com/2.0/?"); + url.addQueryItem("api_key", apiKey); + url.addQueryItem("format", "json"); + url.addQueryItem("method", "user.getPlaylists"); + url.addQueryItem("user", userName); + url.addQueryItem("api_sig", generateSignature(baseString)); + + // Create the request, set the url + aRequest.iNetworkRequest.setUrl(url); + aRequest.iRequestType = SmfMusicGetPlaylistsOfUser; + aRequest.iPostData = NULL; + aRequest.iHttpOperationType = QNetworkAccessManager::GetOperation; + error = SmfPluginErrNone; + + qDebug()<<"Url string is : "< &aTracks ) + { + qDebug()<<"Inside LastFmPlaylistServicePlugin::addToPlaylist()"; + + SmfPluginError error = SmfPluginErrInvalidArguments; + + // invalid arguments + if( aPlaylist.id().isEmpty() || (0 == aTracks.count()) ) + { + qDebug()<<"Invalid arguments"; + return error; + } + else if(aTracks.at(0).title().isEmpty() || aTracks.at(0).artists().names().at(0).isEmpty()) + { + qDebug()<<"Invalid arguments"; + return error; + } + else + qDebug()<<"Valid arguments"; + + + // Get the key sets from SMF Plugin Utility class. + QString apiKey; + QString apiSecret; + QString token; + QString userName; + fetchKeys(apiKey, apiSecret, token, userName); + + // Create the API signature string + QString baseString; + baseString.append("api_key"+apiKey); + baseString.append("artist"+aTracks.at(0).artists().names().at(0)); + baseString.append("methodplaylist.addTrack"); + baseString.append("playlistID"+aPlaylist.id()); + baseString.append("sk"+token); + baseString.append("track"+aTracks.at(0).title()); + baseString.append(apiSecret); + + QUrl postData; + postData.addQueryItem("api_key", apiKey); + postData.addQueryItem("artist", aTracks.at(0).artists().names().at(0)); + postData.addQueryItem("format","json"); + postData.addQueryItem("method", "playlist.addTrack"); + postData.addQueryItem("playlistID",aPlaylist.id()); + postData.addQueryItem("sk",token); + postData.addQueryItem("track",aTracks.at(0).title()); + postData.addQueryItem("api_sig", generateSignature(baseString)); + + QString data(postData.toString()); + data.remove(0, 1); // Remove the first ? + + payload.clear(); + payload.append(data.toAscii()); + + qDebug()<<"Data = "<initialize(); + } + +/** + * Method to get the provider information + * @return Instance of SmfProviderBase + */ +SmfProviderBase* LastFmPlaylistServicePlugin::getProviderInfo( ) + { + return m_provider; + } + +/** + * Method to get the result for a network request. + * @param aOperation The type of operation to be requested + * @param aTransportResult The result of transport operation + * @param aResponse The QByteArray instance containing the network response. + * The plugins should delete this instance once they have read the + * data from it. + * @param aResult [out] An output parameter to the plugin manager.If the + * return value is SmfSendRequestAgain, QVariant will be of type + * SmfPluginRequestData. + * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult + * will be of type SmfMusicProfile. If last operation was searchArtist(), + * aResult will be of type QList. If last operation was searchAlbum(), + * aResult will be of type QList. If last operation was searchEvents(), + * aResult will be of type QList. If last operation was searchVenue(), + * aResult will be of type QList. If last operation was searchUser(), + * aResult will be of type QList. If last operation was + * postCurrentPlaying() or postRating() or postComments(), aResult will be of + * type bool. + * @param aRetType [out] SmfPluginRetType + * @param aPageResult [out] The SmfResultPage structure variable + */ +SmfPluginError LastFmPlaylistServicePlugin::responseAvailable( + const SmfRequestTypeID aOperation, + const SmfTransportResult &aTransportResult, + QByteArray *aResponse, + QVariant* aResult, + SmfPluginRetType &aRetType, + SmfResultPage &aPageResult ) + { + + Q_UNUSED(aPageResult) + qDebug()<<"Inside LastFmPlaylistServicePlugin::responseAvailable()"; + + SmfPluginError error = SmfPluginErrNetworkError; + + if( !aResponse || (0 == aResponse->size()) ) + { + qDebug()<<"Response is NULL or empty"; + aRetType = SmfRequestError; + return error; + } + + QByteArray response(*aResponse); + delete aResponse; + + QFile respFile("c://data//SmfMusicPlaylistPluginResponse.txt"); + if(!respFile.open(QIODevice::WriteOnly)) + qDebug()<<"File to write the response could not be opened"; + else + { + respFile.write(response); + respFile.close(); + qDebug()<<"Writing FB response to a file named 'SmfMusicPlaylistPluginResponse.txt'"; + } + qDebug()<<"FB response size = "< list; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + qDebug()<<"Json parsing complete"; + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + QVariantMap map1 = result["playlists"].toMap(); + QList list1 = map1["playlist"].toList(); + QListIterator iter1(list1); + bool ifList = false; + while(iter1.hasNext()) + { + ifList = true; + QVariantMap map2 = iter1.next().toMap(); + SmfPlaylist playlist; + + playlist.setPlayListTitle(map2["title"].toString()); + playlist.setId(map2["id"].toString()); + playlist.setAuthor(map2["creator"].toString()); + QUrl url(map2["url"].toString()); + playlist.setInfo(url); + playlist.setLocation(url); + + + QList list2 = map2["image"].toList(); + QListIterator iter2(list2); + while(iter2.hasNext()) + { + QVariantMap map3 = iter2.next().toMap(); + QUrl imageUrl(map3["#text"].toString()); + playlist.setImage(imageUrl); + } + + list.append((playlist)); + + if(gItemsPerPage == list.count()) + break; + } + if(!ifList) + { + QVariantMap map2 = map1["playlist"].toMap(); + SmfPlaylist playlist; + + playlist.setPlayListTitle(map2["title"].toString()); + playlist.setId(map2["id"].toString()); + playlist.setAuthor(map2["creator"].toString()); + QUrl url(map2["url"].toString()); + playlist.setInfo(url); + playlist.setLocation(url); + + + QList list2 = map2["image"].toList(); + QListIterator iter2(list2); + while(iter2.hasNext()) + { + QVariantMap map3 = iter2.next().toMap(); + QUrl imageUrl(map3["#text"].toString()); + playlist.setImage(imageUrl); + } + + list.append((playlist)); + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + qDebug()<<"Count of user's recent tracks = "<setValue(list); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + } + } + + // Playlists of another user + else if ( SmfMusicGetPlaylistsOfUser == aOperation ) + { + qDebug()<<"Response for getting another user's playlist"; + QList list; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + qDebug()<<"Json parsing complete"; + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + QVariantMap map1 = result["playlists"].toMap(); + QList list1 = map1["playlist"].toList(); + QListIterator iter1(list1); + bool ifList = false; + while(iter1.hasNext()) + { + ifList = true; + QVariantMap map2 = iter1.next().toMap(); + SmfPlaylist playlist; + + playlist.setPlayListTitle(map2["title"].toString()); + playlist.setId(map2["id"].toString()); + playlist.setAuthor(map2["creator"].toString()); + QUrl url(map2["url"].toString()); + playlist.setInfo(url); + playlist.setLocation(url); + + + QList list2 = map2["image"].toList(); + QListIterator iter2(list2); + while(iter2.hasNext()) + { + QVariantMap map3 = iter2.next().toMap(); + QUrl imageUrl(map3["#text"].toString()); + playlist.setImage(imageUrl); + } + + list.append((playlist)); + + if(gItemsPerPage == list.count()) + break; + } + if(!ifList) + { + QVariantMap map2 = map1["playlist"].toMap(); + SmfPlaylist playlist; + + playlist.setPlayListTitle(map2["title"].toString()); + playlist.setId(map2["id"].toString()); + playlist.setAuthor(map2["creator"].toString()); + QUrl url(map2["url"].toString()); + playlist.setInfo(url); + playlist.setLocation(url); + + + QList list2 = map2["image"].toList(); + QListIterator iter2(list2); + while(iter2.hasNext()) + { + QVariantMap map3 = iter2.next().toMap(); + QUrl imageUrl(map3["#text"].toString()); + playlist.setImage(imageUrl); + } + + list.append((playlist)); + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + qDebug()<<"Count of friend's playlists = "<setValue(list); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + } + } + + // Adding track to playlist AND + // Post current playing playlist + else if ((SmfMusicAddToPlaylist == aOperation) || (SmfMusicPostCurrentPlayingPlaylist == aOperation)) + { + qDebug()<<"Response for adding track to playlist"; + bool reqSuccess = false; + QString errStr; + errStr.clear(); + + bool ok; + SmfPluginUtil util; + QVariantMap result = util.parse(response, &ok).toMap(); + if (!ok) + { + qDebug()<<"An error occurred during json parsing"; + aRetType = SmfRequestError; + return SmfPluginErrParsingFailed; + } + + qDebug()<<"Json parsing complete"; + + if(response.contains(QByteArray("error"))) + { + errStr.append(result["message"].toString()); + } + else + { + reqSuccess = true; + } + + if(errStr.size()) + { + qDebug()<<"Response error found = "<setValue(errStr); + } + else + { + qDebug()<<"Track added to playlist?? "<setValue(reqSuccess); + aRetType = SmfRequestComplete; + error = SmfPluginErrNone; + } + } + + // Other Service requests - NOT SUPPORTED + else + { + qDebug()<<"Service unsupported!!!"; + aRetType = SmfRequestError; + error = SmfPluginErrServiceNotSupported; + } + } + + else if(SmfTransportOpOperationCanceledError == aTransportResult) + { + qDebug()<<"Operation Cancelled !!!"; + error = SmfPluginErrCancelComplete; + aRetType = SmfRequestComplete; + } + + else + { + qDebug()<<"Transport Error !!!"; + error = SmfPluginErrNetworkError; + aRetType = SmfRequestError; + } + + return error; + + } + + + +/** + * Destructor + */ +LastFmPlaylistServiceProviderBase::~LastFmPlaylistServiceProviderBase( ) + { + } + +/** + * Method to get the Localisable name of the service. + * @return The Localisable name of the service. + */ +QString LastFmPlaylistServiceProviderBase::serviceName( ) const + { + return m_serviceName; + } + + +/** + * Method to get the Logo of the service + * @return The Logo of the service + */ +QImage LastFmPlaylistServiceProviderBase::serviceIcon( ) const + { + return m_serviceIcon; + } + + +/** + * Method to get the Readable service description + * @return The Readable service description + */ +QString LastFmPlaylistServiceProviderBase::description( ) const + { + return m_description; + } + + +/** + * Method to get the Website of the service + * @return The Website of the service + */ +QUrl LastFmPlaylistServiceProviderBase::serviceUrl( ) const + { + return m_serviceUrl; + } + + +/** + * Method to get the URL of the Application providing this service + * @return The URL of the Application providing this service + */ +QUrl LastFmPlaylistServiceProviderBase::applicationUrl( ) const + { + return m_applicationUrl; + } + + +/** + * Method to get the Icon of the application + * @return The Icon of the application + */ +QImage LastFmPlaylistServiceProviderBase::applicationIcon( ) const + { + return m_applicationIcon; + } + +/** +* Method to get the list of interfaces that this provider support +* @return List of supported Interafces +*/ +QList LastFmPlaylistServiceProviderBase::supportedInterfaces( ) const + { + return m_supportedInterfaces; + } + +/** +* Method to get the list of languages supported by this service provider +* @return a QStringList of languages supported by this service +* provider in 2 letter ISO 639-1 format. +*/ +QStringList LastFmPlaylistServiceProviderBase::supportedLanguages( ) const + { + return m_supportedLangs; + } + +/** + * Method to get the Plugin specific ID + * @return The Plugin specific ID + */ +QString LastFmPlaylistServiceProviderBase::pluginId( ) const + { + return m_pluginId; + } + + +/** + * Method to get the ID of the authentication application + * for this service + * @param aProgram The authentication application name + * @param aArguments List of arguments required for authentication app + * @param aMode Strting mode for authentication application + * @return The ID of the authentication application + */ +QString LastFmPlaylistServiceProviderBase::authenticationApp( QString &aProgram, + QStringList & aArguments, + QIODevice::OpenModeFlag aMode ) const + { + Q_UNUSED(aProgram) + Q_UNUSED(aArguments) + Q_UNUSED(aMode) + return m_authAppId; + } + + +/** + * Method to get the unique registration ID provided by the + * Smf for authorised plugins + * @return The unique registration ID/token provided by the Smf for + * authorised plugins + */ +QString LastFmPlaylistServiceProviderBase::smfRegistrationId( ) const + { + return m_smfRegToken; + } + + +/** + * Method that initializes this class. This method should be called + * from the initialize() method of the FBContactFetcherPlugin class + */ +void LastFmPlaylistServiceProviderBase::initialize() + { + m_serviceName = "last.fm"; + m_description = "Last.fm music playlist plugin description"; + m_serviceUrl = QUrl(QString("http://www.last.fm")); + m_pluginId = "lastfmplaylistserviceplugin.qtplugin"; + m_authAppId = "0x12345678"; + m_supportedInterfaces.append("org.symbian.smf.plugin.music.playlist/v0.2"); + QSettings iSettings; + m_smfRegToken = iSettings.value("LastFmRegToken").toString(); + m_validity = iSettings.value("LastFmExpiryTime").toDateTime(); + } + + +/* + * Export Macro + * plugin name : lastfmplaylistserviceplugin + * plugin class : LastFmPlaylistServicePlugin + */ +Q_EXPORT_PLUGIN2( lastfmplaylistserviceplugin, LastFmPlaylistServicePlugin ) diff -r b2eb79881f9d -r 574948b60dab example/lastfmplaylistserviceplugin/lastfmplaylistserviceplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmplaylistserviceplugin/lastfmplaylistserviceplugin.h Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,285 @@ +/** + * Copyright (c) 2010 Sasken Communication Technologies Ltd. + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html" + * + * Initial Contributors: + * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution + * + * Contributors: + * Sangeeta Prasad, Nalina Hariharan + * + * Description: + * The Plugin that does music playlist services related + * functionalities from last.fm site + * + */ + +#ifndef _LASTFMPLAYLISTSERVICEPLUGIN_H_ +#define _LASTFMPLAYLISTSERVICEPLUGIN_H_ + +//Include files +#include + +// Forward declarations +class LastFmPlaylistServiceProviderBase; +class QVariant; + +// Class declaration +class LastFmPlaylistServicePlugin : public QObject, public SmfPlaylistServicePlugin +{ + Q_OBJECT + Q_INTERFACES( SmfPlaylistServicePlugin SmfPluginBase ) + +public: + /** + * Destructor + */ + virtual ~LastFmPlaylistServicePlugin ( ); + +public: // From SmfPlaylistServicePlugin + /** + * Method to get the playlist + * @param aRequest [out] The request data to be sent to network + * @param aPageNum [in] The page to be extracted + * @param aItemsPerPage [in] Number of items per page + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError playlists( SmfPluginRequestData &aRequest, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to get the playlist of a particular user + * @param aRequest [out] The request data to be sent to network + * @param aUser [in] The user whose playlists need to be fetched + * @param aPageNum [in] The page to be extracted + * @param aItemsPerPage [in] Number of items per page + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError playlistsOf( SmfPluginRequestData &aRequest, + const SmfContact &aUser, + const int aPageNum = SMF_FIRST_PAGE, + const int aItemsPerPage = SMF_ITEMS_PER_PAGE ); + + /** + * Method to add tracks to a playlist + * @param aRequest [out] The request data to be sent to network + * @param aPlaylist [in] The playlist where tracks should be added + * @param aTracks [in] The tracks to be added to the playlist + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError addToPlaylist( SmfPluginRequestData &aRequest, + const SmfPlaylist &aPlaylist, + const QList &aTracks ); + + /** + * Method to post the current playing playlist + * @param aRequest [out] The request data to be sent to network + * @param aPlaylist [in] The current playing playlist which should be posted + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError postCurrentPlayingPlaylist( + SmfPluginRequestData &aRequest, + const SmfPlaylist &aPlaylist ); + + /** + * Customised method for SmfPlaylistServicePlugin interface + * @param aRequest [out] The request data to be sent to network + * @param aOperation [in] The operation type (should be known between + * the client interface and the plugin) + * @param aData [in] The data required to form the request (The type + * of data should be known between client and the plugin) + * @return Appropriate value of the enum SmfPluginError. + * Plugin error if any, else SmfPluginErrNone for success + */ + SmfPluginError customRequest( SmfPluginRequestData &aRequest, + const int &aOperation, QByteArray *aData ); + +public: // From SmfPluginBase interface + /** + * The first method to be called in the plugin that implements this interface. + * If this method is not called, plugin may not behave as expected. + */ + void initialize( ); + + /** + * Method to get the provider information + * @return Instance of SmfProviderBase + */ + SmfProviderBase* getProviderInfo( ); + + /** + * Method to get the result for a network request. + * @param aOperation The type of operation to be requested + * @param aTransportResult The result of transport operation + * @param aResponse The QByteArray instance containing the network response. + * The plugins should delete this instance once they have read the + * data from it. + * @param aResult [out] An output parameter to the plugin manager.If the + * return value is SmfSendRequestAgain, QVariant will be of type + * SmfPluginRequestData. + * For SmfMusicServicePlugin: If last operation was userMusicInfo(), aResult + * will be of type SmfMusicProfile. If last operation was searchArtist(), + * aResult will be of type QList. If last operation was searchAlbum(), + * aResult will be of type QList. If last operation was searchEvents(), + * aResult will be of type QList. If last operation was searchVenue(), + * aResult will be of type QList. If last operation was searchUser(), + * aResult will be of type QList. If last operation was + * postCurrentPlaying() or postRating() or postComments(), aResult will be of + * type bool. + * @param aRetType [out] SmfPluginRetType + * @param aPageResult [out] The SmfResultPage structure variable + */ + SmfPluginError responseAvailable( + const SmfRequestTypeID aOperation, + const SmfTransportResult &aTransportResult, + QByteArray *aResponse, + QVariant* aResult, + SmfPluginRetType &aRetType, + SmfResultPage &aPageResult ); + +private: + /** + * Method called by plugins to generate a signature string from a base string + * @param aBaseString The base string + * @return The md5 hash of the base string + */ + QString generateSignature( const QString aBaseString ); + + /** + * Method to interpret the key sets obtained from credential manager + * @param aApiKey [out] The api key + * @param aApiSecret [out] The api secret + * @param aSessionKey [out] The session key + * @param aToken [out] The session token + * @param aName [out] The user name + */ + void fetchKeys( QString &aApiKey, + QString &aApiSecret, + QString &aToken, + QString &aName ); + +private: + LastFmPlaylistServiceProviderBase *m_provider; + }; + +/** + * The Plugin class that implements SmfProviderBase for this last.fm plugin + */ +class LastFmPlaylistServiceProviderBase : public QObject, public SmfProviderBase + { + Q_OBJECT + Q_INTERFACES( SmfProviderBase ) + +public: + /** + * Destructor + */ + virtual ~LastFmPlaylistServiceProviderBase( ); + + /** + * Method to get the Localisable name of the service. + * @return The Localisable name of the service. + */ + QString serviceName( ) const; + + /** + * Method to get the Logo of the service + * @return The Logo of the service + */ + QImage serviceIcon( ) const; + + /** + * Method to get the Readable service description + * @return The Readable service description + */ + QString description( ) const; + + /** + * Method to get the Website of the service + * @return The Website of the service + */ + QUrl serviceUrl( ) const; + + /** + * Method to get the URL of the Application providing this service + * @return The URL of the Application providing this service + */ + QUrl applicationUrl( ) const; + + /** + * Method to get the Icon of the application + * @return The Icon of the application + */ + QImage applicationIcon( ) const; + + /** + * Method to get the list of interfaces that this provider support + * @return List of supported Interafces + */ + QList supportedInterfaces( ) const; + + /** + * Method to get the list of languages supported by this service provider + * @return a QStringList of languages supported by this service + * provider in 2 letter ISO 639-1 format. + */ + QStringList supportedLanguages( ) const; + + /** + * Method to get the Plugin specific ID + * @return The Plugin specific ID + */ + QString pluginId( ) const; + + /** + * Method to get the ID of the authentication application + * for this service + * @param aProgram The authentication application name + * @param aArguments List of arguments required for authentication app + * @param aMode Strting mode for authentication application + * @return The ID of the authentication application + */ + QString authenticationApp( QString &aProgram, QStringList & aArguments, + QIODevice::OpenModeFlag aMode = QIODevice::ReadWrite ) const; + + /** + * Method to get the unique registration ID provided by the + * Smf for authorised plugins + * @return The unique registration ID/token provided by the Smf for + * authorised plugins + */ + QString smfRegistrationId( ) const; + +private: + /** + * Method that initializes this class. This method should be called + * from the initialize() method of the LastFmPlaylistServicePlugin class + */ + void initialize(); + +private: + friend class LastFmPlaylistServicePlugin; + QString m_serviceName; + QImage m_serviceIcon; + QString m_description; + QUrl m_serviceUrl; + QUrl m_applicationUrl; + QImage m_applicationIcon; + QString m_pluginId; + QString m_authAppId; + QString m_smfRegToken; + QList m_supportedInterfaces; + QStringList m_supportedLangs; + QDateTime m_validity; + }; + +#endif /* _LASTFMPLAYLISTSERVICEPLUGIN_H_ */ diff -r b2eb79881f9d -r 574948b60dab example/lastfmplaylistserviceplugin/lastfmplaylistserviceplugin.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmplaylistserviceplugin/lastfmplaylistserviceplugin.pro Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,43 @@ +TEMPLATE = lib + +CONFIG += plugin \ + mobility + +MOBILITY += contacts \ + location + +QT += core \ + network + +HEADERS = lastfmplaylistserviceplugin.h + +SOURCES = lastfmplaylistserviceplugin.cpp + +TARGET = $$qtLibraryTarget(lastfmplaylistserviceplugin) + +symbian: { + # Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files + load(data_caging_paths) + + # EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data + TARGET.EPOCALLOWDLLDATA = 1 + + # Defines plugin files into Symbian .pkg package + pluginDep.sources = lastfmplaylistserviceplugin.dll + pluginDep.path = $$QT_PLUGINS_BASE_DIR/smf/plugin/music.playlist + DEPLOYMENT += pluginDep + + TARGET.CAPABILITY = NetworkServices \ + ReadUserData \ + WriteUserData \ + LocalServices \ + UserEnvironment \ + ReadDeviceData \ + WriteDeviceData + + LIBS += -lsmfcommon +} + +target.path += $$[QT_INSTALL_PLUGINS]/smf/plugin/music.playlist + +INSTALLS += target \ No newline at end of file diff -r b2eb79881f9d -r 574948b60dab example/lastfmplaylistserviceplugin/plugin_commonU.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmplaylistserviceplugin/plugin_commonU.def Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,16 @@ +; ============================================================================== +; Generated by qmake (2.01a) (Qt 4.6.2) on: 2010-09-23T11:35:50 +; This file is generated by qmake and should not be modified by the +; user. +; Name : plugin_commonU.def +; Part of : lastfmplaylistserviceplugin +; Description : Fixes common plugin symbols to known ordinals +; Version : +; +; ============================================================================== + + +EXPORTS + qt_plugin_query_verification_data @ 1 NONAME + qt_plugin_instance @ 2 NONAME + diff -r b2eb79881f9d -r 574948b60dab example/lastfmplaylistserviceplugin/qmakepluginstubs/lastfmplaylistserviceplugin.qtplugin --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/lastfmplaylistserviceplugin/qmakepluginstubs/lastfmplaylistserviceplugin.qtplugin Thu Sep 23 17:15:03 2010 +0530 @@ -0,0 +1,1 @@ +This file is a Qt plugin stub file. The real Qt plugin is located in \sys\bin. Created:2010-09-23T11:35:50 diff -r b2eb79881f9d -r 574948b60dab example/smfclientapp/ui_displaywidget.h --- a/example/smfclientapp/ui_displaywidget.h Thu Sep 16 11:15:30 2010 +0530 +++ b/example/smfclientapp/ui_displaywidget.h Thu Sep 23 17:15:03 2010 +0530 @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'displaywidget.ui' ** -** Created: Fri Jul 30 14:06:51 2010 +** Created: Wed Sep 22 18:28:30 2010 ** by: Qt User Interface Compiler version 4.6.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! diff -r b2eb79881f9d -r 574948b60dab example/smfclientapp/ui_posttestui.h --- a/example/smfclientapp/ui_posttestui.h Thu Sep 16 11:15:30 2010 +0530 +++ b/example/smfclientapp/ui_posttestui.h Thu Sep 23 17:15:03 2010 +0530 @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'posttestui.ui' ** -** Created: Fri Jul 30 14:06:50 2010 +** Created: Wed Sep 22 18:28:30 2010 ** by: Qt User Interface Compiler version 4.6.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! diff -r b2eb79881f9d -r 574948b60dab example/smfclientapp/ui_smfclientapp.h --- a/example/smfclientapp/ui_smfclientapp.h Thu Sep 16 11:15:30 2010 +0530 +++ b/example/smfclientapp/ui_smfclientapp.h Thu Sep 23 17:15:03 2010 +0530 @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'smfclientapp.ui' ** -** Created: Fri Jul 30 14:06:53 2010 +** Created: Wed Sep 22 18:28:33 2010 ** by: Qt User Interface Compiler version 4.6.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file!