diff options
author | Merov Linden <merov@lindenlab.com> | 2014-07-22 15:54:53 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2014-07-22 15:54:53 -0700 |
commit | 87a7eee21d986e2a1c8b5fd467b5da06112690b5 (patch) | |
tree | 609741b2e3d0bfe72843342c19e67b7d78f602f4 /indra/newview/lltooldraganddrop.cpp | |
parent | cec79bdb29ac5438c9b9bb0312b4981116f17f61 (diff) | |
parent | 532433674c9553636af9ea8d433b9da6d6fae587 (diff) |
Sync merge with lindenlab/viewer-release
Diffstat (limited to 'indra/newview/lltooldraganddrop.cpp')
-rwxr-xr-x | indra/newview/lltooldraganddrop.cpp | 90 |
1 files changed, 37 insertions, 53 deletions
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 5ba42380f0..5a3c642d3e 100755 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -1599,13 +1599,22 @@ static void give_inventory_cb(const LLSD& notification, const LLSD& response) const LLUUID& session_id = payload["session_id"]; const LLUUID& agent_id = payload["agent_id"]; LLViewerInventoryItem * inv_item = gInventory.getItem(payload["item_id"]); - if (NULL == inv_item) + LLViewerInventoryCategory * inv_cat = gInventory.getCategory(payload["item_id"]); + if (NULL == inv_item && NULL == inv_cat) { - llassert(NULL != inv_item); + llassert( FALSE ); return; } - - if (LLGiveInventory::doGiveInventoryItem(agent_id, inv_item, session_id)) + bool successfully_shared; + if (inv_item) + { + successfully_shared = LLGiveInventory::doGiveInventoryItem(agent_id, inv_item, session_id); + } + else + { + successfully_shared = LLGiveInventory::doGiveInventoryCategory(agent_id, inv_cat, session_id); + } + if (successfully_shared) { if ("avatarpicker" == payload["d&d_dest"].asString()) { @@ -1615,8 +1624,8 @@ static void give_inventory_cb(const LLSD& notification, const LLSD& response) } } -static void show_item_sharing_confirmation(const std::string name, - LLViewerInventoryItem* inv_item, +static void show_object_sharing_confirmation(const std::string name, + LLInventoryObject* inv_item, const LLSD& dest, const LLUUID& dest_agent, const LLUUID& session_id = LLUUID::null) @@ -1626,32 +1635,28 @@ static void show_item_sharing_confirmation(const std::string name, llassert(NULL != inv_item); return; } - if(gInventory.getItem(inv_item->getUUID()) - && LLGiveInventory::isInventoryGiveAcceptable(inv_item)) - { - LLSD substitutions; - substitutions["RESIDENTS"] = name; - substitutions["ITEMS"] = inv_item->getName(); - LLSD payload; - payload["agent_id"] = dest_agent; - payload["item_id"] = inv_item->getUUID(); - payload["session_id"] = session_id; - payload["d&d_dest"] = dest.asString(); - LLNotificationsUtil::add("ShareItemsConfirmation", substitutions, payload, &give_inventory_cb); - } + LLSD substitutions; + substitutions["RESIDENTS"] = name; + substitutions["ITEMS"] = inv_item->getName(); + LLSD payload; + payload["agent_id"] = dest_agent; + payload["item_id"] = inv_item->getUUID(); + payload["session_id"] = session_id; + payload["d&d_dest"] = dest.asString(); + LLNotificationsUtil::add("ShareItemsConfirmation", substitutions, payload, &give_inventory_cb); } static void get_name_cb(const LLUUID& id, const std::string& full_name, - LLViewerInventoryItem* inv_item, + LLInventoryObject* inv_obj, const LLSD& dest, const LLUUID& dest_agent) { - show_item_sharing_confirmation(full_name, - inv_item, - dest, - id, - LLUUID::null); + show_object_sharing_confirmation(full_name, + inv_obj, + dest, + id, + LLUUID::null); } // function used as drag-and-drop handler for simple agent give inventory requests @@ -1677,10 +1682,11 @@ bool LLToolDragAndDrop::handleGiveDragAndDrop(LLUUID dest_agent, LLUUID session_ case DAD_GESTURE: case DAD_CALLINGCARD: case DAD_MESH: + case DAD_CATEGORY: { - LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data; - if(gInventory.getItem(inv_item->getUUID()) - && LLGiveInventory::isInventoryGiveAcceptable(inv_item)) + LLInventoryObject* inv_obj = (LLInventoryObject*)cargo_data; + if(gInventory.getCategory(inv_obj->getUUID()) || (gInventory.getItem(inv_obj->getUUID()) + && LLGiveInventory::isInventoryGiveAcceptable(dynamic_cast<LLInventoryItem*>(inv_obj)))) { // *TODO: get multiple object transfers working *accept = ACCEPT_YES_COPY_SINGLE; @@ -1697,40 +1703,18 @@ bool LLToolDragAndDrop::handleGiveDragAndDrop(LLUUID dest_agent, LLUUID session_ // Otherwise set up a callback to show the dialog when the name arrives. if (gCacheName->getFullName(dest_agent, fullname)) { - show_item_sharing_confirmation(fullname, inv_item, dest, dest_agent, LLUUID::null); + show_object_sharing_confirmation(fullname, inv_obj, dest, dest_agent, LLUUID::null); } else { - gCacheName->get(dest_agent, false, boost::bind(&get_name_cb, _1, _2, inv_item, dest, dest_agent)); + gCacheName->get(dest_agent, false, boost::bind(&get_name_cb, _1, _2, inv_obj, dest, dest_agent)); } return true; } // If an IM session with destination agent is found item offer will be logged in this session. - show_item_sharing_confirmation(session->mName, inv_item, dest, dest_agent, session_id); - } - } - else - { - // It's not in the user's inventory (it's probably - // in an object's contents), so disallow dragging - // it here. You can't give something you don't - // yet have. - *accept = ACCEPT_NO; - } - break; - } - case DAD_CATEGORY: - { - LLViewerInventoryCategory* inv_cat = (LLViewerInventoryCategory*)cargo_data; - if( gInventory.getCategory( inv_cat->getUUID() ) ) - { - // *TODO: get multiple object transfers working - *accept = ACCEPT_YES_COPY_SINGLE; - if(drop) - { - LLGiveInventory::doGiveInventoryCategory(dest_agent, inv_cat, session_id); + show_object_sharing_confirmation(session->mName, inv_obj, dest, dest_agent, session_id); } } else |