From f99384d2a77ff18ce2ece6d6b58e3d231db3f910 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 14 Feb 2018 11:31:40 -0800 Subject: [PATCH 1/2] fix comit issue --- interface/src/Application.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1c93b2757f..fbb7eb5ff1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2946,6 +2946,7 @@ bool Application::importFromZIP(const QString& filePath) { bool Application::visitServerlessDomain(const QString& urlString) { qDebug() << "QQQQ visit serverless domain" << urlString; setServerlessMode(true); + return true; } bool Application::importImage(const QString& urlString) { From e0bbc57f6c979f1a615893aa49064ec6bcb1ce9f Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 16 Feb 2018 14:48:38 -0800 Subject: [PATCH 2/2] support relative file path from appliaction directory --- libraries/networking/src/AddressManager.cpp | 8 +++++--- libraries/shared/src/PathUtils.cpp | 20 ++++++++++++++++++++ libraries/shared/src/PathUtils.h | 1 + 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index 66e2a452c5..a179db857c 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "AddressManager.h" #include "NodeList.h" @@ -293,10 +294,11 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) { return true; } else if (lookupUrl.scheme() == "http" || lookupUrl.scheme() == "https" || lookupUrl.scheme() == "file") { - - qDebug() << "QQQQ do http before serverless domain" << lookupUrl.toString(); + QUrl url = lookupUrl; + const QString path = PathUtils::expandToAppAbsolutePath(lookupUrl.path()); + url.setPath(path); emit setServersEnabled(false); - emit loadServerlessDomain(lookupUrl); + emit loadServerlessDomain(url); emit lookupResultsFinished(); return true; } diff --git a/libraries/shared/src/PathUtils.cpp b/libraries/shared/src/PathUtils.cpp index ac402a549f..6ce9ac1176 100644 --- a/libraries/shared/src/PathUtils.cpp +++ b/libraries/shared/src/PathUtils.cpp @@ -116,10 +116,30 @@ const QString& PathUtils::resourcesUrl() { return staticResourcePath; } +QString applicationAbsolutePath() { + QString path; +#if defined(Q_OS_OSX) + path = QCoreApplication::applicationDirPath() + "/../"; +#elif defined(Q_OS_ANDROID) + path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); +#else + path = QCoreApplication::applicationDirPath() + "/"; +#endif + + return path; +} + QUrl PathUtils::resourcesUrl(const QString& relativeUrl) { return QUrl(resourcesUrl() + relativeUrl); } +QString PathUtils::expandToAppAbsolutePath(const QString& filePath) { + QString path = filePath; + if (path.startsWith("/~/")) { + path.replace(1, 2, applicationAbsolutePath()); + } + return path; +} const QString& PathUtils::qmlBaseUrl() { static const QString staticResourcePath = resourcesUrl() + "qml/"; return staticResourcePath; diff --git a/libraries/shared/src/PathUtils.h b/libraries/shared/src/PathUtils.h index ec71ccee6a..4e8c442384 100644 --- a/libraries/shared/src/PathUtils.h +++ b/libraries/shared/src/PathUtils.h @@ -37,6 +37,7 @@ public: static QUrl resourcesUrl(const QString& relative); static const QString& resourcesPath(); static const QString& qmlBaseUrl(); + static QString expandToAppAbsolutePath(const QString& filePath); static QUrl qmlUrl(const QString& relative); #ifdef DEV_BUILD static const QString& projectRootPath();