- internal : moved several rlvXXX helper and RlvHandler member functions into an RlvUtil helper class

--HG--
branch : RLVa
master
Kitty Barnett 2010-08-29 04:00:55 +02:00
parent 3d8855efe7
commit 33997d0695
21 changed files with 201 additions and 200 deletions

View File

@ -599,7 +599,7 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL
else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATWHISPER)) )
type = CHAT_TYPE_NORMAL;
animate &= !gRlvHandler.hasBehaviour( (!rlvIsEmote(utf8_text)) ? RLV_BHVR_REDIRCHAT : RLV_BHVR_REDIREMOTE );
animate &= !gRlvHandler.hasBehaviour( (!RlvUtil::isEmote(utf8_text)) ? RLV_BHVR_REDIRCHAT : RLV_BHVR_REDIREMOTE );
}
// [/RLVa:KB]

View File

@ -120,7 +120,7 @@ void LLFloaterInspect::onClickCreatorProfile()
// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) | Modified: RLVa-1.0.0e
const LLUUID& idCreator = node->mPermissions->getCreator();
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) &&
((node->mPermissions->getOwner() == idCreator) || (RlvHandler::isNearbyAgent(idCreator))) )
((node->mPermissions->getOwner() == idCreator) || (RlvUtil::isNearbyAgent(idCreator))) )
{
return;
}
@ -237,7 +237,7 @@ void LLFloaterInspect::refresh()
owner_name = RlvStrings::getAnonym(owner_name);
const LLUUID& idCreator = obj->mPermissions->getCreator();
if ( (obj->mPermissions->getOwner() == idCreator) || (RlvHandler::isNearbyAgent(idCreator)) )
if ( (obj->mPermissions->getOwner() == idCreator) || (RlvUtil::isNearbyAgent(idCreator)) )
creator_name = RlvStrings::getAnonym(creator_name);
}
// [/RLVa:KB]

View File

@ -287,7 +287,7 @@ void LLFloaterProperties::refreshFromItem(LLInventoryItem* item)
// If the object creator matches the object owner we need to anonimize the creator field as well
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) &&
( ((perm.isOwned()) && (!perm.isGroupOwned()) && (perm.getOwner() == item->getCreatorUUID()) ) ||
(RlvHandler::isNearbyAgent(item->getCreatorUUID())) ) )
(RlvUtil::isNearbyAgent(item->getCreatorUUID())) ) )
{
childSetEnabled("BtnCreator", FALSE);
name = RlvStrings::getAnonym(name);
@ -566,7 +566,7 @@ void LLFloaterProperties::onClickCreator()
{
const LLPermissions& perm = item->getPermissions();
if ( ((perm.isOwned()) && (!perm.isGroupOwned()) && (perm.getOwner() == item->getCreatorUUID()) ) ||
(RlvHandler::isNearbyAgent(item->getCreatorUUID())) )
(RlvUtil::isNearbyAgent(item->getCreatorUUID())) )
{
return;
}

View File

@ -305,7 +305,7 @@ void LLGiveInventory::logInventoryOffer(const LLUUID& to_agent, const LLUUID &im
gIMMgr->addSystemMessage(im_session_id, "inventory_item_offered", args);
}
// [RLVa:KB] - Checked: 2010-05-26 (RLVa-1.2.0h) | Modified: RLVa-1.2.0h
else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (gRlvHandler.isNearbyAgent(to_agent)) &&
else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(to_agent)) &&
(!RlvUIEnabler::hasOpenProfile(to_agent)) )
{
// Log to chat history if the user didn't drop on an IM session or a profile to avoid revealing the name of the recipient
@ -418,7 +418,7 @@ void LLGiveInventory::commitGiveInventoryItem(const LLUUID& to_agent,
// LLRecentPeople::instance().add(to_agent);
// [RLVa:KB] - Checked: 2010-04-21 (RLVa-1.2.0f) | Added: RLVa-1.2.0f
// Block the recent activity update if this was an in-world drop on an avatar (as opposed to a drop on an IM session or on a profile)
if ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) || (im_session_id.notNull()) || (!gRlvHandler.isNearbyAgent(to_agent)) ||
if ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) || (im_session_id.notNull()) || (!RlvUtil::isNearbyAgent(to_agent)) ||
(RlvUIEnabler::hasOpenProfile(to_agent)) )
{
LLRecentPeople::instance().add(to_agent);
@ -481,7 +481,7 @@ void LLGiveInventory::commitGiveInventoryCategory(const LLUUID& to_agent,
// LLRecentPeople::instance().add(to_agent);
// [RLVa:KB] - Checked: 2010-04-20 (RLVa-1.2.0f) | Added: RLVa-1.2.0f
// Block the recent activity update if this was an in-world drop on an avatar (as opposed to a drop on an IM session or on a profile)
if ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) || (im_session_id.notNull()) || (!gRlvHandler.isNearbyAgent(to_agent)) ||
if ( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) || (im_session_id.notNull()) || (!RlvUtil::isNearbyAgent(to_agent)) ||
(RlvUIEnabler::hasOpenProfile(to_agent)) )
{
LLRecentPeople::instance().add(to_agent);

View File

@ -570,9 +570,9 @@ void LLHUDText::setStringUTF8(const std::string &wtext)
if (gRlvHandler.canShowHoverText(mSourceObject))
{
if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC))
gRlvHandler.filterLocation(text);
RlvUtil::filterLocation(text);
if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
gRlvHandler.filterNames(text);
RlvUtil::filterNames(text);
}
else
{

View File

@ -488,7 +488,7 @@ void LLInspectObject::updateCreator(LLSelectNode* nodep)
// [RLVa:KB] - Checked: 2010-08-25 (RLVa-1.2.1b) | Added: RLVa-1.2.1b
// Only anonimize the creator if they're also the owner or if they're a nearby avie
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) &&
((nodep->mPermissions->getOwner() == creator_id) || (RlvHandler::isNearbyAgent(creator_id))) )
((nodep->mPermissions->getOwner() == creator_id) || (RlvUtil::isNearbyAgent(creator_id))) )
{
// TODO-RLVa: [RLVa-1.2.2] We need to put a callback here in case the name hasn't previously resolved
std::string strFullName;

View File

@ -728,7 +728,7 @@ void LLNearbyChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type,
else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATWHISPER)) )
type = CHAT_TYPE_NORMAL;
animate &= !gRlvHandler.hasBehaviour( (!rlvIsEmote(utf8_text)) ? RLV_BHVR_REDIRCHAT : RLV_BHVR_REDIREMOTE );
animate &= !gRlvHandler.hasBehaviour( (!RlvUtil::isEmote(utf8_text)) ? RLV_BHVR_REDIRCHAT : RLV_BHVR_REDIREMOTE );
}
// [/RLVa:KB]
@ -901,7 +901,7 @@ void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channe
// Don't allow chat on debug channel if @sendchat, @redirchat or @rediremote restricted (shows as public chat on viewers)
if (CHAT_CHANNEL_DEBUG == channel)
{
bool fIsEmote = rlvIsEmote(utf8_out_text);
bool fIsEmote = RlvUtil::isEmote(utf8_out_text);
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT)) ||
((!fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT))) ||
((fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE))) )

