Commit graph

1923 commits

Author SHA1 Message Date
Szymon Kłos
38731d5818 Allow pasting into document even when DisableCopy is active
From our API description:
DisableCopy
Disables copying from the document in libreoffice online backend.
Pasting into the document would still be possible.

Change-Id: I1f7e272ad3b04208b534eff990fed895951b4751
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
2021-07-28 13:00:45 +02:00
Tor Lillqvist
522431a82e We generate 'S' and 'F' "Async" Trace Events in loleaflet, not 'b' and 'e'
"Async" here refers a specific kind of data in the Trace Event JSON
format, not asynchrony in general.

Actually, we don't have code that would generate such yet in
loleaflet. Just the createAsyncTraceEvent function in Socket.js. Quite
possibly the "Complete" events (a.k.a. ProfileZones) are all we need.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I611ccd4b964bcacdd1050893f70dbdb813ee3c34
2021-07-21 13:26:23 +03:00
Michael Meeks
cd56efe900 cleanup: don't assume that the web-server poll is still alive.
Since a99edb5d29 this gets a different lifecycle, and is often
joined and gone by the time we get to cleanup.

Change-Id: Ic21ca837d484a9a853c7f8f683e876406b00a943
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-07-21 10:03:13 +01:00
Pranam Lashkari
e02e1df76d Introduce Freemium options
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: Ib6b68ff74839cf84f2d8c8cfb7d380be9209f923
2021-07-20 14:41:18 +05:30
Ashod Nakashian
4c87cc36ff wsd: Close socket hard when necessary
Also clear its input buffer explicitly.

Change-Id: I8badbb96d98eaf10433a65fcfd13b0d6d5893594
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>

Ignore input in a somewhat gentler way.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I758302dc3bb1aa87f9fbfa726f73f4b9339e08c2
2021-07-19 17:31:55 +01:00
Ashod Nakashian
90f0360ada wsd: close the connection after failing to load
Change-Id: I571c9afba3ae2d9be83382dab571902669e8b059
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-19 17:31:55 +01:00
Ashod Nakashian
617b1aeae5 wsd: prevent recycling the listening port during tests
When running tests in parallel, closing the server listening
port before all DocBrokers are terminated runs the risk of
the listening port getting recycled by another test. This
means that the new test might get unexpected connections
from the old test that is shutting down.

This improves test stability.

Change-Id: I2c6ac9e7ed9953813e0da6ab19b960b1edc1d1a8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-18 21:14:48 -04:00
Ashod Nakashian
f63d077916 wsd: ssl certificate verification requirements
Change-Id: I72ffa586310296f1986276c3007672c41146c92b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-18 21:14:48 -04:00
Ashod Nakashian
f702c4efab wsd: support certificate verification
Change-Id: I912595f104e24dc66da9cf06bc211cb0c50c9ff0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-18 21:14:48 -04:00
Ashod Nakashian
14b694e4b8 Revert "wsd: initialize SSL if enabled or termination is enabled"
The original behavior must be preserved, which is not to
initialize SSL when termination is enabled but SSL is disabled.

This reverts commit 1c9541a6a636647086397e1310084cc990b6ed70.

Change-Id: Iba3ed3eea45b6b78e696334ca4d1a4a2c014d95b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-18 21:14:48 -04:00
Ashod Nakashian
0690f23ee4 wsd: move isLocalhost to a common area
Change-Id: I2a7986863138a254a6d74644112f5cd60bb898cd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-18 21:14:48 -04:00
Ashod Nakashian
ae7b0d9a00 wsd: before closing save a copy to upload
If the last upload had failed and we are closing,
make sure to save a new copy (i.e. save even if
unmodified) so we would have the latest version to upload.

Change-Id: I25efb76eaf9c0e05a2d18071b273447803b17cc5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-17 22:58:23 -04:00
Ashod Nakashian
61954dc67a wsd: track saving activity
This prevents auto-saving while a
save is in progress.

