Commit graph

66 commits

Author SHA1 Message Date
Tor Lillqvist
3b4269a301 Use Util::symbolicErrno()
I think the general policy should be to always log errno using both
Util::symbolicErrno() and std::strerror(), never log a naked errno.
But only in cases where we know that it is highly likely that it is
the most recent system call that has failed, so errno makes sense.

Change-Id: I4a1fb31e375ea949e7da17687464361efe7c1761
2018-07-11 13:05:22 +03:00
Ashod Nakashian
b3bdd5786d wsd: support optional forcing tracking changes at load
Since changing the tracking state is done by toggling,
we need to wait to get the current state at load time
before we can tell whether we need to toggle it or not.

Change-Id: Ib5a2639b2acf3874c191971eedf9a3bebcefebad
Reviewed-on: https://gerrit.libreoffice.org/53415
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2018-06-14 17:00:39 +02:00
Marco Cecchetti
6a0fcdf15f wopi flag for hiding the change tracking controls from UI
Change-Id: I1b9aa4f8111d77ae12093022205fad1cbee850ac
Reviewed-on: https://gerrit.libreoffice.org/53335
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2018-04-24 18:15:44 +02:00
Pranav Kant
6bb38614bd Some helpful logging
Change-Id: I75e5e6cbbecf1e1af94a6710ecab4ced5637f14f
2018-03-23 16:50:28 +05:30
Ashod Nakashian
5befd0803a wsd: improved wopi info parsing
Better logging during wopi info parsing,
especially upon failures.
Refactored the code from Storage.cpp into
JsonUtil.hpp.
Minor optimizations.

Add unit-tests for the parsing logic.

Change-Id: Ifebc3f6b7030a6c7b3b399786633f6b5e8737478
Reviewed-on: https://gerrit.libreoffice.org/49927
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2018-02-23 16:54:39 +01:00
Andras Timar
baa3e09bde Typo: remove -> remote
Change-Id: I6214f569d6a0302c5a5a69a18150122a371e0d03
2018-02-14 12:29:50 +01:00
Michael Meeks
d2f23dd8c2 Helpful error on non-matched WOPI host.
Change-Id: Ib752148be0acbf15cd8b737b71414313d05f6aca
2018-02-10 17:12:40 +01:00
Miklos Vajna
1dde430bcf wsd: spell out non-trivial autos to improve readability
Change-Id: I0e1f169fc39e5c722704e1cae487147d929f7350
2018-02-07 10:18:12 +01:00
Pranav Kant
0547507b67 wsd: Fix incorrect file size reported
Close/flush the file after copying into it so that we can calculate the exact
filesize later on.

Change-Id: I30aca9d0ac3702394a4465c30c61954a726eec39
2018-01-19 12:58:58 +05:30
Ashod Nakashian
c06376cc1d wsd: cleanup logging and remove unused helpers
Now all logging is done after checking if the
level in question is enabled or not (thanks to
the macros LOG_XXX), which saves unnecessary
conversions and stringification when said level
is disabled.

Change-Id: Icde31e067f60269563896f04f8b0d65643720766
Reviewed-on: https://gerrit.libreoffice.org/47885
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2018-01-19 00:33:40 +01:00
Pranav Kant
f63858433b loplugin:includeform
Change-Id: Ib62a7aa61062f00698aa3e8a144438de5c57e53d
2017-12-20 21:21:05 +05:30
Jan Holesovsky
b20faa8bdc Save As: Advertise the correct size when uploading the new file.
Change-Id: I9b20c4bdb7ddc848437edceae1a77ddb49d55133
Reviewed-on: https://gerrit.libreoffice.org/44357
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2017-11-10 11:08:53 +01:00
Tor Lillqvist
4ab070ec38 Sort #include and using lines for consistency
... but did not have the time or energy to do it in all files.

