diff --git a/examples/notifications.js b/examples/notifications.js index 7e56c1b50d..5ee6874521 100644 --- a/examples/notifications.js +++ b/examples/notifications.js @@ -92,11 +92,13 @@ var NotificationType = { SNAPSHOT: 2, WINDOW_RESIZE: 3, LOD_WARNING: 4, + CONNECTION_REFUSED: 5, properties: [ { text: "Mute Toggle" }, { text: "Snapshot" }, { text: "Window Resize" }, - { text: "Level of Detail" } + { text: "Level of Detail" }, + { text: "Connection Refused" } ], getTypeFromMenuItem: function(menuItemName) { if (menuItemName.substr(menuItemName.length - NOTIFICATION_MENU_ITEM_POST.length) !== NOTIFICATION_MENU_ITEM_POST) { @@ -501,6 +503,10 @@ function onMuteStateChanged() { createNotification(muteString, NotificationType.MUTE_TOGGLE); } +function onDomainConnectionRefused(reason) { + createNotification("Connection refused: " + reason, NotificationType.CONNECTION_REFUSED ); +} + // handles mouse clicks on buttons function mousePressEvent(event) { var pickRay, @@ -608,5 +614,6 @@ Controller.keyReleaseEvent.connect(keyReleaseEvent); Script.update.connect(update); Script.scriptEnding.connect(scriptEnding); Menu.menuItemEvent.connect(menuItemEvent); +Window.domainConnectionRefused.connect(onDomainConnectionRefused); setup(); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 99777d22bf..97d132508a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -297,7 +297,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _lastSendDownstreamAudioStats(usecTimestampNow()), _isVSyncOn(true), _aboutToQuit(false), - _notifiedPacketVersionMismatchThisDomain(false) + _notifiedPacketVersionMismatchThisDomain(false), + _domainConnectionRefusals(QList()) { #ifdef Q_OS_WIN installNativeEventFilter(&MyNativeEventFilter::getInstance()); @@ -3278,6 +3279,14 @@ void Application::clearDomainOctreeDetails() { void Application::domainChanged(const QString& domainHostname) { updateWindowTitle(); clearDomainOctreeDetails(); + _domainConnectionRefusals.clear(); +} + +void Application::domainConnectionDenied(const QString& reason) { + if (!_domainConnectionRefusals.contains(reason)) { + _domainConnectionRefusals.append(reason); + emit domainConnectionRefused(reason); + } } void Application::connectedToDomain(const QString& hostname) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 7764f297d3..a60361cfc0 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -333,6 +333,8 @@ signals: void svoImportRequested(const QString& url); + void domainConnectionRefused(const QString& reason); + public slots: void domainChanged(const QString& domainHostname); void updateWindowTitle(); @@ -383,6 +385,8 @@ public slots: void setActiveFaceTracker(); + void domainConnectionDenied(const QString& reason); + private slots: void clearDomainOctreeDetails(); void checkFPS(); @@ -607,6 +611,8 @@ private: int _menuBarHeight; QHash _acceptedExtensions; + + QList _domainConnectionRefusals; }; #endif // hifi_Application_h diff --git a/interface/src/DatagramProcessor.cpp b/interface/src/DatagramProcessor.cpp index 475ce406bb..9ac2b51097 100644 --- a/interface/src/DatagramProcessor.cpp +++ b/interface/src/DatagramProcessor.cpp @@ -127,6 +127,7 @@ void DatagramProcessor::processDatagrams() { // and check and signal for an access token so that we can make sure they are logged in qDebug() << "The domain-server denied a connection request: " << reason; qDebug() << "You may need to re-log to generate a keypair so you can provide a username signature."; + application->domainConnectionDenied(reason); AccountManager::getInstance().checkAndSignalForAccessToken(); break; } diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 7f4b5ddf45..a5b8128d1e 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -33,6 +33,7 @@ WindowScriptingInterface::WindowScriptingInterface() : const DomainHandler& domainHandler = DependencyManager::get()->getDomainHandler(); connect(&domainHandler, &DomainHandler::hostnameChanged, this, &WindowScriptingInterface::domainChanged); connect(Application::getInstance(), &Application::svoImportRequested, this, &WindowScriptingInterface::svoImportRequested); + connect(Application::getInstance(), &Application::domainConnectionRefused, this, &WindowScriptingInterface::domainConnectionRefused); } WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title, const QString& url, int width, int height, bool isToolWindow) { diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 6a812f14e3..9bc8a834bd 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -62,6 +62,7 @@ signals: void inlineButtonClicked(const QString& name); void nonBlockingFormClosed(); void svoImportRequested(const QString& url); + void domainConnectionRefused(const QString& reason); private slots: QScriptValue showAlert(const QString& message); diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 3ccff46a04..266aa2bdce 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -148,6 +148,7 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro } } } else { + QString entityScriptBefore = entity->getScript(); uint32_t preFlags = entity->getDirtyFlags(); UpdateEntityOperator theOperator(this, containingElement, entity, properties); recurseTreeWithOperator(&theOperator); @@ -166,6 +167,11 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro entity->clearDirtyFlags(); } } + + QString entityScriptAfter = entity->getScript(); + if (entityScriptBefore != entityScriptAfter) { + emitEntityScriptChanging(entity->getEntityItemID()); // the entity script has changed + } } // TODO: this final containingElement check should eventually be removed (or wrapped in an #ifdef DEBUG).