diff options
author | McCabe Maxsted | 2012-02-18 00:21:39 -0700 |
---|---|---|
committer | McCabe Maxsted | 2012-02-18 00:21:39 -0700 |
commit | 0245a8bfd79f295f19b49f19cfb42f78cf1b87a8 (patch) | |
tree | aadc27fb8df6260dbe9b3ab9a65bd7065f4a7643 | |
parent | Merge remote-tracking branch 'armin/next' into next (diff) | |
parent | fix 3 possible memleaks in the new inventory code (diff) | |
download | meta-impy-0245a8bfd79f295f19b49f19cfb42f78cf1b87a8.zip meta-impy-0245a8bfd79f295f19b49f19cfb42f78cf1b87a8.tar.gz meta-impy-0245a8bfd79f295f19b49f19cfb42f78cf1b87a8.tar.bz2 meta-impy-0245a8bfd79f295f19b49f19cfb42f78cf1b87a8.tar.xz |
Merge remote-tracking branch 'armin/inventory-cap' into next
-rw-r--r-- | linden/indra/newview/llfloateropenobject.cpp | 81 | ||||
-rw-r--r-- | linden/indra/newview/llfloateropenobject.h | 15 | ||||
-rw-r--r-- | linden/indra/newview/llinventorybridge.cpp | 18 | ||||
-rw-r--r-- | linden/indra/newview/llinventorymodel.cpp | 119 | ||||
-rw-r--r-- | linden/indra/newview/llinventorymodel.h | 8 | ||||
-rw-r--r-- | linden/indra/newview/llviewerregion.cpp | 1 |
6 files changed, 210 insertions, 32 deletions
diff --git a/linden/indra/newview/llfloateropenobject.cpp b/linden/indra/newview/llfloateropenobject.cpp index fc483dd..3e672b5 100644 --- a/linden/indra/newview/llfloateropenobject.cpp +++ b/linden/indra/newview/llfloateropenobject.cpp | |||
@@ -155,29 +155,76 @@ void LLFloaterOpenObject::moveToInventory(bool wear) | |||
155 | { | 155 | { |
156 | parent_category_id = gAgent.getInventoryRootID(); | 156 | parent_category_id = gAgent.getInventoryRootID(); |
157 | } | 157 | } |
158 | |||
159 | LLCategoryCreate* cat_data = new LLCategoryCreate(object_id, wear); | ||
158 | LLUUID category_id = gInventory.createNewCategory(parent_category_id, | 160 | LLUUID category_id = gInventory.createNewCategory(parent_category_id, |
159 | LLAssetType::AT_NONE, | 161 | LLAssetType::AT_NONE, |
160 | name); | 162 | name, |
161 | 163 | callbackCreateInventoryCategory, | |
162 | LLCatAndWear* data = new LLCatAndWear; | 164 | (void*)cat_data); |
163 | data->mCatID = category_id; | 165 | |
164 | data->mWear = wear; | ||
165 | |||
166 | // Copy and/or move the items into the newly created folder. | ||
167 | // Ignore any "you're going to break this item" messages. | ||
168 | BOOL success = move_inv_category_world_to_agent(object_id, category_id, TRUE, | ||
169 | callbackMoveInventory, | ||
170 | (void*)data); | ||
171 | if (!success) | ||
172 | { | ||
173 | delete data; | ||
174 | data = NULL; | ||
175 | 166 | ||
176 | LLNotifications::instance().add("OpenObjectCannotCopy"); | 167 | // If we get a null category ID, we are using a capability in |
168 | // createNewCategory and we will handle the following in the | ||
169 | // callbackCreateInventoryCategory routine. | ||
170 | if (category_id.notNull()) | ||
171 | { | ||
172 | delete cat_data; | ||
173 | |||
174 | LLCatAndWear* data = new LLCatAndWear; | ||
175 | data->mCatID = category_id; | ||
176 | data->mWear = wear; | ||
177 | data->mFolderResponded = false; | ||
178 | |||
179 | // Copy and/or move the items into the newly created folder. | ||
180 | // Ignore any "you're going to break this item" messages. | ||
181 | BOOL success = move_inv_category_world_to_agent(object_id, category_id, TRUE, | ||
182 | callbackMoveInventory, | ||
183 | (void*)data); | ||
184 | if (!success) | ||
185 | { | ||
186 | delete data; | ||
187 | data = NULL; | ||
188 | |||
189 | LLNotifications::instance().add("OpenObjectCannotCopy"); | ||
190 | } | ||
177 | } | 191 | } |
178 | } | 192 | } |
179 | 193 | ||
180 | // static | 194 | // static |
195 | void LLFloaterOpenObject::callbackCreateInventoryCategory(const LLSD& result, void* data) | ||
196 | { | ||
197 | LLCategoryCreate* cat_data = (LLCategoryCreate*)data; | ||
198 | if (result.has("failure") and result["failure"]) | ||
199 | { | ||
200 | delete cat_data; | ||
201 | return; | ||
202 | } | ||
203 | |||
204 | LLUUID category_id = result["folder_id"].asUUID(); | ||
205 | LLCatAndWear* wear_data = new LLCatAndWear; | ||
206 | |||
207 | wear_data->mCatID = category_id; | ||
208 | wear_data->mWear = cat_data->mWear; | ||
209 | wear_data->mFolderResponded = true; | ||
210 | |||
211 | // Copy and/or move the items into the newly created folder. | ||
212 | // Ignore any "you're going to break this item" messages. | ||
213 | |||
214 | BOOL success = move_inv_category_world_to_agent(cat_data->mObjectID, category_id, TRUE, | ||
215 | callbackMoveInventory, | ||
216 | (void*)wear_data); | ||
217 | if (!success) | ||
218 | { | ||
219 | delete wear_data; | ||
220 | wear_data = NULL; | ||
221 | |||
222 | LLNotifications::instance().add("OpenObjectCannotCopy"); | ||
223 | } | ||
224 | delete cat_data; | ||
225 | } | ||
226 | |||
227 | // static | ||
181 | void LLFloaterOpenObject::callbackMoveInventory(S32 result, void* data) | 228 | void LLFloaterOpenObject::callbackMoveInventory(S32 result, void* data) |
182 | { | 229 | { |
183 | LLCatAndWear* cat = (LLCatAndWear*)data; | 230 | LLCatAndWear* cat = (LLCatAndWear*)data; |
diff --git a/linden/indra/newview/llfloateropenobject.h b/linden/indra/newview/llfloateropenobject.h index 27653a5..4b89158 100644 --- a/linden/indra/newview/llfloateropenobject.h +++ b/linden/indra/newview/llfloateropenobject.h | |||
@@ -50,10 +50,24 @@ public: | |||
50 | static void show(); | 50 | static void show(); |
51 | static void dirty(); | 51 | static void dirty(); |
52 | 52 | ||
53 | class LLCategoryCreate | ||
54 | { | ||
55 | public: | ||
56 | LLCategoryCreate(LLUUID object_id, bool wear) | ||
57 | : mObjectID(object_id), | ||
58 | mWear(wear) | ||
59 | {} | ||
60 | |||
61 | public: | ||
62 | LLUUID mObjectID; | ||
63 | bool mWear; | ||
64 | }; | ||
65 | |||
53 | struct LLCatAndWear | 66 | struct LLCatAndWear |
54 | { | 67 | { |
55 | LLUUID mCatID; | 68 | LLUUID mCatID; |
56 | bool mWear; | 69 | bool mWear; |
70 | bool mFolderResponded; | ||
57 | }; | 71 | }; |
58 | 72 | ||
59 | protected: | 73 | protected: |
@@ -67,6 +81,7 @@ protected: | |||
67 | 81 | ||
68 | static void onClickMoveToInventory(void* data); | 82 | static void onClickMoveToInventory(void* data); |
69 | static void onClickMoveAndWear(void* data); | 83 | static void onClickMoveAndWear(void* data); |
84 | static void callbackCreateInventoryCategory(const LLSD& result, void* data); | ||
70 | static void callbackMoveInventory(S32 result, void* data); | 85 | static void callbackMoveInventory(S32 result, void* data); |
71 | static void* createPanelInventory(void* data); | 86 | static void* createPanelInventory(void* data); |
72 | 87 | ||
diff --git a/linden/indra/newview/llinventorybridge.cpp b/linden/indra/newview/llinventorybridge.cpp index f71df2d..eb2170a 100644 --- a/linden/indra/newview/llinventorybridge.cpp +++ b/linden/indra/newview/llinventorybridge.cpp | |||
@@ -1610,18 +1610,21 @@ void LLRightClickInventoryFetchDescendentsObserver::done() | |||
1610 | class LLInventoryCopyAndWearObserver : public LLInventoryObserver | 1610 | class LLInventoryCopyAndWearObserver : public LLInventoryObserver |
1611 | { | 1611 | { |
1612 | public: | 1612 | public: |
1613 | LLInventoryCopyAndWearObserver(const LLUUID& cat_id, int count) :mCatID(cat_id), mContentsCount(count), mFolderAdded(FALSE) {} | 1613 | LLInventoryCopyAndWearObserver(const LLUUID& cat_id, |
1614 | int count, | ||
1615 | bool folder_added = false) | ||
1616 | : mCatID(cat_id), | ||
1617 | mContentsCount(count), | ||
1618 | mFolderAdded(folder_added) {} | ||
1614 | virtual ~LLInventoryCopyAndWearObserver() {} | 1619 | virtual ~LLInventoryCopyAndWearObserver() {} |
1615 | virtual void changed(U32 mask); | 1620 | virtual void changed(U32 mask); |
1616 | 1621 | ||
1617 | protected: | 1622 | protected: |
1618 | LLUUID mCatID; | 1623 | LLUUID mCatID; |
1619 | int mContentsCount; | 1624 | int mContentsCount; |
1620 | BOOL mFolderAdded; | 1625 | bool mFolderAdded; |
1621 | }; | 1626 | }; |
1622 | 1627 | ||
1623 | |||
1624 | |||
1625 | void LLInventoryCopyAndWearObserver::changed(U32 mask) | 1628 | void LLInventoryCopyAndWearObserver::changed(U32 mask) |
1626 | { | 1629 | { |
1627 | if((mask & (LLInventoryObserver::ADD)) != 0) | 1630 | if((mask & (LLInventoryObserver::ADD)) != 0) |
@@ -2331,13 +2334,16 @@ bool move_task_inventory_callback(const LLSD& notification, const LLSD& response | |||
2331 | 2334 | ||
2332 | if(option == 0 && object) | 2335 | if(option == 0 && object) |
2333 | { | 2336 | { |
2334 | if (cat_and_wear && cat_and_wear->mWear) | 2337 | if (cat_and_wear && cat_and_wear->mWear) // && !cat_and_wear->mFolderResponded) |
2335 | { | 2338 | { |
2336 | InventoryObjectList inventory_objects; | 2339 | InventoryObjectList inventory_objects; |
2337 | object->getInventoryContents(inventory_objects); | 2340 | object->getInventoryContents(inventory_objects); |
2338 | int contents_count = inventory_objects.size()-1; //subtract one for containing folder | 2341 | int contents_count = inventory_objects.size()-1; //subtract one for containing folder |
2339 | 2342 | ||
2340 | LLInventoryCopyAndWearObserver* inventoryObserver = new LLInventoryCopyAndWearObserver(cat_and_wear->mCatID, contents_count); | 2343 | LLInventoryCopyAndWearObserver* inventoryObserver; |
2344 | inventoryObserver = new LLInventoryCopyAndWearObserver(cat_and_wear->mCatID, | ||
2345 | contents_count, | ||
2346 | cat_and_wear->mFolderResponded); | ||
2341 | gInventory.addObserver(inventoryObserver); | 2347 | gInventory.addObserver(inventoryObserver); |
2342 | } | 2348 | } |
2343 | 2349 | ||
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())); |
diff --git a/linden/indra/newview/llinventorymodel.h b/linden/indra/newview/llinventorymodel.h index 7222c60..7788c34 100644 --- a/linden/indra/newview/llinventorymodel.h +++ b/linden/indra/newview/llinventorymodel.h | |||
@@ -308,9 +308,11 @@ public: | |||
308 | // based on preferred type. Returns the UUID of the new | 308 | // based on preferred type. Returns the UUID of the new |
309 | // category. If you want to use the default name based on type, | 309 | // category. If you want to use the default name based on type, |
310 | // pass in a NULL to the 'name parameter. | 310 | // pass in a NULL to the 'name parameter. |
311 | LLUUID createNewCategory(const LLUUID& parent_id, | 311 | LLUUID createNewCategory(const LLUUID& parent_id, |
312 | LLAssetType::EType preferred_type, | 312 | LLAssetType::EType preferred_type, |
313 | const std::string& name); | 313 | const std::string& name, |
314 | void (*callback)(const LLSD&, void*) = NULL, | ||
315 | void* user_data = NULL); | ||
314 | 316 | ||
315 | LLUUID findCategoryByName(std::string name); | 317 | LLUUID findCategoryByName(std::string name); |
316 | 318 | ||
diff --git a/linden/indra/newview/llviewerregion.cpp b/linden/indra/newview/llviewerregion.cpp index a43e0c0..2fafe30 100644 --- a/linden/indra/newview/llviewerregion.cpp +++ b/linden/indra/newview/llviewerregion.cpp | |||
@@ -1428,6 +1428,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) | |||
1428 | LLSD capabilityNames = LLSD::emptyArray(); | 1428 | LLSD capabilityNames = LLSD::emptyArray(); |
1429 | capabilityNames.append("ChatSessionRequest"); | 1429 | capabilityNames.append("ChatSessionRequest"); |
1430 | capabilityNames.append("CopyInventoryFromNotecard"); | 1430 | capabilityNames.append("CopyInventoryFromNotecard"); |
1431 | capabilityNames.append("CreateInventoryCategory"); | ||
1431 | // Aurora settings -- MC | 1432 | // Aurora settings -- MC |
1432 | capabilityNames.append("DispatchOpenRegionSettings"); | 1433 | capabilityNames.append("DispatchOpenRegionSettings"); |
1433 | capabilityNames.append("DispatchRegionInfo"); | 1434 | capabilityNames.append("DispatchRegionInfo"); |