From 80bb0de53a06b10787379c53bb0da8521efa7724 Mon Sep 17 00:00:00 2001 From: Kilian Lackhove Date: Fri, 4 Jan 2013 00:13:10 +0100 Subject: [PATCH] receive icon directly from resolvers Dont let external resolvers send a (probably faulty) path to an image file, but receive the image itself directly. This is consistent with the way the config _msgtype works, so comression is supported, too. --- src/libtomahawk/resolvers/QtScriptResolver.cpp | 12 +++++++++--- src/libtomahawk/resolvers/ScriptResolver.cpp | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/libtomahawk/resolvers/QtScriptResolver.cpp b/src/libtomahawk/resolvers/QtScriptResolver.cpp index cd9e427ab..b722c1eb5 100644 --- a/src/libtomahawk/resolvers/QtScriptResolver.cpp +++ b/src/libtomahawk/resolvers/QtScriptResolver.cpp @@ -326,15 +326,21 @@ QtScriptResolver::init() m_name = m.value( "name" ).toString(); m_weight = m.value( "weight", 0 ).toUInt(); m_timeout = m.value( "timeout", 25 ).toUInt() * 1000; - QString iconPath = QFileInfo( filePath() ).path() + "/" + m.value( "icon" ).toString(); - int success = m_icon.load( iconPath ); + bool compressed = m.value( "compressed", "false" ).toString() == "true"; + + QByteArray icoData = m.value( "icon" ).toByteArray(); + if( compressed ) + icoData = qUncompress( QByteArray::fromBase64( icoData ) ); + else + icoData = QByteArray::fromBase64( icoData ); + bool success = m_icon.loadFromData( icoData ); // load config widget and apply settings loadUi(); QVariantMap config = resolverUserConfig(); fillDataInWidgets( config ); - qDebug() << "JS" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout << "icon" << iconPath << "icon found" << success; + qDebug() << "JS" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout << "icon found" << success; m_ready = true; } diff --git a/src/libtomahawk/resolvers/ScriptResolver.cpp b/src/libtomahawk/resolvers/ScriptResolver.cpp index b2cf5ec71..e977bce4a 100644 --- a/src/libtomahawk/resolvers/ScriptResolver.cpp +++ b/src/libtomahawk/resolvers/ScriptResolver.cpp @@ -376,10 +376,16 @@ ScriptResolver::doSetup( const QVariantMap& m ) m_name = m.value( "name" ).toString(); m_weight = m.value( "weight", 0 ).toUInt(); m_timeout = m.value( "timeout", 5 ).toUInt() * 1000; - QString iconPath = QFileInfo( filePath() ).path() + "/" + m.value( "icon" ).toString(); - int success = m_icon.load( iconPath ); + bool compressed = m.value( "compressed", "false" ).toString() == "true"; - qDebug() << "SCRIPT" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout << "icon" << iconPath << "icon found" << success; + QByteArray icoData = m.value( "icon" ).toByteArray(); + if( compressed ) + icoData = qUncompress( QByteArray::fromBase64( icoData ) ); + else + icoData = QByteArray::fromBase64( icoData ); + bool success = m_icon.loadFromData( icoData ); + + qDebug() << "SCRIPT" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout << "icon found" << success; m_ready = true; m_configSent = false;