Commit Graph

3058 Commits (master)

Author SHA1 Message Date
Ashod Nakashian 0a924e1fe8 wsd: access_header substitution
Change-Id: Ib25228efc5fdf771be6c677604ed1131ca4bdfd1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 19:25:59 +00:00
Ashod Nakashian c62cb19dc9 wsd: access_token_ttl substitution
Change-Id: Ifcc2939124e061313cdb547985ec888aed9aa875
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 19:25:59 +00:00
Ashod Nakashian 5e9fdc8ef8 wsd: access_token substitution
Change-Id: Id55dc5b074d80c3f10fe71e2e0abd90802fe10e9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 19:25:59 +00:00
Ashod Nakashian 2bb765c48f wsd: new helper class UserRequestVars
Used to substitute user-request variables
in the files being served.

Change-Id: I7c0046328ec05f2feb7fcd9df9a21e415a1e2513
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 19:25:59 +00:00
Ashod Nakashian f8944385fb wsd: new Substitute helper for PreProcessedFile
And enable the round-trip test.

Change-Id: If9a54959514a31f9459e8596b2a4e3847465f1b9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 19:25:59 +00:00
Ashod Nakashian d7cbe7488b wsd: improved PreProcessedFile with SegmentType
Change-Id: I34609ae855ebbef395d13c4f77885dd6012685f2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 19:25:59 +00:00
Ashod Nakashian 74a8f61586 wsd: better PreProcessedFile and new disabled test
Change-Id: I30a7698c54913f8eeef9a1e02cabaebd907cb7e3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 19:25:59 +00:00
Ashod Nakashian 78f5b70695 wsd: new PreProcessedFile class
This class will be responsible for faster
variable replacement to serve the templates.

Change-Id: Ic0d75b0a197c0db75c0988c3b6af400a5b1c35a2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 19:25:59 +00:00
Ashod Nakashian 84a0c1eec1 wsd: log cgroup memory and in GB
Change-Id: Ifda8891721228acf50e3348d43e902498e6d884d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian 3585e7ed83 wsd: rvs: copy the WS before passing it to docBroker
Change-Id: Ie1b995b551453e871da19b13888b1e80ff6643b0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian 8358fc2293 wsd: rvs: refactor send error and shutdown socket
Change-Id: I0a32dec86e3e9b9b5989da40a25af90ba9b82095
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian 37efb14d35 wsd: rvs: avoid exceptions when handled gracefully already
Throwing exceptions from an async processor does
nothing good. Instead, we handle the consequences of
the error in-place, instead of throwing.

Change-Id: I85c4cee7cc8231453498e4cb9cb07a07b2b417c9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian a3dcf28bed wsd: rvs: better logging
Change-Id: I56df3835d74502590a5e0104c5dcbee6ad26d827
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian 6fe96901c9 wsd: rvs: support redirection of CheckFileInfo
CheckFileInfo requests can now redirect
to a new URL.

Change-Id: I7579ac37235b1a2ac1d7091366f0046cf889ce15
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian 1f3441cc42 wsd: rvs: refactor CheckFileInfo
This breaks the CheckFileInfo fetching
code in RVS into its own function to
allow for redirection.

Change-Id: I8bfa3a71705c77af8f6e75ed1af75e710767cf19
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian 1164cb90fa wsd: rvs: pass wopiFileInfo around
Change-Id: I52ef794d758a06d66cb91cc7bdb272bd2167b05c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian 2063b1ba50 wsd: rvs: handle StorageSpaceLowException
Change-Id: I036c577716cc0ba38c9585e6d1009c7ba82a87a3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian 91029b0efd wsd: rvs: refactor createDocBroker
Change-Id: Iaff50d505aa054a1f13c71a60a247feaede54172
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian 5c5c4559f9 wsd: rvs: add RequestVettingStation
RequestVettingStation is designed to
vet requests before allocating further
resources. Specifically, it is to be
used to verify whether the resource
requested exists and whether or not
the request is allowed and authenticated.

All of this is designed to be done
asynchronously, for performance reasons.

Change-Id: I399fa7bc91741ffee065a6d41acca0756eedc939
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian d1ac610b50 wsd: new setupTransfer into DocBroker
Will be used for parallel loading, when we
transfer thread ownership to DocBroker.

Change-Id: I99dea58afc6c86d7937e32c8b3313676cc46d3b7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian 733883fb11 wsd: make findOrCreateDocBroker non-static
Needed to reference from ourside COOLWSD.

Change-Id: Ib8a160d912c6d3a2d972cc1fcf231e862f2fe24b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Ashod Nakashian 8afdc40aca wsd: pass WopiFileInfo optionally to addSession
This is to allow for having gotten the WopiFileInfo
before creating DocBroker at all.

Change-Id: I0f21442860e09385e504b9a98049af286cc5b404
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00
Rash419 1fbbae0934 admin: add about page for indirection server
- show full license

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ia51012b5277e6666733fc83441754276a79759da
2024-01-18 16:15:42 +05:30
Michael Meeks ca34860bbc clipboard - dump saved clipboard state and details.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I1dcee22ad66bce1081b88262b58e9999f6e81ada
2024-01-17 09:52:58 +00:00
Miklos Vajna c97e4e2720 admin: handle errors while decoding URLs
#9 0x7f1fb8b06ee7 in __cxa_throw (/usr/lib64/libstdc++.so.6+0xb7ee7) (BuildId: c74eca671e2dd0f063706372d103f8acef88f1e3)
    #10 0x7f1fb808645b in Poco::URI::decode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, bool) (/usr/lib64/libPocoFoundation.so.92+0x15145b) (BuildId: 32601204eb877c998d0122c4bef1c7c08c8d0285)
    #11 0x55a887e4bb8b in Util::decodeURIComponent(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /home/vmiklos/git/collaboraonline/online-fuzz/common/Util.cpp:830:9
    #12 0x55a8874b7547 in AdminSocketHandler::handleMessage(std::vector<char, std::allocator<char>> const&) /home/vmiklos/git/collaboraonline/online-fuzz/wsd/Admin.cpp:392:20

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I87f358d218e8774d5c82f1fb12e2f56898e7581e
2024-01-16 21:36:43 +01:00
Michael Meeks 5bd1f1d0e8 convert-to: be more tolerant of unusual filenames.
But re-write them anyway to be more sensible.

Change-Id: Ie146f4f84b539ab7e826a1c1b947497acde7e384
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-01-15 11:57:55 +01:00
Caolán McNamara 3b86ee3ba2 cid#340393 silence Division or modulo by float zero
and

cid#340397 Division or modulo by float zero

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I0e2fae591f726eca0f3a605cd8c09d2de25d8db7
2024-01-15 08:38:31 +01:00
Rash419 4484f2e955 fix: can't open readonly files
- regression from d118874bee which was a
  fix for regression from 93b5bdf
- previously we used to send blockingcommandstatus message to the core
  when we were getting statusindicatorfinish but when file is readonly
  we load the document first therefore we get the statusindicatorfinish
  first then wait for the input from the to whether to open the readonly
  document or not
- now we send the blockingcommandstatus only after we get the first
  status message which indicates document is loaded and opened

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I0f4934e085befa6f9a918ac61a265391b217a2f2
2024-01-10 23:30:01 +05:30
Caolán McNamara 0f922c2322 Rewinding and rereading proc/smaps_rollup doubles the values on some kernels
So this only affects the case where we reuse the fd from opening smaps_rollup

Bug seen in 4.15.0 and not in 6.5.10, suspected to be fixed by:
258f669e7e
included in >= v4.19

Test for this in coolwsd and set a flag if it is broken

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I0a4aca77b9d9201e4f70172340296e5eb5460229
2024-01-10 17:30:46 +00:00
Miklos Vajna 28665d45d2 wsd, DocumentBroker: check for missing child process
wsd/DocumentBroker.cpp:2861:32: runtime error: member call on null pointer of type 'WSProcess'
    #0 0x55cbce63d7d9 in DocumentBroker::disconnectSessionInternal(std::shared_ptr<ClientSession> const&) /home/vmiklos/git/collaboraonline/online-fuzz/wsd/DocumentBroker.cpp:2861:32
    #1 0x55cbce66c74d in DocumentBroker::removeSession(std::shared_ptr<ClientSession> const&) /home/vmiklos/git/collaboraonline/online-fuzz/wsd/DocumentBroker.cpp:2764:13
    #2 0x55cbce944614 in ClientSession::_handleInput(char const*, int) /home/vmiklos/git/collaboraonline/online-fuzz/wsd/ClientSession.cpp:886:24
    #3 0x55cbced66255 in Session::handleMessage(std::vector<char, std::allocator<char>> const&) /home/vmiklos/git/collaboraonline/online-fuzz/common/Session.cpp:271:13

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I2a6f830de82ec8189312e57e6554a57909a0aaaa
2024-01-08 09:13:27 -05:00
Ashod Nakashian 61cf7b9601 wsd: clean up unused header includes
Clang-tidy recommendation driven header
include clean-up.

Change-Id: I30c32866b7798e70df0463ee6bc7a0bcc3de5049
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-08 08:38:48 +01:00
Michael Meeks 4dc2cd4e16 logging: reduce excessive logging noise re: tiles-on-fly.
Also better explain that we dump sessions twice.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Iec3ad5b9f78f0572d43cfba1191bcec3584c0092
2024-01-08 08:32:12 +01:00
Michael Meeks 29db7db278 logging: calm down dropping of on-the-fly messages.
These tend to be sent at small increments of time, so have some
hysteresis to aggregate drops. Stalled JS such as in a debugger
or a client not responding can cause this for quite some tiles.

Change-Id: Ia807d4ba0ac26a95cad435cba9ed191f22706041
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2024-01-08 08:32:12 +01:00
Andras Timar 890cda88a7 do not display 'Go Offline' button when WASM is not enabled
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I02bde8b9f6ca5cfadc036ae930e7f6eeb23c2587
2024-01-06 19:03:13 +01:00
Ashod Nakashian b1f0834ac4 wsd: do not upload unmodified document
When always_save_on_exit=true we should
still not upload the document when it
isn't modified.

In this case, because we now always
save the document (forced) when
always_save_on_exit=true, and because
saving always generates a new file on
disk, with a new timestamp, we couldn't
detect that there are no modifications.

We now still force save, but ask Core
to skip it if the document is unmodified.

This is safe since we now always issue
the save, but rely on Core to do the
right thing. When the document is saved,
we do the normal upload as in that case
we know we have a new version of the
document, which must be uploaded.

Worth noting that the closedocument
command doesn't trigger the same path.
To reproduce the issue, we need a new
test that disconnects, instead of the
graceful closedocument command.

