Pass callbacks for requestLog() and requestQrCode() by ref
This commit is contained in:
parent
407514289a
commit
8a77cdf516
|
@ -946,12 +946,12 @@ void SyncthingConnection::requestEvents()
|
|||
*
|
||||
* The specified \a callback is called on success; otherwise error() is emitted.
|
||||
*/
|
||||
QMetaObject::Connection SyncthingConnection::requestQrCode(const QString &text, std::function<void(const QByteArray &)> callback)
|
||||
QMetaObject::Connection SyncthingConnection::requestQrCode(const QString &text, const std::function<void(const QByteArray &)> &callback)
|
||||
{
|
||||
QUrlQuery query;
|
||||
query.addQueryItem(QStringLiteral("text"), text);
|
||||
QNetworkReply *reply = requestData(QStringLiteral("/qr/"), query, false);
|
||||
return QObject::connect(reply, &QNetworkReply::finished, [this, reply, callback] {
|
||||
QNetworkReply *const reply = requestData(QStringLiteral("/qr/"), query, false);
|
||||
return QObject::connect(reply, &QNetworkReply::finished, [this, reply, &callback] {
|
||||
reply->deleteLater();
|
||||
switch (reply->error()) {
|
||||
case QNetworkReply::NoError:
|
||||
|
@ -968,10 +968,10 @@ QMetaObject::Connection SyncthingConnection::requestQrCode(const QString &text,
|
|||
*
|
||||
* The specified \a callback is called on success; otherwise error() is emitted.
|
||||
*/
|
||||
QMetaObject::Connection SyncthingConnection::requestLog(std::function<void(const std::vector<SyncthingLogEntry> &)> callback)
|
||||
QMetaObject::Connection SyncthingConnection::requestLog(const std::function<void(const std::vector<SyncthingLogEntry> &)> &callback)
|
||||
{
|
||||
QNetworkReply *const reply = requestData(QStringLiteral("system/log"), QUrlQuery());
|
||||
return QObject::connect(reply, &QNetworkReply::finished, [this, reply, callback] {
|
||||
return QObject::connect(reply, &QNetworkReply::finished, [this, reply, &callback] {
|
||||
reply->deleteLater();
|
||||
switch (reply->error()) {
|
||||
case QNetworkReply::NoError: {
|
||||
|
|
|
@ -136,8 +136,8 @@ public:
|
|||
ChronoUtilities::DateTime startTime() const;
|
||||
ChronoUtilities::TimeSpan uptime() const;
|
||||
const QString &syncthingVersion() const;
|
||||
QMetaObject::Connection requestQrCode(const QString &text, std::function<void(const QByteArray &)> callback);
|
||||
QMetaObject::Connection requestLog(std::function<void(const std::vector<SyncthingLogEntry> &)> callback);
|
||||
QMetaObject::Connection requestQrCode(const QString &text, const std::function<void(const QByteArray &)> &callback);
|
||||
QMetaObject::Connection requestLog(const std::function<void(const std::vector<SyncthingLogEntry> &)> &callback);
|
||||
const QList<QSslError> &expectedSslErrors() const;
|
||||
SyncthingDir *findDirInfo(const QString &dirId, int &row);
|
||||
SyncthingDir *findDirInfo(QLatin1String key, const QJsonObject &object, int *row = nullptr);
|
||||
|
|
Loading…
Reference in New Issue