aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/InventoryManager.cs
diff options
context:
space:
mode:
authorgareth2007-02-27 22:59:35 +0000
committergareth2007-02-27 22:59:35 +0000
commit5453580d550e96cdeeec855d610082c662562022 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /InventoryManager.cs
parentPatch Applied regarding Bug #51 (diff)
downloadopensim-SC_OLD-5453580d550e96cdeeec855d610082c662562022.zip
opensim-SC_OLD-5453580d550e96cdeeec855d610082c662562022.tar.gz
opensim-SC_OLD-5453580d550e96cdeeec855d610082c662562022.tar.bz2
opensim-SC_OLD-5453580d550e96cdeeec855d610082c662562022.tar.xz
Removed old trunk code
Diffstat (limited to 'InventoryManager.cs')
-rw-r--r--InventoryManager.cs242
1 files changed, 0 insertions, 242 deletions
diff --git a/InventoryManager.cs b/InventoryManager.cs
deleted file mode 100644
index 17f7f5c..0000000
--- a/InventoryManager.cs
+++ /dev/null
@@ -1,242 +0,0 @@
1/*
2Copyright (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
27using System;
28using System.Collections.Generic;
29using libsecondlife;
30using libsecondlife.Packets;
31using libsecondlife.AssetSystem;
32using System.IO;
33
34namespace OpenSim
35{
36 /// <summary>
37 /// Description of InventoryManager.
38 /// </summary>
39 public class InventoryManager
40 {
41
42 public Dictionary<LLUUID, InventoryFolder> Folders;
43 public Dictionary<LLUUID, InventoryItem> Items;
44 private Server _server;
45 private System.Text.Encoding _enc = System.Text.Encoding.ASCII;
46 private const uint FULL_MASK_PERMISSIONS = 2147483647;
47
48 /// <summary>
49 ///
50 /// </summary>
51 /// <param name="serve"></param>
52 public InventoryManager(Server server)
53 {
54 _server = server;
55 Folders=new Dictionary<LLUUID, InventoryFolder>();
56 Items=new Dictionary<LLUUID, InventoryItem>();
57 }
58
59 /// <summary>
60 ///
61 /// </summary>
62 /// <param name="UserInfo"></param>
63 /// <param name="FolderID"></param>
64 /// <param name="Asset"></param>
65 /// <returns></returns>
66 public LLUUID AddToInventory(UserAgentInfo userInfo, LLUUID folderID, AssetBase asset)
67 {
68 if(this.Folders.ContainsKey(folderID))
69 {
70 LLUUID NewItemID = LLUUID.Random();
71
72 InventoryItem Item = new InventoryItem();
73 Item.FolderID = folderID;
74 Item.OwnerID = userInfo.AgentID;
75 Item.AssetID = asset.FullID;
76 Item.ItemID = NewItemID;
77 Item.Type = asset.Type;
78 Item.Name = asset.Name;
79 Item.Description = asset.Description;
80 Item.InvType = asset.InvType;
81 this.Items.Add(Item.ItemID, Item);
82 InventoryFolder Folder = Folders[Item.FolderID];
83 Folder.Items.Add(Item);
84 return(Item.ItemID);
85 }
86 else
87 {
88 return(null);
89 }
90 }
91
92 /// <summary>
93 ///
94 /// </summary>
95 /// <param name="UserInfo"></param>
96 /// <param name="NewFolder"></param>
97 /// <returns></returns>
98 public bool CreateNewFolder(UserAgentInfo userInfo, LLUUID newFolder)
99 {
100 InventoryFolder Folder = new InventoryFolder();
101 Folder.FolderID = newFolder;
102 Folder.OwnerID = userInfo.AgentID;
103 this.Folders.Add(Folder.FolderID, Folder);
104
105 return(true);
106 }
107
108 /// <summary>
109 ///
110 /// </summary>
111 /// <param name="User_info"></param>
112 /// <param name="FetchDescend"></param>
113 public void FetchInventoryDescendents(UserAgentInfo userInfo, FetchInventoryDescendentsPacket FetchDescend)
114 {
115 if(FetchDescend.InventoryData.FetchItems)
116 {
117 if(this.Folders.ContainsKey(FetchDescend.InventoryData.FolderID))
118 {
119
120 InventoryFolder Folder = this.Folders[FetchDescend.InventoryData.FolderID];
121 InventoryDescendentsPacket Descend = new InventoryDescendentsPacket();
122 Descend.AgentData.AgentID = userInfo.AgentID;
123 Descend.AgentData.OwnerID = Folder.OwnerID;
124 Descend.AgentData.FolderID = FetchDescend.InventoryData.FolderID;
125 Descend.AgentData.Descendents = Folder.Items.Count;
126 Descend.AgentData.Version = Folder.Items.Count;
127
128 Descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[Folder.Items.Count];
129 for(int i = 0; i < Folder.Items.Count ; i++)
130 {
131
132 InventoryItem Item=Folder.Items[i];
133 Descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock();
134 Descend.ItemData[i].ItemID = Item.ItemID;
135 Descend.ItemData[i].AssetID = Item.AssetID;
136 Descend.ItemData[i].CreatorID = Item.CreatorID;
137 Descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS;
138 Descend.ItemData[i].CreationDate = 1000;
139 Descend.ItemData[i].Description = _enc.GetBytes(Item.Description+"\0");
140 Descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS;
141 Descend.ItemData[i].Flags = 1;
142 Descend.ItemData[i].FolderID = Item.FolderID;
143 Descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
144 Descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS;
145 Descend.ItemData[i].InvType = Item.InvType;
146 Descend.ItemData[i].Name = _enc.GetBytes(Item.Name+"\0");
147 Descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS;
148 Descend.ItemData[i].OwnerID = Item.OwnerID;
149 Descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS;
150 Descend.ItemData[i].SalePrice = 100;
151 Descend.ItemData[i].SaleType = 0;
152 Descend.ItemData[i].Type = Item.Type;
153 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);
154 }
155 _server.SendPacket(Descend, true, userInfo);
156
157 }
158 }
159 else
160 {
161 Console.WriteLine("fetch subfolders");
162 }
163 }
164
165 /// <summary>
166 ///
167 /// </summary>
168 /// <param name="User_info"></param>
169 public void FetchInventory(UserAgentInfo userInfo, FetchInventoryPacket FetchItems)
170 {
171
172 for(int i = 0; i < FetchItems.InventoryData.Length; i++)
173 {
174 if(this.Items.ContainsKey(FetchItems.InventoryData[i].ItemID))
175 {
176
177 InventoryItem Item = Items[FetchItems.InventoryData[i].ItemID];
178 FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket();
179 InventoryReply.AgentData.AgentID = userInfo.AgentID;
180 InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
181 InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
182 InventoryReply.InventoryData[0].ItemID = Item.ItemID;
183 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
184 InventoryReply.InventoryData[0].CreatorID = Item.CreatorID;
185 InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
186 InventoryReply.InventoryData[0].CreationDate = 1000;
187 InventoryReply.InventoryData[0].Description = _enc.GetBytes( Item.Description+"\0");
188 InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
189 InventoryReply.InventoryData[0].Flags = 1;
190 InventoryReply.InventoryData[0].FolderID = Item.FolderID;
191 InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
192 InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
193 InventoryReply.InventoryData[0].InvType = Item.InvType;
194 InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name+"\0");
195 InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
196 InventoryReply.InventoryData[0].OwnerID = Item.OwnerID;
197 InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
198 InventoryReply.InventoryData[0].SalePrice = 100;
199 InventoryReply.InventoryData[0].SaleType = 0;
200 InventoryReply.InventoryData[0].Type = Item.Type;
201 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);
202 _server.SendPacket(InventoryReply, true, userInfo);
203 }
204 }
205 }
206 }
207
208 public class InventoryFolder
209 {
210 public List<InventoryItem> Items;
211 //public List<InventoryFolder> Subfolders;
212
213 public LLUUID FolderID;
214 public LLUUID OwnerID;
215 public LLUUID ParentID;
216
217
218 public InventoryFolder()
219 {
220 Items = new List<InventoryItem>();
221 }
222
223 }
224
225 public class InventoryItem
226 {
227 public LLUUID FolderID;
228 public LLUUID OwnerID;
229 public LLUUID ItemID;
230 public LLUUID AssetID;
231 public LLUUID CreatorID = LLUUID.Zero;
232 public sbyte InvType;
233 public sbyte Type;
234 public string Name;
235 public string Description;
236
237 public InventoryItem()
238 {
239
240 }
241 }
242}