[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp

2019-03-30 Thread Libreoffice Gerrit user
 wsd/ClientSession.cpp  |5 -
 wsd/DocumentBroker.cpp |   23 +--
 wsd/DocumentBroker.hpp |   21 +
 wsd/LOOLWSD.cpp|   30 ++
 4 files changed, 52 insertions(+), 27 deletions(-)

New commits:
commit cca660af532d2bc3c94200454efa7872633554ed
Author: Michael Meeks 
AuthorDate: Sat Mar 2 16:41:47 2019 +0100
Commit: Andras Timar 
CommitDate: Sat Mar 30 18:31:53 2019 +0100

tdf#123482 - cleanup convert-to folder more reliably.

Change-Id: I029bb4136984e05485e462c92da80b92b00fdebc

also squashes:

Simpify DocumentBroker constructor.
Change-Id: I0bf29df9316b129d34862c7464bb6636d42a850d

Avoid using un-necessary reference.
Change-Id: Id5a9fed8fb790f2af8facac119e9e0da476b1e47

Change-Id: I40eb5ae5b4721ffd709db6ecc7754dff8106475d
Reviewed-on: https://gerrit.libreoffice.org/68623
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 2eee1f797..cc325b44b 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -850,11 +850,6 @@ bool ClientSession::handleKitToClientMessage(const char* 
buffer, const int lengt
 
 // Now terminate.
 docBroker->stop("Finished saveas handler.");
-
-// Remove file and directory
-Poco::Path path = docBroker->getDocKey();
-Poco::File(path).remove();
-Poco::File(path.makeParent()).remove();
 }
 
 return true;
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 5b976caf3..465549c27 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -37,6 +37,7 @@
 #include "common/Message.hpp"
 #include "common/Protocol.hpp"
 #include "common/Unit.hpp"
+#include "common/FileUtil.hpp"
 
 #include 
 #include 
@@ -145,13 +146,11 @@ std::atomic DocumentBroker::DocBrokerId(1);
 
 DocumentBroker::DocumentBroker(const std::string& uri,
const Poco::URI& uriPublic,
-   const std::string& docKey,
-   const std::string& childRoot) :
+   const std::string& docKey) :
 _uriOrig(uri),
 _uriPublic(uriPublic),
 _docKey(docKey),
 _docId(Util::encodeId(DocBrokerId++, 3)),
-_childRoot(childRoot),
 _cacheRoot(getCachePath(uriPublic.toString())),
 _documentChangedInStorage(false),
 _lastSaveTime(std::chrono::steady_clock::now()),
@@ -171,10 +170,10 @@ DocumentBroker::DocumentBroker(const std::string& uri,
 _debugRenderedTileCount(0)
 {
 assert(!_docKey.empty());
-assert(!_childRoot.empty());
+assert(!LOOLWSD::ChildRoot.empty());
 
 LOG_INF("DocumentBroker [" << LOOLWSD::anonymizeUrl(_uriPublic.toString()) 
<<
-"] created with docKey [" << _docKey << "] and root [" << 
_childRoot << "]");
+"] created with docKey [" << _docKey << "]");
 }
 
 void DocumentBroker::startThread()
@@ -1027,7 +1026,7 @@ bool DocumentBroker::sendUnoSave(const std::string& 
sessionId, bool dontTerminat
 std::string DocumentBroker::getJailRoot() const
 {
 assert(!_jailId.empty());
-return Poco::Path(_childRoot, _jailId).toString();
+return Poco::Path(LOOLWSD::ChildRoot, _jailId).toString();
 }
 
 size_t DocumentBroker::addSession(const std::shared_ptr& 
session)
@@ -1826,6 +1825,18 @@ void DocumentBroker::getIOStats(uint64_t &sent, uint64_t 
&recv)
 }
 }
 
+ConvertToBroker::~ConvertToBroker()
+{
+if (!_uriOrig.empty())
+{
+// Remove source file and directory
+Poco::Path path = _uriOrig;
+Poco::File(path).remove();
+Poco::File(path.makeParent()).remove();
+FileUtil::removeFile(_uriOrig);
+}
+}
+
 void DocumentBroker::dumpState(std::ostream& os)
 {
 std::unique_lock lock(_mutex);
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index d0fc1a747..8a284f965 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -213,10 +213,9 @@ public:
 /// Construct DocumentBroker with URI, docKey, and root path.
 DocumentBroker(const std::string& uri,
const Poco::URI& uriPublic,
-   const std::string& docKey,
-   const std::string& childRoot);
+   const std::string& docKey);
 
