2014-09-11 10:14:00 -07:00
|
|
|
//
|
|
|
|
// AddressManager.h
|
|
|
|
// libraries/networking/src
|
|
|
|
//
|
|
|
|
// Created by Stephen Birarda on 2014-09-10.
|
|
|
|
// Copyright 2014 High Fidelity, Inc.
|
2021-06-15 00:31:28 -04:00
|
|
|
// Copyright 2021 Vircadia contributors.
|
2014-09-11 10:14:00 -07:00
|
|
|
//
|
|
|
|
// 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_AddressManager_h
|
|
|
|
#define hifi_AddressManager_h
|
|
|
|
|
2015-06-16 08:41:21 -07:00
|
|
|
#include <QtCore/QObject>
|
|
|
|
#include <QtCore/QStack>
|
2014-09-11 10:14:00 -07:00
|
|
|
|
|
|
|
#include <glm/glm.hpp>
|
2014-09-11 17:17:47 -07:00
|
|
|
#include <glm/gtc/quaternion.hpp>
|
|
|
|
|
2014-12-15 14:54:20 -08:00
|
|
|
#include <DependencyManager.h>
|
|
|
|
|
2014-09-11 17:17:47 -07:00
|
|
|
#include "AccountManager.h"
|
|
|
|
|
2018-08-28 15:50:14 -07:00
|
|
|
extern const QString REDIRECT_HIFI_ADDRESS;
|
2022-08-03 21:53:33 +02:00
|
|
|
extern const QString DEFAULT_OVERTE_ADDRESS;
|
2019-01-31 10:52:48 -08:00
|
|
|
extern const QString DEFAULT_HOME_ADDRESS;
|
2016-10-20 16:29:40 -07:00
|
|
|
|
2016-05-10 10:45:57 -07:00
|
|
|
const QString SANDBOX_HIFI_ADDRESS = "hifi://localhost";
|
2015-05-12 14:34:14 -07:00
|
|
|
const QString INDEX_PATH = "/";
|
2014-09-11 17:17:47 -07:00
|
|
|
|
2015-06-26 14:12:26 -07:00
|
|
|
const QString GET_PLACE = "/api/v1/places/%1";
|
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2022-09-04 21:33:44 +02:00
|
|
|
* The <code>location</code> API provides facilities related to your current location in the directory services.
|
2018-01-11 13:44:16 +13:00
|
|
|
*
|
2019-05-01 08:17:43 +12:00
|
|
|
* <h3>Getter/Setter</h3>
|
2022-09-04 21:33:44 +02:00
|
|
|
* <p>You can get and set your current directory services address by directly reading a string value from and writing a string value to
|
2019-05-01 08:17:43 +12:00
|
|
|
* the <code>location</code> object. This is an alternative to using the <code>location.href</code> property or other object
|
2018-05-15 17:37:45 +12:00
|
|
|
* functions.</p>
|
|
|
|
*
|
2018-01-11 13:44:16 +13:00
|
|
|
* @namespace location
|
2018-04-28 20:00:28 +12:00
|
|
|
*
|
|
|
|
* @hifi-interface
|
|
|
|
* @hifi-client-entity
|
2019-02-12 11:49:49 +13:00
|
|
|
* @hifi-avatar
|
2018-04-28 20:00:28 +12:00
|
|
|
* @hifi-assignment-client
|
|
|
|
*
|
2019-06-05 14:39:05 +12:00
|
|
|
* @property {Uuid} domainID - A UUID uniquely identifying the domain you're visiting. Is {@link Uuid(0)|Uuid.NULL} if you're not
|
2018-04-20 10:11:01 +12:00
|
|
|
* connected to the domain or are in a serverless domain.
|
2018-01-11 13:44:16 +13:00
|
|
|
* <em>Read-only.</em>
|
2022-09-04 21:33:44 +02:00
|
|
|
* @property {string} hostname - The name of the domain for your current directory services address (e.g., <code>"DomainName"</code>,
|
2018-04-20 10:11:01 +12:00
|
|
|
* <code>localhost</code>, or an IP address). Is blank if you're in a serverless domain.
|
2018-01-11 13:44:16 +13:00
|
|
|
* <em>Read-only.</em>
|
2022-09-04 21:33:44 +02:00
|
|
|
* @property {string} href - Your current directory services address (e.g., <code>"hifi://domainname/15,-10,26/0,0,0,1"</code>)
|
2021-06-15 00:31:28 -04:00
|
|
|
* regardless of whether or not you're connected to the domain. Starts with <code>"file:///"</code> if you're in a
|
2018-04-20 10:11:01 +12:00
|
|
|
* serverless domain.
|
2018-01-11 13:44:16 +13:00
|
|
|
* <em>Read-only.</em>
|
2018-01-11 14:48:45 +13:00
|
|
|
* @property {boolean} isConnected - <code>true</code> if you're connected to the domain in your current <code>href</code>
|
2022-09-04 21:33:44 +02:00
|
|
|
* directory services address, otherwise <code>false</code>.
|
|
|
|
* @property {string} pathname - The location and orientation in your current <code>href</code> directory services address
|
2018-01-11 13:44:16 +13:00
|
|
|
* (e.g., <code>"/15,-10,26/0,0,0,1"</code>).
|
|
|
|
* <em>Read-only.</em>
|
2022-09-04 21:33:44 +02:00
|
|
|
* @property {string} placename - The place name in your current <code>href</code> directory services address
|
2019-11-19 10:32:38 +13:00
|
|
|
* (e.g., <code>"DomainName"</code>). Is blank if your <code>hostname</code> is an IP address.
|
2018-01-11 13:44:16 +13:00
|
|
|
* <em>Read-only.</em>
|
2022-09-04 21:33:44 +02:00
|
|
|
* @property {string} protocol - The protocol of your current <code>href</code> directory services address (e.g., <code>"hifi"</code>).
|
2018-01-11 13:44:16 +13:00
|
|
|
* <em>Read-only.</em>
|
|
|
|
*/
|
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2022-09-04 21:33:44 +02:00
|
|
|
* The <code>AddressManager</code> API provides facilities related to your current location in the directory services.
|
2019-12-10 07:34:17 +13:00
|
|
|
*
|
|
|
|
* @namespace AddressManager
|
|
|
|
*
|
|
|
|
* @hifi-interface
|
|
|
|
* @hifi-client-entity
|
|
|
|
* @hifi-avatar
|
|
|
|
*
|
2021-06-15 00:31:28 -04:00
|
|
|
* @deprecated This API is deprecated and will be removed. Use the {@link location} or {@link Window|Window.location} APIs
|
2019-12-10 07:34:17 +13:00
|
|
|
* instead.
|
|
|
|
*
|
|
|
|
* @property {Uuid} domainID - A UUID uniquely identifying the domain you're visiting. Is {@link Uuid(0)|Uuid.NULL} if you're not
|
|
|
|
* connected to the domain or are in a serverless domain.
|
|
|
|
* <em>Read-only.</em>
|
2022-09-04 21:33:44 +02:00
|
|
|
* @property {string} hostname - The name of the domain for your current directory services address (e.g., <code>"DomainName"</code>,
|
2019-12-10 07:34:17 +13:00
|
|
|
* <code>localhost</code>, or an IP address). Is blank if you're in a serverless domain.
|
|
|
|
* <em>Read-only.</em>
|
2022-09-04 21:33:44 +02:00
|
|
|
* @property {string} href - Your current directory services address (e.g., <code>"hifi://domainname/15,-10,26/0,0,0,1"</code>)
|
2019-12-10 07:34:17 +13:00
|
|
|
* 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>
|
2022-09-04 21:33:44 +02:00
|
|
|
* directory services address, otherwise <code>false</code>.
|
|
|
|
* @property {string} pathname - The location and orientation in your current <code>href</code> directory services address
|
2019-12-10 07:34:17 +13:00
|
|
|
* (e.g., <code>"/15,-10,26/0,0,0,1"</code>).
|
|
|
|
* <em>Read-only.</em>
|
2022-09-04 21:33:44 +02:00
|
|
|
* @property {string} placename - The place name in your current <code>href</code> directory services address
|
2019-12-10 07:34:17 +13:00
|
|
|
* (e.g., <code>"DomainName"</code>). Is blank if your <code>hostname</code> is an IP address.
|
|
|
|
* <em>Read-only.</em>
|
2022-09-04 21:33:44 +02:00
|
|
|
* @property {string} protocol - The protocol of your current <code>href</code> directory services address (e.g., <code>"hifi"</code>).
|
2019-12-10 07:34:17 +13:00
|
|
|
* <em>Read-only.</em>
|
|
|
|
*
|
|
|
|
* @borrows location.handleLookupString as handleLookupString
|
|
|
|
* @borrows location.goToViewpointForPath as goToViewpointForPath
|
|
|
|
* @borrows location.goBack as goBack
|
|
|
|
* @borrows location.goForward as goForward
|
|
|
|
* @borrows location.goToLocalSandbox as goToLocalSandbox
|
|
|
|
* @borrows location.goToEntry as goToEntry
|
|
|
|
* @borrows location.goToUser as goToUser
|
|
|
|
* @borrows location.goToLastAddress as goToLastAddress
|
|
|
|
* @borrows location.canGoBack as canGoBack
|
|
|
|
* @borrows location.refreshPreviousLookup as refreshPreviousLookup
|
|
|
|
* @borrows location.storeCurrentAddress as storeCurrentAddress
|
|
|
|
* @borrows location.copyAddress as copyAddress
|
|
|
|
* @borrows location.copyPath as copyPath
|
|
|
|
* @borrows location.lookupShareableNameForDomainID as lookupShareableNameForDomainID
|
|
|
|
*
|
|
|
|
* @borrows location.lookupResultsFinished as lookupResultsFinished
|
|
|
|
* @borrows location.lookupResultIsOffline as lookupResultIsOffline
|
|
|
|
* @borrows location.lookupResultIsNotFound as lookupResultIsNotFound
|
|
|
|
* @borrows location.possibleDomainChangeRequired as possibleDomainChangeRequired
|
|
|
|
* @borrows location.locationChangeRequired as locationChangeRequired
|
|
|
|
* @borrows location.possibleDomainChangeRequiredViaICEForID as possibleDomainChangeRequiredViaICEForID
|
|
|
|
* @borrows location.pathChangeRequired as pathChangeRequired
|
|
|
|
* @borrows location.hostChanged as hostChanged
|
|
|
|
* @borrows location.goBackPossible as goBackPossible
|
|
|
|
* @borrows location.goForwardPossible as goForwardPossible
|
|
|
|
*/
|
|
|
|
|
2015-01-13 20:38:01 -08:00
|
|
|
class AddressManager : public QObject, public Dependency {
|
2014-09-11 10:14:00 -07:00
|
|
|
Q_OBJECT
|
2015-01-13 11:03:14 -08:00
|
|
|
SINGLETON_DEPENDENCY
|
2014-10-28 10:35:56 -07:00
|
|
|
Q_PROPERTY(bool isConnected READ isConnected)
|
2016-11-16 12:53:57 -08:00
|
|
|
Q_PROPERTY(QUrl href READ currentShareableAddress)
|
2014-10-28 10:35:56 -07:00
|
|
|
Q_PROPERTY(QString protocol READ getProtocol)
|
2015-06-05 13:33:14 -07:00
|
|
|
Q_PROPERTY(QString hostname READ getHost)
|
2014-10-28 10:35:56 -07:00
|
|
|
Q_PROPERTY(QString pathname READ currentPath)
|
2016-08-10 14:54:29 -07:00
|
|
|
Q_PROPERTY(QString placename READ getPlaceName)
|
2018-01-30 20:46:27 +13:00
|
|
|
Q_PROPERTY(QString domainID READ getDomainID)
|
2014-09-11 10:14:00 -07:00
|
|
|
public:
|
2015-09-24 17:19:50 +02:00
|
|
|
using PositionGetter = std::function<glm::vec3()>;
|
|
|
|
using OrientationGetter = std::function<glm::quat()>;
|
2015-06-16 08:41:21 -07:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2022-09-04 21:33:44 +02:00
|
|
|
* <p>The reasons for an address lookup via the Directory Services API are defined by numeric values:</p>
|
2018-01-11 13:44:16 +13:00
|
|
|
* <table>
|
|
|
|
* <thead>
|
|
|
|
* <tr>
|
|
|
|
* <th>Name</th>
|
|
|
|
* <th>Value</th>
|
|
|
|
* <th>Description</th>
|
|
|
|
* </tr>
|
|
|
|
* </thead>
|
|
|
|
* <tbody>
|
|
|
|
* <tr>
|
|
|
|
* <td><strong>UserInput</strong></td>
|
|
|
|
* <td><code>0</code></td>
|
|
|
|
* <td>User-typed input.</td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td><strong>Back</strong></td>
|
|
|
|
* <td><code>1</code></td>
|
|
|
|
* <td>Address from a {@link location.goBack|goBack} call.</td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td><strong>Forward</strong></td>
|
|
|
|
* <td><code>2</code></td>
|
|
|
|
* <td>Address from a {@link location.goForward|goForward} call.</td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td><strong>StartupFromSettings</strong></td>
|
|
|
|
* <td><code>3</code></td>
|
|
|
|
* <td>Initial location at Interface start-up from settings.</td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td><strong>DomainPathResponse</strong></td>
|
|
|
|
* <td><code>4</code></td>
|
|
|
|
* <td>A named path in the domain.</td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td><strong>Internal</strong></td>
|
|
|
|
* <td><code>5</code></td>
|
|
|
|
* <td>An internal attempt to resolve an alternative path.</td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td><strong>AttemptedRefresh</strong></td>
|
|
|
|
* <td><code>6</code></td>
|
|
|
|
* <td>A refresh after connecting to a domain.</td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td><strong>Suggestions</strong></td>
|
|
|
|
* <td><code>7</code></td>
|
|
|
|
* <td>Address from the Goto dialog.</td>
|
|
|
|
* </tr>
|
|
|
|
* <tr>
|
|
|
|
* <td><strong>VisitUserFromPAL</strong></td>
|
|
|
|
* <td><code>8</code></td>
|
|
|
|
* <td>User from the People dialog.</td>
|
|
|
|
* </tr>
|
|
|
|
* </tbody>
|
|
|
|
* </table>
|
2018-05-21 09:32:10 +12:00
|
|
|
* @typedef {number} location.LookupTrigger
|
2018-01-11 13:44:16 +13:00
|
|
|
*/
|
2018-09-19 09:55:15 -07:00
|
|
|
enum LookupTrigger {
|
2015-06-16 08:41:21 -07:00
|
|
|
UserInput,
|
|
|
|
Back,
|
|
|
|
Forward,
|
2016-05-04 15:46:26 -07:00
|
|
|
StartupFromSettings,
|
2016-05-16 10:51:41 -07:00
|
|
|
DomainPathResponse,
|
2016-06-06 10:50:36 -07:00
|
|
|
Internal,
|
2016-07-15 19:15:58 -07:00
|
|
|
AttemptedRefresh,
|
2017-08-08 05:08:20 +01:00
|
|
|
Suggestions,
|
|
|
|
VisitUserFromPAL
|
2015-06-16 08:41:21 -07:00
|
|
|
};
|
|
|
|
|
2014-10-28 10:35:56 -07:00
|
|
|
bool isConnected();
|
2018-04-12 08:55:47 +12:00
|
|
|
QString getProtocol() const;
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2016-10-25 14:19:44 -07:00
|
|
|
QUrl currentAddress(bool domainOnly = false) const;
|
2016-08-03 16:04:48 -07:00
|
|
|
QUrl currentFacingAddress() const;
|
2016-10-25 14:19:44 -07:00
|
|
|
QUrl currentShareableAddress(bool domainOnly = false) const;
|
2018-04-05 13:39:51 -07:00
|
|
|
QUrl currentPublicAddress(bool domainOnly = false) const;
|
2016-08-23 11:18:42 -07:00
|
|
|
QUrl currentFacingShareableAddress() const;
|
2018-04-05 13:39:51 -07:00
|
|
|
QUrl currentFacingPublicAddress() const;
|
2016-08-03 16:04:48 -07:00
|
|
|
QString currentPath(bool withOrientation = true) const;
|
|
|
|
QString currentFacingPath() const;
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2018-08-31 19:29:48 -07:00
|
|
|
QUrl lastAddress() const;
|
|
|
|
|
2015-01-13 15:02:04 -08:00
|
|
|
const QUuid& getRootPlaceID() const { return _rootPlaceID; }
|
2018-03-01 11:07:37 -08:00
|
|
|
QString getPlaceName() const;
|
2018-01-30 20:46:27 +13:00
|
|
|
QString getDomainID() const;
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2018-04-06 10:59:33 -07:00
|
|
|
QString getHost() const { return _domainURL.host(); }
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2014-10-03 10:29:02 -07:00
|
|
|
void setPositionGetter(PositionGetter positionGetter) { _positionGetter = positionGetter; }
|
|
|
|
void setOrientationGetter(OrientationGetter orientationGetter) { _orientationGetter = orientationGetter; }
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2014-12-15 14:54:20 -08:00
|
|
|
void loadSettings(const QString& lookupString = QString());
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2015-06-19 16:05:45 -07:00
|
|
|
const QStack<QUrl>& getBackStack() const { return _backStack; }
|
|
|
|
const QStack<QUrl>& getForwardStack() const { return _forwardStack; }
|
2015-06-19 11:18:16 -07:00
|
|
|
|
2018-03-01 11:07:37 -08:00
|
|
|
QUrl getDomainURL() { return _domainURL; }
|
2018-02-23 16:46:42 -08:00
|
|
|
|
2014-09-11 17:17:47 -07:00
|
|
|
public slots:
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2022-09-04 21:33:44 +02:00
|
|
|
* Takes you to a specified directory services address.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.handleLookupString
|
2021-06-15 00:31:28 -04:00
|
|
|
* @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
|
2020-06-16 12:25:59 +12:00
|
|
|
* <code>"@"</code>).
|
2021-07-05 10:43:50 +12:00
|
|
|
* @param {boolean} [fromSuggestions=false] - Set to <code>true</code> if the address is obtained from the "Explore" app.
|
|
|
|
* Helps ensure that the user's location history is correctly maintained.
|
2018-01-11 13:44:16 +13:00
|
|
|
*/
|
2016-07-15 19:15:58 -07:00
|
|
|
void handleLookupString(const QString& lookupString, bool fromSuggestions = false);
|
2018-09-04 17:46:23 -07:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2021-06-15 00:31:28 -04:00
|
|
|
* Takes you to a position and orientation resulting from a lookup for a named path in the domain (set in the domain
|
2019-05-01 08:17:43 +12:00
|
|
|
* server's settings).
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.goToViewpointForPath
|
|
|
|
* @param {string} path - The position and orientation corresponding to the named path.
|
|
|
|
* @param {string} namedPath - The named path that was looked up on the server.
|
|
|
|
* @deprecated This function is deprecated and will be removed.
|
|
|
|
*/
|
|
|
|
// This function is marked as deprecated in anticipation that it will not be included in the JavaScript API if and when the
|
|
|
|
// functions and signals that should be exposed are moved to a scripting interface class.
|
|
|
|
//
|
2015-06-16 08:41:21 -07:00
|
|
|
// we currently expect this to be called from NodeList once handleLookupString has been called with a path
|
2018-09-19 09:55:15 -07:00
|
|
|
bool goToViewpointForPath(const QString& viewpointString, const QString& pathString)
|
|
|
|
{ return handleViewpoint(viewpointString, false, DomainPathResponse, false, pathString); }
|
2015-06-16 08:41:21 -07:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2019-05-01 08:17:43 +12:00
|
|
|
* Takes you back to the previous location in your navigation history, if there is one.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.goBack
|
|
|
|
*/
|
2015-06-16 08:41:21 -07:00
|
|
|
void goBack();
|
2018-01-11 13:44:16 +13:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2019-05-01 08:17:43 +12:00
|
|
|
* Takes you forward to the next location in your navigation history, if there is one.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.goForward
|
|
|
|
*/
|
2015-06-16 08:41:21 -07:00
|
|
|
void goForward();
|
2018-01-11 13:44:16 +13:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2019-05-01 08:17:43 +12:00
|
|
|
* Takes you to the local Sandbox server that's running on the same PC as Interface.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.goToLocalSandbox
|
2019-05-01 08:17:43 +12:00
|
|
|
* @param {string} [path=""] - The position and orientation to go to (e.g., <code>"/0,0,0"</code>).
|
|
|
|
* @param {location.LookupTrigger} [trigger=StartupFromSettings] - The reason for the function call. Helps ensure that user's
|
2018-01-16 17:14:30 +13:00
|
|
|
* location history is correctly maintained.
|
2018-01-11 13:44:16 +13:00
|
|
|
*/
|
2018-09-04 17:46:23 -07:00
|
|
|
void goToLocalSandbox(QString path = "", LookupTrigger trigger = LookupTrigger::StartupFromSettings) {
|
2021-06-15 00:31:28 -04:00
|
|
|
handleUrl(SANDBOX_HIFI_ADDRESS + path, trigger);
|
2020-08-23 01:49:32 -04:00
|
|
|
}
|
2018-09-04 17:46:23 -07:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2022-09-04 21:33:44 +02:00
|
|
|
* Takes you to the default "welcome" directory services address.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.goToEntry
|
2018-01-16 17:14:30 +13:00
|
|
|
* @param {location.LookupTrigger} trigger=StartupFromSettings - The reason for the function call. Helps ensure that user's
|
|
|
|
* location history is correctly maintained.
|
2018-01-11 13:44:16 +13:00
|
|
|
*/
|
2021-03-29 21:14:00 +13:00
|
|
|
void goToEntry(LookupTrigger trigger = LookupTrigger::StartupFromSettings);
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2019-05-01 08:17:43 +12:00
|
|
|
* Takes you to the specified user's location.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.goToUser
|
2018-01-11 14:48:45 +13:00
|
|
|
* @param {string} username - The user's username.
|
2021-06-15 00:31:28 -04:00
|
|
|
* @param {boolean} [matchOrientation=true] - If <code>true</code> then go to a location just in front of the user and turn
|
2019-05-15 07:56:55 +12:00
|
|
|
* to face them, otherwise go to the user's exact location and orientation.
|
2018-01-11 13:44:16 +13:00
|
|
|
*/
|
2017-08-08 05:08:20 +01:00
|
|
|
void goToUser(const QString& username, bool shouldMatchOrientation = true);
|
2015-06-17 10:13:49 -07:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2019-05-15 07:56:55 +12:00
|
|
|
* Takes you to the last address tried. This will be the last URL tried from <code>location.handleLookupString</code>.
|
|
|
|
* @function location.goToLastAddress
|
|
|
|
*/
|
2021-03-29 21:14:00 +13:00
|
|
|
void goToLastAddress();
|
2018-08-31 19:29:48 -07:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2019-05-15 07:56:55 +12:00
|
|
|
* Checks if going back to the previous location is possible.
|
|
|
|
* @function location.canGoBack
|
2019-09-17 16:26:09 +12:00
|
|
|
* @returns {boolean} <code>true</code> if going back is possible, <code>false</code> if it isn't.
|
2019-05-15 07:56:55 +12:00
|
|
|
*/
|
2018-10-03 17:40:42 -07:00
|
|
|
bool canGoBack() const;
|
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2019-05-01 08:17:43 +12:00
|
|
|
* Refreshes the current address, e.g., after connecting to a domain in order to position the user to the desired location.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.refreshPreviousLookup
|
|
|
|
* @deprecated This function is deprecated and will be removed.
|
|
|
|
*/
|
|
|
|
// This function is marked as deprecated in anticipation that it will not be included in the JavaScript API if and when the
|
|
|
|
// functions and signals that should be exposed are moved to a scripting interface class.
|
2016-06-06 10:50:36 -07:00
|
|
|
void refreshPreviousLookup();
|
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2022-09-04 21:33:44 +02:00
|
|
|
* Updates your current directory services location in Interface's {@link Settings} file as your last-known address. This can be used
|
2018-01-16 17:14:30 +13:00
|
|
|
* to ensure that you start up at that address if you exit Interface without a later address automatically being saved.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.storeCurrentAddress
|
|
|
|
*/
|
2015-01-06 16:13:06 -08:00
|
|
|
void storeCurrentAddress();
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2022-09-04 21:33:44 +02:00
|
|
|
* Copies your current directory services address (i.e., <code>location.href</code> property value) to the OS clipboard.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.copyAddress
|
|
|
|
*/
|
2015-01-18 05:48:14 -08:00
|
|
|
void copyAddress();
|
2018-01-11 13:44:16 +13:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2022-09-04 21:33:44 +02:00
|
|
|
* Copies your current directory services location and orientation (i.e., <code>location.pathname</code> property value) to the OS
|
2018-01-11 13:44:16 +13:00
|
|
|
* clipboard.
|
|
|
|
* @function location.copyPath
|
|
|
|
*/
|
2015-01-18 05:48:14 -08:00
|
|
|
void copyPath();
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2019-05-01 08:17:43 +12:00
|
|
|
* Retrieves and remembers the place name for the given domain ID if the place name is not already known.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.lookupShareableNameForDomainID
|
|
|
|
* @param {Uuid} domainID - The UUID of the domain.
|
|
|
|
* @deprecated This function is deprecated and will be removed.
|
|
|
|
*/
|
|
|
|
// This function is marked as deprecated in anticipation that it will not be included in the JavaScript API if and when the
|
|
|
|
// functions and signals that should be exposed are moved to a scripting interface class.
|
2016-08-22 17:06:43 -07:00
|
|
|
void lookupShareableNameForDomainID(const QUuid& domainID);
|
|
|
|
|
2014-09-11 10:14:00 -07:00
|
|
|
signals:
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2022-09-04 21:33:44 +02:00
|
|
|
* Triggered when looking up the details of a directory services user or location to go to has completed (successfully or
|
2018-01-11 13:44:16 +13:00
|
|
|
* unsuccessfully).
|
|
|
|
* @function location.lookupResultsFinished
|
|
|
|
* @returns {Signal}
|
|
|
|
*/
|
2014-09-23 11:32:16 +02:00
|
|
|
void lookupResultsFinished();
|
2018-01-11 13:44:16 +13:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2022-09-04 21:33:44 +02:00
|
|
|
* Triggered when looking up the details of a directory services user or location to go to has completed and the domain or user is
|
2018-01-11 13:44:16 +13:00
|
|
|
* offline.
|
|
|
|
* @function location.lookupResultIsOffline
|
|
|
|
* @returns {Signal}
|
|
|
|
*/
|
2014-09-11 17:17:47 -07:00
|
|
|
void lookupResultIsOffline();
|
2018-01-11 13:44:16 +13:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2022-09-04 21:33:44 +02:00
|
|
|
* Triggered when looking up the details of a directory services user or location to go to has completed and the domain or user could
|
2018-01-11 14:48:45 +13:00
|
|
|
* not be found.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.lookupResultIsNotFound
|
|
|
|
* @returns {Signal}
|
|
|
|
*/
|
2014-09-12 15:01:08 -07:00
|
|
|
void lookupResultIsNotFound();
|
2015-06-16 13:17:13 -07:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2021-07-05 10:43:50 +12:00
|
|
|
* Triggered when a request is made to go to a URL or IP address.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.possibleDomainChangeRequired
|
2021-07-05 10:43:50 +12:00
|
|
|
* @param {string} domainURL - The URL of the domain.
|
2021-07-06 08:48:43 +12:00
|
|
|
* @param {Uuid} domainID - The UUID of the domain to go to. May be {@link Uuid|Uuid.NULL} if not yet known.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @returns {Signal}
|
|
|
|
*/
|
|
|
|
// No example because this function isn't typically used in scripts.
|
2018-03-01 11:07:37 -08:00
|
|
|
void possibleDomainChangeRequired(QUrl domainURL, QUuid domainID);
|
2018-01-11 13:44:16 +13:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2018-01-11 14:48:45 +13:00
|
|
|
* Triggered when a request is made to go to a named domain or user.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.possibleDomainChangeRequiredViaICEForID
|
|
|
|
* @param {string} iceServerHostName - IP address of the ICE server.
|
|
|
|
* @param {Uuid} domainID - The UUID of the domain to go to.
|
|
|
|
* @returns {Signal}
|
|
|
|
*/
|
|
|
|
// No example because this function isn't typically used in scripts.
|
2014-10-02 14:18:17 -07:00
|
|
|
void possibleDomainChangeRequiredViaICEForID(const QString& iceServerHostname, const QUuid& domainID);
|
2015-06-16 13:17:13 -07:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2018-01-11 13:44:16 +13:00
|
|
|
* Triggered when an attempt is made to send your avatar to a specified position on the current domain. For example, when
|
2018-01-11 14:48:45 +13:00
|
|
|
* you change domains or enter a position to go to in the "Goto" dialog.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @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.
|
2021-06-15 00:31:28 -04:00
|
|
|
* @param {Quat} orientation - The orientation to change to. Is {@link Quat(0)|Quat.IDENTITY} if
|
2018-01-11 13:44:16 +13:00
|
|
|
* <code>hasOrientationChange</code> is <code>false</code>.
|
2021-06-15 00:31:28 -04:00
|
|
|
* @param {boolean} shouldFaceLocation - If <code>true</code> then the request is to go to a position near that specified
|
2018-01-11 13:44:16 +13:00
|
|
|
* 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>
|
|
|
|
* function onLocationChangeRequired(newPosition, hasOrientationChange, newOrientation, shouldFaceLocation) {
|
|
|
|
* print("Location change required:");
|
|
|
|
* print("- New position = " + JSON.stringify(newPosition));
|
|
|
|
* print("- Has orientation change = " + hasOrientationChange);
|
|
|
|
* print("- New orientation = " + JSON.stringify(newOrientation));
|
|
|
|
* print("- Should face location = " + shouldFaceLocation);
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* location.locationChangeRequired.connect(onLocationChangeRequired);
|
|
|
|
*/
|
2014-09-16 09:57:21 -07:00
|
|
|
void locationChangeRequired(const glm::vec3& newPosition,
|
2018-09-19 09:55:15 -07:00
|
|
|
bool hasOrientationChange, const glm::quat& newOrientation,
|
2014-09-16 09:57:21 -07:00
|
|
|
bool shouldFaceLocation);
|
2018-01-11 13:44:16 +13:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2018-01-11 14:48:45 +13:00
|
|
|
* Triggered when an attempt is made to send your avatar to a new named path on the domain (set in the domain server's
|
2018-01-11 13:44:16 +13:00
|
|
|
* settings). For example, when you enter a "/" followed by the path's name in the "GOTO" dialog.
|
|
|
|
* @function location.pathChangeRequired
|
|
|
|
* @param {string} path - The name of the path to go to.
|
|
|
|
* @returns {Signal}
|
|
|
|
* @example <caption>Report path change requests.</caption>
|
|
|
|
* function onPathChangeRequired(newPath) {
|
|
|
|
* print("onPathChangeRequired: newPath = " + newPath);
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* location.pathChangeRequired.connect(onPathChangeRequired);
|
|
|
|
*/
|
2015-05-12 13:48:41 -07:00
|
|
|
void pathChangeRequired(const QString& newPath);
|
2018-02-15 15:19:50 -08:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2018-01-11 14:48:45 +13:00
|
|
|
* Triggered when you navigate to a new domain.
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.hostChanged
|
|
|
|
* @param {string} hostname - The new domain's host name.
|
|
|
|
* @returns {Signal}
|
|
|
|
* @example <caption>Report when you navigate to a new domain.</caption>
|
|
|
|
* function onHostChanged(host) {
|
|
|
|
* print("Host changed to: " + host);
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* location.hostChanged.connect(onHostChanged);
|
|
|
|
*/
|
2015-06-05 13:33:14 -07:00
|
|
|
void hostChanged(const QString& newHost);
|
2015-06-16 13:17:13 -07:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2018-01-11 14:48:45 +13:00
|
|
|
* 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.)
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.goBackPossible
|
2021-06-15 00:31:28 -04:00
|
|
|
* @param {boolean} isPossible - <code>true</code> if there's a previous location to navigate to, otherwise
|
2018-01-11 13:44:16 +13:00
|
|
|
* <code>false</code>.
|
|
|
|
* @returns {Signal}
|
|
|
|
* @example <caption>Report when ability to navigate back changes.</caption>
|
|
|
|
* function onGoBackPossible(isPossible) {
|
|
|
|
* print("Go back possible: " + isPossible);
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* location.goBackPossible.connect(onGoBackPossible);
|
|
|
|
*/
|
2015-06-16 13:17:13 -07:00
|
|
|
void goBackPossible(bool isPossible);
|
2018-01-11 13:44:16 +13:00
|
|
|
|
2021-05-12 10:54:45 +12:00
|
|
|
/*@jsdoc
|
2018-03-07 15:36:35 -08:00
|
|
|
* Triggered when there's a change in whether or not there's a forward location that can be navigated to using
|
2018-01-11 14:48:45 +13:00
|
|
|
* {@link location.goForward|goForward}. (Reflects changes in the state of the "Goto" dialog's forward arrow.)
|
2018-01-11 13:44:16 +13:00
|
|
|
* @function location.goForwardPossible
|
|
|
|
* @param {boolean} isPossible - <code>true</code> if there's a forward location to navigate to, otherwise
|
|
|
|
* <code>false</code>.
|
|
|
|
* @returns {Signal}
|
|
|
|
* @example <caption>Report when ability to navigate forward changes.</caption>
|
|
|
|
* function onGoForwardPossible(isPossible) {
|
|
|
|
* print("Go forward possible: " + isPossible);
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* location.goForwardPossible.connect(onGoForwardPossible);
|
|
|
|
*/
|
2015-06-16 13:17:13 -07:00
|
|
|
void goForwardPossible(bool isPossible);
|
|
|
|
|
2014-10-28 10:00:39 -07:00
|
|
|
private slots:
|
2018-06-25 16:34:07 -07:00
|
|
|
void handleAPIResponse(QNetworkReply* requestReply);
|
|
|
|
void handleAPIError(QNetworkReply* errorReply);
|
2015-06-16 08:41:21 -07:00
|
|
|
|
2018-06-25 16:34:07 -07:00
|
|
|
void handleShareableNameAPIResponse(QNetworkReply* requestReply);
|
2016-08-22 17:06:43 -07:00
|
|
|
|
2014-09-11 10:14:00 -07:00
|
|
|
private:
|
2018-09-04 17:46:23 -07:00
|
|
|
void goToAddressFromObject(const QVariantMap& addressMap, const QNetworkReply* reply);
|
2016-05-04 15:46:48 -07:00
|
|
|
|
2016-05-16 10:51:41 -07:00
|
|
|
// Set host and port, and return `true` if it was changed.
|
|
|
|
bool setHost(const QString& host, LookupTrigger trigger, quint16 port = 0);
|
2018-03-01 11:07:37 -08:00
|
|
|
bool setDomainInfo(const QUrl& domainURL, LookupTrigger trigger);
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2014-09-11 17:17:47 -07:00
|
|
|
const JSONCallbackParameters& apiCallbackParameters();
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2021-06-15 00:31:28 -04:00
|
|
|
bool handleUrl(const QUrl& lookupUrl, LookupTrigger trigger = UserInput, const QString& lookupUrlInString = "");
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2016-05-16 10:51:41 -07:00
|
|
|
bool handleNetworkAddress(const QString& lookupString, LookupTrigger trigger, bool& hostChanged);
|
2015-06-16 08:41:21 -07:00
|
|
|
void handlePath(const QString& path, LookupTrigger trigger, bool wasPathOnly = false);
|
2018-09-19 09:55:15 -07:00
|
|
|
bool handleViewpoint(const QString& viewpointString, bool shouldFace, LookupTrigger trigger,
|
|
|
|
bool definitelyPathOnly = false, const QString& pathString = QString());
|
2014-09-12 11:19:22 -07:00
|
|
|
bool handleUsername(const QString& lookupString);
|
2015-06-05 10:40:17 -07:00
|
|
|
bool handleDomainID(const QString& host);
|
2015-05-12 13:48:41 -07:00
|
|
|
|
2015-06-16 08:41:21 -07:00
|
|
|
void attemptPlaceNameLookup(const QString& lookupString, const QString& overridePath, LookupTrigger trigger);
|
|
|
|
void attemptDomainIDLookup(const QString& lookupString, const QString& overridePath, LookupTrigger trigger);
|
|
|
|
|
|
|
|
void addCurrentAddressToHistory(LookupTrigger trigger);
|
2015-06-09 18:59:58 -07:00
|
|
|
|
2021-03-29 21:14:00 +13:00
|
|
|
void resetConfirmConnectWithoutAvatarEntities();
|
|
|
|
|
2018-03-01 11:07:37 -08:00
|
|
|
QUrl _domainURL;
|
2018-08-31 19:29:48 -07:00
|
|
|
QUrl _lastVisitedURL;
|
2018-03-01 11:07:37 -08:00
|
|
|
|
2015-01-13 14:21:07 -08:00
|
|
|
QUuid _rootPlaceID;
|
2015-09-24 17:19:50 +02:00
|
|
|
PositionGetter _positionGetter;
|
|
|
|
OrientationGetter _orientationGetter;
|
2015-06-09 18:59:58 -07:00
|
|
|
|
2016-08-22 17:06:43 -07:00
|
|
|
QString _shareablePlaceName;
|
|
|
|
|
2015-06-16 08:41:21 -07:00
|
|
|
QStack<QUrl> _backStack;
|
|
|
|
QStack<QUrl> _forwardStack;
|
|
|
|
quint64 _lastBackPush = 0;
|
|
|
|
|
|
|
|
QString _newHostLookupPath;
|
2018-02-16 12:58:50 -08:00
|
|
|
|
2018-08-31 19:29:48 -07:00
|
|
|
QUrl _previousAPILookup;
|
2014-09-11 10:14:00 -07:00
|
|
|
};
|
|
|
|
|
2018-09-04 17:46:23 -07:00
|
|
|
#endif // hifi_AddressManager_h
|