1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 15:29:42 +01:00

Remove boost::{function,bind} from IOFactories

This commit is contained in:
Uwe L. Korn 2014-08-18 15:53:49 +01:00
parent e708e2533e
commit 9f4cf09152
11 changed files with 43 additions and 62 deletions

View File

@ -36,8 +36,6 @@
#include "StatResponseHandler.h"
#include "UrlHandler.h"
#include <boost/bind.hpp>
#include <QHash>
using namespace Tomahawk;
@ -242,8 +240,8 @@ Api_v1::sid( QxtWebRequestEvent* event, QString unused )
return send404( event );
}
boost::function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
boost::bind( &Api_v1::processSid, this, event, rp, _1, _2 );
function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
bind( &Api_v1::processSid, this, event, rp, _1, _2 );
Tomahawk::UrlHandler::getIODeviceForUrl( rp, rp->url(), callback );
}

View File

@ -24,20 +24,19 @@
#include "DllMacro.h"
#include "Typedefs.h"
#include "Query.h"
#include "utils/tr1-functional.h"
#include <QObject>
#include <QList>
#include <QStringList>
#include <boost/function.hpp>
namespace Tomahawk
{
class PipelinePrivate;
class Resolver;
class ExternalResolver;
typedef boost::function<Tomahawk::ExternalResolver*( QString, QString, QStringList )> ResolverFactoryFunc;
typedef function<Tomahawk::ExternalResolver*( QString, QString, QStringList )> ResolverFactoryFunc;
class DLLEXPORT Pipeline : public QObject
{

View File

@ -26,8 +26,6 @@
#include <QFile>
#include <boost/bind.hpp>
Q_DECLARE_METATYPE( IODeviceFactoryFunc )
Q_DECLARE_METATYPE( IODeviceCallback )
@ -42,12 +40,12 @@ initialiseDefaultIOFactories()
{
{
// _1 = result, _2 = callback function for IODevice
IODeviceFactoryFunc fac = boost::bind( localFileIODeviceFactory, _1, _2, _3 );
IODeviceFactoryFunc fac = bind( localFileIODeviceFactory, _1, _2, _3 );
iofactories.insert( "file", fac );
}
{
IODeviceFactoryFunc fac = boost::bind( httpIODeviceFactory, _1, _2, _3 );
IODeviceFactoryFunc fac = bind( httpIODeviceFactory, _1, _2, _3 );
iofactories.insert( "http", fac );
iofactories.insert( "https", fac );
}
@ -68,7 +66,7 @@ registerIODeviceFactory( const QString &proto, IODeviceFactoryFunc fac )
void
getIODeviceForUrl( const Tomahawk::result_ptr& result, const QString& url,
boost::function< void ( const QString, QSharedPointer< QIODevice > ) > callback )
function< void ( const QString, QSharedPointer< QIODevice > ) > callback )
{
if ( iofactories.isEmpty() )
{
@ -98,7 +96,7 @@ getIODeviceForUrl( const Tomahawk::result_ptr& result, const QString& url,
void
localFileIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
boost::function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback )
function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback )
{
// ignore "file://" at front of url
QFile* io = new QFile( url.mid( QString( "file://" ).length() ) );
@ -113,7 +111,7 @@ localFileIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
void
httpIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
boost::function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback )
function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback )
{
QNetworkRequest req( url );
// Follow HTTP Redirects
@ -127,7 +125,7 @@ httpIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
void
getUrlTranslation( const Tomahawk::result_ptr& result, const QString& url, boost::function< void ( const QString& ) > callback )
getUrlTranslation( const Tomahawk::result_ptr& result, const QString& url, function< void ( const QString& ) > callback )
{
QRegExp rx( "^([a-zA-Z0-9]+)://(.+)$" );
if ( rx.indexIn( url ) == -1 )

View File

@ -24,14 +24,13 @@
#include "DllMacro.h"
#include "Typedefs.h"
#include "utils/tr1-functional.h"
#include <boost/function.hpp>
typedef boost::function< void( const Tomahawk::result_ptr&, const QString&,
boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > )> IODeviceFactoryFunc;
typedef boost::function< void( const Tomahawk::result_ptr&, const QString&,
boost::function< void( const QString& ) > )> UrlTranslatorFunc;
typedef boost::function< void ( const QString&, QSharedPointer< QIODevice >& ) > IODeviceCallback;
typedef function< void( const Tomahawk::result_ptr&, const QString&,
function< void( const QString&, QSharedPointer< QIODevice >& ) > )> IODeviceFactoryFunc;
typedef function< void( const Tomahawk::result_ptr&, const QString&,
function< void( const QString& ) > )> UrlTranslatorFunc;
typedef function< void ( const QString&, QSharedPointer< QIODevice >& ) > IODeviceCallback;
namespace Tomahawk
@ -41,12 +40,12 @@ namespace UrlHandler
{
DLLEXPORT void getIODeviceForUrl( const Tomahawk::result_ptr&, const QString& url,
boost::function< void ( const QString, QSharedPointer< QIODevice > ) > callback );
function< void ( const QString, QSharedPointer< QIODevice > ) > callback );
DLLEXPORT void registerIODeviceFactory( const QString& proto, IODeviceFactoryFunc fac );
DLLEXPORT void localFileIODeviceFactory( const Tomahawk::result_ptr& result, const QString& url,
boost::function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback );
function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback );
DLLEXPORT void httpIODeviceFactory( const Tomahawk::result_ptr& result, const QString& url,
boost::function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback );
function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback );
} // namespace UrlHandler
} // namespace Tomahawk

