diff options
author | Don Kjer <don@lindenlab.com> | 2013-08-09 14:52:54 -0700 |
---|---|---|
committer | Don Kjer <don@lindenlab.com> | 2013-08-09 14:52:54 -0700 |
commit | c1af1a692a6bd0f3cdfb3f49cc2451717481b685 (patch) | |
tree | 14932943b15060b91a8ee6dfdb6e1cc6172e0cb7 | |
parent | 3ed3b88892adb4234c375d2d6bd5f0d2da5566c7 (diff) |
Routing link creating through AISv3 when available.
-rwxr-xr-x | indra/newview/llaisapi.cpp | 37 | ||||
-rwxr-xr-x | indra/newview/llaisapi.h | 9 | ||||
-rwxr-xr-x | indra/newview/llviewerinventory.cpp | 65 |
3 files changed, 79 insertions, 32 deletions
diff --git a/indra/newview/llaisapi.cpp b/indra/newview/llaisapi.cpp index f8c9447b17..73aaebc050 100755 --- a/indra/newview/llaisapi.cpp +++ b/indra/newview/llaisapi.cpp @@ -100,20 +100,9 @@ void AISCommand::httpSuccess() /*virtual*/ void AISCommand::httpFailure() { - const LLSD& content = getContent(); + LL_WARNS("Inventory") << dumpResponse() << LL_ENDL; S32 status = getStatus(); - const std::string& reason = getReason(); const LLSD& headers = getResponseHeaders(); - if (!content.isMap()) - { - LL_DEBUGS("Inventory") << "Malformed response contents " << content - << " status " << status << " reason " << reason << LL_ENDL; - } - else - { - LL_DEBUGS("Inventory") << "failed with content: " << ll_pretty_print_sd(content) - << " status " << status << " reason " << reason << LL_ENDL; - } mRetryPolicy->onFailure(status, headers); F32 seconds_to_wait; if (mRetryPolicy->shouldRetry(seconds_to_wait)) @@ -276,6 +265,30 @@ UpdateCategoryCommand::UpdateCategoryCommand(const LLUUID& item_id, setCommandFunc(cmd); } +CreateInventoryCommand::CreateInventoryCommand(const LLUUID& parent_id, + const LLSD& new_inventory, + LLPointer<LLInventoryCallback> callback): + mNewInventory(new_inventory), + AISCommand(callback) +{ + std::string cap; + if (!getInvCap(cap)) + { + llwarns << "No cap found" << llendl; + return; + } + LLUUID tid; + tid.generate(); + std::string url = cap + std::string("/category/") + parent_id.asString() + "?tid=" + tid.asString(); + LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; + LLCurl::ResponderPtr responder = this; + LLSD headers; + headers["Content-Type"] = "application/llsd+xml"; + F32 timeout = HTTP_REQUEST_EXPIRY_SECS; + command_func_type cmd = boost::bind(&LLHTTPClient::post, url, mNewInventory, responder, headers, timeout); + setCommandFunc(cmd); +} + SlamFolderCommand::SlamFolderCommand(const LLUUID& folder_id, const LLSD& contents, LLPointer<LLInventoryCallback> callback): mContents(contents), AISCommand(callback) diff --git a/indra/newview/llaisapi.h b/indra/newview/llaisapi.h index f4e219e9e6..5d31129a16 100755 --- a/indra/newview/llaisapi.h +++ b/indra/newview/llaisapi.h @@ -130,6 +130,15 @@ protected: /* virtual */ bool getResponseUUID(const LLSD& content, LLUUID& id); }; +class CreateInventoryCommand: public AISCommand +{ +public: + CreateInventoryCommand(const LLUUID& parent_id, const LLSD& new_inventory, LLPointer<LLInventoryCallback> callback); + +private: + LLSD mNewInventory; +}; + class AISUpdate { public: diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 33186a5a88..dc17da9009 100755 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1110,6 +1110,7 @@ void link_inventory_array(const LLUUID& category, #endif LLInventoryObject::const_object_list_t::const_iterator it = baseobj_array.begin(); LLInventoryObject::const_object_list_t::const_iterator end = baseobj_array.end(); + LLSD links = LLSD::emptyArray(); for (; it != end; ++it) { const LLInventoryObject* baseobj = *it; @@ -1133,7 +1134,6 @@ void link_inventory_array(const LLUUID& category, continue; } - LLUUID transaction_id; LLInventoryType::EType inv_type = LLInventoryType::IT_NONE; LLAssetType::EType asset_type = LLAssetType::AT_NONE; std::string new_desc; @@ -1171,25 +1171,14 @@ void link_inventory_array(const LLUUID& category, } } - LLMessageSystem* msg = gMessageSystem; - msg->newMessageFast(_PREHASH_LinkInventoryItem); - msg->nextBlock(_PREHASH_AgentData); - { - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - } - msg->nextBlock(_PREHASH_InventoryBlock); - { - msg->addU32Fast(_PREHASH_CallbackID, gInventoryCallbacks.registerCB(cb)); - msg->addUUIDFast(_PREHASH_FolderID, category); - msg->addUUIDFast(_PREHASH_TransactionID, transaction_id); - msg->addUUIDFast(_PREHASH_OldItemID, linkee_id); - msg->addS8Fast(_PREHASH_Type, (S8)asset_type); - msg->addS8Fast(_PREHASH_InvType, (S8)inv_type); - msg->addStringFast(_PREHASH_Name, baseobj->getName()); - msg->addStringFast(_PREHASH_Description, new_desc); - } - gAgent.sendReliableMessage(); + LLSD link = LLSD::emptyMap(); + link["linked_id"] = linkee_id; + link["type"] = (S8)asset_type; + link["inv_type"] = (S8)inv_type; + link["name"] = baseobj->getName(); + link["desc"] = new_desc; + links.append(link); + #ifndef LL_RELEASE_FOR_DOWNLOAD LL_DEBUGS("Inventory") << "Linking Object [ name:" << baseobj->getName() << " UUID:" << baseobj->getUUID() @@ -1197,6 +1186,42 @@ void link_inventory_array(const LLUUID& category, << " UUID:" << category << " ] " << LL_ENDL; #endif } + + bool ais_ran = false; + if (AISCommand::isAPIAvailable()) + { + LLSD new_inventory = LLSD::emptyMap(); + new_inventory["links"] = links; + LLPointer<AISCommand> cmd_ptr = new CreateInventoryCommand(category, new_inventory, cb); + ais_ran = cmd_ptr->run_command(); + } + + if (!ais_ran) + { + LLMessageSystem* msg = gMessageSystem; + for (LLSD::array_iterator iter = links.beginArray(); iter != links.endArray(); ++iter ) + { + msg->newMessageFast(_PREHASH_LinkInventoryItem); + msg->nextBlock(_PREHASH_AgentData); + { + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + } + msg->nextBlock(_PREHASH_InventoryBlock); + { + LLSD link = (*iter); + msg->addU32Fast(_PREHASH_CallbackID, gInventoryCallbacks.registerCB(cb)); + msg->addUUIDFast(_PREHASH_FolderID, category); + msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); + msg->addUUIDFast(_PREHASH_OldItemID, link["linked_id"].asUUID()); + msg->addS8Fast(_PREHASH_Type, link["type"].asInteger()); + msg->addS8Fast(_PREHASH_InvType, link["inv_type"].asInteger()); + msg->addStringFast(_PREHASH_Name, link["name"].asString()); + msg->addStringFast(_PREHASH_Description, link["desc"].asString()); + } + gAgent.sendReliableMessage(); + } + } } |