PageRenderTime 35ms CodeModel.GetById 26ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/llcommon/llliveappconfig.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 80 lines | 39 code | 8 blank | 33 comment | 3 complexity | ff20a5ea67dd2efe3b9873c7755d8b77 MD5 | raw file
 1/** 
 2 * @file llliveappconfig.cpp
 3 * @brief Configuration information for an LLApp that overrides indra.xml
 4 *
 5 * $LicenseInfo:firstyear=2003&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#include "linden_common.h"
28
29#include "llliveappconfig.h"
30
31#include "llapp.h"
32#include "llsd.h"
33#include "llsdserialize.h"
34
35LLLiveAppConfig::LLLiveAppConfig(
36	const std::string& filename,
37	F32 refresh_period,
38	LLApp::OptionPriority priority) :
39	LLLiveFile(filename, refresh_period),
40	mPriority(priority)
41{ }
42
43
44LLLiveAppConfig::~LLLiveAppConfig()
45{ }
46
47// virtual 
48bool LLLiveAppConfig::loadFile()
49{
50	llinfos << "LLLiveAppConfig::loadFile(): reading from "
51		<< filename() << llendl;
52    llifstream file(filename());
53	LLSD config;
54    if (file.is_open())
55    {
56        LLSDSerialize::fromXML(config, file);
57		if(!config.isMap())
58		{
59			llwarns << "Live app config not an map in " << filename()
60				<< " Ignoring the data." << llendl;
61			return false;
62		}
63		file.close();
64    }
65	else
66	{
67		llinfos << "Live file " << filename() << " does not exit." << llendl;
68	}
69	// *NOTE: we do not handle the else case here because we would not
70	// have attempted to load the file unless LLLiveFile had
71	// determined there was a reason to load it. This only happens
72	// when either the file has been updated or it is either suddenly
73	// in existence or has passed out of existence. Therefore, we want
74	// to set the config to an empty config, and return that it
75	// changed.
76
77	LLApp* app = LLApp::instance();
78	if(app) app->setOptionData(mPriority, config);
79	return true;
80}