View File

@ -361,12 +361,12 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args)
// NOTE-RLVa: we can only filter the *message* here since most everything else will already be part of "args" as well
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) && (!tmp_chat.mRlvLocFiltered) && (CHAT_SOURCE_AGENT != tmp_chat.mSourceType) )
{
gRlvHandler.filterLocation(tmp_chat.mText);
RlvUtil::filterLocation(tmp_chat.mText);
tmp_chat.mRlvLocFiltered = TRUE;
}
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (!tmp_chat.mRlvNamesFiltered) && (CHAT_SOURCE_AGENT != tmp_chat.mSourceType) )
{
gRlvHandler.filterNames(tmp_chat.mText);
RlvUtil::filterNames(tmp_chat.mText);
tmp_chat.mRlvNamesFiltered = TRUE;
}
}

View File

@ -369,7 +369,7 @@ void LLPanelPermissions::refresh()
if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
{
// Only anonimize the creator if all of the selection was created by the same avie who's also the owner or they're a nearby avie
if ( (creators_identical) && ((mCreatorID == mOwnerID) || (RlvHandler::isNearbyAgent(mCreatorID))) )
if ( (creators_identical) && ((mCreatorID == mOwnerID) || (RlvUtil::isNearbyAgent(mCreatorID))) )
creator_name = RlvStrings::getAnonym(creator_name);
// Only anonimize the owner name if all of the selection is owned by the same avie and isn't group owned

View File

@ -286,7 +286,7 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item)
// If the object creator matches the object owner we need to anonimize the creator field as well
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) &&
( ((perm.isOwned()) && (!perm.isGroupOwned()) && (perm.getOwner() == item->getCreatorUUID()) ) ||
(RlvHandler::isNearbyAgent(item->getCreatorUUID())) ) )
(RlvUtil::isNearbyAgent(item->getCreatorUUID())) ) )
{
childSetEnabled("BtnCreator", FALSE);
name = RlvStrings::getAnonym(name);
@ -630,7 +630,7 @@ void LLSidepanelItemInfo::onClickCreator()
{
const LLPermissions& perm = item->getPermissions();
if ( ((perm.isOwned()) && (!perm.isGroupOwned()) && (perm.getOwner() == item->getCreatorUUID()) ) ||
(RlvHandler::isNearbyAgent(item->getCreatorUUID())) )
(RlvUtil::isNearbyAgent(item->getCreatorUUID())) )
{
return;
}

View File

@ -336,7 +336,7 @@ void LLSidepanelTaskInfo::refresh()
if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
{
// Only anonimize the creator if all of the selection was created by the same avie who's also the owner or they're a nearby avie
if ( (creators_identical) && ((mCreatorID == mOwnerID) || (RlvHandler::isNearbyAgent(mCreatorID))) )
if ( (creators_identical) && ((mCreatorID == mOwnerID) || (RlvUtil::isNearbyAgent(mCreatorID))) )
creator_name = RlvStrings::getAnonym(creator_name);
// Only anonimize the owner name if all of the selection is owned by the same avie and isn't group owned

View File

@ -387,7 +387,7 @@ std::string LLSLURL::getSLURLString() const
// LLURI::escape(mRegion) + llformat("/%d/%d/%d",x,y,z);
// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.0d) | Added: RLVa-1.2.0d
return LLGridManager::getInstance()->getSLURLBase(mGrid) +
( ((!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) || (!RlvHandler::isNearbyRegion(mRegion)))
( ((!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) || (!RlvUtil::isNearbyRegion(mRegion)))
? (LLURI::escape(mRegion) + llformat("/%d/%d/%d",x,y,z)) : RlvStrings::getString(RLV_STRING_HIDDEN_REGION) );
// [/RLVa:KB]
}

View File

@ -1384,7 +1384,7 @@ void LLOfferInfo::send_auto_receive_response(void)
// LLRecentPeople::instance().add(mFromID);
// [RLVa:KB] - Checked: 2010-04-20 (RLVa-1.2.0f) | Added: RLVa-1.2.0f
// RELEASE-RLVa: [RLVa-1.2.0] Make sure this stays in sync with the condition in inventory_offer_handler()
if ((!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) || (!gRlvHandler.isNearbyAgent(mFromID)) || (RlvUIEnabler::hasOpenIM(mFromID)))
if ((!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) || (!RlvUtil::isNearbyAgent(mFromID)) || (RlvUIEnabler::hasOpenIM(mFromID)))
{
LLRecentPeople::instance().add(mFromID);
}
@ -1647,7 +1647,7 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const
{
// [RLVa:KB] - Checked: 2010-04-022 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f
// RELEASE-RLVa: [RLVa-1.2.0] Make sure this stays in sync with the condition in inventory_offer_handler()
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (gRlvHandler.isNearbyAgent(mFromID)) &&
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(mFromID)) &&
(!RlvUIEnabler::hasOpenIM(mFromID)) )
{
strFullName = RlvStrings::getAnonym(strFullName);
@ -1893,7 +1893,7 @@ void inventory_offer_handler(LLOfferInfo* info)
{
// [RLVa:KB] - Checked: 2010-04-20 (RLVa-1.2.0f) | Added: RLVa-1.2.0f
// Only filter if the object owner is a nearby agent
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (gRlvHandler.isNearbyAgent(info->mFromID)) )
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(info->mFromID)) )
{
payload["rlv_shownames"] = TRUE;
args["NAME"] = args["NAME_SLURL"] = RlvStrings::getAnonym(info->mFromName);
@ -1913,7 +1913,7 @@ void inventory_offer_handler(LLOfferInfo* info)
{
// [RLVa:KB] - Checked: 2010-04-20 (RLVa-1.2.0f) | Added: RLVa-1.2.0f
// Only filter if the offer is from a nearby agent and if there's no open IM session (doesn't necessarily have to be focused)
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (gRlvHandler.isNearbyAgent(info->mFromID)) &&
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(info->mFromID)) &&
(!RlvUIEnabler::hasOpenIM(info->mFromID)) )
{
payload["rlv_shownames"] = TRUE;
@ -2194,7 +2194,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
else if ( (rlv_handler_t::isEnabled()) && (offline == IM_ONLINE) && ("@version" == message) )
{
// TODO-RLVa: [RLVa-1.2.1] Should we send our version string if the other party is muted?
rlvSendBusyMessage(from_id, RlvStrings::getVersion(), session_id);
RlvUtil::sendBusyMessage(from_id, RlvStrings::getVersion(), session_id);
}
// [/RLVa:KB]
// else if (offline == IM_ONLINE && !is_linden && is_busy && name != SYSTEM_FROM)
@ -2284,7 +2284,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
(gRlvHandler.hasBehaviour(RLV_BHVR_RECVIM)) && (!gRlvHandler.isException(RLV_BHVR_RECVIM, from_id)) )
{
if (!mute_im)
rlvSendBusyMessage(from_id, RlvStrings::getString(RLV_STRING_BLOCKED_RECVIM_REMOTE), session_id);
RlvUtil::sendBusyMessage(from_id, RlvStrings::getString(RLV_STRING_BLOCKED_RECVIM_REMOTE), session_id);
message = RlvStrings::getString(RLV_STRING_BLOCKED_RECVIM);
}
// [/RLVa:KB]
@ -2583,7 +2583,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
// args["NAME"] = name;
// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f
// Only filter the name if the agent is nearby, there isn't an open IM session to them and their profile isn't open
bool fRlvFilterName = (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (gRlvHandler.isNearbyAgent(from_id)) &&
bool fRlvFilterName = (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(from_id)) &&
(!RlvUIEnabler::hasOpenProfile(from_id)) && (!RlvUIEnabler::hasOpenIM(from_id));
args["NAME"] = (!fRlvFilterName) ? name : RlvStrings::getAnonym(name);
// [/RLVa:KB]
@ -2597,7 +2597,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
// args["NAME"] = name;
// [RLVa:KB] - Checked: 2010-04-22 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f
// Only filter the name if the agent is nearby, there isn't an open IM session to them and their profile isn't open
bool fRlvFilterName = (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (gRlvHandler.isNearbyAgent(from_id)) &&
bool fRlvFilterName = (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (RlvUtil::isNearbyAgent(from_id)) &&
(!RlvUIEnabler::hasOpenProfile(from_id)) && (!RlvUIEnabler::hasOpenIM(from_id));
args["NAME"] = (!fRlvFilterName) ? name : RlvStrings::getAnonym(name);
// [/RLVa:KB]
@ -2725,7 +2725,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
if (rlv_handler_t::isEnabled())
{
// NOTE: the chat message itself will be filtered in LLNearbyChatHandler::processChat()
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (!from_group) && (gRlvHandler.isNearbyAgent(from_id)) )
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) && (!from_group) && (RlvUtil::isNearbyAgent(from_id)) )
{
std::string strOwnerName;
if (gCacheName->getFullName(from_id, strOwnerName))
@ -2734,13 +2734,13 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
query_string["owner_name"] = RlvStrings::getAnonym(strOwnerName);
}
gRlvHandler.filterNames(name);
RlvUtil::filterNames(name);
chat.mFromName = name;
}
if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC))
{
std::string::size_type idxPos = location.find('/');
if ( (std::string::npos != idxPos) && (gRlvHandler.isNearbyRegion(location.substr(0, idxPos))) )
if ( (std::string::npos != idxPos) && (RlvUtil::isNearbyRegion(location.substr(0, idxPos))) )
location = RlvStrings::getString(RLV_STRING_HIDDEN_REGION);
}
}
@ -2852,7 +2852,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
if ( ( (gRlvHandler.hasBehaviour(RLV_BHVR_TPLURE)) && (!gRlvHandler.isException(RLV_BHVR_TPLURE, from_id)) ) ||
( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) && (isAgentAvatarValid()) && (gAgentAvatarp->isSitting()) ) )
{
rlvSendBusyMessage(from_id, RlvStrings::getString(RLV_STRING_BLOCKED_TPLURE_REMOTE));
RlvUtil::sendBusyMessage(from_id, RlvStrings::getString(RLV_STRING_BLOCKED_TPLURE_REMOTE));
return;
}
@ -3229,7 +3229,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
( (CHAT_SOURCE_OBJECT == chat.mSourceType) && ((!is_owned_by_me) || (!is_attachment)) &&
(CHAT_TYPE_OWNER != chat.mChatType) ) )
{
if (!rlvIsEmote(mesg))
if (!RlvUtil::isEmote(mesg))
{
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_RECVCHAT)) && (!gRlvHandler.isException(RLV_BHVR_RECVCHAT, from_id)) )
gRlvHandler.filterChat(mesg, false);
@ -3253,7 +3253,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
}
else if ( (!is_owned_by_me) || (!is_attachment) )
{
gRlvHandler.filterNames(chat.mFromName);
RlvUtil::filterNames(chat.mFromName);
}
}

