diff options
Diffstat (limited to 'linden/indra/newview/llinventorymodel.cpp')
-rw-r--r-- | linden/indra/newview/llinventorymodel.cpp | 119 |
1 files changed, 113 insertions, 6 deletions
diff --git a/linden/indra/newview/llinventorymodel.cpp b/linden/indra/newview/llinventorymodel.cpp index 58a2bdc..dc216e3 100644 --- a/linden/indra/newview/llinventorymodel.cpp +++ b/linden/indra/newview/llinventorymodel.cpp | |||
@@ -60,6 +60,7 @@ | |||
60 | #include "llvoavatar.h" | 60 | #include "llvoavatar.h" |
61 | #include "llsdutil.h" | 61 | #include "llsdutil.h" |
62 | #include <deque> | 62 | #include <deque> |
63 | #include "llfloateropenobject.h" | ||
63 | 64 | ||
64 | // [RLVa:KB] | 65 | // [RLVa:KB] |
65 | #include "rlvhandler.h" | 66 | #include "rlvhandler.h" |
@@ -396,25 +397,83 @@ LLUUID LLInventoryModel::findCategoryByName(std::string name) | |||
396 | return LLUUID::null; | 397 | return LLUUID::null; |
397 | } | 398 | } |
398 | 399 | ||
400 | class LLCreateInventoryCategoryResponder : public LLHTTPClient::Responder | ||
401 | { | ||
402 | public: | ||
403 | LLCreateInventoryCategoryResponder(LLInventoryModel* model, | ||
404 | void (*callback)(const LLSD&, void*), | ||
405 | void* user_data) | ||
406 | : mModel(model), | ||
407 | mCallback(callback), | ||
408 | mData(user_data) | ||
409 | { | ||
410 | } | ||
411 | |||
412 | virtual void error(U32 status, const std::string& reason) | ||
413 | { | ||
414 | llwarns << "CreateInventoryCategory failed. status = " << status | ||
415 | << ", reason = \"" << reason << "\"" << llendl; | ||
416 | } | ||
417 | |||
418 | virtual void result(const LLSD& content) | ||
419 | { | ||
420 | // Server has created folder. | ||
421 | |||
422 | LLUUID category_id = content["folder_id"].asUUID(); | ||
423 | |||
424 | // Add the category to the internal representation | ||
425 | LLPointer<LLViewerInventoryCategory> cat; | ||
426 | cat = new LLViewerInventoryCategory(category_id, | ||
427 | content["parent_id"].asUUID(), | ||
428 | (LLAssetType::EType)content["type"].asInteger(), | ||
429 | content["name"].asString(), | ||
430 | gAgent.getID()); | ||
431 | cat->setVersion(LLViewerInventoryCategory::VERSION_INITIAL); | ||
432 | cat->setDescendentCount(0); | ||
433 | LLInventoryModel::LLCategoryUpdate update(cat->getParentUUID(), 1); | ||
434 | mModel->accountForUpdate(update); | ||
435 | mModel->updateCategory(cat); | ||
436 | |||
437 | if (mCallback && mData) | ||
438 | { | ||
439 | mCallback(content, mData); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | private: | ||
444 | void (*mCallback)(const LLSD&, void*); | ||
445 | void* mData; | ||
446 | LLInventoryModel* mModel; | ||
447 | }; | ||
448 | |||
399 | // Convenience function to create a new category. You could call | 449 | // Convenience function to create a new category. You could call |
400 | // updateCategory() with a newly generated UUID category, but this | 450 | // updateCategory() with a newly generated UUID category, but this |
401 | // version will take care of details like what the name should be | 451 | // version will take care of details like what the name should be |
402 | // based on preferred type. Returns the UUID of the new category. | 452 | // based on preferred type. Returns the UUID of the new category. |
403 | LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, | 453 | LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, |
404 | LLAssetType::EType preferred_type, | 454 | LLAssetType::EType preferred_type, const std::string& pname, |
405 | const std::string& pname) | 455 | void (*callback)(const LLSD&, void*), |
456 | void* user_data) | ||
406 | { | 457 | { |
458 | llassert_always(NULL != callback); | ||
459 | |||
407 | LLUUID id; | 460 | LLUUID id; |
461 | |||
408 | if(!isInventoryUsable()) | 462 | if(!isInventoryUsable()) |
409 | { | 463 | { |
410 | llwarns << "Inventory is broken." << llendl; | 464 | llwarns << "Inventory is broken." << llendl; |
411 | return id; | 465 | LLSD result; |
412 | } | 466 | result["failure"] = true; |
467 | callback(result, user_data); | ||
468 | } | ||
469 | |||
413 | 470 | ||
414 | if(preferred_type == LLAssetType::AT_SIMSTATE) | 471 | if(preferred_type == LLAssetType::AT_SIMSTATE) |
415 | { | 472 | { |
416 | LL_DEBUGS("Inventory") << "Attempt to create simstate category." << LL_ENDL; | 473 | LL_DEBUGS("Inventory") << "Attempt to create simstate category." << LL_ENDL; |
417 | return id; | 474 | LLSD result; |
475 | result["failure"] = true; | ||
476 | callback(result, user_data); | ||
418 | } | 477 | } |
419 | 478 | ||
420 | id.generate(); | 479 | id.generate(); |
@@ -433,6 +492,54 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, | |||
433 | name.assign(NEW_CATEGORY_NAME); | 492 | name.assign(NEW_CATEGORY_NAME); |
434 | } | 493 | } |
435 | 494 | ||
495 | if (user_data) // callback required for acked message. | ||
496 | { | ||
497 | |||
498 | |||
499 | LLViewerRegion* viewer_region = gAgent.getRegion(); | ||
500 | |||
501 | if (!viewer_region->capabilitiesReceived()) | ||
502 | { | ||
503 | LL_DEBUGS("Inventory") << "We didn't get the region caps yet." << LL_ENDL; | ||
504 | } | ||
505 | |||
506 | std::string url; | ||
507 | if (viewer_region) | ||
508 | { | ||
509 | url = viewer_region->getCapability("CreateInventoryCategory"); | ||
510 | } | ||
511 | |||
512 | if (!url.empty()) | ||
513 | { | ||
514 | LL_DEBUGS("Inventory") << "Using the CreateInventoryCategory capability." << LL_ENDL; | ||
515 | // Let's use the new capability. | ||
516 | LLSD request, body; | ||
517 | body["folder_id"] = id; | ||
518 | body["parent_id"] = parent_id; | ||
519 | body["type"] = (LLSD::Integer) preferred_type; | ||
520 | body["name"] = name; | ||
521 | |||
522 | request["message"] = "CreateInventoryCategory"; | ||
523 | request["payload"] = body; | ||
524 | |||
525 | LLHTTPClient::post(url, body, | ||
526 | new LLCreateInventoryCategoryResponder(this, | ||
527 | callback, | ||
528 | user_data)); | ||
529 | return LLUUID::null; | ||
530 | } | ||
531 | else | ||
532 | { | ||
533 | LL_DEBUGS("Inventory") << "Cap url empty" << LL_ENDL; | ||
534 | } | ||
535 | } | ||
536 | else //NULL == user_data | ||
537 | { | ||
538 | // user_data is a LLCategoryCreate object instantiated in the calling | ||
539 | // function - bug (or low memory - any leaks?). | ||
540 | llwarns << "NULL user_data" << llendl; | ||
541 | } | ||
542 | |||
436 | // Add the category to the internal representation | 543 | // Add the category to the internal representation |
437 | LLPointer<LLViewerInventoryCategory> cat = | 544 | LLPointer<LLViewerInventoryCategory> cat = |
438 | new LLViewerInventoryCategory(id, parent_id, preferred_type, name, gAgent.getID()); | 545 | new LLViewerInventoryCategory(id, parent_id, preferred_type, name, gAgent.getID()); |
@@ -3173,7 +3280,7 @@ void LLInventoryModel::processBulkUpdateInventory(LLMessageSystem* msg, void**) | |||
3173 | // << titem->getParentUUID() << llendl; | 3280 | // << titem->getParentUUID() << llendl; |
3174 | U32 callback_id; | 3281 | U32 callback_id; |
3175 | msg->getU32Fast(_PREHASH_ItemData, _PREHASH_CallbackID, callback_id); | 3282 | msg->getU32Fast(_PREHASH_ItemData, _PREHASH_CallbackID, callback_id); |
3176 | if(titem->getUUID().notNull()) | 3283 | if (titem->getUUID().notNull()) // && callback_id.notNull()) |
3177 | { | 3284 | { |
3178 | items.push_back(titem); | 3285 | items.push_back(titem); |
3179 | cblist.push_back(InventoryCallbackInfo(callback_id, titem->getUUID())); | 3286 | cblist.push_back(InventoryCallbackInfo(callback_id, titem->getUUID())); |