Commit graph

4226 commits

Author SHA1 Message Date
Ashod Nakashian
2906442f03 loolwsd: cleanup LOOLWebSocket
Change-Id: Iad16918a5e0bc239ba969bbe596c1d2c4c01cebb
Reviewed-on: https://gerrit.libreoffice.org/30819
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:21:27 +00:00
Ashod Nakashian
3cff799301 loolwsd: Log error when not sending full frame
... and timeout when receiving frame.

Change-Id: I5bb085f494fc146f7fbd75be3f3bb86597029369
Reviewed-on: https://gerrit.libreoffice.org/30818
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:20:54 +00:00
Ashod Nakashian
b6926c2f4c loolwsd: proper retrying in connectLOKit
Change-Id: Ib99a6012510457876f422767cf42b92f412df1f5
Reviewed-on: https://gerrit.libreoffice.org/30817
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:19:49 +00:00
Ashod Nakashian
0506cbb5c4 loolwsd: move reveiveFrame from IoUtil to LOOLWebSocket
Change-Id: I82b64d16e496f104c34eeddce1ef9a1e57bc03bc
Reviewed-on: https://gerrit.libreoffice.org/30816
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:19:22 +00:00
Ashod Nakashian
5d69d0abd6 loolwsd: log only abbreviated messages
Change-Id: I3328a9171f8b85a802dc888de009bdbb8658cead
Reviewed-on: https://gerrit.libreoffice.org/30815
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:18:43 +00:00
Ashod Nakashian
d2d3bb19e0 loolwsd: new unittest to test forkit crash recovery
Change-Id: I61c79cce83af1fface2f54294d418c67eb6d398e
Reviewed-on: https://gerrit.libreoffice.org/30814
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:18:12 +00:00
Ashod Nakashian
ae3055c19a loolwsd: don't ignore zombies when counting loolkit processes
During tests we need to count the number of
oustanding loolkit processes. Since once a process
dies its parents must first reap it to get removed
from the proc table, we can't assume the process
is fully removed until and unless it's reaped.

In crash tests this becomes critical, since if
we load docs right after intentionally killing
loolkits, we will trick wsd into using a zombie
process. It will then fail at first communication
with the child. While this excercise early failure,
in practice this is unrealistic and will force
handling cases that in practice should not happen
(or when they do, nothing too horrible will happen).

By not counting zombies we can now wait in the crash
tests until forkit reaps the kits, then we test
the scenario where there are no ready children
when documents are loaded.

Change-Id: I0e5ca9a02d215ceca36d80071ba57e9a9c9c3240
Reviewed-on: https://gerrit.libreoffice.org/30813
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:14:36 +00:00
Henry Castro
36474b21a6 loleaflet: add special character 2016-11-11 15:24:48 -04:00
Henry Castro
e6cdb7fa19 loleaflet: simplify remove all child elements 2016-11-11 14:05:15 -04:00
Henry Castro
1fde78d6cd loleaflet: move isVisible to Control class 2016-11-11 13:48:32 -04:00
Pranav Kant
224e6fc8e7 loolwsd: Only warn about mis-spells, don't accept them
Change-Id: Iace494139eee8ff7dececf203c9fd51a98c6bd46
2016-11-11 22:54:46 +05:30
Jan Holesovsky
de9ec63e4f Turns out that setting 'blocking' is the right thing to do.
Unfortunately it turns out that POCO's handling of the non-blocking case is
wrong when EWOULDBLOCK is returned from ::send().  This leads to a situation
when part of the data has been sent, but it is impossible to send only the
rest of it, because of too high-level api for the websockets.

We could essentially re-implement the POCO's websockets and use just the lower
levels of POCO - but then it's a question whether it is actually easier to use
the Linux system calls right away :-)

Change-Id: Ied08f68d5037d0ab9ca8266cd20e1084bcebfd14
2016-11-11 17:39:13 +01:00
Pranav Kant
bde2b14679 loolwsd: Use Levenshtein distance to tolerate mis-spells
... case sensitiveness and wrong types.

Change-Id: I3ce59c551722138f7e5cb0f00ebcdcb8682e7d0b
2016-11-11 20:07:29 +05:30
Pranav Kant
25db37484c tdf#103697: Fix color value for spreadsheets and presentations
Change-Id: I89f871f829abd847321bee927b98e9a96e8babbb
2016-11-11 16:22:44 +05:30
Pranav Kant
dacf16f2d8 tdf#103671: 'true' -> true
Treat booleans as booleans, not string

Change-Id: Id0d3bee44b42461671379754e64e5e2f9b318045
2016-11-10 23:06:15 +05:30
Pranav Kant
d060b242e8 More documentation about post message API
Change-Id: I362e159c32d2ea93139be58ca647a2f4c5678dee
2016-11-10 22:37:38 +05:30
Pranav Kant
08a365302e loleaflet: Fix browser print
Accessing the parent iframe, atleast on my local box, where
parent frame and loleaflet frame have different origin, is not
allowed by browser security policy.