View File

@ -16,10 +16,16 @@
#include "llviewerprecompiledheaders.h"
#include "llagent.h"
#include "llagentui.h"
#include "llappviewer.h"
#include "llinstantmessage.h"
#include "llnotificationsutil.h"
#include "lluictrlfactory.h"
#include "llversionviewer.h"
#include "llviewerparcelmgr.h"
#include "llviewerregion.h"
#include "llviewerstats.h"
#include "llworld.h"
#include "rlvcommon.h"
#include "rlvhandler.h"
@ -320,6 +326,111 @@ bool RlvStrings::hasString(const std::string& strStringName)
return m_StringMap.find(strStringName) != m_StringMap.end();
}
// ============================================================================
// RlvUtil
//
// Checked: 2009-07-04 (RLVa-1.0.0a) | Modified: RLVa-1.0.0a
void RlvUtil::filterLocation(std::string& strUTF8Text)
{
// TODO-RLVa: if either the region or parcel name is a simple word such as "a" or "the" then confusion will ensue?
// -> not sure how you would go about preventing this though :|...
// Filter any mention of the surrounding region names
LLWorld::region_list_t regions = LLWorld::getInstance()->getRegionList();
const std::string& strHiddenRegion = RlvStrings::getString(RLV_STRING_HIDDEN_REGION);
for (LLWorld::region_list_t::const_iterator itRegion = regions.begin(); itRegion != regions.end(); ++itRegion)
rlvStringReplace(strUTF8Text, (*itRegion)->getName(), strHiddenRegion);
// Filter any mention of the parcel name
LLViewerParcelMgr* pParcelMgr = LLViewerParcelMgr::getInstance();
if (pParcelMgr)
rlvStringReplace(strUTF8Text, pParcelMgr->getAgentParcelName(), RlvStrings::getString(RLV_STRING_HIDDEN_PARCEL));
}
// Checked: 2010-04-22 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f
void RlvUtil::filterNames(std::string& strUTF8Text)
{
std::vector<LLUUID> idAgents;
LLWorld::getInstance()->getAvatars(&idAgents, NULL);
std::string strFullName;
for (int idxAgent = 0, cntAgent = idAgents.size(); idxAgent < cntAgent; idxAgent++)
{
// LLCacheName::getFullName() will add the UUID to the lookup queue if we don't know it yet
if (gCacheName->getFullName(idAgents[idxAgent], strFullName))
rlvStringReplace(strUTF8Text, strFullName, RlvStrings::getAnonym(strFullName));
}
}
// Checked: 2010-04-22 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f
bool RlvUtil::isNearbyAgent(const LLUUID& idAgent)
{
// Sanity check since we call this with notification payloads as well and those strings tend to change from one release to another
RLV_ASSERT(idAgent.notNull());
if ( (idAgent.notNull()) && (gAgent.getID() != idAgent) )
{
std::vector<LLUUID> idAgents;
LLWorld::getInstance()->getAvatars(&idAgents, NULL);
for (int idxAgent = 0, cntAgent = idAgents.size(); idxAgent < cntAgent; idxAgent++)
if (idAgents[idxAgent] == idAgent)
return true;
}
return false;
}
// Checked: 2010-04-05 (RLVa-1.2.0d) | Modified: RLVa-1.2.0d
bool RlvUtil::isNearbyRegion(const std::string& strRegion)
{
LLWorld::region_list_t regions = LLWorld::getInstance()->getRegionList();
for (LLWorld::region_list_t::const_iterator itRegion = regions.begin(); itRegion != regions.end(); ++itRegion)
if ((*itRegion)->getName() == strRegion)
return true;
return false;
}
// Checked: 2010-04-08 (RLVa-1.2.0d) | Added: RLVa-1.2.0d
void RlvUtil::notifyFailedAssertion(const char* pstrAssert, const char* pstrFile, int nLine)
{
LLSD argsNotify;
argsNotify["MESSAGE"] = llformat("RLVa assertion failure: %s (%s - %d)", pstrAssert, pstrFile, nLine);
LLNotificationsUtil::add("SystemMessageTip", argsNotify);
}
// Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0b
void RlvUtil::sendBusyMessage(const LLUUID& idTo, const std::string& strMsg, const LLUUID& idSession)
{
// [See process_improved_im()]
std::string strFullName;
LLAgentUI::buildFullname(strFullName);
pack_instant_message(gMessageSystem, gAgent.getID(), FALSE, gAgent.getSessionID(), idTo, strFullName,
strMsg, IM_ONLINE, IM_BUSY_AUTO_RESPONSE, idSession);
gAgent.sendReliableMessage();
}
// Checked: 2010-03-09 (RLVa-1.2.0a) | Modified: RLVa-1.0.1e
bool RlvUtil::sendChatReply(S32 nChannel, const std::string& strUTF8Text)
{
if (!isValidReplyChannel(nChannel))
return false;
// Copy/paste from send_chat_from_viewer()
gMessageSystem->newMessageFast(_PREHASH_ChatFromViewer);
gMessageSystem->nextBlockFast(_PREHASH_AgentData);
gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
gMessageSystem->nextBlockFast(_PREHASH_ChatData);
gMessageSystem->addStringFast(_PREHASH_Message, strUTF8Text);
gMessageSystem->addU8Fast(_PREHASH_Type, CHAT_TYPE_SHOUT);
gMessageSystem->addS32("Channel", nChannel);
gAgent.sendReliableMessage();
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT);
return true;
}
// ============================================================================
// Generic menu enablers
//

