Commit graph

570 commits

Author SHA1 Message Date
Ashod Nakashian
6dec522a65 wsd: sanitizeURI from to RequestDetails
Change-Id: I8693bd6a36be4c67b62be4b5a997dd227460fbd1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-09-26 17:02:01 -04:00
Ashod Nakashian
965e5cb37d wsd: verify that the last-editing-session can save
The last-editing-session could still be valid, but
waiting disconnection, in which case the kit might
have already discarded it, and so saving would
fail (silently, and thereby leaving docbroker
waiting for the save response).

To avoid this, we always validate the
last-editing-session before using, and not just
when setting it.

Change-Id: I60cd219d8e5a9945396110c8f8d194e87f81afba
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit e1fc6adbfef7ee0678c7a563fd6142c32f2da4a6)
2021-09-26 17:02:01 -04:00
Ashod Nakashian
b82b18e8c9 wsd: autosave using the last editing session
Change-Id: I556b7b49b2d1abc0e61ea7ecaa8e5f9406c408f3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit b3738719a3b7301688faecfd721a97180eab0020)
2021-09-26 17:02:01 -04:00
Ashod Nakashian
ff1ff12663 wsd: each view handles its own url params
Change-Id: I0c6b9b86c970b1f45e7fa34d030f08c6f256d082
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit d4aa0a0f73eef5a90a14a2297f3050c1dba95a2d)
2021-09-26 17:02:01 -04:00
Ashod Nakashian
d395f521df wsd: log stopping-although-modified as warning
This log entry can be misleading on its own.
When shutting down, the modified flag is not reset,
and that in itself is not a cause for concern.
So this log entry is seen much more often than we
expect. If we truely fail to save/upload, there
will be other errors that will be the tell-tale
signs of a serious issue. So it's reasonable to
downgrade this error to a warning (and watch for
other errors).

Change-Id: Ic879c3fbac887ed5b64bdd1a31aa38bcfd863850
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 7db86b3eb2cdc2a44023e7b7491e1ee202146ef5)
2021-09-26 17:02:01 -04:00
Ashod Nakashian
c4fb58df61 wsd: allow new views while unloading
Unloading duration depends on the time to save
and upload the document, during which a new view
might be opened. We now allow aborting the unloading
and resume reusing the document as-is.

Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 8f299eb2cdfe0ef869a8c90fbc602a93ba2fcb73)

Change-Id: I7bc485177929c0d1c9ef12b02672db493ac402c9
2021-09-26 17:02:01 -04:00
Mert Tumer
b12d91de67 renamefile: Respond with reload instead
This way it will reload the document without getting
additional errors like "this is embaressing.."
and not timed out on large files due to retrying for a limited
time.

Signed-off-by: Mert Tumer <mert.tumer@collabora.com>
Change-Id: Ied341200ca21e1b7243daaf62813bc9ed69fecd3
2021-09-17 15:26:15 +03:00
Tomaž Vajngerl
b31eb2ab92 New POST service to render a search result + unit and integ. tests
This adds a new service render-search-result, which renders an
image of the position where, the search fund a hit. The search
result contains the information in which object or paragraph,
which is just the node id and node type from the document model.

The service takes the document and the search result (xml file)
as the input and returns a PNG image as the output.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>

Change-Id: Iffc158c5b0a3c9a63f8d05830314c9bc1616b3b1
Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
2021-09-13 10:36:15 +02:00
Rash419
ea4d455f3a Admin Console: add wopihost name in the dashboard
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I8ce68653200bb16877f6ced57fc77f6291b375a8
2021-09-09 10:13:40 +05:30
Pranam Lashkari
daef96dcb3 freemium: corrected typos
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: If21f4471b3ad4b20f049e2e9f2330e31989ead0b
2021-09-01 09:44:19 +02:00
Szymon Kłos
27e95bbe7e Wait for async save result on DocumentBroker stop
When async save was started but we want to stop DocumentBroker
- we shouldn't kill the socket which listens to save result.
Because when we kill socket we will destroy DocumentBroker
before saving is completed, this allows for a minimal time
to connect again to the document and receive old content
from the WOPI storage. When we wait for async save result
we will keep DocumentBroker alive and next session can be
connected and receive correct content.

fixes: https://github.com/CollaboraOnline/online/issues/2747

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I5505a5ccc1f3d6928c723bddfea16bf5c5798d1e
2021-07-28 13:00:45 +02: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
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
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
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
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
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
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
0810234480 wsd: simply passing the authorization object to the storage
Change-Id: I57cf952918edcb5bf2ddeab66c534a6805eec7e6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
2ac35de6df wsd: name session variable instead of opaque iterator
Change-Id: Ic2c16ef94c67c90307f2aae2c35dba0d92fb4271
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
16a3c43871 wsd: stop after successfully uploading
With async uploading we have to process the
stop-condition only after we get the response from
the async operation. For now, we don't stop
if we fail to upload, giving a chance to retrying.