View File

@ -34,7 +34,7 @@
#include <lastfm/XmlQuery.h>
#include <lastfm/Track.h>
#include <boost/bind.hpp>
#include <boost/ref.hpp>
using namespace Tomahawk::Accounts;
@ -367,7 +367,7 @@ LastFmConfig::syncLoved()
foreach ( const Tomahawk::track_ptr& lastfmLoved, m_lastfmLoved )
{
QSet< Tomahawk::track_ptr >::const_iterator iter = std::find_if( myLoved.begin(), myLoved.end(), boost::bind( &trackEquality, _1, boost::ref( lastfmLoved ) ) );
QSet< Tomahawk::track_ptr >::const_iterator iter = std::find_if( myLoved.begin(), myLoved.end(), bind( &trackEquality, _1, boost::ref( lastfmLoved ) ) );
if ( iter == myLoved.constEnd() )
{
// qDebug() << "Found last.fm loved track that we didn't have loved locally:" << lastfmLoved->track() << lastfmLoved->artist();
@ -378,7 +378,7 @@ LastFmConfig::syncLoved()
foreach ( const Tomahawk::track_ptr& localLoved, myLoved )
{
qDebug() << "CHECKING FOR LOCAL LOVED ON LAST.FM TOO:" << m_localLoved[ localLoved ].value.toString() << localLoved->track() << localLoved->artist();
QSet< Tomahawk::track_ptr >::const_iterator iter = std::find_if( m_lastfmLoved.begin(), m_lastfmLoved.end(), boost::bind( &trackEquality, _1, boost::ref( localLoved ) ) );
QSet< Tomahawk::track_ptr >::const_iterator iter = std::find_if( m_lastfmLoved.begin(), m_lastfmLoved.end(), bind( &trackEquality, _1, boost::ref( localLoved ) ) );
qDebug() << "Result:" << (iter == m_lastfmLoved.constEnd());
// If we unloved it locally, but it's still loved on last.fm, unlove it

View File

@ -43,8 +43,6 @@
#include <QDir>
#include <boost/bind.hpp>
using namespace Tomahawk;
#define AUDIO_VOLUME_STEP 5
@ -711,8 +709,8 @@ AudioEngine::performLoadIODevice( const result_ptr& result, const QString& url )
if ( !TomahawkUtils::isLocalResult( url ) && !TomahawkUtils::isHttpResult( url )
&& !TomahawkUtils::isRtmpResult( url ) )
{
boost::function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
boost::bind( &AudioEngine::performLoadTrack, this, result, _1, _2 );
function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
bind( &AudioEngine::performLoadTrack, this, result, _1, _2 );
Tomahawk::UrlHandler::getIODeviceForUrl( result, url, callback );
}
else

View File

@ -56,8 +56,6 @@
#include <QNetworkRequest>
#include <QNetworkReply>
#include <boost/bind.hpp>
typedef QPair< QList< SipInfo >, Connection* > sipConnectionPair;
Q_DECLARE_METATYPE( sipConnectionPair )
@ -89,7 +87,7 @@ Servent::Servent( QObject* parent )
setProxy( QNetworkProxy::NoProxy );
IODeviceFactoryFunc fac = boost::bind( &Servent::remoteIODeviceFactory, this, _1, _2, _3 );
IODeviceFactoryFunc fac = bind( &Servent::remoteIODeviceFactory, this, _1, _2, _3 );
Tomahawk::UrlHandler::registerIODeviceFactory( "servent", fac );
}
@ -1245,7 +1243,7 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
void
Servent::remoteIODeviceFactory( const Tomahawk::result_ptr& result, const QString& url,
boost::function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback )
function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback )
{
QSharedPointer<QIODevice> sp;

View File

@ -29,6 +29,7 @@
#include "DllMacro.h"
#include "Typedefs.h"
#include "utils/tr1-functional.h"
#include <QHostAddress>
#include <QTcpServer>
@ -45,11 +46,6 @@ class RemoteCollectionConnection;
class SipInfo;
class StreamConnection;
namespace boost
{
template <class T> class function;
} // boost
class ServentPrivate;
class DLLEXPORT Servent : public QTcpServer
@ -95,7 +91,7 @@ public:
ControlConnection* lookupControlConnection( const QString& nodeid );
void remoteIODeviceFactory( const Tomahawk::result_ptr& result, const QString& url,
boost::function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback );
function< void ( const QString&, QSharedPointer< QIODevice >& ) > callback );
// you may call this method as often as you like for the same peerInfo, dupe checking is done inside
void registerPeer( const Tomahawk::peerinfo_ptr& peerInfo );

View File

@ -33,9 +33,6 @@
#include "SourceList.h"
#include "UrlHandler.h"
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <QFile>
#include <QTimer>
@ -188,8 +185,8 @@ StreamConnection::startSending( const Tomahawk::result_ptr& result )
m_result = result;
qDebug() << "Starting to transmit" << m_result->url();
boost::function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
boost::bind( &StreamConnection::reallyStartSending, this, result, _1, _2 );
function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
bind( &StreamConnection::reallyStartSending, this, result, _1, _2 );
Tomahawk::UrlHandler::getIODeviceForUrl( m_result, m_result->url(), callback );
}

