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
This commit is contained in:
2011-09-13 06:08:34 +00:00
parent 72be443414
commit 39923d6617
58 changed files with 2258 additions and 654 deletions

View File

@@ -11,6 +11,9 @@
#include "core/log.h"
#include "core/plugin.h"
#include "exportthread.h"
#include "exportinfo.h"
#include "db.h"
extern "C" void Init(PluginInfo &);
@@ -25,10 +28,8 @@ namespace Export
const wchar_t plugin_name[] = L"export";
int mount_par_export_conf = -1;
ExportThread export_thread;
Message msg;
Db db;
ExportInfo export_info;
@@ -50,7 +51,20 @@ void FstabChanged(PluginInfo & info)
void InitPlugin(PluginInfo & info)
{
export_thread.SetUTF8(info.config->utf8);
export_thread.SetBaseUrl(info.config->base_url);
info.system->thread_manager.Add(&export_thread);
export_info.ReadExportDirs();
}
void SendDir(PluginInfo & info)
{
const Item * dir = reinterpret_cast<Item*>(info.p1);
if( dir )
export_info.SendDir(*dir);
}
@@ -59,23 +73,84 @@ void SendFile(PluginInfo & info)
{
const Item * item = reinterpret_cast<Item*>(info.p1);
if( !item )
return;
msg.type = WINIX_PL_EXPORT_TYPE_CREATE_FILE;
msg.url = info.config->url_proto;
msg.url += info.config->base_url;
info.system->dirs.MakePath(item->parent_id, msg.url, false);
msg.url += item->url;
msg.path.clear();
log << log1 << "Export: bede sciagal takiego swiniaka: " << msg.url << logend;
export_thread.AddMessage(msg);
if( item )
{
if( item->file_type == WINIX_ITEM_FILETYPE_IMAGE && info.config->image_resize )
{
// there'll be a next message WINIX_IMAGE_RESIZED
log << log4 << "Export: image will be resized, waiting..." << logend;
}
else
{
export_info.SendFile(*item);
export_info.SendDir(item->parent_id);
}
}
}
void SendFileCopied(PluginInfo & info)
{
const Item * item = reinterpret_cast<Item*>(info.p1);
if( item )
{
export_info.SendFile(*item);
if( item->file_type != WINIX_ITEM_FILETYPE_NONE )
export_info.SendFile(*item, true);
export_info.SendDir(item->parent_id);
}
}
void SendFileResized(PluginInfo & info)
{
const Item * item = reinterpret_cast<Item*>(info.p1);
if( item )
{
export_info.SendFile(*item);
export_info.SendDir(item->parent_id);
}
}
void SendFileThumb(PluginInfo & info)
{
const Item * item = reinterpret_cast<Item*>(info.p1);
if( item )
{
export_info.SendFile(*item, true);
export_info.SendDir(item->parent_id);
}
}
void FileRemoved(PluginInfo & info)
{
const Item * item = reinterpret_cast<Item*>(info.p1);
if( item )
{
export_info.SendDir(item->parent_id);
}
}
void ProcessRequest(PluginInfo & info)
{
if( info.cur->request->function == &info.functions->fun_reload )
{
if( info.cur->request->IsParam(L"export") )
export_info.ReadExportDirs();
}
}
void AddEzcFunctions(PluginInfo & info);
@@ -89,16 +164,37 @@ void Init(PluginInfo & info)
{
using namespace Export;
db.SetConn(info.db->GetConn());
db.LogQueries(info.config->log_db_query);
db.SetDirs(&info.system->dirs);
export_info.SetSystem(info.system);
export_info.SetConfig(info.config);
export_info.SetDb(&db);
export_info.SetExportThread(&export_thread);
// plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
plugin.Assign(WINIX_ADD_MOUNTS, AddMountParams);
// plugin.Assign(WINIX_FSTAB_CHANGED, FstabChanged);
plugin.Assign(WINIX_FILE_ADDED, SendFile);
plugin.Assign(WINIX_FILE_CHANGED, SendFile);
plugin.Assign(WINIX_FILE_CHANGED, SendFileResized);
plugin.Assign(WINIX_CREATED_THUMB, SendFileThumb);
plugin.Assign(WINIX_IMAGE_RESIZED, SendFileResized);
plugin.Assign(WINIX_FILE_MOVED, SendFileCopied);
plugin.Assign(WINIX_FILE_COPIED, SendFileCopied);
plugin.Assign(WINIX_DIR_CONTENT_SORTED, SendDir);
plugin.Assign(5000, FileRemoved);
plugin.Assign(WINIX_PROCESS_REQUEST, ProcessRequest);
plugin.Assign(WINIX_PLUGIN_INIT, InitPlugin);
info.p1 = (void*)(plugin_name);
}