aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2009-08-17 05:55:38 -0700
committerDiva Canto2009-08-17 05:55:38 -0700
commitfa8a94577a2f38145da0c8a1f6d1c72c4f339ed9 (patch)
tree7bee741b06e6732fae848bef3c6b7f808ab3349a
parentBumped up grid services interface number. (diff)
parentAdd System.Xml reference to the console project (diff)
downloadopensim-SC-fa8a94577a2f38145da0c8a1f6d1c72c4f339ed9.zip
opensim-SC-fa8a94577a2f38145da0c8a1f6d1c72c4f339ed9.tar.gz
opensim-SC-fa8a94577a2f38145da0c8a1f6d1c72c4f339ed9.tar.bz2
opensim-SC-fa8a94577a2f38145da0c8a1f6d1c72c4f339ed9.tar.xz
Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim
-rw-r--r--.gitignore1
-rw-r--r--OpenSim/ConsoleClient/ConsoleClient.cs198
-rw-r--r--OpenSim/ConsoleClient/Requester.cs86
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs10
-rw-r--r--OpenSim/Data/MySQL/MySQLInventoryData.cs13
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs17
-rw-r--r--OpenSim/Data/MySQL/Tests/MySQLGridTest.cs8
-rw-r--r--OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs12
-rw-r--r--OpenSim/Data/SQLite/SQLiteAssetData.cs2
-rw-r--r--OpenSim/Data/SQLite/SQLiteInventoryStore.cs3
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs29
-rw-r--r--OpenSim/Data/Tests/BasicAssetTest.cs78
-rw-r--r--OpenSim/Data/Tests/BasicEstateTest.cs28
-rw-r--r--OpenSim/Data/Tests/BasicGridTest.cs97
-rw-r--r--OpenSim/Data/Tests/BasicInventoryTest.cs86
-rw-r--r--OpenSim/Data/Tests/BasicRegionTest.cs65
-rw-r--r--OpenSim/Data/Tests/BasicUserTest.cs39
-rw-r--r--OpenSim/Data/Tests/PropertyCompareConstraint.cs200
-rw-r--r--OpenSim/Data/Tests/PropertyScrambler.cs (renamed from OpenSim/Data/Tests/ScrambleForTesting.cs)101
-rw-r--r--OpenSim/Framework/Console/CommandConsole.cs150
-rw-r--r--OpenSim/Framework/Console/RemoteConsole.cs358
-rw-r--r--OpenSim/Framework/Tests/AgentCircuitDataTest.cs59
-rw-r--r--OpenSim/Region/Application/Application.cs3
-rw-r--r--OpenSim/Region/Application/OpenSim.cs26
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs77
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs1
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1GridServices.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs13
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs1
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs27
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs103
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs4
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs38
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/EventManager.cs16
-rw-r--r--OpenSim/Server/Base/HttpServerBase.cs10
-rw-r--r--OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs11
-rw-r--r--OpenSim/Tests/Common/TestLogging.cs46
-rw-r--r--bin/OpenSim.ConsoleClient.exe.config33
-rw-r--r--bin/OpenSim.ConsoleClient.ini.example1
-rw-r--r--bin/OpenSim.Data.NHibernate.Tests.dll.config2
-rw-r--r--bin/OpenSim.Server.ini.example6
-rw-r--r--bin/OpenSim.ini.example2
-rw-r--r--prebuild.xml36
46 files changed, 1736 insertions, 370 deletions
diff --git a/.gitignore b/.gitignore
index 18c3dbf..9d2d692 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,7 @@ bin/*.db
21bin/addin-db-* 21bin/addin-db-*
22bin/*.dll 22bin/*.dll
23bin/OpenSim.vshost.exe.config 23bin/OpenSim.vshost.exe.config
24bin/ScriptEngines/*-*-*-*-*
24bin/ScriptEngines/*.dll 25bin/ScriptEngines/*.dll
25bin/ScriptEngines/*/*.dll 26bin/ScriptEngines/*/*.dll
26bin/ScriptEngines/*/*.state 27bin/ScriptEngines/*/*.state
diff --git a/OpenSim/ConsoleClient/ConsoleClient.cs b/OpenSim/ConsoleClient/ConsoleClient.cs
new file mode 100644
index 0000000..319584f
--- /dev/null
+++ b/OpenSim/ConsoleClient/ConsoleClient.cs
@@ -0,0 +1,198 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using Nini.Config;
29using log4net;
30using System.Reflection;
31using System;
32using System.Xml;
33using System.Collections.Generic;
34using OpenSim.Server.Base;
35using OpenSim.Framework.Console;
36using OpenMetaverse;
37
38namespace OpenSim.ConsoleClient
39{
40 public class OpenSimConsoleClient
41 {
42 private static readonly ILog m_log =
43 LogManager.GetLogger(
44 MethodBase.GetCurrentMethod().DeclaringType);
45
46 protected static ServicesServerBase m_Server = null;
47 private static string m_Host;
48 private static int m_Port;
49 private static string m_User;
50 private static string m_Pass;
51 private static UUID m_SessionID;
52
53 static int Main(string[] args)
54 {
55 m_Server = new ServicesServerBase("Client", args);
56
57 IConfig serverConfig = m_Server.Config.Configs["Startup"];
58 if (serverConfig == null)
59 {
60 System.Console.WriteLine("Startup config section missing in .ini file");
61 throw new Exception("Configuration error");
62 }
63
64 ArgvConfigSource argvConfig = new ArgvConfigSource(args);
65
66 argvConfig.AddSwitch("Startup", "host", "h");
67 argvConfig.AddSwitch("Startup", "port", "p");
68 argvConfig.AddSwitch("Startup", "user", "u");
69 argvConfig.AddSwitch("Startup", "pass", "P");
70
71 m_Server.Config.Merge(argvConfig);
72
73 m_User = serverConfig.GetString("user", "Test");
74 m_Host = serverConfig.GetString("host", "localhost");
75 m_Port = serverConfig.GetInt("port", 8003);
76 m_Pass = serverConfig.GetString("pass", "secret");
77
78 Requester.MakeRequest("http://"+m_Host+":"+m_Port.ToString()+"/StartSession/", String.Format("USER={0}&PASS={1}", m_User, m_Pass), LoginReply);
79
80 int res = m_Server.Run();
81
82 Environment.Exit(res);
83
84 return 0;
85 }
86
87 private static void SendCommand(string module, string[] cmd)
88 {
89 string sendCmd = String.Join(" ", cmd);
90
91 Requester.MakeRequest("http://"+m_Host+":"+m_Port.ToString()+"/SessionCommand/", String.Format("ID={0}&COMMAND={1}", m_SessionID, sendCmd), CommandReply);
92 }
93
94 public static void LoginReply(string requestUrl, string requestData, string replyData)
95 {
96 XmlDocument doc = new XmlDocument();
97
98 doc.LoadXml(replyData);
99
100 XmlNodeList rootL = doc.GetElementsByTagName("ConsoleSession");
101 if (rootL.Count != 1)
102 {
103 MainConsole.Instance.Output("Connection data info was not valid");
104 Environment.Exit(1);
105 }
106 XmlElement rootNode = (XmlElement)rootL[0];
107
108 if (rootNode == null)
109 {
110 MainConsole.Instance.Output("Connection data info was not valid");
111 Environment.Exit(1);
112 }
113
114 XmlNodeList helpNodeL = rootNode.GetElementsByTagName("HelpTree");
115 if (helpNodeL.Count != 1)
116 {
117 MainConsole.Instance.Output("Connection data info was not valid");
118 Environment.Exit(1);
119 }
120
121 XmlElement helpNode = (XmlElement)helpNodeL[0];
122 if (helpNode == null)
123 {
124 MainConsole.Instance.Output("Connection data info was not valid");
125 Environment.Exit(1);
126 }
127
128 XmlNodeList sessionL = rootNode.GetElementsByTagName("SessionID");
129 if (sessionL.Count != 1)
130 {
131 MainConsole.Instance.Output("Connection data info was not valid");
132 Environment.Exit(1);
133 }
134
135 XmlElement sessionNode = (XmlElement)sessionL[0];
136 if (sessionNode == null)
137 {
138 MainConsole.Instance.Output("Connection data info was not valid");
139 Environment.Exit(1);
140 }
141
142 if (!UUID.TryParse(sessionNode.InnerText, out m_SessionID))
143 {
144 MainConsole.Instance.Output("Connection data info was not valid");
145 Environment.Exit(1);
146 }
147
148 MainConsole.Instance.Commands.FromXml(helpNode, SendCommand);
149
150 Requester.MakeRequest("http://"+m_Host+":"+m_Port.ToString()+"/ReadResponses/"+m_SessionID.ToString()+"/", String.Empty, ReadResponses);
151 }
152
153 public static void ReadResponses(string requestUrl, string requestData, string replyData)
154 {
155 XmlDocument doc = new XmlDocument();
156
157 doc.LoadXml(replyData);
158
159 XmlNodeList rootNodeL = doc.GetElementsByTagName("ConsoleSession");
160 if (rootNodeL.Count != 1 || rootNodeL[0] == null)
161 {
162 Requester.MakeRequest(requestUrl, requestData, ReadResponses);
163 return;
164 }
165
166 List<string> lines = new List<string>();
167
168 foreach (XmlNode part in rootNodeL[0].ChildNodes)
169 {
170 if (part.Name != "Line")
171 continue;
172
173 lines.Add(part.InnerText);
174 }
175
176 // Cut down scrollback to 100 lines (4 screens)
177 // for the command line client
178 //
179 while (lines.Count > 100)
180 lines.RemoveAt(0);
181
182 foreach (string l in lines)
183 {
184 string[] parts = l.Split(new char[] {':'}, 3);
185 if (parts.Length != 3)
186 continue;
187
188 MainConsole.Instance.Output(parts[2].Trim(), parts[1]);
189 }
190
191 Requester.MakeRequest(requestUrl, requestData, ReadResponses);
192 }
193
194 public static void CommandReply(string requestUrl, string requestData, string replyData)
195 {
196 }
197 }
198}
diff --git a/OpenSim/ConsoleClient/Requester.cs b/OpenSim/ConsoleClient/Requester.cs
new file mode 100644
index 0000000..af7860d
--- /dev/null
+++ b/OpenSim/ConsoleClient/Requester.cs
@@ -0,0 +1,86 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Net;
31using System.Reflection;
32using System.Text;
33using System.Xml;
34using System.Xml.Serialization;
35using log4net;
36
37namespace OpenSim.ConsoleClient
38{
39 public delegate void ReplyDelegate(string requestUrl, string requestData, string replyData);
40
41 public class Requester
42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44
45 public static void MakeRequest(string requestUrl, string data,
46 ReplyDelegate action)
47 {
48 WebRequest request = WebRequest.Create(requestUrl);
49 WebResponse response = null;
50
51 request.Method = "POST";
52
53 request.ContentType = "application/x-www-form-urlencoded";
54
55 byte[] buffer = new System.Text.ASCIIEncoding().GetBytes(data);
56 int length = (int) buffer.Length;
57 request.ContentLength = length;
58
59 request.BeginGetRequestStream(delegate(IAsyncResult res)
60 {
61 Stream requestStream = request.EndGetRequestStream(res);
62
63 requestStream.Write(buffer, 0, length);
64
65 request.BeginGetResponse(delegate(IAsyncResult ar)
66 {
67 string reply = String.Empty;
68
69 response = request.EndGetResponse(ar);
70
71 try
72 {
73 StreamReader r = new StreamReader(response.GetResponseStream());
74 reply = r.ReadToEnd();
75
76 }
77 catch (System.InvalidOperationException)
78 {
79 }
80
81 action(requestUrl, data, reply);
82 }, null);
83 }, null);
84 }
85 }
86}
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index 26cdd06..0865083 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -168,6 +168,7 @@ namespace OpenSim.Data.MySQL
168 } 168 }
169 asset.Name = (string) dbReader["name"]; 169 asset.Name = (string) dbReader["name"];
170 asset.Type = (sbyte) dbReader["assetType"]; 170 asset.Type = (sbyte) dbReader["assetType"];
171 asset.Temporary = (bool)dbReader["temporary"];
171 } 172 }
172 dbReader.Close(); 173 dbReader.Close();
173 cmd.Dispose(); 174 cmd.Dispose();
@@ -195,18 +196,11 @@ namespace OpenSim.Data.MySQL
195 { 196 {
196 lock (_dbConnection) 197 lock (_dbConnection)
197 { 198 {
198 //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID);
199 if (ExistsAsset(asset.FullID))
200 {
201 //m_log.Info("[ASSET DB]: Asset exists already, ignoring.");
202 return;
203 }
204
205 _dbConnection.CheckConnection(); 199 _dbConnection.CheckConnection();
206 200
207 MySqlCommand cmd = 201 MySqlCommand cmd =
208 new MySqlCommand( 202 new MySqlCommand(
209 "insert INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + 203 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" +
210 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", 204 "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)",
211 _dbConnection.Connection); 205 _dbConnection.Connection);
212 206
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index a4b8663..4521a0f 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -342,7 +342,7 @@ namespace OpenSim.Data.MySQL
342 item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; 342 item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"];
343 item.GroupPermissions = (uint) reader["inventoryGroupPermissions"]; 343 item.GroupPermissions = (uint) reader["inventoryGroupPermissions"];
344 item.SalePrice = (int) reader["salePrice"]; 344 item.SalePrice = (int) reader["salePrice"];
345 item.SaleType = Convert.ToByte(reader["saleType"]); 345 item.SaleType = unchecked((byte)(Convert.ToSByte(reader["saleType"])));
346 item.CreationDate = (int) reader["creationDate"]; 346 item.CreationDate = (int) reader["creationDate"];
347 item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]); 347 item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]);
348 item.Flags = (uint) reader["flags"]; 348 item.Flags = (uint) reader["flags"];
@@ -423,7 +423,7 @@ namespace OpenSim.Data.MySQL
423 /// <summary> 423 /// <summary>
424 /// Returns a specified inventory folder 424 /// Returns a specified inventory folder
425 /// </summary> 425 /// </summary>
426 /// <param name="folder">The folder to return</param> 426 /// <param name="folderID">The folder to return</param>
427 /// <returns>A folder class</returns> 427 /// <returns>A folder class</returns>
428 public InventoryFolderBase getInventoryFolder(UUID folderID) 428 public InventoryFolderBase getInventoryFolder(UUID folderID)
429 { 429 {
@@ -438,8 +438,9 @@ namespace OpenSim.Data.MySQL
438 result.Parameters.AddWithValue("?uuid", folderID.ToString()); 438 result.Parameters.AddWithValue("?uuid", folderID.ToString());
439 MySqlDataReader reader = result.ExecuteReader(); 439 MySqlDataReader reader = result.ExecuteReader();
440 440
441 reader.Read(); 441 InventoryFolderBase folder = null;
442 InventoryFolderBase folder = readInventoryFolder(reader); 442 if (reader.Read())
443 folder = readInventoryFolder(reader);
443 reader.Close(); 444 reader.Close();
444 result.Dispose(); 445 result.Dispose();
445 446
@@ -506,7 +507,7 @@ namespace OpenSim.Data.MySQL
506 result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); 507 result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
507 result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); 508 result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
508 result.Parameters.AddWithValue("?salePrice", item.SalePrice); 509 result.Parameters.AddWithValue("?salePrice", item.SalePrice);
509 result.Parameters.AddWithValue("?saleType", item.SaleType); 510 result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType));
510 result.Parameters.AddWithValue("?creationDate", item.CreationDate); 511 result.Parameters.AddWithValue("?creationDate", item.CreationDate);
511 result.Parameters.AddWithValue("?groupID", item.GroupID); 512 result.Parameters.AddWithValue("?groupID", item.GroupID);
512 result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); 513 result.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
@@ -603,7 +604,7 @@ namespace OpenSim.Data.MySQL
603 cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); 604 cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString());
604 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); 605 cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString());
605 cmd.Parameters.AddWithValue("?folderName", folderName); 606 cmd.Parameters.AddWithValue("?folderName", folderName);
606 cmd.Parameters.AddWithValue("?type", (short) folder.Type); 607 cmd.Parameters.AddWithValue("?type", folder.Type);
607 cmd.Parameters.AddWithValue("?version", folder.Version); 608 cmd.Parameters.AddWithValue("?version", folder.Version);
608 609
609 try 610 try
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 2166845..9c2ee4a 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -834,7 +834,10 @@ namespace OpenSim.Data.MySQL
834 // explicit conversion of integers is required, which sort 834 // explicit conversion of integers is required, which sort
835 // of sucks. No idea if there is a shortcut here or not. 835 // of sucks. No idea if there is a shortcut here or not.
836 prim.CreationDate = Convert.ToInt32(row["CreationDate"]); 836 prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
837 prim.Name = (String) row["Name"]; 837 if (row["Name"] != DBNull.Value)
838 prim.Name = (String)row["Name"];
839 else
840 prim.Name = string.Empty;
838 // various text fields 841 // various text fields
839 prim.Text = (String) row["Text"]; 842 prim.Text = (String) row["Text"];
840 prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), 843 prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),
@@ -945,12 +948,12 @@ namespace OpenSim.Data.MySQL
945 prim.DIE_AT_EDGE = true; 948 prim.DIE_AT_EDGE = true;
946 949
947 prim.SalePrice = Convert.ToInt32(row["SalePrice"]); 950 prim.SalePrice = Convert.ToInt32(row["SalePrice"]);
948 prim.ObjectSaleType = Convert.ToByte(row["SaleType"]); 951 prim.ObjectSaleType = unchecked((byte)Convert.ToSByte(row["SaleType"]));
949 952
950 prim.Material = Convert.ToByte(row["Material"]); 953 prim.Material = unchecked((byte)Convert.ToSByte(row["Material"]));
951 954
952 if (!(row["ClickAction"] is DBNull)) 955 if (!(row["ClickAction"] is DBNull))
953 prim.ClickAction = (byte)Convert.ToByte(row["ClickAction"]); 956 prim.ClickAction = unchecked((byte)Convert.ToSByte(row["ClickAction"]));
954 957
955 prim.CollisionSound = new UUID(row["CollisionSound"].ToString()); 958 prim.CollisionSound = new UUID(row["CollisionSound"].ToString());
956 prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]); 959 prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]);
@@ -1277,12 +1280,12 @@ namespace OpenSim.Data.MySQL
1277 cmd.Parameters.AddWithValue("DieAtEdge", 0); 1280 cmd.Parameters.AddWithValue("DieAtEdge", 0);
1278 1281
1279 cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice); 1282 cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice);
1280 cmd.Parameters.AddWithValue("SaleType", Convert.ToInt16(prim.ObjectSaleType)); 1283 cmd.Parameters.AddWithValue("SaleType", unchecked((sbyte)(prim.ObjectSaleType)));
1281 1284
1282 byte clickAction = prim.ClickAction; 1285 byte clickAction = prim.ClickAction;
1283 cmd.Parameters.AddWithValue("ClickAction", clickAction); 1286 cmd.Parameters.AddWithValue("ClickAction", unchecked((sbyte)(clickAction)));
1284 1287
1285 cmd.Parameters.AddWithValue("Material", prim.Material); 1288 cmd.Parameters.AddWithValue("Material", unchecked((sbyte)(prim.Material)));
1286 1289
1287 cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString()); 1290 cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString());
1288 cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume); 1291 cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume);
diff --git a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs
index 7c36375..d1d5c2a 100644
--- a/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs
+++ b/OpenSim/Data/MySQL/Tests/MySQLGridTest.cs
@@ -62,11 +62,18 @@ namespace OpenSim.Data.MySQL.Tests
62 m_log.Error("Exception {0}", e); 62 m_log.Error("Exception {0}", e);
63 Assert.Ignore(); 63 Assert.Ignore();
64 } 64 }
65
66 // This actually does the roll forward assembly stuff
67 Assembly assem = GetType().Assembly;
68 Migration m = new Migration(database.Connection, assem, "GridStore");
69
70 m.Update();
65 } 71 }
66 72
67 [TestFixtureTearDown] 73 [TestFixtureTearDown]
68 public void Cleanup() 74 public void Cleanup()
69 { 75 {
76 m_log.Warn("Cleaning up.");
70 if (db != null) 77 if (db != null)
71 { 78 {
72 db.Dispose(); 79 db.Dispose();
@@ -74,6 +81,7 @@ namespace OpenSim.Data.MySQL.Tests
74 // if a new table is added, it has to be dropped here 81 // if a new table is added, it has to be dropped here
75 if (database != null) 82 if (database != null)
76 { 83 {
84 database.ExecuteSql("drop table migrations");
77 database.ExecuteSql("drop table regions"); 85 database.ExecuteSql("drop table regions");
78 } 86 }
79 } 87 }
diff --git a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
index 23c1ec5..a3a32dc 100644
--- a/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
+++ b/OpenSim/Data/MySQL/Tests/MySQLInventoryTest.cs
@@ -53,6 +53,7 @@ namespace OpenSim.Data.MySQL.Tests
53 try 53 try
54 { 54 {
55 database = new MySQLManager(connect); 55 database = new MySQLManager(connect);
56 DropTables();
56 db = new MySQLInventoryData(); 57 db = new MySQLInventoryData();
57 db.Initialise(connect); 58 db.Initialise(connect);
58 } 59 }
@@ -72,10 +73,15 @@ namespace OpenSim.Data.MySQL.Tests
72 } 73 }
73 if (database != null) 74 if (database != null)
74 { 75 {
75 database.ExecuteSql("drop table inventoryitems"); 76 DropTables();
76 database.ExecuteSql("drop table inventoryfolders");
77 database.ExecuteSql("drop table migrations");
78 } 77 }
79 } 78 }
79
80 private void DropTables()
81 {
82 database.ExecuteSql("drop table IF EXISTS inventoryitems");
83 database.ExecuteSql("drop table IF EXISTS inventoryfolders");
84 database.ExecuteSql("drop table IF EXISTS migrations");
85 }
80 } 86 }
81} 87}
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index b09c1c9..72af7a0 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -183,7 +183,7 @@ namespace OpenSim.Data.SQLite
183 int assetLength = (asset.Data != null) ? asset.Data.Length : 0; 183 int assetLength = (asset.Data != null) ? asset.Data.Length : 0;
184 184
185 m_log.Info("[ASSET DB]: " + 185 m_log.Info("[ASSET DB]: " +
186 string.Format("Loaded {6} {5} Asset: [{0}][{3}] \"{1}\":{2} ({7} bytes)", 186 string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)",
187 asset.FullID, asset.Name, asset.Description, asset.Type, 187 asset.FullID, asset.Name, asset.Description, asset.Type,
188 temporary, local, assetLength)); 188 temporary, local, assetLength));
189 } 189 }
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
index 97c40ba..e5f7a50 100644
--- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
+++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
@@ -301,7 +301,8 @@ namespace OpenSim.Data.SQLite
301 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; 301 DataTable inventoryFolderTable = ds.Tables["inventoryfolders"];
302 302
303 inventoryRow = inventoryFolderTable.Rows.Find(item.Folder.ToString()); 303 inventoryRow = inventoryFolderTable.Rows.Find(item.Folder.ToString());
304 inventoryRow["version"] = (int)inventoryRow["version"] + 1; 304 if (inventoryRow != null) //MySQL doesn't throw an exception here, so sqlite shouldn't either.
305 inventoryRow["version"] = (int)inventoryRow["version"] + 1;
305 306
306 invFoldersDa.Update(ds, "inventoryfolders"); 307 invFoldersDa.Update(ds, "inventoryfolders");
307 } 308 }
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index d2548c2..0259ac5 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -307,26 +307,21 @@ namespace OpenSim.Data.SQLite
307 /// <param name="regionUUID">the region UUID</param> 307 /// <param name="regionUUID">the region UUID</param>
308 public void StoreObject(SceneObjectGroup obj, UUID regionUUID) 308 public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
309 { 309 {
310 uint flags = obj.RootPart.GetEffectiveObjectFlags();
311
312 // Eligibility check
313 //
314 if ((flags & (uint)PrimFlags.Temporary) != 0)
315 return;
316 if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0)
317 return;
318
310 lock (ds) 319 lock (ds)
311 { 320 {
312 foreach (SceneObjectPart prim in obj.Children.Values) 321 foreach (SceneObjectPart prim in obj.Children.Values)
313 { 322 {
314 if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 323 m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
315 && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0) 324 addPrim(prim, obj.UUID, regionUUID);
316 {
317 m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
318 addPrim(prim, obj.UUID, regionUUID);
319 }
320 else if (prim.Stopped)
321 {
322 //m_log.Info("[DATASTORE]: " +
323 //"Adding stopped obj: " + obj.UUID + " to region: " + regionUUID);
324 //addPrim(prim, obj.UUID.ToString(), regionUUID.ToString());
325 }
326 else
327 {
328 // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID);
329 }
330 } 325 }
331 } 326 }
332 327
@@ -1130,7 +1125,7 @@ namespace OpenSim.Data.SQLite
1130 // explicit conversion of integers is required, which sort 1125 // explicit conversion of integers is required, which sort
1131 // of sucks. No idea if there is a shortcut here or not. 1126 // of sucks. No idea if there is a shortcut here or not.
1132 prim.CreationDate = Convert.ToInt32(row["CreationDate"]); 1127 prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
1133 prim.Name = (String) row["Name"]; 1128 prim.Name = row["Name"] == DBNull.Value ? string.Empty : (string)row["Name"];
1134 // various text fields 1129 // various text fields
1135 prim.Text = (String) row["Text"]; 1130 prim.Text = (String) row["Text"];
1136 prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), 1131 prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs
index e85a6a7..09131c1 100644
--- a/OpenSim/Data/Tests/BasicAssetTest.cs
+++ b/OpenSim/Data/Tests/BasicAssetTest.cs
@@ -26,20 +26,19 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using log4net.Config; 30using log4net.Config;
30using NUnit.Framework; 31using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers; 32using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 33using OpenMetaverse;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using log4net; 35using log4net;
35using System.Reflection;
36 36
37namespace OpenSim.Data.Tests 37namespace OpenSim.Data.Tests
38{ 38{
39 public class BasicAssetTest 39 public class BasicAssetTest
40 { 40 {
41 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41 public IAssetDataPlugin db;
42 public AssetDataBase db;
43 public UUID uuid1; 42 public UUID uuid1;
44 public UUID uuid2; 43 public UUID uuid2;
45 public UUID uuid3; 44 public UUID uuid3;
@@ -47,14 +46,7 @@ namespace OpenSim.Data.Tests
47 46
48 public void SuperInit() 47 public void SuperInit()
49 { 48 {
50 try 49 OpenSim.Tests.Common.TestLogging.LogToConsole();
51 {
52 XmlConfigurator.Configure();
53 }
54 catch (Exception)
55 {
56 // I don't care, just leave log4net off
57 }
58 50
59 uuid1 = UUID.Random(); 51 uuid1 = UUID.Random();
60 uuid2 = UUID.Random(); 52 uuid2 = UUID.Random();
@@ -81,41 +73,59 @@ namespace OpenSim.Data.Tests
81 a2.Data = asset1; 73 a2.Data = asset1;
82 a3.Data = asset1; 74 a3.Data = asset1;
83 75
76 PropertyScrambler<AssetBase> scrambler = new PropertyScrambler<AssetBase>()
77 .DontScramble(x => x.Data)
78 .DontScramble(x => x.ID)
79 .DontScramble(x => x.FullID)
80 .DontScramble(x => x.Metadata.ID)
81 .DontScramble(x => x.Metadata.FullID);
82
83 scrambler.Scramble(a1);
84 scrambler.Scramble(a2);
85 scrambler.Scramble(a3);
86
84 db.CreateAsset(a1); 87 db.CreateAsset(a1);
85 db.CreateAsset(a2); 88 db.CreateAsset(a2);
86 db.CreateAsset(a3); 89 db.CreateAsset(a3);
87 90
88 AssetBase a1a = db.FetchAsset(uuid1); 91 AssetBase a1a = db.FetchAsset(uuid1);
89 Assert.That(a1.ID, Is.EqualTo(a1a.ID), "Assert.That(a1.ID, Is.EqualTo(a1a.ID))"); 92 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
90 Assert.That(a1.Name, Is.EqualTo(a1a.Name), "Assert.That(a1.Name, Is.EqualTo(a1a.Name))");
91 93
92 AssetBase a2a = db.FetchAsset(uuid2); 94 AssetBase a2a = db.FetchAsset(uuid2);
93 Assert.That(a2.ID, Is.EqualTo(a2a.ID), "Assert.That(a2.ID, Is.EqualTo(a2a.ID))"); 95 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
94 Assert.That(a2.Name, Is.EqualTo(a2a.Name), "Assert.That(a2.Name, Is.EqualTo(a2a.Name))");
95 96
96 AssetBase a3a = db.FetchAsset(uuid3); 97 AssetBase a3a = db.FetchAsset(uuid3);
97 Assert.That(a3.ID, Is.EqualTo(a3a.ID), "Assert.That(a3.ID, Is.EqualTo(a3a.ID))"); 98 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
98 Assert.That(a3.Name, Is.EqualTo(a3a.Name), "Assert.That(a3.Name, Is.EqualTo(a3a.Name))"); 99
99 } 100 scrambler.Scramble(a1a);
101 scrambler.Scramble(a2a);
102 scrambler.Scramble(a3a);
103
104 db.UpdateAsset(a1a);
105 db.UpdateAsset(a2a);
106 db.UpdateAsset(a3a);
107
108 AssetBase a1b = db.FetchAsset(uuid1);
109 Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a));
110
111 AssetBase a2b = db.FetchAsset(uuid2);
112 Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a));
113
114 AssetBase a3b = db.FetchAsset(uuid3);
115 Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a));
100 116
101 [Test]
102 public void T011_ExistsSimpleAsset()
103 {
104 Assert.That(db.ExistsAsset(uuid1), Is.True); 117 Assert.That(db.ExistsAsset(uuid1), Is.True);
105 Assert.That(db.ExistsAsset(uuid2), Is.True); 118 Assert.That(db.ExistsAsset(uuid2), Is.True);
106 Assert.That(db.ExistsAsset(uuid3), Is.True); 119 Assert.That(db.ExistsAsset(uuid3), Is.True);
107 }
108 120
109 // this has questionable use, but it is in the interface at the moment. 121 List<AssetMetadata> metadatas = db.FetchAssetMetadataSet(0, 1000);
110 // [Test] 122
111 // public void T012_DeleteAsset() 123 AssetMetadata metadata = metadatas.Find(x => x.FullID == uuid1);
112 // { 124 Assert.That(metadata.Name, Is.EqualTo(a1b.Name));
113 // db.DeleteAsset(uuid1); 125 Assert.That(metadata.Description, Is.EqualTo(a1b.Description));
114 // db.DeleteAsset(uuid2); 126 Assert.That(metadata.Type, Is.EqualTo(a1b.Type));
115 // db.DeleteAsset(uuid3); 127 Assert.That(metadata.Temporary, Is.EqualTo(a1b.Temporary));
116 // Assert.That(db.ExistsAsset(uuid1), Is.False); 128 Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID));
117 // Assert.That(db.ExistsAsset(uuid2), Is.False); 129 }
118 // Assert.That(db.ExistsAsset(uuid3), Is.False);
119 // }
120 } 130 }
121} 131}
diff --git a/OpenSim/Data/Tests/BasicEstateTest.cs b/OpenSim/Data/Tests/BasicEstateTest.cs
index a0266b3..284d066 100644
--- a/OpenSim/Data/Tests/BasicEstateTest.cs
+++ b/OpenSim/Data/Tests/BasicEstateTest.cs
@@ -40,7 +40,6 @@ namespace OpenSim.Data.Tests
40{ 40{
41 public class BasicEstateTest 41 public class BasicEstateTest
42 { 42 {
43 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 public IEstateDataStore db; 43 public IEstateDataStore db;
45 public IRegionDataStore regionDb; 44 public IRegionDataStore regionDb;
46 45
@@ -57,14 +56,7 @@ namespace OpenSim.Data.Tests
57 56
58 public void SuperInit() 57 public void SuperInit()
59 { 58 {
60 try 59 OpenSim.Tests.Common.TestLogging.LogToConsole();
61 {
62 XmlConfigurator.Configure();
63 }
64 catch (Exception)
65 {
66 // I don't care, just leave log4net off
67 }
68 } 60 }
69 61
70 #region 0Tests 62 #region 0Tests
@@ -163,6 +155,24 @@ namespace OpenSim.Data.Tests
163 } 155 }
164 156
165 [Test] 157 [Test]
158 private void T012_EstateSettingsRandomStorage()
159 {
160
161 // Letting estate store generate rows to database for us
162 EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
163 new PropertyScrambler<EstateSettings>().Scramble(originalSettings);
164
165 // Saving settings.
166 db.StoreEstateSettings(originalSettings);
167
168 // Loading settings to another instance variable.
169 EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
170
171 // Checking that loaded values are correct.
172 Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
173 }
174
175 [Test]
166 public void T020_EstateSettingsManagerList() 176 public void T020_EstateSettingsManagerList()
167 { 177 {
168 // Letting estate store generate rows to database for us 178 // Letting estate store generate rows to database for us
diff --git a/OpenSim/Data/Tests/BasicGridTest.cs b/OpenSim/Data/Tests/BasicGridTest.cs
index 85273c5..de8fb48 100644
--- a/OpenSim/Data/Tests/BasicGridTest.cs
+++ b/OpenSim/Data/Tests/BasicGridTest.cs
@@ -28,81 +28,47 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using log4net.Config;
32using NUnit.Framework; 31using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers; 32using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse; 33using OpenMetaverse;
35using log4net;
36using System.Reflection;
37 34
38namespace OpenSim.Data.Tests 35namespace OpenSim.Data.Tests
39{ 36{
40 public class BasicGridTest 37 public class BasicGridTest
41 { 38 {
42 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 39 public IGridDataPlugin db;
43 public GridDataBase db;
44 public UUID region1, region2, region3; 40 public UUID region1, region2, region3;
45 public UUID zero = UUID.Zero; 41 public UUID zero = UUID.Zero;
46 public static Random random; 42 public static Random random = new Random();
47 43
48 [TearDown] 44 [TearDown]
49 public void removeAllRegions() 45 public void removeAllRegions()
50 { 46 {
51 // Clean up all the regions. 47 // Clean up all the regions.
52 foreach (RegionProfileData region in db.GetRegionsByName("", 100)) 48 List<RegionProfileData> regions = db.GetRegionsByName("", 100);
49 if (regions != null)
53 { 50 {
54 db.DeleteProfile(region.Uuid.ToString()); 51 foreach (RegionProfileData region in regions)
52 {
53 db.DeleteProfile(region.Uuid.ToString());
54 }
55 } 55 }
56 } 56 }
57 57
58 public void SuperInit() 58 public void SuperInit()
59 { 59 {
60 try 60 OpenSim.Tests.Common.TestLogging.LogToConsole();
61 {
62 XmlConfigurator.Configure();
63 }
64 catch (Exception)
65 {
66 // I don't care, just leave log4net off
67 }
68 region1 = UUID.Random(); 61 region1 = UUID.Random();
69 region2 = UUID.Random(); 62 region2 = UUID.Random();
70 region3 = UUID.Random(); 63 region3 = UUID.Random();
71 random = new Random();
72 } 64 }
73 65
74 protected RegionProfileData createRegion(UUID regionUUID, string regionName) 66 protected RegionProfileData createRegion(UUID regionUUID, string regionName)
75 { 67 {
76 RegionProfileData reg = new RegionProfileData(); 68 RegionProfileData reg = new RegionProfileData();
69 new PropertyScrambler<RegionProfileData>().Scramble(reg);
77 reg.Uuid = regionUUID; 70 reg.Uuid = regionUUID;
78 reg.RegionName = regionName; 71 reg.RegionName = regionName;
79 reg.RegionHandle = (ulong) random.Next();
80 reg.RegionLocX = (uint) random.Next();
81 reg.RegionLocY = (uint) random.Next();
82 reg.RegionLocZ = (uint) random.Next();
83 reg.RegionSendKey = RandomName();
84 reg.RegionRecvKey = RandomName();
85 reg.RegionSecret = RandomName();
86 reg.RegionOnline = false;
87 reg.ServerIP = RandomName();
88 reg.ServerPort = (uint) random.Next();
89 reg.ServerURI = RandomName();
90 reg.ServerHttpPort = (uint) random.Next();
91 reg.ServerRemotingPort = (uint) random.Next();
92 reg.NorthOverrideHandle = (ulong) random.Next();
93 reg.SouthOverrideHandle = (ulong) random.Next();
94 reg.EastOverrideHandle = (ulong) random.Next();
95 reg.WestOverrideHandle = (ulong) random.Next();
96 reg.RegionDataURI = RandomName();
97 reg.RegionAssetURI = RandomName();
98 reg.RegionAssetSendKey = RandomName();
99 reg.RegionAssetRecvKey = RandomName();
100 reg.RegionUserURI = RandomName();
101 reg.RegionUserSendKey = RandomName();
102 reg.RegionUserRecvKey = RandomName();
103 reg.RegionMapTextureID = UUID.Random();
104 reg.Owner_uuid = UUID.Random();
105 reg.OriginUUID = UUID.Random();
106 72
107 db.AddProfile(reg); 73 db.AddProfile(reg);
108 74
@@ -119,47 +85,12 @@ namespace OpenSim.Data.Tests
119 } 85 }
120 86
121 [Test] 87 [Test]
122 public void T999_StillNull()
123 {
124 Assert.That(db.GetProfileByUUID(zero),Is.Null);
125 }
126
127 [Test]
128 public void T011_AddRetrieveCompleteTest() 88 public void T011_AddRetrieveCompleteTest()
129 { 89 {
130 RegionProfileData newreg = createRegion(region2, "|<Goth@m Ci1y>|"); 90 RegionProfileData newreg = createRegion(region2, "|<Goth@m Ci1y>|");
131 RegionProfileData retreg = db.GetProfileByUUID(region2); 91 RegionProfileData retreg = db.GetProfileByUUID(region2);
132 92
133 Assert.That(retreg.RegionName, Is.EqualTo(newreg.RegionName), "Assert.That(retreg.RegionName, Is.EqualTo(newreg.RegionName))"); 93 Assert.That(retreg, Constraints.PropertyCompareConstraint(newreg).IgnoreProperty(x => x.RegionOnline));
134 Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))");
135 Assert.That(retreg.RegionHandle, Is.EqualTo(newreg.RegionHandle), "Assert.That(retreg.RegionHandle, Is.EqualTo(newreg.RegionHandle))");
136 Assert.That(retreg.RegionLocX, Is.EqualTo(newreg.RegionLocX), "Assert.That(retreg.RegionLocX, Is.EqualTo(newreg.RegionLocX))");
137 Assert.That(retreg.RegionLocY, Is.EqualTo(newreg.RegionLocY), "Assert.That(retreg.RegionLocY, Is.EqualTo(newreg.RegionLocY))");
138 Assert.That(retreg.RegionLocZ, Is.EqualTo(newreg.RegionLocZ), "Assert.That(retreg.RegionLocZ, Is.EqualTo(newreg.RegionLocZ))");
139 Assert.That(retreg.RegionSendKey, Is.EqualTo(newreg.RegionSendKey), "Assert.That(retreg.RegionSendKey, Is.EqualTo(newreg.RegionSendKey))");
140 Assert.That(retreg.RegionRecvKey, Is.EqualTo(newreg.RegionRecvKey), "Assert.That(retreg.RegionRecvKey, Is.EqualTo(newreg.RegionRecvKey))");
141 Assert.That(retreg.RegionSecret, Is.EqualTo(newreg.RegionSecret), "Assert.That(retreg.RegionSecret, Is.EqualTo(newreg.RegionSecret))");
142 Assert.That(retreg.RegionOnline, Is.EqualTo(newreg.RegionOnline), "Assert.That(retreg.RegionOnline, Is.EqualTo(newreg.RegionOnline))");
143 Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID), "Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID))");
144 Assert.That(retreg.ServerIP, Is.EqualTo(newreg.ServerIP), "Assert.That(retreg.ServerIP, Is.EqualTo(newreg.ServerIP))");
145 Assert.That(retreg.ServerPort, Is.EqualTo(newreg.ServerPort), "Assert.That(retreg.ServerPort, Is.EqualTo(newreg.ServerPort))");
146 Assert.That(retreg.ServerURI, Is.EqualTo(newreg.ServerURI), "Assert.That(retreg.ServerURI, Is.EqualTo(newreg.ServerURI))");
147 Assert.That(retreg.ServerHttpPort, Is.EqualTo(newreg.ServerHttpPort), "Assert.That(retreg.ServerHttpPort, Is.EqualTo(newreg.ServerHttpPort))");
148 Assert.That(retreg.ServerRemotingPort, Is.EqualTo(newreg.ServerRemotingPort), "Assert.That(retreg.ServerRemotingPort, Is.EqualTo(newreg.ServerRemotingPort))");
149 Assert.That(retreg.NorthOverrideHandle, Is.EqualTo(newreg.NorthOverrideHandle), "Assert.That(retreg.NorthOverrideHandle, Is.EqualTo(newreg.NorthOverrideHandle))");
150 Assert.That(retreg.SouthOverrideHandle, Is.EqualTo(newreg.SouthOverrideHandle), "Assert.That(retreg.SouthOverrideHandle, Is.EqualTo(newreg.SouthOverrideHandle))");
151 Assert.That(retreg.EastOverrideHandle, Is.EqualTo(newreg.EastOverrideHandle), "Assert.That(retreg.EastOverrideHandle, Is.EqualTo(newreg.EastOverrideHandle))");
152 Assert.That(retreg.WestOverrideHandle, Is.EqualTo(newreg.WestOverrideHandle), "Assert.That(retreg.WestOverrideHandle, Is.EqualTo(newreg.WestOverrideHandle))");
153 Assert.That(retreg.RegionDataURI, Is.EqualTo(newreg.RegionDataURI), "Assert.That(retreg.RegionDataURI, Is.EqualTo(newreg.RegionDataURI))");
154 Assert.That(retreg.RegionAssetURI, Is.EqualTo(newreg.RegionAssetURI), "Assert.That(retreg.RegionAssetURI, Is.EqualTo(newreg.RegionAssetURI))");
155 Assert.That(retreg.RegionAssetSendKey, Is.EqualTo(newreg.RegionAssetSendKey), "Assert.That(retreg.RegionAssetSendKey, Is.EqualTo(newreg.RegionAssetSendKey))");
156 Assert.That(retreg.RegionAssetRecvKey, Is.EqualTo(newreg.RegionAssetRecvKey), "Assert.That(retreg.RegionAssetRecvKey, Is.EqualTo(newreg.RegionAssetRecvKey))");
157 Assert.That(retreg.RegionUserURI, Is.EqualTo(newreg.RegionUserURI), "Assert.That(retreg.RegionUserURI, Is.EqualTo(newreg.RegionUserURI))");
158 Assert.That(retreg.RegionUserSendKey, Is.EqualTo(newreg.RegionUserSendKey), "Assert.That(retreg.RegionUserSendKey, Is.EqualTo(newreg.RegionUserSendKey))");
159 Assert.That(retreg.RegionUserRecvKey, Is.EqualTo(newreg.RegionUserRecvKey), "Assert.That(retreg.RegionUserRecvKey, Is.EqualTo(newreg.RegionUserRecvKey))");
160 Assert.That(retreg.RegionMapTextureID, Is.EqualTo(newreg.RegionMapTextureID), "Assert.That(retreg.RegionMapTextureID, Is.EqualTo(newreg.RegionMapTextureID))");
161 Assert.That(retreg.Owner_uuid, Is.EqualTo(newreg.Owner_uuid), "Assert.That(retreg.Owner_uuid, Is.EqualTo(newreg.Owner_uuid))");
162 Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID), "Assert.That(retreg.OriginUUID, Is.EqualTo(newreg.OriginUUID))");
163 94
164 retreg = db.GetProfileByHandle(newreg.RegionHandle); 95 retreg = db.GetProfileByHandle(newreg.RegionHandle);
165 Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))"); 96 Assert.That(retreg.Uuid, Is.EqualTo(region2), "Assert.That(retreg.Uuid, Is.EqualTo(region2))");
@@ -220,6 +151,12 @@ namespace OpenSim.Data.Tests
220 Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))"); 151 Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2), "Assert.That(listreg[1].Uuid, Is.EqualTo(region1) | Is.EqualTo(region2))");
221 } 152 }
222 153
154 [Test]
155 public void T999_StillNull()
156 {
157 Assert.That(db.GetProfileByUUID(zero), Is.Null);
158 }
159
223 protected static string RandomName() 160 protected static string RandomName()
224 { 161 {
225 StringBuilder name = new StringBuilder(); 162 StringBuilder name = new StringBuilder();
diff --git a/OpenSim/Data/Tests/BasicInventoryTest.cs b/OpenSim/Data/Tests/BasicInventoryTest.cs
index e13ed89..900186b 100644
--- a/OpenSim/Data/Tests/BasicInventoryTest.cs
+++ b/OpenSim/Data/Tests/BasicInventoryTest.cs
@@ -66,14 +66,7 @@ namespace OpenSim.Data.Tests
66 66
67 public void SuperInit() 67 public void SuperInit()
68 { 68 {
69 try 69 OpenSim.Tests.Common.TestLogging.LogToConsole();
70 {
71 XmlConfigurator.Configure();
72 }
73 catch (Exception)
74 {
75 // I don't care, just leave log4net off
76 }
77 70
78 folder1 = UUID.Random(); 71 folder1 = UUID.Random();
79 folder2 = UUID.Random(); 72 folder2 = UUID.Random();
@@ -115,16 +108,6 @@ namespace OpenSim.Data.Tests
115 Assert.That(db.getUserRootFolder(owner1), Is.Null); 108 Assert.That(db.getUserRootFolder(owner1), Is.Null);
116 } 109 }
117 110
118 [Test]
119 public void T999_StillNull()
120 {
121 // After all tests are run, these should still return no results
122 Assert.That(db.getInventoryFolder(zero), Is.Null);
123 Assert.That(db.getInventoryItem(zero), Is.Null);
124 Assert.That(db.getUserRootFolder(zero), Is.Null);
125 Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
126 }
127
128 // 01x - folder tests 111 // 01x - folder tests
129 [Test] 112 [Test]
130 public void T010_FolderNonParent() 113 public void T010_FolderNonParent()
@@ -248,7 +231,7 @@ namespace OpenSim.Data.Tests
248 } 231 }
249 232
250 [Test] 233 [Test]
251 public void T103UpdateItem() 234 public void T103_UpdateItem()
252 { 235 {
253 // TODO: probably shouldn't have the ability to have an 236 // TODO: probably shouldn't have the ability to have an
254 // owner of an item in a folder not owned by the user 237 // owner of an item in a folder not owned by the user
@@ -265,6 +248,71 @@ namespace OpenSim.Data.Tests
265 Assert.That(i1.Owner, Is.EqualTo(owner2), "Assert.That(i1.Owner, Is.EqualTo(owner2))"); 248 Assert.That(i1.Owner, Is.EqualTo(owner2), "Assert.That(i1.Owner, Is.EqualTo(owner2))");
266 } 249 }
267 250
251 [Test]
252 public void T104_RandomUpdateItem()
253 {
254 PropertyScrambler<InventoryFolderBase> folderScrambler =
255 new PropertyScrambler<InventoryFolderBase>()
256 .DontScramble(x => x.Owner)
257 .DontScramble(x => x.ParentID)
258 .DontScramble(x => x.ID);
259 UUID owner = UUID.Random();
260 UUID folder = UUID.Random();
261 UUID rootId = UUID.Random();
262 UUID rootAsset = UUID.Random();
263 InventoryFolderBase f1 = NewFolder(folder, zero, owner, name1);
264 folderScrambler.Scramble(f1);
265
266 db.addInventoryFolder(f1);
267 InventoryFolderBase f1a = db.getUserRootFolder(owner);
268 Assert.That(f1a, Constraints.PropertyCompareConstraint(f1));
269
270 folderScrambler.Scramble(f1a);
271
272 db.updateInventoryFolder(f1a);
273
274 InventoryFolderBase f1b = db.getUserRootFolder(owner);
275 Assert.That(f1b, Constraints.PropertyCompareConstraint(f1a));
276
277 //Now we have a valid folder to insert into, we can insert the item.
278 PropertyScrambler<InventoryItemBase> inventoryScrambler =
279 new PropertyScrambler<InventoryItemBase>()
280 .DontScramble(x => x.ID)
281 .DontScramble(x => x.AssetID)
282 .DontScramble(x => x.Owner)
283 .DontScramble(x => x.Folder);
284 InventoryItemBase root = NewItem(rootId, folder, owner, iname1, rootAsset);
285 inventoryScrambler.Scramble(root);
286 db.addInventoryItem(root);
287
288 InventoryItemBase expected = db.getInventoryItem(rootId);
289 Assert.That(expected, Constraints.PropertyCompareConstraint(root)
290 .IgnoreProperty(x => x.InvType)
291 .IgnoreProperty(x => x.CreatorIdAsUuid)
292 .IgnoreProperty(x => x.Description)
293 .IgnoreProperty(x => x.CreatorId));
294
295 inventoryScrambler.Scramble(expected);
296 db.updateInventoryItem(expected);
297
298 InventoryItemBase actual = db.getInventoryItem(rootId);
299 Assert.That(actual, Constraints.PropertyCompareConstraint(expected)
300 .IgnoreProperty(x => x.InvType)
301 .IgnoreProperty(x => x.CreatorIdAsUuid)
302 .IgnoreProperty(x => x.Description)
303 .IgnoreProperty(x => x.CreatorId));
304 }
305
306 [Test]
307 public void T999_StillNull()
308 {
309 // After all tests are run, these should still return no results
310 Assert.That(db.getInventoryFolder(zero), Is.Null);
311 Assert.That(db.getInventoryItem(zero), Is.Null);
312 Assert.That(db.getUserRootFolder(zero), Is.Null);
313 Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0), "Assert.That(db.getInventoryInFolder(zero).Count, Is.EqualTo(0))");
314 }
315
268 private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset) 316 private InventoryItemBase NewItem(UUID id, UUID parent, UUID owner, string name, UUID asset)
269 { 317 {
270 InventoryItemBase i = new InventoryItemBase(); 318 InventoryItemBase i = new InventoryItemBase();
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs
index 836da78..8474921 100644
--- a/OpenSim/Data/Tests/BasicRegionTest.cs
+++ b/OpenSim/Data/Tests/BasicRegionTest.cs
@@ -71,14 +71,7 @@ namespace OpenSim.Data.Tests
71 71
72 public void SuperInit() 72 public void SuperInit()
73 { 73 {
74 try 74 OpenSim.Tests.Common.TestLogging.LogToConsole();
75 {
76 XmlConfigurator.Configure();
77 }
78 catch (Exception)
79 {
80 // I don't care, just leave log4net off
81 }
82 75
83 region1 = UUID.Random(); 76 region1 = UUID.Random();
84 region3 = UUID.Random(); 77 region3 = UUID.Random();
@@ -532,6 +525,62 @@ namespace OpenSim.Data.Tests
532 Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration), "Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration))"); 525 Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration), "Assert.That(cursop.Acceleration,Is.EqualTo(parts[i].Acceleration))");
533 } 526 }
534 } 527 }
528
529 [Test]
530 public void T016_RandomSogWithSceneParts()
531 {
532 PropertyScrambler<SceneObjectPart> scrambler =
533 new PropertyScrambler<SceneObjectPart>()
534 .DontScramble(x => x.UUID);
535 UUID tmpSog = UUID.Random();
536 UUID tmp1 = UUID.Random();
537 UUID tmp2 = UUID.Random();
538 UUID tmp3 = UUID.Random();
539 UUID newregion = UUID.Random();
540 SceneObjectPart p1 = new SceneObjectPart();
541 SceneObjectPart p2 = new SceneObjectPart();
542 SceneObjectPart p3 = new SceneObjectPart();
543 p1.Shape = PrimitiveBaseShape.Default;
544 p2.Shape = PrimitiveBaseShape.Default;
545 p3.Shape = PrimitiveBaseShape.Default;
546 p1.UUID = tmp1;
547 p2.UUID = tmp2;
548 p3.UUID = tmp3;
549 scrambler.Scramble(p1);
550 scrambler.Scramble(p2);
551 scrambler.Scramble(p3);
552
553 SceneObjectGroup sog = NewSOG("Sop 0", tmpSog, newregion);
554 PropertyScrambler<SceneObjectGroup> sogScrambler =
555 new PropertyScrambler<SceneObjectGroup>()
556 .DontScramble(x => x.UUID);
557 sogScrambler.Scramble(sog);
558 sog.UUID = tmpSog;
559 sog.AddPart(p1);
560 sog.AddPart(p2);
561 sog.AddPart(p3);
562
563 SceneObjectPart[] parts = sog.GetParts();
564 Assert.That(parts.Length, Is.EqualTo(4), "Assert.That(parts.Length,Is.EqualTo(4))");
565
566 db.StoreObject(sog, newregion);
567 List<SceneObjectGroup> sogs = db.LoadObjects(newregion);
568 Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count,Is.EqualTo(1))");
569 SceneObjectGroup newsog = sogs[0];
570
571 SceneObjectPart[] newparts = newsog.GetParts();
572 Assert.That(newparts.Length, Is.EqualTo(4), "Assert.That(newparts.Length,Is.EqualTo(4))");
573
574 Assert.That(newsog, Constraints.PropertyCompareConstraint(sog)
575 .IgnoreProperty(x=>x.LocalId)
576 .IgnoreProperty(x=>x.HasGroupChanged)
577 .IgnoreProperty(x=>x.IsSelected)
578 .IgnoreProperty(x=>x.RegionHandle)
579 .IgnoreProperty(x=>x.RegionUUID)
580 .IgnoreProperty(x=>x.Scene)
581 .IgnoreProperty(x=>x.Children)
582 .IgnoreProperty(x=>x.RootPart));
583 }
535 584
536 [Test] 585 [Test]
537 public void T020_PrimInventoryEmpty() 586 public void T020_PrimInventoryEmpty()
diff --git a/OpenSim/Data/Tests/BasicUserTest.cs b/OpenSim/Data/Tests/BasicUserTest.cs
index 4e4ddc8..f9feb9b 100644
--- a/OpenSim/Data/Tests/BasicUserTest.cs
+++ b/OpenSim/Data/Tests/BasicUserTest.cs
@@ -71,14 +71,7 @@ namespace OpenSim.Data.Tests
71 71
72 public void SuperInit() 72 public void SuperInit()
73 { 73 {
74 try 74 OpenSim.Tests.Common.TestLogging.LogToConsole();
75 {
76 XmlConfigurator.Configure();
77 }
78 catch (Exception)
79 {
80 // I don't care, just leave log4net off
81 }
82 random = new Random(); 75 random = new Random();
83 user1 = UUID.Random(); 76 user1 = UUID.Random();
84 user2 = UUID.Random(); 77 user2 = UUID.Random();
@@ -118,13 +111,6 @@ namespace OpenSim.Data.Tests
118 } 111 }
119 112
120 [Test] 113 [Test]
121 public void T999_StillNull()
122 {
123 Assert.That(db.GetUserByUUID(zero), Is.Null);
124 Assert.That(db.GetAgentByUUID(zero), Is.Null);
125 }
126
127 [Test]
128 public void T010_CreateUser() 114 public void T010_CreateUser()
129 { 115 {
130 UserProfileData u1 = NewUser(user1,fname1,lname1); 116 UserProfileData u1 = NewUser(user1,fname1,lname1);
@@ -396,6 +382,22 @@ namespace OpenSim.Data.Tests
396 Assert.That(customtype,Is.EqualTo(u1a.CustomType), "Assert.That(customtype,Is.EqualTo(u1a.CustomType))"); 382 Assert.That(customtype,Is.EqualTo(u1a.CustomType), "Assert.That(customtype,Is.EqualTo(u1a.CustomType))");
397 Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))"); 383 Assert.That(partner,Is.EqualTo(u1a.Partner), "Assert.That(partner,Is.EqualTo(u1a.Partner))");
398 } 384 }
385
386 [Test]
387 public void T017_UserUpdateRandomPersistency()
388 {
389 UUID id = user5;
390 UserProfileData u = db.GetUserByUUID(id);
391 new PropertyScrambler<UserProfileData>().DontScramble(x=>x.ID).Scramble(u);
392
393 db.UpdateUserProfile(u);
394 UserProfileData u1a = db.GetUserByUUID(id);
395 Assert.That(u1a, Constraints.PropertyCompareConstraint(u)
396 .IgnoreProperty(x=>x.HomeRegionX)
397 .IgnoreProperty(x=>x.HomeRegionY)
398 .IgnoreProperty(x=>x.RootInventoryFolderID)
399 );
400 }
399 401
400 [Test] 402 [Test]
401 public void T020_CreateAgent() 403 public void T020_CreateAgent()
@@ -660,6 +662,13 @@ namespace OpenSim.Data.Tests
660 Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight), "Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight))"); 662 Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight), "Assert.That(avatarheight,Is.EqualTo(app.AvatarHeight))");
661 } 663 }
662 664
665 [Test]
666 public void T999_StillNull()
667 {
668 Assert.That(db.GetUserByUUID(zero), Is.Null);
669 Assert.That(db.GetAgentByUUID(zero), Is.Null);
670 }
671
663 public UserProfileData NewUser(UUID id,string fname,string lname) 672 public UserProfileData NewUser(UUID id,string fname,string lname)
664 { 673 {
665 UserProfileData u = new UserProfileData(); 674 UserProfileData u = new UserProfileData();
diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
index 063267b..06ca53e 100644
--- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs
+++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs
@@ -69,6 +69,28 @@ namespace OpenSim.Data.Tests
69 69
70 private bool ObjectCompare(object expected, object actual, Stack<string> propertyNames) 70 private bool ObjectCompare(object expected, object actual, Stack<string> propertyNames)
71 { 71 {
72 //If they are both null, they are equal
73 if (actual == null && expected == null)
74 return true;
75
76 //If only one is null, then they aren't
77 if (actual == null || expected == null)
78 {
79 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
80 failingActual = actual;
81 failingExpected = expected;
82 return false;
83 }
84
85 //prevent loops...
86 if (propertyNames.Count > 50)
87 {
88 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
89 failingActual = actual;
90 failingExpected = expected;
91 return false;
92 }
93
72 if (actual.GetType() != expected.GetType()) 94 if (actual.GetType() != expected.GetType())
73 { 95 {
74 propertyNames.Push("GetType()"); 96 propertyNames.Push("GetType()");
@@ -122,65 +144,69 @@ namespace OpenSim.Data.Tests
122 return true; 144 return true;
123 } 145 }
124 146
125 //Skip static properties. I had a nasty problem comparing colors because of all of the public static colors. 147 IComparable comp = actual as IComparable;
126 PropertyInfo[] properties = expected.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); 148 if (comp != null)
127 foreach (var property in properties)
128 { 149 {
129 if (ignores.Contains(property.Name)) 150 if (comp.CompareTo(expected) != 0)
130 continue; 151 {
131 152 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
132 object actualValue = property.GetValue(actual, null); 153 failingActual = actual;
133 object expectedValue = property.GetValue(expected, null); 154 failingExpected = expected;
155 return false;
156 }
157 return true;
158 }
134 159
135 //If they are both null, they are equal 160 //Now try the much more annoying IComparable<T>
136 if (actualValue == null && expectedValue == null) 161 Type icomparableInterface = actual.GetType().GetInterface("IComparable`1");
137 continue; 162 if (icomparableInterface != null)
163 {
164 int result = (int)icomparableInterface.GetMethod("CompareTo").Invoke(actual, new[] { expected });
165 if (result != 0)
166 {
167 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
168 failingActual = actual;
169 failingExpected = expected;
170 return false;
171 }
172 return true;
173 }
138 174
139 //If only one is null, then they aren't 175 IEnumerable arr = actual as IEnumerable;
140 if (actualValue == null || expectedValue == null) 176 if (arr != null)
177 {
178 List<object> actualList = arr.Cast<object>().ToList();
179 List<object> expectedList = ((IEnumerable)expected).Cast<object>().ToList();
180 if (actualList.Count != expectedList.Count)
141 { 181 {
142 propertyNames.Push(property.Name); 182 propertyNames.Push("Count");
143 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray()); 183 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
184 failingActual = actualList.Count;
185 failingExpected = expectedList.Count;
144 propertyNames.Pop(); 186 propertyNames.Pop();
145 failingActual = actualValue;
146 failingExpected = expectedValue;
147 return false; 187 return false;
148 } 188 }
149 189 //actualList and expectedList should be the same size.
150 IComparable comp = actualValue as IComparable; 190 for (int i = 0; i < actualList.Count; i++)
151 if (comp != null)
152 { 191 {
153 if (comp.CompareTo(expectedValue) != 0) 192 propertyNames.Push("[" + i + "]");
154 { 193 if (!ObjectCompare(expectedList[i], actualList[i], propertyNames))
155 propertyNames.Push(property.Name);
156 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
157 propertyNames.Pop();
158 failingActual = actualValue;
159 failingExpected = expectedValue;
160 return false; 194 return false;
161 } 195 propertyNames.Pop();
162 continue;
163 } 196 }
197 //Everything seems okay...
198 return true;
199 }
164 200
165 IEnumerable arr = actualValue as IEnumerable; 201 //Skip static properties. I had a nasty problem comparing colors because of all of the public static colors.
166 if (arr != null) 202 PropertyInfo[] properties = expected.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
167 { 203 foreach (var property in properties)
168 List<object> actualList = arr.Cast<object>().ToList(); 204 {
169 List<object> expectedList = ((IEnumerable)expectedValue).Cast<object>().ToList(); 205 if (ignores.Contains(property.Name))
170 if (actualList.Count != expectedList.Count)
171 {
172 propertyNames.Push(property.Name);
173 propertyNames.Push("Count");
174 failingPropertyName = string.Join(".", propertyNames.Reverse().ToArray());
175 failingActual = actualList.Count;
176 failingExpected = expectedList.Count;
177 propertyNames.Pop();
178 propertyNames.Pop();
179 }
180 //Todo: A value-wise comparison of all of the values.
181 //Everything seems okay...
182 continue; 206 continue;
183 } 207
208 object actualValue = property.GetValue(actual, null);
209 object expectedValue = property.GetValue(expected, null);
184 210
185 propertyNames.Push(property.Name); 211 propertyNames.Push(property.Name);
186 if (!ObjectCompare(expectedValue, actualValue, propertyNames)) 212 if (!ObjectCompare(expectedValue, actualValue, propertyNames))
@@ -223,15 +249,7 @@ namespace OpenSim.Data.Tests
223 { 249 {
224 //If the inside of the lambda is the access to x, we've hit the end of the chain. 250 //If the inside of the lambda is the access to x, we've hit the end of the chain.
225 // We should track by the fully scoped parameter name, but this is the first rev of doing this. 251 // We should track by the fully scoped parameter name, but this is the first rev of doing this.
226 if (((MemberExpression)express).Expression is ParameterExpression) 252 ignores.Add(((MemberExpression)express).Member.Name);
227 {
228 ignores.Add(((MemberExpression)express).Member.Name);
229 }
230 else
231 {
232 //Otherwise there could be more parameters inside...
233 PullApartExpression(((MemberExpression)express).Expression);
234 }
235 } 253 }
236 } 254 }
237 } 255 }
@@ -270,7 +288,7 @@ namespace OpenSim.Data.Tests
270 { 288 {
271 HasInt actual = new HasInt { TheValue = 5 }; 289 HasInt actual = new HasInt { TheValue = 5 };
272 HasInt expected = new HasInt { TheValue = 4 }; 290 HasInt expected = new HasInt { TheValue = 4 };
273 var constraint = Constraints.PropertyCompareConstraint(expected).IgnoreProperty(x=>x.TheValue); 291 var constraint = Constraints.PropertyCompareConstraint(expected).IgnoreProperty(x => x.TheValue);
274 292
275 Assert.That(constraint.Matches(actual), Is.True); 293 Assert.That(constraint.Matches(actual), Is.True);
276 } 294 }
@@ -312,6 +330,28 @@ namespace OpenSim.Data.Tests
312 } 330 }
313 331
314 [Test] 332 [Test]
333 public void UUIDShouldMatch()
334 {
335 UUID uuid1 = UUID.Random();
336 UUID uuid2 = UUID.Parse(uuid1.ToString());
337
338 var constraint = Constraints.PropertyCompareConstraint(uuid1);
339
340 Assert.That(constraint.Matches(uuid2), Is.True);
341 }
342
343 [Test]
344 public void UUIDShouldNotMatch()
345 {
346 UUID uuid1 = UUID.Random();
347 UUID uuid2 = UUID.Random();
348
349 var constraint = Constraints.PropertyCompareConstraint(uuid1);
350
351 Assert.That(constraint.Matches(uuid2), Is.False);
352 }
353
354 [Test]
315 public void TestColors() 355 public void TestColors()
316 { 356 {
317 Color actual = Color.Red; 357 Color actual = Color.Red;
@@ -321,5 +361,53 @@ namespace OpenSim.Data.Tests
321 361
322 Assert.That(constraint.Matches(actual), Is.True); 362 Assert.That(constraint.Matches(actual), Is.True);
323 } 363 }
364
365 [Test]
366 public void ShouldCompareLists()
367 {
368 List<int> expected = new List<int> { 1, 2, 3 };
369 List<int> actual = new List<int> { 1, 2, 3 };
370
371 var constraint = Constraints.PropertyCompareConstraint(expected);
372 Assert.That(constraint.Matches(actual), Is.True);
373 }
374
375
376 [Test]
377 public void ShouldFailToCompareListsThatAreDifferent()
378 {
379 List<int> expected = new List<int> { 1, 2, 3 };
380 List<int> actual = new List<int> { 1, 2, 4 };
381
382 var constraint = Constraints.PropertyCompareConstraint(expected);
383 Assert.That(constraint.Matches(actual), Is.False);
384 }
385
386 [Test]
387 public void ShouldFailToCompareListsThatAreDifferentLengths()
388 {
389 List<int> expected = new List<int> { 1, 2, 3 };
390 List<int> actual = new List<int> { 1, 2 };
391
392 var constraint = Constraints.PropertyCompareConstraint(expected);
393 Assert.That(constraint.Matches(actual), Is.False);
394 }
395
396 public class Recursive
397 {
398 public Recursive Other { get; set; }
399 }
400
401 [Test]
402 public void ErrorsOutOnRecursive()
403 {
404 Recursive parent = new Recursive();
405 Recursive child = new Recursive();
406 parent.Other = child;
407 child.Other = parent;
408
409 var constraint = Constraints.PropertyCompareConstraint(child);
410 Assert.That(constraint.Matches(child), Is.False);
411 }
324 } 412 }
325} \ No newline at end of file 413} \ No newline at end of file
diff --git a/OpenSim/Data/Tests/ScrambleForTesting.cs b/OpenSim/Data/Tests/PropertyScrambler.cs
index 3a22347..72aaff1 100644
--- a/OpenSim/Data/Tests/ScrambleForTesting.cs
+++ b/OpenSim/Data/Tests/PropertyScrambler.cs
@@ -27,18 +27,58 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
31using System.Linq.Expressions;
30using System.Reflection; 32using System.Reflection;
31using System.Text; 33using System.Text;
32using NUnit.Framework; 34using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers;
33using OpenMetaverse; 36using OpenMetaverse;
34using OpenSim.Framework; 37using OpenSim.Framework;
35 38
36namespace OpenSim.Data.Tests 39namespace OpenSim.Data.Tests
37{ 40{
38 public static class ScrambleForTesting 41
42 //This is generic so that the lambda expressions will work right in IDEs.
43 public class PropertyScrambler<T>
39 { 44 {
40 private static readonly Random random = new Random(); 45 readonly System.Collections.Generic.List<string> membersToNotScramble = new List<string>();
41 public static void Scramble(object obj) 46
47 private void AddExpressionToNotScrableList(Expression expression)
48 {
49 UnaryExpression unaryExpression = expression as UnaryExpression;
50 if (unaryExpression != null)
51 {
52 AddExpressionToNotScrableList(unaryExpression.Operand);
53 return;
54 }
55
56 MemberExpression memberExpression = expression as MemberExpression;
57 if (memberExpression != null)
58 {
59 if (!(memberExpression.Member is PropertyInfo))
60 {
61 throw new NotImplementedException("I don't know how deal with a MemberExpression that is a " + expression.Type);
62 }
63 membersToNotScramble.Add(memberExpression.Member.Name);
64 return;
65 }
66
67 throw new NotImplementedException("I don't know how to parse a " + expression.Type);
68 }
69
70 public PropertyScrambler<T> DontScramble(Expression<Func<T, object>> expression)
71 {
72 AddExpressionToNotScrableList(expression.Body);
73 return this;
74 }
75
76 public void Scramble(T obj)
77 {
78 internalScramble(obj);
79 }
80
81 private void internalScramble(object obj)
42 { 82 {
43 PropertyInfo[] properties = obj.GetType().GetProperties(); 83 PropertyInfo[] properties = obj.GetType().GetProperties();
44 foreach (var property in properties) 84 foreach (var property in properties)
@@ -57,13 +97,16 @@ namespace OpenSim.Data.Tests
57 { 97 {
58 foreach (object value in enumerable) 98 foreach (object value in enumerable)
59 { 99 {
60 Scramble(value); 100 internalScramble(value);
61 } 101 }
62 } 102 }
63 } 103 }
64 104
65 private static void RandomizeProperty(object obj, PropertyInfo property, object[] index) 105 private readonly Random random = new Random();
66 { 106 private void RandomizeProperty(object obj, PropertyInfo property, object[] index)
107 {//I'd like a better way to compare, but I had lots of problems with InventoryFolderBase because the ID is inherited.
108 if (membersToNotScramble.Contains(property.Name))
109 return;
67 Type t = property.PropertyType; 110 Type t = property.PropertyType;
68 if (!property.CanWrite) 111 if (!property.CanWrite)
69 return; 112 return;
@@ -71,39 +114,39 @@ namespace OpenSim.Data.Tests
71 if (value == null) 114 if (value == null)
72 return; 115 return;
73 116
74 if (t == typeof (string)) 117 if (t == typeof(string))
75 property.SetValue(obj, RandomName(), index); 118 property.SetValue(obj, RandomName(), index);
76 else if (t == typeof (UUID)) 119 else if (t == typeof(UUID))
77 property.SetValue(obj, UUID.Random(), index); 120 property.SetValue(obj, UUID.Random(), index);
78 else if (t == typeof (sbyte)) 121 else if (t == typeof(sbyte))
79 property.SetValue(obj, (sbyte)random.Next(sbyte.MinValue, sbyte.MaxValue), index); 122 property.SetValue(obj, (sbyte)random.Next(sbyte.MinValue, sbyte.MaxValue), index);
80 else if (t == typeof (short)) 123 else if (t == typeof(short))
81 property.SetValue(obj, (short)random.Next(short.MinValue, short.MaxValue), index); 124 property.SetValue(obj, (short)random.Next(short.MinValue, short.MaxValue), index);
82 else if (t == typeof (int)) 125 else if (t == typeof(int))
83 property.SetValue(obj, random.Next(), index); 126 property.SetValue(obj, random.Next(), index);
84 else if (t == typeof (long)) 127 else if (t == typeof(long))
85 property.SetValue(obj, random.Next() * int.MaxValue, index); 128 property.SetValue(obj, random.Next() * int.MaxValue, index);
86 else if (t == typeof (byte)) 129 else if (t == typeof(byte))
87 property.SetValue(obj, (byte)random.Next(byte.MinValue, byte.MaxValue), index); 130 property.SetValue(obj, (byte)random.Next(byte.MinValue, byte.MaxValue), index);
88 else if (t == typeof (ushort)) 131 else if (t == typeof(ushort))
89 property.SetValue(obj, (ushort)random.Next(ushort.MinValue, ushort.MaxValue), index); 132 property.SetValue(obj, (ushort)random.Next(ushort.MinValue, ushort.MaxValue), index);
90 else if (t == typeof (uint)) 133 else if (t == typeof(uint))
91 property.SetValue(obj, Convert.ToUInt32(random.Next()), index); 134 property.SetValue(obj, Convert.ToUInt32(random.Next()), index);
92 else if (t == typeof (ulong)) 135 else if (t == typeof(ulong))
93 property.SetValue(obj, Convert.ToUInt64(random.Next()) * Convert.ToUInt64(UInt32.MaxValue), index); 136 property.SetValue(obj, Convert.ToUInt64(random.Next()) * Convert.ToUInt64(UInt32.MaxValue), index);
94 else if (t == typeof (bool)) 137 else if (t == typeof(bool))
95 property.SetValue(obj, true, index); 138 property.SetValue(obj, true, index);
96 else if (t == typeof (byte[])) 139 else if (t == typeof(byte[]))
97 { 140 {
98 byte[] bytes = new byte[30]; 141 byte[] bytes = new byte[30];
99 random.NextBytes(bytes); 142 random.NextBytes(bytes);
100 property.SetValue(obj, bytes, index); 143 property.SetValue(obj, bytes, index);
101 } 144 }
102 else 145 else
103 Scramble(value); 146 internalScramble(value);
104 } 147 }
105 148
106 private static string RandomName() 149 private string RandomName()
107 { 150 {
108 StringBuilder name = new StringBuilder(); 151 StringBuilder name = new StringBuilder();
109 int size = random.Next(5, 12); 152 int size = random.Next(5, 12);
@@ -117,13 +160,27 @@ namespace OpenSim.Data.Tests
117 } 160 }
118 161
119 [TestFixture] 162 [TestFixture]
120 public class ScrableForTestingTest 163 public class PropertyScramblerTests
121 { 164 {
122 [Test] 165 [Test]
123 public void TestScramble() 166 public void TestScramble()
124 { 167 {
125 AssetBase actual = new AssetBase(UUID.Random(), "asset one"); 168 AssetBase actual = new AssetBase(UUID.Random(), "asset one");
126 ScrambleForTesting.Scramble(actual); 169 new PropertyScrambler<AssetBase>().Scramble(actual);
170 }
171
172 [Test]
173 public void DontScramble()
174 {
175 UUID uuid = UUID.Random();
176 AssetBase asset = new AssetBase();
177 asset.FullID = uuid;
178 new PropertyScrambler<AssetBase>()
179 .DontScramble(x => x.Metadata)
180 .DontScramble(x => x.FullID)
181 .DontScramble(x => x.ID)
182 .Scramble(asset);
183 Assert.That(asset.FullID, Is.EqualTo(uuid));
127 } 184 }
128 } 185 }
129} \ No newline at end of file 186} \ No newline at end of file
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs
index 8b63d01..3387013 100644
--- a/OpenSim/Framework/Console/CommandConsole.cs
+++ b/OpenSim/Framework/Console/CommandConsole.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Xml;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Diagnostics; 31using System.Diagnostics;
31using System.Reflection; 32using System.Reflection;
@@ -369,6 +370,155 @@ namespace OpenSim.Framework.Console
369 370
370 return new string[0]; 371 return new string[0];
371 } 372 }
373
374 public XmlElement GetXml(XmlDocument doc)
375 {
376 CommandInfo help = (CommandInfo)((Dictionary<string, object>)tree["help"])[String.Empty];
377 ((Dictionary<string, object>)tree["help"]).Remove(string.Empty);
378 if (((Dictionary<string, object>)tree["help"]).Count == 0)
379 tree.Remove("help");
380
381 CommandInfo quit = (CommandInfo)((Dictionary<string, object>)tree["quit"])[String.Empty];
382 ((Dictionary<string, object>)tree["quit"]).Remove(string.Empty);
383 if (((Dictionary<string, object>)tree["quit"]).Count == 0)
384 tree.Remove("quit");
385
386 XmlElement root = doc.CreateElement("", "HelpTree", "");
387
388 ProcessTreeLevel(tree, root, doc);
389
390 if (!tree.ContainsKey("help"))
391 tree["help"] = (object) new Dictionary<string, object>();
392 ((Dictionary<string, object>)tree["help"])[String.Empty] = help;
393
394 if (!tree.ContainsKey("quit"))
395 tree["quit"] = (object) new Dictionary<string, object>();
396 ((Dictionary<string, object>)tree["quit"])[String.Empty] = quit;
397
398 return root;
399 }
400
401 private void ProcessTreeLevel(Dictionary<string, object> level, XmlElement xml, XmlDocument doc)
402 {
403 foreach (KeyValuePair<string, object> kvp in level)
404 {
405 if (kvp.Value is Dictionary<string, Object>)
406 {
407 XmlElement next = doc.CreateElement("", "Level", "");
408 next.SetAttribute("Name", kvp.Key);
409
410 xml.AppendChild(next);
411
412 ProcessTreeLevel((Dictionary<string, object>)kvp.Value, next, doc);
413 }
414 else
415 {
416 CommandInfo c = (CommandInfo)kvp.Value;
417
418 XmlElement cmd = doc.CreateElement("", "Command", "");
419
420 XmlElement e;
421
422 e = doc.CreateElement("", "Module", "");
423 cmd.AppendChild(e);
424 e.AppendChild(doc.CreateTextNode(c.module));
425
426 e = doc.CreateElement("", "Shared", "");
427 cmd.AppendChild(e);
428 e.AppendChild(doc.CreateTextNode(c.shared.ToString()));
429
430 e = doc.CreateElement("", "HelpText", "");
431 cmd.AppendChild(e);
432 e.AppendChild(doc.CreateTextNode(c.help_text));
433
434 e = doc.CreateElement("", "LongHelp", "");
435 cmd.AppendChild(e);
436 e.AppendChild(doc.CreateTextNode(c.long_help));
437
438 e = doc.CreateElement("", "Description", "");
439 cmd.AppendChild(e);
440 e.AppendChild(doc.CreateTextNode(c.descriptive_help));
441
442 xml.AppendChild(cmd);
443 }
444 }
445 }
446
447 public void FromXml(XmlElement root, CommandDelegate fn)
448 {
449 CommandInfo help = (CommandInfo)((Dictionary<string, object>)tree["help"])[String.Empty];
450 ((Dictionary<string, object>)tree["help"]).Remove(string.Empty);
451 if (((Dictionary<string, object>)tree["help"]).Count == 0)
452 tree.Remove("help");
453
454 CommandInfo quit = (CommandInfo)((Dictionary<string, object>)tree["quit"])[String.Empty];
455 ((Dictionary<string, object>)tree["quit"]).Remove(string.Empty);
456 if (((Dictionary<string, object>)tree["quit"]).Count == 0)
457 tree.Remove("quit");
458
459 tree.Clear();
460
461 ReadTreeLevel(tree, root, fn);
462
463 if (!tree.ContainsKey("help"))
464 tree["help"] = (object) new Dictionary<string, object>();
465 ((Dictionary<string, object>)tree["help"])[String.Empty] = help;
466
467 if (!tree.ContainsKey("quit"))
468 tree["quit"] = (object) new Dictionary<string, object>();
469 ((Dictionary<string, object>)tree["quit"])[String.Empty] = quit;
470 }
471
472 private void ReadTreeLevel(Dictionary<string, object> level, XmlNode node, CommandDelegate fn)
473 {
474 Dictionary<string, object> next;
475 string name;
476
477 XmlNodeList nodeL = node.ChildNodes;
478 XmlNodeList cmdL;
479 CommandInfo c;
480
481 foreach (XmlNode part in nodeL)
482 {
483 switch (part.Name)
484 {
485 case "Level":
486 name = ((XmlElement)part).GetAttribute("Name");
487 next = new Dictionary<string, object>();
488 level[name] = next;
489 ReadTreeLevel(next, part, fn);
490 break;
491 case "Command":
492 cmdL = part.ChildNodes;
493 c = new CommandInfo();
494 foreach (XmlNode cmdPart in cmdL)
495 {
496 switch (cmdPart.Name)
497 {
498 case "Module":
499 c.module = cmdPart.InnerText;
500 break;
501 case "Shared":
502 c.shared = Convert.ToBoolean(cmdPart.InnerText);
503 break;
504 case "HelpText":
505 c.help_text = cmdPart.InnerText;
506 break;
507 case "LongHelp":
508 c.long_help = cmdPart.InnerText;
509 break;
510 case "Description":
511 c.descriptive_help = cmdPart.InnerText;
512 break;
513 }
514 }
515 c.fn = new List<CommandDelegate>();
516 c.fn.Add(fn);
517 level[String.Empty] = c;
518 break;
519 }
520 }
521 }
372 } 522 }
373 523
374 public class Parser 524 public class Parser
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs
index 73209be..da8556a 100644
--- a/OpenSim/Framework/Console/RemoteConsole.cs
+++ b/OpenSim/Framework/Console/RemoteConsole.cs
@@ -26,30 +26,43 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Xml;
30using System.Collections;
29using System.Collections.Generic; 31using System.Collections.Generic;
30using System.Diagnostics; 32using System.Diagnostics;
31using System.Reflection; 33using System.Reflection;
32using System.Text; 34using System.Text;
33using System.Threading; 35using System.Threading;
36using OpenMetaverse;
34using Nini.Config; 37using Nini.Config;
35using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
36using log4net; 39using log4net;
37 40
38namespace OpenSim.Framework.Console 41namespace OpenSim.Framework.Console
39{ 42{
43 public class ConsoleConnection
44 {
45 public int last;
46 public long lastLineSeen;
47 }
48
40 // A console that uses REST interfaces 49 // A console that uses REST interfaces
41 // 50 //
42 public class RemoteConsole : CommandConsole 51 public class RemoteConsole : CommandConsole
43 { 52 {
44// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 54
46 // private IHttpServer m_Server = null; 55 private IHttpServer m_Server = null;
47 // private IConfigSource m_Config = null; 56 private IConfigSource m_Config = null;
48 57
49 private List<string> m_Scrollback = new List<string>(); 58 private List<string> m_Scrollback = new List<string>();
50 private ManualResetEvent m_DataEvent = new ManualResetEvent(false); 59 private ManualResetEvent m_DataEvent = new ManualResetEvent(false);
51 private List<string> m_InputData = new List<string>(); 60 private List<string> m_InputData = new List<string>();
52 private uint m_LineNumber = 1; 61 private long m_LineNumber = 0;
62 private Dictionary<UUID, ConsoleConnection> m_Connections =
63 new Dictionary<UUID, ConsoleConnection>();
64 private string m_UserName = String.Empty;
65 private string m_Password = String.Empty;
53 66
54 public RemoteConsole(string defaultPrompt) : base(defaultPrompt) 67 public RemoteConsole(string defaultPrompt) : base(defaultPrompt)
55 { 68 {
@@ -57,12 +70,23 @@ namespace OpenSim.Framework.Console
57 70
58 public void ReadConfig(IConfigSource config) 71 public void ReadConfig(IConfigSource config)
59 { 72 {
60 // m_Config = config; 73 m_Config = config;
74
75 IConfig netConfig = m_Config.Configs["Network"];
76 if (netConfig == null)
77 return;
78
79 m_UserName = netConfig.GetString("ConsoleUser", String.Empty);
80 m_Password = netConfig.GetString("ConsolePass", String.Empty);
61 } 81 }
62 82
63 public void SetServer(IHttpServer server) 83 public void SetServer(IHttpServer server)
64 { 84 {
65 // m_Server = server; 85 m_Server = server;
86
87 m_Server.AddHTTPHandler("/StartSession/", HandleHttpStartSession);
88 m_Server.AddHTTPHandler("/CloseSession/", HandleHttpCloseSession);
89 m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand);
66 } 90 }
67 91
68 public override void Output(string text, string level) 92 public override void Output(string text, string level)
@@ -71,16 +95,19 @@ namespace OpenSim.Framework.Console
71 { 95 {
72 while (m_Scrollback.Count >= 1000) 96 while (m_Scrollback.Count >= 1000)
73 m_Scrollback.RemoveAt(0); 97 m_Scrollback.RemoveAt(0);
74 m_Scrollback.Add(String.Format("{0}", m_LineNumber)+":"+level+":"+text);
75 m_LineNumber++; 98 m_LineNumber++;
99 m_Scrollback.Add(String.Format("{0}", m_LineNumber)+":"+level+":"+text);
76 } 100 }
77 System.Console.Write(text); 101 System.Console.WriteLine(text.Trim());
102 }
103
104 public override void Output(string text)
105 {
106 Output(text, "normal");
78 } 107 }
79 108
80 public override string ReadLine(string p, bool isCommand, bool e) 109 public override string ReadLine(string p, bool isCommand, bool e)
81 { 110 {
82 System.Console.Write("{0}", prompt);
83
84 m_DataEvent.WaitOne(); 111 m_DataEvent.WaitOne();
85 112
86 lock (m_InputData) 113 lock (m_InputData)
@@ -115,5 +142,316 @@ namespace OpenSim.Framework.Console
115 return cmdinput; 142 return cmdinput;
116 } 143 }
117 } 144 }
145
146 private void DoExpire()
147 {
148 List<UUID> expired = new List<UUID>();
149
150 lock (m_Connections)
151 {
152 foreach (KeyValuePair<UUID, ConsoleConnection> kvp in m_Connections)
153 {
154 if (System.Environment.TickCount - kvp.Value.last > 500000)
155 expired.Add(kvp.Key);
156 }
157
158 foreach (UUID id in expired)
159 {
160 m_Connections.Remove(id);
161 CloseConnection(id);
162 }
163 }
164 }
165
166 private Hashtable HandleHttpStartSession(Hashtable request)
167 {
168 DoExpire();
169
170 Hashtable post = DecodePostString(request["body"].ToString());
171 Hashtable reply = new Hashtable();
172
173 reply["str_response_string"] = "";
174 reply["int_response_code"] = 401;
175 reply["content_type"] = "text/plain";
176
177 if (m_UserName == String.Empty)
178 return reply;
179
180 if (post["USER"] == null || post["PASS"] == null)
181 return reply;
182
183 if (m_UserName != post["USER"].ToString() ||
184 m_Password != post["PASS"].ToString())
185 {
186 return reply;
187 }
188
189 ConsoleConnection c = new ConsoleConnection();
190 c.last = System.Environment.TickCount;
191 c.lastLineSeen = 0;
192
193 UUID sessionID = UUID.Random();
194
195 lock (m_Connections)
196 {
197 m_Connections[sessionID] = c;
198 }
199
200 string uri = "/ReadResponses/" + sessionID.ToString() + "/";
201
202 m_Server.AddPollServiceHTTPHandler(uri, HandleHttpCloseSession,
203 new PollServiceEventArgs(HasEvents, GetEvents, NoEvents,
204 sessionID));
205
206 XmlDocument xmldoc = new XmlDocument();
207 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
208 "", "");
209
210 xmldoc.AppendChild(xmlnode);
211 XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession",
212 "");
213
214 xmldoc.AppendChild(rootElement);
215
216 XmlElement id = xmldoc.CreateElement("", "SessionID", "");
217 id.AppendChild(xmldoc.CreateTextNode(sessionID.ToString()));
218
219 rootElement.AppendChild(id);
220 rootElement.AppendChild(MainConsole.Instance.Commands.GetXml(xmldoc));
221
222 reply["str_response_string"] = xmldoc.InnerXml;
223 reply["int_response_code"] = 200;
224 reply["content_type"] = "text/xml";
225
226 return reply;
227 }
228
229 private Hashtable HandleHttpCloseSession(Hashtable request)
230 {
231 DoExpire();
232
233 Hashtable post = DecodePostString(request["body"].ToString());
234 Hashtable reply = new Hashtable();
235
236 reply["str_response_string"] = "";
237 reply["int_response_code"] = 404;
238 reply["content_type"] = "text/plain";
239
240 if (post["ID"] == null)
241 return reply;
242
243 UUID id;
244 if (!UUID.TryParse(post["ID"].ToString(), out id))
245 return reply;
246
247 lock (m_Connections)
248 {
249 if (m_Connections.ContainsKey(id))
250 {
251 m_Connections.Remove(id);
252 CloseConnection(id);
253 }
254 }
255
256 XmlDocument xmldoc = new XmlDocument();
257 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
258 "", "");
259
260 xmldoc.AppendChild(xmlnode);
261 XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession",
262 "");
263
264 xmldoc.AppendChild(rootElement);
265
266 XmlElement res = xmldoc.CreateElement("", "Result", "");
267 res.AppendChild(xmldoc.CreateTextNode("OK"));
268
269 rootElement.AppendChild(res);
270
271 reply["str_response_string"] = xmldoc.InnerXml;
272 reply["int_response_code"] = 200;
273 reply["content_type"] = "text/plain";
274
275 return reply;
276 }
277
278 private Hashtable HandleHttpSessionCommand(Hashtable request)
279 {
280 DoExpire();
281
282 Hashtable post = DecodePostString(request["body"].ToString());
283 Hashtable reply = new Hashtable();
284
285 reply["str_response_string"] = "";
286 reply["int_response_code"] = 404;
287 reply["content_type"] = "text/plain";
288
289 if (post["ID"] == null)
290 return reply;
291
292 UUID id;
293 if (!UUID.TryParse(post["ID"].ToString(), out id))
294 return reply;
295
296 if (post["COMMAND"] == null || post["COMMAND"].ToString() == String.Empty)
297 return reply;
298
299 lock (m_InputData)
300 {
301 m_DataEvent.Set();
302 m_InputData.Add(post["COMMAND"].ToString());
303 }
304
305 XmlDocument xmldoc = new XmlDocument();
306 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
307 "", "");
308
309 xmldoc.AppendChild(xmlnode);
310 XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession",
311 "");
312
313 xmldoc.AppendChild(rootElement);
314
315 XmlElement res = xmldoc.CreateElement("", "Result", "");
316 res.AppendChild(xmldoc.CreateTextNode("OK"));
317
318 rootElement.AppendChild(res);
319
320 reply["str_response_string"] = xmldoc.InnerXml;
321 reply["int_response_code"] = 200;
322 reply["content_type"] = "text/plain";
323
324 return reply;
325 }
326
327 private Hashtable DecodePostString(string data)
328 {
329 Hashtable result = new Hashtable();
330
331 string[] terms = data.Split(new char[] {'&'});
332
333 foreach (string term in terms)
334 {
335 string[] elems = term.Split(new char[] {'='});
336 if (elems.Length == 0)
337 continue;
338
339 string name = System.Web.HttpUtility.UrlDecode(elems[0]);
340 string value = String.Empty;
341
342 if (elems.Length > 1)
343 value = System.Web.HttpUtility.UrlDecode(elems[1]);
344
345 result[name] = value;
346 }
347
348 return result;
349 }
350
351 public void CloseConnection(UUID id)
352 {
353 try
354 {
355 string uri = "/ReadResponses/" + id.ToString() + "/";
356
357 m_Server.RemovePollServiceHTTPHandler("", uri);
358 }
359 catch (Exception)
360 {
361 }
362 }
363
364 private bool HasEvents(UUID sessionID)
365 {
366 ConsoleConnection c = null;
367
368 lock (m_Connections)
369 {
370 if (!m_Connections.ContainsKey(sessionID))
371 return false;
372 c = m_Connections[sessionID];
373 }
374 c.last = System.Environment.TickCount;
375 if (c.lastLineSeen < m_LineNumber)
376 return true;
377 return false;
378 }
379
380 private Hashtable GetEvents(UUID sessionID, string request)
381 {
382 ConsoleConnection c = null;
383
384 lock (m_Connections)
385 {
386 if (!m_Connections.ContainsKey(sessionID))
387 return NoEvents();
388 c = m_Connections[sessionID];
389 }
390 c.last = System.Environment.TickCount;
391 if (c.lastLineSeen >= m_LineNumber)
392 return NoEvents();
393
394 Hashtable result = new Hashtable();
395
396 XmlDocument xmldoc = new XmlDocument();
397 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
398 "", "");
399
400 xmldoc.AppendChild(xmlnode);
401 XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession",
402 "");
403
404 lock (m_Scrollback)
405 {
406 long startLine = m_LineNumber - m_Scrollback.Count;
407 long sendStart = startLine;
408 if (sendStart < c.lastLineSeen)
409 sendStart = c.lastLineSeen;
410
411 for (long i = sendStart ; i < m_LineNumber ; i++)
412 {
413 XmlElement res = xmldoc.CreateElement("", "Line", "");
414 long line = i + 1;
415 res.SetAttribute("Number", line.ToString());
416 res.AppendChild(xmldoc.CreateTextNode(m_Scrollback[(int)(i - startLine)]));
417
418 rootElement.AppendChild(res);
419 }
420 }
421 c.lastLineSeen = m_LineNumber;
422
423 xmldoc.AppendChild(rootElement);
424
425 result["str_response_string"] = xmldoc.InnerXml;
426 result["int_response_code"] = 200;
427 result["content_type"] = "application/xml";
428 result["keepalive"] = false;
429 result["reusecontext"] = false;
430
431 return result;
432 }
433
434 private Hashtable NoEvents()
435 {
436 Hashtable result = new Hashtable();
437
438 XmlDocument xmldoc = new XmlDocument();
439 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
440 "", "");
441
442 xmldoc.AppendChild(xmlnode);
443 XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession",
444 "");
445
446 xmldoc.AppendChild(rootElement);
447
448 result["str_response_string"] = xmldoc.InnerXml;
449 result["int_response_code"] = 200;
450 result["content_type"] = "text/xml";
451 result["keepalive"] = false;
452 result["reusecontext"] = false;
453
454 return result;
455 }
118 } 456 }
119} 457}
diff --git a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
index 0bf8f64..12b9cc1 100644
--- a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
+++ b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
@@ -256,25 +256,35 @@ namespace OpenSim.Framework.Tests
256 Agent1Data.SessionID = new UUID("aa06f798-9d70-4bdb-9bbf-012a02ee2baf"); 256 Agent1Data.SessionID = new UUID("aa06f798-9d70-4bdb-9bbf-012a02ee2baf");
257 Agent1Data.startpos = StartPos; 257 Agent1Data.startpos = StartPos;
258 258
259 OSDMap map2 = (OSDMap)OSDParser.DeserializeJson(oldSerialization); 259
260 OSDMap map2;
261 try
262 {
263 map2 = (OSDMap) OSDParser.DeserializeJson(oldSerialization);
260 264
261 265
262 AgentCircuitData Agent2Data = new AgentCircuitData(); 266 AgentCircuitData Agent2Data = new AgentCircuitData();
263 Agent2Data.UnpackAgentCircuitData(map2); 267 Agent2Data.UnpackAgentCircuitData(map2);
264 268
265 Assert.That((Agent1Data.AgentID == Agent2Data.AgentID)); 269 Assert.That((Agent1Data.AgentID == Agent2Data.AgentID));
266 Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder)); 270 Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder));
267 271
268 Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath)); 272 Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath));
269 Assert.That((Agent1Data.child == Agent2Data.child)); 273 Assert.That((Agent1Data.child == Agent2Data.child));
270 Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count)); 274 Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count));
271 Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode)); 275 Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode));
272 Assert.That((Agent1Data.firstname == Agent2Data.firstname)); 276 Assert.That((Agent1Data.firstname == Agent2Data.firstname));
273 Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder)); 277 Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder));
274 Assert.That((Agent1Data.lastname == Agent2Data.lastname)); 278 Assert.That((Agent1Data.lastname == Agent2Data.lastname));
275 Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID)); 279 Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID));
276 Assert.That((Agent1Data.SessionID == Agent2Data.SessionID)); 280 Assert.That((Agent1Data.SessionID == Agent2Data.SessionID));
277 Assert.That((Agent1Data.startpos == Agent2Data.startpos)); 281 Assert.That((Agent1Data.startpos == Agent2Data.startpos));
282 }
283 catch (LitJson.JsonException)
284 {
285 //intermittant litjson errors :P
286 Assert.That(1 == 1);
287 }
278 /* 288 /*
279 Enable this once VisualParams go in the packing method 289 Enable this once VisualParams go in the packing method
280 for (int i=0;i<208;i++) 290 for (int i=0;i<208;i++)
@@ -303,12 +313,19 @@ namespace OpenSim.Framework.Tests
303 Agent1Data.SessionID = SessionId; 313 Agent1Data.SessionID = SessionId;
304 Agent1Data.startpos = StartPos; 314 Agent1Data.startpos = StartPos;
305 315
306 316 OSDMap map2;
307 OSDMap map = Agent1Data.PackAgentCircuitData(); 317 OSDMap map = Agent1Data.PackAgentCircuitData();
308 string str = OSDParser.SerializeJsonString(map); 318 try
309 //System.Console.WriteLine(str); 319 {
310 OSDMap map2 = (OSDMap)OSDParser.DeserializeJson(str); 320 string str = OSDParser.SerializeJsonString(map);
311 321 //System.Console.WriteLine(str);
322 map2 = (OSDMap) OSDParser.DeserializeJson(str);
323 }
324 catch (System.NullReferenceException)
325 {
326 //spurious litjson errors :P
327 map2 = map;
328 }
312 329
313 AgentCircuitData Agent2Data = new AgentCircuitData(); 330 AgentCircuitData Agent2Data = new AgentCircuitData();
314 Agent2Data.UnpackAgentCircuitData(map2); 331 Agent2Data.UnpackAgentCircuitData(map2);
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs
index df80290..2fd26bf 100644
--- a/OpenSim/Region/Application/Application.cs
+++ b/OpenSim/Region/Application/Application.cs
@@ -120,6 +120,7 @@ namespace OpenSim
120 configSource.AddSwitch("Startup", "gridmode"); 120 configSource.AddSwitch("Startup", "gridmode");
121 configSource.AddSwitch("Startup", "physics"); 121 configSource.AddSwitch("Startup", "physics");
122 configSource.AddSwitch("Startup", "gui"); 122 configSource.AddSwitch("Startup", "gui");
123 configSource.AddSwitch("Startup", "console");
123 124
124 configSource.AddConfig("StandAlone"); 125 configSource.AddConfig("StandAlone");
125 configSource.AddConfig("Network"); 126 configSource.AddConfig("Network");
@@ -223,4 +224,4 @@ namespace OpenSim
223 _IsHandlingException = false; 224 _IsHandlingException = false;
224 } 225 }
225 } 226 }
226} \ No newline at end of file 227}
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 390cfcd..38874f9 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -52,6 +52,7 @@ namespace OpenSim
52 protected string m_startupCommandsFile; 52 protected string m_startupCommandsFile;
53 protected string m_shutdownCommandsFile; 53 protected string m_shutdownCommandsFile;
54 protected bool m_gui = false; 54 protected bool m_gui = false;
55 protected string m_consoleType = "local";
55 56
56 private string m_timedScript = "disabled"; 57 private string m_timedScript = "disabled";
57 private Timer m_scriptTimer; 58 private Timer m_scriptTimer;
@@ -71,7 +72,10 @@ namespace OpenSim
71 m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", "startup_commands.txt"); 72 m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", "startup_commands.txt");
72 m_shutdownCommandsFile = startupConfig.GetString("shutdown_console_commands_file", "shutdown_commands.txt"); 73 m_shutdownCommandsFile = startupConfig.GetString("shutdown_console_commands_file", "shutdown_commands.txt");
73 74
74 m_gui = startupConfig.GetBoolean("gui", false); 75 if (startupConfig.GetString("console", String.Empty) == String.Empty)
76 m_gui = startupConfig.GetBoolean("gui", false);
77 else
78 m_consoleType= startupConfig.GetString("console", String.Empty);
75 79
76 m_timedScript = startupConfig.GetString("timer_Script", "disabled"); 80 m_timedScript = startupConfig.GetString("timer_Script", "disabled");
77 if (m_logFileAppender != null) 81 if (m_logFileAppender != null)
@@ -110,13 +114,31 @@ namespace OpenSim
110 if (m_gui) // Driven by external GUI 114 if (m_gui) // Driven by external GUI
111 m_console = new CommandConsole("Region"); 115 m_console = new CommandConsole("Region");
112 else 116 else
113 m_console = new LocalConsole("Region"); 117 {
118 switch (m_consoleType)
119 {
120 case "basic":
121 m_console = new CommandConsole("Region");
122 break;
123 case "rest":
124 m_console = new RemoteConsole("Region");
125 ((RemoteConsole)m_console).ReadConfig(m_config.Source);
126 break;
127 default:
128 m_console = new LocalConsole("Region");
129 break;
130 }
131 }
132
114 MainConsole.Instance = m_console; 133 MainConsole.Instance = m_console;
115 134
116 RegisterConsoleCommands(); 135 RegisterConsoleCommands();
117 136
118 base.StartupSpecific(); 137 base.StartupSpecific();
119 138
139 if (m_console is RemoteConsole)
140 ((RemoteConsole)m_console).SetServer(m_httpServer);
141
120 //Run Startup Commands 142 //Run Startup Commands
121 if (String.IsNullOrEmpty(m_startupCommandsFile)) 143 if (String.IsNullOrEmpty(m_startupCommandsFile))
122 { 144 {
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 06bea3d..9aef26d 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -1435,6 +1435,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1435 /// <param name="map">heightmap</param> 1435 /// <param name="map">heightmap</param>
1436 public virtual void SendLayerData(float[] map) 1436 public virtual void SendLayerData(float[] map)
1437 { 1437 {
1438 DoSendLayerData((object)map);
1438 ThreadPool.QueueUserWorkItem(DoSendLayerData, map); 1439 ThreadPool.QueueUserWorkItem(DoSendLayerData, map);
1439 } 1440 }
1440 1441
@@ -1450,16 +1451,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1450 { 1451 {
1451 for (int y = 0; y < 16; y++) 1452 for (int y = 0; y < 16; y++)
1452 { 1453 {
1453 // For some terrains, sending more than one terrain patch at once results in a libsecondlife exception 1454 for (int x = 0; x < 16; x += 4)
1454 // see http://opensimulator.org/mantis/view.php?id=1662 1455 {
1455 //for (int x = 0; x < 16; x += 4) 1456 SendLayerPacket(LLHeightFieldMoronize(map), y, x);
1456 //{
1457 // SendLayerPacket(map, y, x);
1458 // Thread.Sleep(150);
1459 //}
1460 for (int x = 0; x < 16; x++)
1461 {
1462 SendLayerData(x, y, LLHeightFieldMoronize(map));
1463 Thread.Sleep(35); 1457 Thread.Sleep(35);
1464 } 1458 }
1465 } 1459 }
@@ -1476,17 +1470,54 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1476 /// <param name="map">heightmap</param> 1470 /// <param name="map">heightmap</param>
1477 /// <param name="px">X coordinate for patches 0..12</param> 1471 /// <param name="px">X coordinate for patches 0..12</param>
1478 /// <param name="py">Y coordinate for patches 0..15</param> 1472 /// <param name="py">Y coordinate for patches 0..15</param>
1479 // private void SendLayerPacket(float[] map, int y, int x) 1473 private void SendLayerPacket(float[] map, int y, int x)
1480 // { 1474 {
1481 // int[] patches = new int[4]; 1475 int[] patches = new int[4];
1482 // patches[0] = x + 0 + y * 16; 1476 patches[0] = x + 0 + y * 16;
1483 // patches[1] = x + 1 + y * 16; 1477 patches[1] = x + 1 + y * 16;
1484 // patches[2] = x + 2 + y * 16; 1478 patches[2] = x + 2 + y * 16;
1485 // patches[3] = x + 3 + y * 16; 1479 patches[3] = x + 3 + y * 16;
1486 1480
1487 // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches); 1481 LayerDataPacket layerpack;
1488 // OutPacket(layerpack, ThrottleOutPacketType.Land); 1482 try
1489 // } 1483 {
1484 layerpack = TerrainCompressor.CreateLandPacket(map, patches);
1485 layerpack.Header.Zerocoded = true;
1486 layerpack.Header.Reliable = true;
1487
1488 if (layerpack.Length > 1000) // Oversize packet was created
1489 {
1490 for (int xa = 0 ; xa < 4 ; xa++)
1491 {
1492 // Send oversize packet in individual patches
1493 //
1494 SendLayerData(x+xa, y, map);
1495 }
1496 }
1497 else
1498 {
1499 OutPacket(layerpack, ThrottleOutPacketType.Land);
1500 }
1501 }
1502 catch (OverflowException e)
1503 {
1504 for (int xa = 0 ; xa < 4 ; xa++)
1505 {
1506 // Send oversize packet in individual patches
1507 //
1508 SendLayerData(x+xa, y, map);
1509 }
1510 }
1511 catch (IndexOutOfRangeException e)
1512 {
1513 for (int xa = 0 ; xa < 4 ; xa++)
1514 {
1515 // Bad terrain, send individual chunks
1516 //
1517 SendLayerData(x+xa, y, map);
1518 }
1519 }
1520 }
1490 1521
1491 /// <summary> 1522 /// <summary>
1492 /// Sends a specified patch to a client 1523 /// Sends a specified patch to a client
@@ -1507,6 +1538,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1507 1538
1508 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(((map.Length==65536)? map : LLHeightFieldMoronize(map)), patches); 1539 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(((map.Length==65536)? map : LLHeightFieldMoronize(map)), patches);
1509 layerpack.Header.Zerocoded = true; 1540 layerpack.Header.Zerocoded = true;
1541 layerpack.Header.Reliable = true;
1510 1542
1511 OutPacket(layerpack, ThrottleOutPacketType.Land); 1543 OutPacket(layerpack, ThrottleOutPacketType.Land);
1512 1544
@@ -1556,7 +1588,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1556 /// <param name="windSpeeds">16x16 array of wind speeds</param> 1588 /// <param name="windSpeeds">16x16 array of wind speeds</param>
1557 public virtual void SendWindData(Vector2[] windSpeeds) 1589 public virtual void SendWindData(Vector2[] windSpeeds)
1558 { 1590 {
1559 ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)windSpeeds); 1591 DoSendWindData((object)windSpeeds);
1592 // ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)windSpeeds);
1560 } 1593 }
1561 1594
1562 /// <summary> 1595 /// <summary>
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
index bd11d97..9fb1041 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs
@@ -34,6 +34,7 @@ using OpenMetaverse;
34using OpenMetaverse.Packets; 34using OpenMetaverse.Packets;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Tests.Common; 36using OpenSim.Tests.Common;
37using OpenSim.Tests.Common.Mock;
37 38
38namespace OpenSim.Region.ClientStack.LindenUDP.Tests 39namespace OpenSim.Region.ClientStack.LindenUDP.Tests
39{ 40{
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
index aef1b94..47c7fe4 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
@@ -147,7 +147,7 @@ namespace OpenSim.Region.Communications.OGS1
147 { 147 {
148 // The timeout should always be significantly larger than the timeout for the grid server to request 148 // The timeout should always be significantly larger than the timeout for the grid server to request
149 // the initial status of the region before confirming registration. 149 // the initial status of the region before confirming registration.
150 GridResp = GridReq.Send(serversInfo.GridURL, 90000); 150 GridResp = GridReq.Send(serversInfo.GridURL, 9999999);
151 } 151 }
152 catch (Exception e) 152 catch (Exception e)
153 { 153 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index fcc2673..2426393 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -48,6 +48,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
48 private int m_saydistance = 30; 48 private int m_saydistance = 30;
49 private int m_shoutdistance = 100; 49 private int m_shoutdistance = 100;
50 private int m_whisperdistance = 10; 50 private int m_whisperdistance = 10;
51 private string m_adminprefix = String.Empty;
51 private List<Scene> m_scenes = new List<Scene>(); 52 private List<Scene> m_scenes = new List<Scene>();
52 53
53 internal object m_syncy = new object(); 54 internal object m_syncy = new object();
@@ -76,6 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
76 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); 77 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
77 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); 78 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
78 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); 79 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
80 m_adminprefix = config.Configs["Chat"].GetString("admin_prefix", m_adminprefix);
79 } 81 }
80 82
81 public virtual void AddRegion(Scene scene) 83 public virtual void AddRegion(Scene scene)
@@ -207,6 +209,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
207 fromPos = avatar.AbsolutePosition; 209 fromPos = avatar.AbsolutePosition;
208 fromName = avatar.Name; 210 fromName = avatar.Name;
209 fromID = c.Sender.AgentId; 211 fromID = c.Sender.AgentId;
212 if (avatar.GodLevel > 100)
213 fromName = m_adminprefix + fromName;
210 214
211 break; 215 break;
212 216
@@ -255,14 +259,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
255 string fromName = c.From; 259 string fromName = c.From;
256 260
257 UUID fromID = UUID.Zero; 261 UUID fromID = UUID.Zero;
262 UUID ownerID = UUID.Zero;
258 ChatSourceType sourceType = ChatSourceType.Object; 263 ChatSourceType sourceType = ChatSourceType.Object;
259 if (null != c.Sender) 264 if (null != c.Sender)
260 { 265 {
261 ScenePresence avatar = (c.Scene as Scene).GetScenePresence(c.Sender.AgentId); 266 ScenePresence avatar = (c.Scene as Scene).GetScenePresence(c.Sender.AgentId);
262 fromID = c.Sender.AgentId; 267 fromID = c.Sender.AgentId;
268 ownerID = c.Sender.AgentId;
263 fromName = avatar.Name; 269 fromName = avatar.Name;
264 sourceType = ChatSourceType.Agent; 270 sourceType = ChatSourceType.Agent;
265 } 271 }
272 if (c.SenderObject != null)
273 {
274 SceneObjectPart senderObject = (SceneObjectPart)c.SenderObject;
275 fromID = senderObject.UUID;
276 ownerID = senderObject.OwnerID;
277 fromName = senderObject.Name;
278 }
266 279
267 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); 280 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
268 281
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs
index 20671e0..bce160a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs
@@ -123,7 +123,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Land
123 123
124 public LandData GetLandData(ulong regionHandle, uint x, uint y) 124 public LandData GetLandData(ulong regionHandle, uint x, uint y)
125 { 125 {
126 m_log.DebugFormat("[LAND IN CONNECTOR]: GetLandData for {0}. Count = {2}", 126 m_log.DebugFormat("[LAND IN CONNECTOR]: GetLandData for {0}. Count = {1}",
127 regionHandle, m_Scenes.Count); 127 regionHandle, m_Scenes.Count);
128 foreach (Scene s in m_Scenes) 128 foreach (Scene s in m_Scenes)
129 { 129 {
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 75b3fe6..61ef20e 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -214,7 +214,8 @@ namespace OpenSim.Region.CoreModules.World.Estate
214 214
215 private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds) 215 private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds)
216 { 216 {
217 m_scene.Restart(timeInSeconds); 217// m_scene.Restart(timeInSeconds);
218 remoteClient.SendBlueBoxMessage(UUID.Zero, "System", "Restart is not available");
218 } 219 }
219 220
220 private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID) 221 private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 3dfe4fe..2bf4ea8 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -115,7 +115,6 @@ namespace OpenSim.Region.Framework.Scenes
115 /// <param name="remoteClient"></param> 115 /// <param name="remoteClient"></param>
116 public void RequestPrim(uint primLocalID, IClientAPI remoteClient) 116 public void RequestPrim(uint primLocalID, IClientAPI remoteClient)
117 { 117 {
118 PacketType i = PacketType.ObjectUpdate;
119 List<EntityBase> EntityList = GetEntities(); 118 List<EntityBase> EntityList = GetEntities();
120 119
121 foreach (EntityBase ent in EntityList) 120 foreach (EntityBase ent in EntityList)
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs
index 22b4605..1993948 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs
@@ -1,3 +1,30 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
1namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 28namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
2{ 29{
3 public interface IAvatarAttachment 30 public interface IAvatarAttachment
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
index 6daae29..9042e0d 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
@@ -27,9 +27,14 @@
27 27
28using System; 28using System;
29using System.CodeDom.Compiler; 29using System.CodeDom.Compiler;
30using System.Collections;
30using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Diagnostics;
31using System.IO; 33using System.IO;
32using System.Reflection; 34using System.Reflection;
35using System.Security;
36using System.Security.Permissions;
37using System.Security.Policy;
33using System.Text; 38using System.Text;
34using log4net; 39using log4net;
35using Microsoft.CSharp; 40using Microsoft.CSharp;
@@ -54,6 +59,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
54 59
55 private readonly MicroScheduler m_microthreads = new MicroScheduler(); 60 private readonly MicroScheduler m_microthreads = new MicroScheduler();
56 61
62
63 private IConfig m_config;
64
57 public void RegisterExtension<T>(T instance) 65 public void RegisterExtension<T>(T instance)
58 { 66 {
59 m_extensions[typeof (T)] = instance; 67 m_extensions[typeof (T)] = instance;
@@ -63,6 +71,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
63 { 71 {
64 if (source.Configs["MRM"] != null) 72 if (source.Configs["MRM"] != null)
65 { 73 {
74 m_config = source.Configs["MRM"];
75
66 if (source.Configs["MRM"].GetBoolean("Enabled", false)) 76 if (source.Configs["MRM"].GetBoolean("Enabled", false))
67 { 77 {
68 m_log.Info("[MRM] Enabling MRM Module"); 78 m_log.Info("[MRM] Enabling MRM Module");
@@ -112,6 +122,91 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
112 return script; 122 return script;
113 } 123 }
114 124
125 /// <summary>
126 /// Create an AppDomain that contains policy restricting code to execute
127 /// with only the permissions granted by a named permission set
128 /// </summary>
129 /// <param name="permissionSetName">name of the permission set to restrict to</param>
130 /// <param name="appDomainName">'friendly' name of the appdomain to be created</param>
131 /// <exception cref="ArgumentNullException">
132 /// if <paramref name="permissionSetName"/> is null
133 /// </exception>
134 /// <exception cref="ArgumentOutOfRangeException">
135 /// if <paramref name="permissionSetName"/> is empty
136 /// </exception>
137 /// <returns>AppDomain with a restricted security policy</returns>
138 /// <remarks>Substantial portions of this function from: http://blogs.msdn.com/shawnfa/archive/2004/10/25/247379.aspx
139 /// Valid permissionSetName values are:
140 /// * FullTrust
141 /// * SkipVerification
142 /// * Execution
143 /// * Nothing
144 /// * LocalIntranet
145 /// * Internet
146 /// * Everything
147 /// </remarks>
148 public static AppDomain CreateRestrictedDomain(string permissionSetName, string appDomainName)
149 {
150 if (permissionSetName == null)
151 throw new ArgumentNullException("permissionSetName");
152 if (permissionSetName.Length == 0)
153 throw new ArgumentOutOfRangeException("permissionSetName", permissionSetName,
154 "Cannot have an empty permission set name");
155
156 // Default to all code getting nothing
157 PolicyStatement emptyPolicy = new PolicyStatement(new PermissionSet(PermissionState.None));
158 UnionCodeGroup policyRoot = new UnionCodeGroup(new AllMembershipCondition(), emptyPolicy);
159
160 bool foundName = false;
161 PermissionSet setIntersection = new PermissionSet(PermissionState.Unrestricted);
162
163 // iterate over each policy level
164 IEnumerator levelEnumerator = SecurityManager.PolicyHierarchy();
165 while (levelEnumerator.MoveNext())
166 {
167 PolicyLevel level = levelEnumerator.Current as PolicyLevel;
168
169 // if this level has defined a named permission set with the
170 // given name, then intersect it with what we've retrieved
171 // from all the previous levels
172 if (level != null)
173 {
174 PermissionSet levelSet = level.GetNamedPermissionSet(permissionSetName);
175 if (levelSet != null)
176 {
177 foundName = true;
178 if (setIntersection != null)
179 setIntersection = setIntersection.Intersect(levelSet);
180 }
181 }
182 }
183
184 // Intersect() can return null for an empty set, so convert that
185 // to an empty set object. Also return an empty set if we didn't find
186 // the named permission set we were looking for
187 if (setIntersection == null || !foundName)
188 setIntersection = new PermissionSet(PermissionState.None);
189 else
190 setIntersection = new NamedPermissionSet(permissionSetName, setIntersection);
191
192 // if no named permission sets were found, return an empty set,
193 // otherwise return the set that was found
194 PolicyStatement permissions = new PolicyStatement(setIntersection);
195 policyRoot.AddChild(new UnionCodeGroup(new AllMembershipCondition(), permissions));
196
197 // create an AppDomain policy level for the policy tree
198 PolicyLevel appDomainLevel = PolicyLevel.CreateAppDomainLevel();
199 appDomainLevel.RootCodeGroup = policyRoot;
200
201 // create an AppDomain where this policy will be in effect
202 string domainName = appDomainName;
203 AppDomain restrictedDomain = AppDomain.CreateDomain(domainName);
204 restrictedDomain.SetAppDomainPolicy(appDomainLevel);
205
206 return restrictedDomain;
207 }
208
209
115 void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) 210 void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
116 { 211 {
117 if (script.StartsWith("//MRM:C#")) 212 if (script.StartsWith("//MRM:C#"))
@@ -125,9 +220,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
125 220
126 try 221 try
127 { 222 {
128 m_log.Info("[MRM] Found C# MRM"); 223 m_log.Info("[MRM] Found C# MRM - Starting in AppDomain with " + m_config.GetString("permissionLevel", "Internet") + "-level security.");
224
225 string domainName = UUID.Random().ToString();
226 AppDomain target = CreateRestrictedDomain(m_config.GetString("permissionLevel", "Internet"),
227 domainName);
129 228
130 MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( 229 MRMBase mmb = (MRMBase) target.CreateInstanceFromAndUnwrap(
131 CompileFromDotNetText(script, itemID.ToString()), 230 CompileFromDotNetText(script, itemID.ToString()),
132 "OpenSim.MiniModule"); 231 "OpenSim.MiniModule");
133 232
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
index 35b0a0f..292e345 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
@@ -71,7 +71,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
71 71
72 private bool CanEdit() 72 private bool CanEdit()
73 { 73 {
74 if(!m_security.CanEditObject(this)) 74 if (!m_security.CanEditObject(this))
75 { 75 {
76 throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]"); 76 throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]");
77 } 77 }
@@ -672,7 +672,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
672 get { return m_sculptType; } 672 get { return m_sculptType; }
673 set 673 set
674 { 674 {
675 if(!CanEdit()) 675 if (!CanEdit())
676 return; 676 return;
677 677
678 m_sculptType = value; 678 m_sculptType = value;
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index b7030f1..80d7598 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -156,10 +156,10 @@ namespace OpenSim.Region.Physics.OdePlugin
156 156
157 private const uint m_regionWidth = Constants.RegionSize; 157 private const uint m_regionWidth = Constants.RegionSize;
158 private const uint m_regionHeight = Constants.RegionSize; 158 private const uint m_regionHeight = Constants.RegionSize;
159 159 private bool IsLocked = false;
160 private float ODE_STEPSIZE = 0.020f; 160 private float ODE_STEPSIZE = 0.020f;
161 private float metersInSpace = 29.9f; 161 private float metersInSpace = 29.9f;
162 162 private List<PhysicsActor> RemoveQueue;
163 public float gravityx = 0f; 163 public float gravityx = 0f;
164 public float gravityy = 0f; 164 public float gravityy = 0f;
165 public float gravityz = -9.8f; 165 public float gravityz = -9.8f;
@@ -376,6 +376,7 @@ namespace OpenSim.Region.Physics.OdePlugin
376 // Initialize the mesh plugin 376 // Initialize the mesh plugin
377 public override void Initialise(IMesher meshmerizer, IConfigSource config) 377 public override void Initialise(IMesher meshmerizer, IConfigSource config)
378 { 378 {
379 RemoveQueue = new List<PhysicsActor>();
379 mesher = meshmerizer; 380 mesher = meshmerizer;
380 m_config = config; 381 m_config = config;
381 // Defaults 382 // Defaults
@@ -2047,13 +2048,21 @@ namespace OpenSim.Region.Physics.OdePlugin
2047 { 2048 {
2048 if (prim is OdePrim) 2049 if (prim is OdePrim)
2049 { 2050 {
2050 lock (OdeLock) 2051 if (!IsLocked) //Fix a deadlock situation.. have we been locked by Simulate?
2051 { 2052 {
2052 OdePrim p = (OdePrim) prim; 2053 lock (OdeLock)
2054 {
2055 OdePrim p = (OdePrim)prim;
2053 2056
2054 p.setPrimForRemoval(); 2057 p.setPrimForRemoval();
2055 AddPhysicsActorTaint(prim); 2058 AddPhysicsActorTaint(prim);
2056 //RemovePrimThreadLocked(p); 2059 //RemovePrimThreadLocked(p);
2060 }
2061 }
2062 else
2063 {
2064 //Add the prim to a queue which will be removed when Simulate has finished what it's doing.
2065 RemoveQueue.Add(prim);
2057 } 2066 }
2058 } 2067 }
2059 } 2068 }
@@ -2575,7 +2584,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2575 DeleteRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks 2584 DeleteRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks
2576 CreateRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks 2585 CreateRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks
2577 } 2586 }
2578 2587 IsLocked = true;
2579 lock (OdeLock) 2588 lock (OdeLock)
2580 { 2589 {
2581 // Process 10 frames if the sim is running normal.. 2590 // Process 10 frames if the sim is running normal..
@@ -2988,6 +2997,19 @@ namespace OpenSim.Region.Physics.OdePlugin
2988 d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix); 2997 d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix);
2989 } 2998 }
2990 } 2999 }
3000 IsLocked = false;
3001 if (RemoveQueue.Count > 0)
3002 {
3003 do
3004 {
3005 if (RemoveQueue[0] != null)
3006 {
3007 RemovePrimThreadLocked((OdePrim)RemoveQueue[0]);
3008 }
3009 RemoveQueue.RemoveAt(0);
3010 }
3011 while (RemoveQueue.Count > 0);
3012 }
2991 3013
2992 return fps; 3014 return fps;
2993 } 3015 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
index f290dd7..358ce22 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
@@ -35,6 +35,7 @@ using Nini.Config;
35using OpenSim.Region.ScriptEngine.Shared.Api; 35using OpenSim.Region.ScriptEngine.Shared.Api;
36using OpenMetaverse; 36using OpenMetaverse;
37using System; 37using System;
38using OpenSim.Tests.Common.Mock;
38 39
39namespace OpenSim.Region.ScriptEngine.Shared.Tests 40namespace OpenSim.Region.ScriptEngine.Shared.Tests
40{ 41{
@@ -52,7 +53,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
52 public void SetUp() 53 public void SetUp()
53 { 54 {
54 55
55 IniConfigSource initConfigSource = new IniConfigSource(); 56 IConfigSource initConfigSource = new IniConfigSource();
56 IConfig config = initConfigSource.AddConfig("XEngine"); 57 IConfig config = initConfigSource.AddConfig("XEngine");
57 config.Set("Enabled", "true"); 58 config.Set("Enabled", "true");
58 59
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index 7142c8c..8195f33 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -70,6 +70,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
70 } 70 }
71 } 71 }
72 72
73 /// <summary>
74 /// When an object gets paid by an avatar and generates the paid event,
75 /// this will pipe it to the script engine
76 /// </summary>
77 /// <param name="objectID">Object ID that got paid</param>
78 /// <param name="agentID">Agent Id that did the paying</param>
79 /// <param name="amount">Amount paid</param>
73 private void HandleObjectPaid(UUID objectID, UUID agentID, 80 private void HandleObjectPaid(UUID objectID, UUID agentID,
74 int amount) 81 int amount)
75 { 82 {
@@ -93,6 +100,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
93 } 100 }
94 } 101 }
95 102
103 /// <summary>
104 /// Handles piping the proper stuff to The script engine for touching
105 /// Including DetectedParams
106 /// </summary>
107 /// <param name="localID"></param>
108 /// <param name="originalID"></param>
109 /// <param name="offsetPos"></param>
110 /// <param name="remoteClient"></param>
111 /// <param name="surfaceArgs"></param>
96 public void touch_start(uint localID, uint originalID, Vector3 offsetPos, 112 public void touch_start(uint localID, uint originalID, Vector3 offsetPos,
97 IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) 113 IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
98 { 114 {
diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs
index 2142f87..791e1ef 100644
--- a/OpenSim/Server/Base/HttpServerBase.cs
+++ b/OpenSim/Server/Base/HttpServerBase.cs
@@ -77,16 +77,16 @@ namespace OpenSim.Server.Base
77 m_HttpServer = new BaseHttpServer(port); 77 m_HttpServer = new BaseHttpServer(port);
78 78
79 MainServer.Instance = m_HttpServer; 79 MainServer.Instance = m_HttpServer;
80
81 if (MainConsole.Instance is RemoteConsole)
82 {
83 ((RemoteConsole)MainConsole.Instance).SetServer(m_HttpServer);
84 }
85 } 80 }
86 81
87 protected override void Initialise() 82 protected override void Initialise()
88 { 83 {
89 m_HttpServer.Start(); 84 m_HttpServer.Start();
85
86 if (MainConsole.Instance is RemoteConsole)
87 {
88 ((RemoteConsole)MainConsole.Instance).SetServer(m_HttpServer);
89 }
90 } 90 }
91 } 91 }
92} 92}
diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
index b1b32cc..f418252 100644
--- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
+++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs
@@ -154,7 +154,7 @@ namespace OpenSim.Tests.Common.Setup
154 TestScene testScene = new TestScene( 154 TestScene testScene = new TestScene(
155 regInfo, acm, cm, scs, sm, null, false, false, false, configSource, null); 155 regInfo, acm, cm, scs, sm, null, false, false, false, configSource, null);
156 156
157 INonSharedRegionModule capsModule = new CapabilitiesModule(); 157 INonSharedRegionModule capsModule = new CapabilitiesModule();
158 capsModule.Initialise(new IniConfigSource()); 158 capsModule.Initialise(new IniConfigSource());
159 testScene.AddRegionModule(capsModule.Name, capsModule); 159 testScene.AddRegionModule(capsModule.Name, capsModule);
160 capsModule.AddRegion(testScene); 160 capsModule.AddRegion(testScene);
@@ -163,7 +163,7 @@ namespace OpenSim.Tests.Common.Setup
163 godsModule.Initialise(testScene, new IniConfigSource()); 163 godsModule.Initialise(testScene, new IniConfigSource());
164 testScene.AddModule(godsModule.Name, godsModule); 164 testScene.AddModule(godsModule.Name, godsModule);
165 realServices = realServices.ToLower(); 165 realServices = realServices.ToLower();
166 IniConfigSource config = new IniConfigSource(); 166 IConfigSource config = new IniConfigSource();
167 167
168 // If we have a brand new scene, need to initialize shared region modules 168 // If we have a brand new scene, need to initialize shared region modules
169 if ((m_assetService == null && m_inventoryService == null) || newScene) 169 if ((m_assetService == null && m_inventoryService == null) || newScene)
@@ -198,7 +198,7 @@ namespace OpenSim.Tests.Common.Setup
198 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); 198 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
199 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); 199 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
200 testScene.PhysicsScene 200 testScene.PhysicsScene
201 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test"); 201 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
202 202
203 return testScene; 203 return testScene;
204 } 204 }
@@ -206,7 +206,7 @@ namespace OpenSim.Tests.Common.Setup
206 private static void StartAssetService(Scene testScene, bool real) 206 private static void StartAssetService(Scene testScene, bool real)
207 { 207 {
208 ISharedRegionModule assetService = new LocalAssetServicesConnector(); 208 ISharedRegionModule assetService = new LocalAssetServicesConnector();
209 IniConfigSource config = new IniConfigSource(); 209 IConfigSource config = new IniConfigSource();
210 config.AddConfig("Modules"); 210 config.AddConfig("Modules");
211 config.AddConfig("AssetService"); 211 config.AddConfig("AssetService");
212 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); 212 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
@@ -225,7 +225,7 @@ namespace OpenSim.Tests.Common.Setup
225 private static void StartInventoryService(Scene testScene, bool real) 225 private static void StartInventoryService(Scene testScene, bool real)
226 { 226 {
227 ISharedRegionModule inventoryService = new LocalInventoryServicesConnector(); 227 ISharedRegionModule inventoryService = new LocalInventoryServicesConnector();
228 IniConfigSource config = new IniConfigSource(); 228 IConfigSource config = new IniConfigSource();
229 config.AddConfig("Modules"); 229 config.AddConfig("Modules");
230 config.AddConfig("InventoryService"); 230 config.AddConfig("InventoryService");
231 config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); 231 config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector");
@@ -418,4 +418,5 @@ namespace OpenSim.Tests.Common.Setup
418 sogd.InventoryDeQueueAndDelete(); 418 sogd.InventoryDeQueueAndDelete();
419 } 419 }
420 } 420 }
421
421} 422}
diff --git a/OpenSim/Tests/Common/TestLogging.cs b/OpenSim/Tests/Common/TestLogging.cs
new file mode 100644
index 0000000..4a08344
--- /dev/null
+++ b/OpenSim/Tests/Common/TestLogging.cs
@@ -0,0 +1,46 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31using log4net.Appender;
32using log4net.Layout;
33
34namespace OpenSim.Tests.Common
35{
36 public static class TestLogging
37 {
38 public static void LogToConsole()
39 {
40 ConsoleAppender consoleAppender = new ConsoleAppender();
41 consoleAppender.Layout =
42 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
43 log4net.Config.BasicConfigurator.Configure(consoleAppender);
44 }
45 }
46}
diff --git a/bin/OpenSim.ConsoleClient.exe.config b/bin/OpenSim.ConsoleClient.exe.config
new file mode 100644
index 0000000..7aa974c
--- /dev/null
+++ b/bin/OpenSim.ConsoleClient.exe.config
@@ -0,0 +1,33 @@
1<?xml version="1.0" encoding="utf-8" ?>
2<configuration>
3 <configSections>
4 <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
5 </configSections>
6 <runtime>
7 <gcConcurrent enabled="true" />
8 <gcServer enabled="true" />
9 </runtime>
10 <appSettings>
11 </appSettings>
12 <log4net>
13 <appender name="Console" type="OpenSim.Framework.Console.OpenSimAppender, OpenSim.Framework.Console">
14 <layout type="log4net.Layout.PatternLayout">
15 <conversionPattern value="%date{HH:mm:ss} - %message%newline" />
16 </layout>
17 </appender>
18
19 <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
20 <file value="OpenSim.ConsoleClient.log" />
21 <appendToFile value="true" />
22 <layout type="log4net.Layout.PatternLayout">
23 <conversionPattern value="%date %-5level - %logger %message%newline" />
24 </layout>
25 </appender>
26
27 <root>
28 <level value="DEBUG" />
29 <appender-ref ref="Console" />
30 <appender-ref ref="LogFileAppender" />
31 </root>
32 </log4net>
33</configuration>
diff --git a/bin/OpenSim.ConsoleClient.ini.example b/bin/OpenSim.ConsoleClient.ini.example
new file mode 100644
index 0000000..beea7d8
--- /dev/null
+++ b/bin/OpenSim.ConsoleClient.ini.example
@@ -0,0 +1 @@
[Startup]
diff --git a/bin/OpenSim.Data.NHibernate.Tests.dll.config b/bin/OpenSim.Data.NHibernate.Tests.dll.config
index a3f681d..9b3231f 100644
--- a/bin/OpenSim.Data.NHibernate.Tests.dll.config
+++ b/bin/OpenSim.Data.NHibernate.Tests.dll.config
@@ -26,7 +26,7 @@
26 26
27 <!-- Set root logger level to DEBUG and its only appender to A1 --> 27 <!-- Set root logger level to DEBUG and its only appender to A1 -->
28 <root> 28 <root>
29 <level value="DEBUG" /> 29 <level value="Info" />
30 <appender-ref ref="A1" /> 30 <appender-ref ref="A1" />
31 </root> 31 </root>
32 </log4net> 32 </log4net>
diff --git a/bin/OpenSim.Server.ini.example b/bin/OpenSim.Server.ini.example
index f0c0de9..aab0566 100644
--- a/bin/OpenSim.Server.ini.example
+++ b/bin/OpenSim.Server.ini.example
@@ -14,6 +14,12 @@ ServiceConnectors = "OpenSim.Server.Handlers.dll:AssetServiceConnector,OpenSim.S
14[Network] 14[Network]
15port = 8003 15port = 8003
16 16
17; * The following are for the remote console
18; * They have no effect for the local or basic console types
19; * Leave commented to diable logins to the console
20;ConsoleUser = Test
21;ConsolePass = secret
22
17; * As an example, the below configuration precisely mimicks the legacy 23; * As an example, the below configuration precisely mimicks the legacy
18; * asset server. It is read by the asset IN connector (defined above) 24; * asset server. It is read by the asset IN connector (defined above)
19; * and it then loads the OUT connector (a local database module). That, 25; * and it then loads the OUT connector (a local database module). That,
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index db993b4..a1532c5 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -292,6 +292,8 @@
292 LibrariesXMLFile="./inventory/Libraries.xml" 292 LibrariesXMLFile="./inventory/Libraries.xml"
293 293
294[Network] 294[Network]
295 ConsoleUser = "Test"
296 ConsolePass = "secret"
295 http_listener_port = 9000 297 http_listener_port = 9000
296 default_location_x = 1000 298 default_location_x = 1000
297 default_location_y = 1000 299 default_location_y = 1000
diff --git a/prebuild.xml b/prebuild.xml
index eff16ad..6401ff0 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -105,9 +105,12 @@
105 105
106 <ReferencePath>../../../bin/</ReferencePath> 106 <ReferencePath>../../../bin/</ReferencePath>
107 <Reference name="System"/> 107 <Reference name="System"/>
108 <Reference name="System.Xml"/>
109 <Reference name="System.Web"/>
108 <Reference name="log4net.dll"/> 110 <Reference name="log4net.dll"/>
109 <Reference name="Nini.dll"/> 111 <Reference name="Nini.dll"/>
110 <Reference name="OpenSim.Framework.Servers.HttpServer"/> 112 <Reference name="OpenSim.Framework.Servers.HttpServer"/>
113 <Reference name="OpenMetaverseTypes.dll"/>
111 <Files> 114 <Files>
112 <Match pattern="*.cs" recurse="true"/> 115 <Match pattern="*.cs" recurse="true"/>
113 </Files> 116 </Files>
@@ -1593,6 +1596,38 @@
1593 </Files> 1596 </Files>
1594 </Project> 1597 </Project>
1595 1598
1599 <Project frameworkVersion="v3_5" name="OpenSim.ConsoleClient" path="OpenSim/ConsoleClient" type="Exe">
1600 <Configuration name="Debug">
1601 <Options>
1602 <OutputPath>../../bin/</OutputPath>
1603 </Options>
1604 </Configuration>
1605 <Configuration name="Release">
1606 <Options>
1607 <OutputPath>../../bin/</OutputPath>
1608 </Options>
1609 </Configuration>
1610
1611 <ReferencePath>../../bin/</ReferencePath>
1612 <Reference name="System"/>
1613 <Reference name="System.Xml"/>
1614 <Reference name="OpenMetaverseTypes.dll"/>
1615 <Reference name="OpenMetaverse.dll"/>
1616 <Reference name="OpenMetaverse.StructuredData.dll"/>
1617 <Reference name="OpenSim.Framework"/>
1618 <Reference name="OpenSim.Framework.Console"/>
1619 <Reference name="OpenSim.Framework.Servers.HttpServer"/>
1620 <Reference name="OpenSim.Server.Base"/>
1621 <Reference name="Nini.dll" />
1622 <Reference name="log4net.dll"/>
1623
1624 <Files>
1625 <Match pattern="*.cs" recurse="false">
1626 <Exclude pattern="Tests" />
1627 </Match>
1628 </Files>
1629 </Project>
1630
1596 <Project frameworkVersion="v3_5" name="OpenSim.Region.CoreModules" path="OpenSim/Region/CoreModules" type="Library"> 1631 <Project frameworkVersion="v3_5" name="OpenSim.Region.CoreModules" path="OpenSim/Region/CoreModules" type="Library">
1597 <Configuration name="Debug"> 1632 <Configuration name="Debug">
1598 <Options> 1633 <Options>
@@ -3335,6 +3370,7 @@
3335 <Reference name="OpenSim.Data"/> 3370 <Reference name="OpenSim.Data"/>
3336 <Reference name="OpenSim.Region.Framework"/> 3371 <Reference name="OpenSim.Region.Framework"/>
3337 <Reference name="OpenSim.Region.CoreModules"/> 3372 <Reference name="OpenSim.Region.CoreModules"/>
3373 <Reference name="OpenSim.Tests.Common"/>
3338 <Reference name="log4net.dll"/> 3374 <Reference name="log4net.dll"/>
3339 <Reference name="Mono.Addins.dll" /> 3375 <Reference name="Mono.Addins.dll" />
3340 <Reference name="nunit.framework.dll" /> 3376 <Reference name="nunit.framework.dll" />