summaryrefslogtreecommitdiff
path: root/indra/newview/llviewernetwork.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewernetwork.cpp')
-rw-r--r--indra/newview/llviewernetwork.cpp213
1 files changed, 125 insertions, 88 deletions
diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp
index c76eee80f7..a81bb2e6f2 100644
--- a/indra/newview/llviewernetwork.cpp
+++ b/indra/newview/llviewernetwork.cpp
@@ -226,11 +226,11 @@ void LLGridManager::initialize(const std::string& grid_file)
LLSD grid = grid_itr->second;
// TODO: Make sure gridfile specified label is not
// a system grid label
- LL_INFOS("GridManager") << "reading: " << key_name << LL_ENDL;
+ LL_DEBUGS("GridManager") << "reading: " << key_name << LL_ENDL;
if (mGridList.has(key_name) &&
mGridList[key_name].has(GRID_IS_SYSTEM_GRID_VALUE))
{
- LL_INFOS("GridManager") << "Cannot override grid " << key_name << " as it's a system grid" << LL_ENDL;
+ LL_DEBUGS("GridManager") << "Cannot override grid " << key_name << " as it's a system grid" << LL_ENDL;
// If the system grid does exist in the grids file, and it's marked as a favorite, set it as a favorite.
if(grid_itr->second.has(GRID_IS_FAVORITE_VALUE) && grid_itr->second[GRID_IS_FAVORITE_VALUE].asBoolean() )
{
@@ -242,7 +242,7 @@ void LLGridManager::initialize(const std::string& grid_file)
try
{
addGrid(grid);
- LL_INFOS("GridManager") << "Added grid: " << key_name << LL_ENDL;
+ LL_DEBUGS("GridManager") << "Added grid: " << key_name << LL_ENDL;
}
catch (...)
{
@@ -260,84 +260,60 @@ void LLGridManager::initialize(const std::string& grid_file)
std::string cmd_line_grid = gSavedSettings.getString("CmdLineGridChoice");
if(!cmd_line_grid.empty())
{
+ // try to find the grid assuming the command line parameter is
+ // the case-insensitive 'label' of the grid. ie 'Agni'
mGrid = getGridByLabel(cmd_line_grid);
+ if(mGrid.empty())
+ {
+ // if we couldn't find it, assume the
+ // requested grid is the actual grid 'name' or index,
+ // which would be the dns name of the grid (for non
+ // linden hosted grids)
+ // If the grid isn't there, that's ok, as it will be
+ // automatically added later.
+ mGrid = cmd_line_grid;
+ }
+
+ }
+ else
+ {
+ // if a grid was not passed in via the command line, grab it from the CurrentGrid setting.
+ // if there's no current grid, that's ok as it'll be either set by the value passed
+ // in via the login uri if that's specified, or will default to maingrid
+ mGrid = gSavedSettings.getString("CurrentGrid");
}
- LL_INFOS("GridManager") << "Grid Name: " << mGrid << LL_ENDL;
- // If a command line login URI was passed in, so we should add the command
- // line grid to the list of grids
-
- LLSD cmd_line_login_uri = gSavedSettings.getLLSD("CmdLineLoginURI");
- if (cmd_line_login_uri.isString())
+ if(mGrid.empty())
{
- LL_INFOS("GridManager") << "adding cmd line login uri" << LL_ENDL;
- // grab the other related URI values
- std::string cmd_line_helper_uri = gSavedSettings.getString("CmdLineHelperURI");
- std::string cmd_line_login_page = gSavedSettings.getString("LoginPage");
+ // no grid was specified so default to maingrid
+ LL_DEBUGS("GridManager") << "Setting grid to MAINGRID as no grid has been specified " << LL_ENDL;
+ mGrid = MAINGRID;
- // we've a cmd line login, so add a grid for the command line,
- // overwriting any existing grids
- LLSD grid = LLSD::emptyMap();
- grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray();
- grid[GRID_LOGIN_URI_VALUE].append(cmd_line_login_uri);
- LL_INFOS("GridManager") << "cmd line login uri: " << cmd_line_login_uri.asString() << LL_ENDL;
- LLURI uri(cmd_line_login_uri.asString());
- if (mGrid.empty())
- {
- // if a grid name was not passed in via the command line,
- // then set the grid name based on the hostname of the
- // login uri
- mGrid = uri.hostName();
- }
-
- grid[GRID_VALUE] = mGrid;
-
- if (mGridList.has(mGrid) && mGridList[mGrid].has(GRID_LABEL_VALUE))
- {
- grid[GRID_LABEL_VALUE] = mGridList[mGrid][GRID_LABEL_VALUE];
- }
- else
- {
- grid[GRID_LABEL_VALUE] = mGrid;
- }
- if(!cmd_line_helper_uri.empty())
- {
- grid[GRID_HELPER_URI_VALUE] = cmd_line_helper_uri;
- }
-
- if(!cmd_line_login_page.empty())
- {
- grid[GRID_LOGIN_PAGE_VALUE] = cmd_line_login_page;
- }
- // if the login page, helper URI value, and so on are not specified,
- // add grid will generate them.
-
- // Also, we will override a system grid if values are passed in via the command
- // line, for testing. These values will not be remembered though.
- if (mGridList.has(mGrid) && mGridList[mGrid].has(GRID_IS_SYSTEM_GRID_VALUE))
- {
- grid[GRID_IS_SYSTEM_GRID_VALUE] = TRUE;
- }
- addGrid(grid);
}
- // if a grid was not passed in via the command line, grab it from the CurrentGrid setting.
- if (mGrid.empty())
+ // generate a 'grid list' entry for any command line parameter overrides
+ // or setting overides that we'll add to the grid list or override
+ // any grid list entries with.
+ LLSD grid = LLSD::emptyMap();
+
+ if(mGridList.has(mGrid))
{
-
- mGrid = gSavedSettings.getString("CurrentGrid");
+ grid = mGridList[mGrid];
}
-
- if (mGrid.empty() || !mGridList.has(mGrid))
+ else
{
- // the grid name was empty, or the grid isn't actually in the list, then set it to the
- // appropriate default.
- LL_INFOS("GridManager") << "Resetting grid as grid name " << mGrid << " is not in the list" << LL_ENDL;
- mGrid = MAINGRID;
+ grid[GRID_VALUE] = mGrid;
+ // add the grid with the additional values, or update the
+ // existing grid if it exists with the given values
+ addGrid(grid);
}
- LL_INFOS("GridManager") << "Selected grid is " << mGrid << LL_ENDL;
- gSavedSettings.setString("CurrentGrid", mGrid);
+ LL_DEBUGS("GridManager") << "Selected grid is " << mGrid << LL_ENDL;
+ setGridChoice(mGrid);
+ if(mGridList[mGrid][GRID_LOGIN_URI_VALUE].isArray())
+ {
+ llinfos << "is array" << llendl;
+ }
}
LLGridManager::~LLGridManager()
@@ -345,6 +321,36 @@ LLGridManager::~LLGridManager()
saveFavorites();
}
+void LLGridManager::getGridInfo(const std::string &grid, LLSD& grid_info)
+{
+
+ grid_info = mGridList[grid];
+
+ // override any grid data with the command line info.
+
+ LLSD cmd_line_login_uri = gSavedSettings.getLLSD("CmdLineLoginURI");
+ if (cmd_line_login_uri.isString())
+ {
+ grid_info[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray();
+ grid_info[GRID_LOGIN_URI_VALUE].append(cmd_line_login_uri);
+ }
+
+ // override the helper uri if it was passed in
+ std::string cmd_line_helper_uri = gSavedSettings.getString("CmdLineHelperURI");
+ if(!cmd_line_helper_uri.empty())
+ {
+ grid_info[GRID_HELPER_URI_VALUE] = cmd_line_helper_uri;
+ }
+
+ // override the login page if it was passed in
+ std::string cmd_line_login_page = gSavedSettings.getString("LoginPage");
+ if(!cmd_line_login_page.empty())
+ {
+ grid_info[GRID_LOGIN_PAGE_VALUE] = cmd_line_login_page;
+ }
+}
+
+
//
// LLGridManager::addGrid - add a grid to the grid list, populating the needed values
// if they're not populated yet.
@@ -401,7 +407,7 @@ void LLGridManager::addGrid(LLSD& grid_data)
grid_data[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_ACCOUNT);
}
- LL_INFOS("GridManager") << "ADDING: " << grid << LL_ENDL;
+ LL_DEBUGS("GridManager") << "ADDING: " << grid << LL_ENDL;
mGridList[grid] = grid_data;
}
}
@@ -467,6 +473,7 @@ std::map<std::string, std::string> LLGridManager::getKnownGrids(bool favorite_on
return result;
}
+
void LLGridManager::setGridChoice(const std::string& grid)
{
// Set the grid choice based on a string.
@@ -477,35 +484,37 @@ void LLGridManager::setGridChoice(const std::string& grid)
// loop through. We could do just a hash lookup but we also want to match
// on label
- for(LLSD::map_iterator grid_iter = mGridList.beginMap();
- grid_iter != mGridList.endMap();
- grid_iter++)
+ std::string grid_name = grid;
+ if(!mGridList.has(grid_name))
{
- if((grid == grid_iter->first) ||
- (grid == grid_iter->second[GRID_LABEL_VALUE].asString()))
- {
- mGrid = grid_iter->second[GRID_VALUE].asString();
- gSavedSettings.setString("CurrentGrid", grid_iter->second[GRID_VALUE]);
- return;
-
- }
+ // case insensitive
+ grid_name = getGridByLabel(grid);
+ }
+
+ if(grid_name.empty())
+ {
+ // the grid was not in the list of grids.
+ LLSD grid_data = LLSD::emptyMap();
+ grid_data[GRID_VALUE] = grid;
+ addGrid(grid_data);
}
- LLSD grid_data = LLSD::emptyMap();
- grid_data[GRID_VALUE] = grid;
- addGrid(grid_data);
mGrid = grid;
gSavedSettings.setString("CurrentGrid", grid);
}
-std::string LLGridManager::getGridByLabel( const std::string &grid_label)
+std::string LLGridManager::getGridByLabel( const std::string &grid_label, bool case_sensitive)
{
for(LLSD::map_iterator grid_iter = mGridList.beginMap();
grid_iter != mGridList.endMap();
grid_iter++)
{
- if (grid_iter->second.has(GRID_LABEL_VALUE) && (grid_iter->second[GRID_LABEL_VALUE].asString() == grid_label))
+ if (grid_iter->second.has(GRID_LABEL_VALUE))
{
- return grid_iter->first;
+ if (0 == (case_sensitive?LLStringUtil::compareStrings(grid_label, grid_iter->second[GRID_LABEL_VALUE].asString()):
+ LLStringUtil::compareInsensitive(grid_label, grid_iter->second[GRID_LABEL_VALUE].asString())))
+ {
+ return grid_iter->first;
+ }
}
}
return std::string();
@@ -514,6 +523,12 @@ std::string LLGridManager::getGridByLabel( const std::string &grid_label)
void LLGridManager::getLoginURIs(std::vector<std::string>& uris)
{
uris.clear();
+ LLSD cmd_line_login_uri = gSavedSettings.getLLSD("CmdLineLoginURI");
+ if (cmd_line_login_uri.isString())
+ {
+ uris.push_back(cmd_line_login_uri);
+ return;
+ }
for (LLSD::array_iterator llsd_uri = mGridList[mGrid][GRID_LOGIN_URI_VALUE].beginArray();
llsd_uri != mGridList[mGrid][GRID_LOGIN_URI_VALUE].endArray();
llsd_uri++)
@@ -522,7 +537,29 @@ void LLGridManager::getLoginURIs(std::vector<std::string>& uris)
}
}
-bool LLGridManager::isInProductionGrid()
+std::string LLGridManager::getHelperURI()
+{
+ std::string cmd_line_helper_uri = gSavedSettings.getString("CmdLineHelperURI");
+ if(!cmd_line_helper_uri.empty())
+ {
+ return cmd_line_helper_uri;
+ }
+ return mGridList[mGrid][GRID_HELPER_URI_VALUE];
+}
+
+std::string LLGridManager::getLoginPage()
+{
+ // override the login page if it was passed in
+ std::string cmd_line_login_page = gSavedSettings.getString("LoginPage");
+ if(!cmd_line_login_page.empty())
+ {
+ return cmd_line_login_page;
+ }
+
+ return mGridList[mGrid][GRID_LOGIN_PAGE_VALUE];
+}
+
+bool LLGridManager::LLGridManager::isInProductionGrid()
{
// *NOTE:Mani This used to compare GRID_INFO_AGNI to gGridChoice,
// but it seems that loginURI trumps that.