changed: plugin messages:
WINIX_FILE_REMOVED and WINIX_DIR_PREPARE_TO_REMOVE
now as a parameter we have a pointer to the Item struct
changed: export plugin now exports all files from a directory
(in the future there'll be an option how the plugin should behave)
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@772 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
db.o: db.h ../../db/dbbase.h ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
db.o: ../../core/textstream.h ../../core/misc.h ../../core/item.h
|
||||
db.o: ../../core/requesttypes.h ../../core/error.h export.h ../../core/dirs.h
|
||||
db.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
|
||||
db.o: ../../db/dbitemquery.h ../../core/item.h ../../db/dbitemcolumns.h
|
||||
db.o: ../../core/user.h ../../core/group.h ../../core/dircontainer.h
|
||||
db.o: ../../core/ugcontainer.h ../../core/log.h ../../core/textstream.h
|
||||
db.o: ../../core/logmanipulators.h ../../core/slog.h ../../core/cur.h
|
||||
db.o: ../../core/request.h ../../core/error.h ../../core/config.h
|
||||
db.o: ../../core/confparser.h ../../core/htmlfilter.h
|
||||
db.o: ../../templates/htmltextstream.h ../../core/session.h ../../core/user.h
|
||||
db.o: ../../core/plugindata.h ../../core/rebus.h ../../core/mount.h
|
||||
db.o: ../../templates/locale.h ../../core/confparser.h ../../notify/notify.h
|
||||
db.o: ../../notify/notifypool.h ../../templates/patterns.h
|
||||
db.o: ../../templates/locale.h ../../templates/localefilter.h
|
||||
db.o: ../../../ezc/src/ezc.h ../../../ezc/src/utf8.h
|
||||
db.o: ../../../ezc/src/generator.h ../../../ezc/src/pattern.h
|
||||
db.o: ../../../ezc/src/functions.h ../../../ezc/src/funinfo.h
|
||||
db.o: ../../../ezc/src/stringconv.h ../../notify/notifythread.h
|
||||
db.o: ../../core/basethread.h ../../core/synchro.h
|
||||
db.o: ../../notify/templatesnotify.h ../../core/config.h ../../core/users.h
|
||||
db.o: ../../core/ugcontainer.h ../../core/lastcontainer.h
|
||||
db.o: ../../templates/misc.h ../../templates/htmltextstream.h
|
||||
db.o: ../../core/log.h
|
||||
edb.o: edb.h ../../db/dbbase.h ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
edb.o: ../../core/textstream.h ../../core/misc.h ../../core/item.h
|
||||
edb.o: ../../core/requesttypes.h ../../core/error.h export.h
|
||||
edb.o: ../../core/dirs.h ../../core/dircontainer.h ../../db/db.h
|
||||
edb.o: ../../db/dbbase.h ../../db/dbitemquery.h ../../core/item.h
|
||||
edb.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
|
||||
edb.o: ../../core/dircontainer.h ../../core/ugcontainer.h ../../core/log.h
|
||||
edb.o: ../../core/textstream.h ../../core/logmanipulators.h ../../core/slog.h
|
||||
edb.o: ../../core/cur.h ../../core/request.h ../../core/error.h
|
||||
edb.o: ../../core/config.h ../../core/confparser.h ../../core/htmlfilter.h
|
||||
edb.o: ../../templates/htmltextstream.h ../../core/session.h
|
||||
edb.o: ../../core/user.h ../../core/plugindata.h ../../core/rebus.h
|
||||
edb.o: ../../core/mount.h ../../templates/locale.h ../../core/confparser.h
|
||||
edb.o: ../../notify/notify.h ../../notify/notifypool.h
|
||||
edb.o: ../../templates/patterns.h ../../templates/locale.h
|
||||
edb.o: ../../templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
edb.o: ../../../ezc/src/utf8.h ../../../ezc/src/generator.h
|
||||
edb.o: ../../../ezc/src/pattern.h ../../../ezc/src/functions.h
|
||||
edb.o: ../../../ezc/src/funinfo.h ../../../ezc/src/stringconv.h
|
||||
edb.o: ../../notify/notifythread.h ../../core/basethread.h
|
||||
edb.o: ../../core/synchro.h ../../notify/templatesnotify.h
|
||||
edb.o: ../../core/config.h ../../core/users.h ../../core/ugcontainer.h
|
||||
edb.o: ../../core/lastcontainer.h ../../templates/misc.h
|
||||
edb.o: ../../templates/htmltextstream.h ../../core/log.h
|
||||
exportinfo.o: ../../core/log.h exportinfo.h ../../core/system.h
|
||||
exportinfo.o: ../../core/dirs.h ../../core/item.h ../../core/dircontainer.h
|
||||
exportinfo.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h
|
||||
@@ -53,7 +53,7 @@ exportinfo.o: ../../templates/htmltextstream.h ../../core/mounts.h
|
||||
exportinfo.o: ../../core/mountparser.h ../../core/crypt.h ../../core/run.h
|
||||
exportinfo.o: ../../core/users.h ../../core/groups.h ../../core/group.h
|
||||
exportinfo.o: ../../core/loadavg.h ../../core/image.h ../../core/basethread.h
|
||||
exportinfo.o: ../../core/threadmanager.h export.h db.h ../../db/dbbase.h
|
||||
exportinfo.o: ../../core/threadmanager.h export.h edb.h ../../db/dbbase.h
|
||||
exportinfo.o: ../../db/dbconn.h ../../db/dbtextstream.h ../../core/error.h
|
||||
exportinfo.o: ../../core/dirs.h message.h exportthread.h
|
||||
exportthread.o: exportthread.h ../../core/basethread.h ../../core/synchro.h
|
||||
@@ -111,6 +111,6 @@ init.o: ../../functions/who.h ../../functions/vim.h ../../core/htmlfilter.h
|
||||
init.o: ../../templates/templates.h ../../templates/patterncacher.h
|
||||
init.o: ../../templates/indexpatterns.h ../../templates/patterns.h
|
||||
init.o: ../../templates/changepatterns.h ../../core/sessionmanager.h
|
||||
init.o: exportthread.h message.h exportinfo.h export.h db.h ../../db/dbbase.h
|
||||
init.o: ../../db/dbconn.h ../../db/dbtextstream.h ../../core/error.h
|
||||
init.o: ../../core/dirs.h
|
||||
init.o: exportthread.h message.h exportinfo.h export.h edb.h
|
||||
init.o: ../../db/dbbase.h ../../db/dbconn.h ../../db/dbtextstream.h
|
||||
init.o: ../../core/error.h ../../core/dirs.h
|
||||
|
||||
@@ -1 +1 @@
|
||||
o = db.o exportinfo.o exportthread.o init.o
|
||||
o = edb.o exportinfo.o exportthread.o init.o
|
||||
|
||||
@@ -7,21 +7,21 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "db.h"
|
||||
#include "edb.h"
|
||||
#include "core/log.h"
|
||||
|
||||
|
||||
namespace Export
|
||||
{
|
||||
|
||||
void Db::SetDirs(Dirs * pdirs)
|
||||
void EDb::SetDirs(Dirs * pdirs)
|
||||
{
|
||||
dirs = pdirs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Db::SetExportCols(PGresult * r)
|
||||
void EDb::SetExportCols(PGresult * r)
|
||||
{
|
||||
cid = AssertColumn(r, "id");
|
||||
cuser_id = AssertColumn(r, "user_id");
|
||||
@@ -40,7 +40,7 @@ void Db::SetExportCols(PGresult * r)
|
||||
}
|
||||
|
||||
|
||||
void Db::SetExportValues(PGresult * r, int row, Export & exp)
|
||||
void EDb::SetExportValues(PGresult * r, int row, Export & exp)
|
||||
{
|
||||
exp.Clear();
|
||||
|
||||
@@ -65,7 +65,7 @@ void Db::SetExportValues(PGresult * r, int row, Export & exp)
|
||||
|
||||
|
||||
|
||||
bool Db::GetExport(long user_id, std::vector<Export> & export_tab, bool clear_tab)
|
||||
bool EDb::GetExport(long user_id, std::vector<Export> & export_tab, bool clear_tab)
|
||||
{
|
||||
if( clear_tab )
|
||||
export_tab.clear();
|
||||
@@ -106,7 +106,7 @@ return result;
|
||||
|
||||
|
||||
|
||||
bool Db::GetExport(long id, Export & exp)
|
||||
bool EDb::GetExport(long id, Export & exp)
|
||||
{
|
||||
exp.Clear();
|
||||
PGresult * r = 0;
|
||||
@@ -142,7 +142,7 @@ return result;
|
||||
|
||||
|
||||
|
||||
bool Db::GetExportDirs(std::vector<ExportDir> & export_tab, bool clear_tab)
|
||||
bool EDb::GetExportDirs(std::vector<ExportDir> & export_tab, bool clear_tab)
|
||||
{
|
||||
if( clear_tab )
|
||||
export_tab.clear();
|
||||
@@ -7,8 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_export_db
|
||||
#define headerfile_winix_plugins_export_db
|
||||
#ifndef headerfile_winix_plugins_export_edb
|
||||
#define headerfile_winix_plugins_export_edb
|
||||
|
||||
#include <vector>
|
||||
#include "db/dbbase.h"
|
||||
@@ -22,7 +22,7 @@ namespace Export
|
||||
|
||||
|
||||
|
||||
class Db : public DbBase
|
||||
class EDb : public DbBase
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -35,6 +35,12 @@ void ExportInfo::SetConfig(Config * pconfig)
|
||||
}
|
||||
|
||||
|
||||
void ExportInfo::SetEDb(EDb * pdb)
|
||||
{
|
||||
edb = pdb;
|
||||
}
|
||||
|
||||
|
||||
void ExportInfo::SetDb(Db * pdb)
|
||||
{
|
||||
db = pdb;
|
||||
@@ -50,7 +56,7 @@ void ExportInfo::SetExportThread(ExportThread * pexport_thread)
|
||||
|
||||
void ExportInfo::ReadExportDirs()
|
||||
{
|
||||
db->GetExportDirs(export_dirs);
|
||||
edb->GetExportDirs(export_dirs);
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +157,7 @@ void ExportInfo::SendFile(const Item & item, bool thumb)
|
||||
|
||||
msg.errors = 0;
|
||||
|
||||
if( SkipDir(exp_dir->dir_id, msg.path) && db->GetExport(exp_dir->id, exp) )
|
||||
if( SkipDir(exp_dir->dir_id, msg.path) && edb->GetExport(exp_dir->id, exp) )
|
||||
{
|
||||
if( DecodePass(exp) )
|
||||
{
|
||||
@@ -195,7 +201,7 @@ void ExportInfo::SendDir(const Item & item)
|
||||
|
||||
msg.errors = 0;
|
||||
|
||||
if( SkipDir(exp_dir->dir_id, msg.path) && db->GetExport(exp_dir->id, exp) )
|
||||
if( SkipDir(exp_dir->dir_id, msg.path) && edb->GetExport(exp_dir->id, exp) )
|
||||
{
|
||||
if( DecodePass(exp) )
|
||||
{
|
||||
@@ -228,6 +234,25 @@ void ExportInfo::SendDir(long dir_id)
|
||||
}
|
||||
|
||||
|
||||
// send all non-static files from a directory
|
||||
void ExportInfo::SendAllFilesFromDir(long dir_id)
|
||||
{
|
||||
iq_dir.SetAll(false, false);
|
||||
iq_dir.sel_parent_id = true;
|
||||
iq_dir.sel_url = true;
|
||||
iq_dir.sel_file = true;
|
||||
iq_dir.WhereParentId(dir_id);
|
||||
iq_dir.WhereType(Item::file);
|
||||
iq_dir.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
|
||||
|
||||
db->GetItems(dir_items, iq_dir);
|
||||
|
||||
for(size_t i=0 ; i<dir_items.size() ; ++i)
|
||||
{
|
||||
SendFile(dir_items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
#define headerfile_winix_plugins_export_exportinfo
|
||||
|
||||
#include "core/system.h"
|
||||
#include "db/db.h"
|
||||
#include "export.h"
|
||||
#include "db.h"
|
||||
#include "edb.h"
|
||||
#include "message.h"
|
||||
#include "exportthread.h"
|
||||
|
||||
@@ -30,6 +31,7 @@ public:
|
||||
|
||||
void SetSystem(System * psystem);
|
||||
void SetConfig(Config * pconfig);
|
||||
void SetEDb(EDb * pdb);
|
||||
void SetDb(Db * pdb);
|
||||
void SetExportThread(ExportThread * pexport_thread);
|
||||
|
||||
@@ -43,11 +45,13 @@ public:
|
||||
void SendFile(const Item & item, bool thumb = false);
|
||||
void SendDir(const Item & item);
|
||||
void SendDir(long dir_id);
|
||||
void SendAllFilesFromDir(long dir_id);
|
||||
|
||||
private:
|
||||
|
||||
System * system;
|
||||
Config * config;
|
||||
EDb * edb;
|
||||
Db * db;
|
||||
ExportThread * export_thread;
|
||||
|
||||
@@ -58,6 +62,8 @@ private:
|
||||
Export exp;
|
||||
std::wstring tmp_dir;
|
||||
std::vector<ExportDir> export_dirs;
|
||||
DbItemQuery iq_dir;
|
||||
std::vector<Item> dir_items;
|
||||
|
||||
bool SkipDir(long dir_id, std::wstring & dir);
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ bool end;
|
||||
end = true;
|
||||
}
|
||||
|
||||
WaitForSignalSleep(5);
|
||||
WaitForSignalSleep(1);
|
||||
Unlock();
|
||||
}
|
||||
while( !end && !IsExitSignal() );
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "core/plugin.h"
|
||||
#include "exportthread.h"
|
||||
#include "exportinfo.h"
|
||||
#include "db.h"
|
||||
#include "edb.h"
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Export
|
||||
const wchar_t plugin_name[] = L"export";
|
||||
int mount_par_export_conf = -1;
|
||||
ExportThread export_thread;
|
||||
Db db;
|
||||
EDb edb;
|
||||
ExportInfo export_info;
|
||||
|
||||
|
||||
@@ -64,12 +64,15 @@ void SendDir(PluginInfo & info)
|
||||
const Item * dir = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( dir )
|
||||
{
|
||||
export_info.SendDir(*dir);
|
||||
export_info.SendAllFilesFromDir(dir->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SendFile(PluginInfo & info)
|
||||
void SendFileAdded(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
@@ -84,27 +87,52 @@ void SendFile(PluginInfo & info)
|
||||
{
|
||||
export_info.SendFile(*item);
|
||||
export_info.SendDir(item->parent_id);
|
||||
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
export_info.SendAllFilesFromDir(item->parent_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SendFileChanged(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
{
|
||||
export_info.SendFile(*item);
|
||||
export_info.SendDir(item->parent_id);
|
||||
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
export_info.SendAllFilesFromDir(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);
|
||||
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
{
|
||||
export_info.SendAllFilesFromDir(item->parent_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
export_info.SendFile(*item);
|
||||
export_info.SendFile(*item, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SendFileResized(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
@@ -129,6 +157,18 @@ void SendFileThumb(PluginInfo & info)
|
||||
}
|
||||
|
||||
|
||||
void SendFilePrepareMove(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
{
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
export_info.SendAllFilesFromDir(item->parent_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FileRemoved(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
@@ -136,6 +176,9 @@ void FileRemoved(PluginInfo & info)
|
||||
if( item )
|
||||
{
|
||||
export_info.SendDir(item->parent_id);
|
||||
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
export_info.SendAllFilesFromDir(item->parent_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,12 +207,13 @@ void Init(PluginInfo & info)
|
||||
{
|
||||
using namespace Export;
|
||||
|
||||
db.SetConn(info.db->GetConn());
|
||||
db.LogQueries(info.config->log_db_query);
|
||||
db.SetDirs(&info.system->dirs);
|
||||
edb.SetConn(info.db->GetConn());
|
||||
edb.LogQueries(info.config->log_db_query);
|
||||
edb.SetDirs(&info.system->dirs);
|
||||
export_info.SetSystem(info.system);
|
||||
export_info.SetConfig(info.config);
|
||||
export_info.SetDb(&db);
|
||||
export_info.SetEDb(&edb);
|
||||
export_info.SetDb(info.db);
|
||||
export_info.SetExportThread(&export_thread);
|
||||
|
||||
|
||||
@@ -178,15 +222,17 @@ using namespace Export;
|
||||
// plugin.Assign(WINIX_FSTAB_CHANGED, FstabChanged);
|
||||
|
||||
|
||||
plugin.Assign(WINIX_FILE_ADDED, SendFile);
|
||||
plugin.Assign(WINIX_FILE_CHANGED, SendFileResized);
|
||||
plugin.Assign(WINIX_FILE_ADDED, SendFileAdded);
|
||||
plugin.Assign(WINIX_FILE_CHANGED, SendFileChanged);
|
||||
plugin.Assign(WINIX_CREATED_THUMB, SendFileThumb);
|
||||
plugin.Assign(WINIX_IMAGE_RESIZED, SendFileResized);
|
||||
|
||||
plugin.Assign(WINIX_FILE_PREPARE_TO_MOVE, SendFilePrepareMove);
|
||||
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_FILE_REMOVED, FileRemoved);
|
||||
|
||||
plugin.Assign(WINIX_PROCESS_REQUEST, ProcessRequest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user