summaryrefslogtreecommitdiff
path: root/indra/newview/llparticipantlist.cpp
diff options
context:
space:
mode:
authorSteve Bennetts <steve@lindenlab.com>2009-11-10 17:52:28 -0800
committerSteve Bennetts <steve@lindenlab.com>2009-11-10 17:52:28 -0800
commit98ca90bed46591573f5072121a774d19cc69381f (patch)
treee11d8e8b4459b8513c0495f76932c71385b1e062 /indra/newview/llparticipantlist.cpp
parent04eaf3f34fbc0b2ba7f6dd22600e8df1aaa63ed8 (diff)
parent2857dd026ce67f26f4da2f07ecffd8d6b754625c (diff)
Merge changes from product-engine
Diffstat (limited to 'indra/newview/llparticipantlist.cpp')
-rw-r--r--indra/newview/llparticipantlist.cpp148
1 files changed, 148 insertions, 0 deletions
diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp
index 2be0781487..f5367c0477 100644
--- a/indra/newview/llparticipantlist.cpp
+++ b/indra/newview/llparticipantlist.cpp
@@ -36,10 +36,12 @@
#include "lltrans.h"
#include "llavataractions.h"
#include "llagent.h"
+#include "llimview.h"
#include "llparticipantlist.h"
#include "llavatarlist.h"
#include "llspeakers.h"
+#include "llviewermenu.h"
//LLParticipantList retrieves add, clear and remove events and updates view accordingly
#if LL_MSVC
@@ -64,6 +66,9 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, LLAvatarList* av
mAvatarList->setDoubleClickCallback(boost::bind(&LLParticipantList::onAvatarListDoubleClicked, this, mAvatarList));
mAvatarList->setRefreshCompleteCallback(boost::bind(&LLParticipantList::onAvatarListRefreshed, this, _1, _2));
+ mParticipantListMenu = new LLParticipantListMenu(*this);
+ mAvatarList->setContextMenu(mParticipantListMenu);
+
//Lets fill avatarList with existing speakers
LLAvatarList::uuid_vector_t& group_members = mAvatarList->getIDs();
@@ -83,8 +88,15 @@ LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, LLAvatarList* av
LLParticipantList::~LLParticipantList()
{
+ delete mParticipantListMenu;
+ mParticipantListMenu = NULL;
}
+void LLParticipantList::setSpeakingIndicatorsVisible(BOOL visible)
+{
+ mAvatarList->setSpeakingIndicatorsVisible(visible);
+};
+
void LLParticipantList::onAvatarListDoubleClicked(LLAvatarList* list)
{
LLUUID clicked_id = list->getSelectedUUID();
@@ -265,3 +277,139 @@ bool LLParticipantList::SpeakerModeratorUpdateListener::handleEvent(LLPointer<LL
{
return mParent.onModeratorUpdateEvent(event, userdata);
}
+
+LLContextMenu* LLParticipantList::LLParticipantListMenu::createMenu()
+{
+ // set up the callbacks for all of the avatar menu items
+ LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
+ LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar;
+
+ registrar.add("ParticipantList.ToggleAllowTextChat", boost::bind(&LLParticipantList::LLParticipantListMenu::toggleAllowTextChat, this, _2));
+ registrar.add("ParticipantList.ToggleMuteText", boost::bind(&LLParticipantList::LLParticipantListMenu::toggleMuteText, this, _2));
+
+ enable_registrar.add("ParticipantList.EnableItem", boost::bind(&LLParticipantList::LLParticipantListMenu::enableContextMenuItem, this, _2));
+ enable_registrar.add("ParticipantList.CheckItem", boost::bind(&LLParticipantList::LLParticipantListMenu::checkContextMenuItem, this, _2));
+
+ // create the context menu from the XUI
+ return LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>(
+ "menu_participant_list.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance());
+}
+
+void LLParticipantList::LLParticipantListMenu::toggleAllowTextChat(const LLSD& userdata)
+{
+ const LLUUID speaker_id = mUUIDs.front();
+
+ std::string url = gAgent.getRegion()->getCapability("ChatSessionRequest");
+ LLSD data;
+ data["method"] = "mute update";
+ data["session-id"] = mParent.mSpeakerMgr->getSessionID();
+ data["params"] = LLSD::emptyMap();
+ data["params"]["agent_id"] = speaker_id;
+ data["params"]["mute_info"] = LLSD::emptyMap();
+ //current value represents ability to type, so invert
+ data["params"]["mute_info"]["text"] = !mParent.mSpeakerMgr->findSpeaker(speaker_id)->mModeratorMutedText;
+
+ class MuteTextResponder : public LLHTTPClient::Responder
+ {
+ public:
+ MuteTextResponder(const LLUUID& session_id)
+ {
+ mSessionID = session_id;
+ }
+
+ virtual void error(U32 status, const std::string& reason)
+ {
+ llwarns << status << ": " << reason << llendl;
+
+ if ( gIMMgr )
+ {
+ //403 == you're not a mod
+ //should be disabled if you're not a moderator
+ if ( 403 == status )
+ {
+ gIMMgr->showSessionEventError(
+ "mute",
+ "not_a_moderator",
+ mSessionID);
+ }
+ else
+ {
+ gIMMgr->showSessionEventError(
+ "mute",
+ "generic",
+ mSessionID);
+ }
+ }
+ }
+
+ private:
+ LLUUID mSessionID;
+ };
+
+ LLHTTPClient::post(
+ url,
+ data,
+ new MuteTextResponder(mParent.mSpeakerMgr->getSessionID()));
+}
+
+void LLParticipantList::LLParticipantListMenu::toggleMuteText(const LLSD& userdata)
+{
+ const LLUUID speaker_id = mUUIDs.front();
+ BOOL is_muted = LLMuteList::getInstance()->isMuted(speaker_id, LLMute::flagTextChat);
+ std::string name;
+
+ //fill in name using voice client's copy of name cache
+ LLPointer<LLSpeaker> speakerp = mParent.mSpeakerMgr->findSpeaker(speaker_id);
+ if (speakerp.isNull())
+ {
+ return;
+ }
+
+ name = speakerp->mDisplayName;
+
+ LLMute mute(speaker_id, name, speakerp->mType == LLSpeaker::SPEAKER_AGENT ? LLMute::AGENT : LLMute::OBJECT);
+
+ if (!is_muted)
+ {
+ LLMuteList::getInstance()->add(mute, LLMute::flagTextChat);
+ }
+ else
+ {
+ LLMuteList::getInstance()->remove(mute, LLMute::flagTextChat);
+ }
+}
+
+bool LLParticipantList::LLParticipantListMenu::enableContextMenuItem(const LLSD& userdata)
+{
+ std::string item = userdata.asString();
+ if (item == "can_mute_text")
+ {
+ return mUUIDs.front() != gAgentID;
+ }
+ else
+ if (item == "can_allow_text_chat")
+ {
+ LLIMModel::LLIMSession* im_session = LLIMModel::getInstance()->findIMSession(mParent.mSpeakerMgr->getSessionID());
+ return im_session->mType == IM_SESSION_GROUP_START && mParent.mSpeakerMgr->findSpeaker(gAgentID)->mIsModerator;
+ }
+ return true;
+}
+
+bool LLParticipantList::LLParticipantListMenu::checkContextMenuItem(const LLSD& userdata)
+{
+ std::string item = userdata.asString();
+ const LLUUID& id = mUUIDs.front();
+ if (item == "is_muted")
+ return LLMuteList::getInstance()->isMuted(id, LLMute::flagTextChat);
+ else
+ if (item == "is_allowed_text_chat")
+ {
+ LLPointer<LLSpeaker> selected_speakerp = mParent.mSpeakerMgr->findSpeaker(id);
+
+ if (selected_speakerp.notNull())
+ {
+ return !selected_speakerp->mModeratorMutedText;
+ }
+ }
+ return false;
+}