emailQt/CurlHandler.hpp

49 lines
1.1 KiB
C++
Raw Permalink Normal View History

2024-03-08 12:10:58 -05:00
#pragma once
#include <cstdlib>
#include <functional>
#include <memory>
#include <string>
#include <thread>
#include <vector>
#include <QObject>
#include <curl/curl.h>
#include "ParametersProvider.hpp"
constexpr long curlTimeoutSeconds{5};
// View RFC 3501 and RFC 2192 for more details
size_t cb(char *data, size_t size, size_t numberOfMembers, void *userdata);
class CurlHandler : public QObject {
Q_OBJECT
public:
CurlHandler();
~CurlHandler();
void configure(const ParametersProvider::settings &sett);
std::vector<std::string> *fetch();
void query(std::string &c, size_t count);
2024-12-19 18:51:41 -05:00
void setupCurl(CURL *ptr, std::string &m, const std::string &ur) const;
2024-03-08 12:10:58 -05:00
signals:
void threadFinished(size_t threadId, int uid);
private:
std::string url;
2024-12-19 18:51:41 -05:00
std::unique_ptr<CURL, decltype(&curl_easy_cleanup)> initialCurl;
2024-03-08 12:10:58 -05:00
CURLcode initialRes;
std::string initialChunk;
std::vector<std::string> decodedMessages;
std::vector<std::string> messagesId;
std::vector<std::thread> v;
ParametersProvider::settings setts;
};