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"];
message = (string)requestData["message"];
if (message == null)
message = string.Empty;
// Bytes don't transfer well over XMLRPC, so, we Base64 Encode them.
string requestData1 = (string)requestData["dialog"];

View File

@ -145,10 +145,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{
ScenePresence presence = scene.GetScenePresence(agentId);
if (presence != null)
{
if (!presence.IsChildAgent)
return scene;
}
return scene;
}
}
return null;
@ -156,7 +153,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
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);
if (scene == null) // Something seriously wrong here.
@ -167,8 +164,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
if (im.dialog == (byte) InstantMessageDialog.InventoryOffered)
{
//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;
// First byte is the asset type
@ -183,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
folderID, new UUID(im.toAgentID));
InventoryFolderBase folderCopy
= scene.GiveInventoryFolder(new UUID(im.toAgentID), client.AgentId, folderID, UUID.Zero);
= scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero);
if (folderCopy == null)
{
@ -199,20 +197,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
im.binaryBucket[0] = (byte)AssetType.Folder;
Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length);
if (user != null && !user.IsChildAgent)
if (user != null)
{
user.ControllingClient.SendBulkUpdateInventory(folderCopy);
}
// HACK!!
im.imSessionID = folderID.Guid;
}
else
{
// First byte of the array is probably the item type
// Next 16 bytes are the UUID
m_log.Info("OnInstantMessage - giving item");
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",
itemID, new UUID(im.toAgentID));
@ -229,29 +229,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
copyID = itemCopy.ID;
Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16);
if (user != null && !user.IsChildAgent)
if (user != null)
{
user.ControllingClient.SendBulkUpdateInventory(itemCopy);
}
// HACK!!
im.imSessionID = itemID.Guid;
}
// Send the IM to the recipient. The item is already
// in their inventory, so it will not be lost if
// 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);
return;
}
else
{
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)
@ -282,10 +285,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
InventoryFolderBase trashFolder =
invService.GetFolderForType(client.AgentId, AssetType.TrashFolder);
UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip
InventoryItemBase item = new InventoryItemBase(inventoryEntityID, client.AgentId);
UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip
InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId);
item = invService.GetItem(item);
InventoryFolderBase folder = null;
@ -301,7 +304,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
}
else
{
folder = new InventoryFolderBase(inventoryEntityID, client.AgentId);
folder = new InventoryFolderBase(inventoryID, client.AgentId);
folder = invService.GetFolder(folder);
if (folder != null & trashFolder != null)
@ -417,90 +420,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{
// Check if this is ours to handle
//
//m_log.Info("OnFridInstantMessage");
if (msg.dialog != (byte) InstantMessageDialog.InventoryOffered)
return;
if (msg.binaryBucket.Length < 17) // Invalid
return;
m_log.Info("OnGridInstantMessage");
Scene scene = FindClientScene(new UUID(msg.toAgentID));
if (scene == null)
return;
// Find agent to deliver to
//
ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID));
if (user == null) // Shouldn't happen
{
m_log.Debug("[INVENTORY TRANSFER] Can't find recipient");
return;
}
// Just forward to local handling
OnInstantMessage(user.ControllingClient, msg);
//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
item.AssetID = asset.FullID;
if (group.UpdateInventoryItem(item))
remoteClient.SendAgentAlertMessage("Notecard saved", false);
remoteClient.SendAgentAlertMessage("Script saved", false);
part.GetProperties(remoteClient);