summaryrefslogtreecommitdiff
path: root/indra/newview/llfriendcard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfriendcard.cpp')
-rw-r--r--indra/newview/llfriendcard.cpp71
1 files changed, 70 insertions, 1 deletions
diff --git a/indra/newview/llfriendcard.cpp b/indra/newview/llfriendcard.cpp
index fbcaeee01f..724b18ded2 100644
--- a/indra/newview/llfriendcard.cpp
+++ b/indra/newview/llfriendcard.cpp
@@ -91,8 +91,44 @@ const LLUUID& get_folder_uuid(const LLUUID& parentFolderUUID, LLInventoryCollect
return LLUUID::null;
}
+
+// LLViewerInventoryCategory::fetchDescendents has it own period of fetching.
+// for now it is FETCH_TIMER_EXPIRY = 10.0f; So made our period a bit more.
+const F32 FETCH_FRIENDS_DESCENDENTS_PERIOD = 11.0f;
+
+
+/**
+ * Intended to call passed callback after the specified period of time.
+ *
+ * Implemented to fix an issue when Inventory folders are in incomplete state. See EXT-2061, EXT-1935, EXT-813.
+ * For now it uses to periodically sync Inventory Friends/All folder with a Agent's Friends List
+ * until it is complete.
+ */
+class FriendListUpdater : public LLEventTimer
+{
+public:
+ typedef boost::function<bool()> callback_t;
+
+ FriendListUpdater(callback_t cb, F32 period)
+ : LLEventTimer(period)
+ , mCallback(cb)
+ {
+ mEventTimer.start();
+ }
+
+ virtual BOOL tick() // from LLEventTimer
+ {
+ return mCallback();
+ }
+
+private:
+ callback_t mCallback;
+};
+
+
// LLFriendCardsManager Constructor / Destructor
LLFriendCardsManager::LLFriendCardsManager()
+: mFriendsAllFolderCompleted(true)
{
LLAvatarTracker::instance().addObserver(this);
}
@@ -269,7 +305,7 @@ bool LLFriendCardsManager::isAnyFriendCategory(const LLUUID& catID) const
return TRUE == gInventory.isObjectDescendentOf(catID, friendFolderID);
}
-void LLFriendCardsManager::syncFriendsFolder()
+bool LLFriendCardsManager::syncFriendsFolder()
{
//lets create "Friends" and "Friends/All" in the Inventory "Calling Cards" if they are absent
LLFriendCardsManager::instance().ensureFriendFoldersExist();
@@ -297,11 +333,35 @@ void LLFriendCardsManager::syncFriendsFolder()
// 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;
+ mFriendsAllFolderCompleted = true;
for(; buddy_it != all_buddies.end(); ++buddy_it)
{
const LLUUID& buddy_id = (*buddy_it).first;
addFriendCardToInventory(buddy_id);
}
+
+ if (!mFriendsAllFolderCompleted)
+ {
+ forceFriendListIsLoaded(findFriendAllSubfolderUUIDImpl());
+
+ static bool timer_started = false;
+ if (!timer_started)
+ {
+ lldebugs << "Create and start timer to sync Inventory Friends All folder with Friends list" << llendl;
+
+ // do not worry about destruction of the FriendListUpdater.
+ // It will be deleted by LLEventTimer::updateClass when FriendListUpdater::tick() returns true.
+ new FriendListUpdater(boost::bind(&LLFriendCardsManager::syncFriendsFolder, this),
+ FETCH_FRIENDS_DESCENDENTS_PERIOD);
+ }
+ timer_started = true;
+ }
+ else
+ {
+ lldebugs << "Friends/All Inventory folder is synchronized with the Agent's Friends List" << llendl;
+ }
+
+ return mFriendsAllFolderCompleted;
}
void LLFriendCardsManager::collectFriendsLists(folderid_buddies_map_t& folderBuddiesMap) const
@@ -461,7 +521,9 @@ bool LLFriendCardsManager::addFriendCardToInventory(const LLUUID& avatarID)
LLUUID friendListFolderID = findFriendAllSubfolderUUIDImpl();
if (shouldBeAdded && !invModel->isCategoryComplete(friendListFolderID))
{
+ mFriendsAllFolderCompleted = false;
shouldBeAdded = false;
+ lldebugs << "Friends/All category is not completed" << llendl;
}
if (shouldBeAdded)
{
@@ -520,4 +582,11 @@ void LLFriendCardsManager::onFriendListUpdate(U32 changed_mask)
}
}
+void LLFriendCardsManager::forceFriendListIsLoaded(const LLUUID& folder_id) const
+{
+ bool fetching_inventory = gInventory.fetchDescendentsOf(folder_id);
+ lldebugs << "Trying to fetch descendants of Friends/All Inventory folder, fetched: "
+ << fetching_inventory << llendl;
+}
+
// EOF