Ïntroduced LLFolderType and LLViewerAssetType (by Shyotl)

This commit is contained in:
Siana Gearz
2011-06-23 21:11:52 +02:00
parent 04e41002c5
commit 6348635d3f
62 changed files with 1688 additions and 1336 deletions

View File

@@ -47,6 +47,7 @@
#include "llinventoryview.h"
#include "llviewerinventory.h"
#include "llviewermessage.h"
#include "llfoldertype.h"
#include "llviewerwindow.h"
#include "llviewerregion.h"
#include "llappviewer.h"
@@ -100,34 +101,36 @@ const F32 MAX_TIME_FOR_SINGLE_FETCH = 10.f;
const S32 MAX_FETCH_RETRIES = 10;
const char CACHE_FORMAT_STRING[] = "%s.inv";
const char* NEW_CATEGORY_NAME = "New Folder";
const char* NEW_CATEGORY_NAMES[LLAssetType::AT_COUNT] =
const char* NEW_CATEGORY_NAMES[LLFolderType::FT_COUNT] =
{
"Textures", // AT_TEXTURE
"Sounds", // AT_SOUND
"Calling Cards", // AT_CALLINGCARD
"Landmarks", // AT_LANDMARK
"Textures", // FT_TEXTURE = 0,
"Sounds", // FT_SOUND = 1,
"Calling Cards", // FT_CALLINGCARD = 2,
"Landmarks", // FT_LANDMARK = 3,
"Scripts", // AT_SCRIPT (deprecated?)
"Clothing", // AT_CLOTHING
"Objects", // AT_OBJECT
"Notecards", // AT_NOTECARD
"New Folder", // AT_CATEGORY
"Clothing", // FT_CLOTHING = 5,
"Objects", // FT_OBJECT = 6,
"Notecards", // FT_NOTECARD = 7,
"New Folder", // FT_ROOT_INVENTORY = 8,
"Inventory", // AT_ROOT_CATEGORY
"Scripts", // AT_LSL_TEXT
"Scripts", // FT_LSL_TEXT = 10,
"Scripts", // AT_LSL_BYTECODE
"Uncompressed Images", // AT_TEXTURE_TGA
"Body Parts", // AT_BODYPART
"Trash", // AT_TRASH
"Photo Album", // AT_SNAPSHOT_CATEGORY
"Lost And Found", // AT_LOST_AND_FOUND
"Body Parts", // FT_BODYPART = 13,
"Trash", // FT_TRASH = 14,
"Photo Album", // FT_SNAPSHOT_CATEGORY = 15,
"Lost And Found", // FT_LOST_AND_FOUND = 16,
"Uncompressed Sounds", // AT_SOUND_WAV
"Uncompressed Images", // AT_IMAGE_TGA
"Uncompressed Images", // AT_IMAGE_JPEG
"Animations", // AT_ANIMATION
"Gestures", // AT_GESTURE
"Animations", // FT_ANIMATION = 20,
"Gestures", // FT_GESTURE = 21,
"New Folder", // AT_SIMSTATE
"Favorites",
"Favorites", // FT_FAVORITE = 23,
"New Folder",
"New Folder",
"New Ensemble", // FT_ENSEMBLE_START = 26,
"New Ensemble",
"New Ensemble",
"New Ensemble",
@@ -146,11 +149,11 @@ const char* NEW_CATEGORY_NAMES[LLAssetType::AT_COUNT] =
"New Ensemble",
"New Ensemble",
"New Ensemble",
"New Ensemble",
"New Ensemble",
"Current Outfit",
"New Outfit",
"My Outfits"
"New Ensemble", // FT_ENSEMBLE_END = 45,
"Current Outfit", // FT_CURRENT_OUTFIT = 46,
"New Outfit", // FT_OUTFIT = 47,
"My Outfits", // FT_MY_OUTFITS = 48,
"Inbox" // FT_INBOX = 49,
};
struct InventoryIDPtrLess
@@ -279,6 +282,29 @@ BOOL LLInventoryModel::isObjectDescendentOf(const LLUUID& obj_id,
return FALSE;
}
const LLViewerInventoryCategory *LLInventoryModel::getFirstNondefaultParent(const LLUUID& obj_id) const
{
const LLInventoryObject* obj = getObject(obj_id);
// Search up the parent chain until we get to root or an acceptable folder.
// This assumes there are no cycles in the tree else we'll get a hang.
LLUUID parent_id = obj->getParentUUID();
while (!parent_id.isNull())
{
const LLViewerInventoryCategory *cat = getCategory(parent_id);
if (!cat) break;
const LLFolderType::EType folder_type = cat->getPreferredType();
if (folder_type != LLFolderType::FT_NONE &&
folder_type != LLFolderType::FT_ROOT_INVENTORY &&
!LLFolderType::lookupIsEnsembleType(folder_type))
{
return cat;
}
parent_id = cat->getParentUUID();
}
return NULL;
}
// Get the object by id. Returns NULL if not found.
LLInventoryObject* LLInventoryModel::getObject(const LLUUID& id) const
{
@@ -383,51 +409,32 @@ void LLInventoryModel::unlockDirectDescendentArrays(const LLUUID& cat_id)
// specifies 'type' as what it defaults to containing. The category is
// not necessarily only for that type. *NOTE: This will create a new
// inventory category on the fly if one does not exist.
const LLUUID LLInventoryModel::findCategoryUUIDForType(LLAssetType::EType t, bool create_folder)
const LLUUID LLInventoryModel::findCategoryUUIDForType(LLFolderType::EType preferred_type,
bool create_folder//,
/*bool find_in_library*/)
{
LLUUID rv = findCatUUID(t);
LLUUID rv = findCatUUID(preferred_type);
if(rv.isNull() && isInventoryUsable() && create_folder)
{
LLUUID root_id = gAgent.getInventoryRootID();
if(root_id.notNull())
{
rv = createNewCategory(root_id, t, LLStringUtil::null);
rv = createNewCategory(root_id, preferred_type, LLStringUtil::null);
}
}
return rv;
}
const LLViewerInventoryCategory *LLInventoryModel::getFirstNondefaultParent(const LLUUID& obj_id) const
{
const LLInventoryObject* obj = getObject(obj_id);
// Search up the parent chain until we get to root or an acceptable folder.
// This assumes there are no cycles in the tree else we'll get a hang.
LLUUID parent_id = obj->getParentUUID();
while (!parent_id.isNull())
{
const LLViewerInventoryCategory *cat = getCategory(parent_id);
if (!cat) break;
const LLAssetType::EType folder_type = cat->getPreferredType();
if (folder_type != LLAssetType::AT_NONE && folder_type != LLAssetType::AT_ROOT_CATEGORY)
{
return cat;
}
parent_id = cat->getParentUUID();
}
return NULL;
}
// Internal method which looks for a category with the specified
// preferred type. Returns LLUUID::null if not found.
LLUUID LLInventoryModel::findCatUUID(LLAssetType::EType preferred_type)
LLUUID LLInventoryModel::findCatUUID(LLFolderType::EType preferred_type)
{
LLUUID root_id = gAgent.getInventoryRootID();
if(LLAssetType::AT_CATEGORY == preferred_type)
const LLUUID &root_id = gAgent.getInventoryRootID();
if(LLFolderType::FT_ROOT_INVENTORY == preferred_type)
{
return root_id;
}
if(root_id.notNull())
else if (root_id.notNull())
{
cat_array_t* cats = NULL;
cats = get_ptr_in_map(mParentChildCategoryTree, root_id);
@@ -473,7 +480,7 @@ LLUUID LLInventoryModel::findCategoryByName(std::string name)
// version will take care of details like what the name should be
// based on preferred type. Returns the UUID of the new category.
LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
LLAssetType::EType preferred_type,
LLFolderType::EType preferred_type,
const std::string& pname)
{
LLUUID id;
@@ -483,38 +490,9 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
return id;
}
if(preferred_type == LLAssetType::AT_SIMSTATE)
if(LLFolderType::lookup(preferred_type) == LLFolderType::badLookup())
{
lldebugs << "Attempt to create simstate category." << llendl;
return id;
}
else if(preferred_type == LLAssetType::AT_SOUND_WAV)
{
lldebugs << "Attempt to create (wave) uncompressed sound category." << llendl;
return id;
}
else if(preferred_type == LLAssetType::AT_IMAGE_TGA)
{
lldebugs << "Attempt to create a AT_IMAGE_TGA uncompresssed images category." << llendl;
return id;
}
else if(preferred_type == LLAssetType::AT_TEXTURE_TGA)
{
lldebugs << "Attempt to create a AT_TEXTURE_TGA uncompresssed images category." << llendl;
return id;
}
else if(preferred_type == LLAssetType::AT_IMAGE_JPEG)
{
lldebugs << "Attempt to create a AT_IMAGE_JPEG uncompresssed images category." << llendl;
return id;
}else if(preferred_type == LLAssetType::AT_SCRIPT)
{
lldebugs << "Attempt to create a AT_Script scripts category." << llendl;
return id;
}else if(preferred_type == LLAssetType::AT_LSL_BYTECODE)
{
lldebugs << "Attempt to create a AT_LSL_BYTECODE scripts category." << llendl;
lldebugs << "Attempt to create undefined category. (" << preferred_type << ")" << llendl;
return id;
}
@@ -524,15 +502,10 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
{
name.assign(pname);
}
else if((preferred_type >= LLAssetType::AT_TEXTURE) &&
(preferred_type <= LLAssetType::AT_MY_OUTFITS))
{
name.assign(NEW_CATEGORY_NAMES[preferred_type]);
}
else
{
if(preferred_type < LLFolderType::FT_TEXTURE || preferred_type > LLFolderType::FT_INBOX)
name.assign(NEW_CATEGORY_NAME);
}
else
name.assign(NEW_CATEGORY_NAMES[preferred_type]);
// Add the category to the internal representation
LLPointer<LLViewerInventoryCategory> cat =
@@ -595,7 +568,7 @@ void LLInventoryModel::collectDescendentsIf(const LLUUID& id,
// Start with categories
if(!include_trash)
{
const LLUUID trash_id = findCategoryUUIDForType(LLAssetType::AT_TRASH);
const LLUUID trash_id = findCategoryUUIDForType(LLFolderType::FT_TRASH);
if(trash_id.notNull() && (trash_id == id))
return;
}
@@ -651,7 +624,7 @@ void LLInventoryModel::collectDescendentsIf(const LLUUID& id,
if (item && item->getActualType() == LLAssetType::AT_LINK_FOLDER)
{
LLViewerInventoryCategory *linked_cat = item->getLinkedCategory();
if (linked_cat && linked_cat->getPreferredType() != LLAssetType::AT_OUTFIT)
if (linked_cat && linked_cat->getPreferredType() != LLFolderType::FT_OUTFIT)
// BAP - was
// LLAssetType::lookupIsEnsembleCategoryType(linked_cat->getPreferredType()))
// Change back once ensemble typing is in place.
@@ -822,7 +795,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
if(item->getParentUUID().isNull())
{
LLUUID category_id = findCategoryUUIDForType(new_item->getType());
const LLUUID category_id = findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(new_item->getType()));
new_item->setParent(category_id);
item_array_t* item_array = get_ptr_in_map(mParentChildItemTree, category_id);
if( item_array )
@@ -846,7 +819,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
LLUUID parent_id = item->getParentUUID();
if(parent_id == CATEGORIZE_LOST_AND_FOUND_ID)
{
parent_id = findCategoryUUIDForType(LLAssetType::AT_LOST_AND_FOUND);
parent_id = findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND);
new_item->setParent(parent_id);
}
item_array_t* item_array = get_ptr_in_map(mParentChildItemTree, parent_id);
@@ -859,7 +832,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
// Whoops! No such parent, make one.
llinfos << "Lost item: " << new_item->getUUID() << " - "
<< new_item->getName() << llendl;
parent_id = findCategoryUUIDForType(LLAssetType::AT_LOST_AND_FOUND);
parent_id = findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND);
new_item->setParent(parent_id);
item_array = get_ptr_in_map(mParentChildItemTree, parent_id);
if(item_array)
@@ -1022,8 +995,12 @@ void LLInventoryModel::deleteObject(const LLUUID& id)
{
lldebugs << "LLInventoryModel::deleteObject()" << llendl;
LLPointer<LLInventoryObject> obj = getObject(id);
if(obj)
if (!obj)
{
llwarns << "Deleting non-existent object [ id: " << id << " ] " << llendl;
return;
}
lldebugs << "Deleting inventory object " << id << llendl;
mLastItem = NULL;
LLUUID parent_id = obj->getParentUUID();
@@ -1057,7 +1034,6 @@ void LLInventoryModel::deleteObject(const LLUUID& id)
addChangedMask(LLInventoryObserver::REMOVE, id);
obj = NULL; // delete obj
}
}
// Delete a particular inventory item by ID, and remove it from the server.
void LLInventoryModel::purgeObject(const LLUUID &id)
@@ -1305,7 +1281,7 @@ void LLInventoryModel::mock(const LLUUID& root_id)
root_id,
LLUUID::null,
LLAssetType::AT_CATEGORY,
NEW_CATEGORY_NAMES[LLAssetType::AT_ROOT_CATEGORY],
NEW_CATEGORY_NAMES[LLFolderType::FT_ROOT_CATEGORY],
gAgent.getID());
addCategory(cat);
gInventory.buildParentChildMap();
@@ -1467,7 +1443,7 @@ void fetchDescendentsResponder::result(const LLSD& content)
item_it != folder_sd["items"].endArray();
++item_it)
{
LLUUID lost_uuid = gInventory.findCategoryUUIDForType(LLAssetType::AT_LOST_AND_FOUND);
LLUUID lost_uuid = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND);
if (lost_uuid.notNull())
{
LLSD item = *item_it;
@@ -2056,14 +2032,16 @@ void LLInventoryModel::accountForUpdate(const LLCategoryUpdate& update) const
}
if(!accounted)
{
lldebugs << "No accounting for: '" << cat->getName() << "' "
// Error condition, this means that the category did not register that
// it got new descendents (perhaps because it is still being loaded)
// which means its descendent count will be wrong.
llwarns << "Accounting failed for '" << cat->getName() << "' version:"
<< version << llendl;
}
}
else
{
llwarns << "No category found for update " << update.mCategoryID
<< llendl;
llwarns << "No category found for update " << update.mCategoryID << llendl;
}
}
@@ -2194,12 +2172,6 @@ bool LLInventoryModel::isCategoryComplete(const LLUUID& cat_id) const
return false;
}
// OGPX : This loadSkeleton() takes LLSD formated data, other loadSkeleton is for XML-RPC data.
// There are major differences in what is returned from the XML-RPC authenticate call versus
// the style and sequence of OGP/llsd style authentication.
// In OGP, authentication returns a cap to the skeleton on agent domain. An HTTP GET then occurs on
// this "agent/inventory-skeleton" cap. This loadSkeleton()
// routine is called after that HTTP GET of "agent/inventory-skeleton" cap occurs.
bool LLInventoryModel::loadSkeleton(
const LLSD& options,
const LLUUID& owner_id)
@@ -2229,11 +2201,11 @@ bool LLInventoryModel::loadSkeleton(
cat->setUUID(folder_id.asUUID());
cat->setParent(parent_id.asUUID());
LLAssetType::EType preferred_type = LLAssetType::AT_NONE;
LLFolderType::EType preferred_type = LLFolderType::FT_NONE;
LLSD type_default = (*it)["type_default"];
if(type_default.isDefined())
{
preferred_type = (LLAssetType::EType)type_default.asInteger();
preferred_type = (LLFolderType::EType)type_default.asInteger();
}
cat->setPreferredType(preferred_type);
cat->setVersion(version.asInteger());
@@ -2534,12 +2506,12 @@ void LLInventoryModel::buildParentChildMap()
<< cat->getName() << " with parent:" << cat->getParentUUID() << llendl;
++lost;
// plop it into the lost & found.
LLAssetType::EType pref = cat->getPreferredType();
if(LLAssetType::AT_NONE == pref)
LLFolderType::EType pref = cat->getPreferredType();
if(LLFolderType::FT_NONE == pref)
{
cat->setParent(findCategoryUUIDForType(LLAssetType::AT_LOST_AND_FOUND));
cat->setParent(findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND));
}
else if(LLAssetType::AT_CATEGORY == pref)
else if(LLFolderType::FT_ROOT_INVENTORY == pref)
{
// it's the root
cat->setParent(LLUUID::null);
@@ -2581,7 +2553,7 @@ void LLInventoryModel::buildParentChildMap()
}
count = items.count();
lost = 0;
std::vector<LLUUID> lost_item_ids;
uuid_vec_t lost_item_ids;
for(i = 0; i < count; ++i)
{
LLPointer<LLViewerInventoryItem> item;
@@ -2598,7 +2570,7 @@ void LLInventoryModel::buildParentChildMap()
++lost;
// plop it into the lost & found.
//
item->setParent(findCategoryUUIDForType(LLAssetType::AT_LOST_AND_FOUND));
item->setParent(findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND));
// move it later using a special message to move items. If
// we update server here, the client might crash.
//item->updateServer();
@@ -2619,8 +2591,8 @@ void LLInventoryModel::buildParentChildMap()
llwarns << "Found " << lost << " lost items." << llendl;
LLMessageSystem* msg = gMessageSystem;
BOOL start_new_message = TRUE;
LLUUID lnf = findCategoryUUIDForType(LLAssetType::AT_LOST_AND_FOUND);
for(std::vector<LLUUID>::iterator it = lost_item_ids.begin() ; it < lost_item_ids.end(); ++it)
const LLUUID lnf = findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND);
for(uuid_vec_t::iterator it = lost_item_ids.begin() ; it < lost_item_ids.end(); ++it)
{
if(start_new_message)
{
@@ -3052,7 +3024,7 @@ void LLInventoryModel::processRemoveInventoryItem(LLMessageSystem* msg, void**)
return;
}
S32 count = msg->getNumberOfBlocksFast(_PREHASH_InventoryData);
std::vector<LLUUID> item_ids;
uuid_vec_t item_ids;
update_map_t update;
for(S32 i = 0; i < count; ++i)
{
@@ -3068,7 +3040,7 @@ void LLInventoryModel::processRemoveInventoryItem(LLMessageSystem* msg, void**)
}
}
gInventory.accountForUpdate(update);
for(std::vector<LLUUID>::iterator it = item_ids.begin(); it != item_ids.end(); ++it)
for(uuid_vec_t::iterator it = item_ids.begin(); it != item_ids.end(); ++it)
{
gInventory.deleteObject(*it);
}
@@ -3099,7 +3071,7 @@ void LLInventoryModel::processUpdateInventoryFolder(LLMessageSystem* msg,
lastfolder = tfolder;
tfolder->unpackMessage(msg, _PREHASH_FolderData, i);
// make sure it's not a protected folder
tfolder->setPreferredType(LLAssetType::AT_NONE);
tfolder->setPreferredType(LLFolderType::FT_NONE);
folders.push_back(tfolder);
// examine update for changes.
LLViewerInventoryCategory* folderp = gInventory.getCategory(tfolder->getUUID());
@@ -3148,7 +3120,7 @@ void LLInventoryModel::processRemoveInventoryFolder(LLMessageSystem* msg,
<< llendl;
return;
}
std::vector<LLUUID> folder_ids;
uuid_vec_t folder_ids;
update_map_t update;
S32 count = msg->getNumberOfBlocksFast(_PREHASH_FolderData);
for(S32 i = 0; i < count; ++i)
@@ -3162,7 +3134,7 @@ void LLInventoryModel::processRemoveInventoryFolder(LLMessageSystem* msg,
}
}
gInventory.accountForUpdate(update);
for(std::vector<LLUUID>::iterator it = folder_ids.begin(); it != folder_ids.end(); ++it)
for(uuid_vec_t::iterator it = folder_ids.begin(); it != folder_ids.end(); ++it)
{
gInventory.deleteObject(*it);
}
@@ -3297,7 +3269,7 @@ void LLInventoryModel::processBulkUpdateInventory(LLMessageSystem* msg, void**)
count = msg->getNumberOfBlocksFast(_PREHASH_ItemData);
std::vector<LLUUID> wearable_ids;
uuid_vec_t wearable_ids;
item_array_t items;
std::list<InventoryCallbackInfo> cblist;
for(i = 0; i < count; ++i)
@@ -3411,8 +3383,7 @@ void LLInventoryModel::processInventoryDescendents(LLMessageSystem* msg,void**)
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
if(agent_id != gAgent.getID())
{
llwarns << "Got a UpdateInventoryItem for the wrong agent."
<< llendl;
llwarns << "Got a UpdateInventoryItem for the wrong agent." << llendl;
return;
}
LLUUID parent_id;