aboutsummaryrefslogtreecommitdiff
path: root/src/configmanager.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-08-09 07:49:38 +0000
committerMike Buland <eichlan@xagasoft.com>2006-08-09 07:49:38 +0000
commit3b036371ae3edebb53fd878ddc8c916e78ee1279 (patch)
tree44506f23a25fcd511783023f4f28eb1a4a45cab1 /src/configmanager.cpp
parent97e6e0c3bce47da037ce4bbaeb977120f0ce6f5a (diff)
downloadlibbu++-3b036371ae3edebb53fd878ddc8c916e78ee1279.tar.gz
libbu++-3b036371ae3edebb53fd878ddc8c916e78ee1279.tar.bz2
libbu++-3b036371ae3edebb53fd878ddc8c916e78ee1279.tar.xz
libbu++-3b036371ae3edebb53fd878ddc8c916e78ee1279.zip
This may work, now the filenames just need to be changed.
Diffstat (limited to '')
-rw-r--r--src/configmanager.cpp82
1 files changed, 12 insertions, 70 deletions
diff --git a/src/configmanager.cpp b/src/configmanager.cpp
index c3ad695..6c239f8 100644
--- a/src/configmanager.cpp
+++ b/src/configmanager.cpp
@@ -2,39 +2,35 @@
2#include <string.h> 2#include <string.h>
3#include "xmlnode.h" 3#include "xmlnode.h"
4#include "xmlfilereader.h" 4#include "xmlfilereader.h"
5#include "configmanager.h" 5#include "configmanagerbase.h"
6#include "multilog.h"
7#include "multilogtext.h"
8#include "config.h"
9 6
10#ifndef DEF_DEF_LANG 7ConfigManagerBase::ConfigManager()
11# error You must define a default default language in DEF_DEF_LANG 8{
12#endif 9}
13 10
14ConfigManager::ConfigManager() : 11ConfigManagerBase::~ConfigManager()
15 sDefLang( DEF_DEF_LANG )
16{ 12{
17} 13}
18 14
19ConfigManager::~ConfigManager() 15void ConfigManagerBase::addSearchPath( const std::string &sPath )
20{ 16{
17 lSearchPath.push_back( sPath );
21} 18}
22 19
23void ConfigManager::loadConfig( const char *lpProfile ) 20void ConfigManagerBase::loadConfig( const char *lpProfile )
24{ 21{
25 // Try a few locations... 22 // Try a few locations...
26 char *locs[] = {"./" CONFIGNAME, SYSCONFIG, NULL}; 23 std::list<std::string>::const_iterator i;
27 24 for( i = lSearchPath.begin(); i != lSearchPath.end(); i++ )
28 for( int j = 0; locs[j] != NULL; j++ )
29 { 25 {
30 if( parseConfig( locs[j], lpProfile ) ) 26 if( parseConfig( (*i).c_str(), lpProfile ) )
31 { 27 {
32 break; 28 break;
33 } 29 }
34 } 30 }
35} 31}
36 32
37bool ConfigManager::parseConfig( const char *lpFileName, const char *lpProfile ) 33bool ConfigManagerBase::parseConfig( const char *lpFileName, const char *lpProfile )
38{ 34{
39 XmlNode *pRoot, *pCur; 35 XmlNode *pRoot, *pCur;
40 XmlFileReader doc( lpFileName ); 36 XmlFileReader doc( lpFileName );
@@ -65,57 +61,3 @@ bool ConfigManager::parseConfig( const char *lpFileName, const char *lpProfile )
65 return false; 61 return false;
66} 62}
67 63
68bool ConfigManager::processProfile( XmlNode *pBase )
69{
70 XmlNode *pCur;
71
72 for( int j = 0; (pCur = pBase->getChild("listen", j)); j++ )
73 {
74 }
75
76 for( int j = 0; (pCur = pBase->getChild("log", j)); j++ )
77 {
78 if( !strcmp( pCur->getProperty("type"), "text" ) )
79 {
80 int nLevel = atoi( pCur->getProperty("level") );
81 int nArchive = atoi( pCur->getProperty("archive") );
82
83 printf("Adding log file: %s\n", pCur->getProperty("file") );
84
85 MultiLog::getInstance().addChannel(
86 new MultiLogText(
87 pCur->getProperty("file"),
88 pCur->getProperty("format")
89 )
90 );
91 }
92 }
93
94 XmlNode *pDefs;
95 if( pDefs = pBase->getChild("defaults") )
96 {
97 if( pCur = pDefs->getChild("language") )
98 {
99 sDefLang = pCur->getContent();
100 }
101 }
102
103 if( pCur = pBase->getChild("backend") )
104 {
105 sBackend = pCur->getProperty("plugin");
106 sBackend = sBackend;
107 pBackend = pBase->getCopy();
108 }
109
110 return true;
111}
112
113std::string &ConfigManager::getDefLanguage()
114{
115 return sDefLang;
116}
117
118std::string &ConfigManager::getBackend()
119{
120 return sBackend;
121}