From c41c7eaa94d3e834d9612c503718e5ae3923427f Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Thu, 14 Jun 2012 21:21:58 +0200 Subject: [PATCH] Provide base64 encode and decode to js resolvers --- src/libtomahawk/resolvers/QtScriptResolver.cpp | 14 ++++++++++++++ src/libtomahawk/resolvers/QtScriptResolver.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/libtomahawk/resolvers/QtScriptResolver.cpp b/src/libtomahawk/resolvers/QtScriptResolver.cpp index 1bfa4ea5e..d20d411eb 100644 --- a/src/libtomahawk/resolvers/QtScriptResolver.cpp +++ b/src/libtomahawk/resolvers/QtScriptResolver.cpp @@ -176,6 +176,20 @@ QtScriptResolverHelper::addCustomUrlHandler( const QString& protocol, const QStr } +QByteArray +QtScriptResolverHelper::base64Encode( const QByteArray& input ) +{ + return input.toBase64(); +} + + +QByteArray +QtScriptResolverHelper::base64Decode( const QByteArray& input ) +{ + return QByteArray::fromBase64( input ); +} + + QSharedPointer< QIODevice > QtScriptResolverHelper::customIODeviceFactory( const Tomahawk::result_ptr& result ) { diff --git a/src/libtomahawk/resolvers/QtScriptResolver.h b/src/libtomahawk/resolvers/QtScriptResolver.h index 85d10d59e..c2dae5210 100644 --- a/src/libtomahawk/resolvers/QtScriptResolver.h +++ b/src/libtomahawk/resolvers/QtScriptResolver.h @@ -53,6 +53,9 @@ public: Q_INVOKABLE void addCustomUrlHandler( const QString& protocol, const QString& callbackFuncName ); + Q_INVOKABLE QByteArray base64Encode( const QByteArray& input ); + Q_INVOKABLE QByteArray base64Decode( const QByteArray& input ); + QSharedPointer customIODeviceFactory( const Tomahawk::result_ptr& result ); public slots: