diff options
author | Justin Clarke Casey | 2008-07-31 17:32:13 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-07-31 17:32:13 +0000 |
commit | a62b906a7b77340c61c4d3b084c3d950cf5172ba (patch) | |
tree | a4a1481357f5387bd0827f1cc5e329b6eea2b325 /OpenSim/Framework/Communications/Cache | |
parent | * refactor: Change CachedUserInfo.HasInventory to HasReceivedInventory to mak... (diff) | |
download | opensim-SC_OLD-a62b906a7b77340c61c4d3b084c3d950cf5172ba.zip opensim-SC_OLD-a62b906a7b77340c61c4d3b084c3d950cf5172ba.tar.gz opensim-SC_OLD-a62b906a7b77340c61c4d3b084c3d950cf5172ba.tar.bz2 opensim-SC_OLD-a62b906a7b77340c61c4d3b084c3d950cf5172ba.tar.xz |
* allow inventory folders to be located by path
* first pass method impl
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 6 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | 58 |
2 files changed, 55 insertions, 9 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index d6e1715..025b934 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | |||
@@ -64,7 +64,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
64 | private readonly UserProfileData m_userProfile; | 64 | private readonly UserProfileData m_userProfile; |
65 | 65 | ||
66 | /// <summary> | 66 | /// <summary> |
67 | /// Has we received the user's inventory from the inventory service? | 67 | /// Have we received the user's inventory from the inventory service? |
68 | /// </summary> | 68 | /// </summary> |
69 | public bool HasReceivedInventory { get { return m_hasReceivedInventory; } } | 69 | public bool HasReceivedInventory { get { return m_hasReceivedInventory; } } |
70 | private bool m_hasReceivedInventory; | 70 | private bool m_hasReceivedInventory; |
@@ -85,9 +85,9 @@ namespace OpenSim.Framework.Communications.Cache | |||
85 | /// </summary> | 85 | /// </summary> |
86 | private IDictionary<LLUUID, IList<InventoryFolderImpl>> pendingCategorizationFolders | 86 | private IDictionary<LLUUID, IList<InventoryFolderImpl>> pendingCategorizationFolders |
87 | = new Dictionary<LLUUID, IList<InventoryFolderImpl>>(); | 87 | = new Dictionary<LLUUID, IList<InventoryFolderImpl>>(); |
88 | 88 | ||
89 | private LLUUID m_session_id = LLUUID.Zero; | ||
90 | public LLUUID SessionID { get { return m_session_id; } } | 89 | public LLUUID SessionID { get { return m_session_id; } } |
90 | private LLUUID m_session_id = LLUUID.Zero; | ||
91 | 91 | ||
92 | /// <summary> | 92 | /// <summary> |
93 | /// Constructor | 93 | /// Constructor |
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 0fbc427..b1fdf76 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | |||
@@ -25,6 +25,7 @@ | |||
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 | ||
28 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using libsecondlife; | 30 | using libsecondlife; |
30 | //using System.Reflection; | 31 | //using System.Reflection; |
@@ -36,12 +37,22 @@ namespace OpenSim.Framework.Communications.Cache | |||
36 | public class InventoryFolderImpl : InventoryFolderBase | 37 | public class InventoryFolderImpl : InventoryFolderBase |
37 | { | 38 | { |
38 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 39 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
40 | |||
41 | public static readonly string PATH_DELIMITER = "/"; | ||
39 | 42 | ||
40 | // Fields | 43 | /// <summary> |
44 | /// Items that are contained in this folder | ||
45 | /// </summary> | ||
41 | public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>(); | 46 | public Dictionary<LLUUID, InventoryItemBase> Items = new Dictionary<LLUUID, InventoryItemBase>(); |
47 | |||
48 | /// <summary> | ||
49 | /// Child folders that are contained in this folder | ||
50 | /// </summary> | ||
42 | public Dictionary<LLUUID, InventoryFolderImpl> SubFolders = new Dictionary<LLUUID, InventoryFolderImpl>(); | 51 | public Dictionary<LLUUID, InventoryFolderImpl> SubFolders = new Dictionary<LLUUID, InventoryFolderImpl>(); |
43 | 52 | ||
44 | // Accessors | 53 | /// <summary> |
54 | /// The number of child folders | ||
55 | /// </summary> | ||
45 | public int SubFoldersCount | 56 | public int SubFoldersCount |
46 | { | 57 | { |
47 | get { return SubFolders.Count; } | 58 | get { return SubFolders.Count; } |
@@ -177,9 +188,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
177 | public InventoryFolderImpl FindFolder(LLUUID folderID) | 188 | public InventoryFolderImpl FindFolder(LLUUID folderID) |
178 | { | 189 | { |
179 | if (folderID == ID) | 190 | if (folderID == ID) |
180 | { | ||
181 | return this; | 191 | return this; |
182 | } | ||
183 | 192 | ||
184 | lock (SubFolders) | 193 | lock (SubFolders) |
185 | { | 194 | { |
@@ -188,14 +197,51 @@ namespace OpenSim.Framework.Communications.Cache | |||
188 | InventoryFolderImpl returnFolder = folder.FindFolder(folderID); | 197 | InventoryFolderImpl returnFolder = folder.FindFolder(folderID); |
189 | 198 | ||
190 | if (returnFolder != null) | 199 | if (returnFolder != null) |
191 | { | ||
192 | return returnFolder; | 200 | return returnFolder; |
193 | } | ||
194 | } | 201 | } |
195 | } | 202 | } |
196 | 203 | ||
197 | return null; | 204 | return null; |
198 | } | 205 | } |
206 | |||
207 | /// <summary> | ||
208 | /// Find a folder given a PATH_DELIMITOR delimited path. | ||
209 | /// | ||
210 | /// This method does not handle paths that contain multiple delimitors | ||
211 | /// | ||
212 | /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some | ||
213 | /// XPath like expression | ||
214 | /// | ||
215 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. | ||
216 | /// </summary> | ||
217 | /// <param name="path"> | ||
218 | /// The path to the required folder. It this is empty then this folder itself is returned. | ||
219 | /// If a folder for the given path is not found, then null is returned. | ||
220 | /// </param> | ||
221 | /// <returns></returns> | ||
222 | public InventoryFolderImpl FindFolderByPath(string path) | ||
223 | { | ||
224 | if (path == string.Empty) | ||
225 | return this; | ||
226 | |||
227 | int delimitorIndex = path.IndexOf(PATH_DELIMITER); | ||
228 | string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); | ||
229 | |||
230 | lock (SubFolders) | ||
231 | { | ||
232 | foreach (InventoryFolderImpl folder in SubFolders.Values) | ||
233 | { | ||
234 | if (folder.Name == components[0]) | ||
235 | if (components.Length > 1) | ||
236 | return folder.FindFolderByPath(components[1]); | ||
237 | else | ||
238 | return folder; | ||
239 | } | ||
240 | } | ||
241 | |||
242 | // We didn't find a folder with the given name | ||
243 | return null; | ||
244 | } | ||
199 | 245 | ||
200 | /// <summary> | 246 | /// <summary> |
201 | /// Return the list of child items in this folder | 247 | /// Return the list of child items in this folder |