35
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
36
|
4 |
* This component and the accompanying materials are made available
|
35
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Music Player Query Manager.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#ifndef MPQUERYMANAGER_H_
|
|
18 |
#define MPQUERYMANAGER_H_
|
|
19 |
|
36
|
20 |
#include <QPointer>
|
35
|
21 |
#include <QNetworkReply>
|
|
22 |
#include <QDomDocument>
|
|
23 |
#include <QMap>
|
47
|
24 |
#include <HbIcon>
|
35
|
25 |
|
|
26 |
#include "mpviewbase.h"
|
|
27 |
|
|
28 |
class QNetworkAccessManager;
|
36
|
29 |
class ThumbnailManager;
|
35
|
30 |
|
|
31 |
/*!
|
|
32 |
MpQueryManager class is responsible for performing music player
|
|
33 |
related network queries, including retrieving the URL for the
|
|
34 |
music.
|
|
35 |
|
|
36 |
It emits searchUrlRetrieved signal when it has received the
|
|
37 |
URL.
|
|
38 |
*/
|
|
39 |
class MpQueryManager : public QObject
|
|
40 |
{
|
|
41 |
Q_OBJECT
|
|
42 |
|
|
43 |
public:
|
|
44 |
MpQueryManager();
|
|
45 |
~MpQueryManager();
|
36
|
46 |
|
35
|
47 |
public:
|
47
|
48 |
void reset();
|
35
|
49 |
void queryLocalMusicStore( QString mArtist,QString mAlbum,QString mTitle );
|
|
50 |
void queryInspireMeItems( QString mArtist,QString mAlbum,QString mTitle );
|
47
|
51 |
void queryLocalMusicStore();
|
|
52 |
bool isLocalMusicStore() const;
|
36
|
53 |
|
47
|
54 |
int recommendationsCount() const;
|
|
55 |
QString recommendedSong(int index) const;
|
|
56 |
QString recommendedArtist(int index) const;
|
|
57 |
HbIcon recommendedAlbumArt(int index) const;
|
35
|
58 |
|
|
59 |
private slots:
|
|
60 |
void retrieveInformationFinished( QNetworkReply* reply );
|
|
61 |
void retrieveInformationNetworkError( QNetworkReply::NetworkError error );
|
|
62 |
void retrieveInformationSslErrors( const QList<QSslError> &error );
|
47
|
63 |
void albumArtDownloaded( QNetworkReply* reply );
|
36
|
64 |
void setAlbumArtUri( const QString &albumArtUri, const QString &albumArtName );
|
47
|
65 |
void thumbnailReady( const QPixmap pixmap, void *data, int id, int error );
|
36
|
66 |
|
35
|
67 |
private:
|
47
|
68 |
void clearThumbnails();
|
|
69 |
void clearRecommendations();
|
|
70 |
void clearNetworkReplies();
|
|
71 |
void signalError();
|
36
|
72 |
void constructRequest( QString &uri );
|
35
|
73 |
// retrieve URI from Ovi music server
|
|
74 |
void retrieveInformation( const QString &urlEncoded );
|
36
|
75 |
|
35
|
76 |
QString keyValues( QStringList keys, QStringList values ) const;
|
|
77 |
void handleParsedXML();
|
|
78 |
|
|
79 |
bool writeImageToFile( const QByteArray &aImageData, const QString &aImageFileName );
|
36
|
80 |
|
35
|
81 |
signals:
|
47
|
82 |
void inspireMeItemAlbumArtReady();
|
|
83 |
void localMusicStoreRetrieved(bool storeUpdated);
|
|
84 |
void localMusicStoreRetrievalError();
|
|
85 |
void inspireMeItemsRetrievalError();
|
|
86 |
void inspireMeItemsMetadataRetrieved();
|
|
87 |
|
36
|
88 |
private:
|
|
89 |
|
47
|
90 |
QNetworkAccessManager *mManager;
|
|
91 |
QNetworkAccessManager *mAlbumArtDownloader;
|
36
|
92 |
|
47
|
93 |
int mDownloadedAlbumArts;
|
36
|
94 |
|
47
|
95 |
QList<QNetworkReply *> mReplys;
|
|
96 |
QList<int> mThumbnailRequests;
|
36
|
97 |
|
47
|
98 |
QDomDocument mDomDocument;
|
|
99 |
ThumbnailManager *mThumbnailManager; //owned
|
36
|
100 |
|
47
|
101 |
QString mArtist;
|
|
102 |
QString mAlbum;
|
|
103 |
QString mTitle;
|
|
104 |
QString mMusicStore;
|
|
105 |
QStringList mRecommendationAlbumArtsName;
|
36
|
106 |
|
47
|
107 |
QStringList mRecommendationSongs;
|
|
108 |
QStringList mRecommendationArtists;
|
|
109 |
QStringList mRecommendationAlbumArtsLink;
|
|
110 |
QMap<QString, HbIcon> mRecommendationAlbumArtsMap;
|
|
111 |
int mAlbumArtsReadyCount;
|
|
112 |
HbIcon mDefaultRecommendationAlbumArt;
|
36
|
113 |
|
47
|
114 |
enum RequestType { NoRequest, InspireMeItemsMetadataRequest, InspireMeItemsAlbumArtRequest, LocalStoreRequest };
|
|
115 |
RequestType mRequestType;
|
|
116 |
int mRecommendationCount;
|
36
|
117 |
|
35
|
118 |
};
|
|
119 |
#endif /* MPQUERYMANAGER_H_ */
|
47
|
120 |
|