From af1591277c41dd38c8365c40ae1538b6f7ed0bb8 Mon Sep 17 00:00:00 2001 From: Adrianl3d Date: Fri, 19 Dec 2014 04:17:36 +1000 Subject: [PATCH 1/9] changes as per list removed dummy code, remove mic mute state at startup, some text changes. --- examples/notifications.js | 107 +++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 60 deletions(-) diff --git a/examples/notifications.js b/examples/notifications.js index 2c2c4a5c0b..7946213abd 100644 --- a/examples/notifications.js +++ b/examples/notifications.js @@ -1,25 +1,32 @@ // -// notifications.js +// notifications.js +// Version 0.801 // Created by Adrian // // Adrian McCarlie 8-10-14 // This script demonstrates on-screen overlay type notifications. // Copyright 2014 High Fidelity, Inc. // +// // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// This script demonstrates notifications created via a number of ways, such as: -// Simple key press alerts, which only depend on a key being pressed, -// dummy examples of this are "q", "w", "e", "r", and "SPACEBAR". -// actual working examples are "a" for left turn, "d" for right turn and Ctrl/s for snapshot. - -// System generated alerts such as users joining and leaving and chat messages which mention this user. -// System generated alerts which originate with a user interface event such as Window Resize, and Mic Mute/Unmute. -// Mic Mute/Unmute may appear to be a key press alert, but it actually gets the call from the system as mic is muted and unmuted, -// so the mic mute/unmute will also trigger the notification by clicking the Mic Mute button at the top of the screen. +// This script generates notifications created via a number of ways, such as: +// keystroke: +// +// "q" returns number of users currently online (for debug purposes) +// CTRL/s for snapshot. +// CTRL/m for mic mute and unmute. +// System generated notifications: +// Displays users online at startup. +// If Screen is resized. +// Triggers notification if @MyUserName is mentioned in chat. +// Announces existing user logging out. +// Announces new user logging in. +// If mic is muted for any reason. +// // To add a new System notification type: // // 1. Set the Event Connector at the bottom of the script. @@ -45,22 +52,23 @@ // 2. Declare a text string. // 3. Call createNotifications(text) parsing the text. // example: -// if (key.text == "a") { -// var noteString = "Turning to the Left"; -// createNotification(noteString); -// } +// if (key.text == "q") { //queries number of users online +// var numUsers = GlobalServices.onlineUsers.length; +// var welcome = "There are " + numUsers + " users online now."; +// createNotification(welcome); +// } var width = 340.0; //width of notification overlay var height = 40.0; // height of a single line notification overlay var windowDimensions = Controller.getViewportDimensions(); // get the size of the interface window -var overlayLocationX = (windowDimensions.x - (width + 60.0));// positions window 60px from the right of the interface window +var overlayLocationX = (windowDimensions.x - (width + 20.0));// positions window 20px from the right of the interface window var buttonLocationX = overlayLocationX + (width - 28.0); var locationY = 20.0; // position down from top of interface window var topMargin = 13.0; var leftMargin = 10.0; var textColor = { red: 228, green: 228, blue: 228}; // text color -var backColor = { red: 38, green: 38, blue: 38}; // background color +var backColor = { red: 2, green: 2, blue: 2}; // background color was 38,38,38 var backgroundAlpha = 0; var fontSize = 12.0; var persistTime = 10.0; // time in seconds before notification fades @@ -115,7 +123,6 @@ function createNotification(text) { color: textColor, backgroundColor: backColor, alpha: backgroundAlpha, - backgroundAlpha: backgroundAlpha, topMargin: topMargin, leftMargin: leftMargin, font: {size: fontSize}, @@ -125,8 +132,8 @@ function createNotification(text) { var buttonProperties = { x: buttonLocationX, y: bLevel, - width: 15.0, - height: 15.0, + width: 10.0, + height: 10.0, subImage: { x: 0, y: 0, width: 10, height: 10 }, imageURL: "http://hifi-public.s3.amazonaws.com/images/close-small-light.svg", color: { red: 255, green: 255, blue: 255}, @@ -161,7 +168,7 @@ function fadeIn(noticeIn, buttonIn) { pauseTimer = Script.setInterval(function() { q++; qFade = q / 10.0; - Overlays.editOverlay(noticeIn, {alpha: qFade, backgroundAlpha: qFade}); + Overlays.editOverlay(noticeIn, {alpha: qFade}); Overlays.editOverlay(buttonIn, {alpha: qFade}); if (q >= 9.0) { Script.clearInterval(pauseTimer); @@ -203,41 +210,18 @@ function keyPressEvent(key) { if (key.key == 16777249) { ctrlIsPressed = true; } - if (key.text == "a") { - var noteString = "Turning to the Left"; - createNotification(noteString); - } - if (key.text == "d") { - var noteString = "Turning to the Right"; - createNotification(noteString); - } + if (key.text == "q") { //queries number of users online + var numUsers = GlobalServices.onlineUsers.length; + var welcome = "There are " + numUsers + " users online now."; + createNotification(welcome); + } + if (key.text == "s") { if (ctrlIsPressed == true){ - var noteString = "You have taken a snapshot"; + var noteString = "Snapshot taken."; createNotification(noteString); } } - if (key.text == "q") { - var noteString = "Enable Scripted Motor control is now on."; - wordWrap(noteString); - } - if (key.text == "w") { - var noteString = "This notification spans 2 lines. The overlay will resize to fit new lines."; - var noteString = "editVoxels.js stopped, editModels.js stopped, selectAudioDevice.js stopped."; - wordWrap(noteString); - } - if (key.text == "e") { - var noteString = "This is an example of a multiple line notification. This notification will span 3 lines." - wordWrap(noteString); - } - if (key.text == "r") { - var noteString = "This is a very long line of text that we are going to use in this example to divide it into rows of maximum 43 chars and see how many lines we use."; - wordWrap(noteString); - } - if (key.text == "SPACE") { - var noteString = "You have pressed the Spacebar, This is an example of a multiple line notification. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam."; - wordWrap(noteString); - } } // formats string to add newline every 43 chars @@ -275,18 +259,14 @@ function checkSize(){ // Triggers notification if a user logs on or off function onOnlineUsersChanged(users) { - var joiners = []; - var leavers = []; for (user in users) { if (last_users.indexOf(users[user]) == -1.0) { - joiners.push(users[user]); - createNotification(users[user] + " Has joined"); + createNotification(users[user] + " has joined"); } } for (user in last_users) { if (users.indexOf(last_users[user]) == -1.0) { - leavers.push(last_users[user]); - createNotification(last_users[user] + " Has left"); + createNotification(last_users[user] + " has left"); } } last_users = users; @@ -303,8 +283,8 @@ function onIncomingMessage(user, message) { } // Triggers mic mute notification function onMuteStateChanged() { - var muteState = AudioDevice.getMuted() ? "Muted" : "Unmuted"; - var muteString = "Microphone is set to " + muteState; + var muteState = AudioDevice.getMuted() ? "muted" : "unmuted"; + var muteString = "Microphone is now " + muteState; createNotification(muteString); } @@ -345,7 +325,7 @@ function fadeOut(noticeOut, buttonOut, arraysOut) { pauseTimer = Script.setInterval(function() { r--; rFade = r / 10.0; - Overlays.editOverlay(noticeOut, {alpha: rFade, backgroundAlpha: rFade}); + Overlays.editOverlay(noticeOut, {alpha: rFade}); Overlays.editOverlay(buttonOut, {alpha: rFade}); if (r < 0) { dismiss(noticeOut, buttonOut, arraysOut); @@ -368,10 +348,17 @@ function dismiss(firstNoteOut, firstButOut, firstOut) { myAlpha.splice(firstOut,1); } -onMuteStateChanged(); +// This is meant to show users online at startup but currently shows 0 users. +function onConnected() { + var numUsers = GlobalServices.onlineUsers.length; + var welcome = "Welcome! There are " + numUsers + " users online now."; + createNotification(welcome); +} + AudioDevice.muteToggled.connect(onMuteStateChanged); Controller.keyPressEvent.connect(keyPressEvent); Controller.mousePressEvent.connect(mousePressEvent); +GlobalServices.connected.connect(onConnected); GlobalServices.onlineUsersChanged.connect(onOnlineUsersChanged); GlobalServices.incomingMessage.connect(onIncomingMessage); Controller.keyReleaseEvent.connect(keyReleaseEvent); From 087ac1db90394ee8dff79e2c97dcbcb9bb324ea1 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 18 Dec 2014 16:03:13 -0800 Subject: [PATCH 2/9] send port along with domain hostname lookup --- libraries/networking/src/AddressManager.cpp | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index 81b3a1328b..1352c54c79 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -107,7 +107,8 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl) { if (!handleUsername(lookupUrl.authority())) { // we're assuming this is either a network address or global place name // check if it is a network address first - if (!handleNetworkAddress(lookupUrl.host())) { + if (!handleNetworkAddress(lookupUrl.host() + + (lookupUrl.port() == -1 ? "" : ":" + QString::number(lookupUrl.port())))) { // wasn't an address - lookup the place name attemptPlaceNameLookup(lookupUrl.host()); } @@ -246,17 +247,6 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) { const QString HOSTNAME_REGEX_STRING = "^((?:[A-Z0-9]|[A-Z0-9][A-Z0-9\\-]{0,61}[A-Z0-9])" "(?:\\.(?:[A-Z0-9]|[A-Z0-9][A-Z0-9\\-]{0,61}[A-Z0-9]))+|localhost)(:{1}\\d{1,5})?$"; - QRegExp hostnameRegex(HOSTNAME_REGEX_STRING, Qt::CaseInsensitive); - - if (hostnameRegex.indexIn(lookupString) != -1) { - QString domainHostname = hostnameRegex.cap(0); - - emit lookupResultsFinished(); - setDomainHostnameAndName(domainHostname); - - return true; - } - QRegExp ipAddressRegex(IP_ADDRESS_REGEX_STRING); if (ipAddressRegex.indexIn(lookupString) != -1) { @@ -268,6 +258,17 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) { return true; } + QRegExp hostnameRegex(HOSTNAME_REGEX_STRING, Qt::CaseInsensitive); + + if (hostnameRegex.indexIn(lookupString) != -1) { + QString domainHostname = hostnameRegex.cap(0); + + emit lookupResultsFinished(); + setDomainHostnameAndName(domainHostname); + + return true; + } + return false; } From 1ab66c2bfefb038824938ccf765afb428a3922b9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 18 Dec 2014 16:17:03 -0800 Subject: [PATCH 3/9] split port and hostname for cleaner domain changes --- interface/src/Application.cpp | 22 +------------ interface/src/Application.h | 1 - libraries/networking/src/AddressManager.cpp | 24 ++++++++++---- libraries/networking/src/AddressManager.h | 4 +-- libraries/networking/src/DomainHandler.cpp | 36 +++++---------------- libraries/networking/src/DomainHandler.h | 6 ++-- libraries/networking/src/NodeList.cpp | 10 ++++++ 7 files changed, 40 insertions(+), 63 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c3ec763426..a975716f9c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -309,13 +309,6 @@ 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); - - // handle domain change signals from AddressManager - connect(&addressManager, &AddressManager::possibleDomainChangeRequiredToHostname, - this, &Application::changeDomainHostname); - - connect(&addressManager, &AddressManager::possibleDomainChangeRequiredViaICEForID, - &domainHandler, &DomainHandler::setIceServerHostnameAndID); _settings = new QSettings(this); _numChangedSettings = 0; @@ -1435,7 +1428,7 @@ void Application::dropEvent(QDropEvent *event) { SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath); if (snapshotData) { if (!snapshotData->getDomain().isEmpty()) { - changeDomainHostname(snapshotData->getDomain()); + NodeList::getInstance()->getDomainHandler().setHostnameAndPort(snapshotData->getDomain()); } _myAvatar->setPosition(snapshotData->getLocation()); @@ -3700,19 +3693,6 @@ void Application::updateLocationInServer() { } } -void Application::changeDomainHostname(const QString &newDomainHostname) { - NodeList* nodeList = NodeList::getInstance(); - - if (!nodeList->getDomainHandler().isCurrentHostname(newDomainHostname)) { - // tell the MyAvatar object to send a kill packet so that it dissapears from its old avatar mixer immediately - _myAvatar->sendKillAvatar(); - - // call the domain hostname change as a queued connection on the nodelist - QMetaObject::invokeMethod(&NodeList::getInstance()->getDomainHandler(), "setHostname", - Q_ARG(const QString&, newDomainHostname)); - } -} - void Application::clearDomainOctreeDetails() { qDebug() << "Clearing domain octree details..."; // reset the environment so that we don't erroneously end up with multiple diff --git a/interface/src/Application.h b/interface/src/Application.h index 111f03c7c6..041e5e6b5b 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -335,7 +335,6 @@ signals: void importDone(); public slots: - void changeDomainHostname(const QString& newDomainHostname); void domainChanged(const QString& domainHostname); void updateWindowTitle(); void updateLocationInServer(); diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index 1352c54c79..f3c14a4597 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -173,7 +173,7 @@ void AddressManager::goToAddressFromObject(const QVariantMap& addressMap) { if (domainObject.contains(DOMAIN_NETWORK_ADDRESS_KEY)) { QString domainHostname = domainObject[DOMAIN_NETWORK_ADDRESS_KEY].toString(); - emit possibleDomainChangeRequiredToHostname(domainHostname); + emit possibleDomainChangeRequired(domainHostname, DEFAULT_DOMAIN_SERVER_PORT); } else { QString iceServerAddress = domainObject[DOMAIN_ICE_SERVER_ADDRESS_KEY].toString(); @@ -250,10 +250,15 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) { QRegExp ipAddressRegex(IP_ADDRESS_REGEX_STRING); if (ipAddressRegex.indexIn(lookupString) != -1) { - QString domainIPString = ipAddressRegex.cap(0); + QString domainIPString = ipAddressRegex.cap(1); + + qint16 domainPort = DEFAULT_DOMAIN_SERVER_PORT; + if (ipAddressRegex.captureCount() > 1) { + domainPort = (qint16) ipAddressRegex.cap(2).toInt(); + } emit lookupResultsFinished(); - setDomainHostnameAndName(domainIPString); + setDomainInfo(domainIPString, domainPort); return true; } @@ -261,10 +266,15 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) { QRegExp hostnameRegex(HOSTNAME_REGEX_STRING, Qt::CaseInsensitive); if (hostnameRegex.indexIn(lookupString) != -1) { - QString domainHostname = hostnameRegex.cap(0); + QString domainHostname = hostnameRegex.cap(1); + + qint16 domainPort = DEFAULT_DOMAIN_SERVER_PORT; + if (ipAddressRegex.captureCount() > 1) { + domainPort = (qint16) ipAddressRegex.cap(2).toInt(); + } emit lookupResultsFinished(); - setDomainHostnameAndName(domainHostname); + setDomainInfo(domainHostname, domainPort); return true; } @@ -340,9 +350,9 @@ bool AddressManager::handleUsername(const QString& lookupString) { } -void AddressManager::setDomainHostnameAndName(const QString& hostname, const QString& domainName) { +void AddressManager::setDomainInfo(const QString &hostname, quint16 port, const QString& domainName) { _currentDomain = domainName.isEmpty() ? hostname : domainName; - emit possibleDomainChangeRequiredToHostname(hostname); + emit possibleDomainChangeRequired(hostname, port); } void AddressManager::goToUser(const QString& username) { diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index cfdaaa7d41..7a83144488 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -59,7 +59,7 @@ signals: void lookupResultsFinished(); void lookupResultIsOffline(); void lookupResultIsNotFound(); - void possibleDomainChangeRequiredToHostname(const QString& newHostname); + void possibleDomainChangeRequired(const QString& newHostname, quint16 newPort); void possibleDomainChangeRequiredViaICEForID(const QString& iceServerHostname, const QUuid& domainID); void locationChangeRequired(const glm::vec3& newPosition, bool hasOrientationChange, const glm::quat& newOrientation, @@ -70,7 +70,7 @@ private slots: private: AddressManager(); - void setDomainHostnameAndName(const QString& hostname, const QString& domainName = QString()); + void setDomainInfo(const QString& hostname, quint16 port, const QString& domainName = QString()); const JSONCallbackParameters& apiCallbackParameters(); diff --git a/libraries/networking/src/DomainHandler.cpp b/libraries/networking/src/DomainHandler.cpp index 6091b0cdd2..34aef8b98f 100644 --- a/libraries/networking/src/DomainHandler.cpp +++ b/libraries/networking/src/DomainHandler.cpp @@ -97,39 +97,19 @@ void DomainHandler::setUUID(const QUuid& uuid) { } } -QString DomainHandler::hostnameWithoutPort(const QString& hostname) { - int colonIndex = hostname.indexOf(':'); - return colonIndex > 0 ? hostname.left(colonIndex) : hostname; -} - -bool DomainHandler::isCurrentHostname(const QString& hostname) { - return hostnameWithoutPort(hostname) == _hostname; -} - -void DomainHandler::setHostname(const QString& hostname) { +void DomainHandler::setHostnameAndPort(const QString& hostname, quint16 port) { - if (hostname != _hostname) { + if (hostname != _hostname || _sockAddr.getPort() != port) { // re-set the domain info so that auth information is reloaded hardReset(); - int colonIndex = hostname.indexOf(':'); + // the new hostname is everything up to the colon + _hostname = hostname; - if (colonIndex > 0) { - // the user has included a custom DS port with the hostname - - // the new hostname is everything up to the colon - _hostname = hostname.left(colonIndex); - - // grab the port by reading the string after the colon - _sockAddr.setPort(atoi(hostname.mid(colonIndex + 1, hostname.size()).toLocal8Bit().constData())); - - qDebug() << "Updated hostname to" << _hostname << "and port to" << _sockAddr.getPort(); - - } else { - // no port included with the hostname, simply set the member variable and reset the domain server port to default - _hostname = hostname; - _sockAddr.setPort(DEFAULT_DOMAIN_SERVER_PORT); - } + // grab the port by reading the string after the colon + _sockAddr.setPort(port); + + qDebug() << "Updated hostname to" << _hostname << "and port to" << _sockAddr.getPort(); // re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname qDebug("Looking up DS hostname %s.", _hostname.toLocal8Bit().constData()); diff --git a/libraries/networking/src/DomainHandler.h b/libraries/networking/src/DomainHandler.h index a27a5d1dd8..295e6eac01 100644 --- a/libraries/networking/src/DomainHandler.h +++ b/libraries/networking/src/DomainHandler.h @@ -37,9 +37,7 @@ public: const QUuid& getUUID() const { return _uuid; } void setUUID(const QUuid& uuid); - - static QString hostnameWithoutPort(const QString& hostname); - bool isCurrentHostname(const QString& hostname); + const QString& getHostname() const { return _hostname; } const QHostAddress& getIP() const { return _sockAddr.getAddress(); } @@ -75,7 +73,7 @@ public: void softReset(); public slots: - void setHostname(const QString& hostname); + void setHostnameAndPort(const QString& hostname, quint16 port = DEFAULT_DOMAIN_SERVER_PORT); void setIceServerHostnameAndID(const QString& iceServerHostname, const QUuid& id); private slots: diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index bf992e7b88..6f6c84f947 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -18,6 +18,7 @@ #include #include "AccountManager.h" +#include "AddressManager.h" #include "Assignment.h" #include "HifiSockAddr.h" #include "NodeList.h" @@ -62,6 +63,15 @@ NodeList::NodeList(char newOwnerType, unsigned short socketListenPort, unsigned _hasCompletedInitialSTUNFailure(false), _stunRequestsSinceSuccess(0) { + AddressManager& addressManager = AddressManager::getInstance(); + + // handle domain change signals from AddressManager + connect(&addressManager, &AddressManager::possibleDomainChangeRequired, + &_domainHandler, &DomainHandler::setHostnameAndPort); + + connect(&addressManager, &AddressManager::possibleDomainChangeRequiredViaICEForID, + &_domainHandler, &DomainHandler::setIceServerHostnameAndID); + // clear our NodeList when the domain changes connect(&_domainHandler, &DomainHandler::disconnectedFromDomain, this, &NodeList::reset); From 3a4f75ff62ead277e5206110e5125c3f129c212e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 18 Dec 2014 16:40:02 -0800 Subject: [PATCH 4/9] fix AddressManager domain lookup to handle port --- libraries/networking/src/AddressManager.cpp | 12 ++++----- libraries/networking/src/DomainHandler.cpp | 28 +++++++++++++-------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index f3c14a4597..57412b645f 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -241,11 +241,11 @@ void AddressManager::attemptPlaceNameLookup(const QString& lookupString) { } bool AddressManager::handleNetworkAddress(const QString& lookupString) { - const QString IP_ADDRESS_REGEX_STRING = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}" - "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(:\\d{1,5})?$"; + const QString IP_ADDRESS_REGEX_STRING = "^((?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}" + "(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(?::(\\d{1,5}))?$"; const QString HOSTNAME_REGEX_STRING = "^((?:[A-Z0-9]|[A-Z0-9][A-Z0-9\\-]{0,61}[A-Z0-9])" - "(?:\\.(?:[A-Z0-9]|[A-Z0-9][A-Z0-9\\-]{0,61}[A-Z0-9]))+|localhost)(:{1}\\d{1,5})?$"; + "(?:\\.(?:[A-Z0-9]|[A-Z0-9][A-Z0-9\\-]{0,61}[A-Z0-9]))+|localhost)(?::(\\d{1,5}))?$"; QRegExp ipAddressRegex(IP_ADDRESS_REGEX_STRING); @@ -253,7 +253,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) { QString domainIPString = ipAddressRegex.cap(1); qint16 domainPort = DEFAULT_DOMAIN_SERVER_PORT; - if (ipAddressRegex.captureCount() > 1) { + if (!ipAddressRegex.cap(2).isEmpty()) { domainPort = (qint16) ipAddressRegex.cap(2).toInt(); } @@ -269,8 +269,8 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) { QString domainHostname = hostnameRegex.cap(1); qint16 domainPort = DEFAULT_DOMAIN_SERVER_PORT; - if (ipAddressRegex.captureCount() > 1) { - domainPort = (qint16) ipAddressRegex.cap(2).toInt(); + if (!hostnameRegex.cap(2).isEmpty()) { + domainPort = (qint16) hostnameRegex.cap(2).toInt(); } emit lookupResultsFinished(); diff --git a/libraries/networking/src/DomainHandler.cpp b/libraries/networking/src/DomainHandler.cpp index 34aef8b98f..126ef27414 100644 --- a/libraries/networking/src/DomainHandler.cpp +++ b/libraries/networking/src/DomainHandler.cpp @@ -103,20 +103,26 @@ void DomainHandler::setHostnameAndPort(const QString& hostname, quint16 port) { // re-set the domain info so that auth information is reloaded hardReset(); - // the new hostname is everything up to the colon - _hostname = hostname; + if (hostname != _hostname) { + // set the new hostname + _hostname = hostname; + + qDebug() << "Updated domain hostname to" << _hostname; + + // re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname + qDebug("Looking up DS hostname %s.", _hostname.toLocal8Bit().constData()); + QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup(const QHostInfo&))); + + UserActivityLogger::getInstance().changedDomain(_hostname); + emit hostnameChanged(_hostname); + } + + if (_sockAddr.getPort() != port) { + qDebug() << "Updated domain port to" << port; + } // grab the port by reading the string after the colon _sockAddr.setPort(port); - - qDebug() << "Updated hostname to" << _hostname << "and port to" << _sockAddr.getPort(); - - // re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname - qDebug("Looking up DS hostname %s.", _hostname.toLocal8Bit().constData()); - QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup(const QHostInfo&))); - - UserActivityLogger::getInstance().changedDomain(_hostname); - emit hostnameChanged(_hostname); } } From 0b1445f8b52139394dde411ea3ea066466e28cab Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 18 Dec 2014 16:41:37 -0800 Subject: [PATCH 5/9] show the address dialog with current address selected --- interface/src/ui/AddressBarDialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/src/ui/AddressBarDialog.cpp b/interface/src/ui/AddressBarDialog.cpp index 5f55aa5210..75049f9ed4 100644 --- a/interface/src/ui/AddressBarDialog.cpp +++ b/interface/src/ui/AddressBarDialog.cpp @@ -116,8 +116,9 @@ void AddressBarDialog::setupUI() { void AddressBarDialog::showEvent(QShowEvent* event) { _goButton->setIcon(QIcon(PathUtils::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON)); - _addressLineEdit->setText(QString()); + _addressLineEdit->setText(AddressManager::getInstance().currentAddress().toString()); _addressLineEdit->setFocus(); + _addressLineEdit->selectAll(); FramelessDialog::showEvent(event); } From dd06d1f4a9f5ca9b1d4cf6ce806ece502d530aba Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 19 Dec 2014 10:01:14 -0800 Subject: [PATCH 6/9] added comments to explain hand state --- libraries/avatars/src/AvatarData.cpp | 7 +++++++ libraries/avatars/src/AvatarData.h | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 01f84ca246..a5ee3f7fff 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -443,7 +443,14 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) { // key state, stored as a semi-nibble in the bitItems _keyState = (KeyState)getSemiNibbleAt(bitItems,KEY_STATE_START_BIT); + // hand state, stored as a semi-nibble plus a bit in the bitItems + // we store the hand state as well as other items in a shared bitset. The hand state is an octal, but is split + // into two sections to maintain backward compatibility. The bits are ordered as such (0-7 left to right). + // +---+-----+-----+--+ + // |x,x|H0,H1|x,x,x|H2| + // +---+-----+-----+--+ + // Hand state - H0,H1,H2 is found in the 3rd, 4th, and 8th bits _handState = getSemiNibbleAt(bitItems, HAND_STATE_START_BIT) + (oneAtBit(bitItems, HAND_STATE_FINGER_POINTING_BIT) ? IS_FINGER_POINTING_FLAG : 0); diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 55b35377c0..6564d53317 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -76,7 +76,17 @@ const quint32 AVATAR_MOTION_SCRIPTABLE_BITS = AVATAR_MOTION_STAND_ON_NEARBY_FLOORS; -// First bitset +// Bitset of state flags - we store the key state, hand state, faceshift, chat circling, and existance of +// referential data in this bit set. The hand state is an octal, but is split into two sections to maintain +// backward compatibility. The bits are ordered as such (0-7 left to right). +// +-----+-----+-+-+-+--+ +// |K0,K1|H0,H1|F|C|R|H2| +// +-----+-----+-+-+-+--+ +// Key state - K0,K1 is found in the 1st and 2nd bits +// Hand state - H0,H1,H2 is found in the 3rd, 4th, and 8th bits +// Faceshift - F is found in the 5th bit +// Chat Circling - C is found in the 6th bit +// Referential Data - R is found in the 7th bit const int KEY_STATE_START_BIT = 0; // 1st and 2nd bits const int HAND_STATE_START_BIT = 2; // 3rd and 4th bits const int IS_FACESHIFT_CONNECTED = 4; // 5th bit From 51121554e51cc13d223d3ace1f47b6e453f8208a Mon Sep 17 00:00:00 2001 From: Adrianl3d Date: Sat, 20 Dec 2014 04:28:39 +1000 Subject: [PATCH 7/9] clean up code intentations lines 263 264 --- examples/notifications.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/notifications.js b/examples/notifications.js index 7946213abd..5527fc35fc 100644 --- a/examples/notifications.js +++ b/examples/notifications.js @@ -260,8 +260,8 @@ function checkSize(){ // Triggers notification if a user logs on or off function onOnlineUsersChanged(users) { for (user in users) { - if (last_users.indexOf(users[user]) == -1.0) { - createNotification(users[user] + " has joined"); + if (last_users.indexOf(users[user]) == -1.0) { + createNotification(users[user] + " has joined"); } } for (user in last_users) { From 979f5f8fc50784bb17dc1208e33f58a3f02ab844 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 19 Dec 2014 12:19:49 -0800 Subject: [PATCH 8/9] fix for coding standard compliance --- libraries/networking/src/AddressManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index 57412b645f..f9789ff97e 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -350,7 +350,7 @@ bool AddressManager::handleUsername(const QString& lookupString) { } -void AddressManager::setDomainInfo(const QString &hostname, quint16 port, const QString& domainName) { +void AddressManager::setDomainInfo(const QString& hostname, quint16 port, const QString& domainName) { _currentDomain = domainName.isEmpty() ? hostname : domainName; emit possibleDomainChangeRequired(hostname, port); } From 66b1886b440e810f7400ec186ca7ef4044d3b934 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 19 Dec 2014 12:33:26 -0800 Subject: [PATCH 9/9] don't add the unused assignment type to DS queue --- domain-server/src/DomainServer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 73092b694b..cea5bec3ef 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -549,7 +549,9 @@ void DomainServer::populateDefaultStaticAssignmentsExcludingTypes(const QSet(static_cast(defaultedType) + 1)) { - if (!excludedTypes.contains(defaultedType) && defaultedType != Assignment::AgentType) { + if (!excludedTypes.contains(defaultedType) + && defaultedType != Assignment::UNUSED + && defaultedType != Assignment::AgentType) { // type has not been set from a command line or config file config, use the default // by clearing whatever exists and writing a single default assignment with no payload Assignment* newAssignment = new Assignment(Assignment::CreateCommand, (Assignment::Type) defaultedType);