From 1842388bb4dcf5ecd57732ffa877b6ca1a3dec7b Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 6 Dec 2013 02:52:13 -0500 Subject: [PATCH 1/4] Add support for user preferences (im via email) --- OpenSim/Data/IProfilesData.cs | 2 + OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 39 ++++----- .../MySQL/Resources/UserProfiles.migrations | 10 +++ OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs | 29 ++++--- .../PGSQL/Resources/UserProfiles.migrations | 9 ++ .../SQLite/Resources/UserProfiles.migrations | 12 +++ OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | 83 +++++++++++++++++++ OpenSim/Framework/UserProfiles.cs | 8 ++ .../Avatar/UserProfiles/UserProfileModule.cs | 67 +++++++++++++++ .../LocalUserProfilesServiceConnector.cs | 2 + .../Profiles/UserProfilesConnector.cs | 2 + .../Handlers/Profiles/UserProfilesHandlers.cs | 53 ++++++++++++ .../Interfaces/IUserProfilesService.cs | 5 ++ .../UserProfilesService.cs | 12 +++ 14 files changed, 297 insertions(+), 36 deletions(-) diff --git a/OpenSim/Data/IProfilesData.cs b/OpenSim/Data/IProfilesData.cs index 0de7f68af9..7fb075d3d5 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 dc88f9460a..63492c2f10 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 c29f1abf3e..bd325da1f0 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 f4e41b47dd..46f57d8066 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 f23c87087c..4fcaa8e0bf 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 16581f6e49..86434e8170 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 8c1bcd48d1..916a226d6b 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 61335917e1..492f6b9bd1 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 56ff2bddb1..b21082fd74 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 323535ab07..4701ee653f 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 28dbbc2e13..640388200d 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 f5f0794653..d30cc228b0 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 319d3075dd..121baa8b1f 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 d00f34d650..69c7b91957 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) { From 1496de7ce99079d3d7bf046db088c3d6e2a97bcb Mon Sep 17 00:00:00 2001 From: dahlia Date: Fri, 6 Dec 2013 15:58:19 -0800 Subject: [PATCH 2/4] use System.IO.Compression.DeflateStream for mesh decompression in an attempt to reduce mesh asset decoding failures --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 14 +++++--------- prebuild.xml | 1 - 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 1f08b030c6..e313a302ae 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -40,7 +40,6 @@ using log4net; using Nini.Config; using System.Reflection; using System.IO; -using ComponentAce.Compression.Libs.zlib; namespace OpenSim.Region.Physics.Meshing { @@ -549,7 +548,6 @@ namespace OpenSim.Region.Physics.Meshing return true; } - /// /// decompresses a gzipped OSD object /// @@ -564,15 +562,13 @@ namespace OpenSim.Region.Physics.Meshing { using (MemoryStream outMs = new MemoryStream()) { - using (ZOutputStream zOut = new ZOutputStream(outMs)) + using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress)) { byte[] readBuffer = new byte[2048]; - int readLen = 0; - while ((readLen = inMs.Read(readBuffer, 0, readBuffer.Length)) > 0) - { - zOut.Write(readBuffer, 0, readLen); - } - zOut.Flush(); + inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header + + decompressionStream.CopyTo(outMs); + outMs.Seek(0, SeekOrigin.Begin); byte[] decompressedBuf = outMs.GetBuffer(); diff --git a/prebuild.xml b/prebuild.xml index de3b89bb46..f6e0f4b4e0 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -585,7 +585,6 @@ - From 4058e5f709990cc502d5479fb4065bf232ee3a8d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 6 Dec 2013 16:01:29 -0800 Subject: [PATCH 3/4] Fixed misleading comment --- OpenSim/Services/Interfaces/IHypergridServices.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs index f9e7f083b4..05e175a243 100644 --- a/OpenSim/Services/Interfaces/IHypergridServices.cs +++ b/OpenSim/Services/Interfaces/IHypergridServices.cs @@ -43,9 +43,6 @@ namespace OpenSim.Services.Interfaces } - /// - /// HG1.5 only - /// public interface IUserAgentService { bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason); From c0380d1bfe596afe33659cc69ae99a09018f9908 Mon Sep 17 00:00:00 2001 From: dahlia Date: Fri, 6 Dec 2013 16:24:44 -0800 Subject: [PATCH 4/4] apparently mono DeflateStream has no CopyTo method =( --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index e313a302ae..d96de4ac8e 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -566,8 +566,12 @@ namespace OpenSim.Region.Physics.Meshing { byte[] readBuffer = new byte[2048]; inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header + int readLen = 0; - decompressionStream.CopyTo(outMs); + while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0) + outMs.Write(readBuffer, 0, readLen); + + outMs.Flush(); outMs.Seek(0, SeekOrigin.Begin);