diff options
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLManager.cs | 51 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserData.cs | 25 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/Resources/005_UserStore.sql | 5 |
3 files changed, 81 insertions, 0 deletions
diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 6ad6609..3a62ec2 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Collections; | ||
30 | using System.Data; | 31 | using System.Data; |
31 | using System.IO; | 32 | using System.IO; |
32 | using System.Reflection; | 33 | using System.Reflection; |
@@ -660,6 +661,26 @@ namespace OpenSim.Data.MySQL | |||
660 | } | 661 | } |
661 | 662 | ||
662 | 663 | ||
664 | // Read attachment list from data reader | ||
665 | public Hashtable readAttachments(IDataReader r) | ||
666 | { | ||
667 | Hashtable ret = new Hashtable(); | ||
668 | |||
669 | while(r.Read()) | ||
670 | { | ||
671 | int attachpoint = Convert.ToInt32(r["attachpoint"]); | ||
672 | if(ret.ContainsKey(attachpoint)) | ||
673 | continue; | ||
674 | Hashtable item = new Hashtable(); | ||
675 | item.Add("item", r["item"].ToString()); | ||
676 | item.Add("asset", r["asset"].ToString()); | ||
677 | |||
678 | ret.Add(attachpoint, item); | ||
679 | } | ||
680 | |||
681 | return ret; | ||
682 | } | ||
683 | |||
663 | /// <summary> | 684 | /// <summary> |
664 | /// Inserts a new row into the log database | 685 | /// Inserts a new row into the log database |
665 | /// </summary> | 686 | /// </summary> |
@@ -1176,5 +1197,35 @@ namespace OpenSim.Data.MySQL | |||
1176 | 1197 | ||
1177 | } | 1198 | } |
1178 | 1199 | ||
1200 | public void writeAttachments(LLUUID agentID, Hashtable data) | ||
1201 | { | ||
1202 | string sql = "delete from avatarattachments where UUID = ?uuid"; | ||
1203 | |||
1204 | MySqlCommand cmd = (MySqlCommand) dbcon.CreateCommand(); | ||
1205 | cmd.CommandText = sql; | ||
1206 | cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); | ||
1207 | |||
1208 | cmd.ExecuteNonQuery(); | ||
1209 | |||
1210 | sql = "insert into avatarattachments (UUID, attachpoint, item, asset) values (?uuid, ?attchpoint, ?item, ?asset)"; | ||
1211 | |||
1212 | cmd = (MySqlCommand) dbcon.CreateCommand(); | ||
1213 | cmd.CommandText = sql; | ||
1214 | |||
1215 | foreach(DictionaryEntry e in data) | ||
1216 | { | ||
1217 | int attachpoint = Convert.ToInt32(e.Key); | ||
1218 | |||
1219 | Hashtable item = (Hashtable)e.Value; | ||
1220 | |||
1221 | cmd.Parameters.Clear(); | ||
1222 | cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); | ||
1223 | cmd.Parameters.AddWithValue("?attachpoint", attachpoint); | ||
1224 | cmd.Parameters.AddWithValue("?item", item["item"]); | ||
1225 | cmd.Parameters.AddWithValue("?asset", item["asset"]); | ||
1226 | |||
1227 | cmd.ExecuteNonQuery(); | ||
1228 | } | ||
1229 | } | ||
1179 | } | 1230 | } |
1180 | } | 1231 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index f77d947..627bc0c 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.Data; | 31 | using System.Data; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -34,6 +35,7 @@ using libsecondlife; | |||
34 | using log4net; | 35 | using log4net; |
35 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
36 | using OpenSim.Data.Base; | 37 | using OpenSim.Data.Base; |
38 | using MySql.Data.MySqlClient; | ||
37 | 39 | ||
38 | namespace OpenSim.Data.MySQL | 40 | namespace OpenSim.Data.MySQL |
39 | { | 41 | { |
@@ -737,6 +739,8 @@ namespace OpenSim.Data.MySQL | |||
737 | reader.Dispose(); | 739 | reader.Dispose(); |
738 | result.Dispose(); | 740 | result.Dispose(); |
739 | 741 | ||
742 | appearance.SetAttachments(GetUserAttachments(user)); | ||
743 | |||
740 | return appearance; | 744 | return appearance; |
741 | } | 745 | } |
742 | } | 746 | } |
@@ -762,6 +766,8 @@ namespace OpenSim.Data.MySQL | |||
762 | { | 766 | { |
763 | appearance.Owner = user; | 767 | appearance.Owner = user; |
764 | database.insertAppearanceRow(appearance); | 768 | database.insertAppearanceRow(appearance); |
769 | |||
770 | UpdateUserAttachments(user, appearance.GetAttachments()); | ||
765 | } | 771 | } |
766 | } | 772 | } |
767 | catch (Exception e) | 773 | catch (Exception e) |
@@ -818,5 +824,24 @@ namespace OpenSim.Data.MySQL | |||
818 | { | 824 | { |
819 | get {return "0.1";} | 825 | get {return "0.1";} |
820 | } | 826 | } |
827 | |||
828 | public Hashtable GetUserAttachments(LLUUID agentID) | ||
829 | { | ||
830 | MySqlCommand cmd = (MySqlCommand) (database.Connection.CreateCommand()); | ||
831 | cmd.CommandText = "select attachpoint, item, asset from avatarattachments where UUID = ?uuid"; | ||
832 | cmd.Parameters.AddWithValue("?uuid", agentID.ToString()); | ||
833 | |||
834 | IDataReader r = cmd.ExecuteReader(); | ||
835 | |||
836 | return database.readAttachments(r); | ||
837 | } | ||
838 | |||
839 | public void UpdateUserAttachments(LLUUID agentID, Hashtable data) | ||
840 | { | ||
841 | if(data == null) | ||
842 | return; | ||
843 | |||
844 | database.writeAttachments(agentID, data); | ||
845 | } | ||
821 | } | 846 | } |
822 | } | 847 | } |
diff --git a/OpenSim/Data/MySQL/Resources/005_UserStore.sql b/OpenSim/Data/MySQL/Resources/005_UserStore.sql new file mode 100644 index 0000000..55896bc --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/005_UserStore.sql | |||
@@ -0,0 +1,5 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | CREATE TABLE `avatarattachments` (`UUID` char(36) NOT NULL, `attachpoint` int(11) NOT NULL, `item` char(36) NOT NULL, `asset` char(36) NOT NULL) ENGINE=InnoDB; | ||
4 | |||
5 | COMMIT; | ||