2022-02-16 08:49:13 +02:00
|
|
|
/* This file is part of the KDE libraries
|
|
|
|
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License version 2, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
2014-11-13 01:04:59 +02:00
|
|
|
*/
|
|
|
|
|
2024-03-19 22:04:36 +02:00
|
|
|
#ifndef KIO_CURL_H
|
|
|
|
#define KIO_CURL_H
|
2014-11-13 01:04:59 +02:00
|
|
|
|
|
|
|
#include <kurl.h>
|
2022-02-16 08:49:13 +02:00
|
|
|
#include <kio/slavebase.h>
|
2014-11-13 01:04:59 +02:00
|
|
|
|
2022-02-19 16:40:06 +02:00
|
|
|
#include <curl/curl.h>
|
|
|
|
|
2024-03-16 23:08:00 +02:00
|
|
|
class CurlProtocol : public KIO::SlaveBase
|
2014-11-13 01:04:59 +02:00
|
|
|
{
|
2022-02-17 13:55:51 +02:00
|
|
|
public:
|
2024-03-16 23:08:00 +02:00
|
|
|
CurlProtocol(const QByteArray &app);
|
|
|
|
~CurlProtocol();
|
2014-11-13 01:04:59 +02:00
|
|
|
|
2022-05-13 00:55:00 +03:00
|
|
|
void stat(const KUrl &url) final;
|
2024-03-16 23:08:00 +02:00
|
|
|
void listDir(const KUrl &url) final;
|
2024-03-18 00:26:05 +02:00
|
|
|
void get(const KUrl &url) final;
|
2024-03-18 05:22:26 +02:00
|
|
|
void chmod(const KUrl &url, int permissions) final;
|
2024-03-18 06:13:28 +02:00
|
|
|
void mkdir(const KUrl &url, int permissions) final;
|
|
|
|
void del(const KUrl &url, bool isfile) final;
|
2022-02-17 14:17:40 +02:00
|
|
|
|
2022-02-19 16:40:06 +02:00
|
|
|
void slotData(const char* curldata, const size_t curldatasize);
|
2024-03-19 00:14:28 +02:00
|
|
|
void slotProgress(const KIO::filesize_t received, const KIO::filesize_t total);
|
2022-02-19 16:40:06 +02:00
|
|
|
|
2022-05-13 17:13:51 +03:00
|
|
|
bool aborttransfer;
|
|
|
|
|
2022-02-19 16:40:06 +02:00
|
|
|
private:
|
2024-03-19 00:14:28 +02:00
|
|
|
CURLcode setupAuth(const QString &username, const QString &password);
|
2024-03-18 07:47:46 +02:00
|
|
|
bool setupCurl(const KUrl &url, const bool ftporsftp);
|
2024-03-18 03:38:19 +02:00
|
|
|
CURLcode performCurl(const KUrl &url, KUrl *redirecturl);
|
2024-03-18 00:26:05 +02:00
|
|
|
QList<KIO::UDSEntry> udsEntries();
|
2022-05-11 23:06:14 +03:00
|
|
|
|
2022-05-13 17:13:51 +03:00
|
|
|
bool m_emitmime;
|
2024-03-16 23:08:00 +02:00
|
|
|
bool m_ishttp;
|
|
|
|
bool m_isftp;
|
|
|
|
bool m_issftp;
|
|
|
|
bool m_collectdata;
|
|
|
|
QByteArray m_writedata;
|
|
|
|
KUrl m_url;
|
2022-02-19 16:40:06 +02:00
|
|
|
CURL* m_curl;
|
2024-03-18 05:22:26 +02:00
|
|
|
struct curl_slist* m_curlheaders;
|
|
|
|
struct curl_slist* m_curlquotes;
|
2014-11-13 01:04:59 +02:00
|
|
|
};
|
2022-02-16 08:49:13 +02:00
|
|
|
|
2024-03-19 22:04:36 +02:00
|
|
|
#endif // KIO_CURL_H
|