Commit graph

1950 commits

Author SHA1 Message Date
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
Ashod Nakashian
cb077179b0 wsd: logs and assertion in upload completion handler
Change-Id: I7abec95525e73d7d9a9621f8c389a63b7dd66afc
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
09dd73f6a2 wsd: add async API to Storage
This allows uploading to storage asynchronously.

Change-Id: I83956d8b27cfd24430462b1a6d0a6845bb97b7a5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-19 17:44:59 -04:00
Tor Lillqvist
9813c393dd Remove leftover incorrect usage hint
loleaflet does not look for a &enabletraceeventlogging=yes query
parameter. That was removed many weeks ago.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I33b36191f1d21c2c0177061ff704aa9bcd5f9ef3
2021-06-14 18:45:40 +03: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
Ashod Nakashian
9e501acb25 wsd: remove unused DocumentBroker member
Change-Id: Id39d8f2c9ac6d0ba9cc042d3c2dd12794a640ddb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-13 21:57:43 -04:00
Ashod Nakashian
c6f7e3758f wsd: typo
Change-Id: I0b9e17c1963636855a3360df57747dec8f9e4aa2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-13 21:57:43 -04:00
Ashod Nakashian
e8a52959ea wsd: document ModifiedTime getter/setter
Change-Id: I95763c62d5937f0749604ab26d530e85c2ed105e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-06-13 21:57:43 -04:00
Miklos Vajna
8f1621299b wsd: guard against negative counter in loolclient cmd
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: If1b1b515015b8aae01f2d1a6cb6a98426e2b03a8
2021-06-04 14:31:57 +02:00
Tor Lillqvist
cfa3de6aa4 Add the thread name also to Trace Events from the client without args
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ica43ea4c2043ba74f7eb912e81a2c38244271933
2021-06-02 09:04:21 +03:00
Tor Lillqvist
8cef48a0fa Introduce a generic TraceEvent class and instant events here, too
Modelled on how it is done in core. ProfileZone is derived from
NamedEvent which is derived from TraceEvent. Here we don't keep any
separate ProfileZone.hpp, though.

This was needed to introduce generation of "instant" events here, too.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I6583134e96001641c50339deb4197fca6ab7d5d5
2021-06-02 09:04:21 +03:00
Henry Castro
d118500a70 wsd: revisit log messages ClientSession.cpp
LOG_FTL = abnormal, crash, denied service
LOG_ERR = load, save, session, connection, wrong parameters
other cases LOG_WRN, LOG_INF

Change-Id: I4ab8d04099a432e7fd3fb6810d7a9aa038cbb57d
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-06-01 14:15:30 -04:00
Tor Lillqvist
5e9e0d620e Add a ProfileZone around two more WopiStorage member functions
As requested by mmeeks.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Iba04bc5255479b9b0998a385d558bf07279bf00c
2021-05-31 15:33:23 +03:00
Tor Lillqvist
eee8fe99d5 Avoid maximum/minimum logging level terminology for newly introduced settings
(Also in variable names.)

