diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | 166 |
1 files changed, 65 insertions, 101 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index bcb7f42..bba48cc 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -47,10 +47,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
47 | 47 | ||
48 | /// <summary> | 48 | /// <summary> |
49 | private List<Scene> m_Scenelist = new List<Scene>(); | 49 | private List<Scene> m_Scenelist = new List<Scene>(); |
50 | // private Dictionary<UUID, Scene> m_AgentRegions = | ||
51 | // new Dictionary<UUID, Scene>(); | ||
52 | 50 | ||
53 | private IMessageTransferModule m_TransferModule = null; | 51 | private IMessageTransferModule m_TransferModule; |
54 | private bool m_Enabled = true; | 52 | private bool m_Enabled = true; |
55 | 53 | ||
56 | #region Region Module interface | 54 | #region Region Module interface |
@@ -81,9 +79,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
81 | // scene.RegisterModuleInterface<IInventoryTransferModule>(this); | 79 | // scene.RegisterModuleInterface<IInventoryTransferModule>(this); |
82 | 80 | ||
83 | scene.EventManager.OnNewClient += OnNewClient; | 81 | scene.EventManager.OnNewClient += OnNewClient; |
84 | // scene.EventManager.OnClientClosed += ClientLoggedOut; | ||
85 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | 82 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; |
86 | // scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene; | ||
87 | } | 83 | } |
88 | 84 | ||
89 | public void RegionLoaded(Scene scene) | 85 | public void RegionLoaded(Scene scene) |
@@ -96,11 +92,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
96 | m_log.Error("[INVENTORY TRANSFER]: No Message transfer module found, transfers will be local only"); | 92 | m_log.Error("[INVENTORY TRANSFER]: No Message transfer module found, transfers will be local only"); |
97 | m_Enabled = false; | 93 | m_Enabled = false; |
98 | 94 | ||
99 | m_Scenelist.Clear(); | 95 | // m_Scenelist.Clear(); |
100 | scene.EventManager.OnNewClient -= OnNewClient; | 96 | // scene.EventManager.OnNewClient -= OnNewClient; |
101 | // scene.EventManager.OnClientClosed -= ClientLoggedOut; | ||
102 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | 97 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; |
103 | // scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene; | ||
104 | } | 98 | } |
105 | } | 99 | } |
106 | } | 100 | } |
@@ -108,9 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
108 | public void RemoveRegion(Scene scene) | 102 | public void RemoveRegion(Scene scene) |
109 | { | 103 | { |
110 | scene.EventManager.OnNewClient -= OnNewClient; | 104 | scene.EventManager.OnNewClient -= OnNewClient; |
111 | // scene.EventManager.OnClientClosed -= ClientLoggedOut; | ||
112 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | 105 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; |
113 | // scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene; | ||
114 | m_Scenelist.Remove(scene); | 106 | m_Scenelist.Remove(scene); |
115 | } | 107 | } |
116 | 108 | ||
@@ -139,11 +131,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
139 | // Inventory giving is conducted via instant message | 131 | // Inventory giving is conducted via instant message |
140 | client.OnInstantMessage += OnInstantMessage; | 132 | client.OnInstantMessage += OnInstantMessage; |
141 | } | 133 | } |
142 | |||
143 | // protected void OnSetRootAgentScene(UUID id, Scene scene) | ||
144 | // { | ||
145 | // m_AgentRegions[id] = scene; | ||
146 | // } | ||
147 | 134 | ||
148 | private Scene FindClientScene(UUID agentId) | 135 | private Scene FindClientScene(UUID agentId) |
149 | { | 136 | { |
@@ -162,8 +149,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
162 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) | 149 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) |
163 | { | 150 | { |
164 | // m_log.DebugFormat( | 151 | // m_log.DebugFormat( |
165 | // "[INVENTORY TRANSFER]: {0} IM type received from {1}", | 152 | // "[INVENTORY TRANSFER]: {0} IM type received from client {1}. From={2} ({3}), To={4}", |
166 | // (InstantMessageDialog)im.dialog, client.Name); | 153 | // (InstantMessageDialog)im.dialog, client.Name, |
154 | // im.fromAgentID, im.fromAgentName, im.toAgentID); | ||
167 | 155 | ||
168 | Scene scene = FindClientScene(client.AgentId); | 156 | Scene scene = FindClientScene(client.AgentId); |
169 | 157 | ||
@@ -188,12 +176,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
188 | { | 176 | { |
189 | UUID folderID = new UUID(im.binaryBucket, 1); | 177 | UUID folderID = new UUID(im.binaryBucket, 1); |
190 | 178 | ||
191 | m_log.DebugFormat("[INVENTORY TRANSFER]: Inserting original folder {0} "+ | 179 | m_log.DebugFormat( |
192 | "into agent {1}'s inventory", | 180 | "[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory", |
193 | folderID, new UUID(im.toAgentID)); | 181 | folderID, new UUID(im.toAgentID)); |
194 | 182 | ||
195 | InventoryFolderBase folderCopy | 183 | InventoryFolderBase folderCopy |
196 | = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); | 184 | = scene.GiveInventoryFolder(client, receipientID, client.AgentId, folderID, UUID.Zero); |
197 | 185 | ||
198 | if (folderCopy == null) | 186 | if (folderCopy == null) |
199 | { | 187 | { |
@@ -213,7 +201,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
213 | user.ControllingClient.SendBulkUpdateInventory(folderCopy); | 201 | user.ControllingClient.SendBulkUpdateInventory(folderCopy); |
214 | 202 | ||
215 | // HACK!! | 203 | // HACK!! |
216 | im.imSessionID = folderID.Guid; | 204 | // Insert the ID of the copied folder into the IM so that we know which item to move to trash if it |
205 | // is rejected. | ||
206 | // XXX: This is probably a misuse of the session ID slot. | ||
207 | im.imSessionID = copyID.Guid; | ||
217 | } | 208 | } |
218 | else | 209 | else |
219 | { | 210 | { |
@@ -226,13 +217,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
226 | "into agent {1}'s inventory", | 217 | "into agent {1}'s inventory", |
227 | itemID, new UUID(im.toAgentID)); | 218 | itemID, new UUID(im.toAgentID)); |
228 | 219 | ||
229 | InventoryItemBase itemCopy = scene.GiveInventoryItem( | 220 | string message; |
230 | new UUID(im.toAgentID), | 221 | InventoryItemBase itemCopy = scene.GiveInventoryItem(new UUID(im.toAgentID), client.AgentId, itemID, out message); |
231 | client.AgentId, itemID); | ||
232 | 222 | ||
233 | if (itemCopy == null) | 223 | if (itemCopy == null) |
234 | { | 224 | { |
235 | client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); | 225 | client.SendAgentAlertMessage(message, false); |
236 | return; | 226 | return; |
237 | } | 227 | } |
238 | 228 | ||
@@ -243,7 +233,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
243 | user.ControllingClient.SendBulkUpdateInventory(itemCopy); | 233 | user.ControllingClient.SendBulkUpdateInventory(itemCopy); |
244 | 234 | ||
245 | // HACK!! | 235 | // HACK!! |
246 | im.imSessionID = itemID.Guid; | 236 | // Insert the ID of the copied item into the IM so that we know which item to move to trash if it |
237 | // is rejected. | ||
238 | // XXX: This is probably a misuse of the session ID slot. | ||
239 | im.imSessionID = copyID.Guid; | ||
247 | } | 240 | } |
248 | 241 | ||
249 | // Send the IM to the recipient. The item is already | 242 | // Send the IM to the recipient. The item is already |
@@ -379,7 +372,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
379 | IInventoryService invService = scene.InventoryService; | 372 | IInventoryService invService = scene.InventoryService; |
380 | 373 | ||
381 | InventoryFolderBase trashFolder = | 374 | InventoryFolderBase trashFolder = |
382 | invService.GetFolderForType(client.AgentId, AssetType.TrashFolder); | 375 | invService.GetFolderForType(client.AgentId, FolderType.Trash); |
383 | 376 | ||
384 | UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip | 377 | UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip |
385 | 378 | ||
@@ -403,7 +396,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
403 | { | 396 | { |
404 | folder = new InventoryFolderBase(inventoryID, client.AgentId); | 397 | folder = new InventoryFolderBase(inventoryID, client.AgentId); |
405 | folder = invService.GetFolder(folder); | 398 | folder = invService.GetFolder(folder); |
406 | 399 | ||
407 | if (folder != null & trashFolder != null) | 400 | if (folder != null & trashFolder != null) |
408 | { | 401 | { |
409 | previousParentFolderID = folder.ParentID; | 402 | previousParentFolderID = folder.ParentID; |
@@ -454,90 +447,61 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
454 | } | 447 | } |
455 | } | 448 | } |
456 | 449 | ||
457 | // public bool NeedSceneCacheClear(UUID agentID, Scene scene) | ||
458 | // { | ||
459 | // if (!m_AgentRegions.ContainsKey(agentID)) | ||
460 | // { | ||
461 | // // Since we can get here two ways, we need to scan | ||
462 | // // the scenes here. This is somewhat more expensive | ||
463 | // // but helps avoid a nasty bug | ||
464 | // // | ||
465 | // | ||
466 | // foreach (Scene s in m_Scenelist) | ||
467 | // { | ||
468 | // ScenePresence presence; | ||
469 | // | ||
470 | // if (s.TryGetScenePresence(agentID, out presence)) | ||
471 | // { | ||
472 | // // If the agent is in this scene, then we | ||
473 | // // are being called twice in a single | ||
474 | // // teleport. This is wasteful of cycles | ||
475 | // // but harmless due to this 2nd level check | ||
476 | // // | ||
477 | // // If the agent is found in another scene | ||
478 | // // then the list wasn't current | ||
479 | // // | ||
480 | // // If the agent is totally unknown, then what | ||
481 | // // are we even doing here?? | ||
482 | // // | ||
483 | // if (s == scene) | ||
484 | // { | ||
485 | // //m_log.Debug("[INVTRANSFERMOD]: s == scene. Returning true in " + scene.RegionInfo.RegionName); | ||
486 | // return true; | ||
487 | // } | ||
488 | // else | ||
489 | // { | ||
490 | // //m_log.Debug("[INVTRANSFERMOD]: s != scene. Returning false in " + scene.RegionInfo.RegionName); | ||
491 | // return false; | ||
492 | // } | ||
493 | // } | ||
494 | // } | ||
495 | // //m_log.Debug("[INVTRANSFERMOD]: agent not in scene. Returning true in " + scene.RegionInfo.RegionName); | ||
496 | // return true; | ||
497 | // } | ||
498 | // | ||
499 | // // The agent is left in current Scene, so we must be | ||
500 | // // going to another instance | ||
501 | // // | ||
502 | // if (m_AgentRegions[agentID] == scene) | ||
503 | // { | ||
504 | // //m_log.Debug("[INVTRANSFERMOD]: m_AgentRegions[agentID] == scene. Returning true in " + scene.RegionInfo.RegionName); | ||
505 | // m_AgentRegions.Remove(agentID); | ||
506 | // return true; | ||
507 | // } | ||
508 | // | ||
509 | // // Another region has claimed the agent | ||
510 | // // | ||
511 | // //m_log.Debug("[INVTRANSFERMOD]: last resort. Returning false in " + scene.RegionInfo.RegionName); | ||
512 | // return false; | ||
513 | // } | ||
514 | // | ||
515 | // public void ClientLoggedOut(UUID agentID, Scene scene) | ||
516 | // { | ||
517 | // if (m_AgentRegions.ContainsKey(agentID)) | ||
518 | // m_AgentRegions.Remove(agentID); | ||
519 | // } | ||
520 | |||
521 | /// <summary> | 450 | /// <summary> |
522 | /// | 451 | /// |
523 | /// </summary> | 452 | /// </summary> |
524 | /// <param name="msg"></param> | 453 | /// <param name="im"></param> |
525 | private void OnGridInstantMessage(GridInstantMessage msg) | 454 | private void OnGridInstantMessage(GridInstantMessage im) |
526 | { | 455 | { |
456 | // Check if it's a type of message that we should handle | ||
457 | if (!((im.dialog == (byte) InstantMessageDialog.InventoryOffered) | ||
458 | || (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered) | ||
459 | || (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) | ||
460 | || (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) | ||
461 | || (im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined))) | ||
462 | return; | ||
463 | |||
464 | m_log.DebugFormat( | ||
465 | "[INVENTORY TRANSFER]: {0} IM type received from grid. From={1} ({2}), To={3}", | ||
466 | (InstantMessageDialog)im.dialog, im.fromAgentID, im.fromAgentName, im.toAgentID); | ||
467 | |||
527 | // Check if this is ours to handle | 468 | // Check if this is ours to handle |
528 | // | 469 | // |
529 | Scene scene = FindClientScene(new UUID(msg.toAgentID)); | 470 | Scene scene = FindClientScene(new UUID(im.toAgentID)); |
530 | 471 | ||
531 | if (scene == null) | 472 | if (scene == null) |
532 | return; | 473 | return; |
533 | 474 | ||
534 | // Find agent to deliver to | 475 | // Find agent to deliver to |
535 | // | 476 | // |
536 | ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); | 477 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
537 | 478 | ||
538 | // Just forward to local handling | 479 | if (user != null) |
539 | OnInstantMessage(user.ControllingClient, msg); | 480 | { |
481 | user.ControllingClient.SendInstantMessage(im); | ||
482 | |||
483 | if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) | ||
484 | { | ||
485 | AssetType assetType = (AssetType)im.binaryBucket[0]; | ||
486 | UUID inventoryID = new UUID(im.binaryBucket, 1); | ||
487 | |||
488 | IInventoryService invService = scene.InventoryService; | ||
489 | InventoryNodeBase node = null; | ||
490 | if (AssetType.Folder == assetType) | ||
491 | { | ||
492 | InventoryFolderBase folder = new InventoryFolderBase(inventoryID, new UUID(im.toAgentID)); | ||
493 | node = invService.GetFolder(folder); | ||
494 | } | ||
495 | else | ||
496 | { | ||
497 | InventoryItemBase item = new InventoryItemBase(inventoryID, new UUID(im.toAgentID)); | ||
498 | node = invService.GetItem(item); | ||
499 | } | ||
540 | 500 | ||
501 | if (node != null) | ||
502 | user.ControllingClient.SendBulkUpdateInventory(node); | ||
503 | } | ||
504 | } | ||
541 | } | 505 | } |
542 | } | 506 | } |
543 | } | 507 | } |