Get the most popular top-level tags from gpodder.net

This commit is contained in:
David Sansome 2012-03-06 00:35:55 +00:00
parent c91acdb3f1
commit e54a2ff5c5
66 changed files with 6099 additions and 0 deletions

138
3rdparty/libmygpo-qt/AddRemoveResult.cpp vendored Normal file
View File

@ -0,0 +1,138 @@
/***************************************************************************
* 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 <qjson/parser.h>
#include "AddRemoveResult.h"
#include "AddRemoveResult_p.h"
using namespace mygpo;
AddRemoveResultPrivate::AddRemoveResultPrivate( AddRemoveResult* qq, QNetworkReply* reply ) : q( qq ), m_reply( reply ), m_error( QNetworkReply::NoError )
{
QObject::connect( m_reply, SIGNAL( finished() ), this, SLOT( parseData() ) );
QObject::connect( m_reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( error( QNetworkReply::NetworkError ) ) );
}
AddRemoveResultPrivate::~AddRemoveResultPrivate()
{
}
qulonglong AddRemoveResultPrivate::timestamp() const
{
return m_timestamp;
}
QVariant AddRemoveResultPrivate::updateUrls() const
{
return m_updateUrls;
}
QList< QPair< QUrl, QUrl > > AddRemoveResultPrivate::updateUrlsList() const
{
QVariantList updateVarList = updateUrls().toList();
QList<QPair<QUrl, QUrl > > updateUrls;
foreach( const QVariant & url, updateVarList )
{
QVariantList urlList = url.toList();
QUrl first = QUrl( urlList.at( 0 ).toString() );
QUrl second = QUrl( urlList.at( 1 ).toString() );
updateUrls.append( qMakePair( first, second ) );
}
return updateUrls;
}
bool AddRemoveResultPrivate::parse( const QVariant& data )
{
QJson::Parser parser;
if( !data.canConvert( QVariant::Map ) )
return false;
QVariantMap resultMap = data.toMap();
QVariant v = resultMap.value( QLatin1String( "timestamp" ) );
if( !v.canConvert( QVariant::ULongLong ) )
return false;
m_timestamp = v.toULongLong();
m_updateUrls = resultMap.value( QLatin1String( "update_urls" ) );
return true;
}
bool AddRemoveResultPrivate::parse( const QByteArray& data )
{
QJson::Parser parser;
bool ok;
QVariant variant = parser.parse( data, &ok );
if( ok )
{
ok = ( parse( variant ) );
}
return ok;
}
void AddRemoveResultPrivate::parseData()
{
if( m_reply->error() == QNetworkReply::NoError )
{
if( parse( m_reply->readAll( ) ) )
{
emit q->finished();
}
else
{
emit q->parseError();
}
}
m_reply->deleteLater();
}
void AddRemoveResultPrivate::error( QNetworkReply::NetworkError error )
{
this->m_error = error;
emit q->requestError( error );
}
AddRemoveResult::AddRemoveResult( QNetworkReply* reply , QObject* parent ) : QObject( parent ), d( new AddRemoveResultPrivate( this, reply ) )
{
}
AddRemoveResult::~AddRemoveResult()
{
delete d;
}
QVariant AddRemoveResult::updateUrls() const
{
return d->updateUrls();
}
qulonglong AddRemoveResult::timestamp() const
{
return d->timestamp();
}
QList<QPair<QUrl, QUrl> > AddRemoveResult::updateUrlsList() const
{
return d->updateUrlsList();
}

70
3rdparty/libmygpo-qt/AddRemoveResult.h vendored Normal file
View File

@ -0,0 +1,70 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef ADDREMOVERESULT_H
#define ADDREMOVERESULT_H
#include <QList>
#include <QVariant>
#include <QNetworkReply>
#include <QSharedPointer>
class QUrl;
#include "mygpo_export.h"
namespace mygpo
{
class AddRemoveResultPrivate;
class MYGPO_EXPORT AddRemoveResult : public QObject
{
Q_OBJECT
Q_PROPERTY( qulonglong timestamp READ timestamp CONSTANT )
Q_PROPERTY( QVariant updateUrls READ updateUrls CONSTANT )
public:
AddRemoveResult( QNetworkReply* reply , QObject* parent = 0 );
virtual ~AddRemoveResult();
QVariant updateUrls() const;
qulonglong timestamp() const;
QList<QPair<QUrl, QUrl> > updateUrlsList() const;
private:
Q_DISABLE_COPY( AddRemoveResult )
AddRemoveResultPrivate* const d;
friend class AddRemoveResultPrivate;
signals:
/**Gets emitted when the data is ready to read*/
void finished();
/**Gets emitted when an parse error ocurred*/
void parseError();
/**Gets emitted when an request error ocurred*/
void requestError( QNetworkReply::NetworkError error );
};
typedef QSharedPointer<AddRemoveResult> AddRemoveResultPtr;
}
Q_DECLARE_METATYPE( mygpo::AddRemoveResultPtr );
#endif // ADDREMOVERESULT_H

View File

@ -0,0 +1,59 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef ADDREMOVERESULT_PRIVATE_H
#define ADDREMOVERESULT_PRIVATE_H
#include "AddRemoveResult.h"
#include <QUrl>
namespace mygpo
{
class AddRemoveResultPrivate : public QObject
{
Q_OBJECT
public:
AddRemoveResultPrivate( AddRemoveResult* qq, QNetworkReply* reply );
virtual ~AddRemoveResultPrivate( );
QVariant updateUrls() const;
qulonglong timestamp() const;
QList<QPair<QUrl, QUrl> > updateUrlsList() const;
private:
AddRemoveResult* const q;
qulonglong m_timestamp;
QVariant m_updateUrls;
QNetworkReply* m_reply;
QNetworkReply::NetworkError m_error;
bool parse( const QVariant& data );
bool parse( const QByteArray& data );
private slots:
void parseData();
void error( QNetworkReply::NetworkError error );
};
}
#endif //ADDREMOVERESULT_PRIVATE_H

573
3rdparty/libmygpo-qt/ApiRequest.cpp vendored Normal file
View File

