aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden
diff options
context:
space:
mode:
authorArmin Weatherwax2012-01-10 22:39:31 +0100
committerArmin Weatherwax2012-01-10 22:39:31 +0100
commit56a7ba61f631924e36c779f7efcabfd755c4beb2 (patch)
treee3e2f726fc4969069cca2c23785b25597dce9996 /linden
parentdisable voice if ParcelVoiceInfoRequest response is malformed. (diff)
downloadmeta-impy-56a7ba61f631924e36c779f7efcabfd755c4beb2.zip
meta-impy-56a7ba61f631924e36c779f7efcabfd755c4beb2.tar.gz
meta-impy-56a7ba61f631924e36c779f7efcabfd755c4beb2.tar.bz2
meta-impy-56a7ba61f631924e36c779f7efcabfd755c4beb2.tar.xz
New inventory categrory capability code - needs testing.
* Original code from: https://bitbucket.org/lindenlab/viewer-development/changeset/d327dcc8ae51 * Port by Henri Beauchamp: https://lists.secondlife.com/pipermail/opensource-dev/2012-January/008544.html * 3 Lines of debug by /me (find the Hippos -remove after testing)
Diffstat (limited to 'linden')
-rw-r--r--linden/indra/newview/llfloateropenobject.cpp76
-rw-r--r--linden/indra/newview/llfloateropenobject.h15
-rw-r--r--linden/indra/newview/llinventorybridge.cpp18
-rw-r--r--linden/indra/newview/llinventorymodel.cpp103
-rw-r--r--linden/indra/newview/llinventorymodel.h8
-rw-r--r--linden/indra/newview/llviewerregion.cpp1
6 files changed, 192 insertions, 29 deletions
diff --git a/linden/indra/newview/llfloateropenobject.cpp b/linden/indra/newview/llfloateropenobject.cpp
index fc483dd..4190c3e 100644
--- a/linden/indra/newview/llfloateropenobject.cpp
+++ b/linden/indra/newview/llfloateropenobject.cpp
@@ -155,29 +155,71 @@ 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
195void LLFloaterOpenObject::callbackCreateInventoryCategory(const LLSD& result, void* data)
196{
197 LLCategoryCreate* cat_data = (LLCategoryCreate*)data;
198
199 LLUUID category_id = result["folder_id"].asUUID();
200 LLCatAndWear* wear_data = new LLCatAndWear;
201
202 wear_data->mCatID = category_id;
203 wear_data->mWear = cat_data->mWear;
204 wear_data->mFolderResponded = true;
205
206 // Copy and/or move the items into the newly created folder.
207 // Ignore any "you're going to break this item" messages.
208
209 BOOL success = move_inv_category_world_to_agent(cat_data->mObjectID, category_id, TRUE,
210 callbackMoveInventory,
211 (void*)wear_data);
212 if (!success)
213 {
214 delete wear_data;
215 wear_data = NULL;
216
217 LLNotifications::instance().add("OpenObjectCannotCopy");
218 }
219 delete cat_data;
220 }
221
222// static
181void LLFloaterOpenObject::callbackMoveInventory(S32 result, void* data) 223void LLFloaterOpenObject::callbackMoveInventory(S32 result, void* data)
182{ 224{
183 LLCatAndWear* cat = (LLCatAndWear*)data; 225 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
59protected: 73protected:
@@ -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..bd08773 100644
--- a/linden/indra/newview/llinventorybridge.cpp
+++ b/linden/indra/newview/llinventorybridge.cpp
@@ -1610,18 +1610,21 @@ void LLRightClickInventoryFetchDescendentsObserver::done()
1610class LLInventoryCopyAndWearObserver : public LLInventoryObserver 1610class LLInventoryCopyAndWearObserver : public LLInventoryObserver
1611{ 1611{
1612public: 1612public:
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(FALSE) {}
1614 virtual ~LLInventoryCopyAndWearObserver() {} 1619 virtual ~LLInventoryCopyAndWearObserver() {}
1615 virtual void changed(U32 mask); 1620 virtual void changed(U32 mask);
1616 1621
1617protected: 1622protected:
1618 LLUUID mCatID; 1623 LLUUID mCatID;
1619 int mContentsCount; 1624 int mContentsCount;
1620 BOOL mFolderAdded; 1625 bool mFolderAdded;
1621}; 1626};
1622 1627
1623
1624
1625void LLInventoryCopyAndWearObserver::changed(U32 mask) 1628void 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..0200ed0 100644
--- a/linden/indra/newview/llinventorymodel.cpp
+++ b/linden/indra/newview/llinventorymodel.cpp
@@ -396,13 +396,63 @@ LLUUID LLInventoryModel::findCategoryByName(std::string name)
396 return LLUUID::null; 396 return LLUUID::null;
397} 397}
398 398
399class LLCreateInventoryCategoryResponder : public LLHTTPClient::Responder
400{
401public:
402 LLCreateInventoryCategoryResponder(LLInventoryModel* model,
403 void (*callback)(const LLSD&, void*),
404 void* user_data)
405 : mModel(model),
406 mCallback(callback),
407 mData(user_data)
408 {
409 }
410
411 virtual void error(U32 status, const std::string& reason)
412 {
413 llwarns << "CreateInventoryCategory failed. status = " << status
414 << ", reason = \"" << reason << "\"" << llendl;
415 }
416
417 virtual void result(const LLSD& content)
418 {
419 // Server has created folder.
420
421 LLUUID category_id = content["folder_id"].asUUID();
422
423 // Add the category to the internal representation
424 LLPointer<LLViewerInventoryCategory> cat;
425 cat = new LLViewerInventoryCategory(category_id,
426 content["parent_id"].asUUID(),
427 (LLAssetType::EType)content["type"].asInteger(),
428 content["name"].asString(),
429 gAgent.getID());
430 cat->setVersion(LLViewerInventoryCategory::VERSION_INITIAL);
431 cat->setDescendentCount(0);
432 LLInventoryModel::LLCategoryUpdate update(cat->getParentUUID(), 1);
433 mModel->accountForUpdate(update);
434 mModel->updateCategory(cat);
435
436 if (mCallback && mData)
437 {
438 mCallback(content, mData);
439 }
440 }
441
442private:
443 void (*mCallback)(const LLSD&, void*);
444 void* mData;
445 LLInventoryModel* mModel;
446};
447
399// Convenience function to create a new category. You could call 448// Convenience function to create a new category. You could call
400// updateCategory() with a newly generated UUID category, but this 449// updateCategory() with a newly generated UUID category, but this
401// version will take care of details like what the name should be 450// version will take care of details like what the name should be
402// based on preferred type. Returns the UUID of the new category. 451// based on preferred type. Returns the UUID of the new category.
403LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, 452LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
404 LLAssetType::EType preferred_type, 453 LLAssetType::EType preferred_type, const std::string& pname,
405 const std::string& pname) 454 void (*callback)(const LLSD&, void*),
455 void* user_data)
406{ 456{
407 LLUUID id; 457 LLUUID id;
408 if(!isInventoryUsable()) 458 if(!isInventoryUsable())
@@ -433,6 +483,53 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
433 name.assign(NEW_CATEGORY_NAME); 483 name.assign(NEW_CATEGORY_NAME);
434 } 484 }
435 485
486 if (callback && user_data) // callback required for acked message.
487 {
488
489
490 LLViewerRegion* viewer_region = gAgent.getRegion();
491 if (!viewer_region->capabilitiesReceived())//awfixme
492 {
493 LL_DEBUGS("Inventory") << "HIPPOS! not capabilitiesReceived()" << LL_ENDL;
494 }
495 std::string url;
496 if (viewer_region)
497 {
498 url = viewer_region->getCapability("CreateInventoryCategory");
499 }
500
501 if (!url.empty())
502 {
503 LL_DEBUGS("Inventory") << "Using the CreateInventoryCategory capability." << LL_ENDL;
504 // Let's use the new capability.
505 LLSD request, body;
506 body["folder_id"] = id;
507 body["parent_id"] = parent_id;
508 body["type"] = (LLSD::Integer) preferred_type;
509 body["name"] = name;
510
511 request["message"] = "CreateInventoryCategory";
512 request["payload"] = body;
513
514 LLHTTPClient::post(url, body,
515 new LLCreateInventoryCategoryResponder(this,
516 callback,
517 user_data));
518 return LLUUID::null;
519 }
520 else//awfixme
521 {
522 LL_DEBUGS("Inventory") << "HIPPOS! cap url empty" << LL_ENDL;
523 }
524 }
525 else//awfixme
526 {
527 LL_DEBUGS("Inventory") << "HIPPOS! callback: "
528 << (callback ? "true" : "false")
529 << "user_data" << ((NULL!= user_data) ? "!NULL" : "NULL")
530 << LL_ENDL;
531 }
532
436 // Add the category to the internal representation 533 // Add the category to the internal representation
437 LLPointer<LLViewerInventoryCategory> cat = 534 LLPointer<LLViewerInventoryCategory> cat =
438 new LLViewerInventoryCategory(id, parent_id, preferred_type, name, gAgent.getID()); 535 new LLViewerInventoryCategory(id, parent_id, preferred_type, name, gAgent.getID());
@@ -3173,7 +3270,7 @@ void LLInventoryModel::processBulkUpdateInventory(LLMessageSystem* msg, void**)
3173 // << titem->getParentUUID() << llendl; 3270 // << titem->getParentUUID() << llendl;
3174 U32 callback_id; 3271 U32 callback_id;
3175 msg->getU32Fast(_PREHASH_ItemData, _PREHASH_CallbackID, callback_id); 3272 msg->getU32Fast(_PREHASH_ItemData, _PREHASH_CallbackID, callback_id);
3176 if(titem->getUUID().notNull()) 3273 if (titem->getUUID().notNull()) // && callback_id.notNull())
3177 { 3274 {
3178 items.push_back(titem); 3275 items.push_back(titem);
3179 cblist.push_back(InventoryCallbackInfo(callback_id, titem->getUUID())); 3276 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");