From 4ec4e16c809cf86a63b736d2b7b6ad7291595a5f Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 4 Jun 2008 09:59:27 +0000 Subject: Formatting cleanup, minor refactoring, svn properties. --- .../Modules/Avatar/Chat/IRCBridgeModule.cs | 4 +- .../Avatar/InstantMessage/InstantMessageModule.cs | 38 ++++++------ .../Modules/World/Archiver/ArchiveReadRequest.cs | 48 +++++++-------- .../Modules/World/Archiver/ArchiveWriteRequest.cs | 20 +++---- .../Modules/World/Archiver/TarArchiveReader.cs | 68 +++++++++++----------- .../Modules/World/Serialiser/IRegionSerialiser.cs | 18 +++--- .../Modules/World/Serialiser/SceneXmlLoader.cs | 16 ++--- .../Modules/World/Serialiser/SerialiserModule.cs | 18 +++--- 8 files changed, 115 insertions(+), 115 deletions(-) (limited to 'OpenSim/Region/Environment/Modules') diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs index 7ee7eda..16fd753 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs @@ -644,7 +644,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat } catch (IOException) { - if (m_enabled) + if (m_enabled) { m_log.Error("[IRC]: ListenerRun IOException. Disconnected from IRC server ??? (ListenerRun)"); Reconnect(); @@ -848,7 +848,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat public void Close() { - m_writer.WriteLine(String.Format("QUIT :{0} to {1} wormhole to {2} closing", + m_writer.WriteLine(String.Format("QUIT :{0} to {1} wormhole to {2} closing", m_nick, m_channel, m_server)); m_writer.Flush(); diff --git a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs index 36184d2..b22ca79 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs @@ -50,7 +50,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage #region IRegionModule Members private bool gridmode = false; - + public void Initialise(Scene scene, IConfigSource config) { @@ -183,13 +183,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage } } - + } // Trusty OSG1 called method. This method also gets called from the FriendsModule // Turns out the sim has to send an instant message to the user to get it to show an accepted friend. /// - /// + /// /// /// private void OnGridInstantMessage(GridInstantMessage msg) @@ -207,7 +207,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage /// Process a XMLRPC Grid Instant Message /// /// XMLRPC parameters from_agent_id from_agent_session to_agent_id im_session_id timestamp - /// from_agent_name message dialog from_group offline parent_estate_id position_x position_y position_z region_id + /// from_agent_name message dialog from_group offline parent_estate_id position_x position_y position_z region_id /// binary_bucket region_handle /// Nothing much protected virtual XmlRpcResponse processXMLRPCGridInstantMessage(XmlRpcRequest request) @@ -221,7 +221,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage uint timestamp = 0; string fromAgentName = ""; string message = ""; - byte dialog = (byte)0; + byte dialog = (byte)0; bool fromGroup = false; byte offline = (byte)0; uint ParentEstateID=0; @@ -237,14 +237,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage Hashtable requestData = (Hashtable)request.Params[0]; // Check if it's got all the data - if (requestData.ContainsKey("from_agent_id") && requestData.ContainsKey("from_agent_session") - && requestData.ContainsKey("to_agent_id") && requestData.ContainsKey("im_session_id") - && requestData.ContainsKey("timestamp") && requestData.ContainsKey("from_agent_name") - && requestData.ContainsKey("message") && requestData.ContainsKey("dialog") - && requestData.ContainsKey("from_group") - && requestData.ContainsKey("offline") && requestData.ContainsKey("parent_estate_id") - && requestData.ContainsKey("position_x") && requestData.ContainsKey("position_y") - && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") + if (requestData.ContainsKey("from_agent_id") && requestData.ContainsKey("from_agent_session") + && requestData.ContainsKey("to_agent_id") && requestData.ContainsKey("im_session_id") + && requestData.ContainsKey("timestamp") && requestData.ContainsKey("from_agent_name") + && requestData.ContainsKey("message") && requestData.ContainsKey("dialog") + && requestData.ContainsKey("from_group") + && requestData.ContainsKey("offline") && requestData.ContainsKey("parent_estate_id") + && requestData.ContainsKey("position_x") && requestData.ContainsKey("position_y") + && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") && requestData.ContainsKey("binary_bucket") && requestData.ContainsKey("region_handle")) { // Do the easy way of validating the UUIDs @@ -276,7 +276,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage // Bytes don't transfer well over XMLRPC, so, we Base64 Encode them. byte[] dialogdata = Convert.FromBase64String((string)requestData["dialog"]); dialog = dialogdata[0]; - + if ((string)requestData["from_group"] == "TRUE") fromGroup = true; @@ -365,7 +365,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage gim.Position = new sLLVector3(Position); gim.binaryBucket = binaryBucket; - + // Trigger the Instant message in the scene. foreach (Scene scene in m_scenes) { @@ -381,7 +381,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage } } //OnGridInstantMessage(gim); - + } //Send response back to region calling if it was successful @@ -482,7 +482,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage else { lookupAgent = true; - + } } @@ -564,7 +564,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage else { // try again, but lookup user this time. - // Warning, this must call the Async version + // Warning, this must call the Async version // of this method or we'll be making thousands of threads // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync // The version that spawns the thread is SendGridInstantMessageViaXMLRPC @@ -686,7 +686,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage if (msg.fromGroup) gim["from_group"] = "TRUE"; - else + else gim["from_group"] = "FALSE"; byte[] offlinedata = new byte[1]; offlinedata[0] = msg.offline; gim["offline"] = Convert.ToBase64String(offlinedata, Base64FormattingOptions.None); diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs index 0c5edaa..6a3b519 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs @@ -41,10 +41,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver /// public class ArchiveReadRequest { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); - + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); + private Scene m_scene; private string m_loadPath; @@ -55,22 +55,22 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver DearchiveRegion(); } - + protected void DearchiveRegion() - { + { TarArchiveReader archive = new TarArchiveReader(m_loadPath); - + string serializedPrims = string.Empty; - + // Just test for now by reading first file string filePath = "ERROR"; - + byte[] data; while ((data = archive.ReadEntry(out filePath)) != null) - { + { m_log.DebugFormat( "[ARCHIVER]: Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath); - + if (filePath.Equals(ArchiveConstants.PRIMS_PATH)) { serializedPrims = m_asciiEncoding.GetString(data); @@ -78,37 +78,37 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver else if (filePath.StartsWith(ArchiveConstants.TEXTURES_PATH)) { // Right now we're nastily obtaining the lluuid from the filename - string rawId = filePath.Remove(0, ArchiveConstants.TEXTURES_PATH.Length); + string rawId = filePath.Remove(0, ArchiveConstants.TEXTURES_PATH.Length); rawId = rawId.Remove(rawId.Length - ArchiveConstants.TEXTURE_EXTENSION.Length); - + m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", rawId); - + // Not preserving asset name or description as of yet AssetBase asset = new AssetBase(new LLUUID(rawId), "imported name"); asset.Description = "imported description"; - + asset.Type = (sbyte)AssetType.Texture; asset.InvType = (sbyte)InventoryType.Texture; - + asset.Data = data; - - m_scene.AssetCache.AddAsset(asset); + + m_scene.AssetCache.AddAsset(asset); } } - - m_log.DebugFormat("[ARCHIVER]: Reached end of archive"); - + + m_log.DebugFormat("[ARCHIVER]: Reached end of archive"); + archive.Close(); - + if (serializedPrims.Equals(string.Empty)) { m_log.ErrorFormat("[ARCHIVER]: Archive did not contain a {0} file", ArchiveConstants.PRIMS_PATH); return; } - + // Reload serialized prims m_log.InfoFormat("[ARCHIVER]: Loading prim data"); - + IRegionSerialiser serialiser = m_scene.RequestModuleInterface(); serialiser.LoadPrimsFromXml2(m_scene, new StringReader(serializedPrims)); } diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs index 1cc8877..6c341c6 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs @@ -80,16 +80,16 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver { // XXX: Not a great way to iterate through face textures, but there's no // other way to tell how many faces there actually are - //int i = 0; - foreach (LLObject.TextureEntryFace texture in part.Shape.Textures.FaceTextures) - { + //int i = 0; + foreach (LLObject.TextureEntryFace texture in part.Shape.Textures.FaceTextures) + { if (texture != null) { - //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++); + //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++); textureUuids[texture.TextureID] = 1; } } - + foreach (TaskInventoryItem tit in part.TaskInventory.Values) { if (tit.Type == (int)InventoryType.Texture) @@ -123,7 +123,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver TarArchiveWriter archive = new TarArchiveWriter(); archive.AddFile(ArchiveConstants.PRIMS_PATH, m_serializedEntities); - + // It appears that gtar, at least, doesn't need the intermediate directory entries in the tar //archive.AddDir("assets"); @@ -132,7 +132,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver if (assets[uuid] != null) { archive.AddFile( - ArchiveConstants.TEXTURES_PATH + uuid.ToString() + ArchiveConstants.TEXTURE_EXTENSION, + ArchiveConstants.TEXTURES_PATH + uuid.ToString() + ArchiveConstants.TEXTURE_EXTENSION, assets[uuid].Data); } else @@ -142,7 +142,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver } archive.WriteTar(m_savePath); - + m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath); } @@ -232,11 +232,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver newThread.Start(); } } - + /// /// Perform the callback on the original requester of the assets /// - protected void PerformAssetsRequestCallback() + protected void PerformAssetsRequestCallback() { m_assetsRequestCallback(m_assets); } diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs index b199d5f..463e172 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs @@ -39,24 +39,24 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver public class TarArchiveReader { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); - + + protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); + /// /// Binary reader for the underlying stream /// protected BinaryReader m_br; - + /// /// Used to trim off null chars /// protected char[] m_nullCharArray = new char[] { '\0' }; - + public TarArchiveReader(string archivePath) { m_br = new BinaryReader(new FileStream(archivePath, FileMode.Open)); } - + /// /// Are we at the end of the archive? /// @@ -64,13 +64,13 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver public bool AtEof() { // If we've reached the end of the archive we'll be in null block territory, which means - // the next byte will be 0 + // the next byte will be 0 if (m_br.PeekChar() == 0) return true; - + return false; } - + /// /// Read the next entry in the tar file. /// @@ -79,27 +79,27 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver public byte[] ReadEntry(out string filePath) { filePath = String.Empty; - + if (AtEof()) return null; - - TarHeader header = ReadHeader(); - + + TarHeader header = ReadHeader(); + filePath = header.FilePath; byte[] data = m_br.ReadBytes(header.FileSize); - - m_log.DebugFormat("[TAR ARCHIVE READER]: filePath {0}, fileSize {1}", filePath, header.FileSize); - - // Read the rest of the empty padding in the 512 byte block + + m_log.DebugFormat("[TAR ARCHIVE READER]: filePath {0}, fileSize {1}", filePath, header.FileSize); + + // Read the rest of the empty padding in the 512 byte block if (header.FileSize % 512 != 0) { int paddingLeft = 512 - (header.FileSize % 512); - + m_log.DebugFormat("[TAR ARCHIVE READER]: Reading {0} padding bytes", paddingLeft); m_br.ReadBytes(paddingLeft); - } - + } + return data; } @@ -109,44 +109,44 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver /// /// A tar header struct. protected TarHeader ReadHeader() - { + { TarHeader tarHeader = new TarHeader(); - + byte[] header = m_br.ReadBytes(512); - + tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11); - + return tarHeader; } - + public void Close() { m_br.Close(); } - + /// /// Convert octal bytes to a decimal representation /// /// /// public static int ConvertOctalBytesToDecimal(byte[] bytes, int startIndex, int count) - { - string oString = m_asciiEncoding.GetString(bytes, startIndex, count); - + { + string oString = m_asciiEncoding.GetString(bytes, startIndex, count); + int d = 0; - + foreach (char c in oString) { - d <<= 3; - d |= c - '0'; + d <<= 3; + d |= c - '0'; } return d; - } + } } - + public struct TarHeader { public string FilePath; diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs index b7ed9f9..e0d2add 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs @@ -34,30 +34,30 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser { public interface IRegionSerialiser { - List SerialiseRegion(Scene scene, string saveDir); - + List SerialiseRegion(Scene scene, string saveDir); + void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, LLVector3 loadOffset); - + void SavePrimsToXml(Scene scene, string fileName); /// /// Load prims from the xml2 format /// /// - /// + /// void LoadPrimsFromXml2(Scene scene, string fileName); - + /// /// Load prims from the xml2 format /// /// - /// + /// void LoadPrimsFromXml2(Scene scene, TextReader reader); - + void SavePrimsToXml2(Scene scene, string fileName); - + void LoadGroupFromXml2String(Scene scene, string xmlString); - + string SavePrimGroupToXML2String(SceneObjectGroup grp); } } diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs index 2ac0754..5ec8026 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs @@ -56,14 +56,14 @@ namespace OpenSim.Region.Environment.Scenes foreach (XmlNode aPrimNode in rootNode.ChildNodes) { SceneObjectGroup obj = new SceneObjectGroup(scene, scene.RegionInfo.RegionHandle, aPrimNode.OuterXml); - + if (newIDS) { obj.ResetIDs(); } //if we want this to be a import method then we need new uuids for the object to avoid any clashes //obj.RegenerateFullIDs(); - + scene.AddSceneObject(obj); SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); @@ -156,7 +156,7 @@ namespace OpenSim.Region.Environment.Scenes { LoadPrimsFromXml2(scene, new XmlTextReader(fileName)); } - + /// /// Load prims from the xml2 format /// @@ -173,24 +173,24 @@ namespace OpenSim.Region.Environment.Scenes /// /// protected static void LoadPrimsFromXml2(Scene scene, XmlTextReader reader) - { - XmlDocument doc = new XmlDocument(); + { + XmlDocument doc = new XmlDocument(); reader.WhitespaceHandling = WhitespaceHandling.None; doc.Load(reader); reader.Close(); XmlNode rootNode = doc.FirstChild; - + foreach (XmlNode aPrimNode in rootNode.ChildNodes) { CreatePrimFromXml(scene, aPrimNode.OuterXml); - } + } } public static void CreatePrimFromXml(Scene scene, string xmlData) { SceneObjectGroup obj = new SceneObjectGroup(xmlData); LLVector3 receivedVelocity = obj.RootPart.Velocity; - //System.Console.WriteLine(obj.RootPart.Velocity.ToString()); + //System.Console.WriteLine(obj.RootPart.Velocity.ToString()); scene.AddSceneObjectFromStorage(obj); SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs index b181fe8..c7c8e39 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs @@ -86,42 +86,42 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser #endregion #region IRegionSerialiser Members - + public void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, LLVector3 loadOffset) { SceneXmlLoader.LoadPrimsFromXml(scene, fileName, newIDS, loadOffset); } - + public void SavePrimsToXml(Scene scene, string fileName) { SceneXmlLoader.SavePrimsToXml(scene, fileName); } - + public void LoadPrimsFromXml2(Scene scene, string fileName) { SceneXmlLoader.LoadPrimsFromXml2(scene, fileName); } - + public void LoadPrimsFromXml2(Scene scene, TextReader reader) { SceneXmlLoader.LoadPrimsFromXml2(scene, reader); - } - + } + public void SavePrimsToXml2(Scene scene, string fileName) { SceneXmlLoader.SavePrimsToXml2(scene, fileName); } - + public void LoadGroupFromXml2String(Scene scene, string xmlString) { SceneXmlLoader.LoadGroupFromXml2String(scene, xmlString); } - + public string SavePrimGroupToXML2String(SceneObjectGroup grp) { return SceneXmlLoader.SavePrimGroupToXML2String(grp); } - + public List SerialiseRegion(Scene scene, string saveDir) { List results = new List(); -- cgit v1.1