@ -0,0 +1,573 @@
/***************************************************************************
* 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 );
}
PodcastList* ApiRequestPrivate::toplist( uint count )
{
QString requestUrl = UrlBuilder::getToplistUrl( count );
QNetworkReply *reply;
reply = m_requestHandler.getRequest( requestUrl );
return new PodcastList( reply );
}
PodcastList* ApiRequestPrivate::search( const QString& query )
{
QString requestUrl = UrlBuilder::getPodcastSearchUrl( query );
QNetworkReply *reply;
reply = m_requestHandler.getRequest( requestUrl );
return new PodcastList( reply );
}
PodcastList* ApiRequestPrivate::suggestions( uint count )
{
QString requestUrl = UrlBuilder::getSuggestionsUrl( count );
QNetworkReply *reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new PodcastList( reply );
}
QNetworkReply* ApiRequestPrivate::downloadSubscriptionsJson(const QString& username, const QString& device)
{
QString requestUrl = UrlBuilder::getSubscriptionsUrl( username, device );
return m_requestHandler.authGetRequest( requestUrl );
}
Episode* ApiRequestPrivate::episodeData( const QUrl& podcasturl, const QUrl& episodeurl )
{
QString requestUrl = UrlBuilder::getEpisodeDataUrl( podcasturl.toString(), episodeurl.toString() );
QNetworkReply *reply;
reply = m_requestHandler.getRequest( requestUrl );
return new Episode( reply );
}
EpisodeList* ApiRequestPrivate::favoriteEpisodes( const QString& username )
{
QString requestUrl = UrlBuilder::getFavEpisodesUrl( username );
QNetworkReply *reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new EpisodeList( reply );
}
Podcast* ApiRequestPrivate::podcastData( const QUrl& podcasturl )
{
QString requestUrl = UrlBuilder::getPodcastDataUrl( podcasturl.toString() );
QNetworkReply *reply;
reply = m_requestHandler.getRequest( requestUrl );
return new Podcast( reply );
}
PodcastList* ApiRequestPrivate::podcastsOfTag( uint count, const QString& tag )
{
QString requestUrl = UrlBuilder::getPodcastsOfTagUrl( tag, count );
QNetworkReply *reply;
reply = m_requestHandler.getRequest( requestUrl );
return new PodcastList( reply );
}
TagList* ApiRequestPrivate::topTags( uint count )
{
QString requestUrl = UrlBuilder::getTopTagsUrl( count );
QNetworkReply *reply;
reply = m_requestHandler.getRequest( requestUrl );
return new TagList( reply );
}
AddRemoveResult* ApiRequestPrivate::addRemoveSubscriptions( const QString& username, const QString& device, const QList< QUrl >& add, const QList< QUrl >& remove )
{
QString requestUrl = UrlBuilder::getAddRemoveSubUrl( username, device );
QByteArray data = JsonCreator::addRemoveSubsToJSON( add, remove );
QNetworkReply *reply;
reply = m_requestHandler.postRequest( data, requestUrl );
return new AddRemoveResult( reply );
}
Settings* ApiRequestPrivate::accountSettings( const QString& username )
{
QString requestUrl = UrlBuilder::getAccountSettingsUrl( username );
QNetworkReply *reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new Settings( reply );
}
Settings* ApiRequestPrivate::deviceSettings( const QString& username, const QString& device )
{
QString requestUrl = UrlBuilder::getDeviceSettingsUrl( username, device );
QNetworkReply *reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new Settings( reply );
}
Settings* ApiRequestPrivate::podcastSettings( const QString& username, const QString& podcastUrl )
{
QString requestUrl = UrlBuilder::getPodcastSettingsUrl( username, podcastUrl );
QNetworkReply *reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new Settings( reply );
}
Settings* ApiRequestPrivate::episodeSettings( const QString& username, const QString& podcastUrl, const QString& episodeUrl )
{
QString requestUrl = UrlBuilder::getEpisodeSettingsUrl( username, podcastUrl, episodeUrl );
QNetworkReply *reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new Settings( reply );
}
Settings* ApiRequestPrivate::setAccountSettings( const QString& username, QMap<QString, QVariant >& set, const QList< QString >& remove )
{
QString requestUrl = UrlBuilder::getAccountSettingsUrl( username );
QNetworkReply *reply;
QByteArray postData = JsonCreator::saveSettingsToJSON( set, remove );
reply = m_requestHandler.postRequest( postData, requestUrl );
return new Settings( reply );
}
Settings* ApiRequestPrivate::setDeviceSettings( const QString& username, const QString& device, QMap<QString, QVariant >& set, const QList< QString >& remove )
{
QString requestUrl = UrlBuilder::getDeviceSettingsUrl( username, device );
QNetworkReply *reply;
QByteArray postData = JsonCreator::saveSettingsToJSON( set, remove );
reply = m_requestHandler.postRequest( postData, requestUrl );
return new Settings( reply );
}
Settings* ApiRequestPrivate::setPodcastSettings( const QString& username, const QString& podcastUrl, QMap<QString, QVariant >& set, const QList< QString >& remove )
{
QString requestUrl = UrlBuilder::getPodcastSettingsUrl( username, podcastUrl );
QNetworkReply *reply;
QByteArray postData = JsonCreator::saveSettingsToJSON( set, remove );
reply = m_requestHandler.postRequest( postData, requestUrl );
return new Settings( reply );
}
Settings* ApiRequestPrivate::setEpisodeSettings( const QString& username, const QString& podcastUrl, const QString& episodeUrl, QMap<QString, QVariant >& set, const QList< QString >& remove )
{
QString requestUrl = UrlBuilder::getEpisodeSettingsUrl( username, podcastUrl, episodeUrl );
QNetworkReply *reply;
QByteArray postData = JsonCreator::saveSettingsToJSON( set, remove );
reply = m_requestHandler.postRequest( postData, requestUrl );
return new Settings( reply );
}
DeviceUpdates* ApiRequestPrivate::deviceUpdates( const QString& username, const QString& deviceId, qlonglong timestamp )
{
QString requestUrl = UrlBuilder::getDeviceUpdatesUrl( username, deviceId, timestamp );
QNetworkReply* reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new DeviceUpdates( reply );
}
EpisodeActionList* ApiRequestPrivate::episodeActions( const QString& username, const bool aggregated )
{
QString requestUrl = UrlBuilder::getEpisodeActionsUrl( username, aggregated );
QNetworkReply* reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new EpisodeActionList( reply );
}
EpisodeActionList* ApiRequestPrivate::episodeActionsByPodcast( const QString& username, const QString& podcastUrl, const bool aggregated )
{
QString requestUrl = UrlBuilder::getEpisodeActionsUrlByPodcast( username, podcastUrl, aggregated );
QNetworkReply* reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new EpisodeActionList( reply );
}
EpisodeActionList* ApiRequestPrivate::episodeActionsByDevice( const QString& username, const QString& deviceId, const bool aggregated )
{
QString requestUrl = UrlBuilder::getEpisodeActionsUrlByDevice( username, deviceId, aggregated );
QNetworkReply* reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new EpisodeActionList( reply );
}
EpisodeActionList* ApiRequestPrivate::episodeActionsByTimestamp( const QString& username, const qulonglong since )
{
QString requestUrl = UrlBuilder::getEpisodeActionsUrlByTimestamp( username, since );
QNetworkReply* reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new EpisodeActionList( reply );
}
EpisodeActionList* ApiRequestPrivate::episodeActionsByPodcastAndTimestamp( const QString& username, const QString& podcastUrl, const qulonglong since )
{
QString requestUrl = UrlBuilder::getEpisodeActionsUrlByPodcastAndTimestamp( username, podcastUrl, since );
QNetworkReply* reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new EpisodeActionList( reply );
}
EpisodeActionList* ApiRequestPrivate::episodeActionsByDeviceAndTimestamp( const QString& username, const QString& deviceId, const qulonglong since )
{
QString requestUrl = UrlBuilder::getEpisodeActionsUrlByDeviceAndTimestamp( username, deviceId, since );
QNetworkReply* reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new EpisodeActionList( reply );
}
AddRemoveResult* ApiRequestPrivate::uploadEpisodeActions( const QString& username, const QList<EpisodeActionPtr>& episodeActions )
{
QString requestUrl = UrlBuilder::getEpisodeActionsUrl( username, false );
QNetworkReply *reply;
QByteArray postData = JsonCreator::episodeActionListToJSON( episodeActions );
reply = m_requestHandler.postRequest( postData, requestUrl );
return new AddRemoveResult( reply );
}
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;
}
DeviceList* ApiRequestPrivate::listDevices( const QString& username )
{
QString requestUrl = UrlBuilder::getDeviceListUrl( username );
QNetworkReply* reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new DeviceList( reply );
}
DeviceSyncResult* ApiRequestPrivate::deviceSynchronizationStatus ( const QString& username )
{
QString requestUrl = UrlBuilder::getDeviceSynchronizationStatusUrl( username );
QNetworkReply* reply;
reply = m_requestHandler.authGetRequest( requestUrl );
return new DeviceSyncResult( reply );
}
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 );
}
PodcastList* ApiRequest::toplist( uint count )
{
return d->toplist( count );
}
PodcastList* ApiRequest::search( const QString& query )
{
return d->search( query );
}
PodcastList* ApiRequest::suggestions( uint count )
{
return d->suggestions( count );
}
QNetworkReply* ApiRequest::downloadSubscriptionsJson(const QString& username, const QString& device)
{
return d->downloadSubscriptionsJson( username, device );
}
PodcastList* ApiRequest::podcastsOfTag( uint count, const QString& tag )
{
return d->podcastsOfTag( count, tag );
}
Podcast* ApiRequest::podcastData( const QUrl& podcasturl )
{
return d->podcastData( podcasturl );
}
Episode* ApiRequest::episodeData( const QUrl& podcasturl, const QUrl& episodeurl )
{
return d->episodeData( podcasturl, episodeurl );
}
EpisodeList* ApiRequest::favoriteEpisodes( const QString& username )
{
return d->favoriteEpisodes( username );
}
TagList* ApiRequest::topTags( uint count )
{
return d->topTags( count );
}
AddRemoveResult* ApiRequest::addRemoveSubscriptions( const QString& username, const QString& device, const QList< QUrl >& add, const QList< QUrl >& remove )
{
return d->addRemoveSubscriptions( username, device, add, remove );
}
Settings* ApiRequest::accountSettings( const QString& username )
{
return d->accountSettings( username );
}
Settings* ApiRequest::deviceSettings( const QString& username, const QString& device )
{
return d->deviceSettings( username, device );
}
Settings* ApiRequest::podcastSettings( const QString& username, const QString& podcastUrl )
{
return d->podcastSettings( username, podcastUrl );
}
Settings* ApiRequest::episodeSettings( const QString& username, const QString& podcastUrl, const QString& episodeUrl )
{
return d->episodeSettings( username, podcastUrl, episodeUrl );
}
Settings* ApiRequest::setAccountSettings( const QString& username, QMap<QString, QVariant >& set, const QList< QString >& remove )
{
return d->setAccountSettings( username, set, remove );
}
Settings* ApiRequest::setDeviceSettings( const QString& username, const QString& device, QMap<QString, QVariant >& set, const QList< QString >& remove )
{
return d->setDeviceSettings( username, device, set, remove );
}
Settings* ApiRequest::setPodcastSettings( const QString& username, const QString& podcastUrl, QMap<QString, QVariant >& set, const QList< QString >& remove )
{
return d->setPodcastSettings( username, podcastUrl, set, remove );
}
Settings* ApiRequest::setEpisodeSettings( const QString& username, const QString& podcastUrl, const QString& episodeUrl, QMap<QString, QVariant >& set, const QList< QString >& remove )
{
return d->setEpisodeSettings( username, podcastUrl, episodeUrl, set, remove );
}
DeviceUpdates* ApiRequest::deviceUpdates( const QString& username, const QString& deviceId, qlonglong timestamp )
{
return d->deviceUpdates( username, deviceId, timestamp );
}
EpisodeActionList* ApiRequest::episodeActions( const QString& username, const bool aggregated )
{
return d->episodeActions( username, aggregated );
}
EpisodeActionList* ApiRequest::episodeActionsByPodcast( const QString& username, const QString& podcastUrl, const bool aggregated )
{
return d->episodeActionsByPodcast( username, podcastUrl, aggregated );
}
EpisodeActionList* ApiRequest::episodeActionsByDevice( const QString& username, const QString& deviceId, const bool aggregated )
{
return d->episodeActionsByDevice( username, deviceId, aggregated );
}
EpisodeActionList* ApiRequest::episodeActionsByTimestamp( const QString& username, const qulonglong since )
{
return d->episodeActionsByTimestamp( username, since );
}
EpisodeActionList* ApiRequest::episodeActionsByPodcastAndTimestamp( const QString& username, const QString& podcastUrl, const qulonglong since )
{
return d->episodeActionsByPodcastAndTimestamp( username, podcastUrl, since );
}
EpisodeActionList* ApiRequest::episodeActionsByDeviceAndTimestamp( const QString& username, const QString& deviceId, const qulonglong since )
{
return d->episodeActionsByDeviceAndTimestamp( username, deviceId, since );
}
AddRemoveResult* ApiRequest::uploadEpisodeActions( const QString& username, const QList<EpisodeActionPtr>& episodeActions )
{
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 );
}
DeviceList* ApiRequest::listDevices( const QString& username )
{
return d->listDevices( username );
}
DeviceSyncResult* ApiRequest::deviceSynchronizationStatus ( const QString& username )
{
return d->deviceSynchronizationStatus( username );
}

404
3rdparty/libmygpo-qt/ApiRequest.h vendored Normal file
View File

@ -0,0 +1,404 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef APIREQUEST_H
#define APIREQUEST_H
#define MYGPO_MAJOR_VERSION 1
#define MYGPO_MINOR_VERSION 0
#define MYGPO_PATCH_VERSION 5
#include "mygpo_export.h"
#include "AddRemoveResult.h"
#include "EpisodeList.h"
#include "EpisodeActionList.h"
#include "PodcastList.h"
#include "TagList.h"
#include "Settings.h"
#include "DeviceUpdates.h"
#include "DeviceList.h"
#include "DeviceSyncResult.h"
class QByteArray;
class QString;
namespace mygpo
{
class ApiRequestPrivate;
/**
* This Class is the Frontend of libmygpo-qt.
* Methods from this Class map the Web API of gpodder.net
* and return the Results of the Requests.
* Web API Documentation can be found here: http://wiki.gpodder.org/wiki/Web_Services/API_2
*/
class MYGPO_EXPORT ApiRequest
{
public:
ApiRequest( const QString& username, const QString& password, QNetworkAccessManager* nam );
ApiRequest( QNetworkAccessManager* nam );
~ApiRequest( );
//SIMPLE API
/**
* Returns the OPML Result for the Simple API Call "Downloading Podcast Toplists"
* @param count The number of Podcasts that should be returned - will be set to to 100 if > 100 or < 1
* @return A Pointer to a QNetworkReply which receives network signals and will contain the data
*
*/
QNetworkReply* toplistOpml( uint count );
/**
* Returns the OPML Result for the Simple API Call "Searching for Podcasts"
* @param query The String you want to search for
* @return A Pointer to a QNetworkReply which receives network signals and will contain the data
*
*/
QNetworkReply* searchOpml( const QString& query );
/**
* Returns the OPML Result for the Simple API Call "Downloading podcast suggestions"
* Requires Authentication
* @param count The maximum number of Podcasts that should be returned - will be set to to 100 if > 100 or < 1
* @return A Pointer to a QNetworkReply which receives network signals and will contain the data
*
*/
QNetworkReply* suggestionsOpml( uint count );
QNetworkReply* downloadSubscriptionsOpml( const QString& username, const QString& device );
/**
* Returns the TXT Result for the Simple API Call "Downloading Podcast Toplists"
* @param count The number of Podcasts that should be returned - will be set to to 100 if > 100 or < 1
* @return A Pointer to a QNetworkReply which receives network signals and will contain the data
*
*/
QNetworkReply* toplistTxt( uint count );
/**
* Returns the TXT Result for the Simple API Call "Searching for Podcasts"
* @param query The String you want to search for
* @return A Pointer to a QNetworkReply which receives network signals and will contain the data
*
*/
QNetworkReply* searchTxt( const QString& query );
/**
* Returns the TXT Result for the Simple API Call "Downloading podcast suggestions"
* Requires Authentication
* @param count The maximum number of Podcasts that should be returned - will be set to to 100 if > 100 or < 1
* @return A Pointer to a QNetworkReply which receives network signals and will contain the data
*
*/
QNetworkReply* suggestionsTxt( uint count );
QNetworkReply* downloadSubscriptionsTxt( const QString& username, const QString& device );
/**
* Returns the TXT Result for the Simple API Call "Downloading Podcast Toplists"
* @param count The number of Podcasts that should be returned - will be set to to 100 if > 100 or < 1
* @return A Pointer to a QNetworkReply which receives network signals and will contain the data
*
*/
QNetworkReply* toplistXml( uint count );
/**
* Returns the XML Result for the Simple API Call "Searching for Podcasts"
* @param query The String you want to search for
* @return A Pointer to a QNetworkReply which receives network signals and will contain the data
*
*/
QNetworkReply* searchXml( const QString& query );
/**
* Returns the Result for the Simple API Call "Downloading Podcast Toplists"
* @param count The number of Podcasts that should be returned - will be set to to 100 if > 100 or < 1
* @return List of Podcast Objects containing the Data from gPodder
*
*/
PodcastList* toplist( uint count );
/**
* Returns the Result for the Simple API Call "Searching for Podcasts"
* @param query The String you want to search for
* @return List of Podcast Objects containing the Data from gPodder
*
*/
PodcastList* search( const QString& query );
/**
* Returns the Result for the Simple API Call "Downloading podcast suggestions"
* Requires Authentication
* @param count The maximum number of Podcasts that should be returned - will be set to to 100 if > 100 or < 1
* @return List of Podcast Objects containing the Data from gPodder
*
*/
PodcastList* suggestions( uint count );
QNetworkReply* downloadSubscriptionsJson( const QString& username, const QString& device );
//ADVANCED API
/**
* Returns the Result for the Advanced API Call "Retrieving Podcasts of a Tag"
* @param query The number of Podcasts that should be returned - will be set to to 100 if > 100 or < 1
* @param tag The Tag for which Podcasts should be retrieved
* @return List of Podcast Objects containing the Data from gPodder
*
*/
PodcastList* podcastsOfTag( uint count, const QString& tag );
/**
* Returns the Result for the Advanced API Call "Retrieving Podcast Data"
* @param podcasturl Url of the Podcast for which Data should be retrieved
* @return Podcast Object containing the Data from gPodder
*
*/
Podcast* podcastData( const QUrl& podcasturl );
/**
* Returns the Result for the Advanced API Call "Retrieving Episode Data"
* @param podcasturl Url of the Podcast that contains the Episode
* @param episodeurl Url of the Episode Data for which Data should be retrieved
* @return Episode Object containing the Data from gPodder
*
*/
Episode* episodeData( const QUrl& podcasturl, const QUrl& episodeurl );
/**
* Returns the Result for the Advanced API Call "Listing Favorite Episodes"
* @param username The User whose Favorite Episodes should be retrieved
* @return List of Episode Objects containing the Data from gPodder
*
*/
EpisodeList* favoriteEpisodes( const QString& username );
/**
* Returns the Result for the Advanced API Call "Retrieving Top Tags"
* @param count The number of Tags that should be returned - will be set to to 100 if > 100 or < 1
* @return List of Tag Objects containing the Data from gPodder
*
*/
TagList* topTags( uint count );
/**
* Uploads Data & returns the Result for the Advanced API Call "Add/remove subscriptions"
* Requires Authentication.
* @param username User for which this API Call should be executed
* @param device gPodder Device for which this API Call should be executed
* @param add URLs of Podcasts that should be added to the Subscriptions of the User
* @param remove URLs of Podcasts that should be removed from the Subscriptions of the User
*
*/
AddRemoveResult* addRemoveSubscriptions( const QString& username, const QString& device, const QList< QUrl >& add, const QList< QUrl >& remove );
/**
* Retrieve settings which are attached to an account.
* @param username Username of the targeted account
* @return Received settings as key-value-pairs
*
*/
Settings* accountSettings( const QString& username );
/**
* Retrieve settings which are attached to a device.
* @param username Username of the account which owns the device
* @param device Name of the targeted device
* @return Received settings as key-value-pairs
*
*/
Settings* deviceSettings( const QString& username, const QString& device );
/**
* Retrieve settings which are attached to a podcast.
* @param username Username of the account which owns the podcast
* @param podcastUrl Url which identifies the targeted podcast
* @return Received settings as key-value-pairs
*
*/
Settings* podcastSettings( const QString& username, const QString& podcastUrl );
/**
* Retrieve settings which are attached to an episode.
* @param username Username of the account which owns the episode
* @param podcastUrl Url as String which identifies the podcast to which the episode belongs to
* @param episodeUrl Url as String which identifies the targeted episode
* @return Received settings as key-value-pairs
*
*/
Settings* episodeSettings( const QString& username, const QString& podcastUrl, const QString& episodeUrl );
/**
* Set and or remove settings which are attached to an account.
* @param username Username of the targeted account
* @param set A set of settings as key-value-pairs which shall be set
* @param set A set of exisiting settings as key-value-pairs which shall be removed
* @return All settings as key-value-pairs which are stored after the update
*
*/
Settings* setAccountSettings( const QString& username, QMap<QString, QVariant >& set, const QList<QString>& remove );
/**
* Set and or remove settings which are attached to a device.
* @param username Username of the account which owns the device
* @param device Name of the targeted device
* @param set A set of settings as key-value-pairs which shall be set
* @param set A set of exisiting settings as key-value-pairs which shall be removed
* @return All settings as key-value-pairs which are stored after the update
*
*/
Settings* setDeviceSettings( const QString& username, const QString& device, QMap<QString, QVariant >& set, const QList<QString>& remove );
/**
* Set and or remove settings which are attached to a podcast.
* @param username Username of the account which owns the podcast
* @param podcastUrl Url which identifies the targeted podcast
* @param set A set of settings as key-value-pairs which shall be set
* @param set A set of exisiting settings as key-value-pairs which shall be removed
* @return All settings as key-value-pairs which are stored after the update
*
*/
Settings* setPodcastSettings( const QString& username, const QString& podcastUrl, QMap<QString, QVariant >& set, const QList<QString>& remove );
/**
* Set and or remove settings which are attached to an episode.
* @param username Username of the account which owns the episode
* @param podcastUrl Url as String which identifies the podcast to which the episode belongs to
* @param episodeUrl Url as String which identifies the targeted episode
* @param set A set of settings as key-value-pairs which shall be set
* @param set A set of exisiting settings as key-value-pairs which shall be removed
* @return All settings as key-value-pairs which are stored after the update
*
*/
Settings* setEpisodeSettings( const QString& username, const QString& podcastUrl, const QString& episodeUrl, QMap<QString, QVariant >& set, const QList<QString>& remove );
/**
* Retrieve episode and subscription updates for a given device.
* @param username Username of the account which owns the device
* @param deviceId Id of the targeted device
* @param timestamp A date in milliseconds, All changes since this timestamp will be retrieved
* @return A DeviceUpdates* which accesses:
* - a list of subscriptions to be added, with URL, title and descriptions
* - a list of URLs to be unsubscribed
* - a list of updated episodes
*
*/
DeviceUpdates* deviceUpdates( const QString& username, const QString& deviceId, qlonglong timestamp );
/**
* Sets a new name and type for a device identified by a given ID
* @param username Username of the account which owns the device
* @param deviceId The id of the targeted device
* @param caption The new name of the device
* @param type The new type of the device
* @return A Pointer to a QNetworkReply which receives network signals
*
*/
QNetworkReply* renameDevice( const QString& username, const QString& deviceId, const QString& caption, Device::Type type );
/**
* Returns the list of devices that belong to a user.
* @param username Username of the targeted user
* @return List of devices
*
*/
DeviceList* listDevices( const QString& username );
/**
* Download episode actions for a given username.
* @param Username of the targeted user
* @param aggregated If aggregated is set to true, only the latest episode action will be returned
* @return List of all episode actions of the user
*
*/
EpisodeActionList* episodeActions( const QString& username, const bool aggregated = false );
/**
* Download episode actions for a given podcast.
* @param username Username of the account which owns the podcast
* @param podcastUrl Url which identifies the targeted podcast
* @param aggregated If aggregated is set to true, only the latest episode action will be returned
* @return List of all episode actions for the given podcast
*
*/
EpisodeActionList* episodeActionsByPodcast( const QString& username, const QString& podcastUrl, const bool aggregated = false );
/**
* Download episode actions for a given device.
* @param username Username of the account which owns the device
* @param deviceId The Id of the targeted device
* @param aggregated If aggregated is set to true, only the latest episode action will be returned
* @return List of all episode actions for the given device
*
*/
EpisodeActionList* episodeActionsByDevice( const QString& username, const QString& deviceId, const bool aggregated = false );
/**
* Download episode actions for a given username since a given timestamp.
* @param Username of the targeted user
* @param since Timestamp in milliseconds, Episode Actions since this time will be retrieved
* @return List of all new episode actions since the given timestamp
*
*/
EpisodeActionList* episodeActionsByTimestamp( const QString& username, const qulonglong since );
/**
* Download episode actions for a given podcast since a given timestamp.
* @param username Username of the account which owns the podcast
* @param podcastUrl Url which identifies the targeted podcast
* @param since Timestamp in milliseconds, Episode Actions since this time will be retrieved
* @return List of all new episode actions since the given timestamp
*
*/
EpisodeActionList* episodeActionsByPodcastAndTimestamp( const QString& username, const QString& podcastUrl, const qulonglong since );
/**
* Download episode actions for a given device since a given timestamp.
* @param username Username of the account which owns the device
* @param deviceId The Id of the targeted device
* @param since Timestamp in milliseconds, Episode Actions since this time will be retrieved
* @return List of all new episode actions since the given timestamp
*
*/
EpisodeActionList* episodeActionsByDeviceAndTimestamp( const QString& username, const QString& deviceId, const qulonglong since );
/**
* Upload episode actions
* @param episodeActions The list of episode actions which shall be uploaded
* @return An AddRemoveResult* which contains information about the updated Urls
*
*/
AddRemoveResult* uploadEpisodeActions( const QString& username, const QList<EpisodeActionPtr>& episodeActions );
DeviceSyncResult* deviceSynchronizationStatus( const QString& username );
private:
ApiRequestPrivate* const d;
};
}
#endif

85
3rdparty/libmygpo-qt/ApiRequest_p.h vendored Normal file
View File

@ -0,0 +1,85 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef APIREQUEST_PRIVATE_H
#define APIREQUEST_PRIVATE_H
#include "ApiRequest.h"
#include "RequestHandler.h"
namespace mygpo
{
class ApiRequestPrivate
{
public:
//Constructors
ApiRequestPrivate( const QString& username, const QString& password, QNetworkAccessManager* nam );
ApiRequestPrivate( QNetworkAccessManager* nam );
//Member Functions
QNetworkReply* toplistOpml( uint count );
QNetworkReply* searchOpml( const QString& query );
QNetworkReply* suggestionsOpml( uint count );
QNetworkReply* downloadSubscriptionsOpml( const QString& username, const QString& device );
QNetworkReply* toplistTxt( uint count );
QNetworkReply* searchTxt( const QString& query );
QNetworkReply* suggestionsTxt( uint count );
QNetworkReply* downloadSubscriptionsTxt ( const QString& username, const QString& device );
QNetworkReply* toplistXml( uint count );
QNetworkReply* searchXml( const QString& query );
PodcastList* toplist( uint count );
PodcastList* search( const QString& query );
PodcastList* suggestions( uint count );
QNetworkReply* downloadSubscriptionsJson( const QString& username, const QString& device );
PodcastList* podcastsOfTag( uint count, const QString& tag );
Podcast* podcastData( const QUrl& podcasturl );
Episode* episodeData( const QUrl& podcasturl, const QUrl& episodeurl );
EpisodeList* favoriteEpisodes( const QString& username );
TagList* topTags( uint count );
AddRemoveResult* addRemoveSubscriptions( const QString& username, const QString& device, const QList< QUrl >& add, const QList< QUrl >& remove );
Settings* accountSettings( const QString& username );
Settings* deviceSettings( const QString& username, const QString& device );
Settings* podcastSettings( const QString& username, const QString& podcastUrl );
Settings* episodeSettings( const QString& username, const QString& podcastUrl, const QString& episodeUrl );
Settings* setAccountSettings( const QString& username, QMap<QString, QVariant >& set, const QList<QString>& remove );
Settings* setDeviceSettings( const QString& username, const QString& device, QMap<QString, QVariant >& set, const QList<QString>& remove );
Settings* setPodcastSettings( const QString& username, const QString& podcastUrl, QMap<QString, QVariant >& set, const QList<QString>& remove );
Settings* setEpisodeSettings( const QString& username, const QString& podcastUrl, const QString& episodeUrl, QMap<QString, QVariant >& set, const QList<QString>& remove );
DeviceUpdates* deviceUpdates( const QString& username, const QString& deviceId, qlonglong timestamp );
QNetworkReply* renameDevice( const QString& username, const QString& deviceId, const QString& caption, Device::Type type );
DeviceList* listDevices( const QString& username );
EpisodeActionList* episodeActions( const QString& username, const bool aggregated );
EpisodeActionList* episodeActionsByPodcast( const QString& username, const QString& podcastUrl, const bool aggregated );
EpisodeActionList* episodeActionsByDevice( const QString& username, const QString& deviceId, const bool aggregated );
EpisodeActionList* episodeActionsByTimestamp( const QString& username, const qulonglong since );
EpisodeActionList* episodeActionsByPodcastAndTimestamp( const QString& username, const QString& podcastUrl, const qulonglong since );
EpisodeActionList* episodeActionsByDeviceAndTimestamp( const QString& username, const QString& deviceId, const qulonglong since );
AddRemoveResult* uploadEpisodeActions( const QString& username, const QList<EpisodeActionPtr>& episodeActions );
DeviceSyncResult* deviceSynchronizationStatus( const QString& username );
private:
RequestHandler m_requestHandler;
};
}
#endif //APIREQUEST_PRIVATE_H

80
3rdparty/libmygpo-qt/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,80 @@
include_directories( ${QT_INCLUDES} ${QJSON_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
set ( LIBMYGPO_QT_SRC
DeviceSyncResult.cpp
Settings.cpp
AddRemoveResult.cpp
Tag.cpp
JsonCreator.cpp
Podcast.cpp
Episode.cpp
EpisodeAction.cpp
EpisodeActionList.cpp
ApiRequest.cpp
RequestHandler.cpp
UrlBuilder.cpp
TagList.cpp
EpisodeList.cpp
PodcastList.cpp
DeviceUpdates.cpp
DeviceList.cpp
Device.cpp
)
set ( LIBMYGPO_QT_MOC_H
Podcast.h
Podcast_p.h
PodcastList.h
PodcastList_p.h
Episode.h
Episode_p.h
EpisodeList.h
EpisodeList_p.h
Tag.h
Tag_p.h
TagList.h
TagList_p.h
Device.h
Device_p.h
DeviceList.h
DeviceList_p.h
DeviceSyncResult.h
DeviceSyncResult_p.h
DeviceUpdates.h
DeviceUpdates_p.h
EpisodeAction.h
EpisodeAction_p.h
EpisodeActionList.h
EpisodeActionList_p.h
Settings.h
Settings_p.h
AddRemoveResult.h
AddRemoveResult_p.h
)
set ( LIBMYGPO_QT_INSTALL_H
ApiRequest.h
mygpo_export.h
Podcast.h
PodcastList.h
Episode.h
EpisodeList.h
Tag.h
TagList.h
Device.h
DeviceList.h
DeviceSyncResult.h
DeviceUpdates.h
EpisodeAction.h
EpisodeActionList.h
Settings.h
AddRemoveResult.h
)
QT4_WRAP_CPP(LIBMYGPO_QT_MOC_SRC ${LIBMYGPO_QT_MOC_H} )
add_library( mygpo-qt STATIC ${LIBMYGPO_QT_SRC} ${LIBMYGPO_QT_MOC_SRC} )
target_link_libraries( mygpo-qt ${QJSON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY} )
set_target_properties( mygpo-qt PROPERTIES VERSION ${MYGPO_QT_VERSION} SOVERSION ${MYGPO_QT_SONAME} DEFINE_SYMBOL MYGPO_MAKEDLL)

110
3rdparty/libmygpo-qt/Device.cpp vendored Normal file
View File

@ -0,0 +1,110 @@
/***************************************************************************
* 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 "Device.h"
#include "Device_p.h"
using namespace mygpo;
Device::Device( const QVariant& var, QObject* parent ): QObject( parent ), d( new DevicePrivate( var ) )
{
}
Device::~Device()
{
delete d;
}
QString Device::caption() const
{
return d->caption();
}
QString Device::id() const
{
return d->id();
}
qulonglong Device::subscriptions() const
{
return d->subscriptions();
}
QString Device::type() const
{
return d->type();
}
DevicePrivate::DevicePrivate( const QVariant& var ) : m_id(), m_caption(), m_type(), m_subscriptions( 0 )
{
parse( var );
}
bool DevicePrivate::parse( const QVariant& var )
{
if( var.canConvert( QVariant::Map ) )
{
QVariant vid, vcaption, vtype, vsubscriptions;
QMap<QString, QVariant> varMap;
varMap = var.toMap();
vid = varMap.value( QLatin1String( "id" ) );
vcaption = varMap.value( QLatin1String( "caption" ) );
vtype = varMap.value( QLatin1String( "type" ) );
vsubscriptions = varMap.value( QLatin1String( "subscriptions" ) );
if( vid.canConvert( QVariant::String ) &&
vcaption.canConvert( QVariant::String ) &&
vtype.canConvert( QVariant::String ) &&
vsubscriptions.canConvert( QVariant::LongLong ) )
{
m_id = vid.toString();
m_caption = vcaption.toString();
m_type = vtype.toString();
m_subscriptions = vsubscriptions.toLongLong();
return true;
}
}
return false;
}
QString DevicePrivate::caption() const
{
return this->m_caption;
}
QString DevicePrivate::id() const
{
return this->m_id;
}
qulonglong DevicePrivate::subscriptions() const
{
return this->m_subscriptions;
}
QString DevicePrivate::type() const
{
return this->m_type;
}

71
3rdparty/libmygpo-qt/Device.h vendored Normal file
View File

@ -0,0 +1,71 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef DEVICE_H
#define DEVICE_H
#include "mygpo_export.h"
#include <QSharedPointer>
#include <QVariant>
namespace mygpo
{
class DevicePrivate;
class MYGPO_EXPORT Device : public QObject
{
Q_OBJECT
Q_PROPERTY( QString id READ id CONSTANT )
Q_PROPERTY( QString caption READ caption CONSTANT )
Q_PROPERTY( QString type READ type CONSTANT )
Q_PROPERTY( qulonglong subscriptions READ subscriptions CONSTANT )
public:
enum Type
{
DESKTOP,
LAPTOP,
MOBILE,
SERVER,
OTHER
};
Device( const QVariant& var, QObject* parent = 0 );
virtual ~Device();
QString id() const;
QString caption() const;
QString type() const;
qulonglong subscriptions() const;
private:
Q_DISABLE_COPY( Device )
DevicePrivate* const d;
};
typedef QSharedPointer<Device> DevicePtr;
}
Q_DECLARE_METATYPE( mygpo::DevicePtr );
#endif //DEVICE_H

121
3rdparty/libmygpo-qt/DeviceList.cpp vendored Normal file
View File

@ -0,0 +1,121 @@
/***************************************************************************
* 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 "DeviceList_p.h"
#include <qjson/parser.h>
using namespace mygpo;
DeviceListPrivate::DeviceListPrivate( DeviceList* qq, QNetworkReply* reply ) : q( qq ), m_reply( reply ), m_error( QNetworkReply::NoError )
{
QObject::connect( m_reply, SIGNAL( finished() ), this, SLOT( parseData() ) );
QObject::connect( m_reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( error( QNetworkReply::NetworkError ) ) );
}
DeviceListPrivate::~DeviceListPrivate()
{
}
QVariant DeviceListPrivate::devices() const
{
return m_devices;
}
QList< DevicePtr > DeviceListPrivate::devicesList() const
{
return m_devicesList;
}
void DeviceListPrivate::error( QNetworkReply::NetworkError error )
{
m_error = error;
emit q->requestError( error );
}
bool DeviceListPrivate::parse( const QVariant& data )
{
if( !data.canConvert( QVariant::List ) )
return false;
QVariantList varList = data.toList();
QVariantList devList;
foreach( const QVariant & var, varList )
{
DevicePtr ptr( new Device( var, this ) );
m_devicesList.append( ptr );
QVariant v;
v.setValue<DevicePtr>( ptr );
devList.append( v );
}
m_devices = devList;
return true;
}
bool DeviceListPrivate::parse( const QByteArray& data )
{
QJson::Parser parser;
bool ok;
QVariant variant = parser.parse( data, &ok );
if( ok )
{
ok = ( parse( variant ) );
}
return ok;
}
void DeviceListPrivate::parseData()
{
if( m_reply->error() == QNetworkReply::NoError )
{
if( parse( m_reply->readAll() ) )
{
emit q->finished();
}
else
{
emit q->parseError();
}
}
m_reply->deleteLater();
}
DeviceList::DeviceList( QNetworkReply* reply, QObject* parent ) : QObject( parent ), d( new DeviceListPrivate( this, reply ) )
{
}
DeviceList::~DeviceList()
{
delete d;
}
QVariant mygpo::DeviceList::devices() const
{
return d->devices();
}
QList< DevicePtr > DeviceList::devicesList() const
{
return d->devicesList();
}

68
3rdparty/libmygpo-qt/DeviceList.h vendored Normal file
View File

@ -0,0 +1,68 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef DEVICELIST_H
#define DEVICELIST_H
#include <QNetworkReply>
#include <QSharedPointer>
#include "Device.h"
#include "mygpo_export.h"
namespace mygpo
{
class DeviceListPrivate;
class MYGPO_EXPORT DeviceList : public QObject
{
Q_OBJECT
Q_PROPERTY( QVariant devices READ devices CONSTANT )
public:
DeviceList( QNetworkReply* reply, QObject* parent = 0 );
virtual ~DeviceList();
QVariant devices() const;
QList< DevicePtr > devicesList() const;
private:
Q_DISABLE_COPY( DeviceList )
DeviceListPrivate* const d;
friend class DeviceListPrivate;
signals:
/**Gets emitted when the data is ready to read*/
void finished();
/**Gets emitted when an parse error ocurred*/
void parseError();
/**Gets emitted when an request error ocurred*/
void requestError( QNetworkReply::NetworkError error );
};
typedef QSharedPointer<DeviceList> DeviceListPtr;
}
Q_DECLARE_METATYPE( mygpo::DeviceListPtr );
#endif //DEVICELIST_H

57
3rdparty/libmygpo-qt/DeviceList_p.h vendored Normal file
View File

@ -0,0 +1,57 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef DEVICELIST_PRIVATE_H
#define DEVICELIST_PRIVATE_H
#include "DeviceList.h"
namespace mygpo
{
class DeviceListPrivate : public QObject
{
Q_OBJECT
public:
DeviceListPrivate( DeviceList* qq, QNetworkReply* reply );
virtual ~DeviceListPrivate();
QVariant devices() const;
QList< DevicePtr > devicesList() const;
private:
DeviceList* q;
QNetworkReply* m_reply;
QVariant m_devices;
QList<DevicePtr> m_devicesList;
QNetworkReply::NetworkError m_error;
bool parse( const QVariant& data );
bool parse( const QByteArray& data );
private slots:
void parseData();
void error( QNetworkReply::NetworkError error );
};
}
#endif //DEVICELIST_PRIVATE_H

View File

@ -0,0 +1,148 @@
/***************************************************************************
* This file is part of libmygpo-qt *
* Copyright (c) 2011 Stefan Derkits <stefan@derkits.at> *
* *
* 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 "DeviceSyncResult_p.h"
#include <qjson/parser.h>
using namespace mygpo;
DeviceSyncResultPrivate::DeviceSyncResultPrivate( DeviceSyncResult* qq, QNetworkReply* reply ) : q( qq ), m_reply( reply ), m_error( QNetworkReply::NoError )
{
QObject::connect( m_reply, SIGNAL( finished() ), this, SLOT( parseData() ) );
QObject::connect( m_reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( error( QNetworkReply::NetworkError ) ) );
}
DeviceSyncResultPrivate::~DeviceSyncResultPrivate()
{
}
QVariant DeviceSyncResultPrivate::synchronized() const
{
return m_synchronized;
}
QVariant DeviceSyncResultPrivate::notSynchronized() const
{
return m_notSynchronized;
}
QList<QStringList> DeviceSyncResultPrivate::synchronizedList() const
{
QVariantList synchronizedVarList = synchronized().toList();
QList<QStringList> synchronizedList;
foreach( const QVariant & list, synchronizedVarList )
{
QVariantList innerVarList = list.toList();
QStringList innerList;
foreach( const QVariant& device, innerVarList )
{
innerList.append(device.toString());
}
synchronizedList.append(innerList);
}
return synchronizedList;
}
QList<QString> DeviceSyncResultPrivate::notSynchronizedList() const
{
QVariantList notSynchronizedVarList = notSynchronized().toList();
QList<QString> notSynchronizedList;
foreach ( const QVariant& device, notSynchronizedVarList )
{
notSynchronizedList.append(device.toString());
}
return notSynchronizedList;
}
bool DeviceSyncResultPrivate::parse( const QVariant& data )
{
if( !data.canConvert( QVariant::Map ) )
return false;
QVariantMap varMap = data.toMap();
m_synchronized = varMap.value( QLatin1String( "synchronized" ) );
m_notSynchronized = varMap.value( QLatin1String( "not-synchronized" ) );
return true;
}
bool DeviceSyncResultPrivate::parse( const QByteArray& data )
{
QJson::Parser parser;
bool ok;
QVariant variant = parser.parse( data, &ok );
if( ok )
{
ok = ( parse( variant ) );
}
return ok;
}
void DeviceSyncResultPrivate::parseData()
{
if( m_reply->error() == QNetworkReply::NoError )
{
if( parse( m_reply->readAll() ) )
{
emit q->finished();
}
else
{
emit q->parseError();
}
}
m_reply->deleteLater();
}
void DeviceSyncResultPrivate::error( QNetworkReply::NetworkError error )
{
m_error = error;
emit q->requestError( error );
}
DeviceSyncResult::DeviceSyncResult ( QNetworkReply* reply, QObject* parent ) : QObject ( parent ), d( new DeviceSyncResultPrivate( this, reply ) )
{
}
DeviceSyncResult::~DeviceSyncResult()
{
delete d;
}
QVariant DeviceSyncResult::synchronized() const
{
return d->synchronized();
}
QVariant DeviceSyncResult::notSynchronized() const
{
return d->notSynchronized();
}
QList<QStringList> DeviceSyncResult::synchronizedList() const
{
return d->synchronizedList();
}
QList< QString > DeviceSyncResult::notSynchronizedList() const
{
return d->notSynchronizedList();
}

66
3rdparty/libmygpo-qt/DeviceSyncResult.h vendored Normal file
View File

@ -0,0 +1,66 @@
/***************************************************************************
* This file is part of libmygpo-qt *
* Copyright (c) 2011 Stefan Derkits <stefan@derkits.at> *
* *
* 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 *
***************************************************************************/
#ifndef DEVICESYNCRESULT_H
#define DEVICESYNCRESULT_H
#include <QNetworkReply>
#include <QObject>
#include <QSharedPointer>
#include <QStringList>
#include "mygpo_export.h"
namespace mygpo {
class DeviceSyncResultPrivate;
class MYGPO_EXPORT DeviceSyncResult : public QObject
{
Q_OBJECT
Q_PROPERTY( QVariant synchronized READ synchronized CONSTANT )
Q_PROPERTY( QVariant notSynchronized READ notSynchronized CONSTANT )
public:
DeviceSyncResult ( QNetworkReply* reply, QObject* parent = 0 );
virtual ~DeviceSyncResult();
QVariant synchronized() const;
QVariant notSynchronized() const;
QList<QStringList> synchronizedList() const;
QList<QString> notSynchronizedList() const;
private:
Q_DISABLE_COPY( DeviceSyncResult )
DeviceSyncResultPrivate* const d;
friend class DeviceSyncResultPrivate;
signals:
/**Gets emitted when the data is ready to read*/
void finished();
/**Gets emitted when an parse error ocurred*/
void parseError();
/**Gets emitted when an request error ocurred*/
void requestError( QNetworkReply::NetworkError error );
};
typedef QSharedPointer<DeviceSyncResult> DeviceSyncResultPtr;
}
#endif // DEVICESYNCRESULT_H

View File

@ -0,0 +1,58 @@
/***************************************************************************
* This file is part of libmygpo-qt *
* Copyright (c) 2011 Stefan Derkits <stefan@derkits.at> *
* *
* 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 *
***************************************************************************/
#ifndef DEVICESYNCRESULT_PRIVATE_H
#define DEVICESYNCRESULT_PRIVATE_H
#include "DeviceSyncResult.h"
namespace mygpo {
class DeviceSyncResultPrivate : public QObject
{
Q_OBJECT
public:
DeviceSyncResultPrivate( DeviceSyncResult* qq, QNetworkReply* reply );
virtual ~DeviceSyncResultPrivate();
QVariant synchronized() const;
QVariant notSynchronized() const;
QList<QStringList> synchronizedList() const;
QList<QString> notSynchronizedList() const;
private:
DeviceSyncResult* q;
QVariant m_synchronized;
QVariant m_notSynchronized;
QNetworkReply* m_reply;
QNetworkReply::NetworkError m_error;
bool parse( const QVariant& data );
bool parse( const QByteArray& data );
private slots:
void parseData();
void error( QNetworkReply::NetworkError error );
};
}
#endif // DEVICESYNCRESULT_H

187
3rdparty/libmygpo-qt/DeviceUpdates.cpp vendored Normal file
View File