Change-Id: Iaa4e0363ed2eca124f2d1943393e65c0c187aa18
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-04 05:29:32 -05:00
Ashod Nakashian 7f2f946aec wsd: logging and cosmetics
Change-Id: I777db7d1879e84f341f11a90fce7abf8241f5ced
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-04 05:29:32 -05:00
Szymon Kłos 8c6e2ecbdc Improve logged message: setclientpart syntax error
Don't show error to the user as it is not critical
but put in the logs more meaningful message so we can debbug
later.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I7b27a19ac7af845de74d7a4fb65682dfe03c042d
2024-01-03 16:02:59 +01:00
Szymon Kłos eef78a5c5a Improve logged message: cache miss
so it doesn't sound that serious like previous message
and is less generic and more easy to find in the code

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I3eb746af8aef39b566d3213ab2935372219e8d98
2024-01-03 16:02:59 +01:00
Ashod Nakashian 7a327c337b wsd: force autoSave on always_save_on_exit
This forces autoSave when always_save_on_exit
is true. This is needed so we can guarantee
that we don't have modification and that
we upload if there has every been one.
The latter case is checked in
DocumentBroker::needToUploadToStorage(),
which is called from
DocumentBroker::checkAndUploadToStorage().

A new test reproduces the issue and defends
the fix.

Change-Id: I0b2105a57cfd7049ba7b1f63e62a700fdc3744c2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-02 08:17:01 -05:00
Michael Meeks 4b12e22e68 traceevent: re-factor and cleanup trace event emission.
Share a single emission function. Events are re-parsed and
emitted and adjusted in ClientSession; JSON escape event names.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: If489d516bf20d5ec34cfe61f7e4fb09cf2e14bf2
2024-01-02 12:05:01 +00:00
Szymon Kłos e8f77a6b06 Don't pass invalid hosts for lok_allow #7885
Fixes #7885

Be more flexible and allow to run service with configured
hosts which doesn't work with lok_allow (invalid regular
expression for std::regex which is used in core).

This change instead adds error report in the logs, without
it it was crashing when any host was not compatible.
For example when using domain like:
"*.example.com" which should be ".*\.example\.com"

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Id664df95899bda866b9179a3941280626a2c0299
2024-01-02 11:57:32 +01:00
Ashod Nakashian 29cfaa7682 wsd: quarantine: absolute-path and better logging
The quarantine path should be an absolute path.

Unfortunately, because we had relative=true in
the path config, we couldn't detect empty configs.
This is because with relative=true the getter
would create a path based on the current directory
and the config value, which would default to
"quarantine" when empty.
This would result in /opt/cool/quarantine or
/usr/bin/quarantine when in fact the path is
really empty.

Now, the config has relative=false and
there is no default. In addition, we
warn if the path is no absolute.

Change-Id: I1b3eb5e76866a12d214b47e6556942715a210e54
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-02 10:57:20 +01:00
Ashod Nakashian fb067faae4 wsd: quarantine: isQuarantineEnabled -> isEnabled and log it
As this is a member of the Quarantine class,
there is no need to have "Quarantine" in the
name. This was a hang-up from the time when
it was a static.

Now we can log the enabled-state.

Change-Id: Iab1cec4d90671cda175c1d320e4f3318dd7b89a1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-02 10:57:20 +01:00
Darshan-upadhyay1110 7fbf58cb35 Do not supress ChnageTheme event in readonly mode for any document
- allowed `ChangeTheme` event in readonly mode
Signed-off-by: Darshan-upadhyay1110 <darshan.upadhyay@collabora.com>
Change-Id: Ic64bc61011a9e053c105e5c7540dddd4eb530681
2024-01-02 14:25:01 +05:30
Ashod Nakashian 373c04fe4e wsd: admin: use the cgroup limit as available memory
This applies the cgroup memory limit, if set,
such that if it is lower than the configured
memproportion percentage, we do not exceed it.
Otherwise, we risk running out of our cgroup
limit and by then it is too late to do anything
but die due to OOM.

This also moves the logging of the cgroup memory
stats from COOLWSD into Admin, to avoid duplicate
logging.

Also updated the description of memproportion
config entry to account for the cgroup logic.

Change-Id: I870ae61c1260eb2b3275bd2fa1a4c48ff30957a2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-30 10:36:44 +00:00
Ashod Nakashian a44e9411a8 wsd: admin: minor clean-up of memory-tracking members
Change-Id: If06545a097cd13318870f0e6f675367985035a12
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-30 10:36:44 +00:00
Ashod Nakashian c4470a9687 wsd: do not remove quarantine files explicitly
Let clearOldQuarantineVersions() remove quarantined
files only when necessary and per the config settings.

Change-Id: Ie1fb18c02d61a710546e9b5962ab8b7973c2066e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-27 06:10:17 -05:00
Gökay Şatır 924f13f106 Changes for handling readonly mode click events:
* These changes are made primarily for reading the hyperlink data from the document in readonly mode.
* Added readonlyclick event.
* Added readonlyhyperlinkclicked event.
* And the handlers for these.

When user clicks on document in readonly mode, a readonlyclick event is sent to the server.
Childsession checks if there is a hyperlink at the clicked location.
If so, the information of the hyperlink is sent to the client.

Signed-off-by: Gökay Şatır <gokaysatir@gmail.com>
Change-Id: I9c104a1ec770491725337b9bbb1e2d1c2851321b
2023-12-27 09:24:28 +03:00
Caolán McNamara 24a401c967 the std::ceil inputs are already ints
So std::ceil isn't doing anything useful since:

commit dce6c18fb4
Date:   Thu Aug 30 17:40:42 2018 +0200

    Calculate tiles-on-fly limit a bit more precisely

Leave this case unchanged.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I6d11c9b912facc26ad775fc916012b529ed5b0fa
2023-12-22 14:29:44 +00:00
Caolán McNamara b1ff60ace3 missing tiles in multi-pane spreadsheets
here std::ceil is operating on the result of an int divided by an int
so the input is already an effectively floor-ed int result of the
division so the ceil doesn't do anything

so we end up filtering out some of the invalidates for tiles in frozen
panes.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ibfb25fdfdfb84735ca9410f8250d2e5b9fa1070e
2023-12-22 14:29:44 +00:00
Szymon Kłos 2190cbdc20 Remove protocol when adding to lok_allow
We automatically add allowed wopi hosts to lok_allow.
But we expect to have plain host names, we need to remove
protocol if it is present.

Example:
wopi - group - host: https://.*\.mydomain.com
we need to add: .*\.mydomain.com to lok_allow list.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I80bf3b7c25c0df15e422cd8369eceaddbb588e26
2023-12-20 19:58:43 +00:00
Jaume Pujantell 35d6e2925f use isKitInProcess() instead of KIT_IN_PROCESS
Removed all uses of KIT_IN_PROCESS, used Utils::isKitInProcess()
when necessary. Also removed the now unused parameter 'limit' from
forkLibreOfficeKit.

Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: I068d3f55ab49076590f111847c87b3188f4d25d0
2023-12-18 10:34:10 +00:00
Jaume Pujantell eca990920a add logic to sapwn threads intead of processes
Added code that spawns forkit and lokit in threads instead of new processes.

Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: I6b6ad6dccfedaf28ebd0d68851205c540b9a0317
2023-12-18 10:34:10 +00:00
Jaume Pujantell 8f178ef6cd extract some functions to extra files for in process mode
Extract some functions from ForKit.cpp and COOLWSD.cpp to new files
so we can do a kit in process mode without using ifdef directives.

Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: I7529f8f46a8026318244666b27d1ce72ed5ad4ca
2023-12-18 10:34:10 +00:00
Gökay Şatır ba536c3051 Make sure to set the correct normalized view id for the tiles.
When user switches to dark theme, previously requested tiles' normalizedViewIds may need to be updated.

Issue:
Users sometimes were getting tiles from the wrong theme.

Signed-off-by: Gökay Şatır <gokaysatir@gmail.com>
Change-Id: Ie3324eb3f4879da5bfd0738513409e190422a9c0
2023-12-13 14:05:22 +00:00
Caolán McNamara c231b3b2ec wasm: limit threads using for scaling
disable this with VCL_NO_THREAD_SCALE for wasm

"Yacht.odt" document with lots or large images fails to
render:

Tried to spawn a new thread, but the thread pool is exhausted. This
might result in a deadlock unless some threads eventually exit or the
code explicitly breaks out to the event loop. If you want to increase
the pool size, use setting `-sPTHREAD_POOL_SIZE=...`. If you want to
throw an explicit error instead of the risk of deadlocking in those
cases, use setting `-sPTHREAD_POOL_SIZE_STRICT=2`.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I8b2f994d2d3d23f8a0043f0c7fefa4d5e250b8bc
2023-12-12 20:24:26 +00:00
Caolán McNamara 3d6838e300 serve wasm metadata
[ websrv_poll ] ERR  FileServerRequestHandler: File not found: Invalid URI request: [/browser/515f66e2bc/soffice.data.js.metadata].| wsd/FileServer.cpp:738

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I6e4bb8a5a617f4ff8921430eae1f23147fd1a8cd
2023-12-11 19:28:18 +00:00
Caolán McNamara e903234ec4 cid#336278 COPY_INSTEAD_OF_MOVE
and

cid#318879 COPY_INSTEAD_OF_MOVE
cid#318863 COPY_INSTEAD_OF_MOVE

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I4a2313bd23a0a9b7134d004ebc29db5caebbb17d
2023-12-11 09:25:59 +01:00
Michael Meeks eeea000242 Re-use the current time for a small efficiency win.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I1183a02c5b41554a059cc222f9de82b592ac6322
2023-12-09 21:56:01 +00:00
Michael Meeks 7382a56591 latency: switch tileprocessed to track wire-ids per-connection.
To manage latency, we need to keep the amount of data-in-flight
manageable, this was previously done per-tile - however this is
less useful in the era of small deltas, and seems over-complicated.

Instead track processed tiles by their wire-id to save time,
space & bandwidth.

Change-Id: I1039d8d4ca96fb172278a824fe1ffd55d9fff23e
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-12-09 21:56:01 +00:00
Michael Meeks a9c0db4bcb Significantly simplify tile rendering on invalidation.
Accurate per client tracking of wire-id and avoidance of duplicates
is vital for good delta application, and is done precisely by the
ClientDeltaTracker class.

The inaccurate, _oldWireId tracker imperfectly tracked wireids of
the last tile per session, and used this integer for the boolean
oldWireId used to determine whether to create a delta; in an
un-necessarily complex way.

Instead we more accurately use the TileCache to determine if we
already have a key-frame, and if so use this to encourage Kit to
generate a delta if possible. there seems to be a potential race
though between the Kit's delta-cache size, and what keyframes
we have in the TileCache requiring further investigation, but
this is not a new issue.

Change-Id: If6cec4c1da31f7b715336c60d1dd6f358e1ef6a4
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-12-09 21:56:01 +00:00
Michael Meeks 0e1972faba latency: don't throttle wsd -> kit rendering on render queue size.
Instead throttle rendering only based on the number of tiles on
the fly down the coolwsd <-> browser socket.

