Commit graph

186 commits

Author SHA1 Message Date
Ashod Nakashian
853135decd loolwsd: SocketProcessor can be named and name used in logs
Change-Id: I599b6f7308690b49a0e9ed3c23b88dbcb2ed8848
Reviewed-on: https://gerrit.libreoffice.org/30830
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:32:46 +00:00
Ashod Nakashian
92ca5225a5 loolwsd: logs and consistent formatting
Change-Id: If32bb829b125678c6e8f83c39a3812098f3b38a3
Reviewed-on: https://gerrit.libreoffice.org/30827
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:30:47 +00:00
Ashod Nakashian
71c5f6c303 loolwsd: simplify PrisonerSession
Change-Id: If626b9e5ceb206480f29d4b4b70eeffca55a83c2
Reviewed-on: https://gerrit.libreoffice.org/30823
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-14 05:27:52 +00:00
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
b1cec28cc3 This was only meant for debugging.
Change-Id: Ia31847ab45c1aa18b5d9d4187ac552d7486331e7
2016-11-10 16:30:38 +05:30
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
2507f7f89c loolwsd: refactor DocumentBroker load and addSession
Change-Id: I01db44561f79280f152bdf802efcbc064b22ab89
Reviewed-on: https://gerrit.libreoffice.org/30646
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:43:12 +00:00
Ashod Nakashian
f3ffd59860 loolwsd: assert ChildProcess doesn't destroy DocumentBroker
Change-Id: Iff20323f809f255557e05652ba08f7688b823fe1
Reviewed-on: https://gerrit.libreoffice.org/30645
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:42:40 +00:00
Ashod Nakashian
f669891892 loolwsd: name the child socket thread
Change-Id: I079d821522b016cbd70a958b6a3e908a32b61f37
Reviewed-on: https://gerrit.libreoffice.org/30644
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:41:22 +00:00
Ashod Nakashian
f1f1ff7057 loolwsd: correct document loading and error handling
Change-Id: I7529c8584356f5eea3c91b5d5ffdd6a956710241
Reviewed-on: https://gerrit.libreoffice.org/30640
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:37:36 +00:00
Ashod Nakashian
71f2f4921d loolwsd: better use named variable than it->second
Change-Id: Ia336b9001911dfd2cf1c19c1536f52bed7684a2a
Reviewed-on: https://gerrit.libreoffice.org/30639
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:36:52 +00:00
Ashod Nakashian
11a0d016ca loolwsd: inline and simplify connectPeers
Change-Id: I64fbeefa59573eb9e467dc18ecbf75ebd72b3be4
Reviewed-on: https://gerrit.libreoffice.org/30638
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:36:24 +00:00
Ashod Nakashian
4e13f1b37c loolwsd: cleanup document and storage loading in WSD
Change-Id: I4d6bdda131efb6270fbd5864034ac619cf86ef3d
Reviewed-on: https://gerrit.libreoffice.org/30637
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:36:04 +00:00
Ashod Nakashian
9bb6d73fda loolwsd: DocumentBroker logs updated
Change-Id: I64bd10c05a24f1b6716241cf1048af157282fa18
Reviewed-on: https://gerrit.libreoffice.org/30632
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:33:33 +00:00
Ashod Nakashian
800e711321 loolwsd: proper ChildProcess cleanup
Change-Id: If9be827aa50471b7d1d922402414d028ccdcff8b
Reviewed-on: https://gerrit.libreoffice.org/30629
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:32:10 +00:00
Ashod Nakashian
3993757ee8 loolwsd: fix race while creating new documents
This fixes the race rather than trying to patch it.
It still minimizes the locking necessary to a minimum
to maximize parallelism.

The approach is to have at least the DocBrokers lock
or the DocumentBroker lock (if we already have a doc)
while creating new document views.

Change-Id: I96b4f17b3be3d03cd5e6f4d17d39e2165fe008a7
Reviewed-on: https://gerrit.libreoffice.org/30628
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:31:26 +00:00
Ashod Nakashian
8b9372d517 loolwsd: improved ChildProcess message handling logs
Change-Id: I28a1de58f4c886d7c6f8c9f723a84e2a8726edc2
Reviewed-on: https://gerrit.libreoffice.org/30625
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:29:40 +00:00
Ashod Nakashian
0305cf4819 loolwsd: more efficient child message forwarding
Change-Id: I60ab308b2f7d108ee9e4f2892fe3dda68f7f3201
Reviewed-on: https://gerrit.libreoffice.org/30621
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-07 06:26:05 +00:00
Ashod Nakashian
d17d148880 loolwsd: logging improvements
Change-Id: If291bf20ae59085f2120d4c92a26de6ccddbc98a
Reviewed-on: https://gerrit.libreoffice.org/30553
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-04 05:17:57 +00:00
Ashod Nakashian
61488cce78 loolwsd: move child communication logging
...and simplify the message (new line not needed).

