Showing the changes to libraries/script-engine/src/UsersScriptingInterface.cpp (1 of 5 files). Show all
Unified · Split
| @@ -12,8 +12,6 @@ · 11 unmodified lines | ||
| 12 | 12 | #include "UsersScriptingInterface.h" |
| 13 | 13 | |
| 14 | 14 | #include <NodeList.h> |
| 15 | −#include <AvatarHashMap.h> | |
| 16 | −#include <OffscreenUi.h> | |
| 17 | 15 | |
| 18 | 16 | UsersScriptingInterface::UsersScriptingInterface() { |
| 19 | 17 | // emit a signal when kick permissions have changed |
| @@ -54,42 +52,14 @@ float UsersScriptingInterface::getAvatarGain(const QUuid& nodeID) { · 34 unmodified lines | ||
| 54 | 52 | } |
| 55 | 53 | |
| 56 | 54 | void UsersScriptingInterface::kick(const QUuid& nodeID) { |
| 57 | − bool waitingForKickResponse = _kickResponseLock.resultWithReadLock<bool>([&] { return _waitingForKickResponse; }); | |
| 58 | − if (getCanKick() && !waitingForKickResponse) { | |
| 59 | 55 | |
| 60 | − | |
| 61 | − auto avatarHashMap = DependencyManager::get<AvatarHashMap>(); | |
| 62 | − auto avatar = avatarHashMap->getAvatarBySessionID(nodeID); | |
| 63 | − | |
| 64 | − QString userName; | |
| 65 | − | |
| 66 | − if (avatar) { | |
| 67 | − userName = avatar->getSessionDisplayName(); | |
| 68 | − } else { | |
| 69 | − userName = nodeID.toString(); | |
| 70 | − } | |
| 71 | − | |
| 72 | − QString kickMessage = "Do you wish to kick " + userName + " from your domain"; | |
| 73 | − ModalDialogListener* dlg = OffscreenUi::asyncQuestion("Kick User", kickMessage, | |
| 74 | − QMessageBox::Yes | QMessageBox::No); | |
| 75 | − | |
| 76 | − if (dlg->getDialogItem()) { | |
| 77 | − | |
| 78 | − QObject::connect(dlg, &ModalDialogListener::response, this, [=] (QVariant answer) { | |
| 79 | − QObject::disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 80 | − | |
| 81 | − bool yes = (static_cast<QMessageBox::StandardButton>(answer.toInt()) == QMessageBox::Yes); | |
| 82 | − // ask the NodeList to kick the user with the given session ID | |
| 83 | − | |
| 84 | − if (yes) { | |
| 85 | − DependencyManager::get<NodeList>()->kickNodeBySessionID(nodeID); | |
| 86 | − } | |
| 87 | − | |
| 88 | − _kickResponseLock.withWriteLock([&] { _waitingForKickResponse = false; }); | |
| 89 | − }); | |
| 90 | − | |
| 91 | − _kickResponseLock.withWriteLock([&] { _waitingForKickResponse = true; }); | |
| 56 | + if (_kickConfirmationOperator) { | |
| 57 | + bool waitingForKickResponse = _kickResponseLock.resultWithReadLock<bool>([&] { return _waitingForKickResponse; }); | |
| 58 | + if (getCanKick() && !waitingForKickResponse) { | |
| 59 | + _kickConfirmationOperator(nodeID); | |
| 92 | 60 | } |
| 61 | + } else { | |
| 62 | + DependencyManager::get<NodeList>()->kickNodeBySessionID(nodeID); | |
| 93 | 63 | } |
| 94 | 64 | } |
| 95 | 65 | |