mime categories

This commit is contained in:
dockes
2006-12-20 13:12:49 +00:00
parent 071997c6bb
commit 50174005a1
8 changed files with 206 additions and 30 deletions
+33 -10
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.39 2006-12-20 09:54:17 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.40 2006-12-20 13:12:49 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -318,15 +318,27 @@ string RclConfig::getSuffixFromMimeType(const string &mt)
return "";
}
void RclConfig::freeAll()
/** Get list of file categories from mimeconf */
bool RclConfig::getMimeCategories(list<string>& cats)
{
delete m_conf;
delete mimemap;
delete mimeconf;
delete mimeview;
delete STOPSUFFIXES;
// just in case
zeroMe();
if (!mimeconf)
return false;
cats = mimeconf->getNames("categories");
return true;
}
/** Get list of mime types for category from mimeconf */
bool RclConfig::getMimeCatTypes(const string& cat, list<string>& tps)
{
tps.clear();
if (!mimeconf)
return false;
string slist;
if (!mimeconf->get(cat, slist, "categories"))
return false;
stringToStrings(slist, tps);
return true;
}
string RclConfig::getMimeHandlerDef(const std::string &mtype)
@@ -374,7 +386,7 @@ bool RclConfig::setMimeViewerDef(const string& mt, const string& def)
delete mimeview;
mimeview = new ConfStack<ConfTree>("mimeview", cdirs, true);
if (mimeconf == 0 || !mimeconf->ok()) {
if (mimeview == 0 || !mimeview->ok()) {
m_reason = string("No/bad mimeview in: ") + m_confdir;
return false;
}
@@ -562,6 +574,17 @@ bool RclConfig::initUserConfig()
return true;
}
void RclConfig::freeAll()
{
delete m_conf;
delete mimemap;
delete mimeconf;
delete mimeview;
delete STOPSUFFIXES;
// just in case
zeroMe();
}
void RclConfig::initFrom(const RclConfig& r)
{
zeroMe();
+6 -1
View File
@@ -16,7 +16,7 @@
*/
#ifndef _RCLCONFIG_H_INCLUDED_
#define _RCLCONFIG_H_INCLUDED_
/* @(#$Id: rclconfig.h,v 1.29 2006-12-20 09:54:17 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: rclconfig.h,v 1.30 2006-12-20 13:12:49 dockes Exp $ (C) 2004 J.F.Dockes */
#include <list>
#include <string>
@@ -116,6 +116,11 @@ class RclConfig {
/** Get icon name from mimeconf for mimetype */
string getMimeIconName(const string &mtype, string *path = 0);
/** Get list of file categories from mimeconf */
bool getMimeCategories(list<string>&);
/** Get list of mime types for category from mimeconf */
bool getMimeCatTypes(const string& cat, list<string>&);
/** Get a list of all indexable mime types defined in mimemap */
list<string> getAllMimeTypes();