From 39d83cb74f5978e926ff02dcb20a64802429bc69 Mon Sep 17 00:00:00 2001 From: Seth ProductEngine Date: Fri, 18 Mar 2011 00:28:48 +0200 Subject: STORM-1086 FIXED Agent's own calling card created on startup is placed into Calling Cards folder. If there is an agent's calling card found within Calling Cards and sub-folders no more copies of this calling card are created. --- indra/newview/llfriendcard.cpp | 52 +++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 16 deletions(-) (limited to 'indra/newview/llfriendcard.cpp') diff --git a/indra/newview/llfriendcard.cpp b/indra/newview/llfriendcard.cpp index 70e789f490..11401d6c68 100644 --- a/indra/newview/llfriendcard.cpp +++ b/indra/newview/llfriendcard.cpp @@ -95,6 +95,36 @@ const LLUUID& get_folder_uuid(const LLUUID& parentFolderUUID, LLInventoryCollect return (cats_count >= 1) ? cats.get(0)->getUUID() : LLUUID::null; } +/** + * Class LLFindAgentCallingCard + * + * An inventory collector functor for checking that agent's own calling card + * exists within the Calling Cards category and its sub-folders. + */ +class LLFindAgentCallingCard : public LLInventoryCollectFunctor +{ +public: + LLFindAgentCallingCard() : mIsAgentCallingCardFound(false) {} + virtual ~LLFindAgentCallingCard() {} + virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item); + bool isAgentCallingCardFound() { return mIsAgentCallingCardFound; } + +private: + bool mIsAgentCallingCardFound; +}; + +bool LLFindAgentCallingCard::operator()(LLInventoryCategory* cat, LLInventoryItem* item) +{ + if (mIsAgentCallingCardFound) return true; + + if (item && item->getType() == LLAssetType::AT_CALLINGCARD && item->getCreatorUUID() == gAgentID) + { + mIsAgentCallingCardFound = true; + } + + return mIsAgentCallingCardFound; +} + /** * Class for fetching initial friend cards data * @@ -449,32 +479,22 @@ void LLFriendCardsManager::syncFriendsFolder() LLAvatarTracker::instance().copyBuddyList(all_buddies); // 1. Check if own calling card exists + const LLUUID calling_cards_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CALLINGCARD); + LLInventoryModel::cat_array_t cats; LLInventoryModel::item_array_t items; - - LLUUID friends_all_folder_id = findFriendAllSubfolderUUIDImpl(); - gInventory.collectDescendents(friends_all_folder_id, cats, items, LLInventoryModel::EXCLUDE_TRASH); - - bool own_callingcard_found = false; - LLInventoryModel::item_array_t::const_iterator it; - for (it = items.begin(); it != items.end(); ++it) - { - if ((*it)->getCreatorUUID() == gAgentID) - { - own_callingcard_found = true; - break; - } - } + LLFindAgentCallingCard collector; + gInventory.collectDescendentsIf(calling_cards_folder_id, cats, items, LLInventoryModel::EXCLUDE_TRASH, collector); // Create own calling card if it was not found in Friends/All folder - if (!own_callingcard_found) + if (!collector.isAgentCallingCardFound()) { LLAvatarName av_name; LLAvatarNameCache::get( gAgentID, &av_name ); create_inventory_item(gAgentID, gAgent.getSessionID(), - friends_all_folder_id, + calling_cards_folder_id, LLTransactionID::tnull, av_name.getCompleteName(), gAgentID.asString(), -- cgit v1.2.3