Showing the changes to interface/src/Application.cpp (1 of 69 files). Show all
Unified · Split
| @@ -51,11 +51,11 @@ · 50 unmodified lines | |||
| 51 | #include <QMimeData> | 51 | #include <QMimeData> |
| 52 | #include <QMessageBox> | 52 | #include <QMessageBox> |
| 53 | 53 | ||
| 54 | #include <AccountManager.h> | ||
| 54 | #include <AudioInjector.h> | 55 | #include <AudioInjector.h> |
| 55 | #include <Logging.h> | 56 | #include <Logging.h> |
| 56 | #include <OctalCode.h> | 57 | #include <OctalCode.h> |
| 57 | #include <PacketHeaders.h> | 58 | #include <PacketHeaders.h> |
| 58 | #include <PairingHandler.h> | ||
| 59 | #include <ParticlesScriptingInterface.h> | 59 | #include <ParticlesScriptingInterface.h> |
| 60 | #include <PerfStat.h> | 60 | #include <PerfStat.h> |
| 61 | #include <UUID.h> | 61 | #include <UUID.h> |
| @@ -63,7 +63,6 @@ · 1 unmodified line | |||
| 63 | 63 | ||
| 64 | #include "Application.h" | 64 | #include "Application.h" |
| 65 | #include "ClipboardScriptingInterface.h" | 65 | #include "ClipboardScriptingInterface.h" |
| 66 | #include "DataServerClient.h" | ||
| 67 | #include "InterfaceVersion.h" | 66 | #include "InterfaceVersion.h" |
| 68 | #include "Menu.h" | 67 | #include "Menu.h" |
| 69 | #include "Swatch.h" | 68 | #include "Swatch.h" |
| @@ -129,7 +128,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 59 unmodified lines | |||
| 129 | _wantToKillLocalVoxels(false), | 128 | _wantToKillLocalVoxels(false), |
| 130 | _audioScope(256, 200, true), | 129 | _audioScope(256, 200, true), |
| 131 | _myAvatar(), | 130 | _myAvatar(), |
| 132 | _profile(QString()), | ||
| 133 | _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), | 131 | _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), |
| 134 | _mouseX(0), | 132 | _mouseX(0), |
| 135 | _mouseY(0), | 133 | _mouseY(0), |
| @@ -161,11 +159,27 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 25 unmodified lines | |||
| 161 | _pasteMode(false), | 159 | _pasteMode(false), |
| 162 | _logger(new FileLogger(this)) | 160 | _logger(new FileLogger(this)) |
| 163 | { | 161 | { |
| 162 | switchToResourcesParentIfRequired(); | ||
| 163 | |||
| 164 | // read the ApplicationInfo.ini file for Name/Version/Domain information | ||
| 165 | QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat); | ||
| 166 | |||
| 167 | // set the associated application properties | ||
| 168 | applicationInfo.beginGroup("INFO"); | ||
| 169 | |||
| 170 | qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion()); | ||
| 171 | |||
| 172 | setApplicationName(applicationInfo.value("name").toString()); | ||
| 173 | setApplicationVersion(BUILD_VERSION); | ||
| 174 | setOrganizationName(applicationInfo.value("organizationName").toString()); | ||
| 175 | setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); | ||
| 176 | |||
| 177 | QSettings::setDefaultFormat(QSettings::IniFormat); | ||
| 178 | |||
| 164 | _myAvatar = _avatarManager.getMyAvatar(); | 179 | _myAvatar = _avatarManager.getMyAvatar(); |
| 165 | 180 | ||
| 166 | _applicationStartupTime = startup_time; | 181 | _applicationStartupTime = startup_time; |
| 167 | 182 | ||
| 168 | switchToResourcesParentIfRequired(); | ||
| 169 | QFontDatabase::addApplicationFont("resources/styles/Inconsolata.otf"); | 183 | QFontDatabase::addApplicationFont("resources/styles/Inconsolata.otf"); |
| 170 | _window->setWindowTitle("Interface"); | 184 | _window->setWindowTitle("Interface"); |
| 171 | 185 | ||
| @@ -203,27 +217,27 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 31 unmodified lines | |||
| 203 | connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); | 217 | connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); |
| 204 | 218 | ||
| 205 | audioThread->start(); | 219 | audioThread->start(); |
| 206 | 220 | ||
| 207 | connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&))); | 221 | connect(&nodeList->getDomainInfo(), SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&))); |
| 222 | connect(&nodeList->getDomainInfo(), SIGNAL(connectedToDomain(const QString&)), SLOT(connectedToDomain(const QString&))); | ||
| 223 | |||
| 208 | connect(nodeList, &NodeList::nodeAdded, this, &Application::nodeAdded); | 224 | connect(nodeList, &NodeList::nodeAdded, this, &Application::nodeAdded); |
| 209 | connect(nodeList, &NodeList::nodeKilled, this, &Application::nodeKilled); | 225 | connect(nodeList, &NodeList::nodeKilled, this, &Application::nodeKilled); |
| 210 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); | 226 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); |
| 211 | connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer))); | 227 | connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer))); |
| 212 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); | 228 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); |
| 213 | connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle); | 229 | connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle); |
| 230 | |||
| 231 | // connect to appropriate slots on AccountManager | ||
| 232 | AccountManager& accountManager = AccountManager::getInstance(); | ||
| 233 | connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain); | ||
| 234 | connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle); | ||
| 214 | 235 | ||
| 215 | // read the ApplicationInfo.ini file for Name/Version/Domain information | 236 | // set the account manager's root URL and trigger a login request if we don't have the access token |
| 216 | QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat); | 237 | accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL); |
| 217 | |||
| 218 | // set the associated application properties | ||
| 219 | applicationInfo.beginGroup("INFO"); | ||
| 220 | |||
| 221 | setApplicationName(applicationInfo.value("name").toString()); | ||
| 222 | setApplicationVersion(BUILD_VERSION); | ||
| 223 | setOrganizationName(applicationInfo.value("organizationName").toString()); | ||
| 224 | setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); | ||
| 225 | 238 | ||
| 226 | qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion()); | 239 | // once the event loop has started, check and signal for an access token |
| 240 | QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection); | ||
| 227 | 241 | ||
| 228 | _settings = new QSettings(this); | 242 | _settings = new QSettings(this); |
| 229 | 243 | ||
| @@ -303,7 +317,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 73 unmodified lines | |||
| 303 | 317 | ||
| 304 | _overlays.init(_glWidget); // do this before scripts load | 318 | _overlays.init(_glWidget); // do this before scripts load |
| 305 | 319 | ||
| 306 | |||
| 307 | // do this as late as possible so that all required subsystems are inialized | 320 | // do this as late as possible so that all required subsystems are inialized |
| 308 | loadScripts(); | 321 | loadScripts(); |
| 309 | } | 322 | } |
| @@ -602,13 +615,6 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) · 292 unmodified lines | |||
| 602 | glMatrixMode(GL_MODELVIEW); | 615 | glMatrixMode(GL_MODELVIEW); |
| 603 | } | 616 | } |
| 604 | 617 | ||
| 605 | void Application::resetProfile(const QString& username) { | ||
| 606 | // call the destructor on the old profile and construct a new one | ||
| 607 | (&_profile)->~Profile(); | ||
| 608 | new (&_profile) Profile(username); | ||
| 609 | updateWindowTitle(); | ||
| 610 | } | ||
| 611 | |||
| 612 | void Application::controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes) { | 618 | void Application::controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes) { |
| 613 | foreach(NodeType_t type, destinationNodeTypes) { | 619 | foreach(NodeType_t type, destinationNodeTypes) { |
| 614 | // Intercept data to voxel server when voxels are disabled | 620 | // Intercept data to voxel server when voxels are disabled |
| @@ -1428,12 +1434,7 @@ void Application::timer() { · 813 unmodified lines | |||
| 1428 | // ask the node list to check in with the domain server | 1434 | // ask the node list to check in with the domain server |
| 1429 | NodeList::getInstance()->sendDomainServerCheckIn(); | 1435 | NodeList::getInstance()->sendDomainServerCheckIn(); |
| 1430 | 1436 | ||
| 1431 | // send unmatched DataServerClient packets | 1437 | |
| 1432 | DataServerClient::resendUnmatchedPackets(); | ||
| 1433 | |||
| 1434 | // give the MyAvatar object position, orientation to the Profile so it can propagate to the data-server | ||
| 1435 | _profile.updatePosition(_myAvatar->getPosition()); | ||
| 1436 | _profile.updateOrientation(_myAvatar->getOrientation()); | ||
| 1437 | } | 1438 | } |
| 1438 | 1439 | ||
| 1439 | static glm::vec3 getFaceVector(BoxFace face) { | 1440 | static glm::vec3 getFaceVector(BoxFace face) { |
| @@ -1493,6 +1494,8 @@ void Application::idle() { · 53 unmodified lines | |||
| 1493 | _idleLoopMeasuredJitter = _idleLoopStdev.getStDev(); | 1494 | _idleLoopMeasuredJitter = _idleLoopStdev.getStDev(); |
| 1494 | _idleLoopStdev.reset(); | 1495 | _idleLoopStdev.reset(); |
| 1495 | } | 1496 | } |
| 1497 | |||
| 1498 | _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData()); | ||
| 1496 | 1499 | ||
| 1497 | // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. | 1500 | // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. |
| 1498 | idleTimer->start(2); | 1501 | idleTimer->start(2); |
| @@ -2815,10 +2818,20 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 1316 unmodified lines | |||
| 2815 | "Application::displaySide() ... metavoxels..."); | 2818 | "Application::displaySide() ... metavoxels..."); |
| 2816 | _metavoxels.render(); | 2819 | _metavoxels.render(); |
| 2817 | } | 2820 | } |
| 2821 | |||
| 2822 | if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { | ||
| 2823 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | ||
| 2824 | "Application::displaySide() ... bucky balls..."); | ||
| 2825 | _buckyBalls.render(); | ||
| 2826 | } | ||
| 2818 | 2827 | ||
| 2819 | // render particles... | 2828 | // render particles... |
| 2820 | _particles.render(); | 2829 | if (Menu::getInstance()->isOptionChecked(MenuOption::Particles)) { |
| 2821 | 2830 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | |
| 2831 | "Application::displaySide() ... particles..."); | ||
| 2832 | _particles.render(); | ||
| 2833 | } | ||
| 2834 | |||
| 2822 | // render the ambient occlusion effect if enabled | 2835 | // render the ambient occlusion effect if enabled |
| 2823 | if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) { | 2836 | if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) { |
| 2824 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 2837 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| @@ -2931,9 +2944,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 106 unmodified lines | |||
| 2931 | } | 2944 | } |
| 2932 | } | 2945 | } |
| 2933 | 2946 | ||
| 2934 | // render transmitter pick ray, if non-empty | ||
| 2935 | _myAvatar->renderTransmitterPickRay(); | ||
| 2936 | |||
| 2937 | // give external parties a change to hook in | 2947 | // give external parties a change to hook in |
| 2938 | emit renderingInWorldInterface(); | 2948 | emit renderingInWorldInterface(); |
| 2939 | 2949 | ||
| @@ -2999,8 +3009,6 @@ void Application::displayOverlay() { · 59 unmodified lines | |||
| 2999 | _myAvatar->renderHeadMouse(); | 3009 | _myAvatar->renderHeadMouse(); |
| 3000 | } | 3010 | } |
| 3001 | 3011 | ||
| 3002 | _myAvatar->renderTransmitterLevels(_glWidget->width(), _glWidget->height()); | ||
| 3003 | |||
| 3004 | // Display stats and log text onscreen | 3012 | // Display stats and log text onscreen |
| 3005 | glLineWidth(1.0f); | 3013 | glLineWidth(1.0f); |
| 3006 | glPointSize(1.0f); | 3014 | glPointSize(1.0f); |
| @@ -3979,17 +3987,15 @@ void Application::updateWindowTitle(){ · 972 unmodified lines | |||
| 3979 | QString buildVersion = " (build " + applicationVersion() + ")"; | 3987 | QString buildVersion = " (build " + applicationVersion() + ")"; |
| 3980 | NodeList* nodeList = NodeList::getInstance(); | 3988 | NodeList* nodeList = NodeList::getInstance(); |
| 3981 | 3989 | ||
| 3982 | QString title = QString() + _profile.getUsername() + " " + nodeList->getSessionUUID().toString() | 3990 | QString username = AccountManager::getInstance().getUsername(); |
| 3983 | + " @ " + nodeList->getDomainHostname() + buildVersion; | 3991 | QString title = QString() + (!username.isEmpty() ? username + " " : QString()) + nodeList->getSessionUUID().toString() |
| 3992 | + " @ " + nodeList->getDomainInfo().getHostname() + buildVersion; | ||
| 3984 | 3993 | ||
| 3985 | qDebug("Application title set to: %s", title.toStdString().c_str()); | 3994 | qDebug("Application title set to: %s", title.toStdString().c_str()); |
| 3986 | _window->setWindowTitle(title); | 3995 | _window->setWindowTitle(title); |
| 3987 | } | 3996 | } |
| 3988 | 3997 | ||
| 3989 | void Application::domainChanged(const QString& domainHostname) { | 3998 | void Application::domainChanged(const QString& domainHostname) { |
| 3990 | // update the user's last domain in their Profile (which will propagate to data-server) | ||
| 3991 | _profile.updateDomain(domainHostname); | ||
| 3992 | |||
| 3993 | updateWindowTitle(); | 3999 | updateWindowTitle(); |
| 3994 | 4000 | ||
| 3995 | // reset the environment so that we don't erroneously end up with multiple | 4001 | // reset the environment so that we don't erroneously end up with multiple |
| @@ -4004,6 +4010,19 @@ void Application::domainChanged(const QString& domainHostname) { · 8 unmodified lines | |||
| 4004 | _particles.clear(); | 4010 | _particles.clear(); |
| 4005 | } | 4011 | } |
| 4006 | 4012 | ||
| 4013 | void Application::connectedToDomain(const QString& hostname) { | ||
| 4014 | AccountManager& accountManager = AccountManager::getInstance(); | ||
| 4015 | |||
| 4016 | if (accountManager.isLoggedIn()) { | ||
| 4017 | // update our domain-server with the data-server we're logged in with | ||
| 4018 | |||
| 4019 | QString domainPutJsonString = "{\"location\":{\"domain\":\"" + hostname + "\"}}"; | ||
| 4020 | |||
| 4021 | accountManager.authenticatedRequest("/api/v1/users/location", QNetworkAccessManager::PutOperation, | ||
| 4022 | JSONCallbackParameters(), domainPutJsonString.toUtf8()); | ||
| 4023 | } | ||
| 4024 | } | ||
| 4025 | |||
| 4007 | void Application::nodeAdded(SharedNodePointer node) { | 4026 | void Application::nodeAdded(SharedNodePointer node) { |
| 4008 | if (node->getType() == NodeType::AvatarMixer) { | 4027 | if (node->getType() == NodeType::AvatarMixer) { |
| 4009 | // new avatar mixer, send off our identity packet right away | 4028 | // new avatar mixer, send off our identity packet right away |
| @@ -4392,6 +4411,5 @@ void Application::takeSnapshot() { · 382 unmodified lines | |||
| 4392 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); | 4411 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); |
| 4393 | player->play(); | 4412 | player->play(); |
| 4394 | 4413 | ||
| 4395 | Snapshot::saveSnapshot(_glWidget, &_profile, _myAvatar); | 4414 | Snapshot::saveSnapshot(_glWidget, _myAvatar); |
| 4396 | } | 4415 | } |
| 4397 | |||