Commit ed9daa20 authored by Julius Künzel's avatar Julius Künzel Committed by Jean-Baptiste Mardelle
Browse files

Fix broken Freesound login and import


Signed-off-by: Julius Künzel's avatarJulius Künzel <jk.kdedev@smartlab.uber.space>
parent 3cfaf1a5
...@@ -83,15 +83,15 @@ void LoginDialog::slotRejected() ...@@ -83,15 +83,15 @@ void LoginDialog::slotRejected()
void LoginDialog::urlChanged(const QUrl &url) void LoginDialog::urlChanged(const QUrl &url)
{ {
// qCDebug(KDENLIVE_LOG) << "URL =" << url; // qCDebug(KDENLIVE_LOG) << "URL =" << url;
const QString str = url.toString(); const QString str = url.query(QUrl::FullyDecoded);
const int posCode = str.indexOf(QLatin1String("&code=")); const int posCode = str.indexOf(QLatin1String("code="));
const int posErr = str.indexOf(QLatin1String("&error=")); const int posErr = str.indexOf(QLatin1String("error="));
if (posCode != -1) { if (posCode != -1) {
m_strAuthCode = str.mid(posCode + 6); m_strAuthCode = str.mid(posCode + 5);
emit authCodeObtained(); emit authCodeObtained();
QDialog::accept(); QDialog::accept();
} else if (posErr != -1) { } else if (posErr != -1) {
QString sError = str.mid(posErr + 7); QString sError = str.mid(posErr + 6);
if (sError == QLatin1String("access_denied")) { if (sError == QLatin1String("access_denied")) {
emit accessDenied(); emit accessDenied();
} }
......
...@@ -18,9 +18,6 @@ ...@@ -18,9 +18,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/ ***************************************************************************/
/*
*
*/
#include "resourcewidget.h" #include "resourcewidget.h"
#include "archiveorg.h" #include "archiveorg.h"
#include "freesound.h" #include "freesound.h"
...@@ -758,7 +755,7 @@ void ResourceWidget::slotAccessTokenReceived(const QString &sAccessToken) ...@@ -758,7 +755,7 @@ void ResourceWidget::slotAccessTokenReceived(const QString &sAccessToken)
QUrl srcUrl(m_currentInfo.itemDownload); QUrl srcUrl(m_currentInfo.itemDownload);
request.setUrl(srcUrl); // Download url of a freesound file request.setUrl(srcUrl); // Download url of a freesound file
// eg https://www.freesound.org/apiv2/sounds/39206/download/ // eg https://www.freesound.org/apiv2/sounds/39206/download/
request.setRawHeader(QByteArray("Authorization"), QByteArray("Bearer").append(sAccessToken.toUtf8())); request.setRawHeader(QByteArray("Authorization"), QByteArray("Bearer ").append(sAccessToken.toUtf8())); //Space after "Bearer" is necessary
m_meta = QString(); m_meta = QString();
m_desc = QStringLiteral("<br><b>") + i18n("Starting File Download") + QStringLiteral("</b><br>"); m_desc = QStringLiteral("<br><b>") + i18n("Starting File Download") + QStringLiteral("</b><br>");
...@@ -792,6 +789,7 @@ QString ResourceWidget::GetSaveFileNameAndPathS(const QString &path, const QStri ...@@ -792,6 +789,7 @@ QString ResourceWidget::GetSaveFileNameAndPathS(const QString &path, const QStri
{ {
return saveUrlstring; return saveUrlstring;
} }
if (QFile::exists(saveUrlstring)) { if (QFile::exists(saveUrlstring)) {
int ret = QMessageBox::warning(this, i18n("File Exists"), i18n("Do you want to overwrite the existing file?"), QMessageBox::Yes | QMessageBox::No, int ret = QMessageBox::warning(this, i18n("File Exists"), i18n("Do you want to overwrite the existing file?"), QMessageBox::Yes | QMessageBox::No,
QMessageBox::No); QMessageBox::No);
...@@ -835,7 +833,7 @@ void ResourceWidget::DownloadRequestFinished(QNetworkReply *reply) ...@@ -835,7 +833,7 @@ void ResourceWidget::DownloadRequestFinished(QNetworkReply *reply)
file.close(); file.close();
KMessageBox::information(this, i18n("Resource saved to %1", m_saveLocation), i18n("Data Imported")); KMessageBox::information(this, i18n("Resource saved to %1", m_saveLocation), i18n("Data Imported"));
emit addClip(QUrl(m_saveLocation), QString()); // MainWindow::slotDownloadResources() links this signal to MainWindow::slotAddProjectClip emit addClip(QUrl::fromLocalFile(m_saveLocation), QString()); // MainWindow::slotDownloadResources() links this signal to MainWindow::slotAddProjectClip
m_desc.append(QStringLiteral("<br>") + i18n("Saved file to") + QStringLiteral("<br>")); m_desc.append(QStringLiteral("<br>") + i18n("Saved file to") + QStringLiteral("<br>"));
m_desc.append(m_saveLocation); m_desc.append(m_saveLocation);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment