diff options
| author | Rider Linden <rider@lindenlab.com> | 2015-06-04 17:36:24 -0700 | 
|---|---|---|
| committer | Rider Linden <rider@lindenlab.com> | 2015-06-04 17:36:24 -0700 | 
| commit | d0d58c41b48f8a2a0e18610b577059ee8419be5c (patch) | |
| tree | 459c65b14aab1ced1e55c6051ce7650528ab4236 | |
| parent | d034c4f2445eb3095bd17aef421c367bb913af39 (diff) | |
Default headers added.
Group manager finished conversion.
Outfit folders coverted.
| -rw-r--r-- | indra/llmessage/llcorehttputil.cpp | 38 | ||||
| -rw-r--r-- | indra/llmessage/llcorehttputil.h | 9 | ||||
| -rwxr-xr-x | indra/newview/llgroupmgr.cpp | 223 | ||||
| -rwxr-xr-x | indra/newview/llgroupmgr.h | 9 | ||||
| -rwxr-xr-x | indra/newview/llinventorymodel.cpp | 115 | ||||
| -rwxr-xr-x | indra/newview/llinventorymodel.h | 22 | 
6 files changed, 193 insertions, 223 deletions
| diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index c4a7e9040a..1fd7e7be2e 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -37,6 +37,8 @@  #include "llsdserialize.h"  #include "reader.h"  +#include "message.h" // for getting the port +  using namespace LLCore; @@ -243,11 +245,10 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons          result = LLSD::emptyMap();          LL_WARNS()              << "\n--------------------------------------------------------------------------\n" -            << " Error[" << status.toULong() << "] cannot access url '" << response->getRequestURL() +            << " Error[" << status.getType() << "] cannot access url '" << response->getRequestURL()              << "' because " << status.toString()              << "\n--------------------------------------------------------------------------"              << LL_ENDL; -      }      else      { @@ -578,8 +579,10 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque      LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,      HttpCoroHandler::ptr_t &handler)  { -    //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL;      HttpRequestPumper pumper(request); + +    checkDefaultHeaders(headers); +      // The HTTPCoroHandler does not self delete, so retrieval of a the contained       // pointer from the smart pointer is safe in this case.      LLCore::HttpHandle hhandle = requestPostWithLLSD(request, @@ -623,8 +626,10 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque      LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,      HttpCoroHandler::ptr_t &handler)  { -    //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL;      HttpRequestPumper pumper(request); + +    checkDefaultHeaders(headers); +      // The HTTPCoroHandler does not self delete, so retrieval of a the contained       // pointer from the smart pointer is safe in this case.      LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, mPriority, url, rawbody.get(), @@ -658,8 +663,10 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpReques      LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,      HttpCoroHandler::ptr_t &handler)  { -    //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL;      HttpRequestPumper pumper(request); + +    checkDefaultHeaders(headers); +      // The HTTPCoroHandler does not self delete, so retrieval of a the contained       // pointer from the smart pointer is safe in this case.      LLCore::HttpHandle hhandle = requestPutWithLLSD(request, @@ -713,8 +720,9 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques      LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,       HttpCoroHandler::ptr_t &handler)  { -    //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL;      HttpRequestPumper pumper(request); +    checkDefaultHeaders(headers); +      // The HTTPCoroHandler does not self delete, so retrieval of a the contained       // pointer from the smart pointer is safe in this case.      LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, mPriority, @@ -747,8 +755,9 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq      const std::string & url, LLCore::HttpOptions::ptr_t &options,       LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler)  { -    //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL;      HttpRequestPumper pumper(request); + +    checkDefaultHeaders(headers);      // The HTTPCoroHandler does not self delete, so retrieval of a the contained       // pointer from the smart pointer is safe in this case.      LLCore::HttpHandle hhandle = request->requestDelete(mPolicyId, mPriority, @@ -766,6 +775,21 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq      return results;  } +void HttpCoroutineAdapter::checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers) +{ +    if (!headers) +        headers.reset(new LLCore::HttpHeaders); +    if (!headers->find(HTTP_OUT_HEADER_ACCEPT)) +    { +        headers->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_LLSD_XML); +    } + +    if (!headers->find("X-SecondLife-UDP-Listen-Port") && gMessageSystem) +    { +        headers->append("X-SecondLife-UDP-Listen-Port", llformat("%d", gMessageSystem->mPort)); +    } +} +  void HttpCoroutineAdapter::cancelYieldingOperation()  { diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 53c8112395..e6c9d2463c 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -286,6 +286,13 @@ private:  /// will be automatically pumped and the method will return with an LLSD describing  /// the result of the operation.  See HttpCoroHandler for a description of the   /// decoration done to the returned LLSD. +///  +/// Posting through the adapter will automatically add the following headers to  +/// the request if they have not been previously specified in a supplied  +/// HttpHeaders object: +///     "Accept=application/llsd+xml" +///     "X-SecondLife-UDP-Listen-Port=###" +///       class HttpCoroutineAdapter  {  public: @@ -467,6 +474,8 @@ private:      static void trivialGetCoro(LLCoros::self& self, std::string url, completionCallback_t success, completionCallback_t failure);      static void trivialPostCoro(LLCoros::self& self, std::string url, LLSD postData, completionCallback_t success, completionCallback_t failure); +    void checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers); +      std::string                     mAdapterName;      LLCore::HttpRequest::priority_t mPriority;      LLCore::HttpRequest::policy_t   mPolicyId; diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 21220507e7..0852104ba7 100755 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -1862,120 +1862,94 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id,  	group_datap->mMemberVersion.generate();  } -#if 1 -// Responder class for capability group management -class GroupBanDataResponder : public LLHTTPClient::Responder +void LLGroupMgr::getGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId)  { -public: -	GroupBanDataResponder(const LLUUID& gropup_id, BOOL force_refresh=false); -	virtual ~GroupBanDataResponder() {} -	virtual void httpSuccess(); -	virtual void httpFailure(); -private: -	LLUUID mGroupID; -	BOOL mForceRefresh; -}; +    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); -GroupBanDataResponder::GroupBanDataResponder(const LLUUID& gropup_id, BOOL force_refresh) : -	mGroupID(gropup_id), -	mForceRefresh(force_refresh) -{} +    std::string finalUrl = url + "?group_id=" + groupId.asString(); -void GroupBanDataResponder::httpFailure() -{ -	LL_WARNS("GrpMgr") << "Error receiving group member data [status:"  -		<< mStatus << "]: " << mContent << LL_ENDL; -} +    LLSD result = httpAdapter->getAndYield(self, httpRequest, finalUrl); -void GroupBanDataResponder::httpSuccess() -{ -	if (mContent.has("ban_list")) -	{ -		// group ban data received -		LLGroupMgr::processGroupBanRequest(mContent); -	} -	else if (mForceRefresh) -	{ -		// no ban data received, refreshing data after successful operation  -		LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_GET, mGroupID); -	} +    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); +    }  } -#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) +void LLGroupMgr::postGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, +    U32 action, uuid_vec_t banList, bool update)  {      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::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders, false); +    LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions, false); + +    httpOptions->setFollowRedirects(false); + +    httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); +      std::string finalUrl = url + "?group_id=" + groupId.asString(); -    EBanRequestAction currAction = action; +    LLSD postData = LLSD::emptyMap(); +    postData["ban_action"] = (LLSD::Integer)action; +    // Add our list of potential banned residents to the list +    postData["ban_ids"] = LLSD::emptyArray(); +    LLSD banEntry; -    do +    uuid_vec_t::const_iterator it = banList.begin(); +    for (; it != banList.end(); ++it)      { -        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); -} +        banEntry = (*it); +        postData["ban_ids"].append(banEntry); +    } -#endif +    LL_WARNS() << "post: " << ll_pretty_print_sd(postData) << LL_ENDL; +    LLSD result = httpAdapter->postAndYield(self, httpRequest, finalUrl, postData, httpOptions, httpHeaders); + +    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; +    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + +    if (!status) +    { +        LL_WARNS("GrpMgr") << "Error posting group member data " << LL_ENDL; +        return; +    } + +    if (result.has("ban_list")) +    { +        result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); +        // group ban data received +        processGroupBanRequest(result); +    } + +    if (update) +    { +        getGroupBanRequestCoro(self, url, groupId); +    } +}  void LLGroupMgr::sendGroupBanRequest(	EBanRequestType request_type,   										const LLUUID& group_id,   										U32 ban_action, /* = BAN_NO_ACTION */ -										const std::vector<LLUUID> ban_list) /* = std::vector<LLUUID>() */ +										const std::vector<LLUUID> &ban_list) /* = std::vector<LLUUID>() */  {  	LLViewerRegion* currentRegion = gAgent.getRegion();  	if(!currentRegion) @@ -1998,59 +1972,24 @@ void LLGroupMgr::sendGroupBanRequest(	EBanRequestType request_type,  		return;  	} -#if 0 +    U32 action = ban_action & ~BAN_UPDATE; +    bool update = ((ban_action & BAN_UPDATE) == BAN_UPDATE); -    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) +    switch (request_type)      { -        ban_entry = (*iter); -        body["ban_ids"].append(ban_entry); +    case REQUEST_GET: +        LLCoros::instance().launch("LLGroupMgr::getGroupBanRequestCoro", +            boost::bind(&LLGroupMgr::getGroupBanRequestCoro, this, _1, cap_url, group_id)); +        break; +    case REQUEST_POST: +        LLCoros::instance().launch("LLGroupMgr::postGroupBanRequestCoro", +            boost::bind(&LLGroupMgr::postGroupBanRequestCoro, this, _1, cap_url, group_id,  +            action, ban_list, update)); +        break; +    case REQUEST_PUT: +    case REQUEST_DEL: +        break;      } - -    LLCoros::instance().launch("LLGroupMgr::groupBanRequestCoro", -        boost::bind(&LLGroupMgr::groupBanRequestCoro, this, _1, cap_url, group_id, -        static_cast<LLGroupMgr::EBanRequestAction>(ban_action), body)); - -//     LLCoros::instance().launch("LLGroupMgr::groupBanRequestCoro", -//         boost::bind(&LLGroupMgr::groupBanRequestCoro, this, _1, cap_url, group_id,  -//                 static_cast<LLGroupMgr::EBanRequestAction>(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); -	// 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); -	} - -	LLHTTPClient::ResponderPtr grp_ban_responder = new GroupBanDataResponder(group_id, ban_action & BAN_UPDATE); -	switch(request_type) -	{ -	case REQUEST_GET: -		LLHTTPClient::get(cap_url, grp_ban_responder); -		break; -	case REQUEST_POST: -		LLHTTPClient::post(cap_url, body, grp_ban_responder); -		break; -	case REQUEST_PUT: -	case REQUEST_DEL: -		break; -	} -#endif  }  void LLGroupMgr::processGroupBanRequest(const LLSD& content) diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index f41a637917..1163923eff 100755 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -402,7 +402,7 @@ public:  	void sendGroupBanRequest(EBanRequestType request_type,   									const LLUUID& group_id,	  									U32 ban_action = BAN_NO_ACTION, -									const uuid_vec_t ban_list = uuid_vec_t()); +									const uuid_vec_t &ban_list = uuid_vec_t());  	void sendCapGroupMembersRequest(const LLUUID& group_id); @@ -428,13 +428,12 @@ 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); +    void getGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId); +    void postGroupBanRequestCoro(LLCoros::self& self, std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update); +      static void processGroupBanRequest(const LLSD& content);  	void notifyObservers(LLGroupChange gc); diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index f92332dea5..6d21dd4ba7 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -524,59 +524,6 @@ const LLUUID LLInventoryModel::findLibraryCategoryUUIDForType(LLFolderType::ETyp  	return findCategoryUUIDForTypeInRoot(preferred_type, create_folder, gInventory.getLibraryRootFolderID());  } -class LLCreateInventoryCategoryResponder : public LLHTTPClient::Responder -{ -	LOG_CLASS(LLCreateInventoryCategoryResponder); -public: -	LLCreateInventoryCategoryResponder(LLInventoryModel* model,  -									   boost::optional<inventory_func_type> callback): -		mModel(model), -		mCallback(callback)  -	{ -	} -	 -protected: -	virtual void httpFailure() -	{ -		LL_WARNS(LOG_INV) << dumpResponse() << LL_ENDL; -	} -	 -	virtual void httpSuccess() -	{ -		//Server has created folder. -		const LLSD& content = getContent(); -		if (!content.isMap() || !content.has("folder_id")) -		{ -			failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); -			return; -		} -		LLUUID category_id = content["folder_id"].asUUID(); -		 -		LL_DEBUGS(LOG_INV) << ll_pretty_print_sd(content) << LL_ENDL; -		// Add the category to the internal representation -		LLPointer<LLViewerInventoryCategory> cat = -		new LLViewerInventoryCategory( category_id,  -									  content["parent_id"].asUUID(), -									  (LLFolderType::EType)content["type"].asInteger(), -									  content["name"].asString(),  -									  gAgent.getID() ); -		cat->setVersion(LLViewerInventoryCategory::VERSION_INITIAL); -		cat->setDescendentCount(0); -		LLInventoryModel::LLCategoryUpdate update(cat->getParentUUID(), 1); -		mModel->accountForUpdate(update); -		mModel->updateCategory(cat); - -		if (mCallback) -		{ -			mCallback.get()(category_id); -		} -	} -	 -private: -	boost::optional<inventory_func_type> mCallback; -	LLInventoryModel* mModel; -}; -  // Convenience function to create a new category. You could call  // updateCategory() with a newly generated UUID category, but this  // version will take care of details like what the name should be @@ -584,7 +531,7 @@ private:  LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,  										   LLFolderType::EType preferred_type,  										   const std::string& pname, -										   boost::optional<inventory_func_type> callback) +										   inventory_func_type callback)  {  	LLUUID id; @@ -616,7 +563,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,  	if ( viewer_region )  		url = viewer_region->getCapability("CreateInventoryCategory"); -	if (!url.empty() && callback.get_ptr()) +	if (!url.empty() && callback)  	{  		//Let's use the new capability. @@ -630,11 +577,8 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,  		request["payload"] = body;  		LL_DEBUGS(LOG_INV) << "create category request: " << ll_pretty_print_sd(request) << LL_ENDL; -		//		viewer_region->getCapAPI().post(request); -		LLHTTPClient::post( -			url, -			body, -			new LLCreateInventoryCategoryResponder(this, callback) ); +        LLCoros::instance().launch("LLInventoryModel::createNewCategoryCoro", +            boost::bind(&LLInventoryModel::createNewCategoryCoro, this, _1, url, body, callback));  		return LLUUID::null;  	} @@ -663,6 +607,57 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,  	return id;  } +void LLInventoryModel::createNewCategoryCoro(LLCoros::self& self, std::string url, LLSD postData, inventory_func_type callback) +{ +    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); +    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t +        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("createNewCategoryCoro", httpPolicy)); +    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); +    LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); +     + +    httpOpts->setWantHeaders(true); + +    LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; + +    LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); + +    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; +    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + +    if (!status) +    { +        LL_WARNS() << "HTTP failure attempting to create category." << LL_ENDL; +        return; +    } + +    if (!result.has("folder_id")) +    { +        LL_WARNS() << "Malformed response contents" << ll_pretty_print_sd(result) << LL_ENDL; +        return; +    } + +    LLUUID categoryId = result["folder_id"].asUUID(); + +    // Add the category to the internal representation +    LLPointer<LLViewerInventoryCategory> cat = new LLViewerInventoryCategory(categoryId, +        result["parent_id"].asUUID(), (LLFolderType::EType)result["type"].asInteger(), +        result["name"].asString(), gAgent.getID()); + +    cat->setVersion(LLViewerInventoryCategory::VERSION_INITIAL); +    cat->setDescendentCount(0); +    LLInventoryModel::LLCategoryUpdate update(cat->getParentUUID(), 1); +     +    accountForUpdate(update); +    updateCategory(cat); + +    if (callback) +    { +        callback(categoryId); +    } + +} +  // This is optimized for the case that we just want to know whether a  // category has any immediate children meeting a condition, without  // needing to recurse or build up any lists. diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index ac336e347c..26ee06535a 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -46,6 +46,8 @@  #include "httpoptions.h"  #include "httpheaders.h"  #include "httphandler.h" +#include "lleventcoro.h" +#include "llcoros.h"  class LLInventoryObserver;  class LLInventoryObject; @@ -207,14 +209,14 @@ private:   **/  	//-------------------------------------------------------------------- -	// Descendents +	// Descendants  	//--------------------------------------------------------------------  public: -	// Make sure we have the descendents in the structure.  Returns true +	// Make sure we have the descendants in the structure.  Returns true  	// if a fetch was performed.  	bool fetchDescendentsOf(const LLUUID& folder_id) const; -	// Return the direct descendents of the id provided.Set passed +	// Return the direct descendants of the id provided.Set passed  	// in values to NULL if the call fails.  	//    NOTE: The array provided points straight into the guts of  	//    this object, and should only be used for read operations, since @@ -223,10 +225,10 @@ public:  								cat_array_t*& categories,  								item_array_t*& items) const; -	// Compute a hash of direct descendent names (for detecting child name changes) +	// Compute a hash of direct descendant names (for detecting child name changes)  	LLMD5 hashDirectDescendentNames(const LLUUID& cat_id) const; -	// Starting with the object specified, add its descendents to the +	// Starting with the object specified, add its descendants to the  	// array provided, but do not add the inventory object specified  	// by id. There is no guaranteed order.   	//    NOTE: Neither array will be erased before adding objects to it.  @@ -340,7 +342,7 @@ public:  	U32 updateItem(const LLViewerInventoryItem* item, U32 mask = 0);  	// Change an existing item with the matching id or add -	// the category. No notifcation will be sent to observers. This +	// the category. No notification will be sent to observers. This  	// method will only generate network traffic if the item had to be  	// reparented.  	//    NOTE: In usage, you will want to perform cache accounting @@ -378,7 +380,7 @@ public:  								   bool update_parent_version = true,  								   bool do_notify_observers = true); -	// Update model after all descendents removed from server. +	// Update model after all descendants removed from server.  	void onDescendentsPurgedFromServer(const LLUUID& object_id, bool fix_broken_links = true);  	// Update model after an existing item gets updated on server. @@ -409,7 +411,7 @@ public:  	// Changes items order by insertion of the item identified by src_item_id  	// before (or after) the item identified by dest_item_id. Both items must exist in items array.  	// Sorting is stored after method is finished. Only src_item_id is moved before (or after) dest_item_id. -	// The parameter "insert_before" controls on which side of dest_item_id src_item_id gets rensinserted. +	// The parameter "insert_before" controls on which side of dest_item_id src_item_id gets reinserted.  	static void updateItemsOrder(LLInventoryModel::item_array_t& items,   								 const LLUUID& src_item_id,   								 const LLUUID& dest_item_id, @@ -433,7 +435,7 @@ public:  	LLUUID createNewCategory(const LLUUID& parent_id,  							 LLFolderType::EType preferred_type,  							 const std::string& name, -							 boost::optional<inventory_func_type> callback = boost::optional<inventory_func_type>()); +							 inventory_func_type callback = NULL);  protected:  	// Internal methods that add inventory and make sure that all of  	// the internal data structures are consistent. These methods @@ -441,6 +443,8 @@ protected:  	// instance will take over the memory management from there.  	void addCategory(LLViewerInventoryCategory* category);  	void addItem(LLViewerInventoryItem* item); + +    void createNewCategoryCoro(LLCoros::self& self, std::string url, LLSD postData, inventory_func_type callback);  /**                    Mutators   **                                                                            ** | 
