diff options
Diffstat (limited to 'indra/newview/llpanellogin.cpp')
-rw-r--r-- | indra/newview/llpanellogin.cpp | 108 |
1 files changed, 82 insertions, 26 deletions
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index 4fd39d1211..224cec9650 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -549,18 +549,20 @@ void LLPanelLogin::populateFields(LLPointer<LLCredential> credential, bool remem LL_WARNS() << "Attempted fillFields with no login view shown" << LL_ENDL; return; } - LLUICtrl* remember_check = sInstance->getChild<LLUICtrl>("remember_check"); - remember_check->setValue(remember_psswrd); if (sInstance->mFirstLoginThisInstall) { + LLUICtrl* remember_check = sInstance->getChild<LLUICtrl>("remember_check"); + remember_check->setValue(remember_psswrd); // no list to populate setFields(credential); } else { sInstance->getChild<LLUICtrl>("remember_name")->setValue(remember_user); + LLUICtrl* remember_password = sInstance->getChild<LLUICtrl>("remember_password"); + remember_password->setValue(remember_psswrd); + remember_password->setEnabled(remember_user); sInstance->populateUserList(credential); - remember_check->setEnabled(remember_user); } } @@ -610,15 +612,19 @@ void LLPanelLogin::setFields(LLPointer<LLCredential> credential) login_id += " "; login_id += lastname; } - sInstance->getChild<LLComboBox>("username_combo")->setLabel(login_id); + sInstance->getChild<LLComboBox>("username_combo")->setLabel(login_id); + sInstance->mUsernameLength = login_id.length(); } else if(identifier.has("type") && (std::string)identifier["type"] == "account") { - sInstance->getChild<LLComboBox>("username_combo")->setLabel((std::string)identifier["account_name"]); + std::string login_id = identifier["account_name"].asString(); + sInstance->getChild<LLComboBox>("username_combo")->setLabel(login_id); + sInstance->mUsernameLength = login_id.length(); } else { - sInstance->getChild<LLComboBox>("username_combo")->setLabel(std::string()); + sInstance->getChild<LLComboBox>("username_combo")->setLabel(std::string()); + sInstance->mUsernameLength = 0; } sInstance->addFavoritesToStartLocation(); @@ -642,7 +648,8 @@ void LLPanelLogin::setFields(LLPointer<LLCredential> credential) } else { - sInstance->getChild<LLUICtrl>("password_edit")->setValue(std::string()); + sInstance->getChild<LLUICtrl>("password_edit")->setValue(std::string()); + sInstance->mPasswordLength = 0; } } @@ -660,7 +667,7 @@ void LLPanelLogin::getFields(LLPointer<LLCredential>& credential, LLSD identifier = LLSD::emptyMap(); LLSD authenticator = LLSD::emptyMap(); - std::string username = sInstance->getChild<LLComboBox>("username_combo")->getValue().asString(); + std::string username = sInstance->getChild<LLComboBox>("username_combo")->getSimple(); std::string password = sInstance->getChild<LLUICtrl>("password_edit")->getValue().asString(); LLStringUtil::trim(username); @@ -742,13 +749,14 @@ void LLPanelLogin::getFields(LLPointer<LLCredential>& credential, } } credential = gSecAPIHandler->createCredential(LLGridManager::getInstance()->getGrid(), identifier, authenticator); - remember_psswrd = sInstance->getChild<LLUICtrl>("remember_check")->getValue(); if (!sInstance->mFirstLoginThisInstall) { + remember_psswrd = sInstance->getChild<LLUICtrl>("remember_password")->getValue(); remember_user = sInstance->getChild<LLUICtrl>("remember_name")->getValue(); } else { + remember_psswrd = sInstance->getChild<LLUICtrl>("remember_check")->getValue(); remember_user = remember_psswrd; // on panel_login_first "remember_check" is named as 'remember me' } } @@ -763,11 +771,8 @@ BOOL LLPanelLogin::areCredentialFieldsDirty() } else { - std::string username = sInstance->getChild<LLUICtrl>("username_combo")->getValue().asString(); - LLStringUtil::trim(username); - std::string password = sInstance->getChild<LLUICtrl>("password_edit")->getValue().asString(); LLComboBox* combo = sInstance->getChild<LLComboBox>("username_combo"); - if(combo && combo->isDirty()) + if (combo && combo->getCurrentIndex() == -1 && !combo->getValue().asString().empty()) { return true; } @@ -1079,6 +1084,7 @@ void LLPanelLogin::onUserNameTextEnty(void*) { sInstance->mPasswordModified = true; sInstance->getChild<LLUICtrl>("password_edit")->setValue(std::string()); + sInstance->mPasswordLength = 0; sInstance->addFavoritesToStartLocation(); //will call updateLoginButtons() } @@ -1112,14 +1118,22 @@ void LLPanelLogin::onUserListCommit(void*) } // static +// At the moment only happens if !mFirstLoginThisInstall void LLPanelLogin::onRememberUserCheck(void*) { - if (sInstance) + if (sInstance && !sInstance->mFirstLoginThisInstall) { LLCheckBoxCtrl* remember_name(sInstance->getChild<LLCheckBoxCtrl>("remember_name")); - LLCheckBoxCtrl* remember_psswrd(sInstance->getChild<LLCheckBoxCtrl>("remember_check")); + LLCheckBoxCtrl* remember_psswrd(sInstance->getChild<LLCheckBoxCtrl>("remember_password")); + LLComboBox* user_combo(sInstance->getChild<LLComboBox>("username_combo")); bool remember = remember_name->getValue().asBoolean(); + if (user_combo->getCurrentIndex() != -1 && !remember) + { + remember = true; + remember_name->setValue(true); + LLNotificationsUtil::add("LoginCantRemoveUsername"); + } remember_psswrd->setEnabled(remember); } } @@ -1148,8 +1162,32 @@ void LLPanelLogin::updateServer() try { // if they've selected another grid, we should load the credentials - // for that grid and set them to the UI. - if(!sInstance->areCredentialFieldsDirty()) + // for that grid and set them to the UI. But if there were any modifications to + // fields, modifications should carry over. + // Not sure if it should carry over password but it worked like this before login changes + // Example: you started typing in and found that your are under wrong grid, + // you switch yet don't lose anything + if (sInstance->areCredentialFieldsDirty()) + { + // save modified creds + LLComboBox* user_combo = sInstance->getChild<LLComboBox>("username_combo"); + LLLineEditor* pswd_edit = sInstance->getChild<LLLineEditor>("password_edit"); + std::string username = user_combo->getSimple(); + LLStringUtil::trim(username); + std::string password = pswd_edit->getValue().asString(); + + // populate dropbox and setFields + // Note: following call is related to initializeLoginInfo() + LLPointer<LLCredential> credential = gSecAPIHandler->loadCredential(LLGridManager::getInstance()->getGrid()); + sInstance->populateUserList(credential); + + // restore creds + user_combo->setTextEntry(username); + pswd_edit->setValue(password); + sInstance->mUsernameLength = username.length(); + sInstance->mPasswordLength = password.length(); + } + else { // populate dropbox and setFields // Note: following call is related to initializeLoginInfo() @@ -1185,12 +1223,17 @@ void LLPanelLogin::updateLoginButtons() login_btn->setEnabled(mUsernameLength != 0 && mPasswordLength != 0); - if (!mFirstLoginThisInstall) - { - LLComboBox* user_combo = getChild<LLComboBox>("username_combo"); - LLCheckBoxCtrl* remember_name = getChild<LLCheckBoxCtrl>("remember_name"); - remember_name->setEnabled(user_combo->getCurrentIndex() == -1); - } + if (!mFirstLoginThisInstall) + { + LLComboBox* user_combo = getChild<LLComboBox>("username_combo"); + LLCheckBoxCtrl* remember_name = getChild<LLCheckBoxCtrl>("remember_name"); + if (user_combo->getCurrentIndex() != -1) + { + remember_name->setValue(true); + LLCheckBoxCtrl* remember_pass = getChild<LLCheckBoxCtrl>("remember_password"); + remember_pass->setEnabled(TRUE); + } // Note: might be good idea to do "else remember_name->setValue(mRememberedState)" but it might behave 'weird' to user + } } void LLPanelLogin::populateUserList(LLPointer<LLCredential> credential) @@ -1198,6 +1241,10 @@ void LLPanelLogin::populateUserList(LLPointer<LLCredential> credential) LLComboBox* user_combo = getChild<LLComboBox>("username_combo"); user_combo->removeall(); user_combo->clear(); + user_combo->setValue(std::string()); + getChild<LLUICtrl>("password_edit")->setValue(std::string()); + mUsernameLength = 0; + mPasswordLength = 0; if (gSecAPIHandler->hasCredentialMap("login_list", LLGridManager::getInstance()->getGrid())) { @@ -1218,8 +1265,8 @@ void LLPanelLogin::populateUserList(LLPointer<LLCredential> credential) if (credential.isNull() || !user_combo->setSelectedByValue(LLSD(credential->userID()), true)) { - // selection failed, just deselect whatever might be selected - user_combo->setValue(std::string()); + // selection failed, fields will be mepty + updateLoginButtons(); } else { @@ -1233,9 +1280,18 @@ void LLPanelLogin::populateUserList(LLPointer<LLCredential> credential) const LLSD &ident = credential->getIdentifier(); if (ident.isMap() && ident.has("type")) { - user_combo->add(LLPanelLogin::getUserName(credential), credential->userID(), ADD_BOTTOM, TRUE); + // this llsd might hold invalid credencial (failed login), so + // do not add to the list, just set field. setFields(credential); } + else + { + updateLoginButtons(); + } + } + else + { + updateLoginButtons(); } } } |