aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorTeravus Ovares2008-06-21 03:29:08 +0000
committerTeravus Ovares2008-06-21 03:29:08 +0000
commita5860ad438885cbf76a36dc7958947355522b8cf (patch)
treeb392682ca7bf79e7fae18c16271980a9eead28bf /OpenSim/Data
parentlots of futzing with nhibernate to make it more efficient. I (diff)
downloadopensim-SC_OLD-a5860ad438885cbf76a36dc7958947355522b8cf.zip
opensim-SC_OLD-a5860ad438885cbf76a36dc7958947355522b8cf.tar.gz
opensim-SC_OLD-a5860ad438885cbf76a36dc7958947355522b8cf.tar.bz2
opensim-SC_OLD-a5860ad438885cbf76a36dc7958947355522b8cf.tar.xz
* 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.
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLDataStore.cs16
-rw-r--r--OpenSim/Data/MySQL/MySQLDataStore.cs117
-rw-r--r--OpenSim/Data/MySQL/Resources/003_RegionStore.sql5
-rw-r--r--OpenSim/Data/Null/NullDataStore.cs16
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs17
5 files changed, 171 insertions, 0 deletions
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
492 return landDataForRegion; 492 return landDataForRegion;
493 } 493 }
494 494
495 public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID)
496 {
497 List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>();
498 return regionbanlist;
499 }
500
501 public void AddToRegionBanlist(RegionBanListItem item)
502 {
503
504 }
505
506 public void RemoveFromRegionBanlist(RegionBanListItem item)
507 {
508
509 }
510
495 public void Commit() 511 public void Commit()
496 { 512 {
497 if (m_connection.State != ConnectionState.Open) 513 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
50 private const string m_terrainSelect = "select * from terrain limit 1"; 50 private const string m_terrainSelect = "select * from terrain limit 1";
51 private const string m_landSelect = "select * from land"; 51 private const string m_landSelect = "select * from land";
52 private const string m_landAccessListSelect = "select * from landaccesslist"; 52 private const string m_landAccessListSelect = "select * from landaccesslist";
53 private const string m_regionBanListSelect = "select * from regionban";
53 54
54 55
55 /// <summary> 56 /// <summary>
@@ -65,6 +66,7 @@ namespace OpenSim.Data.MySQL
65 private MySqlDataAdapter m_terrainDataAdapter; 66 private MySqlDataAdapter m_terrainDataAdapter;
66 private MySqlDataAdapter m_landDataAdapter; 67 private MySqlDataAdapter m_landDataAdapter;
67 private MySqlDataAdapter m_landAccessListDataAdapter; 68 private MySqlDataAdapter m_landAccessListDataAdapter;
69 private MySqlDataAdapter m_regionBanListDataAdapter;
68 70
69 private DataTable m_primTable; 71 private DataTable m_primTable;
70 private DataTable m_shapeTable; 72 private DataTable m_shapeTable;
@@ -72,6 +74,7 @@ namespace OpenSim.Data.MySQL
72 private DataTable m_terrainTable; 74 private DataTable m_terrainTable;
73 private DataTable m_landTable; 75 private DataTable m_landTable;
74 private DataTable m_landAccessListTable; 76 private DataTable m_landAccessListTable;
77 private DataTable m_regionBanListTable;
75 78
76 // Temporary attribute while this is experimental 79 // Temporary attribute while this is experimental
77 private bool persistPrimInventories; 80 private bool persistPrimInventories;
@@ -121,6 +124,9 @@ namespace OpenSim.Data.MySQL
121 MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, m_connection); 124 MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, m_connection);
122 m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); 125 m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd);
123 126
127 MySqlCommand regionBanListSelectCmd = new MySqlCommand(m_regionBanListSelect, m_connection);
128 m_regionBanListDataAdapter = new MySqlDataAdapter(regionBanListSelectCmd);
129
124 130
125 lock (m_dataSet) 131 lock (m_dataSet)
126 { 132 {
@@ -133,6 +139,7 @@ namespace OpenSim.Data.MySQL
133 m_dataSet.Tables.Add(m_shapeTable); 139 m_dataSet.Tables.Add(m_shapeTable);
134 SetupShapeCommands(m_shapeDataAdapter, m_connection); 140 SetupShapeCommands(m_shapeDataAdapter, m_connection);
135 m_shapeDataAdapter.Fill(m_shapeTable); 141 m_shapeDataAdapter.Fill(m_shapeTable);
142
136 143
137 if (persistPrimInventories) 144 if (persistPrimInventories)
138 { 145 {
@@ -156,6 +163,11 @@ namespace OpenSim.Data.MySQL
156 m_dataSet.Tables.Add(m_landAccessListTable); 163 m_dataSet.Tables.Add(m_landAccessListTable);
157 setupLandAccessCommands(m_landAccessListDataAdapter, m_connection); 164 setupLandAccessCommands(m_landAccessListDataAdapter, m_connection);
158 m_landAccessListDataAdapter.Fill(m_landAccessListTable); 165 m_landAccessListDataAdapter.Fill(m_landAccessListTable);
166
167 m_regionBanListTable = createRegionBanTable();
168 m_dataSet.Tables.Add(m_regionBanListTable);
169 SetupRegionBanCommands(m_regionBanListDataAdapter, m_connection);
170 m_regionBanListDataAdapter.Fill(m_regionBanListTable);
159 } 171 }
160 } 172 }
161 /// <summary> 173 /// <summary>
@@ -577,6 +589,86 @@ namespace OpenSim.Data.MySQL
577 } 589 }
578 } 590 }
579 591
592 public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID)
593 {
594 List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>();
595 lock (m_dataSet)
596 {
597 DataTable regionban = m_regionBanListTable;
598 string searchExp = "regionUUID = '" + regionUUID.ToString() + "'";
599 DataRow[] rawbanlist = regionban.Select(searchExp);
600 foreach (DataRow rawbanrow in rawbanlist)
601 {
602 RegionBanListItem rbli = new RegionBanListItem();
603 LLUUID tmpvalue = LLUUID.Zero;
604
605 rbli.regionUUID = regionUUID;
606
607 if (Helpers.TryParse((string)rawbanrow["bannedUUID"], out tmpvalue))
608 rbli.bannedUUID = tmpvalue;
609
610 rbli.bannedIP = (string)rawbanrow["bannedIp"];
611 rbli.bannedIPHostMask = (string)rawbanrow["bannedIpHostMask"];
612 regionbanlist.Add(rbli);
613 }
614 return regionbanlist;
615 }
616 }
617
618 public void AddToRegionBanlist(RegionBanListItem item)
619 {
620 lock (m_dataSet)
621 {
622 DataTable regionban = m_regionBanListTable;
623 string searchExp = "regionUUID = '" + item.regionUUID.ToString() + "' AND bannedUUID = '" + item.bannedUUID.ToString() + "'";
624 DataRow[] rawbanlist = regionban.Select(searchExp);
625 if (rawbanlist.Length == 0)
626 {
627 DataRow regionbanrow = regionban.NewRow();
628 regionbanrow["regionUUID"] = item.regionUUID.ToString();
629 regionbanrow["bannedUUID"] = item.bannedUUID.ToString();
630 regionbanrow["bannedIp"] = item.bannedIP.ToString();
631 regionbanrow["bannedIpHostMask"] = item.bannedIPHostMask.ToString();
632 regionban.Rows.Add(regionbanrow);
633 }
634 Commit();
635 }
636 }
637
638 public void RemoveFromRegionBanlist(RegionBanListItem item)
639 {
640 lock (m_dataSet)
641 {
642 DataTable regionban = m_regionBanListTable;
643 string searchExp = "regionUUID = '" + item.regionUUID.ToString() + "' AND bannedUUID = '" + item.bannedUUID.ToString() + "'";
644 DataRow[] rawbanlist = regionban.Select(searchExp);
645 if (rawbanlist.Length > 0)
646 {
647 foreach (DataRow rbli in rawbanlist)
648 {
649 regionban.Rows.Remove(rbli);
650 }
651 }
652 Commit();
653 }
654 if (m_connection.State != ConnectionState.Open)
655 {
656 m_connection.Open();
657 }
658
659 using
660 (
661 MySqlCommand cmd =
662 new MySqlCommand("delete from regionban where regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID", m_connection)
663 )
664 {
665 cmd.Parameters.Add(new MySqlParameter("?regionUUID", item.regionUUID.ToString()));
666 cmd.Parameters.Add(new MySqlParameter("?bannedUUID", item.bannedUUID.ToString()));
667 cmd.ExecuteNonQuery();
668 }
669
670 }
671
580 public List<LandData> LoadLandObjects(LLUUID regionUUID) 672 public List<LandData> LoadLandObjects(LLUUID regionUUID)
581 { 673 {
582 List<LandData> landDataForRegion = new List<LandData>(); 674 List<LandData> landDataForRegion = new List<LandData>();
@@ -624,6 +716,7 @@ namespace OpenSim.Data.MySQL
624 m_terrainDataAdapter.Update(m_terrainTable); 716 m_terrainDataAdapter.Update(m_terrainTable);
625 m_landDataAdapter.Update(m_landTable); 717 m_landDataAdapter.Update(m_landTable);
626 m_landAccessListDataAdapter.Update(m_landAccessListTable); 718 m_landAccessListDataAdapter.Update(m_landAccessListTable);
719 m_regionBanListDataAdapter.Update(m_regionBanListTable);
627 720
628 m_dataSet.AcceptChanges(); 721 m_dataSet.AcceptChanges();
629 } 722 }
@@ -660,6 +753,17 @@ namespace OpenSim.Data.MySQL
660 return terrain; 753 return terrain;
661 } 754 }
662 755
756 private static DataTable createRegionBanTable()
757 {
758 DataTable regionban = new DataTable("regionban");
759 createCol(regionban, "regionUUID", typeof(String));
760 createCol(regionban, "bannedUUID", typeof(String));
761 createCol(regionban, "bannedIp", typeof(String));
762 createCol(regionban, "bannedIpHostMask", typeof(String));
763 return regionban;
764
765 }
766
663 private static DataTable createPrimTable() 767 private static DataTable createPrimTable()
664 { 768 {
665 DataTable prims = new DataTable("prims"); 769 DataTable prims = new DataTable("prims");
@@ -1553,7 +1657,20 @@ namespace OpenSim.Data.MySQL
1553 delete.Connection = conn; 1657 delete.Connection = conn;
1554 da.DeleteCommand = delete; 1658 da.DeleteCommand = delete;
1555 } 1659 }
1660 private void SetupRegionBanCommands(MySqlDataAdapter da, MySqlConnection conn)
1661 {
1662 da.InsertCommand = createInsertCommand("regionban", m_regionBanListTable);
1663 da.InsertCommand.Connection = conn;
1664
1665 da.UpdateCommand = createUpdateCommand("regionban", "regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID", m_regionBanListTable);
1666 da.UpdateCommand.Connection = conn;
1556 1667
1668 MySqlCommand delete = new MySqlCommand("delete from regionban where regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID");
1669 delete.Parameters.Add(createMySqlParameter("regionUUID", typeof(String)));
1670 delete.Parameters.Add(createMySqlParameter("bannedUUID", typeof(String)));
1671 delete.Connection = conn;
1672 da.DeleteCommand = delete;
1673 }
1557 private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn) 1674 private void SetupTerrainCommands(MySqlDataAdapter da, MySqlConnection conn)
1558 { 1675 {
1559 da.InsertCommand = createInsertCommand("terrain", m_dataSet.Tables["terrain"]); 1676 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 @@
1BEGIN;
2
3 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';
4
5COMMIT; \ 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
80 return new List<LandData>(); 80 return new List<LandData>();
81 } 81 }
82 82
83 public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID)
84 {
85 List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>();
86 return regionbanlist;
87 }
88
89 public void AddToRegionBanlist(RegionBanListItem item)
90 {
91
92 }
93
94 public void RemoveFromRegionBanlist(RegionBanListItem item)
95 {
96
97 }
98
83 public void Shutdown() 99 public void Shutdown()
84 { 100 {
85 } 101 }
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
1036 return entry; 1036 return entry;
1037 } 1037 }
1038 1038
1039
1040 public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID)
1041 {
1042 List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>();
1043 return regionbanlist;
1044 }
1045
1046 public void AddToRegionBanlist(RegionBanListItem item)
1047 {
1048
1049 }
1050
1051 public void RemoveFromRegionBanlist(RegionBanListItem item)
1052 {
1053
1054 }
1055
1039 private static Array serializeTerrain(double[,] val) 1056 private static Array serializeTerrain(double[,] val)
1040 { 1057 {
1041 MemoryStream str = new MemoryStream(65536*sizeof (double)); 1058 MemoryStream str = new MemoryStream(65536*sizeof (double));