* Do not blindly override existing auto start entry
* Warn if an auto start entry exists but points to a different executable
* Allow removing such an entry explicitly
* Avoid overriding argv/argc via `CMD_UTILS_CONVERT_ARGS_TO_UTF8` in
Windows-specific code when processing arguments from a 2nd instance
* Move the other startup code to main as well as they are not needed when
processing arguments from a 2nd instance
* Improve debug logging
* Use `waitForBytesWritten()` instead of `flush()` when passing args as
recommended by the documentation
* Avoid use of `bytesAvailable()` as it doesn't work as expected in this
situation on Windows (likely it doesn't really work reliably on all
platforms); calling `readAll()` works and is simpler anyways
* Tested that `--replace` works as well; also the
`waitUntilGone && QFile::exists(fullServerName)` block is entered and if
the previous instance is taking some time it really waits until it is
gone
* Make functions in `main.cpp` static as they are not used by
other units
* Delete the `TrayIcon` via an extra parent object that is
deleted before the `QNetworkAccessManager` is deleted; otherwise
the destruction of `SyncthingConnection` (which aborts pending
replies) might access dangling `QNetworkReply` objects
* Improve error handling in `SingleInstance` code
* Allow to replace the current instance via the new `--replace`
argument; this may be useful when creating an installer/updater
* This is now required after 843f164d which uses event IDs
instead of time stamps and event IDs reset when Syncthing has
been restarted.
* It is likely a good idea to cleanly re-connect anyways.
* This change re-introduces the previously uneffective and hence
removed code (see 8c74b240). It fixes the code to effectively
make sure a re-connect is continued once it has been started.
So this change should fix the re-connect not working in
certain cases.
Calling `handleAdditionalRequestCanceled();` when `handleAborting`
is true is useless because then also `m_abortingAllRequests` is true
and therefore `handleAdditionalRequestCanceled();` always returns
early doing nothing.
This is now misleading as it depends on the general web settings. The
presence of this new settings tab alone should make it clear what will
happen instead so the sentence can just be dropped.
When connecting again, no data is cleared. Since we now keep
track of event IDs and not just timestamps it makes sense to not
forget what the last event IDs were. To still run into the
"limit" case the flags for having events at all can be used
(which is also reset on just `connect()`).
I have observed that Syncthing Tray can get stuck thinking a remote device
still needs data. Likely the update got lost. The code contains certain
conditions in which folder completion events and requesting completion are
supressed. Those conditions are based on timestamps. That is not ideal as
the accuracy is only one second (so different timestamps might be
considered equal as they are rounded to be the same). Additionally, it
makes no sense to assume a timestamp upon receiving a response as the
information might be older than the time it was received.
This change avoids those conditions. It rather uses the event ID to
decide what event/reply is newer.
This change also uses quint64 instead of int for event IDs to avoid running
into an overflow (or rather conversion error) when deserializing the ID
which might be bigger than int. (Not sure how big the ID can become; this
is to be on the safe side.)
Fixes the following error
```
qdbusxml2cpp: Got unknown type `a{sv}' processing '/build/static-compat-syncthingtray/src/syncthingtray/syncthingconnector/org.freedesktop.DBus.Properties.xml'
You should add <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="<type>"/> to the XML description for 'changed_properties'
```
by following the suggestion of that error. Not sure why this
error occurs only now. Maybe `qdbusxml2cpp` changed in Qt 6.5.0.
When stopping the Syncthing service ourselves we can apparently also
get "connection refused" and not just "remote host closed". So this
kind of error should be supressed as well.
* Check directly whether changed properties contain a property
instead of checking indirectly whether the returned QVariant
is invalid.
* Avoid copying the QVariant.
* Effectively this should not change anything; the code is just
more readable and possibly more efficient.