diff options
Diffstat (limited to 'indra/newview/llpanellogin.cpp')
-rw-r--r-- | indra/newview/llpanellogin.cpp | 404 |
1 files changed, 181 insertions, 223 deletions
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index 76aadcd913..a8049b1b03 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -104,7 +104,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 +118,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); @@ -152,12 +151,36 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, LLSLURL slurl(gSavedSettings.getString("LoginLocation")); LLStartUp::setStartSLURL(slurl); } - updateLocationCombo(false); + + 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)); - LLComboBox* server_choice_combo = sInstance->getChild<LLComboBox>("server_combo"); - server_choice_combo->setCommitCallback(onSelectServer, NULL); - server_choice_combo->setFocusLostCallback(boost::bind(onServerComboLostFocus, _1)); - updateServerCombo(); + // 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++) + { + 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); + } + } + 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(); childSetAction("connect_btn", onClickConnect, this); @@ -167,10 +190,6 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, 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); @@ -192,9 +211,6 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, // Show last logged in user favorites in "Start at" combo. addUsersWithFavoritesToUsername(); getChild<LLComboBox>("username_combo")->setTextChangedCallback(boost::bind(&LLPanelLogin::addFavoritesToStartLocation, this)); - - updateLocationCombo(false); - } void LLPanelLogin::addUsersWithFavoritesToUsername() @@ -389,25 +405,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 +585,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 +614,69 @@ 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->getChildView("start_location_combo")->setVisible(show_start); + sInstance->getChildView("start_location_text")->setVisible(show_start); + + BOOL show_server = gSavedSettings.getBOOL("ForceShowGrid"); + LLComboBox* server_choice_combo = sInstance->getChild<LLComboBox>("server_combo"); + server_choice_combo->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) - { - case 0: - { - LLStartUp::setStartSLURL(LLSLURL(LLSLURL::SIM_LOCATION_LAST)); - break; - } - case 1: - { - LLStartUp::setStartSLURL(LLSLURL(LLSLURL::SIM_LOCATION_HOME)); - break; - } - default: + + 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. + */ + if ( LLSLURL::LOCATION == new_start_slurl.getType() ) + { + std::string slurl_grid = LLGridManager::getInstance()->getGrid(new_start_slurl.getGrid()); + if ( ! slurl_grid.empty() ) // is that a valid grid? { - 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"); + location_combo->setTextEntry(LLStringUtil::null); + } } } - 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 +694,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); + } } } @@ -761,7 +751,7 @@ void LLPanelLogin::loadLoginPage() curl_free(curl_version); // Grid - char* curl_grid = curl_escape(LLGridManager::getInstance()->getGridLabel().c_str(), 0); + char* curl_grid = curl_escape(LLGridManager::getInstance()->getGridId().c_str(), 0); oStr << "&grid=" << curl_grid; curl_free(curl_grid); @@ -775,27 +765,13 @@ void LLPanelLogin::loadLoginPage() LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html"); if (web_browser->getCurrentNavUrl() != oStr.str()) { + LL_DEBUGS("AppInit")<<oStr.str()<<LL_ENDL; web_browser->navigateTo( oStr.str(), "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 +788,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 +798,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 +848,10 @@ void LLPanelLogin::onClickConnect(void *) // static void LLPanelLogin::onClickNewAccount(void*) { - LLWeb::loadURLExternal(sInstance->getString("create_account_url")); + if (sInstance) + { + LLWeb::loadURLExternal(sInstance->getString("create_account_url")); + } } @@ -913,7 +887,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 +895,97 @@ 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 - } -} - -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(); + // 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); + } - std::map<std::string, std::string> known_grids = LLGridManager::getInstance()->getKnownGrids(!gSavedSettings.getBOOL("ShowBetaGrids")); + // update the login panel links + bool system_grid = LLGridManager::getInstance()->isSystemGrid(); + + sInstance->getChildView("create_new_account_text")->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) { |