Finalized @getcommand[:<behaviour>[;<type>[;<separator>]]]=<channel>

-> <behaviour>: (optional) command filter (e.g. tp)
     <type> : (optional) any|add|force|reply
     <separator> : (optional) user-defined separator
  -> Examples:
     @getcommand:tp;add=0 will show all restrictions that @clear=tp would clear
     @getcommand:;reply;^-^=0 will show all reply commands separated by ^-^

--HG--
branch : RLVa
master
Kitty Barnett 2016-04-20 01:37:53 +02:00
parent 43e1bb1213
commit 0ccf637e6f
5 changed files with 54 additions and 39 deletions

View File

@ -156,17 +156,6 @@
<key>Value</key>
<boolean>1</boolean>
</map>
<key>RLVaExtendedCommands</key>
<map>
<key>Comment</key>
<string>Enables the extended command set</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<boolean>1</boolean>
</map>
<key>RLVaHideLockedLayers</key>
<map>
<key>Comment</key>

View File

@ -66,6 +66,7 @@ const S32 RLVa_VERSION_BUILD = 0;
#define RLV_ROOT_FOLDER "#RLV"
#define RLV_CMD_PREFIX '@'
#define RLV_OPTION_SEPARATOR ";" // Default separator used in command options
#define RLV_PUTINV_PREFIX "#RLV/~"
#define RLV_PUTINV_SEPARATOR "/"
#define RLV_PUTINV_MAXDEPTH 4

View File

@ -705,7 +705,8 @@ BOOL RlvFloaterConsole::postBuild()
void RlvFloaterConsole::addCommandReply(const std::string& strCommand, const std::string& strReply)
{
m_pOutputText->appendText(llformat("%s: %s", strCommand.c_str(), strReply.c_str()), true);
m_pOutputText->appendText(llformat("%s: ", strCommand.c_str()), true);
m_pOutputText->appendText(strReply, false);
}
void RlvFloaterConsole::onInput(LLUICtrl* pCtrl, const LLSD& sdParam)

View File

