aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs20
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs5
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs115
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs152
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs43
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs51
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs7
10 files changed, 275 insertions, 149 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index c5cec59..78ae5e9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -285,7 +285,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
285 // At the moment we can only deal with a single attachment 285 // At the moment we can only deal with a single attachment
286 if (attachments.Count != 0) 286 if (attachments.Count != 0)
287 { 287 {
288 UUID oldAttachmentItemID = attachments[0].GetFromItemID(); 288 UUID oldAttachmentItemID = attachments[0].FromItemID;
289 289
290 if (oldAttachmentItemID != UUID.Zero) 290 if (oldAttachmentItemID != UUID.Zero)
291 DetachSingleAttachmentToInvInternal(sp, oldAttachmentItemID); 291 DetachSingleAttachmentToInvInternal(sp, oldAttachmentItemID);
@@ -296,7 +296,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
296 } 296 }
297 297
298 // Add the new attachment to inventory if we don't already have it. 298 // Add the new attachment to inventory if we don't already have it.
299 UUID newAttachmentItemID = group.GetFromItemID(); 299 UUID newAttachmentItemID = group.FromItemID;
300 if (newAttachmentItemID == UUID.Zero) 300 if (newAttachmentItemID == UUID.Zero)
301 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID; 301 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
302 302
@@ -336,7 +336,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
336 List<SceneObjectGroup> existingAttachments = sp.GetAttachments(); 336 List<SceneObjectGroup> existingAttachments = sp.GetAttachments();
337 foreach (SceneObjectGroup so in existingAttachments) 337 foreach (SceneObjectGroup so in existingAttachments)
338 { 338 {
339 if (so.GetFromItemID() == itemID) 339 if (so.FromItemID == itemID)
340 { 340 {
341 alreadyOn = true; 341 alreadyOn = true;
342 break; 342 break;
@@ -393,7 +393,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
393 if (so.AttachedAvatar != sp.UUID) 393 if (so.AttachedAvatar != sp.UUID)
394 return; 394 return;
395 395
396 UUID inventoryID = so.GetFromItemID(); 396 UUID inventoryID = so.FromItemID;
397 397
398// m_log.DebugFormat( 398// m_log.DebugFormat(
399// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}", 399// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}",
@@ -410,9 +410,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
410 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); 410 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
411 411
412 sp.RemoveAttachment(so); 412 sp.RemoveAttachment(so);
413 so.FromItemID = UUID.Zero;
413 414
414 SceneObjectPart rootPart = so.RootPart; 415 SceneObjectPart rootPart = so.RootPart;
415 rootPart.FromItemID = UUID.Zero;
416 so.AbsolutePosition = sp.AbsolutePosition; 416 so.AbsolutePosition = sp.AbsolutePosition;
417 so.AttachedAvatar = UUID.Zero; 417 so.AttachedAvatar = UUID.Zero;
418 rootPart.SetParentLocalId(0); 418 rootPart.SetParentLocalId(0);
@@ -526,7 +526,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
526 526
527 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); 527 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
528 528
529 InventoryItemBase item = new InventoryItemBase(grp.GetFromItemID(), sp.UUID); 529 InventoryItemBase item = new InventoryItemBase(grp.FromItemID, sp.UUID);
530 item = m_scene.InventoryService.GetItem(item); 530 item = m_scene.InventoryService.GetItem(item);
531 531
532 if (item != null) 532 if (item != null)
@@ -698,7 +698,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
698 item.CreationDate = Util.UnixTimeSinceEpoch(); 698 item.CreationDate = Util.UnixTimeSinceEpoch();
699 699
700 // sets itemID so client can show item as 'attached' in inventory 700 // sets itemID so client can show item as 'attached' in inventory
701 grp.SetFromItemID(item.ID); 701 grp.FromItemID = item.ID;
702 702
703 if (m_scene.AddInventoryItem(item)) 703 if (m_scene.AddInventoryItem(item))
704 { 704 {
@@ -734,7 +734,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
734 if (entity is SceneObjectGroup) 734 if (entity is SceneObjectGroup)
735 { 735 {
736 group = (SceneObjectGroup)entity; 736 group = (SceneObjectGroup)entity;
737 if (group.GetFromItemID() == itemID) 737 if (group.FromItemID == itemID)
738 { 738 {
739 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); 739 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
740 sp.RemoveAttachment(group); 740 sp.RemoveAttachment(group);
@@ -946,7 +946,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
946 // Calls attach with a Zero position 946 // Calls attach with a Zero position
947 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) 947 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false))
948 { 948 {
949 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); 949 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId);
950 950
951 // Save avatar attachment information 951 // Save avatar attachment information
952 m_log.Debug( 952 m_log.Debug(
@@ -969,7 +969,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
969 ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); 969 ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
970 SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID); 970 SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID);
971 if (sp != null && group != null) 971 if (sp != null && group != null)
972 DetachSingleAttachmentToInv(sp, group.GetFromItemID()); 972 DetachSingleAttachmentToInv(sp, group.FromItemID);
973 } 973 }
974 974
975 private void Client_OnDetachAttachmentIntoInv(UUID itemID, IClientAPI remoteClient) 975 private void Client_OnDetachAttachmentIntoInv(UUID itemID, IClientAPI remoteClient)
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 86cfb32..bfe5e4a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -120,8 +120,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
120 Assert.That(attSo.IsTemporary, Is.False); 120 Assert.That(attSo.IsTemporary, Is.False);
121 121
122 // Check item status 122 // Check item status
123 Assert.That(m_presence.Appearance.GetAttachpoint( 123 Assert.That(
124 attSo.GetFromItemID()), Is.EqualTo((int)AttachmentPoint.Chest)); 124 m_presence.Appearance.GetAttachpoint(attSo.FromItemID),
125 Is.EqualTo((int)AttachmentPoint.Chest));
125 } 126 }
126 127
127 [Test] 128 [Test]
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index b64d372..2b790f4 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -562,12 +562,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
562 // Finally, kill the agent we just created at the destination. 562 // Finally, kill the agent we just created at the destination.
563 m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID); 563 m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID);
564 564
565 sp.Scene.EventManager.TriggerTeleportFail(sp.ControllingClient, logout);
565 } 566 }
566 567
567 protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout) 568 protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout)
568 { 569 {
569 logout = false; 570 logout = false;
570 return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); 571 bool success = m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason);
572
573 if (success)
574 sp.Scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout);
575
576 return success;
571 } 577 }
572 578
573 protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent) 579 protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent)
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 6fc8e4d..8b5ad23 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -51,8 +51,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
51 51
52 private bool m_Initialized = false; 52 private bool m_Initialized = false;
53 53
54 private bool m_RestrictInventoryAccessAbroad = false;
55
56 private GatekeeperServiceConnector m_GatekeeperConnector; 54 private GatekeeperServiceConnector m_GatekeeperConnector;
57 55
58 #region ISharedRegionModule 56 #region ISharedRegionModule
@@ -71,10 +69,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
71 if (name == Name) 69 if (name == Name)
72 { 70 {
73 InitialiseCommon(source); 71 InitialiseCommon(source);
74 IConfig transferConfig = source.Configs["HGEntityTransferModule"];
75 if (transferConfig != null)
76 m_RestrictInventoryAccessAbroad = transferConfig.GetBoolean("RestrictInventoryAccessAbroad", false);
77
78 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); 72 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name);
79 } 73 }
80 } 74 }
@@ -94,34 +88,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
94 client.OnTeleportHomeRequest += TriggerTeleportHome; 88 client.OnTeleportHomeRequest += TriggerTeleportHome;
95 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 89 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
96 client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed); 90 client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed);
97 client.OnCompleteMovementToRegion += new Action<IClientAPI, bool>(OnCompleteMovementToRegion);
98 }
99
100 protected void OnCompleteMovementToRegion(IClientAPI client, bool arg2)
101 {
102 // HACK HACK -- just seeing how the viewer responds
103 // Let's send the Suitcase or the real root folder folder for incoming HG agents
104 // Visiting agents get their suitcase contents; incoming local users get their real root folder's content
105 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: OnCompleteMovementToRegion of user {0}", client.AgentId);
106 object sp = null;
107 if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
108 {
109 if (sp is ScenePresence)
110 {
111 AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId);
112 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
113 {
114 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: ViaHGLogin");
115 if (m_RestrictInventoryAccessAbroad)
116 {
117 RestoreRootFolderContents(client);
118 }
119 }
120 }
121 }
122 } 91 }
123 92
124
125 public override void RegionLoaded(Scene scene) 93 public override void RegionLoaded(Scene scene)
126 { 94 {
127 base.RegionLoaded(scene); 95 base.RegionLoaded(scene);
@@ -131,12 +99,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
131 m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService); 99 m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService);
132 m_Initialized = true; 100 m_Initialized = true;
133 101
134 scene.AddCommand(
135 "HG", this, "send inventory",
136 "send inventory",
137 "Don't use this",
138 HandleSendInventory);
139
140 } 102 }
141 103
142 } 104 }
@@ -209,8 +171,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
209 bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason); 171 bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason);
210 logout = success; // flag for later logout from this grid; this is an HG TP 172 logout = success; // flag for later logout from this grid; this is an HG TP
211 173
212 if (success && m_RestrictInventoryAccessAbroad) 174 if (success)
213 RemoveRootFolderContents(sp.ControllingClient); 175 sp.Scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout);
214 176
215 return success; 177 return success;
216 } 178 }
@@ -221,7 +183,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
221 } 183 }
222 } 184 }
223 185
224 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); 186 return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout);
225 } 187 }
226 188
227 public void TriggerTeleportHome(UUID id, IClientAPI client) 189 public void TriggerTeleportHome(UUID id, IClientAPI client)
@@ -330,15 +292,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
330 292
331 } 293 }
332 294
333 protected override void Fail(ScenePresence sp, GridRegion finalDestination, bool logout)
334 {
335 base.Fail(sp, finalDestination, logout);
336 if (logout && m_RestrictInventoryAccessAbroad)
337 {
338 RestoreRootFolderContents(sp.ControllingClient);
339 }
340 }
341
342 #endregion 295 #endregion
343 296
344 #region IUserAgentVerificationModule 297 #region IUserAgentVerificationModule
@@ -393,60 +346,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
393 346
394 #endregion 347 #endregion
395 348
396 private void RemoveRootFolderContents(IClientAPI client)
397 {
398 // TODO tell the viewer to remove the root folder's content
399 if (client is IClientCore)
400 {
401 IClientCore core = (IClientCore)client;
402 IClientInventory inv;
403
404 if (core.TryGet<IClientInventory>(out inv))
405 {
406 InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
407 if (root != null)
408 {
409 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory for user {0}", client.AgentId);
410 InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
411 UUID[] ids = new UUID[content.Folders.Count];
412 int i = 0;
413 foreach (InventoryFolderBase f in content.Folders)
414 ids[i++] = f.ID;
415 inv.SendRemoveInventoryFolders(ids);
416 ids = new UUID[content.Items.Count];
417 i = 0;
418 foreach (InventoryItemBase it in content.Items)
419 ids[i++] = it.ID;
420 inv.SendRemoveInventoryItems(ids);
421 }
422 }
423 }
424 }
425
426 private void RestoreRootFolderContents(IClientAPI client)
427 {
428 if (client is IClientCore)
429 {
430 IClientCore core = (IClientCore)client;
431 IClientInventory inv;
432
433 if (core.TryGet<IClientInventory>(out inv))
434 {
435 InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
436 client.SendBulkUpdateInventory(root);
437 //if (root != null)
438 //{
439 // m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory for user {0}", client.AgentId);
440 // InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
441 // m_log.DebugFormat("[XXX]: Folder name {0}, id {1}, parent {2}", root.Name, root.ID, root.ParentID);
442 // foreach (InventoryItemBase i in content.Items)
443 // m_log.DebugFormat("[XXX]: Name={0}, folderID={1}", i.Name, i.Folder);
444
445 // inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray());
446 //}
447 }
448 }
449 }
450 349
451 private GridRegion MakeRegion(AgentCircuitData aCircuit) 350 private GridRegion MakeRegion(AgentCircuitData aCircuit)
452 { 351 {
@@ -465,13 +364,5 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
465 return region; 364 return region;
466 } 365 }
467 366
468 protected void HandleSendInventory(string module, string[] cmd)
469 {
470 m_Scenes[0].ForEachClient(delegate(IClientAPI client)
471 {
472 RestoreRootFolderContents(client);
473 });
474 }
475
476 } 367 }
477} 368}
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index d2fe388..a71584a 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31 31
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Client;
33using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Connectors.Hypergrid; 36using OpenSim.Services.Connectors.Hypergrid;
@@ -57,6 +58,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
57 private string m_HomeURI; 58 private string m_HomeURI;
58 private bool m_OutboundPermission; 59 private bool m_OutboundPermission;
59 private string m_ThisGatekeeper; 60 private string m_ThisGatekeeper;
61 private bool m_RestrictInventoryAccessAbroad;
60 62
61// private bool m_Initialized = false; 63// private bool m_Initialized = false;
62 64
@@ -90,6 +92,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
90 m_HomeURI = thisModuleConfig.GetString("HomeURI", m_HomeURI); 92 m_HomeURI = thisModuleConfig.GetString("HomeURI", m_HomeURI);
91 m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); 93 m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true);
92 m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", string.Empty); 94 m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", string.Empty);
95 m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", false);
93 } 96 }
94 else 97 else
95 m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); 98 m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!");
@@ -105,13 +108,79 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
105 base.AddRegion(scene); 108 base.AddRegion(scene);
106 m_assMapper = new HGAssetMapper(scene, m_HomeURI); 109 m_assMapper = new HGAssetMapper(scene, m_HomeURI);
107 scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; 110 scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
108 111 scene.EventManager.OnTeleportStart += TeleportStart;
112 scene.EventManager.OnTeleportFail += TeleportFail;
109 } 113 }
110 114
111 #endregion 115 #endregion
112 116
113 #region Event handlers 117 #region Event handlers
114 118
119 protected override void OnNewClient(IClientAPI client)
120 {
121 base.OnNewClient(client);
122 client.OnCompleteMovementToRegion += new Action<IClientAPI, bool>(OnCompleteMovementToRegion);
123 }
124
125 protected void OnCompleteMovementToRegion(IClientAPI client, bool arg2)
126 {
127 //m_log.DebugFormat("[HG INVENTORY ACCESS MODULE]: OnCompleteMovementToRegion of user {0}", client.Name);
128 object sp = null;
129 if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
130 {
131 if (sp is ScenePresence)
132 {
133 AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId);
134 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
135 {
136 if (m_RestrictInventoryAccessAbroad)
137 {
138 IUserManagement uMan = m_Scene.RequestModuleInterface<IUserManagement>();
139 if (uMan.IsLocalGridUser(client.AgentId))
140 ProcessInventoryForComingHome(client);
141 else
142 ProcessInventoryForArriving(client);
143 }
144 }
145 }
146 }
147 }
148
149 protected void TeleportStart(IClientAPI client, GridRegion destination, GridRegion finalDestination, uint teleportFlags, bool gridLogout)
150 {
151 if (gridLogout && m_RestrictInventoryAccessAbroad)
152 {
153 IUserManagement uMan = m_Scene.RequestModuleInterface<IUserManagement>();
154 if (uMan != null && uMan.IsLocalGridUser(client.AgentId))
155 {
156 // local grid user
157 ProcessInventoryForHypergriding(client);
158 }
159 else
160 {
161 // Foreigner
162 ProcessInventoryForLeaving(client);
163 }
164 }
165
166 }
167
168 protected void TeleportFail(IClientAPI client, bool gridLogout)
169 {
170 if (gridLogout && m_RestrictInventoryAccessAbroad)
171 {
172 IUserManagement uMan = m_Scene.RequestModuleInterface<IUserManagement>();
173 if (uMan.IsLocalGridUser(client.AgentId))
174 {
175 ProcessInventoryForComingHome(client);
176 }
177 else
178 {
179 ProcessInventoryForArriving(client);
180 }
181 }
182 }
183
115 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) 184 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
116 { 185 {
117 string userAssetServer = string.Empty; 186 string userAssetServer = string.Empty;
@@ -236,8 +305,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
236 return false; 305 return false;
237 } 306 }
238 307
239 #endregion
240
241 protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) 308 protected override InventoryItemBase GetItem(UUID agentID, UUID itemID)
242 { 309 {
243 InventoryItemBase item = base.GetItem(agentID, itemID); 310 InventoryItemBase item = base.GetItem(agentID, itemID);
@@ -248,5 +315,84 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
248 315
249 return item; 316 return item;
250 } 317 }
318
319 #endregion
320
321 #region Inventory manipulation upon arriving/leaving
322
323 //
324 // These 2 are for local and foreign users coming back, respectively
325 //
326
327 private void ProcessInventoryForComingHome(IClientAPI client)
328 {
329 m_log.DebugFormat("[HG INVENTORY ACCESS MODULE]: Restoring root folder for local user {0}", client.Name);
330 if (client is IClientCore)
331 {
332 IClientCore core = (IClientCore)client;
333 IClientInventory inv;
334
335 if (core.TryGet<IClientInventory>(out inv))
336 {
337 InventoryFolderBase root = m_Scene.InventoryService.GetRootFolder(client.AgentId);
338 InventoryCollection content = m_Scene.InventoryService.GetFolderContent(client.AgentId, root.ID);
339
340 inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray());
341 }
342 }
343 }
344
345 private void ProcessInventoryForArriving(IClientAPI client)
346 {
347 }
348
349 //
350 // These 2 are for local and foreign users going away respectively
351 //
352
353 private void ProcessInventoryForHypergriding(IClientAPI client)
354 {
355 if (client is IClientCore)
356 {
357 IClientCore core = (IClientCore)client;
358 IClientInventory inv;
359
360 if (core.TryGet<IClientInventory>(out inv))
361 {
362 InventoryFolderBase root = m_Scene.InventoryService.GetRootFolder(client.AgentId);
363 if (root != null)
364 {
365 m_log.DebugFormat("[HG INVENTORY ACCESS MODULE]: Changing root inventory for user {0}", client.Name);
366 InventoryCollection content = m_Scene.InventoryService.GetFolderContent(client.AgentId, root.ID);
367 List<UUID> fids = new List<UUID>();
368 List<UUID> iids = new List<UUID>();
369 List<InventoryFolderBase> keep = new List<InventoryFolderBase>();
370
371 foreach (InventoryFolderBase f in content.Folders)
372 {
373 if (f.Name != "My Suitcase")
374 {
375 f.Name = f.Name + " (Unavailable)";
376 keep.Add(f);
377 }
378 }
379
380 // items directly under the root folder
381 foreach (InventoryItemBase it in content.Items)
382 it.Name = it.Name + " (Unavailable)"; ;
383
384 // Send the new names
385 inv.SendBulkUpdateInventory(keep.ToArray(), content.Items.ToArray());
386
387 }
388 }
389 }
390 }
391
392 private void ProcessInventoryForLeaving(IClientAPI client)
393 {
394 }
395
396 #endregion
251 } 397 }
252} 398}
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index aa99692..74701a5 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -674,9 +674,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
674 // 674 //
675 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) 675 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy)
676 { 676 {
677 if (so.RootPart.FromFolderID != UUID.Zero && userID == remoteClient.AgentId) 677 if (so.FromFolderID != UUID.Zero && userID == remoteClient.AgentId)
678 { 678 {
679 InventoryFolderBase f = new InventoryFolderBase(so.RootPart.FromFolderID, userID); 679 InventoryFolderBase f = new InventoryFolderBase(so.FromFolderID, userID);
680 if (f != null) 680 if (f != null)
681 folder = m_Scene.InventoryService.GetFolder(f); 681 folder = m_Scene.InventoryService.GetFolder(f);
682 } 682 }
@@ -1012,7 +1012,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1012 } 1012 }
1013 } 1013 }
1014 1014
1015 rootPart.FromFolderID = item.Folder; 1015 so.FromFolderID = item.Folder;
1016 1016
1017// Console.WriteLine("rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}", 1017// Console.WriteLine("rootPart.OwnedID {0}, item.Owner {1}, item.CurrentPermissions {2:X}",
1018// rootPart.OwnerID, item.Owner, item.CurrentPermissions); 1018// rootPart.OwnerID, item.Owner, item.CurrentPermissions);
@@ -1071,7 +1071,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1071 rootPart.TrimPermissions(); 1071 rootPart.TrimPermissions();
1072 1072
1073 if (isAttachment) 1073 if (isAttachment)
1074 so.SetFromItemID(item.ID); 1074 so.FromItemID = item.ID;
1075 } 1075 }
1076 1076
1077 return true; 1077 return true;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 4be3804..cf6d2f7 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -297,14 +297,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
297 return m_LocalGridInventoryService.CreateUserInventory(userID); 297 return m_LocalGridInventoryService.CreateUserInventory(userID);
298 } 298 }
299 299
300 public List<InventoryFolderBase> GetInventorySkeleton(UUID userId) 300 public List<InventoryFolderBase> GetInventorySkeleton(UUID userID)
301 { 301 {
302 return m_LocalGridInventoryService.GetInventorySkeleton(userId); 302 string invURL = GetInventoryServiceURL(userID);
303
304 if (invURL == null) // not there, forward to local inventory connector to resolve
305 return m_LocalGridInventoryService.GetInventorySkeleton(userID);
306
307 IInventoryService connector = GetConnector(invURL);
308
309 return connector.GetInventorySkeleton(userID);
303 } 310 }
304 311
305 public InventoryCollection GetUserInventory(UUID userID) 312 public InventoryCollection GetUserInventory(UUID userID)
306 { 313 {
307 return null; 314 string invURL = GetInventoryServiceURL(userID);
315 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetUserInventory for {0} {1}", userID, invURL);
316
317 if (invURL == null) // not there, forward to local inventory connector to resolve
318 return m_LocalGridInventoryService.GetUserInventory(userID);
319
320 InventoryCollection c = m_Cache.GetUserInventory(userID);
321 if (c != null)
322 return c;
323
324 IInventoryService connector = GetConnector(invURL);
325 c = connector.GetUserInventory(userID);
326
327 m_Cache.Cache(userID, c);
328 return c;
308 } 329 }
309 330
310 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) 331 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
@@ -362,8 +383,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
362 if (invURL == null) // not there, forward to local inventory connector to resolve 383 if (invURL == null) // not there, forward to local inventory connector to resolve
363 return m_LocalGridInventoryService.GetFolderContent(userID, folderID); 384 return m_LocalGridInventoryService.GetFolderContent(userID, folderID);
364 385
365 IInventoryService connector = GetConnector(invURL); 386 InventoryCollection c = m_Cache.GetFolderContent(userID, folderID);
387 if (c != null)
388 {
389 m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderContent found content in cache " + folderID);
390 return c;
391 }
366 392
393 IInventoryService connector = GetConnector(invURL);
367 return connector.GetFolderContent(userID, folderID); 394 return connector.GetFolderContent(userID, folderID);
368 395
369 } 396 }
@@ -377,8 +404,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
377 if (invURL == null) // not there, forward to local inventory connector to resolve 404 if (invURL == null) // not there, forward to local inventory connector to resolve
378 return m_LocalGridInventoryService.GetFolderItems(userID, folderID); 405 return m_LocalGridInventoryService.GetFolderItems(userID, folderID);
379 406
380 IInventoryService connector = GetConnector(invURL); 407 List<InventoryItemBase> items = m_Cache.GetFolderItems(userID, folderID);
408 if (items != null)
409 {
410 m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderItems found items in cache " + folderID);
411 return items;
412 }
381 413
414 IInventoryService connector = GetConnector(invURL);
382 return connector.GetFolderItems(userID, folderID); 415 return connector.GetFolderItems(userID, folderID);
383 416
384 } 417 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
index 0fe778d..1e434b9 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
@@ -12,6 +12,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
12 12
13 private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>(); 13 private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>();
14 private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>(); 14 private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>();
15 private static ExpiringCache<UUID, InventoryCollection> m_Inventories = new ExpiringCache<UUID, InventoryCollection>();
15 16
16 public void Cache(UUID userID, InventoryFolderBase root) 17 public void Cache(UUID userID, InventoryFolderBase root)
17 { 18 {
@@ -55,5 +56,55 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
55 56
56 return null; 57 return null;
57 } 58 }
59
60 public void Cache(UUID userID, InventoryCollection inv)
61 {
62 lock (m_Inventories)
63 m_Inventories.AddOrUpdate(userID, inv, 120);
64 }
65
66 public InventoryCollection GetUserInventory(UUID userID)
67 {
68 InventoryCollection inv = null;
69 if (m_Inventories.TryGetValue(userID, out inv))
70 return inv;
71 return null;
72 }
73
74 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
75 {
76 InventoryCollection inv = null;
77 InventoryCollection c;
78 if (m_Inventories.TryGetValue(userID, out inv))
79 {
80 c = new InventoryCollection();
81 c.UserID = userID;
82
83 c.Folders = inv.Folders.FindAll(delegate(InventoryFolderBase f)
84 {
85 return f.ParentID == folderID;
86 });
87 c.Items = inv.Items.FindAll(delegate(InventoryItemBase i)
88 {
89 return i.Folder == folderID;
90 });
91 return c;
92 }
93 return null;
94 }
95
96 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
97 {
98 InventoryCollection inv = null;
99 if (m_Inventories.TryGetValue(userID, out inv))
100 {
101 List<InventoryItemBase> items = inv.Items.FindAll(delegate(InventoryItemBase i)
102 {
103 return i.Folder == folderID;
104 });
105 return items;
106 }
107 return null;
108 }
58 } 109 }
59} 110}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
index 77573c3..990dffb 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
@@ -172,7 +172,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
172 172
173 public InventoryCollection GetUserInventory(UUID userID) 173 public InventoryCollection GetUserInventory(UUID userID)
174 { 174 {
175 return null; 175 return m_RemoteConnector.GetUserInventory(userID);
176 } 176 }
177 177
178 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) 178 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
@@ -193,16 +193,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
193 { 193 {
194 InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID); 194 InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID);
195 195
196 if (UserManager != null) 196 if (invCol != null && UserManager != null)
197 { 197 {
198 // Protect ourselves against the caller subsequently modifying the items list 198 // Protect ourselves against the caller subsequently modifying the items list
199 List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); 199 List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items);
200 200
201 Util.FireAndForget(delegate 201 if (items != null && items.Count > 0)
202 { 202 Util.FireAndForget(delegate
203 foreach (InventoryItemBase item in items) 203 {
204 UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); 204 foreach (InventoryItemBase item in items)
205 }); 205 UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
206 });
206 } 207 }
207 208
208 return invCol; 209 return invCol;
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 1f3f075..509c4d7 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -464,7 +464,7 @@ namespace OpenSim.Region.CoreModules.World.Land
464 { 464 {
465 if (d.GroupID == LandData.GroupID) 465 if (d.GroupID == LandData.GroupID)
466 { 466 {
467 m_groupMemberCache.Add(avatar, false, m_groupMemberCacheTimeout); 467 m_groupMemberCache.Add(avatar, true, m_groupMemberCacheTimeout);
468 return true; 468 return true;
469 } 469 }
470 } 470 }
@@ -472,10 +472,7 @@ namespace OpenSim.Region.CoreModules.World.Land
472 return false; 472 return false;
473 } 473 }
474 474
475 if (!sp.ControllingClient.IsGroupMember(LandData.GroupID)) 475 return sp.ControllingClient.IsGroupMember(LandData.GroupID);
476 return false;
477
478 return true;
479 } 476 }
480 return false; 477 return false;
481 } 478 }