It is almost certainly better to let the Kit process sort and
prioritize rendering with a more holistic view of all rendering
requests, and to elide duplicates - rather than to stack-up some
requests in coolwsd.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I566959306815ddc2742a0fe2694df6a1371c6852
2023-12-09 21:56:01 +00:00
Michael Meeks 395b44b6be remove unused code: ClientSession::clearTilesOnFly.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ie5d8212766afb58d19690b607bea6572407e1adf
2023-12-09 21:56:01 +00:00
Michael Meeks dbcf3218c1 welcome back to the 'break' statement - all is forgiven.
Change-Id: I9c64530ce12861ea63f0b6bc2c5d04743d5672b6
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-12-09 21:56:01 +00:00
Ashod Nakashian e836637aae wasm: wsd: coolwsd remembers disconnected mode preference
Switching to disconnected mode works.

Change-Id: I653b282af41bac483c76564fdcf72a83a79065e1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Ashod Nakashian 9deaf06fb5 wasm: wsd: client handler to switch to disconnected
Change-Id: I678ebfae7ed3d9b877a0fe0af6f6ee3add44cb2d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Ashod Nakashian 1653d48a4f wasm: wsd: switch modes handlers - check and save
Change-Id: I7eef953aff077f20c50568b180ab7a1833655533
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Ashod Nakashian fd5c130d2d wasm: wsd: make switching wasm-only
Change-Id: I13386d60a469ec05c5b15369c32c5b3ccdffa232
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Ashod Nakashian 20508cf5a3 wasm: wsd: switch modes handlers
Change-Id: Ic56186baf54a51630f3d902175bee23b118a31f3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Ashod Nakashian 4879049d9e wasm: disable file and color logging
Change-Id: Id9d13552af7e963739e6c30e5faa97519ddec76a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Ashod Nakashian a96f8a0f92 configure: WASMAPP is now defined for WASM targets
This is in line with MOBILEAPP and GTKAPP and
is independent of __EMSCRIPTEN__.

Replace all application-specific cases, leaving
only toolchain-specific ones (such as include
protection).

Change-Id: Ic44288aa5ace51e0a8b54566170c19120f7bf0dd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Ashod Nakashian 1954f9abcb wsd: reduce includes where possible
Change-Id: I99f489e57cb9391ea819d52b49b0d0034a289cf9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-12-09 19:22:24 +00:00
Caolán McNamara 5f1c943a98 add hasWASMSupport to capabilities
so the launching site can query if wasm is enabled to see if it needs to
insert the required headers, so we can then in turn make it optional on
those being set to also require matching headers.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Icd73081809abb8098c21bc61a8357869db45ff6c
2023-12-06 09:58:57 +00:00
Rash419 f203a4d68f admin: indirection add new command for sanity check
- routetoken_sanity_check

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ieaabcd044b65ad0620089ae6413e3f626ff68c4c
2023-12-05 10:46:31 +05:30
Hubert Figuière aa43f7e43b wopi: Added DisableInsertLocalImage
This allow being able to disable pick up of a local image. Handle the UI as well.
To be used with EnableInsertRemoteImage.

Return DisableInsertLocalImage: true as part of the WOPI CheckFileInfo reply
Default value is false (enabled)

Added an 'insertremotegraphic' button to the classic toolbar for use when
it's the only option.

Signed-off-by: Hubert Figuière <hub@collabora.com>
Change-Id: I1925f804433a7bda6025cb65b0943d78927bea15
2023-12-04 20:36:13 +00:00
Michael Meeks 9de0b02e7b Refactor: move tile limit accounting into ClientSession.
Also add state dumping of tile on the fly statistics per session.

Change-Id: I8413cdfd489be3c238738f95d9d5c4aa177ff262
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-12-04 17:45:12 +00:00
Miklos Vajna 2659983faa wsd: fix missing session handling in DocumentBroker::forwardToChild()
To reproduce:

	./clientsession_fuzzer -max_len=16384 fuzzer/data/crash-32e5136d2291e6c5fa99aa5942acded42b66a528

Failed with:

    #7 0x7f1aeb9c9cf1 in __assert_fail (/lib64/libc.so.6+0x42cf1) (BuildId: f732026552f6adff988b338e92d466bc81a01c37)
    #8 0x55a9f13968a5 in DocumentBroker::forwardToChild(std::shared_ptr<ClientSession> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool) /home/vmiklos/git/collaboraonline/online-fuzz/wsd/DocumentBroker.cpp:3613:5
    #9 0x55a9f1676a9a in ClientSession::forwardToChild(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::shared_ptr<DocumentBroker> const&) /home/vmiklos/git/collaboraonline/online-fuzz/wsd/ClientSession.cpp:1414:23
    #10 0x55a9f166f96a in ClientSession::_handleInput(char const*, int) /home/vmiklos/git/collaboraonline/online-fuzz/wsd/ClientSession.cpp:1100:20

The reproducer was originally added in commit
aefc65465b (wsd: fix crash when downloadas
has not enough parameters, 2020-02-21), but now it also triggered this
assertion failure problem as well.

The brave assert was added in commit
b2aff3e817 (wsd: pass ClientSession to
forwardToChild, 2022-11-26).

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I4a0adda49aa2d24925d448fa5753509917d2585a
2023-12-04 16:15:16 +00:00
Rash419 d118874bee wsd: fix: failed to load passwordprotected and csv files
- send blockingcommandstatus after document is loaded
- also fix odd nodocloaded dialog

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I8f0ae405ffa77b47e09c01caf51ddc4fd5e1d862
2023-12-04 11:23:32 +05:30
Caolán McNamara c33a372876 wasm attempt to download file that doesn't exist with reverse proxy enabled
Handling request: /wasm/https:%252F%252Fwhatever%252Fnextcloud%252Findex.php%252Fapps%252Frichdocuments%252Fwopi%252Ffiles%252Fwhatever%3Faccess_token=ozxpkBByLTd9XnWaWHdrTVhMp3Exf1mt&access_token_ttl=0| wsd/COOLWSD.cpp:4093
[ websrv_poll ] INF  #22: Starting GET request handler for session [032] on url [https:%252F%252Fwhatever%252Fnextcloud%252Findex.php%252Fapps%252Frichdocuments%252Fwopi%252Ffiles%252Fwhatever%3Faccess_token=ozxpkBByLTd9XnWaWHdrTVhMp3Exf1mt&access_token_ttl=0].| wsd/WopiProxy.cpp:37
[ websrv_poll ] DBG  #22: Getting info for wopi uri [https://whatever/nextcloud/index.php/apps/richdocuments/wopi/files/212272_ocbizrjb36ht?access_token=whatever&access_token_ttl=0]| wsd/WopiProxy.cpp:120
[ websrv_poll ] ERR  Invalid URI [] to http::Session::create| net/HttpRequest.cpp:664

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I8471ee4247ecab62284e06330bd157aa126b9cd8
2023-12-01 21:02:35 +00:00
Miklos Vajna 89f080ba45 wsd: check for nullptr channel in AdminSocketHandler
This can happen like this:

    #8 0x7f14fdf4ec86 in std::terminate() (/usr/lib64/libstdc++.so.6+0xb7c86) (BuildId: c74eca671e2dd0f063706372d103f8acef88f1e3)
    #9 0x7f14fdf4eee7 in __cxa_throw (/usr/lib64/libstdc++.so.6+0xb7ee7) (BuildId: c74eca671e2dd0f063706372d103f8acef88f1e3)
    #10 0x55ddc5b906d2 in Poco::AutoPtr<Poco::Channel>::operator->() /usr/include/Poco/AutoPtr.h:232:4
    #11 0x55ddc5b7eb07 in AdminSocketHandler::handleMessage(std::vector<char, std::allocator<char>> const&) /home/vmiklos/git/collaboraonline/online-fuzz/wsd/Admin.cpp:236:13

Note how LOG_ANY() assumes that Log::logger().getChannel() is not
nullptr (so the caller has to check for it), while the more typical
variants with a log level like LOG_TRC() already do a similar check via
LOG_CONDITIONAL().

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I5e1379f33e6640fd07de673ef0d07b1d4d611c89
2023-12-01 15:35:39 +00:00
Szymon Kłos a243bc9f49 Add list of allowed data sources
- uses new lok_allow setting to provide such list
- for backward compatibility uses also all post_allow and storage.wopi
  entries
- Used for example in: PostMessage Action_InsertGraphics,
  =WEBSERVICE() function, external reference in the cell

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Ib930e0119d4ea124b9cd565f6b3683310b1b3ced
2023-12-01 15:25:47 +00:00
Miklos Vajna dc149702ae doc broker: handle no _storage in uploadToStorageInternal()
Similar to commit eb5c86a4d3
(DocumentBroker::saveToStorage: guard against nullptr _storage,
2020-10-26), with the same input.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I17ac2bc12ba086d16ccbf3d5c758e081a32cbf5a
2023-12-01 09:17:36 +01:00
Rash419 2c78023630 Revert "wsd: disable ctrl+s when HideSaveOption is true"
- fix: disabled 'Action_Save' postmessage when HideSaveOption is true

This reverts commit 34f3dd4a62.

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I5e6425621550153547278a61a936ba9dc7e4aad1
2023-11-30 14:00:03 +01:00
Caolán McNamara 48002c5d40 allow testing wasm in non-debug mode
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I583a8104f590e26a76837bef00814684e2015c7a
2023-11-30 12:58:42 +00:00
Miklos Vajna 07db53bb6e wsd: handle Poco::URISyntaxException in AdminSocketHandler::handleMessage()
terminate called after throwing an instance of 'Poco::URISyntaxException'
    #8 0x7f014e70dc86 in std::terminate() (/usr/lib64/libstdc++.so.6+0xb7c86) (BuildId: c74eca671e2dd0f063706372d103f8acef88f1e3)
    #9 0x7f014e70dee7 in __cxa_throw (/usr/lib64/libstdc++.so.6+0xb7ee7) (BuildId: c74eca671e2dd0f063706372d103f8acef88f1e3)
    #10 0x7f014dcea45b in Poco::URI::decode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, bool) (/usr/lib64/libPocoFoundation.so.92+0x15145b) (BuildId: 32601204eb877c998d0122c4bef1c7c08c8d0285)
    #11 0x56496c48320b in Util::decodeURIComponent(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /home/vmiklos/git/collaboraonline/online-fuzz/common/Util.cpp:800:9
    #12 0x56496bb21ec0 in AdminSocketHandler::handleMessage(std::vector<char, std::allocator<char>> const&) /home/vmiklos/git/collaboraonline/online-fuzz/wsd/Admin.cpp:84:20

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I07551d92be5ae677d1cf63f0f0092fb838583337
2023-11-29 15:41:00 +00:00
Miklos Vajna 1e125c7bdc Fix fuzzers build
- the HttpEcho build broke with commit
  08d9081280 (net: don't try to set
  TCP_NODELAY on local Unix sockets., 2023-10-30)

- fix an unused variable error from commit
  0631593c96 (wasm: proxy wopi documents,
  2023-11-06).

