mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 22:22:54 +02:00
Merge pull request #5066 from venkatn93/master
Title bar shows domain IDs upon teleport
This commit is contained in:
commit
a63811a491
3 changed files with 67 additions and 22 deletions
|
@ -474,7 +474,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
addressManager->setPositionGetter(getPositionForPath);
|
addressManager->setPositionGetter(getPositionForPath);
|
||||||
addressManager->setOrientationGetter(getOrientationForPath);
|
addressManager->setOrientationGetter(getOrientationForPath);
|
||||||
|
|
||||||
connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle);
|
connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
|
||||||
connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
|
connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -3650,7 +3650,7 @@ void Application::updateWindowTitle(){
|
||||||
|
|
||||||
QString connectionStatus = nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED) ";
|
QString connectionStatus = nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED) ";
|
||||||
QString username = AccountManager::getInstance().getAccountInfo().getUsername();
|
QString username = AccountManager::getInstance().getAccountInfo().getUsername();
|
||||||
QString currentPlaceName = DependencyManager::get<AddressManager>()->getRootPlaceName();
|
QString currentPlaceName = DependencyManager::get<AddressManager>()->getHost();
|
||||||
|
|
||||||
if (currentPlaceName.isEmpty()) {
|
if (currentPlaceName.isEmpty()) {
|
||||||
currentPlaceName = nodeList->getDomainHandler().getHostname();
|
currentPlaceName = nodeList->getDomainHandler().getHostname();
|
||||||
|
|
|
@ -30,7 +30,7 @@ const QString SETTINGS_CURRENT_ADDRESS_KEY = "address";
|
||||||
Setting::Handle<QUrl> currentAddressHandle(QStringList() << ADDRESS_MANAGER_SETTINGS_GROUP << "address", DEFAULT_HIFI_ADDRESS);
|
Setting::Handle<QUrl> currentAddressHandle(QStringList() << ADDRESS_MANAGER_SETTINGS_GROUP << "address", DEFAULT_HIFI_ADDRESS);
|
||||||
|
|
||||||
AddressManager::AddressManager() :
|
AddressManager::AddressManager() :
|
||||||
_rootPlaceName(),
|
_host(),
|
||||||
_rootPlaceID(),
|
_rootPlaceID(),
|
||||||
_positionGetter(NULL),
|
_positionGetter(NULL),
|
||||||
_orientationGetter(NULL)
|
_orientationGetter(NULL)
|
||||||
|
@ -45,7 +45,7 @@ const QUrl AddressManager::currentAddress() const {
|
||||||
QUrl hifiURL;
|
QUrl hifiURL;
|
||||||
|
|
||||||
hifiURL.setScheme(HIFI_URL_SCHEME);
|
hifiURL.setScheme(HIFI_URL_SCHEME);
|
||||||
hifiURL.setHost(_rootPlaceName);
|
hifiURL.setHost(_host);
|
||||||
hifiURL.setPath(currentPath());
|
hifiURL.setPath(currentPath());
|
||||||
|
|
||||||
return hifiURL;
|
return hifiURL;
|
||||||
|
@ -123,6 +123,10 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl) {
|
||||||
+ (lookupUrl.port() == -1 ? "" : ":" + QString::number(lookupUrl.port())))) {
|
+ (lookupUrl.port() == -1 ? "" : ":" + QString::number(lookupUrl.port())))) {
|
||||||
// we may have a path that defines a relative viewpoint - if so we should jump to that now
|
// we may have a path that defines a relative viewpoint - if so we should jump to that now
|
||||||
handlePath(lookupUrl.path());
|
handlePath(lookupUrl.path());
|
||||||
|
} else if (handleDomainID(lookupUrl.host())){
|
||||||
|
// no place name - this is probably a domain ID
|
||||||
|
// try to look up the domain ID on the metaverse API
|
||||||
|
attemptDomainIDLookup(lookupUrl.host(), lookupUrl.path());
|
||||||
} else {
|
} else {
|
||||||
// wasn't an address - lookup the place name
|
// 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
|
// we may have a path that defines a relative viewpoint - pass that through the lookup so we can go to it after
|
||||||
|
@ -161,11 +165,18 @@ void AddressManager::handleLookupString(const QString& lookupString) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString DATA_OBJECT_DOMAIN_KEY = "domain";
|
||||||
|
|
||||||
|
|
||||||
void AddressManager::handleAPIResponse(QNetworkReply& requestReply) {
|
void AddressManager::handleAPIResponse(QNetworkReply& requestReply) {
|
||||||
QJsonObject responseObject = QJsonDocument::fromJson(requestReply.readAll()).object();
|
QJsonObject responseObject = QJsonDocument::fromJson(requestReply.readAll()).object();
|
||||||
QJsonObject dataObject = responseObject["data"].toObject();
|
QJsonObject dataObject = responseObject["data"].toObject();
|
||||||
|
|
||||||
|
if (!dataObject.isEmpty()) {
|
||||||
goToAddressFromObject(dataObject.toVariantMap(), requestReply);
|
goToAddressFromObject(dataObject.toVariantMap(), requestReply);
|
||||||
|
} else if (responseObject.contains(DATA_OBJECT_DOMAIN_KEY)) {
|
||||||
|
goToAddressFromObject(responseObject.toVariantMap(), requestReply);
|
||||||
|
}
|
||||||
|
|
||||||
emit lookupResultsFinished();
|
emit lookupResultsFinished();
|
||||||
}
|
}
|
||||||
|
@ -180,6 +191,8 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
||||||
QVariantMap locationMap;
|
QVariantMap locationMap;
|
||||||
if (dataObject.contains(DATA_OBJECT_PLACE_KEY)) {
|
if (dataObject.contains(DATA_OBJECT_PLACE_KEY)) {
|
||||||
locationMap = dataObject[DATA_OBJECT_PLACE_KEY].toMap();
|
locationMap = dataObject[DATA_OBJECT_PLACE_KEY].toMap();
|
||||||
|
} else if (dataObject.contains(DATA_OBJECT_DOMAIN_KEY)) {
|
||||||
|
locationMap = dataObject;
|
||||||
} else {
|
} else {
|
||||||
locationMap = dataObject[DATA_OBJECT_USER_LOCATION_KEY].toMap();
|
locationMap = dataObject[DATA_OBJECT_USER_LOCATION_KEY].toMap();
|
||||||
}
|
}
|
||||||
|
@ -206,6 +219,10 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
||||||
|
|
||||||
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::HandleAddress);
|
DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::HandleAddress);
|
||||||
|
|
||||||
|
const QString DOMAIN_ID_KEY = "id";
|
||||||
|
QString domainIDString = domainObject[DOMAIN_ID_KEY].toString();
|
||||||
|
QUuid domainID(domainIDString);
|
||||||
|
|
||||||
if (domainObject.contains(DOMAIN_NETWORK_ADDRESS_KEY)) {
|
if (domainObject.contains(DOMAIN_NETWORK_ADDRESS_KEY)) {
|
||||||
QString domainHostname = domainObject[DOMAIN_NETWORK_ADDRESS_KEY].toString();
|
QString domainHostname = domainObject[DOMAIN_NETWORK_ADDRESS_KEY].toString();
|
||||||
|
|
||||||
|
@ -219,10 +236,6 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
||||||
} else {
|
} else {
|
||||||
QString iceServerAddress = domainObject[DOMAIN_ICE_SERVER_ADDRESS_KEY].toString();
|
QString iceServerAddress = domainObject[DOMAIN_ICE_SERVER_ADDRESS_KEY].toString();
|
||||||
|
|
||||||
const QString DOMAIN_ID_KEY = "id";
|
|
||||||
QString domainIDString = domainObject[DOMAIN_ID_KEY].toString();
|
|
||||||
QUuid domainID(domainIDString);
|
|
||||||
|
|
||||||
qCDebug(networking) << "Possible domain change required to connect to domain with ID" << domainID
|
qCDebug(networking) << "Possible domain change required to connect to domain with ID" << domainID
|
||||||
<< "via ice-server at" << iceServerAddress;
|
<< "via ice-server at" << iceServerAddress;
|
||||||
|
|
||||||
|
@ -235,8 +248,12 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
|
||||||
|
|
||||||
// set our current root place name to the name that came back
|
// set our current root place name to the name that came back
|
||||||
const QString PLACE_NAME_KEY = "name";
|
const QString PLACE_NAME_KEY = "name";
|
||||||
QString newRootPlaceName = rootMap[PLACE_NAME_KEY].toString();
|
QString placeName = rootMap[PLACE_NAME_KEY].toString();
|
||||||
setRootPlaceName(newRootPlaceName);
|
if (!placeName.isEmpty()) {
|
||||||
|
setHost(placeName);
|
||||||
|
} else {
|
||||||
|
setHost(domainIDString);
|
||||||
|
}
|
||||||
|
|
||||||
// check if we had a path to override the path returned
|
// check if we had a path to override the path returned
|
||||||
QString overridePath = reply.property(OVERRIDE_PATH_KEY).toString();
|
QString overridePath = reply.property(OVERRIDE_PATH_KEY).toString();
|
||||||
|
@ -304,6 +321,24 @@ void AddressManager::attemptPlaceNameLookup(const QString& lookupString, const Q
|
||||||
QByteArray(), NULL, requestParams);
|
QByteArray(), NULL, requestParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString GET_DOMAIN_ID = "/api/v1/domains/%1";
|
||||||
|
|
||||||
|
void AddressManager::attemptDomainIDLookup(const QString& lookupString, const QString& overridePath) {
|
||||||
|
// assume this is a domain ID and see if we can get any info on it
|
||||||
|
QString domainID = QUrl::toPercentEncoding(lookupString);
|
||||||
|
|
||||||
|
QVariantMap requestParams;
|
||||||
|
if (!overridePath.isEmpty()) {
|
||||||
|
requestParams.insert(OVERRIDE_PATH_KEY, overridePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountManager::getInstance().sendRequest(GET_DOMAIN_ID.arg(domainID),
|
||||||
|
AccountManagerAuth::None,
|
||||||
|
QNetworkAccessManager::GetOperation,
|
||||||
|
apiCallbackParameters(),
|
||||||
|
QByteArray(), NULL, requestParams);
|
||||||
|
}
|
||||||
|
|
||||||
bool AddressManager::handleNetworkAddress(const QString& lookupString) {
|
bool AddressManager::handleNetworkAddress(const QString& lookupString) {
|
||||||
const QString IP_ADDRESS_REGEX_STRING = "^((?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}"
|
const QString IP_ADDRESS_REGEX_STRING = "^((?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}"
|
||||||
"(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(?::(\\d{1,5}))?$";
|
"(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(?::(\\d{1,5}))?$";
|
||||||
|
@ -347,6 +382,14 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AddressManager::handleDomainID(const QString& host) {
|
||||||
|
const QString UUID_REGEX_STRING = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
||||||
|
|
||||||
|
QRegExp domainIDRegex(UUID_REGEX_STRING, Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
return (domainIDRegex.indexIn(host) != -1);
|
||||||
|
}
|
||||||
|
|
||||||
void AddressManager::handlePath(const QString& path) {
|
void AddressManager::handlePath(const QString& path) {
|
||||||
if (!handleViewpoint(path)) {
|
if (!handleViewpoint(path)) {
|
||||||
qCDebug(networking) << "User entered path could not be handled as a viewpoint - " << path <<
|
qCDebug(networking) << "User entered path could not be handled as a viewpoint - " << path <<
|
||||||
|
@ -422,16 +465,16 @@ bool AddressManager::handleUsername(const QString& lookupString) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressManager::setRootPlaceName(const QString& rootPlaceName) {
|
void AddressManager::setHost(const QString& host) {
|
||||||
if (rootPlaceName != _rootPlaceName) {
|
if (host != _host) {
|
||||||
_rootPlaceName = rootPlaceName;
|
_host = host;
|
||||||
emit rootPlaceNameChanged(_rootPlaceName);
|
emit hostChanged(_host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AddressManager::setDomainInfo(const QString& hostname, quint16 port) {
|
void AddressManager::setDomainInfo(const QString& hostname, quint16 port) {
|
||||||
_rootPlaceName = hostname;
|
_host = hostname;
|
||||||
_rootPlaceID = QUuid();
|
_rootPlaceID = QUuid();
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -35,7 +35,7 @@ class AddressManager : public QObject, public Dependency {
|
||||||
Q_PROPERTY(bool isConnected READ isConnected)
|
Q_PROPERTY(bool isConnected READ isConnected)
|
||||||
Q_PROPERTY(QUrl href READ currentAddress)
|
Q_PROPERTY(QUrl href READ currentAddress)
|
||||||
Q_PROPERTY(QString protocol READ getProtocol)
|
Q_PROPERTY(QString protocol READ getProtocol)
|
||||||
Q_PROPERTY(QString hostname READ getRootPlaceName)
|
Q_PROPERTY(QString hostname READ getHost)
|
||||||
Q_PROPERTY(QString pathname READ currentPath)
|
Q_PROPERTY(QString pathname READ currentPath)
|
||||||
public:
|
public:
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
|
@ -46,10 +46,11 @@ public:
|
||||||
|
|
||||||
const QUuid& getRootPlaceID() const { return _rootPlaceID; }
|
const QUuid& getRootPlaceID() const { return _rootPlaceID; }
|
||||||
|
|
||||||
const QString& getRootPlaceName() const { return _rootPlaceName; }
|
const QString& getHost() const { return _host; }
|
||||||
void setRootPlaceName(const QString& rootPlaceName);
|
void setHost(const QString& host);
|
||||||
|
|
||||||
void attemptPlaceNameLookup(const QString& lookupString, const QString& overridePath = QString());
|
void attemptPlaceNameLookup(const QString& lookupString, const QString& overridePath = QString());
|
||||||
|
void attemptDomainIDLookup(const QString& lookupString, const QString& overridePath = QString());
|
||||||
|
|
||||||
void setPositionGetter(PositionGetter positionGetter) { _positionGetter = positionGetter; }
|
void setPositionGetter(PositionGetter positionGetter) { _positionGetter = positionGetter; }
|
||||||
void setOrientationGetter(OrientationGetter orientationGetter) { _orientationGetter = orientationGetter; }
|
void setOrientationGetter(OrientationGetter orientationGetter) { _orientationGetter = orientationGetter; }
|
||||||
|
@ -78,7 +79,7 @@ signals:
|
||||||
bool hasOrientationChange, const glm::quat& newOrientation,
|
bool hasOrientationChange, const glm::quat& newOrientation,
|
||||||
bool shouldFaceLocation);
|
bool shouldFaceLocation);
|
||||||
void pathChangeRequired(const QString& newPath);
|
void pathChangeRequired(const QString& newPath);
|
||||||
void rootPlaceNameChanged(const QString& newRootPlaceName);
|
void hostChanged(const QString& newHost);
|
||||||
protected:
|
protected:
|
||||||
AddressManager();
|
AddressManager();
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -95,8 +96,9 @@ private:
|
||||||
void handlePath(const QString& path);
|
void handlePath(const QString& path);
|
||||||
bool handleViewpoint(const QString& viewpointString, bool shouldFace = false);
|
bool handleViewpoint(const QString& viewpointString, bool shouldFace = false);
|
||||||
bool handleUsername(const QString& lookupString);
|
bool handleUsername(const QString& lookupString);
|
||||||
|
bool handleDomainID(const QString& host);
|
||||||
|
|
||||||
QString _rootPlaceName;
|
QString _host;
|
||||||
QUuid _rootPlaceID;
|
QUuid _rootPlaceID;
|
||||||
PositionGetter _positionGetter;
|
PositionGetter _positionGetter;
|
||||||
OrientationGetter _orientationGetter;
|
OrientationGetter _orientationGetter;
|
||||||
|
|
Loading…
Reference in a new issue