aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llwlparammanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llwlparammanager.cpp128
1 files changed, 61 insertions, 67 deletions
diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp
index 1707fe9..b522284 100644
--- a/linden/indra/newview/llwlparammanager.cpp
+++ b/linden/indra/newview/llwlparammanager.cpp
@@ -106,84 +106,65 @@ LLWLParamManager::~LLWLParamManager()
106 106
107void LLWLParamManager::loadPresets(const std::string& file_name) 107void LLWLParamManager::loadPresets(const std::string& file_name)
108{ 108{
109 // if fileName exists, use legacy loading form the big file, otherwise, search the sky 109 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", ""));
110 // directory, and add the list 110 LL_INFOS2("AppInit", "Shaders") << "Loading Default WindLight settings from " << path_name << LL_ENDL;
111 if(file_name != "") 111
112 bool found = true;
113 while(found)
112 { 114 {
113 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", file_name)); 115 std::string name;
114 LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL; 116 found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false);
115 117 if(found)
116 llifstream presetsXML(path_name);
117
118 if (presetsXML)
119 { 118 {
120 LLSD paramsData(LLSD::emptyMap());
121 119
122 LLPointer<LLSDParser> parser = new LLSDXMLParser(); 120 name=name.erase(name.length()-4);
123 121
124 parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED); 122 // bugfix for SL-46920: preventing filenames that break stuff.
123 char * curl_str = curl_unescape(name.c_str(), name.size());
124 std::string unescaped_name(curl_str);
125 curl_free(curl_str);
126 curl_str = NULL;
125 127
126 LLSD::map_const_iterator endParams = paramsData.endMap(); 128 LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
127 for(LLSD::map_const_iterator curParams = paramsData.beginMap(); 129 loadPreset(unescaped_name,FALSE);
128 curParams != endParams;
129 ++curParams)
130 {
131 addParamSet(curParams->first, curParams->second);
132 }
133 } 130 }
134 } 131 }
135 132
136 // otherwise, search the sky directory and find things there 133 // And repeat for user presets, note the user presets will modify any system presets already loaded
137 else 134
135 std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", ""));
136 LL_INFOS2("AppInit", "Shaders") << "Loading User WindLight settings from " << path_name2 << LL_ENDL;
137
138 found = true;
139 while(found)
138 { 140 {
139 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); 141 std::string name;
140 LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL; 142 found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false);
141 143 if(found)
142 //mParamList.clear();
143
144 bool found = true;
145 while(found)
146 { 144 {
147 std::string name; 145 name=name.erase(name.length()-4);
148 found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); 146
147 // bugfix for SL-46920: preventing filenames that break stuff.
148 char * curl_str = curl_unescape(name.c_str(), name.size());
149 std::string unescaped_name(curl_str);
150 curl_free(curl_str);
151 curl_str = NULL;
149 152
150 LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; 153 LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
151 154 loadPreset(unescaped_name,FALSE);
152 // if we have one
153 if(found)
154 {
155 // bugfix for SL-46920: preventing filenames that break stuff.
156 char * curl_str = curl_unescape(name.c_str(), name.size());
157 std::string unescaped_name(curl_str);
158 curl_free(curl_str);
159 curl_str = NULL;
160
161 // not much error checking here since we're getting rid of this
162 std::string sky_name = unescaped_name.substr(0, unescaped_name.size() - 4);
163
164 std::string cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", name));
165 LL_DEBUGS2("AppInit", "Shaders") << "Loading sky from " << cur_path << LL_ENDL;
166
167 llifstream sky_xml(cur_path);
168 if (sky_xml)
169 {
170 LLSD sky_data(LLSD::emptyMap());
171 LLPointer<LLSDParser> parser = new LLSDXMLParser();
172 parser->parse(sky_xml, sky_data, LLSDSerialize::SIZE_UNLIMITED);
173
174 addParamSet(sky_name, sky_data);
175 sky_xml.close();
176 }
177 }
178 } 155 }
179 } 156 }
157
180} 158}
181 159
182void LLWLParamManager::savePresets(const std::string & fileName) 160void LLWLParamManager::savePresets(const std::string & fileName)
183{ 161{
162 //Nobody currently calls me, but if they did, then its reasonable to write the data out to the user's folder
163 //and not over the RO system wide version.
164
184 LLSD paramsData(LLSD::emptyMap()); 165 LLSD paramsData(LLSD::emptyMap());
185 166
186 std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", fileName)); 167 std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight", fileName));
187 168
188 for(std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.begin(); 169 for(std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.begin();
189 mIt != mParamList.end(); 170 mIt != mParamList.end();
@@ -201,8 +182,9 @@ void LLWLParamManager::savePresets(const std::string & fileName)
201 presetsXML.close(); 182 presetsXML.close();
202} 183}
203 184
204void LLWLParamManager::loadPreset(const std::string & name) 185void LLWLParamManager::loadPreset(const std::string & name,bool propagate)
205{ 186{
187
206 // bugfix for SL-46920: preventing filenames that break stuff. 188 // bugfix for SL-46920: preventing filenames that break stuff.
207 char * curl_str = curl_escape(name.c_str(), name.size()); 189 char * curl_str = curl_escape(name.c_str(), name.size());
208 std::string escaped_filename(curl_str); 190 std::string escaped_filename(curl_str);
@@ -214,7 +196,16 @@ void LLWLParamManager::loadPreset(const std::string & name)
214 std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); 196 std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename));
215 llinfos << "Loading WindLight sky setting from " << pathName << llendl; 197 llinfos << "Loading WindLight sky setting from " << pathName << llendl;
216 198
217 llifstream presetsXML(pathName); 199 llifstream presetsXML;
200 presetsXML.open(pathName.c_str());
201
202 // That failed, try loading from the users area instead.
203 if(!presetsXML)
204 {
205 pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename);
206 llinfos << "Loading User WindLight sky setting from " << pathName << llendl;
207 presetsXML.open(pathName.c_str());
208 }
218 209
219 if (presetsXML) 210 if (presetsXML)
220 { 211 {
@@ -241,10 +232,13 @@ void LLWLParamManager::loadPreset(const std::string & name)
241 return; 232 return;
242 } 233 }
243 234
244 getParamSet(name, mCurParams); 235
245 236 if(propagate)
246 propagateParameters(); 237 {
247} 238 getParamSet(name, mCurParams);
239 propagateParameters();
240 }
241}
248 242
249void LLWLParamManager::savePreset(const std::string & name) 243void LLWLParamManager::savePreset(const std::string & name)
250{ 244{
@@ -258,7 +252,7 @@ void LLWLParamManager::savePreset(const std::string & name)
258 252
259 // make an empty llsd 253 // make an empty llsd
260 LLSD paramsData(LLSD::emptyMap()); 254 LLSD paramsData(LLSD::emptyMap());
261 std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); 255 std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename));
262 256
263 // fill it with LLSD windlight params 257 // fill it with LLSD windlight params
264 paramsData = mParamList[name].getAll(); 258 paramsData = mParamList[name].getAll();
@@ -533,7 +527,7 @@ bool LLWLParamManager::removeParamSet(const std::string& name, bool delete_from_
533 527
534 if(delete_from_disk) 528 if(delete_from_disk)
535 { 529 {
536 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); 530 std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", ""));
537 531
538 // use full curl escaped name 532 // use full curl escaped name
539 char * curl_str = curl_escape(name.c_str(), name.size()); 533 char * curl_str = curl_escape(name.c_str(), name.size());