Commit graph

309 commits

Author SHA1 Message Date
Szymon Kłos
b0dd943089 Add export as pdf
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I61853fb2213e57acd02d7a3eee53e86f43cb36b5
2023-01-26 13:06:57 +00:00
Ashod Nakashian
e99af3a932 wsd: correctly log the time since upload request
Change-Id: I66661d5cdc1cd5efcfb86732d86d2a7a6053f2ba
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-22 10:10:08 +01:00
Ashod Nakashian
b2aff3e817 wsd: pass ClientSession to forwardToChild
Change-Id: I2d78687adf9e5a64b75f586b53bf983f3c8d8119
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-07 07:53:09 -05:00
Ashod Nakashian
98687db97e wsd: pass ClientSession to sendUnoSave and simplify
Change-Id: I155c896a3f5520a31ce5f413e0c59c2e93701ad1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-07 07:53:09 -05:00
Ashod Nakashian
44aeb9e705 wsd: pass ClientSession to uploadAsToStorage
And move the validation of rename sessionId
where it belongs.

Change-Id: I3fb16ff7b648accaa20b041bf3fd6b82f516cb9b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-07 07:53:09 -05:00
Ashod Nakashian
eb2728cd0f wsd: move idleSaveInterval in SaveManager
This fixes a regression where the
per_document.idlesave_duration_secs setting
wasn't effective.

Idle save also takes into account the time
uploading finished, or if we had a recent
save issued. This is particularly helpful
for large documents and/or slow networks
where uploading takes dozens of seconds.
In that case, we don't idle-save too
frequently.

Change-Id: I76ee1869003073b5cf9bd420f610bd8a12ff71b3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 08:59:34 -04:00
Ashod Nakashian
e5c939a31a wsd: autosave -> autoSave for readability and consistency
Change-Id: I9568993a8f7ff7dac43f3f48264952f8259846d7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 08:59:34 -04:00
Ashod Nakashian
b507d5bb08 wsd: pass ClientSession to checkAndUploadToStorage
And to handleSaveResponse.

Change-Id: I01d7bc0424df7f1b4998d9698cdfcadbaaabc704
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:28 -05:00
Ashod Nakashian
68beb87b7b wsd: pass ClientSession to disconnectSessionInternal
And simplify the logic.

Change-Id: I71dfc447f2ee35b7ab54e23a9ab6db4faa463444
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:28 -05:00
Ashod Nakashian
57b0a50d18 wsd: pass ClientSession to finalRemoveSession
Change-Id: I31e34c004dd54ab8f5f942a03bdd23be88e43335
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-30 05:14:28 -05:00
Ashod Nakashian
6547138660 wsd: pass ClientSession to uploadAfterLoadingTemplate
Avoid looking up _sessions.

Change-Id: I685e9843b75ed26dd0ef78aad9a46790561f45ba
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-28 12:50:36 +01:00
Ashod Nakashian
20a8b8a62f wsd: pass ClientSession to uploadToStorage
Avoid looking up _session.

Change-Id: Ie0cec1802db729ead09a6da71712242fdb28bc07
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-28 12:50:36 +01:00
Ashod Nakashian
b708dc5ee8 wsd: pass ClientSession to removeSession
This avoids an unnecessary lookup in
_sessions, as we already have the
ClientSession instance.

Change-Id: I3dfdfd322fb907f916235a5ccc5f3b76e0eb4855
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-28 12:50:36 +01:00
Ashod Nakashian
2262da355f wsd: breakup getWritableSessionId and getWritableSession
Change-Id: If08a9984c75a84d85b5f3c37e6780cc0b99a1800
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-28 12:50:36 +01:00
Ashod Nakashian
4123a88b24 wsd: correct logged upload duration
Change-Id: Ic9fd69cabb782cd1a5662db1cf47fd87be6cf6b3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:34 -05:00
Ashod Nakashian
0069a41dbb wsd: test: capture the UnitWSD instance per DocBroker
Each test loads one or more document. At the end
of the test we may load a new test (a new
UnitWSD/Kit instance). However, because of the
static interface that the tests have, there
could be only one instance at a time. This
means that when we switch the current test
instance, an existing DocBroker might fire
events into the wrong (new) test, making it
fail.

By capturing the current test, we make sure
that DocBroker can never run against different
tests.

Change-Id: I161ec3c9ce1617f41d03b53d2d5fb19682930b78
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:17 -05:00
Ashod Nakashian
fc0b163732 wsd: move svg processing to ClientSession
This helps generate the public URL
easily and unifies the processing
of embedded video.

Change-Id: I07ef7f7722f368957a85e41493fe175de38464f7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-10-26 16:26:15 +02:00
Ashod Nakashian
7f5d77f1ff wsd: move mediashape handling to ClientSession
And reuse the public URI helper.

Change-Id: I9d56e91c2df571609c575b401c6a4eea958d710a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-10-26 16:26:15 +02:00
Ashod Nakashian
f81a1d1c01 wsd: support embedded video in slideshow
Change-Id: I2f7621fceb6c9f267bcf86da358b6eb07d55c9f3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-10-25 09:16:36 +02:00
Ashod Nakashian
76ac5d09c2 wsd: support embedded media
Change-Id: I28c1a813bad22c49ae759b89ad90e377890acddb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-10-25 09:16:36 +02:00
Gabriel Masei
cd106b9976 wsd: add lang param to conversion
This is needed, for example, for date type cells
for which the format language is set to default.
In this case the load language is used and it
determines the display/output format.

Signed-off-by: Gabriel Masei <gabriel.masei@1and1.ro>
Change-Id: I49ec4940377b261971224d37ea5fbe8ed7006157
2022-10-20 11:08:42 +01:00
Michael Meeks
2b20e4050d Forward setclipboard data to the Kit as a binary message:
assert: invalid utf-8 - check Message::detectType()
 #3  0x00007fce7ae57fd6 in __GI___assert_fail at ./net/WebSocketHandler.hpp",
 #4  0x0000558bd2790231 in WebSocketHandler::sendFrame at ./net/WebSocketHandler.hpp:748
 #5  0x0000558bd2851202 in WebSocketHandler::sendMessage (flush=false, code=WSOpCode::Text, len=22118,
     data=0x7fce5c227b50 "child-045 setclipboard\napplication/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"\n1370\nPK\003\004\024", this=0x7fce6c003340)
     at ./net/WebSocketHandler.hpp:641
 #6  WebSocketHandler::sendTextMessage (flush=false, len=22118, ...) at ./net/WebSocketHandler.hpp:619
 #7  WebSocketHandler::sendMessage (msg="child-045 setclipboard\nappl...) at ./net/WebSocketHandler.hpp:613
 #8  WSProcess::sendTextFrame (this=0x7fce6c001300, data="child-045 setclipboard\nap...) at wsd/COOLWSD.hpp:142
 #9  0x0000558bd27d5678 in DocumentBroker::forwardToChild (this=this@entry=0x7fce64027940, viewId="045", message="setclipboard\n...) at /usr/include/c++/9/bits/shared_ptr_base.h:1020
 #10 0x0000558bd2899d50 in ClientSession::handleClipboardRequest (this=0x7fce64027dc0, type=type@entry=DocumentBroker::CLIP_REQUEST_SET, ...) at ./common/Session.hpp:76
 #11 0x0000558bd27e0999 in DocumentBroker::handleClipboardRequest (this=0x7fce64027940, type=DocumentBroker::CLIP_REQUEST_SET, ...) at /usr/include/c++/9/bits/shared_ptr_base.h:1020
 #12 0x0000558bd2847b8b in ClientRequestDispatcher::handleClipboardRequest(...) at /usr/include/c++/9/bits/shared_ptr_base.h:1020

Change-Id: I406eee0ac3a47986fdd9511e674c9228d1994d38
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-08-27 08:21:28 -04:00
Ashod Nakashian
cd497ba7f0 wsd: move storage attributes to DocBroker
There are a number of races with having Storage
track the attributes. To fix them, we move all
attributes to DocBroker and correct a number
of issues.

The idea of the design is based on the fact that
we want to capture the attributes between
uploads, but based on the saved document.

That is, when we upload a document version, we
want to pass to the storage whether from the
perspective of the *Storage* there has been
any user-modifications or not. Since saving
to disk may happen multiple times between
uploads (not least because of failures), and
since saving resets the modified flag, we need
to capture the modified flag at each save and
propagate it until we upload successfully.
Upon uploading successfully, we reset the
attributes.

For this reason we have two attribute instances;
one is the 'current' attributes as being uploaded
and the other the 'next' one. We capture the
current state at saving into 'next' and we merge
with 'current' when saving succeeds and we
aren't already uploading (otherwise, we update
it and then discard it when uploading succeeds,
losing the last attributes).

Furthermore, because the modified flag is
reset after each save, and because we might
save and upload immediately after a
modification, we may not have the modified flag.
This means that we need some heuristics to
decide if there has been user-issued
modifications. (It is better to be conservative
here.) We try to detect this by introspecting
the commands we receive from users.

In effect, we capture the attributes when issuing
an internal save, we transfer the captured
attributes only when saving succeeds and we aren't
uploading, and from then on, uploading has to
succeed to reset the 'current' attributes. In the
meantime, if we fail to upload and issue another
save, the new attributes will be captured and
merged with the 'current' and the next upload
will not have any lost attributes.

Change-Id: I8c5e75d25ac235c6232318343678bf5c0933c31e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-25 15:12:10 +01:00
Ashod Nakashian
b35625d4ca wsd: state-dumping and comments
Change-Id: I2522d1578faf28c40682f63dd487efde9c5a738d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-25 15:12:10 +01:00
Ashod Nakashian
e85854ed39 wsd: track modifying user commands
There is a race between the time of modifying
a document, receiving the modified flag, and
saving. This can happen when, for example,
the user modifies the document and closes
immediately. In that case, when uploading
we will not have the modified flag and will
not set the User-Modified attribute.

While this isn't 100% accurate, and it can
never be, it's still better to be conservative
and flag a version in storage as user-modified
than otherwise.

Change-Id: Ia504a7cddd4839bcbfeaaf9bf6c90ed8b68efa91
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-25 15:12:10 +01:00
Andras Timar
cf6e22c22c Fix typos in comments
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I813f652b516c79f350b46317e589b91e0ef39a1a
2022-08-23 18:37:44 +02:00
Miklos Vajna
c9cb1f4e01 wsd: fix uninitialized DocumentBroker::_savingTimeout
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Id004b635cfd8e77de85f932a3035870300ba1c47
2022-08-17 13:30:07 +02:00
Ashod Nakashian
6f969932bf wsd: remove lastUploadTime as it is redundant
Change-Id: I5dee3ed1a77c3672056e3cfc894192d334ae5c15
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-06 20:38:09 -04:00
Ashod Nakashian
b96ea2f9e7 wsd: move minTimeBetweenUploads into StorageManager
Change-Id: I3c4ff6146d2950b618effc348aa3a44c2cfa2c85
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-06 20:38:09 -04:00
Ashod Nakashian
2cee775e0e wsd: move minTimeBetweenSaves into SaveManager
Change-Id: I00336230f80557e0986a2ea6d29b1f498f04fe0a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-06 20:38:09 -04:00
Ashod Nakashian
5e0c29c73b wsd: move the autosave interval into SaveManager
Change-Id: I79e33e3089a4da0c1d968b0fdbc2f4bab55c4fc6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-06 20:38:09 -04:00
Ashod Nakashian
caacf21710 wsd: add min_time_between_upload_ms config
This introduces a new config entry to
control the minimum time between uploads
after a failed attempt. In the case of
a successful upload, the minimum time
between uploads is bounded by the
min_time_between_save_ms config.

Change-Id: Ic7e37f97a52af2c5ec82897b6e81f57211d16553
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-06 20:38:09 -04:00
Ashod Nakashian
2d695a489e wsd: add min_time_between_save_ms config
This adds a new config entry to help tune
how often to save after the last save
request. This is used regardless of
the auto-save interval.

Change-Id: I58c291e69a63a3b98e72584817b408b54d9f80f1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-06 20:38:09 -04:00
Ashod Nakashian
45b7eb778d wsd: reuse parsed message
Change-Id: I9d67f92ba99037954400e07a7d1101e5de3716fd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-07-15 11:14:14 +01:00
Ashod Nakashian
84f4267caf wsd: saving timeout set to 4x loading-time
And dump the saving timeout in the state dump.

Change-Id: If203d5434ee17f646009ee241b8484ca597840ad
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-07-03 18:03:35 -04:00
Ashod Nakashian
697607d122 wsd: timeout on saving stuck with test
Change-Id: I66769e4e5131f60b41327ada9a6f0a45b2ee11ac
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-06-27 14:07:08 +01:00
Michael Meeks
b830ca266e perf: don't send endless stream of updates/callbacks to Admin.
Change-Id: Ic4ac1f189706f5a9b409c91e2497e5a37692c333
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-26 19:53:11 -04:00
Michael Meeks
6483e1500a Enable deltas by default.
Cleanup some debugging, distinguish wsd/viewport delta fetches from
client-side tilecombines.

