Commit Graph

373 Commits

Author SHA1 Message Date
Martchus 4c6315b450 Terminate Syncthing gracefully via REST-API on non-UNIX platforms (2)
A follow up to 0faacaa7c8 to cover the stop button within the launcher
and terminating Syncthing on shutdown/exit. To find the relevant connection
the connection settings are searched for a local URL where the port matches
the port from the Syncthing process log.
2021-07-15 02:38:26 +02:00
Martchus 0ef3b80447 Fix typos found via `codespell --skip .git -w` 2021-07-03 19:29:49 +02:00
Martchus 9f7a19eabc Update translations 2021-07-03 18:50:59 +02:00
Martchus 1acfb8c896 Consider directories still out-of-sync if there are pull errors
Syncthing can report an "idle" status despite pull errors. This still means
the directory is out-of-sync. With this change the out-of-sync status is
only cleared when reading a "FolderSummary" event without pull errors (or
temporarily if the directory is e.g. scanning).
2021-07-01 17:40:23 +02:00
Martchus fdc73bed60 Query only one event at the beginning (to find the ID of the latest event)
Syncthing's official web UI also does the first query for events like this.
This should make loading times a bit faster and removes the possibility of
picking-up obsolete events (which was always problematic).
2021-07-01 17:37:47 +02:00
Martchus 6cfa8a96b6 Do not buffer further output when `readData()` is called on empty buffer
See comment; otherwise calls to `readAll()` with no `bytesAvailable()`
like done in the `syncthingctl` tests fail sporadically as async read
operations are started concurrently.
2021-07-01 17:32:49 +02:00
Martchus 7508e59379 Update translations 2021-06-27 18:59:26 +02:00
Martchus 17f394c118 Add missing library ws2_32 required by Boost.Asio under Windows 2021-06-27 18:54:43 +02:00
Martchus 0faacaa7c8 Terminate Syncthing gracefully via REST-API on non-UNIX platforms
If there's a configured and local Syncthing connection and we're on a
non-UNIX platform which doesn't support SIGTERM (basically Windows) it
makes sense to use the REST-API instead. That's likely better than just
terminating the process forcefully.

This doesn't cover the stop button within the launcher settings yet because
from this context is isn't clear which connection is relevant as there can
be multiple tray icons/widgets but only one settings page.
2021-06-21 23:18:51 +02:00
Martchus 04c82e3ec4 Make logging of process exit an info message 2021-06-21 22:32:51 +02:00
Martchus 900dac793d Silence clazy warnings
For some reason clazy thinks `QIODevice::aboutToClose()` is not a signal.
2021-06-21 22:30:26 +02:00
Martchus 765a323b47 Use a queued connection to handle SyncthingProcess::finished 2021-06-21 22:23:18 +02:00
Martchus eac3b31727 Link against threading library when using Boost.Process 2021-06-21 17:44:43 +02:00
Martchus d91448dfb4 Avoid using `QProcess::ProcessError` to avoid `QMetaMethod::invoke` error
Otherwise `QMetaMethod::invoke` wouldn't be able to handle it:
```
QMetaMethod::invoke: Unable to handle unregistered datatype 'QProcess::ProcessError'
```
2021-06-17 21:17:21 +02:00
Martchus 1bc52ebb0f Improve Boost.Process-based SyncthingProcess
* Implement member functions required to run tests
* Add documentation
* Add minor tweaks
2021-06-17 20:32:40 +02:00
Martchus 9ce9b11ba4 Use Boost.Process for launcher to cope with further sub processes
* Use a process group / job object via Boost.Process to be able to
  terminate sub processes as well
* Do not try to stop the process gracefully under Windows by posting
  WM_CLOSE because this has no effect on Syncthing anyways
* See https://github.com/Martchus/syncthingtray/issues/94
2021-06-16 22:44:48 +02:00
Martchus 7f55afc51c Update translations 2021-06-04 16:26:35 +02:00
Martchus 986959c8b2 Avoid reading reply data if the reply isn't open
This might be the case when the request has been aborted. Reading from the
reply in this case would result in an unwanted log message from Qt.
2021-06-04 16:26:09 +02:00
Martchus 93f59ebf8a Apply clang-format 2021-05-27 18:16:56 +02:00
Martchus 0c475f5b7e Update translations 2021-05-27 18:16:22 +02:00
Martchus 7ad82c9dfe Emit time stamp parsing errors like other parsing errors 2021-05-21 22:34:42 +02:00
Martchus 62e7797558 Allow enabling logging of libsyncthingconnector at runtime
* Remove compile-time switches to enable logging
* Enable logging if certain environment variables are set
* Allow logging all API responses
2021-05-18 18:21:48 +02:00
Martchus fbb7685f4b Fix warnings about detatching Qt container via for loop 2021-05-18 00:08:21 +02:00
Martchus 239f750028 Improve timestamp parsing/handling
* Use local time consistently for timestamps which might get displayed
  within the UI, e.g. the dir status was in one case set to the local time
  and in other cases GMT was used which could lead to discarding status
  updates