Change-Id: Ic304d39e444b13c140e16dbe232c2cb03659ff99
Reviewed-on: https://gerrit.libreoffice.org/30551
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-04 05:11:43 +00:00
Ashod Nakashian
84fb2d43fb loolwsd: warn if sessions remain by ~DocumentBroker
Change-Id: I03be11b02af7560f934b138e86f8857fd9870a60
Reviewed-on: https://gerrit.libreoffice.org/30550
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-04 05:04:47 +00:00
Ashod Nakashian
05d4234208 loolwsd: more efficient client message forwarding
Change-Id: I10f880059380599cf0187064e1009bef5fa693b1
Reviewed-on: https://gerrit.libreoffice.org/30492
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-02 13:21:44 +00:00
Michael Meeks
e48f9d7557 loolwsd: remove assertion that sessions are cleaned up nicely. 2016-11-02 01:23:00 +00:00
Michael Meeks
2b9ae4b263 DocumentBroker - hold mutex while iterating over _sessions. 2016-11-01 23:38:25 +00:00
Tor Lillqvist
be22779c21 Assertion failures are for developers to read
'_sessions.empty()' does not need a verbal explanation. We don't do
those in other assertions in the same file anyway.

(Also, I dislike the use of exclamation marks, especially in contexts
that by themselves already are alerts, like in assertion failure
messages. Exposure to LibreOffice source code with its style (in some
neighbourhoods) of multiple exclamation marks, even, in comments,
makes you like that. Exclamation marks makes your comments or messages
look like check-out tabloid headlines.)
2016-10-31 18:06:40 +02:00
Ashod Nakashian
c8eb2ba612 loolwsd: cleanup tile response handling
Change-Id: I34b76b463c05e3479d1fd1516906c9a75282c753
Reviewed-on: https://gerrit.libreoffice.org/30419
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-31 06:08:01 +00:00
Ashod Nakashian
c96c13f014 loolwsd: expect no sessions when destroying DocumentBroker
Change-Id: Ib8244cd8ae6449a07eb010fba4b26ec5bad09162
Reviewed-on: https://gerrit.libreoffice.org/30418
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-31 06:07:10 +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
cfcc6bdd94 tdf#103450: Implement WOPI initialization postmessage API
This includes support for Host_PostmessageReady and
App_LoadingStatus

Change-Id: Iaa0222dfa63c17b26a4fcb2236973bacdd61ee62
2016-10-26 21:34:11 +05:30
Pranav Kant
cccf6dcb7d loolwsd: Store UserId in ChildSession
Change-Id: I46593442f7f8c61bddf00a624977c9d32bffdf44
2016-10-26 21:10:15 +05:30
Pranav Kant
cc184ea2c2 loolwsd: Separate FileInfo classes for different storages
The idea, for now, is to call the storage specific fileinfo
functions (getLocalFileInfo, getWOPIFileInfo) which returns the
file + user specific data for given URI. By user specific, it
means data which is token (provided in URI) dependent.
For WOPI, it would mean various user permissions
(editable/viewable etc.)

For our current storages, these calls also include the basic file
information which is common across all tokens. This can be
retreived by calling getFileInfo on the storage object.

Change-Id: Ibbd3b74b011d8bb6fe4730c33276ef9ac6c47103
2016-10-26 20:13:34 +05:30
Pranav Kant
36fece8b07 loolwsd: Separate WOPI load duration and check fileinfo duration
Add both of them and send them as wopiloadduration to the client,
if storage is WOPI.

Change-Id: I5652d346d70f473624f03536469acf45470db742
2016-10-24 16:04:28 +05:30
Pranav Kant
050bf4c65e loolwsd: Remove this comment - this is fixed now
Change-Id: I032c7e4a1609b68882dba6cc48ebd3fb2d59b8f5
2016-10-24 12:21:33 +05:30
Ashod Nakashian
f0c3365f9f loolwsd: improve ChildProcess cleanup
Change-Id: I9852f04021097800d5ab0ce775f26fada5f3c8e7
Reviewed-on: https://gerrit.libreoffice.org/30207
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 21:11:19 +00:00
Ashod Nakashian
47ed5e40dd loolwsd: kill assertIsNotLocked
It was intended to assert that the *same* thread
hadn't locked, not any. As it stands, it's problematic
and was decided to let go.

