This fixes exporter

This commit is contained in:
Siana Gearz
2011-07-12 04:23:48 +02:00
parent 379f4c63ec
commit cf81a4457e
4 changed files with 163 additions and 91 deletions

View File

@@ -2863,15 +2863,10 @@ class LLObjectExport : public view_listener_t
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{ {
LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject();
if (!object) return true; if (object)
LLVOAvatar* avatar = find_avatar_from_object(object);
if (!avatar)
{ {
LLObjectBackup::getInstance()->exportObject(); LLObjectBackup::getInstance()->exportObject();
} }
return true; return true;
} }
}; };

View File

@@ -34,12 +34,10 @@
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include "hippogridmanager.h"
// linden library includes // linden library includes
#include "indra_constants.h" #include "indra_constants.h"
#include "llapr.h"
#include "llalertdialog.h" #include "llalertdialog.h"
#include "llapr.h"
#include "llcallbacklist.h" #include "llcallbacklist.h"
#include "lldir.h" #include "lldir.h"
#include "lleconomy.h" #include "lleconomy.h"
@@ -79,9 +77,37 @@
#include "llviewerstats.h" #include "llviewerstats.h"
#include "llviewerwindow.h" #include "llviewerwindow.h"
#include "hippogridmanager.h"
#include "llviewerobjectbackup.h" #include "llviewerobjectbackup.h"
LLObjectBackup* LLObjectBackup::sInstance = 0; LLObjectBackup* LLObjectBackup::sInstance = NULL;
// Note: these default textures are initialized with hard coded values to
// prevent cheating. When not in SL, the user-configurable values are used
// instead (see setDefaultTextures() below).
static LLUUID LL_TEXTURE_PLYWOOD = LLUUID("89556747-24cb-43ed-920b-47caed15465f");
static LLUUID LL_TEXTURE_BLANK = LLUUID("5748decc-f629-461c-9a36-a35a221fe21f");
static LLUUID LL_TEXTURE_INVISIBLE = LLUUID("38b86f85-2575-52a9-a531-23108d8da837");
static LLUUID LL_TEXTURE_TRANSPARENT = LLUUID("8dcd4a48-2d37-4909-9f78-f7a9eb4ef903");
static LLUUID LL_TEXTURE_MEDIA = LLUUID("8b5fec65-8d8d-9dc5-cda8-8fdf2716e361");
void setDefaultTextures()
{
if (!gHippoGridManager->getConnectedGrid()->isSecondLife())
{
// When not in SL (no texture perm check needed), we can get these
// defaults from the user settings...
LL_TEXTURE_PLYWOOD = LLUUID(gSavedSettings.getString("DefaultObjectTexture"));
LL_TEXTURE_BLANK = LLUUID(gSavedSettings.getString("UIImgWhiteUUID"));
if (gSavedSettings.controlExists("UIImgInvisibleUUID"))
{
// This control only exists in the Cool VL Viewer (added by the
// AllowInvisibleTextureInPicker patch)
LL_TEXTURE_INVISIBLE = LLUUID(gSavedSettings.getString("UIImgInvisibleUUID"));
}
}
}
class importResponder: public LLNewAgentInventoryResponder class importResponder: public LLNewAgentInventoryResponder
{ {
@@ -95,7 +121,7 @@ public:
//virtual //virtual
virtual void uploadComplete(const LLSD& content) virtual void uploadComplete(const LLSD& content)
{ {
lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl; LL_DEBUGS("ObjectBackup") << "LLNewAgentInventoryResponder::result from capabilities" << LL_ENDL;
LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString()); LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString());
LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString()); LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString());
@@ -120,8 +146,8 @@ public:
} }
// Actually add the upload to viewer inventory // Actually add the upload to viewer inventory
llinfos << "Adding " << content["new_inventory_item"].asUUID() << " " LL_INFOS("ObjectBackup") << "Adding " << content["new_inventory_item"].asUUID() << " "
<< content["new_asset"].asUUID() << " to inventory." << llendl; << content["new_asset"].asUUID() << " to inventory." << LL_ENDL;
if (mPostData["folder_id"].asUUID().notNull()) if (mPostData["folder_id"].asUUID().notNull())
{ {
LLPermissions perm; LLPermissions perm;
@@ -154,7 +180,7 @@ public:
} }
else else
{ {
llwarns << "Can't find a folder to put it into" << llendl; LL_WARNS("ObjectBackup") << "Can't find a folder to put it into" << LL_ENDL;
} }
// remove the "Uploading..." message // remove the "Uploading..." message
@@ -177,7 +203,7 @@ public:
{ {
if (imageformat == IMG_CODEC_TGA && mFormattedImage->getCodec() == IMG_CODEC_J2C) if (imageformat == IMG_CODEC_TGA && mFormattedImage->getCodec() == IMG_CODEC_J2C)
{ {
llwarns << "FAILED: texture " << mID << " is formatted as TGA. Not saving." << llendl; LL_WARNS("ObjectBackup") << "FAILED: texture " << mID << " is formatted as TGA. Not saving." << LL_ENDL;
LLObjectBackup::getInstance()->mNonExportedTextures |= LLObjectBackup::TEXTURE_BAD_ENCODING; LLObjectBackup::getInstance()->mNonExportedTextures |= LLObjectBackup::TEXTURE_BAD_ENCODING;
mFormattedImage = NULL; mFormattedImage = NULL;
mImageSize = 0; mImageSize = 0;
@@ -202,14 +228,14 @@ public:
{ {
if (success && mFormattedImage.notNull() && mImageSize > 0) if (success && mFormattedImage.notNull() && mImageSize > 0)
{ {
llinfos << "SUCCESS getting texture " << mID << llendl; LL_INFOS("ObjectBackup") << "SUCCESS getting texture " << mID << LL_ENDL;
std::string name; std::string name;
mID.toString(name); mID.toString(name);
name = LLObjectBackup::getInstance()->getfolder() + "//" + name; name = LLObjectBackup::getInstance()->getfolder() + "//" + name;
llinfos << "Saving to " << name << llendl; LL_INFOS("ObjectBackup") << "Saving to " << name << LL_ENDL;
if (!mFormattedImage->save(name)) if (!mFormattedImage->save(name))
{ {
llwarns << "FAILED to save texture " << mID << llendl; LL_WARNS("ObjectBackup") << "FAILED to save texture " << mID << LL_ENDL;
LLObjectBackup::getInstance()->mNonExportedTextures |= LLObjectBackup::TEXTURE_SAVED_FAILED; LLObjectBackup::getInstance()->mNonExportedTextures |= LLObjectBackup::TEXTURE_SAVED_FAILED;
} }
} }
@@ -217,12 +243,12 @@ public:
{ {
if (!success) if (!success)
{ {
llwarns << "FAILED to get texture " << mID << llendl; LL_WARNS("ObjectBackup") << "FAILED to get texture " << mID << LL_ENDL;
LLObjectBackup::getInstance()->mNonExportedTextures |= LLObjectBackup::TEXTURE_MISSING; LLObjectBackup::getInstance()->mNonExportedTextures |= LLObjectBackup::TEXTURE_MISSING;
} }
if (mFormattedImage.isNull()) if (mFormattedImage.isNull())
{ {
llwarns << "FAILED: NULL texture " << mID << llendl; LL_WARNS("ObjectBackup") << "FAILED: NULL texture " << mID << LL_ENDL;
LLObjectBackup::getInstance()->mNonExportedTextures |= LLObjectBackup::TEXTURE_IS_NULL; LLObjectBackup::getInstance()->mNonExportedTextures |= LLObjectBackup::TEXTURE_IS_NULL;
} }
} }
@@ -340,6 +366,9 @@ void LLObjectBackup::exportObject()
mLLSD.clear(); mLLSD.clear();
mThisGroup.clear(); mThisGroup.clear();
setDefaultTextures();
LLSelectMgr::getInstance()->getSelection()->ref();
// Open the file save dialog // Open the file save dialog
AIFilePicker* filepicker = AIFilePicker::create(); AIFilePicker* filepicker = AIFilePicker::create();
filepicker->open("", FFSAVE_XML); filepicker->open("", FFSAVE_XML);
@@ -351,6 +380,7 @@ void LLObjectBackup::exportObject_continued(AIFilePicker* filepicker)
if (!filepicker->hasFilename()) if (!filepicker->hasFilename())
{ {
// User canceled save. // User canceled save.
LLSelectMgr::getInstance()->getSelection()->unref();
return; return;
} }
@@ -365,7 +395,7 @@ void LLObjectBackup::exportObject_continued(AIFilePicker* filepicker)
bool LLObjectBackup::validatePerms(const LLPermissions *item_permissions) bool LLObjectBackup::validatePerms(const LLPermissions *item_permissions)
{ {
if (gHippoGridManager->getConnectedGrid()->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) if (gHippoGridManager->getConnectedGrid()->isSecondLife())
{ {
// In Second Life, you must be the creator to be permitted to export the asset. // In Second Life, you must be the creator to be permitted to export the asset.
return (gAgent.getID() == item_permissions->getOwner() && return (gAgent.getID() == item_permissions->getOwner() &&
@@ -390,12 +420,21 @@ bool LLObjectBackup::validatePerms(const LLPermissions *item_permissions)
// the textures in the Library), whoever is the actual creator... Go figure ! // the textures in the Library), whoever is the actual creator... Go figure !
LLUUID LLObjectBackup::validateTextureID(LLUUID asset_id) LLUUID LLObjectBackup::validateTextureID(LLUUID asset_id)
{ {
if (gHippoGridManager->getConnectedGrid()->getPlatform() != HippoGridInfo::PLATFORM_SECONDLIFE) if (!gHippoGridManager->getConnectedGrid()->isSecondLife())
{ {
// If we are not in Second Life, don't bother. // If we are not in Second Life, don't bother.
return asset_id; return asset_id;
} }
LLUUID texture = LLUUID(gSavedSettings.getString("DefaultObjectTexture")); LLUUID texture = LL_TEXTURE_PLYWOOD;
if (asset_id == texture ||
asset_id == LL_TEXTURE_BLANK ||
asset_id == LL_TEXTURE_INVISIBLE ||
asset_id == LL_TEXTURE_TRANSPARENT ||
asset_id == LL_TEXTURE_MEDIA)
{
// Allow to export a few default SL textures.
return asset_id;
}
LLViewerInventoryCategory::cat_array_t cats; LLViewerInventoryCategory::cat_array_t cats;
LLViewerInventoryItem::item_array_t items; LLViewerInventoryItem::item_array_t items;
LLAssetIDMatches asset_id_matches(asset_id); LLAssetIDMatches asset_id_matches(asset_id);
@@ -434,7 +473,6 @@ void LLObjectBackup::exportWorker(void *userdata)
case EXPORT_INIT: case EXPORT_INIT:
{ {
LLObjectBackup::getInstance()->show(true); LLObjectBackup::getInstance()->show(true);
LLSelectMgr::getInstance()->getSelection()->ref();
struct ff : public LLSelectedNodeFunctor struct ff : public LLSelectedNodeFunctor
{ {
virtual bool apply(LLSelectNode* node) virtual bool apply(LLSelectNode* node)
@@ -449,7 +487,7 @@ void LLObjectBackup::exportWorker(void *userdata)
} }
else else
{ {
llwarns << "Incorrect permission to export" << llendl; LL_WARNS("ObjectBackup") << "Incorrect permission to export" << LL_ENDL;
LLObjectBackup::getInstance()->mExportState = EXPORT_FAILED; LLObjectBackup::getInstance()->mExportState = EXPORT_FAILED;
LLSelectMgr::getInstance()->getSelection()->unref(); LLSelectMgr::getInstance()->getSelection()->unref();
} }
@@ -462,13 +500,22 @@ void LLObjectBackup::exportWorker(void *userdata)
{ {
virtual bool apply(LLViewerObject* object) virtual bool apply(LLViewerObject* object)
{ {
bool is_attachment = object->isAttachment();
object->boostTexturePriority(TRUE); object->boostTexturePriority(TRUE);
LLViewerObject::child_list_t children = object->getChildren(); LLViewerObject::child_list_t children = object->getChildren();
children.push_front(object); //push root onto list children.push_front(object); //push root onto list
LLSD prim_llsd = LLObjectBackup::getInstance()->primsToLLSD(children); LLSD prim_llsd = LLObjectBackup::getInstance()->primsToLLSD(children, is_attachment);
LLSD stuff; LLSD stuff;
stuff["root_position"] = object->getPosition().getValue(); if (is_attachment)
stuff["root_rotation"] = ll_sd_from_quaternion(object->getRotation()); {
stuff["root_position"] = object->getPositionEdit().getValue();
stuff["root_rotation"] = ll_sd_from_quaternion(object->getRotationEdit());
}
else
{
stuff["root_position"] = object->getPosition().getValue();
stuff["root_rotation"] = ll_sd_from_quaternion(object->getRotation());
}
stuff["group_body"] = prim_llsd; stuff["group_body"] = prim_llsd;
LLObjectBackup::getInstance()->mLLSD["data"].append(stuff); LLObjectBackup::getInstance()->mLLSD["data"].append(stuff);
return true; return true;
@@ -512,12 +559,12 @@ void LLObjectBackup::exportWorker(void *userdata)
gIdleCallbacks.deleteFunction(exportWorker); gIdleCallbacks.deleteFunction(exportWorker);
if (LLObjectBackup::getInstance()->mNonExportedTextures == LLObjectBackup::TEXTURE_OK) if (LLObjectBackup::getInstance()->mNonExportedTextures == LLObjectBackup::TEXTURE_OK)
{ {
llinfos << "Export successful and complete." << llendl; LL_INFOS("ObjectBackup") << "Export successful and complete." << LL_ENDL;
LLNotifications::instance().add("ExportSuccessful"); LLNotifications::instance().add("ExportSuccessful");
} }
else else
{ {
llinfos << "Export successful but incomplete: some texture(s) not saved." << llendl; LL_INFOS("ObjectBackup") << "Export successful but incomplete: some texture(s) not saved." << LL_ENDL;
std::string reason; std::string reason;
if (LLObjectBackup::getInstance()->mNonExportedTextures & LLObjectBackup::TEXTURE_BAD_PERM) if (LLObjectBackup::getInstance()->mNonExportedTextures & LLObjectBackup::TEXTURE_BAD_PERM)
{ {
@@ -525,7 +572,7 @@ void LLObjectBackup::exportWorker(void *userdata)
} }
if (LLObjectBackup::getInstance()->mNonExportedTextures & LLObjectBackup::TEXTURE_MISSING) if (LLObjectBackup::getInstance()->mNonExportedTextures & LLObjectBackup::TEXTURE_MISSING)
{ {
reason += "\nMissing texture."; reason += "\nMissing texture (retrying after full rezzing might work).";
} }
if (LLObjectBackup::getInstance()->mNonExportedTextures & LLObjectBackup::TEXTURE_BAD_ENCODING) if (LLObjectBackup::getInstance()->mNonExportedTextures & LLObjectBackup::TEXTURE_BAD_ENCODING)
{ {
@@ -548,14 +595,14 @@ void LLObjectBackup::exportWorker(void *userdata)
case EXPORT_FAILED: case EXPORT_FAILED:
gIdleCallbacks.deleteFunction(exportWorker); gIdleCallbacks.deleteFunction(exportWorker);
llwarns << "Export process aborted." << llendl; LL_WARNS("ObjectBackup") << "Export process aborted." << LL_ENDL;
LLNotifications::instance().add("ExportFailed"); LLNotifications::instance().add("ExportFailed");
LLObjectBackup::getInstance()->close(); LLObjectBackup::getInstance()->close();
break; break;
} }
} }
LLSD LLObjectBackup::primsToLLSD(LLViewerObject::child_list_t child_list) LLSD LLObjectBackup::primsToLLSD(LLViewerObject::child_list_t child_list, bool is_attachment)
{ {
LLViewerObject* object; LLViewerObject* object;
LLSD llsd; LLSD llsd;
@@ -566,7 +613,7 @@ LLSD LLObjectBackup::primsToLLSD(LLViewerObject::child_list_t child_list)
object = (*i); object = (*i);
LLUUID id = object->getID(); LLUUID id = object->getID();
llinfos << "Exporting prim " << object->getID().asString() << llendl; LL_INFOS("ObjectBackup") << "Exporting prim " << object->getID().asString() << LL_ENDL;
// Create an LLSD object that represents this prim. It will be injected in to the overall LLSD // Create an LLSD object that represents this prim. It will be injected in to the overall LLSD
// tree structure // tree structure
@@ -588,9 +635,17 @@ LLSD LLObjectBackup::primsToLLSD(LLViewerObject::child_list_t child_list)
} }
// Transforms // Transforms
prim_llsd["position"] = object->getPosition().getValue(); if (is_attachment)
{
prim_llsd["position"] = object->getPositionEdit().getValue();
prim_llsd["rotation"] = ll_sd_from_quaternion(object->getRotationEdit());
}
else
{
prim_llsd["position"] = object->getPosition().getValue();
prim_llsd["rotation"] = ll_sd_from_quaternion(object->getRotation());
}
prim_llsd["scale"] = object->getScale().getValue(); prim_llsd["scale"] = object->getScale().getValue();
prim_llsd["rotation"] = ll_sd_from_quaternion(object->getRotation());
// Flags // Flags
prim_llsd["shadows"] = object->flagCastShadows(); prim_llsd["shadows"] = object->flagCastShadows();
@@ -632,13 +687,13 @@ LLSD LLObjectBackup::primsToLLSD(LLViewerObject::child_list_t child_list)
} }
if (alreadyseen == false) if (alreadyseen == false)
{ {
llinfos << "Found a sculpt texture, adding to list " << sculpt_texture << llendl; LL_INFOS("ObjectBackup") << "Found a sculpt texture, adding to list " << sculpt_texture << LL_ENDL;
mTexturesList.push_back(sculpt_texture); mTexturesList.push_back(sculpt_texture);
} }
} }
else else
{ {
llwarns << "Incorrect permission to export a sculpt texture." << llendl; LL_WARNS("ObjectBackup") << "Incorrect permission to export a sculpt texture." << LL_ENDL;
LLObjectBackup::getInstance()->mExportState = EXPORT_FAILED; LLObjectBackup::getInstance()->mExportState = EXPORT_FAILED;
} }
} }
@@ -655,14 +710,22 @@ LLSD LLObjectBackup::primsToLLSD(LLViewerObject::child_list_t child_list)
this_te_llsd = object->getTE(i)->asLLSD(); this_te_llsd = object->getTE(i)->asLLSD();
this_te_llsd["imageid"] = t_id; this_te_llsd["imageid"] = t_id;
te_llsd.append(this_te_llsd); te_llsd.append(this_te_llsd);
std::list<LLUUID>::iterator iter; // Do not export Linden textures even though they don't taint creation.
for (iter = mTexturesList.begin(); iter != mTexturesList.end(); iter++) if (t_id != LL_TEXTURE_PLYWOOD &&
{ t_id != LL_TEXTURE_BLANK &&
if ((*iter) == t_id) t_id != LL_TEXTURE_TRANSPARENT &&
alreadyseen = true; t_id != LL_TEXTURE_INVISIBLE &&
t_id != LL_TEXTURE_MEDIA)
{
std::list<LLUUID>::iterator iter;
for (iter = mTexturesList.begin(); iter != mTexturesList.end(); iter++)
{
if ((*iter) == t_id)
alreadyseen = true;
}
if (alreadyseen == false)
mTexturesList.push_back(t_id);
} }
if (alreadyseen == false)
mTexturesList.push_back(t_id);
} }
prim_llsd["textures"] = te_llsd; prim_llsd["textures"] = te_llsd;
@@ -679,7 +742,7 @@ void LLObjectBackup::exportNextTexture()
{ {
if (mTexturesList.empty()) if (mTexturesList.empty())
{ {
llinfos << "Finished exporting textures." << llendl; LL_INFOS("ObjectBackup") << "Finished exporting textures." << LL_ENDL;
return; return;
} }
@@ -687,7 +750,7 @@ void LLObjectBackup::exportNextTexture()
std::list<LLUUID>::iterator iter; std::list<LLUUID>::iterator iter;
iter = mTexturesList.begin(); iter = mTexturesList.begin();
while (1) while (true)
{ {
if (iter == mTexturesList.end()) if (iter == mTexturesList.end())
{ {
@@ -696,6 +759,13 @@ void LLObjectBackup::exportNextTexture()
} }
id = (*iter); id = (*iter);
if (id.isNull())
{
// NULL texture id: just remove and ignore.
mTexturesList.remove(id);
iter = mTexturesList.begin();
continue;
}
LLViewerTexture* imagep = LLViewerTextureManager::findTexture(id); LLViewerTexture* imagep = LLViewerTextureManager::findTexture(id);
if (imagep != NULL) if (imagep != NULL)
@@ -716,15 +786,17 @@ void LLObjectBackup::exportNextTexture()
} }
else else
{ {
llwarns << "We *DON'T* have the texture " << llendl; LL_WARNS("ObjectBackup") << "We *DON'T* have the texture " << id.asString() << LL_ENDL;
mNonExportedTextures |= TEXTURE_MISSING; mNonExportedTextures |= TEXTURE_MISSING;
mTexturesList.remove(id);
return;
} }
iter++; iter++;
} }
mTexturesList.remove(id); mTexturesList.remove(id);
llinfos << "Requesting texture " << id << llendl; LL_INFOS("ObjectBackup") << "Requesting texture " << id << LL_ENDL;
LLImageJ2C* mFormattedImage = new LLImageJ2C; LLImageJ2C* mFormattedImage = new LLImageJ2C;
CacheReadResponder* responder = new CacheReadResponder(id, mFormattedImage); CacheReadResponder* responder = new CacheReadResponder(id, mFormattedImage);
LLAppViewer::getTextureCache()->readFromCache(id, LLWorkerThread::PRIORITY_HIGH, 0, 999999, responder); LLAppViewer::getTextureCache()->readFromCache(id, LLWorkerThread::PRIORITY_HIGH, 0, 999999, responder);
@@ -736,10 +808,12 @@ void LLObjectBackup::importObject(bool upload)
mAssetMap.clear(); mAssetMap.clear();
mCurrentAsset = LLUUID::null; mCurrentAsset = LLUUID::null;
setDefaultTextures();
mRetexture = upload; mRetexture = upload;
// Open the file open dialog // Open the file open dialog
AIFilePicker* filepicker = AIFilePicker::create(); AIFilePicker* filepicker = new AIFilePicker;
filepicker->open(FFLOAD_XML, "", "import"); filepicker->open(FFLOAD_XML, "", "import");
filepicker->run(boost::bind(&LLObjectBackup::importObject_continued, this, filepicker)); filepicker->run(boost::bind(&LLObjectBackup::importObject_continued, this, filepicker));
@@ -749,13 +823,17 @@ void LLObjectBackup::importObject(bool upload)
void LLObjectBackup::importObject_continued(AIFilePicker* filepicker) void LLObjectBackup::importObject_continued(AIFilePicker* filepicker)
{ {
if (!filepicker->hasFilename()) if (!filepicker->hasFilename())
{
// User canceled save.
return; return;
}
std::string file_name = filepicker->getFilename(); std::string file_name = filepicker->getFilename();
mFolder = gDirUtilp->getDirName(file_name); mFolder = gDirUtilp->getDirName(file_name);
llifstream import_file(file_name); llifstream import_file(file_name);
LLSDSerialize::fromXML(mLLSD, import_file); LLSDSerialize::fromXML(mLLSD, import_file);
import_file.close(); import_file.close();
show(false);
mAgentPos = gAgent.getPositionAgent(); mAgentPos = gAgent.getPositionAgent();
mAgentRot = LLQuaternion(gAgent.getAtAxis(), gAgent.getLeftAxis(), gAgent.getUpAxis()); mAgentRot = LLQuaternion(gAgent.getAtAxis(), gAgent.getLeftAxis(), gAgent.getUpAxis());
@@ -770,17 +848,6 @@ void LLObjectBackup::importObject_continued(AIFilePicker* filepicker)
mObjects = mLLSD["data"].size(); mObjects = mLLSD["data"].size();
mPrims = 0; mPrims = 0;
mRezCount = 0; mRezCount = 0;
if (mObjects <= 0) {
LLSD args;
args["MESSAGE"] = std::string("Object import failed.\nThe XML file has an incompatible format or does not contain any objects.");
LLNotifications::instance().add("GenericAlert", args);
llwarns << "Trying to import illegal XML object file." << llendl;
return;
}
show(false);
updateImportNumbers(); updateImportNumbers();
for (prim_arr_it = mLLSD["data"].beginArray(); prim_arr_it != mLLSD["data"].endArray(); prim_arr_it++) for (prim_arr_it = mLLSD["data"].beginArray(); prim_arr_it != mLLSD["data"].endArray(); prim_arr_it++)
@@ -806,7 +873,7 @@ void LLObjectBackup::importObject_continued(AIFilePicker* filepicker)
} }
if (alreadyseen == false) if (alreadyseen == false)
{ {
llinfos << "Found a new SCULPT texture to upload " << orig << llendl; LL_INFOS("ObjectBackup") << "Found a new SCULPT texture to upload " << orig << LL_ENDL;
mTexturesList.push_back(orig); mTexturesList.push_back(orig);
} }
} }
@@ -819,18 +886,21 @@ void LLObjectBackup::importObject_continued(AIFilePicker* filepicker)
LLTextureEntry te; LLTextureEntry te;
te.fromLLSD(the_te); te.fromLLSD(the_te);
te.getID(); LLUUID id = te.getID();
bool alreadyseen = false; if (id != LL_TEXTURE_PLYWOOD && id != LL_TEXTURE_BLANK && id != LL_TEXTURE_INVISIBLE) // Do not upload the default textures
{
bool alreadyseen = false;
for (iter = mTexturesList.begin(); iter != mTexturesList.end(); iter++) for (iter = mTexturesList.begin(); iter != mTexturesList.end(); iter++)
{ {
if ((*iter) == te.getID()) if ((*iter) == te.getID())
alreadyseen = true; alreadyseen = true;
} }
if (alreadyseen == false) if (alreadyseen == false)
{ {
llinfos << "Found a new texture to upload "<< te.getID() << llendl; LL_INFOS("ObjectBackup") << "Found a new texture to upload "<< te.getID() << LL_ENDL;
mTexturesList.push_back(te.getID()); mTexturesList.push_back(te.getID());
}
} }
} }
} }
@@ -970,7 +1040,7 @@ void LLObjectBackup::xmlToPrim(LLSD prim_llsd, LLViewerObject* object)
} }
// Textures // Textures
llinfos << "Processing textures for prim" << llendl; LL_INFOS("ObjectBackup") << "Processing textures for prim" << LL_ENDL;
LLSD te_llsd = prim_llsd["textures"]; LLSD te_llsd = prim_llsd["textures"];
LLSD::array_iterator text_it; LLSD::array_iterator text_it;
U8 i = 0; U8 i = 0;
@@ -990,7 +1060,7 @@ void LLObjectBackup::xmlToPrim(LLSD prim_llsd, LLViewerObject* object)
object->setTE(i++, te); object->setTE(i++, te);
} }
llinfos << "Textures done !" << llendl; LL_INFOS("ObjectBackup") << "Textures done !" << LL_ENDL;
//bump the iterator now so the callbacks hook together nicely //bump the iterator now so the callbacks hook together nicely
//if (mPrimImportIter != mThisGroup.endMap()) //if (mPrimImportIter != mThisGroup.endMap())
@@ -1023,7 +1093,7 @@ void LLObjectBackup::primUpdate(LLViewerObject* object)
if (mPrimImportIter == mThisGroup.endMap()) if (mPrimImportIter == mThisGroup.endMap())
{ {
llinfos << "Trying to link" << llendl; LL_INFOS("ObjectBackup") << "Trying to link" << LL_ENDL;
if (mToSelect.size() > 1) if (mToSelect.size() > 1)
{ {
@@ -1053,7 +1123,7 @@ void LLObjectBackup::primUpdate(LLViewerObject* object)
if (mToSelect.empty()) if (mToSelect.empty())
{ {
llwarns << "error: ran out of objects to mod." << llendl; LL_WARNS("ObjectBackup") << "error: ran out of objects to mod." << LL_ENDL;
return; return;
} }
@@ -1085,7 +1155,7 @@ bool LLObjectBackup::newPrim(LLViewerObject* pobject)
} }
else else
{ {
llinfos << "All prims rezzed, moving to build stage" << llendl; LL_INFOS("ObjectBackup") << "All prims rezzed, moving to build stage" << LL_ENDL;
// Deselecting is required to ensure that the first child prim // Deselecting is required to ensure that the first child prim
// in the link set (which is also the last rezzed prim and thus // in the link set (which is also the last rezzed prim and thus
// currently selected) will be properly renamed and desced. // currently selected) will be properly renamed and desced.
@@ -1104,7 +1174,7 @@ void LLObjectBackup::updateMap(LLUUID uploaded_asset)
if (mCurrentAsset.isNull()) if (mCurrentAsset.isNull())
return; return;
llinfos << "Mapping " << mCurrentAsset << " to " << uploaded_asset << llendl; LL_INFOS("ObjectBackup") << "Mapping " << mCurrentAsset << " to " << uploaded_asset << LL_ENDL;
mAssetMap.insert(std::pair<LLUUID, LLUUID>(mCurrentAsset, uploaded_asset)); mAssetMap.insert(std::pair<LLUUID, LLUUID>(mCurrentAsset, uploaded_asset));
} }
@@ -1140,13 +1210,13 @@ void myupload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_
std::ostringstream llsdxml; std::ostringstream llsdxml;
LLSDSerialize::toXML(body, llsdxml); LLSDSerialize::toXML(body, llsdxml);
lldebugs << "posting body to capability: " << llsdxml.str() << llendl; LL_DEBUGS("ObjectBackup") << "posting body to capability: " << llsdxml.str() << LL_ENDL;
//LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, uuid, asset_type)); //LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, uuid, asset_type));
LLHTTPClient::post(url, body, new importResponder(body, uuid, asset_type)); LLHTTPClient::post(url, body, new importResponder(body, uuid, asset_type));
} }
else else
{ {
llinfos << "NewAgentInventory capability not found. Can't upload !" << llendl; LL_INFOS("ObjectBackup") << "NewAgentInventory capability not found. Can't upload !" << LL_ENDL;
} }
} }
@@ -1154,7 +1224,7 @@ void LLObjectBackup::uploadNextAsset()
{ {
if (mTexturesList.empty()) if (mTexturesList.empty())
{ {
llinfos << "Texture list is empty, moving to rez stage." << llendl; LL_INFOS("ObjectBackup") << "Texture list is empty, moving to rez stage." << LL_ENDL;
mCurrentAsset = LLUUID::null; mCurrentAsset = LLUUID::null;
importFirstObject(); importFirstObject();
return; return;
@@ -1167,7 +1237,7 @@ void LLObjectBackup::uploadNextAsset()
LLUUID id = *iter; LLUUID id = *iter;
mTexturesList.pop_front(); mTexturesList.pop_front();
llinfos << "Got texture ID " << id << ": trying to upload" << llendl; LL_INFOS("ObjectBackup") << "Got texture ID " << id << ": trying to upload" << LL_ENDL;
mCurrentAsset = id; mCurrentAsset = id;
std::string struid; std::string struid;
@@ -1182,7 +1252,7 @@ void LLObjectBackup::uploadNextAsset()
S32 file_size; S32 file_size;
LLAPRFile outfile; LLAPRFile outfile;
outfile.open(filename, LL_APR_RB, LLAPRFile::global, &file_size); outfile.open(filename, LL_APR_RB, LLAPRFile::local, &file_size);
if (outfile.getFileHandle()) if (outfile.getFileHandle())
{ {
const S32 buf_size = 65536; const S32 buf_size = 65536;
@@ -1197,7 +1267,7 @@ void LLObjectBackup::uploadNextAsset()
} }
else else
{ {
llwarns << "Unable to access output file " << filename << llendl; LL_WARNS("ObjectBackup") << "Unable to access output file " << filename << LL_ENDL;
uploadNextAsset(); uploadNextAsset();
return; return;
} }

View File

@@ -107,7 +107,7 @@ private:
LLUUID validateTextureID(LLUUID asset_id); LLUUID validateTextureID(LLUUID asset_id);
// Convert a selection list of objects to LLSD // Convert a selection list of objects to LLSD
LLSD primsToLLSD(LLViewerObject::child_list_t child_list); LLSD primsToLLSD(LLViewerObject::child_list_t child_list, bool is_attachment);
// Start the import process // Start the import process
void importFirstObject(); void importFirstObject();
@@ -176,3 +176,4 @@ private:
LLVector3 mAgentPos; LLVector3 mAgentPos;
LLQuaternion mAgentRot; LLQuaternion mAgentRot;
}; };

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater can_close="true" can_drag_on_left="false" can_minimize="true" can_resize="false"
rect_control="FloaterObjectBackuptRect"
height="80" width="200" name="Import" title="Import progress" mouse_opaque="true">
<text height="30" left="10" name="name_label" top="-20"> Progress </text>
</floater>