From 51e6468abdee3430366dec1ab20f8fdbaec0c285 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Fri, 11 Jun 2021 17:04:16 -0400 Subject: [PATCH 01/10] Rename 'URL_SCHEME_HIFI' -> 'URL_SCHEME_VIRCADIA'. --- interface/src/Application.cpp | 10 ++--- interface/src/main.cpp | 2 +- .../scripting/WindowScriptingInterface.cpp | 4 +- libraries/networking/src/AddressManager.cpp | 38 +++++++++---------- libraries/networking/src/DomainHandler.cpp | 14 +++---- libraries/networking/src/DomainHandler.h | 2 +- .../networking/src/NetworkingConstants.h | 4 +- libraries/networking/src/NodeList.cpp | 2 +- libraries/script-engine/src/ScriptEngine.cpp | 2 +- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 807b5e55a5..68d6cd9657 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4004,7 +4004,7 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { parser.parse(arguments()); if (parser.isSet(urlOption)) { QUrl url = QUrl(parser.value(urlOption)); - if (url.scheme() == URL_SCHEME_HIFIAPP) { + if (url.scheme() == URL_SCHEME_VIRCADIAAPP) { Setting::Handle("startUpApp").set(url.path()); } else { addressLookupString = url.toString(); @@ -7285,7 +7285,7 @@ void Application::clearDomainOctreeDetails(bool clearAll) { void Application::domainURLChanged(QUrl domainURL) { // disable physics until we have enough information about our new location to not cause craziness. - setIsServerlessMode(domainURL.scheme() != URL_SCHEME_HIFI); + setIsServerlessMode(domainURL.scheme() != URL_SCHEME_VIRCADIA); if (isServerlessMode()) { loadServerlessDomain(domainURL); } @@ -7294,7 +7294,7 @@ void Application::domainURLChanged(QUrl domainURL) { void Application::goToErrorDomainURL(QUrl errorDomainURL) { // disable physics until we have enough information about our new location to not cause craziness. - setIsServerlessMode(errorDomainURL.scheme() != URL_SCHEME_HIFI); + setIsServerlessMode(errorDomainURL.scheme() != URL_SCHEME_VIRCADIA); if (isServerlessMode()) { loadErrorDomain(errorDomainURL); } @@ -7658,7 +7658,7 @@ bool Application::canAcceptURL(const QString& urlString) const { QUrl url(urlString); if (url.query().contains(WEB_VIEW_TAG)) { return false; - } else if (urlString.startsWith(URL_SCHEME_HIFI)) { + } else if (urlString.startsWith(URL_SCHEME_VIRCADIA)) { return true; } QString lowerPath = url.path().toLower(); @@ -7673,7 +7673,7 @@ bool Application::canAcceptURL(const QString& urlString) const { bool Application::acceptURL(const QString& urlString, bool defaultUpload) { QUrl url(urlString); - if (url.scheme() == URL_SCHEME_HIFI) { + if (url.scheme() == URL_SCHEME_VIRCADIA) { // this is a hifi URL - have the AddressManager handle it QMetaObject::invokeMethod(DependencyManager::get().data(), "handleLookupString", Qt::AutoConnection, Q_ARG(const QString&, urlString)); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index d190e3f3da..4e338a629b 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -265,7 +265,7 @@ int main(int argc, const char* argv[]) { if (socket.waitForConnected(LOCAL_SERVER_TIMEOUT_MS)) { if (parser.isSet(urlOption)) { QUrl url = QUrl(parser.value(urlOption)); - if (url.isValid() && (url.scheme() == URL_SCHEME_HIFI || url.scheme() == URL_SCHEME_HIFIAPP + if (url.isValid() && (url.scheme() == URL_SCHEME_VIRCADIA || url.scheme() == URL_SCHEME_VIRCADIAAPP || url.scheme() == HIFI_URL_SCHEME_HTTP || url.scheme() == HIFI_URL_SCHEME_HTTPS || url.scheme() == HIFI_URL_SCHEME_FILE)) { qDebug() << "Writing URL to local socket"; diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index c8714e2a8f..e594ecd536 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -139,9 +139,9 @@ void WindowScriptingInterface::disconnectedFromDomain() { void WindowScriptingInterface::openUrl(const QUrl& url) { if (!url.isEmpty()) { auto scheme = url.scheme(); - if (scheme == URL_SCHEME_HIFI) { + if (scheme == URL_SCHEME_VIRCADIA) { DependencyManager::get()->handleLookupString(url.toString()); - } else if (scheme == URL_SCHEME_HIFIAPP) { + } else if (scheme == URL_SCHEME_VIRCADIAAPP) { DependencyManager::get()->openSystemApp(url.path()); } else { #if defined(Q_OS_ANDROID) diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index f0fa1365c4..c246cc00de 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -39,7 +39,7 @@ const QString SETTINGS_CURRENT_ADDRESS_KEY = "address"; const QString DEFAULT_VIRCADIA_ADDRESS = (!BuildInfo::PRELOADED_STARTUP_LOCATION.isEmpty()) ? BuildInfo::PRELOADED_STARTUP_LOCATION : NetworkingConstants::DEFAULT_VIRCADIA_ADDRESS; -const QString DEFAULT_HOME_ADDRESS = (!BuildInfo::PRELOADED_STARTUP_LOCATION.isEmpty()) +const QString DEFAULT_HOME_ADDRESS = (!BuildInfo::PRELOADED_STARTUP_LOCATION.isEmpty()) ? BuildInfo::PRELOADED_STARTUP_LOCATION : NetworkingConstants::DEFAULT_VIRCADIA_ADDRESS; @@ -56,7 +56,7 @@ QString AddressManager::getProtocol() const { QUrl AddressManager::currentAddress(bool domainOnly) const { QUrl hifiURL = _domainURL; - if (!domainOnly && hifiURL.scheme() == URL_SCHEME_HIFI) { + if (!domainOnly && hifiURL.scheme() == URL_SCHEME_VIRCADIA) { hifiURL.setPath(currentPath()); } @@ -65,7 +65,7 @@ QUrl AddressManager::currentAddress(bool domainOnly) const { QUrl AddressManager::currentFacingAddress() const { auto hifiURL = currentAddress(); - if (hifiURL.scheme() == URL_SCHEME_HIFI) { + if (hifiURL.scheme() == URL_SCHEME_VIRCADIA) { hifiURL.setPath(currentFacingPath()); } @@ -77,7 +77,7 @@ QUrl AddressManager::currentShareableAddress(bool domainOnly) const { // if we have a shareable place name use that instead of whatever the current host is QUrl hifiURL; - hifiURL.setScheme(URL_SCHEME_HIFI); + hifiURL.setScheme(URL_SCHEME_VIRCADIA); hifiURL.setHost(_shareablePlaceName); if (!domainOnly) { @@ -94,7 +94,7 @@ QUrl AddressManager::currentPublicAddress(bool domainOnly) const { // return an address that can be used by others to visit this client's current location. If // in a serverless domain (which can't be visited) return an empty URL. QUrl shareableAddress = currentShareableAddress(domainOnly); - if (shareableAddress.scheme() != URL_SCHEME_HIFI) { + if (shareableAddress.scheme() != URL_SCHEME_VIRCADIA) { return QUrl(); // file: urls aren't public } return shareableAddress; @@ -103,7 +103,7 @@ QUrl AddressManager::currentPublicAddress(bool domainOnly) const { QUrl AddressManager::currentFacingShareableAddress() const { auto hifiURL = currentShareableAddress(); - if (hifiURL.scheme() == URL_SCHEME_HIFI) { + if (hifiURL.scheme() == URL_SCHEME_VIRCADIA) { hifiURL.setPath(currentFacingPath()); } @@ -114,7 +114,7 @@ QUrl AddressManager::currentFacingPublicAddress() const { // return an address that can be used by others to visit this client's current location. If // in a serverless domain (which can't be visited) return an empty URL. QUrl shareableAddress = currentFacingShareableAddress(); - if (shareableAddress.scheme() != URL_SCHEME_HIFI) { + if (shareableAddress.scheme() != URL_SCHEME_VIRCADIA) { return QUrl(); // file: urls aren't public } return shareableAddress; @@ -165,7 +165,7 @@ void AddressManager::storeCurrentAddress() { if (url.scheme() == HIFI_URL_SCHEME_FILE || url.scheme() == HIFI_URL_SCHEME_HTTP || url.scheme() == HIFI_URL_SCHEME_HTTPS || - (url.scheme() == URL_SCHEME_HIFI && !url.host().isEmpty())) { + (url.scheme() == URL_SCHEME_VIRCADIA && !url.host().isEmpty())) { // TODO -- once Octree::readFromURL no-longer takes over the main event-loop, serverless-domain urls can // be loaded over http(s) // url.scheme() == HIFI_URL_SCHEME_HTTP || @@ -258,24 +258,24 @@ bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger) { if (lookupUrl.scheme().isEmpty() && !lookupUrl.path().startsWith("/")) { // 'urls' without schemes are taken as domain names, as opposed to // simply a path portion of a url, so we need to set the scheme - lookupUrl.setScheme(URL_SCHEME_HIFI); + lookupUrl.setScheme(URL_SCHEME_VIRCADIA); } static const QRegExp PORT_REGEX = QRegExp("\\d{1,5}(\\/.*)?"); if(!lookupUrl.scheme().isEmpty() && lookupUrl.host().isEmpty() && PORT_REGEX.exactMatch(lookupUrl.path())) { // this is in the form somewhere:, convert it to hifi://somewhere: - lookupUrl = QUrl(URL_SCHEME_HIFI + "://" + lookupUrl.toString()); + lookupUrl = QUrl(URL_SCHEME_VIRCADIA + "://" + lookupUrl.toString()); } // it should be noted that url's in the form // somewhere: are not valid, as that // would indicate that the scheme is 'somewhere' // use hifi://somewhere: instead - if (lookupUrl.scheme() == URL_SCHEME_HIFI) { + if (lookupUrl.scheme() == URL_SCHEME_VIRCADIA) { if (lookupUrl.host().isEmpty()) { // this was in the form hifi:/somewhere or hifi:somewhere. Fix it by making it hifi://somewhere - static const QRegExp HIFI_SCHEME_REGEX = QRegExp(URL_SCHEME_HIFI + ":\\/{0,2}", Qt::CaseInsensitive); - lookupUrl = QUrl(lookupUrl.toString().replace(HIFI_SCHEME_REGEX, URL_SCHEME_HIFI + "://")); + static const QRegExp HIFI_SCHEME_REGEX = QRegExp(URL_SCHEME_VIRCADIA + ":\\/{0,2}", Qt::CaseInsensitive); + lookupUrl = QUrl(lookupUrl.toString().replace(HIFI_SCHEME_REGEX, URL_SCHEME_VIRCADIA + "://")); } DependencyManager::get()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::LookupAddress); @@ -371,7 +371,7 @@ bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger) { return true; } else if (lookupUrl.scheme() == HIFI_URL_SCHEME_FILE || lookupUrl.scheme() == HIFI_URL_SCHEME_HTTPS || lookupUrl.scheme() == HIFI_URL_SCHEME_HTTP) { - + // Save the last visited domain URL. _lastVisitedURL = lookupUrl; @@ -494,7 +494,7 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const qCDebug(networking) << "Possible domain change required to connect to" << domainHostname << "on" << domainPort; QUrl domainURL; - domainURL.setScheme(URL_SCHEME_HIFI); + domainURL.setScheme(URL_SCHEME_VIRCADIA); domainURL.setHost(domainHostname); if (domainPort > 0) { domainURL.setPort(domainPort); @@ -667,7 +667,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri emit lookupResultsFinished(); QUrl domainURL; - domainURL.setScheme(URL_SCHEME_HIFI); + domainURL.setScheme(URL_SCHEME_VIRCADIA); domainURL.setHost(domainIPString); if (domainPort > 0) { domainURL.setPort(domainPort); @@ -690,7 +690,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri emit lookupResultsFinished(); QUrl domainURL; - domainURL.setScheme(URL_SCHEME_HIFI); + domainURL.setScheme(URL_SCHEME_VIRCADIA); domainURL.setHost(domainHostname); if (domainPort > 0) { domainURL.setPort(domainPort); @@ -823,7 +823,7 @@ bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16 addCurrentAddressToHistory(trigger); _domainURL = QUrl(); - _domainURL.setScheme(URL_SCHEME_HIFI); + _domainURL.setScheme(URL_SCHEME_VIRCADIA); _domainURL.setHost(host); if (port > 0) { _domainURL.setPort(port); @@ -860,7 +860,7 @@ bool AddressManager::setDomainInfo(const QUrl& domainURL, LookupTrigger trigger) // clear any current place information _rootPlaceID = QUuid(); - if (_domainURL.scheme() == URL_SCHEME_HIFI) { + if (_domainURL.scheme() == URL_SCHEME_VIRCADIA) { qCDebug(networking) << "Possible domain change required to connect to domain at" << hostname << "on" << port; } else { qCDebug(networking) << "Possible domain change required to serverless domain: " << domainURL.toString(); diff --git a/libraries/networking/src/DomainHandler.cpp b/libraries/networking/src/DomainHandler.cpp index 5a1d8fb4a0..c6daf384ca 100644 --- a/libraries/networking/src/DomainHandler.cpp +++ b/libraries/networking/src/DomainHandler.cpp @@ -184,7 +184,7 @@ void DomainHandler::setSockAddr(const HifiSockAddr& sockAddr, const QString& hos // some callers may pass a hostname, this is not to be used for lookup but for DTLS certificate verification _domainURL = QUrl(); - _domainURL.setScheme(URL_SCHEME_HIFI); + _domainURL.setScheme(URL_SCHEME_VIRCADIA); _domainURL.setHost(hostname); _domainURL.setPort(_sockAddr.getPort()); } @@ -199,7 +199,7 @@ void DomainHandler::setUUID(const QUuid& uuid) { void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) { _pendingDomainID = domainID; - if (domainURL.scheme() != URL_SCHEME_HIFI) { + if (domainURL.scheme() != URL_SCHEME_VIRCADIA) { _sockAddr.clear(); // if this is a file URL we need to see if it has a ~ for us to expand @@ -215,7 +215,7 @@ void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) { // if it's in the error state, reset and try again. if (_domainURL != domainURL - || (_sockAddr.getPort() != domainPort && domainURL.scheme() == URL_SCHEME_HIFI) + || (_sockAddr.getPort() != domainPort && domainURL.scheme() == URL_SCHEME_VIRCADIA) || isServerless() // For reloading content in serverless domain. || _isInErrorState) { // re-set the domain info so that auth information is reloaded @@ -230,7 +230,7 @@ void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) { qCDebug(networking) << "Updated domain hostname to" << domainURL.host(); if (!domainURL.host().isEmpty()) { - if (domainURL.scheme() == URL_SCHEME_HIFI) { + if (domainURL.scheme() == URL_SCHEME_VIRCADIA) { // re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname qCDebug(networking, "Looking up DS hostname %s.", domainURL.host().toLocal8Bit().constData()); QHostInfo::lookupHost(domainURL.host(), this, SLOT(completedHostnameLookup(const QHostInfo&))); @@ -303,7 +303,7 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname, void DomainHandler::activateICELocalSocket() { DependencyManager::get()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket); _sockAddr = _icePeer.getLocalSocket(); - _domainURL.setScheme(URL_SCHEME_HIFI); + _domainURL.setScheme(URL_SCHEME_VIRCADIA); _domainURL.setHost(_sockAddr.getAddress().toString()); emit domainURLChanged(_domainURL); emit completedSocketDiscovery(); @@ -312,7 +312,7 @@ void DomainHandler::activateICELocalSocket() { void DomainHandler::activateICEPublicSocket() { DependencyManager::get()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket); _sockAddr = _icePeer.getPublicSocket(); - _domainURL.setScheme(URL_SCHEME_HIFI); + _domainURL.setScheme(URL_SCHEME_VIRCADIA); _domainURL.setHost(_sockAddr.getAddress().toString()); emit domainURLChanged(_domainURL); emit completedSocketDiscovery(); @@ -369,7 +369,7 @@ void DomainHandler::setIsConnected(bool isConnected) { // FIXME: Reinstate the requestDomainSettings() call here in version 2021.2.0 instead of having it in // NodeList::processDomainServerList(). /* - if (_domainURL.scheme() == URL_SCHEME_HIFI && !_domainURL.host().isEmpty()) { + if (_domainURL.scheme() == URL_SCHEME_VIRCADIA && !_domainURL.host().isEmpty()) { // we've connected to new domain - time to ask it for global settings requestDomainSettings(); } diff --git a/libraries/networking/src/DomainHandler.h b/libraries/networking/src/DomainHandler.h index a56d3162bd..9262c6277d 100644 --- a/libraries/networking/src/DomainHandler.h +++ b/libraries/networking/src/DomainHandler.h @@ -137,7 +137,7 @@ public: void setCanConnectWithoutAvatarEntities(bool canConnect); bool canConnectWithoutAvatarEntities(); - bool isServerless() const { return _domainURL.scheme() != URL_SCHEME_HIFI; } + bool isServerless() const { return _domainURL.scheme() != URL_SCHEME_VIRCADIA; } bool getInterstitialModeEnabled() const; void setInterstitialModeEnabled(bool enableInterstitialMode); diff --git a/libraries/networking/src/NetworkingConstants.h b/libraries/networking/src/NetworkingConstants.h index d5ad90a6f4..6fa352f699 100644 --- a/libraries/networking/src/NetworkingConstants.h +++ b/libraries/networking/src/NetworkingConstants.h @@ -83,8 +83,8 @@ namespace NetworkingConstants { } const QString HIFI_URL_SCHEME_ABOUT = "about"; -const QString URL_SCHEME_HIFI = "hifi"; -const QString URL_SCHEME_HIFIAPP = "hifiapp"; +const QString URL_SCHEME_VIRCADIA = "hifi"; +const QString URL_SCHEME_VIRCADIAAPP = "hifiapp"; const QString URL_SCHEME_DATA = "data"; const QString URL_SCHEME_QRC = "qrc"; const QString HIFI_URL_SCHEME_FILE = "file"; diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index a975302699..fbf09d93fa 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -824,7 +824,7 @@ void NodeList::processDomainServerList(QSharedPointer message) // FIXME: Remove this call to requestDomainSettings() and reinstate the one in DomainHandler::setIsConnected(), in version // 2021.2.0. (New protocol version implies a domain server upgrade.) if (!_domainHandler.isConnected() - && _domainHandler.getScheme() == URL_SCHEME_HIFI && !_domainHandler.getHostname().isEmpty()) { + && _domainHandler.getScheme() == URL_SCHEME_VIRCADIA && !_domainHandler.getHostname().isEmpty()) { // We're about to connect but we need the domain settings (in particular, the node permissions) in order to adjust the // canRezAvatarEntities permission above before using the permissions in determining whether or not to connect without // avatar entities rezzing below. diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 417e6d94e5..6627f75ae6 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -2405,7 +2405,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co QString currentDomain = DependencyManager::get()->getDomainURL().host(); QString domainSafeIP = nodeList->getDomainHandler().getHostname(); - QString domainSafeURL = URL_SCHEME_HIFI + "://" + currentDomain; + QString domainSafeURL = URL_SCHEME_VIRCADIA + "://" + currentDomain; for (const auto& str : safeURLPrefixes) { if (domainSafeURL.startsWith(str) || domainSafeIP.startsWith(str)) { qCDebug(scriptengine) << whitelistPrefix << "Whitelist Bypassed, entire domain is whitelisted. Current Domain Host: " From 1411d5536479b07ea92afee754c871a12c5679c6 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Tue, 15 Jun 2021 00:31:28 -0400 Subject: [PATCH 02/10] Add ability for 'handleLookupString' to have spaces. --- libraries/networking/src/AddressManager.cpp | 49 ++++++++++++++++----- libraries/networking/src/AddressManager.h | 33 +++++++------- 2 files changed, 55 insertions(+), 27 deletions(-) diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index c246cc00de..db9f35fa94 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -242,7 +242,7 @@ const JSONCallbackParameters& AddressManager::apiCallbackParameters() { return callbackParams; } -bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger) { +bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger, const QString& lookupUrlInString) { static QString URL_TYPE_USER = "user"; static QString URL_TYPE_DOMAIN_ID = "domain_id"; static QString URL_TYPE_PLACE = "place"; @@ -271,7 +271,15 @@ bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger) { // would indicate that the scheme is 'somewhere' // use hifi://somewhere: instead - if (lookupUrl.scheme() == URL_SCHEME_VIRCADIA) { + if (lookupUrl.scheme() == URL_SCHEME_VIRCADIA || lookupUrlInString.startsWith(URL_SCHEME_VIRCADIA + "://")) { + QString lookupUrlString; + + if (lookupUrlInString.startsWith(URL_SCHEME_VIRCADIA + "://")) { + lookupUrlString = lookupUrlInString; + } else { + lookupUrlString = lookupUrl.toString(QUrl::FullyEncoded); + } + if (lookupUrl.host().isEmpty()) { // this was in the form hifi:/somewhere or hifi:somewhere. Fix it by making it hifi://somewhere static const QRegExp HIFI_SCHEME_REGEX = QRegExp(URL_SCHEME_VIRCADIA + ":\\/{0,2}", Qt::CaseInsensitive); @@ -340,6 +348,8 @@ bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger) { // try to look up the domain ID on the metaverse API attemptDomainIDLookup(lookupUrl.host(), lookupUrl.path(), trigger); } else { + // wasn't an address - lookup the place name + // we may have a path that defines a relative viewpoint - pass that through the lookup so we can go to it after UserActivityLogger::getInstance().wentTo(trigger, URL_TYPE_PLACE, lookupUrl.toString()); // save the last visited domain URL. @@ -348,10 +358,27 @@ bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger) { // store this place name as the previous lookup in case we fail to connect and want to refresh API info _previousAPILookup = lookupUrl; - // wasn't an address - lookup the place name - // we may have a path that defines a relative viewpoint - pass that through the lookup so we can go to it after - if (!lookupUrl.host().isNull() && !lookupUrl.host().isEmpty()) { - attemptPlaceNameLookup(lookupUrl.host(), lookupUrl.path(), trigger); + // Let's convert this to a QString for processing in case there are spaces in it. + + if (lookupUrlString.contains(URL_SCHEME_VIRCADIA + "://", Qt::CaseInsensitive)) { + lookupUrlString = lookupUrlString.replace((URL_SCHEME_VIRCADIA + "://"), ""); + } else if (lookupUrlString.contains(URL_SCHEME_VIRCADIA + ":/", Qt::CaseInsensitive)) { + lookupUrlString = lookupUrlString.replace((URL_SCHEME_VIRCADIA + ":/"), ""); + } else if (lookupUrlString.contains(URL_SCHEME_VIRCADIA + ":", Qt::CaseInsensitive)) { + lookupUrlString = lookupUrlString.replace((URL_SCHEME_VIRCADIA + ":"), ""); + } + + // Get the path and then strip it out. + QString lookupUrlStringPath; + + int index = lookupUrlString.indexOf('/'); + if (index != -1) { + lookupUrlStringPath = lookupUrlString.mid(index); + lookupUrlString.replace(lookupUrlStringPath, ""); + } + + if (!lookupUrlString.isNull() && !lookupUrlString.isEmpty()) { + attemptPlaceNameLookup(lookupUrlString, lookupUrlStringPath, trigger); } } } @@ -412,13 +439,13 @@ bool isPossiblePlaceName(QString possiblePlaceName) { } void AddressManager::handleLookupString(const QString& lookupString, bool fromSuggestions) { + QString trimmedString = lookupString.trimmed(); - QString sanitizedString = lookupString.trimmed(); - if (!sanitizedString.isEmpty()) { + if (!trimmedString.isEmpty()) { resetConfirmConnectWithoutAvatarEntities(); // make this a valid hifi URL and handle it off to handleUrl - handleUrl(sanitizedString, fromSuggestions ? Suggestions : UserInput); + handleUrl(trimmedString, fromSuggestions ? Suggestions : UserInput, trimmedString); } } @@ -606,7 +633,7 @@ void AddressManager::handleAPIError(QNetworkReply* errorReply) { void AddressManager::attemptPlaceNameLookup(const QString& lookupString, const QString& overridePath, LookupTrigger trigger) { // assume this is a place name and see if we can get any info on it - QString placeName = QUrl::toPercentEncoding(lookupString); + //QString placeName = QUrl::toPercentEncoding(lookupString); QVariantMap requestParams; @@ -618,7 +645,7 @@ void AddressManager::attemptPlaceNameLookup(const QString& lookupString, const Q // remember how this lookup was triggered for history storage handling later requestParams.insert(LOOKUP_TRIGGER_KEY, static_cast(trigger)); - DependencyManager::get()->sendRequest(GET_PLACE.arg(placeName), + DependencyManager::get()->sendRequest(GET_PLACE.arg(lookupString), AccountManagerAuth::None, QNetworkAccessManager::GetOperation, apiCallbackParameters(), diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index e8793edc1d..3632b7f938 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -4,6 +4,7 @@ // // Created by Stephen Birarda on 2014-09-10. // Copyright 2014 High Fidelity, Inc. +// Copyright 2021 Vircadia contributors. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -35,7 +36,7 @@ const QString GET_PLACE = "/api/v1/places/%1"; * The location API provides facilities related to your current location in the metaverse. * *

Getter/Setter

- *

You can get and set your current metaverse address by directly reading a string value from and writing a string value to + *

You can get and set your current metaverse address by directly reading a string value from and writing a string value to * the location object. This is an alternative to using the location.href property or other object * functions.

* @@ -53,12 +54,12 @@ const QString GET_PLACE = "/api/v1/places/%1"; * localhost, or an IP address). Is blank if you're in a serverless domain. * Read-only. * @property {string} href - Your current metaverse address (e.g., "hifi://domainname/15,-10,26/0,0,0,1") - * regardless of whether or not you're connected to the domain. Starts with "file:///" if you're in a + * regardless of whether or not you're connected to the domain. Starts with "file:///" if you're in a * serverless domain. * Read-only. * @property {boolean} isConnected - true if you're connected to the domain in your current href * metaverse address, otherwise false. - * @property {string} pathname - The location and orientation in your current href metaverse address + * @property {string} pathname - The location and orientation in your current href metaverse address * (e.g., "/15,-10,26/0,0,0,1"). * Read-only. * @property {string} placename - The place name in your current href metaverse address @@ -77,7 +78,7 @@ const QString GET_PLACE = "/api/v1/places/%1"; * @hifi-client-entity * @hifi-avatar * - * @deprecated This API is deprecated and will be removed. Use the {@link location} or {@link Window|Window.location} APIs + * @deprecated This API is deprecated and will be removed. Use the {@link location} or {@link Window|Window.location} APIs * instead. * * @property {Uuid} domainID - A UUID uniquely identifying the domain you're visiting. Is {@link Uuid(0)|Uuid.NULL} if you're not @@ -248,9 +249,9 @@ public slots: /*@jsdoc * Takes you to a specified metaverse address. * @function location.handleLookupString - * @param {string} address - The address to go to: a "hifi://" address, an IP address (e.g., - * "127.0.0.1" or "localhost"), a file:/// address, a domain name, a named path - * on a domain (starts with "/"), a position or position and orientation, or a user (starts with + * @param {string} address - The address to go to: a "hifi://" address, an IP address (e.g., + * "127.0.0.1" or "localhost"), a file:/// address, a domain name, a named path + * on a domain (starts with "/"), a position or position and orientation, or a user (starts with * "@"). * @param {boolean} [fromSuggestions=false] - Set to true if the address is obtained from the "Goto" dialog. * Helps ensure that user's location history is correctly maintained. @@ -258,7 +259,7 @@ public slots: void handleLookupString(const QString& lookupString, bool fromSuggestions = false); /*@jsdoc - * Takes you to a position and orientation resulting from a lookup for a named path in the domain (set in the domain + * Takes you to a position and orientation resulting from a lookup for a named path in the domain (set in the domain * server's settings). * @function location.goToViewpointForPath * @param {string} path - The position and orientation corresponding to the named path. @@ -292,7 +293,7 @@ public slots: * location history is correctly maintained. */ void goToLocalSandbox(QString path = "", LookupTrigger trigger = LookupTrigger::StartupFromSettings) { - handleUrl(SANDBOX_HIFI_ADDRESS + path, trigger); + handleUrl(SANDBOX_HIFI_ADDRESS + path, trigger); } /*@jsdoc @@ -307,7 +308,7 @@ public slots: * Takes you to the specified user's location. * @function location.goToUser * @param {string} username - The user's username. - * @param {boolean} [matchOrientation=true] - If true then go to a location just in front of the user and turn + * @param {boolean} [matchOrientation=true] - If true then go to a location just in front of the user and turn * to face them, otherwise go to the user's exact location and orientation. */ void goToUser(const QString& username, bool shouldMatchOrientation = true); @@ -348,7 +349,7 @@ public slots: void copyAddress(); /*@jsdoc - * Copies your current metaverse location and orientation (i.e., location.pathname property value) to the OS + * Copies your current metaverse location and orientation (i.e., location.pathname property value) to the OS * clipboard. * @function location.copyPath */ @@ -374,7 +375,7 @@ signals: void lookupResultsFinished(); /*@jsdoc - * Triggered when looking up the details of a metaverse user or location to go to has completed and the domain or user is + * Triggered when looking up the details of a metaverse user or location to go to has completed and the domain or user is * offline. * @function location.lookupResultIsOffline * @returns {Signal} @@ -415,9 +416,9 @@ signals: * @function location.locationChangeRequired * @param {Vec3} position - The position to go to. * @param {boolean} hasOrientationChange - If true then a new orientation has been requested. - * @param {Quat} orientation - The orientation to change to. Is {@link Quat(0)|Quat.IDENTITY} if + * @param {Quat} orientation - The orientation to change to. Is {@link Quat(0)|Quat.IDENTITY} if * hasOrientationChange is false. - * @param {boolean} shouldFaceLocation - If true then the request is to go to a position near that specified + * @param {boolean} shouldFaceLocation - If true then the request is to go to a position near that specified * and orient your avatar to face it. For example when you visit someone from the "People" dialog. * @returns {Signal} * @example Report location change requests. @@ -468,7 +469,7 @@ signals: * Triggered when there's a change in whether or not there's a previous location that can be navigated to using * {@link location.goBack|goBack}. (Reflects changes in the state of the "Goto" dialog's back arrow.) * @function location.goBackPossible - * @param {boolean} isPossible - true if there's a previous location to navigate to, otherwise + * @param {boolean} isPossible - true if there's a previous location to navigate to, otherwise * false. * @returns {Signal} * @example Report when ability to navigate back changes. @@ -511,7 +512,7 @@ private: const JSONCallbackParameters& apiCallbackParameters(); - bool handleUrl(const QUrl& lookupUrl, LookupTrigger trigger = UserInput); + bool handleUrl(const QUrl& lookupUrl, LookupTrigger trigger = UserInput, const QString& lookupUrlInString = ""); bool handleNetworkAddress(const QString& lookupString, LookupTrigger trigger, bool& hostChanged); void handlePath(const QString& path, LookupTrigger trigger, bool wasPathOnly = false); From 1215ced6fa6c4c1d62048294865ef492b3ddca23 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Tue, 15 Jun 2021 15:02:03 -0400 Subject: [PATCH 03/10] CR. --- libraries/networking/src/AddressManager.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index db9f35fa94..96d72cabaf 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -359,7 +359,6 @@ bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger, c _previousAPILookup = lookupUrl; // Let's convert this to a QString for processing in case there are spaces in it. - if (lookupUrlString.contains(URL_SCHEME_VIRCADIA + "://", Qt::CaseInsensitive)) { lookupUrlString = lookupUrlString.replace((URL_SCHEME_VIRCADIA + "://"), ""); } else if (lookupUrlString.contains(URL_SCHEME_VIRCADIA + ":/", Qt::CaseInsensitive)) { @@ -377,7 +376,7 @@ bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger, c lookupUrlString.replace(lookupUrlStringPath, ""); } - if (!lookupUrlString.isNull() && !lookupUrlString.isEmpty()) { + if (!lookupUrlString.isEmpty()) { attemptPlaceNameLookup(lookupUrlString, lookupUrlStringPath, trigger); } } @@ -633,8 +632,6 @@ void AddressManager::handleAPIError(QNetworkReply* errorReply) { void AddressManager::attemptPlaceNameLookup(const QString& lookupString, const QString& overridePath, LookupTrigger trigger) { // assume this is a place name and see if we can get any info on it - //QString placeName = QUrl::toPercentEncoding(lookupString); - QVariantMap requestParams; // if the user asked for a specific path with this lookup then keep it with the request so we can use it later From 0625dbe53c801904e59ed378d466692a831d8522 Mon Sep 17 00:00:00 2001 From: Kalila L Date: Thu, 17 Jun 2021 19:45:56 -0400 Subject: [PATCH 04/10] Some URL updates. --- .../networking/src/NetworkingConstants.h | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/networking/src/NetworkingConstants.h b/libraries/networking/src/NetworkingConstants.h index 6fa352f699..ae3607eed9 100644 --- a/libraries/networking/src/NetworkingConstants.h +++ b/libraries/networking/src/NetworkingConstants.h @@ -25,7 +25,7 @@ namespace NetworkingConstants { // You can avoid changing that and still effectively use a connected domain on staging // if you manually generate a personal access token for the domains scope // at https://staging.highfidelity.com/user/tokens/new?for_domain_server=true - + const QString WEB_ENGINE_VERSION = "Chrome/83.0.4103.122"; // For now we only have one Metaverse server. @@ -35,21 +35,21 @@ namespace NetworkingConstants { // Web Engine requests to this parent domain have an account authorization header added const QString AUTH_HOSTNAME_BASE = "vircadia.com"; const QStringList IS_AUTHABLE_HOSTNAME = { "vircadia.com", "vircadia.io" }; - + // Use a custom User-Agent to avoid ModSecurity filtering, e.g. by hosting providers. const QByteArray VIRCADIA_USER_AGENT = "Mozilla/5.0 (VircadiaInterface)"; - + const QString WEB_ENGINE_USER_AGENT = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) " + WEB_ENGINE_VERSION + " Mobile Safari/537.36"; const QString MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) " + WEB_ENGINE_VERSION + " Mobile Safari/537.36"; - + // WebEntity Defaults const QString WEB_ENTITY_DEFAULT_SOURCE_URL = "https://vircadia.com/"; const QString WEB_ENTITY_DEFAULT_USER_AGENT = WEB_ENGINE_USER_AGENT; - + // Builds URLs const QUrl BUILDS_XML_URL("https://highfidelity.com/builds.xml"); const QUrl MASTER_BUILDS_XML_URL("https://highfidelity.com/dev-builds.xml"); - + const QString DEFAULT_AVATAR_COLLISION_SOUND_URL = "https://hifi-public.s3.amazonaws.com/sounds/Collisions-otherorganic/Body_Hits_Impact.wav"; // CDN URLs @@ -71,12 +71,12 @@ namespace NetworkingConstants { const unsigned short STUN_SERVER_DEFAULT_PORT = 19302; #endif - const QUrl HELP_DOCS_URL { "https://docs.vircadia.dev" }; - const QUrl HELP_FORUM_URL { "https://forums.vircadia.dev" }; + const QUrl HELP_DOCS_URL { "https://docs.vircadia.com" }; + const QUrl HELP_FORUM_URL { "https://forum.vircadia.com" }; const QUrl HELP_SCRIPTING_REFERENCE_URL{ "https://apidocs.vircadia.dev/" }; - const QUrl HELP_RELEASE_NOTES_URL{ "https://docs.vircadia.dev/release-notes.html" }; + const QUrl HELP_RELEASE_NOTES_URL{ "https://docs.vircadia.com/release-notes.html" }; const QUrl HELP_BUG_REPORT_URL{ "https://github.com/vircadia/vircadia/issues" }; - + const QString DEFAULT_VIRCADIA_ADDRESS = "file:///~/serverless/tutorial.json"; const QString DEFAULT_HOME_ADDRESS = "file:///~/serverless/tutorial.json"; const QString REDIRECT_HIFI_ADDRESS = "file:///~/serverless/redirect.json"; From 4835a4a33da1084230b556e71800461623919432 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 4 Jul 2021 01:41:32 +0200 Subject: [PATCH 05/10] Archive vcpkg logs, for debugging This collects the logs generated during the vcpkg run, and archives them as an artifact. --- .github/workflows/pr_build.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 8b4201f068..3cffad0b3d 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -25,6 +25,8 @@ env: # WIN32 specific variables PreferredToolArchitecture: X64 + # Ensure XZ always runs with muticore support + XZ_OPT: -T0 jobs: build: @@ -140,6 +142,18 @@ jobs: working-directory: ${{runner.workspace}}/build shell: bash run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DVCPKG_BUILD_TYPE=release $CMAKE_EXTRA + - name: Compress cmake logs + if: always() + shell: bash + run: | + find "$HOME/vircadia-files/vcpkg" -name '*log' -type f -print0 | tar --null --force-local -T - -c --xz -v -f "${{ runner.workspace }}/cmake-logs.tar.xz" + - name: Archive cmake logs + if: always() + uses: actions/upload-artifact@v2 + with: + name: cmake-logs + path: ${{ runner.workspace }}/cmake-logs.tar.xz + if-no-files-found: error - name: Build Application if: matrix.build_type == 'full' || matrix.build_type == 'client' working-directory: ${{runner.workspace}}/build @@ -231,4 +245,4 @@ jobs: if [[ "${{ matrix.build_type }}" == "android" ]]; then cd $GITHUB_WORKSPACE/android fi - $PYTHON_EXEC "$GITHUB_WORKSPACE/tools/ci-scripts/upload_to_publish_server.py" \ No newline at end of file + $PYTHON_EXEC "$GITHUB_WORKSPACE/tools/ci-scripts/upload_to_publish_server.py" From 6722c6af26f3269d01d21d147f7260a6048f32a9 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 4 Jul 2021 15:28:55 +0200 Subject: [PATCH 06/10] Use GNU Tar --- .github/workflows/pr_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 3cffad0b3d..c22fe56877 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -146,7 +146,7 @@ jobs: if: always() shell: bash run: | - find "$HOME/vircadia-files/vcpkg" -name '*log' -type f -print0 | tar --null --force-local -T - -c --xz -v -f "${{ runner.workspace }}/cmake-logs.tar.xz" + find "$HOME/vircadia-files/vcpkg" -name '*log' -type f -print0 | gtar --null --force-local -T - -c --xz -v -f "${{ runner.workspace }}/cmake-logs.tar.xz" - name: Archive cmake logs if: always() uses: actions/upload-artifact@v2 From 4971ae4bd33a85deee2618f1a352fc6719a50db7 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 4 Jul 2021 16:00:16 +0200 Subject: [PATCH 07/10] Deal with different tar names --- .github/workflows/pr_build.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index c22fe56877..f462c0a84c 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -146,7 +146,13 @@ jobs: if: always() shell: bash run: | - find "$HOME/vircadia-files/vcpkg" -name '*log' -type f -print0 | gtar --null --force-local -T - -c --xz -v -f "${{ runner.workspace }}/cmake-logs.tar.xz" + if [ "${{ matrix.os }}" == "macOS-latest" ]; then + TAR=gtar + else + TAR=tar + fi + + find "$HOME/vircadia-files/vcpkg" -name '*log' -type f -print0 | $TAR --null --force-local -T - -c --xz -v -f "${{ runner.workspace }}/cmake-logs.tar.xz" - name: Archive cmake logs if: always() uses: actions/upload-artifact@v2 From c4bc4fc15affcea527f603bf984d71302139e834 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 4 Jul 2021 16:37:00 +0200 Subject: [PATCH 08/10] Improve log archive naming --- .github/workflows/pr_build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index f462c0a84c..4cb298c6c9 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -152,13 +152,13 @@ jobs: TAR=tar fi - find "$HOME/vircadia-files/vcpkg" -name '*log' -type f -print0 | $TAR --null --force-local -T - -c --xz -v -f "${{ runner.workspace }}/cmake-logs.tar.xz" + find "$HOME/vircadia-files/vcpkg" -name '*log' -type f -print0 | $TAR --null --force-local -T - -c --xz -v -f "${{ runner.workspace }}/cmake-logs-${{ matrix.os }}-${{ github.event.number }}.tar.xz" - name: Archive cmake logs if: always() uses: actions/upload-artifact@v2 with: name: cmake-logs - path: ${{ runner.workspace }}/cmake-logs.tar.xz + path: ${{ runner.workspace }}/cmake-logs-${{ matrix.os }}-${{ github.event.number }}.tar.xz if-no-files-found: error - name: Build Application if: matrix.build_type == 'full' || matrix.build_type == 'client' From 54b28a1fed71e6799a196e8435278c46247aa325 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 4 Jul 2021 16:57:02 +0200 Subject: [PATCH 09/10] Name the artifact too --- .github/workflows/pr_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index 4cb298c6c9..7ad8d2c0a5 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -157,7 +157,7 @@ jobs: if: always() uses: actions/upload-artifact@v2 with: - name: cmake-logs + name: cmake-logs-${{ matrix.os }}-${{ github.event.number }}.tar.xz path: ${{ runner.workspace }}/cmake-logs-${{ matrix.os }}-${{ github.event.number }}.tar.xz if-no-files-found: error - name: Build Application From 6314cd33edd3d066053691e46155e5084a23993a Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 11 Jul 2021 00:48:11 +0200 Subject: [PATCH 10/10] Fix "Ninja does not support toolset specification" on Windows --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index facc1c999f..7293e9f825 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ MESSAGE(STATUS "GLES_OPTION: ${GLES_OPTION}") include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros/TargetPython.cmake") target_python() -if (WIN32 AND NOT HIFI_ANDROID) +if (WIN32 AND NOT HIFI_ANDROID AND NOT (CMAKE_GENERATOR STREQUAL "Ninja")) # Force x64 toolset set(CMAKE_GENERATOR_TOOLSET "host=x64" CACHE STRING "64-bit toolset" FORCE) endif()