Change-Id: I2606df704482ad54a954414d48ed3ca35d4764a9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-17 22:58:23 -04:00
Ashod Nakashian
cc23a03dc0 wsd: correctly update the modified flag
There is an important distinction between
internally saving a document and uploading
the latest saved version to storage.

Core reports the modified state, which was
at some point used to flag the modified state
in the admin console. This state is misleading
if uploading failed.

This patch makes this distinction even more
explicit than it was. We now always update
the modified flag given by Core, and flag
the document as modified in the admin console
too.  But we only update the admin console to
unmodfied when we successfully upload and the
document is not modified at that point (which
it might very well be modified again by the
time we finish uploading).

Without this patch, we stop updating the
modified flag when uploading fails. This
is problematic when said failure occures
right before closing the document, because
the document will have no modification
but we will be stuck thinking it is modified.

This combines two commits:
8c602e179e
and
9db39ce741

Change-Id: I31c72aa2491b8e98597075cd35b6a809fab560a1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-17 22:58:23 -04:00
Ashod Nakashian
9c50fdc155 wsd: better logging of the document activity
Change-Id: I89e673ffa819600bd227fab291a46d9108ed5cca
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-07-17 22:58:23 -04:00
Jan Holesovsky
41c0b1add3 Sanitize the css theming.
Change-Id: Id0eb21fc7e7039bf406c074cd210c6c355bd7dbf
Signed-off-by: Andras Timar <andras.timar@collabora.com>

Sanitize the css theming.

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ifccb58c2bc9a070409c9a4dd9e9e4034e7338469
2021-07-16 11:57:43 +02:00
Michael Meeks
53ac96b025 wsd: don't re-render tiles while closing a session.
During the save during shutdown we can get big invalidation
emissions, there is no point in re-rendering the view at that
stage; so skip it.

Change-Id: Ie85ef57648815a1872ca35dcb1bdfc9fa54e64c0
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-07-12 16:12:27 +01:00
Szymon Kłos
27799f23eb HTTP 302 - updates after review
Change-Id: Iaac4384385e05f33472b6678422b4a444319b59c
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
2021-07-12 08:44:39 +02:00
Szymon Kłos
fef43e237a HTTP 302 Found - block redirection loops
Change-Id: I686a801a7003d14210a0319d421b326b7f8c107a
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
2021-07-12 08:44:39 +02:00
Szymon Kłos
b72c8e9ae6 Handle all redirect HTTP verbs
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I6d8417da1e147c63bc44c3fe238bdda7e3dac1b2
2021-07-12 08:44:39 +02:00
Szymon Kłos
3330293e57 HTTP 302 Found - redirrect support for downloadDocument
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I7030159c1d745f877f927e21bea7caba25c1eb8b
2021-07-12 08:44:39 +02:00
Szymon Kłos
850f3cee71 HTTP 302 Found - remember the correct resource address
remember correct URI so all the following communication
(eg. downloading the file, upload) will be performed on new location.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Id14c5209eb1d9ffc7c24d7e02f0c7c32a60568b7
2021-07-12 08:44:39 +02:00
Szymon Kłos
f8bea2e9c5 HTTP 302 Found - redirrect support for getWOPIFileInfo
With some loadbalancers it may happen that HTTP 302 Found
response with redirect location will appear.

Change-Id: I7bac807761423adcd827cf775bd1d3d2ba87a6cc
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
2021-07-12 08:44:39 +02:00
Gökay Şatır
580d6ba1d3 Session: Send file mode to the client. We need to know if comments are editable or not.
Signed-off-by: Gökay Şatır <gokay.satir@collabora.com>
Change-Id: I607e165b373ca6605ae5d72bf45821e3a3870f76
2021-07-09 21:05:40 +03:00
Henry Castro
e9745e33c4 wsd: log javascript handled exceptions
Change-Id: I09de6d3f1e406e53692eb4ce16644c337c9e3793
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-07-07 09:45:39 -04:00
Tor Lillqvist
bd0c225c9f Revert "Make it possible to generate Trace Events already when loading the document"
Makes unit-rendering-options fail reliably.

