summaryrefslogtreecommitdiff
path: root/indra/newview/llfriendcard.cpp
diff options
context:
space:
mode:
authorleyla <leyla@leyla.com>2011-03-14 11:28:13 -0700
committerleyla <leyla@leyla.com>2011-03-14 11:28:13 -0700
commitc762beed267115b7670e01219ccff4fc64bdca4c (patch)
tree8ee42a8defd3bae58759a9dd3517385d830c52b8 /indra/newview/llfriendcard.cpp
parentbc2aca863f5d27f551e48a2de8f879360a3a96ab (diff)
parent405a748746c8ea040fe0efeda54e58f378289795 (diff)
Merge
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;