diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e5fb9949db..c887007fae 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2774,6 +2774,18 @@ bool Application::importSVOFromURL(const QString& urlString) { return true; } +bool Application::importFromZIP(const QString& filePath) { + qDebug() << "A zip file has been dropped in: " << filePath; + QUrl empty; + // handle Blocks download from Marketplace + if (filePath.contains("vr.google.com/downloads")) { + qApp->getFileDownloadInterface()->runUnzip("", filePath, true, true); + } else { + qApp->getFileDownloadInterface()->runUnzip(filePath, empty, true, true); + } + return true; +} + void Application::onPresent(quint32 frameCount) { if (shouldPaint()) { postEvent(this, new QEvent(static_cast(Idle)), Qt::HighEventPriority); @@ -2781,13 +2793,6 @@ void Application::onPresent(quint32 frameCount) { } } -bool Application::importFromZIP(const QString& filePath) { - qDebug() << "A zip file has been dropped in: " << filePath; - QUrl empty; - qApp->getFileDownloadInterface()->runUnzip(filePath, empty, true, true); - return true; -} - bool _renderRequested { false }; bool Application::event(QEvent* event) { diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/FileScriptingInterface.cpp index 5eaaea86a9..ba1e9bcddf 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/FileScriptingInterface.cpp @@ -34,6 +34,10 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool isZip) { qCDebug(scriptengine) << "Url that was downloaded: " + url.toString(); + if ((url.toString()).contains("vr.google.com/downloads")) { + + path = downloadBlocksZip(url); + } qCDebug(scriptengine) << "Path where download is saved: " + path; QString fileName = "/" + path.section("/", -1); QString tempDir = path; @@ -52,10 +56,10 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool } QStringList fileList = unzipFile(path, tempDir); - QString filename = QUrl::fromLocalFile(fileList.first()).toString(); + //QString filename = QUrl::fromLocalFile(fileList.first()).toString(); - if (filename != "") { - qCDebug(scriptengine) << "File to upload: " + filename; + if (!fileList.isEmpty()) { + qCDebug(scriptengine) << "File to upload: " + fileList.first(); } else { qCDebug(scriptengine) << "Unzip failed"; @@ -111,6 +115,18 @@ QString FileScriptingInterface::convertUrlToPath(QUrl url) { return newUrl; } +// handles a download from Blocks in the marketplace +QString FileScriptingInterface::downloadBlocksZip(QUrl url) { + qCDebug(scriptengine) << "Made it to the download blocks! " << url.toString(); + + /*auto request = DependencyManager::get()->createResourceRequest(nullptr, url); + connect(request, &ResourceRequest::finished, this, [this, url] { + unzipFile(url, ""); // so intellisense isn't mad + }); + request->send();*/ + return url.toString(); +} + // this function is not in use void FileScriptingInterface::downloadZip(QString path, const QString link) { QUrl url = QUrl(link); diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/FileScriptingInterface.h index 4069e7cc78..c2b309ce43 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/FileScriptingInterface.h @@ -34,6 +34,7 @@ private: bool isTempDir(QString tempDir); QStringList unzipFile(QString path, QString tempDir); void recursiveFileScan(QFileInfo file, QString* dirName); + QString downloadBlocksZip(QUrl url); void downloadZip(QString path, const QString link); }; diff --git a/scripts/system/html/js/marketplacesInject.js b/scripts/system/html/js/marketplacesInject.js index 8902a5deee..ca9e4aa2b6 100644 --- a/scripts/system/html/js/marketplacesInject.js +++ b/scripts/system/html/js/marketplacesInject.js @@ -80,10 +80,9 @@ // Add button links. - /* Blocks not yet implemented $('#exploreBlocksMarketplace').on('click', function () { window.location = "https://vr.google.com/objects"; - });*/ + }); $('#exploreClaraMarketplace').on('click', function () { window.location = "https://clara.io/library?gameCheck=true&public=true"; }); @@ -157,7 +156,7 @@ // One file request at a time. if (isPreparing) { - console.log("WARNIKNG: Clara.io FBX: Prepare only one download at a time"); + console.log("WARNING: Clara.io FBX: Prepare only one download at a time"); return; } @@ -347,7 +346,6 @@ if (location.href.indexOf("google.com/") !== -1) { pageType = BLOCKS; } if (location.href.indexOf("clara.io/") !== -1) { pageType = CLARA; } - //if (pageType != BLOCKS) injectCommonCode(pageType === DIRECTORY); switch (pageType) { case DIRECTORY: @@ -358,7 +356,7 @@ break; case BLOCKS: console.log("in Blocks"); - //injectBlocksCode(); + injectBlocksCode(); console.log("blocks injection"); break; case CLARA: