From 43967dc9a629111221be0f899697d5d4474eb0eb Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Jul 2016 15:47:56 -0700 Subject: [PATCH] handle running of non .svo.json JSON files from mp CDN --- interface/src/Application.cpp | 29 +++++++++++++++++++++++------ interface/src/Application.h | 1 + 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 94dc26693f..94ede3ca83 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -170,7 +170,8 @@ static QTimer pingTimer; static const QString SNAPSHOT_EXTENSION = ".jpg"; static const QString SVO_EXTENSION = ".svo"; -static const QString SVO_JSON_EXTENSION = ".svo.json"; +static const QString SVO_JSON_EXTENSION = ".svo.json"; +static const QString JSON_EXTENSION = ".json"; static const QString JS_EXTENSION = ".js"; static const QString FST_EXTENSION = ".fst"; static const QString FBX_EXTENSION = ".fbx"; @@ -202,13 +203,16 @@ static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStanda Setting::Handle maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS); +static const QString MARKETPLACE_CDN_HOSTNAME = "mpassets.highfidelity.com"; + const QHash Application::_acceptedExtensions { { SNAPSHOT_EXTENSION, &Application::acceptSnapshot }, { SVO_EXTENSION, &Application::importSVOFromURL }, { SVO_JSON_EXTENSION, &Application::importSVOFromURL }, + { AVA_JSON_EXTENSION, &Application::askToWearAvatarAttachmentUrl }, + { JSON_EXTENSION, &Application::importJSONFromURL }, { JS_EXTENSION, &Application::askToLoadScript }, - { FST_EXTENSION, &Application::askToSetAvatarUrl }, - { AVA_JSON_EXTENSION, &Application::askToWearAvatarAttachmentUrl } + { FST_EXTENSION, &Application::askToSetAvatarUrl } }; class DeadlockWatchdogThread : public QThread { @@ -1969,7 +1973,22 @@ void Application::resizeGL() { } } +bool Application::importJSONFromURL(const QString& urlString) { + // we only load files that terminate in just .json (not .svo.json and not .ava.json) + // if they come from the High Fidelity Marketplace Assets CDN + + QUrl jsonURL { urlString }; + + if (jsonURL.host().endsWith(MARKETPLACE_CDN_HOSTNAME)) { + emit svoImportRequested(urlString); + return true; + } else { + return false; + } +} + bool Application::importSVOFromURL(const QString& urlString) { + emit svoImportRequested(urlString); return true; } @@ -4807,10 +4826,8 @@ bool Application::askToSetAvatarUrl(const QString& url) { bool Application::askToLoadScript(const QString& scriptFilenameOrURL) { QMessageBox::StandardButton reply; - static const QString MARKETPLACE_SCRIPT_URL_HOSTNAME_SUFFIX = "mpassets.highfidelity.com"; - QString shortName = scriptFilenameOrURL; - if (shortName.contains(MARKETPLACE_SCRIPT_URL_HOSTNAME_SUFFIX)) { + if (shortName.contains(MARKETPLACE_CDN_HOSTNAME)) { shortName = shortName.mid(shortName.lastIndexOf('/') + 1); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 6857ba2a3a..1ccef79198 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -380,6 +380,7 @@ private: void displaySide(RenderArgs* renderArgs, Camera& whichCamera, bool selfAvatarOnly = false); + bool importJSONFromURL(const QString& urlString); bool importSVOFromURL(const QString& urlString); bool nearbyEntitiesAreReadyForPhysics();