Commit graph

105 commits

Author SHA1 Message Date
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
Ashod Nakashian
f02b98b432 loolwsd: use new log macros in LOOLSession
Change-Id: Ia971d4ef3b67fe289b58c6d2b1f27d6e6454a56f
Reviewed-on: https://gerrit.libreoffice.org/30495
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-02 13:23:17 +00:00
Ashod Nakashian
773c15f710 loolwsd: consistent formatting
With the help of clang-format.
For reference, the following command was used,
but not all changes were commited:

clang-format-3.9 -style='{BasedOnStyle: WebKit,
 AlignAfterOpenBracket: Align,
 AlwaysBreakAfterReturnType: None,
 BreakBeforeBraces: Allman,
 DerivePointerAlignment: 'true',
 ExperimentalAutoDetectBinPacking: 'true',
 IndentWrappedFunctionNames: 'true',
 UseTab: Never}'

Change-Id: I0f7490c7ee38aeefeefcf9d5d4c3dab380cd63b8
Reviewed-on: https://gerrit.libreoffice.org/30416
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-31 06:06:35 +00:00
Pranav Kant
cccf6dcb7d loolwsd: Store UserId in ChildSession
Change-Id: I46593442f7f8c61bddf00a624977c9d32bffdf44
2016-10-26 21:10:15 +05:30
Michael Meeks
f8746373a7 Handle exceptions during websocket shutdown. 2016-10-22 16:43:42 +01:00
Ashod Nakashian
de7cda7891 loolwsd: improve child cleanup and forking
Change-Id: I437216d87b6fa15e567e102ed875b22ef03351b2
Reviewed-on: https://gerrit.libreoffice.org/29948
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:11:18 +00:00
Tor Lillqvist
e07069eda2 Drop parameter when we always pass the same value for it
For the 'message' parameter of LOOLSession::shutdown(),
ClientSession::shutdownPeer(), and PrisonerSession::shutdownPeer() we
always passed "". It was passed on as the 'statusMessage' parameter to
WebSocet::shutdown() which has "" as default anyway.
2016-10-12 13:05:57 +03:00
Ashod Nakashian
128cd73154 loolwsd: send child messages to client via unified wsd-kit WS
Change-Id: I237120e5a81a2e6d8772a2b6f1e98b1ba567f97e
Reviewed-on: https://gerrit.libreoffice.org/29647
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-10 06:29:32 +00:00
Ashod Nakashian
71dfb9f7b7 loolwsd: localise locking in ChildSession
Avoid using the static mutex and instead use
the loKitDocument mutex when accessing the
latter. The static mutex is used only when
accessing the document manager. That is,
only when loading and unloading a document.

For ChildSession members that may
be accessed from both the callback and
incoming web-socket, guard them with the
member mutex.

Finally, move any local data manipulation
outside of locks altogether.

Change-Id: I046906bc6ed7e0b38c309f97836b38e27f9bfc8e
Reviewed-on: https://gerrit.libreoffice.org/29336
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-28 03:28:26 +00:00
Ashod Nakashian
4c7b015b68 loolwsd: use atomics for potentially shared flags
Change-Id: I36e34159cca24e2c3d99eaf4d4f36f3e008cb6ce
Reviewed-on: https://gerrit.libreoffice.org/29334
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-09-28 03:26:20 +00:00
Tor Lillqvist
20d6acae29 Return true in LOOLSession::forwardToPeer() when peer is closing
Fixes the testEditAnnotationWriter unit test, and doesn't break any
other ones. Many other tests do fail, but they fail also without this
change.
2016-09-16 18:28:21 +03:00
Tor Lillqvist
9d17637488 Fix comment 2016-09-16 11:24:12 +03:00
Pranav Kant
67444eeb80 loolwsd: Pass sessions' usernames to core
Change-Id: I8c81c02fafd2cb9d0048729401e082bb422e299b
Reviewed-on: https://gerrit.libreoffice.org/28481
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2016-08-30 07:45:37 +00:00
Ashod Nakashian
76ad9b3451 loolwsd: cleanup of LOOLSession
Change-Id: Ib65e65c44b258c7ae4d4fbe68555f664900d21c9
Reviewed-on: https://gerrit.libreoffice.org/28305
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-22 05:48:00 +00:00
Ashod Nakashian
08909b2a3d loolwsd: doxygen comments added to all classes
Change-Id: Ia485c2dcec20a6840d46836a61f75a8e7e8762ed
Reviewed-on: https://gerrit.libreoffice.org/28128
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-15 03:12:31 +00:00
Ashod Nakashian
ecd33e1b07 loolwsd: send json messages to the UI as text
Change-Id: Ie5712b4ebf4f01a6650f5f7c0df5197b5b9f9208
Reviewed-on: https://gerrit.libreoffice.org/27588
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-07-27 16:00:25 +00:00
Pranav Kant
9417ec839c loolwsd: Introduce headless peer;fix convert-to API partially
Convert-to API got broken in
80786cc79d

