diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-01-28 21:54:52 +0200 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-01-28 22:15:41 +0200 |
commit | 1d0f25714e17d1f65ee7ef4c9394fed9210e3cd4 (patch) | |
tree | 2fc1de28fd71a928ac1851608c1e2b4a1946eed4 /indra/newview/llpanelprofile.cpp | |
parent | 2d113743f2943a1ab614a41d29cef7e13bc4e878 (diff) |
SL-14486 Avoid accidental truncation of avatar notes field
Server sided limitation, web page allows more than server sends to viewer. This is a workaround untill server sided restriction gets lifted.
Diffstat (limited to 'indra/newview/llpanelprofile.cpp')
-rw-r--r-- | indra/newview/llpanelprofile.cpp | 81 |
1 files changed, 73 insertions, 8 deletions
diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 82515c8d4a..49b18874f3 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -1237,10 +1237,24 @@ void LLPanelProfileFirstLife::updateButtons() LLPanelProfileNotes::LLPanelProfileNotes() : LLPanelProfileTab() +, mAvatarNameCacheConnection() { } +LLPanelProfileNotes::~LLPanelProfileNotes() +{ + if (getAvatarId().notNull()) + { + LLAvatarTracker::instance().removeParticularFriendObserver(getAvatarId(), this); + } + + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } +} + void LLPanelProfileNotes::updateData() { LLUUID avatar_id = getAvatarId(); @@ -1257,6 +1271,7 @@ BOOL LLPanelProfileNotes::postBuild() mMapRights = getChild<LLCheckBoxCtrl>("map_check"); mEditObjectRights = getChild<LLCheckBoxCtrl>("objects_check"); mNotesEditor = getChild<LLTextEditor>("notes_edit"); + mCharacterLimitWarning = getChild<LLTextBox>("character_limit_warning"); mEditObjectRights->setCommitCallback(boost::bind(&LLPanelProfileNotes::onCommitRights, this)); @@ -1272,6 +1287,8 @@ void LLPanelProfileNotes::onOpen(const LLSD& key) resetData(); fillRightsData(); + + mAvatarNameCacheConnection = LLAvatarNameCache::get(getAvatarId(), boost::bind(&LLPanelProfileNotes::onAvatarNameCache, this, _1, _2)); } void LLPanelProfileNotes::apply() @@ -1379,6 +1396,27 @@ void LLPanelProfileNotes::applyRights() LLAvatarPropertiesProcessor::getInstance()->sendFriendRights(getAvatarId(), rights); } +void LLPanelProfileNotes::updateWarning() +{ + mCharacterLimitWarning->setText(std::string()); + + std::string str = getString("header_symbol_limit"); + mCharacterLimitWarning->appendText(str, false, LLStyle::Params().color(LLColor4::yellow)); + mCharacterLimitWarning->appendText(" ", false, LLStyle::Params()); + + LLStringUtil::format_map_t args; + if (!mURLWebProfile.empty()) + { + args["[PROFILE_URL]"] = mURLWebProfile; + } + else + { + args["[PROFILE_URL]"] = getProfileURL(getAvatarId().asString()); + } + str = getString("body_symbol_limit", args); + mCharacterLimitWarning->appendText(str, false, LLStyle::Params()); +} + void LLPanelProfileNotes::processProperties(void* data, EAvatarProcessorType type) { if (APT_NOTES == type) @@ -1390,6 +1428,16 @@ void LLPanelProfileNotes::processProperties(void* data, EAvatarProcessorType typ mNotesEditor->setEnabled(TRUE); updateButtons(); + if (avatar_notes->notes.size() > 1000) + { + mCharacterLimitWarning->setVisible(TRUE); + updateWarning(); + } + else + { + mCharacterLimitWarning->setVisible(FALSE); + } + LLAvatarPropertiesProcessor::getInstance()->removeObserver(getAvatarId(),this); } } @@ -1402,6 +1450,9 @@ void LLPanelProfileNotes::resetData() mOnlineStatus->setValue(FALSE); mMapRights->setValue(FALSE); mEditObjectRights->setValue(FALSE); + mCharacterLimitWarning->setVisible(FALSE); + + mURLWebProfile.clear(); } void LLPanelProfileNotes::enableCheckboxes(bool enable) @@ -1411,14 +1462,6 @@ void LLPanelProfileNotes::enableCheckboxes(bool enable) mEditObjectRights->setEnabled(enable); } -LLPanelProfileNotes::~LLPanelProfileNotes() -{ - if (getAvatarId().notNull()) - { - LLAvatarTracker::instance().removeParticularFriendObserver(getAvatarId(), this); - } -} - // virtual, called by LLAvatarTracker void LLPanelProfileNotes::changed(U32 mask) { @@ -1439,6 +1482,28 @@ void LLPanelProfileNotes::setAvatarId(const LLUUID& avatar_id) } } +void LLPanelProfileNotes::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name) +{ + mAvatarNameCacheConnection.disconnect(); + + std::string username = av_name.getAccountName(); + if (username.empty()) + { + username = LLCacheName::buildUsername(av_name.getDisplayName()); + } + else + { + LLStringUtil::replaceChar(username, ' ', '.'); + } + + mURLWebProfile = getProfileURL(username, false); + + if (mCharacterLimitWarning->getVisible()) + { + updateWarning(); + } +} + ////////////////////////////////////////////////////////////////////////// // LLPanelProfile |