clockwerk-opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 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 OpenSimulator 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 using System;
28 using System.Collections.Generic;
29 using System.Reflection;
30  
31 using OpenSim.Framework;
32  
33 using OpenSim.Services.Interfaces;
34  
35 using OpenMetaverse;
36 using log4net;
37  
38 namespace OpenSim.Region.CoreModules.Framework.Library
39 {
40 public class LocalInventoryService : IInventoryService
41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43  
44 private InventoryFolderImpl m_Library;
45  
46 public LocalInventoryService(InventoryFolderImpl lib)
47 {
48 m_Library = lib;
49 }
50  
51 /// <summary>
52 /// Retrieve the root inventory folder for the given user.
53 /// </summary>
54 /// <param name="userID"></param>
55 /// <returns>null if no root folder was found</returns>
56 public InventoryFolderBase GetRootFolder(UUID userID) { return m_Library; }
57  
58 /// <summary>
59 /// Gets everything (folders and items) inside a folder
60 /// </summary>
61 /// <param name="userId"></param>
62 /// <param name="folderID"></param>
63 /// <returns></returns>
64 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
65 {
66 InventoryFolderImpl folder = null;
67 InventoryCollection inv = new InventoryCollection();
68 inv.UserID = m_Library.Owner;
69  
70 if (folderID != m_Library.ID)
71 {
72 folder = m_Library.FindFolder(folderID);
73 if (folder == null)
74 {
75 inv.Folders = new List<InventoryFolderBase>();
76 inv.Items = new List<InventoryItemBase>();
77 return inv;
78 }
79 }
80 else
81 folder = m_Library;
82  
83 inv.Folders = folder.RequestListOfFolders();
84 inv.Items = folder.RequestListOfItems();
85  
86 m_log.DebugFormat("[LIBRARY MODULE]: Got content for folder {0}", folder.Name);
87 return inv;
88 }
89  
90 /// <summary>
91 /// Add a new folder to the user's inventory
92 /// </summary>
93 /// <param name="folder"></param>
94 /// <returns>true if the folder was successfully added</returns>
95 public bool AddFolder(InventoryFolderBase folder)
96 {
97 //m_log.DebugFormat("[LIBRARY MODULE]: Adding folder {0} ({1}) to {2}", folder.Name, folder.ID, folder.ParentID);
98 InventoryFolderImpl parent = m_Library;
99 if (m_Library.ID != folder.ParentID)
100 parent = m_Library.FindFolder(folder.ParentID);
101  
102 if (parent == null)
103 {
104 m_log.DebugFormat("[LIBRARY MODULE]: could not add folder {0} because parent folder {1} not found", folder.Name, folder.ParentID);
105 return false;
106 }
107  
108 parent.CreateChildFolder(folder.ID, folder.Name, (ushort)folder.Type);
109  
110 return true;
111 }
112  
113 /// <summary>
114 /// Add a new item to the user's inventory
115 /// </summary>
116 /// <param name="item"></param>
117 /// <returns>true if the item was successfully added</returns>
118 public bool AddItem(InventoryItemBase item)
119 {
120 //m_log.DebugFormat("[LIBRARY MODULE]: Adding item {0} to {1}", item.Name, item.Folder);
121 InventoryFolderImpl folder = m_Library;
122 if (m_Library.ID != item.Folder)
123 folder = m_Library.FindFolder(item.Folder);
124  
125 if (folder == null)
126 {
127 m_log.DebugFormat("[LIBRARY MODULE]: could not add item {0} because folder {1} not found", item.Name, item.Folder);
128 return false;
129 }
130  
131 folder.Items.Add(item.ID, item);
132 return true;
133 }
134  
135 public bool CreateUserInventory(UUID user) { return false; }
136  
137 /// <summary>
138 /// Gets the skeleton of the inventory -- folders only
139 /// </summary>
140 /// <param name="userId"></param>
141 /// <returns></returns>
142 public List<InventoryFolderBase> GetInventorySkeleton(UUID userId) { return null; }
143  
144 /// <summary>
145 /// Gets the user folder for the given folder-type
146 /// </summary>
147 /// <param name="userID"></param>
148 /// <param name="type"></param>
149 /// <returns></returns>
150 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) { return null; }
151  
152  
153 /// <summary>
154 /// Gets the items inside a folder
155 /// </summary>
156 /// <param name="userID"></param>
157 /// <param name="folderID"></param>
158 /// <returns></returns>
159 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) { return null; }
160  
161  
162 /// <summary>
163 /// Update a folder in the user's inventory
164 /// </summary>
165 /// <param name="folder"></param>
166 /// <returns>true if the folder was successfully updated</returns>
167 public bool UpdateFolder(InventoryFolderBase folder) { return false; }
168  
169 /// <summary>
170 /// Move an inventory folder to a new location
171 /// </summary>
172 /// <param name="folder">A folder containing the details of the new location</param>
173 /// <returns>true if the folder was successfully moved</returns>
174 public bool MoveFolder(InventoryFolderBase folder) { return false; }
175  
176 /// <summary>
177 /// Delete an item from the user's inventory
178 /// </summary>
179 /// <param name="item"></param>
180 /// <returns>true if the item was successfully deleted</returns>
181 //bool DeleteItem(InventoryItemBase item);
182 public bool DeleteFolders(UUID userID, List<UUID> folderIDs) { return false; }
183  
184 /// <summary>
185 /// Purge an inventory folder of all its items and subfolders.
186 /// </summary>
187 /// <param name="folder"></param>
188 /// <returns>true if the folder was successfully purged</returns>
189 public bool PurgeFolder(InventoryFolderBase folder) { return false; }
190  
191  
192 /// <summary>
193 /// Update an item in the user's inventory
194 /// </summary>
195 /// <param name="item"></param>
196 /// <returns>true if the item was successfully updated</returns>
197 public bool UpdateItem(InventoryItemBase item) { return false; }
198  
199 public bool MoveItems(UUID ownerID, List<InventoryItemBase> items) { return false; }
200  
201 /// <summary>
202 /// Delete an item from the user's inventory
203 /// </summary>
204 /// <param name="item"></param>
205 /// <returns>true if the item was successfully deleted</returns>
206 //bool DeleteItem(InventoryItemBase item);
207 public bool DeleteItems(UUID userID, List<UUID> itemIDs) { return false; }
208  
209 /// <summary>
210 /// Get an item, given by its UUID
211 /// </summary>
212 /// <param name="item"></param>
213 /// <returns></returns>
214 public InventoryItemBase GetItem(InventoryItemBase item) { return null; }
215  
216 /// <summary>
217 /// Get a folder, given by its UUID
218 /// </summary>
219 /// <param name="folder"></param>
220 /// <returns></returns>
221 public InventoryFolderBase GetFolder(InventoryFolderBase folder) { return null; }
222  
223 /// <summary>
224 /// Does the given user have an inventory structure?
225 /// </summary>
226 /// <param name="userID"></param>
227 /// <returns></returns>
228 public bool HasInventoryForUser(UUID userID) { return false; }
229  
230 /// <summary>
231 /// Get the active gestures of the agent.
232 /// </summary>
233 /// <param name="userId"></param>
234 /// <returns></returns>
235 public List<InventoryItemBase> GetActiveGestures(UUID userId) { return null; }
236  
237 /// <summary>
238 /// Get the union of permissions of all inventory items
239 /// that hold the given assetID.
240 /// </summary>
241 /// <param name="userID"></param>
242 /// <param name="assetID"></param>
243 /// <returns>The permissions or 0 if no such asset is found in
244 /// the user's inventory</returns>
245 public int GetAssetPermissions(UUID userID, UUID assetID) { return 0; }
246 }
247 }