View File

@ -115,6 +115,28 @@ protected:
#endif // RLV_EXTENSION_NOTIFY_BEHAVIOUR
};
// ============================================================================
// RlvUtil - Collection of (static) helper functions
//
class RlvUtil
{
public:
static bool isEmote(const std::string& strUTF8Text);
static bool isNearbyAgent(const LLUUID& idAgent); // @shownames
static bool isNearbyRegion(const std::string& strRegion); // @showloc
static void filterLocation(std::string& strUTF8Text); // @showloc
static void filterNames(std::string& strUTF8Text); // @shownames
static void notifyFailedAssertion(const char* pstrAssert, const char* pstrFile, int nLine);
static void sendBusyMessage(const LLUUID& idTo, const std::string& strMsg, const LLUUID& idSession = LLUUID::null);
static bool isValidReplyChannel(S32 nChannel);
static bool sendChatReply(S32 nChannel, const std::string& strUTF8Text);
static bool sendChatReply(const std::string& strChannel, const std::string& strUTF8Text);
};
// ============================================================================
// Extensibility classes
//
@ -186,6 +208,29 @@ protected:
const LLViewerInventoryItem* m_pItem;
};
// ============================================================================
// Inlined class member functions
//
// Checked: 2010-03-26 (RLVa-1.2.0b) | Modified: RLVa-1.0.2a
inline bool RlvUtil::isEmote(const std::string& strUTF8Text)
{
return (strUTF8Text.length() > 4) && ( (strUTF8Text.compare(0, 4, "/me ") == 0) || (strUTF8Text.compare(0, 4, "/me'") == 0) );
}
// Checked: 2010-03-09 (RLVa-1.2.0b) | Added: RLVa-1.0.2a
inline bool RlvUtil::isValidReplyChannel(S32 nChannel)
{
return (nChannel > 0) && (CHAT_CHANNEL_DEBUG != nChannel);
}
// Checked: 2009-08-05 (RLVa-1.0.1e) | Added: RLVa-1.0.0e
inline bool RlvUtil::sendChatReply(const std::string& strChannel, const std::string& strUTF8Text)
{
S32 nChannel;
return (LLStringUtil::convertToS32(strChannel, nChannel)) ? sendChatReply(nChannel, strUTF8Text) : false;
}
// ============================================================================
#endif // RLV_COMMON_H

