mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:24:00 +02:00
Merge pull request #3406 from birarda/master
handle location lookup for offline user or not found
This commit is contained in:
commit
4c9dbad779
5 changed files with 50 additions and 23 deletions
|
@ -290,6 +290,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
|
||||
// once the event loop has started, check and signal for an access token
|
||||
QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection);
|
||||
|
||||
AddressManager& addressManager = AddressManager::getInstance();
|
||||
|
||||
// connect to the domainChangeRequired signal on AddressManager
|
||||
connect(&addressManager, &AddressManager::possibleDomainChangeRequired,
|
||||
this, &Application::changeDomainHostname);
|
||||
|
||||
// when -url in command line, teleport to location
|
||||
addressManager.handleLookupString(getCmdOption(argc, constArgv, "-url"));
|
||||
|
||||
_settings = new QSettings(this);
|
||||
_numChangedSettings = 0;
|
||||
|
@ -403,15 +412,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
|
||||
connect(_window, &MainWindow::windowGeometryChanged,
|
||||
_runningScriptsWidget, &RunningScriptsWidget::setBoundary);
|
||||
|
||||
AddressManager& addressManager = AddressManager::getInstance();
|
||||
|
||||
// connect to the domainChangeRequired signal on AddressManager
|
||||
connect(&addressManager, &AddressManager::possibleDomainChangeRequired,
|
||||
this, &Application::changeDomainHostname);
|
||||
|
||||
// when -url in command line, teleport to location
|
||||
addressManager.handleLookupString(getCmdOption(argc, constArgv, "-url"));
|
||||
|
||||
// call the OAuthWebviewHandler static getter so that its instance lives in our thread
|
||||
OAuthWebViewHandler::getInstance();
|
||||
|
@ -810,6 +810,7 @@ bool Application::event(QEvent* event) {
|
|||
|
||||
// handle custom URL
|
||||
if (event->type() == QEvent::FileOpen) {
|
||||
|
||||
QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
|
||||
|
||||
if (!fileEvent->url().isEmpty()) {
|
||||
|
@ -3947,11 +3948,13 @@ void Application::uploadAttachment() {
|
|||
}
|
||||
|
||||
void Application::openUrl(const QUrl& url) {
|
||||
if (url.scheme() == HIFI_URL_SCHEME) {
|
||||
AddressManager::getInstance().handleLookupString(url.toString());
|
||||
} else {
|
||||
// address manager did not handle - ask QDesktopServices to handle
|
||||
QDesktopServices::openUrl(url);
|
||||
if (!url.isEmpty()) {
|
||||
if (url.scheme() == HIFI_URL_SCHEME) {
|
||||
AddressManager::getInstance().handleLookupString(url.toString());
|
||||
} else {
|
||||
// address manager did not handle - ask QDesktopServices to handle
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,9 +142,14 @@ Menu::Menu() :
|
|||
// call our toggle login function now so the menu option is setup properly
|
||||
toggleLoginMenuItem();
|
||||
|
||||
// connect to the appropriate slots of the AccountManager so that we can change the Login/Logout menu item
|
||||
// connect to the appropriate signal of the AccountManager so that we can change the Login/Logout menu item
|
||||
connect(&accountManager, &AccountManager::profileChanged, this, &Menu::toggleLoginMenuItem);
|
||||
connect(&accountManager, &AccountManager::logoutComplete, this, &Menu::toggleLoginMenuItem);
|
||||
|
||||
// connect to signal of account manager so we can tell user when the user/place they looked at is offline
|
||||
AddressManager& addressManager = AddressManager::getInstance();
|
||||
connect(&addressManager, &AddressManager::lookupResultIsOffline, this, &Menu::displayAddressOfflineMessage);
|
||||
connect(&addressManager, &AddressManager::lookupResultIsNotFound, this, &Menu::displayAddressNotFoundMessage);
|
||||
|
||||
addDisabledActionAndSeparator(fileMenu, "Scripts");
|
||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScript, Qt::CTRL | Qt::Key_O, appInstance, SLOT(loadDialog()));
|
||||
|
@ -1158,6 +1163,16 @@ void Menu::toggleAddressBar() {
|
|||
sendFakeEnterEvent();
|
||||
}
|
||||
|
||||
void Menu::displayAddressOfflineMessage() {
|
||||
QMessageBox::information(Application::getInstance()->getWindow(), "Address offline",
|
||||
"That user or place is currently offline.");
|
||||
}
|
||||
|
||||
void Menu::displayAddressNotFoundMessage() {
|
||||
QMessageBox::information(Application::getInstance()->getWindow(), "Address not found",
|
||||
"There is no address information for that user or place.");
|
||||
}
|
||||
|
||||
void Menu::muteEnvironment() {
|
||||
int headerSize = numBytesForPacketHeaderGivenPacketType(PacketTypeMuteEnvironment);
|
||||
int packetSize = headerSize + sizeof(glm::vec3) + sizeof(float);
|
||||
|
|
|
@ -219,6 +219,8 @@ private slots:
|
|||
void toggleChat();
|
||||
void audioMuteToggled();
|
||||
void displayNameLocationResponse(const QString& errorString);
|
||||
void displayAddressOfflineMessage();
|
||||
void displayAddressNotFoundMessage();
|
||||
void muteEnvironment();
|
||||
|
||||
private:
|
||||
|
|
|
@ -52,6 +52,8 @@ const JSONCallbackParameters& AddressManager::apiCallbackParameters() {
|
|||
bool AddressManager::handleUrl(const QUrl& lookupUrl) {
|
||||
if (lookupUrl.scheme() == HIFI_URL_SCHEME) {
|
||||
|
||||
qDebug() << "Trying to go to URL" << lookupUrl.toString();
|
||||
|
||||
// there are 4 possible lookup strings
|
||||
|
||||
// 1. global place name (name of domain or place) - example: sanfrancisco
|
||||
|
@ -59,8 +61,6 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl) {
|
|||
// 3. location string (posX,posY,posZ/eulerX,eulerY,eulerZ)
|
||||
// 4. domain network address (IP or dns resolvable hostname)
|
||||
|
||||
qDebug() << lookupUrl;
|
||||
|
||||
if (lookupUrl.isRelative()) {
|
||||
// if this is a relative path then handle it as a relative viewpoint
|
||||
handleRelativeViewpoint(lookupUrl.path());
|
||||
|
@ -86,12 +86,14 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl) {
|
|||
}
|
||||
|
||||
void AddressManager::handleLookupString(const QString& lookupString) {
|
||||
// we've verified that this is a valid hifi URL - hand it off to handleLookupString
|
||||
QString sanitizedString = lookupString;
|
||||
const QRegExp HIFI_SCHEME_REGEX = QRegExp(HIFI_URL_SCHEME + ":\\/{1,2}", Qt::CaseInsensitive);
|
||||
sanitizedString = sanitizedString.remove(HIFI_SCHEME_REGEX);
|
||||
|
||||
handleUrl(QUrl(HIFI_URL_SCHEME + "://" + sanitizedString));
|
||||
if (!lookupString.isEmpty()) {
|
||||
// make this a valid hifi URL and handle it off to handleUrl
|
||||
QString sanitizedString = lookupString;
|
||||
const QRegExp HIFI_SCHEME_REGEX = QRegExp(HIFI_URL_SCHEME + ":\\/{1,2}", Qt::CaseInsensitive);
|
||||
sanitizedString = sanitizedString.remove(HIFI_SCHEME_REGEX);
|
||||
|
||||
handleUrl(QUrl(HIFI_URL_SCHEME + "://" + sanitizedString));
|
||||
}
|
||||
}
|
||||
|
||||
void AddressManager::handleAPIResponse(const QJsonObject &jsonObject) {
|
||||
|
@ -141,6 +143,10 @@ void AddressManager::handleAPIResponse(const QJsonObject &jsonObject) {
|
|||
|
||||
void AddressManager::handleAPIError(QNetworkReply& errorReply) {
|
||||
qDebug() << "AddressManager API error -" << errorReply.error() << "-" << errorReply.errorString();
|
||||
|
||||
if (errorReply.error() == QNetworkReply::ContentNotFoundError) {
|
||||
emit lookupResultIsNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
const QString GET_PLACE = "/api/v1/places/%1";
|
||||
|
|
|
@ -38,6 +38,7 @@ public slots:
|
|||
void goToUser(const QString& username);
|
||||
signals:
|
||||
void lookupResultIsOffline();
|
||||
void lookupResultIsNotFound();
|
||||
void possibleDomainChangeRequired(const QString& newHostname);
|
||||
void locationChangeRequired(const glm::vec3& newPosition, bool hasOrientationChange, const glm::vec3& newOrientation);
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue