[Libreoffice-commits] online.git: Branch 'libreoffice-5-3' - 27 commits - AUTHORS autogen.sh bundled/include ChangeLog .clang-tidy common/Common.hpp common/FileUtil.cpp common/FileUtil.hpp common/IoUtil.cpp common/IoUtil.hpp common/Log.cpp common/Log.hpp common/MessageQueue.cpp common/MessageQueue.hpp common/Png.hpp common/Protocol.cpp common/Protocol.hpp common/Rectangle.hpp common/security.h common/Session.cpp common/Session.hpp common/SigUtil.cpp common/SigUtil.hpp common/Unit.cpp common/Unit.hpp common/UnitHTTP.cpp common/UnitHTTP.hpp common/Util.cpp common/Util.hpp configure.ac COPYING debian/changelog debian/compat debian/control debian/copyright debian/loolwsd.cron.d debian/loolwsd.postinst debian/loolwsd.preinst debian/rules debian/source discovery.xml etc/ca-chain.cert.pem etc/cert.pem etc/key.pem favicon.ico .gitignore INSTALL kit/ChildSession.cpp kit/ChildSession.hpp kit/ForKit.cpp kit/Kit.cpp kit/KitHelper.hpp kit/Kit.hpp loleaflet/dist loleaflet/src loolstat loolwsd/Admin.cpp loolwsd /Admin.hpp loolwsd/AdminModel.cpp loolwsd/AdminModel.hpp loolwsd/Auth.cpp loolwsd/Auth.hpp loolwsd/AUTHORS loolwsd/autogen.sh loolwsd/bundled loolwsd/ChangeLog loolwsd/ChildSession.cpp loolwsd/ChildSession.hpp loolwsd/.clang-tidy loolwsd/ClientSession.cpp loolwsd/ClientSession.hpp loolwsd/common loolwsd/Common.hpp loolwsd/configure.ac loolwsd/Connect.cpp loolwsd/COPYING loolwsd/debian loolwsd/discovery.xml loolwsd/DocumentBroker.cpp loolwsd/DocumentBroker.hpp loolwsd/etc loolwsd/Exceptions.hpp loolwsd/favicon.ico loolwsd/FileServer.cpp loolwsd/FileServer.hpp loolwsd/.gitignore loolwsd/INSTALL loolwsd/IoUtil.cpp loolwsd/IoUtil.hpp loolwsd/lint-discovery.py loolwsd/Log.cpp loolwsd/Log.hpp loolwsd/LOKitClient.cpp loolwsd/LOKitHelper.hpp loolwsd/LOOLForKit.cpp loolwsd/LOOLKit.cpp loolwsd/LOOLKit.hpp loolwsd/loolmap.c loolwsd/loolmount.c loolwsd/LOOLProtocol.cpp loolwsd/LOOLProtocol.hpp loolwsd/LOOLSession.cpp loolwsd/LOOLSession.hpp loolwsd/loolstat loolwsd/LOOLStress.cpp loolwsd/LOOLTo ol.cpp loolwsd/LOOLWebSocket.hpp loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp loolwsd/loolwsd.service loolwsd/loolwsd.spec.in loolwsd/loolwsd-systemplate-setup loolwsd/loolwsd.xml.in loolwsd/Makefile.am loolwsd/maketarballfordeb.sh.in loolwsd/MessageQueue.cpp loolwsd/MessageQueue.hpp loolwsd/NEWS loolwsd/Png.hpp loolwsd/PrisonerSession.cpp loolwsd/PrisonerSession.hpp loolwsd/PROBLEMS loolwsd/protocol.txt loolwsd/QueueHandler.hpp loolwsd/README loolwsd/README.vars loolwsd/Rectangle.hpp loolwsd/reference.txt loolwsd/robots.txt loolwsd/security.h loolwsd.service loolwsd.spec.in loolwsd/Storage.cpp loolwsd/Storage.hpp loolwsd/sysconfig.loolwsd loolwsd-systemplate-setup loolwsd/test loolwsd/TileCache.cpp loolwsd/TileCache.hpp loolwsd/TileDesc.hpp loolwsd/TODO loolwsd/TraceFile.hpp loolwsd/Unit.cpp loolwsd/Unit.hpp loolwsd/UnitHTTP.cpp loolwsd/UnitHTTP.hpp loolwsd/UserMessages.hpp loolwsd/Util.cpp loolwsd/Util.hpp loolwsd.xml.in Makefile.am maketarballfordeb.sh.in NEWS PROBLEMS README rename.s h robots.txt sysconfig.loolwsd test/countloolkits.hpp test/data test/.gitignore test/helpers.hpp test/httpcrashtest.cpp test/httpwserror.cpp test/httpwstest.cpp test/integration-http-server.cpp test/Makefile.am test/run_unit.sh.in test/test.cpp test/TileCacheTests.cpp test/TileQueueTests.cpp test/UnitAdmin.cpp test/UnitFonts.cpp test/UnitFuzz.cpp test/UnitPrefork.cpp test/UnitRequests.cpp test/UnitStorage.cpp test/UnitTileCache.cpp test/UnitTimeout.cpp test/WhiteBoxTests.cpp TODO tools/Connect.cpp tools/KitClient.cpp tools/map.cpp tools/mount.cpp tools/Stress.cpp tools/Tool.cpp wsd/Admin.cpp wsd/Admin.hpp wsd/AdminModel.cpp wsd/AdminModel.hpp wsd/Auth.cpp wsd/Auth.hpp wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/Exceptions.hpp wsd/FileServer.cpp wsd/FileServer.hpp wsd/lint-discovery.py wsd/LOOLWebSocket.hpp wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp wsd/PrisonerSession.cpp wsd/PrisonerSession.hpp wsd/protocol.txt wsd/QueueHandler.hpp wsd/README wsd/README.vars wsd/reference.txt wsd/Storage.cpp wsd/Storage.hpp wsd/TileCache.cpp wsd/TileCache.hpp wsd/TileDesc.hpp wsd/TraceFile.hpp wsd/UserMessages.hpp

Andras Timar andras.timar at collabora.com
Fri Nov 25 12:10:59 UTC 2016


 .clang-tidy                                                  |    3 
 .gitignore                                                   |   58 
 COPYING                                                      |    5 
 ChangeLog                                                    |    1 
 INSTALL                                                      |    1 
 Makefile.am                                                  |  213 +
 NEWS                                                         |    1 
 PROBLEMS                                                     |   55 
 README                                                       |   20 
 TODO                                                         |   25 
 autogen.sh                                                   |   27 
 bundled/include/LibreOfficeKit/LibreOfficeKit.h              |  263 +
 bundled/include/LibreOfficeKit/LibreOfficeKit.hxx            |  610 +++
 bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h         |  532 ++
 bundled/include/LibreOfficeKit/LibreOfficeKitInit.h          |  293 +
 bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h         |   30 
 common/Common.hpp                                            |   48 
 common/FileUtil.cpp                                          |  205 +
 common/FileUtil.hpp                                          |   93 
 common/IoUtil.cpp                                            |  335 +
 common/IoUtil.hpp                                            |   69 
 common/Log.cpp                                               |  207 +
 common/Log.hpp                                               |  185 
 common/MessageQueue.cpp                                      |  317 +
 common/MessageQueue.hpp                                      |  152 
 common/Png.hpp                                               |  235 +
 common/Protocol.cpp                                          |  204 +
 common/Protocol.hpp                                          |  226 +
 common/Rectangle.hpp                                         |   82 
 common/Session.cpp                                           |  247 +
 common/Session.hpp                                           |  208 +
 common/SigUtil.cpp                                           |  302 +
 common/SigUtil.hpp                                           |   61 
 common/Unit.cpp                                              |  205 +
 common/Unit.hpp                                              |  240 +
 common/UnitHTTP.cpp                                          |   35 
 common/UnitHTTP.hpp                                          |  138 
 common/Util.cpp                                              |  209 +
 common/Util.hpp                                              |  257 +
 common/security.h                                            |   40 
 configure.ac                                                 |  326 +
 debian/changelog                                             |   25 
 debian/compat                                                |    1 
 debian/control                                               |   14 
 debian/copyright                                             |   31 
 debian/loolwsd.cron.d                                        |    1 
 debian/loolwsd.postinst                                      |   28 
 debian/loolwsd.preinst                                       |   10 
 debian/rules                                                 |   29 
 debian/source/format                                         |    1 
 dev/null                                                     |binary
 discovery.xml                                                |  303 +
 etc/ca-chain.cert.pem                                        |   71 
 etc/cert.pem                                                 |   35 
 etc/key.pem                                                  |   27 
 favicon.ico                                                  |binary
 kit/ChildSession.cpp                                         | 1152 +++++
 kit/ChildSession.hpp                                         |  154 
 kit/ForKit.cpp                                               |  449 ++
 kit/Kit.cpp                                                  | 1662 ++++++++
 kit/Kit.hpp                                                  |   45 
 kit/KitHelper.hpp                                            |  162 
 loleaflet/dist/errormessages.js                              |    5 
 loleaflet/dist/loleaflet.css                                 |    5 
 loleaflet/dist/toolbar/toolbar.js                            |    2 
 loleaflet/src/control/Control.CharacterMap.js                |    4 
 loleaflet/src/control/Control.Dialog.js                      |    4 
 loleaflet/src/core/Socket.js                                 |   11 
 loleaflet/src/layer/marker/Icon.Default.js                   |    6 
 loleaflet/src/layer/tile/TileLayer.js                        |   14 
 loleaflet/src/map/Map.js                                     |   12 
 loleaflet/src/map/handler/Map.Keyboard.js                    |   25 
 loleaflet/src/map/handler/Map.TouchZoom.js                   |    7 
 loolstat                                                     |   90 
 loolwsd-systemplate-setup                                    |   97 
 loolwsd.service                                              |   13 
 loolwsd.spec.in                                              |  191 
 loolwsd.xml.in                                               |   76 
 loolwsd/.clang-tidy                                          |    3 
 loolwsd/.gitignore                                           |   58 
 loolwsd/Admin.cpp                                            |  391 -
 loolwsd/Admin.hpp                                            |  158 
 loolwsd/AdminModel.cpp                                       |  358 -
 loolwsd/AdminModel.hpp                                       |  195 
 loolwsd/Auth.cpp                                             |  238 -
 loolwsd/Auth.hpp                                             |   95 
 loolwsd/COPYING                                              |    5 
 loolwsd/ChangeLog                                            |    1 
 loolwsd/ChildSession.cpp                                     | 1152 -----
 loolwsd/ChildSession.hpp                                     |  154 
 loolwsd/ClientSession.cpp                                    |  401 --
 loolwsd/ClientSession.hpp                                    |  113 
 loolwsd/Common.hpp                                           |   48 
 loolwsd/Connect.cpp                                          |  262 -
 loolwsd/DocumentBroker.cpp                                   | 1011 -----
 loolwsd/DocumentBroker.hpp                                   |  352 -
 loolwsd/Exceptions.hpp                                       |   72 
 loolwsd/FileServer.cpp                                       |  257 -
 loolwsd/FileServer.hpp                                       |   65 
 loolwsd/INSTALL                                              |    1 
 loolwsd/IoUtil.cpp                                           |  335 -
 loolwsd/IoUtil.hpp                                           |   69 
 loolwsd/LOKitClient.cpp                                      |  222 -
 loolwsd/LOKitHelper.hpp                                      |  162 
 loolwsd/LOOLForKit.cpp                                       |  449 --
 loolwsd/LOOLKit.cpp                                          | 1662 --------
 loolwsd/LOOLKit.hpp                                          |   45 
 loolwsd/LOOLProtocol.cpp                                     |  204 -
 loolwsd/LOOLProtocol.hpp                                     |  226 -
 loolwsd/LOOLSession.cpp                                      |  247 -
 loolwsd/LOOLSession.hpp                                      |  208 -
 loolwsd/LOOLStress.cpp                                       |  553 --
 loolwsd/LOOLTool.cpp                                         |  253 -
 loolwsd/LOOLWSD.cpp                                          | 2185 ----------
 loolwsd/LOOLWSD.hpp                                          |  169 
 loolwsd/LOOLWebSocket.hpp                                    |  153 
 loolwsd/Log.cpp                                              |  207 -
 loolwsd/Log.hpp                                              |  185 
 loolwsd/Makefile.am                                          |  206 -
 loolwsd/MessageQueue.cpp                                     |  317 -
 loolwsd/MessageQueue.hpp                                     |  152 
 loolwsd/NEWS                                                 |    1 
 loolwsd/PROBLEMS                                             |   55 
 loolwsd/Png.hpp                                              |  235 -
 loolwsd/PrisonerSession.cpp                                  |  263 -
 loolwsd/PrisonerSession.hpp                                  |   41 
 loolwsd/QueueHandler.hpp                                     |   68 
 loolwsd/README                                               |  389 -
 loolwsd/README.vars                                          |   33 
 loolwsd/Rectangle.hpp                                        |   82 
 loolwsd/Storage.cpp                                          |  523 --
 loolwsd/Storage.hpp                                          |  255 -
 loolwsd/TODO                                                 |   25 
 loolwsd/TileCache.cpp                                        |  542 --
 loolwsd/TileCache.hpp                                        |  104 
 loolwsd/TileDesc.hpp                                         |  410 --
 loolwsd/TraceFile.hpp                                        |  309 -
 loolwsd/Unit.cpp                                             |  205 -
 loolwsd/Unit.hpp                                             |  240 -
 loolwsd/UnitHTTP.cpp                                         |   35 
 loolwsd/UnitHTTP.hpp                                         |  138 
 loolwsd/UserMessages.hpp                                     |   21 
 loolwsd/Util.cpp                                             |  209 -
 loolwsd/Util.hpp                                             |  257 -
 loolwsd/autogen.sh                                           |   27 
 loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h      |  263 -
 loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx    |  610 ---
 loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h |  532 --
 loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitInit.h  |  293 -
 loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h |   30 
 loolwsd/common/FileUtil.cpp                                  |  205 -
 loolwsd/common/FileUtil.hpp                                  |   93 
 loolwsd/common/SigUtil.cpp                                   |  302 -
 loolwsd/common/SigUtil.hpp                                   |   61 
 loolwsd/configure.ac                                         |  326 -
 loolwsd/debian/changelog                                     |   25 
 loolwsd/debian/compat                                        |    1 
 loolwsd/debian/control                                       |   14 
 loolwsd/debian/copyright                                     |   31 
 loolwsd/debian/loolwsd.cron.d                                |    1 
 loolwsd/debian/loolwsd.postinst                              |   28 
 loolwsd/debian/loolwsd.preinst                               |   10 
 loolwsd/debian/rules                                         |   29 
 loolwsd/debian/source/format                                 |    1 
 loolwsd/discovery.xml                                        |  303 -
 loolwsd/etc/ca-chain.cert.pem                                |   71 
 loolwsd/etc/cert.pem                                         |   35 
 loolwsd/etc/key.pem                                          |   27 
 loolwsd/lint-discovery.py                                    |  246 -
 loolwsd/loolmap.c                                            |  180 
 loolwsd/loolmount.c                                          |   35 
 loolwsd/loolstat                                             |   90 
 loolwsd/loolwsd-systemplate-setup                            |   97 
 loolwsd/loolwsd.service                                      |   13 
 loolwsd/loolwsd.spec.in                                      |  191 
 loolwsd/loolwsd.xml.in                                       |   76 
 loolwsd/maketarballfordeb.sh.in                              |   14 
 loolwsd/protocol.txt                                         |  567 --
 loolwsd/reference.txt                                        |    7 
 loolwsd/robots.txt                                           |    2 
 loolwsd/security.h                                           |   40 
 loolwsd/sysconfig.loolwsd                                    |    6 
 loolwsd/test/.gitignore                                      |   12 
 loolwsd/test/Makefile.am                                     |   90 
 loolwsd/test/TileCacheTests.cpp                              |  985 ----
 loolwsd/test/TileQueueTests.cpp                              |  264 -
 loolwsd/test/UnitAdmin.cpp                                   |  482 --
 loolwsd/test/UnitFonts.cpp                                   |  169 
 loolwsd/test/UnitFuzz.cpp                                    |   75 
 loolwsd/test/UnitPrefork.cpp                                 |  328 -
 loolwsd/test/UnitRequests.cpp                                |   99 
 loolwsd/test/UnitStorage.cpp                                 |   80 
 loolwsd/test/UnitTileCache.cpp                               |   90 
 loolwsd/test/UnitTimeout.cpp                                 |   70 
 loolwsd/test/WhiteBoxTests.cpp                               |  224 -
 loolwsd/test/countloolkits.hpp                               |  112 
 loolwsd/test/data/hello.txt                                  |    1 
 loolwsd/test/data/paste.html                                 |    1 
 loolwsd/test/helpers.hpp                                     |  566 --
 loolwsd/test/httpcrashtest.cpp                               |  263 -
 loolwsd/test/httpwserror.cpp                                 |  195 
 loolwsd/test/httpwstest.cpp                                  | 2145 ----------
 loolwsd/test/integration-http-server.cpp                     |  288 -
 loolwsd/test/run_unit.sh.in                                  |  121 
 loolwsd/test/test.cpp                                        |  103 
 maketarballfordeb.sh.in                                      |   14 
 rename.sh                                                    |    1 
 robots.txt                                                   |    2 
 sysconfig.loolwsd                                            |    6 
 test/.gitignore                                              |   12 
 test/Makefile.am                                             |   91 
 test/TileCacheTests.cpp                                      |  985 ++++
 test/TileQueueTests.cpp                                      |  264 +
 test/UnitAdmin.cpp                                           |  482 ++
 test/UnitFonts.cpp                                           |  169 
 test/UnitFuzz.cpp                                            |   75 
 test/UnitPrefork.cpp                                         |  328 +
 test/UnitRequests.cpp                                        |   99 
 test/UnitStorage.cpp                                         |   80 
 test/UnitTileCache.cpp                                       |   90 
 test/UnitTimeout.cpp                                         |   70 
 test/WhiteBoxTests.cpp                                       |  224 +
 test/countloolkits.hpp                                       |  112 
 test/data/Example.odt                                        |binary
 test/data/calc_render.xls                                    |binary
 test/data/calc_render_0_512x512.3840,0.7680x7680.png         |binary
 test/data/empty.odg                                          |binary
 test/data/empty.odp                                          |binary
 test/data/empty.ods                                          |binary
 test/data/empty.odt                                          |binary
 test/data/graphicviewselection.odp                           |binary
 test/data/graphicviewselection.ods                           |binary
 test/data/graphicviewselection.odt                           |binary
 test/data/hello.odt                                          |binary
 test/data/hello.txt                                          |    1 
 test/data/hide-whitespace.odt                                |binary
 test/data/insert-delete.odp                                  |binary
 test/data/load12.ods                                         |binary
 test/data/password-protected.ods                             |binary
 test/data/paste.html                                         |    1 
 test/data/setclientpart.odp                                  |binary
 test/data/setclientpart.ods                                  |binary
 test/data/shape.ods                                          |binary
 test/data/timeline.xlsx                                      |binary
 test/data/viewcursor.odp                                     |binary
 test/data/with_comment.odt                                   |binary
 test/helpers.hpp                                             |  566 ++
 test/httpcrashtest.cpp                                       |  263 +
 test/httpwserror.cpp                                         |  195 
 test/httpwstest.cpp                                          | 2145 ++++++++++
 test/integration-http-server.cpp                             |  288 +
 test/run_unit.sh.in                                          |  121 
 test/test.cpp                                                |  103 
 tools/Connect.cpp                                            |  262 +
 tools/KitClient.cpp                                          |  222 +
 tools/Stress.cpp                                             |  553 ++
 tools/Tool.cpp                                               |  253 +
 tools/map.cpp                                                |  180 
 tools/mount.cpp                                              |   35 
 wsd/Admin.cpp                                                |  391 +
 wsd/Admin.hpp                                                |  158 
 wsd/AdminModel.cpp                                           |  361 +
 wsd/AdminModel.hpp                                           |  191 
 wsd/Auth.cpp                                                 |  238 +
 wsd/Auth.hpp                                                 |   95 
 wsd/ClientSession.cpp                                        |  401 ++
 wsd/ClientSession.hpp                                        |  113 
 wsd/DocumentBroker.cpp                                       | 1026 +++++
 wsd/DocumentBroker.hpp                                       |  352 +
 wsd/Exceptions.hpp                                           |   72 
 wsd/FileServer.cpp                                           |  257 +
 wsd/FileServer.hpp                                           |   65 
 wsd/LOOLWSD.cpp                                              | 2191 +++++++++++
 wsd/LOOLWSD.hpp                                              |  169 
 wsd/LOOLWebSocket.hpp                                        |  153 
 wsd/PrisonerSession.cpp                                      |  263 +
 wsd/PrisonerSession.hpp                                      |   41 
 wsd/QueueHandler.hpp                                         |   68 
 wsd/README                                                   |  389 +
 wsd/README.vars                                              |   33 
 wsd/Storage.cpp                                              |  532 ++
 wsd/Storage.hpp                                              |  262 +
 wsd/TileCache.cpp                                            |  542 ++
 wsd/TileCache.hpp                                            |  104 
 wsd/TileDesc.hpp                                             |  415 ++
 wsd/TraceFile.hpp                                            |  309 +
 wsd/UserMessages.hpp                                         |   21 
 wsd/lint-discovery.py                                        |  246 +
 wsd/protocol.txt                                             |  572 ++
 wsd/reference.txt                                            |    7 
 290 files changed, 29831 insertions(+), 29707 deletions(-)

