diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 0ec2ed56f9..25026a6102 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -6962,7 +6962,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP assetRequestItem = invService.GetItem(assetRequestItem); if (assetRequestItem == null) { - assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); + ILibraryService lib = m_scene.RequestModuleInterface(); + if (lib != null) + assetRequestItem = lib.LibraryRootFolder.FindItem(itemID); if (assetRequestItem == null) return true; } diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index 6941e009cd..f1022fd7dd 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs @@ -37,6 +37,7 @@ using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using OpenSim.Server.Base; using OpenMetaverse; using log4net; @@ -53,6 +54,8 @@ namespace OpenSim.Region.CoreModules.Framework.Library private string m_LibraryName = "OpenSim Library"; private Scene m_Scene; + private ILibraryService m_Library; + #region ISharedRegionModule public void Initialise(IConfigSource config) @@ -60,9 +63,22 @@ namespace OpenSim.Region.CoreModules.Framework.Library m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); if (m_Enabled) { - IConfig libConfig = config.Configs["LibraryModule"]; + IConfig libConfig = config.Configs["LibraryService"]; if (libConfig != null) - m_LibraryName = libConfig.GetString("LibraryName", m_LibraryName); + { + string dllName = libConfig.GetString("LocalServiceModule", string.Empty); + m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName); + if (dllName != string.Empty) + { + Object[] args = new Object[] { config }; + m_Library = ServerUtils.LoadPlugin(dllName, args); + } + } + } + if (m_Library == null) + { + m_log.Warn("[LIBRARY MODULE]: No local library service. Module will be disabled."); + m_Enabled = false; } } @@ -91,10 +107,15 @@ namespace OpenSim.Region.CoreModules.Framework.Library { m_Scene = scene; } + scene.RegisterModuleInterface(m_Library); } public void RemoveRegion(Scene scene) { + if (!m_Enabled) + return; + + scene.UnregisterModuleInterface(m_Library); } public void RegionLoaded(Scene scene) @@ -127,19 +148,17 @@ namespace OpenSim.Region.CoreModules.Framework.Library protected void LoadLibrariesFromArchives() { - InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot; + InventoryFolderImpl lib = m_Library.LibraryRootFolder; if (lib == null) { m_log.Debug("[LIBRARY MODULE]: No library. Ignoring Library Module"); return; } - lib.Name = m_LibraryName; - RegionInfo regInfo = new RegionInfo(); Scene m_MockScene = new Scene(regInfo); m_MockScene.CommsManager = m_Scene.CommsManager; - LocalInventoryService invService = new LocalInventoryService((LibraryRootFolder)lib); + LocalInventoryService invService = new LocalInventoryService(lib); m_MockScene.RegisterModuleInterface(invService); m_MockScene.RegisterModuleInterface(m_Scene.AssetService); @@ -181,7 +200,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library private void DumpLibrary() { - InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot; + InventoryFolderImpl lib = m_Library.LibraryRootFolder; m_log.DebugFormat(" - folder {0}", lib.Name); DumpFolder(lib); diff --git a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs index 2c95b5a592..685c0315b2 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs @@ -41,9 +41,9 @@ namespace OpenSim.Region.CoreModules.Framework.Library { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private LibraryRootFolder m_Library; + private InventoryFolderImpl m_Library; - public LocalInventoryService(LibraryRootFolder lib) + public LocalInventoryService(InventoryFolderImpl lib) { m_Library = lib; } diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index c9b307156c..91c0a532b5 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -95,6 +95,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions protected Scene m_scene; + private InventoryFolderImpl m_libraryRootFolder; + protected InventoryFolderImpl LibraryRootFolder + { + get + { + if (m_libraryRootFolder != null) + return m_libraryRootFolder; + + ILibraryService lib = m_scene.RequestModuleInterface(); + if (lib != null) + { + m_libraryRootFolder = lib.LibraryRootFolder; + } + return m_libraryRootFolder; + } + } + #region Constants // These are here for testing. They will be taken out @@ -1005,9 +1022,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions IInventoryService invService = m_scene.InventoryService; InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); assetRequestItem = invService.GetItem(assetRequestItem); - if (assetRequestItem == null) // Library item + if (assetRequestItem == null && LibraryRootFolder != null) // Library item { - assetRequestItem = scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); + assetRequestItem = LibraryRootFolder.FindItem(notecard); if (assetRequestItem != null) // Implicitly readable return true; @@ -1425,9 +1442,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions IInventoryService invService = m_scene.InventoryService; InventoryItemBase assetRequestItem = new InventoryItemBase(script, user); assetRequestItem = invService.GetItem(assetRequestItem); - if (assetRequestItem == null) // Library item + if (assetRequestItem == null && LibraryRootFolder != null) // Library item { - assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(script); + assetRequestItem = LibraryRootFolder.FindItem(script); if (assetRequestItem != null) // Implicitly readable return true; @@ -1520,9 +1537,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions IInventoryService invService = m_scene.InventoryService; InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); assetRequestItem = invService.GetItem(assetRequestItem); - if (assetRequestItem == null) // Library item + if (assetRequestItem == null && LibraryRootFolder != null) // Library item { - assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); + assetRequestItem = LibraryRootFolder.FindItem(notecard); if (assetRequestItem != null) // Implicitly readable return true; diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 89ce4ae9a8..f322af3604 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -573,7 +573,9 @@ namespace OpenSim.Region.Framework.Scenes "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); - InventoryItemBase item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(oldItemID); + InventoryItemBase item = null; + if (LibraryService != null && LibraryService.LibraryRootFolder != null) + item = LibraryService.LibraryRootFolder.FindItem(oldItemID); if (item == null) { @@ -1211,9 +1213,9 @@ namespace OpenSim.Region.Framework.Scenes item = InventoryService.GetItem(item); // Try library - if (null == item) + if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) { - item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); + item = LibraryService.LibraryRootFolder.FindItem(itemID); } if (item != null) @@ -1280,9 +1282,9 @@ namespace OpenSim.Region.Framework.Scenes // Try library // XXX clumsy, possibly should be one call - if (null == item) + if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) { - item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); + item = LibraryService.LibraryRootFolder.FindItem(itemID); } if (item != null) diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 47fbeb45db..022d79d9d7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -424,7 +424,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) { - if (ownerID == CommsManager.UserProfileCacheService.LibraryRoot.Owner) + if (LibraryService != null && LibraryService.LibraryRootFolder != null && ownerID == LibraryService.LibraryRootFolder.Owner) { //m_log.Debug("request info for library item"); return; @@ -458,13 +458,14 @@ namespace OpenSim.Region.Framework.Scenes // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. // can be handled transparently). InventoryFolderImpl fold = null; - if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) - { - remoteClient.SendInventoryFolderDetails( - fold.Owner, folderID, fold.RequestListOfItems(), - fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); - return; - } + if (LibraryService != null && LibraryService.LibraryRootFolder != null) + if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) + { + remoteClient.SendInventoryFolderDetails( + fold.Owner, folderID, fold.RequestListOfItems(), + fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); + return; + } // We're going to send the reply async, because there may be // an enormous quantity of packets -- basically the entire inventory! @@ -512,15 +513,16 @@ namespace OpenSim.Region.Framework.Scenes // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. // can be handled transparently). InventoryFolderImpl fold; - if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) - { - version = 0; - InventoryCollection ret = new InventoryCollection(); - ret.Folders = new List(); - ret.Items = fold.RequestListOfItems(); + if (LibraryService != null && LibraryService.LibraryRootFolder != null) + if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) + { + version = 0; + InventoryCollection ret = new InventoryCollection(); + ret.Folders = new List(); + ret.Items = fold.RequestListOfItems(); - return ret; - } + return ret; + } InventoryCollection contents = new InventoryCollection(); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 418cfbf45d..ae189b5bd4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -240,6 +240,19 @@ namespace OpenSim.Region.Framework.Scenes } } + protected ILibraryService m_LibraryService; + + public ILibraryService LibraryService + { + get + { + if (m_LibraryService == null) + m_LibraryService = RequestModuleInterface(); + + return m_LibraryService; + } + } + protected IXMLRPC m_xmlrpcModule; protected IWorldComm m_worldCommModule; protected IAvatarFactory m_AvatarFactory; diff --git a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs index d5e073c6b4..e24055b015 100644 --- a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs +++ b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs @@ -51,8 +51,9 @@ namespace OpenSim.Server.Handlers.Login string loginService = ReadLocalServiceFromConfig(config); ISimulationService simService = scene.RequestModuleInterface(); + ILibraryService libService = scene.RequestModuleInterface(); - Object[] args = new Object[] { config, simService }; + Object[] args = new Object[] { config, simService, libService }; m_LoginService = ServerUtils.LoadPlugin(loginService, args); InitializeHandlers(server); diff --git a/OpenSim/Services/InventoryService/LibraryService.cs b/OpenSim/Services/InventoryService/LibraryService.cs new file mode 100644 index 0000000000..383f311fdf --- /dev/null +++ b/OpenSim/Services/InventoryService/LibraryService.cs @@ -0,0 +1,283 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Xml; + +using OpenSim.Framework; +using OpenSim.Services.Base; +using OpenSim.Services.Interfaces; + +using log4net; +using Nini.Config; +using OpenMetaverse; + +namespace OpenSim.Services.InventoryService +{ + /// + /// Basically a hack to give us a Inventory library while we don't have a inventory server + /// once the server is fully implemented then should read the data from that + /// + public class LibraryService : ServiceBase, ILibraryService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private InventoryFolderImpl m_LibraryRootFolder; + + public InventoryFolderImpl LibraryRootFolder + { + get { return m_LibraryRootFolder; } + } + + private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000"); + + /// + /// Holds the root library folder and all its descendents. This is really only used during inventory + /// setup so that we don't have to repeatedly search the tree of library folders. + /// + protected Dictionary libraryFolders + = new Dictionary(); + + public LibraryService(IConfigSource config) + : base(config) + { + string pLibrariesLocation = Path.Combine("inventory", "Libraries.xml"); + string pLibName = "OpenSim Library"; + + IConfig libConfig = config.Configs["LibraryService"]; + if (libConfig != null) + { + pLibrariesLocation = libConfig.GetString("DefaultLibrary", pLibrariesLocation); + pLibName = libConfig.GetString("LibraryName", pLibName); + } + + m_log.Debug("[LIBRARY]: Starting library service..."); + + m_LibraryRootFolder = new InventoryFolderImpl(); + m_LibraryRootFolder.Owner = libOwner; + m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000"); + m_LibraryRootFolder.Name = pLibName; + m_LibraryRootFolder.ParentID = UUID.Zero; + m_LibraryRootFolder.Type = (short)8; + m_LibraryRootFolder.Version = (ushort)1; + + libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); + + LoadLibraries(pLibrariesLocation); + } + + public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description, + int assetType, int invType, UUID parentFolderID) + { + InventoryItemBase item = new InventoryItemBase(); + item.Owner = libOwner; + item.CreatorId = libOwner.ToString(); + item.ID = inventoryID; + item.AssetID = assetID; + item.Description = description; + item.Name = name; + item.AssetType = assetType; + item.InvType = invType; + item.Folder = parentFolderID; + item.BasePermissions = 0x7FFFFFFF; + item.EveryOnePermissions = 0x7FFFFFFF; + item.CurrentPermissions = 0x7FFFFFFF; + item.NextPermissions = 0x7FFFFFFF; + return item; + } + + /// + /// Use the asset set information at path to load assets + /// + /// + /// + protected void LoadLibraries(string librariesControlPath) + { + m_log.InfoFormat("[LIBRARY INVENTORY]: Loading library control file {0}", librariesControlPath); + LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig); + } + + /// + /// Read a library set from config + /// + /// + protected void ReadLibraryFromConfig(IConfig config, string path) + { + string basePath = Path.GetDirectoryName(path); + string foldersPath + = Path.Combine( + basePath, config.GetString("foldersFile", String.Empty)); + + LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig); + + string itemsPath + = Path.Combine( + basePath, config.GetString("itemsFile", String.Empty)); + + LoadFromFile(itemsPath, "Library items", ReadItemFromConfig); + } + + /// + /// Read a library inventory folder from a loaded configuration + /// + /// + private void ReadFolderFromConfig(IConfig config, string path) + { + InventoryFolderImpl folderInfo = new InventoryFolderImpl(); + + folderInfo.ID = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); + folderInfo.Name = config.GetString("name", "unknown"); + folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString())); + folderInfo.Type = (short)config.GetInt("type", 8); + + folderInfo.Owner = libOwner; + folderInfo.Version = 1; + + if (libraryFolders.ContainsKey(folderInfo.ParentID)) + { + InventoryFolderImpl parentFolder = libraryFolders[folderInfo.ParentID]; + + libraryFolders.Add(folderInfo.ID, folderInfo); + parentFolder.AddChildFolder(folderInfo); + +// m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); + } + else + { + m_log.WarnFormat( + "[LIBRARY INVENTORY]: Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!", + folderInfo.Name, folderInfo.ID, folderInfo.ParentID); + } + } + + /// + /// Read a library inventory item metadata from a loaded configuration + /// + /// + private void ReadItemFromConfig(IConfig config, string path) + { + InventoryItemBase item = new InventoryItemBase(); + item.Owner = libOwner; + item.CreatorId = libOwner.ToString(); + item.ID = new UUID(config.GetString("inventoryID", m_LibraryRootFolder.ID.ToString())); + item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString())); + item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString())); + item.Name = config.GetString("name", String.Empty); + item.Description = config.GetString("description", item.Name); + item.InvType = config.GetInt("inventoryType", 0); + item.AssetType = config.GetInt("assetType", item.InvType); + item.CurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF); + item.NextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF); + item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF); + item.BasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF); + item.Flags = (uint)config.GetInt("flags", 0); + + if (libraryFolders.ContainsKey(item.Folder)) + { + InventoryFolderImpl parentFolder = libraryFolders[item.Folder]; + try + { + parentFolder.Items.Add(item.ID, item); + } + catch (Exception) + { + m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name); + } + } + else + { + m_log.WarnFormat( + "[LIBRARY INVENTORY]: Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!", + item.Name, item.ID, item.Folder); + } + } + + private delegate void ConfigAction(IConfig config, string path); + + /// + /// Load the given configuration at a path and perform an action on each Config contained within it + /// + /// + /// + /// + private static void LoadFromFile(string path, string fileDescription, ConfigAction action) + { + if (File.Exists(path)) + { + try + { + XmlConfigSource source = new XmlConfigSource(path); + + for (int i = 0; i < source.Configs.Count; i++) + { + action(source.Configs[i], path); + } + } + catch (XmlException e) + { + m_log.ErrorFormat("[LIBRARY INVENTORY]: Error loading {0} : {1}", path, e); + } + } + else + { + m_log.ErrorFormat("[LIBRARY INVENTORY]: {0} file {1} does not exist!", fileDescription, path); + } + } + + /// + /// Looks like a simple getter, but is written like this for some consistency with the other Request + /// methods in the superclass + /// + /// + public Dictionary GetAllFolders() + { + Dictionary fs = new Dictionary(); + fs.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); + List fis = TraverseFolder(m_LibraryRootFolder); + foreach (InventoryFolderImpl f in fis) + { + fs.Add(f.ID, f); + } + //return libraryFolders; + return fs; + } + + private List TraverseFolder(InventoryFolderImpl node) + { + List folders = node.RequestListOfFolderImpls(); + List subs = new List(); + foreach (InventoryFolderImpl f in folders) + subs.AddRange(TraverseFolder(f)); + + folders.AddRange(subs); + return folders; + } + } +} diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index c80ab7f11d..4db6a05126 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -215,12 +215,12 @@ namespace OpenSim.Services.LLLoginService } public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo, - GridRegion destination, List invSkel, + GridRegion destination, List invSkel, ILibraryService libService, string where, string startlocation, Vector3 position, Vector3 lookAt, string message, GridRegion home, IPEndPoint clientIP) : this() { - FillOutInventoryData(invSkel); + FillOutInventoryData(invSkel, libService); CircuitCode = (int)aCircuit.circuitcode; Lastname = account.LastName; @@ -243,7 +243,7 @@ namespace OpenSim.Services.LLLoginService } - private void FillOutInventoryData(List invSkel) + private void FillOutInventoryData(List invSkel, ILibraryService libService) { InventoryData inventData = null; @@ -272,13 +272,16 @@ namespace OpenSim.Services.LLLoginService } // Inventory Library Section - Hashtable InventoryLibRootHash = new Hashtable(); - InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; - InventoryLibRoot = new ArrayList(); - InventoryLibRoot.Add(InventoryLibRootHash); + if (libService != null && libService.LibraryRootFolder != null) + { + Hashtable InventoryLibRootHash = new Hashtable(); + InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; + InventoryLibRoot = new ArrayList(); + InventoryLibRoot.Add(InventoryLibRootHash); - InventoryLibraryOwner = GetLibraryOwner(); - InventoryLibrary = GetInventoryLibrary(); + InventoryLibraryOwner = GetLibraryOwner(libService.LibraryRootFolder); + InventoryLibrary = GetInventoryLibrary(libService); + } } private void FillOutHomeData(PresenceInfo pinfo, GridRegion home) @@ -646,12 +649,11 @@ namespace OpenSim.Services.LLLoginService /// Converts the inventory library skeleton into the form required by the rpc request. /// /// - protected virtual ArrayList GetInventoryLibrary() + protected virtual ArrayList GetInventoryLibrary(ILibraryService library) { - // While we don't have library... - //Dictionary rootFolders - // = m_libraryRootFolder.RequestSelfAndDescendentFolders(); - Dictionary rootFolders = new Dictionary(); + Dictionary rootFolders = library.GetAllFolders(); + m_log.DebugFormat("[LLOGIN]: Library has {0} folders", rootFolders.Count); + //Dictionary rootFolders = new Dictionary(); ArrayList folderHashes = new ArrayList(); foreach (InventoryFolderBase folder in rootFolders.Values) @@ -672,11 +674,11 @@ namespace OpenSim.Services.LLLoginService /// /// /// - protected virtual ArrayList GetLibraryOwner() + protected virtual ArrayList GetLibraryOwner(InventoryFolderImpl libFolder) { //for now create random inventory library owner Hashtable TempHash = new Hashtable(); - TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; + TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; // libFolder.Owner ArrayList inventoryLibOwner = new ArrayList(); inventoryLibOwner.Add(TempHash); return inventoryLibOwner; diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 58038cb417..2b745398cf 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -26,13 +26,14 @@ namespace OpenSim.Services.LLLoginService private IGridService m_GridService; private IPresenceService m_PresenceService; private ISimulationService m_LocalSimulationService; + private ILibraryService m_LibraryService; private string m_DefaultRegionName; private string m_RemoteSimulationDll; private string m_WelcomeMessage; private bool m_RequireInventory; - public LLLoginService(IConfigSource config, ISimulationService simService) + public LLLoginService(IConfigSource config, ISimulationService simService, ILibraryService libraryService) { IConfig serverConfig = config.Configs["LoginService"]; if (serverConfig == null) @@ -43,13 +44,14 @@ namespace OpenSim.Services.LLLoginService string invService = serverConfig.GetString("InventoryService", String.Empty); string gridService = serverConfig.GetString("GridService", String.Empty); string presenceService = serverConfig.GetString("PresenceService", String.Empty); + string libService = serverConfig.GetString("LibraryService", String.Empty); m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty); m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty); m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); m_RequireInventory = serverConfig.GetBoolean("RequireInventory", true); - // These 3 are required; the other 2 aren't + // These 3 are required; the others aren't if (accountService == string.Empty || authService == string.Empty || invService == string.Empty) throw new Exception("LoginService is missing service specifications"); @@ -62,13 +64,27 @@ namespace OpenSim.Services.LLLoginService m_GridService = ServerUtils.LoadPlugin(gridService, args); if (presenceService != string.Empty) m_PresenceService = ServerUtils.LoadPlugin(presenceService, args); + + // + // deal with the services given as argument + // m_LocalSimulationService = simService; + if (libraryService != null) + { + m_log.DebugFormat("[LLOGIN SERVICE]: Using LibraryService given as argument"); + m_LibraryService = libraryService; + } + else if (libService != string.Empty) + { + m_log.DebugFormat("[LLOGIN SERVICE]: Using instantiated LibraryService"); + m_LibraryService = ServerUtils.LoadPlugin(libService, args); + } m_log.DebugFormat("[LLOGIN SERVICE]: Starting..."); } - public LLLoginService(IConfigSource config) : this(config, null) + public LLLoginService(IConfigSource config) : this(config, null, null) { } @@ -171,7 +187,7 @@ namespace OpenSim.Services.LLLoginService // TODO: Get Friends list... // Finally, fill out the response and return it - LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, + LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, m_LibraryService, where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP); return response; diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index 96c25e6251..d89029feda 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini @@ -43,6 +43,11 @@ LocalGridInventoryService = "OpenSim.Services.InventoryService.dll:InventoryService" HypergridInventoryService = "OpenSim.Services.Connectors.dll:HGInventoryServiceConnector" +[LibraryService] + LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService" + LibraryName = "OpenSim Library" + DefaultLibrary = "./inventory/Libraries.xml" + [AuthorizationService] LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService" diff --git a/prebuild.xml b/prebuild.xml index b533f7ba28..f5092da73f 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1460,6 +1460,7 @@ ../../../bin/ +