Merge branch 'podcasts'. Fixes issue 44
This commit is contained in:
commit
204f7acbfa
138
3rdparty/libmygpo-qt/AddRemoveResult.cpp
vendored
Normal file
138
3rdparty/libmygpo-qt/AddRemoveResult.cpp
vendored
Normal 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
70
3rdparty/libmygpo-qt/AddRemoveResult.h
vendored
Normal 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 LIBMYGPO_QT_ADDREMOVERESULT_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_ADDREMOVERESULT_H
|
59
3rdparty/libmygpo-qt/AddRemoveResult_p.h
vendored
Normal file
59
3rdparty/libmygpo-qt/AddRemoveResult_p.h
vendored
Normal 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
573
3rdparty/libmygpo-qt/ApiRequest.cpp
vendored
Normal 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
404
3rdparty/libmygpo-qt/ApiRequest.h
vendored
Normal 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 LIBMYGPO_QT_APIREQUEST_H
|
||||
#define LIBMYGPO_QT_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
85
3rdparty/libmygpo-qt/ApiRequest_p.h
vendored
Normal 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
|
79
3rdparty/libmygpo-qt/CMakeLists.txt
vendored
Normal file
79
3rdparty/libmygpo-qt/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
|
||||
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} )
|
110
3rdparty/libmygpo-qt/Device.cpp
vendored
Normal file
110
3rdparty/libmygpo-qt/Device.cpp
vendored
Normal 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
71
3rdparty/libmygpo-qt/Device.h
vendored
Normal 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 LIBMYGPO_QT_DEVICE_H
|
||||
#define LIBMYGPO_QT_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 //LIBMYGPO_QT_DEVICE_H
|
121
3rdparty/libmygpo-qt/DeviceList.cpp
vendored
Normal file
121
3rdparty/libmygpo-qt/DeviceList.cpp
vendored
Normal 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
68
3rdparty/libmygpo-qt/DeviceList.h
vendored
Normal 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 LIBMYGPO_QT_DEVICELIST_H
|
||||
#define LIBMYGPO_QT_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 //LIBMYGPO_QT_DEVICELIST_H
|
57
3rdparty/libmygpo-qt/DeviceList_p.h
vendored
Normal file
57
3rdparty/libmygpo-qt/DeviceList_p.h
vendored
Normal 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
|
148
3rdparty/libmygpo-qt/DeviceSyncResult.cpp
vendored
Normal file
148
3rdparty/libmygpo-qt/DeviceSyncResult.cpp
vendored
Normal 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
66
3rdparty/libmygpo-qt/DeviceSyncResult.h
vendored
Normal 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 LIBMYGPO_QT_DEVICESYNCRESULT_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_DEVICESYNCRESULT_H
|
58
3rdparty/libmygpo-qt/DeviceSyncResult_p.h
vendored
Normal file
58
3rdparty/libmygpo-qt/DeviceSyncResult_p.h
vendored
Normal 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
187
3rdparty/libmygpo-qt/DeviceUpdates.cpp
vendored
Normal 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
72
3rdparty/libmygpo-qt/DeviceUpdates.h
vendored
Normal 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 LIBMYGPO_QT_DEVICEUPDATES_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_DEVICEUPDATES_H
|
67
3rdparty/libmygpo-qt/DeviceUpdates_p.h
vendored
Normal file
67
3rdparty/libmygpo-qt/DeviceUpdates_p.h
vendored
Normal 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
51
3rdparty/libmygpo-qt/Device_p.h
vendored
Normal 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
258
3rdparty/libmygpo-qt/Episode.cpp
vendored
Normal 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
96
3rdparty/libmygpo-qt/Episode.h
vendored
Normal 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 LIBMYGPO_QT_EPISODE_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_EPISODE_H
|
268
3rdparty/libmygpo-qt/EpisodeAction.cpp
vendored
Normal file
268
3rdparty/libmygpo-qt/EpisodeAction.cpp
vendored
Normal 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
78
3rdparty/libmygpo-qt/EpisodeAction.h
vendored
Normal 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 LIBMYGPO_QT_EPISODEACTION_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_EPISODEACTION_H
|
148
3rdparty/libmygpo-qt/EpisodeActionList.cpp
vendored
Normal file
148
3rdparty/libmygpo-qt/EpisodeActionList.cpp
vendored
Normal 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;
|
||||
}
|
71
3rdparty/libmygpo-qt/EpisodeActionList.h
vendored
Normal file
71
3rdparty/libmygpo-qt/EpisodeActionList.h
vendored
Normal 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 LIBMYGPO_QT_EPISODEACTIONLIST_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_EPISODEACTIONLIST_H
|
61
3rdparty/libmygpo-qt/EpisodeActionList_p.h
vendored
Normal file
61
3rdparty/libmygpo-qt/EpisodeActionList_p.h
vendored
Normal 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
67
3rdparty/libmygpo-qt/EpisodeAction_p.h
vendored
Normal 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
128
3rdparty/libmygpo-qt/EpisodeList.cpp
vendored
Normal 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
66
3rdparty/libmygpo-qt/EpisodeList.h
vendored
Normal 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 LIBMYGPO_QT_EPISODELIST_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_EPISODELIST_H
|
57
3rdparty/libmygpo-qt/EpisodeList_p.h
vendored
Normal file
57
3rdparty/libmygpo-qt/EpisodeList_p.h
vendored
Normal 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
71
3rdparty/libmygpo-qt/Episode_p.h
vendored
Normal 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
|
156
3rdparty/libmygpo-qt/JsonCreator.cpp
vendored
Normal file
156
3rdparty/libmygpo-qt/JsonCreator.cpp
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
/***************************************************************************
|
||||
* 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 ) {
|
||||
#if QT_VERSION >= 0x040700
|
||||
QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(episodeAction->timestamp() );
|
||||
#else
|
||||
QDateTime dateTime = QDateTime::fromTime_t(episodeAction->timestamp() / 1000 );
|
||||
QTime time = dateTime.time();
|
||||
time.addMSecs(episodeAction->timestamp() % 1000 );
|
||||
dateTime.setTime(time);
|
||||
#endif
|
||||
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
56
3rdparty/libmygpo-qt/JsonCreator.h
vendored
Normal 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 LIBMYGPO_QT_JSONPARSER_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_JSONPARSER_H
|
217
3rdparty/libmygpo-qt/Podcast.cpp
vendored
Normal file
217
3rdparty/libmygpo-qt/Podcast.cpp
vendored
Normal 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
84
3rdparty/libmygpo-qt/Podcast.h
vendored
Normal 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 LIBMYGPO_QT_PODCAST_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_PODCAST_H
|
124
3rdparty/libmygpo-qt/PodcastList.cpp
vendored
Normal file
124
3rdparty/libmygpo-qt/PodcastList.cpp
vendored
Normal 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
67
3rdparty/libmygpo-qt/PodcastList.h
vendored
Normal 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 LIBMYGPO_QT_PODCASTLIST_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_PODCASTLIST_H
|
55
3rdparty/libmygpo-qt/PodcastList_p.h
vendored
Normal file
55
3rdparty/libmygpo-qt/PodcastList_p.h
vendored
Normal 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
71
3rdparty/libmygpo-qt/Podcast_p.h
vendored
Normal 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
71
3rdparty/libmygpo-qt/RequestHandler.cpp
vendored
Normal 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
85
3rdparty/libmygpo-qt/RequestHandler.h
vendored
Normal 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 LIBMYGPO_QT_REQUESTHANDLER_H_
|
||||
#define LIBMYGPO_QT_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 /* LIBMYGPO_QT_REQUESTHANDLER_H_ */
|
99
3rdparty/libmygpo-qt/Settings.cpp
vendored
Normal file
99
3rdparty/libmygpo-qt/Settings.cpp
vendored
Normal 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
66
3rdparty/libmygpo-qt/Settings.h
vendored
Normal 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 LIBMYGPO_QT_SETTINGS_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_SETTINGS_H
|
58
3rdparty/libmygpo-qt/Settings_p.h
vendored
Normal file
58
3rdparty/libmygpo-qt/Settings_p.h
vendored
Normal 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
76
3rdparty/libmygpo-qt/Tag.cpp
vendored
Normal 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
59
3rdparty/libmygpo-qt/Tag.h
vendored
Normal 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 LIBMYGPO_QT_TAG_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_TAG_H
|
124
3rdparty/libmygpo-qt/TagList.cpp
vendored
Normal file
124
3rdparty/libmygpo-qt/TagList.cpp
vendored
Normal 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
66
3rdparty/libmygpo-qt/TagList.h
vendored
Normal 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 LIBMYGPO_QT_TAGLIST_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_TAGLIST_H
|
56
3rdparty/libmygpo-qt/TagList_p.h
vendored
Normal file
56
3rdparty/libmygpo-qt/TagList_p.h
vendored
Normal 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
49
3rdparty/libmygpo-qt/Tag_p.h
vendored
Normal 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
207
3rdparty/libmygpo-qt/UrlBuilder.cpp
vendored
Normal 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
146
3rdparty/libmygpo-qt/UrlBuilder.h
vendored
Normal 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 LIBMYGPO_QT_URLBUILDER_H
|
||||
#define LIBMYGPO_QT_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 // LIBMYGPO_QT_URLBUILDER_H
|
30
3rdparty/libmygpo-qt/mygpo_export.h
vendored
Normal file
30
3rdparty/libmygpo-qt/mygpo_export.h
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/***************************************************************************
|
||||
* 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>
|
||||
|
||||
#define MYGPO_EXPORT
|
||||
|
||||
#endif // MYGPO_EXPORT_H
|
@ -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)
|
||||
|
@ -337,5 +337,11 @@
|
||||
<file>schema/schema-35.sql</file>
|
||||
<file>schema/schema-36.sql</file>
|
||||
<file>grooveshark-valicert-ca.pem</file>
|
||||
<file>schema/schema-37.sql</file>
|
||||
<file>providers/podcast16.png</file>
|
||||
<file>providers/podcast32.png</file>
|
||||
<file>providers/mygpo32.png</file>
|
||||
<file>providers/itunes.png</file>
|
||||
<file>providers/bbc.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
data/providers/bbc.png
Normal file
BIN
data/providers/bbc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 664 B |
BIN
data/providers/itunes.png
Normal file
BIN
data/providers/itunes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
BIN
data/providers/mygpo32.png
Normal file
BIN
data/providers/mygpo32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
data/providers/podcast16.png
Executable file
BIN
data/providers/podcast16.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 764 B |
BIN
data/providers/podcast32.png
Executable file
BIN
data/providers/podcast32.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
45
data/schema/schema-37.sql
Normal file
45
data/schema/schema-37.sql
Normal file
@ -0,0 +1,45 @@
|
||||
CREATE TABLE podcasts (
|
||||
url TEXT,
|
||||
title TEXT,
|
||||
description TEXT,
|
||||
copyright TEXT,
|
||||
link TEXT,
|
||||
image_url_large TEXT,
|
||||
image_url_small TEXT,
|
||||
author TEXT,
|
||||
owner_name TEXT,
|
||||
owner_email TEXT,
|
||||
|
||||
last_updated INTEGER,
|
||||
last_update_error TEXT,
|
||||
|
||||
extra BLOB
|
||||
);
|
||||
|
||||
CREATE TABLE podcast_episodes (
|
||||
podcast_id INTEGER,
|
||||
|
||||
title TEXT,
|
||||
description TEXT,
|
||||
author TEXT,
|
||||
publication_date INTEGER,
|
||||
duration_secs INTEGER,
|
||||
url TEXT,
|
||||
|
||||
listened BOOLEAN,
|
||||
listened_date INTEGER,
|
||||
downloaded BOOLEAN,
|
||||
local_url TEXT,
|
||||
|
||||
extra BLOB
|
||||
);
|
||||
|
||||
CREATE INDEX podcast_idx_url ON podcasts(url);
|
||||
|
||||
CREATE INDEX podcast_episodes_idx_podcast_id ON podcast_episodes(podcast_id);
|
||||
|
||||
CREATE INDEX podcast_episodes_idx_url ON podcast_episodes(url);
|
||||
|
||||
CREATE INDEX podcast_episodes_idx_local_url ON podcast_episodes(local_url);
|
||||
|
||||
UPDATE schema_version SET version=37;
|
4
debian/clementine.gconf-defaults
vendored
Normal file
4
debian/clementine.gconf-defaults
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/desktop/gnome/url-handlers/zune/command "clementine %s"
|
||||
/desktop/gnome/url-handlers/itpc/command "clementine %s"
|
||||
/desktop/gnome/url-handlers/itms/command "clementine %s"
|
||||
/desktop/gnome/url-handlers/feed/command "clementine %s"
|
1
debian/rules.in
vendored
1
debian/rules.in
vendored
@ -48,6 +48,7 @@ binary-arch: install
|
||||
dh_installchangelogs
|
||||
dh_installmenu
|
||||
dh_installdocs
|
||||
dh_gconf
|
||||
dh_link
|
||||
dh_strip
|
||||
dh_compress
|
||||
|
4
dist/CMakeLists.txt
vendored
4
dist/CMakeLists.txt
vendored
@ -40,6 +40,10 @@ if (NOT APPLE)
|
||||
DESTINATION share/applications
|
||||
)
|
||||
|
||||
install(FILES itms.protocol itpc.protocol feed.protocol zune.protocol
|
||||
DESTINATION share/kde4/services
|
||||
)
|
||||
|
||||
if(INSTALL_UBUNTU_ICONS)
|
||||
foreach(icon clementine-panel.png clementine-panel-grey.png)
|
||||
foreach(theme ubuntu-mono-dark ubuntu-mono-light)
|
||||
|
2
dist/clementine.desktop
vendored
2
dist/clementine.desktop
vendored
@ -12,7 +12,7 @@ Icon=application-x-clementine
|
||||
Terminal=false
|
||||
Categories=AudioVideo;Player;Qt;
|
||||
StartupNotify=false
|
||||
MimeType=application/ogg;application/x-ogg;application/x-ogm-audio;audio/aac;audio/mp4;audio/mpeg;audio/mpegurl;audio/ogg;audio/vnd.rn-realaudio;audio/vorbis;audio/x-flac;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-wma;audio/x-musepack;audio/x-oggflac;audio/x-pn-realaudio;audio/x-scpls;audio/x-speex;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-wav;video/x-ms-asf;x-content/audio-player;
|
||||
MimeType=application/ogg;application/x-ogg;application/x-ogm-audio;audio/aac;audio/mp4;audio/mpeg;audio/mpegurl;audio/ogg;audio/vnd.rn-realaudio;audio/vorbis;audio/x-flac;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-wma;audio/x-musepack;audio/x-oggflac;audio/x-pn-realaudio;audio/x-scpls;audio/x-speex;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-wav;video/x-ms-asf;x-content/audio-player;x-scheme-handler/zune;x-scheme-handler/itpc;x-scheme-handler/itms;x-scheme-handler/feed;
|
||||
X-Ayatana-Desktop-Shortcuts=Play;Pause;Stop;Previous;Next;
|
||||
|
||||
[Play Shortcut Group]
|
||||
|
13
dist/feed.protocol
vendored
Normal file
13
dist/feed.protocol
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
[Protocol]
|
||||
exec=clementine %U
|
||||
protocol=feed
|
||||
input=none
|
||||
output=none
|
||||
helper=true
|
||||
listing=false
|
||||
reading=false
|
||||
writing=false
|
||||
makedir=false
|
||||
deleting=false
|
||||
URIMode=rawuri
|
||||
Icon=application-x-clementine
|
13
dist/itms.protocol
vendored
Normal file
13
dist/itms.protocol
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
[Protocol]
|
||||
exec=clementine %U
|
||||
protocol=itms
|
||||
input=none
|
||||
output=none
|
||||
helper=true
|
||||
listing=false
|
||||
reading=false
|
||||
writing=false
|
||||
makedir=false
|
||||
deleting=false
|
||||
URIMode=rawuri
|
||||
Icon=application-x-clementine
|
13
dist/itpc.protocol
vendored
Normal file
13
dist/itpc.protocol
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
[Protocol]
|
||||
exec=clementine %U
|
||||
protocol=itpc
|
||||
input=none
|
||||
output=none
|
||||
helper=true
|
||||
listing=false
|
||||
reading=false
|
||||
writing=false
|
||||
makedir=false
|
||||
deleting=false
|
||||
URIMode=rawuri
|
||||
Icon=application-x-clementine
|
13
dist/zune.protocol
vendored
Normal file
13
dist/zune.protocol
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
[Protocol]
|
||||
exec=clementine %U
|
||||
protocol=zune
|
||||
input=none
|
||||
output=none
|
||||
helper=true
|
||||
listing=false
|
||||
reading=false
|
||||
writing=false
|
||||
makedir=false
|
||||
deleting=false
|
||||
URIMode=rawuri
|
||||
Icon=application-x-clementine
|
@ -25,12 +25,14 @@ Closure::Closure(QObject* sender,
|
||||
const char* slot,
|
||||
const ClosureArgumentWrapper* val0,
|
||||
const ClosureArgumentWrapper* val1,
|
||||
const ClosureArgumentWrapper* val2)
|
||||
const ClosureArgumentWrapper* val2,
|
||||
const ClosureArgumentWrapper* val3)
|
||||
: QObject(receiver),
|
||||
callback_(NULL),
|
||||
val0_(val0),
|
||||
val1_(val1),
|
||||
val2_(val2) {
|
||||
val2_(val2),
|
||||
val3_(val3) {
|
||||
const QMetaObject* meta_receiver = receiver->metaObject();
|
||||
|
||||
QByteArray normalised_slot = QMetaObject::normalizedSignature(slot + 1);
|
||||
@ -64,7 +66,8 @@ void Closure::Invoked() {
|
||||
parent(),
|
||||
val0_ ? val0_->arg() : QGenericArgument(),
|
||||
val1_ ? val1_->arg() : QGenericArgument(),
|
||||
val2_ ? val2_->arg() : QGenericArgument());
|
||||
val2_ ? val2_->arg() : QGenericArgument(),
|
||||
val3_ ? val3_->arg() : QGenericArgument());
|
||||
}
|
||||
deleteLater();
|
||||
}
|
||||
|
@ -56,7 +56,8 @@ class Closure : public QObject, boost::noncopyable {
|
||||
QObject* receiver, const char* slot,
|
||||
const ClosureArgumentWrapper* val0 = 0,
|
||||
const ClosureArgumentWrapper* val1 = 0,
|
||||
const ClosureArgumentWrapper* val2 = 0);
|
||||
const ClosureArgumentWrapper* val2 = 0,
|
||||
const ClosureArgumentWrapper* val3 = 0);
|
||||
|
||||
Closure(QObject* sender, const char* signal,
|
||||
std::tr1::function<void()> callback);
|
||||
@ -74,6 +75,7 @@ class Closure : public QObject, boost::noncopyable {
|
||||
boost::scoped_ptr<const ClosureArgumentWrapper> val0_;
|
||||
boost::scoped_ptr<const ClosureArgumentWrapper> val1_;
|
||||
boost::scoped_ptr<const ClosureArgumentWrapper> val2_;
|
||||
boost::scoped_ptr<const ClosureArgumentWrapper> val3_;
|
||||
};
|
||||
|
||||
#define C_ARG(type, data) new ClosureArgument<type>(data)
|
||||
@ -123,4 +125,19 @@ Closure* NewClosure(
|
||||
C_ARG(T0, val0), C_ARG(T1, val1), C_ARG(T2, val2));
|
||||
}
|
||||
|
||||
template <typename T0, typename T1, typename T2, typename T3>
|
||||
Closure* NewClosure(
|
||||
QObject* sender,
|
||||
const char* signal,
|
||||
QObject* receiver,
|
||||
const char* slot,
|
||||
const T0& val0,
|
||||
const T1& val1,
|
||||
const T2& val2,
|
||||
const T3& val3) {
|
||||
return new Closure(
|
||||
sender, signal, receiver, slot,
|
||||
C_ARG(T0, val0), C_ARG(T1, val1), C_ARG(T2, val2), C_ARG(T3, val3));
|
||||
}
|
||||
|
||||
#endif // CLOSURE_H
|
||||
|
@ -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})
|
||||
@ -227,6 +228,28 @@ set(SOURCES
|
||||
playlistparsers/xmlparser.cpp
|
||||
playlistparsers/xspfparser.cpp
|
||||
|
||||
podcasts/addpodcastbyurl.cpp
|
||||
podcasts/addpodcastdialog.cpp
|
||||
podcasts/addpodcastpage.cpp
|
||||
podcasts/fixedopmlpage.cpp
|
||||
podcasts/gpoddersearchpage.cpp
|
||||
podcasts/gpoddersync.cpp
|
||||
podcasts/gpoddertoptagsmodel.cpp
|
||||
podcasts/gpoddertoptagspage.cpp
|
||||
podcasts/itunessearchpage.cpp
|
||||
podcasts/podcast.cpp
|
||||
podcasts/podcastbackend.cpp
|
||||
podcasts/podcastdiscoverymodel.cpp
|
||||
podcasts/podcastdownloader.cpp
|
||||
podcasts/podcastepisode.cpp
|
||||
podcasts/podcastinfowidget.cpp
|
||||
podcasts/podcastservice.cpp
|
||||
podcasts/podcastservicemodel.cpp
|
||||
podcasts/podcastsettingspage.cpp
|
||||
podcasts/podcastparser.cpp
|
||||
podcasts/podcastupdater.cpp
|
||||
podcasts/podcasturlloader.cpp
|
||||
|
||||
smartplaylists/generator.cpp
|
||||
smartplaylists/generatorinserter.cpp
|
||||
smartplaylists/querygenerator.cpp
|
||||
@ -290,6 +313,7 @@ set(SOURCES
|
||||
ui/screensaver.cpp
|
||||
ui/settingsdialog.cpp
|
||||
ui/settingspage.cpp
|
||||
ui/standarditemiconloader.cpp
|
||||
ui/systemtrayicon.cpp
|
||||
ui/trackselectiondialog.cpp
|
||||
ui/windows7thumbbar.cpp
|
||||
@ -321,7 +345,6 @@ set(SOURCES
|
||||
widgets/ratingwidget.cpp
|
||||
widgets/renametablineedit.cpp
|
||||
widgets/sliderwidget.cpp
|
||||
widgets/spinbox.cpp
|
||||
widgets/stickyslider.cpp
|
||||
widgets/stretchheaderview.cpp
|
||||
widgets/stylehelper.cpp
|
||||
@ -462,6 +485,25 @@ set(HEADERS
|
||||
playlistparsers/plsparser.h
|
||||
playlistparsers/xspfparser.h
|
||||
|
||||
podcasts/addpodcastbyurl.h
|
||||
podcasts/addpodcastdialog.h
|
||||
podcasts/addpodcastpage.h
|
||||
podcasts/fixedopmlpage.h
|
||||
podcasts/gpoddersearchpage.h
|
||||
podcasts/gpoddersync.h
|
||||
podcasts/gpoddertoptagsmodel.h
|
||||
podcasts/gpoddertoptagspage.h
|
||||
podcasts/itunessearchpage.h
|
||||
podcasts/podcastbackend.h
|
||||
podcasts/podcastdiscoverymodel.h
|
||||
podcasts/podcastdownloader.h
|
||||
podcasts/podcastinfowidget.h
|
||||
podcasts/podcastservice.h
|
||||
podcasts/podcastservicemodel.h
|
||||
podcasts/podcastsettingspage.h
|
||||
podcasts/podcastupdater.h
|
||||
podcasts/podcasturlloader.h
|
||||
|
||||
smartplaylists/generator.h
|
||||
smartplaylists/generatorinserter.h
|
||||
smartplaylists/generatormimedata.h
|
||||
@ -515,6 +557,7 @@ set(HEADERS
|
||||
ui/qtsystemtrayicon.h
|
||||
ui/settingsdialog.h
|
||||
ui/settingspage.h
|
||||
ui/standarditemiconloader.h
|
||||
ui/systemtrayicon.h
|
||||
ui/trackselectiondialog.h
|
||||
ui/windows7thumbbar.h
|
||||
@ -544,7 +587,6 @@ set(HEADERS
|
||||
widgets/ratingwidget.h
|
||||
widgets/renametablineedit.h
|
||||
widgets/sliderwidget.h
|
||||
widgets/spinbox.h
|
||||
widgets/stickyslider.h
|
||||
widgets/stretchheaderview.h
|
||||
widgets/trackslider.h
|
||||
@ -579,6 +621,13 @@ set(UI
|
||||
playlist/playlistsequence.ui
|
||||
playlist/queuemanager.ui
|
||||
|
||||
podcasts/addpodcastbyurl.ui
|
||||
podcasts/addpodcastdialog.ui
|
||||
podcasts/gpoddersearchpage.ui
|
||||
podcasts/itunessearchpage.ui
|
||||
podcasts/podcastinfowidget.ui
|
||||
podcasts/podcastsettingspage.ui
|
||||
|
||||
remote/remotesettingspage.ui
|
||||
|
||||
smartplaylists/querysearchpage.ui
|
||||
@ -984,6 +1033,7 @@ target_link_libraries(clementine_lib
|
||||
libclementine-tagreader
|
||||
${SHA2_LIBRARIES}
|
||||
${TAGLIB_LIBRARIES}
|
||||
${MYGPOQT_LIBRARIES}
|
||||
${CHROMAPRINT_LIBRARIES}
|
||||
${ECHONEST_LIBRARIES}
|
||||
${GOBJECT_LIBRARIES}
|
||||
|
@ -31,12 +31,18 @@
|
||||
#include "library/librarybackend.h"
|
||||
#include "playlist/playlistbackend.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "podcasts/gpoddersync.h"
|
||||
#include "podcasts/podcastbackend.h"
|
||||
#include "podcasts/podcastdownloader.h"
|
||||
#include "podcasts/podcastupdater.h"
|
||||
|
||||
Application::Application(QObject* parent)
|
||||
: QObject(parent),
|
||||
tag_reader_client_(NULL),
|
||||
database_(NULL),
|
||||
album_cover_loader_(NULL),
|
||||
playlist_backend_(NULL),
|
||||
podcast_backend_(NULL),
|
||||
appearance_(NULL),
|
||||
cover_providers_(NULL),
|
||||
task_manager_(NULL),
|
||||
@ -46,8 +52,10 @@ Application::Application(QObject* parent)
|
||||
global_search_(NULL),
|
||||
internet_model_(NULL),
|
||||
library_(NULL),
|
||||
playlist_backend_(NULL),
|
||||
device_manager_(NULL)
|
||||
device_manager_(NULL),
|
||||
podcast_updater_(NULL),
|
||||
podcast_downloader_(NULL),
|
||||
gpodder_sync_(NULL)
|
||||
{
|
||||
tag_reader_client_ = new TagReaderClient(this);
|
||||
MoveToNewThread(tag_reader_client_);
|
||||
@ -59,6 +67,12 @@ Application::Application(QObject* parent)
|
||||
album_cover_loader_ = new AlbumCoverLoader(this);
|
||||
MoveToNewThread(album_cover_loader_);
|
||||
|
||||
playlist_backend_ = new PlaylistBackend(this, this);
|
||||
MoveToThread(playlist_backend_, database_->thread());
|
||||
|
||||
podcast_backend_ = new PodcastBackend(this, this);
|
||||
MoveToThread(podcast_backend_, database_->thread());
|
||||
|
||||
appearance_ = new Appearance(this);
|
||||
cover_providers_ = new CoverProviders(this);
|
||||
task_manager_ = new TaskManager(this);
|
||||
@ -67,13 +81,11 @@ Application::Application(QObject* parent)
|
||||
current_art_loader_ = new CurrentArtLoader(this, this);
|
||||
global_search_ = new GlobalSearch(this, this);
|
||||
internet_model_ = new InternetModel(this, this);
|
||||
|
||||
library_ = new Library(this, this);
|
||||
|
||||
playlist_backend_ = new PlaylistBackend(this, this);
|
||||
MoveToThread(playlist_backend_, database_->thread());
|
||||
|
||||
device_manager_ = new DeviceManager(this, this);
|
||||
podcast_updater_ = new PodcastUpdater(this, this);
|
||||
podcast_downloader_ = new PodcastDownloader(this, this);
|
||||
gpodder_sync_ = new GPodderSync(this, this);
|
||||
|
||||
library_->Init();
|
||||
library_->StartThreads();
|
||||
@ -124,3 +136,11 @@ LibraryBackend* Application::library_backend() const {
|
||||
LibraryModel* Application::library_model() const {
|
||||
return library()->model();
|
||||
}
|
||||
|
||||
void Application::ReloadSettings() {
|
||||
emit SettingsChanged();
|
||||
}
|
||||
|
||||
void Application::OpenSettingsDialogAtPage(SettingsDialog::Page page) {
|
||||
emit SettingsDialogRequested(page);
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
#ifndef APPLICATION_H
|
||||
#define APPLICATION_H
|
||||
|
||||
#include "ui/settingsdialog.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class AlbumCoverLoader;
|
||||
@ -27,13 +29,17 @@ class CurrentArtLoader;
|
||||
class Database;
|
||||
class DeviceManager;
|
||||
class GlobalSearch;
|
||||
class GPodderSync;
|
||||
class InternetModel;
|
||||
class Library;
|
||||
class LibraryBackend;
|
||||
class LibraryModel;
|
||||
class Player;
|
||||
class PlaylistBackend;
|
||||
class PodcastDownloader;
|
||||
class PlaylistManager;
|
||||
class PodcastBackend;
|
||||
class PodcastUpdater;
|
||||
class TagReaderClient;
|
||||
class TaskManager;
|
||||
|
||||
@ -48,6 +54,8 @@ public:
|
||||
TagReaderClient* tag_reader_client() const { return tag_reader_client_; }
|
||||
Database* database() const { return database_; }
|
||||
AlbumCoverLoader* album_cover_loader() const { return album_cover_loader_; }
|
||||
PlaylistBackend* playlist_backend() const { return playlist_backend_; }
|
||||
PodcastBackend* podcast_backend() const { return podcast_backend_; }
|
||||
Appearance* appearance() const { return appearance_; }
|
||||
CoverProviders* cover_providers() const { return cover_providers_; }
|
||||
TaskManager* task_manager() const { return task_manager_; }
|
||||
@ -56,10 +64,11 @@ public:
|
||||
CurrentArtLoader* current_art_loader() const { return current_art_loader_; }
|
||||
GlobalSearch* global_search() const { return global_search_; }
|
||||
InternetModel* internet_model() const { return internet_model_; }
|
||||
|
||||
Library* library() const { return library_; }
|
||||
PlaylistBackend* playlist_backend() const { return playlist_backend_; }
|
||||
DeviceManager* device_manager() const { return device_manager_; }
|
||||
PodcastUpdater* podcast_updater() const { return podcast_updater_; }
|
||||
PodcastDownloader* podcast_downloader() const { return podcast_downloader_; }
|
||||
GPodderSync* gpodder_sync() const { return gpodder_sync_; }
|
||||
|
||||
LibraryBackend* library_backend() const;
|
||||
LibraryModel* library_model() const;
|
||||
@ -69,14 +78,20 @@ public:
|
||||
|
||||
public slots:
|
||||
void AddError(const QString& message);
|
||||
void ReloadSettings();
|
||||
void OpenSettingsDialogAtPage(SettingsDialog::Page page);
|
||||
|
||||
signals:
|
||||
void ErrorAdded(const QString& message);
|
||||
void SettingsChanged();
|
||||
void SettingsDialogRequested(SettingsDialog::Page page);
|
||||
|
||||
private:
|
||||
TagReaderClient* tag_reader_client_;
|
||||
Database* database_;
|
||||
AlbumCoverLoader* album_cover_loader_;
|
||||
PlaylistBackend* playlist_backend_;
|
||||
PodcastBackend* podcast_backend_;
|
||||
Appearance* appearance_;
|
||||
CoverProviders* cover_providers_;
|
||||
TaskManager* task_manager_;
|
||||
@ -85,10 +100,11 @@ private:
|
||||
CurrentArtLoader* current_art_loader_;
|
||||
GlobalSearch* global_search_;
|
||||
InternetModel* internet_model_;
|
||||
|
||||
Library* library_;
|
||||
PlaylistBackend* playlist_backend_;
|
||||
DeviceManager* device_manager_;
|
||||
PodcastUpdater* podcast_updater_;
|
||||
PodcastDownloader* podcast_downloader_;
|
||||
GPodderSync* gpodder_sync_;
|
||||
|
||||
QList<QObject*> objects_in_threads_;
|
||||
QList<QThread*> threads_;
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include <QVariant>
|
||||
|
||||
const char* Database::kDatabaseFilename = "clementine.db";
|
||||
const int Database::kSchemaVersion = 36;
|
||||
const int Database::kSchemaVersion = 37;
|
||||
const char* Database::kMagicAllSongsTables = "%allsongstables";
|
||||
|
||||
int Database::sNextConnectionId = 1;
|
||||
|
@ -455,4 +455,9 @@ QKeySequence KeySequenceFromNSEvent(NSEvent* event) {
|
||||
return QKeySequence(key);
|
||||
}
|
||||
|
||||
void DumpDictionary(CFDictionaryRef dict) {
|
||||
NSDictionary* d = (NSDictionary*)dict;
|
||||
NSLog(@"%@", d);
|
||||
}
|
||||
|
||||
} // namespace mac
|
||||
|
@ -15,14 +15,19 @@
|
||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Only include this from Objective-C++ files
|
||||
|
||||
#include <QKeySequence>
|
||||
|
||||
#include <CoreFoundation/CFDictionary.h>
|
||||
|
||||
#ifdef __OBJC__
|
||||
@class NSEvent;
|
||||
#else
|
||||
class NSEvent;
|
||||
#endif
|
||||
|
||||
namespace mac {
|
||||
|
||||
QKeySequence KeySequenceFromNSEvent(NSEvent* event);
|
||||
void DumpDictionary(CFDictionaryRef dict);
|
||||
|
||||
}
|
||||
|
@ -16,9 +16,9 @@
|
||||
*/
|
||||
|
||||
#include "mergedproxymodel.h"
|
||||
#include "core/logging.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QtDebug>
|
||||
|
||||
#include <limits>
|
||||
|
||||
@ -55,6 +55,8 @@ void MergedProxyModel::AddSubModel(const QModelIndex& source_parent,
|
||||
this, SLOT(RowsInserted(QModelIndex,int,int)));
|
||||
connect(submodel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
|
||||
this, SLOT(RowsRemoved(QModelIndex,int,int)));
|
||||
connect(submodel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
|
||||
this, SLOT(DataChanged(QModelIndex,QModelIndex)));
|
||||
|
||||
QModelIndex proxy_parent = mapFromSource(source_parent);
|
||||
const int rows = submodel->rowCount();
|
||||
|
@ -134,3 +134,42 @@ void NetworkTimeouts::timerEvent(QTimerEvent* e) {
|
||||
reply->abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RedirectFollower::RedirectFollower(QNetworkReply* first_reply, int max_redirects)
|
||||
: QObject(NULL),
|
||||
current_reply_(first_reply),
|
||||
redirects_remaining_(max_redirects) {
|
||||
ConnectReply(first_reply);
|
||||
}
|
||||
|
||||
void RedirectFollower::ConnectReply(QNetworkReply* reply) {
|
||||
connect(reply, SIGNAL(readyRead()), SIGNAL(readyRead()));
|
||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SIGNAL(error(QNetworkReply::NetworkError)));
|
||||
connect(reply, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(downloadProgress(qint64,qint64)));
|
||||
connect(reply, SIGNAL(uploadProgress(qint64,qint64)), SIGNAL(uploadProgress(qint64,qint64)));
|
||||
connect(reply, SIGNAL(finished()), SLOT(ReplyFinished()));
|
||||
}
|
||||
|
||||
void RedirectFollower::ReplyFinished() {
|
||||
current_reply_->deleteLater();
|
||||
|
||||
if (current_reply_->attribute(QNetworkRequest::RedirectionTargetAttribute).isValid()) {
|
||||
if (redirects_remaining_-- == 0) {
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
|
||||
const QUrl next_url = current_reply_->url().resolved(
|
||||
current_reply_->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl());
|
||||
|
||||
QNetworkRequest req(current_reply_->request());
|
||||
req.setUrl(next_url);
|
||||
|
||||
current_reply_ = current_reply_->manager()->get(req);
|
||||
ConnectReply(current_reply_);
|
||||
return;
|
||||
}
|
||||
|
||||
emit finished();
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <QAbstractNetworkCache>
|
||||
#include <QMutex>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
|
||||
class QNetworkDiskCache;
|
||||
|
||||
@ -43,6 +44,7 @@ private:
|
||||
static QNetworkDiskCache* sCache;
|
||||
};
|
||||
|
||||
|
||||
class NetworkAccessManager : public QNetworkAccessManager {
|
||||
Q_OBJECT
|
||||
|
||||
@ -54,6 +56,7 @@ protected:
|
||||
QIODevice* outgoingData);
|
||||
};
|
||||
|
||||
|
||||
class NetworkTimeouts : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
@ -74,4 +77,41 @@ private:
|
||||
QMap<QNetworkReply*, int> timers_;
|
||||
};
|
||||
|
||||
|
||||
class RedirectFollower : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RedirectFollower(QNetworkReply* first_reply, int max_redirects = 5);
|
||||
|
||||
bool hit_redirect_limit() const { return redirects_remaining_ < 0; }
|
||||
QNetworkReply* reply() const { return current_reply_; }
|
||||
|
||||
// These are all forwarded to the current reply.
|
||||
QNetworkReply::NetworkError error() const { return current_reply_->error(); }
|
||||
QString errorString() const { return current_reply_->errorString(); }
|
||||
QVariant attribute(QNetworkRequest::Attribute code) const { return current_reply_->attribute(code); }
|
||||
QVariant header(QNetworkRequest::KnownHeaders header) const { return current_reply_->header(header); }
|
||||
|
||||
signals:
|
||||
// These are all forwarded from the current reply.
|
||||
void readyRead();
|
||||
void error(QNetworkReply::NetworkError);
|
||||
void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
|
||||
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
||||
|
||||
// This is NOT emitted when a request that has a redirect finishes.
|
||||
void finished();
|
||||
|
||||
private slots:
|
||||
void ReplyFinished();
|
||||
|
||||
private:
|
||||
void ConnectReply(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
QNetworkReply* current_reply_;
|
||||
int redirects_remaining_;
|
||||
};
|
||||
|
||||
#endif // NETWORK_H
|
||||
|
29
src/core/qhash_qurl.h
Normal file
29
src/core/qhash_qurl.h
Normal file
@ -0,0 +1,29 @@
|
||||
/* 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 QHASH_QURL_H
|
||||
#define QHASH_QURL_H
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
#if QT_VERSION < 0x040700
|
||||
inline uint qHash(const QUrl& url) {
|
||||
return qHash(url.toEncoded());
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // QHASH_QURL_H
|
@ -67,25 +67,6 @@ using boost::scoped_ptr;
|
||||
#include "widgets/trackslider.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
QStringList Prepend(const QString& text, const QStringList& list) {
|
||||
QStringList ret(list);
|
||||
for (int i=0 ; i<ret.count() ; ++i)
|
||||
ret[i].prepend(text);
|
||||
return ret;
|
||||
}
|
||||
|
||||
QStringList Updateify(const QStringList& list) {
|
||||
QStringList ret(list);
|
||||
for (int i=0 ; i<ret.count() ; ++i)
|
||||
ret[i].prepend(ret[i] + " = :");
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
const QStringList Song::kColumns = QStringList()
|
||||
<< "title" << "album" << "artist" << "albumartist" << "composer" << "track"
|
||||
<< "disc" << "bpm" << "year" << "genre" << "comment" << "compilation"
|
||||
@ -97,8 +78,8 @@ const QStringList Song::kColumns = QStringList()
|
||||
<< "cue_path" << "unavailable" << "effective_albumartist";
|
||||
|
||||
const QString Song::kColumnSpec = Song::kColumns.join(", ");
|
||||
const QString Song::kBindSpec = Prepend(":", Song::kColumns).join(", ");
|
||||
const QString Song::kUpdateSpec = Updateify(Song::kColumns).join(", ");
|
||||
const QString Song::kBindSpec = Utilities::Prepend(":", Song::kColumns).join(", ");
|
||||
const QString Song::kUpdateSpec = Utilities::Updateify(Song::kColumns).join(", ");
|
||||
|
||||
|
||||
const QStringList Song::kFtsColumns = QStringList()
|
||||
@ -106,8 +87,8 @@ const QStringList Song::kFtsColumns = QStringList()
|
||||
<< "ftscomposer" << "ftsgenre" << "ftscomment";
|
||||
|
||||
const QString Song::kFtsColumnSpec = Song::kFtsColumns.join(", ");
|
||||
const QString Song::kFtsBindSpec = Prepend(":", Song::kFtsColumns).join(", ");
|
||||
const QString Song::kFtsUpdateSpec = Updateify(Song::kFtsColumns).join(", ");
|
||||
const QString Song::kFtsBindSpec = Utilities::Prepend(":", Song::kFtsColumns).join(", ");
|
||||
const QString Song::kFtsUpdateSpec = Utilities::Updateify(Song::kFtsColumns).join(", ");
|
||||
|
||||
const QString Song::kManuallyUnsetCover = "(unset)";
|
||||
const QString Song::kEmbeddedCover = "(embedded)";
|
||||
@ -324,7 +305,7 @@ void Song::set_basefilename(const QString& v) { d->basefilename_ = v; }
|
||||
void Song::set_directory_id(int v) { d->directory_id_ = v; }
|
||||
|
||||
QString Song::JoinSpec(const QString& table) {
|
||||
return Prepend(table + ".", kColumns).join(", ");
|
||||
return Utilities::Prepend(table + ".", kColumns).join(", ");
|
||||
}
|
||||
|
||||
QString Song::TextForFiletype(FileType type) {
|
||||
|
@ -22,11 +22,15 @@
|
||||
#include "core/tagreaderclient.h"
|
||||
#include "core/timeconstants.h"
|
||||
#include "internet/fixlastfm.h"
|
||||
#include "internet/internetmodel.h"
|
||||
#include "library/librarybackend.h"
|
||||
#include "library/sqlrow.h"
|
||||
#include "playlistparsers/parserbase.h"
|
||||
#include "playlistparsers/cueparser.h"
|
||||
#include "playlistparsers/playlistparser.h"
|
||||
#include "podcasts/podcastparser.h"
|
||||
#include "podcasts/podcastservice.h"
|
||||
#include "podcasts/podcasturlloader.h"
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QDirIterator>
|
||||
@ -50,11 +54,13 @@ SongLoader::SongLoader(LibraryBackendInterface* library, QObject *parent)
|
||||
: QObject(parent),
|
||||
timeout_timer_(new QTimer(this)),
|
||||
playlist_parser_(new PlaylistParser(library, this)),
|
||||
podcast_parser_(new PodcastParser),
|
||||
cue_parser_(new CueParser(library, this)),
|
||||
timeout_(kDefaultTimeout),
|
||||
state_(WaitingForType),
|
||||
success_(false),
|
||||
parser_(NULL),
|
||||
is_podcast_(false),
|
||||
library_(library)
|
||||
{
|
||||
if (sRawUriSchemes.isEmpty()) {
|
||||
@ -72,6 +78,8 @@ SongLoader::~SongLoader() {
|
||||
state_ = Finished;
|
||||
gst_element_set_state(pipeline_.get(), GST_STATE_NULL);
|
||||
}
|
||||
|
||||
delete podcast_parser_;
|
||||
}
|
||||
|
||||
SongLoader::Result SongLoader::Load(const QUrl& url) {
|
||||
@ -88,6 +96,8 @@ SongLoader::Result SongLoader::Load(const QUrl& url) {
|
||||
return Success;
|
||||
}
|
||||
|
||||
url_ = PodcastUrlLoader::FixPodcastUrl(url_);
|
||||
|
||||
timeout_timer_->start(timeout_);
|
||||
return LoadRemote();
|
||||
}
|
||||
@ -393,6 +403,19 @@ void SongLoader::StopTypefind() {
|
||||
QBuffer buf(&buffer_);
|
||||
buf.open(QIODevice::ReadOnly);
|
||||
songs_ = parser_->Load(&buf);
|
||||
} else if (success_ && is_podcast_) {
|
||||
qLog(Debug) << "Parsing" << url_ << "as a podcast";
|
||||
|
||||
QBuffer buf(&buffer_);
|
||||
buf.open(QIODevice::ReadOnly);
|
||||
QVariant result = podcast_parser_->Load(&buf, url_);
|
||||
|
||||
if (result.isNull()) {
|
||||
qLog(Warning) << "Failed to parse podcast";
|
||||
} else {
|
||||
InternetModel::Service<PodcastService>()->SubscribeAndShow(result);
|
||||
}
|
||||
|
||||
} else if (success_) {
|
||||
qLog(Debug) << "Loading" << url_ << "as raw stream";
|
||||
|
||||
@ -463,7 +486,7 @@ void SongLoader::TypeFound(GstElement*, uint, GstCaps* caps, void* self) {
|
||||
qLog(Debug) << "Mime type is" << instance->mime_type_;
|
||||
if (instance->mime_type_ == "text/plain" ||
|
||||
instance->mime_type_ == "text/uri-list" ||
|
||||
instance->mime_type_ == "application/xml") {
|
||||
instance->podcast_parser_->supported_mime_types().contains(instance->mime_type_)) {
|
||||
// Yeah it might be a playlist, let's get some data and have a better look
|
||||
instance->state_ = WaitingForMagic;
|
||||
return;
|
||||
@ -473,11 +496,11 @@ void SongLoader::TypeFound(GstElement*, uint, GstCaps* caps, void* self) {
|
||||
instance->StopTypefindAsync(true);
|
||||
}
|
||||
|
||||
void SongLoader::DataReady(GstPad*, GstBuffer* buf, void* self) {
|
||||
gboolean SongLoader::DataReady(GstPad*, GstBuffer* buf, void* self) {
|
||||
SongLoader* instance = static_cast<SongLoader*>(self);
|
||||
|
||||
if (instance->state_ == Finished)
|
||||
return;
|
||||
return true;
|
||||
|
||||
// Append the data to the buffer
|
||||
instance->buffer_.append(reinterpret_cast<const char*>(GST_BUFFER_DATA(buf)),
|
||||
@ -490,6 +513,8 @@ void SongLoader::DataReady(GstPad*, GstBuffer* buf, void* self) {
|
||||
// Got enough that we can test the magic
|
||||
instance->MagicReady();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
gboolean SongLoader::BusCallback(GstBus*, GstMessage* msg, gpointer self) {
|
||||
@ -504,11 +529,12 @@ gboolean SongLoader::BusCallback(GstBus*, GstMessage* msg, gpointer self) {
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GstBusSyncReply SongLoader::BusCallbackSync(GstBus*, GstMessage* msg, gpointer self) {
|
||||
SongLoader* instance = reinterpret_cast<SongLoader*>(self);
|
||||
|
||||
switch (GST_MESSAGE_TYPE(msg)) {
|
||||
case GST_MESSAGE_EOS:
|
||||
instance->EndOfStreamReached();
|
||||
@ -579,24 +605,34 @@ void SongLoader::EndOfStreamReached() {
|
||||
void SongLoader::MagicReady() {
|
||||
qLog(Debug) << Q_FUNC_INFO;
|
||||
parser_ = playlist_parser_->ParserForMagic(buffer_, mime_type_);
|
||||
is_podcast_ = false;
|
||||
|
||||
if (!parser_) {
|
||||
qLog(Warning) << url_.toString() << "is text, but not a recognised playlist";
|
||||
// It doesn't look like a playlist, so just finish
|
||||
StopTypefindAsync(false);
|
||||
return;
|
||||
// Maybe it's a podcast?
|
||||
if (podcast_parser_->TryMagic(buffer_)) {
|
||||
is_podcast_ = true;
|
||||
qLog(Debug) << "Looks like a podcast";
|
||||
} else {
|
||||
qLog(Warning) << url_.toString() << "is text, but not a recognised playlist";
|
||||
// It doesn't look like a playlist, so just finish
|
||||
StopTypefindAsync(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// It is a playlist - we'll get more data and parse the whole thing in
|
||||
// EndOfStreamReached
|
||||
qLog(Debug) << "Magic says" << parser_->name();
|
||||
if (parser_->name() == "ASX/INI" && url_.scheme() == "http") {
|
||||
// This is actually a weird MS-WMSP stream. Changing the protocol to MMS from
|
||||
// HTTP makes it playable.
|
||||
parser_ = NULL;
|
||||
url_.setScheme("mms");
|
||||
StopTypefindAsync(true);
|
||||
// We'll get more data and parse the whole thing in EndOfStreamReached
|
||||
|
||||
if (!is_podcast_) {
|
||||
qLog(Debug) << "Magic says" << parser_->name();
|
||||
if (parser_->name() == "ASX/INI" && url_.scheme() == "http") {
|
||||
// This is actually a weird MS-WMSP stream. Changing the protocol to MMS from
|
||||
// HTTP makes it playable.
|
||||
parser_ = NULL;
|
||||
url_.setScheme("mms");
|
||||
StopTypefindAsync(true);
|
||||
}
|
||||
}
|
||||
|
||||
state_ = WaitingForData;
|
||||
|
||||
if (!IsPipelinePlaying()) {
|
||||
@ -605,9 +641,15 @@ void SongLoader::MagicReady() {
|
||||
}
|
||||
|
||||
bool SongLoader::IsPipelinePlaying() {
|
||||
GstState pipeline_state;
|
||||
gst_element_get_state(pipeline_.get(), &pipeline_state, NULL, GST_MSECOND);
|
||||
return pipeline_state == GST_STATE_PLAYING;
|
||||
GstState state = GST_STATE_NULL;
|
||||
GstState pending_state = GST_STATE_NULL;
|
||||
GstStateChangeReturn ret = gst_element_get_state(pipeline_.get(), &state, &pending_state, GST_SECOND);
|
||||
|
||||
if (ret == GST_STATE_CHANGE_ASYNC && pending_state == GST_STATE_PLAYING) {
|
||||
// We're still on the way to playing
|
||||
return true;
|
||||
}
|
||||
return state == GST_STATE_PLAYING;
|
||||
}
|
||||
|
||||
void SongLoader::StopTypefindAsync(bool success) {
|
||||
|
@ -32,6 +32,7 @@ class CueParser;
|
||||
class LibraryBackendInterface;
|
||||
class ParserBase;
|
||||
class PlaylistParser;
|
||||
class PodcastParser;
|
||||
|
||||
class SongLoader : public QObject {
|
||||
Q_OBJECT
|
||||
@ -95,7 +96,7 @@ private:
|
||||
|
||||
// GStreamer callbacks
|
||||
static void TypeFound(GstElement* typefind, uint probability, GstCaps* caps, void* self);
|
||||
static void DataReady(GstPad*, GstBuffer* buf, void* self);
|
||||
static gboolean DataReady(GstPad*, GstBuffer* buf, void* self);
|
||||
static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage*, gpointer);
|
||||
static gboolean BusCallback(GstBus*, GstMessage*, gpointer);
|
||||
|
||||
@ -113,6 +114,7 @@ private:
|
||||
|
||||
QTimer* timeout_timer_;
|
||||
PlaylistParser* playlist_parser_;
|
||||
PodcastParser* podcast_parser_;
|
||||
CueParser* cue_parser_;
|
||||
|
||||
// For async loads
|
||||
@ -121,6 +123,7 @@ private:
|
||||
bool success_;
|
||||
ParserBase* parser_;
|
||||
QString mime_type_;
|
||||
bool is_podcast_;
|
||||
QByteArray buffer_;
|
||||
LibraryBackendInterface* library_;
|
||||
|
||||
|
@ -31,4 +31,6 @@ const qint64 kNsecPerUsec = 1000ll;
|
||||
const qint64 kNsecPerMsec = 1000000ll;
|
||||
const qint64 kNsecPerSec = 1000000000ll;
|
||||
|
||||
const qint64 kSecsPerDay = 24 * 60 * 60;
|
||||
|
||||
#endif // TIMECONSTANTS_H
|
||||
|
@ -52,7 +52,11 @@
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
# include "core/mac_startup.h"
|
||||
# include "core/mac_utilities.h"
|
||||
# include "core/scoped_cftyperef.h"
|
||||
# include "CoreServices/CoreServices.h"
|
||||
# include "IOKit/ps/IOPowerSources.h"
|
||||
# include "IOKit/ps/IOPSKeys.h"
|
||||
#endif
|
||||
|
||||
#include <boost/scoped_array.hpp>
|
||||
@ -403,6 +407,35 @@ void ConsumeCurrentElement(QXmlStreamReader* reader) {
|
||||
}
|
||||
}
|
||||
|
||||
bool ParseUntilElement(QXmlStreamReader* reader, const QString& name) {
|
||||
while (!reader->atEnd()) {
|
||||
QXmlStreamReader::TokenType type = reader->readNext();
|
||||
switch (type) {
|
||||
case QXmlStreamReader::StartElement:
|
||||
if (reader->name() == name) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QDateTime ParseRFC822DateTime(const QString& text) {
|
||||
// This sucks but we need it because some podcasts don't quite follow the
|
||||
// spec properly - they might have 1-digit hour numbers for example.
|
||||
|
||||
QRegExp re("([a-zA-Z]{3}),? (\\d{1,2}) ([a-zA-Z]{3}) (\\d{4}) (\\d{1,2}):(\\d{1,2}):(\\d{1,2})");
|
||||
if (re.indexIn(text) == -1)
|
||||
return QDateTime();
|
||||
|
||||
return QDateTime(
|
||||
QDate::fromString(QString("%1 %2 %3 %4").arg(re.cap(1), re.cap(3), re.cap(2), re.cap(4)), Qt::TextDate),
|
||||
QTime(re.cap(5).toInt(), re.cap(6).toInt(), re.cap(7).toInt()));
|
||||
}
|
||||
|
||||
const char* EnumToString(const QMetaObject& meta, const char* name, int value) {
|
||||
int index = meta.indexOfEnumerator(name);
|
||||
if (index == -1)
|
||||
@ -414,6 +447,30 @@ const char* EnumToString(const QMetaObject& meta, const char* name, int value) {
|
||||
return result;
|
||||
}
|
||||
|
||||
QStringList Prepend(const QString& text, const QStringList& list) {
|
||||
QStringList ret(list);
|
||||
for (int i=0 ; i<ret.count() ; ++i)
|
||||
ret[i].prepend(text);
|
||||
return ret;
|
||||
}
|
||||
|
||||
QStringList Updateify(const QStringList& list) {
|
||||
QStringList ret(list);
|
||||
for (int i=0 ; i<ret.count() ; ++i)
|
||||
ret[i].prepend(ret[i] + " = :");
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString DecodeHtmlEntities(const QString& text) {
|
||||
QString copy(text);
|
||||
copy.replace("&", "&");
|
||||
copy.replace(""", "\"");
|
||||
copy.replace("'", "'");
|
||||
copy.replace("<", "<");
|
||||
copy.replace(">", ">");
|
||||
return copy;
|
||||
}
|
||||
|
||||
int SetThreadIOPriority(IoPriority priority) {
|
||||
#ifdef Q_OS_LINUX
|
||||
return syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, GetThreadId(),
|
||||
@ -434,6 +491,37 @@ int GetThreadId() {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsLaptop() {
|
||||
#ifdef Q_OS_WIN
|
||||
SYSTEM_POWER_STATUS status;
|
||||
if (!GetSystemPowerStatus(&status)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !(status.BatteryFlag & 128); // 128 = no system battery
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
return !QDir("/proc/acpi/battery").entryList(QDir::Dirs | QDir::NoDotAndDotDot).isEmpty();
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
ScopedCFTypeRef<CFTypeRef> power_sources(IOPSCopyPowerSourcesInfo());
|
||||
ScopedCFTypeRef<CFArrayRef> power_source_list(
|
||||
IOPSCopyPowerSourcesList(power_sources.get()));
|
||||
for (CFIndex i = 0; i < CFArrayGetCount(power_source_list.get()); ++i) {
|
||||
CFTypeRef ps = CFArrayGetValueAtIndex(power_source_list.get(), i);
|
||||
CFDictionaryRef description = IOPSGetPowerSourceDescription(
|
||||
power_sources.get(), ps);
|
||||
|
||||
if (CFDictionaryContainsKey(description, CFSTR(kIOPSBatteryHealthKey))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Utilities
|
||||
|
||||
|
||||
|
@ -76,17 +76,30 @@ namespace Utilities {
|
||||
// Checks if the mouse event was inside the widget's rectangle.
|
||||
bool IsMouseEventInWidget(const QMouseEvent* e, const QWidget* widget);
|
||||
|
||||
|
||||
// Reads all children of the current element, and returns with the stream
|
||||
// reader either on the EndElement for the current element, or the end of the
|
||||
// file - whichever came first.
|
||||
void ConsumeCurrentElement(QXmlStreamReader* reader);
|
||||
|
||||
// Advances the stream reader until it finds an element with the given name.
|
||||
// Returns false if the end of the document was reached before finding a
|
||||
// matching element.
|
||||
bool ParseUntilElement(QXmlStreamReader* reader, const QString& name);
|
||||
|
||||
// Parses a string containing an RFC822 time and date.
|
||||
QDateTime ParseRFC822DateTime(const QString& text);
|
||||
|
||||
// Replaces some HTML entities with their normal characters.
|
||||
QString DecodeHtmlEntities(const QString& text);
|
||||
|
||||
// Shortcut for getting a Qt-aware enum value as a string.
|
||||
// Pass in the QMetaObject of the class that owns the enum, the string name of
|
||||
// the enum and a valid value from that enum.
|
||||
const char* EnumToString(const QMetaObject& meta, const char* name, int value);
|
||||
|
||||
QStringList Prepend(const QString& text, const QStringList& list);
|
||||
QStringList Updateify(const QStringList& list);
|
||||
|
||||
|
||||
enum ConfigPath {
|
||||
Path_Root,
|
||||
@ -117,6 +130,9 @@ namespace Utilities {
|
||||
|
||||
int SetThreadIOPriority(IoPriority priority);
|
||||
int GetThreadId();
|
||||
|
||||
// Returns true if this machine has a battery.
|
||||
bool IsLaptop();
|
||||
}
|
||||
|
||||
class ScopedWCharArray {
|
||||
|
@ -56,7 +56,6 @@ DigitallyImportedServiceBase::DigitallyImportedServiceBase(
|
||||
basic_audio_type_(1),
|
||||
premium_audio_type_(2),
|
||||
root_(NULL),
|
||||
context_item_(NULL),
|
||||
saved_channels_(kSettingsGroup, api_service_name, kStreamsCacheDurationSecs),
|
||||
api_client_(new DigitallyImportedClient(api_service_name, this))
|
||||
{
|
||||
@ -171,8 +170,7 @@ void DigitallyImportedServiceBase::ReloadSettings() {
|
||||
saved_channels_.Load();
|
||||
}
|
||||
|
||||
void DigitallyImportedServiceBase::ShowContextMenu(
|
||||
const QModelIndex& index, const QPoint& global_pos) {
|
||||
void DigitallyImportedServiceBase::ShowContextMenu(const QPoint& global_pos) {
|
||||
if (!context_menu_) {
|
||||
context_menu_.reset(new QMenu);
|
||||
context_menu_->addActions(GetPlaylistActions());
|
||||
@ -188,7 +186,6 @@ void DigitallyImportedServiceBase::ShowContextMenu(
|
||||
this, SLOT(ShowSettingsDialog()));
|
||||
}
|
||||
|
||||
context_item_ = model()->itemFromIndex(index);
|
||||
context_menu_->popup(global_pos);
|
||||
}
|
||||
|
||||
@ -213,7 +210,7 @@ void DigitallyImportedServiceBase::LoadPlaylistFinished() {
|
||||
}
|
||||
|
||||
void DigitallyImportedServiceBase::ShowSettingsDialog() {
|
||||
emit OpenSettingsAtPage(SettingsDialog::Page_DigitallyImported);
|
||||
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_DigitallyImported);
|
||||
}
|
||||
|
||||
DigitallyImportedClient::ChannelList DigitallyImportedServiceBase::Channels() {
|
||||
@ -244,10 +241,6 @@ void DigitallyImportedServiceBase::LoadStation(const QString& key) {
|
||||
connect(reply, SIGNAL(finished()), SLOT(LoadPlaylistFinished()));
|
||||
}
|
||||
|
||||
QModelIndex DigitallyImportedServiceBase::GetCurrentIndex() {
|
||||
return context_item_->index();
|
||||
}
|
||||
|
||||
|
||||
DigitallyImportedService::DigitallyImportedService(
|
||||
Application* app, InternetModel* model, QObject* parent)
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
|
||||
QStandardItem* CreateRootItem();
|
||||
void LazyPopulate(QStandardItem* parent);
|
||||
void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos);
|
||||
void ShowContextMenu(const QPoint& global_pos);
|
||||
|
||||
void ReloadSettings();
|
||||
|
||||
@ -72,9 +72,6 @@ public slots:
|
||||
signals:
|
||||
void StreamsChanged();
|
||||
|
||||
protected:
|
||||
QModelIndex GetCurrentIndex();
|
||||
|
||||
private slots:
|
||||
void LoadPlaylistFinished();
|
||||
void Homepage();
|
||||
|
@ -156,7 +156,7 @@ void GroovesharkService::LazyPopulate(QStandardItem* item) {
|
||||
}
|
||||
|
||||
void GroovesharkService::ShowConfig() {
|
||||
emit OpenSettingsAtPage(SettingsDialog::Page_Grooveshark);
|
||||
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_Grooveshark);
|
||||
}
|
||||
|
||||
void GroovesharkService::Search(const QString& text, Playlist* playlist, bool now) {
|
||||
@ -434,7 +434,7 @@ void GroovesharkService::ResetSessionId() {
|
||||
s.setValue("sessionid", session_id_);
|
||||
}
|
||||
|
||||
void GroovesharkService::ShowContextMenu(const QModelIndex& index, const QPoint& global_pos) {
|
||||
void GroovesharkService::ShowContextMenu(const QPoint& global_pos) {
|
||||
EnsureMenuCreated();
|
||||
|
||||
// Check if we should display actions
|
||||
@ -442,6 +442,8 @@ void GroovesharkService::ShowContextMenu(const QModelIndex& index, const QPoint&
|
||||
display_remove_from_playlist_action = false,
|
||||
display_remove_from_favorites_action = false;
|
||||
|
||||
QModelIndex index(model()->current_index());
|
||||
|
||||
if (index.data(InternetModel::Role_Type).toInt() == InternetModel::Type_UserPlaylist &&
|
||||
index.data(Role_PlaylistType).toInt() == UserPlaylist) {
|
||||
display_delete_playlist_action = true;
|
||||
@ -463,11 +465,6 @@ void GroovesharkService::ShowContextMenu(const QModelIndex& index, const QPoint&
|
||||
remove_from_favorites_->setVisible(display_remove_from_favorites_action);
|
||||
|
||||
context_menu_->popup(global_pos);
|
||||
context_item_ = index;
|
||||
}
|
||||
|
||||
QModelIndex GroovesharkService::GetCurrentIndex() {
|
||||
return context_item_;
|
||||
}
|
||||
|
||||
void GroovesharkService::UpdateTotalSongCount(int count) {
|
||||
@ -1168,12 +1165,12 @@ void GroovesharkService::NewPlaylistCreated(QNetworkReply* reply, const QString&
|
||||
}
|
||||
|
||||
void GroovesharkService::DeleteCurrentPlaylist() {
|
||||
if (context_item_.data(InternetModel::Role_Type).toInt() !=
|
||||
if (model()->current_index().data(InternetModel::Role_Type).toInt() !=
|
||||
InternetModel::Type_UserPlaylist) {
|
||||
return;
|
||||
}
|
||||
|
||||
int playlist_id = context_item_.data(Role_UserPlaylistId).toInt();
|
||||
int playlist_id = model()->current_index().data(Role_UserPlaylistId).toInt();
|
||||
DeletePlaylist(playlist_id);
|
||||
}
|
||||
|
||||
@ -1212,12 +1209,14 @@ void GroovesharkService::PlaylistDeleted(QNetworkReply* reply, int playlist_id)
|
||||
}
|
||||
|
||||
void GroovesharkService::RenameCurrentPlaylist() {
|
||||
if (context_item_.data(InternetModel::Role_Type).toInt() != InternetModel::Type_UserPlaylist
|
||||
|| context_item_.data(Role_PlaylistType).toInt() != UserPlaylist) {
|
||||
const QModelIndex& index(model()->current_index());
|
||||
|
||||
if (index.data(InternetModel::Role_Type).toInt() != InternetModel::Type_UserPlaylist
|
||||
|| index.data(Role_PlaylistType).toInt() != UserPlaylist) {
|
||||
return;
|
||||
}
|
||||
|
||||
int playlist_id = context_item_.data(Role_UserPlaylistId).toInt();
|
||||
const int playlist_id = index.data(Role_UserPlaylistId).toInt();
|
||||
RenamePlaylist(playlist_id);
|
||||
}
|
||||
|
||||
@ -1284,13 +1283,15 @@ void GroovesharkService::UserFavoriteSongAdded(QNetworkReply* reply, int task_id
|
||||
}
|
||||
|
||||
void GroovesharkService::RemoveCurrentFromPlaylist() {
|
||||
if (context_item_.parent().data(InternetModel::Role_Type).toInt() !=
|
||||
const QModelIndex& index(model()->current_index());
|
||||
|
||||
if (index.parent().data(InternetModel::Role_Type).toInt() !=
|
||||
InternetModel::Type_UserPlaylist) {
|
||||
return;
|
||||
}
|
||||
|
||||
int playlist_id = context_item_.data(Role_UserPlaylistId).toInt();
|
||||
int song_id = ExtractSongId(context_item_.data(InternetModel::Role_Url).toUrl());
|
||||
int playlist_id = index.data(Role_UserPlaylistId).toInt();
|
||||
int song_id = ExtractSongId(index.data(InternetModel::Role_Url).toUrl());
|
||||
if (song_id) {
|
||||
RemoveFromPlaylist(playlist_id, song_id);
|
||||
}
|
||||
@ -1308,11 +1309,13 @@ void GroovesharkService::RemoveFromPlaylist(int playlist_id, int song_id) {
|
||||
}
|
||||
|
||||
void GroovesharkService::RemoveCurrentFromFavorites() {
|
||||
if (context_item_.parent().data(Role_PlaylistType).toInt() != UserFavorites) {
|
||||
const QModelIndex& index(model()->current_index());
|
||||
|
||||
if (index.parent().data(Role_PlaylistType).toInt() != UserFavorites) {
|
||||
return;
|
||||
}
|
||||
|
||||
int song_id = ExtractSongId(context_item_.data(InternetModel::Role_Url).toUrl());
|
||||
int song_id = ExtractSongId(index.data(InternetModel::Role_Url).toUrl());
|
||||
if (song_id) {
|
||||
RemoveFromFavorites(song_id);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class GroovesharkService : public InternetService {
|
||||
smart_playlists::GeneratorPtr CreateGenerator(QStandardItem* item);
|
||||
void DropMimeData(const QMimeData* data, const QModelIndex& index);
|
||||
QList<QAction*> playlistitem_actions(const Song& song);
|
||||
void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos);
|
||||
void ShowContextMenu(const QPoint& global_pos);
|
||||
|
||||
void Search(const QString& text, Playlist* playlist, bool now = false);
|
||||
// User should be logged in to be able to generate streaming urls
|
||||
@ -131,8 +131,6 @@ class GroovesharkService : public InternetService {
|
||||
void ShowConfig();
|
||||
|
||||
protected:
|
||||
QModelIndex GetCurrentIndex();
|
||||
|
||||
struct PlaylistInfo {
|
||||
PlaylistInfo() {}
|
||||
PlaylistInfo(int id, QString name, QStandardItem* item)
|
||||
@ -249,7 +247,6 @@ class GroovesharkService : public InternetService {
|
||||
NetworkAccessManager* network_;
|
||||
|
||||
QMenu* context_menu_;
|
||||
QModelIndex context_item_;
|
||||
int current_song_id_;
|
||||
|
||||
QAction* create_playlist_;
|
||||
|
@ -273,17 +273,12 @@ QWidget* IcecastService::HeaderWidget() const {
|
||||
return filter_;
|
||||
}
|
||||
|
||||
void IcecastService::ShowContextMenu(const QModelIndex& index,
|
||||
const QPoint& global_pos) {
|
||||
void IcecastService::ShowContextMenu(const QPoint& global_pos) {
|
||||
EnsureMenuCreated();
|
||||
|
||||
if (index.model() == model_)
|
||||
context_item_ = index;
|
||||
else
|
||||
context_item_ = QModelIndex();
|
||||
|
||||
const bool can_play = context_item_.isValid() &&
|
||||
model_->GetSong(context_item_).is_valid();
|
||||
const bool can_play = model()->current_index().isValid() &&
|
||||
model()->current_index().model() == model_ &&
|
||||
model_->GetSong(model()->current_index()).is_valid();
|
||||
|
||||
GetAppendToPlaylistAction()->setEnabled(can_play);
|
||||
GetReplacePlaylistAction()->setEnabled(can_play);
|
||||
@ -308,7 +303,3 @@ void IcecastService::EnsureMenuCreated() {
|
||||
void IcecastService::Homepage() {
|
||||
QDesktopServices::openUrl(QUrl(kHomepage));
|
||||
}
|
||||
|
||||
QModelIndex IcecastService::GetCurrentIndex() {
|
||||
return context_item_;
|
||||
}
|
||||
|
@ -48,13 +48,10 @@ public:
|
||||
QStandardItem* CreateRootItem();
|
||||
void LazyPopulate(QStandardItem* item);
|
||||
|
||||
void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos);
|
||||
void ShowContextMenu(const QPoint& global_pos);
|
||||
|
||||
QWidget* HeaderWidget() const;
|
||||
|
||||
protected:
|
||||
QModelIndex GetCurrentIndex();
|
||||
|
||||
private slots:
|
||||
void LoadDirectory();
|
||||
void Homepage();
|
||||
@ -70,7 +67,6 @@ private:
|
||||
QStandardItem* root_;
|
||||
NetworkAccessManager* network_;
|
||||
QMenu* context_menu_;
|
||||
QModelIndex context_item_;
|
||||
|
||||
IcecastBackend* backend_;
|
||||
IcecastModel* model_;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "groovesharkservice.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/mergedproxymodel.h"
|
||||
#include "podcasts/podcastservice.h"
|
||||
#include "smartplaylists/generatormimedata.h"
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
@ -65,6 +66,7 @@ InternetModel::InternetModel(Application* app, QObject* parent)
|
||||
#endif
|
||||
AddService(new GroovesharkService(app, this));
|
||||
AddService(new MagnatuneService(app, this));
|
||||
AddService(new PodcastService(app, this));
|
||||
AddService(new SavedRadio(app, this));
|
||||
AddService(new SkyFmService(app, this));
|
||||
AddService(new SomaFMService(app, this));
|
||||
@ -89,8 +91,8 @@ void InternetModel::AddService(InternetService *service) {
|
||||
|
||||
connect(service, SIGNAL(StreamError(QString)), SIGNAL(StreamError(QString)));
|
||||
connect(service, SIGNAL(StreamMetadataFound(QUrl,Song)), SIGNAL(StreamMetadataFound(QUrl,Song)));
|
||||
connect(service, SIGNAL(OpenSettingsAtPage(SettingsDialog::Page)), SIGNAL(OpenSettingsAtPage(SettingsDialog::Page)));
|
||||
connect(service, SIGNAL(AddToPlaylistSignal(QMimeData*)), SIGNAL(AddToPlaylist(QMimeData*)));
|
||||
connect(service, SIGNAL(ScrollToIndex(QModelIndex)), SIGNAL(ScrollToIndex(QModelIndex)));
|
||||
connect(service, SIGNAL(destroyed()), SLOT(ServiceDeleted()));
|
||||
|
||||
service->ReloadSettings();
|
||||
@ -254,11 +256,19 @@ bool InternetModel::dropMimeData(const QMimeData* data, Qt::DropAction action, i
|
||||
return true;
|
||||
}
|
||||
|
||||
void InternetModel::ShowContextMenu(const QModelIndex& merged_model_index,
|
||||
const QPoint& global_pos) {
|
||||
InternetService* service = ServiceForIndex(merged_model_index);
|
||||
void InternetModel::ShowContextMenu(const QModelIndexList& selected_merged_model_indexes,
|
||||
const QModelIndex& current_merged_model_index,
|
||||
const QPoint& global_pos) {
|
||||
current_index_ = merged_model_->mapToSource(current_merged_model_index);
|
||||
|
||||
selected_indexes_.clear();
|
||||
foreach (const QModelIndex& index, selected_merged_model_indexes) {
|
||||
selected_indexes_ << merged_model_->mapToSource(index);
|
||||
}
|
||||
|
||||
InternetService* service = ServiceForIndex(current_merged_model_index);
|
||||
if (service)
|
||||
service->ShowContextMenu(merged_model_->mapToSource(merged_model_index), global_pos);
|
||||
service->ShowContextMenu(global_pos);
|
||||
}
|
||||
|
||||
void InternetModel::ReloadSettings() {
|
||||
|
@ -141,19 +141,23 @@ public:
|
||||
bool hasChildren(const QModelIndex& parent) const;
|
||||
int rowCount(const QModelIndex& parent) const;
|
||||
|
||||
void ShowContextMenu(const QModelIndex& merged_model_index,
|
||||
void ShowContextMenu(const QModelIndexList& selected_merged_model_indexes,
|
||||
const QModelIndex& current_merged_model_index,
|
||||
const QPoint& global_pos);
|
||||
void ReloadSettings();
|
||||
|
||||
Application* app() const { return app_; }
|
||||
MergedProxyModel* merged_model() const { return merged_model_; }
|
||||
|
||||
const QModelIndex& current_index() const { return current_index_; }
|
||||
const QModelIndexList& selected_indexes() const { return selected_indexes_; }
|
||||
|
||||
signals:
|
||||
void StreamError(const QString& message);
|
||||
void StreamMetadataFound(const QUrl& original_url, const Song& song);
|
||||
void OpenSettingsAtPage(SettingsDialog::Page);
|
||||
|
||||
void AddToPlaylist(QMimeData* data);
|
||||
void ScrollToIndex(const QModelIndex& index);
|
||||
|
||||
private slots:
|
||||
void ServiceDeleted();
|
||||
@ -163,6 +167,11 @@ private:
|
||||
|
||||
Application* app_;
|
||||
MergedProxyModel* merged_model_;
|
||||
|
||||
// Set when a context menu is requested, can be accessed by context menu
|
||||
// actions to do things to the current item.
|
||||
QModelIndexList selected_indexes_;
|
||||
QModelIndex current_index_;
|
||||
};
|
||||
|
||||
#endif // INTERNETMODEL_H
|
||||
|
@ -94,13 +94,13 @@ void InternetService::AddItemsToPlaylist(const QModelIndexList& indexes, AddMode
|
||||
}
|
||||
|
||||
void InternetService::AppendToPlaylist() {
|
||||
AddItemToPlaylist(GetCurrentIndex(), AddMode_Append);
|
||||
AddItemsToPlaylist(model()->selected_indexes(), AddMode_Append);
|
||||
}
|
||||
|
||||
void InternetService::ReplacePlaylist() {
|
||||
AddItemToPlaylist(GetCurrentIndex(), AddMode_Replace);
|
||||
AddItemsToPlaylist(model()->selected_indexes(), AddMode_Replace);
|
||||
}
|
||||
|
||||
void InternetService::OpenInNewPlaylist() {
|
||||
AddItemToPlaylist(GetCurrentIndex(), AddMode_OpenInNew);
|
||||
AddItemsToPlaylist(model()->selected_indexes(), AddMode_OpenInNew);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
virtual QStandardItem* CreateRootItem() = 0;
|
||||
virtual void LazyPopulate(QStandardItem* parent) = 0;
|
||||
|
||||
virtual void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos) {}
|
||||
virtual void ShowContextMenu(const QPoint& global_pos) {}
|
||||
virtual void ItemDoubleClicked(QStandardItem* item) {}
|
||||
// Create a generator for smart playlists
|
||||
virtual smart_playlists::GeneratorPtr CreateGenerator(QStandardItem* item) { return smart_playlists::GeneratorPtr(); }
|
||||
@ -68,9 +68,9 @@ public:
|
||||
signals:
|
||||
void StreamError(const QString& message);
|
||||
void StreamMetadataFound(const QUrl& original_url, const Song& song);
|
||||
void OpenSettingsAtPage(SettingsDialog::Page page);
|
||||
|
||||
void AddToPlaylistSignal(QMimeData* data);
|
||||
void ScrollToIndex(const QModelIndex& index);
|
||||
|
||||
private slots:
|
||||
void AppendToPlaylist();
|
||||
@ -78,10 +78,6 @@ private slots:
|
||||
void OpenInNewPlaylist();
|
||||
|
||||
protected:
|
||||
// Subclass provides the currently selected QModelIndex on InternetService's
|
||||
// request.
|
||||
virtual QModelIndex GetCurrentIndex() = 0;
|
||||
|
||||
// Returns all the playlist insertion related QActions (see below).
|
||||
QList<QAction*> GetPlaylistActions();
|
||||
|
||||
|
@ -39,7 +39,8 @@ void InternetView::contextMenuEvent(QContextMenuEvent* e) {
|
||||
MergedProxyModel* merged_model = static_cast<MergedProxyModel*>(model());
|
||||
InternetModel* internet_model = static_cast<InternetModel*>(merged_model->sourceModel());
|
||||
|
||||
internet_model->ShowContextMenu(index, e->globalPos());
|
||||
internet_model->ShowContextMenu(selectionModel()->selectedRows(), index,
|
||||
e->globalPos());
|
||||
}
|
||||
|
||||
void InternetView::currentChanged(const QModelIndex ¤t, const QModelIndex&) {
|
||||
|
@ -146,3 +146,9 @@ void InternetViewContainer::SetHeaderHeight(int height) {
|
||||
if (header)
|
||||
header->setMaximumHeight(height);
|
||||
}
|
||||
|
||||
void InternetViewContainer::ScrollToIndex(const QModelIndex& index) {
|
||||
tree()->scrollTo(index, QTreeView::PositionAtCenter);
|
||||
tree()->setCurrentIndex(index);
|
||||
tree()->expand(index);
|
||||
}
|
||||
|
@ -43,6 +43,9 @@ class InternetViewContainer : public QWidget {
|
||||
|
||||
InternetView* tree() const;
|
||||
|
||||
public slots:
|
||||
void ScrollToIndex(const QModelIndex& index);
|
||||
|
||||
private slots:
|
||||
void Collapsed(const QModelIndex& index);
|
||||
void Expanded(const QModelIndex& index);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user