The Library Service is now working. UserProfileCacheService.LibraryRoot is obsolete. Didn't delete it yet to avoid merge conflicts later -- want to stay out of core as much as possible.
parent
ec53301e63
commit
8a9677a531
|
@ -6962,7 +6962,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
assetRequestItem = invService.GetItem(assetRequestItem);
|
assetRequestItem = invService.GetItem(assetRequestItem);
|
||||||
if (assetRequestItem == null)
|
if (assetRequestItem == null)
|
||||||
{
|
{
|
||||||
assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID);
|
ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>();
|
||||||
|
if (lib != null)
|
||||||
|
assetRequestItem = lib.LibraryRootFolder.FindItem(itemID);
|
||||||
if (assetRequestItem == null)
|
if (assetRequestItem == null)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ using OpenSim.Region.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
|
using OpenSim.Server.Base;
|
||||||
|
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
@ -53,6 +54,8 @@ namespace OpenSim.Region.CoreModules.Framework.Library
|
||||||
private string m_LibraryName = "OpenSim Library";
|
private string m_LibraryName = "OpenSim Library";
|
||||||
private Scene m_Scene;
|
private Scene m_Scene;
|
||||||
|
|
||||||
|
private ILibraryService m_Library;
|
||||||
|
|
||||||
#region ISharedRegionModule
|
#region ISharedRegionModule
|
||||||
|
|
||||||
public void Initialise(IConfigSource config)
|
public void Initialise(IConfigSource config)
|
||||||
|
@ -60,9 +63,22 @@ namespace OpenSim.Region.CoreModules.Framework.Library
|
||||||
m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled);
|
m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled);
|
||||||
if (m_Enabled)
|
if (m_Enabled)
|
||||||
{
|
{
|
||||||
IConfig libConfig = config.Configs["LibraryModule"];
|
IConfig libConfig = config.Configs["LibraryService"];
|
||||||
if (libConfig != null)
|
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<ILibraryService>(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;
|
m_Scene = scene;
|
||||||
}
|
}
|
||||||
|
scene.RegisterModuleInterface<ILibraryService>(m_Library);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveRegion(Scene scene)
|
public void RemoveRegion(Scene scene)
|
||||||
{
|
{
|
||||||
|
if (!m_Enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
scene.UnregisterModuleInterface<ILibraryService>(m_Library);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegionLoaded(Scene scene)
|
public void RegionLoaded(Scene scene)
|
||||||
|
@ -127,19 +148,17 @@ namespace OpenSim.Region.CoreModules.Framework.Library
|
||||||
|
|
||||||
protected void LoadLibrariesFromArchives()
|
protected void LoadLibrariesFromArchives()
|
||||||
{
|
{
|
||||||
InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot;
|
InventoryFolderImpl lib = m_Library.LibraryRootFolder;
|
||||||
if (lib == null)
|
if (lib == null)
|
||||||
{
|
{
|
||||||
m_log.Debug("[LIBRARY MODULE]: No library. Ignoring Library Module");
|
m_log.Debug("[LIBRARY MODULE]: No library. Ignoring Library Module");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lib.Name = m_LibraryName;
|
|
||||||
|
|
||||||
RegionInfo regInfo = new RegionInfo();
|
RegionInfo regInfo = new RegionInfo();
|
||||||
Scene m_MockScene = new Scene(regInfo);
|
Scene m_MockScene = new Scene(regInfo);
|
||||||
m_MockScene.CommsManager = m_Scene.CommsManager;
|
m_MockScene.CommsManager = m_Scene.CommsManager;
|
||||||
LocalInventoryService invService = new LocalInventoryService((LibraryRootFolder)lib);
|
LocalInventoryService invService = new LocalInventoryService(lib);
|
||||||
m_MockScene.RegisterModuleInterface<IInventoryService>(invService);
|
m_MockScene.RegisterModuleInterface<IInventoryService>(invService);
|
||||||
m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService);
|
m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService);
|
||||||
|
|
||||||
|
@ -181,7 +200,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library
|
||||||
|
|
||||||
private void DumpLibrary()
|
private void DumpLibrary()
|
||||||
{
|
{
|
||||||
InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot;
|
InventoryFolderImpl lib = m_Library.LibraryRootFolder;
|
||||||
|
|
||||||
m_log.DebugFormat(" - folder {0}", lib.Name);
|
m_log.DebugFormat(" - folder {0}", lib.Name);
|
||||||
DumpFolder(lib);
|
DumpFolder(lib);
|
||||||
|
|
|
@ -41,9 +41,9 @@ namespace OpenSim.Region.CoreModules.Framework.Library
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
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;
|
m_Library = lib;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
||||||
|
|
||||||
protected Scene m_scene;
|
protected Scene m_scene;
|
||||||
|
|
||||||
|
private InventoryFolderImpl m_libraryRootFolder;
|
||||||
|
protected InventoryFolderImpl LibraryRootFolder
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_libraryRootFolder != null)
|
||||||
|
return m_libraryRootFolder;
|
||||||
|
|
||||||
|
ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>();
|
||||||
|
if (lib != null)
|
||||||
|
{
|
||||||
|
m_libraryRootFolder = lib.LibraryRootFolder;
|
||||||
|
}
|
||||||
|
return m_libraryRootFolder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Constants
|
#region Constants
|
||||||
// These are here for testing. They will be taken out
|
// 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;
|
IInventoryService invService = m_scene.InventoryService;
|
||||||
InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user);
|
InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user);
|
||||||
assetRequestItem = invService.GetItem(assetRequestItem);
|
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
|
if (assetRequestItem != null) // Implicitly readable
|
||||||
return true;
|
return true;
|
||||||
|
@ -1425,9 +1442,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
||||||
IInventoryService invService = m_scene.InventoryService;
|
IInventoryService invService = m_scene.InventoryService;
|
||||||
InventoryItemBase assetRequestItem = new InventoryItemBase(script, user);
|
InventoryItemBase assetRequestItem = new InventoryItemBase(script, user);
|
||||||
assetRequestItem = invService.GetItem(assetRequestItem);
|
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
|
if (assetRequestItem != null) // Implicitly readable
|
||||||
return true;
|
return true;
|
||||||
|
@ -1520,9 +1537,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
|
||||||
IInventoryService invService = m_scene.InventoryService;
|
IInventoryService invService = m_scene.InventoryService;
|
||||||
InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user);
|
InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user);
|
||||||
assetRequestItem = invService.GetItem(assetRequestItem);
|
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
|
if (assetRequestItem != null) // Implicitly readable
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -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}",
|
"[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}",
|
||||||
remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName);
|
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)
|
if (item == null)
|
||||||
{
|
{
|
||||||
|
@ -1211,9 +1213,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
item = InventoryService.GetItem(item);
|
item = InventoryService.GetItem(item);
|
||||||
|
|
||||||
// Try library
|
// 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)
|
if (item != null)
|
||||||
|
@ -1280,9 +1282,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
// Try library
|
// Try library
|
||||||
// XXX clumsy, possibly should be one call
|
// 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)
|
if (item != null)
|
||||||
|
|
|
@ -424,7 +424,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="ownerID"></param>
|
/// <param name="ownerID"></param>
|
||||||
public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID)
|
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");
|
//m_log.Debug("request info for library item");
|
||||||
return;
|
return;
|
||||||
|
@ -458,7 +458,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
|
// CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
|
||||||
// can be handled transparently).
|
// can be handled transparently).
|
||||||
InventoryFolderImpl fold = null;
|
InventoryFolderImpl fold = null;
|
||||||
if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null)
|
if (LibraryService != null && LibraryService.LibraryRootFolder != null)
|
||||||
|
if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
|
||||||
{
|
{
|
||||||
remoteClient.SendInventoryFolderDetails(
|
remoteClient.SendInventoryFolderDetails(
|
||||||
fold.Owner, folderID, fold.RequestListOfItems(),
|
fold.Owner, folderID, fold.RequestListOfItems(),
|
||||||
|
@ -512,7 +513,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
|
// CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
|
||||||
// can be handled transparently).
|
// can be handled transparently).
|
||||||
InventoryFolderImpl fold;
|
InventoryFolderImpl fold;
|
||||||
if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null)
|
if (LibraryService != null && LibraryService.LibraryRootFolder != null)
|
||||||
|
if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
|
||||||
{
|
{
|
||||||
version = 0;
|
version = 0;
|
||||||
InventoryCollection ret = new InventoryCollection();
|
InventoryCollection ret = new InventoryCollection();
|
||||||
|
|
|
@ -240,6 +240,19 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ILibraryService m_LibraryService;
|
||||||
|
|
||||||
|
public ILibraryService LibraryService
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_LibraryService == null)
|
||||||
|
m_LibraryService = RequestModuleInterface<ILibraryService>();
|
||||||
|
|
||||||
|
return m_LibraryService;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected IXMLRPC m_xmlrpcModule;
|
protected IXMLRPC m_xmlrpcModule;
|
||||||
protected IWorldComm m_worldCommModule;
|
protected IWorldComm m_worldCommModule;
|
||||||
protected IAvatarFactory m_AvatarFactory;
|
protected IAvatarFactory m_AvatarFactory;
|
||||||
|
|
|
@ -51,8 +51,9 @@ namespace OpenSim.Server.Handlers.Login
|
||||||
string loginService = ReadLocalServiceFromConfig(config);
|
string loginService = ReadLocalServiceFromConfig(config);
|
||||||
|
|
||||||
ISimulationService simService = scene.RequestModuleInterface<ISimulationService>();
|
ISimulationService simService = scene.RequestModuleInterface<ISimulationService>();
|
||||||
|
ILibraryService libService = scene.RequestModuleInterface<ILibraryService>();
|
||||||
|
|
||||||
Object[] args = new Object[] { config, simService };
|
Object[] args = new Object[] { config, simService, libService };
|
||||||
m_LoginService = ServerUtils.LoadPlugin<ILoginService>(loginService, args);
|
m_LoginService = ServerUtils.LoadPlugin<ILoginService>(loginService, args);
|
||||||
|
|
||||||
InitializeHandlers(server);
|
InitializeHandlers(server);
|
||||||
|
|
|
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 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
|
||||||
|
/// </summary>
|
||||||
|
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");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
protected Dictionary<UUID, InventoryFolderImpl> libraryFolders
|
||||||
|
= new Dictionary<UUID, InventoryFolderImpl>();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use the asset set information at path to load assets
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="assets"></param>
|
||||||
|
protected void LoadLibraries(string librariesControlPath)
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[LIBRARY INVENTORY]: Loading library control file {0}", librariesControlPath);
|
||||||
|
LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read a library set from config
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config"></param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read a library inventory folder from a loaded configuration
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read a library inventory item metadata from a loaded configuration
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
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);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Load the given configuration at a path and perform an action on each Config contained within it
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="fileDescription"></param>
|
||||||
|
/// <param name="action"></param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks like a simple getter, but is written like this for some consistency with the other Request
|
||||||
|
/// methods in the superclass
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Dictionary<UUID, InventoryFolderImpl> GetAllFolders()
|
||||||
|
{
|
||||||
|
Dictionary<UUID, InventoryFolderImpl> fs = new Dictionary<UUID, InventoryFolderImpl>();
|
||||||
|
fs.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder);
|
||||||
|
List<InventoryFolderImpl> fis = TraverseFolder(m_LibraryRootFolder);
|
||||||
|
foreach (InventoryFolderImpl f in fis)
|
||||||
|
{
|
||||||
|
fs.Add(f.ID, f);
|
||||||
|
}
|
||||||
|
//return libraryFolders;
|
||||||
|
return fs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<InventoryFolderImpl> TraverseFolder(InventoryFolderImpl node)
|
||||||
|
{
|
||||||
|
List<InventoryFolderImpl> folders = node.RequestListOfFolderImpls();
|
||||||
|
List<InventoryFolderImpl> subs = new List<InventoryFolderImpl>();
|
||||||
|
foreach (InventoryFolderImpl f in folders)
|
||||||
|
subs.AddRange(TraverseFolder(f));
|
||||||
|
|
||||||
|
folders.AddRange(subs);
|
||||||
|
return folders;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -215,12 +215,12 @@ namespace OpenSim.Services.LLLoginService
|
||||||
}
|
}
|
||||||
|
|
||||||
public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo,
|
public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo,
|
||||||
GridRegion destination, List<InventoryFolderBase> invSkel,
|
GridRegion destination, List<InventoryFolderBase> invSkel, ILibraryService libService,
|
||||||
string where, string startlocation, Vector3 position, Vector3 lookAt, string message,
|
string where, string startlocation, Vector3 position, Vector3 lookAt, string message,
|
||||||
GridRegion home, IPEndPoint clientIP)
|
GridRegion home, IPEndPoint clientIP)
|
||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
FillOutInventoryData(invSkel);
|
FillOutInventoryData(invSkel, libService);
|
||||||
|
|
||||||
CircuitCode = (int)aCircuit.circuitcode;
|
CircuitCode = (int)aCircuit.circuitcode;
|
||||||
Lastname = account.LastName;
|
Lastname = account.LastName;
|
||||||
|
@ -243,7 +243,7 @@ namespace OpenSim.Services.LLLoginService
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillOutInventoryData(List<InventoryFolderBase> invSkel)
|
private void FillOutInventoryData(List<InventoryFolderBase> invSkel, ILibraryService libService)
|
||||||
{
|
{
|
||||||
InventoryData inventData = null;
|
InventoryData inventData = null;
|
||||||
|
|
||||||
|
@ -272,13 +272,16 @@ namespace OpenSim.Services.LLLoginService
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inventory Library Section
|
// Inventory Library Section
|
||||||
|
if (libService != null && libService.LibraryRootFolder != null)
|
||||||
|
{
|
||||||
Hashtable InventoryLibRootHash = new Hashtable();
|
Hashtable InventoryLibRootHash = new Hashtable();
|
||||||
InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
|
InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
|
||||||
InventoryLibRoot = new ArrayList();
|
InventoryLibRoot = new ArrayList();
|
||||||
InventoryLibRoot.Add(InventoryLibRootHash);
|
InventoryLibRoot.Add(InventoryLibRootHash);
|
||||||
|
|
||||||
InventoryLibraryOwner = GetLibraryOwner();
|
InventoryLibraryOwner = GetLibraryOwner(libService.LibraryRootFolder);
|
||||||
InventoryLibrary = GetInventoryLibrary();
|
InventoryLibrary = GetInventoryLibrary(libService);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillOutHomeData(PresenceInfo pinfo, GridRegion home)
|
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.
|
/// Converts the inventory library skeleton into the form required by the rpc request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected virtual ArrayList GetInventoryLibrary()
|
protected virtual ArrayList GetInventoryLibrary(ILibraryService library)
|
||||||
{
|
{
|
||||||
// While we don't have library...
|
Dictionary<UUID, InventoryFolderImpl> rootFolders = library.GetAllFolders();
|
||||||
//Dictionary<UUID, InventoryFolderImpl> rootFolders
|
m_log.DebugFormat("[LLOGIN]: Library has {0} folders", rootFolders.Count);
|
||||||
// = m_libraryRootFolder.RequestSelfAndDescendentFolders();
|
//Dictionary<UUID, InventoryFolderImpl> rootFolders = new Dictionary<UUID,InventoryFolderImpl>();
|
||||||
Dictionary<UUID, InventoryFolderImpl> rootFolders = new Dictionary<UUID,InventoryFolderImpl>();
|
|
||||||
ArrayList folderHashes = new ArrayList();
|
ArrayList folderHashes = new ArrayList();
|
||||||
|
|
||||||
foreach (InventoryFolderBase folder in rootFolders.Values)
|
foreach (InventoryFolderBase folder in rootFolders.Values)
|
||||||
|
@ -672,11 +674,11 @@ namespace OpenSim.Services.LLLoginService
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected virtual ArrayList GetLibraryOwner()
|
protected virtual ArrayList GetLibraryOwner(InventoryFolderImpl libFolder)
|
||||||
{
|
{
|
||||||
//for now create random inventory library owner
|
//for now create random inventory library owner
|
||||||
Hashtable TempHash = new Hashtable();
|
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();
|
ArrayList inventoryLibOwner = new ArrayList();
|
||||||
inventoryLibOwner.Add(TempHash);
|
inventoryLibOwner.Add(TempHash);
|
||||||
return inventoryLibOwner;
|
return inventoryLibOwner;
|
||||||
|
|
|
@ -26,13 +26,14 @@ namespace OpenSim.Services.LLLoginService
|
||||||
private IGridService m_GridService;
|
private IGridService m_GridService;
|
||||||
private IPresenceService m_PresenceService;
|
private IPresenceService m_PresenceService;
|
||||||
private ISimulationService m_LocalSimulationService;
|
private ISimulationService m_LocalSimulationService;
|
||||||
|
private ILibraryService m_LibraryService;
|
||||||
|
|
||||||
private string m_DefaultRegionName;
|
private string m_DefaultRegionName;
|
||||||
private string m_RemoteSimulationDll;
|
private string m_RemoteSimulationDll;
|
||||||
private string m_WelcomeMessage;
|
private string m_WelcomeMessage;
|
||||||
private bool m_RequireInventory;
|
private bool m_RequireInventory;
|
||||||
|
|
||||||
public LLLoginService(IConfigSource config, ISimulationService simService)
|
public LLLoginService(IConfigSource config, ISimulationService simService, ILibraryService libraryService)
|
||||||
{
|
{
|
||||||
IConfig serverConfig = config.Configs["LoginService"];
|
IConfig serverConfig = config.Configs["LoginService"];
|
||||||
if (serverConfig == null)
|
if (serverConfig == null)
|
||||||
|
@ -43,13 +44,14 @@ namespace OpenSim.Services.LLLoginService
|
||||||
string invService = serverConfig.GetString("InventoryService", String.Empty);
|
string invService = serverConfig.GetString("InventoryService", String.Empty);
|
||||||
string gridService = serverConfig.GetString("GridService", String.Empty);
|
string gridService = serverConfig.GetString("GridService", String.Empty);
|
||||||
string presenceService = serverConfig.GetString("PresenceService", String.Empty);
|
string presenceService = serverConfig.GetString("PresenceService", String.Empty);
|
||||||
|
string libService = serverConfig.GetString("LibraryService", String.Empty);
|
||||||
|
|
||||||
m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty);
|
m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty);
|
||||||
m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty);
|
m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty);
|
||||||
m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
|
m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
|
||||||
m_RequireInventory = serverConfig.GetBoolean("RequireInventory", true);
|
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 ||
|
if (accountService == string.Empty || authService == string.Empty ||
|
||||||
invService == string.Empty)
|
invService == string.Empty)
|
||||||
throw new Exception("LoginService is missing service specifications");
|
throw new Exception("LoginService is missing service specifications");
|
||||||
|
@ -62,13 +64,27 @@ namespace OpenSim.Services.LLLoginService
|
||||||
m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
|
m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
|
||||||
if (presenceService != string.Empty)
|
if (presenceService != string.Empty)
|
||||||
m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
|
m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
|
||||||
|
|
||||||
|
//
|
||||||
|
// deal with the services given as argument
|
||||||
|
//
|
||||||
m_LocalSimulationService = simService;
|
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<ILibraryService>(libService, args);
|
||||||
|
}
|
||||||
|
|
||||||
m_log.DebugFormat("[LLOGIN SERVICE]: Starting...");
|
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...
|
// TODO: Get Friends list...
|
||||||
|
|
||||||
// Finally, fill out the response and return it
|
// 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);
|
where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
|
@ -43,6 +43,11 @@
|
||||||
LocalGridInventoryService = "OpenSim.Services.InventoryService.dll:InventoryService"
|
LocalGridInventoryService = "OpenSim.Services.InventoryService.dll:InventoryService"
|
||||||
HypergridInventoryService = "OpenSim.Services.Connectors.dll:HGInventoryServiceConnector"
|
HypergridInventoryService = "OpenSim.Services.Connectors.dll:HGInventoryServiceConnector"
|
||||||
|
|
||||||
|
[LibraryService]
|
||||||
|
LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService"
|
||||||
|
LibraryName = "OpenSim Library"
|
||||||
|
DefaultLibrary = "./inventory/Libraries.xml"
|
||||||
|
|
||||||
[AuthorizationService]
|
[AuthorizationService]
|
||||||
LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService"
|
LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService"
|
||||||
|
|
||||||
|
|
|
@ -1460,6 +1460,7 @@
|
||||||
|
|
||||||
<ReferencePath>../../../bin/</ReferencePath>
|
<ReferencePath>../../../bin/</ReferencePath>
|
||||||
<Reference name="System"/>
|
<Reference name="System"/>
|
||||||
|
<Reference name="System.Xml"/>
|
||||||
<Reference name="OpenMetaverseTypes.dll"/>
|
<Reference name="OpenMetaverseTypes.dll"/>
|
||||||
<Reference name="OpenMetaverse.dll"/>
|
<Reference name="OpenMetaverse.dll"/>
|
||||||
<Reference name="OpenSim.Framework"/>
|
<Reference name="OpenSim.Framework"/>
|
||||||
|
|
Loading…
Reference in New Issue