aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
diff options
context:
space:
mode:
authorMW2007-08-21 13:21:03 +0000
committerMW2007-08-21 13:21:03 +0000
commit252b48fb3e0905e6b21648e818aebd091e8532a8 (patch)
treedfd27c645a54273c4c1724755bb2b7a92929706e /OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
parentAdded Property to SceneObjectGroup to allow the UUID of the region it is in t... (diff)
downloadopensim-SC_OLD-252b48fb3e0905e6b21648e818aebd091e8532a8.zip
opensim-SC_OLD-252b48fb3e0905e6b21648e818aebd091e8532a8.tar.gz
opensim-SC_OLD-252b48fb3e0905e6b21648e818aebd091e8532a8.tar.bz2
opensim-SC_OLD-252b48fb3e0905e6b21648e818aebd091e8532a8.tar.xz
Can now turn on/off server side permission checking (on prim editing etc) from the opensim.ini file. Just add a line to the Startup section like : serverside_object_permissions = true
Changes /editing that are made to clothing/ body parts in your inventory should now be saved between logins/ restarts.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.Inventory.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs325
1 files changed, 325 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
new file mode 100644
index 0000000..3e2a97a
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -0,0 +1,325 @@
1using System;
2using System.IO;
3using System.Collections.Generic;
4using libsecondlife;
5using libsecondlife.Packets;
6using OpenSim.Framework.Interfaces;
7using OpenSim.Framework.Types;
8using OpenSim.Framework.Communications.Caches;
9using OpenSim.Framework.Data;
10using OpenSim.Framework.Utilities;
11
12namespace OpenSim.Region.Environment.Scenes
13{
14 public partial class Scene
15 {
16 //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete
17 // or at least some of they can be moved somewhere else
18
19 public void AddInventoryItem(LLUUID userID, InventoryItemBase item)
20 {
21 if (this.Avatars.ContainsKey(userID))
22 {
23 this.AddInventoryItem(this.Avatars[userID].ControllingClient, item);
24 }
25 }
26
27 public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item)
28 {
29 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
30 if (userInfo != null)
31 {
32 userInfo.AddItem(remoteClient.AgentId, item);
33 remoteClient.SendInventoryItemUpdate(item);
34 }
35 }
36
37 public LLUUID CapsUpdateInventoryItemAsset(LLUUID userID, LLUUID itemID, byte[] data)
38 {
39 if (this.Avatars.ContainsKey(userID))
40 {
41 return this.CapsUpdateInventoryItemAsset(this.Avatars[userID].ControllingClient, itemID, data);
42 }
43 return LLUUID.Zero;
44 }
45
46 public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data)
47 {
48 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
49 if (userInfo != null)
50 {
51 if (userInfo.RootFolder != null)
52 {
53 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
54 if (item != null)
55 {
56 AssetBase asset;
57 asset = new AssetBase();
58 asset.FullID = LLUUID.Random();
59 asset.Type = (sbyte)item.assetType;
60 asset.InvType = (sbyte)item.invType;
61 asset.Name = item.inventoryName;
62 asset.Data = data;
63 commsManager.AssetCache.AddAsset(asset);
64
65 item.assetID = asset.FullID;
66 userInfo.UpdateItem(remoteClient.AgentId, item);
67
68 // remoteClient.SendInventoryItemUpdate(item);
69 if (item.invType == 7)
70 {
71 //do we want to know about updated note cards?
72 }
73 else if (item.invType == 10)
74 {
75 // do we want to know about updated scripts
76 }
77
78 return (asset.FullID);
79 }
80 }
81 }
82 return LLUUID.Zero;
83 }
84
85 public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID)
86 {
87 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
88 if (userInfo != null)
89 {
90 if (userInfo.RootFolder != null)
91 {
92 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
93 if (item != null)
94 {
95 AgentAssetTransactions transactions = commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
96 if (transactions != null)
97 {
98 AssetBase asset = null;
99 bool addToCache = false;
100
101 asset = commsManager.AssetCache.GetAsset(assetID);
102 if (asset == null)
103 {
104 asset = transactions.GetTransactionAsset(transactionID);
105 addToCache = true;
106 }
107
108 if (asset != null)
109 {
110 if (asset.FullID == assetID)
111 {
112 asset.Name = item.inventoryName;
113 asset.Description = item.inventoryDescription;
114 asset.InvType = (sbyte) item.invType;
115 asset.Type = (sbyte) item.assetType;
116 item.assetID = asset.FullID;
117
118 if (addToCache)
119 {
120 commsManager.AssetCache.AddAsset(asset);
121 }
122
123 userInfo.UpdateItem(remoteClient.AgentId, item);
124 }
125 }
126 }
127 }
128 }
129 }
130 }
131
132 /// <summary>
133 /// temporary method to test out creating new inventory items
134 /// </summary>
135 /// <param name="remoteClient"></param>
136 /// <param name="transActionID"></param>
137 /// <param name="folderID"></param>
138 /// <param name="callbackID"></param>
139 /// <param name="description"></param>
140 /// <param name="name"></param>
141 /// <param name="invType"></param>
142 /// <param name="type"></param>
143 /// <param name="wearableType"></param>
144 /// <param name="nextOwnerMask"></param>
145 public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask)
146 {
147 if (transActionID == LLUUID.Zero)
148 {
149 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
150 if (userInfo != null)
151 {
152 AssetBase asset = new AssetBase();
153 asset.Name = name;
154 asset.Description = description;
155 asset.InvType = invType;
156 asset.Type = type;
157 asset.FullID = LLUUID.Random();
158 asset.Data = new byte[1];
159 this.commsManager.AssetCache.AddAsset(asset);
160
161 InventoryItemBase item = new InventoryItemBase();
162 item.avatarID = remoteClient.AgentId;
163 item.creatorsID = remoteClient.AgentId;
164 item.inventoryID = LLUUID.Random();
165 item.assetID = asset.FullID;
166 item.inventoryDescription = description;
167 item.inventoryName = name;
168 item.assetType = invType;
169 item.invType = invType;
170 item.parentFolderID = folderID;
171 item.inventoryCurrentPermissions = 2147483647;
172 item.inventoryNextPermissions = nextOwnerMask;
173
174 userInfo.AddItem(remoteClient.AgentId, item);
175 remoteClient.SendInventoryItemUpdate(item);
176 }
177 }
178 else
179 {
180 commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
181 //System.Console.WriteLine("request to create inventory item from transaction " + transActionID);
182 }
183 }
184
185 /// <summary>
186 ///
187 /// </summary>
188 /// <param name="remoteClient"></param>
189 /// <param name="primLocalID"></param>
190 public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
191 {
192
193 bool hasPrim = false;
194 foreach (EntityBase ent in Entities.Values)
195 {
196 if (ent is SceneObjectGroup)
197 {
198 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
199 if (hasPrim != false)
200 {
201 ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID);
202 break;
203 }
204 }
205 }
206 }
207
208 /// <summary>
209 ///
210 /// </summary>
211 /// <param name="packet"></param>
212 /// <param name="simClient"></param>
213 public void DeRezObject(Packet packet, IClientAPI remoteClient)
214 {
215 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
216
217
218 if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
219 {
220 //currently following code not used (or don't know of any case of destination being zero
221 }
222 else
223 {
224 foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
225 {
226 EntityBase selectedEnt = null;
227 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
228 foreach (EntityBase ent in this.Entities.Values)
229 {
230 if (ent.LocalId == Data.ObjectLocalID)
231 {
232 selectedEnt = ent;
233 break;
234 }
235 }
236 if (selectedEnt != null)
237 {
238 if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup)selectedEnt).UUID))
239 {
240 string sceneObjectXml = ((SceneObjectGroup)selectedEnt).ToXmlString();
241 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
242 if (userInfo != null)
243 {
244 AssetBase asset = new AssetBase();
245 asset.Name = ((SceneObjectGroup)selectedEnt).GetPartName(selectedEnt.LocalId);
246 asset.Description = ((SceneObjectGroup)selectedEnt).GetPartDescription(selectedEnt.LocalId);
247 asset.InvType = 6;
248 asset.Type = 6;
249 asset.FullID = LLUUID.Random();
250 asset.Data = Helpers.StringToField(sceneObjectXml);
251 commsManager.AssetCache.AddAsset(asset);
252
253
254 InventoryItemBase item = new InventoryItemBase();
255 item.avatarID = remoteClient.AgentId;
256 item.creatorsID = remoteClient.AgentId;
257 item.inventoryID = LLUUID.Random();
258 item.assetID = asset.FullID;
259 item.inventoryDescription = asset.Description;
260 item.inventoryName = asset.Name;
261 item.assetType = asset.Type;
262 item.invType = asset.InvType;
263 item.parentFolderID = DeRezPacket.AgentBlock.DestinationID;
264 item.inventoryCurrentPermissions = 2147483647;
265 item.inventoryNextPermissions = 2147483647;
266
267 userInfo.AddItem(remoteClient.AgentId, item);
268 remoteClient.SendInventoryItemUpdate(item);
269 }
270
271 storageManager.DataStore.RemoveObject(((SceneObjectGroup)selectedEnt).UUID, m_regInfo.SimUUID);
272 ((SceneObjectGroup)selectedEnt).DeleteGroup();
273
274 lock (Entities)
275 {
276 Entities.Remove(((SceneObjectGroup)selectedEnt).UUID);
277 }
278 }
279 }
280 }
281 }
282 }
283
284 public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos)
285 {
286 CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
287 if (userInfo != null)
288 {
289 if (userInfo.RootFolder != null)
290 {
291 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
292 if (item != null)
293 {
294 AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false);
295 if (rezAsset != null)
296 {
297 this.AddRezObject(Util.FieldToString(rezAsset.Data), pos);
298 userInfo.DeleteItem(remoteClient.AgentId, item);
299 remoteClient.SendRemoveInventoryItem(itemID);
300 }
301 else
302 {
303 //lets try once more incase the asset cache is being slow getting the asset from server
304 rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false);
305 if (rezAsset != null)
306 {
307 this.AddRezObject(Util.FieldToString(rezAsset.Data), pos);
308 userInfo.DeleteItem(remoteClient.AgentId, item);
309 remoteClient.SendRemoveInventoryItem(itemID);
310 }
311 }
312 }
313 }
314 }
315 }
316
317 private void AddRezObject(string xmlData, LLVector3 pos)
318 {
319 SceneObjectGroup group = new SceneObjectGroup(this, this.m_regionHandle, xmlData);
320 this.AddEntity(group);
321 group.AbsolutePosition = pos;
322 }
323 }
324
325}