-~DocumentBroker();
+virtual ~DocumentBroker();
 
 /// Start processing events
 void startThread();
@@ -393,8 +392,9 @@ private:
 /// Sum the I/O stats from all connected sessions
 void getIOStats(uint64_t &sent, uint64_t &recv);
 
-private:
+protected:
 const std::string _uriOrig;
+private:
 const Poco::URI _uriPublic;
 /// URL-based key. May be repeated during the lifetime of WSD.
 const std::string _docKey;
@@ -463,6 +463,19 @@ private:
 static std::atomic DocBrokerId;
 };
 
+class ConvertToBroker : public DocumentBroker
+{
+public:
+/// Co

[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp

2018-11-08 Thread Libreoffice Gerrit user
 wsd/ClientSession.cpp |5 +
 1 file changed, 5 insertions(+)

New commits:
commit 9655ed9274c536defb185ff475233ef73de94fe8
Author: Michael Meeks 
AuthorDate: Thu Nov 8 02:35:44 2018 +
Commit: Tor Lillqvist 
CommitDate: Thu Nov 8 15:05:34 2018 +0100

Convert-to - cleanup after ourselves.

Change-Id: I85de9721ac1b33d053b59fc36fc7c307206a0888
Reviewed-on: https://gerrit.libreoffice.org/63056
Reviewed-by: Tor Lillqvist 
Tested-by: Tor Lillqvist 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 4753db07c..864863288 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -846,6 +846,11 @@ bool ClientSession::handleKitToClientMessage(const char* 
buffer, const int lengt
 
 // Now terminate.
 docBroker->stop("Finished saveas handler.");
+
+// Remove file and directory
+Poco::Path path = docBroker->getDocKey();
+Poco::File(path).remove();
+Poco::File(path.makeParent()).remove();
 }
 
 return true;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp

2018-10-02 Thread Libreoffice Gerrit user
 wsd/ClientSession.cpp |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 8f2ea2eba7fbc58b2e2ab5c154e3c9b7a240f59e
Author: Tamás Zolnai 
AuthorDate: Mon Oct 1 18:11:25 2018 +0200
Commit: Andras Timar 
CommitDate: Wed Oct 3 08:32:53 2018 +0200

wsd: Avoid parsing tile messages twice

Change-Id: I049e7ce645999a4d0366ab34ffa75ab0d351947b
(cherry picked from commit 8a318cc44d0a96bced7c565544c4772cfb936f93)
Reviewed-on: https://gerrit.libreoffice.org/61211
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 428455f0f..4753db07c 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1027,15 +1028,16 @@ void ClientSession::enqueueSendMessage(const 
std::shared_ptr& data)
 docBroker->assertCorrectThread();
 
 const std::string command = data->firstToken();
+std::unique_ptr tile;
 if (command == "tile:")
 {
 // Avoid sending tile if it has the same wireID as the previously sent 
tile
-const TileDesc tile = TileDesc::parse(data->firstLine());
-const std::string tileID = generateTileID(tile);
+tile.reset(new TileDesc(TileDesc::parse(data->firstLine(;
+const std::string tileID = generateTileID(*tile);
 auto iter = _oldWireIds.find(tileID);
-if(iter != _oldWireIds.end() && tile.getWireId() != 0 && 
tile.getWireId() == iter->second)
+if(iter != _oldWireIds.end() && tile->getWireId() != 0 && 
tile->getWireId() == iter->second)
 {
-LOG_INF("WSD filters out a tile with the same wireID: " <<  
tile.serialize("tile:"));
+LOG_INF("WSD filters out a tile with the same wireID: " <<  
tile->serialize("tile:"));
 return;
 }
 }
@@ -1045,10 +1047,9 @@ void ClientSession::enqueueSendMessage(const 
std::shared_ptr& data)
 size_t newSize = _senderQueue.enqueue(data);
 
 // Track sent tile
-if (command == "tile:")
+if (tile)
 {
-const TileDesc tile = TileDesc::parse(data->firstLine());
-traceTileBySend(tile, sizeBefore == newSize);
+traceTileBySend(*tile, sizeBefore == newSize);
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp

2018-10-02 Thread Libreoffice Gerrit user
 wsd/ClientSession.cpp |2 --
 1 file changed, 2 deletions(-)

New commits:
commit e4766c150ffb1a7a71b93c089bbba0e17c75542f
Author: Tamás Zolnai 
AuthorDate: Mon Oct 1 18:04:47 2018 +0200
Commit: Andras Timar 
CommitDate: Wed Oct 3 08:32:05 2018 +0200

Remove accidentally pushed log line

Change-Id: Icd7fcb96725b3cf7fded199a5eae13ec2c109a58
(cherry picked from commit 835959a617f388541edaf11b210897566b65b754)
Reviewed-on: https://gerrit.libreoffice.org/61210
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index d28915ec8..428455f0f 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1049,8 +1049,6 @@ void ClientSession::enqueueSendMessage(const 
std::shared_ptr& data)
 {
 const TileDesc tile = TileDesc::parse(data->firstLine());
 traceTileBySend(tile, sizeBefore == newSize);
-if (sizeBefore != newSize)
-LOG_INF("Sending new tile to client: " <<  
tile.serialize("tile:"));
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp

2018-10-01 Thread Libreoffice Gerrit user
 wsd/ClientSession.cpp |5 +
 1 file changed, 5 insertions(+)

New commits:
commit 0726bdf1df4982febd6b0a7cba1c0736be0b488e
Author: Tamás Zolnai 
AuthorDate: Wed Sep 26 22:16:11 2018 +0200
Commit: Jan Holesovsky 
CommitDate: Mon Oct 1 12:42:04 2018 +0200

Don't send tiles which was changed outside of the visible area

Since this commit:
9473908d45a884827356b504c5f768e2f29cc46b
We can avoid that, because the tiles will be invalidated
on the client side and when the client visible area changes
the invalidated tiles are requested anyway.

(cherry picked from commit a1a0bf3718f5dff3996a3ace98a6a9cb0f10f55b)

Change-Id: I272e3b4b87380ae574c16a2b480dbc8caabf4b32
Reviewed-on: https://gerrit.libreoffice.org/61126
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index b097d5dd3..eb8414ff5 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1185,9 +1185,14 @@ void ClientSession::handleTileInvalidation(const 
std::string& message,
 int part = result.first;
 Util::Rectangle& invalidateRect = result.second;
 
+// We can ignore the invalidation if it's outside of the visible area
+if(!normalizedVisArea.intersects(invalidateRect))
+return;
+
 if( part == -1 ) // If no part is specifed we use the part used by the 
client
 part = _clientSelectedPart;
 
+
 std::vector invalidTiles;
 if(part == _clientSelectedPart || _isTextDocument)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp

2018-10-01 Thread Libreoffice Gerrit user
 wsd/ClientSession.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 7253dd1499db54550a4e4e887820027c9c8a4c31
Author: Tamás Zolnai 
AuthorDate: Fri Sep 21 16:04:53 2018 +0200
Commit: Jan Holesovsky 
CommitDate: Mon Oct 1 12:16:38 2018 +0200

Use a bigger timeout for waiting tileprocessed message

The main purpose of this time-out is to avoid waiting forever for lost
tile messages, but since it rare to loose them we can use bigger value,
so we can avoid to send new tiles to a slow network.

Note that the used time stamp does not mean the time when the tile
actually send to the client, but the time when it gets to the sender
queue.

Change-Id: I230d85c38b3a5dafd195851d0cf4caac23149e3e
(cherry picked from commit b623aca57ea47c785ab70ff6ccec58acbff63d75)
Reviewed-on: https://gerrit.libreoffice.org/60879
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 9ef6cf07f..ca43bc426 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1066,7 +1066,7 @@ void ClientSession::removeOutdatedTilesOnFly()
 {
 auto tileIter = _tilesOnFly.begin();
 double elapsedTimeMs = 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 - tileIter->second).count();
-if(elapsedTimeMs > 3000)
+if(elapsedTimeMs > 5000.0)
 {
 LOG_WRN("Tracker tileID was dropped because of time out. 
Tileprocessed message did not arrive");
 _tilesOnFly.erase(tileIter);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp

2018-10-01 Thread Libreoffice Gerrit user
 wsd/ClientSession.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 0e7fbcb26f7231088d402186500c24992ffa7288
Author: Tamás Zolnai 
AuthorDate: Fri Sep 21 15:52:08 2018 +0200
Commit: Jan Holesovsky 
CommitDate: Mon Oct 1 12:15:25 2018 +0200

Convert this warning to info

There valid cases when we get unknown tileID. For example we
sent some tiles, but in the meantime canceltiles arrives which
resets tiles-on-fly list, but the client still send tileprocessed
messages for earlier requested tiles.

Change-Id: If2ec015106a0e58d66ae4517b64a9552eb8c38fc
(cherry picked from commit 0807d04934476a5c27ada9b1938fd7b94147e012)
Reviewed-on: https://gerrit.libreoffice.org/60878
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 6461851d9..9ef6cf07f 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -351,7 +351,7 @@ bool ClientSession::_handleInput(const char *buffer, int 
length)
 if(iter != _tilesOnFly.end())
 _tilesOnFly.erase(iter);
 else
-LOG_WRN("Tileprocessed message with an unknown tile ID");
+LOG_INF("Tileprocessed message with an unknown tile ID");
 
 docBroker->sendRequestedTiles(shared_from_this());
 return true;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/DocumentBroker.cpp

2018-09-07 Thread Libreoffice Gerrit user
 wsd/ClientSession.cpp  |   18 --
 wsd/ClientSession.hpp  |3 +++
 wsd/DocumentBroker.cpp |   14 --
 3 files changed, 23 insertions(+), 12 deletions(-)

New commits:
commit ac47dfed72a549b5e15e00b5cef5e76ffd4b6277
Author: Tamás Zolnai 
AuthorDate: Thu Aug 30 17:40:42 2018 +0200
Commit: Jan Holesovsky 
CommitDate: Fri Sep 7 13:16:28 2018 +0200

Calculate tiles-on-fly limit a bit more precisely

Change-Id: Id012a83d6ccd226d1b66e3cd48a9caeafd849fc5
(cherry picked from commit dce6c18fb4848a27c2e50faed4e6585b0b7bfdcd)
Reviewed-on: https://gerrit.libreoffice.org/59836
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 00fd8373d..6461851d9 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1076,6 +1076,16 @@ void ClientSession::removeOutdatedTilesOnFly()
 }
 }
 
+Util::Rectangle ClientSession::getNormalizedVisibleArea() const
+{
+Util::Rectangle normalizedVisArea;
+normalizedVisArea._x1 = std::max(_clientVisibleArea._x1, 0);
+normalizedVisArea._y1 = std::max(_clientVisibleArea._y1, 0);
+normalizedVisArea._x2 = _clientVisibleArea._x2;
+normalizedVisArea._y2 = _clientVisibleArea._y2;
+return normalizedVisArea;
+}
+
 void ClientSession::onDisconnect()
 {
 LOG_INF(getName() << " Disconnected, current number of connections: " << 
LOOLWSD::NumConnections);
@@ -1169,12 +1179,8 @@ void ClientSession::handleTileInvalidation(const 
std::string& message,
 return;
 }
 
-// Visible area can have negativ value as position, but we have tiles only 
in the positiv range 
-Util::Rectangle normalizedVisArea;
-normalizedVisArea._x1 = std::max(_clientVisibleArea._x1, 0);
-normalizedVisArea._y1 = std::max(_clientVisibleArea._y1, 0);
-normalizedVisArea._x2 = _clientVisibleArea._x2;
-normalizedVisArea._y2 = _clientVisibleArea._y2;
+// Visible area can have negativ value as position, but we have tiles only 
in the positive range
+Util::Rectangle normalizedVisArea = getNormalizedVisibleArea();
 
 std::pair result = 
TileCache::parseInvalidateMsg(message);
 int part = result.first;
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 397f7b670..67664ee35 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -130,6 +130,9 @@ public:
 void removeOutdatedTilesOnFly();
 
 Util::Rectangle getVisibleArea() const { return _clientVisibleArea; }
+/// Visible area can have negative value as position, but we have tiles 
only in the positive range
+Util::Rectangle getNormalizedVisibleArea() const;
+
 int getTileWidthInTwips() const { return _tileWidthTwips; }
 int getTileHeightInTwips() const { return _tileHeightTwips; }
 
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 9f9e63304..367445e84 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1391,13 +1391,15 @@ void DocumentBroker::sendRequestedTiles(const 
std::shared_ptr& se
 std::unique_lock lock(_mutex);
 
 // How many tiles we have on the visible area, set the upper limit 
accordingly
-const float tilesFitOnWidth = 
static_cast(session->getVisibleArea().getWidth()) /
-  
static_cast(session->getTileWidthInTwips());
-const float tilesFitOnHeight = 
static_cast(session->getVisibleArea().getHeight()) /
-   
static_cast(session->getTileHeightInTwips());
-const float tilesInVisArea = tilesFitOnWidth * tilesFitOnHeight;
+Util::Rectangle normalizedVisArea = session->getNormalizedVisibleArea();
 
-const float tilesOnFlyUpperLimit = std::max(TILES_ON_FLY_MIN_UPPER_LIMIT, 
tilesInVisArea * 1.20f);
+const int tilesFitOnWidth = std::ceil(normalizedVisArea._x2 / 
session->getTileWidthInTwips()) -
+std::ceil(normalizedVisArea._x1 / 
session->getTileWidthInTwips()) + 1;
+const int tilesFitOnHeight = std::ceil(normalizedVisArea._y2 / 
session->getTileHeightInTwips()) -
+ std::ceil(normalizedVisArea._y1 / 
session->getTileHeightInTwips()) + 1;
+const int tilesInVisArea = tilesFitOnWidth * tilesFitOnHeight;
+
+const float tilesOnFlyUpperLimit = std::max(TILES_ON_FLY_MIN_UPPER_LIMIT, 
tilesInVisArea * 1.5f);
 
 // Update client's tilesBeingRendered list
 session->removeOutdatedTileSubscriptions();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp

2018-05-29 Thread Ashod Nakashian
 wsd/ClientSession.cpp |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit 1f30b1fe9fc7de54f908e0d39e4f89aad6569688
Author: Ashod Nakashian 
Date:   Wed Feb 28 09:20:55 2018 -0500

wsd: localize variables

Change-Id: I411e435fa2360423b4c48d087eb501b942cc637d
Reviewed-on: https://gerrit.libreoffice.org/52681
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 5d172417a..d85366ef2 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -869,11 +869,9 @@ bool ClientSession::handleKitToClientMessage(const char* 
buffer, const int lengt
 
 bool ClientSession::forwardToClient(const std::shared_ptr& payload)
 {
-const auto& message = payload->abbr();
-
 if (isCloseFrame())
 {
-LOG_TRC(getName() << ": peer began the closing handshake. Dropping 
forward message [" << message << "].");
+LOG_TRC(getName() << ": peer began the closing handshake. Dropping 
forward message [" << payload->abbr() << "].");
 return true;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp

2018-04-26 Thread Jan Holesovsky
 wsd/ClientSession.cpp |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 1e536b80f31d978e35dd21577003c20a4d4ecb2f
Author: Jan Holesovsky 
Date:   Wed Apr 25 13:46:23 2018 +0200

Avoid crash in the non-wopi case.

Change-Id: I87aff462dab4abca0235622493f720eacbc39f03
Reviewed-on: https://gerrit.libreoffice.org/53445
Reviewed-by: Michael Meeks 
Tested-by: Michael Meeks 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 8b1d6654c..5d172417a 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -750,9 +750,9 @@ bool ClientSession::handleKitToClientMessage(const char* 
buffer, const int lengt
 if (unoStatePair.first == ".uno:TrackChanges")
 {
 if ((unoStatePair.second == "true" &&
- _wopiFileInfo->_disableChangeTrackingRecord == 
WopiStorage::WOPIFileInfo::TriState::True) ||
+ _wopiFileInfo && 
_wopiFileInfo->_disableChangeTrackingRecord == 
WopiStorage::WOPIFileInfo::TriState::True) ||
 (unoStatePair.second == "false" &&
- _wopiFileInfo->_disableChangeTrackingRecord == 
WopiStorage::WOPIFileInfo::TriState::False))
+ _wopiFileInfo && 
_wopiFileInfo->_disableChangeTrackingRecord == 
WopiStorage::WOPIFileInfo::TriState::False))
 {
 // Toggle the TrackChanges state.
 LOG_DBG("Forcing " << unoStatePair.first << " toggle 
per user settings.");
@@ -762,9 +762,9 @@ bool ClientSession::handleKitToClientMessage(const char* 
buffer, const int lengt
 else if (unoStatePair.first == ".uno:ShowTrackedChanges")
 {
 if ((unoStatePair.second == "true" &&
- _wopiFileInfo->_disableChangeTrackingShow == 
WopiStorage::WOPIFileInfo::TriState::True) ||
+ _wopiFileInfo && 
_wopiFileInfo->_disableChangeTrackingShow == 
WopiStorage::WOPIFileInfo::TriState::True) ||
 (unoStatePair.second == "false" &&
- _wopiFileInfo->_disableChangeTrackingShow == 
WopiStorage::WOPIFileInfo::TriState::False))
+ _wopiFileInfo && 
_wopiFileInfo->_disableChangeTrackingShow == 
WopiStorage::WOPIFileInfo::TriState::False))
 {
 // Toggle the ShowTrackChanges state.
 LOG_DBG("Forcing " << unoStatePair.first << " toggle 
per user settings.");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/Storage.cpp wsd/Storage.hpp

2018-04-25 Thread Ashod Nakashian
 wsd/ClientSession.cpp  |   36 +++-
 wsd/DocumentBroker.cpp |   13 -
 wsd/DocumentBroker.hpp |9 +
 wsd/Storage.cpp|   32 
 wsd/Storage.hpp|   24 
 5 files changed, 100 insertions(+), 14 deletions(-)

New commits:
commit 9927458251fd069e11efc8e83c78449497cc2048
Author: Ashod Nakashian 
Date:   Tue Apr 24 12:09:37 2018 -0400

wsd: support optional forcing tracking changes at load

Since changing the tracking state is done by toggling,
we need to wait to get the current state at load time
before we can tell whether we need to toggle it or not.

Change-Id: Ib5a2639b2acf3874c191971eedf9a3bebcefebad
Reviewed-on: https://gerrit.libreoffice.org/53426
Tested-by: Aron Budea 
Reviewed-by: Jan Holesovsky 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 77a6e075a..8b1d6654c 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -19,6 +19,7 @@
 
 #include "DocumentBroker.hpp"
 #include "LOOLWSD.hpp"
+#include "Storage.hpp"
 #include "common/Common.hpp"
 #include "common/Log.hpp"
 #include "common/Protocol.hpp"
@@ -738,6 +739,40 @@ bool ClientSession::handleKitToClientMessage(const char* 
buffer, const int lengt
 {
 docBroker->setModified(stateTokens[1] == "true");
 }
+else
+{
+// Set the initial settings per the user's request.
+const std::pair unoStatePair = 
LOOLProtocol::split(tokens[1], '=');
+
+if (!docBroker->isInitialSettingSet(unoStatePair.first))
+{
+docBroker->setInitialSetting(unoStatePair.first);
+if (unoStatePair.first == ".uno:TrackChanges")
+{
+if ((unoStatePair.second == "true" &&
+ _wopiFileInfo->_disableChangeTrackingRecord == 
WopiStorage::WOPIFileInfo::TriState::True) ||
+(unoStatePair.second == "false" &&
+ _wopiFileInfo->_disableChangeTrackingRecord == 
WopiStorage::WOPIFileInfo::TriState::False))
+{
+// Toggle the TrackChanges state.
+LOG_DBG("Forcing " << unoStatePair.first << " toggle 
per user settings.");
+forwardToChild("uno .uno:TrackChanges", docBroker);
+}
+}
+else if (unoStatePair.first == ".uno:ShowTrackedChanges")
+{
+if ((unoStatePair.second == "true" &&
+ _wopiFileInfo->_disableChangeTrackingShow == 
WopiStorage::WOPIFileInfo::TriState::True) ||
+(unoStatePair.second == "false" &&
+ _wopiFileInfo->_disableChangeTrackingShow == 
WopiStorage::WOPIFileInfo::TriState::False))
+{
+// Toggle the ShowTrackChanges state.
+LOG_DBG("Forcing " << unoStatePair.first << " toggle 
per user settings.");
+forwardToChild("uno .uno:ShowTrackedChanges", 
docBroker);
+}
+}
+}
+}
 }
 
 if (!_isDocPasswordProtected)
@@ -843,7 +878,6 @@ bool ClientSession::forwardToClient(const 
std::shared_ptr& payload)
 }
 
 enqueueSendMessage(payload);
-
 return true;
 }
 
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 72c618831..2b08c4882 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -502,12 +502,13 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 wopiInfo->set("HidePrintOption", wopifileinfo->_hidePrintOption);
 wopiInfo->set("HideSaveOption", wopifileinfo->_hideSaveOption);
 wopiInfo->set("HideExportOption", wopifileinfo->_hideExportOption);
-wopiInfo->set("HideChangeTrackingControls", 
wopifileinfo->_hideChangeTrackingControls);
 wopiInfo->set("DisablePrint", wopifileinfo->_disablePrint);
 wopiInfo->set("DisableExport", wopifileinfo->_disableExport);
 wopiInfo->set("DisableCopy", wopifileinfo->_disableCopy);
 wopiInfo->set("DisableInactiveMessages", 
wopifileinfo->_disableInactiveMessages);
 wopiInfo->set("UserCanNotWriteRelative", 
wopifileinfo->_userCanNotWriteRelative);
+if (wopifileinfo->_hideChangeTrackingControls != 
WopiStorage::WOPIFileInfo::TriState::Unset)
+wopiInfo->set("HideChangeTrackingControls", 
wopifileinfo->_hideChangeTrackingControls == 
WopiStorage::WOPIFileInfo::TriState::True);
 
 std::ostringstream ossWopiInfo;
 wopiInfo->stringify(ossWopiInfo);
@@ -1447,6 +1448,16 @@ void DocumentBroker::setModified(const bool value)
 _tileCache->setUnsavedChanges(value);
 }
 
+bool DocumentBroker::isInitialSettingSet(const std::string& name) const
+{
+return _isInitialStateSet.find(name) != _isInitia

[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp

2018-04-13 Thread Tamás Zolnai
 wsd/ClientSession.cpp |   21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 6136cc34d679c409da2506ed5fe96394f2c7ca41
Author: Tamás Zolnai 
Date:   Thu Apr 12 20:28:54 2018 +0200

Update dumper code to handle new payload for invalidatecursor

Change-Id: Ibfe129ce4db9ff33d409fb6ebabfb3a435b64829
Reviewed-on: https://gerrit.libreoffice.org/52804
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index b307e2e6b..77a6e075a 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -781,16 +781,23 @@ bool ClientSession::handleKitToClientMessage(const char* 
buffer, const int lengt
 else if (tokens[0] == "invalidatecursor:")
 {
 assert(firstLine.size() == 
static_cast(length));
-StringTokenizer firstLineTokens(firstLine, " ", 
StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
+
+const size_t index = firstLine.find_first_of('{');
+const std::string stringJSON = firstLine.substr(index);
+Poco::JSON::Parser parser;
+const Poco::Dynamic::Var result = parser.parse(stringJSON);
+const auto& object = result.extract();
+const std::string rectangle = object->get("rectangle").toString();
+StringTokenizer rectangleTokens(rectangle, ",", 
StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
 int x = 0, y = 0, w = 0, h = 0;
-if (firstLineTokens.count() > 2 &&
-stringToInteger(firstLineTokens[1], x) &&
-stringToInteger(firstLineTokens[2], y))
+if (rectangleTokens.count() > 2 &&
+stringToInteger(rectangleTokens[0], x) &&
+stringToInteger(rectangleTokens[1], y))
 {
-if (firstLineTokens.count() > 3)
+if (rectangleTokens.count() > 3)
 {
-stringToInteger(firstLineTokens[3], w);
-stringToInteger(firstLineTokens[4], h);
+stringToInteger(rectangleTokens[2], w);
+stringToInteger(rectangleTokens[3], h);
 }
 
 docBroker->invalidateCursor(x, y, w, h);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits