Refactor SyncthingConnection
* Reduce if-cascades * Add extra method for handling fatal errors * Read directory summary in extra method * Allow requesting summary for directory explicitely
This commit is contained in:
parent
be6d0cbf5d
commit
ca256b62e8
File diff suppressed because it is too large
Load Diff
|
@ -174,6 +174,8 @@ private Q_SLOTS:
|
|||
void requestErrors();
|
||||
void requestClearingErrors();
|
||||
void requestDirStatistics();
|
||||
void requestDirStatus(const QString &dirId);
|
||||
|
||||
void requestDeviceStatistics();
|
||||
void requestEvents();
|
||||
void abortAllRequests();
|
||||
|
@ -201,6 +203,8 @@ private Q_SLOTS:
|
|||
void readDirPauseResume();
|
||||
void readRestart();
|
||||
void readShutdown();
|
||||
void readDirStatus();
|
||||
void readDirSummary(const QJsonObject &summary, SyncthingDir &dirInfo, int index);
|
||||
|
||||
void continueConnecting();
|
||||
void continueReconnecting();
|
||||
|
@ -210,6 +214,7 @@ private Q_SLOTS:
|
|||
void emitError(const QString &message, const QJsonParseError &jsonError, QNetworkReply *reply, const QByteArray &response = QByteArray());
|
||||
void emitError(const QString &message, SyncthingErrorCategory category, QNetworkReply *reply);
|
||||
void emitMyIdChanged(const QString &newId);
|
||||
void handleFatalConnectionError();
|
||||
|
||||
private:
|
||||
QNetworkRequest prepareRequest(const QString &path, const QUrlQuery &query, bool rest = true);
|
||||
|
|
|
@ -74,6 +74,7 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
|||
QStringList deviceNames;
|
||||
bool readOnly = false;
|
||||
bool ignorePermissions = false;
|
||||
bool ignorePatterns = false;
|
||||
bool autoNormalize = false;
|
||||
int rescanInterval = 0;
|
||||
int minDiskFreePercentage = 0;
|
||||
|
@ -85,9 +86,9 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
|||
QString globalError;
|
||||
std::vector<SyncthingItemError> itemErrors;
|
||||
std::vector<SyncthingItemError> previousItemErrors;
|
||||
int globalBytes = 0, globalDeleted = 0, globalFiles = 0;
|
||||
int localBytes = 0, localDeleted = 0, localFiles = 0;
|
||||
int neededByted = 0, neededFiles = 0;
|
||||
quint64 globalBytes = 0, globalDeleted = 0, globalFiles = 0, globalDirs = 0;
|
||||
quint64 localBytes = 0, localDeleted = 0, localFiles = 0, localDirs = 0;
|
||||
quint64 neededByted = 0, neededFiles = 0, neededDirs = 0;
|
||||
ChronoUtilities::DateTime lastScanTime;
|
||||
ChronoUtilities::DateTime lastFileTime;
|
||||
QString lastFileName;
|
||||
|
|
|
@ -44,146 +44,152 @@
|
|||
<translation>Verbindungsstatus unbekannt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="144"/>
|
||||
<location filename="../syncthingconnection.cpp" line="231"/>
|
||||
<location filename="../syncthingconnection.cpp" line="147"/>
|
||||
<location filename="../syncthingconnection.cpp" line="233"/>
|
||||
<source>Connection configuration is insufficient.</source>
|
||||
<translation>Verbindungskonfiguration is ungenügend</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="436"/>
|
||||
<location filename="../syncthingconnection.cpp" line="438"/>
|
||||
<source>Unable to pause/resume a devices when not connected</source>
|
||||
<translation>Fehler beim Anfordern Verzeichnis zu Pausieren/Fortzusetzen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="466"/>
|
||||
<location filename="../syncthingconnection.cpp" line="469"/>
|
||||
<source>Unable to pause/resume a directories when not connected</source>
|
||||
<translation>Fehler beim Anfordern Gerät zu Pausieren/Fortzusetzen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="730"/>
|
||||
<location filename="../syncthingconnection.cpp" line="745"/>
|
||||
<source>Unable to request QR-Code: </source>
|
||||
<translation>Fehler beim Abfragen des QR-Codes: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="759"/>
|
||||
<location filename="../syncthingconnection.cpp" line="765"/>
|
||||
<source>Unable to parse Syncthing log: </source>
|
||||
<translation>Fehler beim Auslesen des Syncthing-Logs: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="764"/>
|
||||
<location filename="../syncthingconnection.cpp" line="780"/>
|
||||
<source>Unable to request Syncthing log: </source>
|
||||
<translation>Fehler beim Abfragen des Syncthing-Logs: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="798"/>
|
||||
<location filename="../syncthingconnection.cpp" line="814"/>
|
||||
<source>Unable to locate certificate used by Syncthing.</source>
|
||||
<translation>Das SSL-Zertifikat von Syncthing kann nicht gefunden werden.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="804"/>
|
||||
<location filename="../syncthingconnection.cpp" line="820"/>
|
||||
<source>Unable to load certificate used by Syncthing.</source>
|
||||
<translation>Das SSL-Zertifikat von Syncthing kann nicht ausgelesen werden.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="884"/>
|
||||
<location filename="../syncthingconnection.cpp" line="895"/>
|
||||
<source>Unable to parse Syncthing config: </source>
|
||||
<translation>Fehler beim Auslesen der Syncthing-Konfiguration: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="891"/>
|
||||
<location filename="../syncthingconnection.cpp" line="909"/>
|
||||
<source>Unable to request Syncthing config: </source>
|
||||
<translation>Fehler beim Abfragen der Syncthing-Konfiguration: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="986"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1005"/>
|
||||
<source>Unable to parse Syncthing status: </source>
|
||||
<translation>Fehler beim Auslesen des Syncthing-Status: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="993"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1019"/>
|
||||
<source>Unable to request Syncthing status: </source>
|
||||
<translation>Fehler beim Abfragen des Syncthing-Status: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1094"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1060"/>
|
||||
<source>Unable to parse connections: </source>
|
||||
<translation>Fehler beim Auslesen der Verbindungen: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1101"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1133"/>
|
||||
<source>Unable to request connections: </source>
|
||||
<translation>Fehler beim Abfragen der Verbindungen: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1156"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1151"/>
|
||||
<source>Unable to parse directory statistics: </source>
|
||||
<translation>Fehler beim Auslesen der Verzeichnisstatistiken: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1163"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1197"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1781"/>
|
||||
<source>Unable to request directory statistics: </source>
|
||||
<translation>Fehler beim Abfragen der Verzeichnisstatistiken: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1200"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1215"/>
|
||||
<source>Unable to parse device statistics: </source>
|
||||
<translation>Fehler beim Auslesen der Gerätestatistiken: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1207"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1242"/>
|
||||
<source>Unable to request device statistics: </source>
|
||||
<translation>Fehler beim Abfragen der Gerätestatistiken: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1246"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1268"/>
|
||||
<source>Unable to parse errors: </source>
|
||||
<translation>Fehler beim Auslesen der Syncthing-Fehlermeldungen: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1258"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1295"/>
|
||||
<source>Unable to request errors: </source>
|
||||
<translation>Fehler beim Abfragen der Syncthing-Fehlermeldungen: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1274"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1311"/>
|
||||
<source>Unable to request clearing errors: </source>
|
||||
<translation>Fehler beim Löschen der Fehlermeldungen: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1328"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1332"/>
|
||||
<source>Unable to parse Syncthing events: </source>
|
||||
<translation>Fehler beim Auslesen der Syncthing-Ereignisse: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1351"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1385"/>
|
||||
<source>Unable to request Syncthing events: </source>
|
||||
<translation>Fehler beim Abfragen der Syncthing-Ereignisse: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1633"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1669"/>
|
||||
<source>Unable to request rescan: </source>
|
||||
<translation>Fehler beim Anfordern eines Verzeichnis-Rescans: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1657"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1693"/>
|
||||
<source>Unable to request device pause/resume: </source>
|
||||
<translation>Fehler beim Anfordern Gerät zu Pausieren/Fortzusetzen: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1678"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1714"/>
|
||||
<source>Unable to request directory pause/resume: </source>
|
||||
<translation>Fehler beim Anfordern Verzeichnis zu Pausieren/Fortzusetzen: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1694"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1730"/>
|
||||
<source>Unable to request restart: </source>
|
||||
<translation>Fehler beim Anfordern eines Neustarts: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1710"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1746"/>
|
||||
<source>Unable to request shutdown: </source>
|
||||
<translation>Fehler beim Anfordern Syncthing zu beenden: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1773"/>
|
||||
<source>Unable to parse status for directory %1: </source>
|
||||
<translation>Fehler beim Anfordern des Status von Verzeichnis %1: </translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Data::SyncthingService</name>
|
||||
|
|
|
@ -44,146 +44,152 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="144"/>
|
||||
<location filename="../syncthingconnection.cpp" line="231"/>
|
||||
<location filename="../syncthingconnection.cpp" line="147"/>
|
||||
<location filename="../syncthingconnection.cpp" line="233"/>
|
||||
<source>Connection configuration is insufficient.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="436"/>
|
||||
<location filename="../syncthingconnection.cpp" line="438"/>
|
||||
<source>Unable to pause/resume a devices when not connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="466"/>
|
||||
<location filename="../syncthingconnection.cpp" line="469"/>
|
||||
<source>Unable to pause/resume a directories when not connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="730"/>
|
||||
<location filename="../syncthingconnection.cpp" line="745"/>
|
||||
<source>Unable to request QR-Code: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="759"/>
|
||||
<location filename="../syncthingconnection.cpp" line="765"/>
|
||||
<source>Unable to parse Syncthing log: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="764"/>
|
||||
<location filename="../syncthingconnection.cpp" line="780"/>
|
||||
<source>Unable to request Syncthing log: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="798"/>
|
||||
<location filename="../syncthingconnection.cpp" line="814"/>
|
||||
<source>Unable to locate certificate used by Syncthing.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="804"/>
|
||||
<location filename="../syncthingconnection.cpp" line="820"/>
|
||||
<source>Unable to load certificate used by Syncthing.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="884"/>
|
||||
<location filename="../syncthingconnection.cpp" line="895"/>
|
||||
<source>Unable to parse Syncthing config: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="891"/>
|
||||
<location filename="../syncthingconnection.cpp" line="909"/>
|
||||
<source>Unable to request Syncthing config: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="986"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1005"/>
|
||||
<source>Unable to parse Syncthing status: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="993"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1019"/>
|
||||
<source>Unable to request Syncthing status: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1094"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1060"/>
|
||||
<source>Unable to parse connections: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1101"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1133"/>
|
||||
<source>Unable to request connections: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1156"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1151"/>
|
||||
<source>Unable to parse directory statistics: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1163"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1197"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1781"/>
|
||||
<source>Unable to request directory statistics: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1200"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1215"/>
|
||||
<source>Unable to parse device statistics: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1207"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1242"/>
|
||||
<source>Unable to request device statistics: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1246"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1268"/>
|
||||
<source>Unable to parse errors: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1258"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1295"/>
|
||||
<source>Unable to request errors: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1274"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1311"/>
|
||||
<source>Unable to request clearing errors: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1328"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1332"/>
|
||||
<source>Unable to parse Syncthing events: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1351"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1385"/>
|
||||
<source>Unable to request Syncthing events: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1633"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1669"/>
|
||||
<source>Unable to request rescan: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1657"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1693"/>
|
||||
<source>Unable to request device pause/resume: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1678"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1714"/>
|
||||
<source>Unable to request directory pause/resume: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1694"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1730"/>
|
||||
<source>Unable to request restart: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1710"/>
|
||||
<location filename="../syncthingconnection.cpp" line="1746"/>
|
||||
<source>Unable to request shutdown: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../syncthingconnection.cpp" line="1773"/>
|
||||
<source>Unable to parse status for directory %1: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Data::SyncthingService</name>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "./global.h"
|
||||
|
||||
#include <QJsonValue>
|
||||
#include <QStringList>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QUrl)
|
||||
|
@ -19,6 +20,11 @@ bool LIB_SYNCTHING_CONNECTOR_EXPORT isLocal(const QUrl &url);
|
|||
bool LIB_SYNCTHING_CONNECTOR_EXPORT setDirectoriesPaused(QJsonObject &syncthingConfig, const QStringList &dirIds, bool paused);
|
||||
bool LIB_SYNCTHING_CONNECTOR_EXPORT setDevicesPaused(QJsonObject &syncthingConfig, const QStringList &dirs, bool paused);
|
||||
|
||||
inline quint64 LIB_SYNCTHING_CONNECTOR_EXPORT toUInt64(const QJsonValue &value, double defaultValue = 0.0)
|
||||
{
|
||||
return static_cast<quint64>(value.toDouble(defaultValue));
|
||||
}
|
||||
|
||||
template <class Objects> QStringList LIB_SYNCTHING_CONNECTOR_EXPORT ids(const Objects &objects)
|
||||
{
|
||||
QStringList ids;
|
||||
|
|
Loading…
Reference in New Issue