diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs index 2626b14ba9..5ec77f380b 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs @@ -1,132 +1,133 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -/* Original code: Tedd Hansen */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Console; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Scenes.Scripting; -using OpenSim.Region.Environment.Interfaces; -using libsecondlife; - -namespace OpenSim.Grid.ScriptEngine.DotNetEngine -{ - /// - /// This is the root object for ScriptEngine - /// - [Serializable] - public class ScriptEngine :IRegionModule - { - - internal OpenSim.Region.Environment.Scenes.Scene World; - internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim - internal EventQueueManager m_EventQueueManager; // Executes events - internal ScriptManager m_ScriptManager; // Load, unload and execute scripts - internal AppDomainManager m_AppDomainManager; - internal LSLLongCmdHandler m_LSLLongCmdHandler; - - private OpenSim.Framework.Console.LogBase m_log; - - public ScriptEngine() - { - //Common.SendToDebug("ScriptEngine Object Initialized"); - Common.mySE = this; - } - - public LogBase Log - { - get { return m_log; } - } - - public void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger) - { - - World = Sceneworld; - m_log = logger; - - Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing"); - - //m_logger.Status("ScriptEngine", "InitializeEngine"); - - // Create all objects we'll be using - m_EventQueueManager = new EventQueueManager(this); - m_EventManager = new EventManager(this); - m_ScriptManager = new ScriptManager(this); - m_AppDomainManager = new AppDomainManager(); - m_LSLLongCmdHandler = new LSLLongCmdHandler(this); - - // Should we iterate the region for scripts that needs starting? - // Or can we assume we are loaded before anything else so we can use proper events? - - - } - - public void Shutdown() - { - // We are shutting down - } - - //// !!!FOR DEBUGGING ONLY!!! (for executing script directly from test app) - //[Obsolete("!!!FOR DEBUGGING ONLY!!!")] - //public void StartScript(string ScriptID, IScriptHost ObjectID) - //{ - // this.myEventManager.TEMP_OBJECT_ID = ObjectID; - // Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID); - // myScriptManager.StartScript(ScriptID, ObjectID); - //} - - #region IRegionModule - - public void Initialise(Scene scene) - { - this.InitializeEngine(scene, MainLog.Instance); - } - - public void PostInitialise() - { - - } - - public void Close() - { - } - - public string Name - { - get { return "LSLScriptingModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - - #endregion - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +/* Original code: Tedd Hansen */ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Scenes.Scripting; +using OpenSim.Region.Environment.Interfaces; +using libsecondlife; +using Nini.Config; + +namespace OpenSim.Grid.ScriptEngine.DotNetEngine +{ + /// + /// This is the root object for ScriptEngine + /// + [Serializable] + public class ScriptEngine :IRegionModule + { + + internal OpenSim.Region.Environment.Scenes.Scene World; + internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim + internal EventQueueManager m_EventQueueManager; // Executes events + internal ScriptManager m_ScriptManager; // Load, unload and execute scripts + internal AppDomainManager m_AppDomainManager; + internal LSLLongCmdHandler m_LSLLongCmdHandler; + + private OpenSim.Framework.Console.LogBase m_log; + + public ScriptEngine() + { + //Common.SendToDebug("ScriptEngine Object Initialized"); + Common.mySE = this; + } + + public LogBase Log + { + get { return m_log; } + } + + public void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger) + { + + World = Sceneworld; + m_log = logger; + + Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing"); + + //m_logger.Status("ScriptEngine", "InitializeEngine"); + + // Create all objects we'll be using + m_EventQueueManager = new EventQueueManager(this); + m_EventManager = new EventManager(this); + m_ScriptManager = new ScriptManager(this); + m_AppDomainManager = new AppDomainManager(); + m_LSLLongCmdHandler = new LSLLongCmdHandler(this); + + // Should we iterate the region for scripts that needs starting? + // Or can we assume we are loaded before anything else so we can use proper events? + + + } + + public void Shutdown() + { + // We are shutting down + } + + //// !!!FOR DEBUGGING ONLY!!! (for executing script directly from test app) + //[Obsolete("!!!FOR DEBUGGING ONLY!!!")] + //public void StartScript(string ScriptID, IScriptHost ObjectID) + //{ + // this.myEventManager.TEMP_OBJECT_ID = ObjectID; + // Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID); + // myScriptManager.StartScript(ScriptID, ObjectID); + //} + + #region IRegionModule + + public void Initialise(Scene scene, IConfigSource config) + { + this.InitializeEngine(scene, MainLog.Instance); + } + + public void PostInitialise() + { + + } + + public void Close() + { + } + + public string Name + { + get { return "LSLScriptingModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + #endregion + } +} diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 5fb514f2ed..c367537456 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -63,6 +63,7 @@ namespace OpenSim protected ModuleLoader m_moduleLoader; protected LocalLoginService m_loginService; + private IConfigSource m_config; protected string m_storageDLL = "OpenSim.DataStore.NullStorage.dll"; @@ -89,9 +90,8 @@ namespace OpenSim public OpenSimMain(IConfigSource configSource) : base() { - IConfigSource startupSource = configSource; - string iniFile = startupSource.Configs["Startup"].GetString("inifile", "OpenSim.ini"); - string useExecutePathString = startupSource.Configs["Startup"].GetString("useexecutepath", "false").ToLower(); + string iniFile = configSource.Configs["Startup"].GetString("inifile", "OpenSim.ini"); + string useExecutePathString = configSource.Configs["Startup"].GetString("useexecutepath", "false").ToLower(); bool useExecutePath = false; if (useExecutePathString == "true" || useExecutePathString == "" || useExecutePathString == "1" || useExecutePathString == "yes") { @@ -104,46 +104,46 @@ namespace OpenSim string iniFilePath = Path.Combine(Util.configDir(), iniFile); if (File.Exists(iniFilePath)) { - startupSource = new IniConfigSource(iniFilePath); + m_config = new IniConfigSource(iniFilePath); //enable following line, if we want the original config source(normally commandline args) merged with ini file settings. //in this case we have it so that if both sources have the same named setting, the command line value will overwrite the ini file value. //(as if someone has bothered to enter a command line arg, we should take notice of it) - startupSource.Merge(configSource); + m_config.Merge(configSource); } - ReadConfigSettings(startupSource); + ReadConfigSettings(); } - protected void ReadConfigSettings(IConfigSource configSource) + protected void ReadConfigSettings() { m_networkServersInfo = new NetworkServersInfo(); - m_sandbox = !configSource.Configs["Startup"].GetBoolean("gridmode", false); - m_physicsEngine = configSource.Configs["Startup"].GetString("physics", "basicphysics"); - m_silent = configSource.Configs["Startup"].GetBoolean("noverbose", false); - m_permissions = configSource.Configs["Startup"].GetBoolean("serverside_object_permissions", false); + m_sandbox = !m_config.Configs["Startup"].GetBoolean("gridmode", false); + m_physicsEngine = m_config.Configs["Startup"].GetString("physics", "basicphysics"); + m_silent = m_config.Configs["Startup"].GetBoolean("noverbose", false); + m_permissions = m_config.Configs["Startup"].GetBoolean("serverside_object_permissions", false); - m_storageDLL = configSource.Configs["Startup"].GetString("storage_plugin", "OpenSim.DataStore.NullStorage.dll"); + m_storageDLL = m_config.Configs["Startup"].GetString("storage_plugin", "OpenSim.DataStore.NullStorage.dll"); - m_startupCommandsFile = configSource.Configs["Startup"].GetString("startup_console_commands_file", ""); - m_shutdownCommandsFile = configSource.Configs["Startup"].GetString("shutdown_console_commands_file", ""); + m_startupCommandsFile = m_config.Configs["Startup"].GetString("startup_console_commands_file", ""); + m_shutdownCommandsFile = m_config.Configs["Startup"].GetString("shutdown_console_commands_file", ""); - m_scriptEngine = configSource.Configs["Startup"].GetString("script_engine", "DotNetEngine"); + m_scriptEngine = m_config.Configs["Startup"].GetString("script_engine", "DotNetEngine"); - m_assetStorage = configSource.Configs["Startup"].GetString("asset_database", "db4o"); + m_assetStorage = m_config.Configs["Startup"].GetString("asset_database", "db4o"); - configSource.Configs["Startup"].GetBoolean("default_modules", true); - configSource.Configs["Startup"].GetBoolean("default_shared_modules", true); - configSource.Configs["Startup"].GetString("except_modules", ""); - configSource.Configs["Startup"].GetString("except_shared_modules", ""); + m_config.Configs["Startup"].GetBoolean("default_modules", true); + m_config.Configs["Startup"].GetBoolean("default_shared_modules", true); + m_config.Configs["Startup"].GetString("except_modules", ""); + m_config.Configs["Startup"].GetString("except_shared_modules", ""); - standaloneAuthenticate = configSource.Configs["StandAlone"].GetBoolean("accounts_authenticate", false); - standaloneWelcomeMessage = configSource.Configs["StandAlone"].GetString("welcome_message", "Welcome to OpenSim"); - standaloneInventoryPlugin = configSource.Configs["StandAlone"].GetString("inventory_plugin", "OpenSim.Framework.Data.SQLite.dll"); - standaloneUserPlugin = configSource.Configs["StandAlone"].GetString("userDatabase_plugin", "OpenSim.Framework.Data.DB4o.dll"); - standaloneAssetPlugin = configSource.Configs["StandAlone"].GetString("asset_plugin", "OpenSim.Framework.Data.SQLite.dll"); - m_networkServersInfo.loadFromConfiguration(configSource); + standaloneAuthenticate = m_config.Configs["StandAlone"].GetBoolean("accounts_authenticate", false); + standaloneWelcomeMessage = m_config.Configs["StandAlone"].GetString("welcome_message", "Welcome to OpenSim"); + standaloneInventoryPlugin = m_config.Configs["StandAlone"].GetString("inventory_plugin", "OpenSim.Framework.Data.SQLite.dll"); + standaloneUserPlugin = m_config.Configs["StandAlone"].GetString("userDatabase_plugin", "OpenSim.Framework.Data.DB4o.dll"); + standaloneAssetPlugin = m_config.Configs["StandAlone"].GetString("asset_plugin", "OpenSim.Framework.Data.SQLite.dll"); + m_networkServersInfo.loadFromConfiguration(m_config); } @@ -207,7 +207,7 @@ namespace OpenSim configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); } - m_moduleLoader = new ModuleLoader( m_log ); + m_moduleLoader = new ModuleLoader( m_log, m_config ); MainLog.Instance.Verbose("Loading Shared Modules"); m_moduleLoader.LoadDefaultSharedModules(); diff --git a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs index e60c42b574..808b94a934 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs @@ -27,12 +27,13 @@ */ using OpenSim.Region.Environment.Scenes; +using Nini.Config; namespace OpenSim.Region.Environment.Interfaces { public interface IRegionModule { - void Initialise(Scene scene); + void Initialise(Scene scene, IConfigSource source); void PostInitialise(); void Close(); string Name { get; } diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index 69cc379187..f88f9ac63b 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs @@ -1,202 +1,205 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using OpenSim.Framework.Console; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Modules; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Environment -{ - public class ModuleLoader - { - public Dictionary LoadedAssemblys = new Dictionary(); - - public List LoadedModules = new List(); - public Dictionary LoadedSharedModules = new Dictionary(); - private readonly LogBase m_log; - - public ModuleLoader(LogBase log) - { - m_log = log; - } - - public void PickupModules(Scene scene, string moduleDir) - { - DirectoryInfo dir = new DirectoryInfo(moduleDir); - - foreach (FileInfo fileInfo in dir.GetFiles("*.dll")) - { - LoadRegionModules(fileInfo.FullName, scene); - } - } - - public void LoadDefaultSharedModules() - { - DynamicTextureModule dynamicModule = new DynamicTextureModule(); - LoadedSharedModules.Add(dynamicModule.Name, dynamicModule); - } - - public void InitialiseSharedModules(Scene scene) - { - foreach (IRegionModule module in LoadedSharedModules.Values) - { - module.Initialise(scene); - scene.AddModule(module.Name, module); //should be doing this? - } - } - - public void InitializeModule(IRegionModule module, Scene scene) - { - module.Initialise(scene); - scene.AddModule(module.Name, module); - LoadedModules.Add(module); - } - - /// - /// Loads/initialises a Module instance that can be used by mutliple Regions - /// - /// - /// - /// - public void LoadSharedModule(string dllName, string moduleName) - { - IRegionModule module = LoadModule(dllName, moduleName); - if (module != null) - { - LoadedSharedModules.Add(module.Name, module); - } - } - - public void LoadRegionModules(string dllName, Scene scene) - { - IRegionModule[] modules = LoadModules(dllName); - - if (modules.Length > 0) - { - m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName ); - foreach (IRegionModule module in modules) - { - m_log.Verbose("MODULES", " [{0}]: Initializing.", module.Name); - InitializeModule(module, scene); - } - } - } - - public void LoadRegionModule(string dllName, string moduleName, Scene scene) - { - IRegionModule module = LoadModule(dllName, moduleName); - if (module != null) - { - InitializeModule(module, scene); - } - } - - /// - /// Loads a external Module (if not already loaded) and creates a new instance of it. - /// - /// - /// - /// - public IRegionModule LoadModule(string dllName, string moduleName) - { - IRegionModule[] modules = LoadModules(dllName); - - foreach (IRegionModule module in modules) - { - if ((module != null) && (module.Name == moduleName)) - { - return module; - } - } - - return null; - } - - public IRegionModule[] LoadModules(string dllName) - { - List modules = new List(); - - Assembly pluginAssembly; - if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly )) - { - try - { - pluginAssembly = Assembly.LoadFrom(dllName); - LoadedAssemblys.Add(dllName, pluginAssembly); - } - catch( BadImageFormatException e ) - { - m_log.Warn( "MODULES", "The file [{0}] is not a module assembly.", e.FileName ); - } - } - - - if (pluginAssembly != null) - { - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - if( pluginType.GetInterface("IRegionModule") != null ) - { - modules.Add((IRegionModule) Activator.CreateInstance(pluginType)); - } - } - } - } - } - - return modules.ToArray(); - } - - public void PostInitialise() - { - foreach (IRegionModule module in LoadedSharedModules.Values) - { - module.PostInitialise(); - } - - foreach (IRegionModule module in LoadedModules) - { - module.PostInitialise(); - } - } - - public void ClearCache() - { - LoadedAssemblys.Clear(); - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Modules; +using OpenSim.Region.Environment.Scenes; +using Nini.Config; + +namespace OpenSim.Region.Environment +{ + public class ModuleLoader + { + public Dictionary LoadedAssemblys = new Dictionary(); + + public List LoadedModules = new List(); + public Dictionary LoadedSharedModules = new Dictionary(); + private readonly LogBase m_log; + private IConfigSource m_config; + + public ModuleLoader(LogBase log, IConfigSource config) + { + m_log = log; + m_config = config; + } + + public void PickupModules(Scene scene, string moduleDir) + { + DirectoryInfo dir = new DirectoryInfo(moduleDir); + + foreach (FileInfo fileInfo in dir.GetFiles("*.dll")) + { + LoadRegionModules(fileInfo.FullName, scene); + } + } + + public void LoadDefaultSharedModules() + { + DynamicTextureModule dynamicModule = new DynamicTextureModule(); + LoadedSharedModules.Add(dynamicModule.Name, dynamicModule); + } + + public void InitialiseSharedModules(Scene scene) + { + foreach (IRegionModule module in LoadedSharedModules.Values) + { + module.Initialise(scene, m_config); + scene.AddModule(module.Name, module); //should be doing this? + } + } + + public void InitializeModule(IRegionModule module, Scene scene) + { + module.Initialise(scene, m_config); + scene.AddModule(module.Name, module); + LoadedModules.Add(module); + } + + /// + /// Loads/initialises a Module instance that can be used by mutliple Regions + /// + /// + /// + /// + public void LoadSharedModule(string dllName, string moduleName) + { + IRegionModule module = LoadModule(dllName, moduleName); + if (module != null) + { + LoadedSharedModules.Add(module.Name, module); + } + } + + public void LoadRegionModules(string dllName, Scene scene) + { + IRegionModule[] modules = LoadModules(dllName); + + if (modules.Length > 0) + { + m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName ); + foreach (IRegionModule module in modules) + { + m_log.Verbose("MODULES", " [{0}]: Initializing.", module.Name); + InitializeModule(module, scene); + } + } + } + + public void LoadRegionModule(string dllName, string moduleName, Scene scene) + { + IRegionModule module = LoadModule(dllName, moduleName); + if (module != null) + { + InitializeModule(module, scene); + } + } + + /// + /// Loads a external Module (if not already loaded) and creates a new instance of it. + /// + /// + /// + /// + public IRegionModule LoadModule(string dllName, string moduleName) + { + IRegionModule[] modules = LoadModules(dllName); + + foreach (IRegionModule module in modules) + { + if ((module != null) && (module.Name == moduleName)) + { + return module; + } + } + + return null; + } + + public IRegionModule[] LoadModules(string dllName) + { + List modules = new List(); + + Assembly pluginAssembly; + if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly )) + { + try + { + pluginAssembly = Assembly.LoadFrom(dllName); + LoadedAssemblys.Add(dllName, pluginAssembly); + } + catch( BadImageFormatException e ) + { + m_log.Warn( "MODULES", "The file [{0}] is not a module assembly.", e.FileName ); + } + } + + + if (pluginAssembly != null) + { + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + if( pluginType.GetInterface("IRegionModule") != null ) + { + modules.Add((IRegionModule) Activator.CreateInstance(pluginType)); + } + } + } + } + } + + return modules.ToArray(); + } + + public void PostInitialise() + { + foreach (IRegionModule module in LoadedSharedModules.Values) + { + module.PostInitialise(); + } + + foreach (IRegionModule module in LoadedModules) + { + module.PostInitialise(); + } + } + + public void ClearCache() + { + LoadedAssemblys.Clear(); + } + } +} diff --git a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs index 417e3bcb88..b53c05e6e6 100644 --- a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs @@ -29,6 +29,7 @@ using OpenSim.Framework.Interfaces; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; +using Nini.Config; namespace OpenSim.Region.Environment.Modules { @@ -40,7 +41,7 @@ namespace OpenSim.Region.Environment.Modules { } - public void Initialise(Scene scene) + public void Initialise(Scene scene, IConfigSource config) { m_scene = scene; m_scene.EventManager.OnNewClient += NewClient; diff --git a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs index 9c627df90f..4bdb61b0a9 100644 --- a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs @@ -1,93 +1,94 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Environment.Modules -{ - public class AvatarProfilesModule : IRegionModule - { - private Scene m_scene; - - public AvatarProfilesModule() - { - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return "AvatarProfilesModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - - public void NewClient(IClientAPI client) - { - client.OnRequestAvatarProperties += RequestAvatarProperty; - } - - public void RemoveClient(IClientAPI client) - { - client.OnRequestAvatarProperties -= RequestAvatarProperty; - } - - /// - /// - /// - /// - /// - public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) - { - string about = "OpenSim crash test dummy"; - string bornOn = "Before now"; - string flAbout = "First life? What is one of those? OpenSim is my life!"; - LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); - remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", - partner); - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using Nini.Config; + +namespace OpenSim.Region.Environment.Modules +{ + public class AvatarProfilesModule : IRegionModule + { + private Scene m_scene; + + public AvatarProfilesModule() + { + } + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "AvatarProfilesModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + public void NewClient(IClientAPI client) + { + client.OnRequestAvatarProperties += RequestAvatarProperty; + } + + public void RemoveClient(IClientAPI client) + { + client.OnRequestAvatarProperties -= RequestAvatarProperty; + } + + /// + /// + /// + /// + /// + public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) + { + string about = "OpenSim crash test dummy"; + string bornOn = "Before now"; + string flAbout = "First life? What is one of those? OpenSim is my life!"; + LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); + remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", + partner); + } + } +} diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 6b8050e896..a85a12cf62 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -1,242 +1,243 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System; -using System.IO; -using System.Net.Sockets; -using System.Threading; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Environment.Modules -{ - public class ChatModule : IRegionModule, ISimChat - { - private Scene m_scene; - - private string m_server = "irc2.choopa.net"; - - // private int m_port = 6668; - //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; - private string m_nick = "OSimBot"; - private string m_channel = "#opensim"; - - // private NetworkStream m_stream; - private TcpClient m_irc; - private StreamWriter m_ircWriter; - private StreamReader m_ircReader; - - // private Thread pingSender; - // private Thread listener; - - private bool connected = false; - - public ChatModule() - { - m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); - m_irc = null; - m_ircWriter = null; - m_ircReader = null; - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - - m_scene.RegisterModuleInterface(this); - } - - public void PostInitialise() - { - /* - try - { - m_irc = new TcpClient(m_server, m_port); - m_stream = m_irc.GetStream(); - m_ircReader = new StreamReader(m_stream); - m_ircWriter = new StreamWriter(m_stream); - - pingSender = new Thread(new ThreadStart(this.PingRun)); - pingSender.Start(); - - listener = new Thread(new ThreadStart(this.ListenerRun)); - listener.Start(); - - m_ircWriter.WriteLine(m_user); - m_ircWriter.Flush(); - m_ircWriter.WriteLine("NICK " + m_nick); - m_ircWriter.Flush(); - m_ircWriter.WriteLine("JOIN " + m_channel); - m_ircWriter.Flush(); - connected = true; - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - } - */ - } - - public void Close() - { - m_ircWriter.Close(); - m_ircReader.Close(); - m_irc.Close(); - } - - public string Name - { - get { return "ChatModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - - public void NewClient(IClientAPI client) - { - client.OnChatFromViewer += SimChat; - } - - public void PingRun() - { - while (true) - { - m_ircWriter.WriteLine("PING :" + m_server); - m_ircWriter.Flush(); - Thread.Sleep(15000); - } - } - - public void ListenerRun() - { - string inputLine; - LLVector3 pos = new LLVector3(128, 128, 20); - while (true) - { - while ((inputLine = m_ircReader.ReadLine()) != null) - { - Console.WriteLine(inputLine); - if (inputLine.Contains(m_channel)) - { - string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); - m_scene.Broadcast(delegate(IClientAPI client) - { - client.SendChatMessage( - Helpers.StringToField(mess), 255, pos, "IRC:", - LLUUID.Zero); - }); - } - } - } - } - - public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, - LLUUID fromAgentID) - { - ScenePresence avatar = null; - avatar = m_scene.GetScenePresence(fromAgentID); - if (avatar != null) - { - fromPos = avatar.AbsolutePosition; - fromName = avatar.Firstname + " " + avatar.Lastname; - avatar = null; - } - - if (connected) - { - m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + - Util.FieldToString(message)); - m_ircWriter.Flush(); - } - - if (channel == 0) - { - m_scene.ForEachScenePresence(delegate(ScenePresence presence) - { - int dis = -1000; - - //err ??? the following code seems to be request a scenePresence when it already has a ref to it - avatar = m_scene.GetScenePresence(presence.ControllingClient.AgentId); - if (avatar != null) - { - dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); - } - - switch (type) - { - case 0: // Whisper - if ((dis < 10) && (dis > -10)) - { - //should change so the message is sent through the avatar rather than direct to the ClientView - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case 1: // Say - if ((dis < 30) && (dis > -30)) - { - //Console.WriteLine("sending chat"); - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case 2: // Shout - if ((dis < 100) && (dis > -100)) - { - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - - case 0xff: // Broadcast - presence.ControllingClient.SendChatMessage(message, type, - fromPos, - fromName, - fromAgentID); - break; - } - }); - } - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.IO; +using System.Net.Sockets; +using System.Threading; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using Nini.Config; + +namespace OpenSim.Region.Environment.Modules +{ + public class ChatModule : IRegionModule, ISimChat + { + private Scene m_scene; + + private string m_server = "irc2.choopa.net"; + + // private int m_port = 6668; + //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; + private string m_nick = "OSimBot"; + private string m_channel = "#opensim"; + + // private NetworkStream m_stream; + private TcpClient m_irc; + private StreamWriter m_ircWriter; + private StreamReader m_ircReader; + + // private Thread pingSender; + // private Thread listener; + + private bool connected = false; + + public ChatModule() + { + m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); + m_irc = null; + m_ircWriter = null; + m_ircReader = null; + } + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + + m_scene.RegisterModuleInterface(this); + } + + public void PostInitialise() + { + /* + try + { + m_irc = new TcpClient(m_server, m_port); + m_stream = m_irc.GetStream(); + m_ircReader = new StreamReader(m_stream); + m_ircWriter = new StreamWriter(m_stream); + + pingSender = new Thread(new ThreadStart(this.PingRun)); + pingSender.Start(); + + listener = new Thread(new ThreadStart(this.ListenerRun)); + listener.Start(); + + m_ircWriter.WriteLine(m_user); + m_ircWriter.Flush(); + m_ircWriter.WriteLine("NICK " + m_nick); + m_ircWriter.Flush(); + m_ircWriter.WriteLine("JOIN " + m_channel); + m_ircWriter.Flush(); + connected = true; + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + */ + } + + public void Close() + { + m_ircWriter.Close(); + m_ircReader.Close(); + m_irc.Close(); + } + + public string Name + { + get { return "ChatModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + public void NewClient(IClientAPI client) + { + client.OnChatFromViewer += SimChat; + } + + public void PingRun() + { + while (true) + { + m_ircWriter.WriteLine("PING :" + m_server); + m_ircWriter.Flush(); + Thread.Sleep(15000); + } + } + + public void ListenerRun() + { + string inputLine; + LLVector3 pos = new LLVector3(128, 128, 20); + while (true) + { + while ((inputLine = m_ircReader.ReadLine()) != null) + { + Console.WriteLine(inputLine); + if (inputLine.Contains(m_channel)) + { + string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); + m_scene.Broadcast(delegate(IClientAPI client) + { + client.SendChatMessage( + Helpers.StringToField(mess), 255, pos, "IRC:", + LLUUID.Zero); + }); + } + } + } + } + + public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, + LLUUID fromAgentID) + { + ScenePresence avatar = null; + avatar = m_scene.GetScenePresence(fromAgentID); + if (avatar != null) + { + fromPos = avatar.AbsolutePosition; + fromName = avatar.Firstname + " " + avatar.Lastname; + avatar = null; + } + + if (connected) + { + m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + + Util.FieldToString(message)); + m_ircWriter.Flush(); + } + + if (channel == 0) + { + m_scene.ForEachScenePresence(delegate(ScenePresence presence) + { + int dis = -1000; + + //err ??? the following code seems to be request a scenePresence when it already has a ref to it + avatar = m_scene.GetScenePresence(presence.ControllingClient.AgentId); + if (avatar != null) + { + dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); + } + + switch (type) + { + case 0: // Whisper + if ((dis < 10) && (dis > -10)) + { + //should change so the message is sent through the avatar rather than direct to the ClientView + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + case 1: // Say + if ((dis < 30) && (dis > -30)) + { + //Console.WriteLine("sending chat"); + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + case 2: // Shout + if ((dis < 100) && (dis > -100)) + { + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + + case 0xff: // Broadcast + presence.ControllingClient.SendChatMessage(message, type, + fromPos, + fromName, + fromAgentID); + break; + } + }); + } + } + } +} diff --git a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs index e776717c7f..4e29977337 100644 --- a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs +++ b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs @@ -1,190 +1,191 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System; -using System.Collections.Generic; -using libsecondlife; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Environment.Modules -{ - public class DynamicTextureModule : IRegionModule, IDynamicTextureManager - { - private Dictionary RegisteredScenes = new Dictionary(); - - private Dictionary RenderPlugins = - new Dictionary(); - - private Dictionary Updaters = new Dictionary(); - - public void Initialise(Scene scene) - { - if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) - { - RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); - scene.RegisterModuleInterface(this); - } - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return "DynamicTextureModule"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - public void RegisterRender(string handleType, IDynamicTextureRender render) - { - if (!RenderPlugins.ContainsKey(handleType)) - { - RenderPlugins.Add(handleType, render); - } - } - - public void ReturnData(LLUUID id, byte[] data) - { - if (Updaters.ContainsKey(id)) - { - DynamicTextureUpdater updater = Updaters[id]; - if (RegisteredScenes.ContainsKey(updater.SimUUID)) - { - Scene scene = RegisteredScenes[updater.SimUUID]; - updater.DataReceived(data, scene); - } - } - } - - public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, - string extraParams, int updateTimer) - { - if (RenderPlugins.ContainsKey(contentType)) - { - //Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); - - DynamicTextureUpdater updater = new DynamicTextureUpdater(); - updater.SimUUID = simID; - updater.PrimID = primID; - updater.ContentType = contentType; - updater.Url = url; - updater.UpdateTimer = updateTimer; - updater.UpdaterID = LLUUID.Random(); - updater.Params = extraParams; - - if (!Updaters.ContainsKey(updater.UpdaterID)) - { - Updaters.Add(updater.UpdaterID, updater); - } - - RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); - return updater.UpdaterID; - } - return LLUUID.Zero; - } - - public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, - string extraParams, int updateTimer) - { - if (RenderPlugins.ContainsKey(contentType)) - { - DynamicTextureUpdater updater = new DynamicTextureUpdater(); - updater.SimUUID = simID; - updater.PrimID = primID; - updater.ContentType = contentType; - updater.BodyData = data; - updater.UpdateTimer = updateTimer; - updater.UpdaterID = LLUUID.Random(); - updater.Params = extraParams; - - if (!Updaters.ContainsKey(updater.UpdaterID)) - { - Updaters.Add(updater.UpdaterID, updater); - } - - RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); - return updater.UpdaterID; - } - return LLUUID.Zero; - } - - public class DynamicTextureUpdater - { - public LLUUID SimUUID; - public LLUUID UpdaterID; - public string ContentType; - public string Url; - public string BodyData; - public LLUUID PrimID; - public int UpdateTimer; - public LLUUID LastAssetID; - public string Params; - - public DynamicTextureUpdater() - { - LastAssetID = LLUUID.Zero; - UpdateTimer = 0; - BodyData = null; - } - - public void DataReceived(byte[] data, Scene scene) - { - //TODO delete the last asset(data), if it was a dynamic texture - byte[] assetData = new byte[data.Length]; - Array.Copy(data, assetData, data.Length); - AssetBase asset = new AssetBase(); - asset.FullID = LLUUID.Random(); - asset.Data = assetData; - asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); - asset.Type = 0; - asset.Description = "dynamic image"; - asset.Local = false; - asset.Temporary = false; - scene.commsManager.AssetCache.AddAsset(asset); - - LastAssetID = asset.FullID; - - SceneObjectPart part = scene.GetSceneObjectPart(PrimID); - part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes(); - part.ScheduleFullUpdate(); - } - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using Nini.Config; + +namespace OpenSim.Region.Environment.Modules +{ + public class DynamicTextureModule : IRegionModule, IDynamicTextureManager + { + private Dictionary RegisteredScenes = new Dictionary(); + + private Dictionary RenderPlugins = + new Dictionary(); + + private Dictionary Updaters = new Dictionary(); + + public void Initialise(Scene scene, IConfigSource config) + { + if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) + { + RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); + scene.RegisterModuleInterface(this); + } + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "DynamicTextureModule"; } + } + + public bool IsSharedModule + { + get { return true; } + } + + public void RegisterRender(string handleType, IDynamicTextureRender render) + { + if (!RenderPlugins.ContainsKey(handleType)) + { + RenderPlugins.Add(handleType, render); + } + } + + public void ReturnData(LLUUID id, byte[] data) + { + if (Updaters.ContainsKey(id)) + { + DynamicTextureUpdater updater = Updaters[id]; + if (RegisteredScenes.ContainsKey(updater.SimUUID)) + { + Scene scene = RegisteredScenes[updater.SimUUID]; + updater.DataReceived(data, scene); + } + } + } + + public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, + string extraParams, int updateTimer) + { + if (RenderPlugins.ContainsKey(contentType)) + { + //Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); + + DynamicTextureUpdater updater = new DynamicTextureUpdater(); + updater.SimUUID = simID; + updater.PrimID = primID; + updater.ContentType = contentType; + updater.Url = url; + updater.UpdateTimer = updateTimer; + updater.UpdaterID = LLUUID.Random(); + updater.Params = extraParams; + + if (!Updaters.ContainsKey(updater.UpdaterID)) + { + Updaters.Add(updater.UpdaterID, updater); + } + + RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); + return updater.UpdaterID; + } + return LLUUID.Zero; + } + + public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, + string extraParams, int updateTimer) + { + if (RenderPlugins.ContainsKey(contentType)) + { + DynamicTextureUpdater updater = new DynamicTextureUpdater(); + updater.SimUUID = simID; + updater.PrimID = primID; + updater.ContentType = contentType; + updater.BodyData = data; + updater.UpdateTimer = updateTimer; + updater.UpdaterID = LLUUID.Random(); + updater.Params = extraParams; + + if (!Updaters.ContainsKey(updater.UpdaterID)) + { + Updaters.Add(updater.UpdaterID, updater); + } + + RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); + return updater.UpdaterID; + } + return LLUUID.Zero; + } + + public class DynamicTextureUpdater + { + public LLUUID SimUUID; + public LLUUID UpdaterID; + public string ContentType; + public string Url; + public string BodyData; + public LLUUID PrimID; + public int UpdateTimer; + public LLUUID LastAssetID; + public string Params; + + public DynamicTextureUpdater() + { + LastAssetID = LLUUID.Zero; + UpdateTimer = 0; + BodyData = null; + } + + public void DataReceived(byte[] data, Scene scene) + { + //TODO delete the last asset(data), if it was a dynamic texture + byte[] assetData = new byte[data.Length]; + Array.Copy(data, assetData, data.Length); + AssetBase asset = new AssetBase(); + asset.FullID = LLUUID.Random(); + asset.Data = assetData; + asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); + asset.Type = 0; + asset.Description = "dynamic image"; + asset.Local = false; + asset.Temporary = false; + scene.commsManager.AssetCache.AddAsset(asset); + + LastAssetID = asset.FullID; + + SceneObjectPart part = scene.GetSceneObjectPart(PrimID); + part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes(); + part.ScheduleFullUpdate(); + } + } + } +} diff --git a/OpenSim/Region/Environment/Modules/FriendsModule.cs b/OpenSim/Region/Environment/Modules/FriendsModule.cs index 1b51d9ed10..9144bee98a 100644 --- a/OpenSim/Region/Environment/Modules/FriendsModule.cs +++ b/OpenSim/Region/Environment/Modules/FriendsModule.cs @@ -1,61 +1,62 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Environment.Modules -{ - public class FriendsModule : IRegionModule - { - private Scene m_scene; - - public void Initialise(Scene scene) - { - m_scene = scene; - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return "FriendsModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using Nini.Config; + +namespace OpenSim.Region.Environment.Modules +{ + public class FriendsModule : IRegionModule + { + private Scene m_scene; + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "FriendsModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + } +} diff --git a/OpenSim/Region/Environment/Modules/GroupsModule.cs b/OpenSim/Region/Environment/Modules/GroupsModule.cs index a024ccd0f2..150f294cce 100644 --- a/OpenSim/Region/Environment/Modules/GroupsModule.cs +++ b/OpenSim/Region/Environment/Modules/GroupsModule.cs @@ -1,61 +1,62 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Environment.Modules -{ - public class GroupsModule : IRegionModule - { - private Scene m_scene; - - public void Initialise(Scene scene) - { - m_scene = scene; - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return "GroupsModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using Nini.Config; + +namespace OpenSim.Region.Environment.Modules +{ + public class GroupsModule : IRegionModule + { + private Scene m_scene; + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "GroupsModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + } +} diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs index dbd243469a..7c4e2c8dc6 100644 --- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs +++ b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs @@ -1,100 +1,101 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System.Collections.Generic; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework.Console; - -namespace OpenSim.Region.Environment.Modules -{ - public class InstantMessageModule : IRegionModule - { - private List m_scenes = new List(); - private LogBase m_log; - - public void Initialise(Scene scene) - { - if (!m_scenes.Contains(scene)) - { - m_scenes.Add(scene); - - scene.EventManager.OnNewClient += OnNewClient; - m_log = OpenSim.Framework.Console.MainLog.Instance; - } - } - - void OnNewClient(OpenSim.Framework.Interfaces.IClientAPI client) - { - client.OnInstantMessage += OnInstantMessage; - } - - void OnInstantMessage(libsecondlife.LLUUID fromAgentID, - libsecondlife.LLUUID fromAgentSession, libsecondlife.LLUUID toAgentID, - libsecondlife.LLUUID imSessionID, uint timestamp, string fromAgentName, - string message, byte dialog) - { - // TODO: Remove after debugging. Privacy implications. - m_log.Verbose("IM",fromAgentName + ": " + message); - - foreach (Scene m_scene in m_scenes) - { - if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) - { - // Local Message - ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; - user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, - toAgentID, imSessionID, user.Firstname + " " + user.Lastname, dialog, timestamp); - - // Message sent - return; - } - } - - // Still here, try send via Grid - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return "InstantMessageModule"; } - } - - public bool IsSharedModule - { - get { return true; } - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System.Collections.Generic; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Framework.Console; +using Nini.Config; + +namespace OpenSim.Region.Environment.Modules +{ + public class InstantMessageModule : IRegionModule + { + private List m_scenes = new List(); + private LogBase m_log; + + public void Initialise(Scene scene, IConfigSource config) + { + if (!m_scenes.Contains(scene)) + { + m_scenes.Add(scene); + + scene.EventManager.OnNewClient += OnNewClient; + m_log = OpenSim.Framework.Console.MainLog.Instance; + } + } + + void OnNewClient(OpenSim.Framework.Interfaces.IClientAPI client) + { + client.OnInstantMessage += OnInstantMessage; + } + + void OnInstantMessage(libsecondlife.LLUUID fromAgentID, + libsecondlife.LLUUID fromAgentSession, libsecondlife.LLUUID toAgentID, + libsecondlife.LLUUID imSessionID, uint timestamp, string fromAgentName, + string message, byte dialog) + { + // TODO: Remove after debugging. Privacy implications. + m_log.Verbose("IM",fromAgentName + ": " + message); + + foreach (Scene m_scene in m_scenes) + { + if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) + { + // Local Message + ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; + user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, + toAgentID, imSessionID, user.Firstname + " " + user.Lastname, dialog, timestamp); + + // Message sent + return; + } + } + + // Still here, try send via Grid + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "InstantMessageModule"; } + } + + public bool IsSharedModule + { + get { return true; } + } + } +} diff --git a/OpenSim/Region/Environment/Modules/InventoryModule.cs b/OpenSim/Region/Environment/Modules/InventoryModule.cs index d3b90c21aa..3f8cd6ed19 100644 --- a/OpenSim/Region/Environment/Modules/InventoryModule.cs +++ b/OpenSim/Region/Environment/Modules/InventoryModule.cs @@ -1,61 +1,62 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Environment.Modules -{ - public class InventoryModule : IRegionModule - { - private Scene m_scene; - - public void Initialise(Scene scene) - { - m_scene = scene; - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return "InventoryModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using Nini.Config; + +namespace OpenSim.Region.Environment.Modules +{ + public class InventoryModule : IRegionModule + { + private Scene m_scene; + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "InventoryModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + } +} diff --git a/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs b/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs index f1f479d0e4..8b8b386ba9 100644 --- a/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs +++ b/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs @@ -1,123 +1,124 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Net; -using System.IO; -using System.Drawing; -using libsecondlife; -using OpenJPEGNet; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - -namespace OpenSim.Region.Environment.Modules -{ - public class LoadImageURLModule : IRegionModule , IDynamicTextureRender - { - private string m_name = "LoadImageURL"; - private IDynamicTextureManager m_textureManager; - private Scene m_scene; - - public void Initialise(Scene scene) - { - if (m_scene == null) - { - m_scene = scene; - } - } - - public void PostInitialise() - { - m_textureManager = m_scene.RequestModuleInterface(); - m_textureManager.RegisterRender(GetContentType(), this); - } - - public void Close() - { - } - - public string Name - { - get { return m_name; } - } - - public bool IsSharedModule - { - get { return true; } - } - - public string GetName() - { - return m_name; - } - - public string GetContentType() - { - return ("image"); - } - - public bool SupportsAsynchronous() - { - return true; - } - - public byte[] ConvertUrl(string url, string extraParams) - { - return null; - } - - public byte[] ConvertStream(Stream data, string extraParams) - { - return null; - } - - public bool AsyncConvertUrl(LLUUID id, string url, string extraParams) - { - MakeHttpRequest(url, id); - return true; - } - - public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams) - { - return false; - } - - private void MakeHttpRequest(string url, LLUUID requestID) - { - WebRequest request = HttpWebRequest.Create(url); - RequestState state = new RequestState((HttpWebRequest)request, requestID); - IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); - - TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); - state.TimeOfRequest = (int)t.TotalSeconds; - } - - private void HttpRequestReturn(IAsyncResult result) - { - RequestState state = (RequestState)result.AsyncState; - WebRequest request = (WebRequest)state.Request; - HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result); - if (response.StatusCode == HttpStatusCode.OK) - { - Bitmap image = new Bitmap(response.GetResponseStream()); - Bitmap resize = new Bitmap(image, new Size(512, 512)); - byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); - - m_textureManager.ReturnData(state.RequestID, imageJ2000); - } - } - - public class RequestState - { - public HttpWebRequest Request = null; - public LLUUID RequestID = LLUUID.Zero; - public int TimeOfRequest = 0; - - public RequestState(HttpWebRequest request, LLUUID requestID) - { - Request = request; - RequestID = requestID; - } - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Net; +using System.IO; +using System.Drawing; +using libsecondlife; +using OpenJPEGNet; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; +using Nini.Config; + +namespace OpenSim.Region.Environment.Modules +{ + public class LoadImageURLModule : IRegionModule , IDynamicTextureRender + { + private string m_name = "LoadImageURL"; + private IDynamicTextureManager m_textureManager; + private Scene m_scene; + + public void Initialise(Scene scene, IConfigSource config) + { + if (m_scene == null) + { + m_scene = scene; + } + } + + public void PostInitialise() + { + m_textureManager = m_scene.RequestModuleInterface(); + m_textureManager.RegisterRender(GetContentType(), this); + } + + public void Close() + { + } + + public string Name + { + get { return m_name; } + } + + public bool IsSharedModule + { + get { return true; } + } + + public string GetName() + { + return m_name; + } + + public string GetContentType() + { + return ("image"); + } + + public bool SupportsAsynchronous() + { + return true; + } + + public byte[] ConvertUrl(string url, string extraParams) + { + return null; + } + + public byte[] ConvertStream(Stream data, string extraParams) + { + return null; + } + + public bool AsyncConvertUrl(LLUUID id, string url, string extraParams) + { + MakeHttpRequest(url, id); + return true; + } + + public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams) + { + return false; + } + + private void MakeHttpRequest(string url, LLUUID requestID) + { + WebRequest request = HttpWebRequest.Create(url); + RequestState state = new RequestState((HttpWebRequest)request, requestID); + IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); + + TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); + state.TimeOfRequest = (int)t.TotalSeconds; + } + + private void HttpRequestReturn(IAsyncResult result) + { + RequestState state = (RequestState)result.AsyncState; + WebRequest request = (WebRequest)state.Request; + HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result); + if (response.StatusCode == HttpStatusCode.OK) + { + Bitmap image = new Bitmap(response.GetResponseStream()); + Bitmap resize = new Bitmap(image, new Size(512, 512)); + byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); + + m_textureManager.ReturnData(state.RequestID, imageJ2000); + } + } + + public class RequestState + { + public HttpWebRequest Request = null; + public LLUUID RequestID = LLUUID.Zero; + public int TimeOfRequest = 0; + + public RequestState(HttpWebRequest request, LLUUID requestID) + { + Request = request; + RequestID = requestID; + } + } + + } +} diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index 2531265100..d3297c84fe 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs @@ -1,76 +1,77 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Environment.Modules -{ - public class TextureDownloadModule : IRegionModule - { - private Scene m_scene; - - public TextureDownloadModule() - { - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return "TextureDownloadModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - - public void NewClient(IClientAPI client) - { - } - - public void TextureAssetCallback(LLUUID texture, byte[] data) - { - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using Nini.Config; + +namespace OpenSim.Region.Environment.Modules +{ + public class TextureDownloadModule : IRegionModule + { + private Scene m_scene; + + public TextureDownloadModule() + { + } + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "TextureDownloadModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + public void NewClient(IClientAPI client) + { + } + + public void TextureAssetCallback(LLUUID texture, byte[] data) + { + } + } +} diff --git a/OpenSim/Region/Environment/Modules/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/WorldCommModule.cs index 994d07e0b9..765f1b4c45 100644 --- a/OpenSim/Region/Environment/Modules/WorldCommModule.cs +++ b/OpenSim/Region/Environment/Modules/WorldCommModule.cs @@ -40,6 +40,7 @@ using OpenSim.Framework.Servers; using Nwc.XmlRpc; using System.Collections; using System.Collections.Generic; +using Nini.Config; /***************************************************** * @@ -84,7 +85,7 @@ namespace OpenSim.Region.Environment.Modules { } - public void Initialise(Scene scene) + public void Initialise(Scene scene, IConfigSource config) { m_scene = scene; diff --git a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs index 941d3c1430..3a5b3c65d1 100644 --- a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs +++ b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs @@ -39,6 +39,7 @@ using OpenSim.Framework.Servers; using Nwc.XmlRpc; using System.Collections; using System.Collections.Generic; +using Nini.Config; /***************************************************** * @@ -93,7 +94,7 @@ namespace OpenSim.Region.Environment.Modules { } - public void Initialise(Scene scene) + public void Initialise(Scene scene, IConfigSource config) { m_scene = scene; diff --git a/OpenSim/Region/Environment/Modules/XferModule.cs b/OpenSim/Region/Environment/Modules/XferModule.cs index 7bc831f401..2adb1c99bc 100644 --- a/OpenSim/Region/Environment/Modules/XferModule.cs +++ b/OpenSim/Region/Environment/Modules/XferModule.cs @@ -1,201 +1,202 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System; -using System.Collections.Generic; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Environment.Modules -{ - public class XferModule : IRegionModule, IXfer - { - public Dictionary NewFiles = new Dictionary(); - public Dictionary Transfers = new Dictionary(); - - private Scene m_scene; - - public XferModule() - { - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - - m_scene.RegisterModuleInterface(this); - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return "XferModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - - public void NewClient(IClientAPI client) - { - client.OnRequestXfer += RequestXfer; - client.OnConfirmXfer += AckPacket; - } - - /// - /// - /// - /// - /// - /// - public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) - { - lock (NewFiles) - { - if (NewFiles.ContainsKey(fileName)) - { - if (!Transfers.ContainsKey(xferID)) - { - byte[] fileData = NewFiles[fileName]; - XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); - Transfers.Add(xferID, transaction); - NewFiles.Remove(fileName); - transaction.StartSend(); - } - } - } - } - - public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) - { - if (Transfers.ContainsKey(xferID)) - { - Transfers[xferID].AckPacket(packet); - } - } - - public bool AddNewFile(string fileName, byte[] data) - { - lock (NewFiles) - { - if (NewFiles.ContainsKey(fileName)) - { - NewFiles[fileName] = data; - } - else - { - NewFiles.Add(fileName, data); - } - } - return true; - } - - - public class XferDownLoad - { - public byte[] Data = new byte[0]; - public string FileName = ""; - public ulong XferID = 0; - public int DataPointer = 0; - public uint Packet = 0; - public IClientAPI Client; - public uint Serial = 1; - private bool complete = false; - - public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) - { - FileName = fileName; - Data = data; - XferID = xferID; - Client = client; - } - - public XferDownLoad() - { - } - - public void StartSend() - { - if (Data.Length < 1000) - { - // for now (testing ) we only support files under 1000 bytes - byte[] transferData = new byte[Data.Length + 4]; - Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); - Array.Copy(Data, 0, transferData, 4, Data.Length); - Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); - complete = true; - } - else - { - byte[] transferData = new byte[1000 + 4]; - Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); - Array.Copy(Data, 0, transferData, 4, 1000); - Client.SendXferPacket(XferID, 0, transferData); - Packet++; - DataPointer = 1000; - } - } - - public void AckPacket(uint packet) - { - if (!complete) - { - if ((Data.Length - DataPointer) > 1000) - { - byte[] transferData = new byte[1000]; - Array.Copy(Data, DataPointer, transferData, 0, 1000); - Client.SendXferPacket(XferID, Packet, transferData); - Packet++; - DataPointer += 1000; - } - else - { - byte[] transferData = new byte[Data.Length - DataPointer]; - Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); - uint endPacket = Packet |= (uint) 0x80000000; - Client.SendXferPacket(XferID, endPacket, transferData); - Packet++; - DataPointer += (Data.Length - DataPointer); - complete = true; - } - } - } - } - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using Nini.Config; + +namespace OpenSim.Region.Environment.Modules +{ + public class XferModule : IRegionModule, IXfer + { + public Dictionary NewFiles = new Dictionary(); + public Dictionary Transfers = new Dictionary(); + + private Scene m_scene; + + public XferModule() + { + } + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + + m_scene.RegisterModuleInterface(this); + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "XferModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + public void NewClient(IClientAPI client) + { + client.OnRequestXfer += RequestXfer; + client.OnConfirmXfer += AckPacket; + } + + /// + /// + /// + /// + /// + /// + public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) + { + lock (NewFiles) + { + if (NewFiles.ContainsKey(fileName)) + { + if (!Transfers.ContainsKey(xferID)) + { + byte[] fileData = NewFiles[fileName]; + XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); + Transfers.Add(xferID, transaction); + NewFiles.Remove(fileName); + transaction.StartSend(); + } + } + } + } + + public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) + { + if (Transfers.ContainsKey(xferID)) + { + Transfers[xferID].AckPacket(packet); + } + } + + public bool AddNewFile(string fileName, byte[] data) + { + lock (NewFiles) + { + if (NewFiles.ContainsKey(fileName)) + { + NewFiles[fileName] = data; + } + else + { + NewFiles.Add(fileName, data); + } + } + return true; + } + + + public class XferDownLoad + { + public byte[] Data = new byte[0]; + public string FileName = ""; + public ulong XferID = 0; + public int DataPointer = 0; + public uint Packet = 0; + public IClientAPI Client; + public uint Serial = 1; + private bool complete = false; + + public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) + { + FileName = fileName; + Data = data; + XferID = xferID; + Client = client; + } + + public XferDownLoad() + { + } + + public void StartSend() + { + if (Data.Length < 1000) + { + // for now (testing ) we only support files under 1000 bytes + byte[] transferData = new byte[Data.Length + 4]; + Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); + Array.Copy(Data, 0, transferData, 4, Data.Length); + Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); + complete = true; + } + else + { + byte[] transferData = new byte[1000 + 4]; + Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); + Array.Copy(Data, 0, transferData, 4, 1000); + Client.SendXferPacket(XferID, 0, transferData); + Packet++; + DataPointer = 1000; + } + } + + public void AckPacket(uint packet) + { + if (!complete) + { + if ((Data.Length - DataPointer) > 1000) + { + byte[] transferData = new byte[1000]; + Array.Copy(Data, DataPointer, transferData, 0, 1000); + Client.SendXferPacket(XferID, Packet, transferData); + Packet++; + DataPointer += 1000; + } + else + { + byte[] transferData = new byte[Data.Length - DataPointer]; + Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); + uint endPacket = Packet |= (uint) 0x80000000; + Client.SendXferPacket(XferID, endPacket, transferData); + Packet++; + DataPointer += (Data.Length - DataPointer); + complete = true; + } + } + } + } + } +} diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 7967867324..35f205196a 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -39,12 +39,15 @@ using OpenSim.Region.Communications.Local; using OpenSim.Region.Environment; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Physics.Manager; +using Nini.Config; namespace SimpleApp { class Program : RegionApplicationBase, conscmd_callback { private ModuleLoader m_moduleLoader; + private IConfigSource m_config; + protected override LogBase CreateLog() { return new LogBase(null, "SimpleApp", this, false); @@ -86,7 +89,7 @@ namespace SimpleApp UDPServer udpServer; - m_moduleLoader = new ModuleLoader( m_log ); + m_moduleLoader = new ModuleLoader( m_log, m_config ); m_moduleLoader.LoadDefaultSharedModules(); Scene scene = SetupScene(regionInfo, out udpServer); @@ -155,7 +158,7 @@ namespace SimpleApp protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager) { - return new MyWorld(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, new ModuleLoader( m_log )); + return new MyWorld(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, new ModuleLoader( m_log, m_config )); } protected override StorageManager CreateStorageManager(RegionInfo regionInfo) diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs index a818155398..be27a0b516 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs @@ -1,148 +1,149 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System.Collections.Generic; -using OpenSim.Framework.Console; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.ExtensionsScriptModule.CSharp; -using OpenSim.Region.ExtensionsScriptModule.JScript; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine; - -namespace OpenSim.Region.ExtensionsScriptModule -{ - public class ScriptManager : IRegionModule, IExtensionScriptModule - { - readonly List scripts = new List(); - Scene m_scene; - readonly Dictionary compilers = new Dictionary(); - - private void LoadFromCompiler(Dictionary compiledscripts) - { - foreach (KeyValuePair script in compiledscripts) - { - ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. - MainLog.Instance.Verbose("Loading " + script.Key); - script.Value.Initialise(scriptInfo); - scripts.Add(script.Value); - } - - MainLog.Instance.Verbose(string.Format("Finished loading {0} script(s)", compiledscripts.Count)); - } - - public ScriptManager() - { - // Default Engines - CSharpScriptEngine csharpCompiler = new CSharpScriptEngine(); - compilers.Add(csharpCompiler.FileExt(), csharpCompiler); - - JScriptEngine jscriptCompiler = new JScriptEngine(); - compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler); - - JavaEngine javaCompiler = new JavaEngine(); - compilers.Add(javaCompiler.FileExt(), javaCompiler); - } - - public void Initialise(Scene scene) - { - System.Console.WriteLine("Initialising Extensions Scripting Module"); - m_scene = scene; - - m_scene.RegisterModuleInterface(this); - } - - public void PostInitialise() - { - - } - - public void Close() - { - - } - - public string Name - { - get { return "ExtensionsScriptingModule"; } - } - - public bool IsSharedModule -{ - get { return false; } - } - - public bool Compile(string filename) - { - foreach (KeyValuePair compiler in compilers) - { - if (filename.EndsWith(compiler.Key)) - { - LoadFromCompiler(compiler.Value.compile(filename)); - break; - } - } - - return true; - } - - public void RunScriptCmd(string[] args) - { - switch (args[0]) - { - case "load": - Compile(args[1]); - break; - - default: - MainLog.Instance.Error("Unknown script command"); - break; - } - } - - public bool AddPreCompiledScript(IScript script) - { - MainLog.Instance.Verbose("Loading script " + script.Name); - ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. - script.Initialise(scriptInfo); - scripts.Add(script); - - return true; - } - } - - public interface IExtensionScriptModule - { - bool Compile(string filename); - bool AddPreCompiledScript(IScript script); - } - - interface IScriptCompiler - { - Dictionary compile(string filename); - string FileExt(); - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System.Collections.Generic; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.ExtensionsScriptModule.CSharp; +using OpenSim.Region.ExtensionsScriptModule.JScript; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine; +using Nini.Config; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + public class ScriptManager : IRegionModule, IExtensionScriptModule + { + readonly List scripts = new List(); + Scene m_scene; + readonly Dictionary compilers = new Dictionary(); + + private void LoadFromCompiler(Dictionary compiledscripts) + { + foreach (KeyValuePair script in compiledscripts) + { + ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. + MainLog.Instance.Verbose("Loading " + script.Key); + script.Value.Initialise(scriptInfo); + scripts.Add(script.Value); + } + + MainLog.Instance.Verbose(string.Format("Finished loading {0} script(s)", compiledscripts.Count)); + } + + public ScriptManager() + { + // Default Engines + CSharpScriptEngine csharpCompiler = new CSharpScriptEngine(); + compilers.Add(csharpCompiler.FileExt(), csharpCompiler); + + JScriptEngine jscriptCompiler = new JScriptEngine(); + compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler); + + JavaEngine javaCompiler = new JavaEngine(); + compilers.Add(javaCompiler.FileExt(), javaCompiler); + } + + public void Initialise(Scene scene, IConfigSource config) + { + System.Console.WriteLine("Initialising Extensions Scripting Module"); + m_scene = scene; + + m_scene.RegisterModuleInterface(this); + } + + public void PostInitialise() + { + + } + + public void Close() + { + + } + + public string Name + { + get { return "ExtensionsScriptingModule"; } + } + + public bool IsSharedModule +{ + get { return false; } + } + + public bool Compile(string filename) + { + foreach (KeyValuePair compiler in compilers) + { + if (filename.EndsWith(compiler.Key)) + { + LoadFromCompiler(compiler.Value.compile(filename)); + break; + } + } + + return true; + } + + public void RunScriptCmd(string[] args) + { + switch (args[0]) + { + case "load": + Compile(args[1]); + break; + + default: + MainLog.Instance.Error("Unknown script command"); + break; + } + } + + public bool AddPreCompiledScript(IScript script) + { + MainLog.Instance.Verbose("Loading script " + script.Name); + ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. + script.Initialise(scriptInfo); + scripts.Add(script); + + return true; + } + } + + public interface IExtensionScriptModule + { + bool Compile(string filename); + bool AddPreCompiledScript(IScript script); + } + + interface IScriptCompiler + { + Dictionary compile(string filename); + string FileExt(); + } +} diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs index d89a8adece..38bf746362 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs @@ -1,132 +1,133 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -/* Original code: Tedd Hansen */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Console; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Scenes.Scripting; -using OpenSim.Region.Environment.Interfaces; -using libsecondlife; - -namespace OpenSim.Region.ScriptEngine.DotNetEngine -{ - /// - /// This is the root object for ScriptEngine - /// - [Serializable] - public class ScriptEngine :IRegionModule - { - - internal OpenSim.Region.Environment.Scenes.Scene World; - internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim - internal EventQueueManager m_EventQueueManager; // Executes events - internal ScriptManager m_ScriptManager; // Load, unload and execute scripts - internal AppDomainManager m_AppDomainManager; - internal LSLLongCmdHandler m_LSLLongCmdHandler; - - private OpenSim.Framework.Console.LogBase m_log; - - public ScriptEngine() - { - //Common.SendToDebug("ScriptEngine Object Initialized"); - Common.mySE = this; - } - - public LogBase Log - { - get { return m_log; } - } - - public void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger) - { - - World = Sceneworld; - m_log = logger; - - Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing"); - - //m_logger.Status("ScriptEngine", "InitializeEngine"); - - // Create all objects we'll be using - m_EventQueueManager = new EventQueueManager(this); - m_EventManager = new EventManager(this); - m_ScriptManager = new ScriptManager(this); - m_AppDomainManager = new AppDomainManager(); - m_LSLLongCmdHandler = new LSLLongCmdHandler(this); - - // Should we iterate the region for scripts that needs starting? - // Or can we assume we are loaded before anything else so we can use proper events? - - - } - - public void Shutdown() - { - // We are shutting down - } - - //// !!!FOR DEBUGGING ONLY!!! (for executing script directly from test app) - //[Obsolete("!!!FOR DEBUGGING ONLY!!!")] - //public void StartScript(string ScriptID, IScriptHost ObjectID) - //{ - // this.myEventManager.TEMP_OBJECT_ID = ObjectID; - // Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID); - // myScriptManager.StartScript(ScriptID, ObjectID); - //} - - #region IRegionModule - - public void Initialise(Scene scene) - { - this.InitializeEngine(scene, MainLog.Instance); - } - - public void PostInitialise() - { - - } - - public void Close() - { - } - - public string Name - { - get { return "LSLScriptingModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - - #endregion - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +/* Original code: Tedd Hansen */ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Scenes.Scripting; +using OpenSim.Region.Environment.Interfaces; +using libsecondlife; +using Nini.Config; + +namespace OpenSim.Region.ScriptEngine.DotNetEngine +{ + /// + /// This is the root object for ScriptEngine + /// + [Serializable] + public class ScriptEngine :IRegionModule + { + + internal OpenSim.Region.Environment.Scenes.Scene World; + internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim + internal EventQueueManager m_EventQueueManager; // Executes events + internal ScriptManager m_ScriptManager; // Load, unload and execute scripts + internal AppDomainManager m_AppDomainManager; + internal LSLLongCmdHandler m_LSLLongCmdHandler; + + private OpenSim.Framework.Console.LogBase m_log; + + public ScriptEngine() + { + //Common.SendToDebug("ScriptEngine Object Initialized"); + Common.mySE = this; + } + + public LogBase Log + { + get { return m_log; } + } + + public void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger) + { + + World = Sceneworld; + m_log = logger; + + Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing"); + + //m_logger.Status("ScriptEngine", "InitializeEngine"); + + // Create all objects we'll be using + m_EventQueueManager = new EventQueueManager(this); + m_EventManager = new EventManager(this); + m_ScriptManager = new ScriptManager(this); + m_AppDomainManager = new AppDomainManager(); + m_LSLLongCmdHandler = new LSLLongCmdHandler(this); + + // Should we iterate the region for scripts that needs starting? + // Or can we assume we are loaded before anything else so we can use proper events? + + + } + + public void Shutdown() + { + // We are shutting down + } + + //// !!!FOR DEBUGGING ONLY!!! (for executing script directly from test app) + //[Obsolete("!!!FOR DEBUGGING ONLY!!!")] + //public void StartScript(string ScriptID, IScriptHost ObjectID) + //{ + // this.myEventManager.TEMP_OBJECT_ID = ObjectID; + // Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID); + // myScriptManager.StartScript(ScriptID, ObjectID); + //} + + #region IRegionModule + + public void Initialise(Scene scene, IConfigSource config) + { + this.InitializeEngine(scene, MainLog.Instance); + } + + public void PostInitialise() + { + + } + + public void Close() + { + } + + public string Name + { + get { return "LSLScriptingModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + #endregion + } +} diff --git a/prebuild.xml b/prebuild.xml index 2af29f431d..a5045b5aa1 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -475,11 +475,12 @@ + - + @@ -592,7 +593,7 @@ - + @@ -670,7 +671,7 @@ - + @@ -895,6 +896,7 @@ + @@ -983,6 +985,8 @@ + +