[Libreoffice-commits] online.git: loolwsd/LOOLSession.cpp loolwsd/LOOLSession.hpp
Henry Castro
hcastro at collabora.com
Wed Aug 26 21:21:29 PDT 2015
loolwsd/LOOLSession.cpp | 26 +++++++++++++++++++++-----
loolwsd/LOOLSession.hpp | 1 +
2 files changed, 22 insertions(+), 5 deletions(-)
New commits:
commit b32b407714d1d51c6530c6f140b11f9758979f54
Author: Henry Castro <hcastro at collabora.com>
Date: Thu Aug 27 00:18:44 2015 -0400
loolwsd: add an optional parameter to load url= ...
load part=X url="http" is required to re-establish the connection
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index e489962..e2ca290 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -134,7 +134,8 @@ std::mutex MasterProcessSession::_rngMutex;
MasterProcessSession::MasterProcessSession(std::shared_ptr<WebSocket> ws, Kind kind) :
LOOLSession(ws, kind),
_childId(0),
- _curPart(0)
+ _curPart(0),
+ _loadPart(-1)
{
std::cout << Util::logPrefix() << "MasterProcessSession ctor this=" << this << " ws=" << _ws.get() << std::endl;
}
@@ -369,12 +370,15 @@ bool MasterProcessSession::invalidateTiles(const char *buffer, int length, Strin
bool MasterProcessSession::loadDocument(const char *buffer, int length, StringTokenizer& tokens)
{
- if (tokens.count() < 2 || tokens.count() > 3)
+ if (tokens.count() < 2 || tokens.count() > 4)
{
sendTextFrame("error: cmd=load kind=syntax");
return false;
}
+ if (tokens.count() > 2 )
+ getTokenInteger(tokens[1], "part", _loadPart);
+
std::string timestamp;
for (size_t i = 1; i < tokens.count(); ++i)
{
@@ -571,7 +575,7 @@ void MasterProcessSession::dispatchChild()
_peer = childSession;
childSession->_peer = shared_from_this();
- std::string loadRequest = "load url=" + _docURL;
+ std::string loadRequest = "load" + (_loadPart >= 0 ? " part=" + std::to_string(_loadPart) : "") + " url=" + _docURL;
forwardToPeer(loadRequest.c_str(), loadRequest.size());
}
@@ -784,13 +788,19 @@ extern "C"
bool ChildProcessSession::loadDocument(const char *buffer, int length, StringTokenizer& tokens)
{
- if (tokens.count() != 2)
+ int part = -1;
+ if (tokens.count() < 2 || tokens.count() > 4)
{
sendTextFrame("error: cmd=load kind=syntax");
return false;
}
- if (tokens[1].find("url=") == 0)
+ if (tokens.count() > 2 && tokens[2].find("url=") == 0)
+ {
+ getTokenInteger(tokens[1], "part", part);
+ _docURL = tokens[2].substr(strlen("url="));
+ }
+ else if (tokens[1].find("url=") == 0)
_docURL = tokens[1].substr(strlen("url="));
else
_docURL = tokens[1];
@@ -830,6 +840,12 @@ bool ChildProcessSession::loadDocument(const char *buffer, int length, StringTok
_loKitDocument->pClass->initializeForRendering(_loKitDocument);
+ if ( _docType != "text" && part != -1)
+ {
+ _clientPart = part;
+ _loKitDocument->pClass->setPart(_loKitDocument, part);
+ }
+
if (!getStatus(buffer, length))
return false;
diff --git a/loolwsd/LOOLSession.hpp b/loolwsd/LOOLSession.hpp
index a63e40e..fdd4008 100644
--- a/loolwsd/LOOLSession.hpp
+++ b/loolwsd/LOOLSession.hpp
@@ -146,6 +146,7 @@ private:
static Poco::Random _rng;
static std::mutex _rngMutex;
int _curPart;
+ int _loadPart;
};
class ChildProcessSession final : public LOOLSession
More information about the Libreoffice-commits
mailing list