Change-Id: I92ea101cae1ad7be0fd2f31ce5a8d4b4149332c9
2017-11-08 10:34:37 +02:00
Tor Lillqvist
12aaff7d1a Bin some superfluous vertical whitespace
Change-Id: I770342c34c87e38597d5eb3695c432af69273ce1
2017-10-31 12:09:52 +02:00
Jan Holesovsky
6745464c70 tdf#99744 SaveAs: Report back to loleaflet that the saveas succeeded.
Change-Id: I670c8b4503c1a4c0a88001a1343f6dec2974e044
2017-10-26 11:11:38 +02:00
Jan Holesovsky
6fe4484395 tdf#99744 SaveAs: Use X-WOPI-SuggestedTarget instead of X-WOPI-RelativeTarget.
And the correct encoding - UTF-7 (huh).

Change-Id: I6634fedb598c620128cc25a3e8fdc46e4096a756
2017-10-26 11:11:38 +02:00
Jan Holesovsky
7ff432a370 tdf#99744 SaveAs: Reimplementation of the PutRelativeFile going through Kit.
This is necessary so that changing of the file type works.

Includes a unit test.

Change-Id: Id01d44e555b6bac1002ff950de461fd330602f63
2017-10-26 11:11:38 +02:00
Jan Holesovsky
f4198526ca tdf#99744 SaveAs: Reverts parts of the previous Save As work.
It is necessary to go through the Kit when performing the Save As, so that we
can change the file type, sync with loading the file, etc.
2017-10-26 11:11:38 +02:00
Pranav Kant
6a73c19d16 Show save-as option based on CheckFileInfo params
If UserCanNotWriteRelative is mentioned in the CheckFileInfo response.

Change-Id: I33d2e21159b3e18ae88fd72f404f2d1d1d9b64e5
2017-10-03 20:58:36 +05:30
Jan Holesovsky
7f49b1eba6 PutFile ext: X-LOOL-WOPI-IsAutosave header to indicate autosave + unit test.
Change-Id: I65ed711dae5100467fe6ed9902bd7bad8c7f8d68
Reviewed-on: https://gerrit.libreoffice.org/43074
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2017-10-03 12:04:18 +02:00
Jan Holesovsky
5c604e9f78 PutFile ext: X-LOOL-WOPI-IsModifiedByUser header to indicate modifications.
Change-Id: I5d69903211045969d678df695717eae7452e7f04
Reviewed-on: https://gerrit.libreoffice.org/42852
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2017-09-27 16:36:02 +02:00
Marco Cecchetti
dee39a562c support for rendering a watermark on each tile
Change-Id: I3edccac49a3bcd3d2493d8d7ef3a1ae29307e727
Reviewed-on: https://gerrit.libreoffice.org/41898
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2017-09-07 17:28:44 +02:00
Jan Holesovsky
f7c199684c WOPI extension: DisableInactiveMessages to avoid showing message when dimmed.
Change-Id: I925602295dde95611ab1a6565dd7266460769a50
Reviewed-on: https://gerrit.libreoffice.org/41709
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2017-08-29 19:44:33 +02:00
Pranav Kant
da4fe86b82 wsd: Do not throw when cannot save local file out of jail
Change-Id: Ie155823536694facb8bfcfe49f6386a7fc845689
2017-08-22 19:50:19 +05:30
Pranav Kant
769e41dfb2 Fix build
Mismerge. There is no session->getAccessToken now

Change-Id: I4d8f2cc612cbd39b3163bcdbba5df8ea5d732774
2017-08-18 07:14:33 +05:30
Aditya Dewan
c3711a4375 Extending WOPI implementaion to introduce 'Save As' feature
Change-Id: Ic4c80f4c4b54944143682c25a5878c1336787b27
Reviewed-on: https://gerrit.libreoffice.org/40946
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2017-08-17 19:25:44 +02:00
Jan Holesovsky
afcfac4bef access_header: Infrastructure for providing custom headers for authentication.
Change-Id: I52e61dc01dbad0d501471e663aaf364d9bc23c52
Reviewed-on: https://gerrit.libreoffice.org/41223
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2017-08-17 13:40:57 +02:00
Jan Holesovsky
beffd4967a convert-to: New features in the convert-to functionality.
* Add possibility to omit the 'format' parameter
* Allow it even when the 'file' storage is disabled

Change-Id: Ib8dcad5f81499aec0ba147a3a4ef0b7a30995bcc
2017-08-07 11:32:10 +02:00
Henry Castro
a262b7d7ba wsd: OAuth token passing
MS-WOPI:
"The following HTTP header MUST be included in all WOPI requests."
"Authorization "Bearer" and <token>"

