diff --git a/plugins/export/Makefile.dep b/plugins/export/Makefile.dep index 32d4cf3..8a37487 100755 --- a/plugins/export/Makefile.dep +++ b/plugins/export/Makefile.dep @@ -80,6 +80,48 @@ exportthread.o: ../../../pikotools/convert/inttostr.h exportthread.o: ../../../pikotools/membuffer/membuffer.h exportthread.o: ../../../pikotools/textstream/types.h exportthread.o: ../../../pikotools/utf8/utf8.h +funexport.o: funexport.h ../../functions/functionbase.h ../../core/item.h +funexport.o: ../../db/db.h ../../db/dbbase.h ../../db/dbitemquery.h +funexport.o: ../../db/dbitemcolumns.h ../../core/user.h +funexport.o: ../../../pikotools/space/space.h +funexport.o: ../../../pikotools/textstream/types.h +funexport.o: ../../../pikotools/date/date.h ../../core/group.h +funexport.o: ../../core/dircontainer.h ../../core/ugcontainer.h +funexport.o: ../../core/log.h ../../core/textstream.h +funexport.o: ../../core/logmanipulators.h +funexport.o: ../../../pikotools/textstream/textstream.h +funexport.o: ../../../pikotools/convert/convert.h +funexport.o: ../../../pikotools/convert/inttostr.h +funexport.o: ../../../pikotools/membuffer/membuffer.h +funexport.o: ../../../pikotools/textstream/types.h ../../core/slog.h +funexport.o: ../../core/cur.h ../../core/request.h ../../core/requesttypes.h +funexport.o: ../../core/item.h ../../core/error.h ../../core/config.h +funexport.o: ../../../pikotools/space/spaceparser.h +funexport.o: ../../../pikotools/space/space.h ../../core/htmlfilter.h +funexport.o: ../../templates/htmltextstream.h ../../core/textstream.h +funexport.o: ../../core/misc.h ../../../pikotools/utf8/utf8.h +funexport.o: ../../core/session.h ../../core/user.h ../../core/plugindata.h +funexport.o: ../../core/rebus.h ../../core/mount.h ../../templates/locale.h +funexport.o: ../../core/request.h ../../core/config.h ../../core/system.h +funexport.o: ../../core/job.h ../../core/basethread.h ../../core/synchro.h +funexport.o: ../../core/dirs.h ../../core/dircontainer.h +funexport.o: ../../notify/notify.h ../../notify/notifypool.h +funexport.o: ../../templates/patterns.h ../../templates/locale.h +funexport.o: ../../templates/localefilter.h ../../../ezc/src/ezc.h +funexport.o: ../../../ezc/src/generator.h ../../../ezc/src/pattern.h +funexport.o: ../../../ezc/src/functions.h ../../../ezc/src/funinfo.h +funexport.o: ../../../ezc/src/stringconv.h ../../notify/notifythread.h +funexport.o: ../../core/basethread.h ../../notify/templatesnotify.h +funexport.o: ../../core/users.h ../../core/ugcontainer.h +funexport.o: ../../core/lastcontainer.h ../../core/mounts.h +funexport.o: ../../core/mountparser.h ../../core/crypt.h ../../core/run.h +funexport.o: ../../core/users.h ../../core/groups.h ../../core/group.h +funexport.o: ../../core/loadavg.h ../../core/image.h +funexport.o: ../../core/threadmanager.h ../../core/timezones.h +funexport.o: ../../core/timezone.h ../../core/synchro.h exportinfo.h export.h +funexport.o: edb.h ../../db/dbbase.h ../../db/dbconn.h +funexport.o: ../../db/dbtextstream.h ../../core/error.h ../../core/dirs.h +funexport.o: message.h exportthread.h init.o: ../../core/log.h ../../core/plugin.h ../../core/pluginmsg.h init.o: ../../core/log.h ../../core/textstream.h ../../core/logmanipulators.h init.o: ../../../pikotools/textstream/textstream.h @@ -142,3 +184,4 @@ init.o: ../../templates/changepatterns.h ../../templates/htmltextstream.h init.o: ../../core/sessionmanager.h exportthread.h message.h exportinfo.h init.o: export.h edb.h ../../db/dbbase.h ../../db/dbconn.h init.o: ../../db/dbtextstream.h ../../core/error.h ../../core/dirs.h +init.o: funexport.h ../../functions/functionbase.h diff --git a/plugins/export/Makefile.o.dep b/plugins/export/Makefile.o.dep index fab4ae1..49464b5 100755 --- a/plugins/export/Makefile.o.dep +++ b/plugins/export/Makefile.o.dep @@ -1 +1 @@ -o = edb.o exportinfo.o exportthread.o init.o +o = edb.o exportinfo.o exportthread.o funexport.o init.o diff --git a/plugins/export/exportinfo.cpp b/plugins/export/exportinfo.cpp index 442328c..478ee4f 100755 --- a/plugins/export/exportinfo.cpp +++ b/plugins/export/exportinfo.cpp @@ -137,7 +137,7 @@ bool ExportInfo::HasRecurrenceId(long id) } -void ExportInfo::SendFile(const Item & item, bool thumb) +void ExportInfo::SendFile(const Item & item, bool thumb, bool put_to_recurrence_tab) { ExportDir * exp_dir = FindDir(item.parent_id); @@ -150,7 +150,8 @@ void ExportInfo::SendFile(const Item & item, bool thumb) return; } - recurrence_check.push_back(item.id); + if( put_to_recurrence_tab ) + recurrence_check.push_back(item.id); msg.Clear(); system->dirs.MakePath(item.parent_id, msg.path); diff --git a/plugins/export/exportinfo.h b/plugins/export/exportinfo.h index d7d4701..0a69a49 100755 --- a/plugins/export/exportinfo.h +++ b/plugins/export/exportinfo.h @@ -42,7 +42,7 @@ public: bool DecodePass(Export & exp); - void SendFile(const Item & item, bool thumb = false); + void SendFile(const Item & item, bool thumb = false, bool put_to_recurrence_tab = true); void SendDir(const Item & item); void SendDir(long dir_id); void SendAllFilesFromDir(long dir_id); diff --git a/plugins/export/funexport.cpp b/plugins/export/funexport.cpp new file mode 100755 index 0000000..b00ff63 --- /dev/null +++ b/plugins/export/funexport.cpp @@ -0,0 +1,114 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2012, Tomasz Sowa + * All rights reserved. + * + */ + + +#include "funexport.h" + + + + +namespace Export +{ + + +FunExport::FunExport() +{ + fun.url = L"export"; +} + + +void FunExport::SetExportInfo(ExportInfo * pexport_info) +{ + export_info = pexport_info; +} + + +bool FunExport::HasAccess() +{ + // temporarily only the root can use this function + return cur->session->puser && cur->session->puser->super_user; +} + + +void FunExport::ExportFile(const Item & item) +{ + log << log4 << "Export: exporting file: url: " << item.url << ", id: " << item.id << logend; + + if( item.file_type == WINIX_ITEM_FILETYPE_NONE ) + { + export_info->SendFile(item, false, true); + } + else + { + export_info->SendFile(item, false, false); + export_info->SendFile(item, true, true); + } +} + + +void FunExport::ExportDir(const Item & dir) +{ + log << log4 << "Export: exporting directory: url: " << dir.url << ", id: " << dir.id << logend; + + 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 ; idirs.FindFirstChild(dir.id); + + for( ; i != system->dirs.ParentEnd() ; i = system->dirs.NextChild(i) ) + { + ExportDir(*i->second); + } +} + + +void FunExport::Export() +{ + export_info->ResetRecurrenceCheck(); + + if( cur->request->is_item ) + ExportFile(cur->request->item); + else + ExportDir(*cur->request->dir_tab.back()); +} + + + +void FunExport::MakePost() +{ + Export(); +} + + +void FunExport::MakeGet() +{ +// if( cur->request->IsParam(L"noconfirm") ) +// Export(); +} + + + + + +} // namespace + + diff --git a/plugins/export/funexport.h b/plugins/export/funexport.h new file mode 100755 index 0000000..97ad99c --- /dev/null +++ b/plugins/export/funexport.h @@ -0,0 +1,54 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2012, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfile_winix_plugins_export_funexport +#define headerfile_winix_plugins_export_funexport + +#include "functions/functionbase.h" +#include "db/db.h" +#include "exportinfo.h" + + +namespace Export +{ + + +class FunExport : public FunctionBase +{ +public: + + FunExport(); + void SetExportInfo(ExportInfo * pexport_info); + + bool HasAccess(); + + void MakePost(); + void MakeGet(); + + + void ExportFile(const Item & item); + void ExportDir(const Item & dir); + +private: + + ExportInfo * export_info; + DbItemQuery iq_dir; + std::vector dir_items; + + void Export(); + + +}; + + + +} // namespace + +#endif + diff --git a/plugins/export/init.cpp b/plugins/export/init.cpp index fe28fb1..97df046 100755 --- a/plugins/export/init.cpp +++ b/plugins/export/init.cpp @@ -13,6 +13,7 @@ #include "exportthread.h" #include "exportinfo.h" #include "edb.h" +#include "funexport.h" @@ -30,9 +31,16 @@ int mount_par_export_conf = -1; ExportThread export_thread; EDb edb; ExportInfo export_info; +FunExport fun_export; +void AddWinixFunctions(PluginInfo & info) +{ + info.functions->Add(fun_export); +} + + void AddMountParams(PluginInfo & info) { using TemplatesFunctions::system; @@ -226,11 +234,13 @@ using namespace Export; export_info.SetDb(info.db); export_info.SetExportThread(&export_thread); + fun_export.SetExportInfo(&export_info); + // plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions); plugin.Assign(WINIX_ADD_MOUNTS, AddMountParams); // plugin.Assign(WINIX_FSTAB_CHANGED, FstabChanged); - + plugin.Assign(WINIX_CREATE_FUNCTIONS, AddWinixFunctions); plugin.Assign(WINIX_FILE_ADDED, SendFileAdded); plugin.Assign(WINIX_FILE_CHANGED, SendFileChanged);