From df4abb1ef1f0c3fe4dd9c1614cec081be4107873 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 11 Dec 2014 01:04:54 +0100 Subject: [PATCH] Allow plugins to enforce reloading of the resolver, to invalidate old results --- src/libtomahawk/resolvers/JSResolverHelper.cpp | 8 ++++++++ src/libtomahawk/resolvers/JSResolverHelper.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/libtomahawk/resolvers/JSResolverHelper.cpp b/src/libtomahawk/resolvers/JSResolverHelper.cpp index 9700eb440..3f7e02b3d 100644 --- a/src/libtomahawk/resolvers/JSResolverHelper.cpp +++ b/src/libtomahawk/resolvers/JSResolverHelper.cpp @@ -906,6 +906,14 @@ JSResolverHelper::deleteFuzzyIndex() } +void +JSResolverHelper::readdResolver() +{ + Pipeline::instance()->removeResolver( m_resolver ); + Pipeline::instance()->addResolver( m_resolver ); +} + + void JSResolverHelper::returnStreamUrl( const QString& streamUrl, const QMap& headers, std::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback ) diff --git a/src/libtomahawk/resolvers/JSResolverHelper.h b/src/libtomahawk/resolvers/JSResolverHelper.h index 072210dc5..1dec71510 100644 --- a/src/libtomahawk/resolvers/JSResolverHelper.h +++ b/src/libtomahawk/resolvers/JSResolverHelper.h @@ -115,12 +115,20 @@ public: Q_INVOKABLE QVariantList resolveFromFuzzyIndex( const QString& artist, const QString& album, const QString& tracks ); Q_INVOKABLE void deleteFuzzyIndex(); + /** + * This is horrible, we can use it to invalidate resolver results when the config changes + * TODO: register the resolver through registerPlugin and remove it through standard methods + */ + Q_INVOKABLE void readdResolver(); + + /** * INTERNAL USE ONLY! */ void customIODeviceFactory( const Tomahawk::result_ptr&, const QString& url, std::function< void( const QString&, QSharedPointer< QIODevice >& ) > callback ); // async + public slots: QByteArray readRaw( const QString& fileName ); QString readBase64( const QString& fileName );