add underlying controls for user discoverability
Showing the changes to interface/src/Application.cpp (1 of 7 files). Show all
Unified · Split
| @@ -87,6 +87,7 @@ · 86 unmodified lines | |||
| 87 | 87 | ||
| 88 | #include "Application.h" | 88 | #include "Application.h" |
| 89 | #include "AudioClient.h" | 89 | #include "AudioClient.h" |
| 90 | #include "DiscoverabilityManager.h" | ||
| 90 | #include "InterfaceVersion.h" | 91 | #include "InterfaceVersion.h" |
| 91 | #include "LODManager.h" | 92 | #include "LODManager.h" |
| 92 | #include "Menu.h" | 93 | #include "Menu.h" |
| @@ -246,6 +247,7 @@ bool setupEssentials(int& argc, char** argv) { · 153 unmodified lines | |||
| 246 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) | 247 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) |
| 247 | auto speechRecognizer = DependencyManager::set<SpeechRecognizer>(); | 248 | auto speechRecognizer = DependencyManager::set<SpeechRecognizer>(); |
| 248 | #endif | 249 | #endif |
| 250 | auto discoverabilityManager = DependencyManager::set<DiscoverabilityManager>(); | ||
| 249 | 251 | ||
| 250 | return true; | 252 | return true; |
| 251 | } | 253 | } |
| @@ -367,11 +369,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 115 unmodified lines | |||
| 367 | connect(&domainHandler, &DomainHandler::hostnameChanged, | 369 | connect(&domainHandler, &DomainHandler::hostnameChanged, |
| 368 | DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress); | 370 | DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress); |
| 369 | 371 | ||
| 370 | // update our location every 5 seconds in the data-server, assuming that we are authenticated with one | 372 | // update our location every 5 seconds in the metaverse server, assuming that we are authenticated with one |
| 371 | const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000; | 373 | const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000; |
| 372 | 374 | ||
| 373 | locationUpdateTimer = new QTimer(this); | 375 | locationUpdateTimer = new QTimer(this); |
| 374 | connect(locationUpdateTimer, &QTimer::timeout, this, &Application::updateLocationInServer); | 376 | auto discoverabilityManager = DependencyManager::get<DiscoverabilityManager>(); |
| 377 | connect(locationUpdateTimer, &QTimer::timeout, discoverabilityManager.data(), &DiscoverabilityManager::updateLocation); | ||
| 375 | locationUpdateTimer->start(DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS); | 378 | locationUpdateTimer->start(DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS); |
| 376 | 379 | ||
| 377 | connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded); | 380 | connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded); |
| @@ -3191,45 +3194,6 @@ void Application::updateWindowTitle(){ · 2813 unmodified lines | |||
| 3191 | _window->setWindowTitle(title); | 3194 | _window->setWindowTitle(title); |
| 3192 | } | 3195 | } |
| 3193 | 3196 | ||
| 3194 | void Application::updateLocationInServer() { | ||
| 3195 | |||
| 3196 | AccountManager& accountManager = AccountManager::getInstance(); | ||
| 3197 | auto addressManager = DependencyManager::get<AddressManager>(); | ||
| 3198 | DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler(); | ||
| 3199 | |||
| 3200 | if (accountManager.isLoggedIn() && domainHandler.isConnected() | ||
| 3201 | && (!addressManager->getRootPlaceID().isNull() || !domainHandler.getUUID().isNull())) { | ||
| 3202 | |||
| 3203 | // construct a QJsonObject given the user's current address information | ||
| 3204 | QJsonObject rootObject; | ||
| 3205 | |||
| 3206 | QJsonObject locationObject; | ||
| 3207 | |||
| 3208 | QString pathString = addressManager->currentPath(); | ||
| 3209 | |||
| 3210 | const QString LOCATION_KEY_IN_ROOT = "location"; | ||
| 3211 | |||
| 3212 | const QString PATH_KEY_IN_LOCATION = "path"; | ||
| 3213 | locationObject.insert(PATH_KEY_IN_LOCATION, pathString); | ||
| 3214 | |||
| 3215 | if (!addressManager->getRootPlaceID().isNull()) { | ||
| 3216 | const QString PLACE_ID_KEY_IN_LOCATION = "place_id"; | ||
| 3217 | locationObject.insert(PLACE_ID_KEY_IN_LOCATION, | ||
| 3218 | uuidStringWithoutCurlyBraces(addressManager->getRootPlaceID())); | ||
| 3219 | |||
| 3220 | } else { | ||
| 3221 | const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id"; | ||
| 3222 | locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, | ||
| 3223 | uuidStringWithoutCurlyBraces(domainHandler.getUUID())); | ||
| 3224 | } | ||
| 3225 | |||
| 3226 | rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject); | ||
| 3227 | |||
| 3228 | accountManager.authenticatedRequest("/api/v1/user/location", QNetworkAccessManager::PutOperation, | ||
| 3229 | JSONCallbackParameters(), QJsonDocument(rootObject).toJson()); | ||
| 3230 | } | ||
| 3231 | } | ||
| 3232 | |||
| 3233 | void Application::clearDomainOctreeDetails() { | 3197 | void Application::clearDomainOctreeDetails() { |
| 3234 | qDebug() << "Clearing domain octree details..."; | 3198 | qDebug() << "Clearing domain octree details..."; |
| 3235 | // reset the environment so that we don't erroneously end up with multiple | 3199 | // reset the environment so that we don't erroneously end up with multiple |