From 1af87e57dadca6eb3283ff52354a382283e658ce Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 13 Jan 2015 14:21:07 -0800 Subject: [PATCH 01/16] handle new places API format in AddressManager --- libraries/networking/src/AddressManager.cpp | 39 ++++++++++++--------- libraries/networking/src/AddressManager.h | 3 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index 23aa8dad72..e6ad3220c2 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -22,7 +22,8 @@ #include "AddressManager.h" AddressManager::AddressManager() : - _currentDomain(), + _rootPlaceName(), + _rootPlaceID(), _positionGetter(NULL), _orientationGetter(NULL) { @@ -37,7 +38,7 @@ const QUrl AddressManager::currentAddress() const { QUrl hifiURL; hifiURL.setScheme(HIFI_URL_SCHEME); - hifiURL.setHost(_currentDomain); + hifiURL.setHost(_rootPlaceName); hifiURL.setPath(currentPath()); return hifiURL; @@ -174,15 +175,21 @@ void AddressManager::handleAPIResponse(QNetworkReply& requestReply) { } void AddressManager::goToAddressFromObject(const QVariantMap& addressMap) { + const QString ADDRESS_API_ROOT_KEY = "root"; const QString ADDRESS_API_DOMAIN_KEY = "domain"; const QString ADDRESS_API_ONLINE_KEY = "online"; if (!addressMap.contains(ADDRESS_API_ONLINE_KEY) || addressMap[ADDRESS_API_ONLINE_KEY].toBool()) { - if (addressMap.contains(ADDRESS_API_DOMAIN_KEY)) { - QVariantMap domainObject = addressMap[ADDRESS_API_DOMAIN_KEY].toMap(); - + QVariantMap rootMap = addressMap[ADDRESS_API_ROOT_KEY].toMap(); + if (rootMap.isEmpty()) { + rootMap = addressMap; + } + + QVariantMap domainObject = rootMap[ADDRESS_API_DOMAIN_KEY].toMap(); + + if (!domainObject.isEmpty()) { const QString DOMAIN_NETWORK_ADDRESS_KEY = "network_address"; const QString DOMAIN_ICE_SERVER_ADDRESS_KEY = "ice_server_address"; @@ -200,22 +207,22 @@ void AddressManager::goToAddressFromObject(const QVariantMap& addressMap) { emit possibleDomainChangeRequiredViaICEForID(iceServerAddress, domainID); } - // set our current domain to the name that came back - const QString DOMAIN_NAME_KEY = "name"; + // set our current root place id to the ID that came back + const QString PLACE_ID_KEY = "id"; + _rootPlaceID = rootMap[PLACE_ID_KEY].toUuid(); - _currentDomain = domainObject[DOMAIN_NAME_KEY].toString(); + // set our current root place name to the name that came back + const QString PLACE_NAME_KEY = "name"; + _rootPlaceName = rootMap[PLACE_NAME_KEY].toString(); // take the path that came back - const QString LOCATION_KEY = "location"; - const QString LOCATION_PATH_KEY = "path"; + const QString PLACE_PATH_KEY = "path"; QString returnedPath; - if (domainObject.contains(LOCATION_PATH_KEY)) { - returnedPath = domainObject[LOCATION_PATH_KEY].toString(); - } else if (domainObject.contains(LOCATION_KEY)) { - returnedPath = domainObject[LOCATION_KEY].toMap()[LOCATION_PATH_KEY].toString(); - } else if (addressMap.contains(LOCATION_PATH_KEY)) { - returnedPath = addressMap[LOCATION_PATH_KEY].toString(); + if (addressMap.contains(PLACE_PATH_KEY) && !addressMap[PLACE_PATH_KEY].toString().isEmpty()) { + returnedPath = addressMap[PLACE_PATH_KEY].toString(); + } else if (rootMap.contains(PLACE_PATH_KEY) && !rootMap[PLACE_PATH_KEY].toString().isEmpty()) { + returnedPath = rootMap[PLACE_PATH_KEY].toString(); } bool shouldFaceViewpoint = addressMap.contains(ADDRESS_API_ONLINE_KEY); diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index dee070740f..ac4200d675 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -85,7 +85,8 @@ private: bool handleRelativeViewpoint(const QString& pathSubsection, bool shouldFace = false); bool handleUsername(const QString& lookupString); - QString _currentDomain; + QString _rootPlaceName; + QUuid _rootPlaceID; PositionGetter _positionGetter; OrientationGetter _orientationGetter; }; From 16261a5fc1ba0be82f4d81c563a4338310b88259 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 13 Jan 2015 14:49:24 -0800 Subject: [PATCH 02/16] more updates for new place/location APIs --- interface/src/Application.cpp | 2 +- libraries/networking/src/AddressManager.cpp | 140 +++++++++++--------- libraries/networking/src/AddressManager.h | 8 +- 3 files changed, 81 insertions(+), 69 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 22a2b6bc22..6960f2d025 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3112,7 +3112,7 @@ void Application::updateWindowTitle(){ QString connectionStatus = nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED) "; QString username = AccountManager::getInstance().getAccountInfo().getUsername(); QString title = QString() + (!username.isEmpty() ? username + " @ " : QString()) - + DependencyManager::get()->getCurrentDomain() + connectionStatus + buildVersion; + + DependencyManager::get()->getRootPlaceName() + connectionStatus + buildVersion; #ifndef WIN32 // crashes with vs2013/win32 diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index e6ad3220c2..8ca0226a34 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -89,11 +89,6 @@ const QString AddressManager::currentPath(bool withOrientation) const { } } -QString AddressManager::getDomainID() const { - const QUuid& domainID = NodeList::getInstance()->getDomainHandler().getUUID(); - return domainID.isNull() ? "" : uuidStringWithoutCurlyBraces(domainID); -} - const JSONCallbackParameters& AddressManager::apiCallbackParameters() { static bool hasSetupParameters = false; static JSONCallbackParameters callbackParams; @@ -174,73 +169,90 @@ void AddressManager::handleAPIResponse(QNetworkReply& requestReply) { emit lookupResultsFinished(); } -void AddressManager::goToAddressFromObject(const QVariantMap& addressMap) { - const QString ADDRESS_API_ROOT_KEY = "root"; - const QString ADDRESS_API_DOMAIN_KEY = "domain"; - const QString ADDRESS_API_ONLINE_KEY = "online"; +void AddressManager::goToAddressFromObject(const QVariantMap& dataObject) { - if (!addressMap.contains(ADDRESS_API_ONLINE_KEY) - || addressMap[ADDRESS_API_ONLINE_KEY].toBool()) { - - QVariantMap rootMap = addressMap[ADDRESS_API_ROOT_KEY].toMap(); - if (rootMap.isEmpty()) { - rootMap = addressMap; - } - - QVariantMap domainObject = rootMap[ADDRESS_API_DOMAIN_KEY].toMap(); + const QString DATA_OBJECT_PLACE_KEY = "place"; + const QString DATA_OBJECT_USER_LOCATION_KEY = "location"; - if (!domainObject.isEmpty()) { - const QString DOMAIN_NETWORK_ADDRESS_KEY = "network_address"; - const QString DOMAIN_ICE_SERVER_ADDRESS_KEY = "ice_server_address"; + QVariantMap locationMap; + if (dataObject.contains(DATA_OBJECT_PLACE_KEY)) { + locationMap = dataObject[DATA_OBJECT_PLACE_KEY].toMap(); + } else { + locationMap = dataObject[DATA_OBJECT_USER_LOCATION_KEY].toMap(); + } + + qDebug() << locationMap; + + if (!locationMap.isEmpty()) { + const QString LOCATION_API_ROOT_KEY = "root"; + const QString LOCATION_API_DOMAIN_KEY = "domain"; + const QString LOCATION_API_ONLINE_KEY = "online"; + + if (!locationMap.contains(LOCATION_API_ONLINE_KEY) + || locationMap[LOCATION_API_ONLINE_KEY].toBool()) { - if (domainObject.contains(DOMAIN_NETWORK_ADDRESS_KEY)) { - QString domainHostname = domainObject[DOMAIN_NETWORK_ADDRESS_KEY].toString(); - - emit possibleDomainChangeRequired(domainHostname, DEFAULT_DOMAIN_SERVER_PORT); - } else { - 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); - - emit possibleDomainChangeRequiredViaICEForID(iceServerAddress, domainID); + QVariantMap rootMap = locationMap[LOCATION_API_ROOT_KEY].toMap(); + if (rootMap.isEmpty()) { + rootMap = locationMap; } - // set our current root place id to the ID that came back - const QString PLACE_ID_KEY = "id"; - _rootPlaceID = rootMap[PLACE_ID_KEY].toUuid(); + QVariantMap domainObject = rootMap[LOCATION_API_DOMAIN_KEY].toMap(); - // set our current root place name to the name that came back - const QString PLACE_NAME_KEY = "name"; - _rootPlaceName = rootMap[PLACE_NAME_KEY].toString(); - - // take the path that came back - const QString PLACE_PATH_KEY = "path"; - QString returnedPath; - - if (addressMap.contains(PLACE_PATH_KEY) && !addressMap[PLACE_PATH_KEY].toString().isEmpty()) { - returnedPath = addressMap[PLACE_PATH_KEY].toString(); - } else if (rootMap.contains(PLACE_PATH_KEY) && !rootMap[PLACE_PATH_KEY].toString().isEmpty()) { - returnedPath = rootMap[PLACE_PATH_KEY].toString(); - } - - bool shouldFaceViewpoint = addressMap.contains(ADDRESS_API_ONLINE_KEY); - - if (!returnedPath.isEmpty()) { - // try to parse this returned path as a viewpoint, that's the only thing it could be for now - if (!handleRelativeViewpoint(returnedPath, shouldFaceViewpoint)) { - qDebug() << "Received a location path that was could not be handled as a viewpoint -" << returnedPath; + if (!domainObject.isEmpty()) { + const QString DOMAIN_NETWORK_ADDRESS_KEY = "network_address"; + const QString DOMAIN_ICE_SERVER_ADDRESS_KEY = "ice_server_address"; + + if (domainObject.contains(DOMAIN_NETWORK_ADDRESS_KEY)) { + QString domainHostname = domainObject[DOMAIN_NETWORK_ADDRESS_KEY].toString(); + + emit possibleDomainChangeRequired(domainHostname, DEFAULT_DOMAIN_SERVER_PORT); + } else { + 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); + + emit possibleDomainChangeRequiredViaICEForID(iceServerAddress, domainID); } + + // set our current root place id to the ID that came back + const QString PLACE_ID_KEY = "id"; + _rootPlaceID = rootMap[PLACE_ID_KEY].toUuid(); + + // set our current root place name to the name that came back + const QString PLACE_NAME_KEY = "name"; + _rootPlaceName = rootMap[PLACE_NAME_KEY].toString(); + + // take the path that came back + const QString PLACE_PATH_KEY = "path"; + QString returnedPath; + + if (locationMap.contains(PLACE_PATH_KEY) && !locationMap[PLACE_PATH_KEY].toString().isEmpty()) { + returnedPath = locationMap[PLACE_PATH_KEY].toString(); + } else if (rootMap.contains(PLACE_PATH_KEY) && !rootMap[PLACE_PATH_KEY].toString().isEmpty()) { + returnedPath = rootMap[PLACE_PATH_KEY].toString(); + } + + bool shouldFaceViewpoint = locationMap.contains(LOCATION_API_ONLINE_KEY); + + if (!returnedPath.isEmpty()) { + // try to parse this returned path as a viewpoint, that's the only thing it could be for now + if (!handleRelativeViewpoint(returnedPath, shouldFaceViewpoint)) { + qDebug() << "Received a location path that was could not be handled as a viewpoint -" << returnedPath; + } + } + } else { + qDebug() << "Received an address manager API response with no domain key. Cannot parse."; + qDebug() << locationMap; } - } else { - qDebug() << "Received an address manager API response with no domain key. Cannot parse."; - qDebug() << addressMap; + // we've been told that this result exists but is offline, emit our signal so the application can handle + emit lookupResultIsOffline(); } } else { - // we've been told that this result exists but is offline, emit our signal so the application can handle - emit lookupResultIsOffline(); + qDebug() << "Received an address manager API response with no location key or place key. Cannot parse."; + qDebug() << locationMap; } } @@ -373,8 +385,10 @@ bool AddressManager::handleUsername(const QString& lookupString) { } -void AddressManager::setDomainInfo(const QString& hostname, quint16 port, const QString& domainName) { - _currentDomain = domainName.isEmpty() ? hostname : domainName; +void AddressManager::setDomainInfo(const QString& hostname, quint16 port) { + _rootPlaceName = hostname; + _rootPlaceID = QUuid(); + emit possibleDomainChangeRequired(hostname, port); } diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index ac4200d675..e98526689b 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -33,9 +33,8 @@ class AddressManager : public QObject { Q_PROPERTY(bool isConnected READ isConnected) Q_PROPERTY(QUrl href READ currentAddress) Q_PROPERTY(QString protocol READ getProtocol) - Q_PROPERTY(QString hostname READ getCurrentDomain) + Q_PROPERTY(QString hostname READ getRootPlaceName) Q_PROPERTY(QString pathname READ currentPath) - Q_PROPERTY(QString domainID READ getDomainID) public: bool isConnected(); const QString& getProtocol() { return HIFI_URL_SCHEME; }; @@ -43,8 +42,7 @@ public: const QUrl currentAddress() const; const QString currentPath(bool withOrientation = true) const; - const QString& getCurrentDomain() const { return _currentDomain; } - QString getDomainID() const; + const QString& getRootPlaceName() const { return _rootPlaceName; } void attemptPlaceNameLookup(const QString& lookupString); @@ -75,7 +73,7 @@ private slots: void handleAPIResponse(QNetworkReply& requestReply); void handleAPIError(QNetworkReply& errorReply); private: - void setDomainInfo(const QString& hostname, quint16 port, const QString& domainName = QString()); + void setDomainInfo(const QString& hostname, quint16 port); const JSONCallbackParameters& apiCallbackParameters(); From 92b8cd2d1e888e23d66d10c54ff939c5ef56b817 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 13 Jan 2015 15:02:04 -0800 Subject: [PATCH 03/16] handle storage of user location in new format --- interface/src/Application.cpp | 19 ++++++++++++++----- libraries/networking/src/AddressManager.h | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6960f2d025..c156de03ca 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3124,23 +3124,32 @@ void Application::updateWindowTitle(){ void Application::updateLocationInServer() { AccountManager& accountManager = AccountManager::getInstance(); + AddressManager::SharedPointer addressManager = DependencyManager::get(); DomainHandler& domainHandler = NodeList::getInstance()->getDomainHandler(); - if (accountManager.isLoggedIn() && domainHandler.isConnected() && !domainHandler.getUUID().isNull()) { + if (accountManager.isLoggedIn() && domainHandler.isConnected() + && (!addressManager->getRootPlaceID().isNull() || !domainHandler.getUUID().isNull())) { // construct a QJsonObject given the user's current address information QJsonObject rootObject; QJsonObject locationObject; - QString pathString = DependencyManager::get()->currentPath(); + QString pathString = addressManager->currentPath(); const QString LOCATION_KEY_IN_ROOT = "location"; - const QString PATH_KEY_IN_LOCATION = "path"; - const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id"; + const QString PATH_KEY_IN_LOCATION = "path"; locationObject.insert(PATH_KEY_IN_LOCATION, pathString); - locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, domainHandler.getUUID().toString()); + + if (!addressManager->getRootPlaceID().isNull()) { + const QString PLACE_ID_KEY_IN_LOCATION = "place_id"; + locationObject.insert(PLACE_ID_KEY_IN_LOCATION, addressManager->getRootPlaceID().toString()); + + } else { + const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id"; + locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, domainHandler.getUUID().toString()); + } rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject); diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index e98526689b..a8adf57741 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -42,6 +42,7 @@ public: const QUrl currentAddress() const; const QString currentPath(bool withOrientation = true) const; + const QUuid& getRootPlaceID() const { return _rootPlaceID; } const QString& getRootPlaceName() const { return _rootPlaceName; } void attemptPlaceNameLookup(const QString& lookupString); From 6e1ba17c6eda08361d660596436eb2e3c7f79325 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 13 Jan 2015 15:07:45 -0800 Subject: [PATCH 04/16] handle application title change for place name change --- interface/src/Application.cpp | 2 ++ libraries/networking/src/AddressManager.cpp | 12 +++++++++--- libraries/networking/src/AddressManager.h | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c156de03ca..ecc36d7f05 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -306,6 +306,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : // use our MyAvatar position and quat for address manager path addressManager->setPositionGetter(getPositionForPath); addressManager->setOrientationGetter(getOrientationForPath); + + connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle); _settings = new QSettings(this); _numChangedSettings = 0; diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index 8ca0226a34..4802f3ca15 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -181,8 +181,6 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject) { locationMap = dataObject[DATA_OBJECT_USER_LOCATION_KEY].toMap(); } - qDebug() << locationMap; - if (!locationMap.isEmpty()) { const QString LOCATION_API_ROOT_KEY = "root"; const QString LOCATION_API_DOMAIN_KEY = "domain"; @@ -222,7 +220,8 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject) { // set our current root place name to the name that came back const QString PLACE_NAME_KEY = "name"; - _rootPlaceName = rootMap[PLACE_NAME_KEY].toString(); + QString newRootPlaceName = rootMap[PLACE_NAME_KEY].toString(); + setRootPlaceName(newRootPlaceName); // take the path that came back const QString PLACE_PATH_KEY = "path"; @@ -384,6 +383,13 @@ bool AddressManager::handleUsername(const QString& lookupString) { return false; } +void AddressManager::setRootPlaceName(const QString& rootPlaceName) { + if (rootPlaceName != _rootPlaceName) { + _rootPlaceName = rootPlaceName; + emit rootPlaceNameChanged(_rootPlaceName); + } +} + void AddressManager::setDomainInfo(const QString& hostname, quint16 port) { _rootPlaceName = hostname; diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index a8adf57741..6cb5cdbf60 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -43,7 +43,9 @@ public: const QString currentPath(bool withOrientation = true) const; const QUuid& getRootPlaceID() const { return _rootPlaceID; } + const QString& getRootPlaceName() const { return _rootPlaceName; } + void setRootPlaceName(const QString& rootPlaceName); void attemptPlaceNameLookup(const QString& lookupString); @@ -68,6 +70,7 @@ signals: void locationChangeRequired(const glm::vec3& newPosition, bool hasOrientationChange, const glm::quat& newOrientation, bool shouldFaceLocation); + void rootPlaceNameChanged(const QString& newRootPlaceName); protected: AddressManager(); private slots: From 6d2c87c7a3faf7f4deca34c2cb17a266c10a8e14 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 13 Jan 2015 15:15:39 -0800 Subject: [PATCH 05/16] put current domain hostname if no place name present --- interface/src/Application.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ecc36d7f05..8c82281007 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3113,8 +3113,14 @@ void Application::updateWindowTitle(){ QString connectionStatus = nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED) "; QString username = AccountManager::getInstance().getAccountInfo().getUsername(); + QString currentPlaceName = DependencyManager::get()->getRootPlaceName(); + + if (currentPlaceName.isEmpty()) { + currentPlaceName = nodeList->getDomainHandler().getHostname(); + } + QString title = QString() + (!username.isEmpty() ? username + " @ " : QString()) - + DependencyManager::get()->getRootPlaceName() + connectionStatus + buildVersion; + + currentPlaceName + connectionStatus + buildVersion; #ifndef WIN32 // crashes with vs2013/win32 From b8b5b2b6ecd3d815092d4932a19404843f9c13ae Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 14 Jan 2015 16:56:49 -0800 Subject: [PATCH 06/16] don't check the root object for path --- libraries/networking/src/AddressManager.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index 4802f3ca15..76a974c7ef 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -225,13 +225,7 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject) { // take the path that came back const QString PLACE_PATH_KEY = "path"; - QString returnedPath; - - if (locationMap.contains(PLACE_PATH_KEY) && !locationMap[PLACE_PATH_KEY].toString().isEmpty()) { - returnedPath = locationMap[PLACE_PATH_KEY].toString(); - } else if (rootMap.contains(PLACE_PATH_KEY) && !rootMap[PLACE_PATH_KEY].toString().isEmpty()) { - returnedPath = rootMap[PLACE_PATH_KEY].toString(); - } + QString returnedPath = locationMap[PLACE_PATH_KEY].toString(); bool shouldFaceViewpoint = locationMap.contains(LOCATION_API_ONLINE_KEY); From e5fe24e088166ab167af7b3a0254fa79a3369fc5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 14 Jan 2015 16:58:15 -0800 Subject: [PATCH 07/16] remove My Locations and Name This Location --- interface/src/Menu.cpp | 70 ------------------------------------------ interface/src/Menu.h | 4 --- 2 files changed, 74 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 996bb6a641..2079805379 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -123,16 +123,6 @@ Menu::Menu() : appInstance, SLOT(toggleRunningScriptsWidget())); addDisabledActionAndSeparator(fileMenu, "Go"); - addActionToQMenuAndActionHash(fileMenu, - MenuOption::NameLocation, - Qt::CTRL | Qt::Key_N, - this, - SLOT(nameLocation())); - addActionToQMenuAndActionHash(fileMenu, - MenuOption::MyLocations, - Qt::CTRL | Qt::Key_K, - this, - SLOT(toggleLocationList())); addActionToQMenuAndActionHash(fileMenu, MenuOption::AddressBar, Qt::Key_Enter, @@ -1019,66 +1009,6 @@ void Menu::displayNameLocationResponse(const QString& errorString) { } } -void Menu::toggleLocationList() { - if (!_userLocationsDialog) { - JavascriptObjectMap locationObjectMap; - locationObjectMap.insert("InterfaceLocation", DependencyManager::get().data()); - _userLocationsDialog = DataWebDialog::dialogForPath("/user/locations", locationObjectMap); - } - - if (!_userLocationsDialog->isVisible()) { - _userLocationsDialog->show(); - } - - _userLocationsDialog->raise(); - _userLocationsDialog->activateWindow(); - _userLocationsDialog->showNormal(); - -} - -void Menu::nameLocation() { - // check if user is logged in or show login dialog if not - - AccountManager& accountManager = AccountManager::getInstance(); - - if (!accountManager.isLoggedIn()) { - QMessageBox msgBox; - msgBox.setText("We need to tie this location to your username."); - msgBox.setInformativeText("Please login first, then try naming the location again."); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.button(QMessageBox::Ok)->setText("Login"); - - if (msgBox.exec() == QMessageBox::Ok) { - loginForCurrentDomain(); - } - - return; - } - - DomainHandler& domainHandler = NodeList::getInstance()->getDomainHandler(); - if (domainHandler.getUUID().isNull()) { - const QString UNREGISTERED_DOMAIN_MESSAGE = "This domain is not registered with High Fidelity." - "\n\nYou cannot create a global location in an unregistered domain."; - QMessageBox::critical(this, "Unregistered Domain", UNREGISTERED_DOMAIN_MESSAGE); - - return; - } - - if (!_newLocationDialog) { - JavascriptObjectMap locationObjectMap; - locationObjectMap.insert("InterfaceLocation", DependencyManager::get().data()); - _newLocationDialog = DataWebDialog::dialogForPath("/user/locations/new", locationObjectMap); - } - - if (!_newLocationDialog->isVisible()) { - _newLocationDialog->show(); - } - - _newLocationDialog->raise(); - _newLocationDialog->activateWindow(); - _newLocationDialog->showNormal(); -} - void Menu::toggleLoginMenuItem() { AccountManager& accountManager = AccountManager::getInstance(); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 6f30ca983b..6f4af7f7cf 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -286,8 +286,6 @@ private: QPointer _attachmentsDialog; QPointer _bandwidthDialog; QPointer _cachesSizeDialog; - QPointer _newLocationDialog; - QPointer _userLocationsDialog; QPointer _hmdToolsDialog; QPointer _lodToolsDialog; QPointer _loginDialog; @@ -397,8 +395,6 @@ namespace MenuOption { const QString Mirror = "Mirror"; const QString MuteAudio = "Mute Microphone"; const QString MuteEnvironment = "Mute Environment"; - const QString MyLocations = "My Locations..."; - const QString NameLocation = "Name this location"; const QString NetworkSimulator = "Network Simulator..."; const QString NewVoxelCullingMode = "New Voxel Culling Mode"; const QString ObeyEnvironmentalGravity = "Obey Environmental Gravity"; From 69869a696beab33aee60ef58c3fd6cc0785308dc Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 14 Jan 2015 17:00:21 -0800 Subject: [PATCH 08/16] remove name this location call from application --- interface/src/Application.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c24dd69649..9ad4fe96cb 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -884,13 +884,6 @@ void Application::keyPressEvent(QKeyEvent* event) { Menu::getInstance()->triggerOption(MenuOption::Chat); break; - case Qt::Key_N: - if (isMeta) { - Menu::getInstance()->triggerOption(MenuOption::NameLocation); - } - - break; - case Qt::Key_Up: if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { if (!isShifted) { From ef87b59a0c2b854fcc2c91c180796a494b6fb782 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 14 Jan 2015 17:02:18 -0800 Subject: [PATCH 09/16] remove method declarations for location changes --- interface/src/Menu.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 6f4af7f7cf..3ac47f752a 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -200,8 +200,6 @@ private slots: void editAttachments(); void editAnimations(); void changePrivateKey(); - void nameLocation(); - void toggleLocationList(); void hmdToolsClosed(); void runTests(); void showMetavoxelEditor(); From 79d214619deb343d66a6ee02c530474045f01080 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 14 Jan 2015 18:18:26 -0800 Subject: [PATCH 10/16] update lobby for new places API --- examples/lobby.js | 52 +++++++++---------- .../scripting/LocationScriptingInterface.cpp | 13 ++--- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/examples/lobby.js b/examples/lobby.js index 15a8aca328..829f399e06 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -66,20 +66,20 @@ function textOverlayPosition() { Vec3.multiply(Quat.getUp(Camera.orientation), TEXT_DISTANCE_DOWN)); } -var panelLocationOrder = [ +var panelPlaceOrder = [ 7, 8, 9, 10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6, 14, 15, 16, 17, 18, 19, 20 ]; -// Location index is 0-based -function locationIndexToPanelIndex(locationIndex) { - return panelLocationOrder.indexOf(locationIndex) + 1; +// place index is 0-based +function placeIndexToPanelIndex(placeIndex) { + return panelPlaceOrder.indexOf(placeIndex) + 1; } // Panel index is 1-based -function panelIndexToLocationIndex(panelIndex) { - return panelLocationOrder[panelIndex - 1]; +function panelIndexToPlaceIndex(panelIndex) { + return panelPlaceOrder[panelIndex - 1]; } var MAX_NUM_PANELS = 21; @@ -148,25 +148,25 @@ function drawLobby() { } } -var locations = {}; +var places = {}; function changeLobbyTextures() { var req = new XMLHttpRequest(); - req.open("GET", "https://data.highfidelity.io/api/v1/locations?limit=21", false); + req.open("GET", "https://data.highfidelity.io/api/v1/places?limit=21", false); req.send(); - locations = JSON.parse(req.responseText).data.locations; + places = JSON.parse(req.responseText).data.places; - var NUM_PANELS = locations.length; + var NUM_PANELS = places.length; var textureProp = { textures: {} }; for (var j = 0; j < NUM_PANELS; j++) { - var panelIndex = locationIndexToPanelIndex(j); - textureProp["textures"]["file" + panelIndex] = HIFI_PUBLIC_BUCKET + "images/locations/" - + locations[j].id + "/hifi-location-" + locations[j].id + "_640x360.jpg"; + var panelIndex = placeIndexToPanelIndex(j); + textureProp["textures"]["file" + panelIndex] = HIFI_PUBLIC_BUCKET + "images/places/" + + place[j].id + "/hifi-place-" + place[j].id + "_640x360.jpg"; }; Overlays.editOverlay(panelWall, textureProp); @@ -234,7 +234,7 @@ function cleanupLobby() { Audio.stopInjector(currentMuzakInjector); currentMuzakInjector = null; - locations = {}; + places = {}; toggleEnvironmentRendering(true); MyAvatar.detachOne(HELMET_ATTACHMENT_URL); @@ -252,14 +252,14 @@ function actionStartEvent(event) { var panelStringIndex = panelName.indexOf("Panel"); if (panelStringIndex != -1) { var panelIndex = parseInt(panelName.slice(5)); - var locationIndex = panelIndexToLocationIndex(panelIndex); - if (locationIndex < locations.length) { - var actionLocation = locations[locationIndex]; + var placeIndex = panelIndexToPlaceIndex(panelIndex); + if (placeIndex < place.length) { + var actionPlace = places[placeIndex]; - print("Jumping to " + actionLocation.name + " at " + actionLocation.path - + " in " + actionLocation.domain.name + " after click on panel " + panelIndex + " with location index " + locationIndex); + print("Jumping to " + actionPlace.name + " at " + actionPlace.address + + " after click on panel " + panelIndex + " with place index " + placeIndex); - Window.location = actionLocation; + Window.location = actionPlace.address; maybeCleanupLobby(); } } @@ -302,15 +302,15 @@ function handleLookAt(pickRay) { var panelStringIndex = panelName.indexOf("Panel"); if (panelStringIndex != -1) { var panelIndex = parseInt(panelName.slice(5)); - var locationIndex = panelIndexToLocationIndex(panelIndex); - if (locationIndex < locations.length) { - var actionLocation = locations[locationIndex]; + var placeIndex = panelIndexToPlaceIndex(panelIndex); + if (placeIndex < places.length) { + var actionPlace = places[placeIndex]; - if (actionLocation.description == "") { - Overlays.editOverlay(descriptionText, { text: actionLocation.name, visible: showText }); + if (actionPlace.description == "") { + Overlays.editOverlay(descriptionText, { text: actionPlace.name, visible: showText }); } else { // handle line wrapping - var allWords = actionLocation.description.split(" "); + var allWords = actionPlace.description.split(" "); var currentGoodLine = ""; var currentTestLine = ""; var formatedDescription = ""; diff --git a/interface/src/scripting/LocationScriptingInterface.cpp b/interface/src/scripting/LocationScriptingInterface.cpp index fda9875837..c0a9a62ff3 100644 --- a/interface/src/scripting/LocationScriptingInterface.cpp +++ b/interface/src/scripting/LocationScriptingInterface.cpp @@ -25,16 +25,9 @@ QScriptValue LocationScriptingInterface::locationGetter(QScriptContext* context, QScriptValue LocationScriptingInterface::locationSetter(QScriptContext* context, QScriptEngine* engine) { const QVariant& argumentVariant = context->argument(0).toVariant(); - - if (argumentVariant.canConvert(QMetaType::QVariantMap)) { - // this argument is a variant map, so we'll assume it's an address map - QMetaObject::invokeMethod(DependencyManager::get().data(), "goToAddressFromObject", - Q_ARG(const QVariantMap&, argumentVariant.toMap())); - } else { - // just try and convert the argument to a string, should be a hifi:// address - QMetaObject::invokeMethod(DependencyManager::get().data(), "handleLookupString", - Q_ARG(const QString&, argumentVariant.toString())); - } + // just try and convert the argument to a string, should be a hifi:// address + QMetaObject::invokeMethod(DependencyManager::get().data(), "handleLookupString", + Q_ARG(const QString&, argumentVariant.toString())); return QScriptValue::UndefinedValue; } From 93c3b2fb74352c77358fb35329e07173eb61830b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 15 Jan 2015 13:14:26 -0800 Subject: [PATCH 11/16] repairs for new DependencyManager format --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 46ebe98564..dbc409bac2 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3165,8 +3165,8 @@ void Application::updateWindowTitle(){ void Application::updateLocationInServer() { AccountManager& accountManager = AccountManager::getInstance(); - AddressManager::SharedPointer addressManager = DependencyManager::get(); - DomainHandler& domainHandler = NodeList::getInstance()->getDomainHandler(); + auto addressManager = DependencyManager::get(); + DomainHandler& domainHandler = DependencyManager::get()->getDomainHandler(); if (accountManager.isLoggedIn() && domainHandler.isConnected() && (!addressManager->getRootPlaceID().isNull() || !domainHandler.getUUID().isNull())) { From 250a3de9fe23d889bfc4fb8d8c20a54acb60f7e5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 15 Jan 2015 13:34:33 -0800 Subject: [PATCH 12/16] make node mutex in LimitedNodeList recursive for double read lock --- libraries/networking/src/LimitedNodeList.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 6f79b248cf..5bf416af7f 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -41,6 +41,7 @@ const QUrl DEFAULT_NODE_AUTH_URL = QUrl("https://data.highfidelity.io"); LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short dtlsListenPort) : _sessionUUID(), _nodeHash(), + _nodeMutex(QReadWriteLock::Recursive), _nodeSocket(this), _dtlsSocket(NULL), _localSockAddr(), From 786c0a5462b2092628a6fe3dd42954d402948d4f Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 15 Jan 2015 14:00:45 -0800 Subject: [PATCH 13/16] Drop DM ref before creating new object --- libraries/shared/src/DependencyManager.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/shared/src/DependencyManager.h b/libraries/shared/src/DependencyManager.h index e996e10590..3868bf14da 100644 --- a/libraries/shared/src/DependencyManager.h +++ b/libraries/shared/src/DependencyManager.h @@ -83,11 +83,13 @@ template QSharedPointer DependencyManager::set(Args&&... args) { static size_t hashCode = _manager.getHashCode(); - QSharedPointer instance(new T(args...), &T::customDeleter); - QSharedPointer storedInstance = qSharedPointerCast(instance); - _manager.safeGet(hashCode).swap(storedInstance); + QSharedPointer& instance = _manager.safeGet(hashCode); + instance.clear(); // Clear instance before creation of new one to avoid edge cases + QSharedPointer newInstance(new T(args...), &T::customDeleter); + QSharedPointer storedInstance = qSharedPointerCast(newInstance); + instance.swap(storedInstance); - return instance; + return newInstance; } template From cfb996db0c1c83c6365d42a38ca9660c254b3d25 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 15 Jan 2015 14:15:59 -0800 Subject: [PATCH 14/16] Add missing paramaters to Base3DOverlay copy ctor --- interface/src/ui/overlays/Base3DOverlay.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/src/ui/overlays/Base3DOverlay.cpp b/interface/src/ui/overlays/Base3DOverlay.cpp index 81f12d7fbb..57c7aa791b 100644 --- a/interface/src/ui/overlays/Base3DOverlay.cpp +++ b/interface/src/ui/overlays/Base3DOverlay.cpp @@ -41,7 +41,9 @@ Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) : _rotation(base3DOverlay->_rotation), _isSolid(base3DOverlay->_isSolid), _isDashedLine(base3DOverlay->_isDashedLine), - _ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection) + _ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection), + _drawInFront(base3DOverlay->_drawInFront), + _drawOnHUD(base3DOverlay->_drawOnHUD) { } From 00f4e92e06920168d0ab9a7a342433097b341bf6 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 15 Jan 2015 14:58:49 -0800 Subject: [PATCH 15/16] fix places array grab --- examples/lobby.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/lobby.js b/examples/lobby.js index 2367819524..87ffddcf17 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -166,7 +166,7 @@ function changeLobbyTextures() { for (var j = 0; j < NUM_PANELS; j++) { var panelIndex = placeIndexToPanelIndex(j); textureProp["textures"]["file" + panelIndex] = HIFI_PUBLIC_BUCKET + "images/places/" - + place[j].id + "/hifi-place-" + place[j].id + "_640x360.jpg"; + + places[j].id + "/hifi-place-" + places[j].id + "_640x360.jpg"; }; Overlays.editOverlay(panelWall, textureProp); From 336f28e0146b8b0f4439b06e42a8391cd9c071c9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 15 Jan 2015 15:00:42 -0800 Subject: [PATCH 16/16] repair to places array length --- examples/lobby.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/lobby.js b/examples/lobby.js index 87ffddcf17..636f0a95f1 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -253,7 +253,7 @@ function actionStartEvent(event) { if (panelStringIndex != -1) { var panelIndex = parseInt(panelName.slice(5)); var placeIndex = panelIndexToPlaceIndex(panelIndex); - if (placeIndex < place.length) { + if (placeIndex < places.length) { var actionPlace = places[placeIndex]; print("Jumping to " + actionPlace.name + " at " + actionPlace.address