diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index 51e5dcd8d96aa1862511ce914b404752e0d6f27f..ef0064583b2f873d96aa979aae6349a7b610bc83 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -75,8 +75,6 @@ #include "llviewernetwork.h" //LLGridManager #include "llviewerparcelmgr.h" #include "llviewerregion.h" -#include "lltrans.h" -#include "llcallingcard.h" #include "llslurl.h" // IDEVO #include "llsidepanelinventory.h" #include "llavatarname.h" @@ -148,7 +146,9 @@ void LLAvatarActions::requestFriendshipDialog(const LLUUID& id) void LLAvatarActions::removeFriendDialog(const LLUUID& id) { if (id.isNull()) + { return; + } uuid_vec_t ids; ids.push_back(id); @@ -158,8 +158,10 @@ void LLAvatarActions::removeFriendDialog(const LLUUID& id) // static void LLAvatarActions::removeFriendsDialog(const uuid_vec_t& ids) { - if(ids.size() == 0) + if (ids.empty()) + { return; + } LLSD args; std::string msgType; @@ -195,8 +197,9 @@ void LLAvatarActions::removeFriendsDialog(const uuid_vec_t& ids) void LLAvatarActions::offerTeleport(const LLUUID& invitee) { if (invitee.isNull()) + { return; - + } std::vector<LLUUID> ids; ids.push_back(invitee); offerTeleport(ids); @@ -205,9 +208,10 @@ void LLAvatarActions::offerTeleport(const LLUUID& invitee) // static void LLAvatarActions::offerTeleport(const uuid_vec_t& ids) { - if (ids.size() == 0) + if (ids.empty()) + { return; - + } handle_lure(ids); } @@ -227,9 +231,10 @@ static void on_avatar_name_cache_start_im(const LLUUID& agent_id, void LLAvatarActions::startIM(const LLUUID& id) { if (id.isNull() || gAgent.getID() == id) + { return; - -// [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9) + } + // [RLVa:KB] - Checked: 2013-05-09 (RLVa-1.4.9) if (!RlvActions::canStartIM(id)) { make_ui_sound("UISndInvalidOp"); @@ -245,8 +250,9 @@ void LLAvatarActions::startIM(const LLUUID& id) void LLAvatarActions::endIM(const LLUUID& id) { if (id.isNull()) + { return; - + } LLUUID session_id = gIMMgr->computeSessionID(IM_NOTHING_SPECIAL, id); if (session_id != LLUUID::null) { @@ -286,7 +292,7 @@ void LLAvatarActions::startCall(const LLUUID& id) // static void LLAvatarActions::startAdhocCall(const uuid_vec_t& ids, const LLUUID& floater_id) { - if (ids.size() == 0) + if (ids.empty()) { return; } @@ -574,10 +580,11 @@ LLFloater* LLAvatarActions::findProfileFloater(const LLUUID& avatar_id) { LLFloater* profile = nullptr; static LLCachedControl<bool> legacy_profile(gSkinSettings, "LegacyProfile"); - if (legacy_profile) + if (legacy_profile) { profile = LLFloaterReg::findTypedInstance<LLFloaterProfileLegacy>("legacy_profile", LLSD().with("avatar_id", avatar_id)); - else + } else { profile = LLFloaterReg::findTypedInstance<LLFloaterProfile>("profile", LLSD().with("id", avatar_id)); + } return profile; } diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index f6d19dfe9bd2d321a48cd60238da5864d318bb3b..4fdfc6cd39b8eb1ed7e77d0c3f277760794e5a1e 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -62,16 +62,18 @@ #include "llcommandhandler.h" #include "llfloaterprofiletexture.h" #include "llfloaterreg.h" -#include "lltexturectrl.h" +#include "llfloaterblocked.h" +#include "llfloaterreporter.h" #include "llfilepicker.h" #include "llfirstuse.h" #include "llgroupactions.h" #include "lllogchat.h" #include "llmutelist.h" #include "llnotificationsutil.h" -//#include "llpanelblockedlist.h" +#include "llpanelblockedlist.h" #include "llpanelprofileclassifieds.h" #include "llpanelprofilepicks.h" +#include "llprofileimagepicker.h" #include "lltrans.h" #include "llviewercontrol.h" #include "llviewermenu.h" //is_agent_mappable @@ -103,190 +105,178 @@ static const std::string PROFILE_IMAGE_UPLOAD_CAP = "UploadAgentProfileImage"; ////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -// LLWebProfileHandler - -class LLWebProfileHandler : public LLCommandHandler +LLUUID post_profile_image(std::string cap_url, const LLSD &first_data, std::string path_to_image, LLHandle<LLPanel> *handle) { -public: - // requires trusted browser to trigger - LLWebProfileHandler() : LLCommandHandler("profile", UNTRUSTED_THROTTLE) { } + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("post_profile_image_coro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpHeaders::ptr_t httpHeaders; - 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); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + httpOpts->setFollowRedirects(true); - return true; - } -}; -LLWebProfileHandler gWebProfileHandler; -#if 0 // ALCHMERGE -LLProfileHandler gProfileHandler; + LLSD result = httpAdapter->postAndSuspend(httpRequest, cap_url, first_data, httpOpts, httpHeaders); + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -////////////////////////////////////////////////////////////////////////// -// LLAgentHandler + if (!status) + { + // todo: notification? + LL_WARNS("AvatarProperties") << "Failed to get uploader cap " << status.toString() << LL_ENDL; + return LLUUID::null; + } + if (!result.has("uploader")) + { + // todo: notification? + LL_WARNS("AvatarProperties") << "Failed to get uploader cap, response contains no data." << LL_ENDL; + return LLUUID::null; + } + std::string uploader_cap = result["uploader"].asString(); + if (uploader_cap.empty()) + { + LL_WARNS("AvatarProperties") << "Failed to get uploader cap, cap invalid." << LL_ENDL; + return LLUUID::null; + } -class LLAgentHandler : public LLCommandHandler -{ -public: - // requires trusted browser to trigger - LLAgentHandler() : LLCommandHandler("agent", UNTRUSTED_THROTTLE) { } + // 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); + S64 length; - virtual bool canHandleUntrusted( - const LLSD& params, - const LLSD& query_map, - LLMediaCtrl* web, - const std::string& nav_type) { - if (params.size() < 2) + llifstream instream(path_to_image.c_str(), std::iostream::binary | std::iostream::ate); + if (!instream.is_open()) { - return true; // don't block, will fail later + LL_WARNS("AvatarProperties") << "Failed to open file " << path_to_image << LL_ENDL; + return LLUUID::null; } + length = instream.tellg(); + } - if (nav_type == NAV_TYPE_CLICKED - || nav_type == NAV_TYPE_EXTERNAL) - { - return true; - } + uploaderhttpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "application/jp2"); // optional + uploaderhttpHeaders->append(HTTP_OUT_HEADER_CONTENT_LENGTH, llformat("%d", length)); // required! + uploaderhttpOpts->setFollowRedirects(true); - const std::string verb = params[1].asString(); - if (verb == "about" || verb == "inspect" || verb == "reportAbuse") - { - return true; - } - return false; - } + result = httpAdapter->postFileAndSuspend(uploaderhttpRequest, uploader_cap, path_to_image, uploaderhttpOpts, uploaderhttpHeaders); - 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; - } + httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - const std::string verb = params[1].asString(); - if (verb == "about") - { - LLAvatarActions::showProfile(avatar_id); - return true; - } + LL_DEBUGS("AvatarProperties") << result << LL_ENDL; - if (verb == "inspect") - { - LLFloaterReg::showInstance("inspect_avatar", LLSD().with("avatar_id", avatar_id)); - return true; - } + if (!status) + { + LL_WARNS("AvatarProperties") << "Failed to upload image " << status.toString() << LL_ENDL; + return LLUUID::null; + } - if (verb == "im") + if (result["state"].asString() != "complete") + { + if (result.has("message")) { - LLAvatarActions::startIM(avatar_id); - return true; + LL_WARNS("AvatarProperties") << "Failed to upload image, state " << result["state"] << " message: " << result["message"] << LL_ENDL; } - - if (verb == "pay") + else { - if (!LLUI::getInstance()->mSettingGroups["config"]->getBOOL("EnableAvatarPay")) - { - LLNotificationsUtil::add("NoAvatarPay", LLSD(), LLSD(), std::string("SwitchToStandardSkinAndQuit")); - return true; - } - - LLAvatarActions::pay(avatar_id); - return true; + LL_WARNS("AvatarProperties") << "Failed to upload image " << result << LL_ENDL; } + return LLUUID::null; + } - if (verb == "offerteleport") - { - LLAvatarActions::offerTeleport(avatar_id); - return true; - } + return result["new_asset"].asUUID(); +} - if (verb == "requestfriend") - { - LLAvatarActions::requestFriendshipDialog(avatar_id); - return true; - } +void post_profile_image_coro(std::string cap_url, EProfileImageType type, std::string path_to_image, LLHandle<LLPanel> *handle) +{ + LLSD data; + switch (type) + { + case PROFILE_IMAGE_SL: + data["profile-image-asset"] = "sl_image_id"; + break; + case PROFILE_IMAGE_FL: + data["profile-image-asset"] = "fl_image_id"; + break; + } - if (verb == "removefriend") - { - LLAvatarActions::removeFriendDialog(avatar_id); - return true; - } + LLUUID result = post_profile_image(cap_url, data, path_to_image, handle); - if (verb == "mute") + // reset loading indicator + if (!handle->isDead()) + { + switch (type) { - if (! LLAvatarActions::isBlocked(avatar_id)) + case PROFILE_IMAGE_SL: { - LLAvatarActions::toggleBlock(avatar_id); + LLPanelProfileSecondLife* panel = static_cast<LLPanelProfileSecondLife*>(handle->get()); + if (result.notNull()) + { + panel->setProfileImageUploaded(result); + } + else + { + // failure, just stop progress indicator + panel->setProfileImageUploading(false); + } + break; } - return true; - } - - if (verb == "unmute") - { - if (LLAvatarActions::isBlocked(avatar_id)) + case PROFILE_IMAGE_FL: { - LLAvatarActions::toggleBlock(avatar_id); + LLPanelProfileFirstLife* panel = static_cast<LLPanelProfileFirstLife*>(handle->get()); + if (result.notNull()) + { + panel->setProfileImageUploaded(result); + } + else + { + // failure, just stop progress indicator + panel->setProfileImageUploading(false); + } + break; } - 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 (type == PROFILE_IMAGE_SL && result.notNull()) + { + LLAvatarIconIDCache::getInstance()->add(gAgentID, result); + // Should trigger callbacks in icon controls + LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(gAgentID); + } - 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; - } + // Cleanup + LLFile::remove(path_to_image); + delete handle; +} - // reportAbuse is here due to convoluted avatar handling - // in LLScrollListCtrl and LLTextBase - if (verb == "reportAbuse" && web == NULL) - { - LLAvatarName av_name; - if (LLAvatarNameCache::get(avatar_id, &av_name)) - { - LLFloaterReporter::showFromAvatar(avatar_id, av_name.getCompleteName()); - } - else - { - LLFloaterReporter::showFromAvatar(avatar_id, "not avaliable"); - } - return true; - } - return false; +////////////////////////////////////////////////////////////////////////// +// LLWebProfileHandler + +class LLWebProfileHandler : public LLCommandHandler +{ +public: + // requires trusted browser to trigger + LLWebProfileHandler() : LLCommandHandler("profile", UNTRUSTED_THROTTLE) { } + + 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; } }; -LLAgentHandler gAgentHandler; -#endif +LLWebProfileHandler gWebProfileHandler; + ///---------------------------------------------------------------------------- /// LLFloaterProfilePermissions