1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-04 21:27:58 +02: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 "StatResponseHandler.h"
#include "UrlHandler.h" #include "UrlHandler.h"
#include <boost/bind.hpp>
#include <QHash> #include <QHash>
using namespace Tomahawk; using namespace Tomahawk;
@@ -242,8 +240,8 @@ Api_v1::sid( QxtWebRequestEvent* event, QString unused )
return send404( event ); return send404( event );
} }
boost::function< void ( const QString, QSharedPointer< QIODevice > ) > callback = function< void ( const QString, QSharedPointer< QIODevice > ) > callback =
boost::bind( &Api_v1::processSid, this, event, rp, _1, _2 ); bind( &Api_v1::processSid, this, event, rp, _1, _2 );
Tomahawk::UrlHandler::getIODeviceForUrl( rp, rp->url(), callback ); Tomahawk::UrlHandler::getIODeviceForUrl( rp, rp->url(), callback );
} }

View File

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

View File

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

View File

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

View File

@@ -34,7 +34,7 @@
#include <lastfm/XmlQuery.h> #include <lastfm/XmlQuery.h>
#include <lastfm/Track.h> #include <lastfm/Track.h>
#include <boost/bind.hpp> #include <boost/ref.hpp>
using namespace Tomahawk::Accounts; using namespace Tomahawk::Accounts;
@@ -367,7 +367,7 @@ LastFmConfig::syncLoved()
foreach ( const Tomahawk::track_ptr& lastfmLoved, m_lastfmLoved ) 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() ) if ( iter == myLoved.constEnd() )
{ {
// qDebug() << "Found last.fm loved track that we didn't have loved locally:" << lastfmLoved->track() << lastfmLoved->artist(); // 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 ) 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(); 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()); qDebug() << "Result:" << (iter == m_lastfmLoved.constEnd());
// If we unloved it locally, but it's still loved on last.fm, unlove it // If we unloved it locally, but it's still loved on last.fm, unlove it

View File

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

View File

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

View File

@@ -29,6 +29,7 @@
#include "DllMacro.h" #include "DllMacro.h"
#include "Typedefs.h" #include "Typedefs.h"
#include "utils/tr1-functional.h"
#include <QHostAddress> #include <QHostAddress>
#include <QTcpServer> #include <QTcpServer>
@@ -45,11 +46,6 @@ class RemoteCollectionConnection;
class SipInfo; class SipInfo;
class StreamConnection; class StreamConnection;
namespace boost
{
template <class T> class function;
} // boost
class ServentPrivate; class ServentPrivate;
class DLLEXPORT Servent : public QTcpServer class DLLEXPORT Servent : public QTcpServer
@@ -95,7 +91,7 @@ public:
ControlConnection* lookupControlConnection( const QString& nodeid ); ControlConnection* lookupControlConnection( const QString& nodeid );
void remoteIODeviceFactory( const Tomahawk::result_ptr& result, const QString& url, 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 // 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 ); void registerPeer( const Tomahawk::peerinfo_ptr& peerInfo );

View File

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

View File

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

View File

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