summaryrefslogtreecommitdiff
path: root/indra/newview/llparticipantlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llparticipantlist.cpp')
-rw-r--r--indra/newview/llparticipantlist.cpp343
1 files changed, 4 insertions, 339 deletions
diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp
index e199cb5776..9a4d1166db 100644
--- a/indra/newview/llparticipantlist.cpp
+++ b/indra/newview/llparticipantlist.cpp
@@ -1,6 +1,6 @@
/**
* @file llparticipantlist.cpp
- * @brief LLParticipantList intended to update view(LLAvatarList) according to incoming messages
+ * @brief LLParticipantList : model of a conversation session with added speaker events handling
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -26,45 +26,17 @@
#include "llviewerprecompiledheaders.h"
-// common includes
-#include "lltrans.h"
-#include "llavataractions.h"
#include "llavatarnamecache.h"
-#include "llavatarname.h"
-#include "llagent.h"
-
#include "llimview.h"
#include "llimfloatercontainer.h"
-#include "llpanelpeoplemenus.h"
-#include "llnotificationsutil.h"
#include "llparticipantlist.h"
#include "llspeakers.h"
-#include "llviewercontrol.h"
-#include "llviewermenu.h"
-#include "llvoiceclient.h"
//LLParticipantList retrieves add, clear and remove events and updates view accordingly
#if LL_MSVC
#pragma warning (disable : 4355) // 'this' used in initializer list: yes, intentionally
#endif
-static const LLAvatarItemAgentOnTopComparator AGENT_ON_TOP_NAME_COMPARATOR;
-
-// helper function to update AvatarList Item's indicator in the voice participant list
-static void update_speaker_indicator(const LLAvatarList* const avatar_list, const LLUUID& avatar_uuid, bool is_muted)
-{
- if (avatar_list)
- {
- LLAvatarListItem* item = dynamic_cast<LLAvatarListItem*>(avatar_list->getItemByValue(avatar_uuid));
- if (item)
- {
- LLOutputMonitorCtrl* indicator = item->getChild<LLOutputMonitorCtrl>("speaking_indicator");
- indicator->setIsMuted(is_muted);
- }
- }
-}
-
-
// See EXT-4301.
/**
* class LLAvalineUpdater - observe the list of voice participants in session and check
@@ -204,16 +176,9 @@ private:
uuid_set_t mAvalineCallers;
};
-LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source,
- LLAvatarList* avatar_list,
- LLFolderViewModelInterface& root_view_model,
- bool use_context_menu/* = true*/,
- bool exclude_agent /*= true*/,
- bool can_toggle_icons /*= true*/) :
+LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, LLFolderViewModelInterface& root_view_model) :
LLConversationItemSession(data_source->getSessionID(), root_view_model),
mSpeakerMgr(data_source),
- mAvatarList(avatar_list),
- mExcludeAgent(exclude_agent),
mValidateSpeakerCallback(NULL)
{
@@ -234,32 +199,6 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source,
mSpeakerMgr->addListener(mSpeakerUpdateListener, "update_speaker");
setSessionID(mSpeakerMgr->getSessionID());
-
- if (mAvatarList)
- {
- mAvatarList->setNoItemsCommentText(LLTrans::getString("LoadingData"));
- LL_DEBUGS("SpeakingIndicator") << "Set session for speaking indicators: " << mSpeakerMgr->getSessionID() << LL_ENDL;
- mAvatarList->setSessionID(mSpeakerMgr->getSessionID());
- mAvatarListDoubleClickConnection = mAvatarList->setItemDoubleClickCallback(boost::bind(&LLParticipantList::onAvatarListDoubleClicked, this, _1));
- mAvatarListRefreshConnection = mAvatarList->setRefreshCompleteCallback(boost::bind(&LLParticipantList::onAvatarListRefreshed, this, _1, _2));
- // Set onAvatarListDoubleClicked as default on_return action.
- mAvatarListReturnConnection = mAvatarList->setReturnCallback(boost::bind(&LLParticipantList::onAvatarListDoubleClicked, this, mAvatarList));
-
- if (use_context_menu)
- {
- mAvatarList->setContextMenu(&LLPanelPeopleMenus::gNearbyMenu);
- }
- else
- {
- mAvatarList->setContextMenu(NULL);
- }
-
- if (use_context_menu && can_toggle_icons)
- {
- mAvatarList->setShowIcons("ParticipantListShowIcons");
- mAvatarListToggleIconsConnection = gSavedSettings.getControl("ParticipantListShowIcons")->getSignal()->connect(boost::bind(&LLAvatarList::toggleIcons, mAvatarList));
- }
- }
//Lets fill avatarList with existing speakers
LLSpeakerMgr::speaker_list_t speaker_list;
@@ -278,8 +217,6 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source,
mModeratorToRemoveList.insert(speakerp->mID);
}
}
- // we need to exclude agent id for non group chat
- sort();
// Identify and store what kind of session we are
LLIMModel::LLIMSession* im_session = LLIMModel::getInstance()->findIMSession(data_source->getSessionID());
@@ -305,129 +242,9 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source,
LLParticipantList::~LLParticipantList()
{
- if (mAvatarList)
- {
- mAvatarListDoubleClickConnection.disconnect();
- mAvatarListRefreshConnection.disconnect();
- mAvatarListReturnConnection.disconnect();
- mAvatarListToggleIconsConnection.disconnect();
- }
-
- if (mAvatarList)
- {
- mAvatarList->setContextMenu(NULL);
- mAvatarList->setComparator(NULL);
- }
-
delete mAvalineUpdater;
}
-void LLParticipantList::setSpeakingIndicatorsVisible(BOOL visible)
-{
- if (mAvatarList)
- {
- mAvatarList->setSpeakingIndicatorsVisible(visible);
- }
-}
-
-void LLParticipantList::onAvatarListDoubleClicked(LLUICtrl* ctrl)
-{
- LLAvatarListItem* item = dynamic_cast<LLAvatarListItem*>(ctrl);
- if(!item)
- {
- return;
- }
-
- LLUUID clicked_id = item->getAvatarId();
-
- if (clicked_id.isNull() || clicked_id == gAgent.getID())
- return;
-
- LLAvatarActions::startIM(clicked_id);
-}
-
-void LLParticipantList::onAvatarListRefreshed(LLUICtrl* ctrl, const LLSD& param)
-{
- LLAvatarList* list = dynamic_cast<LLAvatarList*>(ctrl);
- const std::string moderator_indicator(LLTrans::getString("IM_moderator_label"));
- const std::size_t moderator_indicator_len = moderator_indicator.length();
-
- // Firstly remove moderators indicator
- std::set<LLUUID>::const_iterator
- moderator_list_it = mModeratorToRemoveList.begin(),
- moderator_list_end = mModeratorToRemoveList.end();
- for (;moderator_list_it != moderator_list_end; ++moderator_list_it)
- {
- LLAvatarListItem* item = (list ? dynamic_cast<LLAvatarListItem*> (list->getItemByValue(*moderator_list_it)) : NULL);
- if ( item )
- {
- std::string name = item->getAvatarName();
- std::string tooltip = item->getAvatarToolTip();
- size_t found = name.find(moderator_indicator);
- if (found != std::string::npos)
- {
- name.erase(found, moderator_indicator_len);
- item->setAvatarName(name);
- }
- found = tooltip.find(moderator_indicator);
- if (found != tooltip.npos)
- {
- tooltip.erase(found, moderator_indicator_len);
- item->setAvatarToolTip(tooltip);
- }
- }
- setParticipantIsModerator(*moderator_list_it,false);
- }
-
- mModeratorToRemoveList.clear();
-
- // Add moderators indicator
- moderator_list_it = mModeratorList.begin();
- moderator_list_end = mModeratorList.end();
- for (;moderator_list_it != moderator_list_end; ++moderator_list_it)
- {
- LLAvatarListItem* item = (list ? dynamic_cast<LLAvatarListItem*> (list->getItemByValue(*moderator_list_it)) : NULL);
- if ( item )
- {
- std::string name = item->getAvatarName();
- std::string tooltip = item->getAvatarToolTip();
- size_t found = name.find(moderator_indicator);
- if (found == std::string::npos)
- {
- name += " ";
- name += moderator_indicator;
- item->setAvatarName(name);
- }
- found = tooltip.find(moderator_indicator);
- if (found == std::string::npos)
- {
- tooltip += " ";
- tooltip += moderator_indicator;
- item->setAvatarToolTip(tooltip);
- }
- }
- setParticipantIsModerator(*moderator_list_it,true);
- }
-
- // update voice mute state of all items. See EXT-7235
- LLSpeakerMgr::speaker_list_t speaker_list;
-
- // Use also participants which are not in voice session now (the second arg is TRUE).
- // They can already have mModeratorMutedVoice set from the previous voice session
- // and LLSpeakerVoiceModerationEvent will not be sent when speaker manager is updated next time.
- mSpeakerMgr->getSpeakerList(&speaker_list, TRUE);
- for(LLSpeakerMgr::speaker_list_t::iterator it = speaker_list.begin(); it != speaker_list.end(); it++)
- {
- const LLPointer<LLSpeaker>& speakerp = *it;
-
- if (speakerp->mStatus == LLSpeaker::STATUS_TEXT_ONLY)
- {
- setParticipantIsMuted(speakerp->mID, speakerp->mModeratorMutedVoice);
- update_speaker_indicator(list, speakerp->mID, speakerp->mModeratorMutedVoice);
- }
- }
-}
-
/*
Seems this method is not necessary after onAvalineCallerRemoved was implemented;
@@ -441,40 +258,11 @@ void LLParticipantList::onAvatarListRefreshed(LLUICtrl* ctrl, const LLSD& param)
*/
void LLParticipantList::onAvalineCallerFound(const LLUUID& participant_id)
{
- if (mAvatarList)
- {
- LLPanel* item = mAvatarList->getItemByValue(participant_id);
-
- if (NULL == item)
- {
- LL_WARNS("Avaline") << "Something wrong. Unable to find item for: " << participant_id << LL_ENDL;
- return;
- }
-
- if (typeid(*item) == typeid(LLAvalineListItem))
- {
- LL_DEBUGS("Avaline") << "Avaline caller has already correct class type for: " << participant_id << LL_ENDL;
- // item representing an Avaline caller has a correct type already.
- return;
- }
-
- LL_DEBUGS("Avaline") << "remove item from the list and re-add it: " << participant_id << LL_ENDL;
-
- // remove UUID from LLAvatarList::mIDs to be able add it again.
- uuid_vec_t& ids = mAvatarList->getIDs();
- uuid_vec_t::iterator pos = std::find(ids.begin(), ids.end(), participant_id);
- ids.erase(pos);
-
- // remove item directly
- mAvatarList->removeItem(item);
- }
-
LLConversationItemParticipant* participant = findParticipant(participant_id);
if (participant)
{
removeParticipant(participant);
}
-
// re-add avaline caller with a correct class instance.
addAvatarIDExceptAgent(participant_id);
}
@@ -486,23 +274,6 @@ void LLParticipantList::onAvalineCallerRemoved(const LLUUID& participant_id)
mSpeakerMgr->removeAvalineSpeaker(participant_id);
}
-void LLParticipantList::setSortOrder(EParticipantSortOrder order)
-{
- const U32 speaker_sort_order = gSavedSettings.getU32("SpeakerParticipantDefaultOrder");
-
- if ( speaker_sort_order != order )
- {
- gSavedSettings.setU32("SpeakerParticipantDefaultOrder", (U32)order);
- sort();
- }
-}
-
-const LLParticipantList::EParticipantSortOrder LLParticipantList::getSortOrder() const
-{
- const U32 speaker_sort_order = gSavedSettings.getU32("SpeakerParticipantDefaultOrder");
- return EParticipantSortOrder(speaker_sort_order);
-}
-
void LLParticipantList::setValidateSpeakerCallback(validate_speaker_callback_t cb)
{
mValidateSpeakerCallback = cb;
@@ -511,20 +282,6 @@ void LLParticipantList::setValidateSpeakerCallback(validate_speaker_callback_t c
void LLParticipantList::update()
{
mSpeakerMgr->update(true);
-
- // Need to resort the participant list if it's in sort by recent speaker order.
- if (E_SORT_BY_RECENT_SPEAKERS == getSortOrder() && !isHovered())
- {
- // Resort avatar list
- sort();
- }
-}
-
-bool LLParticipantList::isHovered()
-{
- S32 x, y;
- LLUI::getMousePositionScreen(&x, &y);
- return (mAvatarList ? mAvatarList->calcScreenRect().pointInRect(x, y) : false);
}
bool LLParticipantList::onAddItemEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata)
@@ -537,35 +294,18 @@ bool LLParticipantList::onAddItemEvent(LLPointer<LLOldEvents::LLEvent> event, co
}
addAvatarIDExceptAgent(uu_id);
- sort();
return true;
}
bool LLParticipantList::onRemoveItemEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata)
{
LLUUID avatar_id = event->getValue().asUUID();
- if (mAvatarList)
- {
- uuid_vec_t& group_members = mAvatarList->getIDs();
- uuid_vec_t::iterator pos = std::find(group_members.begin(), group_members.end(), avatar_id);
- if(pos != group_members.end())
- {
- group_members.erase(pos);
- mAvatarList->setDirty();
- }
- }
removeParticipant(avatar_id);
return true;
}
bool LLParticipantList::onClearListEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata)
{
- if (mAvatarList)
- {
- uuid_vec_t& group_members = mAvatarList->getIDs();
- group_members.clear();
- mAvatarList->setDirty();
- }
clearParticipants();
return true;
}
@@ -605,9 +345,7 @@ bool LLParticipantList::onModeratorUpdateEvent(LLPointer<LLOldEvents::LLEvent> e
mModeratorList.erase(id);
}
}
-
- // apply changes immediately
- onAvatarListRefreshed(mAvatarList, LLSD());
+ // *TODO : do we have to fire an event so that LLIMConversation::refreshConversation() gets called
}
}
return true;
@@ -622,48 +360,13 @@ bool LLParticipantList::onSpeakerMuteEvent(LLPointer<LLOldEvents::LLEvent> event
if (event->getValue().asString() == "voice")
{
setParticipantIsMuted(speakerp->mID, speakerp->mModeratorMutedVoice);
- update_speaker_indicator(mAvatarList, speakerp->mID, speakerp->mModeratorMutedVoice);
}
return true;
}
-void LLParticipantList::sort()
-{
- // *TODO : Merov : Need to plan for sort() for LLConversationModel
- if ( !mAvatarList )
- return;
-
- switch ( getSortOrder() )
- {
- case E_SORT_BY_NAME :
- // if mExcludeAgent == true , then no need to keep agent on top of the list
- if(mExcludeAgent)
- {
- mAvatarList->sortByName();
- }
- else
- {
- mAvatarList->setComparator(&AGENT_ON_TOP_NAME_COMPARATOR);
- mAvatarList->sort();
- }
- break;
- case E_SORT_BY_RECENT_SPEAKERS:
- if (mSortByRecentSpeakers.isNull())
- mSortByRecentSpeakers = new LLAvatarItemRecentSpeakerComparator(*this);
- mAvatarList->setComparator(mSortByRecentSpeakers.get());
- mAvatarList->sort();
- break;
- default :
- llwarns << "Unrecognized sort order for " << mAvatarList->getName() << llendl;
- return;
- }
-}
-
void LLParticipantList::addAvatarIDExceptAgent(const LLUUID& avatar_id)
{
// Do not add if already in there or excluded for some reason
- if (mExcludeAgent && gAgent.getID() == avatar_id) return;
- if (mAvatarList && mAvatarList->contains(avatar_id)) return;
if (findParticipant(avatar_id)) return;
bool is_avatar = LLVoiceClient::getInstance()->isParticipantAvatar(avatar_id);
@@ -677,25 +380,16 @@ void LLParticipantList::addAvatarIDExceptAgent(const LLUUID& avatar_id)
bool has_name = LLAvatarNameCache::get(avatar_id, &avatar_name);
participant = new LLConversationItemParticipant(!has_name ? LLTrans::getString("AvatarNameWaiting") : avatar_name.mDisplayName , avatar_id, mRootViewModel);
participant->fetchAvatarName();
- if (mAvatarList)
- {
- mAvatarList->getIDs().push_back(avatar_id);
- mAvatarList->setDirty();
- }
}
else
{
std::string display_name = LLVoiceClient::getInstance()->getDisplayName(avatar_id);
// Create a participant view model instance
participant = new LLConversationItemParticipant(display_name.empty() ? LLTrans::getString("AvatarNameWaiting") : display_name, avatar_id, mRootViewModel);
- if (mAvatarList)
- {
- mAvatarList->addAvalineItem(avatar_id, mSpeakerMgr->getSessionID(), display_name.empty() ? LLTrans::getString("AvatarNameWaiting") : display_name);
- }
mAvalineUpdater->watchAvalineCaller(avatar_id);
}
- // *TODO : Merov : need to update the online/offline status of the participant.
+ // *TODO : Need to update the online/offline status of the participant
// Hack for this: LLAvatarTracker::instance().isBuddyOnline(avatar_id))
// Add the participant model to the session's children list
@@ -768,33 +462,4 @@ bool LLParticipantList::SpeakerMuteListener::handleEvent(LLPointer<LLOldEvents::
return mParent.onSpeakerMuteEvent(event, userdata);
}
-bool LLParticipantList::LLAvatarItemRecentSpeakerComparator::doCompare(const LLAvatarListItem* avatar_item1, const LLAvatarListItem* avatar_item2) const
-{
- if (mParent.mSpeakerMgr)
- {
- LLPointer<LLSpeaker> lhs = mParent.mSpeakerMgr->findSpeaker(avatar_item1->getAvatarId());
- LLPointer<LLSpeaker> rhs = mParent.mSpeakerMgr->findSpeaker(avatar_item2->getAvatarId());
- if ( lhs.notNull() && rhs.notNull() )
- {
- // Compare by last speaking time
- if( lhs->mLastSpokeTime != rhs->mLastSpokeTime )
- return ( lhs->mLastSpokeTime > rhs->mLastSpokeTime );
- else if ( lhs->mSortIndex != rhs->mSortIndex )
- return ( lhs->mSortIndex < rhs->mSortIndex );
- }
- else if ( lhs.notNull() )
- {
- // True if only avatar_item1 speaker info available
- return true;
- }
- else if ( rhs.notNull() )
- {
- // False if only avatar_item2 speaker info available
- return false;
- }
- }
- // By default compare by name.
- return LLAvatarItemNameComparator::doCompare(avatar_item1, avatar_item2);
-}
-
//EOF