@ -53,6 +53,7 @@ struct RlvCommandOptionHelper
{
template <typename optionType>
static bool parseOption(const std::string& strOption, optionType& valueOption);
static bool parseStringList(const std::string& strOption, std::vector<std::string>& optionList);
};
template<>
@ -68,6 +69,13 @@ bool RlvCommandOptionHelper::parseOption<int>(const std::string& strOption, int&
return LLStringUtil::convertToS32(strOption, nOption);
}
bool RlvCommandOptionHelper::parseStringList(const std::string& strOption, std::vector<std::string>& optionList)
{
if (!strOption.empty())
boost::split(optionList, strOption, boost::is_any_of(std::string(RLV_OPTION_SEPARATOR)));
return !optionList.empty();
}
// ============================================================================
// Command specific helper functions
//
@ -1934,14 +1942,6 @@ ERlvCmdRet RlvHandler::processReplyCommand(const RlvCommand& rlvCmd) const
strReply = idSitObj.asString();
}
break;
case RLV_BHVR_GETCOMMAND: // @getcommand:<option>=<channel> - Checked: 2010-12-11 (RLVa-1.2.2c) | Added: RLVa-1.2.2c
{
std::list<std::string> cmdList;
if (RlvBehaviourDictionary::instance().getCommands(rlvCmd.getOption(), RLV_TYPE_UNKNOWN, cmdList))
for (std::list<std::string>::const_iterator itCmd = cmdList.begin(); itCmd != cmdList.end(); ++itCmd)
strReply.append("/").append(*itCmd);
}
break;
case RLV_BHVR_GETSTATUS: // @getstatus - Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.1.0f
{
std::string strFilter, strSeparator;
@ -2106,6 +2106,35 @@ ERlvCmdRet RlvHandler::onGetAttachNames(const RlvCommand& rlvCmd, std::string& s
return RLV_RET_SUCCESS;
}
// Handles: @getcommand[:<behaviour>[;<type>[;<separator>]]]=<channel>
template<> template<>
ERlvCmdRet RlvReplyHandler<RLV_BHVR_GETCOMMAND>::onCommand(const RlvCommand& rlvCmd, std::string& strReply)
{
std::vector<std::string> optionList;
RlvCommandOptionHelper::parseStringList(rlvCmd.getOption(), optionList);
// If a second parameter is present it'll specify the command type
ERlvParamType eType = RLV_TYPE_UNKNOWN;
if (optionList.size() >= 2)
{
if ( (optionList[1] == "any") || (optionList[1].empty()) )
eType = RLV_TYPE_UNKNOWN;
else if (optionList[1] == "add")
eType = RLV_TYPE_ADDREM;
else if (optionList[1] == "force")
eType = RLV_TYPE_FORCE;
else if (optionList[1] == "reply")
eType = RLV_TYPE_REPLY;
else
return RLV_RET_FAILED_OPTION;
}
std::list<std::string> cmdList;
if (RlvBehaviourDictionary::instance().getCommands((optionList.size() >= 1) ? optionList[0] : LLStringUtil::null, eType, cmdList))
strReply = boost::algorithm::join(cmdList, (optionList.size() >= 3) ? optionList[2] : std::string(RLV_OPTION_SEPARATOR) );
return RLV_RET_SUCCESS;
}
// Checked: 2010-03-09 (RLVa-1.2.0a) | Modified: RLVa-1.1.0f
ERlvCmdRet RlvHandler::onGetInv(const RlvCommand& rlvCmd, std::string& strReply) const
{

View File

@ -204,7 +204,7 @@ RlvBehaviourDictionary::RlvBehaviourDictionary()
RLV_ASSERT( (itBhvr.first != pBhvrInfo->getBehaviourType()) || (itBhvr.second->getBehaviourFlags() != pBhvrInfo->getBehaviourFlags()) );
}
#endif // RLV_DEBUG
m_Bhvr2InfoMap.insert(std::pair<ERlvBehaviour, const RlvBehaviourInfo*>(pBhvrInfo->getBehaviourType(), pBhvrInfo));
m_Bhvr2InfoMap.insert(std::pair<ERlvBehaviour, const RlvBehaviourInfo*>(pBhvrInfo->getBehaviourType(), pBhvrInfo));
}
}
@ -222,6 +222,13 @@ RlvBehaviourDictionary::~RlvBehaviourDictionary()
void RlvBehaviourDictionary::addEntry(const RlvBehaviourInfo* pEntry)
{
// Filter experimental commands (if disabled)
static LLCachedControl<bool> sEnableExperimental(gSavedSettings, "RLVaExperimentalCommands");
if ( (!pEntry) || ((!sEnableExperimental) && (pEntry->isExperimental())) )
{
return;
}
// Sanity check for duplicate entries
#ifndef LL_RELEASE_FOR_DOWNLOAD
std::for_each(m_BhvrInfoList.begin(), m_BhvrInfoList.end(),
@ -252,17 +259,14 @@ ERlvBehaviour RlvBehaviourDictionary::getBehaviourFromString(const std::string&
bool RlvBehaviourDictionary::getCommands(const std::string& strMatch, ERlvParamType eParamType, std::list<std::string>& cmdList) const
{
cmdList.clear();
if (strMatch.empty())
return false;
for (const RlvBehaviourInfo* pBhvrInfo : m_BhvrInfoList)
{
if ( (pBhvrInfo->getParamTypeMask() & eParamType) || (RLV_TYPE_UNKNOWN == eParamType) )
{
std::string strCmd = pBhvrInfo->getBehaviour();
if (std::string::npos != strCmd.find(strMatch))
if ( (std::string::npos != strCmd.find(strMatch)) || (strMatch.empty()) )
cmdList.push_back(strCmd);
if ( (pBhvrInfo->hasStrict()) && (std::string::npos != strCmd.append("_sec").find(strMatch)) )
if ( (pBhvrInfo->hasStrict()) && ((std::string::npos != strCmd.append("_sec").find(strMatch)) || (strMatch.empty())) )
cmdList.push_back(strCmd);
}
}
@ -325,16 +329,7 @@ RlvCommand::RlvCommand(const LLUUID& idObj, const std::string& strCommand)
return;
}
if (m_pBhvrInfo = RlvBehaviourDictionary::instance().getBehaviourInfo(strBehaviour, m_eParamType, &m_fStrict))
{
// Filter experimental and/or extended commands (if disabled)
static LLCachedControl<bool> sEnableExperimental(gSavedSettings, "RLVaExperimentalCommands");
static LLCachedControl<bool> sEnableExtended(gSavedSettings, "RLVaExtendedCommands");
if ( ((!sEnableExperimental) && (m_pBhvrInfo->isExperimental())) || ((!sEnableExtended) && (m_pBhvrInfo->isExtended())) )
{
m_pBhvrInfo = NULL;
}
}
m_pBhvrInfo = RlvBehaviourDictionary::instance().getBehaviourInfo(strBehaviour, m_eParamType, &m_fStrict);
}
bool RlvCommand::parseCommand(const std::string& strCommand, std::string& strBehaviour, std::string& strOption, std::string& strParam)
@ -809,13 +804,13 @@ bool RlvForceWear::isForceDetachable(const LLViewerObject* pAttachObj, bool fChe
#endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS
return
(
(pAttachObj) && (pAttachObj->isAttachment())
(pAttachObj) && (pAttachObj->isAttachment())
&& ( (idExcept.isNull()) ? (!gRlvAttachmentLocks.isLockedAttachment(pAttachObj))
: (!gRlvAttachmentLocks.isLockedAttachmentExcept(pAttachObj, idExcept)) )
: (!gRlvAttachmentLocks.isLockedAttachmentExcept(pAttachObj, idExcept)) )
&& (isStrippable(pAttachObj->getAttachmentItemID()))
#ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS
&& ( (!fCheckComposite) || (!RlvSettings::getEnableComposites()) ||
(!gRlvHandler.getCompositeInfo(pAttachPt->getItemID(), NULL, &pFolder)) || (gRlvHandler.canTakeOffComposite(pFolder)) )
(!gRlvHandler.getCompositeInfo(pAttachPt->getItemID(), NULL, &pFolder)) || (gRlvHandler.canTakeOffComposite(pFolder)) )
#endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS
);
}