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:
2016-03-17 08:26:02 +00:00
parent ed5adb3f23
commit 145efe937c
246 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
include Makefile.o.dep
name = thread.so
all: $(name)
$(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

View File

@@ -0,0 +1,623 @@
# DO NOT DELETE
createthread.o: createthread.h ../../../winix/functions/functionbase.h
createthread.o: ../../../winix/core/item.h ../../../pikotools/space/space.h
createthread.o: ../../../pikotools/textstream/types.h
createthread.o: ../../../pikotools/date/date.h ../../../winix/db/db.h
createthread.o: ../../../winix/db/dbbase.h ../../../winix/db/dbconn.h
createthread.o: ../../../winix/db/dbtextstream.h
createthread.o: ../../../winix/core/textstream.h ../../../winix/core/misc.h
createthread.o: ../../../winix/core/item.h ../../../winix/core/requesttypes.h
createthread.o: ../../../pikotools/textstream/textstream.h
createthread.o: ../../../pikotools/convert/convert.h
createthread.o: ../../../pikotools/convert/inttostr.h
createthread.o: ../../../pikotools/membuffer/membuffer.h
createthread.o: ../../../pikotools/textstream/types.h
createthread.o: ../../../pikotools/utf8/utf8.h
createthread.o: ../../../winix/core/winix_const.h ../../../winix/core/error.h
createthread.o: ../../../pikotools/space/spaceparser.h
createthread.o: ../../../pikotools/space/space.h
createthread.o: ../../../winix/db/dbitemquery.h
createthread.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
createthread.o: ../../../winix/core/group.h
createthread.o: ../../../winix/core/dircontainer.h
createthread.o: ../../../winix/core/ugcontainer.h ../../../winix/core/log.h
createthread.o: ../../../winix/core/textstream.h
createthread.o: ../../../winix/core/logmanipulators.h
createthread.o: ../../../winix/core/slog.h ../../../winix/core/cur.h
createthread.o: ../../../winix/core/request.h ../../../winix/core/error.h
createthread.o: ../../../winix/core/config.h ../../../winix/core/htmlfilter.h
createthread.o: ../../../winix/templates/htmltextstream.h
createthread.o: ../../../pikotools/space/spacetojson.h
createthread.o: ../../../ezc/src/outstreams.h ../../../winix/core/session.h
createthread.o: ../../../winix/core/user.h ../../../winix/core/plugindata.h
createthread.o: ../../../winix/core/rebus.h ../../../winix/core/ipban.h
createthread.o: ../../../winix/core/mount.h ../../../winix/templates/locale.h
createthread.o: ../../../winix/core/request.h ../../../winix/core/config.h
createthread.o: ../../../winix/core/system.h ../../../winix/core/job.h
createthread.o: ../../../winix/core/basethread.h
createthread.o: ../../../winix/core/synchro.h ../../../winix/core/dirs.h
createthread.o: ../../../winix/core/dircontainer.h
createthread.o: ../../../winix/notify/notify.h
createthread.o: ../../../winix/notify/notifypool.h
createthread.o: ../../../winix/templates/patterns.h
createthread.o: ../../../winix/templates/locale.h
createthread.o: ../../../winix/templates/localefilter.h
createthread.o: ../../../ezc/src/ezc.h ../../../ezc/src/generator.h
createthread.o: ../../../ezc/src/blocks.h ../../../ezc/src/cache.h
createthread.o: ../../../ezc/src/functions.h ../../../ezc/src/funinfo.h
createthread.o: ../../../ezc/src/objects.h ../../../ezc/src/pattern.h
createthread.o: ../../../ezc/src/patternparser.h
createthread.o: ../../../winix/notify/notifythread.h
createthread.o: ../../../winix/core/basethread.h
createthread.o: ../../../winix/notify/templatesnotify.h
createthread.o: ../../../winix/core/users.h ../../../winix/core/ugcontainer.h
createthread.o: ../../../winix/core/lastcontainer.h
createthread.o: ../../../winix/core/mounts.h
createthread.o: ../../../winix/core/mountparser.h ../../../winix/core/crypt.h
createthread.o: ../../../winix/core/run.h ../../../winix/core/users.h
createthread.o: ../../../winix/core/groups.h ../../../winix/core/group.h
createthread.o: ../../../winix/core/loadavg.h ../../../winix/core/image.h
createthread.o: ../../../winix/core/threadmanager.h
createthread.o: ../../../winix/core/timezones.h
createthread.o: ../../../winix/core/timezone.h ../../../winix/core/synchro.h
createthread.o: tdb.h thread.h ../../../winix/db/dbbase.h threadinfo.h
createthread.o: ../../../winix/functions/functions.h
createthread.o: ../../../winix/functions/functionbase.h
createthread.o: ../../../winix/functions/functionparser.h
createthread.o: ../../../winix/core/cur.h ../../../winix/functions/account.h
createthread.o: ../../../winix/functions/adduser.h
createthread.o: ../../../winix/functions/cat.h
createthread.o: ../../../winix/functions/chmod.h
createthread.o: ../../../winix/functions/privchanger.h
createthread.o: ../../../winix/functions/chown.h
createthread.o: ../../../winix/functions/ckeditor.h
createthread.o: ../../../winix/functions/cp.h
createthread.o: ../../../winix/functions/default.h
createthread.o: ../../../winix/functions/download.h
createthread.o: ../../../winix/functions/emacs.h
createthread.o: ../../../winix/functions/env.h
createthread.o: ../../../winix/functions/imgcrop.h
createthread.o: ../../../winix/functions/last.h
createthread.o: ../../../winix/functions/login.h
createthread.o: ../../../winix/functions/logout.h
createthread.o: ../../../winix/functions/ln.h ../../../winix/functions/ls.h
createthread.o: ../../../winix/functions/man.h
createthread.o: ../../../winix/functions/meta.h
createthread.o: ../../../winix/functions/mkdir.h
createthread.o: ../../../winix/functions/mv.h
createthread.o: ../../../winix/functions/nicedit.h
createthread.o: ../../../winix/functions/node.h
createthread.o: ../../../winix/functions/passwd.h
createthread.o: ../../../winix/functions/priv.h ../../../winix/functions/pw.h
createthread.o: ../../../winix/functions/reload.h
createthread.o: ../../../winix/functions/rm.h
createthread.o: ../../../winix/functions/rmuser.h
createthread.o: ../../../winix/functions/sort.h
createthread.o: ../../../winix/functions/specialdefault.h
createthread.o: ../../../winix/functions/stat.h
createthread.o: ../../../winix/functions/subject.h
createthread.o: ../../../winix/functions/template.h
createthread.o: ../../../winix/functions/tinymce.h
createthread.o: ../../../winix/functions/uname.h
createthread.o: ../../../winix/functions/upload.h
createthread.o: ../../../winix/functions/uptime.h
createthread.o: ../../../winix/functions/who.h ../../../winix/functions/vim.h
createthread.o: ../../../winix/core/htmlfilter.h
funthread.o: ../../../winix/core/misc.h ../../../winix/core/item.h
funthread.o: ../../../winix/core/requesttypes.h
funthread.o: ../../../pikotools/textstream/textstream.h
funthread.o: ../../../pikotools/space/space.h
funthread.o: ../../../pikotools/textstream/types.h
funthread.o: ../../../pikotools/date/date.h
funthread.o: ../../../pikotools/convert/convert.h
funthread.o: ../../../pikotools/convert/inttostr.h
funthread.o: ../../../pikotools/membuffer/membuffer.h
funthread.o: ../../../pikotools/textstream/types.h
funthread.o: ../../../pikotools/utf8/utf8.h ../../../winix/core/winix_const.h
funthread.o: funthread.h ../../../winix/functions/functionbase.h
funthread.o: ../../../winix/core/item.h ../../../winix/db/db.h
funthread.o: ../../../winix/db/dbbase.h ../../../winix/db/dbconn.h
funthread.o: ../../../winix/db/dbtextstream.h
funthread.o: ../../../winix/core/textstream.h ../../../winix/core/misc.h
funthread.o: ../../../winix/core/error.h
funthread.o: ../../../pikotools/space/spaceparser.h
funthread.o: ../../../pikotools/space/space.h ../../../winix/db/dbitemquery.h
funthread.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
funthread.o: ../../../winix/core/group.h ../../../winix/core/dircontainer.h
funthread.o: ../../../winix/core/ugcontainer.h ../../../winix/core/log.h
funthread.o: ../../../winix/core/textstream.h
funthread.o: ../../../winix/core/logmanipulators.h ../../../winix/core/slog.h
funthread.o: ../../../winix/core/cur.h ../../../winix/core/request.h
funthread.o: ../../../winix/core/error.h ../../../winix/core/config.h
funthread.o: ../../../winix/core/htmlfilter.h
funthread.o: ../../../winix/templates/htmltextstream.h
funthread.o: ../../../pikotools/space/spacetojson.h
funthread.o: ../../../ezc/src/outstreams.h ../../../winix/core/session.h
funthread.o: ../../../winix/core/user.h ../../../winix/core/plugindata.h
funthread.o: ../../../winix/core/rebus.h ../../../winix/core/ipban.h
funthread.o: ../../../winix/core/mount.h ../../../winix/templates/locale.h
funthread.o: ../../../winix/core/request.h ../../../winix/core/config.h
funthread.o: ../../../winix/core/system.h ../../../winix/core/job.h
funthread.o: ../../../winix/core/basethread.h ../../../winix/core/synchro.h
funthread.o: ../../../winix/core/dirs.h ../../../winix/core/dircontainer.h
funthread.o: ../../../winix/notify/notify.h
funthread.o: ../../../winix/notify/notifypool.h
funthread.o: ../../../winix/templates/patterns.h
funthread.o: ../../../winix/templates/locale.h
funthread.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
funthread.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
funthread.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
funthread.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
funthread.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
funthread.o: ../../../winix/notify/notifythread.h
funthread.o: ../../../winix/core/basethread.h
funthread.o: ../../../winix/notify/templatesnotify.h
funthread.o: ../../../winix/core/users.h ../../../winix/core/ugcontainer.h
funthread.o: ../../../winix/core/lastcontainer.h ../../../winix/core/mounts.h
funthread.o: ../../../winix/core/mountparser.h ../../../winix/core/crypt.h
funthread.o: ../../../winix/core/run.h ../../../winix/core/users.h
funthread.o: ../../../winix/core/groups.h ../../../winix/core/group.h
funthread.o: ../../../winix/core/loadavg.h ../../../winix/core/image.h
funthread.o: ../../../winix/core/threadmanager.h
funthread.o: ../../../winix/core/timezones.h ../../../winix/core/timezone.h
funthread.o: ../../../winix/core/synchro.h tdb.h thread.h
funthread.o: ../../../winix/db/dbbase.h threadinfo.h
init.o: tdb.h thread.h ../../../pikotools/date/date.h
init.o: ../../../winix/db/dbbase.h ../../../winix/core/error.h reply.h
init.o: ../../../winix/functions/functionbase.h ../../../winix/core/item.h
init.o: ../../../pikotools/space/space.h
init.o: ../../../pikotools/textstream/types.h ../../../winix/db/db.h
init.o: ../../../winix/db/dbbase.h ../../../winix/db/dbconn.h
init.o: ../../../winix/db/dbtextstream.h ../../../winix/core/textstream.h
init.o: ../../../winix/core/misc.h ../../../winix/core/item.h
init.o: ../../../winix/core/requesttypes.h
init.o: ../../../pikotools/textstream/textstream.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 ../../../pikotools/utf8/utf8.h
init.o: ../../../winix/core/winix_const.h
init.o: ../../../pikotools/space/spaceparser.h
init.o: ../../../pikotools/space/space.h ../../../winix/db/dbitemquery.h
init.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
init.o: ../../../winix/core/group.h ../../../winix/core/dircontainer.h
init.o: ../../../winix/core/ugcontainer.h ../../../winix/core/log.h
init.o: ../../../winix/core/textstream.h
init.o: ../../../winix/core/logmanipulators.h ../../../winix/core/slog.h
init.o: ../../../winix/core/cur.h ../../../winix/core/request.h
init.o: ../../../winix/core/error.h ../../../winix/core/config.h
init.o: ../../../winix/core/htmlfilter.h
init.o: ../../../winix/templates/htmltextstream.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/request.h
init.o: ../../../winix/core/config.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/notify/notify.h
init.o: ../../../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/users.h
init.o: ../../../winix/core/ugcontainer.h ../../../winix/core/lastcontainer.h
init.o: ../../../winix/core/mounts.h ../../../winix/core/mountparser.h
init.o: ../../../winix/core/crypt.h ../../../winix/core/run.h
init.o: ../../../winix/core/users.h ../../../winix/core/groups.h
init.o: ../../../winix/core/group.h ../../../winix/core/loadavg.h
init.o: ../../../winix/core/image.h ../../../winix/core/threadmanager.h
init.o: ../../../winix/core/timezones.h ../../../winix/core/timezone.h
init.o: ../../../winix/core/synchro.h threadinfo.h funthread.h createthread.h
init.o: showthreads.h ../../../winix/core/log.h ../../../winix/core/plugin.h
init.o: pluginmsg.h ../../../winix/core/system.h
init.o: ../../../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
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 templates.h
reply.o: ../../../winix/core/plugin.h pluginmsg.h ../../../winix/core/log.h
reply.o: ../../../winix/core/textstream.h
reply.o: ../../../winix/core/logmanipulators.h
reply.o: ../../../pikotools/textstream/textstream.h
reply.o: ../../../pikotools/space/space.h
reply.o: ../../../pikotools/textstream/types.h ../../../pikotools/date/date.h
reply.o: ../../../pikotools/convert/convert.h
reply.o: ../../../pikotools/convert/inttostr.h
reply.o: ../../../pikotools/membuffer/membuffer.h
reply.o: ../../../pikotools/textstream/types.h ../../../winix/core/slog.h
reply.o: ../../../winix/core/cur.h ../../../winix/core/request.h
reply.o: ../../../winix/core/requesttypes.h ../../../winix/core/item.h
reply.o: ../../../winix/core/error.h ../../../winix/core/config.h
reply.o: ../../../pikotools/space/spaceparser.h
reply.o: ../../../pikotools/space/space.h ../../../winix/core/htmlfilter.h
reply.o: ../../../winix/templates/htmltextstream.h
reply.o: ../../../winix/core/textstream.h ../../../winix/core/misc.h
reply.o: ../../../pikotools/utf8/utf8.h ../../../winix/core/winix_const.h
reply.o: ../../../pikotools/space/spacetojson.h ../../../ezc/src/outstreams.h
reply.o: ../../../winix/core/session.h ../../../winix/core/user.h
reply.o: ../../../winix/core/plugindata.h ../../../winix/core/rebus.h
reply.o: ../../../winix/core/ipban.h ../../../winix/core/mount.h
reply.o: ../../../winix/templates/locale.h ../../../winix/core/system.h
reply.o: ../../../winix/core/sessionmanager.h
reply.o: ../../../winix/core/sessioncontainer.h
reply.o: ../../../winix/core/ipbancontainer.h
reply.o: ../../../winix/core/lastcontainer.h ../../../winix/core/synchro.h
reply.o: ../../../winix/core/basethread.h
reply.o: ../../../winix/core/sessionidmanager.h ../../../tito/src/base64.h
reply.o: ../../../tito/src/aes.h ../../../winix/functions/functions.h
reply.o: ../../../winix/functions/functionbase.h
reply.o: ../../../winix/functions/functionparser.h ../../../winix/db/db.h
reply.o: ../../../winix/db/dbbase.h ../../../winix/db/dbconn.h
reply.o: ../../../winix/db/dbtextstream.h ../../../winix/core/error.h
reply.o: ../../../winix/db/dbitemquery.h ../../../winix/core/item.h
reply.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
reply.o: ../../../winix/core/group.h ../../../winix/core/dircontainer.h
reply.o: ../../../winix/core/ugcontainer.h ../../../winix/core/cur.h
reply.o: ../../../winix/core/system.h ../../../winix/core/job.h
reply.o: ../../../winix/core/dirs.h ../../../winix/core/dircontainer.h
reply.o: ../../../winix/notify/notify.h ../../../winix/notify/notifypool.h
reply.o: ../../../winix/templates/patterns.h
reply.o: ../../../winix/templates/locale.h
reply.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
reply.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
reply.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
reply.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
reply.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
reply.o: ../../../winix/notify/notifythread.h
reply.o: ../../../winix/core/basethread.h
reply.o: ../../../winix/notify/templatesnotify.h ../../../winix/core/config.h
reply.o: ../../../winix/core/users.h ../../../winix/core/ugcontainer.h
reply.o: ../../../winix/core/mounts.h ../../../winix/core/mountparser.h
reply.o: ../../../winix/core/crypt.h ../../../winix/core/run.h
reply.o: ../../../winix/core/users.h ../../../winix/core/groups.h
reply.o: ../../../winix/core/group.h ../../../winix/core/loadavg.h
reply.o: ../../../winix/core/image.h ../../../winix/core/threadmanager.h
reply.o: ../../../winix/core/timezones.h ../../../winix/core/timezone.h
reply.o: ../../../winix/functions/account.h
reply.o: ../../../winix/functions/adduser.h ../../../winix/functions/cat.h
reply.o: ../../../winix/functions/chmod.h
reply.o: ../../../winix/functions/privchanger.h ../../../winix/core/request.h
reply.o: ../../../winix/functions/chown.h ../../../winix/functions/ckeditor.h
reply.o: ../../../winix/functions/cp.h ../../../winix/functions/default.h
reply.o: ../../../winix/functions/download.h ../../../winix/functions/emacs.h
reply.o: ../../../winix/functions/env.h ../../../winix/functions/imgcrop.h
reply.o: ../../../winix/functions/last.h ../../../winix/functions/login.h
reply.o: ../../../winix/functions/logout.h ../../../winix/functions/ln.h
reply.o: ../../../winix/functions/ls.h ../../../winix/functions/man.h
reply.o: ../../../winix/functions/meta.h ../../../winix/functions/mkdir.h
reply.o: ../../../winix/functions/mv.h ../../../winix/functions/nicedit.h
reply.o: ../../../winix/functions/node.h ../../../winix/functions/passwd.h
reply.o: ../../../winix/functions/priv.h ../../../winix/functions/pw.h
reply.o: ../../../winix/functions/reload.h ../../../winix/functions/rm.h
reply.o: ../../../winix/functions/rmuser.h ../../../winix/functions/sort.h
reply.o: ../../../winix/functions/specialdefault.h
reply.o: ../../../winix/functions/stat.h ../../../winix/functions/subject.h
reply.o: ../../../winix/functions/template.h
reply.o: ../../../winix/functions/tinymce.h ../../../winix/functions/uname.h
reply.o: ../../../winix/functions/upload.h ../../../winix/functions/uptime.h
reply.o: ../../../winix/functions/who.h ../../../winix/functions/vim.h
reply.o: ../../../winix/core/htmlfilter.h
reply.o: ../../../winix/templates/templates.h
reply.o: ../../../winix/templates/patterncacher.h
reply.o: ../../../winix/templates/indexpatterns.h
reply.o: ../../../winix/templates/patterns.h
reply.o: ../../../winix/templates/changepatterns.h
reply.o: ../../../winix/templates/htmltextstream.h
reply.o: ../../../winix/core/sessionmanager.h reply.h
reply.o: ../../../winix/functions/functionbase.h
reply.o: ../../../winix/core/synchro.h tdb.h thread.h
reply.o: ../../../winix/db/dbbase.h threadinfo.h ../../../winix/core/misc.h
showthreads.o: showthreads.h ../../../winix/functions/functionbase.h
showthreads.o: ../../../winix/core/item.h ../../../pikotools/space/space.h
showthreads.o: ../../../pikotools/textstream/types.h
showthreads.o: ../../../pikotools/date/date.h ../../../winix/db/db.h
showthreads.o: ../../../winix/db/dbbase.h ../../../winix/db/dbconn.h
showthreads.o: ../../../winix/db/dbtextstream.h
showthreads.o: ../../../winix/core/textstream.h ../../../winix/core/misc.h
showthreads.o: ../../../winix/core/item.h ../../../winix/core/requesttypes.h
showthreads.o: ../../../pikotools/textstream/textstream.h
showthreads.o: ../../../pikotools/convert/convert.h
showthreads.o: ../../../pikotools/convert/inttostr.h
showthreads.o: ../../../pikotools/membuffer/membuffer.h
showthreads.o: ../../../pikotools/textstream/types.h
showthreads.o: ../../../pikotools/utf8/utf8.h
showthreads.o: ../../../winix/core/winix_const.h ../../../winix/core/error.h
showthreads.o: ../../../pikotools/space/spaceparser.h
showthreads.o: ../../../pikotools/space/space.h
showthreads.o: ../../../winix/db/dbitemquery.h
showthreads.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
showthreads.o: ../../../winix/core/group.h ../../../winix/core/dircontainer.h
showthreads.o: ../../../winix/core/ugcontainer.h ../../../winix/core/log.h
showthreads.o: ../../../winix/core/textstream.h
showthreads.o: ../../../winix/core/logmanipulators.h
showthreads.o: ../../../winix/core/slog.h ../../../winix/core/cur.h
showthreads.o: ../../../winix/core/request.h ../../../winix/core/error.h
showthreads.o: ../../../winix/core/config.h ../../../winix/core/htmlfilter.h
showthreads.o: ../../../winix/templates/htmltextstream.h
showthreads.o: ../../../pikotools/space/spacetojson.h
showthreads.o: ../../../ezc/src/outstreams.h ../../../winix/core/session.h
showthreads.o: ../../../winix/core/user.h ../../../winix/core/plugindata.h
showthreads.o: ../../../winix/core/rebus.h ../../../winix/core/ipban.h
showthreads.o: ../../../winix/core/mount.h ../../../winix/templates/locale.h
showthreads.o: ../../../winix/core/request.h ../../../winix/core/config.h
showthreads.o: ../../../winix/core/system.h ../../../winix/core/job.h
showthreads.o: ../../../winix/core/basethread.h ../../../winix/core/synchro.h
showthreads.o: ../../../winix/core/dirs.h ../../../winix/core/dircontainer.h
showthreads.o: ../../../winix/notify/notify.h
showthreads.o: ../../../winix/notify/notifypool.h
showthreads.o: ../../../winix/templates/patterns.h
showthreads.o: ../../../winix/templates/locale.h
showthreads.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
showthreads.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
showthreads.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
showthreads.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
showthreads.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
showthreads.o: ../../../winix/notify/notifythread.h
showthreads.o: ../../../winix/core/basethread.h
showthreads.o: ../../../winix/notify/templatesnotify.h
showthreads.o: ../../../winix/core/users.h ../../../winix/core/ugcontainer.h
showthreads.o: ../../../winix/core/lastcontainer.h
showthreads.o: ../../../winix/core/mounts.h ../../../winix/core/mountparser.h
showthreads.o: ../../../winix/core/crypt.h ../../../winix/core/run.h
showthreads.o: ../../../winix/core/users.h ../../../winix/core/groups.h
showthreads.o: ../../../winix/core/group.h ../../../winix/core/loadavg.h
showthreads.o: ../../../winix/core/image.h
showthreads.o: ../../../winix/core/threadmanager.h
showthreads.o: ../../../winix/core/timezones.h ../../../winix/core/timezone.h
showthreads.o: ../../../winix/core/synchro.h tdb.h thread.h
showthreads.o: ../../../winix/db/dbbase.h threadinfo.h
tdb.o: tdb.h thread.h ../../../pikotools/date/date.h
tdb.o: ../../../winix/db/dbbase.h ../../../winix/core/error.h
tdb.o: ../../../winix/core/log.h
templates.o: threadinfo.h ../../../winix/core/item.h
templates.o: ../../../pikotools/space/space.h
templates.o: ../../../pikotools/textstream/types.h
templates.o: ../../../pikotools/date/date.h ../../../winix/core/system.h
templates.o: ../../../winix/core/job.h ../../../winix/core/basethread.h
templates.o: ../../../winix/core/synchro.h ../../../winix/core/dirs.h
templates.o: ../../../winix/core/item.h ../../../winix/core/dircontainer.h
templates.o: ../../../winix/db/db.h ../../../winix/db/dbbase.h
templates.o: ../../../winix/db/dbconn.h ../../../winix/db/dbtextstream.h
templates.o: ../../../winix/core/textstream.h ../../../winix/core/misc.h
templates.o: ../../../winix/core/requesttypes.h
templates.o: ../../../pikotools/textstream/textstream.h
templates.o: ../../../pikotools/convert/convert.h
templates.o: ../../../pikotools/convert/inttostr.h
templates.o: ../../../pikotools/membuffer/membuffer.h
templates.o: ../../../pikotools/textstream/types.h
templates.o: ../../../pikotools/utf8/utf8.h ../../../winix/core/winix_const.h
templates.o: ../../../winix/core/error.h
templates.o: ../../../pikotools/space/spaceparser.h
templates.o: ../../../pikotools/space/space.h ../../../winix/db/dbitemquery.h
templates.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
templates.o: ../../../winix/core/group.h ../../../winix/core/dircontainer.h
templates.o: ../../../winix/core/ugcontainer.h ../../../winix/core/log.h
templates.o: ../../../winix/core/textstream.h
templates.o: ../../../winix/core/logmanipulators.h ../../../winix/core/slog.h
templates.o: ../../../winix/core/cur.h ../../../winix/core/request.h
templates.o: ../../../winix/core/error.h ../../../winix/core/config.h
templates.o: ../../../winix/core/htmlfilter.h
templates.o: ../../../winix/templates/htmltextstream.h
templates.o: ../../../pikotools/space/spacetojson.h
templates.o: ../../../ezc/src/outstreams.h ../../../winix/core/session.h
templates.o: ../../../winix/core/user.h ../../../winix/core/plugindata.h
templates.o: ../../../winix/core/rebus.h ../../../winix/core/ipban.h
templates.o: ../../../winix/core/mount.h ../../../winix/templates/locale.h
templates.o: ../../../winix/notify/notify.h
templates.o: ../../../winix/notify/notifypool.h
templates.o: ../../../winix/templates/patterns.h
templates.o: ../../../winix/templates/locale.h
templates.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
templates.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
templates.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
templates.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
templates.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
templates.o: ../../../winix/notify/notifythread.h
templates.o: ../../../winix/core/basethread.h
templates.o: ../../../winix/notify/templatesnotify.h
templates.o: ../../../winix/core/config.h ../../../winix/core/users.h
templates.o: ../../../winix/core/ugcontainer.h
templates.o: ../../../winix/core/lastcontainer.h ../../../winix/core/mounts.h
templates.o: ../../../winix/core/mountparser.h ../../../winix/core/crypt.h
templates.o: ../../../winix/core/run.h ../../../winix/core/users.h
templates.o: ../../../winix/core/groups.h ../../../winix/core/group.h
templates.o: ../../../winix/core/loadavg.h ../../../winix/core/image.h
templates.o: ../../../winix/core/threadmanager.h
templates.o: ../../../winix/core/timezones.h ../../../winix/core/timezone.h
templates.o: thread.h tdb.h ../../../winix/db/dbbase.h reply.h
templates.o: ../../../winix/functions/functionbase.h
templates.o: ../../../winix/core/request.h ../../../winix/core/synchro.h
templates.o: funthread.h createthread.h showthreads.h
templates.o: ../../../winix/core/misc.h ../../../winix/core/plugin.h
templates.o: pluginmsg.h ../../../winix/core/system.h
templates.o: ../../../winix/core/sessionmanager.h
templates.o: ../../../winix/core/sessioncontainer.h
templates.o: ../../../winix/core/ipbancontainer.h
templates.o: ../../../winix/core/sessionidmanager.h
templates.o: ../../../tito/src/base64.h ../../../tito/src/aes.h
templates.o: ../../../winix/functions/functions.h
templates.o: ../../../winix/functions/functionbase.h
templates.o: ../../../winix/functions/functionparser.h
templates.o: ../../../winix/core/cur.h ../../../winix/functions/account.h
templates.o: ../../../winix/functions/adduser.h
templates.o: ../../../winix/functions/cat.h ../../../winix/functions/chmod.h
templates.o: ../../../winix/functions/privchanger.h
templates.o: ../../../winix/functions/chown.h
templates.o: ../../../winix/functions/ckeditor.h
templates.o: ../../../winix/functions/cp.h ../../../winix/functions/default.h
templates.o: ../../../winix/functions/download.h
templates.o: ../../../winix/functions/emacs.h ../../../winix/functions/env.h
templates.o: ../../../winix/functions/imgcrop.h
templates.o: ../../../winix/functions/last.h ../../../winix/functions/login.h
templates.o: ../../../winix/functions/logout.h ../../../winix/functions/ln.h
templates.o: ../../../winix/functions/ls.h ../../../winix/functions/man.h
templates.o: ../../../winix/functions/meta.h ../../../winix/functions/mkdir.h
templates.o: ../../../winix/functions/mv.h ../../../winix/functions/nicedit.h
templates.o: ../../../winix/functions/node.h
templates.o: ../../../winix/functions/passwd.h
templates.o: ../../../winix/functions/priv.h ../../../winix/functions/pw.h
templates.o: ../../../winix/functions/reload.h ../../../winix/functions/rm.h
templates.o: ../../../winix/functions/rmuser.h
templates.o: ../../../winix/functions/sort.h
templates.o: ../../../winix/functions/specialdefault.h
templates.o: ../../../winix/functions/stat.h
templates.o: ../../../winix/functions/subject.h
templates.o: ../../../winix/functions/template.h
templates.o: ../../../winix/functions/tinymce.h
templates.o: ../../../winix/functions/uname.h
templates.o: ../../../winix/functions/upload.h
templates.o: ../../../winix/functions/uptime.h ../../../winix/functions/who.h
templates.o: ../../../winix/functions/vim.h ../../../winix/core/htmlfilter.h
templates.o: ../../../winix/templates/templates.h
templates.o: ../../../winix/templates/patterncacher.h
templates.o: ../../../winix/templates/indexpatterns.h
templates.o: ../../../winix/templates/patterns.h
templates.o: ../../../winix/templates/changepatterns.h
templates.o: ../../../winix/templates/htmltextstream.h
templates.o: ../../../winix/core/sessionmanager.h
threadinfo.o: threadinfo.h ../../../winix/core/item.h
threadinfo.o: ../../../pikotools/space/space.h
threadinfo.o: ../../../pikotools/textstream/types.h
threadinfo.o: ../../../pikotools/date/date.h ../../../winix/core/system.h
threadinfo.o: ../../../winix/core/job.h ../../../winix/core/basethread.h
threadinfo.o: ../../../winix/core/synchro.h ../../../winix/core/dirs.h
threadinfo.o: ../../../winix/core/item.h ../../../winix/core/dircontainer.h
threadinfo.o: ../../../winix/db/db.h ../../../winix/db/dbbase.h
threadinfo.o: ../../../winix/db/dbconn.h ../../../winix/db/dbtextstream.h
threadinfo.o: ../../../winix/core/textstream.h ../../../winix/core/misc.h
threadinfo.o: ../../../winix/core/requesttypes.h
threadinfo.o: ../../../pikotools/textstream/textstream.h
threadinfo.o: ../../../pikotools/convert/convert.h
threadinfo.o: ../../../pikotools/convert/inttostr.h
threadinfo.o: ../../../pikotools/membuffer/membuffer.h
threadinfo.o: ../../../pikotools/textstream/types.h
threadinfo.o: ../../../pikotools/utf8/utf8.h
threadinfo.o: ../../../winix/core/winix_const.h ../../../winix/core/error.h
threadinfo.o: ../../../pikotools/space/spaceparser.h
threadinfo.o: ../../../pikotools/space/space.h
threadinfo.o: ../../../winix/db/dbitemquery.h
threadinfo.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
threadinfo.o: ../../../winix/core/group.h ../../../winix/core/dircontainer.h
threadinfo.o: ../../../winix/core/ugcontainer.h ../../../winix/core/log.h
threadinfo.o: ../../../winix/core/textstream.h
threadinfo.o: ../../../winix/core/logmanipulators.h
threadinfo.o: ../../../winix/core/slog.h ../../../winix/core/cur.h
threadinfo.o: ../../../winix/core/request.h ../../../winix/core/error.h
threadinfo.o: ../../../winix/core/config.h ../../../winix/core/htmlfilter.h
threadinfo.o: ../../../winix/templates/htmltextstream.h
threadinfo.o: ../../../pikotools/space/spacetojson.h
threadinfo.o: ../../../ezc/src/outstreams.h ../../../winix/core/session.h
threadinfo.o: ../../../winix/core/user.h ../../../winix/core/plugindata.h
threadinfo.o: ../../../winix/core/rebus.h ../../../winix/core/ipban.h
threadinfo.o: ../../../winix/core/mount.h ../../../winix/templates/locale.h
threadinfo.o: ../../../winix/notify/notify.h
threadinfo.o: ../../../winix/notify/notifypool.h
threadinfo.o: ../../../winix/templates/patterns.h
threadinfo.o: ../../../winix/templates/locale.h
threadinfo.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
threadinfo.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
threadinfo.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
threadinfo.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
threadinfo.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
threadinfo.o: ../../../winix/notify/notifythread.h
threadinfo.o: ../../../winix/core/basethread.h
threadinfo.o: ../../../winix/notify/templatesnotify.h
threadinfo.o: ../../../winix/core/config.h ../../../winix/core/users.h
threadinfo.o: ../../../winix/core/ugcontainer.h
threadinfo.o: ../../../winix/core/lastcontainer.h
threadinfo.o: ../../../winix/core/mounts.h ../../../winix/core/mountparser.h
threadinfo.o: ../../../winix/core/crypt.h ../../../winix/core/run.h
threadinfo.o: ../../../winix/core/users.h ../../../winix/core/groups.h
threadinfo.o: ../../../winix/core/group.h ../../../winix/core/loadavg.h
threadinfo.o: ../../../winix/core/image.h ../../../winix/core/threadmanager.h
threadinfo.o: ../../../winix/core/timezones.h ../../../winix/core/timezone.h
threadinfo.o: thread.h tdb.h ../../../winix/db/dbbase.h
threadinfo.o: ../../../winix/core/plugin.h pluginmsg.h
threadinfo.o: ../../../winix/core/system.h
threadinfo.o: ../../../winix/core/sessionmanager.h
threadinfo.o: ../../../winix/core/sessioncontainer.h
threadinfo.o: ../../../winix/core/ipbancontainer.h
threadinfo.o: ../../../winix/core/sessionidmanager.h
threadinfo.o: ../../../tito/src/base64.h ../../../tito/src/aes.h
threadinfo.o: ../../../winix/functions/functions.h
threadinfo.o: ../../../winix/functions/functionbase.h
threadinfo.o: ../../../winix/functions/functionparser.h
threadinfo.o: ../../../winix/core/cur.h ../../../winix/functions/account.h
threadinfo.o: ../../../winix/functions/adduser.h
threadinfo.o: ../../../winix/functions/cat.h ../../../winix/functions/chmod.h
threadinfo.o: ../../../winix/functions/privchanger.h
threadinfo.o: ../../../winix/core/request.h ../../../winix/functions/chown.h
threadinfo.o: ../../../winix/functions/ckeditor.h
threadinfo.o: ../../../winix/functions/cp.h
threadinfo.o: ../../../winix/functions/default.h
threadinfo.o: ../../../winix/functions/download.h
threadinfo.o: ../../../winix/functions/emacs.h ../../../winix/functions/env.h
threadinfo.o: ../../../winix/functions/imgcrop.h
threadinfo.o: ../../../winix/functions/last.h
threadinfo.o: ../../../winix/functions/login.h
threadinfo.o: ../../../winix/functions/logout.h ../../../winix/functions/ln.h
threadinfo.o: ../../../winix/functions/ls.h ../../../winix/functions/man.h
threadinfo.o: ../../../winix/functions/meta.h
threadinfo.o: ../../../winix/functions/mkdir.h ../../../winix/functions/mv.h
threadinfo.o: ../../../winix/functions/nicedit.h
threadinfo.o: ../../../winix/functions/node.h
threadinfo.o: ../../../winix/functions/passwd.h
threadinfo.o: ../../../winix/functions/priv.h ../../../winix/functions/pw.h
threadinfo.o: ../../../winix/functions/reload.h ../../../winix/functions/rm.h
threadinfo.o: ../../../winix/functions/rmuser.h
threadinfo.o: ../../../winix/functions/sort.h
threadinfo.o: ../../../winix/functions/specialdefault.h
threadinfo.o: ../../../winix/functions/stat.h
threadinfo.o: ../../../winix/functions/subject.h
threadinfo.o: ../../../winix/functions/template.h
threadinfo.o: ../../../winix/functions/tinymce.h
threadinfo.o: ../../../winix/functions/uname.h
threadinfo.o: ../../../winix/functions/upload.h
threadinfo.o: ../../../winix/functions/uptime.h
threadinfo.o: ../../../winix/functions/who.h ../../../winix/functions/vim.h
threadinfo.o: ../../../winix/core/htmlfilter.h
threadinfo.o: ../../../winix/templates/templates.h
threadinfo.o: ../../../winix/templates/patterncacher.h
threadinfo.o: ../../../winix/templates/indexpatterns.h
threadinfo.o: ../../../winix/templates/patterns.h
threadinfo.o: ../../../winix/templates/changepatterns.h
threadinfo.o: ../../../winix/templates/htmltextstream.h
threadinfo.o: ../../../winix/core/sessionmanager.h

View File

@@ -0,0 +1 @@
o = createthread.o funthread.o init.o reply.o showthreads.o tdb.o templates.o threadinfo.o

View File

@@ -0,0 +1,140 @@
/*
* 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) 2008-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 "createthread.h"
#include "functions.h"
#include "functions/functions.h"
namespace Winix
{
namespace Thread
{
CreateThread::CreateThread()
{
fun.url = L"createthread";
}
void CreateThread::SetTDb(TDb * ptdb)
{
tdb = ptdb;
}
void CreateThread::SetThreadInfo(ThreadInfo * pthread_info)
{
thread_info = pthread_info;
}
// returning true if we can create a thread in the current directory
bool CreateThread::HasAccess()
{
if( cur->request->is_item || !system->HasWriteAccess(*cur->request->dir_tab.back()) )
return false;
if( system->mounts.pmount->type != thread_info->mount_type_thread )
return false;
return true;
}
void CreateThread::SendNotify(const Item & item)
{
// sending notification
notify_msg.code = WINIX_NOTIFY_CODE_ADD;
notify_msg.template_index = thread_info->template_index;
notify_msg.dir_link = config->url_proto;
notify_msg.dir_link += config->base_url;// !! IMPROVE ME what about subdomains?
system->dirs.MakePath(item.parent_id, notify_msg.dir_link, false);
notify_msg.item_link = notify_msg.dir_link;
notify_msg.item_link += item.url;
system->notify.ItemChanged(notify_msg);
}
void CreateThread::MakePost()
{
cur->request->item.Clear();
functions->ReadItem(cur->request->item, Item::file);
functions->SetUser(cur->request->item);
functions->PrepareUrl(cur->request->item);
cur->request->item.parent_id = cur->request->dir_tab.back()->id;
cur->request->item.privileges = system->NewFilePrivileges();
if( functions->CheckAbuse() )
return;
cur->request->status = system->AddFile(cur->request->item);
if( cur->request->status == WINIX_ERR_OK )
{
thread.Clear();
thread.file_id = cur->request->item.id;
cur->request->status = tdb->AddThread(thread);
}
if( cur->request->status == WINIX_ERR_OK )
{
log << log2 << "CreateThread: added a new thread" << logend;
thread_info->MakeRedirectIfPossible(cur->request->item);
SendNotify(cur->request->item);
}
else
{
log << log1 << "CreateThread: problem with adding a new thread, error code: "
<< cur->request->status << logend;
}
}
} // namespace
} // namespace Winix

View File

@@ -0,0 +1,76 @@
/*
* 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) 2010-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_thread_createthread
#define headerfile_winix_plugins_thread_createthread
#include "functions/functionbase.h"
#include "tdb.h"
#include "threadinfo.h"
#include "notify/notify.h"
namespace Winix
{
namespace Thread
{
class CreateThread : public FunctionBase
{
public:
CreateThread();
bool HasAccess();
void MakePost();
void SetTDb(TDb * ptdb);
void SetThreadInfo(ThreadInfo * pthread_info);
private:
TDb * tdb;
ThreadInfo * thread_info;
Thread thread;
NotifyMsg notify_msg;
void SendNotify(const Item & item);
};
} // namespace
} // namespace Winix
#endif

View File

@@ -0,0 +1,118 @@
/*
* 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) 2008-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 <algorithm>
#include "core/misc.h"
#include "funthread.h"
namespace Winix
{
namespace Thread
{
FunThread::FunThread()
{
fun.url = L"thread";
}
void FunThread::SetTDb(TDb * ptdb)
{
tdb = ptdb;
}
void FunThread::SetThreadInfo(ThreadInfo * pthread_info)
{
thread_info = pthread_info;
}
bool FunThread::HasAccess()
{
if( !cur->request->is_item )
return false;
if( system->mounts.pmount->type != thread_info->mount_type_thread )
return false;
return true;
}
void FunThread::PrepareThread(long file_id)
{
thread_info->Clear();
cur->request->status = tdb->GetAnswers(file_id, id_tab);
if( !id_tab.empty() )
{
DbItemQuery iq;
if( system->mounts.pmount->IsArg(thread_info->mount_par_thread, L"sort_desc") )
iq.sort_date_asc = false; // sort_index_asc we are ignoring
iq.WhereIdIn(id_tab);
iq.WhereType(Item::file);
iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
db->GetItems(thread_info->item_tab, iq);
system->CheckAccessToItems(thread_info->item_tab);
thread_info->item_sort_tab.resize(thread_info->item_tab.size());
// thread_info.item_tab is already sorted (by the database)
for(size_t i=0 ; i<thread_info->item_tab.size() ; ++i)
thread_info->item_sort_tab[i] = &thread_info->item_tab[i];
}
}
void FunThread::MakeGet()
{
PrepareThread(cur->request->item.id);
}
} // namespace
} // namespace Winix

View File

@@ -0,0 +1,75 @@
/*
* 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) 2010-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_thread_funthread
#define headerfile_winix_plugins_thread_funthread
#include "functions/functionbase.h"
#include "tdb.h"
#include "threadinfo.h"
namespace Winix
{
namespace Thread
{
class FunThread : public FunctionBase
{
public:
FunThread();
bool HasAccess();
void MakeGet();
void PrepareThread(long file_id);
void SetTDb(TDb * ptdb);
void SetThreadInfo(ThreadInfo * pthread_info);
private:
TDb * tdb;
ThreadInfo * thread_info;
std::vector<long> id_tab;
};
} // namespace
} // namespace Winix
#endif

View File

@@ -0,0 +1,232 @@
/*
* 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) 2010-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 "tdb.h"
#include "reply.h"
#include "funthread.h"
#include "createthread.h"
#include "showthreads.h"
#include "core/log.h"
#include "core/plugin.h"
#include "pluginmsg.h"
#include "templates.h"
namespace Winix
{
extern "C" void Init(PluginInfo &);
namespace Thread
{
const wchar_t plugin_name[] = L"thread";
TDb tdb;
ThreadInfo thread_info;
Reply fun_reply;
FunThread fun_thread;
CreateThread fun_create_thread;
ShowThreads fun_show_threads;
void AddFunctions(PluginInfo & info)
{
info.functions->Add(fun_reply);
info.functions->Add(fun_thread);
info.functions->Add(fun_create_thread);
info.functions->Add(fun_show_threads);
}
void SelectDefaultFunction(PluginInfo & info)
{
if( info.system->mounts.pmount->type == thread_info.mount_type_thread )
{
if( info.cur->request->is_item )
info.cur->request->function = &fun_thread;
else
info.cur->request->function = &fun_show_threads;
}
}
void AddMounts(PluginInfo & info)
{
Mounts & m = info.system->mounts;
thread_info.mount_type_thread = m.AddMountType(L"thread");
thread_info.mount_par_thread = m.AddMountPar(L"thread");
thread_info.mount_par_thread_dir = m.AddMountPar(L"thread_dir");
}
void RemoveThread(PluginInfo & info)
{
const Item * item = reinterpret_cast<Item*>(info.p1);
if( item )
{
thread_info.RemoveThread(item->id);
thread_info.RemoveThreadAnswer(item->id);
}
}
void AddNotifyTemplate(PluginInfo & info)
{
thread_info.template_index = info.system->notify.AddTemplate(L"notify_email_thread.txt");
}
void SetSortTab(PluginInfo & info)
{
if( !info.p1 )
{
log << log1 << "Thread: sort_tab pointer is not set" << logend;
return;
}
typedef std::vector<Item*> SortTab;
SortTab * psort_tab = reinterpret_cast<SortTab*>(info.p1);
// !! IMPROVE ME
// !! dodac jakies czyszczenie tej tablicy wskaznikow na koncu przetwarzania requestu
// aby kiedys przypadkowo nie odwolac sie do nie istniejacego obiektu
// poprzez bezposrednie uzycie jakiejs funkcji z ezc
thread_info.item_sort_tab = *psort_tab;
}
void ReadThreads(PluginInfo & info)
{
fun_show_threads.ReadThreads();
}
void SetSortTabIndex(PluginInfo & info)
{
thread_sort_tab(info.l1);
}
void PrepareThread(PluginInfo & info)
{
fun_thread.PrepareThread(info.l1);
}
void EndRequest(PluginInfo & info)
{
thread_info.Clear();
}
// !! temporarily
void Rescan(PluginInfo & info)
{
if( info.config->Bool(L"thread_rescan", false) == true )
{
log << log1 << "---------- rescanning thread db ------------- " << logend;
thread_info.Repair();
log << log1 << "---------- thread db rescanning is finished ------------- " << logend;
}
}
} // namespace
void Init(PluginInfo & info)
{
using namespace Thread;
plugin.Assign(WINIX_CREATE_FUNCTIONS, AddFunctions);
plugin.Assign(WINIX_SELECT_DEFAULT_FUNCTION, SelectDefaultFunction);
plugin.Assign(WINIX_ADD_MOUNTS, AddMounts);
plugin.Assign(WINIX_FILE_REMOVED, RemoveThread);
plugin.Assign(WINIX_NOTIFY_ADD_TEMPLATE, AddNotifyTemplate);
plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
plugin.Assign(WINIX_END_REQUEST, EndRequest);
// for other plugins
plugin.Assign(WINIX_PL_THREAD_SET_SORTTAB, SetSortTab);
plugin.Assign(WINIX_PL_THREAD_READ_THREADS, ReadThreads);
plugin.Assign(WINIX_PL_THREAD_SET_SORTTAB_INDEX, SetSortTabIndex);
plugin.Assign(WINIX_PL_THREAD_PREPARE_THREAD, PrepareThread);
// temporarily
plugin.Assign(WINIX_PLUGIN_INIT, Rescan);
tdb.SetConn(info.db->GetConn());
tdb.LogQueries(info.config->log_db_query);
// thread_info and fun_show_threads are used in 'ticket' plugins too
thread_info.SetDb(info.db);
thread_info.SetTDb(&tdb);
thread_info.SetSystem(info.system);
thread_info.plugin_id = info.plugin_id;
fun_reply.SetTDb(&tdb);
fun_reply.SetThreadInfo(&thread_info);
fun_thread.SetTDb(&tdb);
fun_thread.SetThreadInfo(&thread_info);
fun_create_thread.SetTDb(&tdb);
fun_create_thread.SetThreadInfo(&thread_info);
fun_show_threads.SetTDb(&tdb);
fun_show_threads.SetThreadInfo(&thread_info);
info.p1 = (void*)(plugin_name);
}
} // namespace Winix

View File

@@ -0,0 +1,67 @@
/*
* 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) 2010-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_thread_pluginmsg
#define headerfile_winix_plugins_thread_pluginmsg
namespace Winix
{
// values from 4000 - 4099 reserved for 'thread' plugin
#define WINIX_PL_THREAD_SET_SORTTAB 4000
#define WINIX_PL_THREAD_READ_THREADS 4001
#define WINIX_PL_THREAD_SET_SORTTAB_INDEX 4002
#define WINIX_PL_THREAD_PREPARE_THREAD 4003
#define WINIX_PL_THREAD_SEARCH_THREAD_DIR 4004
#define WINIX_PL_THREAD_CAN_MAKE_REDIRECT 4005
// a new answer is going to add in a thread
// in p1 you have a pointer to the new Item struct
// cur->request->item is the 'main' thread file
#define WINIX_PL_THREAD_PREPARE_TO_REPLY_IN_THREAD 4006
} // namespace Winix
#endif

View File

@@ -0,0 +1,165 @@
/*
* 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) 2010-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/plugin.h"
#include "reply.h"
#include "functions/functions.h"
#include "core/misc.h"
#include "core/plugin.h"
#include "pluginmsg.h"
namespace Winix
{
namespace Thread
{
Reply::Reply()
{
fun.url = L"reply";
files_dir = 0;
}
void Reply::SetTDb(TDb * ptdb)
{
tdb = ptdb;
}
void Reply::SetThreadInfo(ThreadInfo * pthread_info)
{
thread_info = pthread_info;
}
/*
we can use 'reply' function everywhere where 'thread_dir' mount option is defined
if there is no such a thread in 'thread' table it will be added automatically
*/
bool Reply::HasAccess()
{
if( !cur->request->is_item )
return false;
files_dir = thread_info->FindThreadDir();
if( !files_dir || !system->HasWriteAccess(*files_dir) )
return false;
PT::Space * thread_space = cur->request->item.ameta.FindSpace(L"thread");
if( thread_space )
{
if( thread_space->Bool(L"closed", false) )
return false;
}
return true;
}
void Reply::SendNotify(const Item & item)
{
// sending notification
notify_msg.code = WINIX_NOTIFY_CODE_REPLY;
notify_msg.template_index = thread_info->template_index;
notify_msg.dir_link = config->url_proto;
notify_msg.dir_link += config->base_url;// !! IMPROVE ME what about subdomains?
system->dirs.MakePath(item.parent_id, notify_msg.dir_link, false);
notify_msg.item_link = notify_msg.dir_link;
notify_msg.item_link += item.url;
system->notify.ItemChanged(notify_msg);
}
void Reply::MakePost()
{
// !! jak bedzie dostepne assert
// ASSERT(files_dir)
if( tdb->GetThread(cur->request->item.id, thread) != WINIX_ERR_OK )
{
thread.Clear();
thread.file_id = cur->request->item.id;
tdb->AddThread(thread);
}
answer.Clear();
answer.url = cur->request->item.url;
answer.url += L"_msg_";
answer.url += Toa(thread.replies + 1);
answer.subject = answer.url;
functions->ReadItem(answer, Item::file);
functions->SetUser(answer);
functions->PrepareUrl(answer);
answer.parent_id = files_dir->id;
answer.privileges = system->NewFilePrivileges();
if( functions->CheckAbuse() )
return;
plugin.Call(WINIX_PL_THREAD_PREPARE_TO_REPLY_IN_THREAD, &answer);
cur->request->status = system->AddFile(answer);
if( cur->request->status == WINIX_ERR_OK )
cur->request->status = tdb->AddAnswer(cur->request->item.id, answer.id);
if( cur->request->status == WINIX_ERR_OK )
{
log << log2 << "Reply: added an answer in a thread" << logend;
thread_info->MakeRedirectIfPossible(cur->request->item);
SendNotify(cur->request->item);
}
else
{
log << log1 << "Reply: problem with adding an answer, error code: "
<< cur->request->status << logend;
}
}
} // namespace
} // namespace Winix

