From a2c0f0f00610dedb01cdd7292a4b85b58b7f2473 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Tue, 19 Mar 2024 00:14:28 +0200 Subject: [PATCH] kioslave: const-ify curl slave slot arguments Signed-off-by: Ivailo Monev --- kioslave/curl/kio_curl.cpp | 42 +++++++++++++++++++------------------- kioslave/curl/kio_curl.h | 4 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/kioslave/curl/kio_curl.cpp b/kioslave/curl/kio_curl.cpp index 9d04cf36..cc944309 100644 --- a/kioslave/curl/kio_curl.cpp +++ b/kioslave/curl/kio_curl.cpp @@ -697,7 +697,7 @@ void CurlProtocol::slotData(const char* curldata, const size_t curldatasize) } } -void CurlProtocol::slotProgress(KIO::filesize_t received, KIO::filesize_t total) +void CurlProtocol::slotProgress(const KIO::filesize_t received, const KIO::filesize_t total) { kDebug(7103) << "Received" << received << "from" << total; processedSize(received); @@ -706,6 +706,26 @@ void CurlProtocol::slotProgress(KIO::filesize_t received, KIO::filesize_t total) } } +CURLcode CurlProtocol::setupAuth(const QString &username, const QString &password) +{ + CURLcode curlresult = CURLE_OK; + const QByteArray urlusernamebytes = username.toAscii(); + if (!urlusernamebytes.isEmpty()) { + curlresult = curl_easy_setopt(m_curl, CURLOPT_USERNAME, urlusernamebytes.constData()); + if (curlresult != CURLE_OK) { + return curlresult; + } + } + const QByteArray urlpasswordbytes = password.toAscii(); + if (!urlpasswordbytes.isEmpty()) { + curlresult = curl_easy_setopt(m_curl, CURLOPT_PASSWORD, urlpasswordbytes.constData()); + if (curlresult != CURLE_OK) { + return curlresult; + } + } + return curlresult; +} + bool CurlProtocol::setupCurl(const KUrl &url, const bool ftporsftp) { if (Q_UNLIKELY(!m_curl)) { @@ -980,26 +1000,6 @@ CURLcode CurlProtocol::performCurl(const KUrl &url, KUrl *redirecturl) return curlresult; } -CURLcode CurlProtocol::setupAuth(const QString &username, const QString &password) -{ - CURLcode curlresult = CURLE_OK; - const QByteArray urlusernamebytes = username.toAscii(); - if (!urlusernamebytes.isEmpty()) { - curlresult = curl_easy_setopt(m_curl, CURLOPT_USERNAME, urlusernamebytes.constData()); - if (curlresult != CURLE_OK) { - return curlresult; - } - } - const QByteArray urlpasswordbytes = password.toAscii(); - if (!urlpasswordbytes.isEmpty()) { - curlresult = curl_easy_setopt(m_curl, CURLOPT_PASSWORD, urlpasswordbytes.constData()); - if (curlresult != CURLE_OK) { - return curlresult; - } - } - return curlresult; -} - QList CurlProtocol::udsEntries() { QList result; diff --git a/kioslave/curl/kio_curl.h b/kioslave/curl/kio_curl.h index 59b4102d..b0237cd4 100644 --- a/kioslave/curl/kio_curl.h +++ b/kioslave/curl/kio_curl.h @@ -38,14 +38,14 @@ public: void del(const KUrl &url, bool isfile) final; void slotData(const char* curldata, const size_t curldatasize); - void slotProgress(KIO::filesize_t received, KIO::filesize_t total); + void slotProgress(const KIO::filesize_t received, const KIO::filesize_t total); bool aborttransfer; private: + CURLcode setupAuth(const QString &username, const QString &password); bool setupCurl(const KUrl &url, const bool ftporsftp); CURLcode performCurl(const KUrl &url, KUrl *redirecturl); - CURLcode setupAuth(const QString &username, const QString &password); QList udsEntries(); bool m_emitmime;