Formatting cleanup, minor refactoring, svn properties.

This commit is contained in:
Jeff Ames
2008-06-04 09:59:27 +00:00
parent 0a2d399cad
commit 4ec4e16c80
59 changed files with 851 additions and 834 deletions

View File

@@ -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();

View File

@@ -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.
/// <summary>
///
///
/// </summary>
/// <param name="msg"></param>
private void OnGridInstantMessage(GridInstantMessage msg)
@@ -207,7 +207,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
/// Process a XMLRPC Grid Instant Message
/// </summary>
/// <param name="request">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</param>
/// <returns>Nothing much</returns>
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);

View File

@@ -41,10 +41,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
/// </summary>
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<IRegionSerialiser>();
serialiser.LoadPrimsFromXml2(m_scene, new StringReader(serializedPrims));
}

View File

@@ -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();
}
}
/// <summary>
/// Perform the callback on the original requester of the assets
/// </summary>
protected void PerformAssetsRequestCallback()
protected void PerformAssetsRequestCallback()
{
m_assetsRequestCallback(m_assets);
}

View File

@@ -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();
/// <summary>
/// Binary reader for the underlying stream
/// </summary>
protected BinaryReader m_br;
/// <summary>
/// Used to trim off null chars
/// </summary>
protected char[] m_nullCharArray = new char[] { '\0' };
public TarArchiveReader(string archivePath)
{
m_br = new BinaryReader(new FileStream(archivePath, FileMode.Open));
}
/// <summary>
/// Are we at the end of the archive?
/// </summary>
@@ -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;
}
/// <summary>
/// Read the next entry in the tar file.
/// </summary>
@@ -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
/// </summary>
/// <returns>A tar header struct.</returns>
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();
}
/// <summary>
/// Convert octal bytes to a decimal representation
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
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;

View File

@@ -34,30 +34,30 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
{
public interface IRegionSerialiser
{
List<string> SerialiseRegion(Scene scene, string saveDir);
List<string> SerialiseRegion(Scene scene, string saveDir);
void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, LLVector3 loadOffset);
void SavePrimsToXml(Scene scene, string fileName);
/// <summary>
/// Load prims from the xml2 format
/// </summary>
/// <param name="scene"></param>
/// <param name="fileName"></param>
/// <param name="fileName"></param>
void LoadPrimsFromXml2(Scene scene, string fileName);
/// <summary>
/// Load prims from the xml2 format
/// </summary>
/// <param name="scene"></param>
/// <param name="reader"></param>
/// <param name="reader"></param>
void LoadPrimsFromXml2(Scene scene, TextReader reader);
void SavePrimsToXml2(Scene scene, string fileName);
void LoadGroupFromXml2String(Scene scene, string xmlString);
string SavePrimGroupToXML2String(SceneObjectGroup grp);
}
}

View File

@@ -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));
}
/// <summary>
/// Load prims from the xml2 format
/// </summary>
@@ -173,24 +173,24 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="scene"></param>
/// <param name="reader"></param>
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);

View File

@@ -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<string> SerialiseRegion(Scene scene, string saveDir)
{
List<string> results = new List<string>();