Change-Id: Ia3a356fa1d8a81f38bbc27d256471302be8b6729
2016-11-10 22:03:17 +05:30
Pranav Kant
e850ac836f tdf#103641: Another Post message API - Get_Export_Formats
Change-Id: I8a502d3c88c83cc7fb6c3113522ed637bf349a0e
2016-11-10 22:03:17 +05:30
Pranav Kant
5219baaab0 tdf#103641: WOPI: Implement Action_Save, Action_Print, Action_Export
WOPI hosts can now send above mentioned messages to loleaflet so
that loleaflet does stuff accordingly.

Change-Id: I50e10a62c5b629bd12f7d9ce51bcd13cb13cdd8a
2016-11-10 22:03:17 +05:30
Pranav Kant
9bfd5a512e loleaflet: Factor out save uno command
Change-Id: I155329f9dfa37cb47cbac34aa885b3d7a0cbb573
2016-11-10 22:03:17 +05:30
Pranav Kant
2168617d60 tdf#103641: Implement ability to hide save, print, export options
Add more WOPI extensions for this - HidePrintOption,
HideSaveOption, HideExportOption. Setting HideExportOption to
'true' in WOPI CheckFileInfo response would hide the 'Download
as' option from the File menu.

Change-Id: Ia2259ee9525cc6c4331a52e2221af4df188eab07
2016-11-10 22:03:17 +05:30
Pranav Kant
9c5928a87b tdf#103641: Convert 'wopi:' message to JSON formatted message
... to accomdate other WOPI properties easily in future.

Change-Id: Ic92364f06f4f16ebe8f9f128cd49087f6d72a4d1
2016-11-10 22:03:17 +05:30
Pranav Kant
7cacabad40 loleaflet: Give id to these menu items
So that it is easy to manipulate them in future by their
identifier.

Change-Id: I252aa448c26c23a00f0a3e717e1603b0d0277e67
2016-11-10 22:03:17 +05:30
Pranav Kant
df50c8fd34 loleaflet: Fix some silliness
Change-Id: I8977d2f3a569d2442c34248a9b86fec9761fb0e2
2016-11-10 22:03:17 +05:30
Jan Holesovsky
b8b469c9b2 Block when working via http.
It looks like that the implementation details of POCO are thread-unsafe when
in non-blocking mode, and that is even when the actual sending of the frames
is guarded by a mutex.

Needs more research; but for the moment, enable non-blocking mode for HTTP.

Change-Id: Idcce3fb55bae73c17d9fc321a2273256c0396664
2016-11-10 13:12:56 +01:00
Pranav Kant
b1cec28cc3 This was only meant for debugging.
Change-Id: Ia31847ab45c1aa18b5d9d4187ac552d7486331e7
2016-11-10 16:30:38 +05:30
Andras Timar
4526d54d58 add LOOLWebSocket.hpp to dist tarball 2016-11-10 11:01:33 +01:00
Jan Holesovsky
0674e87831 Implement a thread-safe websocket inherited from Poco::Net::WebSocket.
sendFrame() implemented in LOOLWebSocket is thread safe, and also deals with
large messages - sends the "nextmessage: size=..." frame before the actual
large frame.

The problem this is attempting to solve was that when sending a large frame,
it was split to multiple packets.  During that, another frame was sent from a
different thread; which lead to confusion, and the resulting frame was
corrupted (because it ended up composed from unrelated packets).

Change-Id: Ie85952e431b1cad2fdc6e3c64df8a444ea0ae971
2016-11-10 10:44:48 +01:00
Pranav Kant
b0933b063e tdf#103640: Implement OwnerTermination; send application-level close frame
This implements a new feature 'OwnerTermination' for WOPI based
hosts. WOPI hosts now have to enable this feature by mentioning
'EnableOwnerTermination' as 'true' in their CheckFileInfo
response. If the OwnerId of the file matches that of the UserId
of the session, this session would be able to terminate all other
sessions currently editing the same document.

The reason for this kind of document termination is sent to all
sessions in a new application-level 'close:' message. This new message is
similar to the CLOSE frame of WebSocket protocol which doesn't
seem to work across all browsers as of now. Eg: Chrome -
https://bugs.chromium.org/p/chromium/issues/detail?id=426798
After receiving this 'close: ' message, loleaflet acts
accordingly and tells the WOPI host why the websocket was closed
via post message API.

