Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim

arthursv
Diva Canto 2009-08-17 05:55:38 -07:00
commit fa8a94577a
46 changed files with 1738 additions and 372 deletions

1
.gitignore vendored
View File

@ -21,6 +21,7 @@ bin/*.db
bin/addin-db-* bin/addin-db-*
bin/*.dll bin/*.dll
bin/OpenSim.vshost.exe.config bin/OpenSim.vshost.exe.config
bin/ScriptEngines/*-*-*-*-*
bin/ScriptEngines/*.dll bin/ScriptEngines/*.dll
bin/ScriptEngines/*/*.dll bin/ScriptEngines/*/*.dll
bin/ScriptEngines/*/*.state bin/ScriptEngines/*/*.state

View File

@ -0,0 +1,198 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using Nini.Config;
using log4net;
using System.Reflection;
using System;
using System.Xml;
using System.Collections.Generic;
using OpenSim.Server.Base;
using OpenSim.Framework.Console;
using OpenMetaverse;
namespace OpenSim.ConsoleClient
{
public class OpenSimConsoleClient
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
protected static ServicesServerBase m_Server = null;
private static string m_Host;
private static int m_Port;
private static string m_User;
private static string m_Pass;
private static UUID m_SessionID;
static int Main(string[] args)
{
m_Server = new ServicesServerBase("Client", args);
IConfig serverConfig = m_Server.Config.Configs["Startup"];
if (serverConfig == null)
{
System.Console.WriteLine("Startup config section missing in .ini file");
throw new Exception("Configuration error");
}
ArgvConfigSource argvConfig = new ArgvConfigSource(args);
argvConfig.AddSwitch("Startup", "host", "h");
argvConfig.AddSwitch("Startup", "port", "p");
argvConfig.AddSwitch("Startup", "user", "u");
argvConfig.AddSwitch("Startup", "pass", "P");
m_Server.Config.Merge(argvConfig);
m_User = serverConfig.GetString("user", "Test");
m_Host = serverConfig.GetString("host", "localhost");
m_Port = serverConfig.GetInt("port", 8003);
m_Pass = serverConfig.GetString("pass", "secret");
Requester.MakeRequest("http://"+m_Host+":"+m_Port.ToString()+"/StartSession/", String.Format("USER={0}&PASS={1}", m_User, m_Pass), LoginReply);
int res = m_Server.Run();
Environment.Exit(res);
return 0;
}
private static void SendCommand(string module, string[] cmd)
{
string sendCmd = String.Join(" ", cmd);
Requester.MakeRequest("http://"+m_Host+":"+m_Port.ToString()+"/SessionCommand/", String.Format("ID={0}&COMMAND={1}", m_SessionID, sendCmd), CommandReply);
}
public static void LoginReply(string requestUrl, string requestData, string replyData)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(replyData);
XmlNodeList rootL = doc.GetElementsByTagName("ConsoleSession");
if (rootL.Count != 1)
{
MainConsole.Instance.Output("Connection data info was not valid");
Environment.Exit(1);
}
XmlElement rootNode = (XmlElement)rootL[0];
if (rootNode == null)
{
MainConsole.Instance.Output("Connection data info was not valid");
Environment.Exit(1);
}
XmlNodeList helpNodeL = rootNode.GetElementsByTagName("HelpTree");
if (helpNodeL.Count != 1)
{
MainConsole.Instance.Output("Connection data info was not valid");
Environment.Exit(1);
}
XmlElement helpNode = (XmlElement)helpNodeL[0];
if (helpNode == null)
{
MainConsole.Instance.Output("Connection data info was not valid");
Environment.Exit(1);
}
XmlNodeList sessionL = rootNode.GetElementsByTagName("SessionID");
if (sessionL.Count != 1)
{
MainConsole.Instance.Output("Connection data info was not valid");
Environment.Exit(1);
}
XmlElement sessionNode = (XmlElement)sessionL[0];
if (sessionNode == null)
{
MainConsole.Instance.Output("Connection data info was not valid");
Environment.Exit(1);
}
if (!UUID.TryParse(sessionNode.InnerText, out m_SessionID))
{
MainConsole.Instance.Output("Connection data info was not valid");
Environment.Exit(1);
}
MainConsole.Instance.Commands.FromXml(helpNode, SendCommand);
Requester.MakeRequest("http://"+m_Host+":"+m_Port.ToString()+"/ReadResponses/"+m_SessionID.ToString()+"/", String.Empty, ReadResponses);
}
public static void ReadResponses(string requestUrl, string requestData, string replyData)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(replyData);
XmlNodeList rootNodeL = doc.GetElementsByTagName("ConsoleSession");
if (rootNodeL.Count != 1 || rootNodeL[0] == null)
{
Requester.MakeRequest(requestUrl, requestData, ReadResponses);
return;
}
List<string> lines = new List<string>();
foreach (XmlNode part in rootNodeL[0].ChildNodes)
{
if (part.Name != "Line")
continue;
lines.Add(part.InnerText);
}
// Cut down scrollback to 100 lines (4 screens)
// for the command line client
//
while (lines.Count > 100)
lines.RemoveAt(0);
foreach (string l in lines)
{
string[] parts = l.Split(new char[] {':'}, 3);
if (parts.Length != 3)
continue;
MainConsole.Instance.Output(parts[2].Trim(), parts[1]);
}
Requester.MakeRequest(requestUrl, requestData, ReadResponses);
}
public static void CommandReply(string requestUrl, string requestData, string replyData)
{
}
}
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.IO;
using System.Net;
using System.Reflection;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using log4net;
namespace OpenSim.ConsoleClient
{
public delegate void ReplyDelegate(string requestUrl, string requestData, string replyData);
public class Requester
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static void MakeRequest(string requestUrl, string data,
ReplyDelegate action)
{
WebRequest request = WebRequest.Create(requestUrl);
WebResponse response = null;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
byte[] buffer = new System.Text.ASCIIEncoding().GetBytes(data);
int length = (int) buffer.Length;
request.ContentLength = length;
request.BeginGetRequestStream(delegate(IAsyncResult res)
{
Stream requestStream = request.EndGetRequestStream(res);
requestStream.Write(buffer, 0, length);
request.BeginGetResponse(delegate(IAsyncResult ar)
{
string reply = String.Empty;
response = request.EndGetResponse(ar);
try
{
StreamReader r = new StreamReader(response.GetResponseStream());
reply = r.ReadToEnd();
}
catch (System.InvalidOperationException)
{
}
action(requestUrl, data, reply);
}, null);
}, null);
}
}
}

View File

@ -168,6 +168,7 @@ namespace OpenSim.Data.MySQL
} }
asset.Name = (string) dbReader["name"]; asset.Name = (string) dbReader["name"];
asset.Type = (sbyte) dbReader["assetType"]; asset.Type = (sbyte) dbReader["assetType"];
asset.Temporary = (bool)dbReader["temporary"];
} }
dbReader.Close(); dbReader.Close();
cmd.Dispose(); cmd.Dispose();
@ -195,18 +196,11 @@ namespace OpenSim.Data.MySQL
{ {
lock (_dbConnection) lock (_dbConnection)
{ {
//m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID);
if (ExistsAsset(asset.FullID))
{
//m_log.Info("[ASSET DB]: Asset exists already, ignoring.");
return;
}
_dbConnection.CheckConnection(); _dbConnection.CheckConnection();
MySqlCommand cmd = MySqlCommand cmd =
new MySqlCommand( new MySqlCommand(
"insert INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" +
"VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)",
_dbConnection.Connection); _dbConnection.Connection);

View File

@ -342,7 +342,7 @@ namespace OpenSim.Data.MySQL
item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"];
item.GroupPermissions = (uint) reader["inventoryGroupPermissions"]; item.GroupPermissions = (uint) reader["inventoryGroupPermissions"];
item.SalePrice = (int) reader["salePrice"]; item.SalePrice = (int) reader["salePrice"];
item.SaleType = Convert.ToByte(reader["saleType"]); item.SaleType = unchecked((byte)(Convert.ToSByte(reader["saleType"])));
item.CreationDate = (int) reader["creationDate"]; item.CreationDate = (int) reader["creationDate"];
item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]);
item.Flags = (uint) reader["flags"]; item.Flags = (uint) reader["flags"];
@ -423,7 +423,7 @@ namespace OpenSim.Data.MySQL
/// <summary> /// <summary>
/// Returns a specified inventory folder /// Returns a specified inventory folder
/// </summary> /// </summary>
/// <param name="folder">The folder to return</param> /// <param name="folderID">The folder to return</param>
/// <returns>A folder class</returns> /// <returns>A folder class</returns>
public InventoryFolderBase getInventoryFolder(UUID folderID) public InventoryFolderBase getInventoryFolder(UUID folderID)
{ {
@ -438,8 +438,9 @@ namespace OpenSim.Data.MySQL
result.Parameters.AddWithValue("?uuid", folderID.ToString()); result.Parameters.AddWithValue("?uuid", folderID.ToString());
MySqlDataReader reader = result.ExecuteReader(); MySqlDataReader reader = result.ExecuteReader();
reader.Read(); InventoryFolderBase folder = null;
InventoryFolderBase folder = readInventoryFolder(reader); if (reader.Read())
folder = readInventoryFolder(reader);
reader.Close(); reader.Close();
result.Dispose(); result.Dispose();
@ -506,7 +507,7 @@ namespace OpenSim.Data.MySQL
result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
result.Parameters.AddWithValue("?salePrice", item.SalePrice); result.Parameters.AddWithValue("?salePrice", item.SalePrice);
result.Parameters.AddWithValue("?saleType", item.SaleType); result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType));
result.Parameters.AddWithValue("?creationDate", item.CreationDate); result.Parameters.AddWithValue("?creationDate", item.CreationDate);
result.Parameters.AddWithValue("?groupID", item.GroupID); result.Parameters.AddWithValue("?groupID", item.GroupID);
result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); result.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
@ -603,7 +604,7 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString());
cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
cmd.Parameters.AddWithValue("?folderName", folderName); cmd.Parameters.AddWithValue("?folderName", folderName);
cmd.Parameters.AddWithValue("?type", (short) folder.Type); cmd.Parameters.AddWithValue("?type", folder.Type);
cmd.Parameters.AddWithValue("?version", folder.Version); cmd.Parameters.AddWithValue("?version", folder.Version);
try try

View File

@ -834,7 +834,10 @@ namespace OpenSim.Data.MySQL
// explicit conversion of integers is required, which sort // explicit conversion of integers is required, which sort
// of sucks. No idea if there is a shortcut here or not. // of sucks. No idea if there is a shortcut here or not.
prim.CreationDate = Convert.ToInt32(row["CreationDate"]); prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
prim.Name = (String) row["Name"]; if (row["Name"] != DBNull.Value)
prim.Name = (String)row["Name"];
else
prim.Name = string.Empty;
// various text fields // various text fields
prim.Text = (String) row["Text"]; prim.Text = (String) row["Text"];
prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),
@ -945,12 +948,12 @@ namespace OpenSim.Data.MySQL
prim.DIE_AT_EDGE = true; prim.DIE_AT_EDGE = true;
prim.SalePrice = Convert.ToInt32(row["SalePrice"]); prim.SalePrice = Convert.ToInt32(row["SalePrice"]);
prim.ObjectSaleType = Convert.ToByte(row["SaleType"]); prim.ObjectSaleType = unchecked((byte)Convert.ToSByte(row["SaleType"]));
prim.Material = Convert.ToByte(row["Material"]); prim.Material = unchecked((byte)Convert.ToSByte(row["Material"]));
if (!(row["ClickAction"] is DBNull)) if (!(row["ClickAction"] is DBNull))
prim.ClickAction = (byte)Convert.ToByte(row["ClickAction"]); prim.ClickAction = unchecked((byte)Convert.ToSByte(row["ClickAction"]));
prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); prim.CollisionSound = new UUID(row["CollisionSound"].ToString());
prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]);
@ -1277,12 +1280,12 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("DieAtEdge", 0); cmd.Parameters.AddWithValue("DieAtEdge", 0);
cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice); cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice);
cmd.Parameters.AddWithValue("SaleType", Convert.ToInt16(prim.ObjectSaleType)); cmd.Parameters.AddWithValue("SaleType", unchecked((sbyte)(prim.ObjectSaleType)));
byte clickAction = prim.ClickAction; byte clickAction = prim.ClickAction;
cmd.Parameters.AddWithValue("ClickAction", clickAction); cmd.Parameters.AddWithValue("ClickAction", unchecked((sbyte)(clickAction)));
cmd.Parameters.AddWithValue("Material", prim.Material); cmd.Parameters.AddWithValue("Material", unchecked((sbyte)(prim.Material)));
cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString()); cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString());
cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume); cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume);

View File

@ -62,11 +62,18 @@ namespace OpenSim.Data.MySQL.Tests
m_log.Error("Exception {0}", e); m_log.Error("Exception {0}", e);
Assert.Ignore(); Assert.Ignore();
} }
// This actually does the roll forward assembly stuff
Assembly assem = GetType().Assembly;
Migration m = new Migration(database.Connection, assem, "GridStore");
m.Update();
} }
[TestFixtureTearDown] [TestFixtureTearDown]
public void Cleanup() public void Cleanup()
{ {
m_log.Warn("Cleaning up.");
if (db != null) if (db != null)
{ {
db.Dispose(); db.Dispose();
@ -74,6 +81,7 @@ namespace OpenSim.Data.MySQL.Tests
// if a new table is added, it has to be dropped here // if a new table is added, it has to be dropped here
if (database != null) if (database != null)
{ {
database.ExecuteSql("drop table migrations");
database.ExecuteSql("drop table regions"); database.ExecuteSql("drop table regions");
} }
} }

View File

@ -53,6 +53,7 @@ namespace OpenSim.Data.MySQL.Tests
try try
{ {
database = new MySQLManager(connect); database = new MySQLManager(connect);
DropTables();
db = new MySQLInventoryData(); db = new MySQLInventoryData();
db.Initialise(connect); db.Initialise(connect);
} }
@ -72,10 +73,15 @@ namespace OpenSim.Data.MySQL.Tests
} }
if (database != null) if (database != null)
{ {
database.ExecuteSql("drop table inventoryitems"); DropTables();
database.ExecuteSql("drop table inventoryfolders");
database.ExecuteSql("drop table migrations");
} }
} }
private void DropTables()
{
database.ExecuteSql("drop table IF EXISTS inventoryitems");
database.ExecuteSql("drop table IF EXISTS inventoryfolders");
database.ExecuteSql("drop table IF EXISTS migrations");
}
} }
} }

View File

@ -183,7 +183,7 @@ namespace OpenSim.Data.SQLite
int assetLength = (asset.Data != null) ? asset.Data.Length : 0; int assetLength = (asset.Data != null) ? asset.Data.Length : 0;
m_log.Info("[ASSET DB]: " + m_log.Info("[ASSET DB]: " +
string.Format("Loaded {6} {5} Asset: [{0}][{3}] \"{1}\":{2} ({7} bytes)", string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)",
asset.FullID, asset.Name, asset.Description, asset.Type, asset.FullID, asset.Name, asset.Description, asset.Type,
temporary, local, assetLength)); temporary, local, assetLength));
} }

View File

@ -301,7 +301,8 @@ namespace OpenSim.Data.SQLite
DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
inventoryRow = inventoryFolderTable.Rows.Find(item.Folder.ToString()); inventoryRow = inventoryFolderTable.Rows.Find(item.Folder.ToString());
inventoryRow["version"] = (int)inventoryRow["version"] + 1; if (inventoryRow != null) //MySQL doesn't throw an exception here, so sqlite shouldn't either.
inventoryRow["version"] = (int)inventoryRow["version"] + 1;
invFoldersDa.Update(ds, "inventoryfolders"); invFoldersDa.Update(ds, "inventoryfolders");
} }

View File

@ -307,26 +307,21 @@ namespace OpenSim.Data.SQLite
/// <param name="regionUUID">the region UUID</param> /// <param name="regionUUID">the region UUID</param>
public void StoreObject(SceneObjectGroup obj, UUID regionUUID) public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
{ {
uint flags = obj.RootPart.GetEffectiveObjectFlags();
// Eligibility check
//
if ((flags & (uint)PrimFlags.Temporary) != 0)
return;
if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0)
return;
lock (ds) lock (ds)
{ {
foreach (SceneObjectPart prim in obj.Children.Values) foreach (SceneObjectPart prim in obj.Children.Values)
{ {
if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
&& (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0) addPrim(prim, obj.UUID, regionUUID);
{
m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
addPrim(prim, obj.UUID, regionUUID);
}
else if (prim.Stopped)
{
//m_log.Info("[DATASTORE]: " +
//"Adding stopped obj: " + obj.UUID + " to region: " + regionUUID);
//addPrim(prim, obj.UUID.ToString(), regionUUID.ToString());
}
else
{
// m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID);
}
} }
} }
@ -1130,7 +1125,7 @@ namespace OpenSim.Data.SQLite
// explicit conversion of integers is required, which sort // explicit conversion of integers is required, which sort
// of sucks. No idea if there is a shortcut here or not. // of sucks. No idea if there is a shortcut here or not.
prim.CreationDate = Convert.ToInt32(row["CreationDate"]); prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
prim.Name = (String) row["Name"]; prim.Name = row["Name"] == DBNull.Value ? string.Empty : (string)row["Name"];
// various text fields // various text fields
prim.Text = (String) row["Text"]; prim.Text = (String) row["Text"];
prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),

View File

@ -26,20 +26,19 @@
*/ */
using System; using System;
using System.Collections.Generic;
using log4net.Config; using log4net.Config;
using NUnit.Framework; using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers; using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using log4net; using log4net;
using System.Reflection;
namespace OpenSim.Data.Tests namespace OpenSim.Data.Tests
{ {
public class BasicAssetTest public class BasicAssetTest
{ {
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public IAssetDataPlugin db;
public AssetDataBase db;
public UUID uuid1; public UUID uuid1;
public UUID uuid2; public UUID uuid2;
public UUID uuid3; public UUID uuid3;
@ -47,14 +46,7 @@ namespace OpenSim.Data.Tests
public void SuperInit() public void SuperInit()
{ {
try OpenSim.Tests.Common.TestLogging.LogToConsole();
{
XmlConfigurator.Configure();
}
catch (Exception)
{
// I don't care, just leave log4net off
}
uuid1 = UUID.Random(); uuid1 = UUID.Random();
uuid2 = UUID.Random(); uuid2 = UUID.Random();
@ -81,41 +73,59 @@ namespace OpenSim.Data.Tests
a2.Data = asset1; a2.Data = asset1;
a3.Data = asset1; a3.Data = asset1;
PropertyScrambler<AssetBase> scrambler = new PropertyScrambler<AssetBase>()
.DontScramble(x => x.Data)
.DontScramble(x => x.ID)
.DontScramble(x => x.FullID)
.DontScramble(x => x.Metadata.ID)
.DontScramble(x => x.Metadata.FullID);
scrambler.Scramble(a1);
scrambler.Scramble(a2);
scrambler.Scramble(a3);
db.CreateAsset(a1); db.CreateAsset(a1);
db.CreateAsset(a2); db.CreateAsset(a2);
db.CreateAsset(a3); db.CreateAsset(a3);
AssetBase a1a = db.FetchAsset(uuid1); AssetBase a1a = db.FetchAsset(uuid1);
Assert.That(a1.ID, Is.EqualTo(a1a.ID), "Assert.That(a1.ID, Is.EqualTo(a1a.ID))"); Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
Assert.That(a1.Name, Is.EqualTo(a1a.Name), "Assert.That(a1.Name, Is.EqualTo(a1a.Name))");
AssetBase a2a = db.FetchAsset(uuid2); AssetBase a2a = db.FetchAsset(uuid2);
Assert.That(a2.ID, Is.EqualTo(a2a.ID), "Assert.That(a2.ID, Is.EqualTo(a2a.ID))"); Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
Assert.That(a2.Name, Is.EqualTo(a2a.Name), "Assert.That(a2.Name, Is.EqualTo(a2a.Name))");
AssetBase a3a = db.FetchAsset(uuid3); AssetBase a3a = db.FetchAsset(uuid3);
Assert.That(a3.ID, Is.EqualTo(a3a.ID), "Assert.That(a3.ID, Is.EqualTo(a3a.ID))"); Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
Assert.That(a3.Name, Is.EqualTo(a3a.Name), "Assert.That(a3.Name, Is.EqualTo(a3a.Name))");
} scrambler.Scramble(a1a);
scrambler.Scramble(a2a);
scrambler.Scramble(a3a);
db.UpdateAsset(a1a);
db.UpdateAsset(a2a);
db.UpdateAsset(a3a);
AssetBase a1b = db.FetchAsset(uuid1);
Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a));
AssetBase a2b = db.FetchAsset(uuid2);
Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a));
AssetBase a3b = db.FetchAsset(uuid3);
Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a));
[Test]
public void T011_ExistsSimpleAsset()
{
Assert.That(db.ExistsAsset(uuid1), Is.True); Assert.That(db.ExistsAsset(uuid1), Is.True);
Assert.That(db.ExistsAsset(uuid2), Is.True); Assert.That(db.ExistsAsset(uuid2), Is.True);
Assert.That(db.ExistsAsset(uuid3), Is.True); Assert.That(db.ExistsAsset(uuid3), Is.True);
}
// this has questionable use, but it is in the interface at the moment. List<AssetMetadata> metadatas = db.FetchAssetMetadataSet(0, 1000);
// [Test]
// public void T012_DeleteAsset() AssetMetadata metadata = metadatas.Find(x => x.FullID == uuid1);
// { Assert.That(metadata.Name, Is.EqualTo(a1b.Name));
// db.DeleteAsset(uuid1); Assert.That(metadata.Description, Is.EqualTo(a1b.Description));
// db.DeleteAsset(uuid2); Assert.That(metadata.Type, Is.EqualTo(a1b.Type));
// db.DeleteAsset(uuid3); Assert.That(metadata.Temporary, Is.EqualTo(a1b.Temporary));
// Assert.That(db.ExistsAsset(uuid1), Is.False); Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID));
// Assert.That(db.ExistsAsset(uuid2), Is.False); }
// Assert.That(db.ExistsAsset(uuid3), Is.False);
// }
} }
} }