Change-Id: Ie5327286e93b86a49a0248ff5886bf3ea99df768
2017-08-03 17:11:00 -04:00
Miklos Vajna
01bf6ab344 wsd: use the more effective overload accepting a character in Storage
I guess checking for "{" in parseJSON() happens for performance reasons,
but then it's a good idea to also avoid constructing a temporary string
for no reason.

Change-Id: I285ba0ed615054fc014796f7d8971a2b9783b075
2017-07-06 11:17:33 +02:00
Aditya Dewan
c29815f42c Assign unique editorId to localhost users
Change-Id: I1c8949fa7acca1b11b35b48629cc20a1170d8caa
Reviewed-on: https://gerrit.libreoffice.org/39442
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2017-07-06 09:17:23 +02:00
Michael Meeks
7b90179fe8 Check for spare space in the right place.
ie. destination not source of the local file.

Change-Id: I4d4c4e56deb039a44d8c2ab2886b8ca52bdb2ef8
2017-06-16 20:25:23 +01:00
Pranav Kant
db13014e00 Update modifiedTime for local files unconditionally
Also teach logger to print timestamp object.

Change-Id: Ia13836814c195cef92f5dafd8245c9958600876d
2017-06-16 19:49:37 +05:30
Pranav Kant
41234773e3 If user permits, save to storage force-fully in case of doc conflict
There is one known problem still - after any user decides to overwrite
the file to storage, other users are not informed, so their dialog keeps
hanging on the screen until they press the cancel or reload button.

Change-Id: I6dad1585e4c53eeed79cd38316892a7f239d44ef
2017-06-01 19:53:10 +05:30
Pranav Kant
4d61cae4c8 If user commands, refresh the document for all in case of doc conflict
Change-Id: I42c61fb8099b0bcc60f942e602561cc97486a918
2017-06-01 19:46:38 +05:30
Pranav Kant
ba4e75cfae Inform all clients when document changed behind our back
Introduce a new header X-LOOL-WOPI-Timestamp

This is a WOPI header extension to detect any external document change. For
example, when the file that is already opened by LOOL is changed
in storage.

The WOPI host sends LastModifiedTime field (in WOPI specs) as part
of the CheckFileInfo response. It also expects wsd to send the
same timestamp in X-LOOL-WOPI-Timestamp header during WOPI::PutFile. If
this header is present, then WOPI host checks, before saving the
document, if the timestamp in the header is equal to the timestamp of
the file in its storage. Only upon meeting this condition, it saves the
file back to storage, otherwise it informs us about some change
to the document.

We are supposed to inform the user accordingly. If user is okay
with over-writing the document, then we can omit sending
X-LOOL-WOPI-Timestamp header, in which case, no check as mentioned above
would be performed while saving the file and document will be
overwritten.

Also, use a separate list of LOOL status codes to denote such a change.
It would be wrong to use HTTP_CONFLICT status code for denoting doc
changed in storage scenario. WOPI specs reserves that for WOPI locks
which are not yet implemented. Better to use a separate LOOL specific
status codes synced across WOPI hosts and us to denote scenario that we
expect and are not covered in WOPI specs.

Change-Id: I61539dfae672bc104b8008f030f96e90f9ff48a5
2017-06-01 16:17:07 +05:30
Pranav Kant
15a4474572 Remove superfluous WOPI calls to getFileInfo to check timestamp
One can add the timetamp information in the PutFile call itself. This
way we can avoid making an extra CheckFileInfo call here.

Change-Id: Iae180262e648c36b9cfeb6d5fabdf5d243b93afb
2017-06-01 16:17:07 +05:30
Pranav Kant
cf968e6768 Factor out iso8601 to Poco::Timestamp parsing
Change-Id: I627a7b6b72899371e880e461685f99a86a858232
2017-06-01 16:17:07 +05:30
Pranav Kant
d840e8720a Handle WOPI PutFile unauthorized access token
Change-Id: I29ee8cc0c9f3ea42f70628eca6f74d161d1a38f9
2017-05-31 12:08:31 +05:30
Ashod Nakashian
da2d3cbc92 wsd: support per-user links and commands
userextrainfo is a json array that contains
extra user-specific links.