- the undefined reference to COOLWSD::ForKitProcId probably went wrong
  in commit 3f46c1db44 (kit-in-process:
  pure re-factor to a run-time function to flag this., 2023-11-20)

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I0cf06d188860bdb2f795485a91c7634b596255aa
2023-11-29 15:41:00 +00:00
Caolán McNamara 74b9c72814 need this even if we want to not serve wasm if the headers exist in richdocuments
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I310894e5a72002406eff77b07af76c2b048ffacc
2023-11-27 10:48:44 +00:00
Caolán McNamara 5232e3d735 hack to get this up and working
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I6d3d273f59f58a0c3b2027039dcc7de95ad971b9
2023-11-27 10:48:44 +00:00
Ashod Nakashian 0631593c96 wasm: proxy wopi documents
Change-Id: I3104ac9a6fd180f11aef06b9d4f516a392e021a9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-11-27 10:48:44 +00:00
Ashod Nakashian 7abeb96cd1 wsd: add StorageConnectionManager::createHttpRequest
Change-Id: Ie690e9c4ea33ae8cea8355d414ed137e7d5130ba
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-11-27 10:48:44 +00:00
Ashod Nakashian a624a704ac wsd: add StorageConnectionManager
StorageConnectionManager centralizes the
connection creation and management of
Storage sockets and related bits.
This is needed as we move to a more async
model of communicating with the Storage.

Change-Id: I7a44c95c113bbc536e922b5aa3f7cf9b71917c22
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-11-27 10:48:44 +00:00
Ashod Nakashian 94d213c39e wsd: cache files that need no compression separately
Change-Id: I7b46becd330a7a09a05b7973b18c92679104f597
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-11-27 10:48:44 +00:00
Ashod Nakashian b045c2a7b4 wsd: fix compiler warnings
Change-Id: I9ffa81d97c3b04b4c0608466892f9b59a896e509
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-11-27 10:48:44 +00:00
Darshan-upadhyay1110 de4fe0dfd8 Fix downlaod options in read only mode
- Allowed downlaod options for PDF/PDF as /EPUB
- PDf/PDF as/EPUB will be downlaod in read only mode
Signed-off-by: Darshan-upadhyay1110 <darshan.upadhyay@collabora.com>
Change-Id: Ic6e0c4a16fa5dffc61e61fd4ece9aeeaec1450b9
2023-11-24 09:26:59 +01:00
Darshan-upadhyay1110 3f46c1db44 kit-in-process: pure re-factor to a run-time function to flag this.
Avoids a number of compile time conditionals and adds flexibility.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Iff6b294b504526e70715e436ad33d47c8df4752c
2023-11-22 17:06:29 +00:00
Michael Meeks e9f5f04dad config loading: avoid using the process name to find the config file.
This enables the kit-in-process re-factor.

Change-Id: I93eb0a721945fb7b03e145b6c9d037ef3ce62589
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-22 17:06:29 +00:00
Rash419 34f3dd4a62 wsd: disable ctrl+s when HideSaveOption is true
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I190a03abcf80176cc2da77fd32190c683852b9a7
2023-11-21 16:13:52 +05:30
genofire 2c63cf62d8 fix: rename metric from doc_pid to doc_info
Change-Id: d03c077629b343e9b4cefd5914e74f89
Signed-off-by: genofire <geno+dev@fireorbit.de>
2023-11-18 14:12:53 +00:00
genofire e4ac11756a fix: metrics doc_pid use pid as label
so it would be use on the other metrics for lookup with promql group_left

Change-Id: eaba5e26f99b4cb0843c16f6f5b840c6
Signed-off-by: genofire <geno+dev@fireorbit.de>
2023-11-18 14:12:53 +00:00
Michael Meeks 1a4dafa3e5 Fetch available memory and limits from our control group not the system.
To test:

sudo mkdir /sys/fs/cgroup/memory/0
echo "900M" | sudo tee /sys/fs/cgroup/memory/0/memory.limit_in_bytes
echo $$ | sudo tee /sys/fs/cgroup/memory/0/tasks
make run # and check the log.

Change-Id: I81cf5f6212418d1f900a56cdfe476e1594f4fe77
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-14 19:36:31 +00:00
Michael Meeks 7183a3d3de spdx: improve machine and human readability of headers.
Change-Id: Ice934380029bf27054e830fffc07a5d037d1430f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-14 19:36:31 +00:00
Michael Meeks 2238a40cca Log thread count and memory usage on startup.
Helpful for diagnosing resource constrained systems.

Change-Id: I9e31298d6fa1f5243175350ba48699c0772d486c
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-14 19:36:31 +00:00
Caolán McNamara ed8f95c1bc empty updates seen on first view of document
this is visible even with hello-world.odt in the debugging overlay where
I have 9 cols and 7 rows visible.

Load hello-world.odt and from the 4th row, 8th col onwards each tile has
a "upd: 1" of an additional empty delta update to the original tile

browser-side:
a) we have one OUTGOING: tilecombine request which which requests an
   initial 72 tiles (9 cols, 8 rows)
b) we then receive 72 tiles as requested
c) and browser sends back tileprocessed for each
d) but we then get a series of (38) delta: requests after that which are
   unexplained

server-side:
a) on the initial tilecombine, DocumentBroker::handleTileCombinedRequest
   sends the 72 requested tiles for rendering and registers to send each when
   ready.

    for (auto& tile : tileCombined.getTiles())
    {
        ...
        tilesNeedsRendering.push_back(tile);
        ...
        tileCache().subscribeToTileRendering(tile, session, now);
    }

    // Send rendering request, prerender before we actually send the tiles
    if (!tilesNeedsRendering.empty())
        sendTileCombine(TileCombined::create(tilesNeedsRendering));

    and stores what tiles it want to send in session->getRequestedTiles()

    before calling sendRequestedTiles(session);

b) at this sendRequestedTiles (also later when tileprocessed is seen from
   each tile response from the browser which also calls sendRequestedTiles), then:

c) DocumentBroker::sendRequestedTiles loops over existing requests and drops
   from session->getRequestedTiles() both the tiles that it can send immediately,
   and those that are queued to get rendered.

d) But it only does this for a max amount of tiles, based on beingRendered, up to
   a tilesOnFlyUpperLimit. beingRendered is bumped for each tile not ready yet,
   on the assumption that it needs to be rendered.

e) But we already have some getting rendered, and bump beingRendered anyway,
   so tilesOnFlyUpperLimit can easily get exceeded on a first page, typically this
   first sendRequestedTiles loop stops early, and stops dropping tiles from the
   request queue that are already queued to be rendered.

f) at some point we get a tileprocessed and sendRequestedTiles is called again,
   the request queue wasn't emptied, and by now it is likely the tile cache has
   results for them (which were already sent) and sendTileNow is used to send those,
   resulting in additional empty deltas sent for fulfilled queries.

logs will show "Redundant request to subscribe on tile" warnings in this case

Here as a conservative improvement only increase beingRendered if the sendRequestedTiles
subscribeToTileRendering actually does anything.

There is a mismatch in what handleTileCombinedRequest does vs what
sendRequestedTiles does. Maybe handleTileCombinedRequest should leave it
to sendRequestedTiles to do the sendTileCombine, or maybe
handleTileCombinedRequest shouldn't add those tiles to the session
requestedTiles.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I3044f4b3e47f00c680aa5b87dd7bdad2f27e8c73
2023-11-13 14:27:53 +00:00
Skyler Grey ff1e4eeb57 Add a ui_defaults hint for touchscreens
At the moment, we try to detect whether the browser is running with a
touchscreen, however this is very imperfect. It's possible an integrator
may have more information about whether COOL is running on a device with
a touchscreen, so this ui_defaults option allows us to specify. Touch
mode binds inputs for touchscreen devices (long press for menu, pinch to
zoom, etc.) and does not bind the normal inputs (right click for menu,
etc.), so it's crucial to get it on all touch devices and no desktop
devices, as input is severely hampered if they are the wrong way round.

The option is called TouchscreenHint. Setting it to 'true' will enable
touchscreen mode, setting it to 'false' will disable touchscreen mode.
Leaving it undefined will keep our detection active.

This option must be set at page load so we can register the right
events at creation time. Therefore, ui_defaults is perfect as a method
to override this.

This is not a long-term solution. Instead, "The right thing" is to look
specifically for touch events and specifically for mouse events, rather
than using the default hammer.js behavior which is to look for both...
that should be an eventual followup to this. However, this was a lot
faster to implement and helps with the most pressing issue: not being
able to override our detection when it goes wrong.

Change-Id: Id28a156fe352fe6565ce6b472b7aa54d0869c48e
Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
2023-11-10 23:20:22 +00:00
Andras Timar 23574cd6b6 missing continue keyword
Caused log ERR on startup:
[ websrv_poll ] ERR  unknown UI default's component UITheme| wsd/FileServerUtil.cpp:99

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I82f036e393cfb271e2dec2c52c5dc512aed265c8
2023-11-09 13:36:45 +01:00
Hubert Figuière 00050a59c2 browser: Add ui_default to hide the toolbar
Signed-off-by: Hubert Figuière <hub@collabora.com>
Change-Id: I189224581451c9f5d534593696b060c8efb23414
2023-11-08 23:34:17 +00:00
Skyler Grey 7175c7841b Add a ui_defaults option for onscreen keyboards
The new ui_defaults option OnscreenKeyboardHint is a tristate denoting
whether the device accessing Collabora Online has an onscreen keyboard

If unset, Collabora Online will do its best to guess. At time of
writing, this is the same as checking if the device is a mobile phone
or a tablet (note: only tablets which have the browser registered as a
"mobile" browser will be detected, e.g. the Microsoft Surface tablets
would not be detected)

If "true", Collabora will assume the device has an onscreen keyboard.
This will change when we trigger the keyboard, for example in calc if we
know of an onscreen keyboard we will not automatically focus a cell for
editing when it is selected, as this would pop up the keyboard.

If "false", Collabora will assume the device does not have an onscreen
keyboard, effectively doing the inverse of the "true" option above.

This is a followup to #7580 (0bf054c9a3)
which had Hint_OnscreenKeyboard and Hint_NoOnscreenKeyboard as
postmessage IDs to do the same thing.

Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
Change-Id: I5deeb87a410c135d4cabda7ed24dc37e791800cd
2023-11-08 16:20:49 +00:00
Hubert Figuière 1114af585a default-ui: Allow skipping the UI state saved in local storage.
Pass SavedUIState=false to the ui_defaults

Signed-off-by: Hubert Figuière <hub@collabora.com>
Change-Id: I2cceffed338440d1fee5b0818e072ecc02379468
2023-11-08 10:12:42 -05:00
Michael Meeks 08d9081280 net: don't try to set TCP_NODELAY on local Unix sockets.
Change-Id: Ic0f720554080a01b7a46abbffda023834016c0ea
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-01 08:06:53 +00:00
Michael Meeks 47b89b32ef spdx: improve machine and human readability of headers.
Change-Id: I1b6dcd2ec1fbef6556d70b8af3ccfd5d6a95c59a
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-10-31 10:33:07 +00:00
Ashod Nakashian 8728cd5ea1 wsd: config cleanup and warning fixes
Change-Id: Idb66227d98f8fcca35307c3598a1fcc6b69e38c6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-26 20:31:45 -04:00
Areg Nakashian 8a735d4faf Remove unused requestloksession command
This removes the unused requestloksession command
and all references to it, including protocol documentation.

