diff --git a/src/libtomahawk/infosystem/InfoSystem.cpp b/src/libtomahawk/infosystem/InfoSystem.cpp index b72adeee0..5f965707c 100644 --- a/src/libtomahawk/infosystem/InfoSystem.cpp +++ b/src/libtomahawk/infosystem/InfoSystem.cpp @@ -34,6 +34,34 @@ namespace Tomahawk namespace InfoSystem { +static const int DEFAULT_TIMEOUT_MILLIS = 10000; + +InfoRequestData::InfoRequestData() + : requestId( TomahawkUtils::infosystemRequestId() ) +{ + init( QString() , Tomahawk::InfoSystem::InfoNoInfo, QVariant(), QVariantMap() ); +} + + +InfoRequestData::InfoRequestData( const quint64 rId, const QString& callr, const InfoType typ, const QVariant& inputvar, const QVariantMap& custom ) + : requestId( rId ) +{ + init( callr, typ, inputvar, custom ); +} + + +InfoRequestData::init( const QString& callr, const InfoType typ, const QVariant& inputvar, const QVariantMap& custom ) +{ + internalId = TomahawkUtils::infosystemRequestId(); + caller = callr; + type = typ; + input = inputvar; + customData = custom; + timeoutMillis = DEFAULT_TIMEOUT_MILLIS; + allSources = false; +} + + InfoPlugin::InfoPlugin() : QObject() { @@ -165,7 +193,7 @@ InfoSystem::getInfo( const QString &caller, const QVariantMap &customData, const { requestData.type = type; requestData.input = inputMap[ type ]; - requestData.timeoutMillis = timeoutMap.contains( type ) ? timeoutMap[ type ] : 10000; + requestData.timeoutMillis = timeoutMap.contains( type ) ? timeoutMap[ type ] : DEFAULT_TIMEOUT_MILLIS; QMetaObject::invokeMethod( m_infoSystemWorkerThreadController->worker(), "getInfo", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoRequestData, requestData ) ); } return false; diff --git a/src/libtomahawk/infosystem/InfoSystem.h b/src/libtomahawk/infosystem/InfoSystem.h index 73033f69e..ac9844515 100644 --- a/src/libtomahawk/infosystem/InfoSystem.h +++ b/src/libtomahawk/infosystem/InfoSystem.h @@ -61,27 +61,12 @@ struct InfoRequestData { uint timeoutMillis; bool allSources; - InfoRequestData() - : requestId( TomahawkUtils::infosystemRequestId() ) - , internalId( TomahawkUtils::infosystemRequestId() ) - , caller( QString() ) - , type( Tomahawk::InfoSystem::InfoNoInfo ) - , input( QVariant() ) - , customData( QVariantMap() ) - , timeoutMillis( 10000 ) - , allSources( false ) - {} + InfoRequestData(); - InfoRequestData( const quint64 rId, const QString &callr, const Tomahawk::InfoSystem::InfoType typ, const QVariant &inputvar, const QVariantMap &custom ) - : requestId( rId ) - , internalId( TomahawkUtils::infosystemRequestId() ) - , caller( callr ) - , type( typ ) - , input( inputvar ) - , customData( custom ) - , timeoutMillis( 10000 ) - , allSources( false ) - {} + InfoRequestData( const quint64 rId, const QString &callr, const Tomahawk::InfoSystem::InfoType typ, const QVariant &inputvar, const QVariantMap &custom ); + +private: + init( const QString& callr, const InfoType typ, const QVariant& inputvar, const QVariantMap& custom); };