In case of convert-to API, there is no actual client facing
websocket connection (and we use an invalid websocket
connection). So, when prisoner session tries to forward messages to
client it would fail as we have now started to propagate errors
from forwardToPeer.

Introduce a headless (without an actual client) peer mode, and
fail silently when someone tries to forward messages to such a peer.

Change-Id: I8a9f93f798dca9fea45c41e99bf373cd23d32e2c
2016-07-21 12:37:44 +05:30
Ashod Nakashian
e7078ef49b loolwsd: keep private things private
Reviewed-on: https://gerrit.libreoffice.org/25619
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
(cherry picked from commit 95b4807e05d0edd8caaa191b2230e363f15523bb)

Change-Id: I8fff570c9033bdc5694cec5a7056e9efc9de967a
Reviewed-on: https://gerrit.libreoffice.org/25624
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-29 17:34:40 +00:00
Ashod Nakashian
3cc295b7d2 loolwsd: remove thin wrapper
Change-Id: Id84a404aecd7f553665e65c1959dcca45309199e
Reviewed-on: https://gerrit.libreoffice.org/25240
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 03:29:51 +00:00
Ashod Nakashian
32ee3d0650 loolwsd: socket sending returns success or failure
Change-Id: I3f486b236e5b6a83292a9d7f3e4931e5235f3a33
Reviewed-on: https://gerrit.libreoffice.org/25239
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 03:28:16 +00:00
Ashod Nakashian
7f62bb54fd loolwsd: unified forwardToPeer
Change-Id: Ib12626adad1ff3cf647d6a32f9b1eae35f794b2f
Reviewed-on: https://gerrit.libreoffice.org/25238
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 03:26:15 +00:00
Ashod Nakashian
7444ad4348 loolwsd: check for null WS before shutdown
Change-Id: I47ad44cdfdbcac61bf64bf9e698f23c502a748a5
Reviewed-on: https://gerrit.libreoffice.org/25235
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 03:19:46 +00:00
Ashod Nakashian
d1d5cff3e3 loolwsd: MasterProcessSession splitting: moved forwarding and shutdown
Change-Id: I3c84d9be328e58263cac9c3b1b501ef91ea30170
Reviewed-on: https://gerrit.libreoffice.org/25048
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-17 03:22:41 +00:00
Ashod Nakashian
cf26d9191c loolwsd: MasterProcessSession splitting: member function scope
Change-Id: I3fa43f761ccc93d52badff346941de2a8cd9de03
Reviewed-on: https://gerrit.libreoffice.org/25043
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-17 03:18:17 +00:00
Ashod Nakashian
8af51d0270 loolwsd: MasterProcessSession splitting: moved loadDocument
Change-Id: Iaf32014ab5cbceb6ca5d443a85b0d03d6ccd9876
Reviewed-on: https://gerrit.libreoffice.org/25041
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-17 03:14:57 +00:00
Ashod Nakashian
df67c4a31c loolwsd: move tilecombine handling into lokit
Change-Id: I32854769c5260444b0e97c112a141028f1cda179
Reviewed-on: https://gerrit.libreoffice.org/24641
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-04 10:36:38 +00:00
Ashod Nakashian
1117be07c4 loolwsd: expose sending binary frame on Sessions
Change-Id: I5e81ced0511e44dc5f3445dae42f4354da164b3a
Reviewed-on: https://gerrit.libreoffice.org/24579
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-02 02:53:04 +00:00
Ashod Nakashian
1dd88e68ea loolwsd: shortened some long identifiers
Change-Id: I87809f5ad2a6d8f546cf3abaf646672d2d8168dc
Reviewed-on: https://gerrit.libreoffice.org/24471
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-29 01:05:45 +00:00
Michael Meeks
8f7eed639c Re-factor tile subscription logic.
Move the logic into the TileCache, simplify the API, and
internalize the lock. This should be a plain re-factor.
2016-04-23 18:03:42 +01:00
Jan Holesovsky
06366c2e4c Fix build. 2016-04-21 11:36:47 +02:00
Ashod Nakashian
5fbaa8f3d2 loolwsd: useractive and userinactive command support
loleaflet can now send userinactive when the user
has switched tabs or the browser window loses
focus. Similarly, it can send useractive when
focus is regained.

