summaryrefslogtreecommitdiff
path: root/indra/newview/llfriendcard.cpp
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2011-03-09 11:24:54 -0500
committerLoren Shih <seraph@lindenlab.com>2011-03-09 11:24:54 -0500
commitc8293e29caf4701f130141a88b90709a09143d4e (patch)
treefc84848355f3c5d21e3fd6dd1ba2c5eade2d8c03 /indra/newview/llfriendcard.cpp
parent94b0ce6d842a1f34bd46535a8b4db68aa397a541 (diff)
parent76a325b83271424d231561d8ef099df1406c9517 (diff)
Automated merge up from viewer-development into mesh-development
Diffstat (limited to 'indra/newview/llfriendcard.cpp')
-rw-r--r--indra/newview/llfriendcard.cpp85
1 files changed, 27 insertions, 58 deletions
diff --git a/indra/newview/llfriendcard.cpp b/indra/newview/llfriendcard.cpp
index e9f1e3bc22..70e789f490 100644
--- a/indra/newview/llfriendcard.cpp
+++ b/indra/newview/llfriendcard.cpp
@@ -28,6 +28,7 @@
#include "llfriendcard.h"
+#include "llagent.h"
#include "llavatarnamecache.h"
#include "llinventory.h"
#include "llinventoryfunctions.h"
@@ -290,58 +291,6 @@ void LLFriendCardsManager::syncFriendCardsFolders()
boost::bind(&LLFriendCardsManager::ensureFriendsFolderExists, this));
}
-void LLFriendCardsManager::collectFriendsLists(folderid_buddies_map_t& folderBuddiesMap) const
-{
- folderBuddiesMap.clear();
-
- static bool syncronize_friends_folders = true;
- if (syncronize_friends_folders)
- {
- // Checks whether "Friends" and "Friends/All" folders exist in "Calling Cards" folder,
- // fetches their contents if needed and synchronizes it with buddies list.
- // If the folders are not found they are created.
- LLFriendCardsManager::instance().syncFriendCardsFolders();
- syncronize_friends_folders = false;
- }
-
-
- LLInventoryModel::cat_array_t* listFolders;
- LLInventoryModel::item_array_t* items;
-
- // get folders in the Friend folder. Items should be NULL due to Cards should be in lists.
- gInventory.getDirectDescendentsOf(findFriendFolderUUIDImpl(), listFolders, items);
-
- if (NULL == listFolders)
- return;
-
- LLInventoryModel::cat_array_t::const_iterator itCats; // to iterate Friend Lists (categories)
- LLInventoryModel::item_array_t::const_iterator itBuddy; // to iterate Buddies in each List
- LLInventoryModel::cat_array_t* fakeCatsArg;
- for (itCats = listFolders->begin(); itCats != listFolders->end(); ++itCats)
- {
- if (items)
- items->clear();
-
- // *HACK: Only Friends/All content will be shown for now
- // *TODO: Remove this hack, implement sorting if it will be needded by spec.
- if ((*itCats)->getUUID() != findFriendAllSubfolderUUIDImpl())
- continue;
-
- gInventory.getDirectDescendentsOf((*itCats)->getUUID(), fakeCatsArg, items);
-
- if (NULL == items)
- continue;
-
- uuid_vec_t buddyUUIDs;
- for (itBuddy = items->begin(); itBuddy != items->end(); ++itBuddy)
- {
- buddyUUIDs.push_back((*itBuddy)->getCreatorUUID());
- }
-
- folderBuddiesMap.insert(make_pair((*itCats)->getUUID(), buddyUUIDs));
- }
-}
-
/************************************************************************/
/* Private Methods */
@@ -499,23 +448,43 @@ void LLFriendCardsManager::syncFriendsFolder()
LLAvatarTracker::buddy_map_t all_buddies;
LLAvatarTracker::instance().copyBuddyList(all_buddies);
- // 1. Remove Friend Cards for non-friends
+ // 1. Check if own calling card exists
LLInventoryModel::cat_array_t cats;
LLInventoryModel::item_array_t items;
- gInventory.collectDescendents(findFriendAllSubfolderUUIDImpl(), cats, items, LLInventoryModel::EXCLUDE_TRASH);
+ 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)
{
- lldebugs << "Check if buddy is in list: " << (*it)->getName() << " " << (*it)->getCreatorUUID() << llendl;
- if (NULL == get_ptr_in_map(all_buddies, (*it)->getCreatorUUID()))
+ if ((*it)->getCreatorUUID() == gAgentID)
{
- lldebugs << "NONEXISTS, so remove it" << llendl;
- removeFriendCardFromInventory((*it)->getCreatorUUID());
+ own_callingcard_found = true;
+ break;
}
}
+ // Create own calling card if it was not found in Friends/All folder
+ if (!own_callingcard_found)
+ {
+ LLAvatarName av_name;
+ LLAvatarNameCache::get( gAgentID, &av_name );
+
+ create_inventory_item(gAgentID,
+ gAgent.getSessionID(),
+ friends_all_folder_id,
+ LLTransactionID::tnull,
+ av_name.getCompleteName(),
+ gAgentID.asString(),
+ LLAssetType::AT_CALLINGCARD,
+ LLInventoryType::IT_CALLINGCARD,
+ NOT_WEARABLE,
+ PERM_MOVE | PERM_TRANSFER,
+ NULL);
+ }
+
// 2. Add missing Friend Cards for friends
LLAvatarTracker::buddy_map_t::const_iterator buddy_it = all_buddies.begin();
llinfos << "try to build friends, count: " << all_buddies.size() << llendl;