Seth ProductEngine avatar Seth ProductEngine committed fd87b92

STORM-159 FIXED Added sharing inventory item by dropping it on resident's Profile SP even when no IM session is started with that resident.

Comments (0)

Files changed (1)

indra/newview/lltooldraganddrop.cpp

 	}
 }
 
+static void show_item_sharing_confirmation(const std::string name,
+										   LLViewerInventoryItem* inv_item,
+										   const LLSD& dest,
+										   const LLUUID& dest_agent,
+										   const LLUUID& session_id = LLUUID::null)
+{
+	if (!inv_item)
+	{
+		llassert(NULL != inv_item);
+		return;
+	}
+
+	LLSD substitutions;
+	substitutions["RESIDENTS"] = name;
+	substitutions["ITEMS"] = inv_item ? inv_item->getName() : LLStringUtil::null;
+	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& first_name,
+						const std::string& last_name,
+						LLViewerInventoryItem* inv_item,
+						const LLSD& dest,
+						const LLUUID& dest_agent)
+{
+	show_item_sharing_confirmation(first_name + " " + last_name,
+								   inv_item,
+								   dest,
+								   id,
+								   LLUUID::null);
+}
+
 // function used as drag-and-drop handler for simple agent give inventory requests
 //static
 bool LLToolDragAndDrop::handleGiveDragAndDrop(LLUUID dest_agent, LLUUID session_id, BOOL drop,
 			if (drop)
 			{
 				LLIMModel::LLIMSession * session = LLIMModel::instance().findIMSession(session_id);
+
+				// If no IM session found get the destination agent's name by id.
 				if (NULL == session)
 				{
-					llassert(NULL != session);
-					return false;
+					std::string fullname;
+
+					// If destination agent's name is found in cash proceed to showing the confirmation dialog.
+					// 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);
+					}
+					else
+					{
+						gCacheName->get(dest_agent, FALSE, boost::bind(&get_name_cb, _1, _2, _3, inv_item, dest, dest_agent));
+					}
+
+					return true;
 				}
-				LLSD substitutions;
-				substitutions["RESIDENTS"] = session->mName;
-				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);
+
+				// 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.