View File

@ -40,7 +40,6 @@ namespace OpenSim.Data.Tests
{ {
public class BasicEstateTest public class BasicEstateTest
{ {
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public IEstateDataStore db; public IEstateDataStore db;
public IRegionDataStore regionDb; public IRegionDataStore regionDb;
@ -57,14 +56,7 @@ namespace OpenSim.Data.Tests
public void SuperInit() public void SuperInit()
{ {
try OpenSim.Tests.Common.TestLogging.LogToConsole();
{
XmlConfigurator.Configure();
}
catch (Exception)
{
// I don't care, just leave log4net off
}
} }
#region 0Tests #region 0Tests
@ -162,6 +154,24 @@ namespace OpenSim.Data.Tests
); );
} }
[Test]
private void T012_EstateSettingsRandomStorage()
{
// Letting estate store generate rows to database for us
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
new PropertyScrambler<EstateSettings>().Scramble(originalSettings);
// Saving settings.
db.StoreEstateSettings(originalSettings);
// Loading settings to another instance variable.
EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
// Checking that loaded values are correct.
Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
}
[Test] [Test]
public void T020_EstateSettingsManagerList() public void T020_EstateSettingsManagerList()
{ {

View File

@ -28,81 +28,47 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using log4net.Config;
using NUnit.Framework; using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers; using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse; using OpenMetaverse;
using log4net;
using System.Reflection;
namespace OpenSim.Data.Tests namespace OpenSim.Data.Tests
{ {
public class BasicGridTest public class BasicGridTest
{ {
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public IGridDataPlugin db;
public GridDataBase db;
public UUID region1, region2, region3; public UUID region1, region2, region3;
public UUID zero = UUID.Zero; public UUID zero = UUID.Zero;
public static Random random; public static Random random = new Random();
[TearDown] [TearDown]
public void removeAllRegions() public void removeAllRegions()
{ {
// Clean up all the regions. // Clean up all the regions.
foreach (RegionProfileData region in db.GetRegionsByName("", 100)) List<RegionProfileData> regions = db.GetRegionsByName("", 100);
if (regions != null)
{ {
db.DeleteProfile(region.Uuid.ToString()); foreach (RegionProfileData region in regions)
{
db.DeleteProfile(region.Uuid.ToString());
}
} }
} }
public void SuperInit() public void SuperInit()
{ {
try OpenSim.Tests.Common.TestLogging.LogToConsole();
{
XmlConfigurator.Configure();
}
catch (Exception)
{
// I don't care, just leave log4net off
}
region1 = UUID.Random(); region1 = UUID.Random();
region2 = UUID.Random(); region2 = UUID.Random();
region3 = UUID.Random(); region3 = UUID.Random();
random = new Random();
} }
protected RegionProfileData createRegion(UUID regionUUID, string regionName) protected RegionProfileData createRegion(UUID regionUUID, string regionName)
{ {
RegionProfileData reg = new RegionProfileData(); RegionProfileData reg = new RegionProfileData();
new PropertyScrambler<RegionProfileData>().Scramble(reg);
reg.Uuid = regionUUID; reg.Uuid = regionUUID;
reg.RegionName = regionName; reg.RegionName = regionName;
reg.RegionHandle = (ulong) random.Next();
reg.RegionLocX = (uint) random.Next();
reg.RegionLocY = (uint) random.Next();
reg.RegionLocZ = (uint) random.Next();
reg.RegionSendKey = RandomName();
reg.RegionRecvKey = RandomName();
reg.RegionSecret = RandomName();
reg.RegionOnline = false;
reg.ServerIP = RandomName();
reg.ServerPort = (uint) random.Next();
reg.ServerURI = RandomName();
reg.ServerHttpPort = (uint) random.Next();
reg.ServerRemotingPort = (uint) random.Next();
reg.NorthOverrideHandle = (ulong) random.Next();
reg.SouthOverrideHandle = (ulong) random.Next();
reg.EastOverrideHandle = (ulong) random.Next();
reg.WestOverrideHandle = (ulong) random.Next();
reg.RegionDataURI = RandomName();
reg.RegionAssetURI = RandomName();
reg.RegionAssetSendKey = RandomName();
reg.RegionAssetRecvKey = RandomName();
reg.RegionUserURI = RandomName();
reg.RegionUserSendKey = RandomName();
reg.RegionUserRecvKey = RandomName();
reg.RegionMapTextureID = UUID.Random();
reg.Owner_uuid = UUID.Random();
reg.OriginUUID = UUID.Random();
db.AddProfile(reg); db.AddProfile(reg);
@ -118,48 +84,13 @@ namespace OpenSim.Data.Tests
Assert.That(db.GetProfileByUUID(zero),Is.Null); Assert.That(db.GetProfileByUUID(zero),Is.Null);
} }
[Test]
public void T999_StillNull()
{
Assert.That(db.GetProfileByUUID(zero),Is.Null);
}
[Test] [Test]
public void T011_AddRetrieveCompleteTest() public void T011_AddRetrieveCompleteTest()
{ {
RegionProfileData newreg = createRegion(region2, "|<Goth@m Ci1y>|"); RegionProfileData newreg = createRegion(region2, "|<Goth@m Ci1y>|");
RegionProfileData retreg = db.GetProfileByUUID(region2); RegionProfileData retreg = db.GetProfileByUUID(region2);
Assert.That(retreg.RegionName, Is.EqualTo(newreg.RegionName), "Assert.That(retreg.RegionName, Is.EqualTo(newreg.RegionName))"); Assert.That(retreg, Constraints.PropertyCompareConstraint(newreg).IgnoreProperty(x => x.RegionOnline));
Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))");
Assert.That(retreg.RegionHandle, Is.EqualTo(newreg.RegionHandle), "Assert.That(retreg.RegionHandle, Is.EqualTo(newreg.RegionHandle))");
Assert.That(retreg.RegionLocX, Is.EqualTo(newreg.RegionLocX), "Assert.That(retreg.RegionLocX, Is.EqualTo(newreg.RegionLocX))");
Assert.That(retreg.RegionLocY, Is.EqualTo(newreg.RegionLocY), "Assert.That(retreg.RegionLocY, Is.EqualTo(newreg.RegionLocY))");
Assert.That(retreg.RegionLocZ, Is.EqualTo(newreg.RegionLocZ), "Assert.That(retreg.RegionLocZ, Is.EqualTo(newreg.RegionLocZ))");
Assert.That(retreg.RegionSendKey, Is.EqualTo(newreg.RegionSendKey), "Assert.That(retreg.RegionSendKey, Is.EqualTo(newreg.RegionSendKey))");
Assert.That(retreg.RegionRecvKey, Is.EqualTo(newreg.RegionRecvKey), "Assert.That(retreg.RegionRecvKey, Is.EqualTo(newreg.RegionRecvKey))");
Assert.That(retreg.RegionSecret, Is.EqualTo(newreg.RegionSecret), "Assert.That(retreg.RegionSecret, Is.EqualTo(newreg.RegionSecret))");
Assert.That(retreg.RegionOnline, Is.EqualTo(newreg.RegionOnline), "Assert.That(retreg.RegionOnline, Is.EqualTo(newreg.RegionOnline))");
Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID), "Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID))");
Assert.That(retreg.ServerIP, Is.EqualTo(newreg.ServerIP), "Assert.That(retreg.ServerIP, Is.EqualTo(newreg.ServerIP))");
Assert.That(retreg.ServerPort, Is.EqualTo(newreg.ServerPort), "Assert.That(retreg.ServerPort, Is.EqualTo(newreg.ServerPort))");
Assert.That(retreg.ServerURI, Is.EqualTo(newreg.ServerURI), "Assert.That(retreg.ServerURI, Is.EqualTo(newreg.ServerURI))");
Assert.That(retreg.ServerHttpPort, Is.EqualTo(newreg.ServerHttpPort), "Assert.That(retreg.ServerHttpPort, Is.EqualTo(newreg.ServerHttpPort))");
Assert.That(retreg.ServerRemotingPort, Is.EqualTo(newreg.ServerRemotingPort), "Assert.That(retreg.ServerRemotingPort, Is.EqualTo(newreg.ServerRemotingPort))");
Assert.That(retreg.NorthOverrideHandle, Is.EqualTo(newreg.NorthOverrideHandle), "Assert.That(retreg.NorthOverrideHandle, Is.EqualTo(newreg.NorthOverrideHandle))");
Assert.That(retreg.SouthOverrideHandle, Is.EqualTo(newreg.SouthOverrideHandle), "Assert.That(retreg.SouthOverrideHandle, Is.EqualTo(newreg.SouthOverrideHandle))");
Assert.That(retreg.EastOverrideHandle, Is.EqualTo(newreg.EastOverrideHandle), "Assert.That(retreg.EastOverrideHandle, Is.EqualTo(newreg.EastOverrideHandle))");
Assert.That(retreg.WestOverrideHandle, Is.EqualTo(newreg.WestOverrideHandle), "Assert.That(retreg.WestOverrideHandle, Is.EqualTo(newreg.WestOverrideHandle))");
Assert.That(retreg.RegionDataURI, Is.EqualTo(newreg.RegionDataURI), "Assert.That(retreg.RegionDataURI, Is.EqualTo(newreg.RegionDataURI))");
Assert.That(retreg.RegionAssetURI, Is.EqualTo(newreg.RegionAssetURI), "Assert.That(retreg.RegionAssetURI, Is.EqualTo(newreg.RegionAssetURI))");
Assert.That(retreg.RegionAssetSendKey, Is.EqualTo(newreg.RegionAssetSendKey), "Assert.That(retreg.RegionAssetSendKey, Is.EqualTo(newreg.RegionAssetSendKey))");
Assert.That(retreg.RegionAssetRecvKey, Is.EqualTo(newreg.RegionAssetRecvKey), "Assert.That(retreg.RegionAssetRecvKey, Is.EqualTo(newreg.RegionAssetRecvKey))");
Assert.That(retreg.RegionUserURI, Is.EqualTo(newreg.RegionUserURI), "Assert.That(retreg.RegionUserURI, Is.EqualTo(newreg.RegionUserURI))");
Assert.That(retreg.RegionUserSendKey, Is.EqualTo(newreg.RegionUserSendKey), "Assert.That(retreg.RegionUserSendKey, Is.EqualTo(newreg.RegionUserSendKey))");
Assert.That(retreg.RegionUserRecvKey, Is.EqualTo(newreg.RegionUserRecvKey), "Assert.That(retreg.RegionUserRecvKey, Is.EqualTo(newreg.RegionUserRecvKey))");
Assert.That(retreg.RegionMapTextureID, Is.EqualTo(newreg.RegionMapTextureID), "Assert.That(retreg.RegionMapTextureID, Is.EqualTo(newreg.RegionMapTextureID))");
Assert.That(retreg.Owner_uuid, Is.EqualTo(newreg.Owner_uuid), "Assert.That(retreg.Owner_uuid, Is.EqualTo(newreg.Owner_uuid))");
Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID), "Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID))");
retreg = db.GetProfileByHandle(newreg.RegionHandle); retreg = db.GetProfileByHandle(newreg.RegionHandle);
Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))"); Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))");
@ -220,6 +151,12 @@ namespace OpenSim.Data.Tests
Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))"); Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))");
} }
[Test]
public void T999_StillNull()
{
Assert.That(db.GetProfileByUUID(zero), Is.Null);
}
protected static string RandomName() protected static string RandomName()
{ {
StringBuilder name = new StringBuilder(); StringBuilder name = new StringBuilder();

View File

@ -66,14 +66,7 @@ namespace OpenSim.Data.Tests
public void SuperInit() public void SuperInit()
{ {
try OpenSim.Tests.Common.TestLogging.LogToConsole();
{
XmlConfigurator.Configure();
}
catch (Exception)
{
// I don't care, just leave log4net off
}
folder1 = UUID.Random(); folder1 = UUID.Random();
folder2 = UUID.Random(); folder2 = UUID.Random();
@ -115,16 +108,6 @@ namespace OpenSim.Data.Tests
Assert.That(db.getUserRootFolder(owner1), Is.Null); Assert.That(db.getUserRootFolder(owner1), Is.Null);
} }
[Test]
public void T999_StillNull()
{
// After all tests are run, these should still return no results
Assert.That(db.getInventoryFolder(zero), Is.Null);
Assert.That(db.getInventoryItem(zero), Is.Null);
Assert.That(db.getUserRootFolder(zero), Is.Null);
Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
}
// 01x - folder tests // 01x - folder tests
[Test] [Test]
public void T010_FolderNonParent() public void T010_FolderNonParent()
@ -248,7 +231,7 @@ namespace OpenSim.Data.Tests
} }
[Test] [Test]
public void T103UpdateItem() public void T103_UpdateItem()
{ {
// TODO: probably shouldn't have the ability to have an // TODO: probably shouldn't have the ability to have an
// owner of an item in a folder not owned by the user // owner of an item in a folder not owned by the user
@ -265,6 +248,71 @@ namespace OpenSim.Data.Tests
Assert.That(i1.Owner, Is.EqualTo(owner2), "Assert.That(i1.Owner, Is.EqualTo(owner2))"); Assert.That(i1.Owner, Is.EqualTo(owner2), "Assert.That(i1.Owner, Is.EqualTo(owner2))");
} }
[Test]
public void T104_RandomUpdateItem()
{
PropertyScrambler<InventoryFolderBase> folderScrambler =
new PropertyScrambler<InventoryFolderBase>()
.DontScramble(x => x.Owner)
.DontScramble(x => x.ParentID)
.DontScramble(x => x.ID);
UUID owner = UUID.Random();
UUID folder = UUID.Random();
UUID rootId = UUID.Random();
UUID rootAsset = UUID.Random();
InventoryFolderBase f1 = NewFolder(folder, zero, owner, name1);
folderScrambler.Scramble(f1);
db.addInventoryFolder(f1);
InventoryFolderBase f1a = db.getUserRootFolder(owner);
Assert.That(f1a, Constraints.PropertyCompareConstraint(f1));
folderScrambler.Scramble(f1a);
db.updateInventoryFolder(f1a);
InventoryFolderBase f1b = db.getUserRootFolder(owner);
Assert.That(f1b, Constraints.PropertyCompareConstraint(f1a));
//Now we have a valid folder to insert into, we can insert the item.
PropertyScrambler<InventoryItemBase> inventoryScrambler =
new PropertyScrambler<InventoryItemBase>()
.DontScramble(x => x.ID)
.DontScramble(x => x.AssetID)
.DontScramble(x => x.Owner)
.DontScramble(x => x.Folder);
InventoryItemBase root = NewItem(rootId, folder, owner, iname1, rootAsset);
inventoryScrambler.Scramble(root);
db.addInventoryItem(root);
InventoryItemBase expected = db.getInventoryItem(rootId);
Assert.That(expected, Constraints.PropertyCompareConstraint(root)
.IgnoreProperty(x => x.InvType)
.IgnoreProperty(x => x.CreatorIdAsUuid)
.IgnoreProperty(x => x.Description)
.IgnoreProperty(x => x.CreatorId));
inventoryScrambler.Scramble(expected);
db.updateInventoryItem(expected);
InventoryItemBase actual = db.getInventoryItem(rootId);
Assert.That(actual, Constraints.PropertyCompareConstraint(expected)
.IgnoreProperty(x => x.InvType)
.IgnoreProperty(x => x.CreatorIdAsUuid)
.IgnoreProperty(x => x.Description)
.IgnoreProperty(x => x.CreatorId));
}
[Test]
public void T999_StillNull()
{
// After all tests are run, these should still return no results
Assert.That(db.getInventoryFolder(zero), Is.Null);
Assert.That(db.getInventoryItem(zero), Is.Null);
Assert.That(db.getUserRootFolder(zero), Is.Null);
Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
}
private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset) private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset)
{ {
InventoryItemBase i = new InventoryItemBase(); InventoryItemBase i = new InventoryItemBase();

View File

@ -71,14 +71,7 @@ namespace OpenSim.Data.Tests
public void SuperInit() public void SuperInit()
{ {
try OpenSim.Tests.Common.TestLogging.LogToConsole();
{
XmlConfigurator.Configure();
}
catch (Exception)
{
// I don't care, just leave log4net off
}
region1 = UUID.Random(); region1 = UUID.Random();
region3 = UUID.Random(); region3 = UUID.Random();
@ -533,6 +526,62 @@ namespace OpenSim.Data.Tests
} }
} }
[Test]
public void T016_RandomSogWithSceneParts()
{
PropertyScrambler<SceneObjectPart> scrambler =
new PropertyScrambler<SceneObjectPart>()
.DontScramble(x => x.UUID);
UUID tmpSog = UUID.Random();
UUID tmp1 = UUID.Random();
UUID tmp2 = UUID.Random();
UUID tmp3 = UUID.Random();
UUID newregion = UUID.Random();
SceneObjectPart p1 = new SceneObjectPart();
SceneObjectPart p2 = new SceneObjectPart();
SceneObjectPart p3 = new SceneObjectPart();
p1.Shape = PrimitiveBaseShape.Default;
p2.Shape = PrimitiveBaseShape.Default;
p3.Shape = PrimitiveBaseShape.Default;
p1.UUID = tmp1;
p2.UUID = tmp2;
p3.UUID = tmp3;
scrambler.Scramble(p1);
scrambler.Scramble(p2);
scrambler.Scramble(p3);
SceneObjectGroup sog = NewSOG("Sop 0", tmpSog, newregion);
PropertyScrambler<SceneObjectGroup> sogScrambler =
new PropertyScrambler<SceneObjectGroup>()
.DontScramble(x => x.UUID);
sogScrambler.Scramble(sog);
sog.UUID = tmpSog;
sog.AddPart(p1);
sog.AddPart(p2);
sog.AddPart(p3);
SceneObjectPart[] parts = sog.GetParts();
Assert.That(parts.Length, Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))");
db.StoreObject(sog, newregion);
List<SceneObjectGroup> sogs = db.LoadObjects(newregion);
Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))");
SceneObjectGroup newsog = sogs[0];
SceneObjectPart[] newparts = newsog.GetParts();
Assert.That(newparts.Length, Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))");
Assert.That(newsog, Constraints.PropertyCompareConstraint(sog)
.IgnoreProperty(x=>x.LocalId)
.IgnoreProperty(x=>x.HasGroupChanged)
.IgnoreProperty(x=>x.IsSelected)
.IgnoreProperty(x=>x.RegionHandle)
.IgnoreProperty(x=>x.RegionUUID)
.IgnoreProperty(x=>x.Scene)
.IgnoreProperty(x=>x.Children)
.IgnoreProperty(x=>x.RootPart));
}
[Test] [Test]
public void T020_PrimInventoryEmpty() public void T020_PrimInventoryEmpty()
{ {

View File

@ -71,14 +71,7 @@ namespace OpenSim.Data.Tests
public void SuperInit() public void SuperInit()
{ {
try OpenSim.Tests.Common.TestLogging.LogToConsole();
{
XmlConfigurator.Configure();
}
catch (Exception)
{
// I don't care, just leave log4net off
}
random = new Random(); random = new Random();
user1 = UUID.Random(); user1 = UUID.Random();
user2 = UUID.Random(); user2 = UUID.Random();
@ -117,13 +110,6 @@ namespace OpenSim.Data.Tests
Assert.That(db.GetAgentByUUID(UUID.Random()), Is.Null); Assert.That(db.GetAgentByUUID(UUID.Random()), Is.Null);
} }
[Test]
public void T999_StillNull()
{
Assert.That(db.GetUserByUUID(zero), Is.Null);
Assert.That(db.GetAgentByUUID(zero), Is.Null);
}
[Test] [Test]
public void T010_CreateUser() public void T010_CreateUser()
{ {
@ -397,6 +383,22 @@ namespace OpenSim.Data.Tests
Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))"); Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))");
} }
[Test]
public void T017_UserUpdateRandomPersistency()
{
UUID id = user5;
UserProfileData u = db.GetUserByUUID(id);
new PropertyScrambler<UserProfileData>().DontScramble(x=>x.ID).Scramble(u);
db.UpdateUserProfile(u);
UserProfileData u1a = db.GetUserByUUID(id);
Assert.That(u1a, Constraints.PropertyCompareConstraint(u)
.IgnoreProperty(x=>x.HomeRegionX)
.IgnoreProperty(x=>x.HomeRegionY)
.IgnoreProperty(x=>x.RootInventoryFolderID)
);
}
[Test] [Test]
public void T020_CreateAgent() public void T020_CreateAgent()
{ {
@ -660,6 +662,13 @@ namespace OpenSim.Data.Tests
Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight), "Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight))"); Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight), "Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight))");
} }
[Test]
public void T999_StillNull()
{
Assert.That(db.GetUserByUUID(zero), Is.Null);
Assert.That(db.GetAgentByUUID(zero), Is.Null);
}
public UserProfileData NewUser(UUID id,string fname,string lname) public UserProfileData NewUser(UUID id,string fname,string lname)
{ {
UserProfileData u = new UserProfileData(); UserProfileData u = new UserProfileData();

View File

@ -69,6 +69,28 @@ namespace OpenSim.Data.Tests
private bool ObjectCompare(object expected, object actual, Stack<string> propertyNames) private bool ObjectCompare(object expected, object actual, Stack<string> propertyNames)
{ {
//If they are both null, they are equal
if (actual == null && expected == null)
return true;
//If only one is null, then they aren't
if (actual == null || expected == null)
{
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
failingActual = actual;
failingExpected = expected;
return false;
}
//prevent loops...
if (propertyNames.Count > 50)
{
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
failingActual = actual;
failingExpected = expected;
return false;
}
if (actual.GetType() != expected.GetType()) if (actual.GetType() != expected.GetType())
{ {
propertyNames.Push("GetType()"); propertyNames.Push("GetType()");
@ -122,6 +144,60 @@ namespace OpenSim.Data.Tests
return true; return true;
} }
IComparable comp = actual as IComparable;
if (comp != null)
{
if (comp.CompareTo(expected) != 0)
{
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
failingActual = actual;
failingExpected = expected;
return false;
}
return true;
}
//Now try the much more annoying IComparable<T>
Type icomparableInterface = actual.GetType().GetInterface("IComparable`1");
if (icomparableInterface != null)
{
int result = (int)icomparableInterface.GetMethod("CompareTo").Invoke(actual, new[] { expected });
if (result != 0)
{
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
failingActual = actual;
failingExpected = expected;
return false;
}
return true;
}
IEnumerable arr = actual as IEnumerable;
if (arr != null)
{
List<object> actualList = arr.Cast<object>().ToList();
List<object> expectedList = ((IEnumerable)expected).Cast<object>().ToList();
if (actualList.Count != expectedList.Count)
{
propertyNames.Push("Count");
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
failingActual = actualList.Count;
failingExpected = expectedList.Count;
propertyNames.Pop();
return false;
}
//actualList and expectedList should be the same size.
for (int i = 0; i < actualList.Count; i++)
{
propertyNames.Push("[" + i + "]");
if (!ObjectCompare(expectedList[i], actualList[i], propertyNames))
return false;
propertyNames.Pop();
}
//Everything seems okay...
return true;
}
//Skip static properties. I had a nasty problem comparing colors because of all of the public static colors. //Skip static properties. I had a nasty problem comparing colors because of all of the public static colors.
PropertyInfo[] properties = expected.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); PropertyInfo[] properties = expected.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (var property in properties) foreach (var property in properties)
@ -132,56 +208,6 @@ namespace OpenSim.Data.Tests
object actualValue = property.GetValue(actual, null); object actualValue = property.GetValue(actual, null);
object expectedValue = property.GetValue(expected, null); object expectedValue = property.GetValue(expected, null);
//If they are both null, they are equal
if (actualValue == null && expectedValue == null)
continue;
//If only one is null, then they aren't
if (actualValue == null || expectedValue == null)
{
propertyNames.Push(property.Name);
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
propertyNames.Pop();
failingActual = actualValue;
failingExpected = expectedValue;
return false;
}
IComparable comp = actualValue as IComparable;
if (comp != null)
{
if (comp.CompareTo(expectedValue) != 0)
{
propertyNames.Push(property.Name);
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
propertyNames.Pop();
failingActual = actualValue;
failingExpected = expectedValue;
return false;
}
continue;
}
IEnumerable arr = actualValue as IEnumerable;
if (arr != null)
{
List<object> actualList = arr.Cast<object>().ToList();
List<object> expectedList = ((IEnumerable)expectedValue).Cast<object>().ToList();
if (actualList.Count != expectedList.Count)
{
propertyNames.Push(property.Name);
propertyNames.Push("Count");
failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
failingActual = actualList.Count;
failingExpected = expectedList.Count;
propertyNames.Pop();
propertyNames.Pop();
}
//Todo: A value-wise comparison of all of the values.
//Everything seems okay...
continue;
}
propertyNames.Push(property.Name); propertyNames.Push(property.Name);
if (!ObjectCompare(expectedValue, actualValue, propertyNames)) if (!ObjectCompare(expectedValue, actualValue, propertyNames))
return false; return false;
@ -223,15 +249,7 @@ namespace OpenSim.Data.Tests
{ {
//If the inside of the lambda is the access to x, we've hit the end of the chain. //If the inside of the lambda is the access to x, we've hit the end of the chain.
// We should track by the fully scoped parameter name, but this is the first rev of doing this. // We should track by the fully scoped parameter name, but this is the first rev of doing this.
if (((MemberExpression)express).Expression is ParameterExpression) ignores.Add(((MemberExpression)express).Member.Name);
{
ignores.Add(((MemberExpression)express).Member.Name);
}
else
{
//Otherwise there could be more parameters inside...
PullApartExpression(((MemberExpression)express).Expression);
}
} }
} }
} }
@ -270,7 +288,7 @@ namespace OpenSim.Data.Tests
{ {
HasInt actual = new HasInt { TheValue = 5 }; HasInt actual = new HasInt { TheValue = 5 };
HasInt expected = new HasInt { TheValue = 4 }; HasInt expected = new HasInt { TheValue = 4 };
var constraint = Constraints.PropertyCompareConstraint(expected).IgnoreProperty(x=>x.TheValue); var constraint = Constraints.PropertyCompareConstraint(expected).IgnoreProperty(x => x.TheValue);
Assert.That(constraint.Matches(actual), Is.True); Assert.That(constraint.Matches(actual), Is.True);
} }
@ -311,6 +329,28 @@ namespace OpenSim.Data.Tests
Assert.That(constraint.Matches(actual), Is.False); Assert.That(constraint.Matches(actual), Is.False);
} }
[Test]
public void UUIDShouldMatch()
{
UUID uuid1 = UUID.Random();
UUID uuid2 = UUID.Parse(uuid1.ToString());
var constraint = Constraints.PropertyCompareConstraint(uuid1);
Assert.That(constraint.Matches(uuid2), Is.True);
}
[Test]
public void UUIDShouldNotMatch()
{
UUID uuid1 = UUID.Random();
UUID uuid2 = UUID.Random();
var constraint = Constraints.PropertyCompareConstraint(uuid1);
Assert.That(constraint.Matches(uuid2), Is.False);
}
[Test] [Test]
public void TestColors() public void TestColors()
{ {
@ -321,5 +361,53 @@ namespace OpenSim.Data.Tests
Assert.That(constraint.Matches(actual), Is.True); Assert.That(constraint.Matches(actual), Is.True);
} }
[Test]
public void ShouldCompareLists()
{
List<int> expected = new List<int> { 1, 2, 3 };
List<int> actual = new List<int> { 1, 2, 3 };
var constraint = Constraints.PropertyCompareConstraint(expected);
Assert.That(constraint.Matches(actual), Is.True);
}
[Test]
public void ShouldFailToCompareListsThatAreDifferent()
{
List<int> expected = new List<int> { 1, 2, 3 };
List<int> actual = new List<int> { 1, 2, 4 };
var constraint = Constraints.PropertyCompareConstraint(expected);
Assert.That(constraint.Matches(actual), Is.False);
}
[Test]
public void ShouldFailToCompareListsThatAreDifferentLengths()
{
List<int> expected = new List<int> { 1, 2, 3 };
List<int> actual = new List<int> { 1, 2 };
var constraint = Constraints.PropertyCompareConstraint(expected);
Assert.That(constraint.Matches(actual), Is.False);
}
public class Recursive
{
public Recursive Other { get; set; }
}
[Test]
public void ErrorsOutOnRecursive()
{
Recursive parent = new Recursive();
Recursive child = new Recursive();
parent.Other = child;
child.Other = parent;
var constraint = Constraints.PropertyCompareConstraint(child);
Assert.That(constraint.Matches(child), Is.False);
}
} }
} }

