Standard library folders can now be configued in the xml in inventory/OpenSimLibrary - no hardcoded changes are required. For some reason, all the folders are currently

showing up as texture folders, even though they are configured with the same types as the agent inventory folders.  This should be resolved soon.
afrisby
Justin Clarke Casey 2007-12-31 03:33:21 +00:00
parent b0a6299937
commit 60fa75ac04
9 changed files with 208 additions and 63 deletions

View File

@ -26,10 +26,12 @@
* *
*/ */
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Xml; using System.Xml;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
namespace OpenSim.Framework.Communications.Cache namespace OpenSim.Framework.Communications.Cache
@ -41,44 +43,62 @@ namespace OpenSim.Framework.Communications.Cache
public class LibraryRootFolder : InventoryFolderImpl public class LibraryRootFolder : InventoryFolderImpl
{ {
private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000");
private InventoryFolderImpl m_textureFolder;
/// <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<LLUUID, InventoryFolderImpl> libraryFolders
= new Dictionary<LLUUID, InventoryFolderImpl>();
public LibraryRootFolder() public LibraryRootFolder()
{ {
MainLog.Instance.Verbose("LIBRARYINVENTORY", "Loading library inventory");
agentID = libOwner; agentID = libOwner;
folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); folderID = new LLUUID("00000112-000f-0000-0000-000100bba000");
name = "OpenSim Library"; name = "OpenSim Library";
parentID = LLUUID.Zero; parentID = LLUUID.Zero;
type = (short) -1; type = (short) 8;
version = (ushort) 1; version = (ushort) 1;
InventoryFolderImpl folderInfo = new InventoryFolderImpl(); libraryFolders.Add(folderID, this);
folderInfo.agentID = libOwner;
folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001"); string foldersPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibraryFolders.xml");
folderInfo.name = "Texture Library"; if (File.Exists(foldersPath))
folderInfo.parentID = folderID;
folderInfo.type = -1;
folderInfo.version = 1;
SubFolders.Add(folderInfo.folderID, folderInfo);
m_textureFolder = folderInfo;
CreateLibraryItems();
string filePath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibrary.xml");
if (File.Exists(filePath))
{ {
try try
{ {
XmlConfigSource source = new XmlConfigSource(filePath); XmlConfigSource source = new XmlConfigSource(foldersPath);
ReadFoldersFromFile(source);
}
catch (XmlException e)
{
MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + foldersPath + ": " + e.ToString());
}
}
CreateLibraryItems();
string itemsPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibrary.xml");
if (File.Exists(itemsPath))
{
try
{
XmlConfigSource source = new XmlConfigSource(itemsPath);
ReadItemsFromFile(source); ReadItemsFromFile(source);
} }
catch (XmlException e) catch (XmlException e)
{ {
MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + filePath + ": " + e.ToString()); MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + itemsPath + ": " + e.ToString());
} }
} }
} }
/// <summary>
/// Hardcoded item creation. Please don't add any more items here - future items should be created
/// in the xml in the bin/inventory folder.
/// </summary>
private void CreateLibraryItems() private void CreateLibraryItems()
{ {
InventoryItemBase item = InventoryItemBase item =
@ -133,7 +153,51 @@ namespace OpenSim.Framework.Communications.Cache
item.inventoryNextPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF;
return item; return item;
} }
/// <summary>
/// Read library inventory folders from an external source
/// </summary>
/// <param name="source"></param>
private void ReadFoldersFromFile(IConfigSource source)
{
for (int i = 0; i < source.Configs.Count; i++)
{
IConfig config = source.Configs[i];
InventoryFolderImpl folderInfo = new InventoryFolderImpl();
folderInfo.folderID = new LLUUID(config.GetString("folderID", folderID.ToString()));
folderInfo.name = config.GetString("name", "unknown");
folderInfo.parentID = new LLUUID(config.GetString("parentFolderID", folderID.ToString()));
folderInfo.type = (short)config.GetInt("type", 8);
folderInfo.agentID = libOwner;
folderInfo.version = 1;
if (libraryFolders.ContainsKey(folderInfo.parentID))
{
InventoryFolderImpl parentFolder = libraryFolders[folderInfo.parentID];
libraryFolders.Add(folderInfo.folderID, folderInfo);
parentFolder.SubFolders.Add(folderInfo.folderID, folderInfo);
// MainLog.Instance.Verbose(
// "LIBRARYINVENTORY", "Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID);
}
else
{
MainLog.Instance.Warn(
"LIBRARYINVENTORY",
"Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!",
folderInfo.name, folderInfo.folderID, folderInfo.parentID);
}
}
}
/// <summary>
/// Read library inventory items metadata from an external source
/// </summary>
/// <param name="source"></param>
private void ReadItemsFromFile(IConfigSource source) private void ReadItemsFromFile(IConfigSource source)
{ {
for (int i = 0; i < source.Configs.Count; i++) for (int i = 0; i < source.Configs.Count; i++)
@ -145,7 +209,7 @@ namespace OpenSim.Framework.Communications.Cache
new LLUUID(source.Configs[i].GetString("inventoryID", folderID.ToString())); new LLUUID(source.Configs[i].GetString("inventoryID", folderID.ToString()));
item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToString())); item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToString()));
item.parentFolderID item.parentFolderID
= new LLUUID(source.Configs[i].GetString("folderID", LLUUID.Random().ToString())); = new LLUUID(source.Configs[i].GetString("folderID", folderID.ToString()));
item.inventoryDescription = source.Configs[i].GetString("description", ""); item.inventoryDescription = source.Configs[i].GetString("description", "");
item.inventoryName = source.Configs[i].GetString("name", ""); item.inventoryName = source.Configs[i].GetString("name", "");
item.assetType = source.Configs[i].GetInt("assetType", 0); item.assetType = source.Configs[i].GetInt("assetType", 0);
@ -155,19 +219,30 @@ namespace OpenSim.Framework.Communications.Cache
item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF);
item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF);
if (item.parentFolderID == folderID) if (libraryFolders.ContainsKey(item.parentFolderID))
{ {
Items.Add(item.inventoryID, item); InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID];
parentFolder.Items.Add(item.inventoryID, item);
} }
else else
{ {
// Very temporary - will only work for immediate child folders MainLog.Instance.Warn(
if (SubFolders.ContainsKey(item.parentFolderID)) "LIBRARYINVENTORY",
{ "Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!",
SubFolders[item.parentFolderID].Items.Add(item.inventoryID, item); item.inventoryName, item.inventoryID, item.parentFolderID);
} }
}
} }
} }
/// <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<LLUUID, InventoryFolderImpl> RequestSelfAndDescendentFolders()
{
return libraryFolders;
}
} }
} }

