Make it possible for new inventory 'libraries' to be added without changing the default OpenSimLibrary files. Additional library folders and items can be added in a separate
directory and linked in by an entry to inventory/Libraries.xmlafrisby
parent
3180432deb
commit
b8975ecbd9
|
@ -64,35 +64,9 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
|
||||
libraryFolders.Add(folderID, this);
|
||||
|
||||
string foldersPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibraryFolders.xml");
|
||||
if (File.Exists(foldersPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlConfigSource source = new XmlConfigSource(foldersPath);
|
||||
ReadFoldersFromFile(source);
|
||||
}
|
||||
catch (XmlException e)
|
||||
{
|
||||
MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + foldersPath + ": " + e.ToString());
|
||||
}
|
||||
}
|
||||
LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.xml"));
|
||||
|
||||
CreateLibraryItems();
|
||||
|
||||
string itemsPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibrary.xml");
|
||||
if (File.Exists(itemsPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlConfigSource source = new XmlConfigSource(itemsPath);
|
||||
ReadItemsFromFile(source);
|
||||
}
|
||||
catch (XmlException e)
|
||||
{
|
||||
MainLog.Instance.Error("AGENTINVENTORY", "Error loading " + itemsPath + ": " + e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -155,83 +129,139 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read library inventory folders from an external source
|
||||
/// Use the asset set information at path to load assets
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="assets"></param>
|
||||
protected void LoadLibraries(string librariesControlPath)
|
||||
{
|
||||
MainLog.Instance.Verbose(
|
||||
"LIBRARYINVENTORY", "Loading libraries 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 foldersPath
|
||||
= Path.Combine(
|
||||
Util.inventoryDir(), config.GetString("foldersFile", ""));
|
||||
|
||||
LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig);
|
||||
|
||||
string itemsPath
|
||||
= Path.Combine(
|
||||
Util.inventoryDir(), config.GetString("itemsFile", ""));
|
||||
|
||||
LoadFromFile(itemsPath, "Library items", ReadItemFromConfig);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a library inventory folder from a loaded configuration
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
private void ReadFoldersFromFile(IConfigSource source)
|
||||
private void ReadFolderFromConfig(IConfig config)
|
||||
{
|
||||
for (int i = 0; i < source.Configs.Count; 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))
|
||||
{
|
||||
IConfig config = source.Configs[i];
|
||||
InventoryFolderImpl parentFolder = libraryFolders[folderInfo.parentID];
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
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
|
||||
/// Read a library inventory item metadata from a loaded configuration
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
private void ReadItemsFromFile(IConfigSource source)
|
||||
private void ReadItemFromConfig(IConfig config)
|
||||
{
|
||||
for (int i = 0; i < source.Configs.Count; i++)
|
||||
InventoryItemBase item = new InventoryItemBase();
|
||||
item.avatarID = libOwner;
|
||||
item.creatorsID = libOwner;
|
||||
item.inventoryID = new LLUUID(config.GetString("inventoryID", folderID.ToString()));
|
||||
item.assetID = new LLUUID(config.GetString("assetID", LLUUID.Random().ToString()));
|
||||
item.parentFolderID = new LLUUID(config.GetString("folderID", folderID.ToString()));
|
||||
item.inventoryDescription = config.GetString("description", "");
|
||||
item.inventoryName = config.GetString("name", "");
|
||||
item.assetType = config.GetInt("assetType", 0);
|
||||
item.invType = config.GetInt("inventoryType", 0);
|
||||
item.inventoryCurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF);
|
||||
item.inventoryNextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF);
|
||||
item.inventoryEveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF);
|
||||
item.inventoryBasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF);
|
||||
|
||||
if (libraryFolders.ContainsKey(item.parentFolderID))
|
||||
{
|
||||
InventoryItemBase item = new InventoryItemBase();
|
||||
item.avatarID = libOwner;
|
||||
item.creatorsID = libOwner;
|
||||
item.inventoryID =
|
||||
new LLUUID(source.Configs[i].GetString("inventoryID", folderID.ToString()));
|
||||
item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToString()));
|
||||
item.parentFolderID
|
||||
= new LLUUID(source.Configs[i].GetString("folderID", folderID.ToString()));
|
||||
item.inventoryDescription = source.Configs[i].GetString("description", "");
|
||||
item.inventoryName = source.Configs[i].GetString("name", "");
|
||||
item.assetType = source.Configs[i].GetInt("assetType", 0);
|
||||
item.invType = source.Configs[i].GetInt("inventoryType", 0);
|
||||
item.inventoryCurrentPermissions = (uint) source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF);
|
||||
item.inventoryNextPermissions = (uint) source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF);
|
||||
item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF);
|
||||
item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF);
|
||||
InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID];
|
||||
|
||||
if (libraryFolders.ContainsKey(item.parentFolderID))
|
||||
{
|
||||
InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID];
|
||||
parentFolder.Items.Add(item.inventoryID, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Warn(
|
||||
"LIBRARYINVENTORY",
|
||||
"Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!",
|
||||
item.inventoryName, item.inventoryID, item.parentFolderID);
|
||||
}
|
||||
}
|
||||
|
||||
parentFolder.Items.Add(item.inventoryID, item);
|
||||
}
|
||||
else
|
||||
private delegate void ConfigAction(IConfig config);
|
||||
|
||||
/// <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 void LoadFromFile(string path, string fileDescription, ConfigAction action)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
MainLog.Instance.Warn(
|
||||
"LIBRARYINVENTORY",
|
||||
"Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!",
|
||||
item.inventoryName, item.inventoryID, item.parentFolderID);
|
||||
XmlConfigSource source = new XmlConfigSource(path);
|
||||
|
||||
for (int i = 0; i < source.Configs.Count; i++)
|
||||
{
|
||||
action(source.Configs[i]);
|
||||
}
|
||||
}
|
||||
catch (XmlException e)
|
||||
{
|
||||
MainLog.Instance.Error(
|
||||
"LIBRARYINVENTORY", "Error loading {0} : {1}", path, e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Error(
|
||||
"LIBRARYINVENTORY", "{0} file {1} does not exist!", fileDescription, path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -280,6 +280,7 @@ namespace OpenSim.Framework.UserManagement
|
|||
}
|
||||
return buddylistreturn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the inventory library skeleton into the form required by the rpc request.
|
||||
/// </summary>
|
||||
|
|
|
@ -321,7 +321,12 @@ namespace OpenSim.Framework
|
|||
|
||||
public static string assetsDir()
|
||||
{
|
||||
return "assets";
|
||||
return Path.Combine(configDir(), "assets");
|
||||
}
|
||||
|
||||
public static string inventoryDir()
|
||||
{
|
||||
return Path.Combine(configDir(), "inventory");
|
||||
}
|
||||
|
||||
public static string configDir()
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
<Nini>
|
||||
<!-- You probably don't want to remove the OpenSim asset set
|
||||
since it contains various default assets which are currently hardcoded -->
|
||||
since it contains various default assets which are currently hardcoded
|
||||
However, you can remove the corresponding inventory library in bin/inventory if you wish
|
||||
-->
|
||||
|
||||
<Section Name="OpenSim Asset Set">
|
||||
<Key Name="file" Value="OpenSimAssetSet/OpenSimAssetSet.xml"/>
|
||||
</Section>
|
||||
|
||||
<!-- New asset sets can be added as shown below -->
|
||||
<!--
|
||||
|
||||
<!--
|
||||
<Section Name="My Asset Set">
|
||||
<Key Name="file" Value="MyAssetSet/MyAssetSet.xml"/>
|
||||
</Section>
|
||||
-->
|
||||
-->
|
||||
</Nini>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<Nini>
|
||||
<Section Name="OpenSim Standard Library">
|
||||
<Key Name="foldersFile" Value="OpenSimLibrary/OpenSimLibraryFolders.xml"/>
|
||||
<Key Name="itemsFile" Value="OpenSimLibrary/OpenSimLibrary.xml"/>
|
||||
</Section>
|
||||
<!-- Additional libraries can be added as shown below. These folders and items can appear underneath
|
||||
the hardcoded root library folder ("OpenSim Library")
|
||||
|
||||
You can also add folders and items to the folders of libraries defined earlier on in this file -->
|
||||
|
||||
<!--
|
||||
<Section Name="My Site Library">
|
||||
<Key Name="foldersFile" Value="MySiteLibrary/MySiteLibraryFolders.xml"/>
|
||||
<Key Name="itemsFile" Value="MySiteLibrary/MySiteLibraryItems.xml"/>
|
||||
</Section>
|
||||
-->
|
||||
</Nini>
|
|
@ -1,14 +1,21 @@
|
|||
README
|
||||
|
||||
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.
|
||||
Folders and items which will appear in the standard common library for all
|
||||
avatars can be configured here. The root folder (currently called OpenSim
|
||||
Library) is hardcoded, but you can add your own configuration of folders and
|
||||
items directly beneath this, in addition to (or instead of) the contents of the
|
||||
default OpenSim library.
|
||||
|
||||
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)
|
||||
To add a new library, edit Libraries.xml. The entry in here needs to point to
|
||||
two further xml files, one which details your library inventory folders and another
|
||||
which details your library inventory items. Each inventory item will need to be
|
||||
associated with an asset. Assets are configured separately in the bin/assets
|
||||
directory.
|
||||
|
||||
If you are running in grid mode, any library you add must be present in both
|
||||
your grid servers installation and in
|
||||
every region installation, otherwise library items will fail in the regions
|
||||
where the inventory configuration is not present. The reasons for this are historical
|
||||
and will probably be lifted in a future revision.
|
||||
|
||||
Files in the attic directory are currently unused.
|
||||
|
|
Loading…
Reference in New Issue