* Print warning when timestamp parsing fails (instead of ignoring it
  silently)
* Set directory status from folder status response even when parsing the
  timestamp fails
* Catch possible exception when printing log timestamps in syncthingctl
2021-05-18 00:08:21 +02:00
Martchus b5aa29c98b Update translations 2021-04-07 20:01:07 +02:00
Martchus 46099abc0c Assign empty completion when receiving 404 response 2021-04-07 19:55:47 +02:00
Martchus 9ae7f4a265 Avoid requesting completion for paused devs/dirs after remote index changed 2021-04-07 19:53:16 +02:00
Martchus a5f629d710 Avoid crash when start time can not be parsed 2021-04-07 19:42:07 +02:00
Martchus 31ad8b979c Do not request completion for paused directories
See https://github.com/Martchus/PKGBUILDs/issues/132
2021-04-07 15:12:28 +02:00
Martchus f75966aadc Fix warnings 2021-03-20 22:39:40 +01:00
Martchus 6c12f18eaf Update translations 2021-03-06 16:26:23 +01:00
Martchus 851edeaafc Never consider the own device as paused 2021-02-12 19:44:27 +01:00
Martchus 1cfd067abd Do not accept "lastSeen" timestamps older or equal to the UNIX epoch
The UNIX epoch seems to be the "null-value" provided by Syncthing's API
when there's no "lastSeen" timestamp, e.g. when it is the own device.
2021-02-12 17:55:38 +01:00
Martchus bdf00a9889 Never consider the own device as paused 2021-02-12 12:51:18 +01:00
Martchus 76407c1f1e Consider process initially stopped so the disconnect notification is correctly suppressed 2021-01-06 17:51:21 +01:00
Martchus 4c4fc676e6 Update translations 2021-01-01 21:22:15 +01:00
Martchus ed495ec667 Add UI to configure what information should be considered to compute overall status
* See https://github.com/Martchus/syncthingtray/issues/74
* See https://github.com/Martchus/syncthingtray/issues/76
2021-01-01 20:55:18 +01:00
Martchus b2ba8c01ea Use header-only target of qtutilities
See the commit message of the corresponding commit in c++utilities
(9fb3bbe179698fb10339d4911b98531b0847cfa1) and also the related commit in
reflective-rapidjson (5c49a438ade5ae4253ae978e3a22cf88bd7cb2e2).
2021-01-01 18:50:46 +01:00
Martchus da911c6350 Refactor overall status compution
* Allow configuring the information to consider for computing the overall
  status via SyncthingStatusComputionFlags
    * Add flag to allow considering the status of remote devices for
      https://github.com/Martchus/syncthingtray/issues/74
    * Show only plain "idle" status when no flags are present for
      https://github.com/Martchus/syncthingtray/issues/76
* Set the default flags to keep the default behavior as-is
2020-12-31 02:48:18 +01:00
Martchus 392eb70b12 Remove uses of SyncthingStatus::OutOfSync which is never actually set 2020-12-31 02:33:20 +01:00
Martchus f7c3ceaece Improve documentation of connector library 2020-12-31 02:30:05 +01:00
Martchus 41e0934cd8 Don't call recalculateStatus() in emitNotifications()
because notifications have nothing to do with the status and it should not
make a difference since the status would not change. The UI is supposed to
rely only on newNotification().
2020-12-31 02:28:11 +01:00
Martchus b8f3b664e0 Use CPP_UTILITIES_MARK_FLAG_ENUM_CLASS for SyncthingHighLevelNotification 2020-12-31 02:17:25 +01:00
Martchus c827907ea6 Update SyncthingDirStatus enum to new states from syncthing/lib/model/folderstate.go 2020-12-31 02:13:32 +01:00
Martchus 64686caee6 Avoid detaching Qt container in SyncthingConnection::abortAllRequests()
* See https://doc.qt.io/qt-5/qtglobal.html#qAsConst
* Using std::as_const() instead of qAsConst() to keep support for Qt 5.6
2020-12-31 02:11:35 +01:00
Martchus 1bf58bf38d Apply cmake-format and clang-format 2020-12-17 17:52:02 +01:00
Martchus a069fa954b Apply clang-format 2020-11-03 18:28:31 +01:00
Martchus bacca0241a Fix build with Qt 6 (beta1) 2020-10-23 17:04:35 +02:00
Martchus 49bbebd1ad Allow configuring package suffix for qtutilities individually 2020-10-23 17:03:57 +02:00
Martchus c9a56da42c Fix compilation of mocked configuration 2020-10-07 21:42:50 +02:00