OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
LocalInventoryService.cs
Go to the documentation of this file.
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 {
41  {
42  private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 
44  private InventoryFolderImpl m_Library;
45 
47  {
48  m_Library = lib;
49  }
50 
56  public InventoryFolderBase GetRootFolder(UUID userID) { return m_Library; }
57 
64  public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
65  {
66  InventoryFolderImpl folder = null;
68  inv.OwnerID = 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  public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
91  {
92  InventoryCollection[] invColl = new InventoryCollection[folderIDs.Length];
93  int i = 0;
94  foreach (UUID fid in folderIDs)
95  {
96  invColl[i++] = GetFolderContent(principalID, fid);
97  }
98 
99  return invColl;
100  }
101 
102  public virtual InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs)
103  {
104  InventoryItemBase[] itemColl = new InventoryItemBase[itemIDs.Length];
105  int i = 0;
107  item.Owner = principalID;
108  foreach (UUID fid in itemIDs)
109  {
110  item.ID = fid;
111  itemColl[i++] = GetItem(item);
112  }
113 
114  return itemColl;
115  }
116 
117 
123  public bool AddFolder(InventoryFolderBase folder)
124  {
125  //m_log.DebugFormat("[LIBRARY MODULE]: Adding folder {0} ({1}) to {2}", folder.Name, folder.ID, folder.ParentID);
126  InventoryFolderImpl parent = m_Library;
127  if (m_Library.ID != folder.ParentID)
128  parent = m_Library.FindFolder(folder.ParentID);
129 
130  if (parent == null)
131  {
132  m_log.DebugFormat("[LIBRARY MODULE]: could not add folder {0} because parent folder {1} not found", folder.Name, folder.ParentID);
133  return false;
134  }
135 
136  parent.CreateChildFolder(folder.ID, folder.Name, (ushort)folder.Type);
137 
138  return true;
139  }
140 
146  public bool AddItem(InventoryItemBase item)
147  {
148  //m_log.DebugFormat("[LIBRARY MODULE]: Adding item {0} to {1}", item.Name, item.Folder);
149  InventoryFolderImpl folder = m_Library;
150  if (m_Library.ID != item.Folder)
151  folder = m_Library.FindFolder(item.Folder);
152 
153  if (folder == null)
154  {
155  m_log.DebugFormat("[LIBRARY MODULE]: could not add item {0} because folder {1} not found", item.Name, item.Folder);
156  return false;
157  }
158 
159  folder.Items.Add(item.ID, item);
160  return true;
161  }
162 
163  public bool CreateUserInventory(UUID user) { return false; }
164 
170  public List<InventoryFolderBase> GetInventorySkeleton(UUID userId) { return null; }
171 
178  public InventoryFolderBase GetFolderForType(UUID userID, FolderType type) { return null; }
179 
180 
187  public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) { return null; }
188 
189 
195  public bool UpdateFolder(InventoryFolderBase folder) { return false; }
196 
202  public bool MoveFolder(InventoryFolderBase folder) { return false; }
203 
209  //bool DeleteItem(InventoryItemBase item);
210  public bool DeleteFolders(UUID userID, List<UUID> folderIDs) { return false; }
211 
217  public bool PurgeFolder(InventoryFolderBase folder) { return false; }
218 
219 
225  public bool UpdateItem(InventoryItemBase item) { return false; }
226 
227  public bool MoveItems(UUID ownerID, List<InventoryItemBase> items) { return false; }
228 
234  //bool DeleteItem(InventoryItemBase item);
235  public bool DeleteItems(UUID userID, List<UUID> itemIDs) { return false; }
236 
242  public InventoryItemBase GetItem(InventoryItemBase item) { return null; }
243 
249  public InventoryFolderBase GetFolder(InventoryFolderBase folder) { return null; }
250 
256  public bool HasInventoryForUser(UUID userID) { return false; }
257 
263  public List<InventoryItemBase> GetActiveGestures(UUID userId) { return null; }
264 
273  public int GetAssetPermissions(UUID userID, UUID assetID) { return 0; }
274  }
275 }
List< InventoryFolderBase > GetInventorySkeleton(UUID userId)
Gets the skeleton of the inventory – folders only
List< InventoryItemBase > GetActiveGestures(UUID userId)
Get the active gestures of the agent.
bool AddFolder(InventoryFolderBase folder)
Add a new folder to the user's inventory
bool MoveFolder(InventoryFolderBase folder)
Move an inventory folder to a new location
bool HasInventoryForUser(UUID userID)
Does the given user have an inventory structure?
virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
Gets everything (folders and items) inside a folder
bool CreateUserInventory(UUID user)
Create the entire inventory for a given user
bool UpdateItem(InventoryItemBase item)
Update an item in the user's inventory
virtual InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs)
Get multiple items, given by their UUIDs
InventoryItemBase GetItem(InventoryItemBase item)
Get an item, given by its UUID
bool DeleteFolders(UUID userID, List< UUID > folderIDs)
Delete an item from the user's inventory
bool PurgeFolder(InventoryFolderBase folder)
Purge an inventory folder of all its items and subfolders.
InventoryFolderBase GetRootFolder(UUID userID)
Retrieve the root inventory folder for the given user.
Inventory Item - contains all the properties associated with an individual inventory piece...
InventoryCollection GetFolderContent(UUID userID, UUID folderID)
Gets everything (folders and items) inside a folder
int GetAssetPermissions(UUID userID, UUID assetID)
Get the union of permissions of all inventory items that hold the given assetID.
bool DeleteItems(UUID userID, List< UUID > itemIDs)
Delete an item from the user's inventory
bool AddItem(InventoryItemBase item)
Add a new item to the user's inventory
InventoryFolderBase GetFolderForType(UUID userID, FolderType type)
Gets the user folder for the given folder-type
InventoryFolderBase GetFolder(InventoryFolderBase folder)
Get a folder, given by its UUID
bool UpdateFolder(InventoryFolderBase folder)
Update a folder in the user's inventory
List< InventoryItemBase > GetFolderItems(UUID userID, UUID folderID)
Gets the items inside a folder
bool MoveItems(UUID ownerID, List< InventoryItemBase > items)
Used to serialize a whole inventory for transfer over the network.