Signed-off-by: Areg Nakashian <ss4crifice@gmail.com>
Change-Id: I8c410460a5f500f724996fbcbf8f9650028daaf9
2023-10-24 21:35:38 -04:00
Ashod Nakashian d9d13d7092 wasm: support serving wasm files
Updates README with instructions.

Change-Id: I5188d3ca267ff88a956dc17f302a70bda1046266
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 21:33:02 -04:00
Ashod Nakashian 184a4a522e killpoco: replace HTTPResponse in sendFileAndShutdown
We now use our http::Response in HttpHelper::sendFileAndShutdown.

Change-Id: I77503fce7a66a11435bad896d3d5d6df611544be
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 21:33:02 -04:00
Ashod Nakashian bd056aef91 wsd: test: proper parsing of http header in UnitHttp
This removes the literal string comparison of the
received http header with proper parsing and
comparison.

Change-Id: I383794aa1dc791632ec9d5ed2191880a57d457ee
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 21:33:02 -04:00
Ashod Nakashian 6ed5dc9a64 wsd: http: no need to pass the mime-type explicitly to sendFile
Since we already have an http response instance (in all but
one case, prior to this change), there is no need to pass
the mime-type explicitly to the sendFileAndShutdown
function, only to set it on the http response.

There are already too many arguments and the mime-type
is surely redundant.

Change-Id: Iab64074dc111573b87fb8fa9b907c26a4160910c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 21:33:02 -04:00
Ashod Nakashian 0c59eda780 wsd: http: use named HTTP status-code instead of naked int
Self-documenting, less error-prone, and searchable.

Change-Id: Ifc21d7cf5512d9a63c5d5bc10ebc003fcccc93c1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 21:33:02 -04:00
Caolán McNamara 3a9089ea95 cid#318929 Big parameter passed by value
this is called from only one place where the arguments are already
passed by const reference, i.e.
void AdminModel::addDocument(const std::string&, ...  const Poco::URI& wopiSrc, ...)
so might as well forword as const reference and construct the copies in
this ctor.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I4fe0ed4a4dd8cb71aa970798760d8488be68f82b
2023-10-24 09:23:47 +02:00
Caolán McNamara 03782fff83 cid#318932 Structurally dead code
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I7dc171a701825c67abf1df9b13c5df689e1d0921
2023-10-20 17:01:47 +02:00
Caolán McNamara 7c9c0f487e cid#321979 Big parameter passed by value
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Id514b14c6bfda08cd561d5c75ab2430b933a8919
2023-10-20 17:01:47 +02:00
Szymon Kłos 181cb7fe78 Fix media request error
It fixes richdocumentscode case when trying to request media:
[ websrv_poll ] ERR  #-1: Failed to open file [.../9a2gf9.ogg] for uploading| net/HttpRequest.hpp:1603

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Ia326f46a4a1aae28dbf03519ca88c03f499c281c
2023-10-20 11:40:07 +02:00
Caolán McNamara 6c67b072fa cid#318855 Unchecked return value from library
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I9572414e3cfc8426ca6b25872231470f072c5aad
2023-10-20 08:25:07 +02:00
Caolán McNamara df1cb7164c cid#318873 don't pass object by const reference
Poco::JSON::Object::Ptr anonObject(object) is effectively a
const_cast and the comment in the header warns that object
may be modified, so just pass it by non-const and drop the cast
and merge the resulting duplicate stringify call

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I9701ae95ff991b0dece854f295ba76ac9b3c2fa5
2023-10-20 08:25:07 +02:00
Gülşah Köse 81c2f16302 coolwsd.xml.in: Add possibility to disable overwrite mode
It seems large groups of people don't have a use for overwrite mode
- Would like to avoid enable it by default

This is just the first step on improving the user experience here.

------

The whole plan would be to:
- 1st Follow up PR
  - Where we disable the overwrite mode when enableExperimental is true
  this we will be able to see if community likes that change or not before making it everywhere
- Other possible improvements
  - Triger a snackbar for the first time the user press the Insert key
    - If the feature is disabled we would show snackbar with timeout
      "Overwrite is disabled. Please contact admin."[Dismiss]
    - If the feature is enabled we would show snackbar with timeout
      "Overwrite mode is now enabled" [Disable] (Disable here means the same action as pressing again the **Insert** does)

Signed-off-by: Gülşah Köse <gulsah.kose@collabora.com>
Change-Id: I060b3d2d9d1e7e29a18f5ea1d619c9349eae67c3
Signed-off-by: Pedro Pinto Silva <pedro.silva@collabora.com>
2023-10-20 06:39:18 +02:00
Caolán McNamara c4e973ee5e cid#318817 avoid Uncaught exception
and

cid#318819 Uncaught exception

take a reference in the COOLWSD/DocumentBroker ctor, so indicating it
exists before the calls in the COOLWSD/DocumentBroker dtor, and so the
Admin ctor doesn't throw during the COOLWSD/DocumentBroker dtor.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I8190cc3594a5f81fedd355aeadcca45e532bda90
2023-10-19 08:45:23 +02:00
Cosmin Humeniuc 7dae294a71 Avoid logging messages when anonymization is on
Signed-off-by: Cosmin Humeniuc <cosmin.humeniuc@1and1.ro>
Change-Id: I5bcf615521d13758b2b70a0c9466a3bbc1a0a918
2023-10-18 16:22:31 +01:00
Caolán McNamara 53d84b4382 raise quarantine logging to WRN and include more information
scraping the logs with:

if line.find('Backtrace ') != -1:
    pid = re.findall(r'Backtrace ([0-9]+?) -', line)
    if pid:
        for file in os.listdir("/opt/cool/quarantine"):
            if file.find(pid[0]) != -1:
                ...

shows an unexpected lack of hits

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I63b5e62a5d46627146763cb0f847b976017f6c4b
2023-10-18 16:55:53 +02:00
Caolán McNamara 5acb4138e3 cid#318873 silence bogus Double free
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ie4b0753e305f2232673837bcf7a376ad7622c120
2023-10-18 08:31:41 +02:00
Caolán McNamara acbea27acf cid#318979 Big parameter passed by value
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Iae9f67cf8bd71d8df51409e91606c68b51244ac2
2023-10-18 08:31:41 +02:00
Caolán McNamara f86d894eb1 cid#318862 Dereference after null check
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Idf2a678a56531b7e3c3a51f6e86582bb9ac69dc7
2023-10-18 08:31:41 +02:00
Pranam Lashkari 93b5bdfd79 feature-locking: send lock/restriction status from client session
problem:
earlier restriction/lock status was sent to kit via browser,
now client session send this status directily to the kit.
this design will require less communication between server and browser

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I6b830f30fb326a5e6637e345250893cbba101de6
2023-10-18 03:05:40 +07:00
Caolán McNamara 395d6c9f12 Assertion in DocumentBroker::sendRequestedTiles fails on running cypress impress tests
make -C cypress_test check-desktop

asserts seen in cypress_test/cypress/wsd_logs/coolwsd_output.log of:

