diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 28100efd2d..436f49c7ca 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -339,12 +340,12 @@ bool DomainServer::optionallySetupOAuth() { const QVariantMap& settingsMap = _settingsManager.getSettingsMap(); _oauthProviderURL = QUrl(settingsMap.value(OAUTH_PROVIDER_URL_OPTION).toString()); - auto accountManager = DependencyManager::get(); // if we don't have an oauth provider URL then we default to the default node auth url if (_oauthProviderURL.isEmpty()) { - _oauthProviderURL = accountManager->getMetaverseServerURL(); + _oauthProviderURL = NetworkingConstants::METAVERSE_SERVER_URL; } + auto accountManager = DependencyManager::get(); accountManager->setAuthURL(_oauthProviderURL); _oauthClientID = settingsMap.value(OAUTH_CLIENT_ID_OPTION).toString(); diff --git a/ice-server/src/IceServer.cpp b/ice-server/src/IceServer.cpp index a2e900e8d2..f8bf1f62ae 100644 --- a/ice-server/src/IceServer.cpp +++ b/ice-server/src/IceServer.cpp @@ -18,9 +18,9 @@ #include #include -#include #include #include +#include #include #include @@ -208,7 +208,7 @@ void IceServer::requestDomainPublicKey(const QUuid& domainID) { // send a request to the metaverse API for the public key for this domain auto& networkAccessManager = NetworkAccessManager::getInstance(); - QUrl publicKeyURL { DependencyManager::get()->getMetaverseServerURL() }; + QUrl publicKeyURL { NetworkingConstants::METAVERSE_SERVER_URL }; QString publicKeyPath = QString("/api/v1/domains/%1/public_key").arg(uuidStringWithoutCurlyBraces(domainID)); publicKeyURL.setPath(publicKeyPath); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5e41886905..f2bb52ea47 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -94,6 +94,7 @@ #include #include #include +#include #include #include #include @@ -960,7 +961,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // set the account manager's root URL and trigger a login request if we don't have the access token accountManager->setIsAgent(true); - accountManager->setAuthURL(accountManager->getMetaverseServerURL()); + accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL); auto addressManager = DependencyManager::get(); diff --git a/interface/src/commerce/Ledger.cpp b/interface/src/commerce/Ledger.cpp index bd7668cf32..80e599fb24 100644 --- a/interface/src/commerce/Ledger.cpp +++ b/interface/src/commerce/Ledger.cpp @@ -16,6 +16,7 @@ #include "Wallet.h" #include "Ledger.h" #include "CommerceLogging.h" +#include // inventory answers {status: 'success', data: {assets: [{id: "guid", title: "name", preview: "url"}....]}} // balance answers {status: 'success', data: {balance: integer}} @@ -120,6 +121,7 @@ QString nameFromKey(const QString& key, const QStringList& publicKeys) { return "Someone"; } +static const QString MARKETPLACE_ITEMS_BASE_URL = NetworkingConstants::METAVERSE_SERVER_URL.toString() + "/marketplace/items/"; void Ledger::historySuccess(QNetworkReply& reply) { // here we send a historyResult with some extra stuff in it // Namely, the styled text we'd like to show. The issue is the @@ -152,7 +154,7 @@ void Ledger::historySuccess(QNetworkReply& reply) { } } else { coloredQuantityAndAssetTitle = QString("\"") + coloredQuantityAndAssetTitle + diff --git a/interface/src/networking/CloseEventSender.cpp b/interface/src/networking/CloseEventSender.cpp index 41e1fb8bef..de8bd897b2 100644 --- a/interface/src/networking/CloseEventSender.cpp +++ b/interface/src/networking/CloseEventSender.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -26,13 +27,13 @@ QNetworkRequest createNetworkRequest() { QNetworkRequest request; - auto accountManager = DependencyManager::get(); - QUrl requestURL = accountManager->getMetaverseServerURL(); + QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL; requestURL.setPath(USER_ACTIVITY_URL); request.setUrl(requestURL); + auto accountManager = DependencyManager::get(); if (accountManager->hasValidAccessToken()) { request.setRawHeader(ACCESS_TOKEN_AUTHORIZATION_HEADER, diff --git a/interface/src/ui/AddressBarDialog.h b/interface/src/ui/AddressBarDialog.h index 48e702f5bf..cab533cce3 100644 --- a/interface/src/ui/AddressBarDialog.h +++ b/interface/src/ui/AddressBarDialog.h @@ -13,8 +13,8 @@ #ifndef hifi_AddressBarDialog_h #define hifi_AddressBarDialog_h -#include #include +#include class AddressBarDialog : public OffscreenQmlDialog { Q_OBJECT @@ -30,7 +30,7 @@ public: bool forwardEnabled() { return _forwardEnabled; } bool useFeed() { return _useFeed; } void setUseFeed(bool useFeed) { if (_useFeed != useFeed) { _useFeed = useFeed; emit useFeedChanged(); } } - QString metaverseServerUrl() { return DependencyManager::get()->getMetaverseServerURL().toString(); } + QString metaverseServerUrl() { return NetworkingConstants::METAVERSE_SERVER_URL.toString(); } signals: void backEnabledChanged(); diff --git a/interface/src/ui/overlays/ContextOverlayInterface.cpp b/interface/src/ui/overlays/ContextOverlayInterface.cpp index 08e8e734c0..70b75a0b17 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.cpp +++ b/interface/src/ui/overlays/ContextOverlayInterface.cpp @@ -12,8 +12,8 @@ #include "ContextOverlayInterface.h" #include "Application.h" -#include #include +#include #ifndef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) @@ -263,6 +263,8 @@ void ContextOverlayInterface::openInspectionCertificate() { } } +static const QString MARKETPLACE_BASE_URL = NetworkingConstants::METAVERSE_SERVER_URL.toString() + "/marketplace/items/"; + void ContextOverlayInterface::openMarketplace() { // lets open the tablet and go to the current item in // the marketplace (if the current entity has a @@ -270,7 +272,7 @@ void ContextOverlayInterface::openMarketplace() { if (!_currentEntityWithContextOverlay.isNull() && _entityMarketplaceID.length() > 0) { auto tablet = dynamic_cast(_tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); // construct the url to the marketplace item - QString url = DependencyManager::get()->getMetaverseServerURL().toString() + "/marketplace/items/" + _entityMarketplaceID; + QString url = MARKETPLACE_BASE_URL + _entityMarketplaceID; QString MARKETPLACES_INJECT_SCRIPT_PATH = "file:///" + qApp->applicationDirPath() + "/scripts/system/html/js/marketplacesInject.js"; tablet->gotoWebScreen(url, MARKETPLACES_INJECT_SCRIPT_PATH); _hmdScriptingInterface->openTablet(); diff --git a/libraries/networking/src/AccountManager.h b/libraries/networking/src/AccountManager.h index a0abde26c9..7d97687d0b 100644 --- a/libraries/networking/src/AccountManager.h +++ b/libraries/networking/src/AccountManager.h @@ -18,6 +18,7 @@ #include #include +#include "NetworkingConstants.h" #include "NetworkAccessManager.h" #include "DataServerAccountInfo.h" @@ -58,13 +59,6 @@ using UserAgentGetter = std::function; const auto DEFAULT_USER_AGENT_GETTER = []() -> QString { return HIGH_FIDELITY_USER_AGENT; }; -// If you want to use STAGING instead of STABLE, -// don't forget to ALSO change the Domain Server Metaverse Server URL, which is at the top of: -// \domain-server\resources\web\settings\js\settings.js -const QUrl METAVERSE_SERVER_URL_STAGING("https://staging.highfidelity.com"); -const QUrl METAVERSE_SERVER_URL_STABLE("https://metaverse.highfidelity.com"); -const QUrl METAVERSE_SERVER_URL = METAVERSE_SERVER_URL_STABLE; - class AccountManager : public QObject, public Dependency { Q_OBJECT public: @@ -103,7 +97,7 @@ public: void setTemporaryDomain(const QUuid& domainID, const QString& key); const QString& getTemporaryDomainKey(const QUuid& domainID) { return _accountInfo.getTemporaryDomainKey(domainID); } - QUrl getMetaverseServerURL() { return METAVERSE_SERVER_URL; } + QUrl getMetaverseServerURL() { return NetworkingConstants::METAVERSE_SERVER_URL; } public slots: void requestAccessToken(const QString& login, const QString& password); diff --git a/libraries/networking/src/NetworkingConstants.h b/libraries/networking/src/NetworkingConstants.h new file mode 100644 index 0000000000..0bb0cee5d2 --- /dev/null +++ b/libraries/networking/src/NetworkingConstants.h @@ -0,0 +1,26 @@ +// +// NetworkingConstants.h +// libraries/networking/src +// +// Created by Stephen Birarda on 2015-03-31. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_NetworkingConstants_h +#define hifi_NetworkingConstants_h + +#include + +namespace NetworkingConstants { + // If you want to use STAGING instead of STABLE, + // don't forget to ALSO change the Domain Server Metaverse Server URL, which is at the top of: + // \domain-server\resources\web\settings\js\settings.js + const QUrl METAVERSE_SERVER_URL_STABLE("https://metaverse.highfidelity.com"); + const QUrl METAVERSE_SERVER_URL_STAGING("https://staging.highfidelity.com"); + const QUrl METAVERSE_SERVER_URL = METAVERSE_SERVER_URL_STABLE; +} + +#endif // hifi_NetworkingConstants_h diff --git a/libraries/networking/src/OAuthNetworkAccessManager.cpp b/libraries/networking/src/OAuthNetworkAccessManager.cpp index 42b8f16575..15d5acbc67 100644 --- a/libraries/networking/src/OAuthNetworkAccessManager.cpp +++ b/libraries/networking/src/OAuthNetworkAccessManager.cpp @@ -15,6 +15,7 @@ #include "AccountManager.h" #include "LimitedNodeList.h" +#include "NetworkingConstants.h" #include "SharedUtil.h" #include "OAuthNetworkAccessManager.h" @@ -34,7 +35,7 @@ QNetworkReply* OAuthNetworkAccessManager::createRequest(QNetworkAccessManager::O auto accountManager = DependencyManager::get(); if (accountManager->hasValidAccessToken() - && req.url().host() == accountManager->getMetaverseServerURL().host()) { + && req.url().host() == NetworkingConstants::METAVERSE_SERVER_URL.host()) { QNetworkRequest authenticatedRequest(req); authenticatedRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); authenticatedRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); diff --git a/libraries/script-engine/src/XMLHttpRequestClass.cpp b/libraries/script-engine/src/XMLHttpRequestClass.cpp index c8d518e6c9..1d3c8fda32 100644 --- a/libraries/script-engine/src/XMLHttpRequestClass.cpp +++ b/libraries/script-engine/src/XMLHttpRequestClass.cpp @@ -17,10 +17,13 @@ #include #include +#include #include "ScriptEngine.h" #include "XMLHttpRequestClass.h" +const QString METAVERSE_API_URL = NetworkingConstants::METAVERSE_SERVER_URL.toString() + "/api/"; + Q_DECLARE_METATYPE(QByteArray*) XMLHttpRequestClass::XMLHttpRequestClass(QScriptEngine* engine) : @@ -137,9 +140,7 @@ void XMLHttpRequestClass::open(const QString& method, const QString& url, bool a _url.setUrl(url); _async = async; - auto metaverseApiUrl = DependencyManager::get()->getMetaverseServerURL().toString() + "/api/"; - - if (url.toLower().left(metaverseApiUrl.length()) == metaverseApiUrl) { + if (url.toLower().left(METAVERSE_API_URL.length()) == METAVERSE_API_URL) { auto accountManager = DependencyManager::get(); if (accountManager->hasValidAccessToken()) { diff --git a/libraries/ui/src/ui/types/RequestFilters.cpp b/libraries/ui/src/ui/types/RequestFilters.cpp index 10c0eef58d..b1deec47c8 100644 --- a/libraries/ui/src/ui/types/RequestFilters.cpp +++ b/libraries/ui/src/ui/types/RequestFilters.cpp @@ -10,6 +10,7 @@ // #include "RequestFilters.h" +#include "NetworkingConstants.h" #include #include @@ -19,7 +20,7 @@ namespace { bool isAuthableHighFidelityURL(const QUrl& url) { - auto metaverseServerURL = DependencyManager::get()->getMetaverseServerURL(); + auto metaverseServerURL = NetworkingConstants::METAVERSE_SERVER_URL; static const QStringList HF_HOSTS = { "highfidelity.com", "highfidelity.io", metaverseServerURL.toString(), "metaverse.highfidelity.io" diff --git a/tools/ac-client/src/ACClientApp.cpp b/tools/ac-client/src/ACClientApp.cpp index f3ea9b7348..e00560158f 100644 --- a/tools/ac-client/src/ACClientApp.cpp +++ b/tools/ac-client/src/ACClientApp.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -105,7 +106,7 @@ ACClientApp::ACClientApp(int argc, char* argv[]) : auto accountManager = DependencyManager::get(); accountManager->setIsAgent(true); - accountManager->setAuthURL(accountManager->getMetaverseServerURL()); + accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL); auto nodeList = DependencyManager::get(); diff --git a/tools/atp-client/src/ATPClientApp.cpp b/tools/atp-client/src/ATPClientApp.cpp index 85aee10d76..c5edf27b67 100644 --- a/tools/atp-client/src/ATPClientApp.cpp +++ b/tools/atp-client/src/ATPClientApp.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -144,7 +145,7 @@ ATPClientApp::ATPClientApp(int argc, char* argv[]) : auto accountManager = DependencyManager::get(); accountManager->setIsAgent(true); - accountManager->setAuthURL(accountManager->getMetaverseServerURL()); + accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL); auto nodeList = DependencyManager::get();