diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | 310 |
1 files changed, 159 insertions, 151 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 33b4839..582aac4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
@@ -38,20 +39,21 @@ using OpenSim.Services.Interfaces; | |||
38 | 39 | ||
39 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | 40 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer |
40 | { | 41 | { |
41 | public class InventoryTransferModule : IInventoryTransferModule, ISharedRegionModule | 42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "InventoryTransferModule")] |
43 | public class InventoryTransferModule : ISharedRegionModule | ||
42 | { | 44 | { |
43 | private static readonly ILog m_log | 45 | private static readonly ILog m_log |
44 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 47 | ||
46 | /// <summary> | 48 | /// <summary> |
47 | private List<Scene> m_Scenelist = new List<Scene>(); | 49 | private List<Scene> m_Scenelist = new List<Scene>(); |
48 | private Dictionary<UUID, Scene> m_AgentRegions = | 50 | // private Dictionary<UUID, Scene> m_AgentRegions = |
49 | new Dictionary<UUID, Scene>(); | 51 | // new Dictionary<UUID, Scene>(); |
50 | 52 | ||
51 | private IMessageTransferModule m_TransferModule = null; | 53 | private IMessageTransferModule m_TransferModule = null; |
52 | private bool m_Enabled = true; | 54 | private bool m_Enabled = true; |
53 | 55 | ||
54 | #region IRegionModule Members | 56 | #region Region Module interface |
55 | 57 | ||
56 | public void Initialise(IConfigSource config) | 58 | public void Initialise(IConfigSource config) |
57 | { | 59 | { |
@@ -76,12 +78,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
76 | 78 | ||
77 | m_Scenelist.Add(scene); | 79 | m_Scenelist.Add(scene); |
78 | 80 | ||
79 | scene.RegisterModuleInterface<IInventoryTransferModule>(this); | 81 | // scene.RegisterModuleInterface<IInventoryTransferModule>(this); |
80 | 82 | ||
81 | scene.EventManager.OnNewClient += OnNewClient; | 83 | scene.EventManager.OnNewClient += OnNewClient; |
82 | scene.EventManager.OnClientClosed += ClientLoggedOut; | 84 | // scene.EventManager.OnClientClosed += ClientLoggedOut; |
83 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | 85 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; |
84 | scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene; | 86 | // scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene; |
85 | } | 87 | } |
86 | 88 | ||
87 | public void RegionLoaded(Scene scene) | 89 | public void RegionLoaded(Scene scene) |
@@ -96,9 +98,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
96 | 98 | ||
97 | m_Scenelist.Clear(); | 99 | m_Scenelist.Clear(); |
98 | scene.EventManager.OnNewClient -= OnNewClient; | 100 | scene.EventManager.OnNewClient -= OnNewClient; |
99 | scene.EventManager.OnClientClosed -= ClientLoggedOut; | 101 | // scene.EventManager.OnClientClosed -= ClientLoggedOut; |
100 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | 102 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; |
101 | scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene; | 103 | // scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene; |
102 | } | 104 | } |
103 | } | 105 | } |
104 | } | 106 | } |
@@ -106,9 +108,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
106 | public void RemoveRegion(Scene scene) | 108 | public void RemoveRegion(Scene scene) |
107 | { | 109 | { |
108 | scene.EventManager.OnNewClient -= OnNewClient; | 110 | scene.EventManager.OnNewClient -= OnNewClient; |
109 | scene.EventManager.OnClientClosed -= ClientLoggedOut; | 111 | // scene.EventManager.OnClientClosed -= ClientLoggedOut; |
110 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | 112 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; |
111 | scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene; | 113 | // scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene; |
112 | m_Scenelist.Remove(scene); | 114 | m_Scenelist.Remove(scene); |
113 | } | 115 | } |
114 | 116 | ||
@@ -138,10 +140,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
138 | client.OnInstantMessage += OnInstantMessage; | 140 | client.OnInstantMessage += OnInstantMessage; |
139 | } | 141 | } |
140 | 142 | ||
141 | protected void OnSetRootAgentScene(UUID id, Scene scene) | 143 | // protected void OnSetRootAgentScene(UUID id, Scene scene) |
142 | { | 144 | // { |
143 | m_AgentRegions[id] = scene; | 145 | // m_AgentRegions[id] = scene; |
144 | } | 146 | // } |
145 | 147 | ||
146 | private Scene FindClientScene(UUID agentId) | 148 | private Scene FindClientScene(UUID agentId) |
147 | { | 149 | { |
@@ -298,73 +300,76 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
298 | } | 300 | } |
299 | } | 301 | } |
300 | 302 | ||
301 | // XXX: This code was placed here to try and accomdate RLV which moves given folders named #RLV/~<name> | 303 | // Disabled for now as it looks like http://opensimulator.org/mantis/view.php?id=6311 was fixed by fixes |
302 | // to a folder called name in #RLV. However, this approach may not be ultimately correct - from analysis | 304 | // to inventory folder versioning allowing the viewer to move the received folder itself as happens on the |
303 | // of Firestorm 4.2.2 on sending an InventoryOffered instead of TaskInventoryOffered (as was previously | 305 | // LL grid. Doing it again server-side then wrongly does a second create and move |
304 | // done), the viewer itself would appear to move and rename the folder, rather than the simulator doing it here. | 306 | // // XXX: This code was placed here to try and accomdate RLV which moves given folders named #RLV/~<name> |
305 | else if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | 307 | // // to a folder called name in #RLV. However, this approach may not be ultimately correct - from analysis |
306 | { | 308 | // // of Firestorm 4.2.2 on sending an InventoryOffered instead of TaskInventoryOffered (as was previously |
307 | UUID destinationFolderID = UUID.Zero; | 309 | // // done), the viewer itself would appear to move and rename the folder, rather than the simulator doing it here. |
308 | 310 | // else if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | |
309 | if (im.binaryBucket != null && im.binaryBucket.Length >= 16) | 311 | // { |
310 | { | 312 | // UUID destinationFolderID = UUID.Zero; |
311 | destinationFolderID = new UUID(im.binaryBucket, 0); | 313 | // |
312 | } | 314 | // if (im.binaryBucket != null && im.binaryBucket.Length >= 16) |
313 | 315 | // { | |
314 | if (destinationFolderID != UUID.Zero) | 316 | // destinationFolderID = new UUID(im.binaryBucket, 0); |
315 | { | 317 | // } |
316 | InventoryFolderBase destinationFolder = new InventoryFolderBase(destinationFolderID, client.AgentId); | 318 | // |
317 | if (destinationFolder == null) | 319 | // if (destinationFolderID != UUID.Zero) |
318 | { | 320 | // { |
319 | m_log.WarnFormat( | 321 | // InventoryFolderBase destinationFolder = new InventoryFolderBase(destinationFolderID, client.AgentId); |
320 | "[INVENTORY TRANSFER]: TaskInventoryAccepted message from {0} in {1} specified folder {2} which does not exist", | 322 | // if (destinationFolder == null) |
321 | client.Name, scene.Name, destinationFolderID); | 323 | // { |
322 | 324 | // m_log.WarnFormat( | |
323 | return; | 325 | // "[INVENTORY TRANSFER]: TaskInventoryAccepted message from {0} in {1} specified folder {2} which does not exist", |
324 | } | 326 | // client.Name, scene.Name, destinationFolderID); |
325 | 327 | // | |
326 | IInventoryService invService = scene.InventoryService; | 328 | // return; |
327 | 329 | // } | |
328 | UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip | 330 | // |
329 | 331 | // IInventoryService invService = scene.InventoryService; | |
330 | InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId); | 332 | // |
331 | item = invService.GetItem(item); | 333 | // UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip |
332 | InventoryFolderBase folder = null; | 334 | // |
333 | UUID? previousParentFolderID = null; | 335 | // InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId); |
334 | 336 | // item = invService.GetItem(item); | |
335 | if (item != null) // It's an item | 337 | // InventoryFolderBase folder = null; |
336 | { | 338 | // UUID? previousParentFolderID = null; |
337 | previousParentFolderID = item.Folder; | 339 | // |
338 | item.Folder = destinationFolderID; | 340 | // if (item != null) // It's an item |
339 | 341 | // { | |
340 | invService.DeleteItems(item.Owner, new List<UUID>() { item.ID }); | 342 | // previousParentFolderID = item.Folder; |
341 | scene.AddInventoryItem(client, item); | 343 | // item.Folder = destinationFolderID; |
342 | } | 344 | // |
343 | else | 345 | // invService.DeleteItems(item.Owner, new List<UUID>() { item.ID }); |
344 | { | 346 | // scene.AddInventoryItem(client, item); |
345 | folder = new InventoryFolderBase(inventoryID, client.AgentId); | 347 | // } |
346 | folder = invService.GetFolder(folder); | 348 | // else |
347 | 349 | // { | |
348 | if (folder != null) // It's a folder | 350 | // folder = new InventoryFolderBase(inventoryID, client.AgentId); |
349 | { | 351 | // folder = invService.GetFolder(folder); |
350 | previousParentFolderID = folder.ParentID; | 352 | // |
351 | folder.ParentID = destinationFolderID; | 353 | // if (folder != null) // It's a folder |
352 | invService.MoveFolder(folder); | 354 | // { |
353 | } | 355 | // previousParentFolderID = folder.ParentID; |
354 | } | 356 | // folder.ParentID = destinationFolderID; |
355 | 357 | // invService.MoveFolder(folder); | |
356 | // Tell client about updates to original parent and new parent (this should probably be factored with existing move item/folder code). | 358 | // } |
357 | if (previousParentFolderID != null) | 359 | // } |
358 | { | 360 | // |
359 | InventoryFolderBase previousParentFolder | 361 | // // Tell client about updates to original parent and new parent (this should probably be factored with existing move item/folder code). |
360 | = new InventoryFolderBase((UUID)previousParentFolderID, client.AgentId); | 362 | // if (previousParentFolderID != null) |
361 | previousParentFolder = invService.GetFolder(previousParentFolder); | 363 | // { |
362 | scene.SendInventoryUpdate(client, previousParentFolder, true, true); | 364 | // InventoryFolderBase previousParentFolder |
363 | 365 | // = new InventoryFolderBase((UUID)previousParentFolderID, client.AgentId); | |
364 | scene.SendInventoryUpdate(client, destinationFolder, true, true); | 366 | // previousParentFolder = invService.GetFolder(previousParentFolder); |
365 | } | 367 | // scene.SendInventoryUpdate(client, previousParentFolder, true, true); |
366 | } | 368 | // |
367 | } | 369 | // scene.SendInventoryUpdate(client, destinationFolder, true, true); |
370 | // } | ||
371 | // } | ||
372 | // } | ||
368 | else if ( | 373 | else if ( |
369 | im.dialog == (byte)InstantMessageDialog.InventoryDeclined | 374 | im.dialog == (byte)InstantMessageDialog.InventoryDeclined |
370 | || im.dialog == (byte)InstantMessageDialog.TaskInventoryDeclined) | 375 | || im.dialog == (byte)InstantMessageDialog.TaskInventoryDeclined) |
@@ -434,83 +439,86 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
434 | scene.SendInventoryUpdate(client, trashFolder, true, true); | 439 | scene.SendInventoryUpdate(client, trashFolder, true, true); |
435 | } | 440 | } |
436 | 441 | ||
437 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); | 442 | if (im.dialog == (byte)InstantMessageDialog.InventoryDeclined) |
438 | |||
439 | if (user != null) // Local | ||
440 | { | ||
441 | user.ControllingClient.SendInstantMessage(im); | ||
442 | } | ||
443 | else | ||
444 | { | ||
445 | if (m_TransferModule != null) | ||
446 | m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); | ||
447 | } | ||
448 | } | ||
449 | } | ||
450 | |||
451 | public bool NeedSceneCacheClear(UUID agentID, Scene scene) | ||
452 | { | ||
453 | if (!m_AgentRegions.ContainsKey(agentID)) | ||
454 | { | ||
455 | // Since we can get here two ways, we need to scan | ||
456 | // the scenes here. This is somewhat more expensive | ||
457 | // but helps avoid a nasty bug | ||
458 | // | ||
459 | |||
460 | foreach (Scene s in m_Scenelist) | ||
461 | { | 443 | { |
462 | ScenePresence presence; | 444 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
463 | 445 | ||
464 | if (s.TryGetScenePresence(agentID, out presence)) | 446 | if (user != null) // Local |
465 | { | 447 | { |
466 | // If the agent is in this scene, then we | 448 | user.ControllingClient.SendInstantMessage(im); |
467 | // are being called twice in a single | 449 | } |
468 | // teleport. This is wasteful of cycles | 450 | else |
469 | // but harmless due to this 2nd level check | 451 | { |
470 | // | 452 | if (m_TransferModule != null) |
471 | // If the agent is found in another scene | 453 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { }); |
472 | // then the list wasn't current | ||
473 | // | ||
474 | // If the agent is totally unknown, then what | ||
475 | // are we even doing here?? | ||
476 | // | ||
477 | if (s == scene) | ||
478 | { | ||
479 | //m_log.Debug("[INVTRANSFERMOD]: s == scene. Returning true in " + scene.RegionInfo.RegionName); | ||
480 | return true; | ||
481 | } | ||
482 | else | ||
483 | { | ||
484 | //m_log.Debug("[INVTRANSFERMOD]: s != scene. Returning false in " + scene.RegionInfo.RegionName); | ||
485 | return false; | ||
486 | } | ||
487 | } | 454 | } |
488 | } | 455 | } |
489 | //m_log.Debug("[INVTRANSFERMOD]: agent not in scene. Returning true in " + scene.RegionInfo.RegionName); | ||
490 | return true; | ||
491 | } | ||
492 | |||
493 | // The agent is left in current Scene, so we must be | ||
494 | // going to another instance | ||
495 | // | ||
496 | if (m_AgentRegions[agentID] == scene) | ||
497 | { | ||
498 | //m_log.Debug("[INVTRANSFERMOD]: m_AgentRegions[agentID] == scene. Returning true in " + scene.RegionInfo.RegionName); | ||
499 | m_AgentRegions.Remove(agentID); | ||
500 | return true; | ||
501 | } | 456 | } |
502 | |||
503 | // Another region has claimed the agent | ||
504 | // | ||
505 | //m_log.Debug("[INVTRANSFERMOD]: last resort. Returning false in " + scene.RegionInfo.RegionName); | ||
506 | return false; | ||
507 | } | 457 | } |
508 | 458 | ||
509 | public void ClientLoggedOut(UUID agentID, Scene scene) | 459 | // public bool NeedSceneCacheClear(UUID agentID, Scene scene) |
510 | { | 460 | // { |
511 | if (m_AgentRegions.ContainsKey(agentID)) | 461 | // if (!m_AgentRegions.ContainsKey(agentID)) |
512 | m_AgentRegions.Remove(agentID); | 462 | // { |
513 | } | 463 | // // Since we can get here two ways, we need to scan |
464 | // // the scenes here. This is somewhat more expensive | ||
465 | // // but helps avoid a nasty bug | ||
466 | // // | ||
467 | // | ||
468 | // foreach (Scene s in m_Scenelist) | ||
469 | // { | ||
470 | // ScenePresence presence; | ||
471 | // | ||
472 | // if (s.TryGetScenePresence(agentID, out presence)) | ||
473 | // { | ||
474 | // // If the agent is in this scene, then we | ||
475 | // // are being called twice in a single | ||
476 | // // teleport. This is wasteful of cycles | ||
477 | // // but harmless due to this 2nd level check | ||
478 | // // | ||
479 | // // If the agent is found in another scene | ||
480 | // // then the list wasn't current | ||
481 | // // | ||
482 | // // If the agent is totally unknown, then what | ||
483 | // // are we even doing here?? | ||
484 | // // | ||
485 | // if (s == scene) | ||
486 | // { | ||
487 | // //m_log.Debug("[INVTRANSFERMOD]: s == scene. Returning true in " + scene.RegionInfo.RegionName); | ||
488 | // return true; | ||
489 | // } | ||
490 | // else | ||
491 | // { | ||
492 | // //m_log.Debug("[INVTRANSFERMOD]: s != scene. Returning false in " + scene.RegionInfo.RegionName); | ||
493 | // return false; | ||
494 | // } | ||
495 | // } | ||
496 | // } | ||
497 | // //m_log.Debug("[INVTRANSFERMOD]: agent not in scene. Returning true in " + scene.RegionInfo.RegionName); | ||
498 | // return true; | ||
499 | // } | ||
500 | // | ||
501 | // // The agent is left in current Scene, so we must be | ||
502 | // // going to another instance | ||
503 | // // | ||
504 | // if (m_AgentRegions[agentID] == scene) | ||
505 | // { | ||
506 | // //m_log.Debug("[INVTRANSFERMOD]: m_AgentRegions[agentID] == scene. Returning true in " + scene.RegionInfo.RegionName); | ||
507 | // m_AgentRegions.Remove(agentID); | ||
508 | // return true; | ||
509 | // } | ||
510 | // | ||
511 | // // Another region has claimed the agent | ||
512 | // // | ||
513 | // //m_log.Debug("[INVTRANSFERMOD]: last resort. Returning false in " + scene.RegionInfo.RegionName); | ||
514 | // return false; | ||
515 | // } | ||
516 | // | ||
517 | // public void ClientLoggedOut(UUID agentID, Scene scene) | ||
518 | // { | ||
519 | // if (m_AgentRegions.ContainsKey(agentID)) | ||
520 | // m_AgentRegions.Remove(agentID); | ||
521 | // } | ||
514 | 522 | ||
515 | /// <summary> | 523 | /// <summary> |
516 | /// | 524 | /// |