wsd: readonly message filtering in separate function
Change-Id: I1c02be876aa4cf2a878082b593de3c83e45e15b3
This commit is contained in:
parent
49c505f327
commit
8357a2bcee
2 changed files with 21 additions and 3 deletions
|
@ -213,9 +213,7 @@ bool ClientSession::_handleInput(const char *buffer, int length)
|
|||
}
|
||||
else
|
||||
{
|
||||
// Allow 'downloadas' for all kinds of views
|
||||
if ( (isReadOnly()) && tokens[0] != "downloadas" &&
|
||||
tokens[0] != "userinactive" && tokens[0] != "useractive")
|
||||
if (!filterMessage(firstLine))
|
||||
{
|
||||
const std::string dummyFrame = "dummymsg";
|
||||
return forwardToChild(dummyFrame, docBroker);
|
||||
|
@ -390,6 +388,22 @@ bool ClientSession::forwardToChild(const std::string& message,
|
|||
return docBroker->forwardToChild(getId(), message);
|
||||
}
|
||||
|
||||
bool ClientSession::filterMessage(const std::string& message) const
|
||||
{
|
||||
bool allowed = true;
|
||||
StringTokenizer tokens(message, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
|
||||
if (isReadOnly())
|
||||
{
|
||||
allowed = false;
|
||||
if (tokens[0] == "downloadas" || tokens[0] == "userinactive" || tokens[0] == "useractive")
|
||||
{
|
||||
allowed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return allowed;
|
||||
}
|
||||
|
||||
void ClientSession::setReadOnly()
|
||||
{
|
||||
_isReadOnly = true;
|
||||
|
|
|
@ -87,6 +87,10 @@ private:
|
|||
bool forwardToChild(const std::string& message,
|
||||
const std::shared_ptr<DocumentBroker>& docBroker);
|
||||
|
||||
/// Returns true if given message from the client should be allowed or not
|
||||
/// Eg. in readonly mode only few messages should be allowed
|
||||
bool filterMessage(const std::string& msg) const;
|
||||
|
||||
private:
|
||||
std::weak_ptr<DocumentBroker> _docBroker;
|
||||
|
||||
|
|
Loading…
Reference in a new issue