View File

@ -27,18 +27,58 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using NUnit.Framework; using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
namespace OpenSim.Data.Tests namespace OpenSim.Data.Tests
{ {
public static class ScrambleForTesting
//This is generic so that the lambda expressions will work right in IDEs.
public class PropertyScrambler<T>
{ {
private static readonly Random random = new Random(); readonly System.Collections.Generic.List<string> membersToNotScramble = new List<string>();
public static void Scramble(object obj)
private void AddExpressionToNotScrableList(Expression expression)
{
UnaryExpression unaryExpression = expression as UnaryExpression;
if (unaryExpression != null)
{
AddExpressionToNotScrableList(unaryExpression.Operand);
return;
}
MemberExpression memberExpression = expression as MemberExpression;
if (memberExpression != null)
{
if (!(memberExpression.Member is PropertyInfo))
{
throw new NotImplementedException("I don't know how deal with a MemberExpression that is a " + expression.Type);
}
membersToNotScramble.Add(memberExpression.Member.Name);
return;
}
throw new NotImplementedException("I don't know how to parse a " + expression.Type);
}
public PropertyScrambler<T> DontScramble(Expression<Func<T, object>> expression)
{
AddExpressionToNotScrableList(expression.Body);
return this;
}
public void Scramble(T obj)
{
internalScramble(obj);
}
private void internalScramble(object obj)
{ {
PropertyInfo[] properties = obj.GetType().GetProperties(); PropertyInfo[] properties = obj.GetType().GetProperties();
foreach (var property in properties) foreach (var property in properties)
@ -57,13 +97,16 @@ namespace OpenSim.Data.Tests
{ {
foreach (object value in enumerable) foreach (object value in enumerable)
{ {
Scramble(value); internalScramble(value);
} }
} }
} }
private static void RandomizeProperty(object obj, PropertyInfo property, object[] index) private readonly Random random = new Random();
{ private void RandomizeProperty(object obj, PropertyInfo property, object[] index)
{//I'd like a better way to compare, but I had lots of problems with InventoryFolderBase because the ID is inherited.
if (membersToNotScramble.Contains(property.Name))
return;
Type t = property.PropertyType; Type t = property.PropertyType;
if (!property.CanWrite) if (!property.CanWrite)
return; return;
@ -71,39 +114,39 @@ namespace OpenSim.Data.Tests
if (value == null) if (value == null)
return; return;
if (t == typeof (string)) if (t == typeof(string))
property.SetValue(obj, RandomName(), index); property.SetValue(obj, RandomName(), index);
else if (t == typeof (UUID)) else if (t == typeof(UUID))
property.SetValue(obj, UUID.Random(), index); property.SetValue(obj, UUID.Random(), index);
else if (t == typeof (sbyte)) else if (t == typeof(sbyte))
property.SetValue(obj, (sbyte)random.Next(sbyte.MinValue, sbyte.MaxValue), index); property.SetValue(obj, (sbyte)random.Next(sbyte.MinValue, sbyte.MaxValue), index);
else if (t == typeof (short)) else if (t == typeof(short))
property.SetValue(obj, (short)random.Next(short.MinValue, short.MaxValue), index); property.SetValue(obj, (short)random.Next(short.MinValue, short.MaxValue), index);
else if (t == typeof (int)) else if (t == typeof(int))
property.SetValue(obj, random.Next(), index); property.SetValue(obj, random.Next(), index);
else if (t == typeof (long)) else if (t == typeof(long))
property.SetValue(obj, random.Next() * int.MaxValue, index); property.SetValue(obj, random.Next() * int.MaxValue, index);
else if (t == typeof (byte)) else if (t == typeof(byte))
property.SetValue(obj, (byte)random.Next(byte.MinValue, byte.MaxValue), index); property.SetValue(obj, (byte)random.Next(byte.MinValue, byte.MaxValue), index);
else if (t == typeof (ushort)) else if (t == typeof(ushort))
property.SetValue(obj, (ushort)random.Next(ushort.MinValue, ushort.MaxValue), index); property.SetValue(obj, (ushort)random.Next(ushort.MinValue, ushort.MaxValue), index);
else if (t == typeof (uint)) else if (t == typeof(uint))
property.SetValue(obj, Convert.ToUInt32(random.Next()), index); property.SetValue(obj, Convert.ToUInt32(random.Next()), index);
else if (t == typeof (ulong)) else if (t == typeof(ulong))
property.SetValue(obj, Convert.ToUInt64(random.Next()) * Convert.ToUInt64(UInt32.MaxValue), index); property.SetValue(obj, Convert.ToUInt64(random.Next()) * Convert.ToUInt64(UInt32.MaxValue), index);
else if (t == typeof (bool)) else if (t == typeof(bool))
property.SetValue(obj, true, index); property.SetValue(obj, true, index);
else if (t == typeof (byte[])) else if (t == typeof(byte[]))
{ {
byte[] bytes = new byte[30]; byte[] bytes = new byte[30];
random.NextBytes(bytes); random.NextBytes(bytes);
property.SetValue(obj, bytes, index); property.SetValue(obj, bytes, index);
} }
else else
Scramble(value); internalScramble(value);
} }
private static string RandomName() private string RandomName()
{ {
StringBuilder name = new StringBuilder(); StringBuilder name = new StringBuilder();
int size = random.Next(5, 12); int size = random.Next(5, 12);
@ -117,13 +160,27 @@ namespace OpenSim.Data.Tests
} }
[TestFixture] [TestFixture]
public class ScrableForTestingTest public class PropertyScramblerTests
{ {
[Test] [Test]
public void TestScramble() public void TestScramble()
{ {
AssetBase actual = new AssetBase(UUID.Random(), "asset one"); AssetBase actual = new AssetBase(UUID.Random(), "asset one");
ScrambleForTesting.Scramble(actual); new PropertyScrambler<AssetBase>().Scramble(actual);
}
[Test]
public void DontScramble()
{
UUID uuid = UUID.Random();
AssetBase asset = new AssetBase();
asset.FullID = uuid;
new PropertyScrambler<AssetBase>()
.DontScramble(x => x.Metadata)
.DontScramble(x => x.FullID)
.DontScramble(x => x.ID)
.Scramble(asset);
Assert.That(asset.FullID, Is.EqualTo(uuid));
} }
} }
} }

View File

@ -26,6 +26,7 @@
*/ */
using System; using System;
using System.Xml;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Reflection; using System.Reflection;
@ -369,6 +370,155 @@ namespace OpenSim.Framework.Console
return new string[0]; return new string[0];
} }
public XmlElement GetXml(XmlDocument doc)
{
CommandInfo help = (CommandInfo)((Dictionary<string, object>)tree["help"])[String.Empty];
((Dictionary<string, object>)tree["help"]).Remove(string.Empty);
if (((Dictionary<string, object>)tree["help"]).Count == 0)
tree.Remove("help");
CommandInfo quit = (CommandInfo)((Dictionary<string, object>)tree["quit"])[String.Empty];
((Dictionary<string, object>)tree["quit"]).Remove(string.Empty);
if (((Dictionary<string, object>)tree["quit"]).Count == 0)
tree.Remove("quit");
XmlElement root = doc.CreateElement("", "HelpTree", "");
ProcessTreeLevel(tree, root, doc);
if (!tree.ContainsKey("help"))
tree["help"] = (object) new Dictionary<string, object>();
((Dictionary<string, object>)tree["help"])[String.Empty] = help;
if (!tree.ContainsKey("quit"))
tree["quit"] = (object) new Dictionary<string, object>();
((Dictionary<string, object>)tree["quit"])[String.Empty] = quit;
return root;
}
private void ProcessTreeLevel(Dictionary<string, object> level, XmlElement xml, XmlDocument doc)
{
foreach (KeyValuePair<string, object> kvp in level)
{
if (kvp.Value is Dictionary<string, Object>)
{
XmlElement next = doc.CreateElement("", "Level", "");
next.SetAttribute("Name", kvp.Key);
xml.AppendChild(next);
ProcessTreeLevel((Dictionary<string, object>)kvp.Value, next, doc);
}
else
{
CommandInfo c = (CommandInfo)kvp.Value;
XmlElement cmd = doc.CreateElement("", "Command", "");
XmlElement e;
e = doc.CreateElement("", "Module", "");
cmd.AppendChild(e);
e.AppendChild(doc.CreateTextNode(c.module));
e = doc.CreateElement("", "Shared", "");
cmd.AppendChild(e);
e.AppendChild(doc.CreateTextNode(c.shared.ToString()));
e = doc.CreateElement("", "HelpText", "");
cmd.AppendChild(e);
e.AppendChild(doc.CreateTextNode(c.help_text));
e = doc.CreateElement("", "LongHelp", "");
cmd.AppendChild(e);
e.AppendChild(doc.CreateTextNode(c.long_help));
e = doc.CreateElement("", "Description", "");
cmd.AppendChild(e);
e.AppendChild(doc.CreateTextNode(c.descriptive_help));
xml.AppendChild(cmd);
}
}
}
public void FromXml(XmlElement root, CommandDelegate fn)
{
CommandInfo help = (CommandInfo)((Dictionary<string, object>)tree["help"])[String.Empty];
((Dictionary<string, object>)tree["help"]).Remove(string.Empty);
if (((Dictionary<string, object>)tree["help"]).Count == 0)
tree.Remove("help");
CommandInfo quit = (CommandInfo)((Dictionary<string, object>)tree["quit"])[String.Empty];
((Dictionary<string, object>)tree["quit"]).Remove(string.Empty);
if (((Dictionary<string, object>)tree["quit"]).Count == 0)
tree.Remove("quit");
tree.Clear();
ReadTreeLevel(tree, root, fn);
if (!tree.ContainsKey("help"))
tree["help"] = (object) new Dictionary<string, object>();
((Dictionary<string, object>)tree["help"])[String.Empty] = help;
if (!tree.ContainsKey("quit"))
tree["quit"] = (object) new Dictionary<string, object>();
((Dictionary<string, object>)tree["quit"])[String.Empty] = quit;
}
private void ReadTreeLevel(Dictionary<string, object> level, XmlNode node, CommandDelegate fn)
{
Dictionary<string, object> next;
string name;
XmlNodeList nodeL = node.ChildNodes;
XmlNodeList cmdL;
CommandInfo c;
foreach (XmlNode part in nodeL)
{
switch (part.Name)
{
case "Level":
name = ((XmlElement)part).GetAttribute("Name");
next = new Dictionary<string, object>();
level[name] = next;
ReadTreeLevel(next, part, fn);
break;
case "Command":
cmdL = part.ChildNodes;
c = new CommandInfo();
foreach (XmlNode cmdPart in cmdL)
{
switch (cmdPart.Name)
{
case "Module":
c.module = cmdPart.InnerText;
break;
case "Shared":
c.shared = Convert.ToBoolean(cmdPart.InnerText);
break;
case "HelpText":
c.help_text = cmdPart.InnerText;
break;
case "LongHelp":
c.long_help = cmdPart.InnerText;
break;
case "Description":
c.descriptive_help = cmdPart.InnerText;
break;
}
}
c.fn = new List<CommandDelegate>();
c.fn.Add(fn);
level[String.Empty] = c;
break;
}
}
}
} }
public class Parser public class Parser

