mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-04 13:10:28 +02:00
Merge pull request #504 from kasenvr/fix/import-entities-any-domain
Import entities now works on domains that you do not have rights on.
This commit is contained in:
commit
56b6d370fb
5 changed files with 21 additions and 18 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
|
// FIXME: readFromURL() can take over the main event loop which may cause problems, especially if downloading the JSON
|
||||||
// from the Web.
|
// from the Web.
|
||||||
success = _entityClipboard->readFromURL(urlOrFilename, isObservable, callerId);
|
success = _entityClipboard->readFromURL(urlOrFilename, isObservable, callerId, true);
|
||||||
if (success) {
|
if (success) {
|
||||||
_entityClipboard->reaverageOctreeElements();
|
_entityClipboard->reaverageOctreeElements();
|
||||||
}
|
}
|
||||||
|
|
|
@ -537,7 +537,7 @@ bool EntityTree::updateEntity(EntityItemPointer entity, const EntityItemProperti
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const EntityItemProperties& properties, bool isClone) {
|
EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const EntityItemProperties& properties, bool isClone, const bool isImport) {
|
||||||
EntityItemProperties props = properties;
|
EntityItemProperties props = properties;
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
@ -548,7 +548,8 @@ EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const Enti
|
||||||
|
|
||||||
if (properties.getEntityHostType() == entity::HostType::DOMAIN && getIsClient() &&
|
if (properties.getEntityHostType() == entity::HostType::DOMAIN && getIsClient() &&
|
||||||
!nodeList->getThisNodeCanRez() && !nodeList->getThisNodeCanRezTmp() &&
|
!nodeList->getThisNodeCanRez() && !nodeList->getThisNodeCanRezTmp() &&
|
||||||
!nodeList->getThisNodeCanRezCertified() && !nodeList->getThisNodeCanRezTmpCertified() && !_serverlessDomain && !isClone) {
|
!nodeList->getThisNodeCanRezCertified() && !nodeList->getThisNodeCanRezTmpCertified() &&
|
||||||
|
!_serverlessDomain && !isClone && !isImport) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2954,7 +2955,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)
|
// These are needed to deal with older content (before adding inheritance modes)
|
||||||
int contentVersion = map["Version"].toInt();
|
int contentVersion = map["Version"].toInt();
|
||||||
|
|
||||||
|
@ -3124,7 +3125,7 @@ bool EntityTree::readFromMap(QVariantMap& map) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityItemPointer entity = addEntity(entityItemID, properties);
|
EntityItemPointer entity = addEntity(entityItemID, properties, isImport);
|
||||||
if (!entity) {
|
if (!entity) {
|
||||||
qCDebug(entities) << "adding Entity failed:" << entityItemID << properties.getType();
|
qCDebug(entities) << "adding Entity failed:" << entityItemID << properties.getType();
|
||||||
success = false;
|
success = false;
|
||||||
|
|
|
@ -118,7 +118,7 @@ public:
|
||||||
// The newer API...
|
// The newer API...
|
||||||
void postAddEntity(EntityItemPointer entityItem);
|
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, const bool isImport = false);
|
||||||
|
|
||||||
// use this method if you only know the entityID
|
// use this method if you only know the entityID
|
||||||
bool updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties, const SharedNodePointer& senderNode = SharedNodePointer(nullptr));
|
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,
|
virtual bool writeToMap(QVariantMap& entityDescription, OctreeElementPointer element, bool skipDefaultValues,
|
||||||
bool skipThoseWithBadParents) override;
|
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;
|
virtual bool writeToJSON(QString& jsonString, const OctreeElementPointer& element) override;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -734,7 +734,8 @@ QString getMarketplaceID(const QString& urlString) {
|
||||||
bool Octree::readFromURL(
|
bool Octree::readFromURL(
|
||||||
const QString& urlString,
|
const QString& urlString,
|
||||||
const bool isObservable,
|
const bool isObservable,
|
||||||
const qint64 callerId
|
const qint64 callerId,
|
||||||
|
const bool isImport
|
||||||
) {
|
) {
|
||||||
QString trimmedUrl = urlString.trimmed();
|
QString trimmedUrl = urlString.trimmed();
|
||||||
QString marketplaceID = getMarketplaceID(trimmedUrl);
|
QString marketplaceID = getMarketplaceID(trimmedUrl);
|
||||||
|
@ -766,7 +767,7 @@ bool Octree::readFromURL(
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream inputStream(data);
|
QDataStream inputStream(data);
|
||||||
return readFromStream(data.size(), inputStream, marketplaceID);
|
return readFromStream(data.size(), inputStream, marketplaceID, isImport);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Octree::readFromByteArray(
|
bool Octree::readFromByteArray(
|
||||||
|
@ -791,7 +792,8 @@ bool Octree::readFromByteArray(
|
||||||
bool Octree::readFromStream(
|
bool Octree::readFromStream(
|
||||||
uint64_t streamLength,
|
uint64_t streamLength,
|
||||||
QDataStream& inputStream,
|
QDataStream& inputStream,
|
||||||
const QString& marketplaceID
|
const QString& marketplaceID,
|
||||||
|
const bool isImport
|
||||||
) {
|
) {
|
||||||
// decide if this is binary SVO or JSON-formatted SVO
|
// decide if this is binary SVO or JSON-formatted SVO
|
||||||
QIODevice *device = inputStream.device();
|
QIODevice *device = inputStream.device();
|
||||||
|
@ -804,7 +806,7 @@ bool Octree::readFromStream(
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
qCDebug(octree) << "Reading from JSON SVO Stream length:" << streamLength;
|
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(
|
bool Octree::readJSONFromStream(
|
||||||
uint64_t streamLength,
|
uint64_t streamLength,
|
||||||
QDataStream& inputStream,
|
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
|
// 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.
|
// we get an eof. Leave streamLength parameter for consistency.
|
||||||
|
@ -866,7 +869,7 @@ bool Octree::readJSONFromStream(
|
||||||
addMarketplaceIDToDocumentEntities(asMap, marketplaceID);
|
addMarketplaceIDToDocumentEntities(asMap, marketplaceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success = readFromMap(asMap);
|
bool success = readFromMap(asMap, isImport);
|
||||||
delete[] rawData;
|
delete[] rawData;
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,13 +216,12 @@ public:
|
||||||
|
|
||||||
// Octree importers
|
// Octree importers
|
||||||
bool readFromFile(const char* filename);
|
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 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="", const bool isImport = false);
|
||||||
bool readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="");
|
|
||||||
bool readJSONFromGzippedFile(QString qFileName);
|
bool readJSONFromGzippedFile(QString qFileName);
|
||||||
virtual bool readFromMap(QVariantMap& entityDescription) = 0;
|
virtual bool readFromMap(QVariantMap& entityDescription, const bool isImport = false) = 0;
|
||||||
|
|
||||||
uint64_t getOctreeElementsCount();
|
uint64_t getOctreeElementsCount();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue