- internal : reviewed @startim for CHUI (SL-3.5)

-> fixed : "Send Instant Message" on a calling card opens an IM session
    -> fixed : "Start Conference Chat" on a selection of multiple calling cards opens an IM session
    -> fixed : actions that would result in an IM window opening shouldn't be blocked if the session is already open
    -> added : RlvActions class to mimick LLAvatarActions and lowering the rlvhandler.h include dependency

--HG--
branch : RLVa
master
Kitty Barnett 2013-05-09 15:09:03 +02:00
parent a9ffc0120a
commit 574e054b09
12 changed files with 194 additions and 50 deletions

View File

@ -664,6 +664,7 @@ set(viewer_SOURCE_FILES
llxmlrpctransaction.cpp
noise.cpp
pipeline.cpp
rlvactions.cpp
rlvhandler.cpp
rlvhelper.cpp
rlvcommon.cpp
@ -1244,6 +1245,7 @@ set(viewer_HEADER_FILES
macmain.h
noise.h
pipeline.h
rlvactions.h
rlvdefines.h
rlvhandler.h
rlvhelper.h

View File

@ -73,8 +73,9 @@
#include "llcallingcard.h"
#include "llslurl.h" // IDEVO
#include "llsidepanelinventory.h"
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h
#include "rlvhandler.h"
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0)
#include "rlvactions.h"
#include "rlvcommon.h"
// [/RLVa:KB]
// static
@ -199,16 +200,12 @@ void LLAvatarActions::startIM(const LLUUID& id)
if (id.isNull() || gAgent.getID() == id)
return;
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h
if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canStartIM(id)) )
// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9)
if ( (!RlvActions::canStartIM(id)) && (!RlvActions::hasOpenP2PSession(id)) )
{
LLUUID idSession = gIMMgr->computeSessionID(IM_NOTHING_SPECIAL, id);
if ( (idSession.notNull()) && (!gIMMgr->hasSession(idSession)) )
{
make_ui_sound("UISndInvalidOp");
RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTIM, LLSD().with("RECIPIENT", LLSLURL("agent", id, "completename").getSLURLString()));
return;
}
make_ui_sound("UISndInvalidOp");
RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTIM, LLSD().with("RECIPIENT", LLSLURL("agent", id, "completename").getSLURLString()));
return;
}
// [/RLVa:KB]
@ -248,16 +245,12 @@ void LLAvatarActions::startCall(const LLUUID& id)
return;
}
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h
if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canStartIM(id)) )
// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9)
if ( (!RlvActions::canStartIM(id)) && (!RlvActions::hasOpenP2PSession(id)) )
{
LLUUID idSession = gIMMgr->computeSessionID(IM_NOTHING_SPECIAL, id);
if ( (idSession.notNull()) && (!gIMMgr->hasSession(idSession)) )
{
make_ui_sound("UISndInvalidOp");
RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTIM, LLSD().with("RECIPIENT", LLSLURL("agent", id, "completename").getSLURLString()));
return;
}
make_ui_sound("UISndInvalidOp");
RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTIM, LLSD().with("RECIPIENT", LLSLURL("agent", id, "completename").getSLURLString()));
return;
}
// [/RLVa:KB]
@ -276,12 +269,12 @@ void LLAvatarActions::startAdhocCall(const uuid_vec_t& ids, const LLUUID& floate
LLDynamicArray<LLUUID> id_array;
for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it)
{
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0)
const LLUUID& idAgent = *it;
if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canStartIM(idAgent)) )
if (!RlvActions::canStartIM(idAgent))
{
make_ui_sound("UISndInvalidOp");
RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTCONF, LLSD().with("RECIPIENT", LLSLURL("agent", idAgent, "completename").getSLURLString()));
RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTCONF);
return;
}
id_array.push_back(idAgent);
@ -331,12 +324,12 @@ void LLAvatarActions::startConference(const uuid_vec_t& ids, const LLUUID& float
LLDynamicArray<LLUUID> id_array;
for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it)
{
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0)
const LLUUID& idAgent = *it;
if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canStartIM(idAgent)) )
if (!RlvActions::canStartIM(idAgent))
{
make_ui_sound("UISndInvalidOp");
RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTCONF, LLSD().with("RECIPIENT", LLSLURL("agent", idAgent, "completename").getSLURLString()));
RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTCONF);
return;
}
id_array.push_back(idAgent);

View File