View File

@ -41,7 +41,6 @@
#include "SourceList.h"
#include "UrlHandler.h"
#include <boost/bind.hpp>
#include <QFile>
#include <QFileInfo>
#include <QMap>
@ -443,9 +442,9 @@ JSResolverHelper::addCustomUrlHandler( const QString& protocol,
{
m_urlCallbackIsAsync = ( isAsynchronous.toLower() == "true" ) ? true : false;
boost::function< void( const Tomahawk::result_ptr&, const QString&,
boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > )> fac =
boost::bind( &JSResolverHelper::customIODeviceFactory, this, _1, _2, _3 );
function< void( const Tomahawk::result_ptr&, const QString&,
function< void( const QString&, QSharedPointer< QIODevice >& ) > )> fac =
bind( &JSResolverHelper::customIODeviceFactory, this, _1, _2, _3 );
Tomahawk::UrlHandler::registerIODeviceFactory( protocol, fac );
m_urlCallback = callbackFuncName;
@ -461,7 +460,7 @@ JSResolverHelper::reportStreamUrl( const QString& qid, const QString& streamUrl
void
JSResolverHelper::customIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback )
function< void( const QString&, QSharedPointer< QIODevice >& ) > callback )
{
//can be sync or async
if ( m_urlCallbackIsAsync )
@ -493,7 +492,7 @@ JSResolverHelper::reportStreamUrl( const QString& qid,
if ( !m_streamCallbacks.contains( qid ) )
return;
boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback = m_streamCallbacks.take( qid );
function< void( const QString&, QSharedPointer< QIODevice >& ) > callback = m_streamCallbacks.take( qid );
QMap<QString, QString> parsedHeaders;
foreach ( const QString& key, headers.keys()) {
@ -873,7 +872,7 @@ JSResolverHelper::deleteFuzzyIndex()
void
JSResolverHelper::returnStreamUrl( const QString& streamUrl, const QMap<QString, QString>& headers,
boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback )
function< void( const QString&, QSharedPointer< QIODevice >& ) > callback )
{
if ( streamUrl.isEmpty() || !( TomahawkUtils::isHttpResult( streamUrl ) || TomahawkUtils::isHttpsResult( streamUrl ) ) )
{
@ -899,7 +898,7 @@ JSResolverHelper::returnStreamUrl( const QString& streamUrl, const QMap<QString,
Q_DECLARE_METATYPE( IODeviceCallback )
void
JSResolverHelper::gotStreamUrl( boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback, NetworkReply* reply )
JSResolverHelper::gotStreamUrl( function< void( const QString&, QSharedPointer< QIODevice >& ) > callback, NetworkReply* reply )
{
//boost::functions cannot accept temporaries as parameters
QSharedPointer< QIODevice > sp = QSharedPointer< QIODevice >( reply->reply(), &QObject::deleteLater );

View File

@ -27,15 +27,14 @@
#include "UrlHandler.h"
#include "database/fuzzyindex/FuzzyIndex.h"
#include "utils/NetworkReply.h"
#include <boost/function.hpp>
#include "utils/tr1-functional.h"
#include <QObject>
#include <QVariantMap>
class JSResolver;
Q_DECLARE_METATYPE( boost::function< void( QSharedPointer< QIODevice >& ) > )
Q_DECLARE_METATYPE( function< void( QSharedPointer< QIODevice >& ) > )
class DLLEXPORT JSResolverHelper : public QObject
{
@ -109,7 +108,7 @@ public:
* INTERNAL USE ONLY!
*/
void customIODeviceFactory( const Tomahawk::result_ptr&, const QString& url,
boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback ); // async
function< void( const QString&, QSharedPointer< QIODevice >& ) > callback ); // async
public slots:
QByteArray readRaw( const QString& fileName );
@ -142,7 +141,7 @@ private slots:
private:
Tomahawk::query_ptr parseTrack( const QVariantMap& track );
void returnStreamUrl( const QString& streamUrl, const QMap<QString, QString>& headers,
boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback );
function< void( const QString&, QSharedPointer< QIODevice >& ) > callback );
bool indexDataFromVariant( const QVariantMap& map, struct Tomahawk::IndexData& indexData );
QVariantList searchInFuzzyIndex( const Tomahawk::query_ptr& query );
@ -150,8 +149,8 @@ private:
QVariantMap m_resolverConfig;
JSResolver* m_resolver;
QString m_scriptPath, m_urlCallback, m_urlTranslator;
QHash< QString, boost::function< void( const QString&, QSharedPointer< QIODevice >& ) > > m_streamCallbacks;
QHash< QString, boost::function< void( const QString& ) > > m_translatorCallbacks;
QHash< QString, function< void( const QString&, QSharedPointer< QIODevice >& ) > > m_streamCallbacks;
QHash< QString, function< void( const QString& ) > > m_translatorCallbacks;
bool m_urlCallbackIsAsync;
QString m_pendingUrl;
Tomahawk::album_ptr m_pendingAlbum;