mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 22:22:54 +02:00
gather together the url scheme constants, name them consistently
This commit is contained in:
parent
fdb53b6543
commit
606face7c0
11 changed files with 44 additions and 38 deletions
|
@ -513,12 +513,12 @@ bool isDomainURL(QUrl url) {
|
||||||
if (!url.isValid()) {
|
if (!url.isValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (url.scheme() == HIFI_URL_SCHEME) {
|
if (url.scheme() == URL_SCHEME_HIFI) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (url.scheme() != "file" &&
|
if (url.scheme() != URL_SCHEME_FILE &&
|
||||||
url.scheme() != "http" &&
|
url.scheme() != URL_SCHEME_HTTP &&
|
||||||
url.scheme() != "https") {
|
url.scheme() != URL_SCHEME_HTTPS) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (url.path().endsWith(".json", Qt::CaseInsensitive) ||
|
if (url.path().endsWith(".json", Qt::CaseInsensitive) ||
|
||||||
|
@ -3109,16 +3109,15 @@ bool Application::importFromZIP(const QString& filePath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::isServerlessMode() const {
|
bool Application::isServerlessMode() const {
|
||||||
auto& tree = getEntities()->getTree();
|
auto tree = getEntities()->getTree();
|
||||||
if (tree) {
|
if (tree) {
|
||||||
return tree->isServerlessMode();
|
return tree->isServerlessMode();
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setServerlessDomain(bool serverlessDomain) {
|
void Application::setServerlessDomain(bool serverlessDomain) {
|
||||||
auto& tree = getEntities()->getTree();
|
auto tree = getEntities()->getTree();
|
||||||
if (tree) {
|
if (tree) {
|
||||||
tree->setIsServerlessMode(serverlessDomain);
|
tree->setIsServerlessMode(serverlessDomain);
|
||||||
}
|
}
|
||||||
|
@ -5885,7 +5884,7 @@ void Application::domainURLChanged(QUrl domainURL) {
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
// disable physics until we have enough information about our new location to not cause craziness.
|
// disable physics until we have enough information about our new location to not cause craziness.
|
||||||
resetPhysicsReadyInformation();
|
resetPhysicsReadyInformation();
|
||||||
if (domainURL.scheme() != HIFI_URL_SCHEME) {
|
if (domainURL.scheme() != URL_SCHEME_HIFI) {
|
||||||
loadServerlessDomain(domainURL);
|
loadServerlessDomain(domainURL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6257,7 +6256,7 @@ bool Application::canAcceptURL(const QString& urlString) const {
|
||||||
QUrl url(urlString);
|
QUrl url(urlString);
|
||||||
if (url.query().contains(WEB_VIEW_TAG)) {
|
if (url.query().contains(WEB_VIEW_TAG)) {
|
||||||
return false;
|
return false;
|
||||||
} else if (urlString.startsWith(HIFI_URL_SCHEME)) {
|
} else if (urlString.startsWith(URL_SCHEME_HIFI)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
QHashIterator<QString, AcceptURLMethod> i(_acceptedExtensions);
|
QHashIterator<QString, AcceptURLMethod> i(_acceptedExtensions);
|
||||||
|
|
|
@ -129,7 +129,7 @@ int main(int argc, const char* argv[]) {
|
||||||
if (socket.waitForConnected(LOCAL_SERVER_TIMEOUT_MS)) {
|
if (socket.waitForConnected(LOCAL_SERVER_TIMEOUT_MS)) {
|
||||||
if (parser.isSet(urlOption)) {
|
if (parser.isSet(urlOption)) {
|
||||||
QUrl url = QUrl(parser.value(urlOption));
|
QUrl url = QUrl(parser.value(urlOption));
|
||||||
if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) {
|
if (url.isValid() && url.scheme() == URL_SCHEME_HIFI) {
|
||||||
qDebug() << "Writing URL to local socket";
|
qDebug() << "Writing URL to local socket";
|
||||||
socket.write(url.toString().toUtf8());
|
socket.write(url.toString().toUtf8());
|
||||||
if (!socket.waitForBytesWritten(5000)) {
|
if (!socket.waitForBytesWritten(5000)) {
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
#include "NetworkLogging.h"
|
#include "NetworkLogging.h"
|
||||||
#include "ModelNetworkingLogging.h"
|
#include "ModelNetworkingLogging.h"
|
||||||
|
#include "NetworkingConstants.h"
|
||||||
#include <Trace.h>
|
#include <Trace.h>
|
||||||
#include <StatTracker.h>
|
#include <StatTracker.h>
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ bool AddressManager::isConnected() {
|
||||||
QUrl AddressManager::currentAddress(bool domainOnly) const {
|
QUrl AddressManager::currentAddress(bool domainOnly) const {
|
||||||
QUrl hifiURL = _domainURL;
|
QUrl hifiURL = _domainURL;
|
||||||
|
|
||||||
if (!domainOnly && hifiURL.scheme() == HIFI_URL_SCHEME) {
|
if (!domainOnly && hifiURL.scheme() == URL_SCHEME_HIFI) {
|
||||||
hifiURL.setPath(currentPath());
|
hifiURL.setPath(currentPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ QUrl AddressManager::currentAddress(bool domainOnly) const {
|
||||||
|
|
||||||
QUrl AddressManager::currentFacingAddress() const {
|
QUrl AddressManager::currentFacingAddress() const {
|
||||||
auto hifiURL = currentAddress();
|
auto hifiURL = currentAddress();
|
||||||
if (hifiURL.scheme() == HIFI_URL_SCHEME) {
|
if (hifiURL.scheme() == URL_SCHEME_HIFI) {
|
||||||
hifiURL.setPath(currentFacingPath());
|
hifiURL.setPath(currentFacingPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ QUrl AddressManager::currentShareableAddress(bool domainOnly) const {
|
||||||
// if we have a shareable place name use that instead of whatever the current host is
|
// if we have a shareable place name use that instead of whatever the current host is
|
||||||
QUrl hifiURL;
|
QUrl hifiURL;
|
||||||
|
|
||||||
hifiURL.setScheme(HIFI_URL_SCHEME);
|
hifiURL.setScheme(URL_SCHEME_HIFI);
|
||||||
hifiURL.setHost(_shareablePlaceName);
|
hifiURL.setHost(_shareablePlaceName);
|
||||||
|
|
||||||
if (!domainOnly) {
|
if (!domainOnly) {
|
||||||
|
@ -88,7 +88,7 @@ QUrl AddressManager::currentShareableAddress(bool domainOnly) const {
|
||||||
|
|
||||||
QUrl AddressManager::currentFacingShareableAddress() const {
|
QUrl AddressManager::currentFacingShareableAddress() const {
|
||||||
auto hifiURL = currentShareableAddress();
|
auto hifiURL = currentShareableAddress();
|
||||||
if (hifiURL.scheme() == HIFI_URL_SCHEME) {
|
if (hifiURL.scheme() == URL_SCHEME_HIFI) {
|
||||||
hifiURL.setPath(currentFacingPath());
|
hifiURL.setPath(currentFacingPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,10 @@ void AddressManager::goForward() {
|
||||||
void AddressManager::storeCurrentAddress() {
|
void AddressManager::storeCurrentAddress() {
|
||||||
auto url = currentAddress();
|
auto url = currentAddress();
|
||||||
|
|
||||||
if (url.scheme() == "file" || url.scheme() == "http" || url.scheme() == "https" || !url.host().isEmpty()) {
|
if (url.scheme() == URL_SCHEME_FILE ||
|
||||||
|
url.scheme() == URL_SCHEME_HTTP ||
|
||||||
|
url.scheme() == URL_SCHEME_HTTPS ||
|
||||||
|
!url.host().isEmpty()) {
|
||||||
currentAddressHandle.set(url);
|
currentAddressHandle.set(url);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(networking) << "Ignoring attempt to save current address with an empty host" << url;
|
qCWarning(networking) << "Ignoring attempt to save current address with an empty host" << url;
|
||||||
|
@ -205,7 +208,7 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
||||||
static QString URL_TYPE_DOMAIN_ID = "domain_id";
|
static QString URL_TYPE_DOMAIN_ID = "domain_id";
|
||||||
static QString URL_TYPE_PLACE = "place";
|
static QString URL_TYPE_PLACE = "place";
|
||||||
static QString URL_TYPE_NETWORK_ADDRESS = "network_address";
|
static QString URL_TYPE_NETWORK_ADDRESS = "network_address";
|
||||||
if (lookupUrl.scheme() == HIFI_URL_SCHEME) {
|
if (lookupUrl.scheme() == URL_SCHEME_HIFI) {
|
||||||
|
|
||||||
qCDebug(networking) << "Trying to go to URL" << lookupUrl.toString();
|
qCDebug(networking) << "Trying to go to URL" << lookupUrl.toString();
|
||||||
|
|
||||||
|
@ -287,7 +290,9 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
||||||
emit lookupResultsFinished();
|
emit lookupResultsFinished();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (lookupUrl.scheme() == "http" || lookupUrl.scheme() == "https" || lookupUrl.scheme() == "file") {
|
} else if (lookupUrl.scheme() == URL_SCHEME_HTTP ||
|
||||||
|
lookupUrl.scheme() == URL_SCHEME_HTTPS ||
|
||||||
|
lookupUrl.scheme() == URL_SCHEME_FILE) {
|
||||||
_previousLookup.clear();
|
_previousLookup.clear();
|
||||||
QUrl domainUrl = PathUtils::expandToLocalDataAbsolutePath(lookupUrl);
|
QUrl domainUrl = PathUtils::expandToLocalDataAbsolutePath(lookupUrl);
|
||||||
emit setServerlessDomain(true);
|
emit setServerlessDomain(true);
|
||||||
|
@ -321,7 +326,7 @@ void AddressManager::handleLookupString(const QString& lookupString, bool fromSu
|
||||||
|
|
||||||
if (!lookupString.startsWith('/')) {
|
if (!lookupString.startsWith('/')) {
|
||||||
// sometimes we need to handle lookupStrings like hifi:/somewhere
|
// sometimes we need to handle lookupStrings like hifi:/somewhere
|
||||||
const QRegExp HIFI_SCHEME_REGEX = QRegExp(HIFI_URL_SCHEME + ":\\/{1,2}", Qt::CaseInsensitive);
|
const QRegExp HIFI_SCHEME_REGEX = QRegExp(URL_SCHEME_HIFI + ":\\/{1,2}", Qt::CaseInsensitive);
|
||||||
sanitizedString = sanitizedString.remove(HIFI_SCHEME_REGEX);
|
sanitizedString = sanitizedString.remove(HIFI_SCHEME_REGEX);
|
||||||
|
|
||||||
lookupURL = QUrl(sanitizedString);
|
lookupURL = QUrl(sanitizedString);
|
||||||
|
@ -408,7 +413,7 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
||||||
qCDebug(networking) << "Possible domain change required to connect to" << domainHostname
|
qCDebug(networking) << "Possible domain change required to connect to" << domainHostname
|
||||||
<< "on" << domainPort;
|
<< "on" << domainPort;
|
||||||
QUrl domainURL;
|
QUrl domainURL;
|
||||||
domainURL.setScheme(HIFI_URL_SCHEME);
|
domainURL.setScheme(URL_SCHEME_HIFI);
|
||||||
domainURL.setHost(domainHostname);
|
domainURL.setHost(domainHostname);
|
||||||
domainURL.setPort(domainPort);
|
domainURL.setPort(domainPort);
|
||||||
emit possibleDomainChangeRequired(domainURL, domainID);
|
emit possibleDomainChangeRequired(domainURL, domainID);
|
||||||
|
@ -579,7 +584,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
|
||||||
|
|
||||||
emit lookupResultsFinished();
|
emit lookupResultsFinished();
|
||||||
QUrl domainURL;
|
QUrl domainURL;
|
||||||
domainURL.setScheme(HIFI_URL_SCHEME);
|
domainURL.setScheme(URL_SCHEME_HIFI);
|
||||||
domainURL.setHost(domainIPString);
|
domainURL.setHost(domainIPString);
|
||||||
domainURL.setPort(domainPort);
|
domainURL.setPort(domainPort);
|
||||||
hostChanged = setDomainInfo(domainURL, trigger);
|
hostChanged = setDomainInfo(domainURL, trigger);
|
||||||
|
@ -600,7 +605,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
|
||||||
|
|
||||||
emit lookupResultsFinished();
|
emit lookupResultsFinished();
|
||||||
QUrl domainURL;
|
QUrl domainURL;
|
||||||
domainURL.setScheme(HIFI_URL_SCHEME);
|
domainURL.setScheme(URL_SCHEME_HIFI);
|
||||||
domainURL.setHost(domainHostname);
|
domainURL.setHost(domainHostname);
|
||||||
domainURL.setPort(domainPort);
|
domainURL.setPort(domainPort);
|
||||||
hostChanged = setDomainInfo(domainURL, trigger);
|
hostChanged = setDomainInfo(domainURL, trigger);
|
||||||
|
@ -732,7 +737,7 @@ bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16
|
||||||
|
|
||||||
bool emitHostChanged = host != _domainURL.host();
|
bool emitHostChanged = host != _domainURL.host();
|
||||||
_domainURL = QUrl();
|
_domainURL = QUrl();
|
||||||
_domainURL.setScheme(HIFI_URL_SCHEME);
|
_domainURL.setScheme(URL_SCHEME_HIFI);
|
||||||
_domainURL.setHost(host);
|
_domainURL.setHost(host);
|
||||||
_domainURL.setPort(port);
|
_domainURL.setPort(port);
|
||||||
|
|
||||||
|
@ -772,7 +777,7 @@ bool AddressManager::setDomainInfo(const QUrl& domainURL, LookupTrigger trigger)
|
||||||
// clear any current place information
|
// clear any current place information
|
||||||
_rootPlaceID = QUuid();
|
_rootPlaceID = QUuid();
|
||||||
|
|
||||||
if (_domainURL.scheme() == HIFI_URL_SCHEME) {
|
if (_domainURL.scheme() == URL_SCHEME_HIFI) {
|
||||||
qCDebug(networking) << "Possible domain change required to connect to domain at" << hostname << "on" << port;
|
qCDebug(networking) << "Possible domain change required to connect to domain at" << hostname << "on" << port;
|
||||||
} else {
|
} else {
|
||||||
qCDebug(networking) << "Possible domain change required to serverless domain: " << domainURL.toString();
|
qCDebug(networking) << "Possible domain change required to serverless domain: " << domainURL.toString();
|
||||||
|
|
|
@ -154,7 +154,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
const QString& getProtocol() { return HIFI_URL_SCHEME; };
|
const QString& getProtocol() { return URL_SCHEME_HIFI; };
|
||||||
|
|
||||||
QUrl currentAddress(bool domainOnly = false) const;
|
QUrl currentAddress(bool domainOnly = false) const;
|
||||||
QUrl currentFacingAddress() const;
|
QUrl currentFacingAddress() const;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "NetworkAccessManager.h"
|
#include "NetworkAccessManager.h"
|
||||||
#include "NetworkLogging.h"
|
#include "NetworkLogging.h"
|
||||||
|
#include "NetworkingConstants.h"
|
||||||
|
|
||||||
#include "ResourceManager.h"
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) {
|
||||||
|
|
||||||
_domainURL = domainURL;
|
_domainURL = domainURL;
|
||||||
|
|
||||||
if (domainURL.scheme() != HIFI_URL_SCHEME) {
|
if (domainURL.scheme() != URL_SCHEME_HIFI) {
|
||||||
setIsConnected(true);
|
setIsConnected(true);
|
||||||
} else if (hostname != _domainURL.host()) {
|
} else if (hostname != _domainURL.host()) {
|
||||||
qCDebug(networking) << "Updated domain hostname to" << hostname;
|
qCDebug(networking) << "Updated domain hostname to" << hostname;
|
||||||
|
@ -233,7 +233,7 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
|
||||||
void DomainHandler::activateICELocalSocket() {
|
void DomainHandler::activateICELocalSocket() {
|
||||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
||||||
_sockAddr = _icePeer.getLocalSocket();
|
_sockAddr = _icePeer.getLocalSocket();
|
||||||
_domainURL.setScheme(HIFI_URL_SCHEME);
|
_domainURL.setScheme(URL_SCHEME_HIFI);
|
||||||
_domainURL.setHost(_sockAddr.getAddress().toString());
|
_domainURL.setHost(_sockAddr.getAddress().toString());
|
||||||
emit completedSocketDiscovery();
|
emit completedSocketDiscovery();
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ void DomainHandler::activateICELocalSocket() {
|
||||||
void DomainHandler::activateICEPublicSocket() {
|
void DomainHandler::activateICEPublicSocket() {
|
||||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
||||||
_sockAddr = _icePeer.getPublicSocket();
|
_sockAddr = _icePeer.getPublicSocket();
|
||||||
_domainURL.setScheme(HIFI_URL_SCHEME);
|
_domainURL.setScheme(URL_SCHEME_HIFI);
|
||||||
_domainURL.setHost(_sockAddr.getAddress().toString());
|
_domainURL.setHost(_sockAddr.getAddress().toString());
|
||||||
emit completedSocketDiscovery();
|
emit completedSocketDiscovery();
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ void DomainHandler::setIsConnected(bool isConnected) {
|
||||||
if (_isConnected) {
|
if (_isConnected) {
|
||||||
emit connectedToDomain(_domainURL);
|
emit connectedToDomain(_domainURL);
|
||||||
|
|
||||||
if (_domainURL.scheme() == HIFI_URL_SCHEME && !_domainURL.host().isEmpty()) {
|
if (_domainURL.scheme() == URL_SCHEME_HIFI && !_domainURL.host().isEmpty()) {
|
||||||
// we've connected to new domain - time to ask it for global settings
|
// we've connected to new domain - time to ask it for global settings
|
||||||
requestDomainSettings();
|
requestDomainSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
|
|
||||||
bool isConnected() const { return _isConnected; }
|
bool isConnected() const { return _isConnected; }
|
||||||
void setIsConnected(bool isConnected);
|
void setIsConnected(bool isConnected);
|
||||||
bool isServerless() const { return _domainURL.scheme() != HIFI_URL_SCHEME; }
|
bool isServerless() const { return _domainURL.scheme() != URL_SCHEME_HIFI; }
|
||||||
|
|
||||||
bool hasSettings() const { return !_settingsObject.isEmpty(); }
|
bool hasSettings() const { return !_settingsObject.isEmpty(); }
|
||||||
void requestDomainSettings();
|
void requestDomainSettings();
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include "NetworkLogging.h"
|
#include "NetworkLogging.h"
|
||||||
#include "ResourceManager.h"
|
#include "ResourceManager.h"
|
||||||
|
#include "NetworkingConstants.h"
|
||||||
|
|
||||||
void FileResourceRequest::doSend() {
|
void FileResourceRequest::doSend() {
|
||||||
auto statTracker = DependencyManager::get<StatTracker>();
|
auto statTracker = DependencyManager::get<StatTracker>();
|
||||||
|
|
|
@ -30,6 +30,12 @@ namespace NetworkingConstants {
|
||||||
QUrl METAVERSE_SERVER_URL();
|
QUrl METAVERSE_SERVER_URL();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString HIFI_URL_SCHEME = "hifi";
|
const QString URL_SCHEME_HIFI = "hifi";
|
||||||
|
const QString URL_SCHEME_QRC = "qrc";
|
||||||
|
const QString URL_SCHEME_FILE = "file";
|
||||||
|
const QString URL_SCHEME_HTTP = "http";
|
||||||
|
const QString URL_SCHEME_HTTPS = "https";
|
||||||
|
const QString URL_SCHEME_FTP = "ftp";
|
||||||
|
const QString URL_SCHEME_ATP = "atp";
|
||||||
|
|
||||||
#endif // hifi_NetworkingConstants_h
|
#endif // hifi_NetworkingConstants_h
|
||||||
|
|
|
@ -22,13 +22,6 @@
|
||||||
|
|
||||||
#include "ResourceRequest.h"
|
#include "ResourceRequest.h"
|
||||||
|
|
||||||
const QString URL_SCHEME_QRC = "qrc";
|
|
||||||
const QString URL_SCHEME_FILE = "file";
|
|
||||||
const QString URL_SCHEME_HTTP = "http";
|
|
||||||
const QString URL_SCHEME_HTTPS = "https";
|
|
||||||
const QString URL_SCHEME_FTP = "ftp";
|
|
||||||
const QString URL_SCHEME_ATP = "atp";
|
|
||||||
|
|
||||||
class ResourceManager: public QObject, public Dependency {
|
class ResourceManager: public QObject, public Dependency {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
|
|
Loading…
Reference in a new issue