aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
diff options
context:
space:
mode:
authorMelanie2012-04-07 04:52:14 +0100
committerMelanie2012-04-07 04:52:14 +0100
commitb39de2425cac4c2a94a7fdd6c77100ef831d66b4 (patch)
tree9258928681a82d68b408354e534c32bcf283ad3a /OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
parentMerge branch 'ubitwork' (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-b39de2425cac4c2a94a7fdd6c77100ef831d66b4.zip
opensim-SC-b39de2425cac4c2a94a7fdd6c77100ef831d66b4.tar.gz
opensim-SC-b39de2425cac4c2a94a7fdd6c77100ef831d66b4.tar.bz2
opensim-SC-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
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs81
1 files changed, 68 insertions, 13 deletions
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;
36using log4net; 36using log4net;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Region.Framework; 38using OpenSim.Region.Framework;
39using OpenSim.Framework.Client;
39using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes.Serialization; 41using 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);