diff options
author | Melanie | 2012-04-07 04:52:14 +0100 |
---|---|---|
committer | Melanie | 2012-04-07 04:52:14 +0100 |
commit | b39de2425cac4c2a94a7fdd6c77100ef831d66b4 (patch) | |
tree | 9258928681a82d68b408354e534c32bcf283ad3a | |
parent | Merge branch 'ubitwork' (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-b39de2425cac4c2a94a7fdd6c77100ef831d66b4.zip opensim-SC_OLD-b39de2425cac4c2a94a7fdd6c77100ef831d66b4.tar.gz opensim-SC_OLD-b39de2425cac4c2a94a7fdd6c77100ef831d66b4.tar.bz2 opensim-SC_OLD-b39de2425cac4c2a94a7fdd6c77100ef831d66b4.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
OpenSim/Region/CoreModules/World/Land/LandObject.cs
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
27 files changed, 960 insertions, 373 deletions
diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs index 8b44f72..d5c062b 100644 --- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs | |||
@@ -162,7 +162,7 @@ namespace OpenSim.Capabilities.Handlers | |||
162 | invFetch.owner_id, invFetch.folder_id, invFetch.owner_id, | 162 | invFetch.owner_id, invFetch.folder_id, invFetch.owner_id, |
163 | invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order, out version); | 163 | invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order, out version); |
164 | 164 | ||
165 | if (inv.Folders != null) | 165 | if (inv != null && inv.Folders != null) |
166 | { | 166 | { |
167 | foreach (InventoryFolderBase invFolder in inv.Folders) | 167 | foreach (InventoryFolderBase invFolder in inv.Folders) |
168 | { | 168 | { |
@@ -170,7 +170,7 @@ namespace OpenSim.Capabilities.Handlers | |||
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | if (inv.Items != null) | 173 | if (inv != null && inv.Items != null) |
174 | { | 174 | { |
175 | foreach (InventoryItemBase invItem in inv.Items) | 175 | foreach (InventoryItemBase invItem in inv.Items) |
176 | { | 176 | { |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 2c0d8f0..ad5af1f 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -662,11 +662,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
662 | } | 662 | } |
663 | catch (IOException e) | 663 | catch (IOException e) |
664 | { | 664 | { |
665 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw ", e); | 665 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e); |
666 | } | 666 | } |
667 | catch (Exception e) | 667 | catch (Exception e) |
668 | { | 668 | { |
669 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw " + e.ToString()); | 669 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e.StackTrace); |
670 | SendHTML500(response); | 670 | SendHTML500(response); |
671 | } | 671 | } |
672 | finally | 672 | finally |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 3118613..1004be6 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -1923,7 +1923,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1923 | 1923 | ||
1924 | folderBlock.FolderID = folder.ID; | 1924 | folderBlock.FolderID = folder.ID; |
1925 | folderBlock.ParentID = folder.ParentID; | 1925 | folderBlock.ParentID = folder.ParentID; |
1926 | folderBlock.Type = -1; | 1926 | //folderBlock.Type = -1; |
1927 | folderBlock.Type = (sbyte)folder.Type; | ||
1927 | folderBlock.Name = Util.StringToBytes256(folder.Name); | 1928 | folderBlock.Name = Util.StringToBytes256(folder.Name); |
1928 | 1929 | ||
1929 | return folderBlock; | 1930 | return folderBlock; |
@@ -4360,7 +4361,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4360 | block.OwnerID = sop.OwnerID; | 4361 | block.OwnerID = sop.OwnerID; |
4361 | 4362 | ||
4362 | block.ItemID = sop.FromUserInventoryItemID; | 4363 | block.ItemID = sop.FromUserInventoryItemID; |
4363 | block.FolderID = UUID.Zero; // sop.FromFolderID ?? | 4364 | block.FolderID = UUID.Zero; // sog.FromFolderID ?? |
4364 | block.FromTaskID = UUID.Zero; // ??? | 4365 | block.FromTaskID = UUID.Zero; // ??? |
4365 | block.InventorySerial = (short)sop.InventorySerial; | 4366 | block.InventorySerial = (short)sop.InventorySerial; |
4366 | 4367 | ||
@@ -5082,7 +5083,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5082 | update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim | 5083 | update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim |
5083 | if (data.ParentGroup.IsAttachment) | 5084 | if (data.ParentGroup.IsAttachment) |
5084 | { | 5085 | { |
5085 | update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.FromItemID); | 5086 | update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID); |
5086 | update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16)); | 5087 | update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16)); |
5087 | } | 5088 | } |
5088 | else | 5089 | else |
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; | |||
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | 31 | ||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Client; | ||
33 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
35 | using OpenSim.Services.Connectors.Hypergrid; | 36 | using 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 | } |
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 741d233..2365cfe 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -506,6 +506,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
506 | public delegate void PrimsLoaded(Scene s); | 506 | public delegate void PrimsLoaded(Scene s); |
507 | public event PrimsLoaded OnPrimsLoaded; | 507 | public event PrimsLoaded OnPrimsLoaded; |
508 | 508 | ||
509 | public delegate void TeleportStart(IClientAPI client, GridRegion destination, GridRegion finalDestination, uint teleportFlags, bool gridLogout); | ||
510 | public event TeleportStart OnTeleportStart; | ||
511 | |||
512 | public delegate void TeleportFail(IClientAPI client, bool gridLogout); | ||
513 | public event TeleportFail OnTeleportFail; | ||
514 | |||
509 | public class MoneyTransferArgs : EventArgs | 515 | public class MoneyTransferArgs : EventArgs |
510 | { | 516 | { |
511 | public UUID sender; | 517 | public UUID sender; |
@@ -2487,5 +2493,48 @@ namespace OpenSim.Region.Framework.Scenes | |||
2487 | } | 2493 | } |
2488 | } | 2494 | } |
2489 | } | 2495 | } |
2496 | |||
2497 | public void TriggerTeleportStart(IClientAPI client, GridRegion destination, GridRegion finalDestination, uint teleportFlags, bool gridLogout) | ||
2498 | { | ||
2499 | TeleportStart handler = OnTeleportStart; | ||
2500 | |||
2501 | if (handler != null) | ||
2502 | { | ||
2503 | foreach (TeleportStart d in handler.GetInvocationList()) | ||
2504 | { | ||
2505 | try | ||
2506 | { | ||
2507 | d(client, destination, finalDestination, teleportFlags, gridLogout); | ||
2508 | } | ||
2509 | catch (Exception e) | ||
2510 | { | ||
2511 | m_log.ErrorFormat("[EVENT MANAGER]: Delegate for TeleportStart failed - continuing {0} - {1}", | ||
2512 | e.Message, e.StackTrace); | ||
2513 | } | ||
2514 | } | ||
2515 | } | ||
2516 | } | ||
2517 | |||
2518 | public void TriggerTeleportFail(IClientAPI client, bool gridLogout) | ||
2519 | { | ||
2520 | TeleportFail handler = OnTeleportFail; | ||
2521 | |||
2522 | if (handler != null) | ||
2523 | { | ||
2524 | foreach (TeleportFail d in handler.GetInvocationList()) | ||
2525 | { | ||
2526 | try | ||
2527 | { | ||
2528 | d(client, gridLogout); | ||
2529 | } | ||
2530 | catch (Exception e) | ||
2531 | { | ||
2532 | m_log.ErrorFormat("[EVENT MANAGER]: Delegate for TeleportFail failed - continuing {0} - {1}", | ||
2533 | e.Message, e.StackTrace); | ||
2534 | } | ||
2535 | } | ||
2536 | } | ||
2537 | } | ||
2538 | |||
2490 | } | 2539 | } |
2491 | } | 2540 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 6cf1067..0089c7d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -36,6 +36,7 @@ using OpenMetaverse.Packets; | |||
36 | using log4net; | 36 | using log4net; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Region.Framework; | 38 | using OpenSim.Region.Framework; |
39 | using OpenSim.Framework.Client; | ||
39 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
40 | using OpenSim.Region.Framework.Scenes.Serialization; | 41 | using OpenSim.Region.Framework.Scenes.Serialization; |
41 | 42 | ||
@@ -117,20 +118,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
117 | /// <param name="item"></param> | 118 | /// <param name="item"></param> |
118 | public bool AddInventoryItem(InventoryItemBase item) | 119 | public bool AddInventoryItem(InventoryItemBase item) |
119 | { | 120 | { |
120 | InventoryFolderBase folder; | 121 | if (item.Folder != UUID.Zero && InventoryService.AddItem(item)) |
121 | |||
122 | if (item.Folder == UUID.Zero) | ||
123 | { | 122 | { |
124 | folder = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); | 123 | int userlevel = 0; |
125 | if (folder == null) | 124 | if (Permissions.IsGod(item.Owner)) |
126 | { | 125 | { |
127 | folder = InventoryService.GetRootFolder(item.Owner); | 126 | userlevel = 1; |
128 | |||
129 | if (folder == null) | ||
130 | return false; | ||
131 | } | 127 | } |
128 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); | ||
129 | |||
130 | return true; | ||
131 | } | ||
132 | 132 | ||
133 | item.Folder = folder.ID; | 133 | // OK so either the viewer didn't send a folderID or AddItem failed |
134 | UUID originalFolder = item.Folder; | ||
135 | InventoryFolderBase f = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); | ||
136 | if (f != null) | ||
137 | { | ||
138 | m_log.DebugFormat( | ||
139 | "[AGENT INVENTORY]: Found folder {0} type {1} for item {2}", | ||
140 | f.Name, (AssetType)f.Type, item.Name); | ||
141 | |||
142 | item.Folder = f.ID; | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | f = InventoryService.GetRootFolder(item.Owner); | ||
147 | if (f != null) | ||
148 | { | ||
149 | item.Folder = f.ID; | ||
150 | } | ||
151 | else | ||
152 | { | ||
153 | m_log.WarnFormat( | ||
154 | "[AGENT INVENTORY]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified", | ||
155 | item.Owner, item.Name); | ||
156 | return false; | ||
157 | } | ||
134 | } | 158 | } |
135 | 159 | ||
136 | if (InventoryService.AddItem(item)) | 160 | if (InventoryService.AddItem(item)) |
@@ -141,7 +165,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
141 | userlevel = 1; | 165 | userlevel = 1; |
142 | } | 166 | } |
143 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); | 167 | EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); |
144 | 168 | ||
169 | if (originalFolder != UUID.Zero) | ||
170 | { | ||
171 | // Tell the viewer that the item didn't go there | ||
172 | ChangePlacement(item, f); | ||
173 | } | ||
174 | |||
145 | return true; | 175 | return true; |
146 | } | 176 | } |
147 | else | 177 | else |
@@ -153,7 +183,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
153 | return false; | 183 | return false; |
154 | } | 184 | } |
155 | } | 185 | } |
156 | 186 | ||
187 | private void ChangePlacement(InventoryItemBase item, InventoryFolderBase f) | ||
188 | { | ||
189 | ScenePresence sp = GetScenePresence(item.Owner); | ||
190 | if (sp != null) | ||
191 | { | ||
192 | if (sp.ControllingClient is IClientCore) | ||
193 | { | ||
194 | IClientCore core = (IClientCore)sp.ControllingClient; | ||
195 | IClientInventory inv; | ||
196 | |||
197 | if (core.TryGet<IClientInventory>(out inv)) | ||
198 | { | ||
199 | InventoryFolderBase parent = new InventoryFolderBase(f.ParentID, f.Owner); | ||
200 | parent = InventoryService.GetFolder(parent); | ||
201 | inv.SendRemoveInventoryItems(new UUID[] { item.ID }); | ||
202 | inv.SendBulkUpdateInventory(new InventoryFolderBase[0], new InventoryItemBase[] { item }); | ||
203 | string message = "The item was placed in folder " + f.Name; | ||
204 | if (parent != null) | ||
205 | message += " under " + parent.Name; | ||
206 | sp.ControllingClient.SendAgentAlertMessage(message, false); | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | |||
157 | /// <summary> | 212 | /// <summary> |
158 | /// Add the given inventory item to a user's inventory. | 213 | /// Add the given inventory item to a user's inventory. |
159 | /// </summary> | 214 | /// </summary> |
@@ -2085,7 +2140,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2085 | item.CreationDate = Util.UnixTimeSinceEpoch(); | 2140 | item.CreationDate = Util.UnixTimeSinceEpoch(); |
2086 | 2141 | ||
2087 | // sets itemID so client can show item as 'attached' in inventory | 2142 | // sets itemID so client can show item as 'attached' in inventory |
2088 | grp.SetFromItemID(item.ID); | 2143 | grp.FromItemID = item.ID; |
2089 | 2144 | ||
2090 | if (AddInventoryItem(item)) | 2145 | if (AddInventoryItem(item)) |
2091 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | 2146 | remoteClient.SendInventoryItemCreateUpdate(item, 0); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index df37b98..a34079c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -2248,12 +2248,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2248 | part.RemoveFromPhysics(); | 2248 | part.RemoveFromPhysics(); |
2249 | } | 2249 | } |
2250 | } | 2250 | } |
2251 | |||
2252 | // if (rootPart.PhysActor != null) | ||
2253 | // { | ||
2254 | // PhysicsScene.RemovePrim(rootPart.PhysActor); | ||
2255 | // rootPart.PhysActor = null; | ||
2256 | // } | ||
2257 | 2251 | ||
2258 | if (UnlinkSceneObject(group, false)) | 2252 | if (UnlinkSceneObject(group, false)) |
2259 | { | 2253 | { |
@@ -2668,7 +2662,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2668 | SceneObjectGroup grp = sceneObject; | 2662 | SceneObjectGroup grp = sceneObject; |
2669 | 2663 | ||
2670 | m_log.DebugFormat( | 2664 | m_log.DebugFormat( |
2671 | "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.GetFromItemID(), grp.UUID); | 2665 | "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID); |
2672 | m_log.DebugFormat( | 2666 | m_log.DebugFormat( |
2673 | "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); | 2667 | "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); |
2674 | 2668 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 54e8d50..107d9b6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -775,7 +775,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
775 | set { m_LoopSoundSlavePrims = value; } | 775 | set { m_LoopSoundSlavePrims = value; } |
776 | } | 776 | } |
777 | 777 | ||
778 | // The UUID for the Region this Object is in. | 778 | /// <summary> |
779 | /// The UUID for the region this object is in. | ||
780 | /// </summary> | ||
779 | public UUID RegionUUID | 781 | public UUID RegionUUID |
780 | { | 782 | { |
781 | get | 783 | get |
@@ -788,6 +790,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
788 | } | 790 | } |
789 | } | 791 | } |
790 | 792 | ||
793 | /// <summary> | ||
794 | /// The item ID that this object was rezzed from, if applicable. | ||
795 | /// </summary> | ||
796 | /// <remarks> | ||
797 | /// If not applicable will be UUID.Zero | ||
798 | /// </remarks> | ||
799 | public UUID FromItemID { get; set; } | ||
800 | |||
801 | /// <summary> | ||
802 | /// The folder ID that this object was rezzed from, if applicable. | ||
803 | /// </summary> | ||
804 | /// <remarks> | ||
805 | /// If not applicable will be UUID.Zero | ||
806 | /// </remarks> | ||
807 | public UUID FromFolderID { get; set; } | ||
808 | |||
791 | #endregion | 809 | #endregion |
792 | 810 | ||
793 | // ~SceneObjectGroup() | 811 | // ~SceneObjectGroup() |
@@ -851,18 +869,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
851 | } | 869 | } |
852 | } | 870 | } |
853 | 871 | ||
854 | public void SetFromItemID(UUID AssetId) | ||
855 | { | ||
856 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
857 | for (int i = 0; i < parts.Length; i++) | ||
858 | parts[i].FromItemID = AssetId; | ||
859 | } | ||
860 | |||
861 | public UUID GetFromItemID() | ||
862 | { | ||
863 | return m_rootPart.FromItemID; | ||
864 | } | ||
865 | |||
866 | /// <summary> | 872 | /// <summary> |
867 | /// Hooks this object up to the backup event so that it is persisted to the database when the update thread executes. | 873 | /// Hooks this object up to the backup event so that it is persisted to the database when the update thread executes. |
868 | /// </summary> | 874 | /// </summary> |
@@ -1498,7 +1504,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1498 | return; | 1504 | return; |
1499 | 1505 | ||
1500 | detachedpos = avatar.AbsolutePosition; | 1506 | detachedpos = avatar.AbsolutePosition; |
1501 | RootPart.FromItemID = UUID.Zero; | 1507 | FromItemID = UUID.Zero; |
1502 | 1508 | ||
1503 | AbsolutePosition = detachedpos; | 1509 | AbsolutePosition = detachedpos; |
1504 | AttachedAvatar = UUID.Zero; | 1510 | AttachedAvatar = UUID.Zero; |
@@ -3379,6 +3385,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3379 | { | 3385 | { |
3380 | m_rootPart.AttachedPos = pos; | 3386 | m_rootPart.AttachedPos = pos; |
3381 | } | 3387 | } |
3388 | |||
3382 | if (RootPart.GetStatusSandbox()) | 3389 | if (RootPart.GetStatusSandbox()) |
3383 | { | 3390 | { |
3384 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, pos) > 10) | 3391 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, pos) > 10) |
@@ -3389,8 +3396,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3389 | ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); | 3396 | ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); |
3390 | } | 3397 | } |
3391 | } | 3398 | } |
3392 | AbsolutePosition = pos; | ||
3393 | 3399 | ||
3400 | AbsolutePosition = pos; | ||
3394 | HasGroupChanged = true; | 3401 | HasGroupChanged = true; |
3395 | } | 3402 | } |
3396 | 3403 | ||
@@ -4032,7 +4039,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4032 | 4039 | ||
4033 | public virtual string ExtraToXmlString() | 4040 | public virtual string ExtraToXmlString() |
4034 | { | 4041 | { |
4035 | return "<ExtraFromItemID>" + GetFromItemID().ToString() + "</ExtraFromItemID>"; | 4042 | return "<ExtraFromItemID>" + FromItemID.ToString() + "</ExtraFromItemID>"; |
4036 | } | 4043 | } |
4037 | 4044 | ||
4038 | public virtual void ExtraFromXmlString(string xmlstr) | 4045 | public virtual void ExtraFromXmlString(string xmlstr) |
@@ -4044,7 +4051,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4044 | UUID uuid = UUID.Zero; | 4051 | UUID uuid = UUID.Zero; |
4045 | UUID.TryParse(id, out uuid); | 4052 | UUID.TryParse(id, out uuid); |
4046 | 4053 | ||
4047 | SetFromItemID(uuid); | 4054 | FromItemID = uuid; |
4048 | } | 4055 | } |
4049 | 4056 | ||
4050 | public void ResetOwnerChangeFlag() | 4057 | public void ResetOwnerChangeFlag() |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 951e987..969ddaf 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -126,12 +126,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
126 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 126 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
127 | 127 | ||
128 | /// <value> | 128 | /// <value> |
129 | /// Is this sop a root part? | 129 | /// Is this a root part? |
130 | /// </value> | 130 | /// </value> |
131 | 131 | /// <remarks> | |
132 | /// This will return true even if the whole object is attached to an avatar. | ||
133 | /// </remarks> | ||
132 | public bool IsRoot | 134 | public bool IsRoot |
133 | { | 135 | { |
134 | get { return ParentGroup.RootPart == this; } | 136 | get { return ParentGroup.RootPart == this; } |
135 | } | 137 | } |
136 | 138 | ||
137 | #region Fields | 139 | #region Fields |
@@ -160,15 +162,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
160 | /// If another thread is simultaneously turning physics off on this part then this refernece could become | 162 | /// If another thread is simultaneously turning physics off on this part then this refernece could become |
161 | /// null at any time. | 163 | /// null at any time. |
162 | /// </remarks> | 164 | /// </remarks> |
163 | public PhysicsActor PhysActor | 165 | public PhysicsActor PhysActor { get; set; } |
164 | { | ||
165 | get { return m_physActor; } | ||
166 | set | ||
167 | { | ||
168 | // m_log.DebugFormat("[SOP]: PhysActor set to {0} for {1} {2}", value, Name, UUID); | ||
169 | m_physActor = value; | ||
170 | } | ||
171 | } | ||
172 | 166 | ||
173 | //Xantor 20080528 Sound stuff: | 167 | //Xantor 20080528 Sound stuff: |
174 | // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. | 168 | // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. |
@@ -188,10 +182,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
188 | public uint TimeStampLastActivity; // Will be used for AutoReturn | 182 | public uint TimeStampLastActivity; // Will be used for AutoReturn |
189 | 183 | ||
190 | public uint TimeStampTerse; | 184 | public uint TimeStampTerse; |
191 | |||
192 | public UUID FromItemID; | ||
193 | |||
194 | public UUID FromFolderID; | ||
195 | 185 | ||
196 | // The following two are to hold the attachment data | 186 | // The following two are to hold the attachment data |
197 | // while an object is inworld | 187 | // while an object is inworld |
@@ -275,7 +265,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
275 | 265 | ||
276 | private bool m_passTouches; | 266 | private bool m_passTouches; |
277 | 267 | ||
278 | private PhysicsActor m_physActor; | ||
279 | protected Vector3 m_acceleration; | 268 | protected Vector3 m_acceleration; |
280 | protected Vector3 m_angularVelocity; | 269 | protected Vector3 m_angularVelocity; |
281 | 270 | ||
@@ -1149,6 +1138,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1149 | } | 1138 | } |
1150 | } | 1139 | } |
1151 | 1140 | ||
1141 | /// <summary> | ||
1142 | /// The parent ID of this part. | ||
1143 | /// </summary> | ||
1144 | /// <remarks> | ||
1145 | /// If this is a root part which is not attached to an avatar then the value will be 0. | ||
1146 | /// If this is a root part which is attached to an avatar then the value is the local id of that avatar. | ||
1147 | /// If this is a child part then the value is the local ID of the root part. | ||
1148 | /// </remarks> | ||
1152 | public uint ParentID | 1149 | public uint ParentID |
1153 | { | 1150 | { |
1154 | get { return _parentID; } | 1151 | get { return _parentID; } |
@@ -1847,9 +1844,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1847 | // if (VolumeDetectActive) | 1844 | // if (VolumeDetectActive) |
1848 | // isPhantom = false; | 1845 | // isPhantom = false; |
1849 | 1846 | ||
1850 | // Added clarification.. since A rigid body is an object that you can kick around, etc. | ||
1851 | // bool RigidBody = isPhysical && !isPhantom; | ||
1852 | |||
1853 | // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition | 1847 | // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition |
1854 | // or flexible | 1848 | // or flexible |
1855 | // if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) | 1849 | // if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) |
@@ -1876,7 +1870,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1876 | PhysActor = null; | 1870 | PhysActor = null; |
1877 | } | 1871 | } |
1878 | 1872 | ||
1879 | // Basic Physics can also return null as well as an exception catch. | ||
1880 | PhysicsActor pa = PhysActor; | 1873 | PhysicsActor pa = PhysActor; |
1881 | 1874 | ||
1882 | if (pa != null) | 1875 | if (pa != null) |
@@ -4859,7 +4852,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
4859 | } | 4852 | } |
4860 | 4853 | ||
4861 | /// <summary> | 4854 | /// <summary> |
4862 | /// This removes the part from physics | 4855 | /// Adds this part to the physics scene. |
4856 | /// </summary> | ||
4857 | /// <remarks>This method also sets the PhysActor property.</remarks> | ||
4858 | /// <param name="rigidBody">Add this prim with a rigid body.</param> | ||
4859 | /// <returns> | ||
4860 | /// The physics actor. null if there was a failure. | ||
4861 | /// </returns> | ||
4862 | private PhysicsActor AddToPhysics(bool rigidBody) | ||
4863 | { | ||
4864 | PhysicsActor pa; | ||
4865 | |||
4866 | try | ||
4867 | { | ||
4868 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( | ||
4869 | string.Format("{0}/{1}", Name, UUID), | ||
4870 | Shape, | ||
4871 | AbsolutePosition, | ||
4872 | Scale, | ||
4873 | RotationOffset, | ||
4874 | rigidBody, | ||
4875 | m_localId); | ||
4876 | } | ||
4877 | catch | ||
4878 | { | ||
4879 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); | ||
4880 | pa = null; | ||
4881 | } | ||
4882 | |||
4883 | // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical | ||
4884 | // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor | ||
4885 | // being set. | ||
4886 | PhysActor = pa; | ||
4887 | |||
4888 | // Basic Physics can also return null as well as an exception catch. | ||
4889 | if (pa != null) | ||
4890 | { | ||
4891 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | ||
4892 | pa.SetMaterial(Material); | ||
4893 | DoPhysicsPropertyUpdate(rigidBody, true); | ||
4894 | } | ||
4895 | |||
4896 | return pa; | ||
4897 | } | ||
4898 | |||
4899 | /// <summary> | ||
4900 | /// This removes the part from the physics scene. | ||
4863 | /// </summary> | 4901 | /// </summary> |
4864 | /// <remarks> | 4902 | /// <remarks> |
4865 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics | 4903 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ed3a7f1..b51d41b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3617,6 +3617,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3617 | }); | 3617 | }); |
3618 | } | 3618 | } |
3619 | 3619 | ||
3620 | /// <summary> | ||
3621 | /// Gets the mass. | ||
3622 | /// </summary> | ||
3623 | /// <returns> | ||
3624 | /// The mass. | ||
3625 | /// </returns> | ||
3626 | public float GetMass() | ||
3627 | { | ||
3628 | PhysicsActor pa = PhysicsActor; | ||
3629 | |||
3630 | if (pa != null) | ||
3631 | return pa.Mass; | ||
3632 | else | ||
3633 | return 0; | ||
3634 | } | ||
3635 | |||
3620 | internal void PushForce(Vector3 impulse) | 3636 | internal void PushForce(Vector3 impulse) |
3621 | { | 3637 | { |
3622 | if (PhysicsActor != null) | 3638 | if (PhysicsActor != null) |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index 9ff3652..65bd26c 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | |||
@@ -1294,7 +1294,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1294 | 1294 | ||
1295 | OnAgentDataUpdateRequest(remoteClient, dataForAgentID, UUID.Zero); | 1295 | OnAgentDataUpdateRequest(remoteClient, dataForAgentID, UUID.Zero); |
1296 | 1296 | ||
1297 | |||
1298 | // Need to send a group membership update to the client | 1297 | // Need to send a group membership update to the client |
1299 | // UDP version doesn't seem to behave nicely. But we're going to send it out here | 1298 | // UDP version doesn't seem to behave nicely. But we're going to send it out here |
1300 | // with an empty group membership to hopefully remove groups being displayed due | 1299 | // with an empty group membership to hopefully remove groups being displayed due |
@@ -1305,6 +1304,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1305 | SendGroupMembershipInfoViaCaps(remoteClient, dataForAgentID, membershipArray); | 1304 | SendGroupMembershipInfoViaCaps(remoteClient, dataForAgentID, membershipArray); |
1306 | remoteClient.SendAvatarGroupsReply(dataForAgentID, membershipArray); | 1305 | remoteClient.SendAvatarGroupsReply(dataForAgentID, membershipArray); |
1307 | 1306 | ||
1307 | if (remoteClient.AgentId == dataForAgentID) | ||
1308 | remoteClient.RefreshGroupMembership(); | ||
1308 | } | 1309 | } |
1309 | 1310 | ||
1310 | /// <summary> | 1311 | /// <summary> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5268ade..7cf284d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -2271,11 +2271,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2271 | protected LSL_Vector GetPartLocalPos(SceneObjectPart part) | 2271 | protected LSL_Vector GetPartLocalPos(SceneObjectPart part) |
2272 | { | 2272 | { |
2273 | m_host.AddScriptLPS(1); | 2273 | m_host.AddScriptLPS(1); |
2274 | if (part.ParentID == 0) | 2274 | |
2275 | Vector3 pos; | ||
2276 | |||
2277 | if (!part.IsRoot) | ||
2275 | { | 2278 | { |
2276 | return new LSL_Vector(part.AbsolutePosition.X, | 2279 | pos = part.OffsetPosition; |
2277 | part.AbsolutePosition.Y, | ||
2278 | part.AbsolutePosition.Z); | ||
2279 | } | 2280 | } |
2280 | else | 2281 | else |
2281 | { | 2282 | { |
@@ -2287,11 +2288,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2287 | } | 2288 | } |
2288 | else | 2289 | else |
2289 | { | 2290 | { |
2290 | return new LSL_Vector(part.OffsetPosition.X, | 2291 | pos = part.AbsolutePosition; |
2291 | part.OffsetPosition.Y, | ||
2292 | part.OffsetPosition.Z); | ||
2293 | } | 2292 | } |
2294 | } | 2293 | } |
2294 | |||
2295 | // m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos); | ||
2296 | |||
2297 | return new LSL_Vector(pos.X, pos.Y, pos.Z); | ||
2295 | } | 2298 | } |
2296 | 2299 | ||
2297 | public void llSetRot(LSL_Rotation rot) | 2300 | public void llSetRot(LSL_Rotation rot) |
@@ -3165,7 +3168,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3165 | public LSL_Float llGetMass() | 3168 | public LSL_Float llGetMass() |
3166 | { | 3169 | { |
3167 | m_host.AddScriptLPS(1); | 3170 | m_host.AddScriptLPS(1); |
3168 | return m_host.GetMass(); | 3171 | |
3172 | if (m_host.ParentGroup.IsAttachment) | ||
3173 | { | ||
3174 | ScenePresence attachedAvatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); | ||
3175 | |||
3176 | if (attachedAvatar != null) | ||
3177 | { | ||
3178 | return attachedAvatar.GetMass(); | ||
3179 | } | ||
3180 | else | ||
3181 | { | ||
3182 | return 0; | ||
3183 | } | ||
3184 | } | ||
3185 | else | ||
3186 | { | ||
3187 | if (m_host.IsRoot) | ||
3188 | { | ||
3189 | return m_host.ParentGroup.GetMass(); | ||
3190 | } | ||
3191 | else | ||
3192 | { | ||
3193 | return m_host.GetMass(); | ||
3194 | } | ||
3195 | } | ||
3169 | } | 3196 | } |
3170 | 3197 | ||
3171 | public void llCollisionFilter(string name, string id, int accept) | 3198 | public void llCollisionFilter(string name, string id, int accept) |
@@ -3334,7 +3361,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3334 | SceneObjectPart host = (SceneObjectPart)o; | 3361 | SceneObjectPart host = (SceneObjectPart)o; |
3335 | 3362 | ||
3336 | SceneObjectGroup grp = host.ParentGroup; | 3363 | SceneObjectGroup grp = host.ParentGroup; |
3337 | UUID itemID = grp.GetFromItemID(); | 3364 | UUID itemID = grp.FromItemID; |
3338 | ScenePresence presence = World.GetScenePresence(host.OwnerID); | 3365 | ScenePresence presence = World.GetScenePresence(host.OwnerID); |
3339 | 3366 | ||
3340 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3367 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
@@ -7782,14 +7809,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7782 | switch (code) | 7809 | switch (code) |
7783 | { | 7810 | { |
7784 | case (int)ScriptBaseClass.PRIM_POSITION: | 7811 | case (int)ScriptBaseClass.PRIM_POSITION: |
7785 | if (remain < 1) | ||
7786 | return; | ||
7787 | |||
7788 | v=rules.GetVector3Item(idx++); | ||
7789 | positionChanged = true; | ||
7790 | currentPosition = GetSetPosTarget(part, v, currentPosition); | ||
7791 | |||
7792 | break; | ||
7793 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | 7812 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: |
7794 | if (remain < 1) | 7813 | if (remain < 1) |
7795 | return; | 7814 | return; |
@@ -11154,6 +11173,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11154 | case ScriptBaseClass.OBJECT_CREATOR: | 11173 | case ScriptBaseClass.OBJECT_CREATOR: |
11155 | ret.Add(new LSL_String(UUID.Zero.ToString())); | 11174 | ret.Add(new LSL_String(UUID.Zero.ToString())); |
11156 | break; | 11175 | break; |
11176 | // For the following 8 see the Object version below | ||
11177 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: | ||
11178 | ret.Add(new LSL_Integer(0)); | ||
11179 | break; | ||
11180 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: | ||
11181 | ret.Add(new LSL_Integer(0)); | ||
11182 | break; | ||
11183 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: | ||
11184 | ret.Add(new LSL_Integer(0)); | ||
11185 | break; | ||
11186 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: | ||
11187 | ret.Add(new LSL_Float(0)); | ||
11188 | break; | ||
11189 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: | ||
11190 | ret.Add(new LSL_Integer(0)); | ||
11191 | break; | ||
11192 | case ScriptBaseClass.OBJECT_SERVER_COST: | ||
11193 | ret.Add(new LSL_Float(0)); | ||
11194 | break; | ||
11195 | case ScriptBaseClass.OBJECT_STREAMING_COST: | ||
11196 | ret.Add(new LSL_Float(0)); | ||
11197 | break; | ||
11198 | case ScriptBaseClass.OBJECT_PHYSICS_COST: | ||
11199 | ret.Add(new LSL_Float(0)); | ||
11200 | break; | ||
11201 | default: | ||
11202 | // Invalid or unhandled constant. | ||
11203 | ret.Add(new LSL_Integer(ScriptBaseClass.OBJECT_UNKNOWN_DETAIL)); | ||
11204 | break; | ||
11157 | } | 11205 | } |
11158 | } | 11206 | } |
11159 | 11207 | ||
@@ -11191,6 +11239,49 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11191 | case ScriptBaseClass.OBJECT_CREATOR: | 11239 | case ScriptBaseClass.OBJECT_CREATOR: |
11192 | ret.Add(new LSL_String(obj.CreatorID.ToString())); | 11240 | ret.Add(new LSL_String(obj.CreatorID.ToString())); |
11193 | break; | 11241 | break; |
11242 | // The following 8 I have intentionaly coded to return zero. They are part of | ||
11243 | // "Land Impact" calculations. These calculations are probably not applicable | ||
11244 | // to OpenSim, required figures (cpu/memory usage) are not currently tracked | ||
11245 | // I have intentionally left these all at zero rather than return possibly | ||
11246 | // missleading numbers | ||
11247 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: | ||
11248 | // in SL this currently includes crashed scripts | ||
11249 | ret.Add(new LSL_Integer(0)); | ||
11250 | break; | ||
11251 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: | ||
11252 | ret.Add(new LSL_Integer(0)); | ||
11253 | break; | ||
11254 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: | ||
11255 | // The value returned in SL for mono scripts is 65536 * number of active scripts | ||
11256 | ret.Add(new LSL_Integer(0)); | ||
11257 | break; | ||
11258 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: | ||
11259 | // Average cpu time per simulator frame expended on all scripts in the objetc | ||
11260 | ret.Add(new LSL_Float(0)); | ||
11261 | break; | ||
11262 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: | ||
11263 | // according to the SL wiki A prim or linkset will have prim | ||
11264 | // equivalent of the number of prims in a linkset if it does not | ||
11265 | // contain a mesh anywhere in the link set or is not a normal prim | ||
11266 | // The value returned in SL for normal prims is prim count | ||
11267 | ret.Add(new LSL_Integer(0)); | ||
11268 | break; | ||
11269 | case ScriptBaseClass.OBJECT_SERVER_COST: | ||
11270 | // The value returned in SL for normal prims is prim count | ||
11271 | ret.Add(new LSL_Float(0)); | ||
11272 | break; | ||
11273 | case ScriptBaseClass.OBJECT_STREAMING_COST: | ||
11274 | // The value returned in SL for normal prims is prim count * 0.06 | ||
11275 | ret.Add(new LSL_Float(0)); | ||
11276 | break; | ||
11277 | case ScriptBaseClass.OBJECT_PHYSICS_COST: | ||
11278 | // The value returned in SL for normal prims is prim count | ||
11279 | ret.Add(new LSL_Float(0)); | ||
11280 | break; | ||
11281 | default: | ||
11282 | // Invalid or unhandled constant. | ||
11283 | ret.Add(new LSL_Integer(ScriptBaseClass.OBJECT_UNKNOWN_DETAIL)); | ||
11284 | break; | ||
11194 | } | 11285 | } |
11195 | } | 11286 | } |
11196 | 11287 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 4ce3cf1..6246b57 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -481,6 +481,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
481 | public const int DEBUG_CHANNEL = 0x7FFFFFFF; | 481 | public const int DEBUG_CHANNEL = 0x7FFFFFFF; |
482 | public const int PUBLIC_CHANNEL = 0x00000000; | 482 | public const int PUBLIC_CHANNEL = 0x00000000; |
483 | 483 | ||
484 | // Constants for llGetObjectDetails | ||
485 | public const int OBJECT_UNKNOWN_DETAIL = -1; | ||
484 | public const int OBJECT_NAME = 1; | 486 | public const int OBJECT_NAME = 1; |
485 | public const int OBJECT_DESC = 2; | 487 | public const int OBJECT_DESC = 2; |
486 | public const int OBJECT_POS = 3; | 488 | public const int OBJECT_POS = 3; |
@@ -489,6 +491,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
489 | public const int OBJECT_OWNER = 6; | 491 | public const int OBJECT_OWNER = 6; |
490 | public const int OBJECT_GROUP = 7; | 492 | public const int OBJECT_GROUP = 7; |
491 | public const int OBJECT_CREATOR = 8; | 493 | public const int OBJECT_CREATOR = 8; |
494 | public const int OBJECT_RUNNING_SCRIPT_COUNT = 9; | ||
495 | public const int OBJECT_TOTAL_SCRIPT_COUNT = 10; | ||
496 | public const int OBJECT_SCRIPT_MEMORY = 11; | ||
497 | public const int OBJECT_SCRIPT_TIME = 12; | ||
498 | public const int OBJECT_PRIM_EQUIVALENCE = 13; | ||
499 | public const int OBJECT_SERVER_COST = 14; | ||
500 | public const int OBJECT_STREAMING_COST = 15; | ||
501 | public const int OBJECT_PHYSICS_COST = 16; | ||
492 | 502 | ||
493 | // Can not be public const? | 503 | // Can not be public const? |
494 | public static readonly vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0); | 504 | public static readonly vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0); |
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 040c840..cb9b65d 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | |||
@@ -114,6 +114,8 @@ namespace OpenSim.Server.Handlers.Asset | |||
114 | return HandleCreateUserInventory(request); | 114 | return HandleCreateUserInventory(request); |
115 | case "GETINVENTORYSKELETON": | 115 | case "GETINVENTORYSKELETON": |
116 | return HandleGetInventorySkeleton(request); | 116 | return HandleGetInventorySkeleton(request); |
117 | case "GETUSERINVENTORY": | ||
118 | return HandleGetUserInventory(request); | ||
117 | case "GETROOTFOLDER": | 119 | case "GETROOTFOLDER": |
118 | return HandleGetRootFolder(request); | 120 | return HandleGetRootFolder(request); |
119 | case "GETFOLDERFORTYPE": | 121 | case "GETFOLDERFORTYPE": |
@@ -153,7 +155,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
153 | } | 155 | } |
154 | catch (Exception e) | 156 | catch (Exception e) |
155 | { | 157 | { |
156 | m_log.DebugFormat("[XINVENTORY HANDLER]: Exception {0}", e); | 158 | m_log.DebugFormat("[XINVENTORY HANDLER]: Exception {0}", e.StackTrace); |
157 | } | 159 | } |
158 | 160 | ||
159 | return FailureResult(); | 161 | return FailureResult(); |
@@ -248,6 +250,45 @@ namespace OpenSim.Server.Handlers.Asset | |||
248 | return encoding.GetBytes(xmlString); | 250 | return encoding.GetBytes(xmlString); |
249 | } | 251 | } |
250 | 252 | ||
253 | byte[] HandleGetUserInventory(Dictionary<string, object> request) | ||
254 | { | ||
255 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
256 | UUID principal = UUID.Zero; | ||
257 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
258 | |||
259 | InventoryCollection icoll = m_InventoryService.GetUserInventory(principal); | ||
260 | if (icoll != null) | ||
261 | { | ||
262 | Dictionary<string, object> folders = new Dictionary<string, object>(); | ||
263 | int i = 0; | ||
264 | if (icoll.Folders != null) | ||
265 | { | ||
266 | foreach (InventoryFolderBase f in icoll.Folders) | ||
267 | { | ||
268 | folders["folder_" + i.ToString()] = EncodeFolder(f); | ||
269 | i++; | ||
270 | } | ||
271 | result["FOLDERS"] = folders; | ||
272 | } | ||
273 | if (icoll.Items != null) | ||
274 | { | ||
275 | i = 0; | ||
276 | Dictionary<string, object> items = new Dictionary<string, object>(); | ||
277 | foreach (InventoryItemBase it in icoll.Items) | ||
278 | { | ||
279 | items["item_" + i.ToString()] = EncodeItem(it); | ||
280 | i++; | ||
281 | } | ||
282 | result["ITEMS"] = items; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
287 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | ||
288 | UTF8Encoding encoding = new UTF8Encoding(); | ||
289 | return encoding.GetBytes(xmlString); | ||
290 | } | ||
291 | |||
251 | byte[] HandleGetRootFolder(Dictionary<string,object> request) | 292 | byte[] HandleGetRootFolder(Dictionary<string,object> request) |
252 | { | 293 | { |
253 | Dictionary<string,object> result = new Dictionary<string,object>(); | 294 | Dictionary<string,object> result = new Dictionary<string,object>(); |
@@ -293,22 +334,27 @@ namespace OpenSim.Server.Handlers.Asset | |||
293 | if (icoll != null) | 334 | if (icoll != null) |
294 | { | 335 | { |
295 | Dictionary<string, object> folders = new Dictionary<string, object>(); | 336 | Dictionary<string, object> folders = new Dictionary<string, object>(); |
296 | int i = 0; | 337 | int i = 0; |
297 | foreach (InventoryFolderBase f in icoll.Folders) | 338 | if (icoll.Folders != null) |
298 | { | 339 | { |
299 | folders["folder_" + i.ToString()] = EncodeFolder(f); | 340 | foreach (InventoryFolderBase f in icoll.Folders) |
300 | i++; | 341 | { |
342 | folders["folder_" + i.ToString()] = EncodeFolder(f); | ||
343 | i++; | ||
344 | } | ||
345 | result["FOLDERS"] = folders; | ||
301 | } | 346 | } |
302 | result["FOLDERS"] = folders; | 347 | if (icoll.Items != null) |
303 | |||
304 | i = 0; | ||
305 | Dictionary<string, object> items = new Dictionary<string, object>(); | ||
306 | foreach (InventoryItemBase it in icoll.Items) | ||
307 | { | 348 | { |
308 | items["item_" + i.ToString()] = EncodeItem(it); | 349 | i = 0; |
309 | i++; | 350 | Dictionary<string, object> items = new Dictionary<string, object>(); |
351 | foreach (InventoryItemBase it in icoll.Items) | ||
352 | { | ||
353 | items["item_" + i.ToString()] = EncodeItem(it); | ||
354 | i++; | ||
355 | } | ||
356 | result["ITEMS"] = items; | ||
310 | } | 357 | } |
311 | result["ITEMS"] = items; | ||
312 | } | 358 | } |
313 | 359 | ||
314 | string xmlString = ServerUtils.BuildXmlResponse(result); | 360 | string xmlString = ServerUtils.BuildXmlResponse(result); |
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs index 39e983b..9d96703 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs | |||
@@ -111,19 +111,21 @@ namespace OpenSim.Services.Connectors | |||
111 | if (ret.Count == 0) | 111 | if (ret.Count == 0) |
112 | return null; | 112 | return null; |
113 | 113 | ||
114 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | 114 | Dictionary<string, object> folders = (Dictionary<string, object>)ret["FOLDERS"]; |
115 | |||
116 | List<InventoryFolderBase> fldrs = new List<InventoryFolderBase>(); | ||
115 | 117 | ||
116 | try | 118 | try |
117 | { | 119 | { |
118 | foreach (Object o in ret.Values) | 120 | foreach (Object o in folders.Values) |
119 | folders.Add(BuildFolder((Dictionary<string, object>)o)); | 121 | fldrs.Add(BuildFolder((Dictionary<string, object>)o)); |
120 | } | 122 | } |
121 | catch (Exception e) | 123 | catch (Exception e) |
122 | { | 124 | { |
123 | m_log.DebugFormat("[XINVENTORY CONNECTOR STUB]: Exception unwrapping folder list: {0}", e.Message); | 125 | m_log.DebugFormat("[XINVENTORY CONNECTOR STUB]: Exception unwrapping folder list: {0}", e.Message); |
124 | } | 126 | } |
125 | 127 | ||
126 | return folders; | 128 | return fldrs; |
127 | } | 129 | } |
128 | 130 | ||
129 | public InventoryFolderBase GetRootFolder(UUID principalID) | 131 | public InventoryFolderBase GetRootFolder(UUID principalID) |
@@ -492,12 +494,41 @@ namespace OpenSim.Services.Connectors | |||
492 | return int.Parse(ret["RESULT"].ToString()); | 494 | return int.Parse(ret["RESULT"].ToString()); |
493 | } | 495 | } |
494 | 496 | ||
495 | |||
496 | // These are either obsolete or unused | ||
497 | // | ||
498 | public InventoryCollection GetUserInventory(UUID principalID) | 497 | public InventoryCollection GetUserInventory(UUID principalID) |
499 | { | 498 | { |
500 | return null; | 499 | InventoryCollection inventory = new InventoryCollection(); |
500 | inventory.Folders = new List<InventoryFolderBase>(); | ||
501 | inventory.Items = new List<InventoryItemBase>(); | ||
502 | inventory.UserID = principalID; | ||
503 | |||
504 | try | ||
505 | { | ||
506 | Dictionary<string, object> ret = MakeRequest("GETUSERINVENTORY", | ||
507 | new Dictionary<string, object> { | ||
508 | { "PRINCIPAL", principalID.ToString() } | ||
509 | }); | ||
510 | |||
511 | if (ret == null) | ||
512 | return null; | ||
513 | if (ret.Count == 0) | ||
514 | return null; | ||
515 | |||
516 | Dictionary<string, object> folders = | ||
517 | (Dictionary<string, object>)ret["FOLDERS"]; | ||
518 | Dictionary<string, object> items = | ||
519 | (Dictionary<string, object>)ret["ITEMS"]; | ||
520 | |||
521 | foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i | ||
522 | inventory.Folders.Add(BuildFolder((Dictionary<string, object>)o)); | ||
523 | foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i | ||
524 | inventory.Items.Add(BuildItem((Dictionary<string, object>)o)); | ||
525 | } | ||
526 | catch (Exception e) | ||
527 | { | ||
528 | m_log.DebugFormat("[XINVENTORY CONNECTOR STUB]: Exception in GetUserInventory: {0}", e.Message); | ||
529 | } | ||
530 | |||
531 | return inventory; | ||
501 | } | 532 | } |
502 | 533 | ||
503 | public void GetUserInventory(UUID principalID, InventoryReceiptCallback callback) | 534 | public void GetUserInventory(UUID principalID, InventoryReceiptCallback callback) |
diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs index b29d803..2e9bd40 100644 --- a/OpenSim/Services/HypergridService/HGInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGInventoryService.cs | |||
@@ -105,6 +105,12 @@ namespace OpenSim.Services.HypergridService | |||
105 | return new List<InventoryFolderBase>(); | 105 | return new List<InventoryFolderBase>(); |
106 | } | 106 | } |
107 | 107 | ||
108 | public override InventoryCollection GetUserInventory(UUID userID) | ||
109 | { | ||
110 | // NOGO for this inventory service | ||
111 | return null; | ||
112 | } | ||
113 | |||
108 | public override InventoryFolderBase GetRootFolder(UUID principalID) | 114 | public override InventoryFolderBase GetRootFolder(UUID principalID) |
109 | { | 115 | { |
110 | //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetRootFolder for {0}", principalID); | 116 | //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetRootFolder for {0}", principalID); |
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index cb686e2..b6ec558 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Services.HypergridService | |||
59 | 59 | ||
60 | private UserAccountCache m_Cache; | 60 | private UserAccountCache m_Cache; |
61 | 61 | ||
62 | private ExpiringCache<UUID, List<XInventoryFolder>> m_SuitcaseTrees = new ExpiringCache<UUID,List<XInventoryFolder>>(); | 62 | private ExpiringCache<UUID, List<XInventoryFolder>> m_SuitcaseTrees = new ExpiringCache<UUID, List<XInventoryFolder>>(); |
63 | 63 | ||
64 | public HGSuitcaseInventoryService(IConfigSource config, string configName) | 64 | public HGSuitcaseInventoryService(IConfigSource config, string configName) |
65 | : base(config, configName) | 65 | : base(config, configName) |
@@ -104,11 +104,72 @@ namespace OpenSim.Services.HypergridService | |||
104 | return false; | 104 | return false; |
105 | } | 105 | } |
106 | 106 | ||
107 | |||
108 | public override List<InventoryFolderBase> GetInventorySkeleton(UUID principalID) | 107 | public override List<InventoryFolderBase> GetInventorySkeleton(UUID principalID) |
109 | { | 108 | { |
110 | // NOGO for this inventory service | 109 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); |
111 | return new List<InventoryFolderBase>(); | 110 | XInventoryFolder root = GetRootXFolder(principalID); |
111 | |||
112 | List<XInventoryFolder> tree = GetFolderTree(suitcase.folderID); | ||
113 | if (tree == null || (tree != null && tree.Count == 0)) | ||
114 | return null; | ||
115 | |||
116 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | ||
117 | foreach (XInventoryFolder x in tree) | ||
118 | { | ||
119 | folders.Add(ConvertToOpenSim(x)); | ||
120 | } | ||
121 | |||
122 | SetAsRootFolder(suitcase, root); | ||
123 | folders.Add(ConvertToOpenSim(suitcase)); | ||
124 | |||
125 | return folders; | ||
126 | } | ||
127 | |||
128 | public override InventoryCollection GetUserInventory(UUID userID) | ||
129 | { | ||
130 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Get Suitcase inventory for user {0}", userID); | ||
131 | InventoryCollection userInventory = new InventoryCollection(); | ||
132 | userInventory.UserID = userID; | ||
133 | userInventory.Folders = new List<InventoryFolderBase>(); | ||
134 | userInventory.Items = new List<InventoryItemBase>(); | ||
135 | |||
136 | XInventoryFolder suitcase = GetSuitcaseXFolder(userID); | ||
137 | XInventoryFolder root = GetRootXFolder(userID); | ||
138 | |||
139 | List<XInventoryFolder> tree = GetFolderTree(suitcase.folderID); | ||
140 | if (tree == null || (tree != null && tree.Count == 0)) | ||
141 | { | ||
142 | SetAsRootFolder(suitcase, root); | ||
143 | userInventory.Folders.Add(ConvertToOpenSim(suitcase)); | ||
144 | return userInventory; | ||
145 | } | ||
146 | |||
147 | List<InventoryItemBase> items; | ||
148 | foreach (XInventoryFolder f in tree) | ||
149 | { | ||
150 | // Add the items of this subfolder | ||
151 | items = GetFolderItems(userID, f.folderID); | ||
152 | if (items != null && items.Count > 0) | ||
153 | { | ||
154 | userInventory.Items.AddRange(items); | ||
155 | } | ||
156 | |||
157 | // Add the folder itself | ||
158 | userInventory.Folders.Add(ConvertToOpenSim(f)); | ||
159 | } | ||
160 | |||
161 | items = GetFolderItems(userID, suitcase.folderID); | ||
162 | if (items != null && items.Count > 0) | ||
163 | { | ||
164 | userInventory.Items.AddRange(items); | ||
165 | } | ||
166 | |||
167 | SetAsRootFolder(suitcase, root); | ||
168 | userInventory.Folders.Add(ConvertToOpenSim(suitcase)); | ||
169 | |||
170 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items", | ||
171 | userID, userInventory.Folders.Count, userInventory.Items.Count); | ||
172 | return userInventory; | ||
112 | } | 173 | } |
113 | 174 | ||
114 | public override InventoryFolderBase GetRootFolder(UUID principalID) | 175 | public override InventoryFolderBase GetRootFolder(UUID principalID) |
@@ -131,51 +192,92 @@ namespace OpenSim.Services.HypergridService | |||
131 | { | 192 | { |
132 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder. Creating it...", principalID); | 193 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder. Creating it...", principalID); |
133 | // make one, and let's add it to the user's inventory as a direct child of the root folder | 194 | // make one, and let's add it to the user's inventory as a direct child of the root folder |
195 | // In the DB we tag it as type 100, but we use -1 (Unknown) outside | ||
134 | suitcase = CreateFolder(principalID, root.folderID, 100, "My Suitcase"); | 196 | suitcase = CreateFolder(principalID, root.folderID, 100, "My Suitcase"); |
135 | if (suitcase == null) | 197 | if (suitcase == null) |
136 | m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder"); | 198 | m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder"); |
137 | |||
138 | m_Database.StoreFolder(suitcase); | 199 | m_Database.StoreFolder(suitcase); |
200 | |||
201 | // Create System folders | ||
202 | CreateSystemFolders(principalID, suitcase.folderID); | ||
139 | } | 203 | } |
140 | 204 | ||
141 | // Now let's change the folder ID to match that of the real root folder | 205 | SetAsRootFolder(suitcase, root); |
142 | SetAsRootFolder(suitcase, root.folderID); | ||
143 | 206 | ||
144 | return ConvertToOpenSim(suitcase); | 207 | return ConvertToOpenSim(suitcase); |
145 | } | 208 | } |
146 | 209 | ||
210 | protected void CreateSystemFolders(UUID principalID, UUID rootID) | ||
211 | { | ||
212 | m_log.Debug("[HG SUITCASE INVENTORY SERVICE]: Creating System folders under Suitcase..."); | ||
213 | XInventoryFolder[] sysFolders = GetSystemFolders(principalID, rootID); | ||
214 | |||
215 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Animation) return true; return false; })) | ||
216 | CreateFolder(principalID, rootID, (int)AssetType.Animation, "Animations"); | ||
217 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Bodypart) return true; return false; })) | ||
218 | CreateFolder(principalID, rootID, (int)AssetType.Bodypart, "Body Parts"); | ||
219 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.CallingCard) return true; return false; })) | ||
220 | CreateFolder(principalID, rootID, (int)AssetType.CallingCard, "Calling Cards"); | ||
221 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Clothing) return true; return false; })) | ||
222 | CreateFolder(principalID, rootID, (int)AssetType.Clothing, "Clothing"); | ||
223 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; })) | ||
224 | CreateFolder(principalID, rootID, (int)AssetType.Gesture, "Gestures"); | ||
225 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Landmark) return true; return false; })) | ||
226 | CreateFolder(principalID, rootID, (int)AssetType.Landmark, "Landmarks"); | ||
227 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.LostAndFoundFolder) return true; return false; })) | ||
228 | CreateFolder(principalID, rootID, (int)AssetType.LostAndFoundFolder, "Lost And Found"); | ||
229 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Notecard) return true; return false; })) | ||
230 | CreateFolder(principalID, rootID, (int)AssetType.Notecard, "Notecards"); | ||
231 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Object) return true; return false; })) | ||
232 | CreateFolder(principalID, rootID, (int)AssetType.Object, "Objects"); | ||
233 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.SnapshotFolder) return true; return false; })) | ||
234 | CreateFolder(principalID, rootID, (int)AssetType.SnapshotFolder, "Photo Album"); | ||
235 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.LSLText) return true; return false; })) | ||
236 | CreateFolder(principalID, rootID, (int)AssetType.LSLText, "Scripts"); | ||
237 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Sound) return true; return false; })) | ||
238 | CreateFolder(principalID, rootID, (int)AssetType.Sound, "Sounds"); | ||
239 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Texture) return true; return false; })) | ||
240 | CreateFolder(principalID, rootID, (int)AssetType.Texture, "Textures"); | ||
241 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.TrashFolder) return true; return false; })) | ||
242 | CreateFolder(principalID, rootID, (int)AssetType.TrashFolder, "Trash"); | ||
243 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.FavoriteFolder) return true; return false; })) | ||
244 | CreateFolder(principalID, rootID, (int)AssetType.FavoriteFolder, "Favorites"); | ||
245 | if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.CurrentOutfitFolder) return true; return false; })) | ||
246 | CreateFolder(principalID, rootID, (int)AssetType.CurrentOutfitFolder, "Current Outfit"); | ||
247 | |||
248 | } | ||
249 | |||
147 | public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) | 250 | public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) |
148 | { | 251 | { |
149 | //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type); | 252 | //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type); |
150 | return GetRootFolder(principalID); | 253 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); |
254 | XInventoryFolder[] folders = m_Database.GetFolders( | ||
255 | new string[] { "agentID", "type", "parentFolderID" }, | ||
256 | new string[] { principalID.ToString(), ((int)type).ToString(), suitcase.folderID.ToString() }); | ||
257 | |||
258 | if (folders.Length == 0) | ||
259 | { | ||
260 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no folder for type {0} for user {1}", type, principalID); | ||
261 | return null; | ||
262 | } | ||
263 | |||
264 | m_log.DebugFormat( | ||
265 | "[HG SUITCASE INVENTORY SERVICE]: Found folder {0} {1} for type {2} for user {3}", | ||
266 | folders[0].folderName, folders[0].folderID, type, principalID); | ||
267 | |||
268 | return ConvertToOpenSim(folders[0]); | ||
151 | } | 269 | } |
152 | 270 | ||
153 | public override InventoryCollection GetFolderContent(UUID principalID, UUID folderID) | 271 | public override InventoryCollection GetFolderContent(UUID principalID, UUID folderID) |
154 | { | 272 | { |
155 | InventoryCollection coll = null; | 273 | InventoryCollection coll = null; |
156 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); | 274 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); |
157 | XInventoryFolder root = GetRootXFolder(principalID); | ||
158 | 275 | ||
159 | if (!IsWithinSuitcaseTree(folderID, root, suitcase)) | 276 | if (!IsWithinSuitcaseTree(folderID, suitcase)) |
160 | return new InventoryCollection(); | 277 | return new InventoryCollection(); |
161 | 278 | ||
162 | if (folderID == root.folderID) // someone's asking for the root folder, we'll give them the suitcase | 279 | coll = base.GetFolderContent(principalID, folderID); |
163 | { | 280 | |
164 | if (suitcase != null) | ||
165 | { | ||
166 | coll = base.GetFolderContent(principalID, suitcase.folderID); | ||
167 | foreach (InventoryFolderBase f in coll.Folders) | ||
168 | f.ParentID = root.folderID; | ||
169 | foreach (InventoryItemBase i in coll.Items) | ||
170 | i.Folder = root.folderID; | ||
171 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent for root folder returned content for suitcase folder"); | ||
172 | } | ||
173 | } | ||
174 | else | ||
175 | { | ||
176 | coll = base.GetFolderContent(principalID, folderID); | ||
177 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent for non-root folder {0}", folderID); | ||
178 | } | ||
179 | if (coll == null) | 281 | if (coll == null) |
180 | { | 282 | { |
181 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Something wrong with user {0}'s suitcase folder", principalID); | 283 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Something wrong with user {0}'s suitcase folder", principalID); |
@@ -188,10 +290,9 @@ namespace OpenSim.Services.HypergridService | |||
188 | { | 290 | { |
189 | // Let's do a bit of sanity checking, more than the base service does | 291 | // Let's do a bit of sanity checking, more than the base service does |
190 | // make sure the given folder exists under the suitcase tree of this user | 292 | // make sure the given folder exists under the suitcase tree of this user |
191 | XInventoryFolder root = GetRootXFolder(principalID); | ||
192 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); | 293 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); |
193 | 294 | ||
194 | if (!IsWithinSuitcaseTree(folderID, root, suitcase)) | 295 | if (!IsWithinSuitcaseTree(folderID, suitcase)) |
195 | return new List<InventoryItemBase>(); | 296 | return new List<InventoryItemBase>(); |
196 | 297 | ||
197 | return base.GetFolderItems(principalID, folderID); | 298 | return base.GetFolderItems(principalID, folderID); |
@@ -199,52 +300,40 @@ namespace OpenSim.Services.HypergridService | |||
199 | 300 | ||
200 | public override bool AddFolder(InventoryFolderBase folder) | 301 | public override bool AddFolder(InventoryFolderBase folder) |
201 | { | 302 | { |
303 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID); | ||
202 | // Let's do a bit of sanity checking, more than the base service does | 304 | // Let's do a bit of sanity checking, more than the base service does |
203 | // make sure the given folder's parent folder exists under the suitcase tree of this user | 305 | // make sure the given folder's parent folder exists under the suitcase tree of this user |
204 | XInventoryFolder root = GetRootXFolder(folder.Owner); | ||
205 | XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner); | 306 | XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner); |
206 | 307 | ||
207 | if (!IsWithinSuitcaseTree(folder.ParentID, root, suitcase)) | 308 | if (!IsWithinSuitcaseTree(folder.ParentID, suitcase)) |
208 | return false; | 309 | return false; |
209 | 310 | ||
210 | // OK, it's legit | 311 | // OK, it's legit |
211 | // Check if it's under the Root folder directly | ||
212 | if (folder.ParentID == root.folderID) | ||
213 | { | ||
214 | // someone's trying to add a subfolder of the root folder, we'll add it to the suitcase instead | ||
215 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder for root folder for user {0}. Adding in suitcase instead", folder.Owner); | ||
216 | folder.ParentID = suitcase.folderID; | ||
217 | } | ||
218 | |||
219 | return base.AddFolder(folder); | 312 | return base.AddFolder(folder); |
220 | } | 313 | } |
221 | 314 | ||
222 | public bool UpdateFolder(InventoryFolderBase folder) | 315 | public override bool UpdateFolder(InventoryFolderBase folder) |
223 | { | 316 | { |
224 | XInventoryFolder root = GetRootXFolder(folder.Owner); | ||
225 | XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner); | 317 | XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner); |
226 | 318 | ||
227 | if (!IsWithinSuitcaseTree(folder.ID, root, suitcase)) | 319 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); |
320 | if (!IsWithinSuitcaseTree(folder.ID, suitcase)) | ||
321 | { | ||
322 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name); | ||
228 | return false; | 323 | return false; |
324 | } | ||
229 | 325 | ||
326 | // For all others | ||
230 | return base.UpdateFolder(folder); | 327 | return base.UpdateFolder(folder); |
231 | } | 328 | } |
232 | 329 | ||
233 | public override bool MoveFolder(InventoryFolderBase folder) | 330 | public override bool MoveFolder(InventoryFolderBase folder) |
234 | { | 331 | { |
235 | XInventoryFolder root = GetRootXFolder(folder.Owner); | ||
236 | XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner); | 332 | XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner); |
237 | 333 | ||
238 | if (!IsWithinSuitcaseTree(folder.ID, root, suitcase) || !IsWithinSuitcaseTree(folder.ParentID, root, suitcase)) | 334 | if (!IsWithinSuitcaseTree(folder.ID, suitcase) || !IsWithinSuitcaseTree(folder.ParentID, suitcase)) |
239 | return false; | 335 | return false; |
240 | 336 | ||
241 | if (folder.ParentID == root.folderID) | ||
242 | { | ||
243 | // someone's trying to add a subfolder of the root folder, we'll add it to the suitcase instead | ||
244 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder to root folder for user {0}. Moving it to suitcase instead", folder.Owner); | ||
245 | folder.ParentID = suitcase.folderID; | ||
246 | } | ||
247 | |||
248 | return base.MoveFolder(folder); | 337 | return base.MoveFolder(folder); |
249 | } | 338 | } |
250 | 339 | ||
@@ -264,31 +353,21 @@ namespace OpenSim.Services.HypergridService | |||
264 | { | 353 | { |
265 | // Let's do a bit of sanity checking, more than the base service does | 354 | // Let's do a bit of sanity checking, more than the base service does |
266 | // make sure the given folder's parent folder exists under the suitcase tree of this user | 355 | // make sure the given folder's parent folder exists under the suitcase tree of this user |
267 | XInventoryFolder root = GetRootXFolder(item.Owner); | ||
268 | XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner); | 356 | XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner); |
269 | 357 | ||
270 | if (!IsWithinSuitcaseTree(item.Folder, root, suitcase)) | 358 | if (!IsWithinSuitcaseTree(item.Folder, suitcase)) |
271 | return false; | 359 | return false; |
272 | 360 | ||
273 | // OK, it's legit | 361 | // OK, it's legit |
274 | // Check if it's under the Root folder directly | ||
275 | if (item.Folder == root.folderID) | ||
276 | { | ||
277 | // someone's trying to add a subfolder of the root folder, we'll add it to the suitcase instead | ||
278 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddItem for root folder for user {0}. Adding in suitcase instead", item.Owner); | ||
279 | item.Folder = suitcase.folderID; | ||
280 | } | ||
281 | |||
282 | return base.AddItem(item); | 362 | return base.AddItem(item); |
283 | 363 | ||
284 | } | 364 | } |
285 | 365 | ||
286 | public override bool UpdateItem(InventoryItemBase item) | 366 | public override bool UpdateItem(InventoryItemBase item) |
287 | { | 367 | { |
288 | XInventoryFolder root = GetRootXFolder(item.Owner); | ||
289 | XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner); | 368 | XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner); |
290 | 369 | ||
291 | if (!IsWithinSuitcaseTree(item.Folder, root, suitcase)) | 370 | if (!IsWithinSuitcaseTree(item.Folder, suitcase)) |
292 | return false; | 371 | return false; |
293 | 372 | ||
294 | return base.UpdateItem(item); | 373 | return base.UpdateItem(item); |
@@ -298,68 +377,64 @@ namespace OpenSim.Services.HypergridService | |||
298 | { | 377 | { |
299 | // Principal is b0rked. *sigh* | 378 | // Principal is b0rked. *sigh* |
300 | 379 | ||
301 | XInventoryFolder root = GetRootXFolder(items[0].Owner); | ||
302 | XInventoryFolder suitcase = GetSuitcaseXFolder(items[0].Owner); | 380 | XInventoryFolder suitcase = GetSuitcaseXFolder(items[0].Owner); |
303 | 381 | ||
304 | if (!IsWithinSuitcaseTree(items[0].Folder, root, suitcase)) | 382 | if (!IsWithinSuitcaseTree(items[0].Folder, suitcase)) |
305 | return false; | 383 | return false; |
306 | 384 | ||
307 | foreach (InventoryItemBase it in items) | ||
308 | if (it.Folder == root.folderID) | ||
309 | { | ||
310 | // someone's trying to add a subfolder of the root folder, we'll add it to the suitcase instead | ||
311 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItem to root folder for user {0}. Moving it to suitcase instead", it.Owner); | ||
312 | it.Folder = suitcase.folderID; | ||
313 | } | ||
314 | |||
315 | return base.MoveItems(principalID, items); | 385 | return base.MoveItems(principalID, items); |
316 | 386 | ||
317 | } | 387 | } |
318 | 388 | ||
319 | // Let these pass. Use inherited methods. | ||
320 | public override bool DeleteItems(UUID principalID, List<UUID> itemIDs) | 389 | public override bool DeleteItems(UUID principalID, List<UUID> itemIDs) |
321 | { | 390 | { |
322 | return false; | 391 | return false; |
323 | } | 392 | } |
324 | 393 | ||
325 | public override InventoryItemBase GetItem(InventoryItemBase item) | 394 | public new InventoryItemBase GetItem(InventoryItemBase item) |
326 | { | 395 | { |
327 | InventoryItemBase it = base.GetItem(item); | 396 | InventoryItemBase it = base.GetItem(item); |
328 | XInventoryFolder root = GetRootXFolder(it.Owner); | 397 | if (it == null) |
398 | { | ||
399 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve item {0} ({1}) in folder {2}", | ||
400 | item.Name, item.ID, item.Folder); | ||
401 | return null; | ||
402 | } | ||
329 | XInventoryFolder suitcase = GetSuitcaseXFolder(it.Owner); | 403 | XInventoryFolder suitcase = GetSuitcaseXFolder(it.Owner); |
330 | 404 | if (suitcase == null) | |
331 | if (it != null) | ||
332 | { | 405 | { |
333 | if (!IsWithinSuitcaseTree(it.Folder, root, suitcase)) | 406 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Root or Suitcase are null for user {0}", |
334 | return null; | 407 | it.Owner); |
408 | return null; | ||
409 | } | ||
335 | 410 | ||
336 | if (it.Folder == suitcase.folderID) | 411 | if (!IsWithinSuitcaseTree(it.Folder, suitcase)) |
337 | it.Folder = root.folderID; | 412 | { |
413 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", | ||
414 | it.Name, it.Folder); | ||
415 | return null; | ||
416 | } | ||
338 | 417 | ||
339 | // UserAccount user = m_Cache.GetUser(it.CreatorId); | 418 | // UserAccount user = m_Cache.GetUser(it.CreatorId); |
340 | 419 | ||
341 | // // Adjust the creator data | 420 | // // Adjust the creator data |
342 | // if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty)) | 421 | // if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty)) |
343 | // it.CreatorData = m_HomeURL + ";" + user.FirstName + " " + user.LastName; | 422 | // it.CreatorData = m_HomeURL + ";" + user.FirstName + " " + user.LastName; |
344 | //} | 423 | //} |
345 | } | ||
346 | 424 | ||
347 | return it; | 425 | return it; |
348 | } | 426 | } |
349 | 427 | ||
350 | public override InventoryFolderBase GetFolder(InventoryFolderBase folder) | 428 | public new InventoryFolderBase GetFolder(InventoryFolderBase folder) |
351 | { | 429 | { |
352 | InventoryFolderBase f = base.GetFolder(folder); | 430 | InventoryFolderBase f = base.GetFolder(folder); |
353 | XInventoryFolder root = GetRootXFolder(f.Owner); | ||
354 | XInventoryFolder suitcase = GetSuitcaseXFolder(f.Owner); | ||
355 | 431 | ||
356 | if (f != null) | 432 | if (f != null) |
357 | { | 433 | { |
358 | if (!IsWithinSuitcaseTree(f.ID, root, suitcase)) | 434 | XInventoryFolder suitcase = GetSuitcaseXFolder(f.Owner); |
359 | return null; | ||
360 | 435 | ||
361 | if (f.ParentID == suitcase.folderID) | 436 | if (!IsWithinSuitcaseTree(f.ID, suitcase)) |
362 | f.ParentID = root.folderID; | 437 | return null; |
363 | } | 438 | } |
364 | 439 | ||
365 | return f; | 440 | return f; |
@@ -409,20 +484,19 @@ namespace OpenSim.Services.HypergridService | |||
409 | return null; | 484 | return null; |
410 | } | 485 | } |
411 | 486 | ||
412 | private void SetAsRootFolder(XInventoryFolder suitcase, UUID rootID) | 487 | private void SetAsRootFolder(XInventoryFolder suitcase, XInventoryFolder root) |
413 | { | 488 | { |
414 | suitcase.folderID = rootID; | 489 | suitcase.type = (short)AssetType.Folder; |
415 | suitcase.parentFolderID = UUID.Zero; | ||
416 | } | 490 | } |
417 | 491 | ||
418 | private List<XInventoryFolder> GetFolderTree(UUID root) | 492 | private List<XInventoryFolder> GetFolderTree(UUID folder) |
419 | { | 493 | { |
420 | List<XInventoryFolder> t = null; | 494 | List<XInventoryFolder> t = null; |
421 | if (m_SuitcaseTrees.TryGetValue(root, out t)) | 495 | if (m_SuitcaseTrees.TryGetValue(folder, out t)) |
422 | return t; | 496 | return t; |
423 | 497 | ||
424 | t = GetFolderTreeRecursive(root); | 498 | t = GetFolderTreeRecursive(folder); |
425 | m_SuitcaseTrees.AddOrUpdate(root, t, 120); | 499 | m_SuitcaseTrees.AddOrUpdate(folder, t, 120); |
426 | return t; | 500 | return t; |
427 | } | 501 | } |
428 | 502 | ||
@@ -447,10 +521,17 @@ namespace OpenSim.Services.HypergridService | |||
447 | 521 | ||
448 | } | 522 | } |
449 | 523 | ||
450 | private bool IsWithinSuitcaseTree(UUID folderID, XInventoryFolder root, XInventoryFolder suitcase) | 524 | /// <summary> |
525 | /// Return true if the folderID is a subfolder of the Suitcase or the suitcase folder itself | ||
526 | /// </summary> | ||
527 | /// <param name="folderID"></param> | ||
528 | /// <param name="root"></param> | ||
529 | /// <param name="suitcase"></param> | ||
530 | /// <returns></returns> | ||
531 | private bool IsWithinSuitcaseTree(UUID folderID, XInventoryFolder suitcase) | ||
451 | { | 532 | { |
452 | List<XInventoryFolder> tree = new List<XInventoryFolder>(); | 533 | List<XInventoryFolder> tree = new List<XInventoryFolder>(); |
453 | tree.Add(root); // Warp! the tree is the real root folder plus the children of the suitcase folder | 534 | tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder |
454 | tree.AddRange(GetFolderTree(suitcase.folderID)); | 535 | tree.AddRange(GetFolderTree(suitcase.folderID)); |
455 | XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) | 536 | XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) |
456 | { | 537 | { |
@@ -463,4 +544,5 @@ namespace OpenSim.Services.HypergridService | |||
463 | } | 544 | } |
464 | #endregion | 545 | #endregion |
465 | } | 546 | } |
547 | |||
466 | } | 548 | } |
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 7b2c3a6..0e7a358 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs | |||
@@ -40,9 +40,9 @@ namespace OpenSim.Services.InventoryService | |||
40 | { | 40 | { |
41 | public class XInventoryService : ServiceBase, IInventoryService | 41 | public class XInventoryService : ServiceBase, IInventoryService |
42 | { | 42 | { |
43 | // private static readonly ILog m_log = | 43 | private static readonly ILog m_log = |
44 | // LogManager.GetLogger( | 44 | LogManager.GetLogger( |
45 | // MethodBase.GetCurrentMethod().DeclaringType); | 45 | MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | protected IXInventoryData m_Database; | 47 | protected IXInventoryData m_Database; |
48 | protected bool m_AllowDelete = true; | 48 | protected bool m_AllowDelete = true; |
@@ -113,7 +113,7 @@ namespace OpenSim.Services.InventoryService | |||
113 | result = true; | 113 | result = true; |
114 | } | 114 | } |
115 | 115 | ||
116 | XInventoryFolder[] sysFolders = GetSystemFolders(principalID); | 116 | XInventoryFolder[] sysFolders = GetSystemFolders(principalID, rootFolder.ID); |
117 | 117 | ||
118 | if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Animation) return true; return false; })) | 118 | if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Animation) return true; return false; })) |
119 | CreateFolder(principalID, rootFolder.ID, (int)AssetType.Animation, "Animations"); | 119 | CreateFolder(principalID, rootFolder.ID, (int)AssetType.Animation, "Animations"); |
@@ -163,13 +163,13 @@ namespace OpenSim.Services.InventoryService | |||
163 | return newFolder; | 163 | return newFolder; |
164 | } | 164 | } |
165 | 165 | ||
166 | protected virtual XInventoryFolder[] GetSystemFolders(UUID principalID) | 166 | protected virtual XInventoryFolder[] GetSystemFolders(UUID principalID, UUID rootID) |
167 | { | 167 | { |
168 | // m_log.DebugFormat("[XINVENTORY SERVICE]: Getting system folders for {0}", principalID); | 168 | // m_log.DebugFormat("[XINVENTORY SERVICE]: Getting system folders for {0}", principalID); |
169 | 169 | ||
170 | XInventoryFolder[] allFolders = m_Database.GetFolders( | 170 | XInventoryFolder[] allFolders = m_Database.GetFolders( |
171 | new string[] { "agentID" }, | 171 | new string[] { "agentID", "parentFolderID" }, |
172 | new string[] { principalID.ToString() }); | 172 | new string[] { principalID.ToString(), rootID.ToString() }); |
173 | 173 | ||
174 | XInventoryFolder[] sysFolders = Array.FindAll( | 174 | XInventoryFolder[] sysFolders = Array.FindAll( |
175 | allFolders, | 175 | allFolders, |
@@ -301,16 +301,26 @@ namespace OpenSim.Services.InventoryService | |||
301 | 301 | ||
302 | public virtual bool AddFolder(InventoryFolderBase folder) | 302 | public virtual bool AddFolder(InventoryFolderBase folder) |
303 | { | 303 | { |
304 | //m_log.DebugFormat("[XINVENTORY]: Add folder {0} type {1} in parent {2}", folder.Name, folder.Type, folder.ParentID); | ||
304 | InventoryFolderBase check = GetFolder(folder); | 305 | InventoryFolderBase check = GetFolder(folder); |
305 | if (check != null) | 306 | if (check != null) |
306 | return false; | 307 | return false; |
307 | 308 | ||
308 | XInventoryFolder xFolder = ConvertFromOpenSim(folder); | 309 | if (folder.Type == (short)AssetType.Folder || folder.Type == (short)AssetType.Unknown || |
309 | return m_Database.StoreFolder(xFolder); | 310 | GetFolderForType(folder.Owner, (AssetType)(folder.Type)) == null) |
311 | { | ||
312 | XInventoryFolder xFolder = ConvertFromOpenSim(folder); | ||
313 | return m_Database.StoreFolder(xFolder); | ||
314 | } | ||
315 | else | ||
316 | m_log.DebugFormat("[XINVENTORY]: Folder {0} of type {1} already exists", folder.Name, folder.Type); | ||
317 | |||
318 | return false; | ||
310 | } | 319 | } |
311 | 320 | ||
312 | public virtual bool UpdateFolder(InventoryFolderBase folder) | 321 | public virtual bool UpdateFolder(InventoryFolderBase folder) |
313 | { | 322 | { |
323 | //m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID); | ||
314 | XInventoryFolder xFolder = ConvertFromOpenSim(folder); | 324 | XInventoryFolder xFolder = ConvertFromOpenSim(folder); |
315 | InventoryFolderBase check = GetFolder(folder); | 325 | InventoryFolderBase check = GetFolder(folder); |
316 | if (check == null) | 326 | if (check == null) |
@@ -319,9 +329,13 @@ namespace OpenSim.Services.InventoryService | |||
319 | if (check.Type != -1 || xFolder.type != -1) | 329 | if (check.Type != -1 || xFolder.type != -1) |
320 | { | 330 | { |
321 | if (xFolder.version < check.Version) | 331 | if (xFolder.version < check.Version) |
332 | { | ||
333 | //m_log.DebugFormat("[XINVENTORY]: {0} < {1} can't do", xFolder.version, check.Version); | ||
322 | return false; | 334 | return false; |
335 | } | ||
323 | check.Version = (ushort)xFolder.version; | 336 | check.Version = (ushort)xFolder.version; |
324 | xFolder = ConvertFromOpenSim(check); | 337 | xFolder = ConvertFromOpenSim(check); |
338 | //m_log.DebugFormat("[XINVENTORY]: Storing {0} {1} {2}", xFolder.folderName, xFolder.version, xFolder.type); | ||
325 | return m_Database.StoreFolder(xFolder); | 339 | return m_Database.StoreFolder(xFolder); |
326 | } | 340 | } |
327 | 341 | ||
@@ -499,13 +513,30 @@ namespace OpenSim.Services.InventoryService | |||
499 | return m_Database.GetAssetPermissions(principalID, assetID); | 513 | return m_Database.GetAssetPermissions(principalID, assetID); |
500 | } | 514 | } |
501 | 515 | ||
502 | // CM never needed those. Left unimplemented. | 516 | public virtual InventoryCollection GetUserInventory(UUID userID) |
503 | // Obsolete in core | ||
504 | // | ||
505 | public InventoryCollection GetUserInventory(UUID userID) | ||
506 | { | 517 | { |
507 | return null; | 518 | InventoryCollection userInventory = new InventoryCollection(); |
519 | userInventory.UserID = userID; | ||
520 | userInventory.Folders = new List<InventoryFolderBase>(); | ||
521 | userInventory.Items = new List<InventoryItemBase>(); | ||
522 | |||
523 | List<InventoryFolderBase> skel = GetInventorySkeleton(userID); | ||
524 | if (skel != null) | ||
525 | { | ||
526 | foreach (InventoryFolderBase f in skel) | ||
527 | { | ||
528 | InventoryCollection c = GetFolderContent(userID, f.ID); | ||
529 | if (c != null && c.Items != null && c.Items.Count > 0) | ||
530 | userInventory.Items.AddRange(c.Items); | ||
531 | if (c != null && c.Folders != null && c.Folders.Count > 0) | ||
532 | userInventory.Folders.AddRange(c.Folders); | ||
533 | } | ||
534 | } | ||
535 | m_log.DebugFormat("[XINVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items", | ||
536 | userID, userInventory.Folders.Count, userInventory.Items.Count); | ||
537 | return userInventory; | ||
508 | } | 538 | } |
539 | |||
509 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) | 540 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) |
510 | { | 541 | { |
511 | } | 542 | } |
@@ -525,6 +556,9 @@ namespace OpenSim.Services.InventoryService | |||
525 | 556 | ||
526 | newFolder.ParentID = folder.parentFolderID; | 557 | newFolder.ParentID = folder.parentFolderID; |
527 | newFolder.Type = (short)folder.type; | 558 | newFolder.Type = (short)folder.type; |
559 | // Viewer can't understand anything that's not in it's LLFolderType enum | ||
560 | if (newFolder.Type == 100) | ||
561 | newFolder.Type = -1; | ||
528 | newFolder.Version = (ushort)folder.version; | 562 | newFolder.Version = (ushort)folder.version; |
529 | newFolder.Name = folder.folderName; | 563 | newFolder.Name = folder.folderName; |
530 | newFolder.Owner = folder.agentID; | 564 | newFolder.Owner = folder.agentID; |