View File

@@ -0,0 +1,80 @@
/*
* 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) 2010-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_thread_reply
#define headerfile_winix_plugins_thread_reply
#include "functions/functionbase.h"
#include "tdb.h"
#include "threadinfo.h"
#include "notify/notify.h"
namespace Winix
{
namespace Thread
{
class Reply : public FunctionBase
{
public:
Reply();
bool HasAccess();
void MakePost();
void SetTDb(TDb * ptdb);
void SetThreadInfo(ThreadInfo * pthread_info);
private:
TDb * tdb;
ThreadInfo * thread_info;
Item answer;
Thread thread;
Item * files_dir;
NotifyMsg notify_msg;
void SendNotify(const Item & item);
};
} // namespace
} // namespace Winix
#endif

View File

@@ -0,0 +1,175 @@
/*
* 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) 2010-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 <algorithm>
#include "showthreads.h"
#include "functions.h"
namespace Winix
{
namespace Thread
{
ShowThreads::ShowThreads()
{
fun.url = L"showthreads";
}
void ShowThreads::SetTDb(TDb * ptdb)
{
tdb = ptdb;
}
void ShowThreads::SetThreadInfo(ThreadInfo * pthread_info)
{
thread_info = pthread_info;
}
bool ShowThreads::HasAccess()
{
if( cur->request->is_item )
return false;
if( system->mounts.pmount->type != thread_info->mount_type_thread )
return false;
return true;
}
bool ShowThreads::Sort::operator()(const Item * item1, const Item * item2)
{
if( sort_type == 0 )
{
// sorting by url
return item1->url < item2->url;
}
else
{
// sorting by date
return item1->date_creation > item2->date_creation;
}
}
void ShowThreads::ReadFiles()
{
// reading files
DbItemQuery iq;
iq.SetAll(false, false);
iq.sel_url = true;
iq.sel_subject = true;
iq.sel_date = true;
iq.sel_user_id = true;
iq.sel_group_id = true;
iq.sel_guest_name = true;
iq.sel_privileges = true;
iq.sel_date = true;
iq.WhereParentId(cur->request->dir_tab.back()->id);
iq.WhereType(Item::file);
iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
db->GetItems(thread_info->item_tab, iq);
system->CheckAccessToItems(thread_info->item_tab);
}
void ShowThreads::CreatePointers()
{
// creating a pointers table
thread_info->item_sort_tab.resize(thread_info->item_tab.size());
for(size_t i=0 ; i<thread_info->item_tab.size() ; ++i)
thread_info->item_sort_tab[i] = &thread_info->item_tab[i];
}
void ShowThreads::SortPointers()
{
int sort_type = 1;
if( cur->request->ParamValue(L"sort") == L"url" )
sort_type = 0;
std::vector<Item*> & table = thread_info->item_sort_tab;
std::sort(table.begin(), table.end(), Sort(this, sort_type));
}
void ShowThreads::ReadThreads()
{
// reading threads for the files
file_id_tab.resize(thread_info->item_sort_tab.size());
for(size_t i=0 ; i<thread_info->item_sort_tab.size() ; ++i)
file_id_tab[i] = thread_info->item_sort_tab[i]->id;
tdb->GetThreads(file_id_tab, thread_info->thread_tab);
}
void ShowThreads::MakeGet()
{
thread_info->Clear();
ReadFiles();
CreatePointers();
SortPointers();
ReadThreads();
}
} // namespace
} // namespace Winix

View File

@@ -0,0 +1,92 @@
/*
* 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) 2010-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_thread_showthreads
#define headerfile_winix_plugins_thread_showthreads
#include "functions/functionbase.h"
#include "tdb.h"
#include "threadinfo.h"
namespace Winix
{
namespace Thread
{
class ShowThreads : public FunctionBase
{
public:
ShowThreads();
bool HasAccess();
void MakeGet();
void SetTDb(TDb * ptdb);
void SetThreadInfo(ThreadInfo * pthread_info);
void ReadThreads();
private:
TDb * tdb;
ThreadInfo * thread_info;
std::vector<long> file_id_tab;
void ReadFiles();
void CreatePointers();
void SortPointers();
struct Sort
{
ShowThreads * show_threads;
int sort_type;
Sort(ShowThreads * show, int type) : show_threads(show), sort_type(type) {}
bool operator()(const Item * item1, const Item * item2);
};
};
} // namespace
} // namespace Winix
#endif

View File

@@ -0,0 +1,502 @@
/*
* 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) 2010-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 "tdb.h"
#include "core/log.h"
namespace Winix
{
namespace Thread
{
Error TDb::AddThread(const Thread & thread)
{
query.Clear();
query << R("insert into plugins.thread (file_id, replies, last_item, closed) values (")
<< thread.file_id
<< thread.replies
<< thread.last_item_id
<< (thread.closed ? 1 : 0 )
<< R(");");
return DoCommand(query);
}
void TDb::SetThreadColumns(PGresult * r)
{
cfile_id = AssertColumn(r, "file_id");
creplies = AssertColumn(r, "replies");
cclosed = AssertColumn(r, "closed");
clast_item = AssertColumn(r, "last_item");
cdate_modification = AssertColumn(r, "date_modification");
cuser_id = AssertColumn(r, "user_id");
cguest = AssertColumn(r, "guest_name");
}
void TDb::SetThread(PGresult * r, int col, Thread & thread)
{
thread.file_id = AssertValueLong(r, col, cfile_id);
thread.replies = AssertValueLong(r, col, creplies);
thread.closed = AssertValueBool(r, col, cclosed);
thread.last_item_id = AssertValueLong(r, col, clast_item);
thread.last_item_date_modification = AssertValueDate(r, col, cdate_modification);
thread.last_item_user_id = AssertValueLong(r, col, cuser_id);
AssertValueWide(r, col, cguest, thread.last_item_guest_name);
}
Error TDb::GetThread(long file_id, Thread & thread)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
try
{
query.Clear();
query << R("select thread.file_id, thread.replies, thread.closed, thread.last_item, "
"item.date_modification, item.user_id, item.guest_name "
"from plugins.thread left join core.item on thread.last_item = item.id "
"where thread.file_id = ") << file_id << R(";");
r = AssertQuery(query);
AssertResult(r, PGRES_TUPLES_OK);
int rows = Rows(r);
if( rows > 1 )
log << log1 << "ThreadDb: there is more than one thread with file_id: " << file_id << logend;
else
if( rows == 0 )
throw Error(WINIX_ERR_NO_THREAD);
SetThreadColumns(r);
SetThread(r, 0, thread);
}
catch(const Error & e)
{
status = e;
}
ClearResult(r);
return status;
}
Error TDb::GetThreads(const std::vector<long> & file_id_tab, std::vector<Thread> & thread_tab)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
thread_tab.clear();
if( file_id_tab.empty() )
return status;
try
{
CreateIdList(file_id_tab, list_id);
// they should be sorted by file_id (they are used in a binary search later)
query.Clear();
query << R("select thread.file_id, thread.replies, thread.closed, thread.last_item, "
"item.date_modification, item.user_id, item.guest_name "
"from plugins.thread left join core.item on thread.last_item = item.id "
"where thread.file_id in ") << R(list_id) << R(" order by file_id asc;");
r = AssertQuery(query);
AssertResult(r, PGRES_TUPLES_OK);
int rows = Rows(r);
SetThreadColumns(r);
for(int i=0 ; i<rows ; ++i)
{
SetThread(r, i, thread_temp);
thread_tab.push_back(thread_temp);
}
}
catch(const Error & e)
{
status = e;
}
ClearResult(r);
return status;
}
Error TDb::GetAnswers(long file_id, std::vector<long> & answer_id_tab)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
answer_id_tab.clear();
try
{
query.Clear();
query << R("select answer_id from plugins.thread_files "
"where file_id = ") << file_id << R(";");
r = AssertQuery(query);
AssertResult(r, PGRES_TUPLES_OK);
int rows = Rows(r);
answer_id_tab.resize(rows);
for(int i=0 ; i<rows ; ++i)
answer_id_tab[i] = AssertValueLong(r, i, 0);
}
catch(const Error & e)
{
status = e;
}
ClearResult(r);
return status;
}
Error TDb::AddAnswer(long file_id, long answer_id)
{
query.Clear();
query << R("insert into plugins.thread_files (file_id, answer_id) values (")
<< file_id
<< answer_id
<< R(");");
Error status = DoCommand(query);
if( status != WINIX_ERR_OK )
return status;
query.Clear();
query << R("update plugins.thread set (last_item, replies) = (")
<< answer_id
<< R(", replies+1) where file_id=")
<< file_id
<< R(";");
return DoCommand(query);
}
long TDb::FindLastAnswer(long file_id)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
long last_item_id = -1;
try
{
query.Clear();
query << R("select id from plugins.thread_files left join core.item on item.id=answer_id where file_id=")
<< file_id
<< R(" order by date_creation desc limit 1;");
r = AssertQuery(query);
AssertResult(r, PGRES_TUPLES_OK);
if( Rows(r) == 1 )
last_item_id = AssertValueLong(r, 0, 0);
}
catch(const Error & e)
{
status = e;
}
ClearResult(r);
return last_item_id;
}
Error TDb::RemoveAnswer(long answer_id)
{
PGresult * r1 = 0;
PGresult * r2 = 0;
Error status = WINIX_ERR_OK;
try
{
// selecting files which have answer_id as an answer
query.Clear();
query << R("select file_id from plugins.thread_files where answer_id = ")
<< answer_id
<< R(";");
r1 = AssertQuery(query);
AssertResult(r1, PGRES_TUPLES_OK);
int rows = Rows(r1);
file_id_tab.resize(rows);
for(int i=0 ; i<rows ; ++i)
file_id_tab[i] = AssertValueLong(r1, i, 0);
// deleting those answers
query.Clear();
query << R("delete from plugins.thread_files where answer_id = ")
<< answer_id
<< R(";");
r2 = AssertQuery(query);
AssertResult(r2, PGRES_COMMAND_OK);
rows = AffectedRows(r2);
if( rows > 0 )
log << log2 << "ThreadDb: deleted " << rows << " rows from plugins.thread_files" << logend;
// setting new last_items to the files
status = RemoveAnswerRecalcLast(file_id_tab);
}
catch(const Error & e)
{
status = e;
}
ClearResult(r1);
ClearResult(r2);
return status;
}
Error TDb::RemoveAnswerRecalcLast(long file_id)
{
long last_item_id = FindLastAnswer(file_id);
query.Clear();
query << R("update plugins.thread set (replies, last_item) = (replies-1,")
<< last_item_id
<< R(") where file_id=")
<< file_id
<< R(";");
return DoCommand(query);
}
Error TDb::RemoveAnswerRecalcLast(const std::vector<long> & file_id_tab)
{
for(size_t i=0 ; i<file_id_tab.size() ; ++i)
{
long file_id = file_id_tab[i];
Error status = RemoveAnswerRecalcLast(file_id);
if( status != WINIX_ERR_OK )
return status;
}
return WINIX_ERR_OK;
}
Error TDb::RecalcThread(long file_id)
{
long replies = CalcAnswers(file_id);
long last_item = FindLastAnswer(file_id);
query.Clear();
query << R("update plugins.thread set (replies, last_item) = (")
<< replies
<< last_item
<< R(") where file_id=")
<< file_id
<< R(";");
return DoCommand(query);
}
long TDb::CalcAnswers(long file_id)
{
PGresult * r = 0;
long answers = 0;
try
{
query.Clear();
query << R("select count(file_id) from plugins.thread_files where file_id=") << file_id << R(";");
r = AssertQuery(query);
AssertResult(r, PGRES_TUPLES_OK);
if( Rows(r) == 1 )
answers = AssertValueLong(r, 0, 0);
}
catch(const Error &)
{
}
ClearResult(r);
return answers;
}
Error TDb::RemoveThread(long file_id)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
try
{
query.Clear();
query << R("delete from plugins.thread where file_id=") << file_id << R(";");
r = AssertQuery(query);
AssertResult(r, PGRES_COMMAND_OK);
long rows = AffectedRows(r);
if( rows > 0 )
log << log2 << "ThreadDb: deleted " << rows << " rows from plugins.thread" << logend;
ClearResult(r);
query.Clear();
query << R("delete from plugins.thread_files where file_id=") << file_id << R(";");
r = AssertQuery(query);
AssertResult(r, PGRES_COMMAND_OK);
rows = AffectedRows(r);
if( rows > 0 )
log << log2 << "ThreadDb: deleted " << rows << " rows from plugins.thread_files" << logend;
}
catch(const Error & e)
{
status = e;
}
ClearResult(r);
return status;
}
Error TDb::RemoveAnswerOnly(long answer_id)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
try
{
query.Clear();
query << R("delete from plugins.thread_files where answer_id=") << answer_id << R(";");
r = AssertQuery(query);
AssertResult(r, PGRES_COMMAND_OK);
long rows = AffectedRows(r);
if( rows > 0 )
log << log2 << "ThreadDb: deleted " << rows << " rows from plugins.thread_files" << logend;
}
catch(const Error & e)
{
status = e;
}
ClearResult(r);
return status;
}
void TDb::GetAllThreadsId(std::vector<long> & file_id)
{
PGresult * r = 0;
file_id.clear();
try
{
query.Clear();
query << R("select file_id from plugins.thread;");
r = AssertQuery(query);
AssertResult(r, PGRES_TUPLES_OK);
int rows = Rows(r);
file_id.resize(rows);
for(int i=0 ; i<rows ; ++i)
file_id[i] = AssertValueLong(r, i, 0);
}
catch(const Error &)
{
}
ClearResult(r);
}
} // namespace
} // namespace Winix

114
winixd/plugins/thread/tdb.h Normal file
View File

@@ -0,0 +1,114 @@
/*
* 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) 2010-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_thread_tdb
#define headerfile_winix_plugins_thread_tdb
#include <vector>
#include "thread.h"
#include "db/dbbase.h"
#include "core/error.h"
namespace Winix
{
namespace Thread
{
class TDb : public DbBase
{
public:
/*
high level interface
*/
Error AddThread(const Thread & thread);
Error GetThread(long file_id, Thread & thread);
Error GetThreads(const std::vector<long> & file_id_tab, std::vector<Thread> & thread_tab);
Error RemoveThread(long file_id);
Error AddAnswer(long file_id, long answer_id);
Error GetAnswers(long file_id, std::vector<long> & answer_id_tab);
Error RemoveAnswer(long answer_id);
/*
low level interface
*/
// looking for the last answer in a thread (in 'thread_files' table)
// this is not the value from 'thread' table
long FindLastAnswer(long file_id);
// returning all threads id (file_id) (from 'thread' table)
void GetAllThreadsId(std::vector<long> & file_id);
// removing only the answer in 'thread_files' table without updating 'thread' table
Error RemoveAnswerOnly(long answer_id);
// returning how many answers there are
// calculating from 'thread_files' table
// this is not the value from 'thread' table
long CalcAnswers(long file_id);
// recalculating last_item, replies in 'thread' table on a given thread
Error RecalcThread(long file_id);
private:
DbTextStream query;
std::wstring list_id;
int cfile_id, creplies, cclosed, clast_item, cdate_modification, cuser_id, cguest;
Thread thread_temp;
std::vector<long> file_id_tab;
void SetThreadColumns(PGresult * r);
void SetThread(PGresult * r, int col, Thread & thread);
Error RemoveAnswerRecalcLast(long file_id);
Error RemoveAnswerRecalcLast(const std::vector<long> & file_id_tab);
};
} // namespace
} // namespace Winix
#endif

