aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/Assets/InventoryCache.cs
diff options
context:
space:
mode:
authorgareth2007-03-22 10:11:15 +0000
committergareth2007-03-22 10:11:15 +0000
commit7daa3955bc3a1918e40962851f9e8d38597a245e (patch)
treebee3e1372a7eed0c1b220a8a49f7bee7d29a6b91 /OpenSim.RegionServer/Assets/InventoryCache.cs
parentLoad XML for neighbourinfo from grid (diff)
downloadopensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.zip
opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.gz
opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.bz2
opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.xz
brought zircon branch into trunk
Diffstat (limited to 'OpenSim.RegionServer/Assets/InventoryCache.cs')
-rw-r--r--OpenSim.RegionServer/Assets/InventoryCache.cs199
1 files changed, 199 insertions, 0 deletions
diff --git a/OpenSim.RegionServer/Assets/InventoryCache.cs b/OpenSim.RegionServer/Assets/InventoryCache.cs
new file mode 100644
index 0000000..0788db2
--- /dev/null
+++ b/OpenSim.RegionServer/Assets/InventoryCache.cs
@@ -0,0 +1,199 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using System;
29using System.Collections.Generic;
30using libsecondlife;
31using OpenSim;
32using libsecondlife.Packets;
33//using OpenSim.GridServers;
34using OpenSim.Framework.Inventory;
35using OpenSim.Framework.Assets;
36
37namespace OpenSim.Assets
38{
39 /// <summary>
40 /// Description of InventoryManager.
41 /// </summary>
42 public class InventoryCache
43 {
44 private Dictionary<LLUUID, AgentInventory> _agentsInventory;
45 private List<UserServerRequest> _serverRequests; //list of requests made to user server.
46 private System.Text.Encoding _enc = System.Text.Encoding.ASCII;
47 private const uint FULL_MASK_PERMISSIONS = 2147483647;
48
49 public InventoryCache()
50 {
51 _agentsInventory = new Dictionary<LLUUID, AgentInventory>();
52 _serverRequests = new List<UserServerRequest>();
53 }
54
55 public void AddNewAgentsInventory(AgentInventory agentInventory)
56 {
57 this._agentsInventory.Add(agentInventory.AgentID, agentInventory);
58 }
59
60 public void ClientLeaving(LLUUID clientID)
61 {
62 if (this._agentsInventory.ContainsKey(clientID))
63 {
64 this._agentsInventory.Remove(clientID);
65 }
66
67 }
68 public bool CreateNewInventoryFolder(SimClient remoteClient, LLUUID folderID)
69 {
70 bool res = false;
71 if (folderID != LLUUID.Zero) //don't create a folder with a zero id
72 {
73 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
74 {
75 res = this._agentsInventory[remoteClient.AgentID].CreateNewFolder(folderID);
76 }
77 }
78 return res;
79 }
80
81 public LLUUID AddNewInventoryItem(SimClient remoteClient, LLUUID folderID, OpenSim.Framework.Assets.AssetBase asset)
82 {
83 LLUUID newItem = null;
84 if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
85 {
86 newItem = this._agentsInventory[remoteClient.AgentID].AddToInventory(folderID, asset);
87 }
88
89 return newItem;
90 }
91
92 public void FetchInventoryDescendents(SimClient userInfo, FetchInventoryDescendentsPacket FetchDescend)
93 {
94 if (this._agentsInventory.ContainsKey(userInfo.AgentID))
95 {
96 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID];
97 if (FetchDescend.InventoryData.FetchItems)
98 {
99 if (agentInventory.InventoryFolders.ContainsKey(FetchDescend.InventoryData.FolderID))
100 {
101 InventoryFolder Folder = agentInventory.InventoryFolders[FetchDescend.InventoryData.FolderID];
102 InventoryDescendentsPacket Descend = new InventoryDescendentsPacket();
103 Descend.AgentData.AgentID = userInfo.AgentID;
104 Descend.AgentData.OwnerID = Folder.OwnerID;
105 Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID;
106 Descend.AgentData.Descendents = Folder.Items.Count;
107 Descend.AgentData.Version = Folder.Items.Count;
108
109
110 Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count];
111 for (int i = 0; i < Folder.Items.Count; i++)
112 {
113
114 InventoryItem Item = Folder.Items[i];
115 Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock();
116 Descend.ItemData[i].ItemID = Item.ItemID;
117 Descend.ItemData[i].AssetID = Item.AssetID;
118 Descend.ItemData[i].CreatorID = Item.CreatorID;
119 Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS;
120 Descend.ItemData[i].CreationDate = 1000;
121 Descend.ItemData[i].Description = _enc.GetBytes(Item.Description + "\0");
122 Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS;
123 Descend.ItemData[i].Flags = 1;
124 Descend.ItemData[i].FolderID = Item.FolderID;
125 Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
126 Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS;
127 Descend.ItemData[i].InvType = Item.InvType;
128 Descend.ItemData[i].Name = _enc.GetBytes(Item.Name + "\0");
129 Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS;
130 Descend.ItemData[i].OwnerID = Item.OwnerID;
131 Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS;
132 Descend.ItemData[i].SalePrice = 100;
133 Descend.ItemData[i].SaleType = 0;
134 Descend.ItemData[i].Type = Item.Type;
135 Descend.ItemData[i].CRC = libsecondlife.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);
136 }
137 userInfo.OutPacket(Descend);
138
139 }
140 }
141 else
142 {
143 Console.WriteLine("fetch subfolders");
144 }
145 }
146 }
147
148 public void FetchInventory(SimClient userInfo, FetchInventoryPacket FetchItems)
149 {
150 if (this._agentsInventory.ContainsKey(userInfo.AgentID))
151 {
152 AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID];
153
154 for (int i = 0; i < FetchItems.InventoryData.Length; i++)
155 {
156 if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID))
157 {
158 InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID];
159 FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket();
160 InventoryReply.AgentData.AgentID = userInfo.AgentID;
161 InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
162 InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
163 InventoryReply.InventoryData[0].ItemID = Item.ItemID;
164 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
165 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID;
166 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
167 InventoryReply.InventoryData[0].CreationDate = 1000;
168 InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0");
169 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
170 InventoryReply.InventoryData[0].Flags = 1;
171 InventoryReply.InventoryData[0].FolderID = Item.FolderID;
172 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
173 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
174 InventoryReply.InventoryData[0].InvType = Item.InvType;
175 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0");
176 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
177 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID;
178 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
179 InventoryReply.InventoryData[0].SalePrice = 100;
180 InventoryReply.InventoryData[0].SaleType = 0;
181 InventoryReply.InventoryData[0].Type = Item.Type;
182 InventoryReply.InventoryData[0].CRC = libsecondlife.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);
183 userInfo.OutPacket(InventoryReply);
184 }
185 }
186 }
187 }
188 }
189
190
191
192 public class UserServerRequest
193 {
194 public UserServerRequest()
195 {
196
197 }
198 }
199}