aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Assets
diff options
context:
space:
mode:
authorMW2007-08-16 16:57:30 +0000
committerMW2007-08-16 16:57:30 +0000
commit67873b8614e51fad759b3ba3de0dd0c2f9dba43f (patch)
treef3b1261aac15cb08c53dc69ecae205c35cb5137c /OpenSim/Region/ClientStack/Assets
parentTaking Prims (SceneObjectGroups) in and out of inventory should now work and ... (diff)
downloadopensim-SC_OLD-67873b8614e51fad759b3ba3de0dd0c2f9dba43f.zip
opensim-SC_OLD-67873b8614e51fad759b3ba3de0dd0c2f9dba43f.tar.gz
opensim-SC_OLD-67873b8614e51fad759b3ba3de0dd0c2f9dba43f.tar.bz2
opensim-SC_OLD-67873b8614e51fad759b3ba3de0dd0c2f9dba43f.tar.xz
Deleted old inventoryCache.cs
Diffstat (limited to 'OpenSim/Region/ClientStack/Assets')
-rw-r--r--OpenSim/Region/ClientStack/Assets/InventoryCache.cs317
1 files changed, 0 insertions, 317 deletions
diff --git a/OpenSim/Region/ClientStack/Assets/InventoryCache.cs b/OpenSim/Region/ClientStack/Assets/InventoryCache.cs
deleted file mode 100644
index 8185502..0000000
--- a/OpenSim/Region/ClientStack/Assets/InventoryCache.cs
+++ /dev/null
@@ -1,317 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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
29using System;
30using System.Collections.Generic;
31using System.Text;
32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Inventory;
36using OpenSim.Framework.Types;
37using OpenSim.Region.ClientStack;
38using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder;
39using InventoryItem = OpenSim.Framework.Inventory.InventoryItem;
40
41namespace OpenSim.Assets
42{
43 /// <summary>
44 /// Description of InventoryManager.
45 /// </summary>
46 public class InventoryCache
47 {
48 private Dictionary<LLUUID, AgentInventory> _agentsInventory;
49 private List<UserServerRequest> _serverRequests; //list of requests made to user server.
50 private Encoding _enc = Encoding.ASCII;
51 private const uint FULL_MASK_PERMISSIONS = 2147483647;
52
53 public InventoryCache()
54 {
55 _agentsInventory = new Dictionary<LLUUID, AgentInventory>();
56 _serverRequests = new List<UserServerRequest>();
57 }
58
59 public void AddNewAgentsInventory(AgentInventory agentInventory)
60 {
61 if (!this._agentsInventory.ContainsKey(agentInventory.AgentID))
62 {
63 this._agentsInventory.Add(agentInventory.AgentID, agentInventory);
64 }
65 }
66
67 public AgentInventory GetAgentsInventory(LLUUID agentID)
68 {
69 if (this._agentsInventory.ContainsKey(agentID))
70 {
71 return this._agentsInventory[agentID];
72 }
73
74 return null;
75 }
76
77 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID)
78 {
79 return this.CreateNewInventoryFolder(remoteClient, folderID, 0);
80 }
81
82 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type)
83 {
84 bool res = false;
85 if (folderID != LLUUID.Zero) //don't create a folder with a zero id
86 {
87 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
88 {
89 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type);
90 }
91 }
92 return res;
93 }
94
95 public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent)
96 {
97 bool res = false;
98 if (folderID != LLUUID.Zero) //don't create a folder with a zero id
99 {
100 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
101 {
102 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID, type, folderName, parent);
103 }
104 }
105 return res;
106 }
107
108 public LLUUID AddNewInventoryItem(ClientView remoteClient, LLUUID folderID, AssetBase asset)
109 {
110 LLUUID newItem = null;
111 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
112 {
113 newItem = this._agentsInventory[remoteClient.AgentID].AddToInventory(folderID, asset);
114 if (newItem != null)
115 {
116 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[newItem];
117 this.SendItemUpdateCreate(remoteClient, Item);
118 }
119 }
120
121 return newItem;
122 }
123 public bool DeleteInventoryItem(ClientView remoteClient, LLUUID itemID)
124 {
125 bool res = false;
126 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
127 {
128 res = this._agentsInventory[remoteClient.AgentID].DeleteFromInventory(itemID);
129 if (res)
130 {
131 RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket();
132 remove.AgentData.AgentID = remoteClient.AgentID;
133 remove.AgentData.SessionID = remoteClient.SessionID;
134 remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
135 remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
136 remove.InventoryData[0].ItemID = itemID;
137 remoteClient.OutPacket(remove);
138 }
139 }
140
141 return res;
142 }
143
144 public bool UpdateInventoryItemAsset(ClientView remoteClient, LLUUID itemID, AssetBase asset)
145 {
146 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
147 {
148 bool res = _agentsInventory[remoteClient.AgentID].UpdateItemAsset(itemID, asset);
149 if (res)
150 {
151 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
152 this.SendItemUpdateCreate(remoteClient, Item);
153 }
154 return res;
155 }
156
157 return false;
158 }
159
160 public bool UpdateInventoryItemDetails(ClientView remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
161 {
162 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
163 {
164 bool res = _agentsInventory[remoteClient.AgentID].UpdateItemDetails(itemID, packet);
165 if (res)
166 {
167 InventoryItem Item = this._agentsInventory[remoteClient.AgentID].InventoryItems[itemID];
168 this.SendItemUpdateCreate(remoteClient, Item);
169 }
170 return res;
171 }
172
173 return false;
174 }
175
176 public void FetchInventoryDescendents(ClientView userInfo, FetchInventoryDescendentsPacket FetchDescend)
177 {
178
179 if (this._agentsInventory.ContainsKey(userInfo.AgentID))
180 {
181 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID];
182 if (FetchDescend.InventoryData.FetchItems)
183 {
184 if (agentInventory.InventoryFolders.ContainsKey(FetchDescend.InventoryData.FolderID))
185 {
186 InventoryFolder Folder = agentInventory.InventoryFolders[FetchDescend.InventoryData.FolderID];
187 InventoryDescendentsPacket Descend = new InventoryDescendentsPacket();
188 Descend.AgentData.AgentID = userInfo.AgentID;
189 Descend.AgentData.OwnerID = Folder.OwnerID;
190 Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID;
191 Descend.AgentData.Descendents = Folder.Items.Count;
192 Descend.AgentData.Version = Folder.Items.Count;
193
194
195 Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count];
196 for (int i = 0; i < Folder.Items.Count; i++)
197 {
198
199 InventoryItem Item = Folder.Items[i];
200 Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock();
201 Descend.ItemData[i].ItemID = Item.ItemID;
202 Descend.ItemData[i].AssetID = Item.AssetID;
203 Descend.ItemData[i].CreatorID = Item.CreatorID;
204 Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS;
205 Descend.ItemData[i].CreationDate = 1000;
206 Descend.ItemData[i].Description = _enc.GetBytes(Item.Description + "\0");
207 Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS;
208 Descend.ItemData[i].Flags = 1;
209 Descend.ItemData[i].FolderID = Item.FolderID;
210 Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
211 Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS;
212 Descend.ItemData[i].InvType = Item.InvType;
213 Descend.ItemData[i].Name = _enc.GetBytes(Item.Name + "\0");
214 Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS;
215 Descend.ItemData[i].OwnerID = Item.OwnerID;
216 Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS;
217 Descend.ItemData[i].SalePrice = 100;
218 Descend.ItemData[i].SaleType = 0;
219 Descend.ItemData[i].Type = Item.Type;
220 Descend.ItemData[i].CRC = Helpers.InventoryCRC(1000, 0, Descend.ItemData[i].InvType, Descend.ItemData[i].Type, Descend.ItemData[i].AssetID, Descend.ItemData[i].GroupID, 100, Descend.ItemData[i].OwnerID, Descend.ItemData[i].CreatorID, Descend.ItemData[i].ItemID, Descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
221 }
222
223 userInfo.OutPacket(Descend);
224
225 }
226 }
227 else
228 {
229 Console.WriteLine("fetch subfolders");
230 }
231 }
232 }
233
234 public void FetchInventory(ClientView userInfo, FetchInventoryPacket FetchItems)
235 {
236 if (this._agentsInventory.ContainsKey(userInfo.AgentID))
237 {
238 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID];
239
240 for (int i = 0; i < FetchItems.InventoryData.Length; i++)
241 {
242 if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID))
243 {
244 InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID];
245 FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket();
246 InventoryReply.AgentData.AgentID = userInfo.AgentID;
247 InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
248 InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
249 InventoryReply.InventoryData[0].ItemID = Item.ItemID;
250 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
251 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID;
252 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
253 InventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
254 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0");
255 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
256 InventoryReply.InventoryData[0].Flags = 0;
257 InventoryReply.InventoryData[0].FolderID = Item.FolderID;
258 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
259 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
260 InventoryReply.InventoryData[0].InvType = Item.InvType;
261 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0");
262 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
263 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID;
264 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
265 InventoryReply.InventoryData[0].SalePrice = 100;
266 InventoryReply.InventoryData[0].SaleType = 0;
267 InventoryReply.InventoryData[0].Type = Item.Type;
268 InventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
269 userInfo.OutPacket(InventoryReply);
270 }
271 }
272 }
273 }
274
275 private void SendItemUpdateCreate(ClientView remoteClient, InventoryItem Item)
276 {
277
278 UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket();
279 InventoryReply.AgentData.AgentID = remoteClient.AgentID;
280 InventoryReply.AgentData.SimApproved = true;
281 InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
282 InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
283 InventoryReply.InventoryData[0].ItemID = Item.ItemID;
284 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
285 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID;
286 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
287 InventoryReply.InventoryData[0].CreationDate = 1000;
288 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0");
289 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
290 InventoryReply.InventoryData[0].Flags = 0;
291 InventoryReply.InventoryData[0].FolderID = Item.FolderID;
292 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
293 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
294 InventoryReply.InventoryData[0].InvType = Item.InvType;
295 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0");
296 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
297 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID;
298 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
299 InventoryReply.InventoryData[0].SalePrice = 100;
300 InventoryReply.InventoryData[0].SaleType = 0;
301 InventoryReply.InventoryData[0].Type = Item.Type;
302 InventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
303
304 remoteClient.OutPacket(InventoryReply);
305 }
306 }
307
308
309
310 public class UserServerRequest
311 {
312 public UserServerRequest()
313 {
314
315 }
316 }
317}