moved winix directories to winixdsubdirectory
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1028 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
30
winixd/plugins/export/Makefile
Normal file
30
winixd/plugins/export/Makefile
Normal file
@@ -0,0 +1,30 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
name = export.so
|
||||
|
||||
|
||||
all: $(name)
|
||||
|
||||
|
||||
# -lcurl is used when linking the main winix.so so we don't have to use it here
|
||||
$(name): $(o)
|
||||
$(CXX) -shared -Wl,-soname,$(name) -o $(name) $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) $(LDFLAGS) *.o
|
||||
|
||||
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) $<
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
makedepend -Y. $(CXXWINIXINCLUDEFLAGS) -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f *.so
|
||||
rm -f $(name)
|
||||
|
||||
include Makefile.dep
|
264
winixd/plugins/export/Makefile.dep
Normal file
264
winixd/plugins/export/Makefile.dep
Normal file
@@ -0,0 +1,264 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
edb.o: edb.h ../../../winix/db/dbbase.h ../../../winix/db/dbconn.h
|
||||
edb.o: ../../../winix/db/dbtextstream.h ../../../winix/core/textstream.h
|
||||
edb.o: ../../../winix/core/misc.h ../../../winix/core/item.h
|
||||
edb.o: ../../../pikotools/space/space.h ../../../pikotools/textstream/types.h
|
||||
edb.o: ../../../pikotools/date/date.h ../../../winix/core/requesttypes.h
|
||||
edb.o: ../../../pikotools/textstream/textstream.h
|
||||
edb.o: ../../../pikotools/convert/convert.h
|
||||
edb.o: ../../../pikotools/convert/inttostr.h
|
||||
edb.o: ../../../pikotools/membuffer/membuffer.h
|
||||
edb.o: ../../../pikotools/textstream/types.h ../../../pikotools/utf8/utf8.h
|
||||
edb.o: ../../../winix/core/winix_const.h ../../../winix/core/error.h
|
||||
edb.o: ../../../pikotools/space/spaceparser.h
|
||||
edb.o: ../../../pikotools/space/space.h export.h ../../../winix/core/dirs.h
|
||||
edb.o: ../../../winix/core/dircontainer.h ../../../winix/db/db.h
|
||||
edb.o: ../../../winix/db/dbbase.h ../../../winix/db/dbitemquery.h
|
||||
edb.o: ../../../winix/core/item.h ../../../winix/db/dbitemcolumns.h
|
||||
edb.o: ../../../winix/core/user.h ../../../winix/core/group.h
|
||||
edb.o: ../../../winix/core/dircontainer.h ../../../winix/core/ugcontainer.h
|
||||
edb.o: ../../../winix/core/log.h ../../../winix/core/textstream.h
|
||||
edb.o: ../../../winix/core/logmanipulators.h ../../../winix/core/slog.h
|
||||
edb.o: ../../../winix/core/cur.h ../../../winix/core/request.h
|
||||
edb.o: ../../../winix/core/error.h ../../../winix/core/config.h
|
||||
edb.o: ../../../winix/core/htmlfilter.h
|
||||
edb.o: ../../../winix/templates/htmltextstream.h
|
||||
edb.o: ../../../pikotools/space/spacetojson.h ../../../ezc/src/outstreams.h
|
||||
edb.o: ../../../winix/core/session.h ../../../winix/core/user.h
|
||||
edb.o: ../../../winix/core/plugindata.h ../../../winix/core/rebus.h
|
||||
edb.o: ../../../winix/core/ipban.h ../../../winix/core/mount.h
|
||||
edb.o: ../../../winix/templates/locale.h ../../../winix/notify/notify.h
|
||||
edb.o: ../../../winix/notify/notifypool.h ../../../winix/templates/patterns.h
|
||||
edb.o: ../../../winix/templates/locale.h
|
||||
edb.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
edb.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
|
||||
edb.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
|
||||
edb.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
|
||||
edb.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
|
||||
edb.o: ../../../winix/notify/notifythread.h ../../../winix/core/basethread.h
|
||||
edb.o: ../../../winix/core/synchro.h ../../../winix/notify/templatesnotify.h
|
||||
edb.o: ../../../winix/core/config.h ../../../winix/core/users.h
|
||||
edb.o: ../../../winix/core/ugcontainer.h ../../../winix/core/lastcontainer.h
|
||||
edb.o: ../../../winix/core/log.h
|
||||
exportinfo.o: ../../../winix/core/log.h exportinfo.h
|
||||
exportinfo.o: ../../../winix/core/system.h ../../../winix/core/job.h
|
||||
exportinfo.o: ../../../winix/core/basethread.h ../../../winix/core/synchro.h
|
||||
exportinfo.o: ../../../pikotools/space/space.h
|
||||
exportinfo.o: ../../../pikotools/textstream/types.h
|
||||
exportinfo.o: ../../../winix/core/dirs.h ../../../winix/core/item.h
|
||||
exportinfo.o: ../../../pikotools/date/date.h
|
||||
exportinfo.o: ../../../winix/core/dircontainer.h ../../../winix/db/db.h
|
||||
exportinfo.o: ../../../winix/db/dbbase.h ../../../winix/db/dbitemquery.h
|
||||
exportinfo.o: ../../../winix/core/item.h ../../../winix/db/dbitemcolumns.h
|
||||
exportinfo.o: ../../../winix/core/user.h ../../../winix/core/group.h
|
||||
exportinfo.o: ../../../winix/core/dircontainer.h
|
||||
exportinfo.o: ../../../winix/core/ugcontainer.h ../../../winix/core/log.h
|
||||
exportinfo.o: ../../../winix/core/textstream.h
|
||||
exportinfo.o: ../../../winix/core/logmanipulators.h
|
||||
exportinfo.o: ../../../pikotools/textstream/textstream.h
|
||||
exportinfo.o: ../../../pikotools/convert/convert.h
|
||||
exportinfo.o: ../../../pikotools/convert/inttostr.h
|
||||
exportinfo.o: ../../../pikotools/membuffer/membuffer.h
|
||||
exportinfo.o: ../../../pikotools/textstream/types.h
|
||||
exportinfo.o: ../../../winix/core/slog.h ../../../winix/core/cur.h
|
||||
exportinfo.o: ../../../winix/core/request.h
|
||||
exportinfo.o: ../../../winix/core/requesttypes.h ../../../winix/core/error.h
|
||||
exportinfo.o: ../../../winix/core/config.h
|
||||
exportinfo.o: ../../../pikotools/space/spaceparser.h
|
||||
exportinfo.o: ../../../pikotools/space/space.h
|
||||
exportinfo.o: ../../../winix/core/htmlfilter.h
|
||||
exportinfo.o: ../../../winix/templates/htmltextstream.h
|
||||
exportinfo.o: ../../../winix/core/textstream.h ../../../winix/core/misc.h
|
||||
exportinfo.o: ../../../pikotools/utf8/utf8.h
|
||||
exportinfo.o: ../../../winix/core/winix_const.h
|
||||
exportinfo.o: ../../../pikotools/space/spacetojson.h
|
||||
exportinfo.o: ../../../ezc/src/outstreams.h ../../../winix/core/session.h
|
||||
exportinfo.o: ../../../winix/core/user.h ../../../winix/core/plugindata.h
|
||||
exportinfo.o: ../../../winix/core/rebus.h ../../../winix/core/ipban.h
|
||||
exportinfo.o: ../../../winix/core/mount.h ../../../winix/templates/locale.h
|
||||
exportinfo.o: ../../../winix/notify/notify.h
|
||||
exportinfo.o: ../../../winix/notify/notifypool.h
|
||||
exportinfo.o: ../../../winix/templates/patterns.h
|
||||
exportinfo.o: ../../../winix/templates/locale.h
|
||||
exportinfo.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
exportinfo.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
|
||||
exportinfo.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
|
||||
exportinfo.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
|
||||
exportinfo.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
|
||||
exportinfo.o: ../../../winix/notify/notifythread.h
|
||||
exportinfo.o: ../../../winix/core/basethread.h
|
||||
exportinfo.o: ../../../winix/notify/templatesnotify.h
|
||||
exportinfo.o: ../../../winix/core/config.h ../../../winix/core/users.h
|
||||
exportinfo.o: ../../../winix/core/ugcontainer.h
|
||||
exportinfo.o: ../../../winix/core/lastcontainer.h
|
||||
exportinfo.o: ../../../winix/core/mounts.h ../../../winix/core/mountparser.h
|
||||
exportinfo.o: ../../../winix/core/crypt.h ../../../winix/core/run.h
|
||||
exportinfo.o: ../../../winix/core/users.h ../../../winix/core/groups.h
|
||||
exportinfo.o: ../../../winix/core/group.h ../../../winix/core/loadavg.h
|
||||
exportinfo.o: ../../../winix/core/image.h ../../../winix/core/threadmanager.h
|
||||
exportinfo.o: ../../../winix/core/timezones.h ../../../winix/core/timezone.h
|
||||
exportinfo.o: export.h edb.h ../../../winix/db/dbbase.h
|
||||
exportinfo.o: ../../../winix/db/dbconn.h ../../../winix/db/dbtextstream.h
|
||||
exportinfo.o: ../../../winix/core/error.h ../../../winix/core/dirs.h
|
||||
exportinfo.o: message.h exportthread.h
|
||||
exportthread.o: exportthread.h ../../../winix/core/basethread.h
|
||||
exportthread.o: ../../../winix/core/synchro.h message.h
|
||||
exportthread.o: ../../../winix/core/log.h ../../../winix/core/misc.h
|
||||
exportthread.o: ../../../winix/core/item.h ../../../pikotools/space/space.h
|
||||
exportthread.o: ../../../pikotools/textstream/types.h
|
||||
exportthread.o: ../../../pikotools/date/date.h
|
||||
exportthread.o: ../../../winix/core/requesttypes.h
|
||||
exportthread.o: ../../../pikotools/textstream/textstream.h
|
||||
exportthread.o: ../../../pikotools/convert/convert.h
|
||||
exportthread.o: ../../../pikotools/convert/inttostr.h
|
||||
exportthread.o: ../../../pikotools/membuffer/membuffer.h
|
||||
exportthread.o: ../../../pikotools/textstream/types.h
|
||||
exportthread.o: ../../../pikotools/utf8/utf8.h
|
||||
exportthread.o: ../../../winix/core/winix_const.h
|
||||
funexport.o: funexport.h ../../../winix/functions/functionbase.h
|
||||
funexport.o: ../../../winix/core/item.h ../../../winix/db/db.h
|
||||
funexport.o: ../../../winix/db/dbbase.h ../../../winix/db/dbitemquery.h
|
||||
funexport.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
|
||||
funexport.o: ../../../pikotools/space/space.h
|
||||
funexport.o: ../../../pikotools/textstream/types.h
|
||||
funexport.o: ../../../pikotools/date/date.h ../../../winix/core/group.h
|
||||
funexport.o: ../../../winix/core/dircontainer.h
|
||||
funexport.o: ../../../winix/core/ugcontainer.h ../../../winix/core/log.h
|
||||
funexport.o: ../../../winix/core/textstream.h
|
||||
funexport.o: ../../../winix/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 ../../../winix/core/slog.h
|
||||
funexport.o: ../../../winix/core/cur.h ../../../winix/core/request.h
|
||||
funexport.o: ../../../winix/core/requesttypes.h ../../../winix/core/item.h
|
||||
funexport.o: ../../../winix/core/error.h ../../../winix/core/config.h
|
||||
funexport.o: ../../../pikotools/space/spaceparser.h
|
||||
funexport.o: ../../../pikotools/space/space.h
|
||||
funexport.o: ../../../winix/core/htmlfilter.h
|
||||
funexport.o: ../../../winix/templates/htmltextstream.h
|
||||
funexport.o: ../../../winix/core/textstream.h ../../../winix/core/misc.h
|
||||
funexport.o: ../../../pikotools/utf8/utf8.h ../../../winix/core/winix_const.h
|
||||
funexport.o: ../../../pikotools/space/spacetojson.h
|
||||
funexport.o: ../../../ezc/src/outstreams.h ../../../winix/core/session.h
|
||||
funexport.o: ../../../winix/core/user.h ../../../winix/core/plugindata.h
|
||||
funexport.o: ../../../winix/core/rebus.h ../../../winix/core/ipban.h
|
||||
funexport.o: ../../../winix/core/mount.h ../../../winix/templates/locale.h
|
||||
funexport.o: ../../../winix/core/request.h ../../../winix/core/config.h
|
||||
funexport.o: ../../../winix/core/system.h ../../../winix/core/job.h
|
||||
funexport.o: ../../../winix/core/basethread.h ../../../winix/core/synchro.h
|
||||
funexport.o: ../../../winix/core/dirs.h ../../../winix/core/dircontainer.h
|
||||
funexport.o: ../../../winix/notify/notify.h
|
||||
funexport.o: ../../../winix/notify/notifypool.h
|
||||
funexport.o: ../../../winix/templates/patterns.h
|
||||
funexport.o: ../../../winix/templates/locale.h
|
||||
funexport.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
funexport.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
|
||||
funexport.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
|
||||
funexport.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
|
||||
funexport.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
|
||||
funexport.o: ../../../winix/notify/notifythread.h
|
||||
funexport.o: ../../../winix/core/basethread.h
|
||||
funexport.o: ../../../winix/notify/templatesnotify.h
|
||||
funexport.o: ../../../winix/core/users.h ../../../winix/core/ugcontainer.h
|
||||
funexport.o: ../../../winix/core/lastcontainer.h ../../../winix/core/mounts.h
|
||||
funexport.o: ../../../winix/core/mountparser.h ../../../winix/core/crypt.h
|
||||
funexport.o: ../../../winix/core/run.h ../../../winix/core/users.h
|
||||
funexport.o: ../../../winix/core/groups.h ../../../winix/core/group.h
|
||||
funexport.o: ../../../winix/core/loadavg.h ../../../winix/core/image.h
|
||||
funexport.o: ../../../winix/core/threadmanager.h
|
||||
funexport.o: ../../../winix/core/timezones.h ../../../winix/core/timezone.h
|
||||
funexport.o: ../../../winix/core/synchro.h exportinfo.h export.h edb.h
|
||||
funexport.o: ../../../winix/db/dbbase.h ../../../winix/db/dbconn.h
|
||||
funexport.o: ../../../winix/db/dbtextstream.h ../../../winix/core/error.h
|
||||
funexport.o: ../../../winix/core/dirs.h message.h exportthread.h
|
||||
init.o: ../../../winix/core/log.h ../../../winix/core/plugin.h
|
||||
init.o: ../../../winix/core/pluginmsg.h ../../../winix/core/log.h
|
||||
init.o: ../../../winix/core/textstream.h
|
||||
init.o: ../../../winix/core/logmanipulators.h
|
||||
init.o: ../../../pikotools/textstream/textstream.h
|
||||
init.o: ../../../pikotools/space/space.h
|
||||
init.o: ../../../pikotools/textstream/types.h ../../../pikotools/date/date.h
|
||||
init.o: ../../../pikotools/convert/convert.h
|
||||
init.o: ../../../pikotools/convert/inttostr.h
|
||||
init.o: ../../../pikotools/membuffer/membuffer.h
|
||||
init.o: ../../../pikotools/textstream/types.h ../../../winix/core/slog.h
|
||||
init.o: ../../../winix/core/cur.h ../../../winix/core/request.h
|
||||
init.o: ../../../winix/core/requesttypes.h ../../../winix/core/item.h
|
||||
init.o: ../../../winix/core/error.h ../../../winix/core/config.h
|
||||
init.o: ../../../pikotools/space/spaceparser.h
|
||||
init.o: ../../../pikotools/space/space.h ../../../winix/core/htmlfilter.h
|
||||
init.o: ../../../winix/templates/htmltextstream.h
|
||||
init.o: ../../../winix/core/textstream.h ../../../winix/core/misc.h
|
||||
init.o: ../../../pikotools/utf8/utf8.h ../../../winix/core/winix_const.h
|
||||
init.o: ../../../pikotools/space/spacetojson.h ../../../ezc/src/outstreams.h
|
||||
init.o: ../../../winix/core/session.h ../../../winix/core/user.h
|
||||
init.o: ../../../winix/core/plugindata.h ../../../winix/core/rebus.h
|
||||
init.o: ../../../winix/core/ipban.h ../../../winix/core/mount.h
|
||||
init.o: ../../../winix/templates/locale.h ../../../winix/core/system.h
|
||||
init.o: ../../../winix/core/job.h ../../../winix/core/basethread.h
|
||||
init.o: ../../../winix/core/synchro.h ../../../winix/core/dirs.h
|
||||
init.o: ../../../winix/core/dircontainer.h ../../../winix/db/db.h
|
||||
init.o: ../../../winix/db/dbbase.h ../../../winix/db/dbitemquery.h
|
||||
init.o: ../../../winix/core/item.h ../../../winix/db/dbitemcolumns.h
|
||||
init.o: ../../../winix/core/user.h ../../../winix/core/group.h
|
||||
init.o: ../../../winix/core/dircontainer.h ../../../winix/core/ugcontainer.h
|
||||
init.o: ../../../winix/notify/notify.h ../../../winix/notify/notifypool.h
|
||||
init.o: ../../../winix/templates/patterns.h ../../../winix/templates/locale.h
|
||||
init.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
init.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
|
||||
init.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
|
||||
init.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
|
||||
init.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
|
||||
init.o: ../../../winix/notify/notifythread.h ../../../winix/core/basethread.h
|
||||
init.o: ../../../winix/notify/templatesnotify.h ../../../winix/core/config.h
|
||||
init.o: ../../../winix/core/users.h ../../../winix/core/ugcontainer.h
|
||||
init.o: ../../../winix/core/lastcontainer.h ../../../winix/core/mounts.h
|
||||
init.o: ../../../winix/core/mountparser.h ../../../winix/core/crypt.h
|
||||
init.o: ../../../winix/core/run.h ../../../winix/core/users.h
|
||||
init.o: ../../../winix/core/groups.h ../../../winix/core/group.h
|
||||
init.o: ../../../winix/core/loadavg.h ../../../winix/core/image.h
|
||||
init.o: ../../../winix/core/threadmanager.h ../../../winix/core/timezones.h
|
||||
init.o: ../../../winix/core/timezone.h ../../../winix/core/sessionmanager.h
|
||||
init.o: ../../../winix/core/sessioncontainer.h
|
||||
init.o: ../../../winix/core/ipbancontainer.h
|
||||
init.o: ../../../winix/core/sessionidmanager.h ../../../tito/src/base64.h
|
||||
init.o: ../../../tito/src/aes.h ../../../winix/functions/functions.h
|
||||
init.o: ../../../winix/functions/functionbase.h ../../../winix/core/request.h
|
||||
init.o: ../../../winix/core/system.h ../../../winix/core/synchro.h
|
||||
init.o: ../../../winix/functions/functionparser.h ../../../winix/core/cur.h
|
||||
init.o: ../../../winix/functions/account.h ../../../winix/functions/adduser.h
|
||||
init.o: ../../../winix/functions/cat.h ../../../winix/functions/chmod.h
|
||||
init.o: ../../../winix/functions/privchanger.h
|
||||
init.o: ../../../winix/functions/chown.h ../../../winix/functions/ckeditor.h
|
||||
init.o: ../../../winix/functions/cp.h ../../../winix/functions/default.h
|
||||
init.o: ../../../winix/functions/download.h ../../../winix/functions/emacs.h
|
||||
init.o: ../../../winix/functions/env.h ../../../winix/functions/imgcrop.h
|
||||
init.o: ../../../winix/functions/last.h ../../../winix/functions/login.h
|
||||
init.o: ../../../winix/functions/logout.h ../../../winix/functions/ln.h
|
||||
init.o: ../../../winix/functions/ls.h ../../../winix/functions/man.h
|
||||
init.o: ../../../winix/functions/meta.h ../../../winix/functions/mkdir.h
|
||||
init.o: ../../../winix/functions/mv.h ../../../winix/functions/nicedit.h
|
||||
init.o: ../../../winix/functions/node.h ../../../winix/functions/passwd.h
|
||||
init.o: ../../../winix/functions/priv.h ../../../winix/functions/pw.h
|
||||
init.o: ../../../winix/functions/reload.h ../../../winix/functions/rm.h
|
||||
init.o: ../../../winix/functions/rmuser.h ../../../winix/functions/sort.h
|
||||
init.o: ../../../winix/functions/specialdefault.h
|
||||
init.o: ../../../winix/functions/stat.h ../../../winix/functions/subject.h
|
||||
init.o: ../../../winix/functions/template.h
|
||||
init.o: ../../../winix/functions/tinymce.h ../../../winix/functions/uname.h
|
||||
init.o: ../../../winix/functions/upload.h ../../../winix/functions/uptime.h
|
||||
init.o: ../../../winix/functions/who.h ../../../winix/functions/vim.h
|
||||
init.o: ../../../winix/core/htmlfilter.h ../../../winix/templates/templates.h
|
||||
init.o: ../../../winix/templates/patterncacher.h
|
||||
init.o: ../../../winix/templates/indexpatterns.h
|
||||
init.o: ../../../winix/templates/patterns.h
|
||||
init.o: ../../../winix/templates/changepatterns.h
|
||||
init.o: ../../../winix/templates/htmltextstream.h
|
||||
init.o: ../../../winix/core/sessionmanager.h exportthread.h message.h
|
||||
init.o: exportinfo.h export.h edb.h ../../../winix/db/dbbase.h
|
||||
init.o: ../../../winix/db/dbconn.h ../../../winix/db/dbtextstream.h
|
||||
init.o: ../../../winix/core/error.h ../../../winix/core/dirs.h funexport.h
|
||||
init.o: ../../../winix/functions/functionbase.h
|
1
winixd/plugins/export/Makefile.o.dep
Normal file
1
winixd/plugins/export/Makefile.o.dep
Normal file
@@ -0,0 +1 @@
|
||||
o = edb.o exportinfo.o exportthread.o funexport.o init.o
|
238
winixd/plugins/export/edb.cpp
Normal file
238
winixd/plugins/export/edb.cpp
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "edb.h"
|
||||
#include "core/log.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
namespace Export
|
||||
{
|
||||
|
||||
void EDb::SetDirs(Dirs * pdirs)
|
||||
{
|
||||
dirs = pdirs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EDb::SetExportCols(PGresult * r)
|
||||
{
|
||||
cid = AssertColumn(r, "id");
|
||||
cuser_id = AssertColumn(r, "user_id");
|
||||
cdir = AssertColumn(r, "dir");
|
||||
cftp_id = AssertColumn(r, "ftp_id");
|
||||
cftp_dir = AssertColumn(r, "ftp_dir");
|
||||
cname = AssertColumn(r, "name");
|
||||
cserver = AssertColumn(r, "server");
|
||||
clogin = AssertColumn(r, "login");
|
||||
cpass = AssertColumn(r, "pass");
|
||||
cpass_type = AssertColumn(r, "pass_type");
|
||||
|
||||
ccan_change_ftp_params = AssertColumn(r, "can_change_ftp_params");
|
||||
ccan_change_dir = AssertColumn(r, "can_change_dir");
|
||||
chttp_server = AssertColumn(r, "http_server");
|
||||
}
|
||||
|
||||
|
||||
void EDb::SetExportValues(PGresult * r, int row, Export & exp)
|
||||
{
|
||||
exp.Clear();
|
||||
|
||||
exp.id = AssertValueLong(r, row, cid);
|
||||
exp.user_id = AssertValueLong(r, row, cuser_id);
|
||||
exp.ftp_id = AssertValueLong(r, row, cftp_id);
|
||||
exp.ftp_pass_type = AssertValueInt(r, row, cpass_type);
|
||||
|
||||
AssertValueWide(r, row, cdir, exp.dir);
|
||||
AssertValueWide(r, row, cftp_dir, exp.ftp_dir);
|
||||
AssertValueWide(r, row, cname, exp.ftp_name);
|
||||
AssertValueWide(r, row, cserver, exp.ftp_server);
|
||||
AssertValueWide(r, row, clogin, exp.ftp_login);
|
||||
AssertValueWide(r, row, chttp_server, exp.http_server);
|
||||
AssertValueWide(r, row, cpass, exp.ftp_pass);
|
||||
|
||||
exp.can_change_ftp_params = AssertValueBool(r, row, ccan_change_ftp_params);
|
||||
exp.can_change_dir = AssertValueBool(r, row, ccan_change_dir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool EDb::GetExport(long user_id, std::vector<Export> & export_tab, bool clear_tab)
|
||||
{
|
||||
if( clear_tab )
|
||||
export_tab.clear();
|
||||
|
||||
PGresult * r = 0;
|
||||
bool result = true;
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R( "select export.id, user_id, dir, ftp_id, ftp_dir, can_change_ftp_params, can_change_dir, "
|
||||
"http_server, name, server, login, pass, pass_type from plugins.export "
|
||||
"left join plugins.export_ftp on ftp_id = export_ftp.id where user_id = ")
|
||||
<< user_id
|
||||
<< R(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_TUPLES_OK);
|
||||
|
||||
SetExportCols(r);
|
||||
int rows = Rows(r);
|
||||
|
||||
for(int i=0 ; i<rows ; ++i)
|
||||
{
|
||||
SetExportValues(r, i, exp);
|
||||
export_tab.push_back(exp);
|
||||
}
|
||||
}
|
||||
catch(const Error &)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool EDb::GetExport(long id, Export & exp)
|
||||
{
|
||||
exp.Clear();
|
||||
PGresult * r = 0;
|
||||
bool result = false;
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R( "select export.id, user_id, dir, ftp_id, ftp_dir, can_change_ftp_params, can_change_dir, "
|
||||
"http_server, name, server, login, pass, pass_type from plugins.export "
|
||||
"left join plugins.export_ftp on ftp_id = export_ftp.id where export.id = ")
|
||||
<< id
|
||||
<< R(";");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_TUPLES_OK);
|
||||
SetExportCols(r);
|
||||
|
||||
if( Rows(r) == 1 )
|
||||
{
|
||||
SetExportValues(r, 0, exp);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
catch(const Error &)
|
||||
{
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool EDb::GetExportDirs(std::vector<ExportDir> & export_tab, bool clear_tab)
|
||||
{
|
||||
if( clear_tab )
|
||||
export_tab.clear();
|
||||
|
||||
PGresult * r = 0;
|
||||
bool result = true;
|
||||
|
||||
try
|
||||
{
|
||||
query.Clear();
|
||||
query << R( "select export.id, dir from plugins.export;");
|
||||
|
||||
r = AssertQuery(query);
|
||||
AssertResult(r, PGRES_TUPLES_OK);
|
||||
|
||||
int rows = Rows(r);
|
||||
cid = AssertColumn(r, "id");
|
||||
cdir = AssertColumn(r, "dir");
|
||||
|
||||
for(int i=0 ; i<rows ; ++i)
|
||||
{
|
||||
exp_dir.id = AssertValueLong(r, i, cid);
|
||||
AssertValueWide(r, i, cdir, dir_temp);
|
||||
|
||||
Item * pdir = dirs->GetDir(dir_temp);
|
||||
|
||||
if( pdir )
|
||||
{
|
||||
exp_dir.dir_id = pdir->id;
|
||||
export_tab.push_back(exp_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
slog << "There is not such a directory: " << dir_temp << " (skipping)" << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const Error &)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace Winix
|
||||
|
95
winixd/plugins/export/edb.h
Normal file
95
winixd/plugins/export/edb.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_export_edb
|
||||
#define headerfile_winix_plugins_export_edb
|
||||
|
||||
#include <vector>
|
||||
#include "db/dbbase.h"
|
||||
#include "export.h"
|
||||
#include "core/dirs.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
namespace Export
|
||||
{
|
||||
|
||||
|
||||
|
||||
class EDb : public DbBase
|
||||
{
|
||||
public:
|
||||
|
||||
void SetDirs(Dirs * pdirs);
|
||||
|
||||
bool GetExport(long user_id, std::vector<Export> & export_tab, bool clear_tab = true);
|
||||
bool GetExport(long id, Export & exp);
|
||||
bool GetExportDirs(std::vector<ExportDir> & export_tab, bool clear_tab = true);
|
||||
|
||||
private:
|
||||
|
||||
Dirs * dirs;
|
||||
|
||||
Export exp;
|
||||
ExportDir exp_dir;
|
||||
DbTextStream query;
|
||||
std::wstring dir_temp;
|
||||
|
||||
int cid;
|
||||
int cuser_id;
|
||||
int cdir;
|
||||
int cftp_id;
|
||||
int cftp_dir;
|
||||
int cname;
|
||||
int cserver;
|
||||
int clogin;
|
||||
int cpass;
|
||||
int cpass_type;
|
||||
int ccan_change_ftp_params;
|
||||
int ccan_change_dir;
|
||||
int chttp_server;
|
||||
|
||||
void SetExportCols(PGresult * r);
|
||||
void SetExportValues(PGresult * r, int row, Export & exp);
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
108
winixd/plugins/export/export.h
Normal file
108
winixd/plugins/export/export.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_export_export
|
||||
#define headerfile_winix_plugins_export_export
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
namespace Export
|
||||
{
|
||||
|
||||
struct ExportDir
|
||||
{
|
||||
long id;
|
||||
long dir_id;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct Export
|
||||
{
|
||||
long id;
|
||||
long user_id;
|
||||
std::wstring dir;
|
||||
|
||||
long ftp_id;
|
||||
std::wstring ftp_dir;
|
||||
|
||||
std::wstring ftp_name;
|
||||
std::wstring ftp_server;
|
||||
std::wstring ftp_login;
|
||||
std::wstring ftp_pass;
|
||||
int ftp_pass_type;
|
||||
|
||||
bool can_change_ftp_params;
|
||||
bool can_change_dir;
|
||||
|
||||
std::wstring http_server;
|
||||
|
||||
|
||||
|
||||
Export()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
id = user_id = ftp_id = -1;
|
||||
ftp_pass_type = 0;
|
||||
|
||||
dir.clear();
|
||||
ftp_dir.clear();
|
||||
ftp_name.clear();
|
||||
ftp_server.clear();
|
||||
ftp_login.clear();
|
||||
ftp_pass.clear();
|
||||
|
||||
can_change_ftp_params = false;
|
||||
can_change_dir = false;
|
||||
|
||||
http_server.clear();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
367
winixd/plugins/export/exportinfo.cpp
Normal file
367
winixd/plugins/export/exportinfo.cpp
Normal file
@@ -0,0 +1,367 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/log.h"
|
||||
#include "exportinfo.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
namespace Export
|
||||
{
|
||||
|
||||
|
||||
ExportInfo::ExportInfo()
|
||||
{
|
||||
use_rsa = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ExportInfo::SetSystem(System * psystem)
|
||||
{
|
||||
system = psystem;
|
||||
}
|
||||
|
||||
|
||||
void ExportInfo::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
}
|
||||
|
||||
|
||||
void ExportInfo::SetEDb(EDb * pdb)
|
||||
{
|
||||
edb = pdb;
|
||||
}
|
||||
|
||||
|
||||
void ExportInfo::SetDb(Db * pdb)
|
||||
{
|
||||
db = pdb;
|
||||
}
|
||||
|
||||
|
||||
void ExportInfo::SetExportThread(ExportThread * pexport_thread)
|
||||
{
|
||||
export_thread = pexport_thread;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ExportInfo::ReadExportDirs()
|
||||
{
|
||||
edb->GetExportDirs(export_dirs);
|
||||
}
|
||||
|
||||
|
||||
void ExportInfo::ReadConfigVars()
|
||||
{
|
||||
use_rsa = config->Bool(L"export_rsa", false);
|
||||
rsa_key = config->Text(L"export_rsa_key");
|
||||
}
|
||||
|
||||
|
||||
ExportDir * ExportInfo::FindDir(long dir_id)
|
||||
{
|
||||
for(size_t i=0 ; i<export_dirs.size() ; ++i)
|
||||
{
|
||||
if( dir_id == export_dirs[i].dir_id || system->dirs.HasParent(dir_id, export_dirs[i].dir_id) )
|
||||
return &export_dirs[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool ExportInfo::DecodePass(Export & exp)
|
||||
{
|
||||
if( exp.ftp_pass_type == 0 )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
if( system->crypt.RSA(false, rsa_key, exp.ftp_pass_bin, pass_decrypted) )
|
||||
{
|
||||
PT::UTF8ToWide(pass_decrypted, exp.ftp_pass);
|
||||
system->crypt.ClearString(pass_decrypted);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Export: I cannot decrypt a password (RSA failed)" << logend;
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ExportInfo::SkipDir(long dir_id, std::wstring & dir)
|
||||
{
|
||||
if( system->dirs.MakePath(dir_id, tmp_dir) )
|
||||
{
|
||||
if( !tmp_dir.empty() && IsSubString(tmp_dir, dir) )
|
||||
{
|
||||
// tmp_dir has a slash at the end
|
||||
// we want the slash at the beginning
|
||||
dir.erase(0, tmp_dir.size()-1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void ExportInfo::ResetRecurrenceCheck()
|
||||
{
|
||||
recurrence_check.clear();
|
||||
}
|
||||
|
||||
|
||||
bool ExportInfo::HasRecurrenceId(long id)
|
||||
{
|
||||
return (std::find(recurrence_check.begin(), recurrence_check.end(), id) != recurrence_check.end());
|
||||
}
|
||||
|
||||
|
||||
void ExportInfo::SendFile(const Item & item, bool thumb, bool put_to_recurrence_tab)
|
||||
{
|
||||
ExportDir * exp_dir = FindDir(item.parent_id);
|
||||
|
||||
if( !exp_dir )
|
||||
return;
|
||||
|
||||
if( HasRecurrenceId(item.id) )
|
||||
{
|
||||
log << log1 << "Export: recurrence found on item.id: " << item.id << ", url: " << item.url << " (skipping)" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
if( put_to_recurrence_tab )
|
||||
recurrence_check.push_back(item.id);
|
||||
|
||||
msg.Clear();
|
||||
system->dirs.MakePath(item.parent_id, msg.path);
|
||||
msg.path += item.url;
|
||||
|
||||
if( item.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
{
|
||||
msg.type = WINIX_PL_EXPORT_TYPE_CREATE_FILE_STATIC;
|
||||
|
||||
if( !system->MakeFilePath(item, msg.url, thumb) )
|
||||
{
|
||||
log << log1 << "Export: I cannot create a path to a static file, item id: " << item.id << logend;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.type = WINIX_PL_EXPORT_TYPE_CREATE_FILE;
|
||||
msg.url = config->url_proto;
|
||||
msg.url += config->base_url;// !! IMPROVE ME what about subdomains?
|
||||
system->dirs.MakePath(item.parent_id, msg.url, false);
|
||||
msg.url += item.url;
|
||||
msg.path += L".php"; // !! do konfiga
|
||||
}
|
||||
|
||||
msg.errors = 0;
|
||||
|
||||
if( SkipDir(exp_dir->dir_id, msg.path) && edb->GetExport(exp_dir->id, exp) )
|
||||
{
|
||||
if( DecodePass(exp) )
|
||||
{
|
||||
msg.ftp_login = exp.ftp_login;
|
||||
msg.ftp_pass = exp.ftp_pass;
|
||||
msg.ftp_server = exp.ftp_server;
|
||||
msg.http_server = exp.http_server;
|
||||
system->dirs.MakePath(exp_dir->dir_id, msg.src_dir);
|
||||
|
||||
if( !item.file_path.empty() && thumb ) // !! uzyc file_type
|
||||
msg.path.insert(0, L"/download"); // !! do konfiga
|
||||
|
||||
if( !exp.ftp_dir.empty() )
|
||||
msg.path.insert(0, exp.ftp_dir);
|
||||
|
||||
if( !msg.path.empty() && msg.path[0] != '/' )
|
||||
msg.path.insert(0, L"/");
|
||||
|
||||
export_thread->AddMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ExportInfo::SendDir(const Item & item)
|
||||
{
|
||||
ExportDir * exp_dir = FindDir(item.id);
|
||||
|
||||
if( !exp_dir )
|
||||
return;
|
||||
|
||||
if( HasRecurrenceId(item.id) )
|
||||
{
|
||||
log << log1 << "Export: recurrence found on item.id: " << item.id << ", url: " << item.url << " (skipping)" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
recurrence_check.push_back(item.id);
|
||||
|
||||
msg.Clear();
|
||||
system->dirs.MakePath(item.id, msg.path);
|
||||
|
||||
msg.type = WINIX_PL_EXPORT_TYPE_CREATE_FILE;
|
||||
msg.url = config->url_proto;
|
||||
msg.url += config->base_url;// !! IMPROVE ME what about subdomains?
|
||||
system->dirs.MakePath(item.id, msg.url, false);
|
||||
msg.path += L"index.html"; // !! do konfiga
|
||||
|
||||
msg.errors = 0;
|
||||
|
||||
if( SkipDir(exp_dir->dir_id, msg.path) && edb->GetExport(exp_dir->id, exp) )
|
||||
{
|
||||
if( DecodePass(exp) )
|
||||
{
|
||||
msg.ftp_login = exp.ftp_login;
|
||||
msg.ftp_pass = exp.ftp_pass;
|
||||
msg.ftp_server = exp.ftp_server;
|
||||
msg.http_server = exp.http_server;
|
||||
system->dirs.MakePath(exp_dir->dir_id, msg.src_dir);
|
||||
|
||||
if( !exp.ftp_dir.empty() )
|
||||
msg.path.insert(0, exp.ftp_dir);
|
||||
|
||||
if( !msg.path.empty() && msg.path[0] != '/' )
|
||||
msg.path.insert(0, L"/");
|
||||
|
||||
export_thread->AddMessage(msg);
|
||||
AdditionalExport(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ExportInfo::SendDir(long dir_id)
|
||||
{
|
||||
Item * dir = system->dirs.GetDir(dir_id);
|
||||
|
||||
if( !dir )
|
||||
return;
|
||||
|
||||
SendDir(*dir);
|
||||
}
|
||||
|
||||
|
||||
// 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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ExportInfo::AdditionalExport(const Item & item)
|
||||
{
|
||||
for(size_t i=0 ; i<item.meta.spaces.size() ; ++i)
|
||||
{
|
||||
if( item.meta.spaces[i]->name == L"export" )
|
||||
AdditionalExport(item, *item.meta.spaces[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ExportInfo::AdditionalExport(const Item & item, PT::Space & meta)
|
||||
{
|
||||
if( meta.ListText(L"additional_export", additional_export) )
|
||||
{
|
||||
for(size_t i=0 ; i<additional_export.size() ; ++i)
|
||||
{
|
||||
log << log1 << "exportuje dodatkowo takiego swiniaka: " << additional_export[i] << logend;
|
||||
AdditionalExport(additional_export[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ExportInfo::AdditionalExport(const std::wstring & path)
|
||||
{
|
||||
int res = system->FollowAllLinks(path, additional_export_dir_tab, additional_export_item);
|
||||
|
||||
if( res == 0 )
|
||||
{
|
||||
// directory
|
||||
SendDir(*additional_export_dir_tab.back());
|
||||
}
|
||||
else
|
||||
if( res == 1 )
|
||||
{
|
||||
// file
|
||||
// !! uwaga jesli to bedzie plik statyczny (moze dwa razy uzyc raz false i raz true?)
|
||||
SendFile(additional_export_item);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Export: incorrect path for additional export: " << path << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
117
winixd/plugins/export/exportinfo.h
Normal file
117
winixd/plugins/export/exportinfo.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_export_exportinfo
|
||||
#define headerfile_winix_plugins_export_exportinfo
|
||||
|
||||
#include "core/system.h"
|
||||
#include "db/db.h"
|
||||
#include "export.h"
|
||||
#include "edb.h"
|
||||
#include "message.h"
|
||||
#include "exportthread.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
namespace Export
|
||||
{
|
||||
|
||||
|
||||
class ExportInfo
|
||||
{
|
||||
public:
|
||||
|
||||
ExportInfo();
|
||||
|
||||
void SetSystem(System * psystem);
|
||||
void SetConfig(Config * pconfig);
|
||||
void SetEDb(EDb * pdb);
|
||||
void SetDb(Db * pdb);
|
||||
void SetExportThread(ExportThread * pexport_thread);
|
||||
|
||||
void ReadExportDirs();
|
||||
void ReadConfigVars();
|
||||
|
||||
ExportDir * FindDir(long dir_id);
|
||||
|
||||
bool DecodePass(Export & exp);
|
||||
|
||||
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);
|
||||
|
||||
void ResetRecurrenceCheck();
|
||||
|
||||
private:
|
||||
|
||||
System * system;
|
||||
Config * config;
|
||||
EDb * edb;
|
||||
Db * db;
|
||||
ExportThread * export_thread;
|
||||
|
||||
bool use_rsa;
|
||||
std::wstring rsa_key;
|
||||
std::string pass_decrypted;
|
||||
Message msg;
|
||||
Export exp;
|
||||
std::wstring tmp_dir;
|
||||
std::vector<ExportDir> export_dirs;
|
||||
DbItemQuery iq_dir;
|
||||
std::vector<Item> dir_items;
|
||||
std::vector<std::wstring> additional_export;
|
||||
std::vector<Item*> additional_export_dir_tab;
|
||||
Item additional_export_item;
|
||||
std::vector<long> recurrence_check;
|
||||
|
||||
bool SkipDir(long dir_id, std::wstring & dir);
|
||||
|
||||
void AdditionalExport(const Item & item);
|
||||
void AdditionalExport(const Item & item, PT::Space & meta);
|
||||
void AdditionalExport(const std::wstring & path);
|
||||
|
||||
bool HasRecurrenceId(long id);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
||||
|
584
winixd/plugins/export/exportthread.cpp
Normal file
584
winixd/plugins/export/exportthread.cpp
Normal file
@@ -0,0 +1,584 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "exportthread.h"
|
||||
#include "core/log.h"
|
||||
#include "core/misc.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
namespace Export
|
||||
{
|
||||
ExportThread * ExportThread::exp_thread;
|
||||
|
||||
|
||||
ExportThread::ExportThread()
|
||||
{
|
||||
exp_thread = 0;
|
||||
browser_name = "Winix Export";
|
||||
conn_timeout = 5;
|
||||
conn_max_errors = 3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ExportThread::SetBaseUrl(const std::wstring & url)
|
||||
{
|
||||
// SetBaseUrl() is called before this thread
|
||||
// is started so we can use 'base_url' later without locking
|
||||
base_url = url;
|
||||
}
|
||||
|
||||
void ExportThread::AddMessage(const Message & message)
|
||||
{
|
||||
message_tab.insert(message_tab.end(), message);
|
||||
WakeUpThread();
|
||||
}
|
||||
|
||||
|
||||
// first thread (objects locked)
|
||||
void ExportThread::AddMessage(int type, const std::wstring & url, const std::wstring & path)
|
||||
{
|
||||
message_add_temp.type = type;
|
||||
message_add_temp.url = url;
|
||||
message_add_temp.path = path;
|
||||
|
||||
AddMessage(message_add_temp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread
|
||||
// objects are locked
|
||||
bool ExportThread::SignalReceived()
|
||||
{
|
||||
return !message_tab.empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread
|
||||
// objects are not locked
|
||||
void ExportThread::Do()
|
||||
{
|
||||
MessageTab::iterator i;
|
||||
bool end;
|
||||
|
||||
Lock();
|
||||
i = message_tab.begin();
|
||||
Unlock();
|
||||
|
||||
do
|
||||
{
|
||||
Lock();
|
||||
|
||||
if( i != message_tab.end() )
|
||||
{
|
||||
message_work = *i;
|
||||
|
||||
Unlock();
|
||||
DoMessage();
|
||||
Lock();
|
||||
|
||||
// although there was Unlock() used we can use the same iterator 'i' here
|
||||
// it will *not* be invalidated (MessageTab is a std::list)
|
||||
// and we are deleting only here
|
||||
i->errors = message_work.errors;
|
||||
|
||||
if( message_work.can_remove )
|
||||
message_tab.erase(i++);
|
||||
|
||||
end = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
end = true;
|
||||
}
|
||||
|
||||
WaitForSignalSleep(1);
|
||||
Unlock();
|
||||
}
|
||||
while( !end && !IsExitSignal() );
|
||||
}
|
||||
|
||||
|
||||
// second thread
|
||||
// objects are not locked
|
||||
// current message we have in 'message_work'
|
||||
void ExportThread::DoMessage()
|
||||
{
|
||||
bool sent_ok = false;
|
||||
|
||||
Convert(message_work.url, url_a);
|
||||
|
||||
if( message_work.type == WINIX_PL_EXPORT_TYPE_CREATE_FILE )
|
||||
{
|
||||
if( Fetch(url_a.c_str()) )
|
||||
{
|
||||
ChangeAdresses(buffer);
|
||||
|
||||
if( Put() )
|
||||
sent_ok = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Put() )
|
||||
sent_ok = true;
|
||||
}
|
||||
|
||||
|
||||
if( sent_ok )
|
||||
{
|
||||
message_work.can_remove = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
message_work.errors += 1;
|
||||
message_work.can_remove = false;
|
||||
|
||||
if( message_work.errors > conn_max_errors )
|
||||
{
|
||||
message_work.can_remove = true;
|
||||
|
||||
Lock();
|
||||
log << log1 << "Export: too many errors for uploading " << message_work.path << " (skipping)" << logend << logsave;
|
||||
Unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// second thread
|
||||
// objects are not locked
|
||||
bool ExportThread::Fetch(const char * url)
|
||||
{
|
||||
Lock();
|
||||
CURL * curl = curl_easy_init();
|
||||
Unlock();
|
||||
|
||||
if( !curl )
|
||||
{
|
||||
Lock();
|
||||
log << log1 << "Export: I can't use curl" << logend;
|
||||
Unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
error_buf[0] = 0;
|
||||
exp_thread = this;
|
||||
buffer.clear();
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, StaticSaveFunction);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, browser_name.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, conn_timeout);
|
||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, conn_timeout);
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buf);
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 20);
|
||||
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
|
||||
|
||||
CURLcode res = curl_easy_perform(curl);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
if( res != 0 )
|
||||
{
|
||||
Lock();
|
||||
log << log1 << "Export: download failed: " << error_buf << logend << logsave;
|
||||
Unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t ExportThread::StaticSaveFunction(char * ptr, size_t size, size_t nmemb, void *userdata)
|
||||
{
|
||||
if( exp_thread )
|
||||
return exp_thread->SaveFunction(ptr, size, nmemb, userdata);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
size_t ExportThread::SaveFunction(char * ptr, size_t size, size_t nmemb, void *userdata)
|
||||
{
|
||||
size_t len = size * nmemb;
|
||||
|
||||
if( len > 0 )
|
||||
buffer.append(ptr, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread
|
||||
// objects are not locked
|
||||
void ExportThread::Convert(const std::wstring & in, std::string & out, bool clear)
|
||||
{
|
||||
Lock();
|
||||
PT::WideToUTF8(in, out, clear);
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread
|
||||
// objects are not locked
|
||||
bool ExportThread::Put()
|
||||
{
|
||||
FILE * file = 0;
|
||||
|
||||
if( message_work.type == WINIX_PL_EXPORT_TYPE_CREATE_FILE_STATIC )
|
||||
{
|
||||
Convert(message_work.url, local_path);
|
||||
file = fopen(local_path.c_str(), "r");
|
||||
|
||||
if( !file )
|
||||
{
|
||||
Lock();
|
||||
log << log1 << "Export: I cannot open the file: " << local_path << logend;
|
||||
Unlock();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log3 << "Export: sending a static file: " << local_path << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Lock();
|
||||
CURL * curl = curl_easy_init();
|
||||
Unlock();
|
||||
|
||||
|
||||
if( !curl )
|
||||
{
|
||||
Lock();
|
||||
log << log1 << "Export: I can't use curl (sending)" << logend;
|
||||
Unlock();
|
||||
|
||||
if( file )
|
||||
fclose(file);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
exp_thread = this;
|
||||
error_buf[0] = 0;
|
||||
buffer_read_index = 0;
|
||||
|
||||
ftp_server = "ftp://";
|
||||
Convert(message_work.ftp_server, ftp_server, false);
|
||||
Convert(message_work.path, ftp_server, false);
|
||||
Convert(message_work.ftp_login, ftp_login);
|
||||
Convert(message_work.ftp_pass, ftp_pass);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, ftp_server.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, ftp_login.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, ftp_pass.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 2);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, browser_name.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_FTP_RESPONSE_TIMEOUT, conn_timeout);
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buf);
|
||||
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
|
||||
|
||||
if( file )
|
||||
{
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, file);
|
||||
}
|
||||
else
|
||||
{
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, StaticReadFunction);
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE, buffer.size());
|
||||
}
|
||||
|
||||
CURLcode res = curl_easy_perform(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
if( file )
|
||||
fclose(file);
|
||||
|
||||
if( res != 0 )
|
||||
{
|
||||
Lock();
|
||||
log << log1 << "Export: upload failed: " << error_buf << " (" << ftp_server << ")" << logend << logsave;
|
||||
Unlock();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Lock();
|
||||
log << log2 << "Export: uploaded: " << ftp_server << logend << logsave;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
size_t ExportThread::StaticReadFunction(char * ptr, size_t size, size_t nmemb, void *userdata)
|
||||
{
|
||||
if( exp_thread )
|
||||
return exp_thread->ReadFunction(ptr, size, nmemb, userdata);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
size_t ExportThread::ReadFunction(char * ptr, size_t size, size_t nmemb, void *userdata)
|
||||
{
|
||||
size_t max_len = size * nmemb;
|
||||
size_t i;
|
||||
|
||||
for(i=0 ; i<max_len && buffer_read_index < buffer.size() ; ++i, ++buffer_read_index )
|
||||
{
|
||||
ptr[i] = buffer[buffer_read_index];
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
// second thread
|
||||
// objects locked
|
||||
bool ExportThread::HasThumbInAdress(std::string & buf, size_t i)
|
||||
{
|
||||
const char * thumb1 = "/-/thumb";
|
||||
const char * thumb2 = "/download/thumb";
|
||||
|
||||
size_t len1 = strlen(thumb1);
|
||||
size_t len2 = strlen(thumb2);
|
||||
|
||||
for( ; i<buf.size() ; ++i)
|
||||
{
|
||||
if( IsSubStringp(thumb1, &buf[i]) )
|
||||
{
|
||||
buf.erase(i, len1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if( IsSubStringp(thumb2, &buf[i]) )
|
||||
{
|
||||
buf.erase(i, len2);
|
||||
return true;
|
||||
}
|
||||
|
||||
if( buf[i] == 10 || buf[i] == '"' || buf[i] == ' ' || buf[i] == '\t' ||
|
||||
buf[i] == '>' ||buf[i] == '<' )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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<buf.size() ; ++i)
|
||||
{
|
||||
if( IsSubStringp(look_for_url.c_str(), &buf[i]) )
|
||||
{
|
||||
i += look_for_url.size() - 1; // without skipping the last slash
|
||||
|
||||
if( HasThumbInAdress(buf, i) )
|
||||
{
|
||||
if( i <= buf.size() )
|
||||
buf.insert(i, "/download"); //!! do konfiga (prefiks katalogu z miniaturami na serwerze docelowym)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread
|
||||
// objects not locked
|
||||
void ExportThread::ChangeAdressesThumb(std::string & buf)
|
||||
{
|
||||
Lock();
|
||||
ChangeAdressesThumb(buf, "http://");
|
||||
ChangeAdressesThumb(buf, "https://");
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// second thread
|
||||
// objects locked
|
||||
void ExportThread::ChangeLogStrings()
|
||||
{
|
||||
log << log3 << "Export: changing string: |" << look_for_url << "|, to: |" << repl_url << "|" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread
|
||||
// objects locked
|
||||
void ExportThread::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)
|
||||
{
|
||||
look_for_url = http_prefix;
|
||||
Convert(base_url, look_for_url, false);
|
||||
look_for_url += dir_prefix;
|
||||
Convert(message_work.src_dir, look_for_url, false);
|
||||
|
||||
if( skip_dir_last_slash )
|
||||
NoLastSlash(look_for_url);
|
||||
|
||||
look_for_url += dir_postfix;
|
||||
|
||||
Convert(message_work.http_server, repl_url);
|
||||
repl_url += repl_dir_postfix;
|
||||
|
||||
ChangeLogStrings();
|
||||
ReplaceString(buf, look_for_url, repl_url);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread
|
||||
// objects not locked
|
||||
void ExportThread::ChangeBaseAdress(std::string & buf,
|
||||
const char * dir_prefix, const char * dir_postfix,
|
||||
const char * repl_dir_postfix, bool skip_dir_last_slash)
|
||||
{
|
||||
Lock();
|
||||
ChangeBaseAdress(buf, "http://", dir_prefix, dir_postfix, repl_dir_postfix, skip_dir_last_slash);
|
||||
ChangeBaseAdress(buf, "https://", dir_prefix, dir_postfix, repl_dir_postfix, skip_dir_last_slash);
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
// second thread
|
||||
// objects not locked
|
||||
void ExportThread::ChangeSiteNames(std::string & buf)
|
||||
{
|
||||
Lock();
|
||||
|
||||
// changing:
|
||||
// /sitename/ -> /
|
||||
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)
|
||||
{
|
||||
// http:// in sources here means either http:// or https://
|
||||
|
||||
// changing:
|
||||
// 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://domain.tld/static/sitename/ -> http://otherdomain.tld/static/
|
||||
ChangeBaseAdress(buf, "/static", "", "/static/");
|
||||
|
||||
// changing:
|
||||
// http://domain.tld/common/sitename/ -> http://otherdomain.tld/common/
|
||||
//ChangeAdresss(buf, "/common", "", "/common/");
|
||||
|
||||
// changing:
|
||||
// http://domain.tld/sitename/ -> http://otherdomain.tld/
|
||||
ChangeBaseAdress(buf, "", "", "/");
|
||||
|
||||
// changing:
|
||||
// http://domain.tld/sitename" -> http://otherdomain.tld"
|
||||
ChangeBaseAdress(buf, "", "\"", "\"", true);
|
||||
|
||||
// changing:
|
||||
// /sitename/ -> /
|
||||
// /sitename" -> /"
|
||||
ChangeSiteNames(buf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace Winix
|
||||
|
123
winixd/plugins/export/exportthread.h
Normal file
123
winixd/plugins/export/exportthread.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#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 Winix
|
||||
{
|
||||
|
||||
|
||||
namespace Export
|
||||
{
|
||||
|
||||
|
||||
class ExportThread : public BaseThread
|
||||
{
|
||||
public:
|
||||
|
||||
ExportThread();
|
||||
|
||||
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;
|
||||
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);
|
||||
bool HasThumbInAdress(std::string & buf, size_t i);
|
||||
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
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
151
winixd/plugins/export/funexport.cpp
Normal file
151
winixd/plugins/export/funexport.cpp
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "funexport.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Export
|
||||
{
|
||||
|
||||
|
||||
FunExport::FunExport()
|
||||
{
|
||||
fun.url = L"export";
|
||||
}
|
||||
|
||||
|
||||
void FunExport::SetExportInfo(ExportInfo * pexport_info)
|
||||
{
|
||||
export_info = pexport_info;
|
||||
}
|
||||
|
||||
|
||||
bool FunExport::HasAccess()
|
||||
{
|
||||
// temporarily only a logged user can use this function
|
||||
// !! IMPROVEME we have to change to only some users can use this function in a specified directory
|
||||
return cur->session->puser;
|
||||
}
|
||||
|
||||
|
||||
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, bool static_files_too)
|
||||
{
|
||||
export_info->SendDir(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);
|
||||
|
||||
if( !static_files_too )
|
||||
iq_dir.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
|
||||
|
||||
db->GetItems(dir_items, iq_dir);
|
||||
|
||||
for(size_t i=0 ; i<dir_items.size() ; ++i)
|
||||
{
|
||||
ExportFile(dir_items[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
DirContainer::ParentIterator i = system->dirs.FindFirstChild(dir.id);
|
||||
|
||||
for( ; i != system->dirs.ParentEnd() ; i = system->dirs.NextChild(i) )
|
||||
{
|
||||
ExportDir(*i->second, static_files_too);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FunExport::Export()
|
||||
{
|
||||
export_info->ResetRecurrenceCheck();
|
||||
bool static_files_too = cur->request->IsPostVar(L"staticfilestoo");
|
||||
|
||||
if( cur->request->is_item )
|
||||
ExportFile(cur->request->item);
|
||||
else
|
||||
ExportDir(*cur->request->dir_tab.back(), static_files_too);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunExport::MakePost()
|
||||
{
|
||||
Export();
|
||||
}
|
||||
|
||||
|
||||
void FunExport::MakeGet()
|
||||
{
|
||||
// if( cur->request->IsParam(L"noconfirm") )
|
||||
// Export();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
84
winixd/plugins/export/funexport.h
Normal file
84
winixd/plugins/export/funexport.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_export_funexport
|
||||
#define headerfile_winix_plugins_export_funexport
|
||||
|
||||
#include "functions/functionbase.h"
|
||||
#include "db/db.h"
|
||||
#include "exportinfo.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
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, bool static_files_too = false);
|
||||
|
||||
private:
|
||||
|
||||
ExportInfo * export_info;
|
||||
DbItemQuery iq_dir;
|
||||
std::vector<Item> dir_items;
|
||||
|
||||
void Export();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
||||
|
297
winixd/plugins/export/init.cpp
Normal file
297
winixd/plugins/export/init.cpp
Normal file
@@ -0,0 +1,297 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "core/log.h"
|
||||
#include "core/plugin.h"
|
||||
#include "exportthread.h"
|
||||
#include "exportinfo.h"
|
||||
#include "edb.h"
|
||||
#include "funexport.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
extern "C" void Init(PluginInfo &);
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Export
|
||||
{
|
||||
|
||||
|
||||
const wchar_t plugin_name[] = L"export";
|
||||
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;
|
||||
|
||||
mount_par_export_conf = system->mounts.AddMountPar(L"export_conf");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FstabChanged(PluginInfo & info)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void InitPlugin(PluginInfo & info)
|
||||
{
|
||||
export_thread.SetBaseUrl(info.config->base_url);
|
||||
|
||||
info.system->thread_manager.Add(&export_thread, L"export");
|
||||
|
||||
export_info.ReadExportDirs();
|
||||
}
|
||||
|
||||
|
||||
void SendDir(PluginInfo & info)
|
||||
{
|
||||
const Item * dir = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( dir )
|
||||
{
|
||||
export_info.ResetRecurrenceCheck();
|
||||
export_info.SendDir(*dir);
|
||||
export_info.SendAllFilesFromDir(dir->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SendFileAdded(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
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.ResetRecurrenceCheck();
|
||||
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.ResetRecurrenceCheck();
|
||||
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.ResetRecurrenceCheck();
|
||||
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);
|
||||
|
||||
if( item )
|
||||
{
|
||||
export_info.ResetRecurrenceCheck();
|
||||
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.ResetRecurrenceCheck();
|
||||
export_info.SendFile(*item, true);
|
||||
export_info.SendDir(item->parent_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SendFilePrepareMove(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
{
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
{
|
||||
export_info.ResetRecurrenceCheck();
|
||||
export_info.SendAllFilesFromDir(item->parent_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FileRemoved(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
{
|
||||
export_info.ResetRecurrenceCheck();
|
||||
export_info.SendDir(item->parent_id);
|
||||
|
||||
if( item->file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
export_info.SendAllFilesFromDir(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);
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Init(PluginInfo & info)
|
||||
{
|
||||
using namespace Export;
|
||||
|
||||
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.SetEDb(&edb);
|
||||
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);
|
||||
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(WINIX_FILE_REMOVED, FileRemoved);
|
||||
|
||||
plugin.Assign(WINIX_PROCESS_REQUEST, ProcessRequest);
|
||||
|
||||
plugin.Assign(WINIX_PLUGIN_INIT, InitPlugin);
|
||||
|
||||
|
||||
|
||||
|
||||
info.p1 = (void*)(plugin_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
103
winixd/plugins/export/message.h
Normal file
103
winixd/plugins/export/message.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_export_message
|
||||
#define headerfile_winix_plugins_export_message
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
// message types
|
||||
#define WINIX_PL_EXPORT_TYPE_CREATE_FILE 1
|
||||
#define WINIX_PL_EXPORT_TYPE_CREATE_FILE_STATIC 2
|
||||
|
||||
|
||||
|
||||
|
||||
struct Message
|
||||
{
|
||||
// message type
|
||||
int type;
|
||||
|
||||
// original (source) url (if message is WINIX_PL_EXPORT_TYPE_CREATE_FILE)
|
||||
// or a file path (WINIX_PL_EXPORT_TYPE_CREATE_FILE_STATIC)
|
||||
std::wstring url;
|
||||
|
||||
// source directory
|
||||
std::wstring src_dir;
|
||||
|
||||
// output file (directory) name
|
||||
// relative path
|
||||
// with a slash at the beginning (and at the end if it is a directory)
|
||||
std::wstring path;
|
||||
|
||||
std::wstring ftp_server;
|
||||
std::wstring ftp_login;
|
||||
std::wstring ftp_pass;
|
||||
|
||||
// server on which the site will be visible
|
||||
std::wstring http_server;
|
||||
|
||||
// how many errors were with this message
|
||||
int errors;
|
||||
|
||||
// shoud be removed
|
||||
bool can_remove;
|
||||
|
||||
|
||||
void Clear()
|
||||
{
|
||||
type = 0;
|
||||
errors = 0;
|
||||
can_remove = true;
|
||||
|
||||
url.clear();
|
||||
src_dir.clear();
|
||||
path.clear();
|
||||
ftp_server.clear();
|
||||
ftp_login.clear();
|
||||
ftp_pass.clear();
|
||||
http_server.clear();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user