Merge branch 'master' into careminster-presence-refactor

avinationmerge
Melanie 2010-06-11 20:35:00 +01:00
commit 1cfebca48d
3 changed files with 34 additions and 99 deletions

View File

@ -268,6 +268,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
fromAgentName = (string)requestData["from_agent_name"]; fromAgentName = (string)requestData["from_agent_name"];
message = (string)requestData["message"]; message = (string)requestData["message"];
if (message == null)
message = string.Empty;
// Bytes don't transfer well over XMLRPC, so, we Base64 Encode them. // Bytes don't transfer well over XMLRPC, so, we Base64 Encode them.
string requestData1 = (string)requestData["dialog"]; string requestData1 = (string)requestData["dialog"];

View File

@ -145,10 +145,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{ {
ScenePresence presence = scene.GetScenePresence(agentId); ScenePresence presence = scene.GetScenePresence(agentId);
if (presence != null) if (presence != null)
{ return scene;
if (!presence.IsChildAgent)
return scene;
}
} }
} }
return null; return null;
@ -156,7 +153,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
private void OnInstantMessage(IClientAPI client, GridInstantMessage im) private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
{ {
m_log.InfoFormat("OnInstantMessage {0}", im.dialog); m_log.InfoFormat("[INVENTORY TRANSFER]: OnInstantMessage {0}", im.dialog);
Scene scene = FindClientScene(client.AgentId); Scene scene = FindClientScene(client.AgentId);
if (scene == null) // Something seriously wrong here. if (scene == null) // Something seriously wrong here.
@ -168,7 +165,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{ {
//m_log.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0])); //m_log.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0]));
ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); UUID receipientID = new UUID(im.toAgentID);
ScenePresence user = scene.GetScenePresence(receipientID);
UUID copyID; UUID copyID;
// First byte is the asset type // First byte is the asset type
@ -183,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
folderID, new UUID(im.toAgentID)); folderID, new UUID(im.toAgentID));
InventoryFolderBase folderCopy InventoryFolderBase folderCopy
= scene.GiveInventoryFolder(new UUID(im.toAgentID), client.AgentId, folderID, UUID.Zero); = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero);
if (folderCopy == null) if (folderCopy == null)
{ {
@ -199,20 +197,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
im.binaryBucket[0] = (byte)AssetType.Folder; im.binaryBucket[0] = (byte)AssetType.Folder;
Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length); Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length);
if (user != null && !user.IsChildAgent) if (user != null)
{ {
user.ControllingClient.SendBulkUpdateInventory(folderCopy); user.ControllingClient.SendBulkUpdateInventory(folderCopy);
} }
// HACK!!
im.imSessionID = folderID.Guid;
} }
else else
{ {
// First byte of the array is probably the item type // First byte of the array is probably the item type
// Next 16 bytes are the UUID // Next 16 bytes are the UUID
m_log.Info("OnInstantMessage - giving item");
UUID itemID = new UUID(im.binaryBucket, 1); UUID itemID = new UUID(im.binaryBucket, 1);
m_log.DebugFormat("[AGENT INVENTORY]: Inserting item {0} "+ m_log.DebugFormat("[AGENT INVENTORY]: (giving) Inserting item {0} "+
"into agent {1}'s inventory", "into agent {1}'s inventory",
itemID, new UUID(im.toAgentID)); itemID, new UUID(im.toAgentID));
@ -229,29 +229,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
copyID = itemCopy.ID; copyID = itemCopy.ID;
Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16); Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16);
if (user != null && !user.IsChildAgent) if (user != null)
{ {
user.ControllingClient.SendBulkUpdateInventory(itemCopy); user.ControllingClient.SendBulkUpdateInventory(itemCopy);
} }
// HACK!!
im.imSessionID = itemID.Guid;
} }
// Send the IM to the recipient. The item is already // Send the IM to the recipient. The item is already
// in their inventory, so it will not be lost if // in their inventory, so it will not be lost if
// they are offline. // they are offline.
// //
if (user != null && !user.IsChildAgent) if (user != null)
{ {
// And notify. Transaction ID is the item ID. We get that
// same ID back on the reply so we know what to act on
//
user.ControllingClient.SendInstantMessage(im); user.ControllingClient.SendInstantMessage(im);
return; return;
} }
else else
{ {
if (m_TransferModule != null) if (m_TransferModule != null)
m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); m_TransferModule.SendInstantMessage(im, delegate(bool success)
{
if (!success)
client.SendAlertMessage("User not online. Inventory has been saved");
});
} }
} }
else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted)
@ -283,9 +286,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
InventoryFolderBase trashFolder = InventoryFolderBase trashFolder =
invService.GetFolderForType(client.AgentId, AssetType.TrashFolder); invService.GetFolderForType(client.AgentId, AssetType.TrashFolder);
UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip
InventoryItemBase item = new InventoryItemBase(inventoryEntityID, client.AgentId); InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId);
item = invService.GetItem(item); item = invService.GetItem(item);
InventoryFolderBase folder = null; InventoryFolderBase folder = null;
@ -301,7 +304,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
} }
else else
{ {
folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); folder = new InventoryFolderBase(inventoryID, client.AgentId);
folder = invService.GetFolder(folder); folder = invService.GetFolder(folder);
if (folder != null & trashFolder != null) if (folder != null & trashFolder != null)
@ -417,90 +420,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{ {
// Check if this is ours to handle // Check if this is ours to handle
// //
//m_log.Info("OnFridInstantMessage"); m_log.Info("OnGridInstantMessage");
if (msg.dialog != (byte) InstantMessageDialog.InventoryOffered)
return;
if (msg.binaryBucket.Length < 17) // Invalid
return;
Scene scene = FindClientScene(new UUID(msg.toAgentID)); Scene scene = FindClientScene(new UUID(msg.toAgentID));
if (scene == null)
return;
// Find agent to deliver to // Find agent to deliver to
// //
ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID));
if (user == null) // Shouldn't happen // Just forward to local handling
{ OnInstantMessage(user.ControllingClient, msg);
m_log.Debug("[INVENTORY TRANSFER] Can't find recipient");
return;
}
//CachedUserInfo userInfo =
// scene.CommsManager.UserProfileCacheService.
// GetUserDetails(user.ControllingClient.AgentId);
//if (userInfo == null)
//{
// m_log.Debug("[INVENTORY TRANSFER] Can't find user info of recipient");
// return;
//}
AssetType assetType = (AssetType)msg.binaryBucket[0];
IInventoryService invService = scene.InventoryService;
if (AssetType.Folder == assetType)
{
UUID folderID = new UUID(msg.binaryBucket, 1);
InventoryFolderBase folder = new InventoryFolderBase();
folder.ID = folderID;
folder.Owner = user.ControllingClient.AgentId;
// Fetch from service
//
folder = invService.GetFolder(folder);
if (folder == null)
{
m_log.Debug("[INVENTORY TRANSFER] Can't find folder to give");
return;
}
user.ControllingClient.SendBulkUpdateInventory(folder);
//// This unelegant, slow kludge is to reload the folders and
//// items. Since a folder give can transfer subfolders and
//// items, this is the easiest way to pull that stuff in
////
//userInfo.DropInventory();
//userInfo.FetchInventory();
// Deliver message
//
user.ControllingClient.SendInstantMessage(msg);
}
else
{
UUID itemID = new UUID(msg.binaryBucket, 1);
InventoryItemBase item = new InventoryItemBase(itemID, user.ControllingClient.AgentId);
// Fetch from service
//
item = invService.GetItem(item);
if (item == null)
{
m_log.Debug("[INVENTORY TRANSFER] Can't find item to give");
return;
}
// Update item to viewer (makes it appear in proper folder)
//
user.ControllingClient.SendBulkUpdateInventory(item);
// Deliver message
//
user.ControllingClient.SendInstantMessage(msg);
}
} }
} }
} }

View File

@ -219,7 +219,7 @@ namespace OpenSim.Region.Framework.Scenes
// Update item with new asset // Update item with new asset
item.AssetID = asset.FullID; item.AssetID = asset.FullID;
if (group.UpdateInventoryItem(item)) if (group.UpdateInventoryItem(item))
remoteClient.SendAgentAlertMessage("Notecard saved", false); remoteClient.SendAgentAlertMessage("Script saved", false);
part.GetProperties(remoteClient); part.GetProperties(remoteClient);