New commits:
commit 0f2e5ef3fe8d52a2f58afc6d8ac19046df155202
Author: Andras Timar <andras.timar at collabora.com>
Date:   Fri Nov 25 12:58:13 2016 +0100

    loolwsd: add common/FileUtil.hpp to tarball

diff --git a/Makefile.am b/Makefile.am
index 3384a35..63908d6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -109,6 +109,7 @@ wsd_headers = wsd/Admin.hpp \
 
 shared_headers = common/Common.hpp \
                  common/IoUtil.hpp \
+                 common/FileUtil.hpp \
                  common/Log.hpp \
                  common/Protocol.hpp \
                  common/Session.hpp \
commit 3e98b1d139b4e0aa69123c9aeaedebff35511a1c
Author: Andras Timar <andras.timar at collabora.com>
Date:   Fri Nov 25 12:55:52 2016 +0100

    loolwsd: add common/SigUtil.hpp to tarball

diff --git a/Makefile.am b/Makefile.am
index d25ee75..3384a35 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -118,6 +118,7 @@ shared_headers = common/Common.hpp \
                  common/MessageQueue.hpp \
                  common/Png.hpp \
                  common/Rectangle.hpp \
+                 common/SigUtil.hpp \
                  common/security.h
 
 kit_headers = kit/ChildSession.hpp \
commit d0929fb2f6cfbdaf1cc2ca1df16518f186dceab2
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Nov 25 16:55:26 2016 +0530

    loleaflet: Popup keyboard on mobile devices
    
    Change-Id: I4f0d1928633f5f0be4148fffd2c68c7aad1a0508

diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 40961cb..aaa04ac 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -894,6 +894,14 @@ L.Map = L.Evented.extend({
 			//type = e.type === 'keypress' && e.keyCode === 13 ? 'click' : e.type;
 		    type = e.type;
 
+		// For touch devices, to pop-up the keyboard, it is required to call
+		// .focus() method on hidden input within actual 'click' event here
+		// Calling from some other place with no real 'click' event doesn't work
+		if (type === 'click') {
+			this._textArea.blur();
+			this._textArea.focus();
+		}
+
 		// we need to keep track if we have entered/left the map
 		this._mouseEnteringLeaving = false;
 		// mouse leaving the map ?
commit 3402546faee83006c30a546373f57a0c02baf812
Author: Andras Timar <andras.timar at collabora.com>
Date:   Fri Nov 25 12:21:30 2016 +0100

    adapt maketarballfordeb.sh script to new dir layout

diff --git a/maketarballfordeb.sh.in b/maketarballfordeb.sh.in
old mode 100755
new mode 100644
index 3000455..5fead3a
--- a/maketarballfordeb.sh.in
+++ b/maketarballfordeb.sh.in
@@ -7,7 +7,7 @@ tar xzf $SRCDIR/loolwsd- at PACKAGE_VERSION@.tar.gz
 cp -a $SRCDIR/debian loolwsd- at PACKAGE_VERSION@
 mkdir loolwsd- at PACKAGE_VERSION@/loleaflet
 cd loolwsd- at PACKAGE_VERSION@/loleaflet
-tar xzf $SRCDIR/../loleaflet/loleaflet- at PACKAGE_VERSION@.tar.gz --strip-components=1
+tar xzf $SRCDIR/loleaflet/loleaflet- at PACKAGE_VERSION@.tar.gz --strip-components=1
 cd $TEMPDIR
 tar czf $SRCDIR/loolwsd_ at PACKAGE_VERSION@.orig.tar.gz loolwsd- at PACKAGE_VERSION@
 cd $SRCDIR
commit bbe0723e7883e6ec559bbb0dda012744ccce31e6
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Nov 24 19:32:51 2016 +0000

    Tweak code to use new paths.

diff --git a/loolwsd.xml.in b/loolwsd.xml.in
index 50527f8..c3a550b 100644
--- a/loolwsd.xml.in
+++ b/loolwsd.xml.in
@@ -9,7 +9,7 @@
     <child_root_path desc="Path to the directory under which the chroot jails for the child processes will be created. Should be on the same file system as systemplate and lotemplate. Must be an empty directory." type="path" relative="true" default="jails"></child_root_path>
 
     <server_name desc="Hostname:port of the server running loolwsd. If empty, it's derived from the request." type="string" default=""></server_name>
-    <file_server_root_path desc="Path to the directory that should be considered root for the file server. This should be the directory containing loleaflet." type="path" relative="true" default="../loleaflet/../"></file_server_root_path>
+    <file_server_root_path desc="Path to the directory that should be considered root for the file server. This should be the directory containing loleaflet." type="path" relative="true" default="loleaflet/../"></file_server_root_path>
 
     <num_prespawn_children desc="Number of child processes to keep started in advance and waiting for new clients." type="uint" default="1">1</num_prespawn_children>
     <per_document desc="Document-specific settings, including LO Core settings.">
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index b03d59f..64eabf0 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1489,7 +1489,7 @@ void LOOLWSD::initialize(Application& self)
             { "child_root_path", "jails" },
             { "lo_jail_subpath", "lo" },
             { "server_name", "" },
-            { "file_server_root_path", "../loleaflet/../" },
+            { "file_server_root_path", "loleaflet/.." },
             { "num_prespawn_children", "1" },
             { "per_document.max_concurrency", "4" },
             { "loleaflet_html", "loleaflet.html" },
@@ -1927,7 +1927,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
     FileUtil::registerFileSystemForDiskSpaceChecks(Cache + "/.");
 
     if (FileServerRoot.empty())
-        FileServerRoot = Poco::Path(Application::instance().commandPath()).parent().parent().toString();
+        FileServerRoot = Poco::Path(Application::instance().commandPath()).parent().toString();
     FileServerRoot = Poco::Path(FileServerRoot).absolute().toString();
     LOG_DBG("FileServerRoot: " << FileServerRoot);
 
commit c1a398977ffc10364bc37221e4b75c3996ca4cec
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Nov 24 14:56:06 2016 +0000

    Adapt makefiles, includes etc. to new locations.

diff --git a/Makefile.am b/Makefile.am
index 6df3998..d25ee75 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,109 +24,114 @@ endif
 
 ACLOCAL_AMFLAGS = -I m4
 
-AM_CPPFLAGS = -pthread -DLOOLWSD_DATADIR='"@LOOLWSD_DATADIR@"' -DLOOLWSD_CONFIGDIR='"@LOOLWSD_CONFIGDIR@"'
+# quick and easy for now.
+include_paths = -I${top_srcdir}/common -I${top_srcdir}/wsd -I${top_srcdir}/kit
+
+AM_CPPFLAGS = -pthread -DLOOLWSD_DATADIR='"@LOOLWSD_DATADIR@"' -DLOOLWSD_CONFIGDIR='"@LOOLWSD_CONFIGDIR@"' ${include_paths}
 AM_LDFLAGS = -pthread -Wl,-E
 
 AM_ETAGSFLAGS = --c++-kinds=+p --fields=+iaS --extra=+q -R --totals=yes *
 AM_CTAGSFLAGS = $(AM_ETAGSFLAGS)
 
-shared_sources = ChildSession.cpp \
-                 common/FileUtil.cpp \
+shared_sources = common/FileUtil.cpp \
+                 common/IoUtil.cpp \
+                 common/Log.cpp \
+                 common/Protocol.cpp \
+                 common/Session.cpp \
+                 common/MessageQueue.cpp \
                  common/SigUtil.cpp \
-                 IoUtil.cpp \
-                 Log.cpp \
-                 LOOLProtocol.cpp \
-                 LOOLSession.cpp \
-                 MessageQueue.cpp \
-                 Unit.cpp \
-                 UnitHTTP.cpp \
-                 Util.cpp
-
-loolwsd_SOURCES = Admin.cpp \
-                  AdminModel.cpp \
-                  Auth.cpp \
-                  DocumentBroker.cpp \
-                  LOOLWSD.cpp \
-                  ClientSession.cpp \
-                  FileServer.cpp \
-                  PrisonerSession.cpp \
-                  Storage.cpp \
-                  TileCache.cpp \
+                 common/Unit.cpp \
+                 common/UnitHTTP.cpp \
+                 common/Util.cpp
+
+loolwsd_SOURCES = wsd/Admin.cpp \
+                  wsd/AdminModel.cpp \
+                  wsd/Auth.cpp \
+                  wsd/DocumentBroker.cpp \
+                  wsd/LOOLWSD.cpp \
+                  wsd/ClientSession.cpp \
+                  wsd/FileServer.cpp \
+                  wsd/PrisonerSession.cpp \
+                  wsd/Storage.cpp \
+                  wsd/TileCache.cpp \
                   $(shared_sources)
 
 noinst_PROGRAMS = connect \
                   lokitclient \
                   loolforkit-nocaps
 
-connect_SOURCES = Connect.cpp \
-                  Log.cpp \
-                  LOOLProtocol.cpp \
-                  Util.cpp
+connect_SOURCES = tools/Connect.cpp \
+                  common/Log.cpp \
+                  common/Protocol.cpp \
+                  common/Util.cpp
 
-lokitclient_SOURCES = IoUtil.cpp \
-                      Log.cpp \
-                      LOKitClient.cpp \
-                      LOOLProtocol.cpp \
-                      Util.cpp
+lokitclient_SOURCES = common/IoUtil.cpp \
+                      common/Log.cpp \
+                      tools/KitClient.cpp \
+                      common/Protocol.cpp \
+                      common/Util.cpp
 
-loolforkit_SOURCES = LOOLForKit.cpp \
-                     LOOLKit.cpp \
+loolforkit_SOURCES = kit/ChildSession.cpp \
+                     kit/ForKit.cpp \
+                     kit/Kit.cpp \
                      $(shared_sources)
 
 # build a binary with no caps to help debugging
 loolforkit_nocaps_SOURCES = $(loolforkit_SOURCES)
 
-loolmount_SOURCES = loolmount.c
-
-loolmap_SOURCES = loolmap.c
-
-looltool_SOURCES = LOOLTool.cpp
-
-loolstress_CPPFLAGS = -DTDOC=\"$(abs_top_srcdir)/test/data\"
-loolstress_SOURCES = LOOLStress.cpp \
-                     LOOLProtocol.cpp \
-                     Log.cpp
-
-noinst_HEADERS = Admin.hpp \
-                 AdminModel.hpp \
-                 Auth.hpp \
-                 ChildSession.hpp \
-                 Common.hpp \
-                 DocumentBroker.hpp \
-                 Exceptions.hpp \
-                 FileServer.hpp \
-                 common/FileUtil.hpp \
-                 common/SigUtil.hpp \
-                 IoUtil.hpp \
-                 Log.hpp \
-                 LOKitHelper.hpp \
-                 LOOLKit.hpp \
-                 LOOLProtocol.hpp \
-                 LOOLSession.hpp \
-                 LOOLWebSocket.hpp \
-                 LOOLWSD.hpp \
-                 ClientSession.hpp \
-                 PrisonerSession.hpp \
-                 MessageQueue.hpp \
-                 Png.hpp \
-                 QueueHandler.hpp \
-                 Rectangle.hpp \
-                 Storage.hpp \
-                 TileCache.hpp \
-                 TileDesc.hpp \
-                 TraceFile.hpp \
-                 Unit.hpp \
-                 UnitHTTP.hpp \
-                 UserMessages.hpp \
-                 Util.hpp \
+loolmount_SOURCES = tools/mount.cpp
+
+loolmap_SOURCES = tools/map.cpp
+
+looltool_SOURCES = tools/Tool.cpp
+
+loolstress_CPPFLAGS = -DTDOC=\"$(abs_top_srcdir)/test/data\" ${include_paths}
+loolstress_SOURCES = tools/Stress.cpp \
+                     common/Protocol.cpp \
+                     common/Log.cpp
+
+wsd_headers = wsd/Admin.hpp \
+              wsd/AdminModel.hpp \
+              wsd/Auth.hpp \
+              wsd/ClientSession.hpp \
+              wsd/DocumentBroker.hpp \
+              wsd/Exceptions.hpp \
+              wsd/FileServer.hpp \
+              wsd/LOOLWebSocket.hpp \
+              wsd/LOOLWSD.hpp \
+              wsd/PrisonerSession.hpp \
+              wsd/QueueHandler.hpp \
+              wsd/Storage.hpp \
+              wsd/TileCache.hpp \
+              wsd/TileDesc.hpp \
+              wsd/TraceFile.hpp \
+              wsd/UserMessages.hpp
+
+shared_headers = common/Common.hpp \
+                 common/IoUtil.hpp \
+                 common/Log.hpp \
+                 common/Protocol.hpp \
+                 common/Session.hpp \
+                 common/Unit.hpp \
+                 common/UnitHTTP.hpp \
+                 common/Util.hpp \
+                 common/MessageQueue.hpp \
+                 common/Png.hpp \
+                 common/Rectangle.hpp \
+                 common/security.h
+
+kit_headers = kit/ChildSession.hpp \
+              kit/Kit.hpp \
+	      kit/KitHelper.hpp
+
+noinst_HEADERS = $(wsd_headers) $(shared_headers) $(kit_headers) \
                  bundled/include/LibreOfficeKit/LibreOfficeKit.h \
                  bundled/include/LibreOfficeKit/LibreOfficeKit.hxx \
                  bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h \
                  bundled/include/LibreOfficeKit/LibreOfficeKitInit.h \
                  bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h \
                  test/countloolkits.hpp \
-                 test/helpers.hpp \
-                 security.h
+                 test/helpers.hpp
 
 EXTRA_DIST = discovery.xml \
              favicon.ico \
diff --git a/README b/README
index dd0ae68..9a7f327 100644
--- a/README
+++ b/README
@@ -1,16 +1,22 @@
 LibreOffice on-line.
 
-This project fundamentally has two pieces:
+This project has several components:
 
-loolwsd/
-	The server side component.
+wsd/
+	The Web Services Daemon - which accepts external connections.
+
+kit/
+	The client which lives in its own chroot and renders documents.
+
+common/
+	Shared code between these processes.
 
 loleaflet/
-	The client side component.
+	The client side JavaScript component.
 
-First compile loolwsd, and then loleaflet.
+It is recommended to read these files:
 
-Since you need both of these to get things working, it is recommended
-to read the READMEs in both projects.
+	wsd/README
+	loleaflet/README
 
 Enjoy.
diff --git a/common/IoUtil.cpp b/common/IoUtil.cpp
index 035dcf8..6ae507c 100644
--- a/common/IoUtil.cpp
+++ b/common/IoUtil.cpp
@@ -27,7 +27,7 @@
 #include <Poco/URI.h>
 
 #include "Common.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include <LOOLWebSocket.hpp>
 #include "Log.hpp"
 #include "Util.hpp"
diff --git a/common/MessageQueue.cpp b/common/MessageQueue.cpp
index db9d223..b32fdeb 100644
--- a/common/MessageQueue.cpp
+++ b/common/MessageQueue.cpp
@@ -13,7 +13,7 @@
 
 #include <Poco/StringTokenizer.h>
 
-#include <LOOLProtocol.hpp>
+#include <Protocol.hpp>
 #include <Log.hpp>
 #include <TileDesc.hpp>
 
diff --git a/common/Protocol.cpp b/common/Protocol.cpp
index 30f75c6..6cd5455 100644
--- a/common/Protocol.cpp
+++ b/common/Protocol.cpp
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include "config.h"
 
 #include <cassert>
diff --git a/common/Session.cpp b/common/Session.cpp
index c503af7..36bf79c 100644
--- a/common/Session.cpp
+++ b/common/Session.cpp
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include "LOOLSession.hpp"
+#include "Session.hpp"
 #include "config.h"
 
 #include <sys/stat.h>
@@ -34,7 +34,7 @@
 
 #include "Common.hpp"
 #include "IoUtil.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include <LOOLWebSocket.hpp>
 #include "Log.hpp"
 #include "TileCache.hpp"
diff --git a/common/Session.hpp b/common/Session.hpp
index 736e63d..9873aad 100644
--- a/common/Session.hpp
+++ b/common/Session.hpp
@@ -22,7 +22,7 @@
 #include <Poco/StringTokenizer.h>
 #include <Poco/Types.h>
 
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include <LOOLWebSocket.hpp>
 #include "Log.hpp"
 #include "MessageQueue.hpp"
diff --git a/configure.ac b/configure.ac
index 9b6fc3d..7aa8775 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,7 @@ AC_SUBST([LOOLWSD_VERSION_HASH])
 
 AC_DEFINE_UNQUOTED([LOOLWSD_VERSION_HASH],[["$LOOLWSD_VERSION_HASH"]],[LibreOffice On-Line git hash if present])
 
-AC_CONFIG_SRCDIR([LOOLWSD.cpp])
+AC_CONFIG_SRCDIR([wsd/LOOLWSD.cpp])
 
 AC_CONFIG_HEADERS([config.h])
 
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 07b3a4c..5e364ae 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -19,7 +19,7 @@
 #include <Poco/URI.h>
 
 #include "common/FileUtil.hpp"
-#include "LOKitHelper.hpp"
+#include "KitHelper.hpp"
 #include "Log.hpp"
 #include "Png.hpp"
 #include "Util.hpp"
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp
index 871de23..665e09f 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -19,8 +19,8 @@
 #include <Poco/Thread.h>
 
 #include "Common.hpp"
-#include "LOOLKit.hpp"
-#include "LOOLSession.hpp"
+#include "Kit.hpp"
+#include "Session.hpp"
 
 class ChildSession;
 
diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp
index ab3d2c3..4680c4d 100644
--- a/kit/ForKit.cpp
+++ b/kit/ForKit.cpp
@@ -33,7 +33,7 @@
 
 #include "Common.hpp"
 #include "IoUtil.hpp"
-#include "LOOLKit.hpp"
+#include "Kit.hpp"
 #include "Log.hpp"
 #include "Unit.hpp"
 #include "Util.hpp"
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 7407384..255e473 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -52,9 +52,9 @@
 #include "ChildSession.hpp"
 #include "Common.hpp"
 #include "IoUtil.hpp"
-#include "LOKitHelper.hpp"
-#include "LOOLKit.hpp"
-#include "LOOLProtocol.hpp"
+#include "KitHelper.hpp"
+#include "Kit.hpp"
+#include "Protocol.hpp"
 #include "LOOLWebSocket.hpp"
 #include "Log.hpp"
 #include "Png.hpp"
diff --git a/test/Makefile.am b/test/Makefile.am
index fec8969..e18d3db 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -9,7 +9,8 @@ check_PROGRAMS = test
 
 noinst_PROGRAMS = test unittest
 
-AM_CXXFLAGS = $(CPPUNIT_CFLAGS) -DTDOC=\"$(top_srcdir)/test/data\"
+AM_CXXFLAGS = $(CPPUNIT_CFLAGS) -DTDOC=\"$(top_srcdir)/test/data\" \
+	-I${top_srcdir}/common -I${top_srcdir}/wsd -I${top_srcdir}/kit
 
 noinst_LTLIBRARIES = \
         unit-timeout.la unit-prefork.la \
@@ -29,15 +30,15 @@ AM_CPPFLAGS = -pthread -I$(top_srcdir) -DBUILDING_TESTS
 wsd_sources = \
             ../common/FileUtil.cpp \
             ../common/SigUtil.cpp \
-            ../IoUtil.cpp \
-            ../Log.cpp \
-            ../LOOLKit.cpp \
-            ../LOOLProtocol.cpp \
-            ../LOOLSession.cpp \
-            ../TileCache.cpp \
-            ../MessageQueue.cpp \
-            ../Unit.cpp \
-            ../Util.cpp
+            ../common/IoUtil.cpp \
+            ../common/Log.cpp \
+            ../common/Protocol.cpp \
+            ../common/Session.cpp \
+	    ../common/MessageQueue.cpp \
+            ../kit/Kit.cpp \
+            ../wsd/TileCache.cpp \
+            ../common/Unit.cpp \
+            ../common/Util.cpp
 
 test_CPPFLAGS = -I$(top_srcdir) -DBUILDING_TESTS
 test_SOURCES = TileCacheTests.cpp integration-http-server.cpp \
diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp
index e391526..64780a6 100644
--- a/test/TileCacheTests.cpp
+++ b/test/TileCacheTests.cpp
@@ -12,7 +12,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include "Common.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include <LOOLWebSocket.hpp>
 #include "MessageQueue.hpp"
 #include "Png.hpp"
diff --git a/test/TileQueueTests.cpp b/test/TileQueueTests.cpp
index 964df48..dea692b 100644
--- a/test/TileQueueTests.cpp
+++ b/test/TileQueueTests.cpp
@@ -12,7 +12,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include "Common.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include "MessageQueue.hpp"
 #include "Util.hpp"
 
diff --git a/test/UnitFonts.cpp b/test/UnitFonts.cpp
index 60312d4..265d5b2 100644
--- a/test/UnitFonts.cpp
+++ b/test/UnitFonts.cpp
@@ -20,7 +20,7 @@
 #include <Poco/Timestamp.h>
 
 #include "Common.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include "Log.hpp"
 #include "Unit.hpp"
 #include "Util.hpp"
diff --git a/test/UnitFuzz.cpp b/test/UnitFuzz.cpp
index 7454aa4..fba1d73 100644
--- a/test/UnitFuzz.cpp
+++ b/test/UnitFuzz.cpp
@@ -16,7 +16,7 @@
 
 #include "Common.hpp"
 #include "IoUtil.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include <LOOLWebSocket.hpp>
 #include "Unit.hpp"
 #include "Util.hpp"
diff --git a/test/UnitPrefork.cpp b/test/UnitPrefork.cpp
index 9f5463b..93d4adb 100644
--- a/test/UnitPrefork.cpp
+++ b/test/UnitPrefork.cpp
@@ -24,7 +24,7 @@
 
 #include "Common.hpp"
 #include "IoUtil.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include <LOOLWebSocket.hpp>
 #include "Log.hpp"
 #include "Unit.hpp"
diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp
index 2224619..6ca75bc 100644
--- a/test/WhiteBoxTests.cpp
+++ b/test/WhiteBoxTests.cpp
@@ -13,8 +13,8 @@
 
 #include <ChildSession.hpp>
 #include <Common.hpp>
-#include <LOOLKit.hpp>
-#include <LOOLProtocol.hpp>
+#include <Kit.hpp>
+#include <Protocol.hpp>
 #include <MessageQueue.hpp>
 #include <Util.hpp>
 
diff --git a/test/helpers.hpp b/test/helpers.hpp
index 30aeac1..a10cc53 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -41,7 +41,7 @@
 
 #include <Common.hpp>
 #include "common/FileUtil.hpp"
-#include <LOOLProtocol.hpp>
+#include <Protocol.hpp>
 #include <LOOLWebSocket.hpp>
 #include <UserMessages.hpp>
 #include <Util.hpp>
diff --git a/test/httpcrashtest.cpp b/test/httpcrashtest.cpp
index 1bfd4f2..a4a4ff3 100644
--- a/test/httpcrashtest.cpp
+++ b/test/httpcrashtest.cpp
@@ -40,7 +40,7 @@
 #include <Common.hpp>
 #include <UserMessages.hpp>
 #include <Util.hpp>
-#include <LOOLProtocol.hpp>
+#include <Protocol.hpp>
 #include <LOOLWebSocket.hpp>
 #include "helpers.hpp"
 #include "countloolkits.hpp"
diff --git a/test/httpwserror.cpp b/test/httpwserror.cpp
index 0bd8b65..67fd235 100644
--- a/test/httpwserror.cpp
+++ b/test/httpwserror.cpp
@@ -22,7 +22,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include "Common.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include <LOOLWebSocket.hpp>
 #include "helpers.hpp"
 #include "countloolkits.hpp"
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index 1e65fc2..d180820 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -40,7 +40,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include "Common.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include <LOOLWebSocket.hpp>
 #include "Png.hpp"
 #include "UserMessages.hpp"
diff --git a/tools/Connect.cpp b/tools/Connect.cpp
index 5b550dd..d45b243 100644
--- a/tools/Connect.cpp
+++ b/tools/Connect.cpp
@@ -41,7 +41,7 @@
 #include <Poco/Version.h>
 
 #include "Common.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include <LOOLWebSocket.hpp>
 #include "Log.hpp"
 #include "Util.hpp"
diff --git a/tools/KitClient.cpp b/tools/KitClient.cpp
index 06d0a33..a587a28 100644
--- a/tools/KitClient.cpp
+++ b/tools/KitClient.cpp
@@ -27,7 +27,7 @@
 #include <Poco/URI.h>
 #include <Poco/Util/Application.h>
 
-#include "LOKitHelper.hpp"
+#include "KitHelper.hpp"
 #include "Png.hpp"
 #include "Util.hpp"
 
diff --git a/tools/Tool.cpp b/tools/Tool.cpp
index b658108..437fe1d 100644
--- a/tools/Tool.cpp
+++ b/tools/Tool.cpp
@@ -40,7 +40,7 @@
 #include <Poco/Util/OptionSet.h>
 
 #include "Common.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include "Util.hpp"
 
 #include <Poco/Util/Application.h>
diff --git a/tools/map.c b/tools/map.cpp
similarity index 100%
rename from tools/map.c
rename to tools/map.cpp
diff --git a/tools/mount.c b/tools/mount.cpp
similarity index 100%
rename from tools/mount.c
rename to tools/mount.cpp
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index c9bd23b..09a561e 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -31,8 +31,8 @@
 #include "Common.hpp"
 #include "FileServer.hpp"
 #include "IoUtil.hpp"
-#include "LOOLProtocol.hpp"
-#include <LOOLWebSocket.hpp>
+#include "Protocol.hpp"
+#include "LOOLWebSocket.hpp"
 #include "LOOLWSD.hpp"
 #include "Log.hpp"
 #include "Storage.hpp"
diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp
index 6de25e4..1099a0d 100644
--- a/wsd/AdminModel.cpp
+++ b/wsd/AdminModel.cpp
@@ -19,7 +19,7 @@
 #include <Poco/StringTokenizer.h>
 #include <Poco/URI.h>
 
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include <LOOLWebSocket.hpp>
 #include "Log.hpp"
 #include "Unit.hpp"
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 00a0a3f..cedbc5e 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -20,8 +20,8 @@
 
 #include "Common.hpp"
 #include "IoUtil.hpp"
-#include "LOOLProtocol.hpp"
-#include "LOOLSession.hpp"
+#include "Protocol.hpp"
+#include "Session.hpp"
 #include "LOOLWSD.hpp"
 #include "Log.hpp"
 #include "PrisonerSession.hpp"
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index a8f2e51..bf484f4 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -10,7 +10,7 @@
 #ifndef INCLUDED_CLIENTSSESSION_HPP
 #define INCLUDED_CLIENTSSESSION_HPP
 
-#include "LOOLSession.hpp"
+#include "Session.hpp"
 #include "MessageQueue.hpp"
 
 #include <Poco/URI.h>
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index fcd4d7a..886cf98 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -22,7 +22,7 @@
 #include "Admin.hpp"
 #include "ClientSession.hpp"
 #include "Exceptions.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include "LOOLWSD.hpp"
 #include "Log.hpp"
 #include "PrisonerSession.hpp"
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 5ca3fce..b03d59f 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -101,8 +101,8 @@
 #include "FileServer.hpp"
 #include "common/FileUtil.hpp"
 #include "IoUtil.hpp"
-#include "LOOLProtocol.hpp"
-#include "LOOLSession.hpp"
+#include "Protocol.hpp"
+#include "Session.hpp"
 #include <LOOLWebSocket.hpp>
 #include "Log.hpp"
 #include "PrisonerSession.hpp"
diff --git a/wsd/LOOLWebSocket.hpp b/wsd/LOOLWebSocket.hpp
index e10af2a..e744cf7 100644
--- a/wsd/LOOLWebSocket.hpp
+++ b/wsd/LOOLWebSocket.hpp
@@ -17,7 +17,7 @@
 #include <Poco/Net/WebSocket.h>
 
 #include <Common.hpp>
-#include <LOOLProtocol.hpp>
+#include <Protocol.hpp>
 #include <Log.hpp>
 
 /// WebSocket that is thread safe, and handles large frames transparently.
diff --git a/wsd/PrisonerSession.cpp b/wsd/PrisonerSession.cpp
index 28e4ac6..faf8232 100644
--- a/wsd/PrisonerSession.cpp
+++ b/wsd/PrisonerSession.cpp
@@ -17,8 +17,8 @@
 #include <Poco/URIStreamOpener.h>
 
 #include "Common.hpp"
-#include "LOOLProtocol.hpp"
-#include "LOOLSession.hpp"
+#include "Protocol.hpp"
+#include "Session.hpp"
 #include "LOOLWSD.hpp"
 #include "Log.hpp"
 #include "ClientSession.hpp"
diff --git a/wsd/PrisonerSession.hpp b/wsd/PrisonerSession.hpp
index a52dfc8..1518ab4 100644
--- a/wsd/PrisonerSession.hpp
+++ b/wsd/PrisonerSession.hpp
@@ -10,7 +10,7 @@
 #ifndef INCLUDED_PRISONERSESSION_HPP
 #define INCLUDED_PRISONERSESSION_HPP
 
-#include "LOOLSession.hpp"
+#include "Session.hpp"
 
 class DocumentBroker;
 class ClientSession;
diff --git a/wsd/QueueHandler.hpp b/wsd/QueueHandler.hpp
index 3f330e6..445b91e 100644
--- a/wsd/QueueHandler.hpp
+++ b/wsd/QueueHandler.hpp
@@ -9,8 +9,8 @@
 
 #include <Poco/Runnable.h>
 
-#include "LOOLProtocol.hpp"
-#include "LOOLSession.hpp"
+#include "Protocol.hpp"
+#include "Session.hpp"
 #include "MessageQueue.hpp"
 #include "Util.hpp"
 
diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index 41d9bd0..0ce257f 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -33,7 +33,7 @@
 #include "ClientSession.hpp"
 #include "Common.hpp"
 #include "common/FileUtil.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 #include "Unit.hpp"
 #include "Util.hpp"
 
diff --git a/wsd/TileDesc.hpp b/wsd/TileDesc.hpp
index 85bc453..765341d 100644
--- a/wsd/TileDesc.hpp
+++ b/wsd/TileDesc.hpp
@@ -18,7 +18,7 @@
 #include <Poco/StringTokenizer.h>
 
 #include "Exceptions.hpp"
-#include "LOOLProtocol.hpp"
+#include "Protocol.hpp"
 
 /// Tile Descriptor
 /// Represents a tile's coordinates and dimensions.
commit cca657c8f2031ec88366c52f5e8e10c2e04129f9
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Nov 24 14:52:34 2016 +0000

    Apply the pre-branch rename script to re-organize the source.

diff --git a/loolwsd/.clang-tidy b/.clang-tidy
similarity index 100%
rename from loolwsd/.clang-tidy
rename to .clang-tidy
diff --git a/loolwsd/.gitignore b/.gitignore
similarity index 100%
rename from loolwsd/.gitignore
rename to .gitignore
diff --git a/loolwsd/AUTHORS b/AUTHORS
similarity index 100%
rename from loolwsd/AUTHORS
rename to AUTHORS
diff --git a/loolwsd/COPYING b/COPYING
similarity index 100%
rename from loolwsd/COPYING
rename to COPYING
diff --git a/loolwsd/ChangeLog b/ChangeLog
similarity index 100%
rename from loolwsd/ChangeLog
rename to ChangeLog
diff --git a/loolwsd/INSTALL b/INSTALL
similarity index 100%
rename from loolwsd/INSTALL
rename to INSTALL
diff --git a/loolwsd/Makefile.am b/Makefile.am
similarity index 100%
rename from loolwsd/Makefile.am
rename to Makefile.am
diff --git a/loolwsd/NEWS b/NEWS
similarity index 100%
rename from loolwsd/NEWS
rename to NEWS
diff --git a/loolwsd/PROBLEMS b/PROBLEMS
similarity index 100%
rename from loolwsd/PROBLEMS
rename to PROBLEMS
diff --git a/loolwsd/TODO b/TODO
similarity index 100%
rename from loolwsd/TODO
rename to TODO
diff --git a/loolwsd/autogen.sh b/autogen.sh
similarity index 100%
rename from loolwsd/autogen.sh
rename to autogen.sh
diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h b/bundled/include/LibreOfficeKit/LibreOfficeKit.h
similarity index 100%
rename from loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h
rename to bundled/include/LibreOfficeKit/LibreOfficeKit.h
diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx b/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
similarity index 100%
rename from loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
rename to bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
similarity index 100%
rename from loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
rename to bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitInit.h b/bundled/include/LibreOfficeKit/LibreOfficeKitInit.h
similarity index 100%
rename from loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitInit.h
rename to bundled/include/LibreOfficeKit/LibreOfficeKitInit.h
diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h b/bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h
similarity index 100%
rename from loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h
rename to bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h
diff --git a/loolwsd/Common.hpp b/common/Common.hpp
similarity index 100%
rename from loolwsd/Common.hpp
rename to common/Common.hpp
diff --git a/loolwsd/common/FileUtil.cpp b/common/FileUtil.cpp
similarity index 100%
rename from loolwsd/common/FileUtil.cpp
rename to common/FileUtil.cpp
diff --git a/loolwsd/common/FileUtil.hpp b/common/FileUtil.hpp
similarity index 100%
rename from loolwsd/common/FileUtil.hpp
rename to common/FileUtil.hpp
diff --git a/loolwsd/IoUtil.cpp b/common/IoUtil.cpp
similarity index 100%
rename from loolwsd/IoUtil.cpp
rename to common/IoUtil.cpp
diff --git a/loolwsd/IoUtil.hpp b/common/IoUtil.hpp
similarity index 100%
rename from loolwsd/IoUtil.hpp
rename to common/IoUtil.hpp
diff --git a/loolwsd/Log.cpp b/common/Log.cpp
similarity index 100%
rename from loolwsd/Log.cpp
rename to common/Log.cpp
diff --git a/loolwsd/Log.hpp b/common/Log.hpp
similarity index 100%
rename from loolwsd/Log.hpp
rename to common/Log.hpp
diff --git a/loolwsd/MessageQueue.cpp b/common/MessageQueue.cpp
similarity index 100%
rename from loolwsd/MessageQueue.cpp
rename to common/MessageQueue.cpp
diff --git a/loolwsd/MessageQueue.hpp b/common/MessageQueue.hpp
similarity index 100%
rename from loolwsd/MessageQueue.hpp
rename to common/MessageQueue.hpp
diff --git a/loolwsd/Png.hpp b/common/Png.hpp
similarity index 100%
rename from loolwsd/Png.hpp
rename to common/Png.hpp
diff --git a/loolwsd/LOOLProtocol.cpp b/common/Protocol.cpp
similarity index 100%
rename from loolwsd/LOOLProtocol.cpp
rename to common/Protocol.cpp
diff --git a/loolwsd/LOOLProtocol.hpp b/common/Protocol.hpp
similarity index 100%
rename from loolwsd/LOOLProtocol.hpp
rename to common/Protocol.hpp
diff --git a/loolwsd/Rectangle.hpp b/common/Rectangle.hpp
similarity index 100%
rename from loolwsd/Rectangle.hpp
rename to common/Rectangle.hpp
diff --git a/loolwsd/LOOLSession.cpp b/common/Session.cpp
similarity index 100%
rename from loolwsd/LOOLSession.cpp
rename to common/Session.cpp
diff --git a/loolwsd/LOOLSession.hpp b/common/Session.hpp
similarity index 100%
rename from loolwsd/LOOLSession.hpp
rename to common/Session.hpp
diff --git a/loolwsd/common/SigUtil.cpp b/common/SigUtil.cpp
similarity index 100%
rename from loolwsd/common/SigUtil.cpp
rename to common/SigUtil.cpp
diff --git a/loolwsd/common/SigUtil.hpp b/common/SigUtil.hpp
similarity index 100%
rename from loolwsd/common/SigUtil.hpp
rename to common/SigUtil.hpp
diff --git a/loolwsd/Unit.cpp b/common/Unit.cpp
similarity index 100%
rename from loolwsd/Unit.cpp
rename to common/Unit.cpp
diff --git a/loolwsd/Unit.hpp b/common/Unit.hpp
similarity index 100%
rename from loolwsd/Unit.hpp
rename to common/Unit.hpp
diff --git a/loolwsd/UnitHTTP.cpp b/common/UnitHTTP.cpp
similarity index 100%
rename from loolwsd/UnitHTTP.cpp
rename to common/UnitHTTP.cpp
diff --git a/loolwsd/UnitHTTP.hpp b/common/UnitHTTP.hpp
similarity index 100%
rename from loolwsd/UnitHTTP.hpp
rename to common/UnitHTTP.hpp
diff --git a/loolwsd/Util.cpp b/common/Util.cpp
similarity index 100%
rename from loolwsd/Util.cpp
rename to common/Util.cpp
diff --git a/loolwsd/Util.hpp b/common/Util.hpp
similarity index 100%
rename from loolwsd/Util.hpp
rename to common/Util.hpp
diff --git a/loolwsd/security.h b/common/security.h
similarity index 100%
rename from loolwsd/security.h
rename to common/security.h
diff --git a/loolwsd/configure.ac b/configure.ac
similarity index 100%
rename from loolwsd/configure.ac
rename to configure.ac
diff --git a/loolwsd/debian/changelog b/debian/changelog
similarity index 100%
rename from loolwsd/debian/changelog
rename to debian/changelog
diff --git a/loolwsd/debian/compat b/debian/compat
similarity index 100%
rename from loolwsd/debian/compat
rename to debian/compat
diff --git a/loolwsd/debian/control b/debian/control
similarity index 100%
rename from loolwsd/debian/control
rename to debian/control
diff --git a/loolwsd/debian/copyright b/debian/copyright
similarity index 100%
rename from loolwsd/debian/copyright
rename to debian/copyright
diff --git a/loolwsd/debian/loolwsd.cron.d b/debian/loolwsd.cron.d
similarity index 100%
rename from loolwsd/debian/loolwsd.cron.d
rename to debian/loolwsd.cron.d
diff --git a/loolwsd/debian/loolwsd.postinst b/debian/loolwsd.postinst
similarity index 100%
rename from loolwsd/debian/loolwsd.postinst
rename to debian/loolwsd.postinst
diff --git a/loolwsd/debian/loolwsd.preinst b/debian/loolwsd.preinst
similarity index 100%
rename from loolwsd/debian/loolwsd.preinst
rename to debian/loolwsd.preinst
diff --git a/loolwsd/debian/rules b/debian/rules
similarity index 100%
rename from loolwsd/debian/rules
rename to debian/rules
diff --git a/loolwsd/debian/source/format b/debian/source/format
similarity index 100%
rename from loolwsd/debian/source/format
rename to debian/source/format
diff --git a/loolwsd/discovery.xml b/discovery.xml
similarity index 100%
rename from loolwsd/discovery.xml
rename to discovery.xml
diff --git a/loolwsd/etc/ca-chain.cert.pem b/etc/ca-chain.cert.pem
similarity index 100%
rename from loolwsd/etc/ca-chain.cert.pem
rename to etc/ca-chain.cert.pem
diff --git a/loolwsd/etc/cert.pem b/etc/cert.pem
similarity index 100%
rename from loolwsd/etc/cert.pem
rename to etc/cert.pem
diff --git a/loolwsd/etc/key.pem b/etc/key.pem
similarity index 100%
rename from loolwsd/etc/key.pem
rename to etc/key.pem
diff --git a/loolwsd/favicon.ico b/favicon.ico
similarity index 100%
rename from loolwsd/favicon.ico
rename to favicon.ico
diff --git a/loolwsd/ChildSession.cpp b/kit/ChildSession.cpp
similarity index 100%
rename from loolwsd/ChildSession.cpp
rename to kit/ChildSession.cpp
diff --git a/loolwsd/ChildSession.hpp b/kit/ChildSession.hpp
similarity index 100%
rename from loolwsd/ChildSession.hpp
rename to kit/ChildSession.hpp
diff --git a/loolwsd/LOOLForKit.cpp b/kit/ForKit.cpp
similarity index 100%
rename from loolwsd/LOOLForKit.cpp
rename to kit/ForKit.cpp
diff --git a/loolwsd/LOOLKit.cpp b/kit/Kit.cpp
similarity index 100%
rename from loolwsd/LOOLKit.cpp
rename to kit/Kit.cpp
diff --git a/loolwsd/LOOLKit.hpp b/kit/Kit.hpp
similarity index 100%
rename from loolwsd/LOOLKit.hpp
rename to kit/Kit.hpp
diff --git a/loolwsd/LOKitHelper.hpp b/kit/KitHelper.hpp
similarity index 100%
rename from loolwsd/LOKitHelper.hpp
rename to kit/KitHelper.hpp
diff --git a/loolwsd/loolstat b/loolstat
similarity index 100%
rename from loolwsd/loolstat
rename to loolstat
diff --git a/loolwsd/loolwsd-systemplate-setup b/loolwsd-systemplate-setup
similarity index 100%
rename from loolwsd/loolwsd-systemplate-setup
rename to loolwsd-systemplate-setup
diff --git a/loolwsd/loolwsd.service b/loolwsd.service
similarity index 100%
rename from loolwsd/loolwsd.service
rename to loolwsd.service
diff --git a/loolwsd/loolwsd.spec.in b/loolwsd.spec.in
similarity index 100%
rename from loolwsd/loolwsd.spec.in
rename to loolwsd.spec.in
diff --git a/loolwsd/loolwsd.xml.in b/loolwsd.xml.in
similarity index 100%
rename from loolwsd/loolwsd.xml.in
rename to loolwsd.xml.in
diff --git a/loolwsd/maketarballfordeb.sh.in b/maketarballfordeb.sh.in
similarity index 100%
rename from loolwsd/maketarballfordeb.sh.in
rename to maketarballfordeb.sh.in
diff --git a/rename.sh b/rename.sh
index 03de7f6..2c5c8f1 100755
--- a/rename.sh
+++ b/rename.sh
@@ -33,7 +33,6 @@ git mv wsd/LOOLSession.cpp common/Session.cpp
 git mv wsd/LOOLSession.hpp common/Session.hpp
 git mv wsd/security.h common/security.h
 
-git mv wsd/LibreOfficeKit.hpp kit
 git mv wsd/ChildSession.cpp kit
 git mv wsd/ChildSession.hpp kit
 git mv wsd/LOOLForKit.cpp kit/ForKit.cpp
diff --git a/loolwsd/robots.txt b/robots.txt
similarity index 100%
rename from loolwsd/robots.txt
rename to robots.txt
diff --git a/loolwsd/sysconfig.loolwsd b/sysconfig.loolwsd
similarity index 100%
rename from loolwsd/sysconfig.loolwsd
rename to sysconfig.loolwsd
diff --git a/loolwsd/test/.gitignore b/test/.gitignore
similarity index 100%
rename from loolwsd/test/.gitignore
rename to test/.gitignore
diff --git a/loolwsd/test/Makefile.am b/test/Makefile.am
similarity index 100%
rename from loolwsd/test/Makefile.am
rename to test/Makefile.am
diff --git a/loolwsd/test/TileCacheTests.cpp b/test/TileCacheTests.cpp
similarity index 100%
rename from loolwsd/test/TileCacheTests.cpp
rename to test/TileCacheTests.cpp
diff --git a/loolwsd/test/TileQueueTests.cpp b/test/TileQueueTests.cpp
similarity index 100%
rename from loolwsd/test/TileQueueTests.cpp
rename to test/TileQueueTests.cpp
diff --git a/loolwsd/test/UnitAdmin.cpp b/test/UnitAdmin.cpp
similarity index 100%
rename from loolwsd/test/UnitAdmin.cpp
rename to test/UnitAdmin.cpp
diff --git a/loolwsd/test/UnitFonts.cpp b/test/UnitFonts.cpp
similarity index 100%
rename from loolwsd/test/UnitFonts.cpp
rename to test/UnitFonts.cpp
diff --git a/loolwsd/test/UnitFuzz.cpp b/test/UnitFuzz.cpp
similarity index 100%
rename from loolwsd/test/UnitFuzz.cpp
rename to test/UnitFuzz.cpp
diff --git a/loolwsd/test/UnitPrefork.cpp b/test/UnitPrefork.cpp
similarity index 100%
rename from loolwsd/test/UnitPrefork.cpp
rename to test/UnitPrefork.cpp
diff --git a/loolwsd/test/UnitRequests.cpp b/test/UnitRequests.cpp
similarity index 100%
rename from loolwsd/test/UnitRequests.cpp
rename to test/UnitRequests.cpp
diff --git a/loolwsd/test/UnitStorage.cpp b/test/UnitStorage.cpp
similarity index 100%
rename from loolwsd/test/UnitStorage.cpp
rename to test/UnitStorage.cpp
diff --git a/loolwsd/test/UnitTileCache.cpp b/test/UnitTileCache.cpp
similarity index 100%
rename from loolwsd/test/UnitTileCache.cpp
rename to test/UnitTileCache.cpp
diff --git a/loolwsd/test/UnitTimeout.cpp b/test/UnitTimeout.cpp
similarity index 100%
rename from loolwsd/test/UnitTimeout.cpp
rename to test/UnitTimeout.cpp
diff --git a/loolwsd/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp
similarity index 100%
rename from loolwsd/test/WhiteBoxTests.cpp
rename to test/WhiteBoxTests.cpp
diff --git a/loolwsd/test/countloolkits.hpp b/test/countloolkits.hpp
similarity index 100%
rename from loolwsd/test/countloolkits.hpp
rename to test/countloolkits.hpp
diff --git a/loolwsd/test/data/Example.odt b/test/data/Example.odt
similarity index 100%
rename from loolwsd/test/data/Example.odt
rename to test/data/Example.odt
diff --git a/loolwsd/test/data/calc_render.xls b/test/data/calc_render.xls
similarity index 100%
rename from loolwsd/test/data/calc_render.xls
rename to test/data/calc_render.xls
diff --git a/loolwsd/test/data/calc_render_0_512x512.3840,0.7680x7680.png b/test/data/calc_render_0_512x512.3840,0.7680x7680.png
similarity index 100%
rename from loolwsd/test/data/calc_render_0_512x512.3840,0.7680x7680.png
rename to test/data/calc_render_0_512x512.3840,0.7680x7680.png
diff --git a/loolwsd/test/data/empty.odg b/test/data/empty.odg
similarity index 100%
rename from loolwsd/test/data/empty.odg
rename to test/data/empty.odg
diff --git a/loolwsd/test/data/empty.odp b/test/data/empty.odp
similarity index 100%
rename from loolwsd/test/data/empty.odp
rename to test/data/empty.odp
diff --git a/loolwsd/test/data/empty.ods b/test/data/empty.ods
similarity index 100%
rename from loolwsd/test/data/empty.ods
rename to test/data/empty.ods
diff --git a/loolwsd/test/data/empty.odt b/test/data/empty.odt
similarity index 100%
rename from loolwsd/test/data/empty.odt
rename to test/data/empty.odt
diff --git a/loolwsd/test/data/graphicviewselection.odp b/test/data/graphicviewselection.odp
similarity index 100%
rename from loolwsd/test/data/graphicviewselection.odp
rename to test/data/graphicviewselection.odp
diff --git a/loolwsd/test/data/graphicviewselection.ods b/test/data/graphicviewselection.ods
similarity index 100%
rename from loolwsd/test/data/graphicviewselection.ods
rename to test/data/graphicviewselection.ods
diff --git a/loolwsd/test/data/graphicviewselection.odt b/test/data/graphicviewselection.odt
similarity index 100%
rename from loolwsd/test/data/graphicviewselection.odt
rename to test/data/graphicviewselection.odt
diff --git a/loolwsd/test/data/hello.odt b/test/data/hello.odt
similarity index 100%
rename from loolwsd/test/data/hello.odt
rename to test/data/hello.odt
diff --git a/loolwsd/test/data/hello.txt b/test/data/hello.txt
similarity index 100%
rename from loolwsd/test/data/hello.txt
rename to test/data/hello.txt
diff --git a/loolwsd/test/data/hide-whitespace.odt b/test/data/hide-whitespace.odt
similarity index 100%
rename from loolwsd/test/data/hide-whitespace.odt
rename to test/data/hide-whitespace.odt
diff --git a/loolwsd/test/data/insert-delete.odp b/test/data/insert-delete.odp
similarity index 100%
rename from loolwsd/test/data/insert-delete.odp
rename to test/data/insert-delete.odp
diff --git a/loolwsd/test/data/load12.ods b/test/data/load12.ods
similarity index 100%
rename from loolwsd/test/data/load12.ods
rename to test/data/load12.ods
diff --git a/loolwsd/test/data/password-protected.ods b/test/data/password-protected.ods
similarity index 100%
rename from loolwsd/test/data/password-protected.ods
rename to test/data/password-protected.ods
diff --git a/loolwsd/test/data/paste.html b/test/data/paste.html
similarity index 100%
rename from loolwsd/test/data/paste.html
rename to test/data/paste.html
diff --git a/loolwsd/test/data/setclientpart.odp b/test/data/setclientpart.odp
similarity index 100%
rename from loolwsd/test/data/setclientpart.odp
rename to test/data/setclientpart.odp
diff --git a/loolwsd/test/data/setclientpart.ods b/test/data/setclientpart.ods
similarity index 100%
rename from loolwsd/test/data/setclientpart.ods
rename to test/data/setclientpart.ods
diff --git a/loolwsd/test/data/shape.ods b/test/data/shape.ods
similarity index 100%
rename from loolwsd/test/data/shape.ods
rename to test/data/shape.ods
diff --git a/loolwsd/test/data/timeline.xlsx b/test/data/timeline.xlsx
similarity index 100%
rename from loolwsd/test/data/timeline.xlsx
rename to test/data/timeline.xlsx
diff --git a/loolwsd/test/data/viewcursor.odp b/test/data/viewcursor.odp
similarity index 100%
rename from loolwsd/test/data/viewcursor.odp
rename to test/data/viewcursor.odp
diff --git a/loolwsd/test/data/with_comment.odt b/test/data/with_comment.odt
similarity index 100%
rename from loolwsd/test/data/with_comment.odt
rename to test/data/with_comment.odt
diff --git a/loolwsd/test/helpers.hpp b/test/helpers.hpp
similarity index 100%
rename from loolwsd/test/helpers.hpp
rename to test/helpers.hpp
diff --git a/loolwsd/test/httpcrashtest.cpp b/test/httpcrashtest.cpp
similarity index 100%
rename from loolwsd/test/httpcrashtest.cpp
rename to test/httpcrashtest.cpp
diff --git a/loolwsd/test/httpwserror.cpp b/test/httpwserror.cpp
similarity index 100%
rename from loolwsd/test/httpwserror.cpp
rename to test/httpwserror.cpp
diff --git a/loolwsd/test/httpwstest.cpp b/test/httpwstest.cpp
similarity index 100%
rename from loolwsd/test/httpwstest.cpp
rename to test/httpwstest.cpp
diff --git a/loolwsd/test/integration-http-server.cpp b/test/integration-http-server.cpp
similarity index 100%
rename from loolwsd/test/integration-http-server.cpp
rename to test/integration-http-server.cpp
diff --git a/loolwsd/test/run_unit.sh.in b/test/run_unit.sh.in
similarity index 100%
rename from loolwsd/test/run_unit.sh.in
rename to test/run_unit.sh.in
diff --git a/loolwsd/test/test.cpp b/test/test.cpp
similarity index 100%
rename from loolwsd/test/test.cpp
rename to test/test.cpp
diff --git a/loolwsd/Connect.cpp b/tools/Connect.cpp
similarity index 100%
rename from loolwsd/Connect.cpp
rename to tools/Connect.cpp
diff --git a/loolwsd/LOKitClient.cpp b/tools/KitClient.cpp
similarity index 100%
rename from loolwsd/LOKitClient.cpp
rename to tools/KitClient.cpp
diff --git a/loolwsd/LOOLStress.cpp b/tools/Stress.cpp
similarity index 100%
rename from loolwsd/LOOLStress.cpp
rename to tools/Stress.cpp
diff --git a/loolwsd/LOOLTool.cpp b/tools/Tool.cpp
similarity index 100%
rename from loolwsd/LOOLTool.cpp
rename to tools/Tool.cpp
diff --git a/loolwsd/loolmap.c b/tools/map.c
similarity index 100%
rename from loolwsd/loolmap.c
rename to tools/map.c
diff --git a/loolwsd/loolmount.c b/tools/mount.c
similarity index 100%
rename from loolwsd/loolmount.c
rename to tools/mount.c
diff --git a/loolwsd/Admin.cpp b/wsd/Admin.cpp
similarity index 100%
rename from loolwsd/Admin.cpp
rename to wsd/Admin.cpp
diff --git a/loolwsd/Admin.hpp b/wsd/Admin.hpp
similarity index 100%
rename from loolwsd/Admin.hpp
rename to wsd/Admin.hpp
diff --git a/loolwsd/AdminModel.cpp b/wsd/AdminModel.cpp
similarity index 100%
rename from loolwsd/AdminModel.cpp
rename to wsd/AdminModel.cpp
diff --git a/loolwsd/AdminModel.hpp b/wsd/AdminModel.hpp
similarity index 100%
rename from loolwsd/AdminModel.hpp
rename to wsd/AdminModel.hpp
diff --git a/loolwsd/Auth.cpp b/wsd/Auth.cpp
similarity index 100%
rename from loolwsd/Auth.cpp
rename to wsd/Auth.cpp
diff --git a/loolwsd/Auth.hpp b/wsd/Auth.hpp
similarity index 100%
rename from loolwsd/Auth.hpp
rename to wsd/Auth.hpp
diff --git a/loolwsd/ClientSession.cpp b/wsd/ClientSession.cpp
similarity index 100%
rename from loolwsd/ClientSession.cpp
rename to wsd/ClientSession.cpp
diff --git a/loolwsd/ClientSession.hpp b/wsd/ClientSession.hpp
similarity index 100%
rename from loolwsd/ClientSession.hpp
rename to wsd/ClientSession.hpp
diff --git a/loolwsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
similarity index 100%
rename from loolwsd/DocumentBroker.cpp
rename to wsd/DocumentBroker.cpp
diff --git a/loolwsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
similarity index 100%
rename from loolwsd/DocumentBroker.hpp
rename to wsd/DocumentBroker.hpp
diff --git a/loolwsd/Exceptions.hpp b/wsd/Exceptions.hpp
similarity index 100%
rename from loolwsd/Exceptions.hpp
rename to wsd/Exceptions.hpp
diff --git a/loolwsd/FileServer.cpp b/wsd/FileServer.cpp
similarity index 100%
rename from loolwsd/FileServer.cpp
rename to wsd/FileServer.cpp
diff --git a/loolwsd/FileServer.hpp b/wsd/FileServer.hpp
similarity index 100%
rename from loolwsd/FileServer.hpp
rename to wsd/FileServer.hpp
diff --git a/loolwsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
similarity index 100%
rename from loolwsd/LOOLWSD.cpp
rename to wsd/LOOLWSD.cpp
diff --git a/loolwsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
similarity index 100%
rename from loolwsd/LOOLWSD.hpp
rename to wsd/LOOLWSD.hpp
diff --git a/loolwsd/LOOLWebSocket.hpp b/wsd/LOOLWebSocket.hpp
similarity index 100%
rename from loolwsd/LOOLWebSocket.hpp
rename to wsd/LOOLWebSocket.hpp
diff --git a/loolwsd/PrisonerSession.cpp b/wsd/PrisonerSession.cpp
similarity index 100%
rename from loolwsd/PrisonerSession.cpp
rename to wsd/PrisonerSession.cpp
diff --git a/loolwsd/PrisonerSession.hpp b/wsd/PrisonerSession.hpp
similarity index 100%
rename from loolwsd/PrisonerSession.hpp
rename to wsd/PrisonerSession.hpp
diff --git a/loolwsd/QueueHandler.hpp b/wsd/QueueHandler.hpp
similarity index 100%
rename from loolwsd/QueueHandler.hpp
rename to wsd/QueueHandler.hpp
diff --git a/loolwsd/README b/wsd/README
similarity index 100%
rename from loolwsd/README
rename to wsd/README
diff --git a/loolwsd/README.vars b/wsd/README.vars
similarity index 100%
rename from loolwsd/README.vars
rename to wsd/README.vars
diff --git a/loolwsd/Storage.cpp b/wsd/Storage.cpp
similarity index 100%
rename from loolwsd/Storage.cpp
rename to wsd/Storage.cpp
diff --git a/loolwsd/Storage.hpp b/wsd/Storage.hpp
similarity index 100%
rename from loolwsd/Storage.hpp
rename to wsd/Storage.hpp
diff --git a/loolwsd/TileCache.cpp b/wsd/TileCache.cpp
similarity index 100%
rename from loolwsd/TileCache.cpp
rename to wsd/TileCache.cpp
diff --git a/loolwsd/TileCache.hpp b/wsd/TileCache.hpp
similarity index 100%
rename from loolwsd/TileCache.hpp
rename to wsd/TileCache.hpp
diff --git a/loolwsd/TileDesc.hpp b/wsd/TileDesc.hpp
similarity index 100%
rename from loolwsd/TileDesc.hpp
rename to wsd/TileDesc.hpp
diff --git a/loolwsd/TraceFile.hpp b/wsd/TraceFile.hpp
similarity index 100%
rename from loolwsd/TraceFile.hpp
rename to wsd/TraceFile.hpp
diff --git a/loolwsd/UserMessages.hpp b/wsd/UserMessages.hpp
similarity index 100%
rename from loolwsd/UserMessages.hpp
rename to wsd/UserMessages.hpp
diff --git a/loolwsd/lint-discovery.py b/wsd/lint-discovery.py
similarity index 100%
rename from loolwsd/lint-discovery.py
rename to wsd/lint-discovery.py
diff --git a/loolwsd/protocol.txt b/wsd/protocol.txt
similarity index 100%
rename from loolwsd/protocol.txt
rename to wsd/protocol.txt
diff --git a/loolwsd/reference.txt b/wsd/reference.txt
similarity index 100%
rename from loolwsd/reference.txt
rename to wsd/reference.txt
commit 4432aba25b6ee68356e0ddfc724afb8373651945
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 25 09:48:59 2016 +0000

    Revert "loolwsd: support reading long messages directly"
    
    This reverts commit 84607b43a31574533471defcb4756ba855f835f1.
    
    LOOLWebSocket piece requires a much too recent Poco.

diff --git a/loolwsd/IoUtil.cpp b/loolwsd/IoUtil.cpp
index adf5c55..035dcf8 100644
--- a/loolwsd/IoUtil.cpp
+++ b/loolwsd/IoUtil.cpp
@@ -50,17 +50,17 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
 
     // Timeout given is in microseconds.
     static const Poco::Timespan waitTime(POLL_TIMEOUT_MS * 1000);
-    constexpr auto bufferSize = READ_BUFFER_SIZE * 8;
-
+    const auto bufferSize = READ_BUFFER_SIZE * 100;
     int flags = 0;
     int n = -1;
     bool stop = false;
     std::vector<char> payload(bufferSize);
-    Poco::Buffer<char> buffer(bufferSize);
     try
     {
         ws->setReceiveTimeout(0);
 
+        payload.resize(0);
+
         for (;;)
         {
             stop = stopPredicate();
@@ -79,12 +79,10 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
 
             try
             {
-                payload.resize(0);
-                buffer.resize(0);
+                payload.resize(payload.capacity());
                 n = -1;
-                n = ws->receiveFrame(buffer, flags);
-                LOG_WRN("GOT: [" << LOOLProtocol::getAbbreviatedMessage(buffer.begin(), buffer.size()) << "]");
-                payload.insert(payload.end(), buffer.begin(), buffer.end());
+                n = ws->receiveFrame(payload.data(), payload.capacity(), flags);
+                payload.resize(n > 0 ? n : 0);
             }
             catch (const Poco::TimeoutException&)
             {
@@ -101,7 +99,7 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
 
             assert(n > 0);
 
-            const std::string firstLine = LOOLProtocol::getFirstLine(buffer.begin(), buffer.size());
+            const std::string firstLine = LOOLProtocol::getFirstLine(payload);
             if ((flags & WebSocket::FrameFlags::FRAME_FLAG_FIN) != WebSocket::FrameFlags::FRAME_FLAG_FIN)
             {
                 // One WS message split into multiple frames.
@@ -109,7 +107,8 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
                 LOG_WRN("SocketProcessor [" << name << "]: Receiving multi-parm frame.");
                 while (true)
                 {
-                    n = ws->receiveFrame(buffer, flags);
+                    char buffer[READ_BUFFER_SIZE * 10];
+                    n = ws->receiveFrame(buffer, sizeof(buffer), flags);
                     if (n <= 0 || (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE)
                     {
                         LOG_WRN("SocketProcessor [" << name << "]: Connection closed while reading multiframe message.");
@@ -117,7 +116,7 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
                         break;
                     }
 
-                    payload.insert(payload.end(), buffer.begin(), buffer.end());
+                    payload.insert(payload.end(), buffer, buffer + n);
                     if ((flags & WebSocket::FrameFlags::FRAME_FLAG_FIN) == WebSocket::FrameFlags::FRAME_FLAG_FIN)
                     {
                         // No more frames.
@@ -125,6 +124,27 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
                     }
                 }
             }
+            else
+            {
+                int size = 0;
+                Poco::StringTokenizer tokens(firstLine, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
+                // Check if it is a "nextmessage:" and in that case read the large
+                // follow-up message separately, and handle that only.
+                if (tokens.count() == 2 && tokens[0] == "nextmessage:" &&
+                    LOOLProtocol::getTokenInteger(tokens[1], "size", size) && size > 0)
+                {
+                    LOG_TRC("SocketProcessor [" << name << "]: Getting large message of " << size << " bytes.");
+                    if (size > MAX_MESSAGE_SIZE)
+                    {
+                        LOG_ERR("SocketProcessor [" << name << "]: Large-message size (" << size << ") over limit or invalid.");
+                    }
+                    else
+                    {
+                        payload.resize(size);
+                        continue;
+                    }
+                }
+            }
 
             if (n <= 0 || (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE)
             {
diff --git a/loolwsd/LOOLWebSocket.hpp b/loolwsd/LOOLWebSocket.hpp
index fb1d88b..e10af2a 100644
--- a/loolwsd/LOOLWebSocket.hpp
+++ b/loolwsd/LOOLWebSocket.hpp
@@ -108,39 +108,6 @@ public:
         return -1;
     }
 
-
-    /// Wrapper for Poco::Net::WebSocket::receiveFrame() that handles PING frames
-    /// (by replying with a PONG frame) and PONG frames. PONG frames are ignored.
-    /// Should we also factor out the handling of non-final and continuation frames into this?
-    int receiveFrame(Poco::Buffer<char>& buffer, int& flags)
-    {
-#ifdef ENABLE_DEBUG
-        // Delay receiving the frame
-        std::this_thread::sleep_for(getWebSocketDelay());
-#endif
-        // Timeout given is in microseconds.
-        static const Poco::Timespan waitTime(POLL_TIMEOUT_MS * 1000);
-
-        while (poll(waitTime, Poco::Net::Socket::SELECT_READ))
-        {
-            const int n = Poco::Net::WebSocket::receiveFrame(buffer, flags);
-            if (n > 0 && (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_PING)
-            {
-                sendFrame(buffer.begin(), n, WebSocket::FRAME_FLAG_FIN | WebSocket::FRAME_OP_PONG);
-            }
-            else if ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_PONG)
-            {
-                // In case we do send pongs in the future.
-            }
-            else
-            {
-                return n;
-            }
-        }
-
-        return -1;
-    }
-
     /// Wrapper for Poco::Net::WebSocket::sendFrame() that handles large frames.
     int sendFrame(const char* buffer, const int length, const int flags = FRAME_TEXT)
     {
@@ -150,6 +117,19 @@ public:
 #endif
         std::unique_lock<std::mutex> lock(_mutex);
 
+        // Size after which messages will be sent preceded with
+        // 'nextmessage' frame to let the receiver know in advance
+        // the size of larger coming message. All messages up to this
+        // size are considered small messages.
+        constexpr int SMALL_MESSAGE_SIZE = READ_BUFFER_SIZE / 2;
+
+        if (length > SMALL_MESSAGE_SIZE)
+        {
+            const std::string nextmessage = "nextmessage: size=" + std::to_string(length);
+            Poco::Net::WebSocket::sendFrame(nextmessage.data(), nextmessage.size());
+            Log::debug("Message is long, sent " + nextmessage);
+        }
+
         const int result = Poco::Net::WebSocket::sendFrame(buffer, length, flags);
 
         lock.unlock();
diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp
index 7e5f039..30aeac1 100644
--- a/loolwsd/test/helpers.hpp
+++ b/loolwsd/test/helpers.hpp
@@ -197,7 +197,6 @@ std::vector<char> getResponseMessage(LOOLWebSocket& ws, const std::string& prefi
         int retries = timeoutMs / 500;
         const Poco::Timespan waitTime(retries ? timeoutMs * 1000 / retries : timeoutMs * 1000);
         std::vector<char> response;
-        Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
 
         bool timedout = false;
         ws.setReceiveTimeout(0);
@@ -211,10 +210,9 @@ std::vector<char> getResponseMessage(LOOLWebSocket& ws, const std::string& prefi
                     timedout = false;
                 }
 
-                response.resize(0);
-                buffer.resize(0);
-                const int bytes = ws.receiveFrame(buffer, flags);
-                response.insert(response.end(), buffer.begin(), buffer.end());
+                response.resize(READ_BUFFER_SIZE);
+                int bytes = ws.receiveFrame(response.data(), response.size(), flags);
+                response.resize(bytes >= 0 ? bytes : 0);
                 std::cerr << name << "Got " << LOOLProtocol::getAbbreviatedFrameDump(response.data(), bytes, flags) << std::endl;
                 const auto message = LOOLProtocol::getFirstLine(response);
                 if (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
@@ -223,6 +221,26 @@ std::vector<char> getResponseMessage(LOOLWebSocket& ws, const std::string& prefi
                     {
                         return response;
                     }
+                    else if (LOOLProtocol::matchPrefix("nextmessage", message))
+                    {
+                        int size = 0;
+                        if (LOOLProtocol::getTokenIntegerFromMessage(message, "size", size) && size > 0)
+                        {
+                            response.resize(size);
+                            bytes = ws.receiveFrame(response.data(), response.size(), flags);
+                            response.resize(bytes >= 0 ? bytes : 0);
+                            std::cerr << name << "Got " << LOOLProtocol::getAbbreviatedFrameDump(response.data(), bytes, flags) << std::endl;
+                            if (bytes > 0 &&
+                                LOOLProtocol::matchPrefix(prefix, LOOLProtocol::getFirstLine(response)))
+                            {
+                                return response;
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    response.resize(0);
                 }
 
                 if (bytes <= 0)
commit a2058341a389f09d8b8763a56aecbc0a1d3c7591
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 25 09:46:01 2016 +0000

    Revert "loolwsd: kill receiveFrame with char* and cleanup usage cases"
    
    This reverts commit 45c1856c6ad1753f8a90d3bb90711ab0338d623c.
    
    This patch requires a very bleeding edge Poco, reverting for now.

diff --git a/loolwsd/Connect.cpp b/loolwsd/Connect.cpp
index aad78fa..5b550dd 100644
--- a/loolwsd/Connect.cpp
+++ b/loolwsd/Connect.cpp
@@ -89,24 +89,23 @@ public:
         {
             do
             {
-                Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
-                buffer.resize(0);
-                n = _ws.receiveFrame(buffer, flags);
+                char buffer[100000];
+                n = _ws.receiveFrame(buffer, sizeof(buffer), flags);
                 if (n > 0 && (flags & WebSocket::FRAME_OP_BITMASK) != WebSocket::FRAME_OP_CLOSE)
                 {
                     {
                         std::unique_lock<std::mutex> lock(coutMutex);
-                        std::cout << "Got " << getAbbreviatedFrameDump(buffer.begin(), n, flags) << std::endl;
+                        std::cout << "Got " << getAbbreviatedFrameDump(buffer, n, flags) << std::endl;
                     }
 
-                    const std::string firstLine = getFirstLine(buffer.begin(), n);
+                    std::string firstLine = getFirstLine(buffer, n);
                     StringTokenizer tokens(firstLine, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
 
                     if (std::getenv("DISPLAY") != nullptr && tokens[0] == "tile:")
                     {
                         TemporaryFile pngFile;
                         std::ofstream pngStream(pngFile.path(), std::ios::binary);
-                        pngStream.write(buffer.begin() + firstLine.size() + 1, n - firstLine.size() - 1);
+                        pngStream.write(buffer + firstLine.size() + 1, n - firstLine.size() - 1);
                         pngStream.close();
                         if (std::system((std::string("display ") + pngFile.path()).c_str()) == -1)
                         {
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index b7ad287..5ca3fce 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -196,7 +196,7 @@ void shutdownLimitReached(LOOLWebSocket& ws)
     {
         int flags = 0;
         int retries = 7;
-        Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
+        std::vector<char> buffer(READ_BUFFER_SIZE * 100);
 
         const Poco::Timespan waitTime(POLL_TIMEOUT_MS * 1000);
         do
@@ -214,8 +214,7 @@ void shutdownLimitReached(LOOLWebSocket& ws)
             // Ignore incoming messages.
             if (ws.poll(waitTime, Poco::Net::Socket::SELECT_READ))
             {
-                buffer.resize(0);
-                ws.receiveFrame(buffer, flags);
+                ws.receiveFrame(buffer.data(), buffer.capacity(), flags);
             }
 
             // Shutdown.
diff --git a/loolwsd/LOOLWebSocket.hpp b/loolwsd/LOOLWebSocket.hpp
index 827c324..fb1d88b 100644
--- a/loolwsd/LOOLWebSocket.hpp
+++ b/loolwsd/LOOLWebSocket.hpp
@@ -79,6 +79,39 @@ public:
     /// Wrapper for Poco::Net::WebSocket::receiveFrame() that handles PING frames
     /// (by replying with a PONG frame) and PONG frames. PONG frames are ignored.
     /// Should we also factor out the handling of non-final and continuation frames into this?
+    int receiveFrame(char* buffer, const int length, int& flags)
+    {
+#ifdef ENABLE_DEBUG
+        // Delay receiving the frame
+        std::this_thread::sleep_for(getWebSocketDelay());
+#endif
+        // Timeout given is in microseconds.
+        static const Poco::Timespan waitTime(POLL_TIMEOUT_MS * 1000);
+
+        while (poll(waitTime, Poco::Net::Socket::SELECT_READ))
+        {
+            const int n = Poco::Net::WebSocket::receiveFrame(buffer, length, flags);
+            if ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_PING)
+            {
+                sendFrame(buffer, n, WebSocket::FRAME_FLAG_FIN | WebSocket::FRAME_OP_PONG);
+            }
+            else if ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_PONG)
+            {
+                // In case we do send pongs in the future.
+            }
+            else
+            {
+                return n;
+            }
+        }
+
+        return -1;
+    }
+
+
+    /// Wrapper for Poco::Net::WebSocket::receiveFrame() that handles PING frames
+    /// (by replying with a PONG frame) and PONG frames. PONG frames are ignored.
+    /// Should we also factor out the handling of non-final and continuation frames into this?
     int receiveFrame(Poco::Buffer<char>& buffer, int& flags)
     {
 #ifdef ENABLE_DEBUG
diff --git a/loolwsd/test/UnitFonts.cpp b/loolwsd/test/UnitFonts.cpp
index 232ecb2..60312d4 100644
--- a/loolwsd/test/UnitFonts.cpp
+++ b/loolwsd/test/UnitFonts.cpp
@@ -44,16 +44,17 @@ namespace {
     std::string readFontList(const std::shared_ptr<LOOLWebSocket> &socket)
     {
         int flags;
-        Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
+        char buffer[100 * 1000];
 
-        buffer.resize(0);
-        const int length = socket->receiveFrame(buffer, flags);
+        int length = socket->receiveFrame(buffer, sizeof (buffer), flags);
         if (length > 0)
         {
-            return std::string(buffer.begin(), length);
+            assert(length<(int)sizeof(buffer));
+            buffer[length] = '\0';
+            return std::string(buffer);
         }
-
-        return std::string("read failure");
+        else
+            return std::string("read failure");
     }
 }
 
diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp
index c6c730a..7e5f039 100644
--- a/loolwsd/test/helpers.hpp
+++ b/loolwsd/test/helpers.hpp
@@ -173,8 +173,7 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message)
     ws.setReceiveTimeout(timeout);
     do
     {
-        buffer.resize(0);
-        bytes = ws.receiveFrame(buffer, flags);
+        bytes = ws.receiveFrame(buffer.begin(), READ_BUFFER_SIZE, flags);
     }
     while ((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
 
@@ -410,7 +409,7 @@ void SocketProcessor(const std::string& name,
     const Poco::Timespan waitTime(timeoutMs * 1000);
     int flags = 0;
     int n = 0;
-    Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
+    char buffer[READ_BUFFER_SIZE];
     do
     {
         if (!socket->poll(waitTime, Poco::Net::Socket::SELECT_READ))
@@ -419,12 +418,11 @@ void SocketProcessor(const std::string& name,
             break;
         }
 
-        buffer.resize(0);
-        n = socket->receiveFrame(buffer, flags);
-        std::cerr << name << "Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer.begin(), n, flags) << std::endl;
+        n = socket->receiveFrame(buffer, sizeof(buffer), flags);
+        std::cerr << name << "Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer, n, flags) << std::endl;
         if (n > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
         {
-            if (!handler(std::string(buffer.begin(), n)))
+            if (!handler(std::string(buffer, n)))
             {
                 break;
             }
diff --git a/loolwsd/test/httpcrashtest.cpp b/loolwsd/test/httpcrashtest.cpp
index b9a297c..1bfd4f2 100644
--- a/loolwsd/test/httpcrashtest.cpp
+++ b/loolwsd/test/httpcrashtest.cpp
@@ -164,12 +164,11 @@ void HTTPCrashTest::testCrashKit()
         // receive close frame handshake
         int bytes;
         int flags;
-        Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
+        char buffer[READ_BUFFER_SIZE];
         do
         {
-            buffer.resize(0);
-            bytes = socket->receiveFrame(buffer, flags);
-            std::cerr << testname << "Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer.begin(), bytes, flags) << std::endl;
+            bytes = socket->receiveFrame(buffer, sizeof(buffer), flags);
+            std::cerr << testname << "Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer, bytes, flags) << std::endl;
         }
         while ((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
 
@@ -177,7 +176,7 @@ void HTTPCrashTest::testCrashKit()
         socket->shutdown();
 
         // no more messages is received.
-        bytes = socket->receiveFrame(buffer, flags);
+        bytes = socket->receiveFrame(buffer, sizeof(buffer), flags);
         CPPUNIT_ASSERT_MESSAGE("Expected no more data", bytes <= 2); // The 2-byte marker is ok.
         CPPUNIT_ASSERT_EQUAL(0x88, flags);
     }
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index eeff3f4..1e65fc2 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -253,42 +253,37 @@ void HTTPWSTest::testHandShake()
         socket.setReceiveTimeout(0);
 
         int flags = 0;
-        Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
-        buffer.resize(0);
-        int bytes = socket.receiveFrame(buffer, flags);
-        CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: find"), std::string(buffer.begin(), bytes));
-
-        buffer.resize(0);
-        bytes = socket.receiveFrame(buffer, flags);
-        if (bytes > 0 && !std::strstr(buffer.begin(), "error:"))
+        char buffer[1024] = {0};
+        int bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
+        CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: find"), std::string(buffer, bytes));
+
+        bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
+        if (bytes > 0 && !std::strstr(buffer, "error:"))
         {
-            CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: connect"), std::string(buffer.begin(), bytes));
+            CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: connect"), std::string(buffer, bytes));
 
-            buffer.resize(0);
-            bytes = socket.receiveFrame(buffer, flags);
-            if (!std::strstr(buffer.begin(), "error:"))
+            bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
+            if (!std::strstr(buffer, "error:"))
             {
-                CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: ready"), std::string(buffer.begin(), bytes));
+                CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: ready"), std::string(buffer, bytes));
             }
             else
             {
                 // check error message
-                CPPUNIT_ASSERT(std::strstr(SERVICE_UNAVAILABLE_INTERNAL_ERROR, buffer.begin()) != nullptr);
+                CPPUNIT_ASSERT(std::strstr(SERVICE_UNAVAILABLE_INTERNAL_ERROR, buffer) != nullptr);
 
                 // close frame message
-                buffer.resize(0);
-                bytes = socket.receiveFrame(buffer, flags);
+                bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
                 CPPUNIT_ASSERT((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_CLOSE);
             }
         }
         else
         {
             // check error message
-            CPPUNIT_ASSERT(std::strstr(SERVICE_UNAVAILABLE_INTERNAL_ERROR, buffer.begin()) != nullptr);
+            CPPUNIT_ASSERT(std::strstr(SERVICE_UNAVAILABLE_INTERNAL_ERROR, buffer) != nullptr);
 
             // close frame message
-            buffer.resize(0);
-            bytes = socket.receiveFrame(buffer, flags);
+            bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
             CPPUNIT_ASSERT((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_CLOSE);
         }
     }
@@ -314,16 +309,15 @@ void HTTPWSTest::testCloseAfterClose()
         // receive close frame handshake
         int bytes;
         int flags;
-        Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
+        char buffer[READ_BUFFER_SIZE];
         do
         {
-            buffer.resize(0);
-            bytes = socket->receiveFrame(buffer, flags);
+            bytes = socket->receiveFrame(buffer, sizeof(buffer), flags);
         }
         while (bytes && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
 
         // no more messages is received.
-        bytes = socket->receiveFrame(buffer, flags);
+        bytes = socket->receiveFrame(buffer, sizeof(buffer), flags);
         std::cerr << "Received " << bytes << " bytes, flags: "<< std::hex << flags << std::dec << std::endl;
         CPPUNIT_ASSERT_EQUAL(0, bytes);
         CPPUNIT_ASSERT_EQUAL(0, flags);
commit 47699cd9084e4562dd7983f6c4d48cef74b6ba0b
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Nov 25 14:39:13 2016 +0530

    tdf#98484: Handle spaces in chrome when IME is enabled
    
    When IME is enabled and user presses the space button, firefox
    sends 'compositionend' event with data = ' '. However, chrome
    instead fires 'textInput'
    event. Lets listen for 'textInput' event too and treat it like
    'compositionend' event when data = ' '.
    
    Change-Id: Icbebdf2e89f608f790e6ce68c49f474364e7d5ab

diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 75e20fc..40961cb 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -721,7 +721,7 @@ L.Map = L.Evented.extend({
 		L.DomEvent[onOff](this._container, 'click dblclick mousedown mouseup ' +
 			'mouseover mouseout mousemove contextmenu dragover drop ' +
 			'keydown keypress keyup trplclick qdrplclick', this._handleDOMEvent, this);
-		L.DomEvent[onOff](this._textArea, 'copy cut paste keydown keypress keyup compositionend', this._handleDOMEvent, this);
+		L.DomEvent[onOff](this._textArea, 'copy cut paste keydown keypress keyup compositionstart compositionupdate compositionend textInput', this._handleDOMEvent, this);
 
 		if (this.options.trackResize && this._resizeDetector.contentWindow) {
 			L.DomEvent[onOff](this._resizeDetector.contentWindow, 'resize', this._onResize, this);
@@ -941,7 +941,7 @@ L.Map = L.Evented.extend({
 		};
 		if (e.type !== 'keypress' && e.type !== 'keyup' && e.type !== 'keydown' &&
 			e.type !== 'copy' && e.type !== 'cut' && e.type !== 'paste' &&
-			e.type !== 'compositionend') {
+		    e.type !== 'compositionstart' && e.type !== 'compositionupdate' && e.type !== 'compositionend' && e.type !== 'textInput') {
 			data.containerPoint = target instanceof L.Marker ?
 					this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);
 			data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index e7b638e..1a6988b 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -171,13 +171,13 @@ L.Map.Keyboard = L.Handler.extend({
 
 		this._map.on('mousedown', this._onMouseDown, this);
 		this._map.on('keydown keyup keypress', this._onKeyDown, this);
-		this._map.on('compositionend', this._onKeyDown, this);
+		this._map.on('compositionstart compositionupdate compositionend textInput', this._onKeyDown, this);
 	},
 
 	removeHooks: function () {
 		this._map.off('mousedown', this._onMouseDown, this);
 		this._map.off('keydown keyup keypress', this._onKeyDown, this);
-		this._map.off('compositionend', this._onKeyDown, this);
+		this._map.off('compositionstart compositionupdate compositionend textInput', this._onKeyDown, this);
 	},
 
 	_setPanOffset: function (pan) {
@@ -285,6 +285,14 @@ L.Map.Keyboard = L.Handler.extend({
 
 		var charCode = e.originalEvent.charCode;
 		var keyCode = e.originalEvent.keyCode;
+
+		// Hack for making space work in chrome when IME is enabled
+		// Chrome doesn't fire compositionend event when IME is enabled and user presses <space>.
+		// However, it sends 'textInput' event in such a case. treat it like 'compositionend' events
+		if (e.type === 'textInput' && e.originalEvent.data === ' ') {
+			e.type = 'compositionend';
+		}
+
 		if (e.type === 'compositionend') {
 			var compCharCodes = [];
 			for (var i = 0; i < e.originalEvent.data.length; i++) {
@@ -357,6 +365,7 @@ L.Map.Keyboard = L.Handler.extend({
 				map.setZoom(map.getZoom() + (e.shiftKey ? 3 : 1) * this._zoomKeys[key]);
 			}
 		}
+
 		L.DomEvent.stopPropagation(e.originalEvent);
 	},
 
commit e9dbfa395381e942eff2e14f62aab61382b82e8d
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Nov 25 10:05:49 2016 +0530

    tdf#98484: IME support - handle full string in compositions
    
    Parse the compositionend event's string, convert each into a char
    code and pass them individually to server.
    
    Change-Id: If79d538ccaebaa29749a5ca48a1f6ed5e0689ed5

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 10160b2..d47a6e5 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1202,6 +1202,20 @@ L.TileLayer = L.GridLayer.extend({
 		}
 	},
 
+	_postKeyboardEvents: function(type, charcodes, keycodes) {
+		// Both are arrays
+		if (typeof(charcodes.length) !== 'number' && typeof(keycodes.length) !== 'number')
+			return;
+
+		// both have same length
+		if (charcodes.length !== keycodes.length)
+			return;
+
+		for (var i = 0; i < charcodes.length; i++) {
+			this._postKeyboardEvent(type, charcodes[i], keycodes[i]);
+		}
+	},
+
 	_postKeyboardEvent: function(type, charcode, keycode) {
 		if (this._docType === 'spreadsheet' && this._prevCellCursor && type === 'input')
 		{
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 6e64ae4..e7b638e 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -286,7 +286,10 @@ L.Map.Keyboard = L.Handler.extend({
 		var charCode = e.originalEvent.charCode;
 		var keyCode = e.originalEvent.keyCode;
 		if (e.type === 'compositionend') {
-			charCode = keyCode = e.originalEvent.data.charCodeAt();
+			var compCharCodes = [];
+			for (var i = 0; i < e.originalEvent.data.length; i++) {
+				compCharCodes.push(e.originalEvent.data[i].charCodeAt());
+			}
 		}
 		var unoKeyCode = this._toUNOKeyCode(keyCode);
 
@@ -317,7 +320,12 @@ L.Map.Keyboard = L.Handler.extend({
 					// key press times will be paired with the invalidation messages
 					docLayer._debugKeypressQueue.push(+new Date());
 				}
-				docLayer._postKeyboardEvent('input', charCode, unoKeyCode);
+				if (e.type === 'compositionend') {
+					// Set all keycodes to zero
+					docLayer._postKeyboardEvents('input', compCharCodes, Array.apply(null, Array(compCharCodes.length)).map(Number.prototype.valueOf, 0));
+				} else {
+					docLayer._postKeyboardEvent('input', charCode, unoKeyCode);
+				}
 			}
 			else if (e.type === 'keyup') {
 				docLayer._postKeyboardEvent('up', charCode, unoKeyCode);
commit 45c1856c6ad1753f8a90d3bb90711ab0338d623c
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Thu Nov 24 19:18:15 2016 -0500

    loolwsd: kill receiveFrame with char* and cleanup usage cases
    
    Change-Id: I64585f8992407e0a3ff26fba1dccd327de13b7ff
    Reviewed-on: https://gerrit.libreoffice.org/31185
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/Connect.cpp b/loolwsd/Connect.cpp
index 5b550dd..aad78fa 100644
--- a/loolwsd/Connect.cpp
+++ b/loolwsd/Connect.cpp
@@ -89,23 +89,24 @@ public:
         {
             do
             {
-                char buffer[100000];
-                n = _ws.receiveFrame(buffer, sizeof(buffer), flags);
+                Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
+                buffer.resize(0);
+                n = _ws.receiveFrame(buffer, flags);
                 if (n > 0 && (flags & WebSocket::FRAME_OP_BITMASK) != WebSocket::FRAME_OP_CLOSE)
                 {
                     {
                         std::unique_lock<std::mutex> lock(coutMutex);
-                        std::cout << "Got " << getAbbreviatedFrameDump(buffer, n, flags) << std::endl;
+                        std::cout << "Got " << getAbbreviatedFrameDump(buffer.begin(), n, flags) << std::endl;
                     }
 
-                    std::string firstLine = getFirstLine(buffer, n);
+                    const std::string firstLine = getFirstLine(buffer.begin(), n);
                     StringTokenizer tokens(firstLine, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
 
                     if (std::getenv("DISPLAY") != nullptr && tokens[0] == "tile:")
                     {
                         TemporaryFile pngFile;
                         std::ofstream pngStream(pngFile.path(), std::ios::binary);
-                        pngStream.write(buffer + firstLine.size() + 1, n - firstLine.size() - 1);
+                        pngStream.write(buffer.begin() + firstLine.size() + 1, n - firstLine.size() - 1);
                         pngStream.close();
                         if (std::system((std::string("display ") + pngFile.path()).c_str()) == -1)
                         {
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 5ca3fce..b7ad287 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -196,7 +196,7 @@ void shutdownLimitReached(LOOLWebSocket& ws)
     {
         int flags = 0;
         int retries = 7;
-        std::vector<char> buffer(READ_BUFFER_SIZE * 100);
+        Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
 
         const Poco::Timespan waitTime(POLL_TIMEOUT_MS * 1000);
         do
@@ -214,7 +214,8 @@ void shutdownLimitReached(LOOLWebSocket& ws)
             // Ignore incoming messages.
             if (ws.poll(waitTime, Poco::Net::Socket::SELECT_READ))
             {
-                ws.receiveFrame(buffer.data(), buffer.capacity(), flags);
+                buffer.resize(0);
+                ws.receiveFrame(buffer, flags);
             }
 
             // Shutdown.
diff --git a/loolwsd/LOOLWebSocket.hpp b/loolwsd/LOOLWebSocket.hpp
index fb1d88b..827c324 100644
--- a/loolwsd/LOOLWebSocket.hpp
+++ b/loolwsd/LOOLWebSocket.hpp
@@ -79,39 +79,6 @@ public:
     /// Wrapper for Poco::Net::WebSocket::receiveFrame() that handles PING frames
     /// (by replying with a PONG frame) and PONG frames. PONG frames are ignored.
     /// Should we also factor out the handling of non-final and continuation frames into this?
-    int receiveFrame(char* buffer, const int length, int& flags)
-    {
-#ifdef ENABLE_DEBUG
-        // Delay receiving the frame
-        std::this_thread::sleep_for(getWebSocketDelay());
-#endif
-        // Timeout given is in microseconds.
-        static const Poco::Timespan waitTime(POLL_TIMEOUT_MS * 1000);
-
-        while (poll(waitTime, Poco::Net::Socket::SELECT_READ))
-        {
-            const int n = Poco::Net::WebSocket::receiveFrame(buffer, length, flags);
-            if ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_PING)
-            {
-                sendFrame(buffer, n, WebSocket::FRAME_FLAG_FIN | WebSocket::FRAME_OP_PONG);
-            }
-            else if ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_PONG)
-            {
-                // In case we do send pongs in the future.
-            }
-            else
-            {
-                return n;
-            }
-        }
-
-        return -1;
-    }
-
-
-    /// Wrapper for Poco::Net::WebSocket::receiveFrame() that handles PING frames
-    /// (by replying with a PONG frame) and PONG frames. PONG frames are ignored.
-    /// Should we also factor out the handling of non-final and continuation frames into this?
     int receiveFrame(Poco::Buffer<char>& buffer, int& flags)
     {
 #ifdef ENABLE_DEBUG
diff --git a/loolwsd/test/UnitFonts.cpp b/loolwsd/test/UnitFonts.cpp
index 60312d4..232ecb2 100644
--- a/loolwsd/test/UnitFonts.cpp
+++ b/loolwsd/test/UnitFonts.cpp
@@ -44,17 +44,16 @@ namespace {
     std::string readFontList(const std::shared_ptr<LOOLWebSocket> &socket)
     {
         int flags;
-        char buffer[100 * 1000];
+        Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
 
-        int length = socket->receiveFrame(buffer, sizeof (buffer), flags);
+        buffer.resize(0);
+        const int length = socket->receiveFrame(buffer, flags);
         if (length > 0)
         {
-            assert(length<(int)sizeof(buffer));
-            buffer[length] = '\0';
-            return std::string(buffer);
+            return std::string(buffer.begin(), length);
         }
-        else
-            return std::string("read failure");
+
+        return std::string("read failure");
     }
 }
 
diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp
index 7e5f039..c6c730a 100644
--- a/loolwsd/test/helpers.hpp
+++ b/loolwsd/test/helpers.hpp
@@ -173,7 +173,8 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message)
     ws.setReceiveTimeout(timeout);
     do
     {
-        bytes = ws.receiveFrame(buffer.begin(), READ_BUFFER_SIZE, flags);
+        buffer.resize(0);
+        bytes = ws.receiveFrame(buffer, flags);
     }
     while ((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
 
@@ -409,7 +410,7 @@ void SocketProcessor(const std::string& name,
     const Poco::Timespan waitTime(timeoutMs * 1000);
     int flags = 0;
     int n = 0;
-    char buffer[READ_BUFFER_SIZE];
+    Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
     do
     {
         if (!socket->poll(waitTime, Poco::Net::Socket::SELECT_READ))
@@ -418,11 +419,12 @@ void SocketProcessor(const std::string& name,
             break;
         }
 
-        n = socket->receiveFrame(buffer, sizeof(buffer), flags);
-        std::cerr << name << "Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer, n, flags) << std::endl;
+        buffer.resize(0);
+        n = socket->receiveFrame(buffer, flags);
+        std::cerr << name << "Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer.begin(), n, flags) << std::endl;
         if (n > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
         {
-            if (!handler(std::string(buffer, n)))
+            if (!handler(std::string(buffer.begin(), n)))
             {
                 break;
             }
diff --git a/loolwsd/test/httpcrashtest.cpp b/loolwsd/test/httpcrashtest.cpp
index 1bfd4f2..b9a297c 100644
--- a/loolwsd/test/httpcrashtest.cpp
+++ b/loolwsd/test/httpcrashtest.cpp
@@ -164,11 +164,12 @@ void HTTPCrashTest::testCrashKit()
         // receive close frame handshake
         int bytes;
         int flags;
-        char buffer[READ_BUFFER_SIZE];
+        Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
         do
         {
-            bytes = socket->receiveFrame(buffer, sizeof(buffer), flags);
-            std::cerr << testname << "Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer, bytes, flags) << std::endl;
+            buffer.resize(0);
+            bytes = socket->receiveFrame(buffer, flags);
+            std::cerr << testname << "Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer.begin(), bytes, flags) << std::endl;
         }
         while ((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
 
@@ -176,7 +177,7 @@ void HTTPCrashTest::testCrashKit()
         socket->shutdown();
 
         // no more messages is received.
-        bytes = socket->receiveFrame(buffer, sizeof(buffer), flags);
+        bytes = socket->receiveFrame(buffer, flags);
         CPPUNIT_ASSERT_MESSAGE("Expected no more data", bytes <= 2); // The 2-byte marker is ok.
         CPPUNIT_ASSERT_EQUAL(0x88, flags);
     }
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index 1e65fc2..eeff3f4 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -253,37 +253,42 @@ void HTTPWSTest::testHandShake()
         socket.setReceiveTimeout(0);
 
         int flags = 0;
-        char buffer[1024] = {0};
-        int bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
-        CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: find"), std::string(buffer, bytes));
-
-        bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
-        if (bytes > 0 && !std::strstr(buffer, "error:"))
+        Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
+        buffer.resize(0);
+        int bytes = socket.receiveFrame(buffer, flags);
+        CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: find"), std::string(buffer.begin(), bytes));
+
+        buffer.resize(0);
+        bytes = socket.receiveFrame(buffer, flags);
+        if (bytes > 0 && !std::strstr(buffer.begin(), "error:"))
         {
-            CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: connect"), std::string(buffer, bytes));
+            CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: connect"), std::string(buffer.begin(), bytes));
 
-            bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
-            if (!std::strstr(buffer, "error:"))
+            buffer.resize(0);
+            bytes = socket.receiveFrame(buffer, flags);
+            if (!std::strstr(buffer.begin(), "error:"))
             {
-                CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: ready"), std::string(buffer, bytes));
+                CPPUNIT_ASSERT_EQUAL(std::string("statusindicator: ready"), std::string(buffer.begin(), bytes));
             }
             else
             {
                 // check error message
-                CPPUNIT_ASSERT(std::strstr(SERVICE_UNAVAILABLE_INTERNAL_ERROR, buffer) != nullptr);
+                CPPUNIT_ASSERT(std::strstr(SERVICE_UNAVAILABLE_INTERNAL_ERROR, buffer.begin()) != nullptr);
 
                 // close frame message
-                bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
+                buffer.resize(0);
+                bytes = socket.receiveFrame(buffer, flags);
                 CPPUNIT_ASSERT((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_CLOSE);
             }
         }
         else
         {
             // check error message
-            CPPUNIT_ASSERT(std::strstr(SERVICE_UNAVAILABLE_INTERNAL_ERROR, buffer) != nullptr);
+            CPPUNIT_ASSERT(std::strstr(SERVICE_UNAVAILABLE_INTERNAL_ERROR, buffer.begin()) != nullptr);
 
             // close frame message
-            bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
+            buffer.resize(0);
+            bytes = socket.receiveFrame(buffer, flags);
             CPPUNIT_ASSERT((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_CLOSE);
         }
     }
@@ -309,15 +314,16 @@ void HTTPWSTest::testCloseAfterClose()
         // receive close frame handshake
         int bytes;
         int flags;
-        char buffer[READ_BUFFER_SIZE];
+        Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
         do
         {
-            bytes = socket->receiveFrame(buffer, sizeof(buffer), flags);
+            buffer.resize(0);
+            bytes = socket->receiveFrame(buffer, flags);
         }
         while (bytes && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
 
         // no more messages is received.
-        bytes = socket->receiveFrame(buffer, sizeof(buffer), flags);
+        bytes = socket->receiveFrame(buffer, flags);
         std::cerr << "Received " << bytes << " bytes, flags: "<< std::hex << flags << std::dec << std::endl;
         CPPUNIT_ASSERT_EQUAL(0, bytes);
         CPPUNIT_ASSERT_EQUAL(0, flags);
commit 84607b43a31574533471defcb4756ba855f835f1
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Thu Nov 24 18:26:07 2016 -0500

    loolwsd: support reading long messages directly
    
    Since Poco receiveFrame expected the buffer to be
    at least as large as the frame, otherwise the socket
    had to be closed, we sent a 'nextmessage' frame
    before sending large frames with the payload size.
    
    This caused many problems, not least related to threading
    and lack of atomicity when sending large frames.
    
    There is another API in Poco that doesn't have this
    strict requirement, one that expects Poco::Buffer
    and resizes it as necessary.
    
    One potential issue is the possibility that a malicious
    attacker might send very large frames to force the
    server into allocating large buffers to read them,
    thereby destibilizing the server, if not bringing it
    down altogether.
    
    Change-Id: I05014d54c3a1464f629ed82d761a7a65e4941985
    Reviewed-on: https://gerrit.libreoffice.org/31184
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/IoUtil.cpp b/loolwsd/IoUtil.cpp
index 035dcf8..adf5c55 100644
--- a/loolwsd/IoUtil.cpp
+++ b/loolwsd/IoUtil.cpp
@@ -50,17 +50,17 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
 
     // Timeout given is in microseconds.
     static const Poco::Timespan waitTime(POLL_TIMEOUT_MS * 1000);
-    const auto bufferSize = READ_BUFFER_SIZE * 100;
+    constexpr auto bufferSize = READ_BUFFER_SIZE * 8;
+
     int flags = 0;
     int n = -1;
     bool stop = false;
     std::vector<char> payload(bufferSize);
+    Poco::Buffer<char> buffer(bufferSize);
     try
     {
         ws->setReceiveTimeout(0);
 
-        payload.resize(0);
-
         for (;;)
         {
             stop = stopPredicate();
@@ -79,10 +79,12 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
 
             try
             {
-                payload.resize(payload.capacity());
+                payload.resize(0);
+                buffer.resize(0);
                 n = -1;
-                n = ws->receiveFrame(payload.data(), payload.capacity(), flags);
-                payload.resize(n > 0 ? n : 0);
+                n = ws->receiveFrame(buffer, flags);
+                LOG_WRN("GOT: [" << LOOLProtocol::getAbbreviatedMessage(buffer.begin(), buffer.size()) << "]");
+                payload.insert(payload.end(), buffer.begin(), buffer.end());
             }
             catch (const Poco::TimeoutException&)
             {
@@ -99,7 +101,7 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
 
             assert(n > 0);
 
-            const std::string firstLine = LOOLProtocol::getFirstLine(payload);
+            const std::string firstLine = LOOLProtocol::getFirstLine(buffer.begin(), buffer.size());
             if ((flags & WebSocket::FrameFlags::FRAME_FLAG_FIN) != WebSocket::FrameFlags::FRAME_FLAG_FIN)
             {
                 // One WS message split into multiple frames.
@@ -107,8 +109,7 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
                 LOG_WRN("SocketProcessor [" << name << "]: Receiving multi-parm frame.");
                 while (true)
                 {
-                    char buffer[READ_BUFFER_SIZE * 10];
-                    n = ws->receiveFrame(buffer, sizeof(buffer), flags);
+                    n = ws->receiveFrame(buffer, flags);
                     if (n <= 0 || (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE)
                     {
                         LOG_WRN("SocketProcessor [" << name << "]: Connection closed while reading multiframe message.");
@@ -116,7 +117,7 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
                         break;
                     }
 
-                    payload.insert(payload.end(), buffer, buffer + n);
+                    payload.insert(payload.end(), buffer.begin(), buffer.end());
                     if ((flags & WebSocket::FrameFlags::FRAME_FLAG_FIN) == WebSocket::FrameFlags::FRAME_FLAG_FIN)
                     {
                         // No more frames.
@@ -124,27 +125,6 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
                     }
                 }
             }
-            else
-            {
-                int size = 0;
-                Poco::StringTokenizer tokens(firstLine, " ", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
-                // Check if it is a "nextmessage:" and in that case read the large
-                // follow-up message separately, and handle that only.
-                if (tokens.count() == 2 && tokens[0] == "nextmessage:" &&
-                    LOOLProtocol::getTokenInteger(tokens[1], "size", size) && size > 0)
-                {
-                    LOG_TRC("SocketProcessor [" << name << "]: Getting large message of " << size << " bytes.");
-                    if (size > MAX_MESSAGE_SIZE)
-                    {
-                        LOG_ERR("SocketProcessor [" << name << "]: Large-message size (" << size << ") over limit or invalid.");
-                    }
-                    else
-                    {
-                        payload.resize(size);
-                        continue;
-                    }
-                }
-            }
 
             if (n <= 0 || (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE)
             {
diff --git a/loolwsd/LOOLWebSocket.hpp b/loolwsd/LOOLWebSocket.hpp
index e10af2a..fb1d88b 100644
--- a/loolwsd/LOOLWebSocket.hpp
+++ b/loolwsd/LOOLWebSocket.hpp
@@ -108,6 +108,39 @@ public:
         return -1;
     }
 
+
+    /// Wrapper for Poco::Net::WebSocket::receiveFrame() that handles PING frames
+    /// (by replying with a PONG frame) and PONG frames. PONG frames are ignored.
+    /// Should we also factor out the handling of non-final and continuation frames into this?
+    int receiveFrame(Poco::Buffer<char>& buffer, int& flags)
+    {
+#ifdef ENABLE_DEBUG
+        // Delay receiving the frame
+        std::this_thread::sleep_for(getWebSocketDelay());
+#endif
+        // Timeout given is in microseconds.
+        static const Poco::Timespan waitTime(POLL_TIMEOUT_MS * 1000);
+
+        while (poll(waitTime, Poco::Net::Socket::SELECT_READ))
+        {
+            const int n = Poco::Net::WebSocket::receiveFrame(buffer, flags);
+            if (n > 0 && (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_PING)
+            {
+                sendFrame(buffer.begin(), n, WebSocket::FRAME_FLAG_FIN | WebSocket::FRAME_OP_PONG);
+            }
+            else if ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_PONG)
+            {
+                // In case we do send pongs in the future.
+            }
+            else
+            {
+                return n;
+            }
+        }
+
+        return -1;
+    }
+
     /// Wrapper for Poco::Net::WebSocket::sendFrame() that handles large frames.
     int sendFrame(const char* buffer, const int length, const int flags = FRAME_TEXT)
     {
@@ -117,19 +150,6 @@ public:
 #endif
         std::unique_lock<std::mutex> lock(_mutex);
 
-        // Size after which messages will be sent preceded with
-        // 'nextmessage' frame to let the receiver know in advance
-        // the size of larger coming message. All messages up to this
-        // size are considered small messages.
-        constexpr int SMALL_MESSAGE_SIZE = READ_BUFFER_SIZE / 2;
-
-        if (length > SMALL_MESSAGE_SIZE)
-        {
-            const std::string nextmessage = "nextmessage: size=" + std::to_string(length);
-            Poco::Net::WebSocket::sendFrame(nextmessage.data(), nextmessage.size());

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list