From 095f0b93490633524f2ea2a68f802371cb5b61ac Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 1 Feb 2016 16:46:11 -0800 Subject: [PATCH 1/2] rename canAdjustLocks to isAllowedEditor for multi-purpose --- assignment-client/src/audio/AudioMixer.cpp | 2 +- domain-server/src/DomainGatekeeper.cpp | 14 +++++++------- domain-server/src/DomainServer.cpp | 2 +- .../entities/src/EntityScriptingInterface.cpp | 4 ++-- libraries/entities/src/EntityTree.cpp | 4 ++-- libraries/networking/src/LimitedNodeList.cpp | 15 +++++++-------- libraries/networking/src/LimitedNodeList.h | 10 +++++----- libraries/networking/src/Node.cpp | 8 ++++---- libraries/networking/src/Node.h | 8 ++++---- libraries/networking/src/NodeList.cpp | 12 ++++++------ 10 files changed, 39 insertions(+), 40 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index d85e1d137b..8967436e2d 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -551,7 +551,7 @@ void AudioMixer::handleNodeAudioPacket(QSharedPointer message, void AudioMixer::handleMuteEnvironmentPacket(QSharedPointer message, SharedNodePointer sendingNode) { auto nodeList = DependencyManager::get(); - if (sendingNode->getCanAdjustLocks()) { + if (sendingNode->isAllowedEditor()) { auto newPacket = NLPacket::create(PacketType::MuteEnvironment, message->getSize()); // Copy payload newPacket->write(message->getRawMessage(), message->getSize()); diff --git a/domain-server/src/DomainGatekeeper.cpp b/domain-server/src/DomainGatekeeper.cpp index fb67744d6e..3e4ee7b758 100644 --- a/domain-server/src/DomainGatekeeper.cpp +++ b/domain-server/src/DomainGatekeeper.cpp @@ -155,7 +155,7 @@ SharedNodePointer DomainGatekeeper::processAssignmentConnectRequest(const NodeCo _pendingAssignedNodes.erase(it); // always allow assignment clients to create and destroy entities - newNode->setCanAdjustLocks(true); + newNode->setIsAllowedEditor(true); newNode->setCanRez(true); return newNode; @@ -219,13 +219,13 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect } } - // if this user is in the editors list (or if the editors list is empty) set the user's node's canAdjustLocks to true + // if this user is in the editors list (or if the editors list is empty) set the user's node's isAllowedEditor to true const QVariant* allowedEditorsVariant = valueForKeyPath(_server->_settingsManager.getSettingsMap(), ALLOWED_EDITORS_SETTINGS_KEYPATH); QStringList allowedEditors = allowedEditorsVariant ? allowedEditorsVariant->toStringList() : QStringList(); // if the allowed editors list is empty then everyone can adjust locks - bool canAdjustLocks = allowedEditors.empty(); + bool isAllowedEditor = allowedEditors.empty(); if (allowedEditors.contains(username, Qt::CaseInsensitive)) { // we have a non-empty allowed editors list - check if this user is verified to be in it @@ -238,10 +238,10 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect << "will be given edit rights to avoid a thrasing of public key requests and connect requests."; } - canAdjustLocks = true; + isAllowedEditor = true; } else { // already verified this user and they are in the allowed editors list - canAdjustLocks = true; + isAllowedEditor = true; } } @@ -256,14 +256,14 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect bool canRez = true; if (onlyEditorsAreRezzers) { - canRez = canAdjustLocks; + canRez = isAllowedEditor; } // add the new node SharedNodePointer newNode = addVerifiedNodeFromConnectRequest(nodeConnection); // set the edit rights for this user - newNode->setCanAdjustLocks(canAdjustLocks); + newNode->setIsAllowedEditor(isAllowedEditor); newNode->setCanRez(canRez); // grab the linked data for our new node so we can set the username diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index db3c2df408..64b4f123f5 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -744,7 +744,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif extendedHeaderStream << limitedNodeList->getSessionUUID(); extendedHeaderStream << node->getUUID(); - extendedHeaderStream << (quint8) node->getCanAdjustLocks(); + extendedHeaderStream << (quint8) node->isAllowedEditor(); extendedHeaderStream << (quint8) node->getCanRez(); auto domainListPackets = NLPacketList::create(PacketType::DomainList, extendedHeader); diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 8fd7be912e..be9010cba5 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -29,7 +29,7 @@ EntityScriptingInterface::EntityScriptingInterface() : _entityTree(NULL) { auto nodeList = DependencyManager::get(); - connect(nodeList.data(), &NodeList::canAdjustLocksChanged, this, &EntityScriptingInterface::canAdjustLocksChanged); + connect(nodeList.data(), &NodeList::isAllowedEditorChanged, this, &EntityScriptingInterface::canAdjustLocksChanged); connect(nodeList.data(), &NodeList::canRezChanged, this, &EntityScriptingInterface::canRezChanged); } @@ -40,7 +40,7 @@ void EntityScriptingInterface::queueEntityMessage(PacketType packetType, bool EntityScriptingInterface::canAdjustLocks() { auto nodeList = DependencyManager::get(); - return nodeList->getThisNodeCanAdjustLocks(); + return nodeList->isAllowedEditor(); } bool EntityScriptingInterface::canRez() { diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 34dd809510..3c638fd1a2 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -124,10 +124,10 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI QUuid senderID; if (senderNode.isNull()) { auto nodeList = DependencyManager::get(); - allowLockChange = nodeList->getThisNodeCanAdjustLocks(); + allowLockChange = nodeList->isAllowedEditor(); senderID = nodeList->getSessionUUID(); } else { - allowLockChange = senderNode->getCanAdjustLocks(); + allowLockChange = senderNode->isAllowedEditor(); senderID = senderNode->getUUID(); } diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 3ea3175390..67237ee269 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -52,7 +52,6 @@ LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short _numCollectedPackets(0), _numCollectedBytes(0), _packetStatTimer(), - _thisNodeCanAdjustLocks(false), _thisNodeCanRez(true) { static bool firstCall = true; @@ -131,10 +130,10 @@ void LimitedNodeList::setSessionUUID(const QUuid& sessionUUID) { } } -void LimitedNodeList::setThisNodeCanAdjustLocks(bool canAdjustLocks) { - if (_thisNodeCanAdjustLocks != canAdjustLocks) { - _thisNodeCanAdjustLocks = canAdjustLocks; - emit canAdjustLocksChanged(canAdjustLocks); +void LimitedNodeList::setIsAllowedEditor(bool isAllowedEditor) { + if (_isAllowedEditor != isAllowedEditor) { + _isAllowedEditor = isAllowedEditor; + emit isAllowedEditorChanged(isAllowedEditor); } } @@ -515,7 +514,7 @@ void LimitedNodeList::handleNodeKill(const SharedNodePointer& node) { SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket, - bool canAdjustLocks, bool canRez, + bool isAllowedEditor, bool canRez, const QUuid& connectionSecret) { NodeHash::const_iterator it = _nodeHash.find(uuid); @@ -524,14 +523,14 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t matchingNode->setPublicSocket(publicSocket); matchingNode->setLocalSocket(localSocket); - matchingNode->setCanAdjustLocks(canAdjustLocks); + matchingNode->setIsAllowedEditor(isAllowedEditor); matchingNode->setCanRez(canRez); matchingNode->setConnectionSecret(connectionSecret); return matchingNode; } else { // we didn't have this node, so add them - Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket, canAdjustLocks, canRez, connectionSecret, this); + Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket, isAllowedEditor, canRez, connectionSecret, this); if (nodeType == NodeType::AudioMixer) { LimitedNodeList::flagTimeForConnectionStep(LimitedNodeList::AddedAudioMixer); diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index c9785d240b..fcad23da8f 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -104,8 +104,8 @@ public: const QUuid& getSessionUUID() const { return _sessionUUID; } void setSessionUUID(const QUuid& sessionUUID); - bool getThisNodeCanAdjustLocks() const { return _thisNodeCanAdjustLocks; } - void setThisNodeCanAdjustLocks(bool canAdjustLocks); + bool isAllowedEditor() const { return _isAllowedEditor; } + void setIsAllowedEditor(bool isAllowedEditor); bool getThisNodeCanRez() const { return _thisNodeCanRez; } void setThisNodeCanRez(bool canRez); @@ -137,7 +137,7 @@ public: SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket, - bool canAdjustLocks = false, bool canRez = false, + bool isAllowedEditor = false, bool canRez = false, const QUuid& connectionSecret = QUuid()); bool hasCompletedInitialSTUN() const { return _hasCompletedInitialSTUN; } @@ -244,7 +244,7 @@ signals: void localSockAddrChanged(const HifiSockAddr& localSockAddr); void publicSockAddrChanged(const HifiSockAddr& publicSockAddr); - void canAdjustLocksChanged(bool canAdjustLocks); + void isAllowedEditorChanged(bool isAllowedEditor); void canRezChanged(bool canRez); protected: @@ -289,7 +289,7 @@ protected: int _numCollectedBytes; QElapsedTimer _packetStatTimer; - bool _thisNodeCanAdjustLocks; + bool _isAllowedEditor { false }; bool _thisNodeCanRez; QPointer _initialSTUNTimer; diff --git a/libraries/networking/src/Node.cpp b/libraries/networking/src/Node.cpp index b28d0a6cb1..7e9bf60ea4 100644 --- a/libraries/networking/src/Node.cpp +++ b/libraries/networking/src/Node.cpp @@ -47,7 +47,7 @@ const QString& NodeType::getNodeTypeName(NodeType_t nodeType) { } Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket, - const HifiSockAddr& localSocket, bool canAdjustLocks, bool canRez, const QUuid& connectionSecret, + const HifiSockAddr& localSocket, bool isAllowedEditor, bool canRez, const QUuid& connectionSecret, QObject* parent) : NetworkPeer(uuid, publicSocket, localSocket, parent), _type(type), @@ -57,7 +57,7 @@ Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket, _clockSkewUsec(0), _mutex(), _clockSkewMovingPercentile(30, 0.8f), // moving 80th percentile of 30 samples - _canAdjustLocks(canAdjustLocks), + _isAllowedEditor(isAllowedEditor), _canRez(canRez) { // Update socket's object name @@ -84,7 +84,7 @@ QDataStream& operator<<(QDataStream& out, const Node& node) { out << node._uuid; out << node._publicSocket; out << node._localSocket; - out << node._canAdjustLocks; + out << node._isAllowedEditor; out << node._canRez; return out; @@ -95,7 +95,7 @@ QDataStream& operator>>(QDataStream& in, Node& node) { in >> node._uuid; in >> node._publicSocket; in >> node._localSocket; - in >> node._canAdjustLocks; + in >> node._isAllowedEditor; in >> node._canRez; return in; diff --git a/libraries/networking/src/Node.h b/libraries/networking/src/Node.h index 865e885add..ca05e5b84d 100644 --- a/libraries/networking/src/Node.h +++ b/libraries/networking/src/Node.h @@ -33,7 +33,7 @@ class Node : public NetworkPeer { public: Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket, - bool canAdjustLocks, bool canRez, const QUuid& connectionSecret = QUuid(), + bool isAllowedEditor, bool canRez, const QUuid& connectionSecret = QUuid(), QObject* parent = 0); bool operator==(const Node& otherNode) const { return _uuid == otherNode._uuid; } @@ -58,8 +58,8 @@ public: void updateClockSkewUsec(int clockSkewSample); QMutex& getMutex() { return _mutex; } - void setCanAdjustLocks(bool canAdjustLocks) { _canAdjustLocks = canAdjustLocks; } - bool getCanAdjustLocks() { return _canAdjustLocks; } + void setIsAllowedEditor(bool isAllowedEditor) { _isAllowedEditor = isAllowedEditor; } + bool isAllowedEditor() { return _isAllowedEditor; } void setCanRez(bool canRez) { _canRez = canRez; } bool getCanRez() { return _canRez; } @@ -81,7 +81,7 @@ private: int _clockSkewUsec; QMutex _mutex; MovingPercentile _clockSkewMovingPercentile; - bool _canAdjustLocks; + bool _isAllowedEditor; bool _canRez; }; diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 16277caace..677a1ad1e6 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -512,9 +512,9 @@ void NodeList::processDomainServerList(QSharedPointer message) packetStream >> newUUID; setSessionUUID(newUUID); - quint8 thisNodeCanAdjustLocks; - packetStream >> thisNodeCanAdjustLocks; - setThisNodeCanAdjustLocks((bool) thisNodeCanAdjustLocks); + quint8 isAllowedEditor; + packetStream >> isAllowedEditor; + setIsAllowedEditor((bool) isAllowedEditor); quint8 thisNodeCanRez; packetStream >> thisNodeCanRez; @@ -546,10 +546,10 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) { qint8 nodeType; QUuid nodeUUID, connectionUUID; HifiSockAddr nodePublicSocket, nodeLocalSocket; - bool canAdjustLocks; + bool isAllowedEditor; bool canRez; - packetStream >> nodeType >> nodeUUID >> nodePublicSocket >> nodeLocalSocket >> canAdjustLocks >> canRez; + packetStream >> nodeType >> nodeUUID >> nodePublicSocket >> nodeLocalSocket >> isAllowedEditor >> canRez; // if the public socket address is 0 then it's reachable at the same IP // as the domain server @@ -560,7 +560,7 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) { packetStream >> connectionUUID; SharedNodePointer node = addOrUpdateNode(nodeUUID, nodeType, nodePublicSocket, - nodeLocalSocket, canAdjustLocks, canRez, + nodeLocalSocket, isAllowedEditor, canRez, connectionUUID); } From 79dc2d5d5502f5aeaa98a0f55e6d0a6b012a7544 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 2 Feb 2016 11:40:15 -0800 Subject: [PATCH 2/2] add some debug for mute environment crash --- assignment-client/src/audio/AudioMixer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 8967436e2d..54032e993f 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -552,6 +552,8 @@ void AudioMixer::handleMuteEnvironmentPacket(QSharedPointer mes auto nodeList = DependencyManager::get(); if (sendingNode->isAllowedEditor()) { + qDebug() << "Received a mute environment packet of" << message->getSize() << "bytes"; + auto newPacket = NLPacket::create(PacketType::MuteEnvironment, message->getSize()); // Copy payload newPacket->write(message->getRawMessage(), message->getSize());