aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
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/MySQL
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/MySQL')
-rw-r--r--OpenSim/Data/MySQL/MySQLDataStore.cs117
-rw-r--r--OpenSim/Data/MySQL/Resources/003_RegionStore.sql5
2 files changed, 122 insertions, 0 deletions
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