Timeout should be used in the poll loop to
limit how long we retry.

Change-Id: I8e8f8618f92f34ef2f1853e499f4f8d6ce932b40
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
35bf4a32ed wsd: DocumentBroker::needToUploadToStorage now returns an enum
This is to also include the 'force' case that is
needed when unloading a document.

Now that the force flag is reliably set, we don't
need to override it in needToUploadToStorage.

Change-Id: Ic0672e6c7bcb53a17ec6a0cbd2d2f8b434fbc300
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
48e76c3a94 wsd: better logging of autosave, upload, and modified states
Change-Id: I7249c3e57568acbf24c754db7097c263573fb6bf
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
f32fd0756b wsd: better logging of upload state
Change-Id: Id95c69a09c14e8d07e0a64b113bd7ab7e760850e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
161cf090e2 wsd: upload after saving only if necessary
Change-Id: I4037030329815a87edf8e15d151dbec2491e9973
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
1d0c717d0a wsd: handle async upload callback
Now we can handle the response of the storage
after the async upload is complete (or timed out).

Change-Id: I29d450646bddb07f02bb17d257e7e0fa372ce357
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
39bb098601 wsd: support asynchronous upload requests to storage
Add the necessary support for handling async
document upload to storage in DocumentBroker.

Change-Id: Id7a58c245d729cef58669bafb60db450f7ebbba2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Ashod Nakashian
6bca6847a8 wsd: correct sha1 logging of the downloaded doc
The path to the local file is relative to the jail.

Change-Id: Ie008aee4afc264339706b5b4715af35cd71ac55d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-13 21:57:43 -04:00
Michael Meeks
d387700914 Message: don't generate and allocate abbreviations just for trace logging.
Also avoid generating abbreviations in various message handling loops
unless debugging is enabled.

Change-Id: I22f4929b0bfd4da36917db6882bb2f5f5be02780
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-05-05 09:40:10 +01:00
Tor Lillqvist
fd1910c727 The Chrome format is called Trace Events, not Event Trace
Change-Id: I2515182d9369c3a25727dce0d3790e79de891bff
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-04 15:12:14 +03:00
Tor Lillqvist
be476d23b3 Produce a Chrome Event Trace file
It is (for now) produced (by the ProfileZone things in core) whenever
logging level is "trace". The Event Trace file pathname can be given
in the loolesd.xml file or on the loolwsd command line.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I6d5829121e71460a4600ee94d2ebf51043c8893f
2021-05-03 16:09:35 +03:00
Ashod Nakashian
a21120412e wsd: explanation comment
Change-Id: I5104db5d20049132f88ca15a713bb3c17fb2d32d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-02 22:35:39 -04:00
Ashod Nakashian
e0b5cddffc wsd: shared_ptr can dereference directly
Change-Id: Ie958c2c79da0b3ffa19de0c633e486a390240409
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-02 22:35:39 -04:00
Ashod Nakashian
4e7b0b10fe wsd: simplify assertion
Change-Id: I2cac7543fa20a39deba447e67e9c9cdb08cd3572
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 7188d4013a8bf00379610ec1b0a610c555674a2d)
2021-05-02 22:35:39 -04:00
Ashod Nakashian
6444c35d21 wsd: mobileapp: fix a warning
Change-Id: Ie710a76f3cd5d96056648815ffe393ab2e58ac78
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Ashod Nakashian
9742f91527 wsd: log the reason for terminating DocumentBroker
Change-Id: Ieef1d30bd4abc18e27cc057ac2374f730b8992c2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -04:00
Henry Castro
21c66b2352 wsd: revisit log messages DocumentBroker.cpp
LOG_FTL = abnormal, crash, denied service
LOG_ERR = load, save, session, connection, wrong parameters
other cases LOG_WRN, LOG_INF

Change-Id: I174a86f48e6b4107d0f846fd9af28a7ab1f62afc
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-04-15 10:53:00 -04:00
Ashod Nakashian
af454178ae wsd: avoid unnecessary string copies
Change-Id: I61d50fa2bd1c7e9fc673eb58c9ba85127d6e4883
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-08 22:49:53 -05:00
Ashod Nakashian
3f5e9d5922 wsd: terminate Kit when disconnected while loading
When loading hasn't completed yet, DocBroker can't
simply send a message to Kit that the session is
disconnected, because there would be no UI or
handlers for events if that were the only session.

Of course letting the document load, only to close
it, is also less than helpful to resource consumption.

Here, we recognize this case and simply terminate the
loading by killing the Kit process altogether to
avoid any potential hangs or resource wastage.

Change-Id: Ia72de715cc6238831c244444bb47b417b9b1e1a4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-08 22:17:42 -05:00
Henry Castro
cedf950a52 wsd: add interactive state
Add a new state before load the document,
when Macro Security dialog popup, and avoid
to send the event load timeout.

Change-Id: I5973c5205e90e5447e5478cbab895709a68606f6
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-03-03 09:18:15 -05:00