#pragma once #include #include #include #include #include #include #include #include #include "thread_safe_queue.h" class Downloader { public: struct Command { std::string order; std::string url; std::string filename; std::function finished_callback; }; Downloader(); ~Downloader(); std::string FetchToken(); void FetchDataAndSaveToFile(const std::string& token, const std::string& filePath); private: CURL *m_curl; std::thread m_downloadThread; ThreadSafeQueue m_downloadQueue; std::mutex m_downloadMutex; bool m_cancel{false}; std::string PerformGetRequest(const std::string& url, struct curl_slist* headers = nullptr); void DownloadThread(); };