mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 22:13:12 +02:00
Move API call to Entities scripting and out of Users
This commit is contained in:
parent
e0fd391766
commit
bdb12c38cf
6 changed files with 85 additions and 14 deletions
|
@ -928,7 +928,7 @@ void OctreeServer::handleJurisdictionRequestPacket(QSharedPointer<ReceivedMessag
|
||||||
|
|
||||||
void OctreeServer::handleOctreeFileReplacement(QSharedPointer<ReceivedMessage> message) {
|
void OctreeServer::handleOctreeFileReplacement(QSharedPointer<ReceivedMessage> message) {
|
||||||
if (!_isFinished && !_isShuttingDown) {
|
if (!_isFinished && !_isShuttingDown) {
|
||||||
// these messages are only allowed to come from the domain server, so make sure that is the case
|
// these messages are only allowed to come from the domain server or authenticated users, so make sure that is the case
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
if (message->getSenderSockAddr() == nodeList->getDomainHandler().getSockAddr()) {
|
if (message->getSenderSockAddr() == nodeList->getDomainHandler().getSockAddr()) {
|
||||||
// it's far cleaner to load up the new content upon server startup
|
// it's far cleaner to load up the new content upon server startup
|
||||||
|
@ -977,6 +977,64 @@ void OctreeServer::handleOctreeFileReplacement(QSharedPointer<ReceivedMessage> m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OctreeServer::handleOctreeFileReplacementFromURL(QString url) {
|
||||||
|
if (!_isFinished && !_isShuttingDown) {
|
||||||
|
// This call comes from Interface, so we skip our domain server check
|
||||||
|
if (!_persistAbsoluteFilePath.isEmpty()) {
|
||||||
|
// Download from our QString
|
||||||
|
QUrl modelsURL = QUrl(url, QUrl::StrictMode);
|
||||||
|
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||||
|
QNetworkRequest request(modelsURL);
|
||||||
|
QNetworkReply* reply = networkAccessManager.get(request);
|
||||||
|
connect(reply, &QNetworkReply::finished, [this, reply, modelsURL]() {
|
||||||
|
QNetworkReply::NetworkError networkError = reply->error();
|
||||||
|
if (networkError == QNetworkReply::NoError) {
|
||||||
|
QByteArray contents = reply->readAll();
|
||||||
|
|
||||||
|
// Like above, assume we have compressed data
|
||||||
|
auto compressedOctree = contents;
|
||||||
|
QByteArray jsonOctree;
|
||||||
|
|
||||||
|
bool wasCompressed = gunzip(compressedOctree, jsonOctree);
|
||||||
|
if (!wasCompressed) {
|
||||||
|
// the source was not compressed, assume we were sent regular JSON data
|
||||||
|
jsonOctree = compressedOctree;
|
||||||
|
}
|
||||||
|
// check the JSON data to verify it is an object
|
||||||
|
if (QJsonDocument::fromJson(jsonOctree).isObject()) {
|
||||||
|
if (!wasCompressed) {
|
||||||
|
// source was not compressed, we compress it before we write it locally
|
||||||
|
gzip(jsonOctree, compressedOctree);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write the compressed octree data to a special file
|
||||||
|
auto replacementFilePath = _persistAbsoluteFilePath.append(OctreePersistThread::REPLACEMENT_FILE_EXTENSION);
|
||||||
|
QFile replacementFile(replacementFilePath);
|
||||||
|
if (replacementFile.open(QIODevice::WriteOnly) && replacementFile.write(compressedOctree) != -1) {
|
||||||
|
// we've now written our replacement file, time to take the server down so it can
|
||||||
|
// process it when it comes back up
|
||||||
|
qInfo() << "Wrote octree replacement file to" << replacementFilePath << "- stopping server";
|
||||||
|
setFinished(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qWarning() << "Could not write replacement octree data to file - refusing to process";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "Received replacement octree file that is invalid - refusing to process";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "Error downloading JSON from specified file";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qDebug() << "Cannot perform octree file replacement since current persist file path is not yet known";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool OctreeServer::readOptionBool(const QString& optionName, const QJsonObject& settingsSectionObject, bool& result) {
|
bool OctreeServer::readOptionBool(const QString& optionName, const QJsonObject& settingsSectionObject, bool& result) {
|
||||||
result = false; // assume it doesn't exist
|
result = false; // assume it doesn't exist
|
||||||
bool optionAvailable = false;
|
bool optionAvailable = false;
|
||||||
|
|
|
@ -137,6 +137,7 @@ private slots:
|
||||||
void handleOctreeDataNackPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
|
void handleOctreeDataNackPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
|
||||||
void handleJurisdictionRequestPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
|
void handleJurisdictionRequestPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
|
||||||
void handleOctreeFileReplacement(QSharedPointer<ReceivedMessage> message);
|
void handleOctreeFileReplacement(QSharedPointer<ReceivedMessage> message);
|
||||||
|
void handleOctreeFileReplacementFromURL(QString url);
|
||||||
void removeSendThread();
|
void removeSendThread();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -47,6 +47,8 @@ EntityScriptingInterface::EntityScriptingInterface(bool bidOnSimulationOwnership
|
||||||
connect(nodeList.data(), &NodeList::canRezChanged, this, &EntityScriptingInterface::canRezChanged);
|
connect(nodeList.data(), &NodeList::canRezChanged, this, &EntityScriptingInterface::canRezChanged);
|
||||||
connect(nodeList.data(), &NodeList::canRezTmpChanged, this, &EntityScriptingInterface::canRezTmpChanged);
|
connect(nodeList.data(), &NodeList::canRezTmpChanged, this, &EntityScriptingInterface::canRezTmpChanged);
|
||||||
connect(nodeList.data(), &NodeList::canWriteAssetsChanged, this, &EntityScriptingInterface::canWriteAssetsChanged);
|
connect(nodeList.data(), &NodeList::canWriteAssetsChanged, this, &EntityScriptingInterface::canWriteAssetsChanged);
|
||||||
|
connect(nodeList.data(), &NodeList::canReplaceContentChanged, this, &EntityScriptingInterface::canReplaceDomainContentChanged);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityScriptingInterface::queueEntityMessage(PacketType packetType,
|
void EntityScriptingInterface::queueEntityMessage(PacketType packetType,
|
||||||
|
@ -80,6 +82,11 @@ bool EntityScriptingInterface::canWriteAssets() {
|
||||||
return nodeList->getThisNodeCanWriteAssets();
|
return nodeList->getThisNodeCanWriteAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EntityScriptingInterface::canReplaceDomainContent() {
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
return nodeList->getThisNodeCanReplaceContent();
|
||||||
|
}
|
||||||
|
|
||||||
void EntityScriptingInterface::setEntityTree(EntityTreePointer elementTree) {
|
void EntityScriptingInterface::setEntityTree(EntityTreePointer elementTree) {
|
||||||
if (_entityTree) {
|
if (_entityTree) {
|
||||||
disconnect(_entityTree.get(), &EntityTree::addingEntity, this, &EntityScriptingInterface::addingEntity);
|
disconnect(_entityTree.get(), &EntityTree::addingEntity, this, &EntityScriptingInterface::addingEntity);
|
||||||
|
@ -1158,6 +1165,9 @@ bool EntityScriptingInterface::actionWorker(const QUuid& entityID,
|
||||||
return doTransmit;
|
return doTransmit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityScriptingInterface::replaceDomainContentSet(const QString url){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
QUuid EntityScriptingInterface::addAction(const QString& actionTypeString,
|
QUuid EntityScriptingInterface::addAction(const QString& actionTypeString,
|
||||||
const QUuid& entityID,
|
const QUuid& entityID,
|
||||||
|
|
|
@ -359,6 +359,19 @@ public slots:
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE glm::mat4 getEntityLocalTransform(const QUuid& entityID);
|
Q_INVOKABLE glm::mat4 getEntityLocalTransform(const QUuid& entityID);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Returns true if the user has permissions to replace domain content sets
|
||||||
|
* @function Entities.canReplaceDomainContent
|
||||||
|
* @return {bool} true if the user has permissions to replace domain content sets, false if not
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE bool canReplaceDomainContent();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* TODO: temporary placement for content set calls
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE void replaceDomainContentSet(const QString fileURL);
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void collisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
void collisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||||
|
|
||||||
|
@ -366,6 +379,7 @@ signals:
|
||||||
void canRezChanged(bool canRez);
|
void canRezChanged(bool canRez);
|
||||||
void canRezTmpChanged(bool canRez);
|
void canRezTmpChanged(bool canRez);
|
||||||
void canWriteAssetsChanged(bool canWriteAssets);
|
void canWriteAssetsChanged(bool canWriteAssets);
|
||||||
|
void canReplaceDomainContentChanged();
|
||||||
|
|
||||||
void mousePressOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
void mousePressOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
void mouseMoveOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
void mouseMoveOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
|
|
|
@ -19,7 +19,6 @@ UsersScriptingInterface::UsersScriptingInterface() {
|
||||||
connect(nodeList.data(), &LimitedNodeList::canKickChanged, this, &UsersScriptingInterface::canKickChanged);
|
connect(nodeList.data(), &LimitedNodeList::canKickChanged, this, &UsersScriptingInterface::canKickChanged);
|
||||||
connect(nodeList.data(), &NodeList::ignoreRadiusEnabledChanged, this, &UsersScriptingInterface::ignoreRadiusEnabledChanged);
|
connect(nodeList.data(), &NodeList::ignoreRadiusEnabledChanged, this, &UsersScriptingInterface::ignoreRadiusEnabledChanged);
|
||||||
connect(nodeList.data(), &NodeList::usernameFromIDReply, this, &UsersScriptingInterface::usernameFromIDReply);
|
connect(nodeList.data(), &NodeList::usernameFromIDReply, this, &UsersScriptingInterface::usernameFromIDReply);
|
||||||
connect(nodeList.data(), &NodeList::canReplaceContentChanged, this, &UsersScriptingInterface::canReplaceContentChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsersScriptingInterface::ignore(const QUuid& nodeID, bool ignoreEnabled) {
|
void UsersScriptingInterface::ignore(const QUuid& nodeID, bool ignoreEnabled) {
|
||||||
|
@ -94,6 +93,4 @@ bool UsersScriptingInterface::getRequestsDomainListData() {
|
||||||
void UsersScriptingInterface::setRequestsDomainListData(bool isRequesting) {
|
void UsersScriptingInterface::setRequestsDomainListData(bool isRequesting) {
|
||||||
DependencyManager::get<NodeList>()->setRequestsDomainListData(isRequesting);
|
DependencyManager::get<NodeList>()->setRequestsDomainListData(isRequesting);
|
||||||
}
|
}
|
||||||
bool UsersScriptingInterface::getCanReplaceContent() {
|
|
||||||
return DependencyManager::get<NodeList>()->getThisNodeCanReplaceContent();
|
|
||||||
}
|
|
||||||
|
|
|
@ -25,8 +25,6 @@ class UsersScriptingInterface : public QObject, public Dependency {
|
||||||
|
|
||||||
Q_PROPERTY(bool canKick READ getCanKick)
|
Q_PROPERTY(bool canKick READ getCanKick)
|
||||||
Q_PROPERTY(bool requestsDomainListData READ getRequestsDomainListData WRITE setRequestsDomainListData)
|
Q_PROPERTY(bool requestsDomainListData READ getRequestsDomainListData WRITE setRequestsDomainListData)
|
||||||
Q_PROPERTY(bool canReplaceContent READ getCanReplaceContent)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UsersScriptingInterface();
|
UsersScriptingInterface();
|
||||||
|
|
||||||
|
@ -132,12 +130,6 @@ public slots:
|
||||||
*/
|
*/
|
||||||
bool getIgnoreRadiusEnabled();
|
bool getIgnoreRadiusEnabled();
|
||||||
|
|
||||||
/**jsdoc
|
|
||||||
* Returns true if the user has permissions to replace domain content sets
|
|
||||||
* @function Users.getCanReplaceContent
|
|
||||||
* @return {bool} true if the user has permissions to replace domain content sets, false if not
|
|
||||||
*/
|
|
||||||
bool getCanReplaceContent();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void canKickChanged(bool canKick);
|
void canKickChanged(bool canKick);
|
||||||
|
@ -162,7 +154,6 @@ signals:
|
||||||
* @param {nodeID} NodeID The session ID of the avatar that has disconnected
|
* @param {nodeID} NodeID The session ID of the avatar that has disconnected
|
||||||
*/
|
*/
|
||||||
void avatarDisconnected(const QUuid& nodeID);
|
void avatarDisconnected(const QUuid& nodeID);
|
||||||
void canReplaceContentChanged(bool canReplaceContent);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool getRequestsDomainListData();
|
bool getRequestsDomainListData();
|
||||||
|
|
Loading…
Reference in a new issue