From 70956fb2dbc42501d27a474e3f80003d591ee646 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Sat, 14 Oct 2023 00:11:06 +0200 Subject: SL-20163 Allow residents to hide exact join date on profiles --- indra/newview/llpanelprofile.cpp | 225 +++++++++++++++------------------------ 1 file changed, 86 insertions(+), 139 deletions(-) (limited to 'indra/newview/llpanelprofile.cpp') diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 3333c832d2..1d81586c15 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -191,6 +191,8 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) avatar_data->caption_text = result["caption"].asString(); } + avatar_data->hide_sl_age = result["hide_sl_age"].asBoolean(); + panel = floater_profile->findChild(PANEL_SECONDLIFE, TRUE); LLPanelProfileSecondLife *panel_sl = dynamic_cast(panel); if (panel_sl) @@ -274,38 +276,6 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) } } -//TODO: changes take two minutes to propagate! -// Add some storage that holds updated data for two minutes -// for new instances to reuse the data -// Profile data is only relevant to won avatar, but notes -// are for everybody -void put_avatar_properties_coro(std::string cap_url, LLUUID agent_id, LLSD data) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("put_avatar_properties_coro", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpHeaders::ptr_t httpHeaders; - - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - httpOpts->setFollowRedirects(true); - - std::string finalUrl = cap_url + "/" + agent_id.asString(); - - LLSD result = httpAdapter->putAndSuspend(httpRequest, finalUrl, data, httpOpts, httpHeaders); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status) - { - LL_WARNS("AvatarProperties") << "Failed to put agent information " << data << " for id " << agent_id << LL_ENDL; - return; - } - - LL_DEBUGS("AvatarProperties") << "Agent id: " << agent_id << " Data: " << data << " Result: " << httpResults << LL_ENDL; -} - LLUUID post_profile_image(std::string cap_url, const LLSD &first_data, std::string path_to_image, LLHandle *handle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -889,6 +859,7 @@ LLPanelProfileSecondLife::LLPanelProfileSecondLife() , mHasUnsavedDescriptionChanges(false) , mWaitingForImageUpload(false) , mAllowPublish(false) + , mHideSLAge(false) { } @@ -914,6 +885,7 @@ BOOL LLPanelProfileSecondLife::postBuild() { mGroupList = getChild("group_list"); mShowInSearchCombo = getChild("show_in_search"); + mHideSLAgeCombo = getChild("hide_sl_age"); mSecondLifePic = getChild("2nd_life_pic"); mSecondLifePicLayout = getChild("image_panel"); mDescriptionEdit = getChild("sl_description_edit"); @@ -928,6 +900,7 @@ BOOL LLPanelProfileSecondLife::postBuild() mCantEditObjectsIcon = getChild("cant_edit_objects"); mShowInSearchCombo->setCommitCallback([this](LLUICtrl*, void*) { onShowInSearchCallback(); }, nullptr); + mHideSLAgeCombo->setCommitCallback([this](LLUICtrl*, void*) { onHideSLAgeCallback(); }, nullptr); mGroupList->setDoubleClickCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask) { LLPanelProfileSecondLife::openGroupProfile(); }); mGroupList->setReturnCallback([this](LLUICtrl*, const LLSD&) { LLPanelProfileSecondLife::openGroupProfile(); }); mSaveDescriptionChanges->setCommitCallback([this](LLUICtrl*, void*) { onSaveDescriptionChanges(); }, nullptr); @@ -1202,7 +1175,7 @@ void LLPanelProfileSecondLife::fillCommonData(const LLAvatarData* avatar_data) // and to make sure icons in text will be up to date LLAvatarIconIDCache::getInstance()->add(avatar_data->avatar_id, avatar_data->image_id); - fillAgeData(avatar_data->born_on); + fillAgeData(avatar_data); setDescriptionText(avatar_data->about_text); @@ -1237,7 +1210,7 @@ void LLPanelProfileSecondLife::fillCommonData(const LLAvatarData* avatar_data) if (getSelfProfile()) { mAllowPublish = avatar_data->flags & AVATAR_ALLOW_PUBLISH; - mShowInSearchCombo->setValue((BOOL)mAllowPublish); + mShowInSearchCombo->setValue(mAllowPublish ? TRUE : FALSE); } } @@ -1362,21 +1335,44 @@ void LLPanelProfileSecondLife::fillRightsData() } } -void LLPanelProfileSecondLife::fillAgeData(const LLDate &born_on) +void LLPanelProfileSecondLife::fillAgeData(const LLAvatarData* avatar_data) { // Date from server comes already converted to stl timezone, // so display it as an UTC + 0 - std::string name_and_date = getString("date_format"); + std::string name_and_date = getString(avatar_data->hide_sl_age ? "date_format_short" : "date_format_full"); LLSD args_name; - args_name["datetime"] = (S32)born_on.secondsSinceEpoch(); + args_name["datetime"] = (S32)avatar_data->born_on.secondsSinceEpoch(); LLStringUtil::format(name_and_date, args_name); getChild("sl_birth_date")->setValue(name_and_date); - std::string register_date = getString("age_format"); - LLSD args_age; - args_age["[AGE]"] = LLDateUtil::ageFromDate(born_on, LLDate::now()); - LLStringUtil::format(register_date, args_age); - getChild("user_age")->setValue(register_date); + LLUICtrl* userAgeCtrl = getChild("user_age"); + if (avatar_data->hide_sl_age) + { + userAgeCtrl->setVisible(FALSE); + } + else + { + std::string register_date = getString("age_format"); + LLSD args_age; + args_age["[AGE]"] = LLDateUtil::ageFromDate(avatar_data->born_on, LLDate::now()); + LLStringUtil::format(register_date, args_age); + userAgeCtrl->setValue(register_date); + } + + if (getSelfProfile()) + { + F64 birth = avatar_data->born_on.secondsSinceEpoch(); + F64 now = LLDate::now().secondsSinceEpoch(); + if (now - birth > 365 * 24 * 60 * 60) + { + mHideSLAge = avatar_data->hide_sl_age; + mHideSLAgeCombo->setValue(mHideSLAge ? TRUE : FALSE); + } + else + { + mHideSLAgeCombo->setVisible(FALSE); + } + } } void LLPanelProfileSecondLife::onImageLoaded(BOOL success, LLViewerFetchedTexture *imagep) @@ -1493,6 +1489,10 @@ void LLPanelProfileSecondLife::setLoaded() if (getSelfProfile()) { mShowInSearchCombo->setEnabled(TRUE); + if (mHideSLAgeCombo->getVisible()) + { + mHideSLAgeCombo->setEnabled(TRUE); + } mDescriptionEdit->setEnabled(TRUE); } } @@ -1820,39 +1820,28 @@ void LLPanelProfileSecondLife::onSetDescriptionDirty() void LLPanelProfileSecondLife::onShowInSearchCallback() { - S32 value = mShowInSearchCombo->getValue().asInteger(); - if (mAllowPublish == (bool)value) - { + bool value = mShowInSearchCombo->getValue().asInteger(); + if (value == mAllowPublish) return; - } - std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP); - if (!cap_url.empty()) - { - mAllowPublish = value; - LLSD data; - data["allow_publish"] = mAllowPublish; - LLCoros::instance().launch("putAgentUserInfoCoro", - boost::bind(put_avatar_properties_coro, cap_url, getAvatarId(), data)); - } - else - { - LL_WARNS("AvatarProperties") << "Failed to update profile data, no cap found" << LL_ENDL; - } + + mAllowPublish = value; + saveAgentUserInfoCoro("allow_publish", value); +} + +void LLPanelProfileSecondLife::onHideSLAgeCallback() +{ + bool value = mHideSLAgeCombo->getValue().asInteger(); + if (value == mHideSLAge) + return; + + mHideSLAge = value; + saveAgentUserInfoCoro("hide_sl_age", value); } void LLPanelProfileSecondLife::onSaveDescriptionChanges() { mDescriptionText = mDescriptionEdit->getValue().asString(); - std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP); - if (!cap_url.empty()) - { - LLCoros::instance().launch("putAgentUserInfoCoro", - boost::bind(put_avatar_properties_coro, cap_url, getAvatarId(), LLSD().with("sl_about_text", mDescriptionText))); - } - else - { - LL_WARNS("AvatarProperties") << "Failed to update profile data, no cap found" << LL_ENDL; - } + saveAgentUserInfoCoro("sl_about_text", mDescriptionText); mSaveDescriptionChanges->setEnabled(FALSE); mDiscardDescriptionChanges->setEnabled(FALSE); @@ -1987,46 +1976,34 @@ void LLPanelProfileSecondLife::onShowTexturePicker() void LLPanelProfileSecondLife::onCommitProfileImage(const LLUUID& id) { if (mImageId == id) - { return; - } - std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP); - if (!cap_url.empty()) + if (!saveAgentUserInfoCoro("sl_image_id", id)) + return; + + mImageId = id; + if (mImageId == LLUUID::null) + { + mSecondLifePic->setValue("Generic_Person_Large"); + } + else { - LLSD params; - params["sl_image_id"] = id; - LLCoros::instance().launch("putAgentUserInfoCoro", - boost::bind(put_avatar_properties_coro, cap_url, getAvatarId(), params)); + mSecondLifePic->setValue(mImageId); + } - mImageId = id; + LLFloater *floater = mFloaterProfileTextureHandle.get(); + if (floater) + { + LLFloaterProfileTexture * texture_view = dynamic_cast(floater); if (mImageId == LLUUID::null) { - mSecondLifePic->setValue("Generic_Person_Large"); + texture_view->resetAsset(); } else { - mSecondLifePic->setValue(mImageId); - } - - LLFloater *floater = mFloaterProfileTextureHandle.get(); - if (floater) - { - LLFloaterProfileTexture * texture_view = dynamic_cast(floater); - if (mImageId == LLUUID::null) - { - texture_view->resetAsset(); - } - else - { - texture_view->loadAsset(mImageId); - } + texture_view->loadAsset(mImageId); } } - else - { - LL_WARNS("AvatarProperties") << "Failed to update profile data, no cap found" << LL_ENDL; - } } ////////////////////////////////////////////////////////////////////////// @@ -2324,34 +2301,22 @@ void LLPanelProfileFirstLife::onRemovePhoto() void LLPanelProfileFirstLife::onCommitPhoto(const LLUUID& id) { if (mImageId == id) - { return; - } - std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP); - if (!cap_url.empty()) - { - LLSD params; - params["fl_image_id"] = id; - LLCoros::instance().launch("putAgentUserInfoCoro", - boost::bind(put_avatar_properties_coro, cap_url, getAvatarId(), params)); - - mImageId = id; - if (mImageId.notNull()) - { - mPicture->setValue(mImageId); - } - else - { - mPicture->setValue("Generic_Person_Large"); - } + if (!saveAgentUserInfoCoro("fl_image_id", id)) + return; - mRemovePhoto->setEnabled(mImageId.notNull()); + mImageId = id; + if (mImageId.notNull()) + { + mPicture->setValue(mImageId); } else { - LL_WARNS("AvatarProperties") << "Failed to update profile data, no cap found" << LL_ENDL; + mPicture->setValue("Generic_Person_Large"); } + + mRemovePhoto->setEnabled(mImageId.notNull()); } void LLPanelProfileFirstLife::setDescriptionText(const std::string &text) @@ -2374,16 +2339,7 @@ void LLPanelProfileFirstLife::onSetDescriptionDirty() void LLPanelProfileFirstLife::onSaveDescriptionChanges() { mCurrentDescription = mDescriptionEdit->getValue().asString(); - std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP); - if (!cap_url.empty()) - { - LLCoros::instance().launch("putAgentUserInfoCoro", - boost::bind(put_avatar_properties_coro, cap_url, getAvatarId(), LLSD().with("fl_about_text", mCurrentDescription))); - } - else - { - LL_WARNS("AvatarProperties") << "Failed to update profile data, no cap found" << LL_ENDL; - } + saveAgentUserInfoCoro("fl_about_text", mCurrentDescription); mSaveChanges->setEnabled(FALSE); mDiscardChanges->setEnabled(FALSE); @@ -2517,16 +2473,7 @@ void LLPanelProfileNotes::onSetNotesDirty() void LLPanelProfileNotes::onSaveNotesChanges() { mCurrentNotes = mNotesEditor->getValue().asString(); - std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP); - if (!cap_url.empty()) - { - LLCoros::instance().launch("putAgentUserInfoCoro", - boost::bind(put_avatar_properties_coro, cap_url, getAvatarId(), LLSD().with("notes", mCurrentNotes))); - } - else - { - LL_WARNS("AvatarProperties") << "Failed to update profile data, no cap found" << LL_ENDL; - } + saveAgentUserInfoCoro("notes", mCurrentNotes); mSaveChanges->setEnabled(FALSE); mDiscardChanges->setEnabled(FALSE); -- cgit v1.3 From 633865320aee0b2e1c615f2d5a772e5ddc3d9ae2 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Tue, 17 Oct 2023 12:01:03 +0200 Subject: SL-20163 Rename hide_sl_age to hide_age --- indra/newview/llavatarpropertiesprocessor.cpp | 6 +++- indra/newview/llavatarpropertiesprocessor.h | 4 +-- indra/newview/llpanelprofile.cpp | 32 +++++++++++----------- indra/newview/llpanelprofile.h | 6 ++-- .../default/xui/en/panel_profile_secondlife.xml | 12 ++++---- 5 files changed, 32 insertions(+), 28 deletions(-) (limited to 'indra/newview/llpanelprofile.cpp') diff --git a/indra/newview/llavatarpropertiesprocessor.cpp b/indra/newview/llavatarpropertiesprocessor.cpp index 1d08e158af..f43ada7abc 100644 --- a/indra/newview/llavatarpropertiesprocessor.cpp +++ b/indra/newview/llavatarpropertiesprocessor.cpp @@ -298,7 +298,10 @@ void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_ur || !result.has("id") || agent_id != result["id"].asUUID()) { - LL_WARNS("AvatarProperties") << "Failed to get agent information for id " << agent_id << LL_ENDL; + LL_WARNS("AvatarProperties") << "Failed to get agent information for id " << agent_id + << (!status ? " (no HTTP status)" : !result.has("id") ? " (no result.id)" : + std::string(" (result.id=") + result["id"].asUUID().asString() + ")") + << LL_ENDL; LLAvatarPropertiesProcessor* self = getInstance(); self->removePendingRequest(agent_id, APT_PROPERTIES); self->removePendingRequest(agent_id, APT_PICKS); @@ -320,6 +323,7 @@ void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_ur avatar_data.about_text = result["sl_about_text"].asString(); avatar_data.fl_about_text = result["fl_about_text"].asString(); avatar_data.born_on = result["member_since"].asDate(); + avatar_data.hide_age = result["hide_age"].asBoolean(); avatar_data.profile_url = getProfileURL(agent_id.asString()); avatar_data.flags = 0; diff --git a/indra/newview/llavatarpropertiesprocessor.h b/indra/newview/llavatarpropertiesprocessor.h index c2347b9e35..0f8b1dd130 100644 --- a/indra/newview/llavatarpropertiesprocessor.h +++ b/indra/newview/llavatarpropertiesprocessor.h @@ -85,8 +85,8 @@ struct LLAvatarData std::string profile_url; U8 caption_index; std::string caption_text; - std::string customer_type; - bool hide_sl_age; + std::string customer_type; + bool hide_age; U32 flags; }; diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 1d81586c15..6e4bf62dd9 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -191,7 +191,7 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) avatar_data->caption_text = result["caption"].asString(); } - avatar_data->hide_sl_age = result["hide_sl_age"].asBoolean(); + avatar_data->hide_age = result["hide_age"].asBoolean(); panel = floater_profile->findChild(PANEL_SECONDLIFE, TRUE); LLPanelProfileSecondLife *panel_sl = dynamic_cast(panel); @@ -859,7 +859,7 @@ LLPanelProfileSecondLife::LLPanelProfileSecondLife() , mHasUnsavedDescriptionChanges(false) , mWaitingForImageUpload(false) , mAllowPublish(false) - , mHideSLAge(false) + , mHideAge(false) { } @@ -885,7 +885,7 @@ BOOL LLPanelProfileSecondLife::postBuild() { mGroupList = getChild("group_list"); mShowInSearchCombo = getChild("show_in_search"); - mHideSLAgeCombo = getChild("hide_sl_age"); + mHideAgeCombo = getChild("hide_age"); mSecondLifePic = getChild("2nd_life_pic"); mSecondLifePicLayout = getChild("image_panel"); mDescriptionEdit = getChild("sl_description_edit"); @@ -900,7 +900,7 @@ BOOL LLPanelProfileSecondLife::postBuild() mCantEditObjectsIcon = getChild("cant_edit_objects"); mShowInSearchCombo->setCommitCallback([this](LLUICtrl*, void*) { onShowInSearchCallback(); }, nullptr); - mHideSLAgeCombo->setCommitCallback([this](LLUICtrl*, void*) { onHideSLAgeCallback(); }, nullptr); + mHideAgeCombo->setCommitCallback([this](LLUICtrl*, void*) { onHideAgeCallback(); }, nullptr); mGroupList->setDoubleClickCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask) { LLPanelProfileSecondLife::openGroupProfile(); }); mGroupList->setReturnCallback([this](LLUICtrl*, const LLSD&) { LLPanelProfileSecondLife::openGroupProfile(); }); mSaveDescriptionChanges->setCommitCallback([this](LLUICtrl*, void*) { onSaveDescriptionChanges(); }, nullptr); @@ -1339,14 +1339,14 @@ void LLPanelProfileSecondLife::fillAgeData(const LLAvatarData* avatar_data) { // Date from server comes already converted to stl timezone, // so display it as an UTC + 0 - std::string name_and_date = getString(avatar_data->hide_sl_age ? "date_format_short" : "date_format_full"); + std::string name_and_date = getString(avatar_data->hide_age ? "date_format_short" : "date_format_full"); LLSD args_name; args_name["datetime"] = (S32)avatar_data->born_on.secondsSinceEpoch(); LLStringUtil::format(name_and_date, args_name); getChild("sl_birth_date")->setValue(name_and_date); LLUICtrl* userAgeCtrl = getChild("user_age"); - if (avatar_data->hide_sl_age) + if (avatar_data->hide_age) { userAgeCtrl->setVisible(FALSE); } @@ -1365,12 +1365,12 @@ void LLPanelProfileSecondLife::fillAgeData(const LLAvatarData* avatar_data) F64 now = LLDate::now().secondsSinceEpoch(); if (now - birth > 365 * 24 * 60 * 60) { - mHideSLAge = avatar_data->hide_sl_age; - mHideSLAgeCombo->setValue(mHideSLAge ? TRUE : FALSE); + mHideAge = avatar_data->hide_age; + mHideAgeCombo->setValue(mHideAge ? TRUE : FALSE); } else { - mHideSLAgeCombo->setVisible(FALSE); + mHideAgeCombo->setVisible(FALSE); } } } @@ -1489,9 +1489,9 @@ void LLPanelProfileSecondLife::setLoaded() if (getSelfProfile()) { mShowInSearchCombo->setEnabled(TRUE); - if (mHideSLAgeCombo->getVisible()) + if (mHideAgeCombo->getVisible()) { - mHideSLAgeCombo->setEnabled(TRUE); + mHideAgeCombo->setEnabled(TRUE); } mDescriptionEdit->setEnabled(TRUE); } @@ -1828,14 +1828,14 @@ void LLPanelProfileSecondLife::onShowInSearchCallback() saveAgentUserInfoCoro("allow_publish", value); } -void LLPanelProfileSecondLife::onHideSLAgeCallback() +void LLPanelProfileSecondLife::onHideAgeCallback() { - bool value = mHideSLAgeCombo->getValue().asInteger(); - if (value == mHideSLAge) + bool value = mHideAgeCombo->getValue().asInteger(); + if (value == mHideAge) return; - mHideSLAge = value; - saveAgentUserInfoCoro("hide_sl_age", value); + mHideAge = value; + saveAgentUserInfoCoro("hide_age", value); } void LLPanelProfileSecondLife::onSaveDescriptionChanges() diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h index 61ced27db5..f4b618eb27 100644 --- a/indra/newview/llpanelprofile.h +++ b/indra/newview/llpanelprofile.h @@ -179,7 +179,7 @@ private: void setDescriptionText(const std::string &text); void onSetDescriptionDirty(); void onShowInSearchCallback(); - void onHideSLAgeCallback(); + void onHideAgeCallback(); void onSaveDescriptionChanges(); void onDiscardDescriptionChanges(); void onShowAgentPermissionsDialog(); @@ -194,7 +194,7 @@ private: LLGroupList* mGroupList; LLComboBox* mShowInSearchCombo; - LLComboBox* mHideSLAgeCombo; + LLComboBox* mHideAgeCombo; LLThumbnailCtrl* mSecondLifePic; LLPanel* mSecondLifePicLayout; LLTextEditor* mDescriptionEdit; @@ -216,7 +216,7 @@ private: bool mVoiceStatus; bool mWaitingForImageUpload; bool mAllowPublish; - bool mHideSLAge; + bool mHideAge; std::string mDescriptionText; LLUUID mImageId; diff --git a/indra/newview/skins/default/xui/en/panel_profile_secondlife.xml b/indra/newview/skins/default/xui/en/panel_profile_secondlife.xml index 26cc04e6af..307b7b83ef 100644 --- a/indra/newview/skins/default/xui/en/panel_profile_secondlife.xml +++ b/indra/newview/skins/default/xui/en/panel_profile_secondlife.xml @@ -352,7 +352,7 @@ Account: [ACCTTYPE] name="settings_panel" follows="all" layout="topleft" - height="80" + height="70" auto_resize="false" user_resize="false"> @@ -360,8 +360,8 @@ Account: [ACCTTYPE] name="show_in_search" tool_tip="Let people see you in search results" left="1" - top="18" - height="23" + top="5" + height="25" width="176" follows="left|top" layout="topleft" @@ -376,11 +376,11 @@ Account: [ACCTTYPE] value="0" /> Date: Thu, 19 Oct 2023 18:25:23 +0200 Subject: SL-20163 Rework LLAvatarPropertiesProcessor::sendRequest() --- indra/newview/llavatariconctrl.cpp | 2 +- indra/newview/llavatarpropertiesprocessor.cpp | 240 ++++++++++++------------- indra/newview/llavatarpropertiesprocessor.h | 11 +- indra/newview/llfloaterbuycurrency.cpp | 2 +- indra/newview/llfloaterpreference.cpp | 3 +- indra/newview/llinspectavatar.cpp | 17 +- indra/newview/llpanelprofile.cpp | 18 +- indra/newview/skins/default/xui/en/strings.xml | 3 +- 8 files changed, 146 insertions(+), 150 deletions(-) (limited to 'indra/newview/llpanelprofile.cpp') diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp index c131dc641b..6145a88743 100644 --- a/indra/newview/llavatariconctrl.cpp +++ b/indra/newview/llavatariconctrl.cpp @@ -294,7 +294,7 @@ bool LLAvatarIconCtrl::updateFromCache() //virtual void LLAvatarIconCtrl::processProperties(void* data, EAvatarProcessorType type) { - if (APT_PROPERTIES == type) + if (APT_PROPERTIES_LEGACY == type) { LLAvatarData* avatar_data = static_cast(data); if (avatar_data) diff --git a/indra/newview/llavatarpropertiesprocessor.cpp b/indra/newview/llavatarpropertiesprocessor.cpp index 8be5d370b3..9d3bc7cabe 100644 --- a/indra/newview/llavatarpropertiesprocessor.cpp +++ b/indra/newview/llavatarpropertiesprocessor.cpp @@ -114,32 +114,32 @@ void LLAvatarPropertiesProcessor::sendRequest(const LLUUID& avatar_id, EAvatarPr return; } - std::string cap; - - switch (type) + // Try to send HTTP request if cap_url is available + if (type == APT_PROPERTIES || type == APT_PICKS || type == APT_GROUPS || type == APT_NOTES) { - case APT_PROPERTIES: - // indicate we're going to make a request - sendAvatarPropertiesRequestMessage(avatar_id); - // can use getRegionCapability("AgentProfile"), but it is heavy - // initAgentProfileCapRequest(avatar_id, cap); - break; - case APT_PICKS: - case APT_GROUPS: - case APT_NOTES: - if (cap.empty()) + std::string cap_url(gAgent.getRegionCapability("AgentProfile")); + if (!cap_url.empty()) { - // indicate we're going to make a request - sendGenericRequest(avatar_id, type, method); + initAgentProfileCapRequest(avatar_id, cap_url, type); + return; } - else + + // Don't sent UDP request for APT_PROPERTIES + if (type == APT_PROPERTIES) { - initAgentProfileCapRequest(avatar_id, cap); + LL_WARNS() << "No cap_url for APT_PROPERTIES, request is not sent" << LL_ENDL; + return; } - break; - default: + } + + // Send UDP request + if (type == APT_PROPERTIES_LEGACY) + { + sendAvatarPropertiesRequestMessage(avatar_id); + } + else + { sendGenericRequest(avatar_id, type, method); - break; } } @@ -155,7 +155,7 @@ void LLAvatarPropertiesProcessor::sendGenericRequest(const LLUUID& avatar_id, EA void LLAvatarPropertiesProcessor::sendAvatarPropertiesRequestMessage(const LLUUID& avatar_id) { - addPendingRequest(avatar_id, APT_PROPERTIES); + addPendingRequest(avatar_id, APT_PROPERTIES_LEGACY); LLMessageSystem *msg = gMessageSystem; @@ -167,19 +167,16 @@ void LLAvatarPropertiesProcessor::sendAvatarPropertiesRequestMessage(const LLUUI gAgent.sendReliableMessage(); } -void LLAvatarPropertiesProcessor::initAgentProfileCapRequest(const LLUUID& avatar_id, const std::string& cap_url) +void LLAvatarPropertiesProcessor::initAgentProfileCapRequest(const LLUUID& avatar_id, const std::string& cap_url, EAvatarProcessorType type) { - addPendingRequest(avatar_id, APT_PROPERTIES); - addPendingRequest(avatar_id, APT_PICKS); - addPendingRequest(avatar_id, APT_GROUPS); - addPendingRequest(avatar_id, APT_NOTES); + addPendingRequest(avatar_id, type); LLCoros::instance().launch("requestAgentUserInfoCoro", - boost::bind(requestAvatarPropertiesCoro, cap_url, avatar_id)); + [cap_url, avatar_id, type]() { requestAvatarPropertiesCoro(cap_url, avatar_id, type); }); } -void LLAvatarPropertiesProcessor::sendAvatarPropertiesRequest(const LLUUID& avatar_id) +void LLAvatarPropertiesProcessor::sendAvatarPropertiesRequest(const LLUUID& avatar_id, bool use_cap) { - sendRequest(avatar_id, APT_PROPERTIES, "AvatarPropertiesRequest"); + sendRequest(avatar_id, use_cap ? APT_PROPERTIES : APT_PROPERTIES_LEGACY, "AvatarPropertiesRequest"); } void LLAvatarPropertiesProcessor::sendAvatarPicksRequest(const LLUUID& avatar_id) @@ -274,7 +271,7 @@ bool LLAvatarPropertiesProcessor::hasPaymentInfoOnFile(const LLAvatarData* avata } // static -void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_url, LLUUID agent_id) +void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_url, LLUUID agent_id, EAvatarProcessorType type) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -289,6 +286,9 @@ void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_ur LLSD result = httpAdapter->getAndSuspend(httpRequest, finalUrl, httpOpts, httpHeaders); + // Response is being processed, no longer pending is required + getInstance()->removePendingRequest(agent_id, type); + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -300,114 +300,108 @@ void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_ur << (!status ? " (no HTTP status)" : !result.has("id") ? " (no result.id)" : std::string(" (result.id=") + result["id"].asUUID().asString() + ")") << LL_ENDL; - LLAvatarPropertiesProcessor* self = getInstance(); - self->removePendingRequest(agent_id, APT_PROPERTIES); - self->removePendingRequest(agent_id, APT_PICKS); - self->removePendingRequest(agent_id, APT_GROUPS); - self->removePendingRequest(agent_id, APT_NOTES); return; } - // Avatar Data - - LLAvatarData avatar_data; - std::string birth_date; - - avatar_data.agent_id = agent_id; - avatar_data.avatar_id = agent_id; - avatar_data.image_id = result["sl_image_id"].asUUID(); - avatar_data.fl_image_id = result["fl_image_id"].asUUID(); - avatar_data.partner_id = result["partner_id"].asUUID(); - avatar_data.about_text = result["sl_about_text"].asString(); - avatar_data.fl_about_text = result["fl_about_text"].asString(); - avatar_data.born_on = result["member_since"].asDate(); - avatar_data.hide_age = result["hide_age"].asBoolean(); - avatar_data.profile_url = getProfileURL(agent_id.asString()); - avatar_data.customer_type = result["customer_type"].asString(); - - avatar_data.flags = 0; - if (result["online"].asBoolean()) - { - avatar_data.flags |= AVATAR_ONLINE; - } - if (result["allow_publish"].asBoolean()) + if (type == APT_PROPERTIES) { - avatar_data.flags |= AVATAR_ALLOW_PUBLISH; - } - if (result["identified"].asBoolean()) - { - avatar_data.flags |= AVATAR_IDENTIFIED; - } - if (result["transacted"].asBoolean()) - { - avatar_data.flags |= AVATAR_TRANSACTED; - } + LLAvatarData avatar_data; + + std::string birth_date; + + avatar_data.agent_id = agent_id; + avatar_data.avatar_id = agent_id; + avatar_data.image_id = result["sl_image_id"].asUUID(); + avatar_data.fl_image_id = result["fl_image_id"].asUUID(); + avatar_data.partner_id = result["partner_id"].asUUID(); + avatar_data.about_text = result["sl_about_text"].asString(); + avatar_data.fl_about_text = result["fl_about_text"].asString(); + avatar_data.born_on = result["member_since"].asDate(); + // TODO: SL-20163 Remove the "has" check when SRV-684 is done + // and the field "hide_age" is included to the http response + avatar_data.hide_age = !result.has("hide_age") || result["hide_age"].asBoolean(); + avatar_data.profile_url = getProfileURL(agent_id.asString()); + avatar_data.customer_type = result["customer_type"].asString(); + + avatar_data.flags = 0; + if (result["online"].asBoolean()) + { + avatar_data.flags |= AVATAR_ONLINE; + } + if (result["allow_publish"].asBoolean()) + { + avatar_data.flags |= AVATAR_ALLOW_PUBLISH; + } + if (result["identified"].asBoolean()) + { + avatar_data.flags |= AVATAR_IDENTIFIED; + } + if (result["transacted"].asBoolean()) + { + avatar_data.flags |= AVATAR_TRANSACTED; + } - avatar_data.caption_index = 0; - if (result.has("charter_member")) // won't be present if "caption" is set - { - avatar_data.caption_index = result["charter_member"].asInteger(); + avatar_data.caption_index = 0; + if (result.has("charter_member")) // won't be present if "caption" is set + { + avatar_data.caption_index = result["charter_member"].asInteger(); + } + else if (result.has("caption")) + { + avatar_data.caption_text = result["caption"].asString(); + } + + getInstance()->notifyObservers(agent_id, &avatar_data, type); } - else if (result.has("caption")) + else if (type == APT_PICKS) { - avatar_data.caption_text = result["caption"].asString(); - } - - LLAvatarPropertiesProcessor* self = getInstance(); - // Request processed, no longer pending - self->removePendingRequest(agent_id, APT_PROPERTIES); - self->notifyObservers(agent_id, &avatar_data, APT_PROPERTIES); + LLAvatarPicks avatar_picks; - // Picks + avatar_picks.agent_id = agent_id; // Not in use? + avatar_picks.target_id = agent_id; - LLSD picks_array = result["picks"]; - LLAvatarPicks avatar_picks; - avatar_picks.agent_id = agent_id; // Not in use? - avatar_picks.target_id = agent_id; + LLSD picks_array = result["picks"]; + for (LLSD::array_const_iterator it = picks_array.beginArray(); it != picks_array.endArray(); ++it) + { + const LLSD& pick_data = *it; + avatar_picks.picks_list.emplace_back(pick_data["id"].asUUID(), pick_data["name"].asString()); + } - for (LLSD::array_const_iterator it = picks_array.beginArray(); it != picks_array.endArray(); ++it) - { - const LLSD& pick_data = *it; - avatar_picks.picks_list.emplace_back(pick_data["id"].asUUID(), pick_data["name"].asString()); + getInstance()->notifyObservers(agent_id, &avatar_picks, type); } + else if (type == APT_GROUPS) + { + LLAvatarGroups avatar_groups; - // Request processed, no longer pending - self->removePendingRequest(agent_id, APT_PICKS); - self->notifyObservers(agent_id, &avatar_picks, APT_PICKS); - - // Groups + avatar_groups.agent_id = agent_id; // Not in use? + avatar_groups.avatar_id = agent_id; // target_id - LLSD groups_array = result["groups"]; - LLAvatarGroups avatar_groups; - avatar_groups.agent_id = agent_id; // Not in use? - avatar_groups.avatar_id = agent_id; // target_id + LLSD groups_array = result["groups"]; + for (LLSD::array_const_iterator it = groups_array.beginArray(); it != groups_array.endArray(); ++it) + { + const LLSD& group_info = *it; + LLAvatarGroups::LLGroupData group_data; + group_data.group_powers = 0; // Not in use? + group_data.group_title = group_info["name"].asString(); // Missing data, not in use? + group_data.group_id = group_info["id"].asUUID(); + group_data.group_name = group_info["name"].asString(); + group_data.group_insignia_id = group_info["image_id"].asUUID(); + + avatar_groups.group_list.push_back(group_data); + } - for (LLSD::array_const_iterator it = groups_array.beginArray(); it != groups_array.endArray(); ++it) - { - const LLSD& group_info = *it; - LLAvatarGroups::LLGroupData group_data; - group_data.group_powers = 0; // Not in use? - group_data.group_title = group_info["name"].asString(); // Missing data, not in use? - group_data.group_id = group_info["id"].asUUID(); - group_data.group_name = group_info["name"].asString(); - group_data.group_insignia_id = group_info["image_id"].asUUID(); - - avatar_groups.group_list.push_back(group_data); + getInstance()->notifyObservers(agent_id, &avatar_groups, type); } + else if (type == APT_NOTES) + { + LLAvatarNotes avatar_notes; - self->removePendingRequest(agent_id, APT_GROUPS); - self->notifyObservers(agent_id, &avatar_groups, APT_GROUPS); - - // Notes - LLAvatarNotes avatar_notes; - - avatar_notes.agent_id = agent_id; - avatar_notes.target_id = agent_id; - avatar_notes.notes = result["notes"].asString(); + avatar_notes.agent_id = agent_id; + avatar_notes.target_id = agent_id; + avatar_notes.notes = result["notes"].asString(); - // Request processed, no longer pending - self->removePendingRequest(agent_id, APT_NOTES); - self->notifyObservers(agent_id, &avatar_notes, APT_NOTES); + getInstance()->notifyObservers(agent_id, &avatar_notes, type); + } } void LLAvatarPropertiesProcessor::processAvatarPropertiesReply(LLMessageSystem* msg, void**) @@ -443,8 +437,8 @@ void LLAvatarPropertiesProcessor::processAvatarPropertiesReply(LLMessageSystem* } LLAvatarPropertiesProcessor* self = getInstance(); // Request processed, no longer pending - self->removePendingRequest(avatar_data.avatar_id, APT_PROPERTIES); - self->notifyObservers(avatar_data.avatar_id, &avatar_data, APT_PROPERTIES); + self->removePendingRequest(avatar_data.avatar_id, APT_PROPERTIES_LEGACY); + self->notifyObservers(avatar_data.avatar_id, &avatar_data, APT_PROPERTIES_LEGACY); } void LLAvatarPropertiesProcessor::processAvatarInterestsReply(LLMessageSystem* msg, void**) diff --git a/indra/newview/llavatarpropertiesprocessor.h b/indra/newview/llavatarpropertiesprocessor.h index 57e492f810..0dcda5a748 100644 --- a/indra/newview/llavatarpropertiesprocessor.h +++ b/indra/newview/llavatarpropertiesprocessor.h @@ -50,7 +50,8 @@ class LLMessageSystem; enum EAvatarProcessorType { - APT_PROPERTIES, + APT_PROPERTIES_LEGACY, // APT_PROPERTIES via udp request + APT_PROPERTIES, // APT_PROPERTIES via http request APT_NOTES, APT_GROUPS, APT_PICKS, @@ -210,7 +211,7 @@ public: // Request various types of avatar data. Duplicate requests will be // suppressed while waiting for a response from the network. - void sendAvatarPropertiesRequest(const LLUUID& avatar_id); + void sendAvatarPropertiesRequest(const LLUUID& avatar_id, bool use_cap = false); void sendAvatarPicksRequest(const LLUUID& avatar_id); void sendAvatarNotesRequest(const LLUUID& avatar_id); void sendAvatarGroupsRequest(const LLUUID& avatar_id); @@ -247,7 +248,7 @@ public: static bool hasPaymentInfoOnFile(const LLAvatarData* avatar_data); - static void requestAvatarPropertiesCoro(std::string cap_url, LLUUID agent_id); + static void requestAvatarPropertiesCoro(std::string cap_url, LLUUID agent_id, EAvatarProcessorType type); static void processAvatarPropertiesReply(LLMessageSystem* msg, void**); @@ -267,10 +268,10 @@ public: protected: - void sendRequest(const LLUUID& avatar_id, EAvatarProcessorType type, const std::string &method); + void sendRequest(const LLUUID& avatar_id, EAvatarProcessorType type, const std::string &method); void sendGenericRequest(const LLUUID& avatar_id, EAvatarProcessorType type, const std::string &method); void sendAvatarPropertiesRequestMessage(const LLUUID& avatar_id); - void initAgentProfileCapRequest(const LLUUID& avatar_id, const std::string& cap_url); + void initAgentProfileCapRequest(const LLUUID& avatar_id, const std::string& cap_url, EAvatarProcessorType type); void notifyObservers(const LLUUID& id,void* data, EAvatarProcessorType type); diff --git a/indra/newview/llfloaterbuycurrency.cpp b/indra/newview/llfloaterbuycurrency.cpp index 0cfac166c7..b0e63d5844 100644 --- a/indra/newview/llfloaterbuycurrency.cpp +++ b/indra/newview/llfloaterbuycurrency.cpp @@ -354,7 +354,7 @@ LLFetchAvatarPaymentInfo::~LLFetchAvatarPaymentInfo() void LLFetchAvatarPaymentInfo::processProperties(void* data, EAvatarProcessorType type) { - if (data && type == APT_PROPERTIES) + if (data && type == APT_PROPERTIES_LEGACY) { LLAvatarData* avatar_data = static_cast(data); LLFloaterBuyCurrency::handleBuyCurrency(LLAvatarPropertiesProcessor::hasPaymentInfoOnFile(avatar_data), mHasTarget, mName, mPrice); diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index e48f989c52..1f5eb5fdff 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -330,7 +330,7 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) void LLFloaterPreference::processProperties( void* pData, EAvatarProcessorType type ) { - if ( APT_PROPERTIES == type ) + if ( APT_PROPERTIES_LEGACY == type ) { const LLAvatarData* pAvatarData = static_cast( pData ); if (pAvatarData && (gAgent.getID() == pAvatarData->avatar_id) && (pAvatarData->avatar_id != LLUUID::null)) @@ -636,7 +636,6 @@ void LLFloaterPreference::cancel() void LLFloaterPreference::onOpen(const LLSD& key) { - // this variable and if that follows it are used to properly handle do not disturb mode response message static bool initialized = FALSE; // if user is logged in and we haven't initialized do not disturb mode response yet, do it diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp index b11c440015..4d003989fc 100644 --- a/indra/newview/llinspectavatar.cpp +++ b/indra/newview/llinspectavatar.cpp @@ -124,7 +124,7 @@ public: processor->addObserver(mAvatarID, this); // send a request (duplicates will be suppressed inside the avatar // properties processor) - processor->sendAvatarPropertiesRequest(mAvatarID); + processor->sendAvatarPropertiesRequest(mAvatarID, true); } ~LLFetchAvatarData() @@ -261,12 +261,15 @@ void LLInspectAvatar::requestUpdate() void LLInspectAvatar::processAvatarData(LLAvatarData* data) { LLStringUtil::format_map_t args; - { - std::string birth_date = LLTrans::getString("AvatarBirthDateFormat"); - LLStringUtil::format(birth_date, LLSD().with("datetime", (S32) data->born_on.secondsSinceEpoch())); - args["[BORN_ON]"] = birth_date; - } - args["[AGE]"] = LLDateUtil::ageFromDate(data->born_on, LLDate::now()); + + std::string birth_date = LLTrans::getString(data->hide_age ? + "AvatarBirthDateFormatShort" : + "AvatarBirthDateFormatFull"); + LLStringUtil::format(birth_date, LLSD().with("datetime", (S32)data->born_on.secondsSinceEpoch())); + args["[BORN_ON]"] = birth_date; + args["[AGE]"] = data->hide_age ? + LLStringUtilBase::null : + LLDateUtil::ageFromDate(data->born_on, LLDate::now()); args["[SL_PROFILE]"] = data->about_text; args["[RW_PROFILE"] = data->fl_about_text; args["[ACCTTYPE]"] = LLAvatarPropertiesProcessor::accountType(data); diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 6e4bf62dd9..a7a1f05c8a 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -145,9 +145,7 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) return; } - // Avatar Data - LLAvatarData *avatar_data = &panel_profile->mAvatarData; std::string birth_date; @@ -191,7 +189,11 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) avatar_data->caption_text = result["caption"].asString(); } - avatar_data->hide_age = result["hide_age"].asBoolean(); + // TODO: SL-20163 Remove the "has" check when SRV-684 is done + // and the field "hide_age" is included to the http response + avatar_data->hide_age = result.has("hide_age") ? + result["hide_age"].asBoolean() : // Server option value provided by resident + !panel_profile->getSelfProfile(); // Fallback temporary value (to be removed) panel = floater_profile->findChild(PANEL_SECONDLIFE, TRUE); LLPanelProfileSecondLife *panel_sl = dynamic_cast(panel); @@ -215,7 +217,6 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) } // Picks - LLSD picks_array = result["picks"]; LLAvatarPicks avatar_picks; avatar_picks.agent_id = agent_id; // Not in use? @@ -237,7 +238,6 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) } // Groups - LLSD groups_array = result["groups"]; LLAvatarGroups avatar_groups; avatar_groups.agent_id = agent_id; // Not in use? @@ -312,7 +312,6 @@ LLUUID post_profile_image(std::string cap_url, const LLSD &first_data, std::stri } // Upload the image - LLCore::HttpRequest::ptr_t uploaderhttpRequest(new LLCore::HttpRequest); LLCore::HttpHeaders::ptr_t uploaderhttpHeaders(new LLCore::HttpHeaders); LLCore::HttpOptions::ptr_t uploaderhttpOpts(new LLCore::HttpOptions); @@ -982,7 +981,7 @@ void LLPanelProfileSecondLife::updateData() if (!cap_url.empty()) { LLCoros::instance().launch("requestAgentUserInfoCoro", - boost::bind(request_avatar_properties_coro, cap_url, avatar_id)); + [cap_url, avatar_id]() { request_avatar_properties_coro(cap_url, avatar_id); }); } else { @@ -1058,7 +1057,6 @@ void LLPanelProfileSecondLife::processProfileProperties(const LLAvatarData* avat void LLPanelProfileSecondLife::processGroupProperties(const LLAvatarGroups* avatar_groups) { - LLAvatarGroups::group_list_t::const_iterator it = avatar_groups->group_list.begin(); const LLAvatarGroups::group_list_t::const_iterator it_end = avatar_groups->group_list.end(); @@ -2420,7 +2418,7 @@ void LLPanelProfileNotes::updateData() if (!cap_url.empty()) { LLCoros::instance().launch("requestAgentUserInfoCoro", - boost::bind(request_avatar_properties_coro, cap_url, avatar_id)); + [cap_url, avatar_id]() { request_avatar_properties_coro(cap_url, avatar_id); }); } } } @@ -2586,7 +2584,7 @@ void LLPanelProfile::updateData() if (!cap_url.empty()) { LLCoros::instance().launch("requestAgentUserInfoCoro", - boost::bind(request_avatar_properties_coro, cap_url, avatar_id)); + [cap_url, avatar_id]() { request_avatar_properties_coro(cap_url, avatar_id); }); } } } diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 2305371596..3c72fdf249 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -3935,7 +3935,8 @@ Abuse Report dance8 - [mthnum,datetime,slt]/[day,datetime,slt]/[year,datetime,slt] + [mthnum,datetime,slt]/[day,datetime,slt]/[year,datetime,slt] + [mthnum,datetime,slt]/[day,datetime,slt] none/none Can't load images larger than [WIDTH]*[HEIGHT] -- cgit v1.3 From d4087fce7b36625259576d5964c5a8dd8e93d707 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Sat, 21 Oct 2023 00:07:40 +0300 Subject: SL-20513 Cleanup LLAvatarPropertiesProcessor #1 --- indra/newview/llavatariconctrl.cpp | 4 +- indra/newview/llavatarpropertiesprocessor.cpp | 176 ++++---------------------- indra/newview/llavatarpropertiesprocessor.h | 120 ++++++++---------- indra/newview/llfloaterbuycurrency.cpp | 2 +- indra/newview/llfloaterpreference.cpp | 4 +- indra/newview/llinspectavatar.cpp | 2 +- indra/newview/llpanelprofile.cpp | 78 +++++------- indra/newview/llpanelprofile.h | 7 +- indra/newview/llstartup.cpp | 9 -- 9 files changed, 110 insertions(+), 292 deletions(-) (limited to 'indra/newview/llpanelprofile.cpp') diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp index 6145a88743..43d83da5ab 100644 --- a/indra/newview/llavatariconctrl.cpp +++ b/indra/newview/llavatariconctrl.cpp @@ -245,7 +245,7 @@ void LLAvatarIconCtrl::setValue(const LLSD& value) // messages. People API already hits the user table. LLIconCtrl::setValue(mDefaultIconName, LLViewerFetchedTexture::BOOST_UI); app->addObserver(mAvatarId, this); - app->sendAvatarPropertiesRequest(mAvatarId); + app->sendAvatarLegacyPropertiesRequest(mAvatarId); } } } @@ -296,7 +296,7 @@ void LLAvatarIconCtrl::processProperties(void* data, EAvatarProcessorType type) { if (APT_PROPERTIES_LEGACY == type) { - LLAvatarData* avatar_data = static_cast(data); + LLAvatarLegacyData* avatar_data = static_cast(data); if (avatar_data) { if (avatar_data->avatar_id != mAvatarId) diff --git a/indra/newview/llavatarpropertiesprocessor.cpp b/indra/newview/llavatarpropertiesprocessor.cpp index 49a4a5b65c..472cf8b8d5 100644 --- a/indra/newview/llavatarpropertiesprocessor.cpp +++ b/indra/newview/llavatarpropertiesprocessor.cpp @@ -115,7 +115,7 @@ void LLAvatarPropertiesProcessor::sendRequest(const LLUUID& avatar_id, EAvatarPr } // Try to send HTTP request if cap_url is available - if (type == APT_PROPERTIES || type == APT_PICKS || type == APT_GROUPS || type == APT_NOTES) + if (type == APT_PROPERTIES || type == APT_PICKS) { if (std::string cap_url(gAgent.getRegionCapability("AgentProfile")); !cap_url.empty()) { @@ -172,24 +172,19 @@ void LLAvatarPropertiesProcessor::initAgentProfileCapRequest(const LLUUID& avata [cap_url, avatar_id, type]() { requestAvatarPropertiesCoro(cap_url, avatar_id, type); }); } -void LLAvatarPropertiesProcessor::sendAvatarPropertiesRequest(const LLUUID& avatar_id, bool use_cap) +void LLAvatarPropertiesProcessor::sendAvatarPropertiesRequest(const LLUUID& avatar_id) { - sendRequest(avatar_id, use_cap ? APT_PROPERTIES : APT_PROPERTIES_LEGACY, "AvatarPropertiesRequest"); + sendRequest(avatar_id, APT_PROPERTIES, "AvatarPropertiesRequest"); } -void LLAvatarPropertiesProcessor::sendAvatarPicksRequest(const LLUUID& avatar_id) -{ - sendGenericRequest(avatar_id, APT_PICKS, "avatarpicksrequest"); -} - -void LLAvatarPropertiesProcessor::sendAvatarNotesRequest(const LLUUID& avatar_id) +void LLAvatarPropertiesProcessor::sendAvatarLegacyPropertiesRequest(const LLUUID& avatar_id) { - sendGenericRequest(avatar_id, APT_NOTES, "avatarnotesrequest"); + sendRequest(avatar_id, APT_PROPERTIES_LEGACY, "AvatarPropertiesRequest"); } -void LLAvatarPropertiesProcessor::sendAvatarGroupsRequest(const LLUUID& avatar_id) +void LLAvatarPropertiesProcessor::sendAvatarPicksRequest(const LLUUID& avatar_id) { - sendGenericRequest(avatar_id, APT_GROUPS, "avatargroupsrequest"); + sendGenericRequest(avatar_id, APT_PICKS, "avatarpicksrequest"); } void LLAvatarPropertiesProcessor::sendAvatarTexturesRequest(const LLUUID& avatar_id) @@ -324,6 +319,7 @@ void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_ur avatar_data.hide_age = !result.has("hide_age") || result["hide_age"].asBoolean(); avatar_data.profile_url = getProfileURL(avatar_id.asString()); avatar_data.customer_type = result["customer_type"].asString(); + avatar_data.notes = result["notes"].asString(); avatar_data.flags = 0; if (result["online"].asBoolean()) @@ -353,6 +349,20 @@ void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_ur avatar_data.caption_text = result["caption"].asString(); } + LLSD groups_array = result["groups"]; + for (LLSD::array_const_iterator it = groups_array.beginArray(); it != groups_array.endArray(); ++it) + { + const LLSD& group_info = *it; + LLAvatarData::LLGroupData group_data; + group_data.group_powers = 0; // Not in use? + group_data.group_title = group_info["name"].asString(); // Missing data, not in use? + group_data.group_id = group_info["id"].asUUID(); + group_data.group_name = group_info["name"].asString(); + group_data.group_insignia_id = group_info["image_id"].asUUID(); + + avatar_data.group_list.push_back(group_data); + } + getInstance()->notifyObservers(avatar_id, &avatar_data, type); } else if (type == APT_PICKS) @@ -371,39 +381,6 @@ void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_ur getInstance()->notifyObservers(avatar_id, &avatar_picks, type); } - else if (type == APT_GROUPS) - { - LLAvatarGroups avatar_groups; - - avatar_groups.agent_id = gAgentID; // Not in use? - avatar_groups.avatar_id = avatar_id; // target_id - - LLSD groups_array = result["groups"]; - for (LLSD::array_const_iterator it = groups_array.beginArray(); it != groups_array.endArray(); ++it) - { - const LLSD& group_info = *it; - LLAvatarGroups::LLGroupData group_data; - group_data.group_powers = 0; // Not in use? - group_data.group_title = group_info["name"].asString(); // Missing data, not in use? - group_data.group_id = group_info["id"].asUUID(); - group_data.group_name = group_info["name"].asString(); - group_data.group_insignia_id = group_info["image_id"].asUUID(); - - avatar_groups.group_list.push_back(group_data); - } - - getInstance()->notifyObservers(avatar_id, &avatar_groups, type); - } - else if (type == APT_NOTES) - { - LLAvatarNotes avatar_notes; - - avatar_notes.agent_id = gAgentID; - avatar_notes.target_id = avatar_id; - avatar_notes.notes = result["notes"].asString(); - - getInstance()->notifyObservers(avatar_id, &avatar_notes, type); - } } void LLAvatarPropertiesProcessor::processAvatarPropertiesReply(LLMessageSystem* msg, void**) @@ -443,33 +420,6 @@ void LLAvatarPropertiesProcessor::processAvatarPropertiesReply(LLMessageSystem* self->notifyObservers(avatar_data.avatar_id, &avatar_data, APT_PROPERTIES_LEGACY); } -void LLAvatarPropertiesProcessor::processAvatarInterestsReply(LLMessageSystem* msg, void**) -{ -/* - AvatarInterestsReply is automatically sent by the server in response to the - AvatarPropertiesRequest sent when the panel is opened (in addition to the AvatarPropertiesReply message). - If the interests panel is no longer part of the design (?) we should just register the message - to a handler function that does nothing. - That will suppress the warnings and be compatible with old server versions. - WARNING: LLTemplateMessageReader::decodeData: Message from 216.82.37.237:13000 with no handler function received: AvatarInterestsReply -*/ - - LLInterestsData interests_data; - - msg->getUUIDFast( _PREHASH_AgentData, _PREHASH_AgentID, interests_data.agent_id ); - msg->getUUIDFast( _PREHASH_AgentData, _PREHASH_AvatarID, interests_data.avatar_id ); - msg->getU32Fast( _PREHASH_PropertiesData, _PREHASH_WantToMask, interests_data.want_to_mask ); - msg->getStringFast( _PREHASH_PropertiesData, _PREHASH_WantToText, interests_data.want_to_text ); - msg->getU32Fast( _PREHASH_PropertiesData, _PREHASH_SkillsMask, interests_data.skills_mask ); - msg->getStringFast( _PREHASH_PropertiesData, _PREHASH_SkillsText, interests_data.skills_text ); - msg->getString( _PREHASH_PropertiesData, _PREHASH_LanguagesText, interests_data.languages_text ); - - LLAvatarPropertiesProcessor* self = getInstance(); - // Request processed, no longer pending - self->removePendingRequest(interests_data.avatar_id, APT_INTERESTS_INFO); - self->notifyObservers(interests_data.avatar_id, &interests_data, APT_INTERESTS_INFO); -} - void LLAvatarPropertiesProcessor::processAvatarClassifiedsReply(LLMessageSystem* msg, void**) { LLAvatarClassifieds classifieds; @@ -523,21 +473,6 @@ void LLAvatarPropertiesProcessor::processClassifiedInfoReply(LLMessageSystem* ms self->notifyObservers(c_info.creator_id, &c_info, APT_CLASSIFIED_INFO); } - -void LLAvatarPropertiesProcessor::processAvatarNotesReply(LLMessageSystem* msg, void**) -{ - LLAvatarNotes avatar_notes; - - msg->getUUID(_PREHASH_AgentData, _PREHASH_AgentID, avatar_notes.agent_id); - msg->getUUID(_PREHASH_Data, _PREHASH_TargetID, avatar_notes.target_id); - msg->getString(_PREHASH_Data, _PREHASH_Notes, avatar_notes.notes); - - LLAvatarPropertiesProcessor* self = getInstance(); - // Request processed, no longer pending - self->removePendingRequest(avatar_notes.target_id, APT_NOTES); - self->notifyObservers(avatar_notes.target_id,&avatar_notes,APT_NOTES); -} - void LLAvatarPropertiesProcessor::processAvatarPicksReply(LLMessageSystem* msg, void**) { LLAvatarPicks avatar_picks; @@ -591,31 +526,6 @@ void LLAvatarPropertiesProcessor::processPickInfoReply(LLMessageSystem* msg, voi self->notifyObservers(pick_data.creator_id, &pick_data, APT_PICK_INFO); } -void LLAvatarPropertiesProcessor::processAvatarGroupsReply(LLMessageSystem* msg, void**) -{ - LLAvatarGroups avatar_groups; - msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, avatar_groups.agent_id ); - msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AvatarID, avatar_groups.avatar_id ); - - S32 group_count = msg->getNumberOfBlocksFast(_PREHASH_GroupData); - for(S32 i = 0; i < group_count; ++i) - { - LLAvatarGroups::LLGroupData group_data; - - msg->getU64( _PREHASH_GroupData, _PREHASH_GroupPowers, group_data.group_powers, i ); - msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupTitle, group_data.group_title, i ); - msg->getUUIDFast( _PREHASH_GroupData, _PREHASH_GroupID, group_data.group_id, i); - msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupName, group_data.group_name, i ); - msg->getUUIDFast( _PREHASH_GroupData, _PREHASH_GroupInsigniaID, group_data.group_insignia_id, i ); - - avatar_groups.group_list.emplace_back(group_data); - } - - LLAvatarPropertiesProcessor* self = getInstance(); - self->removePendingRequest(avatar_groups.avatar_id, APT_GROUPS); - self->notifyObservers(avatar_groups.avatar_id,&avatar_groups,APT_GROUPS); -} - void LLAvatarPropertiesProcessor::notifyObservers(const LLUUID& id, void* data, EAvatarProcessorType type) { // Copy the map (because observers may delete themselves when updated?) @@ -652,27 +562,6 @@ void LLAvatarPropertiesProcessor::sendFriendRights(const LLUUID& avatar_id, S32 } } -void LLAvatarPropertiesProcessor::sendNotes(const LLUUID& avatar_id, const std::string notes) -{ - if(!avatar_id.isNull()) - { - LLMessageSystem* msg = gMessageSystem; - - // setup message header - msg->newMessageFast(_PREHASH_AvatarNotesUpdate); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUID(_PREHASH_AgentID, gAgentID); - msg->addUUID(_PREHASH_SessionID, gAgentSessionID); - - msg->nextBlockFast(_PREHASH_Data); - msg->addUUID(_PREHASH_TargetID, avatar_id); - msg->addString(_PREHASH_Notes, notes); - - gAgent.sendReliableMessage(); - } -} - - void LLAvatarPropertiesProcessor::sendPickDelete( const LLUUID& pick_id ) { LLMessageSystem* msg = gMessageSystem; @@ -704,27 +593,6 @@ void LLAvatarPropertiesProcessor::sendClassifiedDelete(const LLUUID& classified_ gAgent.sendReliableMessage(); } -void LLAvatarPropertiesProcessor::sendInterestsInfoUpdate(const LLInterestsData* interests_data) -{ - if(!interests_data) - return; - - LLMessageSystem* msg = gMessageSystem; - - msg->newMessage(_PREHASH_AvatarInterestsUpdate); - msg->nextBlockFast( _PREHASH_AgentData); - msg->addUUIDFast( _PREHASH_AgentID, gAgentID ); - msg->addUUIDFast( _PREHASH_SessionID, gAgentSessionID ); - msg->nextBlockFast( _PREHASH_PropertiesData); - msg->addU32Fast( _PREHASH_WantToMask, interests_data->want_to_mask); - msg->addStringFast( _PREHASH_WantToText, interests_data->want_to_text); - msg->addU32Fast( _PREHASH_SkillsMask, interests_data->skills_mask); - msg->addStringFast( _PREHASH_SkillsText, interests_data->skills_text); - msg->addString( _PREHASH_LanguagesText, interests_data->languages_text); - - gAgent.sendReliableMessage(); -} - void LLAvatarPropertiesProcessor::sendPickInfoUpdate(const LLPickData* new_pick) { if (!new_pick) diff --git a/indra/newview/llavatarpropertiesprocessor.h b/indra/newview/llavatarpropertiesprocessor.h index 330a5591b5..2bf8e879bd 100644 --- a/indra/newview/llavatarpropertiesprocessor.h +++ b/indra/newview/llavatarpropertiesprocessor.h @@ -50,45 +50,68 @@ class LLMessageSystem; enum EAvatarProcessorType { - APT_PROPERTIES_LEGACY, // APT_PROPERTIES via udp request + APT_PROPERTIES_LEGACY, // APT_PROPERTIES via udp request (Truncates data!!!) APT_PROPERTIES, // APT_PROPERTIES via http request - APT_NOTES, - APT_GROUPS, APT_PICKS, APT_PICK_INFO, APT_TEXTURES, - APT_INTERESTS_INFO, APT_CLASSIFIEDS, APT_CLASSIFIED_INFO }; -struct LLInterestsData +// legacy data is supposed to match AvatarPropertiesReply, +// but it is obsolete, fields like about_text will truncate +// data, if you need them, use AgenProfile cap. +// Todo: remove it once once icon ids get moved elsewhere, +// since AgentProfile is too large for bulk icon requests +struct LLAvatarLegacyData { - LLUUID agent_id; - LLUUID avatar_id; //target id - U32 want_to_mask; - std::string want_to_text; - U32 skills_mask; - std::string skills_text; - std::string languages_text; + LLUUID agent_id; + LLUUID avatar_id; //target id + LLUUID image_id; + LLUUID fl_image_id; + LLUUID partner_id; + std::string about_text; + std::string fl_about_text; + LLDate born_on; + std::string profile_url; + U8 caption_index; + std::string caption_text; + std::string customer_type; + U32 flags; }; struct LLAvatarData { - LLUUID agent_id; - LLUUID avatar_id; //target id - LLUUID image_id; - LLUUID fl_image_id; - LLUUID partner_id; - std::string about_text; - std::string fl_about_text; - LLDate born_on; - std::string profile_url; - U8 caption_index; - std::string caption_text; - std::string customer_type; - U32 flags; - bool hide_age; + LLUUID agent_id; + LLUUID avatar_id; //target id + LLUUID image_id; + LLUUID fl_image_id; + LLUUID partner_id; + std::string about_text; + std::string fl_about_text; + LLDate born_on; + std::string profile_url; + U8 caption_index; + std::string caption_text; + std::string customer_type; + U32 flags; + bool hide_age; + std::string notes; + + struct LLGroupData; + typedef std::list group_list_t; + group_list_t group_list; +}; + +struct LLAvatarData::LLGroupData +{ + U64 group_powers; + BOOL accept_notices; + std::string group_title; + LLUUID group_id; + std::string group_name; + LLUUID group_insignia_id; }; struct LLAvatarPicks @@ -122,36 +145,6 @@ struct LLPickData //used only in write (update) requests LLUUID session_id; - -}; - -struct LLAvatarNotes -{ - LLUUID agent_id; - LLUUID target_id; //target id - std::string notes; -}; - -struct LLAvatarGroups -{ - LLUUID agent_id; - LLUUID avatar_id; //target id - BOOL list_in_profile; - - struct LLGroupData; - typedef std::list group_list_t; - - group_list_t group_list; - - struct LLGroupData - { - U64 group_powers; - BOOL accept_notices; - std::string group_title; - LLUUID group_id; - std::string group_name; - LLUUID group_insignia_id; - }; }; struct LLAvatarClassifieds @@ -211,10 +204,9 @@ public: // Request various types of avatar data. Duplicate requests will be // suppressed while waiting for a response from the network. - void sendAvatarPropertiesRequest(const LLUUID& avatar_id, bool use_cap = false); + void sendAvatarPropertiesRequest(const LLUUID& avatar_id); + void sendAvatarLegacyPropertiesRequest(const LLUUID& avatar_id); void sendAvatarPicksRequest(const LLUUID& avatar_id); - void sendAvatarNotesRequest(const LLUUID& avatar_id); - void sendAvatarGroupsRequest(const LLUUID& avatar_id); void sendAvatarTexturesRequest(const LLUUID& avatar_id); void sendAvatarClassifiedsRequest(const LLUUID& avatar_id); @@ -229,14 +221,10 @@ public: void sendFriendRights(const LLUUID& avatar_id, S32 rights); - void sendNotes(const LLUUID& avatar_id, const std::string notes); - void sendPickDelete(const LLUUID& pick_id); void sendClassifiedDelete(const LLUUID& classified_id); - void sendInterestsInfoUpdate(const LLInterestsData* interests_data); - // Returns translated, human readable string for account type, such // as "Resident" or "Linden Employee". Used for profiles, inspectors. static std::string accountType(const LLAvatarData* avatar_data); @@ -252,16 +240,10 @@ public: static void processAvatarPropertiesReply(LLMessageSystem* msg, void**); - static void processAvatarInterestsReply(LLMessageSystem* msg, void**); - static void processAvatarClassifiedsReply(LLMessageSystem* msg, void**); static void processClassifiedInfoReply(LLMessageSystem* msg, void**); - static void processAvatarGroupsReply(LLMessageSystem* msg, void**); - - static void processAvatarNotesReply(LLMessageSystem* msg, void**); - static void processAvatarPicksReply(LLMessageSystem* msg, void**); static void processPickInfoReply(LLMessageSystem* msg, void**); diff --git a/indra/newview/llfloaterbuycurrency.cpp b/indra/newview/llfloaterbuycurrency.cpp index b0e63d5844..0cfac166c7 100644 --- a/indra/newview/llfloaterbuycurrency.cpp +++ b/indra/newview/llfloaterbuycurrency.cpp @@ -354,7 +354,7 @@ LLFetchAvatarPaymentInfo::~LLFetchAvatarPaymentInfo() void LLFetchAvatarPaymentInfo::processProperties(void* data, EAvatarProcessorType type) { - if (data && type == APT_PROPERTIES_LEGACY) + if (data && type == APT_PROPERTIES) { LLAvatarData* avatar_data = static_cast(data); LLFloaterBuyCurrency::handleBuyCurrency(LLAvatarPropertiesProcessor::hasPaymentInfoOnFile(avatar_data), mHasTarget, mName, mPrice); diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 1f5eb5fdff..ba61668d26 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -332,7 +332,7 @@ void LLFloaterPreference::processProperties( void* pData, EAvatarProcessorType t { if ( APT_PROPERTIES_LEGACY == type ) { - const LLAvatarData* pAvatarData = static_cast( pData ); + const LLAvatarLegacyData* pAvatarData = static_cast( pData ); if (pAvatarData && (gAgent.getID() == pAvatarData->avatar_id) && (pAvatarData->avatar_id != LLUUID::null)) { mAllowPublish = (bool)(pAvatarData->flags & AVATAR_ALLOW_PUBLISH); @@ -662,7 +662,7 @@ void LLFloaterPreference::onOpen(const LLSD& key) (gAgent.isMature() || gAgent.isGodlike()); LLComboBox* maturity_combo = getChild("maturity_desired_combobox"); - LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest( gAgent.getID() ); + LLAvatarPropertiesProcessor::getInstance()->sendAvatarLegacyPropertiesRequest( gAgent.getID() ); if (can_choose_maturity) { // if they're not adult or a god, they shouldn't see the adult selection, so delete it diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp index 4d003989fc..ca18dc343d 100644 --- a/indra/newview/llinspectavatar.cpp +++ b/indra/newview/llinspectavatar.cpp @@ -124,7 +124,7 @@ public: processor->addObserver(mAvatarID, this); // send a request (duplicates will be suppressed inside the avatar // properties processor) - processor->sendAvatarPropertiesRequest(mAvatarID, true); + processor->sendAvatarPropertiesRequest(mAvatarID); } ~LLFetchAvatarData() diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index a7a1f05c8a..ba5f6e2e09 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -159,6 +159,7 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) avatar_data->born_on = result["member_since"].asDate(); avatar_data->profile_url = getProfileURL(agent_id.asString()); avatar_data->customer_type = result["customer_type"].asString(); + avatar_data->notes = result["notes"].asString(); avatar_data->flags = 0; @@ -195,6 +196,21 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) result["hide_age"].asBoolean() : // Server option value provided by resident !panel_profile->getSelfProfile(); // Fallback temporary value (to be removed) + // Groups + LLSD groups_array = result["groups"]; + for (LLSD::array_const_iterator it = groups_array.beginArray(); it != groups_array.endArray(); ++it) + { + const LLSD& group_info = *it; + LLAvatarData::LLGroupData group_data; + group_data.group_powers = 0; // Not in use? + group_data.group_title = group_info["name"].asString(); // Missing data, not in use? + group_data.group_id = group_info["id"].asUUID(); + group_data.group_name = group_info["name"].asString(); + group_data.group_insignia_id = group_info["image_id"].asUUID(); + + avatar_data->group_list.push_back(group_data); + } + panel = floater_profile->findChild(PANEL_SECONDLIFE, TRUE); LLPanelProfileSecondLife *panel_sl = dynamic_cast(panel); if (panel_sl) @@ -216,6 +232,13 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) panel_first->processProperties(avatar_data); } + panel = floater_profile->findChild(PANEL_NOTES, TRUE); + LLPanelProfileNotes* panel_notes = dynamic_cast(panel); + if (panel_notes) + { + panel_notes->processProperties(avatar_data); + } + // Picks LLSD picks_array = result["picks"]; LLAvatarPicks avatar_picks; @@ -236,44 +259,6 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) LLAgentPicksInfo::getInstance()->onServerRespond(&avatar_picks); panel_picks->processProperties(&avatar_picks); } - - // Groups - LLSD groups_array = result["groups"]; - LLAvatarGroups avatar_groups; - avatar_groups.agent_id = agent_id; // Not in use? - avatar_groups.avatar_id = agent_id; // target_id - - for (LLSD::array_const_iterator it = groups_array.beginArray(); it != groups_array.endArray(); ++it) - { - const LLSD& group_info = *it; - LLAvatarGroups::LLGroupData group_data; - group_data.group_powers = 0; // Not in use? - group_data.group_title = group_info["name"].asString(); // Missing data, not in use? - group_data.group_id = group_info["id"].asUUID(); - group_data.group_name = group_info["name"].asString(); - group_data.group_insignia_id = group_info["image_id"].asUUID(); - - avatar_groups.group_list.push_back(group_data); - } - - if (panel_sl) - { - panel_sl->processGroupProperties(&avatar_groups); - } - - // Notes - LLAvatarNotes avatar_notes; - - avatar_notes.agent_id = agent_id; - avatar_notes.target_id = agent_id; - avatar_notes.notes = result["notes"].asString(); - - panel = floater_profile->findChild(PANEL_NOTES, TRUE); - LLPanelProfileNotes *panel_notes = dynamic_cast(panel); - if (panel_notes) - { - panel_notes->processProperties(&avatar_notes); - } } LLUUID post_profile_image(std::string cap_url, const LLSD &first_data, std::string path_to_image, LLHandle *handle) @@ -1052,21 +1037,18 @@ void LLPanelProfileSecondLife::processProfileProperties(const LLAvatarData* avat fillAccountStatus(avatar_data); - setLoaded(); -} - -void LLPanelProfileSecondLife::processGroupProperties(const LLAvatarGroups* avatar_groups) -{ - LLAvatarGroups::group_list_t::const_iterator it = avatar_groups->group_list.begin(); - const LLAvatarGroups::group_list_t::const_iterator it_end = avatar_groups->group_list.end(); + LLAvatarData::group_list_t::const_iterator it = avatar_data->group_list.begin(); + const LLAvatarData::group_list_t::const_iterator it_end = avatar_data->group_list.end(); for (; it_end != it; ++it) { - LLAvatarGroups::LLGroupData group_data = *it; + LLAvatarData::LLGroupData group_data = *it; mGroups[group_data.group_name] = group_data.group_id; } mGroupList->setGroups(mGroups); + + setLoaded(); } void LLPanelProfileSecondLife::openGroupProfile() @@ -2483,9 +2465,9 @@ void LLPanelProfileNotes::onDiscardNotesChanges() setNotesText(mCurrentNotes); } -void LLPanelProfileNotes::processProperties(LLAvatarNotes* avatar_notes) +void LLPanelProfileNotes::processProperties(const LLAvatarData* avatar_data) { - setNotesText(avatar_notes->notes); + setNotesText(avatar_data->notes); mNotesEditor->setEnabled(TRUE); setLoaded(); } diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h index f4b618eb27..178c413659 100644 --- a/indra/newview/llpanelprofile.h +++ b/indra/newview/llpanelprofile.h @@ -115,11 +115,6 @@ protected: */ void processProfileProperties(const LLAvatarData* avatar_data); - /** - * Processes group related data received from server. - */ - void processGroupProperties(const LLAvatarGroups* avatar_groups); - /** * Fills common for Avatar profile and My Profile fields. */ @@ -335,7 +330,7 @@ public: BOOL postBuild() override; - void processProperties(LLAvatarNotes* avatar_notes); + void processProperties(const LLAvatarData* avatar_data); void resetData() override; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 228483d42b..cccd16a77e 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2657,15 +2657,6 @@ void register_viewer_callbacks(LLMessageSystem* msg) msg->setHandlerFunc("AvatarPropertiesReply", &LLAvatarPropertiesProcessor::processAvatarPropertiesReply); - msg->setHandlerFunc("AvatarInterestsReply", - &LLAvatarPropertiesProcessor::processAvatarInterestsReply); - msg->setHandlerFunc("AvatarGroupsReply", - &LLAvatarPropertiesProcessor::processAvatarGroupsReply); - // ratings deprecated - //msg->setHandlerFuncFast(_PREHASH_AvatarStatisticsReply, - // LLPanelAvatar::processAvatarStatisticsReply); - msg->setHandlerFunc("AvatarNotesReply", - &LLAvatarPropertiesProcessor::processAvatarNotesReply); msg->setHandlerFunc("AvatarPicksReply", &LLAvatarPropertiesProcessor::processAvatarPicksReply); msg->setHandlerFunc("AvatarClassifiedReply", -- cgit v1.3 From f54d0329f32081883704cc2694871600f896006b Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 24 Oct 2023 00:14:21 +0300 Subject: SL-20513 Cleanup LLAvatarPropertiesProcessor #2 --- indra/newview/llagentpicksinfo.cpp | 12 +- indra/newview/llagentpicksinfo.h | 4 +- indra/newview/llavatarpropertiesprocessor.cpp | 183 ++++++++++---------------- indra/newview/llavatarpropertiesprocessor.h | 21 +-- indra/newview/llpanelprofile.cpp | 25 ++-- indra/newview/llpanelprofilepicks.cpp | 12 +- indra/newview/llpanelprofilepicks.h | 2 +- indra/newview/llstartup.cpp | 4 +- 8 files changed, 105 insertions(+), 158 deletions(-) (limited to 'indra/newview/llpanelprofile.cpp') diff --git a/indra/newview/llagentpicksinfo.cpp b/indra/newview/llagentpicksinfo.cpp index 799060eeab..0b72f1ee4d 100644 --- a/indra/newview/llagentpicksinfo.cpp +++ b/indra/newview/llagentpicksinfo.cpp @@ -49,10 +49,10 @@ public: void sendAgentPicksRequest() { - LLAvatarPropertiesProcessor::getInstance()->sendAvatarPicksRequest(gAgent.getID()); + LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(gAgent.getID()); } - typedef boost::function server_respond_callback_t; + typedef boost::function server_respond_callback_t; void setServerRespondCallback(const server_respond_callback_t& cb) { @@ -61,10 +61,10 @@ public: virtual void processProperties(void* data, EAvatarProcessorType type) { - if(APT_PICKS == type) + if(APT_PROPERTIES == type) { - LLAvatarPicks* picks = static_cast(data); - if(picks && gAgent.getID() == picks->target_id) + LLAvatarData* picks = static_cast(data); + if(picks && gAgent.getID() == picks->avatar_id) { if(mServerRespondCallback) { @@ -115,7 +115,7 @@ bool LLAgentPicksInfo::isPickLimitReached() return getNumberOfPicks() >= getMaxNumberOfPicks(); } -void LLAgentPicksInfo::onServerRespond(LLAvatarPicks* picks) +void LLAgentPicksInfo::onServerRespond(LLAvatarData* picks) { if(!picks) { diff --git a/indra/newview/llagentpicksinfo.h b/indra/newview/llagentpicksinfo.h index 21df036cb7..56e7bd0775 100644 --- a/indra/newview/llagentpicksinfo.h +++ b/indra/newview/llagentpicksinfo.h @@ -29,7 +29,7 @@ #include "llsingleton.h" -struct LLAvatarPicks; +struct LLAvatarData; /** * Class that provides information about Agent Picks @@ -74,7 +74,7 @@ public: void decrementNumberOfPicks() { --mNumberOfPicks; } - void onServerRespond(LLAvatarPicks* picks); + void onServerRespond(LLAvatarData* picks); private: diff --git a/indra/newview/llavatarpropertiesprocessor.cpp b/indra/newview/llavatarpropertiesprocessor.cpp index 472cf8b8d5..5b28e9f4c6 100644 --- a/indra/newview/llavatarpropertiesprocessor.cpp +++ b/indra/newview/llavatarpropertiesprocessor.cpp @@ -115,20 +115,19 @@ void LLAvatarPropertiesProcessor::sendRequest(const LLUUID& avatar_id, EAvatarPr } // Try to send HTTP request if cap_url is available - if (type == APT_PROPERTIES || type == APT_PICKS) + if (type == APT_PROPERTIES) { - if (std::string cap_url(gAgent.getRegionCapability("AgentProfile")); !cap_url.empty()) + std::string cap_url = gAgent.getRegionCapability("AgentProfile"); + if (!cap_url.empty()) { initAgentProfileCapRequest(avatar_id, cap_url, type); - return; } - - // Don't sent UDP request for APT_PROPERTIES - if (type == APT_PROPERTIES) + else { - LL_WARNS() << "No cap_url for APT_PROPERTIES, request is not sent" << LL_ENDL; - return; + // Don't sent UDP request for APT_PROPERTIES + LL_WARNS() << "No cap_url for APT_PROPERTIES, request for " << avatar_id << " is not sent" << LL_ENDL; } + return; } // Send UDP request @@ -182,11 +181,6 @@ void LLAvatarPropertiesProcessor::sendAvatarLegacyPropertiesRequest(const LLUUID sendRequest(avatar_id, APT_PROPERTIES_LEGACY, "AvatarPropertiesRequest"); } -void LLAvatarPropertiesProcessor::sendAvatarPicksRequest(const LLUUID& avatar_id) -{ - sendGenericRequest(avatar_id, APT_PICKS, "avatarpicksrequest"); -} - void LLAvatarPropertiesProcessor::sendAvatarTexturesRequest(const LLUUID& avatar_id) { sendGenericRequest(avatar_id, APT_TEXTURES, "avatartexturesrequest"); @@ -300,90 +294,80 @@ void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_ur return; } - if (type == APT_PROPERTIES) + LLAvatarData avatar_data; + + std::string birth_date; + + avatar_data.agent_id = gAgentID; + avatar_data.avatar_id = avatar_id; + avatar_data.image_id = result["sl_image_id"].asUUID(); + avatar_data.fl_image_id = result["fl_image_id"].asUUID(); + avatar_data.partner_id = result["partner_id"].asUUID(); + avatar_data.about_text = result["sl_about_text"].asString(); + avatar_data.fl_about_text = result["fl_about_text"].asString(); + avatar_data.born_on = result["member_since"].asDate(); + // TODO: SL-20163 Remove the "has" check when SRV-684 is done + // and the field "hide_age" is included to the http response + avatar_data.hide_age = !result.has("hide_age") || result["hide_age"].asBoolean(); + avatar_data.profile_url = getProfileURL(avatar_id.asString()); + avatar_data.customer_type = result["customer_type"].asString(); + avatar_data.notes = result["notes"].asString(); + + avatar_data.flags = 0; + if (result["online"].asBoolean()) { - LLAvatarData avatar_data; - - std::string birth_date; - - avatar_data.agent_id = gAgentID; - avatar_data.avatar_id = avatar_id; - avatar_data.image_id = result["sl_image_id"].asUUID(); - avatar_data.fl_image_id = result["fl_image_id"].asUUID(); - avatar_data.partner_id = result["partner_id"].asUUID(); - avatar_data.about_text = result["sl_about_text"].asString(); - avatar_data.fl_about_text = result["fl_about_text"].asString(); - avatar_data.born_on = result["member_since"].asDate(); - // TODO: SL-20163 Remove the "has" check when SRV-684 is done - // and the field "hide_age" is included to the http response - avatar_data.hide_age = !result.has("hide_age") || result["hide_age"].asBoolean(); - avatar_data.profile_url = getProfileURL(avatar_id.asString()); - avatar_data.customer_type = result["customer_type"].asString(); - avatar_data.notes = result["notes"].asString(); - - avatar_data.flags = 0; - if (result["online"].asBoolean()) - { - avatar_data.flags |= AVATAR_ONLINE; - } - if (result["allow_publish"].asBoolean()) - { - avatar_data.flags |= AVATAR_ALLOW_PUBLISH; - } - if (result["identified"].asBoolean()) - { - avatar_data.flags |= AVATAR_IDENTIFIED; - } - if (result["transacted"].asBoolean()) - { - avatar_data.flags |= AVATAR_TRANSACTED; - } - - avatar_data.caption_index = 0; - if (result.has("charter_member")) // won't be present if "caption" is set - { - avatar_data.caption_index = result["charter_member"].asInteger(); - } - else if (result.has("caption")) - { - avatar_data.caption_text = result["caption"].asString(); - } - - LLSD groups_array = result["groups"]; - for (LLSD::array_const_iterator it = groups_array.beginArray(); it != groups_array.endArray(); ++it) - { - const LLSD& group_info = *it; - LLAvatarData::LLGroupData group_data; - group_data.group_powers = 0; // Not in use? - group_data.group_title = group_info["name"].asString(); // Missing data, not in use? - group_data.group_id = group_info["id"].asUUID(); - group_data.group_name = group_info["name"].asString(); - group_data.group_insignia_id = group_info["image_id"].asUUID(); - - avatar_data.group_list.push_back(group_data); - } - - getInstance()->notifyObservers(avatar_id, &avatar_data, type); + avatar_data.flags |= AVATAR_ONLINE; + } + if (result["allow_publish"].asBoolean()) + { + avatar_data.flags |= AVATAR_ALLOW_PUBLISH; + } + if (result["identified"].asBoolean()) + { + avatar_data.flags |= AVATAR_IDENTIFIED; } - else if (type == APT_PICKS) + if (result["transacted"].asBoolean()) { - LLAvatarPicks avatar_picks; + avatar_data.flags |= AVATAR_TRANSACTED; + } - avatar_picks.agent_id = gAgentID; // Not in use? - avatar_picks.target_id = avatar_id; + avatar_data.caption_index = 0; + if (result.has("charter_member")) // won't be present if "caption" is set + { + avatar_data.caption_index = result["charter_member"].asInteger(); + } + else if (result.has("caption")) + { + avatar_data.caption_text = result["caption"].asString(); + } - LLSD picks_array = result["picks"]; - for (LLSD::array_const_iterator it = picks_array.beginArray(); it != picks_array.endArray(); ++it) - { - const LLSD& pick_data = *it; - avatar_picks.picks_list.emplace_back(pick_data["id"].asUUID(), pick_data["name"].asString()); - } + // Groups + LLSD groups_array = result["groups"]; + for (LLSD::array_const_iterator it = groups_array.beginArray(); it != groups_array.endArray(); ++it) + { + const LLSD& group_info = *it; + LLAvatarData::LLGroupData group_data; + group_data.group_powers = 0; // Not in use? + group_data.group_title = group_info["name"].asString(); // Missing data, not in use? + group_data.group_id = group_info["id"].asUUID(); + group_data.group_name = group_info["name"].asString(); + group_data.group_insignia_id = group_info["image_id"].asUUID(); + + avatar_data.group_list.push_back(group_data); + } - getInstance()->notifyObservers(avatar_id, &avatar_picks, type); + // Picks + LLSD picks_array = result["picks"]; + for (LLSD::array_const_iterator it = picks_array.beginArray(); it != picks_array.endArray(); ++it) + { + const LLSD& pick_data = *it; + avatar_data.picks_list.emplace_back(pick_data["id"].asUUID(), pick_data["name"].asString()); } + + getInstance()->notifyObservers(avatar_id, &avatar_data, type); } -void LLAvatarPropertiesProcessor::processAvatarPropertiesReply(LLMessageSystem* msg, void**) +void LLAvatarPropertiesProcessor::processAvatarLegacyPropertiesReply(LLMessageSystem* msg, void**) { LLAvatarData avatar_data; std::string birth_date; @@ -473,29 +457,6 @@ void LLAvatarPropertiesProcessor::processClassifiedInfoReply(LLMessageSystem* ms self->notifyObservers(c_info.creator_id, &c_info, APT_CLASSIFIED_INFO); } -void LLAvatarPropertiesProcessor::processAvatarPicksReply(LLMessageSystem* msg, void**) -{ - LLAvatarPicks avatar_picks; - msg->getUUID(_PREHASH_AgentData, _PREHASH_AgentID, avatar_picks.agent_id); - msg->getUUID(_PREHASH_AgentData, _PREHASH_TargetID, avatar_picks.target_id); - - S32 block_count = msg->getNumberOfBlocks(_PREHASH_Data); - for (int block = 0; block < block_count; ++block) - { - LLUUID pick_id; - std::string pick_name; - - msg->getUUID(_PREHASH_Data, _PREHASH_PickID, pick_id, block); - msg->getString(_PREHASH_Data, _PREHASH_PickName, pick_name, block); - - avatar_picks.picks_list.emplace_back(pick_id, pick_name); - } - LLAvatarPropertiesProcessor* self = getInstance(); - // Request processed, no longer pending - self->removePendingRequest(avatar_picks.target_id, APT_PICKS); - self->notifyObservers(avatar_picks.target_id,&avatar_picks,APT_PICKS); -} - void LLAvatarPropertiesProcessor::processPickInfoReply(LLMessageSystem* msg, void**) { LLPickData pick_data; diff --git a/indra/newview/llavatarpropertiesprocessor.h b/indra/newview/llavatarpropertiesprocessor.h index 2bf8e879bd..1bf07704a9 100644 --- a/indra/newview/llavatarpropertiesprocessor.h +++ b/indra/newview/llavatarpropertiesprocessor.h @@ -52,7 +52,6 @@ enum EAvatarProcessorType { APT_PROPERTIES_LEGACY, // APT_PROPERTIES via udp request (Truncates data!!!) APT_PROPERTIES, // APT_PROPERTIES via http request - APT_PICKS, APT_PICK_INFO, APT_TEXTURES, APT_CLASSIFIEDS, @@ -102,6 +101,10 @@ struct LLAvatarData struct LLGroupData; typedef std::list group_list_t; group_list_t group_list; + + typedef std::pair pick_data_t; + typedef std::list< pick_data_t> picks_list_t; + picks_list_t picks_list; }; struct LLAvatarData::LLGroupData @@ -114,16 +117,6 @@ struct LLAvatarData::LLGroupData LLUUID group_insignia_id; }; -struct LLAvatarPicks -{ - LLUUID agent_id; - LLUUID target_id; //target id - - typedef std::pair pick_data_t; - typedef std::list< pick_data_t> picks_list_t; - picks_list_t picks_list; -}; - struct LLPickData { LLUUID agent_id; @@ -206,7 +199,6 @@ public: // suppressed while waiting for a response from the network. void sendAvatarPropertiesRequest(const LLUUID& avatar_id); void sendAvatarLegacyPropertiesRequest(const LLUUID& avatar_id); - void sendAvatarPicksRequest(const LLUUID& avatar_id); void sendAvatarTexturesRequest(const LLUUID& avatar_id); void sendAvatarClassifiedsRequest(const LLUUID& avatar_id); @@ -238,14 +230,13 @@ public: static void requestAvatarPropertiesCoro(std::string cap_url, LLUUID avatar_id, EAvatarProcessorType type); - static void processAvatarPropertiesReply(LLMessageSystem* msg, void**); + // Processing of UDP variant of properties, truncates certain fields! + static void processAvatarLegacyPropertiesReply(LLMessageSystem* msg, void**); static void processAvatarClassifiedsReply(LLMessageSystem* msg, void**); static void processClassifiedInfoReply(LLMessageSystem* msg, void**); - static void processAvatarPicksReply(LLMessageSystem* msg, void**); - static void processPickInfoReply(LLMessageSystem* msg, void**); protected: diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index ba5f6e2e09..7cd58ff6f4 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -211,6 +211,15 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) avatar_data->group_list.push_back(group_data); } + // Picks + LLSD picks_array = result["picks"]; + + for (LLSD::array_const_iterator it = picks_array.beginArray(); it != picks_array.endArray(); ++it) + { + const LLSD& pick_data = *it; + avatar_data->picks_list.emplace_back(pick_data["id"].asUUID(), pick_data["name"].asString()); + } + panel = floater_profile->findChild(PANEL_SECONDLIFE, TRUE); LLPanelProfileSecondLife *panel_sl = dynamic_cast(panel); if (panel_sl) @@ -239,25 +248,13 @@ void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) panel_notes->processProperties(avatar_data); } - // Picks - LLSD picks_array = result["picks"]; - LLAvatarPicks avatar_picks; - avatar_picks.agent_id = agent_id; // Not in use? - avatar_picks.target_id = agent_id; - - for (LLSD::array_const_iterator it = picks_array.beginArray(); it != picks_array.endArray(); ++it) - { - const LLSD& pick_data = *it; - avatar_picks.picks_list.emplace_back(pick_data["id"].asUUID(), pick_data["name"].asString()); - } - panel = floater_profile->findChild(PANEL_PICKS, TRUE); LLPanelProfilePicks *panel_picks = dynamic_cast(panel); if (panel_picks) { // Refresh pick limit before processing - LLAgentPicksInfo::getInstance()->onServerRespond(&avatar_picks); - panel_picks->processProperties(&avatar_picks); + LLAgentPicksInfo::getInstance()->onServerRespond(avatar_data); + panel_picks->processProperties(avatar_data); } } diff --git a/indra/newview/llpanelprofilepicks.cpp b/indra/newview/llpanelprofilepicks.cpp index fa42199089..f49ed2d644 100644 --- a/indra/newview/llpanelprofilepicks.cpp +++ b/indra/newview/llpanelprofilepicks.cpp @@ -289,17 +289,17 @@ void LLPanelProfilePicks::callbackDeletePick(const LLSD& notification, const LLS void LLPanelProfilePicks::processProperties(void* data, EAvatarProcessorType type) { - if (APT_PICKS == type) + if (APT_PROPERTIES == type) { - LLAvatarPicks* avatar_picks = static_cast(data); - if (avatar_picks && getAvatarId() == avatar_picks->target_id) + LLAvatarData* avatar_picks = static_cast(data); + if (avatar_picks && getAvatarId() == avatar_picks->avatar_id) { processProperties(avatar_picks); } } } -void LLPanelProfilePicks::processProperties(const LLAvatarPicks* avatar_picks) +void LLPanelProfilePicks::processProperties(const LLAvatarData* avatar_picks) { LLUUID selected_id = mPickToSelectOnLoad; bool has_selection = false; @@ -317,7 +317,7 @@ void LLPanelProfilePicks::processProperties(const LLAvatarPicks* avatar_picks) mTabContainer->deleteAllTabs(); - LLAvatarPicks::picks_list_t::const_iterator it = avatar_picks->picks_list.begin(); + LLAvatarData::picks_list_t::const_iterator it = avatar_picks->picks_list.begin(); for (; avatar_picks->picks_list.end() != it; ++it) { LLUUID pick_id = it->first; @@ -421,7 +421,7 @@ void LLPanelProfilePicks::updateData() { setIsLoading(); - LLAvatarPropertiesProcessor::getInstance()->sendAvatarPicksRequest(avatar_id); + LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(avatar_id); } if (!getIsLoaded()) { diff --git a/indra/newview/llpanelprofilepicks.h b/indra/newview/llpanelprofilepicks.h index f84463cc9b..fc29a9de0f 100644 --- a/indra/newview/llpanelprofilepicks.h +++ b/indra/newview/llpanelprofilepicks.h @@ -58,7 +58,7 @@ public: void selectPick(const LLUUID& pick_id); void processProperties(void* data, EAvatarProcessorType type) override; - void processProperties(const LLAvatarPicks* avatar_picks); + void processProperties(const LLAvatarData* avatar_picks); void resetData() override; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index cccd16a77e..916848ff5f 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2656,9 +2656,7 @@ void register_viewer_callbacks(LLMessageSystem* msg) LLViewerParcelMgr::processParcelDwellReply); msg->setHandlerFunc("AvatarPropertiesReply", - &LLAvatarPropertiesProcessor::processAvatarPropertiesReply); - msg->setHandlerFunc("AvatarPicksReply", - &LLAvatarPropertiesProcessor::processAvatarPicksReply); + &LLAvatarPropertiesProcessor::processAvatarLegacyPropertiesReply); msg->setHandlerFunc("AvatarClassifiedReply", &LLAvatarPropertiesProcessor::processAvatarClassifiedsReply); -- cgit v1.3 From 69aa02d2e1873970302942487b96d3a6aca119e5 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 24 Oct 2023 23:02:56 +0300 Subject: SL-20513 Make profile floater use properties processor #3 --- indra/newview/llpanelavatar.cpp | 10 ++ indra/newview/llpanelavatar.h | 10 +- indra/newview/llpanelclassified.cpp | 5 + indra/newview/llpanelprofile.cpp | 258 ++++++---------------------------- indra/newview/llpanelprofile.h | 33 +---- indra/newview/llpanelprofilepicks.cpp | 4 + indra/newview/llpanelprofilepicks.h | 2 - 7 files changed, 77 insertions(+), 245 deletions(-) (limited to 'indra/newview/llpanelprofile.cpp') diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index 626978f9fb..ad8ed7c144 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -194,3 +194,13 @@ void LLPanelProfilePropertiesProcessorTab::setAvatarId(const LLUUID & avatar_id) LLAvatarPropertiesProcessor::getInstance()->addObserver(getAvatarId(), this); } } + +void LLPanelProfilePropertiesProcessorTab::updateData() +{ + LLUUID avatar_id = getAvatarId(); + if (!getStarted() && avatar_id.notNull()) + { + setIsLoading(); + LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(getAvatarId()); + } +} diff --git a/indra/newview/llpanelavatar.h b/indra/newview/llpanelavatar.h index 572e1eb029..1106c44734 100644 --- a/indra/newview/llpanelavatar.h +++ b/indra/newview/llpanelavatar.h @@ -97,12 +97,12 @@ public: /** * Sends update data request to server. */ - virtual void updateData() {}; + virtual void updateData(){}; /** * Clears panel data if viewing avatar info for first time and sends update data request. */ - virtual void onOpen(const LLSD& key); + virtual void onOpen(const LLSD& key) override; /** * Clears all data received from server. @@ -160,12 +160,14 @@ public: LLPanelProfilePropertiesProcessorTab(); ~LLPanelProfilePropertiesProcessorTab(); - /*virtual*/ void setAvatarId(const LLUUID& avatar_id); + void setAvatarId(const LLUUID& avatar_id) override; + + void updateData() override; /** * Processes data received from server via LLAvatarPropertiesObserver. */ - virtual void processProperties(void* data, EAvatarProcessorType type) = 0; + virtual void processProperties(void* data, EAvatarProcessorType type) override = 0; }; #endif // LL_LLPANELAVATAR_H diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp index 183000ceac..e926ed2b3c 100644 --- a/indra/newview/llpanelclassified.cpp +++ b/indra/newview/llpanelclassified.cpp @@ -104,6 +104,11 @@ LLPanelClassifiedInfo::LLPanelClassifiedInfo() LLPanelClassifiedInfo::~LLPanelClassifiedInfo() { sAllPanels.remove(this); + + if (getAvatarId().notNull()) + { + LLAvatarPropertiesProcessor::getInstance()->removeObserver(getAvatarId(), this); + } } BOOL LLPanelClassifiedInfo::postBuild() diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 7cd58ff6f4..eb62627278 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -102,162 +102,6 @@ static const std::string PROFILE_IMAGE_UPLOAD_CAP = "UploadAgentProfileImage"; ////////////////////////////////////////////////////////////////////////// -void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("request_avatar_properties_coro", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpHeaders::ptr_t httpHeaders; - - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - httpOpts->setFollowRedirects(true); - - std::string finalUrl = cap_url + "/" + agent_id.asString(); - - LLSD result = httpAdapter->getAndSuspend(httpRequest, finalUrl, httpOpts, httpHeaders); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - LL_DEBUGS("AvatarProperties") << "Agent id: " << agent_id << " Result: " << httpResults << LL_ENDL; - - if (!status - || !result.has("id") - || agent_id != result["id"].asUUID()) - { - LL_WARNS("AvatarProperties") << "Failed to get agent information for id " << agent_id << LL_ENDL; - return; - } - - LLFloater* floater_profile = LLFloaterReg::findInstance("profile", LLSD().with("id", agent_id)); - if (!floater_profile) - { - // floater is dead, so panels are dead as well - return; - } - - LLPanel *panel = floater_profile->findChild(PANEL_PROFILE_VIEW, TRUE); - LLPanelProfile *panel_profile = dynamic_cast(panel); - if (!panel_profile) - { - LL_WARNS() << PANEL_PROFILE_VIEW << " not found" << LL_ENDL; - return; - } - - // Avatar Data - LLAvatarData *avatar_data = &panel_profile->mAvatarData; - std::string birth_date; - - avatar_data->agent_id = agent_id; - avatar_data->avatar_id = agent_id; - avatar_data->image_id = result["sl_image_id"].asUUID(); - avatar_data->fl_image_id = result["fl_image_id"].asUUID(); - avatar_data->partner_id = result["partner_id"].asUUID(); - avatar_data->about_text = result["sl_about_text"].asString(); - avatar_data->fl_about_text = result["fl_about_text"].asString(); - avatar_data->born_on = result["member_since"].asDate(); - avatar_data->profile_url = getProfileURL(agent_id.asString()); - avatar_data->customer_type = result["customer_type"].asString(); - avatar_data->notes = result["notes"].asString(); - - avatar_data->flags = 0; - - if (result["online"].asBoolean()) - { - avatar_data->flags |= AVATAR_ONLINE; - } - if (result["allow_publish"].asBoolean()) - { - avatar_data->flags |= AVATAR_ALLOW_PUBLISH; - } - if (result["identified"].asBoolean()) - { - avatar_data->flags |= AVATAR_IDENTIFIED; - } - if (result["transacted"].asBoolean()) - { - avatar_data->flags |= AVATAR_TRANSACTED; - } - - avatar_data->caption_index = 0; - if (result.has("charter_member")) // won't be present if "caption" is set - { - avatar_data->caption_index = result["charter_member"].asInteger(); - } - else if (result.has("caption")) - { - avatar_data->caption_text = result["caption"].asString(); - } - - // TODO: SL-20163 Remove the "has" check when SRV-684 is done - // and the field "hide_age" is included to the http response - avatar_data->hide_age = result.has("hide_age") ? - result["hide_age"].asBoolean() : // Server option value provided by resident - !panel_profile->getSelfProfile(); // Fallback temporary value (to be removed) - - // Groups - LLSD groups_array = result["groups"]; - for (LLSD::array_const_iterator it = groups_array.beginArray(); it != groups_array.endArray(); ++it) - { - const LLSD& group_info = *it; - LLAvatarData::LLGroupData group_data; - group_data.group_powers = 0; // Not in use? - group_data.group_title = group_info["name"].asString(); // Missing data, not in use? - group_data.group_id = group_info["id"].asUUID(); - group_data.group_name = group_info["name"].asString(); - group_data.group_insignia_id = group_info["image_id"].asUUID(); - - avatar_data->group_list.push_back(group_data); - } - - // Picks - LLSD picks_array = result["picks"]; - - for (LLSD::array_const_iterator it = picks_array.beginArray(); it != picks_array.endArray(); ++it) - { - const LLSD& pick_data = *it; - avatar_data->picks_list.emplace_back(pick_data["id"].asUUID(), pick_data["name"].asString()); - } - - panel = floater_profile->findChild(PANEL_SECONDLIFE, TRUE); - LLPanelProfileSecondLife *panel_sl = dynamic_cast(panel); - if (panel_sl) - { - panel_sl->processProfileProperties(avatar_data); - } - - panel = floater_profile->findChild(PANEL_WEB, TRUE); - LLPanelProfileWeb *panel_web = dynamic_cast(panel); - if (panel_web) - { - panel_web->setLoaded(); - } - - panel = floater_profile->findChild(PANEL_FIRSTLIFE, TRUE); - LLPanelProfileFirstLife *panel_first = dynamic_cast(panel); - if (panel_first) - { - panel_first->processProperties(avatar_data); - } - - panel = floater_profile->findChild(PANEL_NOTES, TRUE); - LLPanelProfileNotes* panel_notes = dynamic_cast(panel); - if (panel_notes) - { - panel_notes->processProperties(avatar_data); - } - - panel = floater_profile->findChild(PANEL_PICKS, TRUE); - LLPanelProfilePicks *panel_picks = dynamic_cast(panel); - if (panel_picks) - { - // Refresh pick limit before processing - LLAgentPicksInfo::getInstance()->onServerRespond(avatar_data); - panel_picks->processProperties(avatar_data); - } -} - LLUUID post_profile_image(std::string cap_url, const LLSD &first_data, std::string path_to_image, LLHandle *handle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -835,7 +679,7 @@ void LLFloaterProfilePermissions::onCancel() // LLPanelProfileSecondLife LLPanelProfileSecondLife::LLPanelProfileSecondLife() - : LLPanelProfileTab() + : LLPanelProfilePropertiesProcessorTab() , mAvatarNameCacheConnection() , mHasUnsavedDescriptionChanges(false) , mWaitingForImageUpload(false) @@ -952,26 +796,6 @@ void LLPanelProfileSecondLife::onOpen(const LLSD& key) mAvatarNameCacheConnection = LLAvatarNameCache::get(getAvatarId(), boost::bind(&LLPanelProfileSecondLife::onAvatarNameCache, this, _1, _2)); } -void LLPanelProfileSecondLife::updateData() -{ - LLUUID avatar_id = getAvatarId(); - if (!getStarted() && avatar_id.notNull()) - { - setIsLoading(); - - std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP); - if (!cap_url.empty()) - { - LLCoros::instance().launch("requestAgentUserInfoCoro", - [cap_url, avatar_id]() { request_avatar_properties_coro(cap_url, avatar_id); }); - } - else - { - LL_WARNS() << "Failed to update profile data, no cap found" << LL_ENDL; - } - } -} - void LLPanelProfileSecondLife::refreshName() { if (!mAvatarNameCacheConnection.connected()) @@ -1015,6 +839,18 @@ void LLPanelProfileSecondLife::resetData() childSetVisible("partner_spacer_layout", TRUE); } +void LLPanelProfileSecondLife::processProperties(void* data, EAvatarProcessorType type) +{ + if (APT_PROPERTIES == type) + { + LLAvatarData* avatar_data = static_cast(data); + if (avatar_data && getAvatarId() == avatar_data->avatar_id) + { + processProfileProperties(avatar_data); + } + } +} + void LLPanelProfileSecondLife::processProfileProperties(const LLAvatarData* avatar_data) { const LLRelationship* relationship = LLAvatarTracker::instance().getBuddyInfo(getAvatarId()); @@ -1316,14 +1152,15 @@ void LLPanelProfileSecondLife::fillAgeData(const LLAvatarData* avatar_data) { // Date from server comes already converted to stl timezone, // so display it as an UTC + 0 - std::string name_and_date = getString(avatar_data->hide_age ? "date_format_short" : "date_format_full"); + bool hide_age = avatar_data->hide_age && !getSelfProfile(); + std::string name_and_date = getString(hide_age ? "date_format_short" : "date_format_full"); LLSD args_name; args_name["datetime"] = (S32)avatar_data->born_on.secondsSinceEpoch(); LLStringUtil::format(name_and_date, args_name); getChild("sl_birth_date")->setValue(name_and_date); LLUICtrl* userAgeCtrl = getChild("user_age"); - if (avatar_data->hide_age) + if (hide_age) { userAgeCtrl->setVisible(FALSE); } @@ -1424,7 +1261,7 @@ void LLPanelProfileSecondLife::setAvatarId(const LLUUID& avatar_id) LLAvatarTracker::instance().removeParticularFriendObserver(getAvatarId(), this); } - LLPanelProfileTab::setAvatarId(avatar_id); + LLPanelProfilePropertiesProcessorTab::setAvatarId(avatar_id); if (LLAvatarActions::isFriend(getAvatarId())) { @@ -2111,6 +1948,8 @@ void LLPanelProfileWeb::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent e LLStringUtil::format_map_t args; args["[TIME]"] = llformat("%.2f", mPerformanceTimer.getElapsedTimeF32()); childSetValue("status_text", LLSD( getString("LoadTime", args)) ); + + setLoaded(); } break; @@ -2126,7 +1965,7 @@ void LLPanelProfileWeb::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent e ////////////////////////////////////////////////////////////////////////// LLPanelProfileFirstLife::LLPanelProfileFirstLife() - : LLPanelProfileTab() + : LLPanelProfilePropertiesProcessorTab() , mHasUnsavedChanges(false) { } @@ -2328,6 +2167,18 @@ void LLPanelProfileFirstLife::onDiscardDescriptionChanges() setDescriptionText(mCurrentDescription); } +void LLPanelProfileFirstLife::processProperties(void* data, EAvatarProcessorType type) +{ + if (APT_PROPERTIES == type) + { + LLAvatarData* avatar_data = static_cast(data); + if (avatar_data && getAvatarId() == avatar_data->avatar_id) + { + processProperties(avatar_data); + } + } +} + void LLPanelProfileFirstLife::processProperties(const LLAvatarData* avatar_data) { setDescriptionText(avatar_data->fl_about_text); @@ -2376,7 +2227,7 @@ void LLPanelProfileFirstLife::setLoaded() ////////////////////////////////////////////////////////////////////////// LLPanelProfileNotes::LLPanelProfileNotes() -: LLPanelProfileTab() +: LLPanelProfilePropertiesProcessorTab() , mHasUnsavedChanges(false) { @@ -2386,22 +2237,6 @@ LLPanelProfileNotes::~LLPanelProfileNotes() { } -void LLPanelProfileNotes::updateData() -{ - LLUUID avatar_id = getAvatarId(); - if (!getStarted() && avatar_id.notNull()) - { - setIsLoading(); - - std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP); - if (!cap_url.empty()) - { - LLCoros::instance().launch("requestAgentUserInfoCoro", - [cap_url, avatar_id]() { request_avatar_properties_coro(cap_url, avatar_id); }); - } - } -} - void LLPanelProfileNotes::commitUnsavedChanges() { if (mHasUnsavedChanges) @@ -2462,6 +2297,18 @@ void LLPanelProfileNotes::onDiscardNotesChanges() setNotesText(mCurrentNotes); } +void LLPanelProfileNotes::processProperties(void* data, EAvatarProcessorType type) +{ + if (APT_PROPERTIES == type) + { + LLAvatarData* avatar_data = static_cast(data); + if (avatar_data && getAvatarId() == avatar_data->avatar_id) + { + processProperties(avatar_data); + } + } +} + void LLPanelProfileNotes::processProperties(const LLAvatarData* avatar_data) { setNotesText(avatar_data->notes); @@ -2475,14 +2322,6 @@ void LLPanelProfileNotes::resetData() setNotesText(std::string()); } -void LLPanelProfileNotes::setAvatarId(const LLUUID& avatar_id) -{ - if (avatar_id.notNull()) - { - LLPanelProfileTab::setAvatarId(avatar_id); - } -} - ////////////////////////////////////////////////////////////////////////// // LLPanelProfile @@ -2559,12 +2398,7 @@ void LLPanelProfile::updateData() mPanelFirstlife->setIsLoading(); mPanelNotes->setIsLoading(); - std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP); - if (!cap_url.empty()) - { - LLCoros::instance().launch("requestAgentUserInfoCoro", - [cap_url, avatar_id]() { request_avatar_properties_coro(cap_url, avatar_id); }); - } + LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(getAvatarId()); } } diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h index 178c413659..221a576a65 100644 --- a/indra/newview/llpanelprofile.h +++ b/indra/newview/llpanelprofile.h @@ -68,7 +68,7 @@ class LLViewerFetchedTexture; * Panel for displaying Avatar's second life related info. */ class LLPanelProfileSecondLife - : public LLPanelProfileTab + : public LLPanelProfilePropertiesProcessorTab , public LLFriendObserver , public LLVoiceClientStatusObserver { @@ -93,10 +93,6 @@ public: void resetData() override; - /** - * Sends update data request to server. - */ - void updateData() override; void refreshName(); void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name); @@ -107,7 +103,7 @@ public: bool hasUnsavedChanges() override; void commitUnsavedChanges() override; - friend void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id); + void processProperties(void* data, EAvatarProcessorType type) override; protected: /** @@ -245,8 +241,6 @@ public: void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name); - friend void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id); - protected: void onCommitLoad(LLUICtrl* ctrl); @@ -265,7 +259,7 @@ private: * Panel for displaying Avatar's first life related info. */ class LLPanelProfileFirstLife - : public LLPanelProfileTab + : public LLPanelProfilePropertiesProcessorTab { public: LLPanelProfileFirstLife(); @@ -275,6 +269,7 @@ public: BOOL postBuild() override; + void processProperties(void* data, EAvatarProcessorType type) override; void processProperties(const LLAvatarData* avatar_data); void resetData() override; @@ -285,8 +280,6 @@ public: bool hasUnsavedChanges() override { return mHasUnsavedChanges; } void commitUnsavedChanges() override; - friend void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id); - protected: void setLoaded() override; @@ -318,24 +311,21 @@ protected: * Panel for displaying Avatar's notes and modifying friend's rights. */ class LLPanelProfileNotes - : public LLPanelProfileTab + : public LLPanelProfilePropertiesProcessorTab { public: LLPanelProfileNotes(); /*virtual*/ ~LLPanelProfileNotes(); - void setAvatarId(const LLUUID& avatar_id) override; - void onOpen(const LLSD& key) override; BOOL postBuild() override; + void processProperties(void* data, EAvatarProcessorType type) override; void processProperties(const LLAvatarData* avatar_data); void resetData() override; - void updateData() override; - bool hasUnsavedChanges() override { return mHasUnsavedChanges; } void commitUnsavedChanges() override; @@ -382,10 +372,6 @@ public: void showClassified(const LLUUID& classified_id = LLUUID::null, bool edit = false); void createClassified(); - LLAvatarData getAvatarData() { return mAvatarData; }; - - friend void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id); - private: void onTabChange(); @@ -396,13 +382,6 @@ private: LLPanelProfileFirstLife* mPanelFirstlife; LLPanelProfileNotes* mPanelNotes; LLTabContainer* mTabContainer; - - // Todo: due to server taking minutes to update this needs a more long term storage - // to reuse recently saved values if user opens floater again - // Storage implementation depends onto how a cap will be implemented, if cap will be - // enought to fully update LLAvatarPropertiesProcessor, then this storage can be - // implemented there. - LLAvatarData mAvatarData; }; #endif //LL_LLPANELPROFILE_H diff --git a/indra/newview/llpanelprofilepicks.cpp b/indra/newview/llpanelprofilepicks.cpp index f49ed2d644..13c35a27a0 100644 --- a/indra/newview/llpanelprofilepicks.cpp +++ b/indra/newview/llpanelprofilepicks.cpp @@ -294,6 +294,10 @@ void LLPanelProfilePicks::processProperties(void* data, EAvatarProcessorType typ LLAvatarData* avatar_picks = static_cast(data); if (avatar_picks && getAvatarId() == avatar_picks->avatar_id) { + if (getSelfProfile()) + { + LLAgentPicksInfo::getInstance()->onServerRespond(avatar_picks); + } processProperties(avatar_picks); } } diff --git a/indra/newview/llpanelprofilepicks.h b/indra/newview/llpanelprofilepicks.h index fc29a9de0f..79a5ace865 100644 --- a/indra/newview/llpanelprofilepicks.h +++ b/indra/newview/llpanelprofilepicks.h @@ -77,8 +77,6 @@ public: bool hasUnsavedChanges() override; void commitUnsavedChanges() override; - friend void request_avatar_properties_coro(std::string cap_url, LLUUID agent_id); - private: void onClickNewBtn(); void onClickDelete(); -- cgit v1.3 From 85c4ea76b9a3193dd338bca5c571b84bebf6b38c Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Mon, 6 Nov 2023 17:13:51 +0100 Subject: SL-20163 Allow residents to hide exact join date on profiles (check server support) --- indra/newview/llavatarpropertiesprocessor.cpp | 10 ++++++---- indra/newview/llavatarpropertiesprocessor.h | 5 +++++ indra/newview/llpanelprofile.cpp | 22 ++++++++++++---------- 3 files changed, 23 insertions(+), 14 deletions(-) (limited to 'indra/newview/llpanelprofile.cpp') diff --git a/indra/newview/llavatarpropertiesprocessor.cpp b/indra/newview/llavatarpropertiesprocessor.cpp index e5e9d817c9..bed8887ce1 100644 --- a/indra/newview/llavatarpropertiesprocessor.cpp +++ b/indra/newview/llavatarpropertiesprocessor.cpp @@ -264,6 +264,8 @@ bool LLAvatarPropertiesProcessor::hasPaymentInfoOnFile(const LLAvatarData* avata // static void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_url, LLUUID avatar_id, EAvatarProcessorType type) { + LLAvatarPropertiesProcessor& inst = instance(); + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("requestAvatarPropertiesCoro", httpPolicy)); @@ -278,7 +280,7 @@ void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_ur LLSD result = httpAdapter->getAndSuspend(httpRequest, finalUrl, httpOpts, httpHeaders); // Response is being processed, no longer pending is required - getInstance()->removePendingRequest(avatar_id, type); + inst.removePendingRequest(avatar_id, type); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -308,7 +310,8 @@ void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_ur avatar_data.born_on = result["member_since"].asDate(); // TODO: SL-20163 Remove the "has" check when SRV-684 is done // and the field "hide_age" is included to the http response - avatar_data.hide_age = !result.has("hide_age") || result["hide_age"].asBoolean(); + inst.mIsHideAgeSupportedByServer = result.has("hide_age"); + avatar_data.hide_age = inst.isHideAgeSupportedByServer() && result["hide_age"].asBoolean(); avatar_data.profile_url = getProfileURL(avatar_id.asString()); avatar_data.customer_type = result["customer_type"].asString(); avatar_data.notes = result["notes"].asString(); @@ -364,7 +367,7 @@ void LLAvatarPropertiesProcessor::requestAvatarPropertiesCoro(std::string cap_ur avatar_data.picks_list.emplace_back(pick_data["id"].asUUID(), pick_data["name"].asString()); } - getInstance()->notifyObservers(avatar_id, &avatar_data, type); + inst.notifyObservers(avatar_id, &avatar_data, type); } void LLAvatarPropertiesProcessor::processAvatarLegacyPropertiesReply(LLMessageSystem* msg, void**) @@ -384,7 +387,6 @@ void LLAvatarPropertiesProcessor::processAvatarLegacyPropertiesReply(LLMessageSy msg->getU32Fast( _PREHASH_PropertiesData, _PREHASH_Flags, avatar_data.flags); LLDateUtil::dateFromPDTString(avatar_data.born_on, birth_date); - // Since field 'hide_age' is not supported by msg system we'd better hide the age here avatar_data.caption_index = 0; S32 charter_member_size = 0; diff --git a/indra/newview/llavatarpropertiesprocessor.h b/indra/newview/llavatarpropertiesprocessor.h index 1bf07704a9..99ed110487 100644 --- a/indra/newview/llavatarpropertiesprocessor.h +++ b/indra/newview/llavatarpropertiesprocessor.h @@ -217,6 +217,8 @@ public: void sendClassifiedDelete(const LLUUID& classified_id); + bool isHideAgeSupportedByServer() { return mIsHideAgeSupportedByServer; } + // Returns translated, human readable string for account type, such // as "Resident" or "Linden Employee". Used for profiles, inspectors. static std::string accountType(const LLAvatarData* avatar_data); @@ -274,6 +276,9 @@ protected: // Map avatar_id+request_type -> U32 timestamp in seconds typedef std::map< std::pair, U32> timestamp_map_t; timestamp_map_t mRequestTimestamps; + + // Is returned by isHideAgeSupportedByServer() + bool mIsHideAgeSupportedByServer { false }; }; #endif // LL_LLAVATARPROPERTIESPROCESSOR_H diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index eb62627278..c564b86c60 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -710,7 +710,7 @@ BOOL LLPanelProfileSecondLife::postBuild() { mGroupList = getChild("group_list"); mShowInSearchCombo = getChild("show_in_search"); - mHideAgeCombo = getChild("hide_age"); + mHideAgeCombo = getChild("hide_age"); mSecondLifePic = getChild("2nd_life_pic"); mSecondLifePicLayout = getChild("image_panel"); mDescriptionEdit = getChild("sl_description_edit"); @@ -1173,20 +1173,22 @@ void LLPanelProfileSecondLife::fillAgeData(const LLAvatarData* avatar_data) userAgeCtrl->setValue(register_date); } + BOOL showHideAgeCombo = FALSE; if (getSelfProfile()) { - F64 birth = avatar_data->born_on.secondsSinceEpoch(); - F64 now = LLDate::now().secondsSinceEpoch(); - if (now - birth > 365 * 24 * 60 * 60) + if (LLAvatarPropertiesProcessor::getInstance()->isHideAgeSupportedByServer()) { - mHideAge = avatar_data->hide_age; - mHideAgeCombo->setValue(mHideAge ? TRUE : FALSE); - } - else - { - mHideAgeCombo->setVisible(FALSE); + F64 birth = avatar_data->born_on.secondsSinceEpoch(); + F64 now = LLDate::now().secondsSinceEpoch(); + if (now - birth > 365 * 24 * 60 * 60) + { + mHideAge = avatar_data->hide_age; + mHideAgeCombo->setValue(mHideAge ? TRUE : FALSE); + showHideAgeCombo = TRUE; + } } } + mHideAgeCombo->setVisible(showHideAgeCombo); } void LLPanelProfileSecondLife::onImageLoaded(BOOL success, LLViewerFetchedTexture *imagep) -- cgit v1.3 From 7838c14d871529b39e0fdf63088ac7640478605c Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Mon, 18 Dec 2023 22:02:14 +0200 Subject: SL-18058 Post-merge functionality restore --- indra/newview/llpanelavatar.cpp | 16 +++++++++---- indra/newview/llpanelavatar.h | 2 +- indra/newview/llpanelprofile.cpp | 51 +++++++++------------------------------- 3 files changed, 23 insertions(+), 46 deletions(-) (limited to 'indra/newview/llpanelprofile.cpp') diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index ad8ed7c144..3f2dc5a415 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -127,7 +127,7 @@ void LLPanelProfileTab::setApplyProgress(bool started) } } -static void put_avatar_properties_coro(std::string cap_url, LLUUID agent_id, LLSD data) +static void put_avatar_properties_coro(std::string cap_url, LLUUID agent_id, LLSD data, std::function callback) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -148,13 +148,19 @@ static void put_avatar_properties_coro(std::string cap_url, LLUUID agent_id, LLS if (!status) { LL_WARNS("AvatarProperties") << "Failed to put agent information " << data << " for id " << agent_id << LL_ENDL; - return; + } + else + { + LL_DEBUGS("AvatarProperties") << "Agent id: " << agent_id << " Data: " << data << " Result: " << httpResults << LL_ENDL; } - LL_DEBUGS("AvatarProperties") << "Agent id: " << agent_id << " Data: " << data << " Result: " << httpResults << LL_ENDL; + if (callback) + { + callback(status); + } } -bool LLPanelProfileTab::saveAgentUserInfoCoro(std::string name, LLSD value) const +bool LLPanelProfileTab::saveAgentUserInfoCoro(std::string name, LLSD value, std::function callback) const { std::string cap_url = gAgent.getRegionCapability("AgentProfile"); if (cap_url.empty()) @@ -164,7 +170,7 @@ bool LLPanelProfileTab::saveAgentUserInfoCoro(std::string name, LLSD value) cons } LLCoros::instance().launch("putAgentUserInfoCoro", - boost::bind(put_avatar_properties_coro, cap_url, getAvatarId(), LLSD().with(name, value))); + boost::bind(put_avatar_properties_coro, cap_url, getAvatarId(), LLSD().with(name, value), callback)); return true; } diff --git a/indra/newview/llpanelavatar.h b/indra/newview/llpanelavatar.h index 1106c44734..ec620b39e1 100644 --- a/indra/newview/llpanelavatar.h +++ b/indra/newview/llpanelavatar.h @@ -133,7 +133,7 @@ protected: const bool getSelfProfile() const { return mSelfProfile; } - bool saveAgentUserInfoCoro(std::string name, LLSD value) const; + bool saveAgentUserInfoCoro(std::string name, LLSD value, std::function callback = nullptr) const; public: void setIsLoading() { mLoadingState = PROFILE_LOADING; } diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 6067f9c299..f014dff470 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -102,45 +102,6 @@ static const std::string PROFILE_IMAGE_UPLOAD_CAP = "UploadAgentProfileImage"; ////////////////////////////////////////////////////////////////////////// - -//TODO: changes take two minutes to propagate! -// Add some storage that holds updated data for two minutes -// for new instances to reuse the data -// Profile data is only relevant to own avatar, but notes -// are for everybody (no onger an issue?) -void put_avatar_properties_coro(std::string cap_url, LLUUID agent_id, LLSD data, std::function callback) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("put_avatar_properties_coro", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpHeaders::ptr_t httpHeaders; - - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - httpOpts->setFollowRedirects(true); - - std::string finalUrl = cap_url + "/" + agent_id.asString(); - - LLSD result = httpAdapter->putAndSuspend(httpRequest, finalUrl, data, httpOpts, httpHeaders); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status) - { - LL_WARNS("AvatarProperties") << "Failed to put agent information " << data << " for id " << agent_id << LL_ENDL; - } - else - { - LL_DEBUGS("AvatarProperties") << "Agent id: " << agent_id << " Data: " << data << " Result: " << httpResults << LL_ENDL; - } - - if (callback) - { - callback(status); - } -} - LLUUID post_profile_image(std::string cap_url, const LLSD &first_data, std::string path_to_image, LLHandle *handle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -1840,7 +1801,17 @@ void LLPanelProfileSecondLife::onCommitProfileImage(const LLUUID& id) if (mImageId == id) return; - if (!saveAgentUserInfoCoro("sl_image_id", id)) + std::function callback = [id](bool result) + { + if (result) + { + LLAvatarIconIDCache::getInstance()->add(gAgentID, id); + // Should trigger callbacks in icon controls + LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(gAgentID); + } + }; + + if (!saveAgentUserInfoCoro("sl_image_id", id, callback)) return; mImageId = id; -- cgit v1.3 From 096156d16ce0461c173b1bd925a97e7c41a042e5 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 3 Jan 2024 00:38:57 +0200 Subject: SL-18058 Post-merge functionality restore #2 --- indra/newview/llavatariconctrl.cpp | 22 +++++++++++++++++++++- indra/newview/llpanelprofile.cpp | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpanelprofile.cpp') diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp index a48fbf31a6..52bec5d434 100644 --- a/indra/newview/llavatariconctrl.cpp +++ b/indra/newview/llavatariconctrl.cpp @@ -299,7 +299,13 @@ bool LLAvatarIconCtrl::updateFromCache() //virtual void LLAvatarIconCtrl::processProperties(void* data, EAvatarProcessorType type) { - if (APT_PROPERTIES_LEGACY == type) + // Both APT_PROPERTIES_LEGACY and APT_PROPERTIES have icon data. + // 'Legacy' is cheaper to request so LLAvatarIconCtrl issues that, + // but own icon should track any source for the sake of timely updates. + // + // If this needs to change, make sure to update onCommitProfileImage + // to issue right kind of request + if (APT_PROPERTIES_LEGACY == type) { LLAvatarLegacyData* avatar_data = static_cast(data); if (avatar_data) @@ -313,6 +319,20 @@ void LLAvatarIconCtrl::processProperties(void* data, EAvatarProcessorType type) updateFromCache(); } } + else if (APT_PROPERTIES == type) + { + LLAvatarData* avatar_data = static_cast(data); + if (avatar_data) + { + if (avatar_data->avatar_id != mAvatarId) + { + return; + } + + LLAvatarIconIDCache::getInstance()->add(mAvatarId, avatar_data->image_id); + updateFromCache(); + } + } } void LLAvatarIconCtrl::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name) diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index f014dff470..55ddeed4ec 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -1806,7 +1806,7 @@ void LLPanelProfileSecondLife::onCommitProfileImage(const LLUUID& id) if (result) { LLAvatarIconIDCache::getInstance()->add(gAgentID, id); - // Should trigger callbacks in icon controls + // Should trigger callbacks in icon controls (or request Legacy) LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(gAgentID); } }; -- cgit v1.3 From 305fe845c6058177c84c7f8d49c3faedec2e8282 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Tue, 9 Jan 2024 23:16:57 +0200 Subject: SL-20779 More reliable decode and encode error logging (#615) --- indra/llimage/llimage.cpp | 13 ++++--------- indra/llimage/llimage.h | 5 ++--- indra/llimage/llimageworker.cpp | 19 +++++++++++++++---- indra/llimage/llimageworker.h | 2 +- indra/newview/llfloatersimplesnapshot.cpp | 6 +++--- indra/newview/llpanelprofile.cpp | 2 +- indra/newview/lltexturefetch.cpp | 10 +++++----- indra/newview/llviewerassetupload.cpp | 2 +- indra/newview/llviewermenufile.cpp | 2 +- 9 files changed, 33 insertions(+), 28 deletions(-) (limited to 'indra/newview/llpanelprofile.cpp') diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 031471d1fe..9c0cc8d760 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -584,8 +584,7 @@ static void bilinear_scale(const U8 *src, U32 srcW, U32 srcH, U32 srcCh, U32 src //--------------------------------------------------------------------------- //static -std::string LLImage::sLastErrorMessage; -LLMutex* LLImage::sMutex = NULL; +thread_local std::string LLImage::sLastThreadErrorMessage; bool LLImage::sUseNewByteRange = false; S32 LLImage::sMinimalReverseByteRangePercent = 75; @@ -594,28 +593,24 @@ void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_ { sUseNewByteRange = use_new_byte_range; sMinimalReverseByteRangePercent = minimal_reverse_byte_range_percent; - sMutex = new LLMutex(); } //static void LLImage::cleanupClass() { - delete sMutex; - sMutex = NULL; } //static -const std::string& LLImage::getLastError() +const std::string& LLImage::getLastThreadError() { static const std::string noerr("No Error"); - return sLastErrorMessage.empty() ? noerr : sLastErrorMessage; + return sLastThreadErrorMessage.empty() ? noerr : sLastThreadErrorMessage; } //static void LLImage::setLastError(const std::string& message) { - LLMutexLock m(sMutex); - sLastErrorMessage = message; + sLastThreadErrorMessage = message; } //--------------------------------------------------------------------------- diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 8f9e1b3c54..01b6642e1e 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -95,15 +95,14 @@ public: static void initClass(bool use_new_byte_range = false, S32 minimal_reverse_byte_range_percent = 75); static void cleanupClass(); - static const std::string& getLastError(); + static const std::string& getLastThreadError(); static void setLastError(const std::string& message); static bool useNewByteRange() { return sUseNewByteRange; } static S32 getReverseByteRangePercent() { return sMinimalReverseByteRangePercent; } protected: - static LLMutex* sMutex; - static std::string sLastErrorMessage; + static thread_local std::string sLastThreadErrorMessage; static bool sUseNewByteRange; static S32 sMinimalReverseByteRangePercent; }; diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp index c1ee052997..e09f6a0a13 100644 --- a/indra/llimage/llimageworker.cpp +++ b/indra/llimage/llimageworker.cpp @@ -55,6 +55,7 @@ private: BOOL mDecodedRaw; BOOL mDecodedAux; LLPointer mResponder; + std::string mErrorString; }; @@ -149,8 +150,9 @@ ImageRequest::~ImageRequest() bool ImageRequest::processRequest() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - const F32 decode_time_slice = 0.f; //disable time slicing - bool done = true; + const F32 decode_time_slice = 0.f; //disable time slicing + bool done = true; + mErrorString.clear(); if (!mDecodedRaw && mFormattedImage.notNull()) { // Decode primary channels @@ -159,10 +161,13 @@ bool ImageRequest::processRequest() // parse formatted header if (!mFormattedImage->updateData()) { + // Pick up errors from updateData + mErrorString = LLImage::getLastThreadError(); return true; // done (failed) } if (!(mFormattedImage->getWidth() * mFormattedImage->getHeight() * mFormattedImage->getComponents())) { + mErrorString = "Invalid image size"; return true; // done (failed) } if (mDiscardLevel >= 0) @@ -176,6 +181,9 @@ bool ImageRequest::processRequest() done = mFormattedImage->decode(mDecodedImageRaw, decode_time_slice); // some decoders are removing data when task is complete and there were errors mDecodedRaw = done && mDecodedImageRaw->getData(); + + // Pick up errors from decoding + mErrorString = LLImage::getLastThreadError(); } if (done && mNeedsAux && !mDecodedAux && mFormattedImage.notNull()) { @@ -188,7 +196,10 @@ bool ImageRequest::processRequest() } done = mFormattedImage->decodeChannels(mDecodedImageAux, decode_time_slice, 4, 4); mDecodedAux = done && mDecodedImageAux->getData(); - } + + // Pick up errors from decoding + mErrorString = LLImage::getLastThreadError(); + } return done; } @@ -199,7 +210,7 @@ void ImageRequest::finishRequest(bool completed) if (mResponder.notNull()) { bool success = completed && mDecodedRaw && (!mNeedsAux || mDecodedAux); - mResponder->completed(success, mDecodedImageRaw, mDecodedImageAux); + mResponder->completed(success, mErrorString, mDecodedImageRaw, mDecodedImageAux); } // Will automatically be deleted } diff --git a/indra/llimage/llimageworker.h b/indra/llimage/llimageworker.h index ca4c0d93d0..c48c8084ee 100644 --- a/indra/llimage/llimageworker.h +++ b/indra/llimage/llimageworker.h @@ -39,7 +39,7 @@ public: protected: virtual ~Responder(); public: - virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux) = 0; + virtual void completed(bool success, const std::string& error_message, LLImageRaw* raw, LLImageRaw* aux) = 0; }; public: diff --git a/indra/newview/llfloatersimplesnapshot.cpp b/indra/newview/llfloatersimplesnapshot.cpp index 58604c5628..40d5a5ed84 100644 --- a/indra/newview/llfloatersimplesnapshot.cpp +++ b/indra/newview/llfloatersimplesnapshot.cpp @@ -370,7 +370,7 @@ void LLFloaterSimpleSnapshot::onSend() else { LLSD notif_args; - notif_args["REASON"] = LLImage::getLastError().c_str(); + notif_args["REASON"] = LLImage::getLastThreadError().c_str(); LLNotificationsUtil::add("CannotUploadTexture", notif_args); } } @@ -389,7 +389,7 @@ void LLFloaterSimpleSnapshot::uploadThumbnail(const std::string &file_path, cons if (!LLViewerTextureList::createUploadFile(file_path, temp_file, codec, THUMBNAIL_SNAPSHOT_DIM_MAX, THUMBNAIL_SNAPSHOT_DIM_MIN, true)) { LLSD notif_args; - notif_args["REASON"] = LLImage::getLastError().c_str(); + notif_args["REASON"] = LLImage::getLastThreadError().c_str(); LLNotificationsUtil::add("CannotUploadTexture", notif_args); LL_WARNS("Thumbnail") << "Failed to upload thumbnail for " << inventory_id << " " << task_id << ", reason: " << notif_args["REASON"].asString() << LL_ENDL; return; @@ -404,7 +404,7 @@ void LLFloaterSimpleSnapshot::uploadThumbnail(LLPointer raw_image, c if (!LLViewerTextureList::createUploadFile(raw_image, temp_file, THUMBNAIL_SNAPSHOT_DIM_MAX, THUMBNAIL_SNAPSHOT_DIM_MIN)) { LLSD notif_args; - notif_args["REASON"] = LLImage::getLastError().c_str(); + notif_args["REASON"] = LLImage::getLastThreadError().c_str(); LLNotificationsUtil::add("CannotUploadTexture", notif_args); LL_WARNS("Thumbnail") << "Failed to upload thumbnail for " << inventory_id << " " << task_id << ", reason: " << notif_args["REASON"].asString() << LL_ENDL; return; diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 55ddeed4ec..67c942b267 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -1369,7 +1369,7 @@ void LLProfileImagePicker::notify(const std::vector& filenames) if (!LLViewerTextureList::createUploadFile(file_path, temp_file, codec, MAX_DIM)) { LLSD notif_args; - notif_args["REASON"] = LLImage::getLastError().c_str(); + notif_args["REASON"] = LLImage::getLastThreadError().c_str(); LLNotificationsUtil::add("CannotUploadTexture", notif_args); LL_WARNS("AvatarProperties") << "Failed to upload profile image of type " << (S32)mType << ", " << notif_args["REASON"].asString() << LL_ENDL; return; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 38c9b3717d..a8fc3d295c 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -348,13 +348,13 @@ private: } // Threads: Tid - virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux) + virtual void completed(bool success, const std::string& error_message, LLImageRaw* raw, LLImageRaw* aux) { LL_PROFILE_ZONE_SCOPED; LLTextureFetchWorker* worker = mFetcher->getWorker(mID); if (worker) { - worker->callbackDecoded(success, raw, aux); + worker->callbackDecoded(success, error_message, raw, aux); } } private: @@ -398,7 +398,7 @@ public: void callbackCacheWrite(bool success); // Threads: Tid - void callbackDecoded(bool success, LLImageRaw* raw, LLImageRaw* aux); + void callbackDecoded(bool success, const std::string& error_message, LLImageRaw* raw, LLImageRaw* aux); // Threads: T* void setGetStatus(LLCore::HttpStatus status, const std::string& reason) @@ -2305,7 +2305,7 @@ void LLTextureFetchWorker::callbackCacheWrite(bool success) ////////////////////////////////////////////////////////////////////////////// // Threads: Tid -void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImageRaw* aux) +void LLTextureFetchWorker::callbackDecoded(bool success, const std::string &error_message, LLImageRaw* raw, LLImageRaw* aux) { LLMutexLock lock(&mWorkMutex); // +Mw if (mDecodeHandle == 0) @@ -2332,7 +2332,7 @@ void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImag } else { - LL_WARNS(LOG_TXT) << "DECODE FAILED: " << mID << " Discard: " << (S32)mFormattedImage->getDiscardLevel() << LL_ENDL; + LL_WARNS(LOG_TXT) << "DECODE FAILED: " << mID << " Discard: " << (S32)mFormattedImage->getDiscardLevel() << ", reason: " << error_message << LL_ENDL; removeFromCache(); mDecodedDiscard = -1; // Redundant, here for clarity and paranoia } diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index e2e321af0d..9d95c8d054 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -417,7 +417,7 @@ LLSD LLNewFileResourceUploadInfo::exportTempFile() if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec)) { errorMessage = llformat("Problem with file %s:\n\n%s\n", - getFileName().c_str(), LLImage::getLastError().c_str()); + getFileName().c_str(), LLImage::getLastThreadError().c_str()); errorLabel = "ProblemWithFile"; error = true; } diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 5461e0f362..fe5fee6ee6 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -947,7 +947,7 @@ void handle_compress_image(void*) } else { - LL_INFOS() << "Compression failed: " << LLImage::getLastError() << LL_ENDL; + LL_INFOS() << "Compression failed: " << LLImage::getLastThreadError() << LL_ENDL; } infile = picker.getNextFile(); -- cgit v1.3 From 6ed3a1670cc976975942c1c7e57fb30298669ab7 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Tue, 12 Mar 2024 21:53:38 +0200 Subject: SL-20735 Fix blury profile pictures #2 (#963) Scaling was added to thumbnail images as a measure of memory preservation and said scaling doesn't work well when larger images are needed so had to remake profile images to no longer use thumbnails. --- indra/newview/llfloaterprofiletexture.cpp | 284 ++++++++++++--------- indra/newview/llfloaterprofiletexture.h | 62 +++-- indra/newview/llpanelprofile.cpp | 161 ++---------- indra/newview/llpanelprofile.h | 18 +- .../default/xui/en/floater_profile_texture.xml | 2 +- .../default/xui/en/panel_profile_firstlife.xml | 2 +- .../default/xui/en/panel_profile_secondlife.xml | 2 +- 7 files changed, 248 insertions(+), 283 deletions(-) (limited to 'indra/newview/llpanelprofile.cpp') diff --git a/indra/newview/llfloaterprofiletexture.cpp b/indra/newview/llfloaterprofiletexture.cpp index a78df1015a..a46548f29a 100644 --- a/indra/newview/llfloaterprofiletexture.cpp +++ b/indra/newview/llfloaterprofiletexture.cpp @@ -33,37 +33,173 @@ #include "llpreview.h" // fors constants #include "lltrans.h" #include "llviewercontrol.h" -#include "lltextureview.h" #include "llviewertexture.h" #include "llviewertexturelist.h" + ////////////////////////////////////////////////////////////////////////// + // LLProfileImageCtrl + ////////////////////////////////////////////////////////////////////////// -LLFloaterProfileTexture::LLFloaterProfileTexture(LLView* owner) - : LLFloater(LLSD()) - , mUpdateDimensions(TRUE) - , mLastHeight(0) - , mLastWidth(0) +static LLDefaultChildRegistry::Register r("profile_image"); + +LLProfileImageCtrl::LLProfileImageCtrl(const LLProfileImageCtrl::Params& p) + : LLIconCtrl(p) , mImage(NULL) , mImageOldBoostLevel(LLGLTexture::BOOST_NONE) - , mOwnerHandle(owner->getHandle()) + , mWasNoDelete(false) + , mImageLoadedSignal(NULL) { - buildFromFile("floater_profile_texture.xml"); } -LLFloaterProfileTexture::~LLFloaterProfileTexture() +LLProfileImageCtrl::~LLProfileImageCtrl() +{ + LLLoadedCallbackEntry::cleanUpCallbackList(&mCallbackTextureList); + releaseTexture(); + + delete mImageLoadedSignal; +} + +void LLProfileImageCtrl::releaseTexture() { if (mImage.notNull()) { mImage->setBoostLevel(mImageOldBoostLevel); + if (!mWasNoDelete) + { + // In most cases setBoostLevel marks images as NO_DELETE + mImage->forceActive(); + } mImage = NULL; } } +void LLProfileImageCtrl::setValue(const LLSD& value) +{ + LLUUID id = value.asUUID(); + setImageAssetId(id); + if (id.isNull()) + { + LLIconCtrl::setValue("Generic_Person_Large", LLGLTexture::BOOST_UI); + } + else + { + // called second to not change priority before it gets saved to mImageOldBoostLevel + LLIconCtrl::setValue(value, LLGLTexture::BOOST_PREVIEW); + } +} + +void LLProfileImageCtrl::draw() +{ + if (mImage.notNull()) + { + // Pump the texture priority + mImage->addTextureStats(MAX_IMAGE_AREA); + mImage->setKnownDrawSize(LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT, LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT); + } + LLIconCtrl::draw(); +} + +boost::signals2::connection LLProfileImageCtrl::setImageLoadedCallback(const image_loaded_signal_t::slot_type& cb) +{ + if (!mImageLoadedSignal) mImageLoadedSignal = new image_loaded_signal_t(); + + return mImageLoadedSignal->connect(cb); +} + +void LLProfileImageCtrl::setImageAssetId(const LLUUID& asset_id) +{ + if (mImageID == asset_id) + { + return; + } + + releaseTexture(); + + mImageID = asset_id; + if (mImageID.notNull()) + { + mImage = LLViewerTextureManager::getFetchedTexture(mImageID, FTT_DEFAULT, MIPMAP_YES, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + mWasNoDelete = mImage->getTextureState() == LLGLTexture::NO_DELETE; + mImageOldBoostLevel = mImage->getBoostLevel(); + mImage->setBoostLevel(LLGLTexture::BOOST_PREVIEW); + mImage->setKnownDrawSize(LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT, LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT); + mImage->forceToSaveRawImage(0); + + if ((mImage->getFullWidth() * mImage->getFullHeight()) == 0) + { + mImage->setLoadedCallback(LLProfileImageCtrl::onImageLoaded, + 0, TRUE, FALSE, new LLHandle(getHandle()), &mCallbackTextureList); + } + else + { + onImageLoaded(true, mImage); + } + } +} + +void LLProfileImageCtrl::onImageLoaded(bool success, LLViewerFetchedTexture* img) +{ + if (mImageLoadedSignal) + { + (*mImageLoadedSignal)(success, img); + } +} + +// static +void LLProfileImageCtrl::onImageLoaded(BOOL success, + LLViewerFetchedTexture* src_vi, + LLImageRaw* src, + LLImageRaw* aux_src, + S32 discard_level, + BOOL final, + void* userdata) +{ + if (!userdata) return; + + LLHandle* handle = (LLHandle*)userdata; + + if (!handle->isDead()) + { + LLProfileImageCtrl* caller = static_cast(handle->get()); + if (caller && caller->mImageLoadedSignal) + { + (*caller->mImageLoadedSignal)(success, src_vi); + } + } + + if (final || !success) + { + delete handle; + } +} + + +////////////////////////////////////////////////////////////////////////// +// LLFloaterProfileTexture + ////////////////////////////////////////////////////////////////////////// + +LLFloaterProfileTexture::LLFloaterProfileTexture(LLView* owner) + : LLFloater(LLSD()) + , mLastHeight(0) + , mLastWidth(0) + , mOwnerHandle(owner->getHandle()) + , mContextConeOpacity(0.f) + , mCloseButton(NULL) + , mProfileIcon(NULL) +{ + buildFromFile("floater_profile_texture.xml"); +} + +LLFloaterProfileTexture::~LLFloaterProfileTexture() +{ +} + // virtual BOOL LLFloaterProfileTexture::postBuild() { - mProfileIcon = getChild("profile_pic"); + mProfileIcon = getChild("profile_pic"); + mProfileIcon->setImageLoadedCallback([this](BOOL success, LLViewerFetchedTexture* imagep) {onImageLoaded(success, imagep); }); mCloseButton = getChild("close_btn"); mCloseButton->setCommitCallback([this](LLUICtrl*, void*) { closeFloater(); }, nullptr); @@ -81,55 +217,41 @@ void LLFloaterProfileTexture::reshape(S32 width, S32 height, BOOL called_from_pa // When we receive it, reshape the window accordingly. void LLFloaterProfileTexture::updateDimensions() { - if (mImage.isNull()) + LLPointer image = mProfileIcon->getImage(); + if (image.isNull()) { return; } - if ((mImage->getFullWidth() * mImage->getFullHeight()) == 0) + if ((image->getFullWidth() * image->getFullHeight()) == 0) { return; } - S32 img_width = mImage->getFullWidth(); - S32 img_height = mImage->getFullHeight(); - - if (mAssetStatus != LLPreview::PREVIEW_ASSET_LOADED - || mLastWidth != img_width - || mLastHeight != img_height) - { - mAssetStatus = LLPreview::PREVIEW_ASSET_LOADED; - // Asset has been fully loaded - mUpdateDimensions = TRUE; - } + S32 img_width = image->getFullWidth(); + S32 img_height = image->getFullHeight(); mLastHeight = img_height; mLastWidth = img_width; - // Reshape the floater only when required - if (mUpdateDimensions) - { - mUpdateDimensions = FALSE; + LLRect old_floater_rect = getRect(); + LLRect old_image_rect = mProfileIcon->getRect(); + S32 width = old_floater_rect.getWidth() - old_image_rect.getWidth() + mLastWidth; + S32 height = old_floater_rect.getHeight() - old_image_rect.getHeight() + mLastHeight; - LLRect old_floater_rect = getRect(); - LLRect old_image_rect = mProfileIcon->getRect(); - S32 width = old_floater_rect.getWidth() - old_image_rect.getWidth() + mLastWidth; - S32 height = old_floater_rect.getHeight() - old_image_rect.getHeight() + mLastHeight; + const F32 MAX_DIMENTIONS = 512; // most profiles are supposed to be 256x256 - const F32 MAX_DIMENTIONS = 512; // most profiles are supposed to be 256x256 - - S32 biggest_dim = llmax(width, height); - if (biggest_dim > MAX_DIMENTIONS) - { - F32 scale_down = MAX_DIMENTIONS / (F32)biggest_dim; - width *= scale_down; - height *= scale_down; - } + S32 biggest_dim = llmax(width, height); + if (biggest_dim > MAX_DIMENTIONS) + { + F32 scale_down = MAX_DIMENTIONS / (F32)biggest_dim; + width *= scale_down; + height *= scale_down; + } - //reshape floater - reshape(width, height); + //reshape floater + reshape(width, height); - gFloaterView->adjustToFitScreen(this, FALSE); - } + gFloaterView->adjustToFitScreen(this, FALSE); } void LLFloaterProfileTexture::draw() @@ -139,13 +261,6 @@ void LLFloaterProfileTexture::draw() static LLCachedControl max_opacity(gSavedSettings, "PickerContextOpacity", 0.4f); drawConeToOwner(mContextConeOpacity, max_opacity, owner); - if (mImage.notNull()) - { - // Pump the texture priority - mImage->addTextureStats(MAX_IMAGE_AREA); - mImage->setKnownDrawSize(LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT, LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT); - } - LLFloater::draw(); } @@ -156,77 +271,18 @@ void LLFloaterProfileTexture::onOpen(const LLSD& key) void LLFloaterProfileTexture::resetAsset() { - mProfileIcon->setValue("Generic_Person_Large"); - mImageID = LLUUID::null; - if (mImage.notNull()) - { - mImage->setBoostLevel(mImageOldBoostLevel); - mImage = NULL; - } + mProfileIcon->setValue(LLUUID::null); } void LLFloaterProfileTexture::loadAsset(const LLUUID &image_id) { - if (mImageID != image_id) - { - if (mImage.notNull()) - { - mImage->setBoostLevel(mImageOldBoostLevel); - mImage = NULL; - } - } - else - { - return; - } - mProfileIcon->setValue(image_id); - mImageID = image_id; - mImage = LLViewerTextureManager::getFetchedTexture(mImageID, FTT_DEFAULT, MIPMAP_TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); - mImageOldBoostLevel = mImage->getBoostLevel(); - mImage->setKnownDrawSize(LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT, LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT); - mImage->forceToSaveRawImage(0); - - if ((mImage->getFullWidth() * mImage->getFullHeight()) == 0) - { - mImage->setLoadedCallback(LLFloaterProfileTexture::onTextureLoaded, - 0, TRUE, FALSE, new LLHandle(getHandle()), &mCallbackTextureList); - - mImage->setBoostLevel(LLGLTexture::BOOST_PREVIEW); - mAssetStatus = LLPreview::PREVIEW_ASSET_LOADING; - } - else - { - mAssetStatus = LLPreview::PREVIEW_ASSET_LOADED; - } - - mUpdateDimensions = TRUE; updateDimensions(); } -// static -void LLFloaterProfileTexture::onTextureLoaded( - BOOL success, - LLViewerFetchedTexture *src_vi, - LLImageRaw* src, - LLImageRaw* aux_src, - S32 discard_level, - BOOL final, - void* userdata) +void LLFloaterProfileTexture::onImageLoaded(BOOL success, LLViewerFetchedTexture* imagep) { - LLHandle* handle = (LLHandle*)userdata; - - if (!handle->isDead()) - { - LLFloaterProfileTexture* floater = static_cast(handle->get()); - if (floater && success) - { - floater->mUpdateDimensions = TRUE; - floater->updateDimensions(); - } - } - - if (final || !success) + if (success) { - delete handle; + updateDimensions(); } } diff --git a/indra/newview/llfloaterprofiletexture.h b/indra/newview/llfloaterprofiletexture.h index 66a61213dd..12efbab572 100644 --- a/indra/newview/llfloaterprofiletexture.h +++ b/indra/newview/llfloaterprofiletexture.h @@ -28,11 +28,50 @@ #define LL_LLFLOATERPROFILETEXTURE_H #include "llfloater.h" +#include "lliconctrl.h" #include "llviewertexture.h" class LLButton; class LLImageRaw; -class LLIconCtrl; + +class LLProfileImageCtrl: public LLIconCtrl +{ +public: + struct Params: public LLInitParam::Block + { + }; + + LLProfileImageCtrl(const Params& p); + virtual ~LLProfileImageCtrl(); + + + virtual void setValue(const LLSD& value) override; + LLUUID getImageAssetId() { return mImageID; } + LLPointer getImage() {return mImage;} + void draw() override; + + typedef boost::signals2::signal image_loaded_signal_t; + boost::signals2::connection setImageLoadedCallback(const image_loaded_signal_t::slot_type& cb); +private: + void onImageLoaded(bool success, LLViewerFetchedTexture* src_vi); + static void onImageLoaded(BOOL success, + LLViewerFetchedTexture* src_vi, + LLImageRaw* src, + LLImageRaw* aux_src, + S32 discard_level, + BOOL final, + void* userdata); + void releaseTexture(); + + void setImageAssetId(const LLUUID& asset_id); +private: + LLPointer mImage; + LLUUID mImageID; + S32 mImageOldBoostLevel; + bool mWasNoDelete; + image_loaded_signal_t* mImageLoadedSignal; + LLLoadedCallbackEntry::source_callback_list_t mCallbackTextureList; +}; class LLFloaterProfileTexture : public LLFloater { @@ -46,36 +85,23 @@ public: void resetAsset(); void loadAsset(const LLUUID &image_id); - - static void onTextureLoaded( - BOOL success, - LLViewerFetchedTexture *src_vi, - LLImageRaw* src, - LLImageRaw* aux_src, - S32 discard_level, - BOOL final, - void* userdata); + void onImageLoaded(BOOL success, LLViewerFetchedTexture* imagep); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE) override; + + LLHandle getHandle() const { return LLFloater::getHandle(); } protected: BOOL postBuild() override; private: void updateDimensions(); - LLUUID mImageID; - LLPointer mImage; - S32 mImageOldBoostLevel; - S32 mAssetStatus; F32 mContextConeOpacity; S32 mLastHeight; S32 mLastWidth; - BOOL mUpdateDimensions; LLHandle mOwnerHandle; - LLIconCtrl* mProfileIcon; + LLProfileImageCtrl* mProfileIcon; LLButton* mCloseButton; - - LLLoadedCallbackEntry::source_callback_list_t mCallbackTextureList; }; #endif // LL_LLFLOATERPROFILETEXTURE_H diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 67c942b267..197b0d89c0 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -71,7 +71,6 @@ #include "llpanelblockedlist.h" #include "llpanelprofileclassifieds.h" #include "llpanelprofilepicks.h" -#include "llthumbnailctrl.h" #include "lltrans.h" #include "llviewercontrol.h" #include "llviewermenu.h" //is_agent_mappable @@ -719,7 +718,7 @@ BOOL LLPanelProfileSecondLife::postBuild() mGroupList = getChild("group_list"); mShowInSearchCombo = getChild("show_in_search"); mHideAgeCombo = getChild("hide_age"); - mSecondLifePic = getChild("2nd_life_pic"); + mSecondLifePic = getChild("2nd_life_pic"); mSecondLifePicLayout = getChild("image_panel"); mDescriptionEdit = getChild("sl_description_edit"); mAgentActionMenuButton = getChild("agent_actions_menu"); @@ -818,10 +817,9 @@ void LLPanelProfileSecondLife::resetData() // Set default image and 1:1 dimensions for it mSecondLifePic->setValue("Generic_Person_Large"); - mImageId = LLUUID::null; LLRect imageRect = mSecondLifePicLayout->getRect(); - mSecondLifePicLayout->reshape(imageRect.getHeight(), imageRect.getHeight()); + mSecondLifePicLayout->reshape(imageRect.getWidth(), imageRect.getWidth()); setDescriptionText(LLStringUtil::null); mGroups.clear(); @@ -923,36 +921,12 @@ void LLPanelProfileSecondLife::setProfileImageUploading(bool loading) void LLPanelProfileSecondLife::setProfileImageUploaded(const LLUUID &image_asset_id) { mSecondLifePic->setValue(image_asset_id); - mImageId = image_asset_id; - - LLViewerFetchedTexture* imagep = LLViewerTextureManager::getFetchedTexture(image_asset_id); - if (imagep->getFullHeight()) - { - onImageLoaded(true, imagep); - } - else - { - imagep->setLoadedCallback(onImageLoaded, - MAX_DISCARD_LEVEL, - FALSE, - FALSE, - new LLHandle(getHandle()), - NULL, - FALSE); - } LLFloater *floater = mFloaterProfileTextureHandle.get(); if (floater) { LLFloaterProfileTexture * texture_view = dynamic_cast(floater); - if (mImageId.notNull()) - { - texture_view->loadAsset(mImageId); - } - else - { - texture_view->resetAsset(); - } + texture_view->loadAsset(mSecondLifePic->getImageAssetId()); } setProfileImageUploading(false); @@ -1000,33 +974,7 @@ void LLPanelProfileSecondLife::fillCommonData(const LLAvatarData* avatar_data) setDescriptionText(avatar_data->about_text); - if (avatar_data->image_id.notNull()) - { - mSecondLifePic->setValue(avatar_data->image_id); - mImageId = avatar_data->image_id; - } - else - { - mSecondLifePic->setValue("Generic_Person_Large"); - mImageId = LLUUID::null; - } - - // Will be loaded as a LLViewerFetchedTexture::BOOST_UI due to mSecondLifePic - LLViewerFetchedTexture* imagep = LLViewerTextureManager::getFetchedTexture(avatar_data->image_id); - if (imagep->getFullHeight()) - { - onImageLoaded(true, imagep); - } - else - { - imagep->setLoadedCallback(onImageLoaded, - MAX_DISCARD_LEVEL, - FALSE, - FALSE, - new LLHandle(getHandle()), - NULL, - FALSE); - } + mSecondLifePic->setValue(avatar_data->image_id); if (getSelfProfile()) { @@ -1213,34 +1161,6 @@ void LLPanelProfileSecondLife::onImageLoaded(BOOL success, LLViewerFetchedTextur } } -//static -void LLPanelProfileSecondLife::onImageLoaded(BOOL success, - LLViewerFetchedTexture *src_vi, - LLImageRaw* src, - LLImageRaw* aux_src, - S32 discard_level, - BOOL final, - void* userdata) -{ - if (!userdata) return; - - LLHandle* handle = (LLHandle*)userdata; - - if (!handle->isDead()) - { - LLPanelProfileSecondLife* panel = static_cast(handle->get()); - if (panel) - { - panel->onImageLoaded(success, src_vi); - } - } - - if (final || !success) - { - delete handle; - } -} - // virtual, called by LLAvatarTracker void LLPanelProfileSecondLife::changed(U32 mask) { @@ -1505,7 +1425,7 @@ void LLPanelProfileSecondLife::onCommitMenu(const LLSD& userdata) } else if (item_name == "upload_photo") { - (new LLProfileImagePicker(PROFILE_IMAGE_SL, new LLHandle(getHandle())))->getFile(); + (new LLProfileImagePicker(PROFILE_IMAGE_SL, new LLHandle(LLPanel::getHandle())))->getFile(); LLFloater* floaterp = mFloaterTexturePickerHandle.get(); if (floaterp) @@ -1580,7 +1500,7 @@ bool LLPanelProfileSecondLife::onEnableMenu(const LLSD& userdata) else if (item_name == "remove_photo") { std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP); - return mImageId.notNull() && !cap_url.empty() && !mWaitingForImageUpload && getIsLoaded(); + return mSecondLifePic->getImageAssetId().notNull() && !cap_url.empty() && !mWaitingForImageUpload && getIsLoaded(); } return false; @@ -1715,9 +1635,9 @@ void LLPanelProfileSecondLife::onShowAgentProfileTexture() { LLFloaterProfileTexture * texture_view = new LLFloaterProfileTexture(parent_floater); mFloaterProfileTextureHandle = texture_view->getHandle(); - if (mImageId.notNull()) + if (mSecondLifePic->getImageAssetId().notNull()) { - texture_view->loadAsset(mImageId); + texture_view->loadAsset(mSecondLifePic->getImageAssetId()); } else { @@ -1734,9 +1654,9 @@ void LLPanelProfileSecondLife::onShowAgentProfileTexture() LLFloaterProfileTexture * texture_view = dynamic_cast(floater); texture_view->setMinimized(FALSE); texture_view->setVisibleAndFrontmost(TRUE); - if (mImageId.notNull()) + if (mSecondLifePic->getImageAssetId().notNull()) { - texture_view->loadAsset(mImageId); + texture_view->loadAsset(mSecondLifePic->getImageAssetId()); } else { @@ -1759,9 +1679,9 @@ void LLPanelProfileSecondLife::onShowTexturePicker() getWindow()->setCursor(UI_CURSOR_WAIT); LLFloaterTexturePicker* texture_floaterp = new LLFloaterTexturePicker( this, - mImageId, + mSecondLifePic->getImageAssetId(), LLUUID::null, - mImageId, + mSecondLifePic->getImageAssetId(), FALSE, FALSE, "SELECT PHOTO", @@ -1798,7 +1718,7 @@ void LLPanelProfileSecondLife::onShowTexturePicker() void LLPanelProfileSecondLife::onCommitProfileImage(const LLUUID& id) { - if (mImageId == id) + if (mSecondLifePic->getImageAssetId() == id) return; std::function callback = [id](bool result) @@ -1814,27 +1734,19 @@ void LLPanelProfileSecondLife::onCommitProfileImage(const LLUUID& id) if (!saveAgentUserInfoCoro("sl_image_id", id, callback)) return; - mImageId = id; - if (mImageId == LLUUID::null) - { - mSecondLifePic->setValue("Generic_Person_Large"); - } - else - { - mSecondLifePic->setValue(mImageId); - } + mSecondLifePic->setValue(id); LLFloater *floater = mFloaterProfileTextureHandle.get(); if (floater) { LLFloaterProfileTexture * texture_view = dynamic_cast(floater); - if (mImageId == LLUUID::null) + if (id == LLUUID::null) { texture_view->resetAsset(); } else { - texture_view->loadAsset(mImageId); + texture_view->loadAsset(id); } } } @@ -1996,7 +1908,7 @@ LLPanelProfileFirstLife::~LLPanelProfileFirstLife() BOOL LLPanelProfileFirstLife::postBuild() { mDescriptionEdit = getChild("fl_description_edit"); - mPicture = getChild("real_world_pic"); + mPicture = getChild("real_world_pic"); mUploadPhoto = getChild("fl_upload_image"); mChangePhoto = getChild("fl_change_image"); @@ -2031,7 +1943,7 @@ void LLPanelProfileFirstLife::setProfileImageUploading(bool loading) { mUploadPhoto->setEnabled(!loading); mChangePhoto->setEnabled(!loading); - mRemovePhoto->setEnabled(!loading && mImageId.notNull()); + mRemovePhoto->setEnabled(!loading && mPicture->getImageAssetId().notNull()); LLLoadingIndicator* indicator = getChild("image_upload_indicator"); indicator->setVisible(loading); @@ -2048,7 +1960,6 @@ void LLPanelProfileFirstLife::setProfileImageUploading(bool loading) void LLPanelProfileFirstLife::setProfileImageUploaded(const LLUUID &image_asset_id) { mPicture->setValue(image_asset_id); - mImageId = image_asset_id; setProfileImageUploading(false); } @@ -2062,7 +1973,7 @@ void LLPanelProfileFirstLife::commitUnsavedChanges() void LLPanelProfileFirstLife::onUploadPhoto() { - (new LLProfileImagePicker(PROFILE_IMAGE_FL, new LLHandle(getHandle())))->getFile(); + (new LLProfileImagePicker(PROFILE_IMAGE_FL, new LLHandle(LLPanel::getHandle())))->getFile(); LLFloater* floaterp = mFloaterTexturePickerHandle.get(); if (floaterp) @@ -2085,9 +1996,9 @@ void LLPanelProfileFirstLife::onChangePhoto() getWindow()->setCursor(UI_CURSOR_WAIT); LLFloaterTexturePicker* texture_floaterp = new LLFloaterTexturePicker( this, - mImageId, + mPicture->getImageAssetId(), LLUUID::null, - mImageId, + mPicture->getImageAssetId(), FALSE, FALSE, "SELECT PHOTO", @@ -2134,23 +2045,15 @@ void LLPanelProfileFirstLife::onRemovePhoto() void LLPanelProfileFirstLife::onCommitPhoto(const LLUUID& id) { - if (mImageId == id) + if (mPicture->getImageAssetId() == id) return; if (!saveAgentUserInfoCoro("fl_image_id", id)) return; - mImageId = id; - if (mImageId.notNull()) - { - mPicture->setValue(mImageId); - } - else - { - mPicture->setValue("Generic_Person_Large"); - } + mPicture->setValue(id); - mRemovePhoto->setEnabled(mImageId.notNull()); + mRemovePhoto->setEnabled(id.notNull()); } void LLPanelProfileFirstLife::setDescriptionText(const std::string &text) @@ -2201,16 +2104,7 @@ void LLPanelProfileFirstLife::processProperties(const LLAvatarData* avatar_data) { setDescriptionText(avatar_data->fl_about_text); - mImageId = avatar_data->fl_image_id; - - if (mImageId.notNull()) - { - mPicture->setValue(mImageId); - } - else - { - mPicture->setValue("Generic_Person_Large"); - } + mPicture->setValue(avatar_data->fl_image_id); setLoaded(); } @@ -2218,8 +2112,7 @@ void LLPanelProfileFirstLife::processProperties(const LLAvatarData* avatar_data) void LLPanelProfileFirstLife::resetData() { setDescriptionText(std::string()); - mPicture->setValue("Generic_Person_Large"); - mImageId = LLUUID::null; + mPicture->setValue(LLUUID::null); mUploadPhoto->setVisible(getSelfProfile()); mChangePhoto->setVisible(getSelfProfile()); @@ -2236,7 +2129,7 @@ void LLPanelProfileFirstLife::setLoaded() { mDescriptionEdit->setEnabled(TRUE); mPicture->setEnabled(TRUE); - mRemovePhoto->setEnabled(mImageId.notNull()); + mRemovePhoto->setEnabled(mPicture->getImageAssetId().notNull()); } } diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h index 221a576a65..3760fe11d7 100644 --- a/indra/newview/llpanelprofile.h +++ b/indra/newview/llpanelprofile.h @@ -58,9 +58,9 @@ class LLTextBase; class LLMenuButton; class LLLineEditor; class LLTextEditor; -class LLThumbnailCtrl; class LLPanelProfileClassifieds; class LLPanelProfilePicks; +class LLProfileImageCtrl; class LLViewerFetchedTexture; @@ -137,13 +137,6 @@ protected: void fillAgeData(const LLAvatarData* avatar_data); void onImageLoaded(BOOL success, LLViewerFetchedTexture *imagep); - static void onImageLoaded(BOOL success, - LLViewerFetchedTexture *src_vi, - LLImageRaw* src, - LLImageRaw* aux_src, - S32 discard_level, - BOOL final, - void* userdata); /** * Displays avatar's online status if possible. @@ -186,7 +179,7 @@ private: LLGroupList* mGroupList; LLComboBox* mShowInSearchCombo; LLComboBox* mHideAgeCombo; - LLThumbnailCtrl* mSecondLifePic; + LLProfileImageCtrl* mSecondLifePic; LLPanel* mSecondLifePicLayout; LLTextEditor* mDescriptionEdit; LLMenuButton* mAgentActionMenuButton; @@ -209,8 +202,6 @@ private: bool mAllowPublish; bool mHideAge; std::string mDescriptionText; - LLUUID mImageId; - boost::signals2::connection mAvatarNameCacheConnection; }; @@ -259,7 +250,7 @@ private: * Panel for displaying Avatar's first life related info. */ class LLPanelProfileFirstLife - : public LLPanelProfilePropertiesProcessorTab + : public LLPanelProfilePropertiesProcessorTab { public: LLPanelProfileFirstLife(); @@ -293,7 +284,7 @@ protected: void onDiscardDescriptionChanges(); LLTextEditor* mDescriptionEdit; - LLThumbnailCtrl* mPicture; + LLProfileImageCtrl* mPicture; LLButton* mUploadPhoto; LLButton* mChangePhoto; LLButton* mRemovePhoto; @@ -303,7 +294,6 @@ protected: LLHandle mFloaterTexturePickerHandle; std::string mCurrentDescription; - LLUUID mImageId; bool mHasUnsavedChanges; }; diff --git a/indra/newview/skins/default/xui/en/floater_profile_texture.xml b/indra/newview/skins/default/xui/en/floater_profile_texture.xml index 3b351a3325..7c2dc11e7d 100644 --- a/indra/newview/skins/default/xui/en/floater_profile_texture.xml +++ b/indra/newview/skins/default/xui/en/floater_profile_texture.xml @@ -27,7 +27,7 @@ follows="left|top" auto_resize="true" layout="topleft"> - - -