Migrated code out of drag and drop, and into LLGiveInventory.
This commit is contained in:
@@ -266,6 +266,7 @@ set(viewer_SOURCE_FILES
|
||||
llframestats.cpp
|
||||
llframestatview.cpp
|
||||
llgesturemgr.cpp
|
||||
llgiveinventory.cpp
|
||||
llgivemoney.cpp
|
||||
llglsandbox.cpp
|
||||
llgroupmgr.cpp
|
||||
@@ -741,6 +742,7 @@ set(viewer_HEADER_FILES
|
||||
llframestats.h
|
||||
llframestatview.h
|
||||
llgesturemgr.h
|
||||
llgiveinventory.h
|
||||
llgivemoney.h
|
||||
llgroupmgr.h
|
||||
llgroupnotify.h
|
||||
|
||||
541
indra/newview/llgiveinventory.cpp
Normal file
541
indra/newview/llgiveinventory.cpp
Normal file
@@ -0,0 +1,541 @@
|
||||
/**
|
||||
* @file llgiveinventory.cpp
|
||||
* @brief LLGiveInventory class implementation
|
||||
*
|
||||
* $LicenseInfo:firstyear=2010&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
#include "llgiveinventory.h"
|
||||
|
||||
// library includes
|
||||
#include "llnotificationsutil.h"
|
||||
#include "lltrans.h"
|
||||
|
||||
// newview includes
|
||||
#include "llagent.h"
|
||||
#include "llagentdata.h"
|
||||
#include "llagentui.h"
|
||||
#include "llagentwearables.h"
|
||||
#include "llfloatertools.h" // for gFloaterTool
|
||||
#include "llhudeffecttrail.h"
|
||||
#include "llhudmanager.h"
|
||||
#include "llimview.h"
|
||||
#include "llinventory.h"
|
||||
#include "llinventoryfunctions.h"
|
||||
#include "llmutelist.h"
|
||||
#include "llviewerobjectlist.h"
|
||||
#include "llvoavatarself.h"
|
||||
|
||||
// MAX ITEMS is based on (sizeof(uuid)+2) * count must be < MTUBYTES
|
||||
// or 18 * count < 1200 => count < 1200/18 => 66. I've cut it down a
|
||||
// bit from there to give some pad.
|
||||
const S32 MAX_ITEMS = 42;
|
||||
|
||||
class LLGiveable : public LLInventoryCollectFunctor
|
||||
{
|
||||
public:
|
||||
LLGiveable() : mCountLosing(0) {}
|
||||
virtual ~LLGiveable() {}
|
||||
virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item);
|
||||
|
||||
S32 countNoCopy() const { return mCountLosing; }
|
||||
protected:
|
||||
S32 mCountLosing;
|
||||
};
|
||||
|
||||
bool LLGiveable::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
|
||||
{
|
||||
// All categories can be given.
|
||||
if (cat)
|
||||
return true;
|
||||
|
||||
bool allowed = false;
|
||||
if(item)
|
||||
{
|
||||
allowed = itemTransferCommonlyAllowed(item);
|
||||
if(allowed &&
|
||||
!item->getPermissions().allowOperationBy(PERM_TRANSFER,
|
||||
gAgent.getID()))
|
||||
{
|
||||
allowed = FALSE;
|
||||
}
|
||||
if(allowed &&
|
||||
!item->getPermissions().allowCopyBy(gAgent.getID()))
|
||||
{
|
||||
++mCountLosing;
|
||||
}
|
||||
}
|
||||
return allowed;
|
||||
}
|
||||
|
||||
class LLUncopyableItems : public LLInventoryCollectFunctor
|
||||
{
|
||||
public:
|
||||
LLUncopyableItems() {}
|
||||
virtual ~LLUncopyableItems() {}
|
||||
virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item);
|
||||
};
|
||||
|
||||
bool LLUncopyableItems::operator()(LLInventoryCategory* cat,
|
||||
LLInventoryItem* item)
|
||||
{
|
||||
bool uncopyable = false;
|
||||
if(item)
|
||||
{
|
||||
if (itemTransferCommonlyAllowed(item) &&
|
||||
!item->getPermissions().allowCopyBy(gAgent.getID()))
|
||||
{
|
||||
uncopyable = true;
|
||||
}
|
||||
}
|
||||
return uncopyable;
|
||||
}
|
||||
|
||||
// static
|
||||
bool LLGiveInventory::isInventoryGiveAcceptable(const LLInventoryItem* item)
|
||||
{
|
||||
if (!item) return false;
|
||||
|
||||
if (!isAgentAvatarValid()) return false;
|
||||
|
||||
if (!item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgentID))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool acceptable = true;
|
||||
switch(item->getType())
|
||||
{
|
||||
case LLAssetType::AT_CALLINGCARD:
|
||||
acceptable = false;
|
||||
break;
|
||||
case LLAssetType::AT_OBJECT:
|
||||
// <edit>
|
||||
/*if(my_avatar->isWearingAttachment(item->getUUID()))
|
||||
{
|
||||
acceptable = false;
|
||||
}*/
|
||||
// </edit>
|
||||
break;
|
||||
case LLAssetType::AT_BODYPART:
|
||||
case LLAssetType::AT_CLOTHING:
|
||||
{
|
||||
// <edit>
|
||||
/*bool copyable = false;
|
||||
if(item->getPermissions().allowCopyBy(gAgent.getID())) copyable = true;
|
||||
|
||||
if(!copyable && gAgentWearables.isWearingItem(item->getUUID()))
|
||||
{
|
||||
acceptable = false;
|
||||
}*/
|
||||
// </edit>
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return acceptable;
|
||||
}
|
||||
|
||||
// Static
|
||||
bool LLGiveInventory::isInventoryGroupGiveAcceptable(const LLInventoryItem* item)
|
||||
{
|
||||
if(!item) return false;
|
||||
|
||||
if (!isAgentAvatarValid()) return false;
|
||||
|
||||
// These permissions are double checked in the simulator in
|
||||
// LLGroupNoticeInventoryItemFetch::result().
|
||||
if (!item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgentID))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!item->getPermissions().allowCopyBy(gAgent.getID()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool acceptable = true;
|
||||
|
||||
switch(item->getType())
|
||||
{
|
||||
case LLAssetType::AT_CALLINGCARD:
|
||||
acceptable = false;
|
||||
break;
|
||||
// <edit>
|
||||
/*case LLAssetType::AT_OBJECT:
|
||||
if(gAgentAvatarp->isWearingAttachment(item->getUUID()))
|
||||
{
|
||||
acceptable = false;
|
||||
}*
|
||||
break;*/
|
||||
// </edit>
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return acceptable;
|
||||
}
|
||||
|
||||
// static
|
||||
bool LLGiveInventory::doGiveInventoryItem(const LLUUID& to_agent,
|
||||
const LLInventoryItem* item,
|
||||
const LLUUID& im_session_id/* = LLUUID::null*/)
|
||||
|
||||
{
|
||||
bool res = true;
|
||||
llinfos << "LLGiveInventory::giveInventory()" << llendl;
|
||||
if(!isInventoryGiveAcceptable(item))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (item->getPermissions().allowCopyBy(gAgentID))
|
||||
{
|
||||
// just give it away.
|
||||
LLGiveInventory::commitGiveInventoryItem(to_agent, item, im_session_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ask if the agent is sure.
|
||||
LLSD payload;
|
||||
payload["agent_id"] = to_agent;
|
||||
payload["item_id"] = item->getUUID();
|
||||
LLNotificationsUtil::add("CannotCopyWarning", LLSD(), payload,
|
||||
&LLGiveInventory::handleCopyProtectedItem);
|
||||
res = false;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void LLGiveInventory::doGiveInventoryCategory(const LLUUID& to_agent,
|
||||
const LLInventoryCategory* cat,
|
||||
const LLUUID& im_session_id)
|
||||
|
||||
{
|
||||
if (!cat) return;
|
||||
llinfos << "LLGiveInventory::giveInventoryCategory() - "
|
||||
<< cat->getUUID() << llendl;
|
||||
|
||||
if (!isAgentAvatarValid()) return;
|
||||
|
||||
// Test out how many items are being given.
|
||||
LLViewerInventoryCategory::cat_array_t cats;
|
||||
LLViewerInventoryItem::item_array_t items;
|
||||
LLGiveable giveable;
|
||||
gInventory.collectDescendentsIf(cat->getUUID(),
|
||||
cats,
|
||||
items,
|
||||
LLInventoryModel::EXCLUDE_TRASH,
|
||||
giveable);
|
||||
S32 count = cats.count();
|
||||
bool complete = true;
|
||||
for(S32 i = 0; i < count; ++i)
|
||||
{
|
||||
if(!gInventory.isCategoryComplete(cats.get(i)->getUUID()))
|
||||
{
|
||||
complete = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!complete)
|
||||
{
|
||||
LLNotificationsUtil::add("IncompleteInventory");
|
||||
return;
|
||||
}
|
||||
count = items.count() + cats.count();
|
||||
if(count > MAX_ITEMS)
|
||||
{
|
||||
LLNotificationsUtil::add("TooManyItems");
|
||||
return;
|
||||
}
|
||||
else if(count == 0)
|
||||
{
|
||||
LLNotificationsUtil::add("NoItems");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(0 == giveable.countNoCopy())
|
||||
{
|
||||
LLGiveInventory::commitGiveInventoryCategory(to_agent, cat, im_session_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
LLSD args;
|
||||
args["COUNT"] = llformat("%d",giveable.countNoCopy());
|
||||
LLSD payload;
|
||||
payload["agent_id"] = to_agent;
|
||||
payload["folder_id"] = cat->getUUID();
|
||||
LLNotificationsUtil::add("CannotCopyCountItems", args, payload, &LLGiveInventory::handleCopyProtectedCategory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// PRIVATE METHODS
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//static
|
||||
void LLGiveInventory::logInventoryOffer(const LLUUID& to_agent, const LLUUID &im_session_id)
|
||||
{
|
||||
// If this item was given by drag-and-drop into an IM panel, log this action in the IM panel chat.
|
||||
if (im_session_id.notNull())
|
||||
{
|
||||
LLSD args;
|
||||
gIMMgr->addSystemMessage(im_session_id, "inventory_item_offered", args);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
bool LLGiveInventory::handleCopyProtectedItem(const LLSD& notification, const LLSD& response)
|
||||
{
|
||||
S32 option = LLNotification::getSelectedOption(notification, response);
|
||||
LLInventoryItem* item = NULL;
|
||||
switch(option)
|
||||
{
|
||||
case 0: // "Yes"
|
||||
item = gInventory.getItem(notification["payload"]["item_id"].asUUID());
|
||||
if(item)
|
||||
{
|
||||
LLGiveInventory::commitGiveInventoryItem(notification["payload"]["agent_id"].asUUID(),
|
||||
item);
|
||||
// delete it for now - it will be deleted on the server
|
||||
// quickly enough.
|
||||
gInventory.deleteObject(notification["payload"]["item_id"].asUUID());
|
||||
gInventory.notifyObservers();
|
||||
}
|
||||
else
|
||||
{
|
||||
LLNotificationsUtil::add("CannotGiveItem");
|
||||
}
|
||||
break;
|
||||
|
||||
default: // no, cancel, whatever, who cares, not yes.
|
||||
LLNotificationsUtil::add("TransactionCancelled");
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
void LLGiveInventory::commitGiveInventoryItem(const LLUUID& to_agent,
|
||||
const LLInventoryItem* item,
|
||||
const LLUUID& im_session_id)
|
||||
{
|
||||
if (!item) return;
|
||||
std::string name;
|
||||
LLAgentUI::buildFullname(name);
|
||||
LLUUID transaction_id;
|
||||
transaction_id.generate();
|
||||
const S32 BUCKET_SIZE = sizeof(U8) + UUID_BYTES;
|
||||
U8 bucket[BUCKET_SIZE];
|
||||
bucket[0] = (U8)item->getType();
|
||||
memcpy(&bucket[1], &(item->getUUID().mData), UUID_BYTES); /* Flawfinder: ignore */
|
||||
pack_instant_message(
|
||||
gMessageSystem,
|
||||
gAgentID,
|
||||
FALSE,
|
||||
gAgentSessionID,
|
||||
to_agent,
|
||||
name,
|
||||
item->getName(),
|
||||
IM_ONLINE,
|
||||
IM_INVENTORY_OFFERED,
|
||||
transaction_id,
|
||||
0,
|
||||
LLUUID::null,
|
||||
gAgent.getPositionAgent(),
|
||||
NO_TIMESTAMP,
|
||||
bucket,
|
||||
BUCKET_SIZE);
|
||||
gAgent.sendReliableMessage();
|
||||
// <edit>
|
||||
if (gSavedSettings.getBOOL("BroadcastViewerEffects"))
|
||||
{
|
||||
// </edit>
|
||||
// VEFFECT: giveInventory
|
||||
LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
|
||||
effectp->setSourceObject(gAgentAvatarp);
|
||||
effectp->setTargetObject(gObjectList.findObject(to_agent));
|
||||
effectp->setDuration(LL_HUD_DUR_SHORT);
|
||||
effectp->setColor(LLColor4U(gAgent.getEffectColor()));
|
||||
// <edit>
|
||||
}
|
||||
// </edit>
|
||||
gFloaterTools->dirty();
|
||||
|
||||
LLMuteList::getInstance()->autoRemove(to_agent, LLMuteList::AR_INVENTORY);
|
||||
|
||||
logInventoryOffer(to_agent, im_session_id);
|
||||
}
|
||||
|
||||
// static
|
||||
bool LLGiveInventory::handleCopyProtectedCategory(const LLSD& notification, const LLSD& response)
|
||||
{
|
||||
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
|
||||
LLInventoryCategory* cat = NULL;
|
||||
switch(option)
|
||||
{
|
||||
case 0: // "Yes"
|
||||
cat = gInventory.getCategory(notification["payload"]["folder_id"].asUUID());
|
||||
if(cat)
|
||||
{
|
||||
LLGiveInventory::commitGiveInventoryCategory(notification["payload"]["agent_id"].asUUID(),
|
||||
cat);
|
||||
LLViewerInventoryCategory::cat_array_t cats;
|
||||
LLViewerInventoryItem::item_array_t items;
|
||||
LLUncopyableItems remove;
|
||||
gInventory.collectDescendentsIf(cat->getUUID(),
|
||||
cats,
|
||||
items,
|
||||
LLInventoryModel::EXCLUDE_TRASH,
|
||||
remove);
|
||||
S32 count = items.count();
|
||||
for(S32 i = 0; i < count; ++i)
|
||||
{
|
||||
gInventory.deleteObject(items.get(i)->getUUID());
|
||||
}
|
||||
gInventory.notifyObservers();
|
||||
}
|
||||
else
|
||||
{
|
||||
LLNotificationsUtil::add("CannotGiveCategory");
|
||||
}
|
||||
break;
|
||||
|
||||
default: // no, cancel, whatever, who cares, not yes.
|
||||
LLNotificationsUtil::add("TransactionCancelled");
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
void LLGiveInventory::commitGiveInventoryCategory(const LLUUID& to_agent,
|
||||
const LLInventoryCategory* cat,
|
||||
const LLUUID& im_session_id)
|
||||
|
||||
{
|
||||
if(!cat) return;
|
||||
llinfos << "LLGiveInventory::commitGiveInventoryCategory() - "
|
||||
<< cat->getUUID() << llendl;
|
||||
|
||||
// Test out how many items are being given.
|
||||
LLViewerInventoryCategory::cat_array_t cats;
|
||||
LLViewerInventoryItem::item_array_t items;
|
||||
LLGiveable giveable;
|
||||
gInventory.collectDescendentsIf(cat->getUUID(),
|
||||
cats,
|
||||
items,
|
||||
LLInventoryModel::EXCLUDE_TRASH,
|
||||
giveable);
|
||||
|
||||
// MAX ITEMS is based on (sizeof(uuid)+2) * count must be <
|
||||
// MTUBYTES or 18 * count < 1200 => count < 1200/18 =>
|
||||
// 66. I've cut it down a bit from there to give some pad.
|
||||
S32 count = items.count() + cats.count();
|
||||
if(count > MAX_ITEMS)
|
||||
{
|
||||
LLNotificationsUtil::add("TooManyItems");
|
||||
return;
|
||||
}
|
||||
else if(count == 0)
|
||||
{
|
||||
LLNotificationsUtil::add("NoItems");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string name;
|
||||
LLAgentUI::buildFullname(name);
|
||||
LLUUID transaction_id;
|
||||
transaction_id.generate();
|
||||
S32 bucket_size = (sizeof(U8) + UUID_BYTES) * (count + 1);
|
||||
U8* bucket = new U8[bucket_size];
|
||||
U8* pos = bucket;
|
||||
U8 type = (U8)cat->getType();
|
||||
memcpy(pos, &type, sizeof(U8)); /* Flawfinder: ignore */
|
||||
pos += sizeof(U8);
|
||||
memcpy(pos, &(cat->getUUID()), UUID_BYTES); /* Flawfinder: ignore */
|
||||
pos += UUID_BYTES;
|
||||
S32 i;
|
||||
count = cats.count();
|
||||
for(i = 0; i < count; ++i)
|
||||
{
|
||||
memcpy(pos, &type, sizeof(U8)); /* Flawfinder: ignore */
|
||||
pos += sizeof(U8);
|
||||
memcpy(pos, &(cats.get(i)->getUUID()), UUID_BYTES); /* Flawfinder: ignore */
|
||||
pos += UUID_BYTES;
|
||||
}
|
||||
count = items.count();
|
||||
for(i = 0; i < count; ++i)
|
||||
{
|
||||
type = (U8)items.get(i)->getType();
|
||||
memcpy(pos, &type, sizeof(U8)); /* Flawfinder: ignore */
|
||||
pos += sizeof(U8);
|
||||
memcpy(pos, &(items.get(i)->getUUID()), UUID_BYTES); /* Flawfinder: ignore */
|
||||
pos += UUID_BYTES;
|
||||
}
|
||||
pack_instant_message(
|
||||
gMessageSystem,
|
||||
gAgent.getID(),
|
||||
FALSE,
|
||||
gAgent.getSessionID(),
|
||||
to_agent,
|
||||
name,
|
||||
cat->getName(),
|
||||
IM_ONLINE,
|
||||
IM_INVENTORY_OFFERED,
|
||||
transaction_id,
|
||||
0,
|
||||
LLUUID::null,
|
||||
gAgent.getPositionAgent(),
|
||||
NO_TIMESTAMP,
|
||||
bucket,
|
||||
bucket_size);
|
||||
gAgent.sendReliableMessage();
|
||||
delete[] bucket;
|
||||
// <edit>
|
||||
if (gSavedSettings.getBOOL("BroadcastViewerEffects"))
|
||||
{
|
||||
// </edit>
|
||||
// VEFFECT: giveInventoryCategory
|
||||
LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
|
||||
effectp->setSourceObject(gAgentAvatarp);
|
||||
effectp->setTargetObject(gObjectList.findObject(to_agent));
|
||||
effectp->setDuration(LL_HUD_DUR_SHORT);
|
||||
effectp->setColor(LLColor4U(gAgent.getEffectColor()));
|
||||
// <edit>
|
||||
}
|
||||
// </edit>
|
||||
gFloaterTools->dirty();
|
||||
|
||||
LLMuteList::getInstance()->autoRemove(to_agent, LLMuteList::AR_INVENTORY);
|
||||
|
||||
logInventoryOffer(to_agent, im_session_id);
|
||||
}
|
||||
}
|
||||
// EOF
|
||||
93
indra/newview/llgiveinventory.h
Normal file
93
indra/newview/llgiveinventory.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @file llgiveinventory.cpp
|
||||
* @brief LLGiveInventory class declaration
|
||||
*
|
||||
* $LicenseInfo:firstyear=2010&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#ifndef LL_LLGIVEINVENTORY_H
|
||||
#define LL_LLGIVEINVENTORY_H
|
||||
|
||||
class LLInventoryItem;
|
||||
class LLInventoryCategory;
|
||||
|
||||
/**
|
||||
* Class represented give inventory related actions.
|
||||
*
|
||||
* It has only static methods and is not intended to be instantiated for now.
|
||||
*/
|
||||
class LLGiveInventory
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Checks if inventory item you are attempting to transfer to a resident can be given.
|
||||
*
|
||||
* @return true if you can give, otherwise false.
|
||||
*/
|
||||
static bool isInventoryGiveAcceptable(const LLInventoryItem* item);
|
||||
|
||||
/**
|
||||
* Checks if inventory item you are attempting to transfer to a group can be given.
|
||||
*
|
||||
* @return true if you can give, otherwise false.
|
||||
*/
|
||||
static bool isInventoryGroupGiveAcceptable(const LLInventoryItem* item);
|
||||
|
||||
/**
|
||||
* Gives passed inventory item to specified avatar in specified session.
|
||||
*/
|
||||
static bool doGiveInventoryItem(const LLUUID& to_agent,
|
||||
const LLInventoryItem* item,
|
||||
const LLUUID& im_session_id = LLUUID::null);
|
||||
|
||||
/**
|
||||
* Gives passed inventory category to specified avatar in specified session.
|
||||
*/
|
||||
static void doGiveInventoryCategory(const LLUUID& to_agent,
|
||||
const LLInventoryCategory* item,
|
||||
const LLUUID &session_id = LLUUID::null);
|
||||
// give inventory item functionality
|
||||
static bool handleCopyProtectedItem(const LLSD& notification, const LLSD& response);
|
||||
|
||||
private:
|
||||
// this class is not intended to be instantiated.
|
||||
LLGiveInventory();
|
||||
|
||||
/**
|
||||
* logs "Inventory item offered" to IM
|
||||
*/
|
||||
static void logInventoryOffer(const LLUUID& to_agent,
|
||||
const LLUUID &im_session_id = LLUUID::null);
|
||||
|
||||
static void commitGiveInventoryItem(const LLUUID& to_agent,
|
||||
const LLInventoryItem* item,
|
||||
const LLUUID &im_session_id = LLUUID::null);
|
||||
|
||||
// give inventory category functionality
|
||||
static bool handleCopyProtectedCategory(const LLSD& notification, const LLSD& response);
|
||||
static void commitGiveInventoryCategory(const LLUUID& to_agent,
|
||||
const LLInventoryCategory* cat,
|
||||
const LLUUID &im_session_id = LLUUID::null);
|
||||
|
||||
};
|
||||
|
||||
#endif // LL_LLGIVEINVENTORY_H
|
||||
@@ -65,6 +65,7 @@
|
||||
#include "llfocusmgr.h"
|
||||
#include "llfolderview.h"
|
||||
#include "llgesturemgr.h"
|
||||
#include "llgiveinventory.h"
|
||||
#include "lliconctrl.h"
|
||||
#include "llinventorymodel.h"
|
||||
#include "llinventoryclipboard.h"
|
||||
@@ -3468,7 +3469,7 @@ BOOL LLCallingCardBridge::dragOrDrop(MASK mask, BOOL drop,
|
||||
rv = TRUE;
|
||||
if(drop)
|
||||
{
|
||||
LLToolDragAndDrop::giveInventory(item->getCreatorUUID(),
|
||||
LLGiveInventory::doGiveInventoryItem(item->getCreatorUUID(),
|
||||
(LLInventoryItem*)cargo_data);
|
||||
}
|
||||
}
|
||||
@@ -3489,7 +3490,7 @@ BOOL LLCallingCardBridge::dragOrDrop(MASK mask, BOOL drop,
|
||||
rv = TRUE;
|
||||
if(drop)
|
||||
{
|
||||
LLToolDragAndDrop::giveInventoryCategory(
|
||||
LLGiveInventory::doGiveInventoryCategory(
|
||||
item->getCreatorUUID(),
|
||||
inv_cat);
|
||||
}
|
||||
|
||||
@@ -36,10 +36,12 @@
|
||||
|
||||
#include "llview.h"
|
||||
|
||||
#include "llavatarnamecache.h"
|
||||
#include "llinventory.h"
|
||||
#include "llviewerinventory.h"
|
||||
#include "llinventorymodel.h"
|
||||
#include "llinventorydefines.h"
|
||||
#include "llinventoryfunctions.h"
|
||||
#include "llinventorymodel.h"
|
||||
#include "llinventoryicon.h"
|
||||
#include "llagent.h"
|
||||
#include "lltooldraganddrop.h"
|
||||
@@ -49,7 +51,6 @@
|
||||
#include "llbutton.h"
|
||||
#include "lliconctrl.h"
|
||||
#include "llcheckboxctrl.h"
|
||||
#include "llnotificationsutil.h"
|
||||
#include "llscrolllistctrl.h"
|
||||
#include "lltextbox.h"
|
||||
|
||||
@@ -57,6 +58,8 @@
|
||||
#include "llviewerwindow.h"
|
||||
#include "llviewercontrol.h"
|
||||
#include "llviewermessage.h"
|
||||
#include "llnotificationsutil.h"
|
||||
#include "llgiveinventory.h"
|
||||
|
||||
const S32 NOTICE_DATE_STRING_SIZE = 30;
|
||||
|
||||
@@ -140,7 +143,7 @@ BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
|
||||
{
|
||||
LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data;
|
||||
if(gInventory.getItem(inv_item->getUUID())
|
||||
&& LLToolDragAndDrop::isInventoryGroupGiveAcceptable(inv_item))
|
||||
&& LLGiveInventory::isInventoryGroupGiveAcceptable(inv_item))
|
||||
{
|
||||
// *TODO: get multiple object transfers working
|
||||
*accept = ACCEPT_YES_COPY_SINGLE;
|
||||
|
||||
@@ -48,8 +48,10 @@
|
||||
#include "llfloatertools.h"
|
||||
#include "llfocusmgr.h"
|
||||
#include "llgesturemgr.h"
|
||||
#include "llhudeffecttrail.h"
|
||||
#include "llgiveinventory.h"
|
||||
#include "llhudmanager.h"
|
||||
#include "llhudeffecttrail.h"
|
||||
#include "llimview.h"
|
||||
#include "llinventorybridge.h"
|
||||
#include "llinventorydefines.h"
|
||||
#include "llinventoryfunctions.h"
|
||||
@@ -68,18 +70,15 @@
|
||||
#include "llviewerregion.h"
|
||||
#include "llviewerstats.h"
|
||||
#include "llviewerwindow.h"
|
||||
#include "llvoavatar.h"
|
||||
#include "llvoavatarself.h"
|
||||
#include "llvolume.h"
|
||||
#include "llworld.h"
|
||||
#include "object_flags.h"
|
||||
#include "llimview.h"
|
||||
// <edit>
|
||||
#include "llappviewer.h" // System Folders
|
||||
#include "llparcel.h" // always rez
|
||||
#include "llviewerparcelmgr.h" // always rez
|
||||
// </edit>
|
||||
#include "object_flags.h"
|
||||
#include "llimview.h"
|
||||
|
||||
// [RLVa:KB] - Checked: 2010-03-04 (RLVa-1.2.0a)
|
||||
#include "rlvhandler.h"
|
||||
@@ -145,18 +144,18 @@ bool LLDroppableItem::operator()(LLInventoryCategory* cat,
|
||||
LLInventoryItem* item)
|
||||
{
|
||||
bool allowed = false;
|
||||
if(item)
|
||||
if (item)
|
||||
{
|
||||
allowed = itemTransferCommonlyAllowed(item);
|
||||
|
||||
if(allowed
|
||||
if (allowed
|
||||
&& mIsTransfer
|
||||
&& !item->getPermissions().allowOperationBy(PERM_TRANSFER,
|
||||
gAgent.getID()))
|
||||
{
|
||||
allowed = false;
|
||||
}
|
||||
if(allowed && !item->getPermissions().allowCopyBy(gAgent.getID()))
|
||||
if (allowed && !item->getPermissions().allowCopyBy(gAgent.getID()))
|
||||
{
|
||||
++mCountLosing;
|
||||
}
|
||||
@@ -164,29 +163,6 @@ bool LLDroppableItem::operator()(LLInventoryCategory* cat,
|
||||
return allowed;
|
||||
}
|
||||
|
||||
class LLUncopyableItems : public LLInventoryCollectFunctor
|
||||
{
|
||||
public:
|
||||
LLUncopyableItems() {}
|
||||
virtual ~LLUncopyableItems() {}
|
||||
virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item);
|
||||
};
|
||||
|
||||
bool LLUncopyableItems::operator()(LLInventoryCategory* cat,
|
||||
LLInventoryItem* item)
|
||||
{
|
||||
bool uncopyable = false;
|
||||
if(item)
|
||||
{
|
||||
if (itemTransferCommonlyAllowed(item) &&
|
||||
!item->getPermissions().allowCopyBy(gAgent.getID()))
|
||||
{
|
||||
uncopyable = true;
|
||||
}
|
||||
}
|
||||
return uncopyable;
|
||||
}
|
||||
|
||||
class LLDropCopyableItems : public LLInventoryCollectFunctor
|
||||
{
|
||||
public:
|
||||
@@ -214,43 +190,6 @@ bool LLDropCopyableItems::operator()(
|
||||
return allowed;
|
||||
}
|
||||
|
||||
class LLGiveable : public LLInventoryCollectFunctor
|
||||
{
|
||||
public:
|
||||
LLGiveable() : mCountLosing(0) {}
|
||||
virtual ~LLGiveable() {}
|
||||
virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item);
|
||||
|
||||
S32 countNoCopy() const { return mCountLosing; }
|
||||
protected:
|
||||
S32 mCountLosing;
|
||||
};
|
||||
|
||||
bool LLGiveable::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
|
||||
{
|
||||
// All categories can be given.
|
||||
if (cat)
|
||||
return true;
|
||||
|
||||
bool allowed = false;
|
||||
if(item)
|
||||
{
|
||||
allowed = itemTransferCommonlyAllowed(item);
|
||||
if(allowed &&
|
||||
!item->getPermissions().allowOperationBy(PERM_TRANSFER,
|
||||
gAgent.getID()))
|
||||
{
|
||||
allowed = FALSE;
|
||||
}
|
||||
if(allowed &&
|
||||
!item->getPermissions().allowCopyBy(gAgent.getID()))
|
||||
{
|
||||
++mCountLosing;
|
||||
}
|
||||
}
|
||||
return allowed;
|
||||
}
|
||||
|
||||
class LLCategoryFireAndForget : public LLInventoryFetchComboObserver
|
||||
{
|
||||
public:
|
||||
@@ -558,8 +497,8 @@ void LLToolDragAndDrop::beginDrag(EDragAndDropType type,
|
||||
LLViewerInventoryCategory::cat_array_t cats;
|
||||
LLViewerInventoryItem::item_array_t items;
|
||||
LLNoPreferredTypeOrItem is_not_preferred;
|
||||
LLInventoryFetchComboObserver::folder_ref_t folder_ids;
|
||||
LLInventoryFetchComboObserver::item_ref_t item_ids;
|
||||
uuid_vec_t folder_ids;
|
||||
uuid_vec_t item_ids;
|
||||
if(is_not_preferred(cat, NULL))
|
||||
{
|
||||
folder_ids.push_back(cargo_id);
|
||||
@@ -649,9 +588,9 @@ void LLToolDragAndDrop::beginMultiDrag(
|
||||
}
|
||||
if(!cat_ids.empty())
|
||||
{
|
||||
LLInventoryFetchComboObserver::folder_ref_t folder_ids;
|
||||
LLInventoryFetchComboObserver::item_ref_t item_ids;
|
||||
std::back_insert_iterator<LLInventoryFetchDescendentsObserver::folder_ref_t> copier(folder_ids);
|
||||
uuid_vec_t folder_ids;
|
||||
uuid_vec_t item_ids;
|
||||
std::back_insert_iterator<uuid_vec_t> copier(folder_ids);
|
||||
std::copy(cat_ids.begin(), cat_ids.end(), copier);
|
||||
LLCategoryFireAndForget fetcher;
|
||||
fetcher.fetch(folder_ids, item_ids);
|
||||
@@ -1561,447 +1500,6 @@ struct LLGiveInventoryInfo
|
||||
{}
|
||||
};
|
||||
|
||||
void LLToolDragAndDrop::giveInventory(const LLUUID& to_agent,
|
||||
LLInventoryItem* item,
|
||||
const LLUUID& im_session_id)
|
||||
|
||||
{
|
||||
llinfos << "LLToolDragAndDrop::giveInventory()" << llendl;
|
||||
if(!isInventoryGiveAcceptable(item))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(item->getPermissions().allowCopyBy(gAgent.getID()))
|
||||
{
|
||||
// just give it away.
|
||||
LLToolDragAndDrop::commitGiveInventoryItem(to_agent, item, im_session_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ask if the agent is sure.
|
||||
LLSD payload;
|
||||
payload["agent_id"] = to_agent;
|
||||
payload["item_id"] = item->getUUID();
|
||||
LLNotificationsUtil::add("CannotCopyWarning", LLSD(), payload,
|
||||
&LLToolDragAndDrop::handleCopyProtectedItem);
|
||||
}
|
||||
}
|
||||
// static
|
||||
bool LLToolDragAndDrop::handleCopyProtectedItem(const LLSD& notification, const LLSD& response)
|
||||
{
|
||||
S32 option = LLNotification::getSelectedOption(notification, response);
|
||||
LLInventoryItem* item = NULL;
|
||||
switch(option)
|
||||
{
|
||||
case 0: // "Yes"
|
||||
item = gInventory.getItem(notification["payload"]["item_id"].asUUID());
|
||||
if(item)
|
||||
{
|
||||
LLToolDragAndDrop::commitGiveInventoryItem(notification["payload"]["agent_id"].asUUID(),
|
||||
item);
|
||||
// delete it for now - it will be deleted on the server
|
||||
// quickly enough.
|
||||
gInventory.deleteObject(notification["payload"]["item_id"].asUUID());
|
||||
gInventory.notifyObservers();
|
||||
}
|
||||
else
|
||||
{
|
||||
LLNotificationsUtil::add("CannotGiveItem");
|
||||
}
|
||||
break;
|
||||
|
||||
default: // no, cancel, whatever, who cares, not yes.
|
||||
LLNotificationsUtil::add("TransactionCancelled");
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
void LLToolDragAndDrop::commitGiveInventoryItem(const LLUUID& to_agent,
|
||||
LLInventoryItem* item,
|
||||
const LLUUID& im_session_id)
|
||||
{
|
||||
if(!item) return;
|
||||
std::string name;
|
||||
gAgent.buildFullname(name);
|
||||
LLUUID transaction_id;
|
||||
transaction_id.generate();
|
||||
const S32 BUCKET_SIZE = sizeof(U8) + UUID_BYTES;
|
||||
U8 bucket[BUCKET_SIZE];
|
||||
bucket[0] = (U8)item->getType();
|
||||
memcpy(&bucket[1], &(item->getUUID().mData), UUID_BYTES); /* Flawfinder: ignore */
|
||||
pack_instant_message(
|
||||
gMessageSystem,
|
||||
gAgent.getID(),
|
||||
FALSE,
|
||||
gAgent.getSessionID(),
|
||||
to_agent,
|
||||
name,
|
||||
item->getName(),
|
||||
IM_ONLINE,
|
||||
IM_INVENTORY_OFFERED,
|
||||
transaction_id,
|
||||
0,
|
||||
LLUUID::null,
|
||||
gAgent.getPositionAgent(),
|
||||
NO_TIMESTAMP,
|
||||
bucket,
|
||||
BUCKET_SIZE);
|
||||
gAgent.sendReliableMessage();
|
||||
// <edit>
|
||||
if (gSavedSettings.getBOOL("BroadcastViewerEffects"))
|
||||
{
|
||||
// </edit>
|
||||
// VEFFECT: giveInventory
|
||||
LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
|
||||
effectp->setSourceObject(gAgentAvatarp);
|
||||
effectp->setTargetObject(gObjectList.findObject(to_agent));
|
||||
effectp->setDuration(LL_HUD_DUR_SHORT);
|
||||
effectp->setColor(LLColor4U(gAgent.getEffectColor()));
|
||||
// <edit>
|
||||
}
|
||||
// </edit>
|
||||
gFloaterTools->dirty();
|
||||
|
||||
LLMuteList::getInstance()->autoRemove(to_agent, LLMuteList::AR_INVENTORY);
|
||||
|
||||
// If this item was given by drag-and-drop into an IM panel, log this action in the IM panel chat.
|
||||
if (im_session_id != LLUUID::null)
|
||||
{
|
||||
LLSD args;
|
||||
gIMMgr->addSystemMessage(im_session_id, "inventory_item_offered", args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LLToolDragAndDrop::giveInventoryCategory(const LLUUID& to_agent,
|
||||
LLInventoryCategory* cat,
|
||||
const LLUUID& im_session_id)
|
||||
|
||||
{
|
||||
if(!cat) return;
|
||||
llinfos << "LLToolDragAndDrop::giveInventoryCategory() - "
|
||||
<< cat->getUUID() << llendl;
|
||||
|
||||
LLVOAvatar* my_avatar = gAgentAvatarp;
|
||||
if( !my_avatar )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Test out how many items are being given.
|
||||
LLViewerInventoryCategory::cat_array_t cats;
|
||||
LLViewerInventoryItem::item_array_t items;
|
||||
LLGiveable giveable;
|
||||
gInventory.collectDescendentsIf(cat->getUUID(),
|
||||
cats,
|
||||
items,
|
||||
LLInventoryModel::EXCLUDE_TRASH,
|
||||
giveable);
|
||||
S32 count = cats.count();
|
||||
bool complete = true;
|
||||
for(S32 i = 0; i < count; ++i)
|
||||
{
|
||||
if(!gInventory.isCategoryComplete(cats.get(i)->getUUID()))
|
||||
{
|
||||
complete = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!complete)
|
||||
{
|
||||
LLNotificationsUtil::add("IncompleteInventory");
|
||||
return;
|
||||
}
|
||||
count = items.count() + cats.count();
|
||||
if(count > MAX_ITEMS)
|
||||
{
|
||||
LLNotificationsUtil::add("TooManyItems");
|
||||
return;
|
||||
}
|
||||
else if(count == 0)
|
||||
{
|
||||
LLNotificationsUtil::add("NoItems");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(0 == giveable.countNoCopy())
|
||||
{
|
||||
LLToolDragAndDrop::commitGiveInventoryCategory(to_agent, cat, im_session_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
LLGiveInventoryInfo* info = NULL;
|
||||
info = new LLGiveInventoryInfo(to_agent, cat->getUUID(), im_session_id);
|
||||
LLSD args;
|
||||
args["COUNT"] = llformat("%d",giveable.countNoCopy());
|
||||
LLSD payload;
|
||||
payload["agent_id"] = to_agent;
|
||||
payload["folder_id"] = cat->getUUID();
|
||||
LLNotificationsUtil::add("CannotCopyCountItems", args, payload, &LLToolDragAndDrop::handleCopyProtectedCategory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
bool LLToolDragAndDrop::handleCopyProtectedCategory(const LLSD& notification, const LLSD& response)
|
||||
{
|
||||
S32 option = LLNotification::getSelectedOption(notification, response);
|
||||
LLInventoryCategory* cat = NULL;
|
||||
switch(option)
|
||||
{
|
||||
case 0: // "Yes"
|
||||
cat = gInventory.getCategory(notification["payload"]["folder_id"].asUUID());
|
||||
if(cat)
|
||||
{
|
||||
LLToolDragAndDrop::commitGiveInventoryCategory(notification["payload"]["agent_id"].asUUID(),
|
||||
cat);
|
||||
LLViewerInventoryCategory::cat_array_t cats;
|
||||
LLViewerInventoryItem::item_array_t items;
|
||||
LLUncopyableItems remove;
|
||||
gInventory.collectDescendentsIf(cat->getUUID(),
|
||||
cats,
|
||||
items,
|
||||
LLInventoryModel::EXCLUDE_TRASH,
|
||||
remove);
|
||||
S32 count = items.count();
|
||||
for(S32 i = 0; i < count; ++i)
|
||||
{
|
||||
gInventory.deleteObject(items.get(i)->getUUID());
|
||||
}
|
||||
gInventory.notifyObservers();
|
||||
}
|
||||
else
|
||||
{
|
||||
LLNotificationsUtil::add("CannotGiveCategory");
|
||||
}
|
||||
break;
|
||||
|
||||
default: // no, cancel, whatever, who cares, not yes.
|
||||
LLNotificationsUtil::add("TransactionCancelled");
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
void LLToolDragAndDrop::commitGiveInventoryCategory(const LLUUID& to_agent,
|
||||
LLInventoryCategory* cat,
|
||||
const LLUUID& im_session_id)
|
||||
|
||||
{
|
||||
if(!cat) return;
|
||||
llinfos << "LLToolDragAndDrop::commitGiveInventoryCategory() - "
|
||||
<< cat->getUUID() << llendl;
|
||||
|
||||
// Test out how many items are being given.
|
||||
LLViewerInventoryCategory::cat_array_t cats;
|
||||
LLViewerInventoryItem::item_array_t items;
|
||||
LLGiveable giveable;
|
||||
gInventory.collectDescendentsIf(cat->getUUID(),
|
||||
cats,
|
||||
items,
|
||||
LLInventoryModel::EXCLUDE_TRASH,
|
||||
giveable);
|
||||
|
||||
// MAX ITEMS is based on (sizeof(uuid)+2) * count must be <
|
||||
// MTUBYTES or 18 * count < 1200 => count < 1200/18 =>
|
||||
// 66. I've cut it down a bit from there to give some pad.
|
||||
S32 count = items.count() + cats.count();
|
||||
if(count > MAX_ITEMS)
|
||||
{
|
||||
LLNotificationsUtil::add("TooManyItems");
|
||||
return;
|
||||
}
|
||||
else if(count == 0)
|
||||
{
|
||||
LLNotificationsUtil::add("NoItems");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string name;
|
||||
gAgent.buildFullname(name);
|
||||
LLUUID transaction_id;
|
||||
transaction_id.generate();
|
||||
S32 bucket_size = (sizeof(U8) + UUID_BYTES) * (count + 1);
|
||||
U8* bucket = new U8[bucket_size];
|
||||
U8* pos = bucket;
|
||||
U8 type = (U8)cat->getType();
|
||||
memcpy(pos, &type, sizeof(U8)); /* Flawfinder: ignore */
|
||||
pos += sizeof(U8);
|
||||
memcpy(pos, &(cat->getUUID()), UUID_BYTES); /* Flawfinder: ignore */
|
||||
pos += UUID_BYTES;
|
||||
S32 i;
|
||||
count = cats.count();
|
||||
for(i = 0; i < count; ++i)
|
||||
{
|
||||
memcpy(pos, &type, sizeof(U8)); /* Flawfinder: ignore */
|
||||
pos += sizeof(U8);
|
||||
memcpy(pos, &(cats.get(i)->getUUID()), UUID_BYTES); /* Flawfinder: ignore */
|
||||
pos += UUID_BYTES;
|
||||
}
|
||||
count = items.count();
|
||||
for(i = 0; i < count; ++i)
|
||||
{
|
||||
type = (U8)items.get(i)->getType();
|
||||
memcpy(pos, &type, sizeof(U8)); /* Flawfinder: ignore */
|
||||
pos += sizeof(U8);
|
||||
memcpy(pos, &(items.get(i)->getUUID()), UUID_BYTES); /* Flawfinder: ignore */
|
||||
pos += UUID_BYTES;
|
||||
}
|
||||
pack_instant_message(
|
||||
gMessageSystem,
|
||||
gAgent.getID(),
|
||||
FALSE,
|
||||
gAgent.getSessionID(),
|
||||
to_agent,
|
||||
name,
|
||||
cat->getName(),
|
||||
IM_ONLINE,
|
||||
IM_INVENTORY_OFFERED,
|
||||
transaction_id,
|
||||
0,
|
||||
LLUUID::null,
|
||||
gAgent.getPositionAgent(),
|
||||
NO_TIMESTAMP,
|
||||
bucket,
|
||||
bucket_size);
|
||||
gAgent.sendReliableMessage();
|
||||
delete[] bucket;
|
||||
// <edit>
|
||||
if (gSavedSettings.getBOOL("BroadcastViewerEffects"))
|
||||
{
|
||||
// </edit>
|
||||
// VEFFECT: giveInventoryCategory
|
||||
LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
|
||||
effectp->setSourceObject(gAgentAvatarp);
|
||||
effectp->setTargetObject(gObjectList.findObject(to_agent));
|
||||
effectp->setDuration(LL_HUD_DUR_SHORT);
|
||||
effectp->setColor(LLColor4U(gAgent.getEffectColor()));
|
||||
// <edit>
|
||||
}
|
||||
// </edit>
|
||||
gFloaterTools->dirty();
|
||||
|
||||
LLMuteList::getInstance()->autoRemove(to_agent, LLMuteList::AR_INVENTORY);
|
||||
|
||||
// If this item was given by drag-and-drop into an IM panel, log this action in the IM panel chat.
|
||||
if (im_session_id != LLUUID::null)
|
||||
{
|
||||
LLSD args;
|
||||
gIMMgr->addSystemMessage(im_session_id, "inventory_item_offered", args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
BOOL LLToolDragAndDrop::isInventoryGiveAcceptable(LLInventoryItem* item)
|
||||
{
|
||||
if(!item)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if(!item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
BOOL copyable = FALSE;
|
||||
if(item->getPermissions().allowCopyBy(gAgent.getID())) copyable = TRUE;
|
||||
|
||||
// <edit>
|
||||
/*LLVOAvatar* my_avatar = gAgentAvatarp;
|
||||
if(!my_avatar)
|
||||
{
|
||||
return FALSE;
|
||||
}*/
|
||||
// </edit>
|
||||
|
||||
// <edit>
|
||||
//BOOL acceptable = FALSE;
|
||||
BOOL acceptable = TRUE;
|
||||
// Might also look at what's down below
|
||||
// </edit>
|
||||
switch(item->getType())
|
||||
{
|
||||
case LLAssetType::AT_CALLINGCARD:
|
||||
acceptable = FALSE;
|
||||
break;
|
||||
case LLAssetType::AT_OBJECT:
|
||||
// <edit>
|
||||
/*if(my_avatar->isWearingAttachment(item->getUUID()))
|
||||
{
|
||||
acceptable = FALSE;
|
||||
}*/
|
||||
// </edit>
|
||||
break;
|
||||
case LLAssetType::AT_BODYPART:
|
||||
case LLAssetType::AT_CLOTHING:
|
||||
// <edit>
|
||||
/*if(!copyable && gAgentWearables.isWearingItem(item->getUUID()))
|
||||
{
|
||||
acceptable = FALSE;
|
||||
}*/
|
||||
// </edit>
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return acceptable;
|
||||
}
|
||||
|
||||
// Static
|
||||
BOOL LLToolDragAndDrop::isInventoryGroupGiveAcceptable(LLInventoryItem* item)
|
||||
{
|
||||
if(!item)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// These permissions are double checked in the simulator in
|
||||
// LLGroupNoticeInventoryItemFetch::result().
|
||||
if(!item->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if(!item->getPermissions().allowCopyBy(gAgent.getID()))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LLVOAvatar* my_avatar = gAgentAvatarp;
|
||||
if(!my_avatar)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL acceptable = TRUE;
|
||||
// <edit>
|
||||
/*
|
||||
// </edit>
|
||||
switch(item->getType())
|
||||
{
|
||||
case LLAssetType::AT_CALLINGCARD:
|
||||
acceptable = FALSE;
|
||||
break;
|
||||
case LLAssetType::AT_OBJECT:
|
||||
if(my_avatar->isWearingAttachment(item->getUUID()))
|
||||
{
|
||||
acceptable = FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// <edit>
|
||||
*/
|
||||
// </edit>
|
||||
return acceptable;
|
||||
}
|
||||
|
||||
// accessor that looks at permissions, copyability, and names of
|
||||
// inventory items to determine if a drop would be ok.
|
||||
EAcceptance LLToolDragAndDrop::willObjectAcceptInventory(LLViewerObject* obj, LLInventoryItem* item)
|
||||
@@ -2117,13 +1615,13 @@ bool LLToolDragAndDrop::handleGiveDragAndDrop(LLUUID dest_agent, LLUUID session_
|
||||
{
|
||||
LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data;
|
||||
if(gInventory.getItem(inv_item->getUUID())
|
||||
&& LLToolDragAndDrop::isInventoryGiveAcceptable(inv_item))
|
||||
&& LLGiveInventory::isInventoryGiveAcceptable(inv_item))
|
||||
{
|
||||
// *TODO: get multiple object transfers working
|
||||
*accept = ACCEPT_YES_COPY_SINGLE;
|
||||
if(drop)
|
||||
{
|
||||
LLToolDragAndDrop::giveInventory(dest_agent, inv_item, session_id);
|
||||
LLGiveInventory::doGiveInventoryItem(dest_agent, inv_item, session_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2145,7 +1643,7 @@ bool LLToolDragAndDrop::handleGiveDragAndDrop(LLUUID dest_agent, LLUUID session_
|
||||
*accept = ACCEPT_YES_COPY_SINGLE;
|
||||
if(drop)
|
||||
{
|
||||
LLToolDragAndDrop::giveInventoryCategory(dest_agent, inv_cat, session_id);
|
||||
LLGiveInventory::doGiveInventoryCategory(dest_agent, inv_cat, session_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2868,7 +2366,7 @@ EAcceptance LLToolDragAndDrop::dad3dGiveInventoryObject(
|
||||
{
|
||||
if(drop)
|
||||
{
|
||||
giveInventory(obj->getID(), item );
|
||||
LLGiveInventory::doGiveInventoryItem(obj->getID(), item );
|
||||
}
|
||||
// *TODO: deal with all the issues surrounding multi-object
|
||||
// inventory transfers.
|
||||
@@ -2888,13 +2386,13 @@ EAcceptance LLToolDragAndDrop::dad3dGiveInventory(
|
||||
LLViewerInventoryCategory* cat;
|
||||
locateInventory(item, cat);
|
||||
if(!item || !item->isComplete()) return ACCEPT_NO;
|
||||
if(!isInventoryGiveAcceptable(item))
|
||||
if(!LLGiveInventory::isInventoryGiveAcceptable(item))
|
||||
{
|
||||
return ACCEPT_NO;
|
||||
}
|
||||
if(drop && obj)
|
||||
{
|
||||
giveInventory(obj->getID(), item);
|
||||
LLGiveInventory::doGiveInventoryItem(obj->getID(), item);
|
||||
}
|
||||
// *TODO: deal with all the issues surrounding multi-object
|
||||
// inventory transfers.
|
||||
@@ -2911,7 +2409,7 @@ EAcceptance LLToolDragAndDrop::dad3dGiveInventoryCategory(
|
||||
LLViewerInventoryCategory* cat;
|
||||
locateInventory(item, cat);
|
||||
if(!cat) return ACCEPT_NO;
|
||||
giveInventoryCategory(obj->getID(), cat);
|
||||
LLGiveInventory::doGiveInventoryCategory(obj->getID(), cat);
|
||||
}
|
||||
// *TODO: deal with all the issues surrounding multi-object
|
||||
// inventory transfers.
|
||||
|
||||
@@ -208,27 +208,10 @@ protected:
|
||||
LLToolDragAndDrop::ESource source,
|
||||
const LLUUID& src_id);
|
||||
|
||||
|
||||
// give inventory item functionality
|
||||
static bool handleCopyProtectedItem(const LLSD& notification, const LLSD& response);
|
||||
static void commitGiveInventoryItem(const LLUUID& to_agent,
|
||||
LLInventoryItem* item,
|
||||
const LLUUID &im_session_id = LLUUID::null);
|
||||
|
||||
// give inventory category functionality
|
||||
static bool handleCopyProtectedCategory(const LLSD& notification, const LLSD& response);
|
||||
static void commitGiveInventoryCategory(const LLUUID& to_agent,
|
||||
LLInventoryCategory* cat,
|
||||
const LLUUID &im_session_id = LLUUID::null);
|
||||
|
||||
public:
|
||||
// helper functions
|
||||
static BOOL isInventoryDropAcceptable(LLViewerObject* obj, LLInventoryItem* item) { return (ACCEPT_YES_COPY_SINGLE <= willObjectAcceptInventory(obj, item)); }
|
||||
|
||||
// This simple helper function assumes you are attempting to
|
||||
// transfer item. returns true if you can give, otherwise false.
|
||||
static BOOL isInventoryGiveAcceptable(LLInventoryItem* item);
|
||||
static BOOL isInventoryGroupGiveAcceptable(LLInventoryItem* item);
|
||||
|
||||
BOOL dadUpdateInventory(LLViewerObject* obj, BOOL drop);
|
||||
BOOL dadUpdateInventoryCategory(LLViewerObject* obj, BOOL drop);
|
||||
@@ -255,13 +238,6 @@ public:
|
||||
ESource source,
|
||||
const LLUUID& src_id);
|
||||
|
||||
static void giveInventory(const LLUUID& to_agent,
|
||||
LLInventoryItem* item,
|
||||
const LLUUID &session_id = LLUUID::null);
|
||||
static void giveInventoryCategory(const LLUUID& to_agent,
|
||||
LLInventoryCategory* item,
|
||||
const LLUUID &session_id = LLUUID::null);
|
||||
|
||||
static bool handleGiveDragAndDrop(LLUUID agent, LLUUID session, BOOL drop,
|
||||
EDragAndDropType cargo_type,
|
||||
void* cargo_data,
|
||||
|
||||
@@ -167,6 +167,8 @@
|
||||
#include "llwlparammanager.h"
|
||||
#include "llwaterparammanager.h"
|
||||
|
||||
#include "llgiveinventory.h"
|
||||
|
||||
#include <boost/tokenizer.hpp>
|
||||
|
||||
#if LL_WINDOWS // For Windows specific error handler
|
||||
@@ -1972,7 +1974,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
|
||||
position,
|
||||
false);
|
||||
}
|
||||
LLToolDragAndDrop::giveInventory(from_id, item);
|
||||
LLGiveInventory::doGiveInventoryItem(from_id, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user