summaryrefslogtreecommitdiff
path: root/indra/newview/llinventorymodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llinventorymodel.cpp')
-rw-r--r--indra/newview/llinventorymodel.cpp312
1 files changed, 172 insertions, 140 deletions
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 4e2bb3e2e9..9177d51d5c 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -42,8 +42,10 @@
#include "message.h"
#include "llagent.h"
+#include "llagentwearables.h"
#include "llfloater.h"
#include "llfocusmgr.h"
+#include "llinventorybridge.h"
#include "llinventoryview.h"
#include "llviewerinventory.h"
#include "llviewermessage.h"
@@ -53,11 +55,11 @@
#include "lldbstrings.h"
#include "llviewerstats.h"
#include "llmutelist.h"
-#include "llnotify.h"
+#include "llnotifications.h"
#include "llcallbacklist.h"
#include "llpreview.h"
#include "llviewercontrol.h"
-#include "llvoavatar.h"
+#include "llvoavatarself.h"
#include "llsdutil.h"
#include <deque>
@@ -87,34 +89,6 @@ static std::deque<LLUUID> sFetchQueue;
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] =
-{
- "Textures", // AT_TEXTURE
- "Sounds", // AT_SOUND
- "Calling Cards", // AT_CALLINGCARD
- "Landmarks", // AT_LANDMARK
- "Scripts", // AT_SCRIPT (deprecated?)
- "Clothing", // AT_CLOTHING
- "Objects", // AT_OBJECT
- "Notecards", // AT_NOTECARD
- "New Folder", // AT_CATEGORY
- "Inventory", // AT_ROOT_CATEGORY
- "Scripts", // AT_LSL_TEXT
- "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
- "Uncompressed Sounds", // AT_SOUND_WAV
- "Uncompressed Images", // AT_IMAGE_TGA
- "Uncompressed Images", // AT_IMAGE_JPEG
- "Animations", // AT_ANIMATION
- "Gestures", // AT_GESTURE
- "New Folder", // AT_SIMSTATE
- "My Favorites" //AT_FAVORITE
-};
struct InventoryIDPtrLess
{
@@ -389,15 +363,9 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
{
name.assign(pname);
}
- else if((preferred_type >= LLAssetType::AT_TEXTURE) &&
- //why < LLAssetType::AT_SIMSTATE??? if preferred_type == LLAssetType::AT_SIMSTATE that will be handled above
- (preferred_type < LLAssetType::AT_COUNT))
- {
- name.assign(NEW_CATEGORY_NAMES[preferred_type]);
- }
else
{
- name.assign(NEW_CATEGORY_NAME);
+ name.assign(LLAssetType::lookupCategoryName(preferred_type));
}
// Add the category to the internal representation
@@ -547,7 +515,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
LLViewerInventoryItem* old_item = getItem(item->getUUID());
if(old_item)
{
- // We already have an old item, modify it's values
+ // We already have an old item, modify its values
LLUUID old_parent_id = old_item->getParentUUID();
LLUUID new_parent_id = item->getParentUUID();
if(old_parent_id != new_parent_id)
@@ -1044,7 +1012,7 @@ void LLInventoryModel::mock(const LLUUID& root_id)
root_id,
LLUUID::null,
LLAssetType::AT_CATEGORY,
- NEW_CATEGORY_NAMES[LLAssetType::AT_ROOT_CATEGORY],
+ LLAssetType::lookupCategoryName(LLAssetType::AT_ROOT_CATEGORY),
gAgent.getID());
addCategory(cat);
gInventory.buildParentChildMap();
@@ -1876,56 +1844,63 @@ bool LLInventoryModel::isCategoryComplete(const LLUUID& cat_id) const
}
bool LLInventoryModel::loadSkeleton(
- const LLSD& options,
+ const LLInventoryModel::options_t& options,
const LLUUID& owner_id)
{
lldebugs << "importing inventory skeleton for " << owner_id << llendl;
typedef std::set<LLPointer<LLViewerInventoryCategory>, InventoryIDPtrLess> cat_set_t;
cat_set_t temp_cats;
- bool rv = true;
- for(LLSD::array_const_iterator it = options.beginArray(),
- end = options.endArray(); it != end; ++it)
- {
- LLSD name = (*it)["name"];
- LLSD folder_id = (*it)["folder_id"];
- LLSD parent_id = (*it)["parent_id"];
- LLSD version = (*it)["version"];
- if(name.isDefined()
- && folder_id.isDefined()
- && parent_id.isDefined()
- && version.isDefined()
- && folder_id.asUUID().notNull() // if an id is null, it locks the viewer.
- )
- {
- LLPointer<LLViewerInventoryCategory> cat = new LLViewerInventoryCategory(owner_id);
- cat->rename(name.asString());
- cat->setUUID(folder_id.asUUID());
- cat->setParent(parent_id.asUUID());
+ update_map_t child_counts;
- LLAssetType::EType preferred_type = LLAssetType::AT_NONE;
- LLSD type_default = (*it)["type_default"];
- if(type_default.isDefined())
- {
- preferred_type = (LLAssetType::EType)type_default.asInteger();
- }
- cat->setPreferredType(preferred_type);
- cat->setVersion(version.asInteger());
- temp_cats.insert(cat);
+ LLUUID id;
+ LLAssetType::EType preferred_type;
+ bool rv = true;
+ for(options_t::const_iterator it = options.begin(); it < options.end(); ++it)
+ {
+ LLPointer<LLViewerInventoryCategory> cat = new LLViewerInventoryCategory(owner_id);
+ response_t::const_iterator no_response = (*it).end();
+ response_t::const_iterator skel;
+ skel = (*it).find("name");
+ if(skel == no_response) goto clean_cat;
+ cat->rename(std::string((*skel).second));
+ skel = (*it).find("folder_id");
+ if(skel == no_response) goto clean_cat;
+ id.set((*skel).second);
+ // if an id is null, it locks the viewer.
+ if(id.isNull()) goto clean_cat;
+ cat->setUUID(id);
+ skel = (*it).find("parent_id");
+ if(skel == no_response) goto clean_cat;
+ id.set((*skel).second);
+ cat->setParent(id);
+ skel = (*it).find("type_default");
+ if(skel == no_response)
+ {
+ preferred_type = LLAssetType::AT_NONE;
}
else
{
- llwarns << "Unable to import near " << name.asString() << llendl;
- rv = false;
+ S32 t = atoi((*skel).second.c_str());
+ preferred_type = (LLAssetType::EType)t;
}
+ cat->setPreferredType(preferred_type);
+ skel = (*it).find("version");
+ if(skel == no_response) goto clean_cat;
+ cat->setVersion(atoi((*skel).second.c_str()));
+ temp_cats.insert(cat);
+ continue;
+ clean_cat:
+ llwarns << "Unable to import near " << cat->getName() << llendl;
+ rv = false;
+ //delete cat; // automatic when cat is reasigned or destroyed
}
S32 cached_category_count = 0;
S32 cached_item_count = 0;
if(!temp_cats.empty())
{
- update_map_t child_counts;
cat_array_t categories;
item_array_t items;
std::string owner_id_str;
@@ -1954,7 +1929,6 @@ bool LLInventoryModel::loadSkeleton(
llinfos << "Unable to gunzip " << gzip_filename << llendl;
}
}
-
if(loadFromFile(inventory_filename, categories, items))
{
// We were able to find a cache of files. So, use what we
@@ -2079,84 +2053,85 @@ bool LLInventoryModel::loadSkeleton(
return rv;
}
-bool LLInventoryModel::loadMeat(const LLSD& options, const LLUUID& owner_id)
+bool LLInventoryModel::loadMeat(
+ const LLInventoryModel::options_t& options, const LLUUID& owner_id)
{
llinfos << "importing inventory for " << owner_id << llendl;
+ LLPermissions default_perm;
+ default_perm.init(LLUUID::null, owner_id, LLUUID::null, LLUUID::null);
+ LLPointer<LLViewerInventoryItem> item;
+ LLUUID id;
+ LLAssetType::EType type;
+ LLInventoryType::EType inv_type;
bool rv = true;
- for(LLSD::array_const_iterator it = options.beginArray(),
- end = options.endArray(); it != end; ++it)
- {
- LLSD name = (*it)["name"];
- LLSD item_id = (*it)["item_id"];
- LLSD parent_id = (*it)["parent_id"];
- LLSD asset_type = (*it)["type"];
- LLSD data_id = (*it)["data_id"];
- if(name.isDefined()
- && item_id.isDefined()
- && parent_id.isDefined()
- && asset_type.isDefined()
- && data_id.isDefined())
+ for(options_t::const_iterator it = options.begin(); it < options.end(); ++it)
+ {
+ item = new LLViewerInventoryItem;
+ response_t::const_iterator no_response = (*it).end();
+ response_t::const_iterator meat;
+ meat = (*it).find("name");
+ if(meat == no_response) goto clean_item;
+ item->rename(std::string((*meat).second));
+ meat = (*it).find("item_id");
+ if(meat == no_response) goto clean_item;
+ id.set((*meat).second);
+ item->setUUID(id);
+ meat = (*it).find("parent_id");
+ if(meat == no_response) goto clean_item;
+ id.set((*meat).second);
+ item->setParent(id);
+ meat = (*it).find("type");
+ if(meat == no_response) goto clean_item;
+ type = (LLAssetType::EType)atoi((*meat).second.c_str());
+ item->setType(type);
+ meat = (*it).find("inv_type");
+ if(meat != no_response)
+ {
+ inv_type = (LLInventoryType::EType)atoi((*meat).second.c_str());
+ item->setInventoryType(inv_type);
+ }
+ meat = (*it).find("data_id");
+ if(meat == no_response) goto clean_item;
+ id.set((*meat).second);
+ if(LLAssetType::AT_CALLINGCARD == type)
+ {
+ LLPermissions perm;
+ perm.init(id, owner_id, LLUUID::null, LLUUID::null);
+ item->setPermissions(perm);
+ }
+ else
{
- LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem;
- item->rename(name.asString());
- item->setUUID(item_id.asUUID());
- item->setParent(parent_id.asUUID());
- LLAssetType::EType type = (LLAssetType::EType)asset_type.asInteger();
- item->setType(type);
-
- LLSD llsd_inv_type = (*it)["inv_type"];
- if(llsd_inv_type.isDefined())
- {
- LLInventoryType::EType inv_type = (LLInventoryType::EType)llsd_inv_type.asInteger();
- item->setInventoryType(inv_type);
- }
-
- if(LLAssetType::AT_CALLINGCARD == type)
+ meat = (*it).find("perm_mask");
+ if(meat != no_response)
{
- LLPermissions perm;
- perm.init(data_id.asUUID(), owner_id, LLUUID::null, LLUUID::null);
- item->setPermissions(perm);
+ PermissionMask perm_mask = atoi((*meat).second.c_str());
+ default_perm.initMasks(
+ perm_mask, perm_mask, perm_mask, perm_mask, perm_mask);
}
else
{
- LLPermissions default_perm;
- default_perm.init(LLUUID::null, owner_id, LLUUID::null, LLUUID::null);
- LLSD llsd_perm_mask = (*it)["perm_mask"];
- if(llsd_perm_mask.isDefined())
- {
- PermissionMask perm_mask = llsd_perm_mask.asInteger();
- default_perm.initMasks(
- perm_mask, perm_mask, perm_mask, perm_mask, perm_mask);
- }
- else
- {
- default_perm.initMasks(
- PERM_NONE, PERM_NONE, PERM_NONE, PERM_NONE, PERM_NONE);
- }
- item->setPermissions(default_perm);
- item->setAssetUUID(data_id.asUUID());
+ default_perm.initMasks(
+ PERM_NONE, PERM_NONE, PERM_NONE, PERM_NONE, PERM_NONE);
}
-
- LLSD flags = (*it)["flags"];
- if(flags.isDefined())
- {
- // Not sure how well LLSD.asInteger() maps to
- // unsigned long - using strtoul()
- item->setFlags(strtoul(flags.asString().c_str(), NULL, 0));
- }
-
- LLSD time = (*it)["time"];
- if(time.isDefined())
- {
- item->setCreationDate(time.asInteger());
- }
- addItem(item);
+ item->setPermissions(default_perm);
+ item->setAssetUUID(id);
}
- else
+ meat = (*it).find("flags");
+ if(meat != no_response)
+ {
+ item->setFlags(strtoul((*meat).second.c_str(), NULL, 0));
+ }
+ meat = (*it).find("time");
+ if(meat != no_response)
{
- llwarns << "Unable to import near " << name.asString() << llendl;
- rv = false;
+ item->setCreationDate(atoi((*meat).second.c_str()));
}
+ addItem(item);
+ continue;
+ clean_item:
+ llwarns << "Unable to import near " << item->getName() << llendl;
+ rv = false;
+ //delete item; // automatic when item is reassigned or destroyed
}
return rv;
}
@@ -3153,6 +3128,63 @@ void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**)
}
}
+//----------------------------------------------------------------------------
+
+// Trash: LLAssetType::AT_TRASH, "ConfirmEmptyTrash"
+// Lost&Found: LLAssetType::AT_LOST_AND_FOUND, "ConfirmEmptyLostAndFound"
+
+bool LLInventoryModel::callbackEmptyFolderType(const LLSD& notification, const LLSD& response, LLAssetType::EType folder_type)
+{
+ S32 option = LLNotification::getSelectedOption(notification, response);
+ if (option == 0) // YES
+ {
+ LLUUID folder_id = findCategoryUUIDForType(folder_type);
+ purgeDescendentsOf(folder_id);
+ notifyObservers();
+ }
+ return false;
+}
+
+void LLInventoryModel::emptyFolderType(const std::string notification, LLAssetType::EType folder_type)
+{
+ if (!notification.empty())
+ {
+ LLNotifications::instance().add(notification, LLSD(), LLSD(),
+ boost::bind(&LLInventoryModel::callbackEmptyFolderType, this, _1, _2, folder_type));
+ }
+ else
+ {
+ LLUUID folder_id = findCategoryUUIDForType(folder_type);
+ purgeDescendentsOf(folder_id);
+ notifyObservers();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void LLInventoryModel::removeItem(const LLUUID& item_id)
+{
+ LLViewerInventoryItem* item = getItem(item_id);
+ const LLUUID& new_parent = findCategoryUUIDForType(LLAssetType::AT_TRASH);
+ if (item && item->getParentUUID() != new_parent)
+ {
+ LLInventoryModel::update_list_t update;
+ LLInventoryModel::LLCategoryUpdate old_folder(item->getParentUUID(),-1);
+ update.push_back(old_folder);
+ LLInventoryModel::LLCategoryUpdate new_folder(new_parent, 1);
+ update.push_back(new_folder);
+ accountForUpdate(update);
+
+ LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
+ new_item->setParent(new_parent);
+ new_item->updateParentOnServer(TRUE);
+ updateItem(new_item);
+ notifyObservers();
+ }
+}
+
+//----------------------------------------------------------------------------
+
// *NOTE: DEBUG functionality
void LLInventoryModel::dumpInventory()
{
@@ -3200,7 +3232,7 @@ bool LLInventoryCollectFunctor::itemTransferCommonlyAllowed(LLInventoryItem* ite
return false;
bool allowed = false;
- LLVOAvatar* my_avatar = NULL;
+ LLVOAvatarSelf* my_avatar = NULL;
switch(item->getType())
{
@@ -3218,7 +3250,7 @@ bool LLInventoryCollectFunctor::itemTransferCommonlyAllowed(LLInventoryItem* ite
case LLAssetType::AT_BODYPART:
case LLAssetType::AT_CLOTHING:
- if(!gAgent.isWearingItem(item->getUUID()))
+ if(!gAgentWearables.isWearingItem(item->getUUID()))
{
allowed = true;
}