diff options
author | lbsa71 | 2007-10-31 07:28:23 +0000 |
---|---|---|
committer | lbsa71 | 2007-10-31 07:28:23 +0000 |
commit | 064404ab409ddd0a3b25027a98582696295c46fd (patch) | |
tree | bd84ec2e23930f76e7cc81c8529ef71936c86dd9 /OpenSim/Framework/InventoryItemBase.cs | |
parent | made illogical bitwise operations logical (diff) | |
download | opensim-SC-064404ab409ddd0a3b25027a98582696295c46fd.zip opensim-SC-064404ab409ddd0a3b25027a98582696295c46fd.tar.gz opensim-SC-064404ab409ddd0a3b25027a98582696295c46fd.tar.bz2 opensim-SC-064404ab409ddd0a3b25027a98582696295c46fd.tar.xz |
* Moved OpenSim/Framework/General to OpenSim/Framework for great justice.
Diffstat (limited to 'OpenSim/Framework/InventoryItemBase.cs')
-rw-r--r-- | OpenSim/Framework/InventoryItemBase.cs | 273 |
1 files changed, 273 insertions, 0 deletions
diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs new file mode 100644 index 0000000..331013f --- /dev/null +++ b/OpenSim/Framework/InventoryItemBase.cs | |||
@@ -0,0 +1,273 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.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 | using System; | ||
29 | using System.Xml.Serialization; | ||
30 | using System.Collections; | ||
31 | using System.Collections.Generic; | ||
32 | using libsecondlife; | ||
33 | |||
34 | namespace OpenSim.Framework | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// Inventory Item - contains all the properties associated with an individual inventory piece. | ||
38 | /// </summary> | ||
39 | public class InventoryItemBase | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// A UUID containing the ID for the inventory item itself | ||
43 | /// </summary> | ||
44 | public LLUUID inventoryID; | ||
45 | |||
46 | /// <summary> | ||
47 | /// The UUID of the associated asset on the asset server | ||
48 | /// </summary> | ||
49 | public LLUUID assetID; | ||
50 | |||
51 | /// <summary> | ||
52 | /// This is an enumerated value determining the type of asset (eg Notecard, Sound, Object, etc) | ||
53 | /// </summary> | ||
54 | public int assetType; | ||
55 | |||
56 | /// <summary> | ||
57 | /// The type of inventory item. (Can be slightly different to the asset type | ||
58 | /// </summary> | ||
59 | public int invType; | ||
60 | |||
61 | /// <summary> | ||
62 | /// The folder this item is contained in | ||
63 | /// </summary> | ||
64 | public LLUUID parentFolderID; | ||
65 | |||
66 | /// <summary> | ||
67 | /// The owner of this inventory item | ||
68 | /// </summary> | ||
69 | public LLUUID avatarID; | ||
70 | |||
71 | /// <summary> | ||
72 | /// The creator of this item | ||
73 | /// </summary> | ||
74 | public LLUUID creatorsID; | ||
75 | |||
76 | /// <summary> | ||
77 | /// The name of the inventory item (must be less than 64 characters) | ||
78 | /// </summary> | ||
79 | public string inventoryName; | ||
80 | |||
81 | /// <summary> | ||
82 | /// The description of the inventory item (must be less than 64 characters) | ||
83 | /// </summary> | ||
84 | public string inventoryDescription; | ||
85 | |||
86 | /// <summary> | ||
87 | /// A mask containing the permissions for the next owner (cannot be enforced) | ||
88 | /// </summary> | ||
89 | public uint inventoryNextPermissions; | ||
90 | |||
91 | /// <summary> | ||
92 | /// A mask containing permissions for the current owner (cannot be enforced) | ||
93 | /// </summary> | ||
94 | public uint inventoryCurrentPermissions; | ||
95 | |||
96 | /// <summary> | ||
97 | /// | ||
98 | /// </summary> | ||
99 | public uint inventoryBasePermissions; | ||
100 | |||
101 | /// <summary> | ||
102 | /// | ||
103 | /// </summary> | ||
104 | public uint inventoryEveryOnePermissions; | ||
105 | } | ||
106 | |||
107 | /// <summary> | ||
108 | /// A Class for folders which contain users inventory | ||
109 | /// </summary> | ||
110 | public class InventoryFolderBase | ||
111 | { | ||
112 | /// <summary> | ||
113 | /// The name of the folder (64 characters or less) | ||
114 | /// </summary> | ||
115 | public string name; | ||
116 | |||
117 | /// <summary> | ||
118 | /// The agent who's inventory this is contained by | ||
119 | /// </summary> | ||
120 | public LLUUID agentID; | ||
121 | |||
122 | /// <summary> | ||
123 | /// The folder this folder is contained in | ||
124 | /// </summary> | ||
125 | public LLUUID parentID; | ||
126 | |||
127 | /// <summary> | ||
128 | /// The UUID for this folder | ||
129 | /// </summary> | ||
130 | public LLUUID folderID; | ||
131 | |||
132 | /// <summary> | ||
133 | /// Tyep of Items normally stored in this folder | ||
134 | /// </summary> | ||
135 | public short type; | ||
136 | |||
137 | /// <summary> | ||
138 | /// | ||
139 | /// </summary> | ||
140 | public ushort version; | ||
141 | } | ||
142 | |||
143 | /// <summary> | ||
144 | /// An interface for accessing inventory data from a storage server | ||
145 | /// </summary> | ||
146 | public interface IInventoryData | ||
147 | { | ||
148 | /// <summary> | ||
149 | /// Initialises the interface | ||
150 | /// </summary> | ||
151 | void Initialise(); | ||
152 | |||
153 | /// <summary> | ||
154 | /// Closes the interface | ||
155 | /// </summary> | ||
156 | void Close(); | ||
157 | |||
158 | /// <summary> | ||
159 | /// The plugin being loaded | ||
160 | /// </summary> | ||
161 | /// <returns>A string containing the plugin name</returns> | ||
162 | string getName(); | ||
163 | |||
164 | /// <summary> | ||
165 | /// The plugins version | ||
166 | /// </summary> | ||
167 | /// <returns>A string containing the plugin version</returns> | ||
168 | string getVersion(); | ||
169 | |||
170 | /// <summary> | ||
171 | /// Returns a list of inventory items contained within the specified folder | ||
172 | /// </summary> | ||
173 | /// <param name="folderID">The UUID of the target folder</param> | ||
174 | /// <returns>A List of InventoryItemBase items</returns> | ||
175 | List<InventoryItemBase> getInventoryInFolder(LLUUID folderID); | ||
176 | |||
177 | /// <summary> | ||
178 | /// Returns a list of the root folders within a users inventory | ||
179 | /// </summary> | ||
180 | /// <param name="user">The user whos inventory is to be searched</param> | ||
181 | /// <returns>A list of folder objects</returns> | ||
182 | List<InventoryFolderBase> getUserRootFolders(LLUUID user); | ||
183 | |||
184 | /// <summary> | ||
185 | /// Returns the users inventory root folder. | ||
186 | /// </summary> | ||
187 | /// <param name="user">The UUID of the user who is having inventory being returned</param> | ||
188 | /// <returns>Root inventory folder</returns> | ||
189 | InventoryFolderBase getUserRootFolder(LLUUID user); | ||
190 | |||
191 | /// <summary> | ||
192 | /// Returns a list of inventory folders contained in the folder 'parentID' | ||
193 | /// </summary> | ||
194 | /// <param name="parentID">The folder to get subfolders for</param> | ||
195 | /// <returns>A list of inventory folders</returns> | ||
196 | List<InventoryFolderBase> getInventoryFolders(LLUUID parentID); | ||
197 | |||
198 | /// <summary> | ||
199 | /// Returns an inventory item by its UUID | ||
200 | /// </summary> | ||
201 | /// <param name="item">The UUID of the item to be returned</param> | ||
202 | /// <returns>A class containing item information</returns> | ||
203 | InventoryItemBase getInventoryItem(LLUUID item); | ||
204 | |||
205 | /// <summary> | ||
206 | /// Returns a specified inventory folder by its UUID | ||
207 | /// </summary> | ||
208 | /// <param name="folder">The UUID of the folder to be returned</param> | ||
209 | /// <returns>A class containing folder information</returns> | ||
210 | InventoryFolderBase getInventoryFolder(LLUUID folder); | ||
211 | |||
212 | /// <summary> | ||
213 | /// Creates a new inventory item based on item | ||
214 | /// </summary> | ||
215 | /// <param name="item">The item to be created</param> | ||
216 | void addInventoryItem(InventoryItemBase item); | ||
217 | |||
218 | /// <summary> | ||
219 | /// Updates an inventory item with item (updates based on ID) | ||
220 | /// </summary> | ||
221 | /// <param name="item">The updated item</param> | ||
222 | void updateInventoryItem(InventoryItemBase item); | ||
223 | |||
224 | /// <summary> | ||
225 | /// | ||
226 | /// </summary> | ||
227 | /// <param name="item"></param> | ||
228 | void deleteInventoryItem(LLUUID item); | ||
229 | |||
230 | /// <summary> | ||
231 | /// Adds a new folder specified by folder | ||
232 | /// </summary> | ||
233 | /// <param name="folder">The inventory folder</param> | ||
234 | void addInventoryFolder(InventoryFolderBase folder); | ||
235 | |||
236 | /// <summary> | ||
237 | /// Updates a folder based on its ID with folder | ||
238 | /// </summary> | ||
239 | /// <param name="folder">The inventory folder</param> | ||
240 | void updateInventoryFolder(InventoryFolderBase folder); | ||
241 | |||
242 | /// <summary> | ||
243 | /// Deletes a folder based on its ID with folder | ||
244 | /// </summary> | ||
245 | /// <param name="folder">The id of the folder</param> | ||
246 | void deleteInventoryFolder(LLUUID folder); | ||
247 | } | ||
248 | |||
249 | /* | ||
250 | * .Net has some issues, serializing a dictionary, so we cannot reuse the InventoryFolder | ||
251 | * class defined in Communications.Framework.Communications.Caches. So we serialize/deserialize | ||
252 | * into this simpler class, and then use that. | ||
253 | */ | ||
254 | [XmlRoot(ElementName = "inventory", IsNullable = true)] | ||
255 | public class SerializableInventory | ||
256 | { | ||
257 | [XmlRoot(ElementName = "folder", IsNullable = true)] | ||
258 | public class SerializableFolder : InventoryFolderBase | ||
259 | { | ||
260 | [XmlArray(ElementName = "folders", IsNullable = true)] | ||
261 | [XmlArrayItem(ElementName = "folder", IsNullable = true, Type = typeof(SerializableFolder))] | ||
262 | public ArrayList SubFolders; | ||
263 | |||
264 | [XmlArray(ElementName = "items", IsNullable = true)] | ||
265 | [XmlArrayItem(ElementName = "item", IsNullable = true, Type = typeof(InventoryItemBase))] | ||
266 | public ArrayList Items; | ||
267 | } | ||
268 | |||
269 | [XmlElement(ElementName = "folder", IsNullable = true)] | ||
270 | public SerializableFolder root; | ||
271 | } | ||
272 | |||
273 | } | ||