Commit Graph

29 Commits

Author SHA1 Message Date
Martchus a541b9ba35 Fix crash in launcher when executable is empty or not found 2023-01-12 22:53:18 +01:00
Martchus 268164748f Improve error message when the executable path in the launcher is empty
* Show error "executable path is empty" instead of "Unknown error"
2023-01-12 22:39:47 +01:00
Martchus 525b2c2f94 Improve tracking of whether Syncthing has been stopped manually
* Don't consider the proccess manually stopped by default; otherwise that's
  considered to be the case even though the launcher isn't used at all
* Unset the service being manually stopped only when there's an actual
  state transition to running; otherwise we'd immediately unset the flag
  after manually stopping the service
2022-10-22 12:06:18 +02:00
Martchus 6e6fbf757b Fix buffering further output in `SyncthingProcess` without event loop
When the calling code does not return to the event loop (like the CLI test)
we need to run the event loop internally to make sure `bufferOutput()` is
called as of ecd730fd49.
2022-09-18 19:59:46 +02:00
Martchus ecd730fd49 Avoid crash when invoking short-lived process via `SyncthingProcess`
At least when using Qt 6 I could reproduce crashes very often when invoking
`syncthing -version` as part of the wizard's setup detection (inside
a `QIODevice::readAll()` call).

I suppose the problem is that the callback `bufferOutput()` is already
invoked  on another thread and emitting the next `readyRead()` signal while
Qt is still handling the previous `readData()` call. Continuing reading
from the pipe only after `readData()` returns should fix it. At least it
does not crash anymore with that change in the wizard's setup detection.
2022-09-17 22:52:26 +02:00
Martchus 239d751342 Avoid an unhandled exception when local setup is incorrect
Apparently Boost.Process relies on the setup to be correct so the
configured locale actually needs to be available.
2021-09-30 23:41:27 +02:00
Martchus b828d7c274 Fix launching Syncthing with program/args containing non-ASCII characters
* Pass program/args for Syncthing launcher using UTF-16 under Windows
* See https://github.com/Martchus/syncthingtray/issues/107
2021-08-25 00:15:00 +02:00
Martchus 6aac7b0eae Suppress console Window under Windows
See https://github.com/Martchus/syncthingtray/issues/108
2021-08-24 23:50:28 +02:00
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 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 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 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 76407c1f1e Consider process initially stopped so the disconnect notification is correctly suppressed 2021-01-06 17:51:21 +01:00
Martchus 4b246d4b4d Improve SyncthingProcess and SyncthingLauncher
* Add documentation
* Remove leftovers
* Ensure all members are initialized
* Improve coding style
2019-07-13 16:42:19 +02:00
Martchus 64473df5ba Adapt to changes in c++utilities 2019-06-10 22:48:26 +02:00
Martchus b0dc9c861d Improve SyncthingProcess::splitArguments() parser 2018-04-18 23:46:17 +02:00
Martchus 0d635e5ad5 Refactor launcher
* Pass program and arguments directly
    * Prevent failure on white space in executable path
    * Use own parser for arguments
* Make libsyncthing accessible from launcher
2018-04-18 23:27:45 +02:00
Martchus 0ceb8d5e79 Add high-level abstraction for launching Syncthing
Add new SyncthingLauncher class which lauches Syncthing
under the hood via external SyncthingProcess or using
libsyncthing.

Note: Launching via libsyncthing is still experimental.
2018-04-11 23:16:00 +02:00
Martchus 0c104f60b8 Wait till all processes finished, ask for killing
See https://github.com/Martchus/syncthingtray/issues/15
2018-04-02 23:32:52 +02:00
Martchus 146d4870e4 Refactor preventing unwanted error messages
* See https://github.com/Martchus/syncthingtray/issues/15
* Not tested yet
2018-04-02 20:35:30 +02:00
Martchus 732a5fdd8d Apply clang-format 2017-05-01 03:34:43 +02:00
Martchus 3c2ce3e82f Allow launching syncthing-inotify
Provide a way to have multiple instances of
the launcher option page controlling separate
processes.
2017-03-17 00:38:42 +01:00
Martchus 6470038fc7 Refactor to allow sharing backend with other apps
Intended for creating command line tool and plasmoid
2016-09-30 23:58:45 +02:00