View File

@ -28,9 +28,12 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Threading; using System.Threading;
using libsecondlife; using libsecondlife;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
namespace OpenSim.Framework.UserManagement namespace OpenSim.Framework.UserManagement
@ -40,10 +43,18 @@ namespace OpenSim.Framework.UserManagement
protected string m_welcomeMessage = "Welcome to OpenSim"; protected string m_welcomeMessage = "Welcome to OpenSim";
protected UserManagerBase m_userManager = null; protected UserManagerBase m_userManager = null;
protected Mutex m_loginMutex = new Mutex(false); protected Mutex m_loginMutex = new Mutex(false);
/// <summary>
/// Used during login to send the skeleton of the OpenSim Library to the client.
/// </summary>
protected LibraryRootFolder m_libraryRootFolder;
public LoginService(UserManagerBase userManager, string welcomeMess) public LoginService(
UserManagerBase userManager, LibraryRootFolder libraryRootFolder, string welcomeMess)
{ {
m_userManager = userManager; m_userManager = userManager;
m_libraryRootFolder = libraryRootFolder;
if (welcomeMess != "") if (welcomeMess != "")
{ {
m_welcomeMessage = welcomeMess; m_welcomeMessage = welcomeMess;
@ -255,30 +266,27 @@ namespace OpenSim.Framework.UserManagement
} }
/// <summary> /// <summary>
/// /// 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()
{ {
//return new ArrayList(); Dictionary<LLUUID, InventoryFolderImpl> rootFolders
Hashtable TempHash = new Hashtable(); = m_libraryRootFolder.RequestSelfAndDescendentFolders();
TempHash["name"] = "OpenSim Library"; ArrayList folderHashes = new ArrayList();
TempHash["parent_id"] = LLUUID.Zero.ToString();
TempHash["version"] = 1; foreach (InventoryFolderBase folder in rootFolders.Values)
TempHash["type_default"] = -1; {
TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; Hashtable TempHash = new Hashtable();
ArrayList temp = new ArrayList(); TempHash["name"] = folder.name;
temp.Add(TempHash); TempHash["parent_id"] = folder.parentID.ToString();
TempHash["version"] = folder.version;
TempHash = new Hashtable(); TempHash["type_default"] = folder.type;
TempHash["name"] = "Texture Library"; TempHash["folder_id"] = folder.folderID.ToString();
TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; folderHashes.Add(TempHash);
TempHash["version"] = 1; }
TempHash["type_default"] = -1;
TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; return folderHashes;
temp.Add(TempHash);
return temp;
} }
/// <summary> /// <summary>

View File

@ -31,6 +31,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using libsecondlife; using libsecondlife;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
@ -89,7 +90,8 @@ namespace OpenSim.Grid.UserServer
m_userManager._config = Cfg; m_userManager._config = Cfg;
m_userManager.AddPlugin(Cfg.DatabaseProvider); m_userManager.AddPlugin(Cfg.DatabaseProvider);
m_loginService = new UserLoginService(m_userManager, Cfg, Cfg.DefaultStartupMsg); m_loginService = new UserLoginService(
m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg);
MainLog.Instance.Verbose("REGION", "Starting HTTP process"); MainLog.Instance.Verbose("REGION", "Starting HTTP process");
BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort);

View File

@ -32,7 +32,9 @@ using System.Collections.Generic;
using System.Threading; using System.Threading;
using libsecondlife; using libsecondlife;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Data; using OpenSim.Framework.Data;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
@ -45,8 +47,9 @@ namespace OpenSim.Grid.UserServer
{ {
public UserConfig m_config; public UserConfig m_config;
public UserLoginService(UserManagerBase userManager, UserConfig config, string welcomeMess) public UserLoginService(
: base(userManager, welcomeMess) UserManagerBase userManager, LibraryRootFolder libraryRootFolder, UserConfig config, string welcomeMess)
: base(userManager, libraryRootFolder, welcomeMess)
{ {
m_config = config; m_config = config;
} }

View File

@ -326,12 +326,25 @@ namespace OpenSim
m_moduleLoader = new ModuleLoader(m_log, m_config); m_moduleLoader = new ModuleLoader(m_log, m_config);
MainLog.Instance.Verbose("Plugins", "Loading OpenSim application plugins"); ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/Startup");
foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/Startup")) MainLog.Instance.Verbose("PLUGINS", "Loading {0} OpenSim application plugins", nodes.Count);
{
foreach (TypeExtensionNode node in nodes)
{
IApplicationPlugin plugin = (IApplicationPlugin) node.CreateInstance(); IApplicationPlugin plugin = (IApplicationPlugin) node.CreateInstance();
plugin.Initialise(this);
m_plugins.Add(plugin); // Debug code to try and track down a bizzare ubuntu/mono/linux bug on standalone where we
// appear to try and initialize all the plugins twice. Currently disabled
// MainLog.Instance.Verbose("PLUGINS", "Hitting plugin {0}", plugin.ToString());
// if (m_plugins.Contains(plugin))
// {
// MainLog.Instance.Verbose("PLUGINS", "Skipping {0}", plugin.ToString());
// }
// else
// {
plugin.Initialise(this);
m_plugins.Add(plugin);
// }
} }
// Start UDP servers // Start UDP servers

View File

@ -30,7 +30,9 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using libsecondlife; using libsecondlife;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.UserManagement; using OpenSim.Framework.UserManagement;
using InventoryFolder=OpenSim.Framework.InventoryFolder; using InventoryFolder=OpenSim.Framework.InventoryFolder;
@ -52,7 +54,7 @@ namespace OpenSim.Region.Communications.Local
public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent,
NetworkServersInfo serversInfo, bool authenticate) NetworkServersInfo serversInfo, bool authenticate)
: base(userManager, welcomeMess) : base(userManager, parent.UserProfileCacheService.libraryRoot, welcomeMess)
{ {
m_Parent = parent; m_Parent = parent;
this.serversInfo = serversInfo; this.serversInfo = serversInfo;

View File

@ -1,6 +1,22 @@
<Nini> <Nini>
<!-- the root Opensim Library folder ID is 00000112-000f-0000-0000-000100bba000 --> <!-- the root Opensim Library folder ID is 00000112-000f-0000-0000-000100bba000 -->
<!--
<Section Name="Fart notecard">
<Key Name="inventoryID" Value="30000000-0000-2222-4444-000000000001" />
<Key Name="assetID" Value="30000000-0000-2222-3333-000000000001" />
<Key Name="folderID" Value="30000112-000f-0000-0000-000100bba001"/>
<Key Name="description" Value="ha" />
<Key Name="name" Value="Fart" />
<Key Name="assetType" Value="7" />
<Key Name="inventoryType" Value="7" />
<Key Name="currentPermissions" Value="2147483647" />
<Key Name="nextPermissions" Value="2147483647" />
<Key Name="everyonePermissions" Value="2147483647" />
<Key Name="basePermissions" Value="2147483647" />
</Section>
-->
<Section Name="Welcome notecard"> <Section Name="Welcome notecard">
<Key Name="inventoryID" Value="00000000-0000-2222-4444-000000000001" /> <Key Name="inventoryID" Value="00000000-0000-2222-4444-000000000001" />
<Key Name="assetID" Value="00000000-0000-2222-3333-000000000001" /> <Key Name="assetID" Value="00000000-0000-2222-3333-000000000001" />
@ -9,10 +25,10 @@
<Key Name="name" Value="Welcome" /> <Key Name="name" Value="Welcome" />
<Key Name="assetType" Value="7" /> <Key Name="assetType" Value="7" />
<Key Name="inventoryType" Value="7" /> <Key Name="inventoryType" Value="7" />
<Key Name="currentPermissions" Value="1000000000000000" /> <Key Name="currentPermissions" Value="2147483647" />
<Key Name="nextPermissions" Value="1000000000000000" /> <Key Name="nextPermissions" Value="2147483647" />
<Key Name="everyonePermissions" Value="1000000000000000" /> <Key Name="everyonePermissions" Value="2147483647" />
<Key Name="basePermissions" Value="1000000000000000" /> <Key Name="basePermissions" Value="2147483647" />
</Section> </Section>
<Section Name="4-tile2 Texture"> <Section Name="4-tile2 Texture">
<Key Name="inventoryID" Value="00000000-0000-2222-4444-100000001000" /> <Key Name="inventoryID" Value="00000000-0000-2222-4444-100000001000" />

View File

@ -0,0 +1,18 @@
<Nini>
<!-- The root library inventory folder is hardcoded as 00000112-000f-0000-0000-000100bba000 -->
<Section Name="Texture Library">
<Key Name="folderID" Value="00000112-000f-0000-0000-000100bba001"/>
<Key Name="parentFolderID" Value="00000112-000f-0000-0000-000100bba000"/>
<Key Name="name" Value="Texture Library"/>
<Key Name="type" Value="0"/>
</Section>
<!--
<Section Name="Cheese Library">
<Key Name="folderID" Value="30000112-000f-0000-0000-000100bba001"/>
<Key Name="parentFolderID" Value="00000112-000f-0000-0000-000100bba000"/>
<Key Name="name" Value="Cheese Library"/>
<Key Name="type" Value="13"/>
</Section>
-->
</Nini>

View File

@ -1,6 +1,14 @@
README README
Inventory configuration is carried out here. Currently, you can add new items to OpenSimLibrary/OpenSimLibrary.xml, The standard common inventory library is configured here. You can add new inventory
folders to the standard library by editing OpenSimLibary/OpenSimLibraryFolders.xml
You can also add new inventory items to OpenSimLibrary/OpenSimLibrary.xml,
as long as they have a corresponding asset entry in bin/OpenSimAssetSet.xml. as long as they have a corresponding asset entry in bin/OpenSimAssetSet.xml.
The same set of folders and items must be present in the configuration of both
the grid servers and all the regions. The reasons for this are historical -
this restriction will probably be lifted in the future, at which point the
inventory items and folders will only need to be configured on the grid inventory
server (assuming you are running in grid mode rather than standalone)
Inventory_Default.xml and Inventory_Library.xml are unused at the moment. Inventory_Default.xml and Inventory_Library.xml are unused at the moment.