@ -0,0 +1,187 @@
/***************************************************************************
* 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 "DeviceUpdates_p.h"
#include <qjson/parser.h>
using namespace mygpo;
DeviceUpdatesPrivate::DeviceUpdatesPrivate( DeviceUpdates* qq, QNetworkReply* reply ): q( qq ), m_timestamp( 0 ), m_reply( reply ), m_error( QNetworkReply::NoError )
{
QObject::connect( m_reply, SIGNAL( finished() ), this, SLOT( parseData() ) );
QObject::connect( m_reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( error( QNetworkReply::NetworkError ) ) );
}
DeviceUpdatesPrivate::~DeviceUpdatesPrivate()
{
}
QVariant DeviceUpdatesPrivate::add() const
{
return m_add;
}
QList< PodcastPtr > DeviceUpdatesPrivate::addList() const
{
QVariantList updateVarList = m_add.toList();
QList<PodcastPtr> ret;
foreach( const QVariant & var, updateVarList )
{
ret.append( PodcastPtr( new Podcast( var ) ) );
}
return ret;
}
QVariant DeviceUpdatesPrivate::remove() const
{
return m_remove;
}
QList< QUrl > DeviceUpdatesPrivate::removeList() const
{
QVariantList updateVarList = m_remove.toList();
QList<QUrl> ret;
foreach( const QVariant & var, updateVarList )
{
if( var.canConvert( QVariant::Url ) )
ret.append( var.toUrl() );
}
return ret;
}
QVariant DeviceUpdatesPrivate::update() const
{
return m_update;
}
QList< EpisodePtr > DeviceUpdatesPrivate::updateList() const
{
QVariantList updateVarList = m_update.toList();
QList<EpisodePtr> ret;
foreach( const QVariant & var, updateVarList )
{
ret.append( EpisodePtr( new Episode( var ) ) );
}
return ret;
}
bool DeviceUpdatesPrivate::parse( const QVariant& data )
{
if( !data.canConvert( QVariant::Map ) )
return false;
QVariantMap varMap = data.toMap();
m_add = varMap.value( QLatin1String( "add" ) );
m_remove = varMap.value( QLatin1String( "remove" ) );
m_update = varMap.value( QLatin1String( "updates" ) );
if( varMap.value( QLatin1String( "timestamp" ) ).canConvert( QVariant::LongLong ) )
m_timestamp = varMap.value( QLatin1String( "timestamp" ) ).toLongLong();
return true;
}
bool DeviceUpdatesPrivate::parse( const QByteArray& data )
{
QJson::Parser parser;
bool ok;
QVariant variant = parser.parse( data, &ok );
if( ok )
{
ok = ( parse( variant ) );
}
return ok;
}
void DeviceUpdatesPrivate::parseData()
{
if( m_reply->error() == QNetworkReply::NoError )
{
if( parse( m_reply->readAll() ) )
{
emit q->finished();
}
else
{
emit q->parseError();
}
}
m_reply->deleteLater();
}
void DeviceUpdatesPrivate::error( QNetworkReply::NetworkError error )
{
m_error = error;
emit q->requestError( error );
}
qulonglong DeviceUpdatesPrivate::timestamp() const
{
return m_timestamp;
}
DeviceUpdates::DeviceUpdates( QNetworkReply* reply, QObject* parent ): QObject( parent ), d( new DeviceUpdatesPrivate( this, reply ) )
{
}
DeviceUpdates::~DeviceUpdates()
{
delete d;
}
QVariant DeviceUpdates::add() const
{
return d->add();
}
QList< PodcastPtr > DeviceUpdates::addList() const
{
return d->addList();
}
QVariant mygpo::DeviceUpdates::remove() const
{
return d->remove();
}
QList< QUrl > mygpo::DeviceUpdates::removeList() const
{
return d->removeList();
}
QVariant mygpo::DeviceUpdates::update() const
{
return d->update();
}
QList< mygpo::EpisodePtr > mygpo::DeviceUpdates::updateList() const
{
return d->updateList();
}
qulonglong DeviceUpdates::timestamp() const
{
return d->timestamp();
}

72
3rdparty/libmygpo-qt/DeviceUpdates.h vendored Normal file
View File

@ -0,0 +1,72 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef DEVICEUPDATES_H
#define DEVICEUPDATES_H
#include <QNetworkReply>
#include <QUrl>
#include "mygpo_export.h"
#include "Podcast.h"
#include "Episode.h"
namespace mygpo
{
class DeviceUpdatesPrivate;
class MYGPO_EXPORT DeviceUpdates : public QObject
{
Q_OBJECT
Q_PROPERTY( QVariant add READ add CONSTANT )
Q_PROPERTY( QVariant update READ update CONSTANT )
Q_PROPERTY( QVariant remove READ remove CONSTANT )
Q_PROPERTY( qulonglong timestamp READ timestamp CONSTANT )
public:
DeviceUpdates( QNetworkReply* reply, QObject* parent = 0 );
virtual ~DeviceUpdates();
QList<PodcastPtr> addList() const;
QList<EpisodePtr> updateList() const;
QList<QUrl> removeList() const;
QVariant add() const;
QVariant update() const;
QVariant remove() const;
qulonglong timestamp() const;
private:
Q_DISABLE_COPY( DeviceUpdates )
DeviceUpdatesPrivate* const d;
friend class DeviceUpdatesPrivate;
signals:
/**Gets emitted when the data is ready to read*/
void finished();
/**Gets emitted when an parse error ocurred*/
void parseError();
/**Gets emitted when an request error ocurred*/
void requestError( QNetworkReply::NetworkError error );
};
typedef QSharedPointer<DeviceUpdates> DeviceUpdatesPtr;
}
#endif // DEVICEUPDATES_H

67
3rdparty/libmygpo-qt/DeviceUpdates_p.h vendored Normal file
View File

@ -0,0 +1,67 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef DEVICEUPDATES_PRIVATE_H
#define DEVICEUPDATES_PRIVATE_H
#include "DeviceUpdates.h"
namespace mygpo
{
class DeviceUpdatesPrivate : public QObject
{
Q_OBJECT
public:
DeviceUpdatesPrivate( DeviceUpdates* qq, QNetworkReply* reply );
virtual ~DeviceUpdatesPrivate();
QList<PodcastPtr> addList() const;
QList<EpisodePtr> updateList() const;
QList<QUrl> removeList() const;
QVariant add() const;
QVariant update() const;
QVariant remove() const;
qulonglong timestamp() const;
private:
DeviceUpdates* q;
QVariant m_add;
QVariant m_update;
QVariant m_remove;
qlonglong m_timestamp;
QNetworkReply* m_reply;
QNetworkReply::NetworkError m_error;
bool parse( const QVariant& data );
bool parse( const QByteArray& data );
private slots:
void parseData();
void error( QNetworkReply::NetworkError error );
};
}
#endif //DEVICEUPDATES_PRIVATE_H

51
3rdparty/libmygpo-qt/Device_p.h vendored Normal file
View File

@ -0,0 +1,51 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef DEVICE_PRIVATE_H
#define DEVICE_PRIVATE_H
#include "Device.h"
namespace mygpo
{
class DevicePrivate : public QObject
{
Q_OBJECT
public:
DevicePrivate( const QVariant& var );
QString id() const;
QString caption() const;
QString type() const;
qulonglong subscriptions() const;
private:
QString m_id;
QString m_caption;
QString m_type;
qulonglong m_subscriptions;
bool parse( const QVariant& var );
};
}
#endif //DEVICE_PRIVATE_H

258
3rdparty/libmygpo-qt/Episode.cpp vendored Normal file
View File

@ -0,0 +1,258 @@
/***************************************************************************
* 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 "Episode_p.h"
#include <qjson/parser.h>
using namespace mygpo;
EpisodePrivate::~EpisodePrivate()
{
}
EpisodePrivate::EpisodePrivate ( Episode* qq, QNetworkReply* reply, QObject* parent ) : QObject ( parent ), m_reply ( reply ), q ( qq ), m_error ( QNetworkReply::NoError )
{
QObject::connect ( m_reply, SIGNAL ( finished() ), this, SLOT ( parseData() ) );
QObject::connect ( m_reply, SIGNAL ( error ( QNetworkReply::NetworkError ) ), this, SLOT ( error ( QNetworkReply::NetworkError ) ) );
}
EpisodePrivate::EpisodePrivate ( Episode* qq, const QVariant& variant, QObject* parent ) : QObject ( parent ), m_reply ( 0 ), q ( qq )
{
parse ( variant );
}
bool EpisodePrivate::parse ( const QVariant& data )
{
if ( !data.canConvert ( QVariant::Map ) )
return false;
QVariantMap episodeMap = data.toMap();
QVariant s = episodeMap.value ( QLatin1String ( "url" ) );
if ( !s.canConvert ( QVariant::Url ) )
return false;
m_url = s.toUrl();
s = episodeMap.value ( QLatin1String ( "title" ) );
if ( !s.canConvert ( QVariant::String ) )
return false;
m_title = s.toString();
s = episodeMap.value ( QLatin1String ( "podcast_url" ) );
if ( !s.canConvert ( QVariant::Url ) )
return false;
m_podcastUrl = s.toUrl();
s = episodeMap.value ( QLatin1String ( "podcast_title" ) );
if ( !s.canConvert ( QVariant::String ) )
return false;
m_podcastTitle = s.toString();
s = episodeMap.value ( QLatin1String ( "description" ) );
if ( !s.canConvert ( QVariant::String ) )
return false;
m_description = s.toString();
s = episodeMap.value ( QLatin1String ( "website" ) );
if ( !s.canConvert ( QVariant::Url ) )
return false;
m_website = s.toUrl();
s = episodeMap.value ( QLatin1String ( "mygpo_link" ) );
if ( !s.canConvert ( QVariant::Url ) )
return false;
m_mygpoUrl = s.toUrl();
s = episodeMap.value ( QLatin1String ( "status" ) );
if ( s.canConvert ( QVariant::String ) )
{
QString status = s.toString();
m_status = Episode::UNKNOWN;
if ( QString::compare ( status, QLatin1String ( "new" ) ,Qt::CaseInsensitive ) == 0 )
{
m_status = Episode::NEW;
}
else if ( QString::compare ( status, QLatin1String ( "play" ) ,Qt::CaseInsensitive ) == 0 )
{
m_status = Episode::PLAY;
}
else if ( QString::compare ( status, QLatin1String ( "download" ) ,Qt::CaseInsensitive ) == 0 )
{
m_status = Episode::DOWNLOAD;
}
else if ( QString::compare ( status, QLatin1String ( "delete" ) ,Qt::CaseInsensitive ) == 0 )
{
m_status = Episode::DELETE;
}
}
else
{
m_status = Episode::UNKNOWN;
}
s = episodeMap.value( QLatin1String ( "released" ) );
if ( s.canConvert( QVariant::String ) )
{
QString date = s.toString();
m_released = QDateTime::fromString( date, Qt::ISODate );
}
else
{
m_released = QDateTime::currentDateTime();
}
return true;
}
bool EpisodePrivate::parse ( const QByteArray& data )
{
QJson::Parser parser;
bool ok;
QVariant variant = parser.parse ( data, &ok );
if ( ok )
{
if ( !parse ( variant ) ) return false;
return true;
}
else
{
return false;
}
}
void EpisodePrivate::parseData()
{
//parse and send signal
if ( m_reply->error() == QNetworkReply::NoError )
{
if ( parse ( m_reply->readAll() ) )
{
emit q->finished();
}
else
{
emit q->parseError();
}
}
m_reply->deleteLater();
}
void EpisodePrivate::error ( QNetworkReply::NetworkError error )
{
this->m_error = error;
emit q->requestError ( error );
}
QString EpisodePrivate::description() const
{
return m_description;
}
QUrl EpisodePrivate::mygpoUrl() const
{
return m_mygpoUrl;
}
QString EpisodePrivate::podcastTitle() const
{
return m_podcastTitle;
}
QUrl EpisodePrivate::podcastUrl() const
{
return m_podcastUrl;
}
QString EpisodePrivate::title() const
{
return m_title;
}
QUrl EpisodePrivate::url() const
{
return m_url;
}
QUrl EpisodePrivate::website() const
{
return m_website;
}
Episode::Status EpisodePrivate::status() const
{
return m_status;
}
QDateTime EpisodePrivate::releaded() const
{
return m_released;
}
Episode::Episode ( QNetworkReply* reply, QObject* parent ) : QObject ( parent ), d ( new EpisodePrivate ( this, reply ) )
{
}
Episode::Episode ( const QVariant& variant, QObject* parent ) : QObject ( parent ), d ( new EpisodePrivate ( this, variant ) )
{
}
Episode::~Episode()
{
delete d;
}
QUrl Episode::url() const
{
return d->url();
}
QString Episode::title() const
{
return d->title();
}
QUrl Episode::podcastUrl() const
{
return d->podcastUrl();
}
QString Episode::podcastTitle() const
{
return d->podcastTitle();
}
QString Episode::description() const
{
return d->description();
}
QUrl Episode::website() const
{
return d->website();
}
QUrl Episode::mygpoUrl() const
{
return d->mygpoUrl();
}
Episode::Status Episode::status() const
{
return d->status();
}
QDateTime Episode::released() const
{
return d->releaded();
}

96
3rdparty/libmygpo-qt/Episode.h vendored Normal file
View File

@ -0,0 +1,96 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef EPISODE_H
#define EPISODE_H
#include <QObject>
#include <QUrl>
#include <QString>
#include <QDateTime>
#include <QNetworkReply>
#include <QSharedPointer>
#include "mygpo_export.h"
namespace mygpo
{
class EpisodePrivate;
class MYGPO_EXPORT Episode : public QObject
{
Q_OBJECT
Q_PROPERTY( QUrl url READ url CONSTANT )
Q_PROPERTY( QString title READ title CONSTANT )
Q_PROPERTY( QUrl podcastUrl READ url CONSTANT )
Q_PROPERTY( QString podcastTitle READ title CONSTANT )
Q_PROPERTY( QString description READ description CONSTANT )
Q_PROPERTY( QUrl website READ website CONSTANT )
Q_PROPERTY( QDateTime released READ released CONSTANT )
Q_PROPERTY( int status READ status CONSTANT )
Q_PROPERTY( QUrl mygpoUrl READ mygpoUrl CONSTANT )
public:
enum Status
{
UNKNOWN,
NEW,
PLAY,
DOWNLOAD,
DELETE
};
Episode( QNetworkReply* reply, QObject* parent = 0 );
Episode( const QVariant& variant, QObject* parent = 0 );
virtual ~Episode();
QUrl url() const;
QString title() const;
QUrl podcastUrl() const;
QString podcastTitle() const;
QString description() const;
QUrl website() const;
QUrl mygpoUrl() const;
QDateTime released() const;
Episode::Status status() const;
private:
Q_DISABLE_COPY( Episode )
EpisodePrivate* const d;
friend class EpisodePrivate;
signals:
/**Gets emitted when the data is ready to read*/
void finished();
/**Gets emitted when an parse error ocurred*/
void parseError();
/**Gets emitted when an request error ocurred*/
void requestError( QNetworkReply::NetworkError error );
};
typedef QSharedPointer<Episode> EpisodePtr;
}
Q_DECLARE_METATYPE( mygpo::EpisodePtr );
#endif // EPISODE_H

268
3rdparty/libmygpo-qt/EpisodeAction.cpp vendored Normal file
View File

