mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 19:13:38 +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) {
|
||||
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>();
|
||||
if (message->getSenderSockAddr() == nodeList->getDomainHandler().getSockAddr()) {
|
||||
// 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) {
|
||||
result = false; // assume it doesn't exist
|
||||
bool optionAvailable = false;
|
||||
|
|
|
@ -137,6 +137,7 @@ private slots:
|
|||
void handleOctreeDataNackPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
|
||||
void handleJurisdictionRequestPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
|
||||
void handleOctreeFileReplacement(QSharedPointer<ReceivedMessage> message);
|
||||
void handleOctreeFileReplacementFromURL(QString url);
|
||||
void removeSendThread();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -47,6 +47,8 @@ EntityScriptingInterface::EntityScriptingInterface(bool bidOnSimulationOwnership
|
|||
connect(nodeList.data(), &NodeList::canRezChanged, this, &EntityScriptingInterface::canRezChanged);
|
||||
connect(nodeList.data(), &NodeList::canRezTmpChanged, this, &EntityScriptingInterface::canRezTmpChanged);
|
||||
connect(nodeList.data(), &NodeList::canWriteAssetsChanged, this, &EntityScriptingInterface::canWriteAssetsChanged);
|
||||
connect(nodeList.data(), &NodeList::canReplaceContentChanged, this, &EntityScriptingInterface::canReplaceDomainContentChanged);
|
||||
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::queueEntityMessage(PacketType packetType,
|
||||
|
@ -80,6 +82,11 @@ bool EntityScriptingInterface::canWriteAssets() {
|
|||
return nodeList->getThisNodeCanWriteAssets();
|
||||
}
|
||||
|
||||
bool EntityScriptingInterface::canReplaceDomainContent() {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
return nodeList->getThisNodeCanReplaceContent();
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::setEntityTree(EntityTreePointer elementTree) {
|
||||
if (_entityTree) {
|
||||
disconnect(_entityTree.get(), &EntityTree::addingEntity, this, &EntityScriptingInterface::addingEntity);
|
||||
|
@ -1158,6 +1165,9 @@ bool EntityScriptingInterface::actionWorker(const QUuid& entityID,
|
|||
return doTransmit;
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::replaceDomainContentSet(const QString url){
|
||||
|
||||
}
|
||||
|
||||
QUuid EntityScriptingInterface::addAction(const QString& actionTypeString,
|
||||
const QUuid& entityID,
|
||||
|
|
|
@ -359,6 +359,19 @@ public slots:
|
|||
*/
|
||||
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:
|
||||
void collisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||
|
||||
|
@ -366,6 +379,7 @@ signals:
|
|||
void canRezChanged(bool canRez);
|
||||
void canRezTmpChanged(bool canRez);
|
||||
void canWriteAssetsChanged(bool canWriteAssets);
|
||||
void canReplaceDomainContentChanged();
|
||||
|
||||
void mousePressOnEntity(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(), &NodeList::ignoreRadiusEnabledChanged, this, &UsersScriptingInterface::ignoreRadiusEnabledChanged);
|
||||
connect(nodeList.data(), &NodeList::usernameFromIDReply, this, &UsersScriptingInterface::usernameFromIDReply);
|
||||
connect(nodeList.data(), &NodeList::canReplaceContentChanged, this, &UsersScriptingInterface::canReplaceContentChanged);
|
||||
}
|
||||
|
||||
void UsersScriptingInterface::ignore(const QUuid& nodeID, bool ignoreEnabled) {
|
||||
|
@ -94,6 +93,4 @@ bool UsersScriptingInterface::getRequestsDomainListData() {
|
|||
void UsersScriptingInterface::setRequestsDomainListData(bool 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 requestsDomainListData READ getRequestsDomainListData WRITE setRequestsDomainListData)
|
||||
Q_PROPERTY(bool canReplaceContent READ getCanReplaceContent)
|
||||
|
||||
public:
|
||||
UsersScriptingInterface();
|
||||
|
||||
|
@ -132,12 +130,6 @@ public slots:
|
|||
*/
|
||||
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:
|
||||
void canKickChanged(bool canKick);
|
||||
|
@ -162,7 +154,6 @@ signals:
|
|||
* @param {nodeID} NodeID The session ID of the avatar that has disconnected
|
||||
*/
|
||||
void avatarDisconnected(const QUuid& nodeID);
|
||||
void canReplaceContentChanged(bool canReplaceContent);
|
||||
|
||||
private:
|
||||
bool getRequestsDomainListData();
|
||||
|
|
Loading…
Reference in a new issue