mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 14:03:55 +02:00
Super close
This commit is contained in:
parent
802e283508
commit
2c5db54b08
7 changed files with 39 additions and 47 deletions
|
@ -751,42 +751,31 @@ void DomainServerSettingsManager::processNodeKickRequestPacket(QSharedPointer<Re
|
|||
void DomainServerSettingsManager::processUsernameFromIDRequestPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
||||
// before we do any processing on this packet make sure it comes from a node that is allowed to kick
|
||||
if (sendingNode->getCanKick()) {
|
||||
// pull the UUID being kicked from the packet
|
||||
// From the packet, pull the UUID we're identifying
|
||||
QUuid nodeUUID = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
|
||||
|
||||
if (!nodeUUID.isNull() && nodeUUID != sendingNode->getUUID()) {
|
||||
if (!nodeUUID.isNull()) {
|
||||
// make sure we actually have a node with this UUID
|
||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||
|
||||
auto matchingNode = limitedNodeList->nodeWithUUID(nodeUUID);
|
||||
|
||||
if (matchingNode) {
|
||||
// we have a matching node, time to decide how to store updated permissions for this node
|
||||
|
||||
NodePermissionsPointer destinationPermissions;
|
||||
|
||||
// we have a matching node, time to figure out the username
|
||||
QString verifiedUsername = matchingNode->getPermissions().getVerifiedUserName();
|
||||
|
||||
bool newPermissions = false;
|
||||
|
||||
QByteArray printableVerifiedUsername;
|
||||
|
||||
if (!verifiedUsername.isEmpty()) {
|
||||
printableVerifiedUsername = qPrintable(verifiedUsername);
|
||||
} else {
|
||||
printableVerifiedUsername = qPrintable("");
|
||||
if (verifiedUsername.isEmpty()) {
|
||||
verifiedUsername = "";
|
||||
}
|
||||
// setup the packet
|
||||
auto usernameFromIDReplyPacket = NLPacket::create(PacketType::UsernameFromIDReply, NUM_BYTES_RFC4122_UUID + printableVerifiedUsername.length(), true);
|
||||
auto usernameFromIDReplyPacket = NLPacket::create(PacketType::UsernameFromIDReply, NUM_BYTES_RFC4122_UUID + sizeof(verifiedUsername), true);
|
||||
|
||||
// write the node ID to the packet
|
||||
usernameFromIDReplyPacket->write(nodeUUID.toRfc4122());
|
||||
// write the username to the packet
|
||||
usernameFromIDReplyPacket->write(printableVerifiedUsername);
|
||||
usernameFromIDReplyPacket->writeString(verifiedUsername);
|
||||
|
||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||
nodeList->sendPacket(std::move(usernameFromIDReplyPacket), message->getSenderSockAddr());
|
||||
qDebug() << "SENDING PACKET.";
|
||||
limitedNodeList->sendPacket(std::move(usernameFromIDReplyPacket), *sendingNode);
|
||||
}
|
||||
else {
|
||||
qWarning() << "Node username request received for unknown node. Refusing to process.";
|
||||
|
|
|
@ -76,7 +76,10 @@ Rectangle {
|
|||
var userId = message.params[0];
|
||||
var userName = message.params[1];
|
||||
var userIndex = findSessionIndex(userId);
|
||||
table.get(userIndex).itemCell.nameCard.userName = userName;
|
||||
console.log('computed userIndex:', userIndex);
|
||||
userModel.get(userIndex).userName = userName;
|
||||
userData[userIndex].userName = userName;
|
||||
break;
|
||||
default:
|
||||
console.log('Unrecognized message:', JSON.stringify(message));
|
||||
}
|
||||
|
|
|
@ -893,37 +893,35 @@ void NodeList::muteNodeBySessionID(const QUuid& nodeID) {
|
|||
|
||||
void NodeList::requestUsernameFromSessionID(const QUuid& nodeID) {
|
||||
// send a request to domain-server to get the username associated with the given session ID
|
||||
if (getThisNodeCanKick()) {
|
||||
// setup the packet
|
||||
auto usernameFromIDRequestPacket = NLPacket::create(PacketType::UsernameFromIDRequest, NUM_BYTES_RFC4122_UUID, true);
|
||||
|
||||
if (!nodeID.isNull()) {
|
||||
if (getThisNodeCanKick()) {
|
||||
// setup the packet
|
||||
auto usernameFromIDRequestPacket = NLPacket::create(PacketType::UsernameFromIDRequest, NUM_BYTES_RFC4122_UUID, true);
|
||||
|
||||
// write the node ID to the packet
|
||||
// write the node ID to the packet
|
||||
if (nodeID.isNull()) {
|
||||
usernameFromIDRequestPacket->write(getSessionUUID().toRfc4122());
|
||||
} else {
|
||||
usernameFromIDRequestPacket->write(nodeID.toRfc4122());
|
||||
|
||||
qDebug() << "Sending packet to get username of node" << uuidStringWithoutCurlyBraces(nodeID);
|
||||
|
||||
sendPacket(std::move(usernameFromIDRequestPacket), _domainHandler.getSockAddr());
|
||||
}
|
||||
else {
|
||||
qWarning() << "You do not have permissions to kick in this domain."
|
||||
<< "Request to get the username of node" << uuidStringWithoutCurlyBraces(nodeID) << "will not be sent";
|
||||
}
|
||||
|
||||
|
||||
qDebug() << "Sending packet to get username of node" << uuidStringWithoutCurlyBraces(nodeID);
|
||||
|
||||
sendPacket(std::move(usernameFromIDRequestPacket), _domainHandler.getSockAddr());
|
||||
}
|
||||
else {
|
||||
qWarning() << "NodeList::requestUsernameFromSessionID called with an invalid ID.";
|
||||
|
||||
qWarning() << "You do not have permissions to kick in this domain."
|
||||
<< "Request to get the username of node" << uuidStringWithoutCurlyBraces(nodeID) << "will not be sent";
|
||||
}
|
||||
}
|
||||
|
||||
void NodeList::processUsernameFromIDReply(QSharedPointer<ReceivedMessage> message) {
|
||||
// read the UUID from the packet
|
||||
QUuid nodeUUID = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
|
||||
QString nodeUUIDString = (QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID))).toString();
|
||||
// read the username from the packet
|
||||
QString username = message->readString();
|
||||
|
||||
qDebug() << "Got username" << username << "for node" << uuidStringWithoutCurlyBraces(nodeUUID);
|
||||
qDebug() << "Got username" << username << "for node" << nodeUUIDString;
|
||||
|
||||
emit usernameFromID(nodeUUID, username);
|
||||
emit usernameFromID(nodeUUIDString, username);
|
||||
}
|
||||
|
|
|
@ -82,7 +82,6 @@ public:
|
|||
void kickNodeBySessionID(const QUuid& nodeID);
|
||||
void muteNodeBySessionID(const QUuid& nodeID);
|
||||
void requestUsernameFromSessionID(const QUuid& nodeID);
|
||||
void processUsernameFromIDReply(QSharedPointer<ReceivedMessage> message);
|
||||
|
||||
public slots:
|
||||
void reset();
|
||||
|
@ -101,6 +100,8 @@ public slots:
|
|||
|
||||
void processICEPingPacket(QSharedPointer<ReceivedMessage> message);
|
||||
|
||||
void processUsernameFromIDReply(QSharedPointer<ReceivedMessage> message);
|
||||
|
||||
#if (PR_BUILD || DEV_BUILD)
|
||||
void toggleSendNewerDSConnectVersion(bool shouldSendNewerVersion) { _shouldSendNewerVersion = shouldSendNewerVersion; }
|
||||
#endif
|
||||
|
@ -110,7 +111,7 @@ signals:
|
|||
void receivedDomainServerList();
|
||||
void ignoredNode(const QUuid& nodeID);
|
||||
void ignoreRadiusEnabledChanged(bool isIgnored);
|
||||
void usernameFromID(QUuid& nodeID, QString& username);
|
||||
void usernameFromID(const QString& nodeID, const QString& username);
|
||||
|
||||
private slots:
|
||||
void stopKeepalivePingTimer();
|
||||
|
|
|
@ -103,8 +103,7 @@ public:
|
|||
RadiusIgnoreRequest,
|
||||
UsernameFromIDRequest,
|
||||
UsernameFromIDReply,
|
||||
LAST_PACKET_TYPE = RadiusIgnoreRequest
|
||||
//LAST_PACKET_TYPE = UsernameFromIDRequest
|
||||
LAST_PACKET_TYPE = UsernameFromIDReply
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ signals:
|
|||
* Notifies scripts of the username associated with a UUID.
|
||||
* @function Users.enteredIgnoreRadius
|
||||
*/
|
||||
void usernameFromID(QUuid& nodeID, QString& username);
|
||||
void usernameFromID(const QString& nodeID, const QString& username);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -118,10 +118,10 @@ function populateUserList() {
|
|||
var avatar = AvatarList.getAvatar(id);
|
||||
var avatarPalDatum = {
|
||||
displayName: avatar.displayName || ('anonymous ' + counter++),
|
||||
userName: (Users.canKick && id) ? 'Obtaining username...' : '',
|
||||
userName: '',
|
||||
sessionId: id || ''
|
||||
};
|
||||
if (Users.canKick && id) {
|
||||
if (Users.canKick) {
|
||||
Users.requestUsernameFromID(id);
|
||||
}
|
||||
data.push(avatarPalDatum);
|
||||
|
@ -134,7 +134,7 @@ function populateUserList() {
|
|||
}
|
||||
|
||||
function usernameFromID(id, username) {
|
||||
var data = { id: id, username: username + '\\' + id };
|
||||
var data = [id, username + '/' + id ];
|
||||
print('Username Data:', JSON.stringify(data));
|
||||
pal.sendToQml({ method: 'updateUsername', params: data });
|
||||
}
|
||||
|
@ -259,6 +259,7 @@ function onVisibileChanged() {
|
|||
button.clicked.connect(onClicked);
|
||||
pal.visibleChanged.connect(onVisibileChanged);
|
||||
pal.closed.connect(off);
|
||||
Users.usernameFromID.connect(usernameFromID);
|
||||
|
||||
//
|
||||
// Cleanup.
|
||||
|
@ -268,6 +269,7 @@ Script.scriptEnding.connect(function () {
|
|||
toolBar.removeButton(buttonName);
|
||||
pal.visibleChanged.disconnect(onVisibileChanged);
|
||||
pal.closed.disconnect(off);
|
||||
Users.usernameFromID.disconnect(usernameFromID);
|
||||
off();
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue