Commit graph

464 commits

Author SHA1 Message Date
Ashod Nakashian
f60753a951 wsd: misc cleanup
Change-Id: Ief6cbc40ef2f7d98b0b76477109332676dab45b2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-22 22:26:36 -05:00
Gleb Popov
78904302da Do not call non-standard std:🧵:id constructor.
Change-Id: I916f7ba28bc9a52fa3c601fd695ff8146c1712a1
Signed-off-by: Gleb Popov <6yearold@gmail.com>
2020-11-16 14:02:23 +00:00
Ashod Nakashian
cb4beaca34 wsd: avoid the using keyword and use C++ size_t
size_t in C and in C++ are not necessarily the same
type. The C++ size_t is in the std namespace. Since
we do include many C headers, and indeed some C++
runtime headers do define size_t for backwards
compatibility, it's easy to mix and match the two
types.

Also, 'using std::size_t;' isn't a great practice,
so removed.

This is not exhaustive, just some low-hanging cases.

Change-Id: I85a36b6fd1acd204274b1869de9bcb94c8b3cf13
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-15 15:41:41 -05:00
Ashod Nakashian
ee0b5203ec wsd: SaveResult final and Result enum class
This makes the code self-documenting and avoids accidental
comparison or assignment of Result variables/values.

Change-Id: I84b8e36aa999191c8704938552b73ddc1c3dc3fc
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-15 13:50:16 -05:00
Ashod Nakashian
2ddc1afb69 wsd: resuse Stat where possible
This replaces Util::getFileTimestamp with
FileUtil::Stat::modifiedTimepoint() and fixes a potential bug:
getFileTimestamp had only 1 second precision (it simply dropped
sub-second data). This could mean that any modifications to a file
within a second could not be detected.

Minor simplifications done where possible and overly long lines
have been reformatted.

This is a non-functional change (except that file modified-time
now supports microsecond precision).

Change-Id: I3606638a86fc3e00c0ad5cb602bdbb2b4651867b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-15 13:50:16 -05:00
Michael Meeks
7a02a8c24e Ensure consistent canonical view id accounting between wsd and kit.
Confusion arose due to separate creation of session, and watermark
property fetch from CheckFileInfo which happens in DocumentBroker::load
which doesn't do a load. This happens in a subsequent 'load url='
message cf. global.js which can then race vs. the session creation.

This causes mis-ordering of another unhelpfully shared Session,
letting the view canonicalization list to get out of sync between
the two processes.

So instead - tell the view it's canonical id. An example of the
problems of trying to share some unclear subset of the Session
class between kit and wsd perhaps.

Change-Id: I63dc30f9a047e3f889fd339b6aaf392b9fef37b9
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-11-14 19:56:09 +03:00
Michael Meeks
0d10c2cae8 Set normalized view id for broadcast (ie. slide preview) thumbnails.
Change-Id: Ica5312ae9c7147c8dc969523e28d460348ba2e76
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-11-14 19:54:56 +03:00
Miklos Vajna
a4e70f2507 wsd: fix typo: reserverd -> reserved
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I736c621723502deceb4f01b005b62c2dfd8c4e37
2020-11-05 12:47:37 +01:00
Ashod Nakashian
5f07da1298 wsd: privatize public members
Change-Id: Iab57b946cc29814155fccde9b1fbb0c6697b8c26
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-10-31 15:07:53 -04:00
Jan Dageförde
d7656402d3 Migrate code to use generic sendError
Signed-off-by: Jan Dageförde <jan.dagefoerde@googlemail.com>
Change-Id: I0a00ea1220f19479eb021538f67b6bda0c59f7ef
2020-10-28 13:12:27 +03:00
Miklos Vajna
eb5c86a4d3 DocumentBroker::saveToStorage: guard against nullptr _storage
This can happen on a 'savetostorage' which is after a failed load.

Change-Id: Iad26bf6415c772c8646a119b0454c202873d6860
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
2020-10-26 10:57:23 +01:00
Szymon Kłos
7c7fe41f3a Autosave annotations in pdf
Change-Id: Ic4fb2da63e761b78dedf9f67e0612e90e6d4be87
2020-10-23 14:15:50 +02:00
Ashod Nakashian
8190cf7869 wsd: allow some time between retrying saving
Change-Id: I9d923582057467141a3f4d0b260b982464b60511
2020-10-22 14:40:40 +02:00
Ashod Nakashian
c71998438d wsd: document forced storage saving and remove default args
Change-Id: Ic7fde18f07dfe848e219b4ebba30426277ae1287
2020-10-22 14:40:40 +02:00
Ashod Nakashian
eb377ee8d8 wsd: force saving to storage if the last attempt had failed
When uploading to storage fails, we want to retry on next
save. This works when the document is modified between
the last attempt to upload and the current save.

However, when the document isn't modified (f.e. when unloading
the document) we still need to upload the last version of the
document, so we save the document, but that fails as the
document isn't modified. And so we end up not uploading it.
Actually, it gets worse, because we will keep retrying to
save, because there is nothing else to do when we need to
unload the document (say because it has been idle).

This issue was previously not seen because storage failures
are quite rare. However in certain cases NC with complex
access permission controls does fail fairly frequently,
and this edge-case becomes an issue.

This patch enables forced uploading when the last attempt
had failed, regardless of the state of the current save
result.

Change-Id: I951bf19b62f049547913f490d618be20b6191080
2020-10-20 20:50:30 -04:00
Yusuf Keten
d977d13976 port to util::make_unique for wsd
Change-Id: I4fcbd350bd40de5044fdf08ba7e082d89c8e525d
2020-10-15 09:20:42 +02:00
Miklos Vajna
f4a87047b6 document broker, tile combined handling: warn only once without tile cache
Follow-up to commit 3a7a6948f1 (document
broker: handle combined tile request without tile cache, 2020-10-05),
requested at <https://github.com/CollaboraOnline/online/pull/242>.

Change-Id: I57124c64dbf3034de8f43584164572eed8d67f86
2020-10-12 10:20:57 +02:00
Miklos Vajna
557b14dabd wsd: fix typo, transfering -> transferring
Change-Id: If3729bf278607d33a9c545219cee7db863f0bc7c
2020-10-09 17:28:18 +02:00
Miklos Vajna
3ce20bae68 DocumentBroker::sendRequestedTiles: avoid nullptr _tileCache
Change-Id: I467c7ca451b4f72f4f1205e965be2dd602d6d69d
2020-10-08 11:59:08 +02:00
Miklos Vajna
3a7a6948f1 document broker: handle combined tile request without tile cache
Similar to commit 2b546f72de (document
broker: handle tile request without tile cache, 2020-09-28), though
sadly I don't have a reproducer for this at hand anymore.

Change-Id: I5b3c2c69d5b5719998b3ce261aafb775d5441c2f
2020-10-05 10:24:02 +02:00
Andras Timar
0002fdfd6c fix license headers
Change-Id: I8623770b32d278a45357dc7f757fabfadd2b4af7
2020-10-01 11:56:43 +02:00
Miklos Vajna
2b546f72de document broker: handle tile request without tile cache
Change-Id: I5e0006cde07a84e6553db92627fdab943ac51d04
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/103534
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2020-09-28 10:50:46 +02:00
Szymon Kłos
70827c372c Simplify download process
Use hash to identify download and pass that to the client.
This allows us to reduce parameters for download requests.
DocBroker maps download ids to URL in the file system.

Change-Id: I254d4f0ccaf3cff9f038a817c8162510ae228bc5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101992
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-09-07 15:00:20 +02:00
Ashod Nakashian
9f5bd85008 wsd: use a shared threadname suffix for each document
The use of a common threadname suffix in the WSD and Kit
processes is intentional. It is designed to help filter
for a single document's logs across both processes.

The thread name has nothing to do with the classes in
the code, nor is it intended to imply any relationship
except with the process and the document in question.

As the comment in this patch explains, the choice of
the suffix is arbitrary and while it may be changed,
it has to be sensible and common between the two threads
to allow for easy grepping.

Historically, there were in fact dedicated threads
within the respective "broker" classes, but this
fact should be safely ignored, since at the log level
we care less about which part of the code generates a
log entry (that info, if needed, is at the end of each
log entry, in the form of filename and line number),
rather we care more about which document it relates to,
which is crucial in investigating production issues.

Logs and code structure are only incidentally related.
Logs are (or at least should be) designed around
the execution structure, not code architecture.

(This reverts 2a16f34812)

Change-Id: Ic6fe2f9425998824774d2644fe4362e75dea6b88
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101261
Tested-by: Jenkins
Tested-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-08-26 17:47:50 +02:00
Samuel Mehrbrodt
8c602e179e Revert "Revert "Don't update modified status after saving to storage fails""
This reverts commit e83e36bd9b.

Unit test failure was fixed

Change-Id: I2176368278725c1711df3b23eef95de6526c68d5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100859
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2020-08-24 14:34:10 +02:00
Tamás Zolnai
e83e36bd9b Revert "Don't update modified status after saving to storage fails"
The reverted change breaks unit-wopi-documentconflict test.

This reverts commit 494a5221f5.

Change-Id: I3e89a6e6526e9388e4dc6a1ea8f8d8832e8cb169
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100678
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
2020-08-13 17:35:02 +02:00
Samuel Mehrbrodt
494a5221f5 Don't update modified status after saving to storage fails
Otherwise client gets a notification that document is unmodified.
This should not happen, as the document in the storage has not been updated
and so it should be considered as modified until saving to storage succeeds.

Change-Id: I6918f97d96a546ce086f622854f4cbeed48d54ae
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100162
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2020-08-13 09:39:30 +02:00
Michael Meeks
4c6ba6d850 Notify WSD of tiles which we didn't need to render.
When we get a wid match, this helps WSD to cleanup its tile
subscriber list effectively.

Change-Id: I6517039fb3d8c9ad8f53aef549b8adbb79961ce1
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100348
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-08-07 20:01:40 +02:00
Michael Meeks
1061ac90ce TileCache: cleanup debug, propagate now more helpfully & fix staleness.
Stale tiles were still being counted, unhelpfully. Avoid doing lots
of ::now() calls, and yet detect this.

Change-Id: Ib1e4b2f1968c1994849bb23ec54e28f6706230ee
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100347
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-08-07 20:01:30 +02:00
Tomaž Vajngerl
ca00470722 allow saving a PDF, add "view_comment" state
This adds a "view_comment" in addition to "view" and "edit" state
into discovery.xml. In case it is enabled, the filters let the
comment commands through to core.

In addition add "Save Comment" menu action to allow saving the
comments, which is enabled when in "read-only" with "view_comment"
mode.

Change-Id: I3ab3dbee93ee2167ae96adea7025fc0b385f8201
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99473
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2020-07-27 16:40:12 +02:00
Mike Kaganski
a1fafe27f4 Allow user to try to lock the document for edit
Use mobile-edit-button for that is permitted.

Change-Id: I4d4c3f21d574abae033bacc69def96aaf6b51567
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98786
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-07-20 15:49:09 +02:00
Mike Kaganski
e9c4c0286a Handle failed locking as (temporarily) read-only session
E.g., opening a checked-out document in SharePoint

Change-Id: Ifd5225d8450d7f2f5ba9661f158551c5c16f9b09
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97596
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-07-20 15:47:33 +02:00
Miklos Vajna
7b38cf9fce wsd: fix log order in DocumentBroker::sendRequestedTiles()
First log then modify the container.

Change-Id: Ia2bae55562ec6e158c5622cfd25197b6e65584a5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98872
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-07-16 15:45:05 +02:00
Ashod Nakashian
aba09e165b wsd: improved TileCache
* Excised TileCacheDesc to improve performance and simplify code.
* clang-tidy suggestions and auto-rewrite fixes.
* Const-correctness.
* Inlined and improved a couple of trivial functions (that are called
often).
* Reduced some logs from INF to DBG as they are only meaningful to devs.

Change-Id: I1c4eb8c63da49aa061afbf3eb68cae23d4d5e7f3
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98661
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-07-14 15:35:20 +02:00
Samuel Mehrbrodt
20eaab2720 Log number of active sessions
Change-Id: Id161f09bc637e5dcf5ea0beaf11e360de7aa1fa2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98298
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2020-07-09 10:25:36 +02:00
Tor Lillqvist
c0706831b8 Add comment describing what was not a good idea after all for the iOS app
Change-Id: I43c760fa521f6a5860f2ed5dfef816ba5faaf463
2020-07-08 17:35:40 +03:00
Tor Lillqvist
0a2033d688 Bin pointless virtual function that only calls the base class function
Pointless since my own 7f25109f72, so
yeah, I should have noticed then.

Change-Id: Ic34584134ef840b33b874952e0bba8d14d3fde2f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98374
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-07-08 16:30:13 +02:00
Samuel Mehrbrodt
e71e37bcec Improve reporting save results
Change-Id: I3f2f96f4b8f196e6e9268bed24695f739f679124
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97699
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2020-07-07 15:06:25 +02:00
Mike Kaganski
35f8788e1c Only lock documents in editing sessions
Change-Id: I97753541a944bb299b04c032790d6af7a9ee0f63
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97609
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-07-02 14:21:30 +02:00
Samuel Mehrbrodt
9f8fdb7bd7 tdf#131123 Report back real save result
665b1629de was not correct, as it reported back
the save result of the internal save (which usually succeeds).
Instead we want to know the save result of the remote storage (WOPI/Webdav).
So report that back instead.

Change-Id: Iaaa42b8c817a19c2c77935a6f81c1951fdf2216c
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97637
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2020-07-01 17:57:53 +02:00
Ashod Nakashian
e93f7039c1 wsd: anonymize the filename only when anonymization is enabled
Change-Id: I0649788d38492b66aeb9cc4716dcbd23cd76cb4e
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97190
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-07-01 07:42:46 +02:00
Jan Holesovsky
2c4e4f2e6e android: This assert is iOS-only, ifdef it out.
Change-Id: I2a0dab7069721175983fa426f30422f5fd00e6b8
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97474
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2020-06-30 10:54:29 +02:00
Mike Kaganski
ec1bc58070 Don't show last modification indicator when data is unavailable
E.g., SharePoint 2013 and 2016 don't support LastModifiedTime field
in CheckFileInfo [1].

[1] https://docs.microsoft.com/en-us/openspecs/office_protocols/ms-wopi/e2e91eab-4c6d-4f00-9c3f-3a1962135626#Appendix_A_30

Change-Id: Icdcf9f82758b4bd34be25f553e9d756ab76b8bfa
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97221
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
2020-06-26 14:42:34 +02:00
Tor Lillqvist
7f25109f72 tdf#128502: Chunk of work to enable "multi-tasking" in the iOS app
Seems to not cause any serious regressions in the iOS app or in "make
run", but of course I am not able to run a comprehensive check of all
functionality.

Change-Id: I44a0e8d60bdbc0a885db88475961575c5e95ce88
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93037
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-06-26 13:09:51 +02:00
Tor Lillqvist
a541dc5bcb No need for this 'if (false)'
Change-Id: I552ee8873d398b428aa2c54d7d762c13144b8b75
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96931
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-06-23 13:26:37 +02:00
Ashod Nakashian
17044ade27 wsd: fix: call to virtual function during destruction
Change-Id: I914025fe642f6c78d4a5731fdb8e8920a62838b1
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96379
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-06-23 06:42:53 +02:00
Michael Meeks
d34854f688 Add support for BreadcrumbDocName.
Change-Id: I06c56e92dd3acf9269140ecefb0c8bc731191260
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95960
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-06-11 19:44:01 +02:00
Michael Meeks
36a4b5ad05 Proxy: dump ProxyProtocolHandler state separately
Somewhat inelegant - nasty extra header & dynamic cast.

Change-Id: Id18b2f7831ece3b971290e799c5df182429aa2a0
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95448
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2020-06-04 15:49:46 +02:00
Ashod Nakashian
d2d0492245 wsd: move LOOLProtocol::tokenize to Util::tokenize
The tokenizer(s) are more generic than the protocol
logic, and are used from contexts that don't involve
the protocol as such.

Change-Id: Ie8c256bf11a91e466bff794021f41603c9596a7f
2020-06-02 18:03:36 +01:00
Ashod Nakashian
6ab64ac992 wsd: single-char string literals -> char
Change-Id: I163d6fe1c80334317d38f8fed2199ad2b31a0f8a
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95335
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-06-02 17:22:26 +02:00