From 8332e419896e3fdb43225e8b8d5e716aacf3e1d6 Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Tue, 31 Oct 2023 23:38:50 +0100 Subject: [PATCH 1/2] Remove File API and limit audio recording file location --- .../qml/hifi/+webengine/DesktopWebEngine.qml | 22 ---------------- interface/src/Application.cpp | 5 ++-- interface/src/Application.h | 6 ++--- interface/src/scripting/Audio.cpp | 14 +++++++++-- interface/src/scripting/Audio.h | 9 +++---- ...rface.cpp => ArchiveDownloadInterface.cpp} | 25 ++++++++++--------- ...Interface.h => ArchiveDownloadInterface.h} | 15 +++++------ libraries/script-engine/src/ScriptManager.cpp | 2 -- 8 files changed, 42 insertions(+), 56 deletions(-) rename libraries/script-engine/src/{FileScriptingInterface.cpp => ArchiveDownloadInterface.cpp} (82%) rename libraries/script-engine/src/{FileScriptingInterface.h => ArchiveDownloadInterface.h} (93%) diff --git a/interface/resources/qml/hifi/+webengine/DesktopWebEngine.qml b/interface/resources/qml/hifi/+webengine/DesktopWebEngine.qml index 56cc38254f..b04e771aee 100644 --- a/interface/resources/qml/hifi/+webengine/DesktopWebEngine.qml +++ b/interface/resources/qml/hifi/+webengine/DesktopWebEngine.qml @@ -18,27 +18,5 @@ Item { function initWebviewProfileHandlers(profile) { - downloadUrl = currentUrl; - if (webViewProfileSetup) return; - webViewProfileSetup = true; - - profile.downloadRequested.connect(function(download){ - adaptedPath = File.convertUrlToPath(downloadUrl); - tempDir = File.getTempDir(); - download.path = tempDir + "/" + adaptedPath; - download.accept(); - if (download.state === WebEngineDownloadItem.DownloadInterrupted) { - console.log("download failed to complete"); - } - }) - - profile.downloadFinished.connect(function(download){ - if (download.state === WebEngineDownloadItem.DownloadCompleted) { - File.runUnzip(download.path, downloadUrl, autoAdd); - } else { - console.log("The download was corrupted, state: " + download.state); - } - autoAdd = false; - }) } } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6565d9c387..6c341cd705 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -87,7 +87,6 @@ #include #include #include -#include #include #include #include @@ -3414,9 +3413,9 @@ void Application::onDesktopRootContextCreated(QQmlContext* surfaceContext) { surfaceContext->setContextProperty("Controller", DependencyManager::get().data()); surfaceContext->setContextProperty("Entities", DependencyManager::get().data()); surfaceContext->setContextProperty("Performance", new PerformanceScriptingInterface()); - _fileDownload = new FileScriptingInterface(engine); + _fileDownload = new ArchiveDownloadInterface(engine); surfaceContext->setContextProperty("File", _fileDownload); - connect(_fileDownload, &FileScriptingInterface::unzipResult, this, &Application::handleUnzip); + connect(_fileDownload, &ArchiveDownloadInterface::unzipResult, this, &Application::handleUnzip); surfaceContext->setContextProperty("MyAvatar", getMyAvatar().get()); surfaceContext->setContextProperty("Messages", DependencyManager::get().data()); surfaceContext->setContextProperty("Recording", DependencyManager::get().data()); diff --git a/interface/src/Application.h b/interface/src/Application.h index ced38120ae..11a7132f98 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -37,7 +37,7 @@ #include #include #include -#include +#include "ArchiveDownloadInterface.h" #include #include #include @@ -425,7 +425,7 @@ public slots: void handleUnzip(QString sourceFile, QStringList destinationFile, bool autoAdd, bool isZip, bool isBlocks); - FileScriptingInterface* getFileDownloadInterface() { return _fileDownload; } + ArchiveDownloadInterface* getFileDownloadInterface() { return _fileDownload; } void handleLocalServerConnection() const; void readArgumentsFromLocalSocket() const; @@ -820,7 +820,7 @@ private: QTimer _addAssetToWorldErrorTimer; mutable QTimer _entityServerConnectionTimer; - FileScriptingInterface* _fileDownload; + ArchiveDownloadInterface* _fileDownload; AudioInjectorPointer _snapshotSoundInjector; SharedSoundPointer _snapshotSound; SharedSoundPointer _sampleSound; diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index 57c160b7e0..b6f413575a 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -17,6 +17,8 @@ #include "AudioClient.h" #include "AudioHelpers.h" #include "ui/AvatarInputs.h" +#include "ui/Snapshot.h" +#include "AccountManager.h" using namespace scripting; @@ -58,9 +60,17 @@ Audio::Audio() : _devices(_contextIsHMD) { onContextChanged(); } -bool Audio::startRecording(const QString& filepath) { +bool Audio::startRecording() { return resultWithWriteLock([&] { - return DependencyManager::get()->startRecording(filepath); + const QString FILENAME_PATH_FORMAT = "overte-snap-by-%1-on-%2"; + const QString DEFAULT_FORMAT = "wav"; + const QString DATETIME_FORMAT = "yyyy-MM-dd_hh-mm-ss"; + + QString username = DependencyManager::get()->getAccountInfo().getUsername(); + QString filepath = DependencyManager::get()->_snapshotsLocation.get(); + QDateTime now = QDateTime::currentDateTime(); + QString filename = FILENAME_PATH_FORMAT.arg(username, now.toString(DATETIME_FORMAT)) + "." + DEFAULT_FORMAT; + return DependencyManager::get()->startRecording(filepath + "/" + filename); }); } diff --git a/interface/src/scripting/Audio.h b/interface/src/scripting/Audio.h index 5c1cb68b50..bb5239348d 100644 --- a/interface/src/scripting/Audio.h +++ b/interface/src/scripting/Audio.h @@ -301,18 +301,17 @@ public: * @returns {boolean} true if the specified file could be opened and audio recording has started, otherwise * false. * @example Make a 10 second audio recording. - * var filename = File.getTempDir() + "/audio.wav"; - * if (Audio.startRecording(filename)) { + * if (Audio.startRecording()) { * Script.setTimeout(function () { * Audio.stopRecording(); - * print("Audio recording made in: " + filename); + * print("Audio recording finished."); * }, 10000); * * } else { - * print("Could not make an audio recording in: " + filename); + * print("Could not make an audio recording file."); * } */ - Q_INVOKABLE bool startRecording(const QString& filename); + Q_INVOKABLE bool startRecording(); /*@jsdoc * Finishes making an audio recording started with {@link Audio.startRecording|startRecording}. diff --git a/libraries/script-engine/src/FileScriptingInterface.cpp b/libraries/script-engine/src/ArchiveDownloadInterface.cpp similarity index 82% rename from libraries/script-engine/src/FileScriptingInterface.cpp rename to libraries/script-engine/src/ArchiveDownloadInterface.cpp index 269a5179c1..feef1ba9fb 100644 --- a/libraries/script-engine/src/FileScriptingInterface.cpp +++ b/libraries/script-engine/src/ArchiveDownloadInterface.cpp @@ -1,15 +1,16 @@ // -// FileScriptingInterface.cpp +// ArchiveDownloadInterface.cpp // libraries/script-engine/src // // Created by Elisa Lupin-Jimenez on 6/28/16. // Copyright 2016 High Fidelity, Inc. +// Copyright 2023 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "FileScriptingInterface.h" +#include "ArchiveDownloadInterface.h" #include #include @@ -33,11 +34,11 @@ #include "ScriptEngineLogging.h" -FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent) { +ArchiveDownloadInterface::ArchiveDownloadInterface(QObject* parent) : QObject(parent) { // nothing for now } -void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool isZip, bool isBlocks) { +void ArchiveDownloadInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool isZip, bool isBlocks) { QString fileName = "/" + path.section("/", -1); QString tempDir = path; if (!isZip) { @@ -71,7 +72,7 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool } -QStringList FileScriptingInterface::unzipFile(QString path, QString tempDir) { +QStringList ArchiveDownloadInterface::unzipFile(QString path, QString tempDir) { #if defined(Q_OS_ANDROID) // FIXME quazip hasn't been built on the android toolchain return QStringList(); @@ -94,7 +95,7 @@ QStringList FileScriptingInterface::unzipFile(QString path, QString tempDir) { } // fix to check that we are only referring to a temporary directory -bool FileScriptingInterface::isTempDir(QString tempDir) { +bool ArchiveDownloadInterface::isTempDir(QString tempDir) { QString folderName = "/" + tempDir.section("/", -1); QString tempContainer = tempDir; tempContainer.remove(folderName); @@ -106,7 +107,7 @@ bool FileScriptingInterface::isTempDir(QString tempDir) { return (testContainer == tempContainer); } -bool FileScriptingInterface::hasModel(QStringList fileList) { +bool ArchiveDownloadInterface::hasModel(QStringList fileList) { for (int i = 0; i < fileList.size(); i++) { if (fileList.at(i).toLower().contains(".fbx") || fileList.at(i).toLower().contains(".obj")) { return true; @@ -115,14 +116,14 @@ bool FileScriptingInterface::hasModel(QStringList fileList) { return false; } -QString FileScriptingInterface::getTempDir() { +QString ArchiveDownloadInterface::getTempDir() { QTemporaryDir dir; dir.setAutoRemove(false); return dir.path(); // do something to delete this temp dir later } -QString FileScriptingInterface::convertUrlToPath(QUrl url) { +QString ArchiveDownloadInterface::convertUrlToPath(QUrl url) { QString newUrl; QString oldUrl = url.toString(); newUrl = oldUrl.section("filename=", 1, 1); @@ -130,10 +131,10 @@ QString FileScriptingInterface::convertUrlToPath(QUrl url) { } // this function is not in use -void FileScriptingInterface::downloadZip(QString path, const QString link) { +void ArchiveDownloadInterface::downloadZip(QString path, const QString link) { QUrl url = QUrl(link); auto request = DependencyManager::get()->createResourceRequest( - nullptr, url, true, -1, "FileScriptingInterface::downloadZip"); + nullptr, url, true, -1, "ArchiveDownloadInterface::downloadZip"); connect(request, &ResourceRequest::finished, this, [this, path]{ unzipFile(path, ""); // so intellisense isn't mad }); @@ -141,7 +142,7 @@ void FileScriptingInterface::downloadZip(QString path, const QString link) { } // this function is not in use -void FileScriptingInterface::recursiveFileScan(QFileInfo file, QString* dirName) { +void ArchiveDownloadInterface::recursiveFileScan(QFileInfo file, QString* dirName) { /*if (!file.isDir()) { return; }*/ diff --git a/libraries/script-engine/src/FileScriptingInterface.h b/libraries/script-engine/src/ArchiveDownloadInterface.h similarity index 93% rename from libraries/script-engine/src/FileScriptingInterface.h rename to libraries/script-engine/src/ArchiveDownloadInterface.h index dddadd9fc3..1465ae1eef 100644 --- a/libraries/script-engine/src/FileScriptingInterface.h +++ b/libraries/script-engine/src/ArchiveDownloadInterface.h @@ -1,9 +1,10 @@ // -// FileScriptingInterface.h +// ArchiveDownloadInterface.h // libraries/script-engine/src // // Created by Elisa Lupin-Jimenez on 6/28/16. // Copyright 2016 High Fidelity, Inc. +// Copyright 2023 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -12,10 +13,11 @@ /// @addtogroup ScriptEngine /// @{ -#ifndef hifi_FileScriptingInterface_h -#define hifi_FileScriptingInterface_h +#ifndef hifi_ArchiveDownloadInterface_h +#define hifi_ArchiveDownloadInterface_h #include +#include #include #include @@ -30,12 +32,11 @@ * @hifi-server-entity * @hifi-assignment-client */ -/// Provides the File scripting API -class FileScriptingInterface : public QObject { +class ArchiveDownloadInterface : public QObject { Q_OBJECT public: - FileScriptingInterface(QObject* parent); + ArchiveDownloadInterface(QObject* parent); public slots: @@ -116,6 +117,6 @@ private: }; -#endif // hifi_FileScriptingInterface_h +#endif // hifi_ArchiveDownloadInterface_h /// @} diff --git a/libraries/script-engine/src/ScriptManager.cpp b/libraries/script-engine/src/ScriptManager.cpp index 62a5a798b3..f74bb01b71 100644 --- a/libraries/script-engine/src/ScriptManager.cpp +++ b/libraries/script-engine/src/ScriptManager.cpp @@ -42,7 +42,6 @@ #include "AssetScriptingInterface.h" #include "BatchLoader.h" #include "EventTypes.h" -#include "FileScriptingInterface.h" // unzip project #include "MenuItemProperties.h" #include "ScriptCache.h" #include "ScriptContext.h" @@ -767,7 +766,6 @@ void ScriptManager::init() { scriptEngine->registerGlobalObject("Messages", DependencyManager::get().data()); } - scriptEngine->registerGlobalObject("File", new FileScriptingInterface(this)); scriptEngine->registerGlobalObject("console", &_consoleScriptingInterface); scriptEngine->registerFunction("console", "info", ConsoleScriptingInterface::info, scriptEngine->currentContext()->argumentCount()); scriptEngine->registerFunction("console", "log", ConsoleScriptingInterface::log, scriptEngine->currentContext()->argumentCount()); From bf8ad07b602aca53733f0d33dd6b09956e68d9fb Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Wed, 1 Nov 2023 19:14:42 +0100 Subject: [PATCH 2/2] Moved archive download interface files and converted documetnation to doxygen --- .../src/ArchiveDownloadInterface.cpp | 0 interface/src/ArchiveDownloadInterface.h | 106 +++++++++++++++ interface/src/scripting/Audio.cpp | 20 +-- interface/src/scripting/Audio.h | 11 +- .../src/ArchiveDownloadInterface.h | 122 ------------------ 5 files changed, 122 insertions(+), 137 deletions(-) rename {libraries/script-engine => interface}/src/ArchiveDownloadInterface.cpp (100%) create mode 100644 interface/src/ArchiveDownloadInterface.h delete mode 100644 libraries/script-engine/src/ArchiveDownloadInterface.h diff --git a/libraries/script-engine/src/ArchiveDownloadInterface.cpp b/interface/src/ArchiveDownloadInterface.cpp similarity index 100% rename from libraries/script-engine/src/ArchiveDownloadInterface.cpp rename to interface/src/ArchiveDownloadInterface.cpp diff --git a/interface/src/ArchiveDownloadInterface.h b/interface/src/ArchiveDownloadInterface.h new file mode 100644 index 0000000000..a406108c55 --- /dev/null +++ b/interface/src/ArchiveDownloadInterface.h @@ -0,0 +1,106 @@ +// +// ArchiveDownloadInterface.h +// libraries/script-engine/src +// +// Created by Elisa Lupin-Jimenez on 6/28/16. +// Copyright 2016 High Fidelity, Inc. +// Copyright 2023 Overte e.V. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +/// @addtogroup Interface +/// @{ + +#ifndef hifi_ArchiveDownloadInterface_h +#define hifi_ArchiveDownloadInterface_h + +#include +#include +#include +#include + +/** + * @brief The ArchiveDownloadInterface API provides some facilities for working with the file system. + */ +class ArchiveDownloadInterface : public QObject { + Q_OBJECT + +public: + ArchiveDownloadInterface(QObject* parent); + +public slots: + + /** + * @brief Extracts a filename from a URL, where the filename is specified in the query part of the URL as filename=. + + * @param url - The URL to extract the filename from. + * @return The filename specified in the URL; an empty string if no filename is specified. + */ + QString convertUrlToPath(QUrl url); + + /** + * @brief Unzips a file in the local file system to a new, unique temporary directory. + * @param path - The path of the zip file in the local file system. May have a leading "file:///". + * Need not have a ".zip" extension if it is in a temporary directory (as created by + * getTempDir). + * @param url - Not used. + * @param autoAdd - Not used by user scripts. The value is simply passed through to the + * unzipResult signal. + * @param isZip - Set to true if path has a ".zip" extension, + * false if it doesn't (but should still be treated as a zip file). + * @param isBlocks - Not used by user scripts. The value is simply passed through to the + * unzipResult signal. + * @example (Old example from JS, needs to be converted) + * Select and unzip a file. + * File.unzipResult.connect(function (zipFile, unzipFiles, autoAdd, isZip, isBlocks) { + * print("File.unzipResult()"); + * print("- zipFile: " + zipFile); + * print("- unzipFiles(" + unzipFiles.length + "): " + unzipFiles); + * print("- autoAdd: " + autoAdd); + * print("- isZip: " + isZip); + * print("- isBlocks: " + isBlocks); + * }); + * + * var zipFile = Window.browse("Select a Zip File", "", "*.zip"); + * if (zipFile) { + * File.runUnzip(zipFile, "", false, true, false); + * } else { + * print("Zip file not selected."); + * } + */ + void runUnzip(QString path, QUrl url, bool autoAdd, bool isZip, bool isBlocks); + + /** + * Creates a new, unique directory for temporary use. + * @return The path of the newly created temporary directory. + */ + QString getTempDir(); + +signals: + + /** + * Triggered when runUnzip completes. + * @param zipFile - The file that was unzipped. + * @param unzipFiles - The paths of the unzipped files in a newly created temporary directory. Includes entries + * for any subdirectories created. An empty array if the zipFile could not be unzipped. + * @param autoAdd - The value that runUnzip was called with. + * @param isZip - true if runUnzip was called with isZip == true, + * unless there is no FBX or OBJ file in the unzipped file(s) in which case the value is false. + * @param isBlocks - The value that runUnzip was called with. + */ + void unzipResult(QString zipFile, QStringList unzipFile, bool autoAdd, bool isZip, bool isBlocks); + +private: + bool isTempDir(QString tempDir); + bool hasModel(QStringList fileList); + QStringList unzipFile(QString path, QString tempDir); + void recursiveFileScan(QFileInfo file, QString* dirName); + void downloadZip(QString path, const QString link); + +}; + +#endif // hifi_ArchiveDownloadInterface_h + +/// @} diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index b6f413575a..8f44959d04 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -60,17 +60,19 @@ Audio::Audio() : _devices(_contextIsHMD) { onContextChanged(); } -bool Audio::startRecording() { - return resultWithWriteLock([&] { - const QString FILENAME_PATH_FORMAT = "overte-snap-by-%1-on-%2"; - const QString DEFAULT_FORMAT = "wav"; - const QString DATETIME_FORMAT = "yyyy-MM-dd_hh-mm-ss"; +QUuid Audio::startRecording() { + return resultWithWriteLock([&] { + const QString FILENAME_PREFIX = "overte-audio-"; + const QString AUDIO_FORMAT = "wav"; + QUuid id = QUuid::createUuid(); - QString username = DependencyManager::get()->getAccountInfo().getUsername(); QString filepath = DependencyManager::get()->_snapshotsLocation.get(); - QDateTime now = QDateTime::currentDateTime(); - QString filename = FILENAME_PATH_FORMAT.arg(username, now.toString(DATETIME_FORMAT)) + "." + DEFAULT_FORMAT; - return DependencyManager::get()->startRecording(filepath + "/" + filename); + QString filename = FILENAME_PREFIX + id.toString() + "." + AUDIO_FORMAT; + if (DependencyManager::get()->startRecording(filepath + "/" + filename)) { + return id; + } else { + return QUuid(); + } }); } diff --git a/interface/src/scripting/Audio.h b/interface/src/scripting/Audio.h index bb5239348d..509d5a8fa7 100644 --- a/interface/src/scripting/Audio.h +++ b/interface/src/scripting/Audio.h @@ -295,13 +295,12 @@ public: /*@jsdoc * Starts making an audio recording of the audio being played in-world (i.e., not local-only audio) to a file in WAV format. + * Audio is recorded to snapshots directory specified in settings. * @function Audio.startRecording - * @param {string} filename - The path and name of the file to make the recording in. Should have a .wav - * extension. The file is overwritten if it already exists. - * @returns {boolean} true if the specified file could be opened and audio recording has started, otherwise - * false. + * @returns {Uuid} A valid Uuid if the specified file could be opened and audio recording has started, otherwise + * Uuid.NULL. * @example Make a 10 second audio recording. - * if (Audio.startRecording()) { + * if (Audio.startRecording() !== Uuid.NULL) { * Script.setTimeout(function () { * Audio.stopRecording(); * print("Audio recording finished."); @@ -311,7 +310,7 @@ public: * print("Could not make an audio recording file."); * } */ - Q_INVOKABLE bool startRecording(); + Q_INVOKABLE QUuid startRecording(); /*@jsdoc * Finishes making an audio recording started with {@link Audio.startRecording|startRecording}. diff --git a/libraries/script-engine/src/ArchiveDownloadInterface.h b/libraries/script-engine/src/ArchiveDownloadInterface.h deleted file mode 100644 index 1465ae1eef..0000000000 --- a/libraries/script-engine/src/ArchiveDownloadInterface.h +++ /dev/null @@ -1,122 +0,0 @@ -// -// ArchiveDownloadInterface.h -// libraries/script-engine/src -// -// Created by Elisa Lupin-Jimenez on 6/28/16. -// Copyright 2016 High Fidelity, Inc. -// Copyright 2023 Overte e.V. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -/// @addtogroup ScriptEngine -/// @{ - -#ifndef hifi_ArchiveDownloadInterface_h -#define hifi_ArchiveDownloadInterface_h - -#include -#include -#include -#include - -/*@jsdoc - * The File API provides some facilities for working with the file system. - * - * @namespace File - * - * @hifi-interface - * @hifi-client-entity - * @hifi-avatar - * @hifi-server-entity - * @hifi-assignment-client - */ -class ArchiveDownloadInterface : public QObject { - Q_OBJECT - -public: - ArchiveDownloadInterface(QObject* parent); - -public slots: - - /*@jsdoc - * Extracts a filename from a URL, where the filename is specified in the query part of the URL as filename=. - * @function File.convertUrlToPath - * @param {string} url - The URL to extract the filename from. - * @returns {string} The filename specified in the URL; an empty string if no filename is specified. - * @example Extract a filename from a URL. - * var url = "http://domain.tld/path/page.html?filename=file.ext"; - * print("File name: " + File.convertUrlToPath(url)); // file.ext - */ - QString convertUrlToPath(QUrl url); - - /*@jsdoc - * Unzips a file in the local file system to a new, unique temporary directory. - * @function File.runUnzip - * @param {string} path - The path of the zip file in the local file system. May have a leading "file:///". - * Need not have a ".zip" extension if it is in a temporary directory (as created by - * {@link File.getTempDir|getTempDir}). - * @param {string} url - Not used. - * @param {boolean} autoAdd - Not used by user scripts. The value is simply passed through to the - * {@link File.unzipResult|unzipResult} signal. - * @param {boolean} isZip - Set to true if path has a ".zip" extension, - * false if it doesn't (but should still be treated as a zip file). - * @param {boolean} isBlocks - Not used by user scripts. The value is simply passed through to the - * {@link File.unzipResult|unzipResult} signal. - * @example Select and unzip a file. - * File.unzipResult.connect(function (zipFile, unzipFiles, autoAdd, isZip, isBlocks) { - * print("File.unzipResult()"); - * print("- zipFile: " + zipFile); - * print("- unzipFiles(" + unzipFiles.length + "): " + unzipFiles); - * print("- autoAdd: " + autoAdd); - * print("- isZip: " + isZip); - * print("- isBlocks: " + isBlocks); - * }); - * - * var zipFile = Window.browse("Select a Zip File", "", "*.zip"); - * if (zipFile) { - * File.runUnzip(zipFile, "", false, true, false); - * } else { - * print("Zip file not selected."); - * } - */ - void runUnzip(QString path, QUrl url, bool autoAdd, bool isZip, bool isBlocks); - - /*@jsdoc - * Creates a new, unique directory for temporary use. - * @function File.getTempDir - * @returns {string} The path of the newly created temporary directory. - * @example Create a temporary directory. - * print("New temporary directory: " + File.getTempDir()); - */ - QString getTempDir(); - -signals: - - /*@jsdoc - * Triggered when {@link File.runUnzip|runUnzip} completes. - * @function File.unzipResult - * @param {string} zipFile - The file that was unzipped. - * @param {string[]} unzipFiles - The paths of the unzipped files in a newly created temporary directory. Includes entries - * for any subdirectories created. An empty array if the zipFile could not be unzipped. - * @param {boolean} autoAdd - The value that {@link File.runUnzip|runUnzip} was called with. - * @param {boolean} isZip - true if {@link File.runUnzip|runUnzip} was called with isZip == true, - * unless there is no FBX or OBJ file in the unzipped file(s) in which case the value is false. - * @param {boolean} isBlocks - The value that {@link File.runUnzip|runUnzip} was called with. - * @returns {Signal} - */ - void unzipResult(QString zipFile, QStringList unzipFile, bool autoAdd, bool isZip, bool isBlocks); - -private: - bool isTempDir(QString tempDir); - bool hasModel(QStringList fileList); - QStringList unzipFile(QString path, QString tempDir); - void recursiveFileScan(QFileInfo file, QString* dirName); - void downloadZip(QString path, const QString link); - -}; - -#endif // hifi_ArchiveDownloadInterface_h - -/// @}