@ -0,0 +1,268 @@
/***************************************************************************
* 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 "EpisodeAction_p.h"
#include <qjson/parser.h>
using namespace mygpo;
EpisodeActionPrivate::EpisodeActionPrivate( EpisodeAction* qq, const QVariant& variant, QObject* parent ) : QObject( parent ), q( qq )
{
parse( variant );
}
EpisodeActionPrivate::EpisodeActionPrivate( EpisodeAction* qq, const QUrl& podcastUrl, const QUrl& episodeUrl, const QString& deviceName, EpisodeAction::ActionType action, qulonglong timestamp, qulonglong started, qulonglong position, qulonglong total, QObject* parent )
: QObject( parent ), q( qq ), m_podcastUrl( podcastUrl ), m_episodeUrl( episodeUrl ), m_deviceName( deviceName ), m_action( action ), m_timestamp( timestamp ), m_started( started ), m_position( position ), m_total( total )
{
}
EpisodeActionPrivate::~EpisodeActionPrivate()
{
}
bool EpisodeActionPrivate::parse( const QVariant& data )
{
if( !data.canConvert( QVariant::Map ) )
return false;
QVariantMap episodeActionMap = data.toMap();
QVariant s = episodeActionMap.value( QLatin1String( "podcast" ) );
if( !s.canConvert( QVariant::Url ) )
return false;
m_podcastUrl = s.toUrl();
s = episodeActionMap.value( QLatin1String( "episode" ) );
if( !s.canConvert( QVariant::Url ) )
return false;
m_episodeUrl = s.toUrl();
if( episodeActionMap.contains( QLatin1String( "device" ) ) )
{
s = episodeActionMap.value( QLatin1String( "device" ) );
if( !s.canConvert( QVariant::String ) )
return false;
m_deviceName = s.toString();
}
else
{
m_deviceName = QLatin1String( "" );
}
s = episodeActionMap.value( QLatin1String( "action" ) );
if( !s.canConvert( QVariant::String ) )
return false;
if( !parseActionType( s.toString() ) )
return false;
if( episodeActionMap.contains( QLatin1String( "started" ) ) )
{
s = episodeActionMap.value( QLatin1String( "started" ) );
if( !s.canConvert( QVariant::ULongLong ) )
return false;
m_started = s.toULongLong();
}
else
{
m_started = 0;
}
if( episodeActionMap.contains( QLatin1String( "position" ) ) )
{
s = episodeActionMap.value( QLatin1String( "position" ) );
if( !s.canConvert( QVariant::ULongLong ) )
return false;
m_position = s.toULongLong();
}
else
{
m_position = 0;
}
if( episodeActionMap.contains( QLatin1String( "total" ) ) )
{
s = episodeActionMap.value( QLatin1String( "total" ) );
if( !s.canConvert( QVariant::ULongLong ) )
return false;
m_total = s.toULongLong();
}
else
{
m_total = 0;
}
if( episodeActionMap.contains( QLatin1String( "timestamp" ) ) )
{
s = episodeActionMap.value( QLatin1String( "timestamp" ) );
m_timestamp = s.toULongLong();
}
else
{
m_timestamp = 0;
}
return true;
}
bool EpisodeActionPrivate::parseActionType( const QString& data )
{
if( data.compare( QLatin1String( "delete" ) ) == 0 )
{
m_action = EpisodeAction::Delete;
return true;
}
else if( data.compare( QLatin1String( "download" ) ) == 0 )
{
m_action = EpisodeAction::Download;
return true;
}
else if( data.compare( QLatin1String( "play" ) ) == 0 )
{
m_action = EpisodeAction::Play;
return true;
}
else if( data.compare( QLatin1String( "new" ) ) == 0 )
{
m_action = EpisodeAction::New;
return true;
}
else
{
return false;
}
}
bool EpisodeActionPrivate::parse( const QByteArray& data )
{
QJson::Parser parser;
bool ok;
QVariant variant = parser.parse( data, &ok );
if( ok )
{
if( !parse( variant ) ) return false;
return true;
}
else
{
return false;
}
}
QUrl EpisodeActionPrivate::podcastUrl() const
{
return m_podcastUrl;
}
QUrl EpisodeActionPrivate::episodeUrl() const
{
return m_episodeUrl;
}
QString EpisodeActionPrivate::deviceName() const
{
return m_deviceName;
}
EpisodeAction::ActionType EpisodeActionPrivate::action() const
{
return m_action;
}
qulonglong EpisodeActionPrivate::timestamp() const
{
return m_timestamp;
}
qulonglong EpisodeActionPrivate::started() const
{
return m_started;
}
qulonglong EpisodeActionPrivate::position() const
{
return m_position;
}
qulonglong EpisodeActionPrivate::total() const
{
return m_total;
}
// ### End of EpisodeActionPrivate
EpisodeAction::EpisodeAction( const QVariant& variant, QObject* parent ): QObject( parent ), d( new EpisodeActionPrivate( this, variant ) )
{
}
EpisodeAction::EpisodeAction( const QUrl& podcastUrl, const QUrl& episodeUrl, const QString& deviceName, EpisodeAction::ActionType action, qulonglong timestamp, qulonglong started, qulonglong position, qulonglong total, QObject* parent )
: QObject( parent ), d( new EpisodeActionPrivate( this, podcastUrl, episodeUrl, deviceName, action, timestamp, started, position, total ) )
{
}
EpisodeAction::~EpisodeAction()
{
delete d;
}
QUrl EpisodeAction::podcastUrl() const
{
return d->podcastUrl();
}
QUrl EpisodeAction::episodeUrl() const
{
return d->episodeUrl();
}
QString EpisodeAction::deviceName() const
{
return d->deviceName();
}
EpisodeAction::ActionType EpisodeAction::action() const
{
return d->action();
}
qulonglong EpisodeAction::timestamp() const
{
return d->timestamp();
}
qulonglong EpisodeAction::started() const
{
return d->started();
}
qulonglong EpisodeAction::position() const
{
return d->position();
}
qulonglong EpisodeAction::total() const
{
return d->total();
}

78
3rdparty/libmygpo-qt/EpisodeAction.h vendored Normal file
View File

@ -0,0 +1,78 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef EPISODEACTION_H
#define EPISODEACTION_H
#include <QUrl>
#include <QString>
#include <QNetworkReply>
#include <QSharedPointer>
#include "mygpo_export.h"
namespace mygpo
{
class EpisodeActionPrivate;
class MYGPO_EXPORT EpisodeAction : public QObject
{
Q_OBJECT
Q_ENUMS( ActionType )
Q_PROPERTY( QUrl podcastUrl READ podcastUrl CONSTANT )
Q_PROPERTY( QUrl episodeUrl READ episodeUrl CONSTANT )
Q_PROPERTY( QString deviceName READ deviceName CONSTANT )
Q_PROPERTY( ActionType action READ action CONSTANT )
Q_PROPERTY( qulonglong timestamp READ timestamp CONSTANT )
Q_PROPERTY( qulonglong started READ started CONSTANT )
Q_PROPERTY( qulonglong position READ position CONSTANT )
Q_PROPERTY( qulonglong total READ total CONSTANT )
public:
enum ActionType { Download, Play, Delete, New };
EpisodeAction( const QVariant& variant, QObject* parent = 0 );
EpisodeAction( const QUrl& podcastUrl, const QUrl& episodeUrl, const QString& deviceName, EpisodeAction::ActionType action, qulonglong timestamp, qulonglong started, qulonglong position, qulonglong total, QObject* parent = 0 );
virtual ~EpisodeAction();
QUrl podcastUrl() const;
QUrl episodeUrl() const;
QString deviceName() const;
EpisodeAction::ActionType action() const;
qulonglong timestamp() const;
qulonglong started() const;
qulonglong position() const;
qulonglong total() const;
private:
Q_DISABLE_COPY( EpisodeAction )
EpisodeActionPrivate* const d;
friend class EpisodeActionPrivate;
};
typedef QSharedPointer<EpisodeAction> EpisodeActionPtr;
}
Q_DECLARE_METATYPE( mygpo::EpisodeActionPtr );
#endif // EPISODEACTION_H

View File

@ -0,0 +1,148 @@
/***************************************************************************
* 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 "EpisodeActionList_p.h"
#include <qjson/parser.h>
using namespace mygpo;
EpisodeActionListPrivate::EpisodeActionListPrivate( EpisodeActionList* qq, QNetworkReply* reply ): m_reply( reply ), q( qq ), m_error( QNetworkReply::NoError )
{
QObject::connect( m_reply, SIGNAL( finished() ), this, SLOT( parseData() ) );
QObject::connect( m_reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( error( QNetworkReply::NetworkError ) ) );
}
EpisodeActionListPrivate::~EpisodeActionListPrivate()
{
}
QList<EpisodeActionPtr> EpisodeActionListPrivate::list() const
{
QList<EpisodeActionPtr> list;
QVariantList varList = m_episodeActions.toList();
foreach( QVariant var, varList )
{
list.append( var.value<mygpo::EpisodeActionPtr>() );
}
return list;
}
QVariant EpisodeActionListPrivate::episodeActions() const
{
return m_episodeActions;
}
bool EpisodeActionListPrivate::parse( const QVariant& data )
{
if( !data.canConvert( QVariant::Map ) )
return false;
QVariantMap episodeActionListMap = data.toMap();
QVariant s = episodeActionListMap.value( QLatin1String( "timestamp" ) );
if( !s.canConvert( QVariant::ULongLong ) )
return false;
m_timestamp = s.toULongLong();
s = episodeActionListMap.value( QLatin1String( "actions" ) );
if( !s.canConvert( QVariant::List ) )
return false;
QVariantList varList = s.toList();
QVariantList episodeActionList;
foreach( QVariant var, varList )
{
QVariant v;
v.setValue<mygpo::EpisodeActionPtr> ( mygpo::EpisodeActionPtr( new EpisodeAction( var ) ) );
episodeActionList.append( v );
}
m_episodeActions = QVariant( episodeActionList );
return true;
}
bool EpisodeActionListPrivate::parse( const QByteArray& data )
{
QJson::Parser parser;
bool ok;
QVariant variant = parser.parse( data, &ok );
if( ok )
{
ok = ( parse( variant ) );
}
return ok;
}
void EpisodeActionListPrivate::parseData()
{
if( m_reply->error() == QNetworkReply::NoError )
{
if( parse( m_reply->readAll() ) )
{
emit q->finished();
}
else
{
emit q->parseError();
}
}
m_reply->deleteLater();
}
qulonglong EpisodeActionListPrivate::timestamp() const
{
return m_timestamp;
}
void EpisodeActionListPrivate::error( QNetworkReply::NetworkError error )
{
this->m_error = error;
emit q->requestError( error );
}
// ### End of EpisodeActionListPrivate
EpisodeActionList::EpisodeActionList( QNetworkReply* reply, QObject* parent ) : QObject( parent ), d( new EpisodeActionListPrivate( this, reply ) )
{
}
QVariant EpisodeActionList::episodeActions() const
{
return d->episodeActions();
}
QList< EpisodeActionPtr > EpisodeActionList::list() const
{
return d->list();
}
qulonglong EpisodeActionList::timestamp() const
{
return d->timestamp();
}
EpisodeActionList::~EpisodeActionList()
{
delete d;
}

View File

@ -0,0 +1,71 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef EPISODEACTIONLIST_H
#define EPISODEACTIONLIST_H
#include "EpisodeAction.h"
#include "mygpo_export.h"
#include <QNetworkReply>
#include <QList>
#include <QVariant>
namespace mygpo
{
class EpisodeActionListPrivate;
class MYGPO_EXPORT EpisodeActionList : public QObject
{
Q_OBJECT
Q_PROPERTY( QVariant episodeActions READ episodeActions CONSTANT )
Q_PROPERTY( qulonglong timestamp READ timestamp CONSTANT )
public:
EpisodeActionList( QNetworkReply* reply, QObject* parent = 0 );
virtual ~EpisodeActionList();
QList<EpisodeActionPtr> list() const;
QVariant episodeActions() const;
qulonglong timestamp() const;
private:
EpisodeActionListPrivate* const d;
friend class EpisodeActionListPrivate;
signals:
/**Gets emitted when the data is ready to read*/
void finished();
/**Gets emitted when an parse error ocurred*/
void parseError();
/**Gets emitted when an request error ocurred*/
void requestError( QNetworkReply::NetworkError error );
};
typedef QSharedPointer<EpisodeActionList> EpisodeActionListPtr;
}
Q_DECLARE_METATYPE( mygpo::EpisodeActionListPtr );
#endif // EPISODEACTIONLIST_H

View File

@ -0,0 +1,61 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef EPISODEACTIONLIST_PRIVATE_H
#define EPISODEACTIONLIST_PRIVATE_H
#include "EpisodeActionList.h"
namespace mygpo
{
class EpisodeActionListPrivate : public QObject
{
Q_OBJECT
public:
EpisodeActionListPrivate( EpisodeActionList* qq, QNetworkReply* reply );
virtual ~EpisodeActionListPrivate();
QList<EpisodeActionPtr> list() const;
QVariant episodeActions() const;
qulonglong timestamp() const;
private:
QNetworkReply* m_reply;
EpisodeActionList* const q;
QVariant m_episodeActions;
QNetworkReply::NetworkError m_error;
qulonglong m_timestamp;
bool parse( const QVariant& data );
bool parse( const QByteArray& data );
private slots:
void parseData();
void error( QNetworkReply::NetworkError error );
};
}
#endif //EPISODEACTIONLIST_PRIVATE_H

67
3rdparty/libmygpo-qt/EpisodeAction_p.h vendored Normal file
View File

@ -0,0 +1,67 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef EPISODEACTION_PRIVATE_H
#define EPISODEACTION_PRIVATE_H
#include "EpisodeAction.h"
namespace mygpo
{
class EpisodeActionPrivate : QObject
{
Q_OBJECT
public:
EpisodeActionPrivate( EpisodeAction* qq, const QVariant& variant, QObject* parent = 0 );
EpisodeActionPrivate( EpisodeAction* qq, const QUrl& podcastUrl, const QUrl& episodeUrl, const QString& deviceName, EpisodeAction::ActionType action, qulonglong timestamp, qulonglong started, qulonglong position, qulonglong total, QObject* parent = 0 );
virtual ~EpisodeActionPrivate();
QUrl podcastUrl() const;
QUrl episodeUrl() const;
QString deviceName() const;
EpisodeAction::ActionType action() const;
qulonglong timestamp() const;
qulonglong started() const;
qulonglong position() const;
qulonglong total() const;
private:
EpisodeAction* const q;
QUrl m_podcastUrl;
QUrl m_episodeUrl;
QString m_deviceName;
EpisodeAction::ActionType m_action;
qulonglong m_timestamp;
qulonglong m_started;
qulonglong m_position;
qulonglong m_total;
bool parse( const QVariant& data );
bool parse( const QByteArray& data );
bool parseActionType( const QString& data );
};
}
#endif //EPISODEACTION_PRIVATE_H

128
3rdparty/libmygpo-qt/EpisodeList.cpp vendored Normal file
View File

@ -0,0 +1,128 @@
/***************************************************************************
* 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 "EpisodeList_p.h"
#include <qjson/parser.h>
using namespace mygpo;
EpisodeListPrivate::EpisodeListPrivate( EpisodeList* qq, QNetworkReply* reply ): m_reply( reply ), q( qq ), m_error( QNetworkReply::NoError )
{
QObject::connect( m_reply, SIGNAL( finished() ), this, SLOT( parseData() ) );
QObject::connect( m_reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( error( QNetworkReply::NetworkError ) ) );
}
EpisodeListPrivate::~EpisodeListPrivate()
{
}
QList<EpisodePtr> EpisodeListPrivate::list() const
{
QList<EpisodePtr> list;
QVariantList varList = m_episodes.toList();
foreach( QVariant var, varList )
{
list.append( var.value<mygpo::EpisodePtr>() );
}
return list;
}
QVariant EpisodeListPrivate::episodes() const
{
return m_episodes;
}
bool EpisodeListPrivate::parse( const QVariant& data )
{
if( !data.canConvert( QVariant::List ) )
return false;
QVariantList varList = data.toList();
QVariantList episodeList;
foreach( QVariant var, varList )
{
QVariant v;
v.setValue<mygpo::EpisodePtr> ( EpisodePtr( new Episode( var ) ) );
episodeList.append( v );
}
m_episodes = QVariant( episodeList );
return true;
}
bool EpisodeListPrivate::parse( const QByteArray& data )
{
QJson::Parser parser;
bool ok;
QVariant variant = parser.parse( data, &ok );
if( ok )
{
ok = ( parse( variant ) );
}
return ok;
}
void EpisodeListPrivate::parseData()
{
if( m_reply->error() == QNetworkReply::NoError )
{
if( parse( m_reply->readAll() ) )
{
emit q->finished();
}
else
{
emit q->parseError();
}
}
m_reply->deleteLater();
}
void EpisodeListPrivate::error( QNetworkReply::NetworkError error )
{
this->m_error = error;
emit q->requestError( error );
}
EpisodeList::EpisodeList( QNetworkReply* reply, QObject* parent ) : QObject( parent ), d( new EpisodeListPrivate( this, reply ) )
{
}
QVariant EpisodeList::episodes() const
{
return d->episodes();
}
QList< EpisodePtr > EpisodeList::list() const
{
return d->list();
}
EpisodeList::~EpisodeList()
{
delete d;
}

66
3rdparty/libmygpo-qt/EpisodeList.h vendored Normal file
View File

@ -0,0 +1,66 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef EPISODELIST_H
#define EPISODELIST_H
#include "mygpo_export.h"
#include "Episode.h"
#include <QNetworkReply>
#include <QList>
#include <QVariant>
namespace mygpo
{
class EpisodeListPrivate;
class MYGPO_EXPORT EpisodeList : public QObject
{
Q_OBJECT
Q_PROPERTY( QVariant episodes READ episodes CONSTANT )
public:
EpisodeList( QNetworkReply* reply, QObject* parent = 0 );
//EpisodeList(const EpisodeList& other);
virtual ~EpisodeList();
QList<EpisodePtr> list() const;
QVariant episodes() const;
private:
EpisodeListPrivate* const d;
friend class EpisodeListPrivate;
signals:
/**Gets emitted when the data is ready to read*/
void finished();
/**Gets emitted when an parse error ocurred*/
void parseError();
/**Gets emitted when an request error ocurred*/
void requestError( QNetworkReply::NetworkError error );
};
typedef QSharedPointer<EpisodeList> EpisodeListPtr;
}
#endif // EPISODELIST_H

57
3rdparty/libmygpo-qt/EpisodeList_p.h vendored Normal file
View File

@ -0,0 +1,57 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef EPISODELIST_PRIVATE_H
#define EPISODELIST_PRIVATE_H
#include "EpisodeList.h"
namespace mygpo
{
class EpisodeListPrivate : QObject
{
Q_OBJECT
public:
EpisodeListPrivate( EpisodeList* qq, QNetworkReply* reply );
virtual ~EpisodeListPrivate();
QList<EpisodePtr> list() const;
QVariant episodes() const;
private:
QNetworkReply* m_reply;
EpisodeList* const q;
QVariant m_episodes;
QNetworkReply::NetworkError m_error;
bool parse( const QVariant& data );
bool parse( const QByteArray& data );
private slots:
void parseData();
void error( QNetworkReply::NetworkError error );
};
};
#endif // EPISODELIST_PRIVATE_H

71
3rdparty/libmygpo-qt/Episode_p.h vendored Normal file
View File

@ -0,0 +1,71 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef EPISODE_PRIVATE_H
#define EPISODE_PRIVATE_H
#include "Episode.h"
namespace mygpo
{
class EpisodePrivate : QObject
{
Q_OBJECT
public:
EpisodePrivate ( Episode* qq, QNetworkReply* reply, QObject* parent = 0 );
EpisodePrivate ( Episode* qq, const QVariant& variant, QObject* parent = 0 );
virtual ~EpisodePrivate();
QUrl url() const;
QString title() const;
QUrl podcastUrl() const;
QString podcastTitle() const;
QString description() const;
QUrl website() const;
QUrl mygpoUrl() const;
QDateTime releaded() const;
Episode::Status status() const;
private:
QNetworkReply* m_reply;
Episode* const q;
QUrl m_url;
QString m_title;
QUrl m_podcastUrl;
QString m_podcastTitle;
QString m_description;
QUrl m_website;
QUrl m_mygpoUrl;
QDateTime m_released;
Episode::Status m_status;
QNetworkReply::NetworkError m_error;
bool parse ( const QVariant& data );
bool parse ( const QByteArray& data );
private slots:
void parseData();
void error ( QNetworkReply::NetworkError error );
};
};
#endif // EPISODE_PRIVATE_H

149
3rdparty/libmygpo-qt/JsonCreator.cpp vendored Normal file
View File

@ -0,0 +1,149 @@
/***************************************************************************
* 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 <QVariant>
#include <QList>
#include <QUrl>
#include <QString>
#include <QDateTime>
#include <qjson/serializer.h>
#include "JsonCreator.h"
using namespace mygpo;
QByteArray JsonCreator::addRemoveSubsToJSON( const QList< QUrl >& add, const QList< QUrl >& remove )
{
QJson::Serializer serializer;
QVariantMap jsonData;
QVariant addVar( urlListToQVariantList( add ) );
QVariant removeVar( urlListToQVariantList( remove ) );
jsonData.insert( QString( QLatin1String( "add" ) ), addVar );
jsonData.insert( QString( QLatin1String( "remove" ) ), removeVar );
QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) );
return jsonByteArray;
}
QByteArray JsonCreator::saveSettingsToJSON( const QMap< QString, QVariant >& set, const QList< QString >& remove )
{
QJson::Serializer serializer;
QVariantMap jsonData;
//QVariant setVar(stringMapToQVariantMap(set));
QVariant removeVar( stringListToQVariantList( remove ) );
jsonData.insert( QString( QLatin1String( "set" ) ), set );
jsonData.insert( QString( QLatin1String( "remove" ) ), removeVar );
QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) );
return jsonByteArray;
}
QByteArray JsonCreator::episodeActionListToJSON( const QList<EpisodeActionPtr>& episodeActions )
{
QJson::Serializer serializer;
QVariantList jsonData;
foreach( const EpisodeActionPtr episodeAction, episodeActions )
{
jsonData.append( episodeActionToQVariantMap( episodeAction ) );
}
QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) );
return jsonByteArray;
}
QByteArray mygpo::JsonCreator::renameDeviceStringToJSON( const QString& caption, const QString& type )
{
QJson::Serializer serializer;
QVariantMap jsonData;
QVariant captionVar( caption );
QVariant typeVar( type );
jsonData.insert( QString( QLatin1String( "caption" ) ), captionVar );
jsonData.insert( QString( QLatin1String( "type" ) ), typeVar );
QByteArray jsonByteArray = serializer.serialize( QVariant( jsonData ) );
return jsonByteArray;
}
QVariantList JsonCreator::urlListToQVariantList( const QList< QUrl >& urls )
{
QVariantList list;
foreach( const QUrl & url, urls )
{
QVariant var( url.toString() );
if( !list.contains( var ) )
list.append( var );
}
return list;
}
QVariantList JsonCreator::stringListToQVariantList( const QList< QString >& strings )
{
QVariantList list;
foreach( const QString & str, strings )
{
QVariant var( str );
list.append( var );
}
return list;
}
QVariantMap mygpo::JsonCreator::stringMapToQVariantMap( const QMap< QString, QString >& stringmap )
{
QVariantMap map;
foreach( const QString & str, stringmap.keys() )
{
map.insert( str, QVariant( stringmap.value( str ) ) );
}
return map;
}
QVariantMap JsonCreator::episodeActionToQVariantMap( const EpisodeActionPtr episodeAction )
{
QVariantMap map;
map.insert( QLatin1String( "podcast" ), episodeAction->podcastUrl() );
map.insert( QLatin1String( "episode" ), episodeAction->episodeUrl() );
if( episodeAction->deviceName().compare( QLatin1String( "" ) ) != 0 )
map.insert( QLatin1String( "device" ), episodeAction->deviceName() );
EpisodeAction::ActionType actionType = episodeAction->action();
if( actionType == EpisodeAction::New )
map.insert( QLatin1String( "action" ), QLatin1String( "new" ) );
else if( actionType == EpisodeAction::Delete )
map.insert( QLatin1String( "action" ), QLatin1String( "delete" ) );
else if( actionType == EpisodeAction::Play )
map.insert( QLatin1String( "action" ), QLatin1String( "play" ) );
else if( actionType == EpisodeAction::Download )
map.insert( QLatin1String( "action" ), QLatin1String( "download" ) );
if( episodeAction->timestamp() != 0 ) {
QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(episodeAction->timestamp() );
map.insert( QLatin1String( "timestamp" ), dateTime.toString(Qt::ISODate) );
}
if( episodeAction->started() != 0 )
map.insert( QLatin1String( "started" ), episodeAction->started() );
if( episodeAction->position() != 0 )
map.insert( QLatin1String( "position" ), episodeAction->position() );
if( episodeAction->total() != 0 )
map.insert( QLatin1String( "total" ), episodeAction->total() );
return map;
}

56
3rdparty/libmygpo-qt/JsonCreator.h vendored Normal file
View File

@ -0,0 +1,56 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef JSONPARSER_H
#define JSONPARSER_H
#include <QByteArray>
#include <QVariant>
#include <QList>
#include <QMap>
#include "EpisodeAction.h"
class QUrl;
class QString;
namespace mygpo
{
class JsonCreator
{
public:
static QByteArray addRemoveSubsToJSON( const QList<QUrl>& add, const QList<QUrl>& remove );
static QByteArray saveSettingsToJSON( const QMap<QString, QVariant >& set, const QList<QString>& remove );
static QByteArray episodeActionListToJSON( const QList<EpisodeActionPtr>& episodeActions );
static QByteArray renameDeviceStringToJSON( const QString& caption, const QString& type );
private:
static QVariantList urlListToQVariantList( const QList<QUrl>& urls );
static QVariantList stringListToQVariantList( const QList<QString>& strings );
static QVariantMap stringMapToQVariantMap( const QMap<QString, QString >& stringmap );
static QVariantMap episodeActionToQVariantMap( const EpisodeActionPtr episodeAction );
};
}
#endif // JSONPARSER_H

217
3rdparty/libmygpo-qt/Podcast.cpp vendored Normal file
View File

@ -0,0 +1,217 @@
/***************************************************************************
* 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 "Podcast_p.h"
#include <qjson/parser.h>
using namespace mygpo;
PodcastPrivate::PodcastPrivate( Podcast* qq, QNetworkReply* reply ): m_reply( reply ), q( qq ), m_error( QNetworkReply::NoError )
{
QObject::connect( m_reply, SIGNAL( finished() ), this, SLOT( parseData() ) );
QObject::connect( m_reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( error( QNetworkReply::NetworkError ) ) );
}
PodcastPrivate::PodcastPrivate( Podcast* qq, const QVariant& variant ): m_reply( 0 ), q( qq ), m_error( QNetworkReply::NoError )
{
parse( variant );
}
PodcastPrivate::~PodcastPrivate()
{
}
QUrl PodcastPrivate::url() const
{
return m_url;
}
QString PodcastPrivate::title() const
{
return m_title;
}
QString PodcastPrivate::description() const
{
return m_description;
}
uint PodcastPrivate::subscribers() const
{
return m_subscribers;
}
uint PodcastPrivate::subscribersLastWeek() const
{
return m_SubscribersLastWeek;
}
QUrl PodcastPrivate::logoUrl() const
{
return m_logoUrl;
}
QUrl PodcastPrivate::website() const
{
return m_website;
}
QUrl PodcastPrivate::mygpoUrl() const
{
return m_mygpoUrl;
}
Podcast::Podcast( QNetworkReply* reply, QObject* parent ) : QObject( parent ), d( new PodcastPrivate( this, reply ) )
{
}
Podcast::Podcast( const QVariant& variant, QObject* parent ): QObject( parent ), d( new PodcastPrivate( this, variant ) )
{
}
Podcast::~Podcast()
{
delete d;
}
QUrl Podcast::url() const
{
return d->url();
}
QString Podcast::title() const
{
return d->title();
}
QString Podcast::description() const
{
return d->description();
}
uint Podcast::subscribers() const
{
return d->subscribers();
}
uint Podcast::subscribersLastWeek() const
{
return d->subscribersLastWeek();
}
QUrl Podcast::logoUrl() const
{
return d->logoUrl();
}
QUrl Podcast::website() const
{
return d->website();
}
QUrl Podcast::mygpoUrl() const
{
return d->mygpoUrl();
}
bool PodcastPrivate::parse( const QVariant& data )
{
if ( !data.canConvert( QVariant::Map ) )
return false;
QVariantMap podcastMap = data.toMap();
QVariant v = podcastMap.value( QLatin1String( "url" ) );
if ( !v.canConvert( QVariant::Url ) )
return false;
m_url = v.toUrl();
v = podcastMap.value( QLatin1String( "title" ) );
if ( !v.canConvert( QVariant::String ) )
return false;
m_title = v.toString();
v = podcastMap.value( QLatin1String( "description" ) );
if ( !v.canConvert( QVariant::String ) )
return false;
m_description = v.toString();
v = podcastMap.value( QLatin1String( "subscribers" ) );
if ( !v.canConvert( QVariant::Int ) )
return false;
m_subscribers = v.toUInt();
v = podcastMap.value( QLatin1String( "subscribers_last_week" ) );
if ( !v.canConvert( QVariant::Int ) )
return false;
m_SubscribersLastWeek = v.toUInt();
v = podcastMap.value( QLatin1String( "logo_url" ) );
if ( !v.canConvert( QVariant::Url ) )
return false;
m_logoUrl = v.toUrl();
v = podcastMap.value( QLatin1String( "website" ) );
if ( !v.canConvert( QVariant::Url ) )
return false;
m_website = v.toUrl();
v = podcastMap.value( QLatin1String( "mygpo_link" ) );
if ( !v.canConvert( QVariant::Url ) )
return false;
m_mygpoUrl = v.toUrl();
return true;
}
bool PodcastPrivate::parse( const QByteArray& data )
{
QJson::Parser parser;
bool ok;
QVariant variant = parser.parse( data, &ok );
if ( ok )
{
if ( !parse( variant ) ) return false;
return true;
}
else
{
return false;
}
}
void PodcastPrivate::parseData()
{
//parsen und signal senden
QJson::Parser parser;
if ( parse( m_reply->readAll( ) ) )
{
emit q->finished();
}
else
{
emit q->parseError();
}
m_reply->deleteLater();
}
void PodcastPrivate::error( QNetworkReply::NetworkError error )
{
this->m_error = error;
emit q->requestError( error );
}

84
3rdparty/libmygpo-qt/Podcast.h vendored Normal file
View File

@ -0,0 +1,84 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef PODCAST_H
#define PODCAST_H
#include <QUrl>
#include <QString>
#include <QNetworkReply>
#include <QSharedPointer>
#include "mygpo_export.h"
namespace mygpo
{
class PodcastPrivate;
class MYGPO_EXPORT Podcast : public QObject
{
Q_OBJECT
Q_PROPERTY( QUrl url READ url CONSTANT )
Q_PROPERTY( QString title READ title CONSTANT )
Q_PROPERTY( QString description READ description CONSTANT )
Q_PROPERTY( uint subscribers READ subscribers CONSTANT )
Q_PROPERTY( uint subscribersLastWeek READ subscribersLastWeek CONSTANT )
Q_PROPERTY( QUrl logoUrl READ logoUrl CONSTANT )
Q_PROPERTY( QUrl website READ website CONSTANT )
Q_PROPERTY( QUrl mygpoUrl READ mygpoUrl CONSTANT )
public:
Podcast( QNetworkReply* reply, QObject* parent = 0 );
Podcast( const QVariant& variant, QObject* parent = 0 );
virtual ~Podcast();
//Getters
QUrl url() const;
QString title() const;
QString description() const;
uint subscribers() const;
uint subscribersLastWeek() const;
QUrl logoUrl() const;
QUrl website() const;
QUrl mygpoUrl() const;
private:
Q_DISABLE_COPY( Podcast )
PodcastPrivate* const d;
friend class PodcastPrivate;
bool m_copy; //true if this object was created by the copy-ctor
signals:
/**Gets emitted when the data is ready to read*/
void finished();
/**Gets emitted when an parse error ocurred*/
void parseError();
/**Gets emitted when an request error ocurred*/
void requestError( QNetworkReply::NetworkError error );
};
typedef QSharedPointer<Podcast> PodcastPtr;
}
Q_DECLARE_METATYPE( mygpo::PodcastPtr );
#endif // PODCAST_H

124
3rdparty/libmygpo-qt/PodcastList.cpp vendored Normal file
View File

@ -0,0 +1,124 @@
/***************************************************************************
* 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 "PodcastList_p.h"
#include <qjson/parser.h>
using namespace mygpo;
PodcastListPrivate::PodcastListPrivate( PodcastList* qq, QNetworkReply* reply, QObject* parent ) : QObject( parent ), m_reply( reply ), q( qq ), m_error( QNetworkReply::NoError )
{
QObject::connect( m_reply, SIGNAL( finished() ), this, SLOT( parseData() ) );
QObject::connect( m_reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( error( QNetworkReply::NetworkError ) ) );
}
PodcastListPrivate::~PodcastListPrivate()
{
}
QList< PodcastPtr > PodcastListPrivate::list() const
{
QList<PodcastPtr> list;
QVariantList varList = m_podcasts.toList();
foreach( QVariant var, varList )
{
list.append( var.value<mygpo::PodcastPtr>() );
}
return list;
}
QVariant PodcastListPrivate::podcasts() const
{
return m_podcasts;
}
bool PodcastListPrivate::parse( const QVariant& data )
{
if( !data.canConvert( QVariant::List ) )
return false;
QVariantList varList = data.toList();
QVariantList podcastList;
foreach( QVariant var, varList )
{
QVariant v;
v.setValue<mygpo::PodcastPtr> ( PodcastPtr( new Podcast( var ) ) );
podcastList.append( v );
}
m_podcasts = QVariant( podcastList );
return true;
}
bool PodcastListPrivate::parse( const QByteArray& data )
{
QJson::Parser parser;
bool ok;
QVariant variant = parser.parse( data, &ok );
if( ok )
{
ok = ( parse( variant ) );
}
return ok;
}
void PodcastListPrivate::parseData()
{
if( m_reply->error() == QNetworkReply::NoError )
{
if( parse( m_reply->readAll() ) )
{
emit q->finished();
}
else
{
emit q->parseError();
}
}
m_reply->deleteLater();
}
void PodcastListPrivate::error( QNetworkReply::NetworkError error )
{
this->m_error = error;
emit q->requestError( error );
}
PodcastList::PodcastList( QNetworkReply* reply, QObject* parent ) : QObject( parent ), d( new PodcastListPrivate( this, reply ) )
{
}
PodcastList::~PodcastList()
{
delete d;
}
QList<PodcastPtr> PodcastList::list() const
{
return d->list();
}
QVariant PodcastList::podcasts() const
{
return d->podcasts();
}

67
3rdparty/libmygpo-qt/PodcastList.h vendored Normal file
View File

@ -0,0 +1,67 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef PODCASTLIST_H
#define PODCASTLIST_H
#include "Podcast.h"
#include "mygpo_export.h"
#include <QNetworkReply>
#include <QSharedPointer>
#include <QList>
namespace mygpo
{
class PodcastListPrivate;
class MYGPO_EXPORT PodcastList : public QObject
{
Q_OBJECT
Q_PROPERTY( QVariant podcasts READ podcasts CONSTANT )
public:
PodcastList( QNetworkReply* reply, QObject* parent = 0 );
virtual ~PodcastList();
QList<PodcastPtr> list() const;
QVariant podcasts() const;
private:
Q_DISABLE_COPY( PodcastList )
PodcastListPrivate* const d;
friend class PodcastListPrivate;
signals:
/**Gets emitted when the data is ready to read*/
void finished();
/**Gets emitted when an parse error ocurred*/
void parseError();
/**Gets emitted when an request error ocurred*/
void requestError( QNetworkReply::NetworkError error );
};
typedef QSharedPointer<PodcastList> PodcastListPtr;
}
#endif // PODCASTLIST_H

55
3rdparty/libmygpo-qt/PodcastList_p.h vendored Normal file
View File

@ -0,0 +1,55 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef PODCASTLIST_PRIVATE_H
#define PODCASTLIST_PRIVATE_H
#include "PodcastList.h"
namespace mygpo
{
class PodcastListPrivate : QObject
{
Q_OBJECT
public:
PodcastListPrivate( PodcastList* qq, QNetworkReply* reply, QObject* parent = 0 );
virtual ~PodcastListPrivate();
QList<PodcastPtr> list() const;
QVariant podcasts() const;
private:
QNetworkReply* m_reply;
PodcastList* const q;
QVariant m_podcasts;
QNetworkReply::NetworkError m_error;
bool parse( const QVariant& data );
bool parse( const QByteArray& data );
private slots:
void parseData();
void error( QNetworkReply::NetworkError error );
};
}
#endif // PODCASLIST_PRIVATE_H

71
3rdparty/libmygpo-qt/Podcast_p.h vendored Normal file
View File