This reverts commit 175c9c5b2a.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Id05c911991baaae0dbc52678a192fc01639352e0
2021-07-07 12:38:11 +03:00
Tor Lillqvist
175c9c5b2a Make it possible to generate Trace Events already when loading the document
By passing a traceevent=yes query parameter in the URL. Note that if
Trace Event generation is not enabled in loolwsd.xml this will have no
effect.

It is a bit silly to notice this query parameter only in loleaflet and
then send the information back to the server. Would be better if the
server noticed it itself before sending the URL to loleaflet.

While at it, let's not bother ever enabling Trace Event generation in
the WSD process. That is not what we are interested in.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I985bfd1e2dbd14aa5a55b386b4762fb64bcb4008
2021-07-07 09:28:02 +03:00
merttumer
9137ed9dfa Broadcast save-as to other views
We ask for save as for the plain/text type documents
such as csv or txt. Notify other views about it so
they can follow one to the new document

Signed-off-by: merttumer <mert.tumer@collabora.com>
Change-Id: I4cdcec6148d1064ad4e90ad9be2ce483c19a8eda
2021-07-06 12:38:48 +03:00
Michael Meeks
f946894965 Improve debug output.
Change-Id: If3ca40217be47d5b68290c79137bd8739780347e
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-06-24 13:35:55 +03:00
Tor Lillqvist
596c40eb13 Use S and F events here, too, instead of b and e
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I58970ccc6e6f7e2d9a19b51f8ba1ca8a00a0fd03
2021-06-24 12:32:09 +03:00
Ashod Nakashian
5a310a2232 wsd: separate client SSL context from the server
Change-Id: I4d86f733a16e6c76340b18ff836831ebe6acfd4d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-23 23:39:34 -04:00
Tor Lillqvist
24691998d9 It's Trace Event, not event trace
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I80fe5ff3c7d41d64c101c5487221a43e5145ac63
2021-06-22 16:43:40 +03:00
Tor Lillqvist
036fa5302d Guard against uninitialised or bogus _performanceCounterEpoch values
I have seen cases where the time stamps in the Trace Event JSON end up
very wrong, which makes them useless. What mechanism causes this is
unclear. But at least let's not believe such data.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ic5528e73e502e3691b69d91f57d2fa06de47f5d0
2021-06-22 16:43:40 +03:00
Tor Lillqvist
0ae8eaaad0 Use a synthetic pid and tid for Trace Events from loleaflet
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Icd84ff030c4fdd9d9a034c00d57a3c34540fb1c4
2021-06-22 13:09:59 +03:00
Tor Lillqvist
1db237bb45 Use the WSD's pid for the Trace Events coming in from loleaflet
And not that of the corresponding Kit process, which confuses the
Chrome Trace Event Viewer, as the same pid and tid will appear for
Trace Events actually from that Kit process.

(Yes, we should use a separate, synthetic, pid for the loleaflet Trace
Events. In an upcoming commit.)

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I34298abf5c5f5ef099338d8d3a94b0026131615b
2021-06-22 13:09:59 +03:00
Tor Lillqvist
4c68a97ce5 Re-factor Trace Event stuff for improved functionality and thread safety
Write to the Trace Event JSON file in just one place, protected by a
mutex.

Handle metadata events separately. We want them to propagate to the
output if Event Trace generation is just enabled, regardless whether
it has been turned on or not.

We can send the metadata for the Kit process only after we have opened
the docuemnt as sending a Trace Event to WSD uses the (singleton)
Document object in Kit.

Introduce some new functions for the above and adapt callers
appropriately.

