diff options
Diffstat (limited to 'indra/newview/llpanellogin.cpp')
-rw-r--r-- | indra/newview/llpanellogin.cpp | 527 |
1 files changed, 256 insertions, 271 deletions
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index 76aadcd913..bcb90bcb56 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -27,6 +27,7 @@ #include "llviewerprecompiledheaders.h" #include "llpanellogin.h" +#include "lllayoutstack.h" #include "indra_constants.h" // for key and mask constants #include "llfloaterreg.h" @@ -104,7 +105,6 @@ public: // Public methods //--------------------------------------------------------------------------- LLPanelLogin::LLPanelLogin(const LLRect &rect, - BOOL show_server, void (*callback)(S32 option, void* user_data), void *cb_data) : LLPanel(), @@ -119,7 +119,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, // instance management if (LLPanelLogin::sInstance) { - llwarns << "Duplicate instance of login view deleted" << llendl; + LL_WARNS("AppInit") << "Duplicate instance of login view deleted" << LL_ENDL; // Don't leave bad pointer in gFocusMgr gFocusMgr.setDefaultKeyboardFocus(NULL); @@ -139,44 +139,83 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, mLogoImage = LLUI::getUIImage("startup_logo"); buildFromFile( "panel_login.xml"); - + reshape(rect.getWidth(), rect.getHeight()); - getChild<LLLineEditor>("password_edit")->setKeystrokeCallback(onPassKey, this); + LLLineEditor* password_edit(getChild<LLLineEditor>("password_edit")); + password_edit->setKeystrokeCallback(onPassKey, this); + // STEAM-14: When user presses Enter with this field in focus, initiate login + password_edit->setCommitCallback(boost::bind(&LLPanelLogin::onClickConnect, this)); // change z sort of clickable text to be behind buttons sendChildToBack(getChildView("forgot_password_text")); - if(LLStartUp::getStartSLURL().getType() != LLSLURL::LOCATION) + LLComboBox* location_combo = getChild<LLComboBox>("start_location_combo"); + updateLocationSelectorsVisibility(); // separate so that it can be called from preferences + location_combo->setFocusLostCallback(boost::bind(&LLPanelLogin::onLocationSLURL, this)); + + LLComboBox* server_choice_combo = getChild<LLComboBox>("server_combo"); + server_choice_combo->setCommitCallback(boost::bind(&LLPanelLogin::onSelectServer, this)); + + // Load all of the grids, sorted, and then add a bar and the current grid at the top + server_choice_combo->removeall(); + + std::string current_grid = LLGridManager::getInstance()->getGrid(); + std::map<std::string, std::string> known_grids = LLGridManager::getInstance()->getKnownGrids(); + for (std::map<std::string, std::string>::iterator grid_choice = known_grids.begin(); + grid_choice != known_grids.end(); + grid_choice++) { - LLSLURL slurl(gSavedSettings.getString("LoginLocation")); - LLStartUp::setStartSLURL(slurl); + if (!grid_choice->first.empty() && current_grid != grid_choice->first) + { + LL_DEBUGS("AppInit")<<"adding "<<grid_choice->first<<LL_ENDL; + server_choice_combo->add(grid_choice->second, grid_choice->first); + } } - updateLocationCombo(false); - - LLComboBox* server_choice_combo = sInstance->getChild<LLComboBox>("server_combo"); - server_choice_combo->setCommitCallback(onSelectServer, NULL); - server_choice_combo->setFocusLostCallback(boost::bind(onServerComboLostFocus, _1)); - updateServerCombo(); + server_choice_combo->sortByName(); + server_choice_combo->addSeparator(ADD_TOP); + LL_DEBUGS("AppInit")<<"adding current "<<current_grid<<LL_ENDL; + server_choice_combo->add(LLGridManager::getInstance()->getGridLabel(), + current_grid, + ADD_TOP); + server_choice_combo->selectFirstItem(); + LLSLURL start_slurl(LLStartUp::getStartSLURL()); + if ( !start_slurl.isSpatial() ) // has a start been established by the command line or NextLoginLocation ? + { + // no, so get the preference setting + std::string defaultStartLocation = gSavedSettings.getString("LoginLocation"); + LL_INFOS("AppInit")<<"default LoginLocation '"<<defaultStartLocation<<"'"<<LL_ENDL; + LLSLURL defaultStart(defaultStartLocation); + if ( defaultStart.isSpatial() ) + { + LLStartUp::setStartSLURL(defaultStart); + } + else + { + LL_INFOS("AppInit")<<"no valid LoginLocation, using home"<<LL_ENDL; + LLSLURL homeStart(LLSLURL::SIM_LOCATION_HOME); + LLStartUp::setStartSLURL(homeStart); + } + } + else + { + LLPanelLogin::onUpdateStartSLURL(start_slurl); // updates grid if needed + } + childSetAction("connect_btn", onClickConnect, this); - getChild<LLPanel>("login")->setDefaultBtn("connect_btn"); + getChild<LLPanel>("links_login_panel")->setDefaultBtn("connect_btn"); std::string channel = LLVersionInfo::getChannel(); std::string version = llformat("%s (%d)", LLVersionInfo::getShortVersion().c_str(), LLVersionInfo::getBuild()); - //LLTextBox* channel_text = getChild<LLTextBox>("channel_text"); - //channel_text->setTextArg("[CHANNEL]", channel); // though not displayed - //channel_text->setTextArg("[VERSION]", version); - //channel_text->setClickedCallback(onClickVersion, this); LLTextBox* forgot_password_text = getChild<LLTextBox>("forgot_password_text"); forgot_password_text->setClickedCallback(onClickForgotPassword, NULL); - LLTextBox* create_new_account_text = getChild<LLTextBox>("create_new_account_text"); - create_new_account_text->setClickedCallback(onClickNewAccount, NULL); + childSetAction("create_new_account_btn", onClickNewAccount, NULL); LLTextBox* need_help_text = getChild<LLTextBox>("login_help"); need_help_text->setClickedCallback(onClickHelp, NULL); @@ -184,17 +223,17 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, // get the web browser control LLMediaCtrl* web_browser = getChild<LLMediaCtrl>("login_html"); web_browser->addObserver(this); - + reshapeBrowser(); loadLoginPage(); - + // Show last logged in user favorites in "Start at" combo. addUsersWithFavoritesToUsername(); - getChild<LLComboBox>("username_combo")->setTextChangedCallback(boost::bind(&LLPanelLogin::addFavoritesToStartLocation, this)); - - updateLocationCombo(false); - + LLComboBox* username_combo(getChild<LLComboBox>("username_combo")); + username_combo->setTextChangedCallback(boost::bind(&LLPanelLogin::addFavoritesToStartLocation, this)); + // STEAM-14: When user presses Enter with this field in focus, initiate login + username_combo->setCommitCallback(boost::bind(&LLPanelLogin::onClickConnect, this)); } void LLPanelLogin::addUsersWithFavoritesToUsername() @@ -389,25 +428,27 @@ void LLPanelLogin::giveFocus() // static void LLPanelLogin::showLoginWidgets() { - // *NOTE: Mani - This may or may not be obselete code. - // It seems to be part of the defunct? reg-in-client project. - sInstance->getChildView("login_widgets")->setVisible( true); - LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html"); - sInstance->reshapeBrowser(); - // *TODO: Append all the usual login parameters, like first_login=Y etc. - std::string splash_screen_url = LLGridManager::getInstance()->getLoginPage(); - web_browser->navigateTo( splash_screen_url, "text/html" ); - LLUICtrl* username_combo = sInstance->getChild<LLUICtrl>("username_combo"); - username_combo->setFocus(TRUE); + if (sInstance) + { + // *NOTE: Mani - This may or may not be obselete code. + // It seems to be part of the defunct? reg-in-client project. + sInstance->getChildView("login_widgets")->setVisible( true); + LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html"); + sInstance->reshapeBrowser(); + // *TODO: Append all the usual login parameters, like first_login=Y etc. + std::string splash_screen_url = LLGridManager::getInstance()->getLoginPage(); + web_browser->navigateTo( splash_screen_url, "text/html" ); + LLUICtrl* username_combo = sInstance->getChild<LLUICtrl>("username_combo"); + username_combo->setFocus(TRUE); + } } // static void LLPanelLogin::show(const LLRect &rect, - BOOL show_server, void (*callback)(S32 option, void* user_data), void* callback_data) { - new LLPanelLogin(rect, show_server, callback, callback_data); + new LLPanelLogin(rect, callback, callback_data); if( !gFocusMgr.getKeyboardFocus() ) { @@ -567,21 +608,6 @@ void LLPanelLogin::getFields(LLPointer<LLCredential>& credential, remember = sInstance->getChild<LLUICtrl>("remember_check")->getValue(); } -// static -BOOL LLPanelLogin::isGridComboDirty() -{ - BOOL user_picked = FALSE; - if (!sInstance) - { - llwarns << "Attempted getServer with no login view shown" << llendl; - } - else - { - LLComboBox* combo = sInstance->getChild<LLComboBox>("server_combo"); - user_picked = combo->isDirty(); - } - return user_picked; -} // static BOOL LLPanelLogin::areCredentialFieldsDirty() @@ -611,83 +637,86 @@ BOOL LLPanelLogin::areCredentialFieldsDirty() // static -void LLPanelLogin::updateLocationCombo( bool force_visible ) +void LLPanelLogin::updateLocationSelectorsVisibility() { - if (!sInstance) + if (sInstance) { - return; + BOOL show_start = gSavedSettings.getBOOL("ShowStartLocation"); + sInstance->getChild<LLLayoutPanel>("start_location_panel")->setVisible(show_start); + + BOOL show_server = gSavedSettings.getBOOL("ForceShowGrid"); + sInstance->getChild<LLLayoutPanel>("grid_panel")->setVisible(show_server); } - - LLComboBox* combo = sInstance->getChild<LLComboBox>("start_location_combo"); - - switch(LLStartUp::getStartSLURL().getType()) - { - case LLSLURL::LOCATION: - { - - combo->setCurrentByIndex( 2 ); - combo->setTextEntry(LLStartUp::getStartSLURL().getLocationString()); - break; - } - case LLSLURL::HOME_LOCATION: - combo->setCurrentByIndex(1); - break; - default: - combo->setCurrentByIndex(0); - break; - } - - BOOL show_start = TRUE; - - if ( ! force_visible ) - show_start = gSavedSettings.getBOOL("ShowStartLocation"); - - sInstance->getChildView("start_location_combo")->setVisible( show_start); - sInstance->getChildView("start_location_text")->setVisible( show_start); - - BOOL show_server = gSavedSettings.getBOOL("ForceShowGrid"); - sInstance->getChildView("server_combo_text")->setVisible( show_server); - sInstance->getChildView("server_combo")->setVisible( show_server); } -// static -void LLPanelLogin::updateStartSLURL() +// static - called from LLStartUp::setStartSLURL +void LLPanelLogin::onUpdateStartSLURL(const LLSLURL& new_start_slurl) { if (!sInstance) return; - - LLComboBox* combo = sInstance->getChild<LLComboBox>("start_location_combo"); - S32 index = combo->getCurrentIndex(); - - switch (index) + + LL_DEBUGS("AppInit")<<new_start_slurl.asString()<<LL_ENDL; + + LLComboBox* location_combo = sInstance->getChild<LLComboBox>("start_location_combo"); + /* + * Determine whether or not the new_start_slurl modifies the grid. + * + * Note that some forms that could be in the slurl are grid-agnostic., + * such as "home". Other forms, such as + * https://grid.example.com/region/Party%20Town/20/30/5 + * specify a particular grid; in those cases we want to change the grid + * and the grid selector to match the new value. + */ + enum LLSLURL::SLURL_TYPE new_slurl_type = new_start_slurl.getType(); + switch ( new_slurl_type ) { - case 0: + case LLSLURL::LOCATION: + { + std::string slurl_grid = LLGridManager::getInstance()->getGrid(new_start_slurl.getGrid()); + if ( ! slurl_grid.empty() ) // is that a valid grid? { - LLStartUp::setStartSLURL(LLSLURL(LLSLURL::SIM_LOCATION_LAST)); - break; - } - case 1: - { - LLStartUp::setStartSLURL(LLSLURL(LLSLURL::SIM_LOCATION_HOME)); - break; - } - default: - { - LLSLURL slurl = LLSLURL(combo->getValue().asString()); - if(slurl.getType() == LLSLURL::LOCATION) + if ( slurl_grid != LLGridManager::getInstance()->getGrid() ) // new grid? { - // we've changed the grid, so update the grid selection - LLStartUp::setStartSLURL(slurl); + // the slurl changes the grid, so update everything to match + LLGridManager::getInstance()->setGridChoice(slurl_grid); + + // update the grid selector to match the slurl + LLComboBox* server_combo = sInstance->getChild<LLComboBox>("server_combo"); + std::string server_label(LLGridManager::getInstance()->getGridLabel(slurl_grid)); + server_combo->setSimple(server_label); + + updateServer(); // to change the links and splash screen } - break; - } + location_combo->setTextEntry(new_start_slurl.getLocationString()); + } + else + { + // the grid specified by the slurl is not known + LLNotificationsUtil::add("InvalidLocationSLURL"); + LL_WARNS("AppInit")<<"invalid LoginLocation:"<<new_start_slurl.asString()<<LL_ENDL; + location_combo->setTextEntry(LLStringUtil::null); + } + } + break; + + case LLSLURL::HOME_LOCATION: + location_combo->setCurrentByIndex(1); // home location + break; + + case LLSLURL::LAST_LOCATION: + location_combo->setCurrentByIndex(0); // last location + break; + + default: + LL_WARNS("AppInit")<<"invalid login slurl, using home"<<LL_ENDL; + location_combo->setCurrentByIndex(1); // home location + break; } } - void LLPanelLogin::setLocation(const LLSLURL& slurl) { - LLStartUp::setStartSLURL(slurl); - updateServer(); + LL_DEBUGS("AppInit")<<"setting Location "<<slurl.asString()<<LL_ENDL; + LLStartUp::setStartSLURL(slurl); // calls onUpdateStartSLURL, above } // static @@ -705,13 +734,14 @@ void LLPanelLogin::closePanel() // static void LLPanelLogin::setAlwaysRefresh(bool refresh) { - if (LLStartUp::getStartupState() >= STATE_LOGIN_CLEANUP) return; - - LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html"); - - if (web_browser) + if (sInstance && LLStartUp::getStartupState() < STATE_LOGIN_CLEANUP) { - web_browser->setAlwaysRefresh(refresh); + LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html"); + + if (web_browser) + { + web_browser->setAlwaysRefresh(refresh); + } } } @@ -720,82 +750,53 @@ void LLPanelLogin::setAlwaysRefresh(bool refresh) void LLPanelLogin::loadLoginPage() { if (!sInstance) return; - - std::ostringstream oStr; - std::string login_page = LLGridManager::getInstance()->getLoginPage(); + LLURI login_page = LLURI(LLGridManager::getInstance()->getLoginPage()); + LLSD params(login_page.queryMap()); - oStr << login_page; - - // Use the right delimeter depending on how LLURI parses the URL - LLURI login_page_uri = LLURI(login_page); - - std::string first_query_delimiter = "&"; - if (login_page_uri.queryMap().size() == 0) - { - first_query_delimiter = "?"; - } + LL_DEBUGS("AppInit") << "login_page: " << login_page << LL_ENDL; // Language - std::string language = LLUI::getLanguage(); - oStr << first_query_delimiter<<"lang=" << language; - + params["lang"] = LLUI::getLanguage(); + // First Login? if (gSavedSettings.getBOOL("FirstLoginThisInstall")) { - oStr << "&firstlogin=TRUE"; + params["firstlogin"] = "TRUE"; // not bool: server expects string TRUE } // Channel and Version - std::string version = llformat("%s (%d)", - LLVersionInfo::getShortVersion().c_str(), - LLVersionInfo::getBuild()); + params["version"] = llformat("%s (%d)", + LLVersionInfo::getShortVersion().c_str(), + LLVersionInfo::getBuild()); + params["channel"] = LLVersionInfo::getChannel(); - char* curl_channel = curl_escape(LLVersionInfo::getChannel().c_str(), 0); - char* curl_version = curl_escape(version.c_str(), 0); + // Grid + params["grid"] = LLGridManager::getInstance()->getGridId(); - oStr << "&channel=" << curl_channel; - oStr << "&version=" << curl_version; + // add OS info + params["os"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple(); - curl_free(curl_channel); - curl_free(curl_version); + // sourceid + params["sourceid"] = gSavedSettings.getString("sourceid"); + + // Make an LLURI with this augmented info + LLURI login_uri(LLURI::buildHTTP(login_page.authority(), + login_page.path(), + params)); - // Grid - char* curl_grid = curl_escape(LLGridManager::getInstance()->getGridLabel().c_str(), 0); - oStr << "&grid=" << curl_grid; - curl_free(curl_grid); - - // add OS info - char * os_info = curl_escape(LLAppViewer::instance()->getOSInfo().getOSStringSimple().c_str(), 0); - oStr << "&os=" << os_info; - curl_free(os_info); - gViewerWindow->setMenuBackgroundColor(false, !LLGridManager::getInstance()->isInProductionGrid()); - + LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html"); - if (web_browser->getCurrentNavUrl() != oStr.str()) + if (web_browser->getCurrentNavUrl() != login_uri.asString()) { - web_browser->navigateTo( oStr.str(), "text/html" ); + LL_DEBUGS("AppInit") << "loading: " << login_uri << LL_ENDL; + web_browser->navigateTo( login_uri.asString(), "text/html" ); } } void LLPanelLogin::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent event) { - if(event == MEDIA_EVENT_NAVIGATE_COMPLETE) - { - LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html"); - if (web_browser) - { - // *HACK HACK HACK HACK! - /* Stuff a Tab key into the browser now so that the first field will - ** get the focus! The embedded javascript on the page that properly - ** sets the initial focus in a real web browser is not working inside - ** the viewer, so this is an UGLY HACK WORKAROUND for now. - */ - // Commented out as it's not reliable - //web_browser->handleKey(KEY_TAB, MASK_NONE, false); - } - } } //--------------------------------------------------------------------------- @@ -812,15 +813,9 @@ void LLPanelLogin::onClickConnect(void *) LLComboBox* combo = sInstance->getChild<LLComboBox>("server_combo"); LLSD combo_val = combo->getSelectedValue(); - if (combo_val.isUndefined()) - { - combo_val = combo->getValue(); - } - if(combo_val.isUndefined()) - { - LLNotificationsUtil::add("StartRegionEmpty"); - return; - } + + // the grid definitions may come from a user-supplied grids.xml, so they may not be good + LL_DEBUGS("AppInit")<<"grid "<<combo_val.asString()<<LL_ENDL; try { LLGridManager::getInstance()->setGridChoice(combo_val.asString()); @@ -828,13 +823,14 @@ void LLPanelLogin::onClickConnect(void *) catch (LLInvalidGridName ex) { LLSD args; - args["GRID"] = combo_val.asString(); + args["GRID"] = ex.name(); LLNotificationsUtil::add("InvalidGrid", args); return; } - updateStartSLURL(); - std::string username = sInstance->getChild<LLUICtrl>("username_combo")->getValue().asString(); + // The start location SLURL has already been sent to LLStartUp::setStartSLURL + + std::string username = sInstance->getChild<LLUICtrl>("username_combo")->getValue().asString(); if(username.empty()) { @@ -877,7 +873,10 @@ void LLPanelLogin::onClickConnect(void *) // static void LLPanelLogin::onClickNewAccount(void*) { - LLWeb::loadURLExternal(sInstance->getString("create_account_url")); + if (sInstance) + { + LLWeb::loadURLExternal(LLTrans::getString("create_account_url")); + } } @@ -913,7 +912,7 @@ void LLPanelLogin::onPassKey(LLLineEditor* caller, void* user_data) This->mPasswordModified = TRUE; if (gKeyboard->getKeyDown(KEY_CAPSLOCK) && sCapslockDidNotification == FALSE) { -// *TODO: use another way to notify user about enabled caps lock, see EXT-6858 + // *TODO: use another way to notify user about enabled caps lock, see EXT-6858 sCapslockDidNotification = TRUE; } } @@ -921,113 +920,99 @@ void LLPanelLogin::onPassKey(LLLineEditor* caller, void* user_data) void LLPanelLogin::updateServer() { - try + if (sInstance) { - - updateServerCombo(); - // if they've selected another grid, we should load the credentials - // for that grid and set them to the UI. - if(sInstance && !sInstance->areCredentialFieldsDirty()) + try { - LLPointer<LLCredential> credential = gSecAPIHandler->loadCredential(LLGridManager::getInstance()->getGrid()); - bool remember = sInstance->getChild<LLUICtrl>("remember_check")->getValue(); - sInstance->setFields(credential, remember); - } - // grid changed so show new splash screen (possibly) - loadLoginPage(); - updateLocationCombo(LLStartUp::getStartSLURL().getType() == LLSLURL::LOCATION); - } - catch (LLInvalidGridName ex) - { - // do nothing - } -} + // if they've selected another grid, we should load the credentials + // for that grid and set them to the UI. + if(!sInstance->areCredentialFieldsDirty()) + { + LLPointer<LLCredential> credential = gSecAPIHandler->loadCredential(LLGridManager::getInstance()->getGrid()); + bool remember = sInstance->getChild<LLUICtrl>("remember_check")->getValue(); + sInstance->setFields(credential, remember); + } -void LLPanelLogin::updateServerCombo() -{ - if (!sInstance) - { - return; - } - // We add all of the possible values, sorted, and then add a bar and the current value at the top - LLComboBox* server_choice_combo = sInstance->getChild<LLComboBox>("server_combo"); - server_choice_combo->removeall(); + // update the login panel links + bool system_grid = LLGridManager::getInstance()->isSystemGrid(); - std::map<std::string, std::string> known_grids = LLGridManager::getInstance()->getKnownGrids(!gSavedSettings.getBOOL("ShowBetaGrids")); + // Want to vanish not only create_new_account_btn, but also the + // title text over it, so turn on/off the whole layout_panel element. + sInstance->getChild<LLLayoutPanel>("links")->setVisible(system_grid); + sInstance->getChildView("forgot_password_text")->setVisible(system_grid); - for (std::map<std::string, std::string>::iterator grid_choice = known_grids.begin(); - grid_choice != known_grids.end(); - grid_choice++) - { - if (!grid_choice->first.empty()) + // grid changed so show new splash screen (possibly) + loadLoginPage(); + } + catch (LLInvalidGridName ex) { - server_choice_combo->add(grid_choice->second, grid_choice->first); + LL_WARNS("AppInit")<<"server '"<<ex.name()<<"' selection failed"<<LL_ENDL; + LLSD args; + args["GRID"] = ex.name(); + LLNotificationsUtil::add("InvalidGrid", args); + return; } } - server_choice_combo->sortByName(); - - server_choice_combo->addSeparator(ADD_TOP); - - server_choice_combo->add(LLGridManager::getInstance()->getGridLabel(), - LLGridManager::getInstance()->getGrid(), ADD_TOP); - - server_choice_combo->selectFirstItem(); } -// static -void LLPanelLogin::onSelectServer(LLUICtrl*, void*) +void LLPanelLogin::onSelectServer() { - // *NOTE: The paramters for this method are ignored. - // LLPanelLogin::onServerComboLostFocus(LLFocusableElement* fe, void*) - // calls this method. - LL_INFOS("AppInit") << "onSelectServer" << LL_ENDL; // The user twiddled with the grid choice ui. // apply the selection to the grid setting. LLPointer<LLCredential> credential; - LLComboBox* combo = sInstance->getChild<LLComboBox>("server_combo"); - LLSD combo_val = combo->getSelectedValue(); - if (combo_val.isUndefined()) + LLComboBox* server_combo = getChild<LLComboBox>("server_combo"); + LLSD server_combo_val = server_combo->getSelectedValue(); + LL_INFOS("AppInit") << "grid "<<server_combo_val.asString()<< LL_ENDL; + LLGridManager::getInstance()->setGridChoice(server_combo_val.asString()); + + /* + * Determine whether or not the value in the start_location_combo makes sense + * with the new grid value. + * + * Note that some forms that could be in the location combo are grid-agnostic, + * such as "MyRegion/128/128/0". There could be regions with that name on any + * number of grids, so leave them alone. Other forms, such as + * https://grid.example.com/region/Party%20Town/20/30/5 specify a particular + * grid; in those cases we want to clear the location. + */ + LLComboBox* location_combo = getChild<LLComboBox>("start_location_combo"); + S32 index = location_combo->getCurrentIndex(); + switch (index) { - combo_val = combo->getValue(); + case 0: // last location + case 1: // home location + // do nothing - these are grid-agnostic locations + break; + + default: + { + std::string location = location_combo->getValue().asString(); + LLSLURL slurl(location); // generata a slurl from the location combo contents + if ( slurl.getType() == LLSLURL::LOCATION + && slurl.getGrid() != LLGridManager::getInstance()->getGrid() + ) + { + // the grid specified by the location is not this one, so clear the combo + location_combo->setCurrentByIndex(0); // last location on the new grid + location_combo->setTextEntry(LLStringUtil::null); + } + } + break; } - - combo = sInstance->getChild<LLComboBox>("start_location_combo"); - combo->setCurrentByIndex(1); - LLStartUp::setStartSLURL(LLSLURL(gSavedSettings.getString("LoginLocation"))); - LLGridManager::getInstance()->setGridChoice(combo_val.asString()); - // This new selection will override preset uris - // from the command line. + updateServer(); - updateLocationCombo(false); - updateLoginPanelLinks(); } -void LLPanelLogin::onServerComboLostFocus(LLFocusableElement* fe) +void LLPanelLogin::onLocationSLURL() { - if (!sInstance) - { - return; - } + LLComboBox* location_combo = getChild<LLComboBox>("start_location_combo"); + std::string location = location_combo->getValue().asString(); + LL_DEBUGS("AppInit")<<location<<LL_ENDL; - LLComboBox* combo = sInstance->getChild<LLComboBox>("server_combo"); - if(fe == combo) - { - onSelectServer(combo, NULL); - } + LLStartUp::setStartSLURL(location); // calls onUpdateStartSLURL, above } -void LLPanelLogin::updateLoginPanelLinks() -{ - LLSD grid_data; - LLGridManager::getInstance()->getGridInfo(grid_data); - bool system_grid = grid_data.has(GRID_IS_SYSTEM_GRID_VALUE); - - // need to call through sInstance, as it's called from onSelectServer, which - // is static. - sInstance->getChildView("create_new_account_text")->setVisible( system_grid); - sInstance->getChildView("forgot_password_text")->setVisible( system_grid); -} std::string canonicalize_username(const std::string& name) { |