The startup set of assets in the local asset server can now be set from a xml file (OpenSimAssetSet.xml). (remember to make changes to the set, you will also need to delete the old asset .yap file, so that it is recreated).

Also the set of items in the OpenSim inventory Library can also now be set from a xml file (OpenSimLibrary.xml).
afrisby
MW 2007-08-08 17:11:02 +00:00
parent 7aed9ac59a
commit cf203cf5ee
6 changed files with 99 additions and 6 deletions

View File

@ -1,8 +1,11 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using OpenSim.Framework.Utilities;
using OpenSim.Framework.Data;
using Nini.Config;
namespace OpenSim.Framework.Communications.Caches
{
@ -18,7 +21,7 @@ namespace OpenSim.Framework.Communications.Caches
this.name = "OpenSim Library";
this.parentID = LLUUID.Zero;
this.type = (short)-1;
this.version = (ushort) 1;
this.version = (ushort)1;
InventoryFolder folderInfo = new InventoryFolder();
folderInfo.agentID = libOwner;
@ -31,6 +34,10 @@ namespace OpenSim.Framework.Communications.Caches
this.m_textureFolder = folderInfo;
this.CreateLibraryItems();
string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml");
XmlConfigSource source = new XmlConfigSource(filePath);
this.ReadItemsFromFile(source);
}
private void CreateLibraryItems()
@ -167,6 +174,7 @@ namespace OpenSim.Framework.Communications.Caches
item.inventoryNextPermissions = 0;
this.Items.Add(item.inventoryID, item);
/*
item = new InventoryItemBase();
item.avatarID = libOwner;
item.creatorsID = libOwner;
@ -182,6 +190,37 @@ namespace OpenSim.Framework.Communications.Caches
item.inventoryEveryOnePermissions = (1 << 15);
item.inventoryBasePermissions = (1 << 15);
this.Items.Add(item.inventoryID, item);
*/
}
private void ReadItemsFromFile(IConfigSource source)
{
for (int i = 0; i < source.Configs.Count; i++)
{
InventoryItemBase item = new InventoryItemBase();
item.avatarID = libOwner;
item.creatorsID = libOwner;
item.inventoryID = new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToStringHyphenated()));
item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()));
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 (item.assetType == 0)
{
item.parentFolderID = this.m_textureFolder.folderID;
this.m_textureFolder.Items.Add(item.inventoryID, item);
}
else
{
item.parentFolderID = this.folderID;
this.Items.Add(item.inventoryID, item);
}
}
}
}

View File

@ -31,6 +31,7 @@ using System.Threading;
using Db4objects.Db4o;
using Db4objects.Db4o.Query;
using libsecondlife;
using Nini.Config;
using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types;
@ -345,7 +346,7 @@ namespace OpenSim.Region.GridInterfaces.Local
db.Set(store);
db.Commit();
Image = new AssetBase();
/*Image = new AssetBase();
Image.FullID = new LLUUID("00000000-0000-2222-3333-000000000001");
Image.Name = "WelcomeNote";
Image.Type = 7;
@ -357,7 +358,35 @@ namespace OpenSim.Region.GridInterfaces.Local
store.UUID = Image.FullID;
db.Set(store);
db.Commit();
*/
string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml");
XmlConfigSource source = new XmlConfigSource(filePath);
ReadAssetDetails(source);
}
protected void ReadAssetDetails(IConfigSource source)
{
AssetBase newAsset = null;
for (int i = 0; i < source.Configs.Count; i++)
{
newAsset = new AssetBase();
newAsset.FullID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()));
newAsset.Name = source.Configs[i].GetString("name", "");
newAsset.Type =(sbyte) source.Configs[i].GetInt("assetType", 0);
newAsset.InvType =(sbyte) source.Configs[i].GetInt("inventoryType", 0);
string fileName = source.Configs[i].GetString("fileName", "");
if (fileName != "")
{
this.LoadAsset(newAsset, false, fileName);
AssetStorage store = new AssetStorage();
store.Data = newAsset.Data;
store.Name = newAsset.Name;
store.UUID = newAsset.FullID;
db.Set(store);
db.Commit();
}
}
}
private void LoadAsset(AssetBase info, bool image, string filename)

View File

@ -30,7 +30,7 @@ using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
//using System.Windows.Forms;
namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
{

9
bin/OpenSimAssetSet.xml Normal file
View File

@ -0,0 +1,9 @@
<Nini>
<Section Name="Welcome notecard">
<Key Name="assetID" Value="00000000-0000-2222-3333-000000000001" />
<Key Name="name" Value="WelcomeNote" />
<Key Name="assetType" Value="7" />
<Key Name="inventoryType" Value="7" />
<Key Name="fileName" Value="welcomeNote.dat" />
</Section>
</Nini>

14
bin/OpenSimLibrary.xml Normal file
View File

@ -0,0 +1,14 @@
<Nini>
<Section Name="Welcome notecard">
<Key Name="inventoryID" Value="00000000-0000-2222-4444-000000000001" />
<Key Name="assetID" Value="00000000-0000-2222-3333-000000000001" />
<Key Name="description" Value="Welcome" />
<Key Name="name" Value="Welcome" />
<Key Name="assetType" Value="7" />
<Key Name="inventoryType" Value="7" />
<Key Name="currentPermissions" Value="1000000000000000" />
<Key Name="nextPermissions" Value="1000000000000000" />
<Key Name="everyonePermissions" Value="1000000000000000" />
<Key Name="basePermissions" Value="1000000000000000" />
</Section>
</Nini>

View File

@ -203,6 +203,7 @@
<Reference name="libsecondlife.dll"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="Nini.dll" />
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
@ -452,6 +453,7 @@
<Reference name="OpenSim.Framework.Data" />
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="libsecondlife.dll"/>
<Reference name="Nini.dll" />
<Files>
<Match pattern="*.cs" recurse="true"/>