coolwsd: wsd/DocumentBroker.cpp:3134: void DocumentBroker::sendTileCombine(const TileCombined&): Assertion `!newTileCombined.hasDuplicates()' failed.

If we check for, and don't reuse, an old request with a different
NormalizedViewId then we could end up with multiple requests with
different NormalizedViewIds that end up in the same final tilecombine.

similarly there was no check for different modes ending up in the
same tilecombine.

just split out the logic we have to see if two tiles have the same
properties that appear as a shared set of properties for tilecombine
and use that in the two relevant places.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ieb2ee0e85f124dd57c6b050e5b669dd808cf6bbf
2023-10-17 17:05:24 +01:00
Rash419 11a0e78ed4 admin:log activities irrespective of logging.level
- It logs activities like when admin logged in, authenticated
  metrics endpoint accessed, external monitor getting connected
  and admin actions like kill the document etc

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I059f6b6ee0d8269aec7e3f521622773e348304a3
2023-10-17 14:57:10 +05:30
Caolán McNamara 8afe3dc922 different tile widths in requestedTiles on switching calc tabs
if we zoom in calc quickly that can result in still unfulfilled requests
for the first set of tiles from the earlier zoom in requestedTiles when
the new requests are compared with the existing one for duplicates, but
they are of different tilewidth/tileheight and shouldn't match as a
duplicate.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ifc3f905c5304feb6c05696835dcb4eaed7f1e546
2023-10-16 14:35:53 +02:00
Caolán McNamara 724c0ca7a6 cid#318860 Unchecked return value from library
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I765e71d76ff4be8ef7a92b060af026e3c26f669b
2023-10-16 09:37:01 +02:00
Caolán McNamara 54c63f6cc1 different 'parts' in requestedTiles on switching calc tabs
if we switch calc tabs quickly that can result in still unfulfilled
requests for the first tab in requestedTiles when the new requests are
compared with the existing one for duplicates.

It doesn't make sense to replace a request for a new tile with an old
request from a different part. But tilecombines are intended to share a
'part', so a single tilecombine shouldn't be synthesized from multiple
requests for different parts.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Id8d40f0a7e7f9d32fed67a415756284d7f6a53d4
2023-10-15 19:28:43 +01:00
Skyler Grey 2666063040 Allow http Range header for media files
The range header allows a client to specify that they would like only
part of a file, e.g. only the first 1000 bytes of a video. When playing
video on Apple devices (Macs, iPads, iPhones etc.) this is required to
avoid Safari rejecting the video as broken. This is the first part of a
fix to embedded videos on Safari.

This commit does not implement specifying multiple ranges at once (e.g.
bytes=0-9,-100 to get the first 10 and last 100 bytes).

This feature is necessary to play video on Apple devices, but it is not
sufficient. In particular, I believe some further client-side fixes will
be needed to make the video play properly.

Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
Change-Id: Id89a06d374b7d0efbf2b3184d8618df61684dcb6
2023-10-11 15:09:15 +00:00
Rash419 3c20783ac6 admin: added id field in verifyauth msg
- this id will help to identify which adminClusterOverview socket
  has sent verifyauth message from controller

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ic09b33c9eb2c0072f84b7147acc673031dbac0d8
2023-10-10 13:10:44 +05:30
Caolán McNamara 15c85f3b41 cid#318938 silence Unchecked return value from library
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ic2770254b709fcadcbb551b8b37382541be06902
2023-10-09 10:24:11 +02:00
Rash419 246e0eb191 fix: docker failed to initialize when aliasgroups is passed
wsd-00001-00001 2023-09-07 06:57:38.412560 +0000 [ coolwsd ] FTL  Failed to initialize COOLWSD: Syntax error: Cannot convert to boolean: | wsd/COOLWSD.hpp:513
Syntax error: Cannot convert to boolean:
<shutdown>-00001 2023-09-07 06:57:38.413335 +0000 [ coolwsd ] SIG   Fatal signal received: SIGABRT code: 18446744073709551610 for address: 0x6400000001

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I446bc9b2c2172d820da2ea148eefd1d7f964be80
2023-10-07 16:33:54 +05:30
Caolán McNamara 1f9c1885b9 cid#323357 silence String not null terminated
it's a good catch, but inotify man page says it can't happen

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I350f8fad2aa8308563ccb4f9f3ec9b7850a72fa7
2023-10-07 08:35:04 +00:00
Rash419 72da1dccaf docker: fix all aliasgroup env variable values added to blocked list
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Id7480ab88564965cc7aba34c5020daaf18259815
2023-10-05 11:17:49 +02:00
Caolán McNamara 0ba51f81e7 promote quarantine log message from debug to warn
and tidy the message wrt crash after/before change

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ie4b4b700e7b1e029d077e5726bd35ff4e769fb6d
2023-10-04 17:29:25 +01:00
Caolán McNamara 5b085dec8e quarantine document after an unexpected disconnection from kit
so we capture crashes that happen while a document loaded before
any modifications could take place.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Id8b9ae3e6921aa0be770dbe1ad8fcf9b53a85e8d
2023-10-04 17:29:25 +01:00
Caolán McNamara ec10114f2f quarantine of unmodified original file doesn't succeed
Error while copying from foo.ods to /opt/cool/quarantine/1696408774_5231_blah_foo.ods: Failed to open src foo.ods| common/FileUtil.cpp:162

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I49143f4d7df0c4c1494f28f8f6fe03d8cb045ab0
2023-10-04 17:29:25 +01:00
Caolán McNamara 672f3cee2c rework URP to use a dedicated channel
Instead of fighting the SolarMutex to get the messages
processed by the main loop. Simple and no additional
threading, mutexes etc.

messages from the external uno client are just
written to URPtoLoFD and the core reads from that

messages to the external uno client are written
to URPfromLoFD by core, that fd is in poll, and
activity there triggers a read by the DocBroker
to send it to the external uno client.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ib1f0a0d5fb5ab22eee476d5d740b290c51de59dc
2023-10-03 10:15:55 +01:00
Skyler Grey e6d9c1f87c Add support for URP messages in COOLWSD
- Allow COOLWSD client sessions to forward messages with the prefix
  'urp' to the child, and return messages with 'urp:' to the client,
  communicating with binary
- Make COOLWSD child sessions use the FunctionBasedURPConnection from
  https://gerrit.libreoffice.org/c/core/+/155100
  (core change ID I2bda3d0b988bef7883f9b6829eeb5b7ae8075f27) to start a
  new URP session
- Make COOLWSD child sessions submit messages to this URP session,
  stripping and adding the 'urp' and 'urp:' prefixes so the Java client
  from https://gerrit.libreoffice.org/c/core/+/154680
  (core change ID I91ee52922a24688a6b94512cb7e7bc760bf25ec9) can
  use the connection (and to avoid interference with any other websocket
  messages)
- Add a COOLWSD option for enabling/disabling URP given the security
  implications around allowing anyone to write URP (e.g. URP lets you
  run shell commands so a mallicious actor can take over the child
  session)

Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
Change-Id: Idadfe288a78cfd72b01253dfdade150d506e3f05
2023-10-03 10:15:55 +01:00
Ashod Nakashian c936f0e713 wsd: set up signal handlers early
There are very rare cases (with unit-tests)
where due to early race-conditions a signal
is raised. This helps us catch those early
cases, before the Poco config and init are
executed.

Such a case exists with tzset() and setenv().
While getenv() is thread-safe, setenv() is
not. When tzset() calls getenv(), it can
race with setenv() from a different thread.

Since we only call setenv() during
initialization, this risk is only at startup.

Change-Id: I5e3e593a5d93dd9335d8dfde932f764a45c975c1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-02 20:14:53 +01:00
Caolán McNamara 131d503b93 reduce cost of TileCombined::parse
perf reported 1% of time in collaborative multi user test
on 2023-09-14 was spent in TileCombined::parse.

generic-ize and reuse the TileDesc::parse approach for
TileCombined::parse to avoid need for std::unordered_map

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Iadfc2001e298d8f4d46200c8488f0eb4cd8734c2
2023-10-02 20:05:07 +01:00
Rash419 9d6b1d148b don't request new tiles unnecessarily on canonicalidchange
- it applies for 2 cases:
1. when document is loaded for the first time document already has
tiles of respective theme
2. when Kit loads the document it sends canonicalidchange  unconditionally
(5520965b15/kit/Kit.cpp (L1708))
we don't need to request new tiles for that also

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I42cdc5a03e70c3d3d653f3124d3d5ed9382e22c0
2023-10-02 13:29:25 +05:30
Ashod Nakashian b58ca4be5c wsd: test: remove duplicate uninit
Change-Id: Idc6aa0f7edfdcb7f6cf0fc3e92ff830215f6c1da
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 19:29:12 -04:00
Ashod Nakashian 21889aca26 wsd: add LOG_ASSERT to replace assert with extra logging
In NDEBUG builds, where there is no assert macro,
we log at debug level to still find issues without
adding noise to the logs.

However, in ENABLE_DEBUG builds not only do we assert
but we also log at error level.

Change-Id: I773dbf7bb2b459e505e73d91505b13d8ed2ed6d8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 19:29:12 -04:00
Ashod Nakashian 96bc73ea17 wsd: simpler string appending in readDirToHash
Change-Id: I13c741bd5cae3cfe4ffb1a71ddc2de650356ac4b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 19:29:12 -04:00
Ashod Nakashian 4bf309d136 killpoco: serve the Welcome file using http::Response
Change-Id: Ia29a881f8ec53aa1d48c20240ecc0e01b58ef2b6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 19:29:12 -04:00
Ashod Nakashian 7aed4c0461 wsd: const correctness
Change-Id: I1be6a2055d906b590d7801f9873a48d510c78a0b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 19:29:12 -04:00
Ashod Nakashian d2ebd4cff7 wsd: FileServerRequestHandler instance
This encapsulates and manages the lifetime of
file-serving cache in an instance of
FileServerRequestHandler. Previously, it was
all done through static functions and explicit calls.

Change-Id: I1b0bf0e3c25e6ae82c398bf5d0de255a6fec42a1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 19:29:12 -04:00
Ashod Nakashian 968ab3e529 wsd: test: move File-Serve whitebox tests to own file
Change-Id: I4e659f28636cc78beca3c05ed7f23ef714d32063
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 08:58:39 +02:00
Skyler Grey 1b3218df04 Add cli option to use settings from env variables
Currently [in docker it is possible to do configuration through
environment variables](https://col.la/dockercodeconfigviaenv), which
works using the start-collabora-online.sh start-collabora-online.pl
scripts. This commit lets COOLWSD listen to the same environment
variables directly

Change-Id: I75762ad620132037523fa82167a3ff17075c7027
Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
2023-09-23 12:44:50 +02:00
Skyler Grey d94dbf8c32 Option to stop coolwsd when configuration files change
- This patch only adds an option to enable this feature. It is off by
  default
- This allows you to, say, have a docker container and --restart=always
  to restart when you update the config
- This patch only listens for "/etc/coolwsd/", so if you specify a config
  file that isn't there then you're out of luck... An improvement for a
  followup patch will be make it listen to wherever your config files
  actually are
- The current docker scripts only listen for modifications, so this
  matches that behavior

Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
Change-Id: I674756b0188893f5d192885bb436256aa827e7b5
2023-09-23 12:42:21 +02:00
Ashod Nakashian 0b27e85fc5 wsd: comments can be added to PDF files which otherwise are readonly
This fixes a regression where PDF comments were lost when
the document closed immediately after adding a comment.

Change-Id: Iac78ec13fdbaa7d1ffe25067ea0f41704abb3312
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-21 08:23:36 +02:00
Andras Timar 17c77bf059 Revert "wsd: exclude readonly sessions from modification indication"
This reverts commit e6798e9062.
Reason: this commit caused a regression. PDF comments were not saved.

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I180ecb9e298e37bd5a989a8cd6d23d02c25a6929
2023-09-20 19:57:01 +02:00
Caolán McNamara 084e715dc6 TileDesc broadcast field is always false
apparently since:

commit b0a7532b08
Date:   Sat Nov 14 19:43:02 2020 +0300

    Turn off broadcast on presentation preview tiles

so drop this field from TileDesc and protocol.txt

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ib4b1eca0d30911e13c245551cb3e3261afc99dd2
2023-09-11 09:38:49 +01:00
Caolán McNamara 3b7ef07997 getTokenString is another loop over the tokens that we already loop over
getTokenString(const StringVector& tokens...) loops over each
token and calls
getTokenString(const std::string&...) with token.getParam() on each
token. We already have a loop over each token, so we can merge those
loops here.

perf reports TileDesc::parse taking 3.68% of the time in a hour
of an interactive writer session with multiple participants

Though looking further, broadcast seems unused by anything now.

To be followed up on that topic.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I244637043c58d90562001ec58fac494da54e55a8
2023-09-11 09:38:49 +01:00
Paris Oplopoios 1b9a186c01 Turn canonical id assertion into warning for now
Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: I7e332b5e5a0c6a8ce5a428caf4c23274b9be8d82
2023-09-08 14:46:21 +02:00
Rash419 855429dad5 admin: send serverId with migrate msg
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I484620df234a1dcbedeba5b5102dacee7451015a
2023-09-07 18:35:32 +05:30
Paris Oplopoios 0621aa4825 Fix canonical id related unit tests
Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: Ie4b965c3bac8cddd48a47343d2d1c5f387d8bd41
2023-09-06 10:28:26 +02:00
Paris Oplopoios 5409175a2a Add assertions for bad canonicalviewid
Change-Id: I2621e08123ca9cac30e027b0c018c0e9cc40750d
Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
2023-09-06 10:28:26 +02:00
Ashod Nakashian e6798e9062 wsd: exclude readonly sessions from modification indication
Read only sessions cannot modify the document, so
we shouldn't consider input from such a session
as potentially modifying the document. This
becomes important during an abrupt disconnection
where we look at isPossiblyModified() as an
indicator for data-loss.

New unit-test that reproduces the corner-case
with disconnection. With graceful unloading
a previous unit-test verified that it worked
as expected.

Change-Id: Id84cda4f4599c559018247c32ea1205e154e4984
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-01 07:18:12 -04:00
Miklos Vajna 9b3139d65a wsd: fix -Werror,-Wimplicit-const-int-float-conversion
wsd/ClientSession.cpp:520:32: error: implicit conversion from 'uint64_t' (aka 'unsigned long') to 'double' changes value from 18446744073709551 to 18446744073709552 [-Werror,-Wimplicit-const-int-float-conversion]
                    (counter < (uint64_t)(std::numeric_limits<uint64_t>::max() / 1000)))
                             ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which is a problem since commit e0b70657fa
(cid#318912 Result is not floating-point, 2023-08-23).

Let's make the conversion explicit, hoping that makes both Coverity and
clang happy at the same time. No change in actual behavior intended.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Ib9727f0df4df65a9504d421654d519bee0733b80
2023-08-30 09:25:27 +01:00
Rash419 3ce8c1b224 feature_lock: fix unlock_image option not working
- regression from ec17f72fb5
- also removed the restriction to have "static" in unlock_image
  url

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ie4f1170fb6a12db5218fb28f21d78f88ebc61d56
2023-08-28 16:12:41 +05:30
Rash419 303001623f admin: use sendTextFrame for verifyauth msg
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ib5c4144df168f5a649ce2a4a3a8690eb9de0f723
2023-08-28 10:29:29 +05:30
Rash419 319c6e4570 admin: add new command to verify auth token
- original auth command shutdowns the socket connection
  if the token is invalid
- in controller's case we just want to verify the token
  for adminClusterOverivew socket connection

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I2e640a746c839ea6f4494ddbdfcb8f924150906f
2023-08-28 10:29:29 +05:30
Caolán McNamara afe6c1bed8 reduce cost of TileDesc::parse
perf reported 6.58% of time in collaborative multi user test
on 2023-08-24 was spent in TileDesc::parse and much of that
in std::unordered_map.

There are only 12 arguments in the map we care about here so
we can just used a sorted array, look by name on write, and
read by index.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Iadfc2001e298d8f4d46200c8488f0eb4cd8734c2
2023-08-24 22:22:43 +01:00
Caolán McNamara e0b70657fa cid#318912 Result is not floating-point
we presumably want the current behaviour so silence with
an appropiate explicit cast

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ibed4cb2cc31b26195e407f25f7f0a2ea7172c67d
2023-08-24 08:30:40 +02:00
Caolán McNamara 26934061b1 cid#318872 Improper use of negative value
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ia76b677d466c67fc47760fdcb41459446c4c8e8e
2023-08-23 12:06:31 +02:00
Caolán McNamara 7163b2f9d7 cid#318896 AUTO_CAUSES_COPY
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I1d34ae9287e3c639255541584e3daf9209387bc5
2023-08-23 12:06:31 +02:00
Caolán McNamara 6d5c78dec0 move "combined" bit inside TileCombined class
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I274c5844660acbf69e50587cce3f4ddcae414723
2023-08-21 20:48:31 +01:00
Rash419 c9e7591add clusteroverview: send routeToken with auth message
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I6412d68ef0c86d7a618eaf0ad252c16dee565d77
2023-08-18 23:27:04 +05:30
Caolán McNamara 42df0dac71 cid#318842 silence Unchecked return value
and

cid#318906 Unchecked return value

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I9033f43dbbbcae8f5a15980d6f7b844370d54c7f
2023-08-15 15:09:36 +02:00
Caolán McNamara ce0c11f09f cid#318866 can elide the temporary here
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I8a7bb1b6b8535ecbdae8deddc10f3c010db28897
2023-08-15 15:09:36 +02:00
Caolán McNamara eaa2b0cf2f cid#318821 COPY_INSTEAD_OF_MOVE
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I91e2fe0bcbf9ebe68917b0326425ac73bfa544fe
2023-08-15 15:09:36 +02:00
Miklos Vajna 7d6619be90 wsd, coding style: document double review for security
Document that authentication changes need double amount of care,
compared to other normal functional changes.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Ib1820581f7175957f08f5e080d542c7441a3ffa2
2023-08-15 08:20:05 +02:00
Ashod Nakashian efe874f89c wsd: simplify shutdown and termination flagging
With the use of a single flag for both, the
logic is now less ambiguous, as we cannot have
termination flagged without also implying
shutting down.
The assertions are no longer needed.

Now that setting the termination flag
explicitly implies having the shut down flag
as well, the checks are simpler. We only
need to check that the shutdown is not set
to continue running as normal, since having
the termination flag must perfoce mean shut
down is also set, there is no need to check
both.

Change-Id: I99e22f5668385182b0594040a8e3354b55e74642
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-14 16:32:50 +02:00
Caolán McNamara 307818ba1c cid#318834 Missing move assignment operator
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I798c0e6610afca9d0d503514b33e75c35a7ccb33
2023-08-14 12:31:55 +02:00
Ashod Nakashian a42adac98f wsd: add the web-server URL to the media-src list
We need to allow loading media sources from
the web-server URL. This seems to be necessary
at least on iOS.

Change-Id: Ic7b23c4f80b975460de9311a67f3c5cb51758d14
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-10 12:24:08 +02:00
Caolán McNamara 1cd88f217e cid#321976 AUTO_CAUSES_COPY
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I2207cc530e1773f29cf540ea2ff9c6f44c4c237b
2023-08-10 08:47:25 +02:00
Caolán McNamara 6d873d6837 cid#318919 Dereference after null check
map is never null so make it a reference

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I9f6ad863d0a1102dd7e26a5668b1c6ba71249580
2023-08-09 13:39:23 +02:00
Caolán McNamara 2119a19881 cid#321981 AUTO_CAUSES_COPY
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I6c2d30c8db254beb6b20aae7891b089a986a4df8
2023-08-09 13:39:23 +02:00
Henry Castro a2b924033d admin: rename ACCESS_TOKEN -> JWT_TOKEN
To avoid confusion with the WOPI access token.
.

Change-Id: Ie38e0f11d0655e89eb1c7f1e20b73a9b8756ba21
Signed-off-by: Henry Castro <hcastro@collabora.com>
2023-08-08 08:27:30 -04:00
Rash419 0ed983d7a3 admin: refactor adminClusterOverview.js
- refactored special case for templating
  adminClusterOverview.html
- removed useless variable
- format the code, fix indent

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ib22cb481db7c7ef94b11f3044d0cd856e6d0eed5
2023-08-05 14:28:29 +05:30
Rash419 944f269926 admin: added new cluster overview page
- added DlgLoading class to show loading modal dialog
- upgraded the d3

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I8bd99bbadaa59a7de1e83bebde8db0dce920705d
2023-08-05 14:28:29 +05:30
Rash419 fc77e1a1ff admin: fix auth issue when switching between
multiple cool servers
- also good to check response first as client
  might use persisted cookies

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Idcd85266a4cc5020aeaca7d7fb8428bc0a3d7d32
2023-08-04 21:25:37 +05:30
Caolán McNamara aaa61e44e5 allow tileprocessed to accept multiple comma-seperated tileids
and bundle them together when emitted from the browser-side

// i.e. FIXME: new multi-tile-processed message.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I69916cbe30c26686fb44a2d8d229704c459b6601
2023-08-04 13:07:29 +01:00
Caolán McNamara 509c29421e split this hunk into reusable ClientSession::onTileProcessed
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I383542b6c9c3a888937e2f7e330ec7e77efaaa82
2023-08-04 13:07:29 +01:00
Caolán McNamara 8bb41ee775 cid#318947 Unchecked return value from library
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ia8b96035d5038d82a55f68a751fdbda5806ec1d6
2023-08-04 10:17:58 +02:00
Caolán McNamara 1d179cdf76 cid#321981 AUTO_CAUSES_COPY
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I92d66a3d497d574d819f18960bff5b60e180b715
2023-08-04 10:17:58 +02:00
Caolán McNamara 7cb1dfd4eb cid#321977 AUTO_CAUSES_COPY
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I50f94b290e40b11d555c51448630835d71a62019
2023-08-04 10:17:58 +02:00
Ashod Nakashian 75ae9894b9 wsd: Util::make_unique -> std::make_unique
Change-Id: I1063913f91571ea6ad95386a3da6a4072574d155
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-03 08:40:20 +02:00
Ashod Nakashian 5b52f7d8eb wsd: smart pointer cleanup
std::make_shared and std::make_unique
are superior to explict smart pointer
construction. Where we have private
constructors, we can't use them.

Change-Id: I492122f58e958113c6e6d31445c6614ad98c89aa
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-03 08:40:20 +02:00
Ashod Nakashian b8854ea2e9 wsd: decouple FileServerRequestHandler from COOLWSD
Change-Id: Ie121849a16bb84195d32e11a67e4aad5753aebfc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-03 08:40:20 +02:00
Ashod Nakashian d47001267b wsd: reduce manual http header creation
We have http::Response specifically for
this kind of thing.

Change-Id: I57130754f95c06f5ab958ca373f21763e74cb6a2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-03 08:40:20 +02:00
Ashod Nakashian c1725faac1 wsd: dump the last quarantined version with the status
Change-Id: I46e1d84ba46bea3bf6cfd9c043af247e8b37afc1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-03 08:40:20 +02:00
Henry Castro 47485adc3e admin: add access token
The access token will validate the session
when a websocket is connected to the server.

Change-Id: I008b04a499ab0d85fd6f95fc06a511f800c0bb2e
Signed-off-by: Henry Castro <hcastro@collabora.com>
2023-08-02 20:23:42 +01:00
Michael Meeks 03d83ab6b8 paste: cleanup excessive debugging.
We don't want to dump the whole paste buffer as hex, or indeed any
large mis-encoded string - instead crop to the problematic section
for easier debugging, and no performance hit.

Change-Id: I30518beea436895a42b3429c3cb6e16e2093cca9
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-07-28 21:38:02 +01:00
Pranam Lashkari fb5909bc40 theme: use integration theme value from the interation message
problem:
till now we used values from DOM elements which were unreliable,
sometimes they are not discoverable due to nested iframs.
That threw some 404 due to incorrect theming path.

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: Ibc291ce9f64db799095e1edcb14c598bdd085de7
2023-07-24 10:06:35 +02:00
Andras Timar fc946198d3 Rewrite coolwsd-generate-proof-key in C++
* simplified the tooling a bit: use coolconfig for creating
  RSA key pairs for WOPI Proof headers.
* got rid of a dependency: ssh-keygen, towards leaner docker images

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: Iaf468b5c8585d45027f512bb0a287ab77afb1ea9
2023-07-22 00:14:48 +02:00
Michael Meeks d309d7199a deltas: fold the update: command back into an empty delta: command.
Also: address parts of #6897, primarily:

* remove the problematic aspect of bumping the last wid in our
  TileData, when this could trigger a re-send of a previously
  sent delta, causing tile corruption.
    * instead append an empty wid entry.
    * as an optimization - if the last entry is empty update
      the wid - since re-sending an empty delta is of no
      concern.

* simplify a number of code-paths that special-case zero length
  deltas. All deltas now commence with 'D'.

* still track updates in the JS - by detecting empty deltas.

* shares more code and simplifies various paths.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I02af6d4b152524c201b6985b7a3497da7f08a517
2023-07-17 11:35:25 +02:00
Michael Meeks b7d7c02a3f deltas: allow JS tilecombine to force sending a keyframe to the client.
However, don't force rendering a keyframe, only sending it - other
clients may be happy with deltas. This is to better handle:

window.app.console.debug('Unusual: Delta sent - but we have no keyframe for ' + key);

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I4efff0f6b1d2817e6b8bd567eb3b098383a1ef42
2023-07-17 11:35:25 +02:00
Rash419 8c5d822dc9 android: fix: save failed error while parsing save command
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ia6a53184322f403d2b995213700193d5612fd63d
2023-07-15 20:33:18 +05:30
Szymon Kłos 3d6ed28857 Fix pasting image assertion
Revert "Avoid crash when pasting image in debug mode"
This reverts commit 78558fe9af.

Instead of detecting paste command and not trigerring assertion:
fix frame type so it will be binary in case of paste.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: If5c726463459be7eaffae1522df522dfa1d74443
2023-07-13 20:06:58 +02:00
Michael Meeks 9270ceef16 update: send for redundant tilecombine requests.
Update tests to check for this too.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I02c8f3167886321496245589b34a382fd61617f0
2023-07-13 08:14:48 +01:00
Michael Meeks 9a29a346d8 Allow tilecombine's to send oldWid information to fetch deltas.
Disable the 'forceKeyFrame' for tilecombine messages from the client,
we have a larger cache now and it makes sense to honor and track these.
forceKeyFrame was signalled with a zero oldWireId - which is the default
if we don't have it set.

Change-Id: If96423e96f8dc578a634ed5093517dfa6702cc1b
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-07-13 08:14:48 +01:00
Ashod Nakashian 752f2a4ae1 wsd: save and upload rapidly when unloading
We normally throttle saving and uploading to
avoid hammering repeatedly, but when unloading,
we reduce said minimum wait by a factor of 10.

This allows for a quicker unload cycle, esp.
if we had just saved before unloading, or
if there was a previous failure.

Change-Id: I8710c9b86c05254ad9b9735d8496dd96900221e2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-12 07:00:41 -04:00
Ashod Nakashian 2fd159bc0c wsd: better always-save-on-exit handling
Change-Id: Id718f81fc2eb0af5ca5bfe61e687de5258dbdd7d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-12 07:00:41 -04:00
Ashod Nakashian 75b1cbcb11 wsd: better detection of upload skipping for save-on-exit
Change-Id: I0b8c6dc7429587cddff6304aaf501f24af896602
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-12 07:00:41 -04:00
Ashod Nakashian 68e20add3b wsd: better data-loss detection
Had to disable a crash test due to incorrect
modification check before unloading.

Because we think there are modifications to
the doc, we issue a save, which will fail
because the kit is killed in said test.

Will be re-enabled when isPossiblyModified
is improved.

Change-Id: I0dd7931308e66e9a12d891a979d54e3f373ef99b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-12 07:00:41 -04:00
Ashod Nakashian 0a969e5006 wsd: better modification detection after saving
And now UnitSaveOnExitUnmodified verifies that
we do not unnecessarily upload unmodified
documents because always-save-on-exit is set.

Always-save-on-exit is meaningful only when there
are modifications. Otherwise, we create identical
copies as separate revisions.

Change-Id: I933069d31d3d273c41734b58e0849680566e591a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-12 07:00:41 -04:00
Ashod Nakashian f383cf9032 wsd: always-save-on-exit skips uploading as-loaded docs
Change-Id: Id38c2b708d9d440cedb3d51b345bf180af0349f8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-12 07:00:41 -04:00
Ashod Nakashian acdd74f014 wsd: better session disconnection logic
This improves the disconnected session cleanup
and fixes a corner-case with the last editor
disconnecting before read-only sessions.

Change-Id: Iecb553d7f5be2c63fc55111e60e22b3d8aa668f6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-12 07:00:41 -04:00
Marco Cecchetti abca8e5dd3 Adding support for enabling/disabling a11y support from the ui
Added toggle button/menu entry for enable/disable accessibility support.
This ui feature is available for Online Writer only.
The button/menu entry is added only when accessibility is enabled at
server level.
That allows to enable/disable accessibility per view.
By default, the accessibility support is disabled.
Anyway the accessibility support state is saved to local storage
if available.

Signed-off-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Change-Id: If5968a47f17922038b9da3d320cbed84ebb7688b
2023-07-10 16:02:18 +02:00
Michael Meeks b963cde3c7 FileServer::LocalFileInfo re-work local file-list management.
Calling a PUT before a GET would cause a SEGV around managing the
internal list of files.

Re-factor to ensure we always have a valid LocalFileInfo to
work with, and simplify and cleanup code-paths.

Change-Id: I2b206bb8bdebc3c44cd55c61048da9b0dc30dbd5
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-07-08 13:08:59 +01:00
Michael Meeks 789dd2963c Append the wid properly to invalidatetiles and parse it too.
also re-work parseInvalidateMsg to not use std::pair<> returns.

Change-Id: I724783b7050a1ee251dfbe9b2f1e0ea02e7d45f2
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-07-08 13:08:59 +01:00
Michael Meeks 6d697de175 tilecache: update the wireId on the last keyframe/delta if necessary.
A zero size delta means we're effectively up-to-date for this new
wireId.

Change-Id: I96abdf00648f7c2f833ffd56bd43980265b8d490
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-07-08 13:08:59 +01:00
Ashod Nakashian 1cac1f1698 wsd: test: do not advance to next test on failure
Change-Id: I2831c90e088064f5a254ef8a9809796e8320ed04
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Ashod Nakashian 7fdc33b916 wsd: no default parameters for DocumentBroker::autoSave
Change-Id: Id343cc36886c2768b4af7ee61d9524678c83dc69
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Ashod Nakashian 12bae02ad0 wsd: separate out canSaveToDisk from needToSaveToDisk
Suppressing needToSaveToDisk silently when we cannot
save, because there is no Kit f.e., is unhelpful.

Now we have these two states separated out and
we log appropriate information in each case.

Change-Id: If38798578a7b88600e3f07c88e0bcbf833ae53f0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Ashod Nakashian b1d68e4b3a wsd: better context logging for clipboard activity
Change-Id: I83935df41492e0267b924893594002e6665a671d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Ashod Nakashian 3fef73a33f wsd: DocumentBroker logging improvements
Change-Id: I9c6f32c087275f48ac559c2fbb05d04da4e00a08
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Ashod Nakashian 7650d5e175 wsd: remove redundant cast
Change-Id: I0cac85728cd4ade5d78b2a4cb715d0fdde17c832
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Ashod Nakashian aabe6cba8d wsd: clang-tidy warning fix
Change-Id: Id8b6d9987c03d33286c7b2f819776bd571329f3f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Ashod Nakashian 8ef57dd2ec wsd: better newChild unit-test event
Change-Id: I8403e14780ad0bf971625934b7011fba1f24f07c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Caolán McNamara 01165fbe1f On a cache hit for a tile the result typically had a wireId of 0
And tile::needsFetch on that result will always return true given the
default of invalidFrom of 0 and the comparison of
  return this.invalidFrom >= this.wireId || ...
so the tile return from the cache is unusable.

It is typical for a request not to have a wireId, if we don't use the
cache then doRender will send a timecombine result with wireIds set. But
if we use the cache here we send a response using the wireId of the
request.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I586406af86b0f503dfc204e20120cc8acebf5b8e
2023-07-05 11:49:34 +01:00
Caolán McNamara 2fd50d8965 cid#318897 Using invalid iterator
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I977f65bbd11060fecf4db31e7e25e068771c17b7
2023-07-05 11:49:03 +02:00
Michael Meeks 61aa932d30 Send an 'update' message for an un-changed tile when rendered.
Change-Id: Iefe666f9953195af0001626a9e8d7d080a7fe201
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-07-03 20:27:07 +01:00
Michael Meeks 023a243982 De-confuse two different sendTiles.
Change-Id: Ib67093b9cb61ff7e856db5c8d98178c0afbdf555
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-07-03 20:27:07 +01:00
Ashod Nakashian b18c92aa31 wsd: simplify logging logic
Change-Id: I140d23e4e82e24c5ac66df4b485bca016f1eb22a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-30 21:45:40 +02:00
Ashod Nakashian 7824df4926 wsd: notify the client of loading errors
Change-Id: Ied18f6820a7c3ceb4cc29200111c4a73442d2808
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-30 21:45:40 +02:00
Ashod Nakashian 5fdc4f9623 wsd: better logging of document and session loading
Change-Id: I0cdf08bf711499e63f09c3db6f3f47e873eb3b59
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-30 21:45:40 +02:00
Henry Castro e5b4036627 wsd: fix secure cookie Set-Cookie
The browser will block the cookie if it is sent
over an insecure connection

"This attempt to set a cookie via a set-cookie header was
blocked because it had the "Secure" attribute but was not
received over a secure connection."

Change-Id: I36faac0d9d3a73eed463c2580e5405d61a3a18f5
Signed-off-by: Henry Castro <hcastro@collabora.com>
2023-06-29 20:47:08 +01:00
Rash419 fcce324cbf admin: added retryInterval option in monitor config
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: If0b94bb043a6a4883affac6cf38adcffd3b72b9a
2023-06-29 18:21:33 +02:00
Rash419 9d1741232b admin: added wopiSrcMap command
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I95a7ccec6075848bd18b8899119c720aa303a106
2023-06-29 18:21:33 +02:00
Rash419 d63bca3f8e admin: migrate document after saving
- controller used to send two messages first to save then
  once saving is done migrate the document
- now controller only sends one message, COOL handles
  unsaved document

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Id4afe1f9a04ef99005d7f0dbd6246826ba82442b
2023-06-29 18:21:33 +02:00
Rash419 932f2ad67f admin: don't send the routing_rmdoc if doc is migrating
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Ic1391dd509027e794ed005bcf78014afca31ede5
2023-06-29 18:21:33 +02:00
Rash419 164d1d2826 show message that document is migrating
Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: Id0908f31b578a6f0ff012c212f4ca4468a76038c
2023-06-29 18:21:33 +02:00
Rash419 b717be603e implement document migration
- updated protocol.txt

Signed-off-by: Rash419 <rashesh.padia@collabora.com>
Change-Id: I67a0515580979e15223ea084c835f5ed801ceb5e
2023-06-29 18:21:33 +02:00
Caolán McNamara 2081d49bcc cid#318937 Array compared against 0
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I8e0e270b0a08e9fe343b591095a001530bc88c02
2023-06-29 08:03:00 -04:00
Caolán McNamara b30ccb0392 cid#318852 COPY_INSTEAD_OF_MOVE
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I8e5f1f7f837c7d52922f05c8a65b1af583b864b9
2023-06-29 08:03:00 -04:00
Michael Meeks 455c377d29 wsd: double size of the delta cache.
Change-Id: I218c0fbdef6815a56bf8d4059bfcae186b32ebed
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-06-23 16:59:08 +01:00
Szymon Kłos 722d538d15 Pass ui_theme to welcome dialog
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I19270ad653540b72f5606554848eed88bded8333
2023-06-23 08:15:35 +02:00
Michael Meeks 12e0830b1b Kill canceltiles support completely.
This stopped working well a long time ago, and is already disabled
on the coolwsd side, so dung out the rest of the code & docs on this.

Change-Id: I2e0b73fe9780e16c3cc74ae3a38ae6b04434717a
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-06-22 09:35:22 +01:00