Ejemplo n.º 1
0
void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup)
{
    S32 count = msg->getNumberOfBlocksFast(_PREHASH_UUIDNameBlock);
    for(S32 i = 0; i < count; ++i)
    {
        LLUUID id;
        msg->getUUIDFast(_PREHASH_UUIDNameBlock, _PREHASH_ID, id, i);
        LLCacheNameEntry* entry = get_ptr_in_map(mCache, id);
        if (!entry)
        {
            entry = new LLCacheNameEntry;
            mCache[id] = entry;
        }

        mPendingQueue.erase(id);

        entry->mIsGroup = isGroup;
        entry->mCreateTime = (U32)time(NULL);
        if (!isGroup)
        {
            msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_FirstName, entry->mFirstName, i);
            msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_LastName,  entry->mLastName, i);
        }
        else
        {   // is group
            msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_GroupName, entry->mGroupName, i);
            LLStringFn::replace_ascii_controlchars(entry->mGroupName, LL_UNKNOWN_CHAR);
        }

        if (!isGroup)
        {
            // NOTE: Very occasionally the server sends down a full name
            // in the first name field with an empty last name, for example,
            // first = "Ladanie1 Resident", last = "".
            // I cannot reproduce this, nor can I find a bug in the server code.
            // Ensure "Resident" does not appear via cleanFullName, because
            // buildFullName only checks last name. JC
            std::string full_name;
            if (entry->mLastName.empty())
            {
                full_name = cleanFullName(entry->mFirstName);

                //fix what we are putting in the cache
                entry->mFirstName = full_name;
                entry->mLastName = "Resident";
            }
            else
            {
                full_name = LLCacheName::buildFullName(entry->mFirstName, entry->mLastName);
            }
            mSignal(id, full_name, false);
            mReverseCache[full_name] = id;
        }
        else
        {
            mSignal(id, entry->mGroupName, true);
            mReverseCache[entry->mGroupName] = id;
        }
    }
}
Ejemplo n.º 2
0
//static
// Transform hard-coded name provided by server to a more legible username
std::string LLCacheName::buildUsername(const std::string& full_name)
{
    // rare, but handle hard-coded error names returned from server
    if (full_name == "(\?\?\?) (\?\?\?)")
    {
        return "(\?\?\?)";
    }

    std::string::size_type index = full_name.find(' ');

    if (index != std::string::npos)
    {
        std::string username;
        username = full_name.substr(0, index);
        std::string lastname = full_name.substr(index+1);

        static const LLCachedControl<bool> show_resident("LiruShowLastNameResident", false);
        if (lastname != "Resident" || show_resident)
        {
            username = username + "." + lastname;
        }

        LLStringUtil::toLower(username);
        return username;
    }

    // if the input wasn't a correctly formatted legacy name, just return it
    // cleaned up from a potential terminal "Resident"
    return cleanFullName(full_name);
}