View File

@ -26,30 +26,43 @@
*/ */
using System; using System;
using System.Xml;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using OpenMetaverse;
using Nini.Config; using Nini.Config;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using log4net; using log4net;
namespace OpenSim.Framework.Console namespace OpenSim.Framework.Console
{ {
public class ConsoleConnection
{
public int last;
public long lastLineSeen;
}
// A console that uses REST interfaces // A console that uses REST interfaces
// //
public class RemoteConsole : CommandConsole public class RemoteConsole : CommandConsole
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// private IHttpServer m_Server = null; private IHttpServer m_Server = null;
// private IConfigSource m_Config = null; private IConfigSource m_Config = null;
private List<string> m_Scrollback = new List<string>(); private List<string> m_Scrollback = new List<string>();
private ManualResetEvent m_DataEvent = new ManualResetEvent(false); private ManualResetEvent m_DataEvent = new ManualResetEvent(false);
private List<string> m_InputData = new List<string>(); private List<string> m_InputData = new List<string>();
private uint m_LineNumber = 1; private long m_LineNumber = 0;
private Dictionary<UUID, ConsoleConnection> m_Connections =
new Dictionary<UUID, ConsoleConnection>();
private string m_UserName = String.Empty;
private string m_Password = String.Empty;
public RemoteConsole(string defaultPrompt) : base(defaultPrompt) public RemoteConsole(string defaultPrompt) : base(defaultPrompt)
{ {
@ -57,12 +70,23 @@ namespace OpenSim.Framework.Console
public void ReadConfig(IConfigSource config) public void ReadConfig(IConfigSource config)
{ {
// m_Config = config; m_Config = config;
IConfig netConfig = m_Config.Configs["Network"];
if (netConfig == null)
return;
m_UserName = netConfig.GetString("ConsoleUser", String.Empty);
m_Password = netConfig.GetString("ConsolePass", String.Empty);
} }
public void SetServer(IHttpServer server) public void SetServer(IHttpServer server)
{ {
// m_Server = server; m_Server = server;
m_Server.AddHTTPHandler("/StartSession/", HandleHttpStartSession);
m_Server.AddHTTPHandler("/CloseSession/", HandleHttpCloseSession);
m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand);
} }
public override void Output(string text, string level) public override void Output(string text, string level)
@ -71,16 +95,19 @@ namespace OpenSim.Framework.Console
{ {
while (m_Scrollback.Count >= 1000) while (m_Scrollback.Count >= 1000)
m_Scrollback.RemoveAt(0); m_Scrollback.RemoveAt(0);
m_Scrollback.Add(String.Format("{0}", m_LineNumber)+":"+level+":"+text);
m_LineNumber++; m_LineNumber++;
m_Scrollback.Add(String.Format("{0}", m_LineNumber)+":"+level+":"+text);
} }
System.Console.Write(text); System.Console.WriteLine(text.Trim());
}
public override void Output(string text)
{
Output(text, "normal");
} }
public override string ReadLine(string p, bool isCommand, bool e) public override string ReadLine(string p, bool isCommand, bool e)
{ {
System.Console.Write("{0}", prompt);
m_DataEvent.WaitOne(); m_DataEvent.WaitOne();
lock (m_InputData) lock (m_InputData)
@ -115,5 +142,316 @@ namespace OpenSim.Framework.Console
return cmdinput; return cmdinput;
} }
} }
private void DoExpire()
{
List<UUID> expired = new List<UUID>();
lock (m_Connections)
{
foreach (KeyValuePair<UUID, ConsoleConnection> kvp in m_Connections)
{
if (System.Environment.TickCount - kvp.Value.last > 500000)
expired.Add(kvp.Key);
}
foreach (UUID id in expired)
{
m_Connections.Remove(id);
CloseConnection(id);
}
}
}
private Hashtable HandleHttpStartSession(Hashtable request)
{
DoExpire();
Hashtable post = DecodePostString(request["body"].ToString());
Hashtable reply = new Hashtable();
reply["str_response_string"] = "";
reply["int_response_code"] = 401;
reply["content_type"] = "text/plain";
if (m_UserName == String.Empty)
return reply;
if (post["USER"] == null || post["PASS"] == null)
return reply;
if (m_UserName != post["USER"].ToString() ||
m_Password != post["PASS"].ToString())
{
return reply;
}
ConsoleConnection c = new ConsoleConnection();
c.last = System.Environment.TickCount;
c.lastLineSeen = 0;
UUID sessionID = UUID.Random();
lock (m_Connections)
{
m_Connections[sessionID] = c;
}
string uri = "/ReadResponses/" + sessionID.ToString() + "/";
m_Server.AddPollServiceHTTPHandler(uri, HandleHttpCloseSession,
new PollServiceEventArgs(HasEvents, GetEvents, NoEvents,
sessionID));
XmlDocument xmldoc = new XmlDocument();
XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
"", "");
xmldoc.AppendChild(xmlnode);
XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession",
"");
xmldoc.AppendChild(rootElement);
XmlElement id = xmldoc.CreateElement("", "SessionID", "");
id.AppendChild(xmldoc.CreateTextNode(sessionID.ToString()));
rootElement.AppendChild(id);
rootElement.AppendChild(MainConsole.Instance.Commands.GetXml(xmldoc));
reply["str_response_string"] = xmldoc.InnerXml;
reply["int_response_code"] = 200;
reply["content_type"] = "text/xml";
return reply;
}
private Hashtable HandleHttpCloseSession(Hashtable request)
{
DoExpire();
Hashtable post = DecodePostString(request["body"].ToString());
Hashtable reply = new Hashtable();
reply["str_response_string"] = "";
reply["int_response_code"] = 404;
reply["content_type"] = "text/plain";
if (post["ID"] == null)
return reply;
UUID id;
if (!UUID.TryParse(post["ID"].ToString(), out id))
return reply;
lock (m_Connections)
{
if (m_Connections.ContainsKey(id))
{
m_Connections.Remove(id);
CloseConnection(id);
}
}
XmlDocument xmldoc = new XmlDocument();
XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
"", "");
xmldoc.AppendChild(xmlnode);
XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession",
"");
xmldoc.AppendChild(rootElement);
XmlElement res = xmldoc.CreateElement("", "Result", "");
res.AppendChild(xmldoc.CreateTextNode("OK"));
rootElement.AppendChild(res);
reply["str_response_string"] = xmldoc.InnerXml;
reply["int_response_code"] = 200;
reply["content_type"] = "text/plain";
return reply;
}
private Hashtable HandleHttpSessionCommand(Hashtable request)
{
DoExpire();
Hashtable post = DecodePostString(request["body"].ToString());
Hashtable reply = new Hashtable();
reply["str_response_string"] = "";
reply["int_response_code"] = 404;
reply["content_type"] = "text/plain";
if (post["ID"] == null)
return reply;
UUID id;
if (!UUID.TryParse(post["ID"].ToString(), out id))
return reply;
if (post["COMMAND"] == null || post["COMMAND"].ToString() == String.Empty)
return reply;
lock (m_InputData)
{
m_DataEvent.Set();
m_InputData.Add(post["COMMAND"].ToString());
}
XmlDocument xmldoc = new XmlDocument();
XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
"", "");
xmldoc.AppendChild(xmlnode);
XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession",
"");
xmldoc.AppendChild(rootElement);
XmlElement res = xmldoc.CreateElement("", "Result", "");
res.AppendChild(xmldoc.CreateTextNode("OK"));
rootElement.AppendChild(res);
reply["str_response_string"] = xmldoc.InnerXml;
reply["int_response_code"] = 200;
reply["content_type"] = "text/plain";
return reply;
}
private Hashtable DecodePostString(string data)
{
Hashtable result = new Hashtable();
string[] terms = data.Split(new char[] {'&'});
foreach (string term in terms)
{
string[] elems = term.Split(new char[] {'='});
if (elems.Length == 0)
continue;
string name = System.Web.HttpUtility.UrlDecode(elems[0]);
string value = String.Empty;
if (elems.Length > 1)
value = System.Web.HttpUtility.UrlDecode(elems[1]);
result[name] = value;
}
return result;
}
public void CloseConnection(UUID id)
{
try
{
string uri = "/ReadResponses/" + id.ToString() + "/";
m_Server.RemovePollServiceHTTPHandler("", uri);
}
catch (Exception)
{
}
}
private bool HasEvents(UUID sessionID)
{
ConsoleConnection c = null;
lock (m_Connections)
{
if (!m_Connections.ContainsKey(sessionID))
return false;
c = m_Connections[sessionID];
}
c.last = System.Environment.TickCount;
if (c.lastLineSeen < m_LineNumber)
return true;
return false;
}
private Hashtable GetEvents(UUID sessionID, string request)
{
ConsoleConnection c = null;
lock (m_Connections)
{
if (!m_Connections.ContainsKey(sessionID))
return NoEvents();
c = m_Connections[sessionID];
}
c.last = System.Environment.TickCount;
if (c.lastLineSeen >= m_LineNumber)
return NoEvents();
Hashtable result = new Hashtable();
XmlDocument xmldoc = new XmlDocument();
XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
"", "");
xmldoc.AppendChild(xmlnode);
XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession",
"");
lock (m_Scrollback)
{
long startLine = m_LineNumber - m_Scrollback.Count;
long sendStart = startLine;
if (sendStart < c.lastLineSeen)
sendStart = c.lastLineSeen;
for (long i = sendStart ; i < m_LineNumber ; i++)
{
XmlElement res = xmldoc.CreateElement("", "Line", "");
long line = i + 1;
res.SetAttribute("Number", line.ToString());
res.AppendChild(xmldoc.CreateTextNode(m_Scrollback[(int)(i - startLine)]));
rootElement.AppendChild(res);
}
}
c.lastLineSeen = m_LineNumber;
xmldoc.AppendChild(rootElement);
result["str_response_string"] = xmldoc.InnerXml;
result["int_response_code"] = 200;
result["content_type"] = "application/xml";
result["keepalive"] = false;
result["reusecontext"] = false;
return result;
}
private Hashtable NoEvents()
{
Hashtable result = new Hashtable();
XmlDocument xmldoc = new XmlDocument();
XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
"", "");
xmldoc.AppendChild(xmlnode);
XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession",
"");
xmldoc.AppendChild(rootElement);
result["str_response_string"] = xmldoc.InnerXml;
result["int_response_code"] = 200;
result["content_type"] = "text/xml";
result["keepalive"] = false;
result["reusecontext"] = false;
return result;
}
} }
} }

