summaryrefslogtreecommitdiff
path: root/indra/newview/llviewernetwork.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2012-07-30 19:10:46 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2012-07-30 19:10:46 -0400
commit6ae4802e6d3ed7aa67c4946c434850de3be5ffe3 (patch)
tree2bfeb690ba2dbf9849fb318d3f551a584278cee2 /indra/newview/llviewernetwork.cpp
parent020980fb4cd5f2cc18b56fa795c08c153a15bd4a (diff)
parent58d5e223b8a15b4825b96923b5891b251c6ccc98 (diff)
merge
Diffstat (limited to 'indra/newview/llviewernetwork.cpp')
-rw-r--r--indra/newview/llviewernetwork.cpp721
1 files changed, 350 insertions, 371 deletions
diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp
index ef5c65eb87..97f4c3e5fe 100644
--- a/indra/newview/llviewernetwork.cpp
+++ b/indra/newview/llviewernetwork.cpp
@@ -1,4 +1,4 @@
-/**
+/**
* @file llviewernetwork.cpp
* @author James Cook, Richard Nelson
* @brief Networking constants and globals for viewer.
@@ -6,21 +6,21 @@
* $LicenseInfo:firstyear=2006&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -34,13 +34,39 @@
#include "lltrans.h"
#include "llweb.h"
-
-const char* DEFAULT_LOGIN_PAGE = "http://viewer-login.agni.lindenlab.com/";
-const char* SYSTEM_GRID_SLURL_BASE = "secondlife://%s/secondlife/";
-const char* MAIN_GRID_SLURL_BASE = "http://maps.secondlife.com/secondlife/";
-const char* SYSTEM_GRID_APP_SLURL_BASE = "secondlife:///app";
+/// key used to store the grid, and the name attribute in the grid data
+const std::string GRID_VALUE = "keyname";
+/// the value displayed in the grid selector menu, and other human-oriented text
+const std::string GRID_LABEL_VALUE = "label";
+/// the value used on the --grid command line argument
+const std::string GRID_ID_VALUE = "grid_login_id";
+/// the url for the login cgi script
+const std::string GRID_LOGIN_URI_VALUE = "login_uri";
+///
+const std::string GRID_HELPER_URI_VALUE = "helper_uri";
+/// the splash page url
+const std::string GRID_LOGIN_PAGE_VALUE = "login_page";
+/// internal data on system grids
+const std::string GRID_IS_SYSTEM_GRID_VALUE = "system_grid";
+/// whether this is single or double names
+const std::string GRID_LOGIN_IDENTIFIER_TYPES = "login_identifier_types";
+
+// defines slurl formats associated with various grids.
+// we need to continue to support existing forms, as slurls
+// are shared between viewers that may not understand newer
+// forms.
+const std::string GRID_SLURL_BASE = "slurl_base";
+const std::string GRID_APP_SLURL_BASE = "app_slurl_base";
+
+const std::string DEFAULT_LOGIN_PAGE = "http://viewer-login.agni.lindenlab.com/";
+
+const std::string MAIN_GRID_LOGIN_URI = "https://login.agni.lindenlab.com/cgi-bin/login.cgi";
+
+const std::string MAIN_GRID_SLURL_BASE = "http://maps.secondlife.com/secondlife/";
+const std::string SYSTEM_GRID_APP_SLURL_BASE = "secondlife:///app";
+const char* SYSTEM_GRID_SLURL_BASE = "secondlife://%s/secondlife/";
const char* DEFAULT_SLURL_BASE = "https://%s/region/";
const char* DEFAULT_APP_SLURL_BASE = "x-grid-location-info://%s/app";
@@ -54,14 +80,17 @@ LLGridManager::LLGridManager()
// an attacker. Don't want someone snagging a password.
std::string grid_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,
"grids.xml");
+ LL_DEBUGS("GridManager")<<LL_ENDL;
+
initialize(grid_file);
-
+
}
LLGridManager::LLGridManager(const std::string& grid_file)
{
// initialize with an explicity grid file for testing.
+ LL_DEBUGS("GridManager")<<LL_ENDL;
initialize(grid_file);
}
@@ -74,183 +103,83 @@ LLGridManager::LLGridManager(const std::string& grid_file)
//
// LLGridManager::initialze - initialize the list of known grids based
// on the fixed list of linden grids (fixed for security reasons)
-// the grids.xml file
-// and the command line.
+// and the grids.xml file
void LLGridManager::initialize(const std::string& grid_file)
{
// default grid list.
// Don't move to a modifiable file for security reasons,
mGrid.clear() ;
+
// set to undefined
mGridList = LLSD();
mGridFile = grid_file;
// as we don't want an attacker to override our grid list
// to point the default grid to an invalid grid
- addSystemGrid("None", "", "", "", DEFAULT_LOGIN_PAGE);
-
-
-
- addSystemGrid("Agni",
- MAINGRID,
- "https://login.agni.lindenlab.com/cgi-bin/login.cgi",
- "https://secondlife.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Aditi",
- "util.aditi.lindenlab.com",
- "https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
+ addSystemGrid("Second Life Main Grid (Agni)",
+ MAINGRID,
+ MAIN_GRID_LOGIN_URI,
+ "https://secondlife.com/helpers/",
+ DEFAULT_LOGIN_PAGE,
+ "Agni");
+ addSystemGrid("Second Life Beta Test Grid (Aditi)",
+ "util.aditi.lindenlab.com",
+ "https://login.aditi.lindenlab.com/cgi-bin/login.cgi",
"http://aditi-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Aruna",
- "util.aruna.lindenlab.com",
- "https://login.aruna.lindenlab.com/cgi-bin/login.cgi",
- "http://aruna-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Bharati",
- "util.bharati.lindenlab.com",
- "https://login.bharati.lindenlab.com/cgi-bin/login.cgi",
- "http://bharati-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Chandra",
- "util.chandra.lindenlab.com",
- "https://login.chandra.lindenlab.com/cgi-bin/login.cgi",
- "http://chandra-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Damballah",
- "util.damballah.lindenlab.com",
- "https://login.damballah.lindenlab.com/cgi-bin/login.cgi",
- "http://damballah-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Danu",
- "util.danu.lindenlab.com",
- "https://login.danu.lindenlab.com/cgi-bin/login.cgi",
- "http://danu-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Durga",
- "util.durga.lindenlab.com",
- "https://login.durga.lindenlab.com/cgi-bin/login.cgi",
- "http://durga-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Ganga",
- "util.ganga.lindenlab.com",
- "https://login.ganga.lindenlab.com/cgi-bin/login.cgi",
- "http://ganga-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Mitra",
- "util.mitra.lindenlab.com",
- "https://login.mitra.lindenlab.com/cgi-bin/login.cgi",
- "http://mitra-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Mohini",
- "util.mohini.lindenlab.com",
- "https://login.mohini.lindenlab.com/cgi-bin/login.cgi",
- "http://mohini-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Nandi",
- "util.nandi.lindenlab.com",
- "https://login.nandi.lindenlab.com/cgi-bin/login.cgi",
- "http://nandi-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Parvati",
- "util.parvati.lindenlab.com",
- "https://login.parvati.lindenlab.com/cgi-bin/login.cgi",
- "http://parvati-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Radha",
- "util.radha.lindenlab.com",
- "https://login.radha.lindenlab.com/cgi-bin/login.cgi",
- "http://radha-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Ravi",
- "util.ravi.lindenlab.com",
- "https://login.ravi.lindenlab.com/cgi-bin/login.cgi",
- "http://ravi-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Siva",
- "util.siva.lindenlab.com",
- "https://login.siva.lindenlab.com/cgi-bin/login.cgi",
- "http://siva-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Shakti",
- "util.shakti.lindenlab.com",
- "https://login.shakti.lindenlab.com/cgi-bin/login.cgi",
- "http://shakti-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Soma",
- "util.soma.lindenlab.com",
- "https://login.soma.lindenlab.com/cgi-bin/login.cgi",
- "http://soma-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Uma",
- "util.uma.lindenlab.com",
- "https://login.uma.lindenlab.com/cgi-bin/login.cgi",
- "http://uma-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Vaak",
- "util.vaak.lindenlab.com",
- "https://login.vaak.lindenlab.com/cgi-bin/login.cgi",
- "http://vaak-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Yami",
- "util.yami.lindenlab.com",
- "https://login.yami.lindenlab.com/cgi-bin/login.cgi",
- "http://yami-secondlife.webdev.lindenlab.com/helpers/",
- DEFAULT_LOGIN_PAGE);
- addSystemGrid("Local (Linden)",
- "localhost",
- "https://login.dmz.lindenlab.com/cgi-bin/login.cgi",
- "",
- DEFAULT_LOGIN_PAGE);
-
-
+ DEFAULT_LOGIN_PAGE,
+ "Aditi");
+
LLSD other_grids;
llifstream llsd_xml;
if (!grid_file.empty())
{
+ LL_INFOS("GridManager")<<"Grid configuration file '"<<grid_file<<"'"<<LL_ENDL;
llsd_xml.open( grid_file.c_str(), std::ios::in | std::ios::binary );
// parse through the gridfile, inserting grids into the list unless
- // they overwrite a linden grid.
- if( llsd_xml.is_open())
+ // they overwrite an existing grid.
+ if( llsd_xml.is_open())
{
LLSDSerialize::fromXMLDocument( other_grids, llsd_xml );
if(other_grids.isMap())
{
- for(LLSD::map_iterator grid_itr = other_grids.beginMap();
+ for(LLSD::map_iterator grid_itr = other_grids.beginMap();
grid_itr != other_grids.endMap();
++grid_itr)
{
LLSD::String key_name = grid_itr->first;
LLSD grid = grid_itr->second;
- // TODO: Make sure gridfile specified label is not
- // a system grid label
- LL_DEBUGS("GridManager") << "reading: " << key_name << LL_ENDL;
- if (mGridList.has(key_name) &&
- mGridList[key_name].has(GRID_IS_SYSTEM_GRID_VALUE))
+
+ std::string existingGrid = getGrid(grid);
+ if (mGridList.has(key_name) || !existingGrid.empty())
{
- 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() )
- {
- mGridList[key_name][GRID_IS_FAVORITE_VALUE] = TRUE;
- }
+ LL_WARNS("GridManager") << "Cannot override existing grid '" << key_name << "'; ignoring definition from '"<<grid_file<<"'" << LL_ENDL;
+ }
+ else if ( addGrid(grid) )
+ {
+ LL_INFOS("GridManager") << "added grid '"<<key_name<<"'"<<LL_ENDL;
}
else
{
- try
- {
- addGrid(grid);
- LL_DEBUGS("GridManager") << "Added grid: " << key_name << LL_ENDL;
- }
- catch (...)
- {
- }
+ LL_WARNS("GridManager") << "failed to add invalid grid '"<<key_name<<"'"<<LL_ENDL;
}
}
llsd_xml.close();
- }
- }
+ }
+ else
+ {
+ LL_WARNS("GridManager")<<"Failed to parse grid configuration '"<<grid_file<<"'"<<LL_ENDL;
+ }
+ }
+ else
+ {
+ LL_WARNS("GridManager")<<"Failed to open grid configuration '"<<grid_file<<"'"<<LL_ENDL;
+ }
+ }
+ else
+ {
+ LL_DEBUGS("GridManager")<<"no grid file specified"<<LL_ENDL;
}
-
+
// load a grid from the command line.
// if the actual grid name is specified from the command line,
// set it as the 'selected' grid.
@@ -259,50 +188,38 @@ void LLGridManager::initialize(const std::string& grid_file)
{
// 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);
+ mGrid = getGrid(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;
+ LL_WARNS("GridManager")<<"Unknown grid '"<<cmd_line_grid<<"'"<<LL_ENDL;
+ }
+ else
+ {
+ LL_INFOS("GridManager")<<"Command line specified '"<<cmd_line_grid<<"': "<<mGrid<<LL_ENDL;
}
-
}
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");
+ std::string last_grid = gSavedSettings.getString("CurrentGrid");
+ if ( ! getGrid(last_grid).empty() )
+ {
+ LL_INFOS("GridManager")<<"Using last grid: "<<last_grid<<LL_ENDL;
+ mGrid = last_grid;
+ }
+ else
+ {
+ LL_INFOS("GridManager")<<"Last grid '"<<last_grid<<"' not configured"<<LL_ENDL;
+ }
}
-
+
if(mGrid.empty())
{
// no grid was specified so default to maingrid
- LL_DEBUGS("GridManager") << "Setting grid to MAINGRID as no grid has been specified " << LL_ENDL;
+ LL_INFOS("GridManager") << "Default grid to "<<MAINGRID<< LL_ENDL;
mGrid = MAINGRID;
-
- }
-
- // 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))
- {
- grid = mGridList[mGrid];
- }
- else
- {
- 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);
}
LLControlVariablePtr grid_control = gSavedSettings.getControl("CurrentGrid");
@@ -314,115 +231,105 @@ void LLGridManager::initialize(const std::string& grid_file)
// since above only triggers on changes, trigger the callback manually to initialize state
updateIsInProductionGrid();
- 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()
{
- 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.
//
-void LLGridManager::addGrid(LLSD& grid_data)
+bool LLGridManager::addGrid(LLSD& grid_data)
{
+ bool added = false;
if (grid_data.isMap() && grid_data.has(GRID_VALUE))
{
- std::string grid = utf8str_tolower(grid_data[GRID_VALUE]);
+ std::string grid = utf8str_tolower(grid_data[GRID_VALUE].asString());
- // grid should be in the form of a dns address
- if (!grid.empty() &&
- grid.find_first_not_of("abcdefghijklmnopqrstuvwxyz1234567890-_. ") != std::string::npos)
- {
- printf("grid name: %s", grid.c_str());
- throw LLInvalidGridName(grid);
- }
-
- // populate the other values if they don't exist
- if (!grid_data.has(GRID_LABEL_VALUE))
- {
- grid_data[GRID_LABEL_VALUE] = grid;
- }
- if (!grid_data.has(GRID_ID_VALUE))
- {
- grid_data[GRID_ID_VALUE] = grid;
- }
-
- // if the grid data doesn't include any of the URIs, then
- // generate them from the grid, which should be a dns address
- if (!grid_data.has(GRID_LOGIN_URI_VALUE))
+ if ( getGrid(grid_data[GRID_VALUE]).empty() && getGrid(grid).empty() )
{
- grid_data[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray();
- grid_data[GRID_LOGIN_URI_VALUE].append(std::string("https://") +
- grid + "/cgi-bin/login.cgi");
- }
- // Populate to the default values
- if (!grid_data.has(GRID_LOGIN_PAGE_VALUE))
- {
- grid_data[GRID_LOGIN_PAGE_VALUE] = std::string("http://") + grid + "/app/login/";
- }
- if (!grid_data.has(GRID_HELPER_URI_VALUE))
- {
- grid_data[GRID_HELPER_URI_VALUE] = std::string("https://") + grid + "/helpers/";
+ std::string grid_id = grid_data.has(GRID_ID_VALUE) ? grid_data[GRID_ID_VALUE].asString() : "";
+ if ( getGrid(grid_id).empty() )
+ {
+ // populate the other values if they don't exist
+ if (!grid_data.has(GRID_LABEL_VALUE))
+ {
+ grid_data[GRID_LABEL_VALUE] = grid;
+ }
+ if (!grid_data.has(GRID_ID_VALUE))
+ {
+ grid_data[GRID_ID_VALUE] = grid;
+ }
+
+ // if the grid data doesn't include any of the URIs, then
+ // generate them from the grid, which should be a dns address
+ if (!grid_data.has(GRID_LOGIN_URI_VALUE))
+ {
+ grid_data[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray();
+ grid_data[GRID_LOGIN_URI_VALUE].append(std::string("https://") +
+ grid + "/cgi-bin/login.cgi");
+ }
+ // Populate to the default values
+ if (!grid_data.has(GRID_LOGIN_PAGE_VALUE))
+ {
+ grid_data[GRID_LOGIN_PAGE_VALUE] = std::string("http://") + grid + "/app/login/";
+ }
+ if (!grid_data.has(GRID_HELPER_URI_VALUE))
+ {
+ grid_data[GRID_HELPER_URI_VALUE] = std::string("https://") + grid + "/helpers/";
+ }
+
+ if (!grid_data.has(GRID_LOGIN_IDENTIFIER_TYPES))
+ {
+ // non system grids and grids that haven't already been configured with values
+ // get both types of credentials.
+ grid_data[GRID_LOGIN_IDENTIFIER_TYPES] = LLSD::emptyArray();
+ grid_data[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_AGENT);
+ grid_data[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_ACCOUNT);
+ }
+
+ LL_DEBUGS("GridManager") <<grid<<"\n"
+ <<" id: "<<grid_data[GRID_ID_VALUE].asString()<<"\n"
+ <<" label: "<<grid_data[GRID_LABEL_VALUE].asString()<<"\n"
+ <<" login page: "<<grid_data[GRID_LOGIN_PAGE_VALUE].asString()<<"\n"
+ <<" helper page: "<<grid_data[GRID_HELPER_URI_VALUE].asString()<<"\n";
+ /* still in LL_DEBUGS */
+ for (LLSD::array_const_iterator login_uris = grid_data[GRID_LOGIN_URI_VALUE].beginArray();
+ login_uris != grid_data[GRID_LOGIN_URI_VALUE].endArray();
+ login_uris++)
+ {
+ LL_CONT << " login uri: "<<login_uris->asString()<<"\n";
+ }
+ LL_CONT << LL_ENDL;
+ mGridList[grid] = grid_data;
+ added = true;
+ }
+ else
+ {
+ LL_WARNS("GridManager")<<"duplicate grid id'"<<grid_id<<"' ignored"<<LL_ENDL;
+ }
}
-
- if (!grid_data.has(GRID_LOGIN_IDENTIFIER_TYPES))
+ else
{
- // non system grids and grids that haven't already been configured with values
- // get both types of credentials.
- grid_data[GRID_LOGIN_IDENTIFIER_TYPES] = LLSD::emptyArray();
- grid_data[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_AGENT);
- grid_data[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_ACCOUNT);
+ LL_WARNS("GridManager")<<"duplicate grid name '"<<grid<<"' ignored"<<LL_ENDL;
}
-
- LL_DEBUGS("GridManager") << "ADDING: " << grid << LL_ENDL;
- mGridList[grid] = grid_data;
}
+ else
+ {
+ LL_WARNS("GridManager")<<"invalid grid definition ignored"<<LL_ENDL;
+ }
+ return added;
}
//
// LLGridManager::addSystemGrid - helper for adding a system grid.
-void LLGridManager::addSystemGrid(const std::string& label,
- const std::string& name,
- const std::string& login,
+void LLGridManager::addSystemGrid(const std::string& label,
+ const std::string& name,
+ const std::string& login_uri,
const std::string& helper,
const std::string& login_page,
const std::string& login_id)
@@ -432,12 +339,12 @@ void LLGridManager::addSystemGrid(const std::string& label,
grid[GRID_LABEL_VALUE] = label;
grid[GRID_HELPER_URI_VALUE] = helper;
grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray();
- grid[GRID_LOGIN_URI_VALUE].append(login);
+ grid[GRID_LOGIN_URI_VALUE].append(login_uri);
grid[GRID_LOGIN_PAGE_VALUE] = login_page;
- grid[GRID_IS_SYSTEM_GRID_VALUE] = TRUE;
+ grid[GRID_IS_SYSTEM_GRID_VALUE] = true;
grid[GRID_LOGIN_IDENTIFIER_TYPES] = LLSD::emptyArray();
grid[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_AGENT);
-
+
grid[GRID_APP_SLURL_BASE] = SYSTEM_GRID_APP_SLURL_BASE;
if (login_id.empty())
{
@@ -447,124 +354,187 @@ void LLGridManager::addSystemGrid(const std::string& label,
{
grid[GRID_ID_VALUE] = login_id;
}
-
- // only add the system grids beyond agni to the visible list
- // if we're building a debug version.
+
if (name == std::string(MAINGRID))
{
- grid[GRID_SLURL_BASE] = MAIN_GRID_SLURL_BASE;
- grid[GRID_IS_FAVORITE_VALUE] = TRUE;
+ grid[GRID_SLURL_BASE] = MAIN_GRID_SLURL_BASE;
}
else
{
- grid[GRID_SLURL_BASE] = llformat(SYSTEM_GRID_SLURL_BASE, label.c_str());
+ grid[GRID_SLURL_BASE] = llformat(SYSTEM_GRID_SLURL_BASE, grid[GRID_ID_VALUE].asString().c_str());
}
+
addGrid(grid);
}
// return a list of grid name -> grid label mappings for UI purposes
-std::map<std::string, std::string> LLGridManager::getKnownGrids(bool favorite_only)
+std::map<std::string, std::string> LLGridManager::getKnownGrids()
{
std::map<std::string, std::string> result;
for(LLSD::map_iterator grid_iter = mGridList.beginMap();
grid_iter != mGridList.endMap();
- grid_iter++)
+ grid_iter++)
{
- if(!favorite_only || grid_iter->second.has(GRID_IS_FAVORITE_VALUE))
- {
- result[grid_iter->first] = grid_iter->second[GRID_LABEL_VALUE].asString();
- }
+ result[grid_iter->first] = grid_iter->second[GRID_LABEL_VALUE].asString();
}
return result;
}
-
void LLGridManager::setGridChoice(const std::string& grid)
{
// Set the grid choice based on a string.
- // The string can be:
- // - a grid label from the gGridInfo table
- // - a hostname
- // - an ip address
-
- // loop through. We could do just a hash lookup but we also want to match
- // on label
- std::string grid_name = grid;
- if(!mGridList.has(grid_name))
+ LL_DEBUGS("GridManager")<<"requested "<<grid<<LL_ENDL;
+ std::string grid_name = getGrid(grid); // resolved either the name or the id to the name
+
+ if(!grid_name.empty())
{
- // case insensitive
- grid_name = getGridByLabel(grid);
+ LL_INFOS("GridManager")<<"setting "<<grid_name<<LL_ENDL;
+ mGrid = grid_name;
+ gSavedSettings.setString("CurrentGrid", grid_name);
+
+ updateIsInProductionGrid();
}
-
- if(grid_name.empty())
+ else
{
// the grid was not in the list of grids.
- LLSD grid_data = LLSD::emptyMap();
- grid_data[GRID_VALUE] = grid;
- addGrid(grid_data);
+ LL_WARNS("GridManager")<<"unknown grid "<<grid<<LL_ENDL;
}
- mGrid = grid;
- gSavedSettings.setString("CurrentGrid", grid);
-
- updateIsInProductionGrid();
}
-std::string LLGridManager::getGridByLabel( const std::string &grid_label, bool case_sensitive)
+std::string LLGridManager::getGrid( const std::string &grid )
{
- for(LLSD::map_iterator grid_iter = mGridList.beginMap();
- grid_iter != mGridList.endMap();
- grid_iter++)
+ std::string grid_name;
+
+ if (mGridList.has(grid))
+ {
+ // the grid was the long name, so we're good, return it
+ grid_name = grid;
+ }
+ else
{
- if (grid_iter->second.has(GRID_LABEL_VALUE))
+ // search the grid list for a grid with a matching id
+ for(LLSD::map_iterator grid_iter = mGridList.beginMap();
+ grid_name.empty() && grid_iter != mGridList.endMap();
+ grid_iter++)
{
- 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())))
+ if (grid_iter->second.has(GRID_ID_VALUE))
{
- return grid_iter->first;
+ if (0 == (LLStringUtil::compareInsensitive(grid,
+ grid_iter->second[GRID_ID_VALUE].asString())))
+ {
+ // found a matching label, return this name
+ grid_name = grid_iter->first;
+ }
}
}
}
- return std::string();
+ return grid_name;
}
-void LLGridManager::getLoginURIs(std::vector<std::string>& uris)
+std::string LLGridManager::getGridLabel(const std::string& grid)
+{
+ std::string grid_label;
+ std::string grid_name = getGrid(grid);
+ if (!grid.empty())
+ {
+ grid_label = mGridList[grid_name][GRID_LABEL_VALUE].asString();
+ }
+ else
+ {
+ LL_WARNS("GridManager")<<"invalid grid '"<<grid<<"'"<<LL_ENDL;
+ }
+ LL_DEBUGS("GridManager")<<"returning "<<grid_label<<LL_ENDL;
+ return grid_label;
+}
+
+std::string LLGridManager::getGridId(const std::string& grid)
+{
+ std::string grid_id;
+ std::string grid_name = getGrid(grid);
+ if (!grid.empty())
+ {
+ grid_id = mGridList[grid_name][GRID_ID_VALUE].asString();
+ }
+ else
+ {
+ LL_WARNS("GridManager")<<"invalid grid '"<<grid<<"'"<<LL_ENDL;
+ }
+ LL_DEBUGS("GridManager")<<"returning "<<grid_id<<LL_ENDL;
+ return grid_id;
+}
+
+void LLGridManager::getLoginURIs(const std::string& grid, 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;
+ std::string grid_name = getGrid(grid);
+ if (!grid_name.empty())
+ {
+ for (LLSD::array_iterator llsd_uri = mGridList[grid_name][GRID_LOGIN_URI_VALUE].beginArray();
+ llsd_uri != mGridList[grid_name][GRID_LOGIN_URI_VALUE].endArray();
+ llsd_uri++)
+ {
+ uris.push_back(llsd_uri->asString());
+ }
}
- for (LLSD::array_iterator llsd_uri = mGridList[mGrid][GRID_LOGIN_URI_VALUE].beginArray();
- llsd_uri != mGridList[mGrid][GRID_LOGIN_URI_VALUE].endArray();
- llsd_uri++)
+ else
{
- uris.push_back(llsd_uri->asString());
+ LL_WARNS("GridManager")<<"invalid grid '"<<grid<<"'"<<LL_ENDL;
}
}
-std::string LLGridManager::getHelperURI()
+void LLGridManager::getLoginURIs(std::vector<std::string>& uris)
{
- std::string cmd_line_helper_uri = gSavedSettings.getString("CmdLineHelperURI");
- if(!cmd_line_helper_uri.empty())
+ getLoginURIs(mGrid, uris);
+}
+
+std::string LLGridManager::getHelperURI(const std::string& grid)
+{
+ std::string helper_uri;
+ std::string grid_name = getGrid(grid);
+ if (!grid_name.empty())
{
- return cmd_line_helper_uri;
+ helper_uri = mGridList[grid_name][GRID_HELPER_URI_VALUE].asString();
}
- return mGridList[mGrid][GRID_HELPER_URI_VALUE];
+ else
+ {
+ LL_WARNS("GridManager")<<"invalid grid '"<<grid<<"'"<<LL_ENDL;
+ }
+
+ LL_DEBUGS("GridManager")<<"returning "<<helper_uri<<LL_ENDL;
+ return helper_uri;
}
-std::string LLGridManager::getLoginPage()
+std::string LLGridManager::getLoginPage(const std::string& grid)
{
- // override the login page if it was passed in
- std::string cmd_line_login_page = gSavedSettings.getString("LoginPage");
- if(!cmd_line_login_page.empty())
+ std::string grid_login_page;
+ std::string grid_name = getGrid(grid);
+ if (!grid_name.empty())
+ {
+ grid_login_page = mGridList[grid_name][GRID_LOGIN_PAGE_VALUE].asString();
+ }
+ else
{
- return cmd_line_login_page;
- }
-
- return mGridList[mGrid][GRID_LOGIN_PAGE_VALUE];
+ LL_WARNS("GridManager")<<"invalid grid '"<<grid<<"'"<<LL_ENDL;
+ }
+ return grid_login_page;
+}
+
+std::string LLGridManager::getLoginPage()
+{
+ std::string login_page = mGridList[mGrid][GRID_LOGIN_PAGE_VALUE].asString();
+ LL_DEBUGS("GridManager")<<"returning "<<login_page<<LL_ENDL;
+ return login_page;
+}
+
+void LLGridManager::getLoginIdentifierTypes(LLSD& idTypes)
+{
+ idTypes = mGridList[mGrid][GRID_LOGIN_IDENTIFIER_TYPES];
+}
+
+std::string LLGridManager::getGridLoginID()
+{
+ return mGridList[mGrid][GRID_ID_VALUE];
}
void LLGridManager::updateIsInProductionGrid()
@@ -578,13 +548,19 @@ void LLGridManager::updateIsInProductionGrid()
if (uris.empty())
{
mIsInProductionGrid = true;
- return;
}
- LLStringUtil::toLower(uris[0]);
- if((uris[0].find("agni") != std::string::npos))
+ else
{
- mIsInProductionGrid = true;
- return;
+ for ( std::vector<std::string>::iterator uri_it = uris.begin();
+ ! mIsInProductionGrid && uri_it != uris.end();
+ uri_it++
+ )
+ {
+ if( MAIN_GRID_LOGIN_URI == *uri_it )
+ {
+ mIsInProductionGrid = true;
+ }
+ }
}
}
@@ -593,50 +569,53 @@ bool LLGridManager::isInProductionGrid()
return mIsInProductionGrid;
}
-void LLGridManager::saveFavorites()
+bool LLGridManager::isSystemGrid(const std::string& grid)
{
- // filter out just those marked as favorites
- LLSD output_grid_list = LLSD::emptyMap();
- for(LLSD::map_iterator grid_iter = mGridList.beginMap();
- grid_iter != mGridList.endMap();
- grid_iter++)
- {
- if(grid_iter->second.has(GRID_IS_FAVORITE_VALUE))
- {
- output_grid_list[grid_iter->first] = grid_iter->second;
- }
- }
- llofstream llsd_xml;
- llsd_xml.open( mGridFile.c_str(), std::ios::out | std::ios::binary);
- LLSDSerialize::toPrettyXML(output_grid_list, llsd_xml);
- llsd_xml.close();
-}
+ std::string grid_name = getGrid(grid);
+ return ( !grid_name.empty()
+ && mGridList.has(grid)
+ && mGridList[grid].has(GRID_IS_SYSTEM_GRID_VALUE)
+ && mGridList[grid][GRID_IS_SYSTEM_GRID_VALUE].asBoolean()
+ );
+}
// build a slurl for the given region within the selected grid
std::string LLGridManager::getSLURLBase(const std::string& grid)
{
- std::string grid_base;
- if(mGridList.has(grid) && mGridList[grid].has(GRID_SLURL_BASE))
+ std::string grid_base = "";
+ std::string grid_name = getGrid(grid);
+ if( ! grid_name.empty() && mGridList.has(grid_name) )
{
- return mGridList[grid][GRID_SLURL_BASE].asString();
- }
- else
- {
- return llformat(DEFAULT_SLURL_BASE, grid.c_str());
+ if (mGridList[grid_name].has(GRID_SLURL_BASE))
+ {
+ grid_base = mGridList[grid_name][GRID_SLURL_BASE].asString();
+ }
+ else
+ {
+ grid_base = llformat(DEFAULT_SLURL_BASE, grid_name.c_str());
+ }
}
+ LL_DEBUGS("GridManager")<<"returning '"<<grid_base<<"'"<<LL_ENDL;
+ return grid_base;
}
// build a slurl for the given region within the selected grid
std::string LLGridManager::getAppSLURLBase(const std::string& grid)
{
- std::string grid_base;
- if(mGridList.has(grid) && mGridList[grid].has(GRID_APP_SLURL_BASE))
- {
- return mGridList[grid][GRID_APP_SLURL_BASE].asString();
- }
- else
+ std::string grid_base = "";
+ std::string grid_name = getGrid(grid);
+ if(!grid_name.empty() && mGridList.has(grid))
{
- return llformat(DEFAULT_APP_SLURL_BASE, grid.c_str());
+ if (mGridList[grid].has(GRID_APP_SLURL_BASE))
+ {
+ grid_base = mGridList[grid][GRID_APP_SLURL_BASE].asString();
+ }
+ else
+ {
+ grid_base = llformat(DEFAULT_APP_SLURL_BASE, grid_name.c_str());
+ }
}
+ LL_DEBUGS("GridManager")<<"returning '"<<grid_base<<"'"<<LL_ENDL;
+ return grid_base;
}