Commit graph

950 commits

Author SHA1 Message Date
Caolán McNamara
3502e1d006 cid#318903 Dereference after null check
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I37eeff9afc12a27744a7178da58f4c9b71272c12
2023-08-15 08:21:44 +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
Ashod Nakashian
35dda35f9d wsd: move statics into anonymous namespace
Change-Id: I97b0cd7de96eced1a4023e55171b1e35b52a95c7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-14 16:32:50 +02:00
Caolán McNamara
f7e121e2ea cid#318953 COPY_INSTEAD_OF_MOVE
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I863ce92808f93e98fecb6022324228b5acdba141
2023-08-14 12:31:55 +02:00
Caolán McNamara
b1f88c4cb2 cid#318875 Dereference after null check
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I40c824e26183f0c0c17e1503dc1c438ba1d2ce5c
2023-08-09 13:39:23 +02:00
Paris Oplopoios
d0c5321aaf Fix getting canonical view id of 1000
Also tilecombine request now uses the canonicalviewid

Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: Ib386edcf78de17cb4fc3d8c3c6ce65f6b52c8b5f
2023-08-05 12:00:08 +03: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
35605510aa wsd: include string_view
Change-Id: I85632cd6a9fece7d63ca2402c2cf924465df5e43
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-03 08:40:20 +02:00
Michael Meeks
85152bf953 Typos: wake-up.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I8ae12c8c8390997bbde7af1e203e9075dfa4ea25
2023-07-17 11:35:25 +02: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
3203db2be2 Cleanup includes.
Change-Id: I062579fc7dee2283e6ac62e67c844cf89c3a3188
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
037099fe32 wsd: cosmetic improvements to ClipboardCache
Change-Id: Ie3ccc015203463fcd9f4a9a26826e0d894f9ec50
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Ashod Nakashian
d50b4e4b1c wsd: test: dump state on test failure
Seems a useful thing to capture the internal
state when a test fails, as it might help
understand what was going on.

Change-Id: I591a88662ab86ab4dc7f39dafcc4d7d279a4d9c4
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
Ashod Nakashian
13b6f64d59 wsd: unmount the test mount directory too
We test if mounting is possible by mounting
a test directory. This can leak in crashes
and failed tests, therefore it needs to be
cleaned up too.

Change-Id: I2638cc0863f3f5575f697bece9801d42cd321ed1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Caolán McNamara
0231a4d2a2 impress slide previews are not 256x256 so triggers assert
but they don't go through the delta mechanism, so move the assert
to the delta path, the other path is ok wrt gt 256x256

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I2ba4d8affb7645349540f3a5de31d1802f04c53d
2023-07-06 09:13:45 +01:00
Caolán McNamara
b44a2b71b9 cid#318946 Argument cannot be negative
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I83716319a797ffb5e49c4b98676bfe864a75dec5
2023-07-05 14:49:59 +02:00
Caolán McNamara
bc4a699735 cid#318871 Unintentional integer overflow
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I6af42166c495032a6e76532cc2e919a8d01a63c7
2023-07-05 14:49:59 +02:00
Caolán McNamara
d75f3ffb6e cid#318901 Untrusted loop bound
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ic3455b21f9c2b7c8928c6d3b64f8790a203e3379
2023-07-05 14:49:59 +02:00
Caolán McNamara
76a5a9baff transport in rgba order
so if core is compiled with a cairo using rgba the pixels can
be sent without need to reorder in server or client

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Iaf0410f1eaa605b9ce2716625f6c968bca523ccb
2023-07-05 11:58:54 +01:00
Michael Meeks
36818e9153 tiles: track invalidation by monotonic timestamp.
We want to keep pre-loaded, and invalidated tiles around so that
we have something to render in lots of cases, particularly for
other parts, and slides. However - we need to know that it is
invalid so we can on-demand fetch something better.

It is very important that this invalid state doesn't race with
tile arrivals ie. in a banal way:

	invalidate, req, invalidate, req, tile, invalidate, req, tile

it is unclear whether the latest tile is still invalid; similarly,
if we request(req) a tile and there is no change to it we get no
response.

To disambiguate this, use the monotonic wid to check we are in-sync.

Re-factor:
	setup debug tile layer more pro-active.y
	rename HasContent to NeedsFetch to be more explicit.

Remove:
	previous _invalidCount that was perhaps a similar idea.
	previous .loaded concept.
	previous _pruneTiles concept - now it seems we can be
	confident in cached tiles from other slides and sheets.