@ -38,6 +38,7 @@
#include "llviewerregion.h" // getCapability()
#include "llworld.h"
// [RLVa:KB] - Checked: 2010-06-04 (RLVa-1.2.2a)
#include "rlvactions.h"
#include "rlvhandler.h"
// [/RLVa:KB]
@ -611,8 +612,8 @@ BOOL LLFloaterAvatarPicker::handleDragAndDrop(S32 x, S32 y, MASK mask,
if (dest_agent_id.notNull() && dest_agent_id != gAgentID)
{
// if (drop)
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h
if ( (drop) && ( (!rlv_handler_t::isEnabled()) || (gRlvHandler.canStartIM(dest_agent_id)) ) )
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0)
if ( (drop) && (RlvActions::canStartIM(dest_agent_id)) )
// [/RLVa:KB]
{
// Start up IM before give the item

View File

@ -41,8 +41,10 @@
#include "llnotificationsutil.h"
#include "llstatusbar.h" // can_afford_transaction()
#include "groupchatlistener.h"
// [RLVa:KB] - Checked: 2011-03-28 (RLVa-1.3.0f)
// [RLVa:KB] - Checked: 2011-03-28 (RLVa-1.3.0)
#include "llslurl.h"
#include "rlvactions.h"
#include "rlvcommon.h"
#include "rlvhandler.h"
// [/RLVa:KB]
@ -138,8 +140,8 @@ void LLGroupActions::startCall(const LLUUID& group_id)
return;
}
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h
if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canStartIM(group_id)) && (!gIMMgr->hasSession(group_id)) )
// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9)
if ( (!RlvActions::canStartIM(group_id)) && (!RlvActions::hasOpenGroupSession(group_id)) )
{
make_ui_sound("UISndInvalidOp");
RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTIM, LLSD().with("RECIPIENT", LLSLURL("group", group_id, "about").getSLURLString()));
@ -350,8 +352,8 @@ LLUUID LLGroupActions::startIM(const LLUUID& group_id)
{
if (group_id.isNull()) return LLUUID::null;
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h
if ( (rlv_handler_t::isEnabled()) && (!gRlvHandler.canStartIM(group_id)) && (!gIMMgr->hasSession(group_id)) )
// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9)
if ( (!RlvActions::canStartIM(group_id)) && (!RlvActions::hasOpenGroupSession(group_id)) )
{
make_ui_sound("UISndInvalidOp");
RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTIM, LLSD().with("RECIPIENT", LLSLURL("group", group_id, "about").getSLURLString()));

View File

@ -75,6 +75,7 @@
#include "llwearablelist.h"
#include "lllandmarkactions.h"
// [RLVa:KB] - Checked: 2011-05-22 (RLVa-1.3.1)
#include "rlvactions.h"
#include "rlvhandler.h"
#include "rlvlocks.h"
// [/RLVa:KB]
@ -4781,6 +4782,16 @@ void LLCallingCardBridge::performAction(LLInventoryModel* model, std::string act
{
callingcard_name = av_name.getCompleteName();
}
// [RLVa:KB] - Checked: 2013-05-08 (RLVa-1.4.9)
if ( (!RlvActions::canStartIM(item->getCreatorUUID())) && (!RlvActions::hasOpenP2PSession(item->getCreatorUUID())) )
{
make_ui_sound("UISndInvalidOp");
RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTIM, LLSD().with("RECIPIENT", LLSLURL("agent", item->getCreatorUUID(), "completename").getSLURLString()));
return;
}
// [/RLVa:KB]
LLUUID session_id = gIMMgr->addSession(callingcard_name, IM_NOTHING_SPECIAL, item->getCreatorUUID());
if (session_id != LLUUID::null)
{

View File

@ -50,6 +50,10 @@
#include "llviewerattachmenu.h"
#include "llviewerfoldertype.h"
#include "llvoavatarself.h"
// [RLVa:KB] - Checked: 2013-05-08 (RLVa-1.4.9)
#include "rlvactions.h"
#include "rlvcommon.h"
// [/RLVa:KB]
static LLDefaultChildRegistry::Register<LLInventoryPanel> r("inventory_panel");
@ -1026,6 +1030,10 @@ bool LLInventoryPanel::beginIMSession()
LLDynamicArray<LLUUID> members;
EInstantMessage type = IM_SESSION_CONFERENCE_START;
// [RLVa:KB] - Checked: 2013-05-08 (RLVa-1.4.9)
bool fRlvCanStartIM = true;
// [/RLVa:KB]
std::set<LLFolderViewItem*>::const_iterator iter;
for (iter = selected_items.begin(); iter != selected_items.end(); iter++)
{
@ -1065,6 +1073,9 @@ bool LLInventoryPanel::beginIMSession()
id = item_array.get(i)->getCreatorUUID();
if(at.isBuddyOnline(id))
{
// [RLVa:KB] - Checked: 2013-05-08 (RLVa-1.4.9)
fRlvCanStartIM &= RlvActions::canStartIM(id);
// [/RLVa:KB]
members.put(id);
}
}
@ -1085,6 +1096,9 @@ bool LLInventoryPanel::beginIMSession()
if(at.isBuddyOnline(id))
{
// [RLVa:KB] - Checked: 2013-05-08 (RLVa-1.4.9)
fRlvCanStartIM &= RlvActions::canStartIM(id);
// [/RLVa:KB]
members.put(id);
}
}
@ -1096,6 +1110,15 @@ bool LLInventoryPanel::beginIMSession()
// the session_id is randomly generated UUID which will be replaced later
// with a server side generated number
// [RLVa:KB] - Checked: 2013-05-08 (RLVa-1.4.9)
if (!fRlvCanStartIM)
{
make_ui_sound("UISndInvalidOp");
RlvUtil::notifyBlocked(RLV_STRING_BLOCKED_STARTCONF);
return true;
}
// [/RLVa:KB]
if (name.empty())
{
name = LLTrans::getString("conference-title");

View File

@ -38,6 +38,10 @@
#include "lltoastalertpanel.h"
// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9)
#include "rlvactions.h"
// [/RLVa:KB]
using namespace LLNotificationsUI;
//--------------------------------------------------------------------------
@ -88,8 +92,19 @@ bool LLAlertHandler::processNotification(const LLNotificationPtr& notification)
LLUUID from_id = notification->getPayload()["from_id"];
// firstly create session...
LLHandlerUtil::spawnIMSession(name, from_id);
// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9)
// Don't spawn an IM session for non-chat related events:
// - LLHandlerUtil::logToIMP2P() below will still be called with to_file_only == false
// - LLHandlerUtil::logToIM() will eventually be called as a result and without an open IM session it will log the
// same message as it would for an open session whereas to_file_only == true would take a different code path
if ( (RlvActions::hasOpenP2PSession(from_id)) || (RlvActions::canStartIM(from_id)) )
{
// [/RLVa:KB]
// firstly create session...
LLHandlerUtil::spawnIMSession(name, from_id);
// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9)
}
// [/RLVa:KB]
// ...then log message to have IM Well notified about new message
LLHandlerUtil::logToIMP2P(notification);

View File

@ -36,6 +36,9 @@
#include "llscriptfloater.h"
#include "llimview.h"
#include "llnotificationsutil.h"
// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9)
#include "rlvactions.h"
// [/RLVa:KB]
using namespace LLNotificationsUI;
@ -108,9 +111,21 @@ bool LLOfferHandler::processNotification(const LLNotificationPtr& notification)
notification->playSound();
}
LLHandlerUtil::spawnIMSession(name, from_id);
LLHandlerUtil::addNotifPanelToIM(notification);
// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9)
// Don't spawn an IM session for non-chat related events
if ( (RlvActions::hasOpenP2PSession(from_id)) || (RlvActions::canStartIM(from_id)) )
{
// [/RLVa:KB]
LLHandlerUtil::spawnIMSession(name, from_id);
LLHandlerUtil::addNotifPanelToIM(notification);
// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9)
}
else
{
// Since we didn't add this notification to an IM session we want it to get routed to the notification syswell
add_notif_to_im = false;
}
// [/RLVa:KB]
}
if (!notification->canShowToast())

