aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltooldraganddrop.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lltooldraganddrop.cpp199
1 files changed, 152 insertions, 47 deletions
diff --git a/linden/indra/newview/lltooldraganddrop.cpp b/linden/indra/newview/lltooldraganddrop.cpp
index c83d0f4..156093a 100644
--- a/linden/indra/newview/lltooldraganddrop.cpp
+++ b/linden/indra/newview/lltooldraganddrop.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -66,6 +67,7 @@
66#include "llvolume.h" 67#include "llvolume.h"
67#include "llworld.h" 68#include "llworld.h"
68#include "object_flags.h" 69#include "object_flags.h"
70#include "llimview.h"
69 71
70 72
71// MAX ITEMS is based on (sizeof(uuid)+2) * count must be < MTUBYTES 73// MAX ITEMS is based on (sizeof(uuid)+2) * count must be < MTUBYTES
@@ -953,7 +955,7 @@ void LLToolDragAndDrop::pickCallback(const LLPickInfo& pick_info)
953 955
954 if(hit_obj->isAvatar()) 956 if(hit_obj->isAvatar())
955 { 957 {
956 if(((LLVOAvatar*) hit_obj)->mIsSelf) 958 if(((LLVOAvatar*) hit_obj)->isSelf())
957 { 959 {
958 target = DT_SELF; 960 target = DT_SELF;
959 hit_face = -1; 961 hit_face = -1;
@@ -1051,9 +1053,9 @@ BOOL LLToolDragAndDrop::handleDropTextureProtections(LLViewerObject* hit_obj,
1051 if (hit_obj->isInventoryDirty()) 1053 if (hit_obj->isInventoryDirty())
1052 { 1054 {
1053 hit_obj->fetchInventoryFromServer(); 1055 hit_obj->fetchInventoryFromServer();
1054 LLStringUtil::format_map_t args; 1056 LLSD args;
1055 args["[ERROR_MESSAGE]"] = "Unable to add texture.\nPlease wait a few seconds and try again."; 1057 args["ERROR_MESSAGE"] = "Unable to add texture.\nPlease wait a few seconds and try again.";
1056 gViewerWindow->alertXml("ErrorMessage", args); 1058 LLNotifications::instance().add("ErrorMessage", args);
1057 return FALSE; 1059 return FALSE;
1058 } 1060 }
1059 if (hit_obj->getInventoryItemByAsset(item->getAssetUUID())) 1061 if (hit_obj->getInventoryItemByAsset(item->getAssetUUID()))
@@ -1478,12 +1480,18 @@ struct LLGiveInventoryInfo
1478{ 1480{
1479 LLUUID mToAgentID; 1481 LLUUID mToAgentID;
1480 LLUUID mInventoryObjectID; 1482 LLUUID mInventoryObjectID;
1481 LLGiveInventoryInfo(const LLUUID& to_agent, const LLUUID& obj_id) : 1483 LLUUID mIMSessionID;
1482 mToAgentID(to_agent), mInventoryObjectID(obj_id) {} 1484 LLGiveInventoryInfo(const LLUUID& to_agent, const LLUUID& obj_id, const LLUUID &im_session_id = LLUUID::null) :
1485 mToAgentID(to_agent),
1486 mInventoryObjectID(obj_id),
1487 mIMSessionID(im_session_id)
1488 {}
1483}; 1489};
1484 1490
1485void LLToolDragAndDrop::giveInventory(const LLUUID& to_agent, 1491void LLToolDragAndDrop::giveInventory(const LLUUID& to_agent,
1486 LLInventoryItem* item) 1492 LLInventoryItem* item,
1493 const LLUUID& im_session_id)
1494
1487{ 1495{
1488 llinfos << "LLToolDragAndDrop::giveInventory()" << llendl; 1496 llinfos << "LLToolDragAndDrop::giveInventory()" << llendl;
1489 if(!isInventoryGiveAcceptable(item)) 1497 if(!isInventoryGiveAcceptable(item))
@@ -1493,53 +1501,53 @@ void LLToolDragAndDrop::giveInventory(const LLUUID& to_agent,
1493 if(item->getPermissions().allowCopyBy(gAgent.getID())) 1501 if(item->getPermissions().allowCopyBy(gAgent.getID()))
1494 { 1502 {
1495 // just give it away. 1503 // just give it away.
1496 LLToolDragAndDrop::commitGiveInventoryItem(to_agent, item); 1504 LLToolDragAndDrop::commitGiveInventoryItem(to_agent, item, im_session_id);
1497 } 1505 }
1498 else 1506 else
1499 { 1507 {
1500 // ask if the agent is sure. 1508 // ask if the agent is sure.
1501 LLGiveInventoryInfo* info = new LLGiveInventoryInfo(to_agent, 1509 LLSD payload;
1502 item->getUUID()); 1510 payload["agent_id"] = to_agent;
1503 1511 payload["item_id"] = item->getUUID();
1504 gViewerWindow->alertXml("CannotCopyWarning", 1512 LLNotifications::instance().add("CannotCopyWarning", LLSD(), payload,
1505 &LLToolDragAndDrop::handleCopyProtectedItem, 1513 &LLToolDragAndDrop::handleCopyProtectedItem);
1506 (void*)info);
1507 } 1514 }
1508} 1515}
1509
1510// static 1516// static
1511void LLToolDragAndDrop::handleCopyProtectedItem(S32 option, void* data) 1517bool LLToolDragAndDrop::handleCopyProtectedItem(const LLSD& notification, const LLSD& response)
1512{ 1518{
1513 LLGiveInventoryInfo* info = (LLGiveInventoryInfo*)data; 1519 S32 option = LLNotification::getSelectedOption(notification, response);
1514 LLInventoryItem* item = NULL; 1520 LLInventoryItem* item = NULL;
1515 switch(option) 1521 switch(option)
1516 { 1522 {
1517 case 0: // "Yes" 1523 case 0: // "Yes"
1518 item = gInventory.getItem(info->mInventoryObjectID); 1524 item = gInventory.getItem(notification["payload"]["item_id"].asUUID());
1519 if(item) 1525 if(item)
1520 { 1526 {
1521 LLToolDragAndDrop::commitGiveInventoryItem(info->mToAgentID, 1527 LLToolDragAndDrop::commitGiveInventoryItem(notification["payload"]["agent_id"].asUUID(),
1522 item); 1528 item);
1523 // delete it for now - it will be deleted on the server 1529 // delete it for now - it will be deleted on the server
1524 // quickly enough. 1530 // quickly enough.
1525 gInventory.deleteObject(info->mInventoryObjectID); 1531 gInventory.deleteObject(notification["payload"]["item_id"].asUUID());
1526 gInventory.notifyObservers(); 1532 gInventory.notifyObservers();
1527 } 1533 }
1528 else 1534 else
1529 { 1535 {
1530 gViewerWindow->alertXml("CannotGiveItem"); 1536 LLNotifications::instance().add("CannotGiveItem");
1531 } 1537 }
1532 break; 1538 break;
1533 1539
1534 default: // no, cancel, whatever, who cares, not yes. 1540 default: // no, cancel, whatever, who cares, not yes.
1535 gViewerWindow->alertXml("TransactionCancelled"); 1541 LLNotifications::instance().add("TransactionCancelled");
1536 break; 1542 break;
1537 } 1543 }
1544 return false;
1538} 1545}
1539 1546
1540// static 1547// static
1541void LLToolDragAndDrop::commitGiveInventoryItem(const LLUUID& to_agent, 1548void LLToolDragAndDrop::commitGiveInventoryItem(const LLUUID& to_agent,
1542 LLInventoryItem* item) 1549 LLInventoryItem* item,
1550 const LLUUID& im_session_id)
1543{ 1551{
1544 if(!item) return; 1552 if(!item) return;
1545 std::string name; 1553 std::string name;
@@ -1578,10 +1586,20 @@ void LLToolDragAndDrop::commitGiveInventoryItem(const LLUUID& to_agent,
1578 gFloaterTools->dirty(); 1586 gFloaterTools->dirty();
1579 1587
1580 LLMuteList::getInstance()->autoRemove(to_agent, LLMuteList::AR_INVENTORY); 1588 LLMuteList::getInstance()->autoRemove(to_agent, LLMuteList::AR_INVENTORY);
1589
1590 // If this item was given by drag-and-drop into an IM panel, log this action in the IM panel chat.
1591 if (im_session_id != LLUUID::null)
1592 {
1593 LLSD args;
1594 gIMMgr->addSystemMessage(im_session_id, "inventory_item_offered", args);
1595 }
1596
1581} 1597}
1582 1598
1583void LLToolDragAndDrop::giveInventoryCategory(const LLUUID& to_agent, 1599void LLToolDragAndDrop::giveInventoryCategory(const LLUUID& to_agent,
1584 LLInventoryCategory* cat) 1600 LLInventoryCategory* cat,
1601 const LLUUID& im_session_id)
1602
1585{ 1603{
1586 if(!cat) return; 1604 if(!cat) return;
1587 llinfos << "LLToolDragAndDrop::giveInventoryCategory() - " 1605 llinfos << "LLToolDragAndDrop::giveInventoryCategory() - "
@@ -1614,53 +1632,53 @@ void LLToolDragAndDrop::giveInventoryCategory(const LLUUID& to_agent,
1614 } 1632 }
1615 if(!complete) 1633 if(!complete)
1616 { 1634 {
1617 LLNotifyBox::showXml("IncompleteInventory"); 1635 LLNotifications::instance().add("IncompleteInventory");
1618 return; 1636 return;
1619 } 1637 }
1620 count = items.count() + cats.count(); 1638 count = items.count() + cats.count();
1621 if(count > MAX_ITEMS) 1639 if(count > MAX_ITEMS)
1622 { 1640 {
1623 gViewerWindow->alertXml("TooManyItems"); 1641 LLNotifications::instance().add("TooManyItems");
1624 return; 1642 return;
1625 } 1643 }
1626 else if(count == 0) 1644 else if(count == 0)
1627 { 1645 {
1628 gViewerWindow->alertXml("NoItems"); 1646 LLNotifications::instance().add("NoItems");
1629 return; 1647 return;
1630 } 1648 }
1631 else 1649 else
1632 { 1650 {
1633 if(0 == giveable.countNoCopy()) 1651 if(0 == giveable.countNoCopy())
1634 { 1652 {
1635 LLToolDragAndDrop::commitGiveInventoryCategory(to_agent, cat); 1653 LLToolDragAndDrop::commitGiveInventoryCategory(to_agent, cat, im_session_id);
1636 } 1654 }
1637 else 1655 else
1638 { 1656 {
1639 LLGiveInventoryInfo* info = NULL; 1657 LLGiveInventoryInfo* info = NULL;
1640 info = new LLGiveInventoryInfo(to_agent, cat->getUUID()); 1658 info = new LLGiveInventoryInfo(to_agent, cat->getUUID(), im_session_id);
1641 LLStringUtil::format_map_t args; 1659 LLSD args;
1642 args["[COUNT]"] = llformat("%d",giveable.countNoCopy()); 1660 args["COUNT"] = llformat("%d",giveable.countNoCopy());
1643 gViewerWindow->alertXml("CannotCopyCountItems", args, 1661 LLSD payload;
1644 &LLToolDragAndDrop::handleCopyProtectedCategory, 1662 payload["agent_id"] = to_agent;
1645 (void*)info); 1663 payload["folder_id"] = cat->getUUID();
1646 1664 LLNotifications::instance().add("CannotCopyCountItems", args, payload, &LLToolDragAndDrop::handleCopyProtectedCategory);
1647 } 1665 }
1648 } 1666 }
1649} 1667}
1650 1668
1651 1669
1652// static 1670// static
1653void LLToolDragAndDrop::handleCopyProtectedCategory(S32 option, void* data) 1671bool LLToolDragAndDrop::handleCopyProtectedCategory(const LLSD& notification, const LLSD& response)
1654{ 1672{
1655 LLGiveInventoryInfo* info = (LLGiveInventoryInfo*)data; 1673 S32 option = LLNotification::getSelectedOption(notification, response);
1656 LLInventoryCategory* cat = NULL; 1674 LLInventoryCategory* cat = NULL;
1657 switch(option) 1675 switch(option)
1658 { 1676 {
1659 case 0: // "Yes" 1677 case 0: // "Yes"
1660 cat = gInventory.getCategory(info->mInventoryObjectID); 1678 cat = gInventory.getCategory(notification["payload"]["folder_id"].asUUID());
1661 if(cat) 1679 if(cat)
1662 { 1680 {
1663 LLToolDragAndDrop::commitGiveInventoryCategory(info->mToAgentID, 1681 LLToolDragAndDrop::commitGiveInventoryCategory(notification["payload"]["agent_id"].asUUID(),
1664 cat); 1682 cat);
1665 LLViewerInventoryCategory::cat_array_t cats; 1683 LLViewerInventoryCategory::cat_array_t cats;
1666 LLViewerInventoryItem::item_array_t items; 1684 LLViewerInventoryItem::item_array_t items;
@@ -1679,19 +1697,22 @@ void LLToolDragAndDrop::handleCopyProtectedCategory(S32 option, void* data)
1679 } 1697 }
1680 else 1698 else
1681 { 1699 {
1682 gViewerWindow->alertXml("CannotGiveCategory"); 1700 LLNotifications::instance().add("CannotGiveCategory");
1683 } 1701 }
1684 break; 1702 break;
1685 1703
1686 default: // no, cancel, whatever, who cares, not yes. 1704 default: // no, cancel, whatever, who cares, not yes.
1687 gViewerWindow->alertXml("TransactionCancelled"); 1705 LLNotifications::instance().add("TransactionCancelled");
1688 break; 1706 break;
1689 } 1707 }
1708 return false;
1690} 1709}
1691 1710
1692// static 1711// static
1693void LLToolDragAndDrop::commitGiveInventoryCategory(const LLUUID& to_agent, 1712void LLToolDragAndDrop::commitGiveInventoryCategory(const LLUUID& to_agent,
1694 LLInventoryCategory* cat) 1713 LLInventoryCategory* cat,
1714 const LLUUID& im_session_id)
1715
1695{ 1716{
1696 if(!cat) return; 1717 if(!cat) return;
1697 llinfos << "LLToolDragAndDrop::commitGiveInventoryCategory() - " 1718 llinfos << "LLToolDragAndDrop::commitGiveInventoryCategory() - "
@@ -1713,12 +1734,12 @@ void LLToolDragAndDrop::commitGiveInventoryCategory(const LLUUID& to_agent,
1713 S32 count = items.count() + cats.count(); 1734 S32 count = items.count() + cats.count();
1714 if(count > MAX_ITEMS) 1735 if(count > MAX_ITEMS)
1715 { 1736 {
1716 gViewerWindow->alertXml("TooManyItems"); 1737 LLNotifications::instance().add("TooManyItems");
1717 return; 1738 return;
1718 } 1739 }
1719 else if(count == 0) 1740 else if(count == 0)
1720 { 1741 {
1721 gViewerWindow->alertXml("NoItems"); 1742 LLNotifications::instance().add("NoItems");
1722 return; 1743 return;
1723 } 1744 }
1724 else 1745 else
@@ -1782,6 +1803,13 @@ void LLToolDragAndDrop::commitGiveInventoryCategory(const LLUUID& to_agent,
1782 gFloaterTools->dirty(); 1803 gFloaterTools->dirty();
1783 1804
1784 LLMuteList::getInstance()->autoRemove(to_agent, LLMuteList::AR_INVENTORY); 1805 LLMuteList::getInstance()->autoRemove(to_agent, LLMuteList::AR_INVENTORY);
1806
1807 // If this item was given by drag-and-drop into an IM panel, log this action in the IM panel chat.
1808 if (im_session_id != LLUUID::null)
1809 {
1810 LLSD args;
1811 gIMMgr->addSystemMessage(im_session_id, "inventory_item_offered", args);
1812 }
1785 } 1813 }
1786} 1814}
1787 1815
@@ -1942,6 +1970,82 @@ EAcceptance LLToolDragAndDrop::willObjectAcceptInventory(LLViewerObject* obj, LL
1942 return ACCEPT_NO; 1970 return ACCEPT_NO;
1943} 1971}
1944 1972
1973
1974// function used as drag-and-drop handler for simple agent give inventory requests
1975//static
1976bool LLToolDragAndDrop::handleGiveDragAndDrop(LLUUID dest_agent, LLUUID session_id, BOOL drop,
1977 EDragAndDropType cargo_type,
1978 void* cargo_data,
1979 EAcceptance* accept)
1980{
1981 // check the type
1982 switch(cargo_type)
1983 {
1984 case DAD_TEXTURE:
1985 case DAD_SOUND:
1986 case DAD_LANDMARK:
1987 case DAD_SCRIPT:
1988 case DAD_OBJECT:
1989 case DAD_NOTECARD:
1990 case DAD_CLOTHING:
1991 case DAD_BODYPART:
1992 case DAD_ANIMATION:
1993 case DAD_GESTURE:
1994 {
1995 LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data;
1996 if(gInventory.getItem(inv_item->getUUID())
1997 && LLToolDragAndDrop::isInventoryGiveAcceptable(inv_item))
1998 {
1999 // *TODO: get multiple object transfers working
2000 *accept = ACCEPT_YES_COPY_SINGLE;
2001 if(drop)
2002 {
2003 LLToolDragAndDrop::giveInventory(dest_agent, inv_item, session_id);
2004 }
2005 }
2006 else
2007 {
2008 // It's not in the user's inventory (it's probably
2009 // in an object's contents), so disallow dragging
2010 // it here. You can't give something you don't
2011 // yet have.
2012 *accept = ACCEPT_NO;
2013 }
2014 break;
2015 }
2016 case DAD_CATEGORY:
2017 {
2018 LLViewerInventoryCategory* inv_cat = (LLViewerInventoryCategory*)cargo_data;
2019 if( gInventory.getCategory( inv_cat->getUUID() ) )
2020 {
2021 // *TODO: get multiple object transfers working
2022 *accept = ACCEPT_YES_COPY_SINGLE;
2023 if(drop)
2024 {
2025 LLToolDragAndDrop::giveInventoryCategory(dest_agent, inv_cat, session_id);
2026 }
2027 }
2028 else
2029 {
2030 // It's not in the user's inventory (it's probably
2031 // in an object's contents), so disallow dragging
2032 // it here. You can't give something you don't
2033 // yet have.
2034 *accept = ACCEPT_NO;
2035 }
2036 break;
2037 }
2038 case DAD_CALLINGCARD:
2039 default:
2040 *accept = ACCEPT_NO;
2041 break;
2042 }
2043
2044 return TRUE;
2045}
2046
2047
2048
1945/// 2049///
1946/// Methods called in the drag & drop array 2050/// Methods called in the drag & drop array
1947/// 2051///
@@ -2281,7 +2385,7 @@ EAcceptance LLToolDragAndDrop::dad3dWearItem(
2281 // destroy clothing items. 2385 // destroy clothing items.
2282 if (!gAgent.areWearablesLoaded()) 2386 if (!gAgent.areWearablesLoaded())
2283 { 2387 {
2284 gViewerWindow->alertXml("CanNotChangeAppearanceUntilLoaded"); 2388 LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded");
2285 return ACCEPT_NO; 2389 return ACCEPT_NO;
2286 } 2390 }
2287 2391
@@ -2376,7 +2480,7 @@ EAcceptance LLToolDragAndDrop::dad3dWearCategory(
2376 // destroy clothing items. 2480 // destroy clothing items.
2377 if (!gAgent.areWearablesLoaded()) 2481 if (!gAgent.areWearablesLoaded())
2378 { 2482 {
2379 gViewerWindow->alertXml("CanNotChangeAppearanceUntilLoaded"); 2483 LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded");
2380 return ACCEPT_NO; 2484 return ACCEPT_NO;
2381 } 2485 }
2382 } 2486 }
@@ -2885,6 +2989,7 @@ LLInventoryObject* LLToolDragAndDrop::locateMultipleInventory(LLViewerInventoryC
2885 2989
2886void pack_permissions_slam(LLMessageSystem* msg, U32 flags, const LLPermissions& perms) 2990void pack_permissions_slam(LLMessageSystem* msg, U32 flags, const LLPermissions& perms)
2887{ 2991{
2992 // CRUFT -- the server no longer pays attention to this data
2888 U32 group_mask = perms.getMaskGroup(); 2993 U32 group_mask = perms.getMaskGroup();
2889 U32 everyone_mask = perms.getMaskEveryone(); 2994 U32 everyone_mask = perms.getMaskEveryone();
2890 U32 next_owner_mask = perms.getMaskNextOwner(); 2995 U32 next_owner_mask = perms.getMaskNextOwner();