@ -0,0 +1,71 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef PODCAST_PRIVATE_H
#define PODCAST_PRIVATE_H
#include "Podcast.h"
namespace mygpo
{
class PodcastPrivate : QObject
{
Q_OBJECT
public:
PodcastPrivate( Podcast* qq, QNetworkReply* reply );
PodcastPrivate( Podcast* qq, const QVariant& variant );
virtual ~PodcastPrivate();
//Getters
QUrl url() const;
QString title() const;
QString description() const;
uint subscribers() const;
uint subscribersLastWeek() const;
QUrl logoUrl() const;
QUrl website() const;
QUrl mygpoUrl() const;
private:
QNetworkReply* m_reply;
Podcast* const q;
QUrl m_url;
QString m_title;
QString m_description;
uint m_subscribers;
uint m_SubscribersLastWeek;
QUrl m_logoUrl;
QUrl m_website;
QUrl m_mygpoUrl;
QNetworkReply::NetworkError m_error;
bool parse( const QVariant& data );
bool parse( const QByteArray& data );
private slots:
void parseData();
void error( QNetworkReply::NetworkError error );
};
};
#endif // PODCAST_PRIVATE_H

71
3rdparty/libmygpo-qt/RequestHandler.cpp vendored Normal file
View File

@ -0,0 +1,71 @@
/***************************************************************************
* 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 <QAuthenticator>
#include <QCoreApplication>
#include "RequestHandler.h"
using namespace mygpo;
RequestHandler::RequestHandler( const QString& username, const QString& password, QNetworkAccessManager* nam ) : m_username( username ), m_password( password ), m_nam( nam )
{
}
RequestHandler::RequestHandler( QNetworkAccessManager* nam ) : m_username(), m_password(), m_nam( nam )
{
}
RequestHandler::~RequestHandler()
{
}
QNetworkReply* RequestHandler::getRequest( const QString& url )
{
QUrl reqUrl( url );
QNetworkRequest request( reqUrl );
QNetworkReply* reply = m_nam->get( request );
return reply;
}
QNetworkReply* RequestHandler::authGetRequest( const QString& url )
{
QNetworkRequest request( url );
addAuthData( request );
QNetworkReply* reply = m_nam->get( request );
return reply;
}
QNetworkReply* RequestHandler::postRequest( const QByteArray data, const QString& url )
{
QNetworkRequest request( url );
addAuthData( request );
QNetworkReply* reply = m_nam->post( request, data );
return reply;
}
void RequestHandler::addAuthData( QNetworkRequest& request )
{
QByteArray headerData = "Basic " + QString(m_username + QLatin1String(":") + m_password).toLocal8Bit().toBase64();
request.setRawHeader("Authorization", headerData );
}

85
3rdparty/libmygpo-qt/RequestHandler.h vendored Normal file
View File

@ -0,0 +1,85 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef REQUESTHANDLER_H_
#define REQUESTHANDLER_H_
#include "mygpo_export.h"
#include <QNetworkAccessManager>
#include <QNetworkReply>
namespace mygpo
{
/**
* Class for sending HTTP requests and handle the servers response.
*/
class RequestHandler
{
public:
/**
* @param username The username that should be used for authentication if required.
* @param password The password that should be used for authentication if required
*/
RequestHandler( const QString& username, const QString& password, QNetworkAccessManager* nam );
RequestHandler( QNetworkAccessManager* nam );
virtual ~RequestHandler();
/**
* Sends a GET request with the given url and receives the servers response.
* @param response The servers response will be written into this QByteArray
* @param url The request url (without http://) as QString
* @return 0 if the request was successful, corresponding ErrorCode if unsuccessful
*/
QNetworkReply* getRequest( const QString& url );
/**
* Sends a GET request with the given url, adds auth Data to the URL and receives the servers response.
* @param response The servers response will be written into this QByteArray
* @param url The request url (without http://) as QString
* @return 0 if the request was successful, corresponding ErrorCode if unsuccessful
*/
QNetworkReply* authGetRequest( const QString& url );
/**
* Sends a POST request with the given url and data, adds auth Data and receives the servers response
* @param data The data to send to the url
* @param url The request url (without http://) as QString
* @return 0 if the request was successful, corresponding ErrorCode if unsuccessful
*/
QNetworkReply* postRequest( const QByteArray data, const QString& url );
private:
QString m_username;
QString m_password;
QNetworkAccessManager* m_nam;
void addAuthData( QNetworkRequest& url );
};
}
#endif /* REQUESTHANDLER_H_ */

99
3rdparty/libmygpo-qt/Settings.cpp vendored Normal file
View File

@ -0,0 +1,99 @@
/***************************************************************************
* 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 "Settings_p.h"
#include <qjson/parser.h>
using namespace mygpo;
SettingsPrivate::SettingsPrivate( Settings* qq, QNetworkReply* reply ): q( qq ), m_reply( reply ), m_error( QNetworkReply::NoError )
{
QObject::connect( m_reply, SIGNAL( finished() ), this, SLOT( parseData() ) );
QObject::connect( m_reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( error( QNetworkReply::NetworkError ) ) );
}
SettingsPrivate::~SettingsPrivate()
{
}
QVariant SettingsPrivate::settings() const
{
return m_settings;
}
bool SettingsPrivate::parse( const QVariant& data )
{
m_settings = data;
return true;
}
bool SettingsPrivate::parse( const QByteArray& data )
{
QJson::Parser parser;
bool ok;
QVariant variant = parser.parse( data, &ok );
if( ok )
{
ok = ( parse( variant ) );
}
return ok;
}
void SettingsPrivate::parseData()
{
if( m_reply->error() == QNetworkReply::NoError )
{
QJson::Parser parser;
if( parse( m_reply->readAll() ) )
{
emit q->finished();
}
else
{
emit q->parseError();
}
}
m_reply->deleteLater();
}
void SettingsPrivate::error( QNetworkReply::NetworkError error )
{
this->m_error = error;
emit q->requestError( error );
}
Settings::Settings( QNetworkReply* reply, QObject* parent ): QObject( parent ), d( new SettingsPrivate( this, reply ) )
{
}
Settings::~Settings()
{
delete d;
}
QVariant Settings::settings() const
{
return d->settings();
}

66
3rdparty/libmygpo-qt/Settings.h vendored Normal file
View File

@ -0,0 +1,66 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef SETTINGS_H
#define SETTINGS_H
#include <QSharedPointer>
#include <QMap>
#include <QNetworkReply>
class QVariant;
#include "mygpo_export.h"
namespace mygpo
{
class SettingsPrivate;
class MYGPO_EXPORT Settings : public QObject
{
Q_OBJECT
Q_PROPERTY( QVariant settings READ settings CONSTANT )
public:
Settings( QNetworkReply* reply, QObject* parent = 0 );
virtual ~Settings();
QVariant settings() const;
private:
Q_DISABLE_COPY( Settings )
SettingsPrivate* d;
friend class SettingsPrivate;
signals:
/**Gets emitted when the data is ready to read*/
void finished();
/**Gets emitted when an parse error ocurred*/
void parseError();
/**Gets emitted when an request error ocurred*/
void requestError( QNetworkReply::NetworkError error );
};
typedef QSharedPointer<Settings> SettingsPtr;
}
#endif // SETTINGS_H

58
3rdparty/libmygpo-qt/Settings_p.h vendored Normal file
View File

@ -0,0 +1,58 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef SETTINGS_PRIVATE_H
#define SETTINGS_PRIVATE_H
#include "Settings.h"
namespace mygpo
{
class SettingsPrivate : public QObject
{
Q_OBJECT
public:
SettingsPrivate( Settings* qq, QNetworkReply* reply );
virtual ~SettingsPrivate();
QVariant settings() const;
private:
Settings* const q;
QVariant m_settings;
QNetworkReply* m_reply;
QNetworkReply::NetworkError m_error;
bool parse( const QVariant& data );
bool parse( const QByteArray& data );
private slots:
void parseData();
void error( QNetworkReply::NetworkError error );
};
}
#endif //SETTINGS_PRIVATE_H

76
3rdparty/libmygpo-qt/Tag.cpp vendored Normal file
View File

@ -0,0 +1,76 @@
/***************************************************************************
* 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 "Tag_p.h"
using namespace mygpo;
TagPrivate::TagPrivate( Tag* qq, const QVariant& variant ) : q( qq ), m_tag( QLatin1String( "" ) ), m_usage( 0 )
{
parse( variant );
}
QString TagPrivate::tag() const
{
return m_tag;
}
uint TagPrivate::usage() const
{
return m_usage;
}
bool TagPrivate::parse( const QVariant& data )
{
if( !data.canConvert( QVariant::Map ) )
return false;
QVariantMap tagMap = data.toMap();
QVariant v = tagMap.value( QLatin1String( "tag" ) );
if( !v.canConvert( QVariant::String ) )
return false;
m_tag = v.toString();
v = tagMap.value( QLatin1String( "usage" ) );
if( !v.canConvert( QVariant::UInt ) )
return false;
m_usage = v.toUInt();
return true;
}
Tag::Tag( const QVariant& variant, QObject* parent ) : QObject( parent ), d( new TagPrivate( this, variant ) )
{
}
Tag::~Tag()
{
delete d;
}
QString Tag::tag() const
{
return d->tag();
}
uint Tag::usage() const
{
return d->usage();
}

59
3rdparty/libmygpo-qt/Tag.h vendored Normal file
View File

@ -0,0 +1,59 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef TAG_H
#define TAG_H
#include "mygpo_export.h"
#include <QSharedPointer>
#include <QVariant>
namespace mygpo
{
class TagPrivate;
class MYGPO_EXPORT Tag : public QObject
{
Q_OBJECT
Q_PROPERTY( QString tag READ tag CONSTANT )
Q_PROPERTY( uint usage READ usage CONSTANT )
public:
Tag( const QVariant& variant, QObject* parent = 0 );
virtual ~Tag();
QString tag() const;
uint usage() const;
private:
Q_DISABLE_COPY( Tag )
TagPrivate* const d;
friend class TagPrivate;
};
typedef QSharedPointer<Tag> TagPtr;
}
Q_DECLARE_METATYPE( mygpo::TagPtr );
#endif // TAG_H

124
3rdparty/libmygpo-qt/TagList.cpp vendored Normal file
View File

@ -0,0 +1,124 @@
/***************************************************************************
* 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 "TagList_p.h"
#include <qjson/parser.h>
using namespace mygpo;
TagListPrivate::TagListPrivate( TagList* qq, QNetworkReply* reply ) : q( qq ), m_reply( reply ), m_tags( QVariant() ), m_error( QNetworkReply::NoError )
{
QObject::connect( m_reply, SIGNAL( finished() ), this, SLOT( parseData() ) );
QObject::connect( m_reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( error( QNetworkReply::NetworkError ) ) );
}
TagListPrivate::~TagListPrivate()
{
}
QList<TagPtr> TagListPrivate::list() const
{
QList<TagPtr> list;
QVariantList varList = m_tags.toList();
foreach( QVariant var, varList )
{
list.append( var.value<mygpo::TagPtr>() );
}
return list;
}
QVariant TagListPrivate::tags() const
{
return m_tags;
}
bool TagListPrivate::parse( const QVariant& data )
{
if( !data.canConvert( QVariant::List ) )
return false;
QVariantList varList = data.toList();
QVariantList tagList;
foreach( QVariant var, varList )
{
QVariant v;
v.setValue<mygpo::TagPtr>( TagPtr( new Tag( var ) ) );
tagList.append( v );
}
m_tags = QVariant( tagList );
return true;
}
bool TagListPrivate::parse( const QByteArray& data )
{
QJson::Parser parser;
bool ok;
QVariant variant = parser.parse( data, &ok );
if( ok )
{
ok = ( parse( variant ) );
}
return ok;
}
void TagListPrivate::parseData()
{
if( m_reply->error() == QNetworkReply::NoError )
{
if( parse( m_reply->readAll() ) )
{
emit q->finished();
}
else
{
emit q->parseError();
}
}
m_reply->deleteLater();
}
void TagListPrivate::error( QNetworkReply::NetworkError error )
{
this->m_error = error;
emit q->requestError( error );
}
TagList::TagList( QNetworkReply* reply, QObject* parent ) : QObject( parent ), d( new TagListPrivate( this, reply ) )
{
}
TagList::~TagList()
{
delete d;
}
QList<TagPtr> TagList::list() const
{
return d->list();
}
QVariant TagList::tags() const
{
return d->tags();
}

66
3rdparty/libmygpo-qt/TagList.h vendored Normal file
View File

@ -0,0 +1,66 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef TAGLIST_H
#define TAGLIST_H
#include "Tag.h"
#include "mygpo_export.h"
#include <QNetworkReply>
#include <QSharedPointer>
#include <QList>
namespace mygpo
{
class TagListPrivate;
class MYGPO_EXPORT TagList : public QObject
{
Q_OBJECT
Q_PROPERTY( QVariant tags READ tags CONSTANT )
public:
TagList( QNetworkReply* reply, QObject* parent = 0 );
virtual ~TagList();
QList<TagPtr> list() const;
QVariant tags() const;
private:
Q_DISABLE_COPY( TagList )
TagListPrivate* const d;
friend class TagListPrivate;
signals:
/**Gets emitted when the data is ready to read*/
void finished();
/**Gets emitted when an parse error ocurred*/
void parseError();
/**Gets emitted when an request error ocurred*/
void requestError( QNetworkReply::NetworkError error );
};
typedef QSharedPointer<TagList> TagListPtr;
}
Q_DECLARE_METATYPE( mygpo::TagListPtr );
#endif // TAGLIST_H

56
3rdparty/libmygpo-qt/TagList_p.h vendored Normal file
View File

@ -0,0 +1,56 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef TAGLIST_PRIVATE_H
#define TAGLIST_PRIVATE_H
#include "TagList.h"
namespace mygpo
{
class TagListPrivate : public QObject
{
Q_OBJECT
public:
TagListPrivate( TagList* qq, QNetworkReply* reply );
virtual ~TagListPrivate();
QList<TagPtr> list() const;
QVariant tags() const;
private:
TagList* const q;
QNetworkReply* m_reply;
QVariant m_tags;
QNetworkReply::NetworkError m_error;
bool parse( const QVariant& data );
bool parse( const QByteArray& data );
private slots:
void parseData();
void error( QNetworkReply::NetworkError error );
};
}
#endif // TAGLIST_PRIVATE_H

49
3rdparty/libmygpo-qt/Tag_p.h vendored Normal file
View File

@ -0,0 +1,49 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef TAG_PRIVATE_H
#define TAG_PRIVATE_H
#include "Tag.h"
namespace mygpo
{
class TagPrivate : public QObject
{
Q_OBJECT
public:
TagPrivate( Tag* qq, const QVariant& variant );
QString tag() const;
uint usage() const;
private:
Tag* const q;
QString m_tag;
uint m_usage;
bool parse( const QVariant& data );
};
}
#endif // TAG_PRIVATE_H

207
3rdparty/libmygpo-qt/UrlBuilder.cpp vendored Normal file
View File

