diff options
author | Diva Canto | 2011-12-29 15:33:04 -0800 |
---|---|---|
committer | Diva Canto | 2011-12-29 15:33:04 -0800 |
commit | 98ab3dffa35a007986a43fd15b9ce93202c92ef5 (patch) | |
tree | ff0b8fcb3ed224d29d80b5ce4d0e2163cf45853c /OpenSim/Region | |
parent | Deleted unused methods from HGAssetBroker (diff) | |
download | opensim-SC_OLD-98ab3dffa35a007986a43fd15b9ce93202c92ef5.zip opensim-SC_OLD-98ab3dffa35a007986a43fd15b9ce93202c92ef5.tar.gz opensim-SC_OLD-98ab3dffa35a007986a43fd15b9ce93202c92ef5.tar.bz2 opensim-SC_OLD-98ab3dffa35a007986a43fd15b9ce93202c92ef5.tar.xz |
Deleted two obsolete files in Inventory modules.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs | 223 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs | 237 |
2 files changed, 0 insertions, 460 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs deleted file mode 100644 index dcf08e3..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs +++ /dev/null | |||
@@ -1,223 +0,0 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using Nini.Config; | ||
32 | using log4net; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Services.Interfaces; | ||
35 | |||
36 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | ||
37 | { | ||
38 | public abstract class BaseInventoryConnector : IInventoryService | ||
39 | { | ||
40 | protected static InventoryCache m_cache; | ||
41 | private static bool m_Initialized; | ||
42 | |||
43 | protected virtual void Init(IConfigSource source) | ||
44 | { | ||
45 | if (!m_Initialized) | ||
46 | { | ||
47 | m_cache = new InventoryCache(); | ||
48 | m_cache.Init(source, this); | ||
49 | m_Initialized = true; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | /// <summary> | ||
54 | /// Create the entire inventory for a given user | ||
55 | /// </summary> | ||
56 | /// <param name="user"></param> | ||
57 | /// <returns></returns> | ||
58 | public abstract bool CreateUserInventory(UUID user); | ||
59 | |||
60 | /// <summary> | ||
61 | /// Gets the skeleton of the inventory -- folders only | ||
62 | /// </summary> | ||
63 | /// <param name="userId"></param> | ||
64 | /// <returns></returns> | ||
65 | public abstract List<InventoryFolderBase> GetInventorySkeleton(UUID userId); | ||
66 | |||
67 | /// <summary> | ||
68 | /// Synchronous inventory fetch. | ||
69 | /// </summary> | ||
70 | /// <param name="userID"></param> | ||
71 | /// <returns></returns> | ||
72 | public abstract InventoryCollection GetUserInventory(UUID userID); | ||
73 | |||
74 | /// <summary> | ||
75 | /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the | ||
76 | /// inventory has been received | ||
77 | /// </summary> | ||
78 | /// <param name="userID"></param> | ||
79 | /// <param name="callback"></param> | ||
80 | public abstract void GetUserInventory(UUID userID, InventoryReceiptCallback callback); | ||
81 | |||
82 | /// <summary> | ||
83 | /// Retrieve the root inventory folder for the given user. | ||
84 | /// </summary> | ||
85 | /// <param name="userID"></param> | ||
86 | /// <returns>null if no root folder was found</returns> | ||
87 | public InventoryFolderBase GetRootFolder(UUID userID) | ||
88 | { | ||
89 | // Root folder is here as system type Folder. | ||
90 | return m_cache.GetFolderForType(userID, AssetType.Folder); | ||
91 | } | ||
92 | |||
93 | public abstract Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID); | ||
94 | |||
95 | /// <summary> | ||
96 | /// Gets the user folder for the given folder-type | ||
97 | /// </summary> | ||
98 | /// <param name="userID"></param> | ||
99 | /// <param name="type"></param> | ||
100 | /// <returns></returns> | ||
101 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | ||
102 | { | ||
103 | return m_cache.GetFolderForType(userID, type); | ||
104 | } | ||
105 | |||
106 | /// <summary> | ||
107 | /// Gets everything (folders and items) inside a folder | ||
108 | /// </summary> | ||
109 | /// <param name="userId"></param> | ||
110 | /// <param name="folderID"></param> | ||
111 | /// <returns></returns> | ||
112 | public abstract InventoryCollection GetFolderContent(UUID userID, UUID folderID); | ||
113 | |||
114 | /// <summary> | ||
115 | /// Gets the items inside a folder | ||
116 | /// </summary> | ||
117 | /// <param name="userID"></param> | ||
118 | /// <param name="folderID"></param> | ||
119 | /// <returns></returns> | ||
120 | public abstract List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID); | ||
121 | |||
122 | /// <summary> | ||
123 | /// Add a new folder to the user's inventory | ||
124 | /// </summary> | ||
125 | /// <param name="folder"></param> | ||
126 | /// <returns>true if the folder was successfully added</returns> | ||
127 | public abstract bool AddFolder(InventoryFolderBase folder); | ||
128 | |||
129 | /// <summary> | ||
130 | /// Update a folder in the user's inventory | ||
131 | /// </summary> | ||
132 | /// <param name="folder"></param> | ||
133 | /// <returns>true if the folder was successfully updated</returns> | ||
134 | public abstract bool UpdateFolder(InventoryFolderBase folder); | ||
135 | |||
136 | /// <summary> | ||
137 | /// Move an inventory folder to a new location | ||
138 | /// </summary> | ||
139 | /// <param name="folder">A folder containing the details of the new location</param> | ||
140 | /// <returns>true if the folder was successfully moved</returns> | ||
141 | public abstract bool MoveFolder(InventoryFolderBase folder); | ||
142 | |||
143 | /// <summary> | ||
144 | /// Delete a list of inventory folders (from trash) | ||
145 | /// </summary> | ||
146 | public abstract bool DeleteFolders(UUID ownerID, List<UUID> folderIDs); | ||
147 | |||
148 | /// <summary> | ||
149 | /// Purge an inventory folder of all its items and subfolders. | ||
150 | /// </summary> | ||
151 | /// <param name="folder"></param> | ||
152 | /// <returns>true if the folder was successfully purged</returns> | ||
153 | public abstract bool PurgeFolder(InventoryFolderBase folder); | ||
154 | |||
155 | /// <summary> | ||
156 | /// Add a new item to the user's inventory. | ||
157 | /// If the given item has to parent folder, it tries to find the most | ||
158 | /// suitable folder for it. | ||
159 | /// </summary> | ||
160 | /// <param name="item"></param> | ||
161 | /// <returns>true if the item was successfully added</returns> | ||
162 | public bool AddItem(InventoryItemBase item) | ||
163 | { | ||
164 | if (item == null) | ||
165 | return false; | ||
166 | |||
167 | if (item.Folder == UUID.Zero) | ||
168 | { | ||
169 | InventoryFolderBase f = GetFolderForType(item.Owner, (AssetType)item.AssetType); | ||
170 | if (f != null) | ||
171 | item.Folder = f.ID; | ||
172 | else | ||
173 | { | ||
174 | f = GetRootFolder(item.Owner); | ||
175 | if (f != null) | ||
176 | item.Folder = f.ID; | ||
177 | else | ||
178 | return false; | ||
179 | } | ||
180 | } | ||
181 | |||
182 | return AddItemPlain(item); | ||
183 | } | ||
184 | |||
185 | protected abstract bool AddItemPlain(InventoryItemBase item); | ||
186 | |||
187 | /// <summary> | ||
188 | /// Update an item in the user's inventory | ||
189 | /// </summary> | ||
190 | /// <param name="item"></param> | ||
191 | /// <returns>true if the item was successfully updated</returns> | ||
192 | public abstract bool UpdateItem(InventoryItemBase item); | ||
193 | |||
194 | public abstract bool MoveItems(UUID ownerID, List<InventoryItemBase> items); | ||
195 | |||
196 | /// <summary> | ||
197 | /// Delete an item from the user's inventory | ||
198 | /// </summary> | ||
199 | /// <param name="item"></param> | ||
200 | /// <returns>true if the item was successfully deleted</returns> | ||
201 | public abstract bool DeleteItems(UUID ownerID, List<UUID> itemIDs); | ||
202 | |||
203 | public abstract InventoryItemBase GetItem(InventoryItemBase item); | ||
204 | |||
205 | public abstract InventoryFolderBase GetFolder(InventoryFolderBase folder); | ||
206 | |||
207 | /// <summary> | ||
208 | /// Does the given user have an inventory structure? | ||
209 | /// </summary> | ||
210 | /// <param name="userID"></param> | ||
211 | /// <returns></returns> | ||
212 | public abstract bool HasInventoryForUser(UUID userID); | ||
213 | |||
214 | /// <summary> | ||
215 | /// Get the active gestures of the agent. | ||
216 | /// </summary> | ||
217 | /// <param name="userId"></param> | ||
218 | /// <returns></returns> | ||
219 | public abstract List<InventoryItemBase> GetActiveGestures(UUID userId); | ||
220 | |||
221 | public abstract int GetAssetPermissions(UUID userID, UUID assetID); | ||
222 | } | ||
223 | } | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs deleted file mode 100644 index 2322d7c..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ /dev/null | |||
@@ -1,237 +0,0 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | |||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Client; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | |||
36 | using OpenMetaverse; | ||
37 | using Nini.Config; | ||
38 | using log4net; | ||
39 | |||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | ||
41 | { | ||
42 | public class InventoryCache | ||
43 | { | ||
44 | private static readonly ILog m_log = | ||
45 | LogManager.GetLogger( | ||
46 | MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | protected BaseInventoryConnector m_Connector; | ||
49 | protected List<Scene> m_Scenes; | ||
50 | |||
51 | // The cache proper | ||
52 | protected Dictionary<UUID, Dictionary<AssetType, InventoryFolderBase>> m_InventoryCache; | ||
53 | |||
54 | // A cache of userIDs --> ServiceURLs, for HGBroker only | ||
55 | protected Dictionary<UUID, string> m_InventoryURLs = | ||
56 | new Dictionary<UUID, string>(); | ||
57 | |||
58 | public virtual void Init(IConfigSource source, BaseInventoryConnector connector) | ||
59 | { | ||
60 | m_Scenes = new List<Scene>(); | ||
61 | m_InventoryCache = new Dictionary<UUID, Dictionary<AssetType, InventoryFolderBase>>(); | ||
62 | m_Connector = connector; | ||
63 | } | ||
64 | |||
65 | public virtual void AddRegion(Scene scene) | ||
66 | { | ||
67 | m_Scenes.Add(scene); | ||
68 | scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; | ||
69 | scene.EventManager.OnClientClosed += OnClientClosed; | ||
70 | } | ||
71 | |||
72 | public virtual void RemoveRegion(Scene scene) | ||
73 | { | ||
74 | if ((m_Scenes != null) && m_Scenes.Contains(scene)) | ||
75 | { | ||
76 | m_Scenes.Remove(scene); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | void OnMakeRootAgent(ScenePresence presence) | ||
81 | { | ||
82 | // Get system folders | ||
83 | |||
84 | // First check if they're here already | ||
85 | lock (m_InventoryCache) | ||
86 | { | ||
87 | if (m_InventoryCache.ContainsKey(presence.UUID)) | ||
88 | { | ||
89 | m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent, system folders for {0} {1} already in cache", presence.Firstname, presence.Lastname); | ||
90 | return; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | // If not, go get them and place them in the cache | ||
95 | Dictionary<AssetType, InventoryFolderBase> folders = CacheSystemFolders(presence.UUID); | ||
96 | CacheInventoryServiceURL(presence.Scene, presence.UUID); | ||
97 | |||
98 | m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent in {0}, fetched system folders for {1} {2}: count {3}", | ||
99 | presence.Scene.RegionInfo.RegionName, presence.Firstname, presence.Lastname, folders.Count); | ||
100 | |||
101 | } | ||
102 | |||
103 | void OnClientClosed(UUID clientID, Scene scene) | ||
104 | { | ||
105 | if (m_InventoryCache.ContainsKey(clientID)) // if it's still in cache | ||
106 | { | ||
107 | ScenePresence sp = null; | ||
108 | foreach (Scene s in m_Scenes) | ||
109 | { | ||
110 | s.TryGetScenePresence(clientID, out sp); | ||
111 | if ((sp != null) && !sp.IsChildAgent && (s != scene)) | ||
112 | { | ||
113 | m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping system folders in cache", | ||
114 | scene.RegionInfo.RegionName, clientID); | ||
115 | return; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | m_log.DebugFormat( | ||
120 | "[INVENTORY CACHE]: OnClientClosed in {0}, user {1} out of sim. Dropping system folders", | ||
121 | scene.RegionInfo.RegionName, clientID); | ||
122 | DropCachedSystemFolders(clientID); | ||
123 | DropInventoryServiceURL(clientID); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// Cache a user's 'system' folders. | ||
129 | /// </summary> | ||
130 | /// <param name="userID"></param> | ||
131 | /// <returns>Folders cached</returns> | ||
132 | protected Dictionary<AssetType, InventoryFolderBase> CacheSystemFolders(UUID userID) | ||
133 | { | ||
134 | // If not, go get them and place them in the cache | ||
135 | Dictionary<AssetType, InventoryFolderBase> folders = m_Connector.GetSystemFolders(userID); | ||
136 | |||
137 | if (folders.Count > 0) | ||
138 | lock (m_InventoryCache) | ||
139 | m_InventoryCache.Add(userID, folders); | ||
140 | |||
141 | return folders; | ||
142 | } | ||
143 | |||
144 | /// <summary> | ||
145 | /// Drop a user's cached 'system' folders | ||
146 | /// </summary> | ||
147 | /// <param name="userID"></param> | ||
148 | protected void DropCachedSystemFolders(UUID userID) | ||
149 | { | ||
150 | // Drop system folders | ||
151 | lock (m_InventoryCache) | ||
152 | if (m_InventoryCache.ContainsKey(userID)) | ||
153 | m_InventoryCache.Remove(userID); | ||
154 | } | ||
155 | |||
156 | /// <summary> | ||
157 | /// Get the system folder for a particular asset type | ||
158 | /// </summary> | ||
159 | /// <param name="userID"></param> | ||
160 | /// <param name="type"></param> | ||
161 | /// <returns></returns> | ||
162 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | ||
163 | { | ||
164 | m_log.DebugFormat("[INVENTORY CACHE]: Getting folder for asset type {0} for user {1}", type, userID); | ||
165 | |||
166 | Dictionary<AssetType, InventoryFolderBase> folders = null; | ||
167 | |||
168 | lock (m_InventoryCache) | ||
169 | { | ||
170 | m_InventoryCache.TryGetValue(userID, out folders); | ||
171 | |||
172 | // In some situations (such as non-secured standalones), system folders can be requested without | ||
173 | // the user being logged in. So we need to try caching them here if we don't already have them. | ||
174 | if (null == folders) | ||
175 | CacheSystemFolders(userID); | ||
176 | |||
177 | m_InventoryCache.TryGetValue(userID, out folders); | ||
178 | } | ||
179 | |||
180 | if ((folders != null) && folders.ContainsKey(type)) | ||
181 | { | ||
182 | m_log.DebugFormat( | ||
183 | "[INVENTORY CACHE]: Returning folder {0} as type {1} for {2}", folders[type], type, userID); | ||
184 | |||
185 | return folders[type]; | ||
186 | } | ||
187 | |||
188 | m_log.WarnFormat("[INVENTORY CACHE]: Could not find folder for system type {0} for {1}", type, userID); | ||
189 | |||
190 | return null; | ||
191 | } | ||
192 | |||
193 | /// <summary> | ||
194 | /// Gets the user's inventory URL from its serviceURLs, if the user is foreign, | ||
195 | /// and sticks it in the cache | ||
196 | /// </summary> | ||
197 | /// <param name="userID"></param> | ||
198 | private void CacheInventoryServiceURL(Scene scene, UUID userID) | ||
199 | { | ||
200 | if (scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID) == null) | ||
201 | { | ||
202 | // The user does not have a local account; let's cache its service URL | ||
203 | string inventoryURL = string.Empty; | ||
204 | ScenePresence sp = null; | ||
205 | scene.TryGetScenePresence(userID, out sp); | ||
206 | if (sp != null) | ||
207 | { | ||
208 | AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | ||
209 | if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI")) | ||
210 | { | ||
211 | inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString(); | ||
212 | if (inventoryURL != null && inventoryURL != string.Empty) | ||
213 | { | ||
214 | inventoryURL = inventoryURL.Trim(new char[] { '/' }); | ||
215 | m_InventoryURLs.Add(userID, inventoryURL); | ||
216 | } | ||
217 | } | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | |||
222 | private void DropInventoryServiceURL(UUID userID) | ||
223 | { | ||
224 | lock (m_InventoryURLs) | ||
225 | if (m_InventoryURLs.ContainsKey(userID)) | ||
226 | m_InventoryURLs.Remove(userID); | ||
227 | } | ||
228 | |||
229 | public string GetInventoryServiceURL(UUID userID) | ||
230 | { | ||
231 | if (m_InventoryURLs.ContainsKey(userID)) | ||
232 | return m_InventoryURLs[userID]; | ||
233 | |||
234 | return null; | ||
235 | } | ||
236 | } | ||
237 | } | ||