diff options
Merge branch 'master' into careminster-presence-refactor
15 files changed, 320 insertions, 107 deletions
diff --git a/OpenSim/Data/Tests/EstateTests.cs b/OpenSim/Data/Tests/EstateTests.cs index d6eed3d..fbf8ba6 100644 --- a/OpenSim/Data/Tests/EstateTests.cs +++ b/OpenSim/Data/Tests/EstateTests.cs | |||
@@ -37,11 +37,6 @@ using log4net; | |||
37 | using System.Reflection; | 37 | using System.Reflection; |
38 | using System.Data.Common; | 38 | using System.Data.Common; |
39 | 39 | ||
40 | #if !NUNIT25 | ||
41 | using NUnit.Framework.SyntaxHelpers; | ||
42 | #endif | ||
43 | |||
44 | |||
45 | // DBMS-specific: | 40 | // DBMS-specific: |
46 | using MySql.Data.MySqlClient; | 41 | using MySql.Data.MySqlClient; |
47 | using OpenSim.Data.MySQL; | 42 | using OpenSim.Data.MySQL; |
@@ -52,7 +47,6 @@ using OpenSim.Data.MSSQL; | |||
52 | using Mono.Data.Sqlite; | 47 | using Mono.Data.Sqlite; |
53 | using OpenSim.Data.SQLite; | 48 | using OpenSim.Data.SQLite; |
54 | 49 | ||
55 | |||
56 | namespace OpenSim.Data.Tests | 50 | namespace OpenSim.Data.Tests |
57 | { | 51 | { |
58 | 52 | ||
diff --git a/OpenSim/Data/Tests/InventoryTests.cs b/OpenSim/Data/Tests/InventoryTests.cs index c22e26c..3205bfa 100644 --- a/OpenSim/Data/Tests/InventoryTests.cs +++ b/OpenSim/Data/Tests/InventoryTests.cs | |||
@@ -37,10 +37,6 @@ using log4net; | |||
37 | using System.Reflection; | 37 | using System.Reflection; |
38 | using System.Data.Common; | 38 | using System.Data.Common; |
39 | 39 | ||
40 | #if !NUNIT25 | ||
41 | using NUnit.Framework.SyntaxHelpers; | ||
42 | #endif | ||
43 | |||
44 | // DBMS-specific: | 40 | // DBMS-specific: |
45 | using MySql.Data.MySqlClient; | 41 | using MySql.Data.MySqlClient; |
46 | using OpenSim.Data.MySQL; | 42 | using OpenSim.Data.MySQL; |
diff --git a/OpenSim/Data/Tests/RegionTests.cs b/OpenSim/Data/Tests/RegionTests.cs index 3cd9e0b..29bf5a3 100644 --- a/OpenSim/Data/Tests/RegionTests.cs +++ b/OpenSim/Data/Tests/RegionTests.cs | |||
@@ -40,10 +40,6 @@ using log4net; | |||
40 | using System.Reflection; | 40 | using System.Reflection; |
41 | using System.Data.Common; | 41 | using System.Data.Common; |
42 | 42 | ||
43 | #if !NUNIT25 | ||
44 | using NUnit.Framework.SyntaxHelpers; | ||
45 | #endif | ||
46 | |||
47 | // DBMS-specific: | 43 | // DBMS-specific: |
48 | using MySql.Data.MySqlClient; | 44 | using MySql.Data.MySqlClient; |
49 | using OpenSim.Data.MySQL; | 45 | using OpenSim.Data.MySQL; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 350ad66..915b59e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | |||
@@ -218,24 +218,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
218 | 218 | ||
219 | public bool AddItem(InventoryItemBase item) | 219 | public bool AddItem(InventoryItemBase item) |
220 | { | 220 | { |
221 | m_log.DebugFormat( | 221 | // m_log.DebugFormat( |
222 | "[LOCAL INVENTORY SERVICES CONNECTOR]: Adding inventory item {0} to user {1} folder {2}", | 222 | // "[LOCAL INVENTORY SERVICES CONNECTOR]: Adding inventory item {0} to user {1} folder {2}", |
223 | item.Name, item.Owner, item.Folder); | 223 | // item.Name, item.Owner, item.Folder); |
224 | 224 | ||
225 | if (UUID.Zero == item.Folder) | 225 | if (UUID.Zero == item.Folder) |
226 | { | 226 | { |
227 | InventoryFolderBase f = m_InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); | 227 | InventoryFolderBase f = m_InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); |
228 | if (f != null) | 228 | if (f != null) |
229 | { | 229 | { |
230 | // m_log.DebugFormat( | ||
231 | // "[LOCAL INVENTORY SERVICES CONNECTOR]: Found folder {0} type {1} for item {2}", | ||
232 | // f.Name, (AssetType)f.Type, item.Name); | ||
233 | |||
230 | item.Folder = f.ID; | 234 | item.Folder = f.ID; |
231 | } | 235 | } |
232 | else | 236 | else |
233 | { | 237 | { |
234 | f = m_InventoryService.GetRootFolder(item.Owner); | 238 | f = m_InventoryService.GetRootFolder(item.Owner); |
235 | if (f != null) | 239 | if (f != null) |
240 | { | ||
236 | item.Folder = f.ID; | 241 | item.Folder = f.ID; |
242 | } | ||
237 | else | 243 | else |
244 | { | ||
245 | // m_log.WarnFormat( | ||
246 | // "[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified", | ||
247 | // item.Owner, item.Name); | ||
238 | return false; | 248 | return false; |
249 | } | ||
239 | } | 250 | } |
240 | } | 251 | } |
241 | 252 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs index 7ac3bb9..4211fa9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs | |||
@@ -240,9 +240,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
240 | { | 240 | { |
241 | f = m_RemoteConnector.GetRootFolder(item.Owner); | 241 | f = m_RemoteConnector.GetRootFolder(item.Owner); |
242 | if (f != null) | 242 | if (f != null) |
243 | { | ||
243 | item.Folder = f.ID; | 244 | item.Folder = f.ID; |
245 | } | ||
244 | else | 246 | else |
247 | { | ||
248 | m_log.WarnFormat( | ||
249 | "[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified", | ||
250 | item.Owner, item.Name); | ||
245 | return false; | 251 | return false; |
252 | } | ||
246 | } | 253 | } |
247 | } | 254 | } |
248 | 255 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 0384224..012732b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -122,7 +122,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
122 | else | 122 | else |
123 | { | 123 | { |
124 | m_log.WarnFormat( | 124 | m_log.WarnFormat( |
125 | "[AGENT INVENTORY]: Agent {1} could not add item {2} {3}", | 125 | "[AGENT INVENTORY]: Agent {0} could not add item {1} {2}", |
126 | AgentID, item.Name, item.ID); | 126 | AgentID, item.Name, item.ID); |
127 | 127 | ||
128 | return; | 128 | return; |
@@ -2004,7 +2004,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2004 | remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | 2004 | remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, |
2005 | RezSelected, RemoveItem, fromTaskID, false); | 2005 | RezSelected, RemoveItem, fromTaskID, false); |
2006 | } | 2006 | } |
2007 | 2007 | ||
2008 | /// <summary> | 2008 | /// <summary> |
2009 | /// Rez an object into the scene from a prim's inventory. | 2009 | /// Rez an object into the scene from a prim's inventory. |
2010 | /// </summary> | 2010 | /// </summary> |
@@ -2019,95 +2019,79 @@ namespace OpenSim.Region.Framework.Scenes | |||
2019 | SceneObjectPart sourcePart, TaskInventoryItem item, | 2019 | SceneObjectPart sourcePart, TaskInventoryItem item, |
2020 | Vector3 pos, Quaternion rot, Vector3 vel, int param) | 2020 | Vector3 pos, Quaternion rot, Vector3 vel, int param) |
2021 | { | 2021 | { |
2022 | // Rez object | 2022 | if (null == item) |
2023 | if (item != null) | 2023 | return null; |
2024 | { | 2024 | |
2025 | UUID ownerID = item.OwnerID; | 2025 | UUID ownerID = item.OwnerID; |
2026 | 2026 | AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); | |
2027 | AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); | ||
2028 | |||
2029 | if (rezAsset != null) | ||
2030 | { | ||
2031 | string xmlData = Utils.BytesToString(rezAsset.Data); | ||
2032 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
2033 | 2027 | ||
2034 | if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos)) | 2028 | if (null == rezAsset) |
2035 | { | 2029 | return null; |
2036 | return null; | ||
2037 | } | ||
2038 | group.ResetIDs(); | ||
2039 | 2030 | ||
2040 | AddNewSceneObject(group, true); | 2031 | string xmlData = Utils.BytesToString(rezAsset.Data); |
2032 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
2041 | 2033 | ||
2042 | // we set it's position in world. | 2034 | if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos)) |
2043 | group.AbsolutePosition = pos; | 2035 | return null; |
2044 | 2036 | ||
2045 | SceneObjectPart rootPart = group.GetChildPart(group.UUID); | 2037 | group.ResetIDs(); |
2046 | 2038 | ||
2047 | // Since renaming the item in the inventory does not affect the name stored | 2039 | SceneObjectPart rootPart = group.GetChildPart(group.UUID); |
2048 | // in the serialization, transfer the correct name from the inventory to the | ||
2049 | // object itself before we rez. | ||
2050 | rootPart.Name = item.Name; | ||
2051 | rootPart.Description = item.Description; | ||
2052 | 2040 | ||
2053 | List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values); | 2041 | // Since renaming the item in the inventory does not affect the name stored |
2042 | // in the serialization, transfer the correct name from the inventory to the | ||
2043 | // object itself before we rez. | ||
2044 | rootPart.Name = item.Name; | ||
2045 | rootPart.Description = item.Description; | ||
2054 | 2046 | ||
2055 | group.SetGroup(sourcePart.GroupID, null); | 2047 | List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values); |
2056 | 2048 | ||
2057 | if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) | 2049 | group.SetGroup(sourcePart.GroupID, null); |
2058 | { | ||
2059 | if (Permissions.PropagatePermissions()) | ||
2060 | { | ||
2061 | foreach (SceneObjectPart part in partList) | ||
2062 | { | ||
2063 | part.EveryoneMask = item.EveryonePermissions; | ||
2064 | part.NextOwnerMask = item.NextPermissions; | ||
2065 | } | ||
2066 | group.ApplyNextOwnerPermissions(); | ||
2067 | } | ||
2068 | } | ||
2069 | 2050 | ||
2051 | if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) | ||
2052 | { | ||
2053 | if (Permissions.PropagatePermissions()) | ||
2054 | { | ||
2070 | foreach (SceneObjectPart part in partList) | 2055 | foreach (SceneObjectPart part in partList) |
2071 | { | 2056 | { |
2072 | if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) | ||
2073 | { | ||
2074 | part.LastOwnerID = part.OwnerID; | ||
2075 | part.OwnerID = item.OwnerID; | ||
2076 | part.Inventory.ChangeInventoryOwner(item.OwnerID); | ||
2077 | } | ||
2078 | part.EveryoneMask = item.EveryonePermissions; | 2057 | part.EveryoneMask = item.EveryonePermissions; |
2079 | part.NextOwnerMask = item.NextPermissions; | 2058 | part.NextOwnerMask = item.NextPermissions; |
2080 | } | 2059 | } |
2081 | 2060 | ||
2082 | rootPart.TrimPermissions(); | 2061 | group.ApplyNextOwnerPermissions(); |
2083 | 2062 | } | |
2084 | if (group.RootPart.Shape.PCode == (byte)PCode.Prim) | 2063 | } |
2085 | { | ||
2086 | group.ClearPartAttachmentData(); | ||
2087 | } | ||
2088 | |||
2089 | group.UpdateGroupRotationR(rot); | ||
2090 | |||
2091 | //group.ApplyPhysics(m_physicalPrim); | ||
2092 | if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) | ||
2093 | { | ||
2094 | group.RootPart.ApplyImpulse((vel * group.GetMass()), false); | ||
2095 | group.Velocity = vel; | ||
2096 | rootPart.ScheduleFullUpdate(); | ||
2097 | } | ||
2098 | group.CreateScriptInstances(param, true, DefaultScriptEngine, 2); | ||
2099 | rootPart.ScheduleFullUpdate(); | ||
2100 | 2064 | ||
2101 | if (!Permissions.BypassPermissions()) | 2065 | foreach (SceneObjectPart part in partList) |
2102 | { | 2066 | { |
2103 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | 2067 | if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) |
2104 | sourcePart.Inventory.RemoveInventoryItem(item.ItemID); | 2068 | { |
2105 | } | 2069 | part.LastOwnerID = part.OwnerID; |
2106 | return rootPart.ParentGroup; | 2070 | part.OwnerID = item.OwnerID; |
2071 | part.Inventory.ChangeInventoryOwner(item.OwnerID); | ||
2107 | } | 2072 | } |
2073 | |||
2074 | part.EveryoneMask = item.EveryonePermissions; | ||
2075 | part.NextOwnerMask = item.NextPermissions; | ||
2108 | } | 2076 | } |
2077 | |||
2078 | rootPart.TrimPermissions(); | ||
2109 | 2079 | ||
2110 | return null; | 2080 | if (!Permissions.BypassPermissions()) |
2081 | { | ||
2082 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
2083 | sourcePart.Inventory.RemoveInventoryItem(item.ItemID); | ||
2084 | } | ||
2085 | |||
2086 | AddNewSceneObject(group, true, pos, rot, vel); | ||
2087 | |||
2088 | // We can only call this after adding the scene object, since the scene object references the scene | ||
2089 | // to find out if scripts should be activated at all. | ||
2090 | group.CreateScriptInstances(param, true, DefaultScriptEngine, 2); | ||
2091 | |||
2092 | group.ScheduleGroupForFullUpdate(); | ||
2093 | |||
2094 | return rootPart.ParentGroup; | ||
2111 | } | 2095 | } |
2112 | 2096 | ||
2113 | public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId) | 2097 | public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index eb5c3cb..520f1a1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -42,7 +42,6 @@ using OpenMetaverse.Imaging; | |||
42 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
43 | using OpenSim.Services.Interfaces; | 43 | using OpenSim.Services.Interfaces; |
44 | using OpenSim.Framework.Communications; | 44 | using OpenSim.Framework.Communications; |
45 | |||
46 | using OpenSim.Framework.Console; | 45 | using OpenSim.Framework.Console; |
47 | using OpenSim.Region.Framework.Interfaces; | 46 | using OpenSim.Region.Framework.Interfaces; |
48 | using OpenSim.Region.Framework.Scenes.Scripting; | 47 | using OpenSim.Region.Framework.Scenes.Scripting; |
@@ -2051,7 +2050,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2051 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) | 2050 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) |
2052 | { | 2051 | { |
2053 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); | 2052 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); |
2054 | } | 2053 | } |
2054 | |||
2055 | /// <summary> | ||
2056 | /// Add a newly created object to the scene. | ||
2057 | /// </summary> | ||
2058 | /// | ||
2059 | /// This method does not send updates to the client - callers need to handle this themselves. | ||
2060 | /// <param name="sceneObject"></param> | ||
2061 | /// <param name="attachToBackup"></param> | ||
2062 | /// <param name="pos">Position of the object</param> | ||
2063 | /// <param name="rot">Rotation of the object</param> | ||
2064 | /// <param name="vel">Velocity of the object. This parameter only has an effect if the object is physical</param> | ||
2065 | /// <returns></returns> | ||
2066 | public bool AddNewSceneObject( | ||
2067 | SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) | ||
2068 | { | ||
2069 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel); | ||
2070 | } | ||
2055 | 2071 | ||
2056 | /// <summary> | 2072 | /// <summary> |
2057 | /// Delete every object from the scene. This does not include attachments worn by avatars. | 2073 | /// Delete every object from the scene. This does not include attachments worn by avatars. |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 1268259..3a0532a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -312,6 +312,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
312 | 312 | ||
313 | return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); | 313 | return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); |
314 | } | 314 | } |
315 | |||
316 | /// <summary> | ||
317 | /// Add a newly created object to the scene. | ||
318 | /// </summary> | ||
319 | /// | ||
320 | /// This method does not send updates to the client - callers need to handle this themselves. | ||
321 | /// <param name="sceneObject"></param> | ||
322 | /// <param name="attachToBackup"></param> | ||
323 | /// <param name="pos">Position of the object</param> | ||
324 | /// <param name="rot">Rotation of the object</param> | ||
325 | /// <param name="vel">Velocity of the object. This parameter only has an effect if the object is physical</param> | ||
326 | /// <returns></returns> | ||
327 | public bool AddNewSceneObject( | ||
328 | SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) | ||
329 | { | ||
330 | AddNewSceneObject(sceneObject, true, false); | ||
331 | |||
332 | // we set it's position in world. | ||
333 | sceneObject.AbsolutePosition = pos; | ||
334 | |||
335 | if (sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) | ||
336 | { | ||
337 | sceneObject.ClearPartAttachmentData(); | ||
338 | } | ||
339 | |||
340 | sceneObject.UpdateGroupRotationR(rot); | ||
341 | |||
342 | //group.ApplyPhysics(m_physicalPrim); | ||
343 | if (sceneObject.RootPart.PhysActor != null && sceneObject.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) | ||
344 | { | ||
345 | sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); | ||
346 | sceneObject.Velocity = vel; | ||
347 | } | ||
348 | |||
349 | return true; | ||
350 | } | ||
315 | 351 | ||
316 | /// <summary> | 352 | /// <summary> |
317 | /// Add an object to the scene. This will both update the scene, and send information about the | 353 | /// Add an object to the scene. This will both update the scene, and send information about the |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs index fc66c85..3e2a2af 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs | |||
@@ -134,7 +134,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
134 | sop.Text = RandomName(); | 134 | sop.Text = RandomName(); |
135 | sop.SitName = RandomName(); | 135 | sop.SitName = RandomName(); |
136 | sop.TouchName = RandomName(); | 136 | sop.TouchName = RandomName(); |
137 | sop.ObjectFlags |= (uint)PrimFlags.Phantom; | 137 | sop.Flags |= PrimFlags.Phantom; |
138 | 138 | ||
139 | SceneObjectGroup sog = new SceneObjectGroup(sop); | 139 | SceneObjectGroup sog = new SceneObjectGroup(sop); |
140 | scene.AddNewSceneObject(sog, false); | 140 | scene.AddNewSceneObject(sog, false); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs new file mode 100644 index 0000000..da8199d --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | |||
@@ -0,0 +1,143 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Threading; | ||
33 | using System.Timers; | ||
34 | using Timer=System.Timers.Timer; | ||
35 | using Nini.Config; | ||
36 | using NUnit.Framework; | ||
37 | using NUnit.Framework.SyntaxHelpers; | ||
38 | using OpenMetaverse; | ||
39 | using OpenMetaverse.Assets; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.Communications; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; | ||
45 | using OpenSim.Region.CoreModules.World.Serialiser; | ||
46 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
47 | using OpenSim.Services.Interfaces; | ||
48 | using OpenSim.Tests.Common; | ||
49 | using OpenSim.Tests.Common.Mock; | ||
50 | using OpenSim.Tests.Common.Setup; | ||
51 | |||
52 | namespace OpenSim.Region.Framework.Tests | ||
53 | { | ||
54 | [TestFixture] | ||
55 | public class TaskInventoryTests | ||
56 | { | ||
57 | protected UserAccount CreateUser(Scene scene) | ||
58 | { | ||
59 | string userFirstName = "Jock"; | ||
60 | string userLastName = "Stirrup"; | ||
61 | string userPassword = "troll"; | ||
62 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
63 | return UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); | ||
64 | } | ||
65 | |||
66 | protected SceneObjectGroup CreateSO1(Scene scene, UUID ownerId) | ||
67 | { | ||
68 | string part1Name = "part1"; | ||
69 | UUID part1Id = UUID.Parse("10000000-0000-0000-0000-000000000000"); | ||
70 | SceneObjectPart part1 | ||
71 | = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) | ||
72 | { Name = part1Name, UUID = part1Id }; | ||
73 | return new SceneObjectGroup(part1); | ||
74 | } | ||
75 | |||
76 | protected TaskInventoryItem CreateSOItem1(Scene scene, SceneObjectPart part) | ||
77 | { | ||
78 | AssetNotecard nc = new AssetNotecard("Hello World!"); | ||
79 | UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); | ||
80 | UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); | ||
81 | AssetBase ncAsset | ||
82 | = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); | ||
83 | scene.AssetService.Store(ncAsset); | ||
84 | TaskInventoryItem ncItem | ||
85 | = new TaskInventoryItem | ||
86 | { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid, | ||
87 | Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; | ||
88 | part.Inventory.AddInventoryItem(ncItem, true); | ||
89 | |||
90 | return ncItem; | ||
91 | } | ||
92 | |||
93 | /// <summary> | ||
94 | /// Test MoveTaskInventoryItem where the item has no parent folder assigned. | ||
95 | /// </summary> | ||
96 | /// This should place it in the most suitable user folder. | ||
97 | [Test] | ||
98 | public void TestMoveTaskInventoryItem() | ||
99 | { | ||
100 | TestHelper.InMethod(); | ||
101 | // log4net.Config.XmlConfigurator.Configure(); | ||
102 | |||
103 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
104 | UserAccount user1 = CreateUser(scene); | ||
105 | SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); | ||
106 | SceneObjectPart sop1 = sog1.RootPart; | ||
107 | TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1); | ||
108 | InventoryFolderBase folder | ||
109 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; | ||
110 | |||
111 | // Perform test | ||
112 | scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID); | ||
113 | |||
114 | InventoryItemBase ncUserItem | ||
115 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Objects/ncItem"); | ||
116 | Assert.That(ncUserItem, Is.Not.Null, "Objects/ncItem was not found"); | ||
117 | } | ||
118 | |||
119 | /// <summary> | ||
120 | /// Test MoveTaskInventoryItem where the item has no parent folder assigned. | ||
121 | /// </summary> | ||
122 | /// This should place it in the most suitable user folder. | ||
123 | [Test] | ||
124 | public void TestMoveTaskInventoryItemNoParent() | ||
125 | { | ||
126 | TestHelper.InMethod(); | ||
127 | // log4net.Config.XmlConfigurator.Configure(); | ||
128 | |||
129 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
130 | UserAccount user1 = CreateUser(scene); | ||
131 | SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); | ||
132 | SceneObjectPart sop1 = sog1.RootPart; | ||
133 | TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1); | ||
134 | |||
135 | // Perform test | ||
136 | scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); | ||
137 | |||
138 | InventoryItemBase ncUserItem | ||
139 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Notecards/ncItem"); | ||
140 | Assert.That(ncUserItem, Is.Not.Null, "Notecards/ncItem was not found"); | ||
141 | } | ||
142 | } | ||
143 | } \ No newline at end of file | ||
diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs index fbcd663..86bca79 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs | |||
@@ -268,15 +268,22 @@ namespace OpenSim.Services.InventoryService | |||
268 | 268 | ||
269 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | 269 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) |
270 | { | 270 | { |
271 | // m_log.DebugFormat("[INVENTORY SERVICE]: Looking for folder type {0} for user {1}", type, userID); | ||
272 | |||
271 | InventoryFolderBase root = m_Database.getUserRootFolder(userID); | 273 | InventoryFolderBase root = m_Database.getUserRootFolder(userID); |
272 | if (root != null) | 274 | if (root != null) |
273 | { | 275 | { |
274 | List<InventoryFolderBase> folders = RequestSubFolders(root.ID); | 276 | List<InventoryFolderBase> folders = RequestSubFolders(root.ID); |
275 | 277 | ||
276 | foreach (InventoryFolderBase folder in folders) | 278 | foreach (InventoryFolderBase folder in folders) |
277 | { | 279 | { |
278 | if (folder.Type == (short)type) | 280 | if (folder.Type == (short)type) |
281 | { | ||
282 | // m_log.DebugFormat( | ||
283 | // "[INVENTORY SERVICE]: Found folder {0} type {1}", folder.Name, (AssetType)folder.Type); | ||
284 | |||
279 | return folder; | 285 | return folder; |
286 | } | ||
280 | } | 287 | } |
281 | } | 288 | } |
282 | 289 | ||
diff --git a/OpenSim/Tests/Common/Mock/MockInventoryService.cs b/OpenSim/Tests/Common/Mock/MockInventoryService.cs index 1ea4bc1..4ac1078 100644 --- a/OpenSim/Tests/Common/Mock/MockInventoryService.cs +++ b/OpenSim/Tests/Common/Mock/MockInventoryService.cs | |||
@@ -37,13 +37,9 @@ namespace OpenSim.Tests.Common.Mock | |||
37 | { | 37 | { |
38 | public class MockInventoryService : IInventoryService | 38 | public class MockInventoryService : IInventoryService |
39 | { | 39 | { |
40 | public MockInventoryService() | 40 | public MockInventoryService() {} |
41 | { | ||
42 | } | ||
43 | 41 | ||
44 | public MockInventoryService(IConfigSource config) | 42 | public MockInventoryService(IConfigSource config) {} |
45 | { | ||
46 | } | ||
47 | 43 | ||
48 | /// <summary> | 44 | /// <summary> |
49 | /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/> | 45 | /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/> |
@@ -140,7 +136,7 @@ namespace OpenSim.Tests.Common.Mock | |||
140 | 136 | ||
141 | public bool AddItem(InventoryItemBase item) | 137 | public bool AddItem(InventoryItemBase item) |
142 | { | 138 | { |
143 | return false; | 139 | return true; |
144 | } | 140 | } |
145 | 141 | ||
146 | public bool UpdateItem(InventoryItemBase item) | 142 | public bool UpdateItem(InventoryItemBase item) |
@@ -187,4 +183,4 @@ namespace OpenSim.Tests.Common.Mock | |||
187 | return 1; | 183 | return 1; |
188 | } | 184 | } |
189 | } | 185 | } |
190 | } | 186 | } \ No newline at end of file |
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs index 7c4f689..ed0b1a6 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Tests.Common.Mock | |||
42 | /// </summary> | 42 | /// </summary> |
43 | public class TestInventoryDataPlugin : IInventoryDataPlugin | 43 | public class TestInventoryDataPlugin : IInventoryDataPlugin |
44 | { | 44 | { |
45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | /// <value> | 47 | /// <value> |
48 | /// Inventory folders | 48 | /// Inventory folders |
@@ -84,14 +84,19 @@ namespace OpenSim.Tests.Common.Mock | |||
84 | 84 | ||
85 | public List<InventoryItemBase> getInventoryInFolder(UUID folderID) | 85 | public List<InventoryItemBase> getInventoryInFolder(UUID folderID) |
86 | { | 86 | { |
87 | // m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0}", folderID); | 87 | InventoryFolderBase folder = m_folders[folderID]; |
88 | |||
89 | m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0} {1}", folder.Name, folder.ID); | ||
88 | 90 | ||
89 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | 91 | List<InventoryItemBase> items = new List<InventoryItemBase>(); |
90 | 92 | ||
91 | foreach (InventoryItemBase item in m_items.Values) | 93 | foreach (InventoryItemBase item in m_items.Values) |
92 | { | 94 | { |
93 | if (item.Folder == folderID) | 95 | if (item.Folder == folderID) |
96 | { | ||
97 | m_log.DebugFormat("[MOCK INV DB]: getInventoryInFolder() adding item {0}", item.Name); | ||
94 | items.Add(item); | 98 | items.Add(item); |
99 | } | ||
95 | } | 100 | } |
96 | 101 | ||
97 | return items; | 102 | return items; |
@@ -101,7 +106,7 @@ namespace OpenSim.Tests.Common.Mock | |||
101 | 106 | ||
102 | public InventoryFolderBase getUserRootFolder(UUID user) | 107 | public InventoryFolderBase getUserRootFolder(UUID user) |
103 | { | 108 | { |
104 | // m_log.DebugFormat("[MOCK INV DB]: Looking for root folder for {0}", user); | 109 | m_log.DebugFormat("[MOCK INV DB]: Looking for root folder for {0}", user); |
105 | 110 | ||
106 | InventoryFolderBase folder = null; | 111 | InventoryFolderBase folder = null; |
107 | m_rootFolders.TryGetValue(user, out folder); | 112 | m_rootFolders.TryGetValue(user, out folder); |
@@ -111,12 +116,22 @@ namespace OpenSim.Tests.Common.Mock | |||
111 | 116 | ||
112 | public List<InventoryFolderBase> getInventoryFolders(UUID parentID) | 117 | public List<InventoryFolderBase> getInventoryFolders(UUID parentID) |
113 | { | 118 | { |
119 | InventoryFolderBase parentFolder = m_folders[parentID]; | ||
120 | |||
121 | m_log.DebugFormat("[MOCK INV DB]: Getting folders in folder {0} {1}", parentFolder.Name, parentFolder.ID); | ||
122 | |||
114 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | 123 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); |
115 | 124 | ||
116 | foreach (InventoryFolderBase folder in m_folders.Values) | 125 | foreach (InventoryFolderBase folder in m_folders.Values) |
117 | { | 126 | { |
118 | if (folder.ParentID == parentID) | 127 | if (folder.ParentID == parentID) |
128 | { | ||
129 | m_log.DebugFormat( | ||
130 | "[MOCK INV DB]: Found folder {0} {1} in {2} {3}", | ||
131 | folder.Name, folder.ID, parentFolder.Name, parentFolder.ID); | ||
132 | |||
119 | folders.Add(folder); | 133 | folders.Add(folder); |
134 | } | ||
120 | } | 135 | } |
121 | 136 | ||
122 | return folders; | 137 | return folders; |
@@ -137,6 +152,10 @@ namespace OpenSim.Tests.Common.Mock | |||
137 | 152 | ||
138 | public void addInventoryFolder(InventoryFolderBase folder) | 153 | public void addInventoryFolder(InventoryFolderBase folder) |
139 | { | 154 | { |
155 | m_log.DebugFormat( | ||
156 | "[MOCK INV DB]: Adding inventory folder {0} {1} type {2}", | ||
157 | folder.Name, folder.ID, (AssetType)folder.Type); | ||
158 | |||
140 | m_folders[folder.ID] = folder; | 159 | m_folders[folder.ID] = folder; |
141 | 160 | ||
142 | if (folder.ParentID == UUID.Zero) | 161 | if (folder.ParentID == UUID.Zero) |
@@ -166,8 +185,10 @@ namespace OpenSim.Tests.Common.Mock | |||
166 | 185 | ||
167 | public void addInventoryItem(InventoryItemBase item) | 186 | public void addInventoryItem(InventoryItemBase item) |
168 | { | 187 | { |
169 | // m_log.DebugFormat( | 188 | InventoryFolderBase folder = m_folders[item.Folder]; |
170 | // "[MOCK INV DB]: Adding inventory item {0} {1} in {2}", item.Name, item.ID, item.Folder); | 189 | |
190 | m_log.DebugFormat( | ||
191 | "[MOCK INV DB]: Adding inventory item {0} {1} in {2} {3}", item.Name, item.ID, folder.Name, folder.ID); | ||
171 | 192 | ||
172 | m_items[item.ID] = item; | 193 | m_items[item.ID] = item; |
173 | } | 194 | } |
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index eaa0d33..d9ded2d 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | |||
@@ -285,10 +285,16 @@ namespace OpenSim.Tests.Common.Setup | |||
285 | config.AddConfig("Modules"); | 285 | config.AddConfig("Modules"); |
286 | config.AddConfig("InventoryService"); | 286 | config.AddConfig("InventoryService"); |
287 | config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); | 287 | config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); |
288 | |||
288 | if (real) | 289 | if (real) |
290 | { | ||
289 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); | 291 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); |
292 | } | ||
290 | else | 293 | else |
294 | { | ||
291 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockInventoryService"); | 295 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockInventoryService"); |
296 | } | ||
297 | |||
292 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | 298 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
293 | inventoryService.Initialise(config); | 299 | inventoryService.Initialise(config); |
294 | inventoryService.AddRegion(testScene); | 300 | inventoryService.AddRegion(testScene); |
diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index 122ba2e..554d00f 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example | |||
@@ -100,7 +100,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 | |||
100 | [UserAccountService] | 100 | [UserAccountService] |
101 | ; for the server connector | 101 | ; for the server connector |
102 | LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" | 102 | LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" |
103 | ; Realm = "usersaccounts" | 103 | ; Realm = "useraccounts" |
104 | 104 | ||
105 | ; These are for creating new accounts by the service | 105 | ; These are for creating new accounts by the service |
106 | AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" | 106 | AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" |