Change-Id: Iddb76f0edd62b7cdca062c2aa924b08e3d7952ef
Reviewed-on: https://gerrit.libreoffice.org/30205
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 21:09:43 +00:00
Ashod Nakashian
6c0be6d90d loolwsd: move admin updates into DocumentBroker
Change-Id: Ic35198a7e4457a775fac25954279501e37b94b42
Reviewed-on: https://gerrit.libreoffice.org/30199
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 21:05:28 +00:00
Ashod Nakashian
167f0bf70c loolwsd: throw an exception rather than rethrow nothing
Change-Id: I1b85978d3049b39a15fded31582c2d6a62d90689
Reviewed-on: https://gerrit.libreoffice.org/30186
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-23 20:56:22 +00:00
Michael Meeks
0b93441eff Improving the built-in unit tests.
Connect sockets to the local process using the details we can introspect.
Implement unit test for storage / load failure.
Cleanup tile-cache test a little.
2016-10-22 16:43:41 +01:00
Andras Timar
0cdc9d70b5 loolwsd: fix error: declaration of ‘isLoaded’ shadows a member of 'this' [-Werror=shadow] 2016-10-20 11:03:24 +02:00
Pranav Kant
1be2a78564 Handle WOPI's UserCanWrite to determine readonliness
permission= parameter in URL is still supported, but overridden
by UserCanWrite parameter.

Also, introduce a new protocol message, perm: which dictates
loleaflet about the permission rather than the other way around
(only in case of WOPI)

It is to be noted that by default loolwsd assumes very
restrictive permissions, so not providing UserCanWrite in WOPI
implementation by a WOPI host would lead to opening of only
readonly session.

Change-Id: I2013c1661fd491c79bb367a41e1a7036fa03f984
2016-10-19 20:47:20 +05:30
Pranav Kant
ef32f30017 loolwsd: Fix a crash due to invalid fileinfo
Throw if document load fails. Ignoring such a scenario would lead
to crash later in the document load process.

Change-Id: Ie80fc4f26e08e4920d4c04726f947edd2837a0cf
2016-10-19 15:51:29 +05:30
Michael Meeks
8d4c5d4e68 Avoid deadlock when notifying users of document load failure. 2016-10-18 21:51:33 +01:00
Ashod Nakashian
d266d124df loolwsd: argument cleanup
Pass std::string instead of char* and length where
a string is always constructed anyway. Also cleaner
and safer code.

Change-Id: I1c9341e2c81bbdb7adeb29d3fba59849b2617e95
Reviewed-on: https://gerrit.libreoffice.org/29954
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:14:00 +00:00
Ashod Nakashian
4f4472ffa6 loolwsd: shutdown client sockets and cleanup when kit dies
Change-Id: I4d59553d744a8075d4d873ff520d9f3e417521b3
Reviewed-on: https://gerrit.libreoffice.org/29947
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:10:43 +00:00
Ashod Nakashian
c1ee1f5102 loolwsd: stop ChildProcess WS on TerminationFlag
Change-Id: I303dedb8254a9b815dd0b2c5d0a62cc5345af062
Reviewed-on: https://gerrit.libreoffice.org/29943
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:08:15 +00:00
Ashod Nakashian
7043b95f4d loolwsd: fix convert-to after removing Prisoner WS
Change-Id: I652a9fffa267e01043262eb25d3c2e19bf9eb447
Reviewed-on: https://gerrit.libreoffice.org/29940
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:06:05 +00:00
Ashod Nakashian
b44d71f0ae loolwsd: no need to create prisoner WS anymore
Change-Id: Iaebac49f47353a6848fd2232a1838e4eaadaeefc
Reviewed-on: https://gerrit.libreoffice.org/29937
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:04:31 +00:00
Ashod Nakashian
75c99ed9b6 loolwsd: cleanup child process WS interface
Change-Id: I30d74fc25434301145da292711fe5e33972ac876
Reviewed-on: https://gerrit.libreoffice.org/29936
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:03:56 +00:00
Pranav Kant
9ebd7a15e2 loolwsd: Improved loolwsd -> storage communication
Reduces the number of WOPI calls made during a document load. Earlier
effort was made in edfd3266f8
This commit cleans up and uses better approach for the same.

Other than that, access token of each session is now correctly
used when interacting with the storage. Earlier, we used to
use the same access token for each upload to storage which means
that irrespective of who clicked the save button, changes to the
document were only made on behalf of one person (of whom the
access token is used). This is fixed now.

Also includes minor cleanup left and right.

Change-Id: Id32702ff02aea4f63b7cc6afa9f62664807bb57d
Reviewed-on: https://gerrit.libreoffice.org/29931
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-10-16 22:02:25 +00:00