Merge branch 'master' of git://github.com/Shyotl/SingularityViewer

This commit is contained in:
Lirusaito
2012-01-12 23:39:16 -05:00
37 changed files with 1915 additions and 1554 deletions

View File

@@ -290,8 +290,10 @@ set(viewer_SOURCE_FILES
llinventorybackup.cpp
llinventorybridge.cpp
llinventoryclipboard.cpp
llinventoryfunctions.cpp
llinventoryicon.cpp
llinventorymodel.cpp
llinventoryobserver.cpp
llinventoryview.cpp
lljoystickbutton.cpp
lllandmarklist.cpp
@@ -759,8 +761,10 @@ set(viewer_HEADER_FILES
llinventorybackup.h
llinventorybridge.h
llinventoryclipboard.h
llinventoryfunctions.h
llinventoryicon.h
llinventorymodel.h
llinventoryobserver.h
llinventoryview.h
lljoystickbutton.h
lllandmarklist.h

View File

@@ -20,6 +20,8 @@
#include "llagentwearables.h"
#include "llcommonutils.h"
#include "llerror.h"
#include "llinventoryfunctions.h"
#include "llinventoryobserver.h"
#include "llvoavatarself.h"
#include "rlvviewer2.h"

View File

@@ -25,6 +25,7 @@
#include "llfirstuse.h"
#include "llinventory.h"
#include "llinventoryfunctions.h"
#include "llinventoryview.h"
#include "roles_constants.h"
#include "llviewerregion.h"

View File

@@ -52,7 +52,8 @@
#include "llsliderctrl.h"
#include "lltabcontainervertical.h"
#include "llviewerwindow.h"
#include "llinventorymodel.h"
#include "llinventoryfunctions.h"
#include "llinventoryobserver.h"
#include "llinventoryicon.h"
#include "lltextbox.h"
#include "lllineeditor.h"
@@ -1041,7 +1042,7 @@ void LLPanelEditWearable::draw()
std::string path;
const LLUUID& item_id = gAgentWearables.getWearableItemID( wearable->getType() );
gInventory.appendPath(item_id, path);
append_path(item_id, path);
childSetVisible("path", TRUE);
childSetTextArg("path", "[PATH]", path);
@@ -1054,7 +1055,7 @@ void LLPanelEditWearable::draw()
std::string path;
const LLUUID& item_id = gAgentWearables.getWearableItemID( wearable->getType() );
gInventory.appendPath(item_id, path);
append_path(item_id, path);
childSetVisible("path", TRUE);
childSetTextArg("path", "[PATH]", path);
@@ -2785,7 +2786,7 @@ public:
void LLFloaterCustomize::fetchInventory()
{
// Fetch currently worn items
LLInventoryFetchObserver::item_ref_t ids;
uuid_vec_t ids;
LLUUID item_id;
for(S32 type = (S32)LLWearableType::WT_SHAPE; type < (S32)LLWearableType::WT_COUNT; ++type)
{

View File

@@ -40,7 +40,7 @@
#include "llviewerparcelmgr.h"
#include "llfolderview.h"
#include "llinventory.h"
#include "llinventorymodel.h"
#include "llinventoryfunctions.h"
#include "llinventoryview.h"
#include "llviewerinventory.h"
#include "llpermissions.h"

View File

@@ -70,6 +70,7 @@
#include "llappviewer.h"
#include "llmapimagetype.h"
#include "llweb.h"
#include "llinventoryfunctions.h"
#include "llglheaders.h"

View File

@@ -53,7 +53,7 @@
#include "llagent.h"
#include "llchatbar.h"
#include "lldelayedgestureerror.h"
#include "llinventorymodel.h"
#include "llinventoryobserver.h"
#include "llviewermessage.h"
#include "llvoavatarself.h"
#include "llviewerstats.h"

View File

@@ -53,7 +53,7 @@
#include "llfloatergroupinfo.h"
#include "llimview.h"
#include "llinventory.h"
#include "llinventorymodel.h"
#include "llinventoryfunctions.h"
#include "llinventoryview.h"
#include "llfloateractivespeakers.h"
#include "llfloateravatarinfo.h"

View File

@@ -60,7 +60,7 @@
#include "llfolderview.h"
#include "llgesturemgr.h"
#include "lliconctrl.h"
#include "llinventorymodel.h"
#include "llinventoryfunctions.h"
#include "llinventoryclipboard.h"
#include "lllineeditor.h"
#include "llmenugl.h"

View File

@@ -37,6 +37,7 @@
#include "llinventoryview.h"
#include "llinventorybridge.h"
#include "llinventorydefines.h"
#include "llinventoryfunctions.h"
#include "llinventoryicon.h"
#include "message.h"
@@ -182,39 +183,6 @@ struct LLWearInfo
BOOL mReplace;
};
BOOL get_is_item_worn(const LLInventoryItem *item)
{
if (!item)
return FALSE;
switch(item->getType())
{
case LLAssetType::AT_OBJECT:
{
if (isAgentAvatarValid() && gAgentAvatarp->isWearingAttachment(item->getLinkedUUID()))
return TRUE;
break;
}
case LLAssetType::AT_BODYPART:
case LLAssetType::AT_CLOTHING:
if(gAgentWearables.isWearingItem(item->getLinkedUUID()))
return TRUE;
break;
case LLAssetType::AT_GESTURE:
if (LLGestureMgr::instance().isGestureActive(item->getLinkedUUID()))
return TRUE;
break;
default:
break;
}
return FALSE;
}
BOOL get_is_item_worn(const LLUUID& id)
{
return get_is_item_worn(gInventory.getItem(id));
}
// [RLVa:KB] - Made this part of LLWearableHoldingPattern
//BOOL gAddToOutfit = FALSE;
// [/RLVa:KB]
@@ -4664,7 +4632,7 @@ void LLOutfitFetch::done()
LLOutfitObserver* outfit;
outfit = new LLOutfitObserver(mCompleteFolders.front(), mCopyItems, mAppend);
LLInventoryFetchObserver::item_ref_t ids;
uuid_vec_t ids;
for(S32 i = 0; i < count; ++i)
{
ids.push_back(item_array.get(i)->getUUID());

View File

@@ -37,6 +37,7 @@
#include "llfloaterproperties.h"
#include "llfolderview.h"
#include "llinventorymodel.h"
#include "llinventoryobserver.h"
//#include "llinventoryview.h"
#include "llviewercontrol.h"
#include "llwearable.h"

View File

@@ -0,0 +1,477 @@
/**
* @file llinventoryfunctions.cpp
* @brief Implementation of the inventory view and associated stuff.
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, 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
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include <utility> // for std::pair<>
#include "llinventoryfunctions.h"
// library includes
#include "llagent.h"
#include "llagentwearables.h"
#include "llcallingcard.h"
#include "llinventorydefines.h"
#include "llsdserialize.h"
#include "llspinctrl.h"
#include "llui.h"
#include "message.h"
// newview includes
#include "llappviewer.h"
//#include "llfirstuse.h"
#include "llfocusmgr.h"
#include "llfolderview.h"
#include "llgesturemgr.h"
#include "lliconctrl.h"
#include "llimview.h"
#include "llinventorybridge.h"
#include "llinventoryclipboard.h"
#include "llinventorymodel.h"
#include "llinventoryview.h"
#include "lllineeditor.h"
#include "llmenugl.h"
#include "llnotificationsutil.h"
#include "llpreviewanim.h"
#include "llpreviewgesture.h"
#include "llpreviewnotecard.h"
#include "llpreviewscript.h"
#include "llpreviewsound.h"
#include "llpreviewtexture.h"
#include "llresmgr.h"
#include "llscrollbar.h"
#include "llscrollcontainer.h"
#include "llselectmgr.h"
#include "lltabcontainer.h"
#include "lltooldraganddrop.h"
#include "lluictrlfactory.h"
#include "llviewermessage.h"
#include "llviewerobjectlist.h"
#include "llviewerregion.h"
#include "llviewerwindow.h"
#include "llvoavatarself.h"
#include "llwearablelist.h"
#include "cofmgr.h"
BOOL LLInventoryState::sWearNewClothing = FALSE;
LLUUID LLInventoryState::sWearNewClothingTransactionID;
// Generates a string containing the path to the item specified by
// item_id.
void append_path(const LLUUID& id, std::string& path)
{
std::string temp;
LLInventoryObject* obj = gInventory.getObject(id);
LLUUID parent_id;
if(obj) parent_id = obj->getParentUUID();
std::string forward_slash("/");
while(obj)
{
obj = gInventory.getCategory(parent_id);
if(obj)
{
temp.assign(forward_slash + obj->getName() + temp);
parent_id = obj->getParentUUID();
}
}
path.append(temp);
}
void change_item_parent(LLInventoryModel* model,
LLViewerInventoryItem* item,
const LLUUID& new_parent_id,
BOOL restamp)
{
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);
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();
}
class LLInventoryCollectAllItems : public LLInventoryCollectFunctor
{
public:
virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item)
{
return true;
}
};
BOOL get_is_parent_to_worn_item(const LLUUID& id)
{
const LLViewerInventoryCategory* cat = gInventory.getCategory(id);
if (!cat)
{
return FALSE;
}
LLInventoryModel::cat_array_t cats;
LLInventoryModel::item_array_t items;
LLInventoryCollectAllItems collect_all;
gInventory.collectDescendentsIf(LLCOFMgr::instance().getCOF(), cats, items, LLInventoryModel::EXCLUDE_TRASH, collect_all);
for (LLInventoryModel::item_array_t::const_iterator it = items.begin(); it != items.end(); ++it)
{
const LLViewerInventoryItem * const item = *it;
llassert(item->getIsLinkType());
LLUUID linked_id = item->getLinkedUUID();
const LLViewerInventoryItem * const linked_item = gInventory.getItem(linked_id);
if (linked_item)
{
LLUUID parent_id = linked_item->getParentUUID();
while (!parent_id.isNull())
{
LLInventoryCategory * parent_cat = gInventory.getCategory(parent_id);
if (cat == parent_cat)
{
return TRUE;
}
parent_id = parent_cat->getParentUUID();
}
}
}
return FALSE;
}
BOOL get_is_item_worn(const LLInventoryItem *item)
{
if (!item)
return FALSE;
// Consider the item as worn if it has links in COF.
if (LLCOFMgr::instance().isLinkInCOF(item->getUUID()))
{
return TRUE;
}
switch(item->getType())
{
case LLAssetType::AT_OBJECT:
{
if (isAgentAvatarValid() && gAgentAvatarp->isWearingAttachment(item->getLinkedUUID()))
return TRUE;
break;
}
case LLAssetType::AT_BODYPART:
case LLAssetType::AT_CLOTHING:
if(gAgentWearables.isWearingItem(item->getLinkedUUID()))
return TRUE;
break;
case LLAssetType::AT_GESTURE:
if (LLGestureMgr::instance().isGestureActive(item->getLinkedUUID()))
return TRUE;
break;
default:
break;
}
return FALSE;
}
BOOL get_is_item_worn(const LLUUID& id)
{
return get_is_item_worn(gInventory.getItem(id));
}
BOOL get_can_item_be_worn(const LLUUID& id)
{
const LLViewerInventoryItem* item = gInventory.getItem(id);
if (!item)
return FALSE;
if (LLCOFMgr::instance().isLinkInCOF(item->getLinkedUUID()))
{
// an item having links in COF (i.e. a worn item)
return FALSE;
}
if (gInventory.isObjectDescendentOf(id, LLCOFMgr::instance().getCOF()))
{
// a non-link object in COF (should not normally happen)
return FALSE;
}
const LLUUID trash_id = gInventory.findCategoryUUIDForType(
LLFolderType::FT_TRASH);
// item can't be worn if base obj in trash, see EXT-7015
if (gInventory.isObjectDescendentOf(item->getLinkedUUID(),
trash_id))
{
return false;
}
switch(item->getType())
{
case LLAssetType::AT_OBJECT:
{
if (isAgentAvatarValid() && gAgentAvatarp->isWearingAttachment(item->getLinkedUUID()))
{
// Already being worn
return FALSE;
}
else
{
// Not being worn yet.
return TRUE;
}
break;
}
case LLAssetType::AT_BODYPART:
case LLAssetType::AT_CLOTHING:
if(gAgentWearables.isWearingItem(item->getLinkedUUID()))
{
// Already being worn
return FALSE;
}
else
{
// Not being worn yet.
return TRUE;
}
break;
default:
break;
}
return FALSE;
}
///----------------------------------------------------------------------------
/// LLInventoryCollectFunctor implementations
///----------------------------------------------------------------------------
// static
bool LLInventoryCollectFunctor::itemTransferCommonlyAllowed(const LLInventoryItem* item)
{
if (!item)
return false;
switch(item->getType())
{
case LLAssetType::AT_OBJECT:
case LLAssetType::AT_BODYPART:
case LLAssetType::AT_CLOTHING:
if (!get_is_item_worn(item->getUUID()))
return true;
break;
default:
return true;
break;
}
return false;
}
bool LLIsType::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
{
if(mType == LLAssetType::AT_CATEGORY)
{
if(cat) return TRUE;
}
if(item)
{
if(item->getType() == mType) return TRUE;
}
return FALSE;
}
bool LLIsNotType::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
{
if(mType == LLAssetType::AT_CATEGORY)
{
if(cat) return FALSE;
}
if(item)
{
if(item->getType() == mType) return FALSE;
else return TRUE;
}
return TRUE;
}
bool LLIsOfAssetType::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
{
if(mType == LLAssetType::AT_CATEGORY)
{
if(cat) return TRUE;
}
if(item)
{
if(item->getActualType() == mType) return TRUE;
}
return FALSE;
}
bool LLIsTypeWithPermissions::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
{
if(mType == LLAssetType::AT_CATEGORY)
{
if(cat)
{
return TRUE;
}
}
if(item)
{
if(item->getType() == mType)
{
LLPermissions perm = item->getPermissions();
if ((perm.getMaskBase() & mPerm) == mPerm)
{
return TRUE;
}
}
}
return FALSE;
}
bool LLBuddyCollector::operator()(LLInventoryCategory* cat,
LLInventoryItem* item)
{
if(item)
{
if((LLAssetType::AT_CALLINGCARD == item->getType())
&& (!item->getCreatorUUID().isNull())
&& (item->getCreatorUUID() != gAgent.getID()))
{
return true;
}
}
return false;
}
bool LLUniqueBuddyCollector::operator()(LLInventoryCategory* cat,
LLInventoryItem* item)
{
if(item)
{
if((LLAssetType::AT_CALLINGCARD == item->getType())
&& (item->getCreatorUUID().notNull())
&& (item->getCreatorUUID() != gAgent.getID()))
{
mSeen.insert(item->getCreatorUUID());
return true;
}
}
return false;
}
bool LLParticularBuddyCollector::operator()(LLInventoryCategory* cat,
LLInventoryItem* item)
{
if(item)
{
if((LLAssetType::AT_CALLINGCARD == item->getType())
&& (item->getCreatorUUID() == mBuddyID))
{
return TRUE;
}
}
return FALSE;
}
bool LLNameCategoryCollector::operator()(
LLInventoryCategory* cat, LLInventoryItem* item)
{
if(cat)
{
if (!LLStringUtil::compareInsensitive(mName, cat->getName()))
{
return true;
}
}
return false;
}
///----------------------------------------------------------------------------
/// LLAssetIDMatches
///----------------------------------------------------------------------------
bool LLAssetIDMatches ::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
{
return (item && item->getAssetUUID() == mAssetID);
}
///----------------------------------------------------------------------------
/// LLLinkedItemIDMatches
///----------------------------------------------------------------------------
bool LLLinkedItemIDMatches::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
{
return (item &&
(item->getIsLinkType()) &&
(item->getLinkedUUID() == mBaseItemID)); // A linked item's assetID will be the compared-to item's itemID.
}

View File

@@ -0,0 +1,267 @@
/**
* @file llinventoryfunctions.h
* @brief Miscellaneous inventory-related functions and classes
* class definition
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, 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
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLINVENTORYFUNCTIONS_H
#define LL_LLINVENTORYFUNCTIONS_H
#include "llinventorymodel.h"
#include "llinventory.h"
#include "llwearabletype.h"
/********************************************************************************
** **
** MISCELLANEOUS GLOBAL FUNCTIONS
**/
// Is this a parent folder to a worn item
BOOL get_is_parent_to_worn_item(const LLUUID& id);
// Is this item or its baseitem is worn, attached, etc...
BOOL get_is_item_worn(const LLInventoryItem *item);
BOOL get_is_item_worn(const LLUUID& id);
// Could this item be worn (correct type + not already being worn)
BOOL get_can_item_be_worn(const LLUUID& id);
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);
// Generates a string containing the path to the item specified by item_id.
void append_path(const LLUUID& id, std::string& path);
/********************************************************************************
** **
** INVENTORY COLLECTOR FUNCTIONS
**/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryCollectFunctor
//
// Base class for LLInventoryModel::collectDescendentsIf() method
// which accepts an instance of one of these objects to use as the
// function to determine if it should be added. Derive from this class
// and override the () operator to return TRUE if you want to collect
// the category or item passed in.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryCollectFunctor
{
public:
virtual ~LLInventoryCollectFunctor(){};
virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item) = 0;
static bool itemTransferCommonlyAllowed(const LLInventoryItem* item);
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLAssetIDMatches
//
// This functor finds inventory items pointing to the specified asset
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLViewerInventoryItem;
class LLAssetIDMatches : public LLInventoryCollectFunctor
{
public:
LLAssetIDMatches(const LLUUID& asset_id) : mAssetID(asset_id) {}
virtual ~LLAssetIDMatches() {}
bool operator()(LLInventoryCategory* cat, LLInventoryItem* item);
protected:
LLUUID mAssetID;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLLinkedItemIDMatches
//
// This functor finds inventory items linked to the specific inventory id.
// Assumes the inventory id is itself not a linked item.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLLinkedItemIDMatches : public LLInventoryCollectFunctor
{
public:
LLLinkedItemIDMatches(const LLUUID& item_id) : mBaseItemID(item_id) {}
virtual ~LLLinkedItemIDMatches() {}
bool operator()(LLInventoryCategory* cat, LLInventoryItem* item);
protected:
LLUUID mBaseItemID;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLIsType
//
// Implementation of a LLInventoryCollectFunctor which returns TRUE if
// the type is the type passed in during construction.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLIsType : public LLInventoryCollectFunctor
{
public:
LLIsType(LLAssetType::EType type) : mType(type) {}
virtual ~LLIsType() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
LLAssetType::EType mType;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLIsNotType
//
// Implementation of a LLInventoryCollectFunctor which returns FALSE if the
// type is the type passed in during construction, otherwise false.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLIsNotType : public LLInventoryCollectFunctor
{
public:
LLIsNotType(LLAssetType::EType type) : mType(type) {}
virtual ~LLIsNotType() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
LLAssetType::EType mType;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLIsOfAssetType
//
// Implementation of a LLInventoryCollectFunctor which returns TRUE if
// the item or category is of asset type passed in during construction.
// Link types are treated as links, not as the types they point to.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLIsOfAssetType : public LLInventoryCollectFunctor
{
public:
LLIsOfAssetType(LLAssetType::EType type) : mType(type) {}
virtual ~LLIsOfAssetType() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
LLAssetType::EType mType;
};
class LLIsTypeWithPermissions : public LLInventoryCollectFunctor
{
public:
LLIsTypeWithPermissions(LLAssetType::EType type, const PermissionBit perms, const LLUUID &agent_id, const LLUUID &group_id)
: mType(type), mPerm(perms), mAgentID(agent_id), mGroupID(group_id) {}
virtual ~LLIsTypeWithPermissions() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
LLAssetType::EType mType;
PermissionBit mPerm;
LLUUID mAgentID;
LLUUID mGroupID;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLBuddyCollector
//
// Simple class that collects calling cards that are not null, and not
// the agent. Duplicates are possible.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLBuddyCollector : public LLInventoryCollectFunctor
{
public:
LLBuddyCollector() {}
virtual ~LLBuddyCollector() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLUniqueBuddyCollector
//
// Simple class that collects calling cards that are not null, and not
// the agent. Duplicates are discarded.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLUniqueBuddyCollector : public LLInventoryCollectFunctor
{
public:
LLUniqueBuddyCollector() {}
virtual ~LLUniqueBuddyCollector() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
std::set<LLUUID> mSeen;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLParticularBuddyCollector
//
// Simple class that collects calling cards that match a particular uuid
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLParticularBuddyCollector : public LLInventoryCollectFunctor
{
public:
LLParticularBuddyCollector(const LLUUID& id) : mBuddyID(id) {}
virtual ~LLParticularBuddyCollector() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
LLUUID mBuddyID;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLNameCategoryCollector
//
// Collects categories based on case-insensitive match of prefix
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLNameCategoryCollector : public LLInventoryCollectFunctor
{
public:
LLNameCategoryCollector(const std::string& name) : mName(name) {}
virtual ~LLNameCategoryCollector() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
std::string mName;
};
class LLInventoryState
{
public:
// HACK: Until we can route this info through the instant message hierarchy
static BOOL sWearNewClothing;
static LLUUID sWearNewClothingTransactionID; // wear all clothing in this transaction
};
#endif // LL_LLINVENTORYFUNCTIONS_H

File diff suppressed because it is too large Load Diff

View File

@@ -36,44 +36,20 @@
#include "llassettype.h"
#include "llfoldertype.h"
#include "lldarray.h"
#include "llhttpclient.h"
#include "lluuid.h"
#include "llpermissionsflags.h"
#include "llstring.h"
#include "llhttpclient.h"
#include "llmd5.h"
#include <map>
#include <set>
#include <string>
#include <vector>
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryObserver
//
// This class is designed to be a simple abstract base class which can
// relay messages when the inventory changes.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryObserver;
class LLInventoryObserver
{
public:
// This enumeration is a way to refer to what changed in a more
// human readable format. You can mask the value provided by
// chaged() to see if the observer is interested in the change.
enum
{
NONE = 0,
LABEL = 1, // name changed
INTERNAL = 2, // internal change, eg, asset uuid different
ADD = 4, // something added
REMOVE = 8, // something deleted
STRUCTURE = 16, // structural change, eg, item or folder moved
CALLING_CARD = 32, // online, grant status, cancel, etc change
ALL = 0xffffffff
};
virtual ~LLInventoryObserver() {};
virtual void changed(U32 mask) = 0;
std::string mMessageName; // used by Agent Inventory Service only. [DEV-20328]
};
class LLInventoryObject;
class LLInventoryItem;
class LLInventoryCategory;
@@ -223,6 +199,9 @@ public:
void getDirectDescendentsOf(const LLUUID& cat_id,
cat_array_t*& categories) const;
// Compute a hash of direct descendent names (for detecting child name changes)
LLMD5 hashDirectDescendentNames(const LLUUID& cat_id) const;
// Starting with the object specified, add its descendents to the
// array provided, but do not add the inventory object specified
// by id. There is no guaranteed order.
@@ -381,10 +360,6 @@ public:
//void requestFromServer(const LLUUID& agent_id);
// Generates a string containing the path to the item specified by
// item_id.
void appendPath(const LLUUID& id, std::string& path);
//--------------------------------------------------------------------
// Creation
//--------------------------------------------------------------------
@@ -524,6 +499,9 @@ public:
// Callbacks
//--------------------------------------------------------------------
public:
// Trigger a notification and empty the folder type (FT_TRASH or FT_LOST_AND_FOUND) if confirmed
void emptyFolderType(const std::string notification, LLFolderType::EType folder_type);
bool callbackEmptyFolderType(const LLSD& notification, const LLSD& response, LLFolderType::EType preferred_type);
static void registerCallbacks(LLMessageSystem* msg);
//--------------------------------------------------------------------
@@ -544,9 +522,12 @@ protected:
//--------------------------------------------------------------------
public:
static void processUpdateCreateInventoryItem(LLMessageSystem* msg, void**);
static void removeInventoryItem(LLUUID agent_id, LLMessageSystem* msg, const char* msg_label);
static void processRemoveInventoryItem(LLMessageSystem* msg, void**);
static void processUpdateInventoryFolder(LLMessageSystem* msg, void**);
static void removeInventoryFolder(LLUUID agent_id, LLMessageSystem* msg);
static void processRemoveInventoryFolder(LLMessageSystem* msg, void**);
static void processRemoveInventoryObjects(LLMessageSystem* msg, void**);
static void processSaveAssetIntoInventory(LLMessageSystem* msg, void**);
static void processBulkUpdateInventory(LLMessageSystem* msg, void**);
static void processInventoryDescendents(LLMessageSystem* msg, void**);
@@ -597,384 +578,5 @@ public:
// a special inventory model for the agent
extern LLInventoryModel gInventory;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryCollectFunctor
//
// Base class for LLInventoryModel::collectDescendentsIf() method
// which accepts an instance of one of these objects to use as the
// function to determine if it should be added. Derive from this class
// and override the () operator to return TRUE if you want to collect
// the category or item passed in.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryCollectFunctor
{
public:
virtual ~LLInventoryCollectFunctor(){};
virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item) = 0;
static bool itemTransferCommonlyAllowed(LLInventoryItem* item);
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLAssetIDMatches
//
// This functor finds inventory items pointing to the specified asset
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLViewerInventoryItem;
class LLAssetIDMatches : public LLInventoryCollectFunctor
{
public:
LLAssetIDMatches(const LLUUID& asset_id) : mAssetID(asset_id) {}
virtual ~LLAssetIDMatches() {}
bool operator()(LLInventoryCategory* cat, LLInventoryItem* item);
protected:
LLUUID mAssetID;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLLinkedItemIDMatches
//
// This functor finds inventory items linked to the specific inventory id.
// Assumes the inventory id is itself not a linked item.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLLinkedItemIDMatches : public LLInventoryCollectFunctor
{
public:
LLLinkedItemIDMatches(const LLUUID& item_id) : mBaseItemID(item_id) {}
virtual ~LLLinkedItemIDMatches() {}
bool operator()(LLInventoryCategory* cat, LLInventoryItem* item);
protected:
LLUUID mBaseItemID;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLIsType
//
// Implementation of a LLInventoryCollectFunctor which returns TRUE if
// the type is the type passed in during construction.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLIsType : public LLInventoryCollectFunctor
{
public:
LLIsType(LLAssetType::EType type) : mType(type) {}
virtual ~LLIsType() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
LLAssetType::EType mType;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLIsNotType
//
// Implementation of a LLInventoryCollectFunctor which returns FALSE if the
// type is the type passed in during construction, otherwise false.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLIsNotType : public LLInventoryCollectFunctor
{
public:
LLIsNotType(LLAssetType::EType type) : mType(type) {}
virtual ~LLIsNotType() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
LLAssetType::EType mType;
};
class LLIsTypeWithPermissions : public LLInventoryCollectFunctor
{
public:
LLIsTypeWithPermissions(LLAssetType::EType type, const PermissionBit perms, const LLUUID &agent_id, const LLUUID &group_id)
: mType(type), mPerm(perms), mAgentID(agent_id), mGroupID(group_id) {}
virtual ~LLIsTypeWithPermissions() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
LLAssetType::EType mType;
PermissionBit mPerm;
LLUUID mAgentID;
LLUUID mGroupID;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLIsClone
//
// Implementation of a LLInventoryCollectFunctor which returns TRUE if
// the object is a clone of the item passed in during
// construction.
//
// *NOTE: Since clone information is determined based off of asset id
// (or creator with calling cards), if the id is NULL, it has no
// clones - even itself.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//class LLIsClone : public LLInventoryCollectFunctor
//{
//public:
// LLIsClone(LLViewerInventoryItem* item) : mItem(item) {}
// virtual ~LLIsClone() {}
// virtual bool operator()(LLViewerInventoryCategory* cat,
// LLViewerInventoryItem* item);
//protected:
// LLPointer<LLViewerInventoryItem> mItem;
//};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLBuddyCollector
//
// Simple class that collects calling cards that are not null, and not
// the agent. Duplicates are possible.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLBuddyCollector : public LLInventoryCollectFunctor
{
public:
LLBuddyCollector() {}
virtual ~LLBuddyCollector() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLUniqueBuddyCollector
//
// Simple class that collects calling cards that are not null, and not
// the agent. Duplicates are discarded.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLUniqueBuddyCollector : public LLInventoryCollectFunctor
{
public:
LLUniqueBuddyCollector() {}
virtual ~LLUniqueBuddyCollector() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
std::set<LLUUID> mSeen;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLParticularBuddyCollector
//
// Simple class that collects calling cards that match a particular uuid
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLParticularBuddyCollector : public LLInventoryCollectFunctor
{
public:
LLParticularBuddyCollector(const LLUUID& id) : mBuddyID(id) {}
virtual ~LLParticularBuddyCollector() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
LLUUID mBuddyID;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLNameCategoryCollector
//
// Collects categories based on case-insensitive match of prefix
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLNameCategoryCollector : public LLInventoryCollectFunctor
{
public:
LLNameCategoryCollector(const std::string& name) : mName(name) {}
virtual ~LLNameCategoryCollector() {}
virtual bool operator()(LLInventoryCategory* cat,
LLInventoryItem* item);
protected:
std::string mName;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryCompletionObserver
//
// Class which can be used as a base class for doing something when
// when all observed items are locally complete. This class implements
// the changed() method of LLInventoryObserver and declares a new
// method named done() which is called when all watched items have
// complete information in the inventory model.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryCompletionObserver : public LLInventoryObserver
{
public:
LLInventoryCompletionObserver() {}
virtual void changed(U32 mask);
void watchItem(const LLUUID& id);
protected:
virtual void done() = 0;
typedef std::vector<LLUUID> item_ref_t;
item_ref_t mComplete;
item_ref_t mIncomplete;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryFetchObserver
//
// This class is much like the LLInventoryCompletionObserver, except
// that it handles all the the fetching necessary. Override the done()
// method to do the thing you want.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryFetchObserver : public LLInventoryObserver
{
public:
LLInventoryFetchObserver() {}
virtual void changed(U32 mask);
typedef std::vector<LLUUID> item_ref_t;
bool isEverythingComplete() const;
void fetchItems(const item_ref_t& ids);
virtual void done() = 0;
protected:
item_ref_t mComplete;
item_ref_t mIncomplete;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryFetchDescendentsObserver
//
// This class is much like the LLInventoryCompletionObserver, except
// that it handles fetching based on category. Override the done()
// method to do the thing you want.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryFetchDescendentsObserver : public LLInventoryObserver
{
public:
LLInventoryFetchDescendentsObserver() {}
virtual void changed(U32 mask);
typedef std::vector<LLUUID> folder_ref_t;
void fetchDescendents(const folder_ref_t& ids);
bool isEverythingComplete() const;
virtual void done() = 0;
protected:
bool isComplete(LLViewerInventoryCategory* cat);
folder_ref_t mIncompleteFolders;
folder_ref_t mCompleteFolders;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryFetchComboObserver
//
// This class does an appropriate combination of fetch descendents and
// item fetches based on completion of categories and items. Much like
// the fetch and fetch descendents, this will call done() when everything
// has arrived.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryFetchComboObserver : public LLInventoryObserver
{
public:
LLInventoryFetchComboObserver() : mDone(false) {}
virtual void changed(U32 mask);
typedef std::vector<LLUUID> folder_ref_t;
typedef std::vector<LLUUID> item_ref_t;
void fetch(const folder_ref_t& folder_ids, const item_ref_t& item_ids);
virtual void done() = 0;
protected:
bool mDone;
folder_ref_t mCompleteFolders;
folder_ref_t mIncompleteFolders;
item_ref_t mCompleteItems;
item_ref_t mIncompleteItems;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryExistenceObserver
//
// This class is used as a base class for doing somethign when all the
// observed item ids exist in the inventory somewhere. You can derive
// a class from this class and implement the done() method to do
// something useful.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryExistenceObserver : public LLInventoryObserver
{
public:
LLInventoryExistenceObserver() {}
virtual void changed(U32 mask);
void watchItem(const LLUUID& id);
protected:
virtual void done() = 0;
typedef std::vector<LLUUID> item_ref_t;
item_ref_t mExist;
item_ref_t mMIA;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryAddedObserver
//
// This class is used as a base class for doing something when
// a new item arrives in inventory.
// It does not watch for a certain UUID, rather it acts when anything is added
// Derive a class from this class and implement the done() method to do
// something useful.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryAddedObserver : public LLInventoryObserver
{
public:
LLInventoryAddedObserver() : mAdded() {}
virtual void changed(U32 mask);
protected:
virtual void done() = 0;
typedef std::vector<LLUUID> item_ref_t;
item_ref_t mAdded;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryTransactionObserver
//
// Class which can be used as a base class for doing something when an
// inventory transaction completes.
//
// *NOTE: This class is not quite complete. Avoid using unless you fix up it's
// functionality gaps.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryTransactionObserver : public LLInventoryObserver
{
public:
LLInventoryTransactionObserver(const LLTransactionID& transaction_id);
virtual void changed(U32 mask);
protected:
typedef std::vector<LLUUID> folder_ref_t;
typedef std::vector<LLUUID> item_ref_t;
virtual void done(const folder_ref_t& folders, const item_ref_t& items) = 0;
LLTransactionID mTransactionID;
};
#endif // LL_LLINVENTORYMODEL_H

View File

@@ -0,0 +1,679 @@
/**
* @file llinventoryobserver.cpp
* @brief Implementation of the inventory observers used to track agent inventory.
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, 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
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llinventoryobserver.h"
#include "llassetstorage.h"
#include "llcrc.h"
#include "lldir.h"
#include "llsys.h"
#include "llxfermanager.h"
#include "message.h"
#include "llagent.h"
#include "llagentwearables.h"
#include "llfloater.h"
#include "llfocusmgr.h"
#include "llinventorybridge.h"
//#include "llinventoryfunctions.h"
#include "llinventorymodel.h"
#include "llviewermessage.h"
#include "llviewerwindow.h"
#include "llviewerregion.h"
#include "llappviewer.h"
#include "lldbstrings.h"
#include "llviewerstats.h"
#include "llnotificationsutil.h"
#include "llcallbacklist.h"
#include "llpreview.h"
#include "llviewercontrol.h"
#include "llvoavatarself.h"
#include "llsdutil.h"
#include <deque>
const F32 LLInventoryFetchItemsObserver::FETCH_TIMER_EXPIRY = 60.0f;
void fetch_items_from_llsd(const LLSD& items_llsd);
void LLInventoryCompletionObserver::changed(U32 mask)
{
// scan through the incomplete items and move or erase them as
// appropriate.
if(!mIncomplete.empty())
{
for(uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end(); )
{
LLViewerInventoryItem* item = gInventory.getItem(*it);
if(!item)
{
it = mIncomplete.erase(it);
continue;
}
if(item->isComplete())
{
mComplete.push_back(*it);
it = mIncomplete.erase(it);
continue;
}
++it;
}
if(mIncomplete.empty())
{
done();
}
}
}
void LLInventoryCompletionObserver::watchItem(const LLUUID& id)
{
if(id.notNull())
{
mIncomplete.push_back(id);
}
}
LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const LLUUID& item_id)
{
mIDs.clear();
if (item_id != LLUUID::null)
{
mIDs.push_back(item_id);
}
}
LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids)
: mIDs(item_ids)
{
}
BOOL LLInventoryFetchItemsObserver::isFinished() const
{
return mIncomplete.empty();
}
void LLInventoryFetchItemsObserver::changed(U32 mask)
{
lldebugs << this << " remaining incomplete " << mIncomplete.size()
<< " complete " << mComplete.size()
<< " wait period " << mFetchingPeriod.getRemainingTimeF32()
<< llendl;
// scan through the incomplete items and move or erase them as
// appropriate.
if (!mIncomplete.empty())
{
// Have we exceeded max wait time?
bool timeout_expired = mFetchingPeriod.hasExpired();
for (uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end(); )
{
const LLUUID& item_id = (*it);
LLViewerInventoryItem* item = gInventory.getItem(item_id);
if (item && item->isComplete())
{
mComplete.push_back(item_id);
it = mIncomplete.erase(it);
}
else
{
if (timeout_expired)
{
// Just concede that this item hasn't arrived in reasonable time and continue on.
llwarns << "Fetcher timed out when fetching inventory item UUID: " << item_id << LL_ENDL;
it = mIncomplete.erase(it);
}
else
{
// Keep trying.
++it;
}
}
}
}
if (mIncomplete.empty())
{
lldebugs << this << " done at remaining incomplete "
<< mIncomplete.size() << " complete " << mComplete.size() << llendl;
done();
}
//llinfos << "LLInventoryFetchItemsObserver::changed() mComplete size " << mComplete.size() << llendl;
//llinfos << "LLInventoryFetchItemsObserver::changed() mIncomplete size " << mIncomplete.size() << llendl;
}
void LLInventoryFetchItemsObserver::startFetch()
{
LLUUID owner_id;
LLSD items_llsd;
for (uuid_vec_t::const_iterator it = mIDs.begin(); it < mIDs.end(); ++it)
{
LLViewerInventoryItem* item = gInventory.getItem(*it);
if (item)
{
if (item->isComplete())
{
// It's complete, so put it on the complete container.
mComplete.push_back(*it);
continue;
}
else
{
owner_id = item->getPermissions().getOwner();
}
}
else
{
// assume it's agent inventory.
owner_id = gAgent.getID();
}
// Ignore categories since they're not items. We
// could also just add this to mComplete but not sure what the
// side-effects would be, so ignoring to be safe.
LLViewerInventoryCategory* cat = gInventory.getCategory(*it);
if (cat)
{
continue;
}
// It's incomplete, so put it on the incomplete container, and
// pack this on the message.
mIncomplete.push_back(*it);
// Prepare the data to fetch
LLSD item_entry;
item_entry["owner_id"] = owner_id;
item_entry["item_id"] = (*it);
items_llsd.append(item_entry);
}
mFetchingPeriod.reset();
mFetchingPeriod.setTimerExpirySec(FETCH_TIMER_EXPIRY);
fetch_items_from_llsd(items_llsd);
}
void LLInventoryFetchObserver::changed(U32 mask)
{
// scan through the incomplete items and move or erase them as
// appropriate.
if(!mIncomplete.empty())
{
for(uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end(); )
{
LLViewerInventoryItem* item = gInventory.getItem(*it);
if(!item)
{
// BUG: This can cause done() to get called prematurely below.
// This happens with the LLGestureInventoryFetchObserver that
// loads gestures at startup. JC
it = mIncomplete.erase(it);
continue;
}
if(item->isComplete())
{
mComplete.push_back(*it);
it = mIncomplete.erase(it);
continue;
}
++it;
}
if(mIncomplete.empty())
{
done();
}
}
//llinfos << "LLInventoryFetchObserver::changed() mComplete size " << mComplete.size() << llendl;
//llinfos << "LLInventoryFetchObserver::changed() mIncomplete size " << mIncomplete.size() << llendl;
}
bool LLInventoryFetchObserver::isEverythingComplete() const
{
return mIncomplete.empty();
}
void fetch_items_from_llsd(const LLSD& items_llsd)
{
if (!items_llsd.size() || gDisconnected) return;
LLSD body;
body[0]["cap_name"] = "FetchInventory";
body[1]["cap_name"] = "FetchLib";
for (S32 i=0; i<items_llsd.size();i++)
{
if (items_llsd[i]["owner_id"].asString() == gAgent.getID().asString())
{
body[0]["items"].append(items_llsd[i]);
continue;
}
else if (items_llsd[i]["owner_id"].asString() == ALEXANDRIA_LINDEN_ID.asString())
{
body[1]["items"].append(items_llsd[i]);
continue;
}
}
for (S32 i=0; i<body.size(); i++)
{
if (!gAgent.getRegion())
{
llwarns << "Agent's region is null" << llendl;
break;
}
if (0 == body[i]["items"].size()) {
lldebugs << "Skipping body with no items to fetch" << llendl;
continue;
}
std::string url = gAgent.getRegion()->getCapability(body[i]["cap_name"].asString());
if (!url.empty())
{
body[i]["agent_id"] = gAgent.getID();
LLHTTPClient::post(url, body[i], new LLInventoryModel::fetchInventoryResponder(body[i]));
continue;
}
LLMessageSystem* msg = gMessageSystem;
BOOL start_new_message = TRUE;
for (S32 j=0; j<body[i]["items"].size(); j++)
{
LLSD item_entry = body[i]["items"][j];
if(start_new_message)
{
start_new_message = FALSE;
msg->newMessageFast(_PREHASH_FetchInventory);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
}
msg->nextBlockFast(_PREHASH_InventoryData);
msg->addUUIDFast(_PREHASH_OwnerID, item_entry["owner_id"].asUUID());
msg->addUUIDFast(_PREHASH_ItemID, item_entry["item_id"].asUUID());
if(msg->isSendFull(NULL))
{
start_new_message = TRUE;
gAgent.sendReliableMessage();
}
}
if(!start_new_message)
{
gAgent.sendReliableMessage();
}
}
}
void LLInventoryFetchObserver::fetchItems(
const uuid_vec_t& ids)
{
LLUUID owner_id;
LLSD items_llsd;
for(uuid_vec_t::const_iterator it = ids.begin(); it < ids.end(); ++it)
{
LLViewerInventoryItem* item = gInventory.getItem(*it);
if(item)
{
if(item->isComplete())
{
// It's complete, so put it on the complete container.
mComplete.push_back(*it);
continue;
}
else
{
owner_id = item->getPermissions().getOwner();
}
}
else
{
// assume it's agent inventory.
owner_id = gAgent.getID();
}
// It's incomplete, so put it on the incomplete container, and
// pack this on the message.
mIncomplete.push_back(*it);
// Prepare the data to fetch
LLSD item_entry;
item_entry["owner_id"] = owner_id;
item_entry["item_id"] = (*it);
items_llsd.append(item_entry);
}
fetch_items_from_llsd(items_llsd);
}
// virtual
void LLInventoryFetchDescendentsObserver::changed(U32 mask)
{
for(folder_ref_t::iterator it = mIncompleteFolders.begin(); it < mIncompleteFolders.end();)
{
LLViewerInventoryCategory* cat = gInventory.getCategory(*it);
if(!cat)
{
it = mIncompleteFolders.erase(it);
continue;
}
if(isComplete(cat))
{
mCompleteFolders.push_back(*it);
it = mIncompleteFolders.erase(it);
continue;
}
++it;
}
if(mIncompleteFolders.empty())
{
done();
}
}
void LLInventoryFetchDescendentsObserver::fetchDescendents(
const folder_ref_t& ids)
{
for(folder_ref_t::const_iterator it = ids.begin(); it != ids.end(); ++it)
{
LLViewerInventoryCategory* cat = gInventory.getCategory(*it);
if(!cat) continue;
if(!isComplete(cat))
{
cat->fetchDescendents(); //blindly fetch it without seeing if anything else is fetching it.
mIncompleteFolders.push_back(*it); //Add to list of things being downloaded for this observer.
}
else
{
mCompleteFolders.push_back(*it);
}
}
}
bool LLInventoryFetchDescendentsObserver::isEverythingComplete() const
{
return mIncompleteFolders.empty();
}
bool LLInventoryFetchDescendentsObserver::isComplete(LLViewerInventoryCategory* cat)
{
S32 version = cat->getVersion();
S32 descendents = cat->getDescendentCount();
if((LLViewerInventoryCategory::VERSION_UNKNOWN == version)
|| (LLViewerInventoryCategory::DESCENDENT_COUNT_UNKNOWN == descendents))
{
return false;
}
// it might be complete - check known descendents against
// currently available.
LLInventoryModel::cat_array_t* cats;
LLInventoryModel::item_array_t* items;
gInventory.getDirectDescendentsOf(cat->getUUID(), cats, items);
if(!cats || !items)
{
// bit of a hack - pretend we're done if they are gone or
// incomplete. should never know, but it would suck if this
// kept tight looping because of a corrupt memory state.
return true;
}
S32 known = cats->count() + items->count();
if(descendents == known)
{
// hey - we're done.
return true;
}
return false;
}
void LLInventoryFetchComboObserver::changed(U32 mask)
{
if(!mIncompleteItems.empty())
{
for(item_ref_t::iterator it = mIncompleteItems.begin(); it < mIncompleteItems.end(); )
{
LLViewerInventoryItem* item = gInventory.getItem(*it);
if(!item)
{
it = mIncompleteItems.erase(it);
continue;
}
if(item->isComplete())
{
mCompleteItems.push_back(*it);
it = mIncompleteItems.erase(it);
continue;
}
++it;
}
}
if(!mIncompleteFolders.empty())
{
for(folder_ref_t::iterator it = mIncompleteFolders.begin(); it < mIncompleteFolders.end();)
{
LLViewerInventoryCategory* cat = gInventory.getCategory(*it);
if(!cat)
{
it = mIncompleteFolders.erase(it);
continue;
}
if(gInventory.isCategoryComplete(*it))
{
mCompleteFolders.push_back(*it);
it = mIncompleteFolders.erase(it);
continue;
}
++it;
}
}
if(!mDone && mIncompleteItems.empty() && mIncompleteFolders.empty())
{
mDone = true;
done();
}
}
void LLInventoryFetchComboObserver::fetch(
const folder_ref_t& folder_ids,
const item_ref_t& item_ids)
{
lldebugs << "LLInventoryFetchComboObserver::fetch()" << llendl;
for(folder_ref_t::const_iterator fit = folder_ids.begin(); fit != folder_ids.end(); ++fit)
{
LLViewerInventoryCategory* cat = gInventory.getCategory(*fit);
if(!cat) continue;
if(!gInventory.isCategoryComplete(*fit))
{
cat->fetchDescendents();
lldebugs << "fetching folder " << *fit <<llendl;
mIncompleteFolders.push_back(*fit);
}
else
{
mCompleteFolders.push_back(*fit);
lldebugs << "completing folder " << *fit <<llendl;
}
}
// Now for the items - we fetch everything which is not a direct
// descendent of an incomplete folder because the item will show
// up in an inventory descendents message soon enough so we do not
// have to fetch it individually.
LLSD items_llsd;
LLUUID owner_id;
for(item_ref_t::const_iterator iit = item_ids.begin(); iit != item_ids.end(); ++iit)
{
LLViewerInventoryItem* item = gInventory.getItem(*iit);
if(!item)
{
lldebugs << "uanble to find item " << *iit << llendl;
continue;
}
if(item->isComplete())
{
// It's complete, so put it on the complete container.
mCompleteItems.push_back(*iit);
lldebugs << "completing item " << *iit << llendl;
continue;
}
else
{
mIncompleteItems.push_back(*iit);
owner_id = item->getPermissions().getOwner();
}
if(std::find(mIncompleteFolders.begin(), mIncompleteFolders.end(), item->getParentUUID()) == mIncompleteFolders.end())
{
LLSD item_entry;
item_entry["owner_id"] = owner_id;
item_entry["item_id"] = (*iit);
items_llsd.append(item_entry);
}
else
{
lldebugs << "not worrying about " << *iit << llendl;
}
}
fetch_items_from_llsd(items_llsd);
}
void LLInventoryExistenceObserver::watchItem(const LLUUID& id)
{
if(id.notNull())
{
mMIA.push_back(id);
}
}
void LLInventoryExistenceObserver::changed(U32 mask)
{
// scan through the incomplete items and move or erase them as
// appropriate.
if(!mMIA.empty())
{
for(uuid_vec_t::iterator it = mMIA.begin(); it < mMIA.end(); )
{
LLViewerInventoryItem* item = gInventory.getItem(*it);
if(!item)
{
++it;
continue;
}
mExist.push_back(*it);
it = mMIA.erase(it);
}
if(mMIA.empty())
{
done();
}
}
}
void LLInventoryAddedObserver::changed(U32 mask)
{
if(!(mask & LLInventoryObserver::ADD))
{
return;
}
// *HACK: If this was in response to a packet off
// the network, figure out which item was updated.
LLMessageSystem* msg = gMessageSystem;
std::string msg_name = msg->getMessageName();
if (msg_name.empty())
{
return;
}
// We only want newly created inventory items. JC
if ( msg_name != "UpdateCreateInventoryItem")
{
return;
}
LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_InventoryData);
for(S32 i = 0; i < num_blocks; ++i)
{
titem->unpackMessage(msg, _PREHASH_InventoryData, i);
if (!(titem->getUUID().isNull()))
{
//we don't do anything with null keys
mAdded.push_back(titem->getUUID());
}
}
if (!mAdded.empty())
{
done();
}
}
LLInventoryTransactionObserver::LLInventoryTransactionObserver(const LLTransactionID& transaction_id) :
mTransactionID(transaction_id)
{
}
void LLInventoryTransactionObserver::changed(U32 mask)
{
if(mask & LLInventoryObserver::ADD)
{
// This could be it - see if we are processing a bulk update
LLMessageSystem* msg = gMessageSystem;
if(msg->getMessageName()
&& (0 == strcmp(msg->getMessageName(), "BulkUpdateInventory")))
{
// we have a match for the message - now check the
// transaction id.
LLUUID id;
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_TransactionID, id);
if(id == mTransactionID)
{
// woo hoo, we found it
uuid_vec_t folders;
uuid_vec_t items;
S32 count;
count = msg->getNumberOfBlocksFast(_PREHASH_FolderData);
S32 i;
for(i = 0; i < count; ++i)
{
msg->getUUIDFast(_PREHASH_FolderData, _PREHASH_FolderID, id, i);
if(id.notNull())
{
folders.push_back(id);
}
}
count = msg->getNumberOfBlocksFast(_PREHASH_ItemData);
for(i = 0; i < count; ++i)
{
msg->getUUIDFast(_PREHASH_ItemData, _PREHASH_ItemID, id, i);
if(id.notNull())
{
items.push_back(id);
}
}
// call the derived class the implements this method.
done(folders, items);
}
}
}
}

View File

@@ -0,0 +1,257 @@
/**
* @file llinventoryobserver.h
* @brief LLInventoryObserver class header file
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, 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
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLINVENTORYOBSERVERS_H
#define LL_LLINVENTORYOBSERVERS_H
#include "lluuid.h"
#include "llmd5.h"
#include <string>
#include <vector>
class LLViewerInventoryCategory;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryObserver
//
// A simple abstract base class that can relay messages when the inventory
// changes.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryObserver
{
public:
// This enumeration is a way to refer to what changed in a more
// human readable format. You can mask the value provided by
// chaged() to see if the observer is interested in the change.
enum
{
NONE = 0,
LABEL = 1, // name changed
INTERNAL = 2, // internal change, eg, asset uuid different
ADD = 4, // something added
REMOVE = 8, // something deleted
STRUCTURE = 16, // structural change, eg, item or folder moved
CALLING_CARD = 32, // online, grant status, cancel, etc change
ALL = 0xffffffff
};
virtual ~LLInventoryObserver() {};
virtual void changed(U32 mask) = 0;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryFetchObserver
//
// This class is much like the LLInventoryCompletionObserver, except
// that it handles all the the fetching necessary. Override the done()
// method to do the thing you want.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryFetchObserver : public LLInventoryObserver
{
public:
LLInventoryFetchObserver() {}
virtual void changed(U32 mask);
bool isEverythingComplete() const;
void fetchItems(const uuid_vec_t& ids);
virtual void done() = 0;
protected:
uuid_vec_t mComplete;
uuid_vec_t mIncomplete;
};
class LLInventoryFetchItemsObserver : public LLInventoryObserver
{
public:
LLInventoryFetchItemsObserver(const LLUUID& item_id = LLUUID::null);
LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids);
BOOL isFinished() const;
virtual void startFetch();
virtual void changed(U32 mask);
virtual void done() {};
protected:
uuid_vec_t mComplete;
uuid_vec_t mIncomplete;
uuid_vec_t mIDs;
private:
LLTimer mFetchingPeriod;
/**
* Period of waiting a notification when requested items get added into inventory.
*/
static const F32 FETCH_TIMER_EXPIRY;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryFetchDescendentsObserver
//
// This class is much like the LLInventoryCompletionObserver, except
// that it handles fetching based on category. Override the done()
// method to do the thing you want.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryFetchDescendentsObserver : public LLInventoryObserver
{
public:
LLInventoryFetchDescendentsObserver() {}
virtual void changed(U32 mask);
typedef std::vector<LLUUID> folder_ref_t;
void fetchDescendents(const folder_ref_t& ids);
bool isEverythingComplete() const;
virtual void done() = 0;
protected:
bool isComplete(LLViewerInventoryCategory* cat);
folder_ref_t mIncompleteFolders;
folder_ref_t mCompleteFolders;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryFetchComboObserver
//
// This class does an appropriate combination of fetch descendents and
// item fetches based on completion of categories and items. Much like
// the fetch and fetch descendents, this will call done() when everything
// has arrived.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryFetchComboObserver : public LLInventoryObserver
{
public:
LLInventoryFetchComboObserver() : mDone(false) {}
virtual void changed(U32 mask);
typedef std::vector<LLUUID> folder_ref_t;
typedef std::vector<LLUUID> item_ref_t;
void fetch(const folder_ref_t& folder_ids, const item_ref_t& item_ids);
virtual void done() = 0;
protected:
bool mDone;
folder_ref_t mCompleteFolders;
folder_ref_t mIncompleteFolders;
item_ref_t mCompleteItems;
item_ref_t mIncompleteItems;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryExistenceObserver
//
// This class is used as a base class for doing somethign when all the
// observed item ids exist in the inventory somewhere. You can derive
// a class from this class and implement the done() method to do
// something useful.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryExistenceObserver : public LLInventoryObserver
{
public:
LLInventoryExistenceObserver() {}
virtual void changed(U32 mask);
void watchItem(const LLUUID& id);
protected:
virtual void done() = 0;
uuid_vec_t mExist;
uuid_vec_t mMIA;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryAddedObserver
//
// This class is used as a base class for doing something when
// a new item arrives in inventory.
// It does not watch for a certain UUID, rather it acts when anything is added
// Derive a class from this class and implement the done() method to do
// something useful.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryAddedObserver : public LLInventoryObserver
{
public:
LLInventoryAddedObserver() : mAdded() {}
virtual void changed(U32 mask);
protected:
virtual void done() = 0;
typedef std::vector<LLUUID> item_ref_t;
item_ref_t mAdded;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryTransactionObserver
//
// Class which can be used as a base class for doing something when an
// inventory transaction completes.
//
// *NOTE: This class is not quite complete. Avoid using unless you fix up it's
// functionality gaps.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryTransactionObserver : public LLInventoryObserver
{
public:
LLInventoryTransactionObserver(const LLTransactionID& transaction_id);
virtual void changed(U32 mask);
protected:
typedef std::vector<LLUUID> folder_ref_t;
typedef std::vector<LLUUID> item_ref_t;
virtual void done(const folder_ref_t& folders, const item_ref_t& items) = 0;
LLTransactionID mTransactionID;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Class LLInventoryCompletionObserver
//
// Class which can be used as a base class for doing something when
// when all observed items are locally complete. This class implements
// the changed() method of LLInventoryObserver and declares a new
// method named done() which is called when all watched items have
// complete information in the inventory model.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLInventoryCompletionObserver : public LLInventoryObserver
{
public:
LLInventoryCompletionObserver() {}
virtual void changed(U32 mask);
void watchItem(const LLUUID& id);
protected:
virtual void done() = 0;
uuid_vec_t mComplete;
uuid_vec_t mIncomplete;
};
#endif // LL_LLINVENTORYOBSERVERS_H

View File

@@ -57,7 +57,7 @@
#include "llfolderview.h"
#include "llgesturemgr.h"
#include "lliconctrl.h"
#include "llinventorymodel.h"
#include "llinventoryfunctions.h"
#include "llinventoryclipboard.h"
#include "lllineeditor.h"
#include "llmenugl.h"

View File

@@ -40,6 +40,7 @@
#include "llinventory.h"
#include "llfolderview.h"
#include "llinventorymodel.h"
#include "llinventoryobserver.h"
#include "llmemberlistener.h"
#include "llcombobox.h"
#include "lluictrlfactory.h"

View File

@@ -52,6 +52,7 @@
#include "llcolorswatch.h"
#include "llcombobox.h"
#include "llfocusmgr.h"
#include "llinventoryfunctions.h"
#include "llmanipscale.h"
#include "llnotificationsutil.h"
#include "llpanelinventory.h"

View File

@@ -40,6 +40,7 @@
#include "llviewerinventory.h"
#include "lltabcontainer.h"
#include "llinventorymodel.h"
#include "llinventoryobserver.h"
#include <map>
class LLLineEditor;

View File

@@ -55,7 +55,7 @@
#include "lldelayedgestureerror.h"
#include "llfloatergesture.h" // for some label constants
#include "llgesturemgr.h"
#include "llinventorymodel.h"
#include "llinventoryfunctions.h"
#include "llkeyboard.h"
#include "lllineeditor.h"
#include "llnotificationsutil.h"
@@ -95,8 +95,8 @@ protected:
void LLInventoryGestureAvailable::done()
{
LLPreview* preview = NULL;
item_ref_t::iterator it = mComplete.begin();
item_ref_t::iterator end = mComplete.end();
uuid_vec_t::iterator it = mComplete.begin();
uuid_vec_t::iterator end = mComplete.end();
for(; it < end; ++it)
{
preview = LLPreview::find((*it));

View File

@@ -128,7 +128,7 @@
#include "llhttpclient.h"
#include "llimagebmp.h"
#include "llimview.h" // for gIMMgr
#include "llinventorymodel.h"
#include "llinventoryfunctions.h"
#include "llinventoryview.h"
#include "llkeyboard.h"
#include "llloginhandler.h" // gLoginHandler, SLURL support

View File

@@ -45,7 +45,7 @@
#include "llfocusmgr.h"
#include "llfolderview.h"
#include "llinventory.h"
#include "llinventorymodel.h"
#include "llinventoryfunctions.h"
#include "llinventoryview.h"
#include "lllineeditor.h"
#include "llui.h"

View File

@@ -52,7 +52,7 @@
#include "llhudmanager.h"
#include "llinventorybridge.h"
#include "llinventorydefines.h"
#include "llinventorymodel.h"
#include "llinventoryfunctions.h"
#include "llinventoryview.h"
#include "llmutelist.h"
#include "llnotify.h"
@@ -287,8 +287,8 @@ void LLCategoryDropObserver::done()
{
// *FIX: coalesce these...
LLInventoryItem* item = NULL;
item_ref_t::iterator it = mComplete.begin();
item_ref_t::iterator end = mComplete.end();
uuid_vec_t::iterator it = mComplete.begin();
uuid_vec_t::iterator end = mComplete.end();
for(; it < end; ++it)
{
item = gInventory.getItem(*it);
@@ -346,8 +346,8 @@ void LLCategoryDropDescendentsObserver::done()
{
unique_ids.insert(items.get(i)->getUUID());
}
LLInventoryFetchObserver::item_ref_t ids;
std::back_insert_iterator<LLInventoryFetchObserver::item_ref_t> copier(ids);
uuid_vec_t ids;
std::back_insert_iterator<uuid_vec_t> copier(ids);
std::copy(unique_ids.begin(), unique_ids.end(), copier);
LLCategoryDropObserver* dropper;
dropper = new LLCategoryDropObserver(mObjectID, mSource);
@@ -2812,7 +2812,7 @@ EAcceptance LLToolDragAndDrop::dad3dUpdateInventoryCategory(
if(drop && (ACCEPT_YES_COPY_SINGLE <= rv))
{
S32 count = items.count();
LLInventoryFetchObserver::item_ref_t ids;
uuid_vec_t ids;
for(i = 0; i < count; ++i)
{
//dropInventory(root_object, items.get(i), mSource, mSourceID);

View File

@@ -57,7 +57,7 @@
#include "llhudtext.h"
#include "llhudview.h"
#include "llinventorydefines.h"
#include "llinventorymodel.h"
#include "llinventoryobserver.h"
#include "lllandmarklist.h"
#include "llprogressview.h"
#include "llsky.h"

View File

@@ -170,7 +170,7 @@
#include "llimagej2c.h"
#include "llimagetga.h"
#include "llinventorydefines.h"
#include "llinventorymodel.h"
#include "llinventoryfunctions.h"
#include "llinventoryview.h"
#include "llkeyboard.h"
#include "llpanellogin.h"
@@ -7179,7 +7179,7 @@ class LLAttachmentEnableDrop : public view_listener_t
// if a fetch is already out there (being sent from a slow sim)
// we refetch and there are 2 fetches
LLWornItemFetchedObserver* wornItemFetched = new LLWornItemFetchedObserver();
LLInventoryFetchObserver::item_ref_t items; //add item to the inventory item to be fetched
uuid_vec_t items; //add item to the inventory item to be fetched
items.push_back((*attachment_iter)->getAttachmentItemID());

View File

@@ -1309,7 +1309,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
#endif // RLV_EXTENSION_GIVETORLV_A2A
// [/RLVa:KB]
LLInventoryFetchObserver::item_ref_t items;
uuid_vec_t items;
items.push_back(mObjectID);
LLOpenAgentOffer* open_agent_offer = new LLOpenAgentOffer(from_string);
open_agent_offer->fetchItems(items);

View File

@@ -62,6 +62,7 @@
#include "llfloaternamedesc.h"
#include "llfloatersnapshot.h"
#include "llinventorymodel.h" // gInventory
#include "llinventoryfunctions.h"
#include "llnotificationsutil.h"
#include "llresourcedata.h"
#include "llselectmgr.h"

View File

@@ -60,6 +60,7 @@
#include "llhudmanager.h"
#include "llinventorybridge.h"
#include "llinventoryview.h"
#include "llinventoryfunctions.h"
#include "llhudnametag.h"
#include "llhudtext.h" // for mText/mDebugText
#include "llkeyframefallmotion.h"

View File

@@ -46,7 +46,7 @@
#include "llassetuploadresponders.h"
#include "llviewerwindow.h"
#include "llfloatercustomize.h"
#include "llinventorymodel.h"
#include "llinventoryobserver.h"
#include "llviewertexturelist.h"
#include "llviewerinventory.h"
#include "llviewerregion.h"

View File

@@ -20,7 +20,7 @@
#include "llagent.h"
#include "llboost.h"
#include "llgesturemgr.h"
#include "llinventorymodel.h"
#include "llinventoryobserver.h"
#include "llviewerinventory.h"
#include "llvoavatar.h"
#include "llwlparamset.h"

View File

@@ -178,7 +178,7 @@ void RlvInventory::fetchWornItem(const LLUUID& idItem)
{
if (idItem.notNull())
{
LLInventoryFetchObserver::item_ref_t idItems;
uuid_vec_t idItems;
idItems.push_back(idItem);
RlvItemFetcher itemFetcher;
itemFetcher.fetchItems(idItems);

View File

@@ -19,6 +19,7 @@
#include "llmemory.h"
#include "llviewerinventory.h"
#include "llinventoryfunctions.h"
#include "rlvhelper.h"
#include "rlvlocks.h"

View File

@@ -27,181 +27,3 @@
#include "rlvviewer2.h"
// ============================================================================
// From llinventoryobserver.cpp
void fetch_items_from_llsd(const LLSD& items_llsd);
const F32 LLInventoryFetchItemsObserver::FETCH_TIMER_EXPIRY = 60.0f;
LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const LLUUID& item_id)
{
mIDs.clear();
if (item_id != LLUUID::null)
{
mIDs.push_back(item_id);
}
}
LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids)
: mIDs(item_ids)
{
}
BOOL LLInventoryFetchItemsObserver::isFinished() const
{
return mIncomplete.empty();
}
void LLInventoryFetchItemsObserver::changed(U32 mask)
{
lldebugs << this << " remaining incomplete " << mIncomplete.size()
<< " complete " << mComplete.size()
<< " wait period " << mFetchingPeriod.getRemainingTimeF32()
<< llendl;
// scan through the incomplete items and move or erase them as
// appropriate.
if (!mIncomplete.empty())
{
// Have we exceeded max wait time?
bool timeout_expired = mFetchingPeriod.hasExpired();
for (uuid_vec_t::iterator it = mIncomplete.begin(); it < mIncomplete.end(); )
{
const LLUUID& item_id = (*it);
LLViewerInventoryItem* item = gInventory.getItem(item_id);
if (item && item->isComplete())
{
mComplete.push_back(item_id);
it = mIncomplete.erase(it);
}
else
{
if (timeout_expired)
{
// Just concede that this item hasn't arrived in reasonable time and continue on.
llwarns << "Fetcher timed out when fetching inventory item UUID: " << item_id << LL_ENDL;
it = mIncomplete.erase(it);
}
else
{
// Keep trying.
++it;
}
}
}
}
if (mIncomplete.empty())
{
lldebugs << this << " done at remaining incomplete "
<< mIncomplete.size() << " complete " << mComplete.size() << llendl;
done();
}
//llinfos << "LLInventoryFetchItemsObserver::changed() mComplete size " << mComplete.size() << llendl;
//llinfos << "LLInventoryFetchItemsObserver::changed() mIncomplete size " << mIncomplete.size() << llendl;
}
void LLInventoryFetchItemsObserver::startFetch()
{
LLUUID owner_id;
LLSD items_llsd;
for (uuid_vec_t::const_iterator it = mIDs.begin(); it < mIDs.end(); ++it)
{
LLViewerInventoryItem* item = gInventory.getItem(*it);
if (item)
{
if (item->isComplete())
{
// It's complete, so put it on the complete container.
mComplete.push_back(*it);
continue;
}
else
{
owner_id = item->getPermissions().getOwner();
}
}
else
{
// assume it's agent inventory.
owner_id = gAgent.getID();
}
// Ignore categories since they're not items. We
// could also just add this to mComplete but not sure what the
// side-effects would be, so ignoring to be safe.
LLViewerInventoryCategory* cat = gInventory.getCategory(*it);
if (cat)
{
continue;
}
// It's incomplete, so put it on the incomplete container, and
// pack this on the message.
mIncomplete.push_back(*it);
// Prepare the data to fetch
LLSD item_entry;
item_entry["owner_id"] = owner_id;
item_entry["item_id"] = (*it);
items_llsd.append(item_entry);
}
mFetchingPeriod.reset();
mFetchingPeriod.setTimerExpirySec(FETCH_TIMER_EXPIRY);
fetch_items_from_llsd(items_llsd);
}
// ============================================================================
// From llinventoryfunctions.cpp
void change_item_parent(LLInventoryModel* model, LLViewerInventoryItem* item, const LLUUID& new_parent_id, BOOL restamp)
{
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);
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();
}
// ============================================================================

View File

@@ -25,43 +25,9 @@
#define RLV_VIEWER2_H
#include "llcallbacklist.h"
#include "llinventorymodel.h"
#include "boost/function.hpp"
// ============================================================================
// From llinventoryobserver.h
class LLInventoryFetchItemsObserver : public LLInventoryObserver
{
public:
LLInventoryFetchItemsObserver(const LLUUID& item_id = LLUUID::null);
LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids);
BOOL isFinished() const;
virtual void startFetch();
virtual void changed(U32 mask);
virtual void done() {};
protected:
uuid_vec_t mComplete;
uuid_vec_t mIncomplete;
uuid_vec_t mIDs;
private:
LLTimer mFetchingPeriod;
/**
* Period of waiting a notification when requested items get added into inventory.
*/
static const F32 FETCH_TIMER_EXPIRY;
};
// ============================================================================
// From llinventoryfunctions.cpp
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);
// ============================================================================
#endif // RLV_VIEWER2_H

View File

@@ -32,6 +32,7 @@
#include "aifetchinventoryfolder.h"
#include "aievent.h"
#include "llagent.h"
#include "llinventoryobserver.h"
enum fetchinventoryfolder_state_type {
AIFetchInventoryFolder_checkFolderExists = AIStateMachine::max_state,