summaryrefslogtreecommitdiff
path: root/indra/newview/llappviewer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r--indra/newview/llappviewer.cpp246
1 files changed, 173 insertions, 73 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 327a5ad698..f6fe7ecd01 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1,4 +1,4 @@
-/**
+ /**
* @file llappviewer.cpp
* @brief The LLAppViewer class definitions
*
@@ -337,6 +337,46 @@ void init_default_trans_args()
const char *VFS_DATA_FILE_BASE = "data.db2.x.";
const char *VFS_INDEX_FILE_BASE = "index.db2.x.";
+
+struct SettingsFile : public LLInitParam::Block<SettingsFile>
+{
+ Mandatory<std::string> name;
+ Optional<std::string> file_name;
+ Optional<bool> required,
+ persistent;
+ Optional<std::string> file_name_setting;
+
+ SettingsFile()
+ : name("name"),
+ file_name("file_name"),
+ required("required", false),
+ persistent("persistent", true),
+ file_name_setting("file_name_setting")
+ {}
+};
+
+struct SettingsGroup : public LLInitParam::Block<SettingsGroup>
+{
+ Mandatory<std::string> name;
+ Mandatory<S32> path_index;
+ Multiple<SettingsFile> files;
+
+ SettingsGroup()
+ : name("name"),
+ path_index("path_index"),
+ files("file")
+ {}
+};
+
+struct SettingsFiles : public LLInitParam::Block<SettingsFiles>
+{
+ Multiple<SettingsGroup> groups;
+
+ SettingsFiles()
+ : groups("group")
+ {}
+};
+
static std::string gWindowTitle;
LLAppViewer::LLUpdaterInfo *LLAppViewer::sUpdaterInfo = NULL ;
@@ -594,7 +634,8 @@ LLAppViewer::LLAppViewer() :
mRandomizeFramerate(LLCachedControl<bool>(gSavedSettings,"Randomize Framerate", FALSE)),
mPeriodicSlowFrame(LLCachedControl<bool>(gSavedSettings,"Periodic Slow Frame", FALSE)),
mFastTimerLogThread(NULL),
- mUpdater(new LLUpdaterService())
+ mUpdater(new LLUpdaterService()),
+ mSettingsLocationList(NULL)
{
if(NULL != sInstance)
{
@@ -610,6 +651,8 @@ LLAppViewer::LLAppViewer() :
LLAppViewer::~LLAppViewer()
{
+ delete mSettingsLocationList;
+
LLLoginInstance::instance().setUpdaterService(0);
destroyMainloopTimeout();
@@ -1879,85 +1922,80 @@ bool LLAppViewer::initLogging()
bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key,
bool set_defaults)
{
- // Find and vet the location key.
- if(!mSettingsLocationList.has(location_key))
- {
- llerrs << "Requested unknown location: " << location_key << llendl;
- return false;
- }
-
- LLSD location = mSettingsLocationList.get(location_key);
-
- if(!location.has("PathIndex"))
- {
- llerrs << "Settings location is missing PathIndex value. Settings cannot be loaded." << llendl;
- return false;
- }
- ELLPath path_index = (ELLPath)(location.get("PathIndex").asInteger());
- if(path_index <= LL_PATH_NONE || path_index >= LL_PATH_LAST)
+ if (!mSettingsLocationList)
{
- llerrs << "Out of range path index in app_settings/settings_files.xml" << llendl;
- return false;
+ llerrs << "Invalid settings location list" << llendl;
}
- // Iterate through the locations list of files.
- LLSD files = location.get("Files");
- for(LLSD::map_iterator itr = files.beginMap(); itr != files.endMap(); ++itr)
+ LLControlGroup* global_settings = LLControlGroup::getInstance(sGlobalSettingsName);
+ for(LLInitParam::ParamIterator<SettingsGroup>::const_iterator it = mSettingsLocationList->groups.begin(), end_it = mSettingsLocationList->groups.end();
+ it != end_it;
+ ++it)
{
- std::string settings_group = (*itr).first;
- llinfos << "Attempting to load settings for the group " << settings_group
- << " - from location " << location_key << llendl;
+ // skip settings groups that aren't the one we requested
+ if (it->name() != location_key) continue;
- if(!LLControlGroup::getInstance(settings_group))
+ ELLPath path_index = (ELLPath)it->path_index();
+ if(path_index <= LL_PATH_NONE || path_index >= LL_PATH_LAST)
{
- llwarns << "No matching settings group for name " << settings_group << llendl;
- continue;
+ llerrs << "Out of range path index in app_settings/settings_files.xml" << llendl;
+ return false;
}
- LLSD file = (*itr).second;
-
- std::string full_settings_path;
- if(file.has("NameFromSetting"))
+ LLInitParam::ParamIterator<SettingsFile>::const_iterator file_it, end_file_it;
+ for (file_it = it->files.begin(), end_file_it = it->files.end();
+ file_it != end_file_it;
+ ++file_it)
{
- std::string custom_name_setting = file.get("NameFromSetting");
- // *NOTE: Regardless of the group currently being lodaed,
- // this setting is always read from the Global settings.
- if(LLControlGroup::getInstance(sGlobalSettingsName)->controlExists(custom_name_setting))
+ llinfos << "Attempting to load settings for the group " << file_it->name()
+ << " - from location " << location_key << llendl;
+
+ LLControlGroup* settings_group = LLControlGroup::getInstance(file_it->name);
+ if(!settings_group)
{
- std::string file_name =
- LLControlGroup::getInstance(sGlobalSettingsName)->getString(custom_name_setting);
- full_settings_path = file_name;
+ llwarns << "No matching settings group for name " << file_it->name() << llendl;
+ continue;
}
- }
- if(full_settings_path.empty())
- {
- std::string file_name = file.get("Name");
- full_settings_path = gDirUtilp->getExpandedFilename(path_index, file_name);
- }
+ std::string full_settings_path;
- int requirement = 0;
- if(file.has("Requirement"))
- {
- requirement = file.get("Requirement").asInteger();
- }
-
- if(!LLControlGroup::getInstance(settings_group)->loadFromFile(full_settings_path, set_defaults))
- {
- if(requirement == 1)
+ if (file_it->file_name_setting.isProvided()
+ && global_settings->controlExists(file_it->file_name_setting))
{
- llwarns << "Error: Cannot load required settings file from: "
- << full_settings_path << llendl;
- return false;
+ // try to find filename stored in file_name_setting control
+ full_settings_path = global_settings->getString(file_it->file_name_setting);
+ if (!gDirUtilp->fileExists(full_settings_path))
+ {
+ // search in default path
+ full_settings_path = gDirUtilp->getExpandedFilename((ELLPath)path_index, full_settings_path);
+ }
}
else
{
- llinfos << "Cannot load " << full_settings_path << " - No settings found." << llendl;
+ // by default, use specified file name
+ full_settings_path = gDirUtilp->getExpandedFilename((ELLPath)path_index, file_it->file_name());
+ }
+
+ if(settings_group->loadFromFile(full_settings_path, set_defaults, file_it->persistent))
+ { // success!
+ llinfos << "Loaded settings file " << full_settings_path << llendl;
+ }
+ else
+ { // failed to load
+ if(file_it->required)
+ {
+ llerrs << "Error: Cannot load required settings file from: " << full_settings_path << llendl;
+ return false;
+ }
+ else
+ {
+ // only complain if we actually have a filename at this point
+ if (!full_settings_path.empty())
+ {
+ llinfos << "Cannot load " << full_settings_path << " - No settings found." << llendl;
+ }
+ }
}
- }
- else
- {
- llinfos << "Loaded settings file " << full_settings_path << llendl;
}
}
@@ -1967,18 +2005,25 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key,
std::string LLAppViewer::getSettingsFilename(const std::string& location_key,
const std::string& file)
{
- if(mSettingsLocationList.has(location_key))
+ for(LLInitParam::ParamIterator<SettingsGroup>::const_iterator it = mSettingsLocationList->groups.begin(), end_it = mSettingsLocationList->groups.end();
+ it != end_it;
+ ++it)
{
- LLSD location = mSettingsLocationList.get(location_key);
- if(location.has("Files"))
+ if (it->name() == location_key)
{
- LLSD files = location.get("Files");
- if(files.has(file) && files[file].has("Name"))
+ LLInitParam::ParamIterator<SettingsFile>::const_iterator file_it, end_file_it;
+ for (file_it = it->files.begin(), end_file_it = it->files.end();
+ file_it != end_file_it;
+ ++file_it)
{
- return files.get(file).get("Name").asString();
+ if (file_it->name() == file)
+ {
+ return file_it->file_name;
+ }
}
}
}
+
return std::string();
}
@@ -1991,14 +2036,29 @@ bool LLAppViewer::initConfiguration()
{
//Load settings files list
std::string settings_file_list = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "settings_files.xml");
- LLControlGroup settings_control("SettingsFiles");
- llinfos << "Loading settings file list " << settings_file_list << llendl;
- if (0 == settings_control.loadFromFile(settings_file_list))
+ //LLControlGroup settings_control("SettingsFiles");
+ //llinfos << "Loading settings file list " << settings_file_list << llendl;
+ //if (0 == settings_control.loadFromFile(settings_file_list))
+ //{
+ // llerrs << "Cannot load default configuration file " << settings_file_list << llendl;
+ //}
+
+ LLXMLNodePtr root;
+ BOOL success = LLXMLNode::parseFile(settings_file_list, root, NULL);
+ if (!success)
{
llerrs << "Cannot load default configuration file " << settings_file_list << llendl;
}
- mSettingsLocationList = settings_control.getLLSD("Locations");
+ mSettingsLocationList = new SettingsFiles();
+
+ LLXUIParser parser;
+ parser.readXUI(root, *mSettingsLocationList, settings_file_list);
+
+ if (!mSettingsLocationList->validateBlock())
+ {
+ llerrs << "Invalid settings file list " << settings_file_list << llendl;
+ }
// The settings and command line parsing have a fragile
// order-of-operation:
@@ -2107,6 +2167,32 @@ bool LLAppViewer::initConfiguration()
// - load overrides from user_settings
loadSettingsFromDirectory("User");
+
+ if (gSavedSettings.getBOOL("FirstRunThisInstall"))
+ {
+ gSavedSettings.setString("SessionSettingsFile", "settings_minimal.xml");
+ gSavedSettings.setBOOL("FirstRunThisInstall", FALSE);
+ }
+
+ if (clp.hasOption("sessionsettings"))
+ {
+ std::string session_settings_filename = clp.getOption("sessionsettings")[0];
+ gSavedSettings.setString("SessionSettingsFile", session_settings_filename);
+ llinfos << "Using session settings filename: "
+ << session_settings_filename << llendl;
+ }
+ loadSettingsFromDirectory("Session");
+
+ if (clp.hasOption("usersessionsettings"))
+ {
+ std::string user_session_settings_filename = clp.getOption("usersessionsettings")[0];
+ gSavedSettings.setString("UserSessionSettingsFile", user_session_settings_filename);
+ llinfos << "Using user session settings filename: "
+ << user_session_settings_filename << llendl;
+
+ }
+ loadSettingsFromDirectory("UserSession");
+
// - apply command line settings
clp.notify();
@@ -3226,6 +3312,20 @@ static bool finish_quit(const LLSD& notification, const LLSD& response)
}
static LLNotificationFunctorRegistration finish_quit_reg("ConfirmQuit", finish_quit);
+static bool switch_standard_skin_and_quit(const LLSD& notification, const LLSD& response)
+{
+ S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+
+ if (option == 0)
+ {
+ gSavedSettings.setString("SessionSettingsFile", "");
+ LLAppViewer::instance()->requestQuit();
+ }
+ return false;
+}
+
+static LLNotificationFunctorRegistration standard_skin_quit_reg("SwitchToStandardSkinAndQuit", switch_standard_skin_and_quit);
+
void LLAppViewer::userQuit()
{
if (gDisconnected || gViewerWindow->getProgressView()->getVisible())