mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-13 22:27:13 +02:00
Add ability for 'handleLookupString' to have spaces.
This commit is contained in:
parent
51e6468abd
commit
1411d55364
2 changed files with 55 additions and 27 deletions
|
@ -242,7 +242,7 @@ const JSONCallbackParameters& AddressManager::apiCallbackParameters() {
|
|||
return callbackParams;
|
||||
}
|
||||
|
||||
bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger) {
|
||||
bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger, const QString& lookupUrlInString) {
|
||||
static QString URL_TYPE_USER = "user";
|
||||
static QString URL_TYPE_DOMAIN_ID = "domain_id";
|
||||
static QString URL_TYPE_PLACE = "place";
|
||||
|
@ -271,7 +271,15 @@ bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger) {
|
|||
// would indicate that the scheme is 'somewhere'
|
||||
// use hifi://somewhere:<port> instead
|
||||
|
||||
if (lookupUrl.scheme() == URL_SCHEME_VIRCADIA) {
|
||||
if (lookupUrl.scheme() == URL_SCHEME_VIRCADIA || lookupUrlInString.startsWith(URL_SCHEME_VIRCADIA + "://")) {
|
||||
QString lookupUrlString;
|
||||
|
||||
if (lookupUrlInString.startsWith(URL_SCHEME_VIRCADIA + "://")) {
|
||||
lookupUrlString = lookupUrlInString;
|
||||
} else {
|
||||
lookupUrlString = lookupUrl.toString(QUrl::FullyEncoded);
|
||||
}
|
||||
|
||||
if (lookupUrl.host().isEmpty()) {
|
||||
// this was in the form hifi:/somewhere or hifi:somewhere. Fix it by making it hifi://somewhere
|
||||
static const QRegExp HIFI_SCHEME_REGEX = QRegExp(URL_SCHEME_VIRCADIA + ":\\/{0,2}", Qt::CaseInsensitive);
|
||||
|
@ -340,6 +348,8 @@ bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger) {
|
|||
// try to look up the domain ID on the metaverse API
|
||||
attemptDomainIDLookup(lookupUrl.host(), lookupUrl.path(), trigger);
|
||||
} else {
|
||||
// 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
|
||||
UserActivityLogger::getInstance().wentTo(trigger, URL_TYPE_PLACE, lookupUrl.toString());
|
||||
|
||||
// save the last visited domain URL.
|
||||
|
@ -348,10 +358,27 @@ bool AddressManager::handleUrl(const QUrl& lookupUrlIn, LookupTrigger trigger) {
|
|||
// store this place name as the previous lookup in case we fail to connect and want to refresh API info
|
||||
_previousAPILookup = lookupUrl;
|
||||
|
||||
// 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
|
||||
if (!lookupUrl.host().isNull() && !lookupUrl.host().isEmpty()) {
|
||||
attemptPlaceNameLookup(lookupUrl.host(), lookupUrl.path(), trigger);
|
||||
// Let's convert this to a QString for processing in case there are spaces in it.
|
||||
|
||||
if (lookupUrlString.contains(URL_SCHEME_VIRCADIA + "://", Qt::CaseInsensitive)) {
|
||||
lookupUrlString = lookupUrlString.replace((URL_SCHEME_VIRCADIA + "://"), "");
|
||||
} else if (lookupUrlString.contains(URL_SCHEME_VIRCADIA + ":/", Qt::CaseInsensitive)) {
|
||||
lookupUrlString = lookupUrlString.replace((URL_SCHEME_VIRCADIA + ":/"), "");
|
||||
} else if (lookupUrlString.contains(URL_SCHEME_VIRCADIA + ":", Qt::CaseInsensitive)) {
|
||||
lookupUrlString = lookupUrlString.replace((URL_SCHEME_VIRCADIA + ":"), "");
|
||||
}
|
||||
|
||||
// Get the path and then strip it out.
|
||||
QString lookupUrlStringPath;
|
||||
|
||||
int index = lookupUrlString.indexOf('/');
|
||||
if (index != -1) {
|
||||
lookupUrlStringPath = lookupUrlString.mid(index);
|
||||
lookupUrlString.replace(lookupUrlStringPath, "");
|
||||
}
|
||||
|
||||
if (!lookupUrlString.isNull() && !lookupUrlString.isEmpty()) {
|
||||
attemptPlaceNameLookup(lookupUrlString, lookupUrlStringPath, trigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -412,13 +439,13 @@ bool isPossiblePlaceName(QString possiblePlaceName) {
|
|||
}
|
||||
|
||||
void AddressManager::handleLookupString(const QString& lookupString, bool fromSuggestions) {
|
||||
QString trimmedString = lookupString.trimmed();
|
||||
|
||||
QString sanitizedString = lookupString.trimmed();
|
||||
if (!sanitizedString.isEmpty()) {
|
||||
if (!trimmedString.isEmpty()) {
|
||||
resetConfirmConnectWithoutAvatarEntities();
|
||||
|
||||
// make this a valid hifi URL and handle it off to handleUrl
|
||||
handleUrl(sanitizedString, fromSuggestions ? Suggestions : UserInput);
|
||||
handleUrl(trimmedString, fromSuggestions ? Suggestions : UserInput, trimmedString);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -606,7 +633,7 @@ void AddressManager::handleAPIError(QNetworkReply* errorReply) {
|
|||
|
||||
void AddressManager::attemptPlaceNameLookup(const QString& lookupString, const QString& overridePath, LookupTrigger trigger) {
|
||||
// assume this is a place name and see if we can get any info on it
|
||||
QString placeName = QUrl::toPercentEncoding(lookupString);
|
||||
//QString placeName = QUrl::toPercentEncoding(lookupString);
|
||||
|
||||
QVariantMap requestParams;
|
||||
|
||||
|
@ -618,7 +645,7 @@ void AddressManager::attemptPlaceNameLookup(const QString& lookupString, const Q
|
|||
// remember how this lookup was triggered for history storage handling later
|
||||
requestParams.insert(LOOKUP_TRIGGER_KEY, static_cast<int>(trigger));
|
||||
|
||||
DependencyManager::get<AccountManager>()->sendRequest(GET_PLACE.arg(placeName),
|
||||
DependencyManager::get<AccountManager>()->sendRequest(GET_PLACE.arg(lookupString),
|
||||
AccountManagerAuth::None,
|
||||
QNetworkAccessManager::GetOperation,
|
||||
apiCallbackParameters(),
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Stephen Birarda on 2014-09-10.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
// Copyright 2021 Vircadia contributors.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -35,7 +36,7 @@ const QString GET_PLACE = "/api/v1/places/%1";
|
|||
* The <code>location</code> API provides facilities related to your current location in the metaverse.
|
||||
*
|
||||
* <h3>Getter/Setter</h3>
|
||||
* <p>You can get and set your current metaverse address by directly reading a string value from and writing a string value to
|
||||
* <p>You can get and set your current metaverse address by directly reading a string value from and writing a string value to
|
||||
* the <code>location</code> object. This is an alternative to using the <code>location.href</code> property or other object
|
||||
* functions.</p>
|
||||
*
|
||||
|
@ -53,12 +54,12 @@ const QString GET_PLACE = "/api/v1/places/%1";
|
|||
* <code>localhost</code>, or an IP address). Is blank if you're in a serverless domain.
|
||||
* <em>Read-only.</em>
|
||||
* @property {string} href - Your current metaverse address (e.g., <code>"hifi://domainname/15,-10,26/0,0,0,1"</code>)
|
||||
* regardless of whether or not you're connected to the domain. Starts with <code>"file:///"</code> if you're in a
|
||||
* regardless of whether or not you're connected to the domain. Starts with <code>"file:///"</code> if you're in a
|
||||
* serverless domain.
|
||||
* <em>Read-only.</em>
|
||||
* @property {boolean} isConnected - <code>true</code> if you're connected to the domain in your current <code>href</code>
|
||||
* metaverse address, otherwise <code>false</code>.
|
||||
* @property {string} pathname - The location and orientation in your current <code>href</code> metaverse address
|
||||
* @property {string} pathname - The location and orientation in your current <code>href</code> metaverse address
|
||||
* (e.g., <code>"/15,-10,26/0,0,0,1"</code>).
|
||||
* <em>Read-only.</em>
|
||||
* @property {string} placename - The place name in your current <code>href</code> metaverse address
|
||||
|
@ -77,7 +78,7 @@ const QString GET_PLACE = "/api/v1/places/%1";
|
|||
* @hifi-client-entity
|
||||
* @hifi-avatar
|
||||
*
|
||||
* @deprecated This API is deprecated and will be removed. Use the {@link location} or {@link Window|Window.location} APIs
|
||||
* @deprecated This API is deprecated and will be removed. Use the {@link location} or {@link Window|Window.location} APIs
|
||||
* instead.
|
||||
*
|
||||
* @property {Uuid} domainID - A UUID uniquely identifying the domain you're visiting. Is {@link Uuid(0)|Uuid.NULL} if you're not
|
||||
|
@ -248,9 +249,9 @@ public slots:
|
|||
/*@jsdoc
|
||||
* Takes you to a specified metaverse address.
|
||||
* @function location.handleLookupString
|
||||
* @param {string} address - The address to go to: a <code>"hifi://"</code> address, an IP address (e.g.,
|
||||
* <code>"127.0.0.1"</code> or <code>"localhost"</code>), a <code>file:///</code> address, a domain name, a named path
|
||||
* on a domain (starts with <code>"/"</code>), a position or position and orientation, or a user (starts with
|
||||
* @param {string} address - The address to go to: a <code>"hifi://"</code> address, an IP address (e.g.,
|
||||
* <code>"127.0.0.1"</code> or <code>"localhost"</code>), a <code>file:///</code> address, a domain name, a named path
|
||||
* on a domain (starts with <code>"/"</code>), a position or position and orientation, or a user (starts with
|
||||
* <code>"@"</code>).
|
||||
* @param {boolean} [fromSuggestions=false] - Set to <code>true</code> if the address is obtained from the "Goto" dialog.
|
||||
* Helps ensure that user's location history is correctly maintained.
|
||||
|
@ -258,7 +259,7 @@ public slots:
|
|||
void handleLookupString(const QString& lookupString, bool fromSuggestions = false);
|
||||
|
||||
/*@jsdoc
|
||||
* Takes you to a position and orientation resulting from a lookup for a named path in the domain (set in the domain
|
||||
* Takes you to a position and orientation resulting from a lookup for a named path in the domain (set in the domain
|
||||
* server's settings).
|
||||
* @function location.goToViewpointForPath
|
||||
* @param {string} path - The position and orientation corresponding to the named path.
|
||||
|
@ -292,7 +293,7 @@ public slots:
|
|||
* location history is correctly maintained.
|
||||
*/
|
||||
void goToLocalSandbox(QString path = "", LookupTrigger trigger = LookupTrigger::StartupFromSettings) {
|
||||
handleUrl(SANDBOX_HIFI_ADDRESS + path, trigger);
|
||||
handleUrl(SANDBOX_HIFI_ADDRESS + path, trigger);
|
||||
}
|
||||
|
||||
/*@jsdoc
|
||||
|
@ -307,7 +308,7 @@ public slots:
|
|||
* Takes you to the specified user's location.
|
||||
* @function location.goToUser
|
||||
* @param {string} username - The user's username.
|
||||
* @param {boolean} [matchOrientation=true] - If <code>true</code> then go to a location just in front of the user and turn
|
||||
* @param {boolean} [matchOrientation=true] - If <code>true</code> then go to a location just in front of the user and turn
|
||||
* to face them, otherwise go to the user's exact location and orientation.
|
||||
*/
|
||||
void goToUser(const QString& username, bool shouldMatchOrientation = true);
|
||||
|
@ -348,7 +349,7 @@ public slots:
|
|||
void copyAddress();
|
||||
|
||||
/*@jsdoc
|
||||
* Copies your current metaverse location and orientation (i.e., <code>location.pathname</code> property value) to the OS
|
||||
* Copies your current metaverse location and orientation (i.e., <code>location.pathname</code> property value) to the OS
|
||||
* clipboard.
|
||||
* @function location.copyPath
|
||||
*/
|
||||
|
@ -374,7 +375,7 @@ signals:
|
|||
void lookupResultsFinished();
|
||||
|
||||
/*@jsdoc
|
||||
* Triggered when looking up the details of a metaverse user or location to go to has completed and the domain or user is
|
||||
* Triggered when looking up the details of a metaverse user or location to go to has completed and the domain or user is
|
||||
* offline.
|
||||
* @function location.lookupResultIsOffline
|
||||
* @returns {Signal}
|
||||
|
@ -415,9 +416,9 @@ signals:
|
|||
* @function location.locationChangeRequired
|
||||
* @param {Vec3} position - The position to go to.
|
||||
* @param {boolean} hasOrientationChange - If <code>true</code> then a new <code>orientation</code> has been requested.
|
||||
* @param {Quat} orientation - The orientation to change to. Is {@link Quat(0)|Quat.IDENTITY} if
|
||||
* @param {Quat} orientation - The orientation to change to. Is {@link Quat(0)|Quat.IDENTITY} if
|
||||
* <code>hasOrientationChange</code> is <code>false</code>.
|
||||
* @param {boolean} shouldFaceLocation - If <code>true</code> then the request is to go to a position near that specified
|
||||
* @param {boolean} shouldFaceLocation - If <code>true</code> then the request is to go to a position near that specified
|
||||
* and orient your avatar to face it. For example when you visit someone from the "People" dialog.
|
||||
* @returns {Signal}
|
||||
* @example <caption>Report location change requests.</caption>
|
||||
|
@ -468,7 +469,7 @@ signals:
|
|||
* Triggered when there's a change in whether or not there's a previous location that can be navigated to using
|
||||
* {@link location.goBack|goBack}. (Reflects changes in the state of the "Goto" dialog's back arrow.)
|
||||
* @function location.goBackPossible
|
||||
* @param {boolean} isPossible - <code>true</code> if there's a previous location to navigate to, otherwise
|
||||
* @param {boolean} isPossible - <code>true</code> if there's a previous location to navigate to, otherwise
|
||||
* <code>false</code>.
|
||||
* @returns {Signal}
|
||||
* @example <caption>Report when ability to navigate back changes.</caption>
|
||||
|
@ -511,7 +512,7 @@ private:
|
|||
|
||||
const JSONCallbackParameters& apiCallbackParameters();
|
||||
|
||||
bool handleUrl(const QUrl& lookupUrl, LookupTrigger trigger = UserInput);
|
||||
bool handleUrl(const QUrl& lookupUrl, LookupTrigger trigger = UserInput, const QString& lookupUrlInString = "");
|
||||
|
||||
bool handleNetworkAddress(const QString& lookupString, LookupTrigger trigger, bool& hostChanged);
|
||||
void handlePath(const QString& path, LookupTrigger trigger, bool wasPathOnly = false);
|
||||
|
|
Loading…
Reference in a new issue