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

View File

@@ -0,0 +1 @@
o = cache.o init.o templates.o

View File

@@ -0,0 +1,127 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "cache.h"
#include "core/misc.h"
namespace Winix
{
namespace Menu
{
void Cache::SetDirs(Dirs * pdirs)
{
dirs = pdirs;
}
CacheItem * Cache::Get(long dir_id, int param)
{
Tab::iterator i;
for(i=tab.begin() ; i!=tab.end() ; ++i)
{
if( i->dir_id == dir_id && i->param == param )
{
return &(*i);
}
}
return 0;
}
CacheItem * Cache::Insert(long dir_id, int param)
{
empty_cache_item.dir_id = dir_id;
empty_cache_item.param = param;
empty_cache_item.menu_items.clear();
if( !dirs->MakePath(dir_id, empty_cache_item.dir) )
empty_cache_item.dir.clear();
NoLastSlash(empty_cache_item.dir);
tab.push_back(empty_cache_item);
return &tab.back();
}
void Cache::Remove(long dir_id)
{
Tab::iterator i;
for(i=tab.begin() ; i!=tab.end() ; )
{
if( i->dir_id == dir_id )
{
tab.erase(i++);
}
else
{
++i;
}
}
}
void Cache::Clear()
{
tab.clear();
}
} // namespace
} // namespace Winix

105
winixd/plugins/menu/cache.h Normal file
View File

@@ -0,0 +1,105 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2012-2014, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_winix_plugins_menu_cache
#define headerfile_winix_plugins_menu_cache
#include <string>
#include <vector>
#include <list>
#include "core/item.h"
#include "core/dirs.h"
namespace Winix
{
namespace Menu
{
struct MenuItem
{
long id; // item id
std::wstring url;
std::wstring subject;
PT::Space meta;
Item::Type type;
int file_type;
};
struct CacheItem
{
long dir_id;
int param;
std::vector<MenuItem> menu_items;
std::wstring dir; // without the last slash
CacheItem()
{
dir_id = -1;
param = -1;
}
};
class Cache
{
public:
void SetDirs(Dirs * pdirs);
CacheItem * Get(long dir_id, int param);
CacheItem * Insert(long dir_id, int param);
void Remove(long dir_id);
void Clear();
private:
Dirs * dirs;
typedef std::list<CacheItem> Tab;
Tab tab;
CacheItem empty_cache_item;
};
} // namespace
} // namespace Winix
#endif

View File

@@ -0,0 +1,172 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2011-2014, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "core/log.h"
#include "core/plugin.h"
#include "cache.h"
namespace Winix
{
extern "C" void Init(PluginInfo &);
namespace Menu
{
const wchar_t plugin_name[] = L"menu";
int mount_par_menu_skip = -1;
Cache cache;
void AddMountParams(PluginInfo & info)
{
using TemplatesFunctions::system;
mount_par_menu_skip = system->mounts.AddMountPar(L"menu_skip");
}
void FstabChanged(PluginInfo & info)
{
if( mount_par_menu_skip == -1 )
return;
/*
// GetMountTab() returns a const pointer so we cannot sort menu_skip parameters
// may change it to non-const in the future?
const Mounts::MountTab * mt = system->mounts.GetMountTab();
Mounts::MountTab::const_iterator i;
for(i = mt->begin() ; i != mt->end() ; ++i)
SortMenuSkip(i->second);
*/
}
void InvalidateCache(long dir_id)
{
log << log4 << "Menu: removing cache for dir id: " << dir_id << logend;
cache.Remove(dir_id);
}
void InvalidateCacheByPointerParent(PluginInfo & info)
{
Item * pitem = reinterpret_cast<Item*>(info.p1);
if( pitem )
InvalidateCache(pitem->parent_id);
}
void InvalidateCacheByPointer(PluginInfo & info)
{
Item * pitem = reinterpret_cast<Item*>(info.p1);
if( pitem )
InvalidateCache(pitem->id);
}
void InvalidateCacheById(PluginInfo & info)
{
InvalidateCache(info.l1);
}
void ProcessRequest(PluginInfo & info)
{
if( info.cur->request->function == &info.functions->fun_reload )
{
if( info.cur->request->IsParam(L"menu") )
{
cache.Clear();
log << log3 << "Menu: cache has been cleared" << logend;
}
}
}
void AddEzcFunctions(PluginInfo & info);
} // namespace
void Init(PluginInfo & info)
{
using namespace Menu;
cache.SetDirs(&info.system->dirs);
plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
plugin.Assign(WINIX_ADD_MOUNTS, AddMountParams);
plugin.Assign(WINIX_FSTAB_CHANGED, FstabChanged);
// !! IMPROVE ME
// use modify parameter from a directory
// (not implemented yet)
plugin.Assign(WINIX_FILE_REMOVED, InvalidateCacheByPointerParent);
plugin.Assign(WINIX_DIR_ADDED, InvalidateCacheByPointerParent);
plugin.Assign(WINIX_DIR_PREPARE_TO_REMOVE, InvalidateCacheByPointerParent);
plugin.Assign(WINIX_DIR_REMOVED, InvalidateCacheById);
plugin.Assign(WINIX_FILE_ADDED, InvalidateCacheByPointerParent);
plugin.Assign(WINIX_FILE_CHANGED, InvalidateCacheByPointerParent);
plugin.Assign(WINIX_FILE_COPIED, InvalidateCacheByPointerParent);
plugin.Assign(WINIX_FILE_PREPARE_TO_MOVE, InvalidateCacheByPointerParent);
plugin.Assign(WINIX_FILE_MOVED, InvalidateCacheByPointerParent);
plugin.Assign(WINIX_DIR_CONTENT_SORTED, InvalidateCacheByPointer);
plugin.Assign(WINIX_PROCESS_REQUEST, ProcessRequest);
// !! IMPROVE ME
// we need a WINIX_DIR_CHANGED message
// for example when changing the subject of a directory
info.p1 = (void*)(plugin_name);
}
} // namespace Winix

