winix/plugins/export/exportthread.h

84 lines
2.0 KiB
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_plugins_export_exportthread
#define headerfile_winix_plugins_export_exportthread
#include <vector>
#include <list>
#include <curl/curl.h>
#include "core/basethread.h"
#include "message.h"
namespace Export
{
class ExportThread : public BaseThread
{
public:
ExportThread();
void SetUTF8(bool use_utf8);
void SetBaseUrl(const std::wstring & url);
void AddMessage(const Message & message);
void AddMessage(int type, const std::wstring & url, const std::wstring & path);
private:
typedef std::list<Message> MessageTab;
MessageTab message_tab;
Message message_add_temp;
Message message_work; // a message used by the second thread
static ExportThread * exp_thread;
std::string url_a;
std::string buffer;
size_t buffer_read_index;
bool utf8;
std::wstring base_url;
std::string browser_name;
std::string ftp_server;
std::string ftp_login;
std::string ftp_pass;
char error_buf[CURL_ERROR_SIZE];
int conn_timeout; // timeout in seconds
int conn_max_errors; // maximum errors (if there are more then a message is treated as undeliverable)
std::string look_for_url;
std::string repl_url;
std::string local_path;
virtual bool SignalReceived();
virtual void Do();
void DoMessage();
bool Fetch(const char * url);
bool Put();
static size_t StaticSaveFunction(char * ptr, size_t size, size_t nmemb, void *userdata);
size_t SaveFunction(char * ptr, size_t size, size_t nmemb, void *userdata);
static size_t StaticReadFunction(char * ptr, size_t size, size_t nmemb, void *userdata);
size_t ReadFunction(char * ptr, size_t size, size_t nmemb, void *userdata);
void Convert(const std::wstring & in, std::string & out, bool clear = true);
void ChangeAdresses(std::string & buf);
void ChangeAdressesThumb(std::string & buf);
bool HasThumbInAdress(std::string & buf, size_t i);
void CreateBaseUrl(std::string & buf);
};
} // namespace
#endif