Added support for OpenSim application plugins (as requested by Adam), which use Mono.addins for loading/management. (which is a pure .net solution so works on both Mono and MS .net, and is under the MIT license, will add the source code for the library later). I also suggest we look into switching to using Mono.addins for our Region module loading management.

A little bit more refactoring of Scene.
afrisby
MW 2007-11-04 13:48:15 +00:00
parent d34ee746e7
commit 039f2c46c0
10 changed files with 102 additions and 57 deletions

View File

@ -44,7 +44,8 @@ using OpenSim.Region.Environment;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Physics.Manager;
using Mono.Addins;
using Mono.Addins.Description;
namespace OpenSim
{
@ -93,6 +94,8 @@ namespace OpenSim
: base()
{
IConfig startupConfig = configSource.Configs["Startup"];
AddinManager.Initialize(".");
string iniFilePath = startupConfig.GetString("inifile", "OpenSim.ini");
@ -275,6 +278,13 @@ namespace OpenSim
m_httpServer.AddStreamHandler(new SimStatusHandler());
}
MainLog.Instance.Verbose("Plugins", "Loading OpenSim application plugins");
foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/Startup"))
{
IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance();
plugin.Initialise(this);
}
IRegionLoader regionLoader;
if (m_config.Configs["Startup"].GetString("region_info_source", "filesystem") == "filesystem")
{

View File

@ -177,7 +177,7 @@ namespace OpenSim.Region.Environment.Modules
asset.Description = "dynamic image";
asset.Local = false;
asset.Temporary = false;
scene.commsManager.AssetCache.AddAsset(asset);
scene.AssetCache.AddAsset(asset);
LastAssetID = asset.FullID;

View File

@ -128,7 +128,7 @@ namespace OpenSim.Region.Environment.Modules
AssetRequest request = new AssetRequest(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber);
ClientRequests[client.AgentId].Add(e.RequestedAssetID, request);
}
m_scene.commsManager.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback);
m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback);
}
}

View File

