diff options
| -rw-r--r-- | indra/newview/llparticipantlist.cpp | 102 | ||||
| -rw-r--r-- | indra/newview/llspeakers.cpp | 99 | ||||
| -rw-r--r-- | indra/newview/llspeakers.h | 28 | 
3 files changed, 141 insertions, 88 deletions
diff --git a/indra/newview/llparticipantlist.cpp b/indra/newview/llparticipantlist.cpp index 2c5f1b094e..93e5b8fa15 100644 --- a/indra/newview/llparticipantlist.cpp +++ b/indra/newview/llparticipantlist.cpp @@ -49,43 +49,6 @@  #pragma warning (disable : 4355) // 'this' used in initializer list: yes, intentionally  #endif -class ModerationResponder : public LLHTTPClient::Responder -{ -public: -	ModerationResponder(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_mod_error", -					mSessionID); -			} -			else -			{ -				gIMMgr->showSessionEventError( -					"mute", -					"generic_request_error", -					mSessionID); -			} -		} -	} - -private: -	LLUUID mSessionID; -}; -  LLParticipantList::LLParticipantList(LLSpeakerMgr* data_source, LLAvatarList* avatar_list,  bool use_context_menu/* = true*/):  	mSpeakerMgr(data_source),  	mAvatarList(avatar_list), @@ -471,22 +434,13 @@ void LLParticipantList::LLParticipantListMenu::show(LLView* spawning_view, const  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; - -	LLHTTPClient::post( -		url, -		data, -		new ModerationResponder(mParent.mSpeakerMgr->getSessionID())); +	LLIMSpeakerMgr* mgr = dynamic_cast<LLIMSpeakerMgr*>(mParent.mSpeakerMgr); +	if (mgr) +	{ +		const LLUUID speaker_id = mUUIDs.front(); +		mgr->toggleAllowTextChat(speaker_id); +	}  }  void LLParticipantList::LLParticipantListMenu::toggleMute(const LLSD& userdata, U32 flags) @@ -565,47 +519,19 @@ void LLParticipantList::LLParticipantListMenu::moderateVoice(const LLSD& userdat  void LLParticipantList::LLParticipantListMenu::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute)  { -	if (gAgentID == avatar_id) return; // do not process myself - -	LLPointer<LLSpeaker> speakerp = mParent.mSpeakerMgr->findSpeaker(avatar_id); -	if (!speakerp) return; - -	// *NOTE: mantipov: probably this condition will be incorrect when avatar will be blocked for -	// text chat via moderation (LLSpeaker::mModeratorMutedText == TRUE) -	bool is_in_voice = speakerp->mStatus <= LLSpeaker::STATUS_VOICE_ACTIVE || speakerp->mStatus == LLSpeaker::STATUS_MUTED; - -	// do not send voice moderation changes for avatars not in voice channel -	if (!is_in_voice) return; - -	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"] = avatar_id; -	data["params"]["mute_info"] = LLSD::emptyMap(); -	data["params"]["mute_info"]["voice"] = !unmute; - -	LLHTTPClient::post( -		url, -		data, -		new ModerationResponder(mParent.mSpeakerMgr->getSessionID())); +	LLIMSpeakerMgr* mgr = dynamic_cast<LLIMSpeakerMgr*>(mParent.mSpeakerMgr); +	if (mgr) +	{ +		mgr->moderateVoiceParticipant(avatar_id, unmute); +	}  }  void LLParticipantList::LLParticipantListMenu::moderateVoiceOtherParticipants(const LLUUID& excluded_avatar_id, bool unmute)  { -	LLSpeakerMgr::speaker_list_t speakers; -	mParent.mSpeakerMgr->getSpeakerList(&speakers, FALSE); - -	for (LLSpeakerMgr::speaker_list_t::iterator iter = speakers.begin(); -		iter != speakers.end(); ++iter) +	LLIMSpeakerMgr* mgr = dynamic_cast<LLIMSpeakerMgr*>(mParent.mSpeakerMgr); +	if (mgr)  	{ -		LLSpeaker* speakerp = (*iter).get(); -		LLUUID speaker_id = speakerp->mID; - -		if (excluded_avatar_id == speaker_id) continue; - -		moderateVoiceParticipant(speaker_id, unmute); +		mgr->moderateVoiceOtherParticipants(excluded_avatar_id, unmute);  	}  } diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp index 261bdbcfc0..1b9fee650e 100644 --- a/indra/newview/llspeakers.cpp +++ b/indra/newview/llspeakers.cpp @@ -36,6 +36,7 @@  #include "llagent.h"  #include "llappviewer.h" +#include "llimview.h"  #include "llmutelist.h"  #include "llsdutil.h"  #include "lluicolortable.h" @@ -575,6 +576,104 @@ void LLIMSpeakerMgr::updateSpeakers(const LLSD& update)  	}  } +class ModerationResponder : public LLHTTPClient::Responder +{ +public: +	ModerationResponder(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_mod_error", +					mSessionID); +			} +			else +			{ +				gIMMgr->showSessionEventError( +					"mute", +					"generic_request_error", +					mSessionID); +			} +		} +	} + +private: +	LLUUID mSessionID; +}; + +void LLIMSpeakerMgr::toggleAllowTextChat(const LLUUID& speaker_id) +{ +	std::string url = gAgent.getRegion()->getCapability("ChatSessionRequest"); +	LLSD data; +	data["method"] = "mute update"; +	data["session-id"] = 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"] = !findSpeaker(speaker_id)->mModeratorMutedText; + +	LLHTTPClient::post(url, data, new ModerationResponder(getSessionID())); +} + +void LLIMSpeakerMgr::moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute) +{ +	if (gAgentID == avatar_id) return; // do not process myself + +	LLPointer<LLSpeaker> speakerp = findSpeaker(avatar_id); +	if (!speakerp) return; + +	// *NOTE: mantipov: probably this condition will be incorrect when avatar will be blocked for +	// text chat via moderation (LLSpeaker::mModeratorMutedText == TRUE) +	bool is_in_voice = speakerp->mStatus <= LLSpeaker::STATUS_VOICE_ACTIVE || speakerp->mStatus == LLSpeaker::STATUS_MUTED; + +	// do not send voice moderation changes for avatars not in voice channel +	if (!is_in_voice) return; + +	std::string url = gAgent.getRegion()->getCapability("ChatSessionRequest"); +	LLSD data; +	data["method"] = "mute update"; +	data["session-id"] = getSessionID(); +	data["params"] = LLSD::emptyMap(); +	data["params"]["agent_id"] = avatar_id; +	data["params"]["mute_info"] = LLSD::emptyMap(); +	data["params"]["mute_info"]["voice"] = !unmute; + +	LLHTTPClient::post( +		url, +		data, +		new ModerationResponder(getSessionID())); +} + +void LLIMSpeakerMgr::moderateVoiceOtherParticipants(const LLUUID& excluded_avatar_id, bool unmute) +{ +	LLSpeakerMgr::speaker_list_t speakers; +	getSpeakerList(&speakers, FALSE); + +	for (LLSpeakerMgr::speaker_list_t::iterator iter = speakers.begin(); +		iter != speakers.end(); ++iter) +	{ +		LLSpeaker* speakerp = (*iter).get(); +		LLUUID speaker_id = speakerp->mID; + +		if (excluded_avatar_id == speaker_id) continue; + +		moderateVoiceParticipant(speaker_id, unmute); +	} +} +  //  // LLActiveSpeakerMgr diff --git a/indra/newview/llspeakers.h b/indra/newview/llspeakers.h index 04046a8587..6f7a1d2c49 100644 --- a/indra/newview/llspeakers.h +++ b/indra/newview/llspeakers.h @@ -158,6 +158,34 @@ public:  	void updateSpeakers(const LLSD& update);  	void setSpeakers(const LLSD& speakers); + +	void toggleAllowTextChat(const LLUUID& speaker_id); + +	/** +	 * Mutes/Unmutes avatar for current group voice chat. +	 * +	 * It only marks avatar as muted for session and does not use local Agent's Block list. +	 * It does not mute Agent itself. +	 * +	 * @param[in] avatar_id UUID of avatar to be processed +	 * @param[in] unmute if false - specified avatar will be muted, otherwise - unmuted. +	 * +	 * @see moderateVoiceOtherParticipants() +	 */ +	void moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute); + +	/** +	 * Mutes/Unmutes all avatars except specified for current group voice chat. +	 * +	 * It only marks avatars as muted for session and does not use local Agent's Block list. +	 * It based call moderateVoiceParticipant() for each avatar should be muted/unmuted. +	 * +	 * @param[in] excluded_avatar_id UUID of avatar NOT to be processed +	 * @param[in] unmute if true - avatars will be muted, otherwise - unmuted. +	 * +	 * @see moderateVoiceParticipant() +	 */ +	void moderateVoiceOtherParticipants(const LLUUID& excluded_avatar_id, bool unmute);  protected:  	virtual void updateSpeakerList();  };  | 