Update tests for deltas where they are expected.

Change-Id: I3dca09e4ceb094abf03db2aed2618f19351f3e28
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-05-25 20:31:06 +01:00
Ashod Nakashian
89234116dc wsd: delay uploading if the last attempt had failed
Change-Id: I1c251fdeadf355b003a71408fba31d1ac975822f
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-22 17:23:34 +01:00
Ashod Nakashian
9e7a4ad3d0 wsd: needToSaveToDisk helper and improved autoSaveAndStop
Change-Id: I149a624a8acb005f441d79e0c1f4776e7a2d49c0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-22 17:23:34 +01:00
Ashod Nakashian
e3045b513c wsd: add canSaveToDisk helper
Change-Id: I8ad6c91ac05d60e29726a20d67799aa11714226a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-22 17:23:34 +01:00
Ashod Nakashian
83e96e58bd wsd: add canUploadToStorage helper
Change-Id: Ieba59e3cfc5d26c78a118f8d4fae8a151ac62ef3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-22 17:23:34 +01:00
Ashod Nakashian
622e0ddcb4 wsd: add and use isWritable helper in session
The new helper corrects inconsistencies in
detecting writable sessions and improves
readability.

A writable session is one that is either
not read-only or can change comments
(in PDFs, which are otherwise read-only
documents).

Also fixes a bug in reusing the last editor
session to save. The condition should've
been !isReadOnly(), since sessions used
for saving cannot be read-only. Indeed,
the last editor couldn't possibly have
been read-only by definition.

Change-Id: I9860be287057050eca692568d43f77371964f80b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-14 10:48:45 +01:00
Ashod Nakashian
8cb8624b05 wsd: use STATE_ENUM for DocBroker states
Change-Id: I829b4e78185379705f9c6fb443feb1175c90f08d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-06 18:33:45 -04:00
Ashod Nakashian
e1b1f38922 wsd: log the duration of save and upload when done
Change-Id: I17e16667f67ad3f0ad9bdd8c02aceafa62dd72f5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-06 18:33:45 -04:00
Ashod Nakashian
7920656e36 wsd: remove dup entry in dumpState
Change-Id: I1b5e774d33e743dab98781dbe8609dffa8f5cb63
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-30 23:18:57 -04:00
Ashod Nakashian
28b3e165c2 wsd: remove unsed function in DocumentBroker
Change-Id: Ia310cce20b3ca2c95be98d75b13ec7e047cf19b9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-30 23:18:57 -04:00
Ashod Nakashian
82933be193 wsd: last modified timestamp of the upload file is not now
When deciding whether the file on disk needs uploading
or not, we compare it with the last modified timestamp.
For this to work they need to be different.

When there is no file to upload (i.e. when there is
nothing new to save), the timestamp we get is
unix-time of 0. This is always different from 'now'.
So we incorrectly think there is data to be uploaded
when there isn't.

Better to initialize the last modified timestamp to
unix-time of 0, so in this case we correctly
conclude that there is nothing to upload.

Change-Id: I545e9021e9c76d009e08758342effaf3e9b964c7
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-16 08:31:54 -04:00
Ashod Nakashian
0c88fd8d6e wsd: gracefully close the document when disconnected from Kit
When disconnecting from Kit we shouldn't bluntly stop
DocBroker, because even though we cannot save, we
can still upload the latest document version from
disk.

What makes this particularly problematic is that
we request to kill Kit when the last client is
disconnected.

This was caught through unit-tests, albeit it was
not very common or easy to reproduce.

This fixes cases where always_save_on_exit
doesn't save/upload.

Change-Id: Ib66281fc68d4c0264602852b0acdc453b6f79963
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-16 08:31:54 -04:00
Ashod Nakashian
832e308e8f wsd: more informative timestamps in dumpState
The timestamps now helpfully include how
long ago they were.

This also improves the conversion between
chrono clocks by adding generic functions.

Change-Id: I18081330564c8d969b9364cf1b9e33546e241280
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-03-09 19:24:40 -05:00