summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/rlvcommon.cpp9
-rw-r--r--indra/newview/rlvcommon.h3
-rw-r--r--indra/newview/rlvdefines.h2
-rw-r--r--indra/newview/rlvhandler.cpp31
-rw-r--r--indra/newview/rlvhelper.cpp1
5 files changed, 46 insertions, 0 deletions
diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp
index 898df3af42..eda2cdedc8 100644
--- a/indra/newview/rlvcommon.cpp
+++ b/indra/newview/rlvcommon.cpp
@@ -9,6 +9,8 @@
#include "rlvdefines.h"
#include "rlvcommon.h"
+#include <boost/algorithm/string.hpp>
+
using namespace Rlv;
// ============================================================================
@@ -46,6 +48,13 @@ std::string Strings::getVersionImplNum()
// RlvUtil
//
+bool Util::parseStringList(const std::string& strInput, std::vector<std::string>& optionList, std::string_view strSeparator)
+{
+ if (!strInput.empty())
+ boost::split(optionList, strInput, boost::is_any_of(strSeparator));
+ return !optionList.empty();
+}
+
bool Util::sendChatReply(S32 nChannel, const std::string& strUTF8Text)
{
if (!isValidReplyChannel(nChannel))
diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h
index 79ac6e1704..bec3e23e11 100644
--- a/indra/newview/rlvcommon.h
+++ b/indra/newview/rlvcommon.h
@@ -1,5 +1,7 @@
#pragma once
+#include "rlvdefines.h"
+
namespace Rlv
{
// ============================================================================
@@ -22,6 +24,7 @@ namespace Rlv
namespace Util
{
bool isValidReplyChannel(S32 nChannel, bool isLoopback = false);
+ bool parseStringList(const std::string& strInput, std::vector<std::string>& optionList, std::string_view strSeparator = Constants::OptionSeparator);
bool sendChatReply(S32 nChannel, const std::string& strUTF8Text);
bool sendChatReply(const std::string& strChannel, const std::string& strUTF8Text);
};
diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h
index 0459b59483..c36512007b 100644
--- a/indra/newview/rlvdefines.h
+++ b/indra/newview/rlvdefines.h
@@ -52,6 +52,7 @@ namespace Rlv
namespace Constants
{
constexpr char CmdPrefix = '@';
+ constexpr std::string_view OptionSeparator = ";";
}
}
@@ -65,6 +66,7 @@ namespace Rlv
Version = 0,
VersionNew,
VersionNum,
+ GetCommand,
Count,
Unknown,
diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp
index 3d7f73937f..8b2620cf48 100644
--- a/indra/newview/rlvhandler.cpp
+++ b/indra/newview/rlvhandler.cpp
@@ -9,6 +9,8 @@
#include "rlvhandler.h"
#include "rlvhelper.h"
+#include <boost/algorithm/string.hpp>
+
using namespace Rlv;
// ============================================================================
@@ -143,6 +145,35 @@ ECmdRet CommandHandlerBaseImpl<EParamType::Reply>::processCommand(const RlvComma
return eRet;
}
+// Handles: @getcommand[:<behaviour>[;<type>[;<separator>]]]=<channel>
+template<> template<>
+ECmdRet ReplyHandler<EBehaviour::GetCommand>::onCommand(const RlvCommand& rlvCmd, std::string& strReply)
+{
+ std::vector<std::string> optionList;
+ Util::parseStringList(rlvCmd.getOption(), optionList);
+
+ // If a second parameter is present it'll specify the command type
+ EParamType eType = EParamType::Unknown;
+ if (optionList.size() >= 2)
+ {
+ if (optionList[1] == "any" || optionList[1].empty())
+ eType = EParamType::Unknown;
+ else if (optionList[1] == "add")
+ eType = EParamType::AddRem;
+ else if (optionList[1] == "force")
+ eType = EParamType::Force;
+ else if (optionList[1] == "reply")
+ eType = EParamType::Reply;
+ else
+ return ECmdRet::FailedOption;
+ }
+
+ std::list<std::string> cmdList;
+ if (BehaviourDictionary::instance().getCommands(!optionList.empty() ? optionList[0] : LLStringUtil::null, eType, cmdList))
+ strReply = boost::algorithm::join(cmdList, optionList.size() >= 3 ? optionList[2] : Constants::OptionSeparator);
+ return ECmdRet::Success;
+}
+
// Handles: @version=<chnannel> and @versionnew=<channel>
template<> template<>
ECmdRet VersionReplyHandler::onCommand(const RlvCommand& rlvCmd, std::string& strReply)
diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp
index c3f9e6f756..aad615d813 100644
--- a/indra/newview/rlvhelper.cpp
+++ b/indra/newview/rlvhelper.cpp
@@ -22,6 +22,7 @@ BehaviourDictionary::BehaviourDictionary()
//
// Reply-only
//
+ addEntry(new ReplyProcessor<EBehaviour::GetCommand>("getcommand"));
addEntry(new ReplyProcessor<EBehaviour::Version, VersionReplyHandler>("version"));
addEntry(new ReplyProcessor<EBehaviour::VersionNew, VersionReplyHandler>("versionnew"));
addEntry(new ReplyProcessor<EBehaviour::VersionNum>("versionnum"));