mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-07 10:02:24 +02:00
Import entities now works on domains that you do not have rights on.
This commit is contained in:
parent
cf41ed40ae
commit
afc23954c5
5 changed files with 21 additions and 17 deletions
|
@ -5542,7 +5542,7 @@ bool Application::importEntities(const QString& urlOrFilename, const bool isObse
|
|||
|
||||
// FIXME: readFromURL() can take over the main event loop which may cause problems, especially if downloading the JSON
|
||||
// from the Web.
|
||||
success = _entityClipboard->readFromURL(urlOrFilename, isObservable, callerId);
|
||||
success = _entityClipboard->readFromURL(urlOrFilename, isObservable, callerId, true);
|
||||
if (success) {
|
||||
_entityClipboard->reaverageOctreeElements();
|
||||
}
|
||||
|
|
|
@ -537,7 +537,7 @@ bool EntityTree::updateEntity(EntityItemPointer entity, const EntityItemProperti
|
|||
return true;
|
||||
}
|
||||
|
||||
EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const EntityItemProperties& properties, bool isClone) {
|
||||
EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const EntityItemProperties& properties, bool isClone, bool isImport) {
|
||||
EntityItemProperties props = properties;
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
@ -548,7 +548,8 @@ EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const Enti
|
|||
|
||||
if (properties.getEntityHostType() == entity::HostType::DOMAIN && getIsClient() &&
|
||||
!nodeList->getThisNodeCanRez() && !nodeList->getThisNodeCanRezTmp() &&
|
||||
!nodeList->getThisNodeCanRezCertified() && !nodeList->getThisNodeCanRezTmpCertified() && !_serverlessDomain && !isClone) {
|
||||
!nodeList->getThisNodeCanRezCertified() && !nodeList->getThisNodeCanRezTmpCertified() &&
|
||||
!_serverlessDomain && !isClone && !isImport) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -2932,7 +2933,7 @@ void convertGrabUserDataToProperties(EntityItemProperties& properties) {
|
|||
}
|
||||
|
||||
|
||||
bool EntityTree::readFromMap(QVariantMap& map) {
|
||||
bool EntityTree::readFromMap(QVariantMap& map, const bool isImport) {
|
||||
// These are needed to deal with older content (before adding inheritance modes)
|
||||
int contentVersion = map["Version"].toInt();
|
||||
|
||||
|
@ -3102,7 +3103,7 @@ bool EntityTree::readFromMap(QVariantMap& map) {
|
|||
}
|
||||
}
|
||||
|
||||
EntityItemPointer entity = addEntity(entityItemID, properties);
|
||||
EntityItemPointer entity = addEntity(entityItemID, properties, isImport);
|
||||
if (!entity) {
|
||||
qCDebug(entities) << "adding Entity failed:" << entityItemID << properties.getType();
|
||||
success = false;
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
// The newer API...
|
||||
void postAddEntity(EntityItemPointer entityItem);
|
||||
|
||||
EntityItemPointer addEntity(const EntityItemID& entityID, const EntityItemProperties& properties, bool isClone = false);
|
||||
EntityItemPointer addEntity(const EntityItemID& entityID, const EntityItemProperties& properties, bool isClone = false, bool isImport = false);
|
||||
|
||||
// use this method if you only know the entityID
|
||||
bool updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties, const SharedNodePointer& senderNode = SharedNodePointer(nullptr));
|
||||
|
@ -196,7 +196,7 @@ public:
|
|||
|
||||
virtual bool writeToMap(QVariantMap& entityDescription, OctreeElementPointer element, bool skipDefaultValues,
|
||||
bool skipThoseWithBadParents) override;
|
||||
virtual bool readFromMap(QVariantMap& entityDescription) override;
|
||||
virtual bool readFromMap(QVariantMap& entityDescription, const bool isImport = false) override;
|
||||
virtual bool writeToJSON(QString& jsonString, const OctreeElementPointer& element) override;
|
||||
|
||||
|
||||
|
|
|
@ -734,7 +734,8 @@ QString getMarketplaceID(const QString& urlString) {
|
|||
bool Octree::readFromURL(
|
||||
const QString& urlString,
|
||||
const bool isObservable,
|
||||
const qint64 callerId
|
||||
const qint64 callerId,
|
||||
const bool isImport
|
||||
) {
|
||||
QString trimmedUrl = urlString.trimmed();
|
||||
QString marketplaceID = getMarketplaceID(trimmedUrl);
|
||||
|
@ -766,7 +767,7 @@ bool Octree::readFromURL(
|
|||
}
|
||||
|
||||
QDataStream inputStream(data);
|
||||
return readFromStream(data.size(), inputStream, marketplaceID);
|
||||
return readFromStream(data.size(), inputStream, marketplaceID, isImport);
|
||||
}
|
||||
|
||||
bool Octree::readFromByteArray(
|
||||
|
@ -791,7 +792,8 @@ bool Octree::readFromByteArray(
|
|||
bool Octree::readFromStream(
|
||||
uint64_t streamLength,
|
||||
QDataStream& inputStream,
|
||||
const QString& marketplaceID
|
||||
const QString& marketplaceID,
|
||||
const bool isImport
|
||||
) {
|
||||
// decide if this is binary SVO or JSON-formatted SVO
|
||||
QIODevice *device = inputStream.device();
|
||||
|
@ -804,7 +806,7 @@ bool Octree::readFromStream(
|
|||
return false;
|
||||
} else {
|
||||
qCDebug(octree) << "Reading from JSON SVO Stream length:" << streamLength;
|
||||
return readJSONFromStream(streamLength, inputStream, marketplaceID);
|
||||
return readJSONFromStream(streamLength, inputStream, marketplaceID, isImport);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -834,7 +836,8 @@ const int READ_JSON_BUFFER_SIZE = 2048;
|
|||
bool Octree::readJSONFromStream(
|
||||
uint64_t streamLength,
|
||||
QDataStream& inputStream,
|
||||
const QString& marketplaceID /*=""*/
|
||||
const QString& marketplaceID, /*=""*/
|
||||
const bool isImport
|
||||
) {
|
||||
// if the data is gzipped we may not have a useful bytesAvailable() result, so just keep reading until
|
||||
// we get an eof. Leave streamLength parameter for consistency.
|
||||
|
@ -866,7 +869,7 @@ bool Octree::readJSONFromStream(
|
|||
addMarketplaceIDToDocumentEntities(asMap, marketplaceID);
|
||||
}
|
||||
|
||||
bool success = readFromMap(asMap);
|
||||
bool success = readFromMap(asMap, isImport);
|
||||
delete[] rawData;
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -216,13 +216,13 @@ public:
|
|||
|
||||
// Octree importers
|
||||
bool readFromFile(const char* filename);
|
||||
bool readFromURL(const QString& url, const bool isObservable = true, const qint64 callerId = -1); // will support file urls as well...
|
||||
bool readFromURL(const QString& url, const bool isObservable = true, const qint64 callerId = -1, const bool isImport = false); // will support file urls as well...
|
||||
bool readFromByteArray(const QString& url, const QByteArray& byteArray);
|
||||
bool readFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="");
|
||||
bool readFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="", const bool isImport = false);
|
||||
bool readSVOFromStream(uint64_t streamLength, QDataStream& inputStream);
|
||||
bool readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="");
|
||||
bool readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="", const bool isImport = false);
|
||||
bool readJSONFromGzippedFile(QString qFileName);
|
||||
virtual bool readFromMap(QVariantMap& entityDescription) = 0;
|
||||
virtual bool readFromMap(QVariantMap& entityDescription, const bool isImport = false) = 0;
|
||||
|
||||
uint64_t getOctreeElementsCount();
|
||||
|
||||
|
|
Loading…
Reference in a new issue