diff --git a/.nant/local.include b/.nant/local.include index 35f00589e8..5185717cbc 100644 --- a/.nant/local.include +++ b/.nant/local.include @@ -132,6 +132,16 @@ + + + + + + + + + + @@ -235,6 +245,16 @@ + + + + + + + + + + @@ -245,6 +265,7 @@ + diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index fd00fe8288..43dea0bd3b 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -93,6 +93,7 @@ what it is today. * Garmin Kawaguichi * Gryc Ueusp * Hiro Lecker +* Iain Oliver * Imaze Rhiano * Intimidated * Jeremy Bongio (IBM) @@ -182,12 +183,14 @@ what it is today. This software uses components from the following developers: * Sleepycat Software (Berkeley DB) +* Aurora-Sim (http://aurora-sim.org) * SQLite (Public Domain) * XmlRpcCS (http://xmlrpccs.sf.net/) * MySQL, Inc. (MySQL Connector/NET) * NUnit (http://www.nunit.org) * AGEIA Inc. (PhysX) * Russel L. Smith (ODE) +* Erwin Coumans (Bullet) * Prebuild (http://sourceforge.net/projects/dnpb/) * LibOpenMetaverse (http://lib.openmetaverse.org/) * DotNetOpenMail v0.5.8b (http://dotnetopenmail.sourceforge.net) diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index 00657028e4..fcb6991969 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -99,12 +99,12 @@ namespace OpenSim.ApplicationPlugins.LoadRegions RegionInfo[] regionsToLoad = regionLoader.LoadRegions(); m_log.Info("[LOAD REGIONS PLUGIN]: Loading specific shared modules..."); - m_log.Info("[LOAD REGIONS PLUGIN]: DynamicTextureModule..."); - m_openSim.ModuleLoader.LoadDefaultSharedModule(new DynamicTextureModule()); - m_log.Info("[LOAD REGIONS PLUGIN]: LoadImageURLModule..."); - m_openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule()); - m_log.Info("[LOAD REGIONS PLUGIN]: XMLRPCModule..."); - m_openSim.ModuleLoader.LoadDefaultSharedModule(new XMLRPCModule()); + //m_log.Info("[LOAD REGIONS PLUGIN]: DynamicTextureModule..."); + //m_openSim.ModuleLoader.LoadDefaultSharedModule(new DynamicTextureModule()); + //m_log.Info("[LOAD REGIONS PLUGIN]: LoadImageURLModule..."); + //m_openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule()); + //m_log.Info("[LOAD REGIONS PLUGIN]: XMLRPCModule..."); + //m_openSim.ModuleLoader.LoadDefaultSharedModule(new XMLRPCModule()); // m_log.Info("[LOADREGIONSPLUGIN]: AssetTransactionModule..."); // m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule()); m_log.Info("[LOAD REGIONS PLUGIN]: Done."); @@ -136,9 +136,6 @@ namespace OpenSim.ApplicationPlugins.LoadRegions } } } - - m_openSim.ModuleLoader.PostInitialise(); - m_openSim.ModuleLoader.ClearCache(); } public void Dispose() diff --git a/OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs b/OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs index 59b8ddaab1..57615ea2d3 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs @@ -60,7 +60,7 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("0.6.5.*")] +// [assembly: AssemblyVersion("0.7.5.*")] -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] \ No newline at end of file diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/Properties/AssemblyInfo.cs b/OpenSim/ApplicationPlugins/RegionModulesController/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..14527d9ea9 --- /dev/null +++ b/OpenSim/ApplicationPlugins/RegionModulesController/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.ApplicationPlugins.RegionModulesController")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c023816d-194e-40c1-9195-a0f281d4ac5d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs index 49bd911baf..633d0055fd 100644 --- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs +++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs @@ -215,7 +215,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController } } -#region IRegionModulesController implementation +#region Region Module interfacesController implementation /// /// Check that the given module is no disabled in the [Modules] section of the config files. diff --git a/OpenSim/ApplicationPlugins/RemoteController/Properties/AssemblyInfo.cs b/OpenSim/ApplicationPlugins/RemoteController/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..8ad948c9bd --- /dev/null +++ b/OpenSim/ApplicationPlugins/RemoteController/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.ApplicationPlugins.RemoteController")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("Copyright OpenSimulator developers © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("efec6e69-fc4a-4e21-86e6-4a261c12d4db")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 15fbdddb28..a75d10d417 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -2314,7 +2314,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController destinationItem.Description = item.Description; destinationItem.InvType = item.InvType; destinationItem.CreatorId = item.CreatorId; - destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid; destinationItem.CreatorData = item.CreatorData; destinationItem.NextPermissions = item.NextPermissions; destinationItem.CurrentPermissions = item.CurrentPermissions; @@ -2369,7 +2368,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController destinationItem.Description = item.Description; destinationItem.InvType = item.InvType; destinationItem.CreatorId = item.CreatorId; - destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid; destinationItem.CreatorData = item.CreatorData; destinationItem.NextPermissions = item.NextPermissions; destinationItem.CurrentPermissions = item.CurrentPermissions; @@ -2482,7 +2480,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController destinationItem.Description = item.Description; destinationItem.InvType = item.InvType; destinationItem.CreatorId = item.CreatorId; - destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid; destinationItem.CreatorData = item.CreatorData; destinationItem.NextPermissions = item.NextPermissions; destinationItem.CurrentPermissions = item.CurrentPermissions; @@ -2788,7 +2785,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController inventoryItem.Description = GetStringAttribute(item,"desc",""); inventoryItem.InvType = GetIntegerAttribute(item,"invtype",-1); inventoryItem.CreatorId = GetStringAttribute(item,"creatorid",""); - inventoryItem.CreatorIdAsUuid = (UUID)GetStringAttribute(item,"creatoruuid",""); inventoryItem.CreatorData = GetStringAttribute(item, "creatordata", ""); inventoryItem.NextPermissions = GetUnsignedAttribute(perms, "next", 0x7fffffff); inventoryItem.CurrentPermissions = GetUnsignedAttribute(perms,"current",0x7fffffff); diff --git a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs index 761e4e7564..d4d6d10d83 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs @@ -42,7 +42,7 @@ using OpenSim.Tests.Common.Mock; namespace OpenSim.Capabilities.Handlers.GetTexture.Tests { [TestFixture] - public class GetTextureHandlerTests + public class GetTextureHandlerTests : OpenSimTestCase { [Test] public void TestTextureNotFound() diff --git a/OpenSim/Capabilities/Handlers/Properties/AssemblyInfo.cs b/OpenSim/Capabilities/Handlers/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..a681fb643f --- /dev/null +++ b/OpenSim/Capabilities/Handlers/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Capabilities.Handlers")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("32350823-e1df-45e3-b7fa-0a58b4372433")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Capabilities/Properties/AssemblyInfo.cs b/OpenSim/Capabilities/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..26254f2fcf --- /dev/null +++ b/OpenSim/Capabilities/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Capabilities")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7d1a55b1-8fab-42ff-9c83-066a9cc34d76")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/ConsoleClient/Properties/AssemblyInfo.cs b/OpenSim/ConsoleClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c240f90ca3 --- /dev/null +++ b/OpenSim/ConsoleClient/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.ConsoleClient")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8945df94-2e5e-475b-88fa-35a7cdde6fd7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Data/IXGroupData.cs b/OpenSim/Data/IXGroupData.cs new file mode 100644 index 0000000000..2965e8cc3d --- /dev/null +++ b/OpenSim/Data/IXGroupData.cs @@ -0,0 +1,71 @@ +/* + * 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 OpenSimulator 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 OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Data +{ + public class XGroup + { + public UUID groupID; + public UUID ownerRoleID; + public string name; + public string charter; + public bool showInList; + public UUID insigniaID; + public int membershipFee; + public bool openEnrollment; + public bool allowPublish; + public bool maturePublish; + public UUID founderID; + public ulong everyonePowers; + public ulong ownersPowers; + + public XGroup Clone() + { + return (XGroup)MemberwiseClone(); + } + } + + /// + /// Early stub interface for groups data, not final. + /// + /// + /// Currently in-use only for regression test purposes. Needs to be filled out over time. + /// + public interface IXGroupData + { + bool StoreGroup(XGroup group); + XGroup[] GetGroups(string field, string val); + XGroup[] GetGroups(string[] fields, string[] vals); + bool DeleteGroups(string field, string val); + bool DeleteGroups(string[] fields, string[] vals); + } +} \ No newline at end of file diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs index e64a82820d..ca4750660a 100644 --- a/OpenSim/Data/IXInventoryData.cs +++ b/OpenSim/Data/IXInventoryData.cs @@ -116,7 +116,22 @@ namespace OpenSim.Data /// true if the delete was successful, false if it was not bool DeleteItems(string[] fields, string[] vals); - bool MoveItem(string id, string newParent); + /// + /// Move an item to another folder. + /// + /// /returns> + /// UUID of the item + /// UUID of the new parent folder. + bool MoveItem(string id, string newParentFolderID); + + /// + /// Move a folder to another folder. + /// + /// /returns> + /// UUID of the item + /// UUID of the new parent folder. + bool MoveFolder(string id, string newParentFolderID); + XInventoryItem[] GetActiveGestures(UUID principalID); int GetAssetPermissions(UUID principalID, UUID assetID); } diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs index b19a0da872..9164ffe4e3 100644 --- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs @@ -43,12 +43,12 @@ namespace OpenSim.Data.MSSQL // private static readonly ILog m_log = LogManager.GetLogger( // MethodBase.GetCurrentMethod().DeclaringType); - private MSSQLGenericTableHandler m_Folders; + private MSSQLFolderHandler m_Folders; private MSSQLItemHandler m_Items; public MSSQLXInventoryData(string conn, string realm) { - m_Folders = new MSSQLGenericTableHandler( + m_Folders = new MSSQLFolderHandler( conn, "inventoryfolders", "InventoryStore"); m_Items = new MSSQLItemHandler( conn, "inventoryitems", String.Empty); @@ -85,6 +85,7 @@ namespace OpenSim.Data.MSSQL { return m_Folders.Delete(field, val); } + public bool DeleteFolders(string[] fields, string[] vals) { return m_Folders.Delete(fields, vals); @@ -94,15 +95,22 @@ namespace OpenSim.Data.MSSQL { return m_Items.Delete(field, val); } + public bool DeleteItems(string[] fields, string[] vals) { return m_Items.Delete(fields, vals); } + public bool MoveItem(string id, string newParent) { return m_Items.MoveItem(id, newParent); } + public bool MoveFolder(string id, string newParent) + { + return m_Folders.MoveFolder(id, newParent); + } + public XInventoryItem[] GetActiveGestures(UUID principalID) { return m_Items.GetActiveGestures(principalID); @@ -114,7 +122,7 @@ namespace OpenSim.Data.MSSQL } } - public class MSSQLItemHandler : MSSQLGenericTableHandler + public class MSSQLItemHandler : MSSQLInventoryHandler { public MSSQLItemHandler(string c, string t, string m) : base(c, t, m) @@ -123,70 +131,163 @@ namespace OpenSim.Data.MSSQL public bool MoveItem(string id, string newParent) { - using (SqlConnection conn = new SqlConnection(m_ConnectionString)) - using (SqlCommand cmd = new SqlCommand()) - { + XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id }); + if (retrievedItems.Length == 0) + return false; - cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm); - cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent)); - cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id)); - cmd.Connection = conn; - conn.Open(); - return cmd.ExecuteNonQuery() == 0 ? false : true; + UUID oldParent = retrievedItems[0].parentFolderID; + + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + { + using (SqlCommand cmd = new SqlCommand()) + { + + cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm); + cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent)); + cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id)); + cmd.Connection = conn; + conn.Open(); + + if (cmd.ExecuteNonQuery() == 0) + return false; + } } + + IncrementFolderVersion(oldParent); + IncrementFolderVersion(newParent); + + return true; } public XInventoryItem[] GetActiveGestures(UUID principalID) { using (SqlConnection conn = new SqlConnection(m_ConnectionString)) - using (SqlCommand cmd = new SqlCommand()) { - cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm); + using (SqlCommand cmd = new SqlCommand()) + { + cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm); - cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString())); - cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture)); - cmd.Connection = conn; - conn.Open(); - return DoQuery(cmd); + cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString())); + cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture)); + cmd.Connection = conn; + conn.Open(); + return DoQuery(cmd); + } } } public int GetAssetPermissions(UUID principalID, UUID assetID) { using (SqlConnection conn = new SqlConnection(m_ConnectionString)) - using (SqlCommand cmd = new SqlCommand()) { - cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm); - cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString())); - cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString())); - cmd.Connection = conn; - conn.Open(); - using (SqlDataReader reader = cmd.ExecuteReader()) + using (SqlCommand cmd = new SqlCommand()) { - - int perms = 0; - - if (reader.Read()) + cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm); + cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString())); + cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString())); + cmd.Connection = conn; + conn.Open(); + using (SqlDataReader reader = cmd.ExecuteReader()) { - perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); + + int perms = 0; + + if (reader.Read()) + { + perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); + } + + return perms; } - return perms; } - } } + public override bool Store(XInventoryItem item) { if (!base.Store(item)) return false; - string sql = "update inventoryfolders set version=version+1 where folderID = @folderID"; - using (SqlConnection conn = new SqlConnection(m_ConnectionString)) - using (SqlCommand cmd = new SqlCommand(sql, conn)) - { - conn.Open(); - cmd.Parameters.AddWithValue("@folderID", item.parentFolderID.ToString()); + IncrementFolderVersion(item.parentFolderID); + + return true; + } + } + + public class MSSQLFolderHandler : MSSQLInventoryHandler + { + public MSSQLFolderHandler(string c, string t, string m) : + base(c, t, m) + { + } + + public bool MoveFolder(string id, string newParentFolderID) + { + XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id }); + + if (folders.Length == 0) + return false; + + UUID oldParentFolderUUID = folders[0].parentFolderID; + + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + { + using (SqlCommand cmd = new SqlCommand()) + { + + cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where folderID = @folderID", m_Realm); + cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParentFolderID)); + cmd.Parameters.Add(m_database.CreateParameter("@folderID", id)); + cmd.Connection = conn; + conn.Open(); + + if (cmd.ExecuteNonQuery() == 0) + return false; + } + } + + IncrementFolderVersion(oldParentFolderUUID); + IncrementFolderVersion(newParentFolderID); + + return true; + } + + public override bool Store(XInventoryFolder folder) + { + if (!base.Store(folder)) + return false; + + IncrementFolderVersion(folder.parentFolderID); + + return true; + } + } + + public class MSSQLInventoryHandler : MSSQLGenericTableHandler where T: class, new() + { + public MSSQLInventoryHandler(string c, string t, string m) : base(c, t, m) {} + + protected bool IncrementFolderVersion(UUID folderID) + { + return IncrementFolderVersion(folderID.ToString()); + } + + protected bool IncrementFolderVersion(string folderID) + { +// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); +// Util.PrintCallStack(); + + string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID"; + + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + conn.Open(); + + cmd.Parameters.AddWithValue("@folderID", folderID); + try { cmd.ExecuteNonQuery(); @@ -194,9 +295,11 @@ namespace OpenSim.Data.MSSQL catch (Exception) { return false; - } + } + } } + return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs index e045d75d12..1a67e704e5 100644 --- a/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MSSQL/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index da8e958b07..995c6a5317 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -219,6 +219,8 @@ namespace OpenSim.Data.MySQL public virtual bool Store(T row) { +// m_log.DebugFormat("[MYSQL GENERIC TABLE HANDLER]: Store(T row) invoked"); + using (MySqlCommand cmd = new MySqlCommand()) { string query = ""; @@ -273,6 +275,10 @@ namespace OpenSim.Data.MySQL public virtual bool Delete(string[] fields, string[] keys) { +// m_log.DebugFormat( +// "[MYSQL GENERIC TABLE HANDLER]: Delete(string[] fields, string[] keys) invoked with {0}:{1}", +// string.Join(",", fields), string.Join(",", keys)); + if (fields.Length != keys.Length) return false; diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs index caf18a4780..c74033eefc 100644 --- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs @@ -26,9 +26,10 @@ */ using System; -using System.Data; -using System.Reflection; using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Reflection; using log4net; using MySql.Data.MySqlClient; using OpenMetaverse; @@ -41,12 +42,12 @@ namespace OpenSim.Data.MySQL /// public class MySQLXInventoryData : IXInventoryData { - private MySQLGenericTableHandler m_Folders; + private MySqlFolderHandler m_Folders; private MySqlItemHandler m_Items; public MySQLXInventoryData(string conn, string realm) { - m_Folders = new MySQLGenericTableHandler( + m_Folders = new MySqlFolderHandler( conn, "inventoryfolders", "InventoryStore"); m_Items = new MySqlItemHandler( conn, "inventoryitems", String.Empty); @@ -105,6 +106,11 @@ namespace OpenSim.Data.MySQL return m_Items.MoveItem(id, newParent); } + public bool MoveFolder(string id, string newParent) + { + return m_Folders.MoveFolder(id, newParent); + } + public XInventoryItem[] GetActiveGestures(UUID principalID) { return m_Items.GetActiveGestures(principalID); @@ -116,24 +122,71 @@ namespace OpenSim.Data.MySQL } } - public class MySqlItemHandler : MySQLGenericTableHandler + public class MySqlItemHandler : MySqlInventoryHandler { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public MySqlItemHandler(string c, string t, string m) : base(c, t, m) { } + public override bool Delete(string field, string val) + { + XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val }); + if (retrievedItems.Length == 0) + return false; + + if (!base.Delete(field, val)) + return false; + + // Don't increment folder version here since Delete(string, string) calls Delete(string[], string[]) +// IncrementFolderVersion(retrievedItems[0].parentFolderID); + + return true; + } + + public override bool Delete(string[] fields, string[] vals) + { + XInventoryItem[] retrievedItems = Get(fields, vals); + if (retrievedItems.Length == 0) + return false; + + if (!base.Delete(fields, vals)) + return false; + + HashSet deletedItemFolderUUIDs = new HashSet(); + + Array.ForEach(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID)); + + foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs) + IncrementFolderVersion(deletedItemFolderUUID); + + return true; + } + public bool MoveItem(string id, string newParent) { + XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id }); + if (retrievedItems.Length == 0) + return false; + + UUID oldParent = retrievedItems[0].parentFolderID; + using (MySqlCommand cmd = new MySqlCommand()) { - cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); cmd.Parameters.AddWithValue("?ParentFolderID", newParent); cmd.Parameters.AddWithValue("?InventoryID", id); - return ExecuteNonQuery(cmd) == 0 ? false : true; + if (ExecuteNonQuery(cmd) == 0) + return false; } + + IncrementFolderVersion(oldParent); + IncrementFolderVersion(newParent); + + return true; } public XInventoryItem[] GetActiveGestures(UUID principalID) @@ -184,6 +237,73 @@ namespace OpenSim.Data.MySQL if (!base.Store(item)) return false; + IncrementFolderVersion(item.parentFolderID); + + return true; + } + } + + public class MySqlFolderHandler : MySqlInventoryHandler + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public MySqlFolderHandler(string c, string t, string m) : + base(c, t, m) + { + } + + public bool MoveFolder(string id, string newParentFolderID) + { + XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id }); + + if (folders.Length == 0) + return false; + + UUID oldParentFolderUUID = folders[0].parentFolderID; + + using (MySqlCommand cmd = new MySqlCommand()) + { + cmd.CommandText + = String.Format( + "update {0} set parentFolderID = ?ParentFolderID where folderID = ?folderID", m_Realm); + cmd.Parameters.AddWithValue("?ParentFolderID", newParentFolderID); + cmd.Parameters.AddWithValue("?folderID", id); + + if (ExecuteNonQuery(cmd) == 0) + return false; + } + + IncrementFolderVersion(oldParentFolderUUID); + IncrementFolderVersion(newParentFolderID); + + return true; + } + + public override bool Store(XInventoryFolder folder) + { + if (!base.Store(folder)) + return false; + + IncrementFolderVersion(folder.parentFolderID); + + return true; + } + } + + public class MySqlInventoryHandler : MySQLGenericTableHandler where T: class, new() + { + public MySqlInventoryHandler(string c, string t, string m) : base(c, t, m) {} + + protected bool IncrementFolderVersion(UUID folderID) + { + return IncrementFolderVersion(folderID.ToString()); + } + + protected bool IncrementFolderVersion(string folderID) + { +// m_log.DebugFormat("[MYSQL FOLDER HANDLER]: Incrementing version on folder {0}", folderID); +// Util.PrintCallStack(); + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); @@ -193,7 +313,7 @@ namespace OpenSim.Data.MySQL cmd.Connection = dbcon; cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID"); - cmd.Parameters.AddWithValue("?folderID", item.parentFolderID.ToString()); + cmd.Parameters.AddWithValue("?folderID", folderID); try { @@ -205,9 +325,11 @@ namespace OpenSim.Data.MySQL } cmd.Dispose(); } + dbcon.Close(); } + return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs index c28829caa3..ab3fe36e52 100644 --- a/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/MySQL/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] diff --git a/OpenSim/Data/Null/NullGenericDataHandler.cs b/OpenSim/Data/Null/NullGenericDataHandler.cs new file mode 100644 index 0000000000..dd9d190910 --- /dev/null +++ b/OpenSim/Data/Null/NullGenericDataHandler.cs @@ -0,0 +1,67 @@ +/* + * 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 OpenSimulator 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.Linq; +using System.Reflection; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Data; + +namespace OpenSim.Data.Null +{ + /// + /// Not a proper generic data handler yet - probably needs to actually store the data as well instead of relying + /// on descendent classes + /// + public class NullGenericDataHandler + { + protected List Get(string[] fields, string[] vals, List inputEntities) + { + List entities = inputEntities; + + for (int i = 0; i < fields.Length; i++) + { + entities + = entities.Where( + e => + { + FieldInfo fi = typeof(T).GetField(fields[i]); + if (fi == null) + throw new NotImplementedException(string.Format("No field {0} for val {1}", fields[i], vals[i])); + + return fi.GetValue(e).ToString() == vals[i]; + } + ).ToList(); + } + + return entities; + } + } +} \ No newline at end of file diff --git a/OpenSim/Services/InventoryService/InventoryServiceBase.cs b/OpenSim/Data/Null/NullXGroupData.cs similarity index 52% rename from OpenSim/Services/InventoryService/InventoryServiceBase.cs rename to OpenSim/Data/Null/NullXGroupData.cs index 456e4557db..7a86b9f230 100644 --- a/OpenSim/Services/InventoryService/InventoryServiceBase.cs +++ b/OpenSim/Data/Null/NullXGroupData.cs @@ -26,57 +26,65 @@ */ using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Reflection; -using Nini.Config; +using System.Threading; +using log4net; +using OpenMetaverse; using OpenSim.Framework; using OpenSim.Data; -using OpenSim.Services.Interfaces; -using OpenSim.Services.Base; -namespace OpenSim.Services.InventoryService +namespace OpenSim.Data.Null { - public class InventoryServiceBase : ServiceBase + public class NullXGroupData : NullGenericDataHandler, IXGroupData { - protected IInventoryDataPlugin m_Database = null; +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public InventoryServiceBase(IConfigSource config) : base(config) + private Dictionary m_groups = new Dictionary(); + + public NullXGroupData(string connectionString, string realm) {} + + public bool StoreGroup(XGroup group) { - string dllName = String.Empty; - string connString = String.Empty; - - // - // Try reading the [DatabaseService] section first, if it exists - // - IConfig dbConfig = config.Configs["DatabaseService"]; - if (dbConfig != null) + lock (m_groups) { - dllName = dbConfig.GetString("StorageProvider", String.Empty); - connString = dbConfig.GetString("ConnectionString", String.Empty); + m_groups[group.groupID] = group.Clone(); } - // - // Try reading the more specific [InventoryService] section, if it exists - // - IConfig inventoryConfig = config.Configs["InventoryService"]; - if (inventoryConfig != null) - { - dllName = inventoryConfig.GetString("StorageProvider", dllName); - connString = inventoryConfig.GetString("ConnectionString", connString); - } - - // - // We tried, but this doesn't exist. We can't proceed. - // - if (dllName.Equals(String.Empty)) - throw new Exception("No InventoryService configuration"); - - m_Database = LoadPlugin(dllName); - if (m_Database == null) - throw new Exception("Could not find a storage interface in the given module"); - - m_Database.Initialise(connString); + return true; } + public XGroup[] GetGroups(string field, string val) + { + return GetGroups(new string[] { field }, new string[] { val }); + } + + public XGroup[] GetGroups(string[] fields, string[] vals) + { + lock (m_groups) + { + List origGroups = Get(fields, vals, m_groups.Values.ToList()); + + return origGroups.Select(g => g.Clone()).ToArray(); + } + } + + public bool DeleteGroups(string field, string val) + { + return DeleteGroups(new string[] { field }, new string[] { val }); + } + + public bool DeleteGroups(string[] fields, string[] vals) + { + lock (m_groups) + { + XGroup[] groupsToDelete = GetGroups(fields, vals); + Array.ForEach(groupsToDelete, g => m_groups.Remove(g.groupID)); + } + + return true; + } } -} +} \ No newline at end of file diff --git a/OpenSim/Data/Null/Properties/AssemblyInfo.cs b/OpenSim/Data/Null/Properties/AssemblyInfo.cs index 4b644363dc..43b0bb3214 100644 --- a/OpenSim/Data/Null/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/Null/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] diff --git a/OpenSim/Data/Properties/AssemblyInfo.cs b/OpenSim/Data/Properties/AssemblyInfo.cs index 6940d2579b..0da1a6b799 100644 --- a/OpenSim/Data/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] diff --git a/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs b/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs index d45ab5092a..c9a8553de6 100644 --- a/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs +++ b/OpenSim/Data/SQLite/Properties/AssemblyInfo.cs @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index d0e24c325c..61e7aaf3c7 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -202,7 +202,8 @@ namespace OpenSim.Data.SQLite /// True if exist, or false. override public bool ExistsAsset(UUID uuid) { - lock (this) { + lock (this) + { using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) { cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); @@ -353,12 +354,13 @@ namespace OpenSim.Data.SQLite { lock (this) { - using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); - cmd.ExecuteNonQuery(); - } + using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn)) + { + cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); + cmd.ExecuteNonQuery(); + } } + return true; } diff --git a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs index 5120453d1b..0428c11f76 100644 --- a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs +++ b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs @@ -82,11 +82,14 @@ namespace OpenSim.Data.SQLite { AuthenticationData ret = new AuthenticationData(); ret.Data = new Dictionary(); + IDataReader result; - SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID"); - cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); + using (SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID")) + { + cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); - IDataReader result = ExecuteReader(cmd, m_Connection); + result = ExecuteReader(cmd, m_Connection); + } try { @@ -121,10 +124,6 @@ namespace OpenSim.Data.SQLite catch { } - finally - { - //CloseCommand(cmd); - } return null; } @@ -140,84 +139,81 @@ namespace OpenSim.Data.SQLite foreach (object o in data.Data.Values) values[i++] = o.ToString(); - SqliteCommand cmd = new SqliteCommand(); - - if (Get(data.PrincipalID) != null) + using (SqliteCommand cmd = new SqliteCommand()) { - - - string update = "update `" + m_Realm + "` set "; - bool first = true; - foreach (string field in fields) + if (Get(data.PrincipalID) != null) { - if (!first) - update += ", "; - update += "`" + field + "` = :" + field; - cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); - first = false; - } - update += " where UUID = :UUID"; - cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); - - cmd.CommandText = update; - try - { - if (ExecuteNonQuery(cmd, m_Connection) < 1) + string update = "update `" + m_Realm + "` set "; + bool first = true; + foreach (string field in fields) { + if (!first) + update += ", "; + update += "`" + field + "` = :" + field; + cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); + + first = false; + } + + update += " where UUID = :UUID"; + cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); + + cmd.CommandText = update; + try + { + if (ExecuteNonQuery(cmd, m_Connection) < 1) + { + //CloseCommand(cmd); + return false; + } + } + catch (Exception e) + { + m_log.Error("[SQLITE]: Exception storing authentication data", e); //CloseCommand(cmd); return false; } } - catch (Exception e) + else { - m_log.Error("[SQLITE]: Exception storing authentication data", e); - //CloseCommand(cmd); - return false; - } - } + string insert = "insert into `" + m_Realm + "` (`UUID`, `" + + String.Join("`, `", fields) + + "`) values (:UUID, :" + String.Join(", :", fields) + ")"; - else - { - string insert = "insert into `" + m_Realm + "` (`UUID`, `" + - String.Join("`, `", fields) + - "`) values (:UUID, :" + String.Join(", :", fields) + ")"; + cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); + foreach (string field in fields) + cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); - cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString())); - foreach (string field in fields) - cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field])); + cmd.CommandText = insert; - cmd.CommandText = insert; - - try - { - if (ExecuteNonQuery(cmd, m_Connection) < 1) + try { - //CloseCommand(cmd); + if (ExecuteNonQuery(cmd, m_Connection) < 1) + { + return false; + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); return false; } } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - //CloseCommand(cmd); - return false; - } } - //CloseCommand(cmd); - return true; } public bool SetDataItem(UUID principalID, string item, string value) { - SqliteCommand cmd = new SqliteCommand("update `" + m_Realm + - "` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'"); - - if (ExecuteNonQuery(cmd, m_Connection) > 0) - return true; + using (SqliteCommand cmd = new SqliteCommand("update `" + m_Realm + + "` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'")) + { + if (ExecuteNonQuery(cmd, m_Connection) > 0) + return true; + } return false; } @@ -227,16 +223,13 @@ namespace OpenSim.Data.SQLite if (System.Environment.TickCount - m_LastExpire > 30000) DoExpire(); - SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() + - "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))"); - - if (ExecuteNonQuery(cmd, m_Connection) > 0) + using (SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() + + "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))")) { - cmd.Dispose(); - return true; + if (ExecuteNonQuery(cmd, m_Connection) > 0) + return true; } - cmd.Dispose(); return false; } @@ -245,28 +238,22 @@ namespace OpenSim.Data.SQLite if (System.Environment.TickCount - m_LastExpire > 30000) DoExpire(); - SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() + - " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')"); - - if (ExecuteNonQuery(cmd, m_Connection) > 0) + using (SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() + + " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')")) { - cmd.Dispose(); - return true; + if (ExecuteNonQuery(cmd, m_Connection) > 0) + return true; } - cmd.Dispose(); - return false; } private void DoExpire() { - SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')"); - ExecuteNonQuery(cmd, m_Connection); - - cmd.Dispose(); + using (SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')")) + ExecuteNonQuery(cmd, m_Connection); m_LastExpire = System.Environment.TickCount; } } -} +} \ No newline at end of file diff --git a/OpenSim/Data/SQLite/SQLiteAvatarData.cs b/OpenSim/Data/SQLite/SQLiteAvatarData.cs index faf34da573..c6d615be14 100644 --- a/OpenSim/Data/SQLite/SQLiteAvatarData.cs +++ b/OpenSim/Data/SQLite/SQLiteAvatarData.cs @@ -56,23 +56,17 @@ namespace OpenSim.Data.SQLite public bool Delete(UUID principalID, string name) { - SqliteCommand cmd = new SqliteCommand(); - - cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm); - cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); - cmd.Parameters.AddWithValue(":Name", name); - - try + using (SqliteCommand cmd = new SqliteCommand()) { + cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm); + cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); + cmd.Parameters.AddWithValue(":Name", name); + if (ExecuteNonQuery(cmd, m_Connection) > 0) return true; + } - return false; - } - finally - { - //CloseCommand(cmd); - } + return false; } } -} +} \ No newline at end of file diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs index c042ba2bd3..d51f2d413d 100644 --- a/OpenSim/Data/SQLite/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs @@ -104,12 +104,13 @@ namespace OpenSim.Data.SQLite { string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID"; - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) + { + cmd.CommandText = sql; + cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); - cmd.CommandText = sql; - cmd.Parameters.AddWithValue(":RegionID", regionID.ToString()); - - return DoLoad(cmd, regionID, create); + return DoLoad(cmd, regionID, create); + } } private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create) @@ -186,38 +187,40 @@ namespace OpenSim.Data.SQLite { List names = new List(FieldList); - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); IDataReader r = null; - names.Remove("EstateID"); + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) + { + names.Remove("EstateID"); - string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")"; + string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")"; - cmd.CommandText = sql; - cmd.Parameters.Clear(); + cmd.CommandText = sql; + cmd.Parameters.Clear(); - foreach (string name in FieldList) - { - if (m_FieldMap[name].GetValue(es) is bool) + foreach (string name in FieldList) { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue(":"+name, "1"); + if (m_FieldMap[name].GetValue(es) is bool) + { + if ((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.AddWithValue(":"+name, "1"); + else + cmd.Parameters.AddWithValue(":"+name, "0"); + } else - cmd.Parameters.AddWithValue(":"+name, "0"); - } - else - { - cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); + { + cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); + } } + + cmd.ExecuteNonQuery(); + + cmd.CommandText = "select LAST_INSERT_ROWID() as id"; + cmd.Parameters.Clear(); + + r = cmd.ExecuteReader(); } - cmd.ExecuteNonQuery(); - - cmd.CommandText = "select LAST_INSERT_ROWID() as id"; - cmd.Parameters.Clear(); - - r = cmd.ExecuteReader(); - r.Read(); es.EstateID = Convert.ToUInt32(r["id"]); @@ -239,26 +242,27 @@ namespace OpenSim.Data.SQLite string sql = "update estate_settings set "+String.Join(", ", terms.ToArray())+" where EstateID = :EstateID"; - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = sql; - - foreach (string name in FieldList) + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) { - if (m_FieldMap[name].GetValue(es) is bool) - { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue(":"+name, "1"); - else - cmd.Parameters.AddWithValue(":"+name, "0"); - } - else - { - cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); - } - } + cmd.CommandText = sql; - cmd.ExecuteNonQuery(); + foreach (string name in FieldList) + { + if (m_FieldMap[name].GetValue(es) is bool) + { + if ((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.AddWithValue(":"+name, "1"); + else + cmd.Parameters.AddWithValue(":"+name, "0"); + } + else + { + cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString()); + } + } + + cmd.ExecuteNonQuery(); + } SaveBanList(es); SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); @@ -270,12 +274,15 @@ namespace OpenSim.Data.SQLite { es.ClearBans(); - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + IDataReader r; - cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID"; - cmd.Parameters.AddWithValue(":EstateID", es.EstateID); + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) + { + cmd.CommandText = "select bannedUUID from estateban where EstateID = :EstateID"; + cmd.Parameters.AddWithValue(":EstateID", es.EstateID); - IDataReader r = cmd.ExecuteReader(); + r = cmd.ExecuteReader(); + } while (r.Read()) { @@ -294,60 +301,64 @@ namespace OpenSim.Data.SQLite private void SaveBanList(EstateSettings es) { - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = "delete from estateban where EstateID = :EstateID"; - cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); - - cmd.ExecuteNonQuery(); - - cmd.Parameters.Clear(); - - cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( :EstateID, :bannedUUID, '', '', '' )"; - - foreach (EstateBan b in es.EstateBans) + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) { + cmd.CommandText = "delete from estateban where EstateID = :EstateID"; cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); - cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString()); cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( :EstateID, :bannedUUID, '', '', '' )"; + + foreach (EstateBan b in es.EstateBans) + { + cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue(":bannedUUID", b.BannedUserID.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } } } void SaveUUIDList(uint EstateID, string table, UUID[] data) { - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); - - cmd.CommandText = "delete from "+table+" where EstateID = :EstateID"; - cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); - - cmd.ExecuteNonQuery(); - - cmd.Parameters.Clear(); - - cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( :EstateID, :uuid )"; - - foreach (UUID uuid in data) + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) { + cmd.CommandText = "delete from "+table+" where EstateID = :EstateID"; cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); - cmd.Parameters.AddWithValue(":uuid", uuid.ToString()); cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( :EstateID, :uuid )"; + + foreach (UUID uuid in data) + { + cmd.Parameters.AddWithValue(":EstateID", EstateID.ToString()); + cmd.Parameters.AddWithValue(":uuid", uuid.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } } } UUID[] LoadUUIDList(uint EstateID, string table) { List uuids = new List(); + IDataReader r; - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) + { + cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID"; + cmd.Parameters.AddWithValue(":EstateID", EstateID); - cmd.CommandText = "select uuid from "+table+" where EstateID = :EstateID"; - cmd.Parameters.AddWithValue(":EstateID", EstateID); - - IDataReader r = cmd.ExecuteReader(); + r = cmd.ExecuteReader(); + } while (r.Read()) { @@ -367,12 +378,13 @@ namespace OpenSim.Data.SQLite { string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID = :EstateID"; - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) + { + cmd.CommandText = sql; + cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); - cmd.CommandText = sql; - cmd.Parameters.AddWithValue(":EstateID", estateID.ToString()); - - return DoLoad(cmd, UUID.Zero, false); + return DoLoad(cmd, UUID.Zero, false); + } } public List LoadEstateSettingsAll() @@ -391,13 +403,15 @@ namespace OpenSim.Data.SQLite List result = new List(); string sql = "select EstateID from estate_settings where estate_settings.EstateName = :EstateName"; + IDataReader r; - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) + { + cmd.CommandText = sql; + cmd.Parameters.AddWithValue(":EstateName", search); - cmd.CommandText = sql; - cmd.Parameters.AddWithValue(":EstateName", search); - - IDataReader r = cmd.ExecuteReader(); + r = cmd.ExecuteReader(); + } while (r.Read()) { @@ -413,12 +427,14 @@ namespace OpenSim.Data.SQLite List result = new List(); string sql = "select EstateID from estate_settings"; + IDataReader r; - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) + { + cmd.CommandText = sql; - cmd.CommandText = sql; - - IDataReader r = cmd.ExecuteReader(); + r = cmd.ExecuteReader(); + } while (r.Read()) { @@ -434,13 +450,15 @@ namespace OpenSim.Data.SQLite List result = new List(); string sql = "select EstateID from estate_settings where estate_settings.EstateOwner = :EstateOwner"; + IDataReader r; - SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) + { + cmd.CommandText = sql; + cmd.Parameters.AddWithValue(":EstateOwner", ownerID); - cmd.CommandText = sql; - cmd.Parameters.AddWithValue(":EstateOwner", ownerID); - - IDataReader r = cmd.ExecuteReader(); + r = cmd.ExecuteReader(); + } while (r.Read()) { diff --git a/OpenSim/Data/SQLite/SQLiteFramework.cs b/OpenSim/Data/SQLite/SQLiteFramework.cs index 159471723e..35b9a2fe31 100644 --- a/OpenSim/Data/SQLite/SQLiteFramework.cs +++ b/OpenSim/Data/SQLite/SQLiteFramework.cs @@ -90,12 +90,5 @@ namespace OpenSim.Data.SQLite return cmd.ExecuteReader(); } } - - protected void CloseCommand(SqliteCommand cmd) - { - cmd.Connection.Close(); - cmd.Connection.Dispose(); - cmd.Dispose(); - } } -} +} \ No newline at end of file diff --git a/OpenSim/Data/SQLite/SQLiteFriendsData.cs b/OpenSim/Data/SQLite/SQLiteFriendsData.cs index 5f68977c1f..cab85eb703 100644 --- a/OpenSim/Data/SQLite/SQLiteFriendsData.cs +++ b/OpenSim/Data/SQLite/SQLiteFriendsData.cs @@ -53,13 +53,13 @@ namespace OpenSim.Data.SQLite public FriendsData[] GetFriends(string userID) { - SqliteCommand cmd = new SqliteCommand(); - - cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm); - cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString()); - - return DoQuery(cmd); + using (SqliteCommand cmd = new SqliteCommand()) + { + cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm); + cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString()); + return DoQuery(cmd); + } } public bool Delete(UUID principalID, string friend) @@ -69,13 +69,14 @@ namespace OpenSim.Data.SQLite public bool Delete(string principalID, string friend) { - SqliteCommand cmd = new SqliteCommand(); + using (SqliteCommand cmd = new SqliteCommand()) + { + cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm); + cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); + cmd.Parameters.AddWithValue(":Friend", friend); - cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm); - cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); - cmd.Parameters.AddWithValue(":Friend", friend); - - ExecuteNonQuery(cmd, m_Connection); + ExecuteNonQuery(cmd, m_Connection); + } return true; } diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs index 4f977a80e8..9fbeb100ce 100644 --- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs +++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs @@ -120,34 +120,35 @@ namespace OpenSim.Data.SQLite } } - public T[] Get(string field, string key) + public virtual T[] Get(string field, string key) { return Get(new string[] { field }, new string[] { key }); } - public T[] Get(string[] fields, string[] keys) + public virtual T[] Get(string[] fields, string[] keys) { if (fields.Length != keys.Length) return new T[0]; List terms = new List(); - SqliteCommand cmd = new SqliteCommand(); - - for (int i = 0 ; i < fields.Length ; i++) + using (SqliteCommand cmd = new SqliteCommand()) { - cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); - terms.Add("`" + fields[i] + "` = :" + fields[i]); + for (int i = 0 ; i < fields.Length ; i++) + { + cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); + terms.Add("`" + fields[i] + "` = :" + fields[i]); + } + + string where = String.Join(" and ", terms.ToArray()); + + string query = String.Format("select * from {0} where {1}", + m_Realm, where); + + cmd.CommandText = query; + + return DoQuery(cmd); } - - string where = String.Join(" and ", terms.ToArray()); - - string query = String.Format("select * from {0} where {1}", - m_Realm, where); - - cmd.CommandText = query; - - return DoQuery(cmd); } protected T[] DoQuery(SqliteCommand cmd) @@ -212,53 +213,55 @@ namespace OpenSim.Data.SQLite return result.ToArray(); } - public T[] Get(string where) + public virtual T[] Get(string where) { - SqliteCommand cmd = new SqliteCommand(); + using (SqliteCommand cmd = new SqliteCommand()) + { + string query = String.Format("select * from {0} where {1}", + m_Realm, where); - string query = String.Format("select * from {0} where {1}", - m_Realm, where); + cmd.CommandText = query; - cmd.CommandText = query; - - return DoQuery(cmd); + return DoQuery(cmd); + } } - public bool Store(T row) + public virtual bool Store(T row) { - SqliteCommand cmd = new SqliteCommand(); - - string query = ""; - List names = new List(); - List values = new List(); - - foreach (FieldInfo fi in m_Fields.Values) + using (SqliteCommand cmd = new SqliteCommand()) { - names.Add(fi.Name); - values.Add(":" + fi.Name); - cmd.Parameters.Add(new SqliteParameter(":" + fi.Name, fi.GetValue(row).ToString())); - } + string query = ""; + List names = new List(); + List values = new List(); - if (m_DataField != null) - { - Dictionary data = - (Dictionary)m_DataField.GetValue(row); - - foreach (KeyValuePair kvp in data) + foreach (FieldInfo fi in m_Fields.Values) { - names.Add(kvp.Key); - values.Add(":" + kvp.Key); - cmd.Parameters.Add(new SqliteParameter(":" + kvp.Key, kvp.Value)); + names.Add(fi.Name); + values.Add(":" + fi.Name); + cmd.Parameters.Add(new SqliteParameter(":" + fi.Name, fi.GetValue(row).ToString())); } + + if (m_DataField != null) + { + Dictionary data = + (Dictionary)m_DataField.GetValue(row); + + foreach (KeyValuePair kvp in data) + { + names.Add(kvp.Key); + values.Add(":" + kvp.Key); + cmd.Parameters.Add(new SqliteParameter(":" + kvp.Key, kvp.Value)); + } + } + + query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; + + cmd.CommandText = query; + + if (ExecuteNonQuery(cmd, m_Connection) > 0) + return true; } - query = String.Format("replace into {0} (`", m_Realm) + String.Join("`,`", names.ToArray()) + "`) values (" + String.Join(",", values.ToArray()) + ")"; - - cmd.CommandText = query; - - if (ExecuteNonQuery(cmd, m_Connection) > 0) - return true; - return false; } @@ -267,28 +270,29 @@ namespace OpenSim.Data.SQLite return Delete(new string[] { field }, new string[] { key }); } - public bool Delete(string[] fields, string[] keys) + public virtual bool Delete(string[] fields, string[] keys) { if (fields.Length != keys.Length) return false; List terms = new List(); - SqliteCommand cmd = new SqliteCommand(); - - for (int i = 0 ; i < fields.Length ; i++) + using (SqliteCommand cmd = new SqliteCommand()) { - cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); - terms.Add("`" + fields[i] + "` = :" + fields[i]); + for (int i = 0 ; i < fields.Length ; i++) + { + cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i])); + terms.Add("`" + fields[i] + "` = :" + fields[i]); + } + + string where = String.Join(" and ", terms.ToArray()); + + string query = String.Format("delete from {0} where {1}", m_Realm, where); + + cmd.CommandText = query; + + return ExecuteNonQuery(cmd, m_Connection) > 0; } - - string where = String.Join(" and ", terms.ToArray()); - - string query = String.Format("delete from {0} where {1}", m_Realm, where); - - cmd.CommandText = query; - - return ExecuteNonQuery(cmd, m_Connection) > 0; } } } diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 56df3cbbdd..29cac3c2f1 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs @@ -1366,6 +1366,13 @@ namespace OpenSim.Data.SQLite createCol(land, "UserLookAtZ", typeof(Double)); createCol(land, "AuthbuyerID", typeof(String)); createCol(land, "OtherCleanTime", typeof(Int32)); + createCol(land, "Dwell", typeof(Int32)); + createCol(land, "MediaType", typeof(String)); + createCol(land, "MediaDescription", typeof(String)); + createCol(land, "MediaSize", typeof(String)); + createCol(land, "MediaLoop", typeof(Boolean)); + createCol(land, "ObscureMedia", typeof(Boolean)); + createCol(land, "ObscureMusic", typeof(Boolean)); land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] }; @@ -1781,9 +1788,16 @@ namespace OpenSim.Data.SQLite newData.PassHours = Convert.ToSingle(row["PassHours"]); newData.PassPrice = Convert.ToInt32(row["PassPrice"]); newData.SnapshotID = (UUID)(String)row["SnapshotUUID"]; + newData.Dwell = Convert.ToInt32(row["Dwell"]); + newData.MediaType = (String)row["MediaType"]; + newData.MediaDescription = (String)row["MediaDescription"]; + newData.MediaWidth = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[0]); + newData.MediaHeight = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[1]); + newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]); + newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); + newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); try { - newData.UserLocation = new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), Convert.ToSingle(row["UserLocationZ"])); @@ -2195,12 +2209,13 @@ namespace OpenSim.Data.SQLite row["UserLookAtZ"] = land.UserLookAt.Z; row["AuthbuyerID"] = land.AuthBuyerID.ToString(); row["OtherCleanTime"] = land.OtherCleanTime; + row["Dwell"] = land.Dwell; row["MediaType"] = land.MediaType; row["MediaDescription"] = land.MediaDescription; - row["MediaSize"] = land.MediaWidth.ToString() + "," + land.MediaHeight.ToString(); - row["MediaLoop"] = land.MediaLoop.ToString(); - row["ObscureMusic"] = land.ObscureMusic.ToString(); - row["ObscureMedia"] = land.ObscureMedia.ToString(); + row["MediaSize"] = String.Format("{0},{1}", land.MediaWidth, land.MediaHeight); + row["MediaLoop"] = land.MediaLoop; + row["ObscureMusic"] = land.ObscureMusic; + row["ObscureMedia"] = land.ObscureMedia; } /// diff --git a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs index 7a5de5073d..f98d37660f 100644 --- a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs @@ -66,20 +66,21 @@ namespace OpenSim.Data.SQLite if (words.Length > 2) return new UserAccountData[0]; - SqliteCommand cmd = new SqliteCommand(); - - if (words.Length == 1) + using (SqliteCommand cmd = new SqliteCommand()) { - cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", - m_Realm, scopeID.ToString(), words[0]); - } - else - { - cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')", - m_Realm, scopeID.ToString(), words[0], words[1]); - } + if (words.Length == 1) + { + cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')", + m_Realm, scopeID.ToString(), words[0]); + } + else + { + cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')", + m_Realm, scopeID.ToString(), words[0], words[1]); + } - return DoQuery(cmd); + return DoQuery(cmd); + } } } } diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs index 1f369867ce..2a0a8f6cc9 100644 --- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs +++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs @@ -47,7 +47,7 @@ namespace OpenSim.Data.SQLite { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private SQLiteGenericTableHandler m_Folders; + private SqliteFolderHandler m_Folders; private SqliteItemHandler m_Items; public SQLiteXInventoryData(string conn, string realm) @@ -55,7 +55,7 @@ namespace OpenSim.Data.SQLite if (Util.IsWindows()) Util.LoadArchSpecificWindowsDll("sqlite3.dll"); - m_Folders = new SQLiteGenericTableHandler( + m_Folders = new SqliteFolderHandler( conn, "inventoryfolders", "XInventoryStore"); m_Items = new SqliteItemHandler( conn, "inventoryitems", String.Empty); @@ -114,6 +114,11 @@ namespace OpenSim.Data.SQLite return m_Items.MoveItem(id, newParent); } + public bool MoveFolder(string id, string newParent) + { + return m_Folders.MoveFolder(id, newParent); + } + public XInventoryItem[] GetActiveGestures(UUID principalID) { return m_Items.GetActiveGestures(principalID); @@ -125,44 +130,106 @@ namespace OpenSim.Data.SQLite } } - public class SqliteItemHandler : SQLiteGenericTableHandler + public class SqliteItemHandler : SqliteInventoryHandler { public SqliteItemHandler(string c, string t, string m) : base(c, t, m) { } + public override bool Store(XInventoryItem item) + { + if (!base.Store(item)) + return false; + + IncrementFolderVersion(item.parentFolderID); + + return true; + } + + public override bool Delete(string field, string val) + { + XInventoryItem[] retrievedItems = Get(new string[] { field }, new string[] { val }); + if (retrievedItems.Length == 0) + return false; + + if (!base.Delete(field, val)) + return false; + + // Don't increment folder version here since Delete(string, string) calls Delete(string[], string[]) +// IncrementFolderVersion(retrievedItems[0].parentFolderID); + + return true; + } + + public override bool Delete(string[] fields, string[] vals) + { + XInventoryItem[] retrievedItems = Get(fields, vals); + if (retrievedItems.Length == 0) + return false; + + if (!base.Delete(fields, vals)) + return false; + + HashSet deletedItemFolderUUIDs = new HashSet(); + + Array.ForEach(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID)); + + foreach (UUID deletedItemFolderUUID in deletedItemFolderUUIDs) + IncrementFolderVersion(deletedItemFolderUUID); + + return true; + } + public bool MoveItem(string id, string newParent) { - SqliteCommand cmd = new SqliteCommand(); + XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id }); + if (retrievedItems.Length == 0) + return false; - cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm); - cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent)); - cmd.Parameters.Add(new SqliteParameter(":InventoryID", id)); + UUID oldParent = retrievedItems[0].parentFolderID; - return ExecuteNonQuery(cmd, m_Connection) == 0 ? false : true; + using (SqliteCommand cmd = new SqliteCommand()) + { + cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm); + cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParent)); + cmd.Parameters.Add(new SqliteParameter(":InventoryID", id)); + + if (ExecuteNonQuery(cmd, m_Connection) == 0) + return false; + } + + IncrementFolderVersion(oldParent); + IncrementFolderVersion(newParent); + + return true; } public XInventoryItem[] GetActiveGestures(UUID principalID) { - SqliteCommand cmd = new SqliteCommand(); - cmd.CommandText = String.Format("select * from inventoryitems where avatarId = :uuid and assetType = :type and flags = 1", m_Realm); + using (SqliteCommand cmd = new SqliteCommand()) + { + cmd.CommandText = String.Format("select * from inventoryitems where avatarId = :uuid and assetType = :type and flags = 1", m_Realm); - cmd.Parameters.Add(new SqliteParameter(":uuid", principalID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":type", (int)AssetType.Gesture)); + cmd.Parameters.Add(new SqliteParameter(":uuid", principalID.ToString())); + cmd.Parameters.Add(new SqliteParameter(":type", (int)AssetType.Gesture)); - return DoQuery(cmd); + return DoQuery(cmd); + } } public int GetAssetPermissions(UUID principalID, UUID assetID) { - SqliteCommand cmd = new SqliteCommand(); + IDataReader reader; - cmd.CommandText = String.Format("select inventoryCurrentPermissions from inventoryitems where avatarID = :PrincipalID and assetID = :AssetID", m_Realm); - cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString())); + using (SqliteCommand cmd = new SqliteCommand()) + { + cmd.CommandText = String.Format("select inventoryCurrentPermissions from inventoryitems where avatarID = :PrincipalID and assetID = :AssetID", m_Realm); + cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString())); + cmd.Parameters.Add(new SqliteParameter(":AssetID", assetID.ToString())); - IDataReader reader = ExecuteReader(cmd, m_Connection); + reader = ExecuteReader(cmd, m_Connection); + } int perms = 0; @@ -177,4 +244,81 @@ namespace OpenSim.Data.SQLite return perms; } } -} + + public class SqliteFolderHandler : SqliteInventoryHandler + { + public SqliteFolderHandler(string c, string t, string m) : + base(c, t, m) + { + } + + public override bool Store(XInventoryFolder folder) + { + if (!base.Store(folder)) + return false; + + IncrementFolderVersion(folder.parentFolderID); + + return true; + } + + public bool MoveFolder(string id, string newParentFolderID) + { + XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id }); + + if (folders.Length == 0) + return false; + + UUID oldParentFolderUUID = folders[0].parentFolderID; + + using (SqliteCommand cmd = new SqliteCommand()) + { + cmd.CommandText = String.Format("update {0} set parentFolderID = :ParentFolderID where folderID = :FolderID", m_Realm); + cmd.Parameters.Add(new SqliteParameter(":ParentFolderID", newParentFolderID)); + cmd.Parameters.Add(new SqliteParameter(":FolderID", id)); + + if (ExecuteNonQuery(cmd, m_Connection) == 0) + return false; + } + + IncrementFolderVersion(oldParentFolderUUID); + IncrementFolderVersion(newParentFolderID); + + return true; + } + + } + + public class SqliteInventoryHandler : SQLiteGenericTableHandler where T: class, new() + { + public SqliteInventoryHandler(string c, string t, string m) : base(c, t, m) {} + + protected bool IncrementFolderVersion(UUID folderID) + { + return IncrementFolderVersion(folderID.ToString()); + } + + protected bool IncrementFolderVersion(string folderID) + { +// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID); +// Util.PrintCallStack(); + + using (SqliteCommand cmd = new SqliteCommand()) + { + cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = ?folderID"; + cmd.Parameters.Add(new SqliteParameter(":folderID", folderID)); + + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { + return false; + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/OpenSim/Data/Tests/AssetTests.cs b/OpenSim/Data/Tests/AssetTests.cs index 1174e2f302..8cb2ee083d 100644 --- a/OpenSim/Data/Tests/AssetTests.cs +++ b/OpenSim/Data/Tests/AssetTests.cs @@ -49,7 +49,7 @@ using OpenSim.Data.SQLite; namespace OpenSim.Data.Tests { [TestFixture(Description = "Asset store tests (SQLite)")] - public class SQLiteAssetTests : AssetTests + public class SQLiteAssetTests : AssetTests { } diff --git a/OpenSim/Data/Tests/BasicDataServiceTest.cs b/OpenSim/Data/Tests/BasicDataServiceTest.cs index 7d85f0c8eb..d8019ba9b4 100644 --- a/OpenSim/Data/Tests/BasicDataServiceTest.cs +++ b/OpenSim/Data/Tests/BasicDataServiceTest.cs @@ -33,6 +33,7 @@ using NUnit.Framework; using NUnit.Framework.Constraints; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Tests.Common; using log4net; using System.Data; using System.Data.Common; @@ -45,7 +46,7 @@ namespace OpenSim.Data.Tests /// /// /// - public class BasicDataServiceTest + public class BasicDataServiceTest : OpenSimTestCase where TConn : DbConnection, new() where TService : class, new() { diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs index 6c79bda9ec..b99525a74a 100644 --- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs +++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs @@ -36,6 +36,7 @@ using NUnit.Framework; using NUnit.Framework.Constraints; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Tests.Common; namespace OpenSim.Data.Tests { @@ -254,7 +255,7 @@ namespace OpenSim.Data.Tests } [TestFixture] - public class PropertyCompareConstraintTest + public class PropertyCompareConstraintTest : OpenSimTestCase { public class HasInt { diff --git a/OpenSim/Data/Tests/PropertyScrambler.cs b/OpenSim/Data/Tests/PropertyScrambler.cs index c5d40c2373..e0f5862b93 100644 --- a/OpenSim/Data/Tests/PropertyScrambler.cs +++ b/OpenSim/Data/Tests/PropertyScrambler.cs @@ -34,6 +34,7 @@ using System.Text; using NUnit.Framework; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Tests.Common; namespace OpenSim.Data.Tests { @@ -158,7 +159,7 @@ namespace OpenSim.Data.Tests } [TestFixture] - public class PropertyScramblerTests + public class PropertyScramblerTests : OpenSimTestCase { [Test] public void TestScramble() diff --git a/OpenSim/Framework/AssemblyInfo.cs b/OpenSim/Framework/AssemblyInfo.cs index adeaeb221a..02986d5d2a 100644 --- a/OpenSim/Framework/AssemblyInfo.cs +++ b/OpenSim/Framework/AssemblyInfo.cs @@ -59,5 +59,5 @@ using System.Runtime.InteropServices; // Revision // -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] \ No newline at end of file diff --git a/OpenSim/Framework/AssetLoader/Filesystem/Properties/AssemblyInfo.cs b/OpenSim/Framework/AssetLoader/Filesystem/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..0498ed4888 --- /dev/null +++ b/OpenSim/Framework/AssetLoader/Filesystem/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.AssetLoader.Filesystem")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8cb9cf69-4771-4d3a-a2ba-bac7230de326")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 4f598b04ae..95e9667f6b 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -330,6 +330,9 @@ namespace OpenSim.Framework SetVisualParams(visualParams); } + /// + /// Set avatar height by a calculation based on their visual parameters. + /// public virtual void SetHeight() { // Start with shortest possible female avatar height diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 6d048f436f..dfe60aaff1 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -306,6 +306,8 @@ namespace OpenSim.Framework public AgentGroupData[] Groups; public Animation[] Anims; + public Animation DefaultAnim = null; + public Animation AnimState = null; public UUID GranterID; @@ -390,6 +392,16 @@ namespace OpenSim.Framework args["animations"] = anims; } + if (DefaultAnim != null) + { + args["default_animation"] = DefaultAnim.PackUpdateMessage(); + } + + if (AnimState != null) + { + args["animation_state"] = AnimState.PackUpdateMessage(); + } + if (Appearance != null) args["packed_appearance"] = Appearance.Pack(); @@ -583,6 +595,30 @@ namespace OpenSim.Framework } } + if (args["default_animation"] != null) + { + try + { + DefaultAnim = new Animation((OSDMap)args["default_animation"]); + } + catch + { + DefaultAnim = null; + } + } + + if (args["animation_state"] != null) + { + try + { + AnimState = new Animation((OSDMap)args["animation_state"]); + } + catch + { + AnimState = null; + } + } + //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) //{ // OSDArray textures = (OSDArray)(args["agent_textures"]); diff --git a/OpenSim/Framework/Client/IClientChat.cs b/OpenSim/Framework/Client/IClientChat.cs index 078ea9b668..86b1faa8f6 100644 --- a/OpenSim/Framework/Client/IClientChat.cs +++ b/OpenSim/Framework/Client/IClientChat.cs @@ -33,7 +33,8 @@ namespace OpenSim.Framework.Client { event ChatMessage OnChatFromClient; - void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source, - byte audible); + void SendChatMessage( + string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, + byte audible); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index 2df6aceb08..6d1c03ad4b 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -32,12 +32,12 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly : AssemblyTitle("OpenGrid.Framework.Communications")] +[assembly : AssemblyTitle("OpenSim.Framework.Communications")] [assembly : AssemblyDescription("")] [assembly : AssemblyConfiguration("")] [assembly : AssemblyCompany("http://opensimulator.org")] -[assembly : AssemblyProduct("OpenGrid.Framework.Communications")] -[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] +[assembly : AssemblyProduct("OpenSim")] +[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] [assembly : AssemblyTrademark("")] [assembly : AssemblyCulture("")] @@ -61,5 +61,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] [assembly : AssemblyFileVersion("0.6.5.0")] diff --git a/OpenSim/Framework/Configuration/HTTP/Properties/AssemblyInfo.cs b/OpenSim/Framework/Configuration/HTTP/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..0674656c75 --- /dev/null +++ b/OpenSim/Framework/Configuration/HTTP/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.Configuration.HTTP")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator develoeprs")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("cb78b672-d000-4f93-88f9-dae151cc0061")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Configuration/XML/Properties/AssemblyInfo.cs b/OpenSim/Framework/Configuration/XML/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..1095b232e2 --- /dev/null +++ b/OpenSim/Framework/Configuration/XML/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.Configuration.XML")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("eeb880df-0112-4c3d-87ed-b2108d614c55")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs index 75e35bf688..37c7304424 100644 --- a/OpenSim/Framework/Console/AssemblyInfo.cs +++ b/OpenSim/Framework/Console/AssemblyInfo.cs @@ -39,7 +39,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("http://opensimulator.org")] [assembly : AssemblyProduct("ServerConsole")] -[assembly: AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] +[assembly: AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("0.6.5.*")] +[assembly : AssemblyVersion("0.7.5.*")] diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index bd23d1cb62..de30414cb3 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -83,7 +83,8 @@ namespace OpenSim.Framework.Console = "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n"; public const string ItemHelpText - = "For more information, type 'help ' where is one of the following:"; += @"For more information, type 'help all' to get a list of all commands, + or type help ' where is one of the following:"; /// /// Commands organized by keyword in a tree @@ -117,6 +118,10 @@ namespace OpenSim.Framework.Console help.Add(ItemHelpText); help.AddRange(CollectModulesHelp(tree)); } + else if (helpParts.Count == 1 && helpParts[0] == "all") + { + help.AddRange(CollectAllCommandsHelp()); + } else { help.AddRange(CollectHelp(helpParts)); @@ -124,6 +129,28 @@ namespace OpenSim.Framework.Console return help; } + + /// + /// Collects the help from all commands and return in alphabetical order. + /// + /// + private List CollectAllCommandsHelp() + { + List help = new List(); + + lock (m_modulesCommands) + { + foreach (List commands in m_modulesCommands.Values) + { + var ourHelpText = commands.ConvertAll(c => string.Format("{0} - {1}", c.help_text, c.long_help)); + help.AddRange(ourHelpText); + } + } + + help.Sort(); + + return help; + } /// /// See if we can find the requested command in order to display longer help @@ -711,7 +738,7 @@ namespace OpenSim.Framework.Console /// public void Prompt() { - string line = ReadLine(m_defaultPrompt + "# ", true, true); + string line = ReadLine(DefaultPrompt + "# ", true, true); if (line != String.Empty) Output("Invalid command"); diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 4b375d9963..2d8e723af2 100755 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -43,15 +43,7 @@ namespace OpenSim.Framework.Console public object ConsoleScene { get; set; } - /// - /// The default prompt text. - /// - public string DefaultPrompt - { - set { m_defaultPrompt = value; } - get { return m_defaultPrompt; } - } - protected string m_defaultPrompt; + public string DefaultPrompt { get; set; } public ConsoleBase(string defaultPrompt) { diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index a7cf0c03b2..16a63e0ca5 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -27,88 +27,202 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection; using log4net; using OpenMetaverse; -public class ConsoleUtil +namespace OpenSim.Framework.Console { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public const string MinRawConsoleVectorValue = "-~"; - public const string MaxRawConsoleVectorValue = "~"; - - public const string VectorSeparator = ","; - public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); - - /// - /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 - /// - /// /param> - /// - /// - public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector) + public class ConsoleUtil { - return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector); - } + // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - /// - /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3 - /// - /// /param> - /// - /// - public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector) - { - return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector); - } + public const int LocalIdNotFound = 0; + + /// + /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section + /// rather than in each help summary. + /// + public const string CoordHelp + = @"Each component of the coord is comma separated. There must be no spaces between the commas. + If you don't care about the z component you can simply omit it. + If you don't care about the x or y components then you can leave them blank (though a comma is still required) + If you want to specify the maxmimum value of a component then you can use ~ instead of a number + If you want to specify the minimum value of a component then you can use -~ instead of a number + e.g. + delete object pos 20,20,20 to 40,40,40 + delete object pos 20,20 to 40,40 + delete object pos ,20,20 to ,40,40 + delete object pos ,,30 to ,,~ + delete object pos ,,-~ to ,,30"; + + public const string MinRawConsoleVectorValue = "-~"; + public const string MaxRawConsoleVectorValue = "~"; + + public const string VectorSeparator = ","; + public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); - /// - /// Convert a vector input from the console to an OpenMetaverse.Vector3 - /// - /// - /// A string in the form ,, where there is no space between values. - /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value - /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40) - /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue - /// Other than that, component values must be numeric. - /// - /// - /// - /// - public static bool TryParseConsoleVector( - string rawConsoleVector, Func blankComponentFunc, out Vector3 vector) - { - List components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); - - if (components.Count < 1 || components.Count > 3) + /// + /// Check if the given file path exists. + /// + /// If not, warning is printed to the given console. + /// true if the file does not exist, false otherwise. + /// + /// + public static bool CheckFileDoesNotExist(ICommandConsole console, string path) { - vector = Vector3.Zero; - return false; + if (File.Exists(path)) + { + console.OutputFormat("File {0} already exists. Please move or remove it.", path); + return false; + } + + return true; + } + + /// + /// Try to parse a console UUID from the console. + /// + /// + /// Will complain to the console if parsing fails. + /// + /// + /// If null then no complaint is printed. + /// + /// + public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid) + { + if (!UUID.TryParse(rawUuid, out uuid)) + { + if (console != null) + console.OutputFormat("{0} is not a valid uuid", rawUuid); + + return false; + } + + return true; } - for (int i = components.Count; i < 3; i++) - components.Add(""); + public static bool TryParseConsoleLocalId(ICommandConsole console, string rawLocalId, out uint localId) + { + if (!uint.TryParse(rawLocalId, out localId)) + { + if (console != null) + console.OutputFormat("{0} is not a valid local id", localId); - List semiDigestedComponents - = components.ConvertAll( - c => - { - if (c == "") - return blankComponentFunc.Invoke(c); - else if (c == MaxRawConsoleVectorValue) - return float.MaxValue.ToString(); - else if (c == MinRawConsoleVectorValue) - return float.MinValue.ToString(); - else - return c; - }); + return false; + } - string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray()); + if (localId == 0) + { + if (console != null) + console.OutputFormat("{0} is not a valid local id - it must be greater than 0", localId); -// m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector); + return false; + } - return Vector3.TryParse(semiDigestedConsoleVector, out vector); + return true; + } + + /// + /// Tries to parse the input as either a UUID or a local ID. + /// + /// true if parsing succeeded, false otherwise. + /// + /// + /// + /// + /// Will be set to ConsoleUtil.LocalIdNotFound if parsing result was a UUID or no parse succeeded. + /// + public static bool TryParseConsoleId(ICommandConsole console, string rawId, out UUID uuid, out uint localId) + { + if (TryParseConsoleUuid(null, rawId, out uuid)) + { + localId = LocalIdNotFound; + return true; + } + + if (TryParseConsoleLocalId(null, rawId, out localId)) + { + return true; + } + + if (console != null) + console.OutputFormat("{0} is not a valid UUID or local id", rawId); + + return false; + } + + /// + /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 + /// + /// /param> + /// + /// + public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector) + { + return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector); + } + + /// + /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3 + /// + /// /param> + /// + /// + public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector) + { + return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector); + } + + /// + /// Convert a vector input from the console to an OpenMetaverse.Vector3 + /// + /// + /// A string in the form ,, where there is no space between values. + /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value + /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40) + /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue + /// Other than that, component values must be numeric. + /// + /// + /// + /// + public static bool TryParseConsoleVector( + string rawConsoleVector, Func blankComponentFunc, out Vector3 vector) + { + List components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); + + if (components.Count < 1 || components.Count > 3) + { + vector = Vector3.Zero; + return false; + } + + for (int i = components.Count; i < 3; i++) + components.Add(""); + + List semiDigestedComponents + = components.ConvertAll( + c => + { + if (c == "") + return blankComponentFunc.Invoke(c); + else if (c == MaxRawConsoleVectorValue) + return float.MaxValue.ToString(); + else if (c == MinRawConsoleVectorValue) + return float.MinValue.ToString(); + else + return c; + }); + + string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray()); + + // m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector); + + return Vector3.TryParse(semiDigestedConsoleVector, out vector); + } } } \ No newline at end of file diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index b489f93b69..8ba58e4cc6 100644 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs @@ -46,13 +46,18 @@ namespace OpenSim.Framework.Console public ICommands Commands { get { return m_commands; } } + public string DefaultPrompt { get; set; } + public void Prompt() {} public void RunCommand(string cmd) {} public string ReadLine(string p, bool isCommand, bool e) { return ""; } - public object ConsoleScene { get { return null; } } + public object ConsoleScene { + get { return null; } + set {} + } public void Output(string text, string level) {} public void Output(string text) {} diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 9856978cfd..87433cc3cb 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1099,8 +1099,20 @@ namespace OpenSim.Framework void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs); void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args); - void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source, - byte audible); + /// + /// Send chat to the viewer. + /// + /// + /// + /// + /// + /// + /// + /// + /// + void SendChatMessage( + string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, + byte audible); void SendInstantMessage(GridInstantMessage im); diff --git a/OpenSim/Framework/ICommandConsole.cs b/OpenSim/Framework/ICommandConsole.cs index 8cd20da4ee..a6573f8843 100644 --- a/OpenSim/Framework/ICommandConsole.cs +++ b/OpenSim/Framework/ICommandConsole.cs @@ -82,6 +82,11 @@ namespace OpenSim.Framework ICommands Commands { get; } + /// + /// The default prompt text. + /// + string DefaultPrompt { get; set; } + /// /// Display a command prompt on the console and wait for user input /// diff --git a/OpenSim/Framework/IConsole.cs b/OpenSim/Framework/IConsole.cs index 33024b2076..79560d805b 100644 --- a/OpenSim/Framework/IConsole.cs +++ b/OpenSim/Framework/IConsole.cs @@ -32,7 +32,7 @@ namespace OpenSim.Framework { public interface IConsole { - object ConsoleScene { get; } + object ConsoleScene { get; set; } void Output(string text, string level); void Output(string text); diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs index a663680a78..3d45e76698 100644 --- a/OpenSim/Framework/InventoryItemBase.cs +++ b/OpenSim/Framework/InventoryItemBase.cs @@ -87,16 +87,7 @@ namespace OpenSim.Framework protected string m_creatorId; /// - /// The UUID for the creator. This may be different from the canonical CreatorId. This property is used - /// for communication with the client over the Second Life protocol, since that protocol can only understand - /// UUIDs. As this is a basic framework class, this means that both the string creator id and the uuid - /// reference have to be settable separately - /// - /// Database plugins don't need to set this, it will be set by - /// upstream code (or set by the get accessor if left unset). - /// - /// XXX: An alternative to having a separate uuid property would be to hash the CreatorId appropriately - /// every time there was communication with a UUID-only client. This may be much more expensive. + /// The CreatorId expressed as a UUID.tely /// public UUID CreatorIdAsUuid { @@ -109,20 +100,18 @@ namespace OpenSim.Framework return m_creatorIdAsUuid; } - - set - { - m_creatorIdAsUuid = value; - } } protected UUID m_creatorIdAsUuid = UUID.Zero; - protected string m_creatorData = string.Empty; + /// + /// Extended creator information of the form ; + /// public string CreatorData // = ; { get { return m_creatorData; } set { m_creatorData = value; } } + protected string m_creatorData = string.Empty; /// /// Used by the DB layer to retrieve / store the entire user identification. @@ -162,7 +151,6 @@ namespace OpenSim.Framework name = parts[2]; m_creatorData += ';' + name; - } } } diff --git a/OpenSim/Framework/Monitoring/Properties/AssemblyInfo.cs b/OpenSim/Framework/Monitoring/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..1f2bb4087a --- /dev/null +++ b/OpenSim/Framework/Monitoring/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.Monitoring")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("74506fe3-2f9d-44c1-94c9-a30f79d9e0cb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs b/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs new file mode 100644 index 0000000000..60bed55500 --- /dev/null +++ b/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs @@ -0,0 +1,88 @@ +/* + * 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 OpenSimulator 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.Text; + +namespace OpenSim.Framework.Monitoring +{ + public class PercentageStat : Stat + { + public long Antecedent { get; set; } + public long Consequent { get; set; } + + public override double Value + { + get + { + // Asking for an update here means that the updater cannot access this value without infinite recursion. + // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being + // called by the pull action and just return the value. + if (StatType == StatType.Pull) + PullAction(this); + + long c = Consequent; + + // Avoid any chance of a multi-threaded divide-by-zero + if (c == 0) + return 0; + + return (double)Antecedent / c * 100; + } + + set + { + throw new InvalidOperationException("Cannot set value on a PercentageStat"); + } + } + + public PercentageStat( + string shortName, + string name, + string description, + string category, + string container, + StatType type, + Action pullAction, + StatVerbosity verbosity) + : base(shortName, name, description, "%", category, container, type, pullAction, verbosity) {} + + public override string ToConsoleString() + { + StringBuilder sb = new StringBuilder(); + + sb.AppendFormat( + "{0}.{1}.{2} : {3:0.##}{4} ({5}/{6})", + Category, Container, ShortName, Value, UnitName, Antecedent, Consequent); + + AppendMeasuresOfInterest(sb); + + return sb.ToString(); + } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs new file mode 100644 index 0000000000..f91251b6ea --- /dev/null +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs @@ -0,0 +1,238 @@ +/* + * 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 OpenSimulator 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.Text; + +namespace OpenSim.Framework.Monitoring +{ + /// + /// Holds individual statistic details + /// + public class Stat + { + /// + /// Category of this stat (e.g. cache, scene, etc). + /// + public string Category { get; private set; } + + /// + /// Containing name for this stat. + /// FIXME: In the case of a scene, this is currently the scene name (though this leaves + /// us with a to-be-resolved problem of non-unique region names). + /// + /// + /// The container. + /// + public string Container { get; private set; } + + public StatType StatType { get; private set; } + + public MeasuresOfInterest MeasuresOfInterest { get; private set; } + + /// + /// Action used to update this stat when the value is requested if it's a pull type. + /// + public Action PullAction { get; private set; } + + public StatVerbosity Verbosity { get; private set; } + public string ShortName { get; private set; } + public string Name { get; private set; } + public string Description { get; private set; } + public virtual string UnitName { get; private set; } + + public virtual double Value + { + get + { + // Asking for an update here means that the updater cannot access this value without infinite recursion. + // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being + // called by the pull action and just return the value. + if (StatType == StatType.Pull) + PullAction(this); + + return m_value; + } + + set + { + m_value = value; + } + } + + private double m_value; + + /// + /// Historical samples for calculating measures of interest average. + /// + /// + /// Will be null if no measures of interest require samples. + /// + private static Queue m_samples; + + /// + /// Maximum number of statistical samples. + /// + /// + /// At the moment this corresponds to 1 minute since the sampling rate is every 2.5 seconds as triggered from + /// the main Watchdog. + /// + private static int m_maxSamples = 24; + + public Stat( + string shortName, + string name, + string description, + string unitName, + string category, + string container, + StatType type, + Action pullAction, + StatVerbosity verbosity) + : this( + shortName, + name, + description, + unitName, + category, + container, + type, + MeasuresOfInterest.None, + pullAction, + verbosity) + { + } + + /// + /// Constructor + /// + /// Short name for the stat. Must not contain spaces. e.g. "LongFrames" + /// Human readable name for the stat. e.g. "Long frames" + /// Description of stat + /// + /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value. + /// e.g. " frames" + /// + /// Category under which this stat should appear, e.g. "scene". Do not capitalize. + /// Entity to which this stat relates. e.g. scene name if this is a per scene stat. + /// Push or pull + /// Pull stats need an action to update the stat on request. Push stats should set null here. + /// Measures of interest + /// Verbosity of stat. Controls whether it will appear in short stat display or only full display. + public Stat( + string shortName, + string name, + string description, + string unitName, + string category, + string container, + StatType type, + MeasuresOfInterest moi, + Action pullAction, + StatVerbosity verbosity) + { + if (StatsManager.SubCommands.Contains(category)) + throw new Exception( + string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); + + ShortName = shortName; + Name = name; + Description = description; + UnitName = unitName; + Category = category; + Container = container; + StatType = type; + + if (StatType == StatType.Push && pullAction != null) + throw new Exception("A push stat cannot have a pull action"); + else + PullAction = pullAction; + + MeasuresOfInterest = moi; + + if ((moi & MeasuresOfInterest.AverageChangeOverTime) == MeasuresOfInterest.AverageChangeOverTime) + m_samples = new Queue(m_maxSamples); + + Verbosity = verbosity; + } + + /// + /// Record a value in the sample set. + /// + /// + /// Do not call this if MeasuresOfInterest.None + /// + public void RecordValue() + { + double newValue = Value; + + lock (m_samples) + { + if (m_samples.Count >= m_maxSamples) + m_samples.Dequeue(); + + m_samples.Enqueue(newValue); + } + } + + public virtual string ToConsoleString() + { + StringBuilder sb = new StringBuilder(); + sb.AppendFormat("{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName); + + AppendMeasuresOfInterest(sb); + + return sb.ToString(); + } + + protected void AppendMeasuresOfInterest(StringBuilder sb) + { + if ((MeasuresOfInterest & MeasuresOfInterest.AverageChangeOverTime) + == MeasuresOfInterest.AverageChangeOverTime) + { + double totalChange = 0; + double? lastSample = null; + + lock (m_samples) + { + foreach (double s in m_samples) + { + if (lastSample != null) + totalChange += s - (double)lastSample; + + lastSample = s; + } + } + + int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1; + + sb.AppendFormat(", {0:0.##}{1}/s", totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000), UnitName); + } + } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 31989e50ad..0762b01c7d 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Text; namespace OpenSim.Framework.Monitoring { @@ -207,7 +208,7 @@ namespace OpenSim.Framework.Monitoring return false; newContainer = new Dictionary(container); - newContainer.Remove(stat.UniqueName); + newContainer.Remove(stat.ShortName); newCategory = new Dictionary>(category); newCategory.Remove(stat.Container); @@ -246,6 +247,47 @@ namespace OpenSim.Framework.Monitoring return false; } + + public static void RecordStats() + { + lock (RegisteredStats) + { + foreach (Dictionary> category in RegisteredStats.Values) + { + foreach (Dictionary container in category.Values) + { + foreach (Stat stat in container.Values) + { + if (stat.MeasuresOfInterest != MeasuresOfInterest.None) + stat.RecordValue(); + } + } + } + } + } + } + + /// + /// Stat type. + /// + /// + /// A push stat is one which is continually updated and so it's value can simply by read. + /// A pull stat is one where reading the value triggers a collection method - the stat is not continually updated. + /// + public enum StatType + { + Push, + Pull + } + + /// + /// Measures of interest for this stat. + /// + [Flags] + public enum MeasuresOfInterest + { + None, + AverageChangeOverTime } /// @@ -259,116 +301,4 @@ namespace OpenSim.Framework.Monitoring Debug, Info } - - /// - /// Holds individual static details - /// - public class Stat - { - /// - /// Unique stat name used for indexing. Each ShortName in a Category must be unique. - /// - public string UniqueName { get; private set; } - - /// - /// Category of this stat (e.g. cache, scene, etc). - /// - public string Category { get; private set; } - - /// - /// Containing name for this stat. - /// FIXME: In the case of a scene, this is currently the scene name (though this leaves - /// us with a to-be-resolved problem of non-unique region names). - /// - /// - /// The container. - /// - public string Container { get; private set; } - - public StatVerbosity Verbosity { get; private set; } - public string ShortName { get; private set; } - public string Name { get; private set; } - public string Description { get; private set; } - public virtual string UnitName { get; private set; } - - public virtual double Value { get; set; } - - /// - /// Constructor - /// - /// Short name for the stat. Must not contain spaces. e.g. "LongFrames" - /// Human readable name for the stat. e.g. "Long frames" - /// - /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value. - /// e.g. " frames" - /// - /// Category under which this stat should appear, e.g. "scene". Do not capitalize. - /// Entity to which this stat relates. e.g. scene name if this is a per scene stat. - /// Verbosity of stat. Controls whether it will appear in short stat display or only full display. - /// Description of stat - public Stat( - string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description) - { - if (StatsManager.SubCommands.Contains(category)) - throw new Exception( - string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); - - ShortName = shortName; - Name = name; - UnitName = unitName; - Category = category; - Container = container; - Verbosity = verbosity; - Description = description; - - UniqueName = GenUniqueName(Container, Category, ShortName); - } - - public static string GenUniqueName(string container, string category, string shortName) - { - return string.Format("{0}+{1}+{2}", container, category, shortName); - } - - public virtual string ToConsoleString() - { - return string.Format( - "{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName); - } - } - - public class PercentageStat : Stat - { - public int Antecedent { get; set; } - public int Consequent { get; set; } - - public override double Value - { - get - { - int c = Consequent; - - // Avoid any chance of a multi-threaded divide-by-zero - if (c == 0) - return 0; - - return (double)Antecedent / c * 100; - } - - set - { - throw new Exception("Cannot set value on a PercentageStat"); - } - } - - public PercentageStat( - string shortName, string name, string category, string container, StatVerbosity verbosity, string description) - : base(shortName, name, "%", category, container, verbosity, description) {} - - public override string ToConsoleString() - { - return string.Format( - "{0}.{1}.{2} : {3:0.##}{4} ({5}/{6})", - Category, Container, ShortName, Value, UnitName, Antecedent, Consequent); - } - } } \ No newline at end of file diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index a20326dbd8..3f992b1e3b 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs @@ -39,7 +39,7 @@ namespace OpenSim.Framework.Monitoring public static class Watchdog { /// Timer interval in milliseconds for the watchdog timer - const double WATCHDOG_INTERVAL_MS = 2500.0d; + public const double WATCHDOG_INTERVAL_MS = 2500.0d; /// Default timeout in milliseconds before a thread is considered dead public const int DEFAULT_WATCHDOG_TIMEOUT_MS = 5000; @@ -380,6 +380,8 @@ namespace OpenSim.Framework.Monitoring if (MemoryWatchdog.Enabled) MemoryWatchdog.Update(); + StatsManager.RecordStats(); + m_watchdogTimer.Start(); } } diff --git a/OpenSim/Framework/Pool.cs b/OpenSim/Framework/Pool.cs index 1ca06c3065..5484f5c2d5 100644 --- a/OpenSim/Framework/Pool.cs +++ b/OpenSim/Framework/Pool.cs @@ -38,8 +38,23 @@ namespace OpenSim.Framework /// public class Pool { + /// + /// Number of objects in the pool. + /// + public int Count + { + get + { + lock (m_pool) + return m_pool.Count; + } + } + private Stack m_pool; + /// + /// Maximum pool size. Beyond this, any returned objects are not pooled. + /// private int m_maxPoolSize; private Func m_createFunction; diff --git a/OpenSim/Framework/RegionLoader/Filesystem/Properties/AssemblyInfo.cs b/OpenSim/Framework/RegionLoader/Filesystem/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..d670f2f129 --- /dev/null +++ b/OpenSim/Framework/RegionLoader/Filesystem/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.RegionLoader.Filesystem")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4ab5c74b-e886-40a1-b67d-a04df285e706")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/RegionLoader/Web/Properties/AssemblyInfo.cs b/OpenSim/Framework/RegionLoader/Web/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..7309a12e88 --- /dev/null +++ b/OpenSim/Framework/RegionLoader/Web/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.RegionLoader.Web")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("985afff8-e7ed-4056-acce-39abf7a43d33")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Serialization/ArchiveConstants.cs b/OpenSim/Framework/Serialization/ArchiveConstants.cs index 48f1c4f94f..0c12787882 100644 --- a/OpenSim/Framework/Serialization/ArchiveConstants.cs +++ b/OpenSim/Framework/Serialization/ArchiveConstants.cs @@ -154,6 +154,11 @@ namespace OpenSim.Framework.Serialization EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"] = (sbyte)AssetType.TrashFolder; } + public static string CreateOarLandDataPath(LandData ld) + { + return string.Format("{0}{1}.xml", ArchiveConstants.LANDDATA_PATH, ld.GlobalID); + } + /// /// Create the filename used to store an object in an OpenSim Archive. /// diff --git a/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs b/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..11efa4beb7 --- /dev/null +++ b/OpenSim/Framework/Serialization/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.Serialization")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("919db41e-4ac0-4f24-9992-81d62c0ee183")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs index 8b9756b11d..ea100ee71c 100644 --- a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs +++ b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs @@ -37,7 +37,7 @@ using OpenSim.Tests.Common; namespace OpenSim.Framework.Serialization.Tests { [TestFixture] - public class LandDataSerializerTest + public class LandDataSerializerTest : OpenSimTestCase { private LandData land; private LandData landWithParcelAccessList; diff --git a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs index 09b6f6ddad..142726bbe7 100644 --- a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs +++ b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs @@ -37,7 +37,7 @@ using OpenSim.Tests.Common; namespace OpenSim.Framework.Serialization.Tests { [TestFixture] - public class RegionSettingsSerializerTests + public class RegionSettingsSerializerTests : OpenSimTestCase { private string m_serializedRs = @" diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index aac9c45fb7..c0dc907ddc 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -27,7 +27,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Reflection; using System.Text; @@ -38,6 +37,8 @@ using log4net; using log4net.Appender; using log4net.Core; using log4net.Repository; +using OpenMetaverse; +using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Monitoring; @@ -45,16 +46,12 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using Timer=System.Timers.Timer; -using OpenMetaverse; -using OpenMetaverse.StructuredData; - - namespace OpenSim.Framework.Servers { /// /// Common base for the main OpenSimServers (user, grid, inventory, region, etc) /// - public abstract class BaseOpenSimServer + public abstract class BaseOpenSimServer : ServerBase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -63,27 +60,6 @@ namespace OpenSim.Framework.Servers /// server. /// private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000); - - protected CommandConsole m_console; - protected OpenSimAppender m_consoleAppender; - protected IAppender m_logFileAppender = null; - - /// - /// Time at which this server was started - /// - protected DateTime m_startuptime; - - /// - /// Record the initial startup directory for info purposes - /// - protected string m_startupDirectory = Environment.CurrentDirectory; - - /// - /// Server version information. Usually VersionInfo + information about git commit, operating system, etc. - /// - protected string m_version; - - protected string m_pidFile = String.Empty; /// /// Random uuid for private data @@ -96,30 +72,13 @@ namespace OpenSim.Framework.Servers get { return m_httpServer; } } - public BaseOpenSimServer() + public BaseOpenSimServer() : base() { - m_startuptime = DateTime.Now; - m_version = VersionInfo.Version; - // Random uuid for private data m_osSecret = UUID.Random().ToString(); m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); m_periodicDiagnosticsTimer.Enabled = true; - - // This thread will go on to become the console listening thread - Thread.CurrentThread.Name = "ConsoleThread"; - - ILoggerRepository repository = LogManager.GetRepository(); - IAppender[] appenders = repository.GetAppenders(); - - foreach (IAppender appender in appenders) - { - if (appender.Name == "LogFileAppender") - { - m_logFileAppender = appender; - } - } } /// @@ -127,72 +86,18 @@ namespace OpenSim.Framework.Servers /// protected virtual void StartupSpecific() { - if (m_console != null) - { - ILoggerRepository repository = LogManager.GetRepository(); - IAppender[] appenders = repository.GetAppenders(); + if (m_console == null) + return; - foreach (IAppender appender in appenders) - { - if (appender.Name == "Console") - { - m_consoleAppender = (OpenSimAppender)appender; - break; - } - } + RegisterCommonCommands(); + + m_console.Commands.AddCommand("General", false, "quit", + "quit", + "Quit the application", HandleQuit); - if (null == m_consoleAppender) - { - Notice("No appender named Console found (see the log4net config file for this executable)!"); - } - else - { - m_consoleAppender.Console = m_console; - - // If there is no threshold set then the threshold is effectively everything. - if (null == m_consoleAppender.Threshold) - m_consoleAppender.Threshold = Level.All; - - Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); - } - - m_console.Commands.AddCommand("General", false, "quit", - "quit", - "Quit the application", HandleQuit); - - m_console.Commands.AddCommand("General", false, "shutdown", - "shutdown", - "Quit the application", HandleQuit); - - m_console.Commands.AddCommand("General", false, "set log level", - "set log level ", - "Set the console logging level", HandleLogLevel); - - m_console.Commands.AddCommand("General", false, "show info", - "show info", - "Show general information about the server", HandleShow); - - m_console.Commands.AddCommand("General", false, "show threads", - "show threads", - "Show thread status", HandleShow); - - m_console.Commands.AddCommand("General", false, "show uptime", - "show uptime", - "Show server uptime", HandleShow); - - m_console.Commands.AddCommand("General", false, "show version", - "show version", - "Show server version", HandleShow); - - m_console.Commands.AddCommand("General", false, "threads abort", - "threads abort ", - "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort); - - m_console.Commands.AddCommand("General", false, "threads show", - "threads show", - "Show thread status. Synonym for \"show threads\"", - (string module, string[] args) => Notice(GetThreadsReport())); - } + m_console.Commands.AddCommand("General", false, "shutdown", + "shutdown", + "Quit the application", HandleQuit); } /// @@ -224,75 +129,12 @@ namespace OpenSim.Framework.Servers m_log.Debug(sb); } - /// - /// Get a report about the registered threads in this server. - /// - protected string GetThreadsReport() - { - // This should be a constant field. - string reportFormat = "{0,6} {1,35} {2,16} {3,13} {4,10} {5,30}"; - - StringBuilder sb = new StringBuilder(); - Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreadsInfo(); - - sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine); - - int timeNow = Environment.TickCount & Int32.MaxValue; - - sb.AppendFormat(reportFormat, "ID", "NAME", "LAST UPDATE (MS)", "LIFETIME (MS)", "PRIORITY", "STATE"); - sb.Append(Environment.NewLine); - - foreach (Watchdog.ThreadWatchdogInfo twi in threads) - { - Thread t = twi.Thread; - - sb.AppendFormat( - reportFormat, - t.ManagedThreadId, - t.Name, - timeNow - twi.LastTick, - timeNow - twi.FirstTick, - t.Priority, - t.ThreadState); - - sb.Append("\n"); - } - - sb.Append("\n"); - - // For some reason mono 2.6.7 returns an empty threads set! Not going to confuse people by reporting - // zero active threads. - int totalThreads = Process.GetCurrentProcess().Threads.Count; - if (totalThreads > 0) - sb.AppendFormat("Total threads active: {0}\n\n", totalThreads); - - sb.Append("Main threadpool (excluding script engine pools)\n"); - sb.Append(Util.GetThreadPoolReport()); - - return sb.ToString(); - } - - /// - /// Return a report about the uptime of this server - /// - /// - protected string GetUptimeReport() - { - StringBuilder sb = new StringBuilder(String.Format("Time now is {0}\n", DateTime.Now)); - sb.Append(String.Format("Server has been running since {0}, {1}\n", m_startuptime.DayOfWeek, m_startuptime)); - sb.Append(String.Format("That is an elapsed time of {0}\n", DateTime.Now - m_startuptime)); - - return sb.ToString(); - } - /// /// Performs initialisation of the scene, such as loading configuration from disk. /// public virtual void Startup() { m_log.Info("[STARTUP]: Beginning startup processing"); - - EnhanceVersionInformation(); m_log.Info("[STARTUP]: OpenSimulator version: " + m_version + Environment.NewLine); // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and @@ -327,257 +169,7 @@ namespace OpenSim.Framework.Servers private void HandleQuit(string module, string[] args) { Shutdown(); - } - - private void HandleLogLevel(string module, string[] cmd) - { - if (null == m_consoleAppender) - { - Notice("No appender named Console found (see the log4net config file for this executable)!"); - return; - } - - if (cmd.Length > 3) - { - string rawLevel = cmd[3]; - - ILoggerRepository repository = LogManager.GetRepository(); - Level consoleLevel = repository.LevelMap[rawLevel]; - - if (consoleLevel != null) - m_consoleAppender.Threshold = consoleLevel; - else - Notice( - String.Format( - "{0} is not a valid logging level. Valid logging levels are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF", - rawLevel)); - } - - Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); - } - - /// - /// Show help information - /// - /// - protected virtual void ShowHelp(string[] helpArgs) - { - Notice(""); - - if (helpArgs.Length == 0) - { - Notice("set log level [level] - change the console logging level only. For example, off or debug."); - Notice("show info - show server information (e.g. startup path)."); - Notice("show threads - list tracked threads"); - Notice("show uptime - show server startup time and uptime."); - Notice("show version - show server version."); - Notice(""); - - return; - } - } - - public virtual void HandleShow(string module, string[] cmd) - { - List args = new List(cmd); - - args.RemoveAt(0); - - string[] showParams = args.ToArray(); - - switch (showParams[0]) - { - case "info": - ShowInfo(); - break; - - case "threads": - Notice(GetThreadsReport()); - break; - - case "uptime": - Notice(GetUptimeReport()); - break; - - case "version": - Notice(GetVersionText()); - break; - } - } - - public virtual void HandleThreadsAbort(string module, string[] cmd) - { - if (cmd.Length != 3) - { - MainConsole.Instance.Output("Usage: threads abort "); - return; - } - - int threadId; - if (!int.TryParse(cmd[2], out threadId)) - { - MainConsole.Instance.Output("ERROR: Thread id must be an integer"); - return; - } - - if (Watchdog.AbortThread(threadId)) - MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId); - else - MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId); - } - - protected void ShowInfo() - { - Notice(GetVersionText()); - Notice("Startup directory: " + m_startupDirectory); - if (null != m_consoleAppender) - Notice(String.Format("Console log level: {0}", m_consoleAppender.Threshold)); - } - - protected string GetVersionText() - { - return String.Format("Version: {0} (interface version {1})", m_version, VersionInfo.MajorInterfaceVersion); - } - - /// - /// Console output is only possible if a console has been established. - /// That is something that cannot be determined within this class. So - /// all attempts to use the console MUST be verified. - /// - /// - protected void Notice(string msg) - { - if (m_console != null) - { - m_console.Output(msg); - } - } - - /// - /// Console output is only possible if a console has been established. - /// That is something that cannot be determined within this class. So - /// all attempts to use the console MUST be verified. - /// - /// - /// - protected void Notice(string format, params string[] components) - { - if (m_console != null) - m_console.OutputFormat(format, components); - } - - /// - /// Enhance the version string with extra information if it's available. - /// - protected void EnhanceVersionInformation() - { - string buildVersion = string.Empty; - - // The subversion information is deprecated and will be removed at a later date - // Add subversion revision information if available - // Try file "svn_revision" in the current directory first, then the .svn info. - // This allows to make the revision available in simulators not running from the source tree. - // FIXME: Making an assumption about the directory we're currently in - we do this all over the place - // elsewhere as well - string gitDir = "../.git/"; - string gitRefPointerPath = gitDir + "HEAD"; - - string svnRevisionFileName = "svn_revision"; - string svnFileName = ".svn/entries"; - string manualVersionFileName = ".version"; - string inputLine; - int strcmp; - - if (File.Exists(manualVersionFileName)) - { - using (StreamReader CommitFile = File.OpenText(manualVersionFileName)) - buildVersion = CommitFile.ReadLine(); - - m_version += buildVersion ?? ""; - } - else if (File.Exists(gitRefPointerPath)) - { -// m_log.DebugFormat("[OPENSIM]: Found {0}", gitRefPointerPath); - - string rawPointer = ""; - - using (StreamReader pointerFile = File.OpenText(gitRefPointerPath)) - rawPointer = pointerFile.ReadLine(); - -// m_log.DebugFormat("[OPENSIM]: rawPointer [{0}]", rawPointer); - - Match m = Regex.Match(rawPointer, "^ref: (.+)$"); - - if (m.Success) - { -// m_log.DebugFormat("[OPENSIM]: Matched [{0}]", m.Groups[1].Value); - - string gitRef = m.Groups[1].Value; - string gitRefPath = gitDir + gitRef; - if (File.Exists(gitRefPath)) - { -// m_log.DebugFormat("[OPENSIM]: Found gitRefPath [{0}]", gitRefPath); - - using (StreamReader refFile = File.OpenText(gitRefPath)) - { - string gitHash = refFile.ReadLine(); - m_version += gitHash.Substring(0, 7); - } - } - } - } - else - { - // Remove the else logic when subversion mirror is no longer used - if (File.Exists(svnRevisionFileName)) - { - StreamReader RevisionFile = File.OpenText(svnRevisionFileName); - buildVersion = RevisionFile.ReadLine(); - buildVersion.Trim(); - RevisionFile.Close(); - } - - if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName)) - { - StreamReader EntriesFile = File.OpenText(svnFileName); - inputLine = EntriesFile.ReadLine(); - while (inputLine != null) - { - // using the dir svn revision at the top of entries file - strcmp = String.Compare(inputLine, "dir"); - if (strcmp == 0) - { - buildVersion = EntriesFile.ReadLine(); - break; - } - else - { - inputLine = EntriesFile.ReadLine(); - } - } - EntriesFile.Close(); - } - - m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6); - } - } - - protected void CreatePIDFile(string path) - { - try - { - string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); - FileStream fs = File.Create(path); - - Byte[] buf = Encoding.ASCII.GetBytes(pidstring); - fs.Write(buf, 0, buf.Length); - fs.Close(); - m_pidFile = path; - } - catch (Exception) - { - } - } + } public string osSecret { // Secret uuid for the simulator @@ -596,20 +188,5 @@ namespace OpenSim.Framework.Servers return StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version); } } - - protected void RemovePIDFile() - { - if (m_pidFile != String.Empty) - { - try - { - File.Delete(m_pidFile); - m_pidFile = String.Empty; - } - catch (Exception) - { - } - } - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index b018e57c45..2cd626fa44 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -542,11 +542,8 @@ namespace OpenSim.Framework.Servers.HttpServer { case null: case "text/html": - if (DebugLevel >= 3) - m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", - RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); + LogIncomingToContentTypeHandler(request); buffer = HandleHTTPRequest(request, response); break; @@ -554,11 +551,8 @@ namespace OpenSim.Framework.Servers.HttpServer case "application/llsd+xml": case "application/xml+llsd": case "application/llsd+json": - if (DebugLevel >= 3) - m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", - RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); + LogIncomingToContentTypeHandler(request); buffer = HandleLLSDRequests(request, response); break; @@ -693,7 +687,7 @@ namespace OpenSim.Framework.Servers.HttpServer "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", RequestNumber, Port, - request.ContentType, + (request.ContentType == null || request.ContentType == "") ? "not set" : request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); @@ -725,8 +719,11 @@ namespace OpenSim.Framework.Servers.HttpServer if (DebugLevel == 5) { const int sampleLength = 80; - char[] sampleChars = new char[sampleLength]; + char[] sampleChars = new char[sampleLength + 3]; reader.Read(sampleChars, 0, sampleLength); + sampleChars[80] = '.'; + sampleChars[81] = '.'; + sampleChars[82] = '.'; output = new string(sampleChars); } else @@ -734,7 +731,7 @@ namespace OpenSim.Framework.Servers.HttpServer output = reader.ReadToEnd(); } - m_log.DebugFormat("[BASE HTTP SERVER]: {0}...", output.Replace("\n", @"\n")); + m_log.DebugFormat("[BASE HTTP SERVER]: {0}", output.Replace("\n", @"\n")); } } @@ -1285,59 +1282,6 @@ namespace OpenSim.Framework.Servers.HttpServer map["login"] = OSD.FromString("false"); return map; } - /// - /// A specific agent handler was provided. Such a handler is expecetd to have an - /// intimate, and highly specific relationship with the client. Consequently, - /// nothing is done here. - /// - /// - /// - /// - - private bool HandleAgentRequest(IHttpAgentHandler handler, OSHttpRequest request, OSHttpResponse response) - { - // In the case of REST, then handler is responsible for ALL aspects of - // the request/response handling. Nothing is done here, not even encoding. - - try - { - return handler.Handle(request, response); - } - catch (Exception e) - { - // If the handler did in fact close the stream, then this will blow - // chunks. So that that doesn't disturb anybody we throw away any - // and all exceptions raised. We've done our best to release the - // client. - try - { - m_log.Warn("[HTTP-AGENT]: Error - " + e.Message); - response.SendChunked = false; - response.KeepAlive = true; - response.StatusCode = (int)OSHttpStatusCode.ServerErrorInternalError; - //response.OutputStream.Close(); - try - { - response.Send(); - //response.FreeContext(); - } - catch (SocketException f) - { - // This has to be here to prevent a Linux/Mono crash - m_log.Warn( - String.Format("[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux. ", f.Message), f); - } - } - catch(Exception) - { - } - } - - // Indicate that the request has been "handled" - - return true; - - } public byte[] HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) { diff --git a/OpenSim/Framework/Servers/HttpServer/Properties/AssemblyInfo.cs b/OpenSim/Framework/Servers/HttpServer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..02ecc250a1 --- /dev/null +++ b/OpenSim/Framework/Servers/HttpServer/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.Servers.HttpServer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c4ea5baa-81c4-4867-a645-1ec360c1f164")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Servers/Properties/AssemblyInfo.cs b/OpenSim/Framework/Servers/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..021f63c632 --- /dev/null +++ b/OpenSim/Framework/Servers/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Framework.Servers")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("http://opensimulator.org")] +[assembly: AssemblyProduct("OpenSim")] +[assembly: AssemblyCopyright("OpenSimulator developers")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b48e8b3e-5c5c-4673-b31f-21e13b8e568b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.7.5.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs new file mode 100644 index 0000000000..47baac8022 --- /dev/null +++ b/OpenSim/Framework/Servers/ServerBase.cs @@ -0,0 +1,677 @@ +/* + * 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 OpenSimulator 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.Diagnostics; +using System.IO; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using log4net; +using log4net.Appender; +using log4net.Core; +using log4net.Repository; +using Nini.Config; +using OpenSim.Framework.Console; +using OpenSim.Framework.Monitoring; + +namespace OpenSim.Framework.Servers +{ + public class ServerBase + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public IConfigSource Config { get; protected set; } + + /// + /// Console to be used for any command line output. Can be null, in which case there should be no output. + /// + protected ICommandConsole m_console; + + protected OpenSimAppender m_consoleAppender; + protected FileAppender m_logFileAppender; + + protected DateTime m_startuptime; + protected string m_startupDirectory = Environment.CurrentDirectory; + + protected string m_pidFile = String.Empty; + + /// + /// Server version information. Usually VersionInfo + information about git commit, operating system, etc. + /// + protected string m_version; + + public ServerBase() + { + m_startuptime = DateTime.Now; + m_version = VersionInfo.Version; + EnhanceVersionInformation(); + } + + protected void CreatePIDFile(string path) + { + try + { + string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); + + using (FileStream fs = File.Create(path)) + { + Byte[] buf = Encoding.ASCII.GetBytes(pidstring); + fs.Write(buf, 0, buf.Length); + } + + m_pidFile = path; + + m_log.InfoFormat("[SERVER BASE]: Created pid file {0}", m_pidFile); + } + catch (Exception e) + { + m_log.Warn(string.Format("[SERVER BASE]: Could not create PID file at {0} ", path), e); + } + } + + protected void RemovePIDFile() + { + if (m_pidFile != String.Empty) + { + try + { + File.Delete(m_pidFile); + } + catch (Exception e) + { + m_log.Error(string.Format("[SERVER BASE]: Error whilst removing {0} ", m_pidFile), e); + } + + m_pidFile = String.Empty; + } + } + + public void RegisterCommonAppenders(IConfig startupConfig) + { + ILoggerRepository repository = LogManager.GetRepository(); + IAppender[] appenders = repository.GetAppenders(); + + foreach (IAppender appender in appenders) + { + if (appender.Name == "Console") + { + m_consoleAppender = (OpenSimAppender)appender; + } + else if (appender.Name == "LogFileAppender") + { + m_logFileAppender = (FileAppender)appender; + } + } + + if (null == m_consoleAppender) + { + Notice("No appender named Console found (see the log4net config file for this executable)!"); + } + else + { + // FIXME: This should be done through an interface rather than casting. + m_consoleAppender.Console = (ConsoleBase)m_console; + + // If there is no threshold set then the threshold is effectively everything. + if (null == m_consoleAppender.Threshold) + m_consoleAppender.Threshold = Level.All; + + Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); + } + + if (m_logFileAppender != null && startupConfig != null) + { + string cfgFileName = startupConfig.GetString("LogFile", null); + if (cfgFileName != null) + { + m_logFileAppender.File = cfgFileName; + m_logFileAppender.ActivateOptions(); + } + + m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File); + } + } + + /// + /// Register common commands once m_console has been set if it is going to be set + /// + public void RegisterCommonCommands() + { + if (m_console == null) + return; + + m_console.Commands.AddCommand( + "General", false, "show info", "show info", "Show general information about the server", HandleShow); + + m_console.Commands.AddCommand( + "General", false, "show version", "show version", "Show server version", HandleShow); + + m_console.Commands.AddCommand( + "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow); + + m_console.Commands.AddCommand( + "General", false, "get log level", "get log level", "Get the current console logging level", + (mod, cmd) => ShowLogLevel()); + + m_console.Commands.AddCommand( + "General", false, "set log level", "set log level ", + "Set the console logging level for this session.", HandleSetLogLevel); + + m_console.Commands.AddCommand( + "General", false, "config set", + "config set
", + "Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig); + + m_console.Commands.AddCommand( + "General", false, "config get", + "config get [
] []", + "Synonym for config show", + HandleConfig); + + m_console.Commands.AddCommand( + "General", false, "config show", + "config show [
] []", + "Show config information", + "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine + + "If a section is given but not a field, then all fields in that section are printed.", + HandleConfig); + + m_console.Commands.AddCommand( + "General", false, "config save", + "config save ", + "Save current configuration to a file at the given path", HandleConfig); + + m_console.Commands.AddCommand( + "General", false, "command-script", + "command-script