summaryrefslogtreecommitdiff
path: root/indra/newview/llpanellogin.cpp
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-05-12 11:44:16 +0100
committerTofu Linden <tofu.linden@lindenlab.com>2010-05-12 11:44:16 +0100
commit3d39634cbd3abe4df7b9ce8d229e59c3087de713 (patch)
tree91c436bb6370e511fc2679e8f7b7ca22b7114f70 /indra/newview/llpanellogin.cpp
parent4a3222d9c12812db70f2c9ec0050012d01155565 (diff)
parent1cee577ca0234eee7da243c85be8eb7524d691c7 (diff)
merge from viewer-public
Diffstat (limited to 'indra/newview/llpanellogin.cpp')
-rw-r--r--indra/newview/llpanellogin.cpp540
1 files changed, 330 insertions, 210 deletions
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index 67aea5544d..508a58e74f 100644
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -51,11 +51,12 @@
#include "llfocusmgr.h"
#include "lllineeditor.h"
#include "llnotificationsutil.h"
+#include "llsecapi.h"
#include "llstartup.h"
#include "lltextbox.h"
#include "llui.h"
#include "lluiconstants.h"
-#include "llurlsimstring.h"
+#include "llslurl.h"
#include "llversioninfo.h"
#include "llviewerhelp.h"
#include "llviewertexturelist.h"
@@ -77,6 +78,7 @@
#pragma warning(disable: 4355) // 'this' used in initializer list
#endif // LL_WINDOWS
+#include "llsdserialize.h"
#define USE_VIEWER_AUTH 0
const S32 BLACK_BORDER_HEIGHT = 160;
@@ -104,7 +106,6 @@ public:
LLLoginRefreshHandler gLoginRefreshHandler;
-
// helper class that trys to download a URL from a web site and calls a method
// on parent class indicating if the web server is working or not
class LLIamHereLogin : public LLHTTPClient::Responder
@@ -153,10 +154,6 @@ namespace {
boost::intrusive_ptr< LLIamHereLogin > gResponsePtr = 0;
};
-void set_start_location(LLUICtrl* ctrl, void* data)
-{
- LLURLSimString::setString(ctrl->getValue().asString());
-}
//---------------------------------------------------------------------------
// Public methods
@@ -187,6 +184,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
delete LLPanelLogin::sInstance;
}
+ mPasswordModified = FALSE;
LLPanelLogin::sInstance = this;
// add to front so we are the bottom-most child
@@ -213,10 +211,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
}
#if !USE_VIEWER_AUTH
- childSetPrevalidate("first_name_edit", LLTextValidate::validateASCIIPrintableNoSpace);
- childSetPrevalidate("last_name_edit", LLTextValidate::validateASCIIPrintableNoSpace);
-
- childSetCommitCallback("password_edit", mungePassword, this);
+ childSetPrevalidate("username_edit", LLTextValidate::validateASCIIPrintableNoPipe);
getChild<LLLineEditor>("password_edit")->setKeystrokeCallback(onPassKey, this);
// change z sort of clickable text to be behind buttons
@@ -226,29 +221,17 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
LLLineEditor* edit = getChild<LLLineEditor>("password_edit");
if (edit) edit->setDrawAsterixes(TRUE);
- LLComboBox* combo = getChild<LLComboBox>("start_location_combo");
-
- std::string sim_string = LLURLSimString::sInstance.mSimString;
- if(sim_string.empty())
+ if(LLStartUp::getStartSLURL().getType() != LLSLURL::LOCATION)
{
- LLURLSimString::setString(gSavedSettings.getString("LoginLocation"));
- sim_string = LLURLSimString::sInstance.mSimString;
+ LLSLURL slurl(gSavedSettings.getString("LoginLocation"));
+ LLStartUp::setStartSLURL(slurl);
}
-
- if (!sim_string.empty())
- {
- // Replace "<Type region name>" with this region name
- combo->remove(2);
- combo->add( sim_string );
- combo->setTextEntry(sim_string);
- combo->setCurrentByIndex( 2 );
- }
-
- combo->setCommitCallback( &set_start_location, NULL );
+ 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();
childSetAction("connect_btn", onClickConnect, this);
@@ -304,17 +287,10 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
// kick off a request to grab the url manually
gResponsePtr = LLIamHereLogin::build( this );
- std::string login_page = gSavedSettings.getString("LoginPage");
- if (login_page.empty())
- {
- login_page = getString( "real_url" );
- }
- LLHTTPClient::head( login_page, gResponsePtr );
-#if !USE_VIEWER_AUTH
- // Initialize visibility (and don't force visibility - use prefs)
- refreshLocation( false );
-#endif
+ LLHTTPClient::head( LLGridManager::getInstance()->getLoginPage(), gResponsePtr );
+
+ updateLocationCombo(false);
}
@@ -378,21 +354,6 @@ void LLPanelLogin::setSiteIsAlive( bool alive )
}
}
-void LLPanelLogin::mungePassword(LLUICtrl* caller, void* user_data)
-{
- LLPanelLogin* self = (LLPanelLogin*)user_data;
- LLLineEditor* editor = (LLLineEditor*)caller;
- std::string password = editor->getText();
-
- // Re-md5 if we've changed at all
- if (password != self->mIncomingPassword)
- {
- LLMD5 pass((unsigned char *)password.c_str());
- char munged_password[MD5HEX_STR_SIZE];
- pass.hex_digest(munged_password);
- self->mMungedPassword = munged_password;
- }
-}
LLPanelLogin::~LLPanelLogin()
{
@@ -493,14 +454,14 @@ void LLPanelLogin::giveFocus()
if( sInstance )
{
// Grab focus and move cursor to first blank input field
- std::string first = sInstance->childGetText("first_name_edit");
+ std::string username = sInstance->childGetText("username_edit");
std::string pass = sInstance->childGetText("password_edit");
- BOOL have_first = !first.empty();
+ BOOL have_username = !username.empty();
BOOL have_pass = !pass.empty();
LLLineEditor* edit = NULL;
- if (have_first && !have_pass)
+ if (have_username && !have_pass)
{
// User saved his name but not his password. Move
// focus to password field.
@@ -509,7 +470,7 @@ void LLPanelLogin::giveFocus()
else
{
// User doesn't have a name, so start there.
- edit = sInstance->getChild<LLLineEditor>("first_name_edit");
+ edit = sInstance->getChild<LLLineEditor>("username_edit");
}
if (edit)
@@ -531,8 +492,8 @@ void LLPanelLogin::showLoginWidgets()
// *TODO: Append all the usual login parameters, like first_login=Y etc.
std::string splash_screen_url = sInstance->getString("real_url");
web_browser->navigateTo( splash_screen_url, "text/html" );
- LLUICtrl* first_name_edit = sInstance->getChild<LLUICtrl>("first_name_edit");
- first_name_edit->setFocus(TRUE);
+ LLUICtrl* username_edit = sInstance->getChild<LLUICtrl>("username_edit");
+ username_edit->setFocus(TRUE);
}
// static
@@ -554,77 +515,127 @@ void LLPanelLogin::show(const LLRect &rect,
}
// static
-void LLPanelLogin::setFields(const std::string& firstname,
- const std::string& lastname,
- const std::string& password)
+void LLPanelLogin::setFields(LLPointer<LLCredential> credential,
+ BOOL remember)
{
if (!sInstance)
{
llwarns << "Attempted fillFields with no login view shown" << llendl;
return;
}
+ LL_INFOS("Credentials") << "Setting login fields to " << *credential << LL_ENDL;
- sInstance->childSetText("first_name_edit", firstname);
- sInstance->childSetText("last_name_edit", lastname);
-
- // Max "actual" password length is 16 characters.
- // Hex digests are always 32 characters.
- if (password.length() == 32)
+ LLSD identifier = credential->getIdentifier();
+ if((std::string)identifier["type"] == "agent")
+ {
+ sInstance->childSetText("username_edit", (std::string)identifier["first_name"] + " " +
+ (std::string)identifier["last_name"]);
+ }
+ else if((std::string)identifier["type"] == "account")
{
+ sInstance->childSetText("username_edit", (std::string)identifier["account_name"]);
+ }
+ else
+ {
+ sInstance->childSetText("username_edit", std::string());
+ }
+ // if the password exists in the credential, set the password field with
+ // a filler to get some stars
+ LLSD authenticator = credential->getAuthenticator();
+ LL_INFOS("Credentials") << "Setting authenticator field " << authenticator["type"].asString() << LL_ENDL;
+ if(authenticator.isMap() &&
+ authenticator.has("secret") &&
+ (authenticator["secret"].asString().size() > 0))
+ {
+
// This is a MD5 hex digest of a password.
// We don't actually use the password input field,
// fill it with MAX_PASSWORD characters so we get a
// nice row of asterixes.
const std::string filler("123456789!123456");
- sInstance->childSetText("password_edit", filler);
- sInstance->mIncomingPassword = filler;
- sInstance->mMungedPassword = password;
+ sInstance->childSetText("password_edit", std::string("123456789!123456"));
}
else
{
- // this is a normal text password
- sInstance->childSetText("password_edit", password);
- sInstance->mIncomingPassword = password;
- LLMD5 pass((unsigned char *)password.c_str());
- char munged_password[MD5HEX_STR_SIZE];
- pass.hex_digest(munged_password);
- sInstance->mMungedPassword = munged_password;
+ sInstance->childSetText("password_edit", std::string());
}
+ sInstance->childSetValue("remember_check", remember);
}
// static
-void LLPanelLogin::addServer(const std::string& server, S32 domain_name)
+void LLPanelLogin::getFields(LLPointer<LLCredential>& credential,
+ BOOL& remember)
{
if (!sInstance)
{
- llwarns << "Attempted addServer with no login view shown" << llendl;
+ llwarns << "Attempted getFields with no login view shown" << llendl;
return;
}
+
+ // load the credential so we can pass back the stored password or hash if the user did
+ // not modify the password field.
+
+ credential = gSecAPIHandler->loadCredential(LLGridManager::getInstance()->getGrid());
- LLComboBox* combo = sInstance->getChild<LLComboBox>("server_combo");
- combo->add(server, LLSD(domain_name) );
- combo->setCurrentByIndex(0);
-}
-
-// static
-void LLPanelLogin::getFields(std::string *firstname,
- std::string *lastname,
- std::string *password)
-{
- if (!sInstance)
+ LLSD identifier = LLSD::emptyMap();
+ LLSD authenticator = LLSD::emptyMap();
+
+ if(credential.notNull())
{
- llwarns << "Attempted getFields with no login view shown" << llendl;
- return;
+ authenticator = credential->getAuthenticator();
}
- *firstname = sInstance->childGetText("first_name_edit");
- LLStringUtil::trim(*firstname);
-
- *lastname = sInstance->childGetText("last_name_edit");
- LLStringUtil::trim(*lastname);
+ std::string username = sInstance->childGetText("username_edit");
+ LLStringUtil::trim(username);
+ std::string password = sInstance->childGetText("password_edit");
- *password = sInstance->mMungedPassword;
+ LL_INFOS2("Credentials", "Authentication") << "retrieving username:" << username << LL_ENDL;
+ // determine if the username is a first/last form or not.
+ size_t separator_index = username.find_first_of(' ');
+ if (separator_index == username.npos)
+ {
+ LL_INFOS2("Credentials", "Authentication") << "account: " << username << LL_ENDL;
+ // single username, so this is a 'clear' identifier
+ identifier["type"] = CRED_IDENTIFIER_TYPE_ACCOUNT;
+ identifier["account_name"] = username;
+
+ if (LLPanelLogin::sInstance->mPasswordModified)
+ {
+ authenticator = LLSD::emptyMap();
+ // password is plaintext
+ authenticator["type"] = CRED_AUTHENTICATOR_TYPE_CLEAR;
+ authenticator["secret"] = password;
+ }
+ }
+ else
+ {
+ std::string first = username.substr(0, separator_index);
+ std::string last = username.substr(separator_index, username.npos);
+ LLStringUtil::trim(last);
+
+ if (last.find_first_of(' ') == last.npos)
+ {
+ LL_INFOS2("Credentials", "Authentication") << "agent: " << username << LL_ENDL;
+ // traditional firstname / lastname
+ identifier["type"] = CRED_IDENTIFIER_TYPE_AGENT;
+ identifier["first_name"] = first;
+ identifier["last_name"] = last;
+
+ if (LLPanelLogin::sInstance->mPasswordModified)
+ {
+ authenticator = LLSD::emptyMap();
+ authenticator["type"] = CRED_AUTHENTICATOR_TYPE_HASH;
+ authenticator["algorithm"] = "md5";
+ LLMD5 pass((const U8 *)password.c_str());
+ char md5pass[33]; /* Flawfinder: ignore */
+ pass.hex_digest(md5pass);
+ authenticator["secret"] = md5pass;
+ }
+ }
+ }
+ credential = gSecAPIHandler->createCredential(LLGridManager::getInstance()->getGrid(), identifier, authenticator);
+ remember = sInstance->childGetValue("remember_check");
}
// static
@@ -644,64 +655,112 @@ BOOL LLPanelLogin::isGridComboDirty()
}
// static
-void LLPanelLogin::getLocation(std::string &location)
+BOOL LLPanelLogin::areCredentialFieldsDirty()
{
if (!sInstance)
{
- llwarns << "Attempted getLocation with no login view shown" << llendl;
- return;
+ llwarns << "Attempted getServer with no login view shown" << llendl;
}
-
- LLComboBox* combo = sInstance->getChild<LLComboBox>("start_location_combo");
- location = combo->getValue().asString();
+ else
+ {
+ std::string username = sInstance->childGetText("username_edit");
+ LLStringUtil::trim(username);
+ std::string password = sInstance->childGetText("password_edit");
+ LLLineEditor* ctrl = sInstance->getChild<LLLineEditor>("username_edit");
+ if(ctrl && ctrl->isDirty())
+ {
+ return true;
+ }
+ ctrl = sInstance->getChild<LLLineEditor>("password_edit");
+ if(ctrl && ctrl->isDirty())
+ {
+ return true;
+ }
+ }
+ return false;
}
+
// static
-void LLPanelLogin::refreshLocation( bool force_visible )
+void LLPanelLogin::updateLocationCombo( bool force_visible )
{
- if (!sInstance) return;
-
-#if USE_VIEWER_AUTH
- loadLoginPage();
-#else
+ if (!sInstance)
+ {
+ return;
+ }
+
+ 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 )
- {
- // Don't show on first run after install
- // Otherwise ShowStartLocation defaults to true.
show_start = gSavedSettings.getBOOL("ShowStartLocation");
- }
-
- // Update the value of the location combo.
- updateLocationUI();
sInstance->childSetVisible("start_location_combo", show_start);
sInstance->childSetVisible("start_location_text", show_start);
-
+
BOOL show_server = gSavedSettings.getBOOL("ForceShowGrid");
+ sInstance->childSetVisible("server_combo_text", show_server);
sInstance->childSetVisible("server_combo", show_server);
-
-#endif
}
// static
-void LLPanelLogin::updateLocationUI()
+void LLPanelLogin::updateStartSLURL()
{
if (!sInstance) return;
- std::string sim_string = LLURLSimString::sInstance.mSimString;
- if (!sim_string.empty())
+ LLComboBox* combo = sInstance->getChild<LLComboBox>("start_location_combo");
+ S32 index = combo->getCurrentIndex();
+
+ switch (index)
{
- // Replace "<Type region name>" with this region name
- LLComboBox* combo = sInstance->getChild<LLComboBox>("start_location_combo");
- combo->remove(2);
- combo->add( sim_string );
- combo->setTextEntry(sim_string);
- combo->setCurrentByIndex( 2 );
+ case 0:
+ {
+ 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)
+ {
+ // we've changed the grid, so update the grid selection
+ LLStartUp::setStartSLURL(slurl);
+ }
+ break;
+ }
}
}
+
+void LLPanelLogin::setLocation(const LLSLURL& slurl)
+{
+ LLStartUp::setStartSLURL(slurl);
+ updateServer();
+}
+
// static
void LLPanelLogin::closePanel()
{
@@ -735,15 +794,13 @@ void LLPanelLogin::loadLoginPage()
std::ostringstream oStr;
- std::string login_page = gSavedSettings.getString("LoginPage");
- if (login_page.empty())
- {
- login_page = sInstance->getString( "real_url" );
- }
+ std::string login_page = LLGridManager::getInstance()->getLoginPage();
+
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)
{
@@ -775,11 +832,10 @@ void LLPanelLogin::loadLoginPage()
curl_free(curl_version);
// Grid
- char* curl_grid = curl_escape(LLViewerLogin::getInstance()->getGridLabel().c_str(), 0);
+ char* curl_grid = curl_escape(LLGridManager::getInstance()->getGridLoginID().c_str(), 0);
oStr << "&grid=" << curl_grid;
curl_free(curl_grid);
-
- gViewerWindow->setMenuBackgroundColor(false, !LLViewerLogin::getInstance()->isInProductionGrid());
+ gViewerWindow->setMenuBackgroundColor(false, !LLGridManager::getInstance()->isInProductionGrid());
gLoginMenuBarView->setBackgroundColor(gMenuBarView->getBackgroundColor());
@@ -804,30 +860,20 @@ void LLPanelLogin::loadLoginPage()
location = gSavedSettings.getString("LoginLocation");
}
- std::string firstname, lastname;
+ std::string username;
if(gSavedSettings.getLLSD("UserLoginInfo").size() == 3)
{
LLSD cmd_line_login = gSavedSettings.getLLSD("UserLoginInfo");
- firstname = cmd_line_login[0].asString();
- lastname = cmd_line_login[1].asString();
+ username = cmd_line_login[0].asString() + " " + cmd_line_login[1];
password = cmd_line_login[2].asString();
}
- if (firstname.empty())
- {
- firstname = gSavedSettings.getString("FirstName");
- }
-
- if (lastname.empty())
- {
- lastname = gSavedSettings.getString("LastName");
- }
char* curl_region = curl_escape(region.c_str(), 0);
- oStr <<"firstname=" << firstname <<
- "&lastname=" << lastname << "&location=" << location << "&region=" << curl_region;
+ oStr <<"username=" << username <<
+ "&location=" << location << "&region=" << curl_region;
curl_free(curl_region);
@@ -860,7 +906,7 @@ void LLPanelLogin::loadLoginPage()
#endif
LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html");
-
+
// navigate to the "real" page
if (gSavedSettings.getBOOL("RegInClient"))
{
@@ -909,39 +955,66 @@ void LLPanelLogin::onClickConnect(void *)
// JC - Make sure the fields all get committed.
sInstance->setFocus(FALSE);
- std::string first = sInstance->childGetText("first_name_edit");
- std::string last = sInstance->childGetText("last_name_edit");
- LLComboBox* combo = sInstance->getChild<LLComboBox>("start_location_combo");
- std::string combo_text = combo->getSimple();
-
- bool has_first_and_last = !(first.empty() || last.empty());
- bool has_location = false;
-
- if(combo_text=="<Type region name>" || combo_text =="")
+ 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;
+ }
+ try
{
- // *NOTE: Mani - Location field is not always committed by this point!
- // This may be duplicate work, but better than not doing the work!
- LLURLSimString::sInstance.setString("");
+ LLGridManager::getInstance()->setGridChoice(combo_val.asString());
}
- else
+ catch (LLInvalidGridName ex)
{
- // *NOTE: Mani - Location field is not always committed by this point!
- LLURLSimString::sInstance.setString(combo_text);
- has_location = true;
+ LLSD args;
+ args["GRID"] = combo_val.asString();
+ LLNotificationsUtil::add("InvalidGrid", args);
+ return;
}
+ updateStartSLURL();
+ std::string username = sInstance->childGetText("username_edit");
- if(!has_first_and_last)
+
+ if(username.empty())
{
+ // user must type in something into the username field
LLNotificationsUtil::add("MustHaveAccountToLogIn");
}
- else if(!has_location)
- {
- LLNotificationsUtil::add("StartRegionEmpty");
- }
else
{
- // has both first and last name typed
- sInstance->mCallback(0, sInstance->mCallbackData);
+ LLPointer<LLCredential> cred;
+ BOOL remember;
+ getFields(cred, remember);
+ std::string identifier_type;
+ cred->identifierType(identifier_type);
+ LLSD allowed_credential_types;
+ LLGridManager::getInstance()->getLoginIdentifierTypes(allowed_credential_types);
+
+ // check the typed in credential type against the credential types expected by the server.
+ for(LLSD::array_iterator i = allowed_credential_types.beginArray();
+ i != allowed_credential_types.endArray();
+ i++)
+ {
+
+ if(i->asString() == identifier_type)
+ {
+ // yay correct credential type
+ sInstance->mCallback(0, sInstance->mCallbackData);
+ return;
+ }
+ }
+
+ // Right now, maingrid is the only thing that is picky about
+ // credential format, as it doesn't yet allow account (single username)
+ // format creds. - Rox. James, we wanna fix the message when we change
+ // this.
+ LLNotificationsUtil::add("InvalidCredentialFormat");
}
}
}
@@ -999,6 +1072,8 @@ void LLPanelLogin::onClickHelp(void*)
// static
void LLPanelLogin::onPassKey(LLLineEditor* caller, void* user_data)
{
+ LLPanelLogin *This = (LLPanelLogin *) 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
@@ -1006,54 +1081,88 @@ void LLPanelLogin::onPassKey(LLLineEditor* caller, void* user_data)
}
}
-// static
-void LLPanelLogin::onSelectServer(LLUICtrl*, void*)
-{
- // *NOTE: The paramters for this method are ignored.
- // LLPanelLogin::onServerComboLostFocus(LLFocusableElement* fe, void*)
- // calls this method.
-
- // The user twiddled with the grid choice ui.
- // apply the selection to the grid setting.
- std::string grid_label;
- S32 grid_index;
-
- LLComboBox* combo = sInstance->getChild<LLComboBox>("server_combo");
- LLSD combo_val = combo->getValue();
- if (LLSD::TypeInteger == combo_val.type())
+void LLPanelLogin::updateServer()
+{
+ try
{
- grid_index = combo->getValue().asInteger();
- if ((S32)GRID_INFO_OTHER == grid_index)
+ 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())
{
- // This happens if the user specifies a custom grid
- // via command line.
- grid_label = combo->getSimple();
+ LLPointer<LLCredential> credential = gSecAPIHandler->loadCredential(LLGridManager::getInstance()->getGrid());
+ bool remember = sInstance->childGetValue("remember_check");
+ sInstance->setFields(credential, remember);
}
+ // grid changed so show new splash screen (possibly)
+ loadLoginPage();
+ updateLocationCombo(LLStartUp::getStartSLURL().getType() == LLSLURL::LOCATION);
}
- else
+ catch (LLInvalidGridName ex)
{
- // no valid selection, return other
- grid_index = (S32)GRID_INFO_OTHER;
- grid_label = combo_val.asString();
+ // do nothing
}
+}
- // This new seelction will override preset uris
- // from the command line.
- LLViewerLogin* vl = LLViewerLogin::getInstance();
- vl->resetURIs();
- if(grid_index != GRID_INFO_OTHER)
+void LLPanelLogin::updateServerCombo()
+{
+ if (!sInstance)
{
- vl->setGridChoice((EGridInfo)grid_index);
+ return;
}
- else
+ // 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();
+
+ std::map<std::string, std::string> known_grids = LLGridManager::getInstance()->getKnownGrids(!gSavedSettings.getBOOL("ShowBetaGrids"));
+
+ for (std::map<std::string, std::string>::iterator grid_choice = known_grids.begin();
+ grid_choice != known_grids.end();
+ grid_choice++)
{
- vl->setGridChoice(grid_label);
+ if (!grid_choice->first.empty())
+ {
+ server_choice_combo->add(grid_choice->second, grid_choice->first, ADD_SORTED);
+ }
}
+
+ server_choice_combo->addSeparator(ADD_TOP);
+
+ server_choice_combo->add(LLGridManager::getInstance()->getGridLabel(),
+ LLGridManager::getInstance()->getGrid(), ADD_TOP);
+
+ server_choice_combo->selectFirstItem();
+}
- // grid changed so show new splash screen (possibly)
- loadLoginPage();
+// static
+void LLPanelLogin::onSelectServer(LLUICtrl*, void*)
+{
+ // *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())
+ {
+ combo_val = combo->getValue();
+ }
+
+ 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)
@@ -1066,3 +1175,14 @@ void LLPanelLogin::onServerComboLostFocus(LLFocusableElement* fe)
onSelectServer(combo, NULL);
}
}
+
+void LLPanelLogin::updateLoginPanelLinks()
+{
+ LLSD grid_data = LLGridManager::getInstance()->getGridInfo();
+ 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->childSetVisible("create_new_account_text", system_grid);
+ sInstance->childSetVisible("forgot_password_text", system_grid);
+}