View File

@ -0,0 +1,51 @@
/**
*
* Copyright (c) 2009-2013, Kitty Barnett
*
* The source code in this file is provided to you under the terms of the
* GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt
* in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt
*
* By copying, modifying or distributing this software, you acknowledge that
* you have read and understood your obligations described above, and agree to
* abide by those obligations.
*
*/
#include "llviewerprecompiledheaders.h"
#include "llimview.h"
#include "rlvactions.h"
#include "rlvhandler.h"
// ============================================================================
// RlvActions member functions
//
// Checked: 2011-04-12 (RLVa-1.3.0)
bool RlvActions::canStartIM(const LLUUID& idRecipient)
{
// User can start an IM session with "recipient" (could be an agent or a group) if:
// - not generally restricted from starting IM sessions (or the recipient is an exception)
// - not specifically restricted from starting an IM session with the recipient
return
(!rlv_handler_t::isEnabled()) ||
( ( (!gRlvHandler.hasBehaviour(RLV_BHVR_STARTIM)) || (gRlvHandler.isException(RLV_BHVR_STARTIM, idRecipient)) ) &&
( (!gRlvHandler.hasBehaviour(RLV_BHVR_STARTIMTO)) || (!gRlvHandler.isException(RLV_BHVR_STARTIMTO, idRecipient)) ) );
}
// Checked: 2013-05-09 (RLVa-1.4.9)
bool RlvActions::hasOpenP2PSession(const LLUUID& idAgent)
{
const LLUUID idSession = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, idAgent);
return (idSession.notNull()) && (LLIMMgr::instance().hasSession(idSession));
}
// Checked: 2013-05-09 (RLVa-1.4.9)
bool RlvActions::hasOpenGroupSession(const LLUUID& idGroup)
{
return (idGroup.notNull()) && (LLIMMgr::instance().hasSession(idGroup));
}
// ============================================================================