Change-Id: I997aa2e7805157ed599a3946a877fd32477cee1b
2016-11-10 15:04:21 +05:30
Pranav Kant
410936b600 loolwsd: This is not used anymore
Change-Id: I7a0405faad5a2c1e15788c084d51bb6a4a39f82f
2016-11-10 14:45:20 +05:30
Pranav Kant
a6d2fe80a1 loolwsd: Read and store session owner ids
Change-Id: If905344475eb6d9585eaa5a1df6882dc3a7bdb2b
2016-11-10 14:45:20 +05:30
Pranav Kant
7f77618f38 Document PostMessage API in reference.html
Change-Id: Ibdd3fc060a99f3b6185362fa3143014710873079
2016-11-10 14:45:20 +05:30
Pranav Kant
1a1792cdc1 loleaflet: Group map getters together
Change-Id: I576f78aaa215b6ba3aff6a5ce8498a3449080927
2016-11-10 14:45:20 +05:30
Pranav Kant
f1f5c4ed66 loleaflet: A more OO approach for WOPI post message API
Abstract all the WOPI related logic in a map handler which is
enabled only if map.options.wopi is set during map
initialization.

Change-Id: I54c5d6eecf33f88e4fd4d2b5ac9e8cf9dd001966
2016-11-10 14:45:17 +05:30
Ashod Nakashian
8b5f112ebf loolwsd: recover when forkit dies
Change-Id: Idc1e08fb496d3c68b22e1d8eab2da9a9064ef070
Reviewed-on: https://gerrit.libreoffice.org/30743
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-10 05:17:15 +00:00
Ashod Nakashian
4c6aae20d5 loolwsd: don't error when killing a dead child process
Change-Id: I615911fb40a5218a6d1992dd94b63bff428699ee
Reviewed-on: https://gerrit.libreoffice.org/30742
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-10 05:16:23 +00:00
Ashod Nakashian
c5bff2b6e6 loolwsd: IoUtil logs updated
Change-Id: I632968753673089e8199b37a11f73286f88b20f4
Reviewed-on: https://gerrit.libreoffice.org/30741
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-10 05:15:38 +00:00
Ashod Nakashian
d5d31055c7 loolwsd: Admin formatting and cleanup
Change-Id: I0c0a9800bdd0a8ad1b652f8c5c05dc529ef04fe4
Reviewed-on: https://gerrit.libreoffice.org/30740
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-10 05:07:21 +00:00
Ashod Nakashian
793e00e134 loolwsd: use ostringstream when concatinating many strings
Change-Id: I55d4d0a14c81977568032d8a7dd1655b2f69ae67
Reviewed-on: https://gerrit.libreoffice.org/30739
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-10 05:02:02 +00:00
László Németh
8ef5c5fa36 loleaflet: hide debug control in disabled tile debug mode 2016-11-09 12:16:46 +01:00
Ashod Nakashian
462f71a632 loolwsd: no need to ping to check for live socket
Ping message needs to be echoed and that messes
up reading large messages that come in two parts.

Luckily, it's not necessary to do so as it's
sufficient to poll the state of the socket.

It's true polling is less accurate as there is
a timeout when a socket is disconnected, but
that doesn't seem to be an issue in practice.

Change-Id: I7a5744a621c4416b8f9d003871f6d613cc6ca7dc
Reviewed-on: https://gerrit.libreoffice.org/30705
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-09 06:07:38 +00:00
Andras Timar
7f80400dea loleaflet: typo: No-with -> No-width 2016-11-09 00:28:27 +01:00
Andras Timar
937d8754b7 Updated Slovenian translation 2016-11-09 00:27:13 +01:00
Jan Holesovsky
024a6048a0 Move sendLargeFrame() from Util to IoUtil.
Change-Id: Id5db865b0bcf936651e3c89a0333a101e58ace92
2016-11-08 19:57:03 +01:00
Jan Holesovsky
5f6858f782 Factor out creation of nextmessage: and improve its logging.
Change-Id: I552bc2599835b4f6c9d4ef423889b464c5701221
2016-11-08 18:25:46 +01:00
Jan Holesovsky
66053621bd Make sure we resize the payload to the amount of read bytes.
Change-Id: I33f032182912b4f03d073258c91974518db327fd
2016-11-08 14:54:15 +01:00
Andras Timar
127b39d5b6 fix l10n of word count (thousand separator!) 2016-11-08 14:25:18 +01:00
Ashod Nakashian
d978dc83cf loolwsd: minor improvement to logging while running tests
Change-Id: Id602e52ceb42923f19d902f653e2d6477b8b8e1f
Reviewed-on: https://gerrit.libreoffice.org/30676
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-08 00:21:53 +00:00
Ashod Nakashian
0164df61a5 loolwsd: alertAllUsersOfDocument must be called while holding lock
Change-Id: I266a61402973c9418eb293d2f66601d00be76754
Reviewed-on: https://gerrit.libreoffice.org/30675
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-08 00:21:37 +00:00
Ashod Nakashian
d8c2bb9195 loolwsd: minimize holding locks beyond the necessary point
Change-Id: I379a649469622682d7ebe98b8a7ebe29eddd1dfa
Reviewed-on: https://gerrit.libreoffice.org/30674
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-08 00:21:18 +00:00