Updated LLInventoryModelBackgroundFetch and LLInventoryModel(code migration)

This commit is contained in:
Shyotl
2012-06-11 06:57:54 -05:00
parent 6b1f5c388f
commit 945c663359
12 changed files with 637 additions and 411 deletions

View File

@@ -957,7 +957,7 @@ void LLFolderView::draw()
else if (mShowEmptyMessage)
{
static LLCachedControl<LLColor4> sSearchStatusColor(gColors, "InventorySearchStatusColor", LLColor4::white );
if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() || mCompletedFilterGeneration < mFilter->getMinRequiredGeneration())
if (LLInventoryModelBackgroundFetch::instance().folderFetchActive() || mCompletedFilterGeneration < mFilter->getMinRequiredGeneration())
{
mStatusText = std::string("Searching..."); // *TODO:translate
}
@@ -2003,7 +2003,7 @@ void LLFolderView::scrollToShowSelection()
// However we allow scrolling for folder views with mAutoSelectOverride
// (used in Places SP) as an exception because the selection in them
// is not reset during items filtering. See STORM-133.
if ( (!LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() || mAutoSelectOverride)
if ( (!LLInventoryModelBackgroundFetch::instance().folderFetchActive() || mAutoSelectOverride)
&& mSelectedItems.size() )
{
mNeedsScroll = TRUE;

View File

@@ -1049,7 +1049,7 @@ void LLFolderViewItem::draw()
}
if ((mIsLoading
&& mTimeSinceRequestStart.getElapsedTimeF32() >= gSavedSettings.getF32("FolderLoadingMessageWaitTime"))
|| (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive()
|| (LLInventoryModelBackgroundFetch::instance().folderFetchActive()
&& root_is_loading
&& mShowLoadStatus))
{

View File

@@ -200,6 +200,42 @@ bool isMarketplaceSendAction(const std::string& action)
return ("send_to_marketplace" == action);
}
// Used by LLFolderBridge as callback for directory fetching recursion
class LLRightClickInventoryFetchDescendentsObserver : public LLInventoryFetchDescendentsObserver
{
public:
LLRightClickInventoryFetchDescendentsObserver(const uuid_vec_t& ids) : LLInventoryFetchDescendentsObserver(ids) {}
~LLRightClickInventoryFetchDescendentsObserver() {}
virtual void execute(bool clear_observer = false);
virtual void done()
{
execute(true);
}
};
// Used by LLFolderBridge as callback for directory content items fetching
class LLRightClickInventoryFetchObserver : public LLInventoryFetchItemsObserver
{
public:
LLRightClickInventoryFetchObserver(const uuid_vec_t& ids) : LLInventoryFetchItemsObserver(ids) { };
~LLRightClickInventoryFetchObserver() {}
void execute(bool clear_observer = false)
{
if (clear_observer)
{
dec_busy_count();
gInventory.removeObserver(this);
delete this;
}
// we've downloaded all the items, so repaint the dialog
LLFolderBridge::staticFolderOptionsMenu();
}
virtual void done()
{
execute(true);
}
};
// <edit>
void gotImageForSaveItemAs(BOOL success,
LLViewerTexture *src_vi,
@@ -1050,7 +1086,7 @@ void LLInvFVBridge::changeItemParent(LLInventoryModel* model,
const LLUUID& new_parent_id,
BOOL restamp)
{
change_item_parent(model, item, new_parent_id, restamp);
model->changeItemParent(item, new_parent_id, restamp);
}
// static
@@ -1059,7 +1095,7 @@ void LLInvFVBridge::changeCategoryParent(LLInventoryModel* model,
const LLUUID& new_parent_id,
BOOL restamp)
{
change_category_parent(model, cat, new_parent_id, restamp);
model->changeCategoryParent(cat, new_parent_id, restamp);
}
LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
@@ -1464,7 +1500,8 @@ void LLItemBridge::selectItem()
// <edit>
if(!(gInventory.isObjectDescendentOf(mUUID, gSystemFolderRoot)))
// </edit>
item->fetchFromServer();
//item->fetchFromServer();
LLInventoryModelBackgroundFetch::instance().start(item->getUUID(), false);
}
}
@@ -2498,9 +2535,16 @@ BOOL move_inv_category_world_to_agent(const LLUUID& object_id,
LLInventoryObject::object_list_t::iterator end = inventory_objects.end();
for ( ; it != end; ++it)
{
LLInventoryItem* item = dynamic_cast<LLInventoryItem*>(it->get());
if (!item)
{
llwarns << "Invalid inventory item for drop" << llendl;
continue;
}
// coming from a task. Need to figure out if the person can
// move/copy this item.
LLPermissions perm(((LLInventoryItem*)((LLInventoryObject*)(*it)))->getPermissions());
LLPermissions perm(item->getPermissions());
if((perm.allowCopyBy(gAgent.getID(), gAgent.getGroupID())
&& perm.allowTransferTo(gAgent.getID())))
// || gAgent.isGodlike())
@@ -2553,121 +2597,114 @@ BOOL move_inv_category_world_to_agent(const LLUUID& object_id,
return accept;
}
//Used by LLFolderBridge as callback for directory recursion.
class LLRightClickInventoryFetchObserver : public LLInventoryFetchItemsObserver
void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer)
{
public:
LLRightClickInventoryFetchObserver(const uuid_vec_t& ids) :
LLInventoryFetchItemsObserver(ids),
mCopyItems(false)
{ };
LLRightClickInventoryFetchObserver(const uuid_vec_t& ids,
const LLUUID& cat_id,
bool copy_items) :
LLInventoryFetchItemsObserver(ids),
mCatID(cat_id),
mCopyItems(copy_items)
{ };
virtual void done()
{
// we've downloaded all the items, so repaint the dialog
LLFolderBridge::staticFolderOptionsMenu();
gInventory.removeObserver(this);
delete this;
}
protected:
LLUUID mCatID;
bool mCopyItems;
};
//Used by LLFolderBridge as callback for directory recursion.
class LLRightClickInventoryFetchDescendentsObserver : public LLInventoryFetchDescendentsObserver
{
public:
LLRightClickInventoryFetchDescendentsObserver(const uuid_vec_t& ids,
bool copy_items) :
LLInventoryFetchDescendentsObserver(ids),
mCopyItems(copy_items)
{}
~LLRightClickInventoryFetchDescendentsObserver() {}
virtual void done();
protected:
bool mCopyItems;
};
void LLRightClickInventoryFetchDescendentsObserver::done()
{
// Avoid passing a NULL-ref as mCompleteFolders.front() down to
// gInventory.collectDescendents()
// Bail out immediately if no descendents
if( mComplete.empty() )
{
llwarns << "LLRightClickInventoryFetchDescendentsObserver::done with empty mCompleteFolders" << llendl;
if (clear_observer)
{
dec_busy_count();
gInventory.removeObserver(this);
delete this;
}
return;
}
// What we do here is get the complete information on the items in
// the library, and set up an observer that will wait for that to
// happen.
LLInventoryModel::cat_array_t cat_array;
LLInventoryModel::item_array_t item_array;
gInventory.collectDescendents(mComplete.front(),
cat_array,
item_array,
LLInventoryModel::EXCLUDE_TRASH);
S32 count = item_array.count();
#if 0 // HACK/TODO: Why?
// This early causes a giant menu to get produced, and doesn't seem to be needed.
if(!count)
// Copy the list of complete fetched folders while "this" is still valid
uuid_vec_t completed_folder = mComplete;
// Clean up, and remove this as an observer now since recursive calls
// could notify observers and throw us into an infinite loop.
if (clear_observer)
{
llwarns << "Nothing fetched in category " << mComplete.front()
<< llendl;
dec_busy_count();
gInventory.removeObserver(this);
delete this;
return;
}
#endif
uuid_vec_t ids;
for(S32 i = 0; i < count; ++i)
for (uuid_vec_t::iterator current_folder = completed_folder.begin(); current_folder != completed_folder.end(); ++current_folder)
{
ids.push_back(item_array.get(i)->getUUID());
// Get the information on the fetched folder items and subfolders and fetch those
LLInventoryModel::cat_array_t* cat_array;
LLInventoryModel::item_array_t* item_array;
gInventory.getDirectDescendentsOf(*current_folder, cat_array, item_array);
S32 item_count = item_array->count();
S32 cat_count = cat_array->count();
// Move to next if current folder empty
if ((item_count == 0) && (cat_count == 0))
{
continue;
}
LLRightClickInventoryFetchObserver* outfit = new LLRightClickInventoryFetchObserver(ids, mComplete.front(), mCopyItems);
uuid_vec_t ids;
LLRightClickInventoryFetchObserver* outfit = NULL;
LLRightClickInventoryFetchDescendentsObserver* categories = NULL;
// clean up, and remove this as an observer since the call to the
// outfit could notify observers and throw us into an infinite
// loop.
dec_busy_count();
gInventory.removeObserver(this);
delete this;
// Fetch the items
if (item_count)
{
for (S32 i = 0; i < item_count; ++i)
{
ids.push_back(item_array->get(i)->getUUID());
}
outfit = new LLRightClickInventoryFetchObserver(ids);
}
// Fetch the subfolders
if (cat_count)
{
for (S32 i = 0; i < cat_count; ++i)
{
ids.push_back(cat_array->get(i)->getUUID());
}
categories = new LLRightClickInventoryFetchDescendentsObserver(ids);
}
// increment busy count and either tell the inventory to check &
// call done, or add this object to the inventory for observation.
inc_busy_count();
// do the fetch
// Perform the item fetch
if (outfit)
{
outfit->startFetch();
outfit->done(); //Not interested in waiting and this will be right 99% of the time.
outfit->execute(); // Not interested in waiting and this will be right 99% of the time.
delete outfit;
//Uncomment the following code for laggy Inventory UI.
/* if(outfit->isEverythingComplete())
/*
if (outfit->isFinished())
{
// everything is already here - call done.
outfit->done();
// everything is already here - call done.
outfit->execute();
delete outfit;
}
else
{
// it's all on it's way - add an observer, and the inventory
// will call done for us when everything is here.
gInventory.addObserver(outfit);
}*/
// it's all on its way - add an observer, and the inventory
// will call done for us when everything is here.
inc_busy_count();
gInventory.addObserver(outfit);
}
*/
}
// Perform the subfolders fetch : this is where we truly recurse down the folder hierarchy
if (categories)
{
categories->startFetch();
if (categories->isFinished())
{
// everything is already here - call done.
categories->execute();
delete categories;
}
else
{
// it's all on its way - add an observer, and the inventory
// will call done for us when everything is here.
inc_busy_count();
gInventory.addObserver(categories);
}
}
}
}
@@ -2980,7 +3017,7 @@ bool LLFolderBridge::removeItemResponse(const LLSD& notification, const LLSD& re
{
// move it to the trash
LLPreview::hide(mUUID);
remove_category(getInventoryModel(), mUUID);
getInventoryModel()->removeCategory(mUUID);
return TRUE;
}
return FALSE;
@@ -3336,16 +3373,19 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
folders.push_back(category->getUUID());
sSelf = getHandle();
LLRightClickInventoryFetchDescendentsObserver* fetch = new LLRightClickInventoryFetchDescendentsObserver(folders, FALSE);
LLRightClickInventoryFetchDescendentsObserver* fetch = new LLRightClickInventoryFetchDescendentsObserver(folders);
fetch->startFetch();
inc_busy_count();
if (fetch->isFinished())
{
// Do not call execute() or done() here as if the folder is here, there's likely no point drilling down
// This saves lots of time as buildContextMenu() is called a lot
delete fetch;
buildContextMenuFolderOptions(flags);
}
else
{
// it's all on its way - add an observer, and the inventory will call done for us when everything is here.
inc_busy_count();
gInventory.addObserver(fetch);
}
}

View File

@@ -795,7 +795,7 @@ const std::string& LLInventoryFilter::getFilterText()
filtered_by_all_types = FALSE;
}
if (!LLInventoryModelBackgroundFetch::instance().backgroundFetchActive()
if (!LLInventoryModelBackgroundFetch::instance().folderFetchActive()
&& filtered_by_type
&& !filtered_by_all_types)
{

View File

@@ -110,97 +110,6 @@ void append_path(const LLUUID& id, std::string& path)
path.append(temp);
}
void change_item_parent(LLInventoryModel* model,
LLViewerInventoryItem* item,
const LLUUID& new_parent_id,
BOOL restamp)
{
// <edit>
bool send_parent_update = gInventory.isObjectDescendentOf(item->getUUID(), gInventory.getRootFolderID());
// </edit>
if(item->getParentUUID() != new_parent_id)
{
LLInventoryModel::update_list_t update;
LLInventoryModel::LLCategoryUpdate old_folder(item->getParentUUID(),-1);
update.push_back(old_folder);
LLInventoryModel::LLCategoryUpdate new_folder(new_parent_id, 1);
update.push_back(new_folder);
gInventory.accountForUpdate(update);
LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
new_item->setParent(new_parent_id);
// <edit>
if(send_parent_update)
// </edit>
new_item->updateParentOnServer(restamp);
model->updateItem(new_item);
model->notifyObservers();
}
}
void change_category_parent(LLInventoryModel* model,
LLViewerInventoryCategory* cat,
const LLUUID& new_parent_id,
BOOL restamp)
{
if (!model || !cat)
{
return;
}
// Can't move a folder into a child of itself.
if (model->isObjectDescendentOf(new_parent_id, cat->getUUID()))
{
return;
}
LLInventoryModel::update_list_t update;
LLInventoryModel::LLCategoryUpdate old_folder(cat->getParentUUID(), -1);
update.push_back(old_folder);
LLInventoryModel::LLCategoryUpdate new_folder(new_parent_id, 1);
update.push_back(new_folder);
model->accountForUpdate(update);
LLPointer<LLViewerInventoryCategory> new_cat = new LLViewerInventoryCategory(cat);
new_cat->setParent(new_parent_id);
new_cat->updateParentOnServer(restamp);
model->updateCategory(new_cat);
model->notifyObservers();
}
void remove_category(LLInventoryModel* model, const LLUUID& cat_id)
{
if (!model || !get_is_category_removable(model, cat_id))
{
return;
}
// Look for any gestures and deactivate them
LLInventoryModel::cat_array_t descendent_categories;
LLInventoryModel::item_array_t descendent_items;
gInventory.collectDescendents(cat_id, descendent_categories, descendent_items, FALSE);
for (LLInventoryModel::item_array_t::const_iterator iter = descendent_items.begin();
iter != descendent_items.end();
++iter)
{
const LLViewerInventoryItem* item = (*iter);
const LLUUID& item_id = item->getUUID();
if (item->getType() == LLAssetType::AT_GESTURE
&& LLGestureMgr::instance().isGestureActive(item_id))
{
LLGestureMgr::instance().deactivateGesture(item_id);
}
}
LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id);
if (cat)
{
const LLUUID trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH);
change_category_parent(model, cat, trash_id, TRUE);
}
}
void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::string& new_name)
{
LLViewerInventoryCategory* cat;
@@ -553,8 +462,7 @@ void move_to_outbox_cb_action(const LLSD& payload)
LLUUID parent = viitem->getParentUUID();
change_item_parent(
&gInventory,
gInventory.changeItemParent(
viitem,
dest_folder_id,
false);
@@ -581,7 +489,7 @@ void move_to_outbox_cb_action(const LLSD& payload)
if (cat_array->empty() && item_array->empty())
{
remove_category(&gInventory, parent);
gInventory.removeCategory(parent);
}
if (parent == top_level_folder)
@@ -655,7 +563,7 @@ void move_item_within_outbox(LLInventoryItem* inv_item, LLUUID dest_folder, S32
LLViewerInventoryItem * viewer_inv_item = (LLViewerInventoryItem *) inv_item;
change_item_parent(&gInventory,
gInventory.changeItemParent(
viewer_inv_item,
dest_folder,
false);
@@ -976,20 +884,24 @@ void LLSaveFolderState::setApply(BOOL apply)
void LLSaveFolderState::doFolder(LLFolderViewFolder* folder)
{
LLInvFVBridge* bridge = (LLInvFVBridge*)folder->getListener();
if(!bridge) return;
if(mApply)
{
// we're applying the open state
LLInvFVBridge* bridge = (LLInvFVBridge*)folder->getListener();
if(!bridge) return;
LLUUID id(bridge->getUUID());
if(mOpenFolders.find(id) != mOpenFolders.end())
{
folder->setOpen(TRUE);
if (!folder->isOpen())
{
folder->setOpen(TRUE);
}
}
else
{
// keep selected filter in its current state, this is less jarring to user
if (!folder->isSelected())
if (!folder->isSelected() && folder->isOpen())
{
folder->setOpen(FALSE);
}
@@ -1000,8 +912,6 @@ void LLSaveFolderState::doFolder(LLFolderViewFolder* folder)
// we're recording state at this point
if(folder->isOpen())
{
LLInvFVBridge* bridge = (LLInvFVBridge*)folder->getListener();
if(!bridge) return;
mOpenFolders.insert(bridge->getUUID());
}
}

View File

@@ -55,17 +55,6 @@ BOOL get_is_category_renameable(const LLInventoryModel* model, const LLUUID& id)
void show_item_profile(const LLUUID& item_uuid);
void change_item_parent(LLInventoryModel* model,
LLViewerInventoryItem* item,
const LLUUID& new_parent_id,
BOOL restamp);
void change_category_parent(LLInventoryModel* model,
LLViewerInventoryCategory* cat,
const LLUUID& new_parent_id,
BOOL restamp);
void remove_category(LLInventoryModel* model, const LLUUID& cat_id);
void rename_category(LLInventoryModel* model, const LLUUID& cat_id, const std::string& new_name);
// Generates a string containing the path to the item specified by item_id.

View File

@@ -46,6 +46,8 @@
#include "llviewerregion.h"
#include "llcallbacklist.h"
#include "llvoavatarself.h"
#include "llgesturemgr.h"
#include <typeinfo>
#include "statemachine/aievent.h"
// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1a)
@@ -1080,6 +1082,72 @@ void LLInventoryModel::moveObject(const LLUUID& object_id, const LLUUID& cat_id)
}
}
// Migrated from llinventoryfunctions
void LLInventoryModel::changeItemParent(LLViewerInventoryItem* item,
const LLUUID& new_parent_id,
BOOL restamp)
{
// <edit>
bool send_parent_update = gInventory.isObjectDescendentOf(item->getUUID(), gInventory.getRootFolderID());
// </edit>
if (item->getParentUUID() == new_parent_id)
{
LL_DEBUGS("Inventory") << "'" << item->getName() << "' (" << item->getUUID()
<< ") is already in folder " << new_parent_id << LL_ENDL;
}
else
{
LL_INFOS("Inventory") << "Moving '" << item->getName() << "' (" << item->getUUID()
<< ") from " << item->getParentUUID() << " to folder "
<< new_parent_id << LL_ENDL;
LLInventoryModel::update_list_t update;
LLInventoryModel::LLCategoryUpdate old_folder(item->getParentUUID(),-1);
update.push_back(old_folder);
LLInventoryModel::LLCategoryUpdate new_folder(new_parent_id, 1);
update.push_back(new_folder);
accountForUpdate(update);
LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
new_item->setParent(new_parent_id);
// <edit>
if(send_parent_update)
// </edit>
new_item->updateParentOnServer(restamp);
updateItem(new_item);
notifyObservers();
}
}
// Migrated from llinventoryfunctions
void LLInventoryModel::changeCategoryParent(LLViewerInventoryCategory* cat,
const LLUUID& new_parent_id,
BOOL restamp)
{
if (!cat)
{
return;
}
// Can't move a folder into a child of itself.
if (isObjectDescendentOf(new_parent_id, cat->getUUID()))
{
return;
}
LLInventoryModel::update_list_t update;
LLInventoryModel::LLCategoryUpdate old_folder(cat->getParentUUID(), -1);
update.push_back(old_folder);
LLInventoryModel::LLCategoryUpdate new_folder(new_parent_id, 1);
update.push_back(new_folder);
accountForUpdate(update);
LLPointer<LLViewerInventoryCategory> new_cat = new LLViewerInventoryCategory(cat);
new_cat->setParent(new_parent_id);
new_cat->updateParentOnServer(restamp);
updateCategory(new_cat);
notifyObservers();
}
// Delete a particular inventory object by ID.
void LLInventoryModel::deleteObject(const LLUUID& id)
{
@@ -1208,13 +1276,12 @@ void LLInventoryModel::purgeDescendentsOf(const LLUUID& id)
items,
INCLUDE_TRASH);
S32 count = items.count();
S32 i;
for(i = 0; i < count; ++i)
for(S32 i = 0; i < count; ++i)
{
deleteObject(items.get(i)->getUUID());
}
count = categories.count();
for(i = 0; i < count; ++i)
for(S32 i = 0; i < count; ++i)
{
deleteObject(categories.get(i)->getUUID());
}
@@ -1729,6 +1796,7 @@ bool LLInventoryModel::loadSkeleton(
update_map_t child_counts;
cat_array_t categories;
item_array_t items;
item_array_t possible_broken_links;
cat_set_t invalid_categories; // Used to mark categories that weren't successfully loaded.
std::string owner_id_str;
owner_id.toString(owner_id_str);
@@ -1815,6 +1883,8 @@ bool LLInventoryModel::loadSkeleton(
// Add all the items loaded which are parented to a
// category with a correctly cached parent
S32 bad_link_count = 0;
S32 good_link_count = 0;
S32 recovered_link_count = 0;
cat_map_t::iterator unparented = mCategoryMap.end();
for(item_array_t::const_iterator item_iter = items.begin();
item_iter != items.end();
@@ -1831,26 +1901,56 @@ bool LLInventoryModel::loadSkeleton(
// This can happen if the linked object's baseobj is removed from the cache but the linked object is still in the cache.
if (item->getIsBrokenLink())
{
bad_link_count++;
//bad_link_count++;
lldebugs << "Attempted to add cached link item without baseobj present ( name: "
<< item->getName() << " itemID: " << item->getUUID()
<< " assetID: " << item->getAssetUUID()
<< " ). Ignoring and invalidating " << cat->getName() << " . " << llendl;
invalid_categories.insert(cit->second);
possible_broken_links.push_back(item);
continue;
}
else if (item->getIsLinkType())
{
good_link_count++;
}
addItem(item);
cached_item_count += 1;
++child_counts[cat->getUUID()];
}
}
}
if (bad_link_count > 0)
if (possible_broken_links.size() > 0)
{
llinfos << "Attempted to add " << bad_link_count
<< " cached link items without baseobj present. "
<< "The corresponding categories were invalidated." << llendl;
for(item_array_t::const_iterator item_iter = possible_broken_links.begin();
item_iter != possible_broken_links.end();
++item_iter)
{
LLViewerInventoryItem *item = (*item_iter).get();
const cat_map_t::iterator cit = mCategoryMap.find(item->getParentUUID());
const LLViewerInventoryCategory* cat = cit->second.get();
if (item->getIsBrokenLink())
{
bad_link_count++;
invalid_categories.insert(cit->second);
//llinfos << "link still broken: " << item->getName() << " in folder " << cat->getName() << llendl;
}
else
{
// was marked as broken because of loading order, its actually fine to load
addItem(item);
cached_item_count += 1;
++child_counts[cat->getUUID()];
recovered_link_count++;
}
}
llinfos << "Attempted to add " << bad_link_count
<< " cached link items without baseobj present. "
<< good_link_count << " link items were successfully added. "
<< recovered_link_count << " links added in recovery. "
<< "The corresponding categories were invalidated." << llendl;
}
}
else
{
@@ -3099,27 +3199,62 @@ void LLInventoryModel::emptyFolderType(const std::string notification, LLFolderT
notifyObservers();
}
}
//----------------------------------------------------------------------------
void LLInventoryModel::removeItem(const LLUUID& item_id)
{
LLViewerInventoryItem* item = getItem(item_id);
const LLUUID new_parent = findCategoryUUIDForType(LLFolderType::FT_TRASH);
if(item && new_parent.notNull() && item->getParentUUID() != new_parent)
if (! item)
{
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();
LL_WARNS("Inventory") << "couldn't find inventory item " << item_id << LL_ENDL;
}
else
{
const LLUUID new_parent = findCategoryUUIDForType(LLFolderType::FT_TRASH);
if (new_parent.notNull())
{
LL_INFOS("Inventory") << "Moving to Trash (" << new_parent << "):" << LL_ENDL;
changeItemParent(item, new_parent, TRUE);
}
}
}
void LLInventoryModel::removeCategory(const LLUUID& category_id)
{
if (! get_is_category_removable(this, category_id))
{
return;
}
// Look for any gestures and deactivate them
LLInventoryModel::cat_array_t descendent_categories;
LLInventoryModel::item_array_t descendent_items;
collectDescendents(category_id, descendent_categories, descendent_items, FALSE);
for (LLInventoryModel::item_array_t::const_iterator iter = descendent_items.begin();
iter != descendent_items.end();
++iter)
{
const LLViewerInventoryItem* item = (*iter);
const LLUUID& item_id = item->getUUID();
if (item->getType() == LLAssetType::AT_GESTURE
&& LLGestureMgr::instance().isGestureActive(item_id))
{
LLGestureMgr::instance().deactivateGesture(item_id);
}
}
LLViewerInventoryCategory* cat = getCategory(category_id);
if (cat)
{
const LLUUID trash_id = findCategoryUUIDForType(LLFolderType::FT_TRASH);
if (trash_id.notNull())
{
changeCategoryParent(cat, trash_id, TRUE);
}
}
}
const LLUUID &LLInventoryModel::getRootFolderID() const
{
return mRootFolderID;

View File

@@ -316,6 +316,16 @@ public:
// observer notification, or server update is performed.
void moveObject(const LLUUID& object_id, const LLUUID& cat_id);
// Migrated from llinventoryfunctions
void changeItemParent(LLViewerInventoryItem* item,
const LLUUID& new_parent_id,
BOOL restamp);
// Migrated from llinventoryfunctions
void changeCategoryParent(LLViewerInventoryCategory* cat,
const LLUUID& new_parent_id,
BOOL restamp);
//--------------------------------------------------------------------
// Delete
//--------------------------------------------------------------------
@@ -325,8 +335,13 @@ public:
// consistent internal state. No cache accounting, observer
// notification, or server update is performed.
void deleteObject(const LLUUID& id);
/// move Item item_id to Trash
void removeItem(const LLUUID& item_id);
/// move Category category_id to Trash
void removeCategory(const LLUUID& category_id);
/// removeItem() or removeCategory(), whichever is appropriate
void removeObject(const LLUUID& object_id);
// Delete a particular inventory object by ID, and delete it from
// the server. Also updates linked items.
void purgeObject(const LLUUID& id);

View File

@@ -43,6 +43,7 @@ const S32 MAX_FETCH_RETRIES = 10;
LLInventoryModelBackgroundFetch::LLInventoryModelBackgroundFetch() :
mBackgroundFetchActive(FALSE),
mFolderFetchActive(false),
mAllFoldersFetched(FALSE),
mRecursiveInventoryFetchStarted(FALSE),
mRecursiveLibraryFetchStarted(FALSE),
@@ -50,7 +51,7 @@ LLInventoryModelBackgroundFetch::LLInventoryModelBackgroundFetch() :
mMinTimeBetweenFetches(0.3f),
mMaxTimeBetweenFetches(10.f),
mTimelyFetchPending(FALSE),
mBulkFetchCount(0)
mFetchCount(0)
{
}
@@ -60,7 +61,7 @@ LLInventoryModelBackgroundFetch::~LLInventoryModelBackgroundFetch()
bool LLInventoryModelBackgroundFetch::isBulkFetchProcessingComplete() const
{
return mFetchQueue.empty() && mBulkFetchCount<=0;
return mFetchQueue.empty() && mFetchCount<=0;
}
bool LLInventoryModelBackgroundFetch::libraryFetchStarted() const
@@ -98,19 +99,21 @@ bool LLInventoryModelBackgroundFetch::isEverythingFetched() const
return mAllFoldersFetched;
}
BOOL LLInventoryModelBackgroundFetch::backgroundFetchActive() const
BOOL LLInventoryModelBackgroundFetch::folderFetchActive() const
{
return mBackgroundFetchActive;
return mFolderFetchActive;
}
void LLInventoryModelBackgroundFetch::start(const LLUUID& cat_id, BOOL recursive)
void LLInventoryModelBackgroundFetch::start(const LLUUID& id, BOOL recursive)
{
if (!mAllFoldersFetched || cat_id.notNull())
{
LL_DEBUGS("InventoryFetch") << "Start fetching category: " << cat_id << ", recursive: " << recursive << LL_ENDL;
LLViewerInventoryCategory* cat = gInventory.getCategory(id);
if (cat || (id.isNull() && !isEverythingFetched()))
{ // it's a folder, do a bulk fetch
LL_DEBUGS("InventoryFetch") << "Start fetching category: " << id << ", recursive: " << recursive << LL_ENDL;
mBackgroundFetchActive = TRUE;
if (cat_id.isNull())
mFolderFetchActive = true;
if (id.isNull())
{
if (!mRecursiveInventoryFetchStarted)
{
@@ -128,42 +131,41 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& cat_id, BOOL recursive
else
{
// Specific folder requests go to front of queue.
if (mFetchQueue.empty() || mFetchQueue.front().mCatUUID != cat_id)
if (mFetchQueue.empty() || mFetchQueue.front().mUUID != id)
{
mFetchQueue.push_front(FetchQueueInfo(cat_id, recursive));
mFetchQueue.push_front(FetchQueueInfo(id, recursive));
gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
}
if (cat_id == gInventory.getLibraryRootFolderID())
if (id == gInventory.getLibraryRootFolderID())
{
mRecursiveLibraryFetchStarted |= recursive;
}
if (cat_id == gInventory.getRootFolderID())
if (id == gInventory.getRootFolderID())
{
mRecursiveInventoryFetchStarted |= recursive;
}
}
}
else if (LLViewerInventoryItem* itemp = gInventory.getItem(id))
{
if (!itemp->mIsComplete && (mFetchQueue.empty() || mFetchQueue.front().mUUID != id))
{
mBackgroundFetchActive = TRUE;
mFetchQueue.push_front(FetchQueueInfo(id, false, false));
gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
}
}
}
//static
void LLInventoryModelBackgroundFetch::findLostItems()
{
mBackgroundFetchActive = TRUE;
mFolderFetchActive = true;
mFetchQueue.push_back(FetchQueueInfo(LLUUID::null, TRUE));
gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
}
void LLInventoryModelBackgroundFetch::stopBackgroundFetch()
{
if (mBackgroundFetchActive)
{
mBackgroundFetchActive = FALSE;
gIdleCallbacks.deleteFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
mBulkFetchCount=0;
mMinTimeBetweenFetches=0.0f;
}
}
void LLInventoryModelBackgroundFetch::setAllFoldersFetched()
{
if (mRecursiveInventoryFetchStarted &&
@@ -171,7 +173,7 @@ void LLInventoryModelBackgroundFetch::setAllFoldersFetched()
{
mAllFoldersFetched = TRUE;
}
stopBackgroundFetch();
mFolderFetchActive = false;
}
void LLInventoryModelBackgroundFetch::backgroundFetchCB(void *)
@@ -185,10 +187,9 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
if (mBackgroundFetchActive && gAgent.getRegion())
{
// If we'll be using the capability, we'll be sending batches and the background thing isn't as important.
std::string url = gAgent.getRegion()->getCapability("FetchInventoryDescendents2");
if (gSavedSettings.getBOOL("UseHTTPInventory") && !url.empty())
if (gSavedSettings.getBOOL("UseHTTPInventory"))
{
bulkFetch(url);
bulkFetch();
return;
}
@@ -203,6 +204,9 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
llinfos << "Inventory fetch completed" << llendl;
setAllFoldersFetched();
mBackgroundFetchActive = false;
mFolderFetchActive = false;
return;
}
@@ -232,79 +236,113 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
}
const FetchQueueInfo info = mFetchQueue.front();
LLViewerInventoryCategory* cat = gInventory.getCategory(info.mCatUUID);
// category has been deleted, remove from queue.
if (!cat)
if (info.mIsCategory)
{
mFetchQueue.pop_front();
continue;
}
if (mFetchTimer.getElapsedTimeF32() > mMinTimeBetweenFetches &&
LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion())
{
// category exists but has no children yet, fetch the descendants
// for now, just request every time and rely on retry timer to throttle
if (cat->fetch())
LLViewerInventoryCategory* cat = gInventory.getCategory(info.mUUID);
// Category has been deleted, remove from queue.
if (!cat)
{
mFetchQueue.pop_front();
continue;
}
if (mFetchTimer.getElapsedTimeF32() > mMinTimeBetweenFetches &&
LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion())
{
// Category exists but has no children yet, fetch the descendants
// for now, just request every time and rely on retry timer to throttle.
if (cat->fetch())
{
mFetchTimer.reset();
mTimelyFetchPending = TRUE;
}
else
{
// The catagory also tracks if it has expired and here it says it hasn't
// yet. Get out of here because nothing is going to happen until we
// update the timers.
break;
}
}
// Do I have all my children?
else if (gInventory.isCategoryComplete(info.mUUID))
{
// Finished with this category, remove from queue.
mFetchQueue.pop_front();
// Add all children to queue.
LLInventoryModel::cat_array_t* categories;
gInventory.getDirectDescendentsOf(cat->getUUID(), categories);
for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin();
it != categories->end();
++it)
{
mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(),info.mRecursive));
}
// We received a response in less than the fast time.
if (mTimelyFetchPending && mFetchTimer.getElapsedTimeF32() < fast_fetch_time)
{
// Shrink timeouts based on success.
mMinTimeBetweenFetches = llmax(mMinTimeBetweenFetches * 0.8f, 0.3f);
mMaxTimeBetweenFetches = llmax(mMaxTimeBetweenFetches * 0.8f, 10.f);
lldebugs << "Inventory fetch times shrunk to (" << mMinTimeBetweenFetches << ", " << mMaxTimeBetweenFetches << ")" << llendl;
}
mTimelyFetchPending = FALSE;
continue;
}
else if (mFetchTimer.getElapsedTimeF32() > mMaxTimeBetweenFetches)
{
// Received first packet, but our num descendants does not match db's num descendants
// so try again later.
mFetchQueue.pop_front();
if (mNumFetchRetries++ < MAX_FETCH_RETRIES)
{
// push on back of queue
mFetchQueue.push_back(info);
}
mTimelyFetchPending = FALSE;
mFetchTimer.reset();
break;
}
// Not enough time has elapsed to do a new fetch
break;
}
else
{
LLViewerInventoryItem* itemp = gInventory.getItem(info.mUUID);
mFetchQueue.pop_front();
if (!itemp)
{
continue;
}
if (mFetchTimer.getElapsedTimeF32() > mMinTimeBetweenFetches)
{
itemp->fetchFromServer();
mFetchTimer.reset();
mTimelyFetchPending = TRUE;
}
else
else if (itemp->mIsComplete)
{
// The catagory also tracks if it has expired and here it says it hasn't
// yet. Get out of here because nothing is going to happen until we
// update the timers.
break;
mTimelyFetchPending = FALSE;
}
}
// do I have all my children?
else if (gInventory.isCategoryComplete(info.mCatUUID))
{
// finished with this category, remove from queue
mFetchQueue.pop_front();
// Add all children to queue.
LLInventoryModel::cat_array_t* categories;
gInventory.getDirectDescendentsOf(cat->getUUID(), categories);
for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin();
it != categories->end();
++it)
else if (mFetchTimer.getElapsedTimeF32() > mMaxTimeBetweenFetches)
{
mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(),info.mRecursive));
}
// we received a response in less than the fast time
if (mTimelyFetchPending && mFetchTimer.getElapsedTimeF32() < fast_fetch_time)
{
// shrink timeouts based on success
mMinTimeBetweenFetches = llmax(mMinTimeBetweenFetches * 0.8f, 0.3f);
mMaxTimeBetweenFetches = llmax(mMaxTimeBetweenFetches * 0.8f, 10.f);
lldebugs << "Inventory fetch times shrunk to (" << mMinTimeBetweenFetches << ", " << mMaxTimeBetweenFetches << ")" << llendl;
}
mTimelyFetchPending = FALSE;
continue;
}
else if (mFetchTimer.getElapsedTimeF32() > mMaxTimeBetweenFetches)
{
// received first packet, but our num descendants does not match db's num descendants
// so try again later.
mFetchQueue.pop_front();
if (mNumFetchRetries++ < MAX_FETCH_RETRIES)
{
// push on back of queue
mFetchQueue.push_back(info);
mFetchTimer.reset();
mTimelyFetchPending = FALSE;
}
mTimelyFetchPending = FALSE;
mFetchTimer.reset();
// Not enough time has elapsed to do a new fetch
break;
}
// not enough time has elapsed to do a new fetch
break;
}
//
@@ -314,15 +352,35 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
}
}
void LLInventoryModelBackgroundFetch::incrBulkFetch(S16 fetching)
void LLInventoryModelBackgroundFetch::incrFetchCount(S16 fetching)
{
mBulkFetchCount += fetching;
if (mBulkFetchCount < 0)
mFetchCount += fetching;
if (mFetchCount < 0)
{
mBulkFetchCount = 0;
mFetchCount = 0;
}
}
class LLInventoryModelFetchItemResponder : public LLInventoryModel::fetchInventoryResponder
{
public:
LLInventoryModelFetchItemResponder(const LLSD& request_sd) : LLInventoryModel::fetchInventoryResponder(request_sd) {};
void result(const LLSD& content);
void error(U32 status, const std::string& reason);
};
void LLInventoryModelFetchItemResponder::result( const LLSD& content )
{
LLInventoryModel::fetchInventoryResponder::result(content);
LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1);
}
void LLInventoryModelFetchItemResponder::error( U32 status, const std::string& reason )
{
LLInventoryModel::fetchInventoryResponder::error(status, reason);
LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1);
}
class LLInventoryModelFetchDescendentsResponder: public LLHTTPClient::Responder
{
@@ -459,7 +517,7 @@ void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
}
}
fetcher->incrBulkFetch(-1);
fetcher->incrFetchCount(-1);
if (fetcher->isBulkFetchProcessingComplete())
{
@@ -478,9 +536,9 @@ void LLInventoryModelFetchDescendentsResponder::error(U32 status, const std::str
llinfos << "LLInventoryModelFetchDescendentsResponder::error "
<< status << ": " << reason << llendl;
fetcher->incrBulkFetch(-1);
fetcher->incrFetchCount(-1);
if (status==499) //timed out. Let's be awesome!
if (status==499) // timed out
{
for(LLSD::array_const_iterator folder_it = mRequestSD["folders"].beginArray();
folder_it != mRequestSD["folders"].endArray();
@@ -509,27 +567,29 @@ BOOL LLInventoryModelFetchDescendentsResponder::getIsRecursive(const LLUUID& cat
// Bundle up a bunch of requests to send all at once.
// static
void LLInventoryModelBackgroundFetch::bulkFetch(std::string url)
void LLInventoryModelBackgroundFetch::bulkFetch()
{
//Background fetch is called from gIdleCallbacks in a loop until background fetch is stopped.
//If there are items in sFetchQueue, we want to check the time since the last bulkFetch was
//If there are items in mFetchQueue, we want to check the time since the last bulkFetch was
//sent. If it exceeds our retry time, go ahead and fire off another batch.
//Stopbackgroundfetch will be run from the Responder instead of here.
LLViewerRegion* region = gAgent.getRegion();
if (!region) return;
S16 max_concurrent_fetches=8;
F32 new_min_time = 0.5f; //HACK! Clean this up when old code goes away entirely.
if (mMinTimeBetweenFetches < new_min_time)
if (mMinTimeBetweenFetches < new_min_time)
{
mMinTimeBetweenFetches=new_min_time; //HACK! See above.
}
if (gDisconnected ||
(mBulkFetchCount > max_concurrent_fetches) ||
(mFetchCount > max_concurrent_fetches) ||
(mFetchTimer.getElapsedTimeF32() < mMinTimeBetweenFetches))
{
return; // just bail if we are disconnected.
return; // just bail if we are disconnected
}
U32 item_count=0;
U32 folder_count=0;
U32 max_batch_size=5;
@@ -537,86 +597,163 @@ void LLInventoryModelBackgroundFetch::bulkFetch(std::string url)
uuid_vec_t recursive_cats;
LLSD body;
LLSD body_lib;
LLSD folder_request_body;
LLSD folder_request_body_lib;
LLSD item_request_body;
LLSD item_request_body_lib;
while( !(mFetchQueue.empty() ) && (folder_count < max_batch_size) )
while (!mFetchQueue.empty()
&& (item_count + folder_count) < max_batch_size)
{
const FetchQueueInfo& fetch_info = mFetchQueue.front();
const LLUUID &cat_id = fetch_info.mCatUUID;
if (cat_id.isNull()) //DEV-17797
{
LLSD folder_sd;
folder_sd["folder_id"] = LLUUID::null.asString();
folder_sd["owner_id"] = gAgent.getID();
folder_sd["sort_order"] = (LLSD::Integer)sort_order;
folder_sd["fetch_folders"] = (LLSD::Boolean)FALSE;
folder_sd["fetch_items"] = (LLSD::Boolean)TRUE;
body["folders"].append(folder_sd);
folder_count++;
}
else
{
LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id);
if (fetch_info.mIsCategory)
{
const LLUUID &cat_id = fetch_info.mUUID;
if (cat_id.isNull()) //DEV-17797
{
LLSD folder_sd;
folder_sd["folder_id"] = LLUUID::null.asString();
folder_sd["owner_id"] = gAgent.getID();
folder_sd["sort_order"] = (LLSD::Integer)sort_order;
folder_sd["fetch_folders"] = (LLSD::Boolean)FALSE;
folder_sd["fetch_items"] = (LLSD::Boolean)TRUE;
folder_request_body["folders"].append(folder_sd);
folder_count++;
}
else
{
const LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id);
if (cat)
{
if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion())
{
LLSD folder_sd;
folder_sd["folder_id"] = cat->getUUID();
folder_sd["owner_id"] = cat->getOwnerID();
folder_sd["sort_order"] = (LLSD::Integer)sort_order;
folder_sd["fetch_folders"] = TRUE; //(LLSD::Boolean)sFullFetchStarted;
folder_sd["fetch_items"] = (LLSD::Boolean)TRUE;
if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID())
body_lib["folders"].append(folder_sd);
else
body["folders"].append(folder_sd);
folder_count++;
}
// May already have this folder, but append child folders to list.
if (fetch_info.mRecursive)
{
LLInventoryModel::cat_array_t* categories;
gInventory.getDirectDescendentsOf(cat->getUUID(), categories);
for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin();
it != categories->end();
++it)
if (cat)
{
if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion())
{
mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive));
}
}
}
}
if (fetch_info.mRecursive)
recursive_cats.push_back(cat_id);
LLSD folder_sd;
folder_sd["folder_id"] = cat->getUUID();
folder_sd["owner_id"] = cat->getOwnerID();
folder_sd["sort_order"] = (LLSD::Integer)sort_order;
folder_sd["fetch_folders"] = TRUE; //(LLSD::Boolean)sFullFetchStarted;
folder_sd["fetch_items"] = (LLSD::Boolean)TRUE;
if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID())
folder_request_body_lib["folders"].append(folder_sd);
else
folder_request_body["folders"].append(folder_sd);
folder_count++;
}
// May already have this folder, but append child folders to list.
if (fetch_info.mRecursive)
{
LLInventoryModel::cat_array_t* categories;
LLInventoryModel::item_array_t* items;
gInventory.getDirectDescendentsOf(cat->getUUID(), categories, items);
for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin();
it != categories->end();
++it)
{
mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive));
}
}
}
}
if (fetch_info.mRecursive)
recursive_cats.push_back(cat_id);
}
else
{
LLViewerInventoryItem* itemp = gInventory.getItem(fetch_info.mUUID);
if (itemp)
{
LLSD item_sd;
item_sd["owner_id"] = itemp->getPermissions().getOwner();
item_sd["item_id"] = itemp->getUUID();
if (itemp->getPermissions().getOwner() == gAgent.getID())
{
item_request_body.append(item_sd);
}
else
{
item_request_body_lib.append(item_sd);
}
//itemp->fetchFromServer();
item_count++;
}
}
mFetchQueue.pop_front();
}
if (folder_count > 0)
if (item_count + folder_count > 0)
{
mBulkFetchCount++;
if (body["folders"].size())
if (folder_count)
{
LLInventoryModelFetchDescendentsResponder *fetcher = new LLInventoryModelFetchDescendentsResponder(body, recursive_cats);
LLHTTPClient::post(url, body, fetcher, 300.0);
std::string url = region->getCapability("FetchInventoryDescendents2");
mFetchCount++;
if (folder_request_body["folders"].size())
{
LLInventoryModelFetchDescendentsResponder *fetcher = new LLInventoryModelFetchDescendentsResponder(folder_request_body, recursive_cats);
LLHTTPClient::post(url, folder_request_body, fetcher, 300.0);
}
if (folder_request_body_lib["folders"].size())
{
std::string url_lib = gAgent.getRegion()->getCapability("FetchLibDescendents2");
LLInventoryModelFetchDescendentsResponder *fetcher = new LLInventoryModelFetchDescendentsResponder(folder_request_body_lib, recursive_cats);
LLHTTPClient::post(url_lib, folder_request_body_lib, fetcher, 300.0);
}
}
if (body_lib["folders"].size())
if (item_count)
{
std::string url_lib = gAgent.getRegion()->getCapability("FetchLibDescendents2");
LLInventoryModelFetchDescendentsResponder *fetcher = new LLInventoryModelFetchDescendentsResponder(body_lib, recursive_cats);
LLHTTPClient::post(url_lib, body_lib, fetcher, 300.0);
std::string url;
if (item_request_body.size())
{
mFetchCount++;
url = region->getCapability("FetchInventory2");
if (!url.empty())
{
LLSD body;
body["agent_id"] = gAgent.getID();
body["items"] = item_request_body;
LLHTTPClient::post(url, body, new LLInventoryModelFetchItemResponder(body));
}
//else
//{
// LLMessageSystem* msg = gMessageSystem;
// msg->newMessage("FetchInventory");
// msg->nextBlock("AgentData");
// msg->addUUID("AgentID", gAgent.getID());
// msg->addUUID("SessionID", gAgent.getSessionID());
// msg->nextBlock("InventoryData");
// msg->addUUID("OwnerID", mPermissions.getOwner());
// msg->addUUID("ItemID", mUUID);
// gAgent.sendReliableMessage();
//}
}
if (item_request_body_lib.size())
{
mFetchCount++;
url = region->getCapability("FetchLib2");
if (!url.empty())
{
LLSD body;
body["agent_id"] = gAgent.getID();
body["items"] = item_request_body_lib;
LLHTTPClient::post(url, body, new LLInventoryModelFetchItemResponder(body));
}
}
}
mFetchTimer.reset();
}
else if (isBulkFetchProcessingComplete())
{
setAllFoldersFetched();
}
}
}
bool LLInventoryModelBackgroundFetch::fetchQueueContainsNoDescendentsOf(const LLUUID& cat_id) const
@@ -624,7 +761,7 @@ bool LLInventoryModelBackgroundFetch::fetchQueueContainsNoDescendentsOf(const LL
for (fetch_queue_t::const_iterator it = mFetchQueue.begin();
it != mFetchQueue.end(); ++it)
{
const LLUUID& fetch_id = (*it).mCatUUID;
const LLUUID& fetch_id = (*it).mUUID;
if (gInventory.isObjectDescendentOf(fetch_id, cat_id))
return false;
}

View File

@@ -48,7 +48,7 @@ public:
// This gets triggered when performing a filter-search.
void start(const LLUUID& cat_id = LLUUID::null, BOOL recursive = TRUE);
BOOL backgroundFetchActive() const;
BOOL folderFetchActive() const;
bool isEverythingFetched() const; // completing the fetch once per session should be sufficient
bool libraryFetchStarted() const;
@@ -60,14 +60,13 @@ public:
bool inventoryFetchInProgress() const;
void findLostItems();
void incrFetchCount(S16 fetching);
protected:
void incrBulkFetch(S16 fetching);
bool isBulkFetchProcessingComplete() const;
void bulkFetch(std::string url);
void bulkFetch();
void backgroundFetch();
static void backgroundFetchCB(void*); // background fetch idle function
void stopBackgroundFetch(); // stop fetch process
void setAllFoldersFetched();
bool fetchQueueContainsNoDescendentsOf(const LLUUID& cat_id) const;
@@ -77,7 +76,8 @@ private:
BOOL mAllFoldersFetched;
BOOL mBackgroundFetchActive;
S16 mBulkFetchCount;
bool mFolderFetchActive;
S16 mFetchCount;
BOOL mTimelyFetchPending;
S32 mNumFetchRetries;
@@ -87,11 +87,11 @@ private:
struct FetchQueueInfo
{
FetchQueueInfo(const LLUUID& id, BOOL recursive) :
mCatUUID(id), mRecursive(recursive)
{
}
LLUUID mCatUUID;
FetchQueueInfo(const LLUUID& id, BOOL recursive, bool is_category = true) :
mUUID(id), mRecursive(recursive), mIsCategory(is_category)
{}
LLUUID mUUID;
bool mIsCategory;
BOOL mRecursive;
};
typedef std::deque<FetchQueueInfo> fetch_queue_t;

View File

@@ -841,7 +841,7 @@ BOOL LLInventoryPanel::handleHover(S32 x, S32 y, MASK mask)
if(handled)
{
ECursorType cursor = getWindow()->getCursor();
if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() && cursor == UI_CURSOR_ARROW)
if (LLInventoryModelBackgroundFetch::instance().folderFetchActive() && cursor == UI_CURSOR_ARROW)
{
// replace arrow cursor with arrow and hourglass cursor
getWindow()->setCursor(UI_CURSOR_WORKING);

View File

@@ -862,7 +862,7 @@ void LLInventoryView::updateItemcountText()
{
std::ostringstream title;
title << "Inventory";
if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive())
if (LLInventoryModelBackgroundFetch::instance().folderFetchActive())
{
LLLocale locale(LLLocale::USER_LOCALE);
std::string item_count_string;