From 686c720ab3ad4ef53c114e97021208cad98e9ff0 Mon Sep 17 00:00:00 2001 From: Cinder <cinder@sdf.org> Date: Sun, 26 Jul 2015 20:48:16 -0600 Subject: [PATCH] Grid platform detection --- indra/newview/llfloaterreporter.cpp | 2 +- indra/newview/llmarketplacefunctions.cpp | 2 +- indra/newview/llpanellogin.cpp | 2 +- indra/newview/llpanelprofile.cpp | 5 +- indra/newview/llstartup.cpp | 2 +- indra/newview/llviewermenu.cpp | 20 ++++---- indra/newview/llviewermessage.cpp | 9 ++-- indra/newview/llviewernetwork.cpp | 59 ++++++++++++++++++------ indra/newview/llviewernetwork.h | 25 ++++++++-- indra/newview/llviewerobject.cpp | 8 ++-- indra/newview/llviewerwindow.cpp | 21 +-------- indra/newview/llvoicevivox.cpp | 2 +- indra/newview/llworld.cpp | 4 +- 13 files changed, 96 insertions(+), 65 deletions(-) diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index 01df11550e..5751b4206f 100755 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -611,7 +611,7 @@ LLSD LLFloaterReporter::gatherReport() mCopyrightWarningSeen = FALSE; std::ostringstream summary; - if (!LLGridManager::getInstance()->isInProductionGrid()) + if (LLGridManager::getInstance()->isInSLBeta()) { summary << "Preview "; } diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 4a7a4e268d..8260330335 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -46,7 +46,7 @@ static std::string getMarketplaceDomain() { std::string domain = "secondlife.com"; - if (!LLGridManager::getInstance()->isInProductionGrid()) + if (LLGridManager::getInstance()->isInSLBeta()) { const std::string& grid_id = LLGridManager::getInstance()->getGridId(); const std::string& grid_id_lower = utf8str_tolower(grid_id); diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index 125f3d464f..00d30bbdc3 100755 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -787,7 +787,7 @@ void LLPanelLogin::loadLoginPage() login_page.path(), params)); - gViewerWindow->setMenuBackgroundColor(false, !LLGridManager::getInstance()->isInProductionGrid()); + gViewerWindow->setMenuBackgroundColor(false, LLGridManager::getInstance()->isInSLBeta()); LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html"); if (web_browser->getCurrentNavUrl() != login_uri.asString()) diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index f91c4110c0..1dc638638c 100755 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -46,14 +46,15 @@ std::string getProfileURL(const std::string& agent_name) { std::string url; - if (LLGridManager::getInstance()->isInProductionGrid()) + if (LLGridManager::getInstance()->isInSLMain()) { url = gSavedSettings.getString("WebProfileURL"); } - else + else if (LLGridManager::getInstance()->isInSLBeta()) { url = gSavedSettings.getString("WebProfileNonProductionURL"); } + // *TODO: OPENSIM WebProfile url support LLSD subs; subs["AGENT_NAME"] = agent_name; url = LLWeb::expandURLSubstitutions(url,subs); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index c56733ca78..d1bf98c635 100755 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -3455,7 +3455,7 @@ bool process_login_success_response(U32& first_sim_size_x, U32& first_sim_size_y // Request the map server url // Non-agni grids have a different default location. - if (!LLGridManager::getInstance()->isInProductionGrid()) + if (LLGridManager::getInstance()->isInSLBeta()) { gSavedSettings.setString("MapServerURL", "http://test.map.secondlife.com.s3.amazonaws.com/"); } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index a9024aea8b..afc898f746 100755 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -463,13 +463,13 @@ void init_menus() gPopupMenuView->setBackgroundColor( color ); // If we are not in production, use a different color to make it apparent. - if (LLGridManager::getInstance()->isInProductionGrid()) + if (LLGridManager::getInstance()->isInSLBeta()) { - color = LLUIColorTable::instance().getColor( "MenuBarBgColor" ); + color = LLUIColorTable::instance().getColor( "MenuNonProductionBgColor" ); } else { - color = LLUIColorTable::instance().getColor( "MenuNonProductionBgColor" ); + color = LLUIColorTable::instance().getColor( "MenuBarBgColor" ); } LLView* menu_bar_holder = gViewerWindow->getRootView()->getChildView("menu_bar_holder"); @@ -480,8 +480,8 @@ void init_menus() menu_bar_holder->addChild(gMenuBarView); - gViewerWindow->setMenuBackgroundColor(false, - LLGridManager::getInstance()->isInProductionGrid()); + gViewerWindow->setMenuBackgroundColor(false, + !LLGridManager::getInstance()->isInSLBeta()); // Assume L$10 for now, the server will tell us the real cost at login // *TODO:Also fix cost in llfolderview.cpp for Inventory menus @@ -3904,7 +3904,7 @@ void set_god_level(U8 god_level) if(gViewerWindow) { gViewerWindow->setMenuBackgroundColor(god_level > GOD_NOT, - LLGridManager::getInstance()->isInProductionGrid()); + !LLGridManager::getInstance()->isInSLBeta()); } LLSD args; @@ -3944,7 +3944,7 @@ BOOL check_toggle_hacked_godmode(void*) bool enable_toggle_hacked_godmode(void*) { - return !LLGridManager::getInstance()->isInProductionGrid(); + return LLGridManager::getInstance()->isInSLBeta(); } #endif @@ -4939,7 +4939,7 @@ BOOL enable_take() return TRUE; #else # ifdef TOGGLE_HACKED_GODLIKE_VIEWER - if (!LLGridManager::getInstance()->isInProductionGrid() + if (LLGridManager::getInstance()->isInSLBeta() && gAgent.isGodlike()) { return TRUE; @@ -5578,7 +5578,7 @@ bool enable_object_delete() TRUE; #else # ifdef TOGGLE_HACKED_GODLIKE_VIEWER - (!LLGridManager::getInstance()->isInProductionGrid() + (LLGridManager::getInstance()->isInSLBeta() && gAgent.isGodlike()) || # endif LLSelectMgr::getInstance()->canDoDelete(); @@ -7571,7 +7571,7 @@ bool enable_object_take_copy() all_valid = true; #ifndef HACKED_GODLIKE_VIEWER # ifdef TOGGLE_HACKED_GODLIKE_VIEWER - if (LLGridManager::getInstance()->isInProductionGrid() + if (!LLGridManager::getInstance()->isInSLBeta() || !gAgent.isGodlike()) # endif { diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index d75e9a4c39..2387b4b53f 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -93,6 +93,7 @@ #include "lluri.h" #include "llviewergenericmessage.h" #include "llviewermenu.h" +#include "llviewernetwork.h" #include "llviewerinventory.h" #include "llviewerjoystick.h" #include "llviewerobjectlist.h" @@ -4160,14 +4161,14 @@ void process_teleport_finish(LLMessageSystem* msg, void**) // Viewer trusts the simulator. gMessageSystem->enableCircuit(sim_host, TRUE); - /*if (!gHippoGridManager->getConnectedGrid()->isSecondLife()) + if (LLGridManager::getInstance()->isInOpenSim()) { U32 region_size_x = 256; msg->getU32Fast(_PREHASH_Info, _PREHASH_RegionSizeX, region_size_x); U32 region_size_y = 256; msg->getU32Fast(_PREHASH_Info, _PREHASH_RegionSizeY, region_size_y); LLWorld::getInstance()->setRegionSize(region_size_x, region_size_y); - }*/ + } LLViewerRegion* regionp = LLWorld::getInstance()->addRegion(region_handle, sim_host); /* @@ -4447,14 +4448,14 @@ void process_crossed_region(LLMessageSystem* msg, void**) send_complete_agent_movement(sim_host); - /*if (!gHippoGridManager->getConnectedGrid()->isSecondLife()) + if (LLGridManager::getInstance()->isInOpenSim()) { U32 region_size_x = 256; msg->getU32(_PREHASH_RegionData, _PREHASH_RegionSizeX, region_size_x); U32 region_size_y = 256; msg->getU32(_PREHASH_RegionData, _PREHASH_RegionSizeY, region_size_y); LLWorld::getInstance()->setRegionSize(region_size_x, region_size_y); - }*/ + } LLViewerRegion* regionp = LLWorld::getInstance()->addRegion(region_handle, sim_host); LL_DEBUGS("CrossingCaps") << "Calling setSeedCapability from process_crossed_region(). Seed cap == " diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp index faa58d423f..db327fd64f 100755 --- a/indra/newview/llviewernetwork.cpp +++ b/indra/newview/llviewernetwork.cpp @@ -75,7 +75,7 @@ const char* DEFAULT_SLURL_BASE = "https://%s/region/"; const char* DEFAULT_APP_SLURL_BASE = "x-grid-location-info://%s/app"; LLGridManager::LLGridManager() -: mIsInProductionGrid(false) +: mPlatform(NOPLATFORM) { // by default, we use the 'grids.xml' file in the user settings directory // this file is an LLSD file containing multiple grid definitions. @@ -571,34 +571,63 @@ std::string LLGridManager::getUpdateServiceURL() void LLGridManager::updateIsInProductionGrid() { - mIsInProductionGrid = false; - // *NOTE:Mani This used to compare GRID_INFO_AGNI to gGridChoice, // but it seems that loginURI trumps that. std::vector<std::string> uris; getLoginURIs(uris); if (uris.empty()) { - mIsInProductionGrid = true; + LL_DEBUGS("GridManager") << "uri is empty, Setting grid platform to NOTHING." << LL_ENDL; + mPlatform = NOPLATFORM; + return; } - else + + // Detect Second Life Agni. We want to match the exact uri here because we're dealing with a live economy + for (const std::string& uri : uris) { - for ( std::vector<std::string>::iterator uri_it = uris.begin(); - ! mIsInProductionGrid && uri_it != uris.end(); - uri_it++ - ) + if (MAIN_GRID_LOGIN_URI == uri) { - if( MAIN_GRID_LOGIN_URI == *uri_it ) - { - mIsInProductionGrid = true; - } + LL_DEBUGS("GridManager")<< "Setting grid platform to SLMAIN" << LL_ENDL; + mPlatform = SLMAIN; + return; + } + } + + // Detect Second Life Aditi et al. + for (const std::string& uri : uris) + { + LLURI login_uri = LLURI(uri); + if (login_uri.authority().find("lindenlab.com") != std::string::npos) // Any old lab domain will do + { + LL_DEBUGS("GridManager")<< "Setting grid platform to SLBETA" << LL_ENDL; + mPlatform = SLBETA; + return; } } + + // HACK: OPENSIM - I don't really know of a good way to detect an opensim grid. Just fallthrough to that. + LL_DEBUGS("GridManager")<< "Setting grid platform to OPENSIM" << LL_ENDL; + mPlatform = OPENSIM; +} + +bool LLGridManager::isInSecondlife() +{ + return (isInSLMain() || isInSLBeta()); +} + +bool LLGridManager::isInOpenSim() +{ + return mPlatform == OPENSIM; +} + +bool LLGridManager::isInSLMain() +{ + return mPlatform == SLMAIN; } -bool LLGridManager::isInProductionGrid() +bool LLGridManager::isInSLBeta() { - return mIsInProductionGrid; + return mPlatform == SLBETA; } bool LLGridManager::isSystemGrid(const std::string& grid) diff --git a/indra/newview/llviewernetwork.h b/indra/newview/llviewernetwork.h index 8526c0ba7f..acf824e631 100755 --- a/indra/newview/llviewernetwork.h +++ b/indra/newview/llviewernetwork.h @@ -167,6 +167,13 @@ class LLGridManager : public LLSingleton<LLGridManager> std::string getAppSLURLBase() { return getAppSLURLBase(mGrid); } //@} + + typedef enum e_grid_platform { + NOPLATFORM = 0, + SLMAIN, + SLBETA, + OPENSIM + }EGridPlatform; /* ================================================================ * @name Selecting the current grid @@ -191,9 +198,19 @@ class LLGridManager : public LLSingleton<LLGridManager> /// Is the selected grid one of the hard-coded default grids (Agni or Aditi) bool isSystemGrid() { return isSystemGrid(mGrid); } - - /// Is the selected grid a production grid? - bool isInProductionGrid(); + + /// Is the selected grid Second Life? + bool isInSecondlife(); + + /// Is the selected grid OpenSimulator? + bool isInOpenSim(); + + /// Is the selected grid agni? + bool isInSLMain(); + + /// Is the selected grid aditi? + bool isInSLBeta(); + /** * yes, that's not a very helpful description. * I don't really know why that is different from isSystemGrid() @@ -222,7 +239,7 @@ class LLGridManager : public LLSingleton<LLGridManager> std::string mGrid; std::string mGridFile; LLSD mGridList; - bool mIsInProductionGrid; + EGridPlatform mPlatform; }; const S32 MAC_ADDRESS_BYTES = 6; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index eef31079b8..e13633def4 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -5594,7 +5594,7 @@ BOOL LLViewerObject::permYouOwner() const return TRUE; #else # ifdef TOGGLE_HACKED_GODLIKE_VIEWER - if (!LLGridManager::getInstance()->isInProductionGrid() + if (LLGridManager::getInstance()->isInSLBeta() && (gAgent.getGodLevel() >= GOD_MAINTENANCE)) { return TRUE; @@ -5679,7 +5679,7 @@ BOOL LLViewerObject::permCopy() const return TRUE; #else # ifdef TOGGLE_HACKED_GODLIKE_VIEWER - if (!LLGridManager::getInstance()->isInProductionGrid() + if (LLGridManager::getInstance()->isInSLBeta() && (gAgent.getGodLevel() >= GOD_MAINTENANCE)) { return TRUE; @@ -5703,7 +5703,7 @@ BOOL LLViewerObject::permMove() const return TRUE; #else # ifdef TOGGLE_HACKED_GODLIKE_VIEWER - if (!LLGridManager::getInstance()->isInProductionGrid() + if (LLGridManager::getInstance()->isInSLBeta() && (gAgent.getGodLevel() >= GOD_MAINTENANCE)) { return TRUE; @@ -5727,7 +5727,7 @@ BOOL LLViewerObject::permTransfer() const return TRUE; #else # ifdef TOGGLE_HACKED_GODLIKE_VIEWER - if (!LLGridManager::getInstance()->isInProductionGrid() + if (LLGridManager::getInstance()->isInSLBeta() && (gAgent.getGodLevel() >= GOD_MAINTENANCE)) { return TRUE; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 3d659a7ba4..8d3caecb8c 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2318,7 +2318,7 @@ void LLViewerWindow::setNormalControlsVisible( BOOL visible ) // ...and set the menu color appropriately. setMenuBackgroundColor(gAgent.getGodLevel() > GOD_NOT, - LLGridManager::getInstance()->isInProductionGrid()); + !LLGridManager::getInstance()->isInSLBeta()); } if ( gStatusBar ) @@ -2350,7 +2350,7 @@ void LLViewerWindow::setMenuBackgroundColor(bool god_mode, bool dev_grid) // god more important than project, proj more important than grid if ( god_mode ) { - if ( LLGridManager::getInstance()->isInProductionGrid() ) + if ( !LLGridManager::getInstance()->isInSLBeta() ) { new_bg_color = LLUIColorTable::instance().getColor( "MenuBarGodBgColor" ); } @@ -2359,23 +2359,6 @@ void LLViewerWindow::setMenuBackgroundColor(bool god_mode, bool dev_grid) new_bg_color = LLUIColorTable::instance().getColor( "MenuNonProductionGodBgColor" ); } } - // <alchemy> - /*else if (boost::regex_search(channel, is_beta_channel)) - { - new_bg_color = LLUIColorTable::instance().getColor( "MenuBarBetaBgColor" ); - } - else if (boost::regex_search(channel, is_project_channel)) - { - new_bg_color = LLUIColorTable::instance().getColor( "MenuBarProjectBgColor" ); - } - else if (boost::regex_search(channel, is_test_channel)) - { - new_bg_color = LLUIColorTable::instance().getColor( "MenuBarTestBgColor" ); - } - else if(!LLGridManager::getInstance()->isInProductionGrid()) - { - new_bg_color = LLUIColorTable::instance().getColor( "MenuNonProductionBgColor" ); - }*/ // </alchemy> else { new_bg_color = LLUIColorTable::instance().getColor( "MenuBarBgColor" ); diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 84793136bf..6e44ceee09 100755 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -613,7 +613,7 @@ void LLVivoxVoiceClient::login( // we have an empty account server name // so we fall back to hardcoded defaults - if(LLGridManager::getInstance()->isInProductionGrid()) + if(LLGridManager::getInstance()->isInSLMain()) { // Use the release account server mVoiceSIPURIHostName = "bhr.vivox.com"; diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index d10472e72d..361015305c 100755 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -1163,14 +1163,14 @@ void process_enable_simulator(LLMessageSystem *msg, void **user_data) // Viewer trusts the simulator. msg->enableCircuit(sim, TRUE); - /*if (!gHippoGridManager->getConnectedGrid()->isSecondLife()) + if (LLGridManager::getInstance()->isInOpenSim()) { U32 region_size_x = 256; msg->getU32Fast(_PREHASH_SimulatorInfo, _PREHASH_RegionSizeX, region_size_x); U32 region_size_y = 256; msg->getU32Fast(_PREHASH_SimulatorInfo, _PREHASH_RegionSizeY, region_size_y); LLWorld::getInstance()->setRegionSize(region_size_x, region_size_y); - }*/ + } LLWorld::getInstance()->addRegion(handle, sim); // give the simulator a message it can use to get ip and port -- GitLab