diff options
author | Merov Linden <merov@lindenlab.com> | 2011-03-01 11:56:21 -0800 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2011-03-01 11:56:21 -0800 |
commit | 270f3afad48918d3e970b5505cff0c4e373db298 (patch) | |
tree | 7789459a1cb99e3d7c43d82f4600354abcadeae8 | |
parent | 05546dfa3bd6873bf0764358319d73f00c9f75c1 (diff) | |
parent | 40b50442bfa8d3a60248fc3db3516a7011ec5966 (diff) |
STORM-842 : pull into viewer-development
-rw-r--r-- | indra/newview/llpanellogin.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index 8d3b1fd7a0..3b5830f8e0 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -81,6 +81,9 @@ const S32 MAX_PASSWORD = 16; LLPanelLogin *LLPanelLogin::sInstance = NULL; BOOL LLPanelLogin::sCapslockDidNotification = FALSE; +// Helper for converting a user name into the canonical "Firstname Lastname" form. +// For new accounts without a last name "Resident" is added as a last name. +static std::string canonicalize_username(const std::string& name); class LLLoginRefreshHandler : public LLCommandHandler { @@ -298,7 +301,14 @@ void LLPanelLogin::addFavoritesToStartLocation() for (LLSD::map_const_iterator iter = fav_llsd.beginMap(); iter != fav_llsd.endMap(); ++iter) { - if(iter->first != getChild<LLComboBox>("username_combo")->getSimple()) continue; + std::string user_defined_name = getChild<LLComboBox>("username_combo")->getSimple(); + + // The account name in stored_favorites.xml has Resident last name even if user has + // a single word account name, so it can be compared case-insensitive with the + // user defined "firstname lastname". + S32 res = LLStringUtil::compareInsensitive(canonicalize_username(user_defined_name), iter->first); + if (res != 0) continue; + combo->addSeparator(); LLSD user_llsd = iter->second; for (LLSD::array_const_iterator iter1 = user_llsd.beginArray(); @@ -1156,3 +1166,28 @@ void LLPanelLogin::updateLoginPanelLinks() 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) +{ + std::string cname = name; + LLStringUtil::trim(cname); + + // determine if the username is a first/last form or not. + size_t separator_index = cname.find_first_of(" ._"); + std::string first = cname.substr(0, separator_index); + std::string last; + if (separator_index != cname.npos) + { + last = cname.substr(separator_index+1, cname.npos); + LLStringUtil::trim(last); + } + else + { + // ...on Linden grids, single username users as considered to have + // last name "Resident" + last = "Resident"; + } + + // Username in traditional "firstname lastname" form. + return first + ' ' + last; +} |