View File

@@ -0,0 +1,568 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2011-2015, 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 "templates/templates.h"
#include "core/plugin.h"
#include "core/item.h"
#include "core/log.h"
#include "core/misc.h"
#include "cache.h"
#include "templates/miscspace.h"
namespace Winix
{
#define WINIX_PL_MENU_PARAM_NONE 0
#define WINIX_PL_MENU_PARAM_IMAGES 1
#define WINIX_PL_MENU_PARAM_DIRS 2
#define WINIX_PL_MENU_PARAM_FILES 3
namespace Menu
{
using namespace TemplatesFunctions;
using TemplatesFunctions::system;
extern int mount_par_menu_skip;
extern Cache cache;
static Ezc::Stack * stack = &empty_stack;
static DbItemQuery iq;
static std::vector<Item> item_tab;
static MenuItem menu_item;
struct StackItem : public Ezc::FunData
{
CacheItem * citem;
StackItem(CacheItem * ci)
{
citem = ci;
}
};
int string_to_param(const std::wstring & param, bool use_log = true)
{
if( param == L"images" )
return WINIX_PL_MENU_PARAM_IMAGES;
else
if( param == L"dirs" )
return WINIX_PL_MENU_PARAM_DIRS;
else
if( param == L"files" )
return WINIX_PL_MENU_PARAM_FILES;
else
if( !param.empty() )
{
if( use_log )
log << log1 << "Menu: unknown parameter: " << param << logend;
}
return WINIX_PL_MENU_PARAM_NONE;
}
void read_from_db(long dir_id, int param, bool with_meta)
{
iq.SetAll(false, false);
iq.sel_subject = true;
iq.sel_url = true;
iq.sel_sort_index = true;
iq.sort_date_asc = false; // !! FIXED ME we need an option for this
iq.sel_type = true;
iq.sel_file = true;
iq.sel_meta = with_meta;
iq.WhereParentId(dir_id);
if( param == WINIX_PL_MENU_PARAM_IMAGES )
{
iq.WhereType(Item::file);
iq.WhereFileType(WINIX_ITEM_FILETYPE_IMAGE);
}
else
if( param == WINIX_PL_MENU_PARAM_DIRS )
{
iq.WhereType(Item::dir);
}
else
if( param == WINIX_PL_MENU_PARAM_FILES )
{
iq.WhereType(Item::file);
}
db->GetItems(item_tab, iq);
log << log4 << "Menu: loaded directories/files from the database for parent_id: "
<< dir_id << logend;
}
// !! IMPROVE ME
// O(n^2) complexity
void skip_mount_items(CacheItem & citem)
{
Mount * m = system->mounts.CalcMount(citem.dir_id);
if( !m || mount_par_menu_skip==-1 || !m->param[mount_par_menu_skip].defined )
return;
const Mount::ParamRow::ParamArg & arg = m->param[mount_par_menu_skip].arg;
for(size_t i=0 ; i<arg.size() ; ++i)
{
for(size_t x=0 ; x<citem.menu_items.size() ; )
{
if( citem.menu_items[x].url == arg[i] )
citem.menu_items.erase(citem.menu_items.begin() + x);
else
x += 1;
}
}
}
void skip_static_files(CacheItem & citem)
{
for(size_t x=0 ; x<citem.menu_items.size() ; )
{
if( citem.menu_items[x].type == Item::file && citem.menu_items[x].file_type != WINIX_ITEM_FILETYPE_NONE )
citem.menu_items.erase(citem.menu_items.begin() + x);
else
x += 1;
}
}
void copy_items(CacheItem & citem)
{
size_t new_size = citem.menu_items.size() + item_tab.size();
if( new_size > citem.menu_items.capacity() )
citem.menu_items.reserve(new_size);
for(size_t i=0 ; i < item_tab.size() ; ++i)
{
menu_item.id = item_tab[i].id;
menu_item.subject = item_tab[i].subject;
menu_item.url = item_tab[i].url;
menu_item.meta = item_tab[i].meta;
menu_item.type = item_tab[i].type;
menu_item.file_type = item_tab[i].file_type;
citem.menu_items.push_back(menu_item);
}
}
void menu_dir_init(Info & i, long dir_id, int param, bool with_meta)
{
CacheItem * citem = cache.Get(dir_id, param);
if( !citem )
{
read_from_db(dir_id, param, with_meta);
citem = cache.Insert(dir_id, param);
copy_items(*citem);
skip_mount_items(*citem);
if( param == WINIX_PL_MENU_PARAM_NONE )
skip_static_files(*citem);
}
i.stack.fun_data = new StackItem(citem);
}
void menu_dir_init(Info & i, const std::wstring & dir, int param, bool with_meta)
{
Item * pdir = system->dirs.GetDir(dir);
if( pdir )
{
menu_dir_init(i, pdir->id, param, with_meta);
}
else
{
log << log1 << "Menu: there is not such a directory: " << dir << logend;
}
}
void menu_dir_init(Info & i)
{
int param = WINIX_PL_MENU_PARAM_NONE;
bool with_meta = false;
if( i.params.size() >= 2 )
param = string_to_param(i.params[1].str);
if( i.params.size() >=3 && i.params[2].str == L"withmeta" )
with_meta = true;
if( i.params.empty() || i.params[0].str.empty() )
{
menu_dir_init(i, cur->request->dir_tab.back()->id, param, with_meta);
}
else
if( !i.params.empty() )
{
if( i.params[0].str == L"current" )
{
if( stack->fun_data )
{
StackItem * previous_sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < previous_sitem->citem->menu_items.size() )
menu_dir_init(i, previous_sitem->citem->menu_items[stack->iter].id, param, with_meta);
}
}
else
if( i.params[0].str == L"this" )
{
menu_dir_init(i, cur->request->dir_tab.back()->id, param, with_meta);
}
else
if( !i.params[0].str.empty() && i.params[0].str[0] != '/' )
{
log << log1 << "Menu: path for a menu should not be relative" << logend;
return;
}
else
{
menu_dir_init(i, i.params[0].str, param, with_meta);
}
}
}
void menu_dir_tab(Info & i)
{
if( !i.stack.fun_data )
menu_dir_init(i);
if( i.stack.fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(i.stack.fun_data);
i.res = (i.stack.iter < sitem->citem->menu_items.size());
}
//
// we have 'current' items so we should remember the stack only from [for] statements
// this allows:
// [for menu_dir_tab "/path"]
// [if menu_dir_tab "current"] (here do not remember the stack)
// [for menu_dir_tab "current"]
// work correctly
// [end]
// [end]
// [end]
//
if( i.is_for )
stack = &i.stack;
}
void menu_dir_tab_index(Info & i)
{
i.out << stack->iter;
}
void menu_dir_tab_subject(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
i.out << sitem->citem->menu_items[stack->iter].subject;
}
}
void menu_dir_tab_url(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
i.out << sitem->citem->menu_items[stack->iter].url;
}
}
void menu_dir_tab_link(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
i.out << sitem->citem->dir << '/'
<< sitem->citem->menu_items[stack->iter].url;
}
}
void menu_dir_tab_meta_str(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
sitem->citem->menu_items[stack->iter].meta.Serialize(i.out, true, false);
}
}
void menu_dir_tab_meta(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
space(i, sitem->citem->menu_items[stack->iter].meta);
}
}
void menu_dir_tab_meta_tab(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
spaces_tab(i, sitem->citem->menu_items[stack->iter].meta);
}
}
void menu_dir_tab_meta_tab_value(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
spaces_tab_value(i, sitem->citem->menu_items[stack->iter].meta);
}
}
void menu_dir_tab_meta_tab_has_next(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
spaces_tab_has_next(i, sitem->citem->menu_items[stack->iter].meta);
}
}
void menu_dir_tab_is_dir(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
i.res = (sitem->citem->menu_items[stack->iter].type == Item::dir);
}
}
void menu_dir_tab_is_file(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
i.res = (sitem->citem->menu_items[stack->iter].type == Item::file);
}
}
void menu_dir_tab_is_symlink(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
i.res = (sitem->citem->menu_items[stack->iter].type == Item::symlink);
}
}
void menu_dir_tab_is_current(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
i.res = (sitem->citem->menu_items[stack->iter].id == cur->request->last_item->id);
}
}
void menu_dir_tab_is_current_the_same_dir(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
i.res = (sitem->citem->menu_items[stack->iter].id == cur->request->dir_tab.back()->id);
}
}
// returning true if the dir tab element is a first parent for current item
void menu_dir_tab_is_first_parent_for_current_item(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
i.res = (sitem->citem->menu_items[stack->iter].id == cur->request->last_item->parent_id);
}
}
// returning true if the dir tab element is a parent for current item
// (it don't have to be the first parent - it can be a descendant)
void menu_dir_tab_is_parent_for_current_item(Info & i)
{
if( stack->fun_data )
{
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
if( stack->iter < sitem->citem->menu_items.size() )
{
size_t len = cur->request->dir_tab.size(); // at least one
if( !cur->request->is_item )
{
// the last item is a directory so we don't get it into account
len -= 1;
}
for(size_t a=0 ; a<len ; ++a)
{
if( sitem->citem->menu_items[stack->iter].id == cur->request->dir_tab[a]->id )
{
i.res = true;
break;
}
}
}
}
}
void AddEzcFunctions(PluginInfo & info)
{
using TemplatesFunctions::EzcFun;
EzcFun * fun = reinterpret_cast<EzcFun*>(info.p1);
fun->Insert("menu_dir_tab", menu_dir_tab);
fun->Insert("menu_dir_tab_index", menu_dir_tab_index);
fun->Insert("menu_dir_tab_subject", menu_dir_tab_subject);
fun->Insert("menu_dir_tab_url", menu_dir_tab_url);
fun->Insert("menu_dir_tab_link", menu_dir_tab_link);
fun->Insert("menu_dir_tab_meta_str", menu_dir_tab_meta_str);
fun->Insert("menu_dir_tab_meta", menu_dir_tab_meta);
fun->Insert("menu_dir_tab_meta_tab", menu_dir_tab_meta_tab);
fun->Insert("menu_dir_tab_meta_tab_value", menu_dir_tab_meta_tab_value);
fun->Insert("menu_dir_tab_meta_tab_has_next", menu_dir_tab_meta_tab_has_next);
fun->Insert("menu_dir_tab_is_dir", menu_dir_tab_is_dir);
fun->Insert("menu_dir_tab_is_file", menu_dir_tab_is_file);
fun->Insert("menu_dir_tab_is_symlink", menu_dir_tab_is_symlink);
fun->Insert("menu_dir_tab_is_current", menu_dir_tab_is_current);
fun->Insert("menu_dir_tab_is_current_the_same_dir", menu_dir_tab_is_current_the_same_dir);
fun->Insert("menu_dir_tab_is_first_parent_for_current_item", menu_dir_tab_is_first_parent_for_current_item);
fun->Insert("menu_dir_tab_is_parent_for_current_item", menu_dir_tab_is_parent_for_current_item);
}
} // namespace
} // namespace Winix