Currently 'avatar' is assumed to hold the
image url for the user's avatar.

'mail' and other links can also be added.

Change-Id: I37c4c68bfa0b7ee659e017b4867dcb8cf5c2ca2f
Reviewed-on: https://gerrit.libreoffice.org/38120
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-29 06:45:18 +02:00
Ashod Nakashian
4e6fee5407 Hide connecting spinner on authorization failure
Also, fix regression resulting in "This is embarrassing..."
instead of "Unauthorized..." message.

Change-Id: If6219bfbc445b186bb4064b3f20a0ccd2854d617
Reviewed-on: https://gerrit.libreoffice.org/37893
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-22 07:06:50 +02:00
Pranav Kant
aed840ea04 Didn't mean to truncate this string literal
Otherwise getStatus() returns an integer which increments the char*

Change-Id: I189addb60a02de14085b1501c75362b13dcb3ae2
2017-05-19 21:04:03 +05:30
Pranav Kant
bcf958c500 wsd: Fail gracefully when storage misbehaves
When WOPI's CheckFileInfo or GetFile responds with status code other
than HTTP 200, show a message to the user indicating some problem in the
storage.

Currently, we open an empty document if storage doesn't return a
document which surely is not correct.

Mention the storage server address when asking user to contact the
server administrator to be more friendly.

Change-Id: I15f0489f36db8689b43d42f6b691fdd21815e4fa
2017-05-19 20:53:42 +05:30
Jan Holesovsky
9db41725f4 Revert "wsd: use WOPI host instance ID to support hostname aliases"
Turns out this introduces two calls to the CheckFileInfo which is not really
what we should be doing; instead, let's do a kind of cannonicalization in the
WOPI host directly.

This reverts commit ec2fd0844f.

Change-Id: I311bf8a45b706ed9a4d8cd00db0a990ac6d461b4
2017-05-19 10:34:38 +02:00
Pranav Kant
1717bfbc0b Silence -Werror=unused-parameter in non-debug builds
Change-Id: Ib4c91e52d4ac78b3bafe3d078e41c79b50ca87a8
2017-05-17 16:43:31 +05:30
Pranav Kant
8a02e7a8fa wsd: Debugging environment vars to debug storages
Also, extend the LOOLProtocol::tokenize to accept a custom delimeter.

Change-Id: I7f789e703c5c8d2ad325b3dd149ba888c722f5f3
2017-05-17 16:30:33 +05:30
Ashod Nakashian
ec2fd0844f wsd: use WOPI host instance ID to support hostname aliases
The docKey creation moved to Storage where we first
invoke WOPI (if/when it's a WOPI-hosted doc and WOPI enabled)
and see if the user has access to the document at all.
If they do, we expect the server to give us a
unique ID to use for identifying the host regardless
of hostname aliases.

If a unique ID is not returned (i.e. empty or missing)
we use the hostname and port in its place as fallback.
This will break hostname aliases, but it will still work.

Change-Id: I407b0087395f9df6ad9cc6e037570487999be4a4
Reviewed-on: https://gerrit.libreoffice.org/37697
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-17 04:18:31 +02:00
Ashod Nakashian
6e63c80763 wsd: handle WOPI access failure
Show the user that authorization failed.

Change-Id: Iad63c11ac2033eee80062ecd43dff76f776924c3
Reviewed-on: https://gerrit.libreoffice.org/37610
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-15 05:14:30 +02:00
Ashod Nakashian
d267b86bbd wsd: include version in http agent strings
And move the WOPI agent string to Common.hpp.

Change-Id: Ife679705bcd6914ddd45ad50446e690fb22dd317
Reviewed-on: https://gerrit.libreoffice.org/37607
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-15 05:10:06 +02:00
Jan Holesovsky
95e892168c wsd: When connecting new sessions, always use the original URI...
...but in combination with the appropriate session's access_token to always
authenticate against the same instance of the WOPI host.

Change-Id: Ic94dfa8fcb226a2d134272b22edc1f8f76c24e34
2017-05-12 18:07:23 +02:00