View File

@ -256,25 +256,35 @@ namespace OpenSim.Framework.Tests
Agent1Data.SessionID = new UUID("aa06f798-9d70-4bdb-9bbf-012a02ee2baf"); Agent1Data.SessionID = new UUID("aa06f798-9d70-4bdb-9bbf-012a02ee2baf");
Agent1Data.startpos = StartPos; Agent1Data.startpos = StartPos;
OSDMap map2 = (OSDMap)OSDParser.DeserializeJson(oldSerialization);
OSDMap map2;
try
{
map2 = (OSDMap) OSDParser.DeserializeJson(oldSerialization);
AgentCircuitData Agent2Data = new AgentCircuitData(); AgentCircuitData Agent2Data = new AgentCircuitData();
Agent2Data.UnpackAgentCircuitData(map2); Agent2Data.UnpackAgentCircuitData(map2);
Assert.That((Agent1Data.AgentID == Agent2Data.AgentID)); Assert.That((Agent1Data.AgentID == Agent2Data.AgentID));
Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder)); Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder));
Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath)); Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath));
Assert.That((Agent1Data.child == Agent2Data.child)); Assert.That((Agent1Data.child == Agent2Data.child));
Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count)); Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count));
Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode)); Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode));
Assert.That((Agent1Data.firstname == Agent2Data.firstname)); Assert.That((Agent1Data.firstname == Agent2Data.firstname));
Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder)); Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder));
Assert.That((Agent1Data.lastname == Agent2Data.lastname)); Assert.That((Agent1Data.lastname == Agent2Data.lastname));
Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID)); Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID));
Assert.That((Agent1Data.SessionID == Agent2Data.SessionID)); Assert.That((Agent1Data.SessionID == Agent2Data.SessionID));
Assert.That((Agent1Data.startpos == Agent2Data.startpos)); Assert.That((Agent1Data.startpos == Agent2Data.startpos));
}
catch (LitJson.JsonException)
{
//intermittant litjson errors :P
Assert.That(1 == 1);
}
/* /*
Enable this once VisualParams go in the packing method Enable this once VisualParams go in the packing method
for (int i=0;i<208;i++) for (int i=0;i<208;i++)
@ -303,12 +313,19 @@ namespace OpenSim.Framework.Tests
Agent1Data.SessionID = SessionId; Agent1Data.SessionID = SessionId;
Agent1Data.startpos = StartPos; Agent1Data.startpos = StartPos;
OSDMap map2;
OSDMap map = Agent1Data.PackAgentCircuitData(); OSDMap map = Agent1Data.PackAgentCircuitData();
string str = OSDParser.SerializeJsonString(map); try
//System.Console.WriteLine(str); {
OSDMap map2 = (OSDMap)OSDParser.DeserializeJson(str); string str = OSDParser.SerializeJsonString(map);
//System.Console.WriteLine(str);
map2 = (OSDMap) OSDParser.DeserializeJson(str);
}
catch (System.NullReferenceException)
{
//spurious litjson errors :P
map2 = map;
}
AgentCircuitData Agent2Data = new AgentCircuitData(); AgentCircuitData Agent2Data = new AgentCircuitData();
Agent2Data.UnpackAgentCircuitData(map2); Agent2Data.UnpackAgentCircuitData(map2);

View File

@ -120,6 +120,7 @@ namespace OpenSim
configSource.AddSwitch("Startup", "gridmode"); configSource.AddSwitch("Startup", "gridmode");
configSource.AddSwitch("Startup", "physics"); configSource.AddSwitch("Startup", "physics");
configSource.AddSwitch("Startup", "gui"); configSource.AddSwitch("Startup", "gui");
configSource.AddSwitch("Startup", "console");
configSource.AddConfig("StandAlone"); configSource.AddConfig("StandAlone");
configSource.AddConfig("Network"); configSource.AddConfig("Network");

View File

@ -52,6 +52,7 @@ namespace OpenSim
protected string m_startupCommandsFile; protected string m_startupCommandsFile;
protected string m_shutdownCommandsFile; protected string m_shutdownCommandsFile;
protected bool m_gui = false; protected bool m_gui = false;
protected string m_consoleType = "local";
private string m_timedScript = "disabled"; private string m_timedScript = "disabled";
private Timer m_scriptTimer; private Timer m_scriptTimer;
@ -71,7 +72,10 @@ namespace OpenSim
m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", "startup_commands.txt"); m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", "startup_commands.txt");
m_shutdownCommandsFile = startupConfig.GetString("shutdown_console_commands_file", "shutdown_commands.txt"); m_shutdownCommandsFile = startupConfig.GetString("shutdown_console_commands_file", "shutdown_commands.txt");
m_gui = startupConfig.GetBoolean("gui", false); if (startupConfig.GetString("console", String.Empty) == String.Empty)
m_gui = startupConfig.GetBoolean("gui", false);
else
m_consoleType= startupConfig.GetString("console", String.Empty);
m_timedScript = startupConfig.GetString("timer_Script", "disabled"); m_timedScript = startupConfig.GetString("timer_Script", "disabled");
if (m_logFileAppender != null) if (m_logFileAppender != null)
@ -110,13 +114,31 @@ namespace OpenSim
if (m_gui) // Driven by external GUI if (m_gui) // Driven by external GUI
m_console = new CommandConsole("Region"); m_console = new CommandConsole("Region");
else else
m_console = new LocalConsole("Region"); {
switch (m_consoleType)
{
case "basic":
m_console = new CommandConsole("Region");
break;
case "rest":
m_console = new RemoteConsole("Region");
((RemoteConsole)m_console).ReadConfig(m_config.Source);
break;
default:
m_console = new LocalConsole("Region");
break;
}
}
MainConsole.Instance = m_console; MainConsole.Instance = m_console;
RegisterConsoleCommands(); RegisterConsoleCommands();
base.StartupSpecific(); base.StartupSpecific();
if (m_console is RemoteConsole)
((RemoteConsole)m_console).SetServer(m_httpServer);
//Run Startup Commands //Run Startup Commands
if (String.IsNullOrEmpty(m_startupCommandsFile)) if (String.IsNullOrEmpty(m_startupCommandsFile))
{ {

View File

@ -1435,6 +1435,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="map">heightmap</param> /// <param name="map">heightmap</param>
public virtual void SendLayerData(float[] map) public virtual void SendLayerData(float[] map)
{ {
DoSendLayerData((object)map);
ThreadPool.QueueUserWorkItem(DoSendLayerData, map); ThreadPool.QueueUserWorkItem(DoSendLayerData, map);
} }
@ -1450,16 +1451,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
for (int y = 0; y < 16; y++) for (int y = 0; y < 16; y++)
{ {
// For some terrains, sending more than one terrain patch at once results in a libsecondlife exception for (int x = 0; x < 16; x += 4)
// see http://opensimulator.org/mantis/view.php?id=1662
//for (int x = 0; x < 16; x += 4)
//{
// SendLayerPacket(map, y, x);
// Thread.Sleep(150);
//}
for (int x = 0; x < 16; x++)
{ {
SendLayerData(x, y, LLHeightFieldMoronize(map)); SendLayerPacket(LLHeightFieldMoronize(map), y, x);
Thread.Sleep(35); Thread.Sleep(35);
} }
} }
@ -1476,17 +1470,54 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="map">heightmap</param> /// <param name="map">heightmap</param>
/// <param name="px">X coordinate for patches 0..12</param> /// <param name="px">X coordinate for patches 0..12</param>
/// <param name="py">Y coordinate for patches 0..15</param> /// <param name="py">Y coordinate for patches 0..15</param>
// private void SendLayerPacket(float[] map, int y, int x) private void SendLayerPacket(float[] map, int y, int x)
// { {
// int[] patches = new int[4]; int[] patches = new int[4];
// patches[0] = x + 0 + y * 16; patches[0] = x + 0 + y * 16;
// patches[1] = x + 1 + y * 16; patches[1] = x + 1 + y * 16;
// patches[2] = x + 2 + y * 16; patches[2] = x + 2 + y * 16;
// patches[3] = x + 3 + y * 16; patches[3] = x + 3 + y * 16;
// Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches); LayerDataPacket layerpack;
// OutPacket(layerpack, ThrottleOutPacketType.Land); try
// } {
layerpack = TerrainCompressor.CreateLandPacket(map, patches);
layerpack.Header.Zerocoded = true;
layerpack.Header.Reliable = true;
if (layerpack.Length > 1000) // Oversize packet was created
{
for (int xa = 0 ; xa < 4 ; xa++)
{
// Send oversize packet in individual patches
//
SendLayerData(x+xa, y, map);
}
}
else
{
OutPacket(layerpack, ThrottleOutPacketType.Land);
}
}
catch (OverflowException e)
{
for (int xa = 0 ; xa < 4 ; xa++)
{
// Send oversize packet in individual patches
//
SendLayerData(x+xa, y, map);
}
}
catch (IndexOutOfRangeException e)
{
for (int xa = 0 ; xa < 4 ; xa++)
{
// Bad terrain, send individual chunks
//
SendLayerData(x+xa, y, map);
}
}
}
/// <summary> /// <summary>
/// Sends a specified patch to a client /// Sends a specified patch to a client
@ -1507,6 +1538,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(((map.Length==65536)? map : LLHeightFieldMoronize(map)), patches); LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(((map.Length==65536)? map : LLHeightFieldMoronize(map)), patches);
layerpack.Header.Zerocoded = true; layerpack.Header.Zerocoded = true;
layerpack.Header.Reliable = true;
OutPacket(layerpack, ThrottleOutPacketType.Land); OutPacket(layerpack, ThrottleOutPacketType.Land);
@ -1556,7 +1588,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="windSpeeds">16x16 array of wind speeds</param> /// <param name="windSpeeds">16x16 array of wind speeds</param>
public virtual void SendWindData(Vector2[] windSpeeds) public virtual void SendWindData(Vector2[] windSpeeds)
{ {
ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)windSpeeds); DoSendWindData((object)windSpeeds);
// ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)windSpeeds);
} }
/// <summary> /// <summary>

View File

@ -34,6 +34,7 @@ using OpenMetaverse;
using OpenMetaverse.Packets; using OpenMetaverse.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Tests.Common; using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.ClientStack.LindenUDP.Tests namespace OpenSim.Region.ClientStack.LindenUDP.Tests
{ {

View File

@ -147,7 +147,7 @@ namespace OpenSim.Region.Communications.OGS1
{ {
// The timeout should always be significantly larger than the timeout for the grid server to request // The timeout should always be significantly larger than the timeout for the grid server to request
// the initial status of the region before confirming registration. // the initial status of the region before confirming registration.
GridResp = GridReq.Send(serversInfo.GridURL, 90000); GridResp = GridReq.Send(serversInfo.GridURL, 9999999);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -48,6 +48,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
private int m_saydistance = 30; private int m_saydistance = 30;
private int m_shoutdistance = 100; private int m_shoutdistance = 100;
private int m_whisperdistance = 10; private int m_whisperdistance = 10;
private string m_adminprefix = String.Empty;
private List<Scene> m_scenes = new List<Scene>(); private List<Scene> m_scenes = new List<Scene>();
internal object m_syncy = new object(); internal object m_syncy = new object();
@ -76,6 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
m_adminprefix = config.Configs["Chat"].GetString("admin_prefix", m_adminprefix);
} }
public virtual void AddRegion(Scene scene) public virtual void AddRegion(Scene scene)
@ -207,6 +209,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
fromPos = avatar.AbsolutePosition; fromPos = avatar.AbsolutePosition;
fromName = avatar.Name; fromName = avatar.Name;
fromID = c.Sender.AgentId; fromID = c.Sender.AgentId;
if (avatar.GodLevel > 100)
fromName = m_adminprefix + fromName;
break; break;
@ -255,14 +259,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
string fromName = c.From; string fromName = c.From;
UUID fromID = UUID.Zero; UUID fromID = UUID.Zero;
UUID ownerID = UUID.Zero;
ChatSourceType sourceType = ChatSourceType.Object; ChatSourceType sourceType = ChatSourceType.Object;
if (null != c.Sender) if (null != c.Sender)
{ {
ScenePresence avatar = (c.Scene as Scene).GetScenePresence(c.Sender.AgentId); ScenePresence avatar = (c.Scene as Scene).GetScenePresence(c.Sender.AgentId);
fromID = c.Sender.AgentId; fromID = c.Sender.AgentId;
ownerID = c.Sender.AgentId;
fromName = avatar.Name; fromName = avatar.Name;
sourceType = ChatSourceType.Agent; sourceType = ChatSourceType.Agent;
} }
if (c.SenderObject != null)
{
SceneObjectPart senderObject = (SceneObjectPart)c.SenderObject;
fromID = senderObject.UUID;
ownerID = senderObject.OwnerID;
fromName = senderObject.Name;
}
// m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);

View File

@ -123,7 +123,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Land
public LandData GetLandData(ulong regionHandle, uint x, uint y) public LandData GetLandData(ulong regionHandle, uint x, uint y)
{ {
m_log.DebugFormat("[LAND IN CONNECTOR]: GetLandData for {0}. Count = {2}", m_log.DebugFormat("[LAND IN CONNECTOR]: GetLandData for {0}. Count = {1}",
regionHandle, m_Scenes.Count); regionHandle, m_Scenes.Count);
foreach (Scene s in m_Scenes) foreach (Scene s in m_Scenes)
{ {

View File

@ -214,7 +214,8 @@ namespace OpenSim.Region.CoreModules.World.Estate
private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds) private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds)
{ {
m_scene.Restart(timeInSeconds); // m_scene.Restart(timeInSeconds);
remoteClient.SendBlueBoxMessage(UUID.Zero, "System", "Restart is not available");
} }
private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID) private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)

View File

@ -115,7 +115,6 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
public void RequestPrim(uint primLocalID, IClientAPI remoteClient) public void RequestPrim(uint primLocalID, IClientAPI remoteClient)
{ {
PacketType i = PacketType.ObjectUpdate;
List<EntityBase> EntityList = GetEntities(); List<EntityBase> EntityList = GetEntities();
foreach (EntityBase ent in EntityList) foreach (EntityBase ent in EntityList)

View File

@ -1,3 +1,30 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
public interface IAvatarAttachment public interface IAvatarAttachment

View File

@ -27,9 +27,14 @@
using System; using System;
using System.CodeDom.Compiler; using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
using System.Text; using System.Text;
using log4net; using log4net;
using Microsoft.CSharp; using Microsoft.CSharp;
@ -54,6 +59,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
private readonly MicroScheduler m_microthreads = new MicroScheduler(); private readonly MicroScheduler m_microthreads = new MicroScheduler();
private IConfig m_config;
public void RegisterExtension<T>(T instance) public void RegisterExtension<T>(T instance)
{ {
m_extensions[typeof (T)] = instance; m_extensions[typeof (T)] = instance;
@ -63,6 +71,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{ {
if (source.Configs["MRM"] != null) if (source.Configs["MRM"] != null)
{ {
m_config = source.Configs["MRM"];
if (source.Configs["MRM"].GetBoolean("Enabled", false)) if (source.Configs["MRM"].GetBoolean("Enabled", false))
{ {
m_log.Info("[MRM] Enabling MRM Module"); m_log.Info("[MRM] Enabling MRM Module");
@ -112,6 +122,91 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
return script; return script;
} }
/// <summary>
/// Create an AppDomain that contains policy restricting code to execute
/// with only the permissions granted by a named permission set
/// </summary>
/// <param name="permissionSetName">name of the permission set to restrict to</param>
/// <param name="appDomainName">'friendly' name of the appdomain to be created</param>
/// <exception cref="ArgumentNullException">
/// if <paramref name="permissionSetName"/> is null
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// if <paramref name="permissionSetName"/> is empty
/// </exception>
/// <returns>AppDomain with a restricted security policy</returns>
/// <remarks>Substantial portions of this function from: http://blogs.msdn.com/shawnfa/archive/2004/10/25/247379.aspx
/// Valid permissionSetName values are:
/// * FullTrust
/// * SkipVerification
/// * Execution
/// * Nothing
/// * LocalIntranet
/// * Internet
/// * Everything
/// </remarks>
public static AppDomain CreateRestrictedDomain(string permissionSetName, string appDomainName)
{
if (permissionSetName == null)
throw new ArgumentNullException("permissionSetName");
if (permissionSetName.Length == 0)
throw new ArgumentOutOfRangeException("permissionSetName", permissionSetName,
"Cannot have an empty permission set name");
// Default to all code getting nothing
PolicyStatement emptyPolicy = new PolicyStatement(new PermissionSet(PermissionState.None));
UnionCodeGroup policyRoot = new UnionCodeGroup(new AllMembershipCondition(), emptyPolicy);
bool foundName = false;
PermissionSet setIntersection = new PermissionSet(PermissionState.Unrestricted);
// iterate over each policy level
IEnumerator levelEnumerator = SecurityManager.PolicyHierarchy();
while (levelEnumerator.MoveNext())
{
PolicyLevel level = levelEnumerator.Current as PolicyLevel;
// if this level has defined a named permission set with the
// given name, then intersect it with what we've retrieved
// from all the previous levels
if (level != null)
{
PermissionSet levelSet = level.GetNamedPermissionSet(permissionSetName);
if (levelSet != null)
{
foundName = true;
if (setIntersection != null)
setIntersection = setIntersection.Intersect(levelSet);
}
}
}
// Intersect() can return null for an empty set, so convert that
// to an empty set object. Also return an empty set if we didn't find
// the named permission set we were looking for
if (setIntersection == null || !foundName)
setIntersection = new PermissionSet(PermissionState.None);
else
setIntersection = new NamedPermissionSet(permissionSetName, setIntersection);
// if no named permission sets were found, return an empty set,
// otherwise return the set that was found
PolicyStatement permissions = new PolicyStatement(setIntersection);
policyRoot.AddChild(new UnionCodeGroup(new AllMembershipCondition(), permissions));
// create an AppDomain policy level for the policy tree
PolicyLevel appDomainLevel = PolicyLevel.CreateAppDomainLevel();
appDomainLevel.RootCodeGroup = policyRoot;
// create an AppDomain where this policy will be in effect
string domainName = appDomainName;
AppDomain restrictedDomain = AppDomain.CreateDomain(domainName);
restrictedDomain.SetAppDomainPolicy(appDomainLevel);
return restrictedDomain;
}
void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
{ {
if (script.StartsWith("//MRM:C#")) if (script.StartsWith("//MRM:C#"))
@ -125,9 +220,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
try try
{ {
m_log.Info("[MRM] Found C# MRM"); m_log.Info("[MRM] Found C# MRM - Starting in AppDomain with " + m_config.GetString("permissionLevel", "Internet") + "-level security.");
MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( string domainName = UUID.Random().ToString();
AppDomain target = CreateRestrictedDomain(m_config.GetString("permissionLevel", "Internet"),
domainName);
MRMBase mmb = (MRMBase) target.CreateInstanceFromAndUnwrap(
CompileFromDotNetText(script, itemID.ToString()), CompileFromDotNetText(script, itemID.ToString()),
"OpenSim.MiniModule"); "OpenSim.MiniModule");

View File

@ -71,7 +71,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
private bool CanEdit() private bool CanEdit()
{ {
if(!m_security.CanEditObject(this)) if (!m_security.CanEditObject(this))
{ {
throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]"); throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]");
} }
@ -672,7 +672,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
get { return m_sculptType; } get { return m_sculptType; }
set set
{ {
if(!CanEdit()) if (!CanEdit())
return; return;
m_sculptType = value; m_sculptType = value;

View File

@ -156,10 +156,10 @@ namespace OpenSim.Region.Physics.OdePlugin
private const uint m_regionWidth = Constants.RegionSize; private const uint m_regionWidth = Constants.RegionSize;
private const uint m_regionHeight = Constants.RegionSize; private const uint m_regionHeight = Constants.RegionSize;
private bool IsLocked = false;
private float ODE_STEPSIZE = 0.020f; private float ODE_STEPSIZE = 0.020f;
private float metersInSpace = 29.9f; private float metersInSpace = 29.9f;
private List<PhysicsActor> RemoveQueue;
public float gravityx = 0f; public float gravityx = 0f;
public float gravityy = 0f; public float gravityy = 0f;
public float gravityz = -9.8f; public float gravityz = -9.8f;
@ -376,6 +376,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Initialize the mesh plugin // Initialize the mesh plugin
public override void Initialise(IMesher meshmerizer, IConfigSource config) public override void Initialise(IMesher meshmerizer, IConfigSource config)
{ {
RemoveQueue = new List<PhysicsActor>();
mesher = meshmerizer; mesher = meshmerizer;
m_config = config; m_config = config;
// Defaults // Defaults
@ -2047,13 +2048,21 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (prim is OdePrim) if (prim is OdePrim)
{ {
lock (OdeLock) if (!IsLocked) //Fix a deadlock situation.. have we been locked by Simulate?
{ {
OdePrim p = (OdePrim) prim; lock (OdeLock)
{
OdePrim p = (OdePrim)prim;
p.setPrimForRemoval(); p.setPrimForRemoval();
AddPhysicsActorTaint(prim); AddPhysicsActorTaint(prim);
//RemovePrimThreadLocked(p); //RemovePrimThreadLocked(p);
}
}
else
{
//Add the prim to a queue which will be removed when Simulate has finished what it's doing.
RemoveQueue.Add(prim);
} }
} }
} }
@ -2575,7 +2584,7 @@ namespace OpenSim.Region.Physics.OdePlugin
DeleteRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks DeleteRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks
CreateRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks CreateRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks
} }
IsLocked = true;
lock (OdeLock) lock (OdeLock)
{ {
// Process 10 frames if the sim is running normal.. // Process 10 frames if the sim is running normal..
@ -2988,6 +2997,19 @@ namespace OpenSim.Region.Physics.OdePlugin
d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix); d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix);
} }
} }
IsLocked = false;
if (RemoveQueue.Count > 0)
{
do
{
if (RemoveQueue[0] != null)
{
RemovePrimThreadLocked((OdePrim)RemoveQueue[0]);
}
RemoveQueue.RemoveAt(0);
}
while (RemoveQueue.Count > 0);
}
return fps; return fps;
} }

View File

@ -35,6 +35,7 @@ using Nini.Config;
using OpenSim.Region.ScriptEngine.Shared.Api; using OpenSim.Region.ScriptEngine.Shared.Api;
using OpenMetaverse; using OpenMetaverse;
using System; using System;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.ScriptEngine.Shared.Tests namespace OpenSim.Region.ScriptEngine.Shared.Tests
{ {
@ -52,7 +53,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
public void SetUp() public void SetUp()
{ {
IniConfigSource initConfigSource = new IniConfigSource(); IConfigSource initConfigSource = new IniConfigSource();
IConfig config = initConfigSource.AddConfig("XEngine"); IConfig config = initConfigSource.AddConfig("XEngine");
config.Set("Enabled", "true"); config.Set("Enabled", "true");

View File

@ -70,6 +70,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
} }
} }
/// <summary>
/// When an object gets paid by an avatar and generates the paid event,
/// this will pipe it to the script engine
/// </summary>
/// <param name="objectID">Object ID that got paid</param>
/// <param name="agentID">Agent Id that did the paying</param>
/// <param name="amount">Amount paid</param>
private void HandleObjectPaid(UUID objectID, UUID agentID, private void HandleObjectPaid(UUID objectID, UUID agentID,
int amount) int amount)
{ {
@ -93,6 +100,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
} }
} }
/// <summary>
/// Handles piping the proper stuff to The script engine for touching
/// Including DetectedParams
/// </summary>
/// <param name="localID"></param>
/// <param name="originalID"></param>
/// <param name="offsetPos"></param>
/// <param name="remoteClient"></param>
/// <param name="surfaceArgs"></param>
public void touch_start(uint localID, uint originalID, Vector3 offsetPos, public void touch_start(uint localID, uint originalID, Vector3 offsetPos,
IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
{ {

View File

@ -77,16 +77,16 @@ namespace OpenSim.Server.Base
m_HttpServer = new BaseHttpServer(port); m_HttpServer = new BaseHttpServer(port);
MainServer.Instance = m_HttpServer; MainServer.Instance = m_HttpServer;
}
protected override void Initialise()
{
m_HttpServer.Start();
if (MainConsole.Instance is RemoteConsole) if (MainConsole.Instance is RemoteConsole)
{ {
((RemoteConsole)MainConsole.Instance).SetServer(m_HttpServer); ((RemoteConsole)MainConsole.Instance).SetServer(m_HttpServer);
} }
} }
protected override void Initialise()
{
m_HttpServer.Start();
}
} }
} }

View File

@ -163,7 +163,7 @@ namespace OpenSim.Tests.Common.Setup
godsModule.Initialise(testScene, new IniConfigSource()); godsModule.Initialise(testScene, new IniConfigSource());
testScene.AddModule(godsModule.Name, godsModule); testScene.AddModule(godsModule.Name, godsModule);
realServices = realServices.ToLower(); realServices = realServices.ToLower();
IniConfigSource config = new IniConfigSource(); IConfigSource config = new IniConfigSource();
// If we have a brand new scene, need to initialize shared region modules // If we have a brand new scene, need to initialize shared region modules
if ((m_assetService == null && m_inventoryService == null) || newScene) if ((m_assetService == null && m_inventoryService == null) || newScene)
@ -198,7 +198,7 @@ namespace OpenSim.Tests.Common.Setup
PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
testScene.PhysicsScene testScene.PhysicsScene
= physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test"); = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
return testScene; return testScene;
} }
@ -206,7 +206,7 @@ namespace OpenSim.Tests.Common.Setup
private static void StartAssetService(Scene testScene, bool real) private static void StartAssetService(Scene testScene, bool real)
{ {
ISharedRegionModule assetService = new LocalAssetServicesConnector(); ISharedRegionModule assetService = new LocalAssetServicesConnector();
IniConfigSource config = new IniConfigSource(); IConfigSource config = new IniConfigSource();
config.AddConfig("Modules"); config.AddConfig("Modules");
config.AddConfig("AssetService"); config.AddConfig("AssetService");
config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
@ -225,7 +225,7 @@ namespace OpenSim.Tests.Common.Setup
private static void StartInventoryService(Scene testScene, bool real) private static void StartInventoryService(Scene testScene, bool real)
{ {
ISharedRegionModule inventoryService = new LocalInventoryServicesConnector(); ISharedRegionModule inventoryService = new LocalInventoryServicesConnector();
IniConfigSource config = new IniConfigSource(); IConfigSource config = new IniConfigSource();
config.AddConfig("Modules"); config.AddConfig("Modules");
config.AddConfig("InventoryService"); config.AddConfig("InventoryService");
config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector");
@ -418,4 +418,5 @@ namespace OpenSim.Tests.Common.Setup
sogd.InventoryDeQueueAndDelete(); sogd.InventoryDeQueueAndDelete();
} }
} }
} }

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using log4net.Appender;
using log4net.Layout;
namespace OpenSim.Tests.Common
{
public static class TestLogging
{
public static void LogToConsole()
{
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.Layout =
new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
log4net.Config.BasicConfigurator.Configure(consoleAppender);
}
}
}

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<runtime>
<gcConcurrent enabled="true" />
<gcServer enabled="true" />
</runtime>
<appSettings>
</appSettings>
<log4net>
<appender name="Console" type="OpenSim.Framework.Console.OpenSimAppender, OpenSim.Framework.Console">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{HH:mm:ss} - %message%newline" />
</layout>
</appender>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file value="OpenSim.ConsoleClient.log" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level - %logger %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="Console" />
<appender-ref ref="LogFileAppender" />
</root>
</log4net>
</configuration>

View File

@ -0,0 +1 @@
[Startup]

View File

@ -26,7 +26,7 @@
<!-- Set root logger level to DEBUG and its only appender to A1 --> <!-- Set root logger level to DEBUG and its only appender to A1 -->
<root> <root>
<level value="DEBUG" /> <level value="Info" />
<appender-ref ref="A1" /> <appender-ref ref="A1" />
</root> </root>
</log4net> </log4net>

View File

@ -14,6 +14,12 @@ ServiceConnectors = "OpenSim.Server.Handlers.dll:AssetServiceConnector,OpenSim.S
[Network] [Network]
port = 8003 port = 8003
; * The following are for the remote console
; * They have no effect for the local or basic console types
; * Leave commented to diable logins to the console
;ConsoleUser = Test
;ConsolePass = secret
; * As an example, the below configuration precisely mimicks the legacy ; * As an example, the below configuration precisely mimicks the legacy
; * asset server. It is read by the asset IN connector (defined above) ; * asset server. It is read by the asset IN connector (defined above)
; * and it then loads the OUT connector (a local database module). That, ; * and it then loads the OUT connector (a local database module). That,

View File

@ -292,6 +292,8 @@
LibrariesXMLFile="./inventory/Libraries.xml" LibrariesXMLFile="./inventory/Libraries.xml"
[Network] [Network]
ConsoleUser = "Test"
ConsolePass = "secret"
http_listener_port = 9000 http_listener_port = 9000
default_location_x = 1000 default_location_x = 1000
default_location_y = 1000 default_location_y = 1000

View File

@ -105,9 +105,12 @@
<ReferencePath>../../../bin/</ReferencePath> <ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/> <Reference name="System"/>
<Reference name="System.Xml"/>
<Reference name="System.Web"/>
<Reference name="log4net.dll"/> <Reference name="log4net.dll"/>
<Reference name="Nini.dll"/> <Reference name="Nini.dll"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/> <Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Files> <Files>
<Match pattern="*.cs" recurse="true"/> <Match pattern="*.cs" recurse="true"/>
</Files> </Files>
@ -1593,6 +1596,38 @@
</Files> </Files>
</Project> </Project>
<Project frameworkVersion="v3_5" name="OpenSim.ConsoleClient" path="OpenSim/ConsoleClient" type="Exe">
<Configuration name="Debug">
<Options>
<OutputPath>../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Xml"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Server.Base"/>
<Reference name="Nini.dll" />
<Reference name="log4net.dll"/>
<Files>
<Match pattern="*.cs" recurse="false">
<Exclude pattern="Tests" />
</Match>
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Region.CoreModules" path="OpenSim/Region/CoreModules" type="Library"> <Project frameworkVersion="v3_5" name="OpenSim.Region.CoreModules" path="OpenSim/Region/CoreModules" type="Library">
<Configuration name="Debug"> <Configuration name="Debug">
<Options> <Options>
@ -3335,6 +3370,7 @@
<Reference name="OpenSim.Data"/> <Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Region.Framework"/> <Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.CoreModules"/> <Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Tests.Common"/>
<Reference name="log4net.dll"/> <Reference name="log4net.dll"/>
<Reference name="Mono.Addins.dll" /> <Reference name="Mono.Addins.dll" />
<Reference name="nunit.framework.dll" /> <Reference name="nunit.framework.dll" />