From a5860ad438885cbf76a36dc7958947355522b8cf Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 21 Jun 2008 03:29:08 +0000 Subject: * Adds Region ban capability to Regions. You access this by going to World->Region/Estate. Then on the Estate tab, at the lower right hand corner, clicking the 'Add' button and picking an avatar. * It only persists across reboots for the mySQL datastore currently. * Currently have stubs in the other datastores. --- OpenSim/Data/MSSQL/MSSQLDataStore.cs | 16 ++++ OpenSim/Data/MySQL/MySQLDataStore.cs | 117 +++++++++++++++++++++++ OpenSim/Data/MySQL/Resources/003_RegionStore.sql | 5 + OpenSim/Data/Null/NullDataStore.cs | 16 ++++ OpenSim/Data/SQLite/SQLiteRegionData.cs | 17 ++++ 5 files changed, 171 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/003_RegionStore.sql (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/MSSQL/MSSQLDataStore.cs b/OpenSim/Data/MSSQL/MSSQLDataStore.cs index c339d62..6bf619a 100644 --- a/OpenSim/Data/MSSQL/MSSQLDataStore.cs +++ b/OpenSim/Data/MSSQL/MSSQLDataStore.cs @@ -492,6 +492,22 @@ namespace OpenSim.Data.MSSQL return landDataForRegion; } + public List LoadRegionBanList(LLUUID regionUUID) + { + List regionbanlist = new List(); + return regionbanlist; + } + + public void AddToRegionBanlist(RegionBanListItem item) + { + + } + + public void RemoveFromRegionBanlist(RegionBanListItem item) + { + + } + public void Commit() { if (m_connection.State != ConnectionState.Open) diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index b0f02f0..d3e7a90 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -50,6 +50,7 @@ namespace OpenSim.Data.MySQL private const string m_terrainSelect = "select * from terrain limit 1"; private const string m_landSelect = "select * from land"; private const string m_landAccessListSelect = "select * from landaccesslist"; + private const string m_regionBanListSelect = "select * from regionban"; /// @@ -65,6 +66,7 @@ namespace OpenSim.Data.MySQL private MySqlDataAdapter m_terrainDataAdapter; private MySqlDataAdapter m_landDataAdapter; private MySqlDataAdapter m_landAccessListDataAdapter; + private MySqlDataAdapter m_regionBanListDataAdapter; private DataTable m_primTable; private DataTable m_shapeTable; @@ -72,6 +74,7 @@ namespace OpenSim.Data.MySQL private DataTable m_terrainTable; private DataTable m_landTable; private DataTable m_landAccessListTable; + private DataTable m_regionBanListTable; // Temporary attribute while this is experimental private bool persistPrimInventories; @@ -121,6 +124,9 @@ namespace OpenSim.Data.MySQL MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, m_connection); m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); + MySqlCommand regionBanListSelectCmd = new MySqlCommand(m_regionBanListSelect, m_connection); + m_regionBanListDataAdapter = new MySqlDataAdapter(regionBanListSelectCmd); + lock (m_dataSet) { @@ -133,6 +139,7 @@ namespace OpenSim.Data.MySQL m_dataSet.Tables.Add(m_shapeTable); SetupShapeCommands(m_shapeDataAdapter, m_connection); m_shapeDataAdapter.Fill(m_shapeTable); + if (persistPrimInventories) { @@ -156,6 +163,11 @@ namespace OpenSim.Data.MySQL m_dataSet.Tables.Add(m_landAccessListTable); setupLandAccessCommands(m_landAccessListDataAdapter, m_connection); m_landAccessListDataAdapter.Fill(m_landAccessListTable); + + m_regionBanListTable = createRegionBanTable(); + m_dataSet.Tables.Add(m_regionBanListTable); + SetupRegionBanCommands(m_regionBanListDataAdapter, m_connection); + m_regionBanListDataAdapter.Fill(m_regionBanListTable); } } /// @@ -577,6 +589,86 @@ namespace OpenSim.Data.MySQL } } + public List LoadRegionBanList(LLUUID regionUUID) + { + List regionbanlist = new List(); + lock (m_dataSet) + { + DataTable regionban = m_regionBanListTable; + string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; + DataRow[] rawbanlist = regionban.Select(searchExp); + foreach (DataRow rawbanrow in rawbanlist) + { + RegionBanListItem rbli = new RegionBanListItem(); + LLUUID tmpvalue = LLUUID.Zero; + + rbli.regionUUID = regionUUID; + + if (Helpers.TryParse((string)rawbanrow["bannedUUID"], out tmpvalue)) + rbli.bannedUUID = tmpvalue; + + rbli.bannedIP = (string)rawbanrow["bannedIp"]; + rbli.bannedIPHostMask = (string)rawbanrow["bannedIpHostMask"]; + regionbanlist.Add(rbli); + } + return regionbanlist; + } + } + + public void AddToRegionBanlist(RegionBanListItem item) + { + lock (m_dataSet) + { + DataTable regionban = m_regionBanListTable; + string searchExp = "regionUUID = '" + item.regionUUID.ToString() + "' AND bannedUUID = '" + item.bannedUUID.ToString() + "'"; + DataRow[] rawbanlist = regionban.Select(searchExp); + if (rawbanlist.Length == 0) + { + DataRow regionbanrow = regionban.NewRow(); + regionbanrow["regionUUID"] = item.regionUUID.ToString(); + regionbanrow["bannedUUID"] = item.bannedUUID.ToString(); + regionbanrow["bannedIp"] = item.bannedIP.ToString(); + regionbanrow["bannedIpHostMask"] = item.bannedIPHostMask.ToString(); + regionban.Rows.Add(regionbanrow); + } + Commit(); + } + } + + public void RemoveFromRegionBanlist(RegionBanListItem item) + { + lock (m_dataSet) + { + DataTable regionban = m_regionBanListTable; + string searchExp = "regionUUID = '" + item.regionUUID.ToString() + "' AND bannedUUID = '" + item.bannedUUID.ToString() + "'"; + DataRow[] rawbanlist = regionban.Select(searchExp); + if (rawbanlist.Length > 0) + { + foreach (DataRow rbli in rawbanlist) + { + regionban.Rows.Remove(rbli); + } + } + Commit(); + } + if (m_connection.State != ConnectionState.Open) + { + m_connection.Open(); + } + + using + ( + MySqlCommand cmd = + new MySqlCommand("delete from regionban where regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID", m_connection) + ) + { + cmd.Parameters.Add(new MySqlParameter("?regionUUID", item.regionUUID.ToString())); + cmd.Parameters.Add(new MySqlParameter("?bannedUUID", item.bannedUUID.ToString())); + cmd.ExecuteNonQuery(); + } + + } + public List LoadLandObjects(LLUUID regionUUID) { List landDataForRegion = new List(); @@ -624,6 +716,7 @@ namespace OpenSim.Data.MySQL m_terrainDataAdapter.Update(m_terrainTable); m_landDataAdapter.Update(m_landTable); m_landAccessListDataAdapter.Update(m_landAccessListTable); + m_regionBanListDataAdapter.Update(m_regionBanListTable); m_dataSet.AcceptChanges(); } @@ -660,6 +753,17 @@ namespace OpenSim.Data.MySQL return terrain; } + private static DataTable createRegionBanTable() + { + DataTable regionban = new DataTable("regionban"); + createCol(regionban, "regionUUID", typeof(String)); + createCol(regionban, "bannedUUID", typeof(String)); + createCol(regionban, "bannedIp", typeof(String)); + createCol(regionban, "bannedIpHostMask", typeof(String)); + return regionban; + + } + private static DataTable createPrimTable() { DataTable prims = new DataTable("prims"); @@ -1553,7 +1657,20 @@ namespace OpenSim.Data.MySQL delete.Connection = conn; da.DeleteCommand = delete; } + private void SetupRegionBanCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("regionban", m_regionBanListTable); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("regionban", "regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID", m_regionBanListTable); + da.UpdateCommand.Connection = conn; + MySqlCommand delete = new MySqlCommand("delete from regionban where regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID"); + delete.Parameters.Add(createMySqlParameter("regionUUID", typeof(String))); + delete.Parameters.Add(createMySqlParameter("bannedUUID", typeof(String))); + delete.Connection = conn; + da.DeleteCommand = delete; + } private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn) { da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]); diff --git a/OpenSim/Data/MySQL/Resources/003_RegionStore.sql b/OpenSim/Data/MySQL/Resources/003_RegionStore.sql new file mode 100644 index 0000000..cb0a614 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/003_RegionStore.sql @@ -0,0 +1,5 @@ +BEGIN; + + CREATE TABLE regionban (regionUUID VARCHAR(36) NOT NULL, bannedUUID VARCHAR(36) NOT NULL, bannedIp VARCHAR(16) NOT NULL, bannedIpHostMask VARCHAR(16) NOT NULL) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='Rev. 1'; + +COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/Null/NullDataStore.cs b/OpenSim/Data/Null/NullDataStore.cs index 487f72e..90cf3a1 100644 --- a/OpenSim/Data/Null/NullDataStore.cs +++ b/OpenSim/Data/Null/NullDataStore.cs @@ -80,6 +80,22 @@ namespace OpenSim.Data.Null return new List(); } + public List LoadRegionBanList(LLUUID regionUUID) + { + List regionbanlist = new List(); + return regionbanlist; + } + + public void AddToRegionBanlist(RegionBanListItem item) + { + + } + + public void RemoveFromRegionBanlist(RegionBanListItem item) + { + + } + public void Shutdown() { } diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index b7086bd..ab4d283 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -1036,6 +1036,23 @@ namespace OpenSim.Data.SQLite return entry; } + + public List LoadRegionBanList(LLUUID regionUUID) + { + List regionbanlist = new List(); + return regionbanlist; + } + + public void AddToRegionBanlist(RegionBanListItem item) + { + + } + + public void RemoveFromRegionBanlist(RegionBanListItem item) + { + + } + private static Array serializeTerrain(double[,] val) { MemoryStream str = new MemoryStream(65536*sizeof (double)); -- cgit v1.1