@ -91,8 +91,6 @@ namespace OpenSim.Region.Environment.Scenes
}
else
{
//newAvatar.OnSignificantClientMovement += m_LandManager.handleSignificantClientMovement;
MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new root agent.");
MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Adding Physical agent.");

View File

@ -52,7 +52,7 @@ namespace OpenSim.Region.Environment.Scenes
public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item)
{
CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
userInfo.AddItem(remoteClient.AgentId, item);
@ -74,7 +74,7 @@ namespace OpenSim.Region.Environment.Scenes
public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data)
{
CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
if (userInfo.RootFolder != null)
@ -89,7 +89,7 @@ namespace OpenSim.Region.Environment.Scenes
asset.InvType = (sbyte) item.invType;
asset.Name = item.inventoryName;
asset.Data = data;
commsManager.AssetCache.AddAsset(asset);
AssetCache.AddAsset(asset);
item.assetID = asset.FullID;
userInfo.UpdateItem(remoteClient.AgentId, item);
@ -114,7 +114,7 @@ namespace OpenSim.Region.Environment.Scenes
public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID,
LLUUID itemID)
{
CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
if (userInfo.RootFolder != null)
@ -123,13 +123,13 @@ namespace OpenSim.Region.Environment.Scenes
if (item != null)
{
AgentAssetTransactions transactions =
commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
if (transactions != null)
{
AssetBase asset = null;
bool addToCache = false;
asset = commsManager.AssetCache.GetAsset(assetID);
asset = AssetCache.GetAsset(assetID);
if (asset == null)
{
asset = transactions.GetTransactionAsset(transactionID);
@ -148,7 +148,7 @@ namespace OpenSim.Region.Environment.Scenes
if (addToCache)
{
commsManager.AssetCache.AddAsset(asset);
AssetCache.AddAsset(asset);
}
userInfo.UpdateItem(remoteClient.AgentId, item);
@ -179,7 +179,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (transActionID == LLUUID.Zero)
{
CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
AssetBase asset = new AssetBase();
@ -189,7 +189,7 @@ namespace OpenSim.Region.Environment.Scenes
asset.Type = type;
asset.FullID = LLUUID.Random();
asset.Data = new byte[1];
commsManager.AssetCache.AddAsset(asset);
AssetCache.AddAsset(asset);
InventoryItemBase item = new InventoryItemBase();
item.avatarID = remoteClient.AgentId;
@ -210,7 +210,7 @@ namespace OpenSim.Region.Environment.Scenes
}
else
{
commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID,
CommsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID,
callbackID, description, name, invType,
type, wearableType, nextOwnerMask);
//System.Console.WriteLine("request to create inventory item from transaction " + transActionID);
@ -269,7 +269,7 @@ namespace OpenSim.Region.Environment.Scenes
public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID)
{
CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
LLUUID copyID = LLUUID.Random();
if (userInfo != null)
{
@ -284,7 +284,7 @@ namespace OpenSim.Region.Environment.Scenes
{
isTexture = true;
}
AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture);
AssetBase rezAsset = AssetCache.GetAsset(item.assetID, isTexture);
if (rezAsset != null)
{
string script = Util.FieldToString(rezAsset.Data);
@ -295,7 +295,7 @@ namespace OpenSim.Region.Environment.Scenes
else
{
//lets try once more incase the asset cache is being slow getting the asset from server
rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture);
rezAsset = AssetCache.GetAsset(item.assetID, isTexture);
if (rezAsset != null)
{
string script = Util.FieldToString(rezAsset.Data);
@ -360,7 +360,7 @@ namespace OpenSim.Region.Environment.Scenes
if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID))
{
string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString();
CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
AssetBase asset = new AssetBase();
@ -371,7 +371,7 @@ namespace OpenSim.Region.Environment.Scenes
asset.Type = 6;
asset.FullID = LLUUID.Random();
asset.Data = Helpers.StringToField(sceneObjectXml);
commsManager.AssetCache.AddAsset(asset);
AssetCache.AddAsset(asset);
InventoryItemBase item = new InventoryItemBase();
@ -407,7 +407,7 @@ namespace OpenSim.Region.Environment.Scenes
rootPart.PhysActor = null;
}
storageManager.DataStore.RemoveObject(group.UUID, m_regInfo.RegionID);
m_storageManager.DataStore.RemoveObject(group.UUID, m_regInfo.RegionID);
group.DeleteGroup();
lock (Entities)
@ -419,7 +419,7 @@ namespace OpenSim.Region.Environment.Scenes
public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos)
{
CachedUserInfo userInfo = commsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
if (userInfo.RootFolder != null)
@ -427,7 +427,7 @@ namespace OpenSim.Region.Environment.Scenes
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
if (item != null)
{
AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false);
AssetBase rezAsset = AssetCache.GetAsset(item.assetID, false);
if (rezAsset != null)
{
AddRezObject(Util.FieldToString(rezAsset.Data), pos);
@ -437,7 +437,7 @@ namespace OpenSim.Region.Environment.Scenes
else
{
//lets try once more incase the asset cache is being slow getting the asset from server
rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false);
rezAsset = AssetCache.GetAsset(item.assetID, false);
if (rezAsset != null)
{
AddRezObject(Util.FieldToString(rezAsset.Data), pos);

View File

@ -70,13 +70,13 @@ namespace OpenSim.Region.Environment.Scenes
private readonly Mutex updateLock;
protected ModuleLoader m_moduleLoader;
protected StorageManager storageManager;
protected AgentCircuitManager authenticateHandler;
public CommunicationsManager commsManager;
protected StorageManager m_storageManager;
protected AgentCircuitManager m_authenticateHandler;
public CommunicationsManager CommsManager;
// protected XferManager xferManager;
protected SceneCommunicationService m_sceneGridService;
protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>();
protected Dictionary<LLUUID, Caps> m_capsHandlers = new Dictionary<LLUUID, Caps>();
protected BaseHttpServer httpListener;
protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>();
@ -116,7 +116,7 @@ namespace OpenSim.Region.Environment.Scenes
public AgentCircuitManager AuthenticateHandler
{
get { return authenticateHandler; }
get { return m_authenticateHandler; }
}
private readonly LandManager m_LandManager;
@ -191,11 +191,11 @@ namespace OpenSim.Region.Environment.Scenes
updateLock = new Mutex(false);
m_moduleLoader = moduleLoader;
authenticateHandler = authen;
commsManager = commsMan;
m_authenticateHandler = authen;
CommsManager = commsMan;
m_sceneGridService = sceneGridService;
storageManager = storeManager;
assetCache = assetCach;
m_storageManager = storeManager;
AssetCache = assetCach;
m_regInfo = regInfo;
m_regionHandle = m_regInfo.RegionHandle;
m_regionName = m_regInfo.RegionName;
@ -393,7 +393,7 @@ namespace OpenSim.Region.Environment.Scenes
phyScene.SetTerrain(Terrain.GetHeights1D());
}
storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID);
m_storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID);
float[] terData = Terrain.GetHeights1D();
@ -470,7 +470,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns>
public bool Backup()
{
EventManager.TriggerOnBackup(storageManager.DataStore);
EventManager.TriggerOnBackup(m_storageManager.DataStore);
return true;
}
@ -486,7 +486,7 @@ namespace OpenSim.Region.Environment.Scenes
{
try
{
double[,] map = storageManager.DataStore.LoadTerrain(RegionInfo.RegionID);
double[,] map = m_storageManager.DataStore.LoadTerrain(RegionInfo.RegionID);
if (map == null)
{
if (string.IsNullOrEmpty(m_regInfo.EstateSettings.terrainFile))
@ -494,7 +494,7 @@ namespace OpenSim.Region.Environment.Scenes
MainLog.Instance.Verbose("TERRAIN", "No default terrain. Generating a new terrain.");
Terrain.HillsGenerator();
storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID);
m_storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID);
}
else
{
@ -509,7 +509,7 @@ namespace OpenSim.Region.Environment.Scenes
"No terrain found in database or default. Generating a new terrain.");
Terrain.HillsGenerator();
}
storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID);
m_storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID);
}
}
else
@ -539,7 +539,7 @@ namespace OpenSim.Region.Environment.Scenes
asset.Name = "terrainImage";
asset.Type = 0;
asset.Temporary = true;
commsManager.AssetCache.AddAsset(asset);
AssetCache.AddAsset(asset);
}
#endregion
@ -552,7 +552,7 @@ namespace OpenSim.Region.Environment.Scenes
public virtual void LoadPrimsFromStorage()
{
MainLog.Instance.Verbose("Loading objects from datastore");
List<SceneObjectGroup> PrimsFromDB = storageManager.DataStore.LoadObjects(m_regInfo.RegionID);
List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(m_regInfo.RegionID);
foreach (SceneObjectGroup prim in PrimsFromDB)
{
AddEntityFromStorage(prim);
@ -790,8 +790,8 @@ namespace OpenSim.Region.Environment.Scenes
CreateAndAddScenePresence(client, child);
m_LandManager.sendParcelOverlay(client);
commsManager.UserProfileCache.AddNewUser(client.AgentId);
commsManager.TransactionsManager.AddUser(client.AgentId);
CommsManager.UserProfileCache.AddNewUser(client.AgentId);
CommsManager.TransactionsManager.AddUser(client.AgentId);
}
protected virtual void SubscribeToClientEvents(IClientAPI client)
@ -818,7 +818,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnGrabUpdate += m_innerScene.MoveObject;
client.OnDeRezObject += DeRezObject;
client.OnRezObject += RezObject;
client.OnNameFromUUIDRequest += commsManager.HandleUUIDNameRequest;
client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest;
client.OnObjectDescription += m_innerScene.PrimDescription;
client.OnObjectName += m_innerScene.PrimName;
client.OnLinkObjects += m_innerScene.LinkObjects;
@ -837,13 +837,13 @@ namespace OpenSim.Region.Environment.Scenes
client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
client.OnCreateNewInventoryItem += CreateNewInventoryItem;
client.OnCreateNewInventoryFolder += commsManager.UserProfileCache.HandleCreateInventoryFolder;
client.OnFetchInventoryDescendents += commsManager.UserProfileCache.HandleFecthInventoryDescendents;
client.OnCreateNewInventoryFolder += CommsManager.UserProfileCache.HandleCreateInventoryFolder;
client.OnFetchInventoryDescendents += CommsManager.UserProfileCache.HandleFecthInventoryDescendents;
client.OnRequestTaskInventory += RequestTaskInventory;
client.OnFetchInventory += commsManager.UserProfileCache.HandleFetchInventory;
client.OnFetchInventory += CommsManager.UserProfileCache.HandleFetchInventory;
client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset;
client.OnAssetUploadRequest += commsManager.TransactionsManager.HandleUDPUploadRequest;
client.OnXferReceive += commsManager.TransactionsManager.HandleXfer;
client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest;
client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer;
client.OnRezScript += RezScript;
client.OnRemoveTaskItem += RemoveTaskInventory;
@ -904,7 +904,7 @@ namespace OpenSim.Region.Environment.Scenes
avatar.Close();
// Remove client agent from profile, so new logins will work
commsManager.UserService.clearUserAgent(agentID);
CommsManager.UserService.clearUserAgent(agentID);
return;
}
@ -926,7 +926,7 @@ namespace OpenSim.Region.Environment.Scenes
if (Entities.ContainsKey(entID))
{
Entities.Remove(entID);
storageManager.DataStore.RemoveObject(entID, m_regInfo.RegionID);
m_storageManager.DataStore.RemoveObject(entID, m_regInfo.RegionID);
return true;
}
return false;
@ -963,7 +963,7 @@ namespace OpenSim.Region.Environment.Scenes
if (agent.CapsPath != "")
{
Caps cap =
new Caps(commsManager.AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port,
new Caps(AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port,
agent.CapsPath, agent.AgentID, m_dumpAssetsToFile);
Util.SetCapsURL(agent.AgentID, "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() +
@ -971,18 +971,18 @@ namespace OpenSim.Region.Environment.Scenes
cap.RegisterHandlers();
cap.AddNewInventoryItem = AddInventoryItem;
cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset;
if (capsHandlers.ContainsKey(agent.AgentID))
if (m_capsHandlers.ContainsKey(agent.AgentID))
{
//MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " +
// agent.AgentID.ToStringHyphenated());
capsHandlers[agent.AgentID] = cap;
m_capsHandlers[agent.AgentID] = cap;
}
else
{
capsHandlers.Add(agent.AgentID, cap);
m_capsHandlers.Add(agent.AgentID, cap);
}
}
authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
}
}

View File

@ -68,7 +68,13 @@ namespace OpenSim.Region.Environment.Scenes
protected object m_syncRoot = new object();
private uint m_nextLocalId = 8880000;
protected AssetCache assetCache;
private AssetCache m_assetCache;
public AssetCache AssetCache
{
get { return m_assetCache; }
set { m_assetCache = value; }
}
#endregion

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727" />
</startup>
</configuration>

BIN
bin/mono-addins.exe Normal file

Binary file not shown.

View File

@ -649,7 +649,6 @@
</Files>
</Project>
<!-- OpenSim app -->
<Project name="OpenSim" path="OpenSim/Region/Application" type="Exe">
<Configuration name="Debug">
@ -684,6 +683,32 @@
<Reference name="XMLRPC.dll"/>
<Reference name="OpenSim.Region.Communications.Local"/>
<Reference name="Nini.dll" />
<Reference name="mono-addins.exe" />
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>
<Project name="OpenSim.ApplicationPlugins.Example" path="OpenSim/ApplicationPlugins/Example" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Xml"/>
<Reference name="libsecondlife.dll" />
<Reference name="OpenSim"/>
<Reference name="OpenSim.Region.ClientStack"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="mono-addins.exe" />
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>