2012-03-06 01:35:55 +01:00
|
|
|
/***************************************************************************
|
|
|
|
* This file is part of libmygpo-qt *
|
|
|
|
* Copyright (c) 2010 - 2011 Stefan Derkits <stefan@derkits.at> *
|
|
|
|
* Copyright (c) 2010 - 2011 Christian Wagner <christian.wagner86@gmx.at> *
|
|
|
|
* Copyright (c) 2010 - 2011 Felix Winter <ixos01@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This library is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Lesser General Public *
|
|
|
|
* License as published by the Free Software Foundation; either *
|
|
|
|
* version 2.1 of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This library is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
|
|
|
* Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this library; if not, write to the Free Software *
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *
|
|
|
|
* USA *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "ApiRequest.h"
|
|
|
|
|
|
|
|
#include "ApiRequest_p.h"
|
|
|
|
|
|
|
|
#include "UrlBuilder.h"
|
|
|
|
#include "JsonCreator.h"
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QByteArray>
|
|
|
|
#include <QLatin1String>
|
|
|
|
|
|
|
|
using namespace mygpo;
|
|
|
|
|
|
|
|
ApiRequestPrivate::ApiRequestPrivate( const QString& username, const QString& password, QNetworkAccessManager* nam ) : m_requestHandler( username, password, nam )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ApiRequestPrivate::ApiRequestPrivate( QNetworkAccessManager* nam ) : m_requestHandler( nam )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequestPrivate::toplistOpml( uint count )
|
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getToplistUrl( count, UrlBuilder::OPML );
|
|
|
|
return m_requestHandler.getRequest( requestUrl );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequestPrivate::searchOpml( const QString& query )
|
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getPodcastSearchUrl( query, UrlBuilder::OPML );
|
|
|
|
return m_requestHandler.getRequest( requestUrl );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequestPrivate::suggestionsOpml( uint count )
|
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getSuggestionsUrl( count , UrlBuilder::OPML );
|
|
|
|
return m_requestHandler.authGetRequest( requestUrl );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequestPrivate::downloadSubscriptionsOpml( const QString& username, const QString& device )
|
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getSubscriptionsUrl( username, device, UrlBuilder::OPML );
|
|
|
|
return m_requestHandler.authGetRequest( requestUrl );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequestPrivate::toplistTxt( uint count )
|
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getToplistUrl( count, UrlBuilder::TEXT );
|
|
|
|
return m_requestHandler.getRequest( requestUrl );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequestPrivate::searchTxt( const QString& query )
|
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getPodcastSearchUrl( query, UrlBuilder::TEXT );
|
|
|
|
return m_requestHandler.getRequest( requestUrl );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequestPrivate::suggestionsTxt( uint count )
|
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getSuggestionsUrl( count , UrlBuilder::TEXT );
|
|
|
|
return m_requestHandler.authGetRequest( requestUrl );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequestPrivate::downloadSubscriptionsTxt(const QString& username, const QString& device)
|
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getSubscriptionsUrl( username, device, UrlBuilder::TEXT );
|
|
|
|
return m_requestHandler.authGetRequest( requestUrl );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequestPrivate::toplistXml ( uint count )
|
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getToplistUrl( count, UrlBuilder::XML );
|
|
|
|
return m_requestHandler.getRequest( requestUrl );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequestPrivate::searchXml( const QString& query )
|
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getPodcastSearchUrl( query, UrlBuilder::XML );
|
|
|
|
return m_requestHandler.getRequest( requestUrl );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastListPtr ApiRequestPrivate::toplist( uint count )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getToplistUrl( count );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.getRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastListPtr podcastList( new PodcastList( reply ) );
|
|
|
|
return podcastList;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastListPtr ApiRequestPrivate::search( const QString& query )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getPodcastSearchUrl( query );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.getRequest( requestUrl );
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastListPtr podcastList( new PodcastList( reply ) );
|
|
|
|
return podcastList;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastListPtr ApiRequestPrivate::suggestions( uint count )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getSuggestionsUrl( count );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastListPtr podcastList( new PodcastList( reply ) );
|
|
|
|
return podcastList;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequestPrivate::downloadSubscriptionsJson(const QString& username, const QString& device)
|
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getSubscriptionsUrl( username, device );
|
|
|
|
return m_requestHandler.authGetRequest( requestUrl );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodePtr ApiRequestPrivate::episodeData( const QUrl& podcasturl, const QUrl& episodeurl )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getEpisodeDataUrl( podcasturl.toString(), episodeurl.toString() );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.getRequest( requestUrl );
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodePtr episode( new Episode( reply ) );
|
|
|
|
return episode;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeListPtr ApiRequestPrivate::favoriteEpisodes( const QString& username )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getFavEpisodesUrl( username );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeListPtr episodeList( new EpisodeList( reply ) );
|
|
|
|
return episodeList;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastPtr ApiRequestPrivate::podcastData( const QUrl& podcasturl )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getPodcastDataUrl( podcasturl.toString() );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.getRequest( requestUrl );
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastPtr podcast( new Podcast( reply ) );
|
|
|
|
return podcast;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastListPtr ApiRequestPrivate::podcastsOfTag( uint count, const QString& tag )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getPodcastsOfTagUrl( tag, count );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.getRequest( requestUrl );
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastListPtr podcastList( new PodcastList( reply ) );
|
|
|
|
return podcastList;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
TagListPtr ApiRequestPrivate::topTags( uint count )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getTopTagsUrl( count );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.getRequest( requestUrl );
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
TagListPtr tagList( new TagList( reply ) );
|
|
|
|
return tagList;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
AddRemoveResultPtr ApiRequestPrivate::addRemoveSubscriptions( const QString& username, const QString& device, const QList< QUrl >& add, const QList< QUrl >& remove )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getAddRemoveSubUrl( username, device );
|
|
|
|
QByteArray data = JsonCreator::addRemoveSubsToJSON( add, remove );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.postRequest( data, requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
AddRemoveResultPtr addRemoveResult( new AddRemoveResult( reply ) );
|
|
|
|
return addRemoveResult;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequestPrivate::accountSettings( const QString& username )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getAccountSettingsUrl( username );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr settings( new Settings( reply ) );
|
|
|
|
return settings;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequestPrivate::deviceSettings( const QString& username, const QString& device )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getDeviceSettingsUrl( username, device );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr settings( new Settings( reply ) );
|
|
|
|
return settings;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequestPrivate::podcastSettings( const QString& username, const QString& podcastUrl )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getPodcastSettingsUrl( username, podcastUrl );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr settings( new Settings( reply ) );
|
|
|
|
return settings;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequestPrivate::episodeSettings( const QString& username, const QString& podcastUrl, const QString& episodeUrl )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getEpisodeSettingsUrl( username, podcastUrl, episodeUrl );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr settings( new Settings( reply ) );
|
|
|
|
return settings;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequestPrivate::setAccountSettings( const QString& username, QMap<QString, QVariant >& set, const QList< QString >& remove )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getAccountSettingsUrl( username );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
QByteArray postData = JsonCreator::saveSettingsToJSON( set, remove );
|
|
|
|
reply = m_requestHandler.postRequest( postData, requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr settings( new Settings( reply ) );
|
|
|
|
return settings;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequestPrivate::setDeviceSettings( const QString& username, const QString& device, QMap<QString, QVariant >& set, const QList< QString >& remove )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getDeviceSettingsUrl( username, device );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
QByteArray postData = JsonCreator::saveSettingsToJSON( set, remove );
|
|
|
|
reply = m_requestHandler.postRequest( postData, requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr settings( new Settings( reply ) );
|
|
|
|
return settings;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequestPrivate::setPodcastSettings( const QString& username, const QString& podcastUrl, QMap<QString, QVariant >& set, const QList< QString >& remove )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getPodcastSettingsUrl( username, podcastUrl );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
QByteArray postData = JsonCreator::saveSettingsToJSON( set, remove );
|
|
|
|
reply = m_requestHandler.postRequest( postData, requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr settings( new Settings( reply ) );
|
|
|
|
return settings;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequestPrivate::setEpisodeSettings( const QString& username, const QString& podcastUrl, const QString& episodeUrl, QMap<QString, QVariant >& set, const QList< QString >& remove )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getEpisodeSettingsUrl( username, podcastUrl, episodeUrl );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
QByteArray postData = JsonCreator::saveSettingsToJSON( set, remove );
|
|
|
|
reply = m_requestHandler.postRequest( postData, requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr settings( new Settings( reply ) );
|
|
|
|
return settings;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
DeviceUpdatesPtr ApiRequestPrivate::deviceUpdates( const QString& username, const QString& deviceId, qlonglong timestamp )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getDeviceUpdatesUrl( username, deviceId, timestamp );
|
|
|
|
QNetworkReply* reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
DeviceUpdatesPtr updates( new DeviceUpdates( reply ) );
|
|
|
|
return updates;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr ApiRequestPrivate::episodeActions( const QString& username, const bool aggregated )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getEpisodeActionsUrl( username, aggregated );
|
|
|
|
QNetworkReply* reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr episodeActions( new EpisodeActionList( reply ) );
|
|
|
|
return episodeActions;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr ApiRequestPrivate::episodeActionsByPodcast( const QString& username, const QString& podcastUrl, const bool aggregated )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getEpisodeActionsUrlByPodcast( username, podcastUrl, aggregated );
|
|
|
|
QNetworkReply* reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr episodeActions( new EpisodeActionList( reply ) );
|
|
|
|
return episodeActions;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr ApiRequestPrivate::episodeActionsByDevice( const QString& username, const QString& deviceId, const bool aggregated )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getEpisodeActionsUrlByDevice( username, deviceId, aggregated );
|
|
|
|
QNetworkReply* reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr episodeActions( new EpisodeActionList( reply ) );
|
|
|
|
return episodeActions;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr ApiRequestPrivate::episodeActionsByTimestamp( const QString& username, const qulonglong since )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getEpisodeActionsUrlByTimestamp( username, since );
|
|
|
|
QNetworkReply* reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr episodeActions( new EpisodeActionList( reply ) );
|
|
|
|
return episodeActions;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr ApiRequestPrivate::episodeActionsByPodcastAndTimestamp( const QString& username, const QString& podcastUrl, const qulonglong since )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getEpisodeActionsUrlByPodcastAndTimestamp( username, podcastUrl, since );
|
|
|
|
QNetworkReply* reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr episodeActions( new EpisodeActionList( reply ) );
|
|
|
|
return episodeActions;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr ApiRequestPrivate::episodeActionsByDeviceAndTimestamp( const QString& username, const QString& deviceId, const qulonglong since )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getEpisodeActionsUrlByDeviceAndTimestamp( username, deviceId, since );
|
|
|
|
QNetworkReply* reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr episodeActions( new EpisodeActionList( reply ) );
|
|
|
|
return episodeActions;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
AddRemoveResultPtr ApiRequestPrivate::uploadEpisodeActions( const QString& username, const QList<EpisodeActionPtr>& episodeActions )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getEpisodeActionsUrl( username, false );
|
|
|
|
QNetworkReply *reply;
|
|
|
|
QByteArray postData = JsonCreator::episodeActionListToJSON( episodeActions );
|
|
|
|
reply = m_requestHandler.postRequest( postData, requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
AddRemoveResultPtr addRemoveResult( new AddRemoveResult( reply ) );
|
|
|
|
return addRemoveResult;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequestPrivate::renameDevice( const QString& username , const QString& deviceId , const QString& caption, Device::Type type )
|
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getRenameDeviceUrl( username, deviceId );
|
|
|
|
QNetworkReply* reply;
|
|
|
|
QByteArray data;
|
|
|
|
switch( type )
|
|
|
|
{
|
|
|
|
case Device::DESKTOP:
|
|
|
|
data = JsonCreator::renameDeviceStringToJSON( caption, QLatin1String( "desktop" ) );
|
|
|
|
break;
|
|
|
|
case Device::LAPTOP:
|
|
|
|
data = JsonCreator::renameDeviceStringToJSON( caption, QLatin1String( "laptop" ) );
|
|
|
|
break;
|
|
|
|
case Device::MOBILE:
|
|
|
|
data = JsonCreator::renameDeviceStringToJSON( caption, QLatin1String( "mobile" ) );
|
|
|
|
break;
|
|
|
|
case Device::SERVER:
|
|
|
|
data = JsonCreator::renameDeviceStringToJSON( caption, QLatin1String( "server" ) );
|
|
|
|
break;
|
|
|
|
case Device::OTHER:
|
|
|
|
data = JsonCreator::renameDeviceStringToJSON( caption, QLatin1String( "other" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
reply = m_requestHandler.postRequest( data, requestUrl );
|
|
|
|
return reply;
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
DeviceListPtr ApiRequestPrivate::listDevices( const QString& username )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getDeviceListUrl( username );
|
|
|
|
QNetworkReply* reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
DeviceListPtr list( new DeviceList( reply ) );
|
|
|
|
return list;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
DeviceSyncResultPtr ApiRequestPrivate::deviceSynchronizationStatus ( const QString& username )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
QString requestUrl = UrlBuilder::getDeviceSynchronizationStatusUrl( username );
|
|
|
|
QNetworkReply* reply;
|
|
|
|
reply = m_requestHandler.authGetRequest( requestUrl );
|
2012-03-19 20:35:59 +01:00
|
|
|
DeviceSyncResultPtr result( new DeviceSyncResult( reply ) );
|
|
|
|
return result;
|
2012-03-06 01:35:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ApiRequest::ApiRequest( const QString& username, const QString& password, QNetworkAccessManager* nam ) : d( new ApiRequestPrivate( username, password, nam ) )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ApiRequest::ApiRequest( QNetworkAccessManager* nam ) : d( new ApiRequestPrivate( nam ) )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ApiRequest::~ApiRequest()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequest::toplistOpml( uint count )
|
|
|
|
{
|
|
|
|
return d->toplistOpml( count );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequest::searchOpml( const QString& query )
|
|
|
|
{
|
|
|
|
return d->searchOpml( query );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequest::suggestionsOpml( uint count )
|
|
|
|
{
|
|
|
|
return d->suggestionsOpml( count );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequest::downloadSubscriptionsOpml( const QString& username, const QString& device )
|
|
|
|
{
|
|
|
|
return d->downloadSubscriptionsOpml( username, device );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequest::toplistTxt( uint count )
|
|
|
|
{
|
|
|
|
return d->toplistTxt( count );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequest::searchTxt( const QString& query )
|
|
|
|
{
|
|
|
|
return d->searchTxt( query );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequest::suggestionsTxt( uint count )
|
|
|
|
{
|
|
|
|
return d->suggestionsTxt( count );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequest::downloadSubscriptionsTxt(const QString& username, const QString& device)
|
|
|
|
{
|
|
|
|
return d->downloadSubscriptionsTxt( username, device );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequest::toplistXml ( uint count )
|
|
|
|
{
|
|
|
|
return d->toplistXml( count );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequest::searchXml ( const QString& query )
|
|
|
|
{
|
|
|
|
return d->searchXml( query );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastListPtr ApiRequest::toplist( uint count )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->toplist( count );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastListPtr ApiRequest::search( const QString& query )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->search( query );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastListPtr ApiRequest::suggestions( uint count )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->suggestions( count );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequest::downloadSubscriptionsJson(const QString& username, const QString& device)
|
|
|
|
{
|
|
|
|
return d->downloadSubscriptionsJson( username, device );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastListPtr ApiRequest::podcastsOfTag( uint count, const QString& tag )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->podcastsOfTag( count, tag );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
PodcastPtr ApiRequest::podcastData( const QUrl& podcasturl )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->podcastData( podcasturl );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodePtr ApiRequest::episodeData( const QUrl& podcasturl, const QUrl& episodeurl )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->episodeData( podcasturl, episodeurl );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeListPtr ApiRequest::favoriteEpisodes( const QString& username )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->favoriteEpisodes( username );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
TagListPtr ApiRequest::topTags( uint count )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->topTags( count );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
AddRemoveResultPtr ApiRequest::addRemoveSubscriptions( const QString& username, const QString& device, const QList< QUrl >& add, const QList< QUrl >& remove )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->addRemoveSubscriptions( username, device, add, remove );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequest::accountSettings( const QString& username )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->accountSettings( username );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequest::deviceSettings( const QString& username, const QString& device )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->deviceSettings( username, device );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequest::podcastSettings( const QString& username, const QString& podcastUrl )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->podcastSettings( username, podcastUrl );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequest::episodeSettings( const QString& username, const QString& podcastUrl, const QString& episodeUrl )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->episodeSettings( username, podcastUrl, episodeUrl );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequest::setAccountSettings( const QString& username, QMap<QString, QVariant >& set, const QList< QString >& remove )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->setAccountSettings( username, set, remove );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequest::setDeviceSettings( const QString& username, const QString& device, QMap<QString, QVariant >& set, const QList< QString >& remove )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->setDeviceSettings( username, device, set, remove );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequest::setPodcastSettings( const QString& username, const QString& podcastUrl, QMap<QString, QVariant >& set, const QList< QString >& remove )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->setPodcastSettings( username, podcastUrl, set, remove );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
SettingsPtr ApiRequest::setEpisodeSettings( const QString& username, const QString& podcastUrl, const QString& episodeUrl, QMap<QString, QVariant >& set, const QList< QString >& remove )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->setEpisodeSettings( username, podcastUrl, episodeUrl, set, remove );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
DeviceUpdatesPtr ApiRequest::deviceUpdates( const QString& username, const QString& deviceId, qlonglong timestamp )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->deviceUpdates( username, deviceId, timestamp );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr ApiRequest::episodeActions( const QString& username, const bool aggregated )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->episodeActions( username, aggregated );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr ApiRequest::episodeActionsByPodcast( const QString& username, const QString& podcastUrl, const bool aggregated )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->episodeActionsByPodcast( username, podcastUrl, aggregated );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr ApiRequest::episodeActionsByDevice( const QString& username, const QString& deviceId, const bool aggregated )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->episodeActionsByDevice( username, deviceId, aggregated );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr ApiRequest::episodeActionsByTimestamp( const QString& username, const qulonglong since )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->episodeActionsByTimestamp( username, since );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr ApiRequest::episodeActionsByPodcastAndTimestamp( const QString& username, const QString& podcastUrl, const qulonglong since )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->episodeActionsByPodcastAndTimestamp( username, podcastUrl, since );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
EpisodeActionListPtr ApiRequest::episodeActionsByDeviceAndTimestamp( const QString& username, const QString& deviceId, const qulonglong since )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->episodeActionsByDeviceAndTimestamp( username, deviceId, since );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
AddRemoveResultPtr ApiRequest::uploadEpisodeActions( const QString& username, const QList<EpisodeActionPtr>& episodeActions )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->uploadEpisodeActions( username, episodeActions );
|
|
|
|
}
|
|
|
|
|
|
|
|
QNetworkReply* ApiRequest::renameDevice( const QString& username , const QString& deviceId, const QString& caption, Device::Type type )
|
|
|
|
{
|
|
|
|
return d->renameDevice( username, deviceId, caption, type );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
DeviceListPtr ApiRequest::listDevices( const QString& username )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->listDevices( username );
|
|
|
|
}
|
|
|
|
|
2012-03-19 20:35:59 +01:00
|
|
|
DeviceSyncResultPtr ApiRequest::deviceSynchronizationStatus ( const QString& username )
|
2012-03-06 01:35:55 +01:00
|
|
|
{
|
|
|
|
return d->deviceSynchronizationStatus( username );
|
|
|
|
}
|