Change-Id: Ibc6d3b6050e756ace91a9bd53d3e4efe12b023cf
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-07-03 20:27:07 +01:00
Ashod Nakashian
e0ea9fc883 wsd: some clang-tidy warning fixes
Change-Id: I5d5cce6bec9b377025640d10e7a0053b9f6ddd91
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-30 21:45:40 +02:00
Caolán McNamara
4730458b97 cid#318835 COPY_INSTEAD_OF_MOVE
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I964fc80c2bb7bddb8391e631ce179bf947fce55e
2023-06-29 08:03:00 -04:00
Caolán McNamara
d900c3fc12 cid#318841 markup forcedExit as a fatal path
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I8825d8f2756c33d10efe9bc40129fbf4871e9de0
2023-06-26 07:08:46 -04:00
Ashod Nakashian
9efc81a51b wsd: random device mounting
We now warn when we fail to use mknod
to create the random devices and have
stricter requirements to mounting
character-devices. Specifically,
we explicitly only allow mounting
the random devices.

Change-Id: Ib0dc300dedc40942ea52426af2b267f6a81fbeb8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-23 18:13:59 +02:00
Caolán McNamara
490b0c0d0d drop non-standard width=400 height=400 tile request in unit test
there since:

commit 232499f542
Date:   Thu Apr 21 12:34:30 2016 +0300

and

commit bf66f7a908
Date:   Mon Jun 13 20:31:14 2016 -0400

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I04745be0581a697bbc3b15ba1d8bb94207320a7a
2023-06-23 16:55:25 +01: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
Caolán McNamara
dc044b532f cid#318910 Logically dead code
this should presumably be checking caps_none not caps and is a cnp
error

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I46f381fbec31b3e9c311f1becf0c536c192788fd
2023-06-21 08:40:21 +02:00
Ashod Nakashian
214f212571 wsd: fallback from mknode to bind-mount for random devs
In some cases we may not have permission to create devices.
This happen on nodev systems and some containers. In
those cases, we gracefully fallback to bind-mounting.

Ideally, we would like to reduce the number of bind-mount
cases we do per document, which i why mknod is preferred.

Cleaning up works without modification because the
random devices are mounted in /tmp (in the chroot),
which itself is bind-mounted. So removing it is
sufficient.

Change-Id: If9a4f0a511273952ead95d6c6855ca2becaf757f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-20 09:42:49 +02:00
Ashod Nakashian
95cf60ed5c killpoco: use own file stat helper
Change-Id: I668c2aab04083689a867e7d1f77e2b52c9351969
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-20 09:42:49 +02:00
Patrick Luby
57a9db5664 Replace preprocessor directives with C++ conditional check
UnitBase::isUnitTesting() and UnitWSD::isUnitTesting() to avoid
calling methods that crash on mobile.

Signed-off-by: Patrick Luby <plubius@neooffice.org>
Change-Id: Ie6bc2d238ac9e475b02ceef5809c55acc129dd52
2023-06-15 19:01:42 +01:00
Patrick Luby
12213d7ec5 Fix iOS build breakages by adding http::Request to iOS build
Still needed to add a bunch of #if !MOBILAPP to disable all of the
Online server's unit testing classes so that the iOS app won't crash
when opening a document.

TODO: the iOS app will not accept text input at all. Is some code
unexpectedly consuming message data sent over the mobile fake socket?

Signed-off-by: Patrick Luby <plubius@neooffice.org>
Change-Id: Ie874ee8e452188a7b4cdf6d5f87708e5ed9b0235
2023-06-15 19:01:42 +01:00
Caolán McNamara
00705d4a32 use more string_view
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Iad56a97f9bef1f6f905f08002b1958072a209551
2023-06-15 13:29:04 +02:00
Ashod Nakashian
874e4f4b29 wsd: signal handlers must preserve errno
Change-Id: I13ee808f73d739c9a30724799532d04b0b8b577a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-14 07:04:26 -04:00
Ashod Nakashian
e5f274c65c wsd: test: better test timeout thread management
Change-Id: I156d3563c13bd303e628d5a76fc2a48e6141bcf2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-14 07:04:26 -04:00
Ashod Nakashian
a729d37af2 wsd: signal handler cannot log
Logging allocates and calls signal-unsafe
functions.

Also, we flush cerr now.

