Files
winix/plugins/export/exportthread.h
Tomasz Sowa 39923d6617 fixed: UGContainer<Type> used a std::vector<Type> and when a new item was inserted
then current iterators (and pointers) were invalidated
         now we are using std::vector<Type*>
         this caused some crashes when a new user was added by 'adduser' winix function
added:   plugin 'export' is able to upload files on a remote server now
         (not finished yet)
changed: Thumb class is now called: Image
         and we are able to resize images too
         (some new options in the config and in mount points)
added:   some new plugin messages



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@764 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-09-13 06:08:34 +00:00

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