@ -0,0 +1,207 @@
/***************************************************************************
* 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 "UrlBuilder.h"
#include <QString>
#include <QStringBuilder>
#include <QLatin1String>
using namespace mygpo;
const QString UrlBuilder::s_server = QLatin1String( "http://gpodder.net" );
const QString UrlBuilder::s_api2 = QLatin1String( "/api/2" );
const QString UrlBuilder::s_api1 = QLatin1String( "/api/1" );
static QString getFormatExtension( UrlBuilder::Format f )
{
QString ret;
switch( f )
{
case UrlBuilder::JSON:
ret = QString( QLatin1String( ".json" ) );
break;
case UrlBuilder::OPML:
ret = QString( QLatin1String( ".opml" ) );
break;
case UrlBuilder::TEXT:
ret = QString( QLatin1String( ".txt" ) );
break;
case UrlBuilder::XML:
ret = QString( QLatin1String( ".xml" ) );
break;
}
return ret;
}
QString UrlBuilder::getToplistUrl( uint i, Format f )
{
QString numString = QString::number(( i == 0 ) ? 1 : i );
return s_server % QLatin1String( "/toplist/" ) % numString % getFormatExtension( f );
}
QString UrlBuilder::getSuggestionsUrl( uint i, Format f )
{
QString numString = QString::number(( i == 0 ) ? 1 : i );
return s_server % QLatin1String( "/suggestions/" ) % numString % getFormatExtension( f );
}
QString UrlBuilder::getPodcastSearchUrl( const QString& query, Format f )
{
return s_server % QLatin1String( "/search" ) % getFormatExtension( f ) % QLatin1String( "?q=" ) % query;
}
QString UrlBuilder::getSubscriptionsUrl( const QString& username, const QString& device, UrlBuilder::Format f)
{
return s_server % QLatin1String( "/subscriptions/" ) % username % QLatin1String( "/" ) % device % getFormatExtension( f );
}
QString UrlBuilder::getTopTagsUrl( uint i )
{
QString numString = QString::number(( i == 0 ) ? 1 : i );
return s_server % s_api2 % QLatin1String( "/tags/" ) % numString % QLatin1String( ".json" );
}
QString UrlBuilder::getPodcastsOfTagUrl( const QString& tag, uint i )
{
QString numString = QString::number(( i == 0 ) ? 1 : i );
return s_server % s_api2 % QLatin1String( "/tag/" ) % tag % QLatin1String( "/" ) % numString % QLatin1String( ".json" );
}
QString UrlBuilder::getPodcastDataUrl( const QString& url )
{
return s_server % s_api2 % QLatin1String( "/data/podcast" ) % QLatin1String( ".json" ) % QLatin1String( "?url=" ) % url;
}
QString UrlBuilder::getEpisodeDataUrl( const QString& podcastUrl, const QString& episodeUrl )
{
return s_server % s_api2 % QLatin1String( "/data/episode" ) % QLatin1String( ".json" ) % QLatin1String( "?podcast=" ) % podcastUrl % QLatin1String( "&url=" ) % episodeUrl;
}
QString UrlBuilder::getFavEpisodesUrl( const QString& username )
{
return s_server % s_api2 % QLatin1String( "/favorites/" ) % username % QLatin1String( ".json" );
}
QString UrlBuilder::getAddRemoveSubUrl( const QString& username, const QString& deviceId )
{
return s_server % s_api2 % QLatin1String( "/subscriptions/" ) % username % QLatin1String( "/" ) % deviceId % QLatin1String( ".json" );
}
QString UrlBuilder::getAccountSettingsUrl( const QString& username )
{
return s_server % s_api2 % QLatin1String( "/settings/" ) % username % QLatin1String( "/account" ) % QLatin1String( ".json" );
}
QString UrlBuilder::getDeviceSettingsUrl( const QString& username, const QString& deviceId )
{
return s_server % s_api2 % QLatin1String( "/settings/" ) % username % QLatin1String( "/device" ) % QLatin1String( ".json" ) % QLatin1String( "?device=" ) % deviceId;
}
QString UrlBuilder::getPodcastSettingsUrl( const QString& username, const QString& podcastUrl )
{
return s_server % s_api2 % QLatin1String( "/settings/" ) % username % QLatin1String( "/podcast" ) % QLatin1String( ".json" ) % QLatin1String( "?podcast=" ) % podcastUrl;
}
QString UrlBuilder::getEpisodeSettingsUrl( const QString& username, const QString& podcastUrl, const QString& episodeUrl )
{
return s_server % s_api2 % QLatin1String( "/settings/" ) % username % QLatin1String( "/episode" ) % QLatin1String( ".json" ) % QLatin1String( "?podcast=" ) % podcastUrl % QLatin1String( "&episode=" ) % episodeUrl;
}
QString UrlBuilder::getDeviceListUrl( const QString& username )
{
return s_server % s_api2 % QLatin1String( "/devices/" ) % username % QLatin1String( ".json" ) ;
}
QString UrlBuilder::getDeviceUpdatesUrl( const QString& username, const QString& deviceId, qulonglong timestamp )
{
QString numString = QString::number( timestamp );
return s_server % s_api2 % QLatin1String( "/updates/" ) % username % QLatin1String( "/" ) % deviceId % QLatin1String( ".json?since=" ) % numString;
}
QString UrlBuilder::getRenameDeviceUrl( const QString& username, const QString& deviceId )
{
return s_server % s_api2 % QLatin1String( "/devices/" ) % username % QLatin1String( "/" ) % deviceId % QLatin1String( ".json" );
}
QString UrlBuilder::getEpisodeActionsUrl( const QString& username, const bool aggregated )
{
QString agg;
if( aggregated )
agg = QLatin1String( "?aggregated=true" );
else
agg = QLatin1String( "" );
return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json" ) % agg;
}
QString UrlBuilder::getEpisodeActionsUrlByPodcast( const QString& username, const QString& podcastUrl, const bool aggregated )
{
QString agg;
if( aggregated )
agg = QLatin1String( "&aggregated=true" );
else
agg = QLatin1String( "" );
return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?podcast=" ) % podcastUrl % agg;
}
QString UrlBuilder::getEpisodeActionsUrlByDevice( const QString& username, const QString& deviceId, bool aggregated )
{
QString agg;
if( aggregated )
agg = QLatin1String( "&aggregated=true" );
else
agg = QLatin1String( "" );
return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?device=" ) % deviceId % agg;
}
QString UrlBuilder::getEpisodeActionsUrlByTimestamp( const QString& username, qulonglong since )
{
QString numString = QString::number( since );
return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?since=" ) % numString;
}
QString UrlBuilder::getEpisodeActionsUrlByPodcastAndTimestamp( const QString& username, const QString& podcastUrl, qulonglong since )
{
QString numString = QString::number( since );
return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?podcast=" ) % podcastUrl % QLatin1String( "&since=" ) % numString;
}
QString UrlBuilder::getEpisodeActionsUrlByDeviceAndTimestamp( const QString& username, const QString& deviceId, qulonglong since )
{
QString numString = QString::number( since );
return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?device=" ) % deviceId % QLatin1String( "&since=" ) % numString;
}
QString UrlBuilder::getUploadEpisodeActionsUrl( const QString& username )
{
return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json" );
}
QString UrlBuilder::getDeviceSynchronizationStatusUrl ( const QString& username )
{
return s_server % s_api2 % QLatin1String( "/sync-devices/" ) % username % QLatin1String( ".json" );
}

146
3rdparty/libmygpo-qt/UrlBuilder.h vendored Normal file
View File

@ -0,0 +1,146 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef URLBUILDER_H
#define URLBUILDER_H
#include <QString>
namespace mygpo
{
/**
* Helper class to generate request URL's.
* Helps to generate URL's for the gpodder requests.
* This class uses the singleton pattern, to retrieve a
* reference to the singleton object use the function instance().
*/
class UrlBuilder
{
public:
enum Format
{
JSON,
OPML,
TEXT,
XML
};
/**
* @param i Any value between 1..100. If i <= 0 it will be set to 1.
* @return Request URL to retrieve a list of the top 'i' podcasts.
*/
static QString getToplistUrl( uint i, Format f = JSON );
/**
* @param i Any value between 1..100. If i <= 0 it will be set to 1.
* @return Rquest URL to retrieve 'i' podcast suggestions.
*/
static QString getSuggestionsUrl( uint i, Format f = JSON );
/**
* @param query The query to search in the podcasts name/descrption.
* @return Request URL to retrieve podcasts related to the query.
*/
static QString getPodcastSearchUrl( const QString& query, Format f = JSON );
static QString getSubscriptionsUrl( const QString& username, const QString& device, Format f = JSON );
/**
* @param i Amount of tags. If i == 0 it will be set to 1.
* @return Request URL to retrieve the 'i' most used tags.
*/
static QString getTopTagsUrl( uint i );
/**
* @param i Amount of podcasts. If i == 0 it will be set to 1.
* @return Request URL to retrieve the 'i' most-subscribed podcats that are tagged with tag.
*/
static QString getPodcastsOfTagUrl( const QString& tag, uint i );
/**
* @param url The URL of the podcast
* @return Request URL to retrieve information about the podcast with the given url.
*/
static QString getPodcastDataUrl( const QString& url );
/**
* @param podcastUrl URL of the podcast
* @param episodeUrl URL of the episode that belongs to the podcast-url
* @return Request URL to retrieve information about the episode with the given episode-url.
*/
static QString getEpisodeDataUrl( const QString& podcastUrl, const QString& episodeUrl );
/**
* @param username User name (gpodder.net). You need to be logged in with username.
* @return Request URL to retrieve a list of all favorite episodes.
*/
static QString getFavEpisodesUrl( const QString& username );
/**
* @param username User name (gpodder.net). You need to be logged in with username.
* @param deviceId The id of the device.
* @return Request URL to to update the subscription list for a given device.
*/
static QString getAddRemoveSubUrl( const QString& username, const QString& deviceId );
static QString getAccountSettingsUrl( const QString& username );
static QString getDeviceSettingsUrl( const QString& username, const QString& deviceId );
static QString getPodcastSettingsUrl( const QString& username, const QString& podcastUrl );
static QString getEpisodeSettingsUrl( const QString& username, const QString& podcastUrl, const QString& episodeUrl );
static QString getDeviceListUrl( const QString& username );
static QString getRenameDeviceUrl( const QString& username, const QString& deviceId );
static QString getDeviceUpdatesUrl( const QString& username, const QString& deviceId, qulonglong timestamp );
static QString getEpisodeActionsUrl( const QString& username, bool aggregated );
static QString getEpisodeActionsUrlByPodcast( const QString& username, const QString& podcastUrl, bool aggregated );
static QString getEpisodeActionsUrlByDevice( const QString& username, const QString& deviceId, bool aggregated );
static QString getEpisodeActionsUrlByTimestamp( const QString& username, qulonglong since );
static QString getEpisodeActionsUrlByPodcastAndTimestamp( const QString& username, const QString& podcastUrl, qulonglong since );
static QString getEpisodeActionsUrlByDeviceAndTimestamp( const QString& username, const QString& deviceId, qulonglong since );
static QString getUploadEpisodeActionsUrl( const QString& username );
static QString getDeviceSynchronizationStatusUrl( const QString& username );
private:
UrlBuilder() {};
UrlBuilder( const UrlBuilder& ) {};
static const QString s_server;
static const QString s_api2;
static const QString s_api1;
};
}
#endif // URLBUILDER_H

38
3rdparty/libmygpo-qt/mygpo_export.h vendored Normal file
View File

@ -0,0 +1,38 @@
/***************************************************************************
* 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 *
***************************************************************************/
#ifndef MYGPO_EXPORT_H
#define MYGPO_EXPORT_H
#include <QtCore/qglobal.h>
#ifndef MYGPO_EXPORT
# if defined(MYGPO_MAKEDLL)
/* We are building this library */
# define MYGPO_EXPORT Q_DECL_EXPORT
# else
/* We are using this library */
# define MYGPO_EXPORT Q_DECL_IMPORT
# endif
#endif
#endif // MYGPO_EXPORT_H

View File

@ -379,6 +379,11 @@ if(NOT CHROMAPRINT_FOUND)
endif(WIN32)
endif(NOT CHROMAPRINT_FOUND)
# We have to use our own libmygpo-qt for now
add_subdirectory(3rdparty/libmygpo-qt)
set(MYGPOQT_LIBRARIES mygpo-qt)
set(MYGPOQT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/3rdparty/libmygpo-qt/)
# Subdirectories
add_subdirectory(src)
if (WIN32)

View File

@ -340,5 +340,6 @@
<file>schema/schema-37.sql</file>
<file>providers/podcast16.png</file>
<file>providers/podcast32.png</file>
<file>providers/mygpo32.png</file>
</qresource>
</RCC>

BIN
data/providers/mygpo32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -36,6 +36,7 @@ include_directories(${QXT_INCLUDE_DIRS})
include_directories(${ECHONEST_INCLUDE_DIRS})
include_directories(${SHA2_INCLUDE_DIRS})
include_directories(${CHROMAPRINT_INCLUDE_DIRS})
include_directories(${MYGPOQT_INCLUDE_DIRS})
find_package(OpenGL)
include_directories(${OPENGL_INCLUDE_DIR})
@ -230,6 +231,8 @@ set(SOURCES
podcasts/addpodcastbyurl.cpp
podcasts/addpodcastdialog.cpp
podcasts/addpodcastpage.cpp
podcasts/gpoddertoptagsmodel.cpp
podcasts/gpoddertoptagspage.cpp
podcasts/podcast.cpp
podcasts/podcastbackend.cpp
podcasts/podcastdiscoverymodel.cpp
@ -477,6 +480,8 @@ set(HEADERS
podcasts/addpodcastbyurl.h
podcasts/addpodcastdialog.h
podcasts/addpodcastpage.h
podcasts/gpoddertoptagsmodel.h
podcasts/gpoddertoptagspage.h
podcasts/podcastbackend.h
podcasts/podcastdiscoverymodel.h
podcasts/podcastinfowidget.h
@ -1009,6 +1014,7 @@ target_link_libraries(clementine_lib
libclementine-tagreader
${SHA2_LIBRARIES}
${TAGLIB_LIBRARIES}
${MYGPOQT_LIBRARIES}
${CHROMAPRINT_LIBRARIES}
${ECHONEST_LIBRARIES}
${GOBJECT_LIBRARIES}

View File

@ -17,6 +17,7 @@
#include "addpodcastdialog.h"
#include "addpodcastbyurl.h"
#include "gpoddertoptagspage.h"
#include "podcastdiscoverymodel.h"
#include "ui_addpodcastdialog.h"
#include "core/application.h"
@ -42,6 +43,7 @@ AddPodcastDialog::AddPodcastDialog(Application* app, QWidget* parent)
// Add providers
AddPage(new AddPodcastByUrl(app, this));
AddPage(new GPodderTopTagsPage(app, this));
ui_->provider_list->setCurrentRow(0);
}

View File

@ -23,3 +23,8 @@ AddPodcastPage::AddPodcastPage(Application* app, QWidget* parent)
model_(new PodcastDiscoveryModel(app, this))
{
}
void AddPodcastPage::SetModel(PodcastDiscoveryModel* model) {
delete model_;
model_ = model;
}

View File

@ -34,6 +34,9 @@ public:
signals:
void Busy(bool busy);
protected:
void SetModel(PodcastDiscoveryModel* model);
private:
PodcastDiscoveryModel* model_;
};

View File

@ -0,0 +1,32 @@
/* This file is part of Clementine.
Copyright 2012, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "gpoddertoptagsmodel.h"
GPodderTopTagsModel::GPodderTopTagsModel(Application* app, QObject* parent)
: PodcastDiscoveryModel(app, parent)
{
set_is_tree(true);
}
bool GPodderTopTagsModel::hasChildren(const QModelIndex& parent) const {
if (parent.isValid() && parent.data(Role_Type).toInt() == Type_Folder) {
return true;
}
return PodcastDiscoveryModel::hasChildren(parent);
}

View File

@ -0,0 +1,32 @@
/* This file is part of Clementine.
Copyright 2012, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GPODDERTOPTAGSMODEL_H
#define GPODDERTOPTAGSMODEL_H
#include "podcastdiscoverymodel.h"
class GPodderTopTagsModel : public PodcastDiscoveryModel {
Q_OBJECT
public:
GPodderTopTagsModel(Application* app, QObject* parent = 0);
bool hasChildren(const QModelIndex& parent) const;
};
#endif // GPODDERTOPTAGSMODEL_H

View File

@ -0,0 +1,67 @@
/* This file is part of Clementine.
Copyright 2012, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "gpoddertoptagsmodel.h"
#include "gpoddertoptagspage.h"
#include "core/closure.h"
#include "core/network.h"
#include <ApiRequest.h>
const int GPodderTopTagsPage::kMaxTagCount = 100;
GPodderTopTagsPage::GPodderTopTagsPage(Application* app, QWidget* parent)
: AddPodcastPage(app, parent),
network_(new NetworkAccessManager(this)),
api_(new mygpo::ApiRequest(network_)),
done_initial_load_(false)
{
setWindowTitle(tr("Browse gpodder.net"));
setWindowIcon(QIcon(":providers/mygpo32.png"));
SetModel(new GPodderTopTagsModel(app, this));
}
GPodderTopTagsPage::~GPodderTopTagsPage() {
delete api_;
}
void GPodderTopTagsPage::showEvent(QShowEvent* e) {
QWidget::showEvent(e);
if (!done_initial_load_) {
// Start the request for list of top-level tags
emit Busy(true);
done_initial_load_ = true;
mygpo::TagList* tag_list = api_->topTags(kMaxTagCount);
NewClosure(tag_list, SIGNAL(finished()),
this, SLOT(TagListLoaded(mygpo::TagList*)),
tag_list);
}
}
void GPodderTopTagsPage::TagListLoaded(mygpo::TagList* tag_list) {
tag_list->deleteLater();
emit Busy(false);
foreach (mygpo::TagPtr tag, tag_list->list()) {
model()->appendRow(model()->CreateFolder(tag->tag()));
}
}

View File

@ -0,0 +1,54 @@
/* This file is part of Clementine.
Copyright 2012, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GPODDERTOPTAGSPAGE_H
#define GPODDERTOPTAGSPAGE_H
#include <QScopedPointer>
#include "addpodcastpage.h"
class QNetworkAccessManager;
namespace mygpo {
class ApiRequest;
class TagList;
}
class GPodderTopTagsPage : public AddPodcastPage {
Q_OBJECT
public:
GPodderTopTagsPage(Application* app, QWidget* parent = 0);
~GPodderTopTagsPage();
static const int kMaxTagCount;
private:
void showEvent(QShowEvent* e);
private slots:
void TagListLoaded(mygpo::TagList* tag_list);
private:
QNetworkAccessManager* network_;
mygpo::ApiRequest* api_;
bool done_initial_load_;
};
#endif // GPODDERTOPTAGSPAGE_H

View File

@ -19,6 +19,7 @@
#include "podcastdiscoverymodel.h"
#include "core/application.h"
#include "covers/albumcoverloader.h"
#include "ui/iconloader.h"
#include <QIcon>
#include <QSet>
@ -53,6 +54,18 @@ QStandardItem* PodcastDiscoveryModel::CreatePodcastItem(const Podcast& podcast)
return item;
}
QStandardItem* PodcastDiscoveryModel::CreateFolder(const QString& name) {
if (folder_icon_.isNull()) {
folder_icon_ = IconLoader::Load("folder");
}
QStandardItem* item = new QStandardItem;
item->setIcon(folder_icon_);
item->setText(name);
item->setData(Type_Folder, Role_Type);
return item;
}
void PodcastDiscoveryModel::ImageLoaded(quint64 id, const QImage& image) {
QStandardItem* item = pending_covers_.take(id);
if (!item)

View File

@ -45,6 +45,7 @@ public:
void set_is_tree(bool v) { is_tree_ = v; }
QStandardItem* CreatePodcastItem(const Podcast& podcast);
QStandardItem* CreateFolder(const QString& name);
private slots:
void CancelPendingImages();
@ -57,6 +58,7 @@ private:
AlbumCoverLoaderOptions cover_options_;
QIcon default_icon_;
QIcon folder_icon_;
QMap<quint64, QStandardItem*> pending_covers_;
};