diff options
author | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
commit | 2a4dea528f670b9bb1f77ef27a8a1dd16603d114 (patch) | |
tree | 95c68e362703c9099d571ecbdc6142b1cda1e005 /linden/indra/llcommon/llindraconfigfile.cpp | |
parent | Second Life viewer sources 1.20.6 (diff) | |
download | meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.zip meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.gz meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.bz2 meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.xz |
Second Life viewer sources 1.20.7
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llcommon/llindraconfigfile.cpp | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llindraconfigfile.cpp b/linden/indra/llcommon/llindraconfigfile.cpp new file mode 100644 index 0000000..7ef1a9b --- /dev/null +++ b/linden/indra/llcommon/llindraconfigfile.cpp | |||
@@ -0,0 +1,107 @@ | |||
1 | /** | ||
2 | * @file llindraconfigfile.cpp | ||
3 | * | ||
4 | * | ||
5 | * This class is an LLLiveFile that has config info for indra | ||
6 | * Currently only whether it's blacklisted | ||
7 | * | ||
8 | * $LicenseInfo:firstyear=2007&license=internal$ | ||
9 | * | ||
10 | * Copyright (c) 2007-2008, Linden Research, Inc. | ||
11 | * | ||
12 | * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of | ||
13 | * this source code is governed by the Linden Lab Source Code Disclosure | ||
14 | * Agreement ("Agreement") previously entered between you and Linden | ||
15 | * Lab. By accessing, using, copying, modifying or distributing this | ||
16 | * software, you acknowledge that you have been informed of your | ||
17 | * obligations under the Agreement and agree to abide by those obligations. | ||
18 | * | ||
19 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
20 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
21 | * COMPLETENESS OR PERFORMANCE. | ||
22 | * $/LicenseInfo$ | ||
23 | */ | ||
24 | |||
25 | #include "llindraconfigfile.h" | ||
26 | |||
27 | #include "llfile.h" | ||
28 | #include "llsd.h" | ||
29 | #include "llsdserialize.h" | ||
30 | #include "llframetimer.h" | ||
31 | |||
32 | static std::string sConfigDir = ""; | ||
33 | static const char indraConfigFileName[] = "indra.xml"; | ||
34 | |||
35 | |||
36 | LLIndraConfigFile::LLIndraConfigFile() | ||
37 | : LLLiveFile(filename(), configFileRefreshRate), | ||
38 | mConfig(LLSD()) | ||
39 | { | ||
40 | } | ||
41 | |||
42 | //static | ||
43 | void LLIndraConfigFile::initClass(const std::string& config_dir) | ||
44 | { | ||
45 | sConfigDir = config_dir; | ||
46 | llinfos << "LLIndraConfigFile::initClass config dir " | ||
47 | << config_dir << "/" << indraConfigFileName << llendl; | ||
48 | } | ||
49 | |||
50 | LLSD LLIndraConfigFile::getConfig(const std::string& config_name) | ||
51 | { | ||
52 | if (sConfigDir.empty()) | ||
53 | { | ||
54 | llerrs << "LLIndraConfigFile::initClass() not called" << llendl; | ||
55 | } | ||
56 | |||
57 | LLFrameTimer::updateFrameTime(); | ||
58 | |||
59 | static LLIndraConfigFile the_file; | ||
60 | the_file.checkAndReload(); | ||
61 | |||
62 | return the_file.mConfig[config_name]; | ||
63 | } | ||
64 | |||
65 | std::string LLIndraConfigFile::filename() | ||
66 | { | ||
67 | std::ostringstream ostr; | ||
68 | |||
69 | ostr << sConfigDir | ||
70 | << "/" << indraConfigFileName; | ||
71 | |||
72 | return ostr.str(); | ||
73 | } | ||
74 | |||
75 | /* virtual */ | ||
76 | void LLIndraConfigFile::loadFile() | ||
77 | { | ||
78 | llinfos << "LLIndraConfigFile::loadFile: reading from " | ||
79 | << filename() << llendl; | ||
80 | |||
81 | LLSD config; | ||
82 | |||
83 | { | ||
84 | llifstream file(filename().c_str()); | ||
85 | if (file.is_open()) | ||
86 | { | ||
87 | LLSDSerialize::fromXML(config, file); | ||
88 | } | ||
89 | |||
90 | if (config.isUndefined()) | ||
91 | { | ||
92 | llinfos << "LLIndraConfigFile::loadFile: file missing, ill-formed," | ||
93 | " or simply undefined; not changing the blacklist" << llendl; | ||
94 | return; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | if (config.isMap()) | ||
99 | { | ||
100 | mConfig = config; | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | llwarns << "LLIndraConfigFile: " << indraConfigFileName << " expects a map; wrong format" << llendl; | ||
105 | return; | ||
106 | } | ||
107 | } | ||