diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/IProfilesData.cs | 2 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 59 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/Resources/UserProfiles.migrations | 10 | ||||
-rw-r--r-- | OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs | 29 | ||||
-rw-r--r-- | OpenSim/Data/PGSQL/Resources/UserProfiles.migrations | 9 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/Resources/UserProfiles.migrations | 12 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | 84 |
7 files changed, 163 insertions, 42 deletions
diff --git a/OpenSim/Data/IProfilesData.cs b/OpenSim/Data/IProfilesData.cs index 0de7f68..7fb075d 100644 --- a/OpenSim/Data/IProfilesData.cs +++ b/OpenSim/Data/IProfilesData.cs | |||
@@ -48,6 +48,8 @@ namespace OpenSim.Data | |||
48 | bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result); | 48 | bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result); |
49 | bool UpdateAvatarInterests(UserProfileProperties up, ref string result); | 49 | bool UpdateAvatarInterests(UserProfileProperties up, ref string result); |
50 | bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result); | 50 | bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result); |
51 | bool UpdateUserPreferences(ref UserPreferences pref, ref string result); | ||
52 | bool GetUserPreferences(ref UserPreferences pref, ref string result); | ||
51 | bool GetUserAppData(ref UserAppData props, ref string result); | 53 | bool GetUserAppData(ref UserAppData props, ref string result); |
52 | bool SetUserAppData(UserAppData props, ref string result); | 54 | bool SetUserAppData(UserAppData props, ref string result); |
53 | OSDArray GetUserImageAssets(UUID avatarId); | 55 | OSDArray GetUserImageAssets(UUID avatarId); |
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index dc88f94..6ed3b06 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs | |||
@@ -546,6 +546,10 @@ namespace OpenSim.Data.MySQL | |||
546 | reader.Read(); | 546 | reader.Read(); |
547 | notes.Notes = OSD.FromString((string)reader["notes"]); | 547 | notes.Notes = OSD.FromString((string)reader["notes"]); |
548 | } | 548 | } |
549 | else | ||
550 | { | ||
551 | notes.Notes = OSD.FromString(""); | ||
552 | } | ||
549 | } | 553 | } |
550 | } | 554 | } |
551 | } | 555 | } |
@@ -895,7 +899,7 @@ namespace OpenSim.Data.MySQL | |||
895 | } | 899 | } |
896 | 900 | ||
897 | #region User Preferences | 901 | #region User Preferences |
898 | public OSDArray GetUserPreferences(UUID avatarId) | 902 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) |
899 | { | 903 | { |
900 | string query = string.Empty; | 904 | string query = string.Empty; |
901 | 905 | ||
@@ -912,31 +916,32 @@ namespace OpenSim.Data.MySQL | |||
912 | dbcon.Open(); | 916 | dbcon.Open(); |
913 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | 917 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) |
914 | { | 918 | { |
915 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | 919 | cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); |
916 | 920 | ||
917 | using (MySqlDataReader reader = cmd.ExecuteReader()) | 921 | using (MySqlDataReader reader = cmd.ExecuteReader()) |
918 | { | 922 | { |
919 | if(reader.HasRows) | 923 | if(reader.HasRows) |
920 | { | 924 | { |
921 | reader.Read(); | 925 | reader.Read(); |
922 | OSDMap record = new OSDMap(); | 926 | bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); |
923 | 927 | bool.TryParse((string)reader["visible"], out pref.Visible); | |
924 | record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"])); | 928 | pref.EMail = (string)reader["email"]; |
925 | record.Add("visible",OSD.FromString((string)reader["visible"])); | ||
926 | record.Add("email",OSD.FromString((string)reader["email"])); | ||
927 | data.Add(record); | ||
928 | } | 929 | } |
929 | else | 930 | else |
930 | { | 931 | { |
932 | dbcon.Close(); | ||
933 | dbcon.Open(); | ||
934 | |||
935 | query = "INSERT INTO usersettings VALUES "; | ||
936 | query += "(?uuid,'false','false', ?Email)"; | ||
937 | |||
931 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | 938 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) |
932 | { | 939 | { |
933 | query = "INSERT INTO usersettings VALUES "; | ||
934 | query += "(?Id,'false','false', '')"; | ||
935 | 940 | ||
936 | lock(Lock) | 941 | put.Parameters.AddWithValue("?Email", pref.EMail); |
937 | { | 942 | put.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); |
938 | put.ExecuteNonQuery(); | 943 | |
939 | } | 944 | put.ExecuteNonQuery(); |
940 | } | 945 | } |
941 | } | 946 | } |
942 | } | 947 | } |
@@ -947,17 +952,19 @@ namespace OpenSim.Data.MySQL | |||
947 | { | 952 | { |
948 | m_log.DebugFormat("[PROFILES_DATA]" + | 953 | m_log.DebugFormat("[PROFILES_DATA]" + |
949 | ": Get preferences exception {0}", e.Message); | 954 | ": Get preferences exception {0}", e.Message); |
955 | result = e.Message; | ||
956 | return false; | ||
950 | } | 957 | } |
951 | return data; | 958 | return true; |
952 | } | 959 | } |
953 | 960 | ||
954 | public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId ) | 961 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) |
955 | { | 962 | { |
956 | string query = string.Empty; | 963 | string query = string.Empty; |
957 | 964 | ||
958 | query += "UPDATE userpsettings SET "; | 965 | query += "UPDATE usersettings SET "; |
959 | query += "imviaemail=?ImViaEmail, "; | 966 | query += "imviaemail=?ImViaEmail, "; |
960 | query += "visible=?Visible,"; | 967 | query += "visible=?Visible "; |
961 | query += "WHERE useruuid=?uuid"; | 968 | query += "WHERE useruuid=?uuid"; |
962 | 969 | ||
963 | try | 970 | try |
@@ -967,14 +974,11 @@ namespace OpenSim.Data.MySQL | |||
967 | dbcon.Open(); | 974 | dbcon.Open(); |
968 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | 975 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) |
969 | { | 976 | { |
970 | cmd.Parameters.AddWithValue("?ImViaEmail", emailIm.ToString().ToLower ()); | 977 | cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail); |
971 | cmd.Parameters.AddWithValue("?WantText", visible.ToString().ToLower ()); | 978 | cmd.Parameters.AddWithValue("?Visible", pref.Visible); |
972 | cmd.Parameters.AddWithValue("?uuid", avatarId.ToString()); | 979 | cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); |
973 | 980 | ||
974 | lock(Lock) | 981 | cmd.ExecuteNonQuery(); |
975 | { | ||
976 | cmd.ExecuteNonQuery(); | ||
977 | } | ||
978 | } | 982 | } |
979 | } | 983 | } |
980 | } | 984 | } |
@@ -982,6 +986,7 @@ namespace OpenSim.Data.MySQL | |||
982 | { | 986 | { |
983 | m_log.DebugFormat("[PROFILES_DATA]" + | 987 | m_log.DebugFormat("[PROFILES_DATA]" + |
984 | ": AgentInterestsUpdate exception {0}", e.Message); | 988 | ": AgentInterestsUpdate exception {0}", e.Message); |
989 | result = e.Message; | ||
985 | return false; | 990 | return false; |
986 | } | 991 | } |
987 | return true; | 992 | return true; |
diff --git a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations index c29f1ab..bd325da 100644 --- a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations +++ b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations | |||
@@ -81,3 +81,13 @@ CREATE TABLE IF NOT EXISTS `userdata` ( | |||
81 | 81 | ||
82 | commit; | 82 | commit; |
83 | 83 | ||
84 | :VERSION 3 # ------------------------------- | ||
85 | begin; | ||
86 | CREATE TABLE IF NOT EXISTS `usersettings` ( | ||
87 | `useruuid` varchar(36) NOT NULL, | ||
88 | `imviaemail` enum('true','false') NOT NULL, | ||
89 | `visible` enum('true','false') NOT NULL, | ||
90 | `email` varchar(254) NOT NULL, | ||
91 | PRIMARY KEY (`useruuid`) | ||
92 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | ||
93 | commit; \ No newline at end of file | ||
diff --git a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs index f4e41b4..46f57d8 100644 --- a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs +++ b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs | |||
@@ -874,7 +874,7 @@ namespace OpenSim.Data.PGSQL | |||
874 | } | 874 | } |
875 | 875 | ||
876 | #region User Preferences | 876 | #region User Preferences |
877 | public OSDArray GetUserPreferences(UUID avatarId) | 877 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) |
878 | { | 878 | { |
879 | string query = string.Empty; | 879 | string query = string.Empty; |
880 | 880 | ||
@@ -891,19 +891,16 @@ namespace OpenSim.Data.PGSQL | |||
891 | dbcon.Open(); | 891 | dbcon.Open(); |
892 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | 892 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) |
893 | { | 893 | { |
894 | cmd.Parameters.AddWithValue("Id", avatarId.ToString()); | 894 | cmd.Parameters.AddWithValue("Id", pref.UserId.ToString()); |
895 | 895 | ||
896 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | 896 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
897 | { | 897 | { |
898 | if(reader.HasRows) | 898 | if(reader.HasRows) |
899 | { | 899 | { |
900 | reader.Read(); | 900 | reader.Read(); |
901 | OSDMap record = new OSDMap(); | 901 | bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); |
902 | 902 | bool.TryParse((string)reader["visible"], out pref.Visible); | |
903 | record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"])); | 903 | pref.EMail = (string)reader["email"]; |
904 | record.Add("visible",OSD.FromString((string)reader["visible"])); | ||
905 | record.Add("email",OSD.FromString((string)reader["email"])); | ||
906 | data.Add(record); | ||
907 | } | 904 | } |
908 | else | 905 | else |
909 | { | 906 | { |
@@ -926,15 +923,16 @@ namespace OpenSim.Data.PGSQL | |||
926 | { | 923 | { |
927 | m_log.DebugFormat("[PROFILES_DATA]" + | 924 | m_log.DebugFormat("[PROFILES_DATA]" + |
928 | ": Get preferences exception {0}", e.Message); | 925 | ": Get preferences exception {0}", e.Message); |
926 | result = e.Message; | ||
929 | } | 927 | } |
930 | return data; | 928 | return true; |
931 | } | 929 | } |
932 | 930 | ||
933 | public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId ) | 931 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) |
934 | { | 932 | { |
935 | string query = string.Empty; | 933 | string query = string.Empty; |
936 | 934 | ||
937 | query += "UPDATE userpsettings SET "; | 935 | query += "UPDATE usersettings SET "; |
938 | query += "imviaemail=:ImViaEmail, "; | 936 | query += "imviaemail=:ImViaEmail, "; |
939 | query += "visible=:Visible,"; | 937 | query += "visible=:Visible,"; |
940 | query += "WHERE useruuid=:uuid"; | 938 | query += "WHERE useruuid=:uuid"; |
@@ -946,9 +944,9 @@ namespace OpenSim.Data.PGSQL | |||
946 | dbcon.Open(); | 944 | dbcon.Open(); |
947 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) | 945 | using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) |
948 | { | 946 | { |
949 | cmd.Parameters.AddWithValue("ImViaEmail", emailIm.ToString().ToLower ()); | 947 | cmd.Parameters.AddWithValue("ImViaEmail", pref.IMViaEmail.ToString().ToLower ()); |
950 | cmd.Parameters.AddWithValue("WantText", visible.ToString().ToLower ()); | 948 | cmd.Parameters.AddWithValue("Visible", pref.Visible.ToString().ToLower ()); |
951 | cmd.Parameters.AddWithValue("uuid", avatarId.ToString()); | 949 | cmd.Parameters.AddWithValue("uuid", pref.UserId.ToString()); |
952 | 950 | ||
953 | lock(Lock) | 951 | lock(Lock) |
954 | { | 952 | { |
@@ -961,6 +959,7 @@ namespace OpenSim.Data.PGSQL | |||
961 | { | 959 | { |
962 | m_log.DebugFormat("[PROFILES_DATA]" + | 960 | m_log.DebugFormat("[PROFILES_DATA]" + |
963 | ": AgentInterestsUpdate exception {0}", e.Message); | 961 | ": AgentInterestsUpdate exception {0}", e.Message); |
962 | result = e.Message; | ||
964 | return false; | 963 | return false; |
965 | } | 964 | } |
966 | return true; | 965 | return true; |
diff --git a/OpenSim/Data/PGSQL/Resources/UserProfiles.migrations b/OpenSim/Data/PGSQL/Resources/UserProfiles.migrations index f23c870..4fcaa8e 100644 --- a/OpenSim/Data/PGSQL/Resources/UserProfiles.migrations +++ b/OpenSim/Data/PGSQL/Resources/UserProfiles.migrations | |||
@@ -81,3 +81,12 @@ CREATE TABLE userdata ( | |||
81 | 81 | ||
82 | commit; | 82 | commit; |
83 | 83 | ||
84 | :VERSION 3 # ------------------------------- | ||
85 | begin; | ||
86 | CREATE TABLE usersettings ( | ||
87 | "useruuid" char(36) NOT NULL, | ||
88 | "imviaemail" bytea NOT NULL, | ||
89 | "visible" bytea NOT NULL, | ||
90 | PRIMARY KEY ("useruuid") | ||
91 | ); | ||
92 | commit; \ No newline at end of file | ||
diff --git a/OpenSim/Data/SQLite/Resources/UserProfiles.migrations b/OpenSim/Data/SQLite/Resources/UserProfiles.migrations index 16581f6..86434e8 100644 --- a/OpenSim/Data/SQLite/Resources/UserProfiles.migrations +++ b/OpenSim/Data/SQLite/Resources/UserProfiles.migrations | |||
@@ -88,3 +88,15 @@ CREATE TABLE IF NOT EXISTS userdata ( | |||
88 | 88 | ||
89 | commit; | 89 | commit; |
90 | 90 | ||
91 | |||
92 | :VERSION 3 # ------------------------------- | ||
93 | |||
94 | begin; | ||
95 | CREATE TABLE IF NOT EXISTS usersettings ( | ||
96 | useruuid char(36) NOT NULL, | ||
97 | imviaemail binary(1) NOT NULL, | ||
98 | visible binary(1) NOT NULL, | ||
99 | email varchar(254) NOT NULL, | ||
100 | PRIMARY KEY (useruuid) | ||
101 | ) | ||
102 | commit; \ No newline at end of file | ||
diff --git a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs index 8c1bcd4..90d45e9 100644 --- a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | |||
@@ -747,6 +747,90 @@ namespace OpenSim.Data.SQLite | |||
747 | } | 747 | } |
748 | return true; | 748 | return true; |
749 | } | 749 | } |
750 | |||
751 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) | ||
752 | { | ||
753 | string query = string.Empty; | ||
754 | |||
755 | query += "UPDATE usersettings SET "; | ||
756 | query += "imviaemail=:ImViaEmail, "; | ||
757 | query += "visible=:Visible "; | ||
758 | query += "WHERE useruuid=:uuid"; | ||
759 | |||
760 | try | ||
761 | { | ||
762 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
763 | { | ||
764 | cmd.CommandText = query; | ||
765 | cmd.Parameters.AddWithValue(":ImViaEmail", pref.IMViaEmail); | ||
766 | cmd.Parameters.AddWithValue(":Visible", pref.Visible); | ||
767 | cmd.Parameters.AddWithValue(":uuid", pref.UserId.ToString()); | ||
768 | |||
769 | cmd.ExecuteNonQuery(); | ||
770 | } | ||
771 | } | ||
772 | catch (Exception e) | ||
773 | { | ||
774 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
775 | ": AgentInterestsUpdate exception {0}", e.Message); | ||
776 | result = e.Message; | ||
777 | return false; | ||
778 | } | ||
779 | return true; | ||
780 | } | ||
781 | |||
782 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) | ||
783 | { | ||
784 | IDataReader reader = null; | ||
785 | string query = string.Empty; | ||
786 | |||
787 | query += "SELECT imviaemail,visible,email FROM "; | ||
788 | query += "usersettings WHERE "; | ||
789 | query += "useruuid = :Id"; | ||
790 | |||
791 | OSDArray data = new OSDArray(); | ||
792 | |||
793 | try | ||
794 | { | ||
795 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
796 | { | ||
797 | cmd.CommandText = query; | ||
798 | cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); | ||
799 | |||
800 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
801 | { | ||
802 | if(reader.Read()) | ||
803 | { | ||
804 | bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); | ||
805 | bool.TryParse((string)reader["visible"], out pref.Visible); | ||
806 | pref.EMail = (string)reader["email"]; | ||
807 | } | ||
808 | else | ||
809 | { | ||
810 | query = "INSERT INTO usersettings VALUES "; | ||
811 | query += "(:Id,'false','false', :Email)"; | ||
812 | |||
813 | using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) | ||
814 | { | ||
815 | put.Parameters.AddWithValue(":Id", pref.UserId.ToString()); | ||
816 | put.Parameters.AddWithValue(":Email", pref.EMail); | ||
817 | put.ExecuteNonQuery(); | ||
818 | |||
819 | } | ||
820 | } | ||
821 | } | ||
822 | } | ||
823 | } | ||
824 | catch (Exception e) | ||
825 | { | ||
826 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
827 | ": Get preferences exception {0}", e.Message); | ||
828 | result = e.Message; | ||
829 | return false; | ||
830 | } | ||
831 | return true; | ||
832 | } | ||
833 | |||
750 | public bool GetUserAppData(ref UserAppData props, ref string result) | 834 | public bool GetUserAppData(ref UserAppData props, ref string result) |
751 | { | 835 | { |
752 | IDataReader reader = null; | 836 | IDataReader reader = null; |