Code cleanup: don't store unknown or invalid restrictions/behaviours
--HG-- branch : RLVamaster
parent
e4f327e747
commit
aaedd151ce
|
|
@ -282,6 +282,8 @@ const char* RlvStrings::getStringFromReturnCode(ERlvCmdRet eRet)
|
|||
return "duplicate";
|
||||
case RLV_RET_SUCCESS_DELAYED:
|
||||
return "delayed";
|
||||
case RLV_RET_SUCCESS_DEPRECATED:
|
||||
return "deprecated";
|
||||
case RLV_RET_FAILED_SYNTAX:
|
||||
return "thingy error";
|
||||
case RLV_RET_FAILED_OPTION:
|
||||
|
|
@ -296,8 +298,8 @@ const char* RlvStrings::getStringFromReturnCode(ERlvCmdRet eRet)
|
|||
return "unknown command";
|
||||
case RLV_RET_FAILED_NOSHAREDROOT:
|
||||
return "missing #RLV";
|
||||
case RLV_RET_DEPRECATED:
|
||||
return "deprecated";
|
||||
case RLV_RET_FAILED_DEPRECATED:
|
||||
return "deprecated and disabled";
|
||||
// The following are identified by the chat verb
|
||||
case RLV_RET_RETAINED:
|
||||
case RLV_RET_SUCCESS:
|
||||
|
|
|
|||
|
|
@ -278,6 +278,7 @@ enum ERlvCmdRet {
|
|||
RLV_RET_SUCCESS = 0x0100, // Command executed succesfully
|
||||
RLV_RET_SUCCESS_UNSET, // Command executed succesfully (RLV_TYPE_REMOVE for an unrestricted behaviour)
|
||||
RLV_RET_SUCCESS_DUPLICATE, // Command executed succesfully (RLV_TYPE_ADD for an already restricted behaviour)
|
||||
RLV_RET_SUCCESS_DEPRECATED, // Command executed succesfully but has been marked as deprecated
|
||||
RLV_RET_SUCCESS_DELAYED, // Command parsed valid but will execute at a later time
|
||||
RLV_RET_FAILED = 0x0200, // Command failed (general failure)
|
||||
RLV_RET_FAILED_SYNTAX, // Command failed (syntax error)
|
||||
|
|
@ -287,9 +288,10 @@ enum ERlvCmdRet {
|
|||
RLV_RET_FAILED_DISABLED, // Command failed (command disabled by user)
|
||||
RLV_RET_FAILED_UNKNOWN, // Command failed (unknown command)
|
||||
RLV_RET_FAILED_NOSHAREDROOT, // Command failed (missing #RLV)
|
||||
RLV_RET_DEPRECATED, // Command has been deprecated
|
||||
RLV_RET_FAILED_DEPRECATED, // Command failed (deprecated and no longer supported)
|
||||
RLV_RET_NO_PROCESSOR // Command doesn't have a template processor define (legacy code)
|
||||
};
|
||||
#define RLV_RET_SUCCEEDED(eCmdRet) (((eCmdRet) & RLV_RET_SUCCESS) == RLV_RET_SUCCESS)
|
||||
|
||||
enum ERlvExceptionCheck
|
||||
{
|
||||
|
|
|
|||
|
|
@ -259,8 +259,6 @@ void RlvFloaterBehaviours::onBtnCopyToClipboard()
|
|||
strRestrictions << " -> " << itCmd->asString();
|
||||
if ( (!strOption.empty()) && (strOption != itCmd->getOption()) )
|
||||
strRestrictions << " [" << strOption << "]";
|
||||
if (RLV_RET_SUCCESS != itCmd->getReturnType())
|
||||
strRestrictions << " (" << RlvStrings::getStringFromReturnCode(itCmd->getReturnType()) << ")";
|
||||
strRestrictions << "\n";
|
||||
}
|
||||
}
|
||||
|
|
@ -360,7 +358,6 @@ void RlvFloaterBehaviours::refreshAll()
|
|||
else
|
||||
{
|
||||
// List under the "Restrictions" tab
|
||||
sdBhvrRow["enabled"] = (RLV_RET_SUCCESS == itCmd->getReturnType());
|
||||
sdBhvrColumns[0]["value"] = (strOption.empty()) ? itCmd->asString() : itCmd->getBehaviour() + ":" + strOption;
|
||||
sdBhvrColumns[1]["value"] = strIssuer;
|
||||
pBhvrList->addElement(sdBhvrRow, ADD_BOTTOM);
|
||||
|
|
@ -761,6 +758,7 @@ void RlvFloaterConsole::onInput(LLUICtrl* pCtrl, const LLSD& sdParam)
|
|||
{
|
||||
LLLineEditor* pInputEdit = static_cast<LLLineEditor*>(pCtrl);
|
||||
std::string strInput = pInputEdit->getText();
|
||||
LLStringUtil::trim(strInput);
|
||||
|
||||
m_pOutputText->appendText(strInput, false);
|
||||
pInputEdit->clear();
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ ERlvCmdRet RlvHandler::processCommand(const RlvCommand& rlvCmd, bool fFromObj)
|
|||
{
|
||||
RlvObject rlvObj(idCurObj);
|
||||
fAdded = rlvObj.addCommand(rlvCmd);
|
||||
m_Objects.insert(std::pair<LLUUID, RlvObject>(idCurObj, rlvObj));
|
||||
itObj = m_Objects.insert(std::pair<LLUUID, RlvObject>(idCurObj, rlvObj)).first;
|
||||
}
|
||||
|
||||
RLV_DEBUGS << "\t- " << ( (fAdded) ? "adding behaviour" : "skipping duplicate" ) << RLV_ENDL;
|
||||
|
|
@ -348,7 +348,11 @@ ERlvCmdRet RlvHandler::processCommand(const RlvCommand& rlvCmd, bool fFromObj)
|
|||
if (!m_pGCTimer)
|
||||
m_pGCTimer = new RlvGCTimer();
|
||||
eRet = processAddRemCommand(rlvCmd);
|
||||
m_Objects.find(idCurObj)->second.setCommandRet(rlvCmd, eRet); // HACK-RLVa: find a better way of doing this
|
||||
if (!RLV_RET_SUCCEEDED(eRet))
|
||||
{
|
||||
RlvCommand rlvCmdRem(rlvCmd, RLV_TYPE_REMOVE);
|
||||
itObj->second.removeCommand(rlvCmdRem);
|
||||
}
|
||||
// notifyBehaviourObservers(rlvCmd, !fFromObj);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ bool RlvBehaviourModifier::convertOptionValue(const std::string& optionValue, Rl
|
|||
//
|
||||
|
||||
RlvCommand::RlvCommand(const LLUUID& idObj, const std::string& strCommand)
|
||||
: m_fValid(false), m_idObj(idObj), m_pBhvrInfo(NULL), m_eParamType(RLV_TYPE_UNKNOWN), m_fStrict(false), m_eRet(RLV_RET_UNKNOWN)
|
||||
: m_fValid(false), m_idObj(idObj), m_pBhvrInfo(NULL), m_eParamType(RLV_TYPE_UNKNOWN), m_fStrict(false), m_fRefCounted(false)
|
||||
{
|
||||
if (m_fValid = parseCommand(strCommand, m_strBehaviour, m_strOption, m_strParam))
|
||||
{
|
||||
|
|
@ -558,6 +558,12 @@ RlvCommand::RlvCommand(const LLUUID& idObj, const std::string& strCommand)
|
|||
m_pBhvrInfo = RlvBehaviourDictionary::instance().getBehaviourInfo(m_strBehaviour, m_eParamType, &m_fStrict);
|
||||
}
|
||||
|
||||
RlvCommand::RlvCommand(const RlvCommand& rlvCmd, ERlvParamType eParamType)
|
||||
: m_fValid(rlvCmd.m_fValid), m_idObj(rlvCmd.m_idObj), m_strBehaviour(rlvCmd.m_strBehaviour), m_pBhvrInfo(rlvCmd.m_pBhvrInfo),
|
||||
m_eParamType( (RLV_TYPE_UNKNOWN == eParamType) ? rlvCmd.m_eParamType : eParamType),m_fStrict(rlvCmd.m_fStrict), m_strOption(rlvCmd.m_strOption), m_strParam(rlvCmd.m_strParam), m_fRefCounted(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool RlvCommand::parseCommand(const std::string& strCommand, std::string& strBehaviour, std::string& strOption, std::string& strParam)
|
||||
{
|
||||
// (See behaviour notes for the command parsing truth table)
|
||||
|
|
@ -918,19 +924,6 @@ bool RlvObject::removeCommand(const RlvCommand& rlvCmd)
|
|||
return false; // Command was never added so nothing to remove now
|
||||
}
|
||||
|
||||
// Checked: 2011-05-23 (RLVa-1.3.1c) | Added: RLVa-1.3.1c
|
||||
void RlvObject::setCommandRet(const RlvCommand& rlvCmd, ERlvCmdRet eRet)
|
||||
{
|
||||
for (rlv_command_list_t::iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd)
|
||||
{
|
||||
if (*itCmd == rlvCmd)
|
||||
{
|
||||
itCmd->m_eRet = eRet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool RlvObject::hasBehaviour(ERlvBehaviour eBehaviour, bool fStrictOnly) const
|
||||
{
|
||||
for (rlv_command_list_t::const_iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd)
|
||||
|
|
|
|||
|
|
@ -366,6 +366,7 @@ class RlvCommand
|
|||
{
|
||||
public:
|
||||
explicit RlvCommand(const LLUUID& idObj, const std::string& strCommand);
|
||||
RlvCommand(const RlvCommand& rlvCmd, ERlvParamType eParamType = RLV_TYPE_UNKNOWN);
|
||||
|
||||
/*
|
||||
* Member functions
|
||||
|
|
@ -379,7 +380,6 @@ public:
|
|||
const std::string& getOption() const { return m_strOption; }
|
||||
const std::string& getParam() const { return m_strParam; }
|
||||
ERlvParamType getParamType() const { return m_eParamType; }
|
||||
ERlvCmdRet getReturnType() const { return m_eRet; }
|
||||
bool hasOption() const { return !m_strOption.empty(); }
|
||||
bool isBlocked() const { return (m_pBhvrInfo) ? m_pBhvrInfo->isBlocked() : false; }
|
||||
bool isRefCounted() const { return m_fRefCounted; }
|
||||
|
|
@ -409,7 +409,6 @@ protected:
|
|||
bool m_fStrict;
|
||||
std::string m_strOption;
|
||||
std::string m_strParam;
|
||||
ERlvCmdRet m_eRet;
|
||||
mutable bool m_fRefCounted;
|
||||
|
||||
friend class RlvHandler;
|
||||
|
|
@ -522,7 +521,6 @@ public:
|
|||
public:
|
||||
bool addCommand(const RlvCommand& rlvCmd);
|
||||
bool removeCommand(const RlvCommand& rlvCmd);
|
||||
void setCommandRet(const RlvCommand& rlvCmd, ERlvCmdRet eRet);
|
||||
|
||||
std::string getStatusString(const std::string& strFilter, const std::string& strSeparator) const;
|
||||
bool hasBehaviour(ERlvBehaviour eBehaviour, bool fStrictOnly) const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue