mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +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()) {
|
||||
return false;
|
||||
}
|
||||
if (url.scheme() == HIFI_URL_SCHEME) {
|
||||
if (url.scheme() == URL_SCHEME_HIFI) {
|
||||
return true;
|
||||
}
|
||||
if (url.scheme() != "file" &&
|
||||
url.scheme() != "http" &&
|
||||
url.scheme() != "https") {
|
||||
if (url.scheme() != URL_SCHEME_FILE &&
|
||||
url.scheme() != URL_SCHEME_HTTP &&
|
||||
url.scheme() != URL_SCHEME_HTTPS) {
|
||||
return false;
|
||||
}
|
||||
if (url.path().endsWith(".json", Qt::CaseInsensitive) ||
|
||||
|
@ -3109,16 +3109,15 @@ bool Application::importFromZIP(const QString& filePath) {
|
|||
}
|
||||
|
||||
bool Application::isServerlessMode() const {
|
||||
auto& tree = getEntities()->getTree();
|
||||
auto tree = getEntities()->getTree();
|
||||
if (tree) {
|
||||
return tree->isServerlessMode();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Application::setServerlessDomain(bool serverlessDomain) {
|
||||
auto& tree = getEntities()->getTree();
|
||||
auto tree = getEntities()->getTree();
|
||||
if (tree) {
|
||||
tree->setIsServerlessMode(serverlessDomain);
|
||||
}
|
||||
|
@ -5885,7 +5884,7 @@ void Application::domainURLChanged(QUrl domainURL) {
|
|||
updateWindowTitle();
|
||||
// disable physics until we have enough information about our new location to not cause craziness.
|
||||
resetPhysicsReadyInformation();
|
||||
if (domainURL.scheme() != HIFI_URL_SCHEME) {
|
||||
if (domainURL.scheme() != URL_SCHEME_HIFI) {
|
||||
loadServerlessDomain(domainURL);
|
||||
}
|
||||
}
|
||||
|
@ -6257,7 +6256,7 @@ bool Application::canAcceptURL(const QString& urlString) const {
|
|||
QUrl url(urlString);
|
||||
if (url.query().contains(WEB_VIEW_TAG)) {
|
||||
return false;
|
||||
} else if (urlString.startsWith(HIFI_URL_SCHEME)) {
|
||||
} else if (urlString.startsWith(URL_SCHEME_HIFI)) {
|
||||
return true;
|
||||
}
|
||||
QHashIterator<QString, AcceptURLMethod> i(_acceptedExtensions);
|
||||
|
|
|
@ -129,7 +129,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() == HIFI_URL_SCHEME) {
|
||||
if (url.isValid() && url.scheme() == URL_SCHEME_HIFI) {
|
||||
qDebug() << "Writing URL to local socket";
|
||||
socket.write(url.toString().toUtf8());
|
||||
if (!socket.waitForBytesWritten(5000)) {
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
#include "NetworkLogging.h"
|
||||
#include "ModelNetworkingLogging.h"
|
||||
#include "NetworkingConstants.h"
|
||||
#include <Trace.h>
|
||||
#include <StatTracker.h>
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ bool AddressManager::isConnected() {
|
|||
QUrl AddressManager::currentAddress(bool domainOnly) const {
|
||||
QUrl hifiURL = _domainURL;
|
||||
|
||||
if (!domainOnly && hifiURL.scheme() == HIFI_URL_SCHEME) {
|
||||
if (!domainOnly && hifiURL.scheme() == URL_SCHEME_HIFI) {
|
||||
hifiURL.setPath(currentPath());
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ QUrl AddressManager::currentAddress(bool domainOnly) const {
|
|||
|
||||
QUrl AddressManager::currentFacingAddress() const {
|
||||
auto hifiURL = currentAddress();
|
||||
if (hifiURL.scheme() == HIFI_URL_SCHEME) {
|
||||
if (hifiURL.scheme() == URL_SCHEME_HIFI) {
|
||||
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
|
||||
QUrl hifiURL;
|
||||
|
||||
hifiURL.setScheme(HIFI_URL_SCHEME);
|
||||
hifiURL.setScheme(URL_SCHEME_HIFI);
|
||||
hifiURL.setHost(_shareablePlaceName);
|
||||
|
||||
if (!domainOnly) {
|
||||
|
@ -88,7 +88,7 @@ QUrl AddressManager::currentShareableAddress(bool domainOnly) const {
|
|||
|
||||
QUrl AddressManager::currentFacingShareableAddress() const {
|
||||
auto hifiURL = currentShareableAddress();
|
||||
if (hifiURL.scheme() == HIFI_URL_SCHEME) {
|
||||
if (hifiURL.scheme() == URL_SCHEME_HIFI) {
|
||||
hifiURL.setPath(currentFacingPath());
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,10 @@ void AddressManager::goForward() {
|
|||
void AddressManager::storeCurrentAddress() {
|
||||
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);
|
||||
} else {
|
||||
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_PLACE = "place";
|
||||
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();
|
||||
|
||||
|
@ -287,7 +290,9 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
|||
emit lookupResultsFinished();
|
||||
|
||||
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();
|
||||
QUrl domainUrl = PathUtils::expandToLocalDataAbsolutePath(lookupUrl);
|
||||
emit setServerlessDomain(true);
|
||||
|
@ -321,7 +326,7 @@ void AddressManager::handleLookupString(const QString& lookupString, bool fromSu
|
|||
|
||||
if (!lookupString.startsWith('/')) {
|
||||
// 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);
|
||||
|
||||
lookupURL = QUrl(sanitizedString);
|
||||
|
@ -408,7 +413,7 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
|||
qCDebug(networking) << "Possible domain change required to connect to" << domainHostname
|
||||
<< "on" << domainPort;
|
||||
QUrl domainURL;
|
||||
domainURL.setScheme(HIFI_URL_SCHEME);
|
||||
domainURL.setScheme(URL_SCHEME_HIFI);
|
||||
domainURL.setHost(domainHostname);
|
||||
domainURL.setPort(domainPort);
|
||||
emit possibleDomainChangeRequired(domainURL, domainID);
|
||||
|
@ -579,7 +584,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
|
|||
|
||||
emit lookupResultsFinished();
|
||||
QUrl domainURL;
|
||||
domainURL.setScheme(HIFI_URL_SCHEME);
|
||||
domainURL.setScheme(URL_SCHEME_HIFI);
|
||||
domainURL.setHost(domainIPString);
|
||||
domainURL.setPort(domainPort);
|
||||
hostChanged = setDomainInfo(domainURL, trigger);
|
||||
|
@ -600,7 +605,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
|
|||
|
||||
emit lookupResultsFinished();
|
||||
QUrl domainURL;
|
||||
domainURL.setScheme(HIFI_URL_SCHEME);
|
||||
domainURL.setScheme(URL_SCHEME_HIFI);
|
||||
domainURL.setHost(domainHostname);
|
||||
domainURL.setPort(domainPort);
|
||||
hostChanged = setDomainInfo(domainURL, trigger);
|
||||
|
@ -732,7 +737,7 @@ bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16
|
|||
|
||||
bool emitHostChanged = host != _domainURL.host();
|
||||
_domainURL = QUrl();
|
||||
_domainURL.setScheme(HIFI_URL_SCHEME);
|
||||
_domainURL.setScheme(URL_SCHEME_HIFI);
|
||||
_domainURL.setHost(host);
|
||||
_domainURL.setPort(port);
|
||||
|
||||
|
@ -772,7 +777,7 @@ bool AddressManager::setDomainInfo(const QUrl& domainURL, LookupTrigger trigger)
|
|||
// clear any current place information
|
||||
_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;
|
||||
} else {
|
||||
qCDebug(networking) << "Possible domain change required to serverless domain: " << domainURL.toString();
|
||||
|
|
|
@ -154,7 +154,7 @@ public:
|
|||
};
|
||||
|
||||
bool isConnected();
|
||||
const QString& getProtocol() { return HIFI_URL_SCHEME; };
|
||||
const QString& getProtocol() { return URL_SCHEME_HIFI; };
|
||||
|
||||
QUrl currentAddress(bool domainOnly = false) const;
|
||||
QUrl currentFacingAddress() const;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "NetworkAccessManager.h"
|
||||
#include "NetworkLogging.h"
|
||||
#include "NetworkingConstants.h"
|
||||
|
||||
#include "ResourceManager.h"
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) {
|
|||
|
||||
_domainURL = domainURL;
|
||||
|
||||
if (domainURL.scheme() != HIFI_URL_SCHEME) {
|
||||
if (domainURL.scheme() != URL_SCHEME_HIFI) {
|
||||
setIsConnected(true);
|
||||
} else if (hostname != _domainURL.host()) {
|
||||
qCDebug(networking) << "Updated domain hostname to" << hostname;
|
||||
|
@ -233,7 +233,7 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
|
|||
void DomainHandler::activateICELocalSocket() {
|
||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
||||
_sockAddr = _icePeer.getLocalSocket();
|
||||
_domainURL.setScheme(HIFI_URL_SCHEME);
|
||||
_domainURL.setScheme(URL_SCHEME_HIFI);
|
||||
_domainURL.setHost(_sockAddr.getAddress().toString());
|
||||
emit completedSocketDiscovery();
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ void DomainHandler::activateICELocalSocket() {
|
|||
void DomainHandler::activateICEPublicSocket() {
|
||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
|
||||
_sockAddr = _icePeer.getPublicSocket();
|
||||
_domainURL.setScheme(HIFI_URL_SCHEME);
|
||||
_domainURL.setScheme(URL_SCHEME_HIFI);
|
||||
_domainURL.setHost(_sockAddr.getAddress().toString());
|
||||
emit completedSocketDiscovery();
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ void DomainHandler::setIsConnected(bool isConnected) {
|
|||
if (_isConnected) {
|
||||
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
|
||||
requestDomainSettings();
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
|
||||
bool isConnected() const { return _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(); }
|
||||
void requestDomainSettings();
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "NetworkLogging.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "NetworkingConstants.h"
|
||||
|
||||
void FileResourceRequest::doSend() {
|
||||
auto statTracker = DependencyManager::get<StatTracker>();
|
||||
|
|
|
@ -30,6 +30,12 @@ namespace NetworkingConstants {
|
|||
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
|
||||
|
|
|
@ -22,13 +22,6 @@
|
|||
|
||||
#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 {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
|
|
Loading…
Reference in a new issue