Better to just use terms that say what we mean, i.e. most verbose and
least verbose.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I80d74fda8b80bd34d194c3df97d246a41368189b
2021-05-31 15:06:57 +03:00
Miklos Vajna
c415fcbcce Add an Android setting for the user's name or nickname
This was already worked on iOS since commit
75a3ab02ca (Add an iOS setting for the
user's name or nickname, 2021-04-07), start using the same API on
Android as well.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I37825d143b0ed92bd84f9a1512313e51ff5e761c
2021-05-31 10:45:32 +02:00
Tor Lillqvist
b7ca93a41a Add the possibilty to set a thread-local logging level
Add a way to set it from the client.

For now, in the Help > About dialog, the L key toggges the logging
level between the default (whatever is set in loolwsd.xml or on the
loolwsd command line) and the maximum a client is allowed to set
(which also can be set in loolwsd.xml or on the loolwsd command line).

Also while at it, uncouple the toggling of the Trace Event generation
from the triple-click tha toggles tile debugging. It is now on the T
key.

Also swap the meaning of "min" and "max" for the logging levels. Even
if the Poco::Message::Priority values are such that the less urgent
priorities have a numerbcally higher value, conceptually it is more
clear to say the more urgent priorities (levels) are "higher".

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I5383b16ead7d2d378901525eb0d16513d88f045e
2021-05-31 10:56:19 +03:00
Tor Lillqvist
636069430e Also add logging.min_level_settable_from_client
We don't want a client to be able to turn logging off completely
either.

Note, just to avoid potential confusion: This is about the LOG_INF(),
LOG_WRN(), LOG_TRC() etc logging here in Online. Not related to my
recent work on Trace Event format logging.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I3de527cb9f69d9a5269b1db2e1d4602e7117f22e
2021-05-31 10:56:19 +03:00
Tor Lillqvist
4136e024f9 Add logging.max_level_settable_from_client setting
(Not used yet.)

The intent is that the JS code will be able send the server a message
that adjusts the logging level for the WSD thread(s) and Kit processes
handling that client.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I88ac301f002b1f3a55a5d8c9e3650babdedc1e0d
2021-05-31 10:56:19 +03:00
Tor Lillqvist
2398c792cb No Hungarian notation please
I had accidentally used core naming conventions for ProfileZone.

Change-Id: If10eceb7a5a29d26662d5b21a9289681d814a12e
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-31 10:56:19 +03:00
Tor Lillqvist
496951d2c1 Add a ProfileZone for WopiStorage::getWOPIFileInfo
On request from mmeeks.

Change-Id: I2b0b6e290109b29cd84359b2c26aa30357e8450f
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-31 10:56:19 +03:00
Tor Lillqvist
929e466c91 Re-work the ProfileZone implementation here
Don't bother collecting them into a vector, like in core. Instead,
just call a static member function ProfileZone::addOneRecording() for
each Event Trace object (string) to be emitted. That function then
needs to be implemented separately in each executable. In WSD it logs
the object to the Event Trace file. In Kit it sends it to WSD for
logging. In Unit tests we use a dummy implementation.

(If Event Trace logging is not enabled at all in loolwsd.xml (the
default), nothing is done, of course.)

When receiving the "traceeventrecording start" or "traceeventrecording
stop" message from the client, turn ProfileZone recoring on or off in
the WSD and Kit process. (Probably in WSD the flag should be
per-client.)

Change-Id: Ie1127d65dd44ed77e7eeab4b0f0a90cce95dc4a2
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-31 10:56:19 +03:00
Miklos Vajna
bc0401fc49 Make sure that double fits into uint64_t
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Ic521383f71c1865ae18fc880b79493c52285e29b
2021-05-31 08:54:06 +02:00
Tor Lillqvist
809c78480d The convention is to call the processes 'WSD', 'ForKit', and 'Kit'
I.e., not in upper case. I was misunderstanding.

Change-Id: I3275446cba0eb954b5ef398d3406d0543c2fb7e7
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-25 10:41:11 +03:00
Tor Lillqvist
d5ded73b11 Fix FreeBSD compilation error
Change-Id: I0201c8213c9593f225c0aab7c4e95b06bd6a22ec
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-19 13:33:26 +03:00
Tor Lillqvist
9b948da419 Add thread name and id to Trace Events coming in from a client loleaflet
Change-Id: If469fcfb39b94866e8d8a93a88587c33583b35d2
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-19 13:33:26 +03:00
Tor Lillqvist
9c6b74ad08 Use a loolwsd.xml setting instead of --enable-trace-event-logging
That is our convention, and this also avoids a global variable in the
kit process.

Change-Id: I37d2d53aa7eb24f9848fa8ef98bc57d75db90d13
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-19 13:33:26 +03:00
Tor Lillqvist
cadb005993 Add the possibiliy to include arbitrary arguments in the generated Trace Events in JS, too
For now, an argument object should have all keys and values as strings
not containing any spaces because of the trivial way in which it is
parsed.

This is a bit sad, yes, but necessary until we move to some more
structured syntax for the messages.

Also fix an incorrect comment.

Change-Id: I8a1408a4a1787b66a3cf7b26b3d92c07df244c47
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-19 13:33:26 +03:00
Miklos Vajna
03f13aceb1 wsd: remove unused using declarations
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I99aa27d70c7c1d90f3048009644ebf9a41e73724
2021-05-14 11:05:16 +02:00
Andras Timar
9a522cf0db documentation of default config values
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Ie7022e0db125f85261f17cfa91933fe8d3b51104
2021-05-13 11:52:20 +02:00
Tor Lillqvist
a28ee1bac6 Fix syntax errors in generated Trace Event JSON
Colon, not equals. Comma missing.

Change-Id: Ife64fe7c57e0cff155926f9b17beb17ce530d848
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-10 18:06:59 +03:00
Tor Lillqvist
4e0b03f651 Let the server tell loleaflet whether trace events can be collected or not
Instead of requiring that information in the query string of the loleaflet.html URL.

Change-Id: I8c41e87c7f561561adeb03ec34ce0c19fe9d7fa5
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-10 16:44:07 +03:00
Tor Lillqvist
cdf374dc63 Clarify Trace Event file writing
Make it contain a proper empty JSON array if no trace objects have
been written to it.

Change-Id: Ided1992a822659561a909ac545536261b91adbac
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-10 15:14:40 +03:00
Tor Lillqvist
9da0145280 Add an --enable-trace-event-logging option to loolwsd
It enables turning Trace Event recording on (and off again). The
option is passed down to the client through loleaflet.html, and to the
KIT processes. If the option is not used, the new JS functions that
send trace events to the server turn into no-ops to avoid wasting
bandwidth.

It is always on in a "make run".

Change-Id: Iafe1919ccba7c376137d3e0568b857e20780bbc8
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-10 12:39:07 +03:00
Miklos Vajna
7b89ce2961 ClientSession::_handleInput: avoid pointing to a temporary
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I048ce322111029847d78f917f071b1c0854dc116
2021-05-10 12:38:32 +03:00
Miklos Vajna
d6c41de084 ClientSession: fix -Wdangling-gsl
wsd/ClientSession.cpp:411:31: error: object backing the pointer will be destroyed at the end of the full-expression [-Werror,-Wdangling-gsl]
            const char* str = tokens[2].data();
                              ^~~~~~~~~

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I67e4aa5f61e049ad13663dc1e11ae2bd67399bea
2021-05-07 13:42:54 +02:00
Ashod Nakashian
effa9b942f wsd: log if we skip updating the modified flag
Change-Id: Iadde822ce720ff81abd38fd7c8991352ac57953f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-06 22:14:51 -04:00
Tor Lillqvist
9c57b8a435 Introduce a TRACEEVENT message from client to server
Add a function emitInstantTraceEvent() to leaflet that sends an
"Instant" Trace Event to the server for logging.

Add a function createAsyncTraceEvent() that creates an object that
records the timestamp of its creation and sends the 'b' event to the
server for logging, and when you call finish() on the object, sends
the corresponding 'e' event.

Finally, add a function createCompleteTraceEvent() that creates an
object for a "Complete" Trace Event that includes the end timestamp
*and* the duration. The event is sent to the server when you call
finish() on the object.

Loleaflet sends timestamps in the above messages from
performance.now(). To enable the server to turn those into absolute
timestamps, the loolclient message is amended to include the current
Date.now() and performance.now() values.

Note that the intent is that when generating Trace Event logs, the
server and the web browser run on the same machine, so there is no
wall-clock synchronisation issues between server and client.

Change-Id: Ie9e68b093b769cc942e1e1d17083febeb07ccf5e
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-06 11:24:20 +03: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
686f1ba1cb Make WebSocketHandler::_isClient const and drop default values for bool parms
Avoiding default values for parameters makes the code easier to read.
Especially true for bool parameters. But sure, just a question of
taste.

Change-Id: I473f70bdfafe3a9ccfb325def8760d78fee7e9a6
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-05 09:03:29 +03:00
Henry Castro
4e7fadb2b5 wsd: revisit log messages LOOLWSD.cpp
LOG_FTL = abnormal, crash, denied service
LOG_ERR = load, save, session, connection, wrong parameters
other cases LOG_WRN, LOG_INF

Change-Id: I80e8ee0de2b6858ec8e1c27276eb2058acdb2970
Signed-off-by: Henry Castro <hcastro@collabora.com>
2021-05-04 10:44:01 -04: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
eb9c580c36 Introduce ways to toggle and tweak core Trace Event recording and logging
When toggling tile debugging in the Help>About, toggle Trace Event
recordning, too. Add a comment with an example of how to turn on
SAL_LOG overriding at the same place.

The following new messages from client to server are introduced:

traceeventrecording <start/stop>

    Starts or stops comphelper::TraceEvent recording.

sallogoverride <string>

    Overrides the SAL_LOG value, or stops overriding if no parameter
    or parameter is "default".

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I8b56c28cd99d39115cd796c44e5051d934d21a1f
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-05-03 16:09:35 +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
0dbecddb3a wsd: http: simplify sending response and shutting down the socket
Change-Id: Id4e32c8eb79458d060767a7a5ac26476e2f84331
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-05-02 22:35:39 -04: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
c5490f628e wsd: enable fat writes in WebSocket
This enables writing multiple WS frames
at a time, up to the capacity (rounded
to the next full-frame's size).

Change-Id: I30d25f9ba1e405156d1e44886b2f3ac8017f0f3c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 17:48:23 -04:00
Ashod Nakashian
3decba7eec wsd: specify the minimum bytes we can write to the socket
When writing to the socket, it's always more efficient
to fill the buffer up to the hardware limit for each
write. This is doubly important for efficiency with
SSL, due to the overhead of encrypting multiple
small buffers instead of one large one.

Currently we don't write more than one message
at a time, primarily due to limitations in
the Poco sockets in the unit-tests, which
have a hard time consuming multiple WS frames
with a single poll (subsequent calls to poll
doesn't enter signalled state until new data
arrives, possibly because the data is read and
buffered internally, making the whole scheme
of using poll unreliable and meaningless).

Change-Id: Ic2e2cf1babfb5ab4116efd93f392977ba234d92b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 17:48:23 -04:00
Miklos Vajna
d3c9e07ff3 StringVector: add a way to get a string-number pair out of this ...
... without copying the token.

And use it in TileDesc::parse(), which is known to be a hot path.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I0dcf2eb26c93254cdc6a1c11f9708daf213a825d
2021-04-27 15:31:21 +02:00
Miklos Vajna
c11f0e5708 StringVector: add a way to get a number out of this without copying the token
And use it in TileDesc::parse(), which is known to be a hot path.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I20375d7a1c31f61662446979e4d6799fd45b49d3
2021-04-27 15:31:21 +02:00
Ashod Nakashian
ade93f5f57 wsd: more informative initialization failure log
In some rare cases Poco throws "Exists" exception.

It's not clear what causes it, so this should
log more of the original exception, hoping that
it would shed some light.

Change-Id: I51723f35c9e062c56608e8f7b80c9a65d3f0488f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-27 08:09:49 -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
c50af5b94c wsd: better and consistent logging of ShutdownRequestFlag setting
Change-Id: Ic9e41d193b6a6a678170ec5ca30bd80bcee04c80
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
Michael Meeks
92af50e4b9 Initialize SSL un-conditionally.
Even if we use http:// locally via a tunnel the new outgoing socket
code needs SSL initialized to connect securely to remote servers.

Change-Id: If64a3838267182757591a8026097bf08d9ba732f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-04-15 16:39:45 +02:00
Ashod Nakashian
0a73175764 wsd: reduce string copies
Change-Id: Ib38d7ebf1e66680779720cc1ce4d9bd07f9cab0a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian
b12a4105fb wsd: WebSocketHandler fully supports http::Request
Change-Id: Ia5ff17e9aa8cbaded4e304be8c673b8f1575b6ce
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian
d6d4fe0ea5 wsd: use setbody in LOOLWSD and avoid manual plumbing
Change-Id: I32ce4eba855a0996eff3ae2d85245e167d23abd0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian
64c494c2ee wsd: use http::Response in LOOLWSD
Change-Id: I70db5293e7c0a8dd6602cf015420b6070c0f956f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian
a8b50f5801 wsd: use http::Response in LOOLWSD file serving
Change-Id: Ia2d592e8b279f69f257d5b216e05de2437fa3d60
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian
12c57cb1a0 wsd: use http::Response for LOOLWSD 400 errors
Change-Id: I22f9b78f1ed6500111697b6017b0e654f7b97def
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Ashod Nakashian
e1c1927cc6 wsd: use http::Response for LOOLWSD 401 and 404 errors
Change-Id: I1500939d68db3f68954fcf522d20080420b37e14
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-04-11 01:05:20 -04:00
Tor Lillqvist
75a3ab02ca Add an iOS setting for the user's name or nickname
Used for comments added to documents by the user.

The setting, like templateListURL, can be set through a mobile device
management system.

There is no trivial way on iOS for an app to programmatically find out
the name of the user, and that is good from a privacy point of view.

Fixes https://github.com/CollaboraOnline/online/issues/1843

Change-Id: Ie68fcbacf886ec8f1c74021a71879b38d4180c15
Signed-off-by: Tor Lillqvist <tml@collabora.com>
2021-04-08 00:37:05 +03:00