Return to using NetworkingConstants

This commit is contained in:
Zach Fox 2017-10-26 14:12:36 -07:00
parent 3e95484c4c
commit 002141724b
14 changed files with 59 additions and 27 deletions

View file

@ -31,6 +31,7 @@
#include <HifiConfigVariantMap.h>
#include <HTTPConnection.h>
#include <LogUtils.h>
#include <NetworkingConstants.h>
#include <udt/PacketHeaders.h>
#include <SettingHandle.h>
#include <SharedUtil.h>
@ -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<AccountManager>();
// 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>();
accountManager->setAuthURL(_oauthProviderURL);
_oauthClientID = settingsMap.value(OAUTH_CLIENT_ID_OPTION).toString();

View file

@ -18,9 +18,9 @@
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkRequest>
#include <AccountManager.h>
#include <LimitedNodeList.h>
#include <NetworkAccessManager.h>
#include <NetworkingConstants.h>
#include <udt/PacketHeaders.h>
#include <SharedUtil.h>
@ -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<AccountManager>()->getMetaverseServerURL() };
QUrl publicKeyURL { NetworkingConstants::METAVERSE_SERVER_URL };
QString publicKeyPath = QString("/api/v1/domains/%1/public_key").arg(uuidStringWithoutCurlyBraces(domainID));
publicKeyURL.setPath(publicKeyPath);

View file

@ -94,6 +94,7 @@
#include <MessagesClient.h>
#include <ModelEntityItem.h>
#include <NetworkAccessManager.h>
#include <NetworkingConstants.h>
#include <ObjectMotionState.h>
#include <OctalCode.h>
#include <OctreeSceneStats.h>
@ -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<AddressManager>();

View file

@ -16,6 +16,7 @@
#include "Wallet.h"
#include "Ledger.h"
#include "CommerceLogging.h"
#include <NetworkingConstants.h>
// 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("\"<font color='#0093C5'><a href='") +
DependencyManager::get<AccountManager>()->getMetaverseServerURL().toString() + "/marketplace/items/" +
MARKETPLACE_ITEMS_BASE_URL +
valueObject["asset_id"].toString() +
QString("'>") +
coloredQuantityAndAssetTitle +

View file

@ -17,6 +17,7 @@
#include <ThreadHelpers.h>
#include <AccountManager.h>
#include <NetworkAccessManager.h>
#include <NetworkingConstants.h>
#include <NetworkLogging.h>
#include <UserActivityLogger.h>
#include <UUID.h>
@ -26,13 +27,13 @@
QNetworkRequest createNetworkRequest() {
QNetworkRequest request;
auto accountManager = DependencyManager::get<AccountManager>();
QUrl requestURL = accountManager->getMetaverseServerURL();
QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL;
requestURL.setPath(USER_ACTIVITY_URL);
request.setUrl(requestURL);
auto accountManager = DependencyManager::get<AccountManager>();
if (accountManager->hasValidAccessToken()) {
request.setRawHeader(ACCESS_TOKEN_AUTHORIZATION_HEADER,

View file

@ -13,8 +13,8 @@
#ifndef hifi_AddressBarDialog_h
#define hifi_AddressBarDialog_h
#include <AccountManager.h>
#include <OffscreenQmlDialog.h>
#include <NetworkingConstants.h>
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<AccountManager>()->getMetaverseServerURL().toString(); }
QString metaverseServerUrl() { return NetworkingConstants::METAVERSE_SERVER_URL.toString(); }
signals:
void backEnabledChanged();

View file

@ -12,8 +12,8 @@
#include "ContextOverlayInterface.h"
#include "Application.h"
#include <AccountManager.h>
#include <EntityTreeRenderer.h>
#include <NetworkingConstants.h>
#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<TabletProxy*>(_tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
// construct the url to the marketplace item
QString url = DependencyManager::get<AccountManager>()->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();

View file

@ -18,6 +18,7 @@
#include <QtNetwork/QNetworkReply>
#include <QUrlQuery>
#include "NetworkingConstants.h"
#include "NetworkAccessManager.h"
#include "DataServerAccountInfo.h"
@ -58,13 +59,6 @@ using UserAgentGetter = std::function<QString()>;
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:
// <hifi repo>\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);

View file

@ -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 <QtCore/QUrl>
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:
// <hifi repo>\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

View file

@ -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<AccountManager>();
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);

View file

@ -17,10 +17,13 @@
#include <AccountManager.h>
#include <NetworkAccessManager.h>
#include <NetworkingConstants.h>
#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<AccountManager>()->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<AccountManager>();
if (accountManager->hasValidAccessToken()) {

View file

@ -10,6 +10,7 @@
//
#include "RequestFilters.h"
#include "NetworkingConstants.h"
#include <QtCore/QDebug>
#include <SettingHandle.h>
@ -19,7 +20,7 @@
namespace {
bool isAuthableHighFidelityURL(const QUrl& url) {
auto metaverseServerURL = DependencyManager::get<AccountManager>()->getMetaverseServerURL();
auto metaverseServerURL = NetworkingConstants::METAVERSE_SERVER_URL;
static const QStringList HF_HOSTS = {
"highfidelity.com", "highfidelity.io",
metaverseServerURL.toString(), "metaverse.highfidelity.io"

View file

@ -14,6 +14,7 @@
#include <QLoggingCategory>
#include <QCommandLineParser>
#include <NetworkLogging.h>
#include <NetworkingConstants.h>
#include <SharedLogging.h>
#include <AddressManager.h>
#include <DependencyManager.h>
@ -105,7 +106,7 @@ ACClientApp::ACClientApp(int argc, char* argv[]) :
auto accountManager = DependencyManager::get<AccountManager>();
accountManager->setIsAgent(true);
accountManager->setAuthURL(accountManager->getMetaverseServerURL());
accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL);
auto nodeList = DependencyManager::get<NodeList>();

View file

@ -17,6 +17,7 @@
#include <QCommandLineParser>
#include <NetworkLogging.h>
#include <NetworkingConstants.h>
#include <SharedLogging.h>
#include <AddressManager.h>
#include <DependencyManager.h>
@ -144,7 +145,7 @@ ATPClientApp::ATPClientApp(int argc, char* argv[]) :
auto accountManager = DependencyManager::get<AccountManager>();
accountManager->setIsAgent(true);
accountManager->setAuthURL(accountManager->getMetaverseServerURL());
accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL);
auto nodeList = DependencyManager::get<NodeList>();