PageRenderTime 230ms CodeModel.GetById 100ms app.highlight 9ms RepoModel.GetById 119ms app.codeStats 0ms

/thirdparty/liblastfm2/src/types/Album.cpp

http://github.com/tomahawk-player/tomahawk
C++ | 87 lines | 58 code | 10 blank | 19 comment | 4 complexity | 5fd92f90bf52c506e44e8f504759f698 MD5 | raw file
 1/*
 2   Copyright 2009-2010 Last.fm Ltd.
 3      - Primarily authored by Max Howell, Jono Cole and Doug Mansell
 4
 5   This file is part of liblastfm.
 6
 7   liblastfm is free software: you can redistribute it and/or modify
 8   it under the terms of the GNU General Public License as published by
 9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   liblastfm is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with liblastfm.  If not, see <http://www.gnu.org/licenses/>.
19*/
20#include "Album.h"
21#include "Artist.h"
22#include "User.h"
23#include "../core/UrlBuilder.h"
24#include "../core/XmlQuery.h"
25#include "../ws/ws.h"
26#include <QFile>
27#include <QStringList>
28#include <QTimer>
29
30QNetworkReply*
31lastfm::Album::getInfo() const
32{
33    QMap<QString, QString> map;
34    map["method"] = "album.getInfo";
35    map["artist"] = m_artist;
36    map["album"] = m_title;
37    if (!lastfm::ws::Username.isEmpty()) map["username"] = lastfm::ws::Username;
38    if (!lastfm::ws::SessionKey.isEmpty()) map["sk"] = lastfm::ws::SessionKey;
39    return lastfm::ws::get(map);
40}
41
42
43QNetworkReply*
44lastfm::Album::getTags() const
45{
46    QMap<QString, QString> map;
47    map["method"] = "album.getTags";
48    map["artist"] = m_artist;
49    map["album"] = m_title;
50    return lastfm::ws::get(map);
51}
52
53
54QNetworkReply*
55lastfm::Album::share( const QStringList& recipients, const QString& message, bool isPublic ) const
56{
57    QMap<QString, QString> map;
58    map["method"] = "album.share";
59    map["artist"] = m_artist;
60    map["album"] = m_title;
61    map["recipient"] = recipients.join(",");
62    map["public"] = isPublic ? "1" : "0";
63    if (message.size()) map["message"] = message;
64    return lastfm::ws::post(map);
65}
66
67
68QUrl
69lastfm::Album::www() const
70{
71    return lastfm::UrlBuilder( "music" ).slash( m_artist ).slash( m_title ).url();
72}
73
74
75QNetworkReply*
76lastfm::Album::addTags( const QStringList& tags ) const
77{
78    if (tags.isEmpty())
79        return 0;
80
81    QMap<QString, QString> map;
82    map["method"] = "album.addTags";
83    map["artist"] = m_artist;
84    map["album"] = m_title;
85    map["tags"] = tags.join( QChar(',') );
86    return lastfm::ws::post(map);
87}