Change-Id: I80f371c1d32b0c650f0d5e132d30af9991b1e24e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-14 07:04:26 -04:00
Caolán McNamara
572135c076 cid#318822 Uninitialized scalar field
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I9f3e7d440b0fadf2f73ca3f955ab34b0d1cc11dc
2023-06-14 10:10:46 +02:00
Caolán McNamara
0c027a73a3 cid#318882 AUTO_CAUSES_COPY
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I18f8af8bc3c3b0ea903a1b7d0786d3ce60da21e4
2023-06-14 10:10:46 +02:00
Caolán McNamara
bd34e1f7ee cid#318952 Resource leak
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I1535456a76c403c4fb8d0eb5d3a88a923528f6aa
2023-06-14 10:10:46 +02:00
Caolán McNamara
532688c6ab cid#318877 Resource leak
commit fde57adbbf
Date:   Fri Jul 7 17:12:19 2017 +0530

    Introduce hard mode when we are OOM

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I507fcd07f07d15f613bcf1ce4c0141d23d518f88
2023-06-14 10:10:46 +02:00
Caolán McNamara
53e4209377 Resolves: #6514 disable noop 'canceltiles'
Given that all messages that can have "ver=" in them will also have
"nviewid=", "oldwid=" and "wid=" then the "id=" search is always
successful and this loop doesn't achieve anything. Disable this for now
and later either drop canceltiles or repair it to do something

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I085bd18f05561df3a542eb14ceb4744b228f4621
2023-06-13 20:04:57 +01:00
Caolán McNamara
81b2cbe63a perf: avoid creating strings by using string_view
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ibffa35d40ee9839635cbd37be8cdc9c69b834504
2023-06-13 09:59:59 +02:00
Caolán McNamara
12d4ce7195 use std::string_view in COOLProtocol::matchPrefix
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I56ce6e6b882fe6b5940478a16e4ecf6dcb1287a8
2023-06-09 10:32:06 +02:00
Marco Cecchetti
d01bedc09c a11y: add config for enable/disable accessibility in general
A new section about accessibility has been appended to coolwsd.xml
config file

Signed-off-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Change-Id: I086abdf73646639283eb655ae60f200fb64e495a
2023-06-08 00:00:51 +02:00
Caolán McNamara
bb617b90aa Related: #6514 removeCallbackDuplicate only needs up to 4 tokens
rearrange so we can use the tokens as they are generated and
can end tokenization early as we find we don't need any more

from:

|--74.39%--SvpSalInstance::CheckTimeout
|          SalTimer::CallCallback (inlined)
|          Scheduler::CallbackTaskScheduling
|          |
|          |--63.01%--desktop::CallbackFlushHandler::Invoke
|          |          |
|          |           --62.92%--Document::ViewCallback
|          |                     |
|          |                     |--62.11%--MessageQueue::put
|          |                     |          |
|          |                     |          |--61.95%--MessageQueue::put
|          |                     |          |          TileQueue::put_impl
|          |                     |          |          |
|          |                     |          |          |--61.51%--TileQueue::removeCallbackDuplicate

to:

|--44.61%--SvpSalInstance::CheckTimeout
|          SalTimer::CallCallback (inlined)
|          Scheduler::CallbackTaskScheduling
|          |
|          |--21.23%--desktop::CallbackFlushHandler::Invoke
|          |          |
|          |          |--20.75%--Document::ViewCallback
|          |          |          |
|          |          |          |--19.33%--MessageQueue::put
|          |          |          |          |
|          |          |          |          |--19.17%--MessageQueue::put
|          |          |          |          |          TileQueue::put_impl
|          |          |          |          |          |
|          |          |          |          |          |--18.69%--TileQueue::removeCallbackDuplicate

seen with 25 simultaneous joins to a local instance

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Iea4de188521f7cd8039d6ab60e9c52209fc3154d
2023-06-07 08:54:27 +01:00
Paris Oplopoios
baaecac852 Add debug option that allows tile dumping
Added a debug option (triggerable using the about debug menu) that
allows you to dump tiles as they come in

Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: If5939b816c1e3598e50c2db4971710524f855909
2023-06-05 08:59:39 +01:00
Ashod Nakashian
cec4cf087a wsd: test: initialize logs before unit-tests
Make sure that the logging subsystem is
already initialized before starting
unit-tests.

Change-Id: I2ce3ffdb2d3b0094ae7ed496d7cacfc02af89c21
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-31 07:40:11 -04:00
Ashod Nakashian
7bc0d2ec76 wsd: exact-match JSON entries first
Normally, we do a fuzzy-match for the keys
in JSON (presumably, there has been typos
and minor differences in the spelling of
keys in the past).

However, this can be wrong if there are
two rather similar keys. In that case,
we should always prefer the exact match.
Also, the exact match is faster, since
it's a map lookup (logarithmic) rather
than a linear search with Levenshtein
distance algorithm on each entry,
which is quadratic.

Change-Id: If88d13a305a0c67cc00c3f3f22c7dc472666a1ff
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-22 09:34:29 -04:00