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);
|
libraryFolders.Add(folderID, this);
|
||||||
|
|
||||||
string foldersPath = Path.Combine(Util.configDir(), "inventory/OpenSimLibrary/OpenSimLibraryFolders.xml");
|
LoadLibraries(Path.Combine(Util.inventoryDir(), "Libraries.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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateLibraryItems();
|
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>
|
/// <summary>
|
||||||
|
@ -155,84 +129,140 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
/// <param name="source"></param>
|
/// <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();
|
||||||
{
|
|
||||||
IConfig config = source.Configs[i];
|
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];
|
||||||
|
|
||||||
InventoryFolderImpl folderInfo = new InventoryFolderImpl();
|
libraryFolders.Add(folderInfo.folderID, folderInfo);
|
||||||
|
parentFolder.SubFolders.Add(folderInfo.folderID, folderInfo);
|
||||||
|
|
||||||
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(
|
// MainLog.Instance.Verbose(
|
||||||
// "LIBRARYINVENTORY", "Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID);
|
// "LIBRARYINVENTORY", "Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainLog.Instance.Warn(
|
MainLog.Instance.Warn(
|
||||||
"LIBRARYINVENTORY",
|
"LIBRARYINVENTORY",
|
||||||
"Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!",
|
"Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!",
|
||||||
folderInfo.name, folderInfo.folderID, folderInfo.parentID);
|
folderInfo.name, folderInfo.folderID, folderInfo.parentID);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read library inventory items metadata from an external source
|
/// Read a library inventory item metadata from a loaded configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source"></param>
|
/// <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();
|
InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID];
|
||||||
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);
|
|
||||||
|
|
||||||
if (libraryFolders.ContainsKey(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
{
|
{
|
||||||
InventoryFolderImpl parentFolder = libraryFolders[item.parentFolderID];
|
XmlConfigSource source = new XmlConfigSource(path);
|
||||||
|
|
||||||
parentFolder.Items.Add(item.inventoryID, item);
|
for (int i = 0; i < source.Configs.Count; i++)
|
||||||
|
{
|
||||||
|
action(source.Configs[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (XmlException e)
|
||||||
{
|
{
|
||||||
MainLog.Instance.Warn(
|
MainLog.Instance.Error(
|
||||||
"LIBRARYINVENTORY",
|
"LIBRARYINVENTORY", "Error loading {0} : {1}", path, e);
|
||||||
"Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!",
|
|
||||||
item.inventoryName, item.inventoryID, item.parentFolderID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainLog.Instance.Error(
|
||||||
|
"LIBRARYINVENTORY", "{0} file {1} does not exist!", fileDescription, path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -280,6 +280,7 @@ namespace OpenSim.Framework.UserManagement
|
||||||
}
|
}
|
||||||
return buddylistreturn;
|
return buddylistreturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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>
|
||||||
|
|
|
@ -321,7 +321,12 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
public static string assetsDir()
|
public static string assetsDir()
|
||||||
{
|
{
|
||||||
return "assets";
|
return Path.Combine(configDir(), "assets");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string inventoryDir()
|
||||||
|
{
|
||||||
|
return Path.Combine(configDir(), "inventory");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string configDir()
|
public static string configDir()
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
<Nini>
|
<Nini>
|
||||||
<!-- You probably don't want to remove the OpenSim asset set
|
<!-- 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">
|
<Section Name="OpenSim Asset Set">
|
||||||
<Key Name="file" Value="OpenSimAssetSet/OpenSimAssetSet.xml"/>
|
<Key Name="file" Value="OpenSimAssetSet/OpenSimAssetSet.xml"/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<!-- New asset sets can be added as shown below -->
|
<!-- New asset sets can be added as shown below -->
|
||||||
<!--
|
|
||||||
|
<!--
|
||||||
<Section Name="My Asset Set">
|
<Section Name="My Asset Set">
|
||||||
<Key Name="file" Value="MyAssetSet/MyAssetSet.xml"/>
|
<Key Name="file" Value="MyAssetSet/MyAssetSet.xml"/>
|
||||||
</Section>
|
</Section>
|
||||||
-->
|
-->
|
||||||
</Nini>
|
</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
|
README
|
||||||
|
|
||||||
The standard common inventory library is configured here. You can add new inventory
|
Folders and items which will appear in the standard common library for all
|
||||||
folders to the standard library by editing OpenSimLibary/OpenSimLibraryFolders.xml
|
avatars can be configured here. The root folder (currently called OpenSim
|
||||||
You can also add new inventory items to OpenSimLibrary/OpenSimLibrary.xml,
|
Library) is hardcoded, but you can add your own configuration of folders and
|
||||||
as long as they have a corresponding asset entry in bin/OpenSimAssetSet.xml.
|
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
|
To add a new library, edit Libraries.xml. The entry in here needs to point to
|
||||||
the grid servers and all the regions. The reasons for this are historical -
|
two further xml files, one which details your library inventory folders and another
|
||||||
this restriction will probably be lifted in the future, at which point the
|
which details your library inventory items. Each inventory item will need to be
|
||||||
inventory items and folders will only need to be configured on the grid inventory
|
associated with an asset. Assets are configured separately in the bin/assets
|
||||||
server (assuming you are running in grid mode rather than standalone)
|
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.
|
Files in the attic directory are currently unused.
|
||||||
|
|
Loading…
Reference in New Issue