Change-Id: Id3186949b10a8263e29ada1a790d3123a79e8f08
Reviewed-on: https://gerrit.libreoffice.org/24272
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-21 05:31:18 +00:00
Henry Castro
c29944a386 loolwsd: fix close after close
The closing handshake.
Either peer can send a control frame with data containing
a specified control sequence to begin the closing handshake.

Upon receiving such a frame, the other peer sends a
Close frame in response, if it hasn't already sent one.
2016-04-18 20:27:27 -04:00
Tor Lillqvist
4087ac8089 With "disconnect" messages gone, no need for a 'reason' to disconnect()
YAGNI.
2016-04-13 15:56:23 +03:00
Ashod Nakashian
b6d2edb0e3 loolwsd: moved activity tracking into LOOLSession
Change-Id: I87d5afc43bea29ede2ad6e2871c594c4746bc3d5
Reviewed-on: https://gerrit.libreoffice.org/23948
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-04-10 03:32:58 +00:00
Tor Lillqvist
b6419ee915 Include only what you use 2016-04-04 09:31:52 +03:00
Tor Lillqvist
e55df2d021 The jailed processes are not "loolwsd" in any sense any more 2016-03-20 21:52:27 +02:00
Tor Lillqvist
e8a5ba1b29 _bShutdown is always false 2016-03-08 09:45:23 +02:00
Tor Lillqvist
e7e1ef58ae Cosmetics: Sort and prune #include and 'using' lines 2016-03-08 09:44:04 +02:00
Pranav Kant
b71ebb8dfc loolwsd: Ask for password for multiple views also
This is possible by moving all the password handling logic to
Document container class. When a user opens a password protected
document the first time, it saves all possible data such as
password, password type etc. Upon opening the same document
again, password is matched with the cached password saved in the
document container class before allowing the new view access to
this document.

Change-Id: Id1f2b6e06de806564bf865e83fed51b01c9a0fbc
Reviewed-on: https://gerrit.libreoffice.org/22208
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 22:00:46 +00:00
Pranav Kant
3667bef9a6 loolwsd: Handle password protected documents
Change-Id: Iceb5bb598ef1517bf640994c27bad4ca36bd72c1
Reviewed-on: https://gerrit.libreoffice.org/21894
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-02-19 21:49:45 +00:00
Miklos Vajna
4b3c5ea8ff loolwsd: doxygenize class comments 2016-01-28 19:16:32 +01:00
Ashod Nakashian
dd374d8aec loolwsd: disconnect command to gracefully shutdown a socket
Change-Id: I8beb4c14fc95bdb2a98c7e5da44408511bce5e28
Reviewed-on: https://gerrit.libreoffice.org/21683
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-21 16:05:55 +00:00
Tomaž Vajngerl
721cbbcbb3 Add "tilecombine" command to render more tiles in one call
When invalidating we need to rerender more tiles at once.
This change optimizes that with a new command which rerenders a
larger area once and then separates the rendered buffer into more
tiles. This generally decreases the invalidation time by 2-4 times
and in some cases (when invalidating images in document) up to 9
times.
2016-01-14 13:11:57 +01:00
Ashod Nakashian
06c20923c5 loolwsd: Kit is given the jailed path
Change-Id: I5b475798c7f654aaa3e0032332d5aa97a103a4c8
Reviewed-on: https://gerrit.libreoffice.org/21185
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-07 05:58:08 +00:00
Ashod Nakashian
900c344a7e loolwsd: refactored JailedDocumentRoot path
Change-Id: Ibee16e6ebde0ae1945be53903a0b0bad4f3300ed
Reviewed-on: https://gerrit.libreoffice.org/21179
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-01-07 05:53:39 +00:00
Henry Castro
7fc04b6e71 loolwsd: stop dispatch child when closed websocket prison 2015-12-28 17:05:01 -04:00
Ashod Nakashian
3811abb40a loolwsd: replaced threadId with globally unique sessionId
Change-Id: I55b16d4baa1753bc67dcd72de13e7a516da27abe
Reviewed-on: https://gerrit.libreoffice.org/20981
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-28 04:14:15 +00:00
Ashod Nakashian
42d07b2aea loolwsd: refactored LOOLSession::handleInput to handle errors
Change-Id: I3be929242317f4fafcb62c55d3532b2fbfd6591b
Reviewed-on: https://gerrit.libreoffice.org/20947
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2015-12-26 03:58:51 +00:00
Henry Castro
1f43e99ac7 loolwsd: Refactored ChildProcessSession
ChildProcessSession class now moved to own files.

Change-Id: Ic67c8563ada51f23c83e06631ad913af610d395c
Reviewed-on: https://gerrit.libreoffice.org/20895
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Henry Castro <hcastro@collabora.com>
2015-12-23 17:03:43 +00:00