From ff121254b29ea628472faf1eda06058f06c050d1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 22 May 2015 09:27:33 -0700 Subject: Removed dead HTTP client adapter code Partial conversion of group manager clean up some debug code in web profiles. --- indra/newview/llgroupmgr.cpp | 183 ++++++++++++++++++++++++++++++----------- indra/newview/llgroupmgr.h | 18 +++- indra/newview/llwebprofile.cpp | 24 +----- 3 files changed, 153 insertions(+), 72 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 56e671d902..21220507e7 100755 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -53,6 +53,7 @@ #include "lltrans.h" #include "llviewerregion.h" #include +#include "llcorehttputil.h" #if LL_MSVC #pragma warning(push) @@ -768,9 +769,9 @@ void LLGroupMgrGroupData::removeBanEntry(const LLUUID& ban_id) // LLGroupMgr // -LLGroupMgr::LLGroupMgr() +LLGroupMgr::LLGroupMgr(): + mMemberRequestInFlight(false) { - mLastGroupMembersRequestFrame = 0; } LLGroupMgr::~LLGroupMgr() @@ -1861,7 +1862,7 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, group_datap->mMemberVersion.generate(); } - +#if 1 // Responder class for capability group management class GroupBanDataResponder : public LLHTTPClient::Responder { @@ -1900,6 +1901,77 @@ void GroupBanDataResponder::httpSuccess() } } +#else +//void LLGroupMgr::groupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, +// LLGroupMgr::EBanRequestAction action, uuid_vec_t banList) +void LLGroupMgr::groupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, + LLGroupMgr::EBanRequestAction action, LLSD body) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + std::string finalUrl = url + "?group_id=" + groupId.asString(); + + EBanRequestAction currAction = action; + + do + { + LLSD result; + + if (currAction & (BAN_CREATE | BAN_DELETE)) // these two actions result in POSTS + { // build the post data. +// LLSD postData = LLSD::emptyMap(); +// +// postData["ban_action"] = (LLSD::Integer)(currAction & ~BAN_UPDATE); +// // Add our list of potential banned residents to the list +// postData["ban_ids"] = LLSD::emptyArray(); +// +// LLSD banEntry; +// for (uuid_vec_t::const_iterator it = banList.begin(); it != banList.end(); ++it) +// { +// banEntry = (*it); +// postData["ban_ids"].append(banEntry); +// } +// +// result = httpAdapter->postAndYield(self, httpRequest, finalUrl, postData); + + result = httpAdapter->postAndYield(self, httpRequest, finalUrl, body); + } + else + { + result = httpAdapter->getAndYield(self, httpRequest, finalUrl); + } + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS("GrpMgr") << "Error receiving group member data " << LL_ENDL; + return; + } + + if (result.has("ban_list")) + { + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + // group ban data received + processGroupBanRequest(result); + } + + if (currAction & BAN_UPDATE) + { + currAction = BAN_NO_ACTION; + continue; + } + break; + } while (true); +} + +#endif + + void LLGroupMgr::sendGroupBanRequest( EBanRequestType request_type, const LLUUID& group_id, U32 ban_action, /* = BAN_NO_ACTION */ @@ -1925,7 +1997,32 @@ void LLGroupMgr::sendGroupBanRequest( EBanRequestType request_type, { return; } - cap_url += "?group_id=" + group_id.asString(); + +#if 0 + + LLSD body = LLSD::emptyMap(); + body["ban_action"] = (LLSD::Integer)(ban_action & ~BAN_UPDATE); + // Add our list of potential banned residents to the list + body["ban_ids"] = LLSD::emptyArray(); + LLSD ban_entry; + + uuid_vec_t::const_iterator iter = ban_list.begin(); + for (; iter != ban_list.end(); ++iter) + { + ban_entry = (*iter); + body["ban_ids"].append(ban_entry); + } + + LLCoros::instance().launch("LLGroupMgr::groupBanRequestCoro", + boost::bind(&LLGroupMgr::groupBanRequestCoro, this, _1, cap_url, group_id, + static_cast(ban_action), body)); + +// LLCoros::instance().launch("LLGroupMgr::groupBanRequestCoro", +// boost::bind(&LLGroupMgr::groupBanRequestCoro, this, _1, cap_url, group_id, +// static_cast(ban_action), ban_list)); + +#else + cap_url += "?group_id=" + group_id.asString(); LLSD body = LLSD::emptyMap(); body["ban_action"] = (LLSD::Integer)(ban_action & ~BAN_UPDATE); @@ -1953,9 +2050,9 @@ void LLGroupMgr::sendGroupBanRequest( EBanRequestType request_type, case REQUEST_DEL: break; } +#endif } - void LLGroupMgr::processGroupBanRequest(const LLSD& content) { // Did we get anything in content? @@ -1992,45 +2089,42 @@ void LLGroupMgr::processGroupBanRequest(const LLSD& content) LLGroupMgr::getInstance()->notifyObservers(GC_BANLIST); } +void LLGroupMgr::groupMembersRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + mMemberRequestInFlight = true; -// Responder class for capability group management -class GroupMemberDataResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(GroupMemberDataResponder); -public: - GroupMemberDataResponder() {} - virtual ~GroupMemberDataResponder() {} + LLSD postData = LLSD::emptyMap(); + postData["group_id"] = groupId; -private: - /* virtual */ void httpSuccess(); - /* virtual */ void httpFailure(); - LLSD mMemberData; -}; + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); -void GroupMemberDataResponder::httpFailure() -{ - LL_WARNS("GrpMgr") << "Error receiving group member data " - << dumpResponse() << LL_ENDL; -} + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -void GroupMemberDataResponder::httpSuccess() -{ - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - LLGroupMgr::processCapGroupMembersRequest(content); -} + if (!status) + { + LL_WARNS("GrpMgr") << "Error receiving group member data " << LL_ENDL; + mMemberRequestInFlight = false; + return; + } + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + LLGroupMgr::processCapGroupMembersRequest(result); + mMemberRequestInFlight = false; +} -// static void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) { + static U32 lastGroupMemberRequestFrame = 0; + // Have we requested the information already this frame? - if(mLastGroupMembersRequestFrame == gFrameCount) + if ((lastGroupMemberRequestFrame == gFrameCount) || (mMemberRequestInFlight)) return; LLViewerRegion* currentRegion = gAgent.getRegion(); @@ -2059,20 +2153,13 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) return; } - // Post to our service. Add a body containing the group_id. - LLSD body = LLSD::emptyMap(); - body["group_id"] = group_id; - - LLHTTPClient::ResponderPtr grp_data_responder = new GroupMemberDataResponder(); - - // This could take a while to finish, timeout after 5 minutes. - LLHTTPClient::post(cap_url, body, grp_data_responder, LLSD(), 300); + lastGroupMemberRequestFrame = gFrameCount; - mLastGroupMembersRequestFrame = gFrameCount; + LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", + boost::bind(&LLGroupMgr::groupMembersRequestCoro, this, _1, cap_url, group_id)); } -// static void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) { // Did we get anything in content? @@ -2089,7 +2176,7 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) LLUUID group_id = content["group_id"].asUUID(); - LLGroupMgrGroupData* group_datap = LLGroupMgr::getInstance()->getGroupData(group_id); + LLGroupMgrGroupData* group_datap = getGroupData(group_id); if(!group_datap) { LL_WARNS("GrpMgr") << "Received incorrect, possibly stale, group or request id" << LL_ENDL; @@ -2183,7 +2270,7 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) // TODO: // Refactor to reduce multiple calls for data we already have. if(group_datap->mTitles.size() < 1) - LLGroupMgr::getInstance()->sendGroupTitlesRequest(group_id); + sendGroupTitlesRequest(group_id); group_datap->mMemberDataComplete = true; @@ -2192,11 +2279,11 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) if (group_datap->mPendingRoleMemberRequest || !group_datap->mRoleMemberDataComplete) { group_datap->mPendingRoleMemberRequest = false; - LLGroupMgr::getInstance()->sendGroupRoleMembersRequest(group_id); + sendGroupRoleMembersRequest(group_id); } group_datap->mChanged = TRUE; - LLGroupMgr::getInstance()->notifyObservers(GC_MEMBER_DATA); + notifyObservers(GC_MEMBER_DATA); } diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index 2e94e8d9a0..f41a637917 100755 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -32,6 +32,8 @@ #include #include #include +#include "lleventcoro.h" +#include "llcoros.h" // Forward Declarations class LLMessageSystem; @@ -362,6 +364,7 @@ public: BAN_UPDATE = 4 }; + public: LLGroupMgr(); ~LLGroupMgr(); @@ -396,15 +399,13 @@ public: static void sendGroupMemberEjects(const LLUUID& group_id, uuid_vec_t& member_ids); - static void sendGroupBanRequest(EBanRequestType request_type, + void sendGroupBanRequest(EBanRequestType request_type, const LLUUID& group_id, U32 ban_action = BAN_NO_ACTION, const uuid_vec_t ban_list = uuid_vec_t()); - static void processGroupBanRequest(const LLSD& content); void sendCapGroupMembersRequest(const LLUUID& group_id); - static void processCapGroupMembersRequest(const LLSD& content); void cancelGroupRoleChanges(const LLUUID& group_id); @@ -427,6 +428,15 @@ public: void clearGroupData(const LLUUID& group_id); private: + friend class GroupBanDataResponder; + + void groupMembersRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId); + void processCapGroupMembersRequest(const LLSD& content); + + //void groupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, EBanRequestAction action, uuid_vec_t banList); + void groupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, EBanRequestAction action, LLSD postBody); + static void processGroupBanRequest(const LLSD& content); + void notifyObservers(LLGroupChange gc); void notifyObserver(const LLUUID& group_id, LLGroupChange gc); void addGroup(LLGroupMgrGroupData* group_datap); @@ -442,7 +452,7 @@ private: typedef std::map observer_map_t; observer_map_t mParticularObservers; - S32 mLastGroupMembersRequestFrame; + bool mMemberRequestInFlight; }; diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp index 3d371e629f..df5f4e3588 100755 --- a/indra/newview/llwebprofile.cpp +++ b/indra/newview/llwebprofile.cpp @@ -131,10 +131,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointerappend(HTTP_OUT_HEADER_COOKIE, getAuthCookie()); httpHeaders->remove(HTTP_OUT_HEADER_CONTENT_TYPE); httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "multipart/form-data; boundary=" + boundary); @@ -155,11 +152,6 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointerpostAndYield(self, httpRequest, uploadUrl, body, httpOpts, httpHeaders); - { - std::ostringstream ostm; - LLSDSerialize::toPrettyXML(result, ostm); - LL_WARNS("Snapshots") << ostm.str() << LL_ENDL; - } body.reset(); httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -173,7 +165,7 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointerappend(HTTP_OUT_HEADER_COOKIE, getAuthCookie()); const std::string& redirUrl = resultHeaders[HTTP_IN_HEADER_LOCATION].asStringRef(); @@ -198,16 +190,10 @@ void LLWebProfile::uploadImageCoro(LLCoros::self& self, LLPointer