summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llfilesystem/lldir.cpp33
-rw-r--r--indra/llfilesystem/lldir.h4
-rw-r--r--indra/llui/llfloater.cpp8
-rw-r--r--indra/llui/llfloater.h2
-rw-r--r--indra/llui/llmenubutton.cpp2
-rw-r--r--indra/llui/llpanel.cpp4
-rw-r--r--indra/llui/llpanel.h3
-rw-r--r--indra/llui/lluictrlfactory.cpp4
-rw-r--r--indra/llui/lluictrlfactory.h6
-rw-r--r--indra/llui/llxuiparser.cpp27
-rw-r--r--indra/llxml/llcontrol.cpp24
-rw-r--r--indra/llxml/llcontrol.h2
-rw-r--r--indra/llxml/llxmlnode.cpp78
-rw-r--r--indra/llxml/llxmlnode.h26
-rw-r--r--indra/llxml/llxmltree.cpp45
-rw-r--r--indra/llxml/llxmltree.h4
-rw-r--r--indra/newview/llappviewer.cpp2
-rw-r--r--indra/newview/llblocklist.cpp5
-rw-r--r--indra/newview/llchathistory.cpp6
-rw-r--r--indra/newview/llcommandlineparser.cpp7
-rw-r--r--indra/newview/llfavoritesbar.cpp5
-rw-r--r--indra/newview/llmediactrl.cpp2
-rw-r--r--indra/newview/llnotificationlistitem.cpp2
-rw-r--r--indra/newview/lltoast.cpp2
-rw-r--r--indra/newview/lltoastnotifypanel.cpp4
-rw-r--r--indra/newview/lltoastscriptquestion.cpp2
-rw-r--r--indra/newview/llviewertexturelist.cpp2
27 files changed, 197 insertions, 114 deletions
diff --git a/indra/llfilesystem/lldir.cpp b/indra/llfilesystem/lldir.cpp
index 69b23f9cf8..ee5dec2b77 100644
--- a/indra/llfilesystem/lldir.cpp
+++ b/indra/llfilesystem/lldir.cpp
@@ -71,6 +71,7 @@ LLDir *gDirUtilp = (LLDir *)&gDirUtil;
/// Values for findSkinnedFilenames(subdir) parameter
const char
*LLDir::XUI = "xui",
+ *LLDir::HTML = "html",
*LLDir::TEXTURES = "textures",
*LLDir::SKINBASE = "";
@@ -761,14 +762,13 @@ std::vector<std::string> LLDir::findSkinnedFilenames(const std::string& subdir,
else
{
// We do not recognize this subdir. Investigate.
- std::string subdir_path(add(getDefaultSkinDir(), subdir));
- if (fileExists(add(subdir_path, "en")))
+ if (skinExists(subdir, "en"))
{
// defaultSkinDir/subdir contains subdir "en". That's our
// default language; this subdir is localized.
found = sLocalized.insert(StringMap::value_type(subdir, "en")).first;
}
- else if (fileExists(add(subdir_path, "en-us")))
+ else if (skinExists(subdir, "en-us"))
{
// defaultSkinDir/subdir contains subdir "en-us" but not "en".
// Set as default language; this subdir is localized.
@@ -865,6 +865,33 @@ std::vector<std::string> LLDir::findSkinnedFilenames(const std::string& subdir,
return results;
}
+// virtual
+bool LLDir::skinExists(const std::string& subdir, const std::string& skin) const
+{
+ std::string skin_path(add(getDefaultSkinDir(), subdir, skin));
+ return fileExists(skin_path);
+}
+
+// virtual
+std::string LLDir::getFileContents(const std::string& filename) const
+{
+ LLFILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
+ if (fp)
+ {
+ fseek(fp, 0, SEEK_END);
+ U32 length = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+
+ std::vector<char> buffer(length);
+ size_t nread = fread(buffer.data(), 1, length, fp);
+ fclose(fp);
+
+ return std::string(buffer.data(), nread);
+ }
+
+ return LLStringUtil::null;
+}
+
std::string LLDir::getTempFilename() const
{
LLUUID random_uuid;
diff --git a/indra/llfilesystem/lldir.h b/indra/llfilesystem/lldir.h
index b9a046ba33..d43921c292 100644
--- a/indra/llfilesystem/lldir.h
+++ b/indra/llfilesystem/lldir.h
@@ -72,6 +72,8 @@ class LLDir
// pure virtual functions
virtual std::string getCurPath() = 0;
virtual bool fileExists(const std::string &filename) const = 0;
+ virtual bool skinExists(const std::string& subdir, const std::string &skin) const;
+ virtual std::string getFileContents(const std::string& filename) const;
const std::string findFile(const std::string& filename, const std::vector<std::string> filenames) const;
const std::string findFile(const std::string& filename, const std::string& searchPath1 = "", const std::string& searchPath2 = "", const std::string& searchPath3 = "") const;
@@ -150,7 +152,7 @@ class LLDir
const std::string& filename,
ESkinConstraint constraint=CURRENT_SKIN) const;
/// Values for findSkinnedFilenames(subdir) parameter
- static const char *XUI, *TEXTURES, *SKINBASE;
+ static const char *XUI, *HTML, *TEXTURES, *SKINBASE;
/**
* Return the base-language pathname from findSkinnedFilenames(), or
* the empty string if no such file exists. Parameters are identical to
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 3a6ee50a68..87ab9d0b19 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -3419,12 +3419,16 @@ bool LLFloater::isVisible(const LLFloater* floater)
return floater && floater->getVisible();
}
-bool LLFloater::buildFromFile(const std::string& filename)
+bool LLFloater::buildFromFile(const std::string& filename, bool cacheable)
{
LL_PROFILE_ZONE_SCOPED;
+
+ llassert_msg(!cacheable || !mSingleInstance || !mReuseInstance,
+ "No needs to cache XML for floater with mSingleInstance AND mReuseInstance flags set");
+
LLXMLNodePtr root;
- if (!LLUICtrlFactory::getLayeredXMLNode(filename, root))
+ if (!LLUICtrlFactory::getLayeredXMLNode(filename, root, LLDir::CURRENT_SKIN, cacheable))
{
LL_WARNS() << "Couldn't find (or parse) floater from: " << filename << LL_ENDL;
return false;
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index bc315785d3..50edffbb8d 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -209,7 +209,7 @@ public:
// Don't export top/left for rect, only height/width
static void setupParamsForExport(Params& p, LLView* parent);
- bool buildFromFile(const std::string &filename);
+ bool buildFromFile(const std::string &filename, bool cacheable = false);
boost::signals2::connection setMinimizeCallback( const commit_signal_t::slot_type& cb );
boost::signals2::connection setOpenCallback( const commit_signal_t::slot_type& cb );
diff --git a/indra/llui/llmenubutton.cpp b/indra/llui/llmenubutton.cpp
index 5374b7ea73..85aa766918 100644
--- a/indra/llui/llmenubutton.cpp
+++ b/indra/llui/llmenubutton.cpp
@@ -95,7 +95,7 @@ void LLMenuButton::setMenu(const std::string& menu_filename, EMenuPosition posit
}
llassert(LLMenuGL::sMenuContainer != NULL);
- LLToggleableMenu* menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>(menu_filename, LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance());
+ LLToggleableMenu* menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>(menu_filename, LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance(), true);
if (!menu)
{
LL_WARNS() << "Error loading menu_button menu" << LL_ENDL;
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp
index ba6a31eb9e..bba10bd792 100644
--- a/indra/llui/llpanel.cpp
+++ b/indra/llui/llpanel.cpp
@@ -803,13 +803,13 @@ boost::signals2::connection LLPanel::setVisibleCallback( const commit_signal_t::
//-----------------------------------------------------------------------------
// buildPanel()
//-----------------------------------------------------------------------------
-bool LLPanel::buildFromFile(const std::string& filename, const LLPanel::Params& default_params)
+bool LLPanel::buildFromFile(const std::string& filename, const LLPanel::Params& default_params, bool cacheable)
{
LL_PROFILE_ZONE_SCOPED;
bool didPost = false;
LLXMLNodePtr root;
- if (!LLUICtrlFactory::getLayeredXMLNode(filename, root))
+ if (!LLUICtrlFactory::getLayeredXMLNode(filename, root, LLDir::CURRENT_SKIN, cacheable))
{
LL_WARNS() << "Couldn't parse panel from: " << filename << LL_ENDL;
return didPost;
diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h
index 33883bf6a4..dd73a41132 100644
--- a/indra/llui/llpanel.h
+++ b/indra/llui/llpanel.h
@@ -107,7 +107,8 @@ protected:
public:
typedef std::vector<class LLUICtrl *> ctrl_list_t;
- bool buildFromFile(const std::string &filename, const LLPanel::Params& default_params = getDefaultParams());
+ bool buildFromFile(const std::string &filename, const LLPanel::Params& default_params, bool cacheable = false);
+ bool buildFromFile(const std::string &filename, bool cacheable = false) { return buildFromFile(filename, getDefaultParams(), cacheable); }
static LLPanel* createFactoryPanel(const std::string& name);
diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp
index dca777cc1f..706140fd49 100644
--- a/indra/llui/lluictrlfactory.cpp
+++ b/indra/llui/lluictrlfactory.cpp
@@ -157,7 +157,7 @@ void LLUICtrlFactory::createChildren(LLView* viewp, LLXMLNodePtr node, const wid
// getLayeredXMLNode()
//-----------------------------------------------------------------------------
bool LLUICtrlFactory::getLayeredXMLNode(const std::string &xui_filename, LLXMLNodePtr& root,
- LLDir::ESkinConstraint constraint)
+ LLDir::ESkinConstraint constraint, bool cacheable)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
std::vector<std::string> paths =
@@ -169,7 +169,7 @@ bool LLUICtrlFactory::getLayeredXMLNode(const std::string &xui_filename, LLXMLNo
paths.push_back(xui_filename);
}
- return LLXMLNode::getLayeredXMLNode(root, paths);
+ return LLXMLNode::getLayeredXMLNode(root, paths, cacheable);
}
diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h
index 6e585abfc0..2e1cc75508 100644
--- a/indra/llui/lluictrlfactory.h
+++ b/indra/llui/lluictrlfactory.h
@@ -148,7 +148,7 @@ public:
LLView* createFromXML(LLXMLNodePtr node, LLView* parent, const std::string& filename, const widget_registry_t&, LLXMLNodePtr output_node );
template<typename T>
- static T* createFromFile(const std::string &filename, LLView *parent, const widget_registry_t& registry)
+ static T* createFromFile(const std::string &filename, LLView *parent, const widget_registry_t& registry, bool cacheable = false)
{
T* widget = NULL;
@@ -156,7 +156,7 @@ public:
{
LLXMLNodePtr root_node;
- if (!LLUICtrlFactory::getLayeredXMLNode(filename, root_node))
+ if (!LLUICtrlFactory::getLayeredXMLNode(filename, root_node, LLDir::CURRENT_SKIN, cacheable))
{
LL_WARNS() << "Couldn't parse XUI from path: " << instance().getCurFileName() << ", from filename: " << filename << LL_ENDL;
goto fail;
@@ -192,7 +192,7 @@ fail:
static void createChildren(LLView* viewp, LLXMLNodePtr node, const widget_registry_t&, LLXMLNodePtr output_node = NULL);
static bool getLayeredXMLNode(const std::string &filename, LLXMLNodePtr& root,
- LLDir::ESkinConstraint constraint=LLDir::CURRENT_SKIN);
+ LLDir::ESkinConstraint constraint = LLDir::CURRENT_SKIN, bool cacheable = false);
private:
//NOTE: both friend declarations are necessary to keep both gcc and msvc happy
diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp
index a60ccb537e..84507a58b6 100644
--- a/indra/llui/llxuiparser.cpp
+++ b/indra/llui/llxuiparser.cpp
@@ -28,6 +28,7 @@
#include "llxuiparser.h"
+#include "lldir.h"
#include "llxmlnode.h"
#include "llfasttimer.h"
#ifdef LL_USESYSTEMLIBS
@@ -44,6 +45,7 @@
#include "lluicolor.h"
#include "v3math.h"
+
using namespace BOOST_SPIRIT_CLASSIC_NS;
const S32 MAX_STRING_ATTRIBUTE_SIZE = 40;
@@ -1397,36 +1399,17 @@ bool LLSimpleXUIParser::readXUI(const std::string& filename, LLInitParam::BaseBl
mCurReadDepth = 0;
setParseSilently(silent);
- ScopedFile file(filename, "rb");
- if( !file.isOpen() )
+ std::string xml = gDirUtilp->getFileContents(filename);
+ if (xml.empty())
{
LL_WARNS("ReadXUI") << "Unable to open file " << filename << LL_ENDL;
XML_ParserFree( mParser );
return false;
}
- S32 bytes_read = 0;
-
- S32 buffer_size = file.getRemainingBytes();
- void* buffer = XML_GetBuffer(mParser, buffer_size);
- if( !buffer )
- {
- LL_WARNS("ReadXUI") << "Unable to allocate XML buffer while reading file " << filename << LL_ENDL;
- XML_ParserFree( mParser );
- return false;
- }
-
- bytes_read = (S32)fread(buffer, 1, buffer_size, file.mFile);
- if( bytes_read <= 0 )
- {
- LL_WARNS("ReadXUI") << "Error while reading file " << filename << LL_ENDL;
- XML_ParserFree( mParser );
- return false;
- }
-
mEmptyLeafNode.push_back(false);
- if( !XML_ParseBuffer(mParser, bytes_read, true ) )
+ if (!XML_Parse(mParser, xml.data(), (int)xml.size(), true))
{
LL_WARNS("ReadXUI") << "Error while parsing file " << filename << LL_ENDL;
XML_ParserFree( mParser );
diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp
index e626bac7d0..71ba2b88bc 100644
--- a/indra/llxml/llcontrol.cpp
+++ b/indra/llxml/llcontrol.cpp
@@ -753,13 +753,13 @@ void LLControlGroup::setUntypedValue(std::string_view name, const LLSD& val)
//---------------------------------------------------------------
// Returns number of controls loaded, so 0 if failure
-U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, bool require_declaration, eControlType declare_as)
+U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, const std::string& xml, bool require_declaration, eControlType declare_as)
{
std::string name;
LLXmlTree xml_controls;
- if (!xml_controls.parseFile(filename))
+ if (!xml_controls.parseString(xml))
{
LL_WARNS("Settings") << "Unable to open control file " << filename << LL_ENDL;
return 0;
@@ -772,7 +772,7 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, bool require
return 0;
}
- U32 validitems = 0;
+ U32 validitems = 0;
S32 version;
rootp->getAttributeS32("version", version);
@@ -990,24 +990,24 @@ U32 LLControlGroup::saveToFile(const std::string& filename, bool nondefault_only
U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_values, bool save_values)
{
LLSD settings;
- llifstream infile;
- infile.open(filename.c_str());
- if(!infile.is_open())
+
+ std::string xml = gDirUtilp->getFileContents(filename);
+ if (xml.empty())
{
LL_WARNS("Settings") << "Cannot find file " << filename << " to load." << LL_ENDL;
return 0;
}
- if (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXML(settings, infile))
+ std::stringstream stream(xml);
+ if (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXML(settings, stream))
{
- infile.close();
LL_WARNS("Settings") << "Unable to parse LLSD control file " << filename << ". Trying Legacy Method." << LL_ENDL;
- return loadFromFileLegacy(filename, true, TYPE_STRING);
+ return loadFromFileLegacy(filename, xml, true, TYPE_STRING);
}
U32 validitems = 0;
bool hidefromsettingseditor = false;
-
+
for(LLSD::map_const_iterator itr = settings.beginMap(); itr != settings.endMap(); ++itr)
{
LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT;
@@ -1019,7 +1019,7 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
persist = control_map["Persist"].asInteger()?
LLControlVariable::PERSIST_NONDFT : LLControlVariable::PERSIST_NO;
}
-
+
// Sometimes we want to use the settings system to provide cheap persistence, but we
// don't want the settings themselves to be easily manipulated in the UI because
// doing so can cause support problems. So we have this option:
@@ -1031,7 +1031,7 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
{
hidefromsettingseditor = false;
}
-
+
// If the control exists just set the value from the input file.
LLControlVariable* existing_control = getControl(name);
if(existing_control)
diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h
index a8bc584c48..e148b74292 100644
--- a/indra/llxml/llcontrol.h
+++ b/indra/llxml/llcontrol.h
@@ -300,7 +300,7 @@ public:
// Returns number of controls loaded, 0 if failed
// If require_declaration is false, will auto-declare controls it finds
// as the given type.
- U32 loadFromFileLegacy(const std::string& filename, bool require_declaration = true, eControlType declare_as = TYPE_STRING);
+ U32 loadFromFileLegacy(const std::string& filename, const std::string& xml, bool require_declaration = true, eControlType declare_as = TYPE_STRING);
U32 saveToFile(const std::string& filename, bool nondefault_only);
U32 loadFromFile(const std::string& filename, bool default_values = false, bool save_values = true);
void resetToDefaults();
diff --git a/indra/llxml/llxmlnode.cpp b/indra/llxml/llxmlnode.cpp
index 9c7ac66f01..627e99a1e6 100644
--- a/indra/llxml/llxmlnode.cpp
+++ b/indra/llxml/llxmlnode.cpp
@@ -650,34 +650,56 @@ bool LLXMLNode::updateNode(
return true;
}
-// static
-bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXMLNode* defaults_tree)
+static std::map<std::string, LLXMLNodePtr> sXMLCache;
+static LLSharedMutex sXMLCacheMutex;
+
+static void saveToCache(const std::string& filename, LLXMLNodePtr& node)
{
- // Read file
- LL_DEBUGS("XMLNode") << "parsing XML file: " << filename << LL_ENDL;
- LLFILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
- if (fp == NULL)
- {
- node = NULL ;
- return false;
- }
- fseek(fp, 0, SEEK_END);
- U32 length = ftell(fp);
- fseek(fp, 0, SEEK_SET);
+ LLExclusiveMutexLock lock(&sXMLCacheMutex);
+ sXMLCache.emplace(filename, node.notNull() ? node->deepCopy() : nullptr);
+}
- U8* buffer = new U8[length+1];
- size_t nread = fread(buffer, 1, length, fp);
- buffer[nread] = 0;
- fclose(fp);
+static bool loadFromCache(const std::string& filename, LLXMLNodePtr& node)
+{
+ LLSharedMutexLock lock(&sXMLCacheMutex);
+ auto it = sXMLCache.find(filename);
+ if (it == sXMLCache.end())
+ return false;
+ node = it->second.notNull() ? it->second->deepCopy() : nullptr;
+ return node.notNull();
+}
- bool rv = parseBuffer(buffer, nread, node, defaults_tree);
- delete [] buffer;
- return rv;
+// static
+bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXMLNode* defaults_tree, bool cacheable)
+{
+ // Try to read from cache
+ if (cacheable)
+ {
+ if (loadFromCache(filename, node))
+ return true;
+ }
+
+ std::string xml = gDirUtilp->getFileContents(filename);
+ if (xml.empty())
+ {
+ LL_WARNS("XMLNode") << "no XML file: " << filename << LL_ENDL;
+ }
+ else if (parseBuffer(xml.data(), xml.size(), node, defaults_tree))
+ {
+ if (cacheable)
+ {
+ saveToCache(filename, node);
+ }
+ return true;
+ }
+
+ node = nullptr;
+ return false;
}
// static
bool LLXMLNode::parseBuffer(
- U8* buffer,
+ const char* buffer,
U32 length,
LLXMLNodePtr& node,
LLXMLNode* defaults)
@@ -696,7 +718,7 @@ bool LLXMLNode::parseBuffer(
XML_SetUserData(my_parser, (void *)file_node_ptr);
// Do the parsing
- if (XML_Parse(my_parser, (const char *)buffer, length, true) != XML_STATUS_OK)
+ if (XML_Parse(my_parser, buffer, length, true) != XML_STATUS_OK)
{
LL_WARNS() << "Error parsing xml error code: "
<< XML_ErrorString(XML_GetErrorCode(my_parser))
@@ -824,18 +846,20 @@ bool LLXMLNode::isFullyDefault()
}
// static
-bool LLXMLNode::getLayeredXMLNode(LLXMLNodePtr& root,
- const std::vector<std::string>& paths)
+bool LLXMLNode::getLayeredXMLNode(LLXMLNodePtr& root, const std::vector<std::string>& paths, bool cacheable)
{
- if (paths.empty()) return false;
+ if (paths.empty())
+ {
+ return false;
+ }
std::string filename = paths.front();
if (filename.empty())
{
return false;
}
-
- if (!LLXMLNode::parseFile(filename, root, NULL))
+
+ if (!LLXMLNode::parseFile(filename, root, nullptr, cacheable))
{
LL_WARNS() << "Problem reading UI description file: " << filename << LL_ENDL;
return false;
diff --git a/indra/llxml/llxmlnode.h b/indra/llxml/llxmlnode.h
index d5b8b36d86..32aee057ed 100644
--- a/indra/llxml/llxmlnode.h
+++ b/indra/llxml/llxmlnode.h
@@ -126,34 +126,34 @@ public:
bool isNull();
bool deleteChild(LLXMLNode* child);
- void addChild(LLXMLNodePtr& new_child);
+ void addChild(LLXMLNodePtr& new_child);
void setParent(LLXMLNodePtr& new_parent); // reparent if necessary
- // Serialization
+ // Deserialization
static bool parseFile(
const std::string& filename,
- LLXMLNodePtr& node,
- LLXMLNode* defaults_tree);
+ LLXMLNodePtr& node,
+ LLXMLNode* defaults_tree,
+ bool cacheable = false);
static bool parseBuffer(
- U8* buffer,
+ const char* buffer,
U32 length,
- LLXMLNodePtr& node,
+ LLXMLNodePtr& node,
LLXMLNode* defaults);
static bool parseStream(
std::istream& str,
- LLXMLNodePtr& node,
+ LLXMLNodePtr& node,
LLXMLNode* defaults);
static bool updateNode(
LLXMLNodePtr& node,
LLXMLNodePtr& update_node);
-
- static bool getLayeredXMLNode(LLXMLNodePtr& root, const std::vector<std::string>& paths);
-
-
+
+ static bool getLayeredXMLNode(LLXMLNodePtr& root, const std::vector<std::string>& paths, bool cacheable = false);
+
// Write standard XML file header:
// <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
static void writeHeaderToFile(LLFILE *out_file);
-
+
// Write XML to file with one attribute per line.
// XML escapes values as they are written.
void writeToFile(LLFILE *out_file, const std::string& indent = std::string(), bool use_type_decorations=true);
@@ -237,7 +237,7 @@ public:
// Setters
bool setAttributeString(const char* attr, const std::string& value);
-
+
void setBoolValue(const bool value) { setBoolValue(1, &value); }
void setByteValue(const U8 value, Encoding encoding = ENCODING_DEFAULT) { setByteValue(1, &value, encoding); }
void setIntValue(const S32 value, Encoding encoding = ENCODING_DEFAULT) { setIntValue(1, &value, encoding); }
diff --git a/indra/llxml/llxmltree.cpp b/indra/llxml/llxmltree.cpp
index be3bcf2a66..38321847c3 100644
--- a/indra/llxml/llxmltree.cpp
+++ b/indra/llxml/llxmltree.cpp
@@ -35,6 +35,7 @@
#include "v4math.h"
#include "llquaternion.h"
#include "lluuid.h"
+#include "lldir.h"
//////////////////////////////////////////////////////////////
// LLXmlTree
@@ -60,20 +61,37 @@ void LLXmlTree::cleanup()
mNodeNames.cleanup();
}
+bool LLXmlTree::parseFile(const std::string & filename, bool keep_contents)
+{
+ delete mRoot;
+ mRoot = NULL;
+
+ std::string xml = gDirUtilp->getFileContents(filename);
+ if (xml.empty())
+ {
+ LL_WARNS() << "LLXmlTree parse failed. No XML file: " << filename << LL_ENDL;
+ return false;
+ }
+
+ bool success = parseString(xml, keep_contents);
-bool LLXmlTree::parseFile(const std::string &path, bool keep_contents)
+ return success;
+}
+
+bool LLXmlTree::parseString(const std::string &xml, bool keep_contents)
{
delete mRoot;
mRoot = NULL;
LLXmlTreeParser parser(this);
- bool success = parser.parseFile( path, &mRoot, keep_contents );
- if( !success )
+ bool success = parser.parseString(xml, &mRoot, keep_contents);
+ if (!success)
{
S32 line_number = parser.getCurrentLineNumber();
const char* error = parser.getErrorString();
LL_WARNS() << "LLXmlTree parse failed. Line " << line_number << ": " << error << LL_ENDL;
}
+
return success;
}
@@ -536,6 +554,27 @@ bool LLXmlTreeParser::parseFile(const std::string &path, LLXmlTreeNode** root, b
return success;
}
+bool LLXmlTreeParser::parseString(const std::string& xml, LLXmlTreeNode** root, bool keep_contents)
+{
+ llassert( !mRoot );
+ llassert( !mCurrent );
+
+ mKeepContents = keep_contents;
+
+ bool success = LLXmlParser::parse(xml.data(), (int)xml.size(), true);
+
+ *root = mRoot;
+ mRoot = NULL;
+
+ if (success)
+ {
+ llassert(!mCurrent);
+ }
+
+ mCurrent = NULL;
+
+ return success;
+}
const std::string& LLXmlTreeParser::tabs()
{
diff --git a/indra/llxml/llxmltree.h b/indra/llxml/llxmltree.h
index 5d15c4c7f5..d47f26f731 100644
--- a/indra/llxml/llxmltree.h
+++ b/indra/llxml/llxmltree.h
@@ -56,6 +56,7 @@ public:
void cleanup();
virtual bool parseFile(const std::string &path, bool keep_contents = true);
+ virtual bool parseString(const std::string &xml, bool keep_contents = true);
LLXmlTreeNode* getRoot() { return mRoot; }
@@ -199,7 +200,8 @@ public:
LLXmlTreeParser(LLXmlTree* tree);
virtual ~LLXmlTreeParser();
- bool parseFile(const std::string &path, LLXmlTreeNode** root, bool keep_contents );
+ bool parseFile(const std::string &path, LLXmlTreeNode** root, bool keep_contents);
+ bool parseString(const std::string &xml, LLXmlTreeNode** root, bool keep_contents);
protected:
const std::string& tabs();
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 518b606b44..8865d53f88 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -2978,7 +2978,7 @@ void LLAppViewer::initStrings()
{
std::string strings_file = "strings.xml";
std::string strings_path_full = gDirUtilp->findSkinnedFilenameBaseLang(LLDir::XUI, strings_file);
- if (strings_path_full.empty() || !LLFile::isfile(strings_path_full))
+ if (strings_path_full.empty() || !gDirUtilp->fileExists(strings_path_full))
{
if (strings_path_full.empty())
{
diff --git a/indra/newview/llblocklist.cpp b/indra/newview/llblocklist.cpp
index 29be2aaa6d..16db32862d 100644
--- a/indra/newview/llblocklist.cpp
+++ b/indra/newview/llblocklist.cpp
@@ -61,8 +61,9 @@ LLBlockList::LLBlockList(const Params& p)
LLToggleableMenu* context_menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>(
"menu_people_blocked_gear.xml",
gMenuHolder,
- LLViewerMenuHolderGL::child_registry_t::instance());
- if(context_menu)
+ LLViewerMenuHolderGL::child_registry_t::instance(),
+ true);
+ if (context_menu)
{
mContextMenu = context_menu->getHandle();
}
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index e1140e77fd..0b7cdd1db4 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -131,7 +131,7 @@ public:
static LLChatHistoryHeader* createInstance(const std::string& file_name)
{
LLChatHistoryHeader* pInstance = new LLChatHistoryHeader;
- pInstance->buildFromFile(file_name);
+ pInstance->buildFromFile(file_name, true);
return pInstance;
}
@@ -587,7 +587,7 @@ public:
mUserNameTextBox = getChild<LLTextBox>("user_name");
mTimeBoxTextBox = getChild<LLTextBox>("time_box");
- mInfoCtrl = LLUICtrlFactory::getInstance()->createFromFile<LLUICtrl>("inspector_info_ctrl.xml", this, LLPanel::child_registry_t::instance());
+ mInfoCtrl = LLUICtrlFactory::getInstance()->createFromFile<LLUICtrl>("inspector_info_ctrl.xml", this, LLPanel::child_registry_t::instance(), true);
if (mInfoCtrl)
{
mInfoCtrl->setCommitCallback(boost::bind(&LLChatHistoryHeader::onClickInfoCtrl, mInfoCtrl));
@@ -1179,7 +1179,7 @@ void LLChatHistory::initFromParams(const LLChatHistory::Params& p)
LLView* LLChatHistory::getSeparator()
{
- LLPanel* separator = LLUICtrlFactory::getInstance()->createFromFile<LLPanel>(mMessageSeparatorFilename, NULL, LLPanel::child_registry_t::instance());
+ LLPanel* separator = LLUICtrlFactory::getInstance()->createFromFile<LLPanel>(mMessageSeparatorFilename, NULL, LLPanel::child_registry_t::instance(), true);
return separator;
}
diff --git a/indra/newview/llcommandlineparser.cpp b/indra/newview/llcommandlineparser.cpp
index bc61fac00b..030d24bed8 100644
--- a/indra/newview/llcommandlineparser.cpp
+++ b/indra/newview/llcommandlineparser.cpp
@@ -657,12 +657,11 @@ void LLControlGroupCLP::configure(const std::string& config_filename, LLControlG
// This method reads the llsd based config file, and uses it to set
// members of a control group.
LLSD clpConfigLLSD;
-
- llifstream input_stream;
- input_stream.open(config_filename.c_str(), std::ios::in | std::ios::binary);
- if(input_stream.is_open())
+ std::string xml = gDirUtilp->getFileContents(config_filename);
+ if (!xml.empty())
{
+ std::stringstream input_stream(xml);
LLSDSerialize::fromXML(clpConfigLLSD, input_stream);
for(LLSD::map_iterator option_itr = clpConfigLLSD.beginMap();
option_itr != clpConfigLLSD.endMap();
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index 6f689a5dd9..220ca69a47 100644
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -860,10 +860,11 @@ const LLButton::Params& LLFavoritesBarCtrl::getButtonParams()
if (!params_initialized)
{
LLXMLNodePtr button_xml_node;
- if(LLUICtrlFactory::getLayeredXMLNode("favorites_bar_button.xml", button_xml_node))
+ static const std::string filename("favorites_bar_button.xml");
+ if (LLUICtrlFactory::getLayeredXMLNode(filename, button_xml_node, LLDir::CURRENT_SKIN, true))
{
LLXUIParser parser;
- parser.readXUI(button_xml_node, button_params, "favorites_bar_button.xml");
+ parser.readXUI(button_xml_node, button_params, filename);
}
params_initialized = true;
}
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index 5461f98624..72fbab406b 100644
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -633,7 +633,7 @@ void LLMediaCtrl::navigateTo( std::string url_in, std::string mime_type, bool cl
void LLMediaCtrl::navigateToLocalPage( const std::string& subdir, const std::string& filename_in )
{
std::string filename(gDirUtilp->add(subdir, filename_in));
- std::string expanded_filename = gDirUtilp->findSkinnedFilename("html", filename);
+ std::string expanded_filename = gDirUtilp->findSkinnedFilename(LLDir::HTML, filename);
if (expanded_filename.empty())
{
diff --git a/indra/newview/llnotificationlistitem.cpp b/indra/newview/llnotificationlistitem.cpp
index 75edac105a..79a90c4f4c 100644
--- a/indra/newview/llnotificationlistitem.cpp
+++ b/indra/newview/llnotificationlistitem.cpp
@@ -594,7 +594,7 @@ LLSystemNotificationListItem::LLSystemNotificationListItem(const Params& p)
mSystemNotificationIcon(NULL),
mIsCaution(false)
{
- buildFromFile("panel_notification_list_item.xml");
+ buildFromFile("panel_notification_list_item.xml", true);
mIsCaution = p.notification_priority >= NOTIFICATION_PRIORITY_HIGH;
if (mIsCaution)
{
diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp
index f6fadf276c..5cf2e89c63 100644
--- a/indra/newview/lltoast.cpp
+++ b/indra/newview/lltoast.cpp
@@ -119,7 +119,7 @@ LLToast::LLToast(const LLToast::Params& p)
{
mTimer.reset(new LLToastLifeTimer(this, p.lifetime_secs));
- buildFromFile("panel_toast.xml");
+ buildFromFile("panel_toast.xml", true);
setCanDrag(false);
diff --git a/indra/newview/lltoastnotifypanel.cpp b/indra/newview/lltoastnotifypanel.cpp
index 1f6a88cd95..f7bebf08aa 100644
--- a/indra/newview/lltoastnotifypanel.cpp
+++ b/indra/newview/lltoastnotifypanel.cpp
@@ -266,9 +266,9 @@ void LLToastNotifyPanel::init( LLRect rect, bool show_images )
LLRect current_rect = getRect();
setXMLFilename("");
- buildFromFile("panel_notification.xml");
+ buildFromFile("panel_notification.xml", true);
- if(rect != LLRect::null)
+ if (rect != LLRect::null)
{
this->setShape(rect);
}
diff --git a/indra/newview/lltoastscriptquestion.cpp b/indra/newview/lltoastscriptquestion.cpp
index f6fc9e7889..49fbf885eb 100644
--- a/indra/newview/lltoastscriptquestion.cpp
+++ b/indra/newview/lltoastscriptquestion.cpp
@@ -37,7 +37,7 @@ LLToastScriptQuestion::LLToastScriptQuestion(const LLNotificationPtr& notificati
:
LLToastPanel(notification)
{
- buildFromFile("panel_script_question_toast.xml");
+ buildFromFile("panel_script_question_toast.xml", true);
}
bool LLToastScriptQuestion::postBuild()
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index cea9c91295..57daeccaf7 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -407,7 +407,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromFile(const std::string&
return NULL ;
}
- std::string full_path = gDirUtilp->findSkinnedFilename("textures", filename);
+ std::string full_path = gDirUtilp->findSkinnedFilename(LLDir::TEXTURES, filename);
if (full_path.empty())
{
LL_WARNS() << "Failed to find local image file: " << filename << LL_ENDL;