loolwsd: rework setclientpart

This commit is contained in:
Henry Castro 2016-04-27 13:47:58 -04:00
parent 78308db763
commit 200c6a9281
3 changed files with 15 additions and 21 deletions

View file

@ -284,7 +284,6 @@ ChildProcessSession::ChildProcessSession(const std::string& id,
_multiView(std::getenv("LOK_VIEW_CALLBACK")), _multiView(std::getenv("LOK_VIEW_CALLBACK")),
_jailId(jailId), _jailId(jailId),
_viewId(0), _viewId(0),
_clientPart(0),
_onLoad(onLoad), _onLoad(onLoad),
_onUnload(onUnload), _onUnload(onUnload),
_callbackWorker(new CallbackWorker(_callbackQueue, *this)) _callbackWorker(new CallbackWorker(_callbackQueue, *this))
@ -459,18 +458,6 @@ bool ChildProcessSession::_handleInput(const char *buffer, int length)
tokens[0] == "userinactive" || tokens[0] == "userinactive" ||
tokens[0] == "editlock:"); tokens[0] == "editlock:");
{
std::unique_lock<std::recursive_mutex> lock(Mutex);
if (_multiView)
_loKitDocument->pClass->setView(_loKitDocument, _viewId);
if (_docType != "text" && _loKitDocument->pClass->getPart(_loKitDocument) != _clientPart)
{
_loKitDocument->pClass->setPart(_loKitDocument, _clientPart);
}
}
if (tokens[0] == "clientzoom") if (tokens[0] == "clientzoom")
{ {
return clientZoom(buffer, length, tokens); return clientZoom(buffer, length, tokens);
@ -593,7 +580,6 @@ bool ChildProcessSession::loadDocument(const char * /*buffer*/, int /*length*/,
if (_docType != "text" && part != -1) if (_docType != "text" && part != -1)
{ {
_clientPart = part;
_loKitDocument->pClass->setPart(_loKitDocument, part); _loKitDocument->pClass->setPart(_loKitDocument, part);
} }
@ -1345,11 +1331,25 @@ bool ChildProcessSession::saveAs(const char* /*buffer*/, int /*length*/, StringT
bool ChildProcessSession::setClientPart(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens) bool ChildProcessSession::setClientPart(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{ {
int part;
if (tokens.count() < 2 || if (tokens.count() < 2 ||
!getTokenInteger(tokens[1], "part", _clientPart)) !getTokenInteger(tokens[1], "part", part))
{ {
sendTextFrame("error: cmd=setclientpart kind=invalid");
return false; return false;
} }
std::unique_lock<std::recursive_mutex> lock(Mutex);
if (part == _loKitDocument->pClass->getPart(_loKitDocument))
return true;
if (_multiView)
_loKitDocument->pClass->setView(_loKitDocument, _viewId);
_loKitDocument->pClass->setPart(_loKitDocument, part);
// invalidate all
loKitCallback(LOK_CALLBACK_INVALIDATE_TILES, std::string("EMPTY").c_str());
return true; return true;
} }

View file

@ -99,7 +99,6 @@ private:
const std::string _jailId; const std::string _jailId;
/// View ID, returned by createView() or 0 by default. /// View ID, returned by createView() or 0 by default.
int _viewId; int _viewId;
int _clientPart;
std::map<int, std::string> _lastDocStates; std::map<int, std::string> _lastDocStates;
std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, bool)> _onLoad; std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, bool)> _onLoad;
std::function<void(const std::string&)> _onUnload; std::function<void(const std::string&)> _onUnload;

View file

@ -351,11 +351,6 @@ bool MasterProcessSession::_handleInput(const char *buffer, int length)
dispatchChild(); dispatchChild();
} }
if (tokens[0] == "setclientpart")
{
_docBroker->tileCache().removeFile("status.txt");
}
// Allow 'downloadas' for all kinds of views irrespective of editlock // Allow 'downloadas' for all kinds of views irrespective of editlock
if (_kind == Kind::ToClient && !isEditLocked() && tokens[0] != "downloadas" && if (_kind == Kind::ToClient && !isEditLocked() && tokens[0] != "downloadas" &&
tokens[0] != "userinactive" && tokens[0] != "useractive") tokens[0] != "userinactive" && tokens[0] != "useractive")