diff options
Diffstat (limited to 'indra/newview/llpanelprofile.cpp')
-rw-r--r-- | indra/newview/llpanelprofile.cpp | 1137 |
1 files changed, 416 insertions, 721 deletions
diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 8114e05a94..08605f7cf4 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -46,6 +46,7 @@ #include "lltexteditor.h" #include "lltexturectrl.h" #include "lltoggleablemenu.h" +#include "lltooldraganddrop.h" #include "llgrouplist.h" #include "llurlaction.h" @@ -71,7 +72,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 @@ -102,216 +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<LLPanel>(PANEL_PROFILE_VIEW, TRUE); - LLPanelProfile *panel_profile = dynamic_cast<LLPanelProfile*>(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->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(); - } - - panel = floater_profile->findChild<LLPanel>(PANEL_SECONDLIFE, TRUE); - LLPanelProfileSecondLife *panel_sl = dynamic_cast<LLPanelProfileSecondLife*>(panel); - if (panel_sl) - { - panel_sl->processProfileProperties(avatar_data); - } - - panel = floater_profile->findChild<LLPanel>(PANEL_WEB, TRUE); - LLPanelProfileWeb *panel_web = dynamic_cast<LLPanelProfileWeb*>(panel); - if (panel_web) - { - panel_web->setLoaded(); - } - - panel = floater_profile->findChild<LLPanel>(PANEL_FIRSTLIFE, TRUE); - LLPanelProfileFirstLife *panel_first = dynamic_cast<LLPanelProfileFirstLife*>(panel); - if (panel_first) - { - panel_first->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<LLPanel>(PANEL_PICKS, TRUE); - LLPanelProfilePicks *panel_picks = dynamic_cast<LLPanelProfilePicks*>(panel); - if (panel_picks) - { - // Refresh pick limit before processing - 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<LLPanel>(PANEL_NOTES, TRUE); - LLPanelProfileNotes *panel_notes = dynamic_cast<LLPanelProfileNotes*>(panel); - if (panel_notes) - { - panel_notes->processProperties(&avatar_notes); - } -} - -//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<void(bool)> 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<LLPanel> *handle) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -322,7 +112,7 @@ LLUUID post_profile_image(std::string cap_url, const LLSD &first_data, std::stri LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setFollowRedirects(true); - + LLSD result = httpAdapter->postAndSuspend(httpRequest, cap_url, first_data, httpOpts, httpHeaders); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; @@ -348,7 +138,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); @@ -472,22 +261,22 @@ void post_profile_image_coro(std::string cap_url, EProfileImageType type, std::s class LLProfileHandler : public LLCommandHandler { public: - // requires trusted browser to trigger - LLProfileHandler() : LLCommandHandler("profile", UNTRUSTED_THROTTLE) { } + // requires trusted browser to trigger + LLProfileHandler() : LLCommandHandler("profile", UNTRUSTED_THROTTLE) { } - bool handle(const LLSD& params, + bool handle(const LLSD& params, const LLSD& query_map, const std::string& grid, LLMediaCtrl* web) - { - if (params.size() < 1) return false; - std::string agent_name = params[0]; - LL_INFOS() << "Profile, agent_name " << agent_name << LL_ENDL; - std::string url = getProfileURL(agent_name); - LLWeb::loadURLInternal(url); - - return true; - } + { + if (params.size() < 1) return false; + std::string agent_name = params[0]; + LL_INFOS() << "Profile, agent_name " << agent_name << LL_ENDL; + std::string url = getProfileURL(agent_name); + LLWeb::loadURLInternal(url); + + return true; + } }; LLProfileHandler gProfileHandler; @@ -498,8 +287,8 @@ LLProfileHandler gProfileHandler; class LLAgentHandler : public LLCommandHandler { public: - // requires trusted browser to trigger - LLAgentHandler() : LLCommandHandler("agent", UNTRUSTED_THROTTLE) { } + // requires trusted browser to trigger + LLAgentHandler() : LLCommandHandler("agent", UNTRUSTED_THROTTLE) { } virtual bool canHandleUntrusted( const LLSD& params, @@ -526,111 +315,111 @@ public: return false; } - bool handle(const LLSD& params, + bool handle(const LLSD& params, const LLSD& query_map, const std::string& grid, LLMediaCtrl* web) - { - if (params.size() < 2) return false; - LLUUID avatar_id; - if (!avatar_id.set(params[0], FALSE)) - { - return false; - } - - const std::string verb = params[1].asString(); - if (verb == "about") - { - LLAvatarActions::showProfile(avatar_id); - return true; - } - - if (verb == "inspect") - { - LLFloaterReg::showInstance("inspect_avatar", LLSD().with("avatar_id", avatar_id)); - return true; - } - - if (verb == "im") - { - LLAvatarActions::startIM(avatar_id); - return true; - } - - if (verb == "pay") - { - if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableAvatarPay")) - { - LLNotificationsUtil::add("NoAvatarPay", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); - return true; - } - - LLAvatarActions::pay(avatar_id); - return true; - } - - if (verb == "offerteleport") - { - LLAvatarActions::offerTeleport(avatar_id); - return true; - } - - if (verb == "requestfriend") - { - LLAvatarActions::requestFriendshipDialog(avatar_id); - return true; - } - - if (verb == "removefriend") - { - LLAvatarActions::removeFriendDialog(avatar_id); - return true; - } - - if (verb == "mute") - { - if (! LLAvatarActions::isBlocked(avatar_id)) - { - LLAvatarActions::toggleBlock(avatar_id); - } - return true; - } - - if (verb == "unmute") - { - if (LLAvatarActions::isBlocked(avatar_id)) - { - LLAvatarActions::toggleBlock(avatar_id); - } - return true; - } - - if (verb == "block") - { - if (params.size() > 2) - { - const std::string object_name = LLURI::unescape(params[2].asString()); - LLMute mute(avatar_id, object_name, LLMute::OBJECT); - LLMuteList::getInstance()->add(mute); - LLPanelBlockedList::showPanelAndSelect(mute.mID); - } - return true; - } - - if (verb == "unblock") - { - if (params.size() > 2) - { - const std::string object_name = params[2].asString(); - LLMute mute(avatar_id, object_name, LLMute::OBJECT); - LLMuteList::getInstance()->remove(mute); - } - return true; - } + { + if (params.size() < 2) return false; + LLUUID avatar_id; + if (!avatar_id.set(params[0], false)) + { + return false; + } + + const std::string verb = params[1].asString(); + if (verb == "about") + { + LLAvatarActions::showProfile(avatar_id); + return true; + } + + if (verb == "inspect") + { + LLFloaterReg::showInstance("inspect_avatar", LLSD().with("avatar_id", avatar_id)); + return true; + } + + if (verb == "im") + { + LLAvatarActions::startIM(avatar_id); + return true; + } + + if (verb == "pay") + { + if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableAvatarPay")) + { + LLNotificationsUtil::add("NoAvatarPay", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); + return true; + } + + LLAvatarActions::pay(avatar_id); + return true; + } + + if (verb == "offerteleport") + { + LLAvatarActions::offerTeleport(avatar_id); + return true; + } + + if (verb == "requestfriend") + { + LLAvatarActions::requestFriendshipDialog(avatar_id); + return true; + } + + if (verb == "removefriend") + { + LLAvatarActions::removeFriendDialog(avatar_id); + return true; + } + + if (verb == "mute") + { + if (! LLAvatarActions::isBlocked(avatar_id)) + { + LLAvatarActions::toggleBlock(avatar_id); + } + return true; + } + + if (verb == "unmute") + { + if (LLAvatarActions::isBlocked(avatar_id)) + { + LLAvatarActions::toggleBlock(avatar_id); + } + return true; + } + + if (verb == "block") + { + if (params.size() > 2) + { + const std::string object_name = LLURI::unescape(params[2].asString()); + LLMute mute(avatar_id, object_name, LLMute::OBJECT); + LLMuteList::getInstance()->add(mute); + LLPanelBlockedList::showPanelAndSelect(mute.mID); + } + return true; + } + + if (verb == "unblock") + { + if (params.size() > 2) + { + const std::string object_name = params[2].asString(); + LLMute mute(avatar_id, object_name, LLMute::OBJECT); + LLMuteList::getInstance()->remove(mute); + } + return true; + } // reportAbuse is here due to convoluted avatar handling // in LLScrollListCtrl and LLTextBase - if (verb == "reportAbuse" && web == NULL) + if (verb == "reportAbuse" && web == NULL) { LLAvatarName av_name; if (LLAvatarNameCache::get(avatar_id, &av_name)) @@ -643,8 +432,8 @@ public: } return true; } - return false; - } + return false; + } }; LLAgentHandler gAgentHandler; @@ -660,7 +449,7 @@ class LLFloaterProfilePermissions public: LLFloaterProfilePermissions(LLView * owner, const LLUUID &avatar_id); ~LLFloaterProfilePermissions(); - BOOL postBuild() override; + bool postBuild() override; void onOpen(const LLSD& key) override; void draw() override; void changed(U32 mask) override; // LLFriendObserver @@ -690,7 +479,7 @@ private: bool mHasUnsavedPermChanges; LLHandle<LLView> mOwnerHandle; - boost::signals2::connection mAvatarNameCacheConnection; + boost::signals2::connection mAvatarNameCacheConnection; }; LLFloaterProfilePermissions::LLFloaterProfilePermissions(LLView * owner, const LLUUID &avatar_id) @@ -712,7 +501,7 @@ LLFloaterProfilePermissions::~LLFloaterProfilePermissions() } } -BOOL LLFloaterProfilePermissions::postBuild() +bool LLFloaterProfilePermissions::postBuild() { mDescription = getChild<LLTextBase>("perm_description"); mOnlineStatus = getChild<LLCheckBoxCtrl>("online_check"); @@ -727,7 +516,7 @@ BOOL LLFloaterProfilePermissions::postBuild() mOkBtn->setCommitCallback([this](LLUICtrl*, void*) { onApplyRights(); }, nullptr); mCancelBtn->setCommitCallback([this](LLUICtrl*, void*) { onCancel(); }, nullptr); - return TRUE; + return true; } void LLFloaterProfilePermissions::onOpen(const LLSD& key) @@ -778,11 +567,11 @@ void LLFloaterProfilePermissions::fillRightsData() { S32 rights = relation->getRightsGrantedTo(); - BOOL see_online = LLRelationship::GRANT_ONLINE_STATUS & rights ? TRUE : FALSE; + bool see_online = LLRelationship::GRANT_ONLINE_STATUS & rights; mOnlineStatus->setValue(see_online); mMapRights->setEnabled(see_online); - mMapRights->setValue(LLRelationship::GRANT_MAP_LOCATION & rights ? TRUE : FALSE); - mEditObjectRights->setValue(LLRelationship::GRANT_MODIFY_OBJECTS & rights ? TRUE : FALSE); + mMapRights->setValue(LLRelationship::GRANT_MAP_LOCATION & rights); + mEditObjectRights->setValue(LLRelationship::GRANT_MODIFY_OBJECTS & rights); } else { @@ -797,7 +586,7 @@ void LLFloaterProfilePermissions::rightsConfirmationCallback(const LLSD& notific S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option != 0) // canceled { - mEditObjectRights->setValue(mEditObjectRights->getValue().asBoolean() ? FALSE : TRUE); + mEditObjectRights->setValue(!mEditObjectRights->getValue().asBoolean()); } else { @@ -823,7 +612,7 @@ void LLFloaterProfilePermissions::onCommitSeeOnlineRights() if (relation) { S32 rights = relation->getRightsGrantedTo(); - mMapRights->setValue(LLRelationship::GRANT_MAP_LOCATION & rights ? TRUE : FALSE); + mMapRights->setValue(LLRelationship::GRANT_MAP_LOCATION & rights); } else { @@ -833,7 +622,7 @@ void LLFloaterProfilePermissions::onCommitSeeOnlineRights() } else { - mMapRights->setValue(FALSE); + mMapRights->setValue(false); } mHasUnsavedPermChanges = true; } @@ -898,11 +687,12 @@ void LLFloaterProfilePermissions::onCancel() // LLPanelProfileSecondLife LLPanelProfileSecondLife::LLPanelProfileSecondLife() - : LLPanelProfileTab() + : LLPanelProfilePropertiesProcessorTab() , mAvatarNameCacheConnection() , mHasUnsavedDescriptionChanges(false) , mWaitingForImageUpload(false) , mAllowPublish(false) + , mHideAge(false) { } @@ -913,10 +703,7 @@ LLPanelProfileSecondLife::~LLPanelProfileSecondLife() LLAvatarTracker::instance().removeParticularFriendObserver(getAvatarId(), this); } - if (LLVoiceClient::instanceExists()) - { - LLVoiceClient::getInstance()->removeObserver((LLVoiceClientStatusObserver*)this); - } + LLVoiceClient::removeObserver((LLVoiceClientStatusObserver*)this); if (mAvatarNameCacheConnection.connected()) { @@ -924,11 +711,12 @@ LLPanelProfileSecondLife::~LLPanelProfileSecondLife() } } -BOOL LLPanelProfileSecondLife::postBuild() +bool LLPanelProfileSecondLife::postBuild() { mGroupList = getChild<LLGroupList>("group_list"); mShowInSearchCombo = getChild<LLComboBox>("show_in_search"); - mSecondLifePic = getChild<LLThumbnailCtrl>("2nd_life_pic"); + mHideAgeCombo = getChild<LLComboBox>("hide_age"); + mSecondLifePic = getChild<LLProfileImageCtrl>("2nd_life_pic"); mSecondLifePicLayout = getChild<LLPanel>("image_panel"); mDescriptionEdit = getChild<LLTextEditor>("sl_description_edit"); mAgentActionMenuButton = getChild<LLMenuButton>("agent_actions_menu"); @@ -942,6 +730,7 @@ BOOL LLPanelProfileSecondLife::postBuild() mCantEditObjectsIcon = getChild<LLIconCtrl>("cant_edit_objects"); mShowInSearchCombo->setCommitCallback([this](LLUICtrl*, void*) { onShowInSearchCallback(); }, 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); @@ -956,7 +745,7 @@ BOOL LLPanelProfileSecondLife::postBuild() mCantEditObjectsIcon->setMouseUpCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask) { onShowAgentPermissionsDialog(); }); mSecondLifePic->setMouseUpCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask) { onShowAgentProfileTexture(); }); - return TRUE; + return true; } void LLPanelProfileSecondLife::onOpen(const LLSD& key) @@ -967,7 +756,7 @@ void LLPanelProfileSecondLife::onOpen(const LLSD& key) LLUUID avatar_id = getAvatarId(); - BOOL own_profile = getSelfProfile(); + bool own_profile = getSelfProfile(); mGroupList->setShowNone(!own_profile); @@ -1004,7 +793,7 @@ void LLPanelProfileSecondLife::onOpen(const LLSD& key) if (!own_profile) { - mVoiceStatus = LLAvatarActions::canCall() && (LLAvatarActions::isFriend(avatar_id) ? LLAvatarTracker::instance().isBuddyOnline(avatar_id) : TRUE); + mVoiceStatus = LLAvatarActions::canCall() && (LLAvatarActions::isFriend(avatar_id) ? LLAvatarTracker::instance().isBuddyOnline(avatar_id) : true); updateOnlineStatus(); fillRightsData(); } @@ -1012,24 +801,49 @@ void LLPanelProfileSecondLife::onOpen(const LLSD& key) mAvatarNameCacheConnection = LLAvatarNameCache::get(getAvatarId(), boost::bind(&LLPanelProfileSecondLife::onAvatarNameCache, this, _1, _2)); } -void LLPanelProfileSecondLife::updateData() + +bool LLPanelProfileSecondLife::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) { - LLUUID avatar_id = getAvatarId(); - if (!getStarted() && avatar_id.notNull()) + // Try children first + if (LLPanelProfileTab::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg) + && *accept != ACCEPT_NO) { - setIsLoading(); + return true; + } - std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP); - if (!cap_url.empty()) - { - LLCoros::instance().launch("requestAgentUserInfoCoro", - boost::bind(request_avatar_properties_coro, cap_url, avatar_id)); - } - else - { - LL_WARNS() << "Failed to update profile data, no cap found" << LL_ENDL; - } + // No point sharing with own profile + if (getSelfProfile()) + { + return false; + } + + // Exclude fields that look like they are editable. + S32 child_x = 0; + S32 child_y = 0; + if (localPointToOtherView(x, y, &child_x, &child_y, mDescriptionEdit) + && mDescriptionEdit->pointInView(child_x, child_y)) + { + return false; + } + + if (localPointToOtherView(x, y, &child_x, &child_y, mGroupList) + && mGroupList->pointInView(child_x, child_y)) + { + return false; } + + // Share + LLToolDragAndDrop::handleGiveDragAndDrop(getAvatarId(), + LLUUID::null, + drop, + cargo_type, + cargo_data, + accept); + return true; } void LLPanelProfileSecondLife::refreshName() @@ -1046,10 +860,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(); @@ -1070,9 +883,21 @@ void LLPanelProfileSecondLife::resetData() mCanEditObjectsIcon->setEnabled(false); mCantEditObjectsIcon->setEnabled(false); - childSetVisible("partner_layout", FALSE); - childSetVisible("badge_layout", FALSE); - childSetVisible("partner_spacer_layout", TRUE); + childSetVisible("partner_layout", false); + childSetVisible("badge_layout", false); + childSetVisible("partner_spacer_layout", true); +} + +void LLPanelProfileSecondLife::processProperties(void* data, EAvatarProcessorType type) +{ + if (APT_PROPERTIES == type) + { + LLAvatarData* avatar_data = static_cast<LLAvatarData*>(data); + if (avatar_data && getAvatarId() == avatar_data->avatar_id) + { + processProfileProperties(avatar_data); + } + } } void LLPanelProfileSecondLife::processProfileProperties(const LLAvatarData* avatar_data) @@ -1094,22 +919,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() @@ -1143,36 +964,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<LLPanel>(getHandle()), - NULL, - FALSE); - } LLFloater *floater = mFloaterProfileTextureHandle.get(); if (floater) { LLFloaterProfileTexture * texture_view = dynamic_cast<LLFloaterProfileTexture*>(floater); - if (mImageId.notNull()) - { - texture_view->loadAsset(mImageId); - } - else - { - texture_view->resetAsset(); - } + texture_view->loadAsset(mSecondLifePic->getImageAssetId()); } setProfileImageUploading(false); @@ -1216,42 +1013,16 @@ 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); - 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<LLPanel>(getHandle()), - NULL, - FALSE); - } + mSecondLifePic->setValue(avatar_data->image_id); if (getSelfProfile()) { mAllowPublish = avatar_data->flags & AVATAR_ALLOW_PUBLISH; - mShowInSearchCombo->setValue((BOOL)mAllowPublish); + mShowInSearchCombo->setValue(mAllowPublish); } } @@ -1260,7 +1031,7 @@ void LLPanelProfileSecondLife::fillPartnerData(const LLAvatarData* avatar_data) LLTextBox* partner_text_ctrl = getChild<LLTextBox>("partner_link"); if (avatar_data->partner_id.notNull()) { - childSetVisible("partner_layout", TRUE); + childSetVisible("partner_layout", true); LLStringUtil::format_map_t args; args["[LINK]"] = LLSLURL("agent", avatar_data->partner_id, "inspect").getSLURLString(); std::string partner_text = getString("partner_text", args); @@ -1268,7 +1039,7 @@ void LLPanelProfileSecondLife::fillPartnerData(const LLAvatarData* avatar_data) } else { - childSetVisible("partner_layout", FALSE); + childSetVisible("partner_layout", false); } } @@ -1281,7 +1052,7 @@ void LLPanelProfileSecondLife::fillAccountStatus(const LLAvatarData* avatar_data std::string caption_text = getString("CaptionTextAcctInfo", args); getChild<LLUICtrl>("account_info")->setValue(caption_text); - const S32 LINDEN_EMPLOYEE_INDEX = 3; + constexpr S32 LINDEN_EMPLOYEE_INDEX = 3; LLDate sl_release; sl_release.fromYMDHMS(2003, 6, 23, 0, 0, 0); std::string customer_lower = avatar_data->customer_type; @@ -1290,48 +1061,48 @@ void LLPanelProfileSecondLife::fillAccountStatus(const LLAvatarData* avatar_data { getChild<LLUICtrl>("badge_icon")->setValue("Profile_Badge_Linden"); getChild<LLUICtrl>("badge_text")->setValue(getString("BadgeLinden")); - childSetVisible("badge_layout", TRUE); - childSetVisible("partner_spacer_layout", FALSE); + childSetVisible("badge_layout", true); + childSetVisible("partner_spacer_layout", false); } else if (avatar_data->born_on < sl_release) { getChild<LLUICtrl>("badge_icon")->setValue("Profile_Badge_Beta"); getChild<LLUICtrl>("badge_text")->setValue(getString("BadgeBeta")); - childSetVisible("badge_layout", TRUE); - childSetVisible("partner_spacer_layout", FALSE); + childSetVisible("badge_layout", true); + childSetVisible("partner_spacer_layout", false); } else if (customer_lower == "beta_lifetime") { getChild<LLUICtrl>("badge_icon")->setValue("Profile_Badge_Beta_Lifetime"); getChild<LLUICtrl>("badge_text")->setValue(getString("BadgeBetaLifetime")); - childSetVisible("badge_layout", TRUE); - childSetVisible("partner_spacer_layout", FALSE); + childSetVisible("badge_layout", true); + childSetVisible("partner_spacer_layout", false); } else if (customer_lower == "lifetime") { getChild<LLUICtrl>("badge_icon")->setValue("Profile_Badge_Lifetime"); getChild<LLUICtrl>("badge_text")->setValue(getString("BadgeLifetime")); - childSetVisible("badge_layout", TRUE); - childSetVisible("partner_spacer_layout", FALSE); + childSetVisible("badge_layout", true); + childSetVisible("partner_spacer_layout", false); } else if (customer_lower == "secondlifetime_premium") { getChild<LLUICtrl>("badge_icon")->setValue("Profile_Badge_Premium_Lifetime"); getChild<LLUICtrl>("badge_text")->setValue(getString("BadgePremiumLifetime")); - childSetVisible("badge_layout", TRUE); - childSetVisible("partner_spacer_layout", FALSE); + childSetVisible("badge_layout", true); + childSetVisible("partner_spacer_layout", false); } else if (customer_lower == "secondlifetime_premium_plus") { getChild<LLUICtrl>("badge_icon")->setValue("Profile_Badge_Pplus_Lifetime"); getChild<LLUICtrl>("badge_text")->setValue(getString("BadgePremiumPlusLifetime")); - childSetVisible("badge_layout", TRUE); - childSetVisible("partner_spacer_layout", FALSE); + childSetVisible("badge_layout", true); + childSetVisible("partner_spacer_layout", false); } else { - childSetVisible("badge_layout", FALSE); - childSetVisible("partner_spacer_layout", TRUE); + childSetVisible("badge_layout", false); + childSetVisible("partner_spacer_layout", true); } } @@ -1346,7 +1117,7 @@ void LLPanelProfileSecondLife::fillRightsData() // If true - we are viewing friend's profile, enable check boxes and set values. if (relation) { - S32 rights = relation->getRightsGrantedTo(); + const S32 rights = relation->getRightsGrantedTo(); bool can_see_online = LLRelationship::GRANT_ONLINE_STATUS & rights; bool can_see_on_map = LLRelationship::GRANT_MAP_LOCATION & rights; bool can_edit_objects = LLRelationship::GRANT_MODIFY_OBJECTS & rights; @@ -1376,62 +1147,60 @@ 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"); + 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)born_on.secondsSinceEpoch(); + args_name["datetime"] = (S32)avatar_data->born_on.secondsSinceEpoch(); LLStringUtil::format(name_and_date, args_name); getChild<LLUICtrl>("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<LLUICtrl>("user_age")->setValue(register_date); -} - -void LLPanelProfileSecondLife::onImageLoaded(BOOL success, LLViewerFetchedTexture *imagep) -{ - LLRect imageRect = mSecondLifePicLayout->getRect(); - if (!success || imagep->getFullWidth() == imagep->getFullHeight()) + LLUICtrl* userAgeCtrl = getChild<LLUICtrl>("user_age"); + if (hide_age) { - mSecondLifePicLayout->reshape(imageRect.getWidth(), imageRect.getWidth()); + userAgeCtrl->setVisible(false); } else { - // assume 3:4, for sake of firestorm - mSecondLifePicLayout->reshape(imageRect.getWidth(), imageRect.getWidth() * 3 / 4); + 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); } -} - -//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<LLPanel>* handle = (LLHandle<LLPanel>*)userdata; - if (!handle->isDead()) + bool showHideAgeCombo = false; + if (getSelfProfile()) { - LLPanelProfileSecondLife* panel = static_cast<LLPanelProfileSecondLife*>(handle->get()); - if (panel) + if (LLAvatarPropertiesProcessor::getInstance()->isHideAgeSupportedByServer()) { - panel->onImageLoaded(success, src_vi); + 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); + showHideAgeCombo = true; + } } } + mHideAgeCombo->setVisible(showHideAgeCombo); +} - if (final || !success) +void LLPanelProfileSecondLife::onImageLoaded(bool success, LLViewerFetchedTexture *imagep) +{ + LLRect imageRect = mSecondLifePicLayout->getRect(); + if (!success || imagep->getFullWidth() == imagep->getFullHeight()) { - delete handle; + mSecondLifePicLayout->reshape(imageRect.getWidth(), imageRect.getWidth()); + } + else + { + // assume 3:4, for sake of firestorm + mSecondLifePicLayout->reshape(imageRect.getWidth(), imageRect.getWidth() * 3 / 4); } } @@ -1446,14 +1215,14 @@ void LLPanelProfileSecondLife::changed(U32 mask) } // virtual, called by LLVoiceClient -void LLPanelProfileSecondLife::onChange(EStatusType status, const std::string &channelURI, bool proximal) +void LLPanelProfileSecondLife::onChange(EStatusType status, const LLSD& channelInfo, bool proximal) { if(status == STATUS_JOINING || status == STATUS_LEFT_CHANNEL) { return; } - mVoiceStatus = LLAvatarActions::canCall() && (LLAvatarActions::isFriend(getAvatarId()) ? LLAvatarTracker::instance().isBuddyOnline(getAvatarId()) : TRUE); + mVoiceStatus = LLAvatarActions::canCall() && (LLAvatarActions::isFriend(getAvatarId()) ? LLAvatarTracker::instance().isBuddyOnline(getAvatarId()) : true); } void LLPanelProfileSecondLife::setAvatarId(const LLUUID& avatar_id) @@ -1465,7 +1234,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())) { @@ -1478,7 +1247,7 @@ void LLPanelProfileSecondLife::setAvatarId(const LLUUID& avatar_id) void LLPanelProfileSecondLife::updateOnlineStatus() { const LLRelationship* relationship = LLAvatarTracker::instance().getBuddyInfo(getAvatarId()); - if (relationship != NULL) + if (relationship) { // For friend let check if he allowed me to see his status bool online = relationship->isOnline(); @@ -1506,8 +1275,12 @@ void LLPanelProfileSecondLife::setLoaded() if (getSelfProfile()) { - mShowInSearchCombo->setEnabled(TRUE); - mDescriptionEdit->setEnabled(TRUE); + mShowInSearchCombo->setEnabled(true); + if (mHideAgeCombo->getVisible()) + { + mHideAgeCombo->setEnabled(true); + } + mDescriptionEdit->setEnabled(true); } } @@ -1555,11 +1328,11 @@ void LLProfileImagePicker::notify(const std::vector<std::string>& filenames) // generate a temp texture file for coroutine std::string temp_file = gDirUtilp->getTempFilename(); U32 codec = LLImageBase::getCodecFromExtension(gDirUtilp->getExtension(file_path)); - const S32 MAX_DIM = 256; + constexpr S32 MAX_DIM = 256; 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; @@ -1654,7 +1427,7 @@ void LLPanelProfileSecondLife::onCommitMenu(const LLSD& userdata) else if (item_name == "copy_user_id") { LLWString wstr = utf8str_to_wstring(getAvatarId().asString()); - LLClipboard::instance().copyToClipboard(wstr, 0, wstr.size()); + LLClipboard::instance().copyToClipboard(wstr, 0, static_cast<S32>(wstr.size())); } else if (item_name == "agent_permissions") { @@ -1679,7 +1452,7 @@ void LLPanelProfileSecondLife::onCommitMenu(const LLSD& userdata) { wstr = utf8str_to_wstring(av_name.getUserName()); } - LLClipboard::instance().copyToClipboard(wstr, 0, wstr.size()); + LLClipboard::instance().copyToClipboard(wstr, 0, static_cast<S32>(wstr.size())); } else if (item_name == "edit_display_name") { @@ -1695,7 +1468,7 @@ void LLPanelProfileSecondLife::onCommitMenu(const LLSD& userdata) } else if (item_name == "upload_photo") { - (new LLProfileImagePicker(PROFILE_IMAGE_SL, new LLHandle<LLPanel>(getHandle())))->getFile(); + (new LLProfileImagePicker(PROFILE_IMAGE_SL, new LLHandle<LLPanel>(LLPanel::getHandle())))->getFile(); LLFloater* floaterp = mFloaterTexturePickerHandle.get(); if (floaterp) @@ -1770,7 +1543,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; @@ -1817,8 +1590,8 @@ void LLPanelProfileSecondLife::onAvatarNameCacheSetName(const LLUUID& agent_id, void LLPanelProfileSecondLife::setDescriptionText(const std::string &text) { - mSaveDescriptionChanges->setEnabled(FALSE); - mDiscardDescriptionChanges->setEnabled(FALSE); + mSaveDescriptionChanges->setEnabled(false); + mDiscardDescriptionChanges->setEnabled(false); mHasUnsavedDescriptionChanges = false; mDescriptionText = text; @@ -1827,49 +1600,38 @@ void LLPanelProfileSecondLife::setDescriptionText(const std::string &text) void LLPanelProfileSecondLife::onSetDescriptionDirty() { - mSaveDescriptionChanges->setEnabled(TRUE); - mDiscardDescriptionChanges->setEnabled(TRUE); + mSaveDescriptionChanges->setEnabled(true); + mDiscardDescriptionChanges->setEnabled(true); mHasUnsavedDescriptionChanges = true; } 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, nullptr)); - } - else - { - LL_WARNS("AvatarProperties") << "Failed to update profile data, no cap found" << LL_ENDL; - } + + mAllowPublish = value; + saveAgentUserInfoCoro("allow_publish", value); +} + +void LLPanelProfileSecondLife::onHideAgeCallback() +{ + bool value = mHideAgeCombo->getValue().asInteger(); + if (value == mHideAge) + return; + + mHideAge = value; + saveAgentUserInfoCoro("hide_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), nullptr)); - } - 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); + mSaveDescriptionChanges->setEnabled(false); + mDiscardDescriptionChanges->setEnabled(false); mHasUnsavedDescriptionChanges = false; } @@ -1880,7 +1642,7 @@ void LLPanelProfileSecondLife::onDiscardDescriptionChanges() void LLPanelProfileSecondLife::onShowAgentPermissionsDialog() { - LLFloater *floater = mFloaterPermissionsHandle.get(); + LLFloater* floater = mFloaterPermissionsHandle.get(); if (!floater) { LLFloater* parent_floater = gFloaterView->getParentFloater(this); @@ -1889,15 +1651,15 @@ void LLPanelProfileSecondLife::onShowAgentPermissionsDialog() LLFloaterProfilePermissions * perms = new LLFloaterProfilePermissions(parent_floater, getAvatarId()); mFloaterPermissionsHandle = perms->getHandle(); perms->openFloater(); - perms->setVisibleAndFrontmost(TRUE); + perms->setVisibleAndFrontmost(true); parent_floater->addDependentFloater(mFloaterPermissionsHandle); } } else // already open { - floater->setMinimized(FALSE); - floater->setVisibleAndFrontmost(TRUE); + floater->setMinimized(false); + floater->setVisibleAndFrontmost(true); } } @@ -1908,7 +1670,7 @@ void LLPanelProfileSecondLife::onShowAgentProfileTexture() return; } - LLFloater *floater = mFloaterProfileTextureHandle.get(); + LLFloater* floater = mFloaterProfileTextureHandle.get(); if (!floater) { LLFloater* parent_floater = gFloaterView->getParentFloater(this); @@ -1916,16 +1678,16 @@ 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 { texture_view->resetAsset(); } texture_view->openFloater(); - texture_view->setVisibleAndFrontmost(TRUE); + texture_view->setVisibleAndFrontmost(true); parent_floater->addDependentFloater(mFloaterProfileTextureHandle); } @@ -1933,11 +1695,11 @@ void LLPanelProfileSecondLife::onShowAgentProfileTexture() else // already open { LLFloaterProfileTexture * texture_view = dynamic_cast<LLFloaterProfileTexture*>(floater); - texture_view->setMinimized(FALSE); - texture_view->setVisibleAndFrontmost(TRUE); - if (mImageId.notNull()) + texture_view->setMinimized(false); + texture_view->setVisibleAndFrontmost(true); + if (mSecondLifePic->getImageAssetId().notNull()) { - texture_view->loadAsset(mImageId); + texture_view->loadAsset(mSecondLifePic->getImageAssetId()); } else { @@ -1960,15 +1722,15 @@ void LLPanelProfileSecondLife::onShowTexturePicker() getWindow()->setCursor(UI_CURSOR_WAIT); LLFloaterTexturePicker* texture_floaterp = new LLFloaterTexturePicker( this, - mImageId, + mSecondLifePic->getImageAssetId(), LLUUID::null, - mImageId, - FALSE, - FALSE, + mSecondLifePic->getImageAssetId(), + false, + false, "SELECT PHOTO", PERM_NONE, PERM_NONE, - FALSE, + false, NULL, PICK_TEXTURE); @@ -1981,75 +1743,59 @@ void LLPanelProfileSecondLife::onShowTexturePicker() onCommitProfileImage(asset_id); } }); - texture_floaterp->setLocalTextureEnabled(FALSE); - texture_floaterp->setBakeTextureEnabled(FALSE); + texture_floaterp->setLocalTextureEnabled(false); + texture_floaterp->setBakeTextureEnabled(false); texture_floaterp->setCanApply(false, true, false); parent_floater->addDependentFloater(mFloaterTexturePickerHandle); texture_floaterp->openFloater(); - texture_floaterp->setFocus(TRUE); + texture_floaterp->setFocus(true); } } else { - floaterp->setMinimized(FALSE); - floaterp->setVisibleAndFrontmost(TRUE); + floaterp->setMinimized(false); + floaterp->setVisibleAndFrontmost(true); } } void LLPanelProfileSecondLife::onCommitProfileImage(const LLUUID& id) { - if (mImageId == id) - { + if (mSecondLifePic->getImageAssetId() == id) return; - } - std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP); - if (!cap_url.empty()) + std::function<void(bool)> callback = [id](bool result) { - std::function<void(bool)> callback = [id](bool result) + if (result) { - if (result) - { - LLAvatarIconIDCache::getInstance()->add(gAgentID, id); - // Should trigger callbacks in icon controls - LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(gAgentID); - } - }; - LLSD params; - params["sl_image_id"] = id; - LLCoros::instance().launch("putAgentUserInfoCoro", - boost::bind(put_avatar_properties_coro, cap_url, getAvatarId(), params, callback)); - - mImageId = id; - if (mImageId == LLUUID::null) - { - mSecondLifePic->setValue("Generic_Person_Large"); - } - else - { - mSecondLifePic->setValue(mImageId); + LLAvatarIconIDCache::getInstance()->add(gAgentID, id); + // Should trigger callbacks in icon controls (or request Legacy) + LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(gAgentID); } + }; + + if (!saveAgentUserInfoCoro("sl_image_id", id, callback)) + return; - LLFloater *floater = mFloaterProfileTextureHandle.get(); - if (floater) + mSecondLifePic->setValue(id); + + LLFloater* floater = mFloaterProfileTextureHandle.get(); + if (floater) + { + LLFloaterProfileTexture* texture_view = dynamic_cast<LLFloaterProfileTexture*>(floater); + if (texture_view) { - LLFloaterProfileTexture * texture_view = dynamic_cast<LLFloaterProfileTexture*>(floater); - if (mImageId == LLUUID::null) + if (id.isNull()) { texture_view->resetAsset(); } else { - texture_view->loadAsset(mImageId); + texture_view->loadAsset(id); } } } - else - { - LL_WARNS("AvatarProperties") << "Failed to update profile data, no cap found" << LL_ENDL; - } } ////////////////////////////////////////////////////////////////////////// @@ -2057,8 +1803,9 @@ void LLPanelProfileSecondLife::onCommitProfileImage(const LLUUID& id) LLPanelProfileWeb::LLPanelProfileWeb() : LLPanelProfileTab() - , mWebBrowser(NULL) + , mWebBrowser(nullptr) , mAvatarNameCacheConnection() + , mFirstNavigate(false) { } @@ -2079,13 +1826,13 @@ void LLPanelProfileWeb::onOpen(const LLSD& key) mAvatarNameCacheConnection = LLAvatarNameCache::get(getAvatarId(), boost::bind(&LLPanelProfileWeb::onAvatarNameCache, this, _1, _2)); } -BOOL LLPanelProfileWeb::postBuild() +bool LLPanelProfileWeb::postBuild() { mWebBrowser = getChild<LLMediaCtrl>("profile_html"); mWebBrowser->addObserver(this); mWebBrowser->setHomePageUrl("about:blank"); - return TRUE; + return true; } void LLPanelProfileWeb::resetData() @@ -2100,7 +1847,7 @@ void LLPanelProfileWeb::updateData() { setIsLoading(); - mWebBrowser->setVisible(TRUE); + mWebBrowser->setVisible(true); mPerformanceTimer.start(); mWebBrowser->navigateTo(mURLWebProfile, HTTP_CONTENT_TEXT_HTML); } @@ -2137,7 +1884,7 @@ void LLPanelProfileWeb::onCommitLoad(LLUICtrl* ctrl) LLSD::String valstr = ctrl->getValue().asString(); if (valstr.empty()) { - mWebBrowser->setVisible(TRUE); + mWebBrowser->setVisible(true); mPerformanceTimer.start(); mWebBrowser->navigateTo( mURLHome, HTTP_CONTENT_TEXT_HTML ); } @@ -2180,6 +1927,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; @@ -2195,7 +1944,7 @@ void LLPanelProfileWeb::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent e ////////////////////////////////////////////////////////////////////////// LLPanelProfileFirstLife::LLPanelProfileFirstLife() - : LLPanelProfileTab() + : LLPanelProfilePropertiesProcessorTab() , mHasUnsavedChanges(false) { } @@ -2204,10 +1953,10 @@ LLPanelProfileFirstLife::~LLPanelProfileFirstLife() { } -BOOL LLPanelProfileFirstLife::postBuild() +bool LLPanelProfileFirstLife::postBuild() { mDescriptionEdit = getChild<LLTextEditor>("fl_description_edit"); - mPicture = getChild<LLThumbnailCtrl>("real_world_pic"); + mPicture = getChild<LLProfileImageCtrl>("real_world_pic"); mUploadPhoto = getChild<LLButton>("fl_upload_image"); mChangePhoto = getChild<LLButton>("fl_change_image"); @@ -2222,7 +1971,7 @@ BOOL LLPanelProfileFirstLife::postBuild() mDiscardChanges->setCommitCallback([this](LLUICtrl*, void*) { onDiscardDescriptionChanges(); }, nullptr); mDescriptionEdit->setKeystrokeCallback([this](LLTextEditor* caller) { onSetDescriptionDirty(); }); - return TRUE; + return true; } void LLPanelProfileFirstLife::onOpen(const LLSD& key) @@ -2232,7 +1981,7 @@ void LLPanelProfileFirstLife::onOpen(const LLSD& key) if (!getSelfProfile()) { // Otherwise as the only focusable element it will be selected - mDescriptionEdit->setTabStop(FALSE); + mDescriptionEdit->setTabStop(false); } resetData(); @@ -2242,7 +1991,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<LLLoadingIndicator>("image_upload_indicator"); indicator->setVisible(loading); @@ -2259,7 +2008,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); } @@ -2273,7 +2021,7 @@ void LLPanelProfileFirstLife::commitUnsavedChanges() void LLPanelProfileFirstLife::onUploadPhoto() { - (new LLProfileImagePicker(PROFILE_IMAGE_FL, new LLHandle<LLPanel>(getHandle())))->getFile(); + (new LLProfileImagePicker(PROFILE_IMAGE_FL, new LLHandle<LLPanel>(LLPanel::getHandle())))->getFile(); LLFloater* floaterp = mFloaterTexturePickerHandle.get(); if (floaterp) @@ -2296,15 +2044,15 @@ void LLPanelProfileFirstLife::onChangePhoto() getWindow()->setCursor(UI_CURSOR_WAIT); LLFloaterTexturePicker* texture_floaterp = new LLFloaterTexturePicker( this, - mImageId, + mPicture->getImageAssetId(), LLUUID::null, - mImageId, - FALSE, - FALSE, + mPicture->getImageAssetId(), + false, + false, "SELECT PHOTO", PERM_NONE, PERM_NONE, - FALSE, + false, NULL, PICK_TEXTURE); @@ -2317,19 +2065,19 @@ void LLPanelProfileFirstLife::onChangePhoto() onCommitPhoto(asset_id); } }); - texture_floaterp->setLocalTextureEnabled(FALSE); + texture_floaterp->setLocalTextureEnabled(false); texture_floaterp->setCanApply(false, true, false); parent_floater->addDependentFloater(mFloaterTexturePickerHandle); texture_floaterp->openFloater(); - texture_floaterp->setFocus(TRUE); + texture_floaterp->setFocus(true); } } else { - floaterp->setMinimized(FALSE); - floaterp->setVisibleAndFrontmost(TRUE); + floaterp->setMinimized(false); + floaterp->setVisibleAndFrontmost(true); } } @@ -2346,41 +2094,21 @@ void LLPanelProfileFirstLife::onRemovePhoto() void LLPanelProfileFirstLife::onCommitPhoto(const LLUUID& id) { - if (mImageId == id) - { + if (mPicture->getImageAssetId() == 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, nullptr)); + 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()); - } - else - { - LL_WARNS("AvatarProperties") << "Failed to update profile data, no cap found" << LL_ENDL; - } + mRemovePhoto->setEnabled(id.notNull()); } void LLPanelProfileFirstLife::setDescriptionText(const std::string &text) { - mSaveChanges->setEnabled(FALSE); - mDiscardChanges->setEnabled(FALSE); + mSaveChanges->setEnabled(false); + mDiscardChanges->setEnabled(false); mHasUnsavedChanges = false; mCurrentDescription = text; @@ -2389,27 +2117,18 @@ void LLPanelProfileFirstLife::setDescriptionText(const std::string &text) void LLPanelProfileFirstLife::onSetDescriptionDirty() { - mSaveChanges->setEnabled(TRUE); - mDiscardChanges->setEnabled(TRUE); + mSaveChanges->setEnabled(true); + mDiscardChanges->setEnabled(true); mHasUnsavedChanges = true; } 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), nullptr)); - } - 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); + mSaveChanges->setEnabled(false); + mDiscardChanges->setEnabled(false); mHasUnsavedChanges = false; } @@ -2418,20 +2137,23 @@ void LLPanelProfileFirstLife::onDiscardDescriptionChanges() setDescriptionText(mCurrentDescription); } +void LLPanelProfileFirstLife::processProperties(void* data, EAvatarProcessorType type) +{ + if (APT_PROPERTIES == type) + { + LLAvatarData* avatar_data = static_cast<LLAvatarData*>(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); - 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(); } @@ -2439,8 +2161,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()); @@ -2455,9 +2176,9 @@ void LLPanelProfileFirstLife::setLoaded() if (getSelfProfile()) { - mDescriptionEdit->setEnabled(TRUE); - mPicture->setEnabled(TRUE); - mRemovePhoto->setEnabled(mImageId.notNull()); + mDescriptionEdit->setEnabled(true); + mPicture->setEnabled(true); + mRemovePhoto->setEnabled(mPicture->getImageAssetId().notNull()); } } @@ -2466,7 +2187,7 @@ void LLPanelProfileFirstLife::setLoaded() ////////////////////////////////////////////////////////////////////////// LLPanelProfileNotes::LLPanelProfileNotes() -: LLPanelProfileTab() +: LLPanelProfilePropertiesProcessorTab() , mHasUnsavedChanges(false) { @@ -2476,22 +2197,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", - boost::bind(request_avatar_properties_coro, cap_url, avatar_id)); - } - } -} - void LLPanelProfileNotes::commitUnsavedChanges() { if (mHasUnsavedChanges) @@ -2500,7 +2205,7 @@ void LLPanelProfileNotes::commitUnsavedChanges() } } -BOOL LLPanelProfileNotes::postBuild() +bool LLPanelProfileNotes::postBuild() { mNotesEditor = getChild<LLTextEditor>("notes_edit"); mSaveChanges = getChild<LLButton>("notes_save_changes"); @@ -2510,7 +2215,7 @@ BOOL LLPanelProfileNotes::postBuild() mDiscardChanges->setCommitCallback([this](LLUICtrl*, void*) { onDiscardNotesChanges(); }, nullptr); mNotesEditor->setKeystrokeCallback([this](LLTextEditor* caller) { onSetNotesDirty(); }); - return TRUE; + return true; } void LLPanelProfileNotes::onOpen(const LLSD& key) @@ -2522,8 +2227,8 @@ void LLPanelProfileNotes::onOpen(const LLSD& key) void LLPanelProfileNotes::setNotesText(const std::string &text) { - mSaveChanges->setEnabled(FALSE); - mDiscardChanges->setEnabled(FALSE); + mSaveChanges->setEnabled(false); + mDiscardChanges->setEnabled(false); mHasUnsavedChanges = false; mCurrentNotes = text; @@ -2532,27 +2237,18 @@ void LLPanelProfileNotes::setNotesText(const std::string &text) void LLPanelProfileNotes::onSetNotesDirty() { - mSaveChanges->setEnabled(TRUE); - mDiscardChanges->setEnabled(TRUE); + mSaveChanges->setEnabled(true); + mDiscardChanges->setEnabled(true); mHasUnsavedChanges = true; } 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), nullptr)); - } - else - { - LL_WARNS("AvatarProperties") << "Failed to update profile data, no cap found" << LL_ENDL; - } + saveAgentUserInfoCoro("notes", mCurrentNotes); - mSaveChanges->setEnabled(FALSE); - mDiscardChanges->setEnabled(FALSE); + mSaveChanges->setEnabled(false); + mDiscardChanges->setEnabled(false); mHasUnsavedChanges = false; } @@ -2561,10 +2257,22 @@ void LLPanelProfileNotes::onDiscardNotesChanges() setNotesText(mCurrentNotes); } -void LLPanelProfileNotes::processProperties(LLAvatarNotes* avatar_notes) +void LLPanelProfileNotes::processProperties(void* data, EAvatarProcessorType type) +{ + if (APT_PROPERTIES == type) + { + LLAvatarData* avatar_data = static_cast<LLAvatarData*>(data); + if (avatar_data && getAvatarId() == avatar_data->avatar_id) + { + processProperties(avatar_data); + } + } +} + +void LLPanelProfileNotes::processProperties(const LLAvatarData* avatar_data) { - setNotesText(avatar_notes->notes); - mNotesEditor->setEnabled(TRUE); + setNotesText(avatar_data->notes); + mNotesEditor->setEnabled(true); setLoaded(); } @@ -2574,14 +2282,6 @@ void LLPanelProfileNotes::resetData() setNotesText(std::string()); } -void LLPanelProfileNotes::setAvatarId(const LLUUID& avatar_id) -{ - if (avatar_id.notNull()) - { - LLPanelProfileTab::setAvatarId(avatar_id); - } -} - ////////////////////////////////////////////////////////////////////////// // LLPanelProfile @@ -2595,9 +2295,9 @@ LLPanelProfile::~LLPanelProfile() { } -BOOL LLPanelProfile::postBuild() +bool LLPanelProfile::postBuild() { - return TRUE; + return true; } void LLPanelProfile::onTabChange() @@ -2658,12 +2358,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", - boost::bind(request_avatar_properties_coro, cap_url, avatar_id)); - } + LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(getAvatarId()); } } @@ -2689,12 +2384,12 @@ void LLPanelProfile::showPick(const LLUUID& pick_id) bool LLPanelProfile::isPickTabSelected() { - return (mTabContainer->getCurrentPanel() == mPanelPicks); + return (mTabContainer->getCurrentPanel() == mPanelPicks); } bool LLPanelProfile::isNotesTabSelected() { - return (mTabContainer->getCurrentPanel() == mPanelNotes); + return (mTabContainer->getCurrentPanel() == mPanelNotes); } bool LLPanelProfile::hasUnsavedChanges() |