View File

@ -89,7 +89,7 @@ const S32 RLVa_VERSION_BUILD = 1;
#define RLV_INFOS LL_INFOS("RLV")
#define RLV_DEBUGS LL_DEBUGS("RLV")
#define RLV_ENDL LL_ENDL
#define RLV_VERIFY(f) if (!(f)) { rlvNotifyFailedAssertion(#f, __FILE__, __LINE__); }
#define RLV_VERIFY(f) if (!(f)) { RlvUtil::notifyFailedAssertion(#f, __FILE__, __LINE__); }
#if LL_RELEASE_WITH_DEBUG_INFO || LL_DEBUG
// Turn on extended debugging information

View File

@ -82,7 +82,7 @@ bool RlvExtGetSet::processCommand(const LLUUID& idObj, const RlvCommand& rlvCmd,
{
if ( ("get" == strGetSet) && (RLV_TYPE_REPLY == rlvCmd.getParamType()) )
{
rlvSendChatReply(rlvCmd.getParam(), onGetDebug(strSetting));
RlvUtil::sendChatReply(rlvCmd.getParam(), onGetDebug(strSetting));
eRet = RLV_RET_SUCCESS;
return true;
}
@ -97,7 +97,7 @@ bool RlvExtGetSet::processCommand(const LLUUID& idObj, const RlvCommand& rlvCmd,
{
if ( ("get" == strGetSet) && (RLV_TYPE_REPLY == rlvCmd.getParamType()) )
{
rlvSendChatReply(rlvCmd.getParam(), onGetEnv(strSetting));
RlvUtil::sendChatReply(rlvCmd.getParam(), onGetEnv(strSetting));
eRet = RLV_RET_SUCCESS;
return true;
}

View File

@ -22,7 +22,6 @@
#include "llviewerobjectlist.h"
#include "llviewerparcelmgr.h"
#include "llviewerregion.h"
#include "llworld.h"
#include "rlvhandler.h"
#include "rlvinventory.h"
@ -89,7 +88,7 @@ static bool rlvParseNotifyOption(const std::string& strOption, S32& nChannel, st
boost_tokenizer::const_iterator itTok = tokens.begin();
// Extract and sanity check the first token (required) which is the channel
if ( (itTok == tokens.end()) || (!LLStringUtil::convertToS32(*itTok, nChannel)) || (!rlvIsValidReplyChannel(nChannel)) )
if ( (itTok == tokens.end()) || (!LLStringUtil::convertToS32(*itTok, nChannel)) || (!RlvUtil::isValidReplyChannel(nChannel)) )
return false;
// Second token (optional) is the filter
@ -624,7 +623,7 @@ void RlvHandler::filterChat(std::string& strUTF8Text, bool fFilterEmote) const
if (strUTF8Text.empty())
return;
if (rlvIsEmote(strUTF8Text)) // Check if it's an emote
if (RlvUtil::isEmote(strUTF8Text)) // Check if it's an emote
{
if (fFilterEmote) // Emote filtering depends on fFilterEmote
{
@ -652,45 +651,11 @@ void RlvHandler::filterChat(std::string& strUTF8Text, bool fFilterEmote) const
}
}
// Checked: 2009-07-04 (RLVa-1.0.0a) | Modified: RLVa-1.0.0a
void RlvHandler::filterLocation(std::string& strUTF8Text)
{
// TODO-RLVa: if either the region or parcel name is a simple word such as "a" or "the" then confusion will ensue?
// -> not sure how you would go about preventing this though :|...
// Filter any mention of the surrounding region names
LLWorld::region_list_t regions = LLWorld::getInstance()->getRegionList();
const std::string& strHiddenRegion = RlvStrings::getString(RLV_STRING_HIDDEN_REGION);
for (LLWorld::region_list_t::const_iterator itRegion = regions.begin(); itRegion != regions.end(); ++itRegion)
rlvStringReplace(strUTF8Text, (*itRegion)->getName(), strHiddenRegion);
// Filter any mention of the parcel name
LLViewerParcelMgr* pParcelMgr = LLViewerParcelMgr::getInstance();
if (pParcelMgr)
rlvStringReplace(strUTF8Text, pParcelMgr->getAgentParcelName(), RlvStrings::getString(RLV_STRING_HIDDEN_PARCEL));
}
// Checked: 2010-04-22 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f
void RlvHandler::filterNames(std::string& strUTF8Text)
{
// TODO-RLVa: [RLVa-1.2.1] Should we restrict this to a certain radius?
std::vector<LLUUID> idAgents;
LLWorld::getInstance()->getAvatars(&idAgents, NULL);
std::string strFullName;
for (int idxAgent = 0, cntAgent = idAgents.size(); idxAgent < cntAgent; idxAgent++)
{
// LLCacheName::getFullName() will add the UUID to the lookup queue if we don't know it yet
if (gCacheName->getFullName(idAgents[idxAgent], strFullName))
rlvStringReplace(strUTF8Text, strFullName, RlvStrings::getAnonym(strFullName));
}
}
// Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0a
bool RlvHandler::redirectChatOrEmote(const std::string& strUTF8Text) const
{
// Sanity check - @redirchat only for chat and @rediremote only for emotes
ERlvBehaviour eBhvr = (!rlvIsEmote(strUTF8Text)) ? RLV_BHVR_REDIRCHAT : RLV_BHVR_REDIREMOTE;
ERlvBehaviour eBhvr = (!RlvUtil::isEmote(strUTF8Text)) ? RLV_BHVR_REDIRCHAT : RLV_BHVR_REDIREMOTE;
if (!hasBehaviour(eBhvr))
return false;
@ -707,43 +672,12 @@ bool RlvHandler::redirectChatOrEmote(const std::string& strUTF8Text) const
{
S32 nChannel = boost::get<S32>(itRedir->second.varOption);
if ( (!hasBehaviour(RLV_BHVR_SENDCHANNEL)) || (isException(RLV_BHVR_SENDCHANNEL, nChannel)) )
rlvSendChatReply(nChannel, strUTF8Text);
RlvUtil::sendChatReply(nChannel, strUTF8Text);
}
return true;
}
// ============================================================================
// Public service functions (called by the outside world or by extension handlers)
//
// Checked: 2010-04-22 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f
bool RlvHandler::isNearbyAgent(const LLUUID& idAgent)
{
// Sanity check since we call this with notification payloads as well and those strings tend to change from one release to another
RLV_ASSERT(idAgent.notNull());
if ( (idAgent.notNull()) && (gAgent.getID() != idAgent) )
{
std::vector<LLUUID> idAgents;
LLWorld::getInstance()->getAvatars(&idAgents, NULL);
for (int idxAgent = 0, cntAgent = idAgents.size(); idxAgent < cntAgent; idxAgent++)
if (idAgents[idxAgent] == idAgent)
return true;
}
return false;
}
// Checked: 2010-04-05 (RLVa-1.2.0d) | Modified: RLVa-1.2.0d
bool RlvHandler::isNearbyRegion(const std::string& strRegion)
{
LLWorld::region_list_t regions = LLWorld::getInstance()->getRegionList();
for (LLWorld::region_list_t::const_iterator itRegion = regions.begin(); itRegion != regions.end(); ++itRegion)
if ((*itRegion)->getName() == strRegion)
return true;
return false;
}
// ============================================================================
// Composite folders
//
@ -1085,7 +1019,7 @@ ERlvCmdRet RlvHandler::processAddRemCommand(const LLUUID& idObj, const RlvComman
{
// There should be an option which should specify a valid reply channel (if there's an empty option the command is invalid)
S32 nChannel = 0;
VERIFY_OPTION_REF( (LLStringUtil::convertToS32(strOption, nChannel)) && (rlvIsValidReplyChannel(nChannel)) );
VERIFY_OPTION_REF( (LLStringUtil::convertToS32(strOption, nChannel)) && (RlvUtil::isValidReplyChannel(nChannel)) );
if (RLV_TYPE_ADD == eType)
addException(idObj, eBhvr, nChannel);
@ -1571,7 +1505,7 @@ ERlvCmdRet RlvHandler::processReplyCommand(const LLUUID& idObj, const RlvCommand
// Sanity check - <param> should specify a - valid - reply channel
S32 nChannel;
if ( (!LLStringUtil::convertToS32(rlvCmd.getParam(), nChannel)) || (!rlvIsValidReplyChannel(nChannel)) )
if ( (!LLStringUtil::convertToS32(rlvCmd.getParam(), nChannel)) || (!RlvUtil::isValidReplyChannel(nChannel)) )
return RLV_RET_FAILED_PARAM;
ERlvCmdRet eRet = RLV_RET_SUCCESS; std::string strReply;
@ -1661,7 +1595,7 @@ ERlvCmdRet RlvHandler::processReplyCommand(const LLUUID& idObj, const RlvCommand
// If we made it this far then:
// - the command was handled successfully so we send off the response
// - the command failed but we still send off an - empty - response to keep the issuing script from blocking
rlvSendChatReply(nChannel, strReply);
RlvUtil::sendChatReply(nChannel, strReply);
return eRet;
}

View File

@ -95,10 +95,6 @@ public:
bool canStand() const;
bool canTouch(LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero) const; // @touch
void filterChat(std::string& strUTF8Text, bool fFilterEmote) const; // @sendchat, @recvchat and @redirchat
static void filterLocation(std::string& strUTF8Text); // @showloc
static void filterNames(std::string& strUTF8Text); // @shownames
static bool isNearbyAgent(const LLUUID& idAgent); // @shownames
static bool isNearbyRegion(const std::string& strRegion); // @showloc
bool redirectChatOrEmote(const std::string& strUTF8Test) const; // @redirchat and @rediremote
// Command processing helper functions

View File

@ -15,16 +15,13 @@
*/
#include "llviewerprecompiledheaders.h"
#include "llagentui.h"
#include "llagentwearables.h"
#include "llappearancemgr.h"
#include "llgesturemgr.h"
#include "llinstantmessage.h"
#include "llnotifications.h"
#include "llnotificationsutil.h"
#include "llviewerobject.h"
#include "llviewerobjectlist.h"
#include "llviewerstats.h"
#include "llwlparammanager.h"
#include "rlvhelper.h"
@ -790,7 +787,7 @@ void RlvBehaviourNotifyHandler::onCommand(const LLUUID& idRlvObj, const RlvComma
itNotify != m_Notifications.end(); ++itNotify)
{
if ( (itNotify->second.strFilter.empty()) || (std::string::npos != strCmd.find(itNotify->second.strFilter)) )
rlvSendChatReply(itNotify->second.nChannel, strNotify);
RlvUtil::sendChatReply(itNotify->second.nChannel, strNotify);
}
}
@ -869,52 +866,6 @@ bool rlvCanDeleteOrReturn()
return fIsAllowed;
}
// Checked: 2010-04-08 (RLVa-1.2.0d) | Added: RLVa-1.2.0d
void rlvNotifyFailedAssertion(const char* pstrAssert, const char* pstrFile, int nLine)
{
LLSD argsNotify;
argsNotify["MESSAGE"] = llformat("RLVa assertion failure: %s (%s - %d)", pstrAssert, pstrFile, nLine);
LLNotificationsUtil::add("SystemMessageTip", argsNotify);
}
// =========================================================================
// Message sending functions
//
// Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0b
void rlvSendBusyMessage(const LLUUID& idTo, const std::string& strMsg, const LLUUID& idSession)
{
// [See process_improved_im()]
std::string strFullName;
LLAgentUI::buildFullname(strFullName);
pack_instant_message(gMessageSystem, gAgent.getID(), FALSE, gAgent.getSessionID(), idTo, strFullName,
strMsg, IM_ONLINE, IM_BUSY_AUTO_RESPONSE, idSession);
gAgent.sendReliableMessage();
}
// Checked: 2010-03-09 (RLVa-1.2.0a) | Modified: RLVa-1.0.1e
bool rlvSendChatReply(S32 nChannel, const std::string& strReply)
{
if (!rlvIsValidReplyChannel(nChannel))
return false;
// Copy/paste from send_chat_from_viewer()
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_ChatFromViewer);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_ChatData);
msg->addStringFast(_PREHASH_Message, strReply);
msg->addU8Fast(_PREHASH_Type, CHAT_TYPE_SHOUT);
msg->addS32("Channel", nChannel);
gAgent.sendReliableMessage();
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT);
return true;
}
// =========================================================================
// String helper functions
//

View File

@ -305,24 +305,11 @@ public:
//
bool rlvCanDeleteOrReturn();
bool rlvIsEmote(const std::string& strUTF8Text);
bool rlvIsValidReplyChannel(S32 nChannel);
void rlvSendBusyMessage(const LLUUID& idTo, const std::string& strMsg, const LLUUID& idSession = LLUUID::null);
bool rlvSendChatReply(const std::string& strChannel, const std::string& strReply);
bool rlvSendChatReply(S32 nChannel, const std::string& strReply);
std::string rlvGetFirstParenthesisedText(const std::string& strText, std::string::size_type* pidxMatch = NULL);
std::string rlvGetLastParenthesisedText(const std::string& strText, std::string::size_type* pidxStart = NULL);
void rlvStringReplace(std::string& strText, std::string strFrom, const std::string& strTo);
// ============================================================================
// Debug helper functions
//
void rlvDebugFailedAssertion(const char* pstrAssert, const char* pstrFile, int nLine);
void rlvNotifyFailedAssertion(const char* pstrAssert, const char* pstrFile, int nLine);
// ============================================================================
// Inlined class member functions
//
@ -368,29 +355,6 @@ inline bool RlvForceWear::isWearableItem(const LLInventoryItem* pItem)
(LLAssetType::AT_OBJECT == assetType) || (LLAssetType::AT_GESTURE == assetType);
}
// ============================================================================
// Inlined helper functions
//
// Checked: 2010-03-26 (RLVa-1.2.0b) | Modified: RLVa-1.0.2a
inline bool rlvIsEmote(const std::string& strUTF8Text)
{
return (strUTF8Text.length() > 4) && ( (strUTF8Text.compare(0, 4, "/me ") == 0) || (strUTF8Text.compare(0, 4, "/me'") == 0) );
}
// Checked: 2010-03-09 (RLVa-1.2.0b) | Added: RLVa-1.0.2a
inline bool rlvIsValidReplyChannel(S32 nChannel)
{
return (nChannel > 0) && (CHAT_CHANNEL_DEBUG != nChannel);
}
// Checked: 2009-08-05 (RLVa-1.0.1e) | Added: RLVa-1.0.0e
inline bool rlvSendChatReply(const std::string& strChannel, const std::string& strReply)
{
S32 nChannel;
return (LLStringUtil::convertToS32(strChannel, nChannel)) ? rlvSendChatReply(nChannel, strReply) : false;
}
// ============================================================================
#endif // RLV_HELPER_H