diff options
| author | Paul ProductEngine <pguslisty@productengine.com> | 2012-04-04 20:08:38 +0300 | 
|---|---|---|
| committer | Paul ProductEngine <pguslisty@productengine.com> | 2012-04-04 20:08:38 +0300 | 
| commit | 823a52756a78598cc32efac53d9adb8c760b99e9 (patch) | |
| tree | 485d3b5ddbb0dc62eeac10e795d794c26db46f3f /indra/newview | |
| parent | 780075cecc3d7b8b1558142081a2c407597402b9 (diff) | |
MAINT-830 FIXED ([PUBLIC]"Items successfully shared" appears even when share fails)
- Added check whether sharing inventory category or inventory item was successful
Diffstat (limited to 'indra/newview')
| -rwxr-xr-x | indra/newview/llavataractions.cpp | 16 | ||||
| -rw-r--r-- | indra/newview/llgiveinventory.cpp | 68 | ||||
| -rw-r--r-- | indra/newview/llgiveinventory.h | 7 | 
3 files changed, 67 insertions, 24 deletions
| diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index 9a7cdcfa21..267e0f03b9 100755 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -594,7 +594,7 @@ namespace action_give_inventory  		}  		S32 count = LLShareInfo::instance().mAvatarNames.size(); -		bool shared = false; +		bool shared = count && !inventory_selected_uuids.empty();  		// iterate through avatars  		for(S32 i = 0; i < count; ++i) @@ -616,8 +616,10 @@ namespace action_give_inventory  				LLViewerInventoryCategory* inv_cat = gInventory.getCategory(*it);  				if (inv_cat)  				{ -					LLGiveInventory::doGiveInventoryCategory(avatar_uuid, inv_cat, session_id); -					shared = true; +					if (!LLGiveInventory::doGiveInventoryCategory(avatar_uuid, inv_cat, session_id, "ItemsShared")) +					{ +						shared = false; +					}  					break;  				}  				LLViewerInventoryItem* inv_item = gInventory.getItem(*it); @@ -632,8 +634,10 @@ namespace action_give_inventory  				}  				else  				{ -				LLGiveInventory::doGiveInventoryItem(avatar_uuid, inv_item, session_id); -					shared = true; +					if (!LLGiveInventory::doGiveInventoryItem(avatar_uuid, inv_item, session_id)) +					{ +						shared = false; +					}  				}  			}  			if (noncopy_items.beginArray() != noncopy_items.endArray()) @@ -643,8 +647,10 @@ namespace action_give_inventory  				LLSD payload;  				payload["agent_id"] = avatar_uuid;  				payload["items"] = noncopy_items; +				payload["success_notification"] = "ItemsShared";  				LLNotificationsUtil::add("CannotCopyWarning", substitutions, payload,  					&LLGiveInventory::handleCopyProtectedItem); +				shared = false;  				break;  			}  		} diff --git a/indra/newview/llgiveinventory.cpp b/indra/newview/llgiveinventory.cpp index 30858871ec..72bea8db10 100644 --- a/indra/newview/llgiveinventory.cpp +++ b/indra/newview/llgiveinventory.cpp @@ -220,17 +220,25 @@ bool LLGiveInventory::doGiveInventoryItem(const LLUUID& to_agent,  	return res;  } -void LLGiveInventory::doGiveInventoryCategory(const LLUUID& to_agent, +bool LLGiveInventory::doGiveInventoryCategory(const LLUUID& to_agent,  											  const LLInventoryCategory* cat, -											  const LLUUID& im_session_id) +											  const LLUUID& im_session_id, +											  const std::string& notification_name)  { -	if (!cat) return; +	if (!cat) +	{ +		return false; +	}  	llinfos << "LLGiveInventory::giveInventoryCategory() - "  		<< cat->getUUID() << llendl; -	if (!isAgentAvatarValid()) return; +	if (!isAgentAvatarValid()) +	{ +		return false; +	} +	bool give_successful = true;  	// Test out how many items are being given.  	LLViewerInventoryCategory::cat_array_t cats;  	LLViewerInventoryItem::item_array_t items; @@ -253,24 +261,24 @@ void LLGiveInventory::doGiveInventoryCategory(const LLUUID& to_agent,  	if (!complete)  	{  		LLNotificationsUtil::add("IncompleteInventory"); -		return; +		give_successful = false;  	}  	count = items.count() + cats.count();  	if (count > MAX_ITEMS)  	{  		LLNotificationsUtil::add("TooManyItems"); -		return; +		give_successful = false;  	}  	else if (count == 0)  	{  		LLNotificationsUtil::add("NoItems"); -		return; +		give_successful = false;  	} -	else +	else if (give_successful)  	{  		if (0 == giveable.countNoCopy())  		{ -			LLGiveInventory::commitGiveInventoryCategory(to_agent, cat, im_session_id); +			give_successful = LLGiveInventory::commitGiveInventoryCategory(to_agent, cat, im_session_id);  		}  		else  		{ @@ -279,9 +287,16 @@ void LLGiveInventory::doGiveInventoryCategory(const LLUUID& to_agent,  			LLSD payload;  			payload["agent_id"] = to_agent;  			payload["folder_id"] = cat->getUUID(); +			if (!notification_name.empty()) +			{ +				payload["success_notification"] = notification_name; +			}  			LLNotificationsUtil::add("CannotCopyCountItems", args, payload, &LLGiveInventory::handleCopyProtectedCategory); +			give_successful = false;  		}  	} + +	return give_successful;  }  ////////////////////////////////////////////////////////////////////////// @@ -325,6 +340,7 @@ bool LLGiveInventory::handleCopyProtectedItem(const LLSD& notification, const LL  	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);  	LLSD itmes = notification["payload"]["items"];  	LLInventoryItem* item = NULL; +	bool give_successful = true;  	switch(option)  	{  	case 0:  // "Yes" @@ -343,15 +359,21 @@ bool LLGiveInventory::handleCopyProtectedItem(const LLSD& notification, const LL  			else  			{  				LLNotificationsUtil::add("CannotGiveItem"); +				give_successful = false;  			}  		} +		if (give_successful && notification["payload"]["success_notification"].isDefined()) +		{ +			LLNotificationsUtil::add(notification["payload"]["success_notification"].asString()); +		}  		break;  	default: // no, cancel, whatever, who cares, not yes.  		LLNotificationsUtil::add("TransactionCancelled"); +		give_successful = false;  		break;  	} -	return false; +	return give_successful;  }  // static @@ -408,13 +430,14 @@ bool LLGiveInventory::handleCopyProtectedCategory(const LLSD& notification, cons  {  	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);  	LLInventoryCategory* cat = NULL; +	bool give_successful = true;  	switch(option)  	{  	case 0:  // "Yes"  		cat = gInventory.getCategory(notification["payload"]["folder_id"].asUUID());  		if (cat)  		{ -			LLGiveInventory::commitGiveInventoryCategory(notification["payload"]["agent_id"].asUUID(), +			give_successful = LLGiveInventory::commitGiveInventoryCategory(notification["payload"]["agent_id"].asUUID(),  				cat);  			LLViewerInventoryCategory::cat_array_t cats;  			LLViewerInventoryItem::item_array_t items; @@ -430,27 +453,37 @@ bool LLGiveInventory::handleCopyProtectedCategory(const LLSD& notification, cons  				gInventory.deleteObject(items.get(i)->getUUID());  			}  			gInventory.notifyObservers(); + +			if (give_successful && notification["payload"]["success_notification"].isDefined()) +			{ +				LLNotificationsUtil::add(notification["payload"]["success_notification"].asString()); +			}  		}  		else  		{  			LLNotificationsUtil::add("CannotGiveCategory"); +			give_successful = false;  		}  		break;  	default: // no, cancel, whatever, who cares, not yes.  		LLNotificationsUtil::add("TransactionCancelled"); +		give_successful = false;  		break;  	} -	return false; +	return give_successful;  }  // static -void LLGiveInventory::commitGiveInventoryCategory(const LLUUID& to_agent, +bool LLGiveInventory::commitGiveInventoryCategory(const LLUUID& to_agent,  													const LLInventoryCategory* cat,  													const LLUUID& im_session_id)  { -	if (!cat) return; +	if (!cat) +	{ +		return false; +	}  	llinfos << "LLGiveInventory::commitGiveInventoryCategory() - "  		<< cat->getUUID() << llendl; @@ -467,6 +500,7 @@ void LLGiveInventory::commitGiveInventoryCategory(const LLUUID& to_agent,  		LLInventoryModel::EXCLUDE_TRASH,  		giveable); +	bool give_successful = true;  	// 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. @@ -474,12 +508,12 @@ void LLGiveInventory::commitGiveInventoryCategory(const LLUUID& to_agent,  	if (count > MAX_ITEMS)  	{  		LLNotificationsUtil::add("TooManyItems"); -		return; +		give_successful = false;  	}  	else if (count == 0)  	{  		LLNotificationsUtil::add("NoItems"); -		return; +		give_successful = false;  	}  	else  	{ @@ -545,6 +579,8 @@ void LLGiveInventory::commitGiveInventoryCategory(const LLUUID& to_agent,  		logInventoryOffer(to_agent, im_session_id);  	} + +	return give_successful;  }  // EOF diff --git a/indra/newview/llgiveinventory.h b/indra/newview/llgiveinventory.h index e1e221c75b..85bc1ed49c 100644 --- a/indra/newview/llgiveinventory.h +++ b/indra/newview/llgiveinventory.h @@ -62,9 +62,10 @@ public:  	/**  	 * Gives passed inventory category to specified avatar in specified session.  	 */ -	static void doGiveInventoryCategory(const LLUUID& to_agent, +	static bool doGiveInventoryCategory(const LLUUID& to_agent,  									const LLInventoryCategory* item, -									const LLUUID &session_id = LLUUID::null); +									const LLUUID &session_id = LLUUID::null, +									const std::string& notification = std::string());  	// give inventory item functionality  	static bool handleCopyProtectedItem(const LLSD& notification, const LLSD& response); @@ -85,7 +86,7 @@ private:  	// give inventory category functionality  	static bool handleCopyProtectedCategory(const LLSD& notification, const LLSD& response); -	static void commitGiveInventoryCategory(const LLUUID& to_agent, +	static bool commitGiveInventoryCategory(const LLUUID& to_agent,  									const LLInventoryCategory* cat,  									const LLUUID &im_session_id = LLUUID::null); | 
