summaryrefslogtreecommitdiff
path: root/indra/newview/llaisapi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llaisapi.cpp')
-rwxr-xr-xindra/newview/llaisapi.cpp659
1 files changed, 154 insertions, 505 deletions
diff --git a/indra/newview/llaisapi.cpp b/indra/newview/llaisapi.cpp
index 3565c04609..23ea692a16 100755
--- a/indra/newview/llaisapi.cpp
+++ b/indra/newview/llaisapi.cpp
@@ -37,11 +37,54 @@
#include "llviewercontrol.h"
///----------------------------------------------------------------------------
-#if 1
+/// Classes for AISv3 support.
+///----------------------------------------------------------------------------
+
+//=========================================================================
+const std::string AISAPI::INVENTORY_CAP_NAME("InventoryAPIv3");
+const std::string AISAPI::LIBRARY_CAP_NAME("LibraryAPIv3");
+
+//-------------------------------------------------------------------------
+/*static*/
+bool AISAPI::isAvailable()
+{
+ if (gAgent.getRegion())
+ {
+ return gAgent.getRegion()->isCapabilityAvailable(INVENTORY_CAP_NAME);
+ }
+ return false;
+}
+
+/*static*/
+void AISAPI::getCapNames(LLSD& capNames)
+{
+ capNames.append(INVENTORY_CAP_NAME);
+ capNames.append(LIBRARY_CAP_NAME);
+}
+
+/*static*/
+std::string AISAPI::getInvCap()
+{
+ if (gAgent.getRegion())
+ {
+ return gAgent.getRegion()->getCapability(INVENTORY_CAP_NAME);
+ }
+ return std::string();
+}
+
+/*static*/
+std::string AISAPI::getLibCap()
+{
+ if (gAgent.getRegion())
+ {
+ return gAgent.getRegion()->getCapability(LIBRARY_CAP_NAME);
+ }
+ return std::string();
+}
+
/*static*/
-void AISAPI::CreateInventoryCommand(const LLUUID& parentId, const LLSD& newInventory, completion_t callback)
+void AISAPI::CreateInventory(const LLUUID& parentId, const LLSD& newInventory, completion_t callback)
{
-#if 1
std::string cap = getInvCap();
if (cap.empty())
{
@@ -68,23 +111,22 @@ void AISAPI::CreateInventoryCommand(const LLUUID& parentId, const LLSD& newInven
// Humans ignore next line. It is just a cast.
static_cast<LLSD (LLCoreHttpUtil::HttpCoroutineAdapter::*)(LLCore::HttpRequest::ptr_t, const std::string &, const LLSD &, LLCore::HttpOptions::ptr_t, LLCore::HttpHeaders::ptr_t)>
//----
+ // _1 -> httpAdapter
+ // _2 -> httpRequest
+ // _3 -> url
+ // _4 -> body
+ // _5 -> httpOptions
+ // _6 -> httpHeaders
(&LLCoreHttpUtil::HttpCoroutineAdapter::postAndYield), _1, _2, _3, _4, _5, _6);
LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro,
- _1, postFn, url, parentId, newInventory, callback));
-#else
- LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::CreateInventoryCommandCoro,
- _1, parentId, newInventory, callback));
-
-#endif
+ _1, postFn, url, parentId, newInventory, callback, COPYINVENTORY));
EnqueueAISCommand("CreateInventory", proc);
-
}
/*static*/
-void AISAPI::SlamFolderCommand(const LLUUID& folderId, const LLSD& newInventory, completion_t callback)
+void AISAPI::SlamFolder(const LLUUID& folderId, const LLSD& newInventory, completion_t callback)
{
-#if 1
std::string cap = getInvCap();
if (cap.empty())
{
@@ -99,23 +141,24 @@ void AISAPI::SlamFolderCommand(const LLUUID& folderId, const LLSD& newInventory,
// see comment above in CreateInventoryCommand
invokationFn_t putFn = boost::bind(
- // Humans ignore next line. It is just a cast.
+ // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload.
static_cast<LLSD(LLCoreHttpUtil::HttpCoroutineAdapter::*)(LLCore::HttpRequest::ptr_t, const std::string &, const LLSD &, LLCore::HttpOptions::ptr_t, LLCore::HttpHeaders::ptr_t)>
//----
+ // _1 -> httpAdapter
+ // _2 -> httpRequest
+ // _3 -> url
+ // _4 -> body
+ // _5 -> httpOptions
+ // _6 -> httpHeaders
(&LLCoreHttpUtil::HttpCoroutineAdapter::putAndYield), _1, _2, _3, _4, _5, _6);
LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro,
- _1, putFn, url, folderId, newInventory, callback));
-
-#else
- LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::SlamFolderCommandCoro,
- _1, folderId, newInventory, callback));
-#endif
+ _1, putFn, url, folderId, newInventory, callback, SLAMFOLDER));
EnqueueAISCommand("SlamFolder", proc);
}
-void AISAPI::RemoveCategoryCommand(const LLUUID &categoryId, completion_t callback)
+void AISAPI::RemoveCategory(const LLUUID &categoryId, completion_t callback)
{
std::string cap;
@@ -130,21 +173,26 @@ void AISAPI::RemoveCategoryCommand(const LLUUID &categoryId, completion_t callba
LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL;
invokationFn_t delFn = boost::bind(
- // Humans ignore next line. It is just a cast.
+ // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload.
static_cast<LLSD(LLCoreHttpUtil::HttpCoroutineAdapter::*)(LLCore::HttpRequest::ptr_t, const std::string &, LLCore::HttpOptions::ptr_t, LLCore::HttpHeaders::ptr_t)>
//----
+ // _1 -> httpAdapter
+ // _2 -> httpRequest
+ // _3 -> url
+ // _4 -> body
+ // _5 -> httpOptions
+ // _6 -> httpHeaders
(&LLCoreHttpUtil::HttpCoroutineAdapter::deleteAndYield), _1, _2, _3, _5, _6);
LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro,
- _1, delFn, url, categoryId, LLSD(), callback));
+ _1, delFn, url, categoryId, LLSD(), callback, REMOVECATEGORY));
EnqueueAISCommand("RemoveCategory", proc);
}
/*static*/
-void AISAPI::RemoveItemCommand(const LLUUID &itemId, completion_t callback)
+void AISAPI::RemoveItem(const LLUUID &itemId, completion_t callback)
{
-#if 1
std::string cap;
cap = getInvCap();
@@ -158,25 +206,64 @@ void AISAPI::RemoveItemCommand(const LLUUID &itemId, completion_t callback)
LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL;
invokationFn_t delFn = boost::bind(
- // Humans ignore next line. It is just a cast.
+ // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload.
static_cast<LLSD(LLCoreHttpUtil::HttpCoroutineAdapter::*)(LLCore::HttpRequest::ptr_t, const std::string &, LLCore::HttpOptions::ptr_t, LLCore::HttpHeaders::ptr_t)>
//----
+ // _1 -> httpAdapter
+ // _2 -> httpRequest
+ // _3 -> url
+ // _4 -> body
+ // _5 -> httpOptions
+ // _6 -> httpHeaders
(&LLCoreHttpUtil::HttpCoroutineAdapter::deleteAndYield), _1, _2, _3, _5, _6);
LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro,
- _1, delFn, url, itemId, LLSD(), callback));
-
-#else
- LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::RemoveItemCommandCoro,
- _1, itemId, callback));
-#endif
+ _1, delFn, url, itemId, LLSD(), callback, REMOVEITEM));
EnqueueAISCommand("RemoveItem", proc);
}
+void AISAPI::CopyLibraryCategory(const LLUUID& sourceId, const LLUUID& destId, completion_t callback)
+{
+ std::string cap;
+
+ cap = getLibCap();
+ if (cap.empty())
+ {
+ LL_WARNS("Inventory") << "Library cap not found!" << LL_ENDL;
+ return;
+ }
+
+ LL_DEBUGS("Inventory") << "Copying library category: " << sourceId << " => " << destId << LL_ENDL;
+
+ LLUUID tid;
+ tid.generate();
+
+ std::string url = cap + std::string("/category/") + sourceId.asString() + "?tid=" + tid.asString();
+ LL_INFOS() << url << LL_ENDL;
+
+ std::string destination = destId.asString();
+
+ invokationFn_t copyFn = boost::bind(
+ // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload.
+ static_cast<LLSD(LLCoreHttpUtil::HttpCoroutineAdapter::*)(LLCore::HttpRequest::ptr_t, const std::string &, const std::string, LLCore::HttpOptions::ptr_t, LLCore::HttpHeaders::ptr_t)>
+ //----
+ // _1 -> httpAdapter
+ // _2 -> httpRequest
+ // _3 -> url
+ // _4 -> body
+ // _5 -> httpOptions
+ // _6 -> httpHeaders
+ (&LLCoreHttpUtil::HttpCoroutineAdapter::copyAndYield), _1, _2, _3, destination, _5, _6);
+
+ LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro,
+ _1, copyFn, url, destId, LLSD(), callback, COPYLIBRARYCATEGORY));
+
+ EnqueueAISCommand("CopyLibraryCategory", proc);
+}
/*static*/
-void AISAPI::PurgeDescendentsCommand(const LLUUID &categoryId, completion_t callback)
+void AISAPI::PurgeDescendents(const LLUUID &categoryId, completion_t callback)
{
std::string cap;
@@ -191,20 +278,26 @@ void AISAPI::PurgeDescendentsCommand(const LLUUID &categoryId, completion_t call
LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL;
invokationFn_t delFn = boost::bind(
- // Humans ignore next line. It is just a cast.
+ // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload.
static_cast<LLSD(LLCoreHttpUtil::HttpCoroutineAdapter::*)(LLCore::HttpRequest::ptr_t, const std::string &, LLCore::HttpOptions::ptr_t, LLCore::HttpHeaders::ptr_t)>
//----
+ // _1 -> httpAdapter
+ // _2 -> httpRequest
+ // _3 -> url
+ // _4 -> body
+ // _5 -> httpOptions
+ // _6 -> httpHeaders
(&LLCoreHttpUtil::HttpCoroutineAdapter::deleteAndYield), _1, _2, _3, _5, _6);
LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro,
- _1, delFn, url, categoryId, LLSD(), callback));
+ _1, delFn, url, categoryId, LLSD(), callback, PURGEDESCENDENTS));
EnqueueAISCommand("PurgeDescendents", proc);
}
/*static*/
-void AISAPI::UpdateCategoryCommand(const LLUUID &categoryId, const LLSD &updates, completion_t callback)
+void AISAPI::UpdateCategory(const LLUUID &categoryId, const LLSD &updates, completion_t callback)
{
std::string cap;
@@ -217,19 +310,25 @@ void AISAPI::UpdateCategoryCommand(const LLUUID &categoryId, const LLSD &updates
std::string url = cap + std::string("/category/") + categoryId.asString();
invokationFn_t patchFn = boost::bind(
- // Humans ignore next line. It is just a cast.
+ // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload.
static_cast<LLSD(LLCoreHttpUtil::HttpCoroutineAdapter::*)(LLCore::HttpRequest::ptr_t, const std::string &, const LLSD &, LLCore::HttpOptions::ptr_t, LLCore::HttpHeaders::ptr_t)>
//----
+ // _1 -> httpAdapter
+ // _2 -> httpRequest
+ // _3 -> url
+ // _4 -> body
+ // _5 -> httpOptions
+ // _6 -> httpHeaders
(&LLCoreHttpUtil::HttpCoroutineAdapter::patchAndYield), _1, _2, _3, _4, _5, _6);
LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro,
- _1, patchFn, url, categoryId, updates, callback));
+ _1, patchFn, url, categoryId, updates, callback, UPDATECATEGORY));
EnqueueAISCommand("UpdateCategory", proc);
}
/*static*/
-void AISAPI::UpdateItemCommand(const LLUUID &itemId, const LLSD &updates, completion_t callback)
+void AISAPI::UpdateItem(const LLUUID &itemId, const LLSD &updates, completion_t callback)
{
std::string cap;
@@ -243,13 +342,19 @@ void AISAPI::UpdateItemCommand(const LLUUID &itemId, const LLSD &updates, comple
std::string url = cap + std::string("/item/") + itemId.asString();
invokationFn_t patchFn = boost::bind(
- // Humans ignore next line. It is just a cast.
+ // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload.
static_cast<LLSD(LLCoreHttpUtil::HttpCoroutineAdapter::*)(LLCore::HttpRequest::ptr_t, const std::string &, const LLSD &, LLCore::HttpOptions::ptr_t, LLCore::HttpHeaders::ptr_t)>
//----
+ // _1 -> httpAdapter
+ // _2 -> httpRequest
+ // _3 -> url
+ // _4 -> body
+ // _5 -> httpOptions
+ // _6 -> httpHeaders
(&LLCoreHttpUtil::HttpCoroutineAdapter::patchAndYield), _1, _2, _3, _4, _5, _6);
LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro,
- _1, patchFn, url, itemId, updates, callback));
+ _1, patchFn, url, itemId, updates, callback, UPDATEITEM));
EnqueueAISCommand("UpdateItem", proc);
}
@@ -262,31 +367,10 @@ void AISAPI::EnqueueAISCommand(const std::string &procName, LLCoprocedureManager
}
-/*static*/
-std::string AISAPI::getInvCap()
-{
- if (gAgent.getRegion())
- {
- return gAgent.getRegion()->getCapability("InventoryAPIv3");
- }
-
- return std::string();
-}
-
-/*static*/
-std::string AISAPI::getLibCap()
-{
- if (gAgent.getRegion())
- {
- return gAgent.getRegion()->getCapability("LibraryAPIv3");
- }
- return std::string();
-}
-
/*static*/
void AISAPI::InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter,
invokationFn_t invoke, std::string url,
- LLUUID targetId, LLSD body, completion_t callback)
+ LLUUID targetId, LLSD body, completion_t callback, COMMAND_TYPE type)
{
LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions);
LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest());
@@ -313,455 +397,20 @@ void AISAPI::InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t ht
gInventory.onAISUpdateReceived("AISCommand", result);
if (callback)
- { // UUID always null
- callback(LLUUID::null);
- }
-
-}
-
-#if 0
-/*static*/
-void AISAPI::CreateInventoryCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter, LLUUID parentId, LLSD newInventory, completion_t callback)
-{
- std::string cap;
- LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions);
- LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest());
-
- httpOptions->setTimeout(HTTP_REQUEST_EXPIRY_SECS);
-
- cap = getInvCap();
- if (cap.empty())
- {
- LL_WARNS("Inventory") << "Inventory cap not found!" << LL_ENDL;
- return;
- }
-
- LLUUID tid;
- tid.generate();
+ {
+ LLUUID id(LLUUID::null);
- std::string url = cap + std::string("/category/") + parentId.asString() + "?tid=" + tid.asString();
- LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL;
+ if (result.has("category_id") && (type == COPYLIBRARYCATEGORY))
+ {
+ id = result["category_id"];
+ }
- LLSD result = httpAdapter->postAndYield(httpRequest, url, newInventory, httpOptions);
- LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
- LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
- if (!status || !result.isMap())
- {
- if (!result.isMap())
- {
- status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents");
- }
- LL_WARNS("Inventory") << "Inventory error: " << status.toString() << LL_ENDL;
- LL_WARNS("Inventory") << ll_pretty_print_sd(result) << LL_ENDL;
+ callback(id);
}
- gInventory.onAISUpdateReceived("AISCommand", result);
-
- if (callback)
- { // UUID always null
- callback(LLUUID::null);
- }
-
-}
-
-/*static*/
-void AISAPI::SlamFolderCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter, LLUUID folderId, LLSD newInventory, completion_t callback)
-{
- std::string cap;
- LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions);
- LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest());
-
- httpOptions->setTimeout(HTTP_REQUEST_EXPIRY_SECS);
-
- cap = getInvCap();
- if (cap.empty())
- {
- LL_WARNS("Inventory") << "Inventory cap not found!" << LL_ENDL;
- return;
- }
-
- LLUUID tid;
- tid.generate();
-
- std::string url = cap + std::string("/category/") + folderId.asString() + "/links?tid=" + tid.asString();
-
- LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL;
-
- LLSD result = httpAdapter->putAndYield(httpRequest, url, newInventory, httpOptions);
- LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
- LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
- if (!status || !result.isMap())
- {
- if (!result.isMap())
- {
- status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents");
- }
- LL_WARNS("Inventory") << "Inventory error: " << status.toString() << LL_ENDL;
- LL_WARNS("Inventory") << ll_pretty_print_sd(result) << LL_ENDL;
- }
-
- gInventory.onAISUpdateReceived("AISCommand", result);
-
- if (callback)
- { // UUID always null
- callback(LLUUID::null);
- }
-
-}
-
-void AISAPI::RemoveItemCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter, LLUUID itemId, completion_t callback)
-{
- std::string cap;
- LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions);
- LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest());
-
- httpOptions->setTimeout(HTTP_REQUEST_EXPIRY_SECS);
-
- cap = getInvCap();
- if (cap.empty())
- {
- LL_WARNS("Inventory") << "Inventory cap not found!" << LL_ENDL;
- return;
- }
-
- std::string url = cap + std::string("/item/") + itemId.asString();
- LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL;
-
- LLSD result = httpAdapter->deleteAndYield(httpRequest, url, httpOptions);
- LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
- LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
-
- if (!status || !result.isMap())
- {
- if (!result.isMap())
- {
- status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents");
- }
- LL_WARNS("Inventory") << "Inventory error: " << status.toString() << LL_ENDL;
- LL_WARNS("Inventory") << ll_pretty_print_sd(result) << LL_ENDL;
- }
-
- gInventory.onAISUpdateReceived("AISCommand", result);
-
- if (callback)
- { // UUID always null
- callback(LLUUID::null);
- }
-}
-#endif
-#endif
-///----------------------------------------------------------------------------
-/// Classes for AISv3 support.
-///----------------------------------------------------------------------------
-
-// AISCommand - base class for retry-able HTTP requests using the AISv3 cap.
-AISCommand::AISCommand(LLPointer<LLInventoryCallback> callback):
- mCommandFunc(NULL),
- mCallback(callback)
-{
- mRetryPolicy = new LLAdaptiveRetryPolicy(1.0, 32.0, 2.0, 10);
-}
-
-bool AISCommand::run_command()
-{
- if (NULL == mCommandFunc)
- {
- // This may happen if a command failed to initiate itself.
- LL_WARNS("Inventory") << "AIS command attempted with null command function" << LL_ENDL;
- return false;
- }
- else
- {
- mCommandFunc();
- return true;
- }
-}
-
-void AISCommand::setCommandFunc(command_func_type command_func)
-{
- mCommandFunc = command_func;
-}
-
-// virtual
-bool AISCommand::getResponseUUID(const LLSD& content, LLUUID& id)
-{
- return false;
-}
-
-/* virtual */
-void AISCommand::httpSuccess()
-{
- // Command func holds a reference to self, need to release it
- // after a success or final failure.
- setCommandFunc(no_op);
-
- const LLSD& content = getContent();
- if (!content.isMap())
- {
- failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content);
- return;
- }
- mRetryPolicy->onSuccess();
-
- gInventory.onAISUpdateReceived("AISCommand", content);
-
- if (mCallback)
- {
- LLUUID id; // will default to null if parse fails.
- getResponseUUID(content,id);
- mCallback->fire(id);
- }
-}
-
-/*virtual*/
-void AISCommand::httpFailure()
-{
- LL_WARNS("Inventory") << dumpResponse() << LL_ENDL;
- S32 status = getStatus();
- const LLSD& headers = getResponseHeaders();
- mRetryPolicy->onFailure(status, headers);
- F32 seconds_to_wait;
- if (mRetryPolicy->shouldRetry(seconds_to_wait))
- {
- doAfterInterval(boost::bind(&AISCommand::run_command,this),seconds_to_wait);
- }
- else
- {
- // Command func holds a reference to self, need to release it
- // after a success or final failure.
- // *TODO: Notify user? This seems bad.
- setCommandFunc(no_op);
- }
-}
-
-//static
-bool AISCommand::isAPIAvailable()
-{
- if (gAgent.getRegion())
- {
- return gAgent.getRegion()->isCapabilityAvailable("InventoryAPIv3");
- }
- return false;
-}
-
-//static
-bool AISCommand::getInvCap(std::string& cap)
-{
- if (gAgent.getRegion())
- {
- cap = gAgent.getRegion()->getCapability("InventoryAPIv3");
- }
- if (!cap.empty())
- {
- return true;
- }
- return false;
-}
-
-//static
-bool AISCommand::getLibCap(std::string& cap)
-{
- if (gAgent.getRegion())
- {
- cap = gAgent.getRegion()->getCapability("LibraryAPIv3");
- }
- if (!cap.empty())
- {
- return true;
- }
- return false;
-}
-
-//static
-void AISCommand::getCapabilityNames(LLSD& capabilityNames)
-{
- capabilityNames.append("InventoryAPIv3");
- capabilityNames.append("LibraryAPIv3");
-}
-
-// RemoveItemCommand::RemoveItemCommand(const LLUUID& item_id,
-// LLPointer<LLInventoryCallback> callback):
-// AISCommand(callback)
-// {
-// std::string cap;
-// if (!getInvCap(cap))
-// {
-// LL_WARNS() << "No cap found" << LL_ENDL;
-// return;
-// }
-// std::string url = cap + std::string("/item/") + item_id.asString();
-// LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL;
-// LLHTTPClient::ResponderPtr responder = this;
-// LLSD headers;
-// F32 timeout = HTTP_REQUEST_EXPIRY_SECS;
-// command_func_type cmd = boost::bind(&LLHTTPClient::del, url, responder, headers, timeout);
-// setCommandFunc(cmd);
-// }
-
-// RemoveCategoryCommand::RemoveCategoryCommand(const LLUUID& item_id,
-// LLPointer<LLInventoryCallback> callback):
-// AISCommand(callback)
-// {
-// std::string cap;
-// if (!getInvCap(cap))
-// {
-// LL_WARNS() << "No cap found" << LL_ENDL;
-// return;
-// }
-// std::string url = cap + std::string("/category/") + item_id.asString();
-// LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL;
-// LLHTTPClient::ResponderPtr responder = this;
-// LLSD headers;
-// F32 timeout = HTTP_REQUEST_EXPIRY_SECS;
-// command_func_type cmd = boost::bind(&LLHTTPClient::del, url, responder, headers, timeout);
-// setCommandFunc(cmd);
-// }
-
-// PurgeDescendentsCommand::PurgeDescendentsCommand(const LLUUID& item_id,
-// LLPointer<LLInventoryCallback> callback):
-// AISCommand(callback)
-// {
-// std::string cap;
-// if (!getInvCap(cap))
-// {
-// LL_WARNS() << "No cap found" << LL_ENDL;
-// return;
-// }
-// std::string url = cap + std::string("/category/") + item_id.asString() + "/children";
-// LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL;
-// LLCurl::ResponderPtr responder = this;
-// LLSD headers;
-// F32 timeout = HTTP_REQUEST_EXPIRY_SECS;
-// command_func_type cmd = boost::bind(&LLHTTPClient::del, url, responder, headers, timeout);
-// setCommandFunc(cmd);
-// }
-
-// UpdateItemCommand::UpdateItemCommand(const LLUUID& item_id,
-// const LLSD& updates,
-// LLPointer<LLInventoryCallback> callback):
-// mUpdates(updates),
-// AISCommand(callback)
-// {
-// std::string cap;
-// if (!getInvCap(cap))
-// {
-// LL_WARNS() << "No cap found" << LL_ENDL;
-// return;
-// }
-// std::string url = cap + std::string("/item/") + item_id.asString();
-// LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL;
-// LL_DEBUGS("Inventory") << "request: " << ll_pretty_print_sd(mUpdates) << 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::patch, url, mUpdates, responder, headers, timeout);
-// setCommandFunc(cmd);
-// }
-
-// UpdateCategoryCommand::UpdateCategoryCommand(const LLUUID& cat_id,
-// const LLSD& updates,
-// LLPointer<LLInventoryCallback> callback):
-// mUpdates(updates),
-// AISCommand(callback)
-// {
-// std::string cap;
-// if (!getInvCap(cap))
-// {
-// LL_WARNS() << "No cap found" << LL_ENDL;
-// return;
-// }
-// std::string url = cap + std::string("/category/") + cat_id.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::patch, url, mUpdates, responder, headers, timeout);
-// 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))
-// {
-// LL_WARNS() << "No cap found" << LL_ENDL;
-// 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)
-// {
-// std::string cap;
-// if (!getInvCap(cap))
-// {
-// LL_WARNS() << "No cap found" << LL_ENDL;
-// return;
-// }
-// LLUUID tid;
-// tid.generate();
-// std::string url = cap + std::string("/category/") + folder_id.asString() + "/links?tid=" + tid.asString();
-// LL_INFOS() << 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::put, url, mContents, responder, headers, timeout);
-// setCommandFunc(cmd);
-// }
-
-CopyLibraryCategoryCommand::CopyLibraryCategoryCommand(const LLUUID& source_id,
- const LLUUID& dest_id,
- LLPointer<LLInventoryCallback> callback):
- AISCommand(callback)
-{
- std::string cap;
- if (!getLibCap(cap))
- {
- LL_WARNS() << "No cap found" << LL_ENDL;
- return;
- }
- LL_DEBUGS("Inventory") << "Copying library category: " << source_id << " => " << dest_id << LL_ENDL;
- LLUUID tid;
- tid.generate();
- std::string url = cap + std::string("/category/") + source_id.asString() + "?tid=" + tid.asString();
- LL_INFOS() << url << LL_ENDL;
- LLCurl::ResponderPtr responder = this;
- LLSD headers;
- F32 timeout = HTTP_REQUEST_EXPIRY_SECS;
- command_func_type cmd = boost::bind(&LLHTTPClient::copy, url, dest_id.asString(), responder, headers, timeout);
- setCommandFunc(cmd);
-}
-
-bool CopyLibraryCategoryCommand::getResponseUUID(const LLSD& content, LLUUID& id)
-{
- if (content.has("category_id"))
- {
- id = content["category_id"];
- return true;
- }
- return false;
}
+//-------------------------------------------------------------------------
AISUpdate::AISUpdate(const LLSD& update)
{
parseUpdate(update);