changed: mount points

mount type and mount fs are of type 'int' now
they can be added by plugins


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@652 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-09-12 23:33:27 +00:00
parent f48f08a98b
commit 23aedd68b0
36 changed files with 979 additions and 730 deletions

View File

@@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2009, Tomasz Sowa
* Copyright (c) 2009-2010, Tomasz Sowa
* All rights reserved.
*
*/
@@ -10,8 +10,8 @@
#include "mounts.h"
#include "request.h"
#include "log.h"
#include "mountparser.h"
#include "db.h"
#include "plugin.h"
@@ -22,6 +22,57 @@ Mounts::Mounts()
}
void Mounts::CreateMountType()
{
mount_type_cms = AddMountType("cms");
mount_type_thread = AddMountType("thread");
mount_type_ticket = AddMountType("ticket");
}
void Mounts::CreateMountFs()
{
mount_fs_simplefs = AddMountFs("simplefs");
mount_fs_hashfs = AddMountFs("hashfs");
}
void Mounts::CreateMountPar()
{
mount_par_page = AddMountPar("page");
mount_par_thread = AddMountPar("thread");
mount_par_ticket = AddMountPar("ticket");
mount_par_ticket_type = AddMountPar("ticket_type");
mount_par_ticket_type_default = AddMountPar("ticket_type_default");
mount_par_ticket_status = AddMountPar("ticket_status");
mount_par_ticket_status_default = AddMountPar("ticket_status_default");
mount_par_ticket_priority = AddMountPar("ticket_priority");
mount_par_ticket_priority_default = AddMountPar("ticket_priority_default");
mount_par_ticket_category = AddMountPar("ticket_category");
mount_par_ticket_category_default = AddMountPar("ticket_category_default");
mount_par_ticket_expected = AddMountPar("ticket_expected");
mount_par_ticket_expected_default = AddMountPar("ticket_expected_default");
mount_par_createthread_on = AddMountPar("createthread_on");
mount_par_createticket_on = AddMountPar("createticket_on");
mount_par_only_root_remove = AddMountPar("only_root_remove");
mount_par_emacs_on = AddMountPar("emacs_on");
mount_par_mkdir_on = AddMountPar("mkdir_on");
mount_par_app = AddMountPar("app");
mount_par_html_template = AddMountPar("html_template");
}
void Mounts::CreateMounts()
{
CreateMountType();
CreateMountFs();
CreateMountPar();
plugin.Call(WINIX_ADD_MOUNTS);
}
void Mounts::SetDirs(Dirs * pdirs)
{
dirs = pdirs;
@@ -40,12 +91,86 @@ void Mounts::SetRequest(Request * prequest)
int Mounts::AddMountType(const char * type)
{
mount_type_tab.push_back(type);
return static_cast<int>(mount_type_tab.size()) - 1;
}
int Mounts::AddMountType(const std::string & type)
{
return AddMountType(type.c_str());
}
int Mounts::AddMountFs(const char * fs)
{
mount_fs_tab.push_back(fs);
return static_cast<int>(mount_fs_tab.size()) - 1;
}
const std::string & Mounts::GetMountType(int id)
{
if( id < 0 || id >= (int)mount_type_tab.size() )
return empty_str;
return mount_type_tab[id];
}
int Mounts::AddMountFs(const std::string & fs)
{
return AddMountFs(fs.c_str());
}
const std::string & Mounts::GetMountFs(int id)
{
if( id < 0 || id >= (int)mount_fs_tab.size() )
return empty_str;
return mount_fs_tab[id];
}
int Mounts::AddMountPar(const char * par)
{
mount_par_tab.push_back(par);
return static_cast<int>(mount_par_tab.size()) - 1;
}
int Mounts::AddMountPar(const std::string & par)
{
return AddMountPar(par.c_str());
}
const std::string & Mounts::GetMountPar(int id)
{
if( id < 0 || id >= (int)mount_par_tab.size() )
return empty_str;
return mount_par_tab[id];
}
// reading from 'mounts'
Error Mounts::ReadMounts(const std::string & mounts)
{
MountParser mp;
mp.SetDirs(dirs);
Error err = mp.Parse(mounts, mount_tab);
mount_parser.SetDirs(dirs);
mount_parser.SetMountTypeTab(mount_type_tab);
mount_parser.SetMountFsTab(mount_fs_tab);
mount_parser.SetMountParTab(mount_par_tab);
Error err = mount_parser.Parse(mounts, mount_tab);
if( err != WINIX_ERR_OK )
{
@@ -95,8 +220,8 @@ Error Mounts::ReadMounts()
void Mounts::MountCmsForRoot()
{
Mount mount;
mount.type = Mount::cms;
mount.fs = Mount::simplefs;
mount.type = MountTypeCms();
mount.fs = MountFsSimplefs();
Item * proot = dirs->GetRootDir();
@@ -131,8 +256,8 @@ std::vector<Item*>::reverse_iterator i;
if( m != mount_tab.end() )
{
pmount = &(m->second);
log << log2 << "M: current mount point is: " << pmount->TypeToStr()
<< ", fs: " << pmount->FsToStr() << logend;
log << log2 << "M: current mount point is: " << GetMountType(pmount->type)
<< ", fs: " << GetMountFs(pmount->fs) << logend;
return;
}
}
@@ -140,8 +265,8 @@ std::vector<Item*>::reverse_iterator i;
// if nothing was found
// we assume that 'cms' mount point is used
MountCmsForRoot();
log << log2 << "M: current mount point is: " << pmount->TypeToStr() << " (default)"
<< ", fs: " << pmount->FsToStr() << logend;
log << log2 << "M: current mount point is: " << GetMountType(pmount->type) << " (default)"
<< ", fs: " << GetMountFs(pmount->fs) << logend;
}