Generate a Complete event for the handling of one image tile, from
setting the src attribute of the Image object to finishing the onload
function.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I5978e0fb2495e0d2dc479bf861eb4ac7da03fa50
2021-06-21 12:43:17 +03:00
Tor Lillqvist
b2f4776781 No need to add the thread name to the args of Trace Events now
We automatically emit metadata events that identify threads.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Icb25b5cfc29b28ba7112ca72de56dbb697c8dd5a
2021-06-21 12:43:17 +03:00
Tor Lillqvist
bbd60b5575 Guard against multiple threads writing to the Trace Event log file
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I608779a78db7e8ed71b6fcbf6f092b8a963c9855
2021-06-21 12:43:17 +03:00
Tor Lillqvist
22b0060127 Output a Trace Event metadata event identifying the main thread of WSD
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I9e26f252bb67444934bfce1e820f768f450635fe
2021-06-21 12:43:17 +03:00
Tor Lillqvist
88e77a234b Output a Trace Event metadata event identifying the pid of WSD
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I6a5f40d5c034ed0317c5adfca4d5614b6e390fb9
2021-06-21 12:43:17 +03:00
Ashod Nakashian
1139c99972 wsd: failure to upload is not an error
Change-Id: Ifa0fb37c33c8059cadcd30ff02d9d0e44868f629
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
7963317e7c wsd: un/block the UI during renaming
Change-Id: I2dfa18f2885369c089e326a6a010f084da0897b1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
61499c70a3 wsd: no autosaving during other activities
Change-Id: Idef70a8caf86100f06b839e2f62b7469c6df52bc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
d1ac543df4 wsd: correct conditional scope
In MobileApp builds, the 'else if' was evidentally
getting chained to the unrelated if/else clauses
before the '#if !MOBILEAPP' at line 434 of
DocumentBroker.cpp.

Now this 'else if' is a standalone conditional
in MobileApp builds and it's part of the
'remove idle documents' conditional chail otherwise.

While fixing that, the missing indentation
of a for-loop under a conditaional is also
fixed, to avoid confusing maintainers.

Change-Id: If3de18f385d84cb22d757cf73743fd8541c36df9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
14c17fb07a wsd: postpone autosave
Change-Id: I83d0110d5c216a8063da54618e059e66311e7054
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
d4e60da934 wsd: support uploading after loading from a template
Templates are special because the file that gets
loaded is not in the same format as the final one.
An implicit save-as is issued in Kit for template
loads right after loading to create the final
document format. It is this file (as opposed to the
template) that needs to be uploaded, which we do
right after we get the 'status:' message in
DocBroker to actually create the first version
in storage.

Change-Id: I23cbf527f1059b0b4059f15069737ab35ac860e7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
f2f713cdaf wsd: rename file after saving to support async uploading
To avoid writing (saving) while reading (uploading) or
any other undesirable racse on the document file,
we atomically rename the file after saving on disk
to pass ownership.

After saving in Core, we rename the document in the
jail to .upload (by appending it). DocumentBroker
looks for the file with that extension and atomically
renames it to .uploading (by appening the 'ing' suffix).
This way, the Kit only renames from the original to
.upload and DocBroker renames only .upload to .uploading.
This guarantees that we never rename the same file
concurrently.

Uploading decision is strictly based on the modified
timestamp of the .uploading file, compared to the
timestamp of the last file we uploaded successfully.

Change-Id: I03520cd8c87605f6dad417e7a978204f76fc0c38
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
266fd6e981 wsd: set the timestamp of the file in storage after downloading
This makes sure that if the document isn't modified, we
will detect no change from the storage as well and
avoid making an unnecessary upload.

Change-Id: I8ba2850921d75c96b2aa4f6deb86891b4fad0ea0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
cbf05e0eff wsd: handle renameFile command with async uploading
The client always issued a save before renameFile.
This worked fine until we make uploading asynchronous.

Now that uploading is done asychronously, the renameFile
command arrives while uploading is still in progress
and fails because renaming is done via the same
storage API used for uploading.

It is best to do both the saving (including uploading)
and renaming directly in WSD, instead of relying on
the client to save explicitly before renaming.

Change-Id: I99f6294f4c83130bc13ec8e3b013ba0192f0f84c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
cbee71a6da wsd: track user issued activities on the document
Some user-initiated activities, such as renaming
the document filename, is either a multi-stage
activity or involves async operations.

Using a new Activity enum in DocumentState, we
now track each of the different activities that
needs special attention or handling.

Change-Id: I9cd2d04b10a97387ce02f5c3cc98b41a1732af6a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00