diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/app_settings/logcontrol.xml | 2 | ||||
-rw-r--r-- | indra/newview/llviewernetwork.cpp | 177 | ||||
-rw-r--r-- | indra/newview/llviewernetwork.h | 2 | ||||
-rw-r--r-- | indra/newview/tests/llviewernetwork_test.cpp | 206 |
4 files changed, 261 insertions, 126 deletions
diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml index d7bb64ce8a..0d27c20d40 100644 --- a/indra/newview/app_settings/logcontrol.xml +++ b/indra/newview/app_settings/logcontrol.xml @@ -25,6 +25,7 @@ <string>AppCache</string> <string>Window</string> <string>RenderInit</string> + <string>GridManager</string> </array> </map> <map> @@ -40,6 +41,7 @@ </array> <key>tags</key> <array> + <string>GridManager</string> </array> </map> </array> diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp index c76eee80f7..619deaf50b 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,90 @@ 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"); + } + + 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; + 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(); + + bool grid_dirty = false; + if(mGridList.has(mGrid)) + { + grid = mGridList[mGrid]; + } + else + { + grid[GRID_VALUE] = mGrid; + grid_dirty = true; } - 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()) { - 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"); - - // we've a cmd line login, so add a grid for the command line, - // overwriting any existing grids - LLSD grid = LLSD::emptyMap(); + grid_dirty = true; 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()) + // override the helper uri if it was passed in + std::string cmd_line_helper_uri = gSavedSettings.getString("CmdLineHelperURI"); + if(!cmd_line_helper_uri.empty()) { - - mGrid = gSavedSettings.getString("CurrentGrid"); + grid[GRID_HELPER_URI_VALUE] = cmd_line_helper_uri; + grid_dirty = true; } - - if (mGrid.empty() || !mGridList.has(mGrid)) + + // override the login page if it was passed in + std::string cmd_line_login_page = gSavedSettings.getString("LoginPage"); + if(!cmd_line_login_page.empty()) { - // 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_LOGIN_PAGE_VALUE] = cmd_line_login_page; + grid_dirty = true; } - LL_INFOS("GridManager") << "Selected grid is " << mGrid << LL_ENDL; - gSavedSettings.setString("CurrentGrid", mGrid); + + if(grid_dirty) + { + // add the grid with the additional values, or update the + // existing grid if it exists with the given values + addGrid(grid); + } + 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() @@ -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(); diff --git a/indra/newview/llviewernetwork.h b/indra/newview/llviewernetwork.h index 0271e7a7a5..a99e32f701 100644 --- a/indra/newview/llviewernetwork.h +++ b/indra/newview/llviewernetwork.h @@ -127,7 +127,7 @@ public: LLSD getGridInfo() { return mGridList[mGrid]; } - std::string getGridByLabel( const std::string &grid_label); + std::string getGridByLabel( const std::string &grid_label, bool case_sensitive = false); bool isSystemGrid(const std::string& grid) { diff --git a/indra/newview/tests/llviewernetwork_test.cpp b/indra/newview/tests/llviewernetwork_test.cpp index d819b44564..a3b11e706a 100644 --- a/indra/newview/tests/llviewernetwork_test.cpp +++ b/indra/newview/tests/llviewernetwork_test.cpp @@ -244,35 +244,20 @@ namespace tut template<> template<> void viewerNetworkTestObject::test<3>() { - gCmdLineLoginURI = "https://my.login.uri/cgi-bin/login.cgi"; - + // USE --grid command line + // initialize with a known grid + LLSD grid; + gCmdLineGridChoice = "Aditi"; LLGridManager::getInstance()->initialize("grid_test.xml"); // with single login uri specified. std::map<std::string, std::string> known_grids = LLGridManager::getInstance()->getKnownGrids(); - ensure_equals("adding a command line grid increases known grid size", - known_grids.size(), 24); - ensure_equals("Command line grid is added to the list of grids", - known_grids["my.login.uri"], std::string("my.login.uri")); - LLSD grid = LLGridManager::getInstance()->getGridInfo("my.login.uri"); - ensure_equals("Command line grid name is set", - grid[GRID_VALUE].asString(), std::string("my.login.uri")); - ensure_equals("Command line grid label is set", - grid[GRID_LABEL_VALUE].asString(), std::string("my.login.uri")); - ensure("Command line grid login uri is an array", - grid[GRID_LOGIN_URI_VALUE].isArray()); - ensure_equals("Command line grid login uri is set", - grid[GRID_LOGIN_URI_VALUE][0].asString(), - std::string("https://my.login.uri/cgi-bin/login.cgi")); - ensure_equals("Command line grid helper uri is set", - grid[GRID_HELPER_URI_VALUE].asString(), - std::string("https://my.login.uri/helpers/")); - ensure_equals("Command line grid login page is set", - grid[GRID_LOGIN_PAGE_VALUE].asString(), - std::string("http://my.login.uri/app/login/")); - ensure("Command line grid favorite is set", - !grid.has(GRID_IS_FAVORITE_VALUE)); - ensure("Command line grid isn't a system grid", - !grid.has(GRID_IS_SYSTEM_GRID_VALUE)); + ensure_equals("Using a known grid via command line doesn't increase number of known grids", + known_grids.size(), 23); + ensure_equals("getGridLabel", LLGridManager::getInstance()->getGridLabel(), std::string("Aditi")); + // initialize with a known grid in lowercase + gCmdLineGridChoice = "agni"; + LLGridManager::getInstance()->initialize("grid_test.xml"); + ensure_equals("getGridLabel", LLGridManager::getInstance()->getGridLabel(), std::string("Agni")); // now try a command line with a custom grid identifier gCmdLineGridChoice = "mycustomgridchoice"; @@ -291,26 +276,165 @@ namespace tut grid[GRID_LOGIN_URI_VALUE].isArray()); ensure_equals("Custom Command line grid login uri is set", grid[GRID_LOGIN_URI_VALUE][0].asString(), + std::string("https://mycustomgridchoice/cgi-bin/login.cgi")); + ensure_equals("Custom Command line grid helper uri is set", + grid[GRID_HELPER_URI_VALUE].asString(), + std::string("https://mycustomgridchoice/helpers/")); + ensure_equals("Custom Command line grid login page is set", + grid[GRID_LOGIN_PAGE_VALUE].asString(), + std::string("http://mycustomgridchoice/app/login/")); + } + + // validate override of login uri with cmd line + template<> template<> + void viewerNetworkTestObject::test<4>() + { + // Override with loginuri + // override known grid + LLSD grid; + gCmdLineGridChoice = "Aditi"; + gCmdLineLoginURI = "https://my.login.uri/cgi-bin/login.cgi"; + LLGridManager::getInstance()->initialize("grid_test.xml"); + std::map<std::string, std::string> known_grids = LLGridManager::getInstance()->getKnownGrids(); + ensure_equals("Override known grid login uri: No grids are added", + known_grids.size(), 23); + grid = LLGridManager::getInstance()->getGridInfo(); + ensure("Override known grid login uri: login uri is an array", + grid[GRID_LOGIN_URI_VALUE].isArray()); + ensure_equals("Override known grid login uri: Command line grid login uri is set", + grid[GRID_LOGIN_URI_VALUE][0].asString(), std::string("https://my.login.uri/cgi-bin/login.cgi")); + ensure_equals("Override known grid login uri: helper uri is not changed", + grid[GRID_HELPER_URI_VALUE].asString(), + std::string("http://aditi-secondlife.webdev.lindenlab.com/helpers/")); + ensure_equals("Override known grid login uri: login page is not set", + grid[GRID_LOGIN_PAGE_VALUE].asString(), + std::string("http://secondlife.com/app/login/")); - // add a helperuri - gCmdLineHelperURI = "myhelperuri"; - LLGridManager::getInstance()->initialize("grid_test.xml"); - grid = LLGridManager::getInstance()->getGridInfo("mycustomgridchoice"); - ensure_equals("Validate command line helper uri", - grid[GRID_HELPER_URI_VALUE].asString(), std::string("myhelperuri")); + // Override with loginuri + // override custom grid + gCmdLineGridChoice = "mycustomgridchoice"; + gCmdLineLoginURI = "https://my.login.uri/cgi-bin/login.cgi"; + LLGridManager::getInstance()->initialize("grid_test.xml"); + known_grids = LLGridManager::getInstance()->getKnownGrids(); + grid = LLGridManager::getInstance()->getGridInfo(); + ensure_equals("Override custom grid login uri: Grid is added", + known_grids.size(), 24); + ensure("Override custom grid login uri: login uri is an array", + grid[GRID_LOGIN_URI_VALUE].isArray()); + ensure_equals("Override custom grid login uri: login uri is set", + grid[GRID_LOGIN_URI_VALUE][0].asString(), + std::string("https://my.login.uri/cgi-bin/login.cgi")); + ensure_equals("Override custom grid login uri: Helper uri is not set", + grid[GRID_HELPER_URI_VALUE].asString(), + std::string("https://mycustomgridchoice/helpers/")); + ensure_equals("Override custom grid login uri: Login page is not set", + grid[GRID_LOGIN_PAGE_VALUE].asString(), + std::string("http://mycustomgridchoice/app/login/")); + } + + // validate override of helper uri with cmd line + template<> template<> + void viewerNetworkTestObject::test<5>() + { + // Override with helperuri + // override known grid + LLSD grid; + gCmdLineGridChoice = "Aditi"; + gCmdLineLoginURI = ""; + gCmdLineHelperURI = "https://my.helper.uri/mycustomhelpers"; + LLGridManager::getInstance()->initialize("grid_test.xml"); + std::map<std::string, std::string> known_grids = LLGridManager::getInstance()->getKnownGrids(); + ensure_equals("Override known grid helper uri: No grids are added", + known_grids.size(), 23); + grid = LLGridManager::getInstance()->getGridInfo(); + ensure("Override known known helper uri: login uri is an array", + grid[GRID_LOGIN_URI_VALUE].isArray()); + ensure_equals("Override known grid helper uri: login uri is not changed", + grid[GRID_LOGIN_URI_VALUE][0].asString(), + std::string("https://login.aditi.lindenlab.com/cgi-bin/login.cgi")); + ensure_equals("Override known grid helper uri: helper uri is changed", + grid[GRID_HELPER_URI_VALUE].asString(), + std::string("https://my.helper.uri/mycustomhelpers")); + ensure_equals("Override known grid helper uri: login page is not changed", + grid[GRID_LOGIN_PAGE_VALUE].asString(), + std::string("http://secondlife.com/app/login/")); + + // Override with helperuri + // override custom grid + gCmdLineGridChoice = "mycustomgridchoice"; + gCmdLineHelperURI = "https://my.helper.uri/mycustomhelpers"; + LLGridManager::getInstance()->initialize("grid_test.xml"); + known_grids = LLGridManager::getInstance()->getKnownGrids(); + ensure_equals("Override custom grid helper uri: grids is added", + known_grids.size(), 24); + grid = LLGridManager::getInstance()->getGridInfo(); + ensure("Override custom helper uri: login uri is an array", + grid[GRID_LOGIN_URI_VALUE].isArray()); + ensure_equals("Override custom grid helper uri: login uri is not changed", + grid[GRID_LOGIN_URI_VALUE][0].asString(), + std::string("https://mycustomgridchoice/cgi-bin/login.cgi")); + ensure_equals("Override custom grid helper uri: helper uri is changed", + grid[GRID_HELPER_URI_VALUE].asString(), + std::string("https://my.helper.uri/mycustomhelpers")); + ensure_equals("Override custom grid helper uri: login page is not changed", + grid[GRID_LOGIN_PAGE_VALUE].asString(), + std::string("http://mycustomgridchoice/app/login/")); + } + + // validate overriding of login page via cmd line + template<> template<> + void viewerNetworkTestObject::test<6>() + { + // Override with login page + // override known grid + LLSD grid; + gCmdLineGridChoice = "Aditi"; + gCmdLineHelperURI = ""; + gLoginPage = "myloginpage"; + LLGridManager::getInstance()->initialize("grid_test.xml"); + std::map<std::string, std::string> known_grids = LLGridManager::getInstance()->getKnownGrids(); + ensure_equals("Override known grid login page: No grids are added", + known_grids.size(), 23); + grid = LLGridManager::getInstance()->getGridInfo(); + ensure("Override known grid login page: Command line grid login uri is an array", + grid[GRID_LOGIN_URI_VALUE].isArray()); + ensure_equals("Override known grid login page: login uri is not changed", + grid[GRID_LOGIN_URI_VALUE][0].asString(), + std::string("https://login.aditi.lindenlab.com/cgi-bin/login.cgi")); + ensure_equals("Override known grid login page: helper uri is not changed", + grid[GRID_HELPER_URI_VALUE].asString(), + std::string("http://aditi-secondlife.webdev.lindenlab.com/helpers/")); + ensure_equals("Override known grid login page: login page is changed", + grid[GRID_LOGIN_PAGE_VALUE].asString(), + std::string("myloginpage")); - // add a login page + // Override with login page + // override custom grid + gCmdLineGridChoice = "mycustomgridchoice"; gLoginPage = "myloginpage"; - LLGridManager::getInstance()->initialize("grid_test.xml"); - grid = LLGridManager::getInstance()->getGridInfo("mycustomgridchoice"); - ensure_equals("Validate command line helper uri", - grid[GRID_LOGIN_PAGE_VALUE].asString(), std::string("myloginpage")); + LLGridManager::getInstance()->initialize("grid_test.xml"); + known_grids = LLGridManager::getInstance()->getKnownGrids(); + ensure_equals("Override custom grid login page: grids are added", + known_grids.size(), 24); + grid = LLGridManager::getInstance()->getGridInfo(); + ensure("Override custom grid login page: Command line grid login uri is an array", + grid[GRID_LOGIN_URI_VALUE].isArray()); + ensure_equals("Override custom grid login page: login uri is not changed", + grid[GRID_LOGIN_URI_VALUE][0].asString(), + std::string("https://mycustomgridchoice/cgi-bin/login.cgi")); + ensure_equals("Override custom grid login page: helper uri is not changed", + grid[GRID_HELPER_URI_VALUE].asString(), + std::string("https://mycustomgridchoice/helpers/")); + ensure_equals("Override custom grid login page: login page is changed", + grid[GRID_LOGIN_PAGE_VALUE].asString(), + std::string("myloginpage")); + } // validate grid selection template<> template<> - void viewerNetworkTestObject::test<4>() + void viewerNetworkTestObject::test<7>() { LLSD loginURI = LLSD::emptyArray(); LLSD grid = LLSD::emptyMap(); @@ -346,7 +470,7 @@ namespace tut // name based grid population template<> template<> - void viewerNetworkTestObject::test<5>() + void viewerNetworkTestObject::test<8>() { LLGridManager::getInstance()->initialize("grid_test.xml"); LLSD grid = LLSD::emptyMap(); @@ -386,7 +510,7 @@ namespace tut // persistence of the grid list with an empty gridfile. template<> template<> - void viewerNetworkTestObject::test<6>() + void viewerNetworkTestObject::test<9>() { // try with initial grid list without a grid file, // without setting the grid to a saveable favorite. @@ -420,7 +544,7 @@ namespace tut // persistence of the grid file with existing gridfile template<> template<> - void viewerNetworkTestObject::test<7>() + void viewerNetworkTestObject::test<10>() { llofstream gridfile("grid_test.xml"); |