From d500379cea865e4a6958eee82b5615ace61036c4 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 12 Jun 2012 21:58:52 -0400 Subject: PATH-735: Limit and clean up grid selection --- indra/newview/llviewernetwork.cpp | 645 ++++++++++++++++++-------------------- 1 file changed, 309 insertions(+), 336 deletions(-) (limited to 'indra/newview/llviewernetwork.cpp') diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp index ef5c65eb87..b8994d2182 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 = "name"; +/// 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")<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 '"<asString()<<"\n"; + } + LL_CONT << LL_ENDL; + mGridList[grid] = grid_data; + } + else + { + LL_WARNS("GridManager")<<"duplicate grid id'"< grid label mappings for UI purposes -std::map LLGridManager::getKnownGrids(bool favorite_only) +std::map LLGridManager::getKnownGrids() { std::map 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 + // The string must be a grid label from the gGridInfo table // loop through. We could do just a hash lookup but we also want to match - // on label + // on the id std::string grid_name = grid; if(!mGridList.has(grid_name)) { // case insensitive - grid_name = getGridByLabel(grid); + grid_name = getGrid(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); + addGrid(grid_data); } mGrid = grid; gSavedSettings.setString("CurrentGrid", grid); @@ -510,61 +408,139 @@ void LLGridManager::setGridChoice(const std::string& 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)) { - if (grid_iter->second.has(GRID_LABEL_VALUE)) + // the grid was the long name, so we're good, return it + grid_name = grid; + } + else + { + // 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& 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 '"<& 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 '"<& uris) +{ + 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()) + { + helper_uri = mGridList[grid_name][GRID_HELPER_URI_VALUE].asString(); + } + else + { + LL_WARNS("GridManager")<<"invalid grid '"<::iterator uri_it = uris.begin(); + ! mIsInProductionGrid && uri_it != uris.end(); + uri_it++ + ) + { + if( MAIN_GRID_LOGIN_URI == *uri_it ) + { + mIsInProductionGrid = true; + } + } } } @@ -593,25 +575,16 @@ 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) -- cgit v1.2.3 From 1b8bbc7b863ccfc25833dcdbbf0dd9e3e96dc0bb Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Mon, 25 Jun 2012 17:04:32 -0400 Subject: PATH-773: fix up how the location and grid selectors work on the login panel --- indra/newview/llviewernetwork.cpp | 78 ++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 33 deletions(-) (limited to 'indra/newview/llviewernetwork.cpp') diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp index b8994d2182..0382d837fa 100644 --- a/indra/newview/llviewernetwork.cpp +++ b/indra/newview/llviewernetwork.cpp @@ -354,15 +354,13 @@ 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; } 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); } @@ -384,28 +382,22 @@ std::map LLGridManager::getKnownGrids() void LLGridManager::setGridChoice(const std::string& grid) { // Set the grid choice based on a string. - // The string must be a grid label from the gGridInfo table + LL_DEBUGS("GridManager")<<"requested "< Date: Mon, 2 Jul 2012 11:14:13 -0400 Subject: improve logging of invalid grid definitions, prevent clashes with old viewers --- indra/newview/llviewernetwork.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'indra/newview/llviewernetwork.cpp') diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp index 0382d837fa..97f4c3e5fe 100644 --- a/indra/newview/llviewernetwork.cpp +++ b/indra/newview/llviewernetwork.cpp @@ -36,7 +36,7 @@ /// key used to store the grid, and the name attribute in the grid data -const std::string GRID_VALUE = "name"; +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 @@ -154,15 +154,13 @@ void LLGridManager::initialize(const std::string& grid_file) { LL_WARNS("GridManager") << "Cannot override existing grid '" << key_name << "'; ignoring definition from '"<