kioslave: const-ify curl slave slot arguments

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-03-19 00:14:28 +02:00
parent 657fc7dd05
commit a2c0f0f006
2 changed files with 23 additions and 23 deletions

View file

@ -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<KIO::UDSEntry> CurlProtocol::udsEntries()
{
QList<KIO::UDSEntry> result;

View file

@ -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<KIO::UDSEntry> udsEntries();
bool m_emitmime;