- internal : reviewed @recvim and @sendim for CHUI (SL-3.5)

--HG--
branch : RLVa
master
Kitty Barnett 2013-05-11 14:20:51 +02:00
parent 45afaf7156
commit fe8b4bf140
9 changed files with 110 additions and 64 deletions

View File

@ -60,8 +60,9 @@
#include "llviewerchat.h"
#include "llnotificationmanager.h"
#include "llautoreplace.h"
// [RLVa:KB] - Checked: 2010-04-09 (RLVa-1.2.0e)
#include "rlvhandler.h"
// [RLVa:KB] - Checked: 2013-05-10 (RLVa-1.4.9)
#include "rlvactions.h"
#include "rlvcommon.h"
// [/RLVa:KB]
floater_showed_signal_t LLFloaterIMSession::sIMFloaterShowedSignal;
@ -258,12 +259,12 @@ void LLFloaterIMSession::sendMsgFromInputEditor()
void LLFloaterIMSession::sendMsg(const std::string& msg)
{
// const std::string utf8_text = utf8str_truncate(msg, MAX_MSG_BUF_SIZE - 1);
// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c
// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0)
std::string utf8_text = utf8str_truncate(msg, MAX_MSG_BUF_SIZE - 1);
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDIM)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SENDIMTO)) )
if ( (RlvActions::hasBehaviour(RLV_BHVR_SENDIM)) || (RlvActions::hasBehaviour(RLV_BHVR_SENDIMTO)) )
{
LLIMModel::LLIMSession* pIMSession = LLIMModel::instance().findIMSession(mSessionID);
const LLIMModel::LLIMSession* pIMSession = LLIMModel::instance().findIMSession(mSessionID);
RLV_ASSERT(pIMSession);
bool fRlvFilter = !pIMSession;
@ -272,10 +273,10 @@ void LLFloaterIMSession::sendMsg(const std::string& msg)
switch (pIMSession->mSessionType)
{
case LLIMModel::LLIMSession::P2P_SESSION: // One-on-one IM
fRlvFilter = !gRlvHandler.canSendIM(mOtherParticipantUUID);
fRlvFilter = !RlvActions::canSendIM(mOtherParticipantUUID);
break;
case LLIMModel::LLIMSession::GROUP_SESSION: // Group chat
fRlvFilter = !gRlvHandler.canSendIM(mSessionID);
fRlvFilter = !RlvActions::canSendIM(mSessionID);
break;
case LLIMModel::LLIMSession::ADHOC_SESSION: // Conference chat: allow if all participants can be sent an IM
{
@ -291,7 +292,7 @@ void LLFloaterIMSession::sendMsg(const std::string& msg)
itSpeaker != speakers.end(); ++itSpeaker)
{
const LLSpeaker* pSpeaker = *itSpeaker;
if ( (gAgent.getID() != pSpeaker->mID) && (!gRlvHandler.canSendIM(pSpeaker->mID)) )
if ( (gAgent.getID() != pSpeaker->mID) && (!RlvActions::canSendIM(pSpeaker->mID)) )
{
fRlvFilter = true;
break;
@ -306,7 +307,9 @@ void LLFloaterIMSession::sendMsg(const std::string& msg)
}
if (fRlvFilter)
{
utf8_text = RlvStrings::getString(RLV_STRING_BLOCKED_SENDIM);
}
}
// [/RLVa:KB]

View File

@ -107,6 +107,7 @@
#include "llteleporthistorystorage.h"
#include "llproxy.h"
// [RLVa:KB] - Checked: 2010-03-18 (RLVa-1.2.0a)
#include "rlvactions.h"
#include "rlvhandler.h"
// [/RLVa:KB]
@ -1085,9 +1086,11 @@ void LLFloaterPreference::refreshEnabledState()
LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections");
LLRadioGroup* radio_reflection_detail = getChild<LLRadioGroup>("ReflectionDetailRadio");
// [RLVa:KB] - Checked: 2010-04-09 (RLVa-1.2.0e) | Modified: RLVa-1.2.0e
// [RLVa:KB] - Checked: 2013-05-11 (RLVa-1.4.9)
if (rlv_handler_t::isEnabled())
childSetEnabled("busy_response", !gRlvHandler.hasBehaviour(RLV_BHVR_SENDIM));
{
getChild<LLUICtrl>("do_not_disturb_response")->setEnabled(!RlvActions::hasBehaviour(RLV_BHVR_SENDIM));
}
// [/RLVa:KB]
// Reflections

View File

@ -68,8 +68,9 @@
#include "llviewerparcelmgr.h"
#include "llconversationlog.h"
#include "message.h"
// [RLVa:KB] - Checked: 2010-04-09 (RLVa-1.2.0e)
#include "rlvhandler.h"
// [RLVa:KB] - Checked: 2013-05-10 (RLVa-1.4.9)
#include "rlvactions.h"
#include "rlvcommon.h"
// [/RLVa:KB]
const static std::string ADHOC_NAME_SUFFIX(" Conference");
@ -3509,15 +3510,15 @@ public:
{
return;
}
// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_RECVIM)) || (gRlvHandler.hasBehaviour(RLV_BHVR_RECVIMFROM)) )
// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0)
if ( (RlvActions::hasBehaviour(RLV_BHVR_RECVIM)) || (RlvActions::hasBehaviour(RLV_BHVR_RECVIMFROM)) )
{
if (gAgent.isInGroup(session_id)) // Group chat: don't accept the invite if not an exception
{
if (!gRlvHandler.canReceiveIM(session_id))
if (!RlvActions::canReceiveIM(session_id))
return;
}
else if (!gRlvHandler.canReceiveIM(from_id)) // Conference chat: don't block; censor if not an exception
else if (!RlvActions::canReceiveIM(from_id)) // Conference chat: don't block; censor if not an exception
{
message = RlvStrings::getString(RLV_STRING_BLOCKED_RECVIM);
}

View File

@ -111,6 +111,7 @@
#include "llpanelplaceprofile.h"
#include "llviewerregion.h"
// [RLVa:KB] - Checked: 2010-03-09 (RLVa-1.2.0a)
#include "rlvactions.h"
#include "rlvhandler.h"
#include "rlvinventory.h"
#include "rlvui.h"
@ -2521,7 +2522,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
// do nothing -- don't distract newbies in
// Prelude with global IMs
}
// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a
// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0)
else if ( (rlv_handler_t::isEnabled()) && (offline == IM_ONLINE) && ("@version" == message) &&
(!is_muted) && ((!accept_im_from_only_friend) || (is_friend)) )
{
@ -2532,12 +2533,12 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
// && is_do_not_disturb
// && from_id.notNull() //not a system message
// && to_id.notNull()) //not global message
// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c
// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0)
else if (offline == IM_ONLINE
&& is_do_not_disturb
&& from_id.notNull() //not a system message
&& to_id.notNull() //not global message
&& gRlvHandler.canReceiveIM(from_id))
&& RlvActions::canReceiveIM(from_id))
// [/RLVa:KB]
{
// return a standard "do not disturb" message, but only do it to online IM
@ -2587,12 +2588,19 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
bool mute_im = is_muted;
if(accept_im_from_only_friend&&!is_friend)
{
if (!gIMMgr->isNonFriendSessionNotified(session_id))
{
std::string message = LLTrans::getString("IM_unblock_only_groups_friends");
gIMMgr->addMessage(session_id, from_id, name, message, IM_OFFLINE == offline);
gIMMgr->addNotifiedNonFriendSessionID(session_id);
}
mute_im = true;
}
// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c
// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0)
// Don't block offline IMs, or IMs from Lindens
if ( (rlv_handler_t::isEnabled()) && (offline != IM_OFFLINE) && /*(!is_linden) &&*/ (!gRlvHandler.canReceiveIM(from_id)) )
if ( (rlv_handler_t::isEnabled()) && (offline != IM_OFFLINE) && (!RlvActions::canReceiveIM(from_id)) && (!LLMuteList::getInstance()->isLinden(original_name) ))
{
if (!mute_im)
RlvUtil::sendBusyMessage(from_id, RlvStrings::getString(RLV_STRING_BLOCKED_RECVIM_REMOTE), session_id);
@ -2611,20 +2619,18 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
/*
bool mute_im = is_muted;
if(accept_im_from_only_friend&&!is_friend)
{
if (!gIMMgr->isNonFriendSessionNotified(session_id))
{
std::string message = LLTrans::getString("IM_unblock_only_groups_friends");
gIMMgr->addMessage(session_id, from_id, name, message, IM_OFFLINE == offline);
gIMMgr->addNotifiedNonFriendSessionID(session_id);
}
mute_im = true;
}
*/
// bool mute_im = is_muted;
// if(accept_im_from_only_friend&&!is_friend)
// {
// if (!gIMMgr->isNonFriendSessionNotified(session_id))
// {
// std::string message = LLTrans::getString("IM_unblock_only_groups_friends");
// gIMMgr->addMessage(session_id, from_id, name, message, IM_OFFLINE == offline);
// gIMMgr->addNotifiedNonFriendSessionID(session_id);
// }
//
// mute_im = true;
// }
if (!mute_im)
{
gIMMgr->addMessage(
@ -3258,7 +3264,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
}
// Censor lure message if: 1) restricted from receiving IMs from the sender, or 2) @showloc=n restricted
if ( (!gRlvHandler.canReceiveIM(from_id)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) )
if ( (!RlvActions::canReceiveIM(from_id)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) )
{
message = RlvStrings::getString(RLV_STRING_HIDDEN);
}
@ -7348,14 +7354,14 @@ bool handle_lure_callback(const LLSD& notification, const LLSD& response)
if(0 == option)
{
// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDIM)) || (gRlvHandler.hasBehaviour(RLV_BHVR_SENDIMTO)) )
// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0)
if ( (RlvActions::hasBehaviour(RLV_BHVR_SENDIM)) || (RlvActions::hasBehaviour(RLV_BHVR_SENDIMTO)) )
{
// Filter the lure message if one of the recipients of the lure can't be sent an IM to
for (LLSD::array_const_iterator it = notification["payload"]["ids"].beginArray();
it != notification["payload"]["ids"].endArray(); ++it)
{
if (!gRlvHandler.canSendIM(it->asUUID()))
if (!RlvActions::canSendIM(it->asUUID()))
{
text = RlvStrings::getString(RLV_STRING_HIDDEN);
break;

View File

@ -23,6 +23,30 @@
// RlvActions member functions
//
// Checked: 2010-11-30 (RLVa-1.3.0)
bool RlvActions::canReceiveIM(const LLUUID& idSender)
{
// User can receive an IM from "sender" (could be an agent or a group) if:
// - not generally restricted from receiving IMs (or the sender is an exception)
// - not specifically restricted from receiving an IM from the sender
return
(!rlv_handler_t::isEnabled()) ||
( ( (!gRlvHandler.hasBehaviour(RLV_BHVR_RECVIM)) || (gRlvHandler.isException(RLV_BHVR_RECVIM, idSender)) ) &&
( (!gRlvHandler.hasBehaviour(RLV_BHVR_RECVIMFROM)) || (!gRlvHandler.isException(RLV_BHVR_RECVIMFROM, idSender)) ) );
}
// Checked: 2010-11-30 (RLVa-1.3.0)
bool RlvActions::canSendIM(const LLUUID& idRecipient)
{
// User can send an IM to "recipient" (could be an agent or a group) if:
// - not generally restricted from sending IMs (or the recipient is an exception)
// - not specifically restricted from sending an IM to the recipient
return
(!rlv_handler_t::isEnabled()) ||
( ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SENDIM)) || (gRlvHandler.isException(RLV_BHVR_SENDIM, idRecipient)) ) &&
( (!gRlvHandler.hasBehaviour(RLV_BHVR_SENDIMTO)) || (!gRlvHandler.isException(RLV_BHVR_SENDIMTO, idRecipient)) ) );
}
// Checked: 2011-04-12 (RLVa-1.3.0)
bool RlvActions::canStartIM(const LLUUID& idRecipient)
{
@ -35,6 +59,12 @@ bool RlvActions::canStartIM(const LLUUID& idRecipient)
( (!gRlvHandler.hasBehaviour(RLV_BHVR_STARTIMTO)) || (!gRlvHandler.isException(RLV_BHVR_STARTIMTO, idRecipient)) ) );
}
// Checked: 2013-05-10 (RLVa-1.4.9)
bool RlvActions::hasBehaviour(ERlvBehaviour eBhvr)
{
return gRlvHandler.hasBehaviour(eBhvr);
}
// Checked: 2013-05-09 (RLVa-1.4.9)
bool RlvActions::hasOpenP2PSession(const LLUUID& idAgent)
{

View File

@ -17,19 +17,37 @@
#ifndef RLV_ACTIONS_H
#define RLV_ACTIONS_H
#include "rlvdefines.h"
// ============================================================================
// RlvActions class declaration
// RlvActions class declaration - developer-friendly non-RLVa code facing class, use in lieu of RlvHandler whenever possible
//
class RlvActions
{
public:
/*
* Returns true if the user is allowed to receive IMs from the specified sender (can be an avatar or a group)
*/
static bool canReceiveIM(const LLUUID& idSender);
/*
* Returns true if the user is allowed to send IMs to the specified recipient (can be an avatar or a group)
*/
static bool canSendIM(const LLUUID& idRecipient);
/*
* Returns true if the user is allowed to start a - P2P or group - conversation with the specified UUID.
*/
static bool canStartIM(const LLUUID& idRecipient); // @startim and @startimto
/*
* Convenience function to check for a behaviour without having to include rlvhandler.h.
* Do NOT call this function if speed is important (i.e. per-frame)
*/
static bool hasBehaviour(ERlvBehaviour eBhvr);
/*
* Returns true if a - P2P or group - IM session is open with the specified UUID.
*/

View File

@ -95,9 +95,7 @@ public:
// Command specific helper functions
bool canEdit(const LLViewerObject* pObj) const; // @edit and @editobj
bool canReceiveIM(const LLUUID& idSender) const; // @recvim and @recvimfrom
bool canShowHoverText(const LLViewerObject* pObj) const; // @showhovertext* command family
bool canSendIM(const LLUUID& idRecipient) const; // @sendim and @sendimto
bool canSit(LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero) const;
bool canStand() const;
bool canTeleportViaLure(const LLUUID& idAgent) const;
@ -247,28 +245,6 @@ inline bool RlvHandler::canEdit(const LLViewerObject* pObj) const
((!hasBehaviour(RLV_BHVR_EDITOBJ)) || (!isException(RLV_BHVR_EDITOBJ, pObj->getRootEdit()->getID())));
}
// Checked: 2010-11-30 (RLVa-1.3.0c) | Added: RLVa-1.3.0c
inline bool RlvHandler::canReceiveIM(const LLUUID& idSender) const
{
// User can receive an IM from "sender" (could be an agent or a group) if:
// - not generally restricted from receiving IMs (or the sender is an exception)
// - not specifically restricted from receiving an IM from the sender
return
( (!hasBehaviour(RLV_BHVR_RECVIM)) || (isException(RLV_BHVR_RECVIM, idSender)) ) &&
( (!hasBehaviour(RLV_BHVR_RECVIMFROM)) || (!isException(RLV_BHVR_RECVIMFROM, idSender)) );
}
// Checked: 2010-11-30 (RLVa-1.3.0c) | Added: RLVa-1.3.0c
inline bool RlvHandler::canSendIM(const LLUUID& idRecipient) const
{
// User can send an IM to "recipient" (could be an agent or a group) if:
// - not generally restricted from sending IMs (or the recipient is an exception)
// - not specifically restricted from sending an IM to the recipient
return
( (!hasBehaviour(RLV_BHVR_SENDIM)) || (isException(RLV_BHVR_SENDIM, idRecipient)) ) &&
( (!hasBehaviour(RLV_BHVR_SENDIMTO)) || (!isException(RLV_BHVR_SENDIMTO, idRecipient)) );
}
// Checked: 2010-03-27 (RLVa-1.4.0a) | Modified: RLVa-1.0.0f
inline bool RlvHandler::canShowHoverText(const LLViewerObject *pObj) const
{

View File

@ -70,6 +70,7 @@ RlvUIEnabler::RlvUIEnabler()
// onToggleXXX
m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_EDIT, boost::bind(&RlvUIEnabler::onToggleEdit, this)));
m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SENDIM, boost::bind(&RlvUIEnabler::onToggleSendIM, this)));
m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SETDEBUG, boost::bind(&RlvUIEnabler::onToggleSetDebug, this)));
m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SETENV, boost::bind(&RlvUIEnabler::onToggleSetEnv, this)));
m_Handlers.insert(std::pair<ERlvBehaviour, behaviour_handler_t>(RLV_BHVR_SHOWINV, boost::bind(&RlvUIEnabler::onToggleShowInv, this, _1)));
@ -150,6 +151,13 @@ void RlvUIEnabler::onToggleMovement()
LLFloaterMove::sUpdateMovementStatus();
}
// Checked: 2013-05-11 (RLVa-1.4.9)
void RlvUIEnabler::onToggleSendIM()
{
bool fEnable = !gRlvHandler.hasBehaviour(RLV_BHVR_SENDIM);
gSavedPerAccountSettings.getControl("DoNotDisturbModeResponse")->setHiddenFromSettingsEditor(!fEnable);
}
// Checked: 2011-05-28 (RLVa-1.4.0a) | Added: RLVa-1.4.0a
void RlvUIEnabler::onToggleSetDebug()
{

View File

@ -46,6 +46,7 @@ protected:
void onRefreshHoverText(); // showloc, shownames, showhovertext(all|world|hud)
void onToggleEdit(); // edit
void onToggleMovement(); // fly, alwaysrun and temprun
void onToggleSendIM(); // sendim
void onToggleSetDebug(); // setdebug
void onToggleSetEnv(); // setenv
void onToggleShowInv(bool fQuitting); // showinv