Showing the changes to libraries/script-engine/src/FileScriptingInterface.cpp (1 of 4 files). Show all
Unified · Split
| @@ -34,6 +34,10 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent · 33 unmodified lines | |||
| 34 | 34 | ||
| 35 | void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool isZip) { | 35 | void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool isZip) { |
| 36 | qCDebug(scriptengine) << "Url that was downloaded: " + url.toString(); | 36 | qCDebug(scriptengine) << "Url that was downloaded: " + url.toString(); |
| 37 | if ((url.toString()).contains("vr.google.com/downloads")) { | ||
| 38 | |||
| 39 | path = downloadBlocksZip(url); | ||
| 40 | } | ||
| 37 | qCDebug(scriptengine) << "Path where download is saved: " + path; | 41 | qCDebug(scriptengine) << "Path where download is saved: " + path; |
| 38 | QString fileName = "/" + path.section("/", -1); | 42 | QString fileName = "/" + path.section("/", -1); |
| 39 | QString tempDir = path; | 43 | QString tempDir = path; |
| @@ -52,10 +56,10 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool · 12 unmodified lines | |||
| 52 | } | 56 | } |
| 53 | 57 | ||
| 54 | QStringList fileList = unzipFile(path, tempDir); | 58 | QStringList fileList = unzipFile(path, tempDir); |
| 55 | QString filename = QUrl::fromLocalFile(fileList.first()).toString(); | 59 | //QString filename = QUrl::fromLocalFile(fileList.first()).toString(); |
| 56 | 60 | ||
| 57 | if (filename != "") { | 61 | if (!fileList.isEmpty()) { |
| 58 | qCDebug(scriptengine) << "File to upload: " + filename; | 62 | qCDebug(scriptengine) << "File to upload: " + fileList.first(); |
| 59 | } | 63 | } |
| 60 | else { | 64 | else { |
| 61 | qCDebug(scriptengine) << "Unzip failed"; | 65 | qCDebug(scriptengine) << "Unzip failed"; |
| @@ -111,6 +115,18 @@ QString FileScriptingInterface::convertUrlToPath(QUrl url) { · 49 unmodified lines | |||
| 111 | return newUrl; | 115 | return newUrl; |
| 112 | } | 116 | } |
| 113 | 117 | ||
| 118 | // handles a download from Blocks in the marketplace | ||
| 119 | QString FileScriptingInterface::downloadBlocksZip(QUrl url) { | ||
| 120 | qCDebug(scriptengine) << "Made it to the download blocks! " << url.toString(); | ||
| 121 | |||
| 122 | /*auto request = DependencyManager::get<ResourceManager>()->createResourceRequest(nullptr, url); | ||
| 123 | connect(request, &ResourceRequest::finished, this, [this, url] { | ||
| 124 | unzipFile(url, ""); // so intellisense isn't mad | ||
| 125 | }); | ||
| 126 | request->send();*/ | ||
| 127 | return url.toString(); | ||
| 128 | } | ||
| 129 | |||
| 114 | // this function is not in use | 130 | // this function is not in use |
| 115 | void FileScriptingInterface::downloadZip(QString path, const QString link) { | 131 | void FileScriptingInterface::downloadZip(QString path, const QString link) { |
| 116 | QUrl url = QUrl(link); | 132 | QUrl url = QUrl(link); |