summaryrefslogtreecommitdiff
path: root/indra/newview/llinventorymodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llinventorymodel.cpp')
-rw-r--r--indra/newview/llinventorymodel.cpp42
1 files changed, 13 insertions, 29 deletions
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index fab7ae8f1a..a7b3076e52 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -664,24 +664,25 @@ const LLUUID LLInventoryModel::findLibraryCategoryUUIDForType(LLFolderType::ETyp
// updateCategory() with a newly generated UUID category, but this
// version will take care of details like what the name should be
// based on preferred type. Returns the UUID of the new category.
+//
+// On failure, returns a null UUID.
+// FIXME: callers do not check for or handle a null results currently.
LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
LLFolderType::EType preferred_type,
const std::string& pname,
inventory_func_type callback)
{
- LLUUID id;
+ LLUUID id; // Initially null.
if (!isInventoryUsable())
{
LL_WARNS(LOG_INV) << "Inventory is not usable; can't create requested category of type "
<< preferred_type << LL_ENDL;
- // FIXME failing but still returning an id?
return id;
}
if(LLFolderType::lookup(preferred_type) == LLFolderType::badLookup())
{
LL_DEBUGS(LOG_INV) << "Attempt to create undefined category." << LL_ENDL;
- // FIXME failing but still returning an id?
return id;
}
@@ -693,38 +694,20 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
LL_WARNS(LOG_INV) << "Creating new system folder, type " << preferred_type << LL_ENDL;
}
- id.generate();
std::string name = pname;
- if(!pname.empty())
- {
- name.assign(pname);
- }
- else
+ if (pname.empty())
{
name.assign(LLViewerFolderType::lookupNewCategoryName(preferred_type));
}
- LLViewerRegion* viewer_region = gAgent.getRegion();
- std::string url;
- if ( viewer_region )
- url = viewer_region->getCapability("CreateInventoryCategory");
-
- if (!url.empty() && callback)
+ if (callback)
{
- //Let's use the new capability.
-
- LLSD request, body;
- body["folder_id"] = id;
- body["parent_id"] = parent_id;
- body["type"] = (LLSD::Integer) preferred_type;
- body["name"] = name;
-
- request["message"] = "CreateInventoryCategory";
- request["payload"] = body;
-
- LL_DEBUGS(LOG_INV) << "Creating category via request: " << ll_pretty_print_sd(request) << LL_ENDL;
- LLCoros::instance().launch("LLInventoryModel::createNewCategoryCoro",
- boost::bind(&LLInventoryModel::createNewCategoryCoro, this, url, body, callback));
+ LLSD new_inventory = LLSD::emptyMap();
+ new_inventory["categories"] = LLSD::emptyArray();
+ LLViewerInventoryCategory cat(LLUUID::null, parent_id, preferred_type, name, gAgent.getID());
+ LLSD cat_sd = cat.asLLSD();
+ new_inventory["categories"].append(cat_sd);
+ AISAPI::CreateInventory(parent_id, new_inventory, callback);
return LLUUID::null;
}
@@ -739,6 +722,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
// assuming instant success.
// Add the category to the internal representation
+ id.generate();
LLPointer<LLViewerInventoryCategory> cat =
new LLViewerInventoryCategory(id, parent_id, preferred_type, name, gAgent.getID());
cat->setVersion(LLViewerInventoryCategory::VERSION_INITIAL - 1); // accountForUpdate() will icrease version by 1