diff --git a/plugins/export/exportthread.cpp b/plugins/export/exportthread.cpp index 0e0713a..22d9440 100755 --- a/plugins/export/exportthread.cpp +++ b/plugins/export/exportthread.cpp @@ -42,6 +42,9 @@ void ExportThread::SetUTF8(bool use_utf8) void ExportThread::SetBaseUrl(const std::wstring & url) { + // SetBaseUrl() is called before the this thread + // is started so we can use 'base_url' later without locking + // the same is for 'utf8' base_url = url; } @@ -259,6 +262,7 @@ bool ExportThread::Put() { FILE * file = 0; + if( message_work.type == WINIX_PL_EXPORT_TYPE_CREATE_FILE_STATIC ) { Convert(message_work.url, local_path); @@ -372,101 +376,8 @@ return i; } -void ExportThread::CreateBaseUrl(std::string & buf) -{ - buf = "http://"; - Convert(base_url, buf, false); -} - - - -void ExportThread::ChangeAdresses(std::string & buf) -{ - // !! mozna lock skasowac jesli loger nie bedzie uzywany - Lock(); - - ChangeAdressesThumb(buf); - - CreateBaseUrl(look_for_url); - look_for_url += "/static"; - Convert(message_work.src_dir, look_for_url, false); - Convert(message_work.http_server, repl_url); - repl_url += "/static/"; - log << log1 << "zamiana: |" << look_for_url << "|, na: |" << repl_url << "|" << logend << logsave; - ReplaceString(buf, look_for_url, repl_url); - - /* - CreateBaseUrl(look_for_url); - look_for_url += "/common/"; - Convert(message_work.http_server, repl_url); - repl_url += "/common/"; - log << log1 << "zamiana: |" << look_for_url << "|, na: |" << repl_url << "|" << logend << logsave; - ReplaceString(buf, look_for_url, repl_url); - */ - - CreateBaseUrl(look_for_url); - Convert(message_work.src_dir, look_for_url, false); - Convert(message_work.http_server, repl_url); - repl_url += "/"; - log << log1 << "zamiana: |" << look_for_url << "|, na: |" << repl_url << "|" << logend << logsave; - ReplaceString(buf, look_for_url, repl_url); - - NoLastSlash(look_for_url); - Convert(message_work.http_server, repl_url); - look_for_url += '\"'; - repl_url += '\"'; - log << log1 << "zamiana: |" << look_for_url << "|, na: |" << repl_url << "|" << logend << logsave; - ReplaceString(buf, look_for_url, repl_url); - - - Convert(message_work.src_dir, look_for_url); - repl_url = '/'; - log << log1 << "zamiana: |" << look_for_url << "|, na: |" << repl_url << "|" << logend << logsave; - ReplaceString(buf, look_for_url, repl_url); - - NoLastSlash(look_for_url); - look_for_url += '\"'; - repl_url = "/\""; - log << log1 << "zamiana: |" << look_for_url << "|, na: |" << repl_url << "|" << logend << logsave; - ReplaceString(buf, look_for_url, repl_url); - - - - - - - - - - Unlock(); -} - - - - -void ExportThread::ChangeAdressesThumb(std::string & buf) -{ -size_t i; - - CreateBaseUrl(look_for_url); - Convert(message_work.src_dir, look_for_url, false); - - for(i=0 ; i' ||buf[i] == '<' ) { return false; @@ -501,5 +412,151 @@ return false; +// second thread +// objects locked +void ExportThread::ChangeAdressesThumb(std::string & buf, const char * http_prefix) +{ + look_for_url = http_prefix; + Convert(base_url, look_for_url, false); + Convert(message_work.src_dir, look_for_url, false); + + for(size_t i=0 ; i / + Convert(message_work.src_dir, look_for_url); + repl_url = '/'; + ChangeLogStrings(); + ReplaceString(buf, look_for_url, repl_url); + + // changing: + // /sitename" -> /" + NoLastSlash(look_for_url); + look_for_url += '\"'; + repl_url = "/\""; + ChangeLogStrings(); + ReplaceString(buf, look_for_url, repl_url); + + Unlock(); +} + + +// second thread +// objects not locked +void ExportThread::ChangeAdresses(std::string & buf) +{ + // changing: (http or https) + // http://domain.tld/sitename/[...]/file.jpg/-/thumb -> http://otherdomain.tld/download/[...]/file.jpg + // http://domain.tld/sitename/[...]/file.jpg/download/thumb -> http://otherdomain.tld/download/[...]/file.jpg + ChangeAdressesThumb(buf); + + // changing: (http or https) + // http://domain.tld/static/sitename/ -> http://otherdomain.tld/static/ + ChangeBaseAdress(buf, "/static", "", "/static/"); + + // changing: (http or https) + // http://domain.tld/common/sitename/ -> http://otherdomain.tld/common/ + //ChangeAdresss(buf, "/common", "", "/common/"); + + // changing: (http or https) + // http://domain.tld/sitename/ -> http://otherdomain.tld/ + ChangeBaseAdress(buf, "", "", "/"); + + // changing: + // http://domain.tld/sitename" -> http://otherdomain.tld" + // !! dodac no last slash na zrodle + ChangeBaseAdress(buf, "", "\"", "\"", true); + + // changing: + // /sitename/ -> / + // /sitename" -> /" + ChangeSiteNames(buf); +} + + + + } // namespace diff --git a/plugins/export/exportthread.h b/plugins/export/exportthread.h index 024606d..734d1f7 100755 --- a/plugins/export/exportthread.h +++ b/plugins/export/exportthread.h @@ -72,10 +72,21 @@ private: 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); + void ChangeAdressesThumb(std::string & buf, const char * http_prefix); + void ChangeAdressesThumb(std::string & buf); + void ChangeLogStrings(); + + void ChangeBaseAdress(std::string & buf, + const char * http_prefix, const char * dir_prefix, const char * dir_postfix, + const char * repl_dir_postfix, bool skip_dir_last_slash = false); + void ChangeBaseAdress(std::string & buf, + const char * dir_prefix, const char * dir_postfix, + const char * repl_dir_postfix, bool skip_dir_last_slash = false); + + void ChangeSiteNames(std::string & buf); + }; } // namespace