diff --git a/indra/newview/fsgridhandler.cpp b/indra/newview/fsgridhandler.cpp index cfb39e5e5e..1ec663622f 100644 --- a/indra/newview/fsgridhandler.cpp +++ b/indra/newview/fsgridhandler.cpp @@ -26,11 +26,10 @@ * $/LicenseInfo$ */ - #include "llviewerprecompiledheaders.h" #include "llcommandhandler.h" -#include "lllogininstance.h" // to check if logged in yet +#include "lllogininstance.h" // to check if logged in yet #include "llnotifications.h" #include "llnotificationsutil.h" #include "llviewernetwork.h" @@ -50,35 +49,34 @@ #include "fscorehttputil.h" #include "fspanellogin.h" -#include "lfsimfeaturehandler.h" // -#include "llmaterialtable.h" // FIRE-31628 for access to static var +#include "lfsimfeaturehandler.h" // +#include "llmaterialtable.h" // FIRE-31628 for access to static var -void gridDownloadError( LLSD const &aData, LLGridManager* mOwner, GridEntry* mData, LLGridManager::AddState mState ) +void gridDownloadError(const LLSD& aData, LLGridManager* mOwner, GridEntry* mData, LLGridManager::AddState mState) { - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD( aData ); + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(aData); - if (HTTP_GATEWAY_TIME_OUT == status.getType() )// gateway timeout ... well ... retry once >_> + if (HTTP_GATEWAY_TIME_OUT == status.getType()) // gateway timeout ... well ... retry once >_> { if (LLGridManager::FETCH == mState) { - mOwner->addGrid(mData, LLGridManager::RETRY); + mOwner->addGrid(mData, LLGridManager::RETRY); } - } else if (status.getType() == HTTP_NOT_MODIFIED && LLGridManager::TRYLEGACY != mState) // not modified { mOwner->addGrid(mData, LLGridManager::FINISH); } - else if (HTTP_INTERNAL_ERROR == status.getType() && LLGridManager::LOCAL == mState) //add localhost even if its not up + else if (HTTP_INTERNAL_ERROR == status.getType() && LLGridManager::LOCAL == mState) // add localhost even if its not up { mOwner->addGrid(mData, LLGridManager::FINISH); - //since we know now that its not up we cold also start it + // since we know now that its not up we cold also start it } - else if (LLGridManager::TRYLEGACY == mState) //we did TRYLEGACY and faild + else if (LLGridManager::TRYLEGACY == mState) // we did TRYLEGACY and faild { LLSD args; args["GRID"] = mData->grid[GRID_VALUE]; - //Could not add [GRID] to the grid list. + // Could not add [GRID] to the grid list. std::string reason_dialog = "Server didn't provide grid info: "; reason_dialog.append(mData->last_http_error); reason_dialog.append("\nPlease check if the loginuri is correct and"); @@ -100,27 +98,28 @@ void gridDownloadError( LLSD const &aData, LLGridManager* mOwner, GridEntry* mDa } } -void gridDownloadComplete( LLSD const &aData, LLGridManager* mOwner, GridEntry* mData, LLGridManager::AddState mState ) +void gridDownloadComplete(const LLSD& aData, LLGridManager* mOwner, GridEntry* mData, LLGridManager::AddState mState) { - //mOwner->decResponderCount(); - LLSD header = aData[ LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS ][ LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD( aData[ LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS ] ); + // mOwner->decResponderCount(); + LLSD header = aData[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS][LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS]; + LLCore::HttpStatus status = + LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(aData[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]); - const LLSD::Binary &rawData = aData[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary(); + const LLSD::Binary& rawData = aData[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary(); // LL_DEBUGS("GridManager") << mData->grid[GRID_VALUE] << " status: " << getStatus() << " reason: " << getReason() << LL_ENDL; - if(LLGridManager::TRYLEGACY == mState && HTTP_OK == status.getType() ) + if (LLGridManager::TRYLEGACY == mState && HTTP_OK == status.getType()) { mOwner->addGrid(mData, LLGridManager::SYSTEM); } - else if (HTTP_OK == status.getType() )// OK + else if (HTTP_OK == status.getType()) // OK { - LL_DEBUGS("GridManager") << "Parsing gridinfo xml file from " - << mData->grid[GRID_VALUE] << LL_ENDL; + LL_DEBUGS("GridManager") << "Parsing gridinfo xml file from " << mData->grid[GRID_VALUE] << LL_ENDL; std::string stringData; - stringData.assign( rawData.begin(), rawData.end() ); // LLXMLNode::parseBuffer wants a U8*, not a const U8*, so need to copy here just to be safe - if(LLXMLNode::parseBuffer( reinterpret_cast ( &stringData[0] ), (U64)stringData.size(), mData->info_root, NULL)) + stringData.assign(rawData.begin(), + rawData.end()); // LLXMLNode::parseBuffer wants a U8*, not a const U8*, so need to copy here just to be safe + if (LLXMLNode::parseBuffer(reinterpret_cast(&stringData[0]), (U64)stringData.size(), mData->info_root, NULL)) { mOwner->gridInfoResponderCB(mData); } @@ -128,45 +127,40 @@ void gridDownloadComplete( LLSD const &aData, LLGridManager* mOwner, GridEntry* { LLSD args; args["GRID"] = mData->grid[GRID_VALUE]; - //Could not add [GRID] to the grid list. + // Could not add [GRID] to the grid list. args["REASON"] = "Server provided broken grid info xml. Please"; //[REASON] contact support of [GRID]. LLNotificationsUtil::add("CantAddGrid", args); - LL_WARNS() << " Could not parse grid info xml from server." - << mData->grid[GRID_VALUE] << " skipping." << LL_ENDL; + LL_WARNS() << " Could not parse grid info xml from server." << mData->grid[GRID_VALUE] << " skipping." << LL_ENDL; mOwner->addGrid(mData, LLGridManager::FAIL); } } - else if (HTTP_INTERNAL_ERROR == status.getType() && LLGridManager::LOCAL == mState) //add localhost even if its not up + else if (HTTP_INTERNAL_ERROR == status.getType() && LLGridManager::LOCAL == mState) // add localhost even if its not up { - mOwner->addGrid(mData, LLGridManager::FINISH); - //since we know now that its not up we cold also start it + mOwner->addGrid(mData, LLGridManager::FINISH); + // since we know now that its not up we cold also start it } else { - gridDownloadError( aData[ LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS ], mOwner, mData, mState ); + gridDownloadError(aData[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS], mOwner, mData, mState); } } const char* DEFAULT_LOGIN_PAGE = "https://phoenixviewer.com/app/loginV3/"; -const char* SYSTEM_GRID_SLURL_BASE = "secondlife://%s/secondlife/"; -const char* MAIN_GRID_SLURL_BASE = "http://maps.secondlife.com/secondlife/"; +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"; -const char* DEFAULT_HOP_BASE = "hop://%s/"; // -const char* DEFAULT_SLURL_BASE = "https://%s/region/"; +const char* DEFAULT_HOP_BASE = "hop://%s/"; // +const char* DEFAULT_SLURL_BASE = "https://%s/region/"; const char* DEFAULT_APP_SLURL_BASE = "x-grid-location-info://%s/app"; // -LLGridManager::LLGridManager() -: EGridPlatform(GP_NOTSET), - mReadyToLogin(false), - mCommandLineDone(false), - mResponderCount(0) +LLGridManager::LLGridManager() : EGridPlatform(GP_NOTSET), mReadyToLogin(false), mCommandLineDone(false), mResponderCount(0), mClassifiedFee(0), mDirectoryFee(0) { - mGrid.clear() ; + mGrid.clear(); } void LLGridManager::resetGrids() @@ -183,9 +177,9 @@ void LLGridManager::initGrids() mGridList = LLSD(); #ifndef SINGLEGRID - std::string grid_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "grids.xml"); - std::string grid_user_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grids.user.xml"); - std::string grid_remote_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grids.remote.xml"); + std::string grid_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "grids.xml"); + std::string grid_user_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grids.user.xml"); + std::string grid_remote_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grids.remote.xml"); mGridFile = grid_user_file; #endif @@ -197,14 +191,14 @@ void LLGridManager::initGrids() initGridList(grid_user_file, FINISH); #endif - if(!mCommandLineDone) + if (!mCommandLineDone) { initCmdLineGrids(); } // FIRE-20112 in case grid was set bt settings/cmd line, set it now - if( mStartupGrid.size() ) - setGridChoice( mStartupGrid ); + if (mStartupGrid.size()) + setGridChoice(mStartupGrid); mStartupGrid = ""; // } @@ -216,7 +210,7 @@ void LLGridManager::initSystemGrids() void LLGridManager::initGridList(std::string grid_file, AddState state) { - LLSD other_grids; + LLSD other_grids; llifstream llsd_xml; if (grid_file.empty()) { @@ -228,29 +222,27 @@ void LLGridManager::initGridList(std::string grid_file, AddState state) return; } - llsd_xml.open( grid_file.c_str(), std::ios::in | std::ios::binary ); + llsd_xml.open(grid_file.c_str(), std::ios::in | std::ios::binary); // parse through the gridfile if (llsd_xml.is_open()) { - LLSDSerialize::fromXMLDocument( other_grids, llsd_xml ); + LLSDSerialize::fromXMLDocument(other_grids, llsd_xml); if (other_grids.isMap()) { - for (LLSD::map_iterator grid_itr = other_grids.beginMap(); - grid_itr != other_grids.endMap(); - ++grid_itr) + for (LLSD::map_iterator grid_itr = other_grids.beginMap(); grid_itr != other_grids.endMap(); ++grid_itr) { - LLSD::String key_name = grid_itr->first; - GridEntry* grid_entry = new GridEntry; + LLSD::String key_name = grid_itr->first; + GridEntry* grid_entry = new GridEntry; grid_entry->set_current = false; - grid_entry->grid = grid_itr->second; + grid_entry->grid = grid_itr->second; LL_DEBUGS("GridManager") << "reading: " << key_name << LL_ENDL; try { addGrid(grid_entry, state); - //LL_DEBUGS("GridManager") << "Added grid: " << key_name << LL_ENDL; + // LL_DEBUGS("GridManager") << "Added grid: " << key_name << LL_ENDL; } catch (...) { @@ -281,7 +273,6 @@ void LLGridManager::initCmdLineGrids() if (grid.empty()) { grid = getGridByLabel(cmd_line_grid); - } if (grid.empty()) { @@ -323,9 +314,9 @@ void LLGridManager::initCmdLineGrids() else { LL_DEBUGS("GridManager") << "Trying to fetch commandline grid " << grid << LL_ENDL; - GridEntry* grid_entry = new GridEntry; - grid_entry->set_current = true; - grid_entry->grid = LLSD::emptyMap(); + GridEntry* grid_entry = new GridEntry; + grid_entry->set_current = true; + grid_entry->grid = LLSD::emptyMap(); grid_entry->grid[GRID_VALUE] = grid; // add the grid with the additional values, or update the @@ -334,7 +325,7 @@ void LLGridManager::initCmdLineGrids() { addGrid(grid_entry, FETCH); } - catch(LLInvalidGridName ex) + catch (LLInvalidGridName ex) { } } @@ -344,7 +335,7 @@ LLGridManager::~LLGridManager() { } -void LLGridManager::getGridData(const std::string &grid, LLSD& grid_info) +void LLGridManager::getGridData(const std::string& grid, LLSD& grid_info) { grid_info = mGridList[grid]; } @@ -367,21 +358,21 @@ void LLGridManager::gridInfoResponderCB(GridEntry* grid_entry) grid_entry->grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray(); grid_entry->grid[GRID_LOGIN_URI_VALUE].append(node->getTextContents()); - LL_DEBUGS("GridManager") << "[\""<grid[GRID_LOGIN_URI_VALUE] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[GRID_LOGIN_URI_VALUE] << LL_ENDL; continue; } check = "gridname"; if (node->hasName(check)) { grid_entry->grid[GRID_LABEL_VALUE] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[GRID_LABEL_VALUE] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[GRID_LABEL_VALUE] << LL_ENDL; continue; } check = "gridnick"; if (node->hasName(check)) { grid_entry->grid[check] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[check] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[check] << LL_ENDL; continue; } check = "gatekeeper"; @@ -390,113 +381,113 @@ void LLGridManager::gridInfoResponderCB(GridEntry* grid_entry) LLURI gatekeeper(node->getTextContents()); grid_entry->grid[check] = gatekeeper.authority(); - LL_DEBUGS("GridManager") << "[\""<grid[check] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[check] << LL_ENDL; continue; } check = "welcome"; if (node->hasName(check)) { grid_entry->grid[GRID_LOGIN_PAGE_VALUE] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[GRID_LOGIN_PAGE_VALUE] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[GRID_LOGIN_PAGE_VALUE] << LL_ENDL; continue; } check = GRID_REGISTER_NEW_ACCOUNT; if (node->hasName(check)) { grid_entry->grid[check] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[check] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[check] << LL_ENDL; continue; } check = GRID_FORGOT_PASSWORD; if (node->hasName(check)) { grid_entry->grid[check] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[check] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[check] << LL_ENDL; continue; } check = "help"; if (node->hasName(check)) { grid_entry->grid[check] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[check] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[check] << LL_ENDL; continue; } check = "about"; if (node->hasName(check)) { grid_entry->grid[check] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[check] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[check] << LL_ENDL; continue; } check = "search"; if (node->hasName(check)) { grid_entry->grid[GRID_SEARCH] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[GRID_SEARCH] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[GRID_SEARCH] << LL_ENDL; continue; } check = "web_profile_url"; if (node->hasName(check)) { grid_entry->grid[GRID_WEB_PROFILE_VALUE] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[GRID_WEB_PROFILE_VALUE] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[GRID_WEB_PROFILE_VALUE] << LL_ENDL; continue; } check = "profileuri"; if (node->hasName(check)) { grid_entry->grid[GRID_WEB_PROFILE_VALUE] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[GRID_WEB_PROFILE_VALUE] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[GRID_WEB_PROFILE_VALUE] << LL_ENDL; continue; } check = "SendGridInfoToViewerOnLogin"; if (node->hasName(check)) { grid_entry->grid[GRID_SENDGRIDINFO] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[GRID_SENDGRIDINFO] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[GRID_SENDGRIDINFO] << LL_ENDL; continue; } check = "DirectoryFee"; if (node->hasName(check)) { grid_entry->grid[GRID_DIRECTORY_FEE] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[GRID_DIRECTORY_FEE] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[GRID_DIRECTORY_FEE] << LL_ENDL; continue; } check = "platform"; if (node->hasName(check)) { grid_entry->grid[GRID_PLATFORM] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[GRID_PLATFORM] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[GRID_PLATFORM] << LL_ENDL; continue; } check = "message"; if (node->hasName(check)) { grid_entry->grid[GRID_MESSAGE] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[GRID_MESSAGE] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[GRID_MESSAGE] << LL_ENDL; continue; } check = "helperuri"; if (node->hasName(check)) { grid_entry->grid[GRID_HELPER_URI_VALUE] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[GRID_HELPER_URI_VALUE] << LL_ENDL; - //don't continue, also check the next + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[GRID_HELPER_URI_VALUE] << LL_ENDL; + // don't continue, also check the next } check = "economy"; if (node->hasName(check)) - { //sic! economy and helperuri is 2 names for the same + { // sic! economy and helperuri is 2 names for the same grid_entry->grid[GRID_HELPER_URI_VALUE] = node->getTextContents(); - LL_DEBUGS("GridManager") << "[\""<grid[GRID_HELPER_URI_VALUE] << LL_ENDL; + LL_DEBUGS("GridManager") << "[\"" << check << "\"]: " << grid_entry->grid[GRID_HELPER_URI_VALUE] << LL_ENDL; } } std::string grid = grid_entry->grid[GRID_VALUE].asString(); std::string slurl_base(llformat(DEFAULT_HOP_BASE, grid.c_str())); // - grid_entry->grid[GRID_SLURL_BASE]= slurl_base; + grid_entry->grid[GRID_SLURL_BASE] = slurl_base; - LLDate now = LLDate::now(); + LLDate now = LLDate::now(); grid_entry->grid["LastModified"] = now; addGrid(grid_entry, FINISH); @@ -504,31 +495,31 @@ void LLGridManager::gridInfoResponderCB(GridEntry* grid_entry) void LLGridManager::addGrid(const std::string& loginuri) { - GridEntry* grid_entry = new GridEntry; - grid_entry->set_current = true; - grid_entry->grid = LLSD::emptyMap(); + GridEntry* grid_entry = new GridEntry; + grid_entry->set_current = true; + grid_entry->grid = LLSD::emptyMap(); grid_entry->grid[GRID_VALUE] = loginuri; addGrid(grid_entry, FETCH); } /// LLGridManager::addGrid - add a grid to the grid list, populating the needed values /// if they're not populated yet. -void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) +void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) { - if(!grid_entry) + if (!grid_entry) { LL_WARNS() << "addGrid called with NULL grid_entry. Please send a bug report." << LL_ENDL; state = FAIL; } - if(!grid_entry->grid.has(GRID_VALUE)) + if (!grid_entry->grid.has(GRID_VALUE)) { state = FAIL; } - else if(grid_entry->grid[GRID_VALUE].asString().empty()) + else if (grid_entry->grid[GRID_VALUE].asString().empty()) { state = FAIL; } - else if(!grid_entry->grid.isMap()) + else if (!grid_entry->grid.isMap()) { state = FAIL; } @@ -538,12 +529,12 @@ void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) state = REMOVE; } - if ((FETCH == state) ||(FETCHTEMP == state) || (SYSTEM == state)) + if ((FETCH == state) || (FETCHTEMP == state) || (SYSTEM == state)) { std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]); // grid should be in the form of a dns address // but also support localhost:9000 or localhost:9000/login - if ( !grid.empty() && grid.find_first_not_of("abcdefghijklmnopqrstuvwxyz1234567890-_.:/@% ") != std::string::npos) + if (!grid.empty() && grid.find_first_not_of("abcdefghijklmnopqrstuvwxyz1234567890-_.:/@% ") != std::string::npos) { // // AW: this can be helpful for debugging // printf("grid name: %s", grid.c_str()); @@ -562,44 +553,44 @@ void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) // trim last slash size_t pos = grid.find_last_of("/"); - if ( (grid.length()-1) == pos ) + if ((grid.length() - 1) == pos) { - if (!mGridList.has(grid))// deal with hand edited entries *sigh* + if (!mGridList.has(grid)) // deal with hand edited entries *sigh* { grid.erase(pos); - grid_entry->grid[GRID_VALUE] = grid; + grid_entry->grid[GRID_VALUE] = grid; } } // trim region from hypergrid uris - std::string grid_trimmed = trimHypergrid(grid); + std::string grid_trimmed = trimHypergrid(grid); if (grid_trimmed != grid) { - grid = grid_trimmed; - grid_entry->grid[GRID_VALUE] = grid; - grid_entry->grid["HG"] = "TRUE"; + grid = grid_trimmed; + grid_entry->grid[GRID_VALUE] = grid; + grid_entry->grid["HG"] = "TRUE"; } if (FETCHTEMP == state) { grid_entry->grid["FLAG_TEMPORARY"] = "TRUE"; - state = FETCH; + state = FETCH; } } if (FETCH == state || RETRY == state) { std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]); -// FIRE-24068 allow https support - based on patch by unregi resident + // FIRE-24068 allow https support - based on patch by unregi resident std::string uri; - std::string match = "://"; - size_t find_scheme = grid.find(match); - if ( std::string::npos != find_scheme) + std::string match = "://"; + size_t find_scheme = grid.find(match); + if (std::string::npos != find_scheme) { - uri = grid; // assign the full URI + uri = grid; // assign the full URI grid.erase(0, find_scheme + match.length()); // trim the protocol - grid_entry->grid[GRID_VALUE] = grid; // keep the name + grid_entry->grid[GRID_VALUE] = grid; // keep the name } else { @@ -615,11 +606,10 @@ void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) else { char host_name[255]; - host_name[254] ='\0'; + host_name[254] = '\0'; gethostname(host_name, 254); - if (std::string::npos != uri.find(host_name)|| - std::string::npos != uri.find("127.0.0.1") - || std::string::npos != uri.find("localhost") ) + if (std::string::npos != uri.find(host_name) || std::string::npos != uri.find("127.0.0.1") || + std::string::npos != uri.find("localhost")) { LL_DEBUGS("GridManager") << "state = LOCAL" << LL_ENDL; state = LOCAL; @@ -628,7 +618,7 @@ void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) grid_entry->grid[GRID_LOGIN_URI_VALUE].append(uri); size_t pos = uri.find_last_of("/"); - if ( (uri.length()-1) != pos ) + if ((uri.length() - 1) != pos) { uri.append("/"); } @@ -637,17 +627,18 @@ void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) LL_DEBUGS("GridManager") << "get_grid_info uri: " << uri << LL_ENDL; time_t last_modified = 0; - if(grid_entry->grid.has("LastModified")) + if (grid_entry->grid.has("LastModified")) { LLDate saved_value = grid_entry->grid["LastModified"]; - last_modified = (time_t)saved_value.secondsSinceEpoch(); + last_modified = (time_t)saved_value.secondsSinceEpoch(); } LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); httpOpts->setLastModified((long)last_modified); - FSCoreHttpUtil::callbackHttpGetRaw( uri, boost::bind( gridDownloadComplete, _1, this, grid_entry, state ), - boost::bind( gridDownloadError, _1, this, grid_entry, state ), LLCore::HttpHeaders::ptr_t(), httpOpts ); + FSCoreHttpUtil::callbackHttpGetRaw(uri, boost::bind(gridDownloadComplete, _1, this, grid_entry, state), + boost::bind(gridDownloadError, _1, this, grid_entry, state), LLCore::HttpHeaders::ptr_t(), + httpOpts); return; } } @@ -655,10 +646,10 @@ void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) if (TRYLEGACY == state) { std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]); - std::string uri = "https://"; + std::string uri = "https://"; uri.append(grid); size_t pos = uri.find_last_of("/"); - if ( (uri.length()-1) != pos ) + if ((uri.length() - 1) != pos) { uri.append("/"); } @@ -666,8 +657,8 @@ void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) LL_WARNS() << "No gridinfo found. Trying if legacy login page exists: " << uri << LL_ENDL; - FSCoreHttpUtil::callbackHttpGetRaw( uri, boost::bind( gridDownloadComplete, _1, this, grid_entry, state ), - boost::bind( gridDownloadError, _1, this, grid_entry, state ) ); + FSCoreHttpUtil::callbackHttpGetRaw(uri, boost::bind(gridDownloadComplete, _1, this, grid_entry, state), + boost::bind(gridDownloadError, _1, this, grid_entry, state)); return; } @@ -737,24 +728,23 @@ void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) grid_entry->grid[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_ACCOUNT); } - bool is_current = grid_entry->set_current; + bool is_current = grid_entry->set_current; grid_entry->set_current = false; - if (!mGridList.has(grid)) //new grid + if (!mGridList.has(grid)) // new grid { LL_DEBUGS("GridManager") << "new grid" << LL_ENDL; - if (!grid_entry->grid.has("USER_DELETED") - && !grid_entry->grid.has("DEPRECATED")) + if (!grid_entry->grid.has("USER_DELETED") && !grid_entry->grid.has("DEPRECATED")) { - //finally add the grid \o/ + // finally add the grid \o/ mGridList[grid] = grid_entry->grid; - list_changed = true; + list_changed = true; LL_DEBUGS("GridManager") << "Adding new entry: " << grid << LL_ENDL; } else if (grid_entry->grid.has("DEPRECATED")) { - //add the deprecated entry but hide it - //so it doesn't get used from the user list + // add the deprecated entry but hide it + // so it doesn't get used from the user list mGridList[grid] = grid_entry->grid; LL_DEBUGS("GridManager") << "Marking entry as deprecated : " << grid << LL_ENDL; } @@ -772,38 +762,38 @@ void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) { LL_DEBUGS("GridManager") << "Removing entry marked as deprecated in the fallback list: " << grid << LL_ENDL; mGridList[grid] = grid_entry->grid; - list_changed = true; + list_changed = true; } else if (grid_entry->grid.has("USER_DELETED")) { // entries from the fallback list can't be deleted // hide them instead mGridList[grid] = grid_entry->grid; - list_changed = true; + list_changed = true; LL_DEBUGS("GridManager") << "Entry marked for deletion: " << grid << LL_ENDL; } else if (!existing_grid.has("LastModified")) { - //lack of "LastModified" means existing_grid is from fallback list, - // assume its anyway older and override with the new entry + // lack of "LastModified" means existing_grid is from fallback list, + // assume its anyway older and override with the new entry mGridList[grid] = grid_entry->grid; - list_changed = true; + list_changed = true; LL_DEBUGS("GridManager") << "Using custom entry: " << grid << LL_ENDL; } else if (grid_entry->grid.has("LastModified")) { LLDate testing_newer = grid_entry->grid["LastModified"]; - LLDate existing = existing_grid["LastModified"]; + LLDate existing = existing_grid["LastModified"]; LL_DEBUGS("GridManager") << "testing_newer " << testing_newer << " existing " << existing << LL_ENDL; if (testing_newer.secondsSinceEpoch() > existing.secondsSinceEpoch()) { - //existing_grid is older, override. + // existing_grid is older, override. mGridList[grid] = grid_entry->grid; - list_changed = true; + list_changed = true; LL_DEBUGS("GridManager") << "Updating entry: " << grid << LL_ENDL; } } @@ -826,20 +816,20 @@ void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) } } -// This is only of use if we want to fetch infos of entire gridlists at startup -/* - if(grid_entry && FINISH == state || FAIL == state) - { - - if((FINISH == state && !mCommandLineDone && 0 == mResponderCount) - ||(FAIL == state && grid_entry->set_current) ) + // This is only of use if we want to fetch infos of entire gridlists at startup + /* + if(grid_entry && FINISH == state || FAIL == state) { - LL_DEBUGS("GridManager") << "init CmdLineGrids" << LL_ENDL; - initCmdLineGrids(); + if((FINISH == state && !mCommandLineDone && 0 == mResponderCount) + ||(FAIL == state && grid_entry->set_current) ) + { + LL_DEBUGS("GridManager") << "init CmdLineGrids" << LL_ENDL; + + initCmdLineGrids(); + } } - } -*/ + */ if (FAIL == state) { mGridListChangedSignal(false); @@ -855,34 +845,33 @@ void LLGridManager::addGrid(GridEntry* grid_entry, AddState state) // // LLGridManager::addSystemGrid - helper for adding a system grid. void LLGridManager::addSystemGrid(const std::string& label, - const std::string& name, - const std::string& nick, - const std::string& login_uri, - const std::string& helper, - const std::string& login_page ) + const std::string& name, + const std::string& nick, + const std::string& login_uri, + const std::string& helper, + const std::string& login_page) { - GridEntry* grid_entry = new GridEntry; - grid_entry->set_current = false; - grid_entry->grid = LLSD::emptyMap(); - grid_entry->grid[GRID_VALUE] = name; - grid_entry->grid[GRID_LABEL_VALUE] = label; - grid_entry->grid[GRID_NICK_VALUE] = nick; + GridEntry* grid_entry = new GridEntry; + grid_entry->set_current = false; + grid_entry->grid = LLSD::emptyMap(); + grid_entry->grid[GRID_VALUE] = name; + grid_entry->grid[GRID_LABEL_VALUE] = label; + grid_entry->grid[GRID_NICK_VALUE] = nick; grid_entry->grid[GRID_HELPER_URI_VALUE] = helper; - grid_entry->grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray(); + grid_entry->grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray(); grid_entry->grid[GRID_LOGIN_URI_VALUE].append(login_uri); - grid_entry->grid[GRID_LOGIN_PAGE_VALUE] = login_page; - grid_entry->grid[GRID_IS_SYSTEM_GRID_VALUE] = true; + grid_entry->grid[GRID_LOGIN_PAGE_VALUE] = login_page; + grid_entry->grid[GRID_IS_SYSTEM_GRID_VALUE] = true; grid_entry->grid[GRID_LOGIN_IDENTIFIER_TYPES] = LLSD::emptyArray(); grid_entry->grid[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_AGENT); grid_entry->grid[GRID_APP_SLURL_BASE] = SYSTEM_GRID_APP_SLURL_BASE; - // only add the system grids beyond agni to the visible list // if we're building a debug version. if (name == std::string(MAINGRID)) { - grid_entry->grid[GRID_SLURL_BASE] = MAIN_GRID_SLURL_BASE; + grid_entry->grid[GRID_SLURL_BASE] = MAIN_GRID_SLURL_BASE; grid_entry->grid[GRID_IS_FAVORITE_VALUE] = true; } else @@ -890,31 +879,31 @@ void LLGridManager::addSystemGrid(const std::string& label, grid_entry->grid[GRID_SLURL_BASE] = llformat(SYSTEM_GRID_SLURL_BASE, label.c_str()); } - LL_DEBUGS("PanelLogin") << " " << grid_entry->grid[GRID_LOGIN_PAGE_VALUE]<< LL_ENDL; + LL_DEBUGS("PanelLogin") << " " << grid_entry->grid[GRID_LOGIN_PAGE_VALUE] << LL_ENDL; try { addGrid(grid_entry, SYSTEM); } - catch(LLInvalidGridName ex) + catch (LLInvalidGridName ex) { } } void LLGridManager::reFetchGrid(const std::string& grid, bool set_current) { - GridEntry* grid_entry = new GridEntry; + GridEntry* grid_entry = new GridEntry; grid_entry->grid[GRID_VALUE] = grid; - grid_entry->set_current = set_current; + grid_entry->set_current = set_current; addGrid(grid_entry, FETCH); } void LLGridManager::removeGrid(const std::string& grid) { - GridEntry* grid_entry = new GridEntry; - grid_entry->grid[GRID_VALUE] = grid; - grid_entry->grid["USER_DELETED"]="TRUE"; - grid_entry->set_current = false; + GridEntry* grid_entry = new GridEntry; + grid_entry->grid[GRID_VALUE] = grid; + grid_entry->grid["USER_DELETED"] = "TRUE"; + grid_entry->set_current = false; addGrid(grid_entry, REMOVE); } @@ -927,13 +916,11 @@ boost::signals2::connection LLGridManager::addGridListChangedCallback(grid_list_ std::map LLGridManager::getKnownGrids() { std::map result; - for(LLSD::map_iterator grid_iter = mGridList.beginMap(); - grid_iter != mGridList.endMap(); - grid_iter++) + for (LLSD::map_iterator grid_iter = mGridList.beginMap(); grid_iter != mGridList.endMap(); grid_iter++) { - if (!(grid_iter->second.has("DEPRECATED")//use in fallback list only - ||grid_iter->second.has("USER_DELETED")//use in user list only - )) + if (!(grid_iter->second.has("DEPRECATED") // use in fallback list only + || grid_iter->second.has("USER_DELETED") // use in user list only + )) { result[grid_iter->first] = grid_iter->second[GRID_LABEL_VALUE].asString(); } @@ -942,7 +929,7 @@ std::map LLGridManager::getKnownGrids() return result; } -std::string LLGridManager::getGrid( const std::string &grid ) +std::string LLGridManager::getGrid(const std::string& grid) const { std::string grid_name; @@ -985,7 +972,7 @@ void LLGridManager::setGridChoice(const std::string& grid) } // FIRE-20112 viewer is not properly initialized yet, store grid choice and call this method again later. - if( mGridList.size() == 0 ) + if (mGridList.size() == 0) { mStartupGrid = grid; return; @@ -1001,7 +988,7 @@ void LLGridManager::setGridChoice(const std::string& grid) // loop through. We could do just a hash lookup but we also want to match // on label - mReadyToLogin = false; + mReadyToLogin = false; std::string grid_name = grid; if (mGridList.has(grid_name)) { @@ -1029,24 +1016,24 @@ void LLGridManager::setGridChoice(const std::string& grid) if (grid_name.empty()) { - LL_DEBUGS("GridManager")<< "trying to fetch grid: " << grid << LL_ENDL; + LL_DEBUGS("GridManager") << "trying to fetch grid: " << grid << LL_ENDL; // the grid was not in the list of grids. - GridEntry* grid_entry = new GridEntry; - grid_entry->grid = LLSD::emptyMap(); + GridEntry* grid_entry = new GridEntry; + grid_entry->grid = LLSD::emptyMap(); grid_entry->grid[GRID_VALUE] = grid; - grid_entry->set_current = true; + grid_entry->set_current = true; try { addGrid(grid_entry, FETCH); } - catch(LLInvalidGridName ex) + catch (LLInvalidGridName ex) { } } else { - LL_DEBUGS("GridManager")<< "setting grid choice: " << grid << LL_ENDL; - mGrid = grid;// AW: don't set mGrid anywhere else + LL_DEBUGS("GridManager") << "setting grid choice: " << grid << LL_ENDL; + mGrid = grid; // AW: don't set mGrid anywhere else getGridData(mConnectedGrid); gSavedSettings.setString("CurrentGrid", grid); LLTrans::setDefaultArg("CURRENT_GRID", getGridLabel()); // @@ -1056,7 +1043,7 @@ void LLGridManager::setGridChoice(const std::string& grid) } } -std::string LLGridManager::getGridByProbing( const std::string &probe_for, bool case_sensitive) +std::string LLGridManager::getGridByProbing(const std::string& probe_for, bool case_sensitive) const { std::string ret; ret = getGridByHostName(probe_for, case_sensitive); @@ -1072,36 +1059,34 @@ std::string LLGridManager::getGridByProbing( const std::string &probe_for, bool return ret; } -std::string LLGridManager::getGridByLabel( const std::string &grid_label, bool case_sensitive) +std::string LLGridManager::getGridByLabel(const std::string& grid_label, bool case_sensitive) const { return grid_label.empty() ? std::string() : getGridByAttribute(GRID_LABEL_VALUE, grid_label, case_sensitive); } -std::string LLGridManager::getGridByGridNick( const std::string &grid_nick, bool case_sensitive) +std::string LLGridManager::getGridByGridNick(const std::string& grid_nick, bool case_sensitive) const { return grid_nick.empty() ? std::string() : getGridByAttribute(GRID_NICK_VALUE, grid_nick, case_sensitive); } -std::string LLGridManager::getGridByHostName( const std::string &host_name, bool case_sensitive) +std::string LLGridManager::getGridByHostName(const std::string& host_name, bool case_sensitive) const { return host_name.empty() ? std::string() : getGridByAttribute(GRID_VALUE, host_name, case_sensitive); } -std::string LLGridManager::getGridByAttribute( const std::string &attribute, const std::string &attribute_value, bool case_sensitive) +std::string LLGridManager::getGridByAttribute(const std::string& attribute, const std::string& attribute_value, bool case_sensitive) const { if (attribute.empty() || attribute_value.empty()) { return std::string(); } - for (LLSD::map_iterator grid_iter = mGridList.beginMap(); - grid_iter != mGridList.endMap(); - grid_iter++) + for (LLSD::map_const_iterator grid_iter = mGridList.beginMap(); grid_iter != mGridList.endMap(); grid_iter++) { if (grid_iter->second.has(attribute)) { - if (0 == (case_sensitive ? LLStringUtil::compareStrings(attribute_value, grid_iter->second[attribute].asString()) : - LLStringUtil::compareInsensitive(attribute_value, grid_iter->second[attribute].asString()))) + if (0 == (case_sensitive ? LLStringUtil::compareStrings(attribute_value, grid_iter->second[attribute].asString()) + : LLStringUtil::compareInsensitive(attribute_value, grid_iter->second[attribute].asString()))) { return grid_iter->first; } @@ -1217,22 +1202,22 @@ void LLGridManager::updateIsInProductionGrid() LLURI login_uri = LLURI(uris[0]); // LL looks if "agni" is contained in the string for SL main grid detection. // cool for http://agni.nastyfraud.com/steal.php#allyourmoney - if (login_uri.authority().find("login.agni.lindenlab.com") == 0) + if (login_uri.authority().find("login.agni.lindenlab.com") == 0) { - LL_DEBUGS("GridManager")<< "uri: "<< login_uri.authority() << " setting grid platform to SL MAIN" << LL_ENDL; + LL_DEBUGS("GridManager") << "uri: " << login_uri.authority() << " setting grid platform to SL MAIN" << LL_ENDL; EGridPlatform = GP_SLMAIN; return; } - else if (login_uri.authority().find("lindenlab.com") != std::string::npos ) //here is no real money + else if (login_uri.authority().find("lindenlab.com") != std::string::npos) // here is no real money { - LL_DEBUGS("GridManager")<< "uri: "<< login_uri.authority() << " setting grid platform to SL BETA" << LL_ENDL; + LL_DEBUGS("GridManager") << "uri: " << login_uri.authority() << " setting grid platform to SL BETA" << LL_ENDL; EGridPlatform = GP_SLBETA; return; } if (mGridList[mGrid][GRID_PLATFORM].asString() == "Aurora") { - LL_DEBUGS("GridManager")<< "uri: "<< uris[0] << "setting grid platform to AURORA" << LL_ENDL; + LL_DEBUGS("GridManager") << "uri: " << uris[0] << "setting grid platform to AURORA" << LL_ENDL; EGridPlatform = GP_AURORA; return; } @@ -1241,13 +1226,13 @@ void LLGridManager::updateIsInProductionGrid() // NOTE: This is more TPVP compliant than LLs own viewer, where // setting the command line login page can be used for spoofing. LLURI login_page = LLURI(getLoginPage()); - if (login_page.authority().find("lindenlab.com") != std::string::npos) + if (login_page.authority().find("lindenlab.com") != std::string::npos) { setGridChoice(MAINGRID); return; } - LL_DEBUGS("GridManager")<< "uri: "<< login_uri.authority() << " setting grid platform to OPENSIM" << LL_ENDL; + LL_DEBUGS("GridManager") << "uri: " << login_uri.authority() << " setting grid platform to OPENSIM" << LL_ENDL; EGridPlatform = GP_OPENSIM; } @@ -1289,14 +1274,10 @@ void LLGridManager::saveGridList() { mGridList[mGrid].erase("FLAG_TEMPORARY"); } - for(LLSD::map_iterator grid_iter = mGridList.beginMap(); - grid_iter != mGridList.endMap(); - grid_iter++) + for (LLSD::map_iterator grid_iter = mGridList.beginMap(); grid_iter != mGridList.endMap(); grid_iter++) { - if (!(grid_iter->first.empty() || - grid_iter->second.isUndefined() || - grid_iter->second.has("FLAG_TEMPORARY") || - grid_iter->second.has("DEPRECATED"))) + if (!(grid_iter->first.empty() || grid_iter->second.isUndefined() || grid_iter->second.has("FLAG_TEMPORARY") || + grid_iter->second.has("DEPRECATED"))) { output_grid_list[grid_iter->first] = grid_iter->second; } @@ -1316,12 +1297,12 @@ std::string LLGridManager::trimHypergrid(const std::string& trim) pos = grid.find_last_of(":"); if (pos != std::string::npos) { - std::string part = grid.substr(pos+1, grid.length()-1); + std::string part = grid.substr(pos + 1, grid.length() - 1); // in hope numbers only is a good guess for it's a port number if (std::string::npos != part.find_first_not_of("1234567890/")) { - //and erase if not - grid.erase(pos,grid.length()-1); + // and erase if not + grid.erase(pos, grid.length() - 1); } } @@ -1338,18 +1319,18 @@ std::string LLGridManager::getSLURLBase(const std::string& grid) std::string grid_trimmed = trimHypergrid(grid); - if(mGridList.has(grid_trimmed) && mGridList[grid_trimmed].has(GRID_SLURL_BASE)) + if (mGridList.has(grid_trimmed) && mGridList[grid_trimmed].has(GRID_SLURL_BASE)) { ret = mGridList[grid_trimmed][GRID_SLURL_BASE].asString(); - LL_DEBUGS("GridManager") << "GRID_SLURL_BASE: " << ret << LL_ENDL;// + LL_DEBUGS("GridManager") << "GRID_SLURL_BASE: " << ret << LL_ENDL; // } -// + // else { LL_DEBUGS("GridManager") << "Trying to fetch info for:" << grid << LL_ENDL; - GridEntry* grid_entry = new GridEntry; - grid_entry->set_current = false; - grid_entry->grid = LLSD::emptyMap(); + GridEntry* grid_entry = new GridEntry; + grid_entry->set_current = false; + grid_entry->grid = LLSD::emptyMap(); grid_entry->grid[GRID_VALUE] = grid; // add the grid with the additional values, or update the @@ -1359,20 +1340,20 @@ std::string LLGridManager::getSLURLBase(const std::string& grid) // deal with hand edited entries std::string grid_norm = grid; - if( grid_norm.size() ) + if (grid_norm.size()) { size_t pos = grid_norm.find_last_of("/"); - if ( (grid_norm.length()-1) == pos ) + if ((grid_norm.length() - 1) == pos) grid_norm.erase(pos); } - ret = llformat(DEFAULT_HOP_BASE, grid_norm.c_str());// - LL_DEBUGS("GridManager") << "DEFAULT_HOP_BASE: " << ret << LL_ENDL;// -// + ret = llformat(DEFAULT_HOP_BASE, grid_norm.c_str()); // + LL_DEBUGS("GridManager") << "DEFAULT_HOP_BASE: " << ret << LL_ENDL; // + // } - return ret; + return ret; } // get app slurl base for the given region @@ -1382,17 +1363,17 @@ std::string LLGridManager::getAppSLURLBase(const std::string& grid) std::string grid_base; std::string ret; - if(mGridList.has(grid) && mGridList[grid].has(GRID_APP_SLURL_BASE)) + if (mGridList.has(grid) && mGridList[grid].has(GRID_APP_SLURL_BASE)) { ret = mGridList[grid][GRID_APP_SLURL_BASE].asString(); } else { std::string app_base; - if(mGridList.has(grid) && mGridList[grid].has(GRID_SLURL_BASE)) + if (mGridList.has(grid) && mGridList[grid].has(GRID_SLURL_BASE)) { std::string grid_slurl_base = mGridList[grid][GRID_SLURL_BASE].asString(); - if( 0 == grid_slurl_base.find("hop://")) + if (0 == grid_slurl_base.find("hop://")) { app_base = DEFAULT_HOP_BASE; app_base.append("app"); @@ -1409,12 +1390,12 @@ std::string LLGridManager::getAppSLURLBase(const std::string& grid) // deal with hand edited entries std::string grid_norm = grid; - size_t pos = grid_norm.find_last_of("/"); - if ( (grid_norm.length()-1) == pos ) + size_t pos = grid_norm.find_last_of("/"); + if ((grid_norm.length() - 1) == pos) { grid_norm.erase(pos); } - ret = llformat(app_base.c_str(), grid_norm.c_str()); + ret = llformat(app_base.c_str(), grid_norm.c_str()); } LL_DEBUGS("GridManager") << "App slurl base: " << ret << " - grid = " << grid << LL_ENDL; @@ -1424,9 +1405,7 @@ std::string LLGridManager::getAppSLURLBase(const std::string& grid) class FSGridManagerCommandHandler : public LLCommandHandler { public: - FSGridManagerCommandHandler() : LLCommandHandler("gridmanager", UNTRUSTED_THROTTLE), - mDownloadConnection() - { } + FSGridManagerCommandHandler() : LLCommandHandler("gridmanager", UNTRUSTED_THROTTLE), mDownloadConnection() {} ~FSGridManagerCommandHandler() { @@ -1448,7 +1427,8 @@ public: if (params[0].asString() == "addgrid") { std::string login_uri = LLURI::unescape(params[1].asString()); - mDownloadConnection = LLGridManager::instance().addGridListChangedCallback(boost::bind(&FSGridManagerCommandHandler::handleGridDownloadComplete, this, _1)); + mDownloadConnection = LLGridManager::instance().addGridListChangedCallback( + boost::bind(&FSGridManagerCommandHandler::handleGridDownloadComplete, this, _1)); LLGridManager::instance().addGrid(login_uri); return true; } diff --git a/indra/newview/fsgridhandler.h b/indra/newview/fsgridhandler.h index 7071bd5be5..2e3fcd1329 100644 --- a/indra/newview/fsgridhandler.h +++ b/indra/newview/fsgridhandler.h @@ -36,19 +36,19 @@ #include extern const char* DEFAULT_LOGIN_PAGE; -//Kokua: for llviewernetwork_test -const S32 KNOWN_GRIDS_SIZE = 3; +// Kokua: for llviewernetwork_test +const S32 KNOWN_GRIDS_SIZE = 3; -const std::string GRID_VALUE = "name"; -const std::string GRID_LABEL_VALUE = "gridname"; -const std::string GRID_ID_VALUE = "grid_login_id"; -const std::string GRID_LOGIN_URI_VALUE = "loginuri"; -const std::string GRID_UPDATE_SERVICE_URL = "update_query_url_base"; -const std::string GRID_HELPER_URI_VALUE = "helperuri"; -const std::string GRID_LOGIN_PAGE_VALUE = "loginpage"; -const std::string GRID_IS_SYSTEM_GRID_VALUE = "system_grid"; -const std::string GRID_IS_FAVORITE_VALUE = "favorite"; -const std::string GRID_LOGIN_IDENTIFIER_TYPES = "login_identifier_types"; +const std::string GRID_VALUE = "name"; +const std::string GRID_LABEL_VALUE = "gridname"; +const std::string GRID_ID_VALUE = "grid_login_id"; +const std::string GRID_LOGIN_URI_VALUE = "loginuri"; +const std::string GRID_UPDATE_SERVICE_URL = "update_query_url_base"; +const std::string GRID_HELPER_URI_VALUE = "helperuri"; +const std::string GRID_LOGIN_PAGE_VALUE = "loginpage"; +const std::string GRID_IS_SYSTEM_GRID_VALUE = "system_grid"; +const std::string GRID_IS_FAVORITE_VALUE = "favorite"; +const std::string GRID_LOGIN_IDENTIFIER_TYPES = "login_identifier_types"; const std::string GRID_NICK_VALUE = "gridnick"; const std::string GRID_REGISTER_NEW_ACCOUNT = "register"; @@ -66,8 +66,8 @@ const std::string GRID_MESSAGE = "message"; // 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 GRID_SLURL_BASE = "slurl_base"; +const std::string GRID_APP_SLURL_BASE = "app_slurl_base"; // Inworldz special #define INWORLDZ_URI "inworldz.com:8002" @@ -76,24 +76,22 @@ class GridInfoRequestResponder; struct GridEntry { - LLSD grid; + LLSD grid; LLXMLNodePtr info_root; - bool set_current; - std::string last_http_error; + bool set_current; + std::string last_http_error; }; class LLInvalidGridName { public: - LLInvalidGridName(std::string grid) : mGrid(grid) - { - } + LLInvalidGridName(std::string grid) : mGrid(grid) {} std::string name() { return mGrid; } + protected: std::string mGrid; }; - /** * @brief A class to manage the grids available to the viewer * including persistance. This class also maintains the currently @@ -128,7 +126,7 @@ public: void initCmdLineGrids(); void resetGrids(); // grid list management - bool isReadyToLogin() const {return mReadyToLogin;} + bool isReadyToLogin() const { return mReadyToLogin; } // add a grid to the list of grids void addGrid(const std::string& loginuri); @@ -140,8 +138,8 @@ public: std::map getKnownGrids(); // this was getGridInfo - renamed to avoid ambiguity with the OpenSim grid_info - void getGridData(const std::string& grid, LLSD &grid_info); - void getGridData(LLSD &grid_info) { getGridData(mGrid, grid_info); } + void getGridData(const std::string& grid, LLSD& grid_info); + void getGridData(LLSD& grid_info) { getGridData(mGrid, grid_info); } // current grid management @@ -151,7 +149,7 @@ public: void setGridChoice(const std::string& grid); /// Return the name of a grid, given either its name or its id - std::string getGrid( const std::string &grid ); + std::string getGrid(const std::string& grid) const; /// Get the id (short form selector) for a given grid; example: "agni" std::string getGridId(const std::string& grid); @@ -160,7 +158,7 @@ public: std::string getGridId() { return getGridId(mGrid); } /// Deprecated for compatibility with LL. Use getGridId() instead. - //std::string getGridNick() { return mGridList[mGrid][GRID_NICK_VALUE]; } + // std::string getGridNick() { return mGridList[mGrid][GRID_NICK_VALUE]; } /// Get the user-friendly long form descriptor for a given grid; example: "Second Life" std::string getGridLabel(const std::string& grid); @@ -201,66 +199,67 @@ public: void setWebProfileUrl(const std::string& url) { mGridList[mGrid][GRID_WEB_PROFILE_VALUE] = url; } - bool hasGrid(const std::string& grid){ return mGridList.has(grid); } - bool isTemporary(){ return mGridList[mGrid].has("FLAG_TEMPORARY"); } - bool isTemporary(const std::string& grid){ return mGridList[grid].has("FLAG_TEMPORARY"); } + bool hasGrid(const std::string& grid) const { return mGridList.has(grid); } + bool isTemporary() const { return mGridList[mGrid].has("FLAG_TEMPORARY"); } + bool isTemporary(const std::string& grid) const { return mGridList[grid].has("FLAG_TEMPORARY"); } // tell if we got this from a Hypergrid SLURL bool isHyperGrid(const std::string& grid) { return mGridList[grid].has("HG"); } // tell if we know how to acess this grid via Hypergrid std::string getGatekeeper() { return getGatekeeper(mGrid); } - std::string getGatekeeper(const std::string& grid) { return mGridList[grid].has("gatekeeper") ? mGridList[grid]["gatekeeper"].asString() : std::string(); } - - std::string getGridByLabel( const std::string &grid_label, bool case_sensitive = false); - - std::string getGridByProbing( const std::string &probe_for, bool case_sensitive = false); - std::string getGridByGridNick( const std::string &grid_nick, bool case_sensitive = false); - std::string getGridByHostName( const std::string &host_name, bool case_sensitive = false); - std::string getGridByAttribute(const std::string &attribute, const std::string &attribute_value, bool case_sensitive ); - - bool isSystemGrid(const std::string& grid) + std::string getGatekeeper(const std::string& grid) { - return mGridList.has(grid) && - mGridList[grid].has(GRID_IS_SYSTEM_GRID_VALUE) && + return mGridList[grid].has("gatekeeper") ? mGridList[grid]["gatekeeper"].asString() : std::string(); + } + + std::string getGridByLabel(const std::string& grid_label, bool case_sensitive = false) const; + + std::string getGridByProbing(const std::string& probe_for, bool case_sensitive = false) const; + std::string getGridByGridNick(const std::string& grid_nick, bool case_sensitive = false) const; + std::string getGridByHostName(const std::string& host_name, bool case_sensitive = false) const; + std::string getGridByAttribute(const std::string& attribute, const std::string& attribute_value, bool case_sensitive) const; + + bool isSystemGrid(const std::string& grid) const + { + return mGridList.has(grid) && mGridList[grid].has(GRID_IS_SYSTEM_GRID_VALUE) && mGridList[grid][GRID_IS_SYSTEM_GRID_VALUE].asBoolean(); } - bool isSystemGrid() { return isSystemGrid(mGrid); } + bool isSystemGrid() const { return isSystemGrid(mGrid); } - typedef boost::function grid_list_changed_callback_t; + typedef boost::function grid_list_changed_callback_t; typedef boost::signals2::signal grid_list_changed_signal_t; boost::signals2::connection addGridListChangedCallback(grid_list_changed_callback_t cb); grid_list_changed_signal_t mGridListChangedSignal; - bool isInSecondLife() const; - bool isInSLMain() const; - bool isInSLBeta() const; - bool isInOpenSim() const; - bool isInAuroraSim() const; - void saveGridList(); - void addGrid(GridEntry* grid_info, AddState state); + bool isInSecondLife() const; + bool isInSLMain() const; + bool isInSLBeta() const; + bool isInOpenSim() const; + bool isInAuroraSim() const; + void saveGridList(); + void addGrid(GridEntry* grid_info, AddState state); - void setClassifiedFee(const S32 classified_fee) { sClassifiedFee = classified_fee; } - S32 getClassifiedFee() { return sClassifiedFee; } - void setDirectoryFee(const S32 directory_fee) { sDirectoryFee = directory_fee; } - S32 getDirectoryFee() { return sDirectoryFee; } + void setClassifiedFee(const S32 classified_fee) { mClassifiedFee = classified_fee; } + S32 getClassifiedFee() const { return mClassifiedFee; } + void setDirectoryFee(const S32 directory_fee) { mDirectoryFee = directory_fee; } + S32 getDirectoryFee() const { return mDirectoryFee; } private: friend class GridInfoRequestResponder; - friend void gridDownloadComplete( LLSD const &aData, LLGridManager* mOwner, GridEntry* mData, LLGridManager::AddState mState ); - friend void gridDownloadError( LLSD const &aData, LLGridManager* mOwner, GridEntry* mData, LLGridManager::AddState mState ); + friend void gridDownloadComplete(LLSD const& aData, LLGridManager* mOwner, GridEntry* mData, LLGridManager::AddState mState); + friend void gridDownloadError(LLSD const& aData, LLGridManager* mOwner, GridEntry* mData, LLGridManager::AddState mState); - void incResponderCount(){++mResponderCount;} - void decResponderCount(){--mResponderCount;} + void incResponderCount() { ++mResponderCount; } + void decResponderCount() { --mResponderCount; } void gridInfoResponderCB(GridEntry* grid_data); - void setGridData(const LLSD &grid_info) { mGridList[mGrid]=grid_info; } - S32 sClassifiedFee; - S32 sDirectoryFee; + void setGridData(const LLSD& grid_info) { mGridList[mGrid] = grid_info; } + S32 mClassifiedFee; + S32 mDirectoryFee; protected: - void updateIsInProductionGrid(); // helper function for adding the predefined grids @@ -271,15 +270,14 @@ protected: const std::string& helper, const std::string& login_page); - std::string mGrid; std::string mGridFile; std::string mStartupGrid; - LLSD mGridList; - LLSD mConnectedGrid; - int mResponderCount; - bool mReadyToLogin; - bool mCommandLineDone; + LLSD mGridList; + LLSD mConnectedGrid; + int mResponderCount; + bool mReadyToLogin; + bool mCommandLineDone; enum e_grid_platform { diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp index 8a5c3388b8..f62aa01002 100644 --- a/indra/newview/llviewernetwork.cpp +++ b/indra/newview/llviewernetwork.cpp @@ -434,7 +434,7 @@ void LLGridManager::setGridChoice(const std::string& grid) } } -std::string LLGridManager::getGrid( const std::string &grid ) +std::string LLGridManager::getGrid( const std::string &grid ) const { std::string grid_name; @@ -446,7 +446,7 @@ std::string LLGridManager::getGrid( const std::string &grid ) else { // search the grid list for a grid with a matching id - for(LLSD::map_iterator grid_iter = mGridList.beginMap(); + for(LLSD::map_const_iterator grid_iter = mGridList.beginMap(); grid_name.empty() && grid_iter != mGridList.endMap(); grid_iter++) { diff --git a/indra/newview/llviewernetwork.h b/indra/newview/llviewernetwork.h index 86a46e4849..4ddafe98d2 100644 --- a/indra/newview/llviewernetwork.h +++ b/indra/newview/llviewernetwork.h @@ -95,7 +95,7 @@ class LLGridManager : public LLSingleton * descriptive form (it is used in the login panel grid menu, for example). */ /// Return the name of a grid, given either its name or its id - std::string getGrid( const std::string &grid ); + std::string getGrid( const std::string &grid ) const; /// Get the id (short form selector) for a given grid std::string getGridId(const std::string& grid); @@ -201,7 +201,7 @@ class LLGridManager : public LLSingleton void setGridChoice(const std::string& grid); /// Returns the name of the currently selected grid - std::string getGrid() { return mGrid; } + std::string getGrid() const { return mGrid; } //@}