From 62a2d7836fb36f66a0e42b20f4596e517eb52354 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Dec 2013 02:27:40 +0000 Subject: Ignore X and Y body rotations when sent by mouse look. Fixes http://opensimulator.org/mantis/view.php?id=3274 When not in mouselook, avatar only sends rotations around the Z plane (since that's the only way an avatar can rotate). However, in mouselook it also sends X and Y information. But sending X and Y in terse updates causes issues with wrong camera movement in mouselook. So strip out X and Y components for now. If this is an issue, then could strip out before sending avatar terse update, though this generates more cpu work. Thanks to mirceakitsune for suggesting an initial fix --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1dc7e20..dae20a5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1648,12 +1648,24 @@ namespace OpenSim.Region.Framework.Scenes if (AllowMovement && !SitGround) { - Quaternion bodyRotation = agentData.BodyRotation; +// m_log.DebugFormat("[SCENE PRESENCE]: Initial body rotation {0} for {1}", agentData.BodyRotation, Name); + bool update_rotation = false; - if (bodyRotation != Rotation) + // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis + // it rotates around. + // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted + // excessive up and down movements of the camera when looking up and down. + // See http://opensimulator.org/mantis/view.php?id=3274 + // This does not affect head movement, since this is controlled entirely by camera movement rather than + // body rotation. It does not affect sitting avatar since it's the sitting part rotation that takes + // effect, not the avatar rotation. + // However, if we do need to store X and Y rotations in the future, another solution needs to be found + // for the mouselook bug. Possibly, one could strip out X and Y rotations before sending the avatar + // update messages. + if (agentData.BodyRotation.Z != Rotation.Z || agentData.BodyRotation.W != Rotation.W) { - Rotation = bodyRotation; + Rotation = new Quaternion(0, 0, agentData.BodyRotation.Z, agentData.BodyRotation.W); update_rotation = true; } -- cgit v1.1 From 17b32b764acd815400d9eb903aaec6dcebd60ac7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Dec 2013 02:10:46 +0000 Subject: Fix regression where mouse look flight direction no longer worked by zeroing x/y rot before sending agent updates, instead of before any agent update processing It turns out that the x/y rot data in mouselook is needed to implement this and to push the avatar against the ground if walking in mouselook. Doing this in the terse send so that we preserve mouselook rotation information --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 25 +++++++++++++++++++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 15 ++----------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index c1aae3f..a04ded5 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5091,7 +5091,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP // acceleration = new Vector3(1, 0, 0); angularVelocity = presence.AngularVelocity; + + // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis + // it rotates around. + // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted + // excessive up and down movements of the camera when looking up and down. + // See http://opensimulator.org/mantis/view.php?id=3274 + // This does not affect head movement, since this is controlled entirely by camera movement rather than + // body rotation. It does not affect sitting avatar since it's the sitting part rotation that takes + // effect, not the avatar rotation. rotation = presence.Rotation; + rotation.X = 0; + rotation.Y = 0; if (sendTexture) textureEntry = presence.Appearance.Texture.GetBytes(); @@ -5207,7 +5218,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP data.OffsetPosition.ToBytes(objectData, 16); // data.Velocity.ToBytes(objectData, 28); // data.Acceleration.ToBytes(objectData, 40); - data.Rotation.ToBytes(objectData, 52); + + // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis + // it rotates around. + // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted + // excessive up and down movements of the camera when looking up and down. + // See http://opensimulator.org/mantis/view.php?id=3274 + // This does not affect head movement, since this is controlled entirely by camera movement rather than + // body rotation. It does not affect sitting avatar since it's the sitting part rotation that takes + // effect, not the avatar rotation. + Quaternion rot = data.Rotation; + rot.X = 0; + rot.Y = 0; + rot.ToBytes(objectData, 52); //data.AngularVelocity.ToBytes(objectData, 64); ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index dae20a5..7ed3a4b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1652,20 +1652,9 @@ namespace OpenSim.Region.Framework.Scenes bool update_rotation = false; - // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis - // it rotates around. - // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted - // excessive up and down movements of the camera when looking up and down. - // See http://opensimulator.org/mantis/view.php?id=3274 - // This does not affect head movement, since this is controlled entirely by camera movement rather than - // body rotation. It does not affect sitting avatar since it's the sitting part rotation that takes - // effect, not the avatar rotation. - // However, if we do need to store X and Y rotations in the future, another solution needs to be found - // for the mouselook bug. Possibly, one could strip out X and Y rotations before sending the avatar - // update messages. - if (agentData.BodyRotation.Z != Rotation.Z || agentData.BodyRotation.W != Rotation.W) + if (agentData.BodyRotation != Rotation) { - Rotation = new Quaternion(0, 0, agentData.BodyRotation.Z, agentData.BodyRotation.W); + Rotation = agentData.BodyRotation; update_rotation = true; } -- cgit v1.1 From 16aaba77d49baad0dc581ffbf69d71181b9be70f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 6 Dec 2013 00:30:44 +0000 Subject: Properly set InventoryType.Snapshot when a snapshot is uploaded Resolves http://opensimulator.org/mantis/view.php?id=6857 This prevents the inventory service complaining later about an attempt to change an invariant --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 1d4c7f0..66d2138 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -501,6 +501,10 @@ namespace OpenSim.Region.ClientStack.Linden inType = 1; assType = 1; } + else if (inventoryType == "snapshot") + { + inType = (sbyte)InventoryType.Snapshot; + } else if (inventoryType == "animation") { inType = 19; -- cgit v1.1 From bb4f4d9480df4c17ea31288c069993305c7e1582 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 6 Dec 2013 00:38:18 +0000 Subject: minor: Use enums for setting inv/asset types on data upload rather than magic numbers --- .../ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 66d2138..a4fe81c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -498,8 +498,8 @@ namespace OpenSim.Region.ClientStack.Linden if (inventoryType == "sound") { - inType = 1; - assType = 1; + inType = (sbyte)InventoryType.Sound; + assType = (sbyte)AssetType.Sound; } else if (inventoryType == "snapshot") { @@ -507,19 +507,19 @@ namespace OpenSim.Region.ClientStack.Linden } else if (inventoryType == "animation") { - inType = 19; - assType = 20; + inType = (sbyte)InventoryType.Animation; + assType = (sbyte)AssetType.Animation; } else if (inventoryType == "wearable") { - inType = 18; + inType = (sbyte)InventoryType.Wearable; switch (assetType) { case "bodypart": - assType = 13; + assType = (sbyte)AssetType.Bodypart; break; case "clothing": - assType = 5; + assType = (sbyte)AssetType.Clothing; break; } } -- cgit v1.1 From 9b76a46df0b93e57a1bcb2cfa28248998b8ed841 Mon Sep 17 00:00:00 2001 From: Fernando Oliveira Date: Thu, 28 Nov 2013 00:10:36 -0200 Subject: Reversing back to the row["ColumnName"] case field name. http://opensimulator.org/mantis/view.php?id=6868 --- OpenSim/Data/PGSQL/PGSQLRegionData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Data/PGSQL/PGSQLRegionData.cs b/OpenSim/Data/PGSQL/PGSQLRegionData.cs index f3e4064..b3076f0 100644 --- a/OpenSim/Data/PGSQL/PGSQLRegionData.cs +++ b/OpenSim/Data/PGSQL/PGSQLRegionData.cs @@ -206,7 +206,7 @@ namespace OpenSim.Data.PGSQL DataTable schemaTable = result.GetSchemaTable(); foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["column_name"].ToString()); + m_ColumnNames.Add(row["ColumnName"].ToString()); } foreach (string s in m_ColumnNames) -- cgit v1.1 From 823a175f07297e7a8a973ddf0223e60d3ea7c933 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 5 Dec 2013 20:06:04 -0500 Subject: Stop writing partner id to record when updating profile data. This should be changed only by admin in backend. --- OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index 4c6c8e3..dc88f94 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -736,7 +736,6 @@ namespace OpenSim.Data.MySQL string query = string.Empty; query += "UPDATE userprofile SET "; - query += "profilePartner=?profilePartner, "; query += "profileURL=?profileURL, "; query += "profileImage=?image, "; query += "profileAboutText=?abouttext,"; @@ -752,7 +751,6 @@ namespace OpenSim.Data.MySQL using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) { cmd.Parameters.AddWithValue("?profileURL", props.WebUrl); - cmd.Parameters.AddWithValue("?profilePartner", props.PartnerId.ToString()); cmd.Parameters.AddWithValue("?image", props.ImageId.ToString()); cmd.Parameters.AddWithValue("?abouttext", props.AboutText); cmd.Parameters.AddWithValue("?firstlifeimage", props.FirstLifeImageId.ToString()); -- cgit v1.1 From 04f8fc1ce91e1cda9294d2737ef10ab3fce06982 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 5 Dec 2013 20:25:28 -0500 Subject: Adding profile partners fix to SQLite and PgSQL drivers --- OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs | 2 -- OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | 2 -- 2 files changed, 4 deletions(-) diff --git a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs index e3cbf7f..f4e41b4 100644 --- a/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs +++ b/OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs @@ -715,7 +715,6 @@ namespace OpenSim.Data.PGSQL string query = string.Empty; query += "UPDATE userprofile SET "; - query += "profilePartner=:profilePartner, "; query += "profileURL=:profileURL, "; query += "profileImage=:image, "; query += "profileAboutText=:abouttext,"; @@ -731,7 +730,6 @@ namespace OpenSim.Data.PGSQL using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) { cmd.Parameters.AddWithValue("profileURL", props.WebUrl); - cmd.Parameters.AddWithValue("profilePartner", props.PartnerId.ToString()); cmd.Parameters.AddWithValue("image", props.ImageId.ToString()); cmd.Parameters.AddWithValue("abouttext", props.AboutText); cmd.Parameters.AddWithValue("firstlifeimage", props.FirstLifeImageId.ToString()); diff --git a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs index cc1dac1..8c1bcd4 100644 --- a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs @@ -679,7 +679,6 @@ namespace OpenSim.Data.SQLite string query = string.Empty; query += "UPDATE userprofile SET "; - query += "profilePartner=:profilePartner, "; query += "profileURL=:profileURL, "; query += "profileImage=:image, "; query += "profileAboutText=:abouttext,"; @@ -693,7 +692,6 @@ namespace OpenSim.Data.SQLite { cmd.CommandText = query; cmd.Parameters.AddWithValue(":profileURL", props.WebUrl); - cmd.Parameters.AddWithValue(":profilePartner", props.PartnerId.ToString()); cmd.Parameters.AddWithValue(":image", props.ImageId.ToString()); cmd.Parameters.AddWithValue(":abouttext", props.AboutText); cmd.Parameters.AddWithValue(":firstlifeimage", props.FirstLifeImageId.ToString()); -- cgit v1.1 From 1842388bb4dcf5ecd57732ffa877b6ca1a3dec7b Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 6 Dec 2013 02:52:13 -0500 Subject: Add support for user preferences (im via email) --- OpenSim/Data/IProfilesData.cs | 2 + OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 39 +++++----- .../Data/MySQL/Resources/UserProfiles.migrations | 10 +++ OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs | 29 ++++---- .../Data/PGSQL/Resources/UserProfiles.migrations | 9 +++ .../Data/SQLite/Resources/UserProfiles.migrations | 12 ++++ OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | 83 ++++++++++++++++++++++ OpenSim/Framework/UserProfiles.cs | 8 +++ .../Avatar/UserProfiles/UserProfileModule.cs | 67 +++++++++++++++++ .../LocalUserProfilesServiceConnector.cs | 2 + .../Handlers/Profiles/UserProfilesConnector.cs | 2 + .../Handlers/Profiles/UserProfilesHandlers.cs | 53 ++++++++++++++ .../Services/Interfaces/IUserProfilesService.cs | 5 ++ .../UserProfilesService/UserProfilesService.cs | 12 ++++ 14 files changed, 297 insertions(+), 36 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 bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result); bool UpdateAvatarInterests(UserProfileProperties up, ref string result); bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result); + bool UpdateUserPreferences(ref UserPreferences pref, ref string result); + bool GetUserPreferences(ref UserPreferences pref, ref string result); bool GetUserAppData(ref UserAppData props, ref string result); bool SetUserAppData(UserAppData props, ref string result); OSDArray GetUserImageAssets(UUID avatarId); diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index dc88f94..63492c2 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs @@ -895,7 +895,7 @@ namespace OpenSim.Data.MySQL } #region User Preferences - public OSDArray GetUserPreferences(UUID avatarId) + public bool GetUserPreferences(ref UserPreferences pref, ref string result) { string query = string.Empty; @@ -912,19 +912,16 @@ namespace OpenSim.Data.MySQL dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) { - cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); + cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); using (MySqlDataReader reader = cmd.ExecuteReader()) { if(reader.HasRows) { reader.Read(); - OSDMap record = new OSDMap(); - - record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"])); - record.Add("visible",OSD.FromString((string)reader["visible"])); - record.Add("email",OSD.FromString((string)reader["email"])); - data.Add(record); + bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); + bool.TryParse((string)reader["visible"], out pref.Visible); + pref.EMail = (string)reader["email"]; } else { @@ -947,17 +944,19 @@ namespace OpenSim.Data.MySQL { m_log.DebugFormat("[PROFILES_DATA]" + ": Get preferences exception {0}", e.Message); + result = e.Message; + return false; } - return data; + return true; } - public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId ) + public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) { string query = string.Empty; - - query += "UPDATE userpsettings SET "; + + query += "UPDATE usersettings SET "; query += "imviaemail=?ImViaEmail, "; - query += "visible=?Visible,"; + query += "visible=?Visible "; query += "WHERE useruuid=?uuid"; try @@ -967,14 +966,11 @@ namespace OpenSim.Data.MySQL dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) { - cmd.Parameters.AddWithValue("?ImViaEmail", emailIm.ToString().ToLower ()); - cmd.Parameters.AddWithValue("?WantText", visible.ToString().ToLower ()); - cmd.Parameters.AddWithValue("?uuid", avatarId.ToString()); - - lock(Lock) - { - cmd.ExecuteNonQuery(); - } + cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail); + cmd.Parameters.AddWithValue("?Visible", pref.Visible); + cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); + + cmd.ExecuteNonQuery(); } } } @@ -982,6 +978,7 @@ namespace OpenSim.Data.MySQL { m_log.DebugFormat("[PROFILES_DATA]" + ": AgentInterestsUpdate exception {0}", e.Message); + result = e.Message; return false; } 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` ( commit; +:VERSION 3 # ------------------------------- +begin; +CREATE TABLE IF NOT EXISTS `usersettings` ( + `useruuid` varchar(36) NOT NULL, + `imviaemail` enum('true','false') NOT NULL, + `visible` enum('true','false') NOT NULL, + `email` varchar(254) NOT NULL, + PRIMARY KEY (`useruuid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +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 } #region User Preferences - public OSDArray GetUserPreferences(UUID avatarId) + public bool GetUserPreferences(ref UserPreferences pref, ref string result) { string query = string.Empty; @@ -891,19 +891,16 @@ namespace OpenSim.Data.PGSQL dbcon.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) { - cmd.Parameters.AddWithValue("Id", avatarId.ToString()); + cmd.Parameters.AddWithValue("Id", pref.UserId.ToString()); using (NpgsqlDataReader reader = cmd.ExecuteReader()) { if(reader.HasRows) { reader.Read(); - OSDMap record = new OSDMap(); - - record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"])); - record.Add("visible",OSD.FromString((string)reader["visible"])); - record.Add("email",OSD.FromString((string)reader["email"])); - data.Add(record); + bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); + bool.TryParse((string)reader["visible"], out pref.Visible); + pref.EMail = (string)reader["email"]; } else { @@ -926,15 +923,16 @@ namespace OpenSim.Data.PGSQL { m_log.DebugFormat("[PROFILES_DATA]" + ": Get preferences exception {0}", e.Message); + result = e.Message; } - return data; + return true; } - - public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId ) + + public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) { string query = string.Empty; - query += "UPDATE userpsettings SET "; + query += "UPDATE usersettings SET "; query += "imviaemail=:ImViaEmail, "; query += "visible=:Visible,"; query += "WHERE useruuid=:uuid"; @@ -946,9 +944,9 @@ namespace OpenSim.Data.PGSQL dbcon.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon)) { - cmd.Parameters.AddWithValue("ImViaEmail", emailIm.ToString().ToLower ()); - cmd.Parameters.AddWithValue("WantText", visible.ToString().ToLower ()); - cmd.Parameters.AddWithValue("uuid", avatarId.ToString()); + cmd.Parameters.AddWithValue("ImViaEmail", pref.IMViaEmail.ToString().ToLower ()); + cmd.Parameters.AddWithValue("Visible", pref.Visible.ToString().ToLower ()); + cmd.Parameters.AddWithValue("uuid", pref.UserId.ToString()); lock(Lock) { @@ -961,6 +959,7 @@ namespace OpenSim.Data.PGSQL { m_log.DebugFormat("[PROFILES_DATA]" + ": AgentInterestsUpdate exception {0}", e.Message); + result = e.Message; return false; } 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 ( commit; +:VERSION 3 # ------------------------------- +begin; +CREATE TABLE usersettings ( + "useruuid" char(36) NOT NULL, + "imviaemail" bytea NOT NULL, + "visible" bytea NOT NULL, + PRIMARY KEY ("useruuid") +); +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 ( commit; + +:VERSION 3 # ------------------------------- + +begin; +CREATE TABLE IF NOT EXISTS usersettings ( + useruuid char(36) NOT NULL, + imviaemail binary(1) NOT NULL, + visible binary(1) NOT NULL, + email varchar(254) NOT NULL, + PRIMARY KEY (useruuid) +) +commit; \ No newline at end of file diff --git a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs index 8c1bcd4..916a226 100644 --- a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs @@ -747,6 +747,89 @@ namespace OpenSim.Data.SQLite } return true; } + + public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) + { + string query = string.Empty; + + query += "UPDATE usersettings SET "; + query += "imviaemail=:ImViaEmail, "; + query += "visible=:Visible "; + query += "WHERE useruuid=:uuid"; + + try + { + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) + { + cmd.CommandText = query; + cmd.Parameters.AddWithValue(":ImViaEmail", pref.IMViaEmail); + cmd.Parameters.AddWithValue(":Visible", pref.Visible); + cmd.Parameters.AddWithValue(":uuid", pref.UserId.ToString()); + + cmd.ExecuteNonQuery(); + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": AgentInterestsUpdate exception {0}", e.Message); + result = e.Message; + return false; + } + return true; + } + + public bool GetUserPreferences(ref UserPreferences pref, ref string result) + { + IDataReader reader = null; + string query = string.Empty; + + query += "SELECT imviaemail,visible,email FROM "; + query += "usersettings WHERE "; + query += "useruuid = :Id"; + + OSDArray data = new OSDArray(); + + try + { + using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) + { + cmd.CommandText = query; + cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); + + using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if(reader.Read()) + { + bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); + bool.TryParse((string)reader["visible"], out pref.Visible); + pref.EMail = (string)reader["email"]; + } + else + { + query = "INSERT INTO usersettings VALUES "; + query += "(:Id,'false','false', '')"; + + using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) + { + put.Parameters.AddWithValue(":Id", pref.UserId.ToString()); + put.ExecuteNonQuery(); + + } + } + } + } + } + catch (Exception e) + { + m_log.DebugFormat("[PROFILES_DATA]" + + ": Get preferences exception {0}", e.Message); + result = e.Message; + return false; + } + return true; + } + public bool GetUserAppData(ref UserAppData props, ref string result) { IDataReader reader = null; diff --git a/OpenSim/Framework/UserProfiles.cs b/OpenSim/Framework/UserProfiles.cs index 6133591..492f6b9 100644 --- a/OpenSim/Framework/UserProfiles.cs +++ b/OpenSim/Framework/UserProfiles.cs @@ -90,6 +90,14 @@ namespace OpenSim.Framework public UUID TargetId; public string Notes; } + + public class UserPreferences + { + public UUID UserId; + public bool IMViaEmail = false; + public bool Visible = false; + public string EMail = string.Empty; + } public class UserAccountProperties { diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 56ff2bd..b21082f 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -270,6 +270,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles // Notes client.AddGenericPacketHandler("avatarnotesrequest", NotesRequest); client.OnAvatarNotesUpdate += NotesUpdate; + + // Preferences + client.OnUserInfoRequest += UserPreferencesRequest; + client.OnUpdateUserInfo += UpdateUserPreferences; } #endregion Region Event Handlers @@ -799,6 +803,69 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles } #endregion Notes + #region User Preferences + /// + /// Updates the user preferences. + /// + /// + /// Im via email. + /// + /// + /// Visible. + /// + /// + /// Remote client. + /// + public void UpdateUserPreferences(bool imViaEmail, bool visible, IClientAPI remoteClient) + { + UserPreferences pref = new UserPreferences(); + + pref.UserId = remoteClient.AgentId; + pref.IMViaEmail = imViaEmail; + pref.Visible = visible; + + string serverURI = string.Empty; + bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI); + + object Pref = pref; + if(!JsonRpcRequest(ref Pref, "user_preferences_update", serverURI, UUID.Random().ToString())) + { + m_log.InfoFormat("[PROFILES]: UserPreferences update error"); + remoteClient.SendAgentAlertMessage("Error updating preferences", false); + return; + } + } + + /// + /// Users the preferences request. + /// + /// + /// Remote client. + /// + public void UserPreferencesRequest(IClientAPI remoteClient) + { + UserPreferences pref = new UserPreferences(); + + pref.UserId = remoteClient.AgentId; + + string serverURI = string.Empty; + bool foreign = GetUserProfileServerURI(remoteClient.AgentId, out serverURI); + + + object Pref = (object)pref; + if(!JsonRpcRequest(ref Pref, "user_preferences_request", serverURI, UUID.Random().ToString())) + { + m_log.InfoFormat("[PROFILES]: UserPreferences request error"); + remoteClient.SendAgentAlertMessage("Error requesting preferences", false); + return; + } + pref = (UserPreferences) Pref; + + remoteClient.SendUserInfoReply(pref.IMViaEmail, pref.Visible, pref.EMail); + + } + #endregion User Preferences + #region Avatar Properties /// /// Update the avatars interests . diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs index 323535a..4701ee6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/UserProfiles/LocalUserProfilesServiceConnector.cs @@ -153,6 +153,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Profile Server.AddJsonRPCHandler("avatar_properties_request", handler.AvatarPropertiesRequest); Server.AddJsonRPCHandler("avatar_properties_update", handler.AvatarPropertiesUpdate); Server.AddJsonRPCHandler("avatar_interests_update", handler.AvatarInterestsUpdate); + Server.AddJsonRPCHandler("user_preferences_update", handler.UserPreferenecesUpdate); + Server.AddJsonRPCHandler("user_preferences_request", handler.UserPreferencesRequest); Server.AddJsonRPCHandler("image_assets_request", handler.AvatarImageAssetsRequest); Server.AddJsonRPCHandler("user_data_request", handler.RequestUserAppData); Server.AddJsonRPCHandler("user_data_update", handler.UpdateUserAppData); diff --git a/OpenSim/Server/Handlers/Profiles/UserProfilesConnector.cs b/OpenSim/Server/Handlers/Profiles/UserProfilesConnector.cs index 28dbbc2..6403882 100644 --- a/OpenSim/Server/Handlers/Profiles/UserProfilesConnector.cs +++ b/OpenSim/Server/Handlers/Profiles/UserProfilesConnector.cs @@ -104,6 +104,8 @@ namespace OpenSim.Server.Handlers.Profiles Server.AddJsonRPCHandler("avatar_properties_request", handler.AvatarPropertiesRequest); Server.AddJsonRPCHandler("avatar_properties_update", handler.AvatarPropertiesUpdate); Server.AddJsonRPCHandler("avatar_interests_update", handler.AvatarInterestsUpdate); + Server.AddJsonRPCHandler("user_preferences_update", handler.UserPreferenecesUpdate); + Server.AddJsonRPCHandler("user_preferences_request", handler.UserPreferencesRequest); Server.AddJsonRPCHandler("image_assets_request", handler.AvatarImageAssetsRequest); Server.AddJsonRPCHandler("user_data_request", handler.RequestUserAppData); Server.AddJsonRPCHandler("user_data_update", handler.UpdateUserAppData); diff --git a/OpenSim/Server/Handlers/Profiles/UserProfilesHandlers.cs b/OpenSim/Server/Handlers/Profiles/UserProfilesHandlers.cs index f5f0794..d30cc22 100644 --- a/OpenSim/Server/Handlers/Profiles/UserProfilesHandlers.cs +++ b/OpenSim/Server/Handlers/Profiles/UserProfilesHandlers.cs @@ -381,6 +381,59 @@ namespace OpenSim.Server.Handlers } #endregion Interests + #region User Preferences + public bool UserPreferencesRequest(OSDMap json, ref JsonRpcResponse response) + { + if(!json.ContainsKey("params")) + { + response.Error.Code = ErrorCode.ParseError; + m_log.DebugFormat ("User Preferences Request"); + return false; + } + + string result = string.Empty; + UserPreferences prefs = new UserPreferences(); + object Prefs = (object)prefs; + OSD.DeserializeMembers(ref Prefs, (OSDMap)json["params"]); + if(Service.UserPreferencesRequest(ref prefs, ref result)) + { + response.Result = OSD.SerializeMembers(prefs); + return true; + } + + response.Error.Code = ErrorCode.InternalError; + response.Error.Message = string.Format("{0}", result); + m_log.InfoFormat("[PROFILES]: User preferences request error - {0}", response.Error.Message); + return false; + } + + public bool UserPreferenecesUpdate(OSDMap json, ref JsonRpcResponse response) + { + if(!json.ContainsKey("params")) + { + response.Error.Code = ErrorCode.ParseError; + response.Error.Message = "no parameters supplied"; + m_log.DebugFormat ("User Preferences Update Request"); + return false; + } + + string result = string.Empty; + UserPreferences prefs = new UserPreferences(); + object Prefs = (object)prefs; + OSD.DeserializeMembers(ref Prefs, (OSDMap)json["params"]); + if(Service.UserPreferencesUpdate(ref prefs, ref result)) + { + response.Result = OSD.SerializeMembers(prefs); + return true; + } + + response.Error.Code = ErrorCode.InternalError; + response.Error.Message = string.Format("{0}", result); + m_log.InfoFormat("[PROFILES]: User preferences update error - {0}", response.Error.Message); + return false; + } + #endregion User Preferences + #region Utility public bool AvatarImageAssetsRequest(OSDMap json, ref JsonRpcResponse response) { diff --git a/OpenSim/Services/Interfaces/IUserProfilesService.cs b/OpenSim/Services/Interfaces/IUserProfilesService.cs index 319d307..121baa8 100644 --- a/OpenSim/Services/Interfaces/IUserProfilesService.cs +++ b/OpenSim/Services/Interfaces/IUserProfilesService.cs @@ -57,6 +57,11 @@ namespace OpenSim.Services.Interfaces bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result); bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result); #endregion Profile Properties + + #region User Preferences + bool UserPreferencesRequest(ref UserPreferences pref, ref string result); + bool UserPreferencesUpdate(ref UserPreferences pref, ref string result); + #endregion User Preferences #region Interests bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result); diff --git a/OpenSim/Services/UserProfilesService/UserProfilesService.cs b/OpenSim/Services/UserProfilesService/UserProfilesService.cs index d00f34d..69c7b91 100644 --- a/OpenSim/Services/UserProfilesService/UserProfilesService.cs +++ b/OpenSim/Services/UserProfilesService/UserProfilesService.cs @@ -163,6 +163,18 @@ namespace OpenSim.Services.ProfilesService } #endregion Interests + #region User Preferences + public bool UserPreferencesUpdate(ref UserPreferences pref, ref string result) + { + return ProfilesData.UpdateUserPreferences(ref pref, ref result); + } + + public bool UserPreferencesRequest(ref UserPreferences pref, ref string result) + { + return ProfilesData.GetUserPreferences(ref pref, ref result); + } + #endregion User Preferences + #region Utility public OSD AvatarImageAssetsRequest(UUID avatarId) { -- cgit v1.1