From 4fa212c43b22cfe63ca3fac2c869e05805bebc9f Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Thu, 18 Dec 2014 15:39:20 +0100 Subject: [PATCH] CSync callbacks: Don't use global account. --- src/libsync/creds/credentialscommon.cpp | 6 ++++-- src/libsync/creds/httpcredentials.cpp | 5 +++-- src/libsync/syncengine.cpp | 5 +++++ src/libsync/syncengine.h | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/libsync/creds/credentialscommon.cpp b/src/libsync/creds/credentialscommon.cpp index feba82f90..7ea5c1d77 100644 --- a/src/libsync/creds/credentialscommon.cpp +++ b/src/libsync/creds/credentialscommon.cpp @@ -25,6 +25,7 @@ #include "utility.h" #include "account.h" +#include "syncengine.h" namespace OCC { @@ -34,10 +35,11 @@ int handleNeonSSLProblems(const char* prompt, size_t /*len*/, int /*echo*/, int /*verify*/, - void* /*userdata*/) + void* userdata) { int re = 0; const QString qPrompt = QString::fromLatin1( prompt ).trimmed(); + SyncEngine* engine = reinterpret_cast(userdata); if( qPrompt.startsWith( QLatin1String("There are problems with the SSL certificate:"))) { // SSL is requested. If the program came here, the SSL check was done by Qt @@ -48,7 +50,7 @@ int handleNeonSSLProblems(const char* prompt, int pos = 0; // This is the set of certificates which QNAM accepted, so we should accept // them as well - QList certs = AccountManager::instance()->account()->sslConfiguration().peerCertificateChain(); + QList certs = engine->account()->sslConfiguration().peerCertificateChain(); while (!certOk && (pos = regexp.indexIn(qPrompt, 1+pos)) != -1) { QString neon_fingerprint = regexp.cap(1); diff --git a/src/libsync/creds/httpcredentials.cpp b/src/libsync/creds/httpcredentials.cpp index a5cf73517..1210b7093 100644 --- a/src/libsync/creds/httpcredentials.cpp +++ b/src/libsync/creds/httpcredentials.cpp @@ -29,6 +29,7 @@ #include "accessmanager.h" #include "utility.h" #include "theme.h" +#include "syncengine.h" #include "creds/credentialscommon.h" #include "creds/httpcredentials.h" @@ -47,8 +48,8 @@ int getauth(const char *prompt, int re = 0; // ### safe? Not really. If the wizard is run in the main thread, the caccount could change during the sync. - // Ideally, http_credentials could be use userdata, but userdata is the SyncEngine. - HttpCredentials* http_credentials = qobject_cast(AccountManager::instance()->account()->credentials()); + SyncEngine* engine = reinterpret_cast(userdata); + HttpCredentials* http_credentials = qobject_cast(engine->account()->credentials()); if (!http_credentials) { qDebug() << "Not a HTTP creds instance!"; diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index dd007c3a7..b442608b7 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -1149,6 +1149,11 @@ qint64 SyncEngine::timeSinceFileTouched(const QString& fn) const return -1; } +AccountPtr SyncEngine::account() const +{ + return _account; +} + void SyncEngine::abort() { csync_request_abort(_csync_ctx); diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h index 1b99085cf..e63a51f5d 100644 --- a/src/libsync/syncengine.h +++ b/src/libsync/syncengine.h @@ -76,6 +76,8 @@ public: */ qint64 timeSinceFileTouched(const QString& fn) const; + AccountPtr account() const; + signals: void csyncError( const QString& ); void csyncUnavailable();