aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/General/AgentInventory.cs
diff options
context:
space:
mode:
authorSean Dague2007-07-16 15:40:11 +0000
committerSean Dague2007-07-16 15:40:11 +0000
commit2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch)
treee3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Framework/General/AgentInventory.cs
parent*Trunk compiles now (diff)
downloadopensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz
changed to native line ending encoding
Diffstat (limited to 'OpenSim/Framework/General/AgentInventory.cs')
-rw-r--r--OpenSim/Framework/General/AgentInventory.cs530
1 files changed, 265 insertions, 265 deletions
diff --git a/OpenSim/Framework/General/AgentInventory.cs b/OpenSim/Framework/General/AgentInventory.cs
index e45a0cd..0aeb0b3 100644
--- a/OpenSim/Framework/General/AgentInventory.cs
+++ b/OpenSim/Framework/General/AgentInventory.cs
@@ -1,265 +1,265 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System.Collections.Generic; 28using System.Collections.Generic;
29using libsecondlife; 29using libsecondlife;
30using libsecondlife.Packets; 30using libsecondlife.Packets;
31using OpenSim.Framework.Types; 31using OpenSim.Framework.Types;
32using OpenSim.Framework.Utilities; 32using OpenSim.Framework.Utilities;
33 33
34namespace OpenSim.Framework.Inventory 34namespace OpenSim.Framework.Inventory
35{ 35{
36 public class AgentInventory 36 public class AgentInventory
37 { 37 {
38 //Holds the local copy of Inventory info for a agent 38 //Holds the local copy of Inventory info for a agent
39 public Dictionary<LLUUID, InventoryFolder> InventoryFolders; 39 public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
40 public Dictionary<LLUUID, InventoryItem> InventoryItems; 40 public Dictionary<LLUUID, InventoryItem> InventoryItems;
41 public InventoryFolder InventoryRoot; 41 public InventoryFolder InventoryRoot;
42 public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server 42 public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server
43 public LLUUID AgentID; 43 public LLUUID AgentID;
44 public AvatarWearable[] Wearables; 44 public AvatarWearable[] Wearables;
45 45
46 public AgentInventory() 46 public AgentInventory()
47 { 47 {
48 InventoryFolders = new Dictionary<LLUUID, InventoryFolder>(); 48 InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
49 InventoryItems = new Dictionary<LLUUID, InventoryItem>(); 49 InventoryItems = new Dictionary<LLUUID, InventoryItem>();
50 this.Initialise(); 50 this.Initialise();
51 } 51 }
52 52
53 public virtual void Initialise() 53 public virtual void Initialise()
54 { 54 {
55 Wearables = new AvatarWearable[13]; //should be 12 of these 55 Wearables = new AvatarWearable[13]; //should be 12 of these
56 for (int i = 0; i < 13; i++) 56 for (int i = 0; i < 13; i++)
57 { 57 {
58 Wearables[i] = new AvatarWearable(); 58 Wearables[i] = new AvatarWearable();
59 } 59 }
60 60
61 } 61 }
62 62
63 public bool CreateNewFolder(LLUUID folderID, ushort type) 63 public bool CreateNewFolder(LLUUID folderID, ushort type)
64 { 64 {
65 InventoryFolder Folder = new InventoryFolder(); 65 InventoryFolder Folder = new InventoryFolder();
66 Folder.FolderID = folderID; 66 Folder.FolderID = folderID;
67 Folder.OwnerID = this.AgentID; 67 Folder.OwnerID = this.AgentID;
68 Folder.DefaultType = type; 68 Folder.DefaultType = type;
69 this.InventoryFolders.Add(Folder.FolderID, Folder); 69 this.InventoryFolders.Add(Folder.FolderID, Folder);
70 return (true); 70 return (true);
71 } 71 }
72 72
73 public void CreateRootFolder(LLUUID newAgentID, bool createTextures) 73 public void CreateRootFolder(LLUUID newAgentID, bool createTextures)
74 { 74 {
75 this.AgentID = newAgentID; 75 this.AgentID = newAgentID;
76 InventoryRoot = new InventoryFolder(); 76 InventoryRoot = new InventoryFolder();
77 InventoryRoot.FolderID = LLUUID.Random(); 77 InventoryRoot.FolderID = LLUUID.Random();
78 InventoryRoot.ParentID = new LLUUID(); 78 InventoryRoot.ParentID = new LLUUID();
79 InventoryRoot.Version = 1; 79 InventoryRoot.Version = 1;
80 InventoryRoot.DefaultType = 8; 80 InventoryRoot.DefaultType = 8;
81 InventoryRoot.OwnerID = this.AgentID; 81 InventoryRoot.OwnerID = this.AgentID;
82 InventoryRoot.FolderName = "My Inventory"; 82 InventoryRoot.FolderName = "My Inventory";
83 InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot); 83 InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
84 InventoryRoot.OwnerID = this.AgentID; 84 InventoryRoot.OwnerID = this.AgentID;
85 if (createTextures) 85 if (createTextures)
86 { 86 {
87 this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID); 87 this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID);
88 } 88 }
89 } 89 }
90 90
91 public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName) 91 public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName)
92 { 92 {
93 InventoryFolder Folder = new InventoryFolder(); 93 InventoryFolder Folder = new InventoryFolder();
94 Folder.FolderID = folderID; 94 Folder.FolderID = folderID;
95 Folder.OwnerID = this.AgentID; 95 Folder.OwnerID = this.AgentID;
96 Folder.DefaultType = type; 96 Folder.DefaultType = type;
97 Folder.FolderName = folderName; 97 Folder.FolderName = folderName;
98 this.InventoryFolders.Add(Folder.FolderID, Folder); 98 this.InventoryFolders.Add(Folder.FolderID, Folder);
99 99
100 return (true); 100 return (true);
101 } 101 }
102 102
103 public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parent) 103 public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parent)
104 { 104 {
105 if (!this.InventoryFolders.ContainsKey(folderID)) 105 if (!this.InventoryFolders.ContainsKey(folderID))
106 { 106 {
107 System.Console.WriteLine("creating new folder called " + folderName + " in agents inventory"); 107 System.Console.WriteLine("creating new folder called " + folderName + " in agents inventory");
108 InventoryFolder Folder = new InventoryFolder(); 108 InventoryFolder Folder = new InventoryFolder();
109 Folder.FolderID = folderID; 109 Folder.FolderID = folderID;
110 Folder.OwnerID = this.AgentID; 110 Folder.OwnerID = this.AgentID;
111 Folder.DefaultType = type; 111 Folder.DefaultType = type;
112 Folder.FolderName = folderName; 112 Folder.FolderName = folderName;
113 Folder.ParentID = parent; 113 Folder.ParentID = parent;
114 this.InventoryFolders.Add(Folder.FolderID, Folder); 114 this.InventoryFolders.Add(Folder.FolderID, Folder);
115 } 115 }
116 116
117 return (true); 117 return (true);
118 } 118 }
119 119
120 public bool HasFolder(LLUUID folderID) 120 public bool HasFolder(LLUUID folderID)
121 { 121 {
122 if (this.InventoryFolders.ContainsKey(folderID)) 122 if (this.InventoryFolders.ContainsKey(folderID))
123 { 123 {
124 return true; 124 return true;
125 } 125 }
126 return false; 126 return false;
127 } 127 }
128 128
129 public LLUUID GetFolderID(string folderName) 129 public LLUUID GetFolderID(string folderName)
130 { 130 {
131 foreach (InventoryFolder inv in this.InventoryFolders.Values) 131 foreach (InventoryFolder inv in this.InventoryFolders.Values)
132 { 132 {
133 if (inv.FolderName == folderName) 133 if (inv.FolderName == folderName)
134 { 134 {
135 return inv.FolderID; 135 return inv.FolderID;
136 } 136 }
137 } 137 }
138 138
139 return LLUUID.Zero; 139 return LLUUID.Zero;
140 } 140 }
141 141
142 public bool UpdateItemAsset(LLUUID itemID, AssetBase asset) 142 public bool UpdateItemAsset(LLUUID itemID, AssetBase asset)
143 { 143 {
144 if(this.InventoryItems.ContainsKey(itemID)) 144 if(this.InventoryItems.ContainsKey(itemID))
145 { 145 {
146 InventoryItem Item = this.InventoryItems[itemID]; 146 InventoryItem Item = this.InventoryItems[itemID];
147 Item.AssetID = asset.FullID; 147 Item.AssetID = asset.FullID;
148 System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + " so it now is set to asset " + asset.FullID.ToStringHyphenated()); 148 System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + " so it now is set to asset " + asset.FullID.ToStringHyphenated());
149 //TODO need to update the rest of the info 149 //TODO need to update the rest of the info
150 } 150 }
151 return true; 151 return true;
152 } 152 }
153 153
154 public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet) 154 public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
155 { 155 {
156 System.Console.WriteLine("updating inventory item details"); 156 System.Console.WriteLine("updating inventory item details");
157 if (this.InventoryItems.ContainsKey(itemID)) 157 if (this.InventoryItems.ContainsKey(itemID))
158 { 158 {
159 System.Console.WriteLine("changing name to "+ Util.FieldToString(packet.Name)); 159 System.Console.WriteLine("changing name to "+ Util.FieldToString(packet.Name));
160 InventoryItem Item = this.InventoryItems[itemID]; 160 InventoryItem Item = this.InventoryItems[itemID];
161 Item.Name = Util.FieldToString(packet.Name); 161 Item.Name = Util.FieldToString(packet.Name);
162 System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated()); 162 System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated());
163 //TODO need to update the rest of the info 163 //TODO need to update the rest of the info
164 } 164 }
165 return true; 165 return true;
166 } 166 }
167 167
168 public LLUUID AddToInventory(LLUUID folderID, AssetBase asset) 168 public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
169 { 169 {
170 if (this.InventoryFolders.ContainsKey(folderID)) 170 if (this.InventoryFolders.ContainsKey(folderID))
171 { 171 {
172 LLUUID NewItemID = LLUUID.Random(); 172 LLUUID NewItemID = LLUUID.Random();
173 173
174 InventoryItem Item = new InventoryItem(); 174 InventoryItem Item = new InventoryItem();
175 Item.FolderID = folderID; 175 Item.FolderID = folderID;
176 Item.OwnerID = AgentID; 176 Item.OwnerID = AgentID;
177 Item.AssetID = asset.FullID; 177 Item.AssetID = asset.FullID;
178 Item.ItemID = NewItemID; 178 Item.ItemID = NewItemID;
179 Item.Type = asset.Type; 179 Item.Type = asset.Type;
180 Item.Name = asset.Name; 180 Item.Name = asset.Name;
181 Item.Description = asset.Description; 181 Item.Description = asset.Description;
182 Item.InvType = asset.InvType; 182 Item.InvType = asset.InvType;
183 this.InventoryItems.Add(Item.ItemID, Item); 183 this.InventoryItems.Add(Item.ItemID, Item);
184 InventoryFolder Folder = InventoryFolders[Item.FolderID]; 184 InventoryFolder Folder = InventoryFolders[Item.FolderID];
185 Folder.Items.Add(Item); 185 Folder.Items.Add(Item);
186 return (Item.ItemID); 186 return (Item.ItemID);
187 } 187 }
188 else 188 else
189 { 189 {
190 return (null); 190 return (null);
191 } 191 }
192 } 192 }
193 193
194 public bool DeleteFromInventory(LLUUID itemID) 194 public bool DeleteFromInventory(LLUUID itemID)
195 { 195 {
196 bool res = false; 196 bool res = false;
197 if (this.InventoryItems.ContainsKey(itemID)) 197 if (this.InventoryItems.ContainsKey(itemID))
198 { 198 {
199 InventoryItem item = this.InventoryItems[itemID]; 199 InventoryItem item = this.InventoryItems[itemID];
200 this.InventoryItems.Remove(itemID); 200 this.InventoryItems.Remove(itemID);
201 foreach (InventoryFolder fold in InventoryFolders.Values) 201 foreach (InventoryFolder fold in InventoryFolders.Values)
202 { 202 {
203 if (fold.Items.Contains(item)) 203 if (fold.Items.Contains(item))
204 { 204 {
205 fold.Items.Remove(item); 205 fold.Items.Remove(item);
206 break; 206 break;
207 } 207 }
208 } 208 }
209 res = true; 209 res = true;
210 210
211 } 211 }
212 return res; 212 return res;
213 } 213 }
214 } 214 }
215 215
216 public class InventoryFolder 216 public class InventoryFolder
217 { 217 {
218 public List<InventoryItem> Items; 218 public List<InventoryItem> Items;
219 //public List<InventoryFolder> Subfolders; 219 //public List<InventoryFolder> Subfolders;
220 public LLUUID FolderID; 220 public LLUUID FolderID;
221 public LLUUID OwnerID; 221 public LLUUID OwnerID;
222 public LLUUID ParentID = LLUUID.Zero; 222 public LLUUID ParentID = LLUUID.Zero;
223 public string FolderName; 223 public string FolderName;
224 public ushort DefaultType; 224 public ushort DefaultType;
225 public ushort Version; 225 public ushort Version;
226 226
227 public InventoryFolder() 227 public InventoryFolder()
228 { 228 {
229 Items = new List<InventoryItem>(); 229 Items = new List<InventoryItem>();
230 //Subfolders = new List<InventoryFolder>(); 230 //Subfolders = new List<InventoryFolder>();
231 } 231 }
232 232
233 } 233 }
234 234
235 public class InventoryItem 235 public class InventoryItem
236 { 236 {
237 public LLUUID FolderID; 237 public LLUUID FolderID;
238 public LLUUID OwnerID; 238 public LLUUID OwnerID;
239 public LLUUID ItemID; 239 public LLUUID ItemID;
240 public LLUUID AssetID; 240 public LLUUID AssetID;
241 public LLUUID CreatorID; 241 public LLUUID CreatorID;
242 public sbyte InvType; 242 public sbyte InvType;
243 public sbyte Type; 243 public sbyte Type;
244 public string Name =""; 244 public string Name ="";
245 public string Description; 245 public string Description;
246 246
247 public InventoryItem() 247 public InventoryItem()
248 { 248 {
249 this.CreatorID = LLUUID.Zero; 249 this.CreatorID = LLUUID.Zero;
250 } 250 }
251 251
252 public string ExportString() 252 public string ExportString()
253 { 253 {
254 string typ = "notecard"; 254 string typ = "notecard";
255 string result = ""; 255 string result = "";
256 result += "\tinv_object\t0\n\t{\n"; 256 result += "\tinv_object\t0\n\t{\n";
257 result += "\t\tobj_id\t%s\n"; 257 result += "\t\tobj_id\t%s\n";
258 result += "\t\tparent_id\t"+ ItemID.ToString() +"\n"; 258 result += "\t\tparent_id\t"+ ItemID.ToString() +"\n";
259 result += "\t\ttype\t"+ typ +"\n"; 259 result += "\t\ttype\t"+ typ +"\n";
260 result += "\t\tname\t" + Name+"|\n"; 260 result += "\t\tname\t" + Name+"|\n";
261 result += "\t}\n"; 261 result += "\t}\n";
262 return result; 262 return result;
263 } 263 }
264 } 264 }
265} 265}