History

centralize path creation from position and orientation to AddressManager

Stephen Birarda committed 12 years ago

Commit b56ea5c1 parent 23a0ef210 files · +187 −223Browse files

Showing the changes to interface/src/Application.cpp (1 of 10 files). Show all

Unified · Split

interface/src/Application.cpp+39−26
@@ -84,7 +84,6 @@ · 83 unmodified lines
84#include "scripting/MenuScriptingInterface.h"84#include "scripting/MenuScriptingInterface.h"
85#include "scripting/SettingsScriptingInterface.h"85#include "scripting/SettingsScriptingInterface.h"
86#include "scripting/WindowScriptingInterface.h"86#include "scripting/WindowScriptingInterface.h"
87#include "scripting/LocationScriptingInterface.h"
88 87
89#include "ui/InfoView.h"88#include "ui/InfoView.h"
90#include "ui/OAuthWebViewHandler.h"89#include "ui/OAuthWebViewHandler.h"
@@ -408,7 +407,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 317 unmodified lines
408 _runningScriptsWidget, &RunningScriptsWidget::setBoundary);407 _runningScriptsWidget, &RunningScriptsWidget::setBoundary);
409 408
410 // connect to the domainChangeRequired signal on AddressManager409 // connect to the domainChangeRequired signal on AddressManager
411 connect(&AddressManager::getInstance(), &AddressManager::domainChangeRequired, this, &Application::changeDomainHostname);410 connect(&AddressManager::getInstance(), &AddressManager::possibleDomainChangeRequired,
411 this, &Application::changeDomainHostname);
412 412
413 //When -url in command line, teleport to location413 //When -url in command line, teleport to location
414 urlGoTo(argc, constArgv);414 urlGoTo(argc, constArgv);
@@ -811,7 +811,7 @@ bool Application::event(QEvent* event) { · 396 unmodified lines
811 // handle custom URL811 // handle custom URL
812 if (event->type() == QEvent::FileOpen) {812 if (event->type() == QEvent::FileOpen) {
813 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);813 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
814 bool isHifiSchemeURL = !fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME);814 bool isHifiSchemeURL = !fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(HIFI_URL_SCHEME);
815 if (isHifiSchemeURL) {815 if (isHifiSchemeURL) {
816// Menu::getInstance()->goToURL(fileEvent->url().toLocalFile());816// Menu::getInstance()->goToURL(fileEvent->url().toLocalFile());
817 }817 }
@@ -3376,31 +3376,44 @@ void Application::updateWindowTitle(){ · 2558 unmodified lines
3376void Application::updateLocationInServer() {3376void Application::updateLocationInServer() {
3377 3377
3378 AccountManager& accountManager = AccountManager::getInstance();3378 AccountManager& accountManager = AccountManager::getInstance();
3379 3379 const QUuid& domainUUID = NodeList::getInstance()->getDomainHandler().getUUID();
3380 if (accountManager.isLoggedIn()) {3380
3381 if (accountManager.isLoggedIn() && !domainUUID.isNull()) {
3381 3382
3382 // construct a QJsonObject given the user's current address information3383 // construct a QJsonObject given the user's current address information
3383 QJsonObject updatedLocationObject;3384 QJsonObject rootObject;
3384 3385
3385 QJsonObject addressObject;3386 QJsonObject locationObject;
3386 addressObject.insert("position", QString(createByteArray(_myAvatar->getPosition())));3387
3387 addressObject.insert("orientation", QString(createByteArray(glm::degrees(safeEulerAngles(_myAvatar->getOrientation())))));3388 QString pathString = AddressManager::pathForPositionAndOrientation(_myAvatar->getPosition(),
3388 addressObject.insert("domain", NodeList::getInstance()->getDomainHandler().getHostname());3389 true,
3390 _myAvatar->getOrientation());
3391
3392 const QString LOCATION_KEY_IN_ROOT = "location";
3393 const QString PATH_KEY_IN_LOCATION = "path";
3394 const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id";
3395
3396 locationObject.insert(PATH_KEY_IN_LOCATION, pathString);
3397 locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, domainUUID.toString());
3389 3398
3390 updatedLocationObject.insert("address", addressObject);3399 rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject);
3391 3400
3392 accountManager.authenticatedRequest("/api/v1/users/address", QNetworkAccessManager::PutOperation,3401 accountManager.authenticatedRequest("/api/v1/users/location", QNetworkAccessManager::PutOperation,
3393 JSONCallbackParameters(), QJsonDocument(updatedLocationObject).toJson());3402 JSONCallbackParameters(), QJsonDocument(rootObject).toJson());
3394 }3403 }
3395}3404}
3396 3405
3397void Application::changeDomainHostname(const QString &newDomainHostname) {3406void Application::changeDomainHostname(const QString &newDomainHostname) {
3398 // tell the MyAvatar object to send a kill packet so that it dissapears from its old avatar mixer immediately3407 NodeList* nodeList = NodeList::getInstance();
3399 _myAvatar->sendKillAvatar();
3400 3408
3401 // call the domain hostname change as a queued connection on the nodelist3409 if (!nodeList->getDomainHandler().isCurrentHostname(newDomainHostname)) {
3402 QMetaObject::invokeMethod(&NodeList::getInstance()->getDomainHandler(), "setHostname",3410 // tell the MyAvatar object to send a kill packet so that it dissapears from its old avatar mixer immediately
3403 Q_ARG(const QString&, newDomainHostname));3411 _myAvatar->sendKillAvatar();
3412
3413 // call the domain hostname change as a queued connection on the nodelist
3414 QMetaObject::invokeMethod(&NodeList::getInstance()->getDomainHandler(), "setHostname",
3415 Q_ARG(const QString&, newDomainHostname));
3416 }
3404}3417}
3405 3418
3406void Application::domainChanged(const QString& domainHostname) {3419void Application::domainChanged(const QString& domainHostname) {
@@ -3785,12 +3798,12 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 378 unmodified lines
3785 scriptEngine->registerGlobalObject("Overlays", &_overlays);3798 scriptEngine->registerGlobalObject("Overlays", &_overlays);
3786 3799
3787 QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance());3800 QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance());
3788 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,3801// scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
3789 LocationScriptingInterface::locationSetter, windowValue);3802// LocationScriptingInterface::locationSetter, windowValue);
3790 3803//
3791 // register `location` on the global object.3804// // register `location` on the global object.
3792 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,3805// scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
3793 LocationScriptingInterface::locationSetter);3806// LocationScriptingInterface::locationSetter);
3794 3807
3795 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());3808 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
3796 scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());3809 scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
@@ -4111,8 +4124,8 @@ void Application::takeSnapshot() { · 314 unmodified lines
4111void Application::urlGoTo(int argc, const char * constArgv[]) {4124void Application::urlGoTo(int argc, const char * constArgv[]) {
4112 //Gets the url (hifi://domain/destination/orientation)4125 //Gets the url (hifi://domain/destination/orientation)
4113 QString customUrl = getCmdOption(argc, constArgv, "-url");4126 QString customUrl = getCmdOption(argc, constArgv, "-url");
4114 if(customUrl.startsWith(CUSTOM_URL_SCHEME + "//")) {4127 if(customUrl.startsWith(HIFI_URL_SCHEME + "//")) {
4115 QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);4128 QStringList urlParts = customUrl.remove(0, HIFI_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts);
4116 if (urlParts.count() == 1) {4129 if (urlParts.count() == 1) {
4117 // location coordinates or place name4130 // location coordinates or place name
4118 QString domain = urlParts[0];4131 QString domain = urlParts[0];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t