Sync LLInventoryModel and LLViewerInventory with upstream

This commit is contained in:
Liru Færs
2020-01-21 03:08:32 -05:00
parent 851b3659ee
commit 4b2e358783
5 changed files with 347 additions and 315 deletions

View File

@@ -4184,7 +4184,7 @@ LLUUID LLAppearanceMgr::makeNewOutfitLinks(const std::string& new_folder_name, L
// 2) Stuff with requests via makeLink and makeCopy
// 3) Call dispatch()
// 4) Let the LLPointer go out of scope.
class LLCreateLegacyOutfit : public LLBoostFuncInventoryCallbackFireOnce
class LLCreateLegacyOutfit final : public LLBoostFuncInventoryCallbackFireOnce
{
public:
LLCreateLegacyOutfit(const LLUUID& folder_id, inventory_func_type fire_func, nullary_func_type destroy_func = no_op) :

File diff suppressed because it is too large Load Diff

View File

@@ -192,14 +192,14 @@ private:
**/
//--------------------------------------------------------------------
// Descendents
// Descendants
//--------------------------------------------------------------------
public:
// Make sure we have the descendents in the structure. Returns true
// Make sure we have the descendants in the structure. Returns true
// if a fetch was performed.
bool fetchDescendentsOf(const LLUUID& folder_id) const;
// Return the direct descendents of the id provided.Set passed
// Return the direct descendants of the id provided.Set passed
// in values to NULL if the call fails.
// NOTE: The array provided points straight into the guts of
// this object, and should only be used for read operations, since
@@ -211,10 +211,10 @@ public:
void getDirectDescendentsOf(const LLUUID& cat_id,
cat_array_t*& categories) const;
// Compute a hash of direct descendent names (for detecting child name changes)
// Compute a hash of direct descendant names (for detecting child name changes)
LLMD5 hashDirectDescendentNames(const LLUUID& cat_id) const;
// Starting with the object specified, add its descendents to the
// Starting with the object specified, add its descendants to the
// array provided, but do not add the inventory object specified
// by id. There is no guaranteed order.
// NOTE: Neither array will be erased before adding objects to it.
@@ -340,7 +340,7 @@ public:
U32 updateItem(const LLViewerInventoryItem* item, U32 mask = 0);
// Change an existing item with the matching id or add
// the category. No notifcation will be sent to observers. This
// the category. No notification will be sent to observers. This
// method will only generate network traffic if the item had to be
// reparented.
// NOTE: In usage, you will want to perform cache accounting
@@ -378,7 +378,7 @@ public:
bool update_parent_version = true,
bool do_notify_observers = true);
// Update model after all descendents removed from server.
// Update model after all descendants removed from server.
void onDescendentsPurgedFromServer(const LLUUID& object_id, bool fix_broken_links = true);
// Update model after an existing item gets updated on server.
@@ -499,10 +499,12 @@ public:
// Call to explicitly update everyone on a new state.
void notifyObservers();
// Allows outsiders to tell the inventory if something has
// been changed 'under the hood', but outside the control of the
// inventory. The next notify will include that notification.
void addChangedMask(U32 mask, const LLUUID& referent);
const changed_items_t& getChangedIDs() const { return mChangedItemIDs; }
const changed_items_t& getAddedIDs() const { return mAddedItemIDs; }
protected:
@@ -556,6 +558,7 @@ protected:
static bool loadFromFile(const std::string& filename,
cat_array_t& categories,
item_array_t& items,
changed_items_t& cats_to_update,
bool& is_cache_obsolete);
static bool saveToFile(const std::string& filename,
const cat_array_t& categories,

View File

@@ -4,7 +4,7 @@
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
* Copyright (C) 2014, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -84,20 +84,44 @@ static const char * const LOG_INV("Inventory");
static const char * const LOG_LOCAL("InventoryLocalize");
static const char * const LOG_NOTECARD("copy_inventory_from_notecard");
#if 1
// *TODO$: LLInventoryCallback should be deprecated to conform to the new boost::bind/coroutine model.
// temp code in transition
void doInventoryCb(LLPointer<LLInventoryCallback> cb, LLUUID id)
{
if (cb.notNull())
cb->fire(id);
}
#endif
///----------------------------------------------------------------------------
/// Helper class to store special inventory item names and their localized values.
///----------------------------------------------------------------------------
class LLLocalizedInventoryItemsDictionary : public LLSingleton<LLLocalizedInventoryItemsDictionary>
class LLLocalizedInventoryItemsDictionary final : public LLSingleton<LLLocalizedInventoryItemsDictionary>
{
public:
std::map<std::string, std::string> mInventoryItemsDict;
/**
* Finds passed name in dictionary and replaces it with found localized value.
*
* @param object_name - string to be localized.
* @return true if passed name was found and localized, false otherwise.
*/
bool localizeInventoryObjectName(std::string& object_name)
{
LL_DEBUGS(LOG_LOCAL) << "Searching for localization: " << object_name << LL_ENDL;
std::map<std::string, std::string>::const_iterator dictionary_iter = mInventoryItemsDict.find(object_name);
bool found = dictionary_iter != mInventoryItemsDict.end();
if(found)
{
object_name = dictionary_iter->second;
LL_DEBUGS(LOG_LOCAL) << "Found, new name is: " << object_name << LL_ENDL;
}
return found;
}
LLLocalizedInventoryItemsDictionary()
{
mInventoryItemsDict["New Shape"] = LLTrans::getString("New Shape");
@@ -196,27 +220,6 @@ public:
mInventoryItemsDict["dance7"] = LLTrans::getString("dance7");
mInventoryItemsDict["dance8"] = LLTrans::getString("dance8");
}
/**
* Finds passed name in dictionary and replaces it with found localized value.
*
* @param object_name - string to be localized.
* @return true if passed name was found and localized, false otherwise.
*/
bool localizeInventoryObjectName(std::string& object_name)
{
LL_DEBUGS(LOG_LOCAL) << "Searching for localization: " << object_name << LL_ENDL;
std::map<std::string, std::string>::const_iterator dictionary_iter = mInventoryItemsDict.find(object_name);
bool found = dictionary_iter != mInventoryItemsDict.end();
if(found)
{
object_name = dictionary_iter->second;
LL_DEBUGS(LOG_LOCAL) << "Found, new name is: " << object_name << LL_ENDL;
}
return found;
}
};
@@ -324,6 +327,7 @@ void LLViewerInventoryItem::updateServer(BOOL is_new) const
if(!mIsComplete)
{
// *FIX: deal with this better.
// If we're crashing here then the UI is incorrectly enabled.
LL_ERRS(LOG_INV) << "LLViewerInventoryItem::updateServer() - for incomplete item"
<< LL_ENDL;
LLNotificationsUtil::add("IncompleteInventoryItem");
@@ -455,7 +459,7 @@ void LLViewerInventoryItem::setTransactionID(const LLTransactionID& transaction_
{
mTransactionID = transaction_id;
}
// virtual
void LLViewerInventoryItem::packMessage(LLMessageSystem* msg) const
{
msg->addUUIDFast(_PREHASH_ItemID, mUUID);
@@ -474,6 +478,7 @@ void LLViewerInventoryItem::packMessage(LLMessageSystem* msg) const
U32 crc = getCRC32();
msg->addU32Fast(_PREHASH_CRC, crc);
}
// virtual
BOOL LLViewerInventoryItem::importFile(LLFILE* fp)
{
@@ -621,7 +626,7 @@ void LLViewerInventoryCategory::updateServer(BOOL is_new) const
if (AISAPI::isAvailable())
{
LLSD new_llsd = asLLSD();
AISAPI::completion_t cr = boost::bind(&doInventoryCb, (LLPointer<LLInventoryCallback>)NULL, _1);
AISAPI::completion_t cr = boost::bind(&doInventoryCb, LLPointer<LLInventoryCallback>(NULL), _1);
AISAPI::UpdateCategory(getUUID(), new_llsd, cr);
}
else
@@ -833,7 +838,7 @@ bool LLViewerInventoryCategory::acceptItem(LLInventoryItem* inv_item)
LLInventoryModel::item_array_t* item_array;
gInventory.getDirectDescendentsOf(getUUID(),cat_array,item_array);
// Destination stock folder must be empty OR types of incoming and existing items must be identical and have the same permissions
accept = (!item_array->size() ||
accept = (item_array->empty() ||
((item_array->at(0)->getInventoryType() == inv_item->getInventoryType()) &&
(item_array->at(0)->getPermissions().getMaskNextOwner() == inv_item->getPermissions().getMaskNextOwner())));
}
@@ -981,10 +986,10 @@ void LLInventoryCallbackManager::destroyClass()
{
if (sInstance)
{
for (callback_map_t::iterator it = sInstance->mMap.begin(), end_it = sInstance->mMap.end(); it != end_it; ++it)
for (auto& it : sInstance->mMap)
{
// drop LLPointer reference to callback
it->second = NULL;
it.second = NULL;
}
sInstance->mMap.clear();
}
@@ -1020,7 +1025,7 @@ void LLInventoryCallbackManager::fire(U32 callback_id, const LLUUID& item_id)
}
//void rez_attachment_cb(const LLUUID& inv_item, LLViewerJointAttachment *attachmentp)
// [SL:KB] - Patch: Appearance-DnDWear | Checked: 2010-09-28 (Catznip-3.0.0a) | Added: Catznip-2.2.0a
// [SL:KB] - Patch: Appearance-DnDWear | Checked: 2010-09-28 (Catznip-3.4)
void rez_attachment_cb(const LLUUID& inv_item, LLViewerJointAttachment *attachmentp, bool replace)
// [/SL:KB]
{
@@ -1107,6 +1112,7 @@ void create_gesture_cb(const LLUUID& inv_item)
}
}
void create_notecard_cb(const LLUUID& inv_item)
{
if (!inv_item.isNull())
@@ -1173,10 +1179,10 @@ void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id,
void create_inventory_callingcard(const LLUUID& avatar_id, const LLUUID& parent /*= LLUUID::null*/, LLPointer<LLInventoryCallback> cb/*=NULL*/)
{
std::string item_desc = avatar_id.asString();
std::string item_name;
gCacheName->getFullName(avatar_id, item_name);
LLAvatarName av_name;
LLAvatarNameCache::get(avatar_id, &av_name);
create_inventory_item(gAgent.getID(), gAgent.getSessionID(),
parent, LLTransactionID::tnull, item_name, item_desc, LLAssetType::AT_CALLINGCARD,
parent, LLTransactionID::tnull, av_name.getLegacyName(), item_desc, LLAssetType::AT_CALLINGCARD,
LLInventoryType::IT_CALLINGCARD, NOT_WEARABLE, PERM_MOVE | PERM_TRANSFER, cb);
}
@@ -1432,11 +1438,6 @@ void update_inventory_item(
const LLSD& updates,
LLPointer<LLInventoryCallback> cb)
{
//Singu Note:
// There was some rlva-specific code here, however it adversely affected serverside
// baking when using AISv3. Its omission looks likeley to be inconsequental, but if that's incorrect
// any bugs introduced by its removal are minor compared to non-functional serverside baking.
if (AISAPI::isAvailable())
{
AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1);
@@ -1466,7 +1467,6 @@ void update_inventory_item(
LLInventoryModel::LLCategoryUpdate up(new_item->getParentUUID(), 0);
gInventory.accountForUpdate(up);
gInventory.updateItem(new_item);
if (cb)
{
cb->fire(item_id);
@@ -1525,11 +1525,9 @@ void remove_inventory_items(
LLPointer<LLInventoryCallback> cb
)
{
for (LLInventoryObject::object_list_t::iterator it = items_to_kill.begin();
it != items_to_kill.end();
++it)
for (auto& it : items_to_kill)
{
remove_inventory_item(*it, cb);
remove_inventory_item(it, cb);
}
}
@@ -1603,7 +1601,7 @@ public:
mCB(cb)
{
}
/* virtual */ void fire(const LLUUID& item_id) {}
/* virtual */ void fire(const LLUUID& item_id) override {}
~LLRemoveCategoryOnDestroy()
{
LLInventoryModel::EHasChildren children = gInventory.categoryHasChildren(mID);
@@ -1629,6 +1627,10 @@ void remove_inventory_category(
LLPointer<LLViewerInventoryCategory> obj = gInventory.getCategory(cat_id);
if(obj)
{
if (!gInventory.isCategoryComplete(cat_id))
{
LL_WARNS() << "Removing (purging) incomplete category " << obj->getName() << LL_ENDL;
}
if(LLFolderType::lookupIsProtectedType(obj->getPreferredType()))
{
LLNotificationsUtil::add("CannotRemoveProtectedCategories");
@@ -1849,9 +1851,9 @@ void create_new_item(const std::string& name,
LLViewerAssetType::generateDescriptionFor(asset_type, desc);
next_owner_perm = (next_owner_perm) ? next_owner_perm : PERM_MOVE | PERM_TRANSFER;
LLPointer<LLInventoryCallback> cb = NULL;
LLPointer<LLInventoryCallback> cb = nullptr;
switch(inv_type)
switch (inv_type)
{
case LLInventoryType::IT_LSL:
{
@@ -2003,9 +2005,9 @@ void remove_folder_contents(const LLUUID& category, bool keep_outfit_links,
LLInventoryModel::item_array_t items;
gInventory.collectDescendents(category, cats, items,
LLInventoryModel::EXCLUDE_TRASH);
for (U32 i = 0; i < items.size(); ++i)
for (auto& i : items)
{
LLViewerInventoryItem *item = items.at(i);
LLViewerInventoryItem *item = i;
if (keep_outfit_links && (item->getActualType() == LLAssetType::AT_LINK_FOLDER))
continue;
if (item->getIsLinkType())
@@ -2084,7 +2086,7 @@ const std::string NEW_GESTURE_NAME = "New Gesture"; // *TODO:Translate? (probabl
}
else
{
LL_WARNS() << "Can't create unrecognized type " << type_name << LL_ENDL;
LL_WARNS(LOG_INV) << "Can't create unrecognized type " << type_name << LL_ENDL;
}
}
root->setNeedsAutoRename(TRUE);
@@ -2371,9 +2373,9 @@ PermissionMask LLViewerInventoryItem::getPermissionMask() const
//----------
void LLViewerInventoryItem::onCallingCardNameLookup(const LLUUID& id, const std::string& name, bool is_group)
void LLViewerInventoryItem::onCallingCardNameLookup(const LLUUID& id, const LLAvatarName& name)
{
rename(name);
rename(name.getLegacyName());
gInventory.addChangedMask(LLInventoryObserver::LABEL, getUUID());
gInventory.notifyObservers();
}
@@ -2382,9 +2384,10 @@ class LLRegenerateLinkCollector : public LLInventoryCollectFunctor
{
public:
LLRegenerateLinkCollector(const LLViewerInventoryItem *target_item) : mTargetItem(target_item) {}
virtual ~LLRegenerateLinkCollector() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item)
virtual ~LLRegenerateLinkCollector() = default;
bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item) override
{
if (item)
{
@@ -2412,11 +2415,8 @@ LLUUID find_possible_item_for_regeneration(const LLViewerInventoryItem *target_i
items,
LLInventoryModel::EXCLUDE_TRASH,
candidate_matches);
for (LLViewerInventoryItem::item_array_t::const_iterator item_iter = items.begin();
item_iter != items.end();
++item_iter)
for (const LLViewerInventoryItem* item : items)
{
const LLViewerInventoryItem *item = (*item_iter);
if(item)
return item->getUUID();
}
@@ -2438,11 +2438,9 @@ BOOL LLViewerInventoryItem::regenerateLink()
items,
LLInventoryModel::EXCLUDE_TRASH,
asset_id_matches);
for (LLViewerInventoryItem::item_array_t::iterator item_iter = items.begin();
item_iter != items.end();
item_iter++)
for (auto& item_iter : items)
{
LLViewerInventoryItem *item = (*item_iter);
LLViewerInventoryItem *item = item_iter;
item->setAssetUUID(target_item_id);
item->updateServer(FALSE);
gInventory.addChangedMask(LLInventoryObserver::REBUILD, item->getUUID());

View File

@@ -42,6 +42,7 @@
class LLFolderView;
class LLFolderBridge;
class LLViewerInventoryCategory;
class LLAvatarName;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLViewerInventoryItem
@@ -50,7 +51,7 @@ class LLViewerInventoryCategory;
// their inventory.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLViewerInventoryItem : public LLInventoryItem, public boost::signals2::trackable
class LLViewerInventoryItem final : public LLInventoryItem, public boost::signals2::trackable
{
public:
typedef std::vector<LLPointer<LLViewerInventoryItem> > item_array_t;
@@ -59,24 +60,24 @@ protected:
~LLViewerInventoryItem( void ); // ref counted
public:
virtual LLAssetType::EType getType() const;
virtual const LLUUID& getAssetUUID() const;
LLAssetType::EType getType() const override;
const LLUUID& getAssetUUID() const override;
virtual const LLUUID& getProtectedAssetUUID() const; // returns LLUUID::null if current agent does not have permission to expose this asset's UUID to the user
virtual const std::string& getName() const;
const std::string& getName() const override;
virtual S32 getSortField() const;
//virtual void setSortField(S32 sortField);
virtual void getSLURL(); //Caches SLURL for landmark. //*TODO: Find a better way to do it and remove this method from here.
virtual const LLPermissions& getPermissions() const;
const LLPermissions& getPermissions() const override;
virtual const bool getIsFullPerm() const; // 'fullperm' in the popular sense: modify-ok & copy-ok & transfer-ok, no special god rules applied
virtual const LLUUID& getCreatorUUID() const;
virtual const std::string& getDescription() const;
virtual const LLSaleInfo& getSaleInfo() const;
virtual LLInventoryType::EType getInventoryType() const;
const LLUUID& getCreatorUUID() const override;
const std::string& getDescription() const override;
const LLSaleInfo& getSaleInfo() const override;
LLInventoryType::EType getInventoryType() const override;
virtual bool isWearableType() const;
virtual LLWearableType::EType getWearableType() const;
virtual U32 getFlags() const;
virtual time_t getCreationDate() const;
virtual U32 getCRC32() const; // really more of a checksum.
U32 getFlags() const override;
time_t getCreationDate() const override;
U32 getCRC32() const override; // really more of a checksum.
static BOOL extractSortFieldAndDisplayName(const std::string& name, S32* sortField, std::string* displayName);
@@ -112,7 +113,7 @@ public:
LLViewerInventoryItem(const LLInventoryItem* other);
void copyViewerItem(const LLViewerInventoryItem* other);
/*virtual*/ void copyItem(const LLInventoryItem* other);
/*virtual*/ void copyItem(const LLInventoryItem* other) override;
// construct a new clone of this item - it creates a new viewer
// inventory item using the copy constructor, and returns it.
@@ -120,15 +121,15 @@ public:
void cloneViewerItem(LLPointer<LLViewerInventoryItem>& newitem) const;
// virtual methods
virtual void updateParentOnServer(BOOL restamp) const;
virtual void updateServer(BOOL is_new) const;
void updateParentOnServer(BOOL restamp) const override;
void updateServer(BOOL is_new) const override;
void fetchFromServer(void) const;
virtual void packMessage(LLMessageSystem* msg) const;
virtual BOOL unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
void packMessage(LLMessageSystem* msg) const override;
BOOL unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0) override;
virtual BOOL unpackMessage(const LLSD& item);
virtual BOOL importFile(LLFILE* fp);
virtual BOOL importLegacyStream(std::istream& input_stream);
BOOL importFile(LLFILE* fp) override;
BOOL importLegacyStream(std::istream& input_stream) override;
// file handling on the viewer. These are not meant for anything
// other than cacheing.
@@ -160,7 +161,7 @@ public:
PermissionMask getPermissionMask() const;
// callback
void onCallingCardNameLookup(const LLUUID& id, const std::string& name, bool is_group);
void onCallingCardNameLookup(const LLUUID& id, const LLAvatarName& name);
// If this is a broken link, try to fix it and any other identical link.
BOOL regenerateLink();
@@ -184,7 +185,7 @@ public:
// new ones as needed.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLViewerInventoryCategory : public LLInventoryCategory
class LLViewerInventoryCategory final : public LLInventoryCategory
{
public:
typedef std::vector<LLPointer<LLViewerInventoryCategory> > cat_array_t;
@@ -204,10 +205,10 @@ public:
LLViewerInventoryCategory(const LLViewerInventoryCategory* other);
void copyViewerCategory(const LLViewerInventoryCategory* other);
virtual void updateParentOnServer(BOOL restamp_children) const;
virtual void updateServer(BOOL is_new) const;
void updateParentOnServer(BOOL restamp_children) const override;
void updateServer(BOOL is_new) const override;
virtual void packMessage(LLMessageSystem* msg) const;
void packMessage(LLMessageSystem* msg) const override;
const LLUUID& getOwnerID() const { return mOwnerID; }
@@ -234,7 +235,7 @@ public:
bool importFileLocal(LLFILE* fp);
void determineFolderType();
void changeType(LLFolderType::EType new_folder_type);
virtual void unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0);
void unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num = 0) override;
virtual BOOL unpackMessage(const LLSD& category);
// returns true if the category object will accept the incoming item
@@ -259,37 +260,37 @@ public:
class LLViewerJointAttachment;
//void rez_attachment_cb(const LLUUID& inv_item, LLViewerJointAttachment *attachmentp);
// [SL:KB] - Patch: Appearance-DnDWear | Checked: 2010-09-28 (Catznip-3.0.0a) | Added: Catznip-2.2.0a
// [SL:KB] - Patch: Appearance-DnDWear | Checked: 2010-09-28 (Catznip-3.4)
void rez_attachment_cb(const LLUUID& inv_item, LLViewerJointAttachment *attachmentp, bool replace = false);
// [/SL:KB]
//void rez_attachment_cb(const LLUUID& inv_item, LLViewerJointAttachment *attachmentp);
void activate_gesture_cb(const LLUUID& inv_item);
void create_gesture_cb(const LLUUID& inv_item);
class AddFavoriteLandmarkCallback : public LLInventoryCallback
class AddFavoriteLandmarkCallback final : public LLInventoryCallback
{
public:
AddFavoriteLandmarkCallback() : mTargetLandmarkId(LLUUID::null) {}
void setTargetLandmarkId(const LLUUID& target_uuid) { mTargetLandmarkId = target_uuid; }
private:
void fire(const LLUUID& inv_item);
void fire(const LLUUID& inv_item) override;
LLUUID mTargetLandmarkId;
};
typedef boost::function<void(const LLUUID&)> inventory_func_type;
typedef boost::function<void(const LLSD&)> llsd_func_type;
typedef boost::function<void()> nullary_func_type;
typedef std::function<void(const LLUUID&)> inventory_func_type;
typedef std::function<void(const LLSD&)> llsd_func_type;
typedef std::function<void()> nullary_func_type;
void no_op_inventory_func(const LLUUID&); // A do-nothing inventory_func
void no_op_llsd_func(const LLSD&); // likewise for LLSD
void no_op(); // A do-nothing nullary func.
// Shim between inventory callback and boost function/callable
class LLBoostFuncInventoryCallback: public LLInventoryCallback
class LLBoostFuncInventoryCallback : public LLInventoryCallback
{
public:
@@ -301,7 +302,7 @@ public:
}
// virtual
void fire(const LLUUID& item_id)
void fire(const LLUUID& item_id) override
{
mFireFunc(item_id);
}