aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs17
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs139
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs143
5 files changed, 234 insertions, 74 deletions
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 241e100..9c62ad3 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes
106 else 106 else
107 { 107 {
108 m_log.WarnFormat( 108 m_log.WarnFormat(
109 "[AGENT INVENTORY]: Agent {1} could not add item {2} {3}", 109 "[AGENT INVENTORY]: Agent {0} could not add item {1} {2}",
110 AgentID, item.Name, item.ID); 110 AgentID, item.Name, item.ID);
111 111
112 return; 112 return;
@@ -1951,7 +1951,7 @@ namespace OpenSim.Region.Framework.Scenes
1951 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 1951 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
1952 RezSelected, RemoveItem, fromTaskID, false); 1952 RezSelected, RemoveItem, fromTaskID, false);
1953 } 1953 }
1954 1954
1955 /// <summary> 1955 /// <summary>
1956 /// Rez an object into the scene from a prim's inventory. 1956 /// Rez an object into the scene from a prim's inventory.
1957 /// </summary> 1957 /// </summary>
@@ -1966,95 +1966,94 @@ namespace OpenSim.Region.Framework.Scenes
1966 SceneObjectPart sourcePart, TaskInventoryItem item, 1966 SceneObjectPart sourcePart, TaskInventoryItem item,
1967 Vector3 pos, Quaternion rot, Vector3 vel, int param) 1967 Vector3 pos, Quaternion rot, Vector3 vel, int param)
1968 { 1968 {
1969 // Rez object 1969 if (null == item)
1970 if (item != null) 1970 return null;
1971 { 1971
1972 UUID ownerID = item.OwnerID; 1972 UUID ownerID = item.OwnerID;
1973 AssetBase rezAsset = AssetService.Get(item.AssetID.ToString());
1973 1974
1974 AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); 1975 if (null == rezAsset)
1976 return null;
1975 1977
1976 if (rezAsset != null) 1978 string xmlData = Utils.BytesToString(rezAsset.Data);
1977 { 1979 SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
1978 string xmlData = Utils.BytesToString(rezAsset.Data);
1979 SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
1980 1980
1981 if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos)) 1981 if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos))
1982 { 1982 return null;
1983 return null;
1984 }
1985 group.ResetIDs();
1986 1983
1987 AddNewSceneObject(group, true); 1984 group.ResetIDs();
1988 1985
1989 // we set it's position in world. 1986 AddNewSceneObject(group, true);
1990 group.AbsolutePosition = pos;
1991 1987
1992 SceneObjectPart rootPart = group.GetChildPart(group.UUID); 1988 // we set it's position in world.
1989 group.AbsolutePosition = pos;
1993 1990
1994 // Since renaming the item in the inventory does not affect the name stored 1991 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
1995 // in the serialization, transfer the correct name from the inventory to the
1996 // object itself before we rez.
1997 rootPart.Name = item.Name;
1998 rootPart.Description = item.Description;
1999 1992
2000 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values); 1993 // Since renaming the item in the inventory does not affect the name stored
1994 // in the serialization, transfer the correct name from the inventory to the
1995 // object itself before we rez.
1996 rootPart.Name = item.Name;
1997 rootPart.Description = item.Description;
2001 1998
2002 group.SetGroup(sourcePart.GroupID, null); 1999 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
2003 2000
2004 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) 2001 group.SetGroup(sourcePart.GroupID, null);
2005 {
2006 if (Permissions.PropagatePermissions())
2007 {
2008 foreach (SceneObjectPart part in partList)
2009 {
2010 part.EveryoneMask = item.EveryonePermissions;
2011 part.NextOwnerMask = item.NextPermissions;
2012 }
2013 group.ApplyNextOwnerPermissions();
2014 }
2015 }
2016 2002
2003 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
2004 {
2005 if (Permissions.PropagatePermissions())
2006 {
2017 foreach (SceneObjectPart part in partList) 2007 foreach (SceneObjectPart part in partList)
2018 { 2008 {
2019 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
2020 {
2021 part.LastOwnerID = part.OwnerID;
2022 part.OwnerID = item.OwnerID;
2023 part.Inventory.ChangeInventoryOwner(item.OwnerID);
2024 }
2025 part.EveryoneMask = item.EveryonePermissions; 2009 part.EveryoneMask = item.EveryonePermissions;
2026 part.NextOwnerMask = item.NextPermissions; 2010 part.NextOwnerMask = item.NextPermissions;
2027 } 2011 }
2028 2012
2029 rootPart.TrimPermissions(); 2013 group.ApplyNextOwnerPermissions();
2030 2014 }
2031 if (group.RootPart.Shape.PCode == (byte)PCode.Prim) 2015 }
2032 {
2033 group.ClearPartAttachmentData();
2034 }
2035
2036 group.UpdateGroupRotationR(rot);
2037
2038 //group.ApplyPhysics(m_physicalPrim);
2039 if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero)
2040 {
2041 group.RootPart.ApplyImpulse((vel * group.GetMass()), false);
2042 group.Velocity = vel;
2043 rootPart.ScheduleFullUpdate();
2044 }
2045 group.CreateScriptInstances(param, true, DefaultScriptEngine, 2);
2046 rootPart.ScheduleFullUpdate();
2047 2016
2048 if (!Permissions.BypassPermissions()) 2017 foreach (SceneObjectPart part in partList)
2049 { 2018 {
2050 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 2019 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
2051 sourcePart.Inventory.RemoveInventoryItem(item.ItemID); 2020 {
2052 } 2021 part.LastOwnerID = part.OwnerID;
2053 return rootPart.ParentGroup; 2022 part.OwnerID = item.OwnerID;
2023 part.Inventory.ChangeInventoryOwner(item.OwnerID);
2054 } 2024 }
2025
2026 part.EveryoneMask = item.EveryonePermissions;
2027 part.NextOwnerMask = item.NextPermissions;
2028 }
2029
2030 rootPart.TrimPermissions();
2031
2032 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
2033 {
2034 group.ClearPartAttachmentData();
2035 }
2036
2037 group.UpdateGroupRotationR(rot);
2038
2039 //group.ApplyPhysics(m_physicalPrim);
2040 if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero)
2041 {
2042 group.RootPart.ApplyImpulse((vel * group.GetMass()), false);
2043 group.Velocity = vel;
2044 rootPart.ScheduleFullUpdate();
2055 } 2045 }
2046
2047 group.CreateScriptInstances(param, true, DefaultScriptEngine, 2);
2048 rootPart.ScheduleFullUpdate();
2056 2049
2057 return null; 2050 if (!Permissions.BypassPermissions())
2051 {
2052 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
2053 sourcePart.Inventory.RemoveInventoryItem(item.ItemID);
2054 }
2055
2056 return rootPart.ParentGroup;
2058 } 2057 }
2059 2058
2060 public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId) 2059 public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId)
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse;
39using OpenMetaverse.Assets;
40using OpenSim.Framework;
41using OpenSim.Framework.Communications;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
45using OpenSim.Region.CoreModules.World.Serialiser;
46using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
47using OpenSim.Services.Interfaces;
48using OpenSim.Tests.Common;
49using OpenSim.Tests.Common.Mock;
50using OpenSim.Tests.Common.Setup;
51
52namespace 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