loolwsd/LOOLSession.cpp | 21 +++++++++++++++++++++ loolwsd/LOOLSession.hpp | 9 +++++++++ loolwsd/protocol.txt | 5 +++++ 3 files changed, 35 insertions(+)
New commits: commit 4feb29d1dfaf05a3c1f15dd05bab443a08211f0f Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Oct 20 14:03:31 2015 +0200 LOOLSession: inform to-client session about completed save-as diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp index 1f1a2da..4bee505 100644 --- a/loolwsd/LOOLSession.cpp +++ b/loolwsd/LOOLSession.cpp @@ -184,6 +184,20 @@ bool MasterProcessSession::handleInput(const char *buffer, int length) { return true; } + + if (tokens.count() == 2 && tokens[0] == "saveas:") + { + std::string url; + if (!getTokenString(tokens[1], "url", url)) + return true; + + if (peer) + // Save as completed, inform the other (Kind::ToClient) + // MasterProcessSession about it. + peer->_saveAsQueue.put(url); + + return true; + } } if (_kind == Kind::ToPrisoner && peer && peer->_tileCache) @@ -486,6 +500,11 @@ bool MasterProcessSession::getPartPageRectangles(const char *buffer, int length) return true; } +std::string MasterProcessSession::getSaveAs() +{ + return _saveAsQueue.get(); +} + void MasterProcessSession::sendTile(const char *buffer, int length, StringTokenizer& tokens) { int part, width, height, tilePosX, tilePosY, tileWidth, tileHeight; @@ -1204,6 +1223,8 @@ bool ChildProcessSession::saveAs(const char* /*buffer*/, int /*length*/, StringT format.size() == 0 ? NULL :format.c_str(), filterOptions.size() == 0 ? NULL : filterOptions.c_str()); + sendTextFrame("saveas: url=" + url); + return true; } diff --git a/loolwsd/LOOLSession.hpp b/loolwsd/LOOLSession.hpp index 70210ae..85d9d5a 100644 --- a/loolwsd/LOOLSession.hpp +++ b/loolwsd/LOOLSession.hpp @@ -30,6 +30,7 @@ #include <Poco/Types.h> #include "TileCache.hpp" +#include "tsqueue.h" // We have three kinds of Websocket sessions // 1) Between the master loolwsd server to the end-user LOOL client @@ -117,6 +118,12 @@ public: virtual bool getPartPageRectangles(const char *buffer, int length) override; + /** + * Return the URL of the saved-as document when it's ready. If called + * before it's ready, the call blocks till then. + */ + std::string getSaveAs(); + protected: bool invalidateTiles(const char *buffer, int length, Poco::StringTokenizer& tokens); @@ -151,6 +158,8 @@ private: static std::mutex _rngMutex; int _curPart; int _loadPart; + /// Kind::ToClient instances store URLs of completed 'save as' documents. + tsqueue<std::string> _saveAsQueue; }; class ChildProcessSession final : public LOOLSession diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt index bc7c453..ede153d 100644 --- a/loolwsd/protocol.txt +++ b/loolwsd/protocol.txt @@ -181,3 +181,8 @@ nextmessage: size=<upperlimit> messages that can be "large".) Once we depend on Poco 1.6.1, where one doesn't need to use a pre-allocated buffer when receiving WebSocket messages, this will go away. + +saveas: url=<url> + + <url> is a URL of the destination, encoded. Sent from the child to the + parent after a saveAs() completed. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits