1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-02-25 04:13:10 +01:00

* Cleaned up QtScriptResolver and added vital debug output.

This commit is contained in:
Christian Muehlhaeuser 2011-07-21 00:59:26 +02:00
parent 7f4d64d8dc
commit dbf31d704a
2 changed files with 22 additions and 9 deletions

View File

@ -68,14 +68,14 @@ QtScriptResolverHelper::compress( const QString& data )
QString
QtScriptResolverHelper::readCompressed(const QString& fileName)
QtScriptResolverHelper::readCompressed( const QString& fileName )
{
return compress( readRaw( fileName ) );
}
QString
QtScriptResolverHelper::readBase64(const QString& fileName)
QtScriptResolverHelper::readBase64( const QString& fileName )
{
return readRaw( fileName ).toBase64();
}
@ -91,7 +91,8 @@ QtScriptResolverHelper::resolverData()
}
void QtScriptResolverHelper::log(const QString& message)
void
QtScriptResolverHelper::log( const QString& message )
{
qDebug() << m_scriptPath << ":" << message;
}
@ -104,6 +105,14 @@ QtScriptResolverHelper::setResolverConfig( QVariantMap config )
}
void
ScriptEngine::javaScriptConsoleMessage( const QString& message, int lineNumber, const QString& sourceID )
{
qDebug() << "JAVASCRIPT:" << m_scriptPath << message << lineNumber << sourceID;
Q_ASSERT( false );
}
QtScriptResolver::QtScriptResolver( const QString& scriptPath )
: Tomahawk::ExternalResolver( scriptPath )
, m_ready( false )
@ -118,7 +127,8 @@ QtScriptResolver::QtScriptResolver( const QString& scriptPath )
{
qDebug() << Q_FUNC_INFO << "Failed loading JavaScript resolver:" << scriptPath;
m_error = Tomahawk::ExternalResolver::FileNotFound;
} else
}
else
{
init();
}
@ -132,6 +142,7 @@ QtScriptResolver::~QtScriptResolver()
delete m_engine;
}
void
QtScriptResolver::reload()
{
@ -145,6 +156,7 @@ QtScriptResolver::reload()
}
}
void
QtScriptResolver::init()
{
@ -191,12 +203,14 @@ QtScriptResolver::init()
Tomahawk::Pipeline::instance()->addResolver( this );
}
Tomahawk::ExternalResolver::ErrorState
QtScriptResolver::error() const
{
return m_error;
}
void
QtScriptResolver::resolve( const Tomahawk::query_ptr& query )
{
@ -207,7 +221,7 @@ QtScriptResolver::resolve( const Tomahawk::query_ptr& query )
return;
}
// qDebug() << Q_FUNC_INFO << query->toString();
qDebug() << Q_FUNC_INFO << "Resolving now with" << m_name << "-" << query->toString();
QString eval;
if ( !query->isFullTextQuery() )
@ -225,7 +239,7 @@ QtScriptResolver::resolve( const Tomahawk::query_ptr& query )
"} else {"
" resolve( '%1', '', '', '%2' );"
"}"
)
)
.arg( query->id().replace( "'", "\\'" ) )
.arg( query->fullTextQuery().replace( "'", "\\'" ) );
}

View File

@ -50,7 +50,7 @@ public slots:
QString compress( const QString& data );
QVariantMap resolverData();
void log( const QString& message);
void log( const QString& message );
bool fakeEnv() { return false; }
private:
@ -86,8 +86,7 @@ public slots:
}
protected:
virtual void javaScriptConsoleMessage( const QString & message, int lineNumber, const QString & sourceID )
{ qDebug() << "JAVASCRIPT:" << m_scriptPath << message << lineNumber << sourceID; Q_ASSERT(false);}
virtual void javaScriptConsoleMessage( const QString& message, int lineNumber, const QString& sourceID );
private:
QtScriptResolver* m_parent;