16 */ |
16 */ |
17 #ifndef MPQUERYMANAGER_H_ |
17 #ifndef MPQUERYMANAGER_H_ |
18 #define MPQUERYMANAGER_H_ |
18 #define MPQUERYMANAGER_H_ |
19 |
19 |
20 #include <QPixmap> |
20 #include <QPixmap> |
|
21 #include <QPointer> |
21 #include <QNetworkReply> |
22 #include <QNetworkReply> |
22 #include <QDomDocument> |
23 #include <QDomDocument> |
23 #include <QMap> |
24 #include <QMap> |
24 |
25 |
25 #include "mpviewbase.h" |
26 #include "mpviewbase.h" |
26 |
27 |
27 class QNetworkAccessManager; |
28 class QNetworkAccessManager; |
|
29 class ThumbnailManager; |
28 |
30 |
29 /*! |
31 /*! |
30 MpQueryManager class is responsible for performing music player |
32 MpQueryManager class is responsible for performing music player |
31 related network queries, including retrieving the URL for the |
33 related network queries, including retrieving the URL for the |
32 music. |
34 music. |
39 Q_OBJECT |
41 Q_OBJECT |
40 |
42 |
41 public: |
43 public: |
42 MpQueryManager(); |
44 MpQueryManager(); |
43 ~MpQueryManager(); |
45 ~MpQueryManager(); |
44 |
46 |
45 public: |
47 public: |
46 void clearNetworkReplies(); |
48 void clearNetworkReplies(); |
47 void queryLocalMusicStore( QString mArtist,QString mAlbum,QString mTitle ); |
49 void queryLocalMusicStore( QString mArtist,QString mAlbum,QString mTitle ); |
48 void queryInspireMeItems( QString mArtist,QString mAlbum,QString mTitle ); |
50 void queryInspireMeItems( QString mArtist,QString mAlbum,QString mTitle ); |
49 void clearRecommendations(); |
51 void clearRecommendations(); |
50 |
52 |
51 QStringList recommendationSongs(); |
53 QStringList recommendationSongs(); |
52 QStringList recommendationArtists(); |
54 QStringList recommendationArtists(); |
53 QStringList recommendationAlbumArtsLink(); |
55 QStringList recommendationAlbumArtsLink(); |
54 QMap<QString, QPixmap> recommendationAlbumArtsMap(); |
56 QMap<QString, QPixmap> recommendationAlbumArtsMap(); |
55 int &albumArtsReadyCount(); |
57 void insertMapItem( const QString &uri, const QPixmap &pixmap ); |
56 |
|
57 void insertMapItem( const QString &uri, const QPixmap &pixmap ); |
|
58 |
58 |
59 private slots: |
59 private slots: |
60 void retrieveInformationFinished( QNetworkReply* reply ); |
60 void retrieveInformationFinished( QNetworkReply* reply ); |
61 void retrieveInformationNetworkError( QNetworkReply::NetworkError error ); |
61 void retrieveInformationNetworkError( QNetworkReply::NetworkError error ); |
62 void retrieveInformationSslErrors( const QList<QSslError> &error ); |
62 void retrieveInformationSslErrors( const QList<QSslError> &error ); |
63 void DownloadFinished( QNetworkReply* reply ); |
63 void DownloadFinished( QNetworkReply* reply ); |
64 |
64 void setAlbumArtUri( const QString &albumArtUri, const QString &albumArtName ); |
|
65 void thumbnailReady( const QPixmap& pixmap, void *data, int id, int error ); |
|
66 |
65 private: |
67 private: |
66 void constructRequest( QString &uri ); |
68 void constructRequest( QString &uri ); |
67 // retrieve URI from Ovi music server |
69 // retrieve URI from Ovi music server |
68 void retrieveInformation( const QString &urlEncoded ); |
70 void retrieveInformation( const QString &urlEncoded ); |
69 |
71 |
70 void composeAlbumCover( QPixmap albumart ); |
72 void composeAlbumCover( QPixmap albumart ); |
71 QString keyValues( QStringList keys, QStringList values ) const; |
73 QString keyValues( QStringList keys, QStringList values ) const; |
72 void handleParsedXML(); |
74 void handleParsedXML(); |
73 |
75 |
74 bool writeImageToFile( const QByteArray &aImageData, const QString &aImageFileName ); |
76 bool writeImageToFile( const QByteArray &aImageData, const QString &aImageFileName ); |
|
77 |
|
78 signals: |
|
79 void networkError(); |
|
80 void searchUrlRetrieved( const QString& url ); |
|
81 void recommendationAlbumArtsReady(); |
75 |
82 |
76 signals: |
83 private: |
77 void networkError(); |
84 |
78 void setAlbumArt( const QString &albumArtUri, const QString &albumArtName ); |
|
79 void searchUrlRetrieved( const QString& url ); |
|
80 |
|
81 private: |
|
82 |
|
83 QNetworkAccessManager *mManager; |
85 QNetworkAccessManager *mManager; |
84 QNetworkAccessManager *mDownloadManager; |
86 QNetworkAccessManager *mDownloadManager; |
85 |
87 |
86 int mDownloadedAlbumArts; |
88 int mDownloadedAlbumArts; |
87 |
89 |
88 QList<QNetworkReply *> mReplys; |
90 QList<QNetworkReply *> mReplys; |
89 |
91 |
90 QDomDocument mDomDocument; |
92 QDomDocument mDomDocument; |
91 |
93 ThumbnailManager *mThumbnailManager; //owned |
92 |
94 |
93 QString mArtist; |
95 QString mArtist; |
94 QString mAlbum; |
96 QString mAlbum; |
95 QString mTitle; |
97 QString mTitle; |
96 |
98 |
97 QStringList mRecommendationAlbumArtsName; |
99 QStringList mRecommendationAlbumArtsName; |
98 |
100 |
99 QStringList mRecommendationSongs; |
101 QStringList mRecommendationSongs; |
100 QStringList mRecommendationArtists; |
102 QStringList mRecommendationArtists; |
101 QStringList mRecommendationAlbumArtsLink; |
103 QStringList mRecommendationAlbumArtsLink; |
102 QMap<QString, QPixmap> mRecommendationAlbumArtsMap; |
104 QMap<QString, QPixmap> mRecommendationAlbumArtsMap; |
103 int mAlbumArtsReadyCount; |
105 int mAlbumArtsReadyCount; |
104 |
106 QPixmap mDefaultRecommendationAlbumArt; |
105 |
107 |
|
108 |
106 }; |
109 }; |
107 #endif /* MPQUERYMANAGER_H_ */ |
110 #endif /* MPQUERYMANAGER_H_ */ |