diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/InventoryService/LibraryService.cs (renamed from OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs) | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Services/InventoryService/LibraryService.cs index 74ba0a5..383f311 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Services/InventoryService/LibraryService.cs | |||
@@ -30,20 +30,32 @@ using System.Collections.Generic; | |||
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Xml; | 32 | using System.Xml; |
33 | |||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Services.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | |||
33 | using log4net; | 38 | using log4net; |
34 | using Nini.Config; | 39 | using Nini.Config; |
35 | using OpenMetaverse; | 40 | using OpenMetaverse; |
36 | 41 | ||
37 | namespace OpenSim.Framework.Communications.Cache | 42 | namespace OpenSim.Services.InventoryService |
38 | { | 43 | { |
39 | /// <summary> | 44 | /// <summary> |
40 | /// Basically a hack to give us a Inventory library while we don't have a inventory server | 45 | /// Basically a hack to give us a Inventory library while we don't have a inventory server |
41 | /// once the server is fully implemented then should read the data from that | 46 | /// once the server is fully implemented then should read the data from that |
42 | /// </summary> | 47 | /// </summary> |
43 | public class LibraryRootFolder : InventoryFolderImpl | 48 | public class LibraryService : ServiceBase, ILibraryService |
44 | { | 49 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 51 | ||
52 | private InventoryFolderImpl m_LibraryRootFolder; | ||
53 | |||
54 | public InventoryFolderImpl LibraryRootFolder | ||
55 | { | ||
56 | get { return m_LibraryRootFolder; } | ||
57 | } | ||
58 | |||
47 | private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000"); | 59 | private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000"); |
48 | 60 | ||
49 | /// <summary> | 61 | /// <summary> |
@@ -52,17 +64,31 @@ namespace OpenSim.Framework.Communications.Cache | |||
52 | /// </summary> | 64 | /// </summary> |
53 | protected Dictionary<UUID, InventoryFolderImpl> libraryFolders | 65 | protected Dictionary<UUID, InventoryFolderImpl> libraryFolders |
54 | = new Dictionary<UUID, InventoryFolderImpl>(); | 66 | = new Dictionary<UUID, InventoryFolderImpl>(); |
55 | 67 | ||
56 | public LibraryRootFolder(string pLibrariesLocation) | 68 | public LibraryService(IConfigSource config) |
69 | : base(config) | ||
57 | { | 70 | { |
58 | Owner = libOwner; | 71 | string pLibrariesLocation = Path.Combine("inventory", "Libraries.xml"); |
59 | ID = new UUID("00000112-000f-0000-0000-000100bba000"); | 72 | string pLibName = "OpenSim Library"; |
60 | Name = "OpenSim Library"; | 73 | |
61 | ParentID = UUID.Zero; | 74 | IConfig libConfig = config.Configs["LibraryService"]; |
62 | Type = (short) 8; | 75 | if (libConfig != null) |
63 | Version = (ushort) 1; | 76 | { |
77 | pLibrariesLocation = libConfig.GetString("DefaultLibrary", pLibrariesLocation); | ||
78 | pLibName = libConfig.GetString("LibraryName", pLibName); | ||
79 | } | ||
80 | |||
81 | m_log.Debug("[LIBRARY]: Starting library service..."); | ||
82 | |||
83 | m_LibraryRootFolder = new InventoryFolderImpl(); | ||
84 | m_LibraryRootFolder.Owner = libOwner; | ||
85 | m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000"); | ||
86 | m_LibraryRootFolder.Name = pLibName; | ||
87 | m_LibraryRootFolder.ParentID = UUID.Zero; | ||
88 | m_LibraryRootFolder.Type = (short)8; | ||
89 | m_LibraryRootFolder.Version = (ushort)1; | ||
64 | 90 | ||
65 | libraryFolders.Add(ID, this); | 91 | libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); |
66 | 92 | ||
67 | LoadLibraries(pLibrariesLocation); | 93 | LoadLibraries(pLibrariesLocation); |
68 | } | 94 | } |
@@ -126,9 +152,9 @@ namespace OpenSim.Framework.Communications.Cache | |||
126 | { | 152 | { |
127 | InventoryFolderImpl folderInfo = new InventoryFolderImpl(); | 153 | InventoryFolderImpl folderInfo = new InventoryFolderImpl(); |
128 | 154 | ||
129 | folderInfo.ID = new UUID(config.GetString("folderID", ID.ToString())); | 155 | folderInfo.ID = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); |
130 | folderInfo.Name = config.GetString("name", "unknown"); | 156 | folderInfo.Name = config.GetString("name", "unknown"); |
131 | folderInfo.ParentID = new UUID(config.GetString("parentFolderID", ID.ToString())); | 157 | folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString())); |
132 | folderInfo.Type = (short)config.GetInt("type", 8); | 158 | folderInfo.Type = (short)config.GetInt("type", 8); |
133 | 159 | ||
134 | folderInfo.Owner = libOwner; | 160 | folderInfo.Owner = libOwner; |
@@ -160,9 +186,9 @@ namespace OpenSim.Framework.Communications.Cache | |||
160 | InventoryItemBase item = new InventoryItemBase(); | 186 | InventoryItemBase item = new InventoryItemBase(); |
161 | item.Owner = libOwner; | 187 | item.Owner = libOwner; |
162 | item.CreatorId = libOwner.ToString(); | 188 | item.CreatorId = libOwner.ToString(); |
163 | item.ID = new UUID(config.GetString("inventoryID", ID.ToString())); | 189 | item.ID = new UUID(config.GetString("inventoryID", m_LibraryRootFolder.ID.ToString())); |
164 | item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); | 190 | item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); |
165 | item.Folder = new UUID(config.GetString("folderID", ID.ToString())); | 191 | item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); |
166 | item.Name = config.GetString("name", String.Empty); | 192 | item.Name = config.GetString("name", String.Empty); |
167 | item.Description = config.GetString("description", item.Name); | 193 | item.Description = config.GetString("description", item.Name); |
168 | item.InvType = config.GetInt("inventoryType", 0); | 194 | item.InvType = config.GetInt("inventoryType", 0); |
@@ -230,11 +256,11 @@ namespace OpenSim.Framework.Communications.Cache | |||
230 | /// methods in the superclass | 256 | /// methods in the superclass |
231 | /// </summary> | 257 | /// </summary> |
232 | /// <returns></returns> | 258 | /// <returns></returns> |
233 | public Dictionary<UUID, InventoryFolderImpl> RequestSelfAndDescendentFolders() | 259 | public Dictionary<UUID, InventoryFolderImpl> GetAllFolders() |
234 | { | 260 | { |
235 | Dictionary<UUID, InventoryFolderImpl> fs = new Dictionary<UUID, InventoryFolderImpl>(); | 261 | Dictionary<UUID, InventoryFolderImpl> fs = new Dictionary<UUID, InventoryFolderImpl>(); |
236 | fs.Add(ID, this); | 262 | fs.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); |
237 | List<InventoryFolderImpl> fis = TraverseFolder(this); | 263 | List<InventoryFolderImpl> fis = TraverseFolder(m_LibraryRootFolder); |
238 | foreach (InventoryFolderImpl f in fis) | 264 | foreach (InventoryFolderImpl f in fis) |
239 | { | 265 | { |
240 | fs.Add(f.ID, f); | 266 | fs.Add(f.ID, f); |