1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-04 13:17:34 +02:00

* Moved isLocalResult and isHttpResult to TomahawkUtils.

This commit is contained in:
Lucas Lira Gomes
2012-06-26 11:21:41 -03:00
committed by Dominik Schmidt
parent e4c0bd7f30
commit d8a7669df8
4 changed files with 22 additions and 20 deletions

View File

@@ -440,7 +440,8 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
{ {
setCurrentTrack( result ); setCurrentTrack( result );
if ( !isHttpResult( m_currentTrack->url() ) && !isLocalResult( m_currentTrack->url() ) ) if ( !TomahawkUtils::isHttpResult( m_currentTrack->url() ) &&
!TomahawkUtils::isLocalResult( m_currentTrack->url() ) )
{ {
io = Servent::instance()->getIODeviceForUrl( m_currentTrack ); io = Servent::instance()->getIODeviceForUrl( m_currentTrack );
@@ -458,7 +459,8 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
m_state = Loading; m_state = Loading;
emit loading( m_currentTrack ); emit loading( m_currentTrack );
if ( !isHttpResult( m_currentTrack->url() ) && !isLocalResult( m_currentTrack->url() ) ) if ( !TomahawkUtils::isHttpResult( m_currentTrack->url() ) &&
!TomahawkUtils::isLocalResult( m_currentTrack->url() ) )
{ {
if ( QNetworkReply* qnr_io = qobject_cast< QNetworkReply* >( io.data() ) ) if ( QNetworkReply* qnr_io = qobject_cast< QNetworkReply* >( io.data() ) )
m_mediaObject->setCurrentSource( new QNR_IODeviceStream( qnr_io, this ) ); m_mediaObject->setCurrentSource( new QNR_IODeviceStream( qnr_io, this ) );
@@ -468,7 +470,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
} }
else else
{ {
if ( !isLocalResult( m_currentTrack->url() ) ) if ( !TomahawkUtils::isLocalResult( m_currentTrack->url() ) )
{ {
QUrl furl = m_currentTrack->url(); QUrl furl = m_currentTrack->url();
if ( m_currentTrack->url().contains( "?" ) ) if ( m_currentTrack->url().contains( "?" ) )
@@ -977,20 +979,6 @@ AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
} }
bool
AudioEngine::isHttpResult( const QString& url ) const
{
return url.startsWith( "http://" ) || url.startsWith( "https://" );
}
bool
AudioEngine::isLocalResult( const QString& url ) const
{
return url.startsWith( "file://" );
}
void void
AudioEngine::checkStateQueue() AudioEngine::checkStateQueue()
{ {

View File

@@ -152,9 +152,6 @@ private:
void setState( AudioState state ); void setState( AudioState state );
bool isHttpResult( const QString& ) const;
bool isLocalResult( const QString& ) const;
QSharedPointer<QIODevice> m_input; QSharedPointer<QIODevice> m_input;
Tomahawk::query_ptr m_stopAfterTrack; Tomahawk::query_ptr m_stopAfterTrack;

View File

@@ -772,6 +772,20 @@ md5( const QByteArray& data )
} }
bool
isHttpResult( const QString& url )
{
return url.startsWith( "http://" ) || url.startsWith( "https://" );
}
bool
isLocalResult( const QString& url )
{
return url.startsWith( "file://" );
}
void void
crash() crash()
{ {

View File

@@ -189,6 +189,9 @@ namespace TomahawkUtils
DLLEXPORT QString md5( const QByteArray& data ); DLLEXPORT QString md5( const QByteArray& data );
DLLEXPORT bool removeDirectory( const QString& dir ); DLLEXPORT bool removeDirectory( const QString& dir );
DLLEXPORT bool isHttpResult( const QString& url );
DLLEXPORT bool isLocalResult( const QString& url );
DLLEXPORT bool verifyFile( const QString& filePath, const QString& signature ); DLLEXPORT bool verifyFile( const QString& filePath, const QString& signature );
DLLEXPORT QString extractScriptPayload( const QString& filename, const QString& resolverId ); DLLEXPORT QString extractScriptPayload( const QString& filename, const QString& resolverId );
DLLEXPORT bool unzipFileInFolder( const QString& zipFileName, const QDir& folder ); DLLEXPORT bool unzipFileInFolder( const QString& zipFileName, const QDir& folder );