View File

@@ -0,0 +1,567 @@
/*
* 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) 2008-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 "threadinfo.h"
#include "reply.h"
#include "funthread.h"
#include "createthread.h"
#include "showthreads.h"
#include "core/request.h"
#include "core/misc.h"
#include "core/plugin.h"
#include "templates/templates.h"
#include "functions/functions.h"
namespace Winix
{
namespace Thread
{
using namespace TemplatesFunctions;
using TemplatesFunctions::system;
extern ThreadInfo thread_info;
extern Reply fun_reply;
extern FunThread fun_thread;
extern CreateThread fun_create_thread;
extern ShowThreads fun_show_threads;
static size_t item_sort_index;
static HtmlTextStream item_run_content;
static EzcGen ezc_generator;
static bool has_thread;
static size_t thread_index;
// binary search for file_id in thread_tab (thread_tab must be sorted by id)
bool FindThread(const std::vector<Thread> & thread_tab, long file_id, size_t & thread_index)
{
if( thread_tab.empty() )
return false;
size_t o1 = 0;
size_t o2 = thread_tab.size() - 1;
if( thread_tab[o1].file_id == file_id )
{
thread_index = o1;
return true;
}
if( file_id < thread_tab[o1].file_id )
return false;
if( thread_tab[o2].file_id == file_id )
{
thread_index = o2;
return true;
}
if( file_id > thread_tab[o2].file_id )
return false;
while( o1 + 1 < o2 )
{
thread_index = (o1 + o2) / 2;
if( thread_tab[thread_index].file_id == file_id )
return true;
if( thread_tab[thread_index].file_id < file_id )
o1 = thread_index;
else
o2 = thread_index;
}
return false;
}
bool thread_sort_tab(size_t sort_index)
{
bool res;
item_sort_index = sort_index;
res = item_sort_index < thread_info.item_sort_tab.size();
has_thread = false;
if( res )
{
long file_id = thread_info.item_sort_tab[item_sort_index]->id;
has_thread = FindThread(thread_info.thread_tab, file_id, thread_index);
}
return res;
}
void thread_sort_tab(Info & i)
{
i.res = thread_sort_tab(i.iter);
}
void thread_sort_tab_id(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.out << thread_info.item_sort_tab[item_sort_index]->id;
}
void thread_sort_tab_subject(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.out << thread_info.item_sort_tab[item_sort_index]->subject;
}
void thread_sort_tab_subject_noescape(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.out << R(thread_info.item_sort_tab[item_sort_index]->subject);
}
void thread_sort_tab_content(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.out << thread_info.item_sort_tab[item_sort_index]->content;
}
void thread_sort_tab_content_noescape(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.out << R(thread_info.item_sort_tab[item_sort_index]->content);
}
void thread_sort_tab_print_content(Info & i)
{
if( item_sort_index >= thread_info.item_sort_tab.size() )
return;
std::wstring & content = thread_info.item_sort_tab[item_sort_index]->content;
Item::ContentType type = thread_info.item_sort_tab[item_sort_index]->content_type;
item_print_content(i.out, content, type);
}
void thread_sort_tab_privileges(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.out << "0" << Toa(thread_info.item_sort_tab[item_sort_index]->privileges, 8);
}
void thread_sort_tab_dir(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
std::wstring path;
if( system->dirs.MakePath(thread_info.item_sort_tab[item_sort_index]->parent_id, path) )
i.out << path;
else
i.out << "/the path does not exist/"; // !! do konfiga
}
}
void thread_sort_tab_url(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.out << thread_info.item_sort_tab[item_sort_index]->url;
}
void thread_sort_tab_link(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
doc_proto(i);
i.out << config->base_url;
thread_sort_tab_dir(i);
thread_sort_tab_url(i);
}
}
void thread_sort_tab_can_read(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
if( system->HasReadAccess(*thread_info.item_sort_tab[item_sort_index]) )
i.res = true;
}
}
void thread_sort_tab_can_write(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.res = system->HasWriteAccess(*thread_info.item_sort_tab[item_sort_index]);
}
void thread_sort_tab_user(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
User * puser = system->users.GetUser(thread_info.item_sort_tab[item_sort_index]->user_id);
print_user_name(i, puser, thread_info.item_sort_tab[item_sort_index]->guest_name);
}
}
void thread_sort_tab_modification_user(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
User * puser = system->users.GetUser(thread_info.item_sort_tab[item_sort_index]->modification_user_id);
print_user_name(i, puser, thread_info.item_sort_tab[item_sort_index]->guest_name);
}
}
void thread_sort_tab_users_different(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
i.res = (thread_info.item_sort_tab[item_sort_index]->user_id != thread_info.item_sort_tab[item_sort_index]->modification_user_id);
}
}
void thread_sort_tab_group(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
long group_id = thread_info.item_sort_tab[item_sort_index]->group_id;
Group * pgroup = system->groups.GetGroup(group_id);
if( pgroup )
i.out << pgroup->name;
else
i.out << group_id;
}
}
void thread_sort_tab_date_creation(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
PT::Date date = system->ToLocal(thread_info.item_sort_tab[item_sort_index]->date_creation);
i.out << DateToStr(date.year, date.month, date.day, date.hour, date.min, date.sec);
}
}
void thread_sort_tab_date_modification(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
PT::Date date = system->ToLocal(thread_info.item_sort_tab[item_sort_index]->date_modification);
i.out << DateToStr(date.year, date.month, date.day, date.hour, date.min, date.sec);
}
}
void thread_sort_tab_date_creation_nice(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
print_date_nice(i, thread_info.item_sort_tab[item_sort_index]->date_creation);
}
}
void thread_sort_tab_date_modification_nice(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
print_date_nice(i, thread_info.item_sort_tab[item_sort_index]->date_modification);
}
}
void thread_sort_tab_dates_equal(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
PT::Date & date1 = thread_info.item_sort_tab[item_sort_index]->date_creation;
PT::Date & date2 = thread_info.item_sort_tab[item_sort_index]->date_modification;
i.res = date1 == date2;
}
}
void thread_sort_tab_run(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
if( system->HasReadExecAccess(*thread_info.item_sort_tab[item_sort_index]) )
{
Ezc::Pattern * p = pattern_cacher.GetPattern(*thread_info.item_sort_tab[item_sort_index]);
item_run_content.Clear();
InitGenerator(ezc_generator);
ezc_generator.SetPattern(*p);
ezc_generator.Generate(item_run_content);
item_print_content(i.out, item_run_content.Str(), thread_info.item_sort_tab[item_sort_index]->content_type);
}
else
{
i.out << "<!-- run: permission denied -->";
}
}
}
void thread_sort_tab_has_static_file(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
i.res = thread_info.item_sort_tab[item_sort_index]->file_type != WINIX_ITEM_FILETYPE_NONE &&
!thread_info.item_sort_tab[item_sort_index]->file_path.empty();
}
}
void thread_sort_tab_has_thumb(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.res = thread_info.item_sort_tab[item_sort_index]->has_thumb;
}
void thread_sort_tab_type_is_dir(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.res = thread_info.item_sort_tab[item_sort_index]->type == Item::dir;
}
void thread_sort_tab_type_is_file(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.res = thread_info.item_sort_tab[item_sort_index]->type == Item::file;
}
void thread_sort_tab_type_is_symlink(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.res = thread_info.item_sort_tab[item_sort_index]->type == Item::symlink;
}
void thread_sort_tab_is_link_to(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.res = !thread_info.item_sort_tab[item_sort_index]->link_to.empty();
}
void thread_sort_tab_link_to(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.out << thread_info.item_sort_tab[item_sort_index]->link_to;
}
void thread_sort_tab_is_link_redirect(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
i.res = thread_info.item_sort_tab[item_sort_index]->link_redirect == 1;
}
void thread_sort_tab_has_thread(Info & i)
{
i.res = has_thread;
}
void thread_sort_tab_replies(Info & i)
{
if( has_thread && thread_index < thread_info.thread_tab.size() )
i.out << thread_info.thread_tab[thread_index].replies;
}
void thread_sort_tab_last_item_date_modification_nice(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
if( has_thread && thread_index < thread_info.thread_tab.size() )
{
Thread & thread = thread_info.thread_tab[thread_index];
if( thread.last_item_id != -1 )
print_date_nice(i, thread.last_item_date_modification);
else
print_date_nice(i, thread_info.item_sort_tab[item_sort_index]->date_modification);
}
}
}
void thread_sort_tab_last_item_user(Info & i)
{
if( item_sort_index < thread_info.item_sort_tab.size() )
{
if( has_thread && thread_index < thread_info.thread_tab.size() )
{
Thread & thread = thread_info.thread_tab[thread_index];
if( thread.last_item_id != -1 )
{
User * puser = system->users.GetUser(thread.last_item_user_id);
print_user_name(i, puser, thread.last_item_guest_name);
}
else
{
User * puser = system->users.GetUser(thread_info.item_sort_tab[item_sort_index]->user_id);
print_user_name(i, puser, thread_info.item_sort_tab[item_sort_index]->guest_name);
}
}
}
}
void thread_can_reply(Info & i)
{
i.res = fun_reply.HasAccess();
}
void thread_can_create(Info & i)
{
i.res = fun_create_thread.HasAccess();
}
void thread_mount_arg_is(Info & i)
{
if( system->mounts.pmount )
i.res = system->mounts.pmount->IsArg(thread_info.mount_par_thread, i.par);
}
void AddEzcFunctions(PluginInfo & info)
{
using TemplatesFunctions::EzcFun;
EzcFun * fun = reinterpret_cast<EzcFun*>(info.p1);
fun->Insert("thread_sort_tab", thread_sort_tab);
fun->Insert("thread_sort_tab_id", thread_sort_tab_id);
fun->Insert("thread_sort_tab_subject", thread_sort_tab_subject);
fun->Insert("thread_sort_tab_subject_noescape", thread_sort_tab_subject_noescape);
fun->Insert("thread_sort_tab_content", thread_sort_tab_content);
fun->Insert("thread_sort_tab_content_noescape", thread_sort_tab_content_noescape);
fun->Insert("thread_sort_tab_print_content", thread_sort_tab_print_content);
fun->Insert("thread_sort_tab_privileges", thread_sort_tab_privileges);
fun->Insert("thread_sort_tab_dir", thread_sort_tab_dir);
fun->Insert("thread_sort_tab_url", thread_sort_tab_url);
fun->Insert("thread_sort_tab_link", thread_sort_tab_link);
fun->Insert("thread_sort_tab_can_read", thread_sort_tab_can_read);
fun->Insert("thread_sort_tab_can_write", thread_sort_tab_can_write);
fun->Insert("thread_sort_tab_user", thread_sort_tab_user);
fun->Insert("thread_sort_tab_modification_user", thread_sort_tab_modification_user);
fun->Insert("thread_sort_tab_users_different", thread_sort_tab_users_different);
fun->Insert("thread_sort_tab_group", thread_sort_tab_group);
fun->Insert("thread_sort_tab_date_creation", thread_sort_tab_date_creation);
fun->Insert("thread_sort_tab_date_modification", thread_sort_tab_date_modification);
fun->Insert("thread_sort_tab_date_creation_nice", thread_sort_tab_date_creation_nice);
fun->Insert("thread_sort_tab_date_modification_nice", thread_sort_tab_date_modification_nice);
fun->Insert("thread_sort_tab_dates_equal", thread_sort_tab_dates_equal);
fun->Insert("thread_sort_tab_run", thread_sort_tab_run);
fun->Insert("thread_sort_tab_has_static_file", thread_sort_tab_has_static_file);
fun->Insert("thread_sort_tab_has_thumb", thread_sort_tab_has_thumb);
fun->Insert("thread_sort_tab_type_is_dir", thread_sort_tab_type_is_dir);
fun->Insert("thread_sort_tab_type_is_file", thread_sort_tab_type_is_file);
fun->Insert("thread_sort_tab_type_is_symlink", thread_sort_tab_type_is_symlink);
fun->Insert("thread_sort_tab_is_link_to", thread_sort_tab_is_link_to);
fun->Insert("thread_sort_tab_link_to", thread_sort_tab_link_to);
fun->Insert("thread_sort_tab_is_link_redirect", thread_sort_tab_is_link_redirect);
fun->Insert("thread_sort_tab_has_thread", thread_sort_tab_has_thread);
fun->Insert("thread_sort_tab_replies", thread_sort_tab_replies);
fun->Insert("thread_sort_tab_last_item_date_modification_nice", thread_sort_tab_last_item_date_modification_nice);
fun->Insert("thread_sort_tab_last_item_user", thread_sort_tab_last_item_user);
fun->Insert("thread_can_reply", thread_can_reply);
fun->Insert("thread_can_create", thread_can_create);
fun->Insert("thread_mount_arg_is", thread_mount_arg_is);
}
} // namespace
} // namespace Winix

View File

@@ -0,0 +1,60 @@
/*
* 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) 2010-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_thread_templates
#define headerfile_winix_plugins_thread_templates
#include "core/plugin.h"
namespace Winix
{
namespace Thread
{
bool thread_sort_tab(size_t sort_index);
void AddEzcFunctions(PluginInfo & info);
} // namespace
} // namespace Winix
#endif

View File

@@ -0,0 +1,91 @@
/*
* 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) 2009-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_thread_thread
#define headerfile_winix_plugins_thread_thread
#include <string>
#include <string.h>
#include "date/date.h"
namespace Winix
{
namespace Thread
{
class Thread
{
public:
long file_id;
long replies;
bool closed;
// the last file in a thread
long last_item_id;
PT::Date last_item_date_modification;
long last_item_user_id;
std::wstring last_item_guest_name;
void Clear()
{
file_id = -1;
closed = false;
replies = 0;
last_item_id = -1;
last_item_user_id = -1;
last_item_date_modification.Clear();
last_item_guest_name.clear();
}
Thread()
{
Clear();
}
};
} // namespace
} // namespace Winix
#endif

View File

@@ -0,0 +1,195 @@
/*
* 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) 2010-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 "threadinfo.h"
#include "core/plugin.h"
#include "pluginmsg.h"
namespace Winix
{
namespace Thread
{
void ThreadInfo::SetDb(Db * pdb)
{
db = pdb;
}
void ThreadInfo::SetTDb(TDb * ptdb)
{
tdb = ptdb;
}
void ThreadInfo::SetSystem(System * psystem)
{
system = psystem;
}
void ThreadInfo::Clear()
{
item_tab.clear();
thread_tab.clear();
item_sort_tab.clear();
}
Item * ThreadInfo::FindThreadDir()
{
Item * plugin_dir = 0;
plugin.Call(WINIX_PL_THREAD_SEARCH_THREAD_DIR, &plugin_dir);
if( plugin_dir )
return plugin_dir;
const std::wstring & dir_str = system->mounts.pmount->FirstArg(mount_par_thread_dir);
if( dir_str.empty() )
return 0;
int res = system->FollowAllLinks(dir_str, out_dir_tab, out_item);
if( res != 0 )
return 0;
return out_dir_tab.back();
}
void ThreadInfo::RemoveThread(long file_id)
{
if( tdb->GetAnswers(file_id, remove_answer_id_tab) == WINIX_ERR_OK )
{
for(size_t i=0 ; i<remove_answer_id_tab.size() ; ++i)
db->DelFileById(remove_answer_id_tab[i]);
}
tdb->RemoveThread(file_id);
}
void ThreadInfo::RemoveThreadAnswer(long answer_id)
{
tdb->RemoveAnswer(answer_id);
}
void ThreadInfo::RepairAnswer(long answer_id)
{
iq.Clear();
iq.SetAll(false, false);
iq.WhereId(answer_id);
iq.WhereType(Item::file); // !! moze w przyszlosci pozwolic takze na symlinki?
if( db->GetItem(repair_item, iq) == WINIX_ERR_NO_ITEM )
{
log << log3 << "ThreadInfo: there is no a file for thread answer_id: " << answer_id << logend;
tdb->RemoveAnswerOnly(answer_id);
}
}
void ThreadInfo::RepairAnswers(long file_id)
{
tdb->GetAnswers(file_id, repair_answer_tab);
for(size_t i=0 ; i<repair_answer_tab.size() ; ++i)
RepairAnswer(repair_answer_tab[i]);
}
void ThreadInfo::Repair(long file_id)
{
iq.Clear();
iq.SetAll(false, false);
iq.WhereId(file_id);
iq.WhereType(Item::file); // !! moze w przyszlosci pozwolic takze na symlinki?
if( db->GetItem(repair_item, iq) == WINIX_ERR_NO_ITEM )
{
log << log3 << "ThreadInfo: there is no a file for thread file_id: " << file_id << logend;
tdb->RemoveThread(file_id);
}
else
{
RepairAnswers(file_id);
tdb->RecalcThread(file_id);
}
}
void ThreadInfo::Repair()
{
tdb->GetAllThreadsId(repair_id_tab);
for(size_t i=0 ; i<repair_id_tab.size() ; ++i)
Repair(repair_id_tab[i]);
}
void ThreadInfo::MakeRedirectIfPossible(const Item & item)
{
PluginRes res = plugin.Call(WINIX_PL_THREAD_CAN_MAKE_REDIRECT);
if( res.res_false > 0 )
{
log << log4 << "Thread: redirect prevented" << logend;
return;
}
system->RedirectTo(item);
}
} // namespace
} // namespace Winix

View File

@@ -0,0 +1,125 @@
/*
* 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) 2010-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_thread_threadinfo
#define headerfile_winix_plugins_thread_threadinfo
#include <vector>
#include "core/item.h"
#include "core/system.h"
#include "db/db.h"
#include "thread.h"
#include "tdb.h"
namespace Winix
{
namespace Thread
{
class ThreadInfo
{
public:
void SetDb(Db * pdb);
void SetTDb(TDb * ptdb);
void SetSystem(System * psystem);
void Clear();
Item * FindThreadDir();
// id of a mount type
int mount_type_thread;
// enable a thread in a specific directory
// and set sort type (asc, desc)
int mount_par_thread;
// a special directory in which we store the answers
int mount_par_thread_dir;
// id of the current plugin
int plugin_id;
// files in the current directory
// used for 'show_threads' or 'thread' function
std::vector<Item> item_tab;
// additional info to the above files if 'show_threads' is used
// sorted by file_id
std::vector<Thread> thread_tab;
// for sorting
std::vector<Item*> item_sort_tab;
// template index for notifications
size_t template_index;
void RemoveThread(long file_id);
void RemoveThreadAnswer(long answer_id);
// repairing the database
void Repair();
void MakeRedirectIfPossible(const Item & item);
private:
Db * db;
TDb * tdb;
System * system;
std::vector<Item*> out_dir_tab;
std::vector<long> remove_answer_id_tab, repair_id_tab, repair_answer_tab;
Item out_item, repair_item;
DbItemQuery iq;
void RepairAnswer(long answer_id);
void RepairAnswers(long file_id);
void Repair(long file_id);
};
} // namespace
} // namespace Winix
#endif