rewritten: plugin 'menu'

now we have a cache for the plugin
           (this limits the number of database requests)
added:     to plugin 'menu'
           menu_dir_tab can have a 'current' parameter (first argument)
           (it uses the last path from the previous menu_dir_tab) 
changed:   updated to the new EZC api
added:     new message to plugins: WINIX_DIR_ADDED


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@808 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-02-24 12:09:38 +00:00
parent 97c7edafd6
commit a45fb30e0a
11 changed files with 632 additions and 304 deletions

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* Copyright (c) 2011-2012, Tomasz Sowa
* All rights reserved.
*
*/
@@ -10,7 +10,7 @@
#include "core/log.h"
#include "core/plugin.h"
#include "cache.h"
extern "C" void Init(PluginInfo &);
@@ -24,7 +24,7 @@ namespace Menu
const wchar_t plugin_name[] = L"menu";
int mount_par_menu_skip = -1;
Cache cache;
void AddMountParams(PluginInfo & info)
@@ -53,6 +53,36 @@ void FstabChanged(PluginInfo & info)
*/
}
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 AddEzcFunctions(PluginInfo & info);
@@ -67,10 +97,26 @@ 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);
info.p1 = (void*)(plugin_name);
}