View File

@ -0,0 +1,42 @@
/**
*
* Copyright (c) 2009-2013, Kitty Barnett
*
* The source code in this file is provided to you under the terms of the
* GNU Lesser General Public License, version 2.1, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. Terms of the LGPL can be found in doc/LGPL-licence.txt
* in this distribution, or online at http://www.gnu.org/licenses/lgpl-2.1.txt
*
* By copying, modifying or distributing this software, you acknowledge that
* you have read and understood your obligations described above, and agree to
* abide by those obligations.
*
*/
#ifndef RLV_ACTIONS_H
#define RLV_ACTIONS_H
// ============================================================================
// RlvActions class declaration
//
class RlvActions
{
public:
/*
* 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
/*
* Returns true if a - P2P or group - IM session is open with the specified UUID.
*/
static bool hasOpenP2PSession(const LLUUID& idAgent);
static bool hasOpenGroupSession(const LLUUID& idGroup);
};
// ============================================================================
#endif // RLV_ACTIONS_H

View File

@ -99,7 +99,6 @@ public:
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 canStartIM(const LLUUID& idRecipient) const; // @startim and @startimto
bool canStand() const;
bool canTeleportViaLure(const LLUUID& idAgent) const;
bool canTouch(const LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero) const; // @touch
@ -280,16 +279,6 @@ inline bool RlvHandler::canShowHoverText(const LLViewerObject *pObj) const
(isException(RLV_BHVR_SHOWHOVERTEXT, pObj->getID(), RLV_CHECK_PERMISSIVE)) ) );
}
inline bool RlvHandler::canStartIM(const LLUUID& idRecipient) const
{
// User can start an IM session with "recipient" (could be an agent or a group) if:
// - not generally restricted from starting IM sessions (or the recipient is an exception)
// - not specifically restricted from starting an IM session with the recipient
return
( (!hasBehaviour(RLV_BHVR_STARTIM)) || (isException(RLV_BHVR_STARTIM, idRecipient)) ) &&
( (!hasBehaviour(RLV_BHVR_STARTIMTO)) || (!isException(RLV_BHVR_STARTIMTO, idRecipient)) );
}
// Checked: 2010-12-11 (RLVa-1.2.2c) | Added: RLVa-1.2.2c
inline bool RlvHandler::canTeleportViaLure(const LLUUID& idAgent) const
{

View File

@ -16,7 +16,7 @@
<string name="blocked_permattach">Attempt to attach '[OBJECT]' was denied due to RLV restrictions</string>
<string name="blocked_permteleport">'[OBJECT]' was denied permission to teleport you due to RLV restrictions</string>
<string name="blocked_startim">Unable to start IM session with [RECIPIENT] due to RLV restrictions</string>
<string name="blocked_startconf">Unable to start conference with [RECIPIENT] due to RLV restrictions</string>
<string name="blocked_startconf">Unable to start conference due to RLV restrictions</string>
<string name="blocked_teleport">Unable to initiate teleport due to RLV restrictions</string>